The curve that dodges other cities wanted 24 map units of clearance and picked the most distant of up to 3.8x curves when nothing cleared, so short links in dense regions looped wide. Clearance now scales with link length, offsets are capped at about a third of it, and a modest curve wins over a giant one when nothing clears.
4096 lines
701 KiB
HTML
4096 lines
701 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||
<title>Series of Tubes — Build the Internet, One Tube at a Time</title>
|
||
<meta name="description" content="A free cartoon browser game about building the internet. Lay fiber and subsea cables, buy transit, peer at internet exchanges, host CDN caches and survive backhoes, sharks and BGP leaks on your way to Tier 1.">
|
||
<meta name="keywords" content="internet game, network simulation, BGP, peering, internet exchange, IXP, transit, CDN, subsea cables, dark fiber, browser game, Tier 1">
|
||
<meta name="author" content="Frederic Jung">
|
||
<meta name="robots" content="index, follow, max-image-preview:large">
|
||
<meta name="theme-color" content="#57C4E5">
|
||
<meta name="color-scheme" content="light">
|
||
<meta name="application-name" content="Series of Tubes">
|
||
<meta name="apple-mobile-web-app-title" content="Series of Tubes">
|
||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||
<meta name="mobile-web-app-capable" content="yes">
|
||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||
<meta name="format-detection" content="telephone=no">
|
||
<meta name="mobile-web-app-capable" content="yes">
|
||
<meta name="format-detection" content="telephone=no">
|
||
<meta name="generator" content="Series of Tubes __VERSION__">
|
||
<link rel="canonical" href="https://seriesoftub.es/">
|
||
|
||
<!-- Open Graph -->
|
||
<meta property="og:type" content="website">
|
||
<meta property="og:site_name" content="Series of Tubes">
|
||
<meta property="og:title" content="Series of Tubes — Build the Internet, One Tube at a Time">
|
||
<meta property="og:description" content="Lay fiber, buy transit, peer at IXs and keep the eyeballs happy while backhoes, sharks and route leaks try to stop you. A free cartoon game about how the internet really works.">
|
||
<meta property="og:url" content="https://seriesoftub.es/">
|
||
<meta property="og:locale" content="en_US">
|
||
<meta property="og:image" content="https://seriesoftub.es/images/og-image.png">
|
||
<meta property="og:image:type" content="image/png">
|
||
<meta property="og:image:width" content="1200">
|
||
<meta property="og:image:height" content="630">
|
||
<meta property="og:image:alt" content="Series of Tubes: a cartoon world map with fiber links, subsea cables and routers">
|
||
|
||
<!-- Twitter / X -->
|
||
<meta name="twitter:card" content="summary_large_image">
|
||
<meta name="twitter:title" content="Series of Tubes — Build the Internet, One Tube at a Time">
|
||
<meta name="twitter:description" content="A free cartoon game about building the internet: fiber, transit, peering, CDNs, and a lot of backhoes.">
|
||
<meta name="twitter:image" content="https://seriesoftub.es/images/og-image.png">
|
||
<meta name="twitter:image:alt" content="Series of Tubes: a cartoon world map with fiber links, subsea cables and routers">
|
||
|
||
<!-- Icons -->
|
||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||
<link rel="icon" type="image/x-icon" href="/favicon.ico" sizes="32x32 16x16">
|
||
<link rel="icon" type="image/png" sizes="192x192" href="/icon-192.png">
|
||
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||
<link rel="manifest" href="/site.webmanifest">
|
||
|
||
<!-- Fonts -->
|
||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
|
||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Nunito:wght@500;700;800;900&display=swap">
|
||
|
||
<!-- Structured data -->
|
||
<script type="application/ld+json">
|
||
{
|
||
"@context": "https://schema.org",
|
||
"@type": "WebSite",
|
||
"name": "Series of Tubes",
|
||
"url": "https://seriesoftub.es/",
|
||
"description": "A free cartoon browser game about building the internet."
|
||
}
|
||
</script>
|
||
<script type="application/ld+json">
|
||
{
|
||
"@context": "https://schema.org",
|
||
"@type": "VideoGame",
|
||
"name": "Series of Tubes",
|
||
"url": "https://seriesoftub.es/",
|
||
"image": "https://seriesoftub.es/images/og-image.png",
|
||
"description": "Build an internet: lay terrestrial and subsea fiber, buy IP transit, peer at internet exchanges, set up PNIs and CDN caches, sign business customers and survive constant failures on your way to becoming a Tier 1 network.",
|
||
"genre": ["Simulation", "Strategy", "Tycoon"],
|
||
"gamePlatform": "Web browser",
|
||
"applicationCategory": "Game",
|
||
"operatingSystem": "Any",
|
||
"playMode": "SinglePlayer",
|
||
"inLanguage": "en",
|
||
"isAccessibleForFree": true,
|
||
"softwareVersion": "__VERSION__",
|
||
"dateModified": "__BUILD_DATE__",
|
||
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" },
|
||
"author": { "@type": "Person", "name": "Frederic Jung", "url": "https://github.com/fjaeckel" }
|
||
}
|
||
</script>
|
||
<style>
|
||
/* Layout: full-bleed cartoon world map on canvas; sticker-style panels float above it (HUD top, goals left, inspector right / bottom sheet on phones). Single committed bright look. */
|
||
:root{
|
||
--sea:#57C4E5; --sea2:#3AA6CF; --wave:#9BE2F2; --land:#9BDA6C; --land2:#7FC455; --sand:#F8E6A8;
|
||
--ink:#1E2640; --ink2:#55608A; --paper:#FFFFFF; --soft:#EEF5FB; --line:#D5DEEC;
|
||
--me:#FF4F9A; --sun:#FFD23F; --ok:#22C47A; --warn:#FFAA1F; --bad:#FF4D5E;
|
||
--t1:#7B61FF; --t2:#2F8CFF; --cdn:#FF8A3D; --eye:#16A866;
|
||
--display:'Baloo 2','Trebuchet MS',system-ui,sans-serif;
|
||
--body:'Nunito',system-ui,-apple-system,sans-serif;
|
||
color-scheme:light;
|
||
}
|
||
[hidden]{display:none!important}
|
||
html,body{height:100%}
|
||
body{margin:0}
|
||
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
|
||
.ver{font-size:11.5px;color:var(--ink2);margin-top:10px}
|
||
.ver a{color:inherit}
|
||
body{background:var(--sea);color:var(--ink);font-family:var(--body);overflow:hidden;font-size:14px;-webkit-font-smoothing:antialiased}
|
||
#map{position:fixed;inset:0;width:100%;height:100%;touch-action:none;display:block;cursor:grab}
|
||
#map.linking{cursor:crosshair}
|
||
.num{font-variant-numeric:tabular-nums}
|
||
h2,h3,h4{font-family:var(--display);margin:0;text-wrap:balance;line-height:1.1}
|
||
button{font:inherit;color:inherit}
|
||
:focus-visible{outline:3px solid var(--me);outline-offset:2px}
|
||
|
||
/* sticker surfaces */
|
||
.card{background:var(--paper);border:3px solid var(--ink);border-radius:18px;box-shadow:4px 4px 0 var(--ink)}
|
||
|
||
/* HUD */
|
||
#hud{position:fixed;top:calc(env(safe-area-inset-top,0px) + 10px);left:max(12px,env(safe-area-inset-left,0px));right:max(12px,env(safe-area-inset-right,0px));display:flex;gap:8px;align-items:stretch;flex-wrap:wrap;pointer-events:none;z-index:5}
|
||
#hud>*{pointer-events:auto}
|
||
.chip{background:var(--paper);border:3px solid var(--ink);border-radius:14px;box-shadow:3px 3px 0 var(--ink);padding:3px 11px;display:flex;flex-direction:column;justify-content:center;min-height:46px}
|
||
.chip .lbl{font-size:10px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:var(--ink2)}
|
||
.chip .val{font-family:var(--display);font-weight:800;font-size:19px;line-height:1.05;white-space:nowrap}
|
||
.chip .sub{font-size:11px;font-weight:800;white-space:nowrap}
|
||
.brand{flex-direction:row;align-items:center;gap:9px;background:var(--me);color:#fff}
|
||
.brand .val{font-size:20px}
|
||
.brand .lbl{color:#FFE0EE}
|
||
.tube{width:30px;height:30px;flex:none}
|
||
.up{color:var(--ok)} .down{color:var(--bad)}
|
||
.speed{flex-direction:row;align-items:center;gap:4px;padding:4px 6px}
|
||
.speed button{border:2.5px solid var(--ink);background:var(--paper);border-radius:9px;min-width:34px;height:32px;font-family:var(--display);font-weight:800;cursor:pointer;font-size:13px}
|
||
.speed button.on{background:var(--sun)}
|
||
.spacer{flex:1}
|
||
.noc{cursor:pointer;border:3px solid var(--ink)}
|
||
.hotk{display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:24px;padding:0 4px;border-radius:12px;border:2px solid var(--ink,#1E2640);font:900 11px Nunito,sans-serif;margin-right:8px;color:#fff;background:#FF4D5E}
|
||
.hotk.hk-ix{color:#1E2640;background:#FFD23F}
|
||
.noc.hot{background:var(--bad);color:#fff;animation:throb 1s ease-in-out infinite}
|
||
.noc.hot .lbl{color:#FFE1E4}
|
||
#hCust .cnt{display:inline-block;min-width:18px;padding:0 5px;border-radius:9px;background:var(--bad);color:#fff;font-size:11px;line-height:18px;text-align:center;vertical-align:3px;margin-left:2px}
|
||
#hCust.hot{background:#FFE1E4}
|
||
@keyframes throb{50%{transform:scale(1.05)}}
|
||
.minibar{height:6px;border-radius:4px;background:var(--line);overflow:hidden;margin-top:2px;width:100%}
|
||
.minibar i{display:block;height:100%;background:var(--ok)}
|
||
|
||
/* drawers */
|
||
#left{position:fixed;top:calc(env(safe-area-inset-top,0px) + 76px);left:max(12px,env(safe-area-inset-left,0px));width:300px;max-height:calc(100% - 96px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;z-index:4}
|
||
#panel{position:fixed;top:calc(env(safe-area-inset-top,0px) + 76px);right:max(12px,env(safe-area-inset-right,0px));width:370px;max-height:calc(100% - 96px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;z-index:4}
|
||
.scroll{overflow:auto;padding:12px 14px 14px;overscroll-behavior:contain}
|
||
.tabs{display:flex;gap:4px;padding:8px 8px 0;border-bottom:3px solid var(--ink);flex:none}
|
||
.tabs button{border:2.5px solid var(--ink);border-bottom:none;border-radius:11px 11px 0 0;background:var(--soft);padding:4px 10px 3px;font-family:var(--display);font-weight:800;cursor:pointer;font-size:13.5px;position:relative;top:3px}
|
||
.tabs button.on{background:var(--paper);padding-bottom:6px}
|
||
.tabs .cnt{display:inline-block;background:var(--me);color:#fff;border-radius:9px;padding:0 6px;font-size:11px;margin-left:4px}
|
||
.tabs .cnt.red{background:var(--bad)}
|
||
#leftToggle{display:none}
|
||
|
||
.ph{display:flex;align-items:flex-start;gap:8px;padding:12px 14px 8px;border-bottom:3px solid var(--ink);flex:none}
|
||
.ph h2{font-size:26px}
|
||
.eyebrow{font-size:10.5px;font-weight:900;letter-spacing:.09em;text-transform:uppercase;color:var(--ink2)}
|
||
.x{margin-left:auto;border:2.5px solid var(--ink);background:var(--paper);border-radius:10px;width:32px;height:32px;font-size:20px;line-height:1;cursor:pointer;font-weight:900;flex:none}
|
||
.facts{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
|
||
.fact{background:var(--soft);border:2px solid var(--ink);border-radius:9px;padding:1px 8px;font-size:12px;font-weight:700}
|
||
.fact.ixf{background:#FFF3C4}
|
||
.fact.mine{background:var(--me);color:#fff}
|
||
.fact.down{background:var(--bad);color:#fff}
|
||
section{padding:10px 0;border-bottom:2px dashed var(--line)}
|
||
section:last-child{border-bottom:none}
|
||
section h3{font-size:17px;margin-bottom:6px;display:flex;align-items:center;gap:8px}
|
||
.lead{margin:0 0 8px;color:var(--ink2);font-size:12.5px;line-height:1.45}
|
||
.note{margin:6px 0 0;color:var(--ink2);font-size:12.5px;line-height:1.4}
|
||
.kv{display:flex;justify-content:space-between;gap:8px;font-size:13px;margin:3px 0}
|
||
.kv b{font-variant-numeric:tabular-nums}
|
||
.row{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--line)}
|
||
.row:first-of-type{border-top:none}
|
||
.row .grow{flex:1;min-width:0}
|
||
.row .nm{font-weight:800;font-size:13.5px;line-height:1.2}
|
||
.row .meta{font-size:11.5px;color:var(--ink2);line-height:1.3}
|
||
.btns{display:flex;flex-wrap:wrap;gap:5px;margin-top:5px}
|
||
.why{font-size:11px;color:#B23A48;font-weight:700;margin-top:3px;line-height:1.3}
|
||
|
||
.b{font-family:var(--display);font-weight:800;border:2.5px solid var(--ink);border-radius:11px;background:var(--sun);box-shadow:0 3px 0 var(--ink);padding:4px 11px 3px;cursor:pointer;font-size:14px;line-height:1.2;white-space:nowrap;transition:transform .06s}
|
||
.b:hover{filter:brightness(1.05)}
|
||
.b:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
|
||
.b:disabled{opacity:.42;cursor:not-allowed;transform:none;box-shadow:0 3px 0 var(--ink)}
|
||
.b.ghost{background:var(--paper)}
|
||
.b.pink{background:var(--me);color:#fff}
|
||
.b.red{background:var(--bad);color:#fff}
|
||
.b.green{background:var(--ok);color:#fff}
|
||
.b.sm{font-size:12px;padding:2px 8px 1px;border-radius:9px;box-shadow:0 2px 0 var(--ink)}
|
||
.b.big{font-size:18px;padding:7px 18px 5px}
|
||
.b small{font-family:var(--body);font-weight:800;font-size:10.5px;opacity:.85;margin-left:3px}
|
||
|
||
.logo{width:30px;height:30px;border-radius:50%;background:var(--c);border:2.5px solid var(--ink);display:grid;place-items:center;color:#fff;font-family:var(--display);font-weight:800;font-size:11px;flex:none;letter-spacing:-.02em}
|
||
.tag{display:inline-block;border:1.8px solid var(--ink);border-radius:7px;padding:0 5px;font-size:10px;font-weight:900;letter-spacing:.03em;text-transform:uppercase;vertical-align:1px;color:#fff;background:var(--ink2)}
|
||
.tag.t1{background:var(--t1)} .tag.t2{background:var(--t2)} .tag.cdn{background:var(--cdn)} .tag.eye{background:var(--eye)}
|
||
.tag.open{background:var(--ok)} .tag.selective{background:var(--warn);color:var(--ink)} .tag.restrictive{background:var(--bad)} .tag.paid{background:var(--me)}
|
||
.tag.st{background:var(--paper);color:var(--ink)}
|
||
.tag.st.on{background:var(--ink);color:#fff}
|
||
.bar{height:11px;border:2px solid var(--ink);border-radius:7px;background:var(--paper);overflow:hidden;margin:3px 0}
|
||
.stack{display:flex;height:16px;border:2px solid var(--ink);border-radius:8px;overflow:hidden;margin:4px 0 6px;background:var(--paper)}
|
||
.stack i{display:block;height:100%}
|
||
.sub4{font-size:13.5px;margin:10px 0 3px}
|
||
.dot{display:inline-block;width:10px;height:10px;border-radius:50%;border:1.5px solid var(--ink);margin-right:6px;vertical-align:-1px}
|
||
.bar>i{display:block;height:100%;background:var(--ok);transition:width .3s}
|
||
.bar.warn>i{background:var(--warn)} .bar.bad>i{background:var(--bad)} .bar.me>i{background:var(--me)}
|
||
|
||
.goal{display:flex;gap:9px;padding:8px 0;border-top:1px solid var(--line)}
|
||
.goal:first-child{border-top:none}
|
||
.goal .ck{width:22px;height:22px;border:2.5px solid var(--ink);border-radius:7px;flex:none;display:grid;place-items:center;font-weight:900;background:var(--paper);font-size:13px}
|
||
.goal.done .ck{background:var(--ok);color:#fff}
|
||
.goal.done .gt{text-decoration:line-through;color:var(--ink2)}
|
||
.goal.cur{background:#FFF6CF;margin:0 -14px;padding:9px 14px;border-top:2px solid var(--ink);border-bottom:2px solid var(--ink)}
|
||
.goal .gt{font-weight:900;font-size:13.5px}
|
||
.goal .gd{font-size:12px;color:var(--ink2);line-height:1.4;margin-top:2px}
|
||
.goal .gr{font-size:11px;font-weight:900;color:var(--eye);margin-top:2px}
|
||
.empty{color:var(--ink2);font-size:12.5px;line-height:1.45;padding:6px 0}
|
||
.inc{border:2.5px solid var(--ink);border-radius:12px;padding:8px 10px;margin-bottom:8px;background:#FFF0F1}
|
||
.inc .nm{font-weight:900}
|
||
.inc .meta{font-size:12px;color:var(--ink2);margin-top:2px;line-height:1.35}
|
||
|
||
/* toasts */
|
||
#toasts{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(env(safe-area-inset-bottom,0px) + 14px);display:flex;flex-direction:column-reverse;gap:8px;z-index:8;width:min(460px,calc(100% - 32px));pointer-events:none}
|
||
.toast{pointer-events:none;background:var(--paper);border:3px solid var(--ink);border-radius:14px;box-shadow:3px 3px 0 var(--ink);padding:9px 12px;display:flex;gap:10px;align-items:center;animation:pop .25s cubic-bezier(.3,1.6,.6,1)}
|
||
.toast.good{background:#DFFBEA} .toast.bad{background:#FFE1E4} .toast.goal{background:#FFF3C4}
|
||
.toast .b{pointer-events:auto}
|
||
.seg{display:flex;flex-wrap:wrap;gap:6px}
|
||
.seg .b{white-space:normal;text-align:left}
|
||
.toast .tx{flex:1;font-size:13px;line-height:1.35}
|
||
.toast .tx b{font-family:var(--display);font-size:14.5px}
|
||
@keyframes pop{from{transform:scale(.8) translateY(10px);opacity:0}}
|
||
|
||
#hint{position:fixed;left:50%;transform:translateX(-50%);top:calc(env(safe-area-inset-top,0px) + 76px);background:var(--ink);color:#fff;border-radius:12px;padding:6px 12px;font-weight:800;font-size:12.5px;z-index:3;pointer-events:none;max-width:min(440px,calc(100% - 32px));text-align:center;box-shadow:3px 3px 0 rgba(30,38,64,.25)}
|
||
|
||
/* modal */
|
||
.seg.site{margin-top:4px;align-items:center}
|
||
.seg.site .meta{margin-right:4px}
|
||
.badges{display:grid;grid-template-columns:repeat(auto-fill,minmax(118px,1fr));gap:6px}
|
||
.bdg{border:2px solid #C9CEDD;border-radius:12px;padding:6px 7px;background:#F3F4F8;opacity:.6;display:flex;flex-direction:column;gap:1px;min-width:0}
|
||
.bdg .bi{font-size:20px;filter:grayscale(1)}
|
||
.bdg .bt{font:800 12.5px/1.2 "Baloo 2",sans-serif;color:var(--ink)}
|
||
.bdg .br{font:900 10px Nunito,sans-serif;color:var(--rc);text-transform:uppercase;letter-spacing:.04em}
|
||
.bdg .bd{font-size:11px;color:#5A6280;line-height:1.25}
|
||
.bdg.ever{opacity:.85;border-style:dashed;border-color:var(--rc)}
|
||
.bdg.on{opacity:1;border-color:var(--rc);background:#fff;box-shadow:0 2px 0 var(--rc)}
|
||
.bdg.on .bi,.bdg.ever .bi{filter:none}
|
||
.scn{display:flex;gap:10px;align-items:center;border:2px solid #DDE1EC;border-radius:12px;padding:8px 10px;margin-top:8px}
|
||
.scn.wk{border-color:var(--me);background:#FFF0F6}
|
||
.scn .nm{font-weight:900}
|
||
.term{background:#1E2640;color:#7CFFB2;font:600 12px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;padding:10px 12px;border-radius:10px;overflow-x:auto;white-space:pre;margin:8px 0}
|
||
.trsel{display:flex;flex-wrap:wrap;gap:8px;align-items:flex-end;margin-top:8px}
|
||
.trsel label{display:flex;flex-direction:column;font:800 12px Nunito,sans-serif;gap:2px}
|
||
.trsel select{font:700 14px Nunito,sans-serif;padding:4px 6px;border:2px solid var(--ink);border-radius:8px;max-width:240px}
|
||
.fact.trb{cursor:pointer;font:inherit;border:2px solid var(--ink);background:#fff}
|
||
#coach{position:fixed;left:50%;transform:translateX(-50%);top:calc(env(safe-area-inset-top,0px) + 74px);z-index:16;width:min(520px,calc(100% - 24px));background:#fff;border:3px solid var(--ink);border-radius:14px;box-shadow:0 4px 0 var(--ink);padding:8px 10px;display:flex;gap:8px;align-items:center}
|
||
#coach .ct{flex:1;font-weight:800;font-size:14px;line-height:1.35}
|
||
#coach .cs{display:block;font:900 10px Nunito,sans-serif;color:var(--me);text-transform:uppercase;letter-spacing:.05em}
|
||
.coach-glow{animation:coachglow 1s ease-in-out infinite;position:relative;z-index:2}
|
||
@keyframes coachglow{0%,100%{box-shadow:0 0 0 0 rgba(255,79,154,.9)}50%{box-shadow:0 0 0 6px rgba(255,79,154,.35)}}
|
||
@media (prefers-reduced-motion:reduce){:root:not(.anim-force) .coach-glow{animation:none;outline:3px solid #FF4F9A}}
|
||
:root.no-anim .coach-glow{outline:3px solid #FF4F9A}
|
||
.setline{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:4px 0}
|
||
.setline>span{font-weight:800}
|
||
.thb{font:inherit;font-weight:900;background:none;border:0;padding:0;cursor:pointer;color:inherit}
|
||
.ttop{margin:4px 0;padding:4px 8px;border-left:3px solid #FF8A3D;background:#FFF6EC;border-radius:6px}
|
||
.tecode{width:100%;box-sizing:border-box;font:600 13px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:#1E2640;color:#E6F0FF;border:3px solid var(--ink);border-radius:10px;padding:10px;margin-top:8px;resize:vertical;tab-size:2}
|
||
.term.err{color:#FF9AA5}
|
||
.menu-list{display:flex;flex-direction:column;gap:8px;margin-top:12px}
|
||
.menu-list .b{justify-content:space-between;width:100%}
|
||
#mega{position:fixed;left:0;right:0;bottom:0;z-index:17;background:#7A86B8;border-top:3px solid var(--ink);overflow:hidden;white-space:nowrap;pointer-events:none;animation:megaflash 1.2s steps(2) infinite}
|
||
#mega .mtrack{display:inline-block;padding:7px 0;animation:megascroll 40s linear infinite;font:900 16px "Baloo 2",sans-serif;color:#fff;text-shadow:0 2px 0 var(--ink)}
|
||
#mega span{margin:0 28px}
|
||
#mega span::after{content:"🐘";margin-left:56px}
|
||
@keyframes megascroll{from{transform:translateX(0)}to{transform:translateX(-50%)}}
|
||
@keyframes megaflash{0%{background:#7A86B8}50%{background:#FF4D5E}}
|
||
@media (prefers-reduced-motion:reduce){#mega,#mega .mtrack{animation:none}}
|
||
#update{position:fixed;left:50%;transform:translateX(-50%);top:calc(env(safe-area-inset-top,0px) + 70px);z-index:18;width:min(520px,calc(100% - 24px));pointer-events:auto}
|
||
#update .b{pointer-events:auto}
|
||
.notes{margin:10px 0 0;padding-left:20px;line-height:1.5}
|
||
.notes li{margin:4px 0}
|
||
#bankBox{position:fixed;inset:0;background:rgba(30,38,64,.35);z-index:16;overflow:auto;padding:calc(env(safe-area-inset-top,0px) + 12px) max(12px,env(safe-area-inset-right,0px)) 16px max(12px,env(safe-area-inset-left,0px))}
|
||
#bankCard{max-width:760px;margin:0 auto;padding:16px 18px 18px;background:var(--paper)}
|
||
.menubtn{cursor:pointer;text-align:left;font:inherit;border-color:var(--ink)}
|
||
.menubtn .caret{font-size:13px;margin-left:2px;opacity:.85}
|
||
.cashbtn{cursor:pointer;text-align:left;font:inherit;color:inherit;position:relative}
|
||
.cashbtn .badge{position:absolute;top:-8px;right:-8px;background:var(--me);color:#fff;border:2.5px solid var(--ink);border-radius:10px;font:900 11px Nunito,sans-serif;padding:0 6px;line-height:16px}
|
||
.loan{border:2.5px solid var(--ink);border-radius:14px;padding:10px 12px;margin-top:10px;display:flex;gap:10px;align-items:flex-start}
|
||
.loan .grow{flex:1;min-width:0}
|
||
.loan .terms{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0}
|
||
.grade{font-family:var(--display);font-weight:800;font-size:30px;line-height:1;border:3px solid var(--ink);border-radius:12px;padding:4px 10px;background:var(--sun)}
|
||
#dash{position:fixed;inset:0;background:rgba(30,38,64,.35);z-index:15;overflow:auto;padding:calc(env(safe-area-inset-top,0px) + 12px) max(12px,env(safe-area-inset-right,0px)) 16px max(12px,env(safe-area-inset-left,0px))}
|
||
#dashCard{max-width:980px;margin:0 auto;padding:16px 18px 18px;background:var(--paper)}
|
||
.dgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px;margin:10px 0}
|
||
.tile{border:2.5px solid var(--ink);border-radius:13px;padding:6px 10px;background:var(--soft)}
|
||
.tile .lbl{font-size:10px;font-weight:900;letter-spacing:.08em;text-transform:uppercase;color:var(--ink2)}
|
||
.tile .val{font-family:var(--display);font-weight:800;font-size:22px;line-height:1.1;font-variant-numeric:tabular-nums}
|
||
.tile .sub{font-size:11.5px;color:var(--ink2);font-weight:700}
|
||
.dcols{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr);gap:12px}
|
||
@media (max-width:760px){.dcols{grid-template-columns:minmax(0,1fr)}}
|
||
.panel2{border:2.5px solid var(--ink);border-radius:14px;padding:10px 12px;min-width:0}
|
||
.panel2 h3{font-size:17px;margin-bottom:4px}
|
||
.chart{width:100%;height:auto;display:block}
|
||
.legend{display:flex;flex-wrap:wrap;gap:10px;font-size:11.5px;font-weight:800;color:var(--ink2);margin-top:4px}
|
||
.legend i{display:inline-block;width:11px;height:11px;border-radius:3px;border:1.5px solid var(--ink);margin-right:5px;vertical-align:-1px}
|
||
.tbl{width:100%;border-collapse:collapse;font-size:12.5px;font-variant-numeric:tabular-nums}
|
||
.tbl th{text-align:left;font-size:10px;letter-spacing:.07em;text-transform:uppercase;color:var(--ink2);padding:4px 6px;border-bottom:2px solid var(--ink)}
|
||
.tbl td{padding:5px 6px;border-bottom:1px solid var(--line);vertical-align:middle}
|
||
.tbl td.r,.tbl th.r{text-align:right}
|
||
.mix{display:flex;height:10px;width:100px;border:1.5px solid var(--ink);border-radius:5px;overflow:hidden;background:var(--paper)}
|
||
.mix i{display:block;height:100%}
|
||
.tscroll{overflow-x:auto}
|
||
#modal{position:fixed;inset:0;background:rgba(30,38,64,.45);display:grid;place-items:center;z-index:20;padding:16px max(16px,env(safe-area-inset-right,0px)) 16px max(16px,env(safe-area-inset-left,0px))}
|
||
#modal .card{width:min(560px,100%);max-height:calc(100% - 20px);overflow:auto;padding:20px 22px}
|
||
.title-art{display:flex;align-items:center;gap:14px}
|
||
.title-art h1{font-family:var(--display);font-weight:800;font-size:clamp(34px,7vw,52px);line-height:.95;margin:0;letter-spacing:-.01em}
|
||
.title-art h1 span{color:var(--me)}
|
||
.tagline{color:var(--ink2);font-size:14.5px;line-height:1.45;margin:10px 0 14px}
|
||
label.f{display:block;font-weight:900;font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:var(--ink2);margin:12px 0 5px}
|
||
input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radius:12px;padding:8px 12px;font-family:var(--display);font-weight:800;font-size:18px;background:var(--soft)}
|
||
.network-name{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
|
||
.network-name input.t{flex:1 1 240px;width:auto;min-width:0}
|
||
.plug{display:flex;gap:12px;align-items:center;border:3px solid var(--ink);border-radius:14px;padding:10px 12px;margin:10px 0 4px;background:var(--soft);box-shadow:0 3px 0 var(--ink);color:var(--ink);text-decoration:none}
|
||
.plug:hover{background:#FFF6D6}.plug .pi{font-size:30px;line-height:1}.plug b{font-family:var(--display);font-size:16px}.plug .meta{display:block;margin-top:2px}.plug .go{margin-left:auto;font-weight:900;white-space:nowrap}
|
||
.starts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
|
||
.start{border:3px solid var(--ink);border-radius:14px;padding:8px 10px;background:var(--paper);cursor:pointer;text-align:left;box-shadow:0 3px 0 var(--ink)}
|
||
.start.on{background:#FFE3F0;border-color:var(--me);box-shadow:0 3px 0 var(--me)}
|
||
.start b{font-family:var(--display);font-size:17px;display:block}
|
||
.start span{font-size:12px;color:var(--ink2);line-height:1.3;display:block}
|
||
.tiers{display:grid;gap:7px;margin-top:10px}
|
||
.tierbtn{display:flex;align-items:center;gap:10px;border:3px solid var(--ink);border-radius:13px;padding:8px 12px;background:var(--paper);cursor:pointer;box-shadow:0 3px 0 var(--ink);text-align:left}
|
||
.tierbtn:hover{background:#FFF6CF}
|
||
.tierbtn:disabled{opacity:.4;cursor:not-allowed}
|
||
.tierbtn .sz{font-family:var(--display);font-weight:800;font-size:22px;width:70px}
|
||
.tierbtn .grow{flex:1}
|
||
.tierbtn .pr{font-family:var(--display);font-weight:800;font-size:18px}
|
||
.gl dt{font-family:var(--display);font-weight:800;font-size:16px;margin-top:10px}
|
||
.gl dd{margin:2px 0 0;color:var(--ink2);line-height:1.45;font-size:13px}
|
||
.kbd{display:inline-block;border:2px solid var(--ink);border-radius:6px;padding:0 5px;font-weight:900;font-size:11px;background:var(--soft)}
|
||
|
||
/* Tablets in landscape (and small laptops): slimmer side panels, a tuck-away left panel and
|
||
bigger touch targets so the map keeps some room in the middle. */
|
||
@media (min-width:761px) and (max-width:1200px){
|
||
#left{width:272px}
|
||
#panel{width:336px}
|
||
#left.closed{display:none}
|
||
#leftToggle{display:flex;position:fixed;left:max(12px,env(safe-area-inset-left,0px));bottom:calc(env(safe-area-inset-bottom,0px) + 14px);z-index:4}
|
||
#leftToggle[hidden]{display:none}
|
||
}
|
||
@media (min-width:761px) and (max-width:1366px) and (pointer:coarse){
|
||
.b.sm{min-height:32px;padding:5px 11px}
|
||
.tabs button{min-height:40px}
|
||
.speed button{min-height:34px}
|
||
}
|
||
/* Mid-size screens: keep the HUD on one row so it never wraps over the side panels. */
|
||
@media (min-width:761px) and (max-width:1360px){
|
||
#hud{gap:6px}
|
||
.chip{padding:3px 8px}
|
||
.speed{gap:3px;padding:4px 5px}
|
||
.speed button{min-width:29px;font-size:12px}
|
||
}
|
||
@media (min-width:761px) and (max-width:1180px){
|
||
.hide-md{display:none !important}
|
||
.brand .val{font-size:17px}
|
||
.chip .val{font-size:17px}
|
||
}
|
||
@media (min-width:761px) and (max-width:960px){
|
||
.brand>div{display:none}
|
||
.brand .caret{display:none}
|
||
.chip .lbl{font-size:9px}
|
||
.chip .val{font-size:15px}
|
||
}
|
||
@media (min-width:761px) and (max-width:1040px){
|
||
.hide-md2{display:none !important}
|
||
.speed button{min-width:26px;height:28px;font-size:11.5px}
|
||
.chip{padding:2px 7px}
|
||
}
|
||
|
||
/* ================= PHONES =================
|
||
A decluttered, app-like layout: a one-row status strip at the top, a tab bar at the bottom
|
||
(play, speed, goals, deals, NOC, networks), and bottom sheets you drag up, down or away. */
|
||
html,body{overscroll-behavior:none}
|
||
.dtabs{position:sticky;top:-12px;z-index:3;display:flex;gap:6px;overflow-x:auto;margin:10px -4px 4px;padding:8px 4px;background:var(--paper);border-bottom:2.5px solid var(--ink);scrollbar-width:none}
|
||
.dtabs button{flex:0 0 auto;font:800 13px Nunito,sans-serif;border:2.5px solid var(--ink);border-radius:999px;background:#fff;padding:5px 12px;cursor:pointer;color:var(--ink)}
|
||
.dtabs button.on{background:var(--pink,#FF4F9A);color:#fff}
|
||
.dtabs .cnt{display:inline-block;margin-left:5px;min-width:16px;padding:0 4px;border-radius:8px;background:var(--bad);color:#fff;font-size:10.5px;line-height:16px;text-align:center}
|
||
.pcard{border:2.5px solid var(--ink);border-radius:14px;padding:8px 10px;margin:0 0 10px;background:#FFF6CF}
|
||
.pcard .pt{font-weight:900;font-size:15px;margin:1px 0 2px}.pcard .kv{margin-top:5px}.pcard .bar{margin-top:2px}
|
||
.pcard.lv{background:#EAF6FF}
|
||
.pitch{list-style:none;padding:0;margin:10px 0}.pitch li{margin:7px 0;line-height:1.38;font-size:14px}.pitch li.warn{background:#FFF4D6;border:2px solid var(--ink);border-radius:10px;padding:6px 8px}
|
||
.isteps{padding-left:22px;margin:8px 0 4px}.isteps li{margin:5px 0;line-height:1.38;font-size:14px}.isteps svg{vertical-align:-3px}
|
||
.icard{margin:8px 0 10px;border:2.5px solid var(--ink);border-radius:14px;padding:8px 10px;background:#FFF4D6}
|
||
/* iPhone home-screen app with a viewport shorter than the screen: the page box takes the real screen height
|
||
and becomes the containing block for everything fixed, so bottom-anchored UI reaches the bottom. */
|
||
html.iosfix,html.iosfix body{height:var(--app-h)}
|
||
html.iosfix body{position:fixed;top:0;left:0;right:0;transform:translateZ(0)}
|
||
button,.chip,.b,a{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
|
||
#hud,#tabbar,.tabs,.grab{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
|
||
#tabbar,.grab{display:none}
|
||
@media (max-width:760px),(max-height:500px) and (pointer:coarse){
|
||
:root{--tabbar:calc(58px + env(safe-area-inset-bottom,0px))}
|
||
#hud{flex-wrap:nowrap;top:calc(env(safe-area-inset-top,0px) + 6px);left:max(8px,env(safe-area-inset-left,0px));right:max(8px,env(safe-area-inset-right,0px));gap:5px}
|
||
#hud .speed,#hud #hNoc,#hud .spacer{display:none !important}
|
||
#hud .chip{flex:0 1 auto;min-width:0}
|
||
#hud .chip .lbl{font-size:8.5px;letter-spacing:.05em}
|
||
#hud .cashbtn{flex:0 1 auto}
|
||
#leftToggle{display:none !important}
|
||
#tabbar{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:9;height:var(--tabbar);padding:6px max(6px,env(safe-area-inset-right,0px)) env(safe-area-inset-bottom,0px) max(6px,env(safe-area-inset-left,0px));background:var(--paper);border-top:3px solid var(--ink);box-sizing:border-box;gap:2px;align-items:stretch}
|
||
#tabbar button{flex:1 1 0;min-width:0;border:0;background:transparent;border-radius:12px;font:inherit;font-weight:900;font-size:10.5px;color:var(--ink2);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;padding:2px 0;position:relative}
|
||
#tabbar button .ic{font-size:19px;line-height:1.05;color:var(--ink)}
|
||
#tabbar button.on{background:var(--soft);color:var(--ink)}
|
||
#tabbar button.play .ic{font-size:21px}
|
||
#tabbar button.play.paused{background:#FFE3F0}
|
||
#tabbar .cnt{position:absolute;top:2px;right:calc(50% - 22px);min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:var(--me);color:#fff;font-size:10px;line-height:16px;box-sizing:border-box}
|
||
#tabbar .cnt.red{background:var(--bad)}
|
||
#left,#panel{top:auto !important;left:0 !important;right:0 !important;width:auto !important;bottom:var(--tabbar) !important;max-height:min(62%,calc(100% - var(--tabbar) - 70px)) !important;border-radius:20px 20px 0 0 !important;border-bottom:0 !important;box-shadow:0 -3px 0 var(--ink) !important;transition:max-height .22s ease,transform .22s ease;z-index:7}
|
||
#left.full,#panel.full{max-height:calc(100% - var(--tabbar) - 56px - env(safe-area-inset-top,0px)) !important}
|
||
#left.closed{display:none}
|
||
.grab{display:block;height:22px;flex:0 0 22px;cursor:grab;touch-action:none;position:relative}
|
||
.grab::before{content:"";position:absolute;left:50%;top:8px;width:42px;height:5px;margin-left:-21px;border-radius:3px;background:var(--line)}
|
||
#left .tabs{display:none}
|
||
.ph{padding-top:0 !important}
|
||
.ph h2{font-size:21px}
|
||
.ph .eyebrow{font-size:10px}
|
||
#panel .tags,#panel .ph .btns{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none}
|
||
#toasts{top:calc(env(safe-area-inset-top,0px) + 54px) !important;bottom:auto !important;width:calc(100% - 16px) !important;flex-direction:column !important;pointer-events:auto}
|
||
.toast{pointer-events:auto;padding:6px 10px;border-width:2.5px;box-shadow:2px 2px 0 var(--ink);border-radius:12px}
|
||
.toast .tx{font-size:12px;line-height:1.3}
|
||
.toast .tx b{font-size:12.5px}
|
||
#hint{top:auto !important;bottom:calc(var(--tabbar) + 10px) !important}
|
||
body.sheet-open #hint{display:none}
|
||
#coach{top:auto !important;bottom:calc(var(--tabbar) + 8px);width:calc(100% - 16px);padding:7px 10px;font-size:13px}
|
||
body.sheet-open #coach{bottom:calc(var(--tabbar) + 8px + min(62vh,520px))}
|
||
#modal{align-items:end;padding:0}
|
||
#modal .cta{position:sticky;bottom:calc(-16px - env(safe-area-inset-bottom,0px));z-index:1;background:var(--paper);margin:12px -16px 0 !important;padding:10px 16px calc(10px + env(safe-area-inset-bottom,0px));border-top:2px solid var(--line)}
|
||
.title-art h1{font-size:34px}.title-art svg{width:54px;height:54px}
|
||
.tagline{font-size:13.5px;margin:8px 0 10px}
|
||
#modal .card{box-sizing:border-box;width:100%;max-height:calc(100% - env(safe-area-inset-top,0px) - 24px);border-radius:22px 22px 0 0;padding:16px 16px calc(16px + env(safe-area-inset-bottom,0px));border-bottom:0}
|
||
#dash{padding:calc(env(safe-area-inset-top,0px) + 6px) 0 0}
|
||
#dash>.card{border-radius:20px 20px 0 0;min-height:100%}
|
||
#mega{bottom:calc(var(--tabbar) + 6px)}
|
||
#update{top:auto !important;bottom:calc(var(--tabbar) + 8px) !important;width:calc(100% - 16px) !important;flex-wrap:wrap;gap:6px 8px;padding:8px 10px}
|
||
#update .tx{flex:1 1 100%}
|
||
#update .b{flex:1 1 0}
|
||
}
|
||
/* Phones on their side: the sheets slide in from the right and leave the map visible. */
|
||
@media (orientation:landscape) and (max-height:500px) and (pointer:coarse),(orientation:landscape) and (max-width:760px) and (max-height:500px){
|
||
:root{--tabbar:calc(50px + env(safe-area-inset-bottom,0px))}
|
||
#left,#panel{left:auto !important;right:0 !important;width:min(440px,58%) !important;top:calc(env(safe-area-inset-top,0px) + 50px) !important;max-height:none !important;border-radius:20px 0 0 0 !important;border-right:0 !important}
|
||
#left.full,#panel.full{width:min(640px,80%) !important}
|
||
#tabbar button .ic{font-size:16px}
|
||
body.sheet-open #coach{bottom:calc(var(--tabbar) + 8px);left:8px;transform:none;width:calc(42% - 16px)}
|
||
}
|
||
/* Installed as an app: no browser chrome, so leave room for the notch and the home indicator. */
|
||
@media (display-mode: standalone){
|
||
body{background:#57C4E5}
|
||
}
|
||
/* Whatever the language, the HUD stays on one row: fitHud() drops chips until it fits. */
|
||
#hud.fit1 .hide-md2,#hud.fit2 .hide-md{display:none !important}
|
||
#hud.fit3 .brand>div,#hud.fit3 .brand .caret{display:none}
|
||
@media (max-width:760px){
|
||
.chip{min-height:40px;padding:2px 8px}
|
||
.chip .val{font-size:16px}
|
||
.chip .lbl{font-size:9px}
|
||
.brand .val{font-size:16px}
|
||
.hide-sm{display:none !important}
|
||
#hud{gap:6px}
|
||
.chip{min-height:34px;padding:2px 7px;border-width:2.5px;box-shadow:2px 2px 0 var(--ink);border-radius:11px}
|
||
.chip .val{font-size:14px}
|
||
.chip .sub{font-size:10px}
|
||
.brand .tube{width:22px;height:22px}
|
||
.brand>div{display:none}
|
||
.speed{padding:2px 4px;gap:3px}
|
||
.speed button{min-width:28px;height:26px;font-size:11.5px;border-width:2px;border-radius:7px}
|
||
.spacer{display:none}
|
||
#left{top:auto}
|
||
#left{top:auto;bottom:calc(env(safe-area-inset-bottom,0px) + 8px);left:8px;right:8px;width:auto;max-height:55%}
|
||
#left.closed{display:none}
|
||
#leftToggle{display:flex;position:fixed;left:max(12px,env(safe-area-inset-left,0px));bottom:calc(env(safe-area-inset-bottom,0px) + 14px);z-index:4}
|
||
#panel{top:auto;bottom:calc(env(safe-area-inset-bottom,0px) + 8px);left:8px;right:8px;width:auto;max-height:58%;z-index:6}
|
||
.ph h2{font-size:22px}
|
||
#hint{top:auto;bottom:calc(env(safe-area-inset-bottom,0px) + 70px)}
|
||
#toasts{bottom:auto;top:calc(env(safe-area-inset-top,0px) + 112px);flex-direction:column;width:calc(100% - 24px)}
|
||
.toast{padding:6px 10px;border-width:2.5px;box-shadow:2px 2px 0 var(--ink)}
|
||
.toast .tx{font-size:12px}
|
||
.toast .tx b{font-size:13px}
|
||
}
|
||
@media (prefers-reduced-motion:reduce){:root:not(.anim-force) *{animation:none !important;transition:none !important}}
|
||
:root.no-anim *{animation:none !important;transition:none !important}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<header class="sr-only">
|
||
<h1 data-i18n>Series of Tubes: build the internet, one tube at a time</h1>
|
||
<p data-i18n>A free cartoon browser game about how the internet works. Start as a tiny network in one city, launch home broadband, buy IP transit from Tier 1 and Tier 2 carriers, peer at internet exchanges, set up private interconnects and embedded CDN caches, and lay terrestrial fiber, subsea waves and your own dark fiber with DWDM and ZR optics. Sign enterprise, hosting, high-frequency trading, AI GPU and hyperscaler customers, and keep them happy while backhoes, sharks, fat fingers, route leaks, DDoS attacks and geopolitics break things.</p>
|
||
</header>
|
||
<noscript>
|
||
<div style="max-width:640px;margin:40px auto;padding:0 16px;font:16px/1.5 system-ui,sans-serif;color:#1E2640;background:#fff">
|
||
<h1>Series of Tubes</h1>
|
||
<p>Series of Tubes is a cartoon game about building the internet: fiber, transit, peering, CDNs and a lot of backhoes. It runs entirely in your browser and needs JavaScript to play.</p>
|
||
<p><a href="https://github.com/fjaeckel/seriesoftubes">Source code on GitHub</a></p>
|
||
</div>
|
||
</noscript>
|
||
<canvas id="map" aria-label="World map of your network"></canvas>
|
||
|
||
<header id="hud">
|
||
<button class="chip brand menubtn" data-act="menu" aria-label="Network menu: save, load or start over">
|
||
<svg class="tube" viewBox="0 0 32 32" aria-hidden="true"><path d="M4 22c0-7 5-12 12-12h6" fill="none" stroke="#1E2640" stroke-width="7" stroke-linecap="round"/><path d="M4 22c0-7 5-12 12-12h6" fill="none" stroke="#FFD23F" stroke-width="3.5" stroke-linecap="round"/><circle cx="25" cy="10" r="5" fill="#fff" stroke="#1E2640" stroke-width="2.5"/></svg>
|
||
<div><div class="val" id="hName">Series of Tubes</div><div class="lbl" id="hAsn">AS —</div></div><span class="caret" aria-hidden="true">▾</span>
|
||
</button>
|
||
<button class="chip cashbtn" data-act="bank" aria-label="Cash and bank"><span class="lbl" data-i18n>Cash · Bank</span><span class="val num" id="hCash">$0</span><span class="sub num" id="hRate">—</span><span class="badge" id="hBank" hidden></span></button>
|
||
<div class="chip hide-sm hide-md2"><div class="lbl" data-i18n>Traffic served</div><div class="val num" id="hTraffic">0</div><div class="minibar"><i id="hTrafBar" style="width:0"></i></div></div>
|
||
<div class="chip"><div class="lbl" data-i18n>Reach</div><div class="val num" id="hReach">0%</div></div>
|
||
<div class="chip hide-sm hide-md"><div class="lbl" data-i18n>Rank</div><div class="val" id="hTier">Tier 3</div></div>
|
||
<button class="chip scn hide-sm" id="hScn" data-act="leftTab" data-args='{"t":"goals"}' hidden><span class="lbl" data-i18n>Scenario</span><span class="val num" id="hScnVal">—</span></button>
|
||
<button class="chip cust hide-sm" id="hCust" data-act="custOpen" hidden><span class="lbl" data-i18n>Customers</span><span class="val num" id="hCustVal">—</span></button>
|
||
<button class="chip noc" id="hNoc" data-act="leftTab" data-args='{"t":"noc"}'><span class="lbl">NOC</span><span class="val num" id="hNocVal" data-i18n>All quiet</span></button>
|
||
<div class="spacer"></div>
|
||
<div class="chip"><div class="lbl" data-i18n>Date</div><div class="val num" id="hDate">Y1 · Jan 1</div></div>
|
||
<div class="chip speed" role="group" aria-label="Game speed">
|
||
<button data-act="speed" data-args='{"v":0}' id="sp0" aria-label="Pause">❚❚</button>
|
||
<button data-act="speed" data-args='{"v":0.5}' id="sp0.5" aria-label="Half speed">½×</button>
|
||
<button data-act="speed" data-args='{"v":1}' id="sp1">1×</button>
|
||
<button data-act="speed" data-args='{"v":2}' id="sp2">2×</button>
|
||
<button data-act="speed" data-args='{"v":4}' id="sp4">4×</button>
|
||
<button data-act="speed" data-args='{"v":8}' id="sp8">8×</button>
|
||
<button data-act="dash" aria-label="NOC dashboard" title="NOC dashboard"><svg width="16" height="14" viewBox="0 0 16 14" aria-hidden="true"><path d="M1 13h14M2 10l4-5 3 3 5-6" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
|
||
<button data-act="help" aria-label="How to play">?</button>
|
||
<button data-act="mute" id="muteBtn" aria-label="Toggle sound">♪</button>
|
||
</div>
|
||
</header>
|
||
|
||
<aside id="left" class="card">
|
||
<div class="grab" data-grab="left" aria-hidden="true"></div>
|
||
<nav class="tabs" id="leftTabs"></nav>
|
||
<div class="scroll" id="leftBody"></div>
|
||
</aside>
|
||
<button id="leftToggle" class="b pink" data-act="toggleLeft" data-i18n>Goals & NOC</button>
|
||
<nav id="tabbar" aria-label="Game"></nav>
|
||
|
||
<aside id="panel" class="card" hidden>
|
||
<div class="grab" data-grab="panel" aria-hidden="true"></div>
|
||
<div id="panelBody" style="display:flex;flex-direction:column;min-height:0;flex:1"></div>
|
||
</aside>
|
||
|
||
<div id="hint" hidden></div>
|
||
<div id="coach" hidden role="status"></div>
|
||
<div id="toasts" aria-live="polite"></div>
|
||
<div id="mega" hidden role="alert"><div class="mtrack"><span data-i18n>🐘 BREAKING: CVE-2026-31337 IN PHP TAKES DOWN HALF THE INTERNET</span><span data-i18n>Every WordPress-ish site on Earth is now a crypto miner</span><span data-i18n><?php echo "sorry"; ?></span><span data-i18n>Eyeball traffic down 30%</span><span data-i18n>Hosting customers patching at 3 a.m.</span><span data-i18n>Security team asks: “are we on PHP?” Everyone: “define we”</span><span data-i18n>🐘 BREAKING: CVE-2026-31337 IN PHP TAKES DOWN HALF THE INTERNET</span><span data-i18n>Every WordPress-ish site on Earth is now a crypto miner</span><span data-i18n><?php echo "sorry"; ?></span><span data-i18n>Eyeball traffic down 30%</span><span data-i18n>Hosting customers patching at 3 a.m.</span><span data-i18n>Security team asks: “are we on PHP?” Everyone: “define we”</span></div></div>
|
||
<div id="update" class="toast goal" hidden role="status"></div>
|
||
<div id="bankBox" hidden><div class="card" id="bankCard" role="dialog" aria-label="Bank"></div></div>
|
||
<div id="dash" hidden><div class="card" id="dashCard" role="dialog" aria-label="NOC dashboard"></div></div>
|
||
<div id="modal" hidden><div class="card" id="modalCard" role="dialog" aria-modal="true"></div></div>
|
||
|
||
<script>
|
||
// Language: the player's saved choice, else the browser's, else English. Non-English dictionaries load before the game.
|
||
(function(){const langs=window.SOT_LANGS={en:'English',it:'Italiano'};let l=null;try{l=localStorage.getItem('sot-lang');}catch(e){}
|
||
const b=(navigator.language||'').slice(0,2).toLowerCase();if(!Object.hasOwn(langs,l))l=Object.hasOwn(langs,b)?b:'en';
|
||
window.SOT_LANG=l;document.documentElement.lang=l;if(l!=='en')document.write('<script src="i18n/'+l+'.js?v=__VERSION__"><\/script>');})();
|
||
</script>
|
||
<script>
|
||
'use strict';
|
||
/* ================= LANGUAGE =================
|
||
English is the source text: tr(text,vars) looks it up in the dictionary that
|
||
site/i18n/<lang>.js registered and falls back to the English. trn() picks the singular or plural
|
||
form first; N_() only marks text that doubles as an id, so it can be translated where it is shown. */
|
||
// English when the dictionary did not load (offline, or a copy without the i18n folder).
|
||
const LANGS=window.SOT_LANGS,LANG=window.I18N?.[window.SOT_LANG]?window.SOT_LANG:'en';
|
||
document.documentElement.lang=LANG;
|
||
const DICT=Object.assign(Object.create(null),window.I18N?.[LANG]);
|
||
function tr(s,v){const o=DICT[s]||s;return v?o.replace(/\{(\w+)\}/g,(m,k)=>k in v?v[k]:m):o;}
|
||
function trn(one,other,n,v){return tr(n===1?one:other,{n,...v});}
|
||
function N_(s){return s;}
|
||
/* ================= ANALYTICS (ridiculytics) =================
|
||
Off unless ANALYTICS.host is set. Fill in your collector when you self-host the game.
|
||
Inside the claude.ai viewer outside requests are blocked, so it only reports from your own domain. */
|
||
const APP_VERSION='__VERSION__';
|
||
// Filled in by scripts/build.sh from CHANGELOG.md for this version.
|
||
const RELEASE_NOTES=/*__RELEASE_NOTES__*/[];
|
||
const IS_DEV=APP_VERSION.startsWith('__');
|
||
// Only report from the real site; previews, localhost and the Claude viewer stay silent.
|
||
const ANALYTICS={host:/(^|\.)seriesoftub\.es$/.test(location.hostname)?'https://stats.seriesoftub.es':'',site:'seriesoftub.es'};
|
||
(function(){
|
||
try{
|
||
window.ridiculytics=window.ridiculytics||function(){const q=window.ridiculytics.q=window.ridiculytics.q||[];if(q.length<100)q.push(arguments);};
|
||
if(!ANALYTICS.host)return;
|
||
const sc=document.createElement('script');sc.defer=true;sc.src='https://cdn.jsdelivr.net/npm/ridiculytics@1.0.1/web/counter.min.js';
|
||
sc.setAttribute('data-host',ANALYTICS.host);if(ANALYTICS.site)sc.setAttribute('data-site',ANALYTICS.site);sc.setAttribute('data-spa','false');sc.integrity='sha384-uNCU8e2RB7Yn6lVNut2gupQsJwKwXPZu2i4t/Eg6Q59ki0kchBR4L4yoS3ZxxjEX';sc.crossOrigin='anonymous';sc.referrerPolicy='no-referrer';
|
||
document.head.appendChild(sc);
|
||
}catch(e){}
|
||
})();
|
||
const TRACKED=new Set();
|
||
function track(name,once){if(!ANALYTICS.host)return;if(once){if(TRACKED.has(name))return;TRACKED.add(name);}try{window.ridiculytics(name);}catch(e){}}
|
||
const PLAY_MARKS=[1,5,15,30,60,120];
|
||
/* ================= CONSTANTS ================= */
|
||
const W=2000, H=1000, KM=14;
|
||
const POP_COST=20000, POP_MO=1500, EYE_RATE=150, CACHE_CAP=100, CACHE_MO=400;
|
||
const DAY_MS=2500, ROUTER_COST=15000, ROUTER_MO=1500, GEN_COST=12000, GEN_MO=600, DIVERSE=1.4;
|
||
const RU_BOX=40000, RU_BOX_MO=2000;
|
||
const UAE_LIC=15000,KSA_LIC=25000;
|
||
// Korea: "sender pays" interconnection makes transit into Seoul about four times the usual price.
|
||
const KR_TRANSIT=4;
|
||
const SITE2_COST=45000,SITE2_MO=3000,TE_COST=60000,TE_MO=4000;
|
||
const SITE2_N=[tr('The Other Building'),tr('Campus B (the one with parking)'),tr('Across-the-River DC'),tr('The Annex'),tr('Suburban Mega-shed'),tr('The Cheaper One'),tr('Formerly a Shopping Mall'),tr('Bunker Two')];
|
||
const siteName=(c,s)=>s==='b'?SITE2_N[hstr(c)%SITE2_N.length]:CITY[c].dc;
|
||
const BE_TAPE=30000;
|
||
const popCost=c=>POP_COST+(c&&CITY[c]&&CITY[c].tape?BE_TAPE:0)+(c&&CITY[c]&&CITY[c].ru?RU_BOX:0)+(c&&CITY[c]&&CITY[c].uae?UAE_LIC:0)+(c&&CITY[c]&&CITY[c].saudi?KSA_LIC:0);
|
||
const CN_LIC=150000, CN_JV_MO=6000;
|
||
// Scrubbing centers come in tiers by clean bandwidth. Always-on diverts instantly; on-demand is cheaper
|
||
// but takes a couple of days to engage. A clean-pipe add-on on a transit scrubs upstream, per port.
|
||
const SCRUB_TIERS=[{n:'100G',g:100,cost:60000,mo:5000,lvl:1},{n:'1T',g:1000,cost:180000,mo:15000,lvl:3},{n:'10T',g:10000,cost:500000,mo:40000,lvl:4},{n:'100T',g:100000,cost:1500000,mo:110000,lvl:10}];
|
||
const SCRUB_DELAY=2, SLA_PEN=20000;
|
||
const scrubG=()=>SCRUB_TIERS[S.scrubTier||0].g;
|
||
const scrubMo=()=>Math.round(SCRUB_TIERS[S.scrubTier||0].mo*(S.scrubMode==='ondemand'?0.6:1));
|
||
const cleanMo=t=>Math.round(PORT[t.tier].g*(t.n||1)*5);
|
||
// DDoS has a shape now: a vector, a size and an entry point. A vector's `fs` is whether Flowspec can drop
|
||
// it at the edge — it catches the known volumetric UDP floods, but an application-layer HTTP flood sails
|
||
// through. Whether a POP can run Flowspec at all is a router-model property (`fs` on RG): the rules live in
|
||
// hardware TCAM, and the budget differs by platform. FS_RES is the junk left after filtering, by capability
|
||
// (0 none → no help · 1 basic merchant/whitebox → 40% leaks · 2 full big iron → 15% leaks).
|
||
const FS_RES=[1,0.4,0.15];
|
||
const DDOS_VEC={
|
||
dns:{n:tr('DNS reflection'),fs:true},
|
||
ntp:{n:tr('NTP amplification'),fs:true},
|
||
cldap:{n:tr('CLDAP flood'),fs:true},
|
||
syn:{n:tr('SYN flood'),fs:true},
|
||
http:{n:tr('HTTP flood'),fs:false},
|
||
};
|
||
const MYIX_COST=80000, MYIX_MO=3000, MYIX_FEE=1500, START_CASH=200000;
|
||
// Your own exchange's switching fabric. Bigger fabrics carry more and attract more members.
|
||
const MYIX_FAB=[{n:'400G',g:400,cost:0,mo:3000,max:12},{n:'1.6T',g:1600,cost:60000,mo:6000,max:20,lvl:2},{n:'6.4T',g:6400,cost:200000,mo:12000,max:30,lvl:3},{n:'25.6T',g:25600,cost:600000,mo:25000,max:45,lvl:4},{n:'102.4T',g:102400,cost:1800000,mo:60000,max:60,lvl:9}];
|
||
const myFab=c=>MYIX_FAB[Math.min(MYIX_FAB.length-1,Math.max(0,(S.myIx[c]&&S.myIx[c].fab)|0))];
|
||
const LT=[{n:'10G',g:10,m:1},{n:'100G',g:100,m:2.8},{n:'400G',g:400,m:6},{n:'800G',g:800,m:9},{n:'1.6T',g:1600,m:13},{n:'6.4T',g:6400,m:28,car:1600,note:tr('handed off as 4×1.6T')},{n:'12.8T',g:12800,m:45,car:3200,note:tr('handed off as 4×3.2T')}];
|
||
const PORT=[{n:'10G',g:10,setup:500,tmo:150,ix:400,pni:200},{n:'100G',g:100,setup:1500,tmo:400,ix:1500,pni:350},{n:'400G',g:400,setup:4000,tmo:900,ix:4000,pni:600},{n:'800G',g:800,setup:8000,tmo:1600,ix:7000,pni:1000},{n:'1.6T',g:1600,setup:16000,tmo:2800,ix:12000,pni:1600},{n:'3.2T',g:3200,setup:32000,tmo:5000,ix:20000,pni:2600}];
|
||
const RG=[
|
||
{n:'Rusty Router 9000',pn:'100G',cap:400,cost:0,mo:0,maxLT:1,maxP:1,ports:8,cls:0,lvl:1,boot:6,slowP:10,fs:0,chip:tr('a mystery ASIC'),blurb:tr('Bought used on eBuy. The fans sound like a jet engine.')},
|
||
{n:'Edge Lord 400',pn:'400G',cap:3200,cost:30000,mo:1000,maxLT:2,maxP:2,ports:24,cls:1,lvl:2,boot:11,slowP:20,fs:1,chip:tr('merchant silicon'),blurb:tr('Sharp, edgy, and finally speaks 400G and 400ZR+.')},
|
||
{n:'Chonk 800',pn:'800G',cap:12800,cost:90000,mo:3000,maxLT:3,maxP:3,ports:36,cls:2,lvl:3,boot:25,slowP:45,fs:2,chip:'Junipurr PacketOinker™',blurb:tr('An absolute unit with 800G ports, built around the Junipurr PacketOinker™ forwarding chip. Oinks at line rate. Takes 800ZR+ optics.')},
|
||
{n:'Absolute Unit 1.6T',pn:'1.6T',cap:51200,cost:250000,mo:8000,maxLT:5,maxP:4,ports:40,cls:3,lvl:4,boot:40,slowP:60,fs:2,chip:tr('PacketOinker² (two pigs, one chassis)'),blurb:tr('1.6T ports, its own weather system and two PacketOinker² chips per line card. Takes 6.4T waves as 4×1.6T. Needs a forklift.')},
|
||
{n:'Mikrowtik CCR',pn:'100G',cap:300,cost:4000,mo:150,maxLT:1,maxP:1,ports:16,cls:0,lvl:1,boot:2,slowP:5,badge:'M',fs:1,chip:tr('a few dozen ARM cores'),blurb:tr('Costs less than lunch and has twice the ports of the Rusty. Configuring it takes longer than the lunch.')},
|
||
{n:'Sonic the Whitebox 32',pn:'400G',cap:3200,cost:14000,mo:400,maxLT:2,maxP:2,ports:32,cls:1,lvl:2,boot:9,slowP:25,flaky:true,badge:'W',fs:1,chip:tr('Tomahack merchant silicon'),blurb:tr('A bare-metal switch running open-source SONiC. Saves a fortune, until it crashes and there is nobody to call.')},
|
||
{n:'Arrrhipster 7280R',pn:'400G',cap:4800,cost:42000,mo:1300,maxLT:2,maxP:2,ports:48,cls:1,lvl:2,boot:3,slowP:2,badge:'A',fs:2,chip:tr('Jerry-cho deep-buffer silicon'),blurb:tr('Fixed config, deep buffers, a well-groomed beard and an eyepatch. Runs EOS, the Extensible Operating Ship. Boots before your oat-milk flat white is ready, and ships a Python shell nobody asked for.')},
|
||
{n:'Arrrhipster 7800R',pn:'800G',cap:16000,cost:130000,mo:4200,maxLT:3,maxP:3,ports:96,cls:2,lvl:3,boot:7,slowP:4,badge:'A',fs:2,chip:tr('Jerry-cho³ deep-buffer silicon'),blurb:tr('The modular one. Ninety-six 800G ports, buffers deep enough to lose a ship in, and a vinyl-only release notes policy. Arrr.')},
|
||
{n:'Disco 8K',pn:'800G',cap:12800,cost:80000,mo:4800,maxLT:3,maxP:3,ports:64,cls:2,lvl:3,boot:20,slowP:35,badge:'D',fs:2,chip:'Silly-con One',blurb:tr('Cheap to buy, expensive to own: licence keys for every port, every feature and, rumour has it, the fans. Smart Licensing phones home every week.')},
|
||
{n:'Knockia 7750',pn:'1.6T',cap:40000,cost:200000,mo:7000,maxLT:5,maxP:4,ports:56,cls:3,lvl:4,boot:30,slowP:15,badge:'K',fs:2,chip:tr('Fin-P network processor'),blurb:tr('Finnish engineering: indestructible, extremely thorough, and the CLI only speaks hierarchical config. Boots like a Nordic sunrise.')},
|
||
{n:'Sonic the Whitebox 64',pn:'1.6T',cap:25600,cost:60000,mo:1500,maxLT:5,maxP:4,ports:64,cls:3,lvl:5,boot:9,slowP:25,flaky:true,badge:'W',fs:1,chip:tr('Tomahack 5 merchant silicon'),blurb:tr('Sixty-four 1.6T ports on open-source software for the price of one line card. There is still nobody to call at 3 a.m., but now the crashes are 1.6T crashes.')},
|
||
{n:'Disco 8K Ultra',pn:'1.6T',cap:51200,cost:140000,mo:11000,maxLT:5,maxP:4,ports:72,cls:3,lvl:6,boot:22,slowP:35,badge:'D',fs:2,chip:'Silly-con One G3',blurb:tr('Cheap chassis, eternal subscription. Every port needs a licence, every licence needs a licence server, and the licence server needs a licence.')},
|
||
{n:'Absolute Unit 3.2T',pn:'3.2T',cap:204800,cost:600000,mo:18000,maxLT:6,maxP:5,ports:48,cls:4,lvl:7,boot:50,slowP:60,fs:2,chip:tr('PacketOinker³ (a whole litter)'),blurb:tr('3.2T ports, and 12.8T waves handed off as 4×3.2T. Draws as much power as a small town and ships with its own substation. Needs a bigger forklift.')},
|
||
{n:'Arrrhipster 7800R5',pn:'3.2T',cap:160000,cost:450000,mo:14000,maxLT:6,maxP:5,ports:144,cls:4,lvl:9,boot:8,slowP:4,badge:'A',fs:2,chip:tr('Jerry-cho⁵ deep-buffer silicon'),blurb:tr('A hundred and forty-four 3.2T ports and buffers deep enough to hide a whole fleet. Still boots before your flat white. The beard now has a beard.')},
|
||
{n:'Knockia 7950 XRS',pn:'3.2T',cap:180000,cost:520000,mo:15000,maxLT:6,maxP:5,ports:96,cls:4,lvl:10,boot:32,slowP:15,badge:'K',fs:2,chip:tr('Fin-P6 network processor'),blurb:tr('Built like a sauna door: heavy, hot and nearly impossible to break. The config is now so hierarchical it has a royal family.')},
|
||
{n:'Mikrowtik CCR 3.2T',pn:'3.2T',cap:51200,cost:45000,mo:900,maxLT:6,maxP:5,ports:32,cls:4,lvl:11,boot:3,slowP:5,flaky:true,badge:'M',fs:1,chip:tr('several hundred ARM cores and a prayer'),blurb:tr('A 3.2T router for the price of a used car. The web interface has nine hundred tabs, and one of them is the one you need.')},
|
||
{n:'The Router at the End of the Universe',pn:'3.2T',cap:819200,cost:3000000,mo:60000,maxLT:6,maxP:5,ports:256,cls:4,lvl:13,boot:42,slowP:42,badge:'U',fs:2,chip:tr('forty-two of them'),blurb:tr('Two hundred and fifty-six 3.2T ports and enough forwarding for a small galaxy. Boots in 42 minutes. Nobody remembers what the question was.')}
|
||
];
|
||
/* Some routers take forever to boot. Each POP's chassis has a personality per model: most come
|
||
back in minutes, a few sit through every line card self-test known to the vendor. */
|
||
const SLOW_BOOT=[tr('is oinking through the self-test of every PacketOinker on every line card'),tr('is running fsck on a compact flash card older than your interns'),tr('found a newer firmware on the USB stick someone left in it, and is installing it'),tr('is counting to 2 million routes. Out loud. One at a time'),tr('is waiting for the line cards to agree on who is the primary'),tr('booted, panicked about a missing fan tray, and started again'),tr('is "synchronising the routing engines". Nobody knows what that means')];
|
||
function slowBoot(c){const p=S.pops[c];if(!p)return false;const g=p.rgen||0;return hstr(c+'|boot|'+g+'|'+S.asn)%100<RG[g].slowP;}
|
||
function bootMin(c){const p=S.pops[c],G=RG[(p&&p.rgen)||0];return slowBoot(c)?G.boot*9+40:G.boot;}
|
||
const routerCost=g=>Math.round(ROUTER_COST+RG[g].cost*0.8);
|
||
// Old routers go on eBuy when you swap models or remove one (#82), like spare optics (#45). Chassis age faster.
|
||
const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCost=(c,g)=>{const p=S.pops[c],rt=p.routers||1;return Math.max(0,RG[g].cost*rt-tradeIn(p.rgen||0,rt));};
|
||
const RMAX=6;
|
||
// The plain, badge-less model of each class is the default upgrade path; the others are side-grades.
|
||
const mainRG=k=>RG.findIndex(r=>r.cls===k&&!r.badge);
|
||
// Ports and waves beyond 1.6T / 6.4T only show once a router that takes them is unlocked.
|
||
const portShown=i=>i<=4||RG.some(r=>r.lvl<=lvl()&&r.maxP>=i),waveShown=i=>i<=5||RG.some(r=>r.lvl<=lvl()&&r.maxLT>=i);
|
||
/* Ports are finite. Every transit, IX, PNI and cache port, every wave and every fibre channel
|
||
takes a router port. 10G ports ride a breakout cable, four to a port. */
|
||
const PORT_SLOT=i=>i===0?0.25:1;
|
||
function portsUsed(c){let u=0;
|
||
for(const l of S.links){if(l.a!==c&&l.b!==c||l.kind==='vxc')continue;u+=l.kind==='df'?(l.ch||[]).length:1;}
|
||
for(const t of S.transit)if(t.city===c)u+=PORT_SLOT(t.tier)*(t.n||1);
|
||
for(const x of S.pni)if(x.city===c)u+=PORT_SLOT(x.tier)*(x.n||1);
|
||
for(const x of ixIdsIn(c))if(S.ixp[x]!==undefined&&!S.myIx[x])u+=PORT_SLOT(S.ixp[x])*((S.ixn||{})[x]||1);
|
||
if(S.myIx[c])u+=1;
|
||
u+=S.caches.filter(x=>x.city===c).length+(S.nni||[]).filter(x=>x.city===c).length;
|
||
return u;}
|
||
function portsMax(c,g,rt){const p=S.pops[c];if(!p)return 0;return RG[g===undefined?(p.rgen||0):g].ports*(rt||p.routers||1);}
|
||
function portGate(c,add){if(!S.pops[c]||add<=0)return true;const u=portsUsed(c),m=portsMax(c);if(u+add<=m+1e-9)return true;
|
||
toast(tr('<b>No free router ports in {city}.</b><br>{u} of {m} in use. Add a router, or swap to a model with more ports (Infra tab).',{city:esc(CITY[c].name),u:fmtPorts(u),m}),'bad');sfx('err');return false;}
|
||
const fmtPorts=u=>Number.isInteger(u)?String(u):u.toFixed(2).replace(/0+$/,'');
|
||
function modelFits(c,g){const G=RG[g],p=S.pops[c];if(!p)return '';
|
||
if(S.links.some(l=>(l.a===c||l.b===c)&&l.kind==='wave'&&l.tier>G.maxLT))return tr('A wave here is faster than {pn}.',{pn:G.pn});
|
||
if([...S.transit,...S.pni].some(t=>t.city===c&&t.tier>G.maxP)||ixIdsIn(c).some(x=>S.ixp[x]!==undefined&&!S.myIx[x]&&S.ixp[x]>G.maxP))return tr('A port here is bigger than {pn}.',{pn:G.pn});
|
||
if(S.links.some(l=>(l.a===c||l.b===c)&&l.kind==='df'&&(l.ch||[]).some(o=>OPT[o]&&OPT[o].rg>G.cls)))return tr('A fibre here uses optics this model cannot take.');
|
||
if(portsUsed(c)>portsMax(c,g))return tr('You use {u} ports here and {r} × {model} only has {max}.',{u:fmtPorts(portsUsed(c)),r:p.routers||1,model:G.n,max:portsMax(c,g)});return '';}
|
||
// dark fiber & optical gear
|
||
const DF_SYS={
|
||
lite:{n:'Rainbow-in-a-Box DWDM',max:16,cost:25000,lvl:2,blurb:tr('Fixed mux plus amplifiers. Up to 16 channels, no remote switching.')},
|
||
roadm:{n:'ROADMaster 9000',max:64,cost:60000,lvl:3,blurb:tr('Full C-band, remotely reconfigurable, takes long-haul transponders. Up to 64 channels.')},
|
||
cl:{n:'ROADMaster 9000 C+L',max:128,cost:140000,lvl:6,blurb:tr('Lights the L-band as well: twice the spectrum, up to 128 channels on one fiber pair, and amplifiers that take twice as long to explain.')},
|
||
};
|
||
const AMP_EVERY=100, AMP_COST=8000, AMP_MO=300;
|
||
/* Your own trench holds more than one fiber pair (#35). Once a ROADMaster is full you can light the next pair:
|
||
another ROADMaster and another chain of amplifiers, 64 more channels. Regen huts are shared. */
|
||
const isRdm=y=>y==='roadm'||y==='cl';
|
||
const PAIRS_MAX=4,PAIRS_BIG=8,PAIRS_LV=12,SUB_PAIRS_MAX=8,SUB_PAIR_UP=1500000,pairsMax=l=>l.sub?SUB_PAIRS_MAX:lvl()>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,chMax=l=>DF_SYS[l.sys].max*(isRdm(l.sys)&&l.own?Math.max(1,l.pairs|0):1),
|
||
pairCost=l=>DF_SYS[isRdm(l.sys)?l.sys:'roadm'].cost+(l.sub?SUB_PAIR_UP:ampCount(l.km)*AMP_COST);
|
||
const OPT={
|
||
zr4:{n:'Ackackia 400ZR+',g:400,cost:12000,reach:1500,modes:[[400,1500],[200,3000]],rg:1,lvl:2,sys:'lite',blurb:tr('Coherent pluggable in the router. No transponder shelf.')},
|
||
zr8:{n:'Sizzle 800ZR+',g:800,cost:22000,reach:900,modes:[[800,900],[400,1800],[200,3600]],rg:2,lvl:3,sys:'lite',blurb:tr('Twice the speed, shorter reach.')},
|
||
tp16:{n:'Sienna WaveMagic 1.6T',g:1600,cost:70000,reach:4000,modes:[[1600,4000],[1200,5500],[800,7000],[400,12000]],rg:2,lvl:4,sys:'roadm',blurb:tr('Big shelf, big reach, big invoice.')},
|
||
tp32:{n:'Sienna WaveMagic 3.2T',g:3200,cost:130000,reach:1500,modes:[[3200,1500],[1600,4000],[800,7000],[400,12000]],rg:4,lvl:8,sys:'roadm',blurb:tr('Twice the WaveMagic. Full speed only on shorter spans, and a cooling fan you can hear from the car park.')},
|
||
};
|
||
const dfLeaseMo=km=>Math.round(400+km*1.0);
|
||
const dfBuildCost=km=>Math.round(25000+km*120);
|
||
const dfBuildDays=km=>Math.round(120+km*0.25);
|
||
const ampCount=km=>Math.max(0,Math.floor(km/AMP_EVERY));
|
||
const fmtCap=g=>g>=1000?(+(g/1000).toFixed(1))+'T':g+'G';
|
||
const WAVECO=['Zay-No Fiber','Loomin’ Technologies','Clown Castle Fiber','Bolt Technology','youNetworks','GTT (Got Tangled Twice)'];
|
||
const MONTHS=[tr('Jan'),tr('Feb'),tr('Mar'),tr('Apr'),tr('May'),tr('Jun'),tr('Jul'),tr('Aug'),tr('Sep'),tr('Oct'),tr('Nov'),tr('Dec')];
|
||
const REG={AM:tr('Americas'),SA:tr('South America'),EU:tr('Europe'),AF:tr('Africa'),AS:tr('Asia'),OC:tr('Oceania')};
|
||
const waveMo=(km,sub,tier)=>Math.round((300+km*1.2)*LT[tier].m*(sub?1.8:1));
|
||
const FABS=[
|
||
{id:'mgp',name:'Megapork',col:'#FF5A1F',cities:['icn','sea','sjc','dal','chi','ash','nyc','mia','lon','ams','fra','par','mrs','sto','mad','sin','hkg','tok','syd','jnb'],blurb:tr('Elastic interconnection, now with bacon. Spin up a circuit in 59 seconds, oink in 60.')},
|
||
{id:'pkf',name:'PocketFabric',col:'#00A896',cities:['sea','sjc','dal','chi','ash','nyc','mia','sao','lon','ams','fra'],blurb:tr('A whole network fabric that fits in your pocket.')},
|
||
{id:'ccn',name:'Consolation Connect',col:'#8E44AD',cities:['icn','lon','fra','ams','mrs','bom','sin','hkg','tok','syd','lag','jnb'],blurb:tr('Strong in Asia and Africa. Every circuit comes with a consolation prize.')},
|
||
];
|
||
const FAB=Object.fromEntries(FABS.map(f=>[f.id,f]));
|
||
const NNI=[{n:'10G',g:10,mo:500},{n:'100G',g:100,mo:1200}];
|
||
const VXC=[{n:'10G',g:10,m:1},{n:'50G',g:50,m:2.4},{n:'100G',g:100,m:3.6}];
|
||
const vxcMo=(km,sub,t)=>Math.round((150+km*0.12)*VXC[t].m*(sub?2:1));
|
||
const MET={prefer:{l:tr('Prefer'),f:0.5},normal:{l:tr('Normal'),f:1},avoid:{l:tr('Avoid'),f:4},backup:{l:tr('Backup only'),f:60}};
|
||
const PREF={high:tr('Prefer'),normal:tr('Normal'),low:tr('Backup only')};
|
||
const edgeKey=l=>l.a<l.b?l.a+'|'+l.b:l.b+'|'+l.a;
|
||
/* Reach (#17, #30). Coherent optics trade speed for distance: past full-rate reach they drop to a
|
||
slower, more robust modulation. Regeneration sites go further: each one turns the light back into
|
||
bits and sends it on fresh, so every optical span is shorter. Each site needs a regen card per channel. */
|
||
const REGEN_COST=30000,REGEN_MO=900,REGEN_CH=0.5,REGEN_MAX=8;
|
||
const spanKm=l=>Math.ceil(l.km/((l.regen|0)+1));
|
||
/* Subsea glass is engineered end to end for one route: ultra-low-loss, large-area fiber and a repeater every
|
||
~70 km, no regens (#66, #68). Optics reach about half as far again as on land, and the same physics caps
|
||
every wave on a cable, leased or your own: transatlantic gets 1.6T, transpacific 800G. */
|
||
const SUB_REACH=1.5,reachOn=(r,sub)=>sub?Math.round(r*SUB_REACH):r;
|
||
function optMode(o,l){const O=OPT[o],km=spanKm(l);for(const [g,r] of O.modes||[[O.g,O.reach]])if(km<=reachOn(r,l.sub))return {g,reach:reachOn(r,l.sub),full:g===O.g};return null;}
|
||
// The fastest single carrier any optic can run over this much subsea cable.
|
||
const subCarrier=km=>Math.max(0,...Object.values(OPT).map(O=>{const m=(O.modes||[[O.g,O.reach]]).find(([,r])=>km<=reachOn(r,true));return m?m[0]:0;}));
|
||
// A big leased wave is several carriers (6.4T = 4×1.6T), so each carrier has to make it across on its own.
|
||
const waveCar=i=>LT[i].car||LT[i].g;
|
||
function subWaveWhy(i,km,sub){if(!sub)return '';const c=subCarrier(km);return waveCar(i)>c?tr('{km} km of cable carries at most {g} per carrier.',{km:Math.round(km).toLocaleString(),g:fmtCap(c)}):'';}
|
||
const subMaxTier=km=>{let t=0;LT.forEach((T,i)=>{if(!subWaveWhy(i,km,true))t=i;});return t;};
|
||
const optG=(o,l)=>{const m=optMode(o,l);return m?m.g:0;};
|
||
const regenNeed=(o,l)=>Math.max(0,Math.ceil(l.km/OPT[o].reach)-1);
|
||
const dfCap=l=>{if(l.ready>S.day||l.eqDown>S.day)return 0;const ch=l.ch||[];let g=0;for(const c of ch)g+=optG(c,l);const f=l.chFail&&l.chFail.until>S.day?l.chFail:null;if(f){const fo=f.o&&ch.includes(f.o)?f.o:ch.slice().sort((a,b)=>optG(a,l)-optG(b,l))[0];if(fo)g-=optG(fo,l);}return Math.max(0,g);};
|
||
const capOf=l=>(l.kind==='vxc'?VXC[l.vt].g:l.kind==='df'?dfCap(l):LT[l.tier].g)*(l.deg>S.day?0.5:1)*(l.loss&&l.loss.until>S.day?l.loss.f:1);
|
||
// A sick LAG (LACP trouble) keeps only part of its capacity until the incident clears.
|
||
const lagF=o=>o&&o.lacp&&o.lacp.until>S.day?o.lacp.f:1,ixLagF=x=>lagF(S.ev&&S.ev.ixlacp&&{lacp:S.ev.ixlacp[x]});
|
||
const tierW=l=>{if(l.kind==='wave')return l.tier;if(l.kind==='vxc')return 0;const g=dfCap(l);return g>=6400?4:g>=1600?3:g>=400?2:g>=100?1:0;};
|
||
const capName=l=>l.kind==='vxc'?VXC[l.vt].n:l.kind==='df'?(l.ready>S.day?tr('building'):(l.ch||[]).length?fmtCap(dfCap(l)||(l.ch||[]).reduce((a,c)=>a+optG(c,l),0))+' DF':tr('dark')):LT[l.tier].n;
|
||
|
||
/* ================= WORLD ================= */
|
||
// Simplified real geography: lon/lat outlines, equirectangular, with gentle "magnifying lenses" over the busy regions.
|
||
const LENSES=[{lon:102.5,lat:2.6,r:22,m:1.1},{lon:52.5,lat:25.3,r:45,m:1.5},{lon:78.5,lat:15,r:48,m:1.1},{lon:-44.5,lat:-23.5,r:30,m:1.2},{lon:9,lat:49,r:170,m:1.25},{lon:121,lat:32,r:120,m:0.45},{lon:-80,lat:40,r:110,m:0.5}];
|
||
function proj0(lon,lat){return [(lon+180)/360*W,(84-lat)*6.4];}
|
||
for(const L of LENSES){const q=proj0(L.lon,L.lat);L.x=q[0];L.y=q[1];}
|
||
function proj(lon,lat){const q=proj0(lon,lat);let dx=0,dy=0;for(const L of LENSES){let ex=q[0]-L.x;ex-=W*Math.round(ex/W);const ey=q[1]-L.y,f=L.m*Math.exp(-(ex*ex+ey*ey)/(L.r*L.r));dx+=ex*f;dy+=ey*f;}return [q[0]+dx,q[1]+dy];}
|
||
function hav(lo1,la1,lo2,la2){const r=Math.PI/180,dLa=(la2-la1)*r,dLo=(lo2-lo1)*r,a=Math.sin(dLa/2)**2+Math.cos(la1*r)*Math.cos(la2*r)*Math.sin(dLo/2)**2;return 2*6371*Math.asin(Math.min(1,Math.sqrt(a)));}
|
||
const LANDS_LL=[{id:'am',ll:[[-166,68],[-157,71.2],[-141,69.8],[-128,70],[-115,68.5],[-97,68],[-94,62],[-92.5,57.5],[-85,55.2],[-80,51.5],[-78.5,58],[-77,62],[-70,61],[-64.5,60],[-61.5,56.5],[-57,52],[-55.6,49.5],[-53,47],[-59,46.5],[-61,45.2],[-66,44.5],[-70,43.3],[-70,42],[-74,40.6],[-76,38],[-75.8,35.5],[-77.5,34.5],[-79,33],[-81,31],[-80.05,27],[-80.1,25.3],[-81.5,25],[-82.7,27.5],[-84,30],[-89,30.2],[-94,29.5],[-97,28],[-97.5,25],[-97.7,22],[-96,19],[-94,18.3],[-91,18.5],[-90.4,21],[-87,21.5],[-88,17],[-88.5,15.8],[-84,15.8],[-83.4,12],[-83.7,10.5],[-81.5,9],[-79.5,9.5],[-77.5,8.6],[-75,10.8],[-71.5,12.3],[-68,10.6],[-62,10.5],[-60,8],[-57,6],[-52,5],[-50,1.5],[-48,-1],[-44,-2.5],[-39,-3.5],[-35,-5.5],[-35,-9],[-37.5,-12.5],[-39,-15],[-39.7,-19],[-41,-22],[-44,-23],[-48,-26],[-48.6,-28.5],[-51,-31],[-53,-34],[-58,-34.5],[-57,-37],[-62,-39],[-65,-41],[-64,-43],[-67.5,-46],[-66,-48],[-69,-51],[-68.5,-53],[-70,-55],[-73,-53],[-75,-48],[-73.5,-43],[-73.5,-37],[-71.5,-32],[-71.3,-27],[-70.5,-20],[-71.5,-17],[-76,-14],[-78,-10],[-81,-6],[-80.5,-3],[-80,0],[-79,1.5],[-77.5,4],[-77.4,7.5],[-80,7.3],[-82.5,8.2],[-85.7,10],[-87,12.5],[-91,14],[-94,16],[-96.5,15.7],[-100,17],[-105.5,20],[-105.5,22.5],[-108,25.5],[-110.8,27.9],[-113,31.3],[-114.7,31.7],[-113.5,29],[-112,26.5],[-110,24],[-109.5,23],[-112,24.8],[-114,27.5],[-115.5,29.8],[-117,32.5],[-118.5,34],[-120.6,34.6],[-122.5,37.5],[-124,40.5],[-124.5,43],[-124,46.2],[-124.7,48.4],[-123,49],[-126,50.5],[-130,54.5],[-133,57.5],[-137,58.5],[-141,60],[-146,61],[-150,59.5],[-152,58.5],[-156,57.5],[-158,56.8],[-162,55.5],[-164.5,54.5],[-158,58.5],[-162,60],[-165,61.5],[-166,64],[-164,65.5]]},{id:'eu',ll:[[-9,39],[-9.5,43],[-8,43.7],[-1.8,43.4],[-1.2,46],[-2.5,47.3],[-4.5,48],[-1.6,48.6],[1.5,50.2],[3,51.2],[4.5,52.5],[5,53.4],[7,53.6],[8.6,54],[8.2,55.5],[8.1,57],[10.5,57.7],[10.5,56.5],[11.2,56],[12.6,56.1],[12.7,55.6],[12.1,54.9],[11,54.3],[14,54],[18.5,54.8],[21,55.3],[21,57],[24,57.5],[24,59.2],[28,59.5],[30,60],[28,60.5],[25,60.1],[22.5,60.3],[21.5,61.5],[21.5,63],[25,65],[25.5,65.6],[22,65.8],[20.5,63.5],[18,62.5],[17.4,61],[19,59.8],[18,59],[16.5,57],[16,56.2],[14.2,55.4],[13,55.4],[12.9,56.5],[11.5,58],[10.5,59.3],[8,58],[5.5,58.5],[5,60],[5,62],[7,63],[10,64],[12.5,66],[15,68.5],[18,69.8],[21.5,70.2],[26,71],[30,70],[33,69.3],[41,67],[44,68.5],[53,68.5],[58,69],[68,69],[69,72.8],[73,72.5],[80,73.5],[87,74.8],[100,76],[104,77.7],[112,74],[113.5,73.5],[127,73.5],[132,71.5],[140,72.5],[150,71.5],[160,70],[170,70],[180,69],[190,66.5],[186,64.5],[182,65],[178,62.5],[173,61],[170,60],[164,60],[164,57],[162,55],[159,52],[156.7,51],[156,55.5],[157,58],[155,59.5],[150,59.5],[143,59.3],[137,54.5],[141,53],[140,48.5],[135,43.5],[131,42.7],[129.5,41],[129.4,37],[129.4,35.5],[127.5,34.6],[126.3,34.8],[126.5,37],[125,37.8],[124.5,39.7],[121.5,39],[121.7,40.8],[119,39.3],[117.8,38.5],[119,37.2],[122.5,37.3],[120.5,36],[119.2,35],[121,32],[121.9,30.8],[121.5,28],[119.5,25.5],[116.5,23],[114.3,22.1],[111,21.5],[109.7,20.5],[108.5,21.6],[106.5,20],[106,18],[108.5,15],[109.3,12],[107,10.5],[105,8.6],[104.8,10.3],[103,11],[100.9,12.6],[100,13.4],[99.3,10.5],[100.3,7],[101,6.8],[103.4,4],[104.3,1.4],[103.6,1.25],[101.3,2.8],[100.2,5.3],[98.3,8],[98.6,13],[97.7,16.5],[94.4,16.2],[94.2,18.8],[92.3,20.6],[91.8,22.6],[90,22],[88.3,21.6],[86.9,20.6],[85,19.5],[82.3,16.6],[80.3,15.8],[80.3,13.5],[79.8,10.3],[78.3,8.9],[77.5,8.1],[76.5,8.9],[75.8,11.5],[74.8,12.9],[73.5,16],[72.8,19],[72.7,21.2],[70,22.5],[68.5,23.5],[66.6,25.4],[61.6,25.2],[57.3,25.8],[56.4,27.1],[54.7,26.5],[51.5,27.9],[50,30],[48,30],[48.4,28.5],[49.5,26.7],[50.8,24.8],[50.85,25.6],[51.2,26.15],[51.62,25.9],[51.62,24.6],[52.6,24.2],[54.3,24.6],[55.3,25.3],[55.9,25.75],[56.1,26.1],[56.35,26.38],[56.42,25.8],[56.38,25.0],[56.5,24.6],[57.8,23.8],[58.8,22.5],[59.8,22.4],[58.5,20.5],[57.7,19],[55.4,17.7],[52.2,15.7],[48.7,14],[45,12.8],[43.4,12.6],[42.7,15.7],[42.5,17.2],[41,19.5],[39.1,21.6],[38.4,23.6],[37,25.5],[35.2,28],[34.9,29.5],[34.3,27.8],[33,28.8],[32.6,30],[32.3,31.2],[34.2,31.3],[34.9,32.8],[35.6,34.5],[36,35.8],[36.2,36.7],[34.5,36.8],[32.5,36.1],[30.5,36.4],[29,36.6],[27.3,37.4],[26.3,38.6],[26.5,40],[26.2,40.6],[24,40.8],[22.6,40.4],[24.1,38.2],[24,37.6],[23.2,37.5],[22.3,36.5],[21.7,36.8],[21.2,38.4],[19.5,40],[19.5,41.8],[18.5,42.5],[16,43.5],[13.7,45.6],[12.3,45.3],[12.4,44.2],[13.6,43.5],[15.9,41.6],[18.5,40.2],[17,39],[16.6,38],[15.6,38],[15.3,37],[15.1,36.65],[12.4,37.8],[13.3,38.25],[15.55,38.3],[16.1,39],[15.6,40.1],[14.3,40.6],[12.5,41.6],[11,42.5],[10.2,43.9],[8.8,44.4],[7.5,43.8],[6,43.1],[4,43.5],[3.1,43.1],[3.2,41.9],[0.8,41],[0,39.5],[-0.3,38.4],[-0.8,37.6],[-2.1,36.7],[-4.4,36.7],[-5.6,36],[-6.3,36.8],[-7.4,37.2],[-8.9,37],[-8.8,38.4],[-9.5,38.6]]},{id:'af',ll:[[-17.5,14.7],[-17,21],[-16,24],[-13,27.5],[-9.8,30],[-9.2,32.5],[-6.8,34],[-5.9,35.8],[-2,35.1],[1,36.5],[5,36.8],[9.8,37.3],[11,36.9],[10.2,35.2],[11.1,33.3],[15.2,32.3],[19,30.3],[20.1,32],[23,32.6],[25,31.7],[29,30.9],[32.2,31.3],[32.6,30],[33.5,28],[35.5,24],[37.2,21],[38.5,18],[39.6,15.5],[41.6,13.5],[43.3,12.4],[44,10.4],[47,11.1],[51.2,11.8],[51,10.4],[49.5,7],[47.8,4.5],[45,1.6],[42,-1],[40.2,-2.8],[39.3,-4.8],[38.8,-6.5],[39.6,-10],[40.5,-11],[40.6,-14.6],[37,-17.5],[35.4,-22],[35.5,-24],[32.9,-25.9],[32.5,-28.6],[31,-29.9],[28,-32.7],[25.6,-33.9],[22.5,-34],[20,-34.8],[18.4,-34],[17.9,-32.5],[16.5,-28.6],[15.2,-27],[14.4,-23],[12.8,-19],[11.8,-16.8],[12.2,-14.5],[13.6,-12.2],[13.2,-8.8],[12.3,-6],[11.8,-3.5],[9.5,-1],[9.4,1],[9.8,3.2],[8.9,4.5],[6,4.3],[4.3,6.3],[1.6,6.2],[-2,4.8],[-4.6,5.2],[-7.5,4.4],[-9.4,5.4],[-11.5,6.9],[-13.2,8.7],[-15,10.9],[-16.7,12.4]]},{id:'uk',ll:[[-5.7,50.1],[-3,50.6],[1.4,51.2],[1.7,52.7],[0.3,53.4],[-0.2,54.3],[-1.6,55.6],[-2,56.4],[-1.8,57.6],[-3.4,58.6],[-5,58.6],[-6.2,57.5],[-5.6,56.3],[-5,55],[-3.2,54.9],[-3.4,54],[-3,53.4],[-4.6,53.3],[-4.2,52.2],[-5.2,51.7],[-3.2,51.4],[-4.6,51]]},{id:'ie',ll:[[-6,52.2],[-6.2,53.5],[-5.6,54.6],[-6.4,55.2],[-7.4,55.4],[-8.5,54.5],[-10,54.2],[-9.6,53.2],[-10.2,51.9],[-9.6,51.5],[-8.2,51.8]]},{id:'is',ll:[[-22.5,63.9],[-24,65.5],[-22,66.4],[-16,66.5],[-14.5,65.3],[-14.6,64.4],[-18,63.4]]},{id:'jp',ll:[[129.6,33.3],[130.2,31.3],[131.4,31.5],[132,33],[133.5,33.4],[135.2,33.6],[136.8,34.3],[138.8,34.6],[140,35],[140.8,35.7],[141,38.2],[141.9,39.5],[141.4,41.4],[140,41.4],[139.9,40.3],[139.8,38.5],[138.8,37.8],[137.3,36.9],[136,36],[135.4,35.6],[133,35.5],[131.5,34.6],[130.9,34]]},{id:'oc',ll:[[113.5,-22],[114,-26.5],[115,-30],[115.7,-33.6],[115,-34.3],[117.9,-35.1],[123.5,-33.9],[126,-32.3],[131,-31.5],[134,-32.8],[135.6,-34.8],[137.6,-35.6],[138.5,-34.6],[139.6,-36.9],[141.5,-38.4],[144.9,-37.9],[146.4,-39.1],[150,-37.5],[150.8,-34.5],[152.5,-32.4],[153.6,-28.5],[153,-25],[150.8,-22.5],[149,-20.6],[146.3,-18.9],[145.4,-16],[145.3,-14.9],[143.5,-12.3],[142.5,-10.7],[141.6,-12.8],[141.6,-16],[140.6,-17.6],[139.3,-17.4],[137,-15.9],[135.8,-15],[136.8,-12.2],[135,-12],[132.6,-11.5],[131,-12.2],[129.5,-14.9],[128,-15.4],[126.5,-13.9],[124.5,-16.5],[122.2,-18.2],[121,-19.7],[118.5,-20.3],[116.7,-20.6],[114.6,-21.8]]},{id:'nz',ll:[[172.7,-34.4],[174.5,-36],[175.9,-37.5],[178.5,-37.7],[177.9,-39.2],[176.9,-39.6],[175.2,-41.6],[174.6,-41.2],[174.9,-39.9],[173.8,-39.3],[174.6,-38.1],[174.5,-37.3],[173.1,-35.3]]},{id:'idn',ll:[[105.2,-6.8],[106.8,-6.1],[108.5,-6.4],[110.5,-6.9],[112.6,-6.9],[114.6,-7.7],[114.4,-8.7],[111,-8.3],[108,-7.8],[105.5,-7]]},{id:'ph',ll:[[120.6,18.5],[122.2,18.5],[122,16.5],[121.6,14.2],[124,13.8],[124,12.5],[123.3,13],[121,13.6],[120.6,14.5],[119.8,16.2]]}];
|
||
// South America is drawn as part of 'am' but counts as its own landmass: nothing crosses the Darién Gap.
|
||
LANDS_LL.push({id:'lk',ll:[[79.9, 9.8], [80.6, 9.6], [81.4, 8.5], [81.9, 7.4], [81.6, 6.4], [80.6, 5.9], [80.0, 6.2], [79.75, 7.2], [79.75, 8.3]]},{id:'sa',hide:true,ll:[[-77.5, 8.6], [-75, 10.8], [-71.5, 12.3], [-68, 10.6], [-62, 10.5], [-60, 8], [-57, 6], [-52, 5], [-50, 1.5], [-48, -1], [-44, -2.5], [-39, -3.5], [-35, -5.5], [-35, -9], [-37.5, -12.5], [-39, -15], [-39.7, -19], [-41, -22], [-44, -23], [-48, -26], [-48.6, -28.5], [-51, -31], [-53, -34], [-58, -34.5], [-57, -37], [-62, -39], [-65, -41], [-64, -43], [-67.5, -46], [-66, -48], [-69, -51], [-68.5, -53], [-70, -55], [-73, -53], [-75, -48], [-73.5, -43], [-73.5, -37], [-71.5, -32], [-71.3, -27], [-70.5, -20], [-71.5, -17], [-76, -14], [-78, -10], [-81, -6], [-80.5, -3], [-80, 0], [-79, 1.5], [-77.5, 4], [-77.4, 7.5]]},{id:'tw',ll:[[121.5, 25.35], [122.05, 25.0], [121.85, 24.3], [121.4, 23.0], [120.85, 21.9], [120.6, 22.3], [120.15, 22.9], [120.1, 23.6], [120.55, 24.5], [121.0, 25.1]]});
|
||
const LANDS=LANDS_LL.map(l=>({id:l.id,hide:true,pts:l.ll.map(q=>proj(q[0],q[1]))}));
|
||
// Drawn coastline: Natural Earth 1:50m land, simplified (tight around cities, looser elsewhere), lon/lat rings. Built by scripts/build-land.mjs.
|
||
// LANDS above is only the coarse landmass test that decides which landmass a city sits on (subsea vs overland); it is not drawn.
|
||
const COAST=[[[180,68.98],[181.13,68.75],[181.94,68.27],[182.2,68.34],[181.63,68.57],[184.65,67.68],[184.63,67.36],[185.15,67.35],[185.08,66.62],[185.61,66.34],[185.91,66.47],[185.94,66.23],[186.22,66.43],[185.77,66.63],[185.91,66.94],[185.45,67.09],[186.84,67.07],[186.74,66.84],[187.48,66.95],[186.99,67.06],[188.2,66.93],[189.4,66.25],[190.27,66.06],[189.6,65.93],[189.33,65.62],[188.55,65.79],[188.83,65.5],[187.22,65.68],[187.77,65.45],[187.34,65.25],[187.79,65.05],[186.93,64.85],[187.62,64.43],[187.1,64.53],[186.84,64.28],[186.67,64.54],[186.27,64.36],[184.56,64.82],[183.91,65.47],[181.59,65.49],[181.06,66.03],[181.47,66.4],[181.08,66.18],[180.86,66.37],[180.22,66.02],[180.65,65.52],[179.45,64.82],[178.52,64.6],[176.41,65.07],[177.22,64.86],[176.06,64.96],[174.55,64.68],[176.06,64.9],[176.35,64.7],[176.14,64.59],[177.39,64.77],[177.69,64.3],[178.23,64.36],[178.69,63.84],[178.47,63.57],[179.33,63.19],[179.57,62.77],[179.12,62.32],[177.02,62.78],[177.16,62.56],[172.86,61.47],[172.39,61.06],[170.61,60.43],[170.35,59.97],[169.23,60.6],[167.23,60.41],[166.27,59.86],[166.35,60.48],[165.09,60.1],[164.96,59.84],[163.74,60.03],[161.96,58.08],[162.39,57.72],[162.66,57.95],[163.23,57.79],[162.76,57.24],[162.8,56.81],[163.26,56.69],[163.34,56.23],[162.84,56.06],[162.63,56.23],[163.04,56.52],[162.67,56.49],[162.09,56.09],[161.72,55.5],[162.1,54.75],[160.07,54.19],[159.84,53.78],[160.02,53.13],[158.47,53.03],[158.49,52.38],[158.1,51.81],[156.75,50.97],[155.56,55.2],[156.02,56.75],[156.85,57.29],[156.87,57.8],[158.27,58.01],[162.07,60.47],[163.71,60.92],[163.56,61.03],[164.01,61.34],[163.8,61.46],[164.21,62.29],[165.4,62.49],[164.42,62.71],[163.33,62.55],[163.09,61.57],[162.39,61.66],[160.17,60.64],[160.38,61.02],[159.79,60.96],[160.31,61.89],[157.09,61.68],[154.29,59.83],[154.15,59.53],[154.97,59.45],[155.16,59.19],[153.36,59.21],[152.82,58.93],[151.33,58.88],[151.12,59.08],[152.26,59.22],[149.64,59.77],[148.8,59.53],[148.96,59.37],[148.73,59.26],[146.54,59.46],[146.05,59.17],[145.55,59.41],[142.58,59.24],[140.79,58.3],[140.45,57.81],[138.66,56.97],[137.69,56.14],[135.26,54.94],[135.26,54.73],[135.85,54.58],[136.8,54.62],[136.72,53.8],[137.16,53.82],[137.14,54.18],[137.67,54.28],[137.34,54.1],[137.84,53.95],[137.25,53.55],[137.95,53.6],[138.53,53.96],[138.25,53.52],[138.45,53.54],[138.66,54.3],[139.71,54.28],[141.38,53.29],[141.18,53.01],[140.84,53.09],[141.26,52.84],[141.13,52.43],[141.49,52.18],[140.52,50.8],[140.38,48.96],[138.11,46.25],[135.13,43.53],[133.16,42.7],[132.3,42.88],[132.31,43.31],[131.95,43.1],[132.01,43.28],[131.8,43.25],[131.16,42.63],[130.71,42.66],[130.73,42.33],[129.76,41.71],[129.71,40.86],[127.57,39.78],[127.4,39.21],[128.33,38.68],[129.42,37.06],[129.56,35.95],[129.21,35.18],[128.51,35.1],[128.44,34.87],[127.71,34.96],[127.72,34.72],[127.4,34.82],[127.32,34.46],[127.25,34.76],[126.53,34.31],[126.27,34.67],[126.59,34.82],[126.29,35.15],[126.69,36.01],[126.54,36.17],[126.55,36.48],[126.49,36.69],[126.39,36.65],[126.18,36.69],[126.16,36.77],[126.22,36.87],[126.49,37.01],[126.78,36.95],[126.87,36.82],[126.98,36.94],[126.87,36.98],[126.74,37.19],[126.79,37.3],[126.65,37.45],[126.66,37.55],[126.56,37.72],[126.63,37.78],[126.37,37.88],[126.12,37.74],[126.05,37.87],[125.94,37.87],[125.77,37.99],[125.41,37.72],[124.99,37.93],[125.21,38.08],[124.69,38.13],[125.55,38.69],[125.17,38.81],[125.36,39.53],[124.64,39.61],[124.35,40.01],[122.84,39.6],[121.16,38.73],[121.11,38.92],[121.82,39.39],[121.27,39.55],[122.26,40.5],[121.83,40.97],[121.18,40.9],[120.48,40.23],[119.39,39.75],[118.98,39.18],[117.78,39.13],[117.65,38.42],[118.94,38.04],[119.11,37.2],[119.76,37.15],[120.75,37.83],[121.64,37.46],[122.67,37.4],[122.34,36.83],[121.93,36.96],[120.81,36.63],[120.64,36.13],[120.18,36.2],[120.29,35.98],[119.22,35.01],[119.2,34.75],[120.27,34.27],[120.86,32.66],[121.34,32.43],[121.4,32.37],[121.45,32.15],[121.68,32.05],[121.83,31.9],[121.87,31.7],[121.76,31.7],[121.35,31.86],[120.97,31.87],[120.79,32.03],[120.52,32.11],[120.07,31.96],[120.19,31.91],[120.5,32.02],[120.71,31.98],[120.79,31.82],[121.06,31.72],[121.66,31.32],[121.79,31.16],[121.88,30.92],[121.42,30.79],[121,30.56],[120.82,30.35],[120.45,30.39],[120.23,30.25],[120.5,30.3],[120.63,30.13],[120.91,30.16],[121.16,30.3],[121.26,30.3],[121.43,30.23],[121.68,29.98],[122.08,29.87],[121.91,29.78],[121.51,29.48],[121.97,29.49],[121.92,29.13],[121.45,29.13],[121.68,28.95],[121.47,28.64],[121.61,28.29],[121.15,28.33],[120.75,28.01],[120.09,26.67],[119.59,26.79],[119.88,26.33],[119.14,26.12],[119.62,26],[119.62,25.39],[119.18,25.45],[119.29,25.23],[118.98,25.21],[118.66,24.62],[117.84,24.47],[118.06,24.25],[117.37,23.59],[116.91,23.65],[116.47,22.95],[115.64,22.85],[115.5,22.72],[115.38,22.72],[115.2,22.82],[114.85,22.62],[114.75,22.63],[114.71,22.74],[114.65,22.75],[114.54,22.62],[114.55,22.53],[114.34,22.59],[114.27,22.54],[114.34,22.4],[114.27,22.3],[113.9,22.4],[114.01,22.51],[113.83,22.61],[113.62,22.86],[113.62,23.13],[113.45,23.05],[113.44,22.94],[113.33,22.91],[113.55,22.59],[113.59,22.35],[113.55,22.22],[113.15,22.08],[113.09,22.21],[113.01,22.12],[112.99,21.94],[112.9,21.88],[112.81,21.95],[112.66,21.86],[112.36,21.98],[112.3,21.74],[111.94,21.85],[111.6,21.56],[110.41,21.34],[110.16,20.94],[110.52,20.46],[110.12,20.26],[109.66,20.92],[109.93,21.48],[109.52,21.69],[109.08,21.44],[108.48,21.9],[108.5,21.63],[107.81,21.5],[107.16,20.95],[106.68,21],[106.52,20.29],[105.98,19.94],[105.62,18.97],[106.5,17.95],[106.35,17.77],[108.82,15.38],[109.3,13.86],[109.45,12.6],[109.22,12.65],[109.2,11.73],[108.99,11.34],[108.18,10.92],[108.1,10.9],[108,10.72],[107.84,10.7],[107.26,10.4],[107.09,10.5],[107.01,10.66],[106.95,10.4],[106.81,10.43],[106.73,10.54],[106.61,10.47],[106.74,10.44],[106.76,10.3],[106.47,10.3],[106.73,10.19],[106.79,10.12],[106.6,9.86],[106.14,10.22],[106.51,9.82],[106.57,9.64],[106.48,9.56],[106.38,9.56],[105.83,10],[106.16,9.59],[106.21,9.5],[106.17,9.4],[104.77,8.6],[105.03,10.07],[104.26,10.54],[103.59,10.55],[103.65,11.06],[103.15,10.91],[103.12,11.46],[102.65,12.15],[101.72,12.69],[101.44,12.62],[100.9,12.65],[100.86,12.72],[100.96,13.43],[100.6,13.57],[100.54,13.51],[100.23,13.48],[100.02,13.35],[99.99,13.24],[100.09,13.04],[99.96,12.69],[100.01,12.35],[99.16,10.32],[99.25,9.27],[99.83,9.29],[100.42,7.19],[101.5,6.86],[103.2,5.26],[103.45,4.67],[103.48,2.84],[103.81,2.58],[104.22,1.72],[104.28,1.42],[104.18,1.37],[103.98,1.62],[103.99,1.46],[103.69,1.45],[103.48,1.33],[103.36,1.55],[102.73,1.86],[102.55,2.04],[102.15,2.25],[101.78,2.57],[101.52,2.68],[101.3,2.89],[101.35,3.01],[101.3,3.25],[100.72,3.97],[100.8,4.02],[100.66,4.23],[100.26,6.18],[99.6,7.36],[98.24,8.42],[98.7,10.19],[98.56,10.03],[98.47,10.68],[98.88,11.72],[98.64,11.74],[98.57,13.16],[98.2,13.98],[98.11,13.71],[97.81,14.86],[97.58,16.02],[97.72,16.57],[97.38,16.52],[96.85,17.4],[96.77,16.71],[96.43,16.5],[96.19,16.77],[96.32,16.44],[95.39,15.72],[95.35,16.1],[95.18,15.83],[94.94,15.82],[94.89,16.18],[94.66,15.9],[94.7,16.51],[94.23,16.02],[94.59,17.57],[94.05,19.29],[93.93,18.9],[93.49,19.37],[93.83,19.24],[94,19.44],[93.71,19.91],[93.25,20.07],[93.13,19.86],[93.07,20.38],[92.83,20.18],[92.74,20.56],[92.72,20.3],[92.31,20.79],[91.86,22.35],[91.53,22.71],[91.48,22.88],[91.22,22.64],[90.95,22.6],[90.63,23.09],[90.6,23.59],[90.56,23.42],[90.27,23.46],[90.59,23.27],[90.6,23.13],[90.47,23.05],[90.55,22.91],[90.46,22.88],[90.43,22.75],[90.61,22.36],[90.55,22.22],[90.16,21.82],[90.21,22.16],[89.96,22.02],[89.89,22.31],[89.98,22.47],[89.88,22.39],[89.57,21.77],[89.48,22.28],[89.35,21.72],[89.05,22.09],[89.05,21.65],[88.75,21.58],[88.64,22.12],[88.58,21.66],[88.06,21.69],[88.2,22.14],[87.94,22.37],[88.16,22.12],[87.95,21.83],[86.86,21.24],[86.98,20.7],[86.75,20.31],[86.22,19.9],[85.25,19.76],[85.18,19.59],[85.44,19.63],[84.11,18.29],[82.36,17.1],[82.26,16.56],[81.29,16.34],[80.98,15.76],[80.38,15.79],[80.1,14.8],[80.18,14.48],[80.11,14.21],[80.31,13.49],[80.16,13.71],[80.06,13.61],[80.34,13.36],[80.23,12.69],[80.14,12.45],[79.86,11.99],[79.84,10.32],[79.31,10.26],[78.92,9.45],[79.41,9.19],[78.42,9.1],[78.06,8.38],[77.3,8.15],[76.4,9.24],[76.35,9.92],[74.94,12.56],[74.38,14.49],[73.47,16.05],[73.15,17.53],[72.87,18.64],[73.01,19.02],[72.97,19.15],[72.83,18.98],[72.8,19.08],[72.81,19.3],[72.99,19.28],[72.79,19.36],[72.75,19.45],[72.8,19.52],[72.73,19.58],[72.67,19.83],[72.9,20.67],[72.61,21.46],[73.11,21.75],[72.54,21.7],[72.7,21.97],[72.52,21.98],[72.81,22.23],[72.18,22.27],[72.04,21.82],[72.25,21.53],[72.02,21.16],[70.72,20.74],[68.97,22.29],[70.18,22.57],[70.49,23.09],[69.67,22.76],[69.24,22.85],[68.42,23.57],[68.78,23.85],[68.23,23.6],[68.16,23.86],[68.11,23.75],[68.04,23.85],[67.95,23.83],[67.86,23.9],[67.82,23.83],[67.67,23.81],[67.65,23.92],[67.56,23.88],[67.31,24.17],[67.17,24.76],[66.7,24.86],[66.7,25.23],[66.43,25.58],[66.22,25.59],[66.13,25.49],[66.36,25.51],[66.47,25.45],[66.24,25.46],[65.68,25.35],[61.41,25.1],[60.51,25.44],[59.05,25.42],[57.34,25.79],[57.21,26.04],[57.2,26.16],[56.73,27.13],[56.28,27.19],[55.42,26.77],[55.29,26.79],[54.9,26.56],[54.64,26.51],[54.52,26.59],[53.71,26.73],[52.48,27.62],[51.52,27.91],[50.07,30.2],[49.56,30.03],[49,30.51],[48.83,30.04],[47.98,30.01],[48.15,29.57],[47.72,29.39],[48.05,29.35],[48.8,27.72],[50.15,26.66],[50.15,26.1],[50.1,26.12],[50.08,25.96],[50.24,25.62],[50.46,25.42],[50.56,25.09],[50.81,24.79],[50.85,24.89],[50.76,25.45],[51,25.98],[51.26,26.15],[51.54,25.9],[51.57,25.78],[51.49,25.53],[51.61,25.05],[51.43,24.67],[51.27,24.61],[51.42,24.53],[51.31,24.34],[51.54,24.29],[51.6,24.34],[51.67,24.25],[51.77,24.25],[51.84,24.01],[52.12,23.97],[52.51,24.11],[53.03,24.15],[53.89,24.08],[54.4,24.28],[54.75,24.81],[55.1,25.04],[55.52,25.5],[55.94,25.79],[56.17,26.21],[56.31,26.24],[56.41,26.35],[56.37,25.8],[56.3,25.65],[56.36,25.57],[56.37,25.02],[56.64,24.47],[56.91,24.15],[57.22,23.92],[58.58,23.64],[59.84,22.42],[58.47,20.41],[58.17,20.59],[57.86,20.24],[57.81,19.02],[56.82,18.75],[56.38,17.99],[55.48,17.84],[55.06,17.04],[54.07,17],[52.45,16.39],[52.22,15.66],[51.6,15.34],[49.35,14.64],[48.67,14.05],[45.66,13.34],[45.04,12.82],[44.26,12.64],[43.49,12.7],[42.94,14.94],[42.66,15.23],[42.7,16.74],[41.66,18.01],[40.76,19.75],[40.08,20.27],[39.88,20.29],[39.73,20.39],[39.27,20.97],[39.09,21.31],[39.15,21.52],[38.99,21.88],[39.09,22.39],[39.01,22.77],[38.88,22.88],[38.94,22.88],[38.29,23.91],[37.54,24.29],[37.15,25.29],[35.18,28.04],[34.62,28.06],[34.97,29.55],[34.22,27.76],[33.25,28.57],[32.72,29.52],[32.56,29.97],[32.47,29.93],[32.49,29.85],[32.36,29.63],[32.4,29.53],[32.56,29.39],[32.66,28.93],[33.55,27.9],[33.96,26.65],[35.2,24.47],[35.78,23.94],[35.51,23.78],[35.7,22.95],[36.83,22.1],[37.26,21.11],[37.47,18.82],[38.57,18.07],[39.5,15.53],[39.79,15.12],[39.86,15.47],[40.2,15.01],[41.18,14.62],[43.3,12.46],[43.34,12.03],[42.54,11.51],[43.16,11.57],[44.28,10.47],[44.94,10.44],[45.82,10.84],[46.56,10.75],[47.4,11.17],[50.11,11.53],[50.79,11.98],[51.26,11.83],[51.03,10.44],[51.39,10.39],[50.93,10.34],[50.82,9.43],[47.98,4.5],[46.05,2.47],[43.72,0.86],[41.39,-1.87],[40.22,-2.69],[39.23,-4.67],[38.8,-6.07],[39.54,-7.02],[39.29,-7.52],[39.3,-8.44],[39.72,-10],[40.61,-10.66],[40.43,-12.94],[40.83,-14.79],[39.84,-16.44],[37.51,-17.57],[36.41,-18.77],[34.95,-19.81],[34.65,-19.7],[35.31,-22.4],[35.45,-22.12],[35.54,-22.3],[35.44,-24.17],[34.99,-24.65],[32.79,-25.64],[32.59,-26],[32.85,-26.27],[32.96,-26.08],[32.89,-26.83],[32.38,-28.5],[31.34,-29.38],[29.97,-31.32],[27.86,-33.05],[26.61,-33.71],[25.81,-33.74],[25.57,-34.04],[22.55,-34.01],[21.79,-34.37],[19.64,-34.75],[19.39,-34.6],[19.3,-34.62],[19.33,-34.49],[19.24,-34.41],[19.15,-34.42],[19.1,-34.35],[18.83,-34.36],[18.81,-34.11],[18.75,-34.08],[18.53,-34.09],[18.46,-34.17],[18.46,-34.35],[18.41,-34.3],[18.33,-34.07],[18.35,-33.94],[18.47,-33.89],[18.43,-33.72],[18.26,-33.42],[18.16,-33.36],[17.88,-32.96],[17.85,-32.83],[17.89,-32.75],[17.97,-32.71],[18.04,-32.78],[18.12,-32.75],[18.25,-32.65],[18.33,-32.5],[18.21,-31.74],[16.74,-29.01],[15.29,-27.28],[14.5,-24.2],[14.46,-22.45],[11.78,-18],[11.75,-15.83],[12.55,-13.44],[13.79,-11.81],[13.83,-10.93],[13,-9.05],[13.38,-8.37],[12.28,-6.12],[13.07,-5.87],[12.45,-6],[12.24,-5.81],[11.78,-4.57],[9.72,-2.47],[10.06,-2.55],[9.62,-2.37],[9.04,-1.31],[9.5,-1.55],[9.06,-1.3],[8.7,-0.59],[8.95,-0.69],[9.3,-0.35],[9.35,0.34],[9.8,0.04],[10,0.2],[9.33,0.55],[9.62,0.58],[9.6,1.05],[9.39,1.14],[9.81,1.93],[9.95,3.08],[9.56,3.8],[9.69,4.06],[9,4.09],[8.92,4.55],[8.57,4.53],[8.25,4.92],[8.29,4.56],[7.08,4.72],[6.92,4.39],[6.77,4.72],[6.86,4.37],[6.08,4.29],[5.49,4.84],[5.37,5.34],[5.55,5.47],[5.2,5.53],[5.46,5.61],[5.11,5.64],[4.86,6.03],[4.43,6.35],[4.13,6.41],[3.45,6.43],[3.75,6.58],[3.72,6.6],[3.43,6.52],[3.34,6.4],[1.82,6.26],[-2,4.76],[-3.25,5.11],[-3.02,5.13],[-3.2,5.35],[-3.35,5.13],[-5.28,5.21],[-5.06,5.13],[-7.54,4.35],[-8.26,4.59],[-11.73,7.09],[-12.49,7.39],[-12.48,7.75],[-12.85,7.82],[-13.27,8.43],[-12.89,8.63],[-13.18,8.58],[-13.06,8.88],[-13.69,9.54],[-13.69,9.93],[-14.43,10.25],[-14.59,10.77],[-14.89,10.97],[-15.01,10.8],[-15.05,11.14],[-15.39,11.22],[-15.43,11.5],[-15.07,11.6],[-15.5,11.78],[-15.08,11.97],[-15.94,11.79],[-16.79,12.47],[-16.44,12.61],[-16.77,12.63],[-16.75,13.43],[-16.41,13.27],[-15.43,13.47],[-16.44,13.35],[-16.77,13.9],[-16.62,14.04],[-17.53,14.75],[-16.57,15.73],[-16.08,17.55],[-16.09,18.52],[-16.52,19.36],[-16.21,20.23],[-16.88,21.09],[-17.1,20.86],[-16.93,21.9],[-16.36,22.59],[-15.9,23.84],[-14.91,24.72],[-14.47,26.16],[-13.58,26.74],[-12.95,27.91],[-11.55,28.31],[-10.2,29.38],[-9.67,30.11],[-9.81,31.42],[-9.25,32.57],[-8.51,33.25],[-6.9,33.97],[-5.92,35.79],[-5.28,35.9],[-5.25,35.61],[-4.63,35.21],[-2.97,35.41],[-2.84,35.13],[-1.91,35.09],[1.26,36.52],[3.78,36.9],[5.29,36.65],[6.49,37.09],[7.91,36.86],[9.69,37.34],[9.83,37.14],[10.2,37.21],[10.41,36.73],[10.95,37.06],[11.13,36.87],[10.49,36.26],[11.12,35.24],[10.06,34.21],[10.31,33.73],[10.96,33.63],[11.2,33.25],[12.28,32.86],[13.28,32.92],[15.18,32.39],[15.71,31.43],[17.83,30.93],[18.94,30.29],[19.59,30.41],[20.01,30.8],[19.93,31.82],[20.12,32.22],[21.63,32.94],[23.09,32.62],[23.29,32.21],[24.88,31.98],[25.23,31.53],[26.77,31.47],[29.07,30.83],[30.22,31.26],[30.57,31.47],[30.92,31.57],[30.56,31.42],[31,31.46],[31.08,31.6],[32.14,31.34],[31.89,31.48],[31.77,31.29],[32.01,31.22],[32.1,31.09],[32.28,31.2],[32.21,31.29],[32.6,31.07],[33.67,31.13],[34.48,31.59],[35.98,34.55],[35.81,36.31],[36.18,36.81],[35.39,36.57],[34.7,36.82],[33.69,36.18],[32.79,36.04],[31.24,36.82],[30.65,36.87],[30.45,36.27],[29.69,36.16],[28.97,36.72],[27.46,36.71],[28.24,37.03],[27.26,36.98],[27.53,37.16],[27.07,37.66],[27.23,37.98],[26.29,38.28],[26.44,38.64],[26.67,38.34],[27.14,38.45],[26.76,38.71],[27.01,38.89],[26.68,39.29],[26.9,39.55],[26.09,39.52],[26.18,39.99],[26.74,40.4],[27.73,40.33],[27.85,40.38],[27.73,40.48],[27.99,40.49],[27.93,40.38],[27.96,40.37],[29.01,40.39],[29.05,40.42],[28.79,40.53],[29.05,40.65],[29.85,40.74],[29.36,40.81],[29.12,40.94],[29.05,41.01],[29.15,41.22],[29.92,41.15],[30.35,41.2],[31.25,41.11],[33.28,42],[35,42.06],[35.3,41.73],[36.05,41.68],[36.41,41.27],[38.38,40.93],[39.43,41.11],[40.13,40.94],[41.41,41.42],[41.76,41.97],[41.42,42.74],[38.72,44.29],[36.63,45.15],[36.87,45.43],[37.65,45.38],[37.93,46],[38.49,46.09],[37.77,46.64],[38.5,46.66],[38.44,46.81],[39.27,47.04],[39.02,47.27],[35.83,46.62],[35.02,46.11],[35.23,46.44],[34.85,46.19],[35.02,45.7],[35.46,45.32],[36.57,45.39],[36.39,45.07],[35.47,45.1],[33.91,44.39],[33.45,44.55],[33.55,45.1],[32.51,45.4],[33.67,45.95],[33.59,46.1],[31.83,46.28],[32.01,46.43],[31.56,46.56],[32.58,46.62],[32.05,46.64],[31.76,47.21],[31.87,46.65],[30.8,46.55],[30.22,45.87],[29.63,45.72],[29.56,44.84],[28.89,44.92],[28.56,43.5],[28.13,43.4],[27.89,42.75],[27.48,42.47],[27.98,42.05],[27.99,41.86],[28.2,41.56],[29.06,41.23],[28.96,41.01],[28.78,40.97],[28.17,41.08],[27.92,40.99],[27.5,40.97],[27.43,40.84],[26.2,40.07],[26.79,40.63],[24.48,40.95],[23.76,40.75],[24.34,40.15],[23.73,40.33],[23.95,39.97],[23.43,40.26],[23.63,39.92],[22.81,40.58],[22.59,40.04],[23.23,39.36],[23.33,39.18],[23.22,39.1],[23.12,39.13],[23.16,39.26],[22.99,39.33],[22.84,39.26],[22.97,39.03],[23.07,39.04],[22.8,38.9],[22.57,38.87],[23.25,38.66],[23.37,38.53],[23.57,38.49],[23.68,38.35],[23.97,38.27],[24.06,37.82],[24.05,37.71],[23.97,37.68],[23.5,38.03],[23.03,37.88],[23.15,37.8],[23.2,37.62],[23.39,37.58],[23.49,37.44],[23.16,37.33],[23.1,37.36],[23.1,37.44],[22.94,37.52],[22.78,37.59],[22.73,37.54],[23.06,36.85],[23.04,36.64],[23.11,36.55],[22.83,36.69],[22.78,36.79],[22.72,36.79],[22.49,36.45],[22.08,37.03],[21.89,36.74],[21.58,37.08],[21.68,37.39],[21.12,37.89],[21.83,38.33],[22.24,38.19],[22.92,37.96],[22.89,38.05],[23.12,38.07],[23.18,38.13],[23.15,38.18],[22.83,38.23],[22.42,38.44],[22.23,38.35],[21.11,38.39],[20.77,38.87],[21.12,39.03],[20.3,39.33],[19.85,40.04],[19.4,40.28],[19.58,41.79],[18.65,42.44],[17.04,43.02],[17.72,42.85],[16.9,43.39],[15.99,43.52],[15.19,44.17],[15.47,44.27],[14.55,45.3],[14.31,45.34],[13.86,44.84],[13.52,45.48],[13.78,45.63],[13.63,45.77],[12.27,45.45],[12.52,44.97],[12.25,44.72],[12.4,44.22],[13.56,43.57],[14.01,42.69],[14.54,42.24],[15.17,41.93],[16.17,41.9],[15.9,41.51],[17.96,40.65],[18.48,40.1],[18.34,39.82],[17.87,40.28],[16.93,40.46],[16.52,39.75],[17.11,39.38],[17.17,39],[16.62,38.8],[16.06,37.94],[15.72,37.94],[15.64,38.18],[16.21,38.94],[15.69,39.99],[14.95,40.24],[14.77,40.67],[14.34,40.6],[14.46,40.73],[14.05,40.81],[13.86,41.13],[13.67,41.26],[13.25,41.29],[13.09,41.24],[12.85,41.41],[12.63,41.47],[12.08,41.94],[11.81,42.08],[11.64,42.29],[11.3,42.42],[11.1,42.42],[11.18,42.46],[11.17,42.53],[10.51,42.97],[10.19,43.95],[9.73,44.1],[9.29,44.32],[8.76,44.42],[8.55,44.35],[8.29,44.14],[6.72,43.37],[6.57,43.2],[6.11,43.07],[5.81,43.1],[5.41,43.23],[5.32,43.35],[5.07,43.37],[5.06,43.44],[4.71,43.37],[4.22,43.48],[4.05,43.59],[3.91,43.56],[3.16,43.08],[3.09,42.59],[3.31,42.29],[3.17,42.26],[3.15,42.16],[3.24,42.08],[3.25,41.94],[3,41.77],[2.31,41.47],[2.08,41.29],[1.03,41.06],[0.71,40.82],[0.89,40.72],[-0.33,39.52],[0.2,38.76],[-0.52,38.32],[-0.72,37.63],[-1.64,37.39],[-2.19,36.74],[-4.37,36.72],[-5.63,36.03],[-6.38,36.64],[-6.22,36.91],[-6.86,37.28],[-7.84,37.01],[-8.93,37.17],[-8.81,37.43],[-8.79,37.73],[-8.88,37.96],[-8.8,38.18],[-8.88,38.45],[-8.67,38.42],[-8.8,38.52],[-9.21,38.45],[-9.25,38.66],[-9.02,38.75],[-8.94,39],[-8.79,39.08],[-8.96,39.02],[-9.14,38.74],[-9.36,38.7],[-9.47,38.73],[-9.48,38.8],[-9.35,39.25],[-9.38,39.34],[-9.15,39.54],[-8.84,40.12],[-8.87,40.26],[-8.66,41.03],[-8.89,42.11],[-8.69,42.27],[-9.18,43.17],[-7.7,43.77],[-7.06,43.55],[-1.99,43.35],[-1.49,43.56],[-1.08,44.69],[-1.24,44.67],[-1.08,45.53],[-0.55,45],[-1.2,45.71],[-1.03,45.74],[-1.15,46.31],[-2.09,46.87],[-2.11,47.26],[-1.74,47.22],[-4.31,47.82],[-4.68,48.04],[-4.33,48.17],[-4.58,48.29],[-4.24,48.3],[-4.72,48.54],[-3.23,48.84],[-2.69,48.54],[-1.38,48.65],[-1.86,49.68],[-0.16,49.3],[0.44,49.47],[0.13,49.51],[0.19,49.7],[1.24,50],[1.59,50.25],[1.67,50.88],[3.72,51.37],[4.22,51.39],[4.01,51.44],[3.82,51.41],[3.69,51.45],[3.55,51.59],[3.89,51.57],[4.14,51.46],[4.28,51.47],[4.01,51.6],[4.18,51.61],[3.95,51.81],[4.08,51.99],[4.48,52.31],[4.77,52.94],[4.89,52.91],[5.06,52.96],[5.36,53.1],[5.53,53.27],[6.06,53.41],[7.2,53.28],[7.21,53.66],[7.63,53.7],[8.49,53.39],[8.62,53.88],[9.78,53.55],[8.65,54.29],[8.96,54.54],[8.68,54.79],[8.62,55.42],[8.13,55.6],[8.16,56.61],[9.2,56.7],[9.11,57.04],[8.77,56.72],[8.27,56.81],[10.53,57.73],[10.28,56.62],[10.9,56.36],[9.91,55.84],[9.46,55.04],[10.02,54.67],[9.87,54.47],[11.01,54.38],[10.86,54.01],[12.11,54.17],[12.58,54.47],[13.03,54.41],[13.15,54.28],[13.82,54.02],[13.87,53.85],[13.95,53.8],[14.49,53.67],[14.56,53.82],[14.17,53.87],[13.93,53.88],[13.92,54],[13.83,54.06],[14.38,53.92],[18.08,54.84],[18.76,54.68],[18.44,54.75],[18.84,54.37],[19.41,54.39],[19.97,54.92],[20.68,55.1],[21.12,55.62],[20.59,54.98],[21.19,54.93],[21.03,56.64],[21.73,57.57],[22.56,57.72],[23.65,56.97],[24.4,57.33],[24.3,57.78],[24.49,58.26],[24.55,58.3],[24.53,58.35],[24.34,58.38],[24.11,58.27],[23.77,58.36],[23.69,58.51],[23.51,58.66],[23.68,58.79],[23.5,58.79],[23.43,58.92],[23.51,59],[23.47,59.03],[23.52,59.11],[23.5,59.19],[24.08,59.29],[24.05,59.37],[24.38,59.47],[25.44,59.52],[25.52,59.56],[25.51,59.64],[27.89,59.41],[28.06,59.78],[30.17,59.96],[28.64,60.38],[28.51,60.68],[26.45,60.47],[26.21,60.41],[25.95,60.47],[26.04,60.34],[25.76,60.27],[25.66,60.33],[24.6,60.11],[24.45,60.02],[23.46,59.99],[23.18,59.84],[22.96,59.83],[23.2,60.02],[22.91,60.21],[22.46,60.03],[22.58,60.38],[21.44,60.6],[21.61,61.59],[21.12,62.69],[21.65,63.04],[21.54,63.21],[22.32,63.31],[22.53,63.65],[23.6,64.04],[24.56,64.8],[25.29,64.86],[25.35,65.48],[24.63,65.86],[22.4,65.86],[22.25,65.6],[21.41,65.32],[21.57,65.13],[21.14,64.81],[21.52,64.46],[20.76,63.87],[18.61,63.18],[18.17,62.79],[17.88,62.87],[18.04,62.6],[17.38,62.46],[17.63,62.23],[17.47,61.68],[17.13,61.57],[17.25,60.7],[17.36,60.64],[17.56,60.64],[17.66,60.54],[17.96,60.59],[18.16,60.41],[18.56,60.25],[18.53,60.15],[18.79,60.08],[18.93,59.94],[18.97,59.76],[18.28,59.44],[17.97,59.36],[18.13,59.32],[18.51,59.41],[18.62,59.33],[18.42,59.29],[18.29,59.11],[17.76,58.97],[16.98,58.65],[16.64,58.65],[16.21,58.64],[16.79,58.59],[16.93,58.49],[16.82,58.46],[16.65,58.43],[16.53,57.07],[16,56.22],[14.72,56.13],[14.26,55.89],[14.34,55.53],[14.08,55.39],[13.81,55.43],[13.32,55.35],[12.89,55.41],[12.94,55.48],[12.97,55.75],[12.47,56.29],[12.71,56.23],[12.8,56.26],[12.66,56.44],[12.86,56.45],[12.92,56.52],[12.88,56.62],[12.72,56.66],[12.42,56.91],[11.25,58.42],[11.21,58.87],[11.15,58.99],[11.19,59.08],[11.39,59.04],[11.37,59.1],[10.83,59.18],[10.64,59.39],[10.6,59.76],[10.54,59.7],[10.57,59.59],[10.4,59.52],[10.46,59.38],[10.43,59.28],[10.18,59.01],[9.84,58.96],[9.64,59.12],[9.56,59.11],[9.7,59.01],[9.62,58.95],[8.17,58.14],[7,58.02],[6.9,58.07],[6.88,58.15],[6.8,58.16],[6.73,58.07],[6.59,58.1],[6.55,58.12],[6.69,58.22],[6.66,58.26],[6.39,58.27],[6.05,58.38],[5.71,58.52],[5.52,58.73],[5.56,58.97],[5.61,59.01],[6.1,58.87],[6.36,59],[6.1,58.95],[5.89,59.1],[5.97,59.19],[5.95,59.3],[6.4,59.56],[5.56,59.29],[5.36,59.17],[5.17,59.16],[5.13,59.23],[5.19,59.45],[5.3,59.64],[5.47,59.71],[5.77,59.66],[5.87,59.73],[6.22,59.82],[5.83,59.8],[5.73,59.86],[6.07,60.08],[6.14,60.23],[6.35,60.35],[6.53,60.21],[6.53,60.15],[7,60.51],[6.35,60.42],[6.15,60.35],[5.91,60.15],[5.88,60.07],[5.7,60.01],[5.5,59.83],[5.15,59.64],[5.12,59.83],[5.22,59.98],[5.18,60.05],[5.21,60.09],[5.5,60.07],[5.69,60.12],[5.29,60.21],[5.14,60.44],[5.65,60.69],[5.12,60.64],[5.1,61.07],[6.78,61.14],[7.04,60.95],[7.61,61.21],[7.44,61.43],[7.17,61.17],[5.11,61.19],[5,61.43],[5.34,61.48],[4.93,61.88],[6.73,61.87],[5.27,61.94],[5.14,62.16],[6.69,62.47],[6.14,62.41],[6.35,62.61],[8.09,62.73],[6.73,62.72],[7.57,63.1],[8.62,62.85],[8.16,63.16],[8.63,63.34],[8.36,63.5],[8.58,63.6],[9.7,63.63],[10.02,63.39],[11.37,63.81],[11.18,63.9],[11.31,64.05],[10.06,63.51],[9.57,63.71],[11.63,64.81],[11.3,64.76],[11.49,64.98],[12.92,65.34],[12.42,65.18],[12.12,65.36],[13.03,65.96],[12.79,66.1],[14.03,66.3],[13.12,66.23],[13.21,66.64],[13.96,66.8],[13.65,66.91],[15.42,67.2],[14.44,67.27],[14.96,67.57],[15.59,67.35],[15.69,67.52],[15.25,67.6],[15.31,67.77],[14.78,67.68],[15.05,67.96],[15.62,67.95],[15.29,68.04],[16.01,68.23],[16.31,67.88],[16.21,68.32],[17.57,68.45],[16.58,68.59],[18.1,69.16],[18.26,69.47],[18.92,69.33],[18.61,69.49],[19.2,69.75],[19.72,69.78],[19.64,69.42],[20.32,69.95],[20.05,69.33],[20.74,69.52],[20.62,69.91],[21.98,69.83],[21.36,70.23],[22.69,70.37],[23.36,69.98],[23.38,70.25],[24.66,71],[25.77,70.85],[25.04,70.11],[26.51,70.91],[26.74,70.85],[26.58,70.41],[27.55,70.8],[27.33,71],[28.14,71.04],[28.38,70.87],[27.9,70.68],[28.27,70.67],[28.19,70.25],[28.83,70.86],[30.96,70.34],[28.78,70.15],[29.6,69.98],[29.69,69.74],[31.45,69.69],[31.98,69.95],[33.01,69.72],[32.09,69.63],[32.38,69.48],[33.45,69.43],[33.14,69.07],[33.68,69.31],[35.86,69.19],[40.97,67.71],[41.36,67.21],[41.19,66.83],[40.1,66.3],[38.66,66.07],[34.48,66.55],[32.93,67.09],[31.89,67.16],[33.65,66.44],[33.36,66.33],[34.69,65.95],[34.41,65.4],[35.03,64.44],[37.44,63.81],[38.06,64.09],[37.95,64.32],[37.18,64.41],[36.58,64.79],[36.88,65.17],[39.76,64.58],[40.44,64.78],[39.8,65.35],[39.82,65.6],[42.21,66.52],[43.23,66.41],[44.11,66.01],[44.43,66.94],[43.78,67.26],[44.2,68.25],[43.33,68.67],[45.89,68.48],[46.69,67.85],[45.53,67.76],[44.9,67.41],[46.49,66.8],[47.66,66.98],[47.88,67.58],[48.83,67.68],[48.75,67.9],[51.99,68.54],[52.4,68.35],[52.72,68.48],[52.34,68.61],[53.8,69],[54.49,68.99],[53.8,68.91],[53.93,68.44],[53.26,68.27],[54.86,68.2],[55.42,68.57],[57.13,68.55],[59.06,69.01],[59.37,68.74],[59.1,68.44],[59.73,68.35],[59.9,68.71],[60.93,68.99],[60.17,69.59],[60.91,69.85],[64.19,69.53],[68.5,68.35],[69.14,68.95],[68.54,68.97],[67.62,69.58],[66.9,69.55],[67.29,70.74],[66.7,70.82],[66.85,71.06],[66.64,71.08],[68.27,71.68],[69.39,72.96],[71.5,72.91],[72.81,72.69],[72.57,72.01],[71.87,71.46],[72.7,70.96],[72.47,70.28],[72.58,68.97],[73.59,68.48],[73.14,68.18],[73.07,67.77],[71.85,67.01],[71.37,66.96],[71.54,66.68],[70.72,66.52],[70.38,66.6],[70.69,66.74],[69.01,66.79],[69.98,66.4],[72.07,66.25],[73.79,66.99],[74.77,67.77],[74.39,68.42],[74.58,68.75],[75.12,68.86],[76.46,68.98],[77.24,68.47],[77.18,67.78],[78.92,67.59],[77.59,67.75],[77.67,68.19],[78,68.26],[77.65,68.9],[76,69.24],[73.78,69.2],[73.89,69.42],[73.58,69.8],[74.34,70.58],[73.09,71.44],[73.67,71.85],[74.99,72.15],[75.1,72.42],[74.79,72.81],[75.6,72.58],[75.74,72.3],[75.27,71.96],[75.5,71.65],[75.28,71.43],[75.73,71.27],[79.02,70.95],[76.43,71.55],[76.03,71.91],[78.19,71.91],[77.41,72.11],[78.48,72.4],[79.42,72.38],[81.66,71.72],[83.11,71.72],[82.98,71.45],[82.32,71.26],[82.16,70.6],[82.22,70.4],[82.59,70.89],[83.01,70.9],[82.68,70.22],[83.08,70.09],[83.74,70.55],[83.15,71.1],[83.53,71.68],[80.83,72.49],[80.66,72.71],[80.84,72.95],[80.42,73.23],[80.58,73.57],[86.89,73.89],[85.79,73.44],[86.68,73.11],[85.91,73.39],[87.57,73.81],[86,74.32],[87.23,74.36],[85.79,74.65],[87.47,75.01],[87.01,75.17],[94.16,75.96],[92.86,75.98],[93.26,76.1],[95.58,76.14],[96.08,76.08],[95.65,75.89],[96.5,75.89],[98.66,76.24],[99.77,76.03],[99.54,75.8],[99.82,76.14],[98.8,76.48],[101.6,76.44],[100.93,76.56],[101.1,76.7],[100.91,76.9],[104.01,77.73],[106.06,77.39],[104.2,77.1],[107.43,76.93],[106.42,76.51],[111.11,76.72],[112.62,76.38],[112.66,76.05],[113.27,76.25],[113.56,75.89],[113.86,75.92],[113.57,75.57],[112.45,75.83],[113.73,75.45],[112.92,75.02],[107.27,73.62],[105.14,72.78],[110.87,73.73],[109.67,73.8],[110.26,74.02],[111.55,74.03],[111.23,73.97],[112.15,73.71],[113.03,73.91],[113.42,73.65],[113.16,73.46],[113.49,73.35],[113.16,72.77],[113.67,72.64],[113.22,72.81],[113.89,73.35],[113.51,73.5],[114.06,73.58],[118.45,73.59],[118.94,73.48],[118.46,73.46],[118.43,73.25],[119.75,72.98],[122.54,72.88],[123.62,73.19],[123.32,73.43],[123.41,73.64],[124.54,73.75],[126.55,73.33],[127.74,73.48],[129.1,73.11],[128.6,72.9],[129.25,72.7],[128.42,72.53],[129.28,72.44],[129.28,72.09],[127.73,72.41],[128.91,71.75],[129.21,71.92],[129.46,71.74],[128.84,71.66],[129.76,71.12],[131.02,70.75],[132.04,71.24],[132.65,71.93],[133.69,71.43],[136.09,71.62],[137.94,71.13],[138.32,71.33],[137.92,71.38],[138.23,71.6],[139.99,71.49],[139.72,71.89],[139.36,71.95],[140.19,72.19],[139.18,72.16],[139.14,72.33],[141.08,72.59],[140.65,72.84],[140.81,72.89],[146.25,72.44],[144.29,72.19],[146.83,72.29],[146.11,71.95],[146.23,72.14],[145.76,72.23],[145.76,71.94],[145.07,71.93],[145.19,71.7],[147.26,72.33],[149.5,72.16],[150.02,71.9],[148.92,71.71],[150.67,71.45],[150.1,71.23],[151.58,71.29],[152.09,71.02],[151.76,70.98],[152.51,70.83],[155.89,71.1],[158.7,70.94],[159.91,70.51],[159.83,69.78],[160.91,69.61],[161.34,68.9],[160.86,68.54],[161.56,68.9],[161.54,69.38],[163.2,69.72],[166.89,69.5],[167.86,69.73],[168.3,69.27],[169.31,69.08],[169.61,68.79],[170.54,68.83],[171,69.14],[170.58,69.58],[170.16,69.63],[170.49,70.11],[173.28,69.82],[175.92,69.9],[179.87,69.01]],[[-94.31,71.77],[-93.03,71.34],[-92.98,70.85],[-91.57,70.18],[-92.32,70.24],[-92.51,70.1],[-91.98,70.04],[-92.89,69.67],[-90.42,69.46],[-91.24,69.29],[-90.48,68.88],[-90.58,68.48],[-90.25,68.27],[-89.28,69.26],[-88.04,68.81],[-87.81,68.35],[-88.35,68.29],[-88.31,67.95],[-87.36,67.18],[-86.56,67.48],[-85.69,68.67],[-84.87,68.77],[-85.11,68.84],[-84.86,69.07],[-85.39,69.23],[-85.51,69.85],[-82.62,69.69],[-82.37,69.64],[-82.76,69.49],[-82.23,69.25],[-81.32,69.14],[-81.96,68.88],[-81.28,68.66],[-82.55,68.45],[-81.29,67.5],[-81.39,67.19],[-82.64,66.59],[-83.52,66.37],[-84.85,67.03],[-85.11,66.89],[-84.64,66.9],[-83.8,66.24],[-86.71,66.52],[-85.96,66.12],[-87.45,65.34],[-89.75,65.94],[-91.43,65.95],[-87,65.11],[-88.11,64.18],[-89.13,63.97],[-90.04,64.14],[-89.86,63.96],[-90.17,63.98],[-90.01,63.8],[-90.24,63.64],[-93.7,64.15],[-93.56,63.86],[-92.16,63.69],[-92.47,63.56],[-91.84,63.7],[-90.97,63.44],[-90.7,63.06],[-92.36,62.82],[-91.94,62.59],[-92.55,62.55],[-92.77,62.35],[-92.53,62.17],[-93.21,62.36],[-92.9,62.22],[-93.58,61.94],[-93.31,61.77],[-93.91,61.48],[-94.76,60.5],[-94.96,59.07],[-94.29,58.72],[-94.33,58.3],[-94.12,58.74],[-93.18,58.73],[-92.43,57.32],[-92.8,56.92],[-90.59,57.22],[-88.83,56.81],[-87.48,56.02],[-85.68,55.6],[-85.22,55.35],[-85.37,55.08],[-83.91,55.31],[-82.39,55.07],[-82.22,54.81],[-82.42,54.24],[-82.14,53.82],[-82.29,53.03],[-81.6,52.43],[-81.83,52.22],[-80.59,51.67],[-80.44,51.39],[-80.85,51.12],[-80.1,51.28],[-79.35,50.76],[-79.74,51.19],[-79.34,51.63],[-78.9,51.2],[-78.73,51.5],[-78.98,51.78],[-78.45,52.26],[-79.1,53.66],[-79.01,54.02],[-79.71,54.67],[-77.78,55.29],[-76.55,56.36],[-76.57,57.18],[-76.89,57.76],[-78.51,58.68],[-77.73,59.68],[-77.35,59.58],[-77.29,60.02],[-77.59,60.09],[-77.68,60.43],[-77.5,60.54],[-77.79,60.64],[-77.59,60.81],[-78.18,60.82],[-77.51,61.56],[-78.02,61.83],[-78.13,62.28],[-77.37,62.57],[-74.63,62.11],[-73.71,62.47],[-72.69,62.13],[-72.77,61.84],[-72.23,61.83],[-72.04,61.68],[-72.21,61.59],[-71.64,61.62],[-71.85,61.44],[-71.42,61.16],[-69.99,60.86],[-69.5,61.04],[-69.67,60.08],[-70.66,60.03],[-69.73,59.92],[-69.68,59.34],[-69.35,59.3],[-69.53,58.87],[-70.16,58.76],[-68.38,58.74],[-68.36,58.16],[-69.04,57.9],[-68.41,58.05],[-68.02,58.48],[-68.06,58.14],[-67.75,58.4],[-67.68,57.99],[-66.36,58.79],[-66,58.43],[-66.04,58.82],[-65.38,59.06],[-65.7,59.21],[-65.48,59.47],[-65.04,59.39],[-65.43,59.78],[-65.03,59.77],[-65.17,59.91],[-64.82,60.33],[-64.5,60.27],[-64.77,60.01],[-64.28,60.06],[-64.23,59.74],[-63.75,59.51],[-63.95,59.38],[-63.42,59.19],[-63.97,59.05],[-63.25,59.07],[-63.28,58.87],[-62.87,58.67],[-63.54,58.33],[-62.61,58.5],[-63.26,58.01],[-62.49,58.15],[-61.96,57.91],[-61.97,57.61],[-62.49,57.49],[-61.33,57.01],[-61.37,56.68],[-62.5,56.8],[-61.43,56.36],[-61.71,56.23],[-61.36,56.22],[-61.45,56],[-60.34,55.79],[-60.19,55.48],[-60.62,55.06],[-59.76,55.31],[-59.44,55.18],[-59.84,54.81],[-59.26,55.2],[-58.78,54.84],[-57.96,54.88],[-57.4,54.59],[-60.4,53.65],[-60.1,53.49],[-60.33,53.27],[-57.93,54.1],[-58.36,54.16],[-58.19,54.23],[-57.42,54.16],[-57.13,53.79],[-57.52,53.61],[-57.33,53.47],[-56.46,53.76],[-55.86,53.34],[-55.8,52.64],[-56.32,52.54],[-55.74,52.47],[-56.01,52.39],[-55.69,52.14],[-56.98,51.46],[-58.51,51.29],[-59.88,50.32],[-61.72,50.1],[-62.71,50.3],[-66.41,50.22],[-66.94,49.99],[-67.37,49.35],[-68.28,49.2],[-69.67,48.2],[-71.02,48.46],[-69.77,48.1],[-70.71,47.14],[-72.68,46.29],[-72.98,46.21],[-73.02,46.12],[-73.14,46.07],[-73.47,45.74],[-73.71,45.71],[-74.04,45.5],[-74.31,45.53],[-74,45.43],[-73.98,45.35],[-74.36,45.21],[-74.71,45],[-73.76,45.4],[-73.56,45.42],[-73.46,45.63],[-73.16,46.01],[-72.73,46.18],[-72.37,46.4],[-70.52,47.03],[-69.47,47.97],[-68.24,48.63],[-65.4,49.26],[-64.26,48.92],[-64.51,48.84],[-64.26,48.55],[-65.26,48.02],[-65.93,48.19],[-66.7,48.02],[-65.61,47.67],[-64.7,47.73],[-65.32,47.1],[-64.83,47.06],[-64.54,46.24],[-62.75,45.65],[-61.95,45.87],[-61.35,45.57],[-61.46,45.37],[-61.03,45.29],[-63.6,44.68],[-63.61,44.48],[-64.29,44.55],[-64.86,43.87],[-65.74,43.56],[-66.13,43.81],[-66.02,44.56],[-64.45,45.34],[-64.14,45.02],[-63.37,45.36],[-64.87,45.36],[-64.32,45.84],[-64.63,45.95],[-64.78,45.64],[-65.89,45.22],[-66.03,45.42],[-66.44,45.1],[-67.12,45.17],[-66.99,44.83],[-68.06,44.39],[-68.45,44.51],[-68.53,44.26],[-68.81,44.34],[-68.76,44.57],[-69.14,44.04],[-70.27,43.67],[-70.2,43.63],[-70.52,43.35],[-70.73,43.07],[-70.83,42.83],[-70.74,42.67],[-70.62,42.67],[-70.61,42.62],[-70.83,42.55],[-71.04,42.33],[-70.74,42.23],[-70.62,42.04],[-70.66,41.99],[-70.55,41.94],[-70.52,41.8],[-70.43,41.76],[-70.3,41.73],[-70,41.83],[-70.11,42.03],[-70.24,42.09],[-70.11,42.08],[-69.98,41.96],[-69.93,41.71],[-70.66,41.53],[-70.7,41.72],[-71.17,41.49],[-71.2,41.64],[-71.15,41.75],[-71.27,41.68],[-71.39,41.79],[-71.37,41.7],[-71.43,41.63],[-71.44,41.45],[-71.52,41.38],[-72.92,41.28],[-73.58,41.02],[-73.99,40.75],[-73.87,41.06],[-73.88,41.17],[-73.97,41.25],[-73.92,41.14],[-73.93,40.91],[-74.26,40.53],[-74.24,40.46],[-74,40.45],[-73.97,40.4],[-74.08,39.79],[-74.07,39.99],[-74.26,39.61],[-74.33,39.54],[-74.41,39.55],[-74.39,39.49],[-74.48,39.34],[-74.58,39.32],[-74.61,39.25],[-74.92,38.94],[-74.9,39.15],[-75.52,39.49],[-75.07,39.98],[-75.17,39.89],[-75.32,39.86],[-75.57,39.48],[-75.04,38.43],[-75.93,37.15],[-75.66,37.95],[-75.85,37.97],[-75.86,38.36],[-76.12,38.32],[-76.26,38.44],[-76.26,38.6],[-76,38.6],[-76.21,38.76],[-76.28,38.77],[-76.34,38.71],[-76.3,38.82],[-76.17,38.85],[-76.19,38.91],[-76.33,38.91],[-76.33,38.95],[-76.31,39.01],[-76.19,38.99],[-76.13,39.12],[-76.22,39.06],[-76.24,39.19],[-76.15,39.32],[-75.94,39.4],[-76,39.41],[-75.97,39.51],[-76.01,39.57],[-76.06,39.56],[-76.1,39.43],[-76.21,39.38],[-76.25,39.44],[-76.28,39.32],[-76.33,39.4],[-76.42,39.23],[-76.57,39.27],[-76.43,39.13],[-76.47,39.03],[-76.56,39.07],[-76.5,38.94],[-76.54,38.74],[-76.5,38.53],[-76.39,38.37],[-76.57,38.44],[-76.68,38.61],[-76.67,38.54],[-76.64,38.45],[-76.41,38.27],[-76.34,38.09],[-76.46,38.17],[-76.77,38.26],[-76.87,38.39],[-76.89,38.29],[-77,38.44],[-77.23,38.41],[-77.22,38.54],[-77.02,38.78],[-77.03,38.89],[-77.05,38.78],[-77.26,38.6],[-77.31,38.4],[-77.27,38.35],[-77.05,38.36],[-76.91,38.2],[-76.55,38.09],[-76.35,37.96],[-76.34,37.68],[-76.79,37.94],[-76.94,38.1],[-77.11,38.16],[-76.62,37.76],[-76.27,37.49],[-76.45,37.27],[-76.76,37.51],[-76.34,37.01],[-77.25,37.33],[-76.49,36.9],[-76,36.91],[-75.53,35.82],[-75.95,36.66],[-75.82,36.11],[-76.15,36.28],[-76.56,36.02],[-76.73,36.23],[-76.73,35.96],[-76.07,35.97],[-76.08,35.69],[-75.76,35.84],[-76.17,35.35],[-77.04,35.53],[-76.51,35.27],[-76.78,34.99],[-77.07,35.15],[-76.97,35.02],[-76.44,34.84],[-77.41,34.73],[-77.93,33.94],[-77.95,34.17],[-78.01,33.91],[-78.84,33.72],[-79.94,32.67],[-80.64,32.51],[-80.58,32.29],[-80.8,32.45],[-80.69,32.22],[-81.44,31.2],[-81.25,29.79],[-80.52,28.49],[-80.46,27.9],[-80.84,28.76],[-80.05,26.81],[-80.13,25.83],[-80.16,25.88],[-80.3,25.62],[-80.37,25.33],[-80.48,25.23],[-80.74,25.16],[-81.11,25.14],[-81.17,25.23],[-81.14,25.31],[-80.97,25.22],[-80.94,25.26],[-81.11,25.37],[-81.37,25.83],[-81.72,25.98],[-81.96,26.49],[-81.83,26.69],[-82.04,26.55],[-82.01,26.96],[-82.29,26.87],[-82.72,27.5],[-82.41,27.86],[-82.84,27.85],[-82.65,28.89],[-84.04,30.1],[-85.32,29.68],[-85.6,30.29],[-86.45,30.4],[-86.26,30.49],[-87.2,30.34],[-87,30.57],[-88,30.23],[-87.79,30.29],[-88.01,30.69],[-88.13,30.37],[-89.59,30.17],[-90.23,30.38],[-90.28,30.06],[-89.4,30.05],[-89.35,29.82],[-89.72,29.62],[-89.02,29.2],[-89.38,28.98],[-90.16,29.54],[-90.21,29.1],[-91.29,29.29],[-91.25,29.56],[-91.89,29.84],[-92.26,29.56],[-93.83,29.72],[-93.88,29.81],[-93.81,29.85],[-93.79,29.98],[-93.84,29.98],[-93.94,29.81],[-93.89,29.69],[-94.1,29.67],[-94.76,29.38],[-94.53,29.55],[-94.78,29.55],[-94.74,29.75],[-94.83,29.75],[-94.89,29.68],[-95.02,29.7],[-94.99,29.53],[-94.89,29.37],[-95.14,29.17],[-95.15,29.08],[-95.27,28.96],[-95.85,28.64],[-96.23,28.49],[-96.01,28.63],[-96.37,28.66],[-96.45,28.59],[-96.58,28.72],[-96.42,28.46],[-97.16,28.14],[-97.07,27.99],[-97.43,27.84],[-97.44,27.33],[-97.77,27.46],[-97.48,27.24],[-97.14,26.03],[-97.67,24.39],[-97.86,22.62],[-97.31,21.56],[-97.41,21.27],[-97.75,22.03],[-97.64,21.6],[-95.92,18.82],[-95.18,18.7],[-94.46,18.17],[-92.44,18.67],[-91.53,18.46],[-91.27,18.62],[-91.44,18.89],[-90.74,19.35],[-90.35,21.01],[-88.47,21.57],[-87.04,21.59],[-86.82,21],[-87.69,19.64],[-87.43,19.58],[-87.85,18.27],[-88.03,18.84],[-88.35,18.36],[-88.08,18.23],[-88.31,16.63],[-88.89,15.89],[-88.13,15.7],[-87.7,15.91],[-86.91,15.76],[-84.97,15.99],[-84.26,15.82],[-83.76,15.22],[-83.37,15.24],[-83.19,14.34],[-83.57,13.32],[-83.51,12.41],[-83.59,12.71],[-83.75,12.5],[-83.83,11.13],[-82.24,9.03],[-81.78,8.96],[-81.9,9.14],[-81.55,8.83],[-81.06,8.81],[-80.84,8.89],[-80.55,9.08],[-80.13,9.21],[-79.58,9.6],[-79.11,9.54],[-78.93,9.43],[-78.5,9.41],[-78.08,9.24],[-76.79,7.93],[-76.92,8.57],[-75.64,9.45],[-75.54,10.2],[-75.71,10.14],[-75.45,10.61],[-74.84,11.11],[-74.33,11],[-74.4,10.77],[-74.14,11.32],[-73.31,11.3],[-71.6,12.43],[-71.14,12.05],[-71.96,11.57],[-71.6,10.66],[-72.11,9.82],[-71.62,9.05],[-71.24,9.16],[-71.05,9.71],[-71.47,10.96],[-69.81,11.47],[-70.29,11.89],[-70,12.18],[-69.63,11.48],[-68.4,11.16],[-68.14,10.49],[-66.25,10.63],[-65.13,10.07],[-63.73,10.5],[-64.3,10.64],[-61.88,10.74],[-62.91,10.53],[-62.74,10.06],[-62.55,10.2],[-62.32,9.78],[-62.08,9.98],[-61.74,9.63],[-61.59,9.89],[-60.79,9.36],[-61.25,8.6],[-61.62,8.6],[-61.3,8.41],[-60.17,8.62],[-58.81,7.74],[-58.48,7.33],[-58.67,6.39],[-58.42,6.85],[-57.98,6.79],[-57.23,6.18],[-57.18,5.53],[-56.97,5.99],[-55.9,5.7],[-55.83,5.96],[-54.36,5.91],[-54.05,5.81],[-54.16,5.36],[-53.85,5.78],[-52.9,5.43],[-52.06,4.72],[-52,4.35],[-51.83,4.64],[-51.65,4.06],[-51.55,4.31],[-51.22,4.09],[-50.72,2.13],[-49.96,1.66],[-49.9,1.16],[-51.28,-0.08],[-51.98,-1.37],[-52.66,-1.55],[-51.95,-1.59],[-50.9,-0.94],[-50.4,-2.01],[-49.32,-1.73],[-49.64,-2.66],[-49.21,-1.92],[-48.35,-1.48],[-48.45,-1.15],[-48.12,-0.74],[-47.4,-0.63],[-45.46,-1.36],[-45.33,-1.72],[-45.08,-1.47],[-44.65,-1.75],[-44.54,-2.05],[-44.76,-2.26],[-44.44,-2.17],[-44.38,-2.37],[-44.72,-3.2],[-44.23,-2.47],[-44.19,-2.81],[-43.38,-2.38],[-42.25,-2.79],[-39.77,-2.99],[-39.02,-3.39],[-38.69,-3.65],[-38.48,-3.72],[-38.05,-4.22],[-37.63,-4.59],[-37.3,-4.71],[-36.59,-5.1],[-35.39,-5.25],[-34.83,-7.02],[-34.84,-7.97],[-35.34,-9.23],[-37.36,-11.25],[-38.02,-12.59],[-38.4,-12.97],[-38.69,-12.62],[-38.85,-12.79],[-39.09,-13.59],[-38.88,-15.86],[-39.16,-17.7],[-39.65,-18.25],[-39.78,-19.57],[-40.96,-21.24],[-41,-22],[-41.58,-22.24],[-41.98,-22.58],[-41.94,-22.79],[-42.04,-22.95],[-42.96,-22.97],[-43.08,-22.9],[-43.09,-22.72],[-43.23,-22.75],[-43.22,-22.99],[-43.9,-23.1],[-43.97,-23.06],[-43.68,-23.01],[-43.86,-22.91],[-44.15,-23.01],[-44.37,-23],[-45.21,-23.58],[-45.33,-23.6],[-45.46,-23.8],[-45.97,-23.79],[-46.87,-24.24],[-47.14,-24.49],[-47.59,-24.78],[-48.2,-25.42],[-48.73,-25.37],[-48.4,-25.6],[-48.75,-26.27],[-48.56,-27.2],[-48.8,-28.58],[-49.75,-29.36],[-50.92,-31.26],[-52.04,-32.12],[-52.06,-31.83],[-51.27,-31.48],[-50.58,-30.44],[-50.56,-30.25],[-51.03,-30.37],[-51.3,-30.04],[-51.28,-30.75],[-51.97,-31.38],[-52.65,-33.14],[-53.79,-34.38],[-54.9,-34.93],[-56.85,-34.68],[-57.17,-34.45],[-57.87,-34.45],[-58.4,-33.91],[-58.44,-33.72],[-58.36,-33.18],[-58.15,-33.07],[-58.2,-32.47],[-58.2,-33.01],[-58.25,-33.08],[-58.42,-33.11],[-58.55,-33.66],[-58.39,-34.19],[-58.52,-34.3],[-58.47,-34.46],[-58.28,-34.68],[-57.76,-34.89],[-57.3,-35.19],[-57.17,-35.36],[-57.16,-35.51],[-57.35,-35.72],[-57.26,-36.14],[-56.72,-36.39],[-56.67,-36.85],[-57.65,-38.17],[-59.83,-38.84],[-61.6,-39],[-62.34,-38.8],[-62.3,-39.24],[-62.05,-39.37],[-62.39,-40.89],[-63.62,-41.16],[-64.87,-40.74],[-65.13,-40.88],[-64.99,-42.1],[-64.42,-42.43],[-63.79,-42.11],[-63.62,-42.7],[-64.04,-42.88],[-64.49,-42.51],[-64.97,-42.67],[-64.32,-42.97],[-65.25,-43.57],[-65.29,-44.36],[-65.65,-44.66],[-65.64,-45.01],[-66.94,-45.26],[-67.6,-46.05],[-67.51,-46.44],[-66.78,-47.01],[-65.85,-47.16],[-65.77,-47.57],[-66.22,-47.83],[-65.81,-47.94],[-67.47,-48.95],[-67.91,-49.98],[-68.26,-50.1],[-68.67,-49.75],[-68.98,-50],[-68.42,-50.16],[-68.94,-50.38],[-69.36,-51.03],[-69.06,-51.55],[-69.46,-51.58],[-68.96,-51.68],[-68.4,-52.31],[-69.24,-52.21],[-70.8,-52.77],[-70.99,-53.78],[-71.3,-53.88],[-72.41,-53.35],[-71.94,-53.23],[-71.79,-53.48],[-71.23,-52.81],[-72.28,-53.13],[-72.55,-53.46],[-73.05,-53.24],[-72.73,-52.76],[-71.51,-52.61],[-72.71,-52.54],[-73.12,-53.07],[-73.64,-52.84],[-73.12,-52.49],[-74.01,-52.64],[-74.3,-52.12],[-73.83,-52.23],[-72.79,-51.95],[-72.57,-52.2],[-72.72,-52.36],[-72.52,-52.25],[-72.54,-51.71],[-73.17,-51.45],[-72.6,-51.8],[-73.52,-52.04],[-74.19,-51.68],[-73.93,-51.62],[-73.94,-51.27],[-74.81,-51.06],[-75.09,-50.68],[-74.68,-50.66],[-74.64,-50.36],[-73.81,-50.94],[-73.65,-50.49],[-73.98,-50.83],[-74.2,-50.61],[-73.95,-50.51],[-74.63,-50.19],[-73.96,-49.99],[-74.29,-49.6],[-73.83,-49.61],[-74.09,-49.43],[-73.94,-49.02],[-74.22,-49.5],[-74.37,-49.4],[-74.34,-48.6],[-74.01,-48.48],[-74.48,-48.46],[-74.58,-48],[-73.39,-48.15],[-73.72,-47.66],[-74.23,-47.97],[-74.66,-47.7],[-74.13,-47.59],[-74.48,-47.43],[-74.16,-47.18],[-74.31,-46.79],[-75,-46.74],[-75.02,-46.51],[-75.54,-46.7],[-75.43,-46.93],[-75.71,-46.77],[-74.93,-46.16],[-75.07,-45.88],[-74.16,-45.77],[-73.96,-45.4],[-74.02,-46.06],[-74.39,-46.22],[-73.97,-46.15],[-73.73,-45.81],[-73.85,-46.57],[-73.59,-45.9],[-73.73,-45.48],[-72.93,-45.45],[-73.45,-45.24],[-72.68,-44.59],[-73.27,-44.17],[-73.08,-43.32],[-72.76,-43.04],[-72.77,-42.26],[-72.41,-42.39],[-72.5,-41.98],[-72.82,-41.91],[-72.32,-41.5],[-73.73,-41.74],[-73.98,-40.97],[-73.23,-39.22],[-73.66,-37.34],[-73.22,-37.17],[-71.99,-34.29],[-72,-34.17],[-71.83,-33.82],[-71.66,-33.65],[-71.64,-33.52],[-71.7,-33.43],[-71.74,-33.09],[-71.59,-32.97],[-71.45,-32.66],[-71.42,-32.39],[-71.51,-32.21],[-71.71,-30.63],[-71.31,-29.65],[-71.52,-28.93],[-70.65,-26.33],[-70.39,-23.57],[-70.59,-23.25],[-70.09,-21.49],[-70.36,-18.4],[-71.53,-17.3],[-75.11,-15.41],[-76.29,-14.13],[-76.23,-13.37],[-76.5,-12.98],[-76.83,-12.35],[-77.15,-12.06],[-77.22,-11.66],[-77.31,-11.53],[-77.63,-11.29],[-77.74,-10.84],[-79.76,-7.07],[-81.14,-6.06],[-80.88,-5.63],[-81.34,-4.67],[-81.23,-4.23],[-79.96,-3.16],[-79.73,-2.58],[-79.84,-2.07],[-79.93,-2.55],[-80.01,-2.35],[-80.29,-2.71],[-80.96,-2.19],[-80.77,-2.08],[-80.9,-1.08],[-80.28,-0.62],[-80.48,-0.37],[-80.05,0.16],[-80.09,0.79],[-78.9,1.21],[-79.03,1.62],[-78.58,1.77],[-78.59,2.36],[-77.81,2.72],[-77.08,3.91],[-77.52,4.21],[-77.29,4.72],[-77.54,5.54],[-77.25,5.78],[-77.47,6.18],[-77.37,6.57],[-78.38,7.9],[-78.42,8.06],[-78.29,8.09],[-78.28,8.25],[-78.14,8.39],[-77.76,8.13],[-78.06,8.4],[-78.1,8.5],[-78.22,8.4],[-78.4,8.51],[-78.37,8.4],[-78.41,8.36],[-78.51,8.63],[-78.95,8.93],[-79.25,9.02],[-79.51,8.97],[-79.69,8.85],[-79.81,8.64],[-79.75,8.6],[-80.12,8.35],[-80.37,8.29],[-80.46,8.21],[-80.46,8.08],[-80.07,7.67],[-80.01,7.5],[-80.84,7.22],[-81.06,7.9],[-81.27,7.63],[-82.23,8.31],[-82.78,8.3],[-82.88,8.07],[-83.29,8.67],[-83.47,8.71],[-83.29,8.41],[-83.61,8.48],[-83.74,9.15],[-84.58,9.57],[-85.02,10.12],[-85.26,10.26],[-84.89,9.82],[-85.11,9.58],[-85.63,9.9],[-85.85,10.29],[-85.67,10.74],[-85.91,10.9],[-85.74,11.09],[-87.67,12.9],[-87.34,12.95],[-87.49,13.35],[-88.69,13.28],[-88.51,13.18],[-91.38,13.99],[-93.92,16.05],[-94.86,16.42],[-95.02,16.28],[-94.8,16.21],[-96.21,15.69],[-97.75,15.97],[-100.85,17.2],[-101.92,17.96],[-103.44,18.33],[-103.91,18.83],[-104.94,19.31],[-105.67,20.38],[-105.26,20.58],[-105.51,20.81],[-105.21,21.49],[-105.65,21.99],[-105.79,22.63],[-107.77,24.47],[-107.51,24.49],[-107.95,24.62],[-108.28,25.08],[-108.05,25.07],[-109.03,25.48],[-108.88,25.73],[-109.31,25.63],[-109.42,26.03],[-109.12,26.25],[-109.28,26.53],[-110.38,27.23],[-110.53,27.86],[-111.12,27.97],[-112.16,29.02],[-113.06,30.65],[-113.05,31.18],[-114.93,31.9],[-114.55,30.02],[-112.87,28.42],[-112.73,27.83],[-111.86,26.68],[-111.7,26.58],[-111.79,26.88],[-111.57,26.71],[-110.69,24.87],[-110.66,24.34],[-110.37,24.1],[-110.26,24.34],[-109.42,23.48],[-109.5,23.16],[-110,22.89],[-110.36,23.61],[-112.07,24.84],[-112.38,26.21],[-113.02,26.58],[-113.15,26.95],[-113.6,26.72],[-114.99,27.74],[-114.3,27.87],[-114.07,27.68],[-114.27,27.93],[-114.05,28.43],[-115.67,29.76],[-117.27,32.81],[-117.32,33.1],[-117.47,33.3],[-118.08,33.72],[-118.41,33.74],[-118.39,33.86],[-118.51,34.02],[-118.83,34.02],[-119.14,34.11],[-119.41,34.34],[-119.61,34.42],[-119.71,34.4],[-120.65,34.58],[-120.63,35.08],[-121.46,35.93],[-121.88,36.33],[-121.92,36.57],[-121.79,36.73],[-121.81,36.85],[-121.88,36.94],[-122.17,36.99],[-122.4,37.21],[-122.51,37.77],[-122.39,37.79],[-122.37,37.66],[-122.07,37.48],[-122.39,37.96],[-122.22,38.04],[-121.52,38.06],[-122.03,38.12],[-122.15,38.07],[-122.39,38.14],[-122.48,38.11],[-122.47,37.84],[-122.52,37.83],[-122.93,38.06],[-123,37.99],[-122.98,38.23],[-122.88,38.12],[-122.99,38.28],[-123.7,38.91],[-123.83,39.78],[-124.33,40.25],[-124.07,41.46],[-124.54,42.81],[-124.15,43.69],[-123.99,46.22],[-123.22,46.15],[-124.07,46.28],[-123.89,46.66],[-124.11,46.86],[-123.84,46.96],[-124.14,46.95],[-124.71,48.38],[-123.3,48.12],[-123.12,48.15],[-122.98,48.07],[-122.78,48.14],[-122.66,47.88],[-122.78,47.74],[-122.82,47.79],[-123.05,47.55],[-123.14,47.36],[-122.92,47.41],[-123.07,47.4],[-123.06,47.45],[-122.59,47.86],[-122.59,47.93],[-122.53,47.92],[-122.53,47.77],[-122.62,47.71],[-122.61,47.62],[-122.68,47.61],[-122.56,47.46],[-122.58,47.29],[-122.71,47.32],[-122.77,47.22],[-122.83,47.34],[-123.03,47.14],[-122.7,47.11],[-122.54,47.28],[-122.35,47.37],[-122.4,47.78],[-122.24,48.01],[-122.42,48.18],[-122.4,48.08],[-122.52,48.16],[-122.52,48.23],[-122.41,48.29],[-122.67,48.46],[-122.5,48.51],[-122.54,48.76],[-122.69,48.79],[-122.83,49.03],[-122.96,49.07],[-123.08,48.98],[-123.23,49.26],[-122.88,49.4],[-123.28,49.34],[-123.19,49.68],[-123.53,49.4],[-124.03,49.6],[-123.58,49.68],[-123.88,49.74],[-123.83,50.15],[-124.28,49.77],[-124.78,50.02],[-125.06,50.42],[-124.86,50.87],[-125.06,50.51],[-126.09,50.5],[-126.45,50.59],[-125.91,50.7],[-126.51,50.68],[-126.52,51.06],[-127.06,50.87],[-127.71,51.15],[-127.42,51.61],[-126.69,51.7],[-127.64,51.48],[-127.85,51.67],[-127.8,52.19],[-127.44,52.36],[-126.71,52.06],[-127.19,52.46],[-127.01,52.84],[-128.1,51.79],[-128.36,52.16],[-127.94,52.55],[-128.27,52.36],[-128.05,52.91],[-128.36,52.83],[-129.17,53.53],[-128.85,53.7],[-127.93,53.28],[-128.67,53.55],[-128.76,53.75],[-128.53,53.86],[-128.96,53.84],[-129.56,53.25],[-130.33,53.72],[-130.04,54.13],[-129.62,54.23],[-130.43,54.42],[-129.56,55.46],[-129.79,55.56],[-130.05,55.06],[-130.02,55.89],[-130.04,55.3],[-130.54,54.75],[-131.05,55.16],[-130.75,55.32],[-131.03,56.09],[-132.12,55.57],[-132.21,55.75],[-131.55,56.21],[-132.18,56.42],[-132.83,57.06],[-133.47,57.17],[-133.65,57.64],[-133.12,57.57],[-133.54,57.86],[-133.2,57.88],[-134.03,58.07],[-133.88,58.52],[-134.21,58.23],[-134.78,58.45],[-135.36,59.42],[-135.5,59.2],[-135.09,58.25],[-135.9,58.4],[-136.04,58.82],[-135.83,58.9],[-136.13,59.04],[-136.23,58.77],[-136.99,59.04],[-137.06,58.87],[-136.06,58.45],[-136.61,58.24],[-139.77,59.53],[-139.51,59.95],[-139.29,59.61],[-138.99,59.84],[-139.43,60.01],[-140.42,59.71],[-141.41,59.9],[-141.41,60.12],[-144.15,60.02],[-144.9,60.34],[-144.69,60.67],[-145.25,60.38],[-146.57,60.73],[-146.39,60.81],[-146.63,60.99],[-146.38,61.14],[-147.81,60.89],[-148.01,60.97],[-147.75,61.22],[-148.34,61.06],[-148.56,60.8],[-148.28,60.61],[-148.64,60.49],[-147.96,60.48],[-148.43,59.99],[-149.4,60.11],[-149.6,59.77],[-149.71,59.92],[-150.93,59.25],[-151.74,59.19],[-151.93,59.34],[-151.04,59.77],[-151.85,59.78],[-151.4,60.27],[-151.36,60.72],[-150.44,61.02],[-149.07,60.89],[-150.05,61.17],[-149.33,61.5],[-151.59,60.98],[-152.37,60.34],[-153.02,60.3],[-152.63,60.04],[-153.21,59.84],[-153.05,59.73],[-154.09,59.36],[-154.13,59.12],[-153.33,58.88],[-154.25,58.16],[-158.41,56.44],[-158.55,56.31],[-158.28,56.2],[-159.66,55.63],[-159.77,55.84],[-161.38,55.37],[-161.2,55.54],[-161.52,55.62],[-162.08,55.14],[-162.63,55.25],[-162.67,55],[-163.12,55.06],[-163.34,54.84],[-163.28,55.12],[-161.7,55.91],[-160.29,55.8],[-160.54,56.01],[-160.3,56.31],[-158.67,56.8],[-158.32,57.3],[-157.46,57.51],[-157.7,57.68],[-157.61,58.05],[-157.19,58.19],[-157.52,58.42],[-156.97,58.74],[-156.81,59.13],[-158.19,58.62],[-158.5,58.85],[-158.08,58.98],[-158.81,58.97],[-158.95,58.4],[-159.67,58.91],[-160.36,59.05],[-162.14,58.64],[-161.72,58.79],[-161.64,59.11],[-161.98,59.15],[-161.83,59.59],[-162.42,60.28],[-161.96,60.69],[-162.68,60.27],[-162.57,59.99],[-163.68,59.8],[-165.36,60.54],[-164.8,60.89],[-164.32,60.77],[-164.37,60.59],[-163.42,60.76],[-163.91,60.85],[-163.59,60.9],[-163.75,60.97],[-165.11,60.93],[-164.87,61.11],[-165.27,61.27],[-165.57,61.1],[-165.84,61.54],[-166.15,61.55],[-165.81,61.7],[-166.08,61.8],[-165.61,61.87],[-165.71,62.1],[-165.19,62.47],[-164.76,62.5],[-164.59,62.71],[-164.79,62.62],[-164.8,62.92],[-164.38,63.03],[-164.41,63.22],[-163.29,63.05],[-162.28,63.53],[-161.1,63.56],[-160.78,63.82],[-160.99,64.25],[-161.49,64.43],[-160.86,64.76],[-161.76,64.82],[-162.81,64.37],[-163.2,64.65],[-163.14,64.42],[-166.14,64.58],[-166.93,65.16],[-166.16,65.29],[-168.09,65.66],[-164.46,66.59],[-163.64,66.57],[-163.89,66.58],[-164.03,66.22],[-163.7,66.08],[-161.04,66.19],[-162.61,66.89],[-162.36,66.95],[-161.59,66.46],[-160.23,66.51],[-161.57,66.59],[-161.86,66.7],[-161.72,67.02],[-163.53,67.1],[-164.12,67.61],[-166.79,68.36],[-166.38,68.43],[-166.21,68.89],[-163.87,69.04],[-161.88,70.33],[-162.08,70.16],[-160.12,70.59],[-159.86,70.28],[-159.81,70.5],[-159.39,70.52],[-160.08,70.64],[-159.68,70.79],[-157.91,70.86],[-156.47,71.41],[-155.58,71.12],[-156.15,70.93],[-155.97,70.84],[-155.17,71.1],[-154.19,70.8],[-152.3,70.85],[-152.47,70.65],[-151.77,70.56],[-151.94,70.45],[-149.27,70.5],[-144.62,69.98],[-143.22,70.12],[-135.26,68.68],[-135.91,69.11],[-134.46,69.48],[-134.41,69.68],[-133.88,69.51],[-134.18,69.25],[-130.67,70.13],[-129.54,70.11],[-131.94,69.53],[-133.42,68.84],[-132.71,68.81],[-132.53,68.87],[-132.72,69.08],[-131.79,69.43],[-131.06,69.45],[-130.97,69.21],[-130.12,69.72],[-128.9,69.97],[-129.16,69.8],[-128.85,69.75],[-127.68,70.26],[-128.17,70.42],[-127.99,70.57],[-125.73,69.38],[-125.17,69.43],[-125.34,69.66],[-124.56,70.15],[-124.12,69.69],[-124.34,69.36],[-123.53,69.39],[-123.03,69.81],[-121.74,69.8],[-117.23,68.91],[-115.44,68.94],[-113.96,68.4],[-115.43,67.9],[-115.13,67.82],[-112.43,67.68],[-110.07,67.99],[-107.99,67.26],[-108.5,67.09],[-107.26,66.4],[-107.75,66.96],[-107.16,66.88],[-107.96,67.82],[-105.75,68.59],[-107.73,68.17],[-108.72,68.3],[-108.34,68.6],[-106.16,68.92],[-104.49,68.06],[-103.47,68.11],[-102.32,67.74],[-98.41,67.81],[-98.63,68.07],[-97.61,67.63],[-97.16,67.73],[-98.19,67.92],[-98.65,68.36],[-97.83,68.53],[-96.43,68.31],[-96.72,68.04],[-95.97,68.25],[-96.37,67.51],[-95.42,67.01],[-96.42,67.04],[-95.79,66.62],[-96.04,66.94],[-95.4,66.95],[-95.26,67.26],[-95.65,67.74],[-95.46,68.02],[-93.45,68.62],[-93.85,69],[-94.6,68.8],[-94.09,69.12],[-94.25,69.31],[-93.43,69.37],[-96.05,69.83],[-96.54,70.33],[-95.89,70.69],[-96.36,70.68],[-96.53,71.13],[-96.06,71.41],[-95.56,71.34],[-95.41,71.49],[-95.87,71.57],[-95.2,71.9],[-94.61,71.99],[-94.48,71.85]],[[143.18,-11.96],[143.75,-14.35],[144.47,-14.23],[145.29,-14.94],[145.43,-16.41],[145.91,-16.91],[146.03,-18.27],[146.38,-18.98],[148.76,-20.29],[148.88,-20.48],[148.68,-20.58],[149.21,-21.12],[149.71,-22.44],[149.98,-22.55],[150.08,-22.16],[150.54,-22.56],[150.67,-22.42],[150.84,-23.46],[151.83,-24.12],[153.03,-25.87],[153.17,-25.96],[153.08,-26.3],[153.16,-26.98],[153.12,-27.19],[153.38,-27.77],[153.45,-28.05],[153.58,-28.24],[153.6,-28.86],[152.95,-31.43],[152.21,-32.68],[152.14,-32.68],[152.19,-32.72],[152.16,-32.76],[151.81,-32.9],[151.48,-33.35],[151.43,-33.52],[151.29,-33.58],[151.28,-33.93],[151.24,-33.99],[151.12,-34.01],[151.23,-34.03],[150.96,-34.3],[150.78,-34.89],[150.81,-34.99],[150.68,-35.08],[150.71,-35.16],[150.57,-35.21],[150.2,-35.83],[149.93,-37.53],[147.88,-37.93],[146.86,-38.66],[146.22,-38.73],[146.45,-39.11],[146.16,-38.87],[146.07,-38.83],[145.94,-38.9],[145.79,-38.67],[145.61,-38.66],[145.4,-38.54],[145.46,-38.42],[145.54,-38.39],[145.48,-38.24],[145.29,-38.24],[145.19,-38.38],[144.96,-38.5],[144.72,-38.34],[144.91,-38.34],[145.12,-38.09],[144.89,-37.9],[144.4,-38.14],[144.67,-38.21],[144.1,-38.46],[143.69,-38.77],[141.93,-38.28],[141.43,-38.36],[140.39,-37.9],[139.78,-37.25],[139.73,-36.37],[138.98,-35.62],[139.29,-35.61],[139.28,-35.38],[138.19,-35.61],[138.51,-35.02],[138.09,-34.17],[137.69,-35.14],[136.88,-35.24],[137.02,-34.92],[137.39,-34.91],[137.49,-34.16],[137.93,-33.58],[137.78,-32.58],[137.24,-33.63],[136.43,-34.03],[135.89,-34.66],[135.97,-34.98],[135.65,-34.94],[135.12,-34.59],[135.45,-34.58],[135.22,-33.96],[134.72,-33.26],[134.3,-33.17],[134.23,-32.55],[131.14,-31.5],[128.95,-31.7],[127.32,-32.26],[125.92,-32.3],[124.24,-33.01],[123.51,-33.92],[119.85,-33.97],[117.86,-35.05],[116.52,-34.99],[115.01,-34.26],[114.99,-33.51],[115.36,-33.64],[115.61,-33.37],[115.68,-33.19],[115.62,-32.67],[115.71,-32.57],[115.74,-31.89],[115.7,-31.7],[115.08,-30.56],[114.86,-29.14],[114.17,-28.08],[114.03,-27.35],[113.18,-26.18],[113.36,-26.08],[113.58,-26.56],[113.83,-26.5],[113.45,-25.6],[113.72,-26.13],[114.22,-26.29],[114.21,-25.85],[113.42,-24.44],[113.96,-21.94],[114.12,-21.83],[114.14,-22.48],[114.71,-21.82],[116.71,-20.65],[117.41,-20.72],[119.11,-19.99],[121,-19.6],[122.35,-18.11],[122.14,-17.43],[122.33,-17.06],[122.97,-16.44],[123.56,-17.52],[123.59,-17.03],[123.83,-17.12],[123.88,-16.92],[123.49,-16.49],[123.61,-16.22],[124.77,-16.4],[124.4,-16.3],[124.65,-15.87],[124.38,-15.76],[124.44,-15.49],[124.69,-15.27],[125.06,-15.44],[124.84,-15.16],[125.36,-15.12],[125.18,-14.72],[125.63,-14.26],[125.66,-14.53],[126.02,-14.5],[126.05,-13.98],[126.57,-14.16],[126.9,-13.74],[127.46,-14.03],[128.18,-14.71],[128.07,-15.33],[128.58,-14.77],[129.64,-15.14],[129.64,-14.85],[129.85,-14.83],[129.38,-14.39],[129.94,-13.5],[130.14,-13.45],[130.26,-13.3],[130.14,-13.15],[130.17,-12.96],[130.32,-12.88],[130.4,-12.69],[130.62,-12.65],[130.62,-12.43],[130.74,-12.43],[130.87,-12.56],[130.87,-12.37],[131.03,-12.34],[131.05,-12.19],[131.22,-12.18],[131.29,-12.07],[131.34,-12.21],[131.44,-12.28],[131.89,-12.23],[132.07,-12.28],[132.25,-12.19],[132.41,-12.3],[132.44,-12.18],[132.58,-12.11],[132.67,-11.65],[132.28,-11.47],[132.13,-11.5],[131.81,-11.27],[131.96,-11.18],[132.16,-11.31],[135.03,-12.19],[135.92,-11.83],[135.71,-12.21],[135.94,-12.15],[136.08,-12.42],[136.54,-11.96],[136.95,-12.35],[136.46,-13.23],[135.93,-13.3],[135.95,-13.93],[135.45,-14.92],[140.04,-17.7],[140.83,-17.41],[141.29,-16.46],[141.63,-15.06],[141.61,-12.94],[141.93,-12.74],[141.69,-12.35],[142.46,-10.71],[142.78,-11.12],[142.87,-11.82],[143.07,-11.92]],[[-29.95,83.56],[-25.8,83.26],[-32.03,82.98],[-25.12,83.16],[-24.47,82.88],[-21.52,82.6],[-23.12,82.33],[-29.89,82.05],[-25.15,82],[-24.29,81.7],[-22.94,82.03],[-21.13,81.93],[-21.5,81.44],[-23.12,80.78],[-19.63,81.64],[-17.45,81.4],[-15.45,81.84],[-11.42,81.48],[-14.45,80.99],[-14.23,80.87],[-14.5,80.76],[-16.76,80.57],[-15.94,80.43],[-16.49,80.25],[-19.43,80.26],[-20.15,80.01],[-20.07,79.77],[-19.35,79.73],[-19.41,79.35],[-18.99,79.18],[-21.13,78.66],[-20.95,78.55],[-21.73,77.71],[-20.86,77.91],[-19.49,77.72],[-19.29,77.59],[-20.68,77.62],[-20.23,77.37],[-18.44,77.26],[-18.34,76.92],[-22.61,76.68],[-21.49,76.27],[-19.86,76.12],[-19.4,75.49],[-19.52,75.18],[-22.23,75.12],[-20.99,75.07],[-20.78,74.89],[-21.04,74.65],[-20.86,74.64],[-19.99,74.98],[-19.27,74.34],[-21.13,74.11],[-21.95,74.24],[-21.76,74.48],[-21.98,74.57],[-22.33,74.29],[-22.13,73.99],[-20.37,73.85],[-20.64,73.46],[-22.35,73.27],[-24.16,73.77],[-24.68,73.6],[-25.52,73.85],[-24.78,73.54],[-26.06,73.25],[-27.27,73.44],[-26.54,73.25],[-27.56,73.14],[-24.13,73.41],[-22.04,72.92],[-22.29,72.12],[-24.07,72.5],[-24.63,73.04],[-26.66,72.72],[-24.81,72.9],[-24.7,72.51],[-25.2,72.39],[-21.96,71.74],[-22.48,71.38],[-21.75,71.48],[-21.52,70.53],[-22.38,70.46],[-22.44,70.86],[-22.69,70.44],[-23.33,70.45],[-23.97,70.65],[-24.56,71.22],[-27.09,71.63],[-25.84,71.48],[-25.67,71.27],[-26.72,70.95],[-28.4,70.99],[-27.98,70.84],[-29.07,70.44],[-26.51,70.4],[-27.63,70.03],[-27.38,69.99],[-25.53,70.35],[-22.21,70.11],[-23.87,69.74],[-23.74,69.59],[-24.3,69.58],[-26.48,68.68],[-30.98,68.06],[-32.33,68.44],[-32.16,67.99],[-33.16,67.63],[-34.63,66.43],[-35.19,66.25],[-35.87,66.44],[-35.63,66.14],[-37.76,65.59],[-38,65.71],[-37.28,66.3],[-38.15,66.39],[-37.75,66.26],[-38.14,65.9],[-38.52,66.01],[-38.2,65.71],[-40.17,65.56],[-39.58,65.34],[-41.09,65.03],[-40.18,64.48],[-40.78,64.22],[-41.58,64.3],[-40.62,64.13],[-40.55,63.73],[-41.39,63.06],[-42.18,63.21],[-41.64,62.97],[-41.91,62.74],[-42.94,62.72],[-42.15,62.57],[-42.32,62.15],[-42.11,61.86],[-42.59,61.72],[-42.32,61.68],[-43.04,60.52],[-43.92,60.6],[-43.21,60.39],[-43.12,60.06],[-43.95,60.02],[-43.66,59.86],[-43.91,59.81],[-44.41,59.92],[-44.22,60.27],[-44.61,60.02],[-45.38,60.2],[-44.76,60.67],[-45.38,60.44],[-46.05,60.61],[-45.87,61.22],[-46.87,60.82],[-48.18,60.77],[-47.77,61],[-48.39,61.01],[-49.29,61.59],[-49.38,61.89],[-48.83,62.08],[-49.62,62],[-49.55,62.23],[-50.32,62.47],[-49.79,63.05],[-50.39,62.82],[-51.47,63.64],[-51.55,64.01],[-50.26,64.21],[-51.71,64.2],[-50.68,64.68],[-50.01,64.45],[-50.12,64.7],[-50.96,65.2],[-50.72,64.8],[-51.26,64.76],[-51.92,64.22],[-52.54,65.33],[-51.09,65.78],[-52.55,65.46],[-53.2,65.59],[-53.11,65.98],[-53.39,66.05],[-51.23,66.88],[-53.61,66.15],[-53.42,66.65],[-52.39,66.88],[-53.69,66.99],[-53.8,67.42],[-52.51,67.76],[-50.61,67.53],[-51.17,67.69],[-50.97,67.81],[-52.35,67.84],[-53.74,67.55],[-53.15,68.21],[-51.6,68.06],[-51.17,68.39],[-53.38,68.3],[-53.04,68.61],[-51.13,68.6],[-50.8,68.79],[-51.25,68.74],[-51.09,69.13],[-50.3,69.17],[-51.08,69.21],[-50.32,70.03],[-52.26,70.06],[-54.53,70.7],[-52.8,70.75],[-50.68,70.4],[-51.77,71.01],[-51.02,71],[-53.12,71.31],[-51.78,71.68],[-53.44,71.58],[-53.15,71.81],[-53.81,72.29],[-53.65,72.36],[-53.93,72.32],[-53.48,71.85],[-54.02,71.66],[-53.96,71.46],[-55.59,71.55],[-55.32,72.11],[-54.84,72.38],[-55.58,72.18],[-55.29,72.35],[-55.6,72.45],[-54.92,72.57],[-54.74,72.87],[-55.67,73.01],[-55.29,73.33],[-56.1,73.56],[-55.84,73.76],[-56.23,74.13],[-57.23,74.12],[-56.26,74.53],[-58.57,75.35],[-58.25,75.51],[-58.52,75.69],[-63.29,76.35],[-67.08,76.2],[-66.83,75.97],[-68.32,76.09],[-69.48,76.4],[-68.11,76.65],[-69.89,76.83],[-69.69,76.99],[-70.61,76.82],[-71.16,77.07],[-68.14,77.38],[-66.39,77.28],[-66.27,77.51],[-66.82,77.69],[-69.35,77.47],[-70.56,77.72],[-70.12,77.84],[-71.27,77.81],[-72.82,78.19],[-71.65,78.62],[-65.82,79.17],[-64.79,80],[-64.18,80.1],[-66.84,80.08],[-67.19,80.28],[-64.51,81],[-63.06,80.89],[-63.24,81.08],[-62.99,81.21],[-61.44,81.13],[-61.1,81.4],[-61.2,81.75],[-60.43,81.92],[-56.62,81.36],[-59.27,81.98],[-54.55,82.35],[-53.67,82.16],[-53.56,81.65],[-53.04,81.87],[-53.02,82.32],[-50.9,81.89],[-49.54,81.92],[-50.99,82.46],[-50.04,82.47],[-44.73,81.78],[-44.33,82.47],[-45.56,82.75],[-41.37,82.75],[-46.48,82.95],[-43.01,83.26],[-41.3,83.1],[-40.36,83.33],[-38.15,83],[-37.94,83.16],[-38.75,83.37],[-30.7,83.59]],[[-86.59,71.01],[-84.82,71.03],[-84.7,71.63],[-85.91,71.99],[-85.32,72.23],[-84.28,72.04],[-85.65,72.72],[-85.26,72.95],[-84.26,72.8],[-85.46,73.11],[-83.41,73.63],[-81.6,73.7],[-80.28,72.77],[-81.23,72.31],[-80.61,72.45],[-80.95,71.92],[-79.88,72.18],[-80.11,72.33],[-79.83,72.45],[-79,72.27],[-79.01,72.04],[-78.58,71.88],[-78.86,72.1],[-78.7,72.35],[-77.52,72.18],[-78.42,72.57],[-77.25,72.74],[-75.07,72.32],[-75.92,71.72],[-75.15,72.06],[-74.27,72.04],[-74.32,71.84],[-75.21,71.71],[-74.7,71.68],[-75,71.22],[-74.49,71.65],[-73.87,71.77],[-73.71,71.72],[-74.2,71.4],[-73.71,71.59],[-73.18,71.28],[-73.28,71.54],[-72.9,71.68],[-71.64,71.52],[-71.19,71.28],[-72.63,70.83],[-70.67,71.05],[-70.76,70.79],[-71.89,70.43],[-71.28,70.5],[-71.43,70.13],[-70.98,70.58],[-70.08,70.83],[-68.5,70.61],[-68.48,70.41],[-70.06,70.04],[-68.78,70.2],[-69.01,69.98],[-68.74,69.94],[-67.86,70.28],[-67.19,69.76],[-69.25,69.51],[-66.68,69.26],[-69.04,69.1],[-67.75,69.04],[-67.88,68.78],[-69.32,68.86],[-66.71,68.45],[-67.03,68.33],[-66.92,68.07],[-66.21,68.28],[-66.53,67.85],[-65.94,68.07],[-65.51,67.97],[-65.4,67.68],[-65.41,67.88],[-64.98,68.04],[-65.02,67.79],[-63.85,67.57],[-64.59,67.32],[-63.04,67.23],[-63.7,66.82],[-62.12,67.05],[-61.3,66.65],[-62.12,66.64],[-61.58,66.41],[-61.86,66.31],[-62.55,66.41],[-61.99,66.03],[-62.59,66.03],[-62.38,65.83],[-62.66,65.64],[-63.46,65.85],[-63.65,65.66],[-63.34,65.62],[-63.36,65.23],[-63.61,64.93],[-64.35,65.17],[-64.27,65.4],[-64.55,65.12],[-65.4,65.76],[-64.45,66.32],[-65.82,66],[-65.66,66.2],[-66.06,66.13],[-66.99,66.63],[-67.31,66.57],[-67.23,66.31],[-67.88,66.47],[-67.18,66.03],[-67.35,65.93],[-68.75,66.2],[-68.22,66.08],[-67.87,65.77],[-67.94,65.56],[-67.12,65.44],[-67.34,65.35],[-66.7,64.82],[-66.63,65],[-66.21,64.72],[-65.94,64.89],[-65.43,64.73],[-65.27,64.63],[-65.53,64.51],[-65.08,64.44],[-65.58,64.29],[-64.68,64.03],[-64.8,63.92],[-64.41,63.71],[-64.67,63.24],[-65.19,63.76],[-64.67,62.92],[-65.16,62.93],[-65.11,62.63],[-66.66,63.26],[-66.72,63.08],[-67.89,63.73],[-67.72,63.42],[-68.91,63.7],[-65.98,62.21],[-66.33,61.87],[-71.35,63.07],[-71.99,63.42],[-71.38,63.58],[-72.5,63.82],[-73.45,64.4],[-73.27,64.58],[-74.07,64.43],[-74.68,64.83],[-74.92,64.77],[-74.7,64.5],[-76.86,64.24],[-78.17,64.62],[-78.05,64.98],[-77.36,65.2],[-77.33,65.45],[-75.83,65.23],[-75.45,64.84],[-75.36,65.01],[-75.8,65.3],[-73.55,65.48],[-74.42,66.17],[-72.22,67.26],[-73.28,68.36],[-73.82,68.36],[-73.85,68.7],[-74.42,68.58],[-74.91,68.82],[-74.85,69.07],[-76.59,68.7],[-76.56,69.01],[-75.65,69.21],[-76.52,69.52],[-76.23,69.66],[-77.09,69.64],[-76.86,69.78],[-77.59,69.85],[-77.77,70.24],[-79.07,70.6],[-79.4,70.4],[-78.81,70.18],[-79.09,69.93],[-81.65,70.1],[-80.92,69.73],[-81.56,69.94],[-85.78,70.04],[-86.32,70.15],[-86.4,70.47],[-87.9,70.25],[-88.85,70.52],[-89.46,71.06],[-87.14,71.01],[-89.69,71.42],[-90.02,71.95],[-89.66,72.17],[-89.82,72.47],[-88.71,73.4],[-86.77,73.83],[-85.01,73.78],[-86.67,72.76],[-86.32,72.46],[-86.22,71.9],[-85.02,71.35],[-86.47,71.04]],[[-69.49,83.02],[-66.42,82.93],[-68.47,82.65],[-64.9,82.9],[-63.5,82.79],[-63.64,82.71],[-63.09,82.56],[-63.25,82.45],[-61.21,82.34],[-68.69,81.29],[-64.78,81.49],[-69.55,80.38],[-70.71,80.54],[-70.26,80.23],[-72.06,80.12],[-70.56,80.07],[-71.39,79.76],[-74.39,79.87],[-74.66,79.84],[-73.2,79.6],[-76.9,79.51],[-74.48,79.23],[-74.53,79.05],[-78.58,79.08],[-74.43,78.72],[-76.42,78.51],[-75.19,78.33],[-75.97,77.99],[-78.01,77.95],[-78.08,77.52],[-78.49,77.37],[-81.66,77.53],[-81.28,77.37],[-82.06,77.3],[-79.5,77.2],[-79.22,76.94],[-78,76.85],[-78.28,76.57],[-80.8,76.17],[-80.97,76.47],[-82.53,76.72],[-82.23,76.47],[-83.89,76.45],[-84.22,76.67],[-84.28,76.36],[-86.45,76.58],[-86.68,76.38],[-87.49,76.59],[-87.5,76.39],[-88.4,76.41],[-88.49,76.77],[-88.54,76.42],[-89.57,76.49],[-89.5,76.83],[-88.56,77.07],[-86.81,77.19],[-87.68,77.44],[-88.02,77.78],[-86.76,77.86],[-84.49,77.37],[-83.61,77.44],[-82.59,77.99],[-83.78,77.53],[-84.86,77.5],[-85.29,77.56],[-85.55,77.93],[-84.22,78.18],[-84.91,78.24],[-84.78,78.53],[-85.59,78.11],[-86.22,78.08],[-85.92,78.34],[-87.55,78.18],[-86.81,78.77],[-81.75,78.98],[-84.41,79],[-84.57,79.07],[-83.58,79.05],[-86.42,79.84],[-86.5,80.26],[-83.72,80.23],[-80.48,79.61],[-80.12,79.67],[-81.01,79.69],[-82.99,80.32],[-76.86,80.87],[-78.72,80.95],[-76.88,81.43],[-81.01,80.66],[-85.15,80.52],[-86.62,80.63],[-83.29,81.15],[-85.78,81.04],[-87.71,80.66],[-89.26,80.91],[-84.94,81.29],[-89.62,81.03],[-89.98,81.12],[-89.21,81.25],[-89.68,81.33],[-89.43,81.39],[-87.6,81.53],[-90.31,81.4],[-90.61,81.43],[-89.82,81.63],[-91.68,81.64],[-88.06,82.1],[-85.05,81.98],[-86.62,82.22],[-84.9,82.45],[-79.43,81.85],[-82.45,82.39],[-81.68,82.52],[-82.12,82.63],[-80.81,82.59],[-81.18,82.75],[-81.01,82.78],[-78.75,82.68],[-80.16,82.91],[-79.89,82.94],[-77.48,82.88],[-76.01,82.54],[-75.57,82.61],[-77.13,83.01],[-74.41,83.01],[-72.66,82.72],[-73.44,82.95],[-69.57,83.02]],[[133.47,-0.73],[134.11,-0.85],[134.19,-2.31],[134.46,-2.83],[134.63,-2.54],[135.09,-3.35],[135.49,-3.34],[136.39,-2.27],[137.07,-2.11],[137.12,-1.84],[137.91,-1.48],[139.79,-2.35],[144.48,-3.83],[145.77,-4.82],[145.75,-5.4],[147.42,-5.97],[147.8,-6.31],[147.81,-6.7],[146.95,-6.88],[147.26,-7.46],[148.13,-8.1],[148.58,-9.05],[149.2,-9.03],[149.26,-9.5],[150.01,-9.69],[149.76,-9.81],[149.87,-10.01],[150.85,-10.24],[150.45,-10.31],[150.65,-10.52],[150.32,-10.65],[149.75,-10.35],[147.77,-10.07],[146.03,-8.08],[144.51,-7.57],[144.14,-7.76],[143.65,-7.46],[143.94,-7.95],[143.52,-8],[143.61,-8.2],[142.21,-8.2],[143.38,-8.76],[142.65,-9.33],[141.13,-9.22],[140,-8.2],[140.12,-7.92],[139.38,-8.19],[139.25,-7.98],[138.93,-8.26],[139.09,-7.59],[138.75,-7.25],[139.18,-7.19],[138.6,-6.94],[138.87,-6.86],[138.44,-6.34],[138.34,-5.68],[138.09,-5.71],[137.28,-4.95],[135.19,-4.45],[134.68,-4.08],[134.89,-3.94],[133.97,-3.82],[133.68,-3.48],[133.84,-3.05],[133.4,-3.9],[132.97,-4.09],[132.75,-3.29],[131.97,-2.79],[132.72,-2.79],[133.19,-2.44],[133.7,-2.62],[133.92,-2.1],[132.31,-2.24],[131.93,-1.56],[131,-1.42],[131.26,-0.86],[132.39,-0.36],[133.27,-0.64]],[[116.81,6.69],[117.23,6.94],[117.69,6.35],[117.5,5.88],[118,6.05],[117.97,5.71],[118.35,5.81],[119.26,5.37],[119.13,5.1],[118.26,4.99],[118.55,4.38],[117.5,4.13],[117.78,3.69],[117.06,3.62],[118.06,2.32],[117.79,2.03],[118.99,0.98],[118.53,0.81],[117.91,1.1],[117.52,0.24],[117.56,-0.77],[116.91,-1.22],[116.74,-1.04],[116.75,-1.33],[116.28,-1.79],[116.55,-2.41],[115.96,-3.59],[114.7,-4.17],[114.34,-3.24],[113.71,-3.46],[113.04,-2.93],[112.76,-3.32],[111.86,-3.55],[111.7,-2.89],[110.26,-2.97],[109.98,-1.28],[109.29,-0.85],[109.13,-0.45],[109.26,0.03],[108.91,0.79],[109.08,1.5],[109.63,2.03],[111.22,1.4],[111.04,1.63],[111.51,2.74],[112.99,3.16],[114.01,4.57],[114.99,5.02],[115.43,4.97],[115.42,5.41],[115.88,5.61],[116.78,6.99],[116.84,6.77]],[[-114.52,72.59],[-113.58,72.65],[-113.08,73],[-111.27,72.71],[-111.89,72.36],[-111.67,72.3],[-110.21,72.66],[-110.66,73.01],[-110.01,72.98],[-108.76,72.55],[-108.19,71.72],[-107.81,71.63],[-107.3,71.9],[-107.7,72.15],[-108.24,73.15],[-107.93,73.22],[-108.03,73.35],[-106.48,73.2],[-105.41,72.79],[-104.38,71.58],[-104.51,71.06],[-103.59,70.63],[-101.09,70.14],[-100.91,69.81],[-102.24,69.84],[-102.62,69.55],[-103.43,69.67],[-103.05,69.47],[-103.12,69.2],[-102.15,69.49],[-101.79,69.18],[-102.89,68.82],[-105.1,68.92],[-105.02,69.08],[-106.14,69.16],[-106.66,69.44],[-107.44,69],[-109.47,68.68],[-113.02,68.48],[-113.55,68.77],[-113.69,69.19],[-116.51,69.43],[-117.19,70.05],[-111.63,70.31],[-113.76,70.69],[-117.59,70.63],[-118.38,70.97],[-115.3,71.49],[-117.94,71.39],[-118.23,71.47],[-117.74,71.66],[-118.99,71.76],[-118.94,71.99],[-118.21,72.26],[-118.37,72.53],[-116.57,73.06],[-114.21,73.3],[-114.08,72.91],[-114.5,72.63]],[[49.54,-12.43],[49.94,-13.07],[50.41,-15.63],[50.19,-15.96],[49.89,-15.46],[49.66,-15.52],[49.84,-16.49],[49.45,-17.24],[49.36,-18.34],[47.18,-24.79],[46.73,-25.15],[45.11,-25.54],[44.03,-25],[43.26,-22.38],[43.5,-21.36],[44.4,-19.92],[43.98,-17.39],[44.48,-16.22],[46.16,-15.74],[46.4,-15.93],[46.47,-15.51],[46.94,-15.22],[47.1,-15.43],[47.35,-14.77],[47.48,-15.01],[47.97,-14.67],[47.77,-14.37],[47.94,-13.66],[48.26,-13.72],[48.8,-13.27],[48.79,-12.47],[49.21,-12.08],[49.48,-12.35]],[[96.49,5.23],[97.55,5.21],[98.31,4.09],[99.73,3.18],[100.31,2.47],[100.53,2.19],[100.82,1.99],[100.89,1.95],[100.83,2.24],[100.94,2.29],[101.05,2.26],[101.3,2.01],[101.48,1.69],[101.79,1.62],[102.39,0.84],[102.57,0.75],[102.85,0.72],[103.03,0.58],[103.07,0.49],[102.79,0.3],[102.55,0.22],[102.78,0.24],[103.34,0.51],[103.48,0.48],[103.67,0.29],[103.79,0.05],[103.43,-0.19],[103.53,-0.75],[104.38,-1.07],[104.51,-1.82],[104.85,-2.09],[104.65,-2.59],[105.4,-2.38],[106.04,-3.11],[105.89,-5.01],[105.82,-5.68],[105.75,-5.82],[105.62,-5.8],[105.52,-5.67],[104.64,-5.52],[104.6,-5.91],[101.58,-3.17],[100.89,-2.25],[100.31,-0.83],[99.16,0.35],[98.6,1.87],[97.7,2.36],[96.97,3.58],[95.58,4.66],[95.23,5.56],[96.25,5.27]],[[-3.11,58.52],[-3.99,57.96],[-3.86,57.82],[-4.13,57.58],[-1.96,57.68],[-1.78,57.47],[-2.09,57.1],[-2.26,56.86],[-2.59,56.56],[-3.31,56.36],[-2.89,56.4],[-2.65,56.32],[-2.67,56.25],[-2.98,56.19],[-3.36,56.03],[-3.79,56.09],[-3.61,56.02],[-3.05,55.95],[-2.84,56.03],[-2.6,56.03],[-2.15,55.9],[-1.65,55.57],[-1.23,54.7],[-0.08,54.12],[0.12,53.61],[-0.66,53.72],[0.13,53.47],[0.35,53.16],[0.21,53.03],[0.05,52.91],[0.33,52.81],[0.52,52.94],[1.66,52.75],[1.75,52.47],[1.32,51.96],[1.23,51.97],[1.28,51.84],[1.19,51.8],[0.96,51.81],[0.75,51.73],[0.9,51.69],[0.89,51.57],[0.42,51.47],[0.53,51.49],[0.69,51.39],[0.89,51.36],[1.42,51.36],[1.4,51.18],[1.05,51.05],[0.96,50.93],[0.77,50.93],[0.2,50.76],[-0.2,50.82],[-0.79,50.76],[-1.42,50.9],[-1.33,50.82],[-1.52,50.75],[-3,50.72],[-3.4,50.63],[-3.68,50.24],[-3.79,50.23],[-4.2,50.39],[-4.73,50.29],[-5.01,50.16],[-5.12,50.04],[-5.23,50.02],[-5.43,50.11],[-5.62,50.05],[-5.66,50.13],[-5.34,50.25],[-4.89,50.53],[-4.58,50.78],[-4.52,50.98],[-4.3,51.03],[-4.19,51.19],[-3.84,51.23],[-3.26,51.19],[-3.04,51.25],[-2.43,51.74],[-3.29,51.39],[-3.56,51.41],[-3.89,51.59],[-4.24,51.57],[-4.09,51.66],[-4.39,51.74],[-4.6,51.74],[-4.9,51.63],[-5.12,51.71],[-5.2,51.86],[-5.26,51.88],[-5.09,52],[-4.38,52.2],[-4.15,52.33],[-4.1,52.92],[-4.68,52.84],[-3.81,53.3],[-3.32,53.35],[-3.1,53.26],[-3.17,53.39],[-3.07,53.43],[-2.92,53.3],[-2.75,53.31],[-2.91,53.35],[-3.07,53.51],[-2.93,53.73],[-3.03,53.77],[-3.03,53.91],[-2.9,53.96],[-2.87,54.18],[-3.17,54.13],[-3.57,54.47],[-3.59,54.56],[-3.47,54.77],[-3.27,54.91],[-3.04,54.95],[-3.55,54.95],[-3.96,54.78],[-4.3,54.84],[-4.91,54.69],[-5.17,54.92],[-4.68,55.5],[-4.73,55.6],[-4.87,55.87],[-4.58,55.94],[-4.67,55.97],[-4.8,56.16],[-5.23,55.89],[-5.09,56.2],[-5.77,55.36],[-5.19,56.76],[-5.65,56.53],[-6.13,56.71],[-5.59,57.1],[-5.82,57.44],[-5.58,57.55],[-5.69,57.78],[-5.16,57.88],[-5.41,58.07],[-5.01,58.26],[-4.98,58.58],[-3.06,58.59]],[[141.23,41.37],[141.45,41.4],[141.43,40.72],[141.8,40.29],[141.98,39.43],[141.47,38.4],[140.96,38.15],[141,37.11],[140.79,36.85],[140.63,36.5],[140.57,36.23],[140.62,36.06],[140.87,35.72],[140.64,35.66],[140.46,35.51],[140.36,35.18],[140.06,35.04],[139.92,34.9],[139.8,34.96],[139.84,35.01],[139.83,35.3],[140.1,35.59],[139.99,35.67],[139.83,35.66],[139.77,35.49],[139.65,35.41],[139.74,35.25],[139.68,35.15],[139.47,35.3],[139.25,35.28],[139.13,35.15],[139.09,34.84],[138.98,34.7],[138.84,34.62],[138.76,34.7],[138.8,34.97],[138.9,35.02],[138.72,35.12],[138.58,35.09],[138.35,34.85],[138.19,34.6],[137.06,34.58],[137.3,34.73],[137.1,34.76],[136.96,34.84],[136.94,34.72],[136.87,34.73],[136.85,34.98],[136.9,35.03],[136.8,35.05],[136.69,34.98],[136.53,34.68],[136.88,34.43],[136.85,34.32],[136.33,34.18],[135.92,33.56],[135.69,33.49],[135.45,33.55],[135.13,34.01],[135.1,34.29],[135.31,34.42],[135.42,34.62],[135.04,34.63],[134.74,34.77],[134.25,34.71],[133.97,34.53],[132.31,34.32],[132.14,33.84],[131.74,34.05],[130.92,33.98],[131,34.39],[131.35,34.41],[132.75,35.45],[134.21,35.54],[134.46,35.63],[135.18,35.75],[135.27,35.72],[135.23,35.59],[135.27,35.55],[135.68,35.5],[136.01,35.68],[136.09,35.77],[136.01,35.99],[136.07,36.12],[136.7,36.74],[136.84,37.38],[137.32,37.52],[136.9,37.12],[137.3,36.75],[138.32,37.22],[139.36,38.1],[140.04,39.41],[140,39.86],[139.74,39.92],[140.01,40.26],[139.92,40.6],[140.39,41.23],[140.75,40.83],[141.12,40.88],[141.25,41.21],[140.8,41.25],[140.94,41.5],[141.11,41.46]],[[-119.74,74.11],[-117.51,74.23],[-115.39,73.5],[-118.96,72.68],[-120.18,72.21],[-120.62,71.51],[-122.84,71.1],[-124.01,71.68],[-125.84,71.98],[-124.99,72.59],[-124.97,72.84],[-124.57,72.94],[-124.8,73.13],[-123.8,73.77],[-124.7,74.35],[-121.5,74.54],[-119.56,74.23],[-119.74,74.13]],[[-91.89,81.13],[-90.64,80.59],[-89.24,80.51],[-88.86,80.17],[-88.2,80.11],[-88.61,80.26],[-88.52,80.42],[-87.67,80.37],[-87.92,80.1],[-86.98,79.89],[-87.3,79.58],[-85.65,79.61],[-85.04,79.28],[-87.62,78.68],[-87.92,78.75],[-87.83,79.05],[-88.04,79],[-88.25,78.67],[-87.98,78.54],[-88.74,78.58],[-88.79,78.19],[-90.04,78.61],[-89.49,78.17],[-91.41,78.19],[-92.85,78.46],[-91.87,78.54],[-93.27,78.61],[-93.64,78.75],[-93.16,78.78],[-94.17,78.97],[-91.3,79.37],[-95.1,79.29],[-95.73,79.42],[-94.4,79.74],[-95.86,79.67],[-96.77,80.14],[-94.26,80.2],[-96.39,80.32],[-95.55,80.37],[-96.15,80.55],[-95.93,80.72],[-93.93,80.56],[-95.51,80.84],[-95.27,81],[-93.24,81.13],[-94.18,81.34],[-92,81.18]],[[-15.54,66.23],[-14.6,66.38],[-15.11,66.1],[-14.7,66.02],[-14.83,65.76],[-14.39,65.79],[-14.47,65.57],[-13.62,65.52],[-13.8,65.35],[-13.57,65.07],[-14.63,64.42],[-18.08,63.5],[-20.49,63.69],[-20.41,63.81],[-20.65,63.74],[-21.14,63.89],[-21.09,63.93],[-21.15,63.94],[-21.45,63.86],[-22.65,63.83],[-22.69,63.87],[-22.74,64.02],[-22.7,64.08],[-22.51,63.99],[-22.06,64.07],[-21.67,64.35],[-21.46,64.38],[-21.65,64.4],[-22.05,64.31],[-21.9,64.39],[-22,64.41],[-21.95,64.52],[-21.59,64.63],[-22.16,64.54],[-22.33,64.63],[-22.25,64.73],[-22.47,64.8],[-24.02,64.86],[-23.32,64.96],[-22.79,65.05],[-21.89,65.05],[-21.8,65.11],[-21.78,65.19],[-22.04,65.13],[-22.51,65.2],[-21.84,65.45],[-22.31,65.48],[-22.64,65.57],[-24.47,65.52],[-23.86,65.54],[-24.09,65.78],[-23.29,65.75],[-23.83,65.85],[-23.52,65.88],[-23.78,66.02],[-23.45,66.18],[-22.44,65.91],[-22.95,66.21],[-22.48,66.27],[-23.12,66.34],[-22.89,66.44],[-21.41,66.03],[-21.38,65.74],[-21.66,65.72],[-21.36,65.58],[-21.43,65.47],[-21.23,65.42],[-21.13,65.27],[-21.05,65.43],[-20.45,65.57],[-20.21,66.1],[-19.49,65.77],[-19.38,66.08],[-18.84,66.18],[-18.14,65.73],[-18.3,66.16],[-17.55,65.96],[-16.49,66.2],[-16.54,66.45],[-16.25,66.52],[-15.65,66.26]],[[-94.29,76.91],[-93.21,76.75],[-93.53,76.45],[-91.31,76.68],[-90.54,76.5],[-91.41,76.46],[-89.29,76.3],[-91.41,76.22],[-89.28,75.79],[-89.65,75.57],[-88.92,75.45],[-88.65,75.66],[-85.95,75.4],[-83.93,75.82],[-82.15,75.83],[-79.66,75.45],[-79.51,75.26],[-80.38,75.03],[-79.4,74.92],[-80.35,74.9],[-80.15,74.8],[-80.28,74.58],[-81.94,74.47],[-82.93,74.57],[-83.52,74.9],[-83.34,74.77],[-83.53,74.59],[-84.43,74.51],[-88.42,74.49],[-88.34,74.78],[-88.53,74.83],[-89.56,74.56],[-90.88,74.82],[-91.51,74.65],[-92.39,75.26],[-92.07,75.66],[-92.18,75.85],[-93.09,76.35],[-95.27,76.26],[-96.04,76.49],[-95.65,76.58],[-96.9,76.75],[-96.4,76.8],[-96.76,76.97],[-95.85,77.07],[-94.61,76.96]],[[173.12,-41.28],[173.95,-40.92],[173.8,-41.27],[174,-40.99],[174.3,-41.02],[174.04,-41.24],[174.37,-41.1],[174.07,-41.43],[174.21,-41.85],[172.53,-43.47],[173.1,-43.84],[172.04,-43.7],[172.18,-43.9],[171.24,-44.26],[170.78,-45.87],[169.69,-46.55],[169.1,-46.63],[168.38,-46.61],[167.54,-46.15],[166.83,-46.23],[166.92,-45.96],[166.49,-45.96],[167,-45.71],[166.73,-45.54],[166.87,-45.31],[167.16,-45.41],[167.03,-45.12],[167.91,-44.67],[168.37,-44.08],[169.18,-43.91],[171.04,-42.86],[172.27,-40.76],[172.94,-40.52],[172.7,-40.67],[173.07,-41.19]],[[16.79,79.91],[17.83,79.8],[17.67,79.39],[18.4,79.61],[18.82,79.43],[18.68,79.26],[20.61,79.11],[20.77,79.06],[20.5,78.98],[21.39,78.74],[19.15,78.38],[16.7,76.58],[14,77.51],[16.91,77.9],[14.09,77.77],[13.68,78.03],[17.17,78.42],[16.45,78.5],[16.78,78.66],[15.42,78.47],[15.38,78.77],[14.69,78.72],[14.43,78.49],[14.64,78.41],[13.15,78.24],[11.37,78.95],[12.4,78.95],[11.98,79.03],[11.98,79.29],[11.21,79.13],[10.68,79.76],[13.69,79.86],[13.92,79.76],[12.56,79.57],[13.96,79.34],[14.59,79.8],[16.34,78.98],[15.83,79.71],[16.25,80.05],[16.52,80.02]],[[67.77,76.24],[61.36,75.32],[59.67,74.61],[58.53,74.5],[58.62,74.23],[57.77,74.01],[57.76,73.77],[57.31,73.84],[57.54,73.66],[56.63,73.31],[54.3,73.35],[53.76,73.77],[55.34,74.42],[56.14,74.5],[55.58,74.63],[56.5,74.96],[55.81,75.12],[57.61,75.34],[58.88,75.86],[60.94,76.07],[61.2,76.28],[64.46,76.38],[67.53,77.01],[68.94,76.71],[68.16,76.28]],[[124.89,1],[124.43,0.47],[123.75,0.31],[120.58,0.53],[120.19,0.27],[120.06,-0.55],[120.67,-1.37],[121.15,-1.34],[121.58,-0.83],[121.97,-0.93],[123.17,-0.57],[123.43,-0.78],[123.38,-1],[122.9,-0.9],[122.25,-1.55],[121.36,-1.88],[122.29,-2.91],[122.25,-3.62],[122.85,-4.07],[122.87,-4.39],[122.12,-4.54],[122.04,-4.83],[121.59,-4.76],[121.62,-4.09],[120.89,-3.52],[121.05,-2.75],[120.65,-2.67],[120.26,-2.95],[120.43,-5.59],[119.56,-5.61],[119.36,-5.32],[119.62,-4.03],[119.47,-3.51],[118.92,-3.48],[118.78,-2.72],[119.32,-1.93],[119.51,-0.91],[119.71,-0.68],[119.84,-0.86],[119.72,-0.09],[120.27,0.97],[120.6,0.85],[121.08,1.33],[122.84,0.85],[123.85,0.84],[125.11,1.69],[125.23,1.5],[124.97,1.08]],[[-55.46,51.54],[-56.03,51.33],[-55.8,51.03],[-56.82,49.61],[-56.18,50.12],[-56.16,49.94],[-55.5,49.98],[-56.14,49.62],[-55.23,49.51],[-55.35,49.08],[-54.5,49.53],[-54.45,49.33],[-53.62,49.32],[-53.57,49.14],[-54.16,48.79],[-53.71,48.66],[-54.11,48.39],[-53.03,48.63],[-53.87,48.02],[-53.64,48.02],[-53.86,47.8],[-53.67,47.65],[-52.86,48.11],[-53.17,47.51],[-52.78,47.77],[-52.65,47.55],[-53.07,46.68],[-53.59,46.64],[-53.6,47.15],[-54.18,46.88],[-53.85,47.44],[-54.19,47.86],[-54.49,47.4],[-55.79,46.87],[-55.92,47.02],[-54.78,47.66],[-55.58,47.46],[-56.13,47.5],[-55.86,47.82],[-56.77,47.57],[-59.26,47.63],[-59.34,47.93],[-58.33,48.52],[-59.17,48.56],[-58.71,48.6],[-58.41,49.08],[-57.99,48.99],[-58.21,49.39],[-57.79,49.49],[-57.93,49.7],[-57.04,51.01],[-56.03,51.57],[-55.45,51.56]],[[-108.29,76.06],[-107.72,76],[-108.02,75.8],[-107.21,75.89],[-106.91,75.68],[-106.68,76.02],[-105.9,76.01],[-105.48,75.7],[-106.09,75.09],[-108.83,75.07],[-112.52,74.42],[-114.38,74.67],[-111.03,75.23],[-113.71,75.07],[-113.85,75.26],[-113.47,75.42],[-114.01,75.43],[-114.52,75.28],[-114.45,75.09],[-115.73,74.97],[-117.6,75.27],[-115.14,75.68],[-117.16,75.65],[-114.99,75.9],[-116.66,75.96],[-116.21,76.19],[-114.78,76.17],[-115.83,76.3],[-115,76.5],[-112.7,76.2],[-111.05,75.55],[-109.09,75.51],[-108.92,75.67],[-109.87,75.93],[-109.43,76.11],[-110.31,76.4],[-108.83,76.82],[-108.47,76.74],[-108.63,76.59],[-108.12,76.23],[-108.39,76.07]],[[173.27,-34.93],[174.37,-35.33],[174.54,-35.58],[174.51,-35.67],[174.58,-35.79],[174.39,-35.8],[174.8,-36.31],[174.75,-36.49],[174.82,-36.61],[174.72,-36.84],[174.89,-36.91],[174.95,-36.85],[175.3,-36.99],[175.38,-37.21],[175.54,-37.2],[175.49,-36.69],[175.38,-36.56],[175.46,-36.48],[175.68,-36.75],[175.77,-36.73],[175.99,-37.44],[176.12,-37.54],[176.13,-37.59],[176.03,-37.58],[176.11,-37.64],[177.27,-37.99],[178.01,-37.55],[178.53,-37.69],[177.91,-39.24],[177.08,-39.22],[176.84,-40.16],[175.98,-41.21],[175.31,-41.61],[174.87,-41.22],[174.64,-41.29],[175.21,-40.2],[173.76,-39.32],[174.57,-38.84],[174.65,-38.43],[174.84,-38.02],[174.8,-37.9],[174.93,-37.8],[174.73,-37.45],[174.77,-37.34],[174.71,-37.33],[174.59,-37.1],[174.66,-37.09],[174.73,-37.22],[174.81,-37.11],[174.93,-37.09],[174.78,-36.94],[174.6,-36.98],[174.47,-36.94],[174.38,-36.73],[174.19,-36.49],[174.4,-36.6],[174.46,-36.51],[174.36,-36.38],[174.39,-36.24],[174.27,-36.16],[174.25,-36.25],[174.03,-36.12],[173.92,-35.91],[173.92,-36.02],[174.17,-36.33],[174.15,-36.38],[174.06,-36.36],[173.41,-35.54],[173.63,-35.32],[173.31,-35.44],[172.71,-34.46],[173.04,-34.43],[173.24,-34.9]],[[-7.18,55.06],[-6.13,55.22],[-5.72,54.82],[-5.71,54.76],[-5.88,54.68],[-5.88,54.64],[-5.58,54.66],[-5.47,54.5],[-5.48,54.44],[-5.67,54.55],[-5.66,54.38],[-5.56,54.37],[-5.61,54.27],[-5.83,54.24],[-6.02,54.05],[-6.22,54.09],[-6.16,54.02],[-6.35,53.99],[-6.14,53.58],[-6.15,53.37],[-6.03,52.93],[-6.17,52.74],[-6.22,52.54],[-6.46,52.34],[-6.32,52.25],[-6.89,52.16],[-6.96,52.25],[-7.08,52.14],[-7.22,52.14],[-9.3,51.5],[-10.12,51.6],[-9.6,51.87],[-10.34,51.8],[-9.91,52.12],[-10.36,52.21],[-8.78,52.68],[-9.92,52.57],[-8.93,53.21],[-10.09,53.41],[-9.58,53.8],[-9.91,53.86],[-10.06,54.26],[-8.54,54.24],[-8.13,54.64],[-8.76,54.68],[-8.27,55.15],[-7.67,55.26],[-7.66,54.97],[-7.31,55.37],[-6.96,55.24],[-7.22,55.09]],[[107.37,-6.01],[107.56,-6.18],[108.14,-6.3],[108.29,-6.26],[108.42,-6.38],[108.78,-6.81],[110.43,-6.95],[110.84,-6.42],[112.54,-6.93],[113.01,-7.66],[114.41,-7.79],[114.58,-8.77],[113.25,-8.29],[111.51,-8.3],[107.29,-7.47],[106.53,-7.39],[106.41,-7.31],[106.52,-7.05],[105.94,-6.86],[105.48,-6.85],[105.26,-6.84],[105.34,-6.67],[105.37,-6.66],[105.4,-6.77],[105.48,-6.78],[105.66,-6.47],[105.79,-6.46],[105.87,-6.12],[106.07,-5.91],[106.83,-6.1],[107.01,-6.01],[107.05,-5.9],[107.33,-5.98]],[[142.76,54.39],[143.33,52.96],[143.19,51.95],[144.71,48.64],[144.05,49.25],[143.1,49.2],[142.56,47.74],[143.58,46.36],[143.43,46.03],[143.28,46.56],[142.58,46.7],[142.08,45.92],[141.83,46.45],[142.18,48.01],[141.86,48.75],[142.14,49.57],[142.21,51.22],[141.72,51.74],[141.66,52.27],[141.83,53.34],[142.53,53.45],[142.71,53.89],[142.34,54.28],[142.69,54.42]],[[-81.84,23.16],[-79.82,22.89],[-79.27,22.41],[-77.5,21.87],[-76.87,21.33],[-75.72,21.11],[-75.72,20.71],[-74.88,20.65],[-74.16,20.17],[-75.12,19.9],[-77.72,19.86],[-77.1,20.41],[-77.23,20.64],[-78.12,20.76],[-78.73,21.59],[-79.36,21.58],[-81.19,22.27],[-81.85,22.21],[-82.08,22.39],[-81.71,22.5],[-81.84,22.67],[-82.74,22.69],[-84.03,21.94],[-84.89,21.86],[-84.33,22.07],[-84.36,22.38],[-84.04,22.67],[-82.1,23.19]],[[143.82,44.12],[144.72,43.93],[145.37,44.33],[145.14,43.66],[145.34,43.3],[145.83,43.39],[143.97,42.88],[143.24,42],[141.85,42.58],[140.99,42.34],[140.48,42.56],[140.33,42.29],[141.15,41.81],[140.04,41.47],[139.86,42.58],[140.43,42.95],[140.39,43.3],[141.38,43.28],[141.76,44.48],[141.67,45.4],[141.94,45.51],[143.76,44.13]],[[121.1,18.62],[121.85,18.29],[122.27,18.46],[122.15,17.66],[122.52,17.12],[122.14,16.19],[121.69,16.02],[121.6,15.93],[121.56,15.83],[121.61,15.67],[121.39,15.32],[121.69,14.77],[121.63,14.58],[121.77,14.17],[121.91,14.02],[122.21,13.93],[122.29,14],[122.2,14.15],[122.49,14.32],[122.94,14.19],[123.1,13.75],[123.32,14.06],[123.86,13.8],[123.55,13.65],[123.79,13.11],[124.14,13.04],[124.06,12.57],[123.95,12.92],[123.31,13.04],[122.59,13.91],[122.6,13.19],[122.21,13.65],[122.07,13.79],[121.78,13.94],[121.5,13.84],[121.45,13.71],[121.34,13.65],[121.1,13.68],[120.93,13.76],[120.84,13.89],[120.73,13.9],[120.64,13.81],[120.62,14.19],[120.92,14.49],[120.94,14.65],[120.59,14.88],[120.55,14.77],[120.59,14.48],[120.44,14.45],[120.25,14.79],[120.08,14.85],[119.93,15.43],[119.77,16.25],[120.37,16.11],[120.6,18.51],[121.05,18.61]],[[-100,73.95],[-99.16,73.73],[-97.11,73.79],[-97,73.67],[-97.63,73.5],[-97.27,73.39],[-98.43,72.96],[-97.63,73.03],[-97.13,72.63],[-96.54,72.7],[-96.47,72.43],[-96.8,72.32],[-96.61,71.83],[-97.58,71.63],[-98.32,71.85],[-98.2,71.44],[-99.17,71.37],[-100.59,72.15],[-102.71,72.77],[-102.2,73.08],[-101.27,72.72],[-100.13,72.91],[-100.54,73.2],[-99.82,73.21],[-101.52,73.49],[-100.52,73.45],[-100.99,73.77],[-100.14,73.93]],[[55.32,73.31],[56.43,73.2],[56.12,72.81],[55.4,72.55],[55.52,72.22],[55.3,71.94],[56.45,71.11],[57.62,70.73],[56.26,70.71],[56.44,70.56],[53.72,70.81],[53.38,70.87],[54.16,71.12],[53.41,71.34],[53.41,71.53],[51.81,71.49],[51.44,71.78],[51.58,72.07],[52.62,72.3],[52.92,72.67],[52.55,72.77],[53.37,72.92],[53.25,73.18],[55.12,73.36]],[[-84.92,65.26],[-84.5,65.46],[-82.05,64.64],[-81.68,64.21],[-81.89,64.02],[-80.83,64.09],[-80.26,63.8],[-81.05,63.46],[-83.3,64.14],[-84.63,63.31],[-85.39,63.12],[-85.77,63.7],[-87.18,63.6],[-86.25,64.14],[-86.37,64.57],[-85.81,65.83],[-85.24,65.8],[-85.06,65.44]],[[126.01,9.32],[126.31,8.95],[126.14,8.6],[126.46,8.2],[126.58,7.25],[126.19,6.85],[126.19,6.31],[125.69,7.26],[125.38,6.69],[125.67,5.98],[125.35,5.6],[125.23,6.07],[124.93,5.88],[124.08,6.4],[123.99,6.99],[124.21,7.4],[123.67,7.82],[123.39,7.41],[122.62,7.76],[122.14,6.95],[121.9,7.07],[122.24,7.94],[122.91,8.16],[123.44,8.7],[123.85,8.43],[123.8,8.05],[124.4,8.6],[124.73,8.56],[124.87,8.97],[125.5,9.01],[125.47,9.76],[125.96,9.43]],[[140.05,75.83],[140.82,75.63],[140.99,75.96],[141.49,76.14],[145.36,75.53],[144.02,75.04],[142.82,75.27],[142.7,75.45],[142.94,75.71],[142.31,75.69],[142.09,75.66],[142.2,75.39],[143.13,74.97],[139.68,74.96],[139.1,74.66],[138.09,74.8],[136.95,75.33],[137.29,75.35],[137.27,75.75],[137.71,75.76],[137.56,75.96],[138.21,76.12],[138.92,76.2],[139.74,75.95]],[[-93.17,74.16],[-90.36,73.87],[-92.12,72.75],[-94.21,72.76],[-93.54,72.44],[-94.14,72],[-95.19,72.03],[-95.6,72.88],[-95.63,73.7],[-94.7,73.66],[-95.15,73.91],[-94.97,74.04],[-93.41,74.18]],[[145.04,-40.79],[146.32,-41.16],[148.22,-40.85],[148.34,-42.22],[148.22,-41.97],[148.02,-42.26],[147.98,-43.16],[147.3,-42.79],[146.87,-43.61],[146.04,-43.55],[146.21,-43.32],[145.49,-42.93],[145.2,-42.23],[145.52,-42.35],[144.77,-41.39],[144.72,-40.67],[144.82,-40.72]],[[20.9,80.25],[22.29,80.05],[22.45,80.4],[23.01,80.47],[23.32,80.42],[23.11,80.19],[24.4,80.36],[26.86,80.16],[27.2,79.91],[23.95,79.19],[20.13,79.49],[19.68,79.59],[20.78,79.75],[18.73,79.76],[18.25,79.93],[18.86,80.04],[17.92,80.14],[19.34,80.12],[19.54,80.16],[19.18,80.33],[19.75,80.23],[19.73,80.48],[20.69,80.3]],[[-71.96,19.72],[-70.95,19.91],[-69.96,19.67],[-69.74,19.3],[-69.23,19.27],[-69.62,19.12],[-68.68,18.9],[-68.36,18.54],[-68.69,18.21],[-69.27,18.44],[-71.03,18.27],[-71.44,17.63],[-72.06,18.23],[-73.51,18.25],[-73.89,18.04],[-74.46,18.39],[-74.23,18.66],[-72.38,18.57],[-72.81,19.07],[-72.7,19.44],[-73.44,19.72],[-72.88,19.93],[-72.22,19.74]],[[-69.17,-52.67],[-68.63,-52.65],[-68.24,-53.08],[-68.49,-53.26],[-67.29,-54.05],[-66.24,-54.53],[-65.18,-54.68],[-66.51,-55.03],[-71.9,-54.6],[-70.8,-54.33],[-70.31,-54.53],[-70.86,-54.11],[-70.53,-53.63],[-70.38,-53.99],[-70.63,-54],[-70.24,-54.35],[-69.05,-54.43],[-70.15,-53.89],[-69.39,-53.37],[-70.21,-53.41],[-70.46,-53.21],[-70.13,-52.94],[-70.38,-52.75],[-69.94,-52.82],[-69.5,-52.49],[-69.41,-52.49]],[[97.67,80.16],[98.02,80.02],[97.65,79.76],[98.6,80.05],[99.95,79.85],[99.68,79.32],[99.04,79.29],[99.93,78.96],[97.56,78.83],[93.07,79.5],[94.99,80.1],[97.59,80.17]],[[-115.55,77.36],[-116.33,77.14],[-115.81,76.94],[-116.25,76.9],[-115.94,76.71],[-117,76.53],[-117.23,76.28],[-117.99,76.41],[-117.88,76.8],[-118.79,76.51],[-118.62,76.37],[-118.99,76.15],[-119.58,76.33],[-119.74,76.12],[-119.54,75.98],[-119.91,75.86],[-120.41,75.83],[-120.85,76.18],[-122.4,75.94],[-122.9,76.13],[-119.09,77.3],[-116.84,77.34],[-117.04,77.46],[-116.51,77.55],[-116.01,77.46]],[[79.98,9.81],[80.71,9.37],[81.83,7.43],[81.77,6.61],[81.38,6.24],[80.73,5.98],[80.5,5.95],[80.27,6.01],[80.1,6.15],[79.86,6.83],[79.71,8.07],[79.75,8.29],[79.75,8.05],[79.81,8.05],[79.85,8.41],[80.08,9.58],[80.43,9.48],[79.97,9.79]],[[-97.7,76.47],[-97.53,76.11],[-97.89,75.76],[-97.41,75.67],[-97.34,75.42],[-97.88,75.42],[-97.66,75.15],[-98.07,75.2],[-97.99,75.05],[-100.23,75.01],[-100.48,75.19],[-100.14,75.25],[-100.73,75.35],[-99.19,75.7],[-102.8,75.6],[-102.15,75.87],[-100.97,75.8],[-101.87,76.08],[-101.56,76.24],[-102.14,76.28],[-101.79,76.45],[-99.87,75.92],[-99.69,75.96],[-100.11,76.12],[-99.54,76.15],[-100.89,76.48],[-100.07,76.63],[-98.89,76.47],[-99.02,76.61],[-98.71,76.69],[-97.72,76.5]],[[96.53,81.08],[97.86,80.7],[97.11,80.61],[97.42,80.32],[97.17,80.24],[93.87,80.01],[91.53,80.36],[92.83,80.62],[93.26,80.79],[92.61,80.81],[93.36,81.03],[95.16,81.27],[96.47,81.1]],[[-103.43,79.32],[-102.58,78.88],[-101.7,79.08],[-100.01,78.73],[-99.58,78.56],[-99.75,78.3],[-99,78],[-99.96,77.79],[-101.07,78.19],[-104.51,78.29],[-105,78.52],[-103.57,78.54],[-104.02,78.63],[-103.37,78.74],[-104.18,78.78],[-103.88,78.9],[-104.15,78.99],[-104.9,78.81],[-104.75,79.03],[-105.58,79.11],[-105.39,79.32],[-103.71,79.35]],[[102.88,79.25],[102.41,78.84],[103.8,79.15],[105.34,78.59],[104.74,78.34],[99.29,78.04],[100.42,78.75],[100.95,78.79],[101.05,79.12],[101.59,79.35],[103.1,79.3],[102.94,79.27]],[[131.18,33.6],[131.69,33.6],[131.54,33.27],[131.9,33.25],[132.01,32.92],[131.34,31.4],[131.07,31.44],[130.69,31.01],[130.78,31.71],[130.59,31.18],[130.15,31.41],[130.55,32.83],[130.24,33.18],[130.34,32.7],[129.77,32.57],[129.68,33.06],[129.99,32.85],[129.58,33.24],[130.72,33.93],[131.06,33.67]],[[-127.2,50.64],[-125.48,50.32],[-124.83,49.53],[-123.85,49.12],[-123.5,48.58],[-123.41,48.7],[-123.29,48.46],[-123.31,48.41],[-123.45,48.43],[-123.57,48.32],[-125.12,48.76],[-124.81,49.21],[-125.49,48.93],[-125.93,49.4],[-126.52,49.4],[-126.54,49.59],[-126.13,49.67],[-127.12,49.88],[-127.25,50.14],[-127.86,50.13],[-127.91,50.45],[-127.49,50.41],[-127.46,50.58],[-128.35,50.7],[-127.92,50.86],[-127.71,50.82]],[[121.01,22.62],[120.84,21.92],[120.08,23.09],[120.13,23.65],[120.63,24.48],[121.04,25.03],[121.59,25.28],[121.91,25.06],[121.93,24.97],[121.82,24.82],[121.83,24.53],[121.64,24.13],[121.52,23.67],[121.16,22.78]],[[-79.54,73.65],[-77.21,73.5],[-76.09,72.88],[-79.5,72.76],[-80.78,73.33],[-80.86,73.67],[-79.89,73.7]],[[-49.63,-0.23],[-48.39,-0.3],[-48.83,-1.39],[-49.8,-1.79],[-50.51,-1.79],[-50.79,-0.91],[-50.65,-0.27],[-50.25,-0.12]],[[110.89,19.99],[111.01,19.66],[110.02,18.42],[109.52,18.22],[108.7,18.54],[108.67,19.3],[109.26,19.88],[110.65,20.14],[110.81,20.02]],[[151.92,-4.3],[152.41,-4.34],[152.35,-4.82],[151.98,-5.07],[152.08,-5.46],[151.52,-5.55],[150.47,-6.26],[149.65,-6.29],[148.34,-5.67],[148.43,-5.47],[149.83,-5.52],[150.09,-5.01],[150.18,-5.52],[150.74,-5.51],[151.67,-4.88],[151.59,-4.2],[151.87,-4.26]],[[-97.44,69.64],[-95.27,68.83],[-96.6,68.46],[-99.56,69.03],[-98.5,69.31],[-98.55,69.57],[-98.04,69.46],[-98.3,69.67],[-98.08,69.83],[-97.47,69.67]],[[21.61,78.6],[22.04,78.58],[22.3,78.23],[23.45,78.15],[23.12,77.99],[24.9,77.76],[22.8,77.28],[22.43,77.32],[22.69,77.55],[21.05,77.44],[20.87,77.57],[21.65,77.92],[20.23,78.48],[21.45,78.6]],[[15.58,38.22],[15.1,37.46],[15.29,37.06],[15.11,36.69],[14.37,36.97],[14.14,37.1],[13.8,37.14],[12.92,37.57],[12.64,37.59],[12.44,37.82],[12.55,38.05],[12.74,38.18],[12.9,38.03],[13.16,38.19],[13.35,38.18],[13.38,38.13],[13.79,37.98],[14.05,38.04],[14.51,38.05],[14.79,38.17],[15.63,38.27]],[[9.63,40.88],[9.8,40.5],[9.56,39.17],[9.06,39.24],[8.97,38.96],[8.65,38.93],[8.42,39.21],[8.55,39.84],[8.2,40.87],[9.23,41.26],[9.57,40.91]],[[127.3,-8.42],[125.41,-9.28],[124.43,-10.15],[123.61,-10.27],[123.71,-9.62],[125.18,-8.65],[127.26,-8.39]],[[-93.54,75.03],[-93.57,74.67],[-94.54,74.64],[-96.6,75.06],[-95.95,75.44],[-94.88,75.63],[-93.91,75.42],[-93.55,75.05]],[[134.36,34.26],[134.64,34.23],[134.68,33.85],[134.74,33.82],[134.38,33.61],[134.18,33.25],[133.69,33.52],[133.29,33.36],[132.87,32.75],[132.49,32.92],[132.41,33.43],[132.03,33.34],[132.94,34.1],[133.47,33.97],[133.95,34.35],[134.07,34.36],[134.22,34.32]],[[-75.67,68.32],[-75.06,68.14],[-75.13,67.54],[-75.4,67.37],[-76.95,67.25],[-77.31,67.69],[-76.69,68.26],[-75.87,68.34]],[[-96.21,78.53],[-94.92,78.39],[-95.33,78.22],[-94.93,78.08],[-96.99,77.81],[-97.66,78.09],[-96.94,78.15],[-98.05,78.33],[-98.34,78.75],[-96.26,78.55]],[[-52.73,69.94],[-51.9,69.6],[-53.75,69.26],[-54.18,69.4],[-53.66,69.47],[-53.83,69.54],[-54.92,69.71],[-54.79,69.95],[-54.32,69.94],[-54.83,70.13],[-54.37,70.32],[-53.1,70.14]],[[-110.46,78.1],[-109.62,78.06],[-110.86,77.83],[-110.15,77.76],[-110.2,77.53],[-111.95,77.34],[-113.17,77.53],[-113.28,77.81],[-110.73,78.1]],[[146.8,75.37],[150.82,75.16],[150.58,74.92],[149.05,74.77],[146.15,75.2],[146.44,75.56],[146.75,75.43]],[[127.73,0.85],[128.69,1.57],[128.7,1.11],[128.26,0.73],[128.9,0.22],[127.98,0.47],[127.89,0.3],[128.43,-0.89],[127.69,-0.24],[127.43,1.14],[127.63,1.84],[128.04,2.2],[128.01,1.33],[127.68,0.89]],[[180,71.54],[181.56,71.54],[182.5,71.22],[178.79,70.82],[178.63,71.05],[179.88,71.52]],[[142.19,73.9],[143.34,73.57],[143.49,73.25],[139.69,73.42],[141.08,73.87],[141.93,73.91]],[[-152.9,57.82],[-152.43,57.83],[-152.21,57.58],[-152.94,57.5],[-152.68,57.34],[-153.97,56.77],[-153.79,56.99],[-154.25,57.14],[-154.34,56.92],[-154.71,57.34],[-154.12,57.65],[-153.69,57.3],[-153.84,57.86],[-152.85,57.9]],[[129.75,-2.87],[130.57,-3.13],[130.81,-3.86],[129.84,-3.33],[129.47,-3.45],[128.86,-3.24],[128.52,-3.45],[128.13,-3.16],[127.9,-3.5],[128.2,-2.87],[129.6,-2.81]],[[50.28,80.93],[51.7,80.69],[48.9,80.37],[48.68,80.3],[48.98,80.16],[48.39,80.1],[46.64,80.3],[49.09,80.52],[49.24,80.82],[50.13,80.92]],[[164.2,-20.25],[165.19,-20.77],[166.97,-22.32],[166.47,-22.26],[164.93,-21.29],[164.06,-20.14]],[[122.78,-8.61],[121.04,-8.93],[119.81,-8.7],[119.88,-8.42],[120.61,-8.24],[122.32,-8.63],[122.92,-8.1],[122.82,-8.6]],[[125.24,12.53],[125.54,12.19],[125.74,11.05],[125.03,11.34],[125,11.77],[124.44,12.15],[124.29,12.57],[125.15,12.57]],[[-105.29,72.92],[-106.95,73.51],[-105.51,73.77],[-104.59,73.58],[-104.62,73.31],[-105.2,72.95]],[[-133.57,56.34],[-133.2,56.32],[-132.17,55.48],[-132.63,55.47],[-131.98,55.21],[-132.02,54.73],[-133.12,55.33],[-133.03,55.59],[-133.68,55.79],[-133.24,55.92],[-133.74,55.96],[-133.6,56.32]],[[12.57,55.79],[12.54,55.66],[12.32,55.59],[12.22,55.47],[12.39,55.39],[12.41,55.29],[12.09,55.19],[12.05,54.81],[11.86,54.77],[11.74,54.92],[11.66,55.19],[11.29,55.2],[11.17,55.33],[11.19,55.47],[11.12,55.6],[11.01,55.64],[10.98,55.72],[11.32,55.75],[11.48,55.94],[11.63,55.96],[11.69,55.91],[11.69,55.73],[11.82,55.7],[11.94,55.9],[11.87,55.97],[12.22,56.12],[12.58,56.06],[12.61,56.03],[12.53,55.92]],[[34.46,35.59],[33.94,35.29],[34.05,34.99],[33.01,34.57],[32.32,34.95],[32.94,35.39],[34.55,35.66]],[[-25.43,70.92],[-25.4,70.65],[-26.22,70.45],[-28.04,70.49],[-27.62,70.91],[-25.46,70.94]],[[106.04,-1.67],[106.36,-2.46],[106.82,-2.57],[106.67,-3.07],[106,-2.83],[105.79,-2.18],[105.13,-2.04],[105.46,-1.57],[106.03,-1.59]],[[-82,62.96],[-82.12,62.65],[-83.02,62.21],[-83.7,62.16],[-83.91,62.43],[-83.38,62.9],[-82.05,62.97]],[[122.5,11.61],[123.16,11.54],[123.12,11.29],[122.77,10.82],[121.95,10.44],[122.1,11.64],[121.92,11.85],[122.4,11.7]],[[-61.11,45.94],[-60.86,45.98],[-61.06,45.7],[-60.74,45.75],[-60.3,46.31],[-59.83,45.96],[-60.67,45.59],[-61.45,45.72],[-61.41,46.17],[-60.49,47.01],[-60.49,46.27],[-60.91,46.04]],[[123.13,9.06],[122.4,9.82],[122.86,10.09],[122.98,10.89],[123.26,10.99],[123.57,10.78],[123.16,9.86],[123.32,9.27],[123.19,9.09]],[[-73.77,-43.35],[-74.39,-43.23],[-74.04,-41.8],[-73.53,-41.9],[-73.42,-42.19],[-73.79,-42.59],[-73.44,-42.94],[-73.74,-43.29]],[[118.24,-8.32],[118.93,-8.3],[119.13,-8.67],[116.79,-9.01],[116.83,-8.53],[117.16,-8.37],[117.97,-8.73],[118.23,-8.59],[117.76,-8.15],[118.2,-8.27]],[[62.17,80.83],[62.08,80.62],[61.05,80.42],[59.29,80.57],[59.72,80.84],[62.1,80.87]],[[117.31,8.44],[117.35,8.71],[119.22,10.48],[119.55,11.31],[119.69,10.5],[117.41,8.5]],[[-109.82,78.65],[-109.35,78.37],[-113.29,78.33],[-110.88,78.74],[-109.94,78.68]],[[54.72,81.12],[57.69,80.79],[55.89,80.63],[54.07,80.81],[54.63,81.11]],[[9.48,42.81],[9.56,42.16],[9.19,41.39],[8.81,41.59],[8.57,42.36],[9.32,42.71],[9.36,43.02],[9.48,42.86]],[[50.27,69.19],[48.91,68.74],[48.28,69.04],[48.42,69.35],[48.96,69.51],[50.17,69.26]],[[178.28,-17.37],[178.67,-18.08],[177.96,-18.26],[177.32,-18.08],[177.51,-17.54],[178.25,-17.33]],[[-61.8,49.09],[-63.04,49.23],[-64.49,49.89],[-62.86,49.71],[-61.75,49.11]],[[-77.26,18.46],[-76.21,17.91],[-76.85,17.97],[-77.2,17.71],[-78.34,18.29],[-77.36,18.47]],[[-44.87,82.08],[-47.35,82.6],[-44.92,82.48],[-44.78,82.24]]].map(poly=>poly.map(q=>proj(q[0],q[1])));
|
||
const CITY_LL={"man":[-2.24,53.48],"edi":[-3.19,55.95],"bde":[-4.54,50.83],"svg":[5.73,58.97],"bcn":[2.17,41.39],"mil":[9.19,45.46],"rom":[12.5,41.9],"pmo":[13.36,38.12],"lis":[-9.14,38.72],"ath":[23.73,37.98],"atn":[-84.39,33.75],"den":[-104.99,39.74],"phx":[-112.07,33.45],"bos":[-71.06,42.36],"hou":[-95.37,29.76],"slc":[-111.89,40.76],"jed":[39.25,21.55],"ruh":[46.72,24.71],"doh":[51.45,25.28],"kyv":[30.52,50.45],"mel":[144.96, -37.81],"bne":[153.03, -27.47],"drw":[131.05,-12.46],"osa":[135.5, 34.69],"kul":[101.69, 3.14],"bkk":[100.5, 13.76],"sgn":[106.66, 10.76],"khi":[67.14,25.0],"dac":[90.41, 23.81],"cbo":[80.0, 6.95],"waw":[21.01, 52.23],"prg":[14.42, 50.08],"vie":[16.37, 48.21],"bud":[19.04, 47.5],"buh":[26.1, 44.43],"tll":[24.45,58.9],"ist":[28.98, 41.01],"for":[-38.54, -3.73],"rio":[-43.11,-22.57],"bue":[-58.38, -34.6],"scl":[-70.67, -33.45],"lim":[-76.85,-12.05],"bog":[-74.07, 4.71],"pan":[-79.52, 8.98],"del":[77.21, 28.61],"maa":[80.18,13.25],"blr":[77.59, 12.97],"hyd":[78.49, 17.39],"tpe":[121.56, 25.03],"auh":[54.37, 24.45],"fuj":[56.15,25.07],"cpt":[18.42, -33.92],"stg":[9.18,48.78],"ber":[13.4,52.52],"zrh":[8.54,47.37],"nbo":[36.82,-1.29],"cai":[31.24,30.04],"sea":[-122.33,47.61],"sjc":[-121.89,37.34],"lax":[-118.24,34.05],"dal":[-96.8,32.78],"chi":[-87.63,41.88],"ash":[-77.49,39.04],"nyc":[-74.0,40.71],"mia":[-80.19,25.76],"tor":[-79.38,43.65],"kcy":[-94.58,39.1],"cal":[-114.07,51.05],"van":[-123.12,49.28],"ott":[-75.7,45.42],"mtl":[-73.57,45.5],"mex":[-99.13,19.43],"sao":[-46.63,-23.55],"lon":[-0.13,51.51],"dub":[-6.26,53.35],"rek":[-21.94,64.15],"ams":[4.9,52.37],"bru":[4.35,50.85],"oos":[3.23,51.15],"bet":[6.1,49.52],"fra":[8.68,50.11],"ham":[9.99,53.55],"muc":[11.58,48.14],"par":[2.35,48.86],"mrs":[5.37,43.3],"mad":[-3.7,40.42],"sto":[18.07,59.33],"osl":[10.75,59.91],"cph":[12.57,55.68],"hel":[24.94,60.17],"beg":[20.46,44.79],"sof":[23.32,42.7],"mos":[37.62,55.76],"lag":[3.38,6.52],"jnb":[28.05,-26.2],"dxb":[55.27,25.2],"bom":[72.88,19.08],"sin":[103.82,1.35],"jkt":[106.85,-6.2],"mnl":[120.98,14.6],"hkg":[114.17,22.32],"sha":[121.47,31.23],"pek":[116.4,39.9],"icn":[126.98,37.57],"tok":[139.69,35.69],"syd":[151.21,-33.87],"per":[115.86,-31.95],"akl":[174.76,-36.85]};
|
||
const CITIES=[
|
||
{id:'sea',name:'Seattle',x:205,y:245,land:'am',reg:'AM',P:300,ix:'Sea-IX',dc:'Westerly Carrier Hotel'},
|
||
{id:'sjc',name:'San Jose',x:240,y:345,land:'am',reg:'AM',P:500,ix:'Silly-Con Valley IX',dc:'Equinox SV'},
|
||
{id:'dal',name:'Dallas',x:385,y:415,land:'am',reg:'AM',P:450,ix:'Yee-Haw-IX',dc:'Infomaniac Building'},
|
||
{id:'chi',name:'Chicago',x:470,y:270,land:'am',reg:'AM',P:600,ix:'Windy-IX',dc:'350 Cermak'},
|
||
{id:'ash',name:'Ashburn',x:572,y:332,land:'am',reg:'AM',P:250,ix:'Equinox Ashburn IX',dc:'Data Center Alley',note:tr('The data-center capital. Rumor says 70% of the internet passes through here, and nobody has checked.')},
|
||
{id:'nyc',name:'New York',x:615,y:283,land:'am',reg:'AM',P:1200,ix:'NY-Yikes',dc:'60 Hudson'},
|
||
{id:'mia',name:'Miami',x:530,y:482,land:'am',reg:'AM',P:400,ix:'Miam-IX',dc:'Nap of the Americas',note:tr('Cable landing hub for South America.')},
|
||
{id:'sao',name:'São Paulo',x:640,y:730,land:'sa',reg:'SA',P:900,br:true,andes:'e',ix:'IX.brrr',ixCheap:0.3,dc:'Digital Reality SP',note:tr('South America’s biggest market, and home of IX.brrr: run by a nonprofit, public prices, and nearly everyone is on it.')},
|
||
{id:'lon',name:'London',x:935,y:275,land:'uk',reg:'EU',P:1000,ix:'LYNX',dc:'Telly-House Docklands',note:tr('On an island, so every link off it is a subsea cable.')},
|
||
{id:'ams',name:'Amsterdam',x:1015,y:245,land:'eu',reg:'EU',P:350,ix:'HAMS-IX',dc:'Science Park'},
|
||
{id:'fra',name:'Frankfurt',x:1075,y:295,land:'eu',reg:'EU',P:600,ix:'DE-KICKS',dc:'Kleyerstraße Campus',note:tr('Europe\'s crossroads. Lots of networks, lots of sausages.')},
|
||
{id:'par',name:'Paris',x:990,y:320,land:'eu',reg:'EU',P:900,ix:'Fromage-IX',dc:'Interaction PAR'},
|
||
{id:'mrs',name:'Marseille',x:1045,y:378,land:'eu',reg:'EU',P:250,ix:'Bouilla-IX',dc:'Cable Landing Station',note:tr('Subsea cables to Africa and Asia land here.')},
|
||
{id:'tor',name:'Toronto',ca:true,x:548,y:252,land:'am',reg:'AM',P:500,ix:'Sorry-IX',dc:'151 Front Street',note:tr('Canada’s hub. Polite packets, long winters, free cooling.')},
|
||
{id:'bru',name:'Brussels',x:0,y:0,land:'eu',reg:'EU',P:150,be:true,tape:true,ix:'Frites-IX',dc:'Digital Unreality BRU1',note:tr('Right between London, Amsterdam, Paris and Frankfurt, and somehow pricier than all four. Two networks own every Belgian living room, and nobody switches unless you advertise.')},
|
||
{id:'oos',name:'Oostkamp',x:0,y:0,land:'eu',reg:'EU',P:30,be:true,tape:true,ix:'',dc:'DC-Starfish Oostkamp',note:tr('Inland from Ostend, where the cables from England come ashore. The North Sea is shallow, busy and full of trawlers.')},
|
||
{id:'bet',name:'Bettembourg',x:0,y:0,land:'eu',reg:'EU',P:60,arpu:1.4,lux:true,ix:'LU-SICK',dc:'LuxDisconnect DC1.2',note:tr('Luxembourg’s data centers are not in Luxembourg City. They are here, Tier IV, and cooled by a power plant that burns waste wood.')},
|
||
{id:'mtl',name:'Montreal',ca:true,x:598,y:238,land:'am',reg:'AM',P:300,ix:'Poutine-IX',dc:'Hydro-powered Hangar',note:tr('Cheap hydro power makes it a data center favorite.')},
|
||
{id:'kcy',name:'Kansas City',x:0,y:0,land:'am',reg:'AM',P:200,ix:'Toto-IX',dc:'The Limestone Cave',note:tr('The geographic middle of the US. Data centers sit in old limestone mines underground: steady temperature, no tornadoes, and somebody keeps finding Dorothy’s shoes.')},
|
||
{id:'cal',name:'Calgary',x:0,y:0,land:'am',reg:'AM',P:150,ca:true,ix:'Stampede-IX',dc:'Bow & Arrow DC',note:tr('The prairie gateway between Vancouver and the rest of Canada. A chinook melts the snow in an afternoon, then it snows again.')},
|
||
{id:'van',name:'Vancouver',x:0,y:0,land:'am',reg:'AM',P:250,ca:true,ix:'Raincouver-IX',dc:'Colo-Logics VAN3',note:tr('Canada’s Pacific door. It rains so much that the free cooling comes with free washing.')},
|
||
{id:'ott',name:'Ottawa',x:0,y:0,land:'am',reg:'AM',P:120,ca:true,blackout:true,ix:'Bytown-IX',dc:'Purely Colo (Mostly)',note:tr('Canada’s capital, once called Bytown, which suits it. The grid goes out when it is windy, icy or Tuesday, so bring a generator.')},
|
||
{id:'lax',name:'Los Angeles',x:270,y:395,land:'am',reg:'AM',P:900,ix:'Any2-Anywhere',dc:'One Wilshire',note:tr('Pacific cables land nearby, and everyone meets in one famous building downtown.')},
|
||
{id:'mex',name:'Mexico City',x:368,y:470,land:'am',reg:'AM',P:700,ix:'',dc:'Querétaro Campus',note:tr('Huge mobile market. Most of its traffic still detours through the US.')},
|
||
{id:'rek',name:'Reykjavik',x:850,y:170,land:'is',reg:'EU',P:60,ix:'',dc:'Geothermal Bitcoin Barn',note:tr('Free cooling and geothermal power. Plenty of data centers, very few cables.')},
|
||
{id:'dub',name:'Dublin',x:876,y:268,land:'ie',reg:'EU',P:250,ix:'Craic-IX',dc:'Clonsilla Hyperscale Campus',note:tr('Every hyperscaler’s European HQ, mostly for tax reasons. The power grid is nervous.')},
|
||
{id:'osl',name:'Oslo',x:1062,y:172,land:'eu',reg:'EU',P:200,ix:'NIX-NIX',dc:'Fjord-cooled Mountain Hall'},
|
||
{id:'cph',name:'Copenhagen',x:1085,y:215,land:'eu',reg:'EU',P:250,ix:'Hygge-IX',dc:'Danish Design DC',note:tr('Landing point for cables from the US, Iceland and the Baltic.')},
|
||
{id:'hel',name:'Helsinki',x:1168,y:140,land:'eu',reg:'EU',P:200,ix:'Sauna-IX',dc:'Underground Sauna Bunker',note:tr('Fast fiber east and west, and one very nervous subsea cable to Germany.')},
|
||
{id:'beg',name:'Belgrade',x:1122,y:338,land:'eu',reg:'EU',P:250,ix:'',dc:'Danube Docks DC'},
|
||
{id:'sof',name:'Sofia',x:1165,y:358,land:'eu',reg:'EU',P:250,ix:'Rakija-IX',dc:'Vitosha DC',note:tr('Balkan peering hub with famously cheap ports.')},
|
||
{id:'dxb',name:'Dubai',x:1292,y:428,land:'eu',reg:'AS',P:400,uae:true,ix:'Sand-IX',dc:'Air-conditioned Mirage DC',note:tr('Crossroads for cables between Europe, Asia and Africa. Some voice apps are blocked, and the A/C bill is legendary.')},
|
||
{id:'mos',name:'Moscow',x:1235,y:192,land:'eu',reg:'EU',P:900,ru:true,arpu:0.5,ix:'Borscht-IX',dc:'Very Secure Bunker',note:tr('Sovereign internet rules: every POP needs a government box in the rack, Goggle video is throttled, and the national firewall runs drills.')},
|
||
{id:'akl',name:'Auckland',x:1964,y:826,land:'nz',reg:'OC',P:250,ix:'Kiwi-IX',dc:'Sheep-cooled Shed',note:tr('Far from everything. Every packet here has a long journey home.')},
|
||
{id:'per',name:'Perth',x:1712,y:785,land:'oc',reg:'OC',P:200,ix:'',dc:'Very Remote DC',note:tr('The most isolated big city on Earth. Asia is closer than Sydney.')},
|
||
{id:'jkt',name:'Jakarta',x:1614,y:624,land:'idn',reg:'AS',P:900,ix:'Nasi-IX',dc:'Monsoon-proof DC',note:tr('270 million people on 17,000 islands. Mobile first, and very hungry for bandwidth.')},
|
||
{id:'mnl',name:'Manila',x:1714,y:494,land:'ph',reg:'AS',P:600,ix:'',dc:'Typhoon-rated DC',note:tr('Typhoons, earthquakes and a lot of very online people.')},
|
||
{id:'ber',name:'Berlin',x:0,y:0,land:'eu',reg:'EU',P:450,ix:'Currywurst-IX',dc:'Former Brewery DC',note:tr('Startups, techno and a surprising number of data centers in old breweries.')},
|
||
{id:'ham',name:'Hamburg',x:0,y:0,land:'eu',reg:'EU',P:250,ix:'Moin-IX',dc:'Speicherstadt Colo',note:tr('Germany’s port city. Everyone says “Moin”, at any time of day, and the rain comes in sideways off the Elbe.')},
|
||
{id:'muc',name:'Munich',x:0,y:0,land:'eu',reg:'EU',P:250,ix:'Brezn-IX',dc:'Weißwurst Works',note:tr('Bavaria’s capital: cars, insurers and a two-week beer festival that sends mobile traffic through the roof every autumn. Racks must be finished before noon, like the sausages.')},
|
||
{id:'zrh',name:'Zurich',x:0,y:0,land:'eu',reg:'EU',P:250,ix:'Cuckoo-IX',dc:'Bank Vault DC',note:tr('Banks, very punctual packets, and racks inside old bank vaults.')},
|
||
{id:'nbo',name:'Nairobi',x:0,y:0,land:'af',reg:'AF',P:350,ix:'Safari-IX',dc:'Silicon Savannah Campus',note:tr('East Africa’s hub. Cables land in Mombasa, and mobile money runs everything.')},
|
||
{id:'cai',name:'Cairo',x:0,y:0,land:'af',land2:'eu',reg:'AF',P:600,ix:'Pharaoh-IX',dc:'Pyramid-adjacent DC',note:tr('Almost every Europe–Asia cable crosses Egypt. The tolls are legendary.')},
|
||
{id:'stg',name:'Stuttgart',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Spätzle-IX',dc:'Kehrwoche-certified DC',ixOnly:true,note:tr('Cars, engineers and Kehrwoche: every rack is swept on a strict rota. Nobody sells transit here, there is only the Spätzle-IX. Peer locally or haul your traffic to Frankfurt.')},
|
||
{id:'sto',name:'Stockholm',x:1110,y:160,land:'eu',reg:'EU',P:300,ix:'NodNod',dc:'Nuclear Bunker DC'},
|
||
{id:'bcn',name:'Barcelona',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Catnip-IX',dc:'Poblenou DC',note:tr('Catalonia’s own exchange. Small and proud, and local networks find it impossible to resist.')},
|
||
{id:'mad',name:'Madrid',x:935,y:392,land:'eu',reg:'EU',P:600,ix:'Siesta-IX',dc:'Interaction MAD'},
|
||
{id:'lag',name:'Lagos',x:1010,y:565,land:'af',reg:'AF',P:500,ix:'Jollof-IX',dc:'Rack-n-Roll Centre'},
|
||
{id:'jnb',name:'Johannesburg',x:1130,y:730,land:'af',reg:'AF',P:400,za:true,ix:'Braai-IX',dc:'Tera-Cotta Campus'},
|
||
{id:'bom',name:'Mumbai',x:1385,y:488,land:'eu',reg:'AS',P:1100,india:true,ix:'Mumb-IX',dc:'Goregaon Tech Park'},
|
||
{id:'sin',name:'Singapore',x:1556,y:568,land:'eu',reg:'AS',P:450,ix:'Lah-IX',dc:'Equinox SG',note:tr('Asia\'s hub. Expensive, humid, very well connected.')},
|
||
{id:'hkg',name:'Hong Kong',x:1645,y:440,land:'eu',reg:'AS',P:600,ix:'HK-Kicks',dc:'Mega-Eye Plus'},
|
||
{id:'icn',name:'Seoul',x:1722,y:302,land:'eu',reg:'AS',P:900,kr:true,ix:'Kimch-IX',dc:'Gasan Digital Complex',note:tr('Some of the fastest home broadband on the planet, and the strangest peering market. Under “sender pays”, the big three ISPs charge for every gigabit handed to them, and transit here is among the priciest anywhere.')},
|
||
{id:'pek',name:'Beijing',x:1652,y:318,land:'eu',reg:'AS',P:1800,cn:true,arpu:0.6,ix:'',dc:'Zhongguancun DC',note:tr('Mainland China. Behind the Great Firewall, with its own rules for foreign networks.')},
|
||
{id:'sha',name:'Shanghai',x:1680,y:388,land:'eu',reg:'AS',P:2200,cn:true,arpu:0.6,ix:'',dc:'Lujiazui Data Center',note:tr('Mainland China. Enormous market, strict rules, and a famously congested border.')},
|
||
{id:'tok',name:'Tokyo',x:1795,y:320,land:'jp',reg:'AS',P:1400,ix:'JP-Naptime',dc:'Otemachi Tower'},
|
||
{id:'syd',name:'Sydney',x:1860,y:790,land:'oc',reg:'OC',P:500,ix:'Roo-IX',dc:'Global Swish'},
|
||
{id:'for',name:'Fortaleza',x:0,y:0,land:'sa',reg:'SA',P:250,br:true,andes:'e',ix:'IX.brrr Fortaleza',ixCheap:0.3,dc:'Praia Landing Station',note:tr('Where South America’s cables actually land. Europe, Africa and the US come ashore here, then ride a long backhaul south.')},
|
||
{id:'rio',name:'Rio de Janeiro',x:0,y:0,land:'sa',reg:'SA',P:600,br:true,andes:'e',ix:'IX.brrr Rio',ixCheap:0.3,dc:'Copacabana Colo',note:tr('Beaches, cable landings and a Carnival that melts traffic graphs every February.')},
|
||
{id:'bue',name:'Buenos Aires',x:0,y:0,land:'sa',reg:'SA',P:500,andes:'e',arpu:0.7,ix:'Asado-IX',dc:'Puerto Madero DC',note:tr('Tango, steak and a currency that changes value while you read this.')},
|
||
{id:'scl',name:'Santiago',x:0,y:0,land:'sa',reg:'SA',P:350,andes:'w',ix:'Empanada-IX',dc:'Andes-view Bunker',note:tr('The Pacific gateway. The Andes sit between it and everything else, and the ground shakes now and then.')},
|
||
{id:'lim',name:'Lima',x:0,y:0,land:'sa',reg:'SA',P:400,andes:'w',ix:'Ceviche-IX',dc:'Fog-cooled DC',note:tr('It almost never rains, but the sea fog keeps the racks cool.')},
|
||
{id:'bog',name:'Bogotá',x:0,y:0,land:'sa',reg:'SA',P:400,andes:'m',ix:'Arepa-IX',dc:'2,600 m Above Sea Level DC',note:tr('High up in the Andes. No fiber crosses the Darién Gap jungle to Panama, so the way north is under the sea.')},
|
||
{id:'pan',name:'Panama City',x:0,y:0,land:'am',reg:'AM',P:80,ix:'Canal-IX',dc:'Isthmus Interconnect',note:tr('Every cable between the Americas squeezes past here. Nothing crosses the Darién Gap by land, so South America is always a subsea hop away.')},
|
||
{id:'del',name:'Delhi',x:0,y:0,land:'eu',reg:'AS',P:1600,arpu:0.4,india:true,ix:'Butter-Chicken-IX',dc:'Smog-filtered DC',note:tr('An enormous, very online city a long way from the sea. Every subsea byte rides a backhaul from Mumbai or Chennai.')},
|
||
{id:'maa',name:'Chennai',x:0,y:0,land:'eu',reg:'AS',P:500,arpu:0.5,india:true,ix:'Dosa-IX',dc:'Cyclone-rated Landing Bay',note:tr('India’s east-coast landing hub, with cables to Singapore. Cyclone season is a thing.')},
|
||
{id:'blr',name:'Bengaluru',x:0,y:0,land:'eu',reg:'AS',P:600,arpu:0.6,india:true,ix:'Filter-Kaapi-IX',dc:'Traffic-jam-adjacent Campus',note:tr('India’s tech capital. Packets move faster than the cars outside.')},
|
||
{id:'hyd',name:'Hyderabad',x:0,y:0,land:'eu',reg:'AS',P:400,arpu:0.5,india:true,ix:'Biryani-IX',dc:'Hyperscale Hills',note:tr('Every hyperscaler is building a region here. The land is cheap and the biryani is excellent.')},
|
||
{id:'tpe',name:'Taipei',x:0,y:0,land:'tw',reg:'AS',P:450,ix:'Bubble-Tea-IX',dc:'Typhoon-proof Tower',note:tr('Makes most of the world’s chips and hangs on a handful of subsea cables. Ships keep “accidentally” dragging their anchors over them.')},
|
||
{id:'auh',name:'Abu Dhabi',x:0,y:0,land:'eu',reg:'AS',P:200,arpu:1.4,uae:true,ix:'',dc:'Oasis-cooled Campus',note:tr('The capital. Sovereign AI money and very big data centers. Inside the UAE only the two licensed operators may run fiber.')},
|
||
{id:'fuj',name:'Fujairah',x:0,y:0,land:'eu',reg:'AS',P:20,uae:true,ix:'',dc:'Cable Landing Sandcastle',note:tr('Most UAE cables land on this coast, outside the Strait of Hormuz. Getting from here to Dubai means renting from the duopoly.')},
|
||
{id:'cpt',name:'Cape Town',x:0,y:0,land:'af',reg:'AF',P:250,za:true,ix:'Biltong-IX',dc:'Table Mountain Colo',note:tr('Where the Atlantic cables to Africa’s south land. Penguins on the beach, load shedding on the grid.')},
|
||
{id:'mel',name:'Melbourne',x:0,y:0,land:'oc',reg:'OC',P:450,ix:'Flat-White-IX',dc:'Four-Seasons-a-Day DC',note:tr('Four seasons in one day, and the racks feel every one of them.')},
|
||
{id:'bne',name:'Brisbane',x:0,y:0,land:'oc',reg:'OC',P:250,ix:'Bris-Vegas-IX',dc:'Sunshine State Shed',note:tr('Sunny, humid and closer to the Pacific cables than Sydney would like to admit.')},
|
||
{id:'drw',name:'Darwin',x:0,y:0,land:'oc',reg:'OC',P:15,ix:'',dc:'Crocodile-proof Landing Station',note:tr('Tiny, tropical and the closest Australian city to Asia. New cables to Singapore and Jakarta land here, next to the crocodiles.')},
|
||
{id:'osa',name:'Osaka',x:0,y:0,land:'jp',reg:'AS',P:700,ix:'Takoyaki-IX',dc:'Dojima DC',note:tr('Japan’s second hub, and Tokyo’s disaster-recovery plan. Earthquakes rarely hit both.')},
|
||
{id:'kul',name:'Kuala Lumpur',x:0,y:0,land:'eu',reg:'AS',P:350,ix:'Satay-IX',dc:'Twin Towers Colo',note:tr('Cheaper than Singapore next door. The data center builders noticed, and so did the power grid.')},
|
||
{id:'bkk',name:'Bangkok',x:0,y:0,land:'eu',reg:'AS',P:600,ix:'Tom-Yum-IX',dc:'Floating Market DC',note:tr('Big, busy and flooded with traffic, sometimes literally.')},
|
||
{id:'sgn',name:'Ho Chi Minh City',x:0,y:0,land:'eu',reg:'AS',P:500,vn:true,ix:'Pho-IX',dc:'Scooter-cooled DC',note:tr('Very online and badly served by the sea: at least one of its subsea cables is broken at any given time.')},
|
||
{id:'khi',name:'Karachi',x:0,y:0,land:'eu',reg:'AS',P:500,arpu:0.4,ix:'Chai-IX',dc:'Seaview Landing Station',note:tr('Pakistan’s door to the sea. Every cable lands here, and so does every new firewall rule.')},
|
||
{id:'dac',name:'Dhaka',x:0,y:0,land:'eu',reg:'AS',P:700,arpu:0.3,ix:'Rickshaw-IX',dc:'Monsoon-mapped DC',note:tr('Huge, dense and hungry. Its international traffic squeezes through a couple of cables, or comes overland from India.')},
|
||
{id:'cbo',name:'Colombo',x:0,y:0,land:'lk',reg:'AS',P:120,ix:'Hopper-IX',dc:'Tea-cooled Landing Station',note:tr('A small island at the crossroads of every Indian Ocean cable.')},
|
||
{id:'waw',name:'Warsaw',x:0,y:0,land:'eu',reg:'EU',P:550,ix:'Pierogi-IX',dc:'Palace-of-Culture-adjacent DC',note:tr('Central Europe’s rising hub. More data centers every year and a fiercely competitive ISP scene.')},
|
||
{id:'prg',name:'Prague',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Pilsner-IX',dc:'Castle-view Colo',note:tr('Beer is cheaper than water here, and IX ports are cheaper than both.')},
|
||
{id:'vie',name:'Vienna',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Schnitzel-IX',dc:'Waltz-cooled DC',note:tr('The old gateway to Eastern Europe. Packets still bow politely on the way through.')},
|
||
{id:'bud',name:'Budapest',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Goulash-IX',dc:'Thermal Bath DC',note:tr('Waste heat goes straight into the spa next door.')},
|
||
{id:'buh',name:'Bucharest',x:0,y:0,land:'eu',reg:'EU',P:400,ix:'Sarmale-IX',dc:'Parliament-sized DC',note:tr('Gigabit home broadband for the price of a coffee. Customers here expect a lot for very little.')},
|
||
{id:'tll',name:'Tallinn',x:0,y:0,land:'eu',reg:'EU',P:80,ix:'E-Stonia-IX',dc:'Medieval Wall DC',note:tr('Digital everything, e-residency for anyone, and Baltic cables that ships keep dragging their anchors over.')},
|
||
{id:'ist',name:'Istanbul',x:0,y:0,land:'eu',reg:'EU',P:900,ix:'Baklava-IX',dc:'Bosphorus Bridge DC',note:tr('One foot in Europe, one in Asia. Every land route between them crosses here.')},
|
||
{id:'kyv',name:'Kyiv',x:0,y:0,land:'eu',reg:'EU',P:500,blackout:true,ix:'Varenyky-IX',dc:'Generator-backed Bunker DC',note:tr('Ukrainian network engineers kept the internet running through blackouts and much worse. Generators, spare fiber and redundant everything are standard here, and the peering scene is famously tough.')},
|
||
{id:'jed',name:'Jeddah',x:0,y:0,land:'eu',reg:'AS',P:300,saudi:true,gcc:true,ix:'',dc:'Red Sea Landing Palace',note:tr('Saudi Arabia’s Red Sea cable hub. More and more of the cables between Europe, Africa and Asia stop here instead of in Egypt.')},
|
||
{id:'ruh',name:'Riyadh',x:0,y:0,land:'eu',reg:'AS',P:600,saudi:true,gcc:true,ix:'Kabsa-IX',dc:'Desert Megaproject DC',note:tr('The capital, building AI campuses at gigawatt scale. Data about Saudi users has to stay in the Kingdom, and every POP needs a local telecom licence.')},
|
||
{id:'doh',name:'Doha',x:0,y:0,land:'eu',reg:'AS',P:150,arpu:1.5,qa:true,ix:'Pearl-IX',dc:'Air-cooled Stadium DC',note:tr('Small, rich and very well connected, as long as the neighbours are on speaking terms. Its only land border is with Saudi Arabia.')},
|
||
{id:'mil',name:'Milan',x:0,y:0,land:'eu',reg:'EU',P:450,ix:'MIX-and-Match',dc:'Caldera Park Campus',note:tr('Italy’s digital capital. Fashion-week traffic, an espresso-powered NOC and more exchanges than you would expect.')},
|
||
{id:'rom',name:'Rome',x:0,y:0,land:'eu',reg:'EU',P:450,ix:'Carbonara-IX',dc:'Colosseum-adjacent Colo',note:tr('All roads lead to Rome. Most packets still go via Milan.')},
|
||
{id:'pmo',name:'Palermo',x:0,y:0,land:'eu',reg:'EU',P:60,ix:'Cannoli-IX',dc:'Sicilian Hub-a-Dub',note:tr('A small city on a big crossroads. Cables from Asia, Africa and the Middle East land here to skip the long way round.')},
|
||
{id:'lis',name:'Lisbon',x:0,y:0,land:'eu',reg:'EU',P:300,ix:'Pastel-de-Nata-IX',dc:'Seven Hills Colo',note:tr('Europe’s new Atlantic gateway. Cables to Brazil, Africa and the US land down the coast in Sines.')},
|
||
{id:'ath',name:'Athens',x:0,y:0,land:'eu',reg:'EU',P:350,ix:'Souvlaki-IX',dc:'Acropolis-view DC',note:tr('Ancient city, brand new cables. Greece wants to be the eastern Mediterranean’s landing hub.')},
|
||
{id:'atn',name:'Atlanta',x:0,y:0,land:'am',reg:'AM',P:450,ix:'Peach-IX',dc:'56 Marietta',note:tr('The Southeast’s carrier hotel. Busiest airport, busiest peering south of Ashburn.')},
|
||
{id:'den',name:'Denver',x:0,y:0,land:'am',reg:'AM',P:250,ix:'Mile-High-IX',dc:'Thin Air DC',note:tr('A mile up and halfway between the coasts, so every cross-country route stops here for a breather.')},
|
||
{id:'phx',name:'Phoenix',x:0,y:0,land:'am',reg:'AM',P:300,ix:'Cactus-IX',dc:'Dry Heat Campus',note:tr('Cheap land, cheap power and 48 °C summers. Hyperscalers love it. Chillers do not.')},
|
||
{id:'bos',name:'Boston',x:0,y:0,land:'am',reg:'AM',P:350,ix:'Chowder-IX',dc:'One Summer Street',note:tr('Universities, biotech and a carrier hotel that has outlived most of its carriers.')},
|
||
{id:'hou',name:'Houston',x:0,y:0,land:'am',reg:'AM',P:450,ix:'Rodeo-IX',dc:'Hurricane-hardened DC',note:tr('Oil, gas and hurricanes. The generators here are sized for a week, and they have needed it.')},
|
||
{id:'slc',name:'Salt Lake City',x:0,y:0,land:'am',reg:'AM',P:150,ix:'Fry-Sauce-IX',dc:'Great Salt Lake DC',note:tr('Cheap power, dry air and a surprising number of very quiet data centers.')},
|
||
{id:'man',name:'Manchester',x:0,y:0,land:'uk',reg:'EU',P:350,ix:'Rainy-City-IX',dc:'Old Cotton Mill Colo',note:tr('The North’s hub, with its own exchange and very damp air-conditioning intakes. Cables to Ireland and Denmark come ashore up the coast.')},
|
||
{id:'edi',name:'Edinburgh',x:0,y:0,land:'uk',reg:'EU',P:200,ix:'Haggis-IX',dc:'Castle Rock Colo',note:tr('Scotland’s capital. North Sea cables to Norway and the Faroes land up the coast.')},
|
||
{id:'bde',name:'Bude',x:0,y:0,land:'uk',reg:'EU',P:3,ix:'',dc:'Clifftop Landing Station',note:tr('A tiny surfing town in Cornwall where a remarkable share of the transatlantic internet comes ashore. The cliffs are full of fiber.')},
|
||
{id:'svg',name:'Stavanger',x:0,y:0,land:'eu',reg:'EU',P:60,ix:'Brunost-IX',dc:'Inside-a-Mountain DC',note:tr('Norway’s oil capital, now full of data centers inside mountains, run on hydro and cooled by the fjord. North Sea cables land here.')},
|
||
];
|
||
// Display-only nudges for cities that sit on top of each other at map scale; distances still use real lon/lat.
|
||
const CITY_NUDGE={stg:[7,1],zrh:[-3,3],bru:[1,3],oos:[-3,0],van:[-3,-6],sea:[1,4],ott:[-3,-3],bcn:[-6,-4],auh:[-5,6],dxb:[9,-7],fuj:[8,15],rio:[14,-16],tll:[-4,22],osa:[-10,6],khi:[-2,-6],hou:[0,6],dal:[0,-4],nyc:[.3,-.7],mia:[-.6,.4],mtl:[.8,0],cph:[-.7,.3],hel:[-.8,-.2],akl:[.6,.4],sin:[-1.3,-1.3],hkg:[.8,0],ist:[.8,0],lis:[.8,0]};
|
||
for(const c of CITIES){const q=CITY_LL[c.id];if(q){c.lon=q[0];c.lat=q[1];const pt=proj(q[0],q[1]),n=CITY_NUDGE[c.id]||[0,0];c.x=pt[0]+n[0];c.y=pt[1]+n[1];}}
|
||
const CITY=Object.fromEntries(CITIES.map(c=>[c.id,c]));
|
||
const CABLES=[
|
||
{"id":"marea","name":"Marea Carey","price":0.8,"age":"new","blurb":tr("Hits the high notes across the Atlantic. Huge capacity, cheap waves."),"pairs":[["ash","mad",[[-74,36.5],[-50,40],[-25,43],[-10,44]]]]},
|
||
{"id":"grace","name":"Grace Hopscotch","price":0.85,"age":"new","blurb":tr("Hops from New York to the UK and Spain."),"pairs":[["nyc","lon",[[-72,40],[-50,47],[-25,50],[-10,50.5]]],["nyc","mad",[[-72,39.8],[-50,42],[-25,43.2],[-10,43.8]]]]},
|
||
{"id":"dunant","name":"Dunno-ant","price":0.85,"age":"new","blurb":tr("Nobody remembers who it is named after."),"pairs":[["ash","par",[[-74,36.8],[-50,42],[-25,46],[-5,47.3]]]]},
|
||
{"id":"amitie","name":"Ami-Tea","price":0.9,"age":"new","blurb":tr("A friendly cable with French manners."),"pairs":[["nyc","lon",[[-70,41.5],[-50,46],[-25,49],[-8,50.3]]],["nyc","par",[[-70,41.3],[-50,45],[-25,47.5],[-5,47.6]]]]},
|
||
{"id":"hibx","name":"Hibernia Express-o","price":1.7,"age":"mid","blurb":tr("The straightest line across the Atlantic. Traders pay double to save a few milliseconds."),"pairs":[["nyc","lon",[[-68,42],[-55,46.5],[-30,52.5],[-12,52.5]]]],"lat":0.9},
|
||
{"id":"tat","name":"TAT-14 Retirement Home","price":1.3,"age":"old","blurb":tr("Laid last century. Cuts often, costs more, still somehow running."),"pairs":[["nyc","ams",[[-70,41],[-45,48],[-20,52],[0,54],[3,53.5]]]]},
|
||
{"id":"ella","name":"EllaLink-ing","price":1.0,"age":"new","blurb":tr("Brazil straight to Iberia, skipping the US entirely."),"pairs":[["for","mad",[[-37,-2.2],[-32,5],[-22,20],[-14,33],[-10,37.5]]],["sao","mad",[[-44,-24.5],[-38,-14],[-34,-6],[-30,5],[-22,20],[-14,33],[-10,37.5]]],["for","lis",[[-37,-2.2],[-32,5],[-22,20],[-14,33],[-9.6,37.9]]]]},
|
||
{"id":"sacs","name":"SACS-y Cable","price":1.0,"age":"mid","blurb":tr("South Atlantic, cool and confident."),"pairs":[["for","lag",[[-36,-3],[-20,0],[0,3]]],["sao","lag",[[-44,-24.5],[-35,-10],[-15,-3],[0,2],[3,5.5]]]]},
|
||
{"id":"col3","name":"Columbus III-and-a-half","price":1.4,"age":"old","blurb":tr("Discovered the Atlantic again. Old, pricey and fragile."),"pairs":[["mia","mad",[[-79,26],[-60,30],[-30,35],[-10,36.5]]]]},
|
||
{"id":"twoaf","name":"2Africa-n-Back","price":0.75,"age":"new","blurb":tr("All the way around Africa and back. Cheapest capacity on the map."),"pairs":[["lon","lag",[[-6,49],[-12,40],[-20,20],[-18,8],[-5,3],[3,5.5]]],["jnb","mrs",[[32,-30],[40,-20],[45,-5],[52,10],[45,12.3],[44,12.4],[41,15.1],[38,21.1],[35,26.1],[33,29.6],[32.4,31.3],[30,32.1],[20,34.1],[12,37.6],[6,42.5]]],["mrs","bom",[[6,42.5],[12,37.6],[20,34.1],[30,32.1],[32.4,31.3],[33,29.6],[35,26.1],[38,21.1],[41,15.1],[44,12.4],[52,13],[62,18],[70,19]]]]},
|
||
{"id":"equi","name":"Equi-yes","price":0.8,"age":"new","blurb":tr("Always agrees with you. Iberia to West Africa."),"pairs":[["lag","cpt",[[4,3],[6,-5],[10,-20],[16,-33]]],["mad","lag",[[-10,38],[-15,28],[-18,15],[-14,5],[-2,3],[3,5.8]]],["lis","lag",[[-9.6,37.9],[-15,28],[-18,15],[-14,5],[-2,3],[3,5.8]]]]},
|
||
{"id":"smw6","name":"SEE-ME-WAVE 6","price":0.95,"age":"new","blurb":tr("Sixth in a long-running series. Europe to India to Singapore."),"pairs":[["mrs","bom",[[6.4,42.74],[12.4,37.84],[20.4,34.34],[30.4,32.34],[32.8,31.54],[33.4,29.84],[35.4,26.34],[38.4,21.34],[41.4,15.34],[44.4,12.64],[52,13.4],[62,18.4],[70,19.4]]],["bom","sin",[[72,17],[76,8],[80.5,5],[90,5],[96,5.5],[100,4],[103,1.5]]],["mrs","sin",[[6.4,42.74],[12.4,37.84],[20.4,34.34],[30.4,32.34],[32.8,31.54],[33.4,29.84],[35.4,26.34],[38.4,21.34],[41.4,15.34],[44.4,12.64],[52,12.8],[62,12.5],[75,6.8],[80.5,5.2],[92,5.8],[97,5.8],[100.5,4],[103,1.7]]]]},
|
||
{"id":"peace","name":"PEACE-out","price":0.85,"age":"new","blurb":tr("Marseille to Singapore, then it leaves the party."),"pairs":[["mrs","sin",[[5.6,42.26],[11.6,37.36],[19.6,33.86],[29.6,31.860000000000003],[32.0,31.060000000000002],[32.6,29.360000000000003],[34.6,25.860000000000003],[37.6,20.860000000000003],[40.6,14.86],[43.6,12.16],[52,12.2],[62,11.8],[75,6.3],[80.5,4.6],[92,5.2],[97,5.3],[100.5,3.6],[103,1.4]]]]},
|
||
{"id":"aae","name":"AAAAAE-1","price":1.0,"age":"mid","blurb":tr("Asia, Africa, Europe, and one more thing."),"pairs":[["khi","sin",[[66,22],[70,12],[78,5.5],[90,5.5],[97,6],[100,3.6],[102.6,2.1],[103.7,1.3]]],["mrs","hkg",[[6.8,42.98],[12.8,38.08],[20.8,34.58],[30.8,32.58],[33.199999999999996,31.78],[33.8,30.080000000000002],[35.8,26.580000000000002],[38.8,21.580000000000002],[41.8,15.58],[44.8,12.88],[52,11.8],[62,11.4],[75,6],[80.5,4.4],[92,5],[97,5],[100.5,3.3],[104.5,1.5],[107,5],[110,10],[113,18],[114.2,21.8]]],["sin","hkg",[[104.5,1.5],[108,6],[111,12],[114,20],[114.2,22]]]]},
|
||
{"id":"apg","name":"A Pretty Gateway","price":0.9,"age":"mid","blurb":tr("The pretty way around East Asia."),"pairs":[["tpe","tok",[[123,25.5],[130,29.5],[137,33.5]]],["hkg","tpe",[[116.5,21.8],[119.5,22.8]]],["sin","hkg",[[105,2],[109,7],[112,13],[114.6,20],[114.4,22]]],["hkg","tok",[[116,21.5],[122,24],[126,28],[132,32],[137,33.8],[139.8,35]]],["hkg","icn",[[116,22],[122,26],[125,32],[126,35],[126.2,36.8]]],["tok","icn",[[136,33.8],[130,33.5],[128,34.5],[126.5,35.5]]],["tok","sha",[[135,33.5],[128,31.5],[122.5,31.2]]]]},
|
||
{"id":"jup","name":"Jupiterrible","price":0.9,"age":"new","blurb":tr("Named after a planet, behaves like one: big and far away."),"pairs":[["lax","osa",[[-121,33.3],[-145,31.5],[-175,31.5],[-200,32.5],[-222,33.8]]],["lax","tok",[[-121,33.5],[-145,32],[-175,32],[-200,33],[-218,34.5]]]]},
|
||
{"id":"fast","name":"FASTEST","price":0.85,"age":"mid","blurb":tr("Its predecessor was FASTER. Marketing had a good day."),"pairs":[["sea","tok",[[-125,46],[-150,45],[-180,42],[-205,38],[-218,35]]]]},
|
||
{"id":"ncp","name":"Crosspatch Pacific","price":1.0,"age":"mid","blurb":tr("Crosses the Pacific, mildly annoyed about it."),"pairs":[["sea","tpe",[[-125,46],[-155,45],[-185,38],[-212,28],[-235,25.6]]],["sea","icn",[[-125,46.5],[-155,46.5],[-185,42],[-212,33],[-229,33.8],[-232,36]]],["sea","sha",[[-125,46.2],[-155,45.5],[-185,40],[-212,31],[-236,30.5]]]]},
|
||
{"id":"plcn","name":"Pacific Lite","price":1.1,"age":"mid","blurb":tr("Lighter on paperwork than its namesake. Still heavy on paperwork."),"pairs":[["lax","tpe",[[-121,33],[-150,25],[-180,22],[-215,22],[-236,24]]],["lax","hkg",[[-121,33],[-150,25],[-180,22],[-215,21],[-240,21.5]]]]},
|
||
{"id":"scx","name":"Southern Cross-ed Fingers","price":1.2,"age":"old","blurb":tr("Old Pacific workhorse. Everyone hopes it holds."),"pairs":[["sjc","syd",[[-123,37],[-150,20],[-175,0],[-190,-20],[-200,-30],[-207,-33.5]]],["akl","syd",[[168,-37],[158,-35]]]]},
|
||
{"id":"hwk","name":"Hawaiki-wiki","price":0.95,"age":"new","blurb":tr("Quick Pacific crossing with a stop for snacks."),"pairs":[["sea","syd",[[-125,45],[-150,20],[-170,-5],[-185,-25],[-200,-32],[-206,-33.8]]],["akl","sea",[[178,-34],[190,-20],[210,10],[230,40],[234.5,47]]]]},
|
||
{"id":"indigo","name":"Indigo-go","price":0.9,"age":"new","blurb":tr("Singapore to Sydney in one go, via Perth."),"pairs":[["sin","syd",[[104.5,0],[107,-8],[113,-12],[112,-25],[114,-35],[130,-37],[145,-41],[152,-36]]],["sin","per",[[104.6,0],[107.2,-8],[113,-14],[112.5,-25],[115,-31.8]]]]},
|
||
{"id":"guam","name":"Guam-bling","price":1.1,"age":"mid","blurb":tr("A bet on a tiny island in the middle of the Pacific."),"pairs":[["tok","syd",[[142,33],[146,15],[152,0],[156,-20],[152.5,-33]]]]},
|
||
{"id":"ohman","name":"Oh-Man Australia Cable","price":1.0,"age":"new","blurb":tr("Perth to the Gulf across the Indian Ocean. Oh man, it is long."),"pairs":[["per","dxb",[[113,-31],[100,-25],[80,-10],[65,10],[59,20],[57,24.5]]]]},
|
||
{"id":"tasman","name":"Tasman Global Excess","price":0.95,"age":"new","blurb":tr("Sydney to Auckland with plenty to spare."),"pairs":[["akl","syd",[[170,-36],[158,-34.5]]]]},
|
||
{"id":"bifrost","name":"Bi-Frosted","price":0.9,"age":"new","blurb":tr("A rainbow bridge from Singapore to California, via Jakarta and Manila."),"pairs":[["sin","jkt",[[105,-1],[106,-4]]],["jkt","mnl",[[108,-5],[112,-3],[118,2],[122,6],[121,10],[120,13.5]]],["mnl","lax",[[123,15],[140,20],[180,25],[210,30],[235,33.5]]]]},
|
||
{"id":"sjcph","name":"Sushi-Jollibee Cable","price":0.9,"age":"mid","blurb":tr("Southeast Asia to Japan, with snacks."),"pairs":[["hkg","mnl",[[116,21],[119.5,16],[120.3,14.6]]],["mnl","sin",[[119,12],[115,8],[110,5],[105,2]]],["mnl","tok",[[122,19],[127,24],[133,30],[138.5,34.5]]]]},
|
||
{"id":"farice","name":"Far-Ice-1","price":1.2,"age":"old","blurb":tr("Iceland’s lifeline to Scotland. Lonely but determined."),"pairs":[["rek","lon",[[-20,63],[-10,61],[-4,59],[-1.5,57]]]]},
|
||
{"id":"danice","name":"Dance-Ice","price":1.0,"age":"mid","blurb":tr("Iceland to Denmark, choreographed."),"pairs":[["rek","cph",[[-18,63],[-5,62],[5,59],[8.5,57.5],[11,57]]]]},
|
||
{"id":"gcon","name":"Greenland Connect-the-Dots","price":1.4,"age":"old","blurb":tr("Hops via Greenland. Polar bears included."),"pairs":[["rek","mtl",[[-26,63.5],[-42,60],[-55,53],[-60,48],[-66,47],[-70,46.5]]]]},
|
||
{"id":"iris","name":"IRIS Scan","price":0.9,"age":"new","blurb":tr("Iceland to Ireland, brand new and still smells like plastic."),"pairs":[["rek","dub",[[-22,63],[-15,58],[-10.5,54.5],[-9,53.3]]]]},
|
||
{"id":"aec","name":"AEConnect-the-Dots","price":0.85,"age":"new","blurb":tr("New York to Ireland: the tech-tax express."),"pairs":[["nyc","dub",[[-70,41],[-50,47],[-25,52],[-11,52.8]]]]},
|
||
{"id":"havf","name":"Havfun","price":0.8,"age":"new","blurb":tr("Danish for “sea fun”. Probably."),"pairs":[["nyc","cph",[[-70,41.5],[-50,49],[-25,55],[-10,58],[0,58],[7,57.5],[10,57.6]]],["dub","cph",[[-10,54.5],[-8,57],[-2,59],[6,58],[10,57.6]]]]},
|
||
{"id":"celtix","name":"Celtix Connected","price":0.7,"age":"mid","blurb":tr("Dublin to London across the Irish Sea."),"pairs":[["dub","lon",[[-5,53.4]]]]},
|
||
{"id":"falcon","name":"Falcon Punch","price":0.9,"age":"mid","blurb":tr("Dubai to Mumbai. Hits hard."),"pairs":[["cai","dxb",[[32.6,29.9],[34.4,27.2],[37.5,22.5],[41.5,15.5],[43.4,12.4],[48,12.6],[55,15.8],[59.4,21.8],[57,25.5]]],["fuj","bom",[[58,24.8],[63,22.3],[70,19.2]]],["dxb","bom",[[57,25.5],[60,23],[66,21],[71,19]]]]},
|
||
{"id":"eig","name":"Eye-Gee","price":1.0,"age":"mid","blurb":tr("A gateway from Europe to India, through the Red Sea. Pronounced like a very surprised cable."),"pairs":[["dxb","mrs",[[57,25],[59,22],[55,16],[48,12.8],[43.2,11.92],[40.2,14.62],[37.2,20.62],[34.2,25.62],[32.2,29.12],[31.599999999999998,30.82],[29.2,31.62],[19.2,33.620000000000005],[11.2,37.120000000000005],[5.2,42.02]]]]},
|
||
{"id":"clion","name":"C-Lion King","price":1.0,"age":"new","blurb":tr("Helsinki to Germany under the Baltic. Anchors keep finding it."),"pairs":[["hel","fra",[[24,59.8],[20,57.5],[15,55.2],[12.2,54.3]]]]},
|
||
{"id":"uly","df":true,"name":"Ulysseless","price":0.8,"age":"old","blurb":tr("Short hop across the North Sea. An odyssey it is not."),"pairs":[["lon","ams",[[2,51.8]]]]},
|
||
{"id":"chn","df":true,"name":"Channel Hopper","price":0.7,"age":"mid","blurb":tr("London to Paris under the Channel. Cheaper than the train."),"pairs":[["lon","par",[[1,50.5]]]]},
|
||
{"id":"medn","name":"Med-Nauti-lust","price":0.9,"age":"mid","blurb":tr("Across the Mediterranean, Egypt to France. Romantic, in a cable way."),"pairs":[["ist","mrs",[[26.5,40],[25,37],[20,35.5],[12,38],[6.5,42.6]]],["cai","mrs",[[29.9,31.4],[28,32.5],[20,34.5],[12,38],[6.5,42.6]]]]},
|
||
{"id":"eassy","name":"EASSy Peasy","price":0.95,"age":"mid","blurb":tr("East Africa up to Europe via the Red Sea. Lemon squeezy."),"pairs":[["nbo","mrs",[[39.7,-4],[42,-1],[45,2],[51,10.5],[45,12.3],[43.4,12.0],[40.4,14.7],[37.4,20.700000000000003],[34.4,25.700000000000003],[32.4,29.200000000000003],[31.799999999999997,30.900000000000002],[29.4,31.700000000000003],[19.4,33.7],[11.4,37.2],[5.4,42.1]]]]},
|
||
{"id":"teams","name":"TEAMS-work","price":0.9,"age":"mid","blurb":tr("Kenya to the Gulf. Makes the dream work."),"pairs":[["nbo","dxb",[[39.7,-4],[44,0],[52,8],[58,18],[59,22.5],[57,25]]]]},
|
||
{"id":"monet","name":"Mo-Net-y","price":0.9,"age":"new","blurb":tr("Brazil to Florida. The invoice arrives just as fast."),"pairs":[["sao","mia",[[-44,-25.5],[-36,-14],[-33,-4],[-45,4],[-62,16],[-76,25]]],["for","mia",[[-37,-2.2],[-45,4.5],[-62,16.5],[-76,25.3]]]]},
|
||
{"id":"seabras","name":"Sea-Bras","price":0.9,"age":"new","blurb":tr("Straight from São Paulo to New York, skipping the Miami hairpin."),"pairs":[["sao","nyc",[[-44,-25.5],[-34,-10],[-33,0],[-50,18],[-66,33],[-72,39.5]]]]},
|
||
{"id":"sam1","name":"SAM-1-and-Done","price":1.2,"age":"old","blurb":tr("An old ring around the whole continent, the long way round Cape Horn."),"pairs":[["mia","for",[[-75,24],[-62,16],[-45,4],[-37,-2.5]]],["for","rio",[[-36,-4],[-34,-9],[-37,-16],[-41,-23.6]]],["rio","sao",[[-44,-24.3]]],["sao","bue",[[-47,-27],[-52,-35],[-56,-36]]],["bue","scl",[[-56,-37.5],[-62,-45],[-65,-56],[-72,-56],[-77,-45],[-74,-34]]],["scl","lim",[[-73.5,-30],[-74,-20],[-78,-13]]],["lim","pan",[[-81,-6],[-82,0],[-80,7]]],["pan","mia",[[-79.5,10],[-77,15],[-74,19.5],[-75,23],[-79,25]]]]},
|
||
{"id":"curie","name":"Curie-osity","price":0.85,"age":"new","blurb":tr("Los Angeles to Chile, with a small detour for Panama."),"pairs":[["lax","scl",[[-120,30],[-108,14],[-92,0],[-80,-20],[-73,-33]]],["lax","pan",[[-120,30],[-105,15],[-90,7],[-80,7.5]]]]},
|
||
{"id":"pccs","name":"Caribbean Cruise Control","price":1.0,"age":"mid","blurb":tr("Hops the Caribbean so Bogotá can skip the jungle."),"pairs":[["mia","bog",[[-80,24],[-77.5,19],[-76,12],[-75,10.5]]],["pan","bog",[[-79.6,9.6],[-77,9.9],[-75.5,10.5]]]]},
|
||
{"id":"tannat","name":"Tannat Wine Line","price":0.9,"age":"mid","blurb":tr("Named after a wine. São Paulo to Buenos Aires, past Uruguay."),"pairs":[["sao","bue",[[-46,-26],[-50,-32],[-55,-35.5]]]]},
|
||
{"id":"humb","name":"Humboldt Penguin","price":1.3,"age":"new","blurb":tr("The first cable from South America to Oceania. 14,000 km of very lonely glass."),"pairs":[["scl","syd",[[-75,-34],[-110,-38],[-150,-40],[-180,-38],[-200,-35],[-206,-34]]]]},
|
||
{"id":"wacs","name":"WACS-a-Mole","price":1.1,"age":"mid","blurb":tr("Up the west coast of Africa. Something on it is always down."),"pairs":[["cpt","lag",[[16,-34],[10,-20],[6,-5],[4,3]]],["lag","lon",[[3,4],[-10,8],[-20,20],[-15,35],[-10,45],[-6,49.5]]]]},
|
||
{"id":"safe","name":"SAFE-ty Not Guaranteed","price":1.4,"age":"old","blurb":tr("An old cable from Cape Town round to India, via some very small islands."),"pairs":[["cpt","bom",[[22,-36],[45,-30],[57,-20],[65,0],[70,15]]]]},
|
||
{"id":"bbg","name":"Bay of Bengal Gate-Delay","price":0.95,"age":"mid","blurb":tr("Fujairah to Mumbai, round the tip of India to Chennai, then on to Singapore."),"pairs":[["fuj","bom",[[58,24.5],[63,22],[69.5,19.5]]],["bom","maa",[[72,15],[75,8],[78.5,6.6],[81.8,8],[81,12]]],["maa","sin",[[82,12],[90,8],[96.5,6],[100,3.5],[102.5,2],[103.6,1.25]]]]},
|
||
{"id":"i2i","name":"Eye-to-Eye","price":0.85,"age":"mid","blurb":tr("Chennai to Singapore, looking it straight in the eye."),"pairs":[["maa","sin",[[82,13],[91,9.5],[97,6.6],[100.2,3.8],[102.6,2.2],[103.7,1.3]]]]},
|
||
{"id":"tse","name":"Strait Outta Taipei","price":1.5,"age":"old","blurb":tr("A short cable across a very tense strait."),"pairs":[["tpe","sha",[[122.2,26.5],[122.6,29],[122.2,31]]]]},
|
||
{"id":"gbi","name":"Gulf Bridge Over Troubled Water","price":1.0,"age":"mid","blurb":tr("Leaves the Gulf from Fujairah and runs up the Red Sea to Europe."),"pairs":[["fuj","mrs",[[57.5,23.5],[59.5,21.5],[55,15.5],[48,12.6],[43.2,11.8],[40.2,14.5],[37.2,20.5],[34.2,25.5],[32.2,29],[31.6,30.7],[29.2,31.5],[19.2,33.5],[11.2,37],[5.2,42]]]]},
|
||
{"id":"aagony","name":"AAG-ony","price":1.1,"age":"old","blurb":tr("An Asia–America gateway cable that breaks so often it has its own support group."),"pairs":[["sgn","hkg",[[109,12],[113,18],[114.2,21.5]]],["sgn","sin",[[106,7],[104.6,3]]]]},
|
||
{"id":"darwin","name":"Darwin Award Cable","price":1.0,"age":"new","blurb":tr("Darwin to Singapore via Jakarta. Survival of the fittest packets."),"pairs":[["drw","jkt",[[129,-11.2],[122,-10],[114,-8.6],[108,-6.6]]],["drw","sin",[[129,-11.2],[120,-9],[114,-6],[108,-2],[105,0.6]]]]},
|
||
{"id":"jga","name":"J-G’day-A (Japan–Guam–Aussie)","price":0.9,"age":"new","blurb":tr("Brisbane to Tokyo with a beach break in Guam."),"pairs":[["bne","tok",[[155,-25],[156,-5],[146,13],[141,30]]]]},
|
||
{"id":"smw4","name":"SEE-ME-WAVE 4","price":1.2,"age":"old","blurb":tr("The previous generation. Still carries most of Pakistan, Sri Lanka and Bangladesh, held together with hope."),"pairs":[["khi","mrs",[[65,23.5],[60,22],[55,15.5],[48,12.6],[43.2,11.8],[40.2,14.5],[37.2,20.5],[34.2,25.5],[32.2,29],[31.6,30.7],[29.2,31.5],[19.2,33.5],[11.2,37],[5.2,42]]],["khi","bom",[[67,23],[70,20.5]]],["bom","cbo",[[72,15],[75,8],[78.5,6.3]]],["cbo","maa",[[80.6,8.6],[81,11.5]]],["maa","dac",[[82,14],[87,17.5],[91.5,21.2]]],["dac","sin",[[92,21],[93,17],[95,10],[97,6.4],[100,3.6],[102.6,2.1],[103.7,1.3]]]]},
|
||
{"id":"balt","name":"Baltic Anchor Magnet","price":0.8,"age":"mid","blurb":tr("Short hops under the Baltic Sea. Every passing ship seems to find it."),"pairs":[["tll","hel",[[24.8,59.8]]],["tll","sto",[[22,59.3],[19.5,59.3]]]]},
|
||
{"id":"bsea","name":"Black Sea Shanty","price":1.0,"age":"mid","blurb":tr("Istanbul to Bucharest's coast across the Black Sea."),"pairs":[["ist","buh",[[29.5,42],[29.5,43.5],[28.8,44.2]]]]},
|
||
{"id":"concerto","name":"Concerto in Sea Minor","price":0.55,"age":"new","df":true,"blurb":tr("North Sea workhorse from London to Amsterdam. Dark fiber pairs for sale by the dozen."),"pairs":[["lon","ams",[[1.6,51.72],[3.6,52.02]]]]},
|
||
{"id":"circe","name":"Circe du Soleil","price":0.6,"age":"mid","df":true,"blurb":tr("Another London–Amsterdam route. Everyone has one, so prices are low."),"pairs":[["lon","ams",[[1.8,52.18],[3.8,52.58]]]]},
|
||
{"id":"nshuttle","name":"North Sea Shuttle","price":0.5,"age":"new","df":true,"blurb":tr("Brand new, cheap, and it lands right next to your racks."),"pairs":[["lon","ams",[[1.5,51.42],[3.9,51.88]]]]},
|
||
{"id":"imewe","name":"I-ME-WE-Us","price":1.05,"age":"mid","blurb":tr("India, the Middle East and Western Europe, all on one cable. Lands in Cairo on the way."),"pairs":[["cai","fuj",[[32.6,29.9],[34.4,27.2],[37.5,22.5],[41.5,15.5],[43.4,12.4],[48,12.6],[55,15.8],[59.4,21.8],[57.5,24.3]]],["cai","bom",[[32.6,29.9],[34.4,27.2],[37.5,22.5],[41.5,15.5],[43.4,12.4],[48,12.6],[60,15],[68,17.5]]]]},
|
||
{"id":"jedx","name":"Jeddah-i Express","price":0.95,"age":"new","blurb":tr("New cables increasingly land in Jeddah instead of Egypt. This one heads for India and Singapore."),"pairs":[["jed","bom",[[38.6,22.5],[41.5,15.5],[43.4,12.4],[48,12.6],[60,15],[68,17.5]]],["jed","sin",[[38.6,22.5],[41.5,15.5],[43.4,12.4],[52,11],[70,6],[80,5.2],[92,5.5],[97,6],[100,3.6],[102.6,2.1],[103.7,1.3]]]]},
|
||
{"id":"rsea","name":"Red Sea Shortcut","price":0.9,"age":"mid","blurb":tr("A quick hop across the Red Sea between Egypt and Saudi Arabia."),"pairs":[["cai","jed",[[32.6,29.9],[34.6,27],[37.2,23.6]]]]},
|
||
{"id":"qgulf","name":"Doha Detour","price":1.0,"age":"mid","blurb":tr("Connects Doha to the rest of the Gulf, by sea, which is handy when the land border is closed."),"pairs":[["doh","fuj",[[52.5,26.2],[55,26.4],[56.6,26],[56.9,25.3]]],["doh","bom",[[52.5,26.2],[55,26.4],[57,25.5],[60,23],[66,21],[71,19]]]]},
|
||
{"id":"nouk","name":"NO-UK-Way","price":0.6,"age":"new","df":true,"blurb":tr("Norway to the UK across the North Sea. Fiber pairs for sale, because the oil money wanted a hobby."),"pairs":[["svg","edi",[[5.3,58.8],[2,57.5],[-1.5,56.2]]]]},
|
||
{"id":"celtn","name":"Celtic Norsemen","price":0.85,"age":"new","blurb":tr("Ireland to Norway, the long way round the top of Scotland. Vikings, but in reverse."),"pairs":[["dub","svg",[[-6,54],[-6.8,56.5],[-5.5,59.3],[-1.5,60.2],[3,59.5],[5.2,59]]]]},
|
||
{"id":"havh","name":"Havhingsten Hoofbeat","price":0.8,"age":"new","blurb":tr("The Sea Stallion: Blackpool to Denmark, galloping round the north of Scotland."),"pairs":[["man","cph",[[-3.4,53.9],[-5,54.5],[-6.5,56.5],[-5,59],[-2,59.4],[2,58.5],[7,57.8],[8.2,57.2],[10.5,57.6],[11.5,56.5]]]]},
|
||
{"id":"shefa","name":"Shefa Sheep Line","price":1.1,"age":"mid","blurb":tr("Scotland to Iceland via Shetland and the Faroes. More sheep than packets."),"pairs":[["edi","rek",[[-2.5,56.2],[-1,58],[-1.3,60.2],[-6.8,62],[-14,63.4],[-20,63.6]]]]},
|
||
{"id":"apollo","name":"Apollo 13 (Houston, We Have Latency)","price":0.95,"age":"mid","blurb":tr("New York to the cliffs of Bude. It made it home in the end."),"pairs":[["nyc","bde",[[-70,40],[-50,43],[-25,48.5],[-8,50.2],[-5,50.8]]]]},
|
||
{"id":"yellow","name":"Yellow Brick Road","price":0.9,"age":"mid","blurb":tr("Long Island to Cornwall. Follow it all the way to the wizard in the cable hut."),"pairs":[["nyc","bde",[[-71,40.5],[-50,44.5],[-25,49.3],[-8,50.6],[-5,50.9]]]]},
|
||
{"id":"glo1","name":"Glo-in-the-Dark","price":1.05,"age":"mid","blurb":tr("Cornwall to Lagos down the West African coast. Glows faintly when it is working."),"pairs":[["bde","lag",[[-5.2,50.6],[-11,45],[-15,30],[-19,15],[-12,4],[2,4.5],[3.4,6]]]]},
|
||
{"id":"pasdc","name":"Pas de Câble","price":0.6,"age":"new","df":true,"blurb":tr("Another hop across the Channel, with dark fiber for sale. There is always room for one more."),"pairs":[["lon","par",[[1.3,51.0],[1.7,50.7]]]]},
|
||
{"id":"tampn","name":"Oil Rig Wi-Fi","price":0.9,"age":"mid","blurb":tr("Stavanger to the Netherlands via every oil platform in the North Sea. The roughnecks stream a lot of football."),"pairs":[["svg","ams",[[5.3,58.6],[4.5,56],[4.2,53.5],[4.6,52.6]]]]},
|
||
{"id":"medusa","name":"Medusa Stare","price":0.85,"age":"new","blurb":tr("Lisbon to Barcelona and Marseille along the coast. Look straight at the latency graph and it turns to stone."),"pairs":[["lis","bcn",[[-9.6,37.9],[-8.9,36.6],[-5.6,35.9],[-2,36.4],[0.5,38.5],[2.6,41.1]]],["bcn","mrs",[[2.8,41.3],[3.8,42.4],[5,43]]]]},
|
||
{"id":"nuvem","name":"Nuvem-ber Rain","price":0.85,"age":"new","blurb":tr("Portugal to the US Southeast via Bermuda. Means cloud in Portuguese, and is owned by one."),"pairs":[["lis","atn",[[-9.6,37.9],[-30,35],[-64.8,32.3],[-78.9,33.7]]]]},
|
||
{"id":"blue","name":"Feeling Blue","price":0.85,"age":"new","blurb":tr("Genoa to Sicily and on to Athens, laid by a search giant that got tired of renting."),"pairs":[["mil","pmo",[[8.9,44.2],[9.4,42.5],[11.2,39.5],[12.9,38.4]]],["pmo","ath",[[13.6,38.3],[15.4,37.2],[19,36.8],[22.6,36.2],[23.6,37.6]]]]},
|
||
{"id":"cannoli","name":"Sicilian Spaghetti Junction","price":0.9,"age":"mid","blurb":tr("Palermo to Marseille and Alexandria. Every Europe–Asia shortcut wants a stop in Sicily."),"pairs":[["pmo","mrs",[[12.9,38.4],[9.5,40],[7.4,42.6],[5.4,43.1]]],["pmo","cai",[[13.6,37.8],[15.5,35.6],[22,33.4],[29.9,31.4]]]]},
|
||
{"id":"ouzo","name":"Ouzo Express","price":0.9,"age":"new","blurb":tr("Athens to Alexandria, and up the Dardanelles to Istanbul. Opa!"),"pairs":[["ath","cai",[[24,37.5],[25.2,35.5],[28,33],[29.9,31.4]]],["ath","ist",[[24.3,38.5],[25.6,39.9],[26.5,40.3],[28.2,40.8]]]]},
|
||
{"id":"tea","name":"Boston Tea Party Line","price":0.9,"age":"mid","blurb":tr("Boston to Dublin. Nobody has thrown it into the harbour yet."),"pairs":[["bos","dub",[[-69.5,42.2],[-60,44],[-40,50],[-15,52.4],[-8,53]]]]},
|
||
{"id":"clementine","name":"Clementine","price":0.6,"age":"new","df":true,"blurb":tr("A small, sweet cable from Broadstairs to Ostend, then inland to Oostkamp. Not to be confused with any other citrus-flavoured cable."),"pairs":[["lon","oos",[[1.44,51.36],[2.92,51.23]]]]}
|
||
];
|
||
const CAB=Object.fromEntries(CABLES.map(c=>[c.id,c]));
|
||
const CABLE_PAIRS=CABLES.flatMap(c=>c.pairs.map(([a,b,mid])=>{const A=CITY[a],B=CITY[b];const near=(x,ref)=>x+W*Math.round((ref-x)/W);
|
||
const mp=mid.map(q=>proj(q[0],q[1]));const pts=[[near(A.x,mp[0][0]),A.y]].concat(mp,[[near(B.x,mp[mp.length-1][0]),B.y]]);
|
||
const ll=[[A.lon,A.lat]].concat(mid,[[B.lon,B.lat]]);let L=0;for(let i=1;i<ll.length;i++)L+=hav(ll[i-1][0],ll[i-1][1],ll[i][0],ll[i][1]);
|
||
return {cid:c.id,a,b,pts,km:Math.round(L)};}));
|
||
function cablesOk(a,b){const ban=S&&S.ev&&S.ev.landban&&S.ev.landban.until>S.day&&[a,b].includes(S.ev.landban.city);if(ban)return [];const rl=S&&S.scn&&S.scn.rules,bp=rl&&rl.banPairs,bc=rl&&rl.banCities;return bp||bc?cablesFor(a,b).filter(c=>!(bp&&(bp.includes(c.cid+':'+c.a+'-'+c.b)||bp.includes(c.cid+':'+c.b+'-'+c.a)))&&!(bc&&(bc.includes(c.a)||bc.includes(c.b)))):cablesFor(a,b);}
|
||
function cablesFor(a,b){return CABLE_PAIRS.filter(c=>(c.a===a&&c.b===b)||(c.a===b&&c.b===a));}
|
||
function cablePair(cid,a,b){const c=CABLE_PAIRS.find(x=>x.cid===cid&&((x.a===a&&x.b===b)||(x.a===b&&x.b===a)));if(!c)return null;return c.a===a?c:{...c,pts:c.pts.slice().reverse()};}
|
||
const ALLC=CITIES.filter(c=>!c.cn&&!c.ru&&!c.ixOnly).map(c=>c.id);
|
||
const ruCity=c=>!!CITY[c].ru;
|
||
const cnCity=c=>!!CITY[c].cn;
|
||
const BIGC=['man','edi','bcn','mil','rom','lis','ath','atn','den','phx','bos','hou','ruh','jed','doh','kyv','mel','bne','osa','kul','bkk','sgn','khi','dac','waw','prg','vie','bud','buh','ist','rio','bue','scl','bog','lim','del','maa','blr','hyd','tpe','cpt','auh','ber','zrh','nbo','cai','jkt','mnl','per','akl','dub','lax','tor','mex','dxb','cph','icn','sjc','dal','chi','ash','nyc','mia','sao','lon','ams','fra','par','mrs','mad','sto','bom','sin','hkg','tok','syd','jnb','lag'];
|
||
const MIDC=['man','bcn','mil','lis','atn','den','phx','bos','hou','mel','osa','kul','bkk','waw','vie','ist','rio','bue','scl','bog','del','maa','blr','tpe','auh','ber','zrh','jkt','mnl','dub','lax','tor','dxb','icn','sjc','ash','nyc','chi','dal','mia','lon','ams','fra','par','mad','sin','hkg','tok','syd','bom','sao'];
|
||
|
||
/* ================= NETWORKS ================= */
|
||
const NETS=[
|
||
{id:'lvl',name:'Level Tree',asn:3535,type:'t1',pol:'restrictive',share:.07,price:9,col:'#7B61FF',pops:['bde','man','edi','svg','mil','rom','lis','ath','atn','den','phx','bos','hou','slc','ber','zrh','dub','cph','osl','tor','lax','mex','mtl','sea','sjc','dal','chi','ash','nyc','mia','sao','lon','ams','fra','par','mad','rio','bue','scl','bog','lim','pan','waw','prg','vie','bud','buh','ist','kcy','cal','van','ott','bru','bet','ham','muc'],ix:[],blurb:tr('Grew from a seedling into a global backbone. Leaves no route behind.')},
|
||
{id:'ntt',name:'Not That Telecom',asn:2941,type:'t1',pol:'restrictive',share:.06,price:8,col:'#4B3FC4',pops:['man','mil','atn','den','bos','hou','phx','jkt','mnl','per','lax','dxb','icn','sea','sjc','dal','ash','nyc','lon','ams','fra','sin','hkg','tok','syd','tpe','del','maa','blr','hyd','osa','kul','bkk','sgn','kcy'],ix:[],blurb:tr('Huge in Asia. "Which telecom?" "Not that one."')},
|
||
{id:'tly',name:'Tell-Ya Carrier',asn:1229,type:'t1',pol:'restrictive',share:.05,price:8,col:'#9D4EDD',pops:['svg','edi','man','mil','rom','pmo','ath','ber','osl','cph','hel','beg','sof','chi','ash','nyc','mia','lon','ams','fra','par','sto','mad','mrs','hkg','sin','tpe','tll','waw','vie','bud','buh','prg','kyv','van','bru','ham','muc'],ix:[],blurb:tr('Nordic backbone that tells you exactly where your packets went.')},
|
||
{id:'cog',name:'Cogentle',asn:714,type:'t1',pol:'restrictive',share:.04,price:3,col:'#B35CF0',pops:['bde','man','edi','bcn','mil','rom','lis','ath','atn','den','phx','bos','hou','slc','ber','zrh','dub','hel','sof','beg','tor','lax','mex','cph','icn','sea','sjc','dal','chi','ash','nyc','mia','sao','lon','ams','fra','par','mad','mrs','sto','sin','hkg','tok','rio','bue','scl','bog','lim','osa','waw','prg','vie','bud','buh','ist','kyv','kcy','van','ott','bru','oos','bet','ham','muc'],ix:[],blurb:tr('Cheapest transit on the map. Famously gentle, except during peering spats.')},
|
||
{id:'tat',name:'Ta-Ta Comms',asn:6543,type:'t1',pol:'restrictive',share:.04,price:9,col:'#6A4C93',pops:['mil','pmo','lis','nbo','cai','jkt','dxb','nyc','ash','lon','fra','mrs','lag','jnb','bom','sin','hkg','tok','del','maa','blr','hyd','cpt','fuj','auh','tpe','khi','dac','cbo','kul','bkk','jed','ruh','doh'],ix:[],blurb:tr('Waves goodbye to latency across the Indian Ocean.')},
|
||
{id:'drz',name:'Drizzle Electric',asn:9369,type:'t2',pol:'open',share:.04,price:4,col:'#1E90FF',pops:['man','edi','svg','bde','bcn','mil','rom','pmo','lis','ath','atn','den','phx','bos','hou','slc','ber','zrh','nbo','akl','per','jkt','mnl','dub','rek','tor','mtl','lax','mex','sof','osl','icn','sea','sjc','dal','chi','ash','nyc','mia','lon','ams','fra','par','sto','mad','hkg','sin','tok','syd','jnb','for','rio','bue','scl','lim','bog','pan','del','maa','blr','hyd','tpe','auh','cpt','mel','bne','osa','kul','bkk','sgn','khi','dac','cbo','waw','prg','vie','bud','buh','tll','ist','kyv','jed','ruh','doh','kcy','cal','van','ott','bru','oos','bet','ham','muc'],ix:'ALL',blurb:tr('Will peer with anyone, anywhere. Rumored to mail out IPv6 cakes.')},
|
||
{id:'tng',name:'Tangerine Telecom',asn:5115,type:'t2',pol:'selective',minIx:15,minPni:40,share:.03,price:6,col:'#FF8C42',pops:['bcn','cai','nbo','dxb','par','mrs','mad','lon','ams','lag','jnb','waw','buh'],ix:['bcn','par','mrs','mad','lon','ams','lag','jnb','waw'],blurb:tr('Juicy reach into Europe and Africa.')},
|
||
{id:'sgt',name:'SingTell',asn:7474,type:'t2',pol:'selective',minIx:15,minPni:40,share:.03,price:7,col:'#00A6A6',pops:['jkt','mnl','per','akl','icn','sin','hkg','tok','syd','bom','tpe','maa','kul','bkk','sgn','mel'],ix:['sin','hkg','tok','syd','bom','tpe','maa','kul','bkk'],blurb:tr('Sings your packets across Asia-Pacific.')},
|
||
{id:'vdp',name:'Voda-Phony',asn:1373,type:'t2',pol:'paid',freeLv:7,paidFee:8000,share:.03,price:6,col:'#E63946',pops:['man','edi','mil','rom','lis','ath','nbo','cai','ber','dub','dxb','lon','fra','ams','mad','mrs','jnb','bom','lag','cpt','del','maa','ist','prg','bud','buh','doh'],ix:[],blurb:tr('Ended free peering across Europe and handed it to Inter.Clink, its “interconnection partner”, who will happily sell you a direct connection. Paid peering only, over a PNI. Ring ring, it’s the invoice.')},
|
||
{id:'ctc',name:'China Telecomet',asn:4314,type:'t2',pol:'restrictive',share:.02,price:22,premium:2.5,cn:true,col:'#0B5CAD',pops:['pek','sha','hkg','sin','tok','lon','fra','nyc','sjc'],ix:[],blurb:tr('The biggest network in China. Its CN-Too premium route skips the congested border, for a price.')},
|
||
{id:'cun',name:'China Unicorn',asn:4837,type:'t2',pol:'restrictive',share:.015,price:16,cn:true,col:'#D7000F',pops:['pek','sha','hkg','fra','sjc','lon'],ix:[],blurb:tr('Number two in China, with a horn for every backbone.')},
|
||
{id:'cmb',name:'China Moble',asn:9880,type:'eye',pol:'paid',freeLv:10,paidFee:12000,share:.01,cn:true,col:'#0085CA',pops:['pek','sha','hkg'],ix:[],blurb:tr('The largest mobile network on Earth. Paid peering only.')},
|
||
{id:'cmc',name:'Comecast',asn:7227,type:'eye',pol:'selective',minIx:10,minPni:30,share:.03,col:'#2C7A7B',pops:['atn','den','bos','hou','phx','slc','ash','nyc','chi','sjc','sea','mia'],ix:['atn','den','bos','ash','nyc','chi','sjc','sea'],blurb:tr('Huge eyeball network. Come for the broadband, stay because there is no other choice.')},
|
||
{id:'dtk',name:'Doitsche Telekomm',asn:3203,type:'eye',pol:'paid',freeLv:6,paidFee:9000,share:.03,col:'#E20074',pops:['fra','ams','lon','ham','muc'],ix:[],blurb:tr('Pink eyeball giant. Peering is available... for a monthly fee.')},
|
||
{id:'nfx',name:'NetChill',asn:2906,type:'cdn',pol:'selective',minIx:5,minPni:30,share:.15,cache:{name:'Open Couch',min:12},col:'#C8102E',pops:ALLC,ix:'ALL',blurb:tr('Streams 40% of evening traffic. Hands out free caches if you send enough eyeballs.')},
|
||
{id:'ggl',name:'Goggle',asn:15961,type:'cdn',pol:'selective',minIx:5,minPni:30,share:.13,cache:{name:'Goggle Global Cache',min:15},col:'#3A7BEA',pops:ALLC,ix:'ALL',blurb:tr('Search, video and goggles. Mostly goggles.')},
|
||
{id:'fbk',name:'Faceplant',asn:32943,type:'cdn',pol:'selective',minIx:5,minPni:25,share:.08,cache:{name:'Faceplant Node Thingy',min:10},col:'#3B5BDB',pops:BIGC,ix:'ALL',blurb:tr('Social media. Everyone keeps falling for it.')},
|
||
{id:'akm',name:'Akamaybe',asn:20490,type:'cdn',pol:'open',share:.07,cache:{name:'Akamaybe Box',min:6},col:'#0099CC',pops:ALLC,ix:'ALL',blurb:tr('The original CDN. Maybe it is already in your rack.')},
|
||
{id:'cfl',name:'Crowdflare',asn:13353,type:'cdn',pol:'open',share:.05,col:'#F48120',pops:BIGC,ix:'ALL',blurb:tr('Shields half the web from crowds of bots.')},
|
||
{id:'amz',name:"Amazin' Web Services",asn:16590,type:'cdn',pol:'selective',minIx:8,minPni:30,share:.05,col:'#FF9900',pops:MIDC,ix:'ALL',blurb:tr("The cloud. It's just someone else's Ashburn.")},
|
||
{id:'msf',name:'Microsnoft',asn:8705,type:'cdn',pol:'selective',minIx:5,minPni:25,share:.04,col:'#00A4EF',pops:MIDC,ix:'ALL',blurb:tr('Updates. So many updates.')},
|
||
{id:'bdc',name:'BiteDance',asn:39669,type:'cdn',pol:'open',share:.03,col:'#111111',pops:MIDC.concat(['pek','sha']),ix:'ALL',blurb:tr('Short videos, very long traffic graphs.')},
|
||
{id:'slw',name:'Slowly',asn:54311,type:'cdn',pol:'open',share:.02,col:'#E5383B',pops:MIDC,ix:'ALL',blurb:tr('An edge cloud that is, despite the name, quite fast.')},
|
||
];
|
||
NETS.push(
|
||
{id:'tcs',name:'TenCents',asn:45900,type:'cdn',pol:'selective',minIx:5,minPni:20,share:.02,cn:true,col:'#1AAD19',pops:['pek','sha','hkg','sin','tok','fra','sjc'],ix:['hkg','sin','tok','fra','sjc'],blurb:tr('Chat, games and payments. Every message costs ten cents.')},
|
||
{id:'abc',name:'AliBubble Cloud',asn:37936,type:'cdn',pol:'selective',minIx:5,minPni:20,share:.015,cn:true,col:'#FF6A00',pops:['pek','sha','hkg','sin','tok','fra','sjc','syd'],ix:['hkg','sin','tok','fra','sjc'],blurb:tr('Shopping festivals that melt traffic graphs.')},
|
||
{id:'byd',name:'Bye-du',asn:38635,type:'cdn',pol:'selective',minIx:5,minPni:20,share:.01,cn:true,col:'#2932E1',pops:['pek','sha','hkg'],ix:['hkg'],blurb:tr('Search, maps and a cheerful goodbye.')});
|
||
NETS.push(
|
||
{id:'rtc',name:'Rostelecomedy',asn:12389,type:'t2',pol:'selective',minIx:20,minPni:40,share:.01,price:6,col:'#7700FF',pops:['mos','hel','sto','fra','ams'],ix:['mos','fra','ams'],blurb:tr('The national carrier. Every punchline is pre-approved.')},
|
||
{id:'ydx',name:'Yawndex',asn:13238,type:'cdn',pol:'open',share:.008,col:'#FC3F1D',pops:['mos','hel','fra','ams'],ix:['mos','hel','fra','ams'],blurb:tr('Search, taxis and maps. Slightly sleepy.')},
|
||
{id:'vkl',name:'VKontakt-lens',asn:47541,type:'cdn',pol:'open',share:.006,col:'#0077FF',pops:['mos','hel'],ix:['mos','hel'],blurb:tr('Social network with perfect vision.')},
|
||
{id:'ets',name:'Etis-a-lot',asn:5384,type:'eye',pol:'paid',freeLv:9,paidFee:8000,share:.006,col:'#719E19',pops:['dxb','mrs','lon','fra','sin','auh','fuj','doh'],ix:[],blurb:tr('Charges a lot. Paid peering only, and the name says it all.')},
|
||
{id:'tmx',name:'Tel-Mess',asn:8151,type:'eye',pol:'paid',freeLv:8,paidFee:7000,share:.008,col:'#00A0DF',pops:['mex','dal','lax','mia'],ix:[],blurb:tr('Mexico’s giant. Paid peering only, and the pricing is a mess.')},
|
||
{id:'bcd',name:'Bell Canad-eh',asn:577,type:'eye',pol:'selective',minIx:10,minPni:30,share:.01,col:'#00549A',pops:['tor','mtl','nyc','chi','ott','cal','van'],ix:['tor','mtl','ott'],blurb:tr('Polite, enormous, and sorry about the bill.')});
|
||
NETS.push(
|
||
{id:'tsf',name:'Telkom-selfie',asn:7713,type:'eye',pol:'selective',minIx:10,minPni:30,share:.01,col:'#E4002B',pops:['jkt','sin'],ix:['jkt','sin'],blurb:tr('Indonesia’s mobile giant. Every packet poses for a photo first.')},
|
||
{id:'pld',name:'PLDTea Time',asn:9299,type:'eye',pol:'selective',minIx:10,minPni:30,share:.008,col:'#D62027',pops:['mnl','hkg','sin'],ix:['hkg'],blurb:tr('Philippine giant. Peering requests are reviewed over a cup of tea.')},
|
||
{id:'spk',name:'Spark-le',asn:4771,type:'eye',pol:'open',share:.005,col:'#6A2C91',pops:['akl','syd'],ix:['akl','syd'],blurb:tr('New Zealand’s shiniest ISP.')},
|
||
{id:'tsy',name:'Telstraya',asn:1221,type:'t2',pol:'selective',minIx:15,minPni:40,share:.01,price:9,col:'#0099F8',pops:['syd','per','sin','hkg','lax','tpe','mel','bne','drw'],ix:['syd','sin','hkg','mel','bne'],blurb:tr('Australia’s big one. G’day, that will be nine dollars a megabit. Sorry, gigabit.')});
|
||
NETS.push(
|
||
{id:'sfc',name:'Safari-Comic',asn:33771,type:'eye',pol:'selective',minIx:5,minPni:20,share:.006,col:'#4CB848',pops:['nbo'],ix:['nbo'],blurb:tr('Kenya’s mobile giant. Pays you in M-Pesos.')},
|
||
{id:'teg',name:'Tele-Comet Egypt',asn:8452,type:'t2',pol:'selective',minIx:15,minPni:40,share:.006,price:8,col:'#5B2D8E',pops:['cai','mrs','fra','lon'],ix:['cai','mrs'],blurb:tr('Owns the land crossing every Red Sea cable needs. Collects tolls like a pharaoh.')});
|
||
NETS.push(
|
||
{id:'clr',name:'Clarovision',asn:28537,type:'t2',pol:'selective',minIx:10,minPni:30,share:.012,price:5,col:'#DA291C',pops:['sao','rio','for','bue','scl','lim','bog','pan','mex','mia'],ix:['sao','rio','for','bue','scl','lim','bog'],blurb:tr('The big regional carrier. Sees everything clearly, especially your invoice.')},
|
||
{id:'viv',name:'Viva Vivo',asn:26959,type:'eye',pol:'selective',minIx:8,minPni:25,share:.01,col:'#660099',pops:['sao','rio','for'],ix:['sao','rio','for'],blurb:tr('Brazil’s mobile giant. Very much alive.')},
|
||
{id:'mlv',name:'Mercado Livre-ly',asn:52850,type:'cdn',pol:'open',share:.006,col:'#FFE600',pops:['sao','rio','bue','scl','bog','lim','mia'],ix:['sao','rio','bue','scl','bog','lim'],blurb:tr('Ships parcels and packets, both overnight.')},
|
||
{id:'jio',name:'Jio-graphy',asn:55863,type:'eye',pol:'selective',minIx:10,minPni:30,share:.02,col:'#0F3CC9',pops:['bom','del','maa','blr','hyd'],ix:['bom','del','maa','blr','hyd'],blurb:tr('Gave a billion people cheap data. Knows exactly where every one of them is.')},
|
||
{id:'atl',name:'Airtel-tale',asn:9849,type:'t2',pol:'selective',minIx:15,minPni:40,share:.01,price:7,col:'#E40000',pops:['bom','del','maa','blr','hyd','sin','lon','dxb','dac','cbo'],ix:['bom','del','maa','blr'],blurb:tr('India’s other giant. Every outage comes with a story.')},
|
||
{id:'cht',name:'Chunghwa Tele-calm',asn:3426,type:'t2',pol:'selective',minIx:10,minPni:30,share:.008,price:7,col:'#00A0E9',pops:['tpe','hkg','tok','lax','sin'],ix:['tpe','hkg'],blurb:tr('Taiwan’s incumbent. Stays calm while ships drag their anchors over its cables.')},
|
||
{id:'duu',name:'Du-opoly',asn:15820,type:'eye',pol:'paid',freeLv:11,paidFee:6000,share:.004,col:'#00A9CE',pops:['dxb','auh','fuj'],ix:[],blurb:tr('The other half of the UAE duopoly. Does what Etis-a-lot does, in a different colour.')});
|
||
NETS.push(
|
||
{id:'kdi',name:'KD-DIY',asn:2561,type:'t2',pol:'selective',minIx:10,minPni:30,share:.008,price:6,col:'#E85D04',pops:['tok','osa','lax','sin','hkg'],ix:['tok','osa'],blurb:tr('Japanese carrier that builds everything itself. Even the cable ships.')},
|
||
{id:'opt',name:'Opt-Out-Us',asn:7745,type:'eye',pol:'selective',minIx:8,minPni:25,share:.006,col:'#00837E',pops:['syd','mel','bne','per'],ix:['syd','mel','bne'],blurb:tr('Australia’s number two. You can opt out of the marketing emails, eventually.')},
|
||
{id:'tru',name:'Mostly-True Move',asn:7740,type:'eye',pol:'selective',minIx:5,minPni:20,share:.006,col:'#E4002B',pops:['bkk'],ix:['bkk'],blurb:tr('Thailand’s mobile giant. Its coverage maps are mostly true.')},
|
||
{id:'vtl',name:'Viet-tell',asn:7525,type:'t2',pol:'selective',minIx:10,minPni:30,share:.005,price:7,col:'#EE0033',pops:['sgn','hkg','sin'],ix:['sgn'],blurb:tr('Vietnam’s giant. Will tell you which subsea cable is broken this week.')},
|
||
{id:'ptc',name:'PTC-hell',asn:17577,type:'t2',pol:'selective',minIx:10,minPni:30,share:.004,price:8,col:'#00843D',pops:['khi','dxb'],ix:['khi'],blurb:tr('Pakistan’s incumbent. Every session comes with a firewall rule.')},
|
||
{id:'tmy',name:'Telekom Ma-lazy-sia',asn:4877,type:'t2',pol:'selective',minIx:10,minPni:30,share:.004,price:6,col:'#1F2A6B',pops:['kul','sin'],ix:['kul'],blurb:tr('Malaysia’s incumbent. In no hurry whatsoever.')},
|
||
{id:'ttk',name:'Türk Tele-komik',asn:9211,type:'t2',pol:'selective',minIx:10,minPni:30,share:.008,price:6,col:'#1D3F8F',pops:['ath','ist','fra','sof','lon'],ix:['ist'],blurb:tr('Bridges Europe and Asia, and occasionally your BGP table.')},
|
||
{id:'dgi',name:'Digi-tally Cheap',asn:8798,type:'eye',pol:'open',share:.006,col:'#2A5CAA',pops:['buh','bud','mad'],ix:['buh','bud','mad'],blurb:tr('Gigabit to every flat for the price of a coffee. Peers with anyone.')},
|
||
{id:'ups',name:'UPC-You-Later',asn:6380,type:'eye',pol:'selective',minIx:8,minPni:25,share:.006,col:'#D8001B',pops:['waw','prg','vie','bud','zrh','kyv'],ix:['waw','prg','vie','kyv'],blurb:tr('Cable broadband across Central Europe. See you later, in a support queue.')});
|
||
NETS.push(
|
||
{id:'tlu',name:'Tell Us',asn:852,type:'eye',pol:'selective',minIx:10,minPni:30,share:.008,up:['lvl','tly'],col:'#4B286D',pops:['van','cal','tor','mtl','ott','sea'],ix:['van','cal','tor'],blurb:tr('Western Canada’s incumbent. Tell us what you need, and we will tell you the price.')},
|
||
{id:'rgc',name:'Bodgers Communications',asn:812,type:'eye',pol:'selective',minIx:10,minPni:30,share:.01,up:['cog','ntt'],col:'#DA291C',pops:['tor','ott','mtl','van','cal'],ix:['tor','ott','van'],blurb:tr('Canada’s cable giant, held together with duct tape. Now and then all of it goes down at once, which is at least consistent.')});
|
||
NETS.push(
|
||
{id:'tny',name:'Telenyet',asn:6848,type:'eye',pol:'selective',minIx:10,minPni:30,share:.008,up:['lvl'],col:'#FFC421',pops:['bru','oos','ams','fra','lon'],ix:['bru'],blurb:tr('Half of the Flanders duopoly, on coax. Keeps a tiny port at Frites-IX and hides behind its international parent, so bring a PNI.')},
|
||
{id:'pxm',name:'Proxyminus',asn:5432,type:'eye',pol:'selective',minIx:15,minPni:40,share:.008,up:['bgs','lvl'],col:'#5C2D91',pops:['bru','oos','ams'],ix:['bru'],blurb:tr('The other half of the duopoly, on copper and fiber. Strictly domestic: the world reaches it through its wholesale arm.')},
|
||
{id:'bgs',name:'B.I.G.S.',asn:6774,type:'t2',pol:'selective',minIx:10,minPni:30,share:.005,price:5,up:['lvl'],col:'#7B2D8E',pops:['bru','bet','ams','fra','lon','par','mrs','nyc','sin'],ix:['bru','bet','ams','fra','lon','par'],blurb:tr('Proxyminus’s wholesale arm. Present at nearly every exchange on Earth, and Belgian about it.')},
|
||
{id:'cit',name:'Citrus Belgium',asn:47377,type:'eye',pol:'selective',minIx:10,minPni:30,share:.005,up:['lvl'],col:'#FF7900',pops:['bru','par'],ix:['bru'],blurb:tr('Mobile, cable and a lot of Walloon highway dark fiber. Zesty.')},
|
||
{id:'cms',name:'CityMess',asn:199095,type:'eye',pol:'open',share:.002,up:['cog'],col:'#00B2A9',pops:['oos','bru'],ix:['bru'],blurb:tr('Private 5G and business fiber from Oostkamp. Its traffic arrives in sudden industrial bursts.')});
|
||
NETS.push({id:'kys',name:'Kyiv Superstar',asn:15859,type:'eye',pol:'selective',minIx:5,minPni:20,share:.006,col:'#0055B8',pops:['kyv','waw','fra'],ix:['kyv'],blurb:tr('Ukraine’s biggest mobile network. Has kept working through things most networks never have to plan for.')});
|
||
NETS.push({id:'stc',name:'Sticky Telecom',asn:39368,type:'t2',pol:'selective',minIx:10,minPni:30,share:.01,price:8,col:'#4F008C',pops:['ruh','jed','dxb','fra','lon','cai'],ix:['ruh'],blurb:tr('The Kingdom’s incumbent. Once you are in, you stay in.')},
|
||
{id:'ord',name:'Ooh-redoo',asn:8871,type:'eye',pol:'paid',freeLv:11,paidFee:5000,share:.004,col:'#ED1C24',pops:['doh','dxb','jkt'],ix:[],blurb:tr('Qatar’s big operator. Paid peering only, and it sings the price list to you.')});
|
||
NETS.push(
|
||
{id:'tim',name:'TIM-Tam Italia',asn:3269,type:'eye',pol:'selective',minIx:8,minPni:25,share:.008,col:'#004691',pops:['mil','rom','pmo'],ix:['mil','rom'],blurb:tr('Italy’s incumbent. Sweet on the outside, very firm about peering ratios.')},
|
||
{id:'skl',name:'Sparkly Seabone',asn:6762,type:'t1',pol:'restrictive',share:.04,price:6,col:'#5B2C83',pops:['pmo','mil','rom','ath','mrs','bcn','mad','lis','par','lon','ams','fra','zrh','vie','bud','prg','waw','buh','sof','ist','ber','sto','nyc','ash','mia','atn','dal','chi','lax','sjc','tor','mex','pan','bog','lim','scl','bue','sao','rio','for','cai','jed','dxb','bom','sin','hkg','tok'],ix:[],blurb:tr('The Tier 1 that grew up in Sicily. Its Seabone backbone owns the Mediterranean and reaches deep into the Americas, and it still calls Palermo home.')},
|
||
{id:'fwb',name:'Fast-Webby',asn:12874,type:'eye',pol:'open',share:.004,col:'#FDC300',pops:['mil','rom'],ix:['mil','rom'],blurb:tr('Fiber to the Italian home, with a website from 2003.')},
|
||
{id:'meo',name:'MEO-w Portugal',asn:3243,type:'eye',pol:'selective',minIx:5,minPni:20,share:.004,col:'#00A3E0',pops:['lis','mad'],ix:['lis'],blurb:tr('Portugal’s incumbent. Purrs when you send it traffic.')},
|
||
{id:'nos',name:'NOS-y Neighbour',asn:2860,type:'eye',pol:'open',share:.003,col:'#111111',pops:['lis'],ix:['lis'],blurb:tr('Peers with anyone, and wants to know everything about your routes.')},
|
||
{id:'cos',name:'Cosmo-Note',asn:6799,type:'eye',pol:'selective',minIx:5,minPni:20,share:.004,col:'#7DC242',pops:['ath','sof'],ix:['ath'],blurb:tr('Greece’s incumbent. Takes careful notes on every peering request.')},
|
||
{id:'spc',name:'Spectre-um Cable',asn:20115,type:'eye',pol:'selective',minIx:12,minPni:35,share:.02,col:'#0099D8',pops:['nyc','lax','dal','chi','atn','den','phx','slc','hou','bos','sjc'],ix:['nyc','lax','dal','chi','atn','den'],blurb:tr('Cable broadband for half of America. Haunts your traceroutes.')},
|
||
{id:'vzn',name:'Very-Zone',asn:701,type:'eye',pol:'paid',paidFee:9000,share:.015,col:'#CD040B',pops:['nyc','ash','bos','dal','lax','chi','atn','mia'],ix:[],blurb:tr('Can you hear me now? Only if you pay for the PNI.')});
|
||
/* Rival exchanges. Big metros rarely have just one IX: challengers undercut the incumbent and
|
||
share many members with it, but not all. The incumbent keeps the city id, challengers are 'city~n'. */
|
||
const XIX=[
|
||
{id:'jnb~2',c:'jnb',name:'JINXED-IX',cheap:.7,take:0.5,core:['drz','akm','cfl','tng'],blurb:tr('The older Johannesburg exchange, run by the local ISP association. Knock on wood before every maintenance window.')},
|
||
{id:'fra~2',c:'fra',name:'KleyWrecks',cheap:.5,take:0.5,core:['drz','akm','cfl','slw','bdc','ydx'],blurb:tr('A smaller commercial exchange down the road from DE-KICKS. Publishes its prices on one web page, which DE-KICKS considers an act of war. Ports come without a sales webinar.')},
|
||
{id:'fra~3',c:'fra',name:'Apfelwein-IX',cheap:0.3,take:0.3,blurb:tr('A community exchange run from above a cider bar. Tiny, cheap, and every member gets a glass.')},
|
||
{id:'ams~2',c:'ams',name:'NL-Nyx',cheap:0.6,take:0.6,blurb:tr('One fabric across the whole country. Distributed, cheap and a little smug about it.')},
|
||
{id:'ams~3',c:'ams',name:'FRIES-IX',cheap:1,take:0.5,freeTo:1,core:['drz','akm','cfl','slw','msf'],blurb:tr('Settlement-free peering with Frysian roots. The 10G and 100G ports cost nothing. Bring an ASN and an appetite for route servers. Mayonnaise is extra.')},
|
||
{id:'lon~2',c:'lon',name:'LO-NAPS',cheap:.6,take:0.5,core:['drz','akm','cfl','slw','bdc','msf','fbk'],blurb:tr('Member-owned and not-for-profit. Smaller than LYNX, but the AGM has biscuits.')},
|
||
{id:'par~2',c:'par',name:'Baguette-IX',cheap:0.55,take:0.5,blurb:tr('The challenger. Fresh every morning, a bit crusty by the evening.')},
|
||
{id:'mad~2',c:'mad',name:'Paella-NIX',cheap:.6,take:0.5,core:['drz','akm','cfl','tng','bdc','slw','msf'],blurb:tr('The long-established Madrid exchange. Neutral interconnection, local flavour and a route server that never takes a siesta.')},
|
||
{id:'mil~2',c:'mil',name:'Aperitivo-IX',cheap:0.5,take:0.45,blurb:tr('Opens at six, comes with free snacks, closes when the last session drops.')},
|
||
{id:'ber~2',c:'ber',name:'Club-Mate-IX',cheap:0.35,take:0.4,blurb:tr('Run by hackers on caffeine. The route server has a disco ball.')},
|
||
{id:'waw~2',c:'waw',name:'Bigos-IX',cheap:0.45,take:0.5,blurb:tr('Warsaw has more exchanges than anyone can count. This is the second biggest, this week.')},
|
||
{id:'waw~3',c:'waw',name:'Zapiekanka-IX',cheap:0.3,take:0.35,blurb:tr('Open-faced, cheap and available at 3 a.m.')},
|
||
{id:'prg~2',c:'prg',name:'Knedlík-IX',cheap:0.35,take:0.4,blurb:tr('Dense, filling and very cheap.')},
|
||
{id:'buh~2',c:'buh',name:'Mici-IX',cheap:0.35,take:0.45,blurb:tr('Grilled ports, served with mustard and a cold beer.')},
|
||
{id:'sto~2',c:'sto',name:'Fika-IX',cheap:0.5,take:0.5,blurb:tr('Every session comes with a coffee break. Strictly enforced.')},
|
||
{id:'kyv~2',c:'kyv',name:'Kyiv-Cake-IX',cheap:0.35,take:0.45,blurb:tr('Layered, resilient and somehow always open.')},
|
||
{id:'nyc~2',c:'nyc',name:'Bagel-IX',cheap:0.6,take:0.5,blurb:tr('A community exchange in a Hudson Street basement. Schmear not included.')},
|
||
{id:'chi~2',c:'chi',name:'Deep-Dish-IX',cheap:0.6,take:0.5,blurb:tr('Takes forever to set up, but very filling.')},
|
||
{id:'sjc~2',c:'sjc',name:'Garage-IX',cheap:0.55,take:0.45,blurb:tr('Started in somebody’s garage, like everything else round here.')},
|
||
{id:'lax~2',c:'lax',name:'Smog-IX',cheap:0.6,take:0.45,blurb:tr('You can’t see the fabric, but it is definitely there.')},
|
||
{id:'sin~2',c:'sin',name:'Kopi-IX',cheap:0.6,take:0.5,blurb:tr('Strong, sweet and cheaper than the incumbent.')},
|
||
{id:'hkg~2',c:'hkg',name:'Dim-Sum-IX',cheap:0.6,take:0.5,blurb:tr('Lots of small sessions on little plates.')},
|
||
{id:'tok~2',c:'tok',name:'Bento-IX',cheap:0.65,take:0.5,core:['drz','akm','cfl','sgt','msf','amz'],blurb:tr('Tokyo has more exchanges than anyone can name. This one was started by a broadband giant and comes neatly packed, every member in its own compartment.')},
|
||
{id:'syd~2',c:'syd',name:'IX Strayla',cheap:.7,take:0.5,core:['drz','akm','cfl','ggl','spk','tsy'],blurb:tr('The nationwide not-for-profit exchange. Cheaper ports than Roo-IX, same distance from everything else. An acquired taste, like Vegemite.')},
|
||
{id:'bom~2',c:'bom',name:'Vada-Pav-IX',cheap:0.45,take:0.45,blurb:tr('Mumbai’s street-food exchange. Fast, spicy and cheap.')},
|
||
{id:'dxb~2',c:'dxb',name:'Shawarma-IX',cheap:0.6,take:0.4,blurb:tr('The challenger to the DE-KICKS fabric, wrapped and ready to go.')},
|
||
];
|
||
const XIXM=Object.fromEntries(XIX.map(x=>[x.id,x]));
|
||
/* The long tail: odd little networks with a sliver of traffic each, on one or two exchanges. */
|
||
const TAIL=[
|
||
['Grandma’s Basement Hosting','cdn',['fra'],tr('Three servers, one dehumidifier and a very patient grandmother.')],
|
||
['Hamster Wheel Networks','eye',['ams'],tr('Powered by renewable rodents. Uptime depends on snack schedule.')],
|
||
['Fjordnet Kooperativ','eye',['osl'],tr('A fiber co-op for one valley. Every member owns a metre of cable.')],
|
||
['Kebab-Link','eye',['ber','fra'],tr('An ISP run from the back of a kebab shop. Late-night support is excellent.')],
|
||
['Mesh Collective e.V.','eye',['ber','fra'],tr('Volunteers with rooftop antennas and strong opinions about IPv6.')],
|
||
['Village Fibre Co-op','eye',['lon'],tr('Dug the trench themselves, one field at a time.')],
|
||
['Tiny Swiss Bank Shield','cdn',['zrh'],tr('Hosts exactly one website and three lawyers.')],
|
||
['Clockwork ISP','eye',['zrh'],tr('Packets leave on time, to the second.')],
|
||
['LAN-Party Federation','cdn',['ams','fra'],tr('Game servers, energy drinks and a ping obsession.')],
|
||
['Former Church Datacenter','cdn',['ams'],tr('Racks in the nave, cooling in the crypt. Divine uptime.')],
|
||
['WISP on a Silo','eye',['dal','chi'],tr('Wireless internet from the top of a grain silo.')],
|
||
['Cornfield Broadband','eye',['chi'],tr('Rural fiber that follows the tractor routes.')],
|
||
['Moose Lake Telephone Co-op','eye',['tor','mtl'],tr('Has served the lake since 1912. Now with fiber.')],
|
||
['Surf Shop Networks','cdn',['lax'],tr('Hosting for surfboard shops. Closed when the waves are good.')],
|
||
['Ski Lift Fiber','eye',['den','zrh'],tr('Fiber strung along the chairlifts. Seasonal latency.')],
|
||
['Tumbleweed Telecom','eye',['phx','dal'],tr('Covers a lot of empty ground.')],
|
||
['Crypto Bro Colo','cdn',['ash','mia'],tr('Ten thousand GPUs and a podcast.')],
|
||
['Ye Olde University Network','eye',['bos','lon'],tr('Has had a /8 since before you were born.')],
|
||
['Mom & Pop Packet Shop','eye',['nyc'],tr('Family-run since dial-up. Still answers the phone.')],
|
||
['Space Cowboy Broadband','eye',['hou','dal'],tr('Yee-haw and low Earth orbit.')],
|
||
['Fry Sauce Fibre','eye',['slc'],tr('Utah’s dipping-sauce of an ISP.')],
|
||
['Sauna Uplink Oy','cdn',['hel','sto'],tr('Servers cooled by the lake, then used to heat the sauna.')],
|
||
['Reindeer Relay','eye',['sto','osl','hel'],tr('Wireless links across the tundra. Antlers occasionally in the way.')],
|
||
['Pierogi Hosting','cdn',['waw'],tr('Cheap, filling hosting. Ask for the potato-and-cheese plan.')],
|
||
['Sunflower Uplink','eye',['kyv','waw'],tr('Kept the lights on in its town through every blackout.')],
|
||
['Tram Line Telecom','eye',['prg','vie'],tr('Fiber laid under the tram tracks during a night shift.')],
|
||
['Paprika Peering','eye',['bud'],tr('Spicy pricing, mild latency.')],
|
||
['Dracula Datacenter','cdn',['buh'],tr('Only comes online at night.')],
|
||
['Bosphorus Ferry Net','eye',['ist'],tr('Wi-Fi on every ferry, backhaul on every bridge.')],
|
||
['Gondola Gigabit','eye',['mil','rom'],tr('Started in Venice. Upgraded to land.')],
|
||
['Nonna’s Pasta Pipes','cdn',['rom','pmo'],tr('Hosting for every family restaurant in the south.')],
|
||
['Tram 28 Telecom','eye',['lis'],tr('Slow on the hills, fast on the flat.')],
|
||
['Olive Grove Online','eye',['ath'],tr('Rural broadband for the islands, one olive tree at a time.')],
|
||
['Siesta Server Hotel','cdn',['mad'],tr('Down from 2 to 5 p.m. every day. By design.')],
|
||
['Bouillabaisse Bits','cdn',['mrs','par'],tr('A rich mix of everything the fishermen brought in.')],
|
||
['Baguette Bandwidth Associés','eye',['par'],tr('Delivered fresh every morning.')],
|
||
['Pub Quiz Internet','eye',['dub','lon'],tr('Founded after a pub quiz, by the losing team.')],
|
||
['Gaming Café Net','eye',['lag'],tr('Internet cafe turned ISP. The gamers came for the ping.')],
|
||
['Matatu Mobile Mesh','eye',['nbo'],tr('Wi-Fi on minibuses, and the music is free.')],
|
||
['Load-Shedding Survivors','eye',['jnb','cpt'],tr('Has more batteries than customers.')],
|
||
['Bollywood Buffer','cdn',['bom','del'],tr('Three-hour films, zero-second start times.')],
|
||
['Hawker Centre Hosting','cdn',['sin','kul'],tr('Cheap, fast and open late.')],
|
||
['Karaoke Box Networks','cdn',['tok','osa','icn'],tr('Lyrics servers, low latency, high pitch.')],
|
||
['Night Market Net','eye',['tpe','hkg'],tr('Comes alive after dark.')],
|
||
['Kangaroo Courier','eye',['syd','mel','bne'],tr('Packets hop. Sometimes backwards.')],
|
||
['Hobbit Hole Hosting','cdn',['akl'],tr('Cosy racks under a hill. Second breakfast at 11.')],
|
||
['Capybara Connect','eye',['sao','bue'],tr('Gets along with every other network. Famously chill.')],
|
||
['Llama Link','eye',['lim','scl','bog'],tr('Mountain wireless. Will spit at bad routes.')],
|
||
['Supercar Hosting','cdn',['dxb'],tr('Gold-plated servers, valet parking for packets.')],
|
||
['Tango Transit Co-op','eye',['bue'],tr('It takes two to peer.')],
|
||
['Bánh Mì Broadband','eye',['sgn'],tr('Crispy on the outside, cheap on the inside.')],
|
||
['Jeepney Jumpnet','eye',['mnl'],tr('Colourful, crowded and gets you there eventually.')],
|
||
['Game Server Gremlins','cdn',['fra','ams','lon','nyc','sjc'],tr('Hosts every game you play at 2 a.m. Hates jitter.'),0.003],
|
||
['Discord-ant Voice Relay','cdn',['ams','fra','ash'],tr('Voice chat for millions of gamers who all talk at once.'),0.003],
|
||
['Mastodon Instance Herd','cdn',['ber','ams','par'],tr('A thousand tiny social networks on one rack.')],
|
||
['Dutch Bike Fibre','eye',['ams'],tr('Fiber laid along the bike lanes. Fastest in the rain.')],
|
||
['Chip Fab Cleanroom Net','cdn',['tpe','phx'],tr('Bunny suits mandatory in the server room.')],
|
||
['Volunteer Fire Brigade Wi-Fi','eye',['vie','zrh'],tr('Runs the village network between call-outs.')],
|
||
['Peach State Hosting','cdn',['atn'],tr('Sweet, fuzzy and surprisingly reliable.')],
|
||
['Chowder Hosting','cdn',['bos'],tr('Thick, comforting and very New England.')],
|
||
];
|
||
function ixStatic(c){const o=[];if(CITY[c]&&CITY[c].ix)o.push(c);for(const x of XIX)if(x.c===c)o.push(x.id);return o;}
|
||
TAIL.forEach(([name,type,home,blurb,sh],i)=>{const h=hstr(name),cand=home.flatMap(ixStatic),ix=[];
|
||
if(cand.length){ix.push(cand[h%cand.length]);if(cand.length>1&&(h>>>8)%100<40){const o=cand[(h>>>12)%cand.length];if(!ix.includes(o))ix.push(o);}}
|
||
const sel=(h>>>4)%10>=8;
|
||
NETS.push({id:'tail'+i,name,asn:200000+(h%190000),type,tail:true,pol:sel?'selective':'open',...(sel?{minIx:1+(h>>>16)%3,minPni:6+(h>>>18)%8}:{}),share:sh||+(0.0006+((h>>>20)%15)*0.0001).toFixed(4),col:`hsl(${h%360} 55% 46%)`,pops:home.slice(),ix,blurb});});
|
||
NETS.push(
|
||
{id:'ktt',name:'Kay-Tea',asn:4766,type:'eye',pol:'paid',paidFee:5000,perG:90,kr:true,share:.012,col:'#E4002B',pops:['icn','hkg','tok','lax'],ix:[],blurb:tr('Korea’s incumbent. Sender pays: every gigabit you hand it is billed, on top of the port.')},
|
||
{id:'skb',name:'SK Broadbandit',asn:9318,type:'eye',pol:'paid',paidFee:4000,perG:110,kr:true,share:.01,col:'#EA002C',pops:['icn','hkg','sjc'],ix:[],blurb:tr('Took a streaming giant to court over who pays for the traffic its own customers asked for. Paid peering, per gigabit.')},
|
||
{id:'lgu',name:'LG You-Pay-Plus',asn:3786,type:'eye',pol:'paid',paidFee:3000,perG:80,kr:true,share:.008,col:'#E6007E',pops:['icn','tok'],ix:[],blurb:tr('The plus is a usage fee. Paid peering, per gigabit.')});
|
||
NETS.push(
|
||
{id:'btt',name:'Bee-Tee',asn:2856,type:'eye',pol:'selective',minIx:10,minPni:30,share:.012,col:'#5514B4',pops:['lon','man','edi','bde'],ix:['lon','man'],blurb:tr('The UK’s incumbent. Buzzes politely, stings on price.')},
|
||
{id:'sky',name:'Sky-High Broadband',asn:5607,type:'eye',pol:'selective',minIx:6,minPni:25,share:.008,col:'#0072C9',pops:['lon','man','edi','dub'],ix:['lon','man','edi'],blurb:tr('Football, films and a router that looks like a spaceship.')},
|
||
{id:'vmo',name:'Virgin Mediocre',asn:5089,type:'eye',pol:'selective',minIx:6,minPni:25,share:.007,col:'#E10A0A',pops:['lon','man','edi'],ix:['lon','man'],blurb:tr('Cable broadband for half of Britain. Fast on a good day.')},
|
||
{id:'tnr',name:'Tele-Nor-Way',asn:2119,type:'eye',pol:'selective',minIx:5,minPni:20,share:.006,col:'#00A9E0',pops:['osl','svg','sto','cph'],ix:['osl','svg'],blurb:tr('Norway’s incumbent. Neither yes nor no, until you send enough traffic.')});
|
||
const NET=Object.fromEntries(NETS.map(n=>[n.id,n]));
|
||
for(const X of XIX){X.members=NETS.filter(n=>Array.isArray(n.ix)&&n.ix.includes(X.id)||!n.tail&&(X.core?X.core.includes(n.id):(n.ix==='ALL'||Array.isArray(n.ix)&&n.ix.includes(X.c))&&hstr(n.id+'|'+X.id)%100<(n.ix==='ALL'?72:X.take*100))).map(n=>n.id);}
|
||
const NSH={}; {const t=NETS.reduce((a,n)=>a+n.share,0); NETS.forEach(n=>NSH[n.id]=n.share/t);}
|
||
// After Glitch leaves Korea, Seoul viewers watch half as much of it and the rest moves to everyone else.
|
||
const NSH_KRX={}; {const w=id=>NSH[id]*(id==='amz'?0.5:1),t=NETS.reduce((a,n)=>a+w(n.id),0); NETS.forEach(n=>NSH_KRX[n.id]=w(n.id)/t);}
|
||
const CN_W={ctc:.2,cun:.14,cmb:.08,tcs:.22,abc:.14,byd:.08,bdc:.08,akm:.02,msf:.02,amz:.01,drz:.01};
|
||
const RU_W={ydx:.24,vkl:.12,rtc:.14,ggl:.12,bdc:.08,akm:.05,cfl:.06,msf:.04,amz:.03,tly:.02,cog:.02,drz:.01};
|
||
const NSH_RU={}; {const t=Object.values(RU_W).reduce((a,b)=>a+b,0); for(const k in RU_W)NSH_RU[k]=RU_W[k]/t;}
|
||
const NSH_CN={}; {const t=Object.values(CN_W).reduce((a,b)=>a+b,0); for(const k in CN_W)NSH_CN[k]=CN_W[k]/t;}
|
||
const CN_BLOCKED=NETS.filter(n=>!CN_W[n.id]&&n.type==='cdn').map(n=>n.name);
|
||
const TYPE_L={t1:tr('Tier 1'),t2:tr('Tier 2'),cdn:tr('CDN / content'),eye:tr('Eyeballs')};
|
||
const initials=n=>n.name.replace(/[^A-Za-z ]/g,'').split(' ').filter(Boolean).map(w=>w[0]).join('').slice(0,3).toUpperCase();
|
||
|
||
/* ================= BUSINESSES ================= */
|
||
const BIZ_T={
|
||
dia:{l:tr('Enterprise DIA'),opts:[1,2,5,10],rate:600},
|
||
game:{l:tr('Game servers'),opts:[5,10,20,40],rate:120},
|
||
host:{l:tr('Hosting'),opts:[10,20,40,80],rate:60},
|
||
isp:{l:tr('Downstream ISP (buys transit)'),opts:[100,200,400,800],rate:15,lv:2},
|
||
l2vpn:{l:tr('L2VPN circuit'),opts:[1,10,40,100],rate:0,l2:true,km:1,lv:1},
|
||
fabip:{l:tr('Customer on a fabric (transit over an NNI)'),opts:[1,5,10,25],rate:110,nni:true,lv:2},
|
||
fabl2:{l:tr('Fabric circuit to one of your POPs'),opts:[1,5,10],rate:0,l2:true,nni:true,km:0.8,lv:2},
|
||
stream:{l:tr('Streaming startup'),opts:[50,100,200],rate:80,lv:2},
|
||
edu:{l:tr('University network'),opts:[20,50,100],rate:90,lv:2},
|
||
gpu:{l:tr('AI GPU data center'),opts:[200,400,800],rate:70,lv:3,names:['Neural Noodles AI','GPUs R Us','Hallucination Labs','Transformers & Sons','Token Burners Inc.','Very Large Language Co.','Prompt Engineering Ltd','DeepThought Farms','Parameter Pastures','Gradient Descent Diner','Attention Is All We Need LLC','Overfit Analytics']},
|
||
onramp:{l:tr('Cloud on-ramp'),opts:[100,200,400],rate:0,l2:true,km:0.7,lv:3,names:["Amazin' Web Services on-ramp","Microsnoft Azzure on-ramp",'Goggle Cloud on-ramp','AliBubble Cloud on-ramp','Miracle Cloud on-ramp']},
|
||
ai:{l:tr('AI training interconnect'),opts:[400,800,1600],rate:0,l2:true,div:true,km:0.9,lv:4,names:['Skynot Compute','Galaxy Brain Training Run','Megawatt Minds','The Big Model Co.','Infinite Context Corp','Sentient Spreadsheet Inc.']},
|
||
hyper:{l:tr('Hyperscaler DCI'),opts:[1600,3200,6400],rate:0,l2:true,div:true,km:0.5,lv:4,names:["Amazin' Web Services DCI","Microsnoft Azzure DCI",'Goggle Cloud DCI','Faceplant Infra DCI','AliBubble Cloud DCI']},
|
||
hft:{l:tr('High-frequency trading link'),opts:[1,5,10],rate:0,l2:true,lat:true,km:6,lv:2,names:['Flash Boys Capital','Nanosecond Nancy Trading','Speed of Light Securities','Arbitrage & Sons','Front-Run Fund','Microwave Tower Capital','Tick-Tock Quant','Low Latency Larry LLC']},
|
||
bulk:{l:tr('Bulk backup transfer (latency does not matter)'),opts:[100,200,400],rate:0,l2:true,scenic:true,km:0.1,lv:2,names:['Glacier Slow Storage','Tape Backup Tortoise','Scenic Route Archives','Cold Storage Cold Cuts','Sloth Sync','Eventually Consistent Inc.','Snail Mail Data Co.']},
|
||
event:{l:tr('Event network'),opts:[100,200,400,800,1600,3200],rate:0,event:true,lv:2,names:['Carnaval Parade','Diwali Streaming Night','The Big Football Final','NANOG 99','Burning Router Festival','Euro-Pop Song Contest','Formula Ping Grand Prix','The Big Game','Olympic Pings','A Pop Megastar Stadium Tour','LAN Party of the Century','The Keynote (One More Thing)','Gamer-Con Expo','Oktoberfest Livestream']},
|
||
sdwan:{l:tr('SD-WAN for a chain'),opts:[1,2,5,10],rate:0,l2:true,sdwan:true,km:0,lv:2,names:['Kebab Kingdom','Pretzel Palace','Burger Router Inc.','Café Latte-ncy','Hardware Hut Stores','Pharma-See Pharmacies','Bank of Tiny Branches','Supermarket Superhighway','Fitness Pings Gyms','Hotel Hops Group','Doughnut Data Diners']},
|
||
wwave:{l:tr('Wholesale wave'),opts:[1],rate:0,fiber:true,lv:2,names:['Zay-No Fiber','Loomin’ Technologies','Clown Castle Fiber','GTT (Got Tangled Twice)','A Hyperscaler Who Shall Not Be Named','Megapork','youNetworks']},
|
||
dfpair:{l:tr('Dark fiber pair lease'),opts:[1],rate:0,fiber:true,lv:3,names:['A Hyperscaler Who Shall Not Be Named','Goggle Fiber Division','Faceplant Infra','Amazin’ Backbone Team','A Very Secretive Trading Firm']},
|
||
scrub:{l:tr('DDoS protection + DIA'),opts:[1,5,10,20],rate:900},
|
||
aiwan:{l:tr('AI WAN between two AI factories'),opts:[3200,6400,12800],rate:0,l2:true,div:true,mega:true,km:0.45,lv:4,names:['Fairweather AI WAN','Planet-Scale Superfactory Link','Two Brains One Model Inc.','Distributed Godlike Compute','The Gigawatt Handshake']},
|
||
mtrain:{l:tr('Multi-site training run'),opts:[1600,3200,6400],rate:0,l2:true,sdwan:true,mega:true,lv:4,names:['Gem-in-Eye Ultra Training Run','Frontier Model 9000','The Very Big Model','Checkpoint-Free Training Co.','Model Too Big For One Building']},
|
||
ingest:{l:tr('Dataset ingest (elephant flow)'),opts:[1600,3200,6400],rate:0,event:true,mega:true,lv:3,names:['Scrape-the-Whole-Web Ingest','Checkpoint Sync Storm','Video Dataset Firehose','Every Book Ever (allegedly licensed)','Synthetic Data Tsunami']},
|
||
pairs:{l:tr('Hundreds of fiber pairs'),opts:[1],rate:0,fiber:true,mega:true,lv:4,names:['A Hyperscaler Who Shall Not Be Named','Planet-Scale AI WAN Team','The Fiber-Hungry Giant','Project Very Long Glass']},
|
||
esport:{l:tr('Esports world final'),opts:[400,800,1600,3200],rate:0,event:true,lv:5,names:['League of Lag Finals','Counter-Ping Major','Fortnightly World Cup','Dota Two Many Viewers','Rocket Leak Championship','Street Frighter Evo']},
|
||
sov:{l:tr('Sovereign cloud region'),opts:[400,800,1600],rate:0,l2:true,div:true,km:0.6,lv:6,names:['Gaia-Ex Sovereign Cloud','Bundeswolke (Very Secure)','Le Cloud Souverain','Datenschutz Deluxe','Your Data Stays Here, Probably','A Cloud With a Flag on It','Data Residency Is a State of Mind']},
|
||
cgame:{l:tr('Cloud gaming platform'),opts:[800,1600,3200],rate:45,lv:8,names:['Stadia-ium (Back Again)','GeForce Later','Ping Station Now','Luna-tick Gaming','Shadow of a Doubt Cloud PC','Input Lag Arcade','Bufferbloat Bros. Streaming']},
|
||
metav:{l:tr('Metaverse platform'),opts:[1600,3200,6400],rate:35,lv:9,names:['Meh-taverse','Second Second Life','Horizon Worlds Apart','The Oasis (Ready Player Done)','Legs Finally Shipped Inc.','Decentra-landlocked']},
|
||
agi:{l:tr('AGI lab (allegedly)'),opts:[12800,25600],rate:0,l2:true,div:true,mega:true,km:0.4,lv:11,names:['Almost General Intelligence Inc.','Superintelligence Pending','The Lab That Said Two More Years','Paperclip Maximizer Labs','Deep Thought Two','Benevolent Overlord Research']},
|
||
mars:{l:tr('Mars mission ground station'),opts:[100,200,400],rate:0,l2:true,lat:true,km:4,lv:13,names:['Red Planet Relay','Ares Ground Segment','Olympus Mons Uplink','Mars or Bust Mission Control','Interplanetary Ping Society','Light-Minute Logistics','RFC 1149 Avian Carriers (Mars Division)']},
|
||
provedor:{l:tr('Provedor (small regional ISP)'),opts:[5,10,20,40],rate:20,br:true,names:['Provedor Capivara Net','Fibra do Sertão','Rapidinho Telecom','Net Jabuticaba','Caipirinha Online','Wi-Fi do Zé','Pão de Queijo Fibra','Açaí Net','Tucano Telecom','Forró Fibra','Saci Net','Brigadeiro Banda Larga','Mandioca Online','Churrasco Connect']},
|
||
};
|
||
const LEVELS=[
|
||
{n:tr('Local ISP'),q:tr('Your network diagram is a photo of a whiteboard.'),req:tr('Start here'),unlock:tr('Enterprises, game servers, hosting, L2VPNs and DDoS protection.')},
|
||
{n:tr('Regional player'),q:tr('You now have a change freeze. Nobody remembers who declared it.'),req:tr('peak 200 Gbps and 3 POPs'),unlock:tr('Downstream ISPs, streaming startups and universities. Gear: Edge Lord 400 routers, dark fiber leases, Rainbow-in-a-Box DWDM, Ackackia 400ZR+ optics.')},
|
||
{n:tr('Serious backbone'),q:tr("It's not DNS. There's no way it's DNS. It was DNS."),req:tr('peak 1 Tbps and 6 POPs'),unlock:tr('AI GPU data centers and cloud on-ramps. Gear: Chonk 800 routers, Sizzle 800ZR+ optics, ROADMaster 9000 line systems, building your own fiber.')},
|
||
{n:tr('Big league'),q:tr('Your MTU is 9000 on every link except the one that matters.'),req:tr('peak 3 Tbps, 10 POPs, 3 continents'),unlock:tr('AI training interconnects and hyperscaler DCI deals in the terabits. Gear: Absolute Unit 1.6T routers, Sienna WaveMagic 1.6T transponders.')},
|
||
{n:tr('Continental carrier'),q:tr('Your NOC has a chat channel called #its-always-the-fiber, and it is always the fiber.'),req:tr('peak 6 Tbps, 15 POPs, 4 continents'),era:1.15,unlock:tr('Esports world finals, and the 4K-everything era: eyeballs in every city want 15% more. Gear: Sonic the Whitebox 64 routers.')},
|
||
{n:tr('Transcontinental'),q:tr('You joined the outages mailing list. Today you are the outage.'),req:tr('peak 9 Tbps and 20 POPs'),unlock:tr('Sovereign cloud regions, and a free PNI with Doitsche Telekomm. Gear: ROADMaster 9000 C+L (128 channels), Disco 8K Ultra routers.')},
|
||
{n:tr('Global backbone'),q:tr("Your ASN now shows up in other people's traceroutes, and in their tickets."),req:tr('peak 12 Tbps, 25 POPs, 5 continents'),unlock:tr('A free PNI with Voda-Phony. Gear: Absolute Unit 3.2T routers, 3.2T ports and 12.8T waves.')},
|
||
{n:tr('Packet empire'),q:tr('Your maintenance window is 2 a.m. in every time zone at once.'),req:tr('peak 16 Tbps and 32 POPs'),era:1.15,unlock:tr('Cloud gaming platforms, and the cloud gaming era: eyeballs want another 15%. A free PNI with Tel-Mess. Gear: Sienna WaveMagic 3.2T transponders.')},
|
||
{n:tr('Six-continent carrier'),q:tr('Somewhere, on every continent, a backhoe is thinking about you.'),req:tr('peak 21 Tbps, 40 POPs, 6 continents'),unlock:tr('Metaverse platforms (it finally took off), and a free PNI with Etis-a-lot. Gear: Arrrhipster 7800R5 routers, 102.4T fabrics for your own exchange.')},
|
||
{n:tr('Backbone of backbones'),q:tr('Your routing table needs its own routing table.'),req:tr('peak 26 Tbps and 50 POPs'),era:1.2,unlock:tr('The VR era: eyeballs want 20% more. A free PNI with China Moble. Gear: Knockia 7950 XRS routers, 100T scrubbing.')},
|
||
{n:tr('Internet weather system'),q:tr('When your BGP sneezes, a small country catches a cold.'),req:tr('peak 33 Tbps and 60 POPs'),unlock:tr('AGI labs (allegedly) wanting AI WANs of 12.8 to 25.6 Tbps, and free PNIs with Du-opoly and Ooh-redoo. Gear: Mikrowtik CCR 3.2T routers.')},
|
||
{n:tr('Too big to route'),q:tr('Your last fat-fingered route leak has its own Wikipedia page.'),req:tr('peak 40 Tbps and 70 POPs'),era:1.25,unlock:tr('The AI agent era: eyeballs want 25% more, because bots now browse the web for people and they never sleep. Gear: eight fiber pairs in your own land trenches.')},
|
||
{n:tr('The Internet'),q:tr('People phone you to ask if the internet is down. You are the internet. Have you tried turning yourself off and on again?'),req:tr('peak 50 Tbps and 80 POPs'),unlock:tr('Mars mission ground stations. Gear: The Router at the End of the Universe.')},
|
||
];
|
||
// What each level asks for (peak Gbps, POPs, continents). Continents carry over to the levels above.
|
||
const LV_REQ=[null,{pk:200,pops:3},{pk:1000,pops:6},{pk:3000,pops:10,reg:3},{pk:6000,pops:15,reg:4},{pk:9000,pops:20},{pk:12000,pops:25,reg:5},{pk:16000,pops:32},{pk:21000,pops:40,reg:6},{pk:26000,pops:50},{pk:33000,pops:60},{pk:40000,pops:70},{pk:50000,pops:80}];
|
||
const lvReg=i=>Math.max(0,...LV_REQ.slice(1,i+1).map(q=>q.reg||0));
|
||
const lvl=()=>(S&&S.lvl)||1;
|
||
// Lower-case just the first word for mid-sentence use, so names like Tel-Mess or AGI keep their capitals.
|
||
const lc1=t=>/^[A-Z][a-z]/.test(t)?t[0].toLowerCase()+t.slice(1):t;
|
||
function custLevel(){const pops=Object.keys(S.pops).length,pk=S.stats.peak,rc=regionsCount();let lv=1;for(let i=1;i<LV_REQ.length;i++){const q=LV_REQ[i];if(pk>=q.pk&&pops>=q.pops&&rc>=lvReg(i))lv=i+1;else break;}return lv;}
|
||
// Traffic eras: some levels bring a new reason to watch more video, and every city's eyeballs grow toward more.
|
||
const eraMul=()=>LEVELS.slice(0,lvl()).reduce((a,L)=>a*(L.era||1),1);
|
||
const eyeP=c=>CITY[c].P*eraMul();
|
||
const BIZ_N=['Byte-Size Bakery','Hamster Wheel Power Co.','Llama Logistics','Cloud Nine Hosting','Rural Rabbit Broadband','Tiny Telco','Pixel Pirates Games','Moo-Moo Dairy Corp','Snack Overflow','Git Happens Ltd','Kernel Sanders Fried Code','Lag-Free Llamas','404 Bistro','Ping Pong Sports','Null Pointer Pets','Buffer Bloat Boats','Packet Pizza','Latency Lattes','Ctrl-Alt-Deli','Sudo Sandwiches','Cache Me Outside','Hertz So Good Radio','Jitterbug Dance Hall','Bit Barn Hosting','Fiber Optimists','The Daily Ping','Squirrel Mesh Wireless','Spam & Eggs Diner','Router Rooter Plumbing','Kilobyte Kebab','Gigglebit Studios','Uptime Funk Records','Ohm Sweet Ohm','Dial-Up Nostalgia Club','Two-Factor Tacos'];
|
||
|
||
/* ================= GOALS ================= */
|
||
const GOALS=[
|
||
{id:'bb',t:tr('Light up your first customers'),d:tr('Open your home city and press “Launch broadband”. Eyeballs are people at home watching cat videos. They pay you every month.'),r:5000,ok:()=>Object.values(S.pops).some(p=>p.bb)},
|
||
{id:'tr',t:tr('Reach the whole internet'),d:tr('Your eyeballs want everything. Buy IP transit from a Tier 1 or Tier 2 in your city. Transit gives you the full routing table.'),r:5000,ok:()=>S.transit.length>0},
|
||
{id:'ix',t:tr('Join an Internet Exchange'),d:tr('Get a port at an IX: a big shared switch where networks swap traffic for free instead of paying transit.'),r:7500,ok:()=>Object.keys(S.ixp).length>0},
|
||
{id:'p5',t:tr('Make 5 peering friends'),d:tr('On the Peering tab, request sessions, or join the route server to peer with every open network at once.'),r:10000,ok:()=>R.sessions>=5},
|
||
{id:'ln',t:tr('Lay your first fiber'),d:tr('Drag from your pink router to another city. Short hops are cheap. Oceans are not.'),r:10000,ok:()=>S.links.length>0},
|
||
{id:'bz',t:tr('Sign a business customer'),d:tr('Businesses show up with a $ bubble. You need a POP in their city. Check the Deals tab.'),r:12500,ok:()=>S.biz.some(b=>!b.scripted)},
|
||
{id:'rd',t:tr('Survive a failure'),d:tr('Things break all the time. Build a second path or a second upstream so traffic reroutes when something dies.'),r:12500,ok:()=>S.stats.survived>0},
|
||
{id:'ca',t:tr('Host an embedded cache'),d:tr('Big CDNs give you free cache boxes once you send them enough traffic. Free bandwidth, just add power.'),r:12500,ok:()=>S.caches.length>0},
|
||
{id:'pn',t:tr('Set up a PNI'),d:tr('A private cross-connect to one network in the same data center, for when traffic outgrows the IX.'),r:15000,ok:()=>S.pni.length>0},
|
||
{id:'scrub',t:tr('Stand up DDoS defences'),d:tr('Build a scrubbing center from a POP\'s Infra tab. It cleans attacks up to its capacity and lets you sell DDoS protection.'),r:20000,ok:()=>!!S.scrubAt},
|
||
{id:'c3',t:tr('Go global'),d:tr('Have POPs on 3 continents. Subsea cables cost a fortune, so plan the route.'),r:50000,ok:()=>regionsCount()>=3},
|
||
{id:'t2',t:tr('Become a Tier 2'),d:tr('5+ POPs, ports on 3+ IXs and 15+ peering sessions.'),r:50000,ok:()=>isTier2()},
|
||
{id:'tb',t:tr('Serve 1 Tbps'),d:tr('A terabit per second of happy traffic.'),r:75000,ok:()=>R.served>=1000},
|
||
{id:'df',t:tr('Light your own dark fiber'),d:tr('Lease or dig dark fiber, put a DWDM system on it and light a channel. Cheaper per bit than waves, once it works.'),r:40000,ok:()=>S.links.some(l=>l.kind==='df'&&dfCap(l)>0)},
|
||
{id:'m2',t:tr('Be in two buildings at once'),d:tr('Add a second site in a metro from the Infra tab, so one power cut no longer takes the whole city dark.'),r:30000,ok:()=>Object.values(S.pops).some(p=>p.site2)},
|
||
{id:'c5',t:tr('Five continents'),d:tr('POPs in five of the six regions on the map.'),r:100000,ok:()=>regionsCount()>=5},
|
||
{id:'gi',t:tr('Sign a giant'),d:tr('Land an AI WAN, a multi-site training run or a fiber-pairs deal with a hyperscaler. Customer level 4 and a POP near their campus required.'),r:150000,ok:()=>S.biz.some(b=>BIZ_T[b.type]&&BIZ_T[b.type].mega&&!BIZ_T[b.type].event)},
|
||
{id:'t10',t:tr('Serve 10 Tbps'),d:tr('Ten terabits per second of happy traffic. The giants will notice.'),r:250000,ok:()=>R.served>=10000},
|
||
{id:'t1',t:tr('Go transit-free: Tier 1!'),d:tr('Peer with every Tier 1 over PNIs and cancel every transit port. Then nobody charges you to reach the internet.'),r:0,win:true,ok:()=>isTier1()},
|
||
];
|
||
|
||
/* ================= STATE ================= */
|
||
let S=null, R=emptyR();
|
||
const UI={sel:null,tab:'cust',left:'goals',speed:1,hover:null,drag:null,snap:null,pending:null,confirm:null,leftOpen:false,muted:false,startCity:'fra',hintOff:false};
|
||
let uidN=1; const uid=()=>'i'+(Date.now()%1e7).toString(36)+(uidN++);
|
||
function emptyR(){return {teBlack:0,tNet:{},egT:{},netEg:{},l2lat:{},nodeLoad:{},nodeCap:{},div:{},l2:{},gfwLost:0,gfwCross:0,ef:{},egDesc:{},p95:{},peered:0,peerShare:0,load:{},useT:{},useIx:{},usePni:{},useCache:{},cityDem:{},citySrv:{},cityEye:{},demTo:{},served:0,demand:0,reach:0,sessions:0,revMo:0,costMo:0,cost:{},rev:{},reachable:{}};}
|
||
/* ================= BANKS & LOANS =================
|
||
Lenders make offers now and then (more often when you are broke). Each loan
|
||
is a fixed monthly payment that shows up in your costs; conditions are checked
|
||
daily and breaking one costs a penalty. */
|
||
const BANKS={
|
||
gs:{name:'Goldman Sacks',col:'#6F8FAF',min:'AA',apr:[.07,.11],amt:[4,9],term:[24,48],covs:['peer30','continents2','golf','yacht'],blurb:tr('Only lends to people who do not need it.')},
|
||
db:{name:'Deutsche Bankrupt',col:'#0018A8',min:'A',apr:[.08,.13],amt:[3,7],term:[18,36],covs:['nocog','gen','fax'],blurb:tr('Very solid. Mostly.')},
|
||
jpm:{name:'JP Morgain',col:'#5B4636',min:'A',apr:[.09,.14],amt:[3,6],term:[12,36],covs:['uptime','logo','nephew'],blurb:tr('Lends you money and also a little bit of their own.')},
|
||
cs:{name:'Credit Sweaty',col:'#7A9CC6',min:'BBB',apr:[.11,.17],amt:[2,5],term:[12,30],covs:['cash50','nochina'],blurb:tr('Nervous, but enthusiastic.')},
|
||
wf:{name:'Wells Far-Gone',col:'#D71E28',min:'BB',apr:[.12,.18],amt:[2,4],term:[12,24],covs:['nosub','logo','reach99'],blurb:tr('Opened three accounts for you while you read this.')},
|
||
spk:{name:'Spätzle-Sparkasse',col:'#E30613',min:'B',apr:[.05,.08],amt:[1,3],term:[24,60],covs:['spaetzle','kehrwoche'],blurb:tr('Cheap, patient, and very particular about Stuttgart.')},
|
||
rev:{name:'Revoloot',col:'#191C1F',min:'B',apr:[.13,.2],amt:[1,3],term:[6,18],covs:['app'],blurb:tr('Instant approval. Instant regret.')},
|
||
gov:{name:'Ministry of Tubes',col:'#2E7D32',min:'CCC',apr:[.01,.02],amt:[1,2],term:[36,60],covs:['rural','forms'],blurb:tr('Cheap state money for connecting the underserved. Bring a pen.')},
|
||
crypto:{name:'Crypto Bros Capital',col:'#F7931A',min:'CCC',apr:[.15,.25],amt:[2,6],term:[6,18],covs:['hodl','tier3'],crypto:true,blurb:tr('Pays out in TubeCoin. Value may vary. A lot.')},
|
||
vult:{name:'Venture Vultures',col:'#8E44AD',min:'CCC',amt:[6,12],share:[.1,.15],covs:['blitz'],equity:true,blurb:tr('No repayments, ever. Just a slice of your revenue, forever, and a lot of opinions.')},
|
||
balloon:{name:'Ballooney Brothers',col:'#E91E63',min:'B',apr:[.1,.15],amt:[2,6],term:[12,24],covs:['oddpops'],model:'balloon',blurb:tr('No payments at all! Until the very end. Then all of them, at once.')},
|
||
storm:{name:'Stormy Weather Lending',col:'#546E7A',min:'BB',apr:[.04,.06],amt:[2,5],term:[12,36],covs:['nogen'],model:'storm',blurb:tr('Cheap while the sun shines. Every open incident adds 2% to your rate.')},
|
||
ppp:{name:'Peer Pressure Partners',col:'#00897B',min:'B',amt:[2,5],term:[24,36],covs:['nocache'],model:'transit',blurb:tr('You repay with 30% of your transit bill. Go transit-free and you stop paying. Until the end.')},
|
||
astro:{name:'Horoscope Holdings',col:'#5E35B1',min:'CCC',apr:[.02,.3],amt:[1,4],term:[12,24],covs:['friday','nobude'],model:'astro',blurb:tr('Your rate is set by the stars every month. Mercury is in retrograde a lot.')},
|
||
pizza:{name:'Papa Pizza Capital',col:'#FF7043',min:'BB',apr:[.03,.05],amt:[1,3],term:[12,24],covs:['pizza'],blurb:tr('The cheapest money in town. There is a catch, and it has extra cheese.')},
|
||
shark:{name:'Loan Shark Telecom Finance',col:'#37474F',min:'C',apr:[.6,.9],amt:[1,2],term:[4,8],covs:[],shark:true,blurb:tr('Always open. Ask no questions. Do not be late.')},
|
||
};
|
||
const RATINGS=['C','CCC','B','BB','BBB','A','AA','AAA'];
|
||
const COVS={
|
||
peer30:{l:tr('Keep your peering ratio above 30%. The bank read a blog post about peering.'),ok:()=>(R.peerShare||0)>=0.3},
|
||
continents2:{l:tr('Keep POPs on at least 2 continents. Diversification!'),ok:()=>regionsCount()>=2},
|
||
golf:{l:tr('Your CEO plays golf with our CEO every Thursday.'),ok:()=>true},
|
||
nocog:{l:tr('No Cogentle transit anywhere. Our CEO got de-peered once and has not recovered.'),ok:()=>!S.transit.some(t=>t.net==='cog')},
|
||
gen:{l:tr('Every POP needs a backup generator. Our risk team saw one disaster movie.'),ok:()=>Object.values(S.pops).every(p=>p.gen)},
|
||
fax:{l:tr('Send us your monthly report by fax.'),ok:()=>true},
|
||
uptime:{l:tr('Deliver at least 95% of what your customers want.'),ok:()=>!R.demand||R.served/R.demand>=0.95},
|
||
logo:{l:tr('Our logo goes on every router you own.'),ok:()=>true},
|
||
cash50:{l:tr('Never let cash drop below $50k. It makes us sweat.'),ok:()=>S.cash>=50000},
|
||
nochina:{l:tr('Stay out of mainland China. Compliance said so.'),ok:()=>!Object.keys(S.pops).some(cnCity)},
|
||
nosub:{l:tr('No new subsea links while this loan runs. We are afraid of sharks.'),ok:l=>S.links.filter(x=>x.sub).length<=(l.base&&l.base.sub||0)},
|
||
spaetzle:{l:tr('Peer at the Spätzle-IX in Stuttgart. Local money for local packets.'),ok:()=>S.ixp.stg!==undefined},
|
||
kehrwoche:{l:tr('Do the Kehrwoche: keep your NOC free of incidents older than a week.'),ok:()=>!S.inc.some(i=>S.day-i.start>7)},
|
||
app:{l:tr('Download our app and enable all notifications.'),ok:()=>true},
|
||
rural:{l:tr('Run home broadband somewhere underserved (Asia, Africa, Oceania or South America).'),ok:()=>Object.keys(S.pops).some(c=>S.pops[c].bb&&['AS','AF','OC','SA'].includes(CITY[c].reg))},
|
||
forms:{l:tr('Fill in form T-17b in triplicate, every month, forever.'),ok:()=>true},
|
||
hodl:{l:tr('Never sell your TubeCoin. Diamond hands.'),ok:()=>true},
|
||
oddpops:{l:tr('Always run an odd number of POPs. Our numerologist insists.'),ok:()=>Object.keys(S.pops).length%2===1},
|
||
nobude:{l:tr('Never build in Bude. The loan officer had a bad surfing holiday there.'),ok:()=>!S.pops.bde},
|
||
nogen:{l:tr('No diesel generators anywhere. Our sustainability team is watching.'),ok:()=>!Object.values(S.pops).some(p=>p.gen)},
|
||
friday:{l:tr('No new links on a Friday. The stars do not allow it.'),ok:l=>!S.links.some(x=>(x.day||0)>=l.start&&(x.day||0)%7===4)},
|
||
nocache:{l:tr('No Goggle cache boxes. Our chairman lost an argument with a search engine.'),ok:()=>!S.caches.some(c=>c.net==='ggl')},
|
||
reach99:{l:tr('Reach 99% of the internet at all times. We looked up what a network is for.'),ok:()=>(R.reach||0)>=0.99},
|
||
tier3:{l:tr('Stay Tier 3. Number go up, rank stay down.'),ok:()=>tierLabel()==='Tier 3'},
|
||
nephew:{l:tr('Give our CEO’s nephew a job. He needs {price}/mo and a parking spot.'),fee:3000,ok:()=>true},
|
||
yacht:{l:tr('Our chairman needs a yacht for the summer. You don’t own one, so you rent one: {price}/mo.'),fee:8000,ok:()=>true},
|
||
pizza:{l:tr('Pizza for the whole NOC after every incident: {price} each.'),each:400,ok:()=>true},
|
||
blitz:{l:tr('Open a new POP at least every 90 days. Blitzscale or die.'),ok:l=>S.day-Math.max(l.start,...Object.values(S.pops).map(p=>p.day||0))<=90},
|
||
};
|
||
// Conditions read with their price filled in; some cost money every month, one costs money per incident.
|
||
const covLabel=c=>COVS[c]?COVS[c].l.replace('{price}',fmt$(COVS[c].fee||COVS[c].each||0)):c;
|
||
const loanFees=l=>(l.covs||[]).reduce((a,c)=>a+((COVS[c]&&COVS[c].fee)||0),0);
|
||
// Good terms are for good credit: every notch below AAA adds to the rate.
|
||
const RATE_PREM={AAA:0,AA:.005,A:.01,BBB:.02,BB:.04,B:.07,CCC:.12,C:.2};
|
||
// A loan worth more than this many months of revenue also wants a slice of revenue until it is repaid.
|
||
const BIG_LOAN=5;
|
||
const STAR_SIGNS=[N_('Mercury'),N_('Saturn'),N_('Venus'),N_('Your rising sign'),N_('The moon'),N_('Pluto, which is not even a planet')];
|
||
function niceAmt(v){const m=Math.pow(10,Math.floor(Math.log10(Math.max(1,v)))-1);return Math.max(50000,Math.round(v/m)*m);}
|
||
function rating(){if(!S)return 'BB';const rev=R.revMo||0,pay=(R.cost&&R.cost.loans)||0;let sc=2;
|
||
if(rev>100000)sc++;if(rev>500000)sc++;if(rev>2000000)sc++;if(R.revMo>R.costMo)sc++;else sc--;if(rev&&(R.revMo-R.costMo)/rev>=0.25)sc++;
|
||
if(S.cash<0)sc-=2;if(rev&&pay/rev>0.3)sc--;if(rev&&pay/rev>0.6)sc--;sc-=Math.min(3,S.loanStrikes||0);
|
||
return RATINGS[clamp(sc,0,RATINGS.length-1)];}
|
||
const rIdx=r=>RATINGS.indexOf(r);
|
||
function annuity(P,apr,n){const r=apr/12;return r?P*r/(1-Math.pow(1+r,-n)):P/n;}
|
||
function spawnLoanOffer(emergency){
|
||
const rt=rating(),keys=Object.keys(BANKS).filter(k=>rIdx(rt)>=rIdx(BANKS[k].min)&&!S.loanOffers.some(o=>o.bank===k)&&!(BANKS[k].equity&&S.loans.some(l=>l.bank===k)));
|
||
let pool=emergency?keys.filter(k=>['shark','gov','crypto','vult','rev','spk','astro','balloon'].includes(k)):keys.filter(k=>k!=='shark');if(!pool.length)pool=keys;if(!pool.length)return;
|
||
const k=pick(pool),B=BANKS[k],base=Math.max(60000,R.revMo||0),ra=(a)=>a[0]+Math.random()*(a[1]-a[0]);
|
||
const amount=niceAmt(base*ra(B.amt)*(emergency?0.6:1)),o={id:uid(),bank:k,amount,exp:S.day+(emergency?10:25),covs:B.covs.slice()};
|
||
if(B.equity){o.share=+ra(B.share).toFixed(3);}
|
||
else if(B.model==='transit'){o.model='transit';o.cut=0.3;o.term=Math.round(ra(B.term)/6)*6||6;o.owe=Math.round(amount*1.3);o.apr=0;o.pay=0;}
|
||
else{o.apr=+(ra(B.apr)+(RATE_PREM[rt]||0)).toFixed(3);o.term=Math.round(ra(B.term)/6)*6||6;o.pay=B.model==='balloon'?0:Math.round(annuity(amount,o.apr,o.term));if(B.model)o.model=B.model;}
|
||
if(!B.equity&&amount>BIG_LOAN*base)o.share=+Math.min(0.08,0.02+0.01*(amount/base-BIG_LOAN)).toFixed(3);
|
||
S.loanOffers.push(o);
|
||
toast(tr('<b>{bank} would like to lend you {amount}.</b>',{bank:esc(B.name),amount:fmt$(amount)})+'<br>'+(emergency?tr('They heard you might be in a spot of bother.'):tr('Terms apply. Several terms.')),emergency?'bad':'goal',[{l:tr('Open bank'),act:'bank',args:{}}]);
|
||
}
|
||
function loanTick(d){
|
||
// conditions: 15-day grace, then a penalty every 30 days while broken
|
||
for(const l of S.loans){const B=BANKS[l.bank];
|
||
const broken=l.covs.filter(c=>COVS[c]&&!COVS[c].ok(l));
|
||
if(d-l.start<15||!broken.length){l.breach=0;continue;}
|
||
l.breach=(l.breach||0)+1;
|
||
if(l.breach===1)toast(tr('<b>{bank} is unhappy.</b><br>You broke a loan condition: {cond} Fix it within 10 days or pay a penalty.',{bank:esc(B.name),cond:esc(covLabel(broken[0]))}),'bad',[{l:tr('Open bank'),act:'bank',args:{}}]);
|
||
if(l.breach===10||(l.breach>10&&(l.breach-10)%30===0)){
|
||
if(B.equity){l.share=+(l.share+0.02).toFixed(3);toast(tr('<b>{bank} are circling.</b><br>They now take {pct} of your revenue.',{bank:esc(B.name),pct:pct(l.share)}),'bad');}
|
||
else{const fee=Math.round(l.bal*0.05);l.bal+=fee;l.pay=Math.round(annuity(l.bal,l.apr,Math.max(1,l.left)));S.loanStrikes=(S.loanStrikes||0)+1;toast(tr('<b>Penalty from {bank}: {fee}</b><br>Added to what you owe. Your monthly payment is now {pay}.',{bank:esc(B.name),fee:fmt$(fee),pay:fmt$(l.pay)}),'bad');}
|
||
sfx('err');}}
|
||
// monthly statement: payments already leave your cash daily as part of costs
|
||
for(const l of S.loans.slice()){const B0=BANKS[l.bank];if(B0.equity||(d-l.start)%30!==0||d===l.start)continue;
|
||
if(l.model==='transit')l.bal=Math.max(0,l.bal-Math.round(((R.cost&&R.cost.transit)||0)*(l.cut||0.3)));else l.bal=Math.max(0,l.bal*(1+l.apr/12)-l.pay);l.left--;
|
||
// A balloon, or what a transit-free network never paid, is due in one go at the end.
|
||
if(l.left<=0&&l.bal>=1&&(l.model==='balloon'||l.model==='transit')){S.cash-=Math.round(l.bal);toast(tr('<b>{bank}: the balloon popped.</b><br>The remaining {price} was due today, all at once. It has left your account.',{bank:esc(B0.name),price:fmt$(l.bal)}),'bad');sfx('err');l.bal=0;}
|
||
if(l.left>0&&l.bal>=1){if(l.model==='storm'){l.apr=+((l.apr0||0)+0.02*S.inc.length).toFixed(3);l.pay=Math.round(annuity(l.bal,l.apr,l.left));}
|
||
else if(l.model==='astro'){const a=+(0.02+Math.random()*0.28).toFixed(3);if(Math.abs(a-l.apr)>=0.08)toast(tr('<b>{bank}: {sign} is in retrograde.</b><br>Your rate is now {apr}%.',{bank:esc(B0.name),sign:tr(pick(STAR_SIGNS)),apr:(a*100).toFixed(1)}),a>l.apr?'bad':'good');l.apr=a;l.pay=Math.round(annuity(l.bal,l.apr,l.left));}}
|
||
if(l.left<=0||l.bal<1){S.loans=S.loans.filter(x=>x!==l);track('loan_repaid');toast(tr('<b>Loan from {bank} paid off!</b><br>They sent a fruit basket. It is mostly bananas.',{bank:esc(BANKS[l.bank].name)}),'good');sfx('coin');}}
|
||
// the shark's collectors come by when you are broke
|
||
if(S.cash<0&&S.loans.some(l=>BANKS[l.bank].shark)&&Math.random()<0.03){const c=pick(Object.keys(S.pops));const p=S.pops[c];p.down=Math.max(p.down||0,d+1);const en=N_('Two very large gentlemen from Loan Shark Telecom Finance unplugged your router in {city} "as a reminder".');addInc({type:'shutdown',ref:c,until:d+1,msg:tr(en,{city:CITY[c].name}),cost:0},en);toast(tr('<b>The loan shark sent a reminder.</b><br>Your POP in {city} is dark until tomorrow.',{city:CITY[c].name}),'bad');sfx('alert');}
|
||
// offers: now and then, and much more often when you are in trouble
|
||
S.loanOffers=S.loanOffers.filter(o=>o.exp>d);
|
||
const broke=S.cash<0;
|
||
// With half a billion in the vault, loan offers are just noise (#52): banks stop calling, open offers lapse.
|
||
if(S.cash>=RICH_NO_LOANS){if(S.loanOffers.length||!S.richTold){S.loanOffers=[];if(!S.richTold&&S.mode!=='sandbox'){S.richTold=1;toast(tr('<b>The banks have stopped calling.</b><br>You have more money than most of them. Loan offers come back if your cash ever drops below {cash}.',{cash:fmt$(RICH_NO_LOANS)}),'good');}}return;}
|
||
if(S.loanOffers.length<4&&(broke?Math.random()<0.25:(d>20&&Math.random()<1/40)))spawnLoanOffer(broke);
|
||
}
|
||
const RICH_NO_LOANS=5e8;
|
||
/* Seeded games (scenarios, weekly challenge) draw every random number from S.rng, so the same seed
|
||
gives the same world. Free play keeps using the browser's Math.random. */
|
||
const _rand=Math.random;
|
||
Math.random=function(){if(S&&typeof S.rng==='number'){let t=(S.rng=(S.rng+0x6D2B79F5)|0);t=Math.imul(t^t>>>15,1|t);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;}return _rand();};
|
||
function isoWeek(dt){const d=new Date(Date.UTC(dt.getFullYear(),dt.getMonth(),dt.getDate()));const n=d.getUTCDay()||7;d.setUTCDate(d.getUTCDate()+4-n);const y0=new Date(Date.UTC(d.getUTCFullYear(),0,1));return {y:d.getUTCFullYear(),w:Math.ceil(((d-y0)/864e5+1)/7)};}
|
||
function pathExists(a,b){if(!S.pops[a]||!S.pops[b])return false;const adj={};for(const l of S.links){if(linkDown(l))continue;(adj[l.a]=adj[l.a]||[]).push(l.b);(adj[l.b]=adj[l.b]||[]).push(l.a);}const seen=new Set([a]),q=[a];while(q.length){const u=q.shift();if(u===b)return true;for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return false;}
|
||
// Looked up rather than read from the save, so it follows a language switch mid-scenario.
|
||
const scnName=()=>S.scn.id==='weekly'?tr('Weekly {key}',{key:S.scn.key}):SCN.find(x=>x.id===S.scn.id)?.n||S.scn.name;
|
||
const SCN=[
|
||
{id:'stg',n:tr('Only Spätzle-IX'),city:'stg',cash:400000,days:730,rules:{noTransit:true},d:tr('Start in Stuttgart, where nobody sells transit. Reach the internet through peering, PNIs, caches and your own fiber only. No transit anywhere, ever.'),goal:tr('Serve 200 Gbps'),ok:()=>R.served>=200},
|
||
{id:'redsea',n:tr('Red Sea Crisis'),city:'mrs',cash:2500000,days:540,rules:{banCities:['cai','jed'],banPairs:['eig:dxb-mrs','gbi:fuj-mrs','smw4:khi-mrs','smw6:mrs-bom','smw6:mrs-sin','peace:mrs-sin','aae:mrs-hkg','twoaf:mrs-bom','medn:cai-mrs','medn:ist-mrs','twoaf:jnb-mrs','eassy:nbo-mrs']},d:tr('Every cable through the Red Sea is cut, and so is the hop to Egypt. Get Marseille talking to Singapore anyway: round Africa, overland, or the other way round the planet.'),goal:tr('A path from Marseille to Singapore, and 300 Gbps served'),ok:()=>pathExists('mrs','sin')&&R.served>=300},
|
||
{id:'spat',n:tr('The Cogentle Spat'),city:'nyc',cash:700000,days:540,rules:{spat:true},d:tr('Cogentle and Goggle are not speaking, and this time it is permanent. Buy the cheap transit if you dare.'),goal:tr('99% reach and 150 Gbps served'),ok:()=>R.reach>=0.99&&R.served>=150},
|
||
{id:'carnaval',n:tr('Carnaval'),city:'rio',cash:600000,days:100,rules:{},setup:()=>{S.biz.push({id:uid(),scripted:true,city:'rio',city2:null,reqs:[],name:'Carnaval Parade in Rio de Janeiro',type:'event',bw:400,rate:0,mood:100,since:0,start:90,dur:5,fee:400*5*70});},d:tr('Rio from scratch. Carnaval starts in 90 days and wants 400 Gbps for five days straight. The whole world is watching.'),goal:tr('Deliver Carnaval in full'),ok:()=>(S.stats.evFull||0)>=1},
|
||
{id:'darien',n:tr('Mind the Gap'),city:'pan',cash:900000,days:730,rules:{},d:tr('Start in Panama City. Nothing crosses the Darién Gap by land, and the Andes are in the way of everything else.'),goal:tr('POPs in Bogotá, Lima, Santiago and São Paulo, and 150 Gbps served'),ok:()=>['bog','lim','scl','sao'].every(c=>S.pops[c])&&R.served>=150},
|
||
{id:'gangnam',n:tr('Gangnam Style Peering'),city:'icn',cash:900000,days:365,rules:{},d:tr('Seoul. The fastest, hungriest eyeballs on Earth, transit at four times the price, and three incumbents who bill you for every gigabit you send them.'),goal:tr('99% reach and 200 Gbps served without going broke'),ok:()=>R.reach>=0.99&&R.served>=200},
|
||
{id:'flood',n:tr('Flood Season'),city:'ams',cash:2000000,days:365,rules:{ddos:true},setup:()=>{S.lvl=Math.max(S.lvl||1,3);},d:tr('Amsterdam, hosting capital of Europe, in peak botnet season. Every smart toaster, baby monitor and unpatched fridge on Earth has picked a side, and it is not yours. A flood every few days, more and more of them in the terabits, while everything else keeps breaking too. You start with bigger gear unlocked, and you will need it.'),goal:tr('Hold 20 floods, 5 of them over 1 Tbps, keeping the city under attack at 97% or better'),ok:()=>(S.stats.ddosOk||0)>=20&&(S.stats.ddosOkBig||0)>=5},
|
||
{id:'baltic',n:tr('Anchors Away'),city:'tll',cash:500000,days:540,rules:{anchors:3},d:tr('Tallinn. Ships drag their anchors over Baltic cables three times as often as usual.'),goal:tr('90 days in a row with 99.5% of demand served'),ok:()=>(S.stats.clean||0)>=90},
|
||
];
|
||
const WEEK_CITIES=['fra','ams','lon','nyc','ash','sjc','sin','tok','syd','sao','jnb','bom','waw','ist','scl','hkg'];
|
||
const WEEK_MODS=[{id:'pricey',n:tr('Transit costs 30% more')},{id:'chaos',n:tr('Twice the failures')},{id:'poor',n:tr('Start with only $100k')},{id:'boom',n:tr('Eyeballs grow 50% faster')},{id:'dk',n:tr('Every IX is run by DE-KICKS')},{id:'sharks',n:tr('Shark season: subsea cuts twice as likely')}];
|
||
function weekly(){const {y,w}=isoWeek(new Date());let r=(y*100+w)*2654435761>>>0;const nx=()=>{r=(r*1103515245+12345)>>>0;return r/4294967296;};const city=WEEK_CITIES[Math.floor(nx()*WEEK_CITIES.length)];const mods=[];while(mods.length<2){const m=WEEK_MODS[Math.floor(nx()*WEEK_MODS.length)];if(!mods.includes(m))mods.push(m);}return {id:'weekly',key:`${y}-W${String(w).padStart(2,'0')}`,seed:y*100+w,city,mods,days:365};}
|
||
const scnRule=k=>!!(S&&S.scn&&S.scn.rules&&S.scn.rules[k]);
|
||
function scnHof(){try{return JSON.parse(localStorage.getItem('sot-scn')||'{}')||{};}catch(e){return {};}}
|
||
function beginGame(nm,city,o={}){if(needPitch()&&!UI.pitched){UI.pendGame=[nm,city,o];openModal(pitchHtml(true));return;}newGame(nm,city);S.mode=o.mode||'normal';
|
||
if(S.mode==='sandbox'){S.cash=1e9;S.lvl=LEVELS.length;S.nextFail=1e9;S.nextEvent=1e9;}
|
||
if(o.scn){const sc=o.scn;S.scn={id:sc.id,rules:sc.rules||{},days:sc.days,name:sc.n||tr('Weekly challenge {key}',{key:sc.key}),key:sc.key||null,mods:(sc.mods||[]).map(m=>m.id)};S.rng=(o.seed||hstr(sc.id))|0;S.mode='scenario';S.asn=200000+Math.floor(Math.random()*15000);
|
||
if(sc.cash)S.cash=sc.cash;if(sc.setup)sc.setup();
|
||
for(const m of S.scn.mods){if(m==='pricey')S.priceMul=1.3;if(m==='poor')S.cash=100000;if(m==='chaos')S.scn.rules.chaos=true;if(m==='boom')S.scn.rules.boom=true;if(m==='dk')S.scn.rules.dkAll=true;if(m==='sharks')S.scn.rules.sharks=true;}}
|
||
track('game_new');UI.started=true;closeModal();compute();cam.x=CITY[city].x;cam.y=CITY[city].y;cam.z=innerWidth<760?1.1:1.4;selectCity(city);
|
||
toast(S.scn?`<b>${esc(S.scn.name)}</b><br>${esc(o.scn.goal||tr('Serve as much traffic as you can in one year.'))} ${tr('You have {n} days.',{n:S.scn.days})}`:S.mode==='sandbox'?tr('<b>Sandbox mode</b><br>A billion dollars, every unlock, and nothing ever breaks. Build the internet you always wanted.'):tr('<b>Welcome, {name}!</b><br>The RIPE NCC assigned you AS{asn}. Your first router is humming in {city}.',{name:esc(nm),asn:S.asn,city:CITY[city].name}),'goal');
|
||
renderAll();save();if(!S.scn&&S.mode!=='sandbox')tutorialStart();}
|
||
/* ---------- conference season ---------- */
|
||
const CONFS=[{n:'NANOG',c:'chi',m:1},{n:'APRICOT',c:'sin',m:1},{n:'Peering Days',c:'waw',m:2},{n:'DKNOG',c:'cph',m:2,j:N_('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.')},{n:'UKNOF',c:'lon',m:3},{n:'MENOG',c:'dxb',m:3},{n:'NZNOG',c:'akl',m:3},{n:'RIPE',c:'ams',m:4},{n:'NANOG',c:'sea',m:5},{n:'IX Forum',c:'tok',m:6},{n:'AfPIF',c:'nbo',m:7},{n:'AusNOG',c:'syd',m:8},{n:'NLNOG Day',c:'ams',m:8},{n:'LACNOG',c:'sao',m:9},{n:'NANOG',c:'ash',m:9},{n:'DENOG',c:'fra',m:10},{n:'RIPE',c:'ber',m:10},{n:'PTT Forum',c:'sao',m:11}];
|
||
const CONF_COST=8000,CONF_DAYS=45;
|
||
const confDay=(cf,y)=>y*360+cf.m*30+9;
|
||
function confKey(cf,y){return cf.n+'@'+cf.c+'@'+y;}
|
||
function upcomingConfs(within){const y0=Math.floor(S.day/360),out=[];for(const y of [y0,y0+1])for(const cf of CONFS){const d=confDay(cf,y);if(d>=S.day&&d-S.day<=within)out.push({...cf,day:d,key:confKey(cf,y)});}return out.sort((a,b)=>a.day-b.day);}
|
||
function confBoost(id){const cb=S.conf;if(!cb||!(cb.until>S.day))return 1;const n=NET[id];return n&&n.pops.some(c=>CITY[c]&&CITY[c].reg===cb.reg)?0.5:1;}
|
||
function confTick(d){S.confReg=S.confReg||{};
|
||
for(const cf of upcomingConfs(30)){if(cf.day-d===30&&!S.confReg[cf.key])toast(tr('<b>{conf} comes to {city} in 30 days.</b><br>Peering coordinators, hallway track, free stickers. Register in the Deals tab.',{conf:esc(cf.n),city:esc(CITY[cf.c].name)}),'goal',[{l:tr('Show me'),act:'leftTab',args:{t:'deals'}}]);}
|
||
for(const cf of upcomingConfs(0)){if(cf.day!==d||!S.confReg[cf.key])continue;const reg=CITY[cf.c].reg;S.conf={until:d+CONF_DAYS,reg,name:cf.n};S.stats.confs=(S.stats.confs||0)+1;
|
||
const r=Math.random();let extra='';if(r<0.3){const cash=5000+Math.floor(Math.random()*4)*5000;S.cash+=cash;extra=' '+tr('You also won the raffle: {cash} worth of optics, sold on eBuy the same evening.',{cash:fmt$(cash)});}else if(r<0.5)extra=' '+tr('Someone from Goggle bought you a beer. You did not get their name, only a sticker.');if(cf.j)extra=' '+tr(cf.j)+(r<0.3?extra:'');
|
||
toast(tr('<b>{conf} in {city}</b><br>You shook a lot of hands. For {n} days, selective networks with a presence in {region} want half the usual traffic before they peer.',{conf:esc(cf.n),city:esc(CITY[cf.c].name),n:CONF_DAYS,region:esc(REG[reg])})+extra,'goal');sfx('coin');}}
|
||
function confSection(){const up=upcomingConfs(75).slice(0,3),cb=S.conf&&S.conf.until>S.day?S.conf:null;if(!up.length&&!cb)return '';
|
||
return `<h3 style="font-size:15px;margin:10px 0 4px">${tr('Conferences')}</h3>${cb?`<div class="inc" style="background:#EAF7EE"><div class="nm">${tr('{name} glow: {n} days left',{name:esc(cb.name),n:cb.until-S.day})}</div><div class="meta">${tr('Selective networks in {region} need half the usual traffic to peer. Now is the time to ask for that PNI.',{region:esc(REG[cb.reg])})}</div></div>`:''}${up.map(cf=>{const reg=S.confReg&&S.confReg[cf.key];return `<div class="row"><div class="grow"><div class="nm">${esc(cf.n)} · ${esc(CITY[cf.c].name)}</div><div class="meta">${cf.day===S.day?tr('Today'):tr('in {n} days',{n:cf.day-S.day})} · ${esc(REG[CITY[cf.c].reg])}</div></div>${reg?'<span class="tag st on">'+tr('Registered')+'</span>':cf.day<=S.day?'<span class="tag st">'+tr('Registration closed')+'</span>':btn(tr('Attend <small>{cost}</small>',{cost:fmt$(CONF_COST)}),'confGo',{key:cf.key},'sm',S.cash<CONF_COST)}</div>`;}).join('')}`;}
|
||
|
||
/* ---------- guided first game ---------- */
|
||
const TUT=[
|
||
{t:tr('Your router is live. Press “Launch broadband” to sell internet to the people of your city.'),sel:'[data-act="launchBB"]',ok:()=>S.pops[S.home]&&S.pops[S.home].bb},
|
||
{t:tr('Your customers want the whole internet. Open the Transit tab and buy a port from a carrier.'),sel:'[data-act="tab"][data-args*=\'"up"\'],[data-act="buyTransit"]',ok:()=>S.transit.length>0,skip:()=>!NETS.some(n=>n.price&&n.pops.includes(S.home))},
|
||
{t:tr('Transit costs money per gigabit. Peering is free: open the Peering tab, buy an IX port, then join the route server.'),sel:'[data-act="tab"][data-args*=\'"peer"\'],[data-act="buyIx"],[data-act="rs"]',ok:()=>Object.keys(S.rs).length>0,skip:()=>!ixName(S.home)},
|
||
{t:tr('Start the clock with 1× and watch traffic and money flow. You can pause any time.'),sel:'#sp1',ok:()=>S.day>=5},
|
||
{t:tr('Grow: drag from your pink router onto a nearby city to lay fiber and open a second POP.'),sel:null,ok:()=>S.links.length>0},
|
||
{t:tr('Businesses pop up as $ bubbles on the map. Open Deals and sign your first customer.'),sel:'[data-act="leftTab"][data-args*=\'"deals"\']',ok:()=>S.biz.length>0},
|
||
];
|
||
function tutorialStart(){let done=false;try{done=!!localStorage.getItem('sot-tut');}catch(e){}if(done||window.__TUBES_TEST__&&!window.__TUBES_TUT__)return;S.tut=0;renderCoach();}
|
||
function renderCoach(){const el=$('coach');if(!el)return;document.querySelectorAll('.coach-glow').forEach(x=>x.classList.remove('coach-glow'));
|
||
if(!S||S.tut===undefined||S.tut===null||S.lost){el.hidden=true;return;}
|
||
while(S.tut<TUT.length){const st=TUT[S.tut];let ok=false;try{ok=st.ok()||(st.skip&&st.skip());}catch(e){}if(!ok)break;S.tut++;}
|
||
if(S.tut>=TUT.length){S.tut=null;el.hidden=true;try{localStorage.setItem('sot-tut','1');}catch(e){}toast(tr('<b>You know the basics.</b><br>The goals on the left take it from here. Things will break. That is the fun part.'),'goal');return;}
|
||
const st=TUT[S.tut];el.innerHTML=`<div class="ct"><span class="cs">${tr('Step {n} of {total}',{n:S.tut+1,total:TUT.length})}</span>${esc(st.t)}</div>${btn(tr('Skip tutorial'),'tutSkip',{},'ghost sm')}`;el.hidden=false;
|
||
if(st.sel){const t=document.querySelector(st.sel);if(t)t.classList.add('coach-glow');}}
|
||
/* ---------- traceroute and looking glass ---------- */
|
||
const slug=t=>String(t).toLowerCase().normalize('NFKD').replace(/[̀-ͯ]/g,'').replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'x';
|
||
function trPaths(src){const live=S.links.filter(l=>!linkDown(l)),rem=remoteCities(),ok=c=>popUp(c)||rem.includes(c),adj={};
|
||
for(const l of live){if(!ok(l.a)||!ok(l.b))continue;const w=(l.km+60)*MET[l.metric||'normal'].f;(adj[l.a]=adj[l.a]||[]).push([l.b,l,w]);(adj[l.b]=adj[l.b]||[]).push([l.a,l,w]);}
|
||
const dist={[src]:0},prev={},done=new Set();for(;;){let u=null,ud=Infinity;for(const k in dist)if(!done.has(k)&&dist[k]<ud){u=k;ud=dist[k];}if(u===null)break;done.add(u);for(const [v,l,w] of adj[u]||[]){const nd=ud+w;if(nd<(dist[v]??Infinity)){dist[v]=nd;prev[v]=l;}}}
|
||
const path=dst=>{if(dist[dst]===undefined)return null;const out=[];let v=dst;while(v!==src){const l=prev[v];out.unshift({l,from:l.a===v?l.b:l.a,to:v});v=l.a===v?l.b:l.a;}return out;};return {dist,path};}
|
||
function trExits(net){const day=S.day,ev=S.ev,leak=ev.leak&&ev.leak.until>day?ev.leak.net:null,out=[];
|
||
for(const x of S.caches)if(x.net===net&&popUp(x.city)&&!siteDown(x.city,'a'))out.push({k:'c',rank:0,city:x.city,pref:'normal',lab:tr('{name} cache',{name:NET[net].cache.name}),used:R.useCache[x.id]||0,cap:CACHE_CAP});
|
||
for(const p of S.pni)if(p.net===net&&popUp(p.city)&&liveN(p.city,p.site,p.n))out.push({k:'p',rank:1,city:p.city,pref:p.pref||'normal',lab:tr('PNI with {net}',{net:NET[net].name}),used:R.usePni[p.id]||0,cap:liveCap(PORT[p.tier].g,p.city,p.site,p.n)});
|
||
for(const c in S.ixp)if(ixSessions(c).has(net)&&(popUp(ixCity(c))||remoteCities().includes(ixCity(c)))&&!(ev.ixdown&&ev.ixdown[c]>day))out.push({k:'ix',rank:2,city:ixCity(c),id:c,pref:(S.ixPref&&S.ixPref[c])||'normal',lab:tr('{ix} peering',{ix:ixName(c)}),used:R.useIx[c]||0,cap:ixCap(c)});
|
||
for(const t of S.transit)if(popUp(t.city)&&!(t.down>day)&&liveN(t.city,t.site,t.n)&&net!==leak&&!((ev.depeer>day||scnRule('spat'))&&t.net==='cog'&&net==='ggl'))out.push({k:'t',rank:3,city:t.city,pref:t.pref||'normal',lab:tr('{name} transit',{name:NET[t.net].name}),tnet:t.net,used:R.useT[t.id]||0,cap:liveCap(PORT[t.tier].g,t.city,t.site,t.n)});
|
||
return out;}
|
||
function traceroute(src,to){const P=trPaths(src),me=slug(S.name)+'.net',lines=[],ip=(a,b)=>`100.64.${a%250}.${b%250}`;let rtt=0.3,n=1;
|
||
const hop=(host,addr,extra,note)=>{rtt+=extra;lines.push(`${String(n++).padStart(2)} ${host} (${addr}) ${rtt.toFixed(1)} ms${note?' ← '+note:''}`);};
|
||
hop(`lo0.cr1.${src}.${me}`,ip(hstr(src),1),0,tr('{city}, your router',{city:CITY[src].name}));
|
||
const walk=path=>{for(const h of path){const l=h.l,lat=linkLat(l)*2+0.15;hop(`ae${1+hstr(l.id)%9}.cr1.${h.to}.${me}`,ip(hstr(h.to),2),lat,`${CITY[h.to].name} · ${l.kind==='df'?tr('own dark fiber'):l.kind==='vxc'?tr('fabric circuit'):l.cable?CAB[l.cable].name:tr('terrestrial wave')} · ${capName(l)}`);}};
|
||
if(to.city){const path=P.path(to.city);lines.unshift(`traceroute to ${to.city}.${me} (${CITY[to.city].name}), 30 hops max`);if(!path){lines.push(' 2 * * * ← '+tr('no working path between these POPs'));return {text:lines.join('\n'),why:tr('No path: every route between these cities is down or missing.')};}walk(path);return {text:lines.join('\n'),why:S.te&&S.te.on?trn('Internal path over {n} link, chosen by distance and link metrics. Auto-TE may move overflow elsewhere when this is full.','Internal path over {n} links, chosen by distance and link metrics. Auto-TE may move overflow elsewhere when this is full.',path.length):trn('Internal path over {n} link, chosen by distance and link metrics.','Internal path over {n} links, chosen by distance and link metrics.',path.length)};}
|
||
const N=NET[to.net],ex=trExits(to.net).filter(e=>P.dist[e.city]!==undefined);
|
||
lines.unshift(`traceroute to www.${slug(N.name)}.example (${N.name}, AS${N.asn}) from ${CITY[src].name}, 30 hops max`);
|
||
if(!ex.length){lines.push(' 2 * * *\n 3 * * * ← '+tr('!N network unreachable'));return {text:lines.join('\n'),why:tr('Nothing on your network reaches {net}: no transit, IX session, PNI or cache with a working path from {city}.',{net:N.name,city:CITY[src].name}),asPath:null};}
|
||
ex.sort((a,b)=>(a.pref==='low'?4:a.rank)-(b.pref==='low'?4:b.rank)||(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||P.dist[a.city]-P.dist[b.city]);
|
||
const e=ex.find(x=>x.used<x.cap*0.999)||ex[0];walk(P.path(e.city));
|
||
let asPath=[S.asn];
|
||
if(e.k==='t'){const T=NET[e.tnet];asPath.push(T.asn);hop(`be-${S.asn}.${e.city}.${slug(T.name)}.net`,`203.0.113.${hstr(e.city)%250}`,0.4,tr('hand-off to {net}',{net:T.name}));
|
||
if(T.id!==N.id){const far=(N.pops&&N.pops.length?N.pops:[e.city]).reduce((a,c)=>kmBetween(e.city,c)<kmBetween(e.city,a)?c:a,(N.pops||[e.city])[0]);const km=CITY[far]?kmBetween(e.city,far):0;
|
||
hop(`ae-2.core.${far}.${slug(T.name)}.net`,`203.0.113.${(hstr(far)+7)%250}`,km*1.3/100+0.3,CITY[far]?tr('{net} carries it to {city}',{net:T.name,city:CITY[far].name}):'');
|
||
hop(`${slug(N.name)}-peer.${far}.${slug(T.name)}.net`,`198.51.100.${hstr(N.id)%250}`,0.4,tr('{net} hands it to {to}',{net:T.name,to:N.name}));}}
|
||
else if(e.k==='ix'){hop(`${slug(ixName(e.city))}.peering.${e.city}`,`185.0.${hstr(e.city)%250}.${hstr(N.id)%250}`,0.3,tr('across the {ix} switch',{ix:ixName(e.city)}));}
|
||
else if(e.k==='p'){hop(`pni-${slug(N.name)}.${e.city}.${me}`,ip(hstr(N.id),3),0.2,tr('private cross-connect'));}
|
||
else{hop(`cache-${slug(N.name)}.${e.city}.${me}`,ip(hstr(N.id),4),0.1,tr('embedded cache in your rack'));}
|
||
asPath.push(N.asn);if(e.k!=='c')hop(`www.${slug(N.name)}.example`,`198.51.100.${(hstr(N.id)+1)%250}`,0.5+(e.k==='t'?1:0.2),`${N.name}`);
|
||
const order={c:tr('caches beat PNIs'),p:tr('PNIs beat IX peering'),ix:tr('IX peering beats transit'),t:tr('transit is the last resort')}[e.k];
|
||
const cn=cnCity(src)!==!!N.cn?' '+tr('Crossing the Great Firewall here loses about {p}% of packets.',{p:S.ev.gfw>S.day?35:20}):'';
|
||
return {text:lines.join('\n'),why:`${tr('Exit: {exit} in {city}.',{exit:e.lab,city:CITY[e.city].name})} ${tr('{rule}, and closer exits win ties',{rule:order[0].toUpperCase()+order.slice(1)})}${e.pref!=='normal'?tr('; this one is set to {mode}',{mode:e.pref==='high'?tr('Prefer'):tr('Backup only')}):''}.${e.used>=e.cap*0.999?' '+tr('It is full, so some traffic overflows to the next exit.'):''}${cn}`,asPath};}
|
||
function traceModal(src,to){const pops=Object.keys(S.pops).sort((a,b)=>CITY[a].name.localeCompare(CITY[b].name));src=src&&S.pops[src]?src:UI.trFrom&&S.pops[UI.trFrom]?UI.trFrom:S.home&&S.pops[S.home]?S.home:pops[0];
|
||
const nets=NETS.slice().sort((a,b)=>b.share-a.share),t=to||UI.trTo||'net:ggl';UI.trFrom=src;UI.trTo=t;
|
||
const r=t.startsWith('net:')?traceroute(src,{net:t.slice(4)}):traceroute(src,{city:t.slice(5)});
|
||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('Looking glass')}</div><h2 style="font-size:26px">${tr('Traceroute')}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('Close')}">×</button></div>
|
||
<div class="trsel"><label>${tr('From')} <select id="trFrom">${pops.map(c=>`<option value="${c}"${c===src?' selected':''}>${esc(CITY[c].name)}</option>`).join('')}</select></label>
|
||
<label>${tr('To')} <select id="trTo"><optgroup label="${tr('Networks')}">${nets.map(n=>`<option value="net:${n.id}"${t==='net:'+n.id?' selected':''}>${esc(n.name)} (AS${n.asn})</option>`).join('')}</optgroup><optgroup label="${tr('Your POPs')}">${pops.filter(c=>c!==src).map(c=>`<option value="city:${c}"${t==='city:'+c?' selected':''}>${esc(CITY[c].name)}</option>`).join('')}</optgroup></select></label>${btn(tr('Run'),'traceRun',{},'pink sm')}</div>
|
||
<pre class="term">${esc(r.text)}</pre>${r.asPath?`<p class="meta">${tr('<b>AS path:</b> {path}',{path:r.asPath.map(a=>'AS'+a).join(' → ')})}</p>`:''}<p class="note">${esc(r.why)}</p>
|
||
<div class="btns">${btn(tr('Copy'),'traceCopy',{},'ghost sm')}</div>`);UI.trText=r.text;}
|
||
|
||
/* ---------- share card ---------- */
|
||
// Straight link segments in map coordinates for flat maps. A link across the date line leaves one edge
|
||
// and comes back in at the other, so it becomes two segments, one per edge (#42).
|
||
function linkSegs(){const out=[];for(const l of S.links){const A=CITY[l.a],B=CITY[l.b];if(!A||!B)continue;const d=Math.abs(B.x-A.x)>W/2?(B.x<A.x?W:-W):0;
|
||
for(const o of d?[0,-d]:[0])out.push([A.x+o,A.y,B.x+d+o,B.y]);}return out;}
|
||
function shareCanvas(){const Wc=1200,Hc=630,cv=document.createElement('canvas');cv.width=Wc;cv.height=Hc;const g=cv.getContext&&cv.getContext('2d');if(!g)return null;
|
||
g.fillStyle='#57C4E5';g.fillRect(0,0,Wc,Hc);
|
||
// mini map
|
||
const mx=40,my=150,mw=700,mh=350,sx=mw/W,sy=mh/H;g.save();g.beginPath();g.rect(mx,my,mw,mh);g.clip();g.fillStyle='#3AA6CF';g.fillRect(mx,my,mw,mh);
|
||
g.fillStyle='#9BDA6C';g.strokeStyle='#1E2640';g.lineWidth=1.5;for(const pts of COAST){g.beginPath();pts.forEach((q,i)=>i?g.lineTo(mx+q[0]*sx,my+q[1]*sy):g.moveTo(mx+q[0]*sx,my+q[1]*sy));g.closePath();g.fill();g.stroke();}
|
||
g.strokeStyle='#FF4F9A';g.lineWidth=2.5;for(const [x1,y1,x2,y2] of linkSegs()){g.beginPath();g.moveTo(mx+x1*sx,my+y1*sy);g.lineTo(mx+x2*sx,my+y2*sy);g.stroke();}
|
||
for(const c in S.pops){const C=CITY[c];g.fillStyle='#FF4F9A';g.strokeStyle='#1E2640';g.lineWidth=2;g.beginPath();g.arc(mx+C.x*sx,my+C.y*sy,5,0,7);g.fill();g.stroke();}
|
||
g.restore();g.strokeStyle='#1E2640';g.lineWidth=5;g.strokeRect(mx,my,mw,mh);
|
||
// header
|
||
g.fillStyle='#1E2640';g.font='900 54px "Baloo 2", sans-serif';g.textBaseline='top';g.fillText(S.name,40,28);
|
||
g.font='800 26px Nunito, sans-serif';g.fillText(`AS${S.asn} · ${tierLabel()} · ${dateStr(S.day)}${S.mode==='sandbox'?' · '+tr('Sandbox'):''}`,42,92);
|
||
// stats
|
||
const got=BADGES.filter(b=>S.ach&&S.ach[b.id]!==undefined),rk={l:0,e:1,r:2,c:3},top=got.slice().sort((a,b)=>rk[a.r]-rk[b.r]).slice(0,8);
|
||
const rows=[[tr('Peak traffic'),fmtG(S.stats.peak||0)],[tr('Peered'),pct(R.peerShare||0)],[tr('POPs'),tr('{n} in {r} regions',{n:Object.keys(S.pops).length,r:regionsCount()})],[tr('Links'),String(S.links.length)],[tr('Customers'),String(S.biz.length)],[tr('Incidents survived'),String(S.stats.survived||0)],[tr('Shark bites'),String(S.stats.sharks||0)],[tr('Badges'),`${got.length}/${BADGES.length}`]];
|
||
if(S.scn)rows.unshift([scnName(),S.scn.done?(S.scn.id==='weekly'?tr('score {v}',{v:fmtG(S.scn.score||S.stats.peak||0)}):tr('done in {d} days',{d:S.scn.done})):S.scn.failed?tr('not this time'):tr('in progress')]);
|
||
let y=150;for(const [k,v] of rows.slice(0,9)){g.fillStyle='#fff';g.strokeStyle='#1E2640';g.lineWidth=3;g.beginPath();g.roundRect?g.roundRect(770,y,390,42,12):g.rect(770,y,390,42);g.fill();g.stroke();g.fillStyle='#5A6280';g.font='800 18px Nunito, sans-serif';g.fillText(k,786,y+11);g.fillStyle='#1E2640';g.font='900 22px Nunito, sans-serif';const tw=g.measureText(v).width;g.fillText(v,1146-tw,y+9);y+=48;}
|
||
g.font='34px sans-serif';top.forEach((b,i)=>g.fillText(b.i,40+i*48,520));
|
||
g.fillStyle='#1E2640';g.font='900 30px "Baloo 2", sans-serif';g.fillText('seriesoftub.es',40,572);g.font='700 20px Nunito, sans-serif';g.fillText(tr('Build the internet, one tube at a time'),300,580);
|
||
return cv;}
|
||
function shareModal(){const cv=shareCanvas();if(!cv){toast(tr('<b>Your browser cannot draw the card.</b>'),'bad');return;}let url='';try{url=cv.toDataURL('image/png');}catch(e){}
|
||
UI.shareCv=cv;openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('Share')}</div><h2 style="font-size:26px">${tr('Your network card')}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('Close')}">×</button></div>${url?`<img src="${url}" alt="${tr('Stats card for {name}',{name:esc(S.name)})}" style="width:100%;border:3px solid var(--ink);border-radius:12px;margin-top:8px">`:''}<div class="btns" style="margin-top:10px">${navigator.share?btn(tr('Share…'),'shareGo',{},'pink'):''}${btn(tr('Download PNG'),'shareDl',{},navigator.share?'':'pink')}</div><p class="note">${tr('Post it wherever your peering friends hang out.')}</p>`);track('share_open');}
|
||
function shareFile(cb){const cv=UI.shareCv;if(!cv||!cv.toBlob){cb(null);return;}cv.toBlob(b=>cb(b?new File([b],`series-of-tubes-${slug(S.name)}.png`,{type:'image/png'}):null),'image/png');}
|
||
function scnTick(d){const sc=S.scn;if(!sc||sc.done||sc.failed)return;
|
||
if(sc.id==='weekly'){if(d>=sc.days){sc.done=d;const score=Math.round(S.stats.peak||0);sc.score=score;let best=null;try{const wk=JSON.parse(localStorage.getItem('sot-weekly')||'{}');best=wk[sc.key];if(!best||score>best){wk[sc.key]=score;localStorage.setItem('sot-weekly',JSON.stringify(wk));}}catch(e){}
|
||
const h=scnHof();h.weekly=h.weekly||{d:new Date().toISOString().slice(0,10)};try{localStorage.setItem('sot-scn',JSON.stringify(h));}catch(e){}
|
||
openModal(`<div class="eyebrow">${tr('Weekly challenge {key}',{key:esc(sc.key)})}</div><h2 style="font-size:30px">${tr('Your score: {score}',{score:fmtG(score)})}</h2><p class="tagline">${best&&best>score?tr('Peak traffic served in one year. Your best this week is {best}.',{best:fmtG(best)}):best?tr('Peak traffic served in one year. A new personal best for this week!.'):tr('Peak traffic served in one year.')}</p><div class="btns">${btn(tr('Share my result'),'share',{},'pink big')}${btn(tr('Keep playing'),'closeModal',{},'ghost big')}</div>`);track('weekly_done');}return;}
|
||
const def=SCN.find(x=>x.id===sc.id);if(!def)return;let ok=false;try{ok=def.ok();}catch(e){}
|
||
if(ok){sc.done=d;const h=scnHof();if(!h[sc.id]||h[sc.id].days>d)h[sc.id]={d:new Date().toISOString().slice(0,10),days:d};try{localStorage.setItem('sot-scn',JSON.stringify(h));}catch(e){}track('scenario_'+sc.id);
|
||
openModal(`<div class="eyebrow">${tr('Scenario complete')}</div><h2 style="font-size:30px">${tr('{name}: done in {d} days',{name:esc(def.n),d})}</h2><p class="tagline">${esc(def.goal)}. ${d<def.days/2?tr('With time to spare.'):tr('Just in time.')}</p><div class="btns">${btn(tr('Share my result'),'share',{},'pink big')}${btn(tr('Keep playing'),'closeModal',{},'ghost big')}${btn(tr('More scenarios'),'scenarios',{},'ghost')}</div>`);sfx('coin');}
|
||
else if(d>=def.days){sc.failed=d;openModal(`<div class="eyebrow">${tr('Scenario over')}</div><h2 style="font-size:30px">${tr("Time's up")}</h2><p class="tagline">${tr('{goal} was not reached in {d} days. Keep playing this network as free play, or try again.',{goal:esc(def.goal),d:def.days})}</p><div class="btns">${btn(tr('Try again'),'startScn',{id:def.id},'pink big')}${btn(tr('Keep playing'),'closeModal',{},'ghost big')}</div>`);}}
|
||
function scenarioModal(){const wk=weekly(),h=scnHof();let best=null;try{best=JSON.parse(localStorage.getItem('sot-weekly')||'{}')[wk.key];}catch(e){}
|
||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('Scenarios')}</div><h2 style="font-size:28px">${tr('Pick a challenge')}</h2></div><button class="x" data-act="${UI.started?'closeModal':'helpClose'}" aria-label="${tr('Close')}">×</button></div>
|
||
<div class="scn wk"><div class="grow"><div class="nm">${tr('Weekly challenge {key}',{key:esc(wk.key)})}</div><div class="meta">${tr('Start in {city} · {mods} · one year, score = peak traffic. The same world for everyone this week.',{city:esc(CITY[wk.city].name),mods:wk.mods.map(m=>esc(m.n)).join(' · ')})}${best?' '+tr('Your best: {best}.',{best:fmtG(best)}):''}</div></div>${btn(tr('Play'),'startWeekly',{},'pink')}</div>
|
||
${SCN.map(x=>`<div class="scn"><div class="grow"><div class="nm">${esc(x.n)} ${h[x.id]?`<span class="tag open">${tr('done in {d} days',{d:h[x.id].days})}</span>`:''}</div><div class="meta">${esc(x.d)}</div><div class="meta">${tr('<b>Goal:</b> {goal} · <b>Time:</b> {d} days · start in {city}',{goal:esc(x.goal),d:x.days,city:esc(CITY[x.city].name)})}</div></div>${btn(tr('Play'),'startScn',{id:x.id},'')}</div>`).join('')}`);}
|
||
function newGame(name,home){
|
||
S={v:1,name,asn:200000+Math.floor(_rand()*15000),home,day:0,cash:START_CASH,
|
||
ltv:2,t1v:2,seen:NETS.map(n=>n.id),spares:{},pops:{[home]:{day:0,bb:null,boost:0,down:0,routers:1,gen:false}},links:[],nni:[],transit:[],ixp:{},rs:{},peers:{},pni:[],caches:[],biz:[],offers:[],myIx:{},
|
||
done:{},inc:[],ev:{},priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubAt:null,scrubTier:0,scrubMode:'always',won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0};
|
||
}
|
||
|
||
/* ================= HELPERS ================= */
|
||
const fmt$=v=>{const a=Math.abs(v),s=v<0?'-':'';if(a>=1e6)return s+'$'+(a/1e6).toFixed(a>=1e7?1:2)+'M';if(a>=1e3)return s+'$'+(a/1e3).toFixed(a>=1e5?0:1)+'k';return s+'$'+Math.round(a);};
|
||
const fmtG=g=>g>=1000?(g/1000).toFixed(g>=10000?1:2)+' Tbps':(g>=100?g.toFixed(0):g.toFixed(1))+' Gbps';
|
||
const pct=x=>Math.round(x*100)+'%';
|
||
// Reach never rounds up to 100%: Tier 1 needs more than 99.9%, and 99.6% must not look like a full house (#73).
|
||
const reachPct=x=>x>0.999?'100%':x>=0.99?(Math.floor(x*1000)/10).toFixed(1)+'%':pct(x);
|
||
const clamp=(v,a,b)=>Math.max(a,Math.min(b,v));
|
||
const pick=a=>a[Math.floor(Math.random()*a.length)];
|
||
const esc=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
||
function dateStr(d){const y=1+Math.floor(d/360),m=Math.floor(d/30)%12,dd=d%30+1;return tr('Y{y} · {mon} {d}',{y,mon:MONTHS[m],d:dd});}
|
||
function wrapDx(a,b){let dx=b-a;if(dx>W/2)dx-=W;if(dx<-W/2)dx+=W;return dx;}
|
||
function kmBetween(a,b){const A=CITY[a],B=CITY[b];return Math.max(20,Math.round(hav(A.lon,A.lat,B.lon,B.lat)));}
|
||
// Cities on a land bridge belong to two landmasses: Cairo reaches Asia overland across the Sinai, the way
|
||
// Istanbul does across the Bosporus (#47). Overland between continents still costs the intercontinental price.
|
||
const lands=C=>C.land2?[C.land,C.land2]:[C.land];
|
||
const isSub=(a,b)=>{const A=lands(CITY[a]),B=lands(CITY[b]);return !A.some(x=>B.includes(x));};
|
||
const popUp=c=>S.pops[c]&&!(S.pops[c].down>S.day);
|
||
const regionsCount=()=>new Set(Object.keys(S.pops).map(c=>CITY[c].reg)).size;
|
||
const ixCity=x=>String(x).split('~')[0];
|
||
function ixIdsIn(c){const o=ixStatic(c);if(S&&S.myIx&&S.myIx[c]&&!o.includes(c))o.unshift(c);return o;}
|
||
const hasIxAt=c=>ixIdsIn(c).some(x=>S.ixp[x]!==undefined);
|
||
function ixName(c){if(XIXM[c])return XIXM[c].name;return S.myIx[c]?S.myIx[c].name:CITY[c].ix;}
|
||
function ixMembers(c){if(XIXM[c])return XIXM[c].members.slice();if(S.myIx[c])return S.myIx[c].members.slice();if(!CITY[c].ix)return [];return NETS.filter(n=>n.ix==='ALL'||(Array.isArray(n.ix)&&n.ix.includes(c))).map(n=>n.id);}
|
||
// LAG: several identical ports bundled into one logical link. Flow hashing is never perfectly even, so a bundle carries ~95% of the sum.
|
||
const LAG_MAX=8;
|
||
function lagCap(g,n){n=n||1;return g*n*(n>1?0.95:1);}
|
||
function lagName(tier,n){return (n||1)>1?`${n}×${PORT[tier].n} LAG`:tr('{port} port',{port:PORT[tier].n});}
|
||
function ixCap(c){return ixLagF(c)*(S.myIx[c]?myFab(c).g*(S.pops[c]&&(siteDown(c,'a'))?0:1):liveCap(PORT[S.ixp[c]].g,ixCity(c),(S.ixSite||{})[c],(S.ixn||{})[c])*(isRemote(c)?REMOTE_CAP:1));}
|
||
function ixSessions(c){
|
||
const s=new Set(); if(S.ixp[c]===undefined)return s;
|
||
for(const id of ixMembers(c)){const n=NET[id];
|
||
if(S.peers[id+'@'+c]&&!snub(id,c)&&!(isRemote(c)&&noRemote(id)))s.add(id);
|
||
else if(S.rs[c]&&n.pol==='open')s.add(id);
|
||
else if(S.myIx[c]&&(n.pol==='open'||n.pol==='selective'))s.add(id);}
|
||
return s;
|
||
}
|
||
function t1Club(){
|
||
const miss=[];const pops=Object.keys(S.pops).length;
|
||
if(regionsCount()<3)miss.push(tr('POPs on 3+ continents'));
|
||
if(pops<10)miss.push(tr('10+ POPs ({n})',{n:pops}));
|
||
if(R.served<1500)miss.push(tr('serve 1.5 Tbps ({v})',{v:fmtG(R.served)}));
|
||
if(R.sessions<20)miss.push(tr('20+ peering sessions ({n})',{n:R.sessions}));
|
||
return {ok:!miss.length,missing:miss};
|
||
}
|
||
/* Big networks sometimes refuse to peer in a particular city, for a while. Each (network, city)
|
||
pair gets a stable verdict per window, derived from a hash, so asking again does not reroll it. */
|
||
const SNUB_WIN=150,SNUB_P=0.22;
|
||
const SNUB_IX=[tr('Only peers over PNIs in this metro. Order a cross-connect instead.'),tr('Their IX port here is full until the next upgrade. They promise it is soon.'),tr('Moved everything in this city to PNIs. Please read their PearingDB page, all 40 pages of it.'),tr('The peering coordinator for this city is on a six-month sabbatical.'),tr('Their policy here says "IX peering by invitation only". You were not invited.')];
|
||
const SNUB_ALL=[tr('Not accepting new peers in this region right now.'),tr('Region frozen while they renegotiate with the local incumbent.'),tr('Their routers in this city are "at capacity". They are not.'),tr('Already reach you through your transit provider here and think that is fine.'),tr('Their lawyers are reviewing every peering agreement in this country. Again.'),tr('A new VP wants to "monetise interconnection" in this market.')];
|
||
function hstr(t){let h=2166136261;for(let i=0;i<t.length;i++){h^=t.charCodeAt(i);h=Math.imul(h,16777619);}return h>>>0;}
|
||
function bigPeer(n){return !!n&&n.pol==='selective'&&n.share>=0.03;}
|
||
function snub(id,c){
|
||
const n=NET[id];if(!c||!bigPeer(n)||!S||S.myIx[c])return null;
|
||
const off=hstr(id+c)%SNUB_WIN,ep=Math.floor((S.day+off)/SNUB_WIN),h=hstr(S.asn+'|'+id+'|'+c+'|'+ep);
|
||
if(h%1000>=SNUB_P*1000)return null;
|
||
const all=(h>>>10)%5<2,list=all?SNUB_ALL:SNUB_IX;
|
||
return {all,why:list[(h>>>13)%list.length],until:(ep+1)*SNUB_WIN-off};
|
||
}
|
||
/* Remote peering: offered, but discouraged. A reseller marks up the port, oversubscribes it,
|
||
and many selective networks refuse members who are not physically in the building. */
|
||
const REMOTE_FEE=1.5,REMOTE_CAP=0.8;
|
||
const REMOTE_WARN=`<p class="note" style="color:var(--bad)">${tr('<b>Remote peering is a last resort.</b> Ports come through a reseller at 1.5× the price, only 80% of the port is really yours, latency rides the fabric, one fabric outage drops every session, and many selective networks refuse remote members. A POP here is better.')}</p>`;
|
||
const REMOTE_WHY=[tr('Policy: no remote peers. Be in the building or be in the transit bill.'),tr('Saw your session come in over a fabric and said "we can smell the VXC from here".'),tr('Only peers with members they can reach without a 1,500 km hairpin.'),tr('Their PearingDB entry says "Remote peering: No (we mean it)".'),tr('Tried a remote peer once. It flapped during a product launch. Never again.')];
|
||
function isRemote(c){return S.ixp[c]!==undefined&&!S.pops[ixCity(c)]&&!S.myIx[c];}
|
||
function noRemote(id){const n=NET[id];if(!n||n.pol!=='selective')return false;return hstr(id+'|remote')%100<(n.share>=0.03?60:30);}
|
||
/* Europe's peering market is crowded and competitive: ports are cheaper, and incumbents cut prices
|
||
when a challenger in the same metro gets too popular. DE-KICKS harmonises instead. */
|
||
const IX_REG={EU:0.8};
|
||
function ixMul(x){const X=XIXM[x],c=ixCity(x);return (X?X.cheap:(CITY[c].ixCheap||1))*(IX_REG[CITY[c].reg]||1)*((S&&S.ixCut&&S.ixCut[x])||1);}
|
||
function ixPortMo(c,tier){const X=XIXM[c];if(X&&tier<=(X.freeTo??-1))return 0;return Math.round(PORT[tier].ix*(S.pops[ixCity(c)]?1:REMOTE_FEE)*dkMult(c)*ixMul(c));}
|
||
function ixPriceWar(d){if(!S.ixp||Math.random()>=1/120)return;
|
||
const mine=Object.keys(S.ixp).filter(x=>{const c=ixCity(x);return CITY[c].reg==='EU'&&ixStatic(c).length>1;});if(!mine.length)return;
|
||
const x=pick(mine),c=ixCity(x),rival=pick(ixStatic(c).filter(y=>y!==x));
|
||
if(isDk(x)){toast(tr('<b>{rival} is poaching DE-KICKS members in {city}.</b><br>DE-KICKS responded with a webinar about "the value of premium interconnection". Prices unchanged.',{rival:esc(ixName(rival)),city:esc(CITY[c].name)}),'bad');return;}
|
||
S.ixCut=S.ixCut||{};const cur=S.ixCut[x]||1;if(cur<=0.62)return;S.ixCut[x]=+Math.max(0.6,cur*0.9).toFixed(3);
|
||
toast(tr('<b>Price war in {city}!</b><br>{ix} cut its port prices 10% to stop members drifting to {rival}. Your invoice just got smaller.',{city:esc(CITY[c].name),ix:esc(ixName(x)),rival:esc(ixName(rival))}),'good');}
|
||
/* DE-KICKS Group: runs several big exchanges and really, really hates open pricing.
|
||
No price list, personalised quotes, haggling, yearly "harmonisation", auto-enrolled add-ons
|
||
you have to opt out of, and a retention offer when you try to leave. */
|
||
const DK_CITIES=['fra','mad','mrs','dxb','bom','nyc'];
|
||
const isDk=c=>(DK_CITIES.includes(c)||scnRule('dkAll'))&&!!CITY[c]&&!!CITY[c].ix&&!S.myIx[c];
|
||
const DK_ADDONS=[['Blackholing Plus™',tr('Like blackholing, but with a Plus.')],['Route Server Gold',tr('The same route server, in a gold-coloured portal.')],['Premium Port LEDs',tr('Your port light now blinks in brand colours.')],['Strategic Peering Insights',tr('A monthly PDF of your own traffic graphs.')],['GlobePeer Ready™',tr('Makes your port "ready" for a product you did not buy.')],['Cloud Exchange Readiness Fee',tr('A fee for being ready for the cloud.')],['Account Manager Lunch Fund',tr('Your account manager is hungry.')]];
|
||
const DK_STALL=[tr('Your account manager would love to "align on value" first. Strategic call booked for next week.'),tr('Pricing is reviewed by the Global Commercial Council, who meet on the next full moon.'),tr('They sent a 14-page NDA before they can even repeat the price. Lawyers estimate a week.'),tr('Your account manager is at a conference in Dubai. And then one in Madrid.')];
|
||
function dkMult(c){if(!S||!isDk(c)||!S.dk||!S.dk.m[c])return 1;const ret=S.dk.ret[c];return S.dk.m[c]*(ret&&ret>S.day?0.6:1);}
|
||
function dkAddonMo(c){return S.dk&&S.dk.add[c]?S.dk.add[c].reduce((a,x)=>a+x.mo,0):0;}
|
||
function dkState(){S.dk=S.dk||{m:{},add:{},ret:{},retUsed:{},stall:0,q:null};return S.dk;}
|
||
function dkQuoteMult(){const pops=Object.keys(S.pops).length,big=Math.min(1.2,pops*0.04+(R.served||0)/20000);return +(0.95+Math.random()*0.45+big).toFixed(2);}
|
||
function dkQuoteModal(){const q=S.dk.q,c=q.city,mo=Math.round(PORT[q.tier].ix*(S.pops[c]?1:REMOTE_FEE)*q.m*ixMul(c));
|
||
openModal(`<div class="eyebrow">${tr('DE-KICKS Group · Sales')}</div><h2 style="font-size:26px">${tr('Your personalised {port} quote for {ix}',{port:PORT[q.tier].n,ix:esc(ixName(c))})}</h2>
|
||
<p class="tagline">${tr("“Thanks for your interest! We don't publish prices, because every customer is unique.”")}</p>
|
||
<div class="kv"><span>${tr('Monthly price, just for you')}</span><b>${tr('{price}/mo',{price:fmt$(mo)})}</b></div>
|
||
<div class="kv"><span>${tr('List price')}</span><b>${tr('Confidential')}</b></div>
|
||
<div class="kv"><span>${tr('What others pay')}</span><b>${tr('Covered by NDA')}</b></div>
|
||
<p class="note">${tr('Quotes go up with how big you look.')} ${q.h>=3?tr('Your account manager has stopped replying to haggling.'):tr('Haggles left: {n}.',{n:3-q.h})}</p>
|
||
<div class="btns">${btn(tr('Sign <small>{price}/mo</small>',{price:fmt$(mo)}),'dkAccept',{},'pink',S.cash<mo)}${btn(tr('Haggle'),'dkHaggle',{},'',q.h>=3)}${btn(tr('Walk away'),'dkWalk',{},'ghost')}</div>`);}
|
||
function dkTick(d){if(!S.dk)return;const dk=S.dk;
|
||
for(const c in S.ixp){if(!isDk(c))continue;
|
||
if(dk.ret[c]&&dk.ret[c]===d){dk.m[c]=+(dk.m[c]*1.1).toFixed(3);toast(tr('<b>Your {ix} promo ended.</b><br>Price is back, plus 10% for "loyalty programme administration".',{ix:esc(ixName(c))}),'bad');}
|
||
if(dk.m[c]&&(d+hstr(c)%90)%365===0){const f=1.08+Math.random()*0.07;dk.m[c]=+(dk.m[c]*f).toFixed(3);toast(tr('<b>DE-KICKS has harmonised its prices.</b><br>Harmonised means up: {ix} now costs {p}% more. Thank you for your continued partnership.',{ix:esc(ixName(c)),p:Math.round((f-1)*100)}),'bad');}
|
||
const add=dk.add[c]=dk.add[c]||[];
|
||
if(add.length<3&&Math.random()<1/150){const a=DK_ADDONS.filter(x=>!add.some(y=>y.n===x[0]));if(a.length){const [n,blurb]=pick(a),mo=Math.round((300+Math.random()*1200)/50)*50;add.push({n,blurb,mo,day:d});
|
||
toast(tr("<b>Good news! You've been enrolled in {addon}.</b><br>{blurb} {price}/mo, added to your {ix} invoice. Opt out any time in the IX panel.",{addon:esc(n),blurb:esc(blurb),price:fmt$(mo),ix:esc(ixName(c))}),'bad');}}}
|
||
}
|
||
|
||
function elephant(){S.phpDone=true;S.ev.php=S.day+4;
|
||
toast(tr(`<b>🐘 BREAKING: CVE-2026-31337 just took down half the internet.</b><br>A bug in PHP turned every WordPress-ish site on Earth into a crypto miner. Eyeball traffic is down 30% for a few days while the world patches. Your hosting customers are doing it at 3 a.m.`),'bad');sfx('alert');renderMega();}
|
||
function snubWhy(sn){const d=Math.max(1,sn.until-S.day);return sn.why+' '+trn('They will reconsider in {n} day.','They will reconsider in {n} days.',d);}
|
||
// Paid-peering giants drop the fee for networks too big to ignore (freeLv: the customer level that does it).
|
||
const paidFree=n=>!!(n&&n.freeLv&&lvl()>=n.freeLv);
|
||
function peerOk(id,via,city){
|
||
const n=NET[id],dem=R.demTo[id]||0;
|
||
const sn=snub(id,city);if(sn&&(via==='ix'||sn.all))return {ok:false,snub:true,why:snubWhy(sn)};
|
||
if(via==='ix'&&city&&isRemote(city)&&noRemote(id))return {ok:false,remote:true,why:REMOTE_WHY[hstr(id)%REMOTE_WHY.length]};
|
||
if(n.pol==='open')return {ok:true};
|
||
if(n.pol==='selective'){const need=Math.round((via==='pni'?n.minPni:n.minIx)*confBoost(id));return dem>=need?{ok:true}:{ok:false,why:tr('Wants ≥ {need} Gbps of traffic from you (you send {dem})',{need,dem:dem.toFixed(1)})};}
|
||
if(n.pol==='paid'&&paidFree(n))return via==='pni'?{ok:true,free:true}:{ok:false,why:tr('Peers with you for free now, but only over a PNI')};
|
||
if(n.pol==='paid')return via==='pni'?{ok:true,fee:n.paidFee}:{ok:false,why:n.perG?tr('Sender pays: a paid PNI only, {fee}/mo plus {g} per Gbps you send',{fee:fmt$(n.paidFee),g:fmt$(n.perG)}):tr('Paid peering only, over a PNI')};
|
||
if(n.type!=='t1'){if(via!=='pni')return {ok:false,why:tr('Only peers over PNIs, and only with networks it considers important')};const need=Math.round(60*confBoost(id));return dem>=need||isTier2()?{ok:true}:{ok:false,why:tr('Wants you to be a Tier 2, or send ≥ {need} Gbps to it (you send {dem})',{need,dem:dem.toFixed(1)})};}
|
||
if(via!=='pni')return {ok:false,why:tr('Tier 1s never peer at IXs')};
|
||
const c=t1Club();return c.ok?{ok:true}:{ok:false,why:tr('Not big enough yet: {list}',{list:c.missing.join(', ')})};
|
||
}
|
||
// Everything that can fill up at a POP: transit ports, IX ports, PNIs, caches and the routers themselves.
|
||
const HOT=0.9,HOTL={t:'T',ix:'IX',p:'P',c:'C',r:'R'},HOTC={t:'#7B61FF',ix:'#FFD23F',p:'#2C7A7B',c:'#C8102E',r:'#FF4F9A'};
|
||
function hotPorts(){const out=[];if(!R||!S)return out;
|
||
for(const t of S.transit){if(t.down>S.day)continue;const cap=lagCap(PORT[t.tier].g,t.n),u=(R.useT[t.id]||0)/cap;if(u>=HOT)out.push({k:'t',city:t.city,lab:tr('{net} transit · {lag}',{net:NET[t.net].name,lag:lagName(t.tier,t.n)}),u,tip:tr('Add a LAG member, upgrade the port or buy a second upstream.')});}
|
||
for(const c in S.ixp){const cap=ixCap(c);if(!cap)continue;const u=(R.useIx[c]||0)/cap;if(u>=HOT)out.push({k:'ix',city:ixCity(c),lab:tr('{port} port',{port:ixName(c)}),u,tip:tr('Upgrade the IX port or add a LAG member.')});}
|
||
for(const p of S.pni){const cap=lagCap(PORT[p.tier].g,p.n),u=(R.usePni[p.id]||0)/cap;if(u>=HOT)out.push({k:'p',city:p.city,lab:tr('PNI with {net}',{net:NET[p.net].name}),u,tip:tr('Add a LAG member or upgrade the PNI.')});}
|
||
const cc={};for(const x of S.caches){const k=x.city+'|'+x.net;(cc[k]=cc[k]||{city:x.city,net:x.net,used:0,cap:0});cc[k].used+=R.useCache[x.id]||0;cc[k].cap+=CACHE_CAP;}
|
||
for(const k in cc){const x=cc[k],u=x.used/x.cap;if(u>=HOT)out.push({k:'c',city:x.city,lab:x.cap>CACHE_CAP?tr('{name} caches',{name:NET[x.net].cache.name}):tr('{name} cache',{name:NET[x.net].cache.name}),u,tip:tr('Ask for another box. The overflow goes out over peering or transit.')});}
|
||
for(const c in S.pops){const cap=R.nodeCap[c];if(!cap)continue;const u=(R.nodeLoad[c]||0)/cap;if(u>=HOT)out.push({k:'r',city:c,lab:tr('Routers'),u,tip:tr('Upgrade the router or add a second one in the Infra tab.')});}
|
||
return out.sort((a,b)=>b.u-a.u);}
|
||
function hotByCity(){const m={};for(const h of hotPorts())(m[h.city]=m[h.city]||{})[h.k]=Math.max((m[h.city]||{})[h.k]||0,h.u);return m;}
|
||
function isTier2(){return Object.keys(S.pops).length>=5&&Object.keys(S.ixp).length>=3&&R.sessions>=15;}
|
||
// Sparkly Seabone joined the Tier 1s in 1.12. Older saves keep the five they were playing for.
|
||
const t1Need=()=>NETS.filter(n=>n.type==='t1'&&(n.id!=='skl'||(S&&S.t1v>=2)));
|
||
function isTier1(){return t1Need().every(n=>S.pni.some(p=>p.net===n.id))&&S.transit.length===0&&R.reach>0.999;}
|
||
// What you are now, not what you once were (#46): buying transit again or losing reach drops the label.
|
||
function tierLabel(){return S.won&&isTier1()?'Tier 1':isTier2()?'Tier 2':'Tier 3';}
|
||
function t1Why(){if(S.transit.length)return tr('you buy transit again');const miss=t1Need().filter(n=>!S.pni.some(p=>p.net===n.id));if(miss.length)return tr('no PNI with {list}',{list:miss.map(n=>n.name).join(', ')});{const lost=NETS.filter(n=>!R.reachable[n.id]).sort((a,b)=>NSH[b.id]-NSH[a.id]);if(lost.length)return tr('you cannot reach {list}',{list:lost.slice(0,3).map(n=>n.name).join(', ')+(lost.length>3?' '+tr('and {n} more',{n:lost.length-3}):'')});}return tr('your reach is {p}, not 100%',{p:reachPct(R.reach)});}
|
||
|
||
/* ================= SIMULATION ================= */
|
||
// Binary-heap Dijkstra over an adjacency map {city:[[neighbour,edge],...]}. wf(edge) gives the weight,
|
||
// skip(v,edge) can rule edges out, and the search stops early once `stop` is settled.
|
||
function hpush(h,x){h.push(x);let i=h.length-1;while(i>0){const p=(i-1)>>1;if(h[p][0]<=h[i][0])break;[h[p],h[i]]=[h[i],h[p]];i=p;}}
|
||
function hpop(h){const top=h[0],last=h.pop();if(h.length){h[0]=last;let i=0;for(;;){const l=2*i+1,r=l+1;let m=i;if(l<h.length&&h[l][0]<h[m][0])m=l;if(r<h.length&&h[r][0]<h[m][0])m=r;if(m===i)break;[h[m],h[i]]=[h[i],h[m]];i=m;}}return top;}
|
||
function dijkstra(adj,src,wf,skip,stop){const dist={[src]:0},prev={},done=new Set(),h=[[0,src]];
|
||
while(h.length){const [d,u]=hpop(h);if(done.has(u)||d>dist[u])continue;done.add(u);if(u===stop)break;
|
||
for(const [v,e] of adj[u]||[]){if(skip&&skip(v,e))continue;const nd=d+wf(e);if(nd<(dist[v]??Infinity)){dist[v]=nd;prev[v]=e;hpush(h,[nd,v]);}}}
|
||
return {dist,prev};}
|
||
/* ---------- RouteScript: a tiny, safe rule language for the Auto-TE controller ----------
|
||
Player scripts are parsed into plain data and never executed, so a shared or imported
|
||
save can't run code. One rule per line, # for comments. */
|
||
const TE_KINDS={pni:'p',ix:'ix',transit:'t'};
|
||
const TE_EXAMPLE=`# RouteScript for your Auto-TE controller. One rule per line.
|
||
# Keep Cogentle at its 20 Gbps commit; overflow goes elsewhere
|
||
cap transit cogentle at 20 gbps
|
||
# Goggle should come over peering, not transit
|
||
avoid transit for goggle
|
||
# Move traffic before links are completely full
|
||
spill at 85%
|
||
# Maintenance window? Drain a POP's exits, or steer around a link
|
||
# drain paris
|
||
# avoid link frankfurt-amsterdam
|
||
# Under DDoS: drop the junk at the edge (takes some real traffic with it)
|
||
# blackhole ddos`;
|
||
function lev(a,b){const m=a.length,n=b.length,d=Array.from({length:m+1},(_,i)=>[i]);for(let j=1;j<=n;j++)d[0][j]=j;for(let i=1;i<=m;i++)for(let j=1;j<=n;j++)d[i][j]=Math.min(d[i-1][j]+1,d[i][j-1]+1,d[i-1][j-1]+(a[i-1]===b[j-1]?0:1));return d[m][n];}
|
||
function teFind(word,list,label){const w=slug(word);if(!w)return {err:tr('missing {what}',{what:label})};
|
||
for(const x of list)if(x.id===w||slug(x.name)===w)return {v:x.id};
|
||
const pre=list.filter(x=>w.length>=3&&slug(x.name).startsWith(w));if(pre.length===1)return {v:pre[0].id};
|
||
const best=list.map(x=>({x,d:Math.min(lev(w,slug(x.name)),lev(w,x.id))})).sort((a,b)=>a.d-b.d)[0];
|
||
return {err:tr('unknown {what} “{word}”',{what:label,word})+(best&&best.d<=3?tr('. Did you mean {name}?',{name:best.x.name}):'')};}
|
||
function teParse(src){const out={spill:null,cap:{},net:{},drain:new Set(),avoid:new Set(),blackhole:false,errors:[],n:0};
|
||
const lines=String(src||'').split('\n').slice(0,60);
|
||
lines.forEach((raw,i)=>{const line=raw.replace(/#.*/,'').trim().toLowerCase();if(!line)return;const L=i+1;let m;
|
||
if(m=line.match(/^spill\s+at\s+(\d{1,3})\s*%$/)){const v=+m[1];if(v<20||v>100)out.errors.push(tr('line {n}: spill must be between 20% and 100%',{n:L}));else{out.spill=v/100;out.n++;}return;}
|
||
if(m=line.match(/^(prefer|avoid)\s+(pni|ix|transit)\s+for\s+(.+)$/)){const r=teFind(m[3],NETS,tr('network'));if(r.err){out.errors.push(tr('line {n}: {err}',{n:L,err:r.err}));return;}const o=out.net[r.v]=out.net[r.v]||{};o[m[1]]=TE_KINDS[m[2]];out.n++;return;}
|
||
if(m=line.match(/^cap\s+transit\s+(.+?)\s+at\s+(\d+(?:\.\d+)?)\s*(gbps|tbps|g|t)$/)){const r=teFind(m[1],NETS.filter(n=>n.price),tr('transit provider'));if(r.err){out.errors.push(tr('line {n}: {err}',{n:L,err:r.err}));return;}out.cap[r.v]=+m[2]*(m[3][0]==='t'?1000:1);out.n++;return;}
|
||
if(m=line.match(/^drain\s+(.+)$/)){const r=teFind(m[1],CITIES,tr('city'));if(r.err){out.errors.push(tr('line {n}: {err}',{n:L,err:r.err}));return;}out.drain.add(r.v);out.n++;return;}
|
||
if(m=line.match(/^avoid\s+link\s+(.+?)\s*(?:-|\bto\b|→)\s*(.+)$/)){const a=teFind(m[1],CITIES,tr('city')),b=teFind(m[2],CITIES,tr('city'));if(a.err||b.err){out.errors.push(tr('line {n}: {err}',{n:L,err:a.err||b.err}));return;}out.avoid.add(a.v<b.v?a.v+'|'+b.v:b.v+'|'+a.v);out.n++;return;}
|
||
if(line==='blackhole ddos'){out.blackhole=true;out.n++;return;}
|
||
out.errors.push(tr("line {n}: I don't understand “{text}”. Try: spill at 80%, prefer pni for goggle, avoid transit for netchill, cap transit cogentle at 20 gbps, drain paris, avoid link fra-ams, blackhole ddos",{n:L,text:raw.trim().slice(0,40)}));});
|
||
return out;}
|
||
let TE_CACHE={src:null,p:null};
|
||
function teRules(){if(!S||!S.te||!S.te.on||!S.te.script)return null;if(TE_CACHE.src!==S.te.script)TE_CACHE={src:S.te.script,p:teParse(S.te.script)};return TE_CACHE.p.errors.length?null:TE_CACHE.p;}
|
||
function teModal(msg){const src=UI.teDraft!==undefined?UI.teDraft:(S.te.script||TE_EXAMPLE);
|
||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('Auto-TE controller')}</div><h2 style="font-size:26px">RouteScript</h2></div><button class="x" data-act="teClose" aria-label="${tr('Close')}">×</button></div>
|
||
<p class="tagline">${tr('Write rules, check them against live traffic, then deploy. A bad deploy is a very real way to break your network.')}</p>
|
||
<textarea id="teSrc" class="tecode" spellcheck="false" autocapitalize="off" autocomplete="off" rows="12">${esc(src)}</textarea>
|
||
${msg||''}<div class="btns" style="margin-top:8px">${btn(tr('Check (dry run)'),'teCheck',{},'')}${btn(tr('Deploy'),'teDeploy',{},'pink')}${S.te.script?btn(tr('Remove script'),'teClear',{},'ghost sm'):''}${btn(tr('Reset to example'),'teExample',{},'ghost sm')}</div>
|
||
<p class="meta" style="margin-top:8px"><b>${tr('Rules:')}</b> <code>spill at 80%</code> · <code>prefer pni|ix|transit for NETWORK</code> · <code>avoid pni|ix|transit for NETWORK</code> · <code>cap transit PROVIDER at 20 gbps</code> · <code>drain CITY</code> · <code>avoid link CITY-CITY</code> · <code>blackhole ddos</code></p>
|
||
${S.te.script?`<p class="meta">${tr('Live: {state} · {rules}',{state:S.te.on?tr('deployed'):tr('controller is off'),rules:teRules()?tr('{n} rules active',{n:teRules().n}):tr('not active')})}</p>`:''}`);}
|
||
function teTrial(src){const keep=S.te.script,on=S.te.on,before={served:R.served,tc:R.cost.transit||0,moved:R.teMoved||0};
|
||
S.te.script=src;S.te.on=true;compute();const after={served:R.served,tc:R.cost.transit||0,moved:R.teMoved||0,bh:R.teBlack||0};
|
||
S.te.script=keep;S.te.on=on;compute();return {before,after};}
|
||
function compute(){
|
||
const day=S.day, R2=emptyR(), pops=Object.keys(S.pops).filter(popUp);
|
||
const remote=remoteCities(),adj={}; pops.concat(remote).forEach(p=>adj[p]=[]);
|
||
const edges={},TRX=teRules();
|
||
for(const l of S.links){if(linkDown(l)||!adj[l.a]||!adj[l.b])continue;const key=l.a<l.b?l.a+'|'+l.b:l.b+'|'+l.a;let e=edges[key];
|
||
if(!e){e=edges[key]={id:key,a:l.a,b:l.b,km:l.km,cap:0,w:Infinity,lat:Infinity,links:[]};adj[l.a].push([l.b,e]);adj[l.b].push([l.a,e]);}e.cap+=capOf(l);e.links.push(l);e.w=Math.min(e.w,(l.km+60)*MET[l.metric||'normal'].f*(TRX&&TRX.avoid.has(key)?60:1));e.lat=Math.min(e.lat,linkLat(l));}
|
||
const SP={};
|
||
const wW=e=>e.w;for(const s of pops)SP[s]=dijkstra(adj,s,wW);
|
||
const prevU=e=>{let ld=0;for(const l of e.links)ld+=(R.load&&R.load[l.id])||0;return e.cap?ld/e.cap:0;};
|
||
const dijk=(s0,mode)=>dijkstra(adj,s0,mode==='fast'?e=>e.lat+0.05:e=>e.w*(1+10*prevU(e)));
|
||
const E=[], ev=S.ev;
|
||
const depeer=ev.depeer>day||scnRule('spat'), leak=ev.leak&&ev.leak.until>day?ev.leak.net:null;
|
||
for(const t of S.transit){if(!popUp(t.city)||t.down>day||!liveN(t.city,t.site,t.n))continue;
|
||
E.push({k:'t',prem:!!t.premium&&t.city==='hkg',pref:t.pref||'normal',lab:tr('{net} transit',{net:NET[t.net].name}),id:t.id,city:t.city,cap:Math.min(liveCap(PORT[t.tier].g,t.city,t.site,t.n)*lagF(t),TRX&&TRX.cap[t.net]!==undefined?TRX.cap[t.net]:Infinity),used:0,rank:3,ok:n=>!(depeer&&t.net==='cog'&&n==='ggl')&&n!==leak});}
|
||
for(const c in S.ixp){const ct=ixCity(c);if(!(popUp(ct)||remote.includes(ct))||(S.ev.ixdown&&S.ev.ixdown[c]>day)||!liveN(ct,(S.ixSite||{})[c],(S.ixn||{})[c]))continue;const set=ixSessions(c);R2.sessions+=set.size;
|
||
E.push({k:'ix',pref:(S.ixPref&&S.ixPref[c])||'normal',lab:tr('{ix} peering',{ix:ixName(c)}),id:c,city:ct,cap:ixCap(c),used:0,rank:2,ok:n=>set.has(n)});}
|
||
for(const p of S.pni){if(!popUp(p.city)||!liveN(p.city,p.site,p.n))continue;R2.sessions++;E.push({k:'p',pnc:!!NET[p.net].cn,pref:p.pref||'normal',lab:tr('PNI with {net}',{net:NET[p.net].name}),id:p.id,city:p.city,cap:liveCap(PORT[p.tier].g,p.city,p.site,p.n)*lagF(p)*(p.sacrif?0.5:1),used:0,rank:1,ok:n=>n===p.net||!!(NET[n].up&&NET[n].up.includes(p.net))});}
|
||
for(const c of S.caches){if(!popUp(c.city)||siteDown(c.city,c.site==='b'?'b':'a'))continue;E.push({k:'c',pref:'normal',lab:tr('{name} cache',{name:NET[c.net].cache.name}),id:c.id,city:c.city,cap:CACHE_CAP,used:0,rank:0,ok:n=>n===c.net});}
|
||
// After an update adds networks, a free courtesy route reaches the new ones you have no other way to (#46).
|
||
R2.graceNets=0;if(S.grace&&S.grace.until>day){const gs=new Set(S.grace.nets.filter(n=>NET[n]&&!E.some(e=>e.k!=='c'&&e.ok(n)))),hc=popUp(S.home)?S.home:pops.find(popUp);
|
||
R2.graceNets=gs.size;if(gs.size&&hc)E.push({k:'ix',pref:'normal',lab:tr('Courtesy route to new networks'),id:'~grace',city:hc,cap:1e9,used:0,rank:2,ok:n=>gs.has(n)});}
|
||
{const rp=ev.rpki&&ev.rpki.until>day?new Set(ev.rpki.nets):null;if(rp)for(const e of E){if(e.k==='c')continue;const o=e.ok;e.ok=n=>!rp.has(n)&&o(n);}}
|
||
for(const n of NETS){R2.reachable[n.id]=E.some(e=>e.rank>0&&e.ok(n.id));if(R2.reachable[n.id])R2.reach+=NSH[n.id];}
|
||
const cacheNets=new Set(S.caches.filter(c=>popUp(c.city)).map(c=>c.net));
|
||
const viral=(ev.viral>day?1.25:1)*(ev.php&&ev.php>day?0.7:1);
|
||
const flows=[];
|
||
for(const c of Object.keys(S.pops)){
|
||
const p=S.pops[c],SH=cnCity(c)?NSH_CN:ruCity(c)?NSH_RU:CITY[c].kr&&S.krExit?NSH_KRX:NSH;const eye=(p.bb?p.bb.d:0)*viral*(cnCity(c)&&ev.golden>day?1.4:1);const biz=S.biz.filter(b=>b.city===c&&!BIZ_T[b.type].l2&&!BIZ_T[b.type].fiber&&(!BIZ_T[b.type].event||eventLive(b))).reduce((a,b)=>a+b.bw,0);const d0=eye+biz;
|
||
// Goggle video is throttled in Russia (#70): people there get half of it, so they ask for half. It is not
|
||
// traffic you failed to deliver, and it does not cross your links only to be thrown away.
|
||
const thr=n=>n==='ggl'&&ruCity(c)?0.5:1,d=d0*NETS.reduce((t,n)=>t+(SH[n.id]||0)*thr(n.id),0)/(NETS.reduce((t,n)=>t+(SH[n.id]||0),0)||1);
|
||
R2.cityEye[c]=eye;R2.cityDem[c]=d;R2.citySrv[c]=0;R2.demand+=d;
|
||
for(const n of NETS)R2.demTo[n.id]=(R2.demTo[n.id]||0)+d0*(SH[n.id]||0)*thr(n.id);
|
||
if(!popUp(c))continue;
|
||
// A shaped attack: `rtbh` is the player pulling the plug on the victim IP (junk gone, customer dark too);
|
||
// `edge` is the crude RouteScript `blackhole ddos` filter (junk gone, 10% of real traffic with it). Flowspec
|
||
// (a standing licence) and a scrubbing center each knock the flood down before it reaches the sim.
|
||
const atk=ev.ddos&&ev.ddos.city===c&&ev.ddos.until>day?ev.ddos:null;
|
||
const rtbh=!!(atk&&atk.bh), edge=!!(atk&&TRX&&TRX.blackhole&&!rtbh);
|
||
let dd=0;
|
||
if(atk&&!rtbh){let mult=1;const en=atk.entry||{};
|
||
if(DDOS_VEC[atk.vec]&&DDOS_VEC[atk.vec].fs){const cap=fsAt(atk.city);if(cap)mult=Math.min(mult,FS_RES[cap]);}
|
||
mult=Math.min(mult,scrubMult(atk));
|
||
if(en.k==='t'){const t=S.transit.find(x=>x.id===en.id);if(t&&t.clean)mult=Math.min(mult,0.1);}
|
||
if(atk.ixbh&&hasIxAt(atk.city))mult=Math.min(mult,0.5);
|
||
if(edge)mult=0;
|
||
dd=atk.gbps*mult;
|
||
if(en.k==='p'){const p=S.pni.find(x=>x.id===en.id);if(p&&p.sacrif)dd=Math.min(dd,liveCap(PORT[p.tier].g,p.city,p.site,p.n)*0.9);}}
|
||
const bh=rtbh||edge;
|
||
if(dd>0)for(const n of NETS)flows.push({c,n:n.id,rem:dd*NSH[n.id],junk:true});
|
||
if(edge)R2.teBlack+=atk.gbps*0.15+d*0.1;if(rtbh)R2.teBlack+=atk.gbps+d;
|
||
R2.cityBlocked=R2.cityBlocked||{};
|
||
const mtuH=ev.pmtud&&ev.pmtud.until>day?ev.pmtud:null,kr=CITY[c].kr;
|
||
for(const n of NETS){const a=d0*(SH[n.id]||0)*thr(n.id)*(rtbh?0:edge?0.9:1)*(mtuH&&mtuH.net===n.id?mtuH.f:1)*(kr&&ev.krroute>day&&n.id==='fbk'?0.8:1);if(a<=0)continue;
|
||
if(cacheNets.has(n.id)){flows.push({c,n:n.id,rem:a*0.85,cache:true});flows.push({c,n:n.id,rem:a*0.15});}
|
||
else flows.push({c,n:n.id,rem:a});}
|
||
}
|
||
const res={},eload={},nres={};for(const k in edges)res[k]=edges[k].cap;for(const c of pops){nres[c]=nodeCap(c);R2.nodeCap[c]=nres[c];}
|
||
R2.l2route={};R2.l2split={};
|
||
const l2walk=(sp,A,B)=>{const path=[],ns=[B];let v=B;while(v!==A){const l=sp.prev[v];path.push(l);v=l.a===v?l.b:l.a;ns.push(v);}return {path,ns};};
|
||
/* Scenic routing (#28). "Busy" is judged without the customer's own traffic, or it flees its own load and
|
||
flips paths every day. Two paths that are about as quiet share the load, and yesterday's choice is kept
|
||
unless today's is clearly better. */
|
||
const l2Routes=(A,B,b)=>{const m=b.route||'normal';
|
||
if(m!=='scenic')return [{...l2walk(m==='fast'?dijk(A,'fast'):SP[A],A,B),share:1}];
|
||
const ek='l2:'+b.id,own=e=>(R.ef&&R.ef[e.id]&&R.ef[e.id].eg[ek])||0;
|
||
const wf=e=>{let ld=0;for(const l of e.links)ld+=(R.load&&R.load[l.id])||0;return e.w*(1+10*(e.cap?Math.max(0,ld-own(e))/e.cap:0));};
|
||
const cost=r=>r.path.reduce((x,e)=>x+wf(e),0)*r.share;
|
||
const s1=dijkstra(adj,A,wf,null,B);if(s1.dist[B]===undefined)return [{...l2walk(SP[A],A,B),share:1}];
|
||
const p1=l2walk(s1,A,B),c1=cost({path:p1.path,share:1}),used=new Set(p1.path.map(e=>e.id));let pick2=[{...p1,share:1}];
|
||
const s2=dijkstra(adj,A,wf,(v,e)=>used.has(e.id),B);
|
||
if(s2.dist[B]!==undefined){const p2=l2walk(s2,A,B);if(cost({path:p2.path,share:1})<=c1*1.15)pick2=[{...p1,share:0.5},{...p2,share:0.5}];}
|
||
const key=b.id+'>'+A+'>'+B,old=R.l2route&&R.l2route[key];let out=pick2;
|
||
if(old&&old.every(r=>r.keys.every(k=>edges[k]))){const prev=old.map(r=>{const path=r.keys.map(k=>edges[k]);return {path,ns:r.ns,share:r.share};});
|
||
if(prev.reduce((x,r)=>x+cost(r),0)<=pick2.reduce((x,r)=>x+cost(r),0)*1.1)out=prev;}
|
||
R2.l2route[key]=out.map(r=>({keys:r.path.map(e=>e.id),ns:r.ns,share:r.share}));return out;};
|
||
for(const b of S.biz){if(!BIZ_T[b.type].l2)continue;
|
||
// An SD-WAN is hub-and-spoke: one circuit from the first site to each of the others.
|
||
const pairs=b.sites?b.sites.slice(1).map(x=>[b.sites[0],x]):[[b.city,b.city2]];let minF=1,maxLat=0,tot=0,noPath=false;
|
||
for(const [A,B] of pairs){let amt=0;
|
||
if(popUp(A)&&popUp(B)&&SP[A]&&SP[A].dist[B]!==undefined){
|
||
const ek='l2:'+b.id;R2.egDesc[ek]={lab:b.sites?tr('SD-WAN for {name}',{name:b.name}):tr('L2VPN for {name}',{name:b.name}),city:A,k:'l2'};
|
||
const routes=l2Routes(A,B,b);if(routes.length>1)R2.l2split[b.id]=routes.length;
|
||
for(const {path,ns,share} of routes){let a=b.bw*share;for(const l of path)a=Math.min(a,res[l.id]);for(const n of ns)if(nres[n]!==undefined)a=Math.min(a,nres[n]);a=Math.max(0,a);amt+=a;maxLat=Math.max(maxLat,path.reduce((x,e)=>x+e.lat,0)+path.length*0.05);
|
||
for(const n of ns)if(nres[n]!==undefined){nres[n]-=a;R2.nodeLoad[n]=(R2.nodeLoad[n]||0)+a;}
|
||
for(const l of path){res[l.id]-=a;eload[l.id]=(eload[l.id]||0)+a;const rec=R2.ef[l.id]||(R2.ef[l.id]={eg:{},net:{},dst:{}});rec.eg[ek]=(rec.eg[ek]||0)+a;rec.net.l2vpn=(rec.net.l2vpn||0)+a;rec.dst[B]=(rec.dst[B]||0)+a;}}}
|
||
else noPath=true;
|
||
minF=Math.min(minF,amt/b.bw);tot+=amt;}
|
||
R2.l2lat[b.id]=noPath?Infinity:maxLat;R2.l2[b.id]=b.bw*minF;R2.egT.l2=(R2.egT.l2||0)+tot;if((b.reqs||[]).includes('diverse'))R2.div[b.id]=diversePaths(b.city,b.city2);}
|
||
const TE=!!(S.te&&S.te.on),TR=teRules();R2.teMoved=0;const teCache={},SPILL=TR&&TR.spill?TR.spill:1;
|
||
const spPath=(sp,src,dst)=>{const path=[],ns=[dst];let v=dst;while(v!==src){const l=sp.prev[v];path.push(l);v=l.a===v?l.b:l.a;ns.push(v);}return {path,ns};};
|
||
const altPath=(src,dst,base)=>{const key=src+'>'+dst,c0=teCache[key];
|
||
if(c0===false)return null;if(c0&&c0.path.every(l=>res[l.id]>1e-3)&&c0.ns.every(n=>nres[n]===undefined||nres[n]>1e-3))return c0;
|
||
const {dist,prev}=dijkstra(adj,src,wW,(v,e)=>res[e.id]<=1e-3||(nres[v]!==undefined&&nres[v]<=1e-3),dst);
|
||
if(dist[dst]===undefined||dist[dst]>2*base+60){teCache[key]=false;return null;}
|
||
const P=spPath({prev},src,dst);teCache[key]=P;return P;};
|
||
const base=e=>e.pref==='low'?4:e.rank;
|
||
const eff=(e,n)=>{let r=base(e);if(TR){if(e.k!=='c'&&TR.drain.has(e.city))r=4.6;const o=TR.net[n];if(o){if(o.prefer===e.k)r=0.5;else if(o.avoid===e.k)r=4.5;}}return r;};
|
||
const RANKS=TR?[0,0.5,1,2,3,4,4.5,4.6]:[0,1,2,3,4];
|
||
for(const rank of RANKS){
|
||
const Er=TR?E:E.filter(e=>base(e)===rank);if(!Er.length)continue;const sorted={};
|
||
for(const f of flows){
|
||
if(f.rem<=1e-6||(rank===0&&!f.cache))continue;
|
||
const sp=SP[f.c];
|
||
const srt=sorted[f.c]||(sorted[f.c]=Er.filter(e=>sp.dist[e.city]!==undefined).sort((a,b)=>(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||sp.dist[a.city]-sp.dist[b.city]));
|
||
const cands=srt.filter(e=>e.used<e.cap&&e.ok(f.n)&&(!TR||eff(e,f.n)===rank));
|
||
// Exits with the same preference and the same IGP distance form an ECMP group: spread the flow over
|
||
// them by free capacity (like several transits in one city), then top up in order if one fills.
|
||
// Push up to `want` along one path to exit e; returns what fitted.
|
||
const push=(e,P,want,keep=0)=>{const path=P.path,ns=P.ns;let amt=want;
|
||
for(const l of path)amt=Math.min(amt,res[l.id]-l.cap*keep);for(const n of ns)if(nres[n]!==undefined)amt=Math.min(amt,nres[n]);
|
||
if(amt<=1e-6)return 0;
|
||
for(const n of ns)if(nres[n]!==undefined){nres[n]-=amt;R2.nodeLoad[n]=(R2.nodeLoad[n]||0)+amt;}
|
||
const ek=e.k+':'+e.id;R2.egDesc[ek]={lab:e.lab,city:e.city,k:e.k};
|
||
for(const l of path){res[l.id]-=amt;eload[l.id]=(eload[l.id]||0)+amt;const rec=R2.ef[l.id]||(R2.ef[l.id]={eg:{},net:{},dst:{}});rec.eg[ek]=(rec.eg[ek]||0)+amt;const nk=f.junk?'junk':f.n;rec.net[nk]=(rec.net[nk]||0)+amt;rec.dst[f.c]=(rec.dst[f.c]||0)+amt;}
|
||
e.used+=amt;f.rem-=amt;
|
||
if(!f.junk){let ok=amt;const fc=cnCity(f.c),ec=cnCity(e.city),nc=!!NET[f.n].cn;
|
||
if(fc!==ec||(fc&&!nc)||(!fc&&nc&&e.k==='t')){const prem=(e.k==='t'&&e.prem)||(e.k==='p'&&e.pnc)||path.some(x=>x.links&&x.links.some(y=>y.premium));const loss=prem?0.03:(ev.gfw>day?0.35:0.2);R2.gfwLost+=amt*loss;R2.gfwCross+=amt;ok=amt*(1-loss);}
|
||
R2.citySrv[f.c]+=ok;R2.served+=ok;if(e.rank<=2)R2.peered+=ok;if(e.k==='t'){const m=R2.tNet[e.id]||(R2.tNet[e.id]={});m[f.n]=(m[f.n]||0)+ok;}R2.egT[e.k]=(R2.egT[e.k]||0)+ok;const ne=R2.netEg[f.n]||(R2.netEg[f.n]={c:0,p:0,ix:0,t:0});ne[e.k]+=ok;}
|
||
return amt;
|
||
};
|
||
// Shortest path first. With Auto-TE, whatever does not fit spills onto up to two alternate paths
|
||
// with free capacity, as long as they are no more than twice as long.
|
||
const send=(e,want)=>{
|
||
let room=Math.min(want,f.rem,e.cap-e.used);if(room<=1e-6)return;
|
||
room-=push(e,spPath(sp,f.c,e.city),room,TE&&SPILL<1?1-SPILL:0);
|
||
if(TE&&room>1e-6&&f.rem>1e-6&&e.used<e.cap&&e.city!==f.c)for(let k=0;k<2&&room>1e-6;k++){const P=altPath(f.c,e.city,sp.dist[e.city]);if(!P)break;const m=push(e,P,Math.min(room,e.cap-e.used));if(m<=1e-6)break;room-=m;R2.teMoved+=m;}
|
||
};
|
||
const gk=e=>(e.pref==='high'?0:1);
|
||
for(let i=0;i<cands.length&&f.rem>1e-6;){
|
||
let j=i+1;while(j<cands.length&&gk(cands[j])===gk(cands[i])&&Math.abs(sp.dist[cands[j].city]-sp.dist[cands[i].city])<1e-6)j++;
|
||
const g=cands.slice(i,j);i=j;
|
||
if(g.length>1){const room=g.map(e=>Math.max(0,e.cap-e.used)),tot=room.reduce((a,b)=>a+b,0),want=f.rem;if(tot>1e-6)g.forEach((e,k)=>send(e,want*room[k]/tot));}
|
||
for(const e of g){if(f.rem<=1e-6)break;send(e,f.rem);}
|
||
}
|
||
}
|
||
}
|
||
for(const k in edges){const e=edges[k],ld=eload[k]||0;for(const l of e.links)R2.load[l.id]=ld*capOf(l)/e.cap;}
|
||
R2.peerShare=R2.served>0?R2.peered/R2.served:0;
|
||
for(const e of E){if(e.k==='t')R2.useT[e.id]=e.used;else if(e.k==='ix')R2.useIx[e.id]=e.used;else if(e.k==='p')R2.usePni[e.id]=e.used;else R2.useCache[e.id]=e.used;}
|
||
// money
|
||
const C=R2.cost,V=R2.rev,pm=S.priceMul;
|
||
C.pops=Object.values(S.pops).reduce((a,p)=>a+POP_MO+((p.routers||1)-1)*ROUTER_MO+(p.routers||1)*RG[p.rgen||0].mo+(p.gen?GEN_MO:0),0);
|
||
C.optical=S.links.filter(l=>l.kind==='df').reduce((a,l)=>a+(l.ready>S.day?0:ampCount(l.km)*AMP_MO*(l.own&&isRdm(l.sys)&&!l.sub?Math.max(1,l.pairs|0):1)+(l.regen|0)*REGEN_MO)+(l.spares?Math.round(150+(l.ch||[]).length*80):0),0);
|
||
C.links=S.links.reduce((a,l)=>a+(l.mo||0),0);
|
||
C.nni=(S.nni||[]).reduce((a,x)=>a+NNI[x.tier].mo,0);
|
||
C.transit=S.transit.reduce((a,t)=>{const q=p95(t,R2.useT[t.id]||0);R2.p95[t.id]=q;return a+transitMo(t,q);},0);
|
||
C.ix=Object.keys(S.ixp).reduce((a,c)=>a+ixMo(c),0);
|
||
C.pni=S.pni.reduce((a,p)=>a+pniMo(p,R2.usePni[p.id]||0),0);
|
||
C.caches=S.caches.length*CACHE_MO;
|
||
C.loans=(S.loans||[]).reduce((a,l)=>a+(BANKS[l.bank].equity?0:l.model==='transit'?Math.round((C.transit||0)*(l.cut||0.3)):l.pay)+loanFees(l),0);
|
||
C.extras=(S.cnLic&&S.cnLic.state==='ok'?CN_JV_MO:0)+(S.scrubAt?scrubMo():0)+Object.keys(S.pops).filter(ruCity).length*RU_BOX_MO+Object.values(S.pops).filter(p=>p.site2).length*SITE2_MO+(S.te?TE_MO:0);
|
||
V.eyeballs=0;V.business=0;V.ix=0;
|
||
for(const c in S.pops){const sf=sfOf(R2,c);V.eyeballs+=R2.cityEye[c]*sf*EYE_RATE*(CITY[c].arpu||1);}
|
||
for(const b of S.biz){const sf=BIZ_T[b.type].fiber?(fiberOk(b)?1:0):BIZ_T[b.type].l2?clamp((R2.l2[b.id]||0)/b.bw,0,1):sfOf(R2,b.city);V.business+=b.bw*b.rate*Math.min(1,sf/0.95);}
|
||
for(const c in S.myIx)V.ix+=S.myIx[c].members.length*MYIX_FEE;
|
||
C.revshare=(S.loans||[]).reduce((a,l)=>a+(BANKS[l.bank].equity||l.bal>0?l.share||0:0),0)*(V.eyeballs+V.business+V.ix);
|
||
R2.costMo=Object.values(C).reduce((a,b)=>a+b,0);
|
||
R2.revMo=V.eyeballs+V.business+V.ix;
|
||
R=R2;UI.hotMap=hotByCity();
|
||
}
|
||
function p95(t,cur){const h=(t.hist||[]).slice(-29).concat([cur]).sort((a,b)=>a-b);return h[Math.max(0,Math.ceil(.95*h.length)-1)];}
|
||
function linkDown(l){return l.cut>S.day||(S.ev.runet>S.day&&ruCity(l.a)!==ruCity(l.b))||(S.ev.gulf>S.day&&((CITY[l.a].qa&&(CITY[l.b].gcc||CITY[l.b].uae))||(CITY[l.b].qa&&(CITY[l.a].gcc||CITY[l.a].uae))))||(l.kind==='vxc'&&!!S.ev.fab&&S.ev.fab[l.prov]>S.day)||(l.kind==='df'&&dfCap(l)<=0);}
|
||
function remoteCities(){return [...new Set(S.links.filter(l=>l.kind==='vxc').flatMap(l=>[l.a,l.b]))].filter(c=>!S.pops[c]);}
|
||
function nniUsed(c,prov){return S.links.filter(l=>l.kind==='vxc'&&l.prov===prov&&(l.a===c||l.b===c)).reduce((a,l)=>a+VXC[l.vt].g,0)+S.biz.filter(b=>BIZ_T[b.type].nni&&b.prov===prov&&b.city===c).reduce((a,b)=>a+b.bw,0);}
|
||
// Monthly price of one connection; compute() sums these, the connections overview lists them.
|
||
function transitMo(t,q){const n=t.n||1;return Math.max(q,PORT[t.tier].g*n*0.2)*NET[t.net].price*(t.premium&&t.city==='hkg'?NET[t.net].premium:1)*S.priceMul*regionMult(t.city)+PORT[t.tier].tmo*n+(t.clean?cleanMo(t):0);}
|
||
function pniMo(p,use){return PORT[p.tier].pni*(p.n||1)+(NET[p.net].pol==='paid'&&!paidFree(NET[p.net])?NET[p.net].paidFee:0)+(NET[p.net].perG?Math.round(NET[p.net].perG*use):0);}
|
||
function ixMo(c){return S.myIx[c]?myFab(c).mo:ixPortMo(c,S.ixp[c])*((S.ixn||{})[c]||1)+dkAddonMo(c);}
|
||
function nniPort(c,prov){return (S.nni||[]).find(x=>x.city===c&&x.prov===prov);}
|
||
function repayCost(l,B){return B.equity?Math.round(l.amount*3):Math.round(Math.max(l.bal,B.crypto&&l.got?l.got:0)*1.02);}
|
||
const own=(o,k)=>Object.prototype.hasOwnProperty.call(o,k);
|
||
const isCity=c=>typeof c==='string'&&own(CITY,c),isIx=x=>typeof x==='string'&&(own(CITY,x)||own(XIXM,x)),isNet=n=>typeof n==='string'&&own(NET,n);
|
||
const num=(v,d=0)=>{v=+v;return Number.isFinite(v)?v:d;},int=(v,lo,hi,d)=>{v=Math.round(num(v,d));return Math.min(hi,Math.max(lo,v));};
|
||
/* Saves come from localStorage or from imported files, so treat them as untrusted: fill in anything
|
||
missing, drop references to cities, networks or types that do not exist, and force numbers to be numbers. */
|
||
function sanitize(s){
|
||
const arr=k=>{if(!Array.isArray(s[k]))s[k]=[];},obj=k=>{if(!s[k]||typeof s[k]!=='object'||Array.isArray(s[k]))s[k]={};};
|
||
['links','nni','transit','pni','caches','biz','offers','inc','usedNames','loans','loanOffers','hist','log'].forEach(arr);
|
||
['pops','ixp','rs','peers','myIx','done','ev','stats','ixn','ixPref','ixSite','confReg','ach'].forEach(obj);
|
||
s.v=1;s.name=String(s.name==null?'Packet Pals':s.name).slice(0,24);s.day=int(s.day,0,1e7,0);s.cash=num(s.cash,0);s.asn=int(s.asn,1,4294967294,200000);
|
||
s.priceMul=num(s.priceMul,1);s.nextFail=num(s.nextFail,s.day+45);s.nextEvent=num(s.nextEvent,s.day+40);s.lvl=int(s.lvl,1,LEVELS.length,1);s.neg=int(s.neg,0,1e7,0);s.loanStrikes=int(s.loanStrikes,0,1e3,0);
|
||
for(const k of Object.keys(s.stats)){const v=s.stats[k];if(k==='by'||k==='f'){if(!v||typeof v!=='object')s.stats[k]={};else for(const j of Object.keys(v))v[j]=num(v[j],0);}else if(typeof v!=='boolean')s.stats[k]=num(v,0);}
|
||
for(const k of ['survived','incidents','peak'])s.stats[k]=num(s.stats[k],0);
|
||
for(const c of Object.keys(s.pops)){const p=s.pops[c];if(!isCity(c)||!p||typeof p!=='object'){delete s.pops[c];continue;}p.routers=int(p.routers,1,RMAX,1);if(p.rupDay!==undefined)p.rupDay=num(p.rupDay,-1);if(p.rgen!==undefined)p.rgen=int(p.rgen,0,RG.length-1,0);p.down=num(p.down,0);if(p.bb&&typeof p.bb==='object')p.bb.d=num(p.bb.d,0);else p.bb=null;}
|
||
if(!isCity(s.home))s.home=Object.keys(s.pops)[0]||'fra';
|
||
const tier=v=>int(v,0,PORT.length-1,0),lag=v=>int(v,1,LAG_MAX,1),sid=v=>String(v==null?uid():v).slice(0,40);
|
||
s.links=s.links.filter(l=>l&&isCity(l.a)&&isCity(l.b)&&l.a!==l.b).map(l=>{l.id=sid(l.id);l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.pairs!==undefined)l.pairs=Math.min(l.sub?SUB_PAIRS_MAX:s.lvl>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,Math.max(1,Math.floor(+l.pairs)||1));if(l.kind!=='df'&&l.kind!=='vxc')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&!own(CAB,l.cable))l.cable=null;if(l.kind==='vxc'&&!own(VXC,l.vt))l.vt=0;if(l.kind==='df'){if(!own(DF_SYS,l.sys))l.sys='lite';l.ch=Array.isArray(l.ch)?l.ch.filter(o=>own(OPT,o)):[];l.ready=num(l.ready,0);l.regen=int(l.regen,0,REGEN_MAX,0);}const deg=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;if(l.loss)l.loss=deg(l.loss);if(l.metric&&!own(MET,l.metric))l.metric='normal';return l;});
|
||
const degO=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;
|
||
s.transit=s.transit.filter(t=>t&&isCity(t.city)&&isNet(t.net)).map(t=>(t.lacp=degO(t.lacp),t.site=['a','b','ab'].includes(t.site)?t.site:'a',t.id=sid(t.id),t.tier=tier(t.tier),t.n=lag(t.n),t.down=num(t.down,0),t.clean=!!t.clean,t));
|
||
s.pni=s.pni.filter(x=>x&&isCity(x.city)&&isNet(x.net)).map(x=>(x.lacp=degO(x.lacp),x.site=['a','b','ab'].includes(x.site)?x.site:'a',x.id=sid(x.id),x.tier=tier(x.tier),x.n=lag(x.n),x.sacrif=!!x.sacrif,x));
|
||
{const sp={};if(s.spares&&typeof s.spares==='object')for(const k in s.spares)if(own(OPT,k)){const v=Math.floor(+s.spares[k]);if(v>0)sp[k]=Math.min(999,v);}s.spares=sp;}
|
||
s.caches=s.caches.filter(x=>x&&isCity(x.city)&&isNet(x.net)&&NET[x.net].cache).map(x=>(x.id=sid(x.id),x.site=x.site==='b'&&s.pops[x.city]&&s.pops[x.city].site2?'b':'a',x));
|
||
for(const c of Object.keys(s.ixp)){if(!isIx(c))delete s.ixp[c];else s.ixp[c]=tier(s.ixp[c]);}
|
||
for(const k of ['rs','ixn','ixPref','ixSite'])for(const c of Object.keys(s[k]))if(!isIx(c))delete s[k][c];if(s.ixCut&&typeof s.ixCut==='object'){for(const c of Object.keys(s.ixCut))if(!isIx(c))delete s.ixCut[c];else s.ixCut[c]=Math.min(1,Math.max(0.6,num(s.ixCut[c],1)));}else delete s.ixCut;
|
||
for(const c of Object.keys(s.ixn))s.ixn[c]=lag(s.ixn[c]);for(const c of Object.keys(s.ixSite))if(!['a','b','ab'].includes(s.ixSite[c]))s.ixSite[c]='a';
|
||
for(const k of Object.keys(s.peers)){const [n,c]=k.split('@');if(!isNet(n)||!isIx(c))delete s.peers[k];}
|
||
for(const c of Object.keys(s.myIx)){const m=s.myIx[c];if(!isCity(c)||!m||typeof m!=='object'){delete s.myIx[c];continue;}m.members=Array.isArray(m.members)?m.members.filter(isNet):[];m.name=String(m.name||tr('Your IX')).slice(0,40);m.next=num(m.next,s.day);m.fab=int(m.fab,0,MYIX_FAB.length-1,0);}
|
||
const okBiz=b=>b&&own(BIZ_T,b.type)&&(!BIZ_T[b.type].nni||own(FAB,b.prov))&&isCity(b.city)&&(!b.city2||isCity(b.city2))&&(!b.sites||Array.isArray(b.sites)&&b.sites.every(isCity));
|
||
const fixBiz=b=>{b.id=sid(b.id);b.name=String(b.name||tr('Customer')).slice(0,80);b.bw=num(b.bw,1);b.rate=num(b.rate,0);if(b.fee!==undefined)b.fee=num(b.fee,0);if(b.start!==undefined)b.start=num(b.start,0);if(b.dur!==undefined)b.dur=num(b.dur,1);if(b.slots!==undefined)b.slots=num(b.slots,0);if(b.what!==undefined)b.what=String(b.what).slice(0,200);if(!Array.isArray(b.reqs))b.reqs=[];b.reqs=b.reqs.filter(r=>own(REQS,r));if(b.mood!==undefined)b.mood=num(b.mood,100);if(b.pm!==undefined)b.pm=num(b.pm,b.mood||100);if(b.exp!==undefined)b.exp=num(b.exp,0);if(b.latMax!=null)b.latMax=num(b.latMax,10);if(b.route&&!own(RT,b.route))b.route='normal';return b;};
|
||
s.biz=s.biz.filter(okBiz).map(fixBiz);s.offers=s.offers.filter(okBiz).map(fixBiz);
|
||
s.inc=s.inc.filter(i=>i&&typeof i.type==='string').map(i=>(i.id=sid(i.id),i.until=num(i.until,s.day),i.cost=num(i.cost,0),i.msg=String(i.msg||'').slice(0,400),i.fix=i.fix==null?undefined:String(i.fix).slice(0,60),i));
|
||
s.loans=s.loans.filter(l=>l&&own(BANKS,l.bank));for(const l of s.loans){if(l.model!==undefined&&!['balloon','storm','transit','astro'].includes(l.model))delete l.model;for(const k of ['apr0','cut','share'])if(l[k]!==undefined&&!isFinite(+l[k]))delete l[k];if(!Array.isArray(l.covs))l.covs=[];l.covs=l.covs.filter(c=>own(COVS,c));}s.loanOffers=s.loanOffers.filter(l=>l&&own(BANKS,l.bank));
|
||
s.usedNames=s.usedNames.filter(x=>typeof x==='string');s.log=s.log.filter(e=>e&&typeof e.t==='string').slice(0,30);
|
||
if(s.scrubAt&&!isCity(s.scrubAt))s.scrubAt=null;
|
||
s.scrubTier=int(s.scrubTier,0,SCRUB_TIERS.length-1,0);s.scrubMode=s.scrubMode==='ondemand'?'ondemand':'always';
|
||
if(s.ev&&s.ev.ddos){const a=s.ev.ddos;
|
||
if(!a||typeof a!=='object'||!isCity(a.city)||!own(DDOS_VEC,a.vec))delete s.ev.ddos;
|
||
else{a.gbps=num(a.gbps,2);a.until=num(a.until,s.day);a.bh=!!a.bh;a.ixbh=!!a.ixbh;a.start=num(a.start,s.day);
|
||
if(!a.entry||typeof a.entry!=='object')a.entry={k:'edge',lab:''};else{a.entry.lab=String(a.entry.lab||'').slice(0,60);a.entry.id=a.entry.id==null?undefined:String(a.entry.id).slice(0,40);}}}
|
||
if(s.te){if(typeof s.te!=='object')s.te=null;else{s.te.on=!!s.te.on;s.te.script=typeof s.te.script==='string'?s.te.script.slice(0,4000):'';}}
|
||
return s;}
|
||
function migrate(s){sanitize(s);for(const b of [...s.biz,...s.offers])if(Array.isArray(b.reqs))b.reqs=b.reqs.filter(k=>!REQS[k]||!REQS[k].can||(isCity(b.city)&&(!b.city2||isCity(b.city2))&&REQS[k].can(b,s)));if(s.ltv!==2){for(const l of s.links)if(l.kind==='wave'&&l.tier>=3)l.tier=Math.min(LT.length-1,l.tier+1);s.ltv=2;}if(s.dk){s.dk.m=s.dk.m||{};s.dk.add=s.dk.add||{};s.dk.ret=s.dk.ret||{};s.dk.retUsed=s.dk.retUsed||{};}s.hist=s.hist||[];s.loans=s.loans||[];s.loanOffers=s.loanOffers||[];s.loanStrikes=s.loanStrikes||0;for(const l of s.links||[])if(!l.kind)l.kind='wave';
|
||
for(const c in s.pops){const p=s.pops[c];if(p.rgen===undefined){let g=0;const need=(i,key)=>{const k=RG.findIndex(r=>r[key]>=i);if(k>g)g=k;};
|
||
for(const l of s.links||[])if((l.a===c||l.b===c)&&l.kind==='wave')need(l.tier,'maxLT');
|
||
for(const t of s.transit||[])if(t.city===c)need(t.tier,'maxP');for(const x of s.pni||[])if(x.city===c)need(x.tier,'maxP');if(s.ixp&&s.ixp[c]!==undefined)need(s.ixp[c],'maxP');p.rgen=g;}}for(const b of s.biz||[])if(!b.reqs)b.reqs=BIZ_T[b.type]&&BIZ_T[b.type].div?['diverse']:[];for(const o of s.offers||[])if(!o.reqs)o.reqs=[];if(!s.lvl)s.lvl=1;s.nni=s.nni||[];s.cnLic=s.cnLic||{state:'none'};if(s.scrubAt===undefined)s.scrubAt=null;s.ev=s.ev||{};for(const l of s.links){if(!l.kind)l.kind='wave';if(l.mo===undefined)l.mo=Math.round(waveMo(l.km,l.sub,l.tier)*(l.mult||1));}for(const c in s.pops){if(!s.pops[c].routers)s.pops[c].routers=1;}
|
||
{const all=NETS.map(n=>n.id),seen=Array.isArray(s.seen)?s.seen.filter(x=>typeof x==='string'):null,fresh=seen?all.filter(id=>!seen.includes(id)):all;
|
||
if(fresh.length&&(s.day||0)>0){const g=s.grace&&s.grace.until>s.day?s.grace:{nets:[]};s.grace={until:s.day+GRACE_DAYS,nets:[...new Set(g.nets.concat(fresh))],fresh:seen?fresh.length:0};}
|
||
s.seen=all;}
|
||
if(s.grace&&(typeof s.grace!=='object'||!isFinite(s.grace.until)||!Array.isArray(s.grace.nets)))s.grace=null;if(s.grace)s.grace.nets=s.grace.nets.filter(isNet);
|
||
return s;}
|
||
const GRACE_DAYS=60;
|
||
const REQS={
|
||
lat:{only:true,l2:true,bonus:0,l:o=>tr('One-way latency within {max} ms (best now: {best})',{max:o.latMax,best:(()=>{const v=R.l2lat[o.id]!==undefined?R.l2lat[o.id]:bestLat(o.city,o.city2);return isFinite(v)?v.toFixed(1)+' ms':tr('no path')})()}),ok:b=>(R.l2lat[b.id]!==undefined?R.l2lat[b.id]:bestLat(b.city,b.city2))<=b.latMax},
|
||
nni:{only:true,bonus:0,l:o=>tr('Comes in over {fab}: needs your {fab} port in {city} with room for {bw}',{fab:FAB[o.prov]?FAB[o.prov].name:'?',city:CITY[o.city].name,bw:fmtG(o.bw)}),ok:b=>{const pt=nniPort(b.city,b.prov);return !!pt&&nniUsed(b.city,b.prov)<=NNI[pt.tier].g+1e-9;}},
|
||
diverse:{l:tr('Two paths that share no trench or fabric'),bonus:.25,l2:true,can:(b,s=S)=>diversityPossible(b.city,b.city2,s),ok:b=>R.div[b.id]!==undefined?!!R.div[b.id]:diversePaths(b.city,b.city2)},
|
||
sharks:{l:tr('Afraid of sharks: needs a path with no subsea cable'),bonus:.2,l2:true,ok:b=>terrestrialPath(b.city,b.city2),can:b=>!!b.city2&&!isSub(b.city,b.city2)},
|
||
nocog:{l:tr('Refuses Cogentle transit anywhere on your network (long story)'),bonus:.15,ok:()=>!S.transit.some(t=>t.net==='cog')},
|
||
ipv6:{l:tr('IPv6 or bust: you must peer with Drizzle Electric'),bonus:.1,ok:()=>Object.keys(S.ixp).some(c=>ixSessions(c).has('drz'))||S.pni.some(p=>p.net==='drz')},
|
||
netchill:{l:tr('Wants NetChill on-net: a cache or a PNI'),bonus:.15,ok:()=>S.caches.some(c=>c.net==='nfx')||S.pni.some(p=>p.net==='nfx')},
|
||
gen:{l:tr('Backup generator in every city they touch'),bonus:.15,ok:b=>[b.city,b.city2].filter(Boolean).every(c=>S.pops[c]&&S.pops[c].gen)},
|
||
routers:{l:tr('Insists on two routers in their city'),bonus:.15,ok:b=>((S.pops[b.city]&&S.pops[b.city].routers)||1)>=2},
|
||
local:{l:tr('Local breakout: transit or an IX port in their own city, or a local PNI while Tier 1'),bonus:.2,ip:true,ok:b=>S.transit.some(t=>t.city===b.city)||hasIxAt(b.city)||(isTier1()&&S.pni.some(p=>p.city===b.city))},
|
||
metro:{l:tr('Two data centers in every metro they touch'),bonus:.2,only:true,ok:b=>[b.city,b.city2].filter(Boolean).every(c=>S.pops[c]&&S.pops[c].site2)},
|
||
twoup:{l:tr('Wants two different transit providers (or none at all)'),bonus:.15,ip:true,ok:()=>new Set(S.transit.map(t=>t.net)).size>=2||S.transit.length===0},
|
||
china:{l:tr('Needs low-loss reach into China'),bonus:.3,ip:true,ok:()=>S.transit.some(t=>t.premium&&t.city==='hkg')||S.links.some(l=>l.premium)||S.pni.some(p=>NET[p.net].cn)},
|
||
scrubbed:{l:tr('Will only sign with a network that runs a DDoS scrubbing center'),bonus:.15,ok:()=>!!S.scrubAt},
|
||
puns:{l:tr('Their CEO hates puns. Please do not mention the network names.'),bonus:.05,ok:()=>true},
|
||
};
|
||
function terrestrialPath(a,b){const ls=S.links.filter(l=>!linkDown(l)&&!l.sub);const adj={};for(const l of ls){(adj[l.a]=adj[l.a]||[]).push(l.b);(adj[l.b]=adj[l.b]||[]).push(l.a);}const seen=new Set([a]),q=[a];while(q.length){const u=q.shift();if(u===b)return true;for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return false;}
|
||
const reqOk=b=>(b.reqs||[]).every(k=>REQS[k]&&REQS[k].ok(b));
|
||
// Some requirements only make sense for some customers: nobody can reach another continent without getting wet.
|
||
const reqCan=(k,b)=>!REQS[k].can||REQS[k].can(b);
|
||
function reqList(o){return (o.reqs||[]).map(k=>{const ok=REQS[k].ok(o),lab=typeof REQS[k].l==='function'?REQS[k].l(o):REQS[k].l;return `<div class="meta"><b style="color:${ok?'var(--eye)':'var(--bad)'}">${ok?'✓':'✗'}</b> ${esc(lab)}</div>`;}).join('');}
|
||
function diversePaths(a,b){
|
||
const rem=remoteCities(),ok=c=>popUp(c)||rem.includes(c);
|
||
return disjointRoutes(a,b,S.links.filter(l=>!linkDown(l)&&ok(l.a)&&ok(l.b)));}
|
||
function disjointRoutes(a,b,live){const srlg=l=>l.kind==='vxc'?'fab:'+l.prov:(l.trench||l.id);
|
||
const bfs=ls=>{const adj={};for(const l of ls){(adj[l.a]=adj[l.a]||[]).push([l.b,l]);(adj[l.b]=adj[l.b]||[]).push([l.a,l]);}
|
||
const prev={[a]:null},q=[a];while(q.length){const u=q.shift();if(u===b)break;for(const [v,l] of adj[u]||[])if(!(v in prev)){prev[v]=l;q.push(v);}}
|
||
if(!(b in prev))return null;const path=[];let v=b;while(v!==a){const l=prev[v];path.push(l);v=l.a===v?l.b:l.a;}return path;};
|
||
const p1=bfs(live);if(!p1)return false;const used=new Set(p1.map(srlg));return !!bfs(live.filter(l=>!used.has(srlg(l))));}
|
||
// Check buildable geography, not today's POPs, capacity or outages. Parallel land
|
||
// routes can use separate trenches; all segments of one cable share its risk.
|
||
let diversityMap=null;
|
||
function diversityPossible(a,b,state=S){
|
||
if(!CITY[a]||!CITY[b]||a===b)return false;
|
||
const rules=state.scn&&state.scn.rules||{},key=JSON.stringify([!!state.won,rules]);
|
||
if(!diversityMap||diversityMap.key!==key){
|
||
const links=[],cities=CITIES.filter(c=>!(rules.banCities||[]).includes(c.id)).map(c=>c.id);
|
||
const add=(a,b,id)=>links.push({a,b,id});
|
||
for(let i=0;i<cities.length;i++)for(let j=i+1;j<cities.length;j++){
|
||
const a=cities[i],b=cities[j];
|
||
if(!isSub(a,b)){add(a,b,'land:'+a+':'+b+':1');add(a,b,'land:'+a+':'+b+':2');}
|
||
for(const c of cablesFor(a,b))if(!(rules.banPairs||[]).some(p=>p===c.cid+':'+a+'-'+b||p===c.cid+':'+b+'-'+a))add(a,b,'cab:'+c.cid);
|
||
if(state.won&&seaCab(a,b)&&landing(a)&&landing(b)&&!cnCity(a)&&!cnCity(b))add(a,b,'own:'+a+':'+b);
|
||
for(const f of FABS)if(f.cities.includes(a)&&f.cities.includes(b))add(a,b,'fab:'+f.id);
|
||
}
|
||
diversityMap={key,links,answers:{}};
|
||
}
|
||
const pair=[a,b].sort().join(':');
|
||
return diversityMap.answers[pair]??(diversityMap.answers[pair]=disjointRoutes(a,b,diversityMap.links));
|
||
}
|
||
function fiberOk(b){const l=S.links.find(x=>x.id===b.link);if(!l)return false;if(b.type==='dfpair'||b.type==='pairs')return l.ready<=S.day&&!(l.cut>S.day);return l.ready<=S.day&&!(l.cut>S.day)&&!(l.eqDown>S.day);}
|
||
function soldSlots(l){return S.biz.filter(b=>b.type==='wwave'&&b.link===l.id).reduce((a,b)=>a+(b.slots||0),0);}
|
||
function bizSf(b){const T=BIZ_T[b.type];return T.fiber?(fiberOk(b)?1:0):T.l2?clamp((R.l2[b.id]||0)/b.bw,0,1):sfOf(R,b.city);}
|
||
function bCities(o){return o.sites?o.sites.slice():[o.city,o.city2].filter(Boolean);}
|
||
function bHas(o){return bCities(o).every(c=>S.pops[c]);}
|
||
function eventLive(b){return BIZ_T[b.type].event&&S.day>=b.start&&S.day<b.start+b.dur;}
|
||
function bTerms(o){const T=BIZ_T[o.type];
|
||
if(T.event){const live=S.day>=o.start;return tr('{bw} extra for {d} days, {when} · pays {fee} when it is over',{bw:fmtG(o.bw),d:o.dur,when:live?tr('day {n} of {d}',{n:S.day-o.start+1,d:o.dur}):tr('starting in {n}d',{n:o.start-S.day}),fee:fmt$(o.fee)});}
|
||
if(T.sdwan)return tr('{n} sites: {list} · {bw} per site · {price}/mo',{n:o.sites.length,list:o.sites.map(c=>CITY[c].name).join(', '),bw:fmtG(o.bw),price:fmt$(o.bw*o.rate)});
|
||
if(T.fiber)return esc(o.what)+' · '+tr('{price}/mo',{price:fmt$(o.rate)});
|
||
return fmtG(o.bw)+' · '+tr('{price}/mo',{price:fmt$(o.bw*o.rate)});}
|
||
// Events are paid once at the end, prorated by how much of the crowd you served.
|
||
function eventTick(b,d){if(!BIZ_T[b.type].event)return false;if(d<b.start)return true;
|
||
if(d<b.start+b.dur){b.srv=(b.srv||0)+sfOf(R,b.city);b.srvDays=(b.srvDays||0)+1;if(d===b.start)toast(tr('<b>{name} starts today!</b><br>{bw} of extra demand in {city} for {d} days.',{name:esc(b.name),bw:fmtG(b.bw),city:CITY[b.city].name,d:b.dur}),'goal',[{l:tr('Show me'),act:'focusCity',args:{city:b.city}}]);return true;}
|
||
const avg=b.srvDays?b.srv/b.srvDays:0;if(avg>=0.95)S.stats.evFull=(S.stats.evFull||0)+1;const pay=avg>=0.95?b.fee:avg>=0.7?Math.round(b.fee*avg):-Math.round(b.fee*0.2);S.cash+=pay;S.biz=S.biz.filter(x=>x!==b);
|
||
toast(pay>=0?tr('<b>{name} is over: +{pay}</b><br>You delivered {pct} of what the crowd wanted.',{name:esc(b.name),pay:fmt$(pay),pct:pct(avg)})+(avg>=0.95?' '+tr('Flawless.'):''):tr('<b>{name} was a disaster.</b><br>Only {pct} delivered, and it trended on social media. Penalty: {pay}.',{name:esc(b.name),pct:pct(avg),pay:fmt$(-pay)}),pay>=0?'good':'bad');sfx(pay>=0?'coin':'err');return true;}
|
||
/* Where the giants actually build: gigawatt AI campuses and cloud regions, mapped to the nearest city on the map. */
|
||
const MEGA=[{c:'ash',n:'Data Center Alley'},{c:'ash',n:'Prome-the-mess Ohio'},{c:'dal',n:'Star-Gait Abilene'},{c:'dal',n:'Hyperbole Louisiana'},{c:'dal',n:'Colossal Ego Memphis'},{c:'chi',n:'Fairweather Wisconsin'},{c:'chi',n:'Project Rainy-er Indiana'},{c:'chi',n:'Cornfield Cluster Iowa'},{c:'nyc',n:'Neocloud New Jersey'},{c:'sto',n:'Star-Gait Fjord-way'},{c:'mad',n:'Aragón Mega-shed'},{c:'dub',n:'Bring-Your-Own-Power Dublin'},{c:'auh',n:'Star-Gait UAE'},{c:'ruh',n:'Desert Kingdom AI Campus'},{c:'doh',n:'Lusail Data Oasis'},{c:'kul',n:'Johor Overflow'},{c:'hyd',n:'Vizag AI Hub'},{c:'icn',n:'Ulsan AI Campus'},{c:'tok',n:'Hokkaido Snow DC'},{c:'syd',n:'Star-Gait Down Under'},{c:'mex',n:'Querétaro Cluster'},{c:'for',n:'Short-Video Ceará Campus'},{c:'scl',n:'Quilicura Region'}];
|
||
function spawnMega(t,T,nm,mine){
|
||
const megaMine=MEGA.filter(m=>mine.includes(m.c));if(!megaMine.length)return;
|
||
if(t==='ingest'){const m=pick(megaMine),bw=pick(T.opts),dur=3+Math.floor(Math.random()*4),start=S.day+10+Math.floor(Math.random()*12);
|
||
S.offers.push({id:uid(),city:m.c,city2:null,name:tr('{name} at {site}',{name:nm(),site:m.n}),type:t,bw,rate:0,reqs:[],start,dur,fee:Math.round(bw*dur*55),exp:start-2,mega:true});return;}
|
||
if(t==='aiwan'||t==='agi'){const a=pick(megaMine),others=MEGA.filter(m=>m.c!==a.c&&(Math.random()<0.7?mine.includes(m.c):true));if(!others.length)return;const b=pick(others);if(!reqCan('diverse',{city:a.c,city2:b.c}))return;const km=kmBetween(a.c,b.c),bw=pick(T.opts);
|
||
const reqs=['diverse'];if(Math.random()<0.4)reqs.push('metro');
|
||
S.offers.push({id:uid(),city:a.c,city2:b.c,name:`${nm()}: ${a.n} ⇄ ${b.n}`,type:t,bw,rate:Math.round((150+km*0.08)*T.km),reqs,exp:S.day+45,mega:true});return;}
|
||
if(t==='mtrain'){const hub=pick(megaMine),reg=CITY[hub.c].reg,pool=[...new Set(MEGA.filter(m=>m.c!==hub.c&&CITY[m.c].reg===reg).map(m=>m.c))];if(pool.length<2)return;
|
||
const sites=[hub.c];while(sites.length<Math.min(4,pool.length+1)&&pool.length)sites.push(pool.splice(Math.floor(Math.random()*pool.length),1)[0]);
|
||
const avg=sites.slice(1).reduce((x,c)=>x+kmBetween(hub.c,c),0)/(sites.length-1),bw=pick(T.opts);
|
||
S.offers.push({id:uid(),city:hub.c,city2:null,sites,name:tr('{name} (hub: {site})',{name:nm(),site:hub.n}),type:t,bw,rate:Math.round((150+avg*0.08)*0.6),reqs:[],exp:S.day+45,mega:true});return;}
|
||
if(t==='pairs'){const ls=S.links.filter(l=>l.kind==='df'&&l.own&&l.ready<=S.day&&!S.biz.some(b=>(b.type==='pairs'||b.type==='dfpair')&&b.link===l.id)&&!S.offers.some(o=>o.link===l.id));if(!ls.length)return;const l=pick(ls),n=100+50*Math.floor(Math.random()*7);
|
||
S.offers.push({id:uid(),city:l.a,city2:l.b,link:l.id,what:tr('{n} fiber pairs in your {a}–{b} trench. Trenching was the expensive part, so they want all of it',{n,a:CITY[l.a].name,b:CITY[l.b].name}),name:nm(),type:t,bw:1,rate:Math.round(dfLeaseMo(l.km)*n*0.2),reqs:[],exp:S.day+30,mega:true});}
|
||
}
|
||
function spawnSpecial(t){const T=BIZ_T[t],mine=Object.keys(S.pops),lv=S.lvl||1;
|
||
const nm=()=>{const list=T.names.filter(n=>!S.usedNames.includes(n));const n=list.length?pick(list):pick(T.names);S.usedNames.push(n);return n;};
|
||
if(T.mega){spawnMega(t,T,nm,mine);return;}
|
||
if(T.event){const city=Math.random()<0.85&&mine.length?pick(mine):pick(ALLC);const bw=pick(T.opts.slice(0,Math.min(T.opts.length,lv+2)));const dur=3+Math.floor(Math.random()*5),start=S.day+12+Math.floor(Math.random()*14);
|
||
S.offers.push({id:uid(),city,city2:null,name:tr('{name} in {city}',{name:nm(),city:CITY[city].name}),type:t,bw,rate:0,reqs:[],start,dur,fee:Math.round(bw*dur*70),exp:start-2});return;}
|
||
if(T.sdwan){const hub=pick(mine),n=3+Math.floor(Math.random()*4),pool=(Math.random()<0.85?mine:ALLC).filter(c=>c!==hub),sites=[hub];
|
||
while(sites.length<n&&pool.length)sites.push(pool.splice(Math.floor(Math.random()*pool.length),1)[0]);if(sites.length<3)return;
|
||
S.offers.push({id:uid(),city:hub,city2:null,sites,name:nm(),type:t,bw:pick(T.opts),rate:700*sites.length,reqs:[],exp:S.day+40});return;}
|
||
const ready=S.links.filter(l=>l.kind==='df'&&l.ready<=S.day);
|
||
if(t==='wwave'){const free=l=>chMax(l)-(l.ch||[]).length-soldSlots(l);const ls=ready.filter(l=>free(l)>=1&&!S.offers.some(o=>o.link===l.id));if(!ls.length)return;const l=pick(ls),slots=1+Math.floor(Math.random()*Math.min(4,free(l)));
|
||
S.offers.push({id:uid(),city:l.a,city2:l.b,link:l.id,slots,what:trn('{n}× 400G alien wave on your {a}–{b} fiber','{n}× 400G alien waves on your {a}–{b} fiber',slots,{a:CITY[l.a].name,b:CITY[l.b].name}),name:nm(),type:t,bw:1,rate:Math.round(waveMo(l.km,false,2)*0.55*slots),reqs:[],exp:S.day+30});return;}
|
||
if(t==='dfpair'){const ls=ready.filter(l=>l.own&&S.biz.filter(b=>b.type==='dfpair'&&b.link===l.id).length<2&&!S.biz.some(b=>b.type==='pairs'&&b.link===l.id)&&!S.offers.some(o=>o.link===l.id));if(!ls.length)return;const l=pick(ls);
|
||
S.offers.push({id:uid(),city:l.a,city2:l.b,link:l.id,what:tr('a spare fiber pair in your {a}–{b} trench',{a:CITY[l.a].name,b:CITY[l.b].name}),name:nm(),type:t,bw:1,rate:Math.round(dfLeaseMo(l.km)*0.9),reqs:[],exp:S.day+30});}
|
||
}
|
||
function cnOk(){return S.cnLic&&S.cnLic.state==='ok';}
|
||
function regionMult(c){const C=CITY[c];if(!C||C.cn)return 1;if(C.kr)return KR_TRANSIT;if(C.tape)return 1.5;return C.reg==='AS'?2.5:C.reg==='AF'?2:C.reg==='OC'?1.8:C.reg==='SA'?1.6:1;}
|
||
const uaePair=(a,b)=>!!CITY[a].uae&&!!CITY[b].uae;
|
||
const andesPair=(a,b)=>!!CITY[a].andes&&!!CITY[b].andes&&CITY[a].andes!==CITY[b].andes;
|
||
/* Overland between continents (Europe to the Middle East and Asia) crosses a dozen borders and as many
|
||
carriers, each taking a cut: in real life it costs ten times the subsea route or more (#40). */
|
||
const LAND_X=45,landX=(a,b)=>!isSub(a,b)&&CITY[a].reg!==CITY[b].reg;
|
||
function landMult(a,b){if(isSub(a,b))return 1;if(uaePair(a,b))return 3;return (landX(a,b)?LAND_X:1)*(andesPair(a,b)?2:1);}
|
||
function landWhy(a,b){if(isSub(a,b))return '';if(uaePair(a,b))return tr('Inside the UAE only the two licensed operators, Etis-a-lot and Du-opoly, may run fiber. No dark fiber, no digging your own, and waves cost 3×.');
|
||
const r=[];if(CITY[a].reg!==CITY[b].reg)r.push(tr('Overland between continents crosses a dozen borders, and every carrier on the way takes a cut: {x}× the price. Subsea is far cheaper.',{x:LAND_X}));if(andesPair(a,b))r.push(tr('This route crosses the Andes: 2× the price, and landslides and snow cut it far more often than flat fiber.'));return r.join(' ');}
|
||
function linkLat(l){const f=l.kind==='df'?(l.own?1.1:1.25):l.kind==='vxc'?1.4:l.cable?(CAB[l.cable].lat||1):1.3;return l.km*f/200;}
|
||
/* Wave prices differ a lot by market (TeleGeography): Europe's dense, competitive metro and
|
||
long-haul routes are cheap (Frankfurt–London 100G ≈ $1,150/mo), the US costs more, and
|
||
routes into Africa are several times dearer (Africa–Europe ≈ 5.9× London–New York).
|
||
Each route also gets its own market mood, and new leases get cheaper every year (~8%). */
|
||
const WAVE_LAND={EU:0.65,AM:1,SA:1.6,AS:1.4,OC:1.2,AF:2.2},WAVE_SUB={EU:0.8,AM:1,SA:2,AS:1.5,OC:1.5,AF:4.5};
|
||
const WAVE_NAME={EU:tr('Europe'),AM:tr('North America'),SA:tr('South America'),AS:tr('Asia'),OC:tr('Oceania'),AF:tr('Africa')};
|
||
function waveMarket(a,b,sub){const ra=CITY[a].reg,rb=CITY[b].reg,T=sub?WAVE_SUB:WAVE_LAND;
|
||
const reg=sub?Math.max(T[ra]||1,T[rb]||1):((T[ra]||1)+(T[rb]||1))/2;
|
||
const key=a<b?a+b:b+a,mood=0.85+(hstr(key+'|mood')%31)/100;
|
||
const ero=Math.max(0.55,Math.pow(0.92,Math.floor((S?S.day:0)/360)));
|
||
return {m:reg*mood*ero,reg,mood,ero};}
|
||
function marketNote(a,b,sub){const k=waveMarket(a,b,sub),ra=CITY[a].reg,rb=CITY[b].reg;const where=ra===rb?WAVE_NAME[ra]:tr('{a} to {b}',{a:WAVE_NAME[ra],b:WAVE_NAME[rb]});
|
||
const lvl=k.reg<0.9?tr('cheap: lots of competing fiber'):k.reg<=1.05?tr('about average'):k.reg<2?tr('pricey: fewer carriers'):tr('expensive: scarce capacity');const since=k.ero<1?tr(', and prices have fallen {p}% since you started',{p:Math.round((1-k.ero)*100)}):'';
|
||
return k.mood<0.97?tr('{where}: {lvl}. This route is {p}% below the going rate{since}.',{where,lvl,p:Math.round((1-k.mood)*100),since}):k.mood>1.03?tr('{where}: {lvl}. This route is {p}% above the going rate{since}.',{where,lvl,p:Math.round((k.mood-1)*100),since}):tr('{where}: {lvl}. This route is right at the going rate{since}.',{where,lvl,since});}
|
||
function waveRoute(a,b,mult,border){const cabs=cablesOk(a,b),sub=isSub(a,b);let via=UI.via;
|
||
if(!cabs.find(c=>c.cid===via))via=sub?(cabs[0]?cabs[0].cid:null):(via==='land'||!via?'land':'land');
|
||
if(!via)return null;const bf=border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1;
|
||
if(via==='land')return {via,cabs,cab:null,km:kmBetween(a,b),sub:false,wm:mult*landMult(a,b)*waveMarket(a,b,false).m};
|
||
const c=cabs.find(x=>x.cid===via);return {via,cabs,cab:via,km:c.km,sub:true,wm:bf*CAB[via].price*waveMarket(a,b,true).m};}
|
||
function viaSeg(a,b){const cabs=cablesOk(a,b),sub=isSub(a,b);if(!cabs.length)return landMult(a,b)>1?`<p class="note">${landWhy(a,b)}</p>`:'';const wr=waveRoute(a,b,1,false);
|
||
const opts=(sub?[]:[{v:'land',l:`${tr('Overland')} <small>${landMult(a,b)>1?landMult(a,b)+'× · ':''}${(kmBetween(a,b)*1.3/200).toFixed(1)} ms</small>`}]).concat(cabs.map(c=>({v:c.cid,l:`${esc(CAB[c.cid].name)} <small>${CAB[c.cid].price}× · ${(c.km*(CAB[c.cid].lat||1)/200).toFixed(1)} ms${CAB[c.cid].age==='old'?' · '+tr('old, cuts often'):''}</small>`})));
|
||
return `<h4 class="sub4">${tr('Route')}</h4><div class="seg">${opts.map(o=>btn(o.l,'via',{v:o.v},wr&&wr.via===o.v?'pink':'ghost')).join('')}</div>${wr&&wr.cab?`<p class="note">${esc(CAB[wr.cab].blurb)} ${tr('All your waves on one cable share its fate when it is cut.')}</p>`:''}`;}
|
||
function bestLat(a,b){const ls=S.links.filter(l=>!linkDown(l));const dist={[a]:0},done=new Set();for(;;){let u=null,ud=Infinity;for(const k in dist)if(!done.has(k)&&dist[k]<ud){u=k;ud=dist[k];}if(u===null)break;if(u===b)return ud;done.add(u);for(const l of ls){if(l.a!==u&&l.b!==u)continue;const v=l.a===u?l.b:l.a,nd=ud+linkLat(l)+0.05;if(nd<(dist[v]??Infinity))dist[v]=nd;}}return Infinity;}
|
||
const RT={normal:tr('Follow metrics'),fast:tr('Lowest latency'),scenic:tr('Scenic (quietest links)')};
|
||
function routeCtl(b){const lt=R.l2lat[b.id];return `<div class="btns"><span class="meta" style="align-self:center">${tr('Route:')}</span>${Object.keys(RT).map(m=>btn(RT[m],'setRoute',{id:b.id,m},(b.route||'normal')===m?'pink sm':'ghost sm')).join('')}</div><div class="meta">${tr('Path latency: <b>{lat}</b>',{lat:lt!==undefined&&isFinite(lt)?tr('{ms} ms one-way',{ms:lt.toFixed(1)}):tr('no path right now')})}${b.route==='scenic'&&R.l2split&&R.l2split[b.id]?' · '+tr('split over two equally quiet paths'):''}${b.latMax?' · '+tr('budget {ms} ms',{ms:b.latMax}):''}</div>`;}
|
||
function nodeCap(c){const p=S.pops[c];if(!p)return Infinity;const eff=(p.routers||1)-(p.rdown>S.day?1:0);return RG[p.rgen||0].cap*Math.max(1,eff)*(p.hot>S.day?(p.site2?0.75:0.5):1)*(p.site2&&(siteDown(c,'a')||siteDown(c,'b'))?0.5:1);}
|
||
// With a second site, one building can be dark (or cut off by a ring cut) while the other carries on.
|
||
function siteDown(c,s){const p=S.pops[c];if(!p||!p.site2)return false;if(S.inc.some(i=>i.type==='site'&&i.ref===c&&i.site===s&&i.until>S.day))return true;return s==='b'&&p.ringcut>S.day;}
|
||
// Ports can live in site A, site B, or be split across both ('ab'): a LAG with members in each
|
||
// building, so one dark building only takes out its half.
|
||
function liveN(c,site,n){n=n||1;const p=S.pops[c];if(!p||!p.site2)return n;if(site==='ab'){const a=Math.ceil(n/2),b=n-a;return (siteDown(c,'a')?0:a)+(siteDown(c,'b')?0:b);}return siteDown(c,site==='b'?'b':'a')?0:n;}
|
||
const liveCap=(g,c,site,n)=>{const k=liveN(c,site,n);return k?lagCap(g,k):0;};
|
||
const onSite=(site,s)=>(site||'a')===s||site==='ab';
|
||
function siteCtl(k,id,c,cur){const p=S.pops[c];if(!p||!p.site2)return '';cur=cur||'a';const n=k==='t'?(S.transit.find(x=>x.id===id)||{}).n:k==='p'?(S.pni.find(x=>x.id===id)||{}).n:(S.ixn||{})[id];return `<div class="seg site"><span class="meta">${tr('Site:')}</span>${['a','b'].map(x=>btn(`${x.toUpperCase()} <small>${esc(siteName(c,x))}</small>`,'siteSet',{k,id,s:x},cur===x?'pink sm':'ghost sm')).join('')}${btn((n||1)<2?tr('Both <small>adds a LAG member</small>'):tr('Both <small>split the LAG</small>'),'siteSet',{k,id,s:'ab'},cur==='ab'?'pink sm':'ghost sm')}</div>`;}
|
||
function portOk(c,i){const p=S.pops[c];return i<=RG[p?(p.rgen||0):0].maxP;}
|
||
function waveOk(a,b,i){return [a,b].every(c=>i<=RG[S.pops[c]?(S.pops[c].rgen||0):0].maxLT);}
|
||
function waveNeed(i){const g=RG.find(r=>r.maxLT>=i);return g?tr('{pn} routers',{pn:g.pn}):'?';}
|
||
function routerModels(c){const p=S.pops[c],g=p.rgen||0,rt=p.routers||1;
|
||
return `<div style="margin-top:6px">${RG.map((M,i)=>{if(i===g)return '';const why=modelFits(c,i),lk=M.lvl>lvl();
|
||
return `<div class="row"><span class="logo" style="--c:${M.badge?'#2C7A7B':'#FF4F9A'}">${M.badge||'R'+(M.cls+1)}</span><div class="grow"><div class="nm">${esc(M.n)} <span class="meta">${M.pn} · ${tr('{n} ports',{n:M.ports})} · ${fmtG(M.cap)} · ${tr('boots in ~{n} min',{n:M.boot})}${M.flaky?' · '+tr('crashes more'):''}</span></div><div class="meta">${esc(M.blurb)}</div>${why?`<div class="why">${esc(why)}</div>`:''}</div>${btn(lk?tr('Level {n}',{n:M.lvl}):tr('Swap <small>{cost} + {mo}/mo</small>',{cost:fmt$(swapCost(c,i)),mo:fmt$(M.mo*rt)}),'upRouter',{city:c,g:i},'sm',lk||!!why||S.cash<swapCost(c,i)||p.rupDay===S.day)}</div>`;}).join('')}</div>`;}
|
||
function portNote(c){const p=S.pops[c];if(!p)return '';const g=p.rgen||0;return RG[g].maxP<PORT.length-1?`<p class="note" style="margin-top:0">${tr('Your {model} here tops out at {pn} ports. Bigger ports need a router upgrade (Infra tab).',{model:esc(RG[g].n),pn:RG[g].pn})}</p>`:'';}
|
||
function sfOf(r,c){const d=r.cityDem[c]||0;return d<=1e-6?1:clamp(r.citySrv[c]/d,0,1);}
|
||
|
||
/* ---------- failures & events ---------- */
|
||
// A few badges read the incident text: callers whose message mentions a shark, anchor, crocodile or llama pass its English as en.
|
||
function addInc(o,en=o.msg||''){if(S.loans&&S.loans.some(l=>(l.covs||[]).includes('pizza'))){S.cash-=COVS.pizza.each;S.stats.pizza=(S.stats.pizza||0)+1;}o.id=uid();o.start=S.day;S.inc.push(o);S.stats.incidents++;S.stats.by=S.stats.by||{};S.stats.by[o.type]=(S.stats.by[o.type]||0)+1;if(/shark/i.test(en))S.stats.sharks=(S.stats.sharks||0)+1;const f=S.stats.f=S.stats.f||{};if(/anchor/i.test(en))f.anchor=1;if(/crocodile/i.test(en))f.croc=1;if(/beaver/i.test(en))f.beaver=1;if(/llama/i.test(en))f.llama=1;}
|
||
const HARMLESS=[
|
||
[tr('Certificate expired'),tr('The TLS certificate on your NOC dashboard expired. Nobody can see any graphs, so technically there are no problems.')],
|
||
[tr('It was DNS'),tr('Someone deleted the DNS record for the internal wiki. The runbook for fixing DNS was on the wiki.')],
|
||
[tr('Leap second'),tr('A leap second convinced one of your routers it is 1970. Uptime now reads minus 56 years. Traffic is fine.')],
|
||
[tr('Change freeze'),tr('Management declared a change freeze. Someone made a change to announce the change freeze.')],
|
||
[tr('Ticket of the week'),tr('A customer opened a P1 ticket: “the internet is slow”. Attached was a photo of their router, unplugged.')],
|
||
[tr('Monitoring'),tr('Your monitoring system went down. You found out because nothing alerted. Very peaceful week.')],
|
||
[tr('Load-bearing typo'),tr('Someone named a VLAN “prodcution”. It is now load-bearing and can never be renamed.')],
|
||
[tr('IPv6 milestone'),tr('Your IPv6 traffic grew 400%. From one packet to five.')],
|
||
[tr('Mystery link'),tr('You found a 10G link in the inventory that nobody ordered, nobody pays for, and that carries 3 Gbps of something.')],
|
||
[tr('Spreadsheet IPAM'),tr('Your IP address spreadsheet hit 1,048,576 rows. Excel has opinions.')],
|
||
[tr('Goose incident'),tr('A goose attacked the technician on the way to your amp hut. The goose won. Repair rescheduled, nothing broke.')],
|
||
[tr('Latency test'),tr('A carrier pigeon beat one of your links in an informal latency test. Morale is low. Throughput is fine.')],
|
||
[tr('Zombie route'),tr('A route you withdrew in Year 1 is still visible somewhere in the internet. Nobody knows where. It is fine. Probably.')],
|
||
[tr('Auditor visit'),tr('An auditor asked for a network diagram. You sent the game map. They approved it.')],
|
||
[tr('Open to work'),tr('Your peering coordinator updated their profile to “open to work”. Three Tier 1s suddenly want to chat. Nothing happened, but it felt nice.')],
|
||
[tr('Hold music'),tr('Your upstream support line plays the same 11 seconds of hold music. Your on-call engineer can now hum it in four keys.')],
|
||
[tr('Naming committee'),tr('A two-hour meeting about router hostnames ended with a vote for “router-final-v2-NEW”.')],
|
||
[tr('Vendor TAC'),tr('Vendor support asked you to “try turning it off and on again”. For the router you already rebooted. Ticket closed.')],
|
||
];
|
||
function lagsN(){const o=[];for(const t of S.transit)if((t.n||1)>=2&&!(t.down>S.day))o.push({k:'t',id:t.id,o:t,n:t.n,lab:tr('{name} transit LAG in {city}',{name:NET[t.net].name,city:CITY[t.city].name})});
|
||
for(const p of S.pni)if((p.n||1)>=2)o.push({k:'p',id:p.id,o:p,n:p.n,lab:tr('PNI LAG with {name} in {city}',{name:NET[p.net].name,city:CITY[p.city].name})});
|
||
for(const x in S.ixp){const n=(S.ixn||{})[x]||1;if(n>=2&&!S.myIx[x])o.push({k:'ix',id:x,n,lab:tr('{ix} LAG in {city}',{ix:ixName(x),city:CITY[ixCity(x)].name})});}return o;}
|
||
// Where the junk comes in: one of the city's live uplinks, or just "the edge" if it has none yet.
|
||
function ddosEntry(c){const o=[];
|
||
for(const t of S.transit)if(t.city===c&&!(t.down>S.day))o.push({k:'t',id:t.id,lab:tr('{net} transit',{net:NET[t.net].name})});
|
||
for(const x of ixIdsIn(c))if(S.ixp[x]!==undefined)o.push({k:'ix',id:x,lab:tr('{ix} peering',{ix:ixName(x)})});
|
||
for(const p of S.pni)if(p.city===c)o.push({k:'p',id:p.id,lab:tr('PNI with {net}',{net:NET[p.net].name})});
|
||
return o.length?pick(o):{k:'edge',lab:''};}
|
||
// Flowspec capability of the router in a city: 0 none, 1 basic, 2 full. The flood is filtered where the
|
||
// victim POP's own router has the TCAM for it.
|
||
const fsAt=c=>{const p=S.pops[c];return p?(RG[p.rgen||0].fs||0):0;};
|
||
// Scrubbing residual for an attack: clean up to the center's capacity (to 15%), overflow leaks. On-demand
|
||
// does nothing for the first couple of days while traffic is being diverted.
|
||
function scrubEngaged(atk){return !!S.scrubAt&&(S.scrubMode==='always'||(S.day-(atk.start||S.day))>=SCRUB_DELAY);}
|
||
function scrubMult(atk){if(!scrubEngaged(atk))return 1;const cap=scrubG(),g=atk.gbps||0;if(g<=0)return 1;return g<=cap?0.15:(cap*0.15+(g-cap))/g;}
|
||
// The NOC's live attack view: what is hitting you, what each tool would do about it right now, and the buttons.
|
||
function ddosPanel(){
|
||
const a=S&&S.ev&&S.ev.ddos;if(!a||a.until<=S.day||!S.pops[a.city])return '';
|
||
const V=DDOS_VEC[a.vec]||{n:'?',fs:false},cap=fsAt(a.city),model=RG[(S.pops[a.city].rgen||0)].n,en=a.entry||{};
|
||
const cleanT=en.k==='t'?S.transit.find(x=>x.id===en.id):null, sacP=en.k==='p'?S.pni.find(x=>x.id===en.id):null;
|
||
let mult=1;
|
||
if(V.fs&&cap)mult=Math.min(mult,FS_RES[cap]);
|
||
mult=Math.min(mult,scrubMult(a));
|
||
if(cleanT&&cleanT.clean)mult=Math.min(mult,0.1);
|
||
if(a.ixbh&&hasIxAt(a.city))mult=Math.min(mult,0.5);
|
||
let land=a.bh?0:a.gbps*mult;
|
||
if(sacP&&sacP.sacrif)land=Math.min(land,liveCap(PORT[sacP.tier].g,sacP.city,sacP.site,sacP.n)*0.9);
|
||
land=Math.round(land);
|
||
const fsLine=!V.fs?'— '+tr('Flowspec cannot catch an {vec} (application layer)',{vec:esc(V.n)})
|
||
:cap>=2?'✓ '+tr('Flowspec on your {model} is dropping {vec} at the edge',{model:esc(model),vec:esc(V.n)})
|
||
:cap===1?'~ '+tr('Flowspec on your {model} trims {vec}, but its TCAM is small',{model:esc(model),vec:esc(V.n)})
|
||
:'— '+tr('Your {model} here has no Flowspec TCAM',{model:esc(model)});
|
||
const T=SCRUB_TIERS[S.scrubTier||0];
|
||
const scrLine=!S.scrubAt?'— '+tr('No scrubbing center')
|
||
:!scrubEngaged(a)?'… '+tr('On-demand scrubbing diverting, live in {n}d',{n:Math.max(1,SCRUB_DELAY-(S.day-(a.start||S.day)))})
|
||
:a.gbps<=T.g?'✓ '+tr('{tier} scrubbing in {city} is cleaning it',{tier:T.n,city:esc(CITY[S.scrubAt].name)})
|
||
:'~ '+tr('{tier} scrubbing is over capacity: {g} leaks past',{tier:T.n,g:fmtG(a.gbps-T.g)});
|
||
const entryLine=cleanT&&cleanT.clean?'✓ '+tr('{net} is scrubbing it upstream (clean-pipe)',{net:esc(NET[cleanT.net].name)})
|
||
:sacP&&sacP.sacrif?'✓ '+tr('Contained on your sacrificial {net} PNI',{net:esc(NET[sacP.net].name)}):'';
|
||
let h=`<div class="inc" style="background:#FFE2E6;border:1px solid #FF8A9A">
|
||
<div class="nm">🚨 ${tr('Live attack: {city}',{city:esc(CITY[a.city].name)})}</div>
|
||
<div class="meta">${tr('{size} · {vec}{entry} · {n}d left',{size:fmtG(a.gbps),vec:esc(V.n),entry:a.entry&&a.entry.lab?' · '+esc(a.entry.lab):'',n:a.until-S.day})}</div>
|
||
<div class="meta"><b>${a.bh?tr('Blackholed: the junk is gone, and so is {city}. The attack got what it wanted.',{city:esc(CITY[a.city].name)}):tr('Reaching your network: {g}',{g:fmtG(land)})}</b></div>
|
||
<div class="meta">${scrLine}</div>
|
||
<div class="meta">${fsLine}</div>${entryLine?`\n <div class="meta">${entryLine}</div>`:''}
|
||
<div class="btns">${a.bh?btn(tr('Stop blackholing'),'unrtbh',{},'ghost sm'):btn(tr('Blackhole the target (RTBH)'),'rtbh',{},'red sm')}${hasIxAt(a.city)&&!a.bh?btn(a.ixbh?tr('IX blackhole on ✓'):tr('IX blackhole <small>~half honour it</small>'),'ixbh',{},a.ixbh?'green sm':'sm'):''}${btn(tr('HackBack 3000™ <small>$20k</small>'),'hackback',{},'sm',S.cash<20000)}</div>
|
||
<p class="meta">${tr('RTBH is free and instant, but it drops everything to the victim, attack and customer alike. An IX blackhole keeps the customer up but only about half the members honour it. HackBack 3000™ by Skynot AI sometimes ends it, and sometimes flattens an innocent and earns you a fine.')}</p></div>`;
|
||
return h;}
|
||
function fireFailure(){
|
||
const opts=[];
|
||
const live=S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l));const fabsUsed=[...new Set(S.links.filter(l=>l.kind==='vxc').map(l=>l.prov))];
|
||
if(live.length){opts.push(['cut',2+Math.min(6,live.length/2)]);}
|
||
if(Object.keys(S.pops).length)opts.push(['crash',3],['power',2]);
|
||
if(Object.values(S.pops).some(p=>p.site2))opts.push(['ring',1.2]);
|
||
if(S.transit.some(t=>!(t.down>S.day)))opts.push(['transit',3]);
|
||
if(Object.keys(S.ixp).length)opts.push(['ixloop',2]);
|
||
if(S.transit.length&&S.day>60)opts.push(['leak',2]);
|
||
if(S.day>40&&!scnRule('ddos'))opts.push(['ddos',2]); // Flood Season brings its own
|
||
if(fabsUsed.length)opts.push(['fabric',1.5]);
|
||
const lit=S.links.filter(l=>l.kind==='df'&&dfCap(l)>0&&!linkDown(l));if(lit.length)opts.push(['amp',1.5+lit.length*0.3],['optic',1.5+lit.length*0.3]);
|
||
opts.push(['funny',4]);
|
||
if(!opts.length)return;
|
||
let tot=opts.reduce((a,o)=>a+o[1],0),r=Math.random()*tot,type=opts[0][0];
|
||
for(const o of opts){r-=o[1];if(r<=0){type=o[0];break;}}
|
||
if(type==='funny'){const f=['oops','cleaner','harmless','harmless','harmless','ac'];if(live.length)f.push('fatwave','fatwave','mtu','label','loss','loss');if(lagsN().length)f.push('lacp','lacp');if(R.demand>1)f.push('pmtud');if(Object.keys(S.ixp).length)f.push('maxpfx');if(S.transit.length)f.push('prepend');if(S.day>30)f.push('rpki');if(lit.length)f.push('roadmff');type=pick(f);}
|
||
const before=R.served;
|
||
if(type==='harmless'){const m=pick(HARMLESS);S.stats.incidents++;S.stats.survived++;toast(`<b>${m[0]}</b><br>${m[1]}`,'goal');sfx('alert');return;}
|
||
if(type==='ring'){const cs=Object.keys(S.pops).filter(c=>S.pops[c].site2),c=pick(cs),pp=S.pops[c],dur=2+Math.floor(Math.random()*3);pp.ringcut=S.day+dur;
|
||
addInc({type,ref:c,until:pp.ringcut,msg:pick([tr('A backhoe cut the metro ring between your two sites in {city}. Turns out both fiber routes ran down the same street.',{city:CITY[c].name}),tr('Someone pulled the wrong cross-connect at the meet-me room in {city}, and {siteB} is cut off from {siteA}.',{city:CITY[c].name,siteB:siteName(c,'b'),siteA:siteName(c,'a')}),tr('A tram line construction project in {city} found your metro ring. Both halves of it.',{city:CITY[c].name})]),cost:3000,fix:tr('Splice it tonight')});}
|
||
else if(type==='ac'){const c=pick(Object.keys(S.pops)),pp=S.pops[c];pp.hot=S.day+2;
|
||
addInc({type,ref:c,until:pp.hot,msg:CITY[c].lux&&Math.random()<0.7?tr('A forestry strike stopped the waste-wood deliveries to the power plant that cools {dc}. No steam, no chillers: your routers in {city} run at half capacity.',{dc:CITY[c].dc,city:CITY[c].name}):pick([tr('The A/C at {dc} died on the hottest day of the year. Your routers in {city} throttled to half capacity.',{dc:CITY[c].dc,city:CITY[c].name}),tr('Someone set the data center thermostat in {city} to Fahrenheit thinking it was Celsius. Routers are cooking at half speed.',{city:CITY[c].name}),tr('The cooling contractor in {city} replaced the chillers with a very confident fan. Half capacity for two days.',{city:CITY[c].name})]),cost:2000,fix:tr('Buy 40 desk fans')});
|
||
}else if(type==='fatwave'||type==='label'){
|
||
const l=pick(live),dur=1+Math.floor(Math.random()*2),A=CITY[l.a].name,B=CITY[l.b].name,W=pick(WAVECO);l.cut=Math.max(l.cut||0,S.day+dur);
|
||
const msg=type==='label'?pick([tr('Someone in {dc} labeled every patch cable “DO NOT UNPLUG”. Someone else unplugged one anyway: your {a}–{b} link.',{dc:CITY[l.a].dc,a:A,b:B}),tr('A remote-hands tech in {a} was asked to clean the fiber on port 1. They cleaned it with a sandwich. {a}–{b} is down.',{a:A,b:B}),tr('A new tech in {a} “tidied up” the cable mess. Your {a}–{b} link was part of the mess.',{a:A,b:B})])
|
||
:l.kind==='df'?pick([tr('The landlord in {a} re-routed the building riser and pinched your dark fiber to {b}.',{a:A,b:B}),tr('A splicer fusing someone else’s cable in a manhole near {b} fused yours instead.',{b:B})])
|
||
:pick([tr('{co} fat-fingered a cross-connect and patched your {a}–{b} wave into a pizza oven.',{co:W,a:A,b:B}),tr("{co} did “quick maintenance” on the wrong wavelength. Your {a}–{b} wave is now carrying someone else's cat videos.",{co:W,a:A,b:B}),tr('{co} scheduled maintenance in UTC. Your team read it as local time. {a}–{b} went dark at peak.',{co:W,a:A,b:B}),tr('An engineer at {co} swapped Tx and Rx on your {a}–{b} wave. Light goes in, confusion comes out.',{co:W,a:A,b:B}),tr('{co} decommissioned your {a}–{b} wave because the ticket said “decom” instead of “docs”.',{co:W,a:A,b:B})]);
|
||
addInc({type,ref:l.id,until:l.cut,msg,cost:1500,fix:tr('Bribe their NOC with donuts')});
|
||
}else if(type==='lacp'){
|
||
const g=pick(lagsN()),n=g.n,dur=1+Math.floor(Math.random()*3),v=Math.floor(Math.random()*4);
|
||
const f=v===0?Math.max(0.3,1.4/n):v===3?0:(n-1)/n,until=S.day+(v===3?1:dur),lab=g.lab;
|
||
if(g.k==='ix'){S.ev.ixlacp=S.ev.ixlacp||{};S.ev.ixlacp[g.id]={until,f};}else g.o.lacp={until,f};
|
||
const msg=[N_('Hash polarisation on your {lab}: nearly every flow hashes onto the same member. The bundle says it is up. It is also full.'),
|
||
N_('LACP fast/slow timer mismatch on your {lab}: one member keeps timing out of the bundle and coming back.'),
|
||
N_('One member of your {lab} was patched into the wrong switch. LACP keeps it suspended, quite correctly.'),
|
||
N_('Someone set min-links on your {lab} to the number of members. One member flapped, so the whole bundle went down.')][v];
|
||
addInc({type,ref:g.k+':'+g.id,until,msg:tr(msg,{lab}),cost:600,fix:tr('Fix the LACP config')},msg);
|
||
}else if(type==='loss'){
|
||
const deep=l=>[l.a,l.b].every(c=>S.pops[c]&&/deep-buffer/.test(RG[S.pops[c].rgen||0].chip));
|
||
const l=pick(live),v=Math.floor(Math.random()*3);
|
||
if(v===1&&deep(l)){S.stats.incidents++;S.stats.survived++;toast(tr('<b>Microbursts on {a}–{b}.</b><br>Your deep-buffer routers soaked them up. Nobody noticed.',{a:CITY[l.a].name,b:CITY[l.b].name}),'goal');return;}
|
||
const f=[0.6,0.8,0.7][v],dur=2+Math.floor(Math.random()*3);l.loss={until:S.day+dur,f};
|
||
const msg=[N_('A dirty connector on {a}–{b} drops 2% of packets. TCP hates it: throughput collapses even though the link looks fine.'),
|
||
N_('Microbursts on {a}–{b} overflow shallow router buffers: 0.5% loss at peak, and every video call notices.'),
|
||
N_('CRC errors on {a}–{b}: a marginal optic is mangling a few frames in every thousand.')][v];
|
||
addInc({type,ref:l.id,until:l.loss.until,msg:tr(msg,{a:CITY[l.a].name,b:CITY[l.b].name}),cost:900,fix:[tr('Clean the connector'),tr('Rate-limit the bursts'),tr('Swap the optic')][v]},msg);
|
||
}else if(type==='pmtud'){
|
||
const top=NETS.filter(n=>(R.demTo[n.id]||0)>0.5).sort((a,b)=>(R.demTo[b.id]||0)-(R.demTo[a.id]||0)).slice(0,8),n=pick(top.length?top:NETS),dur=2+Math.floor(Math.random()*3);
|
||
S.ev.pmtud={net:n.id,until:S.day+dur,f:0.6};
|
||
const msg=S.scrubAt&&Math.random()<0.5?N_('Your scrubbing center returns clean traffic over a GRE tunnel, and nobody clamped the MSS. Big packets to {net} vanish, so pages load halfway and stop.')
|
||
:pick([N_('Someone filtered all ICMP on your edge “for security”. Path MTU discovery broke, and connections to {net} hang right after the handshake.'),
|
||
N_('A PPPoE hop shaved 8 bytes off your MTU and nothing told the servers. Large transfers to {net} stall forever; small ones work fine, which makes it so much worse.')]);
|
||
addInc({type,ref:n.id,until:S.ev.pmtud.until,msg:tr(msg,{net:n.name}),cost:500,fix:tr('Clamp the MSS to 1360')},msg);
|
||
}else if(type==='mtu'){
|
||
const l=pick(live);l.deg=S.day+3;addInc({type,ref:l.id,until:l.deg,msg:tr('MTU mismatch on {a}–{b}: jumbo frames keep getting stuck in the tube. Usable capacity halved.',{a:CITY[l.a].name,b:CITY[l.b].name}),cost:800,fix:tr('Set MTU 9216 everywhere')});
|
||
}else if(type==='oops'||type==='cleaner'){
|
||
const c=pick(Object.keys(S.pops)),pp=S.pops[c],C=CITY[c].name;
|
||
if(type==='cleaner'&&pp.site2&&(pp.routers||1)<2){S.stats.survived++;addInc({type:'site',ref:c,site:'a',until:S.day+1,msg:tr('The cleaner unplugged everything at {siteA}.',{siteA:siteName(c,'a')}),cost:0});toast(tr('<b>Vacuum incident in {city}</b><br>The cleaner unplugged everything at {siteA}. {siteB} kept the city online at half capacity.',{city:C,siteA:esc(siteName(c,'a')),siteB:esc(siteName(c,'b'))}),'good');sfx('alert');return;}
|
||
if(type==='cleaner'&&(pp.routers||1)>=2){S.stats.incidents++;S.stats.survived++;toast(tr('<b>Vacuum incident in {city}</b><br>The cleaner at {dc} unplugged one of your routers to plug in a vacuum. The other one kept going. The floor is spotless.',{city:C,dc:CITY[c].dc}),'good');sfx('alert');return;}
|
||
pp.down=Math.max(pp.down||0,S.day+1);
|
||
const msg=type==='cleaner'?tr('The cleaner at {dc} unplugged your router to plug in a vacuum. The floor is spotless.',{dc:CITY[c].dc}):pick([tr('Your on-call engineer typed “clear bgp *” in production in {city} at 3am. It cleared.',{city:C}),tr('An intern pushed an ACL in {city} that denies 0.0.0.0/0. Very secure. Very offline.',{city:C}),tr('Someone ran “reload” on the {city} router, thinking it was their laptop terminal.',{city:C}),tr('A config template rendered “{{ router_id }}” literally in {city}. The router took it personally.',{city:C}),tr('Someone committed a config in {city} with “commit confirmed 1” and went to lunch.',{city:C}),tr('Someone deployed to {city} on a Friday at 16:59.',{city:C}),tr('A cosmic ray flipped a bit in your {city} router. It now believes 10.0.0.0/8 lives in Antarctica.',{city:C}),tr('An automation script in {city} ran “sed” on the whole config instead of one line. Every interface is now named “TODO”.',{city:C})]);
|
||
addInc({type,ref:c,until:pp.down,msg:msg+(type==='oops'&&(pp.routers||1)>=2?' '+tr('Automation pushed it to every router, so redundancy did not help.'):''),cost:1500,fix:type==='oops'?tr('Roll back the config'):tr('Hide the vacuum')});
|
||
}else if(type==='maxpfx'){
|
||
const c=pick(Object.keys(S.ixp));S.ev.ixdown=S.ev.ixdown||{};S.ev.ixdown[c]=Math.max(S.ev.ixdown[c]||0,S.day+1+Math.floor(Math.random()*2));
|
||
addInc({type,ref:c,until:S.ev.ixdown[c],msg:tr('A member at {ix} leaked the full routing table into the route server. Max-prefix limits tripped everywhere. Your peering there, in {city}, is down.',{ix:ixName(c),city:CITY[ixCity(c)].name}),cost:0});
|
||
}else if(type==='prepend'){
|
||
const t=pick(S.transit);t.down=Math.max(t.down||0,S.day+2);addInc({type,ref:t.id,until:t.down,msg:tr('{net} fat-fingered a route-map and prepended your AS {n} times in {city}. Nobody wants that path.',{net:NET[t.net].name,n:30+Math.floor(Math.random()*60),city:CITY[t.city].name}),cost:0});
|
||
}else if(type==='rpki'){
|
||
S.ev.rpki={until:S.day+3,nets:NETS.map(n=>n.id).filter(()=>Math.random()<0.5)};addInc({type,ref:'rpki',until:S.day+3,msg:tr('Your ROA expired over the weekend. Your prefixes are RPKI-invalid and about half the internet is dropping them.'),cost:1000,fix:tr('Renew the ROA')});
|
||
}else if(type==='amp'||type==='roadmff'){
|
||
const l=pick(lit),A=CITY[l.a].name,B=CITY[l.b].name,dur=type==='roadmff'?1:(l.spares?1:2+Math.floor(Math.random()*3));l.eqDown=S.day+dur;
|
||
const msg=type==='roadmff'?tr('You fat-fingered the channel plan on {a}–{b} and lit a new channel right on top of every existing one.',{a:A,b:B}):pick([tr('An in-line amplifier hut between {a} and {b} lost power. A family of mice had moved in.',{a:A,b:B}),tr('Someone stole the copper grounding from an amp hut on {a}–{b}. All channels dark.',{a:A,b:B}),tr('A firmware bug in the {sys} at {a} set every channel to “maintenance”.',{sys:DF_SYS[l.sys].n,a:A}),tr('Lightning hit an amp site on {a}–{b}. The surge protector was decorative.',{a:A,b:B})]);
|
||
addInc({type,ref:l.id,until:l.eqDown,msg:msg+(type==='amp'&&l.spares?' '+tr('Your spares kit gets it back tomorrow.'):''),cost:type==='amp'&&!l.spares?AMP_COST:0,fix:tr('Truck a spare amp out')});
|
||
}else if(type==='optic'){
|
||
const l=pick(lit),A=CITY[l.a].name,B=CITY[l.b].name,o=pick(l.ch),dur=l.spares?1:4;l.chFail={n:1,o,until:S.day+dur};
|
||
addInc({type,ref:l.id,until:S.day+dur,msg:pick([tr('A {optic} on {a}–{b} overheated and is now a very expensive keychain.',{optic:OPT[o].n,a:A,b:B}),tr('The laser in a {optic} on {a}–{b} died. One channel dark.',{optic:OPT[o].n,a:A,b:B}),tr('A {optic} on {a}–{b} started reporting a temperature of 900°C. It was wrong, but it shut down anyway.',{optic:OPT[o].n,a:A,b:B})])+(l.spares?' '+tr('Swapped from your spares kit by tomorrow.'):''),cost:l.spares?0:OPT[o].cost,fix:tr('Buy a replacement')});
|
||
}else if(type==='cut'){
|
||
const mon=Math.floor((S.day%365)/30.42),monsoon=mon>=5&&mon<=8,tw=x=>x.sub&&(x.a==='tpe'||x.b==='tpe'||['clion','balt'].includes(x.cable)),vn=x=>x.sub&&(x.a==='sgn'||x.b==='sgn'),inl=x=>!x.sub&&(CITY[x.a].india||CITY[x.b].india);
|
||
const l=pick(live.flatMap(x=>{const w=(x.cable&&CAB[x.cable].age==='old'?3:1)*(tw(x)?4*(scnRule('anchors')?3:1):1)*(scnRule('sharks')&&x.sub?2:1)*(vn(x)?3:1)*(!x.sub&&andesPair(x.a,x.b)?4:1)*(monsoon&&inl(x)?3:1)*(x.sub&&(x.a==='oos'||x.b==='oos')?3:1);return Array(w).fill(x);})),dur=10+Math.floor(Math.random()*8),trc=l.trench||l.id,hit=S.links.filter(x=>(x.trench||x.id)===trc);hit.forEach(x=>x.cut=Math.max(x.cut||0,S.day+dur));
|
||
const A=CITY[l.a].name,B=CITY[l.b].name;
|
||
const en=vn(l)&&Math.random()<0.8?pick([N_('Another of Vietnam’s subsea cables is broken: your {a}–{b} link. The repair ship will come after the holidays. Which holidays is unclear.'),N_('Your {a}–{b} cable broke in the same spot as last time. The repair crew recognised it.')]):!l.sub&&(l.a==='drw'||l.b==='drw')&&Math.random()<0.7?pick([N_('A crocodile took a bite out of your {a}–{b} fiber. It was not impressed.'),N_('Termites ate the duct on {a}–{b}. Then the fiber. Then the replacement duct.')]):tw(l)&&Math.random()<0.8?pick([N_('A cargo ship “forgot” to raise its anchor and dragged it across your {a}–{b} cable. The owners are very sorry, and somewhat hard to reach.'),N_('Another anchor, another cut: your {a}–{b} cable. The ship’s flag changed twice during the investigation.'),N_('A fishing boat with an unusually heavy anchor cut {a}–{b}. It was not fishing.')]):l.sub&&(l.a==='oos'||l.b==='oos')&&Math.random()<0.8?pick([N_('A trawler off Ostend dragged its gear straight through your {a}–{b} cable. The North Sea is about thirty metres deep and full of boats.'),N_('A wind-farm service vessel dropped anchor on your {a}–{b} cable. It was there to fix a turbine.')]):!l.sub&&(CITY[l.a].ca||CITY[l.b].ca)&&Math.random()<0.4?pick([N_('A beaver chewed through your {a}–{b} wave. It used the fiber to finish a dam.'),N_('Your {a}–{b} fiber is down. The repair crew found tooth marks, a lodge, and a very proud beaver.'),N_('Frost heave cracked the duct on {a}–{b}, and a beaver did the rest.')]):!l.sub&&andesPair(l.a,l.b)?pick([N_('A landslide in the Andes buried your {a}–{b} fiber.'),N_('Snow closed the mountain pass, and the repair crew with it: {a}–{b} is down.'),N_('An earthquake shook your {a}–{b} fiber loose somewhere above 4,000 metres.'),N_('A llama herd trampled the fiber marker on {a}–{b}. Then a backhoe found the fiber.')]):!l.sub&&(CITY[l.a].india||CITY[l.b].india)?pick([N_('Road widening near {a} cut your fiber to {b}. It is always road widening.'),N_('The monsoon flooded a manhole on {a}–{b}. The fiber is now underwater, as is the manhole.'),N_('A digger found your {a}–{b} fiber. A different digger is coming to fix it.')]):l.sub?pick([N_('A curious shark bit your subsea cable {a}–{b}.'),N_('A ship dragged its anchor across your {a}–{b} cable.'),N_('An undersea landslide snapped {a}–{b}.')]):pick([N_('A backhoe found your fiber between {a} and {b}.'),N_('Squirrels chewed through {a}–{b}. They regret nothing.'),N_('Road works cut {a}–{b}. Nobody called before digging.')]);
|
||
addInc({type,ref:trc,until:S.day+dur,msg:tr(en,{a:A,b:B})+(hit.length>1?' '+tr('All {n} links in that trench went down with it.',{n:hit.length}):''),cost:Math.max(4000,Math.round(hit.reduce((a,x)=>a+x.mo,0)*0.5))},en);
|
||
}else if(type==='crash'||type==='power'){
|
||
const c=pick(Object.keys(S.pops).flatMap(x=>type==='power'&&(CITY[x].za||CITY[x].blackout)?[x,x,x]:type==='crash'&&RG[S.pops[x].rgen||0].flaky?[x,x,x]:[x])),pp=S.pops[c],slow=slowBoot(c),dur=(type==='crash'?2+Math.floor(Math.random()*2):3+Math.floor(Math.random()*3))*(type==='crash'&&S.ev.sanction>S.day?2:1)+(slow?2+Math.floor(Math.random()*3):0);
|
||
if(type==='crash'&&(pp.routers||1)>=2){pp.rdown=S.day+dur;S.stats.incidents++;S.stats.survived++;toast(tr('<b>Router crash in {city}</b><br>One router panicked and its twin took over.{slow} Capacity there is down one router for {d} days.',{city:CITY[c].name,slow:slow?' '+tr('The crashed one {what}.',{what:esc(pick(SLOW_BOOT))}):'',d:dur}),'good');sfx('alert');return;}
|
||
if(type==='power'&&!pp.gen&&pp.site2){const sd=Math.random()<0.5?'a':'b';addInc({type:'site',ref:c,site:sd,until:S.day+dur,msg:(CITY[c].za?tr('Load shedding took out {site} in {city}. {other} kept going, so the POP runs at half capacity. Anything plugged in only at the dark site is offline.',{site:siteName(c,sd),city:CITY[c].name,other:siteName(c,sd==='a'?'b':'a')}):tr('A power cut took out {site} in {city}. {other} kept going, so the POP runs at half capacity. Anything plugged in only at the dark site is offline.',{site:siteName(c,sd),city:CITY[c].name,other:siteName(c,sd==='a'?'b':'a')})),cost:5000,fix:tr('Rent a generator')});S.stats.survived++;return;}
|
||
if(type==='power'&&pp.gen&&CITY[c].blackout){S.stats.incidents++;S.stats.survived++;S.stats.shed=(S.stats.shed||0)+1;toast(tr('<b>Blackout in {city}</b><br>The grid went dark again. Your generator started on the first try, like it always does here.',{city:CITY[c].name}),'good');sfx('alert');return;}
|
||
if(type==='power'&&pp.gen){S.stats.incidents++;S.stats.survived++;if(CITY[c].za)S.stats.shed=(S.stats.shed||0)+1;toast(CITY[c].za?tr('<b>Load shedding in {city}</b><br>Stage {n} today. Your generator coughed, then kept the lights on.',{city:CITY[c].name,n:2+Math.floor(Math.random()*5)}):tr('<b>Power cut in {city}</b><br>Your backup generator kicked in. Lights stayed on.',{city:CITY[c].name}),'good');sfx('alert');return;}
|
||
pp.down=Math.max(pp.down||0,S.day+dur);
|
||
const msg=type==='crash'?(slow?tr('Your router in {city} crashed and is rebooting. It {what}. Boot time on this one: about {min} minutes per attempt, and it is on attempt {n}.',{city:CITY[c].name,what:pick(SLOW_BOOT),min:bootMin(c),n:2+Math.floor(Math.random()*5)}):pick([tr('Your router in {city} crashed. Kernel panic, packet panic.',{city:CITY[c].name}),tr('A firmware update bricked your router in {city}.',{city:CITY[c].name})])):CITY[c].blackout?tr('A blackout hit {city} and your POP has no generator. Every other network here has one. Buy one.',{city:CITY[c].name}):CITY[c].za?tr('Load shedding stage {n} in {city}, and you have no generator. Buy one: here it is not optional.',{n:3+Math.floor(Math.random()*4),city:CITY[c].name}):tr('Power outage at {dc} in {city}. The generator did not start.',{dc:CITY[c].dc,city:CITY[c].name});
|
||
addInc({type,ref:c,until:S.pops[c].down,msg,slow:type==='crash'&&slow,cost:type==='crash'?2500:7000,fix:type==='crash'?(slow?tr('Turn it off and on again (it will take a while)'):tr('Turn it off and on again')):tr('Rent a generator')});
|
||
}else if(type==='transit'){
|
||
const t=pick(S.transit.filter(t=>!(t.down>S.day)));t.down=S.day+3+Math.floor(Math.random()*3);
|
||
addInc({type,ref:t.id,until:t.down,msg:tr('{net} is having an outage in {city}. Your transit port there is dark.',{net:NET[t.net].name,city:CITY[t.city].name}),cost:0});
|
||
}else if(type==='ixloop'){
|
||
const c=pick(Object.keys(S.ixp));S.ev.ixdown=S.ev.ixdown||{};S.ev.ixdown[c]=Math.max(S.ev.ixdown[c]||0,S.day+2+Math.floor(Math.random()*2));
|
||
addInc({type,ref:c,until:S.ev.ixdown[c],msg:tr('Someone plugged a loop into the {ix} fabric. Broadcast storm! All peering there is down.',{ix:ixName(c)}),cost:0});
|
||
}else if(type==='leak'){
|
||
const n=pick(['nfx','ggl','fbk','amz','msf']);S.ev.leak={net:n,until:S.day+4};
|
||
addInc({type,ref:n,until:S.day+4,msg:tr("BGP route leak: a small ISP is announcing {net}'s prefixes. Traffic to them over transit is black-holed. Direct peering still works.",{net:NET[n].name}),cost:0});
|
||
}else if(type==='fabric'){
|
||
const f=pick(fabsUsed);S.ev.fab=S.ev.fab||{};S.ev.fab[f]=S.day+2+Math.floor(Math.random()*3);
|
||
addInc({type,ref:f,until:S.ev.fab[f],msg:tr('{fabric} is having a bad day. Every virtual circuit on their fabric is down.',{fabric:FAB[f].name}),cost:0});
|
||
}else if(type==='ddos'){ddosAttack();return;
|
||
}
|
||
compute();
|
||
const last=S.inc[S.inc.length-1];
|
||
last.impact=Math.max(0,before-R.served);
|
||
if(before>1&&last.impact<before*0.03&&type!=='ddos'){S.stats.survived++;toast(`<b>${incTitle(type)}</b><br>${esc(last.msg)} ${tr('Traffic rerouted, customers barely noticed.')}`,'good');}
|
||
else{const paused=pref('pauseIncident')&&autoPause();toast(`<b>${incTitle(type)}</b><br>${esc(last.msg)}${paused?`<br><b>${tr('Game paused.')}</b>`:''}`,'bad',(last.cost?[{l:`${last.fix||tr('Rush repair')} ${fmt$(last.cost)}`,act:'fixInc',args:{id:last.id}}]:[]).concat(paused?[resumeAct()]:[]));}
|
||
sfx('alert');
|
||
}
|
||
// A DDoS attack: mostly short, modest spikes; now and then a "botnet of toasters" monster into the terabits.
|
||
// In Flood Season (scenario rule ddos) they come more often, a third are monsters, and they grow over the year.
|
||
function ddosAttack(){const type='ddos',fl=scnRule('ddos'),grow=fl?1+S.day/180:1;if(S.ev.ddos&&S.ev.ddos.until>S.day)ddosDone(S.ev.ddos);
|
||
const c=pick(Object.keys(S.pops)),vec=pick(Object.keys(DDOS_VEC)),V=DDOS_VEC[vec];
|
||
const monster=Math.random()<(fl?0.33:0.15),base=Math.max(R.cityDem[c]||0,4);
|
||
const gbps=Math.round((monster?800+Math.random()*2600:2+Math.random()*Math.max(18,base*0.9))*grow);
|
||
const dur=2+Math.floor(Math.random()*4),entry=ddosEntry(c);
|
||
S.ev.ddos={city:c,vec,gbps,until:S.day+dur,entry,bh:false,start:S.day};
|
||
const soaked=(V.fs&&fsAt(c))||S.scrubAt;
|
||
const how=entry&&entry.lab?tr(', in via {e}',{e:entry.lab}):'';
|
||
const msg=tr('A {size} {vec} attack is hitting {city}{how}.',{size:fmtG(gbps),vec:V.n,city:CITY[c].name,how})+' '+(soaked?tr('Your mitigation is eating most of it.'):tr('Junk traffic is eating your capacity. Open the NOC to fight back.'));
|
||
if(fl)S.ev.ddos.who=pick(FLOOD_WHO);
|
||
addInc({type,ref:c,until:S.day+dur,msg:fl?msg+' '+tr('Attacker: {who}.',{who:tr(S.ev.ddos.who)}):msg,cost:0});
|
||
if(soaked){S.stats.survived++;S.stats.ddosHeld=(S.stats.ddosHeld||0)+1;if(gbps>=1000)S.stats.ddosMonster=(S.stats.ddosMonster||0)+1;}
|
||
compute();
|
||
toast(`<b>${incTitle('ddos')}: ${esc(CITY[c].name)}</b><br>${esc(msg)}${fl?`<br><i>${esc(tr('Attacker: {who}.',{who:tr(S.ev.ddos.who)}))}</i>`:''}`,soaked?'goal':'bad',[{l:tr('Open NOC'),act:'leftTab',args:{t:'noc'}}]);
|
||
sfx('alert');}
|
||
// When an attack is over: was it held? Held means the city under attack got at least 97% of its traffic every day.
|
||
function ddosDone(a){if(!a||a.done)return;a.done=1;if(a.worst===undefined&&S.pops[a.city])a.worst=sfOf(R,a.city);const ok=(a.worst===undefined?1:a.worst)>=0.97;
|
||
if(ok){S.stats.ddosOk=(S.stats.ddosOk||0)+1;if(a.gbps>=1000)S.stats.ddosOkBig=(S.stats.ddosOkBig||0)+1;}else S.stats.ddosLost=(S.stats.ddosLost||0)+1;
|
||
if(scnRule('ddos')){const who=tr(a.who||FLOOD_WHO[0]);toast(ok?tr('<b>Flood held: {g}.</b><br>{who} gave up and went back to mining crypto.',{g:fmtG(a.gbps),who:who.charAt(0).toUpperCase()+who.slice(1)}):tr('<b>That one got through: {g}.</b><br>{city} sank to {p}. Somewhere, {who} is very proud of itself.',{g:fmtG(a.gbps),city:CITY[a.city]?CITY[a.city].name:tr('Your network'),p:pct(a.worst||0),who}),ok?'goal':'bad');}}
|
||
const FLOOD_WHO=[N_('a botnet of 40,000 smart toasters'),N_('every unpatched baby monitor in Europe'),N_('a gaming clan that lost one match'),N_('a fridge that achieved sentience and chose violence'),N_('a crypto bro shorting your stock'),N_('a teenager with a stolen credit card and a grudge'),N_('a rival ISP’s “stress test”'),N_('ten thousand smart light bulbs, blinking in unison'),N_('a printer. Just one printer. Nobody knows how'),N_('a botnet run from a cloud you also host'),N_('somebody who did not like your network name'),N_('the internet-connected kettles of a whole country')];
|
||
function incTitle(t){return {ring:tr('Metro ring cut'),site:tr('Site outage'),cut:tr('Fiber cut'),crash:tr('Router crash'),power:tr('Power outage'),transit:tr('Upstream outage'),ixloop:tr('IX meltdown'),leak:tr('Route leak'),ddos:tr('DDoS attack'),fabric:tr('Fabric outage'),depeer:tr('Peering spat'),fatwave:tr('Fat-fingered wave'),label:tr('Patch panel mishap'),mtu:tr('MTU mismatch'),krroute:tr('Rerouted via Hong Kong'),ctrlplane:tr('Control plane meltdown'),lacp:tr('LACP trouble'),loss:tr('Packet loss'),pmtud:tr('PMTUD black hole'),oops:tr('Oops'),cleaner:tr('Vacuum incident'),maxpfx:tr('Max-prefix meltdown'),prepend:tr('Prepend-ageddon'),rpki:tr('RPKI invalid'),amp:tr('Amplifier failure'),roadmff:tr('Fat-fingered ROADM'),optic:tr('Dead optic'),maint:tr('Maintenance window'),ac:tr('Cooling failure'),hijack:tr('BGP hijack'),shutdown:tr('Government shutdown'),redsea:tr('Geopolitical cable cut')}[t]||tr('Incident');}
|
||
const LINKCUT_TR=['cut','redsea'],LINKCUT_ID=['fatwave','label'],POPDOWN=['crash','power','oops','cleaner','maint','shutdown'],IXDOWN=['ixloop','maxpfx'],TDOWN=['transit','prepend'],LINKEQ=['mtu','amp','roadmff','optic'];
|
||
function remainUntil(pred){let u=0;for(const x of S.inc)if(pred(x))u=Math.max(u,x.until);return u;}
|
||
// Remove an incident, then restore each affected thing to whatever other incidents still hold it down.
|
||
function clearInc(i){
|
||
S.inc=S.inc.filter(x=>x!==i);const T=i.type;
|
||
if(LINKCUT_TR.includes(T)||LINKCUT_ID.includes(T)){const ls=LINKCUT_TR.includes(T)?S.links.filter(l=>(l.trench||l.id)===i.ref):S.links.filter(l=>l.id===i.ref);
|
||
for(const l of ls)l.cut=remainUntil(x=>(LINKCUT_TR.includes(x.type)&&x.ref===(l.trench||l.id))||(LINKCUT_ID.includes(x.type)&&x.ref===l.id));}
|
||
else if(POPDOWN.includes(T)){if(S.pops[i.ref])S.pops[i.ref].down=remainUntil(x=>POPDOWN.includes(x.type)&&x.ref===i.ref);}
|
||
else if(IXDOWN.includes(T)){if(S.ev.ixdown)S.ev.ixdown[i.ref]=remainUntil(x=>IXDOWN.includes(x.type)&&x.ref===i.ref);}
|
||
else if(TDOWN.includes(T)){const t=S.transit.find(x=>x.id===i.ref);if(t)t.down=remainUntil(x=>TDOWN.includes(x.type)&&x.ref===i.ref);}
|
||
else if(T==='rpki'||T==='hijack'){if(!S.inc.some(x=>x.type==='rpki'||x.type==='hijack'))S.ev.rpki=null;}
|
||
else if(T==='leak'){S.ev.leak=null;}
|
||
else if(T==='ddos'){const a=S.ev.ddos;if(a&&a.city===i.ref&&(a.start===undefined||a.start===i.start)){ddosDone(a);S.ev.ddos=null;}}
|
||
else if(T==='fabric'){if(S.ev.fab)S.ev.fab[i.ref]=remainUntil(x=>x.type==='fabric'&&x.ref===i.ref);}
|
||
else if(T==='mtu'){const l=S.links.find(x=>x.id===i.ref);if(l)l.deg=remainUntil(x=>x.type==='mtu'&&x.ref===i.ref);}
|
||
else if(T==='loss'){const l=S.links.find(x=>x.id===i.ref);if(l&&!S.inc.some(x=>x.type==='loss'&&x.ref===i.ref))l.loss=null;}
|
||
else if(T==='lacp'){if(!S.inc.some(x=>x.type==='lacp'&&x.ref===i.ref)){const [k,...r]=String(i.ref).split(':'),id=r.join(':');if(k==='ix'){if(S.ev.ixlacp)delete S.ev.ixlacp[id];}else{const o=(k==='t'?S.transit:S.pni).find(x=>x.id===id);if(o)o.lacp=null;}}}
|
||
else if(T==='ctrlplane'){for(const id of Array.isArray(i.links)?i.links:[]){const l=S.links.find(x=>x.id===id);if(l)l.cut=Math.max(remainUntil(x=>(LINKCUT_TR.includes(x.type)&&x.ref===(l.trench||l.id))||(LINKCUT_ID.includes(x.type)&&x.ref===l.id)||(x.type==='ctrlplane'&&Array.isArray(x.links)&&x.links.includes(l.id))),0);}}
|
||
else if(T==='pmtud'){if(!S.inc.some(x=>x.type==='pmtud'))S.ev.pmtud=null;}
|
||
else if(T==='ring'){if(S.pops[i.ref])S.pops[i.ref].ringcut=remainUntil(x=>x.type==='ring'&&x.ref===i.ref);}
|
||
else if(T==='ac'){if(S.pops[i.ref])S.pops[i.ref].hot=remainUntil(x=>x.type==='ac'&&x.ref===i.ref);}
|
||
else if(T==='amp'||T==='roadmff'){const l=S.links.find(x=>x.id===i.ref);if(l)l.eqDown=remainUntil(x=>(x.type==='amp'||x.type==='roadmff')&&x.ref===i.ref);}
|
||
else if(T==='optic'){const l=S.links.find(x=>x.id===i.ref);if(l&&!S.inc.some(x=>x.type==='optic'&&x.ref===i.ref))l.chFail=null;}
|
||
}
|
||
function purgeInc(){S.inc=S.inc.filter(i=>{const T=i.type;if(LINKCUT_TR.includes(T))return S.links.some(l=>(l.trench||l.id)===i.ref);if(LINKCUT_ID.includes(T)||LINKEQ.includes(T))return S.links.some(l=>l.id===i.ref);if(TDOWN.includes(T))return S.transit.some(t=>t.id===i.ref);if(IXDOWN.includes(T))return S.ixp[i.ref]!==undefined;if(POPDOWN.includes(T)||T==='ac')return !!S.pops[i.ref];return true;});}
|
||
function fireEvent(){
|
||
const opts=['viral','price','grant'];
|
||
if(S.day>50)opts.push('sanction','tariff','hijack','landban','shutdown','redsea','baltic');
|
||
if(S.day>90&&S.links.filter(l=>l.kind==='wave'&&!l.sub).length>=3)opts.push('ctrlplane');
|
||
if(Object.keys(S.pops).some(ruCity))opts.push('runet','runet');
|
||
if(S.pops.doh&&Object.keys(S.pops).some(c=>CITY[c].gcc||CITY[c].uae)&&!(S.ev.gulf>S.day))opts.push('gulf');
|
||
if(Object.keys(S.pops).some(c=>CITY[c].saudi))opts.push('mega');
|
||
if(['mnl','hkg','tok','icn','sha','jkt'].some(c=>S.pops[c]))opts.push('typhoon');
|
||
if(S.pops.icn&&!S.krExit)opts.push('krexit');if(S.pops.icn&&!(S.ev.krroute>S.day))opts.push('krroute');
|
||
if(Object.keys(S.pops).some(cnCity)||R.gfwCross>1)opts.push('golden','gfw');
|
||
if(S.transit.some(t=>t.net==='cog'))opts.push('depeer','depeer');
|
||
if(Object.keys(S.peers).some(k=>k.startsWith('drz@'))||Object.keys(S.rs).length)opts.push('cake');
|
||
const e=pick(opts);
|
||
if(e==='gulf'){const dur=60+Math.floor(Math.random()*60);S.ev.gulf=S.day+dur;toast(tr('<b>The neighbours have fallen out.</b><br>A diplomatic spat closes borders and airspace around Qatar. Every link between Doha and Saudi Arabia or the UAE is down for about {n} days. Route the long way round, by sea.',{n:dur}),'bad');sfx('alert');}
|
||
/* A wave supplier pushes one bad update to its optical control plane, and every wave it sells you in a
|
||
region goes dark for a day or two. Your own dark fiber, subsea waves and fabric circuits keep working. */
|
||
if(e==='ctrlplane'){const by={};for(const l of S.links)if(l.kind==='wave'&&!l.sub&&!(l.cut>S.day)){const r=CITY[l.a].reg;(by[r]=by[r]||[]).push(l);}
|
||
const reg=Object.keys(by).sort((a,b)=>by[b].length-by[a].length)[0];if(!reg)return;const hit=by[reg],until=S.day+2;
|
||
for(const l of hit)l.cut=Math.max(l.cut||0,until);
|
||
const RN={EU:tr('Europe'),AM:tr('North America'),SA:tr('South America'),AS:tr('Asia'),OC:tr('Oceania'),AF:tr('Africa')};
|
||
addInc({type:'ctrlplane',ref:'reg:'+reg,links:hit.map(l=>l.id),until,msg:tr('Your wave supplier pushed one malformed update to its optical control plane, and it flooded every node. All {n} leased waves you have in {reg} are dark. Their status page says “degraded”.',{n:hit.length,reg:RN[reg]||reg}),cost:Math.round(hit.reduce((a,l)=>a+l.mo,0)*0.3),fix:tr('Escalate to their CTO')},'ctrlplane');
|
||
toast(tr('<b>Optical control plane meltdown!</b><br>Every leased wave in {reg} just went dark at once. Your own dark fiber is fine. This is why people own fiber.',{reg:RN[reg]||reg}),'bad');sfx('alert');return;}
|
||
if(e==='krexit'){S.krExit=S.day+1;S.stats.incidents++;S.stats.survived++;
|
||
toast(tr('<b>Glitch is leaving Korea.</b><br>The game-streaming site says Korean network fees are “prohibitively expensive” and shuts down there. Its Seoul traffic drops by half, for good. Local streamers have already moved on.'),'bad');sfx('alert');return;}
|
||
if(e==='krroute'){S.ev.krroute=S.day+20;addInc({type:'krroute',ref:'icn',until:S.day+20,msg:tr('Faceplant got tired of Korean usage fees and quietly moved Korean users to its Hong Kong servers. Pages crawl in for everyone in Seoul. The regulator is drafting a fine.'),cost:0},'krroute');
|
||
toast(tr('<b>Faceplant rerouted Korea via Hong Kong.</b><br>Seoul users get a fifth less of it for 20 days, however you connect.'),'bad');sfx('alert');return;}
|
||
if(e==='mega'){const c=pick(Object.keys(S.pops).filter(x=>CITY[x].saudi)),bw=pick([800,1600,3200]),start=S.day+15;S.offers.push({id:uid(),city:c,city2:null,name:tr('A futuristic city that is not built yet, demo day in {city}',{city:CITY[c].name}),type:'event',bw,rate:0,reqs:[],start,dur:4,fee:bw*4*90,exp:start-2});toast(tr('<b>A gigaproject wants a demo.</b><br>{bw} for four days in {city}, to show off a city that is still mostly renderings. Check the Deals tab.',{bw:fmtG(bw),city:CITY[c].name}),'goal');}
|
||
if(e==='sanction'){S.ev.sanction=S.day+60;toast(tr('<b>Sanctions!</b><br>The Republic of Paperworkistan sanctioned your router vendor’s favorite screw supplier. Spare parts are slow: router crashes take twice as long to fix for 60 days.'),'bad');sfx('alert');return;}
|
||
if(e==='tariff'){S.ev.tariff=S.day+90;toast(tr('<b>Trade war on optics</b><br>Two governments slapped tariffs on each other’s lasers. Optics cost 40% more for 90 days.'),'bad');sfx('alert');return;}
|
||
if(e==='hijack'){const nh=NETS.map(n=>n.id).filter(()=>Math.random()<0.6),old=S.ev.rpki&&S.ev.rpki.until>S.day?S.ev.rpki:null;S.ev.rpki=old?{until:Math.max(old.until,S.day+1),nets:[...new Set(old.nets.concat(nh))]}:{until:S.day+1,nets:nh};addInc({type:'hijack',ref:'rpki',until:S.day+1,msg:tr('A state-owned ISP “accidentally” announced your prefixes for 18 minutes. Their apology press release was suspiciously well written. Many networks are still routing your traffic into the void.'),cost:1500,fix:tr('Call everyone you know')});toast(tr('<b>BGP hijack</b><br>Someone else is announcing your prefixes. Reach is down until it is cleaned up.'),'bad');sfx('alert');return;}
|
||
if(e==='landban'){const lc=[...new Set(CABLE_PAIRS.flatMap(c=>[c.a,c.b]))];const c=pick(lc);S.ev.landban={city:c,until:S.day+45};toast(tr('<b>Landing permit dispute in {city}</b><br>Two ministries both claim the beach. No new subsea links can land there for 45 days.',{city:CITY[c].name}),'bad');return;}
|
||
if(e==='shutdown'){const ps=Object.keys(S.pops).filter(c=>c!==S.home);if(!ps.length)return;const c=pick(ps);S.pops[c].down=Math.max(S.pops[c].down||0,S.day+1);addInc({type:'shutdown',ref:c,until:S.day+1,msg:tr('Regulators ordered every network in {city} to switch off for a day during national school exams. Yes, this really happens.',{city:CITY[c].name}),cost:0});toast(tr('<b>Ordered offline in {city}</b><br>A government exam-day shutdown. Your POP there is dark for a day.',{city:CITY[c].name}),'bad');sfx('alert');return;}
|
||
if(e==='typhoon'){const c=pick(['mnl','hkg','tok','icn','sha','jkt'].filter(x=>S.pops[x])),p=S.pops[c],nm=pick([tr('Typhoon Bandwidth'),tr('Typhoon Latency'),tr('Typhoon Jitter'),tr('Typhoon Packet-Loss')]);
|
||
if(p.gen){S.stats.survived++;toast(tr('<b>{name} hits {city}</b><br>The grid is down, but your backup generator kept the routers running.',{name:nm,city:CITY[c].name}),'good');sfx('alert');return;}
|
||
p.down=Math.max(p.down||0,S.day+2);addInc({type:'power',ref:c,until:p.down,msg:tr('{name} knocked out power in {city}. Your POP has no generator.',{name:nm,city:CITY[c].name}),cost:7000,fix:tr('Rent a generator')});toast(tr('<b>{name} hits {city}</b><br>Power is out and your POP is dark for two days. A generator would have saved it.',{name:nm,city:CITY[c].name}),'bad');sfx('alert');compute();return;}
|
||
if(e==='runet'){S.ev.runet=S.day+1;toast(tr('<b>Sovereign internet drill</b><br>Moscow unplugged itself from the rest of the internet for a day to see what happens. Everything leaving Russia is dark until tomorrow.'),'bad');sfx('alert');compute();return;}
|
||
if(e==='baltic'){const BAL=['clion','havf','danice'];const hit=S.links.filter(l=>l.cable&&BAL.includes(l.cable)&&!(l.cut>S.day));
|
||
if(!hit.length){toast(tr('<b>Baltic cable damaged</b><br>A cargo ship dragged its anchor for 100 km and swears it noticed nothing. You have no links on those cables.'),'goal');return;}
|
||
const dur=15+Math.floor(Math.random()*15),en=N_('A cargo ship dragged its anchor along the Baltic seabed for 100 km and swears it noticed nothing. Investigators are “looking into it”.');for(const tk of new Set(hit.map(l=>l.trench||l.id))){S.links.filter(l=>(l.trench||l.id)===tk).forEach(l=>l.cut=Math.max(l.cut||0,S.day+dur));addInc({type:'redsea',ref:tk,until:S.day+dur,msg:tr(en),cost:0},en);}
|
||
toast(tr('<b>Baltic cable damaged</b><br>{n} of your links are down for about {d} days.',{n:hit.length,d:dur}),'bad');sfx('alert');compute();return;}
|
||
if(e==='redsea'){const RED=['twoaf','smw6','peace','aae','eig','eassy'];const hit=S.links.filter(l=>l.cable&&RED.includes(l.cable)&&!(l.cut>S.day));
|
||
if(!hit.length){toast(tr('<b>Cables cut in the Red Sea</b><br>A ship dragged its anchor across several cables. Everyone blames everyone. Luckily you do not use those cables.'),'goal');return;}
|
||
const dur=20+Math.floor(Math.random()*15),en=N_(`A ship drifting without power dragged its anchor through the Red Sea cables. Everyone blames everyone. Repair ships need permits from three governments.`);for(const tk of new Set(hit.map(l=>l.trench||l.id))){S.links.filter(l=>(l.trench||l.id)===tk).forEach(l=>l.cut=Math.max(l.cut||0,S.day+dur));addInc({type:'redsea',ref:tk,until:S.day+dur,msg:tr(en),cost:0},en);}
|
||
toast(tr('<b>Cables cut in the Red Sea</b><br>{n} of your subsea links are down for about {d} days while the diplomats argue about repair ships.',{n:hit.length,d:dur}),'bad');sfx('alert');compute();return;}
|
||
if(e==='golden'){S.ev.golden=S.day+7;toast(tr('<b>Golden Week!</b><br>Demand in mainland China is up 40% for a week.'),'goal');return;}
|
||
if(e==='gfw'){S.ev.gfw=S.day+10;toast(tr('<b>The border got stricter.</b><br>Cross-border packet loss rises to 35% for 10 days. Premium routes are barely affected.'),'bad');sfx('alert');return;}
|
||
if(e==='viral'){S.ev.viral=S.day+8;toast(tr('<b>New season of “Stranger Pings” just dropped!</b><br>Eyeball demand is up 25% for a week. Got headroom?'),'goal');}
|
||
else if(e==='price'){S.priceMul*=0.92;toast(tr('<b>Transit prices fell 8%.</b><br>They do this every year. Nobody knows where the bottom is.'),'good');}
|
||
else if(e==='grant'){S.cash+=30000;toast(tr('<b>Rural broadband grant: +$30k</b><br>The Ministry of Tubes likes what you are doing.'),'good');sfx('coin');}
|
||
else if(e==='depeer'){S.ev.depeer=S.day+20;addInc({type:'depeer',ref:'cog',until:S.day+20,msg:tr('Cogentle and Goggle are in a peering spat. Goggle is unreachable through Cogentle transit.'),cost:0});toast(tr('<b>Peering spat!</b><br>Cogentle de-peered Goggle for 20 days. Goggle traffic over Cogentle transit is gone. Peer with Goggle directly or use another upstream.'),'bad');sfx('alert');}
|
||
else if(e==='cake'){S.cash+=8000;toast(tr('<b>Drizzle Electric sent you an IPv6 cake.</b><br>You sold it for $8k.'),'good');sfx('coin');}
|
||
}
|
||
|
||
/* ---------- daily tick ---------- */
|
||
function dayTick(){
|
||
if(!S||S.lost)return;
|
||
S.day++;
|
||
const d=S.day;
|
||
dkTick(d);ixPriceWar(d);
|
||
if(!S.phpDone&&d>45&&Math.random()<1/400)elephant();
|
||
if(R&&R.teMoved)S.stats.teMax=Math.max(S.stats.teMax||0,R.teMoved);
|
||
{const t1=!!S.won&&isTier1();if(S.t1Now&&!t1)toast(tr('<b>You are no longer Tier 1.</b><br>Because {why}. Your Tier 1 badge stays; win the status back to show it again.',{why:t1Why()}),'bad');S.t1Now=t1;}
|
||
if(S.grace&&S.grace.until===d){toast(tr('<b>The courtesy route has ended.</b><br>New networks you have not connected to are now only reachable through your own peering and transit.'),'bad',[{l:tr('Open NOC'),act:'leftTab',args:{t:'noc'}}]);}
|
||
{const a=S.ev.ddos;if(a&&a.until>d&&R&&S.pops[a.city])a.worst=Math.min(a.worst===undefined?1:a.worst,sfOf(R,a.city));}
|
||
if(scnRule('ddos')&&!(S.scn.done||S.scn.failed)&&d>=(+S.scn.nextDdos||3)&&!(S.ev.ddos&&S.ev.ddos.until>d)){ddosAttack();S.scn.nextDdos=d+3+Math.floor(Math.random()*5);}
|
||
if(R&&R.demand>0)S.stats.clean=R.served/R.demand>=0.995?(S.stats.clean||0)+1:0;
|
||
if(S.ev.php===d)toast(tr('<b>The internet is back.</b><br>Half of it, anyway. Everything was patched in a hurry and nobody learned anything.'),'good');
|
||
for(const k in S.peers){const [id,c]=k.split('@'),sn=snub(id,c);if(!sn)continue;delete S.peers[k];S.stats.depeered=(S.stats.depeered||0)+1;
|
||
toast(tr('<b>{net} de-peered you at {ix} in {city}.</b><br>{why} Traffic falls back to your next best path.',{net:esc(NET[id].name),ix:esc(ixName(c)),city:esc(CITY[ixCity(c)].name),why:esc(sn.why)}),'bad');}
|
||
if(S.cnLic&&S.cnLic.state==='pending'&&d>=S.cnLic.ready){S.cnLic.state='ok';toast(tr('<b>License granted!</b><br>Your joint venture can now build POPs in mainland China.'),'goal');sfx('coin');}
|
||
// resolve incidents
|
||
for(const i of S.inc.slice())if(i.until<=d){clearInc(i);toast(tr('<b>Resolved:</b> {what} is fixed.',{what:incTitle(i.type).toLowerCase()}),'good');}
|
||
// eyeball growth / churn uses last computed service
|
||
for(const c in S.pops){const p=S.pops[c];if(!p.bb)continue;const sf=sfOf(R,c),P=eyeP(c);
|
||
if(sf>=0.9){const g=(CITY[c].be&&!(p.boost>d)?0.35:1)*0.025*(scnRule('boom')?1.5:1)*(p.boost>d?2:1)*sf*(0.7+0.6*(R.peerShare||0))*(CITY[c].reg==='AS'&&!CITY[c].cn?1.6:1);p.bb.d+=g*p.bb.d*(1-p.bb.d/P);}
|
||
else p.bb.d=Math.max(3,p.bb.d*(1-(0.9-sf)*0.04));}
|
||
compute();
|
||
for(const t of S.transit){(t.hist=t.hist||[]).push(R.useT[t.id]||0);if(t.hist.length>30)t.hist.shift();}
|
||
S.cash+=(R.revMo-R.costMo)/30;
|
||
S.stats.peak=Math.max(S.stats.peak,R.served);
|
||
S.hist=S.hist||[];S.hist.push({d,dem:+R.demand.toFixed(2),srv:+R.served.toFixed(2),c:+(R.egT.c||0).toFixed(2),p:+(R.egT.p||0).toFixed(2),ix:+(R.egT.ix||0).toFixed(2),t:+(R.egT.t||0).toFixed(2),l2:+(R.egT.l2||0).toFixed(2),rev:Math.round(R.revMo),cost:Math.round(R.costMo),cash:Math.round(S.cash),inc:S.inc.length});if(S.hist.length>180)S.hist.shift();
|
||
{const top=custLevel();if(top>(S.lvl||1)){for(let lv=(S.lvl||1)+1;lv<=top;lv++){track('level_'+lv);toast(tr('<b>Customer level {lv}: {name}</b><br>New customers unlocked: {unlock}',{lv,name:LEVELS[lv-1].n,unlock:LEVELS[lv-1].unlock})+`<br><i>${esc(LEVELS[lv-1].q)}</i>`,'goal');}S.lvl=top;sfx('coin');}}
|
||
for(const l of S.links){if(l.kind!=='df')continue;
|
||
if(l.ready===d){toast(`<b>${l.own?tr('Your fiber is finished: {a}–{b}',{a:CITY[l.a].name,b:CITY[l.b].name}):tr('Dark fiber handed over: {a}–{b}',{a:CITY[l.a].name,b:CITY[l.b].name})}</b><br>${(l.ch||[]).length?tr('Channels are lighting up now.'):tr('It is dark. Add optics to light it up.')}`,'goal',[{l:tr('Open'),act:'selLink',args:{id:l.id}}]);sfx('coin');}
|
||
if(l.own&&l.ready>d&&Math.random()<0.012){const extra=10+Math.floor(Math.random()*40);l.ready+=extra;toast(tr('<b>Construction delay: +{n} days</b><br>{why} ({a}–{b})',{n:extra,why:pick(l.sub?SEA_DELAYS.map(x=>tr(x)):[tr('Archaeologists found a Roman bathhouse on your route.'),tr('A protected hamster species lives along the right-of-way.'),tr('The railway changed its mind about the easement.'),tr('The drilling crew hit a granite boulder the size of a bus.'),tr('A town council wants a public hearing. About the color of the manhole covers.'),tr('Somebody else’s gas main was exactly where the map said it was not.'),tr('The permit office lost your permit. And then the replacement.')]),a:CITY[l.a].name,b:CITY[l.b].name}),'bad');}}
|
||
// DDoS protection SLA: if a protected customer's own city is hit and still goes down, you pay out (once per attack).
|
||
if(S.ev.ddos&&S.ev.ddos.until>d){const a=S.ev.ddos;
|
||
for(const b of S.biz)if(b.type==='scrub'&&b.city===a.city&&b.slaFor!==a.start&&sfOf(R,b.city)<0.85){
|
||
b.slaFor=a.start;S.cash-=SLA_PEN;b.mood=Math.max(0,b.mood-18);S.stats.sla=(S.stats.sla||0)+1;
|
||
toast(tr('<b>SLA breach: {name}.</b><br>The attack on {city} got through and your protected customer went down. You owe {pen} in SLA credits.',{name:esc(b.name),city:CITY[a.city].name,pen:fmt$(SLA_PEN)}),'bad');sfx('err');}}
|
||
// businesses mood
|
||
for(const b of S.biz.slice()){if(eventTick(b,d))continue;b.pm=b.mood;const sf=bizSf(b),reachOk=BIZ_T[b.type].l2||BIZ_T[b.type].fiber||R.reach>0.99,scrubOk=b.type!=='scrub'||!!S.scrubAt,divOk=reqOk(b);
|
||
if(sf>=0.95&&reachOk&&scrubOk&&divOk)b.mood=Math.min(100,b.mood+2);
|
||
else if(S.day-(b.since||0)<15){}
|
||
else{b.mood-=(Math.max(0,0.95-sf)*45+(!reachOk?3:0)+(!scrubOk?4:0)+(!divOk?3:0));
|
||
if(b.mood<=0){S.biz=S.biz.filter(x=>x!==b);toast(tr('<b>{name} cancelled.</b><br>Too many outages and too little bandwidth in {city}.',{name:esc(b.name),city:CITY[b.city].name}),'bad');sfx('err');}
|
||
else if(b.mood<30&&!b.warned){b.warned=b.warn60=true;const why=bizWhy(b)[0],paused=pref('pauseFurious')&&autoPause();
|
||
toast(tr('<b>{name} is furious.</b><br>Fix service in {city} or they leave.',{name:esc(b.name),city:CITY[b.city].name})+(why?`<br><i>${esc(why)}</i>`:'')+(paused?`<br><b>${tr('Game paused.')}</b>`:''),'bad',[{l:tr('Show me'),act:'custGo',args:{id:b.id}}].concat(paused?[resumeAct()]:[]));sfx('err');}
|
||
else if(b.mood<60&&!b.warn60&&pref('warnUnhappy')){b.warn60=true;const why=bizWhy(b)[0];toast(tr('<b>{name} is getting unhappy.</b><br>Happiness {p}% in {city}.',{name:esc(b.name),p:Math.round(b.mood),city:CITY[b.city].name})+(why?`<br><i>${esc(why)}</i>`:''),'',[{l:tr('Show me'),act:'custGo',args:{id:b.id}}]);}}
|
||
if(b.mood>60)b.warned=false;if(b.mood>75)b.warn60=false;}
|
||
// own IX members join
|
||
for(const c in S.myIx){const m=S.myIx[c];if(d>=m.next&&m.members.length<myFab(c).max){
|
||
const cands=NETS.filter(n=>n.type!=='t1'&&!m.members.includes(n.id)&&(n.pops.includes(c)||n.pops.some(p=>CITY[p].reg===CITY[c].reg)));
|
||
if(cands.length){cands.sort((a,b)=>(a.pol==='open'?0:1)-(b.pol==='open'?0:1)||b.share-a.share);const n=Math.random()<.6?cands[0]:pick(cands);m.members.push(n.id);toast(tr('<b>{net} joined {ix}!</b><br>Another member paying {fee}/mo for a port.',{net:esc(n.name),ix:esc(m.name),fee:fmt$(MYIX_FEE)}),'good');sfx('coin');}
|
||
m.next=d+8+Math.floor(Math.random()*10);}}
|
||
loanTick(d);
|
||
if(S.mode==='sandbox'&&S.cash<1e8)S.cash=1e9;
|
||
// offers
|
||
S.offers=S.offers.filter(o=>o.exp>d);
|
||
if(S.offers.length<5&&Math.random()<0.05+0.01*(S.lvl||1))spawnOffer();
|
||
// failures & events
|
||
let dirty=false;
|
||
if(d>=S.nextFail){dirty=true;fireFailure();const size=S.links.length+Object.keys(S.pops).length;S.nextFail=d+Math.round((Math.max(22,50-size*1.5)+Math.floor(Math.random()*25))*(scnRule('chaos')?0.5:1));}
|
||
if(d>=S.nextEvent){dirty=true;fireEvent();S.nextEvent=d+45+Math.floor(Math.random()*45);}
|
||
if(dirty)compute();
|
||
// payday floaters
|
||
if(d%30===0){for(const c in S.pops){let v=(R.cityEye[c]*sfOf(R,c)*EYE_RATE)+S.biz.filter(b=>b.city===c).reduce((a,b)=>a+b.bw*b.rate,0);v=v-R.cityEye[c]*sfOf(R,c)*EYE_RATE*(1-(CITY[c].arpu||1));if(v>500)floater(CITY[c].x,CITY[c].y-30,'+'+fmt$(v),'#16A866');}sfx('coin');}
|
||
checkGoals();
|
||
scnTick(d);
|
||
confTick(d);
|
||
// money trouble
|
||
if(S.cash<0){S.neg++;if(S.neg===1)toast(tr('<b>You are in the red.</b><br>Cancel something expensive, wait for revenue, or check the bank for a loan. At −$100k the bank takes your routers.'),'bad');}
|
||
else S.neg=0;
|
||
if(S.cash<-100000){S.lost=true;track('bankrupt');showLose();return;}
|
||
if(d%360===0&&[1,2,4].includes(d/360))track('game_year_'+(d/360+1),true);
|
||
if(d%10===0)save();
|
||
}
|
||
function spawnOffer(){
|
||
const mine=Object.keys(S.pops),lv=S.lvl||1;
|
||
const types=['dia','dia','game','host'];if(mine.length>=2)types.push('l2vpn','l2vpn');if(S.day>60)types.push('scrub');
|
||
if(lv>=2)types.push('isp','stream','edu','host','hft','bulk','event','event');if(mine.length>=3&&lv>=2)types.push('sdwan','sdwan');
|
||
if(S.links.some(l=>l.kind==='df'&&l.ready<=S.day))types.push('wwave','wwave');if(S.links.some(l=>l.kind==='df'&&l.own&&l.ready<=S.day))types.push('dfpair');if(lv>=3)types.push('gpu','gpu','onramp','onramp');if(lv>=4)types.push('ai','ai','hyper','hyper');
|
||
if(lv>=3&&MEGA.some(m=>mine.includes(m.c)))types.push('ingest');if(lv>=4&&MEGA.some(m=>mine.includes(m.c)))types.push('aiwan','aiwan','mtrain');if(lv>=4&&S.links.some(l=>l.kind==='df'&&l.own&&l.ready<=S.day))types.push('pairs');
|
||
if(lv>=5)types.push('esport');if(lv>=6&&mine.length>=2)types.push('sov','sov');if(lv>=8)types.push('cgame','cgame');if(lv>=9)types.push('metav','metav');if(lv>=11&&MEGA.some(m=>mine.includes(m.c)))types.push('agi');if(lv>=13&&mine.length>=2)types.push('mars');
|
||
const br=mine.filter(c=>CITY[c].br);if(br.length)types.push('provedor','provedor','provedor');
|
||
const fabC=mine.filter(c=>FABS.some(f=>f.cities.includes(c)));if(lv>=2&&fabC.length){types.push('fabip','fabip');if(mine.length>=2)types.push('fabl2');}
|
||
const t=pick(types),T=BIZ_T[t];
|
||
if(T.event||T.sdwan||T.fiber||T.mega){spawnSpecial(t);return;}
|
||
if(T.nni){const city=pick(fabC),prov=pick(FABS.filter(f=>f.cities.includes(city))).id,bw=pick(T.opts),others=mine.filter(c=>c!==city),city2=T.l2&&others.length?pick(others):null;if(T.l2&&!city2)return;
|
||
const base=pick(BIZ_N.filter(n=>!S.usedNames.includes(n)).concat(BIZ_N)).replace(/ (Inc\.|Co\.|Ltd)$/,'');const name=tr('{name} via {fab}',{name:base,fab:FAB[prov].name});S.usedNames.push(base);
|
||
const rate=T.l2?Math.round((150+kmBetween(city,city2)*0.08)*T.km):T.rate;
|
||
S.offers.push({id:uid(),city,city2,prov,name,type:t,bw,rate,reqs:['nni'],exp:S.day+40});return;}
|
||
let city=(Math.random()<0.65&&mine.length)?pick(mine):pick(ALLC.concat(cnOk()?['pek','sha']:[])),city2=null;
|
||
if(T.l2){city=pick(mine);const pool=(Math.random()<(T.lv>=3?0.8:0.6)?mine:ALLC).filter(c=>c!==city);city2=pick(pool.length?pool:ALLC.filter(c=>c!==city));}
|
||
const bw=T.lv>=2?pick(T.opts):pick(T.opts.slice(0,mine.length>=4?4:3));
|
||
const list=(T.names||BIZ_N).filter(n=>!S.usedNames.includes(n));
|
||
let name=list.length?pick(list):(T.names?pick(T.names):'Startup #'+Math.floor(Math.random()*999));
|
||
S.usedNames.push(name);
|
||
if(t==='provedor')city=pick(br);
|
||
if(t==='hft'){const fin=['nyc','chi','lon','fra','tok','sin','hkg','ams','ash'],mf=mine.filter(c=>fin.includes(c));city=mf.length?pick(mf):pick(mine);city2=pick(fin.filter(c=>c!==city));}
|
||
const rate=T.l2?Math.round((150+kmBetween(city,city2)*0.08)*T.km):T.rate;
|
||
if(T.div&&!reqCan('diverse',{city,city2}))return;
|
||
const reqs=T.div?['diverse']:T.lat?['lat']:[];if((t==='hyper'||t==='ai'||t==='gpu')&&Math.random()<0.4)reqs.push('metro');const pool=Object.keys(REQS).filter(k=>!reqs.includes(k)&&!REQS[k].only&&(!REQS[k].l2||T.l2)&&(!REQS[k].ip||!T.l2)&&reqCan(k,{city,city2}));
|
||
if(Math.random()<(T.lv>=3?0.65:0.3))reqs.push(pick(pool));
|
||
if(T.lv>=3&&Math.random()<0.35){const more=pool.filter(k=>!reqs.includes(k));if(more.length)reqs.push(pick(more));}
|
||
const r2=Math.round(rate*(1+reqs.reduce((a,k)=>a+REQS[k].bonus,0)));
|
||
S.offers.push({id:uid(),city,city2,name,type:t,bw,rate:r2,reqs,latMax:T.lat?+(kmBetween(city,city2)/200*1.35).toFixed(1):null,exp:S.day+40});
|
||
}
|
||
/* Badges: achievements with rarities. Earned per game, and also remembered across games on this
|
||
device in a hall of fame, so there is always something grand to work towards. */
|
||
const RARITY={c:{n:tr('Common'),col:'#16A866'},r:{n:tr('Rare'),col:'#3A7BEA'},e:{n:tr('Epic'),col:'#9D4EDD'},l:{n:tr('Legendary'),col:'#FF8A3D'}};
|
||
const st=()=>S.stats||{};
|
||
const BADGES=[
|
||
{id:'hello',i:'👋',t:tr('Hello, Neighbour'),d:tr('Bring up your first peering session.'),r:'c',ok:()=>R.sessions>=1},
|
||
{id:'backhoe',i:'🚜',t:tr('Met the Backhoe'),d:tr('Have a fiber cut.'),r:'c',ok:()=>(st().by||{}).cut>=1},
|
||
{id:'debt',i:'🏦',t:tr('In Debt We Trust'),d:tr('Take out a loan.'),r:'c',ok:()=>(st().loans||0)>=1||(S.loans||[]).length>0},
|
||
{id:'twins',i:'👯',t:tr('Twins'),d:tr('Run two routers in one POP.'),r:'c',ok:()=>Object.values(S.pops).some(p=>(p.routers||1)>=2)},
|
||
{id:'shark',i:'🦈',t:tr('Shark Week'),d:tr('Get a subsea cable bitten by a shark.'),r:'r',ok:()=>(st().sharks||0)>=1},
|
||
{id:'ixc',i:'🔀',t:tr('IX Collector'),d:tr('Have ports on 10 internet exchanges.'),r:'r',ok:()=>Object.keys(S.ixp).length>=10},
|
||
{id:'haggle',i:'🤝',t:tr('Never Paid List Price'),d:tr('Haggle a DE-KICKS quote down.'),r:'r',ok:()=>!!st().haggleWin},
|
||
{id:'unsub',i:'📭',t:tr('Unsubscribed'),d:tr('Opt out of 3 auto-enrolled add-ons.'),r:'r',ok:()=>(st().optouts||0)>=3},
|
||
{id:'read',i:'💔',t:tr('Left on Read'),d:tr('Get de-peered by a big network.'),r:'r',ok:()=>(st().depeered||0)>=1},
|
||
{id:'couch',i:'🛋️',t:tr('Peering From the Couch'),d:tr('Peer at an IX remotely.'),r:'r',ok:()=>Object.keys(S.ixp).some(c=>isRemote(c)&&ixSessions(c).size>0)},
|
||
{id:'sender',i:'🇰🇷',t:tr('Sender Pays'),d:tr('Paid PNIs with all three Korean incumbents.'),r:'e',ok:()=>['ktt','skb','lgu'].every(n=>S.pni.some(p=>p.net===n))},
|
||
{id:'oink',i:'🐖',t:tr('Pig Whisperer'),d:tr('Run a slow-booting PacketOinker chassis.'),r:'r',ok:()=>Object.keys(S.pops).some(c=>/Oinker/.test(RG[S.pops[c].rgen||0].chip)&&slowBoot(c))},
|
||
{id:'gap',i:'🌴',t:tr('Mind the Gap'),d:tr('Link Panama City and Bogotá.'),r:'r',ok:()=>S.links.some(l=>[l.a,l.b].includes('pan')&&[l.a,l.b].includes('bog'))},
|
||
{id:'andes',i:'🏔️',t:tr('Over the Mountains'),d:tr('Build fiber across the Andes.'),r:'r',ok:()=>S.links.some(l=>!l.sub&&andesPair(l.a,l.b))},
|
||
{id:'duo',i:'🏜️',t:tr('Duopoly Customer'),d:tr('Buy a wave inside the UAE.'),r:'r',ok:()=>S.links.some(l=>uaePair(l.a,l.b))},
|
||
{id:'shed',i:'🔌',t:tr('Stage Six'),d:tr('Ride out load shedding on your own generator.'),r:'r',ok:()=>(st().shed||0)>=1},
|
||
{id:'metro3',i:'🏢',t:tr('Two Buildings, Three Cities'),d:tr('Have a second site in 3 metros.'),r:'r',ok:()=>Object.values(S.pops).filter(p=>p.site2).length>=3},
|
||
{id:'penguin',i:'🐧',t:tr('Lonely Penguin'),d:tr('Light a wave on the Humboldt cable to Sydney.'),r:'e',ok:()=>S.links.some(l=>l.cable==='humb')},
|
||
{id:'horn',i:'⛵',t:tr('The Long Way Round'),d:tr('Run a link round Cape Horn.'),r:'e',ok:()=>S.links.some(l=>l.cable==='sam1'&&[l.a,l.b].includes('bue')&&[l.a,l.b].includes('scl'))},
|
||
{id:'six',i:'🌍',t:tr('Six Continents'),d:tr('POPs in every region on the map.'),r:'e',ok:()=>regionsCount()>=6},
|
||
{id:'giants',i:'🏭',t:tr('Friend of Giants'),d:tr('Hold deals at 3 different AI campuses at once.'),r:'e',ok:()=>new Set(S.biz.filter(b=>BIZ_T[b.type]&&BIZ_T[b.type].mega).flatMap(b=>bCities(b))).size>=3},
|
||
{id:'landlord',i:'🧵',t:tr('Trench Landlord'),d:tr('Lease hundreds of fiber pairs to a hyperscaler.'),r:'e',ok:()=>S.biz.some(b=>b.type==='pairs')},
|
||
{id:'t1',i:'👑',t:tr('Tier 1'),d:tr('Go transit-free.'),r:'e',ok:()=>!!S.won},
|
||
{id:'bait',i:'🎣',t:tr('Shark Bait'),d:tr('Get bitten by sharks 3 times in one game.'),r:'l',ok:()=>(st().sharks||0)>=3},
|
||
{id:'nines',i:'💎',t:tr('Five Nines'),d:tr('Serve 99.5% of demand every single day for a whole year.'),r:'l',ok:()=>(st().clean||0)>=365},
|
||
{id:'fifty',i:'🗺️',t:tr('Everywhere at Once'),d:tr('Have POPs in 50 cities.'),r:'l',ok:()=>Object.keys(S.pops).length>=50},
|
||
{id:'unicorn',i:'🦄',t:tr('Unicorn'),d:tr('Hold a billion dollars in cash.'),r:'l',ok:()=>S.cash>=1e9},
|
||
{id:'clean',i:'🧼',t:tr('Debt-Free Tier 1'),d:tr('Win without ever taking a loan.'),r:'l',ok:()=>!!S.won&&!(st().loans||0)&&!(S.loans||[]).length},
|
||
{id:'speed',i:'⚡',t:tr('Speedrun'),d:tr('Reach Tier 1 within three years.'),r:'l',ok:()=>!!S.won&&S.day<=1095},
|
||
{id:'te',i:'🧭',t:tr('Traffic Whisperer'),d:tr('Have Auto-TE move 100 Gbps onto alternate paths at once.'),r:'r',ok:()=>(st().teMax||0)>=100},
|
||
{id:'street',i:'🚧',t:tr('Same Street'),d:tr('Lose a metro ring to one backhoe.'),r:'r',ok:()=>(st().by||{}).ring>=1},
|
||
{id:'anchor',i:'⚓',t:tr('Anchors Aweigh'),d:tr('Have a cable cut by a dragged anchor.'),r:'r',ok:()=>!!(st().f||{}).anchor},
|
||
{id:'retained',i:'🎁',t:tr('Customer Success Story'),d:tr('Take a DE-KICKS retention offer.'),r:'r',ok:()=>!!st().retained},
|
||
{id:'brrr',i:'🇧🇷',t:tr('Samba Peering'),d:tr('Ports on all three IX.brrr exchanges.'),r:'e',ok:()=>['sao','rio','for'].every(c=>S.ixp[c]!==undefined)},
|
||
{id:'bingo',i:'🎰',t:tr('DE-KICKS Bingo'),d:tr('Ports at all six DE-KICKS exchanges. They thank you for your continued partnership.'),r:'e',ok:()=>DK_CITIES.filter(c=>CITY[c]&&CITY[c].ix).every(c=>S.ixp[c]!==undefined)},
|
||
{id:'fire',i:'🌋',t:tr('Ring of Fire'),d:tr('POPs all the way round the Pacific: Los Angeles, Tokyo, Taipei, Manila, Jakarta, Sydney, Auckland and Santiago.'),r:'e',ok:()=>['lax','tok','tpe','mnl','jkt','syd','akl','scl'].every(c=>S.pops[c])},
|
||
{id:'curtain',i:'🎭',t:tr('Iron Curtain Call'),d:tr('POPs in Warsaw, Prague, Vienna, Budapest, Bucharest, Sofia, Belgrade and Tallinn.'),r:'e',ok:()=>['waw','prg','vie','bud','buh','sof','beg','tll'].every(c=>S.pops[c])},
|
||
{id:'islands',i:'🏝️',t:tr('Island Hopper'),d:tr('POPs in Reykjavik, Dublin, London, Colombo, Taipei, Manila, Tokyo and Auckland.'),r:'e',ok:()=>['rek','dub','lon','cbo','tpe','mnl','tok','akl'].every(c=>S.pops[c])},
|
||
{id:'wall',i:'🧱',t:tr('Through the Wall'),d:tr('Run a licensed POP in mainland China.'),r:'e',ok:()=>cnOk()&&Object.keys(S.pops).some(cnCity)},
|
||
{id:'beaver',i:'🦫',t:tr('Dam It'),d:tr('Have your fiber chewed through by a beaver.'),r:'e',ok:()=>!!(st().f||{}).beaver},
|
||
{id:'croc',i:'🐊',t:tr('Darwin Award'),d:tr('Have your fiber bitten by a crocodile.'),r:'l',ok:()=>!!(st().f||{}).croc},
|
||
{id:'unbreak',i:'🛡️',t:tr('Unbreakable'),d:tr('Survive 100 incidents without customer impact.'),r:'l',ok:()=>(st().survived||0)>=100},
|
||
{id:'lv13',i:'🌐',t:tr('Is This the Internet?'),d:tr('Reach customer level 13.'),r:'l',ok:()=>(S.lvl||1)>=13},
|
||
{id:'gigawatt',i:'⚛️',t:tr('Gigawatt Landlord'),d:tr('Hold an AI WAN, a training run, an ingest and a fiber-pairs deal at the same time.'),r:'l',ok:()=>['aiwan','mtrain','ingest','pairs'].every(t=>S.biz.some(b=>b.type===t))},
|
||
{id:'blitz',i:'🚀',t:tr('Blitz'),d:tr('Reach Tier 1 within two years.'),r:'l',ok:()=>!!S.won&&S.day<=730},
|
||
{id:'peta',i:'🌌',t:tr('Hundred Terabits'),d:tr('Serve 100 Tbps.'),r:'l',ok:()=>R.served>=100000},
|
||
{id:'petabit',i:'🪐',t:tr('A Petabit a Second'),d:tr('Serve 1 Pbps: a thousand terabits of happy traffic.'),r:'l',ok:()=>R.served>=1e6},
|
||
{id:'llama',i:'🦙',t:tr('Llama Drama'),d:tr('Lose fiber to a llama herd.'),r:'l',secret:true,ok:()=>!!(st().f||{}).llama},
|
||
{id:'hallway',i:'🎤',t:tr('Hallway Track'),d:tr('Attend a conference.'),r:'r',ok:()=>(st().confs||0)>=1},
|
||
{id:'beer',i:'🍺',t:tr('Peering Over Beer'),d:tr('Set up a PNI while the conference glow lasts.'),r:'e',ok:()=>!!st().beerPni},
|
||
{id:'circuit',i:'✈️',t:tr('Conference Circuit'),d:tr('Attend six conferences in one game.'),r:'l',ok:()=>(st().confs||0)>=6},
|
||
{id:'kiddie',i:'💻',t:tr('Script Kiddie'),d:tr('Deploy a RouteScript that cuts your transit bill by 10% without losing traffic.'),r:'r',ok:()=>!!st().kiddie},
|
||
{id:'fat',i:'🫠',t:tr('Fat Finger'),d:tr('Deploy a RouteScript that takes down a third of your traffic.'),r:'r',ok:()=>!!st().fat},
|
||
{id:'scen1',i:'🎯',t:tr('Scenario Solver'),d:tr('Complete any scenario.'),r:'r',ok:()=>!!(S.scn&&S.scn.done&&S.scn.id!=='weekly')},
|
||
{id:'weekly',i:'📅',t:tr('Weekly Regular'),d:tr('Finish a weekly challenge.'),r:'r',ok:()=>!!(S.scn&&S.scn.done&&S.scn.id==='weekly')},
|
||
{id:'scen3',i:'🏅',t:tr('Scenario Specialist'),d:tr('Complete three different scenarios.'),r:'e',ok:()=>!!(S.scn&&S.scn.done&&S.scn.id!=='weekly')&&Object.keys(scnHof()).filter(k=>k!=='weekly').length>=3},
|
||
{id:'scenall',i:'🏆',t:tr('Scenario Grandmaster'),d:tr('Complete every scenario.'),r:'l',ok:()=>!!(S.scn&&S.scn.done&&S.scn.id!=='weekly')&&SCN.every(x=>scnHof()[x.id])},
|
||
{id:'elephant',i:'🐘',t:tr('I Survived the Elephant'),d:tr('Live through the day half the internet went down.'),r:'l',secret:true,ok:()=>!!S.phpDone&&!(S.ev.php>S.day)},
|
||
{id:'vigil',i:'⚖️',t:tr('Vigilante'),d:tr('Fire the HackBack 3000™ and flatten an innocent.'),r:'e',secret:true,ok:()=>(st().vigilante||0)>=1},
|
||
{id:'nullroute',i:'💥',t:tr('Collateral Damage'),d:tr('Blackhole one of your own cities to stop a DDoS.'),r:'r',ok:()=>(st().rtbh||0)>=1},
|
||
{id:'toaster',i:'🍞',t:tr('Toaster Wrangler'),d:tr('Weather a DDoS with your defences ready.'),r:'c',ok:()=>(st().ddosHeld||0)>=1},
|
||
{id:'cleanpipe',i:'🚿',t:tr('Clean Pipes'),d:tr('Turn on a transit clean-pipe add-on.'),r:'r',ok:()=>S.transit.some(t=>t.clean)},
|
||
{id:'lamb',i:'🐐',t:tr('Sacrificial Lamb'),d:tr('Run a sacrificial PNI choke point.'),r:'r',ok:()=>S.pni.some(p=>p.sacrif)},
|
||
{id:'flood',i:'🌊',t:tr('Held the Flood'),d:tr('Weather a multi-terabit DDoS.'),r:'e',ok:()=>(st().ddosMonster||0)>=1},
|
||
{id:'skynot',i:'🤖',t:tr('Skynot Smiles'),d:tr('Land a HackBack 3000™ that actually works.'),r:'e',secret:true,ok:()=>(st().hackWin||0)>=1},
|
||
{id:'zero',i:'🕳️',t:tr('Zero Peers Given'),d:tr('Reach Tier 2 with every single session over the route server.'),r:'l',secret:true,ok:()=>isTier2()&&!Object.keys(S.peers).length&&!S.pni.length},
|
||
];
|
||
function hof(){try{return JSON.parse(localStorage.getItem('sot-badges')||'{}')||{};}catch(e){return {};}}
|
||
function checkBadges(){S.ach=S.ach||{};if(S.mode==='sandbox')return;let h=null;
|
||
for(const b of BADGES){if(S.ach[b.id]!==undefined)continue;let ok=false;try{ok=b.ok();}catch(e){}
|
||
if(!ok)continue;S.ach[b.id]=S.day;const R0=RARITY[b.r];
|
||
if(!h)h=hof();if(!h[b.id])h[b.id]={d:new Date().toISOString().slice(0,10),n:S.name};
|
||
toast(`<b>${b.i} ${tr('Badge unlocked: {name}',{name:esc(b.t)})}</b><br><span style="color:${R0.col};font-weight:900">${R0.n}</span> · ${esc(b.d)}`,'goal');sfx('coin');track('badge_'+b.id);}
|
||
if(h)try{localStorage.setItem('sot-badges',JSON.stringify(h));}catch(e){}}
|
||
function badgeGrid(){const h=hof(),got=BADGES.filter(b=>S.ach&&S.ach[b.id]!==undefined).length;
|
||
return `<h3 style="font-size:15px;margin:14px 0 6px">${tr('Badges')} <span class="meta">${tr('{got}/{total} this game · {ever} ever',{got,total:BADGES.length,ever:Object.keys(h).filter(k=>BADGES.some(b=>b.id===k)).length})}</span></h3><div class="badges">${BADGES.map(b=>{const on=S.ach&&S.ach[b.id]!==undefined,ever=!!h[b.id],R0=RARITY[b.r],hide=b.secret&&!on&&!ever;
|
||
return `<div class="bdg ${on?'on':ever?'ever':''}" style="--rc:${R0.col}" title="${esc(hide?tr('A secret badge'):b.t+': '+b.d)}"><span class="bi">${hide?'❔':b.i}</span><span class="bt">${esc(hide?'???':b.t)}</span><span class="br">${R0.n}${ever&&!on?' · '+tr('earned before'):''}</span>${hide?'':`<span class="bd">${esc(b.d)}</span>`}</div>`;}).join('')}</div>`;}
|
||
function checkGoals(){checkBadges();
|
||
for(const g of GOALS){if(S.done[g.id]!==undefined)continue;let ok=false;try{ok=g.ok();}catch(e){}
|
||
if(ok){S.done[g.id]=S.day;if(g.r&&S.mode!=='sandbox'){S.cash+=g.r;}
|
||
toast(`<b>${tr('Goal complete: {name}',{name:esc(g.t)})}</b>${g.r?`<br>${tr('Reward: +{amt}',{amt:fmt$(g.r)})}`:''}`,'goal');sfx('coin');
|
||
track('goal_'+g.id);if(g.win&&!S.won){S.won=true;track('win_tier1');checkBadges();showWin();}}}
|
||
}
|
||
|
||
/* ================= ACTIONS ================= */
|
||
function spend(c){if(S.cash<c){toast(tr('<b>Not enough cash.</b><br>Wait for revenue, or speed up time.'),'bad');sfx('err');return false;}S.cash-=c;sfx('build');return true;}
|
||
const ACT={
|
||
speed:({v})=>{v=+v;if(![0,0.5,1,2,4,8].includes(v))return;if(v)UI.lastSpeed=v;UI.speed=v;renderHUD();},
|
||
help:()=>showHelp(),
|
||
dash:()=>{if(!S)return;const d=$('dash');d.hidden=!d.hidden;if(!d.hidden)renderDash();},
|
||
dashClose:()=>{$('dash').hidden=true;},
|
||
dashTab:({k})=>{if(!DTABS.includes(k))return;UI.dtab=k;renderDash();const d=$('dash');if(d)d.scrollTop=0;},
|
||
dashSort:({k})=>{if(!['name','asn','type','traffic','cost','lost'].includes(k))return;if(UI.dashSort===k)UI.dashDir=-(UI.dashDir||-1);else{UI.dashSort=k;UI.dashDir=k==='name'||k==='type'||k==='asn'?1:-1;}renderDash();},
|
||
bank:()=>{if(!S)return;UI.confirm=null;$('dash').hidden=true;const b=$('bankBox');b.hidden=false;UI._bh=null;renderBank();},
|
||
bankClose:()=>{UI.confirm=null;$('bankBox').hidden=true;},
|
||
takeLoan:({id})=>{const o=S.loanOffers.find(x=>x.id===id);if(!o)return;S.stats.loans=(S.stats.loans||0)+1;const B=BANKS[o.bank];let got=o.amount,note='';
|
||
if(B.crypto){const f=0.55+Math.random()*0.8;got=Math.round(o.amount*f);note=' '+(f>=1?tr('TubeCoin moved up {p}% on the way to your account.',{p:Math.round(Math.abs(f-1)*100)}):tr('TubeCoin moved down {p}% on the way to your account.',{p:Math.round(Math.abs(f-1)*100)}));}
|
||
S.cash+=got;S.loanOffers=S.loanOffers.filter(x=>x!==o);
|
||
S.loans.push({id:o.id,bank:o.bank,start:S.day,amount:o.amount,got,bal:o.model==='transit'?o.owe:o.amount,apr:o.apr||0,apr0:o.apr||0,pay:o.pay||0,left:o.term||0,term:o.term||0,share:o.share||0,model:o.model,cut:o.cut,covs:o.covs,base:{sub:S.links.filter(x=>x.sub).length}});
|
||
track('loan_taken');toast(`<b>${tr('{amt} from {bank} has landed.',{amt:fmt$(got),bank:esc(B.name)})}</b><br>${B.equity?tr('They now own {p} of your revenue.',{p:pct(o.share)}):loanSummary(o)}${note}`,'good');sfx('coin');after();renderBank();},
|
||
declineLoan:({id})=>{S.loanOffers=S.loanOffers.filter(x=>x.id!==id);sfx('click');renderBank();},
|
||
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('<b>You bought out {bank}.</b><br>They flew off to find another startup.',{bank:esc(B.name)}):tr('<b>Loan from {bank} repaid early.</b>',{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;selectLink(id);},
|
||
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();},
|
||
langSet:({v})=>{if(!Object.hasOwn(LANGS,v)||v===LANG)return;try{localStorage.setItem('sot-lang',v);}catch(e){}save();location.reload();},
|
||
mute:()=>{UI.muted=!UI.muted;try{localStorage.setItem('sot-mute',UI.muted?'1':'0');}catch(e){}renderHUD();},
|
||
closePanel:()=>{UI.sel=null;UI.confirm=null;renderPanel();renderLeft();},
|
||
closeModal:()=>closeModal(),
|
||
tab:({t})=>{UI.tab=t;UI.confirm=null;renderPanel();},
|
||
leftTab:({t})=>{UI.left=t;UI.leftOpen=true;renderLeft();},
|
||
toggleLeft:()=>{UI.leftOpen=!UI.leftOpen;renderLeft();},
|
||
phoneTab:({t})=>{if(!['goals','deals','noc','nets'].includes(t))return;haptic(8);if(UI.leftOpen&&UI.left===t&&!UI.sel){UI.leftOpen=false;}else{UI.left=t;UI.leftOpen=true;UI.sel=null;renderPanel();}$('left').classList.remove('full');renderLeft();},
|
||
phonePlay:()=>{haptic(10);if(UI.speed){UI.lastSpeed=UI.speed;UI.speed=0;}else UI.speed=UI.lastSpeed||1;renderHUD();},
|
||
phoneSpeed:()=>{haptic(8);const cur=UI.speed||UI.lastSpeed||1,i=SPEEDS.indexOf(cur),n=SPEEDS[(i+1)%SPEEDS.length];UI.speed=n;UI.lastSpeed=n;renderHUD();},
|
||
install:()=>{if(installEvt){installEvt.prompt();installEvt.userChoice.finally(()=>{installEvt=null;});return;}
|
||
openModal(pitchHtml(false));},
|
||
pitchSkip:()=>{const p=UI.pendGame;UI.pendGame=null;UI.pitched=true;if(p)beginGame(...p);else closeModal();},
|
||
focusCity:({city})=>{selectCity(city);const C=CITY[city];cam.x=C.x;cam.y=C.y;cam.z=Math.max(cam.z,1.2);if(innerWidth<760)UI.leftOpen=false;renderLeft();},
|
||
selLink:({id})=>selectLink(id),
|
||
buildPop:({city})=>{if(S.pops[city])return;if(cnCity(city)&&!cnOk()){toast(tr('<b>You need a license first.</b><br>Foreign networks need a joint venture to build in mainland China.'),'bad');sfx('err');return;}if(!spend(popCost(city)))return;S.pops[city]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false};floater(CITY[city].x,CITY[city].y-30,tr('New POP!'),'#FF4F9A');UI.tab='cust';after();},
|
||
launchBB:({city})=>{const p=S.pops[city];if(!p||p.bb)return;const C=CITY[city];if(!spend(bbCost(city)))return;p.bb={d:Math.max(8,C.P*0.03)};floater(C.x,C.y-30,tr('Eyeballs online!'),'#16A866');after();},
|
||
ad:({city})=>{const p=S.pops[city];if(!p||!p.bb)return;if(!spend(8000))return;p.boost=S.day+30;floater(CITY[city].x,CITY[city].y-30,tr('Ad campaign!'),'#FF8A3D');after();},
|
||
buyTransit:({city,net,tier})=>{tier=+tier;if(scnRule('noTransit')){toast(tr('<b>No transit in this scenario.</b><br>Peering, PNIs, caches and your own fiber only.'),'bad');sfx('err');return;}if(!S.pops[city]||!NET[net]||!NET[net].price||!NET[net].pops.includes(city)||!PORT[tier])return;if(!portOk(city,tier)){toast(tr("<b>Your router can't take a {port} port.</b><br>Upgrade it in the Infra tab.",{port:PORT[tier].n}),'bad');sfx('err');return;}const ex=S.transit.find(t=>t.city===city&&t.net===net);if(ex&&tier<=ex.tier)return;if(!portGate(city,ex?(PORT_SLOT(tier)-PORT_SLOT(ex.tier))*(ex.n||1):PORT_SLOT(tier)))return;if(!spend(PORT[tier].setup*(ex&&ex.n||1)))return;if(ex)ex.tier=tier;else S.transit.push({id:uid(),city,net,tier,down:0});toast(tr('<b>{net} transit is live in {city}.</b><br>Full table received: ~1,000,000 routes.',{net:esc(NET[net].name),city:CITY[city].name}),'good');after();},
|
||
lagT:({id,d})=>{d=+d;if(d!==1&&d!==-1)return;const t=S.transit.find(x=>x.id===id);if(!t)return;const n=(t.n||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0){if(!portOk(t.city,t.tier)||!portGate(t.city,PORT_SLOT(t.tier)))return;if(!spend(PORT[t.tier].setup))return;}t.n=n;if(n<2&&t.site==='ab')t.site='a';toast(+d>0?tr('<b>LAG member added.</b><br>{net} in {city} is now {lag}.',{net:esc(NET[t.net].name),city:CITY[t.city].name,lag:lagName(t.tier,n)}):tr(`<b>LAG member removed.</b>`),'good');after();},
|
||
lagP:({id,d})=>{d=+d;if(d!==1&&d!==-1)return;const p=S.pni.find(x=>x.id===id);if(!p)return;const n=(p.n||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0&&(!portGate(p.city,PORT_SLOT(p.tier))||!spend(1500+PORT[p.tier].setup/2)))return;p.n=n;if(n<2&&p.site==='ab')p.site='a';sfx('build');after();},
|
||
lagIx:({city,d})=>{d=+d;if(d!==1&&d!==-1)return;if(!isIx(city)||S.ixp[city]===undefined||S.myIx[city]||!S.pops[ixCity(city)])return;S.ixn=S.ixn||{};const n=(S.ixn[city]||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0&&(!portGate(ixCity(city),PORT_SLOT(S.ixp[city]))||!spend(ixPortMo(city,S.ixp[city]))))return;S.ixn[city]=n;if(n<2&&S.ixSite&&S.ixSite[city]==='ab')S.ixSite[city]='a';sfx('build');after();},
|
||
cancelTransit:({id,ok})=>{if(!ok&&UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.transit=S.transit.filter(t=>t.id!==id);UI.confirm=null;after();},
|
||
buyIx:({city,tier,signed})=>{tier=+tier;if(!PORT[tier]||!ixName(city)||(!S.pops[ixCity(city)]&&(!remoteCities().includes(ixCity(city))||tier>1))||(S.ixp[city]!==undefined&&tier<=S.ixp[city]))return;if(S.pops[ixCity(city)]&&!portOk(ixCity(city),tier)){toast(tr("<b>Your router can't take a {port} port.</b><br>Upgrade it in the Infra tab.",{port:PORT[tier].n}),'bad');sfx('err');return;}{const h0=S.ixp[city]!==undefined;if(!S.myIx[city]&&!portGate(ixCity(city),h0?(PORT_SLOT(tier)-PORT_SLOT(S.ixp[city]))*((S.ixn||{})[city]||1):PORT_SLOT(tier)))return;}
|
||
if(isDk(city)&&S.ixp[city]===undefined&&!signed){const dk=dkState();if(dk.stall>S.day){toast(tr('<b>DE-KICKS sales is still "aligning".</b><br>They will get back to you in {n} days.',{n:dk.stall-S.day}),'bad');sfx('err');return;}dk.lastQ=dk.lastQ||{};const lq=dk.lastQ[city];dk.q={city,tier,m:lq&&lq.until>S.day?lq.m:dkQuoteMult(),h:lq&&lq.until>S.day?lq.h:0};dk.lastQ[city]={m:dk.q.m,h:dk.q.h,until:S.day+90};dkQuoteModal();return;}const had=S.ixp[city]!==undefined;if(!spend(ixPortMo(city,tier)*(had?((S.ixn||{})[city]||1):1)))return;S.ixp[city]=tier;if(!had)toast(S.pops[ixCity(city)]?tr('<b>Port up at {ix}!</b><br>Now request peering, or join the route server.',{ix:esc(ixName(city))}):tr("<b>Remote port up at {ix}.</b><br>It came through a reseller, so expect a markup, a crowded port and some networks that won't talk to you. The route server is your friend here.",{ix:esc(ixName(city))}),'good');after();},
|
||
cancelIx:({city,sure,ok})=>{if(!ok&&UI.confirm!=='ix'+city){UI.confirm='ix'+city;renderPanel();return;}
|
||
if(isDk(city)&&!sure){const dk=dkState();if(!dk.retUsed[city]){openModal(`<div class="eyebrow">${tr('DE-KICKS Group · Customer Success')}</div><h2 style="font-size:26px">${tr('Wait! Before you go…')}</h2><p class="tagline">${tr('We value our partnership too much to let a little thing like price get in the way.')}</p><div class="kv"><span>${tr('Retention offer')}</span><b>${tr('40% off for 6 months')}</b></div><p class="note">${tr('After that, the normal price returns, plus a small loyalty administration fee.')}</p><div class="btns">${btn(tr('Stay, take the discount'),'dkStay',{city},'pink')}${btn(tr('Leave anyway'),'cancelIx',{city,sure:1},'ghost')}</div>`);return;}}
|
||
closeModal();if(S.dk){if(S.dk.m[city]){S.dk.lastQ=S.dk.lastQ||{};S.dk.lastQ[city]={m:S.dk.m[city],h:3,until:S.day+365};}delete S.dk.m[city];delete S.dk.add[city];delete S.dk.ret[city];}delete S.ixp[city];delete S.rs[city];if(S.ixn)delete S.ixn[city];for(const k in S.peers)if(k.endsWith('@'+city))delete S.peers[k];UI.confirm=null;after();},
|
||
rs:({city})=>{if(!isIx(city)||S.ixp[city]===undefined)return;S.rs[city]=!S.rs[city];if(S.rs[city])toast(tr('<b>Route server session up.</b><br>You now peer with every open network on this IX, in one go.'),'good');sfx('build');after();},
|
||
dkAccept:()=>{const dk=dkState(),q=dk.q;if(!q)return;dk.m[q.city]=q.m;dk.q=null;closeModal();ACT.buyIx({city:q.city,tier:q.tier,signed:true});if(S.ixp[q.city]===undefined)delete dk.m[q.city];else toast(tr(`<b>Signed with DE-KICKS.</b><br>Welcome to the family. Please don't tell anyone what you pay.`),'good');},
|
||
dkHaggle:()=>{const dk=dkState(),q=dk.q;if(!q||q.h>=3)return;q.h++;const r=Math.random();
|
||
if(r<0.45){S.stats.haggleWin=1;q.m=+(q.m*(0.75+Math.random()*0.15)).toFixed(2);dkQuoteModal();toast(tr('<b>"Just this once."</b><br>Your account manager found a special discount. Do not tell the others.'),'good');}
|
||
else if(r<0.75){q.m=+(q.m*1.1).toFixed(2);dkQuoteModal();toast(tr('<b>"After consulting with management…"</b><br>The price went up. Management was consulted.'),'bad');}
|
||
else{dk.stall=S.day+5+Math.floor(Math.random()*6);dk.q=null;closeModal();toast(tr('<b>Haggling paused.</b><br>{why}',{why:esc(pick(DK_STALL))}),'bad');}},
|
||
dkWalk:()=>{const dk=dkState(),q=dk.q;if(q){dk.lastQ=dk.lastQ||{};dk.lastQ[q.city]={m:q.m,h:q.h,until:S.day+90};if(q.h>0)dk.stall=Math.max(dk.stall||0,S.day+3);}dk.q=null;closeModal();toast(tr('<b>DE-KICKS will "circle back".</b><br>Expect an email titled "Quick question 🙂" within the hour.'),'');},
|
||
dkOptOut:({city,n})=>{const dk=dkState(),k='dk'+city+n;if(UI.confirm!==k){UI.confirm=k;renderPanel();return;}dk.add[city]=(dk.add[city]||[]).filter(x=>x.n!==n);UI.confirm=null;S.stats.optouts=(S.stats.optouts||0)+1;toast(tr(`<b>Opted out of {name}.</b><br>It took four clicks, a survey and a "we're sad to see you go" page.`,{name:esc(n)}),'good');after();},
|
||
dkStay:({city})=>{S.stats.retained=1;const dk=dkState();dk.ret[city]=S.day+180;dk.retUsed[city]=true;UI.confirm=null;closeModal();toast(tr('<b>40% off {ix} for 6 months.</b><br>Your account manager is relieved. Read the small print later.',{ix:esc(ixName(city))}),'good');after();},
|
||
teEdit:()=>{if(!S.te)return;UI.teDraft=undefined;teModal();},
|
||
teClose:()=>{const t=$('teSrc');if(t)UI.teDraft=t.value;closeModal();},
|
||
teExample:()=>{UI.teDraft=TE_EXAMPLE;teModal();},
|
||
teClear:()=>{S.te.script='';UI.teDraft=undefined;TE_CACHE={src:null,p:null};after();teModal(`<p class="note">${tr('Script removed. Plain Auto-TE is back in charge.')}</p>`);},
|
||
teCheck:()=>{const t=$('teSrc');const src=t?t.value:'';UI.teDraft=src;const p=teParse(src);if(p.errors.length){teModal(`<pre class="term err">${esc(p.errors.join('\n'))}</pre>`);return;}const r=teTrial(src);teModal(`<pre class="term">${esc(trn('✓ {n} rule OK','✓ {n} rules OK',p.n)+'\n'+tr('served {a} → {b}',{a:fmtG(r.before.served),b:fmtG(r.after.served)})+'\n'+tr('transit {a}/mo → {b}/mo',{a:fmt$(r.before.tc),b:fmt$(r.after.tc)})+'\n'+tr('spilled {g} onto alternate paths',{g:fmtG(r.after.moved)})+(r.after.bh?'\n'+tr('blackholed {g}',{g:fmtG(r.after.bh)}):''))}</pre>`);},
|
||
teDeploy:()=>{const t=$('teSrc');const src=(t?t.value:'').slice(0,4000);UI.teDraft=src;const p=teParse(src);if(p.errors.length){teModal(`<pre class="term err">${esc(tr('commit failed')+'\n'+p.errors.join('\n'))}</pre>`);sfx('err');return;}const r=teTrial(src);S.te.script=src;S.te.on=true;TE_CACHE={src:null,p:null};UI.teDraft=undefined;after();
|
||
const drop=r.before.served>1?1-r.after.served/r.before.served:0,saved=r.before.tc>0?1-r.after.tc/r.before.tc:0;
|
||
if(drop>0.3){S.stats.fat=1;toast(tr('<b>Commit complete. Traffic down {p}.</b><br>You just fat-fingered your own network. Classic. Fix the script from the NOC tab.',{p:pct(drop)}),'bad');sfx('alert');}
|
||
else{if(saved>0.1&&drop<0.01)S.stats.kiddie=1;toast(`<b>${tr('Commit complete.')}</b><br>${saved>0.01?trn('{n} rule live, transit bill down {p}.','{n} rules live, transit bill down {p}.',p.n,{p:pct(saved)}):trn('{n} rule live.','{n} rules live.',p.n)}`,'good');sfx('build');}closeModal();checkGoals();},
|
||
buyTE:()=>{if(S.te)return;if(lvl()<3){toast(tr('<b>Auto-TE unlocks at customer level 3.</b>'),'bad');sfx('err');return;}if(!spend(TE_COST))return;S.te={on:true,day:S.day};toast(tr('<b>Auto-TE is live.</b><br>The controller now pushes overflow onto alternate paths whenever the shortest one is full.'),'good');after();},
|
||
teToggle:()=>{if(!S.te)return;S.te.on=!S.te.on;after();},
|
||
trace:({city})=>traceModal(city),
|
||
traceRun:()=>{const f=$('trFrom'),t=$('trTo');traceModal(f&&f.value,t&&t.value);},
|
||
traceCopy:()=>{try{navigator.clipboard.writeText(UI.trText||'');toast(tr('<b>Copied.</b> Paste it into your favourite NOC chat.'),'good');}catch(e){}},
|
||
share:()=>shareModal(),
|
||
shareDl:()=>shareFile(f=>{if(!f)return;const a=document.createElement('a');a.href=URL.createObjectURL(f);a.download=f.name;document.body.appendChild(a);a.click();setTimeout(()=>{URL.revokeObjectURL(a.href);a.remove();},1000);track('share_download');}),
|
||
shareGo:()=>shareFile(f=>{const d={title:'Series of Tubes',text:tr('{name} (AS{asn}): {tier}, {peak} peak. Build your own internet at',{name:S.name,asn:S.asn,tier:tierLabel(),peak:fmtG(S.stats.peak||0)}),url:'https://seriesoftub.es/'};try{if(f&&navigator.canShare&&navigator.canShare({files:[f]}))d.files=[f];navigator.share(d).then(()=>track('share_done')).catch(()=>{});}catch(e){}}),
|
||
confGo:({key})=>{S.confReg=S.confReg||{};if(S.confReg[key])return;const cf=upcomingConfs(75).find(x=>x.key===key);if(!cf||cf.day<=S.day)return;if(!spend(CONF_COST))return;S.confReg[key]=true;toast(tr('<b>Registered.</b><br>Flights booked, badge printed, business cards ordered in the wrong font.'),'good');after();},
|
||
tutSkip:()=>{S.tut=null;try{localStorage.setItem('sot-tut','1');}catch(e){}renderCoach();},
|
||
addSite:({city})=>{const p=S.pops[city];if(!p||p.site2)return;if(!spend(SITE2_COST))return;p.site2=true;p.site2Day=S.day;toast(tr('<b>Second site live in {city}.</b><br>{b} is joined to {a} by your own metro ring. Move some uplinks there from the Transit and Peering tabs.',{city:CITY[city].name,b:esc(siteName(city,'b')),a:esc(siteName(city,'a'))}),'good');sfx('build');after();},
|
||
rmSite:({city})=>{const p=S.pops[city];if(!p||!p.site2)return;if(UI.confirm!=='site'+city){UI.confirm='site'+city;renderPanel();return;}UI.confirm=null;p.site2=0;p.sdown=null;p.ringcut=0;for(const t of S.transit)if(t.city===city)t.site='a';for(const x of S.pni)if(x.city===city)x.site='a';for(const x of S.caches)if(x.city===city)x.site='a';if(S.ixSite)for(const x of ixIdsIn(city))delete S.ixSite[x];after();},
|
||
siteSet:({k,id,s})=>{if(!['a','b','ab'].includes(s))return;
|
||
const o=k==='t'?S.transit.find(x=>x.id===id):k==='p'?S.pni.find(x=>x.id===id):null;if(k!=='ix'&&!o)return;if(k==='ix'&&(!isIx(id)||S.ixp[id]===undefined||S.myIx[id]||!S.pops[ixCity(id)]))return;
|
||
const n=()=>k==='ix'?((S.ixn||{})[id]||1):(o.n||1);
|
||
if(s==='ab'&&n()<2){const before=n();if(k==='t')ACT.lagT({id,d:1});else if(k==='p')ACT.lagP({id,d:1});else ACT.lagIx({city:id,d:1});if(n()<2||n()===before)return;toast(tr(`<b>Second LAG member added.</b><br>One member in each building now, so a dark building only takes out half the port.`),'good');}
|
||
if(k==='ix'){S.ixSite=S.ixSite||{};S.ixSite[id]=s;}else o.site=s;after();},
|
||
peer:({city,net})=>{if(!isIx(city)||!isNet(net)||S.ixp[city]===undefined||!ixMembers(city).includes(net))return;const r=peerOk(net,'ix',city);if(!r.ok){toast(tr('<b>{net} declined.</b><br>{why}',{net:esc(NET[net].name),why:esc(r.why)}),'bad');sfx('err');return;}S.peers[net+'@'+city]=true;
|
||
toast(`<b>${tr('{net} accepted!',{net:esc(NET[net].name)})}</b><br>${NET[net].pol==='selective'?tr('They checked your PearingDB page and liked the traffic numbers.'):tr('BGP session established.')}`,'good');sfx('build');after();},
|
||
unpeer:({city,net})=>{delete S.peers[net+'@'+city];after();},
|
||
peerAll:({city})=>{if(!isIx(city)||S.ixp[city]===undefined)return;const set=ixSessions(city);let n=0;for(const id of ixMembers(city))if(!set.has(id)&&peerOk(id,'ix',city).ok){S.peers[id+'@'+city]=true;n++;}if(!n)return;toast(trn('<b>{n} new session at {ix}.</b><br>Small networks, but they add up, and they all count towards the club.','<b>{n} new sessions at {ix}.</b><br>Small networks, but they add up, and they all count towards the club.',n,{ix:esc(ixName(city))}),'good');sfx('build');after();},
|
||
tailTog:()=>{UI.tailOpen=!UI.tailOpen;renderLeft();},
|
||
pni:({city,net,tier})=>{tier=+tier;if(!S.pops[city]||!NET[net]||!NET[net].pops.includes(city)||!PORT[tier])return;if(!portOk(city,tier)){toast(tr("<b>Your router can't take a {port} port.</b><br>Upgrade it in the Infra tab.",{port:PORT[tier].n}),'bad');sfx('err');return;}const r=peerOk(net,'pni',city);if(!r.ok){toast(tr('<b>{net} declined the PNI.</b><br>{why}',{net:esc(NET[net].name),why:esc(r.why)}),'bad');sfx('err');after();return;}if(S.conf&&S.conf.until>S.day)S.stats.beerPni=1;
|
||
const ex=S.pni.find(p=>p.city===city&&p.net===net);if(ex&&tier<=ex.tier)return;if(!portGate(city,ex?(PORT_SLOT(tier)-PORT_SLOT(ex.tier))*(ex.n||1):PORT_SLOT(tier)))return;if(!spend((1500+PORT[tier].setup/2)*(ex&&ex.n||1)))return;if(ex)ex.tier=tier;else S.pni.push({id:uid(),city,net,tier});
|
||
toast(tr('<b>PNI with {net} is up.</b><br>A cross-connect in {dc}. Private and fast.',{net:esc(NET[net].name),dc:esc(CITY[city].dc)}),'good');after();},
|
||
cancelPni:({id,ok})=>{if(!ok&&UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.pni=S.pni.filter(p=>p.id!==id);UI.confirm=null;after();},
|
||
cache:({city,net})=>{const n=NET[net];if(!n||!n.cache||!S.pops[city])return;if((R.demTo[net]||0)<n.cache.min){toast(tr('<b>{net} says not yet.</b><br>Send them {min}+ Gbps first.',{net:esc(n.name),min:n.cache.min}),'bad');sfx('err');return;}if(!portGate(city,1))return;
|
||
{const hv=S.caches.filter(x=>x.city===city&&x.net===net),nb=hv.filter(x=>x.site==='b').length;S.caches.push({id:uid(),city,net,site:S.pops[city].site2&&nb<hv.length-nb?'b':'a'});}toast(tr('<b>{cache} installed in {city}!</b><br>{net} shipped it for free. You pay {mo}/mo power.',{cache:esc(n.cache.name),city:CITY[city].name,net:esc(n.name),mo:fmt$(CACHE_MO)}),'good');sfx('build');after();},
|
||
rmCache:({id})=>{S.caches=S.caches.filter(c=>c.id!==id);after();},
|
||
// Move one of a CDN's boxes to the other building (#69), so a dark building only takes out part of the cache.
|
||
cacheSite:({city,net,s})=>{if(s!=='a'&&s!=='b'||!S.pops[city]||!S.pops[city].site2)return;const x=S.caches.find(c=>c.city===city&&c.net===net&&(c.site==='b'?'b':'a')!==s);if(!x)return;x.site=s;sfx('click');after();},
|
||
accept:({id})=>{const o=S.offers.find(x=>x.id===id);if(!o)return;if(!bHas(o)){toast(tr('<b>You need a POP in every city on the contract first.</b>'),'bad');return;}
|
||
if(o.type==='wwave'){const l=S.links.find(x=>x.id===o.link);if(!l||chMax(l)-(l.ch||[]).length-soldSlots(l)<o.slots){toast(tr('<b>Not enough free channels on that fiber any more.</b>'),'bad');return;}}
|
||
if(BIZ_T[o.type].event&&S.day>=o.start){toast(tr('<b>Too late: the event has already started.</b>'),'bad');return;}
|
||
S.offers=S.offers.filter(x=>x!==o);S.biz.push({id:o.id,city:o.city,city2:o.city2||null,reqs:o.reqs||[],latMax:o.latMax||null,route:BIZ_T[o.type].scenic?'scenic':BIZ_T[o.type].lat?'fast':'normal',name:o.name,type:o.type,bw:o.bw,rate:o.rate,mood:100,since:S.day,sites:o.sites||null,start:o.start,dur:o.dur,fee:o.fee,link:o.link,slots:o.slots||0,what:o.what,prov:o.prov});
|
||
floater(CITY[o.city].x,CITY[o.city].y-30,tr('Signed!'),'#16A866');sfx('coin');after();},
|
||
decline:({id})=>{S.offers=S.offers.filter(x=>x.id!==id);after();},
|
||
dropBiz:({id})=>{const b0=S.biz.find(x=>x.id===id);if(!b0)return;if(BIZ_T[b0.type].event&&S.day>=b0.start){toast(tr('<b>The event is already running.</b><br>The organisers will not let you walk out now.'),'bad');sfx('err');return;}if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.biz=S.biz.filter(b=>b.id!==id);UI.confirm=null;after();},
|
||
upLink:({id,tier})=>{tier=+tier;const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='wave'||!LT[tier]||tier<=l.tier)return;{const w=subWaveWhy(tier,l.km,l.sub);if(w){toast(tr('<b>No {wave} waves on this cable.</b><br>{why}',{wave:LT[tier].n,why:esc(w)}),'bad');sfx('err');return;}}if(!waveOk(l.a,l.b,tier)){toast(tr('<b>A {wave} wave needs {need} at both ends.</b>',{wave:LT[tier].n,need:esc(waveNeed(tier))}),'bad');sfx('err');return;}const nm=Math.round(waveMo(l.km,l.sub,tier)*(l.mult||1));if(!spend(nm))return;l.mo=nm;l.tier=tier;after();},
|
||
decomOpen:({city})=>{UI.decom=new Set(city&&S.pops[city]?[city]:[]);decomModal();},
|
||
decomToggle:({city})=>{if(!S.pops[city])return;UI.decom=UI.decom||new Set();if(UI.decom.has(city))UI.decom.delete(city);else UI.decom.add(city);decomModal();},
|
||
decomGo:()=>{const sel=[...(UI.decom||[])].filter(c=>S.pops[c]);if(!sel.length||sel.length>=Object.keys(S.pops).length)return;closeModal();UI.decom=null;UI.sel=null;decommission(sel);sfx('alert');after();},
|
||
rmLink:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.links=S.links.filter(l=>l.id!==id);UI.sel=null;UI.confirm=null;after();},
|
||
fixInc:({id})=>{const i=S.inc.find(x=>x.id===id);if(!i||!(i.cost>0))return;if(i.slow&&i.rushed)return;if(!spend(i.cost))return;
|
||
if(i.slow&&i.until>S.day+1){i.rushed=true;i.cost=0;i.until=S.day+1;const p=S.pops[i.ref];if(p)p.down=Math.min(p.down,S.day+1);toast(tr('<b>Power-cycled.</b><br>The router in {city} is booting again. It will be up tomorrow, the {chip} willing.',{city:esc(CITY[i.ref].name),chip:esc(RG[(p&&p.rgen)||0].chip)}),'good');after();return;}clearInc(i);toast(tr('<b>Fixed.</b> {what} resolved early.',{what:incTitle(i.type)}),'good');after();},
|
||
myIxUp:({city})=>{const m=S.myIx[city];if(!m)return;const f=(m.fab|0)+1,N=MYIX_FAB[f];if(!N)return;if(N.lvl>lvl()){toast(tr('<b>A {fab} fabric unlocks at customer level {lv}.</b>',{fab:N.n,lv:N.lvl}),'bad');sfx('err');return;}if(!spend(N.cost))return;m.fab=f;toast(tr('<b>{ix} now runs a {fab} fabric.</b><br>Room for {max} members. Expect a few more to join.',{ix:esc(m.name),fab:N.n,max:N.max}),'good');m.next=Math.min(m.next,S.day+3);after();},
|
||
foundIx:({city})=>{if(!S.pops[city]||S.myIx[city]||CITY[city].ix||CITY[city].cn)return;if(!spend(MYIX_COST))return;const nm=(S.name.split(' ')[0]||'My').replace(/[^A-Za-z0-9]/g,'').slice(0,10)+'-IX '+CITY[city].name;
|
||
S.myIx[city]={name:nm,members:[],next:S.day+4};S.ixp[city]=2;toast(tr('<b>You founded {ix}!</b><br>Networks will join over time and pay you for ports. Open members peer with you for free.',{ix:esc(nm)}),'goal');after();},
|
||
buildLink:({tier})=>{tier=+tier;const p=UI.pending;if(!p)return;const {a,b}=p;const km=kmBetween(a,b),sub=isSub(a,b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'),jn=sib.length?routeJoin(a,b):null,same=!!jn,border=cnCity(a)!==cnCity(b),mult=(sib.length&&!(jn&&jn.k===(landTrenches(a,b)[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1);
|
||
if((cnCity(a)||cnCity(b))&&!cnOk())return;
|
||
if(!waveOk(a,b,tier)){toast(tr('<b>A {wave} wave needs {need} at both ends.</b>',{wave:LT[tier].n,need:esc(waveNeed(tier))}),'bad');sfx('err');return;}
|
||
const wr=waveRoute(a,b,mult,border);if(!wr){toast(tr('<b>No cable available for that route right now.</b>'),'bad');sfx('err');return;}{const w=subWaveWhy(tier,wr.km,wr.sub);if(w){toast(tr('<b>No {wave} waves on this cable.</b><br>{why}',{wave:LT[tier].n,why:esc(w)}),'bad');sfx('err');return;}}const base=Math.round(waveMo(wr.km,wr.sub,tier)*wr.wm),cost=base+(S.pops[b]?0:popCost(b));
|
||
if(!portGate(a,1)||!portGate(b,1))return;if(!spend(cost))return;if(!S.pops[b])S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false};
|
||
const id=uid();const l={id,a,b,kind:'wave',border,premium:border&&!!UI.cnPrem&&(a==='hkg'||b==='hkg'),tier,km:wr.km,sub:wr.sub,cable:wr.cab,mo:base,mult:wr.wm,trench:wr.cab?'cab:'+wr.cab:(jn?jn.k:id),cut:0,day:S.day};S.links.push(l);closeModal();
|
||
if(sib.length){UI.sel={type:'link',id};}else{UI.sel={type:'city',id:b};UI.tab='cust';}
|
||
floater((CITY[a].x+CITY[a].x+wrapDx(CITY[a].x,CITY[b].x))/2,(CITY[a].y+CITY[b].y)/2-20,tr('{wave} lit!',{wave:LT[tier].n}),'#FF4F9A');after();},
|
||
buyNni:({city,prov,tier})=>{tier=+tier;if(!NNI[tier]||!isCity(city)||!own(FAB,prov)||!FAB[prov].cities.includes(city)||!S.pops[city])return;const ex=nniPort(city,prov);if(ex&&tier<=ex.tier)return;if(!ex&&!portGate(city,1))return;if(ex&&nniUsed(city,prov)>NNI[tier].g){toast(tr('<b>Too many circuits</b> for a smaller port.'),'bad');return;}if(!spend(NNI[tier].mo))return;if(ex)ex.tier=tier;else S.nni.push({id:uid(),city,prov,tier});toast(tr('<b>{fab} port is up in {city}.</b><br>Now order virtual circuits to other cities on their fabric.',{fab:esc(FAB[prov].name),city:CITY[city].name}),'good');after();},
|
||
rmNni:({city,prov})=>{if(nniUsed(city,prov)>0){toast(tr('<b>Cancel the circuits on this port first.</b>'),'bad');sfx('err');return;}S.nni=S.nni.filter(x=>!(x.city===city&&x.prov===prov));after();},
|
||
openVxc:(a)=>openVxcModal(a),
|
||
buyVxc:({a,b,prov,t})=>{t=+t;const g=VXC[t].g,pa=nniPort(a,prov);if(!pa||nniUsed(a,prov)+g>NNI[pa.tier].g){toast(tr('<b>Not enough room on your fabric port.</b> Upgrade it first.'),'bad');sfx('err');return;}
|
||
if(S.pops[b]){const pb=nniPort(b,prov);if(!pb||nniUsed(b,prov)+g>NNI[pb.tier].g){toast(tr('<b>Not enough room on your {fab} port in {city}.</b>',{fab:esc(FAB[prov].name),city:CITY[b].name}),'bad');sfx('err');return;}}
|
||
const km=kmBetween(a,b),sub=isSub(a,b),mo=vxcMo(km,sub,t);if(!spend(mo))return;S.links.push({id:uid(),a,b,kind:'vxc',prov,vt:t,km,sub,mo,cut:0,day:S.day});closeModal();
|
||
toast(tr('<b>Circuit up in 59 seconds.</b><br>{vxc} over {fab}: {a} → {b}.',{vxc:VXC[t].n,fab:esc(FAB[prov].name),a:CITY[a].name,b:CITY[b].name})+(S.pops[b]?'':' '+tr('Now grab an IX port there for remote peering.')),'good');if(!S.pops[b])selectCity(b);after();},
|
||
upVxc:({id,t})=>{t=+t;const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='vxc'||!VXC[t]||t<=l.vt)return;const extra=VXC[t].g-VXC[l.vt].g;for(const c of [l.a,l.b]){const pt=nniPort(c,l.prov);if(pt&&nniUsed(c,l.prov)+extra>NNI[pt.tier].g){toast(tr('<b>Fabric port in {city} is full.</b>',{city:CITY[c].name}),'bad');sfx('err');return;}}const mo=vxcMo(l.km,l.sub,t);if(!spend(mo))return;l.vt=t;l.mo=mo;after();},
|
||
cancelVxc:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.links=S.links.filter(l=>l.id!==id);const rem=remoteCities();for(const c in S.ixp){if(!S.pops[ixCity(c)]&&!rem.includes(ixCity(c))){delete S.ixp[c];delete S.rs[c];for(const k in S.peers)if(k.endsWith('@'+c))delete S.peers[k];}}UI.sel=null;UI.confirm=null;after();},
|
||
setPref:({kind,id,v})=>{if(!own(PREF,v))return;if(kind!=='t'&&kind!=='p'&&!(isIx(id)&&S.ixp[id]!==undefined))return;if(kind==='t'){const t=S.transit.find(x=>x.id===id);if(t)t.pref=v;}else if(kind==='p'){const x=S.pni.find(y=>y.id===id);if(x)x.pref=v;}else{S.ixPref=S.ixPref||{};S.ixPref[id]=v;}sfx('click');after();},
|
||
setMetric:({id,v})=>{if(!own(MET,v))return;const l=S.links.find(x=>x.id===id);if(!l)return;for(const x of pairLinks(l.a,l.b))x.metric=v;sfx('click');after();},
|
||
goEgress:({city,k})=>{ACT.focusCity({city});UI.tab=k==='t'?'up':k==='l2'?'cust':k==='nni'?'links':'peer';renderPanel();},
|
||
custGo:({id})=>{const b=S.biz.find(x=>x.id===id);if(!b)return;$('dash').hidden=true;ACT.focusCity({city:b.city});UI.tab='cust';renderPanel();},
|
||
custF:({v})=>{UI.kf=UI.kf||{};UI.kf.f=v==='sad'?'sad':'';renderDash();},
|
||
custCity:({v})=>{UI.kf=UI.kf||{};UI.kf.city=isCity(v)?v:'';renderDash();},
|
||
custSort:({k})=>{if(!['mood','mo','name','city'].includes(k))return;if(UI.custSort===k)UI.custDir=-(UI.custDir||1);else{UI.custSort=k;UI.custDir=k==='mo'?-1:1;}renderDash();},
|
||
custOpen:({sad}={})=>{if(!S)return;UI.kf=sad?{f:'sad'}:{};UI.dtab='cust';const d=$('dash');d.hidden=false;renderDash();d.scrollTop=0;},
|
||
goConn:({city,k})=>{if(!isCity(city)||!own(CONN_K,k))return;$('dash').hidden=true;ACT.goEgress({city,k});},
|
||
connF:({f,v})=>{const F=UI.cf=UI.cf||{};if(f==='all'){UI.cf={};}else if(f==='k'){F.k=own(CONN_K,v)?v:'';}renderDash();},
|
||
connCity:({v})=>{UI.cf=UI.cf||{};UI.cf.city=isCity(v)?v:'';renderDash();},
|
||
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')ACT.cancelTransit({id,ok:1});else if(k==='p')ACT.cancelPni({id,ok:1});else if(k==='ix')ACT.cancelIx({city:id,ok:1});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('<b>Application filed.</b><br>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();},
|
||
buildScrub:({city,tier})=>{if(S.scrubAt)return;const T=SCRUB_TIERS[tier||0];if((lvl()||1)<T.lvl){toast(tr('<b>{tier} scrubbing unlocks at customer level {lv}.</b>',{tier:T.n,lv:T.lvl}),'bad');sfx('err');return;}if(!spend(T.cost))return;S.scrubAt=city;S.scrubTier=tier||0;S.scrubMode='always';toast(tr('<b>{tier} scrubbing center online in {city}.</b><br>Attacks up to {g} are cleaned, and you can sell DDoS protection.',{tier:T.n,city:CITY[city].name,g:fmtG(T.g)}),'good');after();},
|
||
scrubUp:({tier})=>{if(!S.scrubAt||tier<=(S.scrubTier||0))return;const T=SCRUB_TIERS[tier];if((lvl()||1)<T.lvl){toast(tr('<b>{tier} scrubbing unlocks at customer level {lv}.</b>',{tier:T.n,lv:T.lvl}),'bad');sfx('err');return;}if(!spend(Math.round(T.cost*0.6)))return;S.scrubTier=tier;toast(tr('<b>Scrubbing upgraded to {tier}.</b>',{tier:T.n}),'good');after();},
|
||
scrubMode:()=>{if(!S.scrubAt)return;S.scrubMode=S.scrubMode==='ondemand'?'always':'ondemand';sfx('click');after();},
|
||
rmScrub:()=>{if(!S.scrubAt)return;if(UI.confirm!=='scrub'){UI.confirm='scrub';renderAll();return;}S.scrubAt=null;S.scrubTier=0;S.scrubMode='always';UI.confirm=null;after();},
|
||
cleanPipe:({id})=>{const t=S.transit.find(x=>x.id===id);if(!t)return;t.clean=!t.clean;toast(t.clean?tr('<b>Clean-pipe add-on enabled on {net}.</b><br>They scrub a flood before it reaches your port here, for {mo}/mo.',{net:NET[t.net].name,mo:fmt$(cleanMo(t))}):tr('<b>Clean-pipe add-on removed from {net}.</b>',{net:NET[t.net].name}),t.clean?'good':'');after();},
|
||
sacrif:({id})=>{const p=S.pni.find(x=>x.id===id);if(!p)return;p.sacrif=!p.sacrif;toast(p.sacrif?tr('<b>{net} PNI is now a sacrificial choke point.</b><br>A flood from there dies on the small port instead of inside your network, but legit traffic over it runs at half capacity.',{net:NET[p.net].name}):tr('<b>{net} PNI is back to normal.</b>',{net:NET[p.net].name}),p.sacrif?'good':'');after();},
|
||
ixbh:()=>{const a=S.ev.ddos;if(!a){toast(tr('<b>No attack to blackhole right now.</b>'),'');return;}if(!hasIxAt(a.city)){toast(tr('<b>No IX in {city} to announce a blackhole to.</b>',{city:CITY[a.city].name}),'bad');sfx('err');return;}a.ixbh=!a.ixbh;toast(a.ixbh?tr('<b>IX blackhole announced in {city}.</b><br>About half the members honour the /32 and drop the junk. The customer stays up.',{city:CITY[a.city].name}):tr('<b>IX blackhole withdrawn.</b>'),a.ixbh?'good':'');sfx('alert');after();},
|
||
rtbh:()=>{const a=S.ev.ddos;if(!a){toast(tr('<b>No attack to blackhole right now.</b>'),'');return;}a.bh=true;S.stats.rtbh=(S.stats.rtbh||0)+1;toast(tr('<b>RTBH announced.</b><br>You blackholed the target in {city}. The flood stops, and so does everyone there.',{city:CITY[a.city].name}),'bad');sfx('alert');after();},
|
||
unrtbh:()=>{const a=S.ev.ddos;if(!a||!a.bh)return;a.bh=false;toast(tr('<b>Blackhole withdrawn.</b><br>{city} is reachable again. Brace for the junk.',{city:CITY[a.city].name}),'');after();},
|
||
hackback:()=>{const a=S.ev.ddos;if(!a||a.until<=S.day){toast(tr('<b>Nothing to hack back right now.</b>'),'');return;}if(!spend(20000))return;S.stats.hackback=(S.stats.hackback||0)+1;
|
||
if(Math.random()<0.35){a.until=S.day;a.bh=false;S.stats.hackWin=(S.stats.hackWin||0)+1;toast(tr('<b>HackBack 3000™ strikes back!</b><br>Skynot AI traced the botnet and politely bricked it. The attack on {city} stops cold.',{city:CITY[a.city].name}),'goal');sfx('coin');}
|
||
else{const fine=15000+Math.floor(Math.random()*35000);S.cash-=fine;S.stats.vigilante=(S.stats.vigilante||0)+1;
|
||
toast(tr('<b>HackBack 3000™ hit the wrong target.</b><br>{who} A regulator sends you a {fine} fine, and the attack rolls on.',{who:pick([tr("Skynot AI flattened a grandma's internet-connected fridge."),tr('You counter-flooded a hospital in a country you cannot pronounce.'),tr('The botnet was already someone else’s botnet. They are furious.')]),fine:fmt$(fine)}),'bad');sfx('err');}
|
||
after();},
|
||
cnPrem:({v})=>{UI.cnPrem=!!+v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
||
via:({v})=>{UI.via=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
||
setRoute:({id,m})=>{if(!own(RT,m))return;const b=S.biz.find(x=>x.id===id);if(b){b.route=m;sfx('click');after();}},
|
||
route:({r})=>{UI.route=r;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
||
addParallel:({id})=>{const l=S.links.find(x=>x.id===id);if(l)openLinkModal(l.a,l.b);},
|
||
addRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)>=RMAX)return;if(!spend(routerCost(p.rgen||0)))return;p.routers=(p.routers||1)+1;floater(CITY[city].x,CITY[city].y-30,tr('Router added'),'#FF4F9A');after();},
|
||
models:()=>{UI.models=!UI.models;renderPanel();},
|
||
rmRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)<=1)return;if(portsUsed(city)>portsMax(city,undefined,p.routers-1)){toast(tr('<b>Unplug something first.</b><br>{used} ports are in use, and one router fewer only has {max}.',{used:fmtPorts(portsUsed(city)),max:portsMax(city,undefined,p.routers-1)}),'bad');sfx('err');return;}p.routers--;{const back=tradeIn(p.rgen||0,1);if(back>0){S.cash+=back;toast(tr('<b>Sold a {model} on eBuy.</b><br>{price} back.',{model:esc(RG[p.rgen||0].n),price:fmt$(back)}),'good');}}after();},
|
||
upRouter:({city,g})=>{const p=S.pops[city];if(!p)return;g=g===undefined?mainRG(RG[p.rgen||0].cls+1):+g;if(!RG[g]||g===(p.rgen||0))return;{const why=modelFits(city,g);if(why){toast(tr("<b>The {model} won't fit.</b><br>{why}",{model:esc(RG[g].n),why:esc(why)}),'bad');sfx('err');return;}}if(RG[g].lvl>lvl()){toast(tr('<b>{model} unlocks at customer level {lv}.</b>',{model:esc(RG[g].n),lv:RG[g].lvl}),'bad');sfx('err');return;}
|
||
const rt=p.routers||1,old=p.rgen||0;if(p.rupDay===S.day){toast(tr('<b>The new routers in {city} are still being racked.</b><br>One swap a day: try again tomorrow.',{city:CITY[city].name}),'bad');sfx('err');return;}const back=tradeIn(old,rt);if(!spend(swapCost(city,g)))return;p.rgen=g;p.rupDay=S.day;if(back>0)toast(tr('<b>Sold the old {model} on eBuy.</b><br>{price} back toward the new gear.',{model:esc(RG[old].n),price:fmt$(back)}),'good');
|
||
if(rt===1){const sl=slowBoot(city),dd=sl?3:1;p.down=Math.max(p.down||0,S.day+dd);addInc({type:'maint',ref:city,until:S.day+dd,msg:sl?tr('Swapping the only router in {city} for a {model}. The new one {how}. Back in {n} days.',{city:CITY[city].name,model:RG[g].n,how:pick(SLOW_BOOT),n:dd}):tr('Swapping the only router in {city} for a {model}. Maintenance window: back tomorrow.',{city:CITY[city].name,model:RG[g].n}),cost:0});toast(`<b>${tr('Maintenance window in {city}',{city:CITY[city].name})}</b><br>${sl?tr('One router, and this one takes forever to boot. Back in {n} days.',{n:dd}):tr('One router means downtime during the swap. Back tomorrow.')}`,'bad');}
|
||
else toast(tr('<b>Rolling upgrade in {city}</b><br>{n} × {model}, swapped one at a time. Zero downtime.',{city:CITY[city].name,n:rt,model:esc(RG[g].n)}),'good');
|
||
floater(CITY[city].x,CITY[city].y-30,RG[g].n+'!','#FF4F9A');after();},
|
||
dfMode:({m})=>{UI.lmode=m;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
||
ownCab:()=>{UI.lmode='df';UI.dfSrc='cable';if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
||
dfSrc:({v})=>{UI.dfSrc=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
||
dfSys:({v})=>{UI.dfSys=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
||
orderCable:()=>{const p=UI.pending;if(!p)return;const {a,b}=p;if(ownCabWhy(a,b))return;const km=ownCabKm(a,b),cost=ownCabCost(km)+(S.pops[b]?0:popCost(b));if(!spend(cost))return;
|
||
if(!S.pops[b])S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};
|
||
const used=new Set(S.links.map(l=>l.cname).filter(Boolean)),cname=OWNCAB_NAMES.find(n=>!used.has(n))||`${pick(OWNCAB_NAMES)} ${used.size+1}`,ship=pick(OWNCAB_SHIPS),id=uid(),days=ownCabDays(km);
|
||
S.links.push({id,a,b,kind:'df',own:true,sub:true,sys:'roadm',ch:[],km,cable:null,cname,mo:Math.round(km*OWNCAB_OM),trench:'own:'+id,cut:0,day:S.day,ready:S.day+days,spares:false,pairs:1});
|
||
S.stats.ownCab=(S.stats.ownCab||0)+1;UI.dfSrc='lease';closeModal();UI.sel={type:'link',id};
|
||
toast(tr('<b>The {ship} sets sail!</b><br>{name}, your own {km} km cable from {a} to {b}. Ready in about {n} days, if the whales cooperate.',{ship,name:cname,km:km.toLocaleString(),a:CITY[a].name,b:CITY[b].name,n:days}),'goal');sfx('build');after();},
|
||
orderDf:()=>{const p=UI.pending;if(!p)return;const {a,b}=p;if(!dfAllowed(a,b))return;const sc=isSub(a,b)?subDfCable(a,b):null,km=sc?sc.km:kmBetween(a,b);
|
||
const own=UI.dfSrc==='build'&&lvl()>=3&&!sc,sys=DF_SYS[UI.dfSys]&&DF_SYS[UI.dfSys].lvl<=lvl()?UI.dfSys:'lite';if(lvl()<2)return;
|
||
const up=(own?dfBuildCost(km):0)+DF_SYS[sys].cost+ampCount(km)*AMP_COST+(S.pops[b]?0:popCost(b));if(!spend(up))return;
|
||
if(!S.pops[b])S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};
|
||
const sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'),id=uid();
|
||
const l={id,a,b,kind:'df',own,sys,ch:[],km,sub:!!sc,cable:sc?sc.cid:null,mo:own?Math.round(km*0.15):dfLeaseMo(km),trench:sc?'cab:'+sc.cid:id,cut:0,day:S.day,ready:S.day+(own?dfBuildDays(km):30),spares:false};
|
||
S.links.push(l);closeModal();UI.sel={type:'link',id};
|
||
toast(own?tr('<b>Groundbreaking!</b><br>Your own fiber from {a} to {b}. Permits and digging take about {n} days.',{a:CITY[a].name,b:CITY[b].name,n:dfBuildDays(km)}):tr('<b>Dark fiber IRU signed.</b><br>{a}–{b} will be spliced and handed over in about 30 days.',{a:CITY[a].name,b:CITY[b].name}),'goal');after();},
|
||
regen:({id,d})=>{d=+d;const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='df'||l.sub||(d!==1&&d!==-1))return;const n=(l.regen|0)+d;if(n<0||n>REGEN_MAX)return;
|
||
if(d<0&&(l.ch||[]).some(o=>!optMode(o,{km:l.km,regen:n}))){toast(tr('<b>Those optics need the regen site.</b><br>Remove the long-haul channels first, or keep the site.'),'bad');sfx('err');return;}
|
||
if(d>0&&!spend(REGEN_COST+Math.round((l.ch||[]).reduce((a,c)=>a+optCost(c),0)*REGEN_CH)))return;l.regen=n;toast(d>0?tr('<b>Regen site {n} is up.</b><br>Optical spans on {a}–{b} are now {km} km.',{n,a:CITY[l.a].name,b:CITY[l.b].name,km:spanKm(l).toLocaleString()}):tr('<b>Regen site removed.</b>'),'good');sfx('build');after();},
|
||
addCh:({id,o})=>{const l=S.links.find(x=>x.id===id),O=OPT[o];if(!l||!O||l.kind!=='df')return;const why=chWhy(l,o);if(why){toast(tr("<b>Can't add {optic}.</b><br>{why}",{optic:O.n,why:esc(why)}),'bad');sfx('err');return;}if(!portGate(l.a,1)||!portGate(l.b,1))return;const sp=spareN(o)>0;if(!spend(chCost(l,o)))return;if(sp)S.spares[o]--;(l.ch=l.ch||[]).push(o);floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,`+${O.n}`,'#FF4F9A');after();},
|
||
rmCh:({id,o})=>{const l=S.links.find(x=>x.id===id);if(!l||!OPT[o])return;const i=(l.ch||[]).lastIndexOf(o);if(i<0)return;l.ch.splice(i,1);S.spares=S.spares||{};S.spares[o]=(S.spares[o]||0)+1;floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,tr('{optic} to spares',{optic:OPT[o].n}),'#7B61FF');after();},
|
||
sellSpare:({o})=>{if(!OPT[o]||spareN(o)<1)return;S.spares[o]--;const v=spareValue(o);S.cash+=v;toast(tr('<b>Sold a spare {optic} on eBuy.</b><br>{price} back, which is {p} of what it cost new.',{optic:OPT[o].n,price:fmt$(v),p:pct(SPARE_RESALE)}),'good');sfx('coin');after();},
|
||
addPair:({id})=>{const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='df'||!l.own||!isRdm(l.sys)||l.ready>S.day)return;const n=Math.max(1,l.pairs|0);if(n>=pairsMax(l))return;if((l.ch||[]).length+soldSlots(l)<chMax(l)){toast(tr('<b>Fill this pair first.</b><br>Light all {max} channels before you light another fiber pair.',{max:chMax(l)}),'bad');sfx('err');return;}if(!spend(pairCost(l)))return;l.pairs=n+1;toast(tr('<b>Fiber pair {n} is lit: {a}–{b}.</b><br>Another ROADMaster 9000 and a fresh chain of amplifiers. Room for {m} more channels.',{n:n+1,a:CITY[l.a].name,b:CITY[l.b].name,m:DF_SYS[l.sys].max}),'good');sfx('build');after();},
|
||
upSys:({id})=>{const l=S.links.find(x=>x.id===id),to=l&&sysNext(l);if(!to||DF_SYS[to].lvl>lvl())return;if(!spend(sysUpCost(l)))return;l.sys=to;if(l.ready<=S.day){l.eqDown=S.day+1;toast(tr('<b>Line system swap</b><br>All channels are dark for a day while the ROADMs go in.'),'bad');}after();},
|
||
spares:({id})=>{const l=S.links.find(x=>x.id===id);if(!l)return;l.spares=!l.spares;sfx('click');after();},
|
||
crews:({id})=>{const l=S.links.find(x=>x.id===id);if(!l||l.ready<=S.day)return;const c=Math.round(15000+l.km*6);if(!spend(c))return;l.ready=Math.max(S.day+1,l.ready-30);toast(tr('<b>More crews on site.</b><br>Construction is 30 days ahead.'),'good');after();},
|
||
addGen:({city})=>{const p=S.pops[city];if(!p||p.gen)return;if(!spend(GEN_COST))return;p.gen=true;floater(CITY[city].x,CITY[city].y-30,tr('Generator!'),'#FF8A3D');after();},
|
||
randomName:()=>{const input=$('nmIn');if(input)input.value=UI.nm=randomNetworkName(input.value);},
|
||
start:()=>{const nm=(($('nmIn')&&$('nmIn').value)||randomNetworkName()).slice(0,24);beginGame(nm,UI.startCity,{mode:UI.mode==='sandbox'?'sandbox':'normal'});},
|
||
modeSet:({m})=>{UI.mode=m;document.querySelectorAll('.modeb').forEach(b=>b.classList.toggle('pink',b.dataset.m===m));document.querySelectorAll('.modeb').forEach(b=>b.classList.toggle('ghost',b.dataset.m!==m));},
|
||
scenarios:()=>{UI.nm=(($('nmIn')&&$('nmIn').value)||UI.nm||(S&&S.name)||randomNetworkName()).slice(0,24);scenarioModal();},
|
||
startScn:({id,sure})=>{const sc=SCN.find(x=>x.id===id);if(!sc)return;if(!sure&&S&&UI.started&&!S.lost&&!(S.scn&&(S.scn.done||S.scn.failed))){openModal(`<h2 style="font-size:26px">${tr('Start {name}?',{name:esc(sc.n)})}</h2><p class="tagline">${tr('{name} will be replaced. Export it from the menu first if you want to keep it.',{name:esc(S.name)})}</p><div class="btns">${btn(tr('Start the scenario'),'startScn',{id,sure:1},'pink big')}${btn(tr('Keep playing'),'closeModal',{},'ghost big')}</div>`);return;}beginGame(UI.nm||(S&&S.name)||randomNetworkName(),sc.city,{scn:sc});},
|
||
startWeekly:({sure}={})=>{if(!sure&&S&&UI.started&&!S.lost&&!(S.scn&&(S.scn.done||S.scn.failed))){openModal(`<h2 style="font-size:26px">${tr('Start the weekly challenge?')}</h2><p class="tagline">${tr('{name} will be replaced. Export it from the menu first if you want to keep it.',{name:esc(S.name)})}</p><div class="btns">${btn(tr('Start the challenge'),'startWeekly',{sure:1},'pink big')}${btn(tr('Keep playing'),'closeModal',{},'ghost big')}</div>`);return;}const wk=weekly();beginGame(UI.nm||(S&&S.name)||randomNetworkName(),wk.city,{scn:wk,seed:wk.seed});},
|
||
pickStart:({city})=>{UI.startCity=city;document.querySelectorAll('.start').forEach(b=>b.classList.toggle('on',b.dataset.city===city));},
|
||
cont:()=>{migrate(S);track('game_continue',true);UI.started=true;closeModal();renderAll();},
|
||
newgame:()=>{try{localStorage.removeItem('sot-save-v1');}catch(e){}S=null;UI.started=false;UI.sel=null;UI.nm=null;$('dash').hidden=true;$('bankBox').hidden=true;renderAll();showTitle();},
|
||
keepPlaying:()=>{closeModal();},
|
||
exportSave:()=>exportSave(),
|
||
importPick:()=>{let f=$('importIn');if(!f){f=document.createElement('input');f.type='file';f.accept='.json,application/json';f.id='importIn';f.hidden=true;document.body.appendChild(f);f.addEventListener('change',()=>{importFile(f.files[0]);f.value='';});}f.click();},
|
||
importGo:()=>{const s0=UI.importing;if(!s0)return;UI.importing=null;const prev=S;try{S=migrate(JSON.parse(JSON.stringify(s0)));compute();checkGoals();renderAll();}catch(e){S=prev;if(S)compute();renderAll();toast(tr('<b>Import failed.</b><br>That save is damaged and could not be loaded. Your current game is untouched.'),'bad');sfx('err');return;}UI.confirm=null;$('bankBox').hidden=true;$('dash').hidden=true;UI.started=true;UI.sel=null;UI.speed=S.uiSpeed===undefined?1:S.uiSpeed;if(S.cam&&isFinite(S.cam.x))Object.assign(cam,S.cam);else{const h=CITY[S.home];if(h){cam.x=h.x;cam.y=h.y;}}closeModal();$('modal').hidden=true;compute();renderAll();save();toast(tr('<b>Welcome back, {name}.</b><br>Imported and saved on this device.',{name:esc(S.name)}),'good');sfx('coin');track('game_import');},
|
||
menu:()=>{if(!S||!UI.started){showTitle();return;}openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">AS${S.asn} · ${esc(dateStr(S.day))} · ${tierLabel()}</div><h2 style="font-size:28px">${esc(S.name)}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('Close')}">×</button></div>
|
||
<p class="tagline">${tr('Your game saves itself every few seconds on this device.')}</p>${isPhone()?installRow():''}
|
||
<div class="menu-list">
|
||
${btn(tr('Back to the map'),'closeModal',{},'pink big')}
|
||
${btn(tr('Export save <small>download a file</small>'),'exportSave',{},'')}
|
||
${btn(tr('Import a save <small>from a file</small>'),'importPick',{},'')}
|
||
${btn(tr('Share your network <small>image card</small>'),'share',{},'')}
|
||
${btn(tr('Scenarios & weekly challenge'),'scenarios',{},'ghost')}
|
||
${btn(tr('How to play'),'help',{},'ghost')}
|
||
${RELEASE_NOTES.length?btn(tr('What’s new in {v}',{v:esc(APP_VERSION)}),'whatsNewShow',{},'ghost'):''}
|
||
${btn(tr('Settings'),'settings',{},'ghost')}
|
||
${btn(tr('Start a new network'),'resetAsk',{},'red')}
|
||
</div>`);},
|
||
settings:()=>{UI.setOpen=true;openModal(settingsHtml());},
|
||
settingsClose:()=>{UI.setOpen=false;if(!S||!UI.started)showTitle();else closeModal();},
|
||
prefSet:({v})=>{const [k,b]=String(v).split(':');if(!own(PREF_DEF,k))return;setPref(k,b==='1');sfx('click');refreshSettings();},
|
||
vpSet:({v})=>{vpOn(v==='on');refreshSettings();},
|
||
resetAsk:()=>openModal(`<h2 style="font-size:26px">${tr('Start a new network?')}</h2><p class="tagline">${tr('{name} and everything it owns will be deleted. This cannot be undone.',{name:esc(S?S.name:tr('Your network'))})}</p><div class="btns">${btn(tr('Delete and start over'),'newgame',{},'red big')}${btn(tr('Keep playing'),'closeModal',{},'ghost big')}</div>`),
|
||
whatsNewShow:()=>whatsNew(true,true),
|
||
updateNow:()=>{save();location.reload();},
|
||
updateLater:()=>{$('update').hidden=true;UI.updLater=Date.now();},
|
||
helpClose:()=>{if(UI.started)closeModal();else showTitle();},
|
||
};
|
||
// Overland routes already dug between two cities, in the order they were built (#77). The first is the
|
||
// main route; every other one was a diverse route and keeps that price when you add waves to it.
|
||
function landTrenches(a,b){const out=[];for(const l of pairLinks(a,b)){if(l.kind==='vxc'||l.cable||l.sub)continue;const k=l.trench||l.id;let t=out.find(x=>x.k===k);if(!t)out.push(t={k,n:0,caps:[]});t.n++;t.caps.push(capName(l));}return out;}
|
||
// Which route a new wave joins: null = a new diverse route. 'same' is the old two-way choice (the main route).
|
||
function routeJoin(a,b){const ts=landTrenches(a,b),r=UI.route||'';if(r==='same')return ts[0]||null;if(r.startsWith('t:'))return ts.find(t=>t.k===r.slice(2))||null;return null;}
|
||
function pairLinks(a,b){return S.links.filter(l=>(l.a===a&&l.b===b)||(l.a===b&&l.b===a));}
|
||
// Short, busy subsea routes (London–Amsterdam, London–Paris) sell dark fiber pairs too.
|
||
function subDfCable(a,b){return cablesOk(a,b).filter(c=>CAB[c.cid].df).sort((x,y)=>x.km-y.km)[0]||null;}
|
||
function dfAllowed(a,b){if(isSub(a,b))return !!subDfCable(a,b);return cnCity(a)===cnCity(b)&&!uaePair(a,b)&&!landX(a,b);}
|
||
/* Optics you unplug go on a spares shelf instead of in the bin (#45): the next channel of that type uses a spare
|
||
for free (only the regen sites' transponders are new), or you sell it on eBuy for part of the price. */
|
||
const SPARE_RESALE=0.4,spareN=o=>(S&&S.spares&&S.spares[o])|0,spareValue=o=>Math.round(optCost(o)*SPARE_RESALE);
|
||
function chCost(l,o){const r=REGEN_CH*(l.regen|0);return Math.round(optCost(o)*(spareN(o)>0?r:1+r));}
|
||
function optCost(o){return Math.round(OPT[o].cost*(S&&S.ev&&S.ev.tariff>S.day?1.4:1));}
|
||
// Line systems upgrade in place: Rainbow → ROADMaster → C+L. Every lit pair gets the new gear.
|
||
const sysNext=l=>l.sys==='lite'?'roadm':l.sys==='roadm'?'cl':null,sysUpCost=l=>{const t=sysNext(l);return t?DF_SYS[t].cost*(t==='cl'&&l.own?Math.max(1,l.pairs|0):1):0;};
|
||
function pairBtn(l){if(!l.own||!isRdm(l.sys)||l.ready>S.day)return '';const n=Math.max(1,l.pairs|0);if(n>=pairsMax(l))return `<span class="meta" style="align-self:center">${tr('{n} fiber pairs lit, the trench is full',{n})}</span>`;
|
||
const full=(l.ch||[]).length+soldSlots(l)>=chMax(l),c=pairCost(l);return btn(l.sub?tr('Light fiber pair {n} <small>{price}</small>',{n:n+1,price:fmt$(c)}):tr('Light fiber pair {n} <small>{price} + {mo}/mo</small>',{n:n+1,price:fmt$(c),mo:fmt$(ampCount(l.km)*AMP_MO)}),'addPair',{id:l.id},full?'pink sm':'ghost sm',!full||S.cash<c);}
|
||
function chWhy(l,o){const O=OPT[o];if(O.lvl>lvl())return tr('Unlocks at customer level {n}.',{n:O.lvl});if(O.sys==='roadm'&&!isRdm(l.sys))return tr('Needs a ROADMaster 9000 line system.');if(!optMode(o,l)){const mx=reachOn((O.modes||[[0,O.reach]]).at(-1)[1],l.sub);return tr('Too far even at its slowest setting: an optical span here is {span} km and it reaches {max} km. Add a regen site (Line system).',{span:spanKm(l).toLocaleString(),max:mx.toLocaleString()});}
|
||
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].cls<O.rg)return tr('Needs routers with {pn} ports or bigger at both ends ({city}).',{pn:RG[mainRG(O.rg)].pn,city:CITY[c].name});}return '';}
|
||
function bbCost(c){return 15000+CITY[c].P*20;}
|
||
function after(){if(S)purgeInc();compute();checkGoals();renderAll();if(S&&!$('dash').hidden)renderDash();save();}
|
||
const isTablet=()=>innerWidth>760&&innerWidth<=1200;
|
||
function selectLink(id){UI.sel={type:'link',id};UI.confirm=null;if(isTablet()||isPhone())UI.leftOpen=false;$('panel').classList.remove('full');renderPanel();renderLeft();}
|
||
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();}
|
||
|
||
/* ================= SAVE ================= */
|
||
function save(){if(!S||S.lost)return;S.uiSpeed=UI.speed;S.cam={x:cam.x,y:cam.y,z:cam.z};try{localStorage.setItem('sot-save-v1',JSON.stringify(S));}catch(e){}UI.lastSave=performance.now();}
|
||
// Save whenever the player might be leaving: tab hidden, page closing or reloading.
|
||
addEventListener('pagehide',()=>save());
|
||
document.addEventListener('visibilitychange',()=>{if(document.visibilityState==='hidden')save();else checkUpdate();});
|
||
/* Export / import: move a network to another device or keep a backup. The file is the same
|
||
object the autosave writes, wrapped with a little metadata. */
|
||
function saveFileName(){const d=new Date().toISOString().slice(0,10),n=(S&&S.name||'network').toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'network';return `series-of-tubes-${n}-${d}.json`;}
|
||
function exportSave(){if(!S)return;save();const blob=new Blob([JSON.stringify({app:'series-of-tubes',version:APP_VERSION,exported:new Date().toISOString(),S},null,1)],{type:'application/json'});
|
||
const a=document.createElement('a');a.href=URL.createObjectURL(blob);a.download=saveFileName();document.body.appendChild(a);a.click();setTimeout(()=>{URL.revokeObjectURL(a.href);a.remove();},1000);
|
||
toast(tr('<b>Save exported.</b><br>{file} is in your downloads. Open it on another device with “Import a save”.',{file:esc(saveFileName())}),'good');}
|
||
function parseSave(txt){if(typeof txt!=='string')return {err:tr('That file is not valid JSON.')};let j;try{j=JSON.parse(txt);}catch(e){return {err:tr('That file is not valid JSON.')};}
|
||
const s=j&&j.app==='series-of-tubes'&&j.S?j.S:j;
|
||
if(!s||typeof s!=='object'||s.v!==1||typeof s.day!=='number'||typeof s.cash!=='number'||!s.pops||typeof s.pops!=='object'||!Array.isArray(s.links))return {err:tr('That does not look like a Series of Tubes save.')};
|
||
if(s.lost)return {err:tr('That network went bankrupt. It cannot be brought back, only mourned.')};
|
||
for(const c of Object.keys(s.pops))if(!isCity(c))return {err:tr('That save has a POP in a city this version does not know ({city}).',{city:esc(String(c).slice(0,12))})};
|
||
return {s,ver:j.version||'?',name:String(s.name||tr('Unnamed network'))};}
|
||
function importFile(file){if(!file)return;if(file.size>8e6){toast(tr('<b>That file is too big to be a save.</b>'),'bad');return;}
|
||
const rd=new FileReader();rd.onload=()=>{const r=parseSave(String(rd.result));if(r.err){toast(tr('<b>Import failed.</b><br>{err}',{err:esc(r.err)}),'bad');sfx('err');return;}
|
||
UI.importing=r.s;openModal(`<div class="eyebrow">${tr('Import a save')}</div><h2 style="font-size:26px">${tr('Load {name}?',{name:esc(r.name)})}</h2><p class="tagline">${esc(dateStr(r.s.day))} · ${tr('{cash} in the bank',{cash:fmt$(r.s.cash)})} · ${trn('{n} POP','{n} POPs',Object.keys(r.s.pops).length)} · ${tr('saved by v{ver}',{ver:esc(r.ver)})}</p>${S&&UI.started&&!S.lost?`<p class="note" style="color:var(--bad)">${tr('This replaces {name}. Export it first if you want to keep it.',{name:esc(S.name)})}</p>`:''}<div class="btns">${btn(tr('Load this network'),'importGo',{},'pink big')}${btn(tr('Cancel'),UI.started?'closeModal':'helpClose',{},'ghost big')}</div>`);};
|
||
rd.readAsText(file);}
|
||
function loadSave(){try{const t=localStorage.getItem('sot-save-v1');if(t){const s=JSON.parse(t);if(s&&s.v===1&&!s.lost)return s;}}catch(e){}return null;}
|
||
|
||
/* ================= AUDIO ================= */
|
||
let AC=null;
|
||
function audioInit(){if(AC)return;try{AC=new (window.AudioContext||window.webkitAudioContext)();}catch(e){}}
|
||
function tone(f,t0,dur,type='square',vol=.05){if(!AC)return;const o=AC.createOscillator(),g=AC.createGain();o.type=type;o.frequency.value=f;g.gain.setValueAtTime(vol,AC.currentTime+t0);g.gain.exponentialRampToValueAtTime(.0001,AC.currentTime+t0+dur);o.connect(g).connect(AC.destination);o.start(AC.currentTime+t0);o.stop(AC.currentTime+t0+dur+.02);}
|
||
function sfx(k){if(UI.muted||!AC)return;try{
|
||
if(k==='coin'){tone(988,0,.08);tone(1319,.08,.18);}
|
||
else if(k==='build'){tone(523,0,.07,'triangle',.08);tone(784,.06,.12,'triangle',.08);}
|
||
else if(k==='err'){tone(180,0,.18,'sawtooth',.04);}
|
||
else if(k==='alert'){tone(880,0,.1,'square',.04);tone(660,.12,.1,'square',.04);tone(880,.24,.12,'square',.04);}
|
||
else if(k==='click'){tone(660,0,.04,'triangle',.05);}
|
||
}catch(e){}}
|
||
|
||
/* ================= DOM RENDER ================= */
|
||
const $=id=>document.getElementById(id);
|
||
const btn=(label,act,args={},cls='',dis=false,title='')=>`<button class="b ${cls}" data-act="${act}" data-args="${esc(JSON.stringify(args))}"${dis?' disabled':''}${title?` title="${esc(title)}"`:''}>${label}</button>`;
|
||
const logo=n=>`<span class="logo" style="--c:${n.col}">${initials(n)}</span>`;
|
||
const barCls=u=>u>=0.9?'bad':u>=0.65?'warn':'';
|
||
function renderAll(){if(isTablet()&&!UI.sel)UI.leftOpen=false;renderHUD();renderLeft();renderPanel();renderHint();renderMega();renderCoach();}
|
||
function renderMega(){const el=$('mega');if(!el)return;const on=!!(S&&S.ev&&S.ev.php>S.day);if(el.hidden===!on)return;el.hidden=!on;}
|
||
|
||
/* ================= PHONE ================= */
|
||
const isPhone=()=>innerWidth<=760||(innerHeight<=500&&matchMedia('(pointer:coarse)').matches);
|
||
const SPEEDS=[0.5,1,2,4,8];
|
||
function renderTabbar(){const tb=$('tabbar');if(!tb||(pressing&&UI.ticking))return;if(!isPhone()||!S||!UI.started){tb.hidden=true;document.body.classList.remove('sheet-open');return;}tb.hidden=false;
|
||
const open=UI.leftOpen&&!UI.sel,cur=UI.left||'goals',ndone=GOALS.filter(g=>S.done[g.id]!==undefined).length;
|
||
const tab=(k,ic,l,cnt,red)=>`<button class="${open&&cur===k?'on':''}" data-act="phoneTab" data-args='{"t":"${k}"}' aria-label="${esc(l)}"><span class="ic" aria-hidden="true">${ic}</span>${esc(l)}${cnt?`<span class="cnt${red?' red':''}">${cnt}</span>`:''}</button>`;
|
||
const h=`<button class="play${UI.speed?'':' paused'}" data-act="phonePlay" aria-label="${UI.speed?tr('Pause'):tr('Play')}"><span class="ic" aria-hidden="true">${UI.speed?'❚❚':'▶'}</span>${UI.speed?tr('Pause'):tr('Play')}</button>`+
|
||
`<button data-act="phoneSpeed" aria-label="${tr('Game speed')}"><span class="ic" aria-hidden="true">${UI.speed===0.5?'½':(UI.lastSpeed||UI.speed||1)}×</span>${tr('Speed')}</button>`+
|
||
(()=>{const P=scnProg();return tab('goals','🎯',tr('Goals'),P&&!S.scn.done&&!S.scn.failed?`${Math.round(P.f*100)}%`:`${ndone}/${GOALS.length}`);})()+(()=>{const u=custStats().unhappy;return u?tab('deals','💼',tr('Deals'),u,true):tab('deals','💼',tr('Deals'),S.offers.length||'');})()+tab('noc','🚨','NOC',S.inc.length||'',true)+tab('nets','🌐',tr('Networks'));
|
||
if(h!==UI._tb){UI._tb=h;tb.innerHTML=h;}
|
||
document.body.classList.toggle('sheet-open',!!(UI.sel||UI.leftOpen));}
|
||
function haptic(ms){if(UI.muted)return;try{navigator.vibrate&&navigator.vibrate(ms||12);}catch(e){}}
|
||
// Bottom sheets: drag the handle up to expand, down to shrink or close; tap it to toggle.
|
||
(function(){let g=null;
|
||
document.addEventListener('pointerdown',e=>{const h=e.target.closest('[data-grab]');if(!h||!isPhone())return;const el=h.parentElement;g={el,y:e.clientY,dy:0,id:e.pointerId,full:el.classList.contains('full')};try{h.setPointerCapture(e.pointerId);}catch(_){}el.style.transition='none';});
|
||
document.addEventListener('pointermove',e=>{if(!g||e.pointerId!==g.id)return;g.dy=e.clientY-g.y;if(g.dy>0)g.el.style.transform=`translateY(${g.dy}px)`;});
|
||
const end=e=>{if(!g||e.pointerId!==g.id)return;const {el,dy,full}=g;g=null;el.style.transition='';el.style.transform='';
|
||
if(Math.abs(dy)<6){el.classList.toggle('full');return;}
|
||
if(dy<-40){el.classList.add('full');return;}
|
||
if(dy>40){if(full){el.classList.remove('full');return;}if(el.id==='panel')ACT.closePanel();else{UI.leftOpen=false;renderLeft();}}};
|
||
document.addEventListener('pointerup',end);document.addEventListener('pointercancel',end);})();
|
||
// Toasts can be tapped away on touch screens.
|
||
document.addEventListener('click',e=>{const t=e.target.closest('.toast');if(t&&!e.target.closest('[data-act]')&&isPhone())t.remove();});
|
||
/* ================= INSTALL (PWA) ================= */
|
||
let installEvt=null;
|
||
addEventListener('beforeinstallprompt',e=>{e.preventDefault();installEvt=e;});
|
||
addEventListener('appinstalled',()=>{installEvt=null;track('pwa_installed',true);if(UI.pendGame){const p=UI.pendGame;UI.pendGame=null;UI.pitched=true;beginGame(...p);}toast(tr('<b>Installed!</b><br>Open Series of Tubes from your home screen. Your saves come along.'),'good');});
|
||
const isStandalone=()=>{try{return navigator.standalone===true||!!(window.matchMedia&&matchMedia('(display-mode: standalone)').matches);}catch(e){return false;}};
|
||
const isIOS=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||(navigator.platform==='MacIntel'&&navigator.maxTouchPoints>1);
|
||
function installRow(){if(isStandalone())return '';
|
||
return `<div class="row icard"><div class="grow"><div class="nm">📲 ${tr('Best played as an app')}</div><div class="meta">${tr('Full screen, works offline, one tap from your home screen.')}${isIOS()?' '+tr('Install it before you start: a game begun in Safari stays in Safari.'):''}</div></div>${btn(tr('Install'),'install',{},'pink sm')}</div>`;}
|
||
/* Phones get a real pitch before a new game: an installed app is full screen, works offline, and on iPhone
|
||
keeps its save away from Safari's clean-ups. Storage is separate on iOS, so installing first matters. */
|
||
const SHARE_SVG='<svg width="16" height="18" viewBox="0 0 16 18" aria-hidden="true"><path d="M8 1v10M4.5 4.5 8 1l3.5 3.5M5 7H2.5v9.5h11V7H11" fill="none" stroke="#1E2640" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
||
const needPitch=()=>isPhone()&&!isStandalone();
|
||
function installSteps(){
|
||
if(isIOS())return `<ol class="isteps"><li>${tr('Tap <b>Share</b> {icon} in the browser toolbar.',{icon:SHARE_SVG})}</li><li>${tr('Tap <b>Add to Home Screen</b>. You may need to scroll down, or tap <b>More</b> first.')}</li><li>${tr('Open <b>Series of Tubes</b> from your home screen and start your network there.')}</li></ol>`;
|
||
if(installEvt)return '';
|
||
return `<ol class="isteps"><li>${tr('Open your browser menu (⋮).')}</li><li>${tr('Tap <b>Install app</b> or <b>Add to Home screen</b>.')}</li><li>${tr('Open <b>Series of Tubes</b> from your home screen.')}</li></ol>`;}
|
||
function pitchHtml(starting){const ios=isIOS();
|
||
return `<div style="display:flex;align-items:center"><div>${starting?`<div class="eyebrow">${tr('Before you start')}</div>`:''}<h2 style="font-size:26px">📲 ${tr('Play it as an app')}</h2></div><button class="x" data-act="${starting?'pitchSkip':'closeModal'}" aria-label="${tr('Close')}">×</button></div>
|
||
<p class="lead" style="margin-top:6px">${tr('Series of Tubes is made for your home screen. It takes ten seconds, costs nothing, and it is a much better game there:')}</p>
|
||
<ul class="pitch"><li>🗺️ <b>${tr('Full screen.')}</b> ${tr('No browser bars, a lot more map.')}</li><li>📶 <b>${tr('Works offline.')}</b> ${tr('Build your backbone on the train or on a plane.')}</li>${ios?`<li>💾 <b>${tr('Your save stays safe.')}</b> ${tr('Safari can clear the data of websites you have not opened for a week. A home-screen app keeps its own.')}</li><li class="warn">⚠️ <b>${tr('Install first.')}</b> ${tr('On iPhone, a game started in Safari does not carry over to the home-screen app.')}</li>`:`<li>⚡ <b>${tr('One tap away.')}</b> ${tr('It opens straight into your network, like any other app.')}</li>`}</ul>
|
||
${installSteps()}
|
||
<div class="btns cta" style="margin-top:12px">${installEvt?btn(tr('Install the app'),'install',{},'pink big'):''}${starting?btn(tr('Play in the browser anyway'),'pitchSkip',{},installEvt?'ghost':'ghost big'):btn(tr('Got it'),'closeModal',{},installEvt?'ghost':'pink')}</div>`;}
|
||
if('serviceWorker' in navigator&&location.protocol==='https:'&&!IS_DEV)addEventListener('load',()=>{navigator.serviceWorker.register('/sw.js').catch(()=>{});});
|
||
function fitHud(){const h=$('hud');if(!h)return;h.classList.remove('fit1','fit2','fit3');if(innerWidth<=760)return;
|
||
const row=()=>{let m=0;for(const c of h.children)if(c.offsetParent)m=Math.max(m,c.offsetHeight);return m;};
|
||
for(const c of ['fit1','fit2','fit3']){if(h.offsetHeight<=row()*1.5)break;h.classList.add(c);}}
|
||
function renderHUD(){
|
||
for(const v of [0,0.5,1,2,4,8]){const b=$('sp'+v);if(b)b.classList.toggle('on',UI.speed===v);}
|
||
$('muteBtn').style.opacity=UI.muted?.4:1;
|
||
if(!S)return;
|
||
$('hName').textContent=S.name;$('hAsn').textContent='AS'+S.asn+(S.mode==='sandbox'?' · '+tr('Sandbox'):S.scn?' · '+(scnName())+(S.scn.done||S.scn.failed?'':` · ${tr('{n}d left',{n:Math.max(0,S.scn.days-S.day)})}`):'');
|
||
$('hCash').textContent=fmt$(S.cash);$('hCash').style.color=S.cash<0?'var(--bad)':'';
|
||
const net=R.revMo-R.costMo;$('hRate').innerHTML=`<span class="${net>=0?'up':'down'}">${net>=0?'▲':'▼'} ${tr('{price}/mo',{price:fmt$(Math.abs(net))})}</span>`;
|
||
$('hTraffic').textContent=`${fmtG(R.served)}`;
|
||
$('hTrafBar').style.width=(R.demand?R.served/R.demand*100:0)+'%';
|
||
$('hTrafBar').style.background=R.demand&&R.served/R.demand<0.9?'var(--bad)':'var(--ok)';
|
||
$('hReach').textContent=reachPct(R.reach);$('hReach').style.color=R.reach<0.99?'var(--bad)':'var(--eye)';
|
||
$('hTier').textContent=tierLabel()+' · '+tr('Lv {n}',{n:S.lvl||1});
|
||
{const P=scnProg(),hs=$('hScn');hs.hidden=!P;if(P){const sc=S.scn;$('hScnVal').textContent=sc.done?tr('Done!'):sc.failed?tr("Time's up"):`${Math.round(P.f*100)}% · ${tr('{n}d left',{n:Math.max(0,sc.days-S.day)})}`;}}
|
||
$('hDate').textContent=dateStr(S.day);
|
||
{const bo=(S.loanOffers||[]).length,hb=$('hBank');hb.hidden=!bo;hb.textContent=bo;}
|
||
{const st=custStats(),hc=$('hCust');hc.hidden=!st.n;if(st.n){$('hCustVal').innerHTML=`${st.avg>=80?'😀':st.avg>=60?'🙂':st.avg>=30?'😟':'😡'} ${Math.round(st.avg)}%${st.unhappy?` <span class="cnt red">${st.unhappy}</span>`:''}`;hc.classList.toggle('hot',st.furious>0);}}
|
||
const n=S.inc.length;$('hNoc').classList.toggle('hot',n>0);$('hNocVal').textContent=n?trn('{n} incident','{n} incidents',n):tr('All quiet');
|
||
if(!window.__TUBES_TEST__)fitHud();
|
||
renderTabbar();
|
||
}
|
||
function renderLeft(){checkLayer();
|
||
// Tablets in landscape: both side panels don't fit next to the map, so the left one tucks away
|
||
// while a city or link is open and comes back with the toggle button.
|
||
const tab=isTablet(),L=$('left');L.classList.toggle('closed',tab?(!!UI.sel&&!UI.leftOpen):!UI.leftOpen);const tg=$('leftToggle');if(tg&&innerWidth>760)tg.hidden=!(tab&&L.classList.contains('closed'));
|
||
renderTabbar();
|
||
if(!S){L.hidden=true;return;}L.hidden=false;
|
||
const ndone=GOALS.filter(g=>S.done[g.id]!==undefined).length;
|
||
const tabs=[['goals',`${tr('Goals')}<span class="cnt">${ndone}/${GOALS.length}</span>`],['deals',`${tr('Deals')}${S.offers.length?`<span class="cnt">${S.offers.length}</span>`:''}`],['noc',`NOC${S.inc.length?`<span class="cnt red">${S.inc.length}</span>`:''}`],['nets',tr('Networks')]];
|
||
$('leftTabs').innerHTML=tabs.map(([k,l])=>`<button class="${UI.left===k?'on':''}" data-act="leftTab" data-args='{"t":"${k}"}'>${l}</button>`).join('')+(innerWidth<760?`<button data-act="toggleLeft" style="margin-left:auto" aria-label="${tr('Close')}">×</button>`:'');
|
||
let h='';
|
||
if(UI.left==='goals'){
|
||
h+=scnCard()+lvlCard();
|
||
const cur=GOALS.find(g=>S.done[g.id]===undefined);
|
||
h+=GOALS.map(g=>{const d=S.done[g.id]!==undefined,c=g===cur;return `<div class="goal ${d?'done':''} ${c?'cur':''}"><div class="ck">${d?'✓':''}</div><div><div class="gt">${esc(g.t)}</div>${c||!d?`<div class="gd">${esc(g.d)}</div>`:''}${!d&&g.r?`<div class="gr">${tr('Reward {cash}',{cash:fmt$(g.r)})}</div>`:''}</div></div>`;}).join('');
|
||
h+=badgeGrid();
|
||
}else if(UI.left==='deals'){
|
||
{const st=custStats();if(st.n)h+=`<div class="row" style="margin-bottom:8px"><div class="grow"><div class="nm">${tr('Your customers')} <span class="meta">${st.n} · ${tr('happiness {p}%',{p:Math.round(st.avg)})}</span></div><div class="bar ${moodCls(st.avg)}"><i style="width:${st.avg}%"></i></div>${st.unhappy?`<div class="why">${trn('{n} unhappy customer, {price}/mo at risk','{n} unhappy customers, {price}/mo at risk',st.unhappy,{price:fmt$(st.risk)})}</div>`:''}</div>${btn(st.unhappy?tr('See who'):tr('All customers'),'custOpen',{sad:st.unhappy?1:0},st.unhappy?'pink sm':'ghost sm')}</div>`;}
|
||
h+=confSection();
|
||
{const lv=S.lvl||1,nx=LEVELS[lv];h+=`<div class="inc" style="background:#FFF6CF"><div class="nm">${tr('Customer level {lv}: {name}',{lv,name:LEVELS[lv-1].n})}</div><div class="meta">${nx?tr('Next: {req} unlocks {what}',{req:nx.req,what:lc1(nx.unlock)}):tr('Every customer type is unlocked. Go get those terabits.')}</div></div>`;}
|
||
if(!S.offers.length)h+=`<p class="empty">${tr('No open offers right now. Businesses look for networks with POPs in their city. New ones pop up every few weeks.')}</p>`;
|
||
for(const o of S.offers.slice().sort((a,b)=>a.exp-b.exp)){const has=bHas(o);
|
||
h+=`<div class="row"><div class="grow"><div class="nm">${esc(o.name)}</div><div class="meta">${esc(BIZ_T[o.type].l)} · ${CITY[o.city].name}${o.city2?' ⇄ '+CITY[o.city2].name:''} · <b>${bTerms(o)}</b> · ${tr('{n}d left',{n:o.exp-S.day})}${(o.reqs||[]).length?` · ${trn('{n} special requirement','{n} special requirements',o.reqs.length)}`:''}</div>${reqList(o)}
|
||
<div class="btns">${has?btn(tr('Accept'),'accept',{id:o.id},'green sm'):btn(tr('Go there'),'focusCity',{city:bCities(o).find(c=>!S.pops[c])},'ghost sm')}${btn(tr('Decline'),'decline',{id:o.id},'ghost sm')}</div>${has?'':`<div class="why">${tr('Needs a POP in {cities}',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}</div>`}</div></div>`;}
|
||
}else if(UI.left==='noc'){
|
||
h+=`<div class="btns" style="margin-bottom:8px">${btn(tr('Open NOC dashboard'),'dash',{},'pink')}${btn(tr('Connections'),'connOpen',{},'')}${btn(tr('Traceroute'),'trace',{},'')}</div>`;
|
||
h+=`<p class="lead">${tr('Your Network Operations Center. Every notification also lands here. Things fail all the time on the internet. Redundant links and multiple upstreams let traffic reroute by itself.')}</p>`;
|
||
// Incidents come first, the ones you can fix with one click at the top (#63): no scrolling past hot ports to replace an optic.
|
||
for(const i of S.inc.filter(i=>i.type!=='ddos').sort((a,b)=>(b.cost?1:0)-(a.cost?1:0)||(b.impact||0)-(a.impact||0))){h+=`<div class="inc"><div class="nm">${incTitle(i.type)}</div><div class="meta">${esc(i.msg)}</div><div class="meta">${trn('Auto-fix in {n} day','Auto-fix in {n} days',i.until-S.day)}${i.impact?` · ${tr('{g} lost',{g:fmtG(i.impact)})}`:''}</div>${i.cost?`<div class="btns">${btn(`${esc(i.fix||tr('Rush repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red sm',S.cash<i.cost)}</div>`:''}</div>`;}
|
||
h+=`<div class="kv"><span>${tr('DDoS scrubbing')}</span><b>${S.scrubAt?tr('On · {city}',{city:CITY[S.scrubAt].name}):tr('None (build one from a POP\'s Infra tab)')}</b></div>`;
|
||
{const pops=Object.keys(S.pops),nfs=pops.filter(c=>fsAt(c)).length;
|
||
h+=`<div class="kv"><span>${tr('Flowspec-capable POPs')}</span><b>${nfs}/${pops.length}</b></div>`;
|
||
if(nfs<pops.length)h+=`<p class="meta" style="margin:2px 0 6px">${tr('Flowspec drop rules live in router TCAM, so only capable routers filter known UDP floods (DNS, NTP, CLDAP, SYN) at the edge. The used Rusty has none, merchant-silicon and whitebox models do a little, the big chassis do it in full. Upgrade a POP’s router from its Infra tab.')}</p>`;}
|
||
if(S.grace&&S.grace.until>S.day&&R.graceNets)h+=`<div class="kv"><span>${tr('Courtesy route')}</span><b>${tr('{n} networks · {d} days left',{n:R.graceNets,d:S.grace.until-S.day})}</b></div><p class="meta" style="margin:0 0 6px">${tr('Reaches networks from the last update that you have no other path to, for free. Connect to them before it ends.')}</p>`;
|
||
h+=ddosPanel();
|
||
h+=S.te?`<div class="kv"><span>Auto-TE</span><b>${S.te.on?tr('On · moving {g} onto alternate paths',{g:fmtG(R.teMoved||0)}):tr('Off')}</b></div><div class="btns">${btn(S.te.on?tr('Turn Auto-TE off'):tr('Turn Auto-TE on'),'teToggle',{},'ghost sm')}${btn(S.te.script?tr('Edit RouteScript'):tr('Write a RouteScript'),'teEdit',{},'pink sm')}</div>${S.te.script?`<p class="meta" style="margin:2px 0 6px">RouteScript: ${teRules()?tr('{n} rules live',{n:teRules().n}):S.te.on?tr('has errors, not running'):tr('controller off')}${R.teBlack?` · ${tr('blackholing {g}',{g:fmtG(R.teBlack)})}`:''}</p>`:''}`
|
||
:`<div class="kv"><span>Auto-TE</span><b>${lvl()<3?tr('Unlocks at customer level 3'):tr('Not installed')}</b></div><p class="meta" style="margin:2px 0 6px">${tr('Traffic takes the shortest path, even when it is full. A traffic-engineering controller spills the overflow onto the next-best paths with room.')}</p><div class="btns">${btn(tr('Install Auto-TE <small>{cost} + {mo}/mo</small>',{cost:fmt$(TE_COST),mo:fmt$(TE_MO)}),'buyTE',{},'pink sm',lvl()<3||S.cash<TE_COST)}</div>`;
|
||
const hot=S.links.filter(l=>!linkDown(l)&&capOf(l)>0&&(R.load[l.id]||0)/capOf(l)>=0.85).sort((a,b)=>(R.load[b.id]/capOf(b))-(R.load[a.id]/capOf(a)));
|
||
if(hot.length){h+=`<h3 style="font-size:15px;margin:4px 0">${tr('Congested links')}</h3>${S.te&&S.te.on?'':'<p class="meta" style="margin:0 0 4px">'+tr('Raise a full link’s metric so traffic prefers another path, upgrade it, or install Auto-TE.')+'</p>'}`+hot.map(l=>`<div class="row"><div class="grow"><div class="nm">${CITY[l.a].name} ⇄ ${CITY[l.b].name}</div><div class="meta">${capName(l)} · ${tr('{p} full',{p:pct((R.load[l.id]||0)/capOf(l))})}</div></div>${btn(tr('Inspect'),'selLink',{id:l.id},'pink sm')}</div>`).join('');}
|
||
const hotR=hotPorts();
|
||
if(hotR.length)h+=`<h3 style="font-size:15px;margin:4px 0">${tr('Ports, caches and routers running hot')}</h3>`+hotR.map(x=>`<div class="row"><span class="hotk hk-${x.k}">${HOTL[x.k]}</span><div class="grow"><div class="nm">${CITY[x.city].name} · ${esc(x.lab)}</div><div class="meta">${tr('{p} full',{p:pct(Math.min(1,x.u))})}${x.u>=0.995?' · '+tr('dropping or overflowing'):''} · ${esc(x.tip)}</div></div>${btn(tr('Inspect'),'focusCity',{city:x.city},'pink sm')}</div>`).join('');
|
||
if(!S.inc.length&&!hot.length&&!hotR.length)h+=`<p class="empty">${tr('All systems green. Enjoy it while it lasts.')}</p>`;
|
||
if(S.log&&S.log.length){h+=`<h3 style="font-size:15px;margin:12px 0 4px">${tr('Recent events')}</h3>`+S.log.slice(0,15).map(e=>`<div class="row"><div class="grow"><div class="meta"><b class="tag ${e.k==='bad'?'restrictive':e.k==='good'?'open':'st'}">${dateStr(e.d)}</b> ${esc(e.t)}</div></div></div>`).join('');}
|
||
h+=`<div class="kv" style="margin-top:8px"><span>${tr('Incidents so far')}</span><b>${S.stats.incidents}</b></div><div class="kv"><span>${tr('Survived with no impact')}</span><b>${S.stats.survived}</b></div>`;
|
||
}else{
|
||
h+=`<p class="lead">${tr("Every network on the map. Traffic share is how much of your users' traffic goes to them. Tap a connection to jump to its POP.")}</p>`;
|
||
if(conns().length)h+=`<div class="btns" style="margin-bottom:8px">${btn(tr('All connections <small>{n}</small>',{n:conns().length}),'connOpen',{},'pink sm')}</div>`;
|
||
const tl=NETS.filter(n=>n.tail),tlOn=tl.filter(n=>Object.keys(S.ixp).some(c=>ixSessions(c).has(n.id))).length;
|
||
for(const n of NETS){if(n.tail&&!UI.tailOpen)continue;
|
||
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="meta">AS${n.asn}</span></div><div class="meta"><span class="tag ${n.type}">${TYPE_L[n.type]}</span> <span class="tag ${n.pol}">${n.pol}</span> · ${tr('{p}% of traffic',{p:(NSH[n.id]*100).toFixed(1)})}${n.price?` · ${tr('transit ${price}/Gbps',{price:(n.price*S.priceMul).toFixed(2)})}`:''}</div><div class="meta">${esc(n.blurb)}</div>${netWhere(n)}</div></div>`;}
|
||
h+=`<div class="row"><div class="grow"><div class="nm">${tr('The long tail')} <span class="meta">${tr('{n} small networks',{n:tl.length})}</span></div><div class="meta">${tr('{p}% of traffic between them, scattered across exchanges. You peer with {n}.',{p:(tl.reduce((a,n)=>a+NSH[n.id],0)*100).toFixed(1),n:tlOn})}</div></div>${btn(UI.tailOpen?tr('Hide'):tr('Show'),'tailTog',{},'ghost sm')}</div>`;
|
||
}
|
||
if(h!==UI._lh){UI._lh=h;$('leftBody').innerHTML=h;}
|
||
}
|
||
function renderPanel(){checkLayer();
|
||
const P=$('panel');
|
||
if(!S||!UI.sel){P.hidden=true;return;}
|
||
P.hidden=false;
|
||
const scrollEl=$('panelBody').querySelector('.scroll');const st=scrollEl?scrollEl.scrollTop:0;
|
||
const html=UI.sel.type==='city'?cityPanel(UI.sel.id):linkPanel(UI.sel.id);if(html===UI._ph&&!P.hidden&&$('panelBody').firstChild)return;UI._ph=html;$('panelBody').innerHTML=html;
|
||
const ns=$('panelBody').querySelector('.scroll');if(ns)ns.scrollTop=st;
|
||
}
|
||
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(C.dc)}</div><h2>${C.name}</h2>
|
||
<div class="facts"><span class="fact">${tr('{g} of eyeballs',{g:fmtG(eyeP(c))})}</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>`;
|
||
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>`}`;
|
||
h+=offersHere(c);
|
||
const trs=NETS.filter(n=>n.price&&n.pops.includes(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>`;
|
||
return h;
|
||
}
|
||
const tabs=[['cust',tr('Customers')],['up',tr('Transit')],['peer',tr('Peering')],['links',tr('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(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=Math.max(8,C.P*0.03);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)})}</p>${btn(tr('Launch broadband <small>{cost}</small>',{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)})}</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>`;
|
||
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'&&!S.scrubAt?' · <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>`;
|
||
h+=`</section>`+offersHere(c);
|
||
}else if(UI.tab==='up'){
|
||
h+=portNote(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>`;
|
||
const prov=NETS.filter(n=>n.price&&n.pops.includes(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>`;
|
||
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>`;
|
||
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></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(C.dc)})}</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){const u=R.usePni[pn.id]||0,cap=lagCap(PORT[pn.tier].g,pn.n);h+=`<div class="kv"><span>${(pn.n||1)>1?`${pn.n}×${PORT[pn.tier].n} LAG`:PORT[pn.tier].n} PNI</span><b>${fmtG(u)}</b></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)=>i>pn.tier?btn((pn.n||1)>1?tr('Upgrade all to {port} <small>{cost}</small>',{port:P2.n,cost:fmt$((1500+P2.setup/2)*(pn.n||1))}):tr('Upgrade {port} <small>{cost}</small>',{port:P2.n,cost:fmt$((1500+P2.setup/2)*(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?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">${PORT.map((P2,i)=>portShown(i)?btn(`${P2.n} <small>${fmt$(1500+P2.setup/2)}</small>`,'pni',{city:c,net:n.id,tier:i},'sm',S.cash<1500+P2.setup/2||!portOk(c,i)):'').join('')}</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>`;}
|
||
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>`;
|
||
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+=`</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>
|
||
${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&&!S.myIx[x]&&onSite((S.ixSite||{})[x],s)).map(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>`;
|
||
if(S.scrubAt===c){const T=SCRUB_TIERS[S.scrubTier||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$(scrubMo())}/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>(S.scrubTier||0)?btn(tr('Upgrade to {tier} <small>{cost}</small>',{tier:X.n,cost:fmt$(Math.round(X.cost*0.6))}),'scrubUp',{tier:i},'sm',(lvl()||1)<X.lvl||S.cash<X.cost*0.6):'').join('')}${btn(UI.confirm==='scrub'?tr('Really shut it down?'):tr('Shut down'),'rmScrub',{},'ghost sm')}</div>`;}
|
||
else if(S.scrubAt)h+=`<p class="lead">${tr('You already run one in {city}.',{city:CITY[S.scrubAt].name})}</p>`;
|
||
else{h+=`<p class="lead">${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+=`</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>`;
|
||
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>`;
|
||
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>`;
|
||
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+=`</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>`;
|
||
}
|
||
return h+`</div>`;
|
||
}
|
||
/* Decommissioning POPs. Customers that touch a decommissioned city, or ride a removed link, are let go
|
||
with an early-termination penalty of three months of their contract. */
|
||
const DECOM_MONTHS=3;
|
||
function decomImpact(cities){const set=new Set(cities),links=S.links.filter(l=>set.has(l.a)||set.has(l.b)),lids=new Set(links.map(l=>l.id));
|
||
const biz=S.biz.filter(b=>bCities(b).some(c=>set.has(c))||(b.link&&lids.has(b.link)));
|
||
const pen=b=>Math.max(2000,Math.round(b.fee?b.fee*0.5:b.bw*b.rate*DECOM_MONTHS));
|
||
return {links,biz,pen,fee:biz.reduce((a,b)=>a+pen(b),0),eye:cities.reduce((a,c)=>a+(R.cityEye[c]||0),0)};}
|
||
function decomModal(){const sel=[...(UI.decom||[])],im=decomImpact(sel),all=Object.keys(S.pops),left=all.length-sel.length;
|
||
const rows=all.map(c=>`<label class="row" style="cursor:pointer"><input type="checkbox" data-act="decomToggle" data-args='${esc(JSON.stringify({city:c}))}' ${sel.includes(c)?'checked':''}><div class="grow"><div class="nm">${esc(CITY[c].name)}${c===S.home?` <span class="tag st">${tr('home')}</span>`:''}</div><div class="meta">${trn('{n} link','{n} links',S.links.filter(l=>l.a===c||l.b===c).length)} · ${trn('{n} customer','{n} customers',S.biz.filter(b=>bCities(b).includes(c)).length)}</div></div></label>`).join('');
|
||
openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:24px">${tr('Decommission POPs')}</h2><button class="x" data-act="closeModal" aria-label="${tr('Close')}">×</button></div>
|
||
<p class="lead" style="margin-top:6px">${tr('Pick the POPs to shut down. Everything in them goes: routers, ports, caches, exchange ports and every link that touches them.')}</p>${rows}
|
||
${sel.length?`<div class="kv"><span>${tr('Links removed')}</span><b>${im.links.length}</b></div><div class="kv"><span>${tr('Eyeballs you stop serving')}</span><b>${fmtG(im.eye)}</b></div><div class="kv"><span>${trn('{n} customer let go','{n} customers let go',im.biz.length)}</span><b style="color:var(--bad)">${fmt$(im.fee)}</b></div>${im.biz.length?`<p class="meta">${im.biz.map(b=>esc(b.name)+' '+fmt$(im.pen(b))).join(' · ')}</p>`:''}`:''}
|
||
${left<1?`<p class="why">${tr('Keep at least one POP.')}</p>`:''}
|
||
<div class="btns" style="margin-top:10px">${btn(sel.length?trn('Decommission {n} POP · pay {fee}','Decommission {n} POPs · pay {fee}',sel.length,{fee:fmt$(im.fee)}):tr('Pick a POP'),'decomGo',{},'red',!sel.length||left<1)}${btn(tr('Keep them'),'closeModal',{},'ghost')}</div>`);}
|
||
function decommission(cities){const set=new Set(cities),im=decomImpact(cities),lids=new Set(im.links.map(l=>l.id)),bids=new Set(im.biz.map(b=>b.id));
|
||
S.links=S.links.filter(l=>!lids.has(l.id));S.biz=S.biz.filter(b=>!bids.has(b.id));S.offers=S.offers.filter(o=>!bCities(o).some(c=>set.has(c)));
|
||
S.transit=S.transit.filter(t=>!set.has(t.city));S.pni=S.pni.filter(x=>!set.has(x.city));S.caches=S.caches.filter(x=>!set.has(x.city));S.nni=(S.nni||[]).filter(x=>!set.has(x.city));
|
||
for(const c of cities){for(const x of ixIdsIn(c)){delete S.ixp[x];delete S.rs[x];if(S.ixn)delete S.ixn[x];if(S.ixSite)delete S.ixSite[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}delete S.myIx[c];if(S.scrubAt===c)S.scrubAt=null;delete S.pops[c];}
|
||
const rem=remoteCities();for(const x in S.ixp){const c=ixCity(x);if(!S.pops[c]&&!rem.includes(c)){delete S.ixp[x];delete S.rs[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}}
|
||
if(set.has(S.home))S.home=Object.keys(S.pops)[0];
|
||
purgeInc();S.cash-=im.fee;S.stats.decom=(S.stats.decom||0)+cities.length;
|
||
toast(trn('<b>{n} POP decommissioned.</b><br>{fee} in early-termination penalties to {m} customers.','<b>{n} POPs decommissioned.</b><br>{fee} in early-termination penalties to {m} customers.',cities.length,{fee:fmt$(im.fee),m:im.biz.length}),'bad');}
|
||
const portMo=v=>v?tr('{price}/mo',{price:fmt$(v)}):tr('free');
|
||
function ixSection(c){const ids=ixIdsIn(c);if(ids.length<2)return ixBlock(c,false);
|
||
let h=`<section><h3>${tr('Internet Exchanges')}</h3><p class="lead">${tr('{n} exchanges compete in {city}. Members overlap, but not completely, and the challengers undercut the incumbent. Small networks often sit on just one of them.',{n:ids.length,city:esc(CITY[c].name)})}</p></section>`;
|
||
for(const x of ids)h+=ixBlock(x,true);return h;}
|
||
function ixBlock(c,multi){const city=ixCity(c),C=CITY[city],ix=ixName(c),X=XIXM[c];let h='';
|
||
h+=`<section><h3>${multi?esc(ix)+(X?' <span class="tag st">'+tr('challenger')+'</span>':' <span class="tag st">'+tr('incumbent')+'</span>'):tr('Internet Exchange')}</h3>`;
|
||
if(!ix&&C.cn){h+=`<p class="lead">${tr('Running an exchange in mainland China takes a different license entirely. Peer with Chinese networks over PNIs, or meet them in Hong Kong.')}</p>`;}
|
||
else if(!ix){h+=`<p class="lead">${tr("There's no IX in {city} yet. Found one: networks join over time, pay you for ports, and peer with you for free.",{city:C.name})}</p>${S.pops[city]?btn(tr('Found your own IX <small>{cost} + {mo}/mo</small>',{cost:fmt$(MYIX_COST),mo:fmt$(MYIX_MO)}),'foundIx',{city:c},'pink',S.cash<MYIX_COST):'<p class="note">'+tr('Build a POP here first.')+'</p>'}`;}
|
||
else if(S.ixp[c]===undefined){h+=`<p class="lead">${tr('{ix} is a shared switch. One port lets you peer with every member for free. Members: {list}.',{ix:esc(ix),list:(()=>{const m=ixMembers(c),big=m.filter(id=>!NET[id].tail),t=m.length-big.length;return (big.map(id=>esc(NET[id].name)).join(', ')||tr('nobody yet'))+(t?trn(', plus {n} small network',', plus {n} small networks',t):'');})()})}</p>${S.pops[city]?'':REMOTE_WARN}${X?`<p class="note">${esc(X.blurb)} ${X.freeTo!==undefined?tr('Ports up to {port} are free.',{port:PORT[X.freeTo].n}):tr('Ports at {p}% of the usual price.',{p:Math.round(ixMul(c)*100)})}</p>`:''}${CITY[city].ixCheap?`<p class="note">${tr('<b>Run by a nonprofit.</b> Public prices at a fraction of what other exchanges charge, and almost everyone is here.')}</p>`:''}${isDk(c)?`<p class="note">${tr('<b>Run by DE-KICKS Group.</b> No public price list. Ask sales for a personalised quote and bring your haggling face.')}</p>`:''}<div class="btns">${PORT.map((P2,i)=>btn(isDk(c)?tr('{port} port <small>Price on request ☎</small>',{port:P2.n}):tr('{port} port <small>{price}</small>',{port:P2.n,price:portMo(ixPortMo(c,i))}),'buyIx',{city:c,tier:i},'',(!isDk(c)&&S.cash<ixPortMo(c,i))||(!!S.pops[city]&&!portOk(city,i))||(!S.pops[city]&&i>1))).join('')}</div>`;}
|
||
else{const mine=!!S.myIx[c],u=R.useIx[c]||0,cap=ixCap(c),set=ixSessions(c),xdown=S.ev.ixdown&&S.ev.ixdown[c]>S.day;
|
||
h+=`<div class="kv"><span>${mine?tr('Your own fabric · {name}',{name:myFab(c).n}):lagName(S.ixp[c],(S.ixn||{})[c])}${xdown?' · <b style="color:var(--bad)">FABRIC DOWN</b>':''}</span><b>${fmtG(u)}</b></div><div class="bar ${barCls(u/cap)}"><i style="width:${u/cap*100}%"></i></div>${prefCtl('ix',c,S.ixPref&&S.ixPref[c])}${S.pops[city]?siteCtl('ix',c,city,(S.ixSite||{})[c]):''}`;
|
||
if(isDk(c)&&S.dk){const ad=S.dk.add[c]||[],rt=S.dk.ret[c];h+=`<p class="note">${rt&&rt>S.day?tr('DE-KICKS personalised pricing: {p}% of what a normal IX would charge (promo, {n} days left).',{p:Math.round(dkMult(c)*100),n:rt-S.day}):tr('DE-KICKS personalised pricing: {p}% of what a normal IX would charge.',{p:Math.round(dkMult(c)*100)})}</p>`;
|
||
for(const x of ad)h+=`<div class="row"><div class="grow"><div class="nm">${esc(x.n)} <span class="tag paid">${tr('auto-enrolled')}</span></div><div class="meta">${esc(x.blurb)} · ${tr('{price}/mo',{price:fmt$(x.mo)})}</div></div>${btn(UI.confirm==='dk'+c+x.n?tr('Lose exclusive benefits?'):tr('Opt out'),'dkOptOut',{city:c,n:x.n},'ghost sm')}</div>`;}
|
||
if(isRemote(c))h+=`<p class="note">${trn('Remote port via a reseller: 1.5× price, 80% usable, and {n} member here refuse remote peers.','Remote port via a reseller: 1.5× price, 80% usable, and {n} members here refuse remote peers.',ixMembers(c).filter(noRemote).length)}</p>`;
|
||
if(mine){const f=S.myIx[c].fab|0,N=MYIX_FAB[f+1];h+=`<div class="kv"><span>${tr('Members paying you')}</span><b>${tr('{n} of up to {max} · {price}/mo',{n:S.myIx[c].members.length,max:myFab(c).max,price:fmt$(S.myIx[c].members.length*MYIX_FEE)})}</b></div>${N?`<div class="btns">${btn(N.lvl>lvl()?tr('{name} fabric <small>level {lv}</small>',{name:N.n,lv:N.lvl}):tr('Upgrade fabric to {name} <small>{cost} + {mo}/mo</small>',{name:N.n,cost:fmt$(N.cost),mo:fmt$(N.mo)}),'myIxUp',{city:c},'pink sm',N.lvl>lvl()||S.cash<N.cost)}</div><p class="note">${tr('A bigger fabric carries more traffic and has room for more members. Your router here still has to keep up.')}</p>`:'<p class="note">'+tr('Biggest fabric money can buy.')+'</p>'}`;}
|
||
else h+=`<div class="btns">${PORT.map((P2,i)=>i>S.ixp[c]&&portShown(i)?btn(tr('Upgrade {port} <small>{price}</small>',{port:P2.n,price:portMo(ixPortMo(c,i)*((S.ixn||{})[c]||1))}),'buyIx',{city:c,tier:i},'sm',(!!S.pops[city]&&!portOk(city,i))||(!S.pops[city]&&i>1)):'').join('')}${S.pops[city]&&((S.ixn||{})[c]||1)<LAG_MAX?btn(tr('+ LAG member <small>{price}</small>',{price:portMo(ixPortMo(c,S.ixp[c]))}),'lagIx',{city:c,d:1},'sm',S.cash<ixPortMo(c,S.ixp[c])):''}${((S.ixn||{})[c]||1)>1?btn(tr('− member'),'lagIx',{city:c,d:-1},'ghost sm'):''}${btn(S.rs[c]?tr('Leave route server'):tr('Join route server'),'rs',{city:c},S.rs[c]?'ghost sm':'pink sm')}${btn(UI.confirm==='ix'+c?tr('Really leave?'):tr('Leave IX'),'cancelIx',{city:c},'ghost sm')}</div>`;
|
||
h+=`<div style="margin-top:8px">`;
|
||
{const elig=mine?[]:ixMembers(c).filter(id=>!set.has(id)&&peerOk(id,'ix',c).ok);if(elig.length>1)h+=`<div class="btns">${btn(tr('Request all {n} willing peers',{n:elig.length}),'peerAll',{city:c},'pink sm')}</div>`;}
|
||
for(const id of ixMembers(c).sort((a,b)=>NSH[b]-NSH[a])){const n=NET[id],on=set.has(id),viaRs=on&&!S.peers[id+'@'+c]&&!mine,chk=peerOk(id,'ix',c);
|
||
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)}</div><div class="meta"><span class="tag ${n.type}">${TYPE_L[n.type]}</span> <span class="tag ${n.pol}">${n.pol}</span> · ${(NSH[id]*100).toFixed(NSH[id]<0.01?1:0)}%${n.tail?' <span class="tag st">'+tr('tiny')+'</span>':''}</div>${!on&&!chk.ok?`<div class="why">${esc(chk.why)}</div>`:''}</div>
|
||
${on?(viaRs||mine?`<span class="tag st on">${mine?tr('Member'):tr('via RS')}</span>`:btn(tr('Peered ✓'),'unpeer',{city:c,net:id},'green sm',false,tr('Click to tear down'))):btn(tr('Request'),'peer',{city:c,net:id},'sm',!chk.ok)}</div>`;}
|
||
h+=`</div>`;}
|
||
h+=`</section>`;return h;
|
||
}
|
||
function vxcPanel(l){
|
||
const load=R.load[l.id]||0,cap=VXC[l.vt].g,u=load/cap,down=linkDown(l),f=FAB[l.prov];
|
||
let h=`<div class="ph"><div><div class="eyebrow">${tr('Virtual circuit · {name} · {km} km',{name:esc(f.name),km:l.km.toLocaleString()})}</div><h2>${CITY[l.a].name} ⇄ ${CITY[l.b].name}</h2></div><button class="x" data-act="closePanel" aria-label="${tr('Close')}">×</button></div><div class="scroll">`;
|
||
if(down)h+=`<section><h3 style="color:var(--bad)">${tr('Fabric outage')}</h3><p class="lead">${tr('{name} is down. Nothing you can do but wait, or have another path.',{name:esc(f.name)})}</p></section>`;
|
||
h+=`<section><h3>${tr('Capacity')}</h3><div class="kv"><span>${tr('{name} circuit',{name:VXC[l.vt].n})}</span><b>${fmtG(load)} / ${fmtG(cap)}</b></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div>
|
||
<div class="kv"><span>${tr('Monthly')}</span><b>${tr('{price}/mo',{price:fmt$(l.mo)})}</b></div>${!S.pops[l.b]?`<p class="note">${tr('Remote peering leg into {ix}.',{ix:esc(CITY[l.b].ix)})}</p>`:''}
|
||
<div class="btns">${VXC.map((V,t)=>t>l.vt?btn(`${V.n} <small>${tr('{price}/mo',{price:fmt$(vxcMo(l.km,l.sub,t))})}</small>`,'upVxc',{id:l.id,t},'sm'):'').join('')}</div></section>
|
||
${trafficSection(l)}${metricSection(l)}
|
||
<section>${btn(UI.confirm===l.id?tr('Really cancel?'):tr('Cancel circuit'),'cancelVxc',{id:l.id},'ghost sm')}</section></div>`;
|
||
return h;
|
||
}
|
||
function prefCtl(kind,id,cur){cur=cur||'normal';return `<div class="btns"><span class="meta" style="align-self:center">${tr('Egress:')}</span>${Object.keys(PREF).map(v=>btn(PREF[v],'setPref',{kind,id,v},cur===v?'pink sm':'ghost sm')).join('')}</div>`;}
|
||
function trafficSection(l){
|
||
const rec=R.ef[edgeKey(l)],n=pairLinks(l.a,l.b).length;
|
||
let h=`<section><h3>${tr("What's on this link")}</h3>`;
|
||
if(!rec){return h+`<p class="empty">${tr('No traffic right now.')}</p></section>`;}
|
||
const tot=Object.values(rec.net).reduce((a,b)=>a+b,0)||1;
|
||
const nets=Object.entries(rec.net).sort((a,b)=>b[1]-a[1]);
|
||
const col=id=>id==='junk'?'#FF4D5E':id==='l2vpn'?'#7B61FF':NET[id].col,nm=id=>id==='junk'?tr('DDoS junk'):id==='l2vpn'?tr('L2VPN customers'):NET[id].name;
|
||
h+=`${n>1?`<p class="note" style="margin-top:0">${tr('Totals for all {n} links between these cities.',{n})}</p>`:''}<div class="stack">${nets.map(([id,v])=>`<i style="width:${v/tot*100}%;background:${col(id)}" title="${esc(nm(id))}"></i>`).join('')}</div>`;
|
||
h+=`<h4 class="sub4">${tr('Content from')}</h4>`+nets.slice(0,6).map(([id,v])=>`<div class="kv"><span><span class="dot" style="background:${col(id)}"></span>${esc(nm(id))}</span><b>${fmtG(v)} · ${pct(v/tot)}</b></div>`).join('');
|
||
const egs=Object.entries(rec.eg).sort((a,b)=>b[1]-a[1]);
|
||
h+=`<h4 class="sub4">${tr('Enters your network at')}</h4>`+egs.slice(0,6).map(([k,v])=>{const d=R.egDesc[k];return `<div class="row"><div class="grow"><div class="nm">${esc(d.lab)}</div><div class="meta">${CITY[d.city].name} · ${fmtG(v)} · ${pct(v/tot)}</div></div>${btn(tr('Open'),'goEgress',{city:d.city,k:d.k},'ghost sm')}</div>`;}).join('');
|
||
const dst=Object.entries(rec.dst).sort((a,b)=>b[1]-a[1]);
|
||
h+=`<h4 class="sub4">${tr('Going to customers in')}</h4>`+dst.slice(0,6).map(([c,v])=>`<div class="kv"><span>${CITY[c].name}</span><b>${fmtG(v)} · ${pct(v/tot)}</b></div>`).join('');
|
||
const u=tot/pairLinks(l.a,l.b).filter(x=>!linkDown(x)).reduce((a,x)=>a+capOf(x),0);
|
||
if(u>=0.8&&egs.length){const d=R.egDesc[egs[0][0]];h+=`<p class="why">${tr("Biggest feeder: {egress} in {city}. Set it to “Backup only”, give the customers a closer egress (peering, a cache, local transit), or raise this link's metric.",{egress:esc(d.lab),city:CITY[d.city].name})}</p>`;}
|
||
return h+`</section>`;
|
||
}
|
||
function metricSection(l){const cur=l.metric||'normal';
|
||
return `<section><h3>${tr('Routing metric')}</h3><p class="lead">${tr('Your routers pick the lowest-cost path. Raise the metric to push traffic onto other paths. “Backup only” keeps it idle unless nothing else works. Applies to every link between these two cities.')}</p><div class="btns">${Object.keys(MET).map(k=>btn(MET[k].l,'setMetric',{id:l.id,v:k},cur===k?'pink sm':'ghost sm')).join('')}</div></section>`;}
|
||
function chinaSection(c){const st=S.cnLic?S.cnLic.state:'none',loss=S.ev.gfw>S.day?0.35:0.2;
|
||
let h=`<section><h3>${tr('Behind the Great Firewall')}</h3><p class="lead">${tr('Mainland China plays by its own rules. {list} and other foreign services are blocked here, so users mostly reach Chinese networks. Traffic crossing the border loses about {pct} to filtering and congestion, unless it rides a premium route: CN-Too transit or a premium cross-border circuit (both sold only in Hong Kong), or a PNI with a Chinese network. Revenue per user is lower here.',{list:CN_BLOCKED.slice(0,4).map(esc).join(', '),pct:pct(loss)})}</p>`;
|
||
if(st==='none')h+=`<p class="lead">${tr('Foreign networks need a local joint venture and an operating license to build infrastructure here.')}</p>${btn(tr('Apply for a license <small>{price} + {mo}/mo · ~45 days</small>',{price:fmt$(CN_LIC),mo:fmt$(CN_JV_MO)}),'applyCn',{},'pink',S.cash<CN_LIC)}`;
|
||
else if(st==='pending')h+=`<p class="note">${tr('License paperwork in progress: {n} days left.',{n:Math.max(0,S.cnLic.ready-S.day)})}</p>`;
|
||
else h+=`<p class="note">${tr('Your joint venture holds an operating license.')}</p>`;
|
||
if(R.gfwCross>0.5)h+=`<div class="kv"><span>${tr('Your traffic crossing the border')}</span><b>${fmtG(R.gfwCross)}</b></div><div class="kv"><span>${tr('Lost on the way')}</span><b style="color:var(--bad)">${fmtG(R.gfwLost)}</b></div>`;
|
||
return h+`</section>`;}
|
||
function dfPanel(l){
|
||
const load=R.load[l.id]||0,cap=dfCap(l),u=cap?load/cap:0,bld=l.ready>S.day,A=CITY[l.a].name,B=CITY[l.b].name,inc=S.inc.find(i=>i.ref===l.id||i.ref===(l.trench||l.id)),amps=ampCount(l.km),sysD=DF_SYS[l.sys];
|
||
let h=`<div class="ph"><div><div class="eyebrow">${tr('Dark fiber · {kind} · {km} km',{kind:l.own?tr('your own build'):tr('leased IRU'),km:l.km.toLocaleString()})}</div><h2>${A} ⇄ ${B}</h2></div><button class="x" data-act="closePanel" aria-label="${tr('Close')}">×</button></div><div class="scroll">`;
|
||
if(bld){const tot=Math.max(1,l.ready-l.day),done=clamp((S.day-l.day)/tot,0,1);
|
||
h+=`<section><h3>${l.own?tr('Under construction'):tr('Being spliced')}</h3><div class="kv"><span>${l.own?tr('Permits, trenching, splicing'):tr('IRU handover')}</span><b>${tr('{n} days left',{n:l.ready-S.day})}</b></div><div class="bar me"><i style="width:${done*100}%"></i></div>${l.own?btn(tr('Hire extra crews <small>{price} · −30 days</small>',{price:fmt$(Math.round(15000+l.km*6))}),'crews',{id:l.id},'sm',S.cash<15000+l.km*6):''}<p class="note">${tr("You can pre-install optics now so it lights up the day it's ready.")}</p></section>`;}
|
||
else if(inc&&linkDown(l))h+=`<section><h3 style="color:var(--bad)">${tr('Dark!')}</h3><p class="lead">${esc(inc.msg)}</p>${inc.cost?btn(`${esc(inc.fix||tr('Rush repair'))} ${fmt$(inc.cost)}`,'fixInc',{id:inc.id},'red',S.cash<inc.cost):''}</section>`;
|
||
h+=`<section><h3>${tr('Capacity')}</h3><div class="kv"><span>${tr('{n} of {max} channels lit',{n:(l.ch||[]).length,max:chMax(l)})}${soldSlots(l)?` · ${tr('{n} sold as alien waves',{n:soldSlots(l)})}`:''}</span><b>${fmtG(load)} / ${fmtG(cap)}</b></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div>
|
||
<div class="kv"><span>${tr('Latency')}</span><b>${tr('{ms} ms one-way',{ms:linkLat(l).toFixed(1)})}</b></div><div class="kv"><span>${l.own?tr('Right-of-way upkeep'):tr('IRU lease')}</span><b>${tr('{price}/mo',{price:fmt$(l.mo)})}</b></div><div class="kv"><span>${tr('{n} amp huts',{n:amps})}</span><b>${tr('{price}/mo',{price:fmt$(amps*AMP_MO)})}</b></div>${!bld&&!(l.ch||[]).length?`<p class="why">${tr('This fiber is dark. Add optics below to carry traffic.')}</p>`:''}</section>`;
|
||
h+=`<section><h3>${tr('Optics')}</h3><p class="lead">${tr('Each channel is a pair of optics, one per end. ZR+ optics plug straight into your routers. Transponders sit on a shelf.')}</p>`;
|
||
for(const k of Object.keys(OPT)){const O=OPT[k],n=(l.ch||[]).filter(x=>x===k).length,why=chWhy(l,k);
|
||
const md=optMode(k,l),cc=chCost(l,k),sp=spareN(k);
|
||
h+=`<div class="row"><div class="grow"><div class="nm">${O.n} <span class="meta">${(O.modes||[[O.g,O.reach]]).map(([g,r])=>tr('{g} to {km} km',{g:fmtG(g),km:reachOn(r,l.sub).toLocaleString()})).join(' · ')}</span></div><div class="meta">${esc(O.blurb)}${n?` · <b>${tr('{n} lit',{n})}</b>`:''}${sp?` · ${trn('{n} spare on the shelf','{n} spares on the shelf',sp)}`:''}</div>${md&&!md.full?`<div class="meta">⚠️ ${tr('Runs at <b>{g}</b> per channel on this route (long-haul mode).',{g:fmtG(md.g)})} ${!l.sub&®enNeed(k,l)>(l.regen|0)?trn('{n} regen site would bring it back to {g}.','{n} regen sites would bring it back to {g}.',regenNeed(k,l),{g:fmtG(O.g)}):''}</div>`:''}${why?`<div class="why">${esc(why)}</div>`:''}</div>${n?btn('−','rmCh',{id:l.id,o:k},'ghost sm'):''}${btn(sp?`+ <small>${cc?tr('spare + {price}',{price:fmt$(cc)}):tr('spare')}</small>`:`+ <small>${fmt$(cc)}</small>`,'addCh',{id:l.id,o:k},'sm',!!why||S.cash<cc)}</div>`;}
|
||
{const st=Object.keys(OPT).filter(k=>spareN(k)>0);h+=`<p class="note">${tr('Unplugged optics go on the spares shelf and are used first next time.')}</p>`;if(st.length)h+=`<h4 class="sub4">${tr('Spares shelf')}</h4>`+st.map(k=>`<div class="row"><div class="grow"><div class="nm">${spareN(k)} × ${OPT[k].n}</div></div>${btn(tr('Sell one <small>{price}</small>',{price:fmt$(spareValue(k))}),'sellSpare',{o:k},'ghost sm')}</div>`).join('');}
|
||
const rg=l.regen|0,rgAdd=REGEN_COST+Math.round((l.ch||[]).reduce((a,c)=>a+optCost(c),0)*REGEN_CH);
|
||
h+=`</section><section><h3>${tr('Line system')}</h3><div class="kv"><span>${esc(sysD.n)}</span><b>${tr('{n} amplifiers',{n:amps})}</b></div>
|
||
<div class="kv"><span>${tr('Regen sites')}</span><b>${rg?tr('{n} · optical spans of {km} km',{n:rg,km:spanKm(l).toLocaleString()}):tr('none')}</b></div><p class="note">${tr('A regen site turns the light back into bits halfway and sends it on fresh, so optics only have to reach the next site. Each needs a regen card for every lit channel. {price}/mo per site for the hut.',{price:fmt$(REGEN_MO)})}</p>${l.sub&&l.own?`<p class="note">${tr('No regen sites in the middle of the ocean: long cables run their optics in long-haul mode.')}</p>`:`<div class="btns">${rg<REGEN_MAX?btn(tr('+ Regen site <small>{price}</small>',{price:fmt$(rgAdd)}),'regen',{id:l.id,d:1},'sm',S.cash<rgAdd):''}${rg?btn(tr('− Regen site'),'regen',{id:l.id,d:-1},'ghost sm'):''}</div>`}<p class="note">${esc(sysD.blurb)}</p><div class="btns">${(()=>{const t=sysNext(l);if(!t)return '';const T=DF_SYS[t],c=sysUpCost(l);return T.lvl>lvl()?btn(tr('{sys} <small>level {n}</small>',{sys:T.n,n:T.lvl}),'upSys',{id:l.id},'sm',true):btn(tr('Upgrade to {sys} <small>{price}</small>',{sys:T.n,price:fmt$(c)}),'upSys',{id:l.id},'sm',S.cash<c);})()}${pairBtn(l)}${btn(l.spares?tr('Spares kit on ✓'):tr('Keep a spares kit <small>{price}/mo</small>',{price:fmt$(Math.round(150+(l.ch||[]).length*80))}),'spares',{id:l.id},l.spares?'green sm':'sm')}</div><p class="note">${tr('Spare optics and amplifier cards on the shelf turn multi-day hardware failures into one-day swaps.')}</p></section>`;
|
||
{const sib=pairLinks(l.a,l.b).filter(x=>x!==l&&x.kind!=='vxc');h+=`<section><h3>${tr('Redundancy')}</h3><p class="lead">${sib.length?tr('Other links between these cities:'):tr('This is the only link between these cities. Add a parallel one, or a path through another city.')}</p>${sib.map(x=>`<div class="row"><div class="grow"><div class="nm">${esc(capName(x))} ${linkDown(x)?'<span class="tag restrictive">'+tr('CUT')+'</span>':''}</div><div class="meta">${(x.trench||x.id)===(l.trench||l.id)?tr('same trench'):tr('diverse route')}</div></div>${btn(tr('Open'),'selLink',{id:x.id},'ghost sm')}</div>`).join('')}<div class="btns">${btn(tr('Add parallel link'),'addParallel',{id:l.id},'pink sm')}</div></section>`;}
|
||
h+=`${trafficSection(l)}${metricSection(l)}<section>${btn(UI.confirm===l.id?tr('Really give it up?'):(l.own?tr('Abandon the fiber'):tr('Cancel the IRU')),'rmLink',{id:l.id},'ghost sm')}</section></div>`;
|
||
return h;
|
||
}
|
||
function offersHere(c){
|
||
const os=S.offers.filter(o=>bCities(o).includes(c));if(!os.length)return '';
|
||
return `<section><h3>${tr('Offers here')}</h3>${os.map(o=>`<div class="row"><div class="grow"><div class="nm">${esc(o.name)}</div><div class="meta">${esc(BIZ_T[o.type].l)}${o.city2?` ${CITY[o.city].name} ⇄ ${CITY[o.city2].name}`:''} · ${bTerms(o)} · ${tr('{n}d left',{n:o.exp-S.day})}</div>${R.reach<0.99&&!BIZ_T[o.type].l2?`<div class="why">${tr('They need the full internet. Your reach is {pct}.',{pct:pct(R.reach)})}</div>`:''}${o.type==='scrub'&&!S.scrubAt?`<div class="why">${tr('Needs your own scrubbing center (Infra tab).')}</div>`:''}${reqList(o)}${bHas(o)?'':`<div class="why">${tr('Needs a POP in {cities} too.',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}</div>`}</div>${bHas(o)?btn(tr('Accept'),'accept',{id:o.id},'green sm'):''}${btn(tr('No'),'decline',{id:o.id},'ghost sm')}</div>`).join('')}</section>`;
|
||
}
|
||
function linkPanel(id){
|
||
const l=S.links.find(x=>x.id===id);if(!l){UI.sel=null;return '';}
|
||
if(l.kind==='vxc')return vxcPanel(l);
|
||
if(l.kind==='df')return dfPanel(l);
|
||
const load=R.load[l.id]||0,cap=LT[l.tier].g,u=load/cap,cut=l.cut>S.day,trk=l.trench||l.id,inc=S.inc.find(i=>(LINKCUT_TR.includes(i.type)&&i.ref===trk)||((i.type==='fatwave'||i.type==='label'||i.type==='mtu')&&i.ref===l.id)),sib=pairLinks(l.a,l.b).filter(x=>x!==l&&x.kind!=='vxc'),mates=sib.filter(x=>(x.trench||x.id)===trk);
|
||
let h=`<div class="ph"><div><div class="eyebrow">${l.cable?esc(CAB[l.cable].name):l.sub?tr('Subsea cable'):tr('Terrestrial fiber')} · ${l.km.toLocaleString()} km</div><h2>${CITY[l.a].name} ⇄ ${CITY[l.b].name}</h2></div><button class="x" data-act="closePanel" aria-label="${tr('Close')}">×</button></div><div class="scroll">`;
|
||
if(cut)h+=`<section><h3 style="color:var(--bad)">${tr('Cut!')}</h3><p class="lead">${inc?esc(inc.msg):''} ${tr('Back in {n} days.',{n:l.cut-S.day})}</p>${inc&&inc.cost?btn(`${esc(inc.fix||tr('Rush repair'))} ${fmt$(inc.cost)}`,'fixInc',{id:inc.id},'red',S.cash<inc.cost):''}</section>`;
|
||
h+=`<section><h3>${tr('Capacity')}</h3><div class="kv"><span>${tr('{name} wave',{name:LT[l.tier].n})}</span><b>${fmtG(load)} / ${fmtG(cap)}</b></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div>
|
||
<div class="kv"><span>${tr('Latency')}</span><b>${tr('{ms} ms one-way',{ms:linkLat(l).toFixed(1)})}</b></div>${l.cable?`<div class="kv"><span>${tr('Cable system')}</span><b>${esc(CAB[l.cable].name)}</b></div>`:''}
|
||
<div class="kv"><span>${tr('Wave lease')}</span><b>${tr('{price}/mo',{price:fmt$(l.mo)})}</b></div>${u>=0.9?`<p class="why">${tr('Congested. Upgrade it or add a parallel path.')}</p>`:''}
|
||
<div class="btns">${LT.map((T,i)=>{const d=Math.round(waveMo(l.km,l.sub,i)*(l.mult||1)),sw=subWaveWhy(i,l.km,l.sub),ok=waveOk(l.a,l.b,i);return i>l.tier&&waveShown(i)?btn(`${T.n} <small>${sw?tr('too far for this cable'):ok?tr('{price}/mo',{price:fmt$(d)}):tr('needs {what}',{what:esc(waveNeed(i))})}</small>`,'upLink',{id:l.id,tier:i},'sm',S.cash<d||!ok||!!sw):'';}).join('')}${l.sub&&subMaxTier(l.km)<LT.length-1?`<p class="note">${tr('{km} km of cable carries at most {g} per carrier.',{km:Math.round(l.km).toLocaleString(),g:fmtCap(subCarrier(l.km))})}${l.tier>subMaxTier(l.km)?' '+tr('Your wave was sold before the cable owner re-engineered it, so it keeps running.'):''}</p>`:''}</div></section>
|
||
<section><h3>${tr('Redundancy')}</h3><p class="lead">${mates.length?trn('Shares a trench with {n} other link. One cut takes them all down.','Shares a trench with {n} other links. One cut takes them all down.',mates.length):sib.length?tr('Runs on its own route. A cut here leaves the other links up.'):tr('This is the only link between these cities. Add a parallel one, or a path through another city.')}</p>
|
||
${sib.map(x=>`<div class="row"><div class="grow"><div class="nm">${tr('{name} parallel link',{name:capName(x)})} ${x.cut>S.day?'<span class="tag restrictive">'+tr('CUT')+'</span>':''}</div><div class="meta">${(x.trench||x.id)===trk?tr('same trench'):tr('diverse route')}</div></div>${btn(tr('Open'),'selLink',{id:x.id},'ghost sm')}</div>`).join('')}
|
||
<div class="btns">${btn(tr('Add parallel link'),'addParallel',{id:l.id},'pink sm')}</div></section>
|
||
${trafficSection(l)}${metricSection(l)}
|
||
<section>${btn(UI.confirm===l.id?tr('Really decommission?'):tr('Decommission link'),'rmLink',{id:l.id},'ghost sm')}</section></div>`;
|
||
return h;
|
||
}
|
||
const EGC={c:[tr('Caches'),'#16A866'],p:[tr('PNIs'),'#7B61FF'],ix:[tr('IX peering'),'#FFD23F'],t:[tr('Transit'),'#FF8A3D'],l2:[tr('L2 circuits'),'#2F8CFF']};
|
||
function svgChart(rows,stackKeys,lines,fmtY){
|
||
const W=600,H=180,L=50,B=20,T=8,Rr=8;if(rows.length<2)return `<p class="empty">${tr('Collecting data. Check back in a few days.')}</p>`;
|
||
let ymax=1;for(const r of rows){let s=0;for(const k of stackKeys)s+=r[k]||0;ymax=Math.max(ymax,s);for(const ln of lines)ymax=Math.max(ymax,r[ln.k]||0);}ymax*=1.1;
|
||
const x=i=>L+(W-L-Rr)*i/(rows.length-1),y=v=>T+(H-T-B)*(1-v/ymax);let g='';
|
||
for(let j=0;j<=3;j++){const v=ymax*j/3,yy=y(v);g+=`<line x1="${L}" x2="${W-Rr}" y1="${yy}" y2="${yy}" stroke="#D5DEEC" stroke-width="1"/><text x="${L-6}" y="${yy+3}" text-anchor="end" font-size="10" fill="#55608A" font-weight="700">${fmtY(v)}</text>`;}
|
||
const base=rows.map(()=>0);
|
||
for(const k of stackKeys){const top=rows.map((r,i)=>base[i]+(r[k]||0));let d=`M${x(0)},${y(top[0])}`;for(let i=1;i<rows.length;i++)d+=`L${x(i)},${y(top[i])}`;for(let i=rows.length-1;i>=0;i--)d+=`L${x(i)},${y(base[i])}`;g+=`<path d="${d}Z" fill="${EGC[k][1]}" fill-opacity=".85" stroke="#1E2640" stroke-width=".8"/>`;top.forEach((v,i)=>base[i]=v);}
|
||
for(const ln of lines){let d='';rows.forEach((r,i)=>{d+=(i?'L':'M')+x(i)+','+y(r[ln.k]||0);});g+=`<path d="${d}" fill="none" stroke="${ln.col}" stroke-width="2.5" ${ln.dash?'stroke-dasharray="5 4"':''} stroke-linejoin="round"/>`;const last=rows[rows.length-1][ln.k]||0;g+=`<circle cx="${x(rows.length-1)}" cy="${y(last)}" r="3.5" fill="${ln.col}" stroke="#1E2640" stroke-width="1.5"/>`;}
|
||
g+=`<text x="${L}" y="${H-5}" font-size="10" fill="#55608A" font-weight="700">${dateStr(rows[0].d)}</text><text x="${W-Rr}" y="${H-5}" text-anchor="end" font-size="10" fill="#55608A" font-weight="700">${dateStr(rows[rows.length-1].d)}</text>`;
|
||
return `<svg class="chart" viewBox="0 0 ${W} ${H}" role="img">${g}</svg>`;}
|
||
// For a network you currently reach over transit: the cheapest way to move it to peering.
|
||
function offTransitHint(id,city){const n=NET[id];if(n.type==='t1')return tr('Tier 1: only a PNI, and only once you are big enough for the Tier 1 club');
|
||
const ixc=Object.keys(S.pops).flatMap(ixIdsIn).filter(x=>ixMembers(x).includes(id)),here=city&&ixIdsIn(city).find(x=>ixMembers(x).includes(id))||null,pick1=here||ixc.find(x=>S.ixp[x]!==undefined)||ixc[0];
|
||
if(n.pol==='open')return pick1?(here?tr('Open peer: join the route server at {ix}',{ix:ixName(pick1)}):tr('Open peer: join the route server at {ix} ({city})',{ix:ixName(pick1),city:CITY[ixCity(pick1)].name})):tr('Open peer, but not on any IX where you have a POP');
|
||
if(n.pol==='paid')return paidFree(n)?tr('Peers with you for free over a PNI. You got too big to charge.'):n.freeLv?tr('Paid peering only: a PNI costs {price}/mo. Free from customer level {n}.',{price:fmt$(n.paidFee),n:n.freeLv}):tr('Paid peering only: a PNI costs {price}/mo',{price:fmt$(n.paidFee)});
|
||
const pniC=Object.keys(S.pops).filter(c=>n.pops.includes(c));const ixOk=pick1?peerOk(id,'ix',pick1):null,pOk=pniC.length?peerOk(id,'pni',pniC.includes(city)?city:pniC[0]):null;
|
||
if(pOk&&pOk.ok)return tr('Ready for a PNI in {city}',{city:CITY[pniC.includes(city)?city:pniC[0]].name});
|
||
if(ixOk&&ixOk.ok)return tr('Will peer at {ix}: request a session',{ix:ixName(pick1)});
|
||
if(ixOk)return `${ixName(pick1)}: ${ixOk.why}`;
|
||
return pniC.length?tr('PNI in {city}: {why}',{city:CITY[pniC[0]].name,why:pOk.why}):tr('Not present in any of your cities yet');}
|
||
function transitTop(ids,k=5){const m={};for(const id of ids)for(const [n,v] of Object.entries(R.tNet[id]||{}))m[n]=(m[n]||0)+v;return Object.entries(m).filter(([,v])=>v>0.01).sort((a,b)=>b[1]-a[1]).slice(0,k);}
|
||
/* ---------- scenario and level progress (#34) ---------- */
|
||
const pSrv=g=>({l:tr('Traffic served'),v:R.served,max:g,txt:`${fmtG(R.served)} / ${fmtG(g)}`});
|
||
const pReach=()=>({l:tr('Reach'),v:R.reach,max:0.99,txt:`${pct(R.reach)} / 99%`});
|
||
const pChk=(l,ok)=>({l,v:ok?1:0,max:1,txt:ok?'✓':'—'});
|
||
const SCN_PROG={stg:()=>[pSrv(200)],redsea:()=>[pChk(tr('A path from Marseille to Singapore'),pathExists('mrs','sin')),pSrv(300)],spat:()=>[pReach(),pSrv(150)],
|
||
carnaval:()=>[pChk(tr('Carnaval delivered in full'),(S.stats.evFull||0)>=1)],darien:()=>[...['bog','lim','scl','sao'].map(c=>pChk(tr('POP in {city}',{city:CITY[c].name}),!!S.pops[c])),pSrv(150)],
|
||
gangnam:()=>[pReach(),pSrv(200)],
|
||
flood:()=>{const ok=S.stats.ddosOk||0,big=S.stats.ddosOkBig||0,a=S.ev.ddos&&S.ev.ddos.until>S.day?S.ev.ddos:null;
|
||
return [{l:tr('Floods held'),v:ok,max:20,txt:`${ok} / 20`},{l:tr('Terabit floods held'),v:big,max:5,txt:`${big} / 5`},{l:tr('Floods that got through'),v:0,max:0,txt:String(S.stats.ddosLost||0)}].concat(a?[{l:tr('Under attack now'),v:0,max:0,txt:`${fmtG(a.gbps)} · ${CITY[a.city].name} · ${pct(a.worst===undefined?1:a.worst)}`}]:[]);},baltic:()=>[{l:tr('Days in a row with 99.5% served'),v:S.stats.clean||0,max:90,txt:tr('{n} of {m}',{n:S.stats.clean||0,m:90})}]};
|
||
function scnProg(){const sc=S&&S.scn;if(!sc)return null;
|
||
if(sc.id==='weekly')return {goal:tr('Serve as much traffic as you can in one year.'),items:[{l:tr('Your score: peak traffic'),v:0,max:0,txt:fmtG(S.stats.peak||0)}],f:Math.min(1,S.day/sc.days)};
|
||
const def=SCN.find(x=>x.id===sc.id),fn=SCN_PROG[sc.id];if(!def)return null;let items=[];try{items=fn?fn():[];}catch(e){items=[];}
|
||
const meas=items.filter(x=>x.max),f=sc.done?1:meas.length?meas.reduce((a,x)=>a+Math.min(1,x.v/x.max),0)/meas.length:0;return {goal:def.goal,items,f};}
|
||
const pRow=x=>`<div class="kv"><span>${esc(x.l)}</span><b>${esc(x.txt)}</b></div>${x.max?`<div class="bar ${x.v>=x.max?'':'warn'}"><i style="width:${Math.min(100,x.max?x.v/x.max*100:0)}%"></i></div>`:''}`;
|
||
function scnCard(){const sc=S.scn,P=scnProg();if(!sc||!P)return '';const left=Math.max(0,sc.days-S.day);
|
||
const st=sc.done?`<b style="color:var(--eye)">${tr('Done in {d} days!',{d:sc.done})}</b>`:sc.failed?`<b style="color:var(--bad)">${tr("Time's up")}</b>`:tr('{n} days left',{n:left});
|
||
return `<div class="pcard"><div class="eyebrow">${tr('Scenario')} · ${Math.round(P.f*100)}%</div><div class="pt">${esc(sc.name)}</div><div class="meta">🎯 ${esc(P.goal)}</div>${P.items.map(pRow).join('')}<div class="kv"><span>${tr('Time')}</span><b>${st}</b></div><div class="bar ${!sc.done&&left<sc.days*0.2?'bad':''}"><i style="width:${Math.min(100,S.day/sc.days*100)}%"></i></div></div>`;}
|
||
function lvlItems(){const lv=S.lvl||1,pk=S.stats.peak||0,pops=Object.keys(S.pops).length,G=(l,v,max,txt)=>({l,v,max,txt}),q=LV_REQ[lv];if(!q)return [];
|
||
const out=[G(tr('Peak traffic'),pk,q.pk,`${fmtG(pk)} / ${fmtG(q.pk)}`),G(tr('POPs'),pops,q.pops,`${pops} / ${q.pops}`)],rg=lvReg(lv);if(rg)out.push(G(tr('Continents'),regionsCount(),rg,`${regionsCount()} / ${rg}`));return out;}
|
||
// Lost Tier 1 status explains itself where you look for it, not only in a toast you may have missed (#73).
|
||
const t1Note=()=>S.won&&!isTier1()?`<p class="why">${tr('Not Tier 1 right now: {why}.',{why:esc(t1Why())})}</p>`:'';
|
||
function lvlCard(){const lv=S.lvl||1,nx=LEVELS[lv];
|
||
return `<div class="pcard lv"><div class="eyebrow">${tr('Customer level {lv} of {max}',{lv,max:LEVELS.length})}</div><div class="pt">${esc(LEVELS[lv-1].n)}</div><div class="meta"><i>${esc(LEVELS[lv-1].q)}</i></div>${t1Note()}${nx?`<div class="meta">${tr('Next: {name} unlocks {what}',{name:esc(nx.n),what:esc(lc1(nx.unlock))})}</div>${lvlItems().map(pRow).join('')}`:`<div class="meta">${tr('Every customer type is unlocked. Go get those terabits.')}</div>`}</div>`;}
|
||
/* ---------- customers overview (#13, #14, #15) ---------- */
|
||
const bizMo=b=>{const T=BIZ_T[b.type];return T.event?0:T.fiber?b.rate:b.bw*b.rate;};
|
||
// Why a customer is unhappy, in the same terms the daily mood update uses.
|
||
function bizWhy(b){const T=BIZ_T[b.type],out=[];if(T.event&&!eventLive(b))return out;
|
||
const sf=bizSf(b);if(sf<0.95)out.push(T.fiber?tr('their fiber is down'):tr('getting only {p} of the bandwidth they pay for',{p:pct(sf)}));
|
||
if(!(T.l2||T.fiber)&&R.reach<=0.99)out.push(tr('you cannot reach the whole internet ({p})',{p:pct(R.reach)}));
|
||
if(b.type==='scrub'&&!S.scrubAt)out.push(tr('needs a scrubbing center'));
|
||
for(const k of b.reqs||[])if(REQS[k]&&!REQS[k].ok(b))out.push(typeof REQS[k].l==='function'?REQS[k].l(b):REQS[k].l);
|
||
return out;}
|
||
const moodCls=m=>m<30?'bad':m<60?'warn':'';
|
||
const custStats=()=>{const bz=S.biz.filter(b=>!BIZ_T[b.type].event),mo=bz.reduce((a,b)=>a+bizMo(b),0);
|
||
return {n:bz.length,unhappy:bz.filter(b=>b.mood<60).length,furious:bz.filter(b=>b.mood<30).length,avg:bz.length?(mo>0?bz.reduce((a,b)=>a+b.mood*bizMo(b),0)/mo:bz.reduce((a,b)=>a+b.mood,0)/bz.length):100,risk:bz.filter(b=>b.mood<60).reduce((a,b)=>a+bizMo(b),0)};};
|
||
function custSection(){const F=UI.kf||{};let h=`<div class="panel2" id="custSec" style="margin-top:12px"><h3>${tr('Customers')}</h3>`;
|
||
if(!S.biz.length)return h+`<p class="empty">${tr('No customers yet. Offers show up in the Deals tab.')}</p></div>`;
|
||
const st=custStats();
|
||
h+=`<p class="note" style="margin-top:0">${tr('Everyone who pays you, happiest last. Below 60% they start to grumble, below 30% they are furious, and at 0% they cancel.')}</p>`;
|
||
h+=`<div class="dgrid" style="margin:0 0 8px"><div class="tile"><div class="lbl">${tr('Happiness')}</div><div class="val" style="color:${st.avg<60?'var(--bad)':'inherit'}">${Math.round(st.avg)}%</div><div class="sub">${tr('weighted by what they pay')}</div></div><div class="tile"><div class="lbl">${tr('Unhappy')}</div><div class="val" style="color:${st.unhappy?'var(--bad)':'inherit'}">${st.unhappy}</div><div class="sub">${trn('{n} furious','{n} furious',st.furious)}</div></div><div class="tile"><div class="lbl">${tr('At risk')}</div><div class="val">${tr('{price}/mo',{price:fmt$(st.risk)})}</div><div class="sub">${tr('from unhappy customers')}</div></div></div>`;
|
||
const cities=[...new Set(S.biz.map(b=>b.city))].sort((a,b)=>CITY[a].name.localeCompare(CITY[b].name));
|
||
h+=`<div class="trsel" style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:6px"><div class="seg">${btn(tr('All ({n})',{n:S.biz.length}),'custF',{v:''},!F.f?'pink sm':'ghost sm')}${btn(tr('Unhappy ({n})',{n:S.biz.filter(b=>b.mood<60).length}),'custF',{v:'sad'},F.f==='sad'?'pink sm':'ghost sm')}</div><label>${tr('City')} <select data-chg="custCity"><option value="">${tr('All cities')}</option>${cities.map(c=>`<option value="${c}"${F.city===c?' selected':''}>${esc(CITY[c].name)}</option>`).join('')}</select></label></div>`;
|
||
const rows=S.biz.filter(b=>(!F.f||b.mood<60)&&(!F.city||b.city===F.city||b.city2===F.city||(b.sites||[]).includes(F.city)));
|
||
const sk=UI.custSort||'mood',dir=UI.custDir||1,val=b=>sk==='name'?b.name.toLowerCase():sk==='city'?CITY[b.city].name:sk==='mo'?bizMo(b):b.mood;
|
||
rows.sort((a,b)=>{const A=val(a),B=val(b);return (A<B?-1:A>B?1:0)*dir||a.mood-b.mood;});
|
||
if(!rows.length)return h+`<p class="empty">${F.f?tr('Nobody is unhappy. Enjoy it while it lasts.'):tr('No customers here.')}</p></div>`;
|
||
const where=b=>b.sites?b.sites.map(c=>CITY[c].name).join(', '):b.city2?`${CITY[b.city].name} ⇄ ${CITY[b.city2].name}`:CITY[b.city].name;
|
||
const trend=b=>b.pm===undefined||Math.abs(b.mood-b.pm)<0.05?'':b.mood>b.pm?' <span style="color:var(--eye)">▲</span>':' <span style="color:var(--bad)">▼</span>';
|
||
const sorts=[['mood',tr('Happiness')],['mo',tr('Per month')],['name',tr('Name')],['city',tr('Where')]];
|
||
h+=`<div class="seg" style="margin-bottom:4px">${sorts.map(([k,l])=>btn(l+(sk===k?(dir>0?' ▲':' ▼'):''),'custSort',{k},sk===k?'pink sm':'ghost sm')).join('')}</div>`;
|
||
h+=rows.map(b=>{const why=bizWhy(b),grace=S.day-(b.since||0)<15;return `<div class="row"><div class="grow"><div class="nm">${esc(b.name)} <span class="meta">${esc(BIZ_T[b.type].l)}</span></div><div class="meta">${esc(where(b))} · ${BIZ_T[b.type].event?esc(bTerms(b)):tr('{price}/mo',{price:fmt$(bizMo(b))})}${grace?` · ${tr('provisioning, {n}d grace',{n:15-(S.day-(b.since||0))})}`:''}</div>${why.length?`<div class="why">${why.map(esc).join(' · ')}</div>`:''}<div class="bar ${moodCls(b.mood)}"><i style="width:${b.mood}%"></i></div><div class="meta">${tr('Happiness {p}%',{p:Math.round(b.mood)})}${trend(b)}</div></div>${btn(tr('Open'),'custGo',{id:b.id},'ghost sm')}</div>`;}).join('');
|
||
return h+`</div>`;}
|
||
/* ---------- connections overview (#31, #33, #38) ----------
|
||
Every transit port, PNI, IX port, cache and fabric port in one list, filterable by type, city and
|
||
network, with a jump to the POP that holds it. The Networks tab shows the same per network. */
|
||
const CONN_K={t:N_('Transit'),p:'PNI',ix:'IX',c:N_('Cache'),nni:'NNI'},CONN_ORD=['t','p','ix','c','nni'],CONN_COL={t:'#FF8A3D',p:'#7B61FF',ix:'#2DB7F5',c:'#16A866',nni:'#1E2640'};
|
||
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),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,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} <small>{cost} + {mo}/mo</small>',a):tr('Upgrade {port} <small>{cost} + {mo}/mo</small>',a),'buyTransit',{city:t.city,net:t.net,tier:i},'sm',S.cash<PORT[i].setup*n||!portOk(t.city,i));}
|
||
if(n<LAG_MAX)h+=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(t.city,t.tier));}
|
||
else if(r.k==='p'){const p=S.pni.find(x=>x.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} <small>{cost}</small>',a):tr('Upgrade {port} <small>{cost}</small>',a),'pni',{city:p.city,net:p.net,tier:i},'sm',!portOk(p.city,i)||S.cash<c);}
|
||
if(n<LAG_MAX)h+=btn(tr('+ LAG member <small>{cost} + {mo}/mo</small>',{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} <small>{price}</small>',{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<LAG_MAX)h+=btn(tr('+ LAG member <small>{price}</small>',{price:portMo(ixPortMo(c,S.ixp[c]))}),'lagIx',{city:c,d:1},'sm',S.cash<ixPortMo(c,S.ixp[c]));}
|
||
else if(r.k==='c')h+=btn(tr('+ box'),'cache',{city:r.city,net:r.net},'sm');
|
||
else if(r.k==='nni'){const [city,prov]=r.id.split('|'),pt=nniPort(city,prov);if(pt&&pt.tier<NNI.length-1)h+=btn(tr('Upgrade {port} <small>{price}/mo</small>',{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=`<div class="panel2" id="connSec" style="margin-top:12px"><h3>${tr('Connections')}</h3><p class="note" style="margin-top:0">${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.')}</p>`;
|
||
if(!all.length)return h+`<p class="empty">${tr('No connections yet. Buy transit or join an exchange from a POP.')}</p></div>`;
|
||
const cnt=k=>all.filter(r=>r.k===k&&connMatch(r,{...F,k:null})).length;
|
||
h+=`<div class="seg" style="margin-bottom:6px">${btn(tr('All ({n})',{n:all.filter(r=>connMatch(r,{...F,k:null})).length}),'connF',{f:'k',v:''},!F.k?'pink sm':'ghost sm')}${CONN_ORD.filter(k=>all.some(r=>r.k===k)).map(k=>btn(`${tr(CONN_K[k])} (${cnt(k)})`,'connF',{f:'k',v:k},F.k===k?'pink sm':'ghost sm')).join('')}</div>`;
|
||
const cities=[...new Set(all.map(r=>r.city))].sort((a,b)=>CITY[a].name.localeCompare(CITY[b].name));
|
||
const nets=[...new Set(all.flatMap(r=>r.net?[r.net]:(r.nets||[])))].filter(id=>NET[id]&&!NET[id].tail).sort((a,b)=>NET[a].name.localeCompare(NET[b].name));
|
||
h+=`<div class="trsel" style="display:flex;gap:8px;flex-wrap:wrap;margin-bottom:6px"><label>${tr('City')} <select data-chg="connCity"><option value="">${tr('All cities')}</option>${cities.map(c=>`<option value="${c}"${F.city===c?' selected':''}>${esc(CITY[c].name)}</option>`).join('')}</select></label><label>${tr('Network')} <select data-chg="connNet"><option value="">${tr('All networks')}</option>${nets.map(id=>`<option value="${id}"${F.net===id?' selected':''}>${esc(NET[id].name)}</option>`).join('')}</select></label>${F.k||F.city||F.net?btn(tr('Clear filters'),'connF',{f:'all',v:''},'ghost sm'):''}</div>`;
|
||
const rows=all.filter(r=>connMatch(r,F));
|
||
const sk=UI.connSort||'k',dir=UI.connDir||1,val=r=>sk==='city'?CITY[r.city].name:sk==='name'?r.name.toLowerCase():sk==='use'?(r.cap?r.use/r.cap:0):sk==='mo'?r.mo:CONN_ORD.indexOf(r.k);
|
||
rows.sort((a,b)=>{const A=val(a),B=val(b);return (A<B?-1:A>B?1:0)*dir||CONN_ORD.indexOf(a.k)-CONN_ORD.indexOf(b.k)||CITY[a.city].name.localeCompare(CITY[b.city].name)||a.name.localeCompare(b.name);});
|
||
const tc=rows.reduce((a,r)=>a+r.cap,0),tu=rows.reduce((a,r)=>a+r.use,0),tm=rows.reduce((a,r)=>a+r.mo,0);
|
||
if(isPhone()){const st=(r)=>r.down?` <span class="tag restrictive">${tr('DOWN')}</span>`:r.low?` <span class="tag st">${tr('backup')}</span>`:'';
|
||
h+=`<div class="seg" style="margin-bottom:4px">${[['k',tr('Type')],['city',tr('Where')],['use',tr('In use')],['mo',tr('Per month')]].map(([k,l])=>btn(l+(sk===k?(dir>0?' ▲':' ▼'):''),'connSort',{k},sk===k?'pink sm':'ghost sm')).join('')}</div>`;
|
||
h+=rows.map(r=>{const u=r.cap?r.use/r.cap:0,N=r.net&&NET[r.net];return `<div class="row"${r.down?' style="opacity:.55"':''}>${N?logo(N):`<span class="logo" style="--c:${CONN_COL[r.k]}">${r.k==='nni'?'NNI':'IX'}</span>`}<div class="grow"><div class="nm">${esc(r.name)} <span class="tag" style="background:${CONN_COL[r.k]}">${tr(CONN_K[r.k])}</span>${st(r)}</div><div class="meta">${esc(CITY[r.city].name)} · ${esc(r.port)} · ${tr('{price}/mo',{price:fmt$(r.mo)})}${r.note?' · '+esc(r.note):''}</div><div class="kv"><span>${tr('In use')}</span><b>${fmtG(r.use)} / ${fmtCap(Math.round(r.cap))}</b></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div>${r.mine?'':`<div class="btns">${connUp(r)}${connX(r)}</div>`}</div>${btn(tr('Open'),'goConn',{city:r.city,k:r.k},'ghost sm')}</div>`;}).join('');
|
||
return h+`<div class="kv" style="margin-top:6px"><span><b>${trn('{n} connection','{n} connections',rows.length)}</b></span><b>${fmtG(tu)} / ${fmtCap(Math.round(tc))} · ${tr('{price}/mo',{price:fmt$(tm)})}</b></div></div>`;}
|
||
const th=(k,l,c)=>`<th class="${c||''}">${k?`<button class="thb" data-act="connSort" data-args="${esc(JSON.stringify({k}))}">${l}${sk===k?(dir>0?' ▲':' ▼'):''}</button>`:l}</th>`;
|
||
h+=`<div class="tscroll"><table class="tbl"><thead><tr>${th('k',tr('Type'))}${th('city',tr('Where'))}${th('name',tr('With'))}${th('',tr('Port'))}${th('use',tr('In use'),'r')}${th('mo',tr('Per month'),'r')}<th></th></tr></thead><tbody>`;
|
||
h+=rows.map(r=>{const u=r.cap?r.use/r.cap:0,N=r.net&&NET[r.net];return `<tr${r.down?' style="opacity:.55"':''}><td><span class="tag" style="background:${CONN_COL[r.k]}">${tr(CONN_K[r.k])}</span></td><td>${esc(CITY[r.city].name)}</td><td><span style="display:inline-flex;align-items:center;gap:6px">${N?logo(N):''}<span><b>${esc(r.name)}</b>${r.note?`<br><span class="meta">${esc(r.note)}</span>`:''}</span></span></td><td>${esc(r.port)}${r.down?` <span class="tag restrictive">${tr('DOWN')}</span>`:r.low?` <span class="tag st">${tr('backup')}</span>`:''}</td><td class="r">${fmtG(r.use)} / ${fmtCap(Math.round(r.cap))}<div class="bar ${barCls(u)}" style="margin-top:3px"><i style="width:${Math.min(100,u*100)}%"></i></div></td><td class="r">${fmt$(r.mo)}</td><td><div style="display:flex;flex-wrap:wrap;gap:6px;min-width:220px">${btn(tr('Open'),'goConn',{city:r.city,k:r.k},'ghost sm')}${connUp(r)}${connX(r)}</div></td></tr>`;}).join('');
|
||
h+=`</tbody><tfoot><tr><td colspan="4"><b>${trn('{n} connection','{n} connections',rows.length)}</b></td><td class="r"><b>${fmtG(tu)} / ${fmtCap(Math.round(tc))}</b></td><td class="r"><b>${fmt$(tm)}</b></td><td></td></tr></tfoot></table></div></div>`;
|
||
return h;}
|
||
// Where you connect to one network, as buttons that jump to the POP (Networks tab).
|
||
function netWhere(n){const ch=[];
|
||
for(const t of S.transit)if(t.net===n.id)ch.push([tr('Transit'),t.city,'t']);
|
||
for(const x of S.pni)if(x.net===n.id)ch.push(['PNI',x.city,'p']);
|
||
for(const c in S.ixp)if(ixSessions(c).has(n.id))ch.push([ixName(c),ixCity(c),'ix']);
|
||
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 `<div class="btns">${ch.slice(0,MAX).map(([l,c,k])=>btn(`${esc(l)} <small>${esc(CITY[c].name)}</small>`,'goConn',{city:c,k},'ghost sm')).join('')}${ch.length>MAX?btn(tr('+{n} more',{n:ch.length-MAX}),'connFor',{net:n.id},'ghost sm'):''}</div>`;}
|
||
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/g<b.c/b.g))b={g,c};}
|
||
if(b){const n=Math.ceil(cap/b.g);return {n,r,up:Math.round(n*b.c*(1+REGEN_CH*r))+r*REGEN_COST,mo:r*REGEN_MO};}}return null;}
|
||
const leaseCap=ls=>ls.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};};
|
||
// Lighting leased capacity on a fiber you already have (#72 review): needs free channels, and optics cost money.
|
||
function litOn(L,cap){const free=chMax(L)-(L.ch||[]).length-soldSlots(L);let b=null;
|
||
for(const o in OPT){const O=OPT[o];if(O.lvl>lvl()||(O.sys==='roadm'&&!isRdm(L.sys))||[L.a,L.b].some(c=>S.pops[c]&&RG[S.pops[c].rgen||0].cls<O.rg))continue;const g=optG(o,L),c=chCost(L,o);if(g&&(!b||c/g<b.c/b.g))b={o,g,c};}
|
||
if(!b)return {free,n:0,fits:false};const n=Math.ceil(cap/b.g);return {free,n,up:n*b.c,fits:n<=free};}
|
||
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&&l.ready<=S.day)};if(x.own){x.fit=litOn(x.own,cap);if(x.fit.fits)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.fit=litOn(x.iru,leaseCap(ws));if(x.fit.fits)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 `<div class="meta">${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)} <b style="color:${o.save>0?'var(--eye)':'var(--bad)'}">${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.')}</b></div>`;};
|
||
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 `<div class="panel2" style="margin-top:12px"><h3>${tr('Leased lines')}</h3><p class="note" style="margin-top:0">${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.')}</p>
|
||
${xs.length?`<div class="kv"><span>${tr('You pay for leases')}</span><b>${tr('{price}/mo',{price:fmt$(tot)})}</b></div>`+xs.map(x=>`<div class="row"><div class="grow"><div class="nm">${CITY[x.a].name} ⇄ ${CITY[x.b].name} <span class="tag st">${x.sub?tr('subsea'):tr('land')}</span></div><div class="meta">${Object.entries(x.ls.reduce((m,l)=>(m[kind(l)]=(m[kind(l)]||0)+1,m),{})).map(([k,n])=>n>1?`${n} × ${k}`:k).join(', ')} · ${tr('{price}/mo',{price:fmt$(x.mo)})}</div>
|
||
${x.fit&&x.fit.fits?`<div class="meta">${x.own?tr('You already own fiber here. Light {n} more channels for {up}, then cancel the lease to save {price}/mo.',{n:x.fit.n,up:fmt$(x.fit.up),price:fmt$(x.best)}):tr('You already lease dark fiber here. Light {n} more channels for {up}, then cancel the waves to save {price}/mo.',{n:x.fit.n,up:fmt$(x.fit.up),price:fmt$(x.lit)})}</div>`:x.fit?`<div class="meta">${x.fit.n?tr('Your fiber here has room for {free} more channels, and moving these leases needs {n}. Light another fiber pair or upgrade the line system first.',{free:Math.max(0,x.fit.free),n:x.fit.n}):tr('No optic you can buy works on your fiber here yet.')}</div>`:''}${x.opts.map(o=>line(x,o)).join('')}${!x.own&&x.why?`<div class="meta">${esc(x.why)}</div>`:''}
|
||
<div class="btns">${x.own?btn(tr('Open your fiber'),'dashLink',{id:x.own.id},'pink sm'):''}${x.iru&&x.fit?btn(tr('Open your dark fiber'),'dashLink',{id:x.iru.id},x.lit!==undefined?'pink sm':'ghost 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')}</div></div></div>`).join(''):`<p class="empty">${tr('You do not lease any lines between your POPs.')}</p>`}</div>`;}
|
||
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 `<nav class="dtabs">${DTABS.map(k=>`<button class="${cur===k?'on':''}" data-act="dashTab" data-args='{"k":"${k}"}'>${L[k]}${k==='cust'&&u?`<span class="cnt red">${u}</span>`:''}</button>`).join('')}</nav>`;}
|
||
function renderDash(){checkLayer();
|
||
const H=S.hist||[],rows=H.slice(-90),last30=H.slice(-30);
|
||
const up=last30.length?last30.reduce((a,r)=>a+(r.dem?Math.min(1,r.srv/r.dem):1),0)/last30.length:1;
|
||
const net=R.revMo-R.costMo,tot=Object.values(R.egT).reduce((a,b)=>a+b,0)||1;
|
||
const tile=(l,v,sub)=>`<div class="tile"><div class="lbl">${l}</div><div class="val">${v}</div>${sub?`<div class="sub">${sub}</div>`:''}</div>`;
|
||
let h=`<div style="display:flex;align-items:center;gap:10px"><div><div class="eyebrow">AS${S.asn} · ${esc(S.name)} · ${tierLabel()}</div><h2 style="font-size:28px">${tr('NOC dashboard')}</h2></div><button class="x" data-act="dashClose" aria-label="${tr('Close')}">×</button></div>`+dashTabs();const DT=UI.dtab||'overview';if(DT==='overview')h+=`
|
||
<div class="dgrid">${tile(tr('Traffic now'),fmtG(R.served),tr('of {g} wanted',{g:fmtG(R.demand)}))}${tile(tr('Peak'),fmtG(S.stats.peak))}${tile(tr('Delivered, 30 days'),(up*100).toFixed(1)+'%',up>=0.999?tr('five nines-ish'):up>=0.99?tr('two nines and change'):tr('customers are upset'))}${tile(tr('Peering ratio'),pct(R.peerShare||0),tr('caches, PNIs and IX'))}${tile(tr('Monthly P&L'),`<span style="color:${net>=0?'var(--eye)':'var(--bad)'}">${net>=0?'+':''}${fmt$(net)}</span>`,tr('{in} in · {out} out',{in:fmt$(R.revMo),out:fmt$(R.costMo)}))}${tile(tr('Incidents'),S.stats.incidents,tr('{n} shrugged off',{n:S.stats.survived}))}</div>
|
||
<div class="dcols"><div class="panel2"><h3>${tr('Traffic by way out')}</h3>${svgChart(rows,['c','p','ix','t','l2'],[{k:'dem',col:'#1E2640',dash:true}],v=>fmtCap(Math.round(v)))}<div class="legend">${Object.keys(EGC).map(k=>`<span><i style="background:${EGC[k][1]}"></i>${EGC[k][0]} ${pct((R.egT[k]||0)/tot)}</span>`).join('')}<span><i style="background:#fff;border-style:dashed"></i>${tr('Demand')}</span></div></div>
|
||
<div class="panel2"><h3>${tr('Money per month')}</h3>${svgChart(rows,[],[{k:'rev',col:'#16A866'},{k:'cost',col:'#FF4D5E'}],v=>fmt$(v))}<div class="legend"><span><i style="background:#16A866"></i>${tr('Revenue')}</span><span><i style="background:#FF4D5E"></i>${tr('Costs')}</span></div>
|
||
<h3 style="margin-top:8px">${tr('Where the money goes')}</h3>${Object.entries(R.cost).filter(([k,v])=>v>0).sort((a,b)=>b[1]-a[1]).map(([k,v])=>`<div class="kv"><span>${{pops:tr('POPs and routers'),links:tr('Waves and fiber'),transit:tr('Transit'),ix:tr('IX ports'),pni:tr('PNIs'),caches:tr('Cache power'),nni:tr('Fabric ports'),optical:tr('Amp huts and spares'),loans:tr('Loan repayments'),revshare:tr('Investor revenue share'),extras:tr('Licenses and scrubbing')}[k]||k}</span><b>${tr('{price}/mo',{price:fmt$(v)})}</b></div>`).join('')}</div></div>`;
|
||
const tT=(R.egT.t||0)||1;
|
||
const row=(n,e,want)=>{const t=e.c+e.p+e.ix+e.t;return {n,e,t,want,cost:(R.cost.transit||0)*e.t/tT,lost:want>0.01?Math.max(0,1-t/want):0};};
|
||
const nets=NETS.filter(n=>!n.tail).map(n=>row(n,R.netEg[n.id]||{c:0,p:0,ix:0,t:0},R.demTo[n.id]||0));
|
||
{const e={c:0,p:0,ix:0,t:0};let w=0;for(const n of NETS)if(n.tail){const x=R.netEg[n.id];if(x)for(const k in e)e[k]+=x[k]||0;w+=R.demTo[n.id]||0;}nets.push(row({id:'_tail',name:tr('The long tail ({n} small networks)',{n:NETS.filter(n=>n.tail).length}),asn:'many',type:'eye',col:'#8A93B8'},e,w));}
|
||
for(let i=nets.length-1;i>=0;i--)if(!(nets[i].t>0.01||nets[i].want>0.01))nets.splice(i,1);
|
||
{const k=UI.dashSort||'traffic',dir=UI.dashDir||-1,val=x=>k==='name'?x.n.name.toLowerCase():k==='asn'?x.n.asn:k==='type'?x.n.type:k==='cost'?x.cost:k==='lost'?x.lost:x.t;nets.sort((a,b)=>{const A=val(a),B=val(b);return (A<B?-1:A>B?1:0)*dir||b.t-a.t;});}
|
||
if(DT==='cust')h+=custSection();
|
||
if(DT==='conn')h+=connSection();
|
||
if(DT==='traffic')h+=`<div class="panel2" style="margin-top:12px"><h3>${tr('Traffic by network (ASN)')}</h3><p class="note" style="margin-top:0">${tr("Where your users' traffic comes from, and how it gets to you. Transit is the only part you pay per gigabit; caches, PNIs and IX peering are free or flat-rate. Tap a column to sort.")}</p><div class="legend" style="margin:0 0 6px">${['c','p','ix','t'].map(k=>`<span><i style="background:${EGC[k][1]}"></i>${EGC[k][0]}</span>`).join('')}</div><div class="tscroll"><table class="tbl"><thead><tr>${[['name',tr('Network'),''],['asn','AS',''],['type',tr('Type'),''],['traffic',tr('Traffic'),'r'],['mix',tr('How it arrives'),''],['cost',tr('Transit cost'),'r'],['lost',tr('Lost'),'r']].map(([k,l,c])=>`<th class="${c}">${k==='mix'?l:`<button class="thb" data-act="dashSort" data-args="${esc(JSON.stringify({k}))}">${l}${UI.dashSort===k?(UI.dashDir>0?' ▲':' ▼'):''}</button>`}</th>`).join('')}</tr></thead><tbody>
|
||
${nets.map(({n,e,t,want})=>{return `<tr><td><span style="display:inline-flex;align-items:center;gap:6px">${logo(n)}<b>${esc(n.name)}</b></span></td><td>${n.asn}</td><td><span class="tag ${n.type}">${TYPE_L[n.type]}</span></td><td class="r">${fmtG(t)}</td><td><div class="mix" title="${['c','p','ix','t'].filter(k=>e[k]>0.01).map(k=>EGC[k][0]+' '+fmtG(e[k])).join(' · ')||tr('nothing yet')}">${['c','p','ix','t'].map(k=>`<i style="width:${t?e[k]/t*100:0}%;background:${EGC[k][1]}"></i>`).join('')}</div></td><td class="r">${e.t>0.01?tr('{price}/mo',{price:fmt$((R.cost.transit||0)*e.t/tT)}):'—'}</td><td class="r" style="color:${want-t>want*0.05?'var(--bad)':'inherit'}">${want>0.01?pct(Math.max(0,1-t/want)):'—'}</td></tr>`;}).join('')}</tbody></table></div></div>`;
|
||
if(DT==='traffic'){const top=transitTop(S.transit.map(t=>t.id),8);if(top.length)h+=`<div class="panel2" style="margin-top:12px"><h3>${tr('Who your transit carries')}</h3><p class="note" style="margin-top:0">${tr('The networks you pay transit to reach, biggest first, and the cheapest way to move each one to peering. This is your to-do list on the way to Tier 1.')}</p>${top.map(([id,v])=>`<div class="row">${logo(NET[id])}<div class="grow"><div class="nm">${esc(NET[id].name)} <span class="meta">AS${NET[id].asn} · ${fmtG(v)} · ${tr('about {price}/mo',{price:fmt$((R.cost.transit||0)*v/tT)})}</span></div><div class="meta">${esc(offTransitHint(id))}</div></div></div>`).join('')}</div>`;}
|
||
const ls=S.links.filter(l=>capOf(l)>0).map(l=>({l,u:(R.load[l.id]||0)/capOf(l)})).sort((a,b)=>b.u-a.u).slice(0,8);
|
||
const rs=Object.keys(S.pops).map(c=>({c,u:(R.nodeLoad[c]||0)/(R.nodeCap[c]||1)})).sort((a,b)=>b.u-a.u).slice(0,6);
|
||
if(DT==='infra')h+=`<div class="dcols" style="margin-top:12px"><div class="panel2"><h3>${tr('Busiest links')}</h3>${ls.length?ls.map(({l,u})=>`<div class="row"><div class="grow"><div class="nm">${CITY[l.a].name} ⇄ ${CITY[l.b].name} <span class="meta">${capName(l)} · ${linkLat(l).toFixed(1)} ms</span></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div><b class="num" style="min-width:42px;text-align:right">${pct(u)}</b>${btn(tr('Open'),'dashLink',{id:l.id},'ghost sm')}</div>`).join(''):'<p class="empty">'+tr('No links yet.')+'</p>'}</div>
|
||
<div class="panel2"><h3>${tr('Router load')}</h3>${rs.map(({c,u})=>`<div class="row"><div class="grow"><div class="nm">${CITY[c].name} <span class="meta">${(S.pops[c].routers||1)} × ${esc(RG[S.pops[c].rgen||0].n)}</span></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div><b class="num" style="min-width:42px;text-align:right">${pct(u)}</b></div>`).join('')}
|
||
<h3 style="margin-top:10px">${tr('Your AS')}</h3><div class="kv"><span>${tr('AS number')}</span><b>AS${S.asn}</b></div><div class="kv"><span>${tr('Prefixes')}</span><b>${Math.max(1,Math.ceil(Object.keys(S.pops).length/3))} × /22 IPv4, 1 × /32 IPv6</b></div><div class="kv"><span>${tr('BGP sessions')}</span><b>${R.sessions}</b></div><div class="kv"><span>${tr('Upstreams')}</span><b>${new Set(S.transit.map(t=>t.net)).size}</b></div><div class="kv"><span>${tr('Reach')}</span><b>${pct(R.reach)}</b></div><div class="kv"><span>${tr('Customers')}</span><b>${tr('{n} businesses',{n:S.biz.length})}</b></div></div></div>`;
|
||
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)}):'');}
|
||
function loanLine(l){const sh=l.share?' · '+tr('plus {pct} of revenue',{pct:pct(l.share)}):'',fee=loanFees(l)?' · '+tr('{price}/mo in extras',{price:fmt$(loanFees(l))}):'';
|
||
if(l.model==='transit')return tr('{pct} of your transit bill · {n} months left · the rest is due at the end',{pct:pct(l.cut||0.3),n:l.left})+sh+fee;
|
||
if(l.model==='balloon')return tr('Nothing to pay until the end · {n} months left · growing at {apr}% a year',{n:l.left,apr:(l.apr*100).toFixed(1)})+sh+fee;
|
||
return tr('{pay}/mo · {n} months left · {apr}% APR',{pay:fmt$(l.pay),n:l.left,apr:(l.apr*100).toFixed(1)})+(l.model==='storm'?' · '+tr('+2% per open incident'):l.model==='astro'?' · '+tr('rate set by the stars each month'):'')+sh+fee;}
|
||
function renderBank(){
|
||
if(!S||$('bankBox').hidden)return;const rt=rating(),net=R.revMo-R.costMo;
|
||
const terms=(o)=>{const B=BANKS[o.bank],sh=o.share&&!B.equity?`<span class="tag selective">${tr('plus {pct} of revenue until repaid',{pct:pct(o.share)})}</span>`:'';
|
||
if(o.model==='transit')return `<span class="tag st on">${tr('{pct} of your transit bill',{pct:pct(o.cut||0.3)})}</span><span class="tag st">${tr('{price} to repay',{price:fmt$(o.owe||o.amount)})}</span><span class="tag st">${tr('{n} months',{n:o.term})}</span><span class="tag selective">${tr('the rest is due at the end')}</span>${sh}`;
|
||
if(o.model==='balloon')return `<span class="tag st on">${tr('Nothing to pay until the end')}</span><span class="tag st">${tr('{apr}% APR',{apr:(o.apr*100).toFixed(1)})}</span><span class="tag st">${tr('{n} months',{n:o.term})}</span><span class="tag selective">${tr('then about {price} at once',{price:fmt$(o.amount*Math.pow(1+o.apr/12,o.term))})}</span>${sh}`;
|
||
const extra=o.model==='storm'?`<span class="tag selective">${tr('+2% per open incident')}</span>`:o.model==='astro'?`<span class="tag selective">${tr('rate set by the stars each month')}</span>`:'';
|
||
return (B.equity?`<span class="tag st on">${tr('No repayments')}</span><span class="tag st">${tr('{pct} of revenue, forever',{pct:pct(o.share)})}</span><span class="tag st">${tr('Buy-out {price}',{price:fmt$(o.amount*3)})}</span>`:`<span class="tag st on">${tr('{apr}% APR',{apr:(o.apr*100).toFixed(1)})}</span><span class="tag st">${tr('{n} months',{n:o.term})}</span><span class="tag st">${tr('{price}/mo',{price:fmt$(o.pay)})}</span>${B.crypto?'<span class="tag selective">'+tr('Paid in TubeCoin')+'</span>':''}`)+extra+sh;};
|
||
const covList=(l)=>l.covs.length?l.covs.map(c=>{const ok=COVS[c].ok(l);return `<div class="meta"><b style="color:${ok?'var(--eye)':'var(--bad)'}">${ok?'✓':'✗'}</b> ${esc(covLabel(c))}</div>`;}).join(''):'<div class="meta">'+tr('No conditions. That is the scary part.')+'</div>';
|
||
let h=`<div style="display:flex;align-items:center;gap:12px"><div><div class="eyebrow">AS${S.asn} · ${esc(S.name)}</div><h2 style="font-size:28px">${tr('Bank')}</h2></div><button class="x" data-act="bankClose" aria-label="${tr('Close')}">×</button></div>
|
||
<div class="dgrid"><div class="tile"><div class="lbl">${tr('Cash')}</div><div class="val" style="color:${S.cash<0?'var(--bad)':'inherit'}">${fmt$(S.cash)}</div><div class="sub">${S.cash<0?tr('Bankrupt at −$100k'):tr('in the vault')}</div></div>
|
||
<div class="tile"><div class="lbl">${tr('Monthly P&L')}</div><div class="val" style="color:${net>=0?'var(--eye)':'var(--bad)'}">${net>=0?'+':''}${fmt$(net)}</div><div class="sub">${tr('after loan payments')}</div></div>
|
||
<div class="tile"><div class="lbl">${tr('Credit rating')}</div><div class="val">${rt}</div><div class="sub">${rIdx(rt)>=5?tr('Bankers return your calls'):rIdx(rt)>=3?tr('Bankers return your emails'):tr('Bankers pretend to be out')}</div></div>
|
||
<div class="tile"><div class="lbl">${tr('Debt')}</div><div class="val">${fmt$(S.loans.reduce((a,l)=>a+(BANKS[l.bank].equity?0:l.bal),0))}</div><div class="sub">${trn('{n} loan','{n} loans',S.loans.length)}</div></div></div>`;
|
||
h+=`<h3 style="font-size:18px;margin-top:6px">${tr('Offers')}</h3>`;
|
||
if(!S.loanOffers.length)h+=`<p class="empty">${tr('No offers right now. Banks get in touch now and then, and much faster when you are in trouble. A better credit rating brings better banks.')}</p>`;
|
||
for(const o of S.loanOffers){const B=BANKS[o.bank];h+=`<div class="loan"><span class="logo" style="--c:${B.col}">${initials(B)}</span><div class="grow"><div class="nm">${tr('{bank} offers <b>{amount}</b>',{bank:esc(B.name),amount:fmt$(o.amount)})}</div><div class="meta">${esc(B.blurb)} · ${tr('offer ends in {n}d',{n:o.exp-S.day})}</div><div class="terms">${terms(o)}</div>${covList({covs:o.covs,start:S.day,base:{sub:S.links.filter(x=>x.sub).length}})}<div class="btns" style="margin-top:6px">${btn(tr('Take the money'),'takeLoan',{id:o.id},'pink')}${btn(tr('No thanks'),'declineLoan',{id:o.id},'ghost sm')}</div></div></div>`;}
|
||
h+=`<h3 style="font-size:18px;margin-top:14px">${tr('Your loans')}</h3>`;
|
||
if(!S.loans.length)h+=`<p class="empty">${tr('Debt-free. Your accountant is suspicious.')}</p>`;
|
||
for(const l of S.loans){const B=BANKS[l.bank];const cost=repayCost(l,B);
|
||
h+=`<div class="loan"><span class="logo" style="--c:${B.col}">${initials(B)}</span><div class="grow"><div class="nm">${esc(B.name)} · ${fmt$(l.amount)}</div>
|
||
${B.equity?`<div class="meta">${tr('Taking {pct} of your revenue every month.',{pct:pct(l.share)})}</div>`:`<div class="kv"><span>${tr('Still owed')}</span><b>${fmt$(l.bal)}</b></div><div class="bar me"><i style="width:${Math.min(100,(1-l.bal/l.amount)*100)}%"></i></div><div class="meta">${loanLine(l)}</div>`}
|
||
${covList(l)}${l.breach>=1?`<div class="why">${trn('Condition broken for {n} day.','Condition broken for {n} days.',l.breach)} ${l.breach<10?tr('Penalty in {n} days.',{n:10-l.breach}):tr('Penalties are running.')}</div>`:''}
|
||
<div class="btns" style="margin-top:6px">${btn(UI.confirm===l.id?tr('Really pay {price}?',{price:fmt$(cost)}):B.equity?tr('Buy them out <small>{price}</small>',{price:fmt$(cost)}):tr('Repay early <small>{price} incl. 2% fee</small>',{price:fmt$(cost)}),'repayLoan',{id:l.id},UI.confirm===l.id?'red sm':'sm',S.cash<cost)}</div></div></div>`;}
|
||
if(h!==UI._bh){UI._bh=h;$('bankCard').innerHTML=h;}
|
||
}
|
||
function renderHint(){
|
||
const hn=$('hint');if(!S||UI.hintOff||(S.tut!==undefined&&S.tut!==null)||(innerWidth<760&&(UI.sel||UI.leftOpen)&&!(UI.drag&&UI.drag.mode==='link'))){hn.hidden=true;return;}
|
||
let t='';
|
||
if(UI.drag&&UI.drag.mode==='link')t=UI.snap?tr('Release to plan a link'):tr('Drag onto another city');
|
||
else if(!S.links.length&&S.done.tr)t=tr('Tip: drag from your pink router to another city to lay fiber');
|
||
else if(!S.done.bb)t=tr('Tap your city, then Launch broadband');
|
||
hn.textContent=t;hn.hidden=!t;
|
||
}
|
||
|
||
/* ---------- toasts & modals ---------- */
|
||
function toast(html,kind='',actions=[]){
|
||
if(S){S.log=S.log||[];const tmp=document.createElement('div');tmp.innerHTML=html.replace(/<br>/g,' ');S.log.unshift({d:S.day,t:tmp.textContent,k:kind});if(S.log.length>30)S.log.length=30;}
|
||
const el=document.createElement('div');el.className='toast '+kind;el.dataset.born=performance.now();
|
||
el.innerHTML=`<div class="tx">${html}</div>${actions.map(a=>btn(a.l,a.act,a.args,'sm')).join('')}`;
|
||
const box=$('toasts');box.prepend(el);const max=innerWidth<760?2:3;while(box.children.length>max)box.lastChild.remove();
|
||
setTimeout(()=>{el.style.transition='opacity .4s';el.style.opacity=0;setTimeout(()=>el.remove(),400);},actions.length?8000:4500);
|
||
}
|
||
const markLayer=()=>{UI.layerAt=performance.now();};
|
||
// Which layers are open: when that changes (a sheet, the dashboard, the bank, a selection), taps in flight are void.
|
||
function checkLayer(){const q=id=>{const e=$(id);return e?(e.hidden?0:1):0;},sig=[q('modal'),q('dash'),q('bankBox'),UI.leftOpen?1:0,UI.left||'',UI.sel?UI.sel.type+UI.sel.id:'',UI.tab||''].join('|');if(sig!==UI._layer){UI._layer=sig;markLayer();}}
|
||
// Keyboard focus moves into the modal, so Enter or Space can't keep pressing a hidden button behind it.
|
||
function openModal(html){if($('modal').hidden)markLayer();$('modalCard').innerHTML=html;$('modal').hidden=false;const a=document.activeElement;if(a&&a!==document.body&&!a.closest('#modal')){a.blur();const m=$('modalCard');m.tabIndex=-1;m.focus({preventScroll:true});}}
|
||
function closeModal(){if(!$('modal').hidden)markLayer();$('modal').hidden=true;UI.pending=null;}
|
||
const NETWORK_NAMES=[
|
||
'Packet Pals','Shinternet','Post, Telegraph & Tubes','Peering Pressure','Best Effort Telecom',
|
||
'Mostly Online','Buffering & Sons','Lord of the Pings','The Ping Dynasty',
|
||
'LAN Before Time','Bits Please','Hopless Networks','Route of All Evil',
|
||
'TTL You Later','Fiber McFiberface','RFC 1149 Avian Carriers','Spanning Tree Huggers',
|
||
'Dial-Up & Cry','404 Telecom','Loss Leaders','Last Mile Standing',
|
||
'Have You Tried Off & On','Bogon Voyage','Default Route 66','Anycast Away',
|
||
'Hot Potato Routing','Null Route Rangers','Looking Glass Half Full','Jumbo Frame Shop',
|
||
'Route Flap Jacks','Split Horizon & Co.','Path of Least Resistance',
|
||
];
|
||
function randomNetworkName(current){
|
||
// Naming must not advance a running scenario's seeded simulation.
|
||
const names=NETWORK_NAMES.filter(n=>n!==current);
|
||
return names[Math.floor(_rand()*names.length)];
|
||
}
|
||
const HTIW='https://tkjaer.github.io/how-the-internet-works/';
|
||
// The real thing: an interactive, zoomable guide to how packets actually travel. Go read it.
|
||
const plugHtml=(big)=>`<a class="plug" href="${HTIW}" target="_blank" rel="noopener"><span class="pi" aria-hidden="true">🌍</span><span><b>How the Internet Works</b><span class="meta">${big?tr('The real thing, by Thomas Kjær Aabo: a zoomable, interactive map of how your packets actually travel, from Wi-Fi to undersea fiber, today, in 2010 and in 1995. This game makes it up as it goes. That one gets it right.'):tr('The real thing: follow a packet from Wi-Fi to undersea fiber.')}</span></span><span class="go">${tr('Explore →')}</span></a>`;
|
||
function showTitle(){
|
||
const sv=loadSave();
|
||
if(UI.nm==null)UI.nm=randomNetworkName();
|
||
const starts=[['fra',tr('Crossroads of Europe. DE-KICKS IX, cheap transit.')],['nyc',tr('Huge eyeball market. Pricey neighbours.')],['sin',tr('Asia hub. Great peering, far from home.')],['sao',tr('Big hungry market, few providers.')]];
|
||
openModal(`<div class="title-art"><svg width="74" height="74" viewBox="0 0 74 74" aria-hidden="true"><path d="M10 60V40c0-14 10-24 24-24h18" fill="none" stroke="#1E2640" stroke-width="16" stroke-linecap="round"/><path d="M10 60V40c0-14 10-24 24-24h18" fill="none" stroke="#FFD23F" stroke-width="9" stroke-linecap="round"/><circle cx="58" cy="16" r="11" fill="#FF4F9A" stroke="#1E2640" stroke-width="4"/><circle cx="21" cy="44" r="3" fill="#fff"/><circle cx="30" cy="27" r="3" fill="#fff"/></svg>
|
||
<h1>Series<br>of <span>Tubes</span></h1></div>
|
||
<p class="tagline">${tr('Build an internet. Lay fiber between cities, buy transit, peer at exchanges, sign up businesses, and keep the eyeballs happy while backhoes, sharks and route leaks do their best to stop you.')}</p>${plugHtml(false)}${isPhone()?installRow():''}
|
||
${sv?`<div class="btns" style="margin-bottom:6px">${btn(tr('Continue {name} · {date}',{name:esc(sv.name),date:dateStr(sv.day)}),'cont',{},'pink big')}</div>`:''}
|
||
<label class="f" for="nmIn">${tr('Name your network')}</label><div class="network-name"><input class="t" id="nmIn" maxlength="24" value="${esc(UI.nm)}" autocomplete="off">${btn(tr('Another one'),'randomName',{},'ghost sm')}</div>
|
||
<label class="f">${tr('Pick your home city')}</label><div class="starts">${starts.map(([c,d])=>`<button class="start ${UI.startCity===c?'on':''}" data-city="${c}" data-act="pickStart" data-args='{"city":"${c}"}'><b>${CITY[c].name}</b><span>${d}</span></button>`).join('')}</div>
|
||
<label class="f">${tr('Mode')}</label><div class="btns">${[['normal',tr('Normal')],['sandbox',tr('Sandbox')]].map(([m,l])=>`<button class="b sm modeb ${(UI.mode||'normal')===m?'pink':'ghost'}" data-m="${m}" data-act="modeSet" data-args='{"m":"${m}"}'>${l}</button>`).join('')}${btn(tr('Scenarios & weekly challenge →'),'scenarios',{},'sm')}</div>
|
||
<label class="f">${tr('Language')}</label><div class="btns">${segBtns('langSet',LANG,Object.entries(LANGS))}</div>
|
||
<div class="btns cta" style="margin-top:16px;justify-content:space-between;align-items:center">${btn(sv?tr('Start a new network'):tr('Start building'),'start',{},'big')}${btn(tr('How to play'),'help',{},'ghost')}${btn(tr('Import a save'),'importPick',{},'ghost sm')}${btn(tr('Settings'),'settings',{},'ghost sm')}</div><p class="ver">v${APP_VERSION} · <a href="https://github.com/fjaeckel/seriesoftubes" target="_blank" rel="noopener">${tr('Source on GitHub')}</a> · ${tr('Cookieless stats, no tracking')}</p>`);
|
||
$('nmIn').addEventListener('input',e=>{UI.nm=e.target.value;});
|
||
if(sv){S=migrate(sv);compute();}
|
||
}
|
||
// "What's new": shown once to returning players after an update, or on demand.
|
||
function whatsNew(returning,force){
|
||
if(IS_DEV||!RELEASE_NOTES.length)return false;let seen=null;
|
||
try{seen=localStorage.getItem('sot-seen-version');localStorage.setItem('sot-seen-version',APP_VERSION);}catch(e){}
|
||
if(!force&&(!returning||seen===APP_VERSION))return false;
|
||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('Release notes')}</div><h2 style="font-size:28px">${tr('New in Series of Tubes {v}',{v:esc(APP_VERSION)})}</h2></div><button class="x" data-act="${UI.started?'closeModal':'helpClose'}" aria-label="${tr('Close')}">×</button></div>
|
||
${notesHtml(RELEASE_NOTES,APP_VERSION)}
|
||
${returning&&S?`<p class="note">${tr('Your network {name} was saved and is waiting for you.',{name:esc(S.name)})}</p>`:''}
|
||
<div class="btns" style="margin-top:12px">${btn(UI.started?tr('Back to my network'):tr('Got it'),UI.started?'closeModal':'helpClose',{},'pink big')}${notesLong(RELEASE_NOTES)?'':`<a class="b ghost" href="https://github.com/fjaeckel/seriesoftubes/blob/main/CHANGELOG.md" target="_blank" rel="noopener">${tr('Full changelog')}</a>`}</div>`);
|
||
return true;}
|
||
/* In-app notes stay short: at most NOTE_MAX changes, each cut to its first sentence. When anything was cut, a
|
||
link leads to the full notes of this version on GitHub. The CHANGELOG and the GitHub release keep every word. */
|
||
const NOTE_MAX=5,NOTE_CH=140;
|
||
function slimNote(n){const m=String(n).match(/^(.+?[.!?])(\s|$)/);let t=m?m[1]:String(n);if(t.length>NOTE_CH)t=t.slice(0,NOTE_CH-1).replace(/\s+\S*$/,'')+'…';return t;}
|
||
const notesLong=ns=>ns.length>NOTE_MAX||ns.some(n=>slimNote(n)!==n);
|
||
function notesHtml(ns,ver){const more=Math.max(0,ns.length-NOTE_MAX);
|
||
return `<ul class="notes">${ns.slice(0,NOTE_MAX).map(n=>`<li>${esc(slimNote(n))}</li>`).join('')}${more?`<li class="meta">${trn('…and {n} more change','…and {n} more changes',more)}</li>`:''}</ul>`+
|
||
(notesLong(ns)?`<p style="margin:6px 0 0"><a class="b pink sm" href="https://github.com/fjaeckel/seriesoftubes/releases/tag/v${esc(ver)}" target="_blank" rel="noopener">${tr('Read the full notes on GitHub')}</a></p>`:'');}
|
||
function newerVer(a,b){const x=String(a).split('.').map(Number),y=String(b).split('.').map(Number);for(let i=0;i<3;i++){if((x[i]||0)>(y[i]||0))return true;if((x[i]||0)<(y[i]||0))return false;}return false;}
|
||
// While the game is open, look for a newer release now and then and offer a reload.
|
||
function checkUpdate(){
|
||
if(IS_DEV||location.protocol==='file:'||!window.fetch)return;const now=Date.now();if(now-(UI.updChecked||0)<60000)return;UI.updChecked=now;
|
||
fetch('/version.json',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(j=>{
|
||
if(!j||!j.version||!newerVer(j.version,APP_VERSION))return;if(UI.updLater&&now-UI.updLater<6*3600*1000)return;
|
||
const top=(j.notes||[])[0]||'';$('update').innerHTML=`<div class="tx"><b>${tr('Series of Tubes {v} is out!',{v:esc(j.version)})}</b>${top?`<br>${esc(top.length>120?top.slice(0,117)+'…':top)}`:''}<br><span class="meta">${tr('Your game is saved automatically.')}</span></div>${btn(tr('Reload now'),'updateNow',{},'pink sm')}${btn(tr('Later'),'updateLater',{},'ghost sm')}`;$('update').hidden=false;
|
||
}).catch(()=>{});
|
||
}
|
||
function showHelp(){
|
||
openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:28px">${tr('How the internet works here')}</h2><button class="x" data-act="helpClose" aria-label="${tr('Close')}">×</button></div>
|
||
<p class="tagline" style="margin:6px 0 4px">${tr('<b>Controls:</b> drag the map to pan, scroll or pinch to zoom, tap a city to open it. <b>Drag from your pink router to another city</b> to lay fiber. <span class="kbd">Space</span> pauses, <span class="kbd">0</span> is half speed, <span class="kbd">1</span> <span class="kbd">2</span> <span class="kbd">3</span> <span class="kbd">4</span> set speed. At 1× a day lasts 2.5 seconds.')}</p>
|
||
<dl class="gl">
|
||
<dt>${tr('Eyeballs')}</dt><dd>${tr('Home broadband users. They mostly download from CDNs and pay you per Gbps you deliver. Serve them well and they multiply.')}</dd>
|
||
<dt>POP</dt><dd>${tr('Point of presence: your router in a data center. Everything starts at a POP.')}</dd>
|
||
<dt>${tr('IP transit')}</dt><dd>${tr('You pay a bigger network per Gbps and it delivers your traffic anywhere. Easy, full reach, never free.')}</dd>
|
||
<dt>Tier 1 / Tier 2</dt><dd>${tr('Tier 1s reach the whole internet without paying anyone, because they all peer with each other. Tier 2s peer a lot but still buy some transit.')}</dd>
|
||
<dt>CDN</dt><dd>${tr('Content networks like NetChill and Goggle. Most of your traffic comes from them. Peer with them and that traffic is free.')}</dd>
|
||
<dt>${tr('IX (Internet Exchange)')}</dt><dd>${tr('A shared switch in a city. One port, many free peering sessions. The route server peers you with every open member at once.')}</dd>
|
||
<dt>PNI</dt><dd>${tr('Private network interconnect: a cable straight to one network in the same building. For big traffic.')}</dd>
|
||
<dt>${tr('Embedded cache')}</dt><dd>${tr('A CDN\'s server in your rack. Serves most of that CDN\'s traffic locally, for the price of power.')}</dd>
|
||
<dt>DE-KICKS</dt><dd>${tr('The group behind several big exchanges (Frankfurt, Madrid, Marseille, Dubai, Mumbai, New York) treats price lists as a state secret. Ports are quoted per customer and go up the bigger you look. Haggling can work, backfire or stall for a week. Prices get "harmonised" upwards once a year, add-ons appear on your invoice until you opt out, and trying to leave earns you a retention discount that ends with a fee.')}</dd><dt>${tr('Remote peering')}</dt><dd>${tr('Reach an IX over a fabric circuit without a POP there. It works, and the route server still gets you every open network, but it is discouraged: the reseller charges 1.5× for the port and oversubscribes it to 80%, latency rides the fabric, one fabric outage drops every session, and many selective networks refuse remote members outright.')}</dd><dt>${tr('Peering policy')}</dt><dd>${tr('Open peers with anyone. Selective wants to see traffic first. Restrictive (Tier 1s) only peers with giants, over PNIs. Paid means exactly that. Big selective networks also have moods: in some cities they refuse new peers for a few months, or only take PNIs, and now and then they tear down a session you already had. Try another city or a PNI, and ask again later.')}</dd>
|
||
<dt>${tr('Waves')}</dt><dd>${tr('Your fiber links are leased waves at a flat monthly rate. Longer and bigger costs more (10G → 6.4T), and subsea is 1.8× the price.')}</dd><dt>${tr('95th percentile')}</dt><dd>${tr('Transit bills sample your usage every day and charge the 95th percentile of the last 30 days, so short spikes are forgiven but long ones are not.')}</dd><dt>${tr('Routers')}</dt><dd>${tr('Each POP\'s router model caps its fastest port (100G, 400G, 800G, 1.6T) and how much it can forward. Bigger waves and ports need better routers at both ends. Better models unlock with your customer level. With one router, upgrades mean a day of downtime.')}</dd><dt>${tr('Dark fiber')}</dt><dd>${tr('Lease an IRU or build your own (slow, with delays), then buy a line system with amplifiers and light channels with 400ZR+, 800ZR+ or 1.6T transponders. Much cheaper than waves at scale, but the gear can fail. A spares kit speeds up repairs.')}</dd><dt>${tr('Subsea cables')}</dt><dd>${tr('Subsea waves can only follow cable systems modelled on real ones, drawn faintly on the map (tap a city to highlight its cables). Teal ones are new and cheap, purple ones pricey, dashed ones old and cut-prone. All your waves on one cable die together when it is cut. Between continents on land, you can often choose overland (2.5×, many borders) or a cable.')}</dd><dt>${tr('Latency')}</dt><dd>${tr('Every link has latency. High-frequency traders pay a fortune for a circuit within their latency budget; route them “Lowest latency”. Bulk backup customers do not care, so route them “Scenic” over your quiet links to keep busy ones free.')}</dd><dt>${tr('NOC dashboard')}</dt><dd>${tr('The chart button at the top opens traffic graphs by exit (caches, PNIs, IX, transit), money over time, per-ASN traffic with how it reaches you and what its transit costs, plus your busiest links and routers.')}</dd><dt>${tr('Asia')}</dt><dd>${tr('A weird, underserved market. Transit costs 2.5× what it does in Europe (Africa 2×, Oceania 1.8×), local incumbents mostly peer only for pay, and IXs are fragmented. But demand is enormous and users sign up 60% faster than anywhere else. Peering and caches pay off most here.')}</dd><dt>${tr('Russia')}</dt><dd>${tr('Moscow needs a mandatory government box in every POP, Western CDNs are mostly gone, Goggle video is throttled to half speed, and the sovereign internet drills now and then cut Moscow off for a day.')}</dd><dt>${tr('Events, chains and wholesale')}</dt><dd>${tr('Event networks (a final, a festival, a keynote) need a burst of capacity in one city for a few days and pay once at the end, prorated by how much of the crowd you served; below 70% you pay a penalty. SD-WAN chains connect 3–6 of your POPs hub-and-spoke, so one broken spoke upsets the whole contract. Once you run your own dark fiber, carriers want to rent spare channels as alien waves, and on fiber you built yourself, a spare pair.')}</dd><dt>${tr('Bank')}</dt><dd>${tr('Tap your cash to open the bank. Lenders make offers now and then, and much more often when you are in the red. Each loan has a monthly payment and some odd conditions; break one and you pay a penalty. Your credit rating decides which banks talk to you. The loan shark is always there. Do not be late.')}</dd><dt>${tr('LAGs')}</dt><dd>${tr('Out of port speed? Bundle up to 8 identical ports to the same transit provider, IX or PNI into a LAG. Each member costs a full port; flow hashing is never perfectly even, so a bundle carries about 95% of the sum.')}</dd><dt>${tr('Traffic engineering')}</dt><dd>${tr('Tap a link to see which networks, which entry points and which customer cities fill it. Raise a link\'s metric to steer traffic around it, or set an egress (transit, IX, PNI) to Prefer or Backup only.')}</dd><dt>${tr('China')}</dt><dd>${tr('Mainland China needs a license and a local joint venture. Many foreign services are blocked there, and traffic crossing the border loses packets unless you pay for premium routes.')}</dd><dt>${tr('Weird requirements')}</dt><dd>${tr('Some customers come with conditions: no Cogentle anywhere, no subsea cables because of sharks, two routers, a generator, NetChill on-net, low-loss China reach and more. Each pays a bonus. Unmet ones make them grumpy until you fix it or they leave.')}</dd><dt>${tr('Customer levels')}</dt><dd>${tr('As your peak traffic and footprint grow, bigger customers show up: streaming startups and universities, then AI GPU data centers and cloud on-ramps, then AI training interconnects and hyperscaler DCI deals measured in terabits. Pink $$ bubbles mark the big ones.')}</dd><dt>${tr('L2VPN & DDoS protection')}</dt><dd>${tr('Businesses may want a private circuit between two of your POPs (it rides your backbone), or DDoS protection (needs your own scrubbing center).')}</dd><dt>${tr('NNI fabrics')}</dt><dd>${tr('Megapork, PocketFabric and Consolation Connect sell a port plus virtual circuits between cities. Great for small links and remote peering at an IX where you have no POP.')}</dd>
|
||
<dt>${tr('Conferences')}</dt><dd>${tr('NANOG, RIPE, DENOG and friends come round every year. Register in the Deals tab for $8k. For 45 days after, selective networks with a presence in that region need only half the usual traffic before they peer with you. Sometimes you also win the raffle.')}</dd><dt>${tr('Modes')}</dt><dd>${tr('Sandbox gives you a billion dollars, every unlock and no failures, but no badges. Scenarios are hand-built challenges with a goal and a deadline, and the weekly challenge gives everyone the same world for a week. Share your result with the card in the menu.')}</dd><dt>${tr('Traceroute')}</dt><dd>${tr('Tap 🔍 Traceroute on any of your cities, or open it from the NOC tab, to see the exact path to a network or POP, hop by hop, with latency, the exit and the AS path.')}</dd><dt>${tr('Badges')}</dt><dd>${tr('Below your goals sits a wall of badges, from common to legendary. Some take luck, some take years, and a couple are secret. Badges you earned in earlier games stay on this device with a dashed outline.')}</dd><dt>${tr('The giants')}</dt><dd>${tr('At customer level 3 and 4, hyperscalers and AI clouds show up with deals only they would ask for: terabit AI WANs between gigawatt campuses, training runs spread over several sites, week-long dataset ingests, and hundreds of fiber pairs in a trench you dug yourself. They pay like nobody else, and they want diverse paths, two sites per metro and zero excuses. Cities near their campuses list them under “Who’s here”.')}</dd><dt>RouteScript</dt><dd>${tr('Once Auto-TE is installed, you can program it from the NOC tab. Rules include <code>spill at 80%</code>, <code>prefer pni for goggle</code>, <code>avoid transit for netchill</code>, <code>cap transit cogentle at 20 gbps</code>, <code>drain paris</code>, <code>avoid link fra-ams</code> and <code>blackhole ddos</code>. Check runs a dry run against live traffic; Deploy makes it real, mistakes included.')}</dd><dt>Auto-TE</dt><dd>${tr('Traffic follows the shortest path by distance and link metric, and reroutes by itself when links fail. When a path is merely full, the overflow is dropped, just like a real IGP. From customer level 3 you can install Auto-TE in the NOC tab: it spills overflow onto up to two alternate paths with free capacity, as long as they are no more than twice as long.')}</dd><dt>${tr('Metro diversity')}</dt><dd>${tr('A POP is one building until you add a second site in the Infra tab. Then a power cut, cleaner or A/C failure only takes out half the city, and you choose which site each transit, PNI and IX port plugs into, or pick Both to split a LAG across the two buildings. Spread them out, or both halves of your redundancy will sit in the same dark room. Watch out for metro ring cuts, which cut site B off.')}</dd><dt>${tr('Wave markets')}</dt><dd>${tr('What a wave costs depends on where it runs. Europe is cheap (lots of competing fiber), North America is average, Asia and South America are pricier, and anything into Africa is several times the price. Every route has its own going rate, and new leases get about 8% cheaper each year, so waiting can pay. The link planner tells you how a route compares.')}</dd><dt>${tr('Regional quirks')}</dt><dd>${tr('In the Gulf, Saudi POPs need a local telecom licence and data on Saudi users stays in the Kingdom; gigaprojects ask for huge demo networks; and now and then the neighbours fall out and every link between Qatar and Saudi Arabia or the UAE goes dark for months, so keep a sea route. South America hangs off Miami: transit is pricier, nothing crosses the Darién Gap by land, and fiber over the Andes costs double and breaks often. IX.brrr in Brazil is run by a nonprofit with cheap public prices, and small Brazilian provedores buy transit in bulk. Inside the UAE only the duopoly may run fiber, so no dark fiber and 3× waves. Korea runs on “sender pays”: transit into Seoul costs about four times the usual price and the three incumbents only peer over paid PNIs, billed per gigabit you send them. Taiwan’s cables meet a lot of anchors, Indian fiber meets road widening and the monsoon, and South Africa has load shedding: bring a generator.')}</dd><dt>${tr('Boot times')}</dt><dd>${tr('Some routers take forever to boot. The Infra tab shows how long yours takes. Slow booters make crashes last longer and turn a one-router swap into a three-day outage. Bigger chassis, especially anything with a PacketOinker™ inside, are slow more often. Twin routers make it someone else’s problem.')}</dd><dt>${tr('Failures')}</dt><dd>${tr('Things break all the time: fiber cuts, router crashes, power cuts, IX loops, fabric outages, route leaks, DDoS, fat fingers, cooling failures, and geopolitics: sanctions, tariffs, BGP hijacks, landing permit disputes, exam-day shutdowns and Red Sea cable cuts. Traffic reroutes automatically over other paths and upstreams. Parallel links on diverse routes, a second router and a backup generator all help. Or pay to rush repairs.')}</dd>
|
||
</dl><h3 style="margin:16px 0 0">${tr('Want to know how it really works?')}</h3>${plugHtml(true)}</dl><div class="btns" style="margin-top:14px">${btn(UI.started?tr('Back to the map'):tr('Got it'),'helpClose',{},'big')}${RELEASE_NOTES.length?btn(tr('What’s new in {v}',{v:esc(APP_VERSION)}),'whatsNewShow',{},'ghost'):''}${UI.started&&S&&!S.lost?btn(tr('Start a new network'),'resetAsk',{},'ghost sm'):''}</div><div class="btns" style="margin-top:6px">${UI.started&&S&&!S.lost?btn(tr('Export save'),'exportSave',{},'ghost sm'):''}${btn(tr('Import a save'),'importPick',{},'ghost sm')}${btn(tr('Settings'),'settings',{},'ghost sm')}</div>`);
|
||
}
|
||
function showWin(){setTimeout(()=>{const m=$('modalCard');if(m&&!m.querySelector('[data-act=share]'))m.insertAdjacentHTML('beforeend',`<div class="btns" style="margin-top:8px">${btn(tr('Share my network'),'share',{},'pink')}</div><p class="meta" style="margin:12px 0 0">${tr('You built a cartoon internet. Now see how the real one works:')}</p>${plugHtml(true)}`);},0);openModal(`<h1 style="font-family:var(--display);font-size:44px;margin:0">${tr(`You're a <span style="color:var(--me)">Tier 1</span>!`)}</h1><p class="tagline">${tr('{name} (AS{asn}) is transit-free. You peer with every giant on the planet and pay nobody to reach the internet. Took you {days} days and {n} incidents.',{name:esc(S.name),asn:S.asn,days:S.day,n:S.stats.incidents})}</p>${btn(tr('Keep building'),'keepPlaying',{},'pink big')}`);sfx('coin');}
|
||
function showLose(){openModal(`<h1 style="font-family:var(--display);font-size:40px;margin:0">${tr('Bankrupt')}</h1><p class="tagline">${tr('The bank repossessed your routers and sold them on eBuy. {name} lasted {days} days and peaked at {peak}.',{name:esc(S.name),days:S.day,peak:fmtG(S.stats.peak)})}</p>${btn(tr('Try again'),'newgame',{},'pink big')}`);try{localStorage.removeItem('sot-save-v1');}catch(e){}}
|
||
function openLinkModal(a,b){
|
||
if([a,b].includes('kyv')&&[a,b].includes('mos')){openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:24px">${tr('Not happening')}</h2><button class="x" data-act="closeModal" aria-label="${tr('Close')}">×</button></div><p class="lead" style="margin-top:8px">${tr('Nobody sells capacity between Kyiv and Moscow, and nobody is going to. Route through Warsaw, Bucharest or Helsinki instead.')}</p>`);return;}
|
||
if((cnCity(a)||cnCity(b))&&!cnOk()){openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:24px">${tr('Not without a license')}</h2><button class="x" data-act="closeModal" aria-label="${tr('Close')}">×</button></div><p class="lead" style="margin-top:8px">${tr('Building into mainland China needs a joint venture and an operating license. Open {city} to apply.',{city:CITY[cnCity(a)?a:b].name})}</p>`);return;}
|
||
let route='';UI.pending={a,b};const km=kmBetween(a,b),sub=isSub(a,b),pop=S.pops[b]?0:popCost(b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc');
|
||
if(!sib.length)UI.route='diverse';const border=cnCity(a)!==cnCity(b),jn=sib.length?routeJoin(a,b):null,ts=landTrenches(a,b),mult=(sib.length&&!(jn&&jn.k===(ts[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1);
|
||
if(border)route+=`<p class="lead" style="margin-top:8px">${tr('Cross-border circuits into mainland China are sold only by licensed carriers, at 3× the price. Regular ones lose about 20% of traffic at the border.')}</p>${a==='hkg'||b==='hkg'?`<div class="seg">${btn(tr('Regular crossing'),'cnPrem',{v:0},!UI.cnPrem?'pink':'ghost')}${btn(tr('Premium crossing <small>+60% · ~3% loss</small>'),'cnPrem',{v:1},UI.cnPrem?'pink':'ghost')}</div>`:`<p class="note">${tr('Premium crossings are only sold in Hong Kong.')}</p>`}`;
|
||
if(sib.length&&!(isSub(a,b)&&cablesFor(a,b).length)&&!(UI.via&&UI.via!=='land'&&cablesFor(a,b).some(c=>c.cid===UI.via))){route+=`<p class="lead" style="margin-top:8px">${trn('You already have {n} link here ({list}). Parallel links add capacity. How should this one be routed?','You already have {n} links here ({list}). Parallel links add capacity. How should this one be routed?',sib.length,{list:sib.map(l=>capName(l)).join(', ')})}</p>
|
||
<div class="seg">${ts.length>1?ts.map((t,i)=>btn(`${i?tr('Diverse route {n}',{n:i}):tr('Main route')} <small>${esc(t.caps.join(', '))}${i?' · +40%':''}</small>`,'route',{r:'t:'+t.k},jn&&jn.k===t.k?'pink':'ghost')).join('')+btn(tr('New diverse route <small>+40% · survives cuts alone</small>'),'route',{r:'diverse'},!jn?'pink':'ghost'):btn(tr('Diverse route <small>+40% · survives cuts alone</small>'),'route',{r:'diverse'},!jn?'pink':'ghost')+btn(tr('Same trench <small>cheaper · one backhoe cuts all</small>'),'route',{r:'same'},jn?'pink':'ghost')}</div>${ts.length>1?`<p class="note">${tr('Waves on the same route share its fate: one backhoe cuts them all.')}</p>`:''}`;}
|
||
const mode=UI.lmode==='df'?'df':'wave',tabs=`<div class="seg" style="margin-top:8px">${btn(tr('Lease a wave'),'dfMode',{m:'wave'},mode==='wave'?'pink':'ghost')}${btn(tr('Dark fiber'),'dfMode',{m:'df'},mode==='df'?'pink':'ghost')}</div>`;
|
||
const head=`<div style="display:flex;align-items:center"><div><div class="eyebrow">${sub?tr('Subsea'):tr('Terrestrial')} · ${km.toLocaleString()} km</div><h2 style="font-size:26px">${CITY[a].name} → ${CITY[b].name}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('Close')}">×</button></div>${tabs}`;
|
||
if(mode==='df'){openModal(head+dfModalBody(a,b,km,pop));return;}
|
||
if(sub&&!cablesOk(a,b).length){const fr=[...new Set(CABLE_PAIRS.filter(c=>c.a===a||c.b===a).map(c=>CITY[c.a===a?c.b:c.a].name))];openModal(head+`<p class="lead" style="margin-top:10px">${tr('No subsea cable lands in both {a} and {b}. Cables from {a} reach {list}. Hop through one of those.',{a:CITY[a].name,b:CITY[b].name,list:fr.join(', ')||tr('nowhere')})}</p>${S.won&&!ownCabWhy(a,b)?ownCabTeaser(a,b):''}`);return;}
|
||
if(isSub(a,b)&&S.ev.landban&&S.ev.landban.until>S.day&&[a,b].includes(S.ev.landban.city)){openModal(head+`<p class="lead" style="margin-top:10px">${tr('The landing permit dispute in {city} blocks new subsea links for {n} more days.',{city:CITY[S.ev.landban.city].name,n:S.ev.landban.until-S.day})}</p>`);return;}
|
||
if(uaePair(a,b)||andesPair(a,b))route+=`<p class="note" style="margin-top:8px">${landWhy(a,b)}</p>`;
|
||
route+=`<p class="note" style="margin-top:6px">📈 ${esc(marketNote(a,b,sub))}</p>`;
|
||
const wr=waveRoute(a,b,mult,border);
|
||
openModal(`${head}
|
||
<p class="lead" style="margin-top:8px">${tr('Waves are leased at a flat monthly rate. Bigger and longer costs more, and subsea is 1.8×. First month is due now.')}</p>
|
||
${pop?`<p class="lead" style="margin-top:8px">${tr('Includes a new POP in {city} ({price}{extra}).',{city:CITY[b].name,price:fmt$(popCost(b)),extra:ruCity(b)?', '+tr('government box included'):CITY[b].uae?', '+tr('free-zone license included'):CITY[b].saudi?', '+tr('local telecom licence included'):''})}</p>`:''}${route}${viaSeg(a,b)}
|
||
<div class="tiers">${LT.map((T,i)=>{const lc=Math.round(waveMo(wr.km,wr.sub,i)*wr.wm),c=lc+pop,sw=subWaveWhy(i,wr.km,wr.sub),ok=waveOk(a,b,i)&&!sw;return !waveShown(i)?'':`<button class="tierbtn" data-act="buildLink" data-args='{"tier":${i}}'${S.cash<c||!ok?' disabled':''}><span class="sz">${T.n}</span><span class="grow meta">${sw?tr('too far for this cable'):!ok?tr('needs {what} at both ends',{what:esc(waveNeed(i))}):pop?tr('due now {price}',{price:fmt$(c)}):tr('flat rate')}</span><span class="pr num">${tr('{price}/mo',{price:fmt$(lc)})}</span></button>`;}).join('')}</div>`);
|
||
}
|
||
/* Your own subsea cable (#22). Tier 1 networks lay their own: very expensive, slow to build, and it pays for
|
||
itself after a few years if it replaces enough leased waves. Both ends need a cable landing station. You own
|
||
up to eight fiber pairs; the first comes lit with a ROADMaster, the repeaters are powered from shore. */
|
||
const SEA_DELAYS=[N_('A whale has parked on the route and will not move.'),N_('The cable ship’s coffee machine broke. Nobody works without coffee.'),N_('A fishing fleet is trawling exactly where you need to lay.'),N_('The seabed survey found an old sea mine. A small, very careful detour.'),N_('Storm season. The ship is sheltering in port, playing cards.'),N_('The crew fished out somebody else’s cable by mistake and has to put it back.')];
|
||
const OWNCAB_LAND=3000000,OWNCAB_KM=6000,OWNCAB_OM=25,OWNCAB_ROUTE=1.15;
|
||
const OWNCAB_NAMES=['Big Wet Tube','Davy Jones’ Backhaul','Kraken-1','Mariana Trench Coat','The Wet Ethernet','Sea-ya Later','Deep Pockets Express','Salty Sausage','Poseidon’s Patch Cable','Neptune Neutrality','Moby Disk','Fibre Nemo','The Long Wet Thing','Bermuda Triangle Routing','Seabed & Breakfast','Atlantis Backhaul'];
|
||
const OWNCAB_SHIPS=['MV Cable Guy','Spool of Thought','Wet Willy','Reel Deal','Splice Girl','Knot Today','Seas the Day','HMS Unplugged'];
|
||
const landing=c=>CABLE_PAIRS.some(p=>p.a===c||p.b===c);
|
||
const ownCabKm=(a,b)=>Math.round(kmBetween(a,b)*OWNCAB_ROUTE);
|
||
const ownCabCost=km=>2*OWNCAB_LAND+km*OWNCAB_KM+DF_SYS.roadm.cost;
|
||
const ownCabMo=km=>Math.round(km*OWNCAB_OM)+ampCount(km)*AMP_MO;
|
||
const ownCabDays=km=>Math.round(300+km*0.05);
|
||
// Some pairs share a landmass and still have cables between them (Marseille–Singapore, Cairo–Palermo) (#67).
|
||
const seaCab=(a,b)=>isSub(a,b)||(landing(a)&&landing(b)&&cablesFor(a,b).length>0);
|
||
function ownCabWhy(a,b){if(!seaCab(a,b))return tr('This route is on land. Build your own fiber instead.');
|
||
if(!S.won)return tr('Laying your own subsea cable is a Tier 1 thing. Go transit-free first.');
|
||
for(const c of [a,b])if(!landing(c))return tr('{city} has no cable landing station.',{city:CITY[c].name});
|
||
if(cnCity(a)||cnCity(b))return tr('Nobody gives a foreign network a landing licence in mainland China.');
|
||
return '';}
|
||
function ownCabTeaser(a,b){const why=ownCabWhy(a,b);return `<div class="btns" style="margin-top:8px">${btn(S.won?tr('Lay your own subsea cable…'):tr('Your own subsea cable <small>Tier 1 only</small>'),'ownCab',{},S.won&&!why?'pink':'ghost',!!why)}</div>${why&&S.won?`<p class="note">${esc(why)}</p>`:''}`;}
|
||
function ownCabBody(a,b,pop){const why=ownCabWhy(a,b);if(why)return `<p class="lead" style="margin-top:10px">${esc(why)}</p>${btn(tr('Back'),'dfSrc',{v:'lease'},'ghost sm')}`;
|
||
const km=ownCabKm(a,b),cost=ownCabCost(km),mo=ownCabMo(km),days=ownCabDays(km),wt=subMaxTier(km),w=Math.round(waveMo(km,true,wt)*waveMarket(a,b,true).m),save=10*w*LT[4].g/LT[wt].g-mo,pay=save>0?Math.ceil(cost/save):0;
|
||
return `<p class="lead" style="margin-top:8px">${tr('Your very own subsea cable. A ship lays it across the seabed, you own every fiber pair in it, and nobody else’s waves share your glass. It costs a frankly rude amount of money and takes a long time.')}</p>
|
||
<div class="kv"><span>${tr('Route')}</span><b>${tr('{km} km of seabed',{km:km.toLocaleString()})}</b></div>
|
||
<div class="kv"><span>${tr('Fiber pairs')}</span><b>${tr('{n} in the cable, the first one lit',{n:SUB_PAIRS_MAX})}</b></div>
|
||
<div class="kv"><span>${tr('Landing stations')}</span><b>${tr('{a} and {b}',{a:CITY[a].name,b:CITY[b].name})}</b></div>
|
||
<div class="kv"><span>${tr('Build time')}</span><b>${tr('about {n} days',{n:days})}</b></div>
|
||
<div class="kv" style="margin-top:10px"><span>${tr('Due now')}</span><b>${fmt$(cost+pop)}</b></div><div class="kv"><span>${tr('Monthly')}</span><b>${tr('{price}/mo',{price:fmt$(mo)})}</b></div>
|
||
<p class="note">${tr('A leased {wave} wave on this route costs {price}/mo.',{wave:LT[wt].n,price:fmt$(w)})} ${pay?tr('Replace 16 Tbps of them and the cable pays for itself in about {n} months.',{n:pay}):''} ${tr('Cuts still happen, anchors and sharks included, but the repair ship is yours to call.')}</p>
|
||
<div class="btns" style="margin-top:10px">${btn(tr('Lay the cable <small>{price}</small>',{price:fmt$(cost+pop)}),'orderCable',{},'pink big',S.cash<cost+pop)}${btn(tr('Back'),'dfSrc',{v:'lease'},'ghost')}</div>`;}
|
||
function dfModalBody(a,b,km,pop){
|
||
if(seaCab(a,b)&&UI.dfSrc==='cable')return ownCabBody(a,b,pop);
|
||
const sea=!isSub(a,b)&&seaCab(a,b)?ownCabTeaser(a,b):'';
|
||
if(isSub(a,b)&&!subDfCable(a,b))return `<p class="lead" style="margin-top:10px">${tr('Nobody sells dark fiber on a subsea cable here. Subsea capacity comes as leased waves.')}</p>`+ownCabTeaser(a,b);
|
||
const sc=isSub(a,b)?subDfCable(a,b):null;if(sc)km=sc.km;
|
||
if(uaePair(a,b))return `<p class="lead" style="margin-top:10px">${tr('No dark fiber inside the UAE. Only the two licensed operators may run fiber here, and they only sell waves.')}</p>`+sea;
|
||
if(landX(a,b)&&cnCity(a)===cnCity(b))return `<p class="lead" style="margin-top:10px">${tr('Nobody sells one fiber pair across a dozen borders. Between continents, overland capacity only comes as leased waves.')}</p>`+sea;
|
||
if(!dfAllowed(a,b))return `<p class="lead" style="margin-top:10px">${tr('Dark fiber across the Chinese border is not for sale. Buy a cross-border wave instead.')}</p>`+sea;
|
||
if(lvl()<2)return `<p class="lead" style="margin-top:10px">${tr('Dark fiber unlocks at customer level 2. You need the scale to justify buying your own optical gear.')}</p>`+sea;
|
||
const src=UI.dfSrc==='build'&&lvl()>=3&&!sc?'build':'lease',sys=DF_SYS[UI.dfSys]&&DF_SYS[UI.dfSys].lvl<=lvl()?UI.dfSys:'lite',amps=ampCount(km);
|
||
const up=(src==='build'?dfBuildCost(km):0)+DF_SYS[sys].cost+amps*AMP_COST+pop,mo=(src==='build'?Math.round(km*0.15):dfLeaseMo(km))+amps*AMP_MO;
|
||
const w=Math.round(waveMo(km,false,4));
|
||
return `<p class="lead" style="margin-top:8px">${tr('A fiber pair of your own. The glass is cheap, the gear is not: you buy a line system with an amplifier every {km} km, then optics for each channel. Your gear can fail, and you fix it.',{km:AMP_EVERY})}</p>
|
||
<h4 class="sub4">${tr('The glass')}</h4><div class="seg">${btn(tr('Lease an IRU <small>{price}/mo · ready in 30 days</small>',{price:fmt$(dfLeaseMo(km))}),'dfSrc',{v:'lease'},src==='lease'?'pink':'ghost')}${sc?btn(S.won?tr('Lay your own subsea cable…'):tr('Your own subsea cable <small>Tier 1 only</small>'),'ownCab',{},'ghost',!!ownCabWhy(a,b)):btn(lvl()>=3?tr('Build your own <small>{price} · ~{n} days</small>',{price:fmt$(dfBuildCost(km)),n:dfBuildDays(km)}):tr('Build your own <small>level 3</small>'),'dfSrc',{v:'build'},src==='build'?'pink':'ghost',lvl()<3)}${sea?btn(S.won?tr('Lay your own subsea cable…'):tr('Your own subsea cable <small>Tier 1 only</small>'),'ownCab',{},'ghost',!!ownCabWhy(a,b)):''}</div>${sc?`<p class="note">${tr("A fiber pair on {cable}, {km} km. It shares the cable with everyone else's waves, anchors included.",{cable:esc(CAB[sc.cid].name),km:sc.km.toLocaleString()})}</p>`:''}
|
||
${src==='build'?`<p class="note">${tr('Your own trench: almost no rent, but permits and digging take forever, and delays happen.')}</p>`:''}
|
||
<h4 class="sub4">${tr('Line system')}</h4><div class="seg">${Object.keys(DF_SYS).map(k=>btn(`${DF_SYS[k].n} <small>${DF_SYS[k].lvl>lvl()?tr('level {n}',{n:DF_SYS[k].lvl}):fmt$(DF_SYS[k].cost)}</small>`,'dfSys',{v:k},sys===k?'pink':'ghost',DF_SYS[k].lvl>lvl())).join('')}</div>
|
||
<p class="note">${esc(DF_SYS[sys].blurb)} ${trn('Plus {n} in-line amplifier ({price} each, {mo}/mo for hut rent and power).','Plus {n} in-line amplifiers ({price} each, {mo}/mo for hut rent and power).',amps,{price:fmt$(AMP_COST),mo:fmt$(AMP_MO)})}</p>${km>reachOn(OPT.tp16.reach,!!sc)?`<p class="note">${tr('<b>{km} km is longer than any optic reaches at full speed.</b> 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.toLocaleString()})}</p>`:''}
|
||
<div class="kv" style="margin-top:10px"><span>${tr('Due now')}</span><b>${fmt$(up)}</b></div><div class="kv"><span>${tr('Monthly')}</span><b>${tr('{price}/mo',{price:fmt$(mo)})}</b></div>
|
||
<p class="note">${tr('For comparison, a leased 1.6T wave on this route is {price}/mo. Optics come next, from the link panel.',{price:fmt$(w)})}</p>
|
||
<div class="btns" style="margin-top:10px">${btn(`${src==='build'?tr('Start construction'):tr('Sign the IRU')} <small>${fmt$(up)}</small>`,'orderDf',{},'pink big',S.cash<up)}</div>`;
|
||
}
|
||
function openVxcModal({from,to,prov}){
|
||
let rows='';const row=(f,a,b)=>{const km=kmBetween(a,b),sub=isSub(a,b),pb=S.pops[b]?nniPort(b,f.id):null,remote=!S.pops[b];
|
||
const label=remote?tr('Remote peering at {ix} · discouraged',{ix:esc(CITY[b].ix)}):pb?tr('Your POP'):tr('Your POP · needs a fabric port there');
|
||
const freeA=nniPort(a,f.id)?NNI[nniPort(a,f.id).tier].g-nniUsed(a,f.id):0,freeB=remote?1e9:pb?NNI[pb.tier].g-nniUsed(b,f.id):0;
|
||
return `<div class="row"><span class="logo" style="--c:${f.col}">${initials(f)}</span><div class="grow"><div class="nm">${CITY[a].name} → ${CITY[b].name}</div><div class="meta">${label} · ${km.toLocaleString()} km${sub?' '+tr('subsea'):''}</div>
|
||
<div class="btns">${VXC.map((V,t)=>btn(`${V.n} <small>${tr('{price}/mo',{price:fmt$(vxcMo(km,sub,t))})}</small>`,'buyVxc',{a,b,prov:f.id,t},'sm',(!remote&&!pb)||V.g>freeA||V.g>freeB||S.cash<vxcMo(km,sub,t))).join('')}</div></div></div>`;};
|
||
for(const f of FABS){if(prov&&f.id!==prov)continue;
|
||
if(from){if(!nniPort(from,f.id))continue;for(const b of f.cities){if(b===from)continue;if(!S.pops[b]&&!CITY[b].ix)continue;rows+=row(f,from,b);}}
|
||
else if(to&&f.cities.includes(to)){for(const a of Object.keys(S.pops))if(a!==to&&nniPort(a,f.id))rows+=row(f,a,to);}}
|
||
if(!rows){const fs=FABS.filter(f=>!to||f.cities.includes(to));rows=`<p class="empty">${tr("You need a fabric port at one of your POPs first. Open a POP's Infra tab and buy a port on {list}.",{list:fs.map(f=>`<b>${esc(f.name)}</b> (${f.cities.filter(c=>S.pops[c]).map(c=>CITY[c].name).join(', ')||tr('no POP of yours on it yet')})`).join(', ')})}</p>`;}
|
||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('Virtual circuit over an NNI fabric')}</div><h2 style="font-size:26px">${from?tr('From {city}',{city:CITY[from].name}):tr('To {city}',{city:CITY[to].name})}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('Close')}">×</button></div>
|
||
<p class="lead" style="margin-top:8px">${tr("No install fee, live in minutes, billed monthly. Cheaper than a wave for small capacity, but it rides someone else's fabric, and that fabric can fail.")}</p>${rows}`);
|
||
}
|
||
|
||
/* ================= CANVAS ================= */
|
||
const cv=$('map'),ctx=cv.getContext('2d');
|
||
const cam={x:1050,y:330,z:0.8};
|
||
let CW=0,CH=0,DPR=1;
|
||
/* Installed on an iPhone home screen with a translucent status bar, iOS can report a viewport one status bar
|
||
shorter than the screen while drawing from the very top, leaving an empty strip under the tab bar.
|
||
Measure the screen instead, on standalone iPhones only. It must not depend on the gap it fixes: once
|
||
the page is sized to the screen, iOS reports a full viewport, and switching back would bring the strip back. */
|
||
function fixStandaloneHeight(){const R0=document.documentElement;
|
||
const sa=window.navigator.standalone===true||!!(window.matchMedia&&matchMedia('(display-mode: standalone)').matches);
|
||
const sh=screen&&screen.width&&screen.height?(innerWidth>innerHeight?Math.min(screen.width,screen.height):Math.max(screen.width,screen.height)):0,gap=sh-innerHeight;
|
||
const on=sa&&/iPhone|iPod/.test(navigator.userAgent)&&sh>0&&gap>=0&&gap<=80;
|
||
R0.classList.toggle('iosfix',on);if(on)R0.style.setProperty('--app-h',sh+'px');else R0.style.removeProperty('--app-h');return on?sh:0;}
|
||
function resize(){const ah=fixStandaloneHeight();DPR=Math.min(2,window.devicePixelRatio||1);CW=innerWidth;CH=ah||innerHeight;cv.width=CW*DPR;cv.height=CH*DPR;}
|
||
addEventListener('resize',()=>{resize();WL.key=null;renderLeft();fitHud();});resize();
|
||
// Viewport readout for debugging phone layouts: open the game once with ?vp in the address (or the start URL).
|
||
function vpDebug(){let el=document.getElementById('vpdbg');if(!el){el=document.createElement('pre');el.id='vpdbg';el.style.cssText='position:fixed;left:8px;bottom:calc(var(--tabbar,0px) + 8px);z-index:99;margin:0;padding:6px 8px;background:rgba(30,38,64,.85);color:#7CFFB2;font:11px/1.35 ui-monospace,monospace;border-radius:8px;pointer-events:none';document.body.appendChild(el);
|
||
const pr=document.createElement('div');pr.id='vpprobe';pr.style.cssText='position:fixed;visibility:hidden;padding:env(safe-area-inset-top,0px) 0 env(safe-area-inset-bottom,0px)';document.body.appendChild(pr);}
|
||
const pr=document.getElementById('vpprobe'),cs=getComputedStyle(pr),vv=window.visualViewport,de=document.documentElement,tb=document.getElementById('tabbar').getBoundingClientRect();
|
||
el.textContent=`inner ${innerWidth}×${innerHeight} · screen ${screen.width}×${screen.height}\nvv ${vv?Math.round(vv.width)+'×'+Math.round(vv.height)+' top '+Math.round(vv.offsetTop):'-'} · client ${de.clientHeight}\nsafe top ${cs.paddingTop} bottom ${cs.paddingBottom}\nstandalone ${navigator.standalone===true||!!(window.matchMedia&&matchMedia('(display-mode: standalone)').matches)} · iosfix ${de.classList.contains('iosfix')} · CH ${CH}\nbody ${Math.round(document.body.getBoundingClientRect().height)} · tabbar ${Math.round(tb.top)}–${Math.round(tb.bottom)}`;}
|
||
let VP_T=null;const vpOn=on=>{clearInterval(VP_T);VP_T=null;const el=document.getElementById('vpdbg');if(el)el.remove();if(on){VP_T=setInterval(vpDebug,500);vpDebug();}try{on?localStorage.setItem('sot-vp','1'):localStorage.removeItem('sot-vp');}catch(e){}};
|
||
if(/[?&]vp\b/.test(location.search))vpOn(true);else if(/[?&]novp\b/.test(location.search))vpOn(false);
|
||
try{if(localStorage.getItem('sot-vp')==='1')vpOn(true);}catch(e){}
|
||
// Inside an installed app there is no address bar: five quick taps on the date toggle the readout.
|
||
{let taps=[];document.getElementById('hDate').closest('.chip,div').addEventListener('click',()=>{const t=performance.now();taps=taps.filter(x=>t-x<1500).concat(t);if(taps.length>=5){taps=[];vpOn(!VP_T);}});}
|
||
// iOS settles the standalone viewport a moment after launch and after rotating.
|
||
for(const t of [300,1000])setTimeout(()=>{resize();WL.key=null;},t);addEventListener('pageshow',()=>{resize();WL.key=null;});
|
||
function rng(seed){return()=>{seed|=0;seed=seed+0x6D2B79F5|0;let t=Math.imul(seed^seed>>>15,1|seed);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;};}
|
||
function inPoly(x,y,pts){let ins=false;for(let i=0,j=pts.length-1;i<pts.length;j=i++){const [xi,yi]=pts[i],[xj,yj]=pts[j];if(((yi>y)!==(yj>y))&&(x<(xj-xi)*(y-yi)/(yj-yi)+xi))ins=!ins;}return ins;}
|
||
function smoothPath(pts){const p=new Path2D();const n=pts.length;const mid=(a,b)=>[(a[0]+b[0])/2,(a[1]+b[1])/2];let m=mid(pts[n-1],pts[0]);p.moveTo(m[0],m[1]);for(let i=0;i<n;i++){const nx=pts[(i+1)%n];m=mid(pts[i],nx);p.quadraticCurveTo(pts[i][0],pts[i][1],m[0],m[1]);}p.closePath();return p;}
|
||
const LANDP_ALL=COAST.map(smoothPath);
|
||
// Zoomed out, hundreds of tiny Arctic and Pacific islets, each with a thick outline, turn into noise.
|
||
// The far view skips islands smaller than ~600 map px² (Sardinia-sized) unless a city is on them.
|
||
const ringArea=p=>{let a=0;for(let i=0,j=p.length-1;i<p.length;j=i++)a+=(p[j][0]+p[i][0])*(p[j][1]-p[i][1]);return Math.abs(a/2);};
|
||
const LANDP_FAR=COAST.map((p,i)=>ringArea(p)>=600||CITIES.some(c=>inPoly(c.x,c.y,p))?LANDP_ALL[i]:null).filter(Boolean);
|
||
const ALLPOLY=COAST;
|
||
const onLand=(x,y)=>ALLPOLY.some(p=>inPoly(x,y,p));
|
||
const R1=rng(7),WAVES=[],HILLS=[];
|
||
while(WAVES.length<220){const x=R1()*W,y=R1()*H;if(!onLand(x,y)&&!onLand(x+12,y)&&!onLand(x-12,y))WAVES.push([x,y,R1()]);}
|
||
while(HILLS.length<130){const x=R1()*W,y=R1()*H;if(onLand(x,y)&&!CITIES.some(c=>Math.hypot(c.x-x,c.y-y)<40))HILLS.push([x,y,6+R1()*10,R1()]);}
|
||
const CLOUDS=Array.from({length:7},(_,i)=>({x:R1()*W,y:60+R1()*(H-120),s:.7+R1()*.6,v:3+R1()*4}));
|
||
const FLOATS=[];
|
||
function floater(x,y,text,col){if(!animOn())return;FLOATS.push({x,y,text,col,t:performance.now()});}
|
||
// Static markup: data-i18n text and every aria-label/title go through the dictionary once at boot.
|
||
function i18nDom(){if(LANG==='en')return;for(const el of document.querySelectorAll('[data-i18n]'))el.textContent=tr(el.textContent);
|
||
for(const a of ['aria-label','title'])for(const el of document.querySelectorAll('['+a+']'))el.setAttribute(a,tr(el.getAttribute(a)));}
|
||
// One button per [value,label] option; the current one is highlighted.
|
||
function segBtns(act,cur,opts){return opts.map(([v,l])=>btn(l,act,{v},cur===v?'pink sm':'ghost sm')).join('');}
|
||
/* Animation setting: auto follows the system's reduced-motion preference, or force it on or off. */
|
||
/* Settings are per device (localStorage), not part of the save: they are about how you like to play. */
|
||
const PREF_DEF={pauseFurious:true,warnUnhappy:true,pauseIncident:false};
|
||
let PREFS=(()=>{try{const j=JSON.parse(localStorage.getItem('sot-prefs')||'{}');return j&&typeof j==='object'?j:{};}catch(e){return {};}})();
|
||
const pref=k=>typeof PREFS[k]==='boolean'?PREFS[k]:PREF_DEF[k];
|
||
function setPref(k,v){if(!own(PREF_DEF,k))return;PREFS[k]=!!v;try{localStorage.setItem('sot-prefs',JSON.stringify(PREFS));}catch(e){}}
|
||
// Stop the clock for something the player must see. Nothing happens if the game is already paused.
|
||
function autoPause(){if(!S||!UI.speed)return false;UI.resumeSpeed=UI.speed;UI.speed=0;renderHUD();return true;}
|
||
const resumeAct=()=>({l:tr('Resume'),act:'speed',args:{v:UI.resumeSpeed||1}});
|
||
function settingsHtml(){const seg=(lab,act,cur,opts,note)=>`<div class="setline"><span>${lab}</span><div class="seg">${segBtns(act,cur,opts)}</div></div>${note?`<p class="meta" style="margin:0 0 6px">${note}</p>`:''}`;
|
||
const onoff=k=>[[k+':1',tr('On')],[k+':0',tr('Off')]],cur=k=>k+':'+(pref(k)?1:0);
|
||
return `<div style="display:flex;align-items:center"><h2 style="font-size:26px">⚙️ ${tr('Settings')}</h2><button class="x" data-act="settingsClose" aria-label="${tr('Close')}">×</button></div><p class="tagline">${tr('Saved on this device.')}</p>
|
||
<h3 class="sub4">${tr('Customers and alerts')}</h3>
|
||
${seg(tr('Pause when a customer is furious'),'prefSet',cur('pauseFurious'),onoff('pauseFurious'),tr('The game stops so you can fix their service before they cancel. Most useful at high speed.'))}
|
||
${seg(tr('Warn when a customer gets unhappy'),'prefSet',cur('warnUnhappy'),onoff('warnUnhappy'),tr('An early heads-up below 60% happiness, long before they are furious.'))}
|
||
${seg(tr('Pause on outages that hurt'),'prefSet',cur('pauseIncident'),onoff('pauseIncident'),tr('Stops the game when a failure costs you real traffic, not when it reroutes by itself.'))}
|
||
<h3 class="sub4">${tr('Display and sound')}</h3>
|
||
${seg(tr('Animations'),'animSet',UI.anim||'auto',[['auto',tr('Auto')],['on',tr('On')],['off',tr('Off')]],tr('Auto follows your device’s reduce-motion setting. Off freezes the map: no moving packets, pulses or floating text.'))}
|
||
${seg(tr('Sound'),'soundSet',UI.muted?'off':'on',[['on',tr('On')],['off',tr('Off')]])}
|
||
${seg(tr('Language'),'langSet',LANG,Object.entries(LANGS))}
|
||
${seg(tr('Viewport info'),'vpSet',VP_T?'on':'off',[['on',tr('On')],['off',tr('Off')]],tr('For reporting layout bugs: shows what your screen tells the game.'))}
|
||
${installRow()}<div class="btns" style="margin-top:12px">${btn(tr('Done'),'settingsClose',{},'pink')}</div>`;}
|
||
const refreshSettings=()=>{if(UI.setOpen)openModal(settingsHtml());};
|
||
function animOn(){const m=UI.anim||'auto';if(m==='on')return true;if(m==='off')return false;try{return !matchMedia('(prefers-reduced-motion: reduce)').matches;}catch(e){return true;}}
|
||
function applyAnim(){const r=document.documentElement;r.classList.toggle('no-anim',UI.anim==='off');r.classList.toggle('anim-force',UI.anim==='on');if(!animOn())FLOATS.length=0;}
|
||
const toS=(wx,wy,k=0)=>[(wx+k*W-cam.x)*cam.z+CW/2,(wy-cam.y)*cam.z+CH/2];
|
||
const iconScale=()=>clamp(Math.sqrt(cam.z),0.7,1.35);
|
||
/* Level of detail (#37): zoomed out the map turns into a network map, with dots for cities, small
|
||
router pills for your POPs and thinner links. Phones switch a little earlier, the screen is small. */
|
||
const lodFar=()=>cam.z<(innerWidth<=760?0.95:0.72);
|
||
function rr(x,y,w,h,r){ctx.beginPath();ctx.moveTo(x+r,y);ctx.arcTo(x+w,y,x+w,y+h,r);ctx.arcTo(x+w,y+h,x,y+h,r);ctx.arcTo(x,y+h,x,y,r);ctx.arcTo(x,y,x+w,y,r);ctx.closePath();}
|
||
// Enough world copies to cover any screen width at any zoom (the map wraps horizontally).
|
||
function visibleKs(){const ks=[];for(let k=-5;k<=5;k++){const a=toS(0,0,k)[0],b=toS(W,0,k)[0];if(b>-200&&a<CW+200)ks.push(k);}return ks;}
|
||
const GEO=new Map();
|
||
/* Parallel waves on the same cable (or in the same trench) draw as one line with a combined label (#19). */
|
||
// Links drawn as one line share a key; the map spaces lines apart by drawn line, not by link (#64).
|
||
const gKey=l=>{const pr=l.a<l.b?l.a+'|'+l.b:l.b+'|'+l.a;return l.kind==='wave'?pr+'|'+(l.sub?'c:'+(l.cable||''):'t:'+(l.trench||l.id)):l.id;};
|
||
const lineIdx=l=>{const ks=[];for(const x of pairLinks(l.a,l.b)){const k=gKey(x);if(!ks.includes(k))ks.push(k);}return ks.indexOf(gKey(l));};
|
||
function linkGroups(){const m=new Map();for(const l of S.links){const key=gKey(l);const g=m.get(key);if(g)g.push(l);else m.set(key,[l]);}return [...m.values()];}
|
||
function groupLabel(grp,up){const t=grp[0].tier,same=grp.every(x=>x.tier===t),tot=grp.reduce((a,x)=>a+LT[x.tier].g,0);return (same?`${grp.length}×${LT[t].n}`:`${grp.length} × ${fmtCap(tot)}`)+(up.length<grp.length?` · ${up.length}/${grp.length} ${tr('up')}`:'');}
|
||
function linkGeom(l){const i=lineIdx(l);const key=l.id+'|'+i+'|'+(l.cable||'');const h=GEO.get(key);if(h)return h;
|
||
let pts=null;if(l.cable){const cp=cablePair(l.cable,l.a,l.b);if(cp){pts=cp.pts.map(p=>p.slice());const same=pairLinks(l.a,l.b).filter(x=>x.cable===l.cable).indexOf(l);if(same>0)for(let j=1;j<pts.length-1;j++){pts[j][1]+=same*5;}}}
|
||
// Your own subsea cable (#64) follows the shortest commercial cable on the same route, drawn alongside it; with
|
||
// none, a gentle curve. Its shape must not depend on how many waves already run between the two cities.
|
||
if(!pts&&l.kind==='df'&&l.own&&l.sub){const k=pairLinks(l.a,l.b).filter(x=>x.kind==='df'&&x.own&&x.sub).indexOf(l),c0=cablesFor(l.a,l.b).slice().sort((x,y)=>x.km-y.km)[0],cp=c0&&cablePair(c0.cid,l.a,l.b);
|
||
if(cp)pts=besideLine(cp.pts,2+k*1.5);
|
||
else{const g=bezGeom(l,k);pts=[];for(let j=0;j<=20;j++)pts.push(qpt(g,j/20));}}
|
||
if(!pts){const g=bezGeom(l);pts=[];for(let j=0;j<=20;j++)pts.push(qpt(g,j/20));}
|
||
const cum=[0];let L=0;for(let j=1;j<pts.length;j++){L+=Math.hypot(pts[j][0]-pts[j-1][0],pts[j][1]-pts[j-1][1]);cum.push(L);}for(let j=0;j<cum.length;j++)cum[j]/=L||1;
|
||
const g={pts,cum,len:L};GEO.set(key,g);return g;}
|
||
// A path running beside another: resampled, pushed sideways by d, easing to zero at both cities so it still lands there.
|
||
function besideLine(sp,d){const c=[0];for(let j=1;j<sp.length;j++)c.push(c[j-1]+Math.hypot(sp[j][0]-sp[j-1][0],sp[j][1]-sp[j-1][1]));const L=c[c.length-1]||1,N=24,out=[];
|
||
for(let j=0;j<=N;j++){const t=j/N,q=polyAt(sp,c.map(v=>v/L),t),a=polyAt(sp,c.map(v=>v/L),Math.max(0,t-.02)),b=polyAt(sp,c.map(v=>v/L),Math.min(1,t+.02)),dx=b[0]-a[0],dy=b[1]-a[1],n=Math.hypot(dx,dy)||1,f=d*Math.sin(Math.PI*t);out.push([q[0]+dy/n*f,q[1]-dx/n*f]);}return out;}
|
||
function polyAt(sp,cum,t){let i=1;while(i<cum.length-1&&cum[i]<t)i++;const t0=cum[i-1],t1=cum[i],f=t1>t0?(t-t0)/(t1-t0):0;return [sp[i-1][0]+(sp[i][0]-sp[i-1][0])*f,sp[i-1][1]+(sp[i][1]-sp[i-1][1])*f];}
|
||
function segDist(x,y,a,b){const dx=b[0]-a[0],dy=b[1]-a[1],L=dx*dx+dy*dy||1;const t=clamp(((x-a[0])*dx+(y-a[1])*dy)/L,0,1);return Math.hypot(x-a[0]-t*dx,y-a[1]-t*dy);}
|
||
// `cached`: the cables are already painted into the world layer. Zoomed in, the layer is painted without
|
||
// them (#49), so they are drawn here every frame instead.
|
||
function drawCables(ks){const z=cam.z,selC=UI.drag&&UI.drag.mode==='link'?UI.drag.from:(UI.sel&&UI.sel.type==='city'?UI.sel.id:null),cached=!!(WL.cv&&WL.key&&WL.cab);
|
||
if(!selC&&z<1.7&&cached)return;
|
||
ctx.font='800 10px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';
|
||
for(const cp of CABLE_PAIRS){const C=CAB[cp.cid],hot=!!selC&&(cp.a===selC||cp.b===selC);if(!hot&&cached&&z<1.7)continue;const col=cableCol(C);
|
||
for(const k of ks){const sp=cp.pts.map(p=>toS(p[0],p[1],k));let mn=Infinity,mx=-Infinity;for(const q of sp){if(q[0]<mn)mn=q[0];if(q[0]>mx)mx=q[0];}if(mx<-20||mn>CW+20)continue;
|
||
if(hot||!cached){ctx.globalAlpha=hot?0.95:0.4;ctx.strokeStyle=col;ctx.lineWidth=hot?3:1.6;ctx.lineJoin='round';ctx.setLineDash(C.age==='old'?[6,5]:[]);ctx.beginPath();ctx.moveTo(sp[0][0],sp[0][1]);for(let i=1;i<sp.length;i++)ctx.lineTo(sp[i][0],sp[i][1]);ctx.stroke();ctx.setLineDash([]);}
|
||
if(hot||z>=1.7){const m=sp[Math.floor(sp.length/2)];ctx.globalAlpha=hot?1:0.75;ctx.lineWidth=3;ctx.strokeStyle='rgba(255,255,255,.85)';ctx.strokeText(C.name,m[0],m[1]-8);ctx.fillStyle=col;ctx.fillText(C.name,m[0],m[1]-8);}
|
||
ctx.globalAlpha=1;}}}
|
||
function bezGeom(l,at){const A=CITY[l.a],B=CITY[l.b];const i=at!==undefined?at:lineIdx(l);const key=l.id+'|b'+i;const hit=GEO.get(key);if(hit)return hit;
|
||
const bx=A.x+wrapDx(A.x,B.x),by=B.y;const dx=bx-A.x,dy=by-A.y,len=Math.hypot(dx,dy)||1;let nx=-dy/len,ny=dx/len;if(ny>0){nx=-nx;ny=-ny;}
|
||
const base=Math.max(4,Math.min(len*0.1,90)),step=Math.min(16,len*.06),off0=i<=0?base:(i%2?-1:1)*(base*(i%2?0.2:1)+Math.ceil(i/2)*step);
|
||
const mx=(A.x+bx)/2,my=(A.y+by)/2;
|
||
const obs=CITIES.filter(c=>c.id!==l.a&&c.id!==l.b).map(c=>[mx+wrapDx(mx,c.x),c.y]);
|
||
const clear=(cx,cy)=>{let m=Infinity;const g={ax:A.x,ay:A.y,bx,by,cx,cy};for(let t=0.08;t<0.93;t+=0.06){const [px,py]=qpt(g,t);for(const [ox,oy] of obs){const d=Math.hypot(px-ox,py-oy);if(d<m)m=d;}}return m;};
|
||
const sg=Math.sign(off0)||1,mag=Math.abs(off0);
|
||
// Bend around cities in the way, but gently: short links need less room, no curve bows out more than about a
|
||
// third of its length, and when nothing clears, a modest curve beats a giant loop around the neighbourhood.
|
||
const need=Math.min(24,Math.max(7,len*0.2)),cap=Math.max(mag,len*0.32),lim=o=>Math.sign(o)*Math.min(Math.abs(o),cap);
|
||
const cand=[1,1.5,2.1,2.9,3.8].map(k=>lim(sg*mag*k)).concat([1,1.5,2.1,2.9,3.8].map(k=>lim(-sg*Math.max(mag,base)*k)));
|
||
let best=null,bs=-Infinity;
|
||
for(const off of cand){const cx=mx+nx*off,cy=my+ny*off,c=clear(cx,cy);if(c>=need){best=[cx,cy];break;}const sc=Math.min(c,need)-Math.abs(off)*0.35;if(sc>bs){bs=sc;best=[cx,cy];}}
|
||
const g={ax:A.x,ay:A.y,bx,by,cx:best[0],cy:best[1],len};GEO.set(key,g);return g;}
|
||
const qpt=(g,t)=>[(1-t)*(1-t)*g.ax+2*(1-t)*t*g.cx+t*t*g.bx,(1-t)*(1-t)*g.ay+2*(1-t)*t*g.cy+t*t*g.by];
|
||
const utilCol=u=>u<=0.001?'#AFC0D6':u<0.65?'#22C47A':u<0.9?'#FFAA1F':'#FF4D5E';
|
||
|
||
function draw(now){
|
||
if(!ctx)return;
|
||
ctx.setTransform(DPR,0,0,DPR,0,0);
|
||
// sea
|
||
const g=ctx.createLinearGradient(0,0,0,CH);g.addColorStop(0,'#62CBEA');g.addColorStop(1,'#43AED6');ctx.fillStyle=g;ctx.fillRect(0,0,CW,CH);
|
||
const ks=visibleKs(),z=cam.z;
|
||
const wl=worldLayer(z);
|
||
for(const k of ks){
|
||
ctx.setTransform(DPR*z,0,0,DPR*z,DPR*((k*W-cam.x)*z+CW/2),DPR*((-cam.y)*z+CH/2));
|
||
// waves: one path, one stroke
|
||
ctx.strokeStyle='rgba(255,255,255,.45)';ctx.lineWidth=2/z;ctx.lineCap='round';ctx.beginPath();
|
||
const ph0=now/900;for(const [x,y,ph] of WAVES){const o=Math.sin(ph0+ph*6)*3;ctx.moveTo(x-9+o,y);ctx.quadraticCurveTo(x-4.5+o,y-4,x+o,y);ctx.quadraticCurveTo(x+4.5+o,y+4,x+9+o,y);}ctx.stroke();
|
||
}
|
||
for(const k of ks){if(wl)drawWorldLayer(wl,k,z,ks[0]);else{ctx.setTransform(DPR*z,0,0,DPR*z,DPR*((k*W-cam.x)*z+CW/2),DPR*((-cam.y)*z+CH/2));paintWorld(ctx,z,false);}}
|
||
for(const k of ks){
|
||
ctx.setTransform(DPR*z,0,0,DPR*z,DPR*((k*W-cam.x)*z+CW/2),DPR*((-cam.y)*z+CH/2));
|
||
// clouds
|
||
ctx.fillStyle='rgba(255,255,255,.55)';ctx.beginPath();
|
||
for(const c of CLOUDS){const x=((c.x+now/1000*c.v)%(W+200))-100,y=c.y;ctx.moveTo(x+16*c.s,y);ctx.arc(x,y,16*c.s,0,7);ctx.moveTo(x+38*c.s,y-8*c.s);ctx.arc(x+18*c.s,y-8*c.s,20*c.s,0,7);ctx.moveTo(x+55*c.s,y);ctx.arc(x+40*c.s,y,15*c.s,0,7);}ctx.fill();
|
||
}
|
||
ctx.setTransform(DPR,0,0,DPR,0,0);
|
||
if(!S)return;
|
||
const sc=iconScale(),day=S.day;
|
||
// cable systems
|
||
drawCables(ks);
|
||
// links
|
||
for(const grp of linkGroups()){const l=grp[0],many=grp.length>1,up=many?grp.filter(x=>!linkDown(x)):null;
|
||
const gm=linkGeom(l),cap=many?up.reduce((a,x)=>a+capOf(x),0):capOf(l),load=many?grp.reduce((a,x)=>a+(R.load[x.id]||0),0):(R.load[l.id]||0),u=cap?load/cap:0,df=l.kind==='df',bld=df&&l.ready>day,cut=!bld&&(many?!up.length:linkDown(l))&&!(df&&!(l.ch||[]).length),dark=df&&!bld&&!(l.ch||[]).length,vx=l.kind==='vxc';
|
||
const sel=UI.sel&&UI.sel.type==='link'&&grp.some(x=>x.id===UI.sel.id);
|
||
const far=lodFar(),w=(vx?2.2:(2.5+Math.max(...grp.map(tierW))*1.8+(many?Math.min(1.5,(grp.length-1)*0.5):0)))*sc*(far?0.5:1);
|
||
for(const k of ks){
|
||
const sp=gm.pts.map(p=>toS(p[0],p[1],k));let mn=Infinity,mx=-Infinity;for(const q of sp){if(q[0]<mn)mn=q[0];if(q[0]>mx)mx=q[0];}
|
||
if(mx<-40||mn>CW+40)continue;
|
||
const path=()=>{ctx.beginPath();ctx.moveTo(sp[0][0],sp[0][1]);for(let i=1;i<sp.length;i++)ctx.lineTo(sp[i][0],sp[i][1]);};
|
||
ctx.lineCap='round';ctx.lineJoin='round';
|
||
if(sel){ctx.strokeStyle='rgba(255,79,154,.35)';ctx.lineWidth=w+14;path();ctx.stroke();}
|
||
ctx.strokeStyle='#1E2640';ctx.lineWidth=w+4;ctx.setLineDash(cut?[8,8]:vx?[2,7]:bld?[10,8]:[]);path();ctx.stroke();
|
||
ctx.strokeStyle=bld?'#C9B27C':dark?'#5D6788':cut?'#FF4D5E':vx?FAB[l.prov].col:l.sub?(u>0.001?utilCol(u):'#7FD8EE'):utilCol(u);ctx.lineWidth=w;ctx.stroke();ctx.setLineDash([]);
|
||
if(df&&!bld&&!dark){ctx.strokeStyle='rgba(255,255,255,.75)';ctx.lineWidth=Math.max(1,w*0.25);ctx.setLineDash([1,6]);path();ctx.stroke();ctx.setLineDash([]);}
|
||
const at=t=>polyAt(sp,gm.cum,t);
|
||
if(!cut&&load>0.01){const n=clamp(Math.round(2+u*10),2,12)>>(far?1:0)||1,len=gm.len*z,spd=90;
|
||
ctx.fillStyle='#fff';ctx.strokeStyle='#1E2640';ctx.lineWidth=far?1:1.5;
|
||
const rr2=far?1.6:Math.max(2.2,w*.42),base=now/1000*spd/Math.max(len,40);ctx.beginPath();for(let i=0;i<n;i++){let t=(base+i/n)%1;if(i%2)t=1-t;const [px,py]=at(t);ctx.moveTo(px+rr2,py);ctx.arc(px,py,rr2,0,7);}ctx.fill();ctx.stroke();}
|
||
const [mx2,my]=at(.5);const mxx=mx2;
|
||
if(bld){if(far){ctx.fillStyle='#FF8A3D';ctx.strokeStyle='#1E2640';ctx.lineWidth=1.5;ctx.beginPath();ctx.arc(mxx,my,4,0,7);ctx.fill();ctx.stroke();}else drawCone(mxx,my,now);}
|
||
else if(cut&&!vx){if(far){ctx.fillStyle='#FF4D5E';ctx.strokeStyle='#1E2640';ctx.lineWidth=1.5;ctx.beginPath();ctx.arc(mxx,my,5,0,7);ctx.fill();ctx.stroke();ctx.fillStyle='#fff';ctx.font='900 8px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('!',mxx,my+0.5);}else drawBackhoe(mxx,my,now,l.sub);}
|
||
else if(z>0.9||sel){const t=many?groupLabel(grp,up):capName(l);ctx.font='800 11px "Baloo 2", sans-serif';const tw=ctx.measureText(t).width+10;ctx.fillStyle='#fff';ctx.strokeStyle='#1E2640';ctx.lineWidth=2;rr(mxx-tw/2,my-9,tw,17,8);ctx.fill();ctx.stroke();ctx.fillStyle='#1E2640';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(t,mxx,my+1);}
|
||
}
|
||
}
|
||
// drag preview
|
||
if(UI.drag&&UI.drag.mode==='link'){
|
||
const A=CITY[UI.drag.from];let tx=UI.drag.cx,ty=UI.drag.cy;
|
||
if(UI.snap){const sv=UI.snap;tx=sv.sx;ty=sv.sy;}
|
||
let [ax,ay]=toS(A.x,A.y,0);if(UI.snap){const B=CITY[UI.snap.id];const bxw=A.x+wrapDx(A.x,B.x);[tx,ty]=toS(bxw,B.y,0);}else{/* nearest copy of origin to cursor */for(const k of [-1,1]){const [px,py]=toS(A.x,A.y,k);if(Math.abs(px-tx)<Math.abs(ax-tx)){ax=px;ay=py;}}}
|
||
if(UI.snap){const B=CITY[UI.snap.id];const wx=A.x+wrapDx(A.x,B.x);for(const k of [-1,1]){const [px,py]=toS(A.x,A.y,k),[qx]=toS(wx,B.y,k);if(Math.abs(qx-CW/2)<Math.abs(tx-CW/2)){ax=px;ay=py;tx=qx;}}}
|
||
ctx.strokeStyle='#1E2640';ctx.lineWidth=7;ctx.lineCap='round';ctx.setLineDash([2,12]);ctx.beginPath();ctx.moveTo(ax,ay);ctx.lineTo(tx,ty);ctx.stroke();
|
||
ctx.strokeStyle='#FF4F9A';ctx.lineWidth=4;ctx.lineDashOffset=-now/30;ctx.stroke();ctx.setLineDash([]);ctx.lineDashOffset=0;
|
||
if(UI.snap&&UI.snap.id!==UI.drag.from){const b=UI.snap.id,km=kmBetween(UI.drag.from,b),sub=isSub(UI.drag.from,b);
|
||
const t=`${km.toLocaleString()} km${sub?' · '+tr('subsea'):''} · ${sub&&!cablesFor(UI.drag.from,b).length?tr('no cable lands here'):tr('from {price}/mo',{price:fmt$(waveMo(km,sub,0))})}`;
|
||
ctx.font='800 13px "Baloo 2", sans-serif';const tw=ctx.measureText(t).width+18;const lx=(ax+tx)/2,ly=(ay+ty)/2-22;
|
||
ctx.fillStyle='#1E2640';rr(lx-tw/2,ly-12,tw,24,12);ctx.fill();ctx.fillStyle='#fff';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(t,lx,ly+1);}
|
||
}
|
||
// cities
|
||
UI.feed=null;if(UI.sel&&UI.sel.type==='link'){const sl=S.links.find(x=>x.id===UI.sel.id);const rec=sl&&R.ef[edgeKey(sl)];if(rec){UI.feed=new Set(Object.keys(rec.eg).map(k=>R.egDesc[k].city));UI.dest=new Set(Object.keys(rec.dst));}}
|
||
// Place labels: your POPs and the selected city first, then others; a label that would overlap moves above its city or hides.
|
||
const vis=[];for(const C of CITIES)for(const k of ks){const [sx,sy]=toS(C.x,C.y,k);if(sx<-60||sx>CW+60||sy<-60||sy>CH+60)continue;vis.push({C,sx,sy});}
|
||
const prio=v=>(UI.sel&&UI.sel.type==='city'&&UI.sel.id===v.C.id?0:S.pops[v.C.id]?1:2);vis.sort((a,b)=>prio(a)-prio(b)||b.C.P-a.C.P);
|
||
const rects=[],hit=(r)=>rects.some(q=>r.x<q.x+q.w&&q.x<r.x+r.w&&r.y<q.y+q.h&&q.y<r.y+r.h);
|
||
const farL=lodFar();
|
||
for(const v of vis){if(farL){rects.push({x:v.sx-7,y:v.sy-7,w:14,h:14});continue;}const h=(12+Math.sqrt(v.C.P)*0.75)*sc;rects.push({x:v.sx-18*sc,y:v.sy-h-4*sc,w:40*sc,h:h+14*sc});}
|
||
for(const v of vis){const p=S.pops[v.C.id];ctx.font=`800 ${p?13:12}px "Baloo 2", sans-serif`;const tw=(LBLW[v.C.id+(p?1:0)]||(LBLW[v.C.id+(p?1:0)]=ctx.measureText(v.C.name).width+14));
|
||
if(farL&&prio(v)>1&&UI.hover!==v.C.id){v.ly=null;continue;}
|
||
const h=farL?6:12+Math.sqrt(v.C.P)*0.75;const below=farL?v.sy+15:v.sy+16*sc+8,above=farL?v.sy-15:v.sy-h*sc-17*sc;let ly=null;
|
||
for(const y of [below,above]){const r={x:v.sx-tw/2-2,y:y-10,w:tw+4,h:21};if(!hit(r)){ly=y;rects.push(r);break;}}
|
||
if(ly===null&&prio(v)<2){ly=below;rects.push({x:v.sx-tw/2,y:below-10,w:tw,h:21});}
|
||
v.ly=ly;}
|
||
for(const v of vis.slice().reverse())drawCity(v.C,v.sx,v.sy,sc,now,v.ly);
|
||
// floaters
|
||
for(let i=FLOATS.length-1;i>=0;i--){const f=FLOATS[i],a=(now-f.t)/1600;if(a>1){FLOATS.splice(i,1);continue;}
|
||
for(const k of ks){const [sx,sy]=toS(f.x,f.y,k);ctx.globalAlpha=1-a*a;ctx.font='800 17px "Baloo 2", sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.lineWidth=4;ctx.strokeStyle='#fff';ctx.strokeText(f.text,sx,sy-a*40);ctx.fillStyle=f.col;ctx.fillText(f.text,sx,sy-a*40);ctx.globalAlpha=1;}}
|
||
}
|
||
function drawCone(x,y,now){const b=Math.sin(now/300)*1.5;ctx.save();ctx.translate(x,y-12+b);ctx.strokeStyle='#1E2640';ctx.lineWidth=2;ctx.fillStyle='#FF8A3D';ctx.beginPath();ctx.moveTo(-7,9);ctx.lineTo(0,-10);ctx.lineTo(7,9);ctx.closePath();ctx.fill();ctx.stroke();ctx.fillStyle='#fff';ctx.fillRect(-4,-1,8,3);ctx.fillStyle='#1E2640';rr(-10,8,20,4,2);ctx.fill();ctx.restore();}
|
||
// Static land + cable map, rendered once per zoom bucket into an offscreen canvas.
|
||
function paintWorld(c,z,withCables){const LANDP=lodFar()?LANDP_FAR:LANDP_ALL;
|
||
for(const o of [0,W,-W]){c.save();c.translate(o+5/z,7/z);c.fillStyle='rgba(20,90,130,.35)';for(const p of LANDP)c.fill(p);c.restore();}
|
||
c.strokeStyle='#F8E6A8';c.lineWidth=10/z;c.lineJoin='round';for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.stroke(p);c.restore();}
|
||
c.fillStyle='#9BDA6C';for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.fill(p);c.restore();}
|
||
c.fillStyle='#86CB5B';c.beginPath();for(const [x,y,r] of HILLS){c.moveTo(x+r*1.4,y);c.ellipse(x,y,r*1.4,r*.8,0,0,Math.PI*2);}c.fill();
|
||
c.fillStyle='rgba(255,255,255,.18)';c.beginPath();for(const [x,y,r] of HILLS){c.moveTo(x-r*.3+r*.6,y-r*.25);c.ellipse(x-r*.3,y-r*.25,r*.6,r*.3,0,0,Math.PI*2);}c.fill();
|
||
c.strokeStyle='#1E2640';c.lineWidth=2.5/z;for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.stroke(p);c.restore();}
|
||
if(withCables)for(const off of [0,W,-W]){c.save();c.translate(off,0);for(const cp of CABLE_PAIRS){const C=CAB[cp.cid];c.globalAlpha=0.4;c.strokeStyle=cableCol(C);c.lineWidth=1.6/z;c.lineJoin='round';c.setLineDash(C.age==='old'?[6/z,5/z]:[]);c.beginPath();c.moveTo(cp.pts[0][0],cp.pts[0][1]);for(let i=1;i<cp.pts.length;i++)c.lineTo(cp.pts[i][0],cp.pts[i][1]);c.stroke();}c.restore();}
|
||
c.globalAlpha=1;c.setLineDash([]);
|
||
}
|
||
const WL={key:null,cv:null,zAt:0,lastZ:0,sc:1,ox:0,oy:0,full:true};const MAXPX=4096;
|
||
/* The land is never drawn as vectors onto the screen canvas: the coastline has thousands of points, and some
|
||
GPU canvas implementations (Firefox on Android) garble big paths (#43). It is painted into an offscreen image
|
||
instead: the whole world when that fits in MAXPX, otherwise the visible area plus a margin, repainted when you
|
||
pan out of it. While a zoom gesture is still moving, the last image is scaled rather than repainted. */
|
||
const SOFT_CANVAS=/Firefox\//.test(navigator.userAgent);
|
||
function wlCovers(z){if(WL.full)return true;const hw=CW/2/z,hh=CH/2/z,w=WL.cv.width/WL.sc,h=WL.cv.height/WL.sc;
|
||
return cam.x-hw>=WL.ox&&cam.x+hw<=WL.ox+w&&cam.y-hh>=WL.oy&&cam.y+hh<=WL.oy+h;}
|
||
function worldLayer(z){
|
||
const now=performance.now();if(z!==WL.lastZ){WL.lastZ=z;WL.zAt=now;}
|
||
const sc=z*DPR,key=sc.toFixed(4),have=!!(WL.cv&&WL.key);
|
||
if(have&&WL.key===key&&wlCovers(z))return WL;
|
||
if(have&&now-WL.zAt<250)return WL; // mid-gesture: scale the last image
|
||
const full=W*sc+2<=MAXPX;let ox=0,oy=0,w=W,h=H;
|
||
if(!full){const mx=Math.min(MAXPX/sc,CW/z*2),my=Math.min(MAXPX/sc,CH/z*2);w=mx;h=my;ox=cam.x-w/2;oy=cam.y-h/2;}
|
||
const cv2=WL.cv||document.createElement('canvas');cv2.width=Math.ceil(w*sc)+2;cv2.height=Math.ceil(h*sc)+2;
|
||
const c=cv2.getContext('2d',SOFT_CANVAS?{willReadFrequently:true}:undefined);if(!c)return null;
|
||
const kk=full?0:Math.floor(cam.x/W)*W;c.setTransform(1,0,0,1,0,0);c.clearRect(0,0,cv2.width,cv2.height);c.setTransform(sc,0,0,sc,-(ox-kk)*sc,-oy*sc);paintWorld(c,z,z<1.7);
|
||
Object.assign(WL,{cv:cv2,key,sc,ox,oy,full,cab:z<1.7});return WL;
|
||
}
|
||
// Draw the world image for map copy k (full layers repeat per copy; a crop already holds what is visible).
|
||
function drawWorldLayer(wl,k,z,k0){if(!wl.full&&k!==k0)return;const f=z*DPR/wl.sc,ox=(wl.full?k*W:wl.ox);
|
||
ctx.setTransform(1,0,0,1,0,0);ctx.drawImage(wl.cv,Math.round(DPR*((ox-cam.x)*z+CW/2)),Math.round(DPR*((wl.oy-cam.y)*z+CH/2)),wl.cv.width*f,wl.cv.height*f);}
|
||
function cableCol(C){return C.price<=0.85?'#14A88C':C.price<=1.1?'#2F7BEA':'#A05AE0';}
|
||
function drawBackhoe(x,y,now,sub){
|
||
const b=Math.sin(now/180)*2;ctx.save();ctx.translate(x,y-14+b);
|
||
ctx.strokeStyle='#1E2640';ctx.lineWidth=2.2;
|
||
if(sub){ // shark fin
|
||
ctx.fillStyle='#6B7C99';ctx.beginPath();ctx.moveTo(-12,8);ctx.quadraticCurveTo(-2,-14,10,-12);ctx.quadraticCurveTo(4,-2,12,8);ctx.closePath();ctx.fill();ctx.stroke();
|
||
}else{
|
||
ctx.fillStyle='#FFD23F';rr(-12,-4,18,12,3);ctx.fill();ctx.stroke();rr(-8,-12,10,9,2);ctx.fillStyle='#BDE8FF';ctx.fill();ctx.stroke();
|
||
ctx.beginPath();ctx.moveTo(6,0);ctx.lineTo(14,-10);ctx.lineTo(19,2);ctx.stroke();ctx.fillStyle='#1E2640';ctx.beginPath();ctx.arc(-7,10,3,0,7);ctx.arc(2,10,3,0,7);ctx.fill();
|
||
}
|
||
ctx.restore();
|
||
}
|
||
const LBLW={};
|
||
try{document.fonts&&document.fonts.ready.then(()=>{for(const k in LBLW)delete LBLW[k];});}catch(e){}
|
||
function drawCityFar(C,sx,sy,sc,now,lyOverride){
|
||
const p=S.pops[C.id],down=p&&p.down>S.day,sel=UI.sel&&UI.sel.type==='city'&&UI.sel.id===C.id,hov=UI.hover===C.id||(UI.snap&&UI.snap.id===C.id);
|
||
ctx.save();ctx.translate(sx,sy);ctx.strokeStyle='#1E2640';
|
||
if(sel){ctx.strokeStyle='#FF4F9A';ctx.lineWidth=2.5;ctx.setLineDash([4,4]);ctx.lineDashOffset=-now/40;ctx.beginPath();ctx.arc(0,0,p?14:9,0,7);ctx.stroke();ctx.setLineDash([]);ctx.strokeStyle='#1E2640';}
|
||
if(p){
|
||
if(!down&&R.cityDem[C.id]>0&&sfOf(R,C.id)<0.9){ctx.fillStyle=`rgba(255,77,94,${.35+.25*Math.sin(now/200)})`;ctx.beginPath();ctx.arc(0,0,12,0,7);ctx.fill();}
|
||
const col=down?'#8A91A8':'#FF4F9A';ctx.lineWidth=1.8;
|
||
if(p.site2){ctx.setLineDash([2,2]);ctx.beginPath();ctx.moveTo(0,0);ctx.lineTo(9,6);ctx.stroke();ctx.setLineDash([]);ctx.fillStyle=col;rr(5,3,9,7,3);ctx.fill();ctx.stroke();}
|
||
if((p.routers||1)>=2){ctx.fillStyle=down?'#6E7590':'#D63B7F';rr(-6,-7,15,10,4);ctx.fill();ctx.stroke();}
|
||
ctx.fillStyle=col;rr(-8,-5,16,10,4);ctx.fill();ctx.stroke();
|
||
}else{ctx.fillStyle=hasIxAt(C.id)?'#FFD23F':'#FFFFFF';ctx.lineWidth=1.5;ctx.beginPath();ctx.arc(0,0,hov?4.5:3.4,0,7);ctx.fill();ctx.stroke();}
|
||
if(S.offers.some(o=>bCities(o).includes(C.id))){ctx.fillStyle='#16A866';ctx.lineWidth=1.2;ctx.beginPath();ctx.arc(p?9:5,p?-7:-5,3,0,7);ctx.fill();ctx.stroke();}
|
||
if(S.inc.some(i=>i.ref===C.id&&i.type!=='leak')){ctx.fillStyle='#FF4D5E';ctx.lineWidth=1.2;ctx.beginPath();ctx.arc(p?-9:-5,p?-7:-5,3.4,0,7);ctx.fill();ctx.stroke();}
|
||
ctx.restore();
|
||
if(lyOverride!==null&&(p||sel||hov)){ctx.font=`800 ${p?12:11}px "Baloo 2", sans-serif`;const t=C.name,tw=ctx.measureText(t).width+12,ly=lyOverride==null?sy+15:lyOverride;
|
||
ctx.fillStyle=p?'#FF4F9A':'#FFFFFF';ctx.strokeStyle='#1E2640';ctx.lineWidth=1.6;rr(sx-tw/2,ly-8,tw,16,8);ctx.fill();ctx.stroke();
|
||
ctx.fillStyle=p?'#FFFFFF':'#1E2640';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(t,sx,ly+1);}
|
||
}
|
||
function drawCity(C,sx,sy,sc,now,lyOverride){
|
||
if(lodFar())return drawCityFar(C,sx,sy,sc,now,lyOverride);
|
||
const hot=(UI.hotMap||{})[C.id];
|
||
const p=S.pops[C.id],down=p&&p.down>S.day,sel=UI.sel&&UI.sel.type==='city'&&UI.sel.id===C.id,hov=UI.hover===C.id||(UI.snap&&UI.snap.id===C.id);
|
||
const k=sc*(hov?1.15:1);
|
||
ctx.save();ctx.translate(sx,sy);
|
||
if(UI.feed&&UI.feed.has(C.id)){ctx.strokeStyle='#FF8A3D';ctx.lineWidth=4;ctx.setLineDash([3,5]);ctx.beginPath();ctx.arc(0,-6*k,36*k,0,7);ctx.stroke();ctx.setLineDash([]);}
|
||
if(sel){ctx.strokeStyle='#FF4F9A';ctx.lineWidth=3;ctx.setLineDash([6,6]);ctx.lineDashOffset=-now/40;ctx.beginPath();ctx.arc(0,-6*k,30*k,0,7);ctx.stroke();ctx.setLineDash([]);}
|
||
if(p&&!down&&R.cityDem[C.id]>0&&sfOf(R,C.id)<0.9){const a=.35+.25*Math.sin(now/200);ctx.fillStyle=`rgba(255,77,94,${a})`;ctx.beginPath();ctx.arc(0,-6*k,26*k,0,7);ctx.fill();}
|
||
ctx.scale(k,k);
|
||
ctx.fillStyle='rgba(30,38,64,.2)';ctx.beginPath();ctx.ellipse(0,9,20,5,0,0,7);ctx.fill();
|
||
const h=p?18:12+Math.sqrt(C.P)*0.75;
|
||
ctx.strokeStyle='#1E2640';ctx.lineWidth=2.2;
|
||
if(!p){const bl=[[-15,h*.65,'#FFFFFF'],[-5,h,'#FFE7A1'],[5,h*.5,'#BDE8FF']];
|
||
for(const [x,hh,col] of bl){ctx.fillStyle=col;rr(x,8-hh,10,hh,2);ctx.fill();ctx.stroke();}
|
||
ctx.fillStyle='rgba(30,38,64,.35)';ctx.beginPath();for(const [x,hh] of bl)for(let yy=8-hh+4;yy<5;yy+=5){ctx.rect(x+2.5,yy,2,2);ctx.rect(x+5.5,yy,2,2);}ctx.fill();}
|
||
if(p){
|
||
// Second building: a small router B on the metro ring, so dual-site POPs stand out.
|
||
if(p.site2){const dB=siteDown(C.id,'b'),cut=p.ringcut>S.day;ctx.save();ctx.lineWidth=2.2;ctx.setLineDash(cut?[3,4]:[]);ctx.strokeStyle=cut?'#FF4D5E':'#1E2640';ctx.beginPath();ctx.moveTo(10,6);ctx.quadraticCurveTo(22,14,26,7);ctx.stroke();ctx.setLineDash([]);ctx.strokeStyle='#1E2640';
|
||
ctx.fillStyle=dB?'#8A91A8':'#FF4F9A';rr(20,-1,18,12,4);ctx.fill();ctx.stroke();ctx.fillStyle='#fff';ctx.font='900 8px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('B',29,5.5);ctx.restore();}
|
||
ctx.translate(0,2);
|
||
ctx.lineWidth=2.4;ctx.beginPath();ctx.moveTo(-10,-6);ctx.lineTo(-13,-17);ctx.moveTo(10,-6);ctx.lineTo(13,-17);ctx.stroke();
|
||
ctx.fillStyle=down?'#FF4D5E':'#FFD23F';ctx.beginPath();ctx.arc(-13,-18,2.6,0,7);ctx.arc(13,-18,2.6,0,7);ctx.fill();ctx.stroke();
|
||
if((p.routers||1)>=2){ctx.fillStyle=down?'#6E7590':'#D63B7F';rr(-13,-13,34,16,6);ctx.fill();ctx.stroke();}
|
||
if(p.gen){ctx.fillStyle='#FFD23F';rr(-27,-1,9,11,2);ctx.fill();ctx.stroke();}
|
||
ctx.fillStyle=down?'#8A91A8':'#FF4F9A';rr(-17,-7,34,16,6);ctx.fill();ctx.stroke();
|
||
if(!down&&(R.nodeLoad[C.id]||0)>=(R.nodeCap[C.id]||1e12)*0.95){for(let i=0;i<3;i++){const t=(now/700+i/3)%1;ctx.fillStyle=`rgba(90,98,130,${0.55*(1-t)})`;ctx.beginPath();ctx.arc(6+i*3,-12-t*18,3+t*4,0,7);ctx.fill();}}
|
||
if((p.rgen||0)>0){const G=RG[p.rgen||0];ctx.fillStyle=G.badge?'#7CFFB2':'#FFD23F';ctx.beginPath();ctx.arc(17,-7,6,0,7);ctx.fill();ctx.lineWidth=1.8;ctx.stroke();ctx.fillStyle='#1E2640';ctx.font='900 8px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(G.badge||String(G.cls+1),17,-6.5);ctx.lineWidth=2.2;}
|
||
const sf=sfOf(R,C.id);
|
||
for(let i=0;i<4;i++){const on=down?false:(((now/(160+i*37))|0)+i)%3!==0;ctx.fillStyle=down?'#3B4260':on?(sf<0.9?'#FF4D5E':'#7CFFB2'):'#2A3150';ctx.beginPath();ctx.arc(-10+i*6.6,1,2.1,0,7);ctx.fill();}
|
||
if(down){ctx.fillStyle='#fff';ctx.font='900 14px "Baloo 2", sans-serif';ctx.textAlign='center';ctx.fillText('zzz',20,-14);}
|
||
ctx.translate(0,-2);
|
||
}
|
||
const ixn=ixName(C.id);
|
||
if(ixn){const mine=!!S.myIx[C.id],joined=hasIxAt(C.id);const ixHot=hot&&hot.ix;ctx.fillStyle=ixHot?(Math.sin(now/180)>0?'#FF4D5E':'#FF8A3D'):mine?'#FF4F9A':joined?'#FFD23F':'#FFFFFF';ctx.beginPath();for(let i=0;i<6;i++){const a=Math.PI/3*i+Math.PI/6;ctx.lineTo(19+8.5*Math.cos(a),-h+2+8.5*Math.sin(a));}ctx.closePath();ctx.fill();ctx.lineWidth=2;ctx.stroke();
|
||
ctx.fillStyle=mine||ixHot?'#fff':'#1E2640';ctx.font='900 8px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('IX',19,-h+2.5);}
|
||
if(hot&&p){let y=-14;const pulse=.75+.25*Math.sin(now/200);for(const k of ['r','t','p','c']){if(!hot[k])continue;ctx.globalAlpha=pulse;ctx.fillStyle='#FF4D5E';ctx.beginPath();ctx.arc(-29,y,6.5,0,7);ctx.fill();ctx.globalAlpha=1;ctx.lineWidth=2;ctx.strokeStyle='#1E2640';ctx.stroke();ctx.fillStyle='#fff';ctx.font='900 8px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(HOTL[k],-29,y+0.5);y+=14;}}
|
||
const off=S.offers.some(o=>bCities(o).includes(C.id));
|
||
if(off){const by=-h-16+Math.sin(now/250)*3;ctx.fillStyle='#fff';ctx.lineWidth=2.2;ctx.beginPath();ctx.ellipse(-2,by,11,9,0,0,7);ctx.fill();ctx.stroke();ctx.beginPath();ctx.moveTo(-5,by+8);ctx.lineTo(-7,by+14);ctx.lineTo(0,by+8);ctx.fillStyle='#fff';ctx.fill();const big=S.offers.some(o=>bCities(o).includes(C.id)&&(BIZ_T[o.type].lv>=3||BIZ_T[o.type].event));ctx.fillStyle=big?'#FF4F9A':'#16A866';ctx.font='900 13px "Baloo 2", sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(big?'$$':'$',-2,by+1);}
|
||
const inc=S.inc.some(i=>i.ref===C.id&&i.type!=='leak');
|
||
if(inc){ctx.fillStyle='#FF4D5E';ctx.beginPath();ctx.arc(-20,-h+2,7,0,7);ctx.fill();ctx.lineWidth=2;ctx.stroke();ctx.fillStyle='#fff';ctx.font='900 11px Nunito, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('!',-20,-h+3);}
|
||
ctx.restore();
|
||
// label
|
||
if((cam.z>=0.62||p||sel||hov)&&(lyOverride!==null||hov)){
|
||
ctx.font=`800 ${p?13:12}px "Baloo 2", sans-serif`;const t=C.name,tw=ctx.measureText(t).width+14,ly=lyOverride==null?sy+16*sc+8:lyOverride;
|
||
ctx.fillStyle=p?'#FF4F9A':'#FFFFFF';ctx.strokeStyle='#1E2640';ctx.lineWidth=2;rr(sx-tw/2,ly-9,tw,19,9);ctx.fill();ctx.stroke();
|
||
ctx.fillStyle=p?'#FFFFFF':'#1E2640';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(t,sx,ly+1);
|
||
}
|
||
}
|
||
|
||
/* ---------- hit tests & input ---------- */
|
||
function hitCity(x,y,r=28){let best=null,bd=r*iconScale();const KS=visibleKs();for(const C of CITIES)for(const k of KS){const [sx,sy]=toS(C.x,C.y,k);const d=Math.hypot(sx-x,sy+4-y);if(d<bd){bd=d;best={id:C.id,sx,sy};}}return best;}
|
||
function hitLink(x,y){if(!S)return null;let best=null,bd=12;const KS=visibleKs();for(const grp of linkGroups()){const l=grp[0];const g=linkGeom(l);for(const k of KS){let prev=null;for(const p of g.pts){const q=toS(p[0],p[1],k);if(prev){const d=segDist(x,y,prev,q);if(d<bd){bd=d;best=l.id;}}prev=q;}}}return best;}
|
||
function wrapCam(){cam.x=((cam.x%W)+W)%W;cam.y=clamp(cam.y,0,H);}
|
||
const ptrs=new Map();
|
||
cv.addEventListener('pointerdown',e=>{audioInit();cv.setPointerCapture(e.pointerId);ptrs.set(e.pointerId,{x:e.clientX,y:e.clientY});
|
||
if(ptrs.size>=2){if(!UI.drag||UI.drag.mode!=='pinch'){const [a,b]=[...ptrs.values()];UI.drag={mode:'pinch',d0:Math.hypot(a.x-b.x,a.y-b.y)||1,z0:cam.z};UI.snap=null;cv.classList.remove('linking');}return;}
|
||
const hit=S&&hitCity(e.clientX,e.clientY);
|
||
if(hit&&S.pops[hit.id])UI.drag={mode:'maybeLink',from:hit.id,sx:e.clientX,sy:e.clientY,camx:cam.x,camy:cam.y,moved:false};
|
||
else UI.drag={mode:'pan',sx:e.clientX,sy:e.clientY,camx:cam.x,camy:cam.y,moved:false};
|
||
});
|
||
cv.addEventListener('pointermove',e=>{
|
||
if(ptrs.has(e.pointerId))ptrs.set(e.pointerId,{x:e.clientX,y:e.clientY});
|
||
const d=UI.drag;
|
||
if(!d){const h=S&&hitCity(e.clientX,e.clientY);UI.hover=h?h.id:null;cv.style.cursor=h?(S.pops[h.id]?'crosshair':'pointer'):(hitLink(e.clientX,e.clientY)?'pointer':'grab');return;}
|
||
if(d.mode==='pinch'){if(ptrs.size>=2){const [a,b]=[...ptrs.values()];const mx=(a.x+b.x)/2,my=(a.y+b.y)/2;zoomAt(mx,my,clamp(d.z0*Math.hypot(a.x-b.x,a.y-b.y)/d.d0,ZMIN,ZMAX)/cam.z);}return;}
|
||
const dx=e.clientX-d.sx,dy=e.clientY-d.sy;if(Math.hypot(dx,dy)>6)d.moved=true;
|
||
if(d.mode==='maybeLink'&&d.moved){d.mode='link';cv.classList.add('linking');}
|
||
if(d.mode==='link'){d.cx=e.clientX;d.cy=e.clientY;const h=hitCity(e.clientX,e.clientY,40);UI.snap=h&&h.id!==d.from?h:null;renderHint();}
|
||
else if(d.mode==='pan'&&d.moved){cam.x=d.camx-dx/cam.z;cam.y=d.camy-dy/cam.z;wrapCam();cv.style.cursor='grabbing';}
|
||
});
|
||
function endPtr(e){
|
||
ptrs.delete(e.pointerId);const d=UI.drag;if(!d)return;
|
||
if(d.mode==='pinch'){if(ptrs.size===0){UI.drag=null;UI.snap=null;cv.classList.remove('linking');}return;}
|
||
if(d.mode==='link'){if(UI.snap&&UI.snap.id!==d.from){openLinkModal(d.from,UI.snap.id);sfx('click');}}
|
||
else if(!d.moved&&S){const h=hitCity(e.clientX,e.clientY);
|
||
if(h){selectCity(h.id);renderLeft();sfx('click');}
|
||
else{const l=hitLink(e.clientX,e.clientY);if(l){selectLink(l);sfx('click');}else{UI.sel=null;renderPanel();renderLeft();}}}
|
||
UI.drag=null;UI.snap=null;cv.classList.remove('linking');cv.style.cursor='grab';renderHint();
|
||
}
|
||
// A cancelled pointer (scroll takeover, palm rejection, system gesture) is not a tap or a drop.
|
||
function cancelPtr(e){ptrs.delete(e.pointerId);if(ptrs.size)return;UI.drag=null;UI.snap=null;cv.classList.remove('linking');cv.style.cursor='grab';renderHint();}
|
||
cv.addEventListener('pointerup',endPtr);cv.addEventListener('pointercancel',cancelPtr);
|
||
const ZMIN=0.35,ZMAX=6;
|
||
function zoomAt(mx,my,f){const wx=cam.x+(mx-CW/2)/cam.z,wy=cam.y+(my-CH/2)/cam.z;cam.z=clamp(cam.z*f,ZMIN,ZMAX);cam.x=wx-(mx-CW/2)/cam.z;cam.y=wy-(my-CH/2)/cam.z;wrapCam();}
|
||
cv.addEventListener('wheel',e=>{e.preventDefault();zoomAt(e.clientX,e.clientY,Math.exp(-e.deltaY*0.0015));},{passive:false});
|
||
addEventListener('keydown',e=>{if(e.target.closest&&e.target.closest('input,textarea,select,[contenteditable]'))return;if(e.ctrlKey||e.metaKey||e.altKey)return;if(e.code==='Space'&&e.target.closest&&e.target.closest('button,a'))return;if(e.code==='Space'){e.preventDefault();UI.speed=UI.speed?0:1;renderHUD();}if(e.key==='0')ACT.speed({v:0.5});if(e.key==='1')ACT.speed({v:1});if(e.key==='2')ACT.speed({v:2});if(e.key==='3')ACT.speed({v:4});if(e.key==='4')ACT.speed({v:8});if(e.key==='Escape'&&!$('bankBox').hidden){$('bankBox').hidden=true;return;}if(e.key==='Escape'&&!$('dash').hidden){$('dash').hidden=true;return;}if(e.key==='Escape'){if(!$('modal').hidden){if(S&&UI.started&&!S.lost)closeModal();}else{UI.sel=null;renderPanel();}}});
|
||
|
||
/* ---------- click delegation ---------- */
|
||
let pressing=false;
|
||
document.addEventListener('pointerdown',e=>{if(e.target.closest('#panel,#left,#dash,#bankBox,#modal,#tabbar,#toasts'))pressing=true;});
|
||
addEventListener('pointerup',()=>setTimeout(()=>pressing=false,0));
|
||
addEventListener('pointercancel',()=>{pressing=false;});addEventListener('blur',()=>{pressing=false;});
|
||
document.addEventListener('change',e=>{const el=e.target.closest('[data-chg]');if(!el||!S)return;const fn=ACT[el.dataset.chg];if(fn)fn({v:el.value});});
|
||
/* Taps that land on the wrong thing (#44): a real tap only fires the button it went down on, never something that
|
||
appeared or moved under the finger, nothing behind a menu that opened or closed mid-tap, and no toast button in
|
||
the first half second after the toast popped up. Synthetic clicks (keyboard, tests) are not affected. */
|
||
let PD={t:0,b:null};
|
||
document.addEventListener('pointerdown',e=>{PD={t:performance.now(),b:e.target.closest('[data-act]')};},true);
|
||
function tapOk(e,b){if(!e.isTrusted||!PD.t||e.detail===0)return true;const now=performance.now();if(now-PD.t>4000)return true;
|
||
if(PD.b!==b)return false;if((UI.layerAt||0)>PD.t)return false;const ts=b.closest('.toast');if(ts&&PD.t-(+ts.dataset.born||0)<500)return false;return true;}
|
||
document.addEventListener('click',e=>{const b=e.target.closest('[data-act]');if(!b||b.disabled)return;if(!$('modal').hidden&&!b.closest('#modal'))return;if(!tapOk(e,b))return;audioInit();const fn=ACT[b.dataset.act];if(!fn)return;if(!S&&!['start','randomName','pickStart','cont','help','helpClose','newgame','mute','animSet','soundSet','langSet','closeModal','speed','bankClose','whatsNewShow','updateNow','updateLater','importPick','importGo','modeSet','scenarios','startScn','startWeekly','settings','settingsClose','prefSet','vpSet','install','pitchSkip'].includes(b.dataset.act))return;let a={};try{a=JSON.parse(b.dataset.args||'{}');}catch(_){}fn(a);});
|
||
|
||
/* ================= LOOP ================= */
|
||
let last=performance.now(),acc=0,hudT=0,animT=0;
|
||
function frame(now){
|
||
// Schedule the next frame first: one bad lookup in a day tick must not freeze the whole game.
|
||
if(!window.__TUBES_TEST__)requestAnimationFrame(frame);
|
||
const dt=Math.min(250,now-last);last=now;
|
||
if(ANALYTICS.host&&S&&!S.lost&&UI.speed&&document.visibilityState==='visible'){UI.playMs=(UI.playMs||0)+dt;const m=UI.playMs/60000;for(const k of PLAY_MARKS)if(m>=k)track('play_'+k+'m',true);}
|
||
if(S&&UI.started&&!S.lost&&now-(UI.lastSave||0)>5000)save();
|
||
if(S&&!S.lost&&$('modal').hidden&&UI.speed){acc+=dt*UI.speed;let n=0;while(acc>=DAY_MS&&n<4&&UI.speed){acc-=DAY_MS;try{dayTick();}catch(e){tickErr(e);}n++;}
|
||
if(n){UI.ticking=true;renderHUD();UI.ticking=false;if(!pressing){renderPanel();renderLeft();if(!$('dash').hidden)renderDash();renderBank();}renderHint();}}
|
||
if(UI.speed&&!(S&&S.lost))animT+=dt; /* paused = frozen dots, waves and clouds */
|
||
try{draw(animOn()?animT:0);}catch(e){tickErr(e);}
|
||
}
|
||
function tickErr(e){console.error('[tubes] tick failed',e);if(UI.tickErr)return;UI.tickErr=true;track('tick_error',true);
|
||
toast(tr('<b>Something in the NOC glitched.</b><br>The game kept going. If things look odd, export your save and open an issue on GitHub.'),'bad');}
|
||
function boot(data){
|
||
i18nDom();
|
||
try{UI.muted=localStorage.getItem('sot-mute')==='1';UI.anim=localStorage.getItem('sot-anim')||'auto';}catch(e){}
|
||
applyAnim();
|
||
if(data&&data.S){S=migrate(data.S);UI.started=true;if(data.cam)Object.assign(cam,data.cam);compute();renderAll();}
|
||
else{const sv=loadSave();
|
||
let okSave=false;if(sv){try{S=migrate(sv);compute();okSave=true;}catch(e){S=null;UI.started=false;try{localStorage.setItem('sot-save-broken',JSON.stringify(sv));localStorage.removeItem('sot-save-v1');}catch(e2){}}}
|
||
if(okSave){UI.started=true;UI.speed=[0,0.5,1,2,4,8].includes(S.uiSpeed)?S.uiSpeed:1;
|
||
if(S.cam&&isFinite(S.cam.x))Object.assign(cam,S.cam);else{const h=CITY[S.home];if(h){cam.x=h.x;cam.y=h.y;cam.z=innerWidth<760?1.1:1.4;}}
|
||
renderAll();if(S.grace&&S.grace.until>S.day&&R.graceNets&&!S.grace.told){S.grace.told=1;toast(tr('<b>New networks on the map.</b><br>This update added networks you are not connected to yet. For {n} days a free courtesy route reaches them, so your reach does not drop overnight. Peer with them, or buy transit, before it ends.',{n:S.grace.until-S.day}),'goal',[{l:tr('Open NOC'),act:'leftTab',args:{t:'noc'}}]);}
|
||
if(!whatsNew(true))toast(tr('<b>Welcome back, {name}.</b><br>Your network is right where you left it: {date}.',{name:esc(S.name),date:dateStr(S.day)}),'good');}
|
||
else{showTitle();whatsNew(false);if(sv)toast(tr('<b>Your saved game could not be loaded.</b><br>It was damaged, so a backup was kept and you can start fresh.'),'bad');}}
|
||
renderHUD();renderLeft();
|
||
window.claude?.hot?.snapshot?.(()=>({S:S&&JSON.parse(JSON.stringify(S)),cam:{...cam}}));
|
||
if(!window.__TUBES_TEST__){requestAnimationFrame(frame);setTimeout(checkUpdate,4000);setInterval(checkUpdate,10*60*1000);}
|
||
}
|
||
window.claude?.hot?.ready ? window.claude.hot.ready(boot) : boot(window.claude?.hot?.data ?? {});
|
||
</script>
|
||
|
||
</body>
|
||
</html>
|