1import{u as ga,k as fa,c as va,r,d as Je,j as e,B as u,a as H,X as ge,t as d,b as re}from"./index-CudHG6B4.js";import{u as G}from"./useMutation-CBAYgnG2.js";import{C as J,b as X,c as Z,a as ee}from"./card-5b9UOcPu.js";import{I as v}from"./input-kx1YXBs7.js";import{L as l}from"./label-B2onvOiF.js";import{R as Xe,a as Ze,T as ya}from"./textarea-C9FUOvKW.js";import{B as ja}from"./badge-CMf0SrHQ.js";import{S as fe,a as ve,b as ye,c as je,d as g}from"./InstitutionRegister-CdUSyHyq.js";import{V as ea}from"./V2Layout-CQnVHc2g.js";import{A as Na,F as ba,v as Sa}from"./AcreageEditor-vn4_h2Pr.js";import{f as wa,i as Ne,r as Pa}from"./termFormatters-CQF3c-3T.js";import{C as ta}from"./circle-check-CTosiqnS.js";import{M as Ca}from"./skeleton-BegiI0pz.js";import{D as ka}from"./dollar-sign-BcfyEtLy.js";import{F as Aa}from"./file-text-76AiIfll.js";import{U as Ia}from"./AuthenticatedApplication-C2-e6xTS.js";import"./index-C1iJF-SR.js";import"./circle-C1ccQMbh.js";import"./alert-kp6gCZ70.js";import"./chevron-up-qSRaMRim.js";import"./check-D8BjNWtW.js";import"./building-2-CMfa6c9V.js";import"./shield-check-ic92rXB7.js";import"./users-DX1W4CCh.js";import"./AcreageSummary-C1dLRFxT.js";import"./triangle-alert-BA2tGhup.js";import"./connectors-BciFpN0c.js";import"./circle-alert-CRUc3mQk.js";import"./chevron-right-Dr8cwl4J.js";import"./user-DCnI1kiW.js";import"./arrow-left-lxn-dpfG.js";import"./clock-DzjvzExH.js";import"./AboutPage-CamkJ7cK.js";import"./PrivacyPage-Beavwhs0.js";import"./TermsPage-SeBMfIpe.js";import"./BackingDashboard-CVY4Rsg2.js";import"./shield-Hr0aqzVI.js";import"./layers-Ca3pv70P.js";import"./LandVerifyPage-NEwI3vUf.js";import"./award-BusU1ju6.js";import"./hash-DyzAXdJv.js";import"./globe-NLl4Wr5a.js";import"./scale-DM0tAT-O.js";import"./calendar-BTBtzozc.js";import"./trending-up-C66B21n6.js";import"./landmark-BA_0Cnnl.js";import"./LandCertificate-Du_3NAH9.js";import"./printer-C2HCk7DD.js";import"./OnchainDocsPage-DDA6342p.js";import"./book-open-DvSukaGG.js";import"./code-CMLileHq.js";import"./sprout-z_rucUaP.js";import"./TransparencyPage-Ylxz21fu.js";import"./ProtocolPage-UaH8jgc9.js";import"./LandProtocolDevRef-_yp8P5Ot.js";import"./InstitutionInvitePage-CIc8kA4i.js";import"./FlowOfFundsPage-BjbpHgzo.js";import"./CapitalProviderChoice-C78InrEx.js";import"./arrow-right-B1UlrPw0.js";import"./IndividualProviderRegister-DyWPKEYx.js";const be=[{key:"property",label:"Property"},{key:"loan",label:"Loan Details"},{key:"documents",label:"Documents"},{key:"narrative",label:"Statement"},{key:"review",label:"Review"}],Da={financials_income_statement:"Income Statement",financials_balance_sheet:"Balance Sheet",financials_tax_return:"Tax Return (2 years)",appraisal:"Property Appraisal",title_opinion:"Title Opinion",other:"Other Document"},Fa=["financials_income_statement","financials_balance_sheet","appraisal"];function aa(i){if(!i)return"$0";const o=typeof i=="string"?parseFloat(i):i;return isNaN(o)?"$0":"$"+o.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0})}function _a({current:i}){const o=be.findIndex(s=>s.key===i);return e.jsx("div",{className:"flex items-center gap-1 text-xs mb-6",children:be.map((s,p)=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("span",{className:`font-medium ${p===o?"text-foreground":p<o?"text-[#009955]":"text-muted-foreground"}`,children:[p<o?e.jsx(ta,{className:"inline h-3 w-3 text-[#009955]"}):null," ",s.label]}),p<be.length-1&&e.jsx("span",{className:"text-muted-foreground/40 mx-1",children:"/"})]},s.key))})}function Se(i){return`loan-draft-${i}`}function Ta(i){try{const o=localStorage.getItem(Se(i));return o?JSON.parse(o):null}catch{return null}}function La(i){try{localStorage.removeItem(Se(i))}catch{}}function qt(){const[,i]=ga(),o=fa(),{user:s}=va(),p=(s==null?void 0:s.role)==="land_broker";r.useEffect(()=>{p&&i("/apply?filingFor=other")},[p,i]);const[N,y]=r.useState("property"),[q,ra]=r.useState(null),[sa,na]=r.useState(!1),[m,we]=r.useState(!0),[x,Pe]=r.useState(null),[V,Ce]=r.useState(""),[b,ke]=r.useState(""),[S,Ae]=r.useState(""),[w,U]=r.useState([]),[P,se]=r.useState(""),[C,z]=r.useState([]),[k,ne]=r.useState(""),[A,Ie]=r.useState(""),[I,De]=r.useState(""),[D,Fe]=r.useState(""),[F,_e]=r.useState(""),[_,Te]=r.useState(""),[T,Le]=r.useState(""),[L,Ee]=r.useState(""),[E,Oe]=r.useState(""),[K,Re]=r.useState(""),[O,Me]=r.useState(null),[ae,Be]=r.useState(""),[R,$e]=r.useState(""),[M,qe]=r.useState(""),[B,Ve]=r.useState(""),[h,Ue]=r.useState(""),[Q,ze]=r.useState("none"),[W,ie]=r.useState(""),[Y,le]=r.useState(""),[ia,oe]=r.useState(null),[Ke,Qe]=r.useState([]),[$,We]=r.useState(""),ce=r.useRef(!1),{data:de=[],isLoading:la}=Je({queryKey:["/api/lands"]}),{data:oa=[]}=Je({queryKey:["/api/lb/landowners"],enabled:p});r.useEffect(()=>{if(!(s!=null&&s.id)||ce.current)return;ce.current=!0;const a=Ta(s.id);a&&(a.useExistingLand!==void 0&&we(a.useExistingLand),a.selectedLandI
1d!==void 0&&Pe(a.selectedLandId),a.landNickname!==void 0&&Ce(a.landNickname),a.manualName!==void 0&&ke(a.manualName),a.manualAddress!==void 0&&Ae(a.manualAddress),a.manualCounties!==void 0&&U(a.manualCounties),a.manualStates!==void 0&&z(a.manualStates),a.manualAcreage!==void 0&&Ie(a.manualAcreage),a.acreageTillable!==void 0&&De(a.acreageTillable),a.acreagePasture!==void 0&&Fe(a.acreagePasture),a.acreageWoodland!==void 0&&_e(a.acreageWoodland),a.acreageConservation!==void 0&&Te(a.acreageConservation),a.acreageImprovements!==void 0&&Le(a.acreageImprovements),a.acreageOther!==void 0&&Ee(a.acreageOther),a.acreageOtherDescription!==void 0&&Oe(a.acreageOtherDescription),a.manualValue!==void 0&&Re(a.manualValue),a.borrowerId!==void 0&&Me(a.borrowerId),a.amount!==void 0&&Be(a.amount),a.targetLtv!==void 0&&$e(a.targetLtv),a.resetPeriod!==void 0&&qe(a.resetPeriod),a.amortMonths!==void 0&&Ve(a.amortMonths),a.repaymentSchedule!==void 0&&Ue(a.repaymentSchedule),a.prepaymentPenaltyType!==void 0&&ze(a.prepaymentPenaltyType),a.firstPrincipalPaymentDate!==void 0?ie(a.firstPrincipalPaymentDate):a.firstPaymentDate!==void 0&&ie(a.firstPaymentDate),a.firstInterestPaymentDate!==void 0?le(a.firstInterestPaymentDate):a.firstPaymentDate!==void 0&&le(a.firstPaymentDate),a.narrative!==void 0&&We(a.narrative))},[s==null?void 0:s.id]),r.useEffect(()=>{if(!(s!=null&&s.id)||!ce.current)return;const a=setTimeout(()=>{const t={useExistingLand:m,selectedLandId:x,landNickname:V,manualName:b,manualAddress:S,manualCounties:w,manualStates:C,manualAcreage:A,acreageTillable:I,acreagePasture:D,acreageWoodland:F,acreageConservation:_,acreageImprovements:T,acreageOther:L,acreageOtherDescription:E,manualValue:K,borrowerId:O,amount:ae,targetLtv:R,resetPeriod:M,amortMonths:B,repaymentSchedule:h,prepaymentPenaltyType:Q,firstPrincipalPaymentDate:W,firstInterestPaymentDate:Y,narrative:$};try{localStorage.setItem(Se(s.id),JSON.stringify(t))}catch{}},600);return()=>clearTimeout(a)},[s==null?void 0:s.id,m,x,V,b,S,w,C,A,I,D,F,_,T,L,E,K,O,ae,R,M,B,h,Q,W,Y,$]);const me=parseFloat(ae.replace(/,/g,""))||0,ue=G({mutationFn:async()=>{const a=Pa(h),t={requestedAmountUsd:me.toFixed(2),targetLtv:R||null,resetPeriodMonths:M?parseInt(M):null,amortizationMonths:Ne(h)&&B?parseInt(B):null,repaymentType:a,repaymentSchedule:h,firstPrincipalPaymentDate:W||null,firstInterestPaymentDate:Y||null,prepaymentPenaltyType:Q!=="none"?Q:null,narrative:$||null};return m&&x?(t.landId=x,t.propertyName=V.trim()||null,t.propertyAcreage=(c==null?void 0:c.acreage)||null,t.acreageTillable=I||null,t.acreagePasture=D||null,t.acreageWoodland=F||null,t.acreageConservation=_||null,t.acreageImprovements=T||null,t.acreageOther=L||null,t.acreageOtherDescription=E.trim()||null):(t.propertyName=b.trim()||null,t.propertyAddress=S,t.propertyCounty=w.filter(Boolean),t.propertyState=C.filter(Boolean),t.propertyAcreage=A||null,t.acreageTillable=I||null,t.acreagePasture=D||null,t.acreageWoodland=F||null,t.acreageConservation=_||null,t.acreageImprovements=T||null,t.acreageOther=L||null,t.acreageOtherDescription=E.trim()||null,t.estimatedValueUsd=K?parseFloat(K.replace(/,/g,"")).toFixed(2):null),p&&O&&(t.borrowerId=O),(await re("POST","/api/v2/loan-applications",t)).json()},onSuccess:a=>{if(a.receiptStatus==="received_awaiting_authority_review"){o.invalidateQueries({queryKey:["/api/v2/broker/workspace"]}),o.invalidateQueries({queryKey:["/api/broker/me/onboarding"]}),d("Received â awaiting authority review",{description:"Your initial application was received. Staff must verify client authority before Credit Review; do not submit again. Find your receipt under Authority exceptions in your client workspace."}),i("/broker/clients");return}ra(a.id),y("documents"),o.invalidateQueries({queryKey:["/api/v2/loan-applications/my"]}),o.invalidateQueries({queryKey:["/api/v2/broker/workspace"]}),o.invalidateQueries({queryKey:["/api/broker/me/onboarding"]})},onError:a=>{d.error("Failed to save application",{description:String(a)})}}),pe=G({mutationFn:async a=>(await re("PATCH",`/api/v2/loan-applications/${q}`,a)).json(),onError:a=>{d.error("Failed to update application",{description:String(a)})}}),xe=G({mutationFn:async()=>(await re("POST",`/api/v2/loan-applications/${q}/submit`)).json(),onSuccess:()=>{s!=null&&s.id&&La(s.id),na(!0),o.invalidateQueries({queryKey:["/api/v2/loan-applications/my"]}),o.invalidateQueries({queryKey:["/api/v2/broker/workspace"]})},onError:a=>{d.error("Failed to submit",{description:String(a)})}}),Ye=G({mutationFn:async({file:a,docType:t})=>{const n=new FormData;n.append("file",a),n.append("docType",t);const f=await fetch(`/api/v2/loan-applications/${q}/documents`,{method:"POST",body:n,credentials:"include"});if(!f.ok){const j=await f.json();throw new Error(j.message||"Upload failed")}return f.json()},onSuccess:a=>{Qe(t=>[...t.filter(n=>n.docType!==a.docType),a]),oe(null)},onError:a=>{d.error("Upload failed",{description:String(a)}),oe(null)}}),ca=G({mutationFn:async a=>{await re("DELETE",`/api/v2/loan-applications/${q}/documents/${a}`)},onSuccess:(a,t)=>{Qe(n=>n.filter(f=>f.id!==t))}}),da=a=>{const t=a.target.value.replace(/[^0-9]/g,""),n=t?parseInt(t,10).toLocaleStr
1ing("en-US"):"";Be(n)},ma=()=>{if(p&&!O){d.error("Select a landowner");return}if(m&&!x){d.error("Select a property");return}if(!m&&!b.trim()){d.error("Enter a land nickname");return}if(!m&&!S){d.error("Enter a property address");return}const a=Sa({totalPropertyAcreage:m?c==null?void 0:c.acreage:A,acreageTillable:I,acreagePasture:D,acreageWoodland:F,acreageConservation:_,acreageImprovements:T,acreageOther:L,acreageOtherDescription:E});if(a){d.error("Review acreage breakdown",{description:a});return}y("loan")},ua=()=>{if(me<10){d.error("Enter a valid loan amount (minimum $10)");return}if(!h){d.error("Select a repayment schedule");return}if(Ne(h)&&!B){d.error("Select an amortization period");return}if(!!W!=!!Y){d.error("Provide both first payment dates or leave both blank");return}ue.mutate()},pa=()=>y("narrative"),xa=async()=>{q&&await pe.mutateAsync({narrative:$}),y("review")},ha=()=>xe.mutate(),c=de.find(a=>a.id===x),he=m?V.trim()||(c==null?void 0:c.name)||"":b;return sa?e.jsx(ea,{children:e.jsxs("div",{className:"max-w-lg mx-auto py-16 text-center space-y-4",children:[e.jsx(ta,{className:"h-12 w-12 text-[#009955] mx-auto"}),e.jsx("h1",{className:"text-2xl font-semibold",children:"Application Submitted"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your loan application has been submitted. Our credit team will review it and you will receive an email when it moves forward."}),e.jsxs("div",{className:"flex gap-3 justify-center pt-2",children:[e.jsx(u,{variant:"outline",onClick:()=>i("/loans/applications"),children:"View My Applications"}),e.jsx(u,{className:"bg-[#009955] hover:bg-[#007744]",onClick:()=>i("/"),children:"Go to Dashboard"})]})]})}):e.jsx(ea,{children:e.jsxs("div",{className:"max-w-xl mx-auto py-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>i("/"),className:"text-muted-foreground hover:text-foreground text-sm",children:"Back"}),e.jsx("h1",{className:"text-xl font-semibold",children:"Apply for a Loan"})]}),e.jsx(_a,{current:N}),N==="property"&&e.jsxs(J,{children:[e.jsx(X,{children:e.jsx(Z,{className:"text-lg",children:"Property"})}),e.jsxs(ee,{className:"space-y-4",children:[p&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Landowner"}),e.jsxs("select",{className:"w-full border rounded-md px-3 py-2 text-sm",value:O??"",onChange:a=>Me(a.target.value?parseInt(a.target.value):null),children:[e.jsx("option",{value:"",children:"Select landowner..."}),oa.map(a=>e.jsxs("option",{value:a.id,children:[[a.firstName,a.lastName].filter(Boolean).join(" ")||a.email," (",a.email,")"]},a.id))]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Property source"}),e.jsx(Xe,{value:m?"existing":"manual",onValueChange:a=>we(a==="existing"),children:e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{value:"existing",label:"My Land Ledger property"},{value:"manual",label:"Enter manually"}].map(a=>e.jsxs(l,{htmlFor:`src-${a.value}`,className:`flex items-center gap-2 p-3 rounded-lg border-2 cursor-pointer ${m===(a.value==="existing")?"border-[#009955] bg-[#009955]/5":"border-border"}`,children:[e.jsx(Ze,{id:`src-${a.value}`,value:a.value}),e.jsx("span",{className:"text-sm font-medium",children:a.label})]},a.value))})})]}),m?e.jsxs("div",{className:"space-y-3",children:[la?e.jsx(H,{className:"h-5 w-5 animate-spin text-muted-foreground"}):de.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No properties found. You can enter property details manually instead."}):e.jsx(Xe,{value:(x==null?void 0:x.toString())??"",onValueChange:a=>Pe(parseInt(a)),children:e.jsx("div",{className:"space-y-2",children:de.map(a=>e.jsxs(l,{htmlFor:`land-${a.id}`,className:`flex items-start gap-3 p-3 rounded-lg border-2 cursor-pointer ${x===a.id?"border-[#009955] bg-[#009955]/5":"border-border"}`,children:[e.jsx(Ze,{id:`land-${a.id}`,value:a.id.toString(),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:a.name}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ca,{className:"h-3 w-3"}),e.jsx("span",{children:a.location})]}),a.estimatedValue&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Est. value: ",aa(a.estimatedValue)]})]})]},a.id))})}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(l,{htmlFor:"landNickname",children:["Land nickname ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),e.jsx(v,{id:"landNickname",placeholder:"e.g. North 40, Home Farm, River Parcel",value:V,onChange:a=>Ce(a.target.value)}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"A short name for this loan application. Shown throughout the review process."})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(l,{htmlFor:"propname",children:["Land nickname ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(v,{id:"propname",placeholder:"e.g. Smith Farm, North 40, River Parcel",value:b,onChange:a=>ke(a.target.value)}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"A short name for this loan. Shown throughout the review process."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{htmlFor:"addr",children:"Property address"}),e.jsx(v,{id:"addr",placeholder:"1234 Farm Rd, Ames, IA",value:S,onChange:a=>Ae(a.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{children:"County"}),e.jsxs("div",{className:"min-h-10 flex flex-wrap gap-1 rounded-md border border-input bg-background px-3 py-2 text-sm",children:[w.map((a,t)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-[#009955]/10 text-[#009955] rounded px-1.5 py-0.5 text-xs font-medium",children:[a,e.jsx("button",{type:"button",onClick:()=>U(n=>n.filter((f,j)=>j!==t)),className:"hover:text-[#007744]",children:e.jsx(ge,{className:"h-3 w-3"})})]},t)),e.jsx("input",{className:"flex-1 min-w-[80px] outline-none bg-transparent placeholder:text-muted-foreground",placeholder:w.length===0?"Story, Polk...":"Add more...",value:P,onChange:a=>se(a.target.value),onKeyDown:a=>{(a.key==="Enter"||a.key===",")&&P.trim()?(a.preventDefault(),U(t=>[...t,P.trim().replace(/,$/,"")]),se("")):a.key==="Backspace"&&!P&&w.length>0&&U(t=>t.slice(0,-1))},onBlur:()=>{P.trim()&&(U(a=>[...a,P.trim()]),se(""))}})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Press Enter or comma to add multiple."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{children:"State"}),e.jsxs("div",{className:"min-h-10 flex flex-wrap gap-1 rounded-md border border-input bg-background px-3 py-2 text-sm",children:[C.map((a,t)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-[#009955]/10 text-[#009955] rounded px-1.5 py-0.5 text-xs font-medium",children:[a,e.jsx("button",{type:"button",onClick:()=>z(n=>n.filter((f,j)=>j!==t)),className:"hover:text-[#007744]",children:e.jsx(ge,{className:"h-3 w-3"})})]},t)),e.jsx("input",{className:"flex-1 min-w-[60px] outline-none bg-transparent placeholder:text-muted-foreground",placeholder:C.length===0?"IA, NE...":"Add more...",value:k,onChange:a=>ne(a.target.value),onKeyDown:a=>{(a.key==="Enter"||a.key===",")&&k.trim()?(a.preventDefault(),z(t=>[...t,k.trim().replace(/,$/,"")]),ne("")):a.key==="Backspace"&&!k&&C.length>0&&z(t=>t.slice(0,-1))},onBlur:()=>{k.trim()&&(z(a=>[...a,k.trim()]),ne(""))}})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Press Enter or comma to add multiple."})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{htmlFor:"acres",children:"Acres"}),e.jsx(v,{id:"acres",type:"number",placeholder:"160",value:A,onChange:a=>Ie(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{htmlFor:"value",children:"Est. value ($)"}),e.jsx(v,{id:"value",placeholder:"500,000",value:K,onChange:a=>Re(a.target.value)})]})]})]}),e.jsx(Na,{values:{totalPropertyAcreage:m?(c==null?void 0:c.acreage)??"":A,acreageTillable:I,acreagePasture:D,acreageWoodland:F,acreageConservation:_,acreageImprovements:T,acreageOther:L,acreageOtherDescription:E},onChange:a=>{De(String(a.acreageTillable??"")),Fe(String(a.acreagePasture??"")),_e(String(a.acreageWoodland??"")),Te(String(a.acreageConservation??"")),Le(String(a.acreageImprovements??"")),Ee(String(a.acreageOther??"")),Oe(a.acreageOtherDescription??"")}}),e.jsx(u,{className:"w-full bg-[#009955] hover:bg-[#007744]",onClick:ma,children:"Continue"})]})]}),N==="loan"&&e.jsxs(J,{children:[e.jsx(X,{children:e.jsx(Z,{className:"text-lg",children:"Loan Details"})}),e.jsxs(ee,{className:"space-y-5",children:[he&&e.jsxs("div",{className:"p-3 bg-muted rounded-lg text-sm",children:[e.jsx("p",{className:"font-medium",children:he}),c&&e.jsx("p",{className:"text-xs text-muted-foreground",children:c.location})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{htmlFor:"amount",children:"Loan amount"}),e.jsxs("div",{className:"relative",children:[e.jsx(ka,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(v,{id:"amount",inputMode:"numeric",placeholder:"500,000",value:ae,onChange:da,className:"pl-9"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{htmlFor:"ltv",children:"Target LTV (%)"}),e.jsx(v,{id:"ltv",type:"number",min:"0",max:"80",placeholder:"65",value:R,onChange:a=>$e(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{children:"Rate reset period"}),e.jsxs(fe,{value:M,onValueChange:qe,children:[e.jsx(ve,{children:e.jsx(ye,{placeholder:"Select..."})}),e.jsx(je,{children:ba.map(a=>e.jsx(g,{value:String(a),children:wa(a)},a))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(l,{children:["Repayment schedule ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx("div",{className:"grid grid-cols-1 gap-2",children:[{value:"interest_only",label:"Interest Only",desc:"Interest-only payments; full principal due at maturity"},{value:"semi_annual_interest_annual_principal",label:"Semi-annual Interest / Annual Principal",desc:"Interest paid twice a year; a portion of principal paid annually"},{value:"quarterly_interest_annual_principal",label:"Quarterly Interest / Annual Principal",desc:"Interest paid every quarter; a portion of principal paid annually"},{value:"quarterly_amortizing",label:"Quarterly Fully Amortized",desc:"Principal and interest paid each quarter over the loan term"},{value:"monthly_amortizing",label:"Monthly Fully Amortized",desc:"Principal and interest paid each month over the loan term"}].map(a=>e.jsxs("button",{type:"button",onClick:()=>
1Ue(a.value),className:`text-left p-3 rounded-lg border-2 transition-colors ${h===a.value?"border-[#009955] bg-[#009955]/5":"border-border hover:border-[#009955]/40"}`,children:[e.jsx("p",{className:"text-sm font-medium",children:a.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:a.desc})]},a.value))})]}),Ne(h)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{children:"Amortization period"}),e.jsxs(fe,{value:B,onValueChange:Ve,children:[e.jsx(ve,{children:e.jsx(ye,{placeholder:"Select..."})}),e.jsxs(je,{children:[e.jsx(g,{value:"120",children:"10 years (120 months)"}),e.jsx(g,{value:"180",children:"15 years (180 months)"}),e.jsx(g,{value:"240",children:"20 years (240 months)"}),e.jsx(g,{value:"300",children:"25 years (300 months)"}),e.jsx(g,{value:"360",children:"30 years (360 months)"})]})]})]}),M&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{children:"Prepayment penalty"}),e.jsxs(fe,{value:Q,onValueChange:ze,children:[e.jsx(ve,{children:e.jsx(ye,{})}),e.jsxs(je,{children:[e.jsx(g,{value:"none",children:"None"}),e.jsx(g,{value:"3_2_1",children:"3-2-1 step-down"}),e.jsx(g,{value:"5_3_2_1",children:"5-3-2-1 step-down"}),e.jsx(g,{value:"make_whole",children:"Make-whole provision"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Applied if loan is repaid before the rate reset date."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(l,{htmlFor:"firstPrincipalPayment",children:["First principal-payment date ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),e.jsx(v,{id:"firstPrincipalPayment",type:"date",value:W,onChange:a=>ie(a.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(l,{htmlFor:"firstInterestPayment",children:["First interest-payment date ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),e.jsx(v,{id:"firstInterestPayment",type:"date",value:Y,onChange:a=>le(a.target.value)})]}),e.jsx("p",{className:"col-span-2 text-xs text-muted-foreground",children:"Optional, but if you provide one first payment date, provide both."})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(u,{variant:"outline",className:"flex-1",onClick:()=>y("property"),children:"Back"}),e.jsx(u,{className:"flex-1 bg-[#009955] hover:bg-[#007744]",disabled:ue.isPending,onClick:ua,children:ue.isPending?e.jsx(H,{className:"h-4 w-4 animate-spin"}):"Continue"})]})]})]}),N==="documents"&&e.jsxs(J,{children:[e.jsxs(X,{children:[e.jsx(Z,{className:"text-lg",children:"Supporting Documents"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload financial statements, appraisal, and title documents. Required items are marked."})]}),e.jsxs(ee,{className:"space-y-3",children:[Object.entries(Da).map(([a,t])=>{const n=Ke.find(te=>te.docType===a),f=Fa.includes(a),j=ia===a&&Ye.isPending;return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${n?"border-[#009955]/30 bg-[#009955]/5":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Aa,{className:`h-4 w-4 flex-shrink-0 ${n?"text-[#009955]":"text-muted-foreground"}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium",children:[t," ",f&&!n&&e.jsx("span",{className:"text-destructive text-xs",children:"*"})]}),n&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.filename})]})]}),e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:n?e.jsxs(e.Fragment,{children:[e.jsx(ja,{variant:"secondary",className:"text-[#009955] text-xs",children:"Uploaded"}),e.jsx("button",{onClick:()=>ca.mutate(n.id),className:"text-muted-foreground hover:text-destructive",children:e.jsx(ge,{className:"h-3.5 w-3.5"})})]}):e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",className:"hidden",accept:".pdf,.doc,.docx,.jpg,.png",onChange:te=>{var Ge;const He=(Ge=te.target.files)==null?void 0:Ge[0];He&&(oe(a),Ye.mutate({file:He,docType:a})),te.target.value=""}}),e.jsx(u,{size:"sm",variant:"outline",disabled:j,asChild:!0,children:e.jsx("span",{children:j?e.jsx(H,{className:"h-3 w-3 animate-spin"}):e.jsx(Ia,{className:"h-3 w-3"})})})]})})]},a)}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(u,{variant:"outline",className:"flex-1",onClick:()=>y("loan"),children:"Back"}),e.jsx(u,{className:"flex-1 bg-[#009955] hover:bg-[#007744]",onClick:pa,children:"Continue"})]})]})]}),N==="narrative"&&e.jsxs(J,{children:[e.jsxs(X,{children:[e.jsx(Z,{className:"text-lg",children:"Business Statement"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tell capital providers about your farm operation, how you plan to use the funds, and
1your repayment plan."})]}),e.jsxs(ee,{className:"space-y-4",children:[e.jsx(ya,{placeholder:"Describe your operation and the purpose of this loan...",rows:8,value:$,onChange:a=>We(a.target.value),className:"resize-none"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[$.length," / 5000 characters"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u,{variant:"outline",className:"flex-1",onClick:()=>y("documents"),children:"Back"}),e.jsx(u,{className:"flex-1 bg-[#009955] hover:bg-[#007744]",disabled:pe.isPending,onClick:xa,children:pe.isPending?e.jsx(H,{className:"h-4 w-4 animate-spin"}):"Review"})]})]})]}),N==="review"&&e.jsxs(J,{children:[e.jsx(X,{children:e.jsx(Z,{className:"text-lg",children:"Review and Submit"})}),e.jsxs(ee,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg bg-muted p-4 space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Property"}),e.jsx("span",{className:"font-medium",children:he||S})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Amount requested"}),e.jsx("span",{className:"text-xl font-bold",children:aa(me)})]}),R&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Target LTV"}),e.jsxs("span",{className:"font-medium",children:[R,"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Repayment schedule"}),e.jsx("span",{className:"font-medium capitalize",children:h.replace(/_/g," ")})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Documents uploaded"}),e.jsx("span",{className:"font-medium",children:Ke.length})]})]}),e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-900",children:"Fee disclosure"}),e.jsx("p",{className:"text-xs text-amber-800",children:"Land Ledger charges a 1% origination fee on the funded loan amount, collected at closing. Interest accrues from the disbursement date. Annual financial statements may be required during the loan term."})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"By submitting, you authorize Land Ledger to share your application with approved capital providers during the review process."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u,{variant:"outline",className:"flex-1",onClick:()=>y("narrative"),children:"Back"}),e.jsx(u,{className:"flex-1 bg-[#009955] hover:bg-[#007744]",disabled:xe.isPending,onClick:ha,children:xe.isPending?e.jsx(H,{className:"h-4 w-4 animate-spin"}):"Submit Application"})]})]})]})]})})}export{qt 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.