1import{r as p,j as e}from"./index-LqF_JRUD.js";import{n as U,j as B,N as b,h as j,i as x}from"./DeferredCookieConsent-GwdtbJai.js";import{N}from"./Navbar-INkxDoXP.js";import{F as _}from"./Footer-CTw3uNBj.js";import{S as O}from"./SEOHead-g9vh2FTn.js";import{B as q}from"./badge-DfPF_uwz.js";import{u as M}from"./useAuth-CkZNo3-B.js";import{supabase as k}from"./client-tp27EgSx.js";import{i as v,P as y,a as F,f as d,b as R}from"./products-jx3Kero3.js";import{d as V,e as z}from"./userBilling-CfNf-CNa.js";import{L as D}from"./loader-circle-DWFn7h2S.js";import{A as G}from"./arrow-left-DoGtFKzG.js";import{S as H}from"./sparkles-HskBJKAr.js";import{C as u}from"./circle-check-D4E8b2Eb.js";import"./index-iODRMH4i.js";import"./index-DCeA7YNM.js";import"./Combination-CGw6uTfk.js";import"./tslib.es6-eMSY344_.js";import"./chevron-right-CSKCxRua.js";import"./BrandLogo-epMdlG6C.js";import"./proxy--z2qpjbr.js";import"./file-search-3lg8PUPs.js";import"./x-DiMe68w_.js";import"./globe-BcxkUaSw.js";const he=()=>{const{id:l}=U(),{user:c,loading:w}=M(),g=B(),[a,P]=p.useState(null),[A,$]=p.useState(!0),[i,C]=p.useState(0);if(p.useEffect(()=>{!c||!l||(async()=>{const{data:s}=await k.from("visa_plans").select("id, country_name, purpose_label, package_type, selected_plan, plan_paid, purchased_addons").eq("id",l).eq("user_id",c.id).maybeSingle();P(s??null);const{data:t}=await k.from("orders").select("id, package_type, total_amount, order_items(item_type, total_amount)").eq("visa_plan_id",l).eq("status","paid");let o=0;(t??[]).forEach(n=>{const m=(n.order_items??[]).find(L=>L.item_type==="package");m!=null&&m.total_amount?o+=Number(m.total_amount):n.package_type&&n.total_amount&&(o+=Number(n.total_amount))}),C(Math.round(o/100)),$(!1)})()},[c,l]),w||A)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(D,{className:"h-6 w-6 animate-spin text-gold"})});if(!c)return e.jsx(b,{to:"/login",replace:!0});if(!a)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(N,{}),e.jsxs("div",{className:"container mx-auto max-w-2xl px-4 pt-28 pb-16 text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold mb-3",children:"Plan not found"}),e.jsx(j,{to:"/dashboard",children:e.jsx(x,{variant:"outline",children:"Back to dashboard"})})]}),e.jsx(_,{})]});if(!a.plan_paid)return e.jsx(b,{to:`/choose-plan?plan_id=${a.id}`,replace:!0});const r=v(a.package_type)?a.package_type:v(a.selected_plan)?a.selected_plan:null,h=V(r),f=z(r,a.purchased_addons),S=s=>{const t=i>0?`&paid=${i}`:"";g(`/choose-plan?package=${s}&plan_id=${a.id}&upgrade=1&from=${r??""}${t}`)},E=s=>{g(`/choose-plan?package=${r??"basic"}&plan_id=${a.id}&addon=${s}&addon_only=1`)};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(O,{title:"Upgrade your plan â HelpMyVisa",description:"Upgrade your package or add an add-on.",noindex:!0}),e.jsx(N,{}),e.jsx("main",{className:"pt-24 pb-16 px-4",children:e.jsxs("div",{className:"container mx-auto max-w-3xl",children:[e.jsx(j,{to:`/visa-plan/${a.id}`,children:e.jsxs(x,{variant:"ghost",size:"sm",className:"mb-4",children:[e.jsx(G,{className:"mr-2 h-4 w-4"})," Back to plan"]})}),e.jsxs("header",{className:"mb-8",children:[e.jsxs("p",{className:"text-xs uppercase tracking-[0.18em] text-muted-foreground mb-2",children:[a.country_name??"France"," · ",a.purpose_label??"Visa"]}),e.jsx("h1",{className:"font-display text-2xl sm:text-3xl font-semibold tracking-tight text-foreground",children:"Upgrade or add to your plan"}),e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 bg-secondary border border-border rounded-full px-3 py-1 text-xs",children:[e.jsx(H,{className:"h-3 w-3 text-gold"}),e.jsx("span",{className:"text-muted-foreground",children:"Current package:"}),e.jsx("span",{className:"font-semibold text-foreground",children:r?y[r]:"â"})]})]}),e.jsxs("section",{className:"mb-10",children:[e.jsx("h2",{className:"text-sm font-semibold uppercase tracking-wider text-foreground mb-3",children:"Upgrade options"}),h.length===0?e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6 text-center",children:[e.jsx(u,{className:"h-6 w-6 text-success mx-auto mb-2"}),e.jsx("p",{className:"font-medium text-foreground",children:"You're on our top tier"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[r?y[r]:""," includes everything we currently offer."]})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:h.map(s=>{const t=F[s.target],o=Math.max(0,t.price-i);return e.jsxs("div",{className:"bg-card border border-border rounded-xl p-5 flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:t.name}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-display text-lg font-bold",children:d(o)}),i>0&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[d(t.price)," â ",d(i)," credit"]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t.tagline}),e.jsx("ul",{className:"space-y-1 mb-4 flex-1",children:t.features.slice(0,4).map(n=>e.jsxs("li",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(u,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:n})]},n))}),e.jsxs(x,{onClick:()=>S(s.target),className:"bg-gold text-gold-foreground hover:bg-gold/90",children:["Upgrade to ",t.name,o<t.price?` · ${d(o)}`:""]})]},s.target)})})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-sm font-semibold uppercase tracking-wider text-foreground mb-3",children:"Add-ons"}),f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No add-ons available for this package."}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:f.map(s=>e.jsxs("div",{className:`rounded-xl border p-4 ${s.owned?"border-success/30 bg-success/[0.02]":"border-border bg-card"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-1",children:[e.jsx("h3",{className:"font-semibold text-sm text-foreground",children:s.name}),s.owned?e.jsxs(q,{variant:"secondary",className:"text-[10px] uppercase",children:[e.jsx(u,{className:"h-3 w-3 mr-1"})," Included"]}):e.jsx("span",{className:"text-sm font-bold text-foreground",children:d(s.price)})]}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed mb-3",children:s.description}),!s.owned&&e.jsxs(x,{size:"sm",variant:"outline",className:"w-full",onClick:()=>E(s.id),children:["Add for ",d(s.price)]})]},s.id))})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground text-center mt-12 max-w-2xl mx-auto leading-relaxed",children:R})]})}),e.jsx(_,{})]})};export{he 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.