1import{u as ve,r as t,K as Ne,j as e,L as ne,e as ye,A as be,N as Se,C as N,k as y,l as b,cO as ie,n as B,o as S,bD as re,a4 as le,aV as we,v as n,w as Ce,x as qe,y as Ae,z as De,D as Fe,a9 as Pe,I as i,aw as h,aj as _e,B as Ee,ak as Ie,$ as ke,s as x,a0 as w}from"./index-D8_nJFcn.js";import{u as Be,M as Le,a as Ue}from"./module-intro-config-DUbKufrw.js";import{R as Me,a as L}from"./radio-group-Bft0O1C7.js";const Ge=()=>{const U=ve(),[p,ce]=t.useState(),{open:oe,dismiss:de}=Be("financing",p??null),[C,ue]=t.useState([]),[Oe,me]=t.useState(null),[he,xe]=t.useState(!0),[M,O]=t.useState(!1),[pe,T]=t.useState(!1),{tier:R,isPro:ge}=Ne(p||null),[V,G]=t.useState(""),[l,z]=t.useState("sba7"),[q,A]=t.useState(""),[H,D]=t.useState(""),[K,F]=t.useState(""),[Q,P]=t.useState(""),[g,_]=t.useState(""),[j,W]=t.useState(""),[Y,f]=t.useState(""),[$,v]=t.useState(""),[E,J]=t.useState(""),[I,X]=t.useState(""),[k,Z]=t.useState(""),[ee,se]=t.useState(""),[ae,te]=t.useState("");t.useEffect(()=>{(async()=>{const{data:{user:a}}=await x.auth.getUser();if(!a){U("/portal/auth");return}ce(a.id);const{data:r}=await x.from("deals").select("id, title, industry, revenue, ebitda, asking_price").eq("user_id",a.id).order("created_at",{ascending:!1});r&&ue(r);const{data:c}=await x.from("profiles").select("full_name, email, phone").eq("id",a.id).single();c&&(me(c),X(c.full_name||""),Z(c.email||""),se(c.phone||"")),xe(!1)})()},[U]);const je=s=>{var r,c,u;G(s);const a=C.find(m=>m.id===s);if(a&&(A(a.title),D(a.industry||""),F(((r=a.revenue)==null?void 0:r.toString())||""),P(((c=a.ebitda)==null?void 0:c.toString())||""),_(((u=a.asking_price)==null?void 0:u.toString())||""),a.asking_price)){const m=Math.round(a.asking_price*.8);f(m.toString()),v(Math.round(a.asking_price*.2).toString())}},d=s=>{const a=parseInt(s.replace(/\D/g,""),10);return isNaN(a)?"":a.toLocaleString("en-US")},o=s=>{const a=parseInt(s.replace(/\D/g,""),10);return isNaN(a)?void 0:a};t.useEffect(()=>{const s=o(g),a=o(j);if(s&&(l==="sba7"||l==="both")){const r=Math.round(s*.8),c=a?s-a:r,u=Math.min(c,r);if(f(u>0?u.toString():""),l==="both"&&s&&a){const m=s-a-u;v(m>0?m.toString():"")}}},[g,j,l]);const fe=async s=>{if(s.preventDefault(),!ge){T(!0);return}if(!q||!I||!k){w.error("Please fill in all required fields");return}O(!0);try{const{data:{session:a}}=await x.auth.getSession();if(!a){w.error("Please sign in to submit a request");return}const r=await x.functions.invoke("send-financing-request",{body:{deal_id:V||void 0,financing_type:l,business_name:q,industry:H||void 0,annual_revenue:o(K),ebitda:o(Q),purchase_price:o(g),down_payment_available:o(j),sba_loan_amount_requested:o(Y),equity_needed:o($),equity_percentage:E?parseFloat(E):void 0,additional_notes:ae||void 0,contact_name:I,contact_email:k,contact_phone:ee||void 0}});if(r.error)throw new Error(r.error.message);w.success("Financing application submitted successfully! We'll be in touch soon."),G(""),z("sba7"),A(""),D(""),F(""),P(""),_(""),W(""),f(""),v(""),J(""),te("")}catch(a){console.error("Error submitting financing request:",a),w.error("Failed to submit application. Please try again.")}finally{O(!1)}};return he?e.jsx("div",{className:"flex h-screen items-center justify-center",children:e.jsx(ne,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs(ye,{children:[e.jsxs("div",{className:"flex min-h-screen w-full",children:[e.jsx(be,{userId:p,currentConversationId:null,onSelectConversation:()=>{},onNewConversation:()=>{}}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx(Se,{userId:p||null}),e.jsx("main",{className:"flex-1 overflow-auto bg-background pt-24",children:e.jsxs("div",{className:"container max-w-6xl py-8 px-4 md:px-8",children:[e.jsx("div",{className:"mb-8 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"SBA 7(a) / Financing"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Apply for acquisition financing through our preferred lender network"})]})}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(N,{children:[e.jsxs(y,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-5 w-5 text-primary"}),"SBA 7(a) Financing"]}),e.jsx(B,{children:"Government-backed loans for business acquisitions"})]}),e.jsx(S,{children:e.jsx("ul",{className:"space-y-2",children:["Up to 80% of purchase price","10-25 year repayment terms","Competitive interest rates","Lower down payment requirements","Access to our preferred SBA lenders"].map((s,a)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(re,{className:"h-4 w-4 text-green-500 mt-0.5 shrink-0"}),e.jsx("span",{children:s})]},a))})})]}),e.jsxs(N,{children:[e.jsxs(y,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-5 w-5 text-primary"}),"Investor Network"]}),e.jsx(B,{children:"Equity partners for remaining capital needs"})]}),e.jsx(S,{children:e.jsx("ul",{className:"space-y-2",children:["Fill the equity gap after SBA financing","Experienced acquisition partners","Flexible deal structures","Strategic value-ad
1d investors","Quick funding decisions"].map((s,a)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(re,{className:"h-4 w-4 text-green-500 mt-0.5 shrink-0"}),e.jsx("span",{children:s})]},a))})})]}),e.jsxs(N,{className:"bg-muted/50",children:[e.jsx(y,{children:e.jsxs(b,{className:"flex items-center gap-2 text-base",children:[e.jsx(we,{className:"h-5 w-5"}),"Typical Deal Structure"]})}),e.jsxs(S,{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"SBA 7(a) Loan"}),e.jsx("span",{className:"font-medium",children:"Up to 80%"})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Buyer Down Payment"}),e.jsx("span",{className:"font-medium",children:"10-20%"})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Investor Equity"}),e.jsx("span",{className:"font-medium",children:"0-10%"})]}),e.jsx("p",{className:"text-xs text-muted-foreground pt-2 border-t",children:"Many buyers use SBA financing combined with investor equity to minimize their out-of-pocket capital while maintaining majority ownership."})]})]})]}),e.jsxs(N,{children:[e.jsxs(y,{children:[e.jsx(b,{children:"Apply for Financing"}),e.jsx(B,{children:"Select a deal to auto-fill details, or enter information manually"})]}),e.jsx(S,{children:e.jsxs("form",{onSubmit:fe,className:"space-y-6",children:[C.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{children:"Link to Existing Deal (Optional)"}),e.jsxs(Ce,{value:V,onValueChange:je,children:[e.jsx(qe,{children:e.jsx(Ae,{placeholder:"Select a deal to auto-fill"})}),e.jsx(De,{children:C.map(s=>e.jsx(Fe,{value:s.id,children:s.title},s.id))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(n,{children:"Financing Type *"}),e.jsxs(Me,{value:l,onValueChange:s=>
1z(s),className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-3 border rounded-lg p-3 hover:bg-muted/50 cursor-pointer",children:[e.jsx(L,{value:"sba7",id:"sba7"}),e.jsxs(n,{htmlFor:"sba7",className:"flex-1 cursor-pointer",children:[e.jsx("div",{className:"font-medium",children:"SBA 7(a) Loan Only"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Apply for SBA financing through our preferred lender"})]})]}),e.jsxs("div",{className:"flex items-center space-x-3 border rounded-lg p-3 hover:bg-muted/50 cursor-pointer",children:[e.jsx(L,{value:"investor",id:"investor"}),e.jsxs(n,{htmlFor:"investor",className:"flex-1 cursor-pointer",children:[e.jsx("div",{className:"font-medium",children:"Investor Network Only"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Connect with equity investors for your acquisition"})]})]}),e.jsxs("div",{className:"flex items-center space-x-3 border rounded-lg p-3 hover:bg-muted/50 cursor-pointer",children:[e.jsx(L,{value:"both",id:"both"}),e.jsxs(n,{htmlFor:"both",className:"flex-1 cursor-pointer",children:[e.jsx("div",{className:"font-medium",children:"SBA 7(a) + Investor Network"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Combine SBA financing with investor equity"})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[e.jsx(Pe,{className:"h-4 w-4"}),"Business Details"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"businessName",children:"Business Name *"}),e.jsx(i,{id:"businessName",value:q,onChange:s=>A(s.target.value),placeholder:"Enter business name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"industry",children:"Industry"}),e.jsx(i,{id:"industry",value:H,onChange:s=>D(s.target.value),placeholder:"e.g., SaaS, Manufacturing, Retail"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"revenue",children:"Annual Revenue"}),e.jsxs("div",{className:"relative",children:[e.jsx(h,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(i,{id:"revenue",value:K,onChange:s=>F(d(s.target.value)),placeholder:"0",className:"pl-9"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"ebitda",children:"EBITDA"}),e.jsxs("div",{className:"relative",children:[e.jsx(h,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(i,{id:"ebitda",value:Q,onChange:s=>P(d(s.target.value)),placeholder:"0",className:"pl-9"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"purchasePrice",children:"Purchase Price"}),e.jsxs("div",{className:"relative",children:[e.jsx(h,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(i,{id:"purchasePrice",value:g,onChange:s=>_(d(s.target.value)),placeholder:"0",className:"pl-9"})]})]})]})]}),(l==="sba7"||l==="both")&&e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[e.jsx(ie,{className:"h-4 w-4"}),"SBA 7(a) Details"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"downPayment",children:"Down Payment Available"}),e.jsxs("div",{className:"relative",children:[e.jsx(h,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(i,{id:"downPayment",value:j,onChange:s=>W(d(s.target.value)),placeholder:"0",className:"pl-9"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"sbaLoan",children:"SBA Loan Amount (auto-calculated)"}),e.jsxs("div",{className:"relative",children:[e.jsx(h,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(i,{id:"sbaLoan",value:d(Y),onChange:s=>f(s.target.value.replace(/\D/g,"")),placeholder:"Up to 80% of purchase price",className:"pl-9"})]})]})]})]}),(l==="investor"||l==="both")&&e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4"}),"Investor Network Details"]}
1),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"equityNeeded",children:"Equity Amount Needed"}),e.jsxs("div",{className:"relative",children:[e.jsx(h,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(i,{id:"equityNeeded",value:d($),onChange:s=>v(s.target.value.replace(/\D/g,"")),placeholder:"0",className:"pl-9"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"equityPct",children:"Equity % Offered"}),e.jsxs("div",{className:"relative",children:[e.jsx(i,{id:"equityPct",type:"number",min:"0",max:"100",step:"0.1",value:E,onChange:s=>J(s.target.value),placeholder:"e.g., 10",className:"pr-8"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]})]})]}),e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[e.jsx("h4",{className:"font-medium",children:"Contact Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"contactName",children:"Your Name *"}),e.jsx(i,{id:"contactName",value:I,onChange:s=>X(s.target.value),placeholder:"Enter your name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"contactEmail",children:"Email *"}),e.jsx(i,{id:"contactEmail",type:"email",value:k,onChange:s=>Z(s.target.value),placeholder:"Enter your email",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"contactPhone",children:"Phone (Optional)"}),e.jsx(i,{id:"contactPhone",type:"tel",value:ee,onChange:s=>se(s.target.value),placeholder:"Enter your phone number"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"notes",children:"Additional Notes (Optional)"}),e.jsx(_e,{id:"notes",value:ae,onChange:s=>te(s.target.value),placeholder:"Any additional information about your acquisition or financing needs...",rows:3})]}),e.jsx(Ee,{type:"submit",className:"w-full",disabled:M,children:M?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"h-4 w-4 mr-2 animate-spin"}),"Submitting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"h-4 w-4 mr-2"}),"Submit Application"]})})]})})]})]})]})})]})]}),e.jsx(ke,{open:pe,onOpenChange:T,feature:"financing applications",currentTier:R==="deal_sourcing"?"free":R}),e.jsx(Le,{open:oe,onDismiss:de,...Ue.financing})]})};export{Ge 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.