Socket
Socket
Sign inDemoInstall

@paypal/react-paypal-js

Package Overview
Dependencies
9
Maintainers
23
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.1.2 to 8.1.3

23

dist/cjs/react-paypal-js.js
/*!
* react-paypal-js v8.1.2 (2023-08-16T16:11:10.620Z)
* react-paypal-js v8.1.3 (2023-08-16T17:57:48.377Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -487,6 +487,2 @@ *

}
function parseErrorMessage(message) {
var originalErrorText = message.split("/* Original Error:")[1];
return originalErrorText ? originalErrorText.replace(/\n/g, "").replace("*/", "").trim() : message;
}
function createScriptElement(url, attributes) {

@@ -553,17 +549,4 @@ if (attributes === void 0) {

onError: function () {
var defaultError = new Error("The script \"".concat(url, "\" failed to load."));
if (!window.fetch) {
return reject(defaultError);
}
return fetch(url).then(function (response) {
if (response.status === 200) {
reject(defaultError);
}
return response.text();
}).then(function (message) {
var parseMessage = parseErrorMessage(message);
reject(new Error(parseMessage));
}).catch(function (err) {
reject(err);
});
var defaultError = new Error("The script \"".concat(url, "\" failed to load. Check the HTTP status code and response body in DevTools to learn more."));
return reject(defaultError);
}

@@ -570,0 +553,0 @@ });

4

dist/cjs/react-paypal-js.min.js
/*!
* react-paypal-js v8.1.2 (2023-08-16T16:11:10.620Z)
* react-paypal-js v8.1.3 (2023-08-16T17:57:48.377Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -17,2 +17,2 @@ *

*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,r,o,a=t(e);exports.SCRIPT_LOADING_STATE=void 0,(n=exports.SCRIPT_LOADING_STATE||(exports.SCRIPT_LOADING_STATE={})).INITIAL="initial",n.PENDING="pending",n.REJECTED="rejected",n.RESOLVED="resolved",exports.DISPATCH_ACTION=void 0,(r=exports.DISPATCH_ACTION||(exports.DISPATCH_ACTION={})).LOADING_STATUS="setLoadingStatus",r.RESET_OPTIONS="resetOptions",r.SET_BRAINTREE_INSTANCE="braintreeInstance",exports.PAYPAL_HOSTED_FIELDS_TYPES=void 0,(o=exports.PAYPAL_HOSTED_FIELDS_TYPES||(exports.PAYPAL_HOSTED_FIELDS_TYPES={})).NUMBER="number",o.CVV="cvv",o.EXPIRATION_DATE="expirationDate",o.EXPIRATION_MONTH="expirationMonth",o.EXPIRATION_YEAR="expirationYear",o.POSTAL_CODE="postalCode";var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function c(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function s(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var u="data-react-paypal-script-id",l="dataClientToken",d="dataUserIdToken",p="dataSdkIntegrationSource",f="react-paypal-js",P="dataNamespace",v="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),E="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js");function S(e){return void 0===e&&(e="paypal"),window[e]}function T(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),s="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var u=[o,n].filter(Boolean).join();s+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(u,"'}}>`.")}return s}function A(e){var t=e,n=u;t[n];var r=c(t,[n+""]);return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(r)))}function h(e){var t=self.document.querySelector("script[".concat(u,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function m(e,t){var n,r;switch(t.type){case exports.DISPATCH_ACTION.LOADING_STATUS:return"object"==typeof t.value?i(i({},e),{loadingStatus:t.value.state,loadingStatusErrorMessage:t.value.message}):i(i({},e),{loadingStatus:t.value});case exports.DISPATCH_ACTION.RESET_OPTIONS:return h(e.options[u]),i(i({},e),{loadingStatus:exports.SCRIPT_LOADING_STATE.PENDING,options:i(i((n={},n[p]=f,n),t.value),(r={},r[u]="".concat(A(t.value)),r))});case exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE:return i(i({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var I=e.createContext(null);function y(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function N(){var t=y(e.useContext(I));return[i(i({},t),{isInitial:t.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL,isPending:t.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING,isResolved:t.loadingStatus===exports.SCRIPT_LOADING_STATE.RESOLVED,isRejected:t.loadingStatus===exports.SCRIPT_LOADING_STATE.REJECTED}),t.dispatch]}function O(){var t=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[l])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[d]))throw new Error("Invalid authorization data. Use dataClientToken or dataUserIdToken to authorize.");return e}(y(e.useContext(I)));return[t,t.dispatch]}var C=e.createContext({});var _=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,u=void 0!==o&&o,l=t.children,d=t.forceReRender,p=void 0===d?[]:d,f=c(t,["className","disabled","children","forceReRender"]),v=u?{opacity:.38}:{},E="".concat(r," ").concat(u?"paypal-buttons-disabled":"").trim(),A=e.useRef(null),h=e.useRef(null),m=N()[0],I=m.isResolved,y=m.options,O=e.useState(null),C=O[0],b=O[1],R=e.useState(!0),g=R[0],w=R[1],D=e.useState(null)[1];function x(){null!==h.current&&h.current.close().catch((function(){}))}return e.useEffect((function(){if(!1===I)return x;var e=S(y.dataNamespace);if(void 0===e||void 0===e.Buttons)return D((function(){throw new Error(T({reactComponentName:_.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:y.components,sdkDataNamespace:y[P]}))})),x;try{h.current=e.Buttons(i(i({},f),{onInit:function(e,t){b(t),"function"==typeof f.onInit&&f.onInit(e,t)}}))}catch(e){return D((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===h.current.isEligible()?(w(!1),x):A.current?(h.current.render(A.current).catch((function(e){null!==A.current&&0!==A.current.children.length&&D((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),x):x}),s(s([I],p,!0),[f.fundingSource],!1)),e.useEffect((function(){null!==C&&(!0===u?C.disable().catch((function(){})):C.enable().catch((function(){})))}),[u,C]),a.default.createElement(a.default.Fragment,null,g?a.default.createElement("div",{ref:A,style:v,className:E}):l)};function b(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function R(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function g(e,t){if(void 0===t&&(t=Promise),x(e,t),"undefined"==typeof document)return t.resolve(null);var n=function(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseUrl&&(t=e.sdkBaseUrl,delete e.sdkBaseUrl);var n=e,r=Object.keys(n).filter((function(e){return void 0!==n[e]&&null!==n[e]&&""!==n[e]})).reduce((function(e,t){var r,o=n[t].toString();return r=function(e,t){return(t?"-":"")+e.toLowerCase()},"data"===(t=t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)?e.dataAttributes[t]=o:e.queryParams[t]=o,e}),{queryParams:{},dataAttributes:{}}),o=r.queryParams,a=r.dataAttributes;return o["merchant-id"]&&-1!==o["merchant-id"].indexOf(",")&&(a["data-merchant-id"]=o["merchant-id"],o["merchant-id"]="*"),{url:"".concat(t,"?").concat(b(o)),dataAttributes:a}}(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=D(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=R(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):w({url:r,attributes:o},t).then((function(){var e=D(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function w(e,t){void 0===t&&(t=Promise),x(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=R(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}function D(e){return window[e]}function x(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}_.displayName="PayPalButtons";var L=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([w({url:v}),w({url:E})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},k=function(t){var n=t.className,r=void 0===n?"":n,o=t.children,s=c(t,["className","children"]),u=N()[0],l=u.isResolved,d=u.options,p=e.useRef(null),f=e.useState(!0),v=f[0],E=f[1],A=e.useState(null)[1];return e.useEffect((function(){if(!1!==l){var e=S(d[P]);if(void 0===e||void 0===e.Marks)return A((function(){throw new Error(T({reactComponentName:k.displayName,sdkComponentKey:"marks",sdkRequestedComponents:d.components,sdkDataNamespace:d[P]}))}));!function(e){var t=p.current;if(!t||!e.isEligible())return E(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&A((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(i({},s)))}}),[l,s.fundingSource]),a.default.createElement(a.default.Fragment,null,v?a.default.createElement("div",{ref:p,className:r}):o)};k.displayName="PayPalMarks";var F=function(t){var n=t.className,r=void 0===n?"":n,o=t.forceReRender,u=void 0===o?[]:o,l=c(t,["className","forceReRender"]),d=N()[0],p=d.isResolved,f=d.options,v=e.useRef(null),E=e.useRef(null),A=e.useState(null)[1];return e.useEffect((function(){if(!1!==p){var e=S(f[P]);if(void 0===e||void 0===e.Messages)return A((function(){throw new Error(T({reactComponentName:F.displayName,sdkComponentKey:"messages",sdkRequestedComponents:f.components,sdkDataNamespace:f[P]}))}));E.current=e.Messages(i({},l)),E.current.render(v.current).catch((function(e){null!==v.current&&0!==v.current.children.length&&A((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),s([p],u,!0)),a.default.createElement("div",{ref:v,className:r})};F.displayName="PayPalMessages";var H=function(e){if(!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.NUMBER)||!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.CVV)||function(e){return!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_DATE)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_MONTH)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},j=function(e){H(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},G={PAYPAL:"paypal",VENMO:"venmo",APPLEPAY:"applepay",ITAU:"itau",CREDIT:"credit",PAYLATER:"paylater",CARD:"card",IDEAL:"ideal",SEPA:"sepa",BANCONTACT:"bancontact",GIROPAY:"giropay",SOFORT:"sofort",EPS:"eps",MYBANK:"mybank",P24:"p24",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};exports.BraintreePayPalButtons=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,s=void 0!==o&&o,u=t.children,p=t.forceReRender,f=void 0===p?[]:p,P=t.braintreeNamespace,v=t.merchantAccountId,E=c(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),S=e.useState(null)[1],T=O(),A=T[0],h=T[1];return e.useEffect((function(){L(P).then((function(e){var t=A.options[d],n=A.options[l];return e.client.create({authorization:t||n}).then((function(t){var n=v?{merchantAccountId:v}:{};return e.paypalCheckout.create(i(i({},n),{client:t}))})).then((function(e){h({type:exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){S((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[A.options]),a.default.createElement(a.default.Fragment,null,A.braintreePayPalCheckoutInstance&&a.default.createElement(_,i({className:r,disabled:s,forceReRender:f},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,i(i({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,i(i({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,i(i({},n),{braintree:t}))}),i({},e)}(E,A.braintreePayPalCheckoutInstance)),u))},exports.FUNDING=G,exports.PayPalButtons=_,exports.PayPalHostedField=function(t){var n=t.hostedFieldType,r=t.options,o=c(t,["hostedFieldType","options"]),s=e.useContext(C);return e.useEffect((function(){var e;if(!(null==s?void 0:s.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");s.registerHostedField(((e={})[n]={selector:r.selector,placeholder:r.placeholder,type:r.type,formatInput:r.formatInput,maskInput:r.maskInput,select:r.select,maxlength:r.maxlength,minlength:r.minlength,prefill:r.prefill,rejectUnsupportedCards:r.rejectUnsupportedCards},e))}),[]),a.default.createElement("div",i({},o))},exports.PayPalHostedFieldsProvider=function(t){var n=t.styles,r=t.createOrder,o=t.notEligibleError,c=t.children,s=t.installments,u=O()[0],l=u.options,d=u.loadingStatus,p=e.useState(!0),f=p[0],v=p[1],E=e.useState(),T=E[0],A=E[1],h=e.useState(null)[1],m=e.useRef(null),I=e.useRef(),y=function(t){void 0===t&&(t={});var n=e.useRef(t);return[n,function(e){n.current=i(i({},n.current),e)}]}(),N=y[0],_=y[1];return e.useEffect((function(){var e;if(j(Object.keys(N.current)),d===exports.SCRIPT_LOADING_STATE.RESOLVED){if(I.current=S(l[P]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[P],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:l.components})[P]=l[P],e)));if(!I.current.isEligible())return v(!1);T&&T.teardown(),I.current.render({createOrder:r,fields:N.current,installments:s,styles:n}).then((function(e){m.current&&A(e)})).catch((function(e){h((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[d,n]),a.default.createElement("div",{ref:m},f?a.default.createElement(C.Provider,{value:{cardFields:T,registerHostedField:_}},c):o)},exports.PayPalMarks=k,exports.PayPalMessages=F,exports.PayPalScriptProvider=function(t){var n,r,o=t.options,c=void 0===o?{clientId:"test"}:o,s=t.children,l=t.deferLoading,d=void 0!==l&&l,P=e.useReducer(m,{options:i(i((n={},n[p]=f,n),c),(r={},r[u]="".concat(A(c)),r)),loadingStatus:d?exports.SCRIPT_LOADING_STATE.INITIAL:exports.SCRIPT_LOADING_STATE.PENDING}),v=P[0],E=P[1];return e.useEffect((function(){if(!1===d&&v.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL)return E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.PENDING});if(v.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING){var e=!0;return g(v.options).then((function(){e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:{state:exports.SCRIPT_LOADING_STATE.REJECTED,message:String(t)}})})),function(){e=!1}}}),[v.options,d,v.loadingStatus]),a.default.createElement(I.Provider,{value:i(i({},v),{dispatch:E})},s)},exports.ScriptContext=I,exports.destroySDKScript=h,exports.getScriptID=A,exports.scriptReducer=m,exports.usePayPalHostedFields=function(){return e.useContext(C)},exports.usePayPalScriptReducer=N,exports.useScriptProviderContext=O;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,r,o,a=t(e);exports.SCRIPT_LOADING_STATE=void 0,(n=exports.SCRIPT_LOADING_STATE||(exports.SCRIPT_LOADING_STATE={})).INITIAL="initial",n.PENDING="pending",n.REJECTED="rejected",n.RESOLVED="resolved",exports.DISPATCH_ACTION=void 0,(r=exports.DISPATCH_ACTION||(exports.DISPATCH_ACTION={})).LOADING_STATUS="setLoadingStatus",r.RESET_OPTIONS="resetOptions",r.SET_BRAINTREE_INSTANCE="braintreeInstance",exports.PAYPAL_HOSTED_FIELDS_TYPES=void 0,(o=exports.PAYPAL_HOSTED_FIELDS_TYPES||(exports.PAYPAL_HOSTED_FIELDS_TYPES={})).NUMBER="number",o.CVV="cvv",o.EXPIRATION_DATE="expirationDate",o.EXPIRATION_MONTH="expirationMonth",o.EXPIRATION_YEAR="expirationYear",o.POSTAL_CODE="postalCode";var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function c(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function s(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var u="data-react-paypal-script-id",l="dataClientToken",d="dataUserIdToken",p="dataSdkIntegrationSource",f="react-paypal-js",P="dataNamespace",v="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),E="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js");function T(e){return void 0===e&&(e="paypal"),window[e]}function S(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),s="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var u=[o,n].filter(Boolean).join();s+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(u,"'}}>`.")}return s}function A(e){var t=e,n=u;t[n];var r=c(t,[n+""]);return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(r)))}function h(e){var t=self.document.querySelector("script[".concat(u,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function m(e,t){var n,r;switch(t.type){case exports.DISPATCH_ACTION.LOADING_STATUS:return"object"==typeof t.value?i(i({},e),{loadingStatus:t.value.state,loadingStatusErrorMessage:t.value.message}):i(i({},e),{loadingStatus:t.value});case exports.DISPATCH_ACTION.RESET_OPTIONS:return h(e.options[u]),i(i({},e),{loadingStatus:exports.SCRIPT_LOADING_STATE.PENDING,options:i(i((n={},n[p]=f,n),t.value),(r={},r[u]="".concat(A(t.value)),r))});case exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE:return i(i({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var I=e.createContext(null);function y(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function N(){var t=y(e.useContext(I));return[i(i({},t),{isInitial:t.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL,isPending:t.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING,isResolved:t.loadingStatus===exports.SCRIPT_LOADING_STATE.RESOLVED,isRejected:t.loadingStatus===exports.SCRIPT_LOADING_STATE.REJECTED}),t.dispatch]}function O(){var t=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[l])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[d]))throw new Error("Invalid authorization data. Use dataClientToken or dataUserIdToken to authorize.");return e}(y(e.useContext(I)));return[t,t.dispatch]}var C=e.createContext({});var b=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,u=void 0!==o&&o,l=t.children,d=t.forceReRender,p=void 0===d?[]:d,f=c(t,["className","disabled","children","forceReRender"]),v=u?{opacity:.38}:{},E="".concat(r," ").concat(u?"paypal-buttons-disabled":"").trim(),A=e.useRef(null),h=e.useRef(null),m=N()[0],I=m.isResolved,y=m.options,O=e.useState(null),C=O[0],_=O[1],R=e.useState(!0),g=R[0],D=R[1],w=e.useState(null)[1];function x(){null!==h.current&&h.current.close().catch((function(){}))}return e.useEffect((function(){if(!1===I)return x;var e=T(y.dataNamespace);if(void 0===e||void 0===e.Buttons)return w((function(){throw new Error(S({reactComponentName:b.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:y.components,sdkDataNamespace:y[P]}))})),x;try{h.current=e.Buttons(i(i({},f),{onInit:function(e,t){_(t),"function"==typeof f.onInit&&f.onInit(e,t)}}))}catch(e){return w((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===h.current.isEligible()?(D(!1),x):A.current?(h.current.render(A.current).catch((function(e){null!==A.current&&0!==A.current.children.length&&w((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),x):x}),s(s([I],p,!0),[f.fundingSource],!1)),e.useEffect((function(){null!==C&&(!0===u?C.disable().catch((function(){})):C.enable().catch((function(){})))}),[u,C]),a.default.createElement(a.default.Fragment,null,g?a.default.createElement("div",{ref:A,style:v,className:E}):l)};function _(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function R(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function g(e,t){if(void 0===t&&(t=Promise),x(e,t),"undefined"==typeof document)return t.resolve(null);var n=function(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseUrl&&(t=e.sdkBaseUrl,delete e.sdkBaseUrl);var n=e,r=Object.keys(n).filter((function(e){return void 0!==n[e]&&null!==n[e]&&""!==n[e]})).reduce((function(e,t){var r,o=n[t].toString();return r=function(e,t){return(t?"-":"")+e.toLowerCase()},"data"===(t=t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)?e.dataAttributes[t]=o:e.queryParams[t]=o,e}),{queryParams:{},dataAttributes:{}}),o=r.queryParams,a=r.dataAttributes;return o["merchant-id"]&&-1!==o["merchant-id"].indexOf(",")&&(a["data-merchant-id"]=o["merchant-id"],o["merchant-id"]="*"),{url:"".concat(t,"?").concat(_(o)),dataAttributes:a}}(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=w(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=R(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):D({url:r,attributes:o},t).then((function(){var e=w(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function D(e,t){void 0===t&&(t=Promise),x(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=R(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return t(e)}})}))}function w(e){return window[e]}function x(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}b.displayName="PayPalButtons";var L=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([D({url:v}),D({url:E})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},k=function(t){var n=t.className,r=void 0===n?"":n,o=t.children,s=c(t,["className","children"]),u=N()[0],l=u.isResolved,d=u.options,p=e.useRef(null),f=e.useState(!0),v=f[0],E=f[1],A=e.useState(null)[1];return e.useEffect((function(){if(!1!==l){var e=T(d[P]);if(void 0===e||void 0===e.Marks)return A((function(){throw new Error(S({reactComponentName:k.displayName,sdkComponentKey:"marks",sdkRequestedComponents:d.components,sdkDataNamespace:d[P]}))}));!function(e){var t=p.current;if(!t||!e.isEligible())return E(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&A((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(i({},s)))}}),[l,s.fundingSource]),a.default.createElement(a.default.Fragment,null,v?a.default.createElement("div",{ref:p,className:r}):o)};k.displayName="PayPalMarks";var F=function(t){var n=t.className,r=void 0===n?"":n,o=t.forceReRender,u=void 0===o?[]:o,l=c(t,["className","forceReRender"]),d=N()[0],p=d.isResolved,f=d.options,v=e.useRef(null),E=e.useRef(null),A=e.useState(null)[1];return e.useEffect((function(){if(!1!==p){var e=T(f[P]);if(void 0===e||void 0===e.Messages)return A((function(){throw new Error(S({reactComponentName:F.displayName,sdkComponentKey:"messages",sdkRequestedComponents:f.components,sdkDataNamespace:f[P]}))}));E.current=e.Messages(i({},l)),E.current.render(v.current).catch((function(e){null!==v.current&&0!==v.current.children.length&&A((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),s([p],u,!0)),a.default.createElement("div",{ref:v,className:r})};F.displayName="PayPalMessages";var H=function(e){if(!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.NUMBER)||!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.CVV)||function(e){return!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_DATE)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_MONTH)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},j=function(e){H(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},G={PAYPAL:"paypal",VENMO:"venmo",APPLEPAY:"applepay",ITAU:"itau",CREDIT:"credit",PAYLATER:"paylater",CARD:"card",IDEAL:"ideal",SEPA:"sepa",BANCONTACT:"bancontact",GIROPAY:"giropay",SOFORT:"sofort",EPS:"eps",MYBANK:"mybank",P24:"p24",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};exports.BraintreePayPalButtons=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,s=void 0!==o&&o,u=t.children,p=t.forceReRender,f=void 0===p?[]:p,P=t.braintreeNamespace,v=t.merchantAccountId,E=c(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),T=e.useState(null)[1],S=O(),A=S[0],h=S[1];return e.useEffect((function(){L(P).then((function(e){var t=A.options[d],n=A.options[l];return e.client.create({authorization:t||n}).then((function(t){var n=v?{merchantAccountId:v}:{};return e.paypalCheckout.create(i(i({},n),{client:t}))})).then((function(e){h({type:exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){T((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[A.options]),a.default.createElement(a.default.Fragment,null,A.braintreePayPalCheckoutInstance&&a.default.createElement(b,i({className:r,disabled:s,forceReRender:f},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,i(i({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,i(i({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,i(i({},n),{braintree:t}))}),i({},e)}(E,A.braintreePayPalCheckoutInstance)),u))},exports.FUNDING=G,exports.PayPalButtons=b,exports.PayPalHostedField=function(t){var n=t.hostedFieldType,r=t.options,o=c(t,["hostedFieldType","options"]),s=e.useContext(C);return e.useEffect((function(){var e;if(!(null==s?void 0:s.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");s.registerHostedField(((e={})[n]={selector:r.selector,placeholder:r.placeholder,type:r.type,formatInput:r.formatInput,maskInput:r.maskInput,select:r.select,maxlength:r.maxlength,minlength:r.minlength,prefill:r.prefill,rejectUnsupportedCards:r.rejectUnsupportedCards},e))}),[]),a.default.createElement("div",i({},o))},exports.PayPalHostedFieldsProvider=function(t){var n=t.styles,r=t.createOrder,o=t.notEligibleError,c=t.children,s=t.installments,u=O()[0],l=u.options,d=u.loadingStatus,p=e.useState(!0),f=p[0],v=p[1],E=e.useState(),S=E[0],A=E[1],h=e.useState(null)[1],m=e.useRef(null),I=e.useRef(),y=function(t){void 0===t&&(t={});var n=e.useRef(t);return[n,function(e){n.current=i(i({},n.current),e)}]}(),N=y[0],b=y[1];return e.useEffect((function(){var e;if(j(Object.keys(N.current)),d===exports.SCRIPT_LOADING_STATE.RESOLVED){if(I.current=T(l[P]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[P],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:l.components})[P]=l[P],e)));if(!I.current.isEligible())return v(!1);S&&S.teardown(),I.current.render({createOrder:r,fields:N.current,installments:s,styles:n}).then((function(e){m.current&&A(e)})).catch((function(e){h((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[d,n]),a.default.createElement("div",{ref:m},f?a.default.createElement(C.Provider,{value:{cardFields:S,registerHostedField:b}},c):o)},exports.PayPalMarks=k,exports.PayPalMessages=F,exports.PayPalScriptProvider=function(t){var n,r,o=t.options,c=void 0===o?{clientId:"test"}:o,s=t.children,l=t.deferLoading,d=void 0!==l&&l,P=e.useReducer(m,{options:i(i((n={},n[p]=f,n),c),(r={},r[u]="".concat(A(c)),r)),loadingStatus:d?exports.SCRIPT_LOADING_STATE.INITIAL:exports.SCRIPT_LOADING_STATE.PENDING}),v=P[0],E=P[1];return e.useEffect((function(){if(!1===d&&v.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL)return E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.PENDING});if(v.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING){var e=!0;return g(v.options).then((function(){e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:{state:exports.SCRIPT_LOADING_STATE.REJECTED,message:String(t)}})})),function(){e=!1}}}),[v.options,d,v.loadingStatus]),a.default.createElement(I.Provider,{value:i(i({},v),{dispatch:E})},s)},exports.ScriptContext=I,exports.destroySDKScript=h,exports.getScriptID=A,exports.scriptReducer=m,exports.usePayPalHostedFields=function(){return e.useContext(C)},exports.usePayPalScriptReducer=N,exports.useScriptProviderContext=O;
/*!
* react-paypal-js v8.1.2 (2023-08-16T16:11:10.620Z)
* react-paypal-js v8.1.3 (2023-08-16T17:57:48.377Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -593,7 +593,2 @@ *

function parseErrorMessage(message) {
var originalErrorText = message.split("/* Original Error:")[1];
return originalErrorText ? originalErrorText.replace(/\n/g, "").replace("*/", "").trim() : message;
}
function createScriptElement(url, attributes) {

@@ -675,20 +670,4 @@ if (attributes === void 0) {

onError: function () {
var defaultError = new Error("The script \"".concat(url, "\" failed to load."));
if (!window.fetch) {
return reject(defaultError);
}
return fetch(url).then(function (response) {
if (response.status === 200) {
reject(defaultError);
}
return response.text();
}).then(function (message) {
var parseMessage = parseErrorMessage(message);
reject(new Error(parseMessage));
}).catch(function (err) {
reject(err);
});
var defaultError = new Error("The script \"".concat(url, "\" failed to load. Check the HTTP status code and response body in DevTools to learn more."));
return reject(defaultError);
}

@@ -695,0 +674,0 @@ });

/*!
* react-paypal-js v8.1.2 (2023-08-16T16:11:10.620Z)
* react-paypal-js v8.1.3 (2023-08-16T17:57:48.377Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -17,2 +17,2 @@ *

*/
import e,{createContext as t,useContext as n,useRef as r,useState as o,useEffect as a,useReducer as i}from"react";var c,l,s;!function(e){e.INITIAL="initial",e.PENDING="pending",e.REJECTED="rejected",e.RESOLVED="resolved"}(c||(c={})),function(e){e.LOADING_STATUS="setLoadingStatus",e.RESET_OPTIONS="resetOptions",e.SET_BRAINTREE_INSTANCE="braintreeInstance"}(l||(l={})),function(e){e.NUMBER="number",e.CVV="cvv",e.EXPIRATION_DATE="expirationDate",e.EXPIRATION_MONTH="expirationMonth",e.EXPIRATION_YEAR="expirationYear",e.POSTAL_CODE="postalCode"}(s||(s={}));var u=function(){return(u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function d(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function p(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var f="data-react-paypal-script-id",v="dataClientToken",h="dataUserIdToken",m="dataSdkIntegrationSource",E="react-paypal-js",y="dataNamespace",P="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),b="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js");function N(e){return void 0===e&&(e="paypal"),window[e]}function g(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),l="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var s=[o,n].filter(Boolean).join();l+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(s,"'}}>`.")}return l}function w(e){var t=e,n=f;t[n];var r=d(t,[n+""]);return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(r)))}function A(e){var t=self.document.querySelector("script[".concat(f,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function I(e,t){var n,r;switch(t.type){case l.LOADING_STATUS:return"object"==typeof t.value?u(u({},e),{loadingStatus:t.value.state,loadingStatusErrorMessage:t.value.message}):u(u({},e),{loadingStatus:t.value});case l.RESET_OPTIONS:return A(e.options[f]),u(u({},e),{loadingStatus:c.PENDING,options:u(u((n={},n[m]=E,n),t.value),(r={},r[f]="".concat(w(t.value)),r))});case l.SET_BRAINTREE_INSTANCE:return u(u({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var S=t(null);function O(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function T(){var e=O(n(S));return[u(u({},e),{isInitial:e.loadingStatus===c.INITIAL,isPending:e.loadingStatus===c.PENDING,isResolved:e.loadingStatus===c.RESOLVED,isRejected:e.loadingStatus===c.REJECTED}),e.dispatch]}function R(){var e=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[v])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[h]))throw new Error("Invalid authorization data. Use dataClientToken or dataUserIdToken to authorize.");return e}(O(n(S)));return[e,e.dispatch]}var C=t({});function k(){return n(C)}var D=function(t){var n=t.className,i=void 0===n?"":n,c=t.disabled,l=void 0!==c&&c,s=t.children,f=t.forceReRender,v=void 0===f?[]:f,h=d(t,["className","disabled","children","forceReRender"]),m=l?{opacity:.38}:{},E="".concat(i," ").concat(l?"paypal-buttons-disabled":"").trim(),P=r(null),b=r(null),w=T()[0],A=w.isResolved,I=w.options,S=o(null),O=S[0],R=S[1],C=o(!0),k=C[0],j=C[1],L=o(null)[1];function F(){null!==b.current&&b.current.close().catch((function(){}))}return a((function(){if(!1===A)return F;var e=N(I.dataNamespace);if(void 0===e||void 0===e.Buttons)return L((function(){throw new Error(g({reactComponentName:D.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:I.components,sdkDataNamespace:I[y]}))})),F;try{b.current=e.Buttons(u(u({},h),{onInit:function(e,t){R(t),"function"==typeof h.onInit&&h.onInit(e,t)}}))}catch(e){return L((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===b.current.isEligible()?(j(!1),F):P.current?(b.current.render(P.current).catch((function(e){null!==P.current&&0!==P.current.children.length&&L((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),F):F}),p(p([A],v,!0),[h.fundingSource],!1)),a((function(){null!==O&&(!0===l?O.disable().catch((function(){})):O.enable().catch((function(){})))}),[l,O]),e.createElement(e.Fragment,null,k?e.createElement("div",{ref:P,style:m,className:E}):s)};function j(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function L(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function F(e,t){if(void 0===t&&(t=Promise),U(e,t),"undefined"==typeof document)return t.resolve(null);var n=function(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseUrl&&(t=e.sdkBaseUrl,delete e.sdkBaseUrl);var n=e,r=Object.keys(n).filter((function(e){return void 0!==n[e]&&null!==n[e]&&""!==n[e]})).reduce((function(e,t){var r,o=n[t].toString();return r=function(e,t){return(t?"-":"")+e.toLowerCase()},"data"===(t=t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)?e.dataAttributes[t]=o:e.queryParams[t]=o,e}),{queryParams:{},dataAttributes:{}}),o=r.queryParams,a=r.dataAttributes;return o["merchant-id"]&&-1!==o["merchant-id"].indexOf(",")&&(a["data-merchant-id"]=o["merchant-id"],o["merchant-id"]="*"),{url:"".concat(t,"?").concat(j(o)),dataAttributes:a}}(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=M(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=L(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):B({url:r,attributes:o},t).then((function(){var e=M(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function B(e,t){void 0===t&&(t=Promise),U(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=L(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}function M(e){return window[e]}function U(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}D.displayName="PayPalButtons";var _=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([B({url:P}),B({url:b})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},x=function(t){var n=t.className,r=void 0===n?"":n,i=t.disabled,c=void 0!==i&&i,s=t.children,p=t.forceReRender,f=void 0===p?[]:p,m=t.braintreeNamespace,E=t.merchantAccountId,y=d(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),P=o(null)[1],b=R(),N=b[0],g=b[1];return a((function(){_(m).then((function(e){var t=N.options[h],n=N.options[v];return e.client.create({authorization:t||n}).then((function(t){var n=E?{merchantAccountId:E}:{};return e.paypalCheckout.create(u(u({},n),{client:t}))})).then((function(e){g({type:l.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){P((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[N.options]),e.createElement(e.Fragment,null,N.braintreePayPalCheckoutInstance&&e.createElement(D,u({className:r,disabled:c,forceReRender:f},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,u(u({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,u(u({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,u(u({},n),{braintree:t}))}),u({},e)}(y,N.braintreePayPalCheckoutInstance)),s))},H=function(t){var n=t.className,i=void 0===n?"":n,c=t.children,l=d(t,["className","children"]),s=T()[0],p=s.isResolved,f=s.options,v=r(null),h=o(!0),m=h[0],E=h[1],P=o(null)[1];return a((function(){if(!1!==p){var e=N(f[y]);if(void 0===e||void 0===e.Marks)return P((function(){throw new Error(g({reactComponentName:H.displayName,sdkComponentKey:"marks",sdkRequestedComponents:f.components,sdkDataNamespace:f[y]}))}));!function(e){var t=v.current;if(!t||!e.isEligible())return E(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&P((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(u({},l)))}}),[p,l.fundingSource]),e.createElement(e.Fragment,null,m?e.createElement("div",{ref:v,className:i}):c)};H.displayName="PayPalMarks";var G=function(t){var n=t.className,i=void 0===n?"":n,c=t.forceReRender,l=void 0===c?[]:c,s=d(t,["className","forceReRender"]),f=T()[0],v=f.isResolved,h=f.options,m=r(null),E=r(null),P=o(null)[1];return a((function(){if(!1!==v){var e=N(h[y]);if(void 0===e||void 0===e.Messages)return P((function(){throw new Error(g({reactComponentName:G.displayName,sdkComponentKey:"messages",sdkRequestedComponents:h.components,sdkDataNamespace:h[y]}))}));E.current=e.Messages(u({},s)),E.current.render(m.current).catch((function(e){null!==m.current&&0!==m.current.children.length&&P((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),p([v],l,!0)),e.createElement("div",{ref:m,className:i})};G.displayName="PayPalMessages";var K=function(t){var n,r,o=t.options,s=void 0===o?{clientId:"test"}:o,d=t.children,p=t.deferLoading,v=void 0!==p&&p,h=i(I,{options:u(u((n={},n[m]=E,n),s),(r={},r[f]="".concat(w(s)),r)),loadingStatus:v?c.INITIAL:c.PENDING}),y=h[0],P=h[1];return a((function(){if(!1===v&&y.loadingStatus===c.INITIAL)return P({type:l.LOADING_STATUS,value:c.PENDING});if(y.loadingStatus===c.PENDING){var e=!0;return F(y.options).then((function(){e&&P({type:l.LOADING_STATUS,value:c.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&P({type:l.LOADING_STATUS,value:{state:c.REJECTED,message:String(t)}})})),function(){e=!1}}}),[y.options,v,y.loadingStatus]),e.createElement(S.Provider,{value:u(u({},y),{dispatch:P})},d)},Y=function(e){if(!e.includes(s.NUMBER)||!e.includes(s.CVV)||function(e){return!e.includes(s.EXPIRATION_DATE)&&!e.includes(s.EXPIRATION_MONTH)&&!e.includes(s.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},V=function(e){Y(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},q=function(t){var n=t.styles,i=t.createOrder,l=t.notEligibleError,s=t.children,d=t.installments,p=R()[0],f=p.options,v=p.loadingStatus,h=o(!0),m=h[0],E=h[1],P=o(),b=P[0],g=P[1],w=o(null)[1],A=r(null),I=r(),S=function(e){void 0===e&&(e={});var t=r(e);return[t,function(e){t.current=u(u({},t.current),e)}]}(),O=S[0],T=S[1];return a((function(){var e;if(V(Object.keys(O.current)),v===c.RESOLVED){if(I.current=N(f[y]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[y],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:f.components})[y]=f[y],e)));if(!I.current.isEligible())return E(!1);b&&b.teardown(),I.current.render({createOrder:i,fields:O.current,installments:d,styles:n}).then((function(e){A.current&&g(e)})).catch((function(e){w((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[v,n]),e.createElement("div",{ref:A},m?e.createElement(C.Provider,{value:{cardFields:b,registerHostedField:T}},s):l)},X=function(t){var r=t.hostedFieldType,o=t.options,i=d(t,["hostedFieldType","options"]),c=n(C);return a((function(){var e;if(!(null==c?void 0:c.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");c.registerHostedField(((e={})[r]={selector:o.selector,placeholder:o.placeholder,type:o.type,formatInput:o.formatInput,maskInput:o.maskInput,select:o.select,maxlength:o.maxlength,minlength:o.minlength,prefill:o.prefill,rejectUnsupportedCards:o.rejectUnsupportedCards},e))}),[]),e.createElement("div",u({},i))},z={PAYPAL:"paypal",VENMO:"venmo",APPLEPAY:"applepay",ITAU:"itau",CREDIT:"credit",PAYLATER:"paylater",CARD:"card",IDEAL:"ideal",SEPA:"sepa",BANCONTACT:"bancontact",GIROPAY:"giropay",SOFORT:"sofort",EPS:"eps",MYBANK:"mybank",P24:"p24",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};export{x as BraintreePayPalButtons,l as DISPATCH_ACTION,z as FUNDING,s as PAYPAL_HOSTED_FIELDS_TYPES,D as PayPalButtons,X as PayPalHostedField,q as PayPalHostedFieldsProvider,H as PayPalMarks,G as PayPalMessages,K as PayPalScriptProvider,c as SCRIPT_LOADING_STATE,S as ScriptContext,A as destroySDKScript,w as getScriptID,I as scriptReducer,k as usePayPalHostedFields,T as usePayPalScriptReducer,R as useScriptProviderContext};
import e,{createContext as t,useContext as n,useRef as r,useState as o,useEffect as a,useReducer as i}from"react";var c,s,l;!function(e){e.INITIAL="initial",e.PENDING="pending",e.REJECTED="rejected",e.RESOLVED="resolved"}(c||(c={})),function(e){e.LOADING_STATUS="setLoadingStatus",e.RESET_OPTIONS="resetOptions",e.SET_BRAINTREE_INSTANCE="braintreeInstance"}(s||(s={})),function(e){e.NUMBER="number",e.CVV="cvv",e.EXPIRATION_DATE="expirationDate",e.EXPIRATION_MONTH="expirationMonth",e.EXPIRATION_YEAR="expirationYear",e.POSTAL_CODE="postalCode"}(l||(l={}));var u=function(){return(u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function d(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function p(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var f="data-react-paypal-script-id",v="dataClientToken",m="dataUserIdToken",h="dataSdkIntegrationSource",y="react-paypal-js",E="dataNamespace",P="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),b="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js");function N(e){return void 0===e&&(e="paypal"),window[e]}function A(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),s="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var l=[o,n].filter(Boolean).join();s+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(l,"'}}>`.")}return s}function g(e){var t=e,n=f;t[n];var r=d(t,[n+""]);return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(r)))}function w(e){var t=self.document.querySelector("script[".concat(f,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function I(e,t){var n,r;switch(t.type){case s.LOADING_STATUS:return"object"==typeof t.value?u(u({},e),{loadingStatus:t.value.state,loadingStatusErrorMessage:t.value.message}):u(u({},e),{loadingStatus:t.value});case s.RESET_OPTIONS:return w(e.options[f]),u(u({},e),{loadingStatus:c.PENDING,options:u(u((n={},n[h]=y,n),t.value),(r={},r[f]="".concat(g(t.value)),r))});case s.SET_BRAINTREE_INSTANCE:return u(u({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var T=t(null);function S(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function O(){var e=S(n(T));return[u(u({},e),{isInitial:e.loadingStatus===c.INITIAL,isPending:e.loadingStatus===c.PENDING,isResolved:e.loadingStatus===c.RESOLVED,isRejected:e.loadingStatus===c.REJECTED}),e.dispatch]}function R(){var e=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[v])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[m]))throw new Error("Invalid authorization data. Use dataClientToken or dataUserIdToken to authorize.");return e}(S(n(T)));return[e,e.dispatch]}var C=t({});function k(){return n(C)}var D=function(t){var n=t.className,i=void 0===n?"":n,c=t.disabled,s=void 0!==c&&c,l=t.children,f=t.forceReRender,v=void 0===f?[]:f,m=d(t,["className","disabled","children","forceReRender"]),h=s?{opacity:.38}:{},y="".concat(i," ").concat(s?"paypal-buttons-disabled":"").trim(),P=r(null),b=r(null),g=O()[0],w=g.isResolved,I=g.options,T=o(null),S=T[0],R=T[1],C=o(!0),k=C[0],j=C[1],L=o(null)[1];function F(){null!==b.current&&b.current.close().catch((function(){}))}return a((function(){if(!1===w)return F;var e=N(I.dataNamespace);if(void 0===e||void 0===e.Buttons)return L((function(){throw new Error(A({reactComponentName:D.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:I.components,sdkDataNamespace:I[E]}))})),F;try{b.current=e.Buttons(u(u({},m),{onInit:function(e,t){R(t),"function"==typeof m.onInit&&m.onInit(e,t)}}))}catch(e){return L((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===b.current.isEligible()?(j(!1),F):P.current?(b.current.render(P.current).catch((function(e){null!==P.current&&0!==P.current.children.length&&L((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),F):F}),p(p([w],v,!0),[m.fundingSource],!1)),a((function(){null!==S&&(!0===s?S.disable().catch((function(){})):S.enable().catch((function(){})))}),[s,S]),e.createElement(e.Fragment,null,k?e.createElement("div",{ref:P,style:h,className:y}):l)};function j(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function L(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function F(e,t){if(void 0===t&&(t=Promise),U(e,t),"undefined"==typeof document)return t.resolve(null);var n=function(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseUrl&&(t=e.sdkBaseUrl,delete e.sdkBaseUrl);var n=e,r=Object.keys(n).filter((function(e){return void 0!==n[e]&&null!==n[e]&&""!==n[e]})).reduce((function(e,t){var r,o=n[t].toString();return r=function(e,t){return(t?"-":"")+e.toLowerCase()},"data"===(t=t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)?e.dataAttributes[t]=o:e.queryParams[t]=o,e}),{queryParams:{},dataAttributes:{}}),o=r.queryParams,a=r.dataAttributes;return o["merchant-id"]&&-1!==o["merchant-id"].indexOf(",")&&(a["data-merchant-id"]=o["merchant-id"],o["merchant-id"]="*"),{url:"".concat(t,"?").concat(j(o)),dataAttributes:a}}(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=M(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=L(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):B({url:r,attributes:o},t).then((function(){var e=M(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function B(e,t){void 0===t&&(t=Promise),U(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=L(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return t(e)}})}))}function M(e){return window[e]}function U(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}D.displayName="PayPalButtons";var _=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([B({url:P}),B({url:b})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},x=function(t){var n=t.className,r=void 0===n?"":n,i=t.disabled,c=void 0!==i&&i,l=t.children,p=t.forceReRender,f=void 0===p?[]:p,h=t.braintreeNamespace,y=t.merchantAccountId,E=d(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),P=o(null)[1],b=R(),N=b[0],A=b[1];return a((function(){_(h).then((function(e){var t=N.options[m],n=N.options[v];return e.client.create({authorization:t||n}).then((function(t){var n=y?{merchantAccountId:y}:{};return e.paypalCheckout.create(u(u({},n),{client:t}))})).then((function(e){A({type:s.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){P((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[N.options]),e.createElement(e.Fragment,null,N.braintreePayPalCheckoutInstance&&e.createElement(D,u({className:r,disabled:c,forceReRender:f},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,u(u({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,u(u({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,u(u({},n),{braintree:t}))}),u({},e)}(E,N.braintreePayPalCheckoutInstance)),l))},H=function(t){var n=t.className,i=void 0===n?"":n,c=t.children,s=d(t,["className","children"]),l=O()[0],p=l.isResolved,f=l.options,v=r(null),m=o(!0),h=m[0],y=m[1],P=o(null)[1];return a((function(){if(!1!==p){var e=N(f[E]);if(void 0===e||void 0===e.Marks)return P((function(){throw new Error(A({reactComponentName:H.displayName,sdkComponentKey:"marks",sdkRequestedComponents:f.components,sdkDataNamespace:f[E]}))}));!function(e){var t=v.current;if(!t||!e.isEligible())return y(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&P((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(u({},s)))}}),[p,s.fundingSource]),e.createElement(e.Fragment,null,h?e.createElement("div",{ref:v,className:i}):c)};H.displayName="PayPalMarks";var G=function(t){var n=t.className,i=void 0===n?"":n,c=t.forceReRender,s=void 0===c?[]:c,l=d(t,["className","forceReRender"]),f=O()[0],v=f.isResolved,m=f.options,h=r(null),y=r(null),P=o(null)[1];return a((function(){if(!1!==v){var e=N(m[E]);if(void 0===e||void 0===e.Messages)return P((function(){throw new Error(A({reactComponentName:G.displayName,sdkComponentKey:"messages",sdkRequestedComponents:m.components,sdkDataNamespace:m[E]}))}));y.current=e.Messages(u({},l)),y.current.render(h.current).catch((function(e){null!==h.current&&0!==h.current.children.length&&P((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),p([v],s,!0)),e.createElement("div",{ref:h,className:i})};G.displayName="PayPalMessages";var K=function(t){var n,r,o=t.options,l=void 0===o?{clientId:"test"}:o,d=t.children,p=t.deferLoading,v=void 0!==p&&p,m=i(I,{options:u(u((n={},n[h]=y,n),l),(r={},r[f]="".concat(g(l)),r)),loadingStatus:v?c.INITIAL:c.PENDING}),E=m[0],P=m[1];return a((function(){if(!1===v&&E.loadingStatus===c.INITIAL)return P({type:s.LOADING_STATUS,value:c.PENDING});if(E.loadingStatus===c.PENDING){var e=!0;return F(E.options).then((function(){e&&P({type:s.LOADING_STATUS,value:c.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&P({type:s.LOADING_STATUS,value:{state:c.REJECTED,message:String(t)}})})),function(){e=!1}}}),[E.options,v,E.loadingStatus]),e.createElement(T.Provider,{value:u(u({},E),{dispatch:P})},d)},Y=function(e){if(!e.includes(l.NUMBER)||!e.includes(l.CVV)||function(e){return!e.includes(l.EXPIRATION_DATE)&&!e.includes(l.EXPIRATION_MONTH)&&!e.includes(l.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},V=function(e){Y(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},q=function(t){var n=t.styles,i=t.createOrder,s=t.notEligibleError,l=t.children,d=t.installments,p=R()[0],f=p.options,v=p.loadingStatus,m=o(!0),h=m[0],y=m[1],P=o(),b=P[0],A=P[1],g=o(null)[1],w=r(null),I=r(),T=function(e){void 0===e&&(e={});var t=r(e);return[t,function(e){t.current=u(u({},t.current),e)}]}(),S=T[0],O=T[1];return a((function(){var e;if(V(Object.keys(S.current)),v===c.RESOLVED){if(I.current=N(f[E]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[E],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:f.components})[E]=f[E],e)));if(!I.current.isEligible())return y(!1);b&&b.teardown(),I.current.render({createOrder:i,fields:S.current,installments:d,styles:n}).then((function(e){w.current&&A(e)})).catch((function(e){g((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[v,n]),e.createElement("div",{ref:w},h?e.createElement(C.Provider,{value:{cardFields:b,registerHostedField:O}},l):s)},X=function(t){var r=t.hostedFieldType,o=t.options,i=d(t,["hostedFieldType","options"]),c=n(C);return a((function(){var e;if(!(null==c?void 0:c.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");c.registerHostedField(((e={})[r]={selector:o.selector,placeholder:o.placeholder,type:o.type,formatInput:o.formatInput,maskInput:o.maskInput,select:o.select,maxlength:o.maxlength,minlength:o.minlength,prefill:o.prefill,rejectUnsupportedCards:o.rejectUnsupportedCards},e))}),[]),e.createElement("div",u({},i))},z={PAYPAL:"paypal",VENMO:"venmo",APPLEPAY:"applepay",ITAU:"itau",CREDIT:"credit",PAYLATER:"paylater",CARD:"card",IDEAL:"ideal",SEPA:"sepa",BANCONTACT:"bancontact",GIROPAY:"giropay",SOFORT:"sofort",EPS:"eps",MYBANK:"mybank",P24:"p24",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};export{x as BraintreePayPalButtons,s as DISPATCH_ACTION,z as FUNDING,l as PAYPAL_HOSTED_FIELDS_TYPES,D as PayPalButtons,X as PayPalHostedField,q as PayPalHostedFieldsProvider,H as PayPalMarks,G as PayPalMessages,K as PayPalScriptProvider,c as SCRIPT_LOADING_STATE,T as ScriptContext,w as destroySDKScript,g as getScriptID,I as scriptReducer,k as usePayPalHostedFields,O as usePayPalScriptReducer,R as useScriptProviderContext};
{
"name": "@paypal/react-paypal-js",
"version": "8.1.2",
"version": "8.1.3",
"description": "React components for the PayPal JS SDK",

@@ -48,3 +48,3 @@ "keywords": [

"dependencies": {
"@paypal/paypal-js": "^6.0.0",
"@paypal/paypal-js": "^7.0.0",
"@paypal/sdk-constants": "^1.0.122"

@@ -51,0 +51,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc