import{c as o}from"./p-35c4916d.js";import{g as n,b as t,a as e}from"./p-1c2e2695.js";function l(o){const e=o.indexOf("?");if(-1===e)return o;const l=n(o),r=o.substr(0,e);for(var d=arguments.length,i=new Array(d>1?d-1:0),c=1;c<d;c++)i[c-1]=arguments[c];i.forEach((o=>delete l[o]));const u=t(l);return u?r+"?"+u:r}const{state:r,onChange:d,on:i}=o({formId:null,groupId:null,mode:"live",locks:[],product:null,checkout:null,currencyCode:"usd",abandonedCheckoutReturnUrl:null,abandonedCheckoutEnabled:!0},((o,n)=>JSON.stringify(o)!==JSON.stringify(n))),c=(o,n)=>{try{return JSON.parse(o.getItem(n))}catch{return null}},u=(n,t,e,l=!1)=>{var r;const d=o(null!==(r=c(n,t))&&void 0!==r?r:e,((o,n)=>JSON.stringify(o)!==JSON.stringify(n))),i=(()=>{let o=!1;return()=>{o||(o=!0,setTimeout((()=>{n.setItem(t,JSON.stringify(d.state)),o=!1}),0))}})();return i(),l&&window.addEventListener("storage",(()=>{const o=c(n,t);if(null!==o)for(const n in o)d.set(n,o[n])})),d.use({set:i,reset:i}),d};var s;const a=(null===(s=null===window||void 0===window?void 0:window.scData)||void 0===s?void 0:s.do_not_persist_cart)?o({live:{},test:{}}):((o,n,t=!1)=>u(localStorage,"surecart-local-storage",{live:{},test:{}},t))(0,0,!0);window.scStore=a;const w=(o,n)=>{var t;return(null===(t=a.state[n])||void 0===t?void 0:t[o])||{}},v=w,m=(o,n)=>{var t;const l=(null==o?void 0:o.live_mode)?"live":"test";a.set(l,{...a.state[l],[n]:o}),r.formId===n&&r.mode===l&&(r.checkout=o),(null===(t=null===window||void 0===window?void 0:window.scData)||void 0===t?void 0:t.do_not_persist_cart)&&(null==o?void 0:o.id)&&window.history.replaceState({},document.title,e(window.location.href,{checkout_id:null==o?void 0:o.id}))},f=m,h=(o,n)=>{const{[o]:t,...e}=a.state[n];return window.history.replaceState({},document.title,l(window.location.href,"redirect_status","coupon","line_items","confirm_checkout_id","checkout_id")),a.set(n,e)},k=h;d("checkout",(o=>f(o,r.formId))),i("get",(o=>{if("checkout"===o){const o=v(r.formId,r.mode);(null==o?void 0:o.id)&&(r.checkout=o)}}));export{r as a,v as b,h as c,i as d,k as e,w as g,d as o,l as r,m as s}