1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AuditLogs-BLImvoxD.js","assets/index-Twknsoqh.js","assets/index-gLbLQ3-M.css","assets/App-CoeTHGpP.js","assets/module-C38F6iXw.js","assets/onesignal-Cul85E4C.js","assets/breadcrumbs-BIs8L3tZ.js","assets/App-CTZuBZOi.css","assets/table-EF5DmJ1L.js","assets/use-audit-logs-Bb4VkJKx.js","assets/UpgradePrompt-DHWE5vCK.js","assets/filter-C35fvrAw.js","assets/Team-BQF5bD6I.js","assets/avatar-BzL9ztLI.js","assets/circle-check-pP4gHohW.js","assets/format-KN3n2iPW.js","assets/ellipsis-CTefDpRb.js","assets/user-cog-DiPfLRAY.js","assets/Billing-CxBNWYtB.js","assets/radio-group-D1ufASVu.js","assets/switch-BpqH3NHs.js","assets/use-regional-pricing-x5dPsLD7.js","assets/use-tier-features-jKgSJAMY.js"])))=>i.map(i=>d[i]); 2import{r as x,j as e,_ as Se}from"./index-Twknsoqh.js";import{q as ns,v as H,w as K,Z as A,bA as rs,ao as ls,ap as cs,B as S,ar as os,as as Pe,au as ds,av as ms,aw as us,ax as xs,ay as hs,az as ps,aA as gs,aB as vs,aC as fs,j as f,a9 as G,aa as Y,ab as Q,ac as z,ad as P,I as T,am as D,b0 as ys,b1 as js,b2 as bs,b3 as Ns,b4 as ws,bB as Cs,x as W,H as X,y as se,V as xe,O as ae,ak as Ue,s as L,aV as he,a$ as Z,_ as ge,aX as qe,r as Me,bC as Ce,S as re,L as De,Y as de,aQ as Be,g as B,D as Ae,aN as Oe,C as te,a5 as _e,K as Ge,b as _s,aU as Ye,f as pe,a8 as ks,c as Ss,bD as ze,Q as He,a2 as Is,U as Ke,aY as Re,ah as $e,J as Qe,bE as Ts,bF as Ps,bG as Ds,bH as Bs,m as Ee,bz as As,bI as Rs,a_ as Es,X as be,bf as Le,bJ as Fe,bi as Ls,M as Ve,n as Ne,bK as Fs,bL as Vs}from"./App-CoeTHGpP.js";import{b as Je,P as ke,g as Us,c as qs,d as Ms,a as Os,e as Gs}from"./use-payment-methods-CA0sFraL.js";import{E as Ys}from"./ellipsis-CTefDpRb.js";import{P as zs}from"./pencil-7ebStPSk.js";import{S as Ie}from"./switch-BpqH3NHs.js";import{C as ue}from"./circle-check-pP4gHohW.js";import{I as Xe}from"./IdentityLevelBadge-kwIskwQx.js";import{b as We,G as ne,i as Ze,a as es,g as ss}from"./jurisdiction-config-CzdPX1rC.js";import{v as as}from"./government-id-validation-N7fCRTlB.js";import{S as ts}from"./save-BuZj4Lgv.js";import{P as Hs}from"./progress-Cg0lKjFV.js";import{u as Ks}from"./use-tier-features-jKgSJAMY.js";import{T as $s,a as Qs,b as me}from"./tabs-DGBJ-l_6.js";import{L as Js}from"./LogoImage-BLuNWdoD.js";import{I as Xs}from"./info-DOvp_JpT.js";import{I as we}from"./image-CspEvWex.js";import{P as Ws}from"./phone-DfJhEWUe.js";import{M as Zs}from"./map-pin-q_o489ro.js";import"./module-C38F6iXw.js";import"./onesignal-Cul85E4C.js";import"./breadcrumbs-BIs8L3tZ.js";/** 3 * @license lucide-react v0.462.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const ea=ns("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]),sa=new Set(["050e73c2-6c18-4d76-b03d-3f93e3555fdb","1344d2d6-c0e0-4813-828d-76b67f96feec","2770739c-7860-4ae1-b4b2-6555d9cb8b06","27ef4234-a56a-4e50-9ff5-79303f3c8cb6","347e8b2f-56c2-480a-bf5f-02ef8528f393","58816778-b286-4dce-aa2a-497d75b3226e","654906bf-c666-4099-92bf-e76bef0d996d","66319d3d-df2f-4d8b-85da-c13e0f5f6486","70255dd3-3974-49e7-8fb4-f100394e0031","87d2b8b8-8b82-49a1-b00c-8a9363a26471","a2190772-21a8-4d5e-bc78-3e8860a1de6d","b42ad810-58cb-4ab5-a1ec-3912f830db31","cd3ca130-734d-4b98-890b-6e0c3f538d3d","e9d3efe8-564e-4b5d-b543-711c390622de","eb5604cc-d8bb-49dc-a2ae-d99a375f3ac1","f54f20d6-0e43-40cf-a960-b5fdbe59172c","f689fc04-df7f-4822-ad7d-873abf3a86af","ff9548b8-94a6-424d-bb7f-b6f20dd9e21d"]);function aa({methods:s,onEdit:i,onDelete:l,isDeleting:c,canManage:n=!1,canDelete:r=!1}){const[N,u]=x.useState(null);if(s.length===0)return e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"No payment methods configured for this currency."});const h=d=>{var o;return((o=ke.find(w=>w.value===d))==null?void 0:o.label)||d},y=(d,o)=>(Je[d]||[]).filter(j=>o[j.key]).map(j=>({label:j.label,value:o[j.key]}));return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3",children:s.map(d=>{const o=d.instructions||{},w=y(d.provider_type,o);return e.jsx(H,{className:"relative",children:e.jsx(K,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:d.display_name}),e.jsx(A,{variant:"outline",className:"text-xs shrink-0",children:h(d.provider_type)}),d.is_default&&e.jsxs(A,{variant:"secondary",className:"text-xs shrink-0",children:[e.jsx(rs,{className:"h-3 w-3 mr-1"}),"Default"]})]}),w.length>0&&e.jsx("div",{className:"mt-2 space-y-1",children:w.map(({label:j,value:_})=>e.jsxs("div",{className:"flex gap-2 text-xs",children:[e.jsxs("span",{className:"text-muted-foreground shrink-0",children:[j,":"]}),e.jsx("span",{className:"font-mono truncate",children:_})]},j))})]}),n&&e.jsxs(ls,{children:[e.jsx(cs,{asChild:!0,children:e.jsx(S,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:e.jsx(Ys,{className:"h-4 w-4"})})}),e.jsxs(os,{align:"end",children:[e.jsxs(Pe,{onClick:()=>i(d),children:[e.jsx(zs,{className:"h-4 w-4 mr-2"}),"Edit"]}),r&&e.jsxs(Pe,{className:"text-destructive",onClick:()=>u(d.id),children:[e.jsx(ds,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})},d.id)})}),e.jsx(ms,{open:!!N,onOpenChange:()=>u(null),children:e.jsxs(us,{children:[e.jsxs(xs,{children:[e.jsx(hs,{children:"Delete payment method?"}),e.jsx(ps,{children:"This will remove this payment method. It won't affect already-issued invoices (their payment instructions are frozen at issuance)."})]}),e.jsxs(gs,{children:[e.jsx(vs,{children:"Cancel"}),e.jsx(fs,{onClick:()=>{N&&l(N),u(null)}
7,disabled:c,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function ta({initialValues:s,onSubmit:i,onCancel:l,isLoading:c,currencyCode:n}){const[r,N]=x.useState((s==null?void 0:s.provider_type)||""),[u,h]=x.useState((s==null?void 0:s.display_name)||""),[y,d]=x.useState((s==null?void 0:s.instructions)||{}),[o,w]=x.useState((s==null?void 0:s.is_default)||!1),j=r==="bank_transfer"?Us(n):Je[r]||[],_=m=>{N(m),d({});const I=ke.find(E=>E.value===m);I&&!u&&h(n?`${I.label} (${n})`:I.label)},V=(m,I)=>{d(E=>({...E,[m]:I}))},R=m=>{m.preventDefault(),i({provider_type:r,display_name:u,instructions:y,is_default:o})},g=j.filter(m=>m.required),q=r&&u&&g.every(m=>{var I;return(I=y[m.key])==null?void 0:I.trim()});return e.jsxs("form",{onSubmit:R,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Provider Type"}),e.jsxs(G,{value:r,onValueChange:_,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:"Select how you receive payments"})}),e.jsx(z,{children:ke.map(m=>e.jsx(P,{value:m.value,children:m.label},m.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Display Name"}),e.jsx(T,{value:u,onChange:m=>h(m.target.value),placeholder:n?`e.g. Bank Transfer (${n})`:"e.g. Bank Transfer",maxLength:D.SHORT_TEXT})]}),j.length>0&&e.jsxs("div",{className:"space-y-3 rounded-lg border p-4 bg-muted/30",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Payment Details"}),j.map(m=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs(f,{className:"text-sm",children:[m.label,m.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(T,{value:y[m.key]||"",onChange:I=>V(m.key,I.target.value),placeholder:m.placeholder,maxLength:D.SHORT_TEXT,inputMode:m.inputMode})]},m.key))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{checked:o,onCheckedChange:w,id:"is-default"}),e.jsx(f,{htmlFor:"is-default",className:"text-sm",children:"Set as default for this currency"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(S,{type:"button",variant:"outline",onClick:l,disabled:c,children:"Cancel"}),e.jsx(S,{type:"submit",disabled:!q||c,children:c?"Saving...":s?"Update":"Add Payment Method"})]})]})}function ia({open:s,onOpenChange:i,businessId:l,currencyAccountId:c,currencyCode:n,editMethod:r}){const N=qs(),u=Ms(),h=!!r,y=N.isPending||u.isPending,d=async o=>{h&&r?await u.mutateAsync({id:r.id,currency_account_id:c,display_name:o.display_name,instructions:o.instructions,is_default:o.is_default}):await N.mutateAsync({business_id:l,currency_account_id:c,provider_type:o.provider_type,display_name:o.display_name,instructions:o.instructions,is_default:o.is_default}),i(!1)};return e.jsx(ys,{open:s,onOpenChange:i,children:e.jsxs(js,{className:"sm:max-w-md",children:[e.jsxs(bs,{children:[e.jsx(Ns,{children:h?"Edit Payment Method":"Add Payment Method"}),e.jsx(ws,{children:h?"Update how you receive payments for this currency.":"Configure how clients can pay you for this currency."})]}),e.jsx(ta,{initialValues:r?{provider_type:r.provider_type,display_name:r.display_name,instructions:r.instructions||{},is_default:r.is_default}:void 0,onSubmit:d,onCancel:()=>i(!1),isLoading:y,currencyCode:n})]})})}function na({businessId:s,canManage:i,canDelete:l}){const{data:c,isLoading:n}=Cs(s),{data:r,isLoading:N}=Os(s),u=Gs(),[h,y]=x.useState(!1),[d,o]=x.useState(null),[w,j]=x.useState(null),_=c==null?void 0:c.find(g=>g.id===d),V=g=>{o(g),j(null),y(!0)},R=g=>{o(g.currency_account_id),j(g),y(!0)};return n||N?e.jsxs(H,{className:"lg:col-span-2",children:[e.jsxs(W,{children:[e.jsx(X,{className:"h-6 w-48"}),e.jsx(X,{className:"h-4 w-72"})]}),e.jsx(K,{children:e.jsx(X,{className:"h-32"})})]}
7):c!=null&&c.length?e.jsxs(e.Fragment,{children:[e.jsxs(H,{className:"lg:col-span-2",children:[e.jsxs(W,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-5 w-5"}),"Manual Payment Instructions"]}),e.jsx(ae,{children:"Add offline payment details (bank transfer, Wise, crypto, etc.) that appear on your invoices. These are informational only â for online payments, use the section above."})]}),e.jsx(K,{className:"space-y-6",children:c.map(g=>{const q=(r==null?void 0:r.filter(m=>m.currency_account_id===g.id))||[];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{variant:"outline",className:"font-mono",children:g.currency}),e.jsx("span",{className:"text-sm text-muted-foreground",children:g.name||`${g.currency} Account`}),g.is_default&&e.jsx(A,{variant:"secondary",className:"text-xs",children:"Primary"})]}),i&&e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>V(g.id),children:[e.jsx(Ue,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx(aa,{methods:q,onEdit:R,onDelete:m=>u.mutate(m),isDeleting:u.isPending,canManage:i,canDelete:l})]},g.id)})})]}),d&&e.jsx(ia,{open:h,onOpenChange:y,businessId:s,currencyAccountId:d,currencyCode:_==null?void 0:_.currency,editMethod:w})]}):null}function ra(){const[s,i]=x.useState(!1);return{initiateConnect:async c=>{i(!0);try{const{data:n,error:r}=await L.functions.invoke("create-connect-account",{body:{business_id:c}});return r?(he(r,{hook:"useStripeConnect",action:"initiateConnect"}),Z.error(r.message||"Failed to start Stripe Connect setup"),null):n!=null&&n.error?(Z.error(n.error),null):n!=null&&n.url?(window.location.href=n.url,n):(Z.error("No onboarding URL received"),null)}catch(n){return he(n,{hook:"useStripeConnect",action:"initiateConnect"}),Z.error("Failed to initiate Stripe Connect"),null}finally{i(!1)}},loading:s}}function la(){const[s,i]=x.useState(!1);return{createSubaccount:async(c,n,r,N)=>{i(!0);try{const{data:u,error:h}=await L.functions.invoke("create-paystack-subaccount",{body:{business_id:c,bank_code:n,account_number:r,business_name:N}});return h?(he(h,{hook:"usePaystackSubaccount",action:"createSubaccount"}),Z.error(h.message||"Failed to create Paystack subaccount"),null):u!=null&&u.error?(Z.error(u.error),null):u!=null&&u.subaccount_code?(Z.success(`Bank account verified: ${u.account_name}`),u):(Z.error("Failed to set up bank account"),null)}catch(u){return he(u,{hook:"usePaystackSubaccount",action:"createSubaccount"}),Z.error("Failed to set up bank account"),null}finally{i(!1)}},loading:s}}const ca=[{code:"044",name:"Access Bank"},{code:"023",name:"Citibank Nigeria"},{code:"063",name:"Diamond Bank"},{code:"050",name:"Ecobank Nigeria"},{code:"070",name:"Fidelity Bank"},{code:"011",name:"First Bank of Nigeria"},{code:"214",name:"First City Monument Bank"},{code:"058",name:"Guaranty Trust Bank"},{code:"030",name:"Heritage Bank"},{code:"301",name:"Jaiz Bank"},{code:"082",name:"Keystone Bank"},{code:"526",name:"Parallex Bank"},{code:"101",name:"Providus Bank"},{code:"076",name:"Polaris Bank"},{code:"221",name:"Stanbic IBTC Bank"},{code:"068",name:"Standard Chartered Bank"},{code:"232",name:"Sterling Bank"},{code:"100",name:"Suntrust Bank"},{code:"032",name:"Union Bank of Nigeria"},{code:"033",name:"United Bank For Africa"},{code:"215",name:"Unity Bank"},{code:"035",name:"Wema Bank"},{code:"057",name:"Zenith Bank"},{code:"999992",name:"Opay"},{code:"999991",name:"PalmPay"},{code:"50211",name:"Kuda Bank"}];function oa({business:s}){const i=ge(),{toast:l}=qe(),{initiateConnect:c,loading:n}=ra(),{createSubaccount:r,loading:N}=la(),{tier:u}=Me(),h=u==="starter",[y,d]=x.useState(""),[o,w]=x.useState(""),j=s.jurisdiction==="NG",_=s.stripe_connect_status||"not_started",V=s.paystack_subaccount_status||"not_started",R=async b=>{try{const{error:a}=await L.from("businesses").update({online_payments_enabled:b}).eq("id",s.id);if(a)throw a;i.invalidateQueries({queryKey:["businesses"]}),l({title:b?"Online payments enabled":"Online payments disabled",description:b?"Clients can now pay your invoices online.":"The Pay Online button will no longer appear on your invoices."})}catch(a){l({title:"Error",description:a.message||"Failed to update setting",variant:"destructive"})}},g=()=>{c(s.id)},q=async()=>
7{if(!y||!o){l({title:"Missing fields",description:"Please select a bank and enter your account number.",variant:"destructive"});return}await r(s.id,y,o,s.name)&&(i.invalidateQueries({queryKey:["businesses"]}),d(""),w(""))},m=b=>{switch(b){case"active":return e.jsxs(A,{variant:"default",className:"bg-emerald-500/10 text-emerald-700 border-emerald-200",children:[e.jsx(ue,{className:"h-3 w-3 mr-1"})," Connected"]});case"pending":return e.jsxs(A,{variant:"secondary",className:"bg-amber-500/10 text-amber-700 border-amber-200",children:[e.jsx(_e,{className:"h-3 w-3 mr-1"})," Pending"]});case"restricted":return e.jsxs(A,{variant:"secondary",className:"bg-orange-500/10 text-orange-700 border-orange-200",children:[e.jsx(te,{className:"h-3 w-3 mr-1"})," Restricted"]});default:return e.jsx(A,{variant:"outline",children:"Not Connected"})}},E=(s.verification_status||"unverified")==="verified";return e.jsxs(H,{children:[e.jsxs(W,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-5 w-5"}),"Online Payments"]}),e.jsx(ae,{children:"Let clients pay invoices online and receive funds directly into your account"})]}),e.jsxs(K,{className:"space-y-6",children:[!E&&!h&&e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-5 w-5 text-amber-600"}),e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Business verification required"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete business verification to accept online payments. You can verify by completing Stripe Connect onboarding or uploading identity documents for manual review."}),e.jsx(S,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs(De,{to:`/b/${s.id}/settings`,children:["Go to Verification ",e.jsx(de,{className:"h-3.5 w-3.5 ml-1"})]})})]}),h&&e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-4 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Upgrade to accept online payments"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Online payments are available on paid plans. Upgrade to let clients pay your invoices instantly via card."}),e.jsx(S,{size:"sm",variant:"default",asChild:!0,children:e.jsxs(De,{to:`/b/${s.id}/billing`,children:["Upgrade Plan ",e.jsx(de,{className:"h-3.5 w-3.5 ml-1"})]})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Enable online payments"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h?"Available on paid plans only.":'A "Pay Online" button will appear on your public invoice pages.'})]}),e.jsx(Ie,{checked:!h&&(s.online_payments_enabled||!1),onCheckedChange:R,disabled:h||!E})]}),e.jsx(Be,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"How payments reach you"})]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:[{step:"1",icon:xe,title:"Client pays",desc:'Client clicks "Pay Now" on your invoice and pays via card'},{step:"2",icon:Ce,title:"Platform fee deducted",desc:"A small platform fee is deducted automatically"},{step:"3",icon:ea,title:"You receive funds",desc:"The rest is settled directly into your connected account"}].map(b=>e.jsxs("div",{className:"flex gap-3 rounded-lg border border-dashed p-3",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:b.step}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:b.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b.desc})]})]},b.step))})]}),e.jsx(Be,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Payout Setup"}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Stripe Connect"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(International payments)"})]}),m(_)]}),_==="active"?e.jsx("p",{className:"text-xs text-muted-foreground",children:"International payments are settled directly to your Str
7ipe account."}):_==="pending"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Stripe account is being set up. Complete onboarding to start receiving payments."}),e.jsxs(S,{size:"sm",variant:"outline",onClick:g,disabled:n,children:[n?e.jsx(B,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Ae,{className:"h-4 w-4 mr-2"}),"Continue Setup"]})]}):_==="restricted"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-amber-600",children:"Your Stripe account needs attention. Some requirements need to be met."}),e.jsxs(S,{size:"sm",variant:"outline",onClick:g,disabled:n,children:[n?e.jsx(B,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Ae,{className:"h-4 w-4 mr-2"}),"Resolve Issues"]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect a Stripe account to receive international payments directly. Stripe handles identity verification."}),e.jsxs(S,{size:"sm",onClick:g,disabled:n||!E,children:[n?e.jsx(B,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(de,{className:"h-4 w-4 mr-2"}),"Connect Stripe Account"]})]})]}),j&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Bank Account"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(NGN payments via Paystack)"})]}),m(V)]}),V==="active"?e.jsx("p",{className:"text-xs text-muted-foreground",children:"NGN payments are settled directly to your bank account via Paystack."}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add your Nigerian bank account to receive NGN payments directly."}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(f,{htmlFor:"bank",className:"text-xs",children:"Bank"}),e.jsxs(G,{value:y,onValueChange:d,children:[e.jsx(Y,{id:"bank",children:e.jsx(Q,{placeholder:"Select bank..."})}),e.jsx(z,{children:ca.map(b=>e.jsx(P,{value:b.code,children:b.name},b.code))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(f,{htmlFor:"accountNumber",className:"text-xs",children:"Account Number"}),e.jsx(T,{id:"accountNumber",placeholder:"Account number",value:o,onChange:b=>w(b.target.value.replace(/\D/g,"").slice(0,10)),maxLength:10})]})]}),e.jsxs(S,{size:"sm",onClick:q,disabled:N||!y||!o||!E,children:[N?e.jsx(B,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(de,{className:"h-4 w-4 mr-2"}),"Verify & Connect"]})]})]})]}),!h&&s.online_payments_enabled&&_!=="active"&&V!=="active"&&e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800 p-3 flex items-start gap-2",children:[e.jsx(te,{className:"h-4 w-4 text-amber-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400",children:"Online payments are enabled but your payout account is not connected. Clients cannot pay until setup is complete."})]}),e.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:_==="active"||V==="active"?"â Payments are processed securely via Stripe. Funds go directly to your account.":"Connect your payout account above to start receiving payments directly."})})]})]})}function da(s){return Ge({queryKey:["verification-documents",s],queryFn:async()=>{if(!s)return[];const{data:i,error:l}=await L.from("verification_documents").select("*").eq("business_id",s).order("created_at",{ascending:!1});if(l)throw l;return i},enabled:!!s})}function ma(){const s=ge(),{user:i}=_s();return Ye({mutationFn:async({businessId:l,file:c,documentType:n})=>{if(!i)throw new Error("Not authenticated");const r=10*1024*1024;if(c.size>r)throw new Error("File too large. Maximum size is 10MB.");if(!["application/pdf","image/png","image/jpeg","image/webp"].includes(c.type))throw new Error("Invalid file type. Please upload a PDF or image file.");const u=c.name.split(".").pop(),h=`${l}/${crypto.randomUUID()}.${u}`,{error:y}=await L.storage.from("verification-documents").upload(h,c);if(y)throw y;const{data:d}=await L.storage.from("verification-documents").createSignedUrl(h,60*60*24*365),o=(d==null?void 0:d.signedUrl)||h,{data:w,error:j}=await L.from("verification_documents").insert({business_id:l,uploaded_by:i.id,document_type:n,file_url:o,file_path:h,file_name:c.name}).select().single();if(j)throw j;return w},onSuccess:(l,c)=>{s.invalidateQueries({queryKey:["verification-documents",c.businessId]}
7),pe({title:"Document uploaded",description:"Your verification document has been uploaded successfully."})},onError:l=>{pe({title:"Upload failed",description:l.message,variant:"destructive"})}})}function ua(){const s=ge();return Ye({mutationFn:async i=>{const{error:l}=await L.from("businesses").update({verification_status:"pending_review",verification_source:"manual_review",document_verification_status:"pending_review",verification_submitted_at:new Date().toISOString()}).eq("id",i);if(l)throw l},onSuccess:(i,l)=>{s.invalidateQueries({queryKey:["user-business"]}),s.invalidateQueries({queryKey:["user-businesses"]}),pe({title:"Submitted for review",description:"Your business will be reviewed by our team. You'll be notified of the result."}),L.functions.invoke("send-verification-notification",{body:{type:"submission",business_id:l}}).catch(()=>{})},onError:i=>{pe({title:"Submission failed",description:i.message,variant:"destructive"})}})}const xa=[{value:"cac_certificate",label:"CAC Certificate"},{value:"tax_clearance",label:"Tax Clearance Certificate"},{value:"tin_certificate",label:"TIN Certificate"},{value:"business_license",label:"Business License"},{value:"utility_bill",label:"Utility Bill (Address Proof)"},{value:"other",label:"Other Document"}],ha=[{value:"passport",label:"Passport"},{value:"national_id",label:"National ID Card"},{value:"drivers_license",label:"Driver's License"},{value:"utility_bill",label:"Utility Bill (Address Proof)"},{value:"other",label:"Other Document"}];function pa({business:s}){const i=s.verification_status||"unverified",l=s.verification_source||"none",c=s.rejection_reason,n=s.entity_type||"business",r=n==="individual",{isFree:N}=ks(),u=Ss(),h=r?ha:xa,{data:y,isLoading:d}=da(s.id),o=ma(),w=ua(),j=x.useRef(null),[_,V]=x.useState(r?"passport":"cac_certificate"),R=["unverified","self_declared","rejected","requires_action"].includes(i),g=i==="pending_review",q=i==="verified",m=i==="requires_action",I=s.verification_notes,E=ze(),b=s.government_id_type??"",a=s.government_id_value??"",v=s.jurisdiction??"",[M,k]=x.useState(b),[F,le]=x.useState(a);x.useEffect(()=>{k(b),le(a)},[b,a]);const $=We(v),ie=M?ne[M]:void 0,J=as(M||void 0,F,v),ve=(M!==b||F!==a)&&(!F||J.valid),fe=()=>{E.mutate({businessId:s.id,updates:{government_id_type:M||null,government_id_value:F||null}})},ye=async t=>{var C;const p=(C=t.target.files)==null?void 0:C[0];p&&(await o.mutateAsync({businessId:s.id,file:p,documentType:_}),j.current&&(j.current.value=""))},ee=()=>{w.mutate(s.id)},ce=t=>{switch(t){case"approved":return e.jsxs(A,{variant:"default",className:"bg-emerald-500/10 text-emerald-700 border-emerald-200",children:[e.jsx(ue,{className:"h-3 w-3 mr-1"}),"Approved"]});case"rejected":return e.jsxs(A,{variant:"destructive",children:[e.jsx(Re,{className:"h-3 w-3 mr-1"}),"Rejected"]});case"pending":default:return e.jsxs(A,{variant:"secondary",children:[e.jsx(_e,{className:"h-3 w-3 mr-1"}),"Pending"]})}};return e.jsxs(H,{children:[e.jsxs(W,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-5 w-5"}),e.jsx(se,{children:r?"Identity Verification":"Business Verification"})]}),e.jsx(Xe,{level:i,source:l,rejectionReason:c,entityType:n})]}),e.jsx(ae,{children:r?"Verify your identity to enable online payments and build trust with clients.":"Verify your business identity to enable online payments and build trust with clients."})]}),e.jsxs(K,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs(f,{className:"text-sm font-medium",children:["Government ID",!r&&e.jsx("span",{className:"text-destructive ml-0.5",children:"*"})]}),F&&J.valid&&e.jsxs(A,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(ue,{className:"h-3 w-3"}),"Format OK"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Provide your government-issued ID (tax/business number or personal ID). This appears on your invoices and helps reviewers verify your identity faster."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(G,{value:M,onValueChange:k,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:"ID Type"})}),e.jsxs(z,{className:"max-h-72",children:[$.recommended.length>0&&e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground",children:$.countryName?`Recommended for ${$.countryName}`:"Recommended"}),$.recommended.map(t=>e.jsx(P,{value:t,children:ne[t].long},t)),$.other.length>0&&e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground border-t mt
7-1 pt-2",children:"Other"}),$.other.map(t=>e.jsx(P,{value:t,children:ne[t].long},t))]})]}),e.jsx(T,{placeholder:(ie==null?void 0:ie.example)||"Enter ID number",value:F,onChange:t=>le(t.target.value),maxLength:D.TAX_ID,"aria-invalid":F.length>0&&!J.valid})]}),F.length>0&&!J.valid&&J.message&&e.jsx("p",{className:"text-xs text-destructive",children:J.message}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(S,{size:"sm",variant:"outline",onClick:fe,disabled:!ve||E.isPending,children:[E.isPending?e.jsx(B,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ts,{className:"h-4 w-4 mr-2"}),"Save ID"]})})]}),N&&!q&&e.jsxs(He,{className:"border-primary/30 bg-primary/5",children:[e.jsx(Is,{className:"h-4 w-4"}),e.jsxs(Ke,{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Business verification requires a paid plan. Upgrade to unlock verification and online payments."}),e.jsx(S,{size:"sm",variant:"default",onClick:()=>u("/app/business/billing"),children:"Upgrade"})]})]}),q&&e.jsxs("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50 dark:bg-emerald-950/20 dark:border-emerald-900 p-4 flex items-start gap-3",children:[e.jsx(ue,{className:"h-5 w-5 text-emerald-600 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-emerald-800 dark:text-emerald-200",children:r?"Identity verified":"Business verified"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l==="stripe_kyc"?"Verified via Stripe identity verification.":l==="manual_review"?"Verified by Invoicemonk team review.":l==="government_api"?"Verified via government registry.":r?"Your identity has been verified.":"Your business has been verified."})]})]}),g&&e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900 p-4 flex items-start gap-3",children:[e.jsx(_e,{className:"h-5 w-5 text-amber-600 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Awaiting admin review"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your documents have been submitted and are being reviewed by our team. You'll be notified of the result."})]})]}),m&&e.jsxs("div",{className:"rounded-lg border border-amber-300 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800 p-4 flex items-start gap-3",children:[e.jsx(te,{className:"h-5 w-5 text-amber-600 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Your verification needs attention"}),I&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:I}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Please upload the requested documents and resubmit for review."})]})]}),i==="rejected"&&e.jsxs("div",{className:"rounded-lg border border-destructive/50 bg-destructive/5 p-4 flex items-start gap-3",children:[e.jsx(Re,{className:"h-5 w-5 text-destructive shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:"Verification rejected"}),c&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Reason: ",c]}),I&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:I}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"You can upload new documents and resubmit for review."})]})]}),r&&R&&e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-4 flex items-start gap-3",children:[e.jsx(te,{className:"h-5 w-5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Government-issued ID required"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You must upload a valid government-issued ID (passport, national ID, or driver's license) to receive payments."})]})]}),R&&!N&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm font-medium",children:r?"Upload identity documents":"Upload verification documents"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r?"Upload your passport, national ID, or driver's license. Accepted formats: PDF, PNG, JPG (max 10MB).":"Upload your CAC certificate, tax clearance, or other business registration documents. Accepted formats: PDF, PNG, JPG (max 10MB)."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(G,{value:_,onValueChange:V,children:[e.jsx(Y,{className:"w-full sm:w-[220px]",children:e.jsx(Q,{})}),e.jsx(z,{children:h.map(t=>e.jsx(P,{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{children:[e.jsx("input",{ref:j,type:"file",accept:".pdf,.png,.jpg,.jpeg,.webp",onChange:ye,className:"hidden"}),e.jsxs(S,{variant:"outline",onClick:()=>{var t;return(t=j.current)==null?void 0:t.click()},disabled:o.isPending,children:[o.isPending?e.jsx(B,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx($e,{className:"h-4 w-4 mr-2"}),"Upload Document"]})]})]})]}),d?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(B,{className:"h-4 w-4 animate-spin"}),"Loading documents..."]}):y&&y.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Uploaded documents"}),e.jsx("div",{className:"space-y-2",children:y.map(t=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Qe,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.file_name}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:t.document_type.replace(/_/g," ")})]})]}),ce(t.status)]},t.id))})]}):R?e.jsxs("div",{className:"rounded-lg border border-dashed p-6 text-center",children:[e.jsx(te,{className:"h-8 w-8 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No documents uploaded yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Upload documents above to start the verification process."})]}):null,R&&!N&&y&&y.length>0&&e.jsxs(S,{onClick:ee,disabled:w.isPending,children:[w.isPending?e.jsx(B,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(re,{className:"h-4 w-4 mr-2"}),"Submit for Review"]}),R&&e.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("strong",{children:"Tip:"})," You can also verify instantly by completing Stripe Connect onboarding in the Online Payments section below."]})})]})]})}
7const ga=[{key:"name",label:"Business Name",getValue:s=>{var i;return!!((i=s.name)!=null&&i.trim())}},{key:"legalName",label:"Legal Name",getValue:s=>{var i;return!!((i=s.legalName)!=null&&i.trim())},condition:s=>s.entityType!=="individual"},{key:"governmentId",label:"Government ID",getValue:s=>{var i,l;return!!((i=s.governmentIdValue)!=null&&i.trim()||(l=s.taxId)!=null&&l.trim())},condition:s=>s.entityType==="business"||!s.entityType||Ze(s.jurisdiction)},{key:"cacNumber",label:"Commercial Registration",getValue:s=>{var i;return!!((i=s.cacNumber)!=null&&i.trim())},condition:s=>s.entityType!=="individual"&&es(s.jurisdiction)},{key:"email",label:"Email",getValue:s=>{var i;return!!((i=s.email)!=null&&i.trim())}},{key:"addressCity",label:"City",getValue:s=>{var i;return!!((i=s.addressCity)!=null&&i.trim())},condition:s=>s.entityType!=="individual"},{key:"addressCountry",label:"Country",getValue:s=>{var i;return!!((i=s.addressCountry)!=null&&i.trim())}},{key:"vatRegistrationNumber",label:"VAT Registration Number",getValue:s=>{var i;return!!((i=s.vatRegistrationNumber)!=null&&i.trim())},condition:s=>ss(s.jurisdiction||"").showVat&&s.isVatRegistered===!0},{key:"documentVerification",label:"Identity Document Upload",getValue:s=>s.documentVerificationStatus!=="not_uploaded"&&!!s.documentVerificationStatus,condition:s=>s.entityType==="individual"}];function va(s){const i=ga.filter(n=>!n.condition||n.condition(s)),l=i.filter(n=>n.getValue(s)).length,c=i.filter(n=>!n.getValue(s)).map(n=>n.label);return{completed:l,total:i.length,percentage:Math.round(l/i.length*100),isComplete:l===i.length,missingFields:c}}function fa(s,i,l){return Ge({queryKey:["check-duplicate-business",s==null?void 0:s.toLowerCase(),i==null?void 0:i.toLowerCase(),l],queryFn:async()=>{if(!s||!i)return{hasDuplicate:!1};let c=L.from("businesses").select("id, name").ilike("name",s).eq("jurisdiction",i);l&&(c=c.neq("id",l));const{data:n,error:r}=await c.limit(1);return r?(console.error("Error checking duplicate business:",r),{hasDuplicate:!1}):n&&n.length>0?{hasDuplicate:!0,duplicateBusinessName:n[0].name}:{hasDuplicate:!1}},enabled:!!s&&s.length>2&&!!i,staleTime:5e3})}const ya=x.lazy(()=>Se(()=>import("./AuditLogs-BLImvoxD.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),ja=x.lazy(()=>Se(()=>import("./Team-BQF5bD6I.js"),__vite__mapDeps([12,1,2,3,4,5,6,7,13,14,15,16,17]))),ba=x.lazy(()=>Se(()=>import("./Billing-CxBNWYtB.js"),__vite__mapDeps([18,1,2,3,4,5,6,7,19,20,8,21,22])));function Ya(){var ce;const{currentBusiness:s,loading:i,canManageTeam:l,isPlatformAdmin:c,isFree:n}=Me(),r=ze(),N=Ts(),u=Ps(),h=Ds(),y=Bs(),{toast:d}=qe(),o=ge(),w=x.useRef(null),[j,_]=x.useState(!1),[V,R]=x.useState(!1),[g,q]=x.useState("profile"),{data:m,isLoading:I}=Ks(),E=c||!n&&(I||((m==null?void 0:m.hasAccess)??!1)),b=l&&E;x.useEffect(()=>{g==="team"&&!b&&q("profile")},[g,b]);const[a,v]=x.useState({name:"",legalName:"",jurisdiction:"",taxId:"",cacNumber:"",email:"",phone:"",street:"",city:"",state:"",postalCode:"",country:"",invoicePrefix:"INV",invoiceNumberDigits:4,defaultCurrency:"",isVatRegistered:!1,vatRegistrationNumber:"",businessType:"",allowedCurrencies:[],brandColor:"",entityType:"business",governmentIdType:"",governmentIdValue:""}),{data:M}=fa(a.name,a.jurisdiction,s==null?void 0:s.id),k=ss(a.jurisdiction),F=Fs;x.useEffect(()=>{if(s){const t=s.address,p=s;v({name:s.name||"",legalName:s.legal_name||"",jurisdiction:s.jurisdiction||"",taxId:s.tax_id||"",cacNumber:p.cac_number||"",email:s.contact_email||"",phone:s.contact_phone||"",street:(t==null?void 0:t.street)||"",city:(t==null?void 0:t.city)||"",state:(t==null?void 0:t.state)||"",postalCode:(t==null?void 0:t.postal_code)||"",country:(t==null?void 0:t.country)||"",invoicePrefix:s.invoice_prefix||"INV",invoiceNumberDigits:s.invoice_number_digits||4,defaultCurrency:s.default_currency||"",isVatRegistered:p.is_vat_registered||!1,vatRegistrationNumber:p.vat_registration_number||"",businessType:p.business_type||"",allowedCurrencies:p.allowed_currencies||[],brandColor:p.brand_color||"",entityType:p.entity_type||"business",governmentIdType:p.government_id_type||"",governmentIdValue:p.government_id_value||""})}},[s]);const le=async()=>
7{const t={street:a.street||void 0,city:a.city||void 0,state:a.state||void 0,postal_code:a.postalCode||void 0,country:a.country||void 0},p={name:a.name,legal_name:a.entityType==="individual"?null:a.legalName||null,jurisdiction:a.jurisdiction,contact_email:a.email||null,contact_phone:a.phone||null,address:Object.values(t).some(Boolean)?t:null,invoice_prefix:a.invoicePrefix||"INV",invoice_number_digits:a.invoiceNumberDigits||4,default_currency:a.defaultCurrency||null,is_vat_registered:k.showVat?a.isVatRegistered:!1,business_type:a.businessType||null,allowed_currencies:a.allowedCurrencies||[],brand_color:a.brandColor||null,entity_type:a.entityType},C={tax_id:a.governmentIdValue||a.taxId||null,cac_number:k.showCac&&a.entityType!=="individual"&&a.cacNumber||null,vat_registration_number:k.showVat&&a.isVatRegistered&&a.vatRegistrationNumber||null,government_id_type:a.governmentIdType||null,government_id_value:a.governmentIdValue||null};if(s){await r.mutateAsync({businessId:s.id,updates:p});const{error:U}=await L.from("business_sensitive_data").upsert({business_id:s.id,...C},{onConflict:"business_id"});U?d({title:"Sensitive fields not saved",description:U.message,variant:"destructive"}):o.invalidateQueries({queryKey:["business-sensitive",s.id]})}else{const U=await N.mutateAsync({...p,tax_id:C.tax_id});U!=null&&U.id&&(await L.from("business_sensitive_data").upsert({business_id:U.id,...C},{onConflict:"business_id"}),o.invalidateQueries({queryKey:["business-sensitive",U.id]}))}},$=r.isPending||N.isPending,ie=u.isPending,J=h.isPending,Te=(s==null?void 0:s.next_invoice_number)||1,ve=async t=>{var C;const p=(C=t.target.files)==null?void 0:C[0];if(!(!p||!s))try{await u.mutateAsync({businessId:s.id,file:p})}catch{}finally{w.current&&(w.current.value="")}},fe=x.useCallback(async()=>{if(s){_(!0);try{const{count:t,error:p}=await L.from("invoices").select("id",{count:"exact",head:!0}).eq("business_id",s.id).neq("status","draft");if(p)throw p;if(t&&t>0){d({title:"Cannot unlock currency",description:`You have ${t} issued invoice(s). Primary currency cannot be changed after invoices have been issued.`,variant:"destructive"});return}const{error:C}=await L.from("businesses").update({currency_locked:!1,currency_locked_at:null}).eq("id",s.id);if(C)throw C;o.invalidateQueries({queryKey:["businesses"]}),o.invalidateQueries({queryKey:["business-currency"]}),d({title:"Currency unlocked",description:"You can now change your primary currency."})}catch(t){d({title:"Error",description:t.message||"Failed to unlock currency",variant:"destructive"})}finally{_(!1)}}},[s,d,o]),ye=async()=>{s&&await h.mutateAsync(s.id)},ee=x.useMemo(()=>va({name:a.name,legalName:a.legalName,taxId:a.taxId,email:a.email,addressCity:a.city,addressCountry:a.country,jurisdiction:a.jurisdiction,isVatRegistered:a.isVatRegistered,vatRegistrationNumber:a.vatRegistrationNumber,cacNumber:a.cacNumber,entityType:a.entityType,governmentIdValue:a.governmentIdValue,documentVerificationStatus:s==null?void 0:s.document_verification_status}),[a,s]);return i?e.jsxs(Ee.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(X,{className:"h-9 w-48"}),e.jsx(X,{className:"h-5 w-72 mt-2"})]}),e.jsx(X,{className:"h-10 w-32"})]}),e.jsx(X,{className:"h-24 w-full"}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(X,{className:"h-80"}),e.jsx(X,{className:"h-80"})]})]}):e.jsxs(Ee.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Business Settings"}),s&&e.jsx(Xe,{level:s.verification_status||s.business_identity_level||"unverified",source:s.verification_source,rejectionReason:s.rejection_reason})]}),e.jsx("p",{className:"text-muted-foreground",children:"Configure your legal business details for invoicing"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx($s,{"data-tour":"settings-profile",value:g,onValueChange:t=>q(t),children:e.jsxs(Qs,{children:[e.jsxs(me,{value:"profile","data-tour":"settings-tab-profile",className:"gap-1.5",children:[e.jsx(As,{className:"h-4 w-4"}),"Profile"]}),b&&e.jsxs(me,{value:"team","data-tour":"settings-tab-team",className:"gap-1.5",children:[e.jsx(Rs,{className:"h-4 w-4"}),"Team"]}),e.jsxs(me,{value:"billing","data-tour":"settings-tab-billing",className:"gap-1.5",children:[e.jsx(xe,{className:"h-4 w-4"}),"Billing"]}),e.jsxs(me,{value:"audit-logs","data-tour":"settings-tab-audit",className:"gap-1.5",children:[e.jsx(Es,{className:"h-4 w-4"}),"Audit Logs"]})]})})})]}),g==="audit-logs"?e.jsx(x.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(B,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),children:e.jsx(ya,{})}):g==="team"&&b?e.jsx(x.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(B,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),children:e.jsx(ja,{})}):g==="billing"?e.jsx(x.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(B,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),children:e.jsx(ba,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(S,{"data-tour":"settings-save",onClick:le,disabled:$,className:"w-fit",children:[$?e.jsx(B,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ts,{className:"h-4 w-4 mr-2"}),$?"Saving...":"Save Changes"]}),(M==null?void 0:M.hasDuplicate)&&e.jsxs(He,{variant:"default",className:"border-amber-500/50 bg-amber-500/5",children:[e.jsx(Xs,{className:"h-4 w-4 text-amber-600"}),e.jsxs(Ke,{className:"text-amber-700 dark:text-amber-400",children:['Another business named "',M.duplicateBusinessName,'" already exists in this jurisdiction. If this is intentional (e.g., different legal entity), you may proceed.']})]}),!ee.isComplete&&e.jsx(H,{"data-tour":"settings-completion",className:"bg-amber-500/5 border-amber-500/20",children:e.jsxs(K,{className:"flex flex-col gap-4 py-4",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(re,{className:"h-5 w-5 text-amber-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-amber-700 dark:text-amber-400",children:"Complete your profile for compliance"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"A complete business profile ensures your invoices meet regulatory requirements and builds trust with your clients."})]})]}),e.jsxs("div",{className:"space-y-2 pl-9",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Profile completion"}),e.jsxs("span",{className:"font-medium",children:[ee.completed," of ",ee.total," fields complete"]})]}),e.jsx(Hs,{value:ee.percentage,className:"h-2"}),ee.missingFields.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Missing: ",ee.missingFields.join(", ")
7]})]})]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(H,{className:"lg:col-span-2",children:[e.jsxs(W,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-5 w-5"}),"Branding"]}),e.jsx(ae,{children:"Upload your business logo and set your brand color for invoices"})]}),e.jsxs(K,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx("div",{className:"shrink-0",children:s!=null&&s.logo_url?e.jsxs("div",{className:"relative group",children:[e.jsx(Js,{src:s.logo_url,alt:"Business Logo",className:"h-24 w-auto max-w-[180px] object-contain rounded-lg border border-border bg-muted/50 p-2",fallback:e.jsx("div",{className:"h-24 w-32 rounded-lg border-2 border-dashed border-border flex items-center justify-center bg-muted/30",children:e.jsx(we,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsx("button",{onClick:ye,disabled:J,className:"absolute -top-2 -right-2 p-1 bg-destructive text-destructive-foreground rounded-full opacity-0 group-hover:opacity-100 transition-opacity",title:"Remove logo",children:J?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(be,{className:"h-4 w-4"})})]}):e.jsx("div",{className:"h-24 w-32 rounded-lg border-2 border-dashed border-border flex items-center justify-center bg-muted/30",children:e.jsx(we,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("input",{ref:w,type:"file",accept:"image/png,image/jpeg,image/svg+xml,image/webp",onChange:ve,className:"hidden",id:"logo-upload"}),e.jsxs(S,{variant:"outline",onClick:()=>{var t;return(t=w.current)==null?void 0:t.click()},disabled:ie||!s,className:"w-full sm:w-auto",title:s?void 0:"Save your business profile first to enable logo upload",children:[ie?e.jsx(B,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx($e,{className:"h-4 w-4 mr-2"}),ie?"Uploading...":s!=null&&s.logo_url?"Replace Logo":"Upload Logo"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your logo will appear on generated invoices and PDF exports. PNG, JPEG, SVG or WebP up to 5 MB â larger images are automatically resized for you."}),!s&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600 bg-amber-50 dark:bg-amber-500/10 px-3 py-2 rounded-md",children:[e.jsx(te,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{children:'Fill in your business details and click "Save Changes" to enable logo upload.'})]}),s&&!s.logo_url&&sa.has(s.id)&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-amber-600 bg-amber-50 dark:bg-amber-500/10 px-3 py-2 rounded-md",children:[e.jsx(te,{className:"h-4 w-4 shrink-0 mt-0.5"}),e.jsx("span",{children:"A storage migration on our side removed your logo from your profile â that was our mistake, and we're working to restore it for you. If you'd like it back on your invoices right now, you can re-upload it here and it will apply immediately."})]})]})]}),e.jsxs("div",{className:"border-t pt-4 space-y-2",children:[e.jsx(f,{htmlFor:"brandColor",children:"Brand Color"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"color",id:"brandColor",value:a.brandColor||"#1d6b5a",onChange:t=>v({...a,brandColor:t.target.value}),className:"h-10 w-12 rounded border border-input cursor-pointer bg-transparent p-0.5"}),e.jsx(T,{value:a.brandColor,onChange:t=>v({...a,brandColor:t.target.value}),placeholder:"#1d6b5a",className:"w-32 font-mono text-sm",maxLength:7}),a.brandColor&&e.jsxs(S,{variant:"ghost",size:"sm",onClick:()=>v({...a,brandColor:""}),className:"text-muted-foreground",children:[e.jsx(be,{className:"h-3 w-3 mr-1"}),"Clear"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used as the accent color on your invoices. You can override this per-invoice."})]})]})]}),e.jsxs(H,{"data-tour":"settings-identity",children:[e.jsxs(W,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"h-5 w-5"}),a.entityType==="individual"?"Personal Identity":"Business Identity"]}),e.jsx(ae,{children:a.entityType==="individual"?"Your personal information as it will appear on invoices":"Your legal business information as it will appear on invoices"})]}),e.jsxs(K,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"entityType",children:"Entity Type"}),e.jsxs(G,{value:a.entityType,onValueChange:t=>v({...a,entityType:t}),children:[e.jsx(Y,{children:e.jsx(Q,{})}),e.jsxs(z,{children:[e.jsx(P,{value:"individual",children:"Individual / Freelancer"}),e.jsx(P,{value:"business",children:"Registered Business"}),e.jsx(P,{value:"nonprofit",children:"Nonprofit / NGO"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This determines which fields are required for compliance"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"name",children:a.entityType==="individual"?"Full Name or Trading Name":"Business N
7ame"}),e.jsx(T,{id:"name",placeholder:a.entityType==="individual"?"John Doe":"My Business",value:a.name,onChange:t=>v({...a,name:t.target.value}),maxLength:D.NAME})]}),a.entityType!=="individual"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"legalName",children:"Legal Name"}),e.jsx(T,{id:"legalName",placeholder:"My Business Ltd.",value:a.legalName,onChange:t=>v({...a,legalName:t.target.value}),maxLength:D.LEGAL_NAME}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The registered legal name of your business entity"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"jurisdiction",children:"Jurisdiction"}),e.jsxs(G,{value:a.jurisdiction,onValueChange:t=>v({...a,jurisdiction:t}),children:[e.jsxs(Y,{children:[e.jsx(Le,{className:"h-4 w-4 mr-2"}),e.jsx(Q,{})]}),e.jsx(z,{children:Fe.map(t=>e.jsx(P,{value:t.code,children:t.name},t.code))})]})]}),e.jsx("div",{className:"space-y-3",children:(()=>{const p=Ze(a.jurisdiction)||a.entityType==="business",C=We(a.jurisdiction),U=a.governmentIdType,je=U?ne[U]:void 0,is=(je==null?void 0:je.example)||k.taxIdPlaceholder||"Enter ID number",oe=as(U||void 0,a.governmentIdValue,a.jurisdiction);return e.jsxs(e.Fragment,{children:[e.jsxs(f,{children:["Government ID ",p?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(Optional)"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(G,{value:a.governmentIdType,onValueChange:O=>v({...a,governmentIdType:O}),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:"ID Type"})}),e.jsxs(z,{className:"max-h-72",children:[C.recommended.length>0&&e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground",children:C.countryName?`Recommended for ${C.countryName}`:"Recommended"}),C.recommended.map(O=>e.jsx(P,{value:O,children:ne[O].long},O)),C.other.length>0&&e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground border-t mt-1 pt-2",children:"Other"}),C.other.map(O=>e.jsx(P,{value:O,children:ne[O].long},O))]})]}),e.jsx(T,{placeholder:is,value:a.governmentIdValue,onChange:O=>v({...a,governmentIdValue:O.target.value}),maxLength:D.TAX_ID,"aria-invalid":!oe.valid})]}),!oe.valid&&oe.message&&e.jsx("p",{className:"text-xs text-destructive",children:oe.message}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p&&k.countryName?`Required by ${k.countryName} regulations to appear on every invoice you issue.`:a.entityType==="individual"?"Your government-issued ID number. Varies by country.":k.countryName?`This will appear on your invoices to meet ${k.countryName}'s documentation requirements.`:k.taxIdHint})]})})()}),k.showCac&&a.entityType!=="individual"&&(()=>{const t=es(a.jurisdiction);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"cacNumber",children:[k.cacLabel," ",t?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"(Optional)"})]}),e.jsx(T,{id:"cacNumber",placeholder:k.cacPlaceholder,value:a.cacNumber,onChange:p=>v({...a,cacNumber:p.target.value}),maxLength:D.REG_NUMBER}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k.cacHint})]})})(),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"businessType",children:"Business Type"}),e.jsxs(G,{value:a.businessType,onValueChange:t=>v({...a,businessType:t}),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:"Select type..."})}),e.jsxs(z,{children:[e.jsx(P,{value:"freelancer",children:"Freelancer / Solo"}),e.jsx(P,{value:"sme",children:"Small Business / SME"}),e.jsx(P,{value:"agency",children:"Agency / Studio"}),e.jsx(P,{value:"other",children:"Other"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Helps tailor insights to your business model"})]}),k.showVat&&e.jsxs("div",{className:"border-t pt-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(f,{htmlFor:"vatRegistered",className:"flex items-center gap-2",children:[e.jsx(Ls,{className:"h-4 w-4"}),a.jurisdiction==="CA"?"GST/HST Registered":"VAT Registered"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.jurisdiction==="NG"?"Toggle on if your business is registered for VAT with FIRS":a.jurisdiction==="CA"?"Toggle on if your business is registered for GST/HST":"Toggle on if your business is registered for VAT"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Tax is applied automatically based on your country selection."})]}),e.jsx(Ie,{id:"vatRegistered",checked:a.isVatRegistered,onCheckedChange:t=>v({...a,isVatRegistered:t,vatRegistrationNumber:t?a.vatRegistrationNumber:""})})]}),a.isVatRegistered&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"vatRegNumber",children:[k.vatLabel," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(T,{id:"vatRegNumber",placeholder:k.vatPlaceholder,value:a.vatRegistrationNumber,onChange:t=>v({...a,vatRegistrationNumber:t.target.value}),maxLength:D.REG_NUMBER}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k.vatHint||"This will appear on all invoices."})]})]})]})]}),e.jsxs(H,{"data-tour":"settings-address",children:[e.jsxs(W,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-5 w-5"}),"Contact Information"]}),e.jsx(ae,{children:"How clients can reach your business"})]}),e.jsxs(K,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"email",children:"Business Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ve,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(T,{id:"email",type:"email",className:"pl-9",placeholder:"[email protected]",value:a.email,onChange:t=>v({...a,email:t.target.value}),maxLength:D.EMAIL})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"phone",children:"Business Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(T,{id:"phone",type:"tel",className:"pl-9",placeholder:"Phone number",value:a.p
7hone,onChange:t=>v({...a,phone:t.target.value}),maxLength:D.PHONE})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"street",children:"Street Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(Zs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(T,{id:"street",className:"pl-9",placeholder:"123 Business Street",value:a.street,onChange:t=>v({...a,street:t.target.value}),maxLength:D.ADDRESS_LINE})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"city",children:["City ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(T,{id:"city",placeholder:"City",value:a.city,onChange:t=>v({...a,city:t.target.value}),maxLength:D.ADDRESS_LINE})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"state",children:"State/Province"}),e.jsx(T,{id:"state",placeholder:"State / Province",value:a.state,onChange:t=>v({...a,state:t.target.value}),maxLength:D.ADDRESS_LINE})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"postalCode",children:"Postal Code"}),e.jsx(T,{id:"postalCode",placeholder:"Postal Code",value:a.postalCode,onChange:t=>v({...a,postalCode:t.target.value}),maxLength:D.POSTAL_CODE})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"country",children:["Country ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(G,{value:a.country,onValueChange:t=>v({...a,country:t}),children:[e.jsx(Y,{id:"country",children:e.jsx(Q,{placeholder:"Select country"})}),e.jsx(z,{children:Fe.map(t=>e.jsx(P,{value:t.name,children:t.name},t.code))})]})]})]})]})]}),e.jsxs(H,{"data-tour":"settings-invoicing",className:"lg:col-span-2",children:[e.jsxs(W,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Qe,{className:"h-5 w-5"}),"Invoice Settings"]}),e.jsx(ae,{children:"Customize how your invoices are generated"})]}),e.jsxs(K,{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"invoicePrefix",children:"Invoice Prefix"}),e.jsx(T,{id:"invoicePrefix",placeholder:"INV",value:a.invoicePrefix,onChange:t=>v({...a,invoicePrefix:t.target.value}),maxLength:D.INVOICE_PREFIX}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Prefix for your invoice numbers"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"invoiceNumberDigits",children:"Number of Digits"}),e.jsx(T,{id:"invoiceNumberDigits",type:"number",min:1,max:15,value:a.invoiceNumberDigits,onChange:t=>{const p=Math.min(15,Math.max(1,parseInt(t.target.value)||4));v({...a,invoiceNumberDigits:p})}}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How many digits in the number (e.g., 10 for Bulgaria)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Next Invoice Number"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(A,{variant:"secondary",className:"text-lg font-mono",children:[a.invoicePrefix||"INV","-",String(Te).padStart(a.invoiceNumberDigits||4,"0")]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Invoice numbers are sequential and cannot be modified"})]})]}),e.jsx("div",{className:"border-t pt-6 space-y-6",children:e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"defaultCurrency",className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-4 w-4"}),"Primary Currency",(s==null?void 0:s.currency_locked)&&e.jsxs(A,{variant:"secondary",className:"ml-2 text-xs",children:[e.jsx(Ne,{className:"h-3 w-3 mr-1"}),"Locked"]})]}),s!=null&&s.currency_locked?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-md bg-muted/50 border",children:[e.jsx(Ne,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:((ce=F.find(t=>t.value===a.defaultCurrency))==null?void 0:ce.label)||a.defaultCurrency})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:fe,disabled:j,children:[j?e.jsx(B,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(Ne,{className:"h-3 w-3 mr-1"}),j?"Checking...":"Unlock Currency"]})]}):e.jsxs(G,{value:a.defaultCurrency,onValueChange:t=>v({...a,defaultCurrency:t}),children:[e.jsx(Y,{id:"defaultCurrency",children:e.jsx(Q,{placeholder:"Select currency"})}),e.jsx(z,{children:F.map(t=>e.jsx(P,{value:t.value,children:t.label},t.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s!=null&&s.currency_locked?e.jsxs(e.Fragment,{children:["Primary currency locked on ",s.currency_locked_at?new Date(s.currency_locked_at).toLocaleDateString():"first invoice",'. Click "Unlock Currency" if you have no issued invoices.']}):"Currency is set based on your business location. This will become your primary accounting currency after your first invoice."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"h-4 w-4"}),"Additional Currencies"]}
7),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.allowedCurrencies.map(t=>{var p;return e.jsxs(A,{variant:"secondary",className:"cursor-pointer hover:bg-destructive/10",onClick:()=>v({...a,allowedCurrencies:a.allowedCurrencies.filter(C=>C!==t)}),children:[((p=F.find(C=>C.value===t))==null?void 0:p.label)||t,e.jsx(be,{className:"h-3 w-3 ml-1"})]},t)}),a.allowedCurrencies.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No additional currencies"})]}),e.jsxs(G,{value:"",onValueChange:t=>{t&&!a.allowedCurrencies.includes(t)&&t!==a.defaultCurrency&&v({...a,allowedCurrencies:[...a.allowedCurrencies,t]})},children:[e.jsxs(Y,{children:[e.jsx(Ue,{className:"h-4 w-4 mr-2"}),e.jsx("span",{className:"text-muted-foreground",children:"Add currency"})]}),e.jsx(z,{children:F.filter(t=>t.value!==a.defaultCurrency&&!a.allowedCurrencies.includes(t.value)).map(t=>e.jsx(P,{value:t.value,children:t.label},t.value))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add currencies you accept. Invoices in these currencies will require an exchange rate for accounting."})]})]})})]})]})]}),s&&e.jsx("div",{"data-tour":"settings-verification",children:e.jsx(pa,{business:s})}),s&&e.jsx(oa,{business:s}),s&&e.jsx("div",{"data-tour":"settings-payments",children:e.jsx(na,{businessId:s.id,canManage:!0,canDelete:!0})}),s&&!s.is_default&&e.jsxs(H,{"data-tour":"settings-danger",className:"border-destructive/30",children:[e.jsxs(W,{children:[e.jsxs(se,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(te,{className:"h-5 w-5"}),"Danger Zone"]}),e.jsx(ae,{children:"Permanently delete this business and all associated data."})]}),e.jsxs(K,{children:[e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Deletion is only possible while the business is empty. Once it has invoices, receipts or payments, records must be kept for compliance and the business can no longer be removed."}),e.jsx(S,{variant:"destructive",onClick:()=>R(!0),children:"Delete Business"})]})]}),s&&e.jsx(Vs,{open:V,onOpenChange:R,businessName:s.name,onConfirm:()=>y.mutate(s.id),isPending:y.isPending})]})]})}export{Ya 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.