function n(t,e){var r=document.querySelector('script[src="'.concat(t,'"]'));if(null===r)return null;var n=o(t,e),a=r.cloneNode();if(delete a.dataset.uidAuto,Object.keys(a.dataset).length!==Object.keys(n.dataset).length)return null;var i=!0;return Object.keys(a.dataset).forEach((function(t){a.dataset[t]!==n.dataset[t]&&(i=!1)})),i?r:null}function r(t){var e=t.url,r=t.attributes,n=t.onSuccess,a=t.onError,i=o(e,r);i.onerror=a,i.onload=n,document.head.insertBefore(i,document.head.firstElementChild)}function e(e){var r="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(r=e.sdkBaseURL,delete e.sdkBaseURL),u(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,r){var n=e[r].toString();return"data-"===r.substring(0,5)?t.dataAttributes[r]=n:t.queryParams[r]=n,t}),{queryParams:{},dataAttributes:{}}),o=n.queryParams,a=n.dataAttributes;return{url:"".concat(r,"?").concat(t(o)),dataAttributes:a}}function t(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function i(t){var e=t.split("/* Original Error:")[1];return e?e.replace(/\n/g,"").replace("*/","").trim():t}function o(t,e){void 0===e&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach((function(t){r.setAttribute(t,e[t]),"data-csp-nonce"===t&&r.setAttribute("nonce",e["data-csp-nonce"])})),r}function u(t){var e=t["merchant-id"],r=t["data-merchant-id"],n="",o="";return Array.isArray(e)?e.length>1?(n="*",o=e.toString()):n=e.toString():"string"==typeof e&&e.length>0?n=e:"string"==typeof r&&r.length>0&&(n="*",o=r),t["merchant-id"]=n,t["data-merchant-id"]=o,t}function f(t,r){if(void 0===r&&(r=a()),d(t,r),"undefined"==typeof document)return r.resolve(null);var o=e(t),i=o.url,u=o.dataAttributes,s=u["data-namespace"]||"paypal",f=l(s);return n(i,u)&&f?r.resolve(f):c({url:i,attributes:u},r).then((function(){var t=l(s);if(t)return t;throw new Error("The window.".concat(s," global variable is not available."))}))}function c(t,e){void 0===e&&(e=a()),d(t,e);var n=t.url,o=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new e((function(t,e){if("undefined"==typeof document)return t();r({url:n,attributes:o,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(r){return 200===r.status&&e(t),r.text()})).then((function(t){var r=i(t);e(new Error(r))})).catch((function(t){e(t)})):e(t)}})}))}function a(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function l(t){return window[t]}function d(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}const s=({clientId:t,reusable:e,merchantId:r,currency:n="usd",merchantInitiated:o})=>({"client-id":t.replace(/ /g,""),...!e||o?{"merchant-id":r.replace(/ /g,"")}:{},commit:!1,intent:e?"tokenize":"capture",vault:!0,currency:n?n.toUpperCase():"USD"});export{s as g,f as l};