1import{j as e,m as i}from"./vendor-motion-BYx9M_6m.js";import{r,L as E,k as F,N as f}from"./vendor-react-Dro-kgxR.js";import{ap as L,aq as y}from"./index-4zi2R0vs.js";import"./vendor-__icons_-BC95nk_U.js";import"./vendor-gsap-D3jsOSc0.js";const P=y.SUPABASE.URL,_=y.SUPABASE.ANON_KEY,b=L(P,_);async function g(t,s){if(t&&t.context&&typeof t.context.json=="function")try{const n=await t.context.clone().json();if(n&&n.message)return n.message}catch{}return(t==null?void 0:t.message)||s}const j={async checkOnboardingStatus(t){const{data:s,error:n}=await b.functions.invoke(`tappn_edge_server/payout-method/onboarding/check-status?provider_account_id=${encodeURIComponent(t)}`,{method:"GET"});if(n){console.error("[PayoutOnboarding] Check status error:",n);const a=await g(n,"Failed to check onboarding status");throw new Error(a)}if((s==null?void 0:s.success)===!1)throw new Error(s.message||"Failed to check onboarding status");return s.data},async reconnect(t){const{data:s,error:n}=await b.functions.invoke(`tappn_edge_server/payout-method/onboarding/reconnect?provider_account_id=${encodeURIComponent(t)}`,{method:"GET"});if(n){console.error("[PayoutOnboarding] Reconnect error:",n);const a=await g(n,"Failed to regenerate onboarding link");throw new Error(a)}if((s==null?void 0:s.success)===!1)throw new Error(s.message||"Failed to regenerate onboarding link");return s.data}};function B(t){const[s,n]=r.useState("loading"),[a,o]=r.useState(null),[x,l]=r.useState(null),c=r.useCallback(async()=>{if(!t){n("error"),l("Missing provider account ID");return}n("loading"),l(null);try{const d=await j.checkOnboardingStatus(t);o(d),n("success")}catch(d){n("error"),l(d.message||"Failed to check status")}},[t]);return r.useEffect(()=>{c()},[c]),{state:s,status:a,error:x,isLoading:s==="loading",refetch:c}}const u=({className:t=""})=>e.jsx("div",{className:`animate-pulse bg-white/5 rounded ${t}`}),w=({className:t=""})=>e.jsx("div",{className:`animate-pulse bg-white/5 rounded-2xl border border-white/5 ${t}`});function R(){return e.jsxs("div",{className:"min-h-screen bg-[#030303] relative overflow-hidden",children:[e.jsxs("div",{className:"fixed inset-0 overflow-hidden pointer-events-none z-0",children:[e.jsx(i.div,{animate:{scale:[1,1.2,1],opacity:[.1,.15,.1]},transition:{duration:10,repeat:1/0},className:"absolute -top-[10%] -left-[10%] w-[80%] h-[80%] bg-[#F83253] blur-[150px] rounded-full"}),e.jsx(i.div,{animate:{scale:[1,1.1,1],opacity:[.1,.12,.1]},transition:{duration:12,repeat:1/0},className:"absolute bottom-[-10%] right-[-10%] w-[80%] h-[80%] bg-[#BD30F4] blur-[150px] rounded-full"})]}),e.jsx("div",{className:"relative z-10 min-h-screen flex flex-col items-center justify-center px-4 py-8",children:e.jsxs("div",{className:"w-full max-w-[400px] flex flex-col items-center gap-6",children:[e.jsx(w,{className:"w-16 h-16"}),e.jsx(u,{className:"w-48 h-8"}),e.jsx(u,{className:"w-64 h-5"}),e.jsx(u,{className:"w-56 h-5"}),e.jsx(w,{className:"w-full h-12"}),e.jsx(u,{className:"w-32 h-4"})]})})]})}function I({status:t,onCompleteSetup:s,isReconnecting:n,reconnectError:a}){const o=t.status==="ACTIVE";return e.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[e.jsx(i.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:200,damping:15},className:`w-16 h-16 rounded-full flex items-center justify-center ${o?"bg-green-500/20 border-2 border-green-500":"bg-yellow-500/20 border-2 border-yellow-500"}`,children:o?e.jsx("svg",{className:"w-8 h-8 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("svg",{className:"w-8 h-8 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:o?"Payout Setup Complete!":"Payout Setup Incomplete"}),e.jsx("p",{className:"text-white/60 text-sm max-w-sm",children:o?"Your payout method is now active. You can receive tips directly to your bank account.":"Stripe onboarding is not yet complete. Complete the setup to receive payouts."})]}),e.jsxs(i.div,{initial:{opacity:0,y:10}
1,animate:{opacity:1,y:0},transition:{delay:.2},className:"w-full p-4 bg-white/[0.04] backdrop-blur-xl border border-white/10 rounded-2xl space-y-3",children:[e.jsx("p",{className:"text-white/40 text-[10px] uppercase tracking-widest font-bold",children:"Account Status"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-white/40",children:"Status"}),e.jsx("p",{className:`font-semibold ${o?"text-green-400":"text-yellow-400"}`,children:t.status})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white/40",children:"Charges"}),e.jsx("p",{className:`font-semibold ${t.chargesEnabled?"text-green-400":"text-red-400"}`,children:t.chargesEnabled?"Enabled":"Disabled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white/40",children:"Payouts"}),e.jsx("p",{className:`font-semibold ${t.payoutsEnabled?"text-green-400":"text-red-400"}`,children:t.payoutsEnabled?"Enabled":"Disabled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white/40",children:"Onboarding"}),e.jsx("p",{className:`font-semibold ${t.onboardingComplete?"text-green-400":"text-yellow-400"}`,children:t.onboardingComplete?"Complete":"Pending"})]})]})]}),e.jsx(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3},className:"flex flex-col gap-3 w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(E,{to:"/",className:"w-full py-3 px-6 bg-gradient-to-r from-[#F83253] to-[#BD30F4] rounded-full font-semibold text-white text-sm text-center",children:"Go to Home"}),e.jsx("button",{onClick:()=>window.close(),className:"w-full py-3 px-6 bg-white/5 border border-white/10 rounded-full font-semibold text-white/60 text-sm hover:bg-white/10 transition-colors",children:"Close Window"})]}):e.jsxs(e.Fragment,{children:[a&&e.jsx(i.div,{initial:{opacity:0}
1,animate:{opacity:1},className:"w-full p-3 bg-red-500/10 border border-red-500/20 rounded-xl",children:e.jsx("p",{className:"text-red-400 text-sm",children:a})}),e.jsx("button",{onClick:s,disabled:n,className:"w-full py-3 px-6 bg-gradient-to-r from-[#F83253] to-[#BD30F4] rounded-full font-semibold text-white text-sm disabled:opacity-50",children:n?"Redirecting...":"Complete Payout Setup"}),e.jsx("button",{onClick:()=>window.close(),className:"w-full py-3 px-6 bg-white/5 border border-white/10 rounded-full font-semibold text-white/60 text-sm hover:bg-white/10 transition-colors",children:"Close Window"})]})}),e.jsx(i.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.4},className:"text-white/10 text-[8px] tracking-[0.8em] uppercase select-none",children:"TappN Payouts"})]})}function O({isLoading:t,error:s,onRetry:n}){return e.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[e.jsx(i.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:200,damping:15},className:"w-16 h-16 rounded-full bg-red-500/20 border-2 border-red-500 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),e.jsxs(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Oops! Process Incomplete"}),e.jsx("p",{className:"text-white/60 text-sm max-w-sm",children:t?"Generating your onboarding link...":s?"Failed to generate link. Please try again.":"Your onboarding session expired or was not completed. Click below to try again."})]}),s&&e.jsx(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"w-full p-3 bg-red-500/10 border border-red-500/20 rounded-xl",children:e.jsx("p",{className:"text-red-400 text-sm",children:s})}),e.jsxs(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3},className:"flex flex-col gap-3 w-full",children:[e.jsx("button",{onClick:n,disabled:t,className:"w-full py-3 px-6 bg-gradient-to-r from-[#F83253] to-[#BD30F4] rounded-full font-semibold text-white text-sm disabled:opacity-50",children:t?"Redirecting...":"Try Again"}),e.jsx("button",{onClick:()=>window.close(),className:"w-full py-3 px-6 bg-white/5 border border-white/10 rounded-full font-semibold text-white/60 text-sm hover:bg-white/10 transition-colors",children:"Close Window"})]}),e.jsx(i.p,{initial:{opacity:0}
1,animate:{opacity:1},transition:{delay:.2},className:"text-white/10 text-[8px] tracking-[0.8em] uppercase select-none",children:"TappN Payouts"})]})}function T(){const[t]=F(),s=t.get("status"),n=t.get("provider_account_id");if(!s||!n)return e.jsx(f,{to:"/",replace:!0});const a=s==="onboarding-success",o=s==="onboarding-refresh",[x,l]=r.useState(!1),[c,d]=r.useState(null),{state:v,status:N,error:k,isLoading:C,refetch:S}=B(a?n:null),p=async()=>{if(n){l(!0),d(null);try{const m=await j.reconnect(n);window.location.href=m.onboardingUrl}catch(m){d(m.message||"Failed to generate link"),l(!1)}}};return C?e.jsx(R,{}):a?v==="error"?e.jsxs("div",{className:"min-h-screen bg-[#030303] relative overflow-hidden",children:[e.jsx(h,{}),e.jsx("div",{className:"relative z-10 min-h-screen flex flex-col items-center justify-center px-4",children:e.jsx("div",{className:"w-full max-w-[400px] flex flex-col items-center gap-6",children:e.jsx(A,{error:k,onRetry:S})})})]}):e.jsxs("div",{className:"min-h-screen bg-[#030303] relative overflow-hidden",children:[e.jsx(h,{}),e.jsx("div",{className:"relative z-10 min-h-screen flex flex-col items-center justify-center px-4 py-8",children:e.jsx("div",{className:"w-full max-w-[400px]",children:e.jsx(I,{status:N,onCompleteSetup:p,isReconnecting:x,reconnectError:c})})})]}):o?e.jsxs("div",{className:"min-h-screen bg-[#030303] relative overflow-hidden",children:[e.jsx(h,{}),e.jsx("div",{className:"relative z-10 min-h-screen flex flex-col items-center justify-center px-4 py-8",children:e.jsx("div",{className:"w-full max-w-[400px]",children:e.jsx(O,{isLoading:x,error:c,onRetry:p})})})]}):e.jsx(f,{to:"/",replace:!0})}function h(){return e.jsxs("div",{className:"fixed inset-0 overflow-hidden pointer-events-none z-0",children:[e.jsx(i.div,{animate:{scale:[1,1.2,1],opacity:[.1,.15,.1]},transition:{duration:10,repeat:1/0},className:"absolute -top-[10%] -left-[10%] w-[80%] h-[80%] bg-[#F83253] blur-[150px] rounded-full"}),e.jsx(i.div,{animate:{scale:[1,1.1,1],opacity:[.1,.12,.1]},transition:{duration:12,repeat:1/0},className:"absolute bottom-[-10%] right-[-10%] w-[80%] h-[80%] bg-[#BD30F4] blur-[150px] rounded-full"})]})}function A({error:t,onRetry:s}){return e.jsxs(e.Fragment,{children:[e.jsx(i.div,{initial:{scale:0},animate:{scale:1},className:"w-16 h-16 rounded-full bg-red-500/20 border-2 border-red-500 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Something Went Wrong"}),e.jsx("p",{className:"text-white/60 text-sm",children:t||"Unable to load payout status."}),e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[e.jsx("button",{onClick:s,className:"w-full py-3 px-6 bg-gradient-to-r from-[#F83253] to-[#BD30F4] rounded-full font-semibold text-white text-sm",children:"Try Again"}),e.jsx("button",{onClick:()=>window.close(),className:"w-full py-3 px-6 bg-white/5 border border-white/10 rounded-full font-semibold text-white/60 text-sm hover:bg-white/10 transition-colors",children:"Close"})]})]})}export{T 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.