import { View, Text, Link } from "@react-pdf/renderer";
import {
  ConditionalPDFTableRow,
  PDFTable,
  PDFTableRow,
  PDFTableRowLink,
} from "./PDFTableComponents";
import { pdfStyles } from "./PDFStyles";

interface FirstTimeBuyerPDFProps {
  formData: any;
}

export const FirstTimeBuyerPDFContent = ({
  formData,
}: FirstTimeBuyerPDFProps) => {
  // Safely parse income arrays — they may arrive as JSON strings
  const applicantIncomes: any[] = (() => {
    const v = formData.applicantIncomes;
    if (!v) return [];
    if (Array.isArray(v)) return v;
    try { return JSON.parse(v); } catch { return []; }
  })();

  const coApplicantIncomes: any[] = (() => {
    const v = formData.coApplicantIncomes;
    if (!v) return [];
    if (Array.isArray(v)) return v;
    try { return JSON.parse(v); } catch { return []; }
  })();

  return (
    <>
      <View style={pdfStyles.section}>
        <Text style={pdfStyles.infoText}>
          &emsp; Thank you for your interest in the Lackawanna Housing
          Development Corporation’s (LHDC) First-Time Homebuyer Assistance
          Program. If you decide to apply, please complete all required
          information within this application and compile the required income
          and eligibility documents listed on the last page of this application
          packet (Exhibit “A”). LHDC will only accept completed applications
          with 100% of documentation submitted. Once you have completed the
          application and gathered all required documents, please call our
          office at (716) 823-5124 to schedule a meeting to submit your
          application. LHDC will also go over the approval process, eligibility
          requirements, homebuyer education standards, lender coordination, and
          all program restrictions. If you have any questions, please contact
          our office.
        </Text>
        <Text style={pdfStyles.infoText}>
          &emsp; This program assists first-time homebuyers, defined as
          individuals or households who have not owned a home within the past
          three (3) years, in purchasing an owner-occupied 1- or 2-unit home in
          the City of Lackawanna. Eligible applicants must meet moderate-to-low
          income limits and have less than $15,000 in total net assets, not
          including retirement accounts. Funding for this program is provided by
          the New York State Division of Homes and Community Renewal (HCR)
          Office of Affordable Housing Corporation.
        </Text>
        <Text style={pdfStyles.infoText}>
          &emsp; Since this funding source is limited, there is no guarantee
          funds will be available for the entire 2025 Program Year. LHDC may
          need to initiate a waiting list depending on demand and the
          availability of funds. Any waiting list will be based on program
          readiness, income status, and demonstrated need.
        </Text>
        <Text style={pdfStyles.infoText}>
          &emsp; If you are approved for funding through this program, all
          contracts of sale, mortgage agreements, and closing documents will be
          between you and the lender or seller. No purchase offer or contract
          may be executed using program funds prior to authorization by LHDC.
          LHDC does not assign lenders, real estate agents, attorneys, or
          property inspectors; however, a resource directory may be provided to
          assist applicants during the homebuying process.
        </Text>
        <Text style={pdfStyles.infoText}>
          &emsp; We look forward to assisting you in your goal of becoming a
          homeowner. If you have any questions or concerns regarding this
          program, please contact us at 716-823-5124.
        </Text>
        <Text style={pdfStyles.infoText}>
          This Program can provide up to a $ 30,000 deferred loan for the
          purchase and rehab of one (1) or two (2) family homes in the City of
          Lackawanna, funded by the New York State Affordable Housing
          Corporation (AHC), and secured by a mortgage.
        </Text>
        <Text style={pdfStyles.infoTextHighlight}>General Requirements: </Text>
        <Text style={pdfStyles.infoText}>
          1. Maximum gross family income of 80% of area median income (combined
          assets of no more than 25% of unsubsidized sale price of home) *See
          Income Eligibility based on HUD guidelines*
        </Text>
        <Text style={pdfStyles.infoText}>
          2. Must attend Homebuyer Education class
        </Text>
        <Text style={pdfStyles.infoText}>
          3. Must be able to contribute $ 1,500 or 2% of purchase price towards
          down payment and closing costs, whichever is greater
        </Text>
        <Text style={pdfStyles.infoText}>
          4. Must be able to secure a first mortgage, at an acceptable market
          interest rate, with taxes and insurance escrowed
        </Text>
        <Text style={pdfStyles.infoText}>
          5. Home must be approved by LHDC and homeowner must agree to at least
          51% of grant funds ($15,300) to be spent on rehab costs, as determined
          by the LHDC, and rehab to be completed within 6 months of closing
        </Text>
        <Text style={pdfStyles.infoText}>
          6. Live in home for ten (10) years to receive full benefit of subsidy
        </Text>
        <Text style={pdfStyles.infoText}>
          7. Carry Homeowners Insurance naming the NEW YORK STATE AFFORDABLE
          HOUSING CORPORATION as an additional insured
        </Text>
        <Text style={pdfStyles.infoTextHighlight}>
          Steps to Home Ownership:{" "}
        </Text>
        <Text style={pdfStyles.infoText}>
          A. Pre-qualify for a mortgage from a reputable lending institution
        </Text>
        <Text style={pdfStyles.infoText}>
          B. Complete LHDC application to determine eligibility
        </Text>
        <Text style={pdfStyles.infoText}>
          C. Once approved, begin search for a home with a real estate agent
          (~60 days)
        </Text>
        <Text style={pdfStyles.infoText}>
          D. LHDC to inspect and determine scope and cost of rehab
        </Text>
        <Text style={pdfStyles.infoText}>
          E. Applicant to sign rehabilitation agreement
        </Text>
        <Text style={pdfStyles.infoText}>
          F. Sign purchase offer (with LHDC approval, or include contingency for
          LHDC approval)
        </Text>
        <Text style={pdfStyles.infoText}>
          G. An application for a mortgage must be made within seven (7) days of
          acceptance of the purchase offer
        </Text>
        <Text style={pdfStyles.infoText}>H. Close on house (~ 45 days)</Text>
        <Text style={pdfStyles.infoText}>
          I. LHDC will provide homeowner with bid documents
        </Text>
        <Text style={pdfStyles.infoText}>
          J. Solicit a minimum of three (3) bids for rehab within 30 days of
          closing
        </Text>
        <Text style={pdfStyles.infoText}>
          K. Complete rehab within six (6) months of closing
        </Text>
        <Text style={pdfStyles.title}> </Text>
        <Text style={pdfStyles.title}> </Text>

        <Text style={pdfStyles.title}>
          Lackawanna Housing Development Corporation{" "}
        </Text>
        <Text style={pdfStyles.title}>
          First Time Home Buyer Program Application
        </Text>

        <Text style={pdfStyles.sectionTitle}> </Text>
        <PDFTable>
          <PDFTableRow
            label="Applicant’s Legal Name(s)"
            value={formData.applicantName}
          />
          <PDFTableRow
            label="Co-Applicant Name"
            value={formData.coApplicantName}
          />
          <PDFTableRow label="Email Address" value={formData.email} />
          <PDFTableRow label="Cell Phone" value={formData.phoneCell} />
          <PDFTableRow label="Work Phone" value={formData.phoneWork} />
          <PDFTableRow label="Home Phone" value={formData.phoneHome} />
          <ConditionalPDFTableRow
            condition={!!formData.applicantProperty}
            label="Property Address"
            value={formData.applicantProperty}
          />
          <PDFTableRow
            label="Area"
            value={formData.area || formData.applicantArea}
            isLast
          />
        </PDFTable>
      </View>

      <View style={pdfStyles.section}>
        <Text style={pdfStyles.sectionTitle}>Current Employment</Text>
        <PDFTable>
          <PDFTableRow
            label="Applicant Employer"
            value={formData.employerApplicant || formData.applicantEmployerName}
          />
          <PDFTableRow
            hightlight={false}
            label="Applicant Employer Address"
           value={formData.area || formData.applicantArea}
          />
          <ConditionalPDFTableRow
            condition={!!formData.applicantEmployerAddress}
            label="Applicant Employer Address"
            value={formData.applicantEmployerAddress}
          />
          <PDFTableRow
            label="Co-Applicant Employer"
            value={formData.employerCoApplicant}
          />
          <PDFTableRow
            label="Co-Applicant Employer Address"
            value={formData.employerAddressCoApplicant}
            isLast
          />
        </PDFTable>
      </View>


      {/* Applicant Income */}
      {applicantIncomes.length > 0 && (
        <View style={pdfStyles.section}>
          <Text style={pdfStyles.sectionTitle}>Applicant Income</Text>
          <View style={{ borderWidth: 1, borderColor: '#ccc' }}>
            <View style={{ flexDirection: 'row', backgroundColor: '#f3f4f6', borderBottomWidth: 1, borderBottomColor: '#ccc', minHeight: 25, alignItems: 'center' }}>
              <Text style={{ width: '10%', padding: 5, fontSize: 9, fontWeight: 'semibold' }}>Sr No</Text>
              <Text style={{ width: '55%', padding: 5, fontSize: 9, fontWeight: 'semibold' }}>Income Type</Text>
              <Text style={{ width: '35%', padding: 5, fontSize: 9, fontWeight: 'semibold' }}>Income Amount</Text>
            </View>
            {applicantIncomes.map((income: any, index: number) => (
              <View key={index} style={{ flexDirection: 'row', borderBottomWidth: index === applicantIncomes.length - 1 ? 0 : 1, borderBottomColor: '#ccc', minHeight: 25, alignItems: 'center' }}>
                <Text style={{ width: '10%', padding: 5, fontSize: 9 }}>{index + 1}</Text>
                <Text style={{ width: '55%', padding: 5, fontSize: 9 }}>{income.incomeType || 'N/A'}</Text>
                <Text style={{ width: '35%', padding: 5, fontSize: 9 }}>${income.incomeAmount || '0'}</Text>
              </View>
            ))}
            <View style={{ flexDirection: 'row', borderTopWidth: 1, borderTopColor: '#ccc', minHeight: 25, alignItems: 'center', backgroundColor: '#f3f4f6' }}>
              <Text style={{ width: '10%', padding: 5, fontSize: 9 }}></Text>
              <Text style={{ width: '55%', padding: 5, fontSize: 9, fontWeight: 'semibold' }}>Total</Text>
              <Text style={{ width: '35%', padding: 5, fontSize: 9, fontWeight: 'semibold' }}>
                ${applicantIncomes.reduce((sum: number, inc: any) => sum + (parseFloat(inc.incomeAmount) || 0), 0).toFixed(2)}
              </Text>
            </View>
          </View>
        </View>
      )}

      {/* Co-Applicant Income */}
      {coApplicantIncomes.length > 0 && (
        <View style={pdfStyles.section}>
          <Text style={pdfStyles.sectionTitle}>Co-Applicant Income</Text>
          <View style={{ borderWidth: 1, borderColor: '#ccc' }}>
            <View style={{ flexDirection: 'row', backgroundColor: '#f3f4f6', borderBottomWidth: 1, borderBottomColor: '#ccc', minHeight: 25, alignItems: 'center' }}>
              <Text style={{ width: '10%', padding: 5, fontSize: 9, fontWeight: 'semibold' }}>Sr No</Text>
              <Text style={{ width: '55%', padding: 5, fontSize: 9, fontWeight: 'semibold' }}>Income Type</Text>
              <Text style={{ width: '35%', padding: 5, fontSize: 9, fontWeight: 'semibold' }}>Income Amount</Text>
            </View>
            {coApplicantIncomes.map((income: any, index: number) => (
              <View key={index} style={{ flexDirection: 'row', borderBottomWidth: index === coApplicantIncomes.length - 1 ? 0 : 1, borderBottomColor: '#ccc', minHeight: 25, alignItems: 'center' }}>
                <Text style={{ width: '10%', padding: 5, fontSize: 9 }}>{index + 1}</Text>
                <Text style={{ width: '55%', padding: 5, fontSize: 9 }}>{income.incomeType || 'N/A'}</Text>
                <Text style={{ width: '35%', padding: 5, fontSize: 9 }}>${income.incomeAmount || '0'}</Text>
              </View>
            ))}
            <View style={{ flexDirection: 'row', borderTopWidth: 1, borderTopColor: '#ccc', minHeight: 25, alignItems: 'center', backgroundColor: '#f3f4f6' }}>
              <Text style={{ width: '10%', padding: 5, fontSize: 9 }}></Text>
              <Text style={{ width: '55%', padding: 5, fontSize: 9, fontWeight: 'semibold' }}>Total</Text>
              <Text style={{ width: '35%', padding: 5, fontSize: 9, fontWeight: 'semibold' }}>
                ${coApplicantIncomes.reduce((sum: number, inc: any) => sum + (parseFloat(inc.incomeAmount) || 0), 0).toFixed(2)}
              </Text>
            </View>
          </View>
        </View>
      )}

      {formData.payees && formData.payees.length > 0 && (
        <View style={pdfStyles.section}>
          <Text style={pdfStyles.title}>Liabilities</Text>
          <Text style={pdfStyles.sectionTitle}> </Text>
          <PDFTable>
            {formData.payees.map((payee: any, index: number) => (
              <PDFTableRow
                key={index}
                label={
                  ` Payee ${index + 1} - ${payee.payeeName}` ||
                  `Payee ${index + 1}`
                }
                value={`$${payee.amount || "0"}`}
                isLast={index === formData.payees.length - 1}
              />
            ))}
          </PDFTable>
        </View>
      )}

      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>
          Home Improvement Program - Required Certifications
        </Text>
        <Text style={pdfStyles.title}> </Text>
        <Text style={pdfStyles.infoText}>
          1) I hereby certify that I/We am/are the owner(s) and occupant(s) of
          the property to be included within the LHDC Home Improvement Grant
          Program. To the best of my knowledge, all of the information provided
          above is true and accurate. I agree to cooperate with the LHDC which
          is administering this program and to comply with their specified rules
          and procedures.
        </Text>
        <Text style={pdfStyles.infoText}>
          2) I understand that any contract for renovation work paid for in
          whole or in part by a Home Improvement Grant from this program will be
          between the contractor(s) and myself\ourselves, and that I should not
          sign any contract for work under this program until authorized to do
          so by the LHDC. liability, or damage which might arise from my
          relationship with the contractor through this program. In addition, I
          understand that any contract for work to be completed at my/our home
          through a LHDC Home Improvement Grant is between the Contractor I/We
          have selected and myself/ourselves.
        </Text>
        <Text style={pdfStyles.infoText}>
          3) The above information is true and accurate to the best of my
          knowledge. I am aware that Section 1001 of Title 18 of the United
          States code makes it a criminal offense to make willful false
          statements or misrepresentations to any department or agency of the
          United States as to matters within its jurisdiction. In addition, I
          also certify that all information provided in this program application
          and all financial information provided to the LHDC is true and
          accurate. If upon further review, information that was provided to the
          LHDC for program purposes is found to be false, I understand that
          criminal proceedings will be commenced.
        </Text>
        <Text style={pdfStyles.infoText}>
          4) The LHDC and the New York State Affordable Housing Corporation are
          NOT responsible or liable for any breach of contract, faulty
          workmanship, accident liability, installation, performance,
          workmanship, liability, or damages which might arise from my
          participation in this program. Upkeep of the device(s) installed
          through my participation with this program is my/our responsibility.
          My\Our signature(s) below indicates my/our understanding of this
          statement.
        </Text>
        <Text style={pdfStyles.infoText}>
          5) I understand that if this application is approved and I receive a
          grant from the LHDC, a mortgage will be placed on my property by the
          New York State Affordable Housing Corporation as a condition of
          receiving said grant. The mortgage guarantees repayment upon the sale
          or transfer of my property or upon death of the applicant(s).
        </Text>
        <Text style={pdfStyles.infoText}>
          6) I understand that while in the grant recapture period, I must
          complete and return a yearly Continued Occupancy Affidavit to the
          LHDC. Additionally, I understand that the AHC in the care of LHDC will
          be added as a mortgagee to my homeowner's insurance which must be in
          effect throughout the duration of my grant recapture period.
        </Text>
      </View>

      <Text style={pdfStyles.title}> </Text>
      <Text style={pdfStyles.title}> </Text>
      <Text style={pdfStyles.title}> </Text>
      <Text style={pdfStyles.title}> </Text>
   

      {formData.certificationSignerName && (
        <View style={pdfStyles.section}>
          <Text style={pdfStyles.sectionTitle}></Text>
          <PDFTable>
            <PDFTableRow label="Signer Name" value={formData.certificationSignerName} />
            <PDFTableRow label="Date & Time" value={formData.certificationDateTime ? new Date(formData.certificationDateTime).toLocaleString() : "N/A"} isLast />
          </PDFTable>
        </View>
      )}

      <View style={pdfStyles.section}>
        {/* <Text style={pdfStyles.sectionTitle}>Notary Acknowledgment</Text> */}
        <Text style={pdfStyles.infoText}>STATE OF NEW YORK</Text>
        <Text style={pdfStyles.infoText}>COUNTY OF ERIRSS:</Text>
        <Text style={pdfStyles.infoText}> </Text>
        <Text style={pdfStyles.infoText}>
          On the <Text style={{fontWeight: 'bold'}}>{formData.notaryDay || "______"}</Text> day of <Text style={{fontWeight: 'bold'}}>{formData.notaryMonth || "______"}</Text>, in the year <Text style={{fontWeight: 'bold'}}>{formData.notaryYear || "_______"}</Text>, before me, the
          undersigned, a notary public in and for said state, personally
          appeared <Text style={{fontWeight: 'bold'}}>{formData.notaryAppearedName || "_______________________________"}</Text>, personally known to me or
          proved to me on the basis of satisfactory evidence to be the
          individual(s) whose name(s) is/are subscribed to the within instrument
          and acknowledged to me that he/she/they executed the same in
          his/her/their capacity(ies), and that by his/her/their signature(s) on
          the instrument, the individual(s), or the person upon behalf of which
          the individual(s) acted, executed the instrument.
        </Text>
      </View>
      <Text style={pdfStyles.title}> </Text>
      <Text style={pdfStyles.title}> </Text>

      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>
          AUTHORIZATION TO RECEIVE AND VERIFY EMPLOYMENT INFORMATION{" "}
        </Text>
        <Text style={pdfStyles.infoText}>
          We hereby consent to the sharing among you of any employment
          information which we obtain for the purpose of processing my\our
          application for the LHDC Home Improvement Grant Program. I\We waive
          any rights which I\We may have to keep that information confidential
          so long as it is shared only among you for determining my/our
          eligibility to receive a grant through this program. I\We also agree
          to hold harmless the LHDC from any claims for damages for use of that
          information in the manner provided by this waiver.
        </Text>
        <Text style={pdfStyles.infoTextHighlight}>
          NOTICE TO APPLICANT: to process this application. By signing this
          form, you consent to employers sharing employment information about
          you
        </Text>
      </View>
      {formData.authorizationSignerName && (
        <View style={pdfStyles.section}>
          <Text style={pdfStyles.sectionTitle}></Text>
          <PDFTable>
            <PDFTableRow
              label="Signer Name"
              value={formData.authorizationSignerName}
            />
            <PDFTableRow
              label="Date & Time"
              value={
                formData.authorizationDateTime
                  ? new Date(formData.authorizationDateTime).toLocaleString()
                  : "N/A"
              }
            />

            {/* Co-Applicant */}
            <PDFTableRow
              label="Co-Applicant Signer Name"
              value={formData.coApplicantAuthorizationSignerName || "N/A"}
            />

            <PDFTableRow
              label="Co-Applicant Date & Time"
              value={
                formData.coApplicantAuthorizationDateTime
                  ? new Date(
                      formData.coApplicantAuthorizationDateTime,
                    ).toLocaleString()
                  : "N/A"
              }
              isLast
            />
          </PDFTable>
        </View>
      )}

      <Text style={pdfStyles.title}> </Text>
      <Text style={pdfStyles.title}> </Text>
      <Text style={pdfStyles.title}> </Text>

      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>AUTHORIZATION OF INSPECTION </Text>
        <Text style={pdfStyles.infoText}>
          I hereby grant the Lackawanna Housing Development Corporation
          permission to inspect my property and to be on my property located at:
        </Text>
        <Text style={pdfStyles.infoText}>
          for the purpose of evaluating program needs and for all other program
          procedures and purposes. I also agree to hold harmless the LHDC from
          any claims for damages resulting from such access to my property
          through this program.
        </Text>
      </View>

      

      {formData.inspectionSignerName && (
        <View style={pdfStyles.section}>
          <Text style={pdfStyles.sectionTitle}></Text>
          <PDFTable>
            <PDFTableRow label="Signer Name" value={formData.inspectionSignerName} />
            <PDFTableRow label="Date & Time" value={formData.inspectionDateTime ? new Date(formData.inspectionDateTime).toLocaleString() : "N/A"} />
            <PDFTableRow label="Co-Applicant Signer Name" value={formData.inspectionCoApplicantSignerName || "N/A"} />
            <PDFTableRow label="Co-Applicant Date & Time" value={formData.inspectionCoApplicantDateTime ? new Date(formData.inspectionCoApplicantDateTime).toLocaleString() : "N/A"} isLast />
          </PDFTable>
        </View>
      )}

      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>BID RESPONSIBILITY </Text>
        <Text style={pdfStyles.infoText}>
          I, the undersigned homeowner, acknowledge that I am responsible for
          obtaining bids from licensed and insured contractors. I understand
          that I will have four (4) weeks from the date I receive my bid
          packages to secure and submit three (3) contractor bids to the
          Lackawanna Housing Development Corporation (LHDC). Extensions will
          only be granted at the discretion of the LHDC.
        </Text>
      </View>

      {(formData.bidApplicantSignerName ||
        formData.bidCoApplicantSignerName) && (
        <View style={pdfStyles.section}>
          <Text style={pdfStyles.sectionTitle}>Bid Signatures</Text>
          <PDFTable>
            {formData.bidApplicantSignerName && (
              <>
                <PDFTableRow
                  label="Applicant Signer"
                  value={formData.bidApplicantSignerName}
                />
                <PDFTableRow
                  label="Applicant Date & Time"
                  value={
                    formData.bidApplicantDateTime
                      ? new Date(formData.bidApplicantDateTime).toLocaleString()
                      : "N/A"
                  }
                />
              </>
            )}
            {formData.bidCoApplicantSignerName && (
              <>
                <PDFTableRow
                  label="Co-Applicant Signer"
                  value={formData.bidCoApplicantSignerName}
                />
                <PDFTableRow
                  label="Co-Applicant Date & Time"
                  value={
                    formData.bidCoApplicantDateTime
                      ? new Date(
                          formData.bidCoApplicantDateTime,
                        ).toLocaleString()
                      : "N/A"
                  }
                  isLast
                />
              </>
            )}
          </PDFTable>
        </View>
      )}
      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>
          Subordination of AHC Notes & Mortgages
        </Text>
        <Text style={pdfStyles.infoText}>
          The AHC will generally not subordinate its Note and Mortgages to the
          lien of a subsequent Note and Mortgage made to another lender, except
          under certain circumstances, such as:
        </Text>
        <Text style={pdfStyles.infoText}>
          a. The Subordination is needed to relieve a severe hardship that may
          occur due to the death of the homeowner, or in the event of a natural
          (e.g. fire or flood) or financial disaster (e.g. a prolonged disabling
          injury or other unforeseeable cause of involuntary and extended
          unemployment of loss of income),
        </Text>
        <Text style={pdfStyles.infoText}>
          b. The Subordination is necessary to obtain a straight refinanced
          mortgage with a lower interest-rate or term
        </Text>
        <Text style={pdfStyles.infoText}>
          • AHC will determine in its sole discretion whether or not to issue
          such a Subordination.
        </Text>
        <Text style={pdfStyles.infoText}>
          • AHC will not subordinate the lien position so that a homeowner can
          consolidate or pay off other debt, cash out, obtain a HELOC, or pay
          for home improvements.
        </Text>
        <Text style={pdfStyles.infoText}>
          • AHC will not be subordinate to a variable interest rate.
        </Text>
        <Text style={pdfStyles.infoText}>
          • In addition to basing its determination on whether the request fits
          the circumstances outlined above, AHC will consider the degree to
          which its agreement to subordinate the Note and Mortgage would expose
          AHC grant funds to increased risk. AHC will require information on the
          finances of the homeowner and the value of the mortgaged property in
          order to evaluate the extent of such increased risk.
        </Text>
        <Text style={pdfStyles.infoText}>
          The grantee/subgrantee should inform all home buyers or homeowners
          seeking to participate in an AHC project that AHC funds are subject to
          recapture in the event that the subsidized home is not occupied as the
          principal residence of the home buyer or homeowner for the applicable
          required minimum period, and that the AHC funds are immediately due
          and repayable in case of any default under the Note and Mortgage or
          other lender's loan affecting the mortgaged property.
        </Text>
      </View>
      <View style={pdfStyles.section}>
        <Text style={pdfStyles.sectionTitle}></Text>
        <PDFTable>
          {formData.applicantName && (
            <>
              <PDFTableRow
                label="Applicant Name"
                value={formData.applicantName}
              />
              <PDFTableRow
                label="Date"
                value={
                  formData.inspectionDateTime
                    ? new Date(formData.inspectionDateTime).toLocaleString()
                    : "N/A"
                }
              />
            </>
          )}
          {formData.bidCoApplicantSignerName && (
            <>
              <PDFTableRow
                label="Co-Applicant Name"
                value={formData.coApplicantName}
              />
              <PDFTableRow
                label="Date"
                value={
                  formData.inspectionDateTime
                    ? new Date(formData.inspectionDateTime).toLocaleString()
                    : "N/A"
                }
                isLast
              />
            </>
          )}
        </PDFTable>
      </View>

      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>EXHIBIT "A"</Text>
        <Text style={pdfStyles.title}>
          Lackawanna Housing Development Corporation First Time Home Buyer
          Program
        </Text>
        <Text style={pdfStyles.title}>
          Income Verification Required Documents
        </Text>
        <Text style={pdfStyles.infoText}>• Copy of photo identification</Text>
        <Text style={pdfStyles.infoText}>
          • Mortgage Pre-Qualification or Pre-Approval Letter
        </Text>
        <Text style={pdfStyles.infoText}>
          • Proof of Homebuyer education workshop completion
        </Text>
        <Text style={pdfStyles.infoText}>
          • Copy of latest federal and state income tax filings. (Including ALL
          Schedules and W-2's). If you did not file income taxes we need a
          non-filing tax transcript, call 800-908-9946 or fill out 4506-T or
          visit https://www.irs.gov/individuals/get-transcript and make an
          account to access transcript
        </Text>
        <Text style={pdfStyles.infoText}>
          • Verification of all checking and savings accounts, interest and
          annuity, and insurance income statements.
        </Text>
        <Text style={pdfStyles.infoText}>
          &emsp;a) (Provide last three months statements from your financial
          institution(s))
        </Text>
        <Text style={pdfStyles.infoText}>
          &emsp;b) For all members of household who make income
        </Text>
        <Text style={pdfStyles.infoText}>
          • Verification of employment (four most recent pay stubs for all
          employed occupants).
        </Text>
        <Text style={pdfStyles.infoText}>
          &emsp;a) Verification of employment letter from employer
        </Text>
        <Text style={pdfStyles.infoText}>
          • Verification of benefits: (Provide copies of notice of award or
          benefit for any/all that apply)
        </Text>
        <Text style={pdfStyles.infoText}>&emsp;a) Social Security</Text>
        <Text style={pdfStyles.infoText}>&emsp;b) Pension</Text>
        <Text style={pdfStyles.infoText}>&emsp;c) SSI</Text>
        <Text style={pdfStyles.infoText}>&emsp;d) Disability</Text>
        <Text style={pdfStyles.infoText}>&emsp;e) Alimony/child support</Text>
        <Text style={pdfStyles.infoText}>&emsp;f) Food stamps/HEAP/Etc.</Text>
        <Text style={pdfStyles.infoText}>&emsp;g) Veterans</Text>
        <Text style={pdfStyles.infoText}>&emsp;h) Unemployment</Text>
        <Text style={pdfStyles.infoText}>&emsp;i) Welfare</Text>
        <Text style={pdfStyles.infoText}>&emsp;j) Insurance dividends</Text>
        <Text style={pdfStyles.infoText}>
          • Verification of Certificates of Deposit (Produce all financial
          documentation).
        </Text>
        <Text style={pdfStyles.infoText}>
          • Verification of liabilities (credit card statements, auto loans,
          student loans, etc.)
        </Text>
        <Text style={pdfStyles.infoText}>
          Please submit income documentation from the list above that applies to
          all members of your household
        </Text>
      </View>

      {formData.documents &&
        Array.isArray(formData.documents) &&
        formData.documents.length > 0 && (
          <View style={pdfStyles.section}>
            <Text style={pdfStyles.sectionTitle}>Uploaded Documents</Text>
            <PDFTable>
              {formData.documents.map((doc: any, index: number) => (
                <PDFTableRowLink
                  key={index}
                  label={
                    doc.documentType?.replace(/\($/, "").trim() ||
                    `Document ${index + 1}`
                  }
                  linkText={doc.originalName || "Download"}
                  linkUrl={`${process.env.NEXT_PUBLIC_EXPRESS_BACKEND_PUBLIC || "http://localhost:3000"}/documents/${doc.fileName}`}
                  isLast={index === formData.documents.length - 1}
                />
              ))}
            </PDFTable>
          </View>
        )}
    </>
  );
};
