toast(`Duplicated (new id ${d.id})`, "ok"); await load(); } if (b.dataset.pdf) { b.disabled = true; b.textContent = "Rendering…"; try { const d = await POST(`/templates/${id}/test-pdf`); const blob = b64Blob(d.pdf_base64, "application/pdf"); dlBlob(blob, `template_${id}_test.pdf`); toast(`PDF generated with ${d.engine} (${fmtBytes(d.size_bytes)}) — downloading`, "ok"); } catch (err) { toast("PDF failed: " + err.message, "err"); } finally { b.disabled = false; b.textContent = "Test PDF"; } } if (b.dataset.del) confirmedAction("Delete this template?", async () => { await api(`/templates/${id}`, {method:"DELETE"}); toast("Deleted","ok"); await load(); }); });