Public Sentiment: ${getSelectText('publicSentiment')}
Regulatory Clarity: ${getSelectText('regulatoryClarity')}
Prediction Horizon: ${getSelectText('predictionHorizon')}
`;
// --- Heuristic Prediction Logic ---
let overallScore = 0;
overallScore += (scores.techMaturity[inputs.techMaturity] || 0) * 0.1;
overallScore += (scores.institutionType[inputs.institutionType] || 0) * 0.20;
overallScore += (scores.adoptionNature[inputs.adoptionNature] || 0) * 0.25;
overallScore += (scores.adoptionScale[inputs.adoptionScale] || 0) * 0.30;
overallScore += (scores.publicSentiment[inputs.publicSentiment] || 0) * 0.1; // Sentiment can be positive or negative
overallScore += (scores.regulatoryClarity[inputs.regulatoryClarity] || 0) * 0.15; // Clarity can be positive or negative
const marketCap = parseFloat(inputs.marketCap);
if (marketCap < 1000000000) overallScore *= 1.1; // Higher % impact potential for smaller caps
if (marketCap > 50000000000) overallScore *= 0.9; // Harder to move large caps significantly
// Adjustments for specific combinations
if (inputs.institutionType === 'etf_provider' && inputs.adoptionNature === 'etf_investment') {
overallScore += 1; // ETF launch is typically very impactful
}
if (inputs.regulatoryClarity === 'very_high' && scores.adoptionScale[inputs.adoptionScale] >= 4) {
overallScore += 0.5; // High clarity + large scale is a strong positive
}
if (inputs.regulatoryClarity === 'very_low' && scores.adoptionScale[inputs.adoptionScale] >= 3) {
overallScore -= 1; // Very low clarity + significant investment is high risk
}
// --- Generate Predicted Impacts HTML ---
let impactsHTML = "";
let keyDriversText = "";
let risksCaveatsText = "";
// Overall Predicted Impact
let overallImpact = { text: "Neutral", class: "impact-neutral" };
if (overallScore >= 4) overallImpact = { text: "Very High Positive Impact", class: "impact-positive-vhigh" };
else if (overallScore >= 3) overallImpact = { text: "High Positive Impact", class: "impact-positive-high" };
else if (overallScore >= 1.5) overallImpact = { text: "Moderate Positive Impact", class: "impact-positive-moderate" };
else if (overallScore <= -2) overallImpact = { text: "High Negative Impact", class: "impact-negative-high" };
else if (overallScore <= -0.5) overallImpact = { text: "Moderate Negative Impact", class: "impact-negative-moderate" };
impactsHTML += `
Overall Predicted Impact: ${overallImpact.text}
`;
// Price Momentum
let priceMomentum = { text: "Neutral/Mixed", class: "impact-neutral" };
// Simplified: strong positive adoption and sentiment -> upward
if (scores.adoptionScale[inputs.adoptionScale] >= 4 && scores.publicSentiment[inputs.publicSentiment] > 0 && scores.regulatoryClarity[inputs.regulatoryClarity] >=0) {
if (overallScore > 2.5) priceMomentum = { text: "Strong Upward", class: "impact-positive-vhigh" };
else if (overallScore > 1) priceMomentum = { text: "Moderate Upward", class: "impact-positive-high" };
} else if (scores.publicSentiment[inputs.publicSentiment] < 0 && scores.regulatoryClarity[inputs.regulatoryClarity] < 0){
if (overallScore < -1.5) priceMomentum = { text: "Strong Downward", class: "impact-negative-high" };
else if (overallScore < 0) priceMomentum = { text: "Moderate Downward", class: "impact-negative-moderate" };
}
impactsHTML += `
Price Momentum: ${priceMomentum.text}
`;
if(priceMomentum.text !== "Neutral/Mixed") keyDriversText += `
${getSelectText('adoptionScale')} scale adoption by a ${getSelectText('institutionType').toLowerCase()} and ${getSelectText('publicSentiment').toLowerCase()} sentiment are key for predicted price momentum.`;
// Market Cap Growth Potential (linked to overall score)
let mcGrowth = { text: "Moderate", class: "impact-positive-moderate" };
if (overallScore >= 3.5) mcGrowth = { text: "Very Significant", class: "impact-positive-vhigh" };
else if (overallScore >= 2) mcGrowth = { text: "Significant", class: "impact-positive-high" };
else if (overallScore <= 0) mcGrowth = { text: "Low", class: "impact-neutral" };
impactsHTML += `
Market Cap Growth Potential: ${mcGrowth.text}
`;
// Trading Volume Change
let volChange = { text: "Moderate Increase", class: "impact-positive-high" };
if (scores.adoptionScale[inputs.adoptionScale] >= 3 || inputs.institutionType === 'etf_provider') volChange = { text: "Significant Increase", class: "impact-positive-vhigh" };
else if (scores.adoptionScale[inputs.adoptionScale] <=1) volChange = { text: "Minor Increase", class: "impact-positive-moderate" };
impactsHTML += `
Trading Volume Change: ${volChange.text}
`;
// Liquidity Effect
let liquidityEffect = { text: "Moderate Improvement", class: "impact-positive-high" };
if (scores.adoptionScale[inputs.adoptionScale] >= 3 && (inputs.adoptionNature === 'direct_purchase' || inputs.adoptionNature === 'etf_investment' || inputs.adoptionNature === 'trading_services')) {
liquidityEffect = { text: "Significant Improvement", class: "impact-positive-vhigh" };
} else if (scores.adoptionScale[inputs.adoptionScale] <= 1) {
liquidityEffect = { text: "Minor Improvement", class: "impact-positive-moderate" };
}
impactsHTML += `
Market Liquidity Effect: ${liquidityEffect.text}
`;
// Short-Term Volatility Impact
let volatilityImpact = { text: "Increase Moderately", class: "impact-negative-moderate" }; // Default to increase with big news
if (inputs.predictionHorizon === 'long_term' && scores.techMaturity[inputs.techMaturity] >= 3 && scores.adoptionScale[inputs.adoptionScale] >=3) {
volatilityImpact = { text: "Likely to Decrease Moderately (long-term)", class: "impact-positive-moderate" };
} else if (inputs.institutionType === 'etf_provider') {
volatilityImpact = { text: "Increase Significantly (around event)", class: "impact-negative-high" };
}
impactsHTML += `
Short-Term Volatility Impact: ${volatilityImpact.text}
`;
// Mainstream Adoption Catalyst Potential
let catalystPotential = { text: "Moderate", class: "impact-positive-high" };
if (scores.adoptionScale[inputs.adoptionScale] >= 4 && (inputs.institutionType === 'etf_provider' || inputs.institutionType === 'pension_fund' || inputs.institutionType === 'sovereign_wealth' || inputs.institutionType === 'asset_manager')) {
catalystPotential = { text: "Very High", class: "impact-positive-vhigh" };
keyDriversText += `
Adoption by a ${getSelectText('institutionType').toLowerCase()} at ${getSelectText('adoptionScale').toLowerCase()} scale significantly boosts mainstream catalyst potential.`;
} else if (scores.adoptionScale[inputs.adoptionScale] <= 2) {
catalystPotential = { text: "Low", class: "impact-positive-moderate" };
}
impactsHTML += `
Mainstream Adoption Catalyst Potential: ${catalystPotential.text}
`;
// Regulatory Scrutiny Outlook
let regScrutiny = { text: "Likely to Increase Moderately", class: "impact-neutral" };
if (scores.adoptionScale[inputs.adoptionScale] >= 3 || inputs.institutionType === 'etf_provider') {
regScrutiny = { text: "Likely to Increase Significantly", class: "impact-negative-moderate" }; // Increased scrutiny isn't always negative in effect, but it's a factor.
keyDriversText += `
Significant institutional involvement, especially via products like ETFs, is expected to increase regulatory scrutiny.`;
} else if (scores.regulatoryClarity[inputs.regulatoryClarity] >= 1) {
regScrutiny = { text: "No Significant Change (due to existing clarity)", class: "impact-neutral" };
}
impactsHTML += `
Regulatory Scrutiny Outlook: ${regScrutiny.text}
`;
predictedImpactsEl.innerHTML = impactsHTML;
// Key Drivers
if (!keyDriversText) keyDriversText = "
The combination of various factors contributes to the overall prediction. Specific drivers become more prominent with higher impact scenarios.";
keyDriversEl.innerHTML = `
`;
// Risks & Caveats
risksCaveatsText = `
- This prediction is heuristic and not financial advice. Market conditions can change rapidly.
- Unforeseen global macroeconomic events can override specific crypto-related factors.
- The ${getSelectText('predictionHorizon').toLowerCase()} timeframe influences the relevance of certain impacts (e.g., short-term volatility vs. long-term stability).
- If regulatory sentiment shifts negatively, especially in key markets, predictions could be adversely affected.
- Success of the underlying cryptocurrency project and its technology remains a fundamental factor.
`;
risksCaveatsEl.innerHTML = risksCaveatsText;
reportTabButton.disabled = false;
updateNavigationButtons();
return true;
}
function validateAndProcess() {
if (validateInputs()) {
if(calculateImpactPrediction()){
return true;
} else {
reportTabButton.disabled = true;
updateNavigationButtons();
return false;
}
} else {
reportTabButton.disabled = true;
updateNavigationButtons();
return false;
}
}
if (predictButton) {
predictButton.addEventListener('click', () => {
if(validateAndProcess()){
showTab('reportTab', reportTabButton);
}
});
}
if (downloadPdfButton) {
downloadPdfButton.addEventListener('click', () => {
const { jsPDF } = window.jspdf;
const reportContent = document.getElementById('pdfReportContent');
if (!reportContent) {
console.error("PDF report content area not found.");
// Add a user-friendly message if element is not found
const overallAssessmentEl = document.getElementById('predictedImpacts'); // Fallback element
if(overallAssessmentEl) {
const p = document.createElement('p');
p.textContent = "Error: Could not generate PDF. Report content missing.";
p.className = "error-message text-center";
overallAssessmentEl.appendChild(p);
setTimeout(() => p.remove(), 5000);
}
return;
}
html2canvas(reportContent, { scale: 2, useCORS: true })
.then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = pdf.internal.pageSize.getHeight();
const ratio = canvas.width / canvas.height;
let imgWidth = pdfWidth - 20; // 10mm margin each side
let imgHeight = imgWidth / ratio;
if (imgHeight > pdfHeight - 20) {
imgHeight = pdfHeight - 20; // 10mm margin top/bottom
imgWidth = imgHeight * ratio;
}
const x = (pdfWidth - imgWidth) / 2;
const y = 10;
pdf.addImage(imgData, 'PNG', x, y, imgWidth, imgHeight);
const cryptoNameVal = document.getElementById('cryptoName')?.value.trim() || "institutional_impact";
pdf.save(`${cryptoNameVal.replace(/\s+/g, '_')}_impact_prediction.pdf`);
}).catch(error => {
console.error("Error generating PDF: ", error);
const overallAssessmentEl = document.getElementById('predictedImpacts'); // Fallback
if(overallAssessmentEl) {
const p = document.createElement('p');
p.textContent = "An error occurred while generating the PDF. Please try again.";
p.className = "error-message text-center";
overallAssessmentEl.appendChild(p);
setTimeout(() => p.remove(), 5000);
}
});
});
}
updateNavigationButtons(); // Initial call
});