window.trafagDownload = { saveTextFile: function (filename, content, contentType) { const blob = new Blob([content], { type: contentType || "application/json;charset=utf-8" }); const url = URL.createObjectURL(blob); const link = document.createElement("a"); link.href = url; link.download = filename; document.body.appendChild(link); link.click(); document.body.removeChild(link); URL.revokeObjectURL(url); }, printElement: function (elementId) { const element = document.getElementById(elementId); if (!element) { window.print(); return; } const title = element.querySelector(".hr-print-header h1")?.textContent || document.title; const printWindow = window.open("", "_blank", "noopener,noreferrer,width=1200,height=900"); if (!printWindow) { window.print(); return; } const styles = Array.from(document.querySelectorAll('link[rel="stylesheet"], style')) .map(node => node.outerHTML) .join("\n"); printWindow.document.open(); printWindow.document.write(`