1import{r as u,b8 as O,j as r,b1 as D,T as b,N as M,av as U,b9 as z,b0 as g,m as W,aR as G,n as S,V as $,ba as I,bb as Q,bc as H,aJ as K,bd as y,be as R,u as k,bf as Y,bg as Z,ar as J,ax as A,w as d}from"./main-d6900c47.js";import{S as V,l as X,B}from"./billing-redirect-message-e48ae94a.js";import"./TaskAlt-672e5053.js";function E({children:e}){const[t,s]=e;return u.useEffect(()=>{O("be.onboarding.selected")},[]),r.jsxs(u.Fragment,{children:[r.jsx(D,{children:r.jsx(b,{message:"Checkout"})}),r.jsx(M,{size:"sm",color:"transparent",className:"z-10 mb-20 md:mb-0",textColor:"text-main",logoColor:"dark",darkModeColor:"transparent",menuPosition:"checkout-page-navbar"}),r.jsxs("div",{className:"mx-auto w-full justify-between px-20 md:flex md:max-w-950 md:px-0 md:pt-128",children:[r.jsx("div",{className:"fixed right-0 top-0 hidden h-full w-1/2 bg-alt shadow-[15px_0_30px_0_rgb(0_0_0_/_18%)] md:block"}),r.jsxs("div",{className:"overflow-hidden md:w-400",children:[t,r.jsx(U,{menu:"checkout-page-footer",className:"mt-50 overflow-x-auto text-xs text-muted"}),r.jsx("div",{className:"mt-40",children:r.jsx(z,{})})]}),r.jsx("div",{className:"hidden w-384 md:block",children:r.jsx("div",{className:"relative z-10",children:s})})]})]})}const q=e=>`billing/products/${e}`;function ee(){var a;const{productId:e,priceId:t}=g(),s=W({queryKey:[q(e)],queryFn:()=>te(e),placeholderData:G,enabled:e!=null&&t!=null}),n=(a=s.data)==null?void 0:a.product,i=(n==null?void 0:n.prices.find(c=>c.id===parseInt(t)))||(n==null?void 0:n.prices[0]);return{status:s.status,product:n,price:i}}function te(e){return S.get(q(e)).then(t=>t.data)}function N({showBillingLine:e=!0}){const{status:t,product:s,price:n}=ee();return t==="error"||t!=="pending"&&(!s||!n)?null:r.jsxs("div",{children:[r.jsx("h2",{className:"mb-30 text-2xl",children:r.jsx(b,{message:"Summary"})}),t==="pending"?r.jsx(re,{},"loading-skeleton"):r.jsx(se,{product:s,price:n,showBillingLine:e})]})}function se({product:e,price:t,showBillingLine:s}){return r.jsxs($.div,{children:[r.jsx("div",{className:"mb-6 text-xl font-semibold",children:e.name}),e.description&&r.jsx("div",{className:"text-sm text-muted",children:e.description}),r.jsx(I,{priceClassName:"font-bold text-4xl",periodClassName:"text-muted text-xs",variant:"separateLine",price:t,className:"mt-32"}),r.jsx(Q,{product:e}),s&&r.jsxs("div",{className:"mt-32 flex items-center justify-between gap-24 border-t pt-24 font-medium",children:[r.jsx("div",{children:r.jsx(b,{message:"Billed today"})}),r.jsx("div",{children:r.jsx(H,{value:t.amount,currency:t.currency})})]})]})}function re(){return r.jsxs($.div,{...K,className:"max-w-180",children:[r.jsx(y,{className:"mb-6 text-xl"}),r.jsx(y,{className:"text-sm"}),r.jsx(y,{className:"mt-32 text-4xl"})]})}/*! 2 * paypal-js v7.0.3 (2023-09-19T14:17:47.731Z) 3 * Copyright 2020-present, PayPal, Inc. All rights reserved. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */function ne(e,t){var s=document.querySelector('script[src="'.concat(e,'"]'));if(s===null)return null;var n=F(e,t),i=s.cloneNode();if(delete i.dataset.uidAuto,Object.keys(i.dataset).length!==Object.keys(n.dataset).length)return null;var a=!0;return Object.keys(i.dataset).forEach(function(c){i.dataset[c]!==n.dataset[c]&&(a=!1)}),a?s:null}function ae(e){var t=e.url,s=e.attributes,n=e.onSuccess,i=e.onError,a=F(t,s);a.onerror=i,a.onload=n,document.head.insertBefore(a,document.head.firstElementChild)}function ie(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseUrl&&(t=e.sdkBaseUrl,delete e.sdkBaseUrl);var s=e,n=Object.keys(s).filter(function(c){return typeof s[c]<"u"&&s[c]!==null&&s[c]!==""}).reduce(function(c,o){var l=s[o].toString();return o=ce(o),o.substring(0,4)==="data"?c.dataAttributes[o]=l:c.queryParams[o]=l,c},{queryParams:{},dataAttributes:{}}),i=n.queryParams,a=n.dataAttributes;return i["merchant-id"]&&i["merchant-id"].indexOf(",")!==-1&&(a["data-merchant-id"]=i["merchant-id"],i["merchant-id"]="*"),{url:"".concat(t,"?").concat(oe(i)),dataAttributes:a}}function ce(e){var t=function(s,n){return(n?"-":"")+s.toLowerCase()};return e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,t)}function oe(e){var t="";return Object.keys(e).forEach(function(s){t.length!==0&&(t+="&"),t+=s+"="+e[s]}),t}function F(e,t){t===void 0&&(t={});var s=document.createElement("script");return s.src=e,Object.keys(t).forEach(function(n){s.setAttribute(n,t[n]),n==="data-csp-nonce"&&s.setAttribute("nonce",t["data-csp-nonce"])}),s}function ue(e,t){if(t===void 0&&(t=Promise),T(e,t),typeof document>"u")return t.resolve(null);var s=ie(e),n=s.url,i=s.dataAttributes,a=i["data-namespace"]||"paypal",c=L(a);return ne(n,i)&&c?t.resolve(c):le({url:n,attributes:i},t).then(function(){var o=L(a);if(o)return o;throw new Error("The window.".concat(a," global variable is not available."))})}function le(e,t){t===void 0&&(t=Promise),T(e,t);var s=e.url,n=e.attributes;
16if(typeof s!="string"||s.length===0)throw new Error("Invalid url.");if(typeof n<"u"&&typeof n!="object")throw new Error("Expected attributes to be an object.");return new t(function(i,a){if(typeof document>"u")return i();ae({url:s,attributes:n,onSuccess:function(){return i()},onError:function(){var c=new Error('The script "'.concat(s,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return a(c)}})})}function L(e){return window[e]}function T(e,t){if(typeof e!="object"||e===null)throw new Error("Expected an options object.");if(typeof t<"u"&&typeof t!="function")throw new Error("Expected PromisePonyfill to be a function.")}function de({productId:e,priceId:t}){const{data:s}=R(),n=u.useRef(!1),i=u.useRef(!1),[a,c]=u.useState(!1),o=u.useRef(null),{base_url:l,billing:{stripe:{enable:p},paypal:{enable:f,public_key:x}}}=k();return u.useEffect(()=>{!f||!x||n.current||(ue({clientId:x,intent:"subscription",vault:!0,disableFunding:p?"card":void 0}).then(()=>{c(!0)}),n.current=!0)},[x,f,p]),u.useEffect(()=>{var C;if(!a||!((C=window.paypal)!=null&&C.Buttons)||!o.current||!(s!=null&&s.products.length)||!e||!t||i.current)return;const h=s.products.find(m=>m.id===parseInt(e)),v=h==null?void 0:h.prices.find(m=>m.id===parseInt(t));window.paypal.Buttons({style:{label:"pay"},createSubscription:(m,j)=>j.subscription.create({application_context:{shipping_preference:"NO_SHIPPING"},plan_id:v==null?void 0:v.paypal_id}),onApprove:(m,j)=>(j.redirect(`${l}/checkout/${e}/${t}/paypal/done?subscriptionId=${m.subscriptionID}&status=success`),Promise.resolve()),onError:m=>{location.href=`${l}/checkout/${e}/${t}/paypal/done?status=error`}}).render(o.current).then(()=>{i.current=!0})},[e,t,s,a,l]),{paypalElementRef:o,stripeIsEnabled:x!=null&&f}}function ve(){var l;const{productId:e,priceId:t}=g(),s=R(),{paypalElementRef:n}=de({productId:e,priceId:t}),{base_url:i,billing:{stripe:a}}=k();if(s.isLoading)return r.jsx(Y,{screen:!0});const c=(l=s.data)==null?void 0:l.products.find(p=>p.id===parseInt(e)),o=c==null?void 0:c.prices.find(p=>p.id===parseInt(t));return!c||!o||s.status==="error"?r.jsx(Z,{to:"/pricing",replace:!0}):r.jsxs(E,{children:[r.jsxs(u.Fragment,{children:[r.jsx("h1",{className:"mb-40 text-4xl",children:r.jsx(b,{message:"Checkout"})}),a.enable?r.jsxs(u.Fragment,{children:[r.jsx(V,{productId:e,priceId:t,submitLabel:r.jsx(b,{message:"Upgrade"}),type:"subscription",returnUrl:`${i}/checkout/${e}/${t}/stripe/done`}),r.jsx(fe,{})]}):null,r.jsx("div",{ref:n}),r.jsx("div",{className:"mt-30 text-xs text-muted",children:r.jsx(b,{message:"Youâll be charged until you cancel your subscription. Previous charges wonât be refunded when you cancel unless itâs legally required. Your payment data is encrypted and secure. By subscribing your agree to our terms of service and privacy policy."})})]}),r.jsx(N,{})]})}function fe(){return r.jsx("div",{className:"relative my-20 text-center before:absolute before:left-0 before:top-1/2 before:h-1 before:w-full before:-translate-y-1/2 before:bg-divider",children:r.jsx("span",{className:"relative z-10 bg px-10 text-sm text-muted",children:r.jsx(b,{message:"or"})})})}function je(){const{productId:e,priceId:t}=g(),s=J(),{billing:{stripe_public_key:n}}=k(),[i]=A(),a=i.get("payment_intent_client_secret"),[c,o]=u.useState(),l=u.useRef();return u.useEffect(()=>{l.current||(X(n).then(async p=>{if(!p||!a){o(w());return}p.retrievePaymentIntent(a).then(async({paymentIntent:f})=>{(f==null?void 0:f.status)==="succeeded"?(await pe(f.id),o(w("succeeded",e,t)),window.location.href="/billing"):o(w(f==null?void 0:f.status,e,t))})}),l.current=!0)},[n,a,t,e]),a?r.jsxs(E,{children:[r.jsx(B,{config:c}),r.jsx(N,{showBillingLine:!1})]}):(s("/"),null)}function w(e,t,s){switch(e){case"succeeded":return{message:d("Subscription successful!"),status:"success",buttonLabel:d("Return to site"),link:"/billing"};case"processing":return{message:d("Payment processing. We'll update you when payment is received."),status:"success",buttonLabel:d("Return to site"),link:"/billing"};case"requires_payment_method":return{message:d("Payment failed. Please try another payment method."),status:"error",buttonLabel:d("Go back"),link:_(t,s)};default:return{message:d("Something went wrong"),status:"error",buttonLabel:d("Go back"),link:_(t,s)}}}function _(e,t){return e&&t?`/checkout/${e}/${t}`:"/"}function pe(e){return S.post("billing/stripe/store-subscription-detail
16s-locally",{payment_intent_id:e})}function ye(){const{productId:e,priceId:t}=g(),[s]=A(),n=u.useRef(!1),[i,a]=u.useState();return u.useEffect(()=>{const c=s.get("subscriptionId"),o=s.get("status");n.current||(c&&o==="success"?be(c).then(()=>{a(P("success",e,t)),window.location.href="/billing"}):a(P(o,e,t)),n.current=!0)},[t,e,s]),r.jsxs(E,{children:[r.jsx(B,{config:i}),r.jsx(N,{showBillingLine:!1})]})}function P(e,t,s){switch(e){case"success":return{message:d("Subscription successful!"),status:"success",buttonLabel:d("Return to site"),link:"/billing"};default:return{message:d("Something went wrong. Please try again."),status:"error",buttonLabel:d("Go back"),link:me(t,s)}}}function me(e,t){return e&&t?`/checkout/${e}/${t}`:"/"}function be(e){return S.post("billing/paypal/store-subscription-details-locally",{paypal_subscription_id:e})}export{ve as Checkout,ye as CheckoutPaypalDone,je as CheckoutStripeDone}; 17//# sourceMappingURL=checkout-routes.lazy-9a343d6d.js.map
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.