const fs = require('fs');
const path = require('path');

const dir = 'h:\\2026_Creaa Projects\\Digant Sharma\\1. Ai - Website\\2\\Sadananda Das';

const files = fs.readdirSync(dir).filter(f => f.endsWith('.html'));

const sadanandaBio = `
<p style="margin-top:1rem;line-height:1.9">Sadananda was born in Germany in 1908. In the early 1930s, he became a disciple of Shrila Bhaktisiddhanta Sarasvati, a prominent guru and spiritual reformer of Gaudiya Vaishnavism in early 20th century India.</p>
<p style="line-height:1.9">He first came in contact with Swami Hridaya Bon Maharaja in 1933 in Berlin, during the latter’s missionary activities in Europe. In 1934, Sadananda moved to London, where the Gaudiya Mission had established a center. There, he was initiated on behalf of Bhaktisiddhanta Sarasvati by Swami Hridaya Bon Maharaja and Swami Bhakti Pradip Tirtha Maharaja.</p>
<p style="line-height:1.9">In 1935, he traveled to India with Swami Bon, where he received the spiritual name "Sadananda Das" from his guru. After the passing of his guru in 1937, he continued his spiritual journey independently, dedicating his life to studying sacred Hindu scriptures and practicing devotional service.</p>
`;

const SadanandaQuote = `<div class="pull-quote">"The highest perfection of human life, achieved either by complete knowledge of matter and spirit, by practice of mystic powers, or by perfect discharge of occupational duty, is to remember the Personality of Godhead at the end of life." — Srimad Bhagavatam 2.1.6</div>`;

const newTimeline = `
<div class="timeline">
<div class="timeline-item fade-left">
<div class="timeline-content">
<span class="timeline-year">1908</span>
<h3>Birth in Germany</h3>
<p>Born in Germany in 1908. His early years were shaped by the intellectual and cultural landscape of Europe, setting the stage for a profound spiritual awakening later in life.</p>
</div>
</div>
<div class="timeline-item fade-right">
<div class="timeline-content">
<span class="timeline-year">1933</span>
<h3>Contact with Swami Hridaya Bon Maharaja</h3>
<p>He first came in contact with Swami Hridaya Bon Maharaja in 1933 in Berlin, during the latter’s missionary activities in Europe for Gaudiya Vaishnavism.</p>
</div>
</div>
<div class="timeline-item fade-left">
<div class="timeline-content">
<span class="timeline-year">1934</span>
<h3>Initiation in London</h3>
<p>In 1934, Sadananda moved to London, where the Gaudiya Mission had established a center. There, he was initiated on behalf of Bhaktisiddhanta Sarasvati by Swami Hridaya Bon Maharaja and Swami Bhakti Pradip Tirtha Maharaja.</p>
</div>
</div>
<div class="timeline-item fade-right">
<div class="timeline-content">
<span class="timeline-year">1935</span>
<h3>Journey to India & New Name</h3>
<p>In 1935, he traveled to India with Swami Bon, where he received the spiritual name "Sadananda Das" from his guru, deeply embedding himself in the Vedic tradition.</p>
</div>
</div>
<div class="timeline-item fade-left">
<div class="timeline-content">
<span class="timeline-year">1937–Onwards</span>
<h3>Independent Spiritual Journey</h3>
<p>After the passing of his guru in 1937, he continued his spiritual journey independently, dedicating his complete life to studying sacred Hindu scriptures and practicing devotional service to Lord Krishna.</p>
</div>
</div>
</div>
`;

for (let file of files) {
    const filePath = path.join(dir, file);
    let content = fs.readFileSync(filePath, 'utf8');

    // Global replaces for Names
    content = content.replace(/Sri Karunya Sagar Dasa/g, 'Sadananda Das');
    content = content.replace(/Sri <span>Karunya Sagar<\/span> Dasa/g, 'Sadananda <span>Das</span>');
    content = content.replace(/Karunya Sagar Dasa/g, 'Sadananda Das');
    content = content.replace(/Sri Karunya Sagar/g, 'Sadananda Das');
    content = content.replace(/VICE PRESIDENT · ISKCON MYSORE/g, 'DISCIPLE OF BHAKTISIDDHANTA SARASVATI');
    content = content.replace(/Vice President, ISKCON Mysore/g, 'A highly revered disciple of Bhaktisiddhanta Sarasvati');
    
    // Replace index.html specific sections
    if (file === 'index.html') {
        // Biography
        content = content.replace(
            /<p style="margin-top:1rem;line-height:1.9.*?<\/div>/s,
            sadanandaBio + '\\n' + SadanandaQuote + '\\n<a href="about.html" class="btn btn-primary" style="margin-top:1rem">Read Full Biography →</a>'
        );
        // Timeline
        content = content.replace(/<div class="timeline">.*?<\/div>\s*<\/div>\s*<\/section>/s, newTimeline + '\\n</div>\\n</section>');
        // Stats update
        content = content.replace(/>28</, '>30<').replace(/Years of Devotional Service in ISKCON/, 'Years Exploring Sacred Hindu Scriptures');
        content = content.replace(/>50000</, '>1000<').replace(/Lives Touched Through Preaching & Outreach/, 'Texts & Sacred Scriptures Studied');
        content = content.replace(/>5000</, '>50<').replace(/Bhagavad Gita Classes & Seminars Conducted/, 'Years of Dedicated Devotional Service');
        content = content.replace(/>100000</, '>1<').replace(/Plates of Prasadam Distributed Annually/, 'Unwavering Devotion to the Supreme');
    }

    if (file === 'about.html') {
        const aboutBio = `
<div class="fade-right">
<h3>Early Life in Germany (1908–1933)</h3>
${sadanandaBio}
</div>
</div>
<div class="split-layout reverse" style="margin-bottom:4rem">
<div class="fade-left">
<h3>Meeting Swami Bon (1933)</h3>
<p style="line-height:1.9">In 1933, his spiritual destiny manifested rapidly when he encountered Swami Hridaya Bon Maharaja in Berlin. This monumental meeting marked the beginning of his connection to the Gaudiya Vaishnava parampara.</p>
<p style="line-height:1.9">Fascinated by the depth of Vedantic philosophy and the sublime path of Bhakti, he followed to London in 1934 and embraced initiation into the path of Krishna Consciousness. He completely surrendered his Western identity for the eternal identity of the soul.</p>
${SadanandaQuote}
</div>
<div class="split-img fade-right">
<img src="images/about/spiritual-bg_2.jpg" alt="Spiritual awakening" style="object-fit:contain">
<div style="position:absolute;inset:0;background:linear-gradient(to bottom,rgba(230,168,23,.1),rgba(11,29,58,.2));border-radius:var(--radius-lg)"></div>
</div>
</div>
<div class="fade-up" style="max-width:900px;margin:0 auto 4rem">
<h3 style="margin-bottom:1rem">Journey to India & Lifelong Service (1935–Onward)</h3>
<p style="line-height:1.9">In 1935, Sadananda Das arrived in India, the sacred land of his spiritual master, Shrila Bhaktisiddhanta Sarasvati. Under direct tutelage and divine association, he received his spiritual name and dedicated himself to studying ancient Sanskrit texts.</p>
<p style="line-height:1.9">Following the physical departure of his Guru Maharaja in 1937, Sadananda Das did not waver. Instead, he intensified his personal sadhana, delving into intense study of the Srimad Bhagavatam, the Upanishads, and the Six Gosvamis' literatures.</p>
<p style="line-height:1.9">Through his exemplary life, Sadananda Das proved that Krishna Consciousness transcends all geographical and cultural boundaries. A soul born in Germany became a luminous example of pure Gaudiya Vaishnavism, demonstrating the universal applicability of Sanatana Dharma to the entire world.</p>
</div>`;

        content = content.replace(
            /<div class="fade-right">\s*<h3>Early Life & Formative Years.*?<\/div>\s*<\/div>\s*<\/section>/s,
            aboutBio + '\n</div>\n</section>'
        );
    }
    
    // Write back
    fs.writeFileSync(filePath, content, 'utf8');
}
console.log('Replacements done!');
