GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Grid network and substations / code-generator / apps/substation-finder/Si

Substation Intelligence V9 63 (part 12)

A JavaScript file in the substation finder folder of Code Generator that maps elizabeth line and uses data from the ventus-grid-engine repository. Served with the page at https://ventusltd.github.io/code-generator/apps/substation-finder/Si/.

700 lines of JavaScript from code-generator, in 1 file. Topic: Grid network and substations. Section 294 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Substation Intelligence V9 63 geodesy · code-generator / apps/substation-finder/Si/202609062358-substation-intelligence-v9-63.js lines 7701–8400

Substation Intelligence V9 63

A JavaScript file in the substation finder folder of Code Generator that maps elizabeth line and uses data from the ventus-grid-engine repository. Served with the page at https://ventusltd.github.io/code-generator/apps/substation-finder/Si/.

Set aside from the main view: 100% of its lines are the same as atlas/cartridges/202611180026-substation-intelligence-v9-63.js (gridatlas), which stays. (near-copy-of, proposed by families.py). 99% of lines shared with Substation Intelligence V9 63; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9974 to gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/cartridges/202611180026-substation-intelligence-v9-63.js:1-8609 c6f9632fdb6e803baae03a54a542fe508431d153
  • sha256 d94b0de50deddac77643325b10fbe490ce44b8c406dbc6c67e6e7cadbdaa8ec6
  • target sha256 88c538b97bf426776cda436151741f17500a2136867d28362407550d72f9038f
  • group of 4 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

geodesycode-generator / apps/substation-finder/Si/202609062358-substation-intelligence-v9-63.js · lines 7701–8400 of 8590 · version 2026-09-06 23:58 (continued from section 283) · Not reached from any entry point (candidate for review) · pattern switchOn (shared by 4 files)

What it does
It maps elizabeth line, london underground, UK metros trams and hs2. Defines 238 functions or classes, including deepFreeze, escapeHTML, normalizeStatus, fmt, haversine. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage upstream_foresight (path word 'substation'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: 750kV, 400kV, 275kV, 132kV, 66kV, 33kV.
Inputs & outputs
In: data source: ventus-grid-engine data; data source: data-federation-map-for-globalgrid2050-all-repos data; data source: spiders data; data source: npm data; GeoJSON file elizabeth_line.geojson; GeoJSON file london_underground.geojson; GeoJSON file uk_metros_trams.geojson; GeoJSON file hs2.geojson. Out: downloaded file gridatlas-; downloaded file globalgrid2050-grid-atlas-; interactive map; canvas drawing; SVG drawing. Voltage levels named: 750kV, 400kV, 275kV, 132kV, 66kV, 33kV, 11kV.
What it achieves
It normalizes status (`normalizeStatus`), toggles zone draw mode (`toggleZoneDrawMode`) and opens popup (`openPopup`). ASSEMBLED by `tools/build-cartridge.mjs` from the parts below. Its code works with 400 kV, 100 MVA and 132 kV. It responds to fullscreenchange, webkitfullscreenchange and click events.
Why it matters
No other file in the estate was found to import it.
Application
code-generator · apps/substation-finder/Si · script
VEDIC
SNAP LINE ENDS TO SUBSTATIONS (GG2050-VEDIC-000106): GridAtlas / Substations · Geospatial data processing. line_features, substation_point_features → Line features whose first and last vertices are moved onto the nearest substation point within tolerance; other geometry unchanged.
VEDIC
MEASURE (GG2050-VEDIC-000001): GridAtlas / Geodesy · Mathematics / Spherical geometry. coordinate_pair, coordinate_pair → distance_km
VEDIC
REPRESENT (GG2050-VEDIC-000002): GridAtlas / Geodesy · Computer science / Geometry processing. geojson_geometry → coordinate_pair_or_null
Uses
Spider Full Po Test (estate URL), Data — Grid Studies Public Page (estate URL)
Used by
none found
Produces
deepFreeze, escapeHTML, normalizeStatus, fmt, haversine, _zoneDrawGetRadius, _zoneDrawCirclePoints, _zoneDrawCalcArea, _zoneDrawUpdateLayers, _zoneDrawShowPopup, _zoneDrawShowPopupDebounced, _zoneDrawClear
Defines here
collectSourceCode, downloadText, showTeleprintPanel, button, prepareSourceCode, deliverSourceCode, printSourceCode, statusLine, say, beginPreparing, button, install, normalise, ready
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
code-generator@3897d83efcd0259d21dce87704b0c33118fe2c2e apps/substation-finder/Si/202609062358-substation-intelligence-v9-63.js:7701-8400 · blob 2c8121b277e1b152a96688f6a2e0d7ef83471376 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: duplicate_candidate
      seen.set(absolute, { url: absolute, how: new Set([how]) });
    };

    add(location.href, 'the page itself');
    for (const node of document.querySelectorAll('script[src]')) add(node.src, '<script src>');
    for (const node of document.querySelectorAll('link[rel~="stylesheet"][href]')) {
      add(node.href, '<link stylesheet>');
    }
    if (typeof performance !== 'undefined' && performance.getEntriesByType) {
      for (const entry of performance.getEntriesByType('resource')) {
        if (textual(entry.name, entry.initiatorType)) {
          add(entry.name, `loaded by the browser (${entry.initiatorType})`);
        }
      }
    }
    /* A CAP THAT SAYS SO, OR IT IS A LIE.
       This was `.slice(0, MAX_RESOURCES)`. Resource 401 onwards simply vanished
       -- no entry in `missing`, no line in the file -- while the same teleprint
       printed "EVERY file is here in full. Nothing is truncated". A reader
       cannot see a gap that is not declared, so they reason as though it is not
       there, which is the one failure this whole format exists to prevent.
       The cap remains, because an unbounded fetch on a phone is its own
       failure; what changes is that anything beyond it is NAMED. */
    const all = Array.from(seen.values());
    const kept = all.slice(0, MAX_RESOURCES);
    kept.overflow = all.slice(MAX_RESOURCES);
    return kept;
  }

  /**
   * Collect everything and render one text file.
   * @returns {Promise<{text:string,filename:string,included:number,missing:Array}>}
   */
  async function collectSourceCode({ appName = 'GridAtlas', inlineDom = true } = {}) {
    const state = screenState();
    const targets = discover();
    const included = [];
    /* Anything past the cap starts life already declared, so a reader sees it in
       NOT READ instead of never learning it existed. */
    const missing = (targets.overflow || []).map(function (target) {
      return {
        url: target.url,
        reason: 'beyond the ' + MAX_RESOURCES + '-resource cap for one teleprint; '
          + 'named here rather than dropped'
      };
    });
    let total = 0;

    /* Four at a time. Serial is needlessly slow on a page with fifty
       dependencies; unbounded parallelism on a phone on mobile data drops
       requests and produces gaps that look like defects in the app. */
    for (let i = 0; i < targets.length; i += 4) {
      const batch = targets.slice(i, i + 4);
      const results = await Promise.all(batch.map(async target => {
        const read = await readText(target.url);
        return { target, read };
      }));
      for (const { target, read } of results) {
        if (!read.ok) {
          missing.push({ url: target.url, reason: read.reason });
          continue;
        }
        if (total > MAX_TOTAL_BYTES) {
          missing.push({ url: target.url, reason: 'size budget reached before this file' });
          continue;
        }
        /* THE WHOLE THING. NOTHING TRUNCATED.
           "NO I want the whole fucking thing as that's a real sandbox teleprint"
           -- the architect, 2026-09-05, having printed one from a real iPhone.

           An earlier version cut DATA files to their first 4,000 characters to
           get the file under a chat's upload limit. That was solving the right
           problem the wrong way: a teleprint whose defining promise is that it
           is the record exactly as it was cannot quietly hold back four fifths
           of a dataset, however loudly it labels the gap. Size is handled where
           it belongs -- by cutting the finished text into VOLUMES, which drops
           nothing. `kind` is still recorded, because knowing which files are
           code and which are data is useful to a reviewer. */
        const isCode = CODE.test(target.url) || target.url === location.href;
        const full = read.text;
        const truncated = false;
        const body = full;
        total += body.length;
        included.push({
          url: target.url,
          how: Array.from(target.how).join(', '),
          chars: full.length,
          kind: isCode ? 'code' : 'data',
          truncated,
          text: body
        });
      }
    }

    const rule = '='.repeat(78);
    const lines = [];
    lines.push(rule);
    lines.push(`TELEPRINT OF THE SOURCE CODE -- ${appName}`);
    lines.push(rule);
    lines.push('');
    lines.push('WHAT THIS FILE IS');
    lines.push('  Everything the browser loaded to build the screen this was printed');
    lines.push('  from, in full, plus a description of what was on that screen. It is');
    lines.push('  meant to be attached to an AI chat and asked about directly.');
    lines.push('');
    lines.push('HOW TO USE IT');
    lines.push('  Attach this file in ChatGPT, Claude or Gemini and describe what you');
    lines.push('  saw. You do not need to know how to code, and you do not need GitHub.');
    lines.push('');
    lines.push('WHAT IS NOT HERE');
    lines.push('  Map tiles and any other cross-origin response the browser will not let');
    lines.push('  this page read. Every one of those is listed by URL under NOT READ,');
    lines.push('  with the reason. Nothing has been guessed at or substituted.');
    lines.push('');
    lines.push('  EVERY file is here in full. Nothing is truncated, summarised or');
    lines.push('  rewritten. Where the whole thing is too large for a chat to accept, it');
    lines.push('  is cut into numbered VOLUMES at file boundaries -- volume 1 carries this');
    lines.push('  header, the screen state and the index of every file.');
    lines.push('');
    lines.push(rule);
    lines.push('THE SCREEN THIS CAME FROM');
    lines.push(rule);
    lines.push(JSON.stringify(state, null, 2));
    lines.push('');
    lines.push(rule);
    lines.push(`CONTENTS -- ${included.length} file(s), ${total} characters`);
    lines.push(rule);
    included.forEach((item, index) => {
      lines.push(`${String(index + 1).padStart(3, ' ')}. ${item.url}`);
      lines.push(`     ${item.chars} chars · ${item.kind}`
        + (item.truncated ? ` · TRUNCATED to first ${DATA_HEAD_CHARS}` : ' · in full')
        + ` · found via ${item.how}`);
    });
    lines.push('');
    if (missing.length) {
      lines.push(rule);
      lines.push(`NOT READ -- ${missing.length} resource(s)`);
      lines.push(rule);
      for (const item of missing) lines.push(`- ${item.url}\n    ${item.reason}`);
      lines.push('');
    }
    if (inlineDom) {
      lines.push(rule);
      lines.push('THE LIVE PAGE AS IT STOOD (document.documentElement.outerHTML)');
      lines.push(rule);
      lines.push(document.documentElement.outerHTML);
      lines.push('');
    }
    for (const item of included) {
      lines.push(rule);
      lines.push(`FILE: ${item.url}`);
      lines.push(`${item.chars} chars · ${item.kind}`
        + (item.truncated
          ? ` · TRUNCATED: the first ${DATA_HEAD_CHARS} characters of ${item.chars} are shown,`
            + ' because this is data rather than code. Nothing has been summarised or'
            + ' rewritten; the rest is simply not here.'
          : ' · shown in full')
        + ` · found via ${item.how}`);
      lines.push(rule);
      lines.push(item.text);
      lines.push('');
    }
    lines.push(rule);
    lines.push('END OF TELEPRINT');
    lines.push(rule);

    return {
      text: lines.join('\n'),
      filename: `${appName}-source-code-${new Date().toISOString().replace(/[:.]/g, '-')}.txt`,
      included: included.length,
      missing,
      state
    };
  }

  /* OUR OWN WAY OUT, ON EVERY PLATFORM.
     ------------------------------------------------------------------------
     "WE ARE NOT DEPENDENT ON APPLE WE ARE BUILDING OUR OWN NATIVE SOFTWARE OPEN
     SOURCE ON THE WEB." So the primary route is the one WE own: a panel drawn by
     this code, holding the whole teleprint, with its own Copy and Download
     buttons. It cannot be withdrawn by a vendor, it needs no permission, and it
     behaves the same on a phone, a laptop and a tablet.

     The platform's own conveniences are OFFERED, never depended on. A download
     is started because on a desktop that is what a reader expects; a share sheet
     is exposed only where the browser admits it can take a file. If both are
     absent or refused the reader still has the text in front of them, selected,
     with a Copy button under their thumb -- which is the whole point.

     GETTING THE FILE OFF THE PHONE, WHICH IS THE WHOLE POINT.
     ------------------------------------------------------------------------
     The architect's use for this is: print the source on an iPhone, attach it in
     ChatGPT, and show an agent what that phone is actually being served. So the
     delivery path has to work on iOS Safari, where the desktop assumption --
     `a[download]` on a blob URL -- is the least reliable of the four options,
     not the most.

     Four ways out, tried in order, and the returned record names the one that
     worked so a failure on a real device is attributable:

       share      navigator.share({files}) -- the native share sheet, which is
                  how a file actually reaches another app on iOS.
       download   a[download] -- correct everywhere else.
       clipboard  navigator.clipboard.writeText -- pasting works even when no
                  file ever lands.
       shown      a selectable panel of the text on the page itself. Never
                  pretty, always available, and it is the difference between a
                  reader who can get their answer and one who cannot.

     THE USER GESTURE IS THE CONSTRAINT. iOS grants share and clipboard only
     inside a real gesture, and this function has to fetch fifty resources first,
     which ends it. So the bytes are prepared when the FILE MENU OPENS and the
     button click only DELIVERS them. That is why prepareSourceCode() and
     deliverSourceCode() are separate exports. */

  function downloadText(text, filename) {
    const blob = new Blob([text], { type: 'text/plain;charset=utf-8' });
    const url = URL.createObjectURL(blob);
    const link = document.createElement('a');
    link.href = url;
    link.download = filename;
    link.rel = 'noopener';
    document.body.appendChild(link);
    link.click();
    setTimeout(() => {
      URL.revokeObjectURL(url);
      if (link.parentNode) link.parentNode.removeChild(link);
    }, 30000);
  }

  function showTeleprintPanel(text, filename, parts) {
    const existing = document.getElementById('gridatlas-teleprint-fallback');
    if (existing && existing.parentNode) existing.parentNode.removeChild(existing);
    const box = document.createElement('div');
    box.id = 'gridatlas-teleprint-fallback';
    box.style.cssText = 'position:fixed;inset:5% 4%;z-index:100000;display:flex;'
      + 'flex-direction:column;gap:8px;background:#04141a;color:#eaf4f6;'
      + 'border:1px solid rgba(80,220,240,.4);border-radius:6px;padding:12px;'
      + 'font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace';
    const head = document.createElement('div');
    head.textContent = filename
      + ' — the whole record. Select all and copy, or download it.'
      + ((parts && parts.length > 1)
        ? ' If your AI chat refuses the file, the buttons below cut it into '
          + parts.length + ' volumes; nothing is left out of them.'
        : '');
    const area = document.createElement('textarea');
    area.readOnly = true;
    area.value = text;
    area.style.cssText = 'flex:1 1 auto;width:100%;box-sizing:border-box;'
      + 'background:#02090c;color:#cfeef6;border:1px solid rgba(80,220,240,.25);'
      + 'font:11px/1.35 ui-monospace,SFMono-Regular,Menlo,monospace;padding:8px';
    const row = document.createElement('div');
    row.style.cssText = 'display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end';
    const button = (label) => {
      const node = document.createElement('button');
      node.type = 'button';
      node.textContent = label;
      /* 44px because a control smaller than that is not reliably hittable with a
         thumb, and this panel exists to be used on a phone. */
      node.style.cssText = 'min-height:44px;padding:0 16px;background:#0b2b33;'
        + 'color:#eaf4f6;border:1px solid rgba(80,220,240,.4);border-radius:4px;'
        + 'font:inherit;cursor:pointer';
      row.appendChild(node);
      return node;
    };
    const copy = button('Copy all');
    copy.setAttribute('data-teleprint', 'copy');
    copy.addEventListener('click', async () => {
      try {
        area.focus();
        area.setSelectionRange(0, area.value.length);
        if (navigator.clipboard && navigator.clipboard.writeText) {
          await navigator.clipboard.writeText(text);
        } else {
          document.execCommand('copy');
        }
        copy.textContent = 'Copied';
      } catch (_) {
        /* Selection is already made, so the reader can still copy by hand. Say
           that rather than claim a success that did not happen. */
        copy.textContent = 'Selected — press copy';
      }
    });
    const save = button('Download .txt');
    save.setAttribute('data-teleprint', 'download');
    save.addEventListener('click', () => downloadText(text, filename));
    /* One button per remaining volume. A chat that refused a 2 MB file will
       take these; the architect's own attempt came back "too many pages to
       upload" at 1,993,661 bytes. */
    if (parts && parts.length > 1) {
      parts.forEach((part) => {
        const extra = button('Volume ' + part.volume + ' of ' + part.of);
        extra.setAttribute('data-teleprint', 'volume-' + part.volume);
        extra.addEventListener('click', () => downloadText(part.text, part.filename));
      });
    }
    const close = button('Close');
    close.addEventListener('click', () => {
      if (box.parentNode) box.parentNode.removeChild(box);
    });
    box.appendChild(head);
    box.appendChild(area);
    box.appendChild(row);
    document.body.appendChild(box);
    /* Pre-selecting means one tap to "Copy" on a phone rather than a drag
       across half a megabyte of text. */
    try { area.focus(); area.setSelectionRange(0, area.value.length); } catch (_) { /* ignore */ }
    return box;
  }

  /**
   * Prepare the bytes. Call this when the menu OPENS, not when the button is
   * pressed, so the press is still a user gesture.
   */
  function prepareSourceCode(options = {}) {
    return collectSourceCode(options);
  }

  /**
   * Deliver already-prepared bytes. Tries share, download, clipboard, then shows
   * the text. Returns which path was used.
   */
  async function deliverSourceCode(collected, { prefer, panel = true } = {}) {
    /* THE WHOLE THING, IN ONE PIECE, AND NOTHING ELSE.
       ------------------------------------------------------------------------
       Volume splitting lived here and is gone. Two reasons, and the second is
       the serious one.

       First, it was the printer imposing a human limit: "a printer prints what
       it's given it doesn't rely on human induced limits and it's a digital
       printer that doesn't run out of paper 2MB is nothing for vital evidence
       like that."

       Second, it did not exist. `splitIntoVolumes`, `headerLines` and
       `fileBlocks` were REFERENCED here and never defined -- three symbols, each
       appearing exactly once in the file -- so this function threw a
       ReferenceError on every call and the Print source code button was dead on
       the live site. `node --check` passed throughout, because a syntax check
       cannot see an undefined identifier. An independent comparison of the two
       driver lanes found it; my own CI did not. */
    const first = { filename: collected.filename, text: collected.text };
    const parts = [first];
    const record = {
      filename: first.filename,
      bytes: new Blob([collected.text]).size,
      included: collected.included,
      missing: collected.missing.length,
      state: collected.state,
      via: [],
      offered: []
    };

    /* OURS FIRST. Whatever any platform does or refuses to do below, the reader
       is looking at volume 1 with a Copy button under it and one button per
       remaining volume. */
    if (panel) {
      showTeleprintPanel(first.text, first.filename, parts);
      record.via.push('panel');
    }

    /* The whole record. */
    try {
      downloadText(first.text, first.filename);
      record.via.push('download-requested');
    } catch (error) {
      record.offered.push('download: ' + String((error && error.message) || error));
    }

    if (prefer === 'share' && typeof navigator !== 'undefined' && navigator.share
        && typeof File === 'function') {
      try {
        const file = new File([first.text], first.filename, { type: 'text/plain' });
        if (!navigator.canShare || navigator.canShare({ files: [file] })) {
          await navigator.share({ files: [file], title: first.filename });
          record.via.push('share');
        } else {
          record.offered.push('share: this browser will not share files');
        }
      } catch (error) {
        record.offered.push(error && error.name === 'AbortError'
          ? 'share: the reader cancelled'
          : 'share: ' + String((error && error.message) || error));
      }
    }

    return record;
  }

  /** Collect and deliver in one call, for callers outside a gesture. */
  async function printSourceCode(options = {}) {
    const collected = await collectSourceCode(options);
    return deliverSourceCode(collected, options);
  }


  /* WIRING: put the two functions in the File menu, and nowhere else.
     --------------------------------------------------------------------------
     The reader already knows where printing lives -- they found it once and
     printed a sheet from it. A floating button somewhere else would be a second
     place to learn, so both controls go into the same EXPORT THIS VIEW group,
     next to the print command that is already there.

     The two are SEPARATE COMMANDS and are never merged into one "export":
       Print PDF          a picture of the screen, for a person to look at
       Print source code  the whole source and its dependencies, for a machine
                          to read

     NOTHING EXISTING IS REPLACED. The older map-only PDF control stays exactly
     as it is. Two implementations of the same idea sitting side by side is the
     point -- where they disagree, the disagreement is the finding. */

  var PANEL_ANCHOR = '#gridatlas-export-print';
  var STATUS_ID = 'gridatlas-teleprint-status';
  var MAX_TRIES = 80;

  function statusLine(anchor) {
    var node = document.getElementById(STATUS_ID);
    if (node) return node;
    node = document.createElement('div');
    node.id = STATUS_ID;
    node.setAttribute('role', 'status');
    node.setAttribute('aria-live', 'polite');
    node.style.cssText = 'padding:6px 11px;font:10px/1.4 ui-monospace,'
      + 'SFMono-Regular,Menlo,monospace;color:#9fd6e4;opacity:.9;'
      + 'white-space:normal;max-width:34ch';
    if (anchor && anchor.parentNode) anchor.parentNode.appendChild(node);
    return node;
  }

  function say(text) {
    var node = document.getElementById(STATUS_ID);
    if (node) node.textContent = text;
  }

  /* The teleprint of the source is prepared when the FILE MENU OPENS, not when
     the button is pressed.

     Collecting it means reading every resource the browser loaded, which takes
     seconds and ends the user gesture. A share sheet or a clipboard write
     requested after that gesture has ended is refused, and the reader is told
     nothing happened for no reason they can see. Preparing early costs one
     speculative pass and makes the press instant. */
  var prepared = null;
  var preparing = null;

  function beginPreparing() {
    if (prepared || preparing) return preparing;
    preparing = collectSourceCode({ appName: 'GridAtlas' })
      .then(function (result) {
        prepared = result;
        preparing = null;
        say('Source ready · ' + result.included + ' files'
          + (result.missing.length ? ' · ' + result.missing.length + ' not readable' : ''));
        return result;
      })
      .catch(function (error) {
        preparing = null;
        say('Source could not be prepared: ' + (error && error.message));
        throw error;
      });
    return preparing;
  }

  function button(label, id, onClick) {
    var node = document.createElement('button');
    node.id = id;
    node.setAttribute('type', 'button');
    node.setAttribute('data-gm-export', id.replace('gridatlas-', ''));
    node.setAttribute('data-teleprint', '1');
    node.textContent = label;
    node.addEventListener('click', function () { onClick(node); });
    return node;
  }

  function install() {
    var anchor = document.querySelector(PANEL_ANCHOR);
    if (!anchor || !anchor.parentNode) return false;
    if (document.getElementById('gridatlas-teleprint-source')) return true;

    var pdf = button('⎙ Print PDF · exactly this screen',
      'gridatlas-teleprint-pdf', function (node) {
        var was = node.textContent;
        say('Capturing the screen…');
        printPdf({
          note: {
            brand: 'VENTUS · GLOBALGRID2050 · GRID ATLAS',
            title: document.title,
            url: location.href,
            stamp: new Date().toISOString().replace('T', ' ').slice(0, 16) + ' UTC',
            credit: Array.prototype.map.call(
              document.querySelectorAll('.maplibregl-ctrl-attrib-inner'),
              function (n) { return n.textContent.trim(); }
            ).filter(Boolean).join(' | ')
          }
        }).then(function (receipt) {
          /* REPORT THE MEASUREMENT, DO NOT GRADE IT.
             ------------------------------------------------------------------
             This read `scale >= 0.999 ? 'every screen pixel'`. An ultrawide
             capture measured 2326 of 2327 columns -- 0.99957 -- so the sheet
             announced "every screen pixel" for a record that was one pixel
             column short. A threshold dressed as a fact is exactly the habit
             this estate has a rule against, and I wrote the rule.

             It also read width only, so a frame that was full width and short in
             height reported as complete. The claim is now an integer equality on
             BOTH axes, decided in screen-frame.js where the numbers are, and
             anything less prints the pixel counts rather than a verdict. */
          var fidelity = '';
          if (receipt.everyScreenPixel) {
            fidelity = ' · every screen pixel';
          } else if (receipt.screenWidth) {
            fidelity = ' · ' + receipt.width + '×' + receipt.height + ' of '
              + receipt.screenWidth + '×' + receipt.screenHeight + ' screen pixels';
          }
          say('PDF · ' + receipt.width + '×' + receipt.height + ' px, page '
            + receipt.pageWidth + '×' + receipt.pageHeight + fidelity
            + ' · via ' + receipt.method);
          node.textContent = was;
        }, function (error) {
          /* The reader cancelling the screen-share chooser is a decision, not a
             fault, and must not be reported as one. */
          say(error && /denied|Permission|abort/i.test(String(error.message || error))
            ? 'Screen capture was not allowed, so nothing was printed.'
            : 'Could not print: ' + (error && error.message));
          node.textContent = was;
        });
      });

    var source = button('⎙ Print source code · for AI review',
      'gridatlas-teleprint-source', function () {
        say('Preparing the source…');
        Promise.resolve(prepared || beginPreparing()).then(function (collected) {
          return deliverSourceCode(collected, { panel: true });
        }).then(function (receipt) {
          say('Source code · ' + receipt.included + ' files, '
            + receipt.bytes + ' bytes'
            + (receipt.volumesAvailable > 1
              ? ' · whole file; ' + receipt.volumesAvailable
                + ' volumes available if your chat refuses it'
              : '')
            + ' · ' + receipt.via.join(' + ')
            + (receipt.missing ? ' · ' + receipt.missing + ' not readable' : ''));
        }, function (error) {
          say('Could not print the source: ' + (error && error.message));
        });
      });

    anchor.parentNode.insertBefore(pdf, anchor.nextSibling);
    pdf.parentNode.insertBefore(source, pdf.nextSibling);
    statusLine(source);
    say('Print PDF saves this screen. Print source code saves the code behind it.');

    /* Opening File is the signal to start work. Delegated from the document so
       it survives the menu being rebuilt. */
    document.addEventListener('click', function (event) {
      var title = event.target && event.target.closest
        ? event.target.closest('.gm-title') : null;
      if (title && /file/i.test(title.textContent || '')) beginPreparing();
    }, true);
    return true;
  }

  /* The export group is built by the menu bar, which itself installs only once
     63 layer controls exist. Polling rather than assuming: a fixed delay is a
     guess that is wrong on a slow phone and wasteful on a fast desktop. */
  if (!install()) {
    var tries = 0;
    var timer = setInterval(function () {
      tries += 1;
      if (install() || tries >= MAX_TRIES) clearInterval(timer);
    }, 250);
  }

}());

/* ══════════════════════════════════════════════════════════════════════
   PART 2 - the network, as its operator publishes it
   ══════════════════════════════════════════════════════════════════════ */
(() => {
  'use strict';

  const GENERATION = '202609012045';
  /* Pinned to a commit and hashed. The reasoning, the table and the
     digest arithmetic are in the pinned-products module beside this file;
     what matters here is that `main` was the ref and the schema string was
     the whole defence, and a schema string is blind to values. */
  const PINS = (window.__GRIDATLAS_MODULES__ || {}).pinnedProducts || null;
  const PRODUCT_ID = 'connection-points.v3';
  const PRODUCT = PINS ? PINS.url(PRODUCT_ID) : null;
  const REQUIRED_SCHEMA = 'data-grid-gb.connection-points.v3';
  /* Appendix D publishes eight current metrics and they are NOT
     interchangeable, so one is quoted and named rather than any of them
     being called "the fault level".
     Codex, 202609011852: an earlier version of this comment and of the
     card said the RMS break current is "the one switchgear is rated
     against". That overclaims. Switchgear carries several relevant
     ratings - making capacity, short-time withstand, peak withstand -
     and this is ONE published breaker-duty metric among the eight. */
  const QUOTED_METRIC = 'three_phase_rms_break_current_ka';
  const QUOTED_METRIC_LABEL = 'three-phase RMS break current';
  const DEG = Math.PI / 180;

  const state = {
    schema: 'gridatlas.substation-intelligence.v2',
    generation: GENERATION,
    product: PRODUCT,
    loaded: false,
    points: 0,
    located: 0,
    product_schema: null,
    quoted_metric: QUOTED_METRIC,
    failures: []
  };
  window.__GRIDATLAS_NETWORK__ = state;

  /* ONE geodesy, and it is the module's.
     --------------------------------------------------------------
     This carried its own haversine using 2*R*asin(sqrt(a)) while the
     estate canonical form is R*2*atan2(sqrt(a), sqrt(1-a)). They
     agree algebraically and differ in the last place, and the
     difference was invisible for as long as this half of the
     cartridge was a monolith the all-versions scan could not read.
     202609012350 extracted it, the scan found it immediately, and
     the answer is not to retype the right form here but to stop
     having a second implementation at all. */
  const GEODESY = (window.__GRIDATLAS_MODULES__ || {}).geodesy;
  if (!GEODESY) throw new Error("substation-intelligence requires the geodesy module");
  const distanceKm = GEODESY.distanceKm;

  const NOISE = /\b(SUBSTATION|SUB STATION|SUBSTN|GRID|SUPPLY|POINT|GSP|NATIONAL|POWER|STATION|WIND|FARM|WINDFARM|OFFSHORE|ONSHORE|EXTENSION|400KV|275KV|132KV|66KV|33KV|11KV|NGET|SSE|SP|SHE)\b/g;
  function normalise(name) {
    return String(name || '').toUpperCase()
      .replace(/[^A-Z0-9 ]/g, ' ').replace(NOISE, ' ')
      .split(/\s+/).filter(Boolean).join(' ');
  }

  const byName = new Map();
  const located = [];
  /* Every point, not only the ones that survived the name join. `byName`
     keeps the first of a colliding key, so counting from it would report a
     smaller network than the operator publishes. */
  const published = [];

  const ready = (async () => {
    try {
      if (!PRODUCT) throw new Error('the pinned-products module is not composed, '
        + 'so this cartridge has no pinned ref to read and will not guess one');
      const response = await fetch(PRODUCT, { cache: 'no-cache' });
      if (!response.ok) throw new Error('HTTP ' + response.status);
      const text = await response.text();
      const seal = await PINS.verify(PRODUCT_ID, text);
      state.product_pin = seal;
      if (seal.state === 'MISMATCH') {
        state.failures.push(seal.detail
          + '; refusing to answer from bytes this composition has not seen');
        return false;
      }
      const product = JSON.parse(text);
      state.product_schema = product?.schema || null;
      if (product?.schema !== REQUIRED_SCHEMA) {
        state.failures.push('schema is ' + String(product?.schema)
          + ', this cartridge answers only ' + REQUIRED_SCHEMA);
        return false;
      }
      for (const point of product.connection_points || []) {
        const key = normalise(point.name);
        if (key && !byName.has(key)) byName.set(key, point);
        published.push(point);
        if (point.location) located.push(point);
      }
      state.points = (product.connection_points || []).length;
      state.located = located.length;
      state.counts = product.counts || null;
      state.join = product.join || null;
      state.source = product.source || null;
      state.loaded = true;
      return true;
    } catch (error) {
      state.failures.push('network product: ' + String(error?.message || error));
      return false;
    }
  })();
  state.ready = ready;

  state.byName = (name) => state.loaded
    ? (byName.get(normalise(name)) || null) : null;

  /* The owner product's coordinates are NOT used for anything a reader
     sees. Codex, 202609011852: WBUR's exact-name join binds a different
     West Burton 96.42 km from the project, and exact text equality is not
     exact identity. The Atlas measures on its own substation payload and
     always has; this stays available for callers that want it, marked,
     and the card is proven never to print a distance from here. */
  state.location_join_is_unverified = true;
  state.nearest = (lon, lat, options) => {
    if (!state.loaded) return null;
    const minimumKv = options?.minimumKv ?? 0;
    const limit = options?.limit ?? 1;
    const found = [];