1import{a as e,n as t,t as n}from"./jsx-runtime-n5LQ9ujS.js";import{t as r}from"./useRouterState-C8U2cQLW.js";import{H as i,_ as a,et as o}from"./projectClient-DSpn95Y8.js";import{t as s}from"./createLucideIcon-DN0J77WO.js";import{t as c}from"./credit-card-CWU7I3TW.js";import{a as l,c as u,gn as d,hn as f}from"./index-DF6fCh7W.js";var p=s(`wallet-cards`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2`,key:`4125el`}],[`path`,{d:`M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21`,key:`1dpki6`}]]),m=e(t()),h=n(),g=`/app/auth-callback`;function _(){return r({select:e=>e.location.pathname})===`/app`?(0,h.jsx)(v,{}):(0,h.jsx)(f,{})}function v(){let e=d(),t=o.useSession(),n=(0,m.useRef)(!1),r=(0,m.useRef)(!1),[s,u]=(0,m.useState)(null),[f,g]=(0,m.useState)(null),[_,v]=(0,m.useState)(!1),[S,O]=(0,m.useState)(``);(0,m.useEffect)(()=>{fetch(`/api/auth-status`).then(e=>e.json()).then(e=>u(e)).catch(()=>{O(`Could not read the auth setup status. Try again in a moment.`)})},[]),(0,m.useEffect)(()=>{if(t.isPending)return;let o=t.data?.user;if(!o)return;let s=i({email:o.email,id:o.id,image:o.image,name:o.name}),c=b(),l=C();if(l){if(n.current||r.current)return;r.current=!0,v(!0),O(`Loading secure payment options...`),w(l).then(e=>{let t=e.providers??[];if(g(e),t.length===1)return n.current=!0,O(`Opening secure checkout...`),T(l,c,t[0].id);v(!1),O(``)}).catch(e=>{n.current=!1,r.current=!1,v(!1),O(e instanceof Error?e.message:`Could not load payment options. Try again.`)});return}if(c){window.location.assign(c);return}(async()=>{try{if((await a(o.id)).length>0){e({to:`/dashboard/projects`});return}}catch{if(s.onboardingCompleted){e({to:`/dashboard/projects`});return}}e({to:`/app/onboarding`})})()},[e,t.data?.user?.email,t.data?.user?.id,t.data?.user?.image,t.data?.user?.name,t.isPending]);async function k(){if(s?.google_enabled===!1){O(`Google OAuth is not configured yet. Add GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET first.`);return}v(!0),O(``);let e=b(),t=x();await o.signIn.social({callbackURL:t,errorCallbackURL:l(e),provider:`google`},{onError(e){v(!1),O(e.error.message||`Google sign-in failed. Try again.`)},onRequest(){v(!0)},onResponse(){v(!1)}})}async function A(e){let t=C();if(!(!t||n.current)){n.current=!0,v(!0),O(`Opening secure checkout...`);try{await T(t,b(),e)}catch(e){n.current=!1,v(!1),O(e instanceof Error?e.message:`Could not open checkout. Try again.`)}}}let j=y(`auth_error`),M=C(),N=!!(t.data?.user&&M),P=s?.google_enabled===!1,F=_||t.isPending||P,I=t.isPending?`Checking your session...`:t.data?.user?`Signed in as ${t.data.user.email||t.data.user.name}`:``;return(0,h.jsx)(`main`,{className:`min-h-screen bg-[#FAF8F5] text-[#2B2622]`,children:(0,h.jsx)(`section`,{className:`flex min-h-screen items-center justify-center px-4 py-10`,children:(0,h.jsxs)(`div`,{className:`w-full max-w-[520px]`,children:[(0,h.jsxs)(`a`,{className:`mx-auto flex w-fit items-center gap-4`,href:`/`,children:[(0,h.jsx)(`span`,{className:`flex h-14 w-14 items-center justify-center rounded-lg bg-[#F2542D] text-xl font-extrabold text-white shadow-sm shadow-orange-200/70`,children:`W`}),(0,h.jsx)(`span`,{className:`text-3xl font-extrabold tracking-normal text-[#2B2622]`,children:`WhereToPost`})]}),(0,h.jsxs)(`div`,{className:`mt-10 rounded-lg border border-[#E6DFD8] bg-white px-8 py-10 shadow-sm shadow-stone-200/70 sm:px-10`,children:[(0,h.jsx)(`h1`,{className:`text-center text-3xl font-extrabold tracking-normal text-[#2B2622]`,children:N?`Choose how to pay`:`Sign in`}),N&&f?.product?(0,h.jsxs)(`p`,{className:`mt-3 text-center text-sm leading-6 text-[#6B635C]`,children:[f.product.name,` · `,E(f.product.amount_cents,f.product.currency)]}):null,!N&&j?(0,h.jsx)(`p`,{className:`mt-6 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm leading-6 text-red-700`,children:`Google sign-in did not finish. Try again or check the OAuth callback URL.`}):null,S?(0,h.jsx)(`p`,{className:`mt-6 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm leading-6 text-amber-800`,children:S}):null,!N&&P?(0,h.jsxs)(`div`,{className:`mt-6 rounded-lg border border-[#
1E6DFD8] bg-[#FAF8F5] px-4 py-3 text-xs leading-5 text-[#6B635C]`,children:[`Add `,(0,h.jsx)(`strong`,{children:`GOOGLE_CLIENT_ID`}),`, `,(0,h.jsx)(`strong`,{children:`GOOGLE_CLIENT_SECRET`}),`,`,(0,h.jsx)(`strong`,{children:` BETTER_AUTH_SECRET`}),`, and optionally `,(0,h.jsx)(`strong`,{children:`BETTER_AUTH_URL`}),`. Google callback path: `,(0,h.jsx)(`strong`,{children:`/api/auth/callback/google`}),`.`]}):null,N?(0,h.jsxs)(`div`,{className:`mt-8 space-y-3`,children:[(f?.providers??[]).map(e=>(0,h.jsxs)(`button`,{className:`flex min-h-20 w-full items-center gap-4 rounded-lg border border-[#D5D0C9] bg-white px-4 py-3 text-left transition hover:border-[#F2542D] hover:bg-[#FFF7F3] focus:outline-none focus:ring-2 focus:ring-[#FBD9CC] disabled:cursor-not-allowed disabled:opacity-60`,disabled:_,onClick:()=>void A(e.id),type:`button`,children:[(0,h.jsx)(`span`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-[#FFF0EA] text-[#D8431F]`,children:(0,h.jsx)(e.id===`creem`?c:p,{"aria-hidden":`true`,className:`h-5 w-5`})}),(0,h.jsxs)(`span`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`block font-bold text-[#2B2622]`,children:e.label}),(0,h.jsxs)(`span`,{className:`mt-1 block text-sm leading-5 text-[#6B635C]`,children:[e.description,` · `,e.providerName]})]})]},e.id)),!_&&f?.providers?.length===0?(0,h.jsx)(`button`,{className:`inline-flex min-h-11 w-full items-center justify-center rounded-lg border border-[#D5D0C9] bg-white px-4 py-3 font-bold`,onClick:()=>window.location.reload(),type:`button`,children:`Try again`}):null,(0,h.jsx)(`p`,{className:`pt-2 text-center text-xs leading-5 text-[#8B8178]`,children:`Available methods can vary by location, device, and plan. Your order remains tied to the checkout provider you choose.`})]}
1):(0,h.jsxs)(`button`,{className:`mt-8 inline-flex min-h-12 w-full items-center justify-center gap-3 rounded-lg border border-[#D5D0C9] bg-white px-4 py-3 text-base font-bold text-[#2B2622] shadow-sm shadow-stone-200/60 transition hover:border-[#F2542D] hover:bg-[#FFF7F3] focus:outline-none focus:ring-2 focus:ring-[#FBD9CC] disabled:cursor-not-allowed disabled:opacity-60`,disabled:F,onClick:k,type:`button`,children:[(0,h.jsx)(D,{}),`Continue with Google`]}),I?(0,h.jsx)(`p`,{className:`mt-4 text-center text-sm leading-6 text-[#6B635C]`,children:I}):null,(0,h.jsxs)(`p`,{className:`mt-8 text-center text-sm leading-6 text-[#8B8178]`,children:[`By continuing, you agree to our`,` `,(0,h.jsx)(`a`,{className:`font-semibold text-[#D8431F] hover:text-[#B93618]`,href:`/terms`,children:`Terms`}),` `,`and`,` `,(0,h.jsx)(`a`,{className:`font-semibold text-[#D8431F] hover:text-[#B93618]`,href:`/privacy`,children:`Privacy Policy`}),`.`]})]})]})})})}function y(e){return typeof window>`u`?``:new URLSearchParams(window.location.search).get(e)??``}function b(){return u(y(`callbackUrl`),window.location.origin)}function x(){let e=C(),t=b();if(!e)return t??S();let n=new URLSearchParams({plan:e});return t&&n.set(`callbackUrl`,t),`/app?${n.toString()}`}function S(){return g}function C(){let e=y(`plan`);return e===`wheretopost_monthly`||e===`wheretopost_lifetime`?e:null}async function w(e){let t=await fetch(`/api/payment/checkout?product_id=${encodeURIComponent(e)}`,{credentials:`include`}),n=await t.json().catch(()=>null);if(!t.ok||n?.ok===!1||!n?.product||!n.providers||n.providers.length===0)throw Error(n?.message??`Could not load payment options. Try again.`);return n}async function T(e,t,n){let r=await fetch(`/api/payment/checkout`,{body:JSON.stringify({provider:n,product_id:e,return_path:t??`/dashboard/projects`}),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}),i=await r.json().catch(()=>null);if(!r.ok||i?.ok===!1||!i?.checkout_url){if(i?.billing_url===`/payment/billing`){window.location.assign(i.billing_url);return}throw Error(i?.message??`Could not open checkout. Try again.`)}let a=new URL(i.checkout_url);if(a.protocol!==`https:`)throw Error(`Checkout returned an invalid URL.`);window.location.assign(a.toString())}function E(e,t){return new Intl.NumberFormat(`en-US`,{currency:t,maximumFractionDigits:0,style:`currency`}).format(e/100)}function D(){return(0,h.jsxs)(`svg`,{"aria-hidden":`true`,className:`h-5 w-5`,viewBox:`0 0 24 24`,children:[(0,h.jsx)(`path`,{d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`,fill:`#4285F4`}),(0,h.jsx)(`path`,{d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`,fill:`#34A853`}),(0,h.jsx)(`path`,{d:`M5.84 14.1c-.22-.66-.35-1.36-.35-2.1s.13-1.44.35-2.1V7.06H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.94l3.66-2.84z`,fill:`#FBBC05`}),(0,h.jsx)(`path`,{d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.06L5.84 9.9C6.71 7.3 9.14 5.38 12 5.38z`,fill:`#EA4335`})]})}export{_ as component};
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.