JezK
Edit File: mutations-98f05402.js
"use strict";const index=require("./index-c3de642f.js"),utils=require("./utils-a9d13080.js"),removeQueryArgs=require("./remove-query-args-b57e8cd3.js"),index$1=require("./index-fb76df07.js"),google=require("./google-8dbad1a6.js"),currency=require("./currency-71fce0f0.js"),addQueryArgs=require("./add-query-args-49dcb630.js"),store$2=require("./store-01e8edc2.js"),price=require("./price-da3cab3d.js"),safeRead=(e,t)=>{try{return JSON.parse(e.getItem(t))}catch{return null}},debounce=e=>{let t=!1;return()=>{t||(t=!0,setTimeout((()=>{e(),t=!1}),0))}},createStorageStore=(e,t,o,n=!1)=>{var i;const d=index.createStore(null!==(i=safeRead(e,t))&&void 0!==i?i:o,((e,t)=>JSON.stringify(e)!==JSON.stringify(t))),r=debounce((()=>e.setItem(t,JSON.stringify(d.state))));return r(),n&&window.addEventListener("storage",(()=>{const o=safeRead(e,t);if(null!==o)for(const e in o)d.set(e,o[e])})),d.use({set:r,reset:r}),d},createLocalStore=(e,t,o=!1)=>createStorageStore(localStorage,e,t,o),{checkout:checkout$1}=utils.getSerializedState(),notPersistCart="browser"!==(null==checkout$1?void 0:checkout$1.persist)||!!removeQueryArgs.getQueryArg(window.location.href,"no_cart"),store$1=notPersistCart?index.createStore({live:{},test:{}}):createLocalStore("surecart-local-storage",{live:{},test:{}},!0),{state:state$1,onChange:onChange$1,on:on$2,set:set$1,get:get$1,dispose:dispose$1}=store$1;window.scStore=store$1;const{checkout:checkout}=utils.getSerializedState(),{state:state,onChange:onChange,on:on$1,set:set,get:get,dispose:dispose,reset:reset}=index.createStore({formId:null,groupId:null,mode:"live",locks:[],product:null,checkout:null,currencyCode:"usd",abandonedCheckoutEnabled:!0,captureGeoAddressEnabled:!1,geoCapture:null,geoCoordinates:null,showLoginPrompt:!1,initialLineItems:[],isCheckoutPage:!1,validateStock:!1,persist:"browser",paymentMethodRequiresShipping:!1,...checkout},((e,t)=>JSON.stringify(e)!==JSON.stringify(t))),service=store$2.v(store$2.checkoutMachine);service.subscribe((e=>store$2.state.formState=e)),service.start(),store$2.onChange("formState",(()=>{const{formState:e}=store$2.state,{value:t}=e;void 0!==store$2.state.text.loading[t]&&index$1.speak(store$2.state.text.loading[t],"assertive")}));const{send:send}=service,updateFormState=e=>send(e);var _a;onChange("checkout",(e=>setCheckout(e,state.formId))),onChange("checkout",(e=>{(null==e?void 0:e.id)&&(state.mode=(null==e?void 0:e.live_mode)?"live":"test")})),store$2.onChange("formState",(({value:e})=>{var t,o,n,i;"draft"===e&&(null===(o=null===(t=state.checkout)||void 0===t?void 0:t.invoice)||void 0===o?void 0:o.status)&&"open"!==(null===(i=null===(n=state.checkout)||void 0===n?void 0:n.invoice)||void 0===i?void 0:i.status)&&updateFormState("LOCK")})),on$1("get",(e=>{if("checkout"===e){const e=getCheckout(state.formId,state.mode);(null==e?void 0:e.id)&&(state.checkout=e)}})),on$1("set",((e,t,o)=>{var n,i,d,r,u,l,c,a,v,s,m,p,y,g,_;if("checkout"!==e)return;if(!o||!t)return;if((null==t?void 0:t.total_amount)===(null==o?void 0:o.total_amount)&&(null==t?void 0:t.amount_due)===(null==o?void 0:o.total_amount))return;const h=price.getFormattedPrice({amount:t.amount_due,currency:t.currency}),C=price.getFormattedPrice({amount:t.total_amount,currency:t.currency}),f=(null===(i=null===(n=null==t?void 0:t.discount)||void 0===n?void 0:n.promotion)||void 0===i?void 0:i.code)!==(null===(r=null===(d=null==o?void 0:o.discount)||void 0===d?void 0:d.promotion)||void 0===r?void 0:r.code)&&(null===(l=null===(u=null==t?void 0:t.discount)||void 0===u?void 0:u.promotion)||void 0===l?void 0:l.code),w=[...(null===(a=null===(c=null==t?void 0:t.discount)||void 0===c?void 0:c.promotion)||void 0===a?void 0:a.code)===(null===(s=null===(v=null==o?void 0:o.discount)||void 0===v?void 0:v.promotion)||void 0===s?void 0:s.code)||(null===(p=null===(m=null==t?void 0:t.discount)||void 0===m?void 0:m.promotion)||void 0===p?void 0:p.code)?[]:[wp.i18n.__("Coupon code removed.","surecart")],...f?[wp.i18n.sprintf( // Translators: %1$s is the coupon code, %2$s is the human readable discount. wp.i18n.__("Coupon code %1$s added. %2$s applied.","surecart"),null===(g=null===(y=null==t?void 0:t.discount)||void 0===y?void 0:y.promotion)||void 0===g?void 0:g.code,price.getHumanDiscount(null===(_=null==t?void 0:t.discount)||void 0===_?void 0:_.coupon))]:[],t.total_amount===t.amount_due?wp.i18n.sprintf(wp.i18n.__("Checkout updated. The amount due is %1$s.","surecart"),h):wp.i18n.sprintf(wp.i18n.__("Checkout updated. The total amount for the checkout is %1$s and the amount due is %1$s.","surecart"),C,h)];index$1.speak(w.join(" "))}));const store=index.createStore((()=>({cart:{open:!1}})),((e,t)=>JSON.stringify(e)!==JSON.stringify(t))),toggleCart=(e=null)=>{if(!e)return;const t=new CustomEvent("scToggleCart",{bubbles:!0});document.dispatchEvent(t)},{on:on}=store;on("set",((e,t)=>{"cart"===e&&((null==t?void 0:t.open)?index$1.speak(wp.i18n.__("Cart Opened","surecart"),"assertive"):index$1.speak(wp.i18n.__("Cart Closed","surecart"),"assertive"))})),window.sc={...(null===window||void 0===window?void 0:window.sc)||{},cart:{...(null===(_a=null===window||void 0===window?void 0:window.sc)||void 0===_a?void 0:_a.cart)||{},toggle:toggleCart}},on$2("set",((e,t,o)=>Object.keys(t||{}).forEach((e=>handleCheckoutLineItemChange(t[e],null==o?void 0:o[e])))));const handleCheckoutLineItemChange=(e,t)=>{var o,n;const i=(null===(o=null==e?void 0:e.line_items)||void 0===o?void 0:o.data)||[],d=(null===(n=null==t?void 0:t.line_items)||void 0===n?void 0:n.data)||[];if(i.forEach((e=>{const t=d.find((t=>t.id===e.id));if(!t||(null==t?void 0:t.quantity)<(null==e?void 0:e.quantity)){const o=new CustomEvent("scAddedToCart",{detail:{...e,quantity:e.quantity-((null==t?void 0:t.quantity)||0)},bubbles:!0});document.dispatchEvent(o)}})),d.forEach((e=>{const t=i.find((t=>t.id===e.id));if(!t||(null==e?void 0:e.quantity)>(null==t?void 0:t.quantity)){const o=new CustomEvent("scRemovedFromCart",{detail:{...e,quantity:e.quantity-((null==t?void 0:t.quantity)||0)},bubbles:!0});document.dispatchEvent(o)}})),!(null==state?void 0:state.isCheckoutPage)&&JSON.stringify(i)!==JSON.stringify(d)){const o=new CustomEvent("scCartUpdated",{detail:{currentCart:e,previousCart:t},bubbles:!0});document.dispatchEvent(o)}};on("set",((e,t,o)=>{if("cart"===e&&(null==t?void 0:t.open)!==(null==o?void 0:o.open)&&(null==t?void 0:t.open)){const e=new CustomEvent("scViewedCart",{detail:state.checkout,bubbles:!0});document.dispatchEvent(e)}})),on$1("set",((e,t,o)=>{if("checkout"!==e)return;if(null==o?void 0:o.id)return;if(!(null==t?void 0:t.id))return;if(!state.isCheckoutPage)return;const n=new CustomEvent("scCheckoutInitiated",{detail:t,bubbles:!0});document.dispatchEvent(n)}));const COMPLETED_CHECKOUTS_KEY="scCompletedCheckouts",hasTrackedCompletion=e=>{try{return JSON.parse(localStorage.getItem("scCompletedCheckouts")||"[]").includes(e)}catch{return!1}},trackCompletion=e=>{try{const t=JSON.parse(localStorage.getItem("scCompletedCheckouts")||"[]");localStorage.setItem("scCompletedCheckouts",JSON.stringify([...t,e].slice(-20)))}catch{}};on$1("set",((e,t,o)=>{var n,i;if("checkout"!==e)return;if(!(null==t?void 0:t.status)||(null==o?void 0:o.status)===(null==t?void 0:t.status))return;if(!["paid","processing"].includes(t.status))return;if(hasTrackedCompletion(t.id))return;trackCompletion(t.id);const d=new CustomEvent("scOrderPaid",{detail:t,bubbles:!0});document.dispatchEvent(d);const r=new CustomEvent("scCheckoutCompleted",{detail:t,bubbles:!0});document.dispatchEvent(r);const u=((null===(n=null==t?void 0:t.line_items)||void 0===n?void 0:n.data)||[]).filter((e=>{var t;return(null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.trial_duration_days)>0}));if(u.length>0){const e=new CustomEvent("scTrialStarted",{detail:u,bubbles:!0});document.dispatchEvent(e)}const l=((null===(i=null==t?void 0:t.line_items)||void 0===i?void 0:i.data)||[]).filter((e=>{var t;return(null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.recurring_interval_count)>0}));if(l.length>0){const e=new CustomEvent("scSubscriptionStarted",{detail:l,bubbles:!0});document.dispatchEvent(e)}})),on$1("set",((e,t,o)=>{if("checkout"!==e)return;if(!state.isCheckoutPage)return;if(!(null==t?void 0:t.selected_shipping_choice))return;if((null==o?void 0:o.selected_shipping_choice)===(null==t?void 0:t.selected_shipping_choice))return;const n=new CustomEvent("scShippingInfoAdded",{detail:t,bubbles:!0});document.dispatchEvent(n)})),on$1("set",((e,t,o)=>{if("checkout"!==e)return;if(!state.isCheckoutPage)return;if(!(null==o?void 0:o.id))return;if(JSON.stringify(t)===JSON.stringify(o))return;const n=new CustomEvent("scCheckoutUpdated",{detail:{currentCheckout:t,previousCheckout:o},bubbles:!0});document.dispatchEvent(n)})),window.addEventListener("scAddedToCart",(e=>{var t,o,n,i,d,r,u,l,c,a,v,s;const m=e.detail;(null===(t=null==m?void 0:m.price)||void 0===t?void 0:t.product)&&google.trackEvent("add_to_cart",{currency:null===(o=m.price)||void 0===o?void 0:o.currency,value:currency.maybeConvertAmount((null===(n=null==m?void 0:m.price)||void 0===n?void 0:n.amount)||0,(null===(i=m.price)||void 0===i?void 0:i.currency)||"USD"),items:[{item_id:null===(r=null===(d=m.price)||void 0===d?void 0:d.product)||void 0===r?void 0:r.id,item_name:null===(l=null===(u=m.price)||void 0===u?void 0:u.product)||void 0===l?void 0:l.name,item_variant:(m.variant_options||[]).join(" / "),price:currency.maybeConvertAmount((null===(c=null==m?void 0:m.price)||void 0===c?void 0:c.amount)||0,(null===(a=m.price)||void 0===a?void 0:a.currency)||"USD"),currency:null===(v=m.price)||void 0===v?void 0:v.currency,quantity:m.quantity,discount:(null==m?void 0:m.discount_amount)?currency.maybeConvertAmount((null==m?void 0:m.discount_amount)||0,(null===(s=m.price)||void 0===s?void 0:s.currency)||"USD"):0}]})})),window.addEventListener("scRemovedFromCart",(e=>{var t,o,n,i,d,r,u,l,c,a,v,s;const m=e.detail;(null===(t=null==m?void 0:m.price)||void 0===t?void 0:t.product)&&google.trackEvent("remove_from_cart",{currency:null===(o=m.price)||void 0===o?void 0:o.currency,value:currency.maybeConvertAmount((null===(n=null==m?void 0:m.price)||void 0===n?void 0:n.amount)||0,(null===(i=m.price)||void 0===i?void 0:i.currency)||"USD"),items:[{item_id:null===(r=null===(d=m.price)||void 0===d?void 0:d.product)||void 0===r?void 0:r.id,item_name:null===(l=null===(u=m.price)||void 0===u?void 0:u.product)||void 0===l?void 0:l.name,item_variant:(m.variant_options||[]).join(" / "),price:currency.maybeConvertAmount((null===(c=null==m?void 0:m.price)||void 0===c?void 0:c.amount)||0,(null===(a=m.price)||void 0===a?void 0:a.currency)||"USD"),currency:null===(v=m.price)||void 0===v?void 0:v.currency,quantity:m.quantity,discount:(null==m?void 0:m.discount_amount)?currency.maybeConvertAmount((null==m?void 0:m.discount_amount)||0,(null===(s=m.price)||void 0===s?void 0:s.currency)||"USD"):0}]})})),window.addEventListener("scViewedCart",(e=>{var t;const o=e.detail;google.trackEvent("view_cart",{currency:o.currency,value:currency.maybeConvertAmount(o.total_amount,o.currency),items:((null===(t=o.line_items)||void 0===t?void 0:t.data)||[]).map((e=>{var t,o,n,i,d,r,u,l;return{item_id:null===(o=null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.product)||void 0===o?void 0:o.id,item_name:null===(i=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.product)||void 0===i?void 0:i.name,currency:null===(d=e.price)||void 0===d?void 0:d.currency,discount:e.discount_amount?currency.maybeConvertAmount(e.discount_amount,null===(r=e.price)||void 0===r?void 0:r.currency):0,price:currency.maybeConvertAmount(null==e?void 0:e.total_amount,null===(u=e.price)||void 0===u?void 0:u.currency),quantity:e.quantity,...(null===(l=null==e?void 0:e.variant_options)||void 0===l?void 0:l.length)?{item_variant:(e.variant_options||[]).join(" / ")}:{}}}))})})),window.addEventListener("scCheckoutInitiated",(e=>{var t;const o=e.detail;google.trackEvent("begin_checkout",{currency:o.currency,value:currency.maybeConvertAmount(o.total_amount,o.currency),items:((null===(t=o.line_items)||void 0===t?void 0:t.data)||[]).map((e=>{var t,o,n,i,d,r,u,l;return{item_id:null===(o=null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.product)||void 0===o?void 0:o.id,item_name:null===(i=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.product)||void 0===i?void 0:i.name,currency:null===(d=e.price)||void 0===d?void 0:d.currency,discount:e.discount_amount?currency.maybeConvertAmount(e.discount_amount,null===(r=e.price)||void 0===r?void 0:r.currency):0,price:currency.maybeConvertAmount(null==e?void 0:e.total_amount,null===(u=e.price)||void 0===u?void 0:u.currency),quantity:e.quantity,...(null===(l=null==e?void 0:e.variant_options)||void 0===l?void 0:l.length)?{item_variant:(e.variant_options||[]).join(" / ")}:{}}}))})})),window.addEventListener("scCheckoutCompleted",(e=>{var t;const o=e.detail;google.trackEvent("purchase",{transaction_id:null==o?void 0:o.id,value:currency.maybeConvertAmount(null==o?void 0:o.total_amount,(null==o?void 0:o.currency)||"USD"),currency:(o.currency||"").toUpperCase(),items:((null===(t=null==o?void 0:o.line_items)||void 0===t?void 0:t.data)||[]).map((e=>{var t,n,i,d,r,u,l;return{item_id:null===(n=null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.product)||void 0===n?void 0:n.id,currency:(o.currency||"").toUpperCase(),item_name:(null===(d=null===(i=null==e?void 0:e.price)||void 0===i?void 0:i.product)||void 0===d?void 0:d.name)||"",discount:(null==e?void 0:e.discount_amount)?currency.maybeConvertAmount((null==e?void 0:e.discount_amount)||0,(null===(r=null==e?void 0:e.price)||void 0===r?void 0:r.currency)||"USD"):0,price:currency.maybeConvertAmount((null==e?void 0:e.total_amount)||0,(null===(u=null==e?void 0:e.price)||void 0===u?void 0:u.currency)||"USD"),quantity:(null==e?void 0:e.quantity)||1,...(null===(l=null==e?void 0:e.variant_options)||void 0===l?void 0:l.length)?{item_variant:(e.variant_options||[]).join(" / ")}:{}}}))})})),window.addEventListener("scPaymentInfoAdded",(e=>{var t;const o=e.detail;google.trackEvent("add_payment_info",{currency:o.currency,value:currency.maybeConvertAmount(o.total_amount,o.currency),items:((null===(t=o.line_items)||void 0===t?void 0:t.data)||[]).map((e=>{var t,o,n,i,d,r,u,l;return{item_id:null===(o=null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.product)||void 0===o?void 0:o.id,item_name:(null===(i=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.product)||void 0===i?void 0:i.name)||"",currency:null===(d=e.price)||void 0===d?void 0:d.currency,discount:e.discount_amount?currency.maybeConvertAmount(e.discount_amount,null===(r=e.price)||void 0===r?void 0:r.currency):0,price:currency.maybeConvertAmount(null==e?void 0:e.total_amount,null===(u=e.price)||void 0===u?void 0:u.currency),quantity:e.quantity,...(null===(l=null==e?void 0:e.variant_options)||void 0===l?void 0:l.length)?{item_variant:(e.variant_options||[]).join(" / ")}:{}}}))})})),window.addEventListener("scShippingInfoAdded",(e=>{var t,o,n,i,d,r,u,l;const c=e.detail,a=null===(o=null===(t=null==c?void 0:c.shipping_choices)||void 0===t?void 0:t.data)||void 0===o?void 0:o.find((e=>e.id===(null==c?void 0:c.selected_shipping_choice))),v=(null===(n=null==a?void 0:a.shipping_method)||void 0===n?void 0:n.name)||"";google.trackEvent("add_shipping_info",{currency:c.currency,value:currency.maybeConvertAmount(c.total_amount,c.currency),...(null===(d=null===(i=null==c?void 0:c.discount)||void 0===i?void 0:i.promotion)||void 0===d?void 0:d.code)?{coupon:null===(u=null===(r=null==c?void 0:c.discount)||void 0===r?void 0:r.promotion)||void 0===u?void 0:u.code}:{},...v?{shipping_tier:v}:"",items:((null===(l=c.line_items)||void 0===l?void 0:l.data)||[]).map((e=>{var t,o,n,i,d,r,u,l;return{item_id:null===(o=null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.product)||void 0===o?void 0:o.id,item_name:(null===(i=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.product)||void 0===i?void 0:i.name)||"",currency:null===(d=e.price)||void 0===d?void 0:d.currency,discount:e.discount_amount?currency.maybeConvertAmount(e.discount_amount,null===(r=e.price)||void 0===r?void 0:r.currency):0,price:currency.maybeConvertAmount(null==e?void 0:e.total_amount,null===(u=e.price)||void 0===u?void 0:u.currency),quantity:e.quantity,...(null===(l=null==e?void 0:e.variant_options)||void 0===l?void 0:l.length)?{item_variant:(e.variant_options||[]).join(" / ")}:{}}}))})}));const isTrackingDisabled=()=>{var e,t;return!(null===window||void 0===window?void 0:window.fbq)||!1===(null===(t=null===(e=null===window||void 0===window?void 0:window.scData)||void 0===e?void 0:e.tracking)||void 0===t?void 0:t.facebook)},getProductId=e=>{var t,o,n;return"string"==typeof(null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.product)?e.price.product:null===(n=null===(o=null==e?void 0:e.price)||void 0===o?void 0:o.product)||void 0===n?void 0:n.id};window.addEventListener("scAddedToCart",(function(e){var t,o,n,i,d,r,u;if(isTrackingDisabled())return;const l=e.detail;if(!(null===(t=null==l?void 0:l.price)||void 0===t?void 0:t.product))return;const c=null===(o=null==l?void 0:l.price)||void 0===o?void 0:o.product,a=(null===(i=null===(n=null==c?void 0:c.product_collections)||void 0===n?void 0:n.data)||void 0===i?void 0:i.map((e=>e.name)))||[];window.fbq("track","AddToCart",{...a.length?{content_category:a.join(", ")}:{},content_ids:[getProductId(l)],content_name:(null==c?void 0:c.name)+((null===(d=null==l?void 0:l.variant_options)||void 0===d?void 0:d.length)?` - ${null==l?void 0:l.variant_options.join(" / ")}`:""),content_type:"product",contents:[{id:getProductId(l),quantity:l.quantity}],currency:null===(r=null==l?void 0:l.price)||void 0===r?void 0:r.currency,value:currency.maybeConvertAmount((null==l?void 0:l.total_amount)||0,(null===(u=null==l?void 0:l.price)||void 0===u?void 0:u.currency)||"USD")})})),window.addEventListener("scCheckoutInitiated",(function(e){var t,o,n,i;if(isTrackingDisabled())return;const d=e.detail;window.fbq("track","InitiateCheckout",{content_ids:((null===(t=null==d?void 0:d.line_items)||void 0===t?void 0:t.data)||[]).map(getProductId),contents:((null===(o=null==d?void 0:d.line_items)||void 0===o?void 0:o.data)||[]).map((e=>({id:getProductId(e),quantity:e.quantity}))),currency:null==d?void 0:d.currency,num_items:(null===(i=null===(n=null==d?void 0:d.line_items)||void 0===n?void 0:n.data)||void 0===i?void 0:i.length)||0,value:currency.maybeConvertAmount(null==d?void 0:d.total_amount,(null==d?void 0:d.currency)||"USD")},{eventID:null==d?void 0:d.id})})),window.addEventListener("scCheckoutCompleted",(function(e){var t;if(isTrackingDisabled())return;const o=e.detail,n=(null===(t=null==o?void 0:o.line_items)||void 0===t?void 0:t.data)||[];window.fbq("track","Purchase",{content_ids:n.map(getProductId),content_name:"Purchase",content_type:"product",contents:n.map((e=>({id:getProductId(e),quantity:e.quantity}))),currency:null==o?void 0:o.currency,num_items:n.length,value:currency.maybeConvertAmount(null==o?void 0:o.total_amount,(null==o?void 0:o.currency)||"USD")},{eventID:null==o?void 0:o.id})})),window.addEventListener("scTrialStarted",(function(e){isTrackingDisabled()||e.detail.forEach((e=>{var t,o,n;window.fbq("track","StartTrial",{currency:null===(t=e.price)||void 0===t?void 0:t.currency,value:currency.maybeConvertAmount((null===(o=e.price)||void 0===o?void 0:o.amount)||0,(null===(n=e.price)||void 0===n?void 0:n.currency)||"USD")},{eventID:null==e?void 0:e.id})}))})),window.addEventListener("scSubscriptionStarted",(function(e){isTrackingDisabled()||e.detail.forEach((e=>{var t,o,n;window.fbq("track","Subscribe",{currency:null===(t=e.price)||void 0===t?void 0:t.currency,value:currency.maybeConvertAmount((null===(o=e.price)||void 0===o?void 0:o.amount)||0,(null===(n=e.price)||void 0===n?void 0:n.currency)||"USD")},{eventID:null==e?void 0:e.id})}))})),window.addEventListener("scPaymentInfoAdded",(function(e){if(isTrackingDisabled())return;const t=e.detail;window.fbq("track","AddPaymentInfo",{content_category:"Payment Info Added",currency:null==t?void 0:t.currency})}));const getCheckout=(e,t)=>{var o;return(null===(o=store$1.state[t])||void 0===o?void 0:o[e])||{}},setCheckout=(e,t)=>{const o=(null==e?void 0:e.live_mode)?"live":"test";store$1.set(o,{...store$1.state[o],[t]:e}),state.formId===t&&state.mode===o&&(state.checkout=e),"url"===state.persist&&(null==e?void 0:e.id)&&window.history.replaceState({},document.title,addQueryArgs.addQueryArgs(window.location.href,{checkout_id:null==e?void 0:e.id}));const n=new CustomEvent("scCheckoutUpdated",{detail:{checkout:state.checkout,formId:state.formId,mode:state.mode},bubbles:!0});document.dispatchEvent(n)},clearCheckout=(e,t,o="")=>{var n,i,d;const{[e]:r,...u}=store$1.state[t];window.history.replaceState({},document.title,removeQueryArgs.removeQueryArgs(window.location.href,"redirect_status","coupon","line_items","confirm_checkout_id","checkout_id")),store$1.set(t,u);const l=JSON.parse(localStorage.getItem("surecart-local-storage")||"{}");if(null===(n=l[t])||void 0===n?void 0:n[e]){if(o&&(null===(d=null===(i=l[t])||void 0===i?void 0:i[e])||void 0===d?void 0:d.id)!==o)return;delete l[t][e],localStorage.setItem("surecart-local-storage",JSON.stringify(l))}reset()};exports.clearCheckout=clearCheckout,exports.getCheckout=getCheckout,exports.on=on$1,exports.onChange=onChange,exports.onChange$1=onChange$1,exports.setCheckout=setCheckout,exports.state=state,exports.store=store,exports.toggleCart=toggleCart,exports.updateFormState=updateFormState;