1import{a as U,u as I,d as Y,U as F,r as c,a3 as q,j as e,R as V,a4 as W,i as C,C as z,k as m,t as M,a5 as G}from"./index-C-wrOxxP.js";import{S as K,i as P}from"./StripeEmbeddedCheckout-sHawDsuG.js";import{A as Q}from"./arrow-left-nXWMOcUk.js";import"./billingPending-By8APS3H.js";const J=[{id:"solo",name:"Solo Host",price:"$29",period:"/month",featured:!0,features:["3-day free trial included","Full personalized dashboard","Live weather + traffic","Format-aware Quick Grabs","Hot Keys + Show Stack","Cancel anytime before day 3 â no charge"],cta:"Start 3-day trial"},{id:"multi_market",name:"Multi-Market Host",price:"$49",period:"/month",features:["Everything in Solo Host","Multiple station profiles","Switch markets in one click","Built for voicetrackers","Cancel anytime"],cta:"Choose Multi-Market"},{id:"host_producer",name:"Host + Producer",price:"$59",period:"/month",features:["Everything in Solo Host","2 seats â host + invited producer","Shared Show Stack & priorities","Producer notes on every item","3-day free trial included"],cta:"Start 3-day trial"},{id:"station",name:"Full Station",price:"$199",period:"/month",features:["Everything in Host + Producer","Up to 10 hosts, unlimited producers","Station Hub admin dashboard","Task management & scheduling","AI show planning (10/day)","Station-wide content distribution"],cta:"Choose Full Station"}],E={solo:"solo_monthly",multi_market:"multi_market_monthly",host_producer:"host_producer_monthly",station:"station_monthly"},re=()=>{var N,S;const{user:g,plan:r,isPaid:b,entitlement:$,refreshPlan:R}=U(),{profile:A}=I(),{markets:n,maxMarkets:y}=Y(),k=((N=A.name)==null?void 0:N.trim().split(/\s+/)[0])||(((S=g==null?void 0:g.email)==null?void 0:S.split("@")[0])??""),u=F(),[l,p]=c.useState(null),[h,B]=c.useState(null),[w,j]=c.useState(null),v=c.useRef(null),d=q(r),x=b||$==="trialing",f=(r==null?void 0:r.price_id)==="multi_market_monthly"&&n.length>1,H=async t=>{const a=G((r==null?void 0:r.price_id)??null,t),s=(r==null?void 0:r.status)==="trialing";if(!(a&&s&&!window.confirm("Upgrading ends your free trial immediately and charges the new plan rate today. Continue?"))){p("swap");try{const{data:o,error:i}=await P("billing-swap-plan",{price_id:t});if(i)throw i;if(o!=null&&o.error)throw new Error(o.error);m.success("Plan updated",{description:a&&s?"Trial ended and your new plan is active.":"Prorated charge applied."}),await R()}catch(o){const i=o instanceof Error?o.message:"";i.includes("upgrade_payment_required")?m.error("Payment required",{description:"We couldn't charge your card for the upgrade. Update your payment method in Manage billing."}):i.includes("downgrade_requires_market_cleanup")?m.error("Delete extra markets first",{description:`Remove ${n.length-1} market(s) on the Markets page before downgrading to Solo.`,action:{label:"Manage markets",onClick:()=>u("/markets")}}):M(o,"Could not change plan")}finally{p(null)}}},L=t=>{if(t==="solo"&&f){m.error("Delete extra markets first",{description:`You have ${n.length} markets. Solo Host supports 1. Remove ${n.length-1} on the Markets page before downgrading.`,action:{label:"Manage markets",onClick:()=>u("/markets")}});return}const a=E[t];if(a){if(d&&(r==null?void 0:r.price_id)===a){m("You're already on this plan");return}if(d){H(a);return}j(null),B(a)}};c.useEffect(()=>{var t;h&&((t=v.current)==null||t.scrollIntoView({behavior:"smooth",block:"start"}))},[h]);const T=async()=>{p("portal");try{const{data:t,error:a}=await P("billing-portal",{return_url:`${window.location.origin}/billing`});if(a)throw a;const s=t==null?void 0:t.url;if(s)window.open(s,"_blank");else throw new Error("No portal URL returned.")}catch(t){M(t,"Could not open billing portal")}finally{p(null)}};return e.jsxs("div",{className:"relative min-h-screen",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{background:"var(--gradient-glow)"}}),e.jsxs("div",{className:"relative mx-auto max-w-6xl px-6 py-10",children:[e.jsxs("button",{onClick:()=>x&&u("/"),disabled:!x,title:x?"Back to cockpit":"Subscribe or start your trial to access the cockpit",className:"label-mono flex items-center gap-2 text-muted-foreground hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40",children:[e.jsx(Q,{className:"h-3 w-3"})," Back to cockpit"]}),e.jsxs("div",{className:"mt-8 flex items-center gap-3",children:[e.jsx("div",{className:"grid h-10 w-10 place-items-center rounded-sm bg-primary text-primary-foreground",children:e.jsx(V,{className:"h-5 w-5",strokeWidth:2.5})}),e.jsxs("div",{children:[e.jsx("div",{className:"label-mono text-primary",children:"Plans & Billing"}),e.jsxs("div",{className:"font-display text-3xl font-semibold tracking-tight",children:["Pick your plan",k?`, ${k}`:""]})]})]}),r&&e.jsx("div",{className:"mt-6 panel p-4",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("span",{className:"label-mono text-muted-foreground",children:"Current"}),e.jsx("span",{className:"pill text-primary",children:W(r.plan)}),e.jsx("span",{className:"label-mono text-muted-foreground",children:r.status}),r.trial_end&&r.status==="trialing"&&e.jsxs("span",{className:"label-mono text-muted-foreground",children:["trial ends ",new Date(r.trial_end).toLocaleDateString()]}),b&&e.jsx("span",{className:"pill text-status-good",children:"ACTIVE"}),r.stripe_customer_id&&e.jsx("button",{onClick:T,disabled:l==="portal",className:"ml-auto rounded-sm border border-border px-3 py-1.5 font-mono text-xs hover:bg-surface-2 disabled:opacity-50",children:l==="portal"?e.jsx(C,{className:"h-3 w-3 animate-spin"}):"Manage billing â"})]})}),e.jsxs("div",{className:"mt-4 panel p-4 flex flex-wrap items-center gap-3",children:[e.jsx("span",{className:"label-mono text-muted-foreground",children:"Markets"}),e.jsxs("span",{className:"font-mono text-sm",children:[n.length," of ",y," used"]}),y===1&&e.jsx("span",{className:"label-mono text-muted-foreground ml-2",children:"Upgrade to Multi-Market for up to 3 station profiles"}),f&&e.jsxs("span",{className:"label-mono text-status-warn ml-2",children:["Delete ",n.length-1," market",n.length-1===1?"":"s"," before downgrading to Solo"]}),e.jsx("button",{onClick:()=>u("/markets"),className:"ml-auto rounded-sm border border-border px-3 py-1.5 font-mono text-xs hover:bg-surface-2",children:"Manage markets â"})]}),e.jsx("div",{className:"mt-8 grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:J.map(t=>{const a=E[t.id],s=d&&(r==null?void 0:r.price_id)===a,o=d&&!s&&!!a,i=t.id==="solo"&&f,D=l==="swap"&&o?null:s?"Current plan":i?"Delete extras first":o?`Switch to ${t.name}`:t.cta;return e.jsxs("article",{className:`panel p-6 ${t.featured?"border-primary/60 shadow-[var(--shadow-glow)]":""} ${s?"ring-1 ring-status-good/60":""}`,children:[s&&e.jsx("div",{className:"label-mono mb-2 text-status-good",children:"Current plan"}),!s&&t.featured&&e.jsx("div",{className:"label-mono mb-2 text-primary",children:"Recommended"}),e.jsx("div",{className:"font-display text-2xl font-semibold",children:t.name}),e.jsxs("div",{className:"mt-2 flex items-baseline gap-1",children:[e.jsx("span",{className:"font-display text-4xl font-semibold text-primary",children:t.price}),e.jsx("span",{className:"label-mono text-muted-foreground",children:t.period})]}),e.jsx("ul",{className:"mt-5 space-y-2",children:t.features.map(_=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-foreground
1/90",children:[e.jsx(z,{className:"mt-0.5 h-4 w-4 shrink-0 text-status-good"}),e.jsx("span",{children:_})]},_))}),e.jsx("button",{onClick:()=>L(t.id),disabled:s||l==="swap"||i,title:i?`Delete ${n.length-1} market(s) first`:void 0,className:`mt-6 w-full rounded-sm px-4 py-2.5 font-mono text-sm transition-all disabled:opacity-50 ${t.featured&&!s?"bg-primary text-primary-foreground hover:shadow-[var(--shadow-glow)]":"border border-border hover:bg-surface-2"}`,children:l==="swap"&&o?e.jsx(C,{className:"mx-auto h-4 w-4 animate-spin"}):D})]},t.id)})}),h&&!d&&e.jsxs("div",{ref:v,className:"mt-8 scroll-mt-8",children:[e.jsx("div",{className:"mb-3 label-mono text-primary",children:"Step 2 â Add payment method"}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:w===!1?"Your card will be charged today when you confirm. (Trial already used on this account.)":w===!0?"Your card secures your 3-day trial. You won't be charged until the trial ends.":"Add a payment method to start your subscription."}),e.jsx(K,{priceId:h,returnUrl:`${window.location.origin}/billing/return`,onTrialEligible:j})]})]})]})};export{re 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.