`;
contentHtml += `
III. Supply Details
`;
contentHtml += `
Total Supply: ${ta_formatNumber(inputs.supply.totalSupply)} ${inputs.basics.tokenTicker}
`;
contentHtml += `
Circulating Supply: ${ta_formatNumber(inputs.supply.circulatingSupply)} ${inputs.basics.tokenTicker}
`;
contentHtml += `
`;
if (inputs.allocations && inputs.allocations.length > 0) {
contentHtml += `
IV. Allocation Breakdown
| Category | Percentage (%) | Vesting Notes |
`;
inputs.allocations.forEach(alloc => {
contentHtml += `| ${alloc.name.replace(/ | ${ta_formatPercentage(alloc.percent)} | ${alloc.vesting.replace(/ |
`;
});
contentHtml += `
`;
}
contentHtml += `
V. Utility & Demand
`;
let utilsUsed = [];
if (inputs.utility.governance) utilsUsed.push("Governance");
if (inputs.utility.fees_burn) utilsUsed.push("Platform Fees/Burn");
if (inputs.utility.staking) utilsUsed.push("Staking/Yield");
if (inputs.utility.access) utilsUsed.push("Service Access");
if (inputs.utility.moe) utilsUsed.push("Medium of Exchange");
contentHtml += `
Primary Utilities: ${utilsUsed.length > 0 ? utilsUsed.join(', ') : 'None explicitly selected'}
`;
if (inputs.utility.other) contentHtml += `
Other Utilities: ${inputs.utility.other.replace(/
`;
if (inputs.utility.demandDrivers) contentHtml += `
Key Demand Drivers: ${inputs.utility.demandDrivers.replace(/
`;
contentHtml += `
`;
contentHtml += `
VI. Monetary Policy
`;
contentHtml += `
Emission Model: ${inputs.monetary.status}
`;
if (inputs.monetary.inflationDetails) contentHtml += `
Emission Details: ${inputs.monetary.inflationDetails.replace(/
`;
contentHtml += `
Deflationary Mechanisms: ${inputs.monetary.deflationStatus.toUpperCase()}
`;
if (inputs.monetary.deflationStatus === 'yes' && inputs.monetary.deflationDetails) contentHtml += `
Deflation Details: ${inputs.monetary.deflationDetails.replace(/
`;
contentHtml += `
`;
if (observations && observations.length > 0) {
contentHtml += `
VII. Key Observations & Considerations
`;
observations.forEach(obs => {
contentHtml += `
${obs.type === 'warning' ? 'Potential Concern: ' : 'Note: '}${obs.text.replace(/`;
});
}
const disclaimer_pdf = `This analysis is based on user-provided data. Tokenomics are complex, involve significant risks, and can change. Always conduct thorough independent research (DYOR) and consult with a qualified financial advisor before making investment decisions.`;
pdfContentEl.innerHTML = `
${contentHtml}
Disclaimer: ${disclaimer_pdf}
`;
document.body.appendChild(pdfContentEl);
html2canvas(pdfContentEl, { scale: 2, useCORS: true, logging:true, width: pdfContentEl.scrollWidth, height: pdfContentEl.scrollHeight }).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = pdf.internal.pageSize.getHeight();
const imgProps = pdf.getImageProperties(imgData);
let imgHeight = (imgProps.height * (pdfWidth - 40)) / imgProps.width;
let currentPosition = 20;
if (imgHeight <= pdfHeight - 40) {
pdf.addImage(imgData, 'PNG', 20, currentPosition, pdfWidth - 40, imgHeight, undefined, 'FAST');
} else { // Basic multi-page handling
let renderedHeight = 0;
while(renderedHeight < imgProps.height) {
const pageCanvas = document.createElement('canvas');
pageCanvas.width = imgProps.width;
// Calculate height for one PDF page based on aspect ratio, or fixed slice
const sliceHeight = Math.min(imgProps.height - renderedHeight, ( (pdfHeight - 40) / (pdfWidth - 40) ) * imgProps.width );
pageCanvas.height = sliceHeight;
const ctx = pageCanvas.getContext('2d');
ctx.drawImage(canvas, 0, renderedHeight, imgProps.width, sliceHeight, 0, 0, imgProps.width, sliceHeight);
const pageImgData = pageCanvas.toDataURL('image/png');
const pageImgHeight = (sliceHeight * (pdfWidth - 40)) / imgProps.width;
if (currentPosition + pageImgHeight > pdfHeight - 20 && renderedHeight > 0) { // check if needs new page
pdf.addPage();
currentPosition = 20;
}
pdf.addImage(pageImgData, 'PNG', 20, currentPosition, pdfWidth - 40, pageImgHeight, undefined, 'FAST');
renderedHeight += sliceHeight;
currentPosition += pageImgHeight + 10; // add some space, or reset for new page
if(renderedHeight < imgProps.height && currentPosition + 20 > pdfHeight -20) { // if more content and no space
// pdf.addPage(); currentPosition = 20; // already handled by next iteration
}
}
}
pdf.save(`${(inputs.basics.projectName || "Tokenomics").replace(/[^a-z0-9]/gi, '_')}_Analysis.pdf`);
if(document.body.contains(pdfContentEl)) document.body.removeChild(pdfContentEl);
}).catch(err => {
console.error("Tokenomics Analyzer PDF Error:", err); alert("Error generating Tokenomics PDF. See console.");
if(document.body.contains(pdfContentEl)) document.body.removeChild(pdfContentEl);
});
}
document.addEventListener('DOMContentLoaded', function() {
ta_openTab({}, 'ta_tab_basics');
ta_addAllocationRow(); // Add one default allocation row
ta_addAllocationRow();
ta_addAllocationRow();
if (!document.getElementById('ta_projectName')) {
console.error("Critical input 'ta_projectName' not found.");
}
});