@beamimpact/web-sdk
Version:
The Beam SDK enables brands to connect with their customers over shared values, not transactional discounts, to build stronger loyalty. Our integration achieves this by allowing customers to (a) choose a nonprofit where the brand will donate part of their
3 lines (2 loc) • 1.79 kB
JavaScript
import{a as u}from"../chunks/events-Dki0ka4F.esm.js";import{getPromoCodesLocalStorage as P,formatStoreAndReturnPromoCodes as f,promoCodesAreEqual as g,getSanitizedUrlForStorage as v,getPromoCodeFromShopifyCookie as k}from"../utils/promoManager.js";import{logger as t}from"../utils/logger.js";import"../chunks/promo-types-DKAOFHJr.esm.js";import"../chunks/beam-errors-Ci0d3926.esm.js";import"../utils/cookies.js";import"../utils/local-storage.js";var y=(o,e,r)=>{if(!e.has(o))throw TypeError("Cannot "+r)},s=(o,e,r)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,r)},n=(o,e,r)=>(y(o,e,"access private method"),r),d,h,m,p,c,C;class S{constructor(e){s(this,d),s(this,m),s(this,c),this.name="promoManager",this.promoCodes={unvalidatedPromoCodes:[],validatedPromoCodes:[]},this.disableDiscountCodeCookieCheck=!!e?.disableDiscountCodeCookieCheck}async init(e){try{const r=n(this,d,h).call(this),a=this.disableDiscountCodeCookieCheck?null:n(this,m,p).call(this);if(r||a){const l=P({apiKey:e.apiKey})??{unvalidatedPromoCodes:[],validatedPromoCodes:[]},i=[];r&&i.push(r),a&&i.push({value:a}),this.promoCodes=f(i,e.apiKey),!g(this.promoCodes,l)&&n(this,c,C).call(this)}}catch(r){t.error("[PromoManager] Initialization failed:",r)}}}d=new WeakSet,h=function(){try{return v()}catch(o){t.error("[PromoManager] URL sanitization error:",o);return}},m=new WeakSet,p=function(){try{return k()}catch(o){return t.error("[PromoManager] Cookie extraction error:",o),null}},c=new WeakSet,C=function(){if(this.promoCodes)try{const o=new u({promoCodes:{...this.promoCodes}});window.dispatchEvent(o)}catch(o){t.error("[PromoManager] Failed to dispatch event:",o)}};export{S as PromoManagerPlugin};
//# sourceMappingURL=promoManager.js.map