diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6715f36..f5f7851 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,8 @@ All notable changes to this project are documented here. The project follows
- DKNOG in Copenhagen joins the conference calendar every March.
- A PNI in the customer’s city now meets their local-breakout requirement while your network is Tier 1 (#20).
- A deal’s “Go there” button takes you to a required city without a POP, instead of returning to a city you already serve.
+- You can now upgrade, grow and cancel transit, PNIs, IX ports, cache boxes and fabric ports straight from the Connections tab of the NOC dashboard. Each row offers the next port size and another LAG member at the same prices as the POP panel, and cancelling asks you to confirm first.
+- New "Leased lines" tab in the NOC dashboard shows which leased waves, fabric circuits and dark fiber IRUs between your POPs you could replace with cheaper capacity: leased dark fiber, your own fiber or your own subsea cable. Each option lists the up-front cost, the monthly cost, how much you would save and when it pays for itself, with a button to plan the build.
## [1.26.1] — 2026-10-25
diff --git a/site/i18n/it.js b/site/i18n/it.js
index afc54a2..d510475 100644
--- a/site/i18n/it.js
+++ b/site/i18n/it.js
@@ -2362,4 +2362,29 @@
"{km} km is longer than any optic reaches at full speed. Transponders will run in long-haul mode (1.2T, 800G or 400G per channel), or add regen sites along the way to get full speed back.":"{km} km sono più di quanto qualsiasi ottica raggiunga a piena velocità. I transponder andranno in modalità long-haul (1.2T, 800G o 400G per canale), oppure aggiungi siti di rigenerazione lungo il percorso per tornare alla piena velocità.",
"The hallway track moved to a bar by the harbour, where the woman behind the bar kept pouring aquavit long past midnight and asked nobody about their AS path. Back at the hotel bar, someone said “just one more drink”. Your BGP sessions stayed up all night. So did you.":"L'hallway track si è spostato in un bar sul porto, dove la signora dietro al bancone ha continuato a versare acquavite ben oltre mezzanotte senza chiedere a nessuno il suo AS path. Poi al bar dell'hotel qualcuno ha detto «solo un ultimo bicchiere». Le tue sessioni BGP sono rimaste su tutta la notte. Anche tu.",
"Local breakout: transit or an IX port in their own city, or a local PNI while Tier 1":"Breakout locale: transit o una porta IX nella città del cliente, oppure un PNI locale quando sei Tier 1",
+"Nobody lets you dig on this route. Borders and licences are in the way, so keep leasing.":"Su questa tratta nessuno ti lascia scavare. Confini e licenze sono d’intralcio, quindi continua ad affittare.",
+"Digging your own fiber unlocks at customer level 3.":"Scavare la tua fibra si sblocca al livello clienti 3.",
+"No optic you can buy reaches {km} km yet.":"Nessuna ottica che puoi comprare arriva ancora a {km} km.",
+"{cap} fabric circuit":"circuito fabric da {cap}",
+"{cap} on a dark fiber IRU":"{cap} su una dark fiber IRU",
+"{cap} wave":"wave da {cap}",
+"Leased lines":"Linee affittate",
+"Every wave, fabric circuit and dark fiber IRU you rent between two of your POPs, next to what leased dark fiber or your own fiber would cost. Estimates include the line system, amplifiers and enough optics for today’s capacity. Build first, move the traffic, then cancel the lease.":"Ogni wave, circuito fabric e dark fiber IRU che affitti tra due tuoi POP, accanto a quanto costerebbe una dark fiber in affitto o la tua fibra. Le stime includono il sistema di linea, gli amplificatori e abbastanza ottiche per la capacità di oggi. Prima costruisci, poi sposta il traffico, infine disdici l’affitto.",
+"You pay for leases":"Paghi di affitti",
+"land":"terrestre",
+"You already own fiber here. Light more channels on it, then cancel the lease to save {price}/mo.":"Qui hai già la tua fibra. Accendi altri canali, poi disdici l’affitto e risparmi {price}/mese.",
+"Your own cable: {up} up front, {mo}/mo, about {n} days to build.":"Il tuo cavo: {up} subito, {mo}/mese, circa {n} giorni di lavori.",
+"Your own fiber: {up} up front, {mo}/mo, about {n} days to build.":"La tua fibra: {up} subito, {mo}/mese, circa {n} giorni di lavori.",
+"Saves {price}/mo, pays for itself in about {n} months.":"Risparmi {price}/mese, si ripaga in circa {n} mesi.",
+"Costs more than leasing at this size.":"A questa capacità costa più dell’affitto.",
+"Open your fiber":"Apri la tua fibra",
+"Plan a cable":"Progetta un cavo",
+"Plan your own fiber":"Progetta la tua fibra",
+"Open lease":"Apri l’affitto",
+"You do not lease any lines between your POPs.":"Non affitti nessuna linea tra i tuoi POP.",
+"Lease dark fiber: {up} up front, {mo}/mo, ready in about {n} days.":"Dark fiber in affitto: {up} subito, {mo}/mese, pronta in circa {n} giorni.",
+"Plan dark fiber":"Progetta la dark fiber",
+"You already lease dark fiber here. Light more channels on it, then cancel the waves to save {price}/mo.":"Qui affitti già una dark fiber. Accendi altri canali, poi disdici le wave e risparmi {price}/mese.",
+"Open your dark fiber":"Apri la tua dark fiber",
+"− box":"− box",
};
diff --git a/site/index.html b/site/index.html
index fb5dd47..ace47c6 100644
--- a/site/index.html
+++ b/site/index.html
@@ -2542,6 +2542,7 @@ const ACT={
repayLoan:({id})=>{const l=S.loans.find(x=>x.id===id);if(!l)return;const B=BANKS[l.bank];const cost=repayCost(l,B);
if(UI.confirm!==id){UI.confirm=id;renderBank();return;}UI.confirm=null;if(!spend(cost)){renderBank();return;}S.loans=S.loans.filter(x=>x!==l);track('loan_repaid');
toast(B.equity?tr('You bought out {bank}. They flew off to find another startup.',{bank:esc(B.name)}):tr('Loan from {bank} repaid early.',{bank:esc(B.name)}),'good');after();renderBank();},
+ leaseSwap:({a,b,src})=>{if(!S.pops[a]||!S.pops[b]||a===b)return;$('dash').hidden=true;UI.lmode='df';UI.dfSrc=['lease','build','cable'].includes(src)?src:isSub(a,b)?'cable':'build';UI.dfSys=lvl()>=3?'roadm':'lite';openLinkModal(a,b);},
dashLink:({id})=>{$('dash').hidden=true;UI.confirm=null;UI.sel={type:'link',id};renderPanel();},
animSet:({v})=>{if(!['auto','on','off'].includes(v))return;UI.anim=v;try{localStorage.setItem('sot-anim',v);}catch(e){}applyAnim();refreshSettings();},
soundSet:({v})=>{UI.muted=v==='off';try{localStorage.setItem('sot-mute',UI.muted?'1':'0');}catch(e){}renderHUD();refreshSettings();},
@@ -2668,6 +2669,8 @@ const ACT={
connNet:({v})=>{UI.cf=UI.cf||{};UI.cf.net=NET[v]?v:'';renderDash();},
connSort:({k})=>{if(!['k','city','name','use','mo'].includes(k))return;if(UI.connSort===k)UI.connDir=-(UI.connDir||1);else{UI.connSort=k;UI.connDir=k==='use'||k==='mo'?-1:1;}renderDash();},
connFor:({net})=>{if(!NET[net])return;UI.cf={net};ACT.connOpen();},
+ connCancel:({k,id})=>{const r=conns().find(x=>x.k===k&&x.id===id);if(!r||r.mine)return;const key='cc:'+k+':'+id;if(UI.confirm!==key){UI.confirm=key;renderDash();return;}UI.confirm=null;
+ if(k==='t'){UI.confirm=id;ACT.cancelTransit({id});}else if(k==='p'){UI.confirm=id;ACT.cancelPni({id});}else if(k==='ix'){UI.confirm='ix'+id;ACT.cancelIx({city:id});}else if(k==='c')ACT.rmCache({id});else{const [city,prov]=id.split('|');ACT.rmNni({city,prov});}renderDash();},
connOpen:()=>{if(!S)return;UI.dtab='conn';const d=$('dash');d.hidden=false;renderDash();d.scrollTop=0;},
applyCn:()=>{if(S.cnLic.state!=='none')return;if(!spend(CN_LIC))return;S.cnLic={state:'pending',ready:S.day+45};toast(tr('Application filed. Your local partner says about 45 days. Probably.'),'goal');after();},
togglePrem:({id})=>{const t=S.transit.find(x=>x.id===id);if(!t)return;t.premium=!t.premium;sfx('click');after();},
@@ -2780,7 +2783,7 @@ function chWhy(l,o){const O=OPT[o];if(O.lvl>lvl())return tr('Unlocks at customer
if((l.ch||[]).length+soldSlots(l)>=chMax(l))return soldSlots(l)?tr('{sys} is full ({max} channels, {sold} sold to customers).',{sys:DF_SYS[l.sys].n,max:chMax(l),sold:soldSlots(l)}):tr('{sys} is full ({max} channels).',{sys:DF_SYS[l.sys].n,max:chMax(l)});
for(const c of [l.a,l.b]){const p=S.pops[c];if(p&&RG[p.rgen||0].clsinnerWidth>760&&innerWidth<=1200;
function selectCity(c){UI.sel={type:'city',id:c};UI.confirm=null;if(isTablet()||isPhone())UI.leftOpen=false;const P=$('panel');if(P)P.classList.remove('full');if(!S.pops[c])UI.tab='cust';renderPanel();}
@@ -3273,11 +3276,28 @@ const connTab=k=>k==='t'?'up':k==='nni'?'links':'peer';
function conns(){const out=[],pn=(tier,n)=>(n||1)>1?`${n}×${PORT[tier].n} LAG`:PORT[tier].n;
for(const t of S.transit){const q=(R.p95&&R.p95[t.id])||0;out.push({k:'t',id:t.id,city:t.city,net:t.net,name:NET[t.net].name,port:pn(t.tier,t.n),cap:lagCap(PORT[t.tier].g,t.n),use:R.useT[t.id]||0,mo:transitMo(t,q),down:t.down>S.day||!popUp(t.city),low:t.pref==='low',note:tr('95th percentile {g}',{g:fmtG(q)})});}
for(const x of S.pni){const u=R.usePni[x.id]||0;out.push({k:'p',id:x.id,city:x.city,net:x.net,name:NET[x.net].name,port:pn(x.tier,x.n),cap:lagCap(PORT[x.tier].g,x.n),use:u,mo:pniMo(x,u),down:!popUp(x.city),low:x.pref==='low',note:NET[x.net].pol==='paid'?tr('paid peering'):''});}
- for(const c in S.ixp){const ses=ixSessions(c),mine=!!S.myIx[c];out.push({k:'ix',id:c,city:ixCity(c),net:null,nets:[...ses],name:ixName(c),port:mine?tr('your exchange'):pn(S.ixp[c],(S.ixn||{})[c]),cap:ixCap(c),use:R.useIx[c]||0,mo:ixMo(c),down:!!(S.ev.ixdown&&S.ev.ixdown[c]>S.day),low:(S.ixPref&&S.ixPref[c])==='low',note:trn('{n} peering session','{n} peering sessions',ses.size)+(isRemote(c)?' · '+tr('remote'):'')});}
+ for(const c in S.ixp){const ses=ixSessions(c),mine=!!S.myIx[c];out.push({k:'ix',id:c,city:ixCity(c),net:null,nets:[...ses],name:ixName(c),port:mine?tr('your exchange'):pn(S.ixp[c],(S.ixn||{})[c]),cap:ixCap(c),use:R.useIx[c]||0,mo:ixMo(c),mine,down:!!(S.ev.ixdown&&S.ev.ixdown[c]>S.day),low:(S.ixPref&&S.ixPref[c])==='low',note:trn('{n} peering session','{n} peering sessions',ses.size)+(isRemote(c)?' · '+tr('remote'):'')});}
const cg={};for(const x of S.caches){const key=x.city+'|'+x.net;(cg[key]=cg[key]||[]).push(x);}
- for(const key in cg){const g=cg[key],x=g[0];out.push({k:'c',id:x.id,city:x.city,net:x.net,name:NET[x.net].cache.name,port:trn('{n} box','{n} boxes',g.length),cap:CACHE_CAP*g.length,use:g.reduce((a,y)=>a+(R.useCache[y.id]||0),0),mo:CACHE_MO*g.length,down:!popUp(x.city),low:false,note:tr('from {net}',{net:NET[x.net].name})});}
+ for(const key in cg){const g=cg[key],x=g[0];out.push({k:'c',id:x.id,n:g.length,city:x.city,net:x.net,name:NET[x.net].cache.name,port:trn('{n} box','{n} boxes',g.length),cap:CACHE_CAP*g.length,use:g.reduce((a,y)=>a+(R.useCache[y.id]||0),0),mo:CACHE_MO*g.length,down:!popUp(x.city),low:false,note:tr('from {net}',{net:NET[x.net].name})});}
for(const x of S.nni||[])if(FAB[x.prov]&&NNI[x.tier])out.push({k:'nni',id:x.city+'|'+x.prov,city:x.city,net:null,name:FAB[x.prov].name,port:NNI[x.tier].n,cap:NNI[x.tier].g,use:nniUsed(x.city,x.prov),mo:NNI[x.tier].mo,down:!popUp(x.city),low:false,note:tr('virtual circuits and fabric customers')});
return out;}
+// Cancel straight from the list, with the same "Really?" step as the POP panel.
+// Grow a connection from the list: the next port size and one more LAG member, same actions and prices as the POP panel.
+function connUp(r){if(r.mine)return '';const nx=t=>PORT[t+1]&&portShown(t+1)?t+1:-1;let h='';
+ if(r.k==='t'){const t=S.transit.find(x=>x.id===r.id);if(!t)return '';const n=t.n||1,i=nx(t.tier);
+ if(i>=0){const a={port:PORT[i].n,cost:fmt$(PORT[i].setup*n),mo:fmt$(PORT[i].tmo*n)};h+=btn(n>1?tr('Upgrade all to {port} {cost} + {mo}/mo',a):tr('Upgrade {port} {cost} + {mo}/mo',a),'buyTransit',{city:t.city,net:t.net,tier:i},'sm',S.cash{cost} + {mo}/mo',{cost:fmt$(PORT[t.tier].setup),mo:fmt$(PORT[t.tier].tmo)}),'lagT',{id:t.id,d:1},'sm',S.cashx.id===r.id);if(!p)return '';const n=p.n||1,i=nx(p.tier),c=i>=0?(1500+PORT[i].setup/2)*n:0;
+ if(i>=0){const a={port:PORT[i].n,cost:fmt$(c)};h+=btn(n>1?tr('Upgrade all to {port} {cost}',a):tr('Upgrade {port} {cost}',a),'pni',{city:p.city,net:p.net,tier:i},'sm',!portOk(p.city,i)||S.cash{cost} + {mo}/mo',{cost:fmt$(1500+PORT[p.tier].setup/2),mo:fmt$(PORT[p.tier].pni)}),'lagP',{id:p.id,d:1},'sm',S.cash<1500+PORT[p.tier].setup/2);}
+ else if(r.k==='ix'){const c=r.id,city=ixCity(c),n=(S.ixn||{})[c]||1,i=nx(S.ixp[c]);
+ if(i>=0)h+=btn(tr('Upgrade {port} {price}',{port:PORT[i].n,price:portMo(ixPortMo(c,i)*n)}),'buyIx',{city:c,tier:i},'sm',(!!S.pops[city]&&!portOk(city,i))||(!S.pops[city]&&i>1));
+ if(S.pops[city]&&n{price}',{price:portMo(ixPortMo(c,S.ixp[c]))}),'lagIx',{city:c,d:1},'sm',S.cash{price}/mo',{port:NNI[pt.tier+1].n,price:fmt$(NNI[pt.tier+1].mo)}),'buyNni',{city,prov,tier:pt.tier+1},'sm');}
+ return h;}
+function connX(r){if(r.mine)return '';const on=UI.confirm==='cc:'+r.k+':'+r.id;
+ return btn(on?(r.k==='ix'?tr('Really leave?'):r.k==='t'?tr('Really cancel?'):tr('Really remove?')):r.k==='ix'?tr('Leave IX'):r.k==='t'?tr('Cancel'):r.k==='c'&&r.n>1?tr('− box'):r.k==='nni'?tr('Remove port'):tr('Remove'),'connCancel',{k:r.k,id:r.id},on?'red sm':'ghost sm');}
function connMatch(r,F){return (!F.k||r.k===F.k)&&(!F.city||r.city===F.city)&&(!F.net||r.net===F.net||(r.nets&&r.nets.includes(F.net)));}
function connSection(){const all=conns(),F=UI.cf||{};
let h=`
${tr('Connections')}
${tr('Every port that connects you to another network, and where it is. Filter by type, city or network, and tap Open to go to it.')}
`;
return h;}
// Where you connect to one network, as buttons that jump to the POP (Networks tab).
@@ -3308,8 +3328,41 @@ function netWhere(n){const ch=[];
for(const c of new Set(S.caches.filter(x=>x.net===n.id).map(x=>x.city)))ch.push([tr('Cache'),c,'c']);
if(!ch.length)return '';const MAX=6;
return `
`;}
-const DTABS=['overview','cust','conn','traffic','infra'];
-function dashTabs(){const u=custStats().unhappy,cur=UI.dtab||'overview',L={overview:tr('Overview'),cust:tr('Customers'),conn:tr('Connections'),traffic:tr('Traffic'),infra:tr('Links & routers')};
+const DTABS=['overview','cust','conn','traffic','infra','lease'];
+/* Leased lines you could swap for your own glass: waves, fabric circuits and IRUs between two of your POPs,
+ priced against digging (land) or laying a cable (subsea), with enough optics to match what you lease today. */
+function swapOptics(km,cap,sub,sys){for(let r=0;r<=(sub?0:REGEN_MAX);r++){const l={km,regen:r,sub};let b=null;
+ for(const o in OPT){if(OPT[o].lvl>lvl()||sys==='lite'&&OPT[o].sys==='roadm')continue;const g=optG(o,l),c=optCost(o);if(g&&(!b||c/gls.reduce((s,l)=>s+(l.kind==='vxc'?VXC[l.vt].g:l.kind==='df'?(l.ch||[]).reduce((t,o)=>t+optG(o,l),0):LT[l.tier].g),0);
+const swapOpt=(k,up,omo,days,mo)=>{const save=mo-omo;return {k,up,omo,days,save,pay:save>0?Math.ceil(up/save):0};};
+function leaseSwaps(){const by={};
+ for(const l of S.links){if(l.kind==='df'&&l.own||!S.pops[l.a]||!S.pops[l.b])continue;const k=[l.a,l.b].sort().join('|');(by[k]=by[k]||[]).push(l);}
+ return Object.entries(by).map(([k,ls])=>{const [a,b]=k.split('|'),sub=isSub(a,b),mo=ls.reduce((s,l)=>s+(l.mo||0),0),cap=leaseCap(ls);
+ const x={a,b,sub,ls,mo,cap,opts:[],own:pairLinks(a,b).find(l=>l.kind==='df'&&l.own)};if(x.own){x.best=mo;return x;}
+ // Waves and fabric circuits can also move onto a leased fiber pair: cheaper glass, but you buy the gear.
+ const ws=ls.filter(l=>l.kind!=='df'),wmo=ws.reduce((s,l)=>s+(l.mo||0),0),sc=sub?subDfCable(a,b):null;x.iru=ls.find(l=>l.kind==='df');
+ if(ws.length&&x.iru)x.lit=wmo;
+ else if(ws.length&&lvl()>=2&&(sub?sc:dfAllowed(a,b))){const km=sc?sc.km:kmBetween(a,b),sys=lvl()>=3?'roadm':'lite',wc=leaseCap(ws),op=swapOptics(km,wc,sub,sys);
+ if(op&&op.n<=DF_SYS[sys].max)x.opts.push(swapOpt('iru',DF_SYS[sys].cost+ampCount(km)*AMP_COST+op.up,dfLeaseMo(km)+ampCount(km)*AMP_MO+op.mo,30,wmo));}
+ // Dig on land, lay a cable between landing stations (even ones that share a landmass), or both.
+ const whys=[];for(const cab of [false,true]){if(cab?!seaCab(a,b):sub)continue;
+ const why=cab?ownCabWhy(a,b):!dfAllowed(a,b)?tr('Nobody lets you dig on this route. Borders and licences are in the way, so keep leasing.'):lvl()<3?tr('Digging your own fiber unlocks at customer level 3.'):'';
+ if(why){whys.push(why);continue;}const km=cab?ownCabKm(a,b):kmBetween(a,b),op=swapOptics(km,cap,cab,'roadm');
+ if(!op){whys.push(tr('No optic you can buy reaches {km} km yet.',{km:km.toLocaleString()}));continue;}
+ x.opts.push(swapOpt(cab?'cab':'own',(cab?ownCabCost(km):dfBuildCost(km)+DF_SYS.roadm.cost+ampCount(km)*AMP_COST)+op.up,(cab?ownCabMo(km):Math.round(km*0.15)+ampCount(km)*AMP_MO)+op.mo,cab?ownCabDays(km):dfBuildDays(km),mo));}
+ x.why=x.opts.some(o=>o.k!=='iru')?'':whys.join(' ');
+ const sv=[...x.opts.map(o=>o.save),x.lit].filter(v=>v!==undefined);if(sv.length)x.best=Math.max(...sv);return x;})
+ .sort((p,q)=>((p.best===undefined)-(q.best===undefined))||(q.best||0)-(p.best||0)||q.mo-p.mo);}
+function leaseTab(){const xs=leaseSwaps(),tot=xs.reduce((s,x)=>s+x.mo,0);
+ const kind=l=>l.kind==='vxc'?tr('{cap} fabric circuit',{cap:capName(l)}):l.kind==='df'?tr('{cap} on a dark fiber IRU',{cap:capName(l)}):tr('{cap} wave',{cap:capName(l)});
+ const line=(x,o)=>{const a={up:fmt$(o.up),mo:fmt$(o.omo),n:o.days};return `
${o.k==='iru'?tr('Lease dark fiber: {up} up front, {mo}/mo, ready in about {n} days.',a):o.k==='cab'?tr('Your own cable: {up} up front, {mo}/mo, about {n} days to build.',a):tr('Your own fiber: {up} up front, {mo}/mo, about {n} days to build.',a)} ${o.save>0?tr('Saves {price}/mo, pays for itself in about {n} months.',{price:fmt$(o.save),n:o.pay}):tr('Costs more than leasing at this size.')}
`;};
+ const plan=(x,o)=>btn(o.k==='iru'?tr('Plan dark fiber'):o.k==='cab'?tr('Plan a cable'):tr('Plan your own fiber'),'leaseSwap',{a:x.a,b:x.b,src:o.k==='iru'?'lease':o.k==='cab'?'cable':'build'},o.save>0&&o.save===x.best?'pink sm':'ghost sm');
+ return `
${tr('Leased lines')}
${tr('Every wave, fabric circuit and dark fiber IRU you rent between two of your POPs, next to what leased dark fiber or your own fiber would cost. Estimates include the line system, amplifiers and enough optics for today’s capacity. Build first, move the traffic, then cancel the lease.')}
+ ${xs.length?`
${tr('You pay for leases')}${tr('{price}/mo',{price:fmt$(tot)})}
${x.own?btn(tr('Open your fiber'),'dashLink',{id:x.own.id},'pink sm'):''}${x.lit!==undefined?btn(tr('Open your dark fiber'),'dashLink',{id:x.iru.id},'pink sm'):''}${x.opts.map(o=>plan(x,o)).join('')}${btn(tr('Open lease'),'dashLink',{id:(x.ls.find(l=>l.kind!=='df')||x.ls[0]).id},'ghost sm')}
`).join(''):`
${tr('You do not lease any lines between your POPs.')}
`}
`;}
+function dashTabs(){const u=custStats().unhappy,cur=UI.dtab||'overview',L={overview:tr('Overview'),cust:tr('Customers'),conn:tr('Connections'),traffic:tr('Traffic'),infra:tr('Links & routers'),lease:tr('Leased lines')};
return ``;}
function renderDash(){checkLayer();
const H=S.hist||[],rows=H.slice(-90),last30=H.slice(-30);
@@ -3337,6 +3390,7 @@ function renderDash(){checkLayer();
if(DT==='infra')h+=`
${tr('Busiest links')}
${ls.length?ls.map(({l,u})=>`
${CITY[l.a].name} ⇄ ${CITY[l.b].name} ${capName(l)} · ${linkLat(l).toFixed(1)} ms
`;
+ if(DT==='lease')h+=leaseTab();
if(h!==UI._dh){UI._dh=h;$('dashCard').innerHTML=h;}
}
function loanSummary(o){return o.model==='transit'?tr('You pay {pct} of your transit bill until {price} is repaid.',{pct:pct(o.cut||0.3),price:fmt$(o.owe||o.amount)}):o.model==='balloon'?tr('Nothing to pay for {n} months. Then everything.',{n:o.term}):tr('{pay}/mo for {n} months.',{pay:fmt$(o.pay),n:o.term})+(o.share?' '+tr('Plus {pct} of your revenue until it is repaid.',{pct:pct(o.share)}):'');}
diff --git a/tests/issues.test.js b/tests/issues.test.js
index 91543e2..96a8209 100644
--- a/tests/issues.test.js
+++ b/tests/issues.test.js
@@ -670,3 +670,102 @@ test('deal navigation visits the first missing POP, including second endpoints a
ev("S.offers[0].type='l2vpn';delete S.offers[0].sites;S.offers[0].city='bde';renderLeft()");assert.equal(JSON.parse(go().dataset.args).city,'bde','single-site offers still work');
assert.deepEqual(errors,[]);
});
+
+test('NOC leased lines tab prices leased dark fiber, own fiber and cables against the leases', () => {
+ const { ev, errors } = load();
+ base(ev);
+ ev("S.cash=1e9;S.lvl=3;for(const c of ['ams','lon','nyc','par'])ACT.buildPop({city:c});for(const c in S.pops)S.pops[c].rgen=2;const L=(a,b,t)=>{UI.via=null;openLinkModal(a,b);ACT.buildLink({tier:t});closeModal();};L('fra','ams',2);L('fra','ams',2);L('lon','nyc',1);L('fra','par',1);compute()");
+ ev("ACT.dash();ACT.dashTab({k:'lease'})");
+ let t = ev("document.getElementById('dashCard').textContent");
+ assert.match(t, /Leased lines/);
+ assert.match(t, /Amsterdam ⇄ Frankfurt/);
+ assert.match(t, /Lease dark fiber: .* up front/);
+ assert.match(t, /Your own fiber: .* up front/);
+ assert.match(t, /Go transit-free first/, 'own subsea cables stay Tier 1 only');
+ const land = JSON.parse(ev("JSON.stringify(leaseSwaps().find(x=>x.a==='ams'))"));
+ assert.equal(land.ls.length, 2, 'parallel waves on one route are grouped');
+ assert.equal(land.cap, 800);
+ const iru = land.opts.find(o => o.k === 'iru'), own = land.opts.find(o => o.k === 'own');
+ assert.equal(iru.days, 30);
+ assert.equal(iru.save, land.mo - iru.omo);
+ assert.ok(iru.save > 0 && iru.pay > 0, 'two 400G waves are worth moving onto dark fiber');
+ assert.ok(iru.up < own.up, 'leased glass costs less up front than digging');
+ assert.ok(own.up > ev("dfBuildCost(kmBetween('ams','fra'))"), 'optics and line system are in the estimate');
+ assert.equal(land.best, Math.max(iru.save, own.save));
+ ev("S.won=true");
+ assert.match(ev("leaseSwaps().find(x=>x.sub).why"), /No optic you can buy reaches/, "Tier 1 alone is not enough without long-haul optics");
+ ev("S.lvl=4;renderDash()");
+ const sub = JSON.parse(ev("JSON.stringify(leaseSwaps().find(x=>x.sub))"));
+ assert.equal(sub.why, '');
+ assert.ok(sub.opts.find(o => o.k === 'cab').up > ev("ownCabCost(ownCabKm('lon','nyc'))"));
+ ev("for(const c of ['mrs','sin'])ACT.buildPop({city:c});for(const c in S.pops)S.pops[c].rgen=2;UI.via=null;openLinkModal('mrs','sin');ACT.buildLink({tier:2});closeModal();compute()");
+ const ms = JSON.parse(ev("JSON.stringify(leaseSwaps().find(x=>x.a==='mrs'&&x.b==='sin'))"));
+ assert.ok(ms && ms.opts.some(o => o.k === 'cab'), 'landing stations on one landmass can swap a wave for your own cable (#67)');
+ ev("ACT.leaseSwap({a:'ams',b:'fra',src:'lease'})");
+ assert.equal(ev("document.getElementById('dash').hidden"), true);
+ assert.match(ev("document.getElementById('modal').textContent"), /Sign the IRU/);
+ ev("closeModal();ACT.leaseSwap({a:'ams',b:'fra',src:'build'})");
+ assert.match(ev("document.getElementById('modal').textContent"), /Start construction/);
+ ev("closeModal();S.links.push({id:'iru1',a:'fra',b:'par',kind:'df',km:480,sys:'roadm',ch:[],ready:0,mo:900,day:0,cut:0});S.links.push({id:'own1',a:'fra',b:'ams',kind:'df',own:true,km:400,sys:'roadm',ch:[],ready:0,mo:60,day:0,cut:0});ACT.dash();ACT.dashTab({k:'lease'})");
+ t = ev("document.getElementById('dashCard').textContent");
+ assert.match(t, /You already own fiber here/);
+ assert.match(t, /You already lease dark fiber here/);
+ const par = JSON.parse(ev("JSON.stringify(leaseSwaps().find(x=>x.b==='par'))"));
+ assert.ok(!par.opts.some(o => o.k === 'iru'), 'no second IRU offered next to the one you lease');
+ assert.ok(!ev("leaseSwaps().some(x=>x.ls.some(l=>l.own))"), 'your own fiber is never listed as a lease');
+ assert.deepEqual(errors, []);
+});
+
+test('connections in the NOC dashboard can be cancelled right there, after a confirm', () => {
+ const { ev, errors } = load();
+ base(ev);
+ ev("ACT.buildPop({city:'ams'});ACT.buyTransit({city:'fra',net:'cog',tier:1});ACT.buyIx({city:'ams',tier:1});S.pni.push({id:'pn1',city:'fra',net:'nfx',tier:1});S.caches.push({id:'cc1',city:'fra',net:'ggl'},{id:'cc2',city:'fra',net:'ggl'});S.nni.push({city:'fra',prov:'mgp',tier:0});compute();ACT.connOpen()");
+ const card = () => ev("document.getElementById('dashCard').textContent");
+ const click = (k, id) => ev(`ACT.connCancel(${JSON.stringify({ k, id })})`);
+ assert.equal(ev("conns().length"), 5);
+ const tid = ev("S.transit[0].id");
+ click('t', tid);
+ assert.match(card(), /Really cancel\?/, 'first tap only asks');
+ assert.equal(ev("S.transit.length"), 1);
+ click('t', tid);
+ assert.equal(ev("S.transit.length"), 0);
+ assert.doesNotMatch(card(), /Really cancel\?/, 'the list refreshes in place');
+ click('p', 'pn1'); click('p', 'pn1');
+ assert.equal(ev("S.pni.length"), 0);
+ click('ix', 'ams');
+ assert.match(card(), /Really leave\?/);
+ click('ix', 'ams');
+ assert.equal(ev("S.ixp.ams"), undefined);
+ click('c', 'cc1'); click('c', 'cc1');
+ assert.equal(ev("S.caches.length"), 1, 'caches go one box at a time');
+ click('nni', 'fra|mgp'); click('nni', 'fra|mgp');
+ assert.equal(ev("S.nni.length"), 0);
+ ev("S.myIx.fra={name:'Test-IX',members:[],next:S.day+4};S.ixp.fra=2;compute();renderDash()");
+ click('ix', 'fra'); click('ix', 'fra');
+ assert.equal(ev("S.ixp.fra"), 2, 'your own exchange cannot be cancelled from the list');
+ assert.equal(ev("document.getElementById('dash').hidden"), false);
+ assert.deepEqual(errors, []);
+});
+
+test('connections in the NOC dashboard can be upgraded and grown into LAGs right there', () => {
+ const { ev, errors } = load();
+ base(ev);
+ ev("ACT.buildPop({city:'ams'});for(const c in S.pops)S.pops[c].rgen=2;ACT.buyTransit({city:'fra',net:'cog',tier:1});ACT.buyIx({city:'ams',tier:1});S.pni.push({id:'pn1',city:'fra',net:'nfx',tier:1});S.nni.push({city:'fra',prov:'mgp',tier:0});compute();ACT.connOpen()");
+ const tap = act => ev(`(()=>{const b=document.querySelector('#dashCard [data-act="${act}"]');if(!b||b.disabled)return false;b.click();return true;})()`);
+ assert.ok(tap('lagT'), 'transit row offers a LAG member');
+ assert.equal(ev("S.transit[0].n"), 2);
+ assert.match(ev("document.getElementById('dashCard').textContent"), /Upgrade all to 400G/, 'the list refreshes with the LAG');
+ assert.ok(tap('buyTransit'));
+ assert.equal(ev("S.transit[0].tier"), 2);
+ assert.ok(tap('lagP'));
+ assert.equal(ev("S.pni[0].n"), 2);
+ assert.ok(tap('lagIx'));
+ assert.equal(ev("S.ixn.ams"), 2);
+ assert.ok(tap('buyIx'));
+ assert.equal(ev("S.ixp.ams"), 2);
+ assert.ok(tap('buyNni'));
+ assert.equal(ev("S.nni[0].tier"), 1);
+ assert.equal(ev("document.querySelector('#dashCard [data-act=\"buyNni\"]')"), null, 'no upgrade past the biggest fabric port');
+ assert.equal(ev("document.getElementById('dash').hidden"), false);
+ assert.deepEqual(errors, []);
+});