Translations keyed by labels instead of English text

tr('pnis.delivery_2_to_6_weeks') instead of tr('Delivery: 2 to 6 weeks'): the
English lives once, in src/i18n/en.js (inlined into the page at build, so no
extra request), and it/pt/fr map the same labels. Changing English wording no
longer renames a key in every dictionary.

- 2,899 labels, made from where each text is used and its first words; short
  shared words are common.*
- plurals are one label with {one, other}: trn('label', n)
- static markup: data-i18n="label", data-i18n-aria-label, data-i18n-title
- saves from 1.33 and older stored English text in a few places; tr() still
  resolves it
- i18n-check: undefined/unused labels, markup drift, plural shape; i18n-add.js
  works on labels and --rename updates src/ too
- the old-branch port tool gives old English-keyed code and dictionaries the
  same labels
This commit is contained in:
Frederic Jung 2026-10-27 11:05:09 +01:00
parent d0ba85ef8f
commit e817beed1a
No known key found for this signature in database
94 changed files with 13681 additions and 10633 deletions

View file

@ -1,112 +1,112 @@
function cityPanel(c){
const C=CITY[c],p=S.pops[c],ix=ixName(c),down=p&&p.down>S.day;
let h=`<div class="ph"><div style="min-width:0"><div class="eyebrow">${REG[C.reg]} · ${esc(siteName(c,'a'))}</div><h2>${C.name}</h2>
<div class="facts"><span class="fact">${tr('{g} of eyeballs',{g:fmtG(eyeP(c))})}</span>${latSlow(c)?`<span class="fact bad">🐢 ${tr('{ms} ms to transit',{ms:Math.round(R.latFar[c].ms)})}</span>`:''}${regionMult(c)>1?`<span class="fact">${tr('Transit {x}× pricier',{x:regionMult(c)})}</span>`:''}${C.reg==='AS'&&!C.cn?'<span class="fact ixf">'+tr('Underserved: users grow 60% faster')+'</span>':''}${ix?`<span class="fact ixf">${tr('IX: <b>{ix}</b>',{ix:esc(ix)})}</span>`:''}${p?`<span class="fact mine">${tr('Your POP')}</span><button class="fact trb" data-act="trace" data-args='{"city":"${c}"}'>🔍 ${tr('Traceroute')}</button>`:''}${down?`<span class="fact down">DOWN</span>`:''}</div></div>
<button class="x" data-act="closePanel" aria-label="${tr('Close')}">×</button></div>`;
<div class="facts"><span class="fact">${tr('city_panel.g_of_eyeballs',{g:fmtG(eyeP(c))})}</span>${latSlow(c)?`<span class="fact bad">🐢 ${tr('city_panel.ms_ms_to_transit',{ms:Math.round(R.latFar[c].ms)})}</span>`:''}${regionMult(c)>1?`<span class="fact">${tr('city_panel.transit_x_pricier',{x:regionMult(c)})}</span>`:''}${C.reg==='AS'&&!C.cn?'<span class="fact ixf">'+tr('city_panel.underserved_users_grow_60_faster')+'</span>':''}${ix?`<span class="fact ixf">${tr('city_panel.ix_ix',{ix:esc(ix)})}</span>`:''}${p?`<span class="fact mine">${tr('common.your_pop')}</span><button class="fact trb" data-act="trace" data-args='{"city":"${c}"}'>🔍 ${tr('common.traceroute')}</button>`:''}${down?`<span class="fact down">DOWN</span>`:''}</div></div>
<button class="x" data-act="closePanel" aria-label="${tr('common.close')}">×</button></div>`;
if(!p){
h+=`<div class="scroll">${C.note?`<p class="note" style="margin-top:0">${esc(C.note)}</p>`:''}
${C.cn?chinaSection(c):''}${C.cn&&!cnOk()?'':`<section><h3>${tr('Open a POP here')}</h3><p class="lead">${tr('A POP (point of presence) is your router in a rack here. Then connect it: lay fiber from one of your POPs, or buy transit right here.')}</p>
${C.ru?`<p class="why">${tr('Includes the mandatory government box in your rack: {cost} + {mo}/mo. It comes with its own listener.',{cost:fmt$(RU_BOX),mo:fmt$(RU_BOX_MO)})}</p>`:''}${btn(tr('Build POP <small>{cost} + {mo}/mo</small>',{cost:fmt$(popCost(c)),mo:fmt$(POP_MO)}),'buildPop',{city:c},'pink big',S.cash<popCost(c))}
<p class="note">${tr('Or drag from one of your routers to this city to lay fiber and build the POP in one go.')}</p></section>`}`;
${C.cn?chinaSection(c):''}${C.cn&&!cnOk()?'':`<section><h3>${tr('city_panel.open_a_pop_here')}</h3><p class="lead">${tr('city_panel.a_pop_point_of_presence_is')}</p>
${C.ru?`<p class="why">${tr('city_panel.includes_the_mandatory_government',{cost:fmt$(RU_BOX),mo:fmt$(RU_BOX_MO)})}</p>`:''}${btn(tr('city_panel.build_pop_cost_mo_mo',{cost:fmt$(popCost(c)),mo:fmt$(POP_MO)}),'buildPop',{city:c},'pink big',S.cash<popCost(c))}
<p class="note">${tr('city_panel.or_drag_from_one_of_your')}</p></section>`}`;
h+=offersHere(c);
const trs=NETS.filter(n=>sellsAt(n,c));
const fh=FABS.filter(f=>f.cities.includes(c));
if(ix&&fh.length){if(remoteCities().includes(c))h+=ixSection(c).replace('<h3>'+tr('Internet Exchange')+'</h3>','<h3>'+tr('Remote peering at the IX')+'</h3>');
else h+=`<section><h3>${tr('Remote peering')}</h3><p class="lead">${tr('Peer at {ix} without building a POP. Order a virtual circuit here from one of your POPs over {fabs}.',{ix:esc(ix),fabs:fh.map(f=>esc(f.name)).join(tr(' or '))})}</p>${REMOTE_WARN}${btn(tr('Order circuit anyway'),'openVxc',{to:c},'ghost sm')}</section>`;}
h+=`<section><h3>${tr("Who's here")}</h3><div class="meta" style="font-size:12.5px;line-height:1.6">${MEGA.filter(m=>m.c===c).length?`${tr('AI and cloud campuses nearby: {list}',{list:MEGA.filter(m=>m.c===c).map(m=>`<b>${esc(m.n)}</b>`).join(', ')})}<br>`:''}${tr('Transit sellers: {list}',{list:trs.map(n=>`<b>${esc(n.name)}</b>`).join(', ')||tr('none')})}<br>${tr('Fabrics: {list}',{list:fh.map(f=>`<b>${esc(f.name)}</b>`).join(', ')||tr('none')})}<br>${ix?ixIdsIn(c).map(x=>tr('IX members on {ix}: {n}',{ix:esc(ixName(x)),n:ixMembers(x).length})).join('<br>'):tr('No IX here yet. You could found one later.')}</div></section></div>`;
if(ix&&fh.length){if(remoteCities().includes(c))h+=ixSection(c).replace('<h3>'+tr('common.internet_exchange')+'</h3>','<h3>'+tr('city_panel.remote_peering_at_the_ix')+'</h3>');
else h+=`<section><h3>${tr('common.remote_peering')}</h3><p class="lead">${tr('city_panel.peer_at_ix_without_building_a',{ix:esc(ix),fabs:fh.map(f=>esc(f.name)).join(tr('common.or'))})}</p>${REMOTE_WARN}${btn(tr('city_panel.order_circuit_anyway'),'openVxc',{to:c},'ghost sm')}</section>`;}
h+=`<section><h3>${tr('city_panel.who_s_here')}</h3><div class="meta" style="font-size:12.5px;line-height:1.6">${MEGA.filter(m=>m.c===c).length?`${tr('city_panel.ai_and_cloud_campuses_nearby_list',{list:MEGA.filter(m=>m.c===c).map(m=>`<b>${esc(m.n)}</b>`).join(', ')})}<br>`:''}${tr('city_panel.transit_sellers_list',{list:trs.map(n=>`<b>${esc(n.name)}</b>`).join(', ')||tr('common.none')})}<br>${tr('city_panel.fabrics_list',{list:fh.map(f=>`<b>${esc(f.name)}</b>`).join(', ')||tr('common.none')})}<br>${ix?ixIdsIn(c).map(x=>tr('city_panel.ix_members_on_ix_n',{ix:esc(ixName(x)),n:ixMembers(x).length})).join('<br>'):tr('city_panel.no_ix_here_yet_you_could')}</div></section></div>`;
return h;
}
const tabs=[['cust',tr('Customers')],['up',tr('Transit')],['peer',tr('Peering')],['links',tr('Infra')]];
const tabs=[['cust',tr('common.customers')],['up',tr('common.transit')],['peer',tr('common.peering')],['links',tr('common.infra')]];
h+=`<nav class="tabs">${tabs.map(([k,l])=>`<button class="${UI.tab===k?'on':''}" data-act="tab" data-args='{"t":"${k}"}'>${l}</button>`).join('')}</nav><div class="scroll">`;
if(C.cn&&UI.tab==='cust')h+=chinaSection(c);
const sf=sfOf(R,c),dem=R.cityDem[c]||0;
if(down){const i=S.inc.filter(x=>x.ref===c&&POPDOWN.includes(x.type)).sort((a,b)=>b.until-a.until)[0];h+=`<section><h3 style="color:var(--bad)">${tr('This POP is down')}</h3><p class="lead">${i?esc(i.msg):''} ${tr("Customers here get nothing until it's back.")}</p>${i&&i.cost?btn(`${i.fix} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red'):''}</section>`;}
if(down){const i=S.inc.filter(x=>x.ref===c&&POPDOWN.includes(x.type)).sort((a,b)=>b.until-a.until)[0];h+=`<section><h3 style="color:var(--bad)">${tr('city_panel.this_pop_is_down')}</h3><p class="lead">${i?esc(i.msg):''} ${tr('city_panel.customers_here_get_nothing_until_it')}</p>${i&&i.cost?btn(`${i.fix} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red'):''}</section>`;}
if(UI.tab==='cust'){
{const nl=R.nodeLoad[c]||0,nc=R.nodeCap[c]||1;if(nl>=nc*0.95)h+=`<section><h3 style="color:var(--bad)">${tr('Router maxed out')}</h3><p class="lead">${tr('Your routers here are forwarding {load} of {cap}. Traffic is being dropped. Upgrade or add a router in the Infra tab.',{load:fmtG(nl),cap:fmtG(nc)})}</p>${btn(tr('Open Infra'),'tab',{t:'links'},'pink sm')}</section>`;}
h+=`<section><h3>${tr('Home broadband')}</h3>`;
if(!p.bb){const s=bbStart(c);h+=`<p class="lead">${tr('Sell internet to homes here. Starts around {start} and grows toward {max} while service is good. Pays {rate} per Gbps served, every month.',{start:fmtG(s),max:fmtG(eyeP(c)),rate:fmt$(EYE_RATE*(C.arpu||1))})}${C.au?` ${scnRule('levy')?tr('It runs on your own fibre, so the Nearly Broadband Network gets nothing. The government still takes a {pct} levy.',{pct:pct(AU_LEVY)}):tr('The Nearly Broadband Network keeps {pct} of it for the last mile.',{pct:pct(AU_WHOLESALE)})}`:''}</p>${btn(tr('Launch broadband <small>{cost}</small>',{cost:fmt$(bbCost(c))}),'launchBB',{city:c},'pink big',S.cash<bbCost(c))}`;}
{const nl=R.nodeLoad[c]||0,nc=R.nodeCap[c]||1;if(nl>=nc*0.95)h+=`<section><h3 style="color:var(--bad)">${tr('city_panel.router_maxed_out')}</h3><p class="lead">${tr('city_panel.your_routers_here_are_forwarding',{load:fmtG(nl),cap:fmtG(nc)})}</p>${btn(tr('common.open_infra'),'tab',{t:'links'},'pink sm')}</section>`;}
h+=`<section><h3>${tr('common.home_broadband')}</h3>`;
if(!p.bb){const s=bbStart(c);h+=`<p class="lead">${tr('city_panel.sell_internet_to_homes_here_starts',{start:fmtG(s),max:fmtG(eyeP(c)),rate:fmt$(EYE_RATE*(C.arpu||1))})}${C.au?` ${scnRule('levy')?tr('city_panel.it_runs_on_your_own_fibre',{pct:pct(AU_LEVY)}):tr('city_panel.the_nearly_broadband_network_keeps',{pct:pct(AU_WHOLESALE)})}`:''}</p>${btn(tr('city_panel.launch_broadband_cost',{cost:fmt$(bbCost(c))}),'launchBB',{city:c},'pink big',S.cash<bbCost(c))}`;}
else{const eye=R.cityEye[c]||0;
h+=`<div class="kv"><span>${tr('Eyeball demand')}</span><b>${tr('{a} of {b}',{a:fmtG(eye),b:fmtG(eyeP(c))})}</b></div><div class="bar me"><i style="width:${Math.min(100,eye/eyeP(c)*100)}%"></i></div>
<div class="kv"><span>${tr('Served in {city}',{city:C.name})}</span><b style="color:${sf<0.9?'var(--bad)':'var(--eye)'}">${pct(sf)}</b></div><div class="bar ${sf<0.9?'bad':''}"><i style="width:${sf*100}%"></i></div>
<div class="kv"><span>${tr('Revenue')}</span><b>${tr('{price}/mo',{price:fmt$(eye*sf*EYE_RATE*(C.arpu||1))})}</b></div>
<div class="kv"><span>${tr('Network-wide peering ratio')}</span><b>${pct(R.peerShare||0)}</b></div><p class="note">${tr('More traffic over peering, PNIs and caches means lower latency, and happier users grow faster.')}</p>
${sf<0.9?`<p class="why">${tr('Customers are unhappy and leaving. Add upstream capacity, peering, or a bigger link.')}</p>`:''}
<div class="btns">${p.boost>S.day?`<span class="tag st on">${tr('Ad campaign: {n}d left',{n:p.boost-S.day})}</span>`:btn(tr('Run ad campaign <small>$8k · 2× growth 30d</small>'),'ad',{city:c},'',S.cash<8000)}</div>`;}
h+=`</section><section><h3>${tr('Business customers')}</h3>`;
h+=`<div class="kv"><span>${tr('common.eyeball_demand')}</span><b>${tr('city_panel.a_of_b',{a:fmtG(eye),b:fmtG(eyeP(c))})}</b></div><div class="bar me"><i style="width:${Math.min(100,eye/eyeP(c)*100)}%"></i></div>
<div class="kv"><span>${tr('city_panel.served_in_city',{city:C.name})}</span><b style="color:${sf<0.9?'var(--bad)':'var(--eye)'}">${pct(sf)}</b></div><div class="bar ${sf<0.9?'bad':''}"><i style="width:${sf*100}%"></i></div>
<div class="kv"><span>${tr('common.revenue')}</span><b>${tr('common.price_mo',{price:fmt$(eye*sf*EYE_RATE*(C.arpu||1))})}</b></div>
<div class="kv"><span>${tr('city_panel.network_wide_peering_ratio')}</span><b>${pct(R.peerShare||0)}</b></div><p class="note">${tr('city_panel.more_traffic_over_peering_pnis_and')}</p>
${sf<0.9?`<p class="why">${tr('city_panel.customers_are_unhappy_and_leaving')}</p>`:''}
<div class="btns">${p.boost>S.day?`<span class="tag st on">${tr('city_panel.ad_campaign_n_d_left',{n:p.boost-S.day})}</span>`:btn(tr('city_panel.run_ad_campaign_8k_2_growth'),'ad',{city:c},'',S.cash<8000)}</div>`;}
h+=`</section><section><h3>${tr('common.business_customers')}</h3>`;
const bz=S.biz.filter(b=>bCities(b).includes(c));
if(!bz.length)h+=`<p class="empty">${tr('No businesses yet. Offers pop up as $ bubbles on the map.')}</p>`;
for(const b of bz)h+=`<div class="row"><div class="grow"><div class="nm">${esc(b.name)}</div><div class="meta">${esc(BIZ_T[b.type].l)}${b.city2?` ${CITY[b.city].name} ⇄ ${CITY[b.city2].name}`:''} · ${bTerms(b)}${BIZ_T[b.type].l2?` · ${b.sites?tr('carrying {g} per site',{g:fmtG(R.l2[b.id]||0)}):tr('carrying {g}',{g:fmtG(R.l2[b.id]||0)})}`:''}${BIZ_T[b.type].fiber&&!fiberOk(b)?' · <b style="color:var(--bad)">'+tr('fiber is down')+'</b>':''}${BIZ_T[b.type].event&&eventLive(b)?` · <b>${tr('serving {v}',{v:pct(sfOf(R,b.city))})}</b>`:''}${b.type==='scrub'&&!hasScrub()?' · <b style="color:var(--bad)">'+tr('needs a scrubbing center')+'</b>':''}${S.day-(b.since||0)<15?` · <b>${tr('provisioning, {n}d grace',{n:15-(S.day-(b.since||0))})}</b>`:''}</div>${reqList(b)}${BIZ_T[b.type].l2?routeCtl(b):''}<div class="bar ${b.mood<30?'bad':b.mood<65?'warn':''}"><i style="width:${b.mood}%"></i></div><div class="meta">${tr('Happiness {p}%',{p:Math.round(b.mood)})}</div></div>${btn(UI.confirm===b.id?tr('Really drop?'):tr('Drop'),'dropBiz',{id:b.id},'ghost sm')}</div>`;
if(!bz.length)h+=`<p class="empty">${tr('city_panel.no_businesses_yet_offers_pop_up')}</p>`;
for(const b of bz)h+=`<div class="row"><div class="grow"><div class="nm">${esc(b.name)}</div><div class="meta">${esc(BIZ_T[b.type].l)}${b.city2?` ${CITY[b.city].name} ⇄ ${CITY[b.city2].name}`:''} · ${bTerms(b)}${BIZ_T[b.type].l2?` · ${b.sites?tr('city_panel.carrying_g_per_site',{g:fmtG(R.l2[b.id]||0)}):tr('city_panel.carrying_g',{g:fmtG(R.l2[b.id]||0)})}`:''}${BIZ_T[b.type].fiber&&!fiberOk(b)?' · <b style="color:var(--bad)">'+tr('city_panel.fiber_is_down')+'</b>':''}${BIZ_T[b.type].event&&eventLive(b)?` · <b>${tr('city_panel.serving_v',{v:pct(sfOf(R,b.city))})}</b>`:''}${b.type==='scrub'&&!hasScrub()?' · <b style="color:var(--bad)">'+tr('common.needs_a_scrubbing_center')+'</b>':''}${S.day-(b.since||0)<15?` · <b>${tr('common.provisioning_n_d_grace',{n:15-(S.day-(b.since||0))})}</b>`:''}</div>${reqList(b)}${BIZ_T[b.type].l2?routeCtl(b):''}<div class="bar ${b.mood<30?'bad':b.mood<65?'warn':''}"><i style="width:${b.mood}%"></i></div><div class="meta">${tr('common.happiness_p',{p:Math.round(b.mood)})}</div></div>${btn(UI.confirm===b.id?tr('common.really_drop'):tr('common.drop'),'dropBiz',{id:b.id},'ghost sm')}</div>`;
h+=`</section>`+offersHere(c);
}else if(UI.tab==='up'){
h+=portNote(c)+latNote(c);
h+=`<section><h3>${tr('IP transit')}</h3><p class="lead">${tr('Pay a bigger network per Gbps and it carries your traffic to the whole internet. Billed on the 95th percentile of the last 30 days, with a 20% commit and a port fee. Spikes like DDoS raise your bill.')}</p>`;
h+=`<section><h3>${tr('common.ip_transit')}</h3><p class="lead">${tr('city_panel.pay_a_bigger_network_per_gbps')}</p>`;
const prov=NETS.filter(n=>sellsAt(n,c)).sort((a,b)=>a.price-b.price);
if(!prov.length)h+=`<p class="empty">${tr('Nobody sells transit here. Haul your traffic over fiber to a city that has it.')}</p>`;
if(!prov.length)h+=`<p class="empty">${tr('city_panel.nobody_sells_transit_here_haul_your')}</p>`;
for(const n of prov){const t=S.transit.find(x=>x.city===c&&x.net===n.id);const pr=n.price*S.priceMul*(t&&t.premium&&c==='hkg'?n.premium:1)*regionMult(c);
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="tag ${n.type}">${TYPE_L[n.type]}</span></div><div class="meta">${tr('${price} per Gbps / month · billed on 95th percentile',{price:pr.toFixed(2)})}</div>`;
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="tag ${n.type}">${TYPE_L[n.type]}</span></div><div class="meta">${tr('city_panel.price_per_gbps_month_billed_on',{price:pr.toFixed(2)})}</div>`;
if(t){const u=R.useT[t.id]||0,cap=lagCap(PORT[t.tier].g,t.n),tdown=t.down>S.day;
h+=`<div class="kv"><span>${lagName(t.tier,t.n)}${tdown?' · <b style="color:var(--bad)">'+tr('OUTAGE')+'</b>':''}</span><b>${fmtG(u)}</b></div><div class="bar ${barCls(u/cap)}"><i style="width:${u/cap*100}%"></i></div>${prefCtl('t',t.id,t.pref)}${siteCtl('t',t.id,c,t.site)}${n.premium&&c==='hkg'?`<div class="btns">${btn(t.premium?tr('CN-Too premium on ✓'):tr('Switch to CN-Too premium <small>{x}× price · ~3% loss into China</small>',{x:n.premium}),'togglePrem',{id:t.id},t.premium?'green sm':'sm')}</div>`:''}${(()=>{const top=transitTop([t.id],4);return top.length?`<div class="ttop"><div class="meta"><b>${tr('Top destinations on this port')}</b></div>${top.map(([id,v])=>`<div class="meta">${esc(NET[id].name)} · ${fmtG(v)} · <i>${esc(offTransitHint(id,c))}</i></div>`).join('')}</div>`:'';})()}<div class="meta">${tr('95th pct {p95} · commit {commit} · bill {bill}/mo',{p95:fmtG(R.p95[t.id]||0),commit:fmtG(cap*.2),bill:fmt$(Math.max(R.p95[t.id]||0,PORT[t.tier].g*(t.n||1)*.2)*pr+PORT[t.tier].tmo*(t.n||1))})}</div>
<div class="btns">${PORT.map((P2,i)=>i>t.tier&&portShown(i)?btn((t.n||1)>1?tr('Upgrade all to {port} <small>{cost} + {mo}/mo</small>',{port:P2.n,cost:fmt$(P2.setup*(t.n||1)),mo:fmt$(P2.tmo*(t.n||1))}):tr('Upgrade {port} <small>{cost} + {mo}/mo</small>',{port:P2.n,cost:fmt$(P2.setup*(t.n||1)),mo:fmt$(P2.tmo*(t.n||1))}),'buyTransit',{city:c,net:n.id,tier:i},'sm',S.cash<P2.setup*(t.n||1)||!portOk(c,i)):'').join('')}${(t.n||1)<LAG_MAX?btn(tr('+ LAG member <small>{cost} + {mo}/mo</small>',{cost:fmt$(PORT[t.tier].setup),mo:fmt$(PORT[t.tier].tmo)}),'lagT',{id:t.id,d:1},'sm',S.cash<PORT[t.tier].setup||!portOk(c,t.tier)):''}${(t.n||1)>1?btn(tr('− member'),'lagT',{id:t.id,d:-1},'ghost sm'):''}${btn(t.clean?tr('Clean-pipe on ✓'):tr('+ Clean-pipe <small>{mo}/mo · scrubs DDoS upstream</small>',{mo:fmt$(cleanMo(t))}),'cleanPipe',{id:t.id},t.clean?'green sm':'sm')}${btn(UI.confirm===t.id?tr('Really cancel?'):tr('Cancel'),'cancelTransit',{id:t.id},'ghost sm')}</div>`;}
else h+=`<div class="btns">${PORT.map((P2,i)=>portShown(i)?btn(tr('{port} <small>{cost} + {mo}/mo</small>',{port:P2.n,cost:fmt$(P2.setup),mo:fmt$(P2.tmo)}),'buyTransit',{city:c,net:n.id,tier:i},'sm',S.cash<P2.setup||!portOk(c,i)):'').join('')}</div>`;
h+=`<div class="kv"><span>${lagName(t.tier,t.n)}${tdown?' · <b style="color:var(--bad)">'+tr('common.outage')+'</b>':''}</span><b>${fmtG(u)}</b></div><div class="bar ${barCls(u/cap)}"><i style="width:${u/cap*100}%"></i></div>${prefCtl('t',t.id,t.pref)}${siteCtl('t',t.id,c,t.site)}${n.premium&&c==='hkg'?`<div class="btns">${btn(t.premium?tr('city_panel.cn_too_premium_on'):tr('city_panel.switch_to_cn_too_premium_x',{x:n.premium}),'togglePrem',{id:t.id},t.premium?'green sm':'sm')}</div>`:''}${(()=>{const top=transitTop([t.id],4);return top.length?`<div class="ttop"><div class="meta"><b>${tr('city_panel.top_destinations_on_this_port')}</b></div>${top.map(([id,v])=>`<div class="meta">${esc(NET[id].name)} · ${fmtG(v)} · <i>${esc(offTransitHint(id,c))}</i></div>`).join('')}</div>`:'';})()}<div class="meta">${tr('city_panel.95th_pct_p95_commit_commit_bill',{p95:fmtG(R.p95[t.id]||0),commit:fmtG(cap*.2),bill:fmt$(Math.max(R.p95[t.id]||0,PORT[t.tier].g*(t.n||1)*.2)*pr+PORT[t.tier].tmo*(t.n||1))})}</div>
<div class="btns">${PORT.map((P2,i)=>i>t.tier&&portShown(i)?btn((t.n||1)>1?tr('common.upgrade_all_to_port_cost_mo',{port:P2.n,cost:fmt$(P2.setup*(t.n||1)),mo:fmt$(P2.tmo*(t.n||1))}):tr('common.upgrade_port_cost_mo_mo',{port:P2.n,cost:fmt$(P2.setup*(t.n||1)),mo:fmt$(P2.tmo*(t.n||1))}),'buyTransit',{city:c,net:n.id,tier:i},'sm',S.cash<P2.setup*(t.n||1)||!portOk(c,i)):'').join('')}${(t.n||1)<LAG_MAX?btn(tr('common.lag_member_cost_mo_mo',{cost:fmt$(PORT[t.tier].setup),mo:fmt$(PORT[t.tier].tmo)}),'lagT',{id:t.id,d:1},'sm',S.cash<PORT[t.tier].setup||!portOk(c,t.tier)):''}${(t.n||1)>1?btn(tr('common.member'),'lagT',{id:t.id,d:-1},'ghost sm'):''}${btn(t.clean?tr('city_panel.clean_pipe_on'):tr('city_panel.clean_pipe_mo_mo_scrubs_ddos',{mo:fmt$(cleanMo(t))}),'cleanPipe',{id:t.id},t.clean?'green sm':'sm')}${btn(UI.confirm===t.id?tr('common.really_cancel'):tr('common.cancel'),'cancelTransit',{id:t.id},'ghost sm')}</div>`;}
else h+=`<div class="btns">${PORT.map((P2,i)=>portShown(i)?btn(tr('city_panel.port_cost_mo_mo',{port:P2.n,cost:fmt$(P2.setup),mo:fmt$(P2.tmo)}),'buyTransit',{city:c,net:n.id,tier:i},'sm',S.cash<P2.setup||!portOk(c,i)):'').join('')}</div>`;
h+=`</div></div>`;}
h+=`</section>`;
}else if(UI.tab==='peer'){
h+=portNote(c);
h+=ixSection(c);
h+=`<section><h3>${tr('Private interconnects (PNI)')}</h3><p class="lead">${tr('A dedicated cross-connect to one network in {dc}. Needs more traffic than IX peering, but has its own capacity.',{dc:esc(siteName(c,'a'))})}</p>`;
h+=`<section><h3>${tr('city_panel.private_interconnects_pni')}</h3><p class="lead">${tr('city_panel.a_dedicated_cross_connect_to_one',{dc:esc(siteName(c,'a'))})}</p>`;
const here=NETS.filter(n=>n.pops.includes(c));
for(const n of here){const pn=S.pni.find(x=>x.city===c&&x.net===n.id),chk=peerOk(n.id,'pni',c);
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="tag ${n.pol}">${n.pol}</span></div>`;
if(pn&&!pniOn(pn))h+=pniWait(pn,c);
else if(pn){const u=R.usePni[pn.id]||0,cap=lagCap(pniG(pn),pn.n);h+=`<div class="kv"><span>${(pn.n||1)>1?`${pn.n}×${pniPN(pn)} LAG`:pniPN(pn)} PNI</span><b>${fmtG(u)}</b></div>${pn.up?`<div class="meta">${tr('Augment on order: {port}, about {n} days to go.',{port:(pn.up.n>1?pn.up.n+'×':'')+(pn.up.g1?'1G':PORT[pn.up.tier].n),n:Math.max(0,pn.up.ready-S.day)})} ${btn(tr('Chase it'),'pniChase',{id:pn.id},'ghost sm')}</div>`:''}<div class="bar ${barCls(u/cap)}"><i style="width:${u/cap*100}%"></i></div>${prefCtl('p',pn.id,pn.pref)}${siteCtl('p',pn.id,c,pn.site)}<div class="btns">${PORT.map((P2,i)=>!pn.up&&!msfNope(n.id,c)&&(i>pn.tier||(pn.g1&&i===0))?btn((a=>(pn.n||1)>1?tr('Upgrade all to {port} <small>{cost} + {mo}/mo</small>',a):tr('Upgrade {port} <small>{cost} + {mo}/mo</small>',a))({port:P2.n,cost:fmt$((1500+P2.setup/2)*(pn.n||1)),mo:fmt$(P2.pni*(pn.n||1))}),'pni',{city:c,net:n.id,tier:i},'sm',!portOk(c,i)||S.cash<(1500+P2.setup/2)*(pn.n||1)):'').join('')}${(pn.n||1)<LAG_MAX&&!pn.up&&!msfNope(n.id,c)?btn(tr('+ LAG member <small>{cost} + {mo}/mo</small>',{cost:fmt$(1500+PORT[pn.tier].setup/2),mo:fmt$(PORT[pn.tier].pni)}),'lagP',{id:pn.id,d:1},'sm',S.cash<1500+PORT[pn.tier].setup/2):''}${(pn.n||1)>1?btn(tr('− member'),'lagP',{id:pn.id,d:-1},'ghost sm'):''}${NET[n.id].cn?btn(pn.sacrif?tr('Sacrificial choke ✓'):tr('Make sacrificial <small>contains floods · ½ capacity</small>'),'sacrif',{id:pn.id},pn.sacrif?'green sm':'sm'):''}${btn(UI.confirm===pn.id?tr('Really remove?'):tr('Remove'),'cancelPni',{id:pn.id},'ghost sm')}</div>`;}
else{h+=chk.ok?`<div class="btns">${pniG1(n.id)?btn(tr('{port} <small>{cost} + {mo}/mo</small>',{port:'1G',cost:fmt$(PNI_G1_COST),mo:fmt$(Math.round(PORT[0].pni/2))}),'pni',{city:c,net:n.id,tier:-1},'sm',S.cash<PNI_G1_COST||!portOk(c,0)):''}${PORT.map((P2,i)=>portShown(i)&&i>=pniMin(n.id)?btn(tr('{port} <small>{cost} + {mo}/mo</small>',{port:P2.n,cost:fmt$(1500+P2.setup/2),mo:fmt$(P2.pni)}),'pni',{city:c,net:n.id,tier:i},'sm',S.cash<1500+P2.setup/2||!portOk(c,i)):'').join('')}</div><div class="meta">${pniEta(n.id)}${pniMin(n.id)?' · '+tr('no 10G: {net} starts at 100G',{net:esc(n.name)}):pniG1(n.id)?' · '+tr('sells PNIs down to 1G'):''}</div>${chk.fee?`<div class="meta">${tr('Paid peering: {price}/mo on top',{price:fmt$(chk.fee)})}</div>`:''}`:`<div class="why">${esc(chk.why)}</div>`;}
else if(pn){const u=R.usePni[pn.id]||0,cap=lagCap(pniG(pn),pn.n);h+=`<div class="kv"><span>${(pn.n||1)>1?`${pn.n}×${pniPN(pn)} LAG`:pniPN(pn)} PNI</span><b>${fmtG(u)}</b></div>${pn.up?`<div class="meta">${tr('city_panel.augment_on_order_port_about_n',{port:(pn.up.n>1?pn.up.n+'×':'')+(pn.up.g1?'1G':PORT[pn.up.tier].n),n:Math.max(0,pn.up.ready-S.day)})} ${btn(tr('common.chase_it'),'pniChase',{id:pn.id},'ghost sm')}</div>`:''}<div class="bar ${barCls(u/cap)}"><i style="width:${u/cap*100}%"></i></div>${prefCtl('p',pn.id,pn.pref)}${siteCtl('p',pn.id,c,pn.site)}<div class="btns">${PORT.map((P2,i)=>!pn.up&&!msfNope(n.id,c)&&(i>pn.tier||(pn.g1&&i===0))?btn((a=>(pn.n||1)>1?tr('common.upgrade_all_to_port_cost_mo',a):tr('common.upgrade_port_cost_mo_mo',a))({port:P2.n,cost:fmt$((1500+P2.setup/2)*(pn.n||1)),mo:fmt$(P2.pni*(pn.n||1))}),'pni',{city:c,net:n.id,tier:i},'sm',!portOk(c,i)||S.cash<(1500+P2.setup/2)*(pn.n||1)):'').join('')}${(pn.n||1)<LAG_MAX&&!pn.up&&!msfNope(n.id,c)?btn(tr('common.lag_member_cost_mo_mo',{cost:fmt$(1500+PORT[pn.tier].setup/2),mo:fmt$(PORT[pn.tier].pni)}),'lagP',{id:pn.id,d:1},'sm',S.cash<1500+PORT[pn.tier].setup/2):''}${(pn.n||1)>1?btn(tr('common.member'),'lagP',{id:pn.id,d:-1},'ghost sm'):''}${NET[n.id].cn?btn(pn.sacrif?tr('common.sacrificial_choke'):tr('city_panel.make_sacrificial_contains_floods_1_2'),'sacrif',{id:pn.id},pn.sacrif?'green sm':'sm'):''}${btn(UI.confirm===pn.id?tr('common.really_remove'):tr('common.remove'),'cancelPni',{id:pn.id},'ghost sm')}</div>`;}
else{h+=chk.ok?`<div class="btns">${pniG1(n.id)?btn(tr('city_panel.port_cost_mo_mo',{port:'1G',cost:fmt$(PNI_G1_COST),mo:fmt$(Math.round(PORT[0].pni/2))}),'pni',{city:c,net:n.id,tier:-1},'sm',S.cash<PNI_G1_COST||!portOk(c,0)):''}${PORT.map((P2,i)=>portShown(i)&&i>=pniMin(n.id)?btn(tr('city_panel.port_cost_mo_mo',{port:P2.n,cost:fmt$(1500+P2.setup/2),mo:fmt$(P2.pni)}),'pni',{city:c,net:n.id,tier:i},'sm',S.cash<1500+P2.setup/2||!portOk(c,i)):'').join('')}</div><div class="meta">${pniEta(n.id)}${pniMin(n.id)?' · '+tr('city_panel.no_10g_net_starts_at_100g',{net:esc(n.name)}):pniG1(n.id)?' · '+tr('city_panel.sells_pnis_down_to_1g'):''}</div>${chk.fee?`<div class="meta">${tr('city_panel.paid_peering_price_mo_on_top',{price:fmt$(chk.fee)})}</div>`:''}`:`<div class="why">${esc(chk.why)}</div>`;}
h+=`</div></div>`;}
h+=`</section><section><h3>${tr('Embedded caches')}</h3><p class="lead">${tr('CDNs put free cache servers inside your POP. Most of their traffic is then served right here, with no transit and no IX port.')}</p>`;
h+=`</section><section><h3>${tr('common.embedded_caches')}</h3><p class="lead">${tr('city_panel.cdns_put_free_cache_servers_inside')}</p>`;
for(const n of NETS.filter(n=>n.cache)){const have=S.caches.filter(x=>x.city===c&&x.net===n.id),dem=R.demTo[n.id]||0,ok=dem>=n.cache.min;
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.cache.name)}</div><div class="meta">${tr('from {net}',{net:esc(n.name)})} · ${have.length?`${trn('{n} box','{n} boxes',have.length)} · ${tr('serving {v}',{v:fmtG(have.reduce((a,x)=>a+(R.useCache[x.id]||0),0))})}`:tr('100G per box')}</div>${!ok?`<div class="why">${tr('Needs {min} Gbps of traffic to {net} (now {now})',{min:n.cache.min,net:esc(n.name),now:dem.toFixed(1)})}</div>`:''}</div>
${have.length?btn(tr('Remove'),'rmCache',{id:(have.find(x=>x.site==='b')||have[0]).id},'ghost sm'):''}${btn(have.length?tr('+ box'):tr('Request'),'cache',{city:c,net:n.id},'sm',!ok)}</div>${S.pops[c].site2&&have.length?(()=>{const nb=have.filter(x=>x.site==='b').length,na=have.length-nb;return `<div class="seg site"><span class="meta">${tr('Boxes: {a} in A · {b} in B',{a:na,b:nb})}</span>${na?btn(tr('Move one to B'),'cacheSite',{city:c,net:n.id,s:'b'},'ghost sm'):''}${nb?btn(tr('Move one to A'),'cacheSite',{city:c,net:n.id,s:'a'},'ghost sm'):''}</div>`;})():''}`;}
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.cache.name)}</div><div class="meta">${tr('common.from_net',{net:esc(n.name)})} · ${have.length?`${trn('common.n_box',have.length)} · ${tr('city_panel.serving_v',{v:fmtG(have.reduce((a,x)=>a+(R.useCache[x.id]||0),0))})}`:tr('city_panel.100g_per_box')}</div>${!ok?`<div class="why">${tr('city_panel.needs_min_gbps_of_traffic_to',{min:n.cache.min,net:esc(n.name),now:dem.toFixed(1)})}</div>`:''}</div>
${have.length?btn(tr('common.remove'),'rmCache',{id:(have.find(x=>x.site==='b')||have[0]).id},'ghost sm'):''}${btn(have.length?tr('common.box'):tr('common.request'),'cache',{city:c,net:n.id},'sm',!ok)}</div>${S.pops[c].site2&&have.length?(()=>{const nb=have.filter(x=>x.site==='b').length,na=have.length-nb;return `<div class="seg site"><span class="meta">${tr('city_panel.boxes_a_in_a_b_in',{a:na,b:nb})}</span>${na?btn(tr('city_panel.move_one_to_b'),'cacheSite',{city:c,net:n.id,s:'b'},'ghost sm'):''}${nb?btn(tr('city_panel.move_one_to_a'),'cacheSite',{city:c,net:n.id,s:'a'},'ghost sm'):''}</div>`;})():''}`;}
h+=`</section>`;
}else{
const ls=S.links.filter(l=>l.a===c||l.b===c);
const rt=p.routers||1,g=p.rgen||0,G=RG[g],nl=R.nodeLoad[c]||0,nc=R.nodeCap[c]||nodeCap(c),Ni=g===mainRG(G.cls)?mainRG(G.cls+1):-1,N=Ni>=0?RG[Ni]:null,pu=portsUsed(c),pm=portsMax(c);
h+=`<section><h3>${tr('Routers')}</h3><p class="lead">${tr('The model sets your fastest interface and how much this POP can forward. More routers add capacity and survive crashes.')}</p>
<div class="row"><span class="logo" style="--c:${G.badge?'#2C7A7B':'#FF4F9A'}">${G.badge||'R'+(G.cls+1)}</span><div class="grow"><div class="nm">${rt} × ${esc(G.n)}</div><div class="meta">${tr('Up to {pn} interfaces · {ports} ports and {cap} per router',{pn:G.pn,ports:G.ports,cap:fmtG(G.cap)})} · ${esc(G.blurb)}</div></div></div>
<div class="kv"><span>${tr('Router ports')}</span><b>${tr('{used} / {max} in use',{used:fmtPorts(pu),max:pm})}</b></div><div class="bar ${barCls(pu/pm)}"><i style="width:${Math.min(100,pu/pm*100)}%"></i></div>${pu>=pm?`<p class="why">${tr('Every port is taken. Add a router or swap to a model with more ports before you plug in anything new.')}</p>`:''}
<div class="kv"><span>${tr('Forwarding chip')}</span><b>${esc(G.chip)}</b></div><div class="kv"><span>${tr('Boot time')}</span><b>${slowBoot(c)?`<span style="color:var(--bad)">${tr('~{n} min · a slow one',{n:bootMin(c)})}</span>`:tr('~{n} min',{n:bootMin(c)})}</b></div>${slowBoot(c)?`<p class="note">${tr('This chassis takes forever to boot: crashes last longer, and swapping the only router here takes 3 days. A second router hides it.')}</p>`:''}
<div class="kv"><span>${tr('Forwarding load')}</span><b>${fmtG(nl)} / ${fmtG(nc)}</b></div><div class="bar ${barCls(nl/nc)}"><i style="width:${Math.min(100,nl/nc*100)}%"></i></div>
${nl>=nc*0.95?`<p class="why">${tr('Maxed out. Traffic here is being dropped.')}</p>`:''}
<div class="btns">${N?btn(N.lvl>lvl()?tr('{model} <small>level {lv}</small>',{model:esc(N.n),lv:N.lvl}):tr('Upgrade to {model} <small>{cost} + {mo}/mo</small>',{model:esc(N.n),cost:fmt$(swapCost(c,Ni)),mo:fmt$(N.mo*rt)}),'upRouter',{city:c,g:Ni},'pink',N.lvl>lvl()||S.cash<swapCost(c,Ni)||p.rupDay===S.day):''}${btn(UI.models?tr('Hide other models'):tr('Other models'),'models',{},'ghost sm')}${rt<RMAX?btn(tr('Add router <small>{cost} + {mo}/mo</small>',{cost:fmt$(routerCost(g)),mo:fmt$(ROUTER_MO+G.mo)}),'addRouter',{city:c},'',S.cash<routerCost(g)):''}${rt>1?btn(tr('Remove one'),'rmRouter',{city:c},'ghost sm'):''}</div>
h+=`<section><h3>${tr('common.routers')}</h3><p class="lead">${tr('city_panel.the_model_sets_your_fastest')}</p>
<div class="row"><span class="logo" style="--c:${G.badge?'#2C7A7B':'#FF4F9A'}">${G.badge||'R'+(G.cls+1)}</span><div class="grow"><div class="nm">${rt} × ${esc(G.n)}</div><div class="meta">${tr('city_panel.up_to_pn_interfaces_ports_ports',{pn:G.pn,ports:G.ports,cap:fmtG(G.cap)})} · ${esc(G.blurb)}</div></div></div>
<div class="kv"><span>${tr('common.router_ports')}</span><b>${tr('city_panel.used_max_in_use',{used:fmtPorts(pu),max:pm})}</b></div><div class="bar ${barCls(pu/pm)}"><i style="width:${Math.min(100,pu/pm*100)}%"></i></div>${pu>=pm?`<p class="why">${tr('city_panel.every_port_is_taken_add_a')}</p>`:''}
<div class="kv"><span>${tr('common.forwarding_chip')}</span><b>${esc(G.chip)}</b></div><div class="kv"><span>${tr('common.boot_time')}</span><b>${slowBoot(c)?`<span style="color:var(--bad)">${tr('city_panel.n_min_a_slow_one',{n:bootMin(c)})}</span>`:tr('city_panel.n_min',{n:bootMin(c)})}</b></div>${slowBoot(c)?`<p class="note">${tr('city_panel.this_chassis_takes_forever_to_boot')}</p>`:''}
<div class="kv"><span>${tr('common.forwarding_load')}</span><b>${fmtG(nl)} / ${fmtG(nc)}</b></div><div class="bar ${barCls(nl/nc)}"><i style="width:${Math.min(100,nl/nc*100)}%"></i></div>
${nl>=nc*0.95?`<p class="why">${tr('city_panel.maxed_out_traffic_here_is_being')}</p>`:''}
<div class="btns">${N?btn(N.lvl>lvl()?tr('city_panel.model_level_lv',{model:esc(N.n),lv:N.lvl}):tr('city_panel.upgrade_to_model_cost_mo_mo',{model:esc(N.n),cost:fmt$(swapCost(c,Ni)),mo:fmt$(N.mo*rt)}),'upRouter',{city:c,g:Ni},'pink',N.lvl>lvl()||S.cash<swapCost(c,Ni)||p.rupDay===S.day):''}${btn(UI.models?tr('city_panel.hide_other_models'):tr('common.other_models'),'models',{},'ghost sm')}${rt<RMAX?btn(tr('city_panel.add_router_cost_mo_mo',{cost:fmt$(routerCost(g)),mo:fmt$(ROUTER_MO+G.mo)}),'addRouter',{city:c},'',S.cash<routerCost(g)):''}${rt>1?btn(tr('common.remove_one'),'rmRouter',{city:c},'ghost sm'):''}</div>
${UI.models?routerModels(c):''}
${N||UI.models?`<p class="note">${(p.rgen||0)>0?tr('Prices include {p} back for the old routers on eBuy.',{p:fmt$(tradeIn(p.rgen||0,rt))})+' ':''}${p.rupDay===S.day?tr('New routers went in today. The next swap can wait until tomorrow.')+' ':''}${rt>1?tr('Rolling upgrade: one router at a time, no downtime.'):tr('With one router, the upgrade needs a maintenance window: this POP goes dark for a day.')}</p>`:''}
<p class="note">${rt>=2?tr('A crash here only costs one router’s capacity for a few days.'):tr('One router is a single point of failure.')}</p></section>
<section><h3>${tr('Metro diversity')}</h3>${p.site2?(()=>{const up=s=>[...S.transit.filter(t=>t.city===c&&onSite(t.site,s)).map(t=>tr('{net} transit',{net:NET[t.net].name})+(t.site==='ab'?' '+tr('(split)'):'')),...S.pni.filter(x=>x.city===c&&onSite(x.site,s)).map(x=>'PNI '+NET[x.net].name+(x.site==='ab'?' '+tr('(split)'):'')),...ixIdsIn(c).filter(x=>S.ixp[x]!==undefined&&onSite((S.ixSite||{})[x],s)).map(x=>(S.myIx[x]?tr('{ix} switch',{ix:ixName(x)}):tr('{port} port',{port:ixName(x)}))+((S.ixSite||{})[x]==='ab'?' '+tr('(split)'):'')),...S.caches.filter(x=>x.city===c&&(x.site==='b'?'b':'a')===s).map(x=>NET[x.net].cache.name)];
const row=s=>{const dn=siteDown(c,s),u=up(s);return `<div class="row"><span class="logo" style="--c:${s==='a'?'#FF4F9A':'#7B61FF'}">${s.toUpperCase()}</span><div class="grow"><div class="nm">${esc(siteName(c,s))}${dn?' <span class="tag restrictive">DOWN</span>':''}</div><div class="meta">${u.length?esc(u.join(', ')):tr('Nothing plugged in here yet')}</div></div></div>`;};
return `<p class="lead">${tr('Two buildings joined by your own metro ring. A power cut or cleaner in one leaves the other running at half capacity. Uplinks only work while their site is up, unless you split them: choose <b>Both</b> on a port to put LAG members in each building.')}</p>${row('a')}${row('b')}${up('b').length&&up('a').length?'':`<p class="why">${tr('Everything is in one building. Move some uplinks to the other site from the Transit and Peering tabs.')}</p>`}<div class="kv"><span>${tr('Second site and metro ring')}</span><b>${tr('{price}/mo',{price:fmt$(SITE2_MO)})}</b></div><div class="btns">${btn(UI.confirm==='site'+c?tr('Really close it?'):tr('Close site B'),'rmSite',{city:c},'ghost sm')}</div>`;})()
:`<p class="lead">${tr('Right now {city} is one building. A power cut, an A/C failure or a cleaner with a vacuum takes the whole city dark, and a second router does not help with that. A second data center across town, joined by your own metro ring, keeps half the POP up.',{city:esc(CITY[c].name)})}</p><div class="btns">${btn(tr('Add a second site <small>{cost} + {mo}/mo</small>',{cost:fmt$(SITE2_COST),mo:fmt$(SITE2_MO)}),'addSite',{city:c},'pink',S.cash<SITE2_COST)}</div>`}</section>
<section><h3>${tr('Power')}</h3><div class="kv"><span>${tr('Backup generator')}</span><b>${p.gen?tr('Installed'):tr('None')}</b></div>${p.gen?'<p class="note">'+tr('Power cuts are covered.')+'</p>':`<div class="btns">${btn(tr('Install generator <small>{cost} + {mo}/mo</small>',{cost:fmt$(GEN_COST),mo:fmt$(GEN_MO)}),'addGen',{city:c},'',S.cash<GEN_COST)}</div>`}</section>`;
h+=`<section><h3>${tr('DDoS scrubbing center')}</h3>`;
${N||UI.models?`<p class="note">${(p.rgen||0)>0?tr('city_panel.prices_include_p_back_for_the',{p:fmt$(tradeIn(p.rgen||0,rt))})+' ':''}${p.rupDay===S.day?tr('city_panel.new_routers_went_in_today_the')+' ':''}${rt>1?tr('city_panel.rolling_upgrade_one_router_at_a'):tr('city_panel.with_one_router_the_upgrade_needs')}</p>`:''}
<p class="note">${rt>=2?tr('city_panel.a_crash_here_only_costs_one'):tr('city_panel.one_router_is_a_single_point')}</p></section>
<section><h3>${tr('common.metro_diversity')}</h3>${p.site2?(()=>{const up=s=>[...S.transit.filter(t=>t.city===c&&onSite(t.site,s)).map(t=>tr('common.net_transit',{net:NET[t.net].name})+(t.site==='ab'?' '+tr('common.split'):'')),...S.pni.filter(x=>x.city===c&&onSite(x.site,s)).map(x=>'PNI '+NET[x.net].name+(x.site==='ab'?' '+tr('common.split'):'')),...ixIdsIn(c).filter(x=>S.ixp[x]!==undefined&&onSite((S.ixSite||{})[x],s)).map(x=>(S.myIx[x]?tr('city_panel.ix_switch',{ix:ixName(x)}):tr('common.port_port',{port:ixName(x)}))+((S.ixSite||{})[x]==='ab'?' '+tr('common.split'):'')),...S.caches.filter(x=>x.city===c&&(x.site==='b'?'b':'a')===s).map(x=>NET[x.net].cache.name)];
const row=s=>{const dn=siteDown(c,s),u=up(s);return `<div class="row"><span class="logo" style="--c:${s==='a'?'#FF4F9A':'#7B61FF'}">${s.toUpperCase()}</span><div class="grow"><div class="nm">${esc(siteName(c,s))}${dn?' <span class="tag restrictive">DOWN</span>':''}</div><div class="meta">${u.length?esc(u.join(', ')):tr('city_panel.nothing_plugged_in_here_yet')}</div></div></div>`;};
return `<p class="lead">${tr('city_panel.two_buildings_joined_by_your_own')}</p>${row('a')}${row('b')}${up('b').length&&up('a').length?'':`<p class="why">${tr('city_panel.everything_is_in_one_building_move')}</p>`}<div class="kv"><span>${tr('city_panel.second_site_and_metro_ring')}</span><b>${tr('common.price_mo',{price:fmt$(SITE2_MO)})}</b></div><div class="btns">${btn(UI.confirm==='site'+c?tr('city_panel.really_close_it'):tr('city_panel.close_site_b'),'rmSite',{city:c},'ghost sm')}</div>`;})()
:`<p class="lead">${tr('city_panel.right_now_city_is_one_building',{city:esc(CITY[c].name)})}</p><div class="btns">${btn(tr('city_panel.add_a_second_site_cost_mo',{cost:fmt$(SITE2_COST),mo:fmt$(SITE2_MO)}),'addSite',{city:c},'pink',S.cash<SITE2_COST)}</div>`}</section>
<section><h3>${tr('common.power')}</h3><div class="kv"><span>${tr('common.backup_generator')}</span><b>${p.gen?tr('common.installed'):tr('common.none_304f')}</b></div>${p.gen?'<p class="note">'+tr('city_panel.power_cuts_are_covered')+'</p>':`<div class="btns">${btn(tr('city_panel.install_generator_cost_mo_mo',{cost:fmt$(GEN_COST),mo:fmt$(GEN_MO)}),'addGen',{city:c},'',S.cash<GEN_COST)}</div>`}</section>`;
h+=`<section><h3>${tr('city_panel.ddos_scrubbing_center')}</h3>`;
{const here=S.scrubs.find(x=>x.city===c),others=S.scrubs.filter(x=>x.city!==c);
if(here){const T=SCRUB_TIERS[here.tier||0];
h+=`<p class="lead">${tr('Cleans attacks for your whole network, up to its clean-bandwidth capacity, and unlocks DDoS protection contracts. Clean traffic returns over GRE, which can re-open the MSS black hole.')}</p>
<div class="kv"><span>${tr('Capacity')}</span><b>${T.n} · ${fmtG(T.g)}</b></div>
<div class="kv"><span>${tr('Mode')}</span><b>${S.scrubMode==='ondemand'?tr('On-demand (engages in {n}d)',{n:SCRUB_DELAY}):tr('Always-on')} · ${fmt$(scrubMo1(here))}/mo</b></div>
<div class="btns">${btn(S.scrubMode==='ondemand'?tr('Switch to always-on'):tr('Switch to on-demand <small>cheaper</small>'),'scrubMode',{},'sm')}${SCRUB_TIERS.map((X,i)=>i>(here.tier||0)?btn(tr('Upgrade to {tier} <small>{cost}</small>',{tier:X.n,cost:fmt$(Math.round(X.cost*0.6))}),'scrubUp',{city:c,tier:i},'sm',(lvl()||1)<X.lvl||S.cash<X.cost*0.6):'').join('')}${btn(UI.confirm==='scrub:'+c?tr('Really shut it down?'):tr('Shut down'),'rmScrub',{city:c},'ghost sm')}</div>`;}
else{h+=`<p class="lead">${others.length?tr('Attacks go to your nearest scrubbing center. From here that is {city}, {km} km away: the flood rides your backbone there and back, which adds latency, and whatever your links cannot carry is not scrubbed. A center here cleans attacks on the spot.',{city:CITY[others.slice().sort((a,b)=>kmBetween(c,a.city)-kmBetween(c,b.city))[0].city].name,km:Math.round(kmBetween(c,others.slice().sort((a,b)=>kmBetween(c,a.city)-kmBetween(c,b.city))[0].city)).toLocaleString()}):tr('Cleans DDoS attacks for your whole network, up to its clean-bandwidth capacity, and unlocks DDoS protection contracts for businesses.')}</p><div class="btns">${SCRUB_TIERS.map((X,i)=>btn(tr('Build {tier} <small>{cost} + {mo}/mo</small>',{tier:X.n,cost:fmt$(X.cost),mo:fmt$(X.mo)}),'buildScrub',{city:c,tier:i},i===0?'':'sm',(lvl()||1)<X.lvl||S.cash<X.cost)).join('')}</div>`;}}
h+=`<p class="lead">${tr('city_panel.cleans_attacks_for_your_whole')}</p>
<div class="kv"><span>${tr('common.capacity')}</span><b>${T.n} · ${fmtG(T.g)}</b></div>
<div class="kv"><span>${tr('common.mode')}</span><b>${S.scrubMode==='ondemand'?tr('city_panel.on_demand_engages_in_n_d',{n:SCRUB_DELAY}):tr('common.always_on')} · ${fmt$(scrubMo1(here))}/mo</b></div>
<div class="btns">${btn(S.scrubMode==='ondemand'?tr('city_panel.switch_to_always_on'):tr('city_panel.switch_to_on_demand_cheaper'),'scrubMode',{},'sm')}${SCRUB_TIERS.map((X,i)=>i>(here.tier||0)?btn(tr('city_panel.upgrade_to_tier_cost',{tier:X.n,cost:fmt$(Math.round(X.cost*0.6))}),'scrubUp',{city:c,tier:i},'sm',(lvl()||1)<X.lvl||S.cash<X.cost*0.6):'').join('')}${btn(UI.confirm==='scrub:'+c?tr('city_panel.really_shut_it_down'):tr('common.shut_down'),'rmScrub',{city:c},'ghost sm')}</div>`;}
else{h+=`<p class="lead">${others.length?tr('city_panel.attacks_go_to_your_nearest_scrubbing',{city:CITY[others.slice().sort((a,b)=>kmBetween(c,a.city)-kmBetween(c,b.city))[0].city].name,km:Math.round(kmBetween(c,others.slice().sort((a,b)=>kmBetween(c,a.city)-kmBetween(c,b.city))[0].city)).toLocaleString()}):tr('city_panel.cleans_ddos_attacks_for_your_whole')}</p><div class="btns">${SCRUB_TIERS.map((X,i)=>btn(tr('city_panel.build_tier_cost_mo_mo',{tier:X.n,cost:fmt$(X.cost),mo:fmt$(X.mo)}),'buildScrub',{city:c,tier:i},i===0?'':'sm',(lvl()||1)<X.lvl||S.cash<X.cost)).join('')}</div>`;}}
h+=`</section>`;
const fabs=FABS.filter(f=>f.cities.includes(c));
if(fabs.length){h+=`<section><h3>${tr('Interconnection fabrics (NNI)')}</h3><p class="lead">${tr('Buy a port on a fabric, then order virtual circuits to your other POPs or to a remote IX. Fast and flexible, but you share their fabric.')}</p>`;
if(fabs.length){h+=`<section><h3>${tr('city_panel.interconnection_fabrics_nni')}</h3><p class="lead">${tr('city_panel.buy_a_port_on_a_fabric')}</p>`;
for(const f of fabs){const pt=nniPort(c,f.id),used=nniUsed(c,f.id);
h+=`<div class="row"><span class="logo" style="--c:${f.col}">${initials(f)}</span><div class="grow"><div class="nm">${esc(f.name)}</div><div class="meta">${esc(f.blurb)}</div>`;
if(pt){const cap=NNI[pt.tier].g;h+=`<div class="kv"><span>${tr('{port} port · {price}/mo',{port:NNI[pt.tier].n,price:fmt$(NNI[pt.tier].mo)})}</span><b>${tr('{g} of circuits',{g:fmtG(used)})}</b></div><div class="bar ${barCls(used/cap)}"><i style="width:${used/cap*100}%"></i></div><div class="btns">${btn(tr('New circuit'),'openVxc',{from:c,prov:f.id},'pink sm')}${pt.tier<1?btn(tr('Upgrade {port} <small>{price}/mo</small>',{port:NNI[1].n,price:fmt$(NNI[1].mo)}),'buyNni',{city:c,prov:f.id,tier:1},'sm'):''}${btn(tr('Remove port'),'rmNni',{city:c,prov:f.id},'ghost sm')}</div>`;}
else h+=`<div class="btns">${NNI.map((N,i)=>btn(tr('{port} port <small>{price}/mo</small>',{port:N.n,price:fmt$(N.mo)}),'buyNni',{city:c,prov:f.id,tier:i},'sm',S.cash<N.mo)).join('')}</div>`;
if(pt){const cap=NNI[pt.tier].g;h+=`<div class="kv"><span>${tr('city_panel.port_port_price_mo',{port:NNI[pt.tier].n,price:fmt$(NNI[pt.tier].mo)})}</span><b>${tr('city_panel.g_of_circuits',{g:fmtG(used)})}</b></div><div class="bar ${barCls(used/cap)}"><i style="width:${used/cap*100}%"></i></div><div class="btns">${btn(tr('common.new_circuit'),'openVxc',{from:c,prov:f.id},'pink sm')}${pt.tier<1?btn(tr('common.upgrade_port_price_mo',{port:NNI[1].n,price:fmt$(NNI[1].mo)}),'buyNni',{city:c,prov:f.id,tier:1},'sm'):''}${btn(tr('common.remove_port'),'rmNni',{city:c,prov:f.id},'ghost sm')}</div>`;}
else h+=`<div class="btns">${NNI.map((N,i)=>btn(tr('city_panel.port_port_price_mo_197d',{port:N.n,price:fmt$(N.mo)}),'buyNni',{city:c,prov:f.id,tier:i},'sm',S.cash<N.mo)).join('')}</div>`;
h+=`</div></div>`;}
h+=`</section>`;}
h+=`<section><h3>${tr('Fiber from {city}',{city:C.name})}</h3><p class="lead">${tr("Drag from this router to any city on the map to lay a new link. Two paths to every POP means a backhoe can't take you offline.")}</p>`;
if(!ls.length)h+=`<p class="empty">${tr('No links yet.')}</p>`;
h+=`<section><h3>${tr('city_panel.fiber_from_city',{city:C.name})}</h3><p class="lead">${tr('city_panel.drag_from_this_router_to_any')}</p>`;
if(!ls.length)h+=`<p class="empty">${tr('common.no_links_yet')}</p>`;
for(const l of ls){const o=l.a===c?l.b:l.a,u=capOf(l)?(R.load[l.id]||0)/capOf(l):0,cut=linkDown(l);
h+=`<div class="row"><div class="grow"><div class="nm">→ ${CITY[o].name}${l.mult>1?' · '+tr('diverse'):''} ${cut?'<span class="tag restrictive">'+tr('CUT')+'</span>':''}</div><div class="meta">${capName(l)} · ${l.km.toLocaleString()} km ${l.kind==='vxc'?tr('virtual circuit via {fab}',{fab:esc(FAB[l.prov].name)}):l.kind==='df'?(l.own?(l.sub&&l.cname?tr('your own subsea cable {name}',{name:l.cname}):tr('own dark fiber')):tr('dark fiber IRU'))+(l.ready>S.day?` · ${tr('ready in {n}d',{n:l.ready-S.day})}`:''):l.sub?tr('subsea'):tr('terrestrial')} · ${tr('{price}/mo',{price:fmt$(l.mo)})}</div><div class="bar ${barCls(u)}"><i style="width:${u*100}%"></i></div></div>${btn(tr('Open'),'selLink',{id:l.id},'ghost sm')}</div>`;}
h+=`<div class="row"><div class="grow"><div class="nm">→ ${CITY[o].name}${l.mult>1?' · '+tr('common.diverse'):''} ${cut?'<span class="tag restrictive">'+tr('common.cut')+'</span>':''}</div><div class="meta">${capName(l)} · ${l.km.toLocaleString()} km ${l.kind==='vxc'?tr('city_panel.virtual_circuit_via_fab',{fab:esc(FAB[l.prov].name)}):l.kind==='df'?(l.own?(l.sub&&l.cname?tr('city_panel.your_own_subsea_cable_name',{name:l.cname}):tr('common.own_dark_fiber')):tr('city_panel.dark_fiber_iru'))+(l.ready>S.day?` · ${tr('city_panel.ready_in_n_d',{n:l.ready-S.day})}`:''):l.sub?tr('common.subsea'):tr('common.terrestrial')} · ${tr('common.price_mo',{price:fmt$(l.mo)})}</div><div class="bar ${barCls(u)}"><i style="width:${u*100}%"></i></div></div>${btn(tr('common.open'),'selLink',{id:l.id},'ghost sm')}</div>`;}
h+=`</section>`;
if(Object.keys(S.pops).length>1)h+=`<section><h3>${tr('Decommission')}</h3><p class="lead">${tr('Shut this POP down: its links, ports and caches go with it, and every customer that depends on it is let go, with an early-termination penalty.')}</p><div class="btns">${btn(tr('Decommission {city}…',{city:C.name}),'decomOpen',{city:c},'ghost sm')}${btn(tr('Decommission several POPs…'),'decomOpen',{},'ghost sm')}</div></section>`;
if(Object.keys(S.pops).length>1)h+=`<section><h3>${tr('common.decommission')}</h3><p class="lead">${tr('city_panel.shut_this_pop_down_its_links')}</p><div class="btns">${btn(tr('city_panel.decommission_city',{city:C.name}),'decomOpen',{city:c},'ghost sm')}${btn(tr('city_panel.decommission_several_pops'),'decomOpen',{},'ghost sm')}</div></section>`;
}
return h+`</div>`;
}