1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9563],{937:(e,a,s)=>{s.d(a,{A:()=>J,I:()=>Y});var t=s(37876),r=s(14232),l=s(89099),n=s(71538),i=s(47388),d=s(99910),o=s(72071),c=s(89865),u=s(72425),m=s(2663),x=s(75075),b=s(72591),p=s(61678),h=s(26726),g=s(75192),f=s(90266),v=s(85752),j=s(97905),y=s(5367),N=s(30293),w=s(43816);let _=(e,a="INR")=>new Intl.NumberFormat("en-IN",{style:"currency",currency:a,minimumFractionDigits:0,maximumFractionDigits:2}).format(Number(e||0)),k=e=>e?new Intl.DateTimeFormat("en-IN",{day:"numeric",month:"short",year:"numeric"}).format(new Date(e)):"â",S=e=>e?e.replace(/_/g," "):"pending",A=".jpg,.jpeg,.png,.webp,.pdf",C="JPG, JPEG, PNG, WEBP, or PDF",P=({value:e})=>{let a=String(e||"pending"),s="approved"===a||"active"===a||"paid"===a?"bg-emerald-50 text-emerald-700 border-emerald-200":"rejected"===a||"inactive"===a||"expired"===a?"bg-red-50 text-red-700 border-red-200":"processing"===a||"grace"===a?"bg-amber-50 text-amber-700 border-amber-200":"bg-slate-50 text-slate-700 border-slate-200";return(0,t.jsx)("span",{className:`inline-flex rounded-full border px-3 py-1 text-xs font-semibold uppercase tracking-[0.12em] ${s}`,children:S(a)})},R=({label:e="Loading..."})=>(0,t.jsx)("div",{className:"rounded-[1.6rem] border border-[rgba(17,19,57,0.08)] bg-white px-6 py-10 text-center text-sm text-slate-500 shadow-sm",children:e}),U=({message:e,tone:a="info"})=>(0,t.jsx)("div",{className:`mb-4 rounded-2xl border px-4 py-3 text-sm ${"error"===a?"border-red-200 bg-red-50 text-red-700":"success"===a?"border-emerald-200 bg-emerald-50 text-emerald-700":"warning"===a?"border-amber-200 bg-amber-50 text-amber-800":"border-[rgba(17,19,57,0.08)] bg-[rgba(17,19,57,0.04)] text-slate-700"}`,children:e}),q=e=>`w-full rounded-2xl border px-4 py-3 text-sm outline-none transition focus:border-[var(--brand-red)] ${e?"border-red-300 bg-red-50/40":"border-[rgba(17,19,57,0.12)] bg-white"}`,E=e=>`rounded-2xl border border-dashed px-4 py-4 ${e?"border-red-300 bg-red-50/40":"border-[rgba(17,19,57,0.18)] bg-[rgba(17,19,57,0.02)]"}`,$=({title:e,description:a,children:s})=>(0,t.jsxs)("section",{className:"rounded-[1.6rem] border border-[rgba(17,19,57,0.08)] bg-white p-5 shadow-sm sm:p-6",children:[(0,t.jsxs)("div",{className:"mb-5",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold text-[var(--brand-navy)]",children:e}),a?(0,t.jsx)("p",{className:"mt-2 text-sm leading-7 text-slate-600",children:a}):null]}),s]}),L=({label:e,value:a,helper:s,icon:r,iconClassName:l="bg-[rgba(156,3,5,0.08)] text-[var(--brand-red)]"})=>(0,t.jsxs)("div",{className:"rounded-2xl border border-[rgba(17,19,57,0.08)] bg-slate-50 px-4 py-4 transition hover:-translate-y-0.5 hover:border-[rgba(156,3,5,0.16)] hover:bg-white hover:shadow-lg hover:shadow-slate-900/5",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-slate-500",children:e}),(0,t.jsx)("p",{className:"mt-3 text-2xl font-semibold text-[var(--brand-navy)]",children:a})]}),r?(0,t.jsx)("span",{className:`grid h-10 w-10 shrink-0 place-items-center rounded-xl ${l}`,children:(0,t.jsx)(r,{className:"h-5 w-5"})}):null]}),s?(0,t.jsx)("p",{className:"mt-2 text-xs text-slate-500",children:s}):null]}),T=({actualPrice:e,discountPercentage:a,discountAmount:s,discountedPrice:r,gstPercentage:l,gstAmount:n,totalPrice:i,currency:d="INR"})=>{let o=[{label:"Actual Price",value:_(e,d)},{label:"Discount",value:Number(a||0)>0?`${Number(a||0)}% (${_(s,d)})`:"No discount"},{label:"Discounted Price",value:_(r,d)},{label:"GST",value:`${Number(l||0)}% (${_(n,d)})`},{label:"Total Price",value:_(i,d),highlight:!0}];return(0,t.jsx)("div",{className:"overflow-hidden rounded-[1.3rem] border border-[rgba(17,19,57,0.08)] bg-[rgba(17,19,57,0.03)]",children:o.map((e,a)=>(0,t.jsxs)("div",{className:`flex items-center justify-between gap-4 px-4 py-3 ${a!==o.length-1?"border-b border-[rgba(17,19,57,0.08)]":""}`,children:[(0,t.jsx)("div",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-slate-500",children:e.label}),(0,t.jsx)("div",{className:`text-right text-sm font-semibold ${e.highlight?"text-[var(--brand-red)]":"text-[var(--brand-navy)]"}`,children:e.value})]},e.label))})},D=({notes:e})=>0===e.length?null:(0,t.jsxs)("div",{className:"rounded-xl bg-[rgba(17,19,57,0.04)] px-3 py-3",children:[(0,t.jsx)("div",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-slate-500",children:"Notes"}),(0,t.jsx)("ul",{className:"mt-3 space-y-2 text-sm text-slate-600",children:e.map((e,a)=>(0,t.jsxs)("li",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"mt-1 h-1.5 w-1.5 rounded-full bg-[var(--brand-red)]"}),(0,t.jsx)("span",{children:e})]},`${e}-${a}`))})]}),I=({items:e})=>{let a=Math.max(1,...e.flatMap(e=>[e.earned_commission,e.approved_commission,e.withdrawn_amount]));return(0,t.jsx)("div",{className:"space-y-4",children:e.map(e=>(0,t.jsxs)("div",{className:"rounded-2xl border border-[rgba(17,19,57,0.08)] p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("p",{className:"text-sm font-semibold text-[var(--brand-navy)]",children:e.month}),(0,t.jsxs)("p",{className:"text-xs text-slate-500",children:["Earned ",_(e.earned_commission)]})]}),(0,t.jsx)("div",{className:"mt-4 space-y-3",children:[{key:"earned",label:"Earned",value:e.earned_commission,className:"bg-[var(--brand-red)]"},{key:"approved",label:"Approved",value:e.approved_commission,className:"bg-emerald-500"},{key:"withdrawn",label:"Withdrawn",value:e.withdrawn_amount,className:"bg-slate-500"}].map(e=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"mb-1 flex items-center justify-between text-xs text-slate-500",children:[(0,t.jsx)("span",{children:e.label}),(0,t.jsx)("span",{children:_(e.value)})]}),(0,t.jsx)("div",{className:"h-2 rounded-full bg-[rgba(17,19,57,0.08)]",children:(0,t.jsx)("div",{className:`h-2 rounded-full ${e.className}`,style:{width:`${Math.max(e.value/a*100,4*(e.value>0))}%`}})})]},e.key))})]},e.month_key))})},F=({onActivateReferral:e})=>(0,t.jsxs)($,{title:"Activate Your Referral Workspace",description:"Your existing PRNV account can become a referral partner without creating a duplicate login. Activate the workspace first, complete referral document approval, and then continue to subscription checkout to unlock your code, dashboard, and earnings tracking.",children:[(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[(0,t.jsx)(L,{label:"Single account",value:"Multi-role",helper:"Use one login for user, service professional, and referral access."}),(0,t.jsx)(L,{label:"Commission",value:"Fixed amount",helper:"Earn on the first subscription and every renewal."}),(0,t.jsx)(L,{label:"Withdrawal rule",value:"Threshold-based",helper:"The current minimum appears in your withdrawal workspace after KYC, bank approval, and an active subscription."})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void e(),className:"brand-button mt-6 !justify-center",children:"Enable Referral Workspace"})]}),M=({profile:e,refreshKey:a})=>{let[s,l]=(0,r.useState)(null),[p,h]=(0,r.useState)([]),[f,v]=(0,r.useState)(null),[j,y]=(0,r.useState)(!0),[N,w]=(0,r.useState)(null);if((0,r.useEffect)(()=>{let e=!0;return(async()=>{try{y(!0),w(null);let[a,s,t]=await Promise.all([(0,b.vH0)(),(0,b.I1e)(),(0,b.xvr)().catch(()=>null)]);if(!e)return;l(a?.result||null),h(Array.isArray(s?.result?.items)?s.result.items:[]),v(t?.result||null)}catch(a){e&&w(a?.data?.message||a?.message||"Unable to load referral overview.")}finally{e&&y(!1)}})(),()=>{e=!1}},[a]),j)return(0,t.jsx)(R,{label:"Loading referral overview..."});let S=f?.code||e?.referral_code||"Pending",A=e?.referral_link||f?.link||"";return(0,t.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,t.jsx)(g.A,{message:N}),(0,t.jsxs)("section",{className:"rounded-[1.75rem] border border-[rgba(17,19,57,0.08)] bg-white p-5 shadow-[0_20px_60px_rgba(17,19,57,0.08)] sm:p-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-bold uppercase tracking-[0.18em] text-[var(--brand-red)]",children:"Network snapshot"}),(0,t.jsx)("h2",{className:"mt-2 text-2xl font-semibold text-[var(--brand-navy)]",children:"Your referral community"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:"See how many professionals have joined, verified, and subscribed through your network."})]}),(0,t.jsxs)("div",{className:"mt-5 grid gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[(0,t.jsx)(L,{label:"Total referrals",value:s?.total_referrals??0,helper:`${s?.pending_referrals??0} still pending`,icon:n.A,iconClassName:"bg-blue-50 text-blue-700"}),(0,t.jsx)(L,{label:"Verified",value:s?.verified_referrals??0,helper:"Approved professionals",icon:i.A,iconClassName:"bg-emerald-50 text-emerald-700"}),(0,t.jsx)(L,{label:"Subscribed",value:s?.subscribed_referrals??0,helper:"Active paid referrals",icon:d.A,iconClassName:"bg-violet-50 text-violet-700"}),(0,t.jsx)(L,{label:"Renewed",value:s?.renewed_referrals??0,helper:"Returning subscriptions",icon:o.A,iconClassName:"bg-amber-50 text-amber-700"})]})]}),(0,t.jsxs)("section",{className:"grid gap-5 xl:grid-cols-[1.08fr_0.92fr]",children:[(0,t.jsxs)("article",{className:"relative overflow-hidden rounded-[1.75rem] bg-[linear-gradient(135deg,#111339,#263374)] p-5 text-white shadow-[0_22px_60px_rgba(17,19,57,0.18)] sm:p-6",children:[(0,t.jsx)("div",{className:"pointer-events-none absolute -right-20 -top-24 h-56 w-56 rounded-full bg-white/5"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-bold uppercase tracking-[0.18em] text-white/60",children:"Available to withdraw"}),(0,t.jsx)("p",{className:"mt-3 text-3xl font-semibold !text-white sm:text-4xl",children:_(s?.withdrawable_balance)}),(0,t.jsx)("p",{className:"mt-2 text-sm text-white/65",children:"Approved commission ready for payout"})]}),(0,t.jsx)("span",{className:"grid h-12 w-12 shrink-0 place-items-center rounded-xl bg-white/10 text-white",children:(0,t.jsx)(c.A,{className:"h-6 w-6"})})]}),(0,t.jsx)("div",{className:"mt-6 grid gap-3 sm:grid-cols-2",children:[["This month",_(s?.current_month_earnings)],["Lifetime earnings",_(s?.lifetime_earnings)],["Pending commission",_(s?.pending_commission)],["Pending payout",_(s?.pending_payout)]].map(([e,a])=>(0,t.jsxs)("div",{className:"rounded-xl border border-white/10 bg-white/[0.07] px-4 py-3",children:[(0,t.jsx)("p",{className:"text-xs text-white/55",children:e}),(0,t.jsx)("p",{className:"mt-1 text-lg font-semibold !text-white",children:a})]},e))})]})]}),(0,t.jsxs)("article",{className:"rounded-[1.75rem] border border-[rgba(17,19,57,0.08)] bg-white p-5 shadow-[0_20px_60px_rgba(17,19,57,0.08)] sm:p-6",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-bold uppercase tracking-[0.18em] text-[var(--brand-red)]",children:"Share and grow"}),(0,t.jsx)("h2",{className:"mt-2 text-2xl font-semibold text-[var(--brand-navy)]",children:"Your referral code"})]}),(0,t.jsx)("span",{className:"grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-[rgba(156,3,5,0.08)] text-[var(--brand-red)]",children:(0,t.jsx)(u.A,{className:"h-5 w-5"})})]}),(0,t.jsxs)("div",{className:"mt-5 rounded-2xl border border-dashed border-[rgba(156,3,5,0.22)] bg-[rgba(156,3,5,0.04)] px-4 py-5 text-center",children:[(0,t.jsx)("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-slate-500",children:"Partner code"}),(0,t.jsx)("p",{className:"mt-2 break-all text-2xl font-bold tracking-[0.12em] text-[var(--brand-navy)]",children:S}),f?.generated_at?(0,t.jsxs)("p",{className:"mt-2 text-xs text-slate-500",children:["Generated ",k(f.generated_at)]}):null]}),(0,t.jsx)("p",{className:"mt-4 break-all text-sm leading-6 text-slate-600",children:A||"Your shareable referral link will be available after the first successful subscription payment."}),A?(0,t.jsxs)("button",{type:"button",onClick:()=>navigator.clipboard.writeText(String(A)),className:"mt-4 inline-flex w-full items-center justify-center gap-2 rounded-xl bg-[var(--brand-red)] px-4 py-3 text-sm font-bold text-white shadow-lg shadow-red-900/10 transition hover:-translate-y-0.5 hover:bg-[#b30d12]",children:[(0,t.jsx)(m.A,{className:"h-4 w-4"}),"Copy referral link"]}):null,(0,t.jsxs)("div",{className:"mt-4 flex items-center justify-between gap-3 border-t border-slate-100 pt-4 text-sm",children:[(0,t.jsx)("span",{className:"text-slate-500",children:"Partner status"}),(0,t.jsx)(P,{value:e?.status})]})]})]}),(0,t.jsxs)($,{title:"Monthly income",description:"Follow earned commission, approved commission, and paid withdrawals month by month.",children:[(0,t.jsxs)("div",{className:"mb-5 flex items-center gap-3 rounded-xl bg-emerald-50 px-4 py-3 text-sm text-emerald-800",children:[(0,t.jsx)(x.A,{className:"h-5 w-5 shrink-0"}),(0,t.jsxs)("span",{children:["Approved commission: ",(0,t.jsx)("strong",{children:_(s?.approved_commission)})]})]}),(0,t.jsx)(I,{items:p})]})]})},O=({refreshKey:e})=>{let[a,s]=(0,r.useState)([]),[l,n]=(0,r.useState)(null),[i,d]=(0,r.useState)(1),[o,c]=(0,r.useState)(!0),[u,m]=(0,r.useState)(null);return(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{c(!0),m(null);let a=await (0,b.CcN)({page:i,per_page:10});if(!e)return;s(a?.result?.items||[]),n(a?.result?.meta||null)}catch(a){e&&m(a?.data?.message||a?.message||"Unable to load referrals.")}finally{e&&c(!1)}})(),()=>{e=!1}},[i,e]),(0,t.jsxs)($,{title:"My Referrals",description:"Only service professionals mapped to your referral code or referral link appear here. Subscription amount, renewal status, and commission totals are scoped to your account.",children:[(0,t.jsx)(g.A,{message:u}),o?(0,t.jsx)(R,{label:"Loading referrals..."}):0===a.length?(0,t.jsx)("p",{className:"text-sm text-slate-500",children:"No referred service professionals have registered under your co
1de yet."}):(0,t.jsxs)("div",{className:"space-y-4",children:[a.map(e=>(0,t.jsxs)("div",{className:"rounded-2xl border border-[rgba(17,19,57,0.08)] p-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-base font-semibold text-[var(--brand-navy)]",children:e.referred_person_name}),(0,t.jsx)("p",{className:"mt-1 text-sm text-slate-600",children:e.mobile_number}),(0,t.jsx)("p",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-slate-400",children:e.type})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(P,{value:e.verification_status}),(0,t.jsx)(P,{value:e.subscription_status})]})]}),(0,t.jsxs)("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[(0,t.jsx)(L,{label:"Plan",value:e.technician_subscription_plan_name||"â"}),(0,t.jsx)(L,{label:"Plan amount",value:_(e.technician_subscription_amount)}),(0,t.jsx)(L,{label:"Pending",value:_(e.pending_commission)}),(0,t.jsx)(L,{label:"Approved",value:_(e.approved_commission)}),(0,t.jsx)(L,{label:"Total earned",value:_(e.total_commission_earned)}),(0,t.jsx)(L,{label:"Registered",value:k(e.registration_date)}),(0,t.jsx)(L,{label:"First subscription",value:k(e.first_subscription_date)}),(0,t.jsx)(L,{label:"Last renewal",value:k(e.last_renewal_date)})]})]},e.id)),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("button",{type:"button",disabled:!l||i<=1,onClick:()=>d(e=>Math.max(e-1,1)),className:"rounded-xl border border-[rgba(17,19,57,0.12)] px-4 py-2 text-sm font-semibold text-slate-700 disabled:opacity-50",children:"Previous"}),(0,t.jsxs)("p",{className:"text-sm text-slate-500",children:["Page ",l?.current_page||1," of ",l?.last_page||1]}),(0,t.jsx)("button",{type:"button",disabled:!l||!l.has_more,onClick:()=>d(e=>e+1),className:"rounded-xl border border-[rgba(17,19,57,0.12)] px-4 py-2 text-sm font-semibold text-slate-700 disabled:opacity-50",children:"Next"})]})]})]})},W=({refreshKey:e})=>{let[a,s]=(0,r.useState)(null),[l,n]=(0,r.useState)([]),[i,d]=(0,r.useState)(!0);return((0,r.useEffect)(()=>{let e=!0;return(async()=>{try{d(!0);let[a,t]=await Promise.all([(0,b.xZ$)(),(0,b.I1e)()]);if(!e)return;s(a?.result||null),n(t?.result?.items||[])}finally{e&&d(!1)}})(),()=>{e=!1}},[e]),i)?(0,t.jsx)(R,{label:"Loading earnings..."}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)($,{title:"Earnings Summary",description:"Pending commission and approved commission are tracked separately. Approved commission contributes to your withdrawable balance once all other withdrawal rules pass.",children:(0,t.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[(0,t.jsx)(L,{label:"Pending commission",value:_(a?.pending_commission)}),(0,t.jsx)(L,{label:"Approved commission",value:_(a?.approved_commission)}),(0,t.jsx)(L,{label:"Withdrawable balance",value:_(a?.withdrawable_balance)}),(0,t.jsx)(L,{label:"Lifetime earnings",value:_(a?.lifetime_earnings)}),(0,t.jsx)(L,{label:"Current month",value:_(a?.current_month_earnings)}),(0,t.jsx)(L,{label:"Pending payout",value:_(a?.pending_payout)})]})}),(0,t.jsx)($,{title:"Monthly Commission Trend",description:"Use this view to compare the total earned commission against what has already been approved and what has already been withdrawn.",children:(0,t.jsx)(I,{items:l})})]})},B=({refreshKey:e,onRefresh:a})=>{let[s,l]=(0,r.useState)(null),[n,i]=(0,r.useState)([]),[d,o]=(0,r.useState)(null),[c,u]=(0,r.useState)(1),[m,x]=(0,r.useState)(!0),[p,h]=(0,r.useState)(!1),[g,f]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{x(!0);let[a,s]=await Promise.all([(0,b.GJG)(),(0,b.VPd)({page:c,per_page:10})]);if(!e)return;l(a?.result||null),i(s?.result?.items||[]),o(s?.result?.meta||null)}finally{e&&x(!1)}})(),()=>{e=!1}},[c,e]);let v=async()=>{try{h(!0),f(null);let e=await (0,b.B7P)(),s=Number(e?.result?.requested_amount??e?.result?.amount??0)||0;f(s>0?`Withdrawal request created successfully for ${_(s)}.`:"Withdrawal request created successfully."),a()}catch(e){f(e?.data?.message||e?.message||"Unable to create withdrawal request.")}finally{h(!1)}};if(m)return(0,t.jsx)(R,{label:"Loading withdrawal data..."});let j=_(s?.minimum_withdrawal_amount??1e3);return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)($,{title:"Withdrawal Eligibility",description:`Withdrawals are enabled only when your approved balance is at least ${j}, your referral subscription is valid, and both your documents and bank details are approved.`,children:[g?(0,t.jsx)("div",{className:"mb-4 rounded-2xl border border-[rgba(17,19,57,0.08)] bg-[rgba(17,19,57,0.04)] px-4 py-3 text-sm text-slate-700",children:g}):null,(0,t.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[(0,t.jsx)(L,{label:"Approved commission",value:_(s?.approved_commission)}),(0,t.jsx)(L,{label:"Pending commission",value:_(s?.pending_commission)}),(0,t.jsx)(L,{label:"Withdrawable balance",value:_(s?.withdrawable_balance)}),(0,t.jsx)(L,{label:"Minimum withdrawal",value:_(s?.minimum_withdrawal_amount)})]}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(P,{value:s?.bank_verification_status}),(0,t.jsx)(P,{value:s?.document_verification_status}),(0,t.jsx)(P,{value:s?.subscription_status})]}),s?.reasons?.length?(0,t.jsx)("div",{className:"mt-5 space-y-2 rounded-2xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800",children:s.reasons.map(e=>(0,t.jsx)("p",{children:e},e))}):null,(0,t.jsx)("button",{type:"button",onClick:()=>void v(),disabled:!s?.can_withdraw||p,className:"brand-button mt-5 !ju
1stify-center disabled:cursor-not-allowed disabled:opacity-60",children:p?"Submitting...":"Request Withdrawal"})]}),(0,t.jsx)($,{title:"Withdrawal History",description:"Review your requested, processing, paid, rejected, and on-hold payout records.",children:0===n.length?(0,t.jsx)("p",{className:"text-sm text-slate-500",children:"No withdrawal requests have been created yet."}):(0,t.jsxs)("div",{className:"space-y-4",children:[n.map(e=>(0,t.jsxs)("div",{className:"rounded-2xl border border-[rgba(17,19,57,0.08)] p-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-base font-semibold text-[var(--brand-navy)]",children:_(e.requested_amount)}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-slate-500",children:["Requested ",k(e.requested_at)]})]}),(0,t.jsx)(P,{value:e.status})]}),(0,t.jsxs)("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[(0,t.jsx)(L,{label:"Processed",value:k(e.processed_at)}),(0,t.jsx)(L,{label:"Txn Ref",value:e.transaction_reference||"â"})]}),e.admin_remarks?(0,t.jsx)("p",{className:"mt-3 rounded-xl bg-[rgba(17,19,57,0.04)] px-3 py-3 text-sm text-slate-600",children:e.admin_remarks}):null]},e.id)),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("button",{type:"button",disabled:!d||c<=1,onClick:()=>u(e=>Math.max(e-1,1)),className:"rounded-xl border border-[rgba(17,19,57,0.12)] px-4 py-2 text-sm font-semibold text-slate-700 disabled:opacity-50",children:"Previous"}),(0,t.jsxs)("p",{className:"text-sm text-slate-500",children:["Page ",d?.current_page||1," of ",d?.last_page||1]}),(0,t.jsx)("button",{type:"button",disabled:!d||!d.has_more,onClick:()=>u(e=>e+1),className:"rounded-xl border border-[rgba(17,19,57,0.12)] px-4 py-2 text-sm font-semibold text-slate-700 disabled:opacity-50",children:"Next"})]})]})})]})},Y=({profile:e,refreshKey:a,onRefresh:s,selectedPlanId:n,redirectOnBlocked:i=!1})=>{let d=(0,l.useRouter)(),[o,c]=(0,r.useState)([]),[u,m]=(0,r.useState)(null),[x,p]=(0,r.useState)(!0),[h,g]=(0,r.useState)(null),[j,y]=(0,r.useState)(null),N=!!e?.documents_status?.is_approved,w="number"==typeof n&&o.find(e=>Number(e.id)===n)||null,A="number"==typeof n?w?[w]:[]:o,C=!!(u?.renew
1al_final_amount??u?.renewal_amount),U=!!(u?.current_plan||u?.locked_amount!==null||u?.renewal_final_amount!==null||u?.renewal_amount!==null);(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{p(!0);let[a,s]=await Promise.all([(0,b.JWX)(),(0,b.zBE)()]);if(!e)return;c(a?.result?.items||[]),m(s?.result||null)}finally{e&&p(!1)}})(),()=>{e=!1}},[a]),(0,r.useEffect)(()=>{i&&!x&&e&&!N&&d.replace("/referral/verification-documents?subscription_blocked=1")},[N,x,e,i,d]),(0,r.useEffect)(()=>{let e=Array.isArray(d.query.internal_order_id)?d.query.internal_order_id[0]:d.query.internal_order_id;if(!e)return;let a=!0;return(async()=>{try{let t=await (0,b.v_d)(String(e));if(!a)return;let r=t?.data?.status||t?.result?.status||"pending";g("success"===r?"Referral subscription payment completed successfully.":"failed"===r?"Referral subscription payment failed.":"cancelled"===r?"Referral subscription payment was cancelled.":"expired"===r?"Referral subscription payment session expired.":`Referral subscription payment status: ${S(r)}.`),s()}catch(e){a&&g(e?.data?.message||e?.message||"Unable to verify the latest payment status.")}})(),()=>{a=!1}},[s,d.query.internal_order_id]);let q=async e=>{if(!f.Og)return void g("PhonePe payments are temporarily unavailable.");try{y(e),g(null);let a=await (0,b.nF4)(e),s=a?.data?.redirect_url||a?.result?.redirect_url,t=(0,v.N)(s);t?window.location.assign(t):s&&g("The payment provider returned an untrusted redirect.")}catch(e){g(e?.data?.message||e?.message||"Unable to start referral subscription checkout.")}finally{y(null)}},E=async()=>{if(!f.Og)return void g("PhonePe payments are temporarily unavailable.");try{y("renew"),g(null);let e=await (0,b.Cxd)(),a=e?.data?.redirect_url||e?.result?.redirect_url,s=(0,v.N)(a);s?window.location.assign(s):a&&g("The payment provider returned an untrusted redirect.")}catch(e){g(e?.data?.message||e?.message||"Unable to start referral renewal checkout.")}finally{y(null)}};return x?(0,t.jsx)(R,{label:"Loading subscription details..."}):!N&&i?(0,t.jsx)(R,{label:"Redirecting to verification documents..."}):N?(0,t.jsxs)("div",{className:"space-y-6",children:[null==n||C?(0,t.jsxs)($,{title:"Current Subscription",description:"Referral partners keep their original locked pricing for lifetime renewals. Renewal always uses your original subscribed amount, discount, and GST percentage, not the latest live plan settings.",children:[h?(0,t.jsx)("div",{className:"mb-4 rounded-2xl border border-[rgba(17,19,57,0.08)] bg-[rgba(17,19,57,0.04)] px-4 py-3 text-sm text-slate-700",children:h}):null,U?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,t.jsx)(T,{actualPrice:u?.locked_base_amount??u?.locked_amount,discountPercentage:u?.locked_discount_percentage,discountAmount:u?.locked_discount_amount,discountedPrice:u?.locked_taxable_amount,gstPercentage:u?.locked_gst_percentage,gstAmount:u?.locked_gst_amount??u?.renewal_gst_amount,totalPrice:u?.locked_final_amount??u?.renewal_final_amount}),(0,t.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,t.jsx)(L,{label:"Plan",value:u?.current_plan||"Not active"}),(0,t.jsx)(L,{label:"Status",value:S(u?.status).toUpperCase()}),(0,t.jsx)(L,{label:"Start date",value:k(u?.start_date)}),(0,t.jsx)(L,{label:"Expiry date",value:k(u?.expiry_date)}),(0,t.jsx)(L,{label:"Grace end",value:k(u?.grace_period_end_date)}),(0,t.jsx)(L,{label:"Admin extension",value:`${u?.admin_extended_days||0} days`})]})]}),(0,t.jsxs)("div",{className:"mt-4 grid gap-4 sm:grid-cols-2 xl:grid-cols-5",children:[(0,t.jsx)(L,{label:"Billing cycle",value:u?.duration_type?S(u.duration_type):"â"}),(0,t.jsx)(L,{label:"Discount",value:Number(u?.locked_discount_percentage||0)>0?`${u?.locked_discount_percentage}%`:"No discount"}),(0,t.jsx)(L,{label:"Discounted price",value:_(u?.locked_taxable_amount)}),(0,t.jsx)(L,{label:"Renewal total",value:_(u?.renewal_final_amount??u?.renewal_amount)}),(0,t.jsx)(L,{label:"Last renewed",value:k(u?.last_renewed_at)})]}),u?.renewal_final_amount||u?.renewal_amount?(0,t.jsx)("button",{type:"button",onClick:()=>void E(),disabled:!f.Og||"renew"===j,className:"brand-button mt-5 !ju
1stify-center disabled:opacity-60",children:f.Og?"renew"===j?"Preparing renewal...":`Renew at ${_(u?.renewal_final_amount??u?.renewal_amount)}`:"Payments temporarily unavailable"}):null]}):null,U?null:(0,t.jsx)("div",{className:"rounded-2xl border border-[rgba(17,19,57,0.08)] bg-[rgba(17,19,57,0.02)] px-4 py-4 text-sm text-slate-600",children:"No paid referral subscription has been activated yet. Choose one of the plans below to continue."})]}):null,(0,t.jsxs)($,{title:n?"Referral Subscription Details":"Referral Subscription Plans",description:C?"Your first paid referral subscription locks your renewal pricing. Use the renewal action above instead of starting a fresh purchase from a public plan link.":n?"This selected referral subscription plan is loaded from the admin catalog. Review the billing details before starting checkout.":"Monthly and yearly plans are configured by the admin. Free referral subscriptions are not available in this phase.",children:[!n||w||C?null:(0,t.jsx)("div",{className:"rounded-2xl border border-[rgba(17,19,57,0.08)] bg-[rgba(17,19,57,0.02)] px-4 py-4 text-sm text-slate-600",children:"This referral subscription plan is not available right now."}),n||0!==A.length?null:(0,t.jsx)("div",{className:"rounded-2xl border border-[rgba(17,19,57,0.08)] bg-[rgba(17,19,57,0.02)] px-4 py-4 text-sm text-slate-600",children:"No active referral subscription plans are available right now."}),(0,t.jsx)("div",{className:"grid gap-4 lg:grid-cols-2",children:A.map(e=>(0,t.jsxs)("div",{className:"rounded-[1.5rem] border border-[rgba(17,19,57,0.08)] p-5 shadow-sm",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-lg font-semibold text-[var(--brand-navy)]",children:e.name}),(0,t.jsx)("p",{className:"mt-1 text-xs uppercase tracking-[0.16em] text-slate-500",children:e.duration_type}),e.discount_percentage>0?(0,t.jsxs)("div",{className:"mt-3 inline-flex rounded-full bg-[rgba(156,3,5,0.08)] px-3 py-1 text-xs font-semibold uppercase tracking-[0.14em] text-[var(--brand-red)]",children:[e.discount_percentage,"% off"]}):null]}),(0,t.jsx)(P,{value:"active"})]}),(0,t.jsx)("p",{className:"mt-4 text-3xl font-semibold text-[var(--brand-red)]",children:_(e.final_amount)}),(0,t.jsx)("p",{className:"mt-2 text-sm text-slate-600",children:"Final payable amount returned by the API after discount and GST."}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(T,{actualPrice:e.base_amount,discountPercentage:e.discount_percentage,discountAmount:e.discount_amount,discountedPrice:e.taxable_amount,gstPercentage:e.gst_percentage,gstAmount:e.gst_amount,totalPrice:e.final_amount,currency:e.currency})}),(0,t.jsxs)("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"rounded-xl bg-[rgba(17,19,57,0.04)] px-3 py-3 text-sm text-slate-600",children:["Duration:"," ",(0,t.jsx)("span",{className:"font-semibold text-[var(--brand-navy)]",children:e.duration_label||`${e.duration_days} days`})]}),(0,t.jsxs)("div",{className:"rounded-xl bg-[rgba(17,19,57,0.04)] px-3 py-3 text-sm text-slate-600",children:["Grace period:"," ",(0,t.jsxs)("span",{className:"font-semibold text-[var(--brand-navy)]",children:[e.grace_period_days," days"]})]})]}),e.description?(0,t.jsx)("p",{className:"mt-4 text-sm leading-7 text-slate-600",children:e.description}):null,e.notes_items.length>0?(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(D,{notes:e.notes_items})}):null,C?(0,t.jsx)("div",{className:"mt-5 rounded-xl bg-[rgba(17,19,57,0.04)] px-3 py-3 text-sm text-slate-600",children:"Renewal must continue with your locked original pricing shown above."}):(0,t.jsx)("button",{type:"button",onClick:()=>void q(e.id),disabled:!f.Og||j===e.id,className:"brand-button mt-5 !justify-center disabled:cursor-not-allowed disabled:opacity-50",children:f.Og?j===e.id?"Preparing checkout...":n?"Subscribe":"Buy this plan":"Payments temporarily unavailable"})]},e.id))})]})]}):(0,t.jsx)($,{title:"Referral Subscription Access Blocked",description:"Referral documents must be approved before subscription access is available. Complete Aadhaar and one secondary ID, then wait for admin a
1pproval.",children:(0,t.jsx)("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 px-4 py-4 text-sm text-amber-800",children:"Subscription details and checkout are hidden until your referral documents are approved."})})},G=({refreshKey:e,onRefresh:a})=>{let[s,l]=(0,r.useState)(null),[n,i]=(0,r.useState)(""),[d,o]=(0,r.useState)(""),[c,u]=(0,r.useState)(""),[m,x]=(0,r.useState)(""),[p,h]=(0,r.useState)(""),[g,f]=(0,r.useState)(""),[v,j]=(0,r.useState)(""),[y,_]=(0,r.useState)(null),[k,S]=(0,r.useState)(!0),[L,T]=(0,r.useState)(!1),[D,I]=(0,r.useState)(null),{formError:F,fieldErrors:M,clearErrors:O,setClientFieldError:W,applyApiError:B}=(0,w.Ry)({account_holder_name:"accountHolderName",bank_name:"bankName",account_number:"accountNumber",confirm_account_number:"confirmAccountNumber",ifsc_code:"ifscCode",branch_name:"branchName",upi_id:"upiId",cancelled_cheque:"cancelledCheque"});(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{S(!0);let a=await (0,b.VKH)(),s=a?.result||null;if(!e)return;l(s),i(s?.account_holder_name||""),o(s?.bank_name||""),h(s?.ifsc_code||""),f(s?.branch_name||""),j(s?.upi_id||"")}finally{e&&S(!1)}})(),()=>{e=!1}},[e]);let Y=async e=>{if(e.preventDefault(),O(),I(null),!s&&!y)return void W("cancelledCheque","Upload a cancelled cheque or void cheque file before saving.");try{T(!0);let e=new FormData;e.append("account_holder_name",n),e.append("bank_name",d),e.append("account_number",c),e.append("confirm_account_number",m),e.append("ifsc_code",p),e.append("branch_name",g),e.append("upi_id",v),y&&e.append("cancelled_cheque",y),await (0,b.sYr)(e),I("Bank details saved successfully."),u(""),x(""),_(null),a()}catch(e){B(e,"Unable to save bank details.")}finally{T(!1)}};return k?(0,t.jsx)(R,{label:"Loading bank details..."}):(0,t.jsxs)($,{title:"Bank Details",description:"Fill in your payout account details, choose a cancelled cheque or void cheque, then tap Save bank details. The uploaded file is stored privately and only admins can review it during verification.",children:[F?(0,t.jsx)(U,{message:F,tone:"error"}):null,D?(0,t.jsx)(U,{message:D,tone:"success"}):null,s?(0,t.jsxs)("div",{className:"mb-5 rounded-2xl border border-[rgba(17,19,57,0.08)] bg-[rgba(17,19,57,0.02)] p-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-semibold text-[var(--brand-navy)]",children:"Existing verification state"}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-slate-600",children:[s.bank_name," ⢠",s.account_number_masked]})]}),(0,t.jsx)(P,{value:s.status})]}),s.rejection_reason?(0,t.jsx)("p",{className:"mt-3 text-sm text-red-600",children:s.rejection_reason}):null,(0,t.jsx)("p",{className:"mt-3 text-xs leading-6 text-slate-500",children:"Saving updated details or a replacement cheque will send the bank details back for admin review."})]}):null,(0,t.jsxs)("form",{className:"grid gap-4 sm:grid-cols-2",onSubmit:Y,children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"mb-2 block text-sm font-semibold text-slate-700",children:"Account holder name"}),(0,t.jsx)("input",{value:n,onChange:e=>{i(e.target.value),O("accountHolderName")},className:q(!!M.accountHolderName),required:!0}),(0,t.jsx)(N.A,{message:M.accountHolderName})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"mb-2 block text-sm font-semibold text-slate-700",children:"Bank name"}),(0,t.jsx)("input",{value:d,onChange:e=>{o(e.target.value),O("bankName")},className:q(!!M.bankName),required:!0}),(0,t.jsx)(N.A,{message:M.bankName})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"mb-2 block text-sm font-semibold text-slate-700",children:"Account number"}),(0,t.jsx)("input",{value:c,onChange:e=>{u(e.target.value),O("accountNumber")},inputMode:"numeric",className:q(!!M.accountNumber),required:!0}),(0,t.jsx)(N.A,{message:M.accountNumber})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"mb-2 block text-sm font-semibold text-slate-700",children:"Confirm account number"}),(0,t.jsx)("input",{value:m,onChange:e=>{x(e.target.value),O("confirmAccountNumber")},inputMode:"numeric",className:q(!!M.confirmAccountNumber),required:!0}),(0,t.jsx)(N.A,{message:M.confirmAccountNumber})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"mb-2 block text-sm font-semibold text-slate-700",children:"IFSC code"}),(0,t.jsx)("input",{value:p,onChange:e=>{h(e.target.value.toUpperCase()),O("ifscCode")},className:q(!!M.ifscCode),required:!0}),(0,t.jsx)(N.A,{message:M.ifscCode})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"mb-2 block text-sm font-semibold text-slate-700",children:"Branch name"}),(0,t.jsx)("input",{value:g,onChange:e=>{f(e.target.value),O("branchName")},className:q(!!M.branchName)}),(0,t.jsx)(N.A,{message:M.branchName})]}),(0,t.jsxs)("label",{className:"block sm:col-span-2",children:[(0,t.jsx)("span",{className:"mb-2 block text-sm font-semibold text-slate-700",children:"UPI ID"}
1),(0,t.jsx)("input",{value:v,onChange:e=>{j(e.target.value),O("upiId")},placeholder:"Optional",className:q(!!M.upiId)}),(0,t.jsx)(N.A,{message:M.upiId})]}),(0,t.jsxs)("label",{className:`sm:col-span-2 ${E(!!M.cancelledCheque)}`,children:[(0,t.jsx)("span",{className:"block text-sm font-semibold text-[var(--brand-navy)]",children:"Cancelled cheque / void cheque"}),(0,t.jsxs)("span",{className:"mt-1 block text-xs leading-6 text-slate-500",children:["Upload a ",C," file. This document is stored securely on the private disk and is visible only to admins reviewing your account."]}),(0,t.jsx)("input",{type:"file",accept:A,className:"mt-3 block w-full text-sm",onChange:e=>{_(e.target.files?.[0]||null),O("cancelledCheque")}}),y?(0,t.jsxs)("span",{className:"mt-2 block text-xs text-slate-500",children:["Selected file: ",y.name]}):s?(0,t.jsx)("span",{className:"mt-2 block text-xs text-slate-500",children:"Leave this empty if you want to keep the existing cheque on file."}):null,(0,t.jsx)(N.A,{message:M.cancelledCheque})]}),(0,t.jsx)("button",{type:"submit",disabled:L,className:"brand-button sm:col-span-2 !w-full !justify-center disabled:opacity-60",children:L?"Saving...":"Save bank details"})]})]})},K=e=>e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),H=({refreshKey:e,onRefresh:a})=>{let s=(0,l.useRouter)(),[n,i]=(0,r.useState)(null),[d,o]=(0,r.useState)(!0),[c,u]=(0,r.useState)(null),[m,x]=(0,r.useState)(null),[p,h]=(0,r.useState)(null),[g,f]=(0,r.useState)({}),[v,j]=(0,r.useState)({}),y=s.query.subscription_blocked?"Referral documents must be approved before subscription access is available.":null;(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{o(!0);let a=await (0,b.IZ6)();e&&i(a?.result||null)}finally{e&&o(!1)}})(),()=>{e=!1}},[e]);let _=e=>{j(a=>{if(!a[e])return a;let s={...a};return delete s[e],s})},S=async(e,s)=>{let t=g[e]||null;if(!t){j(a=>({...a,[e]:"Choose a file before uploading this document."})),u(null),x(null);return}try{h(e),u(null),x(null),_(e),await (0,b.oNQ)(e,t,s??null),f(a=>({...a,[e]:null})),x(`${K(e)} uploaded successfully.`),a()}catch(t){let a=(0,w.hQ)(t),s=a.file||a.document_type||"";j(a=>({...a,[e]:s||"Unable to upload this document."})),u(t?.data?.message&&t?.data?.message!==s?t.data.message:t?.message&&t?.message!==s?t.message:null)}finally{h(null)}};return d?(0,t.jsx)(R,{label:"Loading document status..."}):(0,t.jsxs)($,{title:"Verification Documents",description:"Aadhaar is mandatory. You must also upload either PAN or Driving License. Choose a file, then tap Upload document to submit it securely for admin review. Approved or pending documents stay locked; replacement is only available if admin review asks for a new upload.",children:[y?(0,t.jsx)(U,{message:y,tone:"warning"}):null,c?(0,t.jsx)(U,{message:c,tone:"error"}):null,m?(0,t.jsx)(U,{message:m,tone:"success"}):null,(0,t.jsxs)("div",{className:"mb-5 grid gap-4 sm:grid-cols-3",children:[(0,t.jsx)(L,{label:"Aadhaar uploaded",value:n?.requirements.aadhaar_uploaded?"Yes":"No"}),(0,t.jsx)(L,{label:"Secondary ID uploaded",value:n?.requirements.secondary_uploaded?"Yes":"No"}),(0,t.jsx)(L,{label:"Documents approved",value:n?.is_approved?"Yes":"No"})]}),(0,t.jsx)("div",{className:"grid gap-4 lg:grid-cols-3",children:["aadhaar","pan","driving_license"].map(e=>{let a=n?.items.find(a=>a.document_type===e),s=!!a?.can_replace,r=!a||s,l=a&&!a.can_replace?a.replace_disabled_reason?a.replace_disabled_reason:"approved"===a.status?"This document is already approved. No replacement is needed.":"pending"===a.status?"This document is still under admin review.":"This document cannot be replaced right now.":null;return(0,t.jsxs)("div",{className:"flex h-full flex-col rounded-[1.4rem] border border-[rgba(17,19,57,0.08)] p-4 sm:p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-base font-semibold text-[var(--brand-navy)]",children:K(e)}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-slate-600",children:["Uploaded: ",k(a?.uploaded_at)]})]}),(0,t.jsx)(P,{value:a?.status})]}),a?.rejection_reason?(0,t.jsx)("p",{className:"mt-4 rounded-2xl border border-red-200 bg-red-50 px-3 py-3 text-sm text-red-700",children:a.rejection_reason}):null,r?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("label",{className:`mt-4 block ${E(!!v[e])}`,children:[(0,t.jsx)("span",{className:"block text-sm font-semibold text-[var(--brand-navy)]",children:"Choose file"}),(0,t.jsxs)("span",{className:"mt-1 block text-xs leading-6 text-slate-500",children:["Upload a ",C," file. This file stays on the private document storage and is only available to admins reviewing your verification."]}),(0,t.jsx)("input",{type:"file",accept:A,className:"mt-3 block w-full text-sm",onChange:a=>{var s;return s=a.target.files?.[0]||null,void(f(a=>({...a,[e]:s})),_(e),u(null),x(null))}}),g[e]?(0,t.jsxs)("span",{className:"mt-2 block text-xs text-slate-500",children:["Selected file: ",g[e]?.name]}):null,(0,t.jsx)(N.A,{message:v[e]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void S(e,s?a?.id:void 0),disabled:!g[e]||p===e,className:"brand-button mt-4 !w-full !justify-center disabled:cursor-not-allowed disabled:opacity-60",children:p===e?"Uploading...":a?"Replace document":"Upload document"}),p===e?(0,t.jsx)("p",{className:"mt-2 text-xs text-slate-500",children:"Uploading..."}):null]}):l?(0,t.jsx)("p",{className:"mt-4 rounded-2xl border border-[rgba(17,19,57,0.08)] bg-slate-50 px-3 py-3 text-sm text-slate-600",children:l}):null]},e)})})]})},V=()=>(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(p.default,{embedded:!0,eyebrow:"Referral profile",title:"Manage your referral profile",description:"Update your name, optional email, and avatar. The same account identity is shared across any enabled workspaces."}),(0,t.jsx)(h.default,{embedded:!0,cancelTo:"/referral/profile-settings"})]}),J=({showSidebarMobile:e,activeTab:a,hasReferralRole:s,profile:r,profileLoading:l,refreshKey:n,onActivateReferral:i,onRefresh:d})=>(0,t.jsx)("div",{className:`min-w-0 flex-1 pb-6 transition-all duration-300 ${e?"blur-sm lg:blur-none":""}`,children:(0,t.jsx)("div",{className:"w-full",children:(()=>
1{if(!s)return(0,t.jsx)(F,{onActivateReferral:i});if(l&&!r)return(0,t.jsx)(R,{label:"Loading referral workspace..."});switch(a){case"notifications":return(0,t.jsx)(y.A,{workspace:"referral"});case"my-referrals":return(0,t.jsx)(O,{refreshKey:n});case"earnings":return(0,t.jsx)(W,{refreshKey:n});case"withdrawals":return(0,t.jsx)(B,{refreshKey:n,onRefresh:d});case"advertisements":return(0,t.jsx)(j.A,{role:"referral"});case"subscription":return(0,t.jsx)(Y,{profile:r,refreshKey:n,onRefresh:d,redirectOnBlocked:!0});case"bank-details":return(0,t.jsx)(G,{refreshKey:n,onRefresh:d});case"verification-documents":return(0,t.jsx)(H,{refreshKey:n,onRefresh:d});case"profile-settings":return(0,t.jsx)(V,{});default:return(0,t.jsx)(M,{profile:r,refreshKey:n})}})()})})},11727:(e,a,s)=>{s.d(a,{e:()=>r});var t=s(14232);function r(e,a,s,r){let l=(0,t.useRef)(null);(0,t.useEffect)(()=>{e&&a&&l.current!==String(e)&&(l.current=String(e),"referral"!==s&&r("referral"))},[e,a,s,r])}},30293:(e,a,s)=>{s.d(a,{A:()=>r});var t=s(37876);s(14232);let r=({message:e,id:a})=>e?(0,t.jsx)("p",{id:a,className:"mt-2 text-sm font-medium text-red-600",children:e}):null},43816:(e,a,s)=>{s.d(a,{Ry:()=>i,hQ:()=>n});var t=s(14232);let r=/^The given data was invalid\.?$/i,l=e=>{if("string"==typeof e)return e.trim()||null;if(Array.isArray(e)){for(let a of e){let e=l(a);if(e)return e}return null}if(e&&"object"==typeof e)for(let a of Object.values(e)){let e=l(a);if(e)return e}return null},n=e=>{let a=e?.data?.errors??e?.errors??e?.response?.data?.errors??null;return!a||"object"!=typeof a||Array.isArray(a)?{}:Object.entries(a).reduce((e,[a,s])=>{let t=l(s);return t&&(e[a]=t),e},{})},i=e=>{let[a,s]=(0,t.useState)(null),[l,i]=(0,t.useState)({}),d=(0,t.useCallback)(()=>{s(null)},[]),o=(0,t.useCallback)(e=>{i(a=>{if(!a[e])return a;let s={...a};return delete s[e],s})},[]),c=(0,t.useCallback)((...e)=>{(s(null),0===e.length)?i({}):i(a=>{if(0===Object.keys(a).length)return a;let s={...a};return e.forEach(e=>{delete s[e]}),s})},[]),u=(0,t.useCallback)((e,a)=>(s(null),i({[e]:a}),!1),[]),m=(0,t.useCallback)(e=>(s(null),i(e),!1),[]),x=(0,t.useCallback)((a,t)=>{let l=Object.entries(n(a)).reduce((a,[s,t])=>{let r=e?.[s]??s;return r&&(a[r]=t),a},{});i(l),s(((e,a,s=!1)=>{let t=e?.data?.message||e?.message||a;return s&&r.test(t)?null:t})(a,t,Object.keys(l).length>0))},[e]);return{formError:a,setFormError:s,clearFormError:d,fieldErrors:l,setFieldErrors:i,clearFieldError:o,clearErrors:c,setClientFieldError:u,setClientFieldErrors:m,applyApiError:x}}},61678:(e,a,s)=>{s.r(a),s.d(a,{default:()=>h});var t=s(37876),r=s(14232),l=s(91153),n=s(15396),i=s(59577),d=s(82133),o=s(72591),c=s(30293),u=s(75192),m=s(43816),x=s(19250),b=s(54347),p=s(90266);let h=({embedded:e=!1,eyebrow:a="User profile",title:s="Edit your profile",description:h="Update your display name, optional email, and avatar. Mobile number is managed by the account identity."})=>{let{user:g}=(0,b.A)(),[f,v]=(0,r.useState)(g?.name||""),[j,y]=(0,r.useState)(g?.email||""),[N,w]=(0,r.useState)(g?.mobile||""),[_,k]=(0,r.useState)(g?.avatarUrl||""),[S,A]=(0,r.useState)(null),[C,P]=(0,r.useState)(!0),[R,U]=(0,r.useState)(!1),[q,E]=(0,r.useState)(null),$=(0,r.useRef)(null),{formError:L,setFormError:T,fieldErrors:D,clearErrors:I,setClientFieldError:F,applyApiError:M}=(0,m.Ry)();(0,x.N)($,D),(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{P(!0);let a=await (0,o.RkI)(),s=a?.result;e&&s&&(v(s.name||""),y(s.email||""),w(s.mobile||""),k(s.avatarUrl||""))}catch(a){e&&T(a?.message||"Unable to load your profile.")}finally{e&&P(!1)}})(),()=>{e=!1}},[T]);let O=(0,r.useMemo)(()=>S?URL.createObjectURL(S):_||p.E$,[S,_]);(0,r.useEffect)(()=>{if(S)return()=>{URL.revokeObjectURL(O)}},[S,O]);let W=async e=>{if(e.preventDefault(),I(),E(null),f.trim().length<2)return void F("name","Enter your full name.");if(j.trim()&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j.trim()))return void F("email","Enter a valid email address or leave it blank.");try{U(!0);let e=await (0,o.AQ4)({name:f.trim(),email:j.trim()||void 0}),a=e?.result;if(S){let e=await (0,o.F4X)(S);a=e?.result||a}a&&(v(a.name||f.trim()),y(a.email||""),w(a.mobile||N),k(a.avatarUrl||_)),A(null),E("Profile updated successfully."),window.dispatchEvent(new Event("userChanged"))}catch(e){M(e,"Unable to update your profile.")}finally{U(!1)}};return C?(0,t.jsx)("section",{className:"rounded-[2rem] bg-white p-8 text-center shadow-[0_22px_60px_rgba(17,19,57,0.08)]",children:"Loading profile..."}):(0,t.jsxs)("section",{className:`${e?"w-full":"mx-auto max-w-3xl"} rounded-[2rem] border border-[rgba(17,19,57,0.08)] bg-white p-5 shadow-[0_30px_80px_rgba(17,19,57,0.12)] sm:p-8`,children:[(0,t.jsx)("div",{className:"flex flex-col gap-5 sm:flex-row sm:items-center sm:justify-between",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-semibold uppercase tracking-[0.2em] text-[var(--brand-red)]",children:a}),(0,t.jsx)("h1",{className:"mt-2 text-3xl font-semibold text-[var(--brand-navy)]",children:s}),(0,t.jsx)("p",{className:"mt-2 text-sm leading-7 text-slate-600",children:h})]})}),(0,t.jsxs)("form",{ref:$,className:"mt-8 space-y-6",onSubmit:W,children:[(0,t.jsx)(u.A,{message:L}),q?(0,t.jsx)("div",{className:"rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm font-medium text-emerald-700",children:q}):null,(0,t.jsxs)("div",{className:"flex flex-col gap-5 sm:flex-row sm:items-center",children:[(0,t.jsx)("img",{src:O,alt:f||"Profile avatar",className:"h-24 w-24 rounded-3xl border border-[rgba(17,19,57,0.08)] object-cover"}),(0,t.jsxs)("label",{className:"inline-flex cursor-pointer items-center gap-2 rounded-2xl border border-[rgba(17,19,57,0.12)] bg-[rgba(17,19,57,0.04)] px-4 py-3 text-sm font-semibold text-[var(--brand-navy)] hover:border-[rgba(156,3,5,0.2)]",children:[(0,t.jsx)(l.A,{className:"h-4 w-4 text-[var(--brand-red)]"}),"Upload avatar",(0,t.jsx)("input",{type:"file",accept:"image/png,image/jpeg,image/jpg,image/webp",className:"sr-only",onChange:e=>{A(e.target.files?.[0]||null),I("avatar")}})]})]}),(0,t.jsx)(c.A,{message:D.avatar}),(0,t.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"sm:col-span-2",children:[(0,t.jsx)("label",{className:"mb-2 block text-sm font-semibold text-slate-700",children:"Full name"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(n.A,{className:"pointer-events-none absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 text-[var(--brand-red)]"}),(0,t.jsx)("input",{value:f,onChange:e=>{v(e.target.value),I("name"),E(null)},"aria-invalid":!!D.name,"aria-describedby":D.name?"profile-name-error":void 0,className:`w-full rounded-2xl border px-12 py-3.5 outline-none transition focus:border-[var(--brand-red)] focus:ring-4 focus:ring-[rgba(156,3,5,0.08)] ${D.name?"border-red-300 bg-red-50/40":"border-[rgba(17,19,57,0.12)]"}`})]}),(0,t.jsx)(c.A,{id:"profile-name-error",message:D.name})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"mb-2 block text-sm font-semibold text-slate-700",children:["Email address ",(0,t.jsx)("span",{className:"font-normal text-slate-400",children:"(optional)"})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(i.A,{className:"pointer-events-none absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 text-[var(--brand-red)]"}),(0,t.jsx)("input",{value:j,onChange:e=>{y(e.target.value),I("email"),E(null)},"aria-invalid":!!D.email,"aria-describedby":D.email?"profile-email-error":void 0,className:`w-full rounded-2xl border px-12 py-3.5 outline-none transition focus:border-[var(--brand-red)] focus:ring-4 focus:ring-[rgba(156,3,5,0.08)] ${D.email?"border-red-300 bg-red-50/40":"border-[rgba(17,19,57,0.12)]"}`})]}),(0,t.jsx)(c.A,{id:"profile-email-error",message:D.email})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mb-2 block text-sm font-semibold text-slate-700",children:"Mobile number"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(d.A,{className:"pointer-events-none absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 text-slate-400"}),(0,t.jsx)("input",{value:N,readOnly:!0,className:"w-full rounded-2xl border border-[rgba(17,19,57,0.08)] bg-[rgba(17,19,57,0.04)] px-12 py-3.5 text-slate-600 outline-none"})]})]})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)("button",{type:"submit",disabled:R,className:"brand-button !justify-center disabled:cursor-not-allowed disabled:opacity-60",children:R?"Saving...":"Save profile"})})]})]})}},85752:(e,a,s)=>{s.d(a,{N:()=>r,x:()=>l});let t=["mercury-uat.phonepe.com","mercury.phonepe.com"];function r(e){let a=String(e??"").trim();if(!a)return null;try{let e=new URL(a),s=[...t,..."mercury.phonepe.com".split(","),"https://api2.prnvservices.com","https://api2.prnvservices.com",window.location.host].flat().map(e=>{let a=e.trim().toLowerCase();try{return a.includes("://")?new URL(a).host:a}catch{return a}}
1).filter(Boolean),r=e=>["localhost","127.0.0.1","[::1]"].includes(e.toLowerCase()),l="http:"===e.protocol&&r(window.location.hostname)&&r(e.hostname);if("https:"!==e.protocol&&!l||0===s.length||e.username||e.password)return null;return s.includes(e.host.toLowerCase())?e.toString():null}catch{return null}}function l(e){let a=String(e??"").trim();if(!a)return null;try{let e=new URL(a);return"https:"===e.protocol?e.toString():null}catch{return null}}}}]);
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.