/**
 * ai-analyzer.js — Business Idea Analyzer (Gemini-powered)
 * Tool key: idea_analyzer
 * Place at: /wp-content/themes/businessdiscovered-wp/assets/js/ai-analyzer.js
 */

(function () {
  'use strict';

  var form      = document.getElementById('bd-analyzer-form');
  var resultBox = document.getElementById('bd-analyzer-result');

  if (!form || !resultBox) return;

  form.addEventListener('submit', function (e) {
    e.preventDefault();

    var idea  = (document.getElementById('bd-idea')  || {}).value || '';
    var niche = (document.getElementById('bd-niche') || {}).value || '';

    if (!idea.trim()) {
      bdGemini.showError(resultBox, 'Please describe your business idea first.');
      return;
    }

    bdGemini.showLoading(resultBox, 'Analyzing your business idea…');

    bdGemini.call('idea_analyzer', { idea: idea, niche: niche })
      .then(function (data) { renderResult(data); })
      .catch(function (err) { bdGemini.showError(resultBox, err.message); });
  });

  function renderResult(d) {
    var score       = d.score || 0;
    var scoreColor  = score >= 70 ? '#10b981' : score >= 40 ? '#f59e0b' : '#ef4444';

    resultBox.innerHTML =
      '<div class="bd-report">' +

        // Header
        '<div class="bd-report-header">' +
          '<div class="bd-score-ring" style="--score-color:' + scoreColor + '">' +
            '<div class="bd-score-number">' + score + '</div>' +
            '<div class="bd-score-label">Viability</div>' +
          '</div>' +
          '<div class="bd-report-meta">' +
            '<h2 class="bd-report-title">Business Idea Analysis</h2>' +
            '<p class="bd-report-verdict">' + (d.verdict || '') + '</p>' +
            '<div class="bd-report-badges">' +
              '<span class="bd-badge bd-badge-blue">⏱ ' + (d.time_to_profit || 'N/A') + ' to profit</span>' +
              '<span class="bd-badge bd-badge-green">📊 ' + (d.market_size || 'N/A') + '</span>' +
            '</div>' +
          '</div>' +
        '</div>' +

        // SWOT grid
        '<div class="bd-swot-grid">' +
          swotCard('💪 Strengths',     d.strengths,    'green') +
          swotCard('⚠️ Weaknesses',    d.weaknesses,   'red')   +
          swotCard('🚀 Opportunities', d.opportunities,'blue')  +
          swotCard('🛡️ Threats',       d.threats,      'amber') +
        '</div>' +

        // Next steps
        '<div class="bd-section">' +
          '<h3 class="bd-section-title">✅ Recommended Next Steps</h3>' +
          bdGemini.bulletList(d.next_steps) +
        '</div>' +

      '</div>';

    resultBox.style.display = 'block';
    resultBox.scrollIntoView({ behavior: 'smooth', block: 'start' });
  }

  function swotCard(title, items, color) {
    return (
      '<div class="bd-swot-card bd-swot-' + color + '">' +
        '<h4 class="bd-swot-title">' + title + '</h4>' +
        bdGemini.bulletList(items) +
      '</div>'
    );
  }

})();<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//businessdiscovered.com/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://businessdiscovered.com/post-sitemap.xml</loc>
		<lastmod>2026-06-23T13:47:14+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://businessdiscovered.com/page-sitemap.xml</loc>
		<lastmod>2026-06-24T04:14:18+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://businessdiscovered.com/category-sitemap.xml</loc>
		<lastmod>2026-06-23T13:47:14+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Rank Math SEO Plugin (c) Rank Math - rankmath.com -->