1import{P as c,R as s,d as be,c as le,r as $,b as J,j as O,u as Le,n as w,h as f,B as _e}from"./index-3d3bd5ca.js";function ne(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(r,o).enumerable})),t.push.apply(t,n)}return t}function ae(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ne(Object(t),!0).forEach(function(n){fe(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ne(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function B(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?B=function(e){return typeof e}:B=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},B(r)}function fe(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function q(r,e){return Ie(r)||ke(r,e)||xe(r,e)||we()}function Ie(r){if(Array.isArray(r))return r}function ke(r,e){var t=r&&(typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"]);if(t!=null){var n=[],o=!0,a=!1,u,m;try{for(t=t.call(r);!(o=(u=t.next()).done)&&(n.push(u.value),!(e&&n.length===e));o=!0);}catch(i){a=!0,m=i}finally{try{!o&&t.return!=null&&t.return()}finally{if(a)throw m}}return n}}function xe(r,e){if(r){if(typeof r=="string")return oe(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return oe(r,e)}}function oe(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function we(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 2In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var X=function(e){var t=s.useRef(e);return s.useEffect(function(){t.current=e},[e]),t.current},L=function(e){return e!==null&&B(e)==="object"},Pe=function(e){return L(e)&&typeof e.then=="function"},je=function(e){return L(e)&&typeof e.elements=="function"&&typeof e.createToken=="function"&&typeof e.createPaymentMethod=="function"&&typeof e.confirmCardPayment=="function"},ie="[object Object]",De=function r(e,t){if(!L(e)||!L(t))return e===t;var n=Array.isArray(e),o=Array.isArray(t);if(n!==o)return!1;var a=Object.prototype.toString.call(e)===ie,u=Object.prototype.toString.call(t)===ie;if(a!==u)return!1;if(!a&&!n)return e===t;var m=Object.keys(e),i=Object.keys(t);if(m.length!==i.length)return!1;for(var l={},S=0;S<m.length;S+=1)l[m[S]]=!0;for(var h=0;h<i.length;h+=1)l[i[h]]=!0;var R=Object.keys(l);if(R.length!==m.length)return!1;var _=e,I=t,y=function(b){return r(_[b],I[b])};return R.every(y)},pe=function(e,t,n){return L(e)?Object.keys(e).reduce(function(o,a){var u=!L(t)||!De(e[a],t[a]);return n.includes(a)?(u&&console.warn("Unsupported prop change: options.".concat(a," is not a mutable property.")),o):u?ae(ae({},o||{}),{},fe({},a,e[a])):o},null):null},de="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",se=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:de;if(e===null||je(e))return e;throw new Error(t)},Me=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:de;if(Pe(e))return{tag:"async",stripePromise:Promise.resolve(e).then(function(o){return se(o,t)})};var n=se(e,t);return n===null?{tag:"empty"}:{tag:"sync",stripe:n}},Fe=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:"react-stripe-js",version:"2.3.1"}),e.registerAppInfo({name:"react-stripe-js",version:"2.3.1",url:"https://stripe.com/docs/stripe-js/react"}))},me=s.createContext(null);me.displayName="CustomCheckoutSdkContext";var Ue=function(e,t){if(!e)throw new Error("Could not find CustomCheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CustomCheckoutProvider> provider."));return e},We=s.createContext(null);We.displayName="CustomCheckoutContext";c.any,c.shape({clientSecret:c.string.isRequired,elementsOptions:c.object}).isRequired;var H=function(e){var t=s.useContext(me),n=s.useContext(V);if(t&&n)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CustomCheckoutProvider> and <Elements> providers."));return t?Ue(t,e):Ce(n,e)},V=s.createContext(null);V.displayName="ElementsContext";var Ce=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},Q=s.createContext(null);
2Q.displayName="CartElementContext";var Ke=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},Ee=function(e){var t=e.stripe,n=e.options,o=e.children,a=s.useMemo(function(){return Me(t)},[t]),u=s.useState(null),m=q(u,2),i=m[0],l=m[1],S=s.useState(null),h=q(S,2),R=h[0],_=h[1],I=s.useState(function(){return{stripe:a.tag==="sync"?a.stripe:null,elements:a.tag==="sync"?a.stripe.elements(n):null}}),y=q(I,2),A=y[0],b=y[1];s.useEffect(function(){var g=!0,j=function(D){b(function(M){return M.stripe?M:{stripe:D,elements:D.elements(n)}})};return a.tag==="async"&&!A.stripe?a.stripePromise.then(function(N){N&&g&&j(N)}):a.tag==="sync"&&!A.stripe&&j(a.stripe),function(){g=!1}},[a,A,n]);var k=X(t);s.useEffect(function(){k!==null&&k!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[k,t]);var P=X(n);return s.useEffect(function(){if(A.elements){var g=pe(n,P,["clientSecret","fonts"]);g&&A.elements.update(g)}},[n,P,A.elements]),s.useEffect(function(){Fe(A.stripe)},[A.stripe]),s.createElement(V.Provider,{value:A},s.createElement(Q.Provider,{value:{cart:i,setCart:l,cartState:R,setCartState:_}},o))};Ee.propTypes={stripe:c.any,options:c.object};var $e=function(e){var t=s.useContext(V);return Ce(t,e)},Be={cart:null,cartState:null,setCart:function(){},setCartState:function(){}},ue=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=s.useContext(Q);return t?Be:Ke(n,e)},qe=function(){var e=$e("calls useElements()"),t=e.elements;return t},Ve=function(){var e=H("calls useStripe()"),t=e.stripe;return t};c.func.isRequired;var v=function(e,t,n){var o=!!n,a=s.useRef(n);s.useEffect(function(){a.current=n},[n]),s.useEffect(function(){if(!o||!e)return function(){};var u=function(){a.current&&a.current.apply(a,arguments)};return e.on(t,u),function(){e.off(t,u)}},[o,t,e,a])},Ye=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},p=function(e,t){var n="".concat(Ye(e),"Element"),o=function(i){var l=i.id,S=i.className,h=i.options,R=h===void 0?{}:h,_=i.onBlur,I=i.onFocus,y=i.onReady,A=i.onChange,b=i.onEscape,k=i.onClick,P=i.onLoadError,g=i.onLoaderStart,j=i.onNetworksChange,N=i.onCheckout,D=i.onLineItemClick,M=i.onConfirm,he=i.onCancel,Re=i.onShippingAddressChange,ye=i.onShippingRateChange,x=H("mounts <".concat(n,">")),F="elements"in x?x.elements:null,U="customCheckoutSdk"in x?x.customCheckoutSdk:null,Te=s.useState(null),Z=q(Te,2),E=Z[0],ge=Z[1],T=s.useRef(null),Y=s.useRef(null),ee=ue("mounts <".concat(n,">"),"customCheckoutSdk"in x),G=ee.setCart,z=ee.setCartState;v(E,"blur",_),v(E,"focus",I),v(E,"escape",b),v(E,"click",k),v(E,"loaderror",P),v(E,"loaderstart",g),v(E,"networkschange",j),v(E,"lineitemclick",D),v(E,"confirm",M),v(E,"cancel",he),v(E,"shippingaddresschange",Re),v(E,"shippingratechange",ye);var W;e==="cart"?W=function(re){z(re),y&&y(re)}:y&&(e==="expressCheckout"?W=y:W=function(){y(E)}),v(E,"ready",W);var Ne=e==="cart"?function(C){z(C),A&&A(C)}:A;v(E,"change",Ne);var Oe=e==="cart"?function(C){z(C),N&&N(C)}:N;v(E,"checkout",Oe),s.useLayoutEffect(function(){if(T.current===null&&Y.current!==null&&(F||U)){var C=null;U?C=U.createElement(e,R):F&&(C=F.create(e,R)),e==="cart"&&G&&G(C),T.current=C,ge(C),C&&C.mount(Y.current)}},[F,U,R,G]);var te=X(R);return s.useEffect(function(){if(T.current){var C=pe(R,te,["paymentRequest"]);C&&T.current.update(C)}},[R,te]),s.useLayoutEffect(function(){return function(){if(T.current&&typeof T.current.destroy=="function")try{T.current.destroy(),T.current=null}catch{}}},[]),s.createElement("div",{id:l,className:S,ref:Y})},a=function(i){var l=H("mounts <".concat(n,">"));ue("mounts <".concat(n,">"),"customCheckoutSdk"in l);var S=i.id,h=i.className;return s.createElement("div",{id:S,className:h})},u=t?a:o;return u.propTypes={id:c.string,className:c.string,onChange:c.func,onBlur:c.func,onFocus:c.func,onReady:c.func,onEscape:c.func,onClick:c.func,onLoadError:c.func,onLoaderStart:c.func,onNetworksChange:c.func,onCheckout:c.func,onLineItemClick:c.func,onConfirm:c.func,onCancel:c.func,onShippingAddressChange:c.func,onShippingRateChange:c.func,options:c.object},u.displayName=n,u.__elementType=e,u},d=typeof window>"u",Ge=s.createContext(null);Ge.displayName="EmbeddedCheckoutProviderContext";p("auBankAccount",d);p("card",d);p("cardNumber",d);p("cardExpiry",d);p("cardCvc",d);p("fpxBank",d);p("iban",d);p("idealBank",d);p("p24Bank",d);p("epsBank",d);var ze=p("payment",d);p("expressCheckout",d);p("paymentRequestButton",d);p("linkAuthentication",d);p("address",d);p("shippingAddress",d);p("cart",d);p("paymentMethodMessaging",d);p("affirmMessage",d);p("afterpayClearpayMessage",d);var ve="https://js.stripe.com/v3",Je=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,ce="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",Xe=function(){for(var e=document.querySelectorAll('script[src^="'.concat(ve,'"]')),t=0;t<e.length;t++){var n=e[t];if(Je.test(n.src))return n}return null},He=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(ve).concat(t);var o=document.head||document.body;if(!o)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return o.appendChild(n),n},Qe=function(e,t){!e||!e._registerWrapper||e._registerWrapper({name:"stripe-js",version:"1.54.2",startTime:t})},K=null,Ze=function(e){return K!==null||(K=new Promise(function(t,n){if(typeof window>"u"||typeof document>"u"){t(null);return}if(window.Stripe&&e&&console.warn(ce),window.Stripe){t(window.Stripe);return}try{var o=Xe();o&&e?console.warn(ce):o||(o=He(e)),o.addEventListener("load",function(){window.Stripe?t(window.Stripe):n(new Error("Stripe.js not available"))}),o.addEventListener("error",function(){n(new Error("Failed to load Stripe.js"))})}catch(a){n(a);return}})),K},et=function(e,t,n){if(e===null)return null;var o=e.apply(void 0,t);return Qe(o,n),o},Ae=Promise.resolve().then(function(){return Ze(null)}),Se=!1;Ae.catch(function(r){Se||console.warn(r)});var tt=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Se=!0;var o=Date.now();return Ae.then(function(a){return et(a,t,o)})};const rt=tt("pk_live_z3hHlNo7rlK0LGcFebcPEoD4"),nt=()=>{const r=Ve(),e=qe(),[t,n]=$.useState(!1),{me:o}=Le(),a=le(),{t:u}=J(),m=async i=>{if(i.preventDefault(),!r||!e)return;n(!0);const{error:l,paymentIntent:S}=await r.confirmPayment({elements:e,confirmParams:{return_url:`${window.location.origin}/stripe`},redirect:"if_required"});switch(((l==null?void 0:l.type)==="card_error"||(l==null?void 0:l.type)==="validation_error")&&(w.error(u(f.ALERT.ALERT_TRANSACTION.REDEEM_COIN_FAILED.i18nKey,f.ALERT.ALERT_TRANSACTION.REDEEM_COIN_FAILED.fallback),{details:u(f.ALERT.ALERT_TRANSACTION.ERROR_VALIDATE_TRANSACTION.i18nKey,f.ALERT.ALERT_TRANSACTION.ERROR_VALIDATE_TRANSACTION.fallback)}),a("/credit",{replace:!0})),S==null?void 0:S.status){case"succeeded":w.success(u(f.ALERT.ALERT_TRANSACTION.REDEEM_COIN_SUCCESS.i18nKey,f.ALERT.ALERT_TRANSACTION.REDEEM_COIN_SUCCESS.fallback)),a("/credit",{replace:!0});break;case"canceled":w.error(u(f.ALERT.ALERT_TRANSACTION.REDEEM_COIN_FAILED.i18nKey,f.ALERT.ALERT_TRANSACTION.REDEEM_COIN_FAILED.fallback),{details:u(f.ALERT.ALERT_TRANSACTION.ERROR_VALIDATE_TRANSACTION.i18nKey,f.ALERT.ALERT_TRANSACTION.ERROR_VALIDATE_TRANSACTION.fallback)}),a("/credit",{replace:!0});break}n(!1)};return O.jsx("div",{children:O.jsxs("form",{id:"payment-form",onSubmit:m,children:[O.jsx(ze,{options:{layout:"accordion",defaultValues:{billingDetails:{email:o==null?void 0:o.email}}},onLoadError:()=>{w.error(u(f.ALERT.ALERT_TRANSACTION.REDEEM_COIN_FAILED.i18nKey,f.ALERT.ALERT_TRANSACTION.REDEEM_COIN_FAILED.fallback),{details:u(f.ALERT.ALERT_TRANSACTION.ERROR_VALIDATE_TRANSACTION.i18nKey,f.ALERT.ALERT_TRANSACTION.ERROR_VALIDATE_TRANSACTION.fallback)}),a("/credit",{replace:!0})}}),O.jsx(_e,{htmlType:"submit",loading:t,disabled:t||!r||!e,block:!0,style:{marginTop:"1rem"}
2,type:"primary",children:u(f.COMMON.CONFIRM.i18nKey,f.COMMON.CONFIRM.fallback)})]})})};function ot(){const[r]=be(),e=le(),t=$.useRef(!0),[n,o]=$.useState(null),{i18n:a}=J(),{t:u}=J(),m=()=>{e("/credit",{replace:!0}),w.error(u(f.ALERT.ALERT_TRANSACTION.TRANSACTION_FAILED_TITLE.i18nKey,f.ALERT.ALERT_TRANSACTION.TRANSACTION_FAILED_TITLE.fallback),{details:u(f.ALERT.ALERT_TRANSACTION.TRANSACTION_FAILED_DETAIL.i18nKey,f.ALERT.ALERT_TRANSACTION.TRANSACTION_FAILED_DETAIL.fallback)})};return $.useEffect(()=>{if(!t.current)return;const i=r.get("secret");if(!i){m();return}const l=i.split("_");if(l.length!==4){m();return}if(l[0]!=="pi"&&l[2]!=="secret"){m();return}return o(i),()=>{t.current=!1}},[]),n?O.jsx("div",{children:O.jsx(Ee,{stripe:rt,options:{clientSecret:n,appearance:{theme:"flat"},locale:a.language},children:O.jsx(nt,{})})}):null}export{ot as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.