1import{b,a as C,aG as k,u as S,r as c,W as h,j as e,C as A,g as B,S as g,B as E,l as O,O as j,h as i,c as m,o as N,ah as x}from"./main-DX7XzkoU.js";import{C as v}from"./circle-check-DRpR_UoF.js";import{C as F}from"./circle-x-ys4HOCgl.js";const P="F3WJ62U",J=()=>{const{t:s}=b(),l=C(),{codigo:n}=k(),{user:o}=S(),[_,a]=c.useState("loading"),[p,u]=c.useState(!1),f=c.useCallback(async()=>{if(n!==P){a("invalid");return}if(!o)return;const{data:r,error:d}=await h.from("subscribers").select("metadata").eq("user_id",o.id).maybeSingle();if(d){a("new");return}const t=(r==null?void 0:r.metadata)??{};t.promo_fulfilled_at?a("fulfilled"):t.promo_activated_at?a("activated"):a("new")},[n,o]);c.useEffect(()=>{f()},[f]);const w=async()=>{u(!0);try{const{data:r,error:d}=await h.rpc("activate_promo",{p_code:n}),t=r;if(d||!(t!=null&&t.success)){if((t==null?void 0:t.reason)==="invalid_code"){a("invalid");return}x.error(s("promo.error"));return}x.success(s("promo.activated_toast")),l("/pricing?promo=1")}catch{x.error(s("promo.error"))}finally{u(!1)}},y=()=>{switch(_){case"loading":return e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8",children:[e.jsx(N,{className:"w-8 h-8 animate-spin text-primary"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:s("promo.loading")})]});case"invalid":return e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx(F,{className:"w-12 h-12 text-destructive"}),e.jsx(i,{children:s("promo.invalid_title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:s("promo.invalid_desc")})]});case"fulfilled":return e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx(v,{className:"w-12 h-12 text-green-500"}),e.jsx(i,{children:s("promo.fulfilled_title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:s("promo.fulfilled_desc")}),e.jsx(m,{onClick:()=>l("/dashboard"),className:"mt-2",children:s("promo.go_to_dashboard")})]});case"activated":return e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx(v,{className:"w-12 h-12 text-green-500"}),e.jsx(i,{children:s("promo.ready_title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:s("promo.ready_desc")}),e.jsxs(m,{onClick:()=>l("/pricing?promo=1"),className:"mt-2 gap-2",children:[e.jsx(g,{className:"w-4 h-4"}),s("promo.go_to_plans")]})]});case"new":default:return e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(j,{className:"w-8 h-8 text-primary"})}),e.jsx(i,{children:s("promo.activate_title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:s("promo.activate_desc")}),e.jsx(m,{onClick:w,disabled:p,size:"lg",className:"mt-2 gap-2",children:p?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"w-4 h-4 animate-spin"}),s("promo.activating")]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{className:"w-4 h-4"}),s("promo.activate_button")]})})]})}};return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-background via-background to-muted/20 flex items-center justify-center px-4",children:e.jsxs(A,{className:"w-full max-w-md",children:[e.jsxs(B,{className:"flex flex-row items-center justify-center gap-2 pb-2",children:[e.jsx("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center",children:e.jsx(g,{className:"w-5 h-5 text-white"})}),e.jsx("span",{className:"font-bold text-lg",children:E.name})]}),e.jsx(O,{children:y()})]})})};export{J 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.