import PDFKit from 'pdfkit';
import { Invoice } from '../../types/invoice.types';

export class SalutationSection {
  private doc: PDFKit.PDFDocument;
  private currentY: number;

  constructor(doc: PDFKit.PDFDocument, currentY: number) {
    this.doc = doc;
    this.currentY = currentY;
  }

  /**
   * Bereich 2: Ansprache zur Rechnung
   * DIN 5008: Mindestens 20mm Abstand zur Empfänger-Adresse
   */
  public draw(invoice: Invoice): number {
    // Rechnungstitel in gleicher Schriftgröße wie Ansprache
    this.doc.font('Helvetica-Bold')
      .fontSize(10) // Gleiche Schriftgröße wie Ansprache
      .text('Rechnung', 50, this.currentY, { continued: false });
    
    this.currentY += 25;
    
    // Ansprache
    this.doc.font('Helvetica')
      .fontSize(10)
      .text(invoice.salutation.greeting, 50, this.currentY, { continued: false });
    this.currentY += 15;
    this.doc.text(invoice.salutation.introduction, 50, this.currentY, { continued: false });
    
    this.currentY += 25;
    
    return this.currentY;
  }
} 