import"./hoisted.yFz1BYXO.js";const i=window.__PW_API||"https://api.performancewest.net";function c(t){return new URLSearchParams(window.location.search).get(t)??""}const d=c("order_id"),l=c("order_type")||"canada_crtc",m=c("expedited")==="1",s=document.getElementById("cancelled-order-id");s&&d&&(s.textContent=`Order ID: ${d}`);if(m){document.querySelectorAll("#retry-methods > label").forEach(r=>{const n=r.querySelector("input[type='radio']");n&&n.value!=="paypal"&&n.value!=="crypto"&&(r.classList.add("hidden"),n.checked=!1)});const t=document.querySelector('input[name="retry_method"][value="paypal"]');t&&(t.checked=!0);const e=document.getElementById("expedited-retry-note");e&&e.classList.remove("hidden")}document.getElementById("btn-retry-payment")?.addEventListener("click",async()=>{const t=document.getElementById("btn-retry-payment"),e=document.getElementById("retry-status"),r=document.querySelector('input[name="retry_method"]:checked')?.value||"card";t.disabled=!0,t.textContent="Redirecting...",e&&(e.textContent="Creating checkout session...",e.classList.remove("hidden"));try{const n=await fetch(i+"/api/v1/checkout/create-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({order_id:d,order_type:l,payment_method:r})}),o=await n.json(),a=o.url||o.checkout_url||o.redirect_url;if(n.ok&&a)e&&(e.textContent="Redirecting to payment..."),window.location.href=a;else throw new Error(o.error||"Failed to create checkout session")}catch(n){e&&(e.className="mt-3 text-sm text-red-600 text-center",e.textContent=n.message||"Something went wrong. Please try again.",e.classList.remove("hidden")),t.disabled=!1,t.innerHTML=' Retry Payment'}});