import{__}from"@wordpress/i18n";export const RAZORPAY_CHECKOUT_SCRIPT_URL="https://checkout.razorpay.com/v1/checkout.js";let razorpayInstance=null,loadPromise=null;export const loadRazorpay=()=>razorpayInstance?Promise.resolve(razorpayInstance):loadPromise||(loadPromise=new Promise(((o,r)=>{const a=document.createElement("script");a.src=RAZORPAY_CHECKOUT_SCRIPT_URL,a.async=!0,a.onload=()=>{razorpayInstance=window.Razorpay,o(razorpayInstance)},a.onerror=()=>{loadPromise=null,r(new Error(__("Failed to load Razorpay script.","surecart")))},document.head.appendChild(a)})),loadPromise);