';
d.querySelector('span').textContent=r.n;d.querySelector('b').textContent=fmt(r.v);var f=d.querySelector('.fl');f.style.background=r.c;el.appendChild(d);
setTimeout(function(){f.style.width=Math.max(2,Math.max(0,r.v)/mx*100)+'%'},reduce?0:200+i*150)})}
function bars(){var R=S.r,col=cv(BANDS[R.idx].c);
hbars($('rates'),[{n:'Your fund',v:R.r*100,c:col,you:1},{n:'Nifty 50 TRI',v:BENCH.nifty,c:'#1E1B4B'},{n:'Bank FD',v:BENCH.fd,c:'#A78BFA'},{n:'Inflation',v:BENCH.inflation,c:'#C9C2EE'}],pctv);
hbars($('vals'),[{n:'Your fund',v:R.c,c:col,you:1},{n:'Nifty 50 TRI '+BENCH.nifty+'%',v:R.nifty,c:'#1E1B4B'},{n:'Bank FD '+BENCH.fd+'%',v:R.fd,c:'#A78BFA'},{n:'Just beat inflation',v:R.inf,c:'#C9C2EE'}],words)}
var rt;addEventListener('resize',function(){clearTimeout(rt);rt=setTimeout(function(){if(!$('s4').hidden)lineChart(false)},150)});
$('again').onclick=function(){S.rep=null;S.r=null;$('sip').value='';$('lump').value='';$('yrs').value='';$('val').value='';$('invHint').textContent='';show(2)};
/* download PDF of this report */
function loadLib(src,test){return new Promise(function(ok,no){if(test())return ok();var sc=document.createElement('script');sc.src=src;sc.onload=ok;sc.onerror=no;document.head.appendChild(sc)})}
$('dlBtn').onclick=function(){var b=$('dlBtn'),t=$('dlT');if(b.disabled)return;b.disabled=true;t.textContent='Preparing PDF…';
Promise.all([loadLib('https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js',function(){return window.html2canvas}),loadLib('https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js',function(){return window.jspdf})]).then(function(){
var el=$('s4');el.classList.add('cap');
return html2canvas(el,{scale:2,backgroundColor:'#F5F3FF',useCORS:true,windowWidth:Math.max(1100,el.scrollWidth)}).then(function(c){el.classList.remove('cap');
var pdf=new window.jspdf.jsPDF({unit:'pt',format:'a4'}),W=pdf.internal.pageSize.getWidth(),H=pdf.internal.pageSize.getHeight(),m=24,iw=W-2*m,ph=Math.floor((H-2*m)*c.width/iw),y=0,pg=0;
while(y
disclaimer',play:'Play disclaimer',stop:'Stop',start:'I understand, start',eb:'Before you start'},hi:{h:'कृपया यह अस्वीकरण सुनें',play:'अस्वीकरण सुनें',stop:'रोकें',start:'मैं समझ गया, शुरू करें',eb:'शुरू करने से पहले'}};
var dl='hi',synth=window.speechSynthesis,speaking=false,voices=[],runId=0;
function loadV(){try{voices=synth?synth.getVoices():[]}catch(e){voices=[]}}
if(synth){loadV();try{synth.onvoiceschanged=loadV}catch(e){}}
function voiceFor(l){var want=l==='hi'?'hi':'en',v=voices.filter(function(x){return x.lang&&x.lang.toLowerCase().indexOf(want)===0});
var inV=v.filter(function(x){return /IN/i.test(x.lang)});return inV[0]||v[0]||null}
function renderIntro(){var u=UI[dl];$('inH').innerHTML=u.h;$('startBtn').textContent=u.start;$('intro').querySelector('.eyebrow').lastChild.textContent=u.eb;
$('ilist').innerHTML='';DIS[dl].forEach(function(t){var li=document.createElement('li');li.textContent=t;$('ilist').appendChild(li)});
$('playT').textContent=speaking?u.stop:u.play;
document.querySelectorAll('.seg2l button').forEach(function(b){b.setAttribute('aria-pressed',String(b.getAttribute('data-l')===dl))});
var note='';if(!synth)note='Audio is not supported on this browser. Please read the points above.';else if(dl==='hi'&&voices.length&&!voiceFor('hi'))note='Hindi voice is not installed on this device, so a default voice will be used.';$('inote').textContent=note;
$('play').hidden=!synth;$('lisTop').hidden=!synth}
function stopTalk(){runId++;speaking=false;try{synth&&synth.cancel()}catch(e){}$('play').classList.remove('on');$('lisTop').classList.remove('on');
document.querySelectorAll('#ilist li,.dis li').forEach(function(li){li.classList.remove('say')});$('playT').textContent=UI[dl].play}
function talk(lang,items,onDone){
if(!synth)return;stopTalk();var my=++runId;speaking=true;var k=0;
(function next(){if(my!==runId)return;items.forEach(function(li,i){li.classList.toggle('say',i===k);if(i=items.length){speaking=false;$('play').classList.remove('on');$('lisTop').classList.remove('on');$('playT').textContent=UI[dl].play;items.forEach(function(li){li.classList.remove('say')});if(onDone)onDone();return}
var u=new SpeechSynthesisUtterance(DIS[lang][k]);u.lang=lang==='hi'?'hi-IN':'en-IN';var v=voiceFor(lang);if(v)u.voice=v;u.rate=.95;
u.onend=function(){k++;next()};u.onerror=function(){k++;next()};
try{synth.speak(u)}catch(e){k++;next()}})();
}
$('play').onclick=function(){if(speaking){stopTalk();return}document.querySelectorAll('#ilist li').forEach(function(li){li.classList.remove('done')});
talk(dl,[].slice.call(document.querySelectorAll('#ilist li')),function(){$('startBtn').focus()});$('play').classList.add('on');$('playT').textContent=UI[dl].stop};
document.querySelectorAll('.seg2l button').forEach(function(b){b.onclick=function(){var was=speaking;stopTalk();dl=b.getAttribute('data-l');renderIntro();if(was)$('play').click()}});
$('lisTop').onclick=function(){if(speaking){stopTalk();return}talk('en',[].slice.call(document.querySelectorAll('.dis li')));$('lisTop').classList.add('on')};
var prevOv='';
function closeIntro(){stopTalk();$('intro').hidden=true;document.documentElement.style.overflow=prevOv;try{sessionStorage.setItem('how-intro','1')}catch(e){}try{$('nm').focus({preventScroll:true})}catch(e){}}
$('startBtn').onclick=closeIntro;
var seen=false;try{seen=sessionStorage.getItem('how-intro')==='1'}catch(e){}
renderIntro();
if(seen)$('intro').hidden=true;else{prevOv=document.documentElement.style.overflow;document.documentElement.style.overflow='hidden'}
if(synth)setTimeout(function(){loadV();renderIntro()},600);
show(1);
})();