"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hcodeInstitutionalTemplate = hcodeInstitutionalTemplate;
const components_1 = require("../components");
// ─────────────────────────────────────────────────────────────────────────────
// Template
// ─────────────────────────────────────────────────────────────────────────────
/**
 * hcode Institutional template — Design System v1.0
 *
 * Structure:
 *   Page 1 — Full-bleed cover (break-after)
 *   Page 2+ — accent bar + header + content sections
 *
 * All sections are optional; only present when the corresponding data
 * field is provided and non-empty.
 */
function hcodeInstitutionalTemplate(data, config) {
    var _a;
    const coverData = {
        title: data.title,
        subtitle: data.subtitle,
        bottomMeta: data.coverMeta,
    };
    const pageTitle = (_a = data.pageTitle) !== null && _a !== void 0 ? _a : `${config.area.toUpperCase()} · ${data.title}`;
    // ── Content sections ──────────────────────────────────────────────────────
    const sections = [];
    // Purpose block (description)
    if (data.description) {
        sections.push((0, components_1.purposeBlock)('SOBRE O PROJETO', config.companyName.toUpperCase(), data.description));
    }
    // Feature cards
    if (data.features && data.features.length > 0) {
        sections.push((0, components_1.sectionHeader)('DIFERENCIAIS', 'O que entregamos'));
        sections.push((0, components_1.featureCards)(data.features));
    }
    // Data table
    if (data.tableHeaders &&
        data.tableHeaders.length > 0 &&
        data.tableRows &&
        data.tableRows.length > 0) {
        sections.push((0, components_1.sectionHeader)('EXECUÇÃO', 'Plano de trabalho'));
        sections.push((0, components_1.dataTable)(data.tableHeaders, data.tableRows));
    }
    // Metadata block
    if (data.metadata && data.metadata.length > 0) {
        sections.push((0, components_1.metadataBlock)(data.metadata));
    }
    // Signature area
    if (data.signatories && data.signatories.length > 0) {
        sections.push((0, components_1.sectionHeader)('ACEITE', 'Assinaturas'));
        sections.push((0, components_1.signatureArea)(data.signatories));
    }
    // ── Assembly ──────────────────────────────────────────────────────────────
    const body = [
        // Page 1: cover
        (0, components_1.coverPage)(config, coverData),
        // Page 2+: content
        (0, components_1.pageAccentBar)(),
        (0, components_1.pageHeader)(config, pageTitle),
        `<div class="page-content">${sections.join('\n')}</div>`,
        // Fixed footer (appears on every page including cover)
        (0, components_1.pdfFooter)(config.companyName),
    ].join('\n');
    return (0, components_1.pageShell)('', body, config);
}
//# sourceMappingURL=hcode-institutional.template.js.map