/* The build standard sheet: every target as a list (two to a row on a phone), grouped POP / ports and peering / fiber; what is below the standard and what bringing it up costs, priced without changing anything; one tap to do it now; and the intern's order that keeps it there. A bottom sheet on phones, like the Ops sheet it sits next to. */ const BSTD_GRP=[['pop',N_('common.pops')],['port',N_('bstd.g_port')],['fiber',N_('bstd.g_fiber')]]; // Every value a target can take, in the order its list shows them; the current one is always on the list. function bstdOpts(k){const L=BSTDK[k].v(),cur=bstd()[k];if(!L.includes(cur))L.push(cur);return L;} function bstdVal(k,v){if(v===BSTDK[k].d&&k!=='rt')return tr('bstd.keep'); switch(k){case 'g':return RG[v].n+(rgOpen(v)?'':' '+tr('bstd.from_level',{lv:RG[v].lvl})); case 'rt':return v>1?tr('bstd.at_least_n',{n:v}):tr('bstd.keep'); case 'site2':case 'gen':return tr('bstd.at_every_pop'); case 'lag':return tr('bstd.at_least_n',{n:v}); case 'split':return tr('bstd.both_buildings'); case 'ix':return tr('bstd.every_exchange'); case 'pni':return tr('bstd.in_n_cities',{n:v}); case 'sys':return tr('bstd.or_better',{x:DF_SYS[v].n}); case 'opt':return tr('bstd.fastest'); case 'wv':return tr('bstd.or_better',{x:LT[v].n});} return String(v);} const bstdShown=()=>!!$('modal')&&!$('modal').hidden&&!!$('modalCard').querySelector('[data-sheet="bstd"]'); // msg: why the sheet is shown again (the quote changed). function bstdModal(msg){if(!S||pzOn())return;const D=bstd(),q=bstdQuote(false),hired=opsHired(),on=hired&&S.ops.on.std; let h=`
${tr('ops.ops')}

${tr('bstd.title')}

${tr('bstd.tagline')}

${typeof msg==='string'&&msg?`

${esc(msg)}

`:''}`; for(const [g,lab] of BSTD_GRP)h+=`

${tr(lab)}

${BSTD.filter(x=>x.grp===g).map(x=>opsSel(tr(x.l),'bstdSet',{k:x.k},bstdOpts(x.k),D[x.k],v=>bstdVal(x.k,v))).join('')}

${g==='pop'?tr('bstd.new_pops_note'):g==='port'?tr('bstd.port_note'):tr('bstd.fiber_note_two')}

`; // What is below it today, and what bringing it all up costs: a quote, nothing changes until the button. A fiber whose // line system has to wait is below it too, but not on the bill. const n={pop:q.pops,port:q.ports,fiber:q.links},w=q.held.length; h+=`

${tr('bstd.below')}

${q.n||w?BSTD_GRP.map(([g,lab])=>`
${tr(lab)}${n[g]}
`).join('') +`
${tr('bstd.cost_now')}${fmt$(q.cost)}
${tr('bstd.cost_mo')}${tr('common.price_mo',{price:opsMo$(q.mo)})}
` +(q.wait.length?`

${trn('bstd.held',q.wait.length)}

`:'')+(q.wv.length?`

${trn('bstd.held_wave',q.wv.length)}

`:'') :`

${S.popStd?tr('bstd.all_up'):tr('bstd.none_set')}

`}
`; // The intern keeps it there: the order's switch and budget, or a word on hiring one. h+=`

${tr('ops.o_std')}

${hired?`
${esc(tr('bstd.intern_keeps',{name:opsName()}))}
${tr('ops.o_std_around_d')}
${on?`
${opsSel(tr('ops.budget'),'opsCap',{k:'std'},opsCaps('std'),opsCap('std'),v=>opsCapName('std',v))}
`:''}
` :`

${tr('bstd.hire_note')}

${btn(tr('ops.hire_an_intern'),'opsOpen',{},'ghost sm',!opsCanHire()||!rule('clock'))}
`}
`; // The button carries the plan it shows and its total (bstdApply checks both again). h+=`
${btn(q.n?tr('bstd.apply_now',{cost:fmt$(q.cost)}):w?tr('bstd.apply_wait'):tr('bstd.apply_nothing'),'bstdApply',{quote:bstdPlanKey(bstdPlan(false)),q:q.cost},'pink',!q.n)}
`; openModal(h,'ops');}