Socket
Socket
Sign inDemoInstall

@paypal/react-paypal-js

Package Overview
Dependencies
9
Maintainers
39
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.6.1 to 7.6.2

19

dist/cjs/react-paypal-js.js
/*!
* react-paypal-js v7.6.1 (2022-05-09T14:44:11.421Z)
* react-paypal-js v7.6.2 (2022-05-09T20:57:39.607Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -70,3 +70,2 @@ *

var SDK_SETTINGS = {
MERCHANT_CLIENT_ID: "merchant-id",
DATA_CLIENT_TOKEN: "data-client-token",

@@ -83,3 +82,2 @@ DATA_USER_ID_TOKEN: "data-user-id-token",

var EMPTY_BRAINTREE_AUTHORIZATION_ERROR_MESSAGE = "Invalid authorization data. Use data-client-token or data-user-id-token to authorize.";
var BRAINTREE_MULTIPLE_MERCHANT_IDS_ERROR_MESSAGE = "Braintree does not support passing in multiple merchantId values.";
var braintreeVersion = "3.84.0";

@@ -667,16 +665,2 @@ var BRAINTREE_SOURCE = "https://js.braintreegateway.com/web/".concat(braintreeVersion, "/js/client.min.js");

};
/**
* Get the merchantId from the source list
*
* @param {Array|string} source - the source list with merchant identifiers
* @throws {Error} when the merchant list has more than 1 value
* @returns {string|undefined} the merchantId or an undefined value
*/
var getMerchantId = function (source) {
var isSourceArray = Array.isArray(source);
if (isSourceArray && source.length > 1) {
throw new Error(BRAINTREE_MULTIPLE_MERCHANT_IDS_ERROR_MESSAGE);
}
return source === null || source === void 0 ? void 0 : source.toString();
};

@@ -708,3 +692,2 @@ /**

client: clientInstance,
merchantAccountId: getMerchantId(providerContext.options[SDK_SETTINGS.MERCHANT_CLIENT_ID]),
});

@@ -711,0 +694,0 @@ })

4

dist/cjs/react-paypal-js.min.js
/*!
* react-paypal-js v7.6.1 (2022-05-09T14:44:11.421Z)
* react-paypal-js v7.6.2 (2022-05-09T20:57:39.607Z)
* 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="data-react-paypal-script-id",c="merchant-id",s="data-client-token",u="data-user-id-token",l="data-sdk-integration-source",d="react-paypal-js",p="data-namespace",f="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),P="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js"),E=function(){return(E=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 v(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 h(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))}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){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(e)))}function m(e){var t=self.document.querySelector("script[".concat(i,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function y(e,t){var n;switch(t.type){case exports.DISPATCH_ACTION.LOADING_STATUS:return E(E({},e),{loadingStatus:t.value});case exports.DISPATCH_ACTION.RESET_OPTIONS:return m(e.options[i]),delete t.value[i],E(E({},e),{loadingStatus:exports.SCRIPT_LOADING_STATE.PENDING,options:E(E({},t.value),(n={},n[i]="".concat(A(t.value)),n[l]=d,n))});case exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE:return E(E({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var I=e.createContext(null);function N(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 t=N(e.useContext(I));return[E(E({},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 C(){var t=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[s])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[u]))throw new Error("Invalid authorization data. Use data-client-token or data-user-id-token to authorize.");return e}(N(e.useContext(I)));return[t,t.dispatch]}var R=e.createContext({});var _=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,i=void 0!==o&&o,c=t.children,s=t.forceReRender,u=void 0===s?[]:s,l=v(t,["className","disabled","children","forceReRender"]),d=i?{opacity:.38}:{},f="".concat(r," ").concat(i?"paypal-buttons-disabled":"").trim(),P=e.useRef(null),A=e.useRef(null),m=O()[0],y=m.isResolved,I=m.options,N=e.useState(null),C=N[0],R=N[1],w=e.useState(!0),b=w[0],g=w[1],D=e.useState(null)[1];function x(){null!==A.current&&A.current.close().catch((function(){}))}return e.useEffect((function(){if(!1===y)return x;var e=S(I[p]);if(void 0===e||void 0===e.Buttons)return D((function(){throw new Error(T({reactComponentName:_.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:I.components,sdkDataNamespace:I[p]}))})),x;try{A.current=e.Buttons(E(E({},l),{onInit:function(e,t){R(t),"function"==typeof l.onInit&&l.onInit(e,t)}}))}catch(e){return D((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===A.current.isEligible()?(g(!1),x):P.current?(A.current.render(P.current).catch((function(e){null!==P.current&&0!==P.current.children.length&&D((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),x):x}),h(h([y],u,!0),[l.fundingSource],!1)),e.useEffect((function(){null!==C&&(!0===i?C.disable().catch((function(){})):C.enable().catch((function(){})))}),[i,C]),a.default.createElement(a.default.Fragment,null,b?a.default.createElement("div",{ref:P,style:d,className:f}):c)};function w(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n);e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(t,"?").concat(b(r)),dataAttributes:o}}function b(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function g(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 D(e,t){if(void 0===t&&(t=L()),F(e,t),"undefined"==typeof window)return t.resolve(null);var n=w(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=k(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=g(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):x({url:r,attributes:o},t).then((function(){var e=k(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function x(e,t){void 0===t&&(t=L()),F(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 window)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=g(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 L(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function k(e){return window[e]}function F(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 H=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([x({url:f}),x({url:P})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},j=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Braintree does not support passing in multiple merchantId values.");return null==e?void 0:e.toString()},G=function(t){var n=t.className,r=void 0===n?"":n,o=t.children,i=v(t,["className","children"]),c=O()[0],s=c.isResolved,u=c.options,l=e.useRef(null),d=e.useState(!0),f=d[0],P=d[1],h=e.useState(null)[1];return e.useEffect((function(){if(!1!==s){var e=S(u[p]);if(void 0===e||void 0===e.Marks)return h((function(){throw new Error(T({reactComponentName:G.displayName,sdkComponentKey:"marks",sdkRequestedComponents:u.components,sdkDataNamespace:u[p]}))}));!function(e){var t=l.current;if(!t||!e.isEligible())return P(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&h((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(E({},i)))}}),[s,i.fundingSource]),a.default.createElement(a.default.Fragment,null,f?a.default.createElement("div",{ref:l,className:r}):o)};G.displayName="PayPalMarks";var B=function(t){var n=t.className,r=void 0===n?"":n,o=t.forceReRender,i=void 0===o?[]:o,c=v(t,["className","forceReRender"]),s=O()[0],u=s.isResolved,l=s.options,d=e.useRef(null),f=e.useRef(null),P=e.useState(null)[1];return e.useEffect((function(){if(!1!==u){var e=S(l[p]);if(void 0===e||void 0===e.Messages)return P((function(){throw new Error(T({reactComponentName:B.displayName,sdkComponentKey:"messages",sdkRequestedComponents:l.components,sdkDataNamespace:l[p]}))}));f.current=e.Messages(E({},c)),f.current.render(d.current).catch((function(e){null!==d.current&&0!==d.current.children.length&&P((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),h([u],i,!0)),a.default.createElement("div",{ref:d,className:r})};B.displayName="PayPalMessages";var Y=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")},M=function(e){Y(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},U={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",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBLANCO:"multiblanco"};exports.BraintreePayPalButtons=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,i=void 0!==o&&o,l=t.children,d=t.forceReRender,p=void 0===d?[]:d,f=t.braintreeNamespace,P=v(t,["className","disabled","children","forceReRender","braintreeNamespace"]),h=e.useState(null)[1],S=C(),T=S[0],A=S[1];return e.useEffect((function(){H(f).then((function(e){var t=T.options[u],n=T.options[s];return e.client.create({authorization:t||n}).then((function(t){return e.paypalCheckout.create({client:t,merchantAccountId:j(T.options[c])})})).then((function(e){A({type:exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){h((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[T.options]),a.default.createElement(a.default.Fragment,null,T.braintreePayPalCheckoutInstance&&a.default.createElement(_,E({className:r,disabled:i,forceReRender:p},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,E(E({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,E(E({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,E(E({},n),{braintree:t}))}),E({},e)}(P,T.braintreePayPalCheckoutInstance)),l))},exports.FUNDING=U,exports.PayPalButtons=_,exports.PayPalHostedField=function(t){var n=t.hostedFieldType,r=t.options,o=v(t,["hostedFieldType","options"]),i=e.useContext(R);return e.useEffect((function(){var e;if(!(null==i?void 0:i.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");i.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",E({},o))},exports.PayPalHostedFieldsProvider=function(t){var n=t.styles,r=t.createOrder,o=t.notEligibleError,i=t.children,c=C()[0],s=c.options,u=c.loadingStatus,l=e.useState(!0),d=l[0],f=l[1],P=e.useState(),v=P[0],h=P[1],T=e.useState(null)[1],A=e.useRef(null),m=e.useRef(),y=function(t){void 0===t&&(t={});var n=e.useRef(t);return[n,function(e){n.current=E(E({},n.current),e)}]}(),I=y[0],N=y[1];return e.useEffect((function(){var e;if(M(Object.keys(I.current)),u===exports.SCRIPT_LOADING_STATE.RESOLVED){if(m.current=S(s[p]).HostedFields,!m.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:s.components})[p]=s[p],e)));if(!m.current.isEligible())return f(!1);v&&v.teardown(),m.current.render({createOrder:r,styles:n,fields:I.current}).then((function(e){A.current&&h(e)})).catch((function(e){T((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[u,n]),a.default.createElement("div",{ref:A},d?a.default.createElement(R.Provider,{value:{cardFields:v,registerHostedField:N}},i):o)},exports.PayPalMarks=G,exports.PayPalMessages=B,exports.PayPalScriptProvider=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,c=t.children,s=t.deferLoading,u=void 0!==s&&s,p=e.useReducer(y,{options:E(E({},o),(n={},n[i]="".concat(A(o)),n[l]=d,n)),loadingStatus:u?exports.SCRIPT_LOADING_STATE.INITIAL:exports.SCRIPT_LOADING_STATE.PENDING}),f=p[0],P=p[1];return e.useEffect((function(){if(!1===u&&f.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL)return P({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.PENDING});if(f.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING){var e=!0;return D(f.options).then((function(){e&&P({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&&P({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.REJECTED})})),function(){e=!1}}}),[f.options,u,f.loadingStatus]),a.default.createElement(I.Provider,{value:E(E({},f),{dispatch:P})},c)},exports.ScriptContext=I,exports.destroySDKScript=m,exports.getScriptID=A,exports.scriptReducer=y,exports.usePayPalHostedFields=function(){return e.useContext(R)},exports.usePayPalScriptReducer=O,exports.useScriptProviderContext=C;
"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="data-react-paypal-script-id",c="data-client-token",s="data-user-id-token",u="data-sdk-integration-source",l="react-paypal-js",d="data-namespace",p="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),f="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js"),P=function(){return(P=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 E(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 v(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))}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 h(e){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(e)))}function A(e){var t=self.document.querySelector("script[".concat(i,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function y(e,t){var n;switch(t.type){case exports.DISPATCH_ACTION.LOADING_STATUS:return P(P({},e),{loadingStatus:t.value});case exports.DISPATCH_ACTION.RESET_OPTIONS:return A(e.options[i]),delete t.value[i],P(P({},e),{loadingStatus:exports.SCRIPT_LOADING_STATE.PENDING,options:P(P({},t.value),(n={},n[i]="".concat(h(t.value)),n[u]=l,n))});case exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE:return P(P({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var m=e.createContext(null);function I(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=I(e.useContext(m));return[P(P({},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[c])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[s]))throw new Error("Invalid authorization data. Use data-client-token or data-user-id-token to authorize.");return e}(I(e.useContext(m)));return[t,t.dispatch]}var C=e.createContext({});var R=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,i=void 0!==o&&o,c=t.children,s=t.forceReRender,u=void 0===s?[]:s,l=E(t,["className","disabled","children","forceReRender"]),p=i?{opacity:.38}:{},f="".concat(r," ").concat(i?"paypal-buttons-disabled":"").trim(),h=e.useRef(null),A=e.useRef(null),y=N()[0],m=y.isResolved,I=y.options,O=e.useState(null),C=O[0],_=O[1],b=e.useState(!0),w=b[0],g=b[1],D=e.useState(null)[1];function x(){null!==A.current&&A.current.close().catch((function(){}))}return e.useEffect((function(){if(!1===m)return x;var e=S(I[d]);if(void 0===e||void 0===e.Buttons)return D((function(){throw new Error(T({reactComponentName:R.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:I.components,sdkDataNamespace:I[d]}))})),x;try{A.current=e.Buttons(P(P({},l),{onInit:function(e,t){_(t),"function"==typeof l.onInit&&l.onInit(e,t)}}))}catch(e){return D((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===A.current.isEligible()?(g(!1),x):h.current?(A.current.render(h.current).catch((function(e){null!==h.current&&0!==h.current.children.length&&D((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),x):x}),v(v([m],u,!0),[l.fundingSource],!1)),e.useEffect((function(){null!==C&&(!0===i?C.disable().catch((function(){})):C.enable().catch((function(){})))}),[i,C]),a.default.createElement(a.default.Fragment,null,w?a.default.createElement("div",{ref:h,style:p,className:f}):c)};function _(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n);e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(t,"?").concat(b(r)),dataAttributes:o}}function b(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function w(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=x()),k(e,t),"undefined"==typeof window)return t.resolve(null);var n=_(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=L(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=w(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=L(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=x()),k(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 window)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=w(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 x(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function L(e){return window[e]}function k(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.")}R.displayName="PayPalButtons";var F=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:p}),D({url:f})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},H=function(t){var n=t.className,r=void 0===n?"":n,o=t.children,i=E(t,["className","children"]),c=N()[0],s=c.isResolved,u=c.options,l=e.useRef(null),p=e.useState(!0),f=p[0],v=p[1],h=e.useState(null)[1];return e.useEffect((function(){if(!1!==s){var e=S(u[d]);if(void 0===e||void 0===e.Marks)return h((function(){throw new Error(T({reactComponentName:H.displayName,sdkComponentKey:"marks",sdkRequestedComponents:u.components,sdkDataNamespace:u[d]}))}));!function(e){var t=l.current;if(!t||!e.isEligible())return v(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&h((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(P({},i)))}}),[s,i.fundingSource]),a.default.createElement(a.default.Fragment,null,f?a.default.createElement("div",{ref:l,className:r}):o)};H.displayName="PayPalMarks";var j=function(t){var n=t.className,r=void 0===n?"":n,o=t.forceReRender,i=void 0===o?[]:o,c=E(t,["className","forceReRender"]),s=N()[0],u=s.isResolved,l=s.options,p=e.useRef(null),f=e.useRef(null),h=e.useState(null)[1];return e.useEffect((function(){if(!1!==u){var e=S(l[d]);if(void 0===e||void 0===e.Messages)return h((function(){throw new Error(T({reactComponentName:j.displayName,sdkComponentKey:"messages",sdkRequestedComponents:l.components,sdkDataNamespace:l[d]}))}));f.current=e.Messages(P({},c)),f.current.render(p.current).catch((function(e){null!==p.current&&0!==p.current.children.length&&h((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),v([u],i,!0)),a.default.createElement("div",{ref:p,className:r})};j.displayName="PayPalMessages";var G=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")},Y=function(e){G(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},B={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",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBLANCO:"multiblanco"};exports.BraintreePayPalButtons=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,i=void 0!==o&&o,u=t.children,l=t.forceReRender,d=void 0===l?[]:l,p=t.braintreeNamespace,f=E(t,["className","disabled","children","forceReRender","braintreeNamespace"]),v=e.useState(null)[1],S=O(),T=S[0],h=S[1];return e.useEffect((function(){F(p).then((function(e){var t=T.options[s],n=T.options[c];return e.client.create({authorization:t||n}).then((function(t){return e.paypalCheckout.create({client:t})})).then((function(e){h({type:exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){v((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[T.options]),a.default.createElement(a.default.Fragment,null,T.braintreePayPalCheckoutInstance&&a.default.createElement(R,P({className:r,disabled:i,forceReRender:d},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,P(P({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,P(P({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,P(P({},n),{braintree:t}))}),P({},e)}(f,T.braintreePayPalCheckoutInstance)),u))},exports.FUNDING=B,exports.PayPalButtons=R,exports.PayPalHostedField=function(t){var n=t.hostedFieldType,r=t.options,o=E(t,["hostedFieldType","options"]),i=e.useContext(C);return e.useEffect((function(){var e;if(!(null==i?void 0:i.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");i.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",P({},o))},exports.PayPalHostedFieldsProvider=function(t){var n=t.styles,r=t.createOrder,o=t.notEligibleError,i=t.children,c=O()[0],s=c.options,u=c.loadingStatus,l=e.useState(!0),p=l[0],f=l[1],E=e.useState(),v=E[0],T=E[1],h=e.useState(null)[1],A=e.useRef(null),y=e.useRef(),m=function(t){void 0===t&&(t={});var n=e.useRef(t);return[n,function(e){n.current=P(P({},n.current),e)}]}(),I=m[0],N=m[1];return e.useEffect((function(){var e;if(Y(Object.keys(I.current)),u===exports.SCRIPT_LOADING_STATE.RESOLVED){if(y.current=S(s[d]).HostedFields,!y.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[d],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:s.components})[d]=s[d],e)));if(!y.current.isEligible())return f(!1);v&&v.teardown(),y.current.render({createOrder:r,styles:n,fields:I.current}).then((function(e){A.current&&T(e)})).catch((function(e){h((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[u,n]),a.default.createElement("div",{ref:A},p?a.default.createElement(C.Provider,{value:{cardFields:v,registerHostedField:N}},i):o)},exports.PayPalMarks=H,exports.PayPalMessages=j,exports.PayPalScriptProvider=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,c=t.children,s=t.deferLoading,d=void 0!==s&&s,p=e.useReducer(y,{options:P(P({},o),(n={},n[i]="".concat(h(o)),n[u]=l,n)),loadingStatus:d?exports.SCRIPT_LOADING_STATE.INITIAL:exports.SCRIPT_LOADING_STATE.PENDING}),f=p[0],E=p[1];return e.useEffect((function(){if(!1===d&&f.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL)return E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.PENDING});if(f.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING){var e=!0;return g(f.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:exports.SCRIPT_LOADING_STATE.REJECTED})})),function(){e=!1}}}),[f.options,d,f.loadingStatus]),a.default.createElement(m.Provider,{value:P(P({},f),{dispatch:E})},c)},exports.ScriptContext=m,exports.destroySDKScript=A,exports.getScriptID=h,exports.scriptReducer=y,exports.usePayPalHostedFields=function(){return e.useContext(C)},exports.usePayPalScriptReducer=N,exports.useScriptProviderContext=O;
/*!
* react-paypal-js v7.6.1 (2022-05-09T14:44:11.421Z)
* react-paypal-js v7.6.2 (2022-05-09T20:57:39.607Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -70,3 +70,2 @@ *

var SDK_SETTINGS = {
MERCHANT_CLIENT_ID: "merchant-id",
DATA_CLIENT_TOKEN: "data-client-token",

@@ -84,3 +83,2 @@ DATA_USER_ID_TOKEN: "data-user-id-token",

var EMPTY_BRAINTREE_AUTHORIZATION_ERROR_MESSAGE = "Invalid authorization data. Use data-client-token or data-user-id-token to authorize.";
var BRAINTREE_MULTIPLE_MERCHANT_IDS_ERROR_MESSAGE = "Braintree does not support passing in multiple merchantId values.";
var braintreeVersion = "3.84.0";

@@ -810,20 +808,2 @@ var BRAINTREE_SOURCE = "https://js.braintreegateway.com/web/".concat(braintreeVersion, "/js/client.min.js");

/**
* Get the merchantId from the source list
*
* @param {Array|string} source - the source list with merchant identifiers
* @throws {Error} when the merchant list has more than 1 value
* @returns {string|undefined} the merchantId or an undefined value
*/
var getMerchantId = function (source) {
var isSourceArray = Array.isArray(source);
if (isSourceArray && source.length > 1) {
throw new Error(BRAINTREE_MULTIPLE_MERCHANT_IDS_ERROR_MESSAGE);
}
return source === null || source === void 0 ? void 0 : source.toString();
};
/**
This `<BraintreePayPalButtons />` component renders the [Braintree PayPal Buttons](https://developer.paypal.com/braintree/docs/guides/paypal/overview) for Braintree Merchants.

@@ -865,4 +845,3 @@ It relies on the `<PayPalScriptProvider />` parent component for managing state related to loading the JS SDK script.

return braintree.paypalCheckout.create({
client: clientInstance,
merchantAccountId: getMerchantId(providerContext.options[SDK_SETTINGS.MERCHANT_CLIENT_ID])
client: clientInstance
});

@@ -869,0 +848,0 @@ }).then(function (paypalCheckoutInstance) {

/*!
* react-paypal-js v7.6.1 (2022-05-09T14:44:11.421Z)
* react-paypal-js v7.6.2 (2022-05-09T20:57:39.607Z)
* 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="data-react-paypal-script-id",d="merchant-id",p="data-client-token",f="data-user-id-token",v="data-sdk-integration-source",h="react-paypal-js",m="data-namespace",y="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"),P=function(){return(P=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 w(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 b(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))}function g(e){return void 0===e&&(e="paypal"),window[e]}function N(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 A(e){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(e)))}function I(e){var t=self.document.querySelector("script[".concat(u,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function S(e,t){var n;switch(t.type){case l.LOADING_STATUS:return P(P({},e),{loadingStatus:t.value});case l.RESET_OPTIONS:return I(e.options[u]),delete t.value[u],P(P({},e),{loadingStatus:c.PENDING,options:P(P({},t.value),(n={},n[u]="".concat(A(t.value)),n[v]=h,n))});case l.SET_BRAINTREE_INSTANCE:return P(P({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var O=t(null);function T(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 R(){var e=T(n(O));return[P(P({},e),{isInitial:e.loadingStatus===c.INITIAL,isPending:e.loadingStatus===c.PENDING,isResolved:e.loadingStatus===c.RESOLVED,isRejected:e.loadingStatus===c.REJECTED}),e.dispatch]}function k(){var e=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[p])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[f]))throw new Error("Invalid authorization data. Use data-client-token or data-user-id-token to authorize.");return e}(T(n(O)));return[e,e.dispatch]}var C=t({});function D(){return n(C)}var j=function(t){var n=t.className,i=void 0===n?"":n,c=t.disabled,l=void 0!==c&&c,s=t.children,u=t.forceReRender,d=void 0===u?[]:u,p=w(t,["className","disabled","children","forceReRender"]),f=l?{opacity:.38}:{},v="".concat(i," ").concat(l?"paypal-buttons-disabled":"").trim(),h=r(null),y=r(null),E=R()[0],A=E.isResolved,I=E.options,S=o(null),O=S[0],T=S[1],k=o(!0),C=k[0],D=k[1],L=o(null)[1];function F(){null!==y.current&&y.current.close().catch((function(){}))}return a((function(){if(!1===A)return F;var e=g(I[m]);if(void 0===e||void 0===e.Buttons)return L((function(){throw new Error(N({reactComponentName:j.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:I.components,sdkDataNamespace:I[m]}))})),F;try{y.current=e.Buttons(P(P({},p),{onInit:function(e,t){T(t),"function"==typeof p.onInit&&p.onInit(e,t)}}))}catch(e){return L((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===y.current.isEligible()?(D(!1),F):h.current?(y.current.render(h.current).catch((function(e){null!==h.current&&0!==h.current.children.length&&L((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),F):F}),b(b([A],d,!0),[p.fundingSource],!1)),a((function(){null!==O&&(!0===l?O.disable().catch((function(){})):O.enable().catch((function(){})))}),[l,O]),e.createElement(e.Fragment,null,C?e.createElement("div",{ref:h,style:f,className:v}):s)};function L(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n);e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(t,"?").concat(F(r)),dataAttributes:o}}function F(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function B(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 M(e,t){if(void 0===t&&(t=_()),H(e,t),"undefined"==typeof window)return t.resolve(null);var n=L(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=x(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=B(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):U({url:r,attributes:o},t).then((function(){var e=x(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function U(e,t){void 0===t&&(t=_()),H(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 window)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=B(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 _(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function x(e){return window[e]}function H(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.")}j.displayName="PayPalButtons";var G=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([U({url:y}),U({url:E})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},K=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Braintree does not support passing in multiple merchantId values.");return null==e?void 0:e.toString()},Y=function(t){var n=t.className,r=void 0===n?"":n,i=t.disabled,c=void 0!==i&&i,s=t.children,u=t.forceReRender,v=void 0===u?[]:u,h=t.braintreeNamespace,m=w(t,["className","disabled","children","forceReRender","braintreeNamespace"]),y=o(null)[1],E=k(),b=E[0],g=E[1];return a((function(){G(h).then((function(e){var t=b.options[f],n=b.options[p];return e.client.create({authorization:t||n}).then((function(t){return e.paypalCheckout.create({client:t,merchantAccountId:K(b.options[d])})})).then((function(e){g({type:l.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){y((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[b.options]),e.createElement(e.Fragment,null,b.braintreePayPalCheckoutInstance&&e.createElement(j,P({className:r,disabled:c,forceReRender:v},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,P(P({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,P(P({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,P(P({},n),{braintree:t}))}),P({},e)}(m,b.braintreePayPalCheckoutInstance)),s))},V=function(t){var n=t.className,i=void 0===n?"":n,c=t.children,l=w(t,["className","children"]),s=R()[0],u=s.isResolved,d=s.options,p=r(null),f=o(!0),v=f[0],h=f[1],y=o(null)[1];return a((function(){if(!1!==u){var e=g(d[m]);if(void 0===e||void 0===e.Marks)return y((function(){throw new Error(N({reactComponentName:V.displayName,sdkComponentKey:"marks",sdkRequestedComponents:d.components,sdkDataNamespace:d[m]}))}));!function(e){var t=p.current;if(!t||!e.isEligible())return h(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&y((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(P({},l)))}}),[u,l.fundingSource]),e.createElement(e.Fragment,null,v?e.createElement("div",{ref:p,className:i}):c)};V.displayName="PayPalMarks";var q=function(t){var n=t.className,i=void 0===n?"":n,c=t.forceReRender,l=void 0===c?[]:c,s=w(t,["className","forceReRender"]),u=R()[0],d=u.isResolved,p=u.options,f=r(null),v=r(null),h=o(null)[1];return a((function(){if(!1!==d){var e=g(p[m]);if(void 0===e||void 0===e.Messages)return h((function(){throw new Error(N({reactComponentName:q.displayName,sdkComponentKey:"messages",sdkRequestedComponents:p.components,sdkDataNamespace:p[m]}))}));v.current=e.Messages(P({},s)),v.current.render(f.current).catch((function(e){null!==f.current&&0!==f.current.children.length&&h((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),b([d],l,!0)),e.createElement("div",{ref:f,className:i})};q.displayName="PayPalMessages";var X=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,s=t.children,d=t.deferLoading,p=void 0!==d&&d,f=i(S,{options:P(P({},o),(n={},n[u]="".concat(A(o)),n[v]=h,n)),loadingStatus:p?c.INITIAL:c.PENDING}),m=f[0],y=f[1];return a((function(){if(!1===p&&m.loadingStatus===c.INITIAL)return y({type:l.LOADING_STATUS,value:c.PENDING});if(m.loadingStatus===c.PENDING){var e=!0;return M(m.options).then((function(){e&&y({type:l.LOADING_STATUS,value:c.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&y({type:l.LOADING_STATUS,value:c.REJECTED})})),function(){e=!1}}}),[m.options,p,m.loadingStatus]),e.createElement(O.Provider,{value:P(P({},m),{dispatch:y})},s)},z=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")},J=function(e){z(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},W=function(t){var n=t.styles,i=t.createOrder,l=t.notEligibleError,s=t.children,u=k()[0],d=u.options,p=u.loadingStatus,f=o(!0),v=f[0],h=f[1],y=o(),E=y[0],w=y[1],b=o(null)[1],N=r(null),A=r(),I=function(e){void 0===e&&(e={});var t=r(e);return[t,function(e){t.current=P(P({},t.current),e)}]}(),S=I[0],O=I[1];return a((function(){var e;if(J(Object.keys(S.current)),p===c.RESOLVED){if(A.current=g(d[m]).HostedFields,!A.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[m],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:d.components})[m]=d[m],e)));if(!A.current.isEligible())return h(!1);E&&E.teardown(),A.current.render({createOrder:i,styles:n,fields:S.current}).then((function(e){N.current&&w(e)})).catch((function(e){b((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[p,n]),e.createElement("div",{ref:N},v?e.createElement(C.Provider,{value:{cardFields:E,registerHostedField:O}},s):l)},Z=function(t){var r=t.hostedFieldType,o=t.options,i=w(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",P({},i))},Q={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",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBLANCO:"multiblanco"};export{Y as BraintreePayPalButtons,l as DISPATCH_ACTION,Q as FUNDING,s as PAYPAL_HOSTED_FIELDS_TYPES,j as PayPalButtons,Z as PayPalHostedField,W as PayPalHostedFieldsProvider,V as PayPalMarks,q as PayPalMessages,X as PayPalScriptProvider,c as SCRIPT_LOADING_STATE,O as ScriptContext,I as destroySDKScript,A as getScriptID,S as scriptReducer,D as usePayPalHostedFields,R as usePayPalScriptReducer,k 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,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="data-react-paypal-script-id",d="data-client-token",f="data-user-id-token",p="data-sdk-integration-source",v="react-paypal-js",h="data-namespace",m="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),y="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js"),E=function(){return(E=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 P(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 w(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))}function b(e){return void 0===e&&(e="paypal"),window[e]}function N(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 g(e){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(e)))}function A(e){var t=self.document.querySelector("script[".concat(u,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function I(e,t){var n;switch(t.type){case l.LOADING_STATUS:return E(E({},e),{loadingStatus:t.value});case l.RESET_OPTIONS:return A(e.options[u]),delete t.value[u],E(E({},e),{loadingStatus:c.PENDING,options:E(E({},t.value),(n={},n[u]="".concat(g(t.value)),n[p]=v,n))});case l.SET_BRAINTREE_INSTANCE:return E(E({},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[E(E({},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[d])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[f]))throw new Error("Invalid authorization data. Use data-client-token or data-user-id-token to authorize.");return e}(O(n(S)));return[e,e.dispatch]}var k=t({});function C(){return n(k)}var D=function(t){var n=t.className,i=void 0===n?"":n,c=t.disabled,l=void 0!==c&&c,s=t.children,u=t.forceReRender,d=void 0===u?[]:u,f=P(t,["className","disabled","children","forceReRender"]),p=l?{opacity:.38}:{},v="".concat(i," ").concat(l?"paypal-buttons-disabled":"").trim(),m=r(null),y=r(null),g=T()[0],A=g.isResolved,I=g.options,S=o(null),O=S[0],R=S[1],k=o(!0),C=k[0],j=k[1],L=o(null)[1];function F(){null!==y.current&&y.current.close().catch((function(){}))}return a((function(){if(!1===A)return F;var e=b(I[h]);if(void 0===e||void 0===e.Buttons)return L((function(){throw new Error(N({reactComponentName:D.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:I.components,sdkDataNamespace:I[h]}))})),F;try{y.current=e.Buttons(E(E({},f),{onInit:function(e,t){R(t),"function"==typeof f.onInit&&f.onInit(e,t)}}))}catch(e){return L((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===y.current.isEligible()?(j(!1),F):m.current?(y.current.render(m.current).catch((function(e){null!==m.current&&0!==m.current.children.length&&L((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),F):F}),w(w([A],d,!0),[f.fundingSource],!1)),a((function(){null!==O&&(!0===l?O.disable().catch((function(){})):O.enable().catch((function(){})))}),[l,O]),e.createElement(e.Fragment,null,C?e.createElement("div",{ref:m,style:p,className:v}):s)};function j(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n);e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(t,"?").concat(L(r)),dataAttributes:o}}function L(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function F(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 B(e,t){if(void 0===t&&(t=U()),x(e,t),"undefined"==typeof window)return t.resolve(null);var n=j(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=_(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=F(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):M({url:r,attributes:o},t).then((function(){var e=_(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function M(e,t){void 0===t&&(t=U()),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 window)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=F(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 U(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function _(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.")}D.displayName="PayPalButtons";var H=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([M({url:m}),M({url:y})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},G=function(t){var n=t.className,r=void 0===n?"":n,i=t.disabled,c=void 0!==i&&i,s=t.children,u=t.forceReRender,p=void 0===u?[]:u,v=t.braintreeNamespace,h=P(t,["className","disabled","children","forceReRender","braintreeNamespace"]),m=o(null)[1],y=R(),w=y[0],b=y[1];return a((function(){H(v).then((function(e){var t=w.options[f],n=w.options[d];return e.client.create({authorization:t||n}).then((function(t){return e.paypalCheckout.create({client:t})})).then((function(e){b({type:l.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){m((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[w.options]),e.createElement(e.Fragment,null,w.braintreePayPalCheckoutInstance&&e.createElement(D,E({className:r,disabled:c,forceReRender:p},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,E(E({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,E(E({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,E(E({},n),{braintree:t}))}),E({},e)}(h,w.braintreePayPalCheckoutInstance)),s))},K=function(t){var n=t.className,i=void 0===n?"":n,c=t.children,l=P(t,["className","children"]),s=T()[0],u=s.isResolved,d=s.options,f=r(null),p=o(!0),v=p[0],m=p[1],y=o(null)[1];return a((function(){if(!1!==u){var e=b(d[h]);if(void 0===e||void 0===e.Marks)return y((function(){throw new Error(N({reactComponentName:K.displayName,sdkComponentKey:"marks",sdkRequestedComponents:d.components,sdkDataNamespace:d[h]}))}));!function(e){var t=f.current;if(!t||!e.isEligible())return m(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&y((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(E({},l)))}}),[u,l.fundingSource]),e.createElement(e.Fragment,null,v?e.createElement("div",{ref:f,className:i}):c)};K.displayName="PayPalMarks";var Y=function(t){var n=t.className,i=void 0===n?"":n,c=t.forceReRender,l=void 0===c?[]:c,s=P(t,["className","forceReRender"]),u=T()[0],d=u.isResolved,f=u.options,p=r(null),v=r(null),m=o(null)[1];return a((function(){if(!1!==d){var e=b(f[h]);if(void 0===e||void 0===e.Messages)return m((function(){throw new Error(N({reactComponentName:Y.displayName,sdkComponentKey:"messages",sdkRequestedComponents:f.components,sdkDataNamespace:f[h]}))}));v.current=e.Messages(E({},s)),v.current.render(p.current).catch((function(e){null!==p.current&&0!==p.current.children.length&&m((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),w([d],l,!0)),e.createElement("div",{ref:p,className:i})};Y.displayName="PayPalMessages";var V=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,s=t.children,d=t.deferLoading,f=void 0!==d&&d,h=i(I,{options:E(E({},o),(n={},n[u]="".concat(g(o)),n[p]=v,n)),loadingStatus:f?c.INITIAL:c.PENDING}),m=h[0],y=h[1];return a((function(){if(!1===f&&m.loadingStatus===c.INITIAL)return y({type:l.LOADING_STATUS,value:c.PENDING});if(m.loadingStatus===c.PENDING){var e=!0;return B(m.options).then((function(){e&&y({type:l.LOADING_STATUS,value:c.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&y({type:l.LOADING_STATUS,value:c.REJECTED})})),function(){e=!1}}}),[m.options,f,m.loadingStatus]),e.createElement(S.Provider,{value:E(E({},m),{dispatch:y})},s)},q=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")},X=function(e){q(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},z=function(t){var n=t.styles,i=t.createOrder,l=t.notEligibleError,s=t.children,u=R()[0],d=u.options,f=u.loadingStatus,p=o(!0),v=p[0],m=p[1],y=o(),P=y[0],w=y[1],N=o(null)[1],g=r(null),A=r(),I=function(e){void 0===e&&(e={});var t=r(e);return[t,function(e){t.current=E(E({},t.current),e)}]}(),S=I[0],O=I[1];return a((function(){var e;if(X(Object.keys(S.current)),f===c.RESOLVED){if(A.current=b(d[h]).HostedFields,!A.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[h],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:d.components})[h]=d[h],e)));if(!A.current.isEligible())return m(!1);P&&P.teardown(),A.current.render({createOrder:i,styles:n,fields:S.current}).then((function(e){g.current&&w(e)})).catch((function(e){N((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[f,n]),e.createElement("div",{ref:g},v?e.createElement(k.Provider,{value:{cardFields:P,registerHostedField:O}},s):l)},J=function(t){var r=t.hostedFieldType,o=t.options,i=P(t,["hostedFieldType","options"]),c=n(k);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",E({},i))},W={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",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBLANCO:"multiblanco"};export{G as BraintreePayPalButtons,l as DISPATCH_ACTION,W as FUNDING,s as PAYPAL_HOSTED_FIELDS_TYPES,D as PayPalButtons,J as PayPalHostedField,z as PayPalHostedFieldsProvider,K as PayPalMarks,Y as PayPalMessages,V as PayPalScriptProvider,c as SCRIPT_LOADING_STATE,S as ScriptContext,A as destroySDKScript,g as getScriptID,I as scriptReducer,C as usePayPalHostedFields,T as usePayPalScriptReducer,R as useScriptProviderContext};

@@ -29,9 +29,1 @@ import type { BraintreeNamespace } from "./../../types/braintreePayPalButtonTypes";

export declare const getBraintreeNamespace: (braintreeSource?: BraintreeNamespace | undefined) => Promise<BraintreeNamespace>;
/**
* Get the merchantId from the source list
*
* @param {Array|string} source - the source list with merchant identifiers
* @throws {Error} when the merchant list has more than 1 value
* @returns {string|undefined} the merchantId or an undefined value
*/
export declare const getMerchantId: (source?: string | string[] | undefined) => string | undefined;

@@ -6,3 +6,2 @@ /*********************************************

export declare const SDK_SETTINGS: {
MERCHANT_CLIENT_ID: string;
DATA_CLIENT_TOKEN: string;

@@ -19,3 +18,2 @@ DATA_USER_ID_TOKEN: string;

export declare const EMPTY_BRAINTREE_AUTHORIZATION_ERROR_MESSAGE = "Invalid authorization data. Use data-client-token or data-user-id-token to authorize.";
export declare const BRAINTREE_MULTIPLE_MERCHANT_IDS_ERROR_MESSAGE = "Braintree does not support passing in multiple merchantId values.";
export declare const BRAINTREE_SOURCE: string;

@@ -22,0 +20,0 @@ export declare const BRAINTREE_PAYPAL_CHECKOUT_SOURCE: string;

@@ -78,5 +78,5 @@ import type { BraintreeCallback, BraintreeCurrencyAmount, BraintreeAddress, BraintreeLineItem, BraintreeTokenizePayload } from "./commonsTypes";

create(options: {
client?: BraintreeClient;
authorization?: string;
merchantAccountId?: string;
client?: BraintreeClient | undefined;
authorization?: string | undefined;
merchantAccountId?: string | undefined;
}): Promise<BraintreePayPalCheckout>;

@@ -83,0 +83,0 @@ /**

{
"name": "@paypal/react-paypal-js",
"version": "7.6.1",
"version": "7.6.2",
"description": "React components for the PayPal JS SDK",

@@ -5,0 +5,0 @@ "keywords": [

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