text: /*!
   * react-paypal-js v7.5.0 (2021-11-29T15:29:28.584Z)
   * Copyright 2020-present, PayPal, Inc. All rights reserved.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * https://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  import e,{createContext as t,useContext as n,useRef as r,useState as o,useEffect as a,useReducer as i,Children as c}from"react";var s,u,l;!function(e){e.INITIAL="initial",e.PENDING="pending",e.REJECTED="rejected",e.RESOLVED="resolved"}(s||(s={})),function(e){e.LOADING_STATUS="setLoadingStatus",e.RESET_OPTIONS="resetOptions",e.SET_BRAINTREE_INSTANCE="braintreeInstance"}(u||(u={})),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 d="data-react-paypal-script-id",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 f(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 v(e){return void 0===e&&(e="paypal"),window[e]}function m(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i="Unable to render <"+t+" /> because window."+(void 0===a?"paypal":a)+"."+n.charAt(0).toUpperCase().concat(n.substring(1))+" is undefined.";if(!o.includes(n)){var c=[o,n].filter(Boolean).join();i+="\nTo fix the issue, add '"+n+"' to the list of components passed to the parent PayPalScriptProvider:\n`<PayPalScriptProvider options={{ components: '"+c+"'}}>`."}return i}function y(e){return"react-paypal-js-"+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 E(e){var t=self.document.querySelector("script["+d+'="'+e+'"]');(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function P(e,t){var n;switch(t.type){case u.LOADING_STATUS:return p(p({},e),{loadingStatus:t.value});case u.RESET_OPTIONS:return E(e.options[d]),delete t.value[d],p(p({},e),{loadingStatus:s.PENDING,options:p(p({},t.value),(n={},n[d]=""+y(t.value),n["data-sdk-integration-source"]="react-paypal-js",n))});case u.SET_BRAINTREE_INSTANCE:return p(p({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var w=t(null);function b(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 e=b(n(w));return[p(p({},e),{isInitial:e.loadingStatus===s.INITIAL,isPending:e.loadingStatus===s.PENDING,isResolved:e.loadingStatus===s.RESOLVED,isRejected:e.loadingStatus===s.REJECTED}),e.dispatch]}function g(){var e=function(e){var t;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t["data-client-token"]))throw new Error("A client token wasn't found in the provider parent component");return e}(b(n(w)));return[e,e.dispatch]}var A=t(null);function I(){return n(A)}var S=function(t){var n=t.className,i=void 0===n?"":n,c=t.disabled,s=void 0!==c&&c,u=t.children,l=t.forceReRender,d=void 0===l?[]:l,y=f(t,["className","disabled","children","forceReRender"]),E=s?{opacity:.38}:{},P=(i+" "+(s?"paypal-buttons-disabled":"")).trim(),w=r(null),b=r(null),g=N()[0],A=g.isResolved,I=g.options,T=o(null),O=T[0],R=T[1],k=o(!0),C=k[0],D=k[1],j=o(null)[1];function L(){null!==b.current&&b.current.close().catch((function(){}))}return a((function(){if(!1===A)return L;var e=v(I["data-namespace"]);if(void 0===e||void 0===e.Buttons)return j((function(){throw new Error(m({reactComponentName:S.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:I.components,sdkDataNamespace:I["data-namespace"]}))})),L;try{b.current=e.Buttons(p(p({},y),{onInit:function(e,t){R(t),"function"==typeof y.onInit&&y.onInit(e,t)}}))}catch(e){return j((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize:  "+e)}))}return!1===b.current.isEligible()?(D(!1),L):w.current?(b.current.render(w.current).catch((function(e){null!==w.current&&0!==w.current.children.length&&j((function(){throw new Error("Failed to render <PayPalButtons /> component. "+e)}))})),L):L}),h(h([A],d,!0),[y.fundingSource],!1)),a((function(){null!==O&&(!0===s?O.disable().catch((function(){})):O.enable().catch((function(){})))}),[s,O]),e.createElement(e.Fragment,null,C?e.createElement("div",{ref:w,style:E,className:P}):u)};function T(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(O(r)),dataAttributes:o}}function O(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 k(e,t){if(void 0===t&&(t=D()),L(e,t),"undefined"==typeof window)return t.resolve(null);var n=T(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=j(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):C({url:r,attributes:o},t).then((function(){var e=j(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function C(e,t){void 0===t&&(t=D()),L(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=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(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function j(e){return window[e]}function L(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.")}S.displayName="PayPalButtons";var F=function(t){var n=t.className,r=void 0===n?"":n,i=t.disabled,c=void 0!==i&&i,s=t.children,l=t.forceReRender,d=void 0===l?[]:l,h=f(t,["className","disabled","children","forceReRender"]),v=o(null)[1],m=g(),y=m[0],E=m[1];return a((function(){Promise.all([C({url:"https://js.braintreegateway.com/web/3.81.0/js/client.min.js"}),C({url:"https://js.braintreegateway.com/web/3.81.0/js/paypal-checkout.min.js"})]).then((function(){var e,t=y.options["data-client-token"],n=(void 0===e&&(e="braintree"),window[e]);return n.client.create({authorization:t}).then((function(e){return n.paypalCheckout.create({client:e})})).then((function(e){E({type:u.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){v((function(){throw new Error("Failed to load the PayPal JS SDK script. "+e)}))}))}),[y.options,E]),e.createElement(e.Fragment,null,y.braintreePayPalCheckoutInstance&&e.createElement(S,p({className:r,disabled:c,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)}(h,y.braintreePayPalCheckoutInstance)),s))},B=function(t){var n=t.className,i=void 0===n?"":n,c=t.children,s=f(t,["className","children"]),u=N()[0],l=u.isResolved,d=u.options,h=r(null),y=o(!0),E=y[0],P=y[1],w=o(null)[1];return a((function(){if(!1!==l){var e=v(d["data-namespace"]);if(void 0===e||void 0===e.Marks)return w((function(){throw new Error(m({reactComponentName:B.displayName,sdkComponentKey:"marks",sdkRequestedComponents:d.components,sdkDataNamespace:d["data-namespace"]}))}));!function(e){var t=h.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&&w((function(){throw new Error("Failed to render <PayPalMarks /> component. "+e)}))}))}(e.Marks(p({},s)))}}),[l,s.fundingSource]),e.createElement(e.Fragment,null,E?e.createElement("div",{ref:h,className:i}):c)};B.displayName="PayPalMarks";var M=function(t){var n=t.className,i=void 0===n?"":n,c=t.forceReRender,s=void 0===c?[]:c,u=f(t,["className","forceReRender"]),l=N()[0],d=l.isResolved,y=l.options,E=r(null),P=r(null),w=o(null)[1];return a((function(){if(!1!==d){var e=v(y["data-namespace"]);if(void 0===e||void 0===e.Messages)return w((function(){throw new Error(m({reactComponentName:M.displayName,sdkComponentKey:"messages",sdkRequestedComponents:y.components,sdkDataNamespace:y["data-namespace"]}))}));P.current=e.Messages(p({},u)),null!==E.current&&P.current.render(E.current).catch((function(e){null!==E.current&&0!==E.current.children.length&&w((function(){throw new Error("Failed to render <PayPalMessages /> component. "+e)}))}))}}),h([d],s,!0)),e.createElement("div",{ref:E,className:i})};M.displayName="PayPalMessages";var _=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,c=t.children,l=t.deferLoading,f=void 0!==l&&l,h=i(P,{options:p(p({},o),(n={},n[d]=""+y(o),n["data-sdk-integration-source"]="react-paypal-js",n)),loadingStatus:f?s.INITIAL:s.PENDING}),v=h[0],m=h[1];return a((function(){if(!1===f&&v.loadingStatus===s.INITIAL)return m({type:u.LOADING_STATUS,value:s.PENDING});if(v.loadingStatus===s.PENDING){var e=!0;return k(v.options).then((function(){e&&m({type:u.LOADING_STATUS,value:s.RESOLVED})})).catch((function(t){console.error("Failed to load the PayPal JS SDK script. "+t),e&&m({type:u.LOADING_STATUS,value:s.REJECTED})})),function(){e=!1}}}),[v.options,f,v.loadingStatus]),e.createElement(w.Provider,{value:p(p({},v),{dispatch:m})},c)},x=function(e){return e.reduce((function(e,t){var n=t.props,r=n.hostedFieldType,o=n.options;return Object.values(l).includes(r)&&(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}),{})},U=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")},G=function(e){var t=function(e){return e.reduce((function(e,t){var n=t;return n.props.hostedFieldType&&e.push(n.props.hostedFieldType),e}),[])}(e);U(t),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(t)},K=function(t){var n=t.styles,i=t.createOrder,u=t.notEligibleError,l=t.children,d=c.toArray(l),p=g()[0],f=p.options,h=p.loadingStatus,m=o(!0),y=m[0],E=m[1],P=o(null),w=P[0],b=P[1],N=r(null),I=r(),S=o(null)[1];return a((function(){G(d)}),[]),a((function(){var e;if(h===s.RESOLVED){if(I.current=v(f["data-namespace"]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e["data-namespace"],o=n?n+",hosted-fields":"hosted-fields",a="Unable to render <PayPalHostedFieldsProvider /> because window."+(void 0===r?"paypal":r)+".HostedFields is undefined.";return n.includes("hosted-fields")||(a+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '"+o+"'}}>"),a}(((e={components:f.components})["data-namespace"]=f["data-namespace"],e)));if(!I.current.isEligible())return E(!1);w&&w.teardown(),I.current.render({createOrder:i,styles:n,fields:x(d)}).then((function(e){b(e)})).catch((function(e){S((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. "+e)}))}))}}),[h,n]),e.createElement("div",{ref:N},y?e.createElement(A.Provider,{value:w},l):u)},Y=function(t){t.hostedFieldType,t.options;var n=f(t,["hostedFieldType","options"]);return e.createElement("div",p({},n))},V={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"};export{F as BraintreePayPalButtons,u as DISPATCH_ACTION,V as FUNDING,l as PAYPAL_HOSTED_FIELDS_TYPES,S as PayPalButtons,Y as PayPalHostedField,K as PayPalHostedFieldsProvider,B as PayPalMarks,M as PayPalMessages,_ as PayPalScriptProvider,s as SCRIPT_LOADING_STATE,w as ScriptContext,E as destroySDKScript,y as getScriptID,P as scriptReducer,I as usePayPalHostedFields,N as usePayPalScriptReducer,g as useScriptProviderContext};
  