/* ---------- Routing & DDoS: one modal for the network-wide settings ----------
The backbone, Auto-TE and DDoS automation used to sit at the bottom of the NOC tab, below every incident and
the log, where nobody found them. A button at the top of the NOC tab opens them here, with the traceroute. */
// Auto-TE: paused, installed or for sale.
function tePanel(){
return S.te&&!coreTE()?`
${btn(tr('hud_and_panels.install_auto_te_cost_mo_mo',{cost:fmt$(TE_COST),mo:fmt$(TE_MO)}),'buyTE',{},'pink sm',lvl()<3||S.cash`;}
// What the modal holds, without its title (scripts/lib/fuzz-page.js reads its buttons too).
// Traceroute opens its own modal from here: it explains the routing these settings shape.
function routingBody(){return `
๐ ${tr('common.traceroute')}
${tr('routing.trace_note')}
${btn(tr('routing.trace_run'),'trace',{},'sm')}
`+corePanel()+`
${tr('common.traffic_engineering')}
${tePanel()}`
+`
${tr('routing.ddos_defence')}
${ddosSettings()}`;}
function routingModal(){if(!S)return;const card=$('modalCard'),open=!$('modal').hidden&&card.querySelector('[data-routing]'),st=open?card.scrollTop:0;
let h=`
`;
openModal(h+routingBody());if(open)card.scrollTop=st;}
// Actions taken in the modal re-render the game through after(); this keeps the open modal in step.
function routingRefresh(){if(S&&!$('modal').hidden&&$('modalCard').querySelector('[data-routing]'))routingModal();}