`;
const tempContainer = document.createElement('div');
tempContainer.style.position = 'absolute';
tempContainer.style.left = '-9999px';
tempContainer.innerHTML = pdfContentHtml;
document.body.appendChild(tempContainer);
try {
const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'letter' });
await pdf.html(tempContainer.querySelector('#pdf-output-container'), {
margin: [72, 72, 72, 72],
autoPaging: 'text',
width: 468,
windowWidth: 700,
});
pdf.save(`class_action_report_${caseName.replace(/ /g, '_') || 'analysis'}.pdf`);
} catch (error) {
console.error("Error generating PDF:", error);
} finally {
document.body.removeChild(tempContainer);
btn.textContent = 'Download Report as PDF';
btn.disabled = false;
}
};
// --- Event Listeners ---
tabs.forEach(tab => tab.addEventListener('click', () => showTab(parseInt(tab.dataset.tab, 10))));
nextBtn.addEventListener('click', () => { if (currentTab < totalTabs) showTab(currentTab + 1); });
prevBtn.addEventListener('click', () => { if (currentTab > 1) showTab(currentTab - 1); });
if(downloadPdfBtn) downloadPdfBtn.addEventListener('click', downloadPDF);
// --- Initial Setup ---
showTab(1);
});
