🏝️ ${tr('wisp.section')}
${tr('wisp.lead',{rate:fmt$(wispRate(zs[0]))})}
${zs.map(wispRow).join('')}`;}
function wispRow(z){const W=WISP[z],Z=wispZ(z),r=R.wisp&&R.wisp[z],P=wispPool(z),st=wispStatus(z,Z),open=UI.wz===z,d=Z?Z.d:0,sf=r?r.sf:0,on=!!Z&&wispTake(Z)>0,n=Z&&!on?wispSoon(Z):0;
let h=`${esc(W.n)} ${st.t}
${tr('wisp.pool',{g:fmtG(P)})}${on?' · '+tr('pie_gov.served',{p:pct(sf)}):n?' · '+tr('city_panel.ready_in_n_d',{n}):''}
${on?`
`:''}
${btn(open?tr('common.close'):tr('common.open'),'wispOpen',{z},'ghost sm')}
`;
return open?h+wispOpenHtml(z,Z,r):h;}
// The open zone: its homes and money (once something reaches them; until then, the day it will), its backhaul (the
// circuit, the birds to order on), the spur, closing it. A cut spur or a solar storm is an outage: that one shows in red.
function wispOpenHtml(z,Z,r){const K=Z?wispK(z,Z):0,k=Z?wispLink(z,Z):null;let h='';
if(Z){const sf=r?r.sf:0,cl=sf<0.9?'var(--tx-red,var(--bad))':'var(--eye)',n=K>0?0:wispSoon(Z);
h+=K>0?`${tr('wisp.homes_online')}${tr('city_panel.a_of_b',{a:fmtG(Z.d),b:fmtG(K)})}
${tr('wisp.served')}${pct(sf)}
${tr('common.revenue')}${tr('common.price_mo',{price:fmt$(r?r.d*r.sf*wispRate(z):0)})}
`:n?`${trn('wisp.online_in_n_days',n)}
`:'';
h+=`${tr('wisp.upkeep')}${tr('common.price_mo',{price:fmt$(wispUpMo(z)+(wispLit(Z)?wispSpurMo(z):0))})}
${k&&r&&r.d>=k.g*0.98?`${tr('wisp.full')}
`:''}`;}
h+=`${tr('wisp.take',{geo:pct(SAT_ORB.geo.wisp),meo:pct(SAT_ORB.meo.wisp),leo:pct(SAT_ORB.leo.wisp)})}
${ip4On()?`${tr('wisp.ipv6')}
`:''}`;
return `${h}${wispBackhaul(z,Z,k)}${wispSpurHtml(z,Z)}${Z?`
${btn(UI.confirm==='wz:'+z?tr('satellites.really_close_it'):tr('wisp.close'),'wispRm',{z},'ghost sm')}
`:''}
`;}
// Backhaul: the circuit (and a move under way), then a row per bird that sees both the city and the islands.
function wispBackhaul(z,Z,k){const W=WISP[z],c=W.c,C=CITY[c].name,t=teleOf(c);
let h=`${tr('wisp.backhaul')}
`;
if(satOnly(c))h+=`${tr('wisp.double_hop',{city:C})}
`;
const o=Z&&Z.sat,run=(x,now)=>{const O=SAT_ORB[wispOrb(x)],P=SAT_PROV[SATS[x.bird].p],car=now&&k===x&&R.wisp&&R.wisp[z]?R.wisp[z].car:0,u=x.g?car/x.g:0,sb=now&&k&&k.sp;
return `${satLogo(P)}
${esc(SATS[x.bird].n)} ${O.n}${sb?` ${tr('common.standby')}`:''}
${fmtCap(x.g)} · ${tr('satellites.ms_round_trip',{ms:Math.round(2*wispMs(z,x.bird))})} · ${tr('common.price_mo',{price:fmt$(x.mo)})}${x.ready>S.day?' · '+tr('city_panel.ready_in_n_d',{n:x.ready-S.day}):''}
${now&&wispOrb(x)==='leo'&&leoStorm()?`
${trn('satellites.leo_safe_mode_n_days',S.ev.sky-S.day)}
`:''}${now?`
`:''}
`;};
if(o){const G=SAT_ORB[wispOrb(o)].g;h+=run(o,true)+`${G.filter(g=>g!==o.g).map(g=>btn(`${g>o.g?tr('satellites.grow_to',{cap:fmtCap(g)}):tr('satellites.shrink_to',{cap:fmtCap(g)})}
${tr('common.price_mo',{price:fmt$(wispSatMo(o.bird,g))})}`,'wispSatSize',{z,g},'sm',g>o.g&&S.cash
`;}
if(Z&&Z.nxt)h+=run(Z.nxt,false);
if(!t){h+=`${tr('wisp.no_teleport',{city:C})}
${btn(tr('satellites.build_a_teleport_cost_mo',{cost:fmt$(TPORT_COST),mo:fmt$(TPORT_MO)}),'teleBuild',{city:c},'sm',S.cash
`;return h;}
if(Z&&Z.nxt)return h;
h+=o?`${tr('wisp.move_note')}
`:Z?'':`${tr('wisp.kit',{cost:fmt$(wispKit(z))})}
`;
const kit=Z?0:wispKit(z);
for(const id of wispBirds(z)){if(o&&o.bird===id)continue;const B=SATS[id],O=SAT_ORB[B.orb],P=SAT_PROV[B.p];if(lvl()${satLogo(P)}${esc(B.n)} ${O.n}
${esc(P.n)} · ${tr('satellites.ms_round_trip',{ms:Math.round(2*wispMs(z,id))})} · ${trn('satellites.up_in_n_days',leadDays(O.days))}
${why?`
${esc(why)}
`:''}
${up||O.g.map(g=>btn(`${fmtCap(g)} ${tr('common.price_mo',{price:fmt$(wispSatMo(id,g))})}`,'wispSat',{z,bird:id,g},'sm',!!why||S.cash
`;}
return h;}
// The spur: what it costs and takes, laying it, lit, or cut (with the incident's own rush button).
function wispSpurHtml(z,Z){const W=WISP[z],c=W.c;let h=`${tr('wisp.spur')}
`;
if(!W.km)return h+`${tr('wisp.spur_none')}
`;
const sp=Z&&Z.sp;
if(!sp){const why=wispSpurWhy(z),cost=wispSpurCost(z)+(Z?0:wispKit(z));
return h+`${tr('wisp.spur_lead',{km:W.km.toLocaleString(),city:CITY[c].name})}
${tr('common.price_mo',{price:fmt$(wispSpurMo(z))})} · ${trn('satellites.up_in_n_days',wispSpurDays(z))}
${why?`${esc(why)}
`:''}${lvl()${btn(tr('wisp.lay_spur',{cost:fmt$(cost)}),'wispSpur',{z},'pink sm',!!why||S.cash`}`;}
if(sp.ready>S.day){const tot=Math.max(1,sp.ready-sp.day),done=clamp((S.day-sp.day)/tot,0,1);
return h+`${tr('wisp.spur_laying')}${tr('common.n_days_left',{n:sp.ready-S.day})}
`;}
const cut=wispCut(z);if(!cut)return h+`${tr('wisp.spur_lit',{cap:fmtCap(WISP_SPUR_G)})}${W.km.toLocaleString()} km
`;
const i=S.inc.filter(x=>x.type==='wspur'&&x.z===z).sort((a,b)=>b.until-a.until)[0],up=!!Z.sat&&!(Z.sat.ready>S.day);
return h+`${trn('wisp.spur_cut',cut-S.day)}
${i&&i.cost?`${btn(`${esc(i.fix||tr('common.rush_repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red sm',S.cash
`:''}${up?'':`${tr('wisp.spur_trap')}
`}`;}
// In the teleport section: the zones' circuits from here, each opening its zone.
function wispTeleRows(c){const zs=wispSats(c);if(!zs.length)return '';
return `${tr('wisp.tele_reaches')}
`+zs.map(z=>{const Z=wispZ(z),o=Z.sat||Z.nxt,k=wispLink(z,Z),car=R.wisp&&R.wisp[z]&&k===Z.sat?R.wisp[z].car:0,u=Z.sat&&Z.sat.g?car/Z.sat.g:0;
return `🏝️ ${esc(WISP[z].n)}${k&&k.sp&&Z.sat?' '+tr('common.standby')+'':''}
${fmtCap(o.g)} · ${esc(SATS[o.bird].n)}${o.ready>S.day?' · '+tr('city_panel.ready_in_n_d',{n:o.ready-S.day}):''} · ${tr('common.price_mo',{price:fmt$(o.mo)})}
${btn(tr('common.open'),'wispOpen',{z},'ghost sm')}
`;}).join('');}