1import{C as l}from"./site.B0Uxz9u8.js";import{c as d}from"./cart.BfET_Op9.js";import{u as f}from"./createStore.Dm90ZrIA.js";import{L as m}from"./LocalStorageCache.s6TLHOVx.js";import"./password-strength.AqUmoxgQ.js";const p=3e4,o="spektrixBasket";class g{constructor(t,e){this.apiBase=t,this.cache=e}buildUrl(t){return`${this.apiBase}/${t}`}isCacheValid(t){return!!t&&Date.now()-t.timestamp<p}async fetchBasket(t=!1){if(!t){const a=this.cache.get(o);if(this.isCacheValid(a))return a.data}const e=await fetch(this.buildUrl("basket?$expand=1"),{credentials:"include"});if(!e.ok)return null;const n=await e.json();return this.cache.set(o,{data:n,timestamp:Date.now()}),n}async fetchFunds(){const t=await fetch(this.buildUrl("funds"),{credentials:"include"});return t.ok?await t.json():[]}async fetchMemberships(){const t=await fetch(this.buildUrl("memberships"),{credentials:"include"});return t.ok?await t.json():[]}async fetchCustomer(){const t=await fetch(this.buildUrl("customer"),{credentials:"include"});return t.ok?t.json():null}}const k=s=>{const t=new m;return new g(s.apiBase,t)};function B(s){if(s===null)return 0;const{tickets:t=[],donations:e=[],giftVouchers:n=[],merchandiseItems:a=[],membershipSubscriptions:h=[]}=s,u=h.filter(r=>!("relatedDonationId"in r)||r.relatedDonationId===null).length;return t.length+e.length+n.length+a.length+u}function b(s){if(typeof s!="string"||!s.startsWith("basketContents:"))return!1;try{const t=JSON.parse(s.substring(15));return typeof t=="object"&&t!==null&&"tickets"in t&&"total"in t}catch{return!1}}const i=class i extends l{constructor(){super(...arguments),this.client=null,this.boundOnPostMessage=this.onPostMessage.bind(this)}async connect(){f(this),this.hasIframe&&window.addEventListener("message",this.boundOnPostMessage),this.client=k({apiBase:this.apiBaseValue}),this.addComponentListeners(),this.hasIframe||await this.fetchBasket()}addComponentListeners(){const t=document.querySelectorAll("[data-spektrix-component]");for(const e of t)e.addEventListener("success",async()=>{await this.fetchBasket(!0)})}disconnect(){this.hasIframe&&window.removeEventListener("message",this.boundOnPostMessage)}get hasIframe(){return!!document.getElementById(this.iframeIdValue)}async fetchBasket(t=!1){var e;try{const n=await((e=this.client)==null?void 0:e.fetchBasket(t));this.handleBasketResponse(n??null)}catch{}}async onPostMessage(t){if(this.iframeOriginValue.includes(t.origin)){if(t.data==="basketUpdated"){await this.fetchBasket();return}if(b(t.data))try{const e=JSON.parse(t.data.substring(15));this.handleBasketResponse(e)}catch{}}}handleBasketResponse(t){if(t===null){this.setCartCountValue(0);return}const e=B(t);this.setCartCountValue(e)}};i.stores=[d],i.values={apiBase:String,iframeId:String,iframeOrigin:String};let c=i;export{c as default}; 2//# sourceMappingURL=spektrix_connector_controller.nnYVsjBu.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.