1var x="creem-embed",I=1,C="payment *; publickey-credentials-get *",y="creem_ref";function R(){try{return new URLSearchParams(window.location.search).get("creem_ref")}catch{return null}}function U(e){try{window.localStorage.setItem(y,e)}catch{}}function L(){try{return window.localStorage.getItem(y)}catch{return null}}function w(e){try{let t=e.split(".")[0].replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";const n=JSON.parse(atob(t));return typeof n.iat=="number"?n.iat:0}catch{return 0}}function p(){if(typeof window>"u")return null;const e=R(),t=L();return e&&(!t||w(e)>=w(t))?(U(e),e):t||e||null}function M(){return p()}function b(e,t){const n=p();if(!t.theme&&!t.locale&&!n)return e;try{const r=new URL(e);return t.theme&&r.searchParams.set("theme",t.theme),t.locale&&r.searchParams.set("locale",t.locale),n&&!r.searchParams.has("creem_ref")&&r.searchParams.set("creem_ref",n),r.toString()}catch{return e}}function f(e){try{return new URL(e).origin}catch{return null}}function T(e,t){if(e===t)return!0;if(!e||!t)return!1;try{const n=new URL(e),r=new URL(t);return n.protocol!==r.protocol||n.port!==r.port?!1:n.hostname.replace(/^www\./,"")===r.hostname.replace(/^www\./,"")}catch{return!1}}function g(e){const t=document.createElement("iframe");return t.src=e,t.setAttribute("allow",C),t.title="Creem checkout",t.style.cssText="border:0;width:100%;height:100%;",t}function k(e,t){const n=f(e);let r=null;function c(l){if(n&&!T(l.origin,n))return;const o=l.data;if(!(!o||o.source!==x)){if(o.type==="ready")t.onReady?.();else if(o.type==="completed"){const i={checkoutId:o.checkoutId,orderId:o.orderId,orderNo:o.orderNo,redirect:o.redirect,redirectUrl:o.redirectUrl};if(i.redirectUrl){const s=i.redirectUrl;r=setTimeout(()=>{window.location.href=s},3e3)}t.onComplete?.(i)}}}return window.addEventListener("message",c),()=>{window.removeEventListener("message",c),r&&clearTimeout(r)}}function _(e){if(typeof window>"u"||typeof document>"u")throw new Error("openCheckout must run in the browser");if(!f(e.checkoutUrl))throw new Error("openCheckout: `checkoutUrl` is not a valid URL");const t=b(e.checkoutUrl,e),r=e.theme==="dark"?"#000":"#f9fafb",c="#333",l="#fff",o=document.createElement("div");o.style.cssText="position:fixed;inset:0;z-index:2147483647;background:rgba(1,1,1,.7);display:flex;align-items:center;justify-content:center;padding:16px;overflow:auto;overscroll-behavior:contain;";const i=document.createElement("div");i.style.cssText="display:flex;flex-direction:column;gap:12px;width:min(460px,100%);height:min(860px,100%);";const s=document.createElement("div");s.style.cssText="position:relative;display:flex;flex-direction:column;width:100%;flex:1 1 auto;min-height:0;background:"+r+";border-radius:14px;overflow:hidden;";const a=document.createElement("button");a.setAttribute("aria-label","Close checkout"),a.innerHTML='<svg width="13" height="13" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M2 2 12 12M12 2 2 12"/></svg>',a.style.cssText="align-self:flex-end;flex:0 0 auto;display:flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0;border-radius:10px;border:none;background:"+c+";color:"+l+";cursor:pointer;transition:background .15s,color .15s,border-color .15s,box-shadow .15s;",a.addEventListener("mouseenter",()=>{a.style.background="#a78bfa",a.style.color="#2e1065"}),a.addEventListener("mouseleave",()=>{a.style.background=c,a.style.color=l});const d=g(t);d.style.flex="1 1 auto",d.style.height="auto",d.style.minHeight="0",d.style.background=r;const v=k(t,e);let h="";function E(){v(),o.remove(),document.body.style.overflow=h}function m(){E(),e.onClose?.()}return a.addEventListener("click",m),i.appendChild(a),i.appendChild(s),s.appendChild(d),o.appendChild(i),h=document.body.style.overflow,document.body.style.overflow="hidden",document.body.appendChild(o),d.focus(),{close:m}}var u=new WeakMap;function S(e){if(typeof window>"u"||typeof document>"u")throw new Error("mount must run in the browser");if(!f(e.checkoutUrl))throw new Error("mount: `checkoutUrl` is not a valid URL");const{container:t}=e,n=b(e.checkoutUrl,e);u.get(t)?.(),t.replaceChildren();const r=k(n,e),c=g(n);c.style.background=e.theme==="dark"?"#000":"#fff",t.appendChild(c);const l=()=>{r(),u.delete(t)};return u.set(t,l),{destroy(){l(),t.replaceChildren()}}}var O={create(e){return new Promise(t=>{let n=!1;const r=l=>{n||(n=!0,t(l))},c=_({...e,onReady:()=>{e.onReady?.(),r(c)}});window.setTimeout(()=>r(c),3e3)})}};export{I as CREEM_EMBED_PROTOCOL_VERSION,x as CREEM_EMBED_SOURCE,O as CreemEmbedCheckout,M as captureAffiliateRef,S as mount,_ as openCheckout};
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.