@beamimpact/web-sdk 1.58.2 → 1.58.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{_share-dialog-dependencies-C3oAeUgm.esm.js → _share-dialog-dependencies-CnECvqGU.esm.js} +2 -2
- package/dist/chunks/{_share-dialog-dependencies-C3oAeUgm.esm.js.map → _share-dialog-dependencies-CnECvqGU.esm.js.map} +1 -1
- package/dist/chunks/index-B80gyym6.esm.js +2 -0
- package/dist/chunks/{index-PWwahCdj.esm.js.map → index-B80gyym6.esm.js.map} +1 -1
- package/dist/chunks/{index-hCVICwBS.esm.js → index-CAt4jZhL.esm.js} +2 -2
- package/dist/chunks/{index-hCVICwBS.esm.js.map → index-CAt4jZhL.esm.js.map} +1 -1
- package/dist/chunks/{index-C6QfHWnX.esm.js → index-CfQMEz6F.esm.js} +2 -2
- package/dist/chunks/{index-C6QfHWnX.esm.js.map → index-CfQMEz6F.esm.js.map} +1 -1
- package/dist/chunks/index-Ct2Qv5IG.esm.js +2 -0
- package/dist/chunks/index-Ct2Qv5IG.esm.js.map +1 -0
- package/dist/chunks/index-D5-gztaa.esm.js +31 -0
- package/dist/chunks/{index-BlaOItQr.esm.js.map → index-D5-gztaa.esm.js.map} +1 -1
- package/dist/chunks/index-D7D-ELzP.esm.js +2 -0
- package/dist/chunks/{index-B2GUlwwp.esm.js.map → index-D7D-ELzP.esm.js.map} +1 -1
- package/dist/chunks/{index-DC8IegOb.esm.js → index-MJhOu5my.esm.js} +2 -2
- package/dist/chunks/{index-DC8IegOb.esm.js.map → index-MJhOu5my.esm.js.map} +1 -1
- package/dist/chunks/{index-BtG64tE0.esm.js → index-mVF3RTDz.esm.js} +2 -2
- package/dist/chunks/{index-BtG64tE0.esm.js.map → index-mVF3RTDz.esm.js.map} +1 -1
- package/dist/chunks/{promo-pill-label-rA01UjBk.esm.js → promo-pill-label-BBi4qq7M.esm.js} +2 -2
- package/dist/chunks/{promo-pill-label-rA01UjBk.esm.js.map → promo-pill-label-BBi4qq7M.esm.js.map} +1 -1
- package/dist/chunks/{share-button-BxrZs18u.esm.js → share-button-CpcTaNLx.esm.js} +2 -2
- package/dist/chunks/{share-button-BxrZs18u.esm.js.map → share-button-CpcTaNLx.esm.js.map} +1 -1
- package/dist/chunks/{share-button-DQT2zQ7w.esm.js → share-button-ivUcw9Vw.esm.js} +11 -7
- package/dist/chunks/share-button-ivUcw9Vw.esm.js.map +1 -0
- package/dist/components/community-impact.esm.js +1 -1
- package/dist/components/community-impact.js +1 -1
- package/dist/components/cumulative-impact.esm.js +35 -26
- package/dist/components/cumulative-impact.esm.js.map +1 -1
- package/dist/components/cumulative-impact.js +35 -26
- package/dist/components/cumulative-impact.js.map +1 -1
- package/dist/components/impact-overview.esm.js +1 -1
- package/dist/components/impact-overview.js +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +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.esm.js +1 -1
- package/dist/components/product-details-page.js +1 -1
- package/dist/components/redeem-transaction.esm.js +1 -1
- package/dist/components/redeem-transaction.js +1 -1
- package/dist/components/select-nonprofit.esm.js +3 -3
- package/dist/components/select-nonprofit.js +3 -3
- package/dist/components/select-subscription-nonprofit.esm.js +5 -4
- package/dist/components/select-subscription-nonprofit.esm.js.map +1 -1
- package/dist/components/select-subscription-nonprofit.js +5 -4
- package/dist/components/select-subscription-nonprofit.js.map +1 -1
- package/dist/components/shopify.esm.js +1 -1
- package/dist/components/shopify.js +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.esm.js +1 -1
- package/dist/components/subscriber-select-nonprofit.js +1 -1
- package/dist/components/subscription-impact.esm.js +14 -13
- package/dist/components/subscription-impact.esm.js.map +1 -1
- package/dist/components/subscription-impact.js +14 -13
- package/dist/components/subscription-impact.js.map +1 -1
- package/dist/components/subscription-management.esm.js +15 -11
- package/dist/components/subscription-management.esm.js.map +1 -1
- package/dist/components/subscription-management.js +15 -11
- package/dist/components/subscription-management.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/beam.esm.js +1 -1
- package/dist/integrations/beam.js +1 -1
- package/dist/integrations/cart.esm.js +1 -1
- package/dist/integrations/cart.js +1 -1
- package/dist/integrations/logs.esm.js +1 -1
- package/dist/integrations/logs.js +1 -1
- package/dist/integrations/shopify-order.esm.js +1 -1
- package/dist/integrations/shopify-order.js +1 -1
- package/dist/integrations/shopify.esm.js +1 -1
- package/dist/integrations/shopify.js +1 -1
- package/dist/integrations/statsig.esm.js +1 -1
- package/dist/integrations/statsig.js +1 -1
- package/dist/react/community-impact.esm.js +1 -1
- package/dist/react/community-impact.js +1 -1
- package/dist/react/cumulative-impact.esm.js +1 -1
- package/dist/react/cumulative-impact.js +1 -1
- package/dist/react/impact-overview.esm.js +1 -1
- package/dist/react/impact-overview.js +1 -1
- package/dist/react/index.esm.js +1 -1
- package/dist/react/index.js +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.esm.js +1 -1
- package/dist/react/product-details-page.js +1 -1
- package/dist/react/redeem-transaction.esm.js +1 -1
- package/dist/react/redeem-transaction.js +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.esm.js +1 -1
- package/dist/react/select-subscription-nonprofit.js +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.esm.js +1 -1
- package/dist/react/subscriber-select-nonprofit.js +1 -1
- package/dist/react/subscription-impact.esm.js +1 -1
- package/dist/react/subscription-impact.js +1 -1
- package/dist/react/subscription-management.esm.js +1 -1
- package/dist/react/subscription-management.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/index-B2GUlwwp.esm.js +0 -2
- package/dist/chunks/index-BhlTVL8_.esm.js +0 -2
- package/dist/chunks/index-BhlTVL8_.esm.js.map +0 -1
- package/dist/chunks/index-BlaOItQr.esm.js +0 -31
- package/dist/chunks/index-PWwahCdj.esm.js +0 -2
- package/dist/chunks/share-button-DQT2zQ7w.esm.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cumulative-impact.js","sources":["../../src/shared/components/animated-counter/index.ts","../../src/shared/sync-element-widths.ts","../../src/components/cumulative-impact/strings.ts","../../src/components/cumulative-impact/index.ts"],"sourcesContent":["import { html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators.js\";\n\nexport class AnimatedCounter extends LitElement {\n @property({ type: Number }) finalValue = 0;\n @property({ type: Number }) duration = 1500;\n @property({ type: String }) scrollTarget?: string;\n\n @state() protected counter = 0;\n private intervalId = 0;\n\n connectedCallback() {\n super.connectedCallback();\n const userPrefersReducedMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n if (this.duration === 0 || userPrefersReducedMotion) {\n this.counter = this.finalValue;\n } else {\n this.observeScrollTarget();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.unobserveScrollTarget();\n clearInterval(this.intervalId);\n }\n\n private handleCounterAnimateIfInView: IntersectionObserverCallback = (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n this.animateCounter();\n this.unobserveScrollTarget();\n }\n };\n\n private animateCounter = () => {\n const ANIMATION_FRAME_RATE = 24;\n const MS_PER_FRAME = 1000 / ANIMATION_FRAME_RATE;\n const INCREMENT_RATE_PER_FRAME = MS_PER_FRAME / this.duration;\n const COUNTER_INCREMENT_PER_FRAME = INCREMENT_RATE_PER_FRAME * this.finalValue;\n\n this.intervalId = setInterval(() => {\n const result = this.counter + COUNTER_INCREMENT_PER_FRAME;\n if (result >= this.finalValue) {\n this.counter = this.finalValue;\n clearInterval(this.intervalId);\n return;\n } else {\n this.counter = result;\n }\n }, MS_PER_FRAME);\n };\n\n private observer = new IntersectionObserver(this.handleCounterAnimateIfInView, {\n threshold: 0.1,\n });\n\n private observeScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.observe(target);\n };\n\n private unobserveScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.unobserve(target);\n };\n\n get scrollTargetElement(): this | Element | null {\n if (this.scrollTarget) {\n return document.querySelector(this.scrollTarget);\n } else {\n return this;\n }\n }\n\n render() {\n return html`${Math.ceil(this.counter).toLocaleString()}`;\n }\n}\n\ncustomElements.get(\"animated-counter\") || customElements.define(\"animated-counter\", AnimatedCounter);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"animated-counter\": AnimatedCounter;\n }\n}\n","import { isAllHtmlElements } from \"./is-all-html-elements\";\n\n/**\n * Synchronize widths of elements\n * @param {Array<HTMLElement|null>} elements - Elements to synchronize\n */\nexport const syncElementWidths = (elements: Array<HTMLElement | null> | NodeList) => {\n const els = elements instanceof NodeList ? Array.from(elements) : elements;\n\n if (els.length === 0 || !isAllHtmlElements(els)) {\n return;\n }\n\n const widthSource = els.sort((a, b) => {\n const widthA = getComputedStyle(a).getPropertyValue(\"width\").replace(\"px\", \"\");\n const widthB = getComputedStyle(b).getPropertyValue(\"width\").replace(\"px\", \"\");\n return parseInt(widthB) - parseInt(widthA);\n })[0];\n\n const syncedWidth = getComputedStyle(widthSource).getPropertyValue(\"width\");\n\n for (const el of els) {\n if (getComputedStyle(el).getPropertyValue(\"width\") !== syncedWidth) {\n el.style[\"width\"] = syncedWidth;\n }\n }\n};\n","export const strings = {\n en: {\n cumulativeImpactTitle: () => `What we've funded`,\n cumulativeImpactDescription: () =>\n \"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day— scroll to check out the goals we're working toward together right now.\",\n },\n fr: {\n cumulativeImpactTitle: () => `Ce que nous avons financé`,\n cumulativeImpactDescription: () =>\n \"Voici l'impact que notre communauté a eu jusqu'à présent en partenariat avec Beam. Notre impact grandit chaque jour : faites défiler pour découvrir les objectifs vers lesquels nous travaillons ensemble en ce moment.\",\n },\n de: {\n cumulativeImpactTitle: () => `Was wir finanziert haben`,\n cumulativeImpactDescription: () =>\n \"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung wächst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten.\",\n },\n es: {\n cumulativeImpactTitle: () => `Lo que hemos financiado`,\n cumulativeImpactDescription: () =>\n \"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociación con Beam. Nuestro impacto crece cada día; desplácese para ver los objetivos por los que estamos trabajando juntos en este momento.\",\n },\n it: {\n cumulativeImpactTitle: () => `Cosa abbiamo finanziato`,\n cumulativeImpactDescription: () =>\n \"Ecco l'impatto che la nostra comunità ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento.\",\n },\n pl: {\n cumulativeImpactTitle: () => `Co sfinansowaliśmy`,\n cumulativeImpactDescription: () =>\n \"Oto wpływ, jaki nasza społeczność wywarła dotychczas we współpracy z Beam. Nasz wpływ rośnie z każdym dniem — przewiń, aby sprawdzić cele, nad którymi obecnie wspólnie pracujemy.\",\n },\n ja: {\n cumulativeImpactTitle: () => `What we've funded`,\n cumulativeImpactDescription: () =>\n \"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day— scroll to check out the goals we're working toward together right now.\",\n },\n};\n","import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { queryAll } from \"lit/decorators/query-all.js\";\nimport debounce from \"lodash-es/debounce\";\nimport \"../../shared/components/animated-counter\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { DEFAULT_BASE_URL, SUPPORTED_LANGUAGES } from \"../../api-sdk/constants\";\nimport { TNumericId } from \"../../shared/types\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { getCumulativeImpact } from \"../../api-sdk/v3/routes\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { BeamError, MissingConfig } from \"../../utils/beam-errors\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { _loading } from \"../../shared/fragments/loading-template\";\nimport { syncElementWidths } from \"../../shared/sync-element-widths\";\nimport { localizeUserString } from \"../../shared/localize\";\nimport { defineCustomText, useCustomText } from \"../../shared/fragments/custom-text\";\nimport { strings } from \"./strings\";\n\ntype RequiredConfig = {\n apiKey: string;\n chainId: TNumericId;\n};\n\ntype IAPIV3CumulativeImpact = Awaited<ReturnType<typeof getCumulativeImpact>>;\n\nconst MAX_COUNTER_ANIMATION_DURATION = 1.5 * 1000;\n\nexport class BeamCumulativeImpact extends LitElement {\n static tagName = \"beam-cumulative-impact\";\n\n @property({ type: String }) public apiKey?: RequiredConfig[\"apiKey\"];\n\n @property({ type: Number }) public chainId?: RequiredConfig[\"chainId\"];\n\n @property({ type: String }) public baseUrl = DEFAULT_BASE_URL;\n\n @property({ type: String }) public lang: LANGUAGES = \"en\";\n\n @property({ type: Boolean }) public disableAnimation = false;\n\n @property({ type: Boolean }) public debug = false;\n\n @property({ type: Boolean }) public draftConfig = false;\n\n get configLang() {\n return SUPPORTED_LANGUAGES[this.lang] || \"en\";\n }\n\n private getCumulativeImpactData = async () => {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"chainId\"], this)) {\n throw new MissingConfig();\n }\n const res = await getCumulativeImpact({\n baseUrl: this.baseUrl,\n pathParams: {\n chainId: this.chainId,\n },\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n queryParams: {\n version: \"1.0.0\",\n lang: this.configLang,\n draftConfig: this.draftConfig,\n },\n });\n\n return res;\n };\n\n private cumulativeImpactDataController = new AsyncController<typeof this.getCumulativeImpactData>(\n this,\n this.getCumulativeImpactData,\n );\n\n @queryAll(\".impact-row-value-container\")\n impactRowRefs!: HTMLElement[];\n resizeElements = debounce(\n () => {\n syncElementWidths(this.impactRowRefs);\n },\n 50,\n { maxWait: 50, leading: true },\n );\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener(\"resize\", this.resizeElements);\n }\n\n async updated(changedProperties: Map<string, unknown>) {\n // Reload nonprofit list on change of any of these props:\n // Also fires on first load as props go from undefined => value\n const requireNewDataProps = [\"chainId\", \"baseUrl\", \"lang\"];\n for (const prop of requireNewDataProps) {\n if (changedProperties.has(prop)) {\n await this.cumulativeImpactDataController.exec();\n break;\n }\n }\n\n this.resizeElements();\n }\n\n render() {\n const { data, error, loading } = this.cumulativeImpactDataController;\n if (loading) {\n return _loading();\n }\n if (error) {\n if (this.debug) {\n return _errorMessage({ error });\n }\n return \"\";\n }\n if (data == null) {\n if (this.debug) {\n return _errorMessage({ error: new BeamError(\"Missing data\") });\n }\n return \"\";\n }\n\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div style=\"display: flex; flex-direction: column;\" class=\"root\">\n <div\n style=\"margin: 10px 0 0 0;\"\n tabindex=\"-1\"\n class=\"options\"\n part=\"options\"\n aria-labelledby=\"beam-RedeemTransaction-title\"\n >\n ${this.renderCumulativeImpact(data)}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpact(data: IAPIV3CumulativeImpact) {\n const rawValues = data.impacts ? data.impacts?.map((impact) => impact.value || 0) : [];\n const maxRawValue = Math.max(...rawValues);\n const durations = rawValues.map(\n (val) => (MAX_COUNTER_ANIMATION_DURATION * Math.log(Math.max(val, 1))) / Math.log(maxRawValue),\n );\n return html`\n <div class=\"main\">\n <div class=\"title\" role=\"heading\">\n ${localizeUserString(this.configLang, data?.config?.web?.title || \"\") ||\n strings[this.configLang].cumulativeImpactTitle()}\n </div>\n <p class=\"description\">\n ${localizeUserString(this.configLang, data?.config?.web?.description || \"\") ||\n strings[this.configLang].cumulativeImpactDescription()}\n </p>\n <div class=\"impact-list\">\n ${data.impacts?.map((impact: any, idx: number) => {\n return this.renderCumulativeImpactRow({ impact, animationDuration: durations[idx] });\n })}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpactRow({ impact, animationDuration }: { impact: any; animationDuration: number }) {\n const disableAnimation = this.cumulativeImpactDataController.data?.config?.web.disableAnimation;\n const floatingCounterClass = \"impact-row-value-counter impact-row-value-floating-counter\";\n const duration = disableAnimation ? 0 : animationDuration;\n\n const unitDisplay = localizeUserString(this.configLang, impact.unit || \"\");\n const summaryDisplay = localizeUserString(this.configLang, impact.summary || \"\");\n\n /**\n * because we set the width using JavaScript by forcing all impact-row-value-container elements\n * to match the width of the widest sibling, we use a hidden span with the total preloaded to\n * ensure that impact-row-value-container widths do not change as the animation runs.\n */\n return html`\n <div class=\"impact-row\">\n <div class=\"impact-row-value-container\">\n <span class=\"impact-row-value-counter\" style=\"visibility: hidden;\" aria-hidden=\"true\">\n ${impact.value.toLocaleString()}\n </span>\n <animated-counter\n class=\"${floatingCounterClass}\"\n finalValue=${impact.value}\n duration=${duration}\n ></animated-counter>\n </span>\n </div>\n <div class=\"impact-row-description\">${unitDisplay} ${summaryDisplay}</div>\n </div>\n `;\n }\n\n public get cssVariables() {\n const defaults: Record<string, string> = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"16px\",\n \"--beam-lineHeight\": \"1\",\n \"--beam-textColor\": \"inherit\",\n // main\n ...defineCustomText(\"--beam-CumulativeImpact-title\", {\n fontSize: \"32px\",\n }),\n ...defineCustomText(\"--beam-CumulativeImpact-description\", {\n marginTop: \"16px\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-impact-list-marginTop\": \"24px\",\n \"--beam-CumulativeImpact-row-marginTop\": \"24px\",\n // row value container\n \"--beam-CumulativeImpact-row-value-container-borderBottomWidth\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-borderBottomColor\": \"currentColor\",\n \"--beam-CumulativeImpact-row-value-container-paddingTop\": \"0\",\n \"--beam-CumulativeImpact-row-value-container-paddingRight\": \"20px\",\n \"--beam-CumulativeImpact-row-value-container-paddingBottom\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-paddingLeft\": \"20px\",\n // row value counter\n ...defineCustomText(\"--beam-CumulativeImpact-row-value-counter\", {\n color: \"currentColor\",\n fontSize: \"24px\",\n fontWeight: \"normal\",\n }),\n // row description\n ...defineCustomText(\"--beam-CumulativeImpact-row-description\", {\n color: \"currentColor\",\n fontSize: \"16px\",\n fontWeight: \"normal\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-row-description-paddingLeft\": \"24px\",\n \"--beam-CumulativeImpact-row-description-paddingRight\": \"24px\",\n \"--beam-CumulativeImpact-row-description-mobile-marginTop\": \"12px\",\n };\n\n const remoteConfig = this.cumulativeImpactDataController.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n css`\n :host {\n display: block;\n font-family: var(--beam-fontFamily, inherit);\n font-style: var(--beam-fontStyle, inherit);\n font-size: var(--beam-fontSize, inherit);\n color: var(--beam-textColor, inherit);\n background-color: var(--beam-backgroundColor, inherit);\n line-height: var(--beam-lineHeight, 1);\n word-break: normal;\n }\n .main {\n text-align: left;\n }\n .title {\n ${useCustomText(\"--beam-CumulativeImpact-title\")}\n text-align: inherit;\n }\n .description {\n ${useCustomText(\"--beam-CumulativeImpact-description\")}\n text-align: inherit;\n }\n .impact-list {\n display: flex;\n flex-direction: column;\n margin-top: var(--beam-CumulativeImpact-impact-list-marginTop);\n }\n .impact-row {\n display: flex;\n align-items: center;\n margin-top: var(--beam-CumulativeImpact-row-marginTop);\n }\n .impact-row-value-container {\n position: relative;\n border-bottom-width: var(--beam-CumulativeImpact-row-value-container-borderBottomWidth);\n border-bottom-color: var(--beam-CumulativeImpact-row-value-container-borderBottomColor);\n border-bottom-style: solid;\n padding-top: var(--beam-CumulativeImpact-row-value-container-paddingTop);\n padding-right: var(--beam-CumulativeImpact-row-value-container-paddingRight);\n padding-bottom: var(--beam-CumulativeImpact-row-value-container-paddingBottom);\n padding-left: var(--beam-CumulativeImpact-row-value-container-paddingLeft);\n text-align: center;\n flex-shrink: 0;\n }\n .impact-row-value-counter {\n ${useCustomText(\"--beam-CumulativeImpact-row-value-counter\")}\n }\n .impact-row-value-floating-counter {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n .impact-row-description {\n ${useCustomText(\"--beam-CumulativeImpact-row-description\")}\n padding-left: var(--beam-CumulativeImpact-row-description-paddingLeft);\n padding-right: var(--beam-CumulativeImpact-row-description-paddingRight);\n /* match padding of value of counter for proper centering */\n padding-bottom: var(--beam-CumulativeImpact-row-value-paddingBottom);\n text-align: inherit;\n flex-grow: 1;\n }\n @media (max-width: 500px) {\n .main {\n text-align: center;\n }\n .impact-row {\n flex-direction: column;\n }\n .impact-row-description {\n margin-top: var(--beam-CumulativeImpact-row-description-mobile-marginTop);\n padding-bottom: 0;\n }\n }\n `,\n ];\n}\n\ndefineCustomElement(BeamCumulativeImpact);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-cumulative-impact\": BeamCumulativeImpact;\n }\n}\n"],"names":["AnimatedCounter","LitElement","entries","entry","MS_PER_FRAME","COUNTER_INCREMENT_PER_FRAME","result","target","userPrefersReducedMotion","html","__decorateClass","property","state","syncElementWidths","elements","els","isAllHtmlElements","widthSource","a","b","widthA","widthB","syncedWidth","el","strings","f","r","s","m","e","MAX_COUNTER_ANIMATION_DURATION","BeamCumulativeImpact","DEFAULT_BASE_URL","enforceConfig","getCumulativeImpact","AsyncController","debounce","SUPPORTED_LANGUAGES","changedProperties","requireNewDataProps","prop","data","error","loading","_loading","_errorMessage","BeamError","rawValues","impact","maxRawValue","durations","val","localizeUserString","idx","animationDuration","disableAnimation","floatingCounterClass","duration","unitDisplay","summaryDisplay","defaults","defineCustomText","remoteConfig","config","_cssVariableMap","cssReset","css","useCustomText","queryAll","defineCustomElement"],"mappings":"sgBAIaA,UAAwBC,CAAW,CAAzC,aAAA,CAAA,MAAA,GAAA,SAAA,EACuB,KAAA,WAAa,EACb,KAAA,SAAW,KAG9B,KAAU,QAAU,EAC7B,KAAQ,WAAa,EAkBrB,KAAQ,6BAA8DC,GAAY,CAC5EA,EAAQ,KAAMC,GAAUA,EAAM,cAAc,IAC9C,KAAK,eAAA,EACL,KAAK,sBAAA,EAET,EAEA,KAAQ,eAAiB,IAAM,CAE7B,MAAMC,EAAe,mBAEfC,EAD2BD,EAAe,KAAK,SACU,KAAK,WAEpE,KAAK,WAAa,YAAY,IAAM,CAClC,MAAME,EAAS,KAAK,QAAUD,EAC9B,GAAIC,GAAU,KAAK,WAAY,CAC7B,KAAK,QAAU,KAAK,WACpB,cAAc,KAAK,UAAU,EAC7B,MACF,MACE,KAAK,QAAUA,CAEnB,EAAGF,CAAY,CACjB,EAEA,KAAQ,SAAW,IAAI,qBAAqB,KAAK,6BAA8B,CAC7E,UAAW,EACb,CAAC,EAED,KAAQ,oBAAsB,IAAM,CAClC,MAAMG,EAAS,KAAK,oBACpBA,GAAU,KAAK,SAAS,QAAQA,CAAM,CACxC,EAEA,KAAQ,sBAAwB,IAAM,CACpC,MAAMA,EAAS,KAAK,oBACpBA,GAAU,KAAK,SAAS,UAAUA,CAAM,CAC1C,CAAA,CArDA,mBAAoB,CAClB,MAAM,oBACN,MAAMC,EAA2B,OAAO,WAAW,kCAAkC,EAAE,QACnF,KAAK,WAAa,GAAKA,EACzB,KAAK,QAAU,KAAK,WAEpB,KAAK,oBAAA,CAET,CAEA,sBAAuB,CACrB,MAAM,qBAAA,EACN,KAAK,sBAAA,EACL,cAAc,KAAK,UAAU,CAC/B,CAyC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B,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EAXhBoB,EAWyB,UAAA,kBAAA,EAEArB,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EAbhBoB,EAayB,UAAA,OAAA,EAEArB,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EAfhBoB,EAeyB,UAAA,aAAA,EAkCpCrB,EAAA,CADC0D,EAAS,6BAA6B,GAhD5BrC,EAiDX,UAAA,eAAA,EAkQFsC,EAAoBtC,CAAoB"}
|
|
1
|
+
{"version":3,"file":"cumulative-impact.js","sources":["../../src/shared/components/animated-counter/index.ts","../../src/shared/sync-element-widths.ts","../../src/components/cumulative-impact/strings.ts","../../src/components/cumulative-impact/index.ts"],"sourcesContent":["import { html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators.js\";\n\nexport class AnimatedCounter extends LitElement {\n @property({ type: Number }) finalValue = 0;\n @property({ type: Number }) duration = 1500;\n @property({ type: String }) scrollTarget?: string;\n\n @state() protected counter = 0;\n private intervalId = 0;\n\n connectedCallback() {\n super.connectedCallback();\n const userPrefersReducedMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n if (this.duration === 0 || userPrefersReducedMotion) {\n this.counter = this.finalValue;\n } else {\n this.observeScrollTarget();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.unobserveScrollTarget();\n clearInterval(this.intervalId);\n }\n\n private handleCounterAnimateIfInView: IntersectionObserverCallback = (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n this.animateCounter();\n this.unobserveScrollTarget();\n }\n };\n\n private animateCounter = () => {\n const ANIMATION_FRAME_RATE = 24;\n const MS_PER_FRAME = 1000 / ANIMATION_FRAME_RATE;\n const INCREMENT_RATE_PER_FRAME = MS_PER_FRAME / this.duration;\n const COUNTER_INCREMENT_PER_FRAME = INCREMENT_RATE_PER_FRAME * this.finalValue;\n\n this.intervalId = setInterval(() => {\n const result = this.counter + COUNTER_INCREMENT_PER_FRAME;\n if (result >= this.finalValue) {\n this.counter = this.finalValue;\n clearInterval(this.intervalId);\n return;\n } else {\n this.counter = result;\n }\n }, MS_PER_FRAME);\n };\n\n private observer = new IntersectionObserver(this.handleCounterAnimateIfInView, {\n threshold: 0.1,\n });\n\n private observeScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.observe(target);\n };\n\n private unobserveScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.unobserve(target);\n };\n\n get scrollTargetElement(): this | Element | null {\n if (this.scrollTarget) {\n return document.querySelector(this.scrollTarget);\n } else {\n return this;\n }\n }\n\n render() {\n return html`${Math.ceil(this.counter).toLocaleString()}`;\n }\n}\n\ncustomElements.get(\"animated-counter\") || customElements.define(\"animated-counter\", AnimatedCounter);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"animated-counter\": AnimatedCounter;\n }\n}\n","import { isAllHtmlElements } from \"./is-all-html-elements\";\n\n/**\n * Synchronize widths of elements\n * @param {Array<HTMLElement|null>} elements - Elements to synchronize\n */\nexport const syncElementWidths = (elements: Array<HTMLElement | null> | NodeList) => {\n const els = elements instanceof NodeList ? Array.from(elements) : elements;\n\n if (els.length === 0 || !isAllHtmlElements(els)) {\n return;\n }\n\n const widthSource = els.sort((a, b) => {\n const widthA = getComputedStyle(a).getPropertyValue(\"width\").replace(\"px\", \"\");\n const widthB = getComputedStyle(b).getPropertyValue(\"width\").replace(\"px\", \"\");\n return parseInt(widthB) - parseInt(widthA);\n })[0];\n\n const syncedWidth = getComputedStyle(widthSource).getPropertyValue(\"width\");\n\n for (const el of els) {\n if (getComputedStyle(el).getPropertyValue(\"width\") !== syncedWidth) {\n el.style[\"width\"] = syncedWidth;\n }\n }\n};\n","export const strings = {\n en: {\n cumulativeImpactTitle: () => `What we've funded`,\n cumulativeImpactDescription: () =>\n \"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day— scroll to check out the goals we're working toward together right now.\",\n },\n fr: {\n cumulativeImpactTitle: () => `Ce que nous avons financé`,\n cumulativeImpactDescription: () =>\n \"Voici l'impact que notre communauté a eu jusqu'à présent en partenariat avec Beam. Notre impact grandit chaque jour : faites défiler pour découvrir les objectifs vers lesquels nous travaillons ensemble en ce moment.\",\n },\n de: {\n cumulativeImpactTitle: () => `Was wir finanziert haben`,\n cumulativeImpactDescription: () =>\n \"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung wächst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten.\",\n },\n es: {\n cumulativeImpactTitle: () => `Lo que hemos financiado`,\n cumulativeImpactDescription: () =>\n \"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociación con Beam. Nuestro impacto crece cada día; desplácese para ver los objetivos por los que estamos trabajando juntos en este momento.\",\n },\n it: {\n cumulativeImpactTitle: () => `Cosa abbiamo finanziato`,\n cumulativeImpactDescription: () =>\n \"Ecco l'impatto che la nostra comunità ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento.\",\n },\n pl: {\n cumulativeImpactTitle: () => `Co sfinansowaliśmy`,\n cumulativeImpactDescription: () =>\n \"Oto wpływ, jaki nasza społeczność wywarła dotychczas we współpracy z Beam. Nasz wpływ rośnie z każdym dniem — przewiń, aby sprawdzić cele, nad którymi obecnie wspólnie pracujemy.\",\n },\n ja: {\n cumulativeImpactTitle: () => `What we've funded`,\n cumulativeImpactDescription: () =>\n \"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day— scroll to check out the goals we're working toward together right now.\",\n },\n};\n","import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { queryAll } from \"lit/decorators/query-all.js\";\nimport debounce from \"lodash-es/debounce\";\nimport \"../../shared/components/animated-counter\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { DEFAULT_BASE_URL, SUPPORTED_LANGUAGES } from \"../../api-sdk/constants\";\nimport { TNumericId } from \"../../shared/types\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { getCumulativeImpact } from \"../../api-sdk/v3/routes\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { BeamError, MissingConfig } from \"../../utils/beam-errors\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { _loading } from \"../../shared/fragments/loading-template\";\nimport { syncElementWidths } from \"../../shared/sync-element-widths\";\nimport { localizeUserString } from \"../../shared/localize\";\nimport { defineCustomText, useCustomText, useCustomTextMap } from \"../../shared/fragments/custom-text\";\nimport { strings } from \"./strings\";\n\ntype RequiredConfig = {\n apiKey: string;\n chainId: TNumericId;\n};\n\ntype IAPIV3CumulativeImpact = Awaited<ReturnType<typeof getCumulativeImpact>>;\n\nconst MAX_COUNTER_ANIMATION_DURATION = 1.5 * 1000;\n\nexport class BeamCumulativeImpact extends LitElement {\n static tagName = \"beam-cumulative-impact\";\n\n @property({ type: String }) public apiKey?: RequiredConfig[\"apiKey\"];\n\n @property({ type: Number }) public chainId?: RequiredConfig[\"chainId\"];\n\n @property({ type: String }) public baseUrl = DEFAULT_BASE_URL;\n\n @property({ type: String }) public lang: LANGUAGES = \"en\";\n\n @property({ type: Boolean }) public disableAnimation = false;\n\n @property({ type: Boolean }) public debug = false;\n\n @property({ type: Boolean }) public draftConfig = false;\n\n get configLang() {\n return SUPPORTED_LANGUAGES[this.lang] || \"en\";\n }\n\n private getCumulativeImpactData = async () => {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"chainId\"], this)) {\n throw new MissingConfig();\n }\n const res = await getCumulativeImpact({\n baseUrl: this.baseUrl,\n pathParams: {\n chainId: this.chainId,\n },\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n queryParams: {\n version: \"1.0.0\",\n lang: this.configLang,\n draftConfig: this.draftConfig,\n },\n });\n\n return res;\n };\n\n private cumulativeImpactDataController = new AsyncController<typeof this.getCumulativeImpactData>(\n this,\n this.getCumulativeImpactData,\n );\n\n @queryAll(\".impact-row-value-container\")\n impactRowRefs!: HTMLElement[];\n resizeElements = debounce(\n () => {\n syncElementWidths(this.impactRowRefs);\n },\n 50,\n { maxWait: 50, leading: true },\n );\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener(\"resize\", this.resizeElements);\n }\n\n async updated(changedProperties: Map<string, unknown>) {\n // Reload nonprofit list on change of any of these props:\n // Also fires on first load as props go from undefined => value\n const requireNewDataProps = [\"chainId\", \"baseUrl\", \"lang\"];\n for (const prop of requireNewDataProps) {\n if (changedProperties.has(prop)) {\n await this.cumulativeImpactDataController.exec();\n break;\n }\n }\n\n this.resizeElements();\n }\n\n render() {\n const { data, error, loading } = this.cumulativeImpactDataController;\n if (loading) {\n return _loading();\n }\n if (error) {\n if (this.debug) {\n return _errorMessage({ error });\n }\n return \"\";\n }\n if (data == null) {\n if (this.debug) {\n return _errorMessage({ error: new BeamError(\"Missing data\") });\n }\n return \"\";\n }\n\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div style=\"display: flex; flex-direction: column;\" class=\"root\">\n <div tabindex=\"-1\" class=\"options\" part=\"options\" aria-labelledby=\"beam-RedeemTransaction-title\">\n ${this.renderCumulativeImpact(data)}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpact(data: IAPIV3CumulativeImpact) {\n const rawValues = data.impacts ? data.impacts?.map((impact) => impact.value || 0) : [];\n const maxRawValue = Math.max(...rawValues);\n const durations = rawValues.map(\n (val) => (MAX_COUNTER_ANIMATION_DURATION * Math.log(Math.max(val, 1))) / Math.log(maxRawValue),\n );\n\n return html`\n <div class=\"main\">\n <div class=\"title\" role=\"heading\">\n ${localizeUserString(this.configLang, data?.config?.web?.title || \"\") ||\n strings[this.configLang].cumulativeImpactTitle()}\n </div>\n <p class=\"description\">\n ${localizeUserString(this.configLang, data?.config?.web?.description || \"\") ||\n strings[this.configLang].cumulativeImpactDescription()}\n </p>\n <div class=\"impact-list\">\n ${data.impacts?.map((impact: any, idx: number) => {\n return this.renderCumulativeImpactRow({ impact, animationDuration: durations[idx] });\n })}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpactRow({ impact, animationDuration }: { impact: any; animationDuration: number }) {\n const disableAnimation = this.cumulativeImpactDataController.data?.config?.web.disableAnimation;\n const floatingCounterClass = \"impact-row-value-counter impact-row-value-floating-counter\";\n const duration = disableAnimation ? 0 : animationDuration;\n\n const unitDisplay = localizeUserString(this.configLang, impact.unit || \"\");\n const summaryDisplay = localizeUserString(this.configLang, impact.summary || \"\");\n\n /**\n * because we set the width using JavaScript by forcing all impact-row-value-container elements\n * to match the width of the widest sibling, we use a hidden span with the total preloaded to\n * ensure that impact-row-value-container widths do not change as the animation runs.\n */\n return html`\n <div class=\"impact-row\">\n <div class=\"impact-row-value-container\">\n <span class=\"impact-row-value-counter\" style=\"visibility: hidden;\" aria-hidden=\"true\">\n ${impact.value.toLocaleString()}\n </span>\n <animated-counter\n class=\"${floatingCounterClass}\"\n finalValue=${impact.value}\n duration=${duration}\n ></animated-counter>\n </span>\n </div>\n <div class=\"impact-row-description\">${unitDisplay} ${summaryDisplay}</div>\n </div>\n `;\n }\n\n public get cssVariables() {\n const defaults: Record<string, string> = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"16px\",\n \"--beam-lineHeight\": \"1\",\n \"--beam-textColor\": \"inherit\",\n \"--beam-CumulativeImpact-margin\": \"10px 0 0 0\",\n // main\n ...defineCustomText(\"--beam-CumulativeImpact-title\", {\n fontSize: \"32px\",\n }),\n \"--beam-CumulativeImpact-title-textAlign\": \"inherit\",\n ...defineCustomText(\"--beam-CumulativeImpact-description\", {\n marginTop: \"16px\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-description-textAlign\": \"inherit\",\n \"--beam-CumulativeImpact-impact-list-marginTop\": \"24px\",\n \"--beam-CumulativeImpact-row-marginTop\": \"24px\",\n // row value container\n \"--beam-CumulativeImpact-row-value-container-borderBottomWidth\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-borderBottomColor\": \"currentColor\",\n \"--beam-CumulativeImpact-row-value-container-paddingTop\": \"0\",\n \"--beam-CumulativeImpact-row-value-container-paddingRight\": \"20px\",\n \"--beam-CumulativeImpact-row-value-container-paddingBottom\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-paddingLeft\": \"20px\",\n // row value counter\n ...defineCustomText(\"--beam-CumulativeImpact-row-value-counter\", {\n color: \"currentColor\",\n fontSize: \"24px\",\n fontWeight: \"normal\",\n }),\n // row description\n ...defineCustomText(\"--beam-CumulativeImpact-row-description\", {\n color: \"currentColor\",\n fontSize: \"16px\",\n fontWeight: \"normal\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-row-description-paddingLeft\": \"24px\",\n \"--beam-CumulativeImpact-row-description-paddingRight\": \"24px\",\n // mobile\n \"--beam-CumulativeImpact-main-mobile-textAlign\": \"center\",\n \"--beam-CumulativeImpact-title-mobile-textAlign\": \"center\",\n \"--beam-CumulativeImpact-description-mobile-textAlign\": \"center\",\n \"--beam-CumulativeImpact-row-mobile-flexDirection\": \"column\",\n \"--beam-CumulativeImpact-row-description-mobile-marginTop\": \"12px\",\n \"--beam-CumulativeImpact-row-description-mobile-paddingBottom\": \"0\",\n \"--beam-CumulativeImpact-row-description-mobile-textAlign\": \"center\",\n };\n\n const remoteConfig = this.cumulativeImpactDataController.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n css`\n :host {\n display: block;\n font-family: var(--beam-fontFamily, inherit);\n font-style: var(--beam-fontStyle, inherit);\n font-size: var(--beam-fontSize, inherit);\n color: var(--beam-textColor, inherit);\n background-color: var(--beam-backgroundColor, inherit);\n line-height: var(--beam-lineHeight, 1);\n word-break: normal;\n margin: var(--beam-CumulativeImpact-margin);\n }\n .main {\n text-align: left;\n }\n .title {\n ${useCustomText(\"--beam-CumulativeImpact-title\")}\n text-align: var(--beam-CumulativeImpact-title-textAlign);\n }\n .description {\n ${useCustomText(\"--beam-CumulativeImpact-description\")}\n text-align: var(--beam-CumulativeImpact-description-textAlign);\n }\n .impact-list {\n display: flex;\n flex-direction: column;\n margin-top: var(--beam-CumulativeImpact-impact-list-marginTop);\n }\n .impact-row {\n display: flex;\n align-items: center;\n margin-top: var(--beam-CumulativeImpact-row-marginTop);\n ${useCustomText(\"--beam-CumulativeImpact-row\")}\n }\n .impact-row-value-container {\n position: relative;\n border-bottom-width: var(--beam-CumulativeImpact-row-value-container-borderBottomWidth);\n border-bottom-color: var(--beam-CumulativeImpact-row-value-container-borderBottomColor);\n border-bottom-style: solid;\n padding-top: var(--beam-CumulativeImpact-row-value-container-paddingTop);\n padding-right: var(--beam-CumulativeImpact-row-value-container-paddingRight);\n padding-bottom: var(--beam-CumulativeImpact-row-value-container-paddingBottom);\n padding-left: var(--beam-CumulativeImpact-row-value-container-paddingLeft);\n text-align: center;\n flex-shrink: 0;\n }\n .impact-row-value-counter {\n ${useCustomText(\"--beam-CumulativeImpact-row-value-counter\")}\n }\n .impact-row-value-floating-counter {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n .impact-row-description {\n ${useCustomText(\"--beam-CumulativeImpact-row-description\")}\n padding-left: var(--beam-CumulativeImpact-row-description-paddingLeft);\n padding-right: var(--beam-CumulativeImpact-row-description-paddingRight);\n /* match padding of value of counter for proper centering */\n padding-bottom: var(--beam-CumulativeImpact-row-value-paddingBottom);\n text-align: inherit;\n flex-grow: 1;\n }\n @media (max-width: 500px) {\n .main {\n text-align: var(--beam-CumulativeImpact-main-mobile-textAlign);\n }\n .title {\n ${useCustomText(\"--beam-CumulativeImpact-title-mobile\", {\n ...useCustomTextMap(\"--beam-CumulativeImpact-title\"),\n })}\n text-align: var(--beam-CumulativeImpact-title-mobile-textAlign);\n }\n .description {\n ${useCustomText(\"--beam-CumulativeImpact-description-mobile\", {\n ...useCustomTextMap(\"--beam-CumulativeImpact-description\"),\n })}\n text-align: var(--beam-CumulativeImpact-description-mobile-textAlign);\n }\n .impact-row {\n ${useCustomText(\"--beam-CumulativeImpact-row-mobile\", {\n ...useCustomTextMap(\"--beam-CumulativeImpact-row\"),\n marginTop: \"var(--beam-CumulativeImpact-row-marginTop)\",\n })}\n flex-direction: var(--beam-CumulativeImpact-row-mobile-flexDirection);\n }\n .impact-row-value-counter {\n ${useCustomText(\"--beam-CumulativeImpact-row-value-counter-mobile\", {\n ...useCustomTextMap(\"--beam-CumulativeImpact-row-value-counter\"),\n })}\n }\n .impact-row-description {\n ${useCustomText(\"--beam-CumulativeImpact-row-description-mobile\", {\n ...useCustomTextMap(\"--beam-CumulativeImpact-row-description\"),\n marginTop: \"var(--beam-CumulativeImpact-row-description-mobile-marginTop)\",\n })}\n padding-bottom: var(--beam-CumulativeImpact-row-description-mobile-paddingBottom);\n text-align: var(--beam-CumulativeImpact-row-description-mobile-textAlign);\n }\n }\n `,\n ];\n}\n\ndefineCustomElement(BeamCumulativeImpact);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-cumulative-impact\": BeamCumulativeImpact;\n }\n}\n"],"names":["AnimatedCounter","LitElement","entries","entry","MS_PER_FRAME","COUNTER_INCREMENT_PER_FRAME","result","target","userPrefersReducedMotion","html","__decorateClass","property","state","syncElementWidths","elements","els","isAllHtmlElements","widthSource","a","b","widthA","widthB","syncedWidth","el","strings","C","r","s","l","e","m","MAX_COUNTER_ANIMATION_DURATION","BeamCumulativeImpact","DEFAULT_BASE_URL","enforceConfig","getCumulativeImpact","AsyncController","debounce","SUPPORTED_LANGUAGES","changedProperties","requireNewDataProps","prop","data","error","loading","_loading","_errorMessage","BeamError","rawValues","impact","maxRawValue","durations","val","localizeUserString","idx","animationDuration","disableAnimation","floatingCounterClass","duration","unitDisplay","summaryDisplay","defaults","defineCustomText","remoteConfig","config","_cssVariableMap","cssReset","css","useCustomText","useCustomTextMap","queryAll","defineCustomElement"],"mappings":"khBAIaA,UAAwBC,CAAW,CAAzC,aAAA,CAAA,MAAA,GAAA,SAAA,EACuB,KAAA,WAAa,EACb,KAAA,SAAW,KAG9B,KAAU,QAAU,EAC7B,KAAQ,WAAa,EAkBrB,KAAQ,6BAA8DC,GAAY,CAC5EA,EAAQ,KAAMC,GAAUA,EAAM,cAAc,IAC9C,KAAK,eAAA,EACL,KAAK,sBAAA,EAET,EAEA,KAAQ,eAAiB,IAAM,CAE7B,MAAMC,EAAe,mBAEfC,EAD2BD,EAAe,KAAK,SACU,KAAK,WAEpE,KAAK,WAAa,YAAY,IAAM,CAClC,MAAME,EAAS,KAAK,QAAUD,EAC9B,GAAIC,GAAU,KAAK,WAAY,CAC7B,KAAK,QAAU,KAAK,WACpB,cAAc,KAAK,UAAU,EAC7B,MACF,MACE,KAAK,QAAUA,CAEnB,EAAGF,CAAY,CACjB,EAEA,KAAQ,SAAW,IAAI,qBAAqB,KAAK,6BAA8B,CAC7E,UAAW,EACb,CAAC,EAED,KAAQ,oBAAsB,IAAM,CAClC,MAAMG,EAAS,KAAK,oBACpBA,GAAU,KAAK,SAAS,QAAQA,CAAM,CACxC,EAEA,KAAQ,sBAAwB,IAAM,CACpC,MAAMA,EAAS,KAAK,oBACpBA,GAAU,KAAK,SAAS,UAAUA,CAAM,CAC1C,CAAA,CArDA,mBAAoB,CAClB,MAAM,oBACN,MAAMC,EAA2B,OAAO,WAAW,kCAAkC,EAAE,QACnF,KAAK,WAAa,GAAKA,EACzB,KAAK,QAAU,KAAK,WAEpB,KAAK,oBAAA,CAET,CAE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/utils-ly9wMwUO.esm.js";import{u as s,g as j,A as P,
|
|
1
|
+
import{i as k,n as c,g as f,a as N,h as $,b as T}from"../chunks/lit-BEag9MFp.esm.js";import{d as F}from"../chunks/lodash-CrMU6wKg.esm.js";import{D as U,W as D,x as A,l as R}from"../chunks/utils-ly9wMwUO.esm.js";import{u as s,g as j,A as P,e as g,_,d as O,f as d,h as V}from"../chunks/index-D5-gztaa.esm.js";import{a as W}from"../chunks/share-button-CpcTaNLx.esm.js";import{c as G,d as K,e as M}from"../chunks/css-card-grid-tjA36yWj.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import{s as h,a as q}from"../chunks/share-button-ivUcw9Vw.esm.js";import{partnerLogosConfigDefaults as Y}from"./beam-partner-logos.esm.js";import{c as H}from"../chunks/responsive-aN8P5PqD.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";const l={en:{descriptionTitle:({nonprofitName:a="a nonprofit"})=>`You just made an impact for ${a}`,descriptionSubtitle:({brandName:a=""})=>`Check out the impact your ${a} purchase made below.`,yourImpactTitle:()=>"You\u2019re funding",communityImpactTitle:()=>"Together we\u2019re funding",personalImpactLinkCopy:({nonprofitName:a=""})=>`Learn about ${a}`,communityImpactLinkCopy:({brandName:a=""})=>`See all of the ${a} community's impact`,impactShareButton:()=>"Share to Grow Your Impact"},fr:{descriptionTitle:({nonprofitName:a="une organisation"})=>`Vous avez cr\xE9\xE9 un impact pour ${a}`,descriptionSubtitle:({brandName:a=""})=>`D\xE9couvrez ci-dessous l'impact de votre achat ${a}.`,yourImpactTitle:()=>"Vous financez",communityImpactTitle:()=>"Ensemble, nous finan\xE7ons",personalImpactLinkCopy:({nonprofitName:a=""})=>`En savoir plus sur ${a}`,communityImpactLinkCopy:({brandName:a=""})=>`Voir tout l'impact de la communaut\xE9 ${a}`,impactShareButton:()=>"Partagez pour d\xE9velopper votre impact"},de:{descriptionTitle:({nonprofitName:a="eine Organisation"})=>`Du hast einen Beitrag f\xFCr ${a} geleistet`,descriptionSubtitle:({brandName:a=""})=>`Sieh dir unten den Beitrag an, den dein ${a} Einkauf gemacht hat.`,yourImpactTitle:()=>"Du finanzierst",communityImpactTitle:()=>"Gemeinsam finanzieren wir",personalImpactLinkCopy:({nonprofitName:a=""})=>`Mehr \xFCber ${a} erfahren`,communityImpactLinkCopy:({brandName:a=""})=>`Sieh dir den gesamten Beitrag der ${a}-Community an`,impactShareButton:()=>"Teile, um deinen Beitrag zu vergr\xF6\xDFern"},es:{descriptionTitle:({nonprofitName:a="una organizaci\xF3n"})=>`Generaste un impacto para ${a}`,descriptionSubtitle:({brandName:a=""})=>`Mira a continuaci\xF3n el impacto que tu compra de ${a} ha generado.`,yourImpactTitle:()=>"Est\xE1s financiando",communityImpactTitle:()=>"Juntos estamos financiando",personalImpactLinkCopy:({nonprofitName:a=""})=>`Conoce m\xE1s sobre ${a}`,communityImpactLinkCopy:({brandName:a=""})=>`Mira todo el impacto de la comunidad ${a}`,impactShareButton:()=>"Comparte para hacer crecer tu impacto"},it:{descriptionTitle:({nonprofitName:a="un'organizzazione"})=>`Hai creato un impatto per ${a}`,descriptionSubtitle:({brandName:a=""})=>`Scopri qui sotto l'impatto del tuo acquisto ${a}.`,yourImpactTitle:()=>"Stai finanziando",communityImpactTitle:()=>"Insieme stiamo finanziando",personalImpactLinkCopy:({nonprofitName:a=""})=>`Scopri di pi\xF9 su ${a}`,communityImpactLinkCopy:({brandName:a=""})=>`Guarda tutto l'impatto della comunit\xE0 ${a}`,impactShareButton:()=>"Condividi per far crescere il tuo impatto"},pl:{descriptionTitle:({nonprofitName:a="organizacj\u0119"})=>`Wywar\u0142a\u015B_e\u015B wp\u0142yw na ${a}`,descriptionSubtitle:({brandName:a=""})=>`Sprawd\u017A poni\u017Cej, jaki wp\u0142yw mia\u0142 Tw\xF3j zakup ${a}.`,yourImpactTitle:()=>"Finansujesz",communityImpactTitle:()=>"Razem finansujemy",personalImpactLinkCopy:({nonprofitName:a=""})=>`Dowiedz si\u0119 wi\u0119cej o ${a}`,communityImpactLinkCopy:({brandName:a=""})=>`Zobacz ca\u0142y wp\u0142yw spo\u0142eczno\u015Bci ${a}`,impactShareButton:()=>"Udost\u0119pnij, aby powi\u0119kszy\u0107 sw\xF3j wp\u0142yw"},ja:{descriptionTitle:({nonprofitName:a=""})=>`\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\uFF01${a}\u3078\u306E\u5BC4\u4ED8\u306B\u3088\u308A\u3001\u4E16\u754C\u306B\u78BA\u304B\u306A\u5909\u5316\u3092\u3082\u305F\u3089\u3057\u307E\u3057\u305F\u3002`,descriptionSubtitle:({brandName:a=""})=>`${a}\u3067\u306E\u3054\u8CFC\u5165\u304C\u3001\u3069\u306E\u3088\u3046\u306B\u4EBA\u3005\u306E\u5F79\u306B\u7ACB\u3064\u304B\u3092\u3054\u78BA\u8A8D\u304F\u3060\u3055\u3044\u3002`,yourImpactTitle:()=>"\u3042\u306A\u305F\u306E\u652F\u63F4\u5B9F\u7E3E",communityImpactTitle:()=>"\u79C1\u305F\u3061\u306F\u5171\u306B\u652F\u63F4\u3057\u3066\u3044\u307E\u3059",personalImpactLinkCopy:({nonprofitName:a=""})=>`${a} \u306B\u3064\u3044\u3066\u8A73\u3057\u304F\u898B\u308B`,communityImpactLinkCopy:({brandName:a=""})=>`${a}\u30B3\u30DF\u30E5\u30CB\u30C6\u30A3\u306E\u6D3B\u52D5\u5B9F\u7E3E\u3092\u3059\u3079\u3066\u898B\u308B `,impactShareButton:()=>"SNS\u3067\u30B7\u30A7\u30A2\u3059\u308B"}};var J=Object.defineProperty,i=(a,e,r,p)=>{for(var n=void 0,m=a.length-1,o;m>=0;m--)(o=a[m])&&(n=o(e,r,n)||n);return n&&J(e,r,n),n};class t extends N{constructor(){super(...arguments),this.baseUrl=U,this.lang="en",this.debug=!1,this.draftConfig=!1,this.getImpactData=async()=>(M(["apiKey","userId","nonprofitId"],this),await j({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{nonprofitId:this.nonprofitId,beamUserId:this.userId,personalImpactLimit:1,communityImpactLimit:1,storeId:this.storeId,widgetName:D.impact_overview,version:"1.0.0",draftConfig:this.draftConfig,lang:this.configLang,discountCodes:this.discountCodes&&this.discountCodes.length>0?this.discountCodes:void 0,transactionId:this.transactionId??void 0}})),this.impactDataController=new P(this,this.getImpactData),this.resizeElements=F(()=>{h(this.impactTitleRefs),h(this.impactDescriptionRefs),h(this.impactLinkRefs),h(this.goalCompletionTextRefs)},50,{maxWait:50,leading:!0})}get configLang(){return A[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.resizeElements)}async updated(e){const r=["baseUrl","storeId","apiKey","userId","lang","discountCodes"];for(const p of r)if(e.has(p)){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=>R.error(r)),e()}renderCard({imageUrl:e,title:r,percentFunded:p,goalProgressText:n,description:m,urlCopy:o,impactUrl:b,isImage:u,cardType:y,goalCompletionText:v}){return T`
|
|
2
2
|
<div class="impact-card ${u?"":"icon"}" part="impact-card">
|
|
3
3
|
<div class="${u?"":"icon-background "}">
|
|
4
4
|
<img
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as k,n as c,g as f,a as N,h as $,b as T}from"../chunks/lit-BEag9MFp.esm.js";import{d as F}from"../chunks/lodash-CrMU6wKg.esm.js";import{D as U,W as D,x as A,l as R}from"../chunks/utils-ly9wMwUO.esm.js";import{u as s,g as j,A as P,
|
|
1
|
+
import{i as k,n as c,g as f,a as N,h as $,b as T}from"../chunks/lit-BEag9MFp.esm.js";import{d as F}from"../chunks/lodash-CrMU6wKg.esm.js";import{D as U,W as D,x as A,l as R}from"../chunks/utils-ly9wMwUO.esm.js";import{u as s,g as j,A as P,e as g,_,d as O,f as d,h as V}from"../chunks/index-D5-gztaa.esm.js";import{a as W}from"../chunks/share-button-CpcTaNLx.esm.js";import{c as G,d as K,e as M}from"../chunks/css-card-grid-tjA36yWj.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import{s as h,a as q}from"../chunks/share-button-ivUcw9Vw.esm.js";import{partnerLogosConfigDefaults as Y}from"./beam-partner-logos.js";import{c as H}from"../chunks/responsive-aN8P5PqD.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";const l={en:{descriptionTitle:({nonprofitName:a="a nonprofit"})=>`You just made an impact for ${a}`,descriptionSubtitle:({brandName:a=""})=>`Check out the impact your ${a} purchase made below.`,yourImpactTitle:()=>"You\u2019re funding",communityImpactTitle:()=>"Together we\u2019re funding",personalImpactLinkCopy:({nonprofitName:a=""})=>`Learn about ${a}`,communityImpactLinkCopy:({brandName:a=""})=>`See all of the ${a} community's impact`,impactShareButton:()=>"Share to Grow Your Impact"},fr:{descriptionTitle:({nonprofitName:a="une organisation"})=>`Vous avez cr\xE9\xE9 un impact pour ${a}`,descriptionSubtitle:({brandName:a=""})=>`D\xE9couvrez ci-dessous l'impact de votre achat ${a}.`,yourImpactTitle:()=>"Vous financez",communityImpactTitle:()=>"Ensemble, nous finan\xE7ons",personalImpactLinkCopy:({nonprofitName:a=""})=>`En savoir plus sur ${a}`,communityImpactLinkCopy:({brandName:a=""})=>`Voir tout l'impact de la communaut\xE9 ${a}`,impactShareButton:()=>"Partagez pour d\xE9velopper votre impact"},de:{descriptionTitle:({nonprofitName:a="eine Organisation"})=>`Du hast einen Beitrag f\xFCr ${a} geleistet`,descriptionSubtitle:({brandName:a=""})=>`Sieh dir unten den Beitrag an, den dein ${a} Einkauf gemacht hat.`,yourImpactTitle:()=>"Du finanzierst",communityImpactTitle:()=>"Gemeinsam finanzieren wir",personalImpactLinkCopy:({nonprofitName:a=""})=>`Mehr \xFCber ${a} erfahren`,communityImpactLinkCopy:({brandName:a=""})=>`Sieh dir den gesamten Beitrag der ${a}-Community an`,impactShareButton:()=>"Teile, um deinen Beitrag zu vergr\xF6\xDFern"},es:{descriptionTitle:({nonprofitName:a="una organizaci\xF3n"})=>`Generaste un impacto para ${a}`,descriptionSubtitle:({brandName:a=""})=>`Mira a continuaci\xF3n el impacto que tu compra de ${a} ha generado.`,yourImpactTitle:()=>"Est\xE1s financiando",communityImpactTitle:()=>"Juntos estamos financiando",personalImpactLinkCopy:({nonprofitName:a=""})=>`Conoce m\xE1s sobre ${a}`,communityImpactLinkCopy:({brandName:a=""})=>`Mira todo el impacto de la comunidad ${a}`,impactShareButton:()=>"Comparte para hacer crecer tu impacto"},it:{descriptionTitle:({nonprofitName:a="un'organizzazione"})=>`Hai creato un impatto per ${a}`,descriptionSubtitle:({brandName:a=""})=>`Scopri qui sotto l'impatto del tuo acquisto ${a}.`,yourImpactTitle:()=>"Stai finanziando",communityImpactTitle:()=>"Insieme stiamo finanziando",personalImpactLinkCopy:({nonprofitName:a=""})=>`Scopri di pi\xF9 su ${a}`,communityImpactLinkCopy:({brandName:a=""})=>`Guarda tutto l'impatto della comunit\xE0 ${a}`,impactShareButton:()=>"Condividi per far crescere il tuo impatto"},pl:{descriptionTitle:({nonprofitName:a="organizacj\u0119"})=>`Wywar\u0142a\u015B_e\u015B wp\u0142yw na ${a}`,descriptionSubtitle:({brandName:a=""})=>`Sprawd\u017A poni\u017Cej, jaki wp\u0142yw mia\u0142 Tw\xF3j zakup ${a}.`,yourImpactTitle:()=>"Finansujesz",communityImpactTitle:()=>"Razem finansujemy",personalImpactLinkCopy:({nonprofitName:a=""})=>`Dowiedz si\u0119 wi\u0119cej o ${a}`,communityImpactLinkCopy:({brandName:a=""})=>`Zobacz ca\u0142y wp\u0142yw spo\u0142eczno\u015Bci ${a}`,impactShareButton:()=>"Udost\u0119pnij, aby powi\u0119kszy\u0107 sw\xF3j wp\u0142yw"},ja:{descriptionTitle:({nonprofitName:a=""})=>`\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\uFF01${a}\u3078\u306E\u5BC4\u4ED8\u306B\u3088\u308A\u3001\u4E16\u754C\u306B\u78BA\u304B\u306A\u5909\u5316\u3092\u3082\u305F\u3089\u3057\u307E\u3057\u305F\u3002`,descriptionSubtitle:({brandName:a=""})=>`${a}\u3067\u306E\u3054\u8CFC\u5165\u304C\u3001\u3069\u306E\u3088\u3046\u306B\u4EBA\u3005\u306E\u5F79\u306B\u7ACB\u3064\u304B\u3092\u3054\u78BA\u8A8D\u304F\u3060\u3055\u3044\u3002`,yourImpactTitle:()=>"\u3042\u306A\u305F\u306E\u652F\u63F4\u5B9F\u7E3E",communityImpactTitle:()=>"\u79C1\u305F\u3061\u306F\u5171\u306B\u652F\u63F4\u3057\u3066\u3044\u307E\u3059",personalImpactLinkCopy:({nonprofitName:a=""})=>`${a} \u306B\u3064\u3044\u3066\u8A73\u3057\u304F\u898B\u308B`,communityImpactLinkCopy:({brandName:a=""})=>`${a}\u30B3\u30DF\u30E5\u30CB\u30C6\u30A3\u306E\u6D3B\u52D5\u5B9F\u7E3E\u3092\u3059\u3079\u3066\u898B\u308B `,impactShareButton:()=>"SNS\u3067\u30B7\u30A7\u30A2\u3059\u308B"}};var J=Object.defineProperty,i=(a,e,r,p)=>{for(var n=void 0,m=a.length-1,o;m>=0;m--)(o=a[m])&&(n=o(e,r,n)||n);return n&&J(e,r,n),n};class t extends N{constructor(){super(...arguments),this.baseUrl=U,this.lang="en",this.debug=!1,this.draftConfig=!1,this.getImpactData=async()=>(M(["apiKey","userId","nonprofitId"],this),await j({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{nonprofitId:this.nonprofitId,beamUserId:this.userId,personalImpactLimit:1,communityImpactLimit:1,storeId:this.storeId,widgetName:D.impact_overview,version:"1.0.0",draftConfig:this.draftConfig,lang:this.configLang,discountCodes:this.discountCodes&&this.discountCodes.length>0?this.discountCodes:void 0,transactionId:this.transactionId??void 0}})),this.impactDataController=new P(this,this.getImpactData),this.resizeElements=F(()=>{h(this.impactTitleRefs),h(this.impactDescriptionRefs),h(this.impactLinkRefs),h(this.goalCompletionTextRefs)},50,{maxWait:50,leading:!0})}get configLang(){return A[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.resizeElements)}async updated(e){const r=["baseUrl","storeId","apiKey","userId","lang","discountCodes"];for(const p of r)if(e.has(p)){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=>R.error(r)),e()}renderCard({imageUrl:e,title:r,percentFunded:p,goalProgressText:n,description:m,urlCopy:o,impactUrl:b,isImage:u,cardType:y,goalCompletionText:v}){return T`
|
|
2
2
|
<div class="impact-card ${u?"":"icon"}" part="impact-card">
|
|
3
3
|
<div class="${u?"":"icon-background "}">
|
|
4
4
|
<img
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{BeamCommunityImpact as S}from"./community-impact.esm.js";import{BeamCumulativeImpact as b}from"./cumulative-impact.esm.js";import{BeamImpactOverview as P}from"./impact-overview.esm.js";import{BeamSelectNonprofit as N}from"./select-nonprofit.esm.js";import{B as g}from"../chunks/index-
|
|
1
|
+
import{BeamCommunityImpact as S}from"./community-impact.esm.js";import{BeamCumulativeImpact as b}from"./cumulative-impact.esm.js";import{BeamImpactOverview as P}from"./impact-overview.esm.js";import{BeamSelectNonprofit as N}from"./select-nonprofit.esm.js";import{B as g}from"../chunks/index-MJhOu5my.esm.js";import{B as C}from"../chunks/index-CAt4jZhL.esm.js";import{BeamSubscriptionManagement as y}from"./subscription-management.esm.js";import{BeamSubscriptionImpact as M}from"./subscription-impact.esm.js";import{BeamProductDetailsPage as R}from"./product-details-page.esm.js";import{BeamSelectSubscriptionNonprofit as j}from"./select-subscription-nonprofit.esm.js";import{BeamSocialShare as q}from"./social-share.esm.js";import{BeamSubscriberSelectNonprofit as A}from"./subscriber-select-nonprofit.esm.js";import"../chunks/lit-BEag9MFp.esm.js";import"../chunks/css-card-grid-tjA36yWj.esm.js";import"../chunks/utils-ly9wMwUO.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";import"../chunks/index-D5-gztaa.esm.js";import"../chunks/share-button-CpcTaNLx.esm.js";import"./beam-partner-logos.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";import"../chunks/share-button-ivUcw9Vw.esm.js";import"../chunks/responsive-aN8P5PqD.esm.js";import"../chunks/promo-pill-label-BBi4qq7M.esm.js";import"../chunks/handlebars-3tRO54kz.esm.js";export{S as BeamCommunityImpact,b as BeamCumulativeImpact,P as BeamImpactOverview,C as BeamPostPurchase,R as BeamProductDetailsPage,g as BeamRedeemTransaction,N as BeamSelectNonprofit,j as BeamSelectSubscriptionNonprofit,q as BeamSocialShare,A as BeamSubscriberSelectNonprofit,M as BeamSubscriptionImpact,y as BeamSubscriptionManagement};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/components/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{BeamCommunityImpact as S}from"./community-impact.js";import{BeamCumulativeImpact as b}from"./cumulative-impact.js";import{BeamImpactOverview as P}from"./impact-overview.js";import{BeamSelectNonprofit as N}from"./select-nonprofit.js";import{B as g}from"../chunks/index-
|
|
1
|
+
import{BeamCommunityImpact as S}from"./community-impact.js";import{BeamCumulativeImpact as b}from"./cumulative-impact.js";import{BeamImpactOverview as P}from"./impact-overview.js";import{BeamSelectNonprofit as N}from"./select-nonprofit.js";import{B as g}from"../chunks/index-CfQMEz6F.esm.js";import{B as C}from"../chunks/index-mVF3RTDz.esm.js";import{BeamSubscriptionManagement as y}from"./subscription-management.js";import{BeamSubscriptionImpact as M}from"./subscription-impact.js";import{BeamProductDetailsPage as R}from"./product-details-page.js";import{BeamSelectSubscriptionNonprofit as j}from"./select-subscription-nonprofit.js";import{BeamSocialShare as q}from"./social-share.js";import{BeamSubscriberSelectNonprofit as A}from"./subscriber-select-nonprofit.js";import"../chunks/lit-BEag9MFp.esm.js";import"../chunks/css-card-grid-tjA36yWj.esm.js";import"../chunks/utils-ly9wMwUO.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";import"../chunks/index-D5-gztaa.esm.js";import"../chunks/share-button-CpcTaNLx.esm.js";import"./beam-partner-logos.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";import"../chunks/share-button-ivUcw9Vw.esm.js";import"../chunks/responsive-aN8P5PqD.esm.js";import"../chunks/promo-pill-label-BBi4qq7M.esm.js";import"../chunks/handlebars-3tRO54kz.esm.js";export{S as BeamCommunityImpact,b as BeamCumulativeImpact,P as BeamImpactOverview,C as BeamPostPurchase,R as BeamProductDetailsPage,g as BeamRedeemTransaction,N as BeamSelectNonprofit,j as BeamSelectSubscriptionNonprofit,q as BeamSocialShare,A as BeamSubscriberSelectNonprofit,M as BeamSubscriptionImpact,y as BeamSubscriptionManagement};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunks/lit-BEag9MFp.esm.js";import"../chunks/utils-ly9wMwUO.esm.js";import"../chunks/css-card-grid-tjA36yWj.esm.js";import"../chunks/index-
|
|
1
|
+
import"../chunks/lit-BEag9MFp.esm.js";import"../chunks/utils-ly9wMwUO.esm.js";import"../chunks/css-card-grid-tjA36yWj.esm.js";import"../chunks/index-D5-gztaa.esm.js";import"../chunks/index-MJhOu5my.esm.js";import"./impact-overview.esm.js";import{B as b}from"../chunks/index-CAt4jZhL.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";import"../chunks/share-button-CpcTaNLx.esm.js";import"./beam-partner-logos.esm.js";import"../chunks/promo-pill-label-BBi4qq7M.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";import"../chunks/share-button-ivUcw9Vw.esm.js";import"../chunks/responsive-aN8P5PqD.esm.js";export{b as BeamPostPurchase};
|
|
2
2
|
//# sourceMappingURL=post-purchase.esm.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunks/lit-BEag9MFp.esm.js";import"../chunks/utils-ly9wMwUO.esm.js";import"../chunks/css-card-grid-tjA36yWj.esm.js";import"../chunks/index-
|
|
1
|
+
import"../chunks/lit-BEag9MFp.esm.js";import"../chunks/utils-ly9wMwUO.esm.js";import"../chunks/css-card-grid-tjA36yWj.esm.js";import"../chunks/index-D5-gztaa.esm.js";import"../chunks/index-CfQMEz6F.esm.js";import"./impact-overview.js";import{B as b}from"../chunks/index-mVF3RTDz.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";import"../chunks/share-button-CpcTaNLx.esm.js";import"./beam-partner-logos.js";import"../chunks/promo-pill-label-BBi4qq7M.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";import"../chunks/share-button-ivUcw9Vw.esm.js";import"../chunks/responsive-aN8P5PqD.esm.js";export{b as BeamPostPurchase};
|
|
2
2
|
//# sourceMappingURL=post-purchase.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as E,b as r,i as B,n as p,r as A,a as z,h as L}from"../chunks/lit-BEag9MFp.esm.js";import{u as b,B as G,
|
|
1
|
+
import{m as E,b as r,i as B,n as p,r as A,a as z,h as L}from"../chunks/lit-BEag9MFp.esm.js";import{u as b,B as G,m as W,A as M,d as R,e as k,f as D,h as _}from"../chunks/index-D5-gztaa.esm.js";import{D as O,A as j,C as H,h as U,E as K,F as w,W as y,y as N,x as V,G as q,H as J,I as Y,J as Z,m as S}from"../chunks/utils-ly9wMwUO.esm.js";import{c as Q,d as X,e as ee}from"../chunks/css-card-grid-tjA36yWj.esm.js";import{c as te}from"../chunks/responsive-aN8P5PqD.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";import{p as oe}from"../chunks/promo-pill-label-BBi4qq7M.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";const ae=(n="",{borderRadius:e="0px",borderStyle:t="unset",borderColor:o="#000000",borderWidth:i="1px"}={})=>{const a=n.startsWith("--beam-")?n:`--beam-${n}`;return{[`${a}-borderRadius`]:e,[`${a}-borderStyle`]:t,[`${a}-borderColor`]:o,[`${a}-borderWidth`]:i}},ie=(n="",{borderRadius:e="0px",borderStyle:t="unset",borderColor:o="#000000",borderWidth:i="1px"}={})=>{const a=n.startsWith("--beam-")?n:`--beam-${n}`;return E(` border-radius: var(${a}-borderRadius, ${e});
|
|
2
2
|
border-style: var(${a}-borderStyle, ${t});
|
|
3
3
|
border-color: var(${a}-borderColor, ${o});
|
|
4
4
|
border-width: var(${a}-borderWidth, ${i});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as E,b as r,i as B,n as p,r as A,a as z,h as L}from"../chunks/lit-BEag9MFp.esm.js";import{u as b,B as G,
|
|
1
|
+
import{m as E,b as r,i as B,n as p,r as A,a as z,h as L}from"../chunks/lit-BEag9MFp.esm.js";import{u as b,B as G,m as W,A as M,d as R,e as k,f as D,h as _}from"../chunks/index-D5-gztaa.esm.js";import{D as O,A as j,C as H,h as U,E as K,F as w,W as y,y as N,x as V,G as q,H as J,I as Y,J as Z,m as S}from"../chunks/utils-ly9wMwUO.esm.js";import{c as Q,d as X,e as ee}from"../chunks/css-card-grid-tjA36yWj.esm.js";import{c as te}from"../chunks/responsive-aN8P5PqD.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";import{p as oe}from"../chunks/promo-pill-label-BBi4qq7M.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";const ae=(n="",{borderRadius:e="0px",borderStyle:t="unset",borderColor:o="#000000",borderWidth:i="1px"}={})=>{const a=n.startsWith("--beam-")?n:`--beam-${n}`;return{[`${a}-borderRadius`]:e,[`${a}-borderStyle`]:t,[`${a}-borderColor`]:o,[`${a}-borderWidth`]:i}},ie=(n="",{borderRadius:e="0px",borderStyle:t="unset",borderColor:o="#000000",borderWidth:i="1px"}={})=>{const a=n.startsWith("--beam-")?n:`--beam-${n}`;return E(` border-radius: var(${a}-borderRadius, ${e});
|
|
2
2
|
border-style: var(${a}-borderStyle, ${t});
|
|
3
3
|
border-color: var(${a}-borderColor, ${o});
|
|
4
4
|
border-width: var(${a}-borderWidth, ${i});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunks/lit-BEag9MFp.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";import"../chunks/index-
|
|
1
|
+
import"../chunks/lit-BEag9MFp.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";import"../chunks/index-D5-gztaa.esm.js";import"../chunks/utils-ly9wMwUO.esm.js";import"../chunks/css-card-grid-tjA36yWj.esm.js";import{B as d}from"../chunks/index-MJhOu5my.esm.js";import"../chunks/share-button-CpcTaNLx.esm.js";import"./beam-partner-logos.esm.js";import"../chunks/promo-pill-label-BBi4qq7M.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";export{d as BeamRedeemTransaction};
|
|
2
2
|
//# sourceMappingURL=redeem-transaction.esm.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunks/lit-BEag9MFp.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";import"../chunks/index-
|
|
1
|
+
import"../chunks/lit-BEag9MFp.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";import"../chunks/index-D5-gztaa.esm.js";import"../chunks/utils-ly9wMwUO.esm.js";import"../chunks/css-card-grid-tjA36yWj.esm.js";import{B as d}from"../chunks/index-CfQMEz6F.esm.js";import"../chunks/share-button-CpcTaNLx.esm.js";import"./beam-partner-logos.js";import"../chunks/promo-pill-label-BBi4qq7M.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";export{d as BeamRedeemTransaction};
|
|
2
2
|
//# sourceMappingURL=redeem-transaction.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as D,i as L,b as d,n as f,r as I,e as C,k as J,j as A,h as Y}from"../chunks/lit-BEag9MFp.esm.js";import{i as Q,d as X}from"../chunks/lodash-CrMU6wKg.esm.js";import{u as S,B as z,
|
|
1
|
+
import{a as D,i as L,b as d,n as f,r as I,e as C,k as J,j as A,h as Y}from"../chunks/lit-BEag9MFp.esm.js";import{i as Q,d as X}from"../chunks/lodash-CrMU6wKg.esm.js";import{u as S,B as z,j as Z,n as ee,A as B,f as u,h as te,_ as oe,d as T,e as m}from"../chunks/index-D5-gztaa.esm.js";import{D as ie,C as F,K as M,h as ne,E as ae,F as K,W as v,L as O,B as P,M as re,A as se,N as E,O as le,x as ce,G as pe,H as de,I as fe,J as me,P as W,m as _,l as he}from"../chunks/utils-ly9wMwUO.esm.js";import{c as ge,d as ue,e as k}from"../chunks/css-card-grid-tjA36yWj.esm.js";import{a as be}from"../chunks/share-button-CpcTaNLx.esm.js";import{c as Se}from"../chunks/responsive-aN8P5PqD.esm.js";import{p as Ne}from"../chunks/promo-pill-label-BBi4qq7M.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";class Ce extends D{static get styles(){return L`
|
|
2
2
|
:host {
|
|
3
3
|
}
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@ import{a as D,i as L,b as d,n as f,r as I,e as C,k as J,j as A,h as Y}from"../ch
|
|
|
18
18
|
aria-label="Notification Blip"
|
|
19
19
|
>
|
|
20
20
|
<span class="notification-blip" part="notification-blip" role="button" tabindex="0" aria-hidden="true"></span>
|
|
21
|
-
</div>`}}customElements.get("beam-notification-blip")||customElements.define("beam-notification-blip",Ce);const ve={"--beam-notificationBlip-color-background":"#000"},h={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose your impact",ctaPromoPrefixMessage:()=>"At no extra cost,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`select a nonprofit and ${o}% will be donated for you.`,ctaMessage:({donationPercentage:o="1"}={})=>`At no extra cost, select a nonprofit and ${o}% will be donated for you.`,inlineSeparator:()=>": "},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choisissez votre cause",ctaPromoPrefixMessage:()=>"Sans frais suppl\xE9mentaires,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`s\xE9lectionnez une association et ${o} % sera revers\xE9 en votre nom.`,ctaMessage:({donationPercentage:o="1"}={})=>`Sans frais suppl\xE9mentaires, choisissez une association et ${o} % de votre commande sera revers\xE9 en votre nom.`,inlineSeparator:()=>" : "},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"W\xE4hle deine Wirkung",ctaPromoPrefixMessage:()=>"Ohne zus\xE4tzliche Kosten,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`w\xE4hle eine Organisation und ${o}% deines Einkaufs werden gespendet.`,ctaMessage:({donationPercentage:o="1"}={})=>`Ohne zus\xE4tzliche Kosten kannst du eine gemeinn\xFCtzige Organisation ausw\xE4hlen und ${o}% deiner Bestellung werden gespendet.`,inlineSeparator:()=>": "},es:{beamAttribution:()=>"Ofrecido por Beam",ctaTitle:()=>"Elige tu impacto",ctaPromoPrefixMessage:()=>"Sin coste adicional,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`elige una organizaci\xF3n y donaremos el ${o}% en tu nombre.`,ctaMessage:({donationPercentage:o="1"}={})=>`Sin coste adicional, elige una organizaci\xF3n sin fines de lucro y donaremos el ${o}% de tu compra en tu nombre.`,inlineSeparator:()=>": "},it:{beamAttribution:()=>"Gestito da Beam",ctaTitle:()=>"Scegli il tuo impatto",ctaPromoPrefixMessage:()=>"Senza costi aggiuntivi,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`scegli un'organizzazione e doneremo l\u2019${o}% per te.`,ctaMessage:({donationPercentage:o="1"}={})=>`Senza costi aggiuntivi, seleziona un'organizzazione no-profit e doneremo l\u2019${o}% del tuo acquisto per te.`,inlineSeparator:()=>": "},pl:{beamAttribution:()=>"Obs\u0142ugiwane przez Beam",ctaTitle:()=>"Wybierz sw\xF3j wp\u0142yw",ctaPromoPrefixMessage:()=>"Bez dodatkowych koszt\xF3w,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`wybierz organizacj\u0119, a ${o}% zostanie przekazane w Twoim imieniu.`,ctaMessage:({donationPercentage:o="1"}={})=>`Bez dodatkowych koszt\xF3w wybierz organizacj\u0119, kt\xF3rej przeka\u017Cemy ${o}% warto\u015Bci Twojego zam\xF3wienia w Twoim imieniu.`,inlineSeparator:()=>": "},ja:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"\u5BC4\u4ED8\u5148\u3092\u304A\u9078\u3073\u304F\u3060\u3055\u3044\u3002",ctaPromoPrefixMessage:()=>"\u8FFD\u52A0\u8CBB\u7528\u306A\u3057\u3067\u3001",ctaPromoMessage:({donationPercentage:o="1"}={})=>`\u975E\u55B6\u5229\u56E3\u4F53\u3092\u9078\u3076\u3068\u3001${o}%\u304C\u305D\u306E\u56E3\u4F53\u306B\u5BC4\u4ED8\u3055\u308C\u307E\u3059\u3002`,ctaMessage:({donationPercentage:o="1"}={})=>`\u8FFD\u52A0\u8CBB\u7528\u306A\u3057\u3067\u975E\u55B6\u5229\u56E3\u4F53\u3092\u304A\u9078\u3073\u3044\u305F\u3060\u304F\u3068\u3001\u3054\u8CFC\u5165\u91D1\u984D\u306E${o}%\u304C\u5BC4\u4ED8\u3055\u308C\u307E\u3059\u3002`,inlineSeparator:()=>"\uFF1A"}};var ye=Object.defineProperty,p=(o,e,t,n)=>{for(var i=void 0,a=o.length-1,r;a>=0;a--)(r=o[a])&&(i=r(e,t,i)||i);return i&&ye(e,t,i),i};let U=!1;class c extends D{constructor(){super(...arguments),this.baseUrl=ie,this.selectedNonprofitId=null,this.lang="en",this.debug=!1,this.draftConfig=!1,this.lastSelectionActionDate=new Date,this.isMobile=window.innerWidth<768,this.enableNonprofitDeselection=!1,this.didTryToCreateNewSelectionFromCache=!1,this.pluginPromoCodes=[],this.handlePromoCodesStored=e=>{const t=(e.detail.promoCodes?.unvalidatedPromoCodes??[]).map(n=>n.attributes?.value??n.attributes?.url??"").sort();this.pluginPromoCodes=t},this.getChainNonprofits=async()=>{k(["apiKey"],this);const e=F(z,{apiKey:this.apiKey}),t=M("cart",{apiKey:this.apiKey}),n=this.cart?.content?{schema:this.cart?.schema,content:this.cart?.content}:void 0,i=this.getManualPromoCodes(),a=ne(i.map(g=>({value:g})),this.apiKey),r=a&&!ae(a);r&&this.dispatchEvent(new K({source:v.select_nonprofit}));const l=await Z({baseUrl:this.baseUrl,apiRoot:"/api/v3",headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId,widgetName:v.select_nonprofit,...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode},beamCartId:e||void 0,cartId:t||void 0,version:"1.0.0",lang:this.configLang,...r&&{promos:a},options:{config:{draftConfig:this.draftConfig}},cart:n}});return this.enableNonprofitDeselection=!!l.config.enableNonprofitDeselection,this.selectedNonprofitId!==null&&this.selectedNonprofitId&&!l.nonprofits.map(g=>g.nonprofit.id).includes(this.selectedNonprofitId)&&(this.selectedNonprofitId=null,await this.postSelectNonprofit({selectedNonprofitId:null}),this.localStorage.setItem("nonprofit",null)),l.store?.id&&l.store.id!==this.storeId&&(this.storeId=l.store.id),await this.createNewSelectionForCachedNonprofit(),this.localStorage.setItemJson(O.CHAIN_NONPROFITS,{createdAt:new Date,data:l}),this.handleValidatedPromoCodes(l),l},this.postSelectNonprofit=async({selectedNonprofitId:e})=>{k(["apiKey","storeId"],this);const t=new Date;this.lastSelectionActionDate=t;const n=M("cart",{apiKey:this.apiKey}),i=F(z,{apiKey:this.apiKey}),a=await ee({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{nonprofitId:e,selectionId:this.selectionId,storeId:this.storeId,cartId:n||void 0,beamCartId:i||void 0,creationMethod:"cart",...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode}}}),r=!this.selectionId;this.selectionId=a?.selectionId,this.localStorage.setItem("transaction",this.selectionId),this.localStorage.setItem("nonprofit",e),this.localStorage.setItem("nonprofit_selected_at",t.toISOString()),await this.updateComplete;const l=this.getNonprofitById(e);e!==null&&this.dispatchEvent(new P({selectedNonprofitId:e,selectionId:this.selectionId,nonprofitName:l?.nonprofit?.name??null,source:v.select_nonprofit,timestamp:t,isFirstSelection:r})),e===null&&this.dispatchEvent(new re({newNonprofitId:null,selectionId:this.selectionId,timestamp:t}))},this.nonprofitListDataController=new B(this,this.getChainNonprofits),this.selectionDataController=new B(this,this.postSelectNonprofit),this.localStorage=se(this),this.handleCartChange=e=>{this.cart=e.detail},this.handleNonprofitSelect=e=>{const{selectionId:t,selectedNonprofitId:n,timestamp:i}=e.detail;!i||i<this.lastSelectionActionDate||(this.lastSelectionActionDate=i,this.selectionId!==t&&(this.selectionId=t),this.selectedNonprofitId!==n&&(this.selectedNonprofitId=n??null))},this.handleInitialNonprofitSync=e=>{if(U)return;const{nonprofitId:t,selectionId:n}=e.detail,i=t!==void 0&&this.selectedNonprofitId!==t,a=n!==void 0&&this.selectionId!==n;(i||a)&&(i&&(this.selectedNonprofitId=t),a&&(this.selectionId=n),this.requestUpdate(),U=!0,window.removeEventListener(E.eventName,this.handleInitialNonprofitSync))},this.makeHandleSelect=(e,t,n)=>async i=>{const a=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let r=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?r=n[n.length-1]:r=n[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===n.length-1?r=n[0]:r=n[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(r){a!=null&&(this.selectedNonprofitId=r.nonprofit.id);const l=this.renderRoot.querySelector(`[data-value="${r.nonprofit.id}"]`);l!==null&&(l.tabIndex=0,l.focus());return}}if(i.currentTarget instanceof HTMLElement)if(a===e)if(this.enableNonprofitDeselection)this.selectedNonprofitId=null,this.localStorage.setItem("nonprofit",null);else return;else this.selectedNonprofitId=e;this.dispatchEvent(new le({})),window.removeEventListener(E.eventName,this.handleInitialNonprofitSync),await this.selectionDataController.exec({selectedNonprofitId:this.selectedNonprofitId})},this.evaluateBreakPoints=X(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return ce[this.lang]||"en"}get parsedPromoCodes(){return pe(this.promoCodes)}getManualPromoCodes(){if(this.parsedPromoCodes&&this.parsedPromoCodes.length>0)return this.parsedPromoCodes;const e=this.localStorage.getItemJson("cart");return e?de(e):[]}async handleValidatedPromoCodes(e){e.promos?.validatedPromoCodes?.length&&(await Promise.all([fe({apiKey:this.apiKey,promoCodes:{validatedPromoCodes:e.promos.validatedPromoCodes,unvalidatedPromoCodes:[]}}),me({validatedPromoCodes:e.promos.validatedPromoCodes,domain:this.domain})]),this.dispatchEvent(new K({source:v.select_nonprofit})))}getNonprofitById(e){return e?this.nonprofitListDataController?.data?.nonprofits.find(t=>t.nonprofit.id===e):null}async connectedCallback(){super.connectedCallback(),window.addEventListener(E.eventName,this.handleInitialNonprofitSync),window.addEventListener(P.eventName,this.handleNonprofitSelect),this.nonprofitListDataController.loading=!0,window.addEventListener(W.eventName,this.handleCartChange),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(){await this.restoreStateFromCache(),window.addEventListener(_.eventName,this.handlePromoCodesStored)}async updated(e){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","cart","lang","promoCodes","pluginPromoCodes"];this.pluginPromoCodes;for(const n of t)if(e.has(n)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){window.removeEventListener(W.eventName,this.handleCartChange),window.removeEventListener("resize",this.evaluateBreakPoints),window.removeEventListener(_.eventName,this.handlePromoCodesStored),window.removeEventListener(P.eventName,this.handleNonprofitSelect),super.disconnectedCallback()}async restoreStateFromCache(){try{const e=new Date().valueOf();this.cart=this.localStorage.getItemJson("cart")??void 0;const t=720*60*60*1e3,n=this.localStorage.getItem("nonprofit_selected_at")??0,i=e>new Date(n).valueOf()+t;i?i&&this.selectedNonprofitId!==null&&(await this.postSelectNonprofit({selectedNonprofitId:null}),this.localStorage.setItem("nonprofit",null)):(this.selectedNonprofitId=parseInt(this.localStorage.getItem("nonprofit")||"")||null,this.selectionId=this.localStorage.getItem("transaction")??void 0);const{createdAt:a=0,data:r}=this.localStorage.getItemJson(O.CHAIN_NONPROFITS)||{},l=7200*1e3;!(e>new Date(a).valueOf()+l)&&this.nonprofitListDataController.loading&&(this.nonprofitListDataController.data=r,this.nonprofitListDataController.loading=!1)}catch(e){he.error(e)}}async createNewSelectionForCachedNonprofit(){if(k(["apiKey"],this),!(!this.storeId||this.didTryToCreateNewSelectionFromCache))try{this.didTryToCreateNewSelectionFromCache=!0}catch{}}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...be,"--beam-SelectNonprofit-title-textAlign":"inherit","--beam-SelectNonprofit-description-textAlign":"inherit","--beam-SelectNonprofit-maxWidth":"800px","--beam-SelectNonprofit-options-marginTop":"0px","--beam-SelectNonprofit-options-iconHeight":"24px","--beam-SelectNonprofit-options-padding":"10px","--beam-SelectNonprofit-options-borderRadius":"0px","--beam-SelectNonprofit-options-borderColor":"currentColor","--beam-SelectNonprofit-options-borderWidth":"1px","--beam-SelectNonprofit-options--selected-borderColor":"currentColor","--beam-SelectNonprofit-options-backgroundColor":"transparent","--beam-SelectNonprofit-options-gap":"8px","--beam-SelectNonprofit-options--selected-backgroundColor":"currentColor","--beam-SelectNonprofit-details-marginTop":"10px","--beam-SelectNonprofit-details-borderRadius":"0px","--beam-SelectNonprofit-details-borderWidth":"1px","--beam-SelectNonprofit-details-borderColor":"currentColor","--beam-SelectNonprofit-details-backgroundColor":"inherit","--beam-SelectNonprofit-details-padding":"10px",...u("--beam-SelectNonprofit-title",{fontSize:"1.25em",fontWeight:"bold"}),"--beam-SelectNonprofit-header-inline-lineHeight":"inherit",...u("--beam-SelectNonprofit-title-inline",{fontWeight:"bold"}),"--beam-SelectNonprofit-title-inline-textTransform":"none","--beam-SelectNonprofit-title-block-margin-right":"8px",...u("--beam-SelectNonprofit-description",{marginTop:"0.5em"}),...u("--beam-SelectNonprofit-description-inline"),...u("--beam-SelectNonprofit-details-cause",{fontSize:"0.85em",fontWeight:"bold"}),...u("--beam-SelectNonprofit-details-beamAttribution",{fontSize:"0.85em"}),...u("--beam-SelectNonprofit-details-impactDescription",{fontSize:"1em",marginTop:"10px"}),"--beam-SelectNonprofit-details-nonprofitName-fontWeight":"bold","--beam-SelectNonprofit-details-nonprofitName-fontStyle":"inherit","--beam-SelectNonprofit-details-fundingProgress-marginTop":"10px",...u("--beam-SelectNonprofit-details-fundingProgressLabel",{fontSize:"0.85em"}),...ve,...Ne,"--beam-SelectNonprofit-promo-block-header-justifyContent":"initial","--beam-SelectNonprofit-notification-blip-top":"4px","--beam-SelectNonprofit-notification-blip-left":"50%","--beam-SelectNonprofit-display-notification-blip":"true","--beam-SelectNonprofit-enable-inline-header":"false","--beam-SelectNonprofit-force-multiline-header":"false"},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},n={...e,...t};return Object.assign(Object.create({toCSS(){return te(this)}}),n)}render(){const{selectedNonprofitId:e}=this,{data:t,loading:n}=this.nonprofitListDataController;if(n&&!t)return oe();if(this.nonprofitListDataController.error)return this.debug?T({error:this.nonprofitListDataController.error}):"";if(this.selectionDataController.error&&this.debug)return T({error:this.selectionDataController.error});const i=t?.nonprofits||[],a=i.find(s=>s.nonprofit.id===e)||null,r=!!t?.config?.web?.promo,l=i.some(s=>!s.promo||!s.promo.isActive),g=s=>this.cssVariables[s],j=g("--beam-SelectNonprofit-display-notification-blip")==="true",y=g("--beam-SelectNonprofit-title-textAlign")==="center",R=g("--beam-SelectNonprofit-enable-inline-header")==="true",b=g("--beam-SelectNonprofit-force-multiline-header")!=="true"&&(R||this.isMobile),$=d`<h3
|
|
21
|
+
</div>`}}customElements.get("beam-notification-blip")||customElements.define("beam-notification-blip",Ce);const ve={"--beam-notificationBlip-color-background":"#000"},h={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose your impact",ctaPromoPrefixMessage:()=>"At no extra cost,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`select a nonprofit and ${o}% will be donated for you.`,ctaMessage:({donationPercentage:o="1"}={})=>`At no extra cost, select a nonprofit and ${o}% will be donated for you.`,inlineSeparator:()=>": "},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choisissez votre cause",ctaPromoPrefixMessage:()=>"Sans frais suppl\xE9mentaires,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`s\xE9lectionnez une association et ${o} % sera revers\xE9 en votre nom.`,ctaMessage:({donationPercentage:o="1"}={})=>`Sans frais suppl\xE9mentaires, choisissez une association et ${o} % de votre commande sera revers\xE9 en votre nom.`,inlineSeparator:()=>" : "},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"W\xE4hle deine Wirkung",ctaPromoPrefixMessage:()=>"Ohne zus\xE4tzliche Kosten,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`w\xE4hle eine Organisation und ${o}% deines Einkaufs werden gespendet.`,ctaMessage:({donationPercentage:o="1"}={})=>`Ohne zus\xE4tzliche Kosten kannst du eine gemeinn\xFCtzige Organisation ausw\xE4hlen und ${o}% deiner Bestellung werden gespendet.`,inlineSeparator:()=>": "},es:{beamAttribution:()=>"Ofrecido por Beam",ctaTitle:()=>"Elige tu impacto",ctaPromoPrefixMessage:()=>"Sin coste adicional,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`elige una organizaci\xF3n y donaremos el ${o}% en tu nombre.`,ctaMessage:({donationPercentage:o="1"}={})=>`Sin coste adicional, elige una organizaci\xF3n sin fines de lucro y donaremos el ${o}% de tu compra en tu nombre.`,inlineSeparator:()=>": "},it:{beamAttribution:()=>"Gestito da Beam",ctaTitle:()=>"Scegli il tuo impatto",ctaPromoPrefixMessage:()=>"Senza costi aggiuntivi,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`scegli un'organizzazione e doneremo l\u2019${o}% per te.`,ctaMessage:({donationPercentage:o="1"}={})=>`Senza costi aggiuntivi, seleziona un'organizzazione no-profit e doneremo l\u2019${o}% del tuo acquisto per te.`,inlineSeparator:()=>": "},pl:{beamAttribution:()=>"Obs\u0142ugiwane przez Beam",ctaTitle:()=>"Wybierz sw\xF3j wp\u0142yw",ctaPromoPrefixMessage:()=>"Bez dodatkowych koszt\xF3w,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`wybierz organizacj\u0119, a ${o}% zostanie przekazane w Twoim imieniu.`,ctaMessage:({donationPercentage:o="1"}={})=>`Bez dodatkowych koszt\xF3w wybierz organizacj\u0119, kt\xF3rej przeka\u017Cemy ${o}% warto\u015Bci Twojego zam\xF3wienia w Twoim imieniu.`,inlineSeparator:()=>": "},ja:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"\u5BC4\u4ED8\u5148\u3092\u304A\u9078\u3073\u304F\u3060\u3055\u3044\u3002",ctaPromoPrefixMessage:()=>"\u8FFD\u52A0\u8CBB\u7528\u306A\u3057\u3067\u3001",ctaPromoMessage:({donationPercentage:o="1"}={})=>`\u975E\u55B6\u5229\u56E3\u4F53\u3092\u9078\u3076\u3068\u3001${o}%\u304C\u305D\u306E\u56E3\u4F53\u306B\u5BC4\u4ED8\u3055\u308C\u307E\u3059\u3002`,ctaMessage:({donationPercentage:o="1"}={})=>`\u8FFD\u52A0\u8CBB\u7528\u306A\u3057\u3067\u975E\u55B6\u5229\u56E3\u4F53\u3092\u304A\u9078\u3073\u3044\u305F\u3060\u304F\u3068\u3001\u3054\u8CFC\u5165\u91D1\u984D\u306E${o}%\u304C\u5BC4\u4ED8\u3055\u308C\u307E\u3059\u3002`,inlineSeparator:()=>"\uFF1A"}};var ye=Object.defineProperty,p=(o,e,t,n)=>{for(var i=void 0,a=o.length-1,r;a>=0;a--)(r=o[a])&&(i=r(e,t,i)||i);return i&&ye(e,t,i),i};let j=!1;class c extends D{constructor(){super(...arguments),this.baseUrl=ie,this.selectedNonprofitId=null,this.lang="en",this.debug=!1,this.draftConfig=!1,this.lastSelectionActionDate=new Date,this.isMobile=window.innerWidth<768,this.enableNonprofitDeselection=!1,this.didTryToCreateNewSelectionFromCache=!1,this.pluginPromoCodes=[],this.handlePromoCodesStored=e=>{const t=(e.detail.promoCodes?.unvalidatedPromoCodes??[]).map(n=>n.attributes?.value??n.attributes?.url??"").sort();this.pluginPromoCodes=t},this.getChainNonprofits=async()=>{k(["apiKey"],this);const e=F(z,{apiKey:this.apiKey}),t=M("cart",{apiKey:this.apiKey}),n=this.cart?.content?{schema:this.cart?.schema,content:this.cart?.content}:void 0,i=this.getManualPromoCodes(),a=ne(i.map(g=>({value:g})),this.apiKey),r=a&&!ae(a);r&&this.dispatchEvent(new K({source:v.select_nonprofit}));const l=await Z({baseUrl:this.baseUrl,apiRoot:"/api/v3",headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId,widgetName:v.select_nonprofit,...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode},beamCartId:e||void 0,cartId:t||void 0,version:"1.0.0",lang:this.configLang,...r&&{promos:a},options:{config:{draftConfig:this.draftConfig}},cart:n}});return this.enableNonprofitDeselection=!!l.config.enableNonprofitDeselection,this.selectedNonprofitId!==null&&this.selectedNonprofitId&&!l.nonprofits.map(g=>g.nonprofit.id).includes(this.selectedNonprofitId)&&(this.selectedNonprofitId=null,await this.postSelectNonprofit({selectedNonprofitId:null}),this.localStorage.setItem("nonprofit",null)),l.store?.id&&l.store.id!==this.storeId&&(this.storeId=l.store.id),await this.createNewSelectionForCachedNonprofit(),this.localStorage.setItemJson(O.CHAIN_NONPROFITS,{createdAt:new Date,data:l}),this.handleValidatedPromoCodes(l),l},this.postSelectNonprofit=async({selectedNonprofitId:e})=>{k(["apiKey","storeId"],this);const t=new Date;this.lastSelectionActionDate=t;const n=M("cart",{apiKey:this.apiKey}),i=F(z,{apiKey:this.apiKey}),a=await ee({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{nonprofitId:e,selectionId:this.selectionId,storeId:this.storeId,cartId:n||void 0,beamCartId:i||void 0,creationMethod:"cart",...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode}}}),r=!this.selectionId;this.selectionId=a?.selectionId,this.localStorage.setItem("transaction",this.selectionId),this.localStorage.setItem("nonprofit",e),this.localStorage.setItem("nonprofit_selected_at",t.toISOString()),await this.updateComplete;const l=this.getNonprofitById(e);e!==null&&this.dispatchEvent(new P({selectedNonprofitId:e,selectionId:this.selectionId,nonprofitName:l?.nonprofit?.name??null,source:v.select_nonprofit,timestamp:t,isFirstSelection:r})),e===null&&this.dispatchEvent(new re({newNonprofitId:null,selectionId:this.selectionId,timestamp:t}))},this.nonprofitListDataController=new B(this,this.getChainNonprofits),this.selectionDataController=new B(this,this.postSelectNonprofit),this.localStorage=se(this),this.handleCartChange=e=>{this.cart=e.detail},this.handleNonprofitSelect=e=>{const{selectionId:t,selectedNonprofitId:n,timestamp:i}=e.detail;!i||i<this.lastSelectionActionDate||(this.lastSelectionActionDate=i,this.selectionId!==t&&(this.selectionId=t),this.selectedNonprofitId!==n&&(this.selectedNonprofitId=n??null))},this.handleInitialNonprofitSync=e=>{if(j)return;const{nonprofitId:t,selectionId:n}=e.detail,i=t!==void 0&&this.selectedNonprofitId!==t,a=n!==void 0&&this.selectionId!==n;(i||a)&&(i&&(this.selectedNonprofitId=t),a&&(this.selectionId=n),this.requestUpdate(),j=!0,window.removeEventListener(E.eventName,this.handleInitialNonprofitSync))},this.makeHandleSelect=(e,t,n)=>async i=>{const a=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let r=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?r=n[n.length-1]:r=n[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===n.length-1?r=n[0]:r=n[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(r){a!=null&&(this.selectedNonprofitId=r.nonprofit.id);const l=this.renderRoot.querySelector(`[data-value="${r.nonprofit.id}"]`);l!==null&&(l.tabIndex=0,l.focus());return}}if(i.currentTarget instanceof HTMLElement)if(a===e)if(this.enableNonprofitDeselection)this.selectedNonprofitId=null,this.localStorage.setItem("nonprofit",null);else return;else this.selectedNonprofitId=e;this.dispatchEvent(new le({})),window.removeEventListener(E.eventName,this.handleInitialNonprofitSync),await this.selectionDataController.exec({selectedNonprofitId:this.selectedNonprofitId})},this.evaluateBreakPoints=X(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return ce[this.lang]||"en"}get parsedPromoCodes(){return pe(this.promoCodes)}getManualPromoCodes(){if(this.parsedPromoCodes&&this.parsedPromoCodes.length>0)return this.parsedPromoCodes;const e=this.localStorage.getItemJson("cart");return e?de(e):[]}async handleValidatedPromoCodes(e){e.promos?.validatedPromoCodes?.length&&(await Promise.all([fe({apiKey:this.apiKey,promoCodes:{validatedPromoCodes:e.promos.validatedPromoCodes,unvalidatedPromoCodes:[]}}),me({validatedPromoCodes:e.promos.validatedPromoCodes,domain:this.domain})]),this.dispatchEvent(new K({source:v.select_nonprofit})))}getNonprofitById(e){return e?this.nonprofitListDataController?.data?.nonprofits.find(t=>t.nonprofit.id===e):null}async connectedCallback(){super.connectedCallback(),window.addEventListener(E.eventName,this.handleInitialNonprofitSync),window.addEventListener(P.eventName,this.handleNonprofitSelect),this.nonprofitListDataController.loading=!0,window.addEventListener(W.eventName,this.handleCartChange),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(){await this.restoreStateFromCache(),window.addEventListener(_.eventName,this.handlePromoCodesStored)}async updated(e){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","cart","lang","promoCodes","pluginPromoCodes"];this.pluginPromoCodes;for(const n of t)if(e.has(n)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){window.removeEventListener(W.eventName,this.handleCartChange),window.removeEventListener("resize",this.evaluateBreakPoints),window.removeEventListener(_.eventName,this.handlePromoCodesStored),window.removeEventListener(P.eventName,this.handleNonprofitSelect),super.disconnectedCallback()}async restoreStateFromCache(){try{const e=new Date().valueOf();this.cart=this.localStorage.getItemJson("cart")??void 0;const t=720*60*60*1e3,n=this.localStorage.getItem("nonprofit_selected_at")??0,i=e>new Date(n).valueOf()+t;i?i&&this.selectedNonprofitId!==null&&(await this.postSelectNonprofit({selectedNonprofitId:null}),this.localStorage.setItem("nonprofit",null)):(this.selectedNonprofitId=parseInt(this.localStorage.getItem("nonprofit")||"")||null,this.selectionId=this.localStorage.getItem("transaction")??void 0);const{createdAt:a=0,data:r}=this.localStorage.getItemJson(O.CHAIN_NONPROFITS)||{},l=7200*1e3;!(e>new Date(a).valueOf()+l)&&this.nonprofitListDataController.loading&&(this.nonprofitListDataController.data=r,this.nonprofitListDataController.loading=!1)}catch(e){he.error(e)}}async createNewSelectionForCachedNonprofit(){if(k(["apiKey"],this),!(!this.storeId||this.didTryToCreateNewSelectionFromCache))try{this.didTryToCreateNewSelectionFromCache=!0}catch{}}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...be,"--beam-SelectNonprofit-title-textAlign":"inherit","--beam-SelectNonprofit-description-textAlign":"inherit","--beam-SelectNonprofit-maxWidth":"800px","--beam-SelectNonprofit-options-marginTop":"0px","--beam-SelectNonprofit-options-iconHeight":"24px","--beam-SelectNonprofit-options-padding":"10px","--beam-SelectNonprofit-options-borderRadius":"0px","--beam-SelectNonprofit-options-borderColor":"currentColor","--beam-SelectNonprofit-options-borderWidth":"1px","--beam-SelectNonprofit-options--selected-borderColor":"currentColor","--beam-SelectNonprofit-options-backgroundColor":"transparent","--beam-SelectNonprofit-options-gap":"8px","--beam-SelectNonprofit-options--selected-backgroundColor":"currentColor","--beam-SelectNonprofit-details-marginTop":"10px","--beam-SelectNonprofit-details-borderRadius":"0px","--beam-SelectNonprofit-details-borderWidth":"1px","--beam-SelectNonprofit-details-borderColor":"currentColor","--beam-SelectNonprofit-details-backgroundColor":"inherit","--beam-SelectNonprofit-details-padding":"10px",...u("--beam-SelectNonprofit-title",{fontSize:"1.25em",fontWeight:"bold"}),"--beam-SelectNonprofit-header-inline-lineHeight":"inherit",...u("--beam-SelectNonprofit-title-inline",{fontWeight:"bold"}),"--beam-SelectNonprofit-title-inline-textTransform":"none","--beam-SelectNonprofit-title-block-margin-right":"8px",...u("--beam-SelectNonprofit-description",{marginTop:"0.5em"}),...u("--beam-SelectNonprofit-description-inline"),...u("--beam-SelectNonprofit-details-cause",{fontSize:"0.85em",fontWeight:"bold"}),...u("--beam-SelectNonprofit-details-beamAttribution",{fontSize:"0.85em"}),...u("--beam-SelectNonprofit-details-impactDescription",{fontSize:"1em",marginTop:"10px"}),"--beam-SelectNonprofit-details-nonprofitName-fontWeight":"bold","--beam-SelectNonprofit-details-nonprofitName-fontStyle":"inherit","--beam-SelectNonprofit-details-fundingProgress-marginTop":"10px",...u("--beam-SelectNonprofit-details-fundingProgressLabel",{fontSize:"0.85em"}),...ve,...Ne,"--beam-SelectNonprofit-promo-block-header-justifyContent":"initial","--beam-SelectNonprofit-notification-blip-top":"4px","--beam-SelectNonprofit-notification-blip-left":"50%","--beam-SelectNonprofit-display-notification-blip":"true","--beam-SelectNonprofit-enable-inline-header":"false","--beam-SelectNonprofit-force-multiline-header":"false"},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},n={...e,...t};return Object.assign(Object.create({toCSS(){return te(this)}}),n)}render(){const{selectedNonprofitId:e}=this,{data:t,loading:n}=this.nonprofitListDataController;if(n&&!t)return oe();if(this.nonprofitListDataController.error)return this.debug?T({error:this.nonprofitListDataController.error}):"";if(this.selectionDataController.error&&this.debug)return T({error:this.selectionDataController.error});const i=t?.nonprofits||[],a=i.find(s=>s.nonprofit.id===e)||null,r=!!t?.config?.web?.promo,l=i.some(s=>!s.promo||!s.promo.isActive),g=s=>this.cssVariables[s],U=g("--beam-SelectNonprofit-display-notification-blip")==="true",y=g("--beam-SelectNonprofit-title-textAlign")==="center",R=g("--beam-SelectNonprofit-enable-inline-header")==="true",b=g("--beam-SelectNonprofit-force-multiline-header")!=="true"&&(R||this.isMobile),$=d`<h3
|
|
22
22
|
class=${C({"title-block":!0,"d-none":!0,"d-block":!b})}
|
|
23
23
|
part="title"
|
|
24
24
|
id="beam-SelectNonprofit-title"
|
|
@@ -70,7 +70,7 @@ import{a as D,i as L,b as d,n as f,r as I,e as C,k as J,j as A,h as Y}from"../ch
|
|
|
70
70
|
aria-labelledby="beam-SelectNonprofit-title"
|
|
71
71
|
style="display: flex; gap: var(--beam-SelectNonprofit-options-gap); margin: 10px 0 0 0;"
|
|
72
72
|
>
|
|
73
|
-
${J(i,s=>s.nonprofit.id,({nonprofit:s,promo:w},x)=>{const N=e===s.id,G=N||a==null&&x===0,V=w?.isActive&&t?.config.web.promo&&l&&
|
|
73
|
+
${J(i,s=>s.nonprofit.id,({nonprofit:s,promo:w},x)=>{const N=e===s.id,G=N||a==null&&x===0,V=w?.isActive&&t?.config.web.promo&&l&&U;return d`
|
|
74
74
|
<div
|
|
75
75
|
class="option"
|
|
76
76
|
part="option"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as D,i as L,b as d,n as f,r as I,e as C,k as J,j as A,h as Y}from"../chunks/lit-BEag9MFp.esm.js";import{i as Q,d as X}from"../chunks/lodash-CrMU6wKg.esm.js";import{u as S,B as z,
|
|
1
|
+
import{a as D,i as L,b as d,n as f,r as I,e as C,k as J,j as A,h as Y}from"../chunks/lit-BEag9MFp.esm.js";import{i as Q,d as X}from"../chunks/lodash-CrMU6wKg.esm.js";import{u as S,B as z,j as Z,n as ee,A as B,f as u,h as te,_ as oe,d as T,e as m}from"../chunks/index-D5-gztaa.esm.js";import{D as ie,C as F,K as M,h as ne,E as ae,F as K,W as v,L as O,B as P,M as re,A as se,N as E,O as le,x as ce,G as pe,H as de,I as fe,J as me,P as W,m as _,l as he}from"../chunks/utils-ly9wMwUO.esm.js";import{c as ge,d as ue,e as k}from"../chunks/css-card-grid-tjA36yWj.esm.js";import{a as be}from"../chunks/share-button-CpcTaNLx.esm.js";import{c as Se}from"../chunks/responsive-aN8P5PqD.esm.js";import{p as Ne}from"../chunks/promo-pill-label-BBi4qq7M.esm.js";import"../chunks/_share-dialog-dependencies-CnECvqGU.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";class Ce extends D{static get styles(){return L`
|
|
2
2
|
:host {
|
|
3
3
|
}
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@ import{a as D,i as L,b as d,n as f,r as I,e as C,k as J,j as A,h as Y}from"../ch
|
|
|
18
18
|
aria-label="Notification Blip"
|
|
19
19
|
>
|
|
20
20
|
<span class="notification-blip" part="notification-blip" role="button" tabindex="0" aria-hidden="true"></span>
|
|
21
|
-
</div>`}}customElements.get("beam-notification-blip")||customElements.define("beam-notification-blip",Ce);const ve={"--beam-notificationBlip-color-background":"#000"},h={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose your impact",ctaPromoPrefixMessage:()=>"At no extra cost,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`select a nonprofit and ${o}% will be donated for you.`,ctaMessage:({donationPercentage:o="1"}={})=>`At no extra cost, select a nonprofit and ${o}% will be donated for you.`,inlineSeparator:()=>": "},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choisissez votre cause",ctaPromoPrefixMessage:()=>"Sans frais suppl\xE9mentaires,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`s\xE9lectionnez une association et ${o} % sera revers\xE9 en votre nom.`,ctaMessage:({donationPercentage:o="1"}={})=>`Sans frais suppl\xE9mentaires, choisissez une association et ${o} % de votre commande sera revers\xE9 en votre nom.`,inlineSeparator:()=>" : "},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"W\xE4hle deine Wirkung",ctaPromoPrefixMessage:()=>"Ohne zus\xE4tzliche Kosten,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`w\xE4hle eine Organisation und ${o}% deines Einkaufs werden gespendet.`,ctaMessage:({donationPercentage:o="1"}={})=>`Ohne zus\xE4tzliche Kosten kannst du eine gemeinn\xFCtzige Organisation ausw\xE4hlen und ${o}% deiner Bestellung werden gespendet.`,inlineSeparator:()=>": "},es:{beamAttribution:()=>"Ofrecido por Beam",ctaTitle:()=>"Elige tu impacto",ctaPromoPrefixMessage:()=>"Sin coste adicional,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`elige una organizaci\xF3n y donaremos el ${o}% en tu nombre.`,ctaMessage:({donationPercentage:o="1"}={})=>`Sin coste adicional, elige una organizaci\xF3n sin fines de lucro y donaremos el ${o}% de tu compra en tu nombre.`,inlineSeparator:()=>": "},it:{beamAttribution:()=>"Gestito da Beam",ctaTitle:()=>"Scegli il tuo impatto",ctaPromoPrefixMessage:()=>"Senza costi aggiuntivi,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`scegli un'organizzazione e doneremo l\u2019${o}% per te.`,ctaMessage:({donationPercentage:o="1"}={})=>`Senza costi aggiuntivi, seleziona un'organizzazione no-profit e doneremo l\u2019${o}% del tuo acquisto per te.`,inlineSeparator:()=>": "},pl:{beamAttribution:()=>"Obs\u0142ugiwane przez Beam",ctaTitle:()=>"Wybierz sw\xF3j wp\u0142yw",ctaPromoPrefixMessage:()=>"Bez dodatkowych koszt\xF3w,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`wybierz organizacj\u0119, a ${o}% zostanie przekazane w Twoim imieniu.`,ctaMessage:({donationPercentage:o="1"}={})=>`Bez dodatkowych koszt\xF3w wybierz organizacj\u0119, kt\xF3rej przeka\u017Cemy ${o}% warto\u015Bci Twojego zam\xF3wienia w Twoim imieniu.`,inlineSeparator:()=>": "},ja:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"\u5BC4\u4ED8\u5148\u3092\u304A\u9078\u3073\u304F\u3060\u3055\u3044\u3002",ctaPromoPrefixMessage:()=>"\u8FFD\u52A0\u8CBB\u7528\u306A\u3057\u3067\u3001",ctaPromoMessage:({donationPercentage:o="1"}={})=>`\u975E\u55B6\u5229\u56E3\u4F53\u3092\u9078\u3076\u3068\u3001${o}%\u304C\u305D\u306E\u56E3\u4F53\u306B\u5BC4\u4ED8\u3055\u308C\u307E\u3059\u3002`,ctaMessage:({donationPercentage:o="1"}={})=>`\u8FFD\u52A0\u8CBB\u7528\u306A\u3057\u3067\u975E\u55B6\u5229\u56E3\u4F53\u3092\u304A\u9078\u3073\u3044\u305F\u3060\u304F\u3068\u3001\u3054\u8CFC\u5165\u91D1\u984D\u306E${o}%\u304C\u5BC4\u4ED8\u3055\u308C\u307E\u3059\u3002`,inlineSeparator:()=>"\uFF1A"}};var ye=Object.defineProperty,p=(o,e,t,n)=>{for(var i=void 0,a=o.length-1,r;a>=0;a--)(r=o[a])&&(i=r(e,t,i)||i);return i&&ye(e,t,i),i};let U=!1;class c extends D{constructor(){super(...arguments),this.baseUrl=ie,this.selectedNonprofitId=null,this.lang="en",this.debug=!1,this.draftConfig=!1,this.lastSelectionActionDate=new Date,this.isMobile=window.innerWidth<768,this.enableNonprofitDeselection=!1,this.didTryToCreateNewSelectionFromCache=!1,this.pluginPromoCodes=[],this.handlePromoCodesStored=e=>{const t=(e.detail.promoCodes?.unvalidatedPromoCodes??[]).map(n=>n.attributes?.value??n.attributes?.url??"").sort();this.pluginPromoCodes=t},this.getChainNonprofits=async()=>{k(["apiKey"],this);const e=F(z,{apiKey:this.apiKey}),t=M("cart",{apiKey:this.apiKey}),n=this.cart?.content?{schema:this.cart?.schema,content:this.cart?.content}:void 0,i=this.getManualPromoCodes(),a=ne(i.map(g=>({value:g})),this.apiKey),r=a&&!ae(a);r&&this.dispatchEvent(new K({source:v.select_nonprofit}));const l=await Z({baseUrl:this.baseUrl,apiRoot:"/api/v3",headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId,widgetName:v.select_nonprofit,...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode},beamCartId:e||void 0,cartId:t||void 0,version:"1.0.0",lang:this.configLang,...r&&{promos:a},options:{config:{draftConfig:this.draftConfig}},cart:n}});return this.enableNonprofitDeselection=!!l.config.enableNonprofitDeselection,this.selectedNonprofitId!==null&&this.selectedNonprofitId&&!l.nonprofits.map(g=>g.nonprofit.id).includes(this.selectedNonprofitId)&&(this.selectedNonprofitId=null,await this.postSelectNonprofit({selectedNonprofitId:null}),this.localStorage.setItem("nonprofit",null)),l.store?.id&&l.store.id!==this.storeId&&(this.storeId=l.store.id),await this.createNewSelectionForCachedNonprofit(),this.localStorage.setItemJson(O.CHAIN_NONPROFITS,{createdAt:new Date,data:l}),this.handleValidatedPromoCodes(l),l},this.postSelectNonprofit=async({selectedNonprofitId:e})=>{k(["apiKey","storeId"],this);const t=new Date;this.lastSelectionActionDate=t;const n=M("cart",{apiKey:this.apiKey}),i=F(z,{apiKey:this.apiKey}),a=await ee({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{nonprofitId:e,selectionId:this.selectionId,storeId:this.storeId,cartId:n||void 0,beamCartId:i||void 0,creationMethod:"cart",...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode}}}),r=!this.selectionId;this.selectionId=a?.selectionId,this.localStorage.setItem("transaction",this.selectionId),this.localStorage.setItem("nonprofit",e),this.localStorage.setItem("nonprofit_selected_at",t.toISOString()),await this.updateComplete;const l=this.getNonprofitById(e);e!==null&&this.dispatchEvent(new P({selectedNonprofitId:e,selectionId:this.selectionId,nonprofitName:l?.nonprofit?.name??null,source:v.select_nonprofit,timestamp:t,isFirstSelection:r})),e===null&&this.dispatchEvent(new re({newNonprofitId:null,selectionId:this.selectionId,timestamp:t}))},this.nonprofitListDataController=new B(this,this.getChainNonprofits),this.selectionDataController=new B(this,this.postSelectNonprofit),this.localStorage=se(this),this.handleCartChange=e=>{this.cart=e.detail},this.handleNonprofitSelect=e=>{const{selectionId:t,selectedNonprofitId:n,timestamp:i}=e.detail;!i||i<this.lastSelectionActionDate||(this.lastSelectionActionDate=i,this.selectionId!==t&&(this.selectionId=t),this.selectedNonprofitId!==n&&(this.selectedNonprofitId=n??null))},this.handleInitialNonprofitSync=e=>{if(U)return;const{nonprofitId:t,selectionId:n}=e.detail,i=t!==void 0&&this.selectedNonprofitId!==t,a=n!==void 0&&this.selectionId!==n;(i||a)&&(i&&(this.selectedNonprofitId=t),a&&(this.selectionId=n),this.requestUpdate(),U=!0,window.removeEventListener(E.eventName,this.handleInitialNonprofitSync))},this.makeHandleSelect=(e,t,n)=>async i=>{const a=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let r=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?r=n[n.length-1]:r=n[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===n.length-1?r=n[0]:r=n[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(r){a!=null&&(this.selectedNonprofitId=r.nonprofit.id);const l=this.renderRoot.querySelector(`[data-value="${r.nonprofit.id}"]`);l!==null&&(l.tabIndex=0,l.focus());return}}if(i.currentTarget instanceof HTMLElement)if(a===e)if(this.enableNonprofitDeselection)this.selectedNonprofitId=null,this.localStorage.setItem("nonprofit",null);else return;else this.selectedNonprofitId=e;this.dispatchEvent(new le({})),window.removeEventListener(E.eventName,this.handleInitialNonprofitSync),await this.selectionDataController.exec({selectedNonprofitId:this.selectedNonprofitId})},this.evaluateBreakPoints=X(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return ce[this.lang]||"en"}get parsedPromoCodes(){return pe(this.promoCodes)}getManualPromoCodes(){if(this.parsedPromoCodes&&this.parsedPromoCodes.length>0)return this.parsedPromoCodes;const e=this.localStorage.getItemJson("cart");return e?de(e):[]}async handleValidatedPromoCodes(e){e.promos?.validatedPromoCodes?.length&&(await Promise.all([fe({apiKey:this.apiKey,promoCodes:{validatedPromoCodes:e.promos.validatedPromoCodes,unvalidatedPromoCodes:[]}}),me({validatedPromoCodes:e.promos.validatedPromoCodes,domain:this.domain})]),this.dispatchEvent(new K({source:v.select_nonprofit})))}getNonprofitById(e){return e?this.nonprofitListDataController?.data?.nonprofits.find(t=>t.nonprofit.id===e):null}async connectedCallback(){super.connectedCallback(),window.addEventListener(E.eventName,this.handleInitialNonprofitSync),window.addEventListener(P.eventName,this.handleNonprofitSelect),this.nonprofitListDataController.loading=!0,window.addEventListener(W.eventName,this.handleCartChange),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(){await this.restoreStateFromCache(),window.addEventListener(_.eventName,this.handlePromoCodesStored)}async updated(e){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","cart","lang","promoCodes","pluginPromoCodes"];this.pluginPromoCodes;for(const n of t)if(e.has(n)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){window.removeEventListener(W.eventName,this.handleCartChange),window.removeEventListener("resize",this.evaluateBreakPoints),window.removeEventListener(_.eventName,this.handlePromoCodesStored),window.removeEventListener(P.eventName,this.handleNonprofitSelect),super.disconnectedCallback()}async restoreStateFromCache(){try{const e=new Date().valueOf();this.cart=this.localStorage.getItemJson("cart")??void 0;const t=720*60*60*1e3,n=this.localStorage.getItem("nonprofit_selected_at")??0,i=e>new Date(n).valueOf()+t;i?i&&this.selectedNonprofitId!==null&&(await this.postSelectNonprofit({selectedNonprofitId:null}),this.localStorage.setItem("nonprofit",null)):(this.selectedNonprofitId=parseInt(this.localStorage.getItem("nonprofit")||"")||null,this.selectionId=this.localStorage.getItem("transaction")??void 0);const{createdAt:a=0,data:r}=this.localStorage.getItemJson(O.CHAIN_NONPROFITS)||{},l=7200*1e3;!(e>new Date(a).valueOf()+l)&&this.nonprofitListDataController.loading&&(this.nonprofitListDataController.data=r,this.nonprofitListDataController.loading=!1)}catch(e){he.error(e)}}async createNewSelectionForCachedNonprofit(){if(k(["apiKey"],this),!(!this.storeId||this.didTryToCreateNewSelectionFromCache))try{this.didTryToCreateNewSelectionFromCache=!0}catch{}}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...be,"--beam-SelectNonprofit-title-textAlign":"inherit","--beam-SelectNonprofit-description-textAlign":"inherit","--beam-SelectNonprofit-maxWidth":"800px","--beam-SelectNonprofit-options-marginTop":"0px","--beam-SelectNonprofit-options-iconHeight":"24px","--beam-SelectNonprofit-options-padding":"10px","--beam-SelectNonprofit-options-borderRadius":"0px","--beam-SelectNonprofit-options-borderColor":"currentColor","--beam-SelectNonprofit-options-borderWidth":"1px","--beam-SelectNonprofit-options--selected-borderColor":"currentColor","--beam-SelectNonprofit-options-backgroundColor":"transparent","--beam-SelectNonprofit-options-gap":"8px","--beam-SelectNonprofit-options--selected-backgroundColor":"currentColor","--beam-SelectNonprofit-details-marginTop":"10px","--beam-SelectNonprofit-details-borderRadius":"0px","--beam-SelectNonprofit-details-borderWidth":"1px","--beam-SelectNonprofit-details-borderColor":"currentColor","--beam-SelectNonprofit-details-backgroundColor":"inherit","--beam-SelectNonprofit-details-padding":"10px",...u("--beam-SelectNonprofit-title",{fontSize:"1.25em",fontWeight:"bold"}),"--beam-SelectNonprofit-header-inline-lineHeight":"inherit",...u("--beam-SelectNonprofit-title-inline",{fontWeight:"bold"}),"--beam-SelectNonprofit-title-inline-textTransform":"none","--beam-SelectNonprofit-title-block-margin-right":"8px",...u("--beam-SelectNonprofit-description",{marginTop:"0.5em"}),...u("--beam-SelectNonprofit-description-inline"),...u("--beam-SelectNonprofit-details-cause",{fontSize:"0.85em",fontWeight:"bold"}),...u("--beam-SelectNonprofit-details-beamAttribution",{fontSize:"0.85em"}),...u("--beam-SelectNonprofit-details-impactDescription",{fontSize:"1em",marginTop:"10px"}),"--beam-SelectNonprofit-details-nonprofitName-fontWeight":"bold","--beam-SelectNonprofit-details-nonprofitName-fontStyle":"inherit","--beam-SelectNonprofit-details-fundingProgress-marginTop":"10px",...u("--beam-SelectNonprofit-details-fundingProgressLabel",{fontSize:"0.85em"}),...ve,...Ne,"--beam-SelectNonprofit-promo-block-header-justifyContent":"initial","--beam-SelectNonprofit-notification-blip-top":"4px","--beam-SelectNonprofit-notification-blip-left":"50%","--beam-SelectNonprofit-display-notification-blip":"true","--beam-SelectNonprofit-enable-inline-header":"false","--beam-SelectNonprofit-force-multiline-header":"false"},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},n={...e,...t};return Object.assign(Object.create({toCSS(){return te(this)}}),n)}render(){const{selectedNonprofitId:e}=this,{data:t,loading:n}=this.nonprofitListDataController;if(n&&!t)return oe();if(this.nonprofitListDataController.error)return this.debug?T({error:this.nonprofitListDataController.error}):"";if(this.selectionDataController.error&&this.debug)return T({error:this.selectionDataController.error});const i=t?.nonprofits||[],a=i.find(s=>s.nonprofit.id===e)||null,r=!!t?.config?.web?.promo,l=i.some(s=>!s.promo||!s.promo.isActive),g=s=>this.cssVariables[s],j=g("--beam-SelectNonprofit-display-notification-blip")==="true",y=g("--beam-SelectNonprofit-title-textAlign")==="center",R=g("--beam-SelectNonprofit-enable-inline-header")==="true",b=g("--beam-SelectNonprofit-force-multiline-header")!=="true"&&(R||this.isMobile),$=d`<h3
|
|
21
|
+
</div>`}}customElements.get("beam-notification-blip")||customElements.define("beam-notification-blip",Ce);const ve={"--beam-notificationBlip-color-background":"#000"},h={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose your impact",ctaPromoPrefixMessage:()=>"At no extra cost,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`select a nonprofit and ${o}% will be donated for you.`,ctaMessage:({donationPercentage:o="1"}={})=>`At no extra cost, select a nonprofit and ${o}% will be donated for you.`,inlineSeparator:()=>": "},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choisissez votre cause",ctaPromoPrefixMessage:()=>"Sans frais suppl\xE9mentaires,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`s\xE9lectionnez une association et ${o} % sera revers\xE9 en votre nom.`,ctaMessage:({donationPercentage:o="1"}={})=>`Sans frais suppl\xE9mentaires, choisissez une association et ${o} % de votre commande sera revers\xE9 en votre nom.`,inlineSeparator:()=>" : "},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"W\xE4hle deine Wirkung",ctaPromoPrefixMessage:()=>"Ohne zus\xE4tzliche Kosten,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`w\xE4hle eine Organisation und ${o}% deines Einkaufs werden gespendet.`,ctaMessage:({donationPercentage:o="1"}={})=>`Ohne zus\xE4tzliche Kosten kannst du eine gemeinn\xFCtzige Organisation ausw\xE4hlen und ${o}% deiner Bestellung werden gespendet.`,inlineSeparator:()=>": "},es:{beamAttribution:()=>"Ofrecido por Beam",ctaTitle:()=>"Elige tu impacto",ctaPromoPrefixMessage:()=>"Sin coste adicional,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`elige una organizaci\xF3n y donaremos el ${o}% en tu nombre.`,ctaMessage:({donationPercentage:o="1"}={})=>`Sin coste adicional, elige una organizaci\xF3n sin fines de lucro y donaremos el ${o}% de tu compra en tu nombre.`,inlineSeparator:()=>": "},it:{beamAttribution:()=>"Gestito da Beam",ctaTitle:()=>"Scegli il tuo impatto",ctaPromoPrefixMessage:()=>"Senza costi aggiuntivi,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`scegli un'organizzazione e doneremo l\u2019${o}% per te.`,ctaMessage:({donationPercentage:o="1"}={})=>`Senza costi aggiuntivi, seleziona un'organizzazione no-profit e doneremo l\u2019${o}% del tuo acquisto per te.`,inlineSeparator:()=>": "},pl:{beamAttribution:()=>"Obs\u0142ugiwane przez Beam",ctaTitle:()=>"Wybierz sw\xF3j wp\u0142yw",ctaPromoPrefixMessage:()=>"Bez dodatkowych koszt\xF3w,",ctaPromoMessage:({donationPercentage:o="1"}={})=>`wybierz organizacj\u0119, a ${o}% zostanie przekazane w Twoim imieniu.`,ctaMessage:({donationPercentage:o="1"}={})=>`Bez dodatkowych koszt\xF3w wybierz organizacj\u0119, kt\xF3rej przeka\u017Cemy ${o}% warto\u015Bci Twojego zam\xF3wienia w Twoim imieniu.`,inlineSeparator:()=>": "},ja:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"\u5BC4\u4ED8\u5148\u3092\u304A\u9078\u3073\u304F\u3060\u3055\u3044\u3002",ctaPromoPrefixMessage:()=>"\u8FFD\u52A0\u8CBB\u7528\u306A\u3057\u3067\u3001",ctaPromoMessage:({donationPercentage:o="1"}={})=>`\u975E\u55B6\u5229\u56E3\u4F53\u3092\u9078\u3076\u3068\u3001${o}%\u304C\u305D\u306E\u56E3\u4F53\u306B\u5BC4\u4ED8\u3055\u308C\u307E\u3059\u3002`,ctaMessage:({donationPercentage:o="1"}={})=>`\u8FFD\u52A0\u8CBB\u7528\u306A\u3057\u3067\u975E\u55B6\u5229\u56E3\u4F53\u3092\u304A\u9078\u3073\u3044\u305F\u3060\u304F\u3068\u3001\u3054\u8CFC\u5165\u91D1\u984D\u306E${o}%\u304C\u5BC4\u4ED8\u3055\u308C\u307E\u3059\u3002`,inlineSeparator:()=>"\uFF1A"}};var ye=Object.defineProperty,p=(o,e,t,n)=>{for(var i=void 0,a=o.length-1,r;a>=0;a--)(r=o[a])&&(i=r(e,t,i)||i);return i&&ye(e,t,i),i};let j=!1;class c extends D{constructor(){super(...arguments),this.baseUrl=ie,this.selectedNonprofitId=null,this.lang="en",this.debug=!1,this.draftConfig=!1,this.lastSelectionActionDate=new Date,this.isMobile=window.innerWidth<768,this.enableNonprofitDeselection=!1,this.didTryToCreateNewSelectionFromCache=!1,this.pluginPromoCodes=[],this.handlePromoCodesStored=e=>{const t=(e.detail.promoCodes?.unvalidatedPromoCodes??[]).map(n=>n.attributes?.value??n.attributes?.url??"").sort();this.pluginPromoCodes=t},this.getChainNonprofits=async()=>{k(["apiKey"],this);const e=F(z,{apiKey:this.apiKey}),t=M("cart",{apiKey:this.apiKey}),n=this.cart?.content?{schema:this.cart?.schema,content:this.cart?.content}:void 0,i=this.getManualPromoCodes(),a=ne(i.map(g=>({value:g})),this.apiKey),r=a&&!ae(a);r&&this.dispatchEvent(new K({source:v.select_nonprofit}));const l=await Z({baseUrl:this.baseUrl,apiRoot:"/api/v3",headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId,widgetName:v.select_nonprofit,...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode},beamCartId:e||void 0,cartId:t||void 0,version:"1.0.0",lang:this.configLang,...r&&{promos:a},options:{config:{draftConfig:this.draftConfig}},cart:n}});return this.enableNonprofitDeselection=!!l.config.enableNonprofitDeselection,this.selectedNonprofitId!==null&&this.selectedNonprofitId&&!l.nonprofits.map(g=>g.nonprofit.id).includes(this.selectedNonprofitId)&&(this.selectedNonprofitId=null,await this.postSelectNonprofit({selectedNonprofitId:null}),this.localStorage.setItem("nonprofit",null)),l.store?.id&&l.store.id!==this.storeId&&(this.storeId=l.store.id),await this.createNewSelectionForCachedNonprofit(),this.localStorage.setItemJson(O.CHAIN_NONPROFITS,{createdAt:new Date,data:l}),this.handleValidatedPromoCodes(l),l},this.postSelectNonprofit=async({selectedNonprofitId:e})=>{k(["apiKey","storeId"],this);const t=new Date;this.lastSelectionActionDate=t;const n=M("cart",{apiKey:this.apiKey}),i=F(z,{apiKey:this.apiKey}),a=await ee({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{nonprofitId:e,selectionId:this.selectionId,storeId:this.storeId,cartId:n||void 0,beamCartId:i||void 0,creationMethod:"cart",...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode}}}),r=!this.selectionId;this.selectionId=a?.selectionId,this.localStorage.setItem("transaction",this.selectionId),this.localStorage.setItem("nonprofit",e),this.localStorage.setItem("nonprofit_selected_at",t.toISOString()),await this.updateComplete;const l=this.getNonprofitById(e);e!==null&&this.dispatchEvent(new P({selectedNonprofitId:e,selectionId:this.selectionId,nonprofitName:l?.nonprofit?.name??null,source:v.select_nonprofit,timestamp:t,isFirstSelection:r})),e===null&&this.dispatchEvent(new re({newNonprofitId:null,selectionId:this.selectionId,timestamp:t}))},this.nonprofitListDataController=new B(this,this.getChainNonprofits),this.selectionDataController=new B(this,this.postSelectNonprofit),this.localStorage=se(this),this.handleCartChange=e=>{this.cart=e.detail},this.handleNonprofitSelect=e=>{const{selectionId:t,selectedNonprofitId:n,timestamp:i}=e.detail;!i||i<this.lastSelectionActionDate||(this.lastSelectionActionDate=i,this.selectionId!==t&&(this.selectionId=t),this.selectedNonprofitId!==n&&(this.selectedNonprofitId=n??null))},this.handleInitialNonprofitSync=e=>{if(j)return;const{nonprofitId:t,selectionId:n}=e.detail,i=t!==void 0&&this.selectedNonprofitId!==t,a=n!==void 0&&this.selectionId!==n;(i||a)&&(i&&(this.selectedNonprofitId=t),a&&(this.selectionId=n),this.requestUpdate(),j=!0,window.removeEventListener(E.eventName,this.handleInitialNonprofitSync))},this.makeHandleSelect=(e,t,n)=>async i=>{const a=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let r=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?r=n[n.length-1]:r=n[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===n.length-1?r=n[0]:r=n[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(r){a!=null&&(this.selectedNonprofitId=r.nonprofit.id);const l=this.renderRoot.querySelector(`[data-value="${r.nonprofit.id}"]`);l!==null&&(l.tabIndex=0,l.focus());return}}if(i.currentTarget instanceof HTMLElement)if(a===e)if(this.enableNonprofitDeselection)this.selectedNonprofitId=null,this.localStorage.setItem("nonprofit",null);else return;else this.selectedNonprofitId=e;this.dispatchEvent(new le({})),window.removeEventListener(E.eventName,this.handleInitialNonprofitSync),await this.selectionDataController.exec({selectedNonprofitId:this.selectedNonprofitId})},this.evaluateBreakPoints=X(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return ce[this.lang]||"en"}get parsedPromoCodes(){return pe(this.promoCodes)}getManualPromoCodes(){if(this.parsedPromoCodes&&this.parsedPromoCodes.length>0)return this.parsedPromoCodes;const e=this.localStorage.getItemJson("cart");return e?de(e):[]}async handleValidatedPromoCodes(e){e.promos?.validatedPromoCodes?.length&&(await Promise.all([fe({apiKey:this.apiKey,promoCodes:{validatedPromoCodes:e.promos.validatedPromoCodes,unvalidatedPromoCodes:[]}}),me({validatedPromoCodes:e.promos.validatedPromoCodes,domain:this.domain})]),this.dispatchEvent(new K({source:v.select_nonprofit})))}getNonprofitById(e){return e?this.nonprofitListDataController?.data?.nonprofits.find(t=>t.nonprofit.id===e):null}async connectedCallback(){super.connectedCallback(),window.addEventListener(E.eventName,this.handleInitialNonprofitSync),window.addEventListener(P.eventName,this.handleNonprofitSelect),this.nonprofitListDataController.loading=!0,window.addEventListener(W.eventName,this.handleCartChange),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(){await this.restoreStateFromCache(),window.addEventListener(_.eventName,this.handlePromoCodesStored)}async updated(e){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","cart","lang","promoCodes","pluginPromoCodes"];this.pluginPromoCodes;for(const n of t)if(e.has(n)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){window.removeEventListener(W.eventName,this.handleCartChange),window.removeEventListener("resize",this.evaluateBreakPoints),window.removeEventListener(_.eventName,this.handlePromoCodesStored),window.removeEventListener(P.eventName,this.handleNonprofitSelect),super.disconnectedCallback()}async restoreStateFromCache(){try{const e=new Date().valueOf();this.cart=this.localStorage.getItemJson("cart")??void 0;const t=720*60*60*1e3,n=this.localStorage.getItem("nonprofit_selected_at")??0,i=e>new Date(n).valueOf()+t;i?i&&this.selectedNonprofitId!==null&&(await this.postSelectNonprofit({selectedNonprofitId:null}),this.localStorage.setItem("nonprofit",null)):(this.selectedNonprofitId=parseInt(this.localStorage.getItem("nonprofit")||"")||null,this.selectionId=this.localStorage.getItem("transaction")??void 0);const{createdAt:a=0,data:r}=this.localStorage.getItemJson(O.CHAIN_NONPROFITS)||{},l=7200*1e3;!(e>new Date(a).valueOf()+l)&&this.nonprofitListDataController.loading&&(this.nonprofitListDataController.data=r,this.nonprofitListDataController.loading=!1)}catch(e){he.error(e)}}async createNewSelectionForCachedNonprofit(){if(k(["apiKey"],this),!(!this.storeId||this.didTryToCreateNewSelectionFromCache))try{this.didTryToCreateNewSelectionFromCache=!0}catch{}}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...be,"--beam-SelectNonprofit-title-textAlign":"inherit","--beam-SelectNonprofit-description-textAlign":"inherit","--beam-SelectNonprofit-maxWidth":"800px","--beam-SelectNonprofit-options-marginTop":"0px","--beam-SelectNonprofit-options-iconHeight":"24px","--beam-SelectNonprofit-options-padding":"10px","--beam-SelectNonprofit-options-borderRadius":"0px","--beam-SelectNonprofit-options-borderColor":"currentColor","--beam-SelectNonprofit-options-borderWidth":"1px","--beam-SelectNonprofit-options--selected-borderColor":"currentColor","--beam-SelectNonprofit-options-backgroundColor":"transparent","--beam-SelectNonprofit-options-gap":"8px","--beam-SelectNonprofit-options--selected-backgroundColor":"currentColor","--beam-SelectNonprofit-details-marginTop":"10px","--beam-SelectNonprofit-details-borderRadius":"0px","--beam-SelectNonprofit-details-borderWidth":"1px","--beam-SelectNonprofit-details-borderColor":"currentColor","--beam-SelectNonprofit-details-backgroundColor":"inherit","--beam-SelectNonprofit-details-padding":"10px",...u("--beam-SelectNonprofit-title",{fontSize:"1.25em",fontWeight:"bold"}),"--beam-SelectNonprofit-header-inline-lineHeight":"inherit",...u("--beam-SelectNonprofit-title-inline",{fontWeight:"bold"}),"--beam-SelectNonprofit-title-inline-textTransform":"none","--beam-SelectNonprofit-title-block-margin-right":"8px",...u("--beam-SelectNonprofit-description",{marginTop:"0.5em"}),...u("--beam-SelectNonprofit-description-inline"),...u("--beam-SelectNonprofit-details-cause",{fontSize:"0.85em",fontWeight:"bold"}),...u("--beam-SelectNonprofit-details-beamAttribution",{fontSize:"0.85em"}),...u("--beam-SelectNonprofit-details-impactDescription",{fontSize:"1em",marginTop:"10px"}),"--beam-SelectNonprofit-details-nonprofitName-fontWeight":"bold","--beam-SelectNonprofit-details-nonprofitName-fontStyle":"inherit","--beam-SelectNonprofit-details-fundingProgress-marginTop":"10px",...u("--beam-SelectNonprofit-details-fundingProgressLabel",{fontSize:"0.85em"}),...ve,...Ne,"--beam-SelectNonprofit-promo-block-header-justifyContent":"initial","--beam-SelectNonprofit-notification-blip-top":"4px","--beam-SelectNonprofit-notification-blip-left":"50%","--beam-SelectNonprofit-display-notification-blip":"true","--beam-SelectNonprofit-enable-inline-header":"false","--beam-SelectNonprofit-force-multiline-header":"false"},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},n={...e,...t};return Object.assign(Object.create({toCSS(){return te(this)}}),n)}render(){const{selectedNonprofitId:e}=this,{data:t,loading:n}=this.nonprofitListDataController;if(n&&!t)return oe();if(this.nonprofitListDataController.error)return this.debug?T({error:this.nonprofitListDataController.error}):"";if(this.selectionDataController.error&&this.debug)return T({error:this.selectionDataController.error});const i=t?.nonprofits||[],a=i.find(s=>s.nonprofit.id===e)||null,r=!!t?.config?.web?.promo,l=i.some(s=>!s.promo||!s.promo.isActive),g=s=>this.cssVariables[s],U=g("--beam-SelectNonprofit-display-notification-blip")==="true",y=g("--beam-SelectNonprofit-title-textAlign")==="center",R=g("--beam-SelectNonprofit-enable-inline-header")==="true",b=g("--beam-SelectNonprofit-force-multiline-header")!=="true"&&(R||this.isMobile),$=d`<h3
|
|
22
22
|
class=${C({"title-block":!0,"d-none":!0,"d-block":!b})}
|
|
23
23
|
part="title"
|
|
24
24
|
id="beam-SelectNonprofit-title"
|
|
@@ -70,7 +70,7 @@ import{a as D,i as L,b as d,n as f,r as I,e as C,k as J,j as A,h as Y}from"../ch
|
|
|
70
70
|
aria-labelledby="beam-SelectNonprofit-title"
|
|
71
71
|
style="display: flex; gap: var(--beam-SelectNonprofit-options-gap); margin: 10px 0 0 0;"
|
|
72
72
|
>
|
|
73
|
-
${J(i,s=>s.nonprofit.id,({nonprofit:s,promo:w},x)=>{const N=e===s.id,G=N||a==null&&x===0,V=w?.isActive&&t?.config.web.promo&&l&&
|
|
73
|
+
${J(i,s=>s.nonprofit.id,({nonprofit:s,promo:w},x)=>{const N=e===s.id,G=N||a==null&&x===0,V=w?.isActive&&t?.config.web.promo&&l&&U;return d`
|
|
74
74
|
<div
|
|
75
75
|
class="option"
|
|
76
76
|
part="option"
|