import{a as O,cv as $,r as b,u as k,an as _,j as u,ci as N,aw as B,T as y}from"./main-D6SjkSWq.js";import{C as L,a as q}from"./checkout-product-summary-puOcaxtm.js";import{S as A}from"./stripe-elements-form-BRv5XWM_.js";import"./formatted-price-BMjupemv.js";import"./skeleton-3NNrk_-o.js";import"./product-feature-list-yAlYHCh6.js";import"./index-U9JJOqTM.js";/*!
 * paypal-js v8.4.2 (2025-09-04T17:21:30.135Z)
 * 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
 *
 * http://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.
 */function I(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r}function R(e,t){var r=document.querySelector('script[src="'.concat(e,'"]'));if(r===null)return null;var n=T(e,t),a=r.cloneNode();if(delete a.dataset.uidAuto,Object.keys(a.dataset).length!==Object.keys(n.dataset).length)return null;var s=!0;return Object.keys(a.dataset).forEach(function(c){a.dataset[c]!==n.dataset[c]&&(s=!1)}),s?r:null}function U(e){var t=e.url,r=e.attributes,n=e.onSuccess,a=e.onError,s=T(t,r);s.onerror=a,s.onload=n,document.head.insertBefore(s,document.head.firstElementChild)}function P(e){var t=e.sdkBaseUrl,r=e.environment,n=I(e,["sdkBaseUrl","environment"]),a=t||W(r),s=n,c=Object.keys(s).filter(function(o){return typeof s[o]<"u"&&s[o]!==null&&s[o]!==""}).reduce(function(o,p){var l=s[p].toString();return p=F(p),p.substring(0,4)==="data"||p==="crossorigin"?o.attributes[p]=l:o.queryParams[p]=l,o},{queryParams:{},attributes:{}}),i=c.queryParams,d=c.attributes;return i["merchant-id"]&&i["merchant-id"].indexOf(",")!==-1&&(d["data-merchant-id"]=i["merchant-id"],i["merchant-id"]="*"),{url:"".concat(a,"?").concat(Q(i)),attributes:d}}function F(e){var t=function(r,n){return(n?"-":"")+r.toLowerCase()};return e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,t)}function Q(e){var t="";return Object.keys(e).forEach(function(r){t.length!==0&&(t+="&"),t+=r+"="+e[r]}),t}function W(e){return e==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}function T(e,t){t===void 0&&(t={});var r=document.createElement("script");return r.src=e,Object.keys(t).forEach(function(n){r.setAttribute(n,t[n]),n==="data-csp-nonce"&&r.setAttribute("nonce",t["data-csp-nonce"])}),r}function D(e,t){if(t===void 0&&(t=Promise),C(e,t),typeof document>"u")return t.resolve(null);var r=P(e),n=r.url,a=r.attributes,s=a["data-namespace"]||"paypal",c=S(s);return a["data-js-sdk-library"]||(a["data-js-sdk-library"]="paypal-js"),R(n,a)&&c?t.resolve(c):z({url:n,attributes:a},t).then(function(){var i=S(s);if(i)return i;throw new Error("The window.".concat(s," global variable is not available."))})}function z(e,t){t===void 0&&(t=Promise),C(e,t);var r=e.url,n=e.attributes;if(typeof r!="string"||r.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(a,s){if(typeof document>"u")return a();U({url:r,attributes:n,onSuccess:function(){return a()},onError:function(){var c=new Error('The script "'.concat(r,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return s(c)}})})}function S(e){return window[e]}function C(e,t){if(typeof e!="object"||e===null)throw new Error("Expected an options object.");var r=e.environment;if(r&&r!=="production"&&r!=="sandbox")throw new Error('The `environment` option must be either "production" or "sandbox".');if(typeof t<"u"&&typeof t!="function")throw new Error("Expected PromisePonyfill to be a function.")}function H({productId:e,priceId:t}){var w,j,E;const{data:r}=O($.products.index()),n=b.useRef(!1),a=b.useRef(!1),[s,c]=b.useState(!1),i=b.useRef(null),{base_url:d,billing:o}=k(),p=(w=o==null?void 0:o.stripe)==null?void 0:w.enable,l=(j=o==null?void 0:o.paypal)==null?void 0:j.enable,m=(E=o==null?void 0:o.paypal)==null?void 0:E.public_key;return b.useEffect(()=>{!l||!m||n.current||(D({clientId:m,intent:"subscription",vault:!0,disableFunding:p?"card":void 0}).then(()=>{c(!0)}),n.current=!0)},[m,l,p]),b.useEffect(()=>{var g;if(!s||!((g=window.paypal)!=null&&g.Buttons)||!i.current||!(r!=null&&r.products.length)||!e||!t||a.current)return;const h=r.products.find(f=>f.id===parseInt(e)),v=h==null?void 0:h.prices.find(f=>f.id===parseInt(t));window.paypal.Buttons({style:{label:"pay"},createSubscription:(f,x)=>x.subscription.create({application_context:{shipping_preference:"NO_SHIPPING",return_url:`${d}/checkout/${e}/${t}/paypal/done?subscriptionId=${f.subscriptionID}&status=success`,cancel_url:`${d}/checkout/${e}/${t}/paypal/done?status=error`},plan_id:v==null?void 0:v.paypal_id}),onApprove:(f,x)=>(x.redirect(`${d}/checkout/${e}/${t}/paypal/done?subscriptionId=${f.subscriptionID}&status=success`),Promise.resolve()),onError:f=>{location.href=`${d}/checkout/${e}/${t}/paypal/done?status=error`}}).render(i.current).then(()=>{a.current=!0})},[e,t,r,s,d]),{paypalElementRef:i,stripeIsEnabled:m!=null&&l}}function ee(){var o,p;const{productId:e,priceId:t}=_(),r=O($.products.index()),{paypalElementRef:n}=H({productId:e,priceId:t}),{base_url:a,billing:s}=k();if(r.isLoading)return u.jsx(N,{screen:!0});const c=(o=r.data)==null?void 0:o.products.find(l=>l.id===parseInt(e)),i=c==null?void 0:c.prices.find(l=>l.id===parseInt(t));if(!c||!i||r.status==="error")return u.jsx(B,{to:"/pricing",replace:!0});const d=c.trial_period_days>0?"confirmSetup":"confirmPayment";return u.jsxs(L,{children:[u.jsxs(b.Fragment,{children:[u.jsx("h1",{className:"mb-40 text-4xl",children:u.jsx(y,{message:"Checkout"})}),(p=s==null?void 0:s.stripe)!=null&&p.enable?u.jsxs(b.Fragment,{children:[u.jsx(A,{productId:e,priceId:t,submitLabel:u.jsx(y,{message:"Upgrade"}),confirmType:d,createType:"subscription",returnUrl:`${a}/checkout/${e}/${t}/stripe/done`}),u.jsx(Y,{})]}):null,u.jsx("div",{ref:n}),u.jsx("div",{className:"mt-30 text-xs text-muted",children:u.jsx(y,{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."})})]}),u.jsx(q,{})]})}function Y(){return u.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:u.jsx("span",{className:"relative z-10 bg px-10 text-sm text-muted",children:u.jsx(y,{message:"or"})})})}export{ee as Component};
