annotepage-client 2.29.0 → 2.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /* ============================================================================
2
2
  annotepage -- the annotation layer, browser side.
3
3
 
4
- Package version : 2.29.0
4
+ Package version : 2.31.0
5
5
  Format version : 2 (see FORMAT.md)
6
6
  Licence : MIT
7
7
 
@@ -16,9 +16,9 @@
16
16
  /* Injected by the build: they come from package.json and from
17
17
  src/styles.css, so that no value is written in two places and can
18
18
  therefore diverge. */
19
- const TOOL_VERSION = "2.29.0";
19
+ const TOOL_VERSION = "2.31.0";
20
20
  const FORMAT = 2;
21
- const STYLES = "/* ============================================================================\n styles.css -- THE STYLES OF THE TOOL, AND OF NO OTHER ELEMENT.\n\n This sheet is INLINED into the served file by the build, then put into the\n tool's shadow root -- as a constructed sheet when the browser can do it, in\n a <style> otherwise. It was loaded by a <link> in the original tool; the\n move to a CDN under SRI brought it inside the file, so that there is only\n one digest to keep up to date. The containment itself has not changed, and\n is still twofold:\n\n - from the tool towards the site: no rule from here can reach an element\n of the host site, the browser sees to that. That is what makes the\n claim \"the layer touches nothing\" checkable rather than promised;\n - from the site towards the tool: no rule of the site can reach an\n element here. A redesign of the site's stylesheet therefore cannot\n distort the tool, nor the other way round.\n\n The \"ap-\" prefix on every class is the third safeguard: the day somebody\n loads these styles WITHOUT a shadow root -- by mistake, or to debug --\n nothing would answer a selector of the site.\n\n NO RULE TARGETS html, body, * OR ANY SELECTOR OF THE SITE. That is the one\n absolute prohibition of this file.\n\n COLOURS: the tool has its OWN palette, defined on the shadow root. It\n reads neither the site's variables nor its theme attribute: it has no\n reason to know how the site names its colours, and it must stay readable\n on a light site as on a dark one. The switch follows the system\n preference, the only information the tool has without asking anyone.\n ============================================================================ */\n\n\n:host {\n --ap-bg: #ffffff;\n --ap-bg-soft: #f4f6f8;\n --ap-bg-raised: #e9edf2;\n --ap-text: #1a1d21;\n --ap-text-soft: #5b6570;\n --ap-border: #d5dbe2;\n --ap-accent: #2f6fed;\n --ap-accent-dark: #1d55c8;\n --ap-accent-text: #ffffff;\n --ap-accent-veil: rgba(47, 111, 237, 0.14);\n --ap-alert-bg: #fdeceb;\n --ap-alert-border: #e3a9a4;\n --ap-alert-text: #8a1f16;\n /* THE TWO STATES A REMARK CAN BE IN ONCE IT IS ANSWERED, as tokens rather\n than as literals. They were literals, written once inside the card's\n state mark -- which meant the dark theme drew them at the LIGHT theme's\n ink: measured, 2.42:1 for \"resolved\" and 2.02:1 against the veil they\n sit on, where WCAG 1.4.3 asks 4.5. Below they are 4.68 and 5.23 in the\n light theme, 6.43 and 6.64 in the dark one, on the same composite.\n\n `pending` is the state that must never be mistaken for done: resolved,\n but not deployed -- the defect is still on the reader's screen. `fill`\n is the same colour asked to carry --ap-accent-text on top of it, for the\n badge on the page: 5.93:1 in light, 10.14:1 in dark. */\n --ap-done-ink: #0f7a52;\n --ap-done-veil: rgba(16, 185, 129, 0.14);\n --ap-pending-ink: #8a5a00;\n --ap-pending-veil: rgba(245, 158, 11, 0.16);\n --ap-pending-fill: #8a5a00;\n --ap-shadow: 0 6px 24px rgba(16, 24, 40, 0.18);\n --ap-radius: 10px;\n --ap-font: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\",\n Arial, sans-serif;\n}\n\n@media (prefers-color-scheme: dark) {\n :host {\n --ap-bg: #1d2126;\n --ap-bg-soft: #262b32;\n --ap-bg-raised: #323942;\n --ap-text: #e9ecf0;\n --ap-text-soft: #a4adb8;\n --ap-border: #3a424c;\n --ap-accent: #6d9bff;\n --ap-accent-dark: #8fb4ff;\n --ap-accent-text: #10151c;\n --ap-accent-veil: rgba(109, 155, 255, 0.18);\n --ap-alert-bg: #3a1f1c;\n --ap-alert-border: #7c3a33;\n --ap-alert-text: #ffb9b1;\n --ap-done-ink: #56d3a0;\n --ap-done-veil: rgba(16, 185, 129, 0.18);\n --ap-pending-ink: #f0b757;\n --ap-pending-veil: rgba(245, 158, 11, 0.16);\n --ap-pending-fill: #f0b757;\n --ap-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);\n }\n}\n\n/* ----------------------------------------------------------------------------\n The layer.\n\n It covers the viewport and receives NO click: that is what lets the page\n behave exactly as usual as long as the tool is not in annotation mode.\n Each widget re-enables clicks for itself alone.\n ---------------------------------------------------------------------------- */\n\n.ap-layer {\n position: absolute;\n inset: 0;\n pointer-events: none;\n font-family: var(--ap-font);\n font-size: 14px;\n line-height: 1.45;\n color: var(--ap-text);\n text-align: left;\n -webkit-font-smoothing: antialiased;\n}\n\n.ap-layer button,\n.ap-layer input,\n.ap-layer textarea {\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n box-sizing: border-box;\n}\n\n/* ----------------------------------------------------------------------------\n The button: the only thing visible when the tool is at rest.\n ---------------------------------------------------------------------------- */\n\n.ap-button {\n position: fixed;\n right: 16px;\n bottom: 16px;\n display: inline-flex;\n align-items: center;\n gap: 8px;\n padding: 9px 14px;\n border: 1px solid var(--ap-border);\n border-radius: 999px;\n background: var(--ap-bg);\n color: var(--ap-text);\n box-shadow: var(--ap-shadow);\n cursor: pointer;\n pointer-events: auto;\n opacity: 0.92;\n transition: opacity 0.15s ease, transform 0.15s ease;\n}\n\n.ap-button:hover,\n.ap-button:focus-visible {\n opacity: 1;\n transform: translateY(-1px);\n}\n\n.ap-button:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n.ap-button[aria-pressed=\"true\"] {\n background: var(--ap-accent);\n border-color: var(--ap-accent);\n color: var(--ap-accent-text);\n opacity: 1;\n}\n\n.ap-button-dot {\n display: inline-block;\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--ap-accent);\n flex: none;\n}\n\n.ap-button[aria-pressed=\"true\"] .ap-button-dot {\n background: var(--ap-accent-text);\n}\n\n.ap-button-count {\n padding: 1px 7px;\n border-radius: 999px;\n background: var(--ap-bg-raised);\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-button[aria-pressed=\"true\"] .ap-button-count {\n background: rgba(255, 255, 255, 0.22);\n color: var(--ap-accent-text);\n}\n\n/* ----------------------------------------------------------------------------\n The pointing highlight.\n\n It is DRAWN HERE, from the coordinates of the element being pointed at.\n Nothing is put on the element itself: no class, no attribute, no style. So\n the site cannot move by a single pixel because of the pointing.\n ---------------------------------------------------------------------------- */\n\n.ap-highlight {\n position: fixed;\n border: 2px solid var(--ap-accent);\n border-radius: 3px;\n background: var(--ap-accent-veil);\n pointer-events: none;\n display: none;\n}\n\n.ap-highlight-label {\n position: fixed;\n max-width: 320px;\n padding: 4px 8px;\n border-radius: 6px;\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-size: 12px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n pointer-events: none;\n display: none;\n box-shadow: var(--ap-shadow);\n}\n\n/* ----------------------------------------------------------------------------\n The markers: \"there are already notes here\".\n ---------------------------------------------------------------------------- */\n\n.ap-marker {\n position: fixed;\n min-width: 22px;\n height: 22px;\n padding: 0 6px;\n border: 2px solid var(--ap-bg);\n border-radius: 999px;\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-size: 12px;\n font-weight: 700;\n line-height: 18px;\n text-align: center;\n cursor: pointer;\n pointer-events: auto;\n box-shadow: var(--ap-shadow);\n}\n\n/* THE STATE, IN THE BADGE ITSELF. The rule above is the OPEN state -- work to\n do -- and it stays the tool's accent, because that is what a badge on a page\n has always meant here. The other two are read against it:\n\n pending filled amber. Resolved, not deployed: the defect is still on the\n screen the reader is looking at, and it is the one state worth\n catching an eye that was not looking for it.\n done hollow, in the soft ink. History: there, countable, and not\n asking for anything.\n\n THE COLOUR IS NEVER ALONE. The count is written in the badge and the state\n is spelled out in its accessible name -- a badge that said \"still to fix\"\n by hue only would say nothing at all to a good part of its readers. */\n.ap-marker-pending {\n background: var(--ap-pending-fill);\n}\n.ap-marker-done {\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-weight: 600;\n /* The 2px border is the halo against the page and cannot be spent on the\n outline, so the outline is drawn inside. */\n box-shadow: var(--ap-shadow), inset 0 0 0 1px var(--ap-border);\n}\n\n.ap-marker:focus-visible {\n outline: 2px solid var(--ap-accent-dark);\n outline-offset: 2px;\n}\n\n/* ----------------------------------------------------------------------------\n The panel.\n ---------------------------------------------------------------------------- */\n\n.ap-panel {\n position: fixed;\n top: 12px;\n right: 12px;\n bottom: 72px;\n width: 360px;\n max-width: calc(100vw - 24px);\n display: none;\n flex-direction: column;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n box-shadow: var(--ap-shadow);\n pointer-events: auto;\n overflow: hidden;\n}\n\n.ap-panel.ap-open {\n display: flex;\n}\n\n/* The other side. Two positions, right and left, and no third one: in\n annotation mode the layer takes every click, so every pixel of panel is a\n pixel of page that can no longer be pointed at. A floating panel would\n only move that loss around.\n\n \"bottom\" IS NOT REDECLARED, on purpose: the panel keeps the same 72 px of\n clearance above the floating button either way, and that clearance is the\n same on both sides because the button moves WITH it.\n\n AND THE BUTTON MOVES WITH IT, which was decided the other way first. The\n argument for leaving it was that it is the tool's only visible trace at\n rest, so an anchor that moved would stop being one. The owner's answer,\n and it is the better one: \"move left\" is asked of the TOOL, not of half of\n it. A panel on one edge and the control that opens it on the other makes\n the eye cross the whole window for one gesture, and somebody who set the\n side set it for the tool.\n\n TWO THINGS THIS RULE DEPENDS ON, both fragile:\n - it is written with ONE class, so it weighs exactly what \".ap-panel\"\n weighs;\n - it is written BEFORE the narrow block below.\n Reverse either and it wins under 560 px, where the panel is a bottom band\n spanning the width -- and a panel pinned to the left there is the full-\n height panel whose defect at 375 px is described in that block. */\n.ap-left {\n right: auto;\n left: 12px;\n}\n/* The button follows, and it is put on the LAYER and not on the panel: the\n button is not inside the panel, so the side has to be readable from a\n common ancestor. Same offset mirrored, same bottom -- only the edge\n changes. */\n.ap-layer.ap-left-side .ap-button {\n right: auto;\n left: 16px;\n}\n\n.ap-panel-header {\n display: flex;\n align-items: baseline;\n gap: 8px;\n padding: 12px 14px;\n border-bottom: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n}\n\n.ap-panel-title {\n font-size: 15px;\n font-weight: 600;\n flex: 1 1 auto;\n}\n\n/* -- what the whole project holds ---------------------------------------\n THE FIRST LINE OF THE FOOTER, on its own row. The footer is a flex row of\n short things -- a name, two buttons -- so this takes the whole width and the\n rest wraps under it. No ground and no border of its own: it is IN the footer,\n not beside it. */\n/* The retention line, when there is one. `:empty` rather than a class the\n script has to add and remove: the element is always there, and CSS decides\n whether it takes any room -- so a server that deletes nothing costs the\n panel exactly nothing. */\n.ap-panel-keeps { margin-top: 6px; color: var(--ap-text-soft); }\n.ap-panel-keeps:empty { display: none; }\n\n.ap-panel-footer { flex-wrap: wrap; }\n\n/* WHO YOU ARE SIGNING AS, ON A LINE OF ITS OWN. `flex-basis: 100%` is the same\n device the block above uses, and for the same reason: the footer is one\n wrapping row and everything in it was being strung end to end. */\n.ap-foot-who {\n flex-basis: 100%;\n display: flex; align-items: baseline; gap: 8px;\n}\n\n/* -- the list of remarks -------------------------------------------------\n A ROW, AND EVERY ROW IS A BUTTON. Not a card with a link in it: the whole\n line is the target, which is what a list of things to open should be, and it\n is reachable with a keyboard for free.\n\n THE EXCERPT TAKES THE ROOM AND FOLDS TO ONE LINE. What a remark is about can\n be a paragraph; what a list can show is a line. The author keeps a fixed\n place at the end so the eye can run down it. */\n.ap-row {\n display: flex; align-items: baseline; gap: 8px;\n width: 100%; margin: 0 0 4px; padding: 8px 10px;\n border: 1px solid var(--ap-border); border-radius: 8px;\n background: var(--ap-bg); color: var(--ap-text);\n font: inherit; text-align: left; cursor: pointer;\n transition: border-color .15s ease, background-color .15s ease;\n}\n.ap-row:hover { background: var(--ap-bg-soft); border-color: var(--ap-accent); }\n.ap-row:focus-visible { outline: 2px solid var(--ap-accent); outline-offset: 2px; }\n.ap-row-about {\n flex: 1; min-width: 0;\n overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n}\n.ap-row-who { flex: none; font-size: 12px; color: var(--ap-text-soft); }\n/* THE STATE, AS A DOT. Three of them, and the middle one is the one that must\n not read as done: resolved but not deployed is a defect still on screen. The\n accessible name spells all three out -- a colour is not a fact for\n everybody. */\n.ap-row-dot {\n flex: none; width: 8px; height: 8px; border-radius: 999px;\n background: var(--ap-accent); align-self: center;\n}\n.ap-row-pending .ap-row-dot { background: var(--ap-text-soft); }\n.ap-row-done .ap-row-dot { background: transparent; border: 1px solid var(--ap-border); }\n.ap-row-done .ap-row-about { color: var(--ap-text-soft); }\n@media (prefers-reduced-motion: reduce) { .ap-row { transition: none; } }\n\n/* -- a window that is not the panel --------------------------------------\n IT FLOATS OVER THE PAGE, and that is the point: the panel is a band down one\n edge, and what goes in here is not about the page beside it. Fixed rather\n than absolute -- the reader scrolls the page under it, and a window that\n scrolled away with the article would have to be chased.\n\n ABOVE THE PANEL AND BELOW NOTHING. It is opened from the panel's footer, so\n it must cover it; the tool's own layer already sits above the site.\n\n WIDTH: it is read, not filled in. 26rem is a paragraph, and min() keeps it\n inside a phone without a media query. */\n.ap-pop {\n position: fixed; z-index: 3;\n /* THE LAYER IS `pointer-events: none` so the site underneath keeps working,\n and every piece that must be reachable turns it back on. Without this\n line the window is a picture: no click on its buttons, and no drag on its\n bar -- which is exactly how it behaved when first measured. */\n pointer-events: auto;\n width: min(26rem, calc(100vw - 24px));\n max-height: calc(100vh - 24px);\n display: flex; flex-direction: column;\n border: 1px solid var(--ap-border); border-radius: 12px;\n background: var(--ap-bg); color: var(--ap-text);\n box-shadow: 0 18px 48px rgba(0, 0, 0, .22);\n overflow: hidden;\n}\n/* THE HANDLE. `touch-action: none` is what makes a finger drag the window\n instead of scrolling the page under it -- without it the browser claims the\n gesture before the first pointermove arrives. */\n.ap-pop-bar {\n display: flex; align-items: center; gap: 8px;\n padding: 8px 12px;\n border-bottom: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n cursor: grab; touch-action: none; user-select: none;\n}\n.ap-pop-moving .ap-pop-bar { cursor: grabbing; }\n.ap-pop-title { flex: 1; font-size: 13px; font-weight: 650; }\n/* `min-height: 0` is what makes the scroll happen INSIDE the window rather\n than the window growing past its own height: a flex item does not shrink\n below its content without it, and the end of a long remark would be behind\n the bottom edge with nothing to scroll. */\n.ap-pop-body { flex: 1 1 auto; min-height: 0; padding: 12px; overflow: auto; }\n/* The one line that says why the page stayed where it was. Drawn as the panel\n draws its own help text, not as an alert: nothing has gone wrong. */\n.ap-why {\n margin: 0 0 10px; padding: 8px 10px;\n border-radius: 8px; background: var(--ap-bg-soft);\n color: var(--ap-text-soft); font-size: 12.5px;\n}\n/* THE CORNER, AND IT IS DRAWN RATHER THAN LEFT TO THE BROWSER. `resize: both`\n would have done this in one line and does nothing under a finger on iOS; the\n window is moved with pointer events for exactly that reason, and it is\n resized with them too. Two hairlines, the shape everybody already reads as a\n grip, in the same ink as the borders around it. */\n.ap-pop-grip {\n position: absolute; right: 0; bottom: 0;\n width: 18px; height: 18px;\n cursor: nwse-resize; touch-action: none;\n background:\n linear-gradient(135deg, transparent 42%, var(--ap-border) 42%,\n var(--ap-border) 54%, transparent 54%),\n linear-gradient(135deg, transparent 66%, var(--ap-border) 66%,\n var(--ap-border) 78%, transparent 78%);\n}\n.ap-pop-sizing { user-select: none; }\n.ap-pop-sizing .ap-pop-grip { cursor: nwse-resize; }\n/* Inside a window, the block is the window: no second frame around it. */\n.ap-pop-body .ap-config { margin: 0; padding: 0; border: 0; background: none; }\n.ap-pop-body .ap-forget { margin: 0; }\n.ap-pop-body .ap-panel-stats { margin: 0; }\n.ap-pop-body .ap-stats { margin: 0; }\n/* A WINDOW HAS ROOM, SO THE FILE GETS IT. In the panel this field was two or\n four lines because the column had nothing to spare; here it can show the\n whole thing without being scrolled. */\n.ap-pop-body .ap-code { min-height: 9.5em; }\n\n/* -- the file the assistant needs ---------------------------------------\n Drawn like the other block the panel opens in its body -- a title, a\n sentence, the thing itself, two buttons -- so nothing here is a new shape to\n learn. The last line is the warning, and it is a line and not a dialog: the\n reviewer asked for this file. */\n.ap-config {\n margin: 10px 0 0; padding: 12px;\n border: 1px solid var(--ap-border); border-radius: 10px;\n background: var(--ap-bg-soft);\n}\n/* The warning is a line at the tool's own soft ink, not in an alert colour:\n the reviewer asked for this file, they are not being warned off it. There is\n no --ap-warn token and this does not invent one. */\n.ap-config .ap-warn { margin-top: 10px; }\n.ap-panel-stats {\n flex-basis: 100%;\n display: flex; flex-wrap: wrap; gap: 4px 18px;\n margin-bottom: 4px;\n}\n.ap-stat { display: inline-flex; align-items: baseline; gap: 5px; }\n/* The row says what it counts, once, and the three figures follow it. Without\n it, \"3 / 2 / 1\" beside a panel about one page reads as being about that\n page. */\n.ap-stat-label {\n flex-basis: 100%; margin-bottom: 2px;\n font-size: 11px; font-weight: 650; letter-spacing: .02em;\n text-transform: uppercase; color: var(--ap-text-soft);\n}\n.ap-stat-n { font-size: 15px; font-weight: 650; color: var(--ap-text); }\n.ap-stat-w { font-size: 12px; color: var(--ap-text-soft); }\n/* TWO BLOCKS, THIS SITE THEN THE WHOLE SERVER, and the second is absent on\n nearly every server. Each block is a label, the figures it holds, and -- when\n age takes anything here -- a second row for what it took. */\n.ap-stats { display: flex; flex-direction: column; gap: 16px; }\n.ap-stats-block { display: flex; flex-direction: column; gap: 4px; }\n.ap-stats .ap-panel-stats { margin-bottom: 0; }\n/* WHAT WAS REMOVED READS AS A FOOTNOTE TO THE ROW ABOVE, not as a second set of\n figures competing with it: same shapes, one step quieter, and indented under\n the count it belongs to. */\n.ap-stat-gone { padding-left: 10px; border-left: 2px solid var(--ap-border); }\n.ap-stat-gone .ap-stat-n { font-size: 13px; font-weight: 600; color: var(--ap-text-soft); }\n.ap-stat-since {\n font-size: 11px; font-weight: 650; letter-spacing: .02em;\n text-transform: uppercase; color: var(--ap-text-soft); align-self: baseline;\n}\n/* The date of the last sweep is context for the figures beside it, not another\n figure: soft ink, smaller, and it wraps under them rather than stretching\n the row. */\n.ap-stat-when { font-size: 12px; color: var(--ap-text-soft); align-self: baseline; }\n.ap-panel-instructions {\n padding: 10px 14px;\n border-bottom: 1px solid var(--ap-border);\n color: var(--ap-text-soft);\n font-size: 13px;\n}\n\n.ap-panel-body {\n flex: 1 1 auto;\n overflow-y: auto;\n overscroll-behavior: contain;\n padding: 4px 14px 14px;\n}\n\n.ap-panel-footer {\n padding: 8px 14px;\n border-top: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 12px;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.ap-section-title {\n margin: 14px 0 6px;\n color: var(--ap-text-soft);\n font-size: 12px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n}\n\n.ap-section-help {\n margin: 0 0 8px;\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-empty {\n margin: 16px 0;\n color: var(--ap-text-soft);\n}\n\n/* ----------------------------------------------------------------------------\n THE MODE BADGE: one word, drawn in both modes, at the top of every draw.\n\n It replaced a paragraph that only the public mode ever drew. Two things\n were wrong with that: secure mode said nothing, so the panel never told a\n reviewer which of the two they were in; and a paragraph pinned to the top\n for ever is skipped after the second reading, while a single word is not.\n\n IT IS NOT A BUTTON AND MUST NOT LOOK LIKE ONE. No shadow, no pressed\n state, cursor stays default: there is nothing to press. What it does have\n is a focus ring, because it takes focus -- the description below has to be\n reachable without a pointer, and that is the only reason it is focusable.\n ---------------------------------------------------------------------------- */\n\n.ap-mode {\n /* The frame the description is positioned against. It spans the width of\n the panel body, so a description pinned to its two edges cannot spill\n sideways out of a body that scrolls -- and a scrolling body clips both\n axes, not just the one it scrolls. */\n position: relative;\n margin: 4px 0 10px;\n}\n\n.ap-mode-chip {\n display: inline-block;\n padding: 2px 9px 3px;\n border: 1px solid var(--ap-border);\n border-radius: 999px;\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 11px;\n font-weight: 600;\n letter-spacing: 0.05em;\n text-transform: uppercase;\n cursor: default;\n}\n\n/* The public badge is the one that carries a consequence, so it is the one\n that is coloured -- in the tool's own accent, not in the alert colours: a\n public key is a choice somebody made on purpose, not an incident. Secure\n keeps the quiet frame: it is the case where nothing is being said. */\n/* The same ring as every other focusable thing in the panel. It is the only\n visual proof, for somebody arriving by Tab, that this word is where their\n focus went. */\n.ap-mode-chip:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n/* Plain wears the same coat as public, and for the same reason: both are a\n choice somebody made on purpose, and both carry a consequence for whoever\n is about to write. Neither is an incident, so neither takes an alert\n colour. They cannot both be true at once. */\n.ap-mode-public .ap-mode-chip,\n.ap-mode-plain .ap-mode-chip {\n border-color: var(--ap-accent);\n background: var(--ap-accent-veil);\n color: var(--ap-accent-dark);\n}\n\n/* The description. Hidden by DEFAULT and shown on demand, and hidden in a way\n that leaves it readable to a screen reader: it is the badge's\n aria-describedby target, and an accessible description is computed from the\n referenced element whether or not it is painted. It is taken out of the\n layout entirely (absolute) so that showing it moves not one pixel of the\n list underneath -- a tooltip that pushes the notes down is a tooltip that\n makes people lose their place. */\n.ap-mode-tip {\n position: absolute;\n z-index: 2;\n top: calc(100% + 6px);\n left: 0;\n right: 0;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg-raised);\n color: var(--ap-text);\n box-shadow: var(--ap-shadow);\n font-size: 12px;\n font-weight: 400;\n letter-spacing: normal;\n text-transform: none;\n line-height: 1.45;\n opacity: 0;\n visibility: hidden;\n transform: translateY(-3px);\n transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s linear 0.12s;\n pointer-events: none;\n}\n\n/* BOTH, and the keyboard one is not the afterthought: :focus-visible is what\n makes the sentence reachable by somebody who never touches a pointer. */\n.ap-mode-chip:hover ~ .ap-mode-tip,\n.ap-mode-chip:focus-visible ~ .ap-mode-tip {\n opacity: 1;\n visibility: visible;\n transform: none;\n transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ap-mode-tip {\n transform: none;\n transition: none;\n }\n .ap-mode-chip:hover ~ .ap-mode-tip,\n .ap-mode-chip:focus-visible ~ .ap-mode-tip {\n transition: none;\n }\n}\n\n/* The \"a newer client exists\" line and the \"this server speaks another\n format\" line are the same object on screen: a standing statement about what\n one is looking at, above the notes and above the failures. One rule, so\n they cannot drift apart -- and the second one joins it rather than\n inventing a colour, precisely because a protocol disagreement is a fact\n about the project, not an incident.\n\n Deliberately NOT the alert colours: neither is a failure, and an alarm that\n never goes away stops being read. */\n.ap-upgrade,\n.ap-format {\n margin: 0 0 10px;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 12px;\n line-height: 1.45;\n}\n\n/* ----------------------------------------------------------------------------\n A note, and its replies.\n ---------------------------------------------------------------------------- */\n\n.ap-note {\n margin: 8px 0;\n padding: 10px 12px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n}\n\n.ap-note.ap-orphan {\n background: var(--ap-bg-soft);\n}\n\n\n.ap-note-header {\n display: flex;\n align-items: baseline;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-note-author {\n font-weight: 600;\n}\n\n.ap-note-date {\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-note-target {\n margin: 4px 0 0;\n color: var(--ap-text-soft);\n font-size: 12px;\n font-style: italic;\n overflow-wrap: anywhere;\n}\n\n.ap-note-text {\n margin: 6px 0 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n.ap-note-actions {\n margin-top: 8px;\n display: flex;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-replies {\n margin: 8px 0 0;\n padding-left: 10px;\n border-left: 2px solid var(--ap-border);\n}\n\n.ap-reply {\n margin: 8px 0 0;\n}\n\n/* ----------------------------------------------------------------------------\n The form, anchored near the element pointed at.\n ---------------------------------------------------------------------------- */\n\n.ap-form {\n position: fixed;\n width: 340px;\n max-width: calc(100vw - 24px);\n display: none;\n flex-direction: column;\n gap: 8px;\n padding: 14px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n box-shadow: var(--ap-shadow);\n pointer-events: auto;\n}\n\n.ap-form.ap-open {\n display: flex;\n}\n\n.ap-form-title {\n font-size: 15px;\n font-weight: 600;\n}\n\n.ap-form-target {\n color: var(--ap-text-soft);\n font-size: 12px;\n font-style: italic;\n overflow-wrap: anywhere;\n}\n\n.ap-label {\n display: block;\n margin-bottom: 3px;\n font-size: 12px;\n font-weight: 600;\n color: var(--ap-text-soft);\n}\n\n.ap-help {\n margin: 3px 0 0;\n font-size: 12px;\n color: var(--ap-text-soft);\n}\n\n.ap-field,\n.ap-area {\n width: 100%;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 8px;\n background: var(--ap-bg-soft);\n color: var(--ap-text);\n}\n\n.ap-field:focus,\n.ap-area:focus {\n outline: 2px solid var(--ap-accent);\n outline-offset: 1px;\n}\n\n.ap-area {\n min-height: 92px;\n resize: vertical;\n}\n\n.ap-actions {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-counter {\n margin-left: auto;\n font-size: 12px;\n color: var(--ap-text-soft);\n}\n\n/* ----------------------------------------------------------------------------\n Buttons.\n ---------------------------------------------------------------------------- */\n\n.ap-primary,\n.ap-secondary,\n.ap-link {\n border-radius: 8px;\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ap-primary {\n padding: 8px 14px;\n border: 1px solid var(--ap-accent);\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-weight: 600;\n}\n\n.ap-primary:hover {\n background: var(--ap-accent-dark);\n border-color: var(--ap-accent-dark);\n}\n\n.ap-secondary {\n padding: 8px 14px;\n border: 1px solid var(--ap-border);\n background: var(--ap-bg);\n color: var(--ap-text);\n}\n\n.ap-secondary:hover {\n background: var(--ap-bg-raised);\n}\n\n.ap-link {\n padding: 2px 4px;\n border: 0;\n background: none;\n color: var(--ap-accent);\n text-decoration: underline;\n font-size: 13px;\n}\n\n.ap-primary:disabled,\n.ap-secondary:disabled,\n.ap-link:disabled {\n opacity: 0.6;\n cursor: default;\n}\n\n.ap-primary:focus-visible,\n.ap-secondary:focus-visible,\n.ap-link:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n/* ----------------------------------------------------------------------------\n The failures.\n\n They are RED, at the top of the block concerned, and carry the message the\n server returned as it stands: that is how a non-technical team learns that\n its remark is not saved, instead of believing it is.\n ---------------------------------------------------------------------------- */\n\n.ap-error {\n margin: 8px 0;\n padding: 10px 12px;\n border: 1px solid var(--ap-alert-border);\n border-radius: var(--ap-radius);\n background: var(--ap-alert-bg);\n color: var(--ap-alert-text);\n}\n\n.ap-error-title {\n font-weight: 700;\n margin-bottom: 4px;\n}\n\n.ap-error-detail {\n margin: 6px 0 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n font-size: 13px;\n}\n\n.ap-error .ap-link {\n color: var(--ap-alert-text);\n}\n\n/* ----------------------------------------------------------------------------\n Narrow: the panel takes the full width, and so does the form.\n ---------------------------------------------------------------------------- */\n\n/* ----------------------------------------------------------------------------\n Narrow.\n\n DEFECT OBSERVED at 375 px wide: a panel taking the full height covers the\n whole page, and no element can be pointed at any more -- every click lands\n on the panel. So it becomes a bottom band, which leaves the top half of\n the viewport free; one scrolls the page there to bring the wanted element\n into view. The form, for its part, hides the panel while typing (see\n notes.js): on a screen that size, writing and reading the list at the same\n time does not hold.\n ---------------------------------------------------------------------------- */\n\n/* On a narrow screen the panel becomes a bottom band and the form takes the\n full width.\n\n THE WIDTH CEILING IS KEPT, and it comes from a measured defect: \"left: 8;\n right: 8\" sizes the element against its CONTAINING BLOCK, which the host\n site's horizontal overflow can make wider than the visible window.\n Measured, in mobile emulation at 390 px: the site overflows to 407 px\n (with the tool and without it), and the panel came out 391 px wide\n starting at 8, that is 9 px off screen. \"100vw\" is the window, not the\n containing block: the ceiling therefore does nothing when the site does\n not overflow, and pulls the width back when it does. */\n@media (max-width: 560px) {\n .ap-panel {\n top: auto;\n right: 8px;\n left: 8px;\n bottom: 66px;\n height: 52vh;\n width: auto;\n max-width: calc(100vw - 16px);\n }\n\n /* A band spanning the width has no side, so the choice is inert here and\n the button says so by not being there. Offering a control that visibly\n does nothing is worse than offering none. The stored side is untouched:\n it is waiting for the wide screen it was chosen on. */\n .ap-side-toggle {\n display: none;\n }\n\n .ap-form {\n left: 8px;\n right: 8px;\n width: auto;\n max-width: calc(100vw - 16px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ap-button {\n transition: none;\n }\n}\n\n/* The failure shows without opening the panel: the button's dot changes\n colour. A team that does not click must be able to see that something is\n wrong. */\n.ap-button.ap-failed .ap-button-dot {\n background: var(--ap-alert-text);\n}\n\n.ap-button.ap-failed {\n border-color: var(--ap-alert-border);\n}\n\n/* Signature reminder, in the note form.\n The name was shown at the foot of the panel only: invisible at the moment\n one writes. A user reported not knowing which name they were writing\n under. */\n.ap-form-signature {\n display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;\n margin: 0 0 .6rem; font-size: .85rem; opacity: .8;\n}\n\n/* Resolution state, said on the card.\n Two cases NOT to be confused: resolved and online, resolved but not\n deployed yet. The second keeps the defect on the reviewer's screen; hiding\n it or announcing it as fixed would cost them their trust in the tool. */\n.ap-state-mark {\n display: inline-block; margin: 0 0 .5rem;\n padding: .15rem .55rem; border-radius: 4px;\n font-size: .75rem; font-weight: 600; letter-spacing: .02em;\n}\n.ap-note.ap-resolved { opacity: .72; }\n.ap-note.ap-resolved .ap-state-mark {\n color: var(--ap-done-ink); background: var(--ap-done-veil);\n}\n.ap-note.ap-resolved-pending .ap-state-mark {\n color: var(--ap-pending-ink); background: var(--ap-pending-veil);\n}\n/* The \"it is fixed\" / \"reopen\" block, opened under the card. Same shape as\n the reply block: it is the same gesture, one answers a remark. */\n.ap-resolve,\n.ap-reply-form {\n margin-top: .6rem;\n padding-top: .6rem;\n border-top: 1px solid var(--ap-border);\n}\n\n/* The question asked before the key is dropped, at the foot of the list.\n Framed like the resolution block -- it is the same shape of gesture, one\n answers before something changes -- and set apart from the notes above it,\n because it is not about a note. */\n.ap-forget {\n margin-top: 1rem;\n padding-top: .6rem;\n border-top: 1px solid var(--ap-border);\n}\n\n.ap-forget .ap-actions {\n margin-top: .5rem;\n}\n\n.ap-history-toggle {\n display: block; width: 100%; margin: 1rem 0 .25rem;\n padding: .5rem .75rem; border: 1px dashed currentColor; border-radius: 6px;\n background: none; color: inherit; font: inherit; opacity: .7; cursor: pointer;\n}\n.ap-history-toggle:hover { opacity: 1; }\n\n\n/* ----------------------------------------------------------------------------\n Setup and pasting the salt.\n\n These are the only screens where something is copied by hand. Everything\n there is SELECTABLE and monospaced: a 43-character salt copied wrong\n cannot be recovered, and nothing helps less than a font that confuses I, l\n and 1.\n ---------------------------------------------------------------------------- */\n\n.ap-panel-wide {\n width: 560px;\n}\n\n.ap-copy {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n margin: 0 0 12px;\n}\n\n.ap-code {\n flex: 1 1 auto;\n width: 100%;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 8px;\n background: var(--ap-bg-soft);\n color: var(--ap-text);\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, \"Liberation Mono\",\n monospace;\n font-size: 12.5px;\n line-height: 1.5;\n resize: vertical;\n white-space: pre;\n overflow-x: auto;\n}\n\n.ap-code:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 1px;\n}\n\n@media (max-width: 560px) {\n .ap-panel-wide {\n width: auto;\n }\n\n .ap-copy {\n flex-direction: column;\n }\n}\n";
21
+ const STYLES = "/* ============================================================================\n styles.css -- THE STYLES OF THE TOOL, AND OF NO OTHER ELEMENT.\n\n This sheet is INLINED into the served file by the build, then put into the\n tool's shadow root -- as a constructed sheet when the browser can do it, in\n a <style> otherwise. It was loaded by a <link> in the original tool; the\n move to a CDN under SRI brought it inside the file, so that there is only\n one digest to keep up to date. The containment itself has not changed, and\n is still twofold:\n\n - from the tool towards the site: no rule from here can reach an element\n of the host site, the browser sees to that. That is what makes the\n claim \"the layer touches nothing\" checkable rather than promised;\n - from the site towards the tool: no rule of the site can reach an\n element here. A redesign of the site's stylesheet therefore cannot\n distort the tool, nor the other way round.\n\n The \"ap-\" prefix on every class is the third safeguard: the day somebody\n loads these styles WITHOUT a shadow root -- by mistake, or to debug --\n nothing would answer a selector of the site.\n\n NO RULE TARGETS html, body, * OR ANY SELECTOR OF THE SITE. That is the one\n absolute prohibition of this file.\n\n COLOURS: the tool has its OWN palette, defined on the shadow root. It\n reads neither the site's variables nor its theme attribute: it has no\n reason to know how the site names its colours, and it must stay readable\n on a light site as on a dark one. The switch follows the system\n preference, the only information the tool has without asking anyone.\n ============================================================================ */\n\n\n:host {\n --ap-bg: #ffffff;\n --ap-bg-soft: #f4f6f8;\n --ap-bg-raised: #e9edf2;\n --ap-text: #1a1d21;\n --ap-text-soft: #5b6570;\n --ap-border: #d5dbe2;\n --ap-accent: #2f6fed;\n --ap-accent-dark: #1d55c8;\n --ap-accent-text: #ffffff;\n --ap-accent-veil: rgba(47, 111, 237, 0.14);\n --ap-alert-bg: #fdeceb;\n --ap-alert-border: #e3a9a4;\n --ap-alert-text: #8a1f16;\n /* THE TWO STATES A REMARK CAN BE IN ONCE IT IS ANSWERED, as tokens rather\n than as literals. They were literals, written once inside the card's\n state mark -- which meant the dark theme drew them at the LIGHT theme's\n ink: measured, 2.42:1 for \"resolved\" and 2.02:1 against the veil they\n sit on, where WCAG 1.4.3 asks 4.5. Below they are 4.68 and 5.23 in the\n light theme, 6.43 and 6.64 in the dark one, on the same composite.\n\n `pending` is the state that must never be mistaken for done: resolved,\n but not deployed -- the defect is still on the reader's screen. `fill`\n is the same colour asked to carry --ap-accent-text on top of it, for the\n badge on the page: 5.93:1 in light, 10.14:1 in dark. */\n --ap-done-ink: #0f7a52;\n --ap-done-veil: rgba(16, 185, 129, 0.14);\n --ap-pending-ink: #8a5a00;\n --ap-pending-veil: rgba(245, 158, 11, 0.16);\n --ap-pending-fill: #8a5a00;\n --ap-shadow: 0 6px 24px rgba(16, 24, 40, 0.18);\n --ap-radius: 10px;\n --ap-font: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\",\n Arial, sans-serif;\n}\n\n@media (prefers-color-scheme: dark) {\n :host {\n --ap-bg: #1d2126;\n --ap-bg-soft: #262b32;\n --ap-bg-raised: #323942;\n --ap-text: #e9ecf0;\n --ap-text-soft: #a4adb8;\n --ap-border: #3a424c;\n --ap-accent: #6d9bff;\n --ap-accent-dark: #8fb4ff;\n --ap-accent-text: #10151c;\n --ap-accent-veil: rgba(109, 155, 255, 0.18);\n --ap-alert-bg: #3a1f1c;\n --ap-alert-border: #7c3a33;\n --ap-alert-text: #ffb9b1;\n --ap-done-ink: #56d3a0;\n --ap-done-veil: rgba(16, 185, 129, 0.18);\n --ap-pending-ink: #f0b757;\n --ap-pending-veil: rgba(245, 158, 11, 0.16);\n --ap-pending-fill: #f0b757;\n --ap-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);\n }\n}\n\n/* ----------------------------------------------------------------------------\n The layer.\n\n It covers the viewport and receives NO click: that is what lets the page\n behave exactly as usual as long as the tool is not in annotation mode.\n Each widget re-enables clicks for itself alone.\n ---------------------------------------------------------------------------- */\n\n.ap-layer {\n position: absolute;\n inset: 0;\n pointer-events: none;\n font-family: var(--ap-font);\n font-size: 14px;\n line-height: 1.45;\n color: var(--ap-text);\n text-align: left;\n -webkit-font-smoothing: antialiased;\n}\n\n.ap-layer button,\n.ap-layer input,\n.ap-layer textarea {\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n box-sizing: border-box;\n}\n\n/* ----------------------------------------------------------------------------\n The button: the only thing visible when the tool is at rest.\n ---------------------------------------------------------------------------- */\n\n.ap-button {\n position: fixed;\n right: 16px;\n bottom: 16px;\n display: inline-flex;\n align-items: center;\n gap: 8px;\n padding: 9px 14px;\n border: 1px solid var(--ap-border);\n border-radius: 999px;\n background: var(--ap-bg);\n color: var(--ap-text);\n box-shadow: var(--ap-shadow);\n cursor: pointer;\n pointer-events: auto;\n opacity: 0.92;\n transition: opacity 0.15s ease, transform 0.15s ease;\n}\n\n.ap-button:hover,\n.ap-button:focus-visible {\n opacity: 1;\n transform: translateY(-1px);\n}\n\n.ap-button:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n.ap-button[aria-pressed=\"true\"] {\n background: var(--ap-accent);\n border-color: var(--ap-accent);\n color: var(--ap-accent-text);\n opacity: 1;\n}\n\n.ap-button-dot {\n display: inline-block;\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--ap-accent);\n flex: none;\n}\n\n.ap-button[aria-pressed=\"true\"] .ap-button-dot {\n background: var(--ap-accent-text);\n}\n\n.ap-button-count {\n padding: 1px 7px;\n border-radius: 999px;\n background: var(--ap-bg-raised);\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-button[aria-pressed=\"true\"] .ap-button-count {\n background: rgba(255, 255, 255, 0.22);\n color: var(--ap-accent-text);\n}\n\n/* ----------------------------------------------------------------------------\n The pointing highlight.\n\n It is DRAWN HERE, from the coordinates of the element being pointed at.\n Nothing is put on the element itself: no class, no attribute, no style. So\n the site cannot move by a single pixel because of the pointing.\n ---------------------------------------------------------------------------- */\n\n.ap-highlight {\n position: fixed;\n border: 2px solid var(--ap-accent);\n border-radius: 3px;\n background: var(--ap-accent-veil);\n pointer-events: none;\n display: none;\n}\n\n.ap-highlight-label {\n position: fixed;\n max-width: 320px;\n padding: 4px 8px;\n border-radius: 6px;\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-size: 12px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n pointer-events: none;\n display: none;\n box-shadow: var(--ap-shadow);\n}\n\n/* ----------------------------------------------------------------------------\n The zones a remark can be written in (data-zone), while annotation mode is on.\n\n DISCREET ON PURPOSE: a dashed line and no fill. The page under review is\n what the reviewer is reading, and a veil over every open area would tint\n the very colours they may be writing about. Drawn from coordinates, like\n the highlight: nothing is put on the site's element.\n ---------------------------------------------------------------------------- */\n\n.ap-zone {\n position: fixed;\n border: 1px dashed var(--ap-accent);\n border-radius: 4px;\n opacity: 0.6;\n pointer-events: none;\n box-sizing: border-box;\n}\n\n.ap-zone-notice {\n position: fixed;\n max-width: 280px;\n padding: 6px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 6px;\n background: var(--ap-bg);\n color: var(--ap-text);\n font-size: 13px;\n box-shadow: var(--ap-shadow);\n pointer-events: none;\n display: none;\n}\n\n/* ----------------------------------------------------------------------------\n The markers: \"there are already notes here\".\n ---------------------------------------------------------------------------- */\n\n.ap-marker {\n position: fixed;\n min-width: 22px;\n height: 22px;\n padding: 0 6px;\n border: 2px solid var(--ap-bg);\n border-radius: 999px;\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-size: 12px;\n font-weight: 700;\n line-height: 18px;\n text-align: center;\n cursor: pointer;\n pointer-events: auto;\n box-shadow: var(--ap-shadow);\n}\n\n/* THE STATE, IN THE BADGE ITSELF. The rule above is the OPEN state -- work to\n do -- and it stays the tool's accent, because that is what a badge on a page\n has always meant here. The other two are read against it:\n\n pending filled amber. Resolved, not deployed: the defect is still on the\n screen the reader is looking at, and it is the one state worth\n catching an eye that was not looking for it.\n done hollow, in the soft ink. History: there, countable, and not\n asking for anything.\n\n THE COLOUR IS NEVER ALONE. The count is written in the badge and the state\n is spelled out in its accessible name -- a badge that said \"still to fix\"\n by hue only would say nothing at all to a good part of its readers. */\n.ap-marker-pending {\n background: var(--ap-pending-fill);\n}\n.ap-marker-done {\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-weight: 600;\n /* The 2px border is the halo against the page and cannot be spent on the\n outline, so the outline is drawn inside. */\n box-shadow: var(--ap-shadow), inset 0 0 0 1px var(--ap-border);\n}\n\n.ap-marker:focus-visible {\n outline: 2px solid var(--ap-accent-dark);\n outline-offset: 2px;\n}\n\n/* ----------------------------------------------------------------------------\n The panel.\n ---------------------------------------------------------------------------- */\n\n.ap-panel {\n position: fixed;\n top: 12px;\n right: 12px;\n bottom: 72px;\n width: 360px;\n max-width: calc(100vw - 24px);\n display: none;\n flex-direction: column;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n box-shadow: var(--ap-shadow);\n pointer-events: auto;\n overflow: hidden;\n}\n\n.ap-panel.ap-open {\n display: flex;\n}\n\n/* The other side. Two positions, right and left, and no third one: in\n annotation mode the layer takes every click, so every pixel of panel is a\n pixel of page that can no longer be pointed at. A floating panel would\n only move that loss around.\n\n \"bottom\" IS NOT REDECLARED, on purpose: the panel keeps the same 72 px of\n clearance above the floating button either way, and that clearance is the\n same on both sides because the button moves WITH it.\n\n AND THE BUTTON MOVES WITH IT, which was decided the other way first. The\n argument for leaving it was that it is the tool's only visible trace at\n rest, so an anchor that moved would stop being one. The owner's answer,\n and it is the better one: \"move left\" is asked of the TOOL, not of half of\n it. A panel on one edge and the control that opens it on the other makes\n the eye cross the whole window for one gesture, and somebody who set the\n side set it for the tool.\n\n TWO THINGS THIS RULE DEPENDS ON, both fragile:\n - it is written with ONE class, so it weighs exactly what \".ap-panel\"\n weighs;\n - it is written BEFORE the narrow block below.\n Reverse either and it wins under 560 px, where the panel is a bottom band\n spanning the width -- and a panel pinned to the left there is the full-\n height panel whose defect at 375 px is described in that block. */\n.ap-left {\n right: auto;\n left: 12px;\n}\n/* The button follows, and it is put on the LAYER and not on the panel: the\n button is not inside the panel, so the side has to be readable from a\n common ancestor. Same offset mirrored, same bottom -- only the edge\n changes. */\n.ap-layer.ap-left-side .ap-button {\n right: auto;\n left: 16px;\n}\n\n.ap-panel-header {\n display: flex;\n align-items: baseline;\n gap: 8px;\n padding: 12px 14px;\n border-bottom: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n}\n\n.ap-panel-title {\n font-size: 15px;\n font-weight: 600;\n flex: 1 1 auto;\n}\n\n/* -- what the whole project holds ---------------------------------------\n THE FIRST LINE OF THE FOOTER, on its own row. The footer is a flex row of\n short things -- a name, two buttons -- so this takes the whole width and the\n rest wraps under it. No ground and no border of its own: it is IN the footer,\n not beside it. */\n/* The retention line, when there is one. `:empty` rather than a class the\n script has to add and remove: the element is always there, and CSS decides\n whether it takes any room -- so a server that deletes nothing costs the\n panel exactly nothing. */\n.ap-panel-keeps { margin-top: 6px; color: var(--ap-text-soft); }\n.ap-panel-keeps:empty { display: none; }\n\n.ap-panel-footer { flex-wrap: wrap; }\n\n/* WHO YOU ARE SIGNING AS, ON A LINE OF ITS OWN. `flex-basis: 100%` is the same\n device the block above uses, and for the same reason: the footer is one\n wrapping row and everything in it was being strung end to end. */\n.ap-foot-who {\n flex-basis: 100%;\n display: flex; align-items: baseline; gap: 8px;\n}\n\n/* -- the list of remarks -------------------------------------------------\n A ROW, AND EVERY ROW IS A BUTTON. Not a card with a link in it: the whole\n line is the target, which is what a list of things to open should be, and it\n is reachable with a keyboard for free.\n\n THE EXCERPT TAKES THE ROOM AND FOLDS TO ONE LINE. What a remark is about can\n be a paragraph; what a list can show is a line. The author keeps a fixed\n place at the end so the eye can run down it. */\n.ap-row {\n display: flex; align-items: baseline; gap: 8px;\n width: 100%; margin: 0 0 4px; padding: 8px 10px;\n border: 1px solid var(--ap-border); border-radius: 8px;\n background: var(--ap-bg); color: var(--ap-text);\n font: inherit; text-align: left; cursor: pointer;\n transition: border-color .15s ease, background-color .15s ease;\n}\n.ap-row:hover { background: var(--ap-bg-soft); border-color: var(--ap-accent); }\n.ap-row:focus-visible { outline: 2px solid var(--ap-accent); outline-offset: 2px; }\n.ap-row-about {\n flex: 1; min-width: 0;\n overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n}\n.ap-row-who { flex: none; font-size: 12px; color: var(--ap-text-soft); }\n/* THE STATE, AS A DOT. Three of them, and the middle one is the one that must\n not read as done: resolved but not deployed is a defect still on screen. The\n accessible name spells all three out -- a colour is not a fact for\n everybody. */\n.ap-row-dot {\n flex: none; width: 8px; height: 8px; border-radius: 999px;\n background: var(--ap-accent); align-self: center;\n}\n.ap-row-pending .ap-row-dot { background: var(--ap-text-soft); }\n.ap-row-done .ap-row-dot { background: transparent; border: 1px solid var(--ap-border); }\n.ap-row-done .ap-row-about { color: var(--ap-text-soft); }\n@media (prefers-reduced-motion: reduce) { .ap-row { transition: none; } }\n\n/* -- a window that is not the panel --------------------------------------\n IT FLOATS OVER THE PAGE, and that is the point: the panel is a band down one\n edge, and what goes in here is not about the page beside it. Fixed rather\n than absolute -- the reader scrolls the page under it, and a window that\n scrolled away with the article would have to be chased.\n\n ABOVE THE PANEL AND BELOW NOTHING. It is opened from the panel's footer, so\n it must cover it; the tool's own layer already sits above the site.\n\n WIDTH: it is read, not filled in. 26rem is a paragraph, and min() keeps it\n inside a phone without a media query. */\n.ap-pop {\n position: fixed; z-index: 3;\n /* THE LAYER IS `pointer-events: none` so the site underneath keeps working,\n and every piece that must be reachable turns it back on. Without this\n line the window is a picture: no click on its buttons, and no drag on its\n bar -- which is exactly how it behaved when first measured. */\n pointer-events: auto;\n width: min(26rem, calc(100vw - 24px));\n max-height: calc(100vh - 24px);\n display: flex; flex-direction: column;\n border: 1px solid var(--ap-border); border-radius: 12px;\n background: var(--ap-bg); color: var(--ap-text);\n box-shadow: 0 18px 48px rgba(0, 0, 0, .22);\n overflow: hidden;\n}\n/* THE HANDLE. `touch-action: none` is what makes a finger drag the window\n instead of scrolling the page under it -- without it the browser claims the\n gesture before the first pointermove arrives. */\n.ap-pop-bar {\n display: flex; align-items: center; gap: 8px;\n padding: 8px 12px;\n border-bottom: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n cursor: grab; touch-action: none; user-select: none;\n}\n.ap-pop-moving .ap-pop-bar { cursor: grabbing; }\n.ap-pop-title { flex: 1; font-size: 13px; font-weight: 650; }\n/* `min-height: 0` is what makes the scroll happen INSIDE the window rather\n than the window growing past its own height: a flex item does not shrink\n below its content without it, and the end of a long remark would be behind\n the bottom edge with nothing to scroll. */\n.ap-pop-body { flex: 1 1 auto; min-height: 0; padding: 12px; overflow: auto; }\n/* The one line that says why the page stayed where it was. Drawn as the panel\n draws its own help text, not as an alert: nothing has gone wrong. */\n.ap-why {\n margin: 0 0 10px; padding: 8px 10px;\n border-radius: 8px; background: var(--ap-bg-soft);\n color: var(--ap-text-soft); font-size: 12.5px;\n}\n/* THE CORNER, AND IT IS DRAWN RATHER THAN LEFT TO THE BROWSER. `resize: both`\n would have done this in one line and does nothing under a finger on iOS; the\n window is moved with pointer events for exactly that reason, and it is\n resized with them too. Two hairlines, the shape everybody already reads as a\n grip, in the same ink as the borders around it. */\n.ap-pop-grip {\n position: absolute; right: 0; bottom: 0;\n width: 18px; height: 18px;\n cursor: nwse-resize; touch-action: none;\n background:\n linear-gradient(135deg, transparent 42%, var(--ap-border) 42%,\n var(--ap-border) 54%, transparent 54%),\n linear-gradient(135deg, transparent 66%, var(--ap-border) 66%,\n var(--ap-border) 78%, transparent 78%);\n}\n.ap-pop-sizing { user-select: none; }\n.ap-pop-sizing .ap-pop-grip { cursor: nwse-resize; }\n/* Inside a window, the block is the window: no second frame around it. */\n.ap-pop-body .ap-config { margin: 0; padding: 0; border: 0; background: none; }\n.ap-pop-body .ap-forget { margin: 0; }\n.ap-pop-body .ap-panel-stats { margin: 0; }\n.ap-pop-body .ap-stats { margin: 0; }\n/* A WINDOW HAS ROOM, SO THE FILE GETS IT. In the panel this field was two or\n four lines because the column had nothing to spare; here it can show the\n whole thing without being scrolled. */\n.ap-pop-body .ap-code { min-height: 9.5em; }\n\n/* -- the file the assistant needs ---------------------------------------\n Drawn like the other block the panel opens in its body -- a title, a\n sentence, the thing itself, two buttons -- so nothing here is a new shape to\n learn. The last line is the warning, and it is a line and not a dialog: the\n reviewer asked for this file. */\n.ap-config {\n margin: 10px 0 0; padding: 12px;\n border: 1px solid var(--ap-border); border-radius: 10px;\n background: var(--ap-bg-soft);\n}\n/* The warning is a line at the tool's own soft ink, not in an alert colour:\n the reviewer asked for this file, they are not being warned off it. There is\n no --ap-warn token and this does not invent one. */\n.ap-config .ap-warn { margin-top: 10px; }\n.ap-panel-stats {\n flex-basis: 100%;\n display: flex; flex-wrap: wrap; gap: 4px 18px;\n margin-bottom: 4px;\n}\n.ap-stat { display: inline-flex; align-items: baseline; gap: 5px; }\n/* The row says what it counts, once, and the three figures follow it. Without\n it, \"3 / 2 / 1\" beside a panel about one page reads as being about that\n page. */\n.ap-stat-label {\n flex-basis: 100%; margin-bottom: 2px;\n font-size: 11px; font-weight: 650; letter-spacing: .02em;\n text-transform: uppercase; color: var(--ap-text-soft);\n}\n.ap-stat-n { font-size: 15px; font-weight: 650; color: var(--ap-text); }\n.ap-stat-w { font-size: 12px; color: var(--ap-text-soft); }\n/* TWO BLOCKS, THIS SITE THEN THE WHOLE SERVER, and the second is absent on\n nearly every server. Each block is a label, the figures it holds, and -- when\n age takes anything here -- a second row for what it took. */\n.ap-stats { display: flex; flex-direction: column; gap: 16px; }\n.ap-stats-block { display: flex; flex-direction: column; gap: 4px; }\n.ap-stats .ap-panel-stats { margin-bottom: 0; }\n/* WHAT WAS REMOVED READS AS A FOOTNOTE TO THE ROW ABOVE, not as a second set of\n figures competing with it: same shapes, one step quieter, and indented under\n the count it belongs to. */\n.ap-stat-gone { padding-left: 10px; border-left: 2px solid var(--ap-border); }\n.ap-stat-gone .ap-stat-n { font-size: 13px; font-weight: 600; color: var(--ap-text-soft); }\n.ap-stat-since {\n font-size: 11px; font-weight: 650; letter-spacing: .02em;\n text-transform: uppercase; color: var(--ap-text-soft); align-self: baseline;\n}\n/* The date of the last sweep is context for the figures beside it, not another\n figure: soft ink, smaller, and it wraps under them rather than stretching\n the row. */\n.ap-stat-when { font-size: 12px; color: var(--ap-text-soft); align-self: baseline; }\n.ap-panel-instructions {\n padding: 10px 14px;\n border-bottom: 1px solid var(--ap-border);\n color: var(--ap-text-soft);\n font-size: 13px;\n}\n\n.ap-panel-body {\n flex: 1 1 auto;\n overflow-y: auto;\n overscroll-behavior: contain;\n padding: 4px 14px 14px;\n}\n\n.ap-panel-footer {\n padding: 8px 14px;\n border-top: 1px solid var(--ap-border);\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 12px;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.ap-section-title {\n margin: 14px 0 6px;\n color: var(--ap-text-soft);\n font-size: 12px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n}\n\n.ap-section-help {\n margin: 0 0 8px;\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-empty {\n margin: 16px 0;\n color: var(--ap-text-soft);\n}\n\n/* ----------------------------------------------------------------------------\n THE MODE BADGE: one word, drawn in both modes, at the top of every draw.\n\n It replaced a paragraph that only the public mode ever drew. Two things\n were wrong with that: secure mode said nothing, so the panel never told a\n reviewer which of the two they were in; and a paragraph pinned to the top\n for ever is skipped after the second reading, while a single word is not.\n\n IT IS NOT A BUTTON AND MUST NOT LOOK LIKE ONE. No shadow, no pressed\n state, cursor stays default: there is nothing to press. What it does have\n is a focus ring, because it takes focus -- the description below has to be\n reachable without a pointer, and that is the only reason it is focusable.\n ---------------------------------------------------------------------------- */\n\n.ap-mode {\n /* The frame the description is positioned against. It spans the width of\n the panel body, so a description pinned to its two edges cannot spill\n sideways out of a body that scrolls -- and a scrolling body clips both\n axes, not just the one it scrolls. */\n position: relative;\n margin: 4px 0 10px;\n}\n\n.ap-mode-chip {\n display: inline-block;\n padding: 2px 9px 3px;\n border: 1px solid var(--ap-border);\n border-radius: 999px;\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 11px;\n font-weight: 600;\n letter-spacing: 0.05em;\n text-transform: uppercase;\n cursor: default;\n}\n\n/* The public badge is the one that carries a consequence, so it is the one\n that is coloured -- in the tool's own accent, not in the alert colours: a\n public key is a choice somebody made on purpose, not an incident. Secure\n keeps the quiet frame: it is the case where nothing is being said. */\n/* The same ring as every other focusable thing in the panel. It is the only\n visual proof, for somebody arriving by Tab, that this word is where their\n focus went. */\n.ap-mode-chip:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n/* Plain wears the same coat as public, and for the same reason: both are a\n choice somebody made on purpose, and both carry a consequence for whoever\n is about to write. Neither is an incident, so neither takes an alert\n colour. They cannot both be true at once. */\n.ap-mode-public .ap-mode-chip,\n.ap-mode-plain .ap-mode-chip {\n border-color: var(--ap-accent);\n background: var(--ap-accent-veil);\n color: var(--ap-accent-dark);\n}\n\n/* The description. Hidden by DEFAULT and shown on demand, and hidden in a way\n that leaves it readable to a screen reader: it is the badge's\n aria-describedby target, and an accessible description is computed from the\n referenced element whether or not it is painted. It is taken out of the\n layout entirely (absolute) so that showing it moves not one pixel of the\n list underneath -- a tooltip that pushes the notes down is a tooltip that\n makes people lose their place. */\n.ap-mode-tip {\n position: absolute;\n z-index: 2;\n top: calc(100% + 6px);\n left: 0;\n right: 0;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg-raised);\n color: var(--ap-text);\n box-shadow: var(--ap-shadow);\n font-size: 12px;\n font-weight: 400;\n letter-spacing: normal;\n text-transform: none;\n line-height: 1.45;\n opacity: 0;\n visibility: hidden;\n transform: translateY(-3px);\n transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s linear 0.12s;\n pointer-events: none;\n}\n\n/* BOTH, and the keyboard one is not the afterthought: :focus-visible is what\n makes the sentence reachable by somebody who never touches a pointer. */\n.ap-mode-chip:hover ~ .ap-mode-tip,\n.ap-mode-chip:focus-visible ~ .ap-mode-tip {\n opacity: 1;\n visibility: visible;\n transform: none;\n transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ap-mode-tip {\n transform: none;\n transition: none;\n }\n .ap-mode-chip:hover ~ .ap-mode-tip,\n .ap-mode-chip:focus-visible ~ .ap-mode-tip {\n transition: none;\n }\n}\n\n/* The \"a newer client exists\" line and the \"this server speaks another\n format\" line are the same object on screen: a standing statement about what\n one is looking at, above the notes and above the failures. One rule, so\n they cannot drift apart -- and the second one joins it rather than\n inventing a colour, precisely because a protocol disagreement is a fact\n about the project, not an incident.\n\n Deliberately NOT the alert colours: neither is a failure, and an alarm that\n never goes away stops being read. */\n.ap-upgrade,\n.ap-format {\n margin: 0 0 10px;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg-soft);\n color: var(--ap-text-soft);\n font-size: 12px;\n line-height: 1.45;\n}\n\n/* ----------------------------------------------------------------------------\n A note, and its replies.\n ---------------------------------------------------------------------------- */\n\n.ap-note {\n margin: 8px 0;\n padding: 10px 12px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n}\n\n.ap-note.ap-orphan {\n background: var(--ap-bg-soft);\n}\n\n\n.ap-note-header {\n display: flex;\n align-items: baseline;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-note-author {\n font-weight: 600;\n}\n\n.ap-note-date {\n color: var(--ap-text-soft);\n font-size: 12px;\n}\n\n.ap-note-target {\n margin: 4px 0 0;\n color: var(--ap-text-soft);\n font-size: 12px;\n font-style: italic;\n overflow-wrap: anywhere;\n}\n\n.ap-note-text {\n margin: 6px 0 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n.ap-note-actions {\n margin-top: 8px;\n display: flex;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-replies {\n margin: 8px 0 0;\n padding-left: 10px;\n border-left: 2px solid var(--ap-border);\n}\n\n.ap-reply {\n margin: 8px 0 0;\n}\n\n/* ----------------------------------------------------------------------------\n The form, anchored near the element pointed at.\n ---------------------------------------------------------------------------- */\n\n.ap-form {\n position: fixed;\n width: 340px;\n max-width: calc(100vw - 24px);\n display: none;\n flex-direction: column;\n gap: 8px;\n padding: 14px;\n border: 1px solid var(--ap-border);\n border-radius: var(--ap-radius);\n background: var(--ap-bg);\n box-shadow: var(--ap-shadow);\n pointer-events: auto;\n}\n\n.ap-form.ap-open {\n display: flex;\n}\n\n.ap-form-title {\n font-size: 15px;\n font-weight: 600;\n}\n\n.ap-form-target {\n color: var(--ap-text-soft);\n font-size: 12px;\n font-style: italic;\n overflow-wrap: anywhere;\n}\n\n.ap-label {\n display: block;\n margin-bottom: 3px;\n font-size: 12px;\n font-weight: 600;\n color: var(--ap-text-soft);\n}\n\n.ap-help {\n margin: 3px 0 0;\n font-size: 12px;\n color: var(--ap-text-soft);\n}\n\n.ap-field,\n.ap-area {\n width: 100%;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 8px;\n background: var(--ap-bg-soft);\n color: var(--ap-text);\n}\n\n.ap-field:focus,\n.ap-area:focus {\n outline: 2px solid var(--ap-accent);\n outline-offset: 1px;\n}\n\n.ap-area {\n min-height: 92px;\n resize: vertical;\n}\n\n.ap-actions {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.ap-counter {\n margin-left: auto;\n font-size: 12px;\n color: var(--ap-text-soft);\n}\n\n/* ----------------------------------------------------------------------------\n Buttons.\n ---------------------------------------------------------------------------- */\n\n.ap-primary,\n.ap-secondary,\n.ap-link {\n border-radius: 8px;\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ap-primary {\n padding: 8px 14px;\n border: 1px solid var(--ap-accent);\n background: var(--ap-accent);\n color: var(--ap-accent-text);\n font-weight: 600;\n}\n\n.ap-primary:hover {\n background: var(--ap-accent-dark);\n border-color: var(--ap-accent-dark);\n}\n\n.ap-secondary {\n padding: 8px 14px;\n border: 1px solid var(--ap-border);\n background: var(--ap-bg);\n color: var(--ap-text);\n}\n\n.ap-secondary:hover {\n background: var(--ap-bg-raised);\n}\n\n.ap-link {\n padding: 2px 4px;\n border: 0;\n background: none;\n color: var(--ap-accent);\n text-decoration: underline;\n font-size: 13px;\n}\n\n.ap-primary:disabled,\n.ap-secondary:disabled,\n.ap-link:disabled {\n opacity: 0.6;\n cursor: default;\n}\n\n.ap-primary:focus-visible,\n.ap-secondary:focus-visible,\n.ap-link:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 2px;\n}\n\n/* ----------------------------------------------------------------------------\n The failures.\n\n They are RED, at the top of the block concerned, and carry the message the\n server returned as it stands: that is how a non-technical team learns that\n its remark is not saved, instead of believing it is.\n ---------------------------------------------------------------------------- */\n\n.ap-error {\n margin: 8px 0;\n padding: 10px 12px;\n border: 1px solid var(--ap-alert-border);\n border-radius: var(--ap-radius);\n background: var(--ap-alert-bg);\n color: var(--ap-alert-text);\n}\n\n.ap-error-title {\n font-weight: 700;\n margin-bottom: 4px;\n}\n\n.ap-error-detail {\n margin: 6px 0 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n font-size: 13px;\n}\n\n.ap-error .ap-link {\n color: var(--ap-alert-text);\n}\n\n/* ----------------------------------------------------------------------------\n Narrow: the panel takes the full width, and so does the form.\n ---------------------------------------------------------------------------- */\n\n/* ----------------------------------------------------------------------------\n Narrow.\n\n DEFECT OBSERVED at 375 px wide: a panel taking the full height covers the\n whole page, and no element can be pointed at any more -- every click lands\n on the panel. So it becomes a bottom band, which leaves the top half of\n the viewport free; one scrolls the page there to bring the wanted element\n into view. The form, for its part, hides the panel while typing (see\n notes.js): on a screen that size, writing and reading the list at the same\n time does not hold.\n ---------------------------------------------------------------------------- */\n\n/* On a narrow screen the panel becomes a bottom band and the form takes the\n full width.\n\n THE WIDTH CEILING IS KEPT, and it comes from a measured defect: \"left: 8;\n right: 8\" sizes the element against its CONTAINING BLOCK, which the host\n site's horizontal overflow can make wider than the visible window.\n Measured, in mobile emulation at 390 px: the site overflows to 407 px\n (with the tool and without it), and the panel came out 391 px wide\n starting at 8, that is 9 px off screen. \"100vw\" is the window, not the\n containing block: the ceiling therefore does nothing when the site does\n not overflow, and pulls the width back when it does. */\n@media (max-width: 560px) {\n .ap-panel {\n top: auto;\n right: 8px;\n left: 8px;\n bottom: 66px;\n height: 52vh;\n width: auto;\n max-width: calc(100vw - 16px);\n }\n\n /* A band spanning the width has no side, so the choice is inert here and\n the button says so by not being there. Offering a control that visibly\n does nothing is worse than offering none. The stored side is untouched:\n it is waiting for the wide screen it was chosen on. */\n .ap-side-toggle {\n display: none;\n }\n\n .ap-form {\n left: 8px;\n right: 8px;\n width: auto;\n max-width: calc(100vw - 16px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ap-button {\n transition: none;\n }\n}\n\n/* The failure shows without opening the panel: the button's dot changes\n colour. A team that does not click must be able to see that something is\n wrong. */\n.ap-button.ap-failed .ap-button-dot {\n background: var(--ap-alert-text);\n}\n\n.ap-button.ap-failed {\n border-color: var(--ap-alert-border);\n}\n\n/* Signature reminder, in the note form.\n The name was shown at the foot of the panel only: invisible at the moment\n one writes. A user reported not knowing which name they were writing\n under. */\n.ap-form-signature {\n display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;\n margin: 0 0 .6rem; font-size: .85rem; opacity: .8;\n}\n\n/* Resolution state, said on the card.\n Two cases NOT to be confused: resolved and online, resolved but not\n deployed yet. The second keeps the defect on the reviewer's screen; hiding\n it or announcing it as fixed would cost them their trust in the tool. */\n.ap-state-mark {\n display: inline-block; margin: 0 0 .5rem;\n padding: .15rem .55rem; border-radius: 4px;\n font-size: .75rem; font-weight: 600; letter-spacing: .02em;\n}\n.ap-note.ap-resolved { opacity: .72; }\n.ap-note.ap-resolved .ap-state-mark {\n color: var(--ap-done-ink); background: var(--ap-done-veil);\n}\n.ap-note.ap-resolved-pending .ap-state-mark {\n color: var(--ap-pending-ink); background: var(--ap-pending-veil);\n}\n/* The \"it is fixed\" / \"reopen\" block, opened under the card. Same shape as\n the reply block: it is the same gesture, one answers a remark. */\n.ap-resolve,\n.ap-reply-form {\n margin-top: .6rem;\n padding-top: .6rem;\n border-top: 1px solid var(--ap-border);\n}\n\n/* The question asked before the key is dropped, at the foot of the list.\n Framed like the resolution block -- it is the same shape of gesture, one\n answers before something changes -- and set apart from the notes above it,\n because it is not about a note. */\n.ap-forget {\n margin-top: 1rem;\n padding-top: .6rem;\n border-top: 1px solid var(--ap-border);\n}\n\n.ap-forget .ap-actions {\n margin-top: .5rem;\n}\n\n.ap-history-toggle {\n display: block; width: 100%; margin: 1rem 0 .25rem;\n padding: .5rem .75rem; border: 1px dashed currentColor; border-radius: 6px;\n background: none; color: inherit; font: inherit; opacity: .7; cursor: pointer;\n}\n.ap-history-toggle:hover { opacity: 1; }\n\n\n/* ----------------------------------------------------------------------------\n Setup and pasting the salt.\n\n These are the only screens where something is copied by hand. Everything\n there is SELECTABLE and monospaced: a 43-character salt copied wrong\n cannot be recovered, and nothing helps less than a font that confuses I, l\n and 1.\n ---------------------------------------------------------------------------- */\n\n.ap-panel-wide {\n width: 560px;\n}\n\n.ap-copy {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n margin: 0 0 12px;\n}\n\n.ap-code {\n flex: 1 1 auto;\n width: 100%;\n padding: 8px 10px;\n border: 1px solid var(--ap-border);\n border-radius: 8px;\n background: var(--ap-bg-soft);\n color: var(--ap-text);\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, \"Liberation Mono\",\n monospace;\n font-size: 12.5px;\n line-height: 1.5;\n resize: vertical;\n white-space: pre;\n overflow-x: auto;\n}\n\n.ap-code:focus-visible {\n outline: 2px solid var(--ap-accent);\n outline-offset: 1px;\n}\n\n@media (max-width: 560px) {\n .ap-panel-wide {\n width: auto;\n }\n\n .ap-copy {\n flex-direction: column;\n }\n}\n";
22
22
 
23
23
  /* ==== 00-preamble.js ==== */
24
24
 
@@ -75,6 +75,67 @@
75
75
  rather than resolved (FORMAT.md section 1.5).
76
76
  neither we stay out, and we say so once in the console. */
77
77
 
78
+ /* ONE TOOL PER PAGE, HOWEVER MANY TIMES THIS FILE RUNS.
79
+
80
+ A tag inside <body> is executed again by every router that swaps the body
81
+ and re-activates its scripts -- Turbo, htmx's hx-boost, Livewire's
82
+ wire:navigate, Astro's ClientRouter -- and a template can carry the tag
83
+ twice. Each execution used to build a tool of its own: two pills, two sets
84
+ of listeners on one page, one remark sent twice.
85
+
86
+ So the copy that boots first takes a slot ON THE DOCUMENT (85-pages), and
87
+ keeps it for the life of the document. Any later copy finds it (below, once
88
+ the tag and the object have been read, and before a single setting is
89
+ judged) and does not start. Which of two things it says depends on what it
90
+ carries:
91
+
92
+ THE SAME CONFIGURATION -- same src, same settings on the tag, same
93
+ object. That is a router executing the tag again, at every click, and it
94
+ stands down in silence: a line per navigation would bury the console. It
95
+ asks the running copy to look at the page again instead, since a
96
+ re-executed tag is the plainest sign there is that the body just changed.
97
+
98
+ ANOTHER CONFIGURATION -- another project, key, prefix, server or file. It
99
+ stands down too, and says so ONCE for the document, however many
100
+ different configurations follow it. One tool
101
+ runs per page BY RULE: two projects on one site are two tags on two sets
102
+ of pages, never two tags on one. The rule was nearly the other one --
103
+ every configuration boots, each holds its own slot -- and it was set
104
+ aside because two tools on a page share one body, one click, one history
105
+ wrapper, and a reviewer who cannot tell which pill files where. What
106
+ cannot be allowed is the silence: a second tag that quietly never starts
107
+ is a project somebody believes is running.
108
+
109
+ AN IDENTITY THIS COPY CANNOT READ -- a running copy that predates
110
+ identities, or one that writes them another way -- is neither. Nothing
111
+ can be said about it that is true, so nothing is said: a false "another
112
+ configuration" is exactly what a CDN serving a newer release in the
113
+ middle of a visit would print, on a page carrying one tag.
114
+
115
+ NO TAKEOVER, EVEN WHEN THE OWNER IS OUT OF ITS data-path. Handing the
116
+ document to whichever copy's prefix matches would make "which tool is on
117
+ this page" depend on the order of navigations, and the owner coming back
118
+ into its prefix would have to take it back. The first copy owns the
119
+ document; the only release is the upgrade hand-over (80-upgrade).
120
+
121
+ WHY THE DOCUMENT AND A REGISTERED SYMBOL. The document is what "one per
122
+ page" means, and it outlives a body swap. Symbol.for gives two copies of
123
+ this file -- two versions, from two addresses -- the same key without it
124
+ being a name a site's script can overwrite by accident: window.Annotepage
125
+ was the obvious place, and a page is allowed to assign that object whole
126
+ (15-labels).
127
+
128
+ THE CONTRACT BETWEEN COPIES IS
129
+ { copy: { version, identity, recheck }, handedOver: [identity],
130
+ refused: [identity] }
131
+ and it is read by versions that do not exist yet. Adding to it is free;
132
+ renaming a member breaks the copy that ships next to an older one.
133
+ `refused` is non-empty once the warning has been said for the document --
134
+ that is the whole of "once" -- and it keeps at most REFUSED_KEPT entries:
135
+ a trace for whoever inspects the slot, not a list that grows at every
136
+ navigation. */
137
+ const INSTANCE_SLOT = Symbol.for('annotepage');
138
+
78
139
  /* THE SETTINGS, AND THE WHOLE LIST OF THEM. `data-` plus the name on a tag,
79
140
  the name alone in the object. Documented in the client's README, and
80
141
  client/tools/check.mjs refuses a list that has drifted from it.
@@ -85,7 +146,7 @@
85
146
  window.annotepageConfig is ours alone, so a name we do not know there is a
86
147
  typo, and a typo that is ignored is a setting somebody believes they set. */
87
148
  const SETTINGS = ['server', 'project', 'key', 'setup', 'mode', 'path',
88
- 'domains', 'version', 'environment', 'labels'];
149
+ 'domains', 'version', 'environment', 'labels', 'zone'];
89
150
 
90
151
  /* Not "written": 60-ui already holds a local of that name, and a helper of the
91
152
  whole file shadowed inside one function is a reader's trap for nothing. */
@@ -129,12 +190,55 @@
129
190
  const SCRIPT_SRC = script ? script.src : '';
130
191
 
131
192
  const declaredConfig = window.annotepageConfig;
132
- const HAS_CONFIG = declaredConfig !== undefined && declaredConfig !== null;
133
- if (HAS_CONFIG && (typeof declaredConfig !== 'object' || Array.isArray(declaredConfig))) {
134
- refuse('tag.config_shape', null,
135
- 'window.annotepageConfig is not an object, so nothing could be read from '
136
- + 'it. It is written { server: "...", project: "..." }.');
137
- }
193
+
194
+ /* -- Is this document already somebody's? ---------------------------------
195
+ Read HERE: after the two sources are in hand, and before anything below can
196
+ write to the console about them. A refused configuration executed again by
197
+ a router must not repeat its warning at every click either.
198
+
199
+ WHAT A CONFIGURATION IS, for this comparison: the file, every setting the
200
+ tag carries, and the object. Read before adoption -- the adopted form is
201
+ only known after the judging this has to come before -- but NOT as
202
+ written: two spellings of one declaration are one configuration, or a
203
+ router executing the tag again is told it brought a second tool. So the
204
+ object's keys are ordered, a value is trimmed, a list of origins is
205
+ trimmed and ordered item by item, and `setup: false` is the absence it
206
+ means (see WHICH SOURCE WINS).
207
+
208
+ THE FILE IS ITS ADDRESS WITHOUT THE QUERY STRING. A query on a script's
209
+ address is how a CMS defeats caches -- WordPress writes ?ver=, often with
210
+ the time in it -- so it changes at every deploy, or at every request, and
211
+ never names another project. Ignoring it can only ever merge two tags
212
+ whose settings are already identical, and running one tool for those is
213
+ the rule anyway. The path stays: another file is another configuration.
214
+
215
+ NOT PART OF IT, EITHER:
216
+ an attribute that is not a setting -- annotepage.com toggles
217
+ data-annotepage-on on its live tag -- or a page flipping its own
218
+ switch would be told it carries two tools;
219
+ data-version, which is a label for the notes and not a project. A body
220
+ swapped after a deploy brings build-2 in the same tag. That tag stands
221
+ down like any re-executed one, and THE RUNNING COPY KEEPS THE VERSION
222
+ IT READ AT BOOT until the page is reloaded: notes written meanwhile
223
+ are filed under the build the document was loaded with.
224
+
225
+ AND IT NEVER THROWS. The object is the page's, and it may hold anything: a
226
+ BigInt that JSON.stringify refuses, an object with no prototype that
227
+ String() cannot convert, a getter that throws, a loop. Each of those gets
228
+ a text of its own, so that two such objects are still told apart. */
229
+ const data = (script && script.dataset) || {};
230
+
231
+ /* Identities this copy writes start with this. One that does not was written
232
+ by a copy that predates it or reads configurations another way. */
233
+ /* 2 SINCE `zone` JOINED THE SETTINGS. The identity lists every setting in
234
+ order, so one more setting is one more member in every identity -- the same
235
+ configuration written another way. Left at 1, a copy of the release before
236
+ still holding the document would read this one's identity as a different
237
+ configuration and warn about a second tool, on a page carrying one tag. */
238
+ const IDENTITY_FORMAT = 'annotepage/identity/2';
239
+ const readableIdentity = (value) =>
240
+ typeof value === 'string' && value.indexOf('["' + IDENTITY_FORMAT + '",') === 0;
241
+ const REFUSED_KEPT = 8;
138
242
 
139
243
  const isTextList = (value) => {
140
244
  if (!Array.isArray(value)) return false;
@@ -144,10 +248,142 @@
144
248
  return true;
145
249
  };
146
250
 
251
+ /* Any value, as text. `seen` is the path from the top, so a loop is named
252
+ rather than followed; the depth is bounded for an object nobody writes by
253
+ hand. */
254
+ const textOfValue = (value, seen) => {
255
+ const kind = typeof value;
256
+ if (kind === 'string') return JSON.stringify(value);
257
+ if (kind === 'bigint') return String(value) + 'n';
258
+ if (kind === 'number' || kind === 'boolean' || kind === 'undefined' || value === null) {
259
+ return String(value);
260
+ }
261
+ if (kind !== 'object') return '<' + kind + '>';
262
+ if (seen.indexOf(value) !== -1) return '<loop>';
263
+ if (seen.length >= 8) return '<deep>';
264
+ seen.push(value);
265
+ let text;
266
+ try {
267
+ const parts = [];
268
+ if (Array.isArray(value)) {
269
+ for (let i = 0; i < value.length; i += 1) parts.push(memberText(value, i, seen));
270
+ text = '[' + parts.join(',') + ']';
271
+ } else {
272
+ const names = Object.keys(value).sort();
273
+ for (let i = 0; i < names.length; i += 1) {
274
+ parts.push(JSON.stringify(names[i]) + ':' + memberText(value, names[i], seen));
275
+ }
276
+ text = '{' + parts.join(',') + '}';
277
+ }
278
+ } catch (e) {
279
+ text = '<unreadable>';
280
+ }
281
+ seen.pop();
282
+ return text;
283
+ };
284
+ function memberText(object, name, seen) {
285
+ try {
286
+ return textOfValue(object[name], seen);
287
+ } catch (e) {
288
+ return '<throws>';
289
+ }
290
+ }
291
+
292
+ /* One setting, as the comparison sees it. null is "not declared". */
293
+ const settingText = (name, value) => {
294
+ if (name === 'setup') return value ? 'yes' : null;
295
+ if (name === 'domains' && (typeof value === 'string' || isTextList(value))) {
296
+ const items = typeof value === 'string' ? value.split(',') : value;
297
+ return JSON.stringify(items.map((d) => d.trim()).filter(Boolean).sort());
298
+ }
299
+ if (typeof value === 'string') return JSON.stringify(value.trim());
300
+ return textOfValue(value, []);
301
+ };
302
+
303
+ const objectText = (object) => {
304
+ if (object === undefined) return null;
305
+ if (object === null || typeof object !== 'object' || Array.isArray(object)) {
306
+ return textOfValue(object, []);
307
+ }
308
+ try {
309
+ const parts = [];
310
+ const names = Object.keys(object).sort();
311
+ for (let i = 0; i < names.length; i += 1) {
312
+ const name = names[i];
313
+ if (name === 'version') continue;
314
+ let text;
315
+ try {
316
+ text = SETTINGS.indexOf(name) === -1
317
+ ? textOfValue(object[name], [object]) : settingText(name, object[name]);
318
+ } catch (e) {
319
+ text = '<throws>';
320
+ }
321
+ if (text !== null) parts.push(JSON.stringify(name) + ':' + text);
322
+ }
323
+ return '{' + parts.join(',') + '}';
324
+ } catch (e) {
325
+ return '<unreadable>';
326
+ }
327
+ };
328
+
329
+ const COPY_IDENTITY = JSON.stringify([IDENTITY_FORMAT,
330
+ SCRIPT_SRC.replace(/[?#].*$/, ''),
331
+ SETTINGS.filter((name) => name !== 'version').map((name) => (declaredIn(data, name)
332
+ ? settingText(name, name === 'setup' ? true : String(data[name])) : null)),
333
+ objectText(declaredConfig)]);
334
+
335
+ const slotFound = document[INSTANCE_SLOT];
336
+ const handedOverHere = (slotFound && Array.isArray(slotFound.handedOver)) ? slotFound.handedOver : [];
337
+ if (slotFound && (slotFound.copy || handedOverHere.indexOf(COPY_IDENTITY) !== -1)) {
338
+ const holder = slotFound.copy;
339
+ /* A COPY THAT HANDED OVER is still this configuration: the newer version
340
+ carries its settings under another address (80-upgrade). The old tag
341
+ executed again by a router is the same declaration, and neither a
342
+ warning nor a second hand-over is owed for it. */
343
+ const same = handedOverHere.indexOf(COPY_IDENTITY) !== -1
344
+ || !!(holder && holder.identity === COPY_IDENTITY);
345
+ /* UNKNOWN IS NOT DIFFERENT: a holder with no identity this copy can read,
346
+ or a hand-over recorded in another format -- this tag may be the very
347
+ one that copy was loaded by. */
348
+ const unknown = !same && (!holder || !readableIdentity(holder.identity)
349
+ || handedOverHere.some((identity) => !readableIdentity(identity)));
350
+ if (!same && !unknown) {
351
+ if (!Array.isArray(slotFound.refused)) slotFound.refused = [];
352
+ const refused = slotFound.refused;
353
+ // ONCE FOR THE DOCUMENT, not once per configuration: a template
354
+ // cycling through several would otherwise print a line per kind.
355
+ if (!refused.length) {
356
+ complain('this page already runs annotepage with another configuration, '
357
+ + 'and one tool runs per page: this one ('
358
+ + (SCRIPT_SRC || 'window.annotepageConfig') + ') was not started, '
359
+ + 'and any further one on this page stands down without another line. '
360
+ + 'Several projects on one site means each page loads only its own '
361
+ + 'tag. See https://annotepage.com/questions.html#one-per-page');
362
+ }
363
+ if (refused.indexOf(COPY_IDENTITY) === -1 && refused.length < REFUSED_KEPT) {
364
+ refused.push(COPY_IDENTITY);
365
+ }
366
+ }
367
+ /* IN A try, because this runs inside whatever executed the tag -- a
368
+ router, in the middle of its navigation -- and a fault of the running
369
+ copy thrown from here would surface there, uncaught, at every click.
370
+ The next sign of navigation asks again. */
371
+ try {
372
+ if (holder) holder.recheck();
373
+ } catch (e) { /* the running copy's fault, not the page's */ }
374
+ return;
375
+ }
376
+
377
+ const HAS_CONFIG = declaredConfig !== undefined && declaredConfig !== null;
378
+ if (HAS_CONFIG && (typeof declaredConfig !== 'object' || Array.isArray(declaredConfig))) {
379
+ refuse('tag.config_shape', null,
380
+ 'window.annotepageConfig is not an object, so nothing could be read from '
381
+ + 'it. It is written { server: "...", project: "..." }.');
382
+ }
383
+
147
384
  /* What each source declares, as text, and whether it declares it AT ALL -- an
148
385
  empty data-key is not the same fact as no data-key (see THE KEY below). */
149
386
  const fromTag = {};
150
- const data = (script && script.dataset) || {};
151
387
  for (let i = 0; i < SETTINGS.length; i += 1) {
152
388
  const name = SETTINGS[i];
153
389
  if (declaredIn(data, name)) fromTag[name] = String(data[name]).trim();
@@ -333,6 +569,21 @@
333
569
  read it. */
334
570
  const DOMAINS = read('domains').split(',').map((d) => d.trim()).filter(Boolean);
335
571
 
572
+ /* The zone: which PARTS of a page a remark can be written on, as a CSS
573
+ selector list. The scope above says which pages; this says where on them.
574
+
575
+ Only READ here, the way the key is: whether the selector is one, and what it
576
+ matches, is judged by 30-state and 60-ui -- the second at every pick, since
577
+ a framework can render the zone after the boot, or swap it at a navigation.
578
+ DECLARED is kept apart from the text for the same reason as the key's: an
579
+ empty data-zone is somebody who meant to write one, and it restricts to
580
+ nothing rather than to everything.
581
+
582
+ Guidance for reviewers, NOT a boundary: the server never sees an element,
583
+ and a hand-made client writes wherever it likes. */
584
+ const ZONE_DECLARED = declaredIn(config, 'zone');
585
+ const ZONE_SELECTOR = read('zone');
586
+
336
587
  /* Setup screen. It opens ONLY when asked for: without it, a page with no
337
588
  project does strictly nothing, like a directory copied there by mistake.
338
589
  That is the rule of silence, applied to setup. */
@@ -636,6 +887,16 @@
636
887
  'This server keeps a thread for {n} days after its last message, then '
637
888
  + 'removes it. Nobody chooses which.',
638
889
  'panel.escape': 'Press Escape to stop.',
890
+ /* -- The zone the site opened to remarks (data-zone) -----------------
891
+ Said where the reviewer acts: the instruction names the frames, and a
892
+ click outside them says why nothing opened. Two refusals, because they
893
+ are not the same news -- one sends the reader to a frame on screen, the
894
+ other has no frame to send them to, and saying "the outlined areas"
895
+ over a page with none would be a sentence nobody can obey. */
896
+ 'panel.instructions_zone':
897
+ 'Click an element inside the outlined areas to write a remark about it.',
898
+ 'zone.outside': 'Remarks go in the outlined areas of this page.',
899
+ 'zone.none': 'No part of this page is open to remarks.',
639
900
  'panel.empty': 'Nobody has written a note on this page yet.',
640
901
  'panel.section_page': 'On this page',
641
902
  /* -- The list, and what opens from it --------------------------------
@@ -1336,6 +1597,22 @@
1336
1597
  let keys = null; // { id, encryptionKey, indexKey }
1337
1598
  let PAGE_INDEX = ''; // blind index of the current page
1338
1599
 
1600
+ /* WHICH PAGE THAT INDEX BELONGS TO. Read once at boot, it was the only
1601
+ answer for the life of the document -- and a router that changes the path
1602
+ without a reload kept the first page's notes on every later one. It is now
1603
+ written wherever the index is computed, and compared against the address at
1604
+ every sign of navigation (85-pages). */
1605
+ let PAGE_PATH = '';
1606
+ /* True while this copy stands down because the current path is outside the
1607
+ declared prefix. A full load would simply have stayed silent; a copy that
1608
+ outlives its first page has to remember WHY it is silent, because only this
1609
+ reason goes away when the path changes. */
1610
+ let outOfScope = false;
1611
+ /* The number of the boot under way. Raised by every start() and by leaving
1612
+ the declared prefix, so that an answer landing for an earlier boot can tell
1613
+ it no longer belongs to the page (bootIsStale, 85-pages). */
1614
+ let bootRun = 0;
1615
+
1339
1616
  const inTool = (n) => !!(host && n && (n === host || host.contains(n)));
1340
1617
 
1341
1618
  /* -- The browser's memory ------------------------------------------------
@@ -1450,6 +1727,108 @@
1450
1727
  return true;
1451
1728
  };
1452
1729
 
1730
+ /* -- The zone ------------------------------------------------------------
1731
+ Where on the page a remark can be WRITTEN (data-zone). Reading is never
1732
+ restricted: a note anchored outside the zone is still listed and badged,
1733
+ because a remark written before the zone was declared is still a remark.
1734
+
1735
+ Everything below takes what it judges as parameters -- the element, the
1736
+ selector, the browser's own verdict on a selector -- so that
1737
+ client/tools/check.mjs runs it against plain objects. */
1738
+
1739
+ /**
1740
+ * The items of a selector list, split on the commas that separate them.
1741
+ *
1742
+ * NOT text.split(','): a comma inside :is(a, b), inside [title="a,b"] or
1743
+ * after a backslash belongs to one item. What an item is still left to the
1744
+ * browser -- this only has to find where one ends, so that the console can
1745
+ * name the item that is wrong instead of repeating a whole list back.
1746
+ */
1747
+ const selectorItems = (text) => {
1748
+ const items = [];
1749
+ let depth = 0;
1750
+ let quote = '';
1751
+ let from = 0;
1752
+ for (let i = 0; i < text.length; i += 1) {
1753
+ const c = text[i];
1754
+ if (c === '\\') {
1755
+ i += 1;
1756
+ } else if (quote) {
1757
+ if (c === quote) quote = '';
1758
+ } else if (c === '"' || c === '\'') {
1759
+ quote = c;
1760
+ } else if (c === '(' || c === '[') {
1761
+ depth += 1;
1762
+ } else if ((c === ')' || c === ']') && depth > 0) {
1763
+ depth -= 1;
1764
+ } else if (c === ',' && depth === 0) {
1765
+ items.push(text.slice(from, i).trim());
1766
+ from = i + 1;
1767
+ }
1768
+ }
1769
+ items.push(text.slice(from).trim());
1770
+ return items;
1771
+ };
1772
+
1773
+ /**
1774
+ * The declared zone, judged once: { declared, valid, selector, broken }.
1775
+ *
1776
+ * `compiles` is the browser asked about one selector. It is the only judge
1777
+ * of CSS here -- a second grammar written in this file would be a second one
1778
+ * to keep in step with every browser.
1779
+ *
1780
+ * AN EMPTY ITEM IS BROKEN TOO: ".a," and ", .b" are refused by every browser,
1781
+ * and so is an empty attribute. `broken` is what the console line names.
1782
+ *
1783
+ * AND INVALID NEVER MEANS "EVERYWHERE". A selector that does not parse
1784
+ * restricts to nothing at all: falling back on the whole page would open
1785
+ * every part the site meant to close, with nothing on screen to say so.
1786
+ */
1787
+ const zoneFrom = (declared, text, compiles) => {
1788
+ if (!declared) return { declared: false, valid: true, selector: '', broken: '' };
1789
+ const selector = String(text).trim();
1790
+ const items = selectorItems(selector);
1791
+ for (let i = 0; i < items.length; i += 1) {
1792
+ if (items[i] === '' || !compiles(items[i])) {
1793
+ return { declared: true, valid: false, selector: selector, broken: items[i] };
1794
+ }
1795
+ }
1796
+ /* The whole list as well: the items passing one by one is what the
1797
+ split believes, and the list is what will actually be matched. */
1798
+ if (!compiles(selector)) return { declared: true, valid: false, selector: selector, broken: selector };
1799
+ return { declared: true, valid: true, selector: selector, broken: '' };
1800
+ };
1801
+
1802
+ /** The zone element holding `el` -- `el` itself when it matches -- or null.
1803
+ Walked by hand rather than with closest(), so that the walk is the code
1804
+ under test and not a stand-in for it. */
1805
+ const zoneHolding = (el, selector) => {
1806
+ for (let n = el; n && n.nodeType === 1; n = n.parentElement) {
1807
+ if (n.matches(selector)) return n;
1808
+ }
1809
+ return null;
1810
+ };
1811
+
1812
+ /** 'anywhere' (no zone declared), 'inside', 'outside', or 'nowhere' (a
1813
+ selector that is not one). Asked at every pick, never cached: the zone
1814
+ may have been rendered, or replaced, since the last one. */
1815
+ const pickVerdict = (zone, el) => {
1816
+ if (!zone.declared) return 'anywhere';
1817
+ if (!zone.valid) return 'nowhere';
1818
+ return zoneHolding(el, zone.selector) ? 'inside' : 'outside';
1819
+ };
1820
+
1821
+ /** Of the elements matching the zone, those no other match contains. A
1822
+ nested zone adds no room to write, and outlining it too would draw a
1823
+ frame inside a frame for every paragraph of `.article, .article p`. */
1824
+ const outermostZones = (elements, selector) => {
1825
+ const outer = [];
1826
+ for (let i = 0; i < elements.length; i += 1) {
1827
+ if (!zoneHolding(elements[i].parentElement, selector)) outer.push(elements[i]);
1828
+ }
1829
+ return outer;
1830
+ };
1831
+
1453
1832
  /* ==== 40-api.js ==== */
1454
1833
 
1455
1834
  /* -- 8. The API ---------------------------------------------------------
@@ -2128,6 +2507,8 @@
2128
2507
  'pointer-events: none !important;' +
2129
2508
  'z-index: 2147483000 !important;';
2130
2509
  document.body.appendChild(host);
2510
+ // And kept there: a router that swaps the body takes it along (85-pages).
2511
+ watchHost();
2131
2512
  root = host.attachShadow({ mode: 'open' });
2132
2513
 
2133
2514
  /* The stylesheet is PUT HERE, in a <style>, and not loaded by a <link>
@@ -2189,11 +2570,20 @@
2189
2570
  button.addEventListener('click', () => toggleMode());
2190
2571
  layer.appendChild(button);
2191
2572
 
2573
+ /* -- the zones a remark can be written in (data-zone) --
2574
+ Before the highlight, so that the outline of the element being pointed
2575
+ at is drawn over the frame of the zone that holds it. */
2576
+ const zones = create('div', 'ap-zones');
2577
+ layer.appendChild(zones);
2578
+ const zoneNotice = create('div', 'ap-zone-notice');
2579
+ zoneNotice.setAttribute('role', 'status');
2580
+
2192
2581
  /* -- pointing highlight -- */
2193
2582
  const highlight = create('div', 'ap-highlight');
2194
2583
  const label = create('div', 'ap-highlight-label');
2195
2584
  layer.appendChild(highlight);
2196
2585
  layer.appendChild(label);
2586
+ layer.appendChild(zoneNotice);
2197
2587
 
2198
2588
  /* -- markers -- */
2199
2589
  const markers = create('div', 'ap-markers');
@@ -2221,7 +2611,13 @@
2221
2611
  header.appendChild(sideToggle);
2222
2612
  header.appendChild(close);
2223
2613
  const instructions = create('div', 'ap-panel-instructions');
2224
- instructions.appendChild(create('div', null, T('panel.instructions')));
2614
+ /* With a zone, the sentence says where to click: frames on the page with
2615
+ nothing explaining them read as the site's own decoration. And the zone
2616
+ is judged HERE, once the tool exists on this page, so that a selector
2617
+ that does not parse is said in the console at load -- not on the day a
2618
+ reviewer first tries to click. */
2619
+ instructions.appendChild(create('div', null,
2620
+ T(judgeZone().declared ? 'panel.instructions_zone' : 'panel.instructions')));
2225
2621
  instructions.appendChild(create('div', null, T('panel.escape')));
2226
2622
  /* HOW LONG THIS SERVER KEEPS A THREAD, AND ONLY WHERE IT KEEPS ONE FOR A
2227
2623
  WHILE. "Nothing is ever deleted" is what this tool promises and what it
@@ -2261,7 +2657,9 @@
2261
2657
  body: body,
2262
2658
  keeps: keeps,
2263
2659
  footer: footer,
2264
- form: form
2660
+ form: form,
2661
+ zones: zones,
2662
+ zoneNotice: zoneNotice
2265
2663
  };
2266
2664
 
2267
2665
  applySide();
@@ -2451,6 +2849,8 @@
2451
2849
  asks while pointing at the element itself. What they want is the remark,
2452
2850
  and the window is where a remark is read. */
2453
2851
  const drawMarkers = () => {
2852
+ // The zones move with the page exactly when the badges do.
2853
+ drawZones();
2454
2854
  empty(ui.markers);
2455
2855
  if (!mode) return;
2456
2856
  for (let i = 0; i < anchored.length; i += 1) {
@@ -2510,11 +2910,138 @@
2510
2910
  // are in the document now, not on the ones that were.
2511
2911
  reanchor();
2512
2912
  drawMarkers();
2513
- if (hovered && document.contains(hovered)) showHighlight(hovered);
2913
+ /* A zone the page has since taken away puts the aim out. Without a
2914
+ zone pickable() is always true, and this is the line it replaced. */
2915
+ if (hovered && document.contains(hovered)) {
2916
+ if (pickable(hovered)) showHighlight(hovered);
2917
+ else hideHighlight();
2918
+ }
2514
2919
  if (target && document.contains(target)) positionForm(target);
2515
2920
  });
2516
2921
  };
2517
2922
 
2923
+ /* -- 14 bis. The zone, on the page ----------------------------------------
2924
+ The pure half -- what a selector is, which element holds which -- is in
2925
+ 30-state. This half asks the document, and it asks AT EVERY PICK AND EVERY
2926
+ FRAME: a framework renders the zone after the boot, replaces it at a
2927
+ client-side navigation (85-pages), or never renders it on some pages. A
2928
+ list of zone elements kept from the boot would be a list of detached nodes
2929
+ by the second page. */
2930
+
2931
+ /* The browser's own parser, asked about one selector. A fragment and not the
2932
+ document: nothing is searched, and nothing the page holds can make the
2933
+ answer slow. */
2934
+ const selectorCompiles = (selector) => {
2935
+ try {
2936
+ document.createDocumentFragment().querySelector(selector);
2937
+ return true;
2938
+ } catch (e) {
2939
+ return false;
2940
+ }
2941
+ };
2942
+
2943
+ /* Which setting to name in the console: the reader has one or the other. */
2944
+ const zoneSource = () => (script ? 'data-zone' : 'zone in window.annotepageConfig');
2945
+
2946
+ let zoneJudged = null;
2947
+ let zoneMissingSaid = false;
2948
+ let zoneNoticeTimer = null;
2949
+
2950
+ /* Judged ONCE: a selector that does not parse will not start parsing, and the
2951
+ line that says so is said once for the copy. */
2952
+ const judgeZone = () => {
2953
+ if (zoneJudged) return zoneJudged;
2954
+ zoneJudged = zoneFrom(ZONE_DECLARED, ZONE_SELECTOR, selectorCompiles);
2955
+ if (zoneJudged.declared && !zoneJudged.valid) {
2956
+ complain('the zone ' + JSON.stringify(zoneJudged.selector) + ' (' + zoneSource()
2957
+ + ') is not a valid CSS selector list: ' + JSON.stringify(zoneJudged.broken)
2958
+ + ' does not parse. No remark can be written on this page until it is '
2959
+ + 'corrected; the notes already written are still shown.');
2960
+ }
2961
+ return zoneJudged;
2962
+ };
2963
+
2964
+ const pickable = (el) => {
2965
+ const verdict = pickVerdict(judgeZone(), el);
2966
+ return verdict === 'anywhere' || verdict === 'inside';
2967
+ };
2968
+
2969
+ /* The zone elements on the page NOW, and ours excluded: `*` or `body > *`
2970
+ would otherwise match the host, and frame the whole viewport. */
2971
+ const zoneElements = () => {
2972
+ const zone = judgeZone();
2973
+ if (!zone.declared || !zone.valid) return [];
2974
+ const found = document.querySelectorAll(zone.selector);
2975
+ const kept = [];
2976
+ for (let i = 0; i < found.length; i += 1) {
2977
+ if (!inTool(found[i])) kept.push(found[i]);
2978
+ }
2979
+ return kept;
2980
+ };
2981
+
2982
+ /* A selector that parses and matches nothing is said too, once for the copy:
2983
+ it is the typo (.artcle) that otherwise looks like a tool refusing every
2984
+ click for no reason. Asked when the mode opens and when a pick is refused,
2985
+ never at every frame, so a zone rendered a moment later is not reported
2986
+ missing at the moment it arrives. */
2987
+ const zoneMissing = () => {
2988
+ const zone = judgeZone();
2989
+ if (!zone.declared || !zone.valid || zoneElements().length) return false;
2990
+ if (!zoneMissingSaid) {
2991
+ zoneMissingSaid = true;
2992
+ complain('the zone ' + JSON.stringify(zone.selector) + ' (' + zoneSource()
2993
+ + ') matches nothing on this page, so no remark can be written here. '
2994
+ + 'The notes already written are still shown.');
2995
+ }
2996
+ return true;
2997
+ };
2998
+
2999
+ /* CAPPED, because a selector is the site's to write and `p` matches hundreds:
3000
+ a frame per paragraph, redrawn at every frame of a scroll, is the tool
3001
+ making the page slow in order to decorate it. Document order puts an
3002
+ ancestor before what it contains, so the frames dropped are the last ones
3003
+ down the page -- and picking inside them still works. */
3004
+ const ZONES_DRAWN = 64;
3005
+
3006
+ const drawZones = () => {
3007
+ empty(ui.zones);
3008
+ if (!mode) return;
3009
+ const zone = judgeZone();
3010
+ if (!zone.declared || !zone.valid) return;
3011
+ const outer = outermostZones(zoneElements(), zone.selector);
3012
+ for (let i = 0, drawn = 0; i < outer.length && drawn < ZONES_DRAWN; i += 1) {
3013
+ const r = outer[i].getBoundingClientRect();
3014
+ if (r.width === 0 && r.height === 0) continue;
3015
+ if (r.bottom < 0 || r.top > window.innerHeight) continue;
3016
+ const frame = create('div', 'ap-zone');
3017
+ place(frame, r, 4);
3018
+ ui.zones.appendChild(frame);
3019
+ drawn += 1;
3020
+ }
3021
+ };
3022
+
3023
+ /* WHY NOTHING OPENED, next to the hand that clicked. A click outside the zone
3024
+ that did nothing at all would be read as a broken tool; a form refused in
3025
+ the panel, a whole band away, would not be read at all. It goes by itself:
3026
+ it answers one click, and the next click is the reader's. */
3027
+ const sayOutsideZone = (event, label) => {
3028
+ const notice = ui.zoneNotice;
3029
+ notice.textContent = T(label);
3030
+ notice.style.display = 'block';
3031
+ const x = typeof event.clientX === 'number' ? event.clientX : window.innerWidth / 2;
3032
+ const y = typeof event.clientY === 'number' ? event.clientY : window.innerHeight / 2;
3033
+ notice.style.left = Math.max(8, Math.min(x + 12, window.innerWidth - notice.offsetWidth - 8)) + 'px';
3034
+ notice.style.top = Math.max(8, Math.min(y + 16, window.innerHeight - notice.offsetHeight - 8)) + 'px';
3035
+ if (zoneNoticeTimer) window.clearTimeout(zoneNoticeTimer);
3036
+ zoneNoticeTimer = window.setTimeout(hideZoneNotice, 2600);
3037
+ };
3038
+
3039
+ const hideZoneNotice = () => {
3040
+ if (zoneNoticeTimer) window.clearTimeout(zoneNoticeTimer);
3041
+ zoneNoticeTimer = null;
3042
+ if (ui) ui.zoneNotice.style.display = 'none';
3043
+ };
3044
+
2518
3045
  /* -- 15. The panel ------------------------------------------------------- */
2519
3046
 
2520
3047
  const failureBlock = (failure, onClose) => {
@@ -3057,7 +3584,7 @@
3057
3584
  the window was up, so nothing has moved `hovered`; without this line the
3058
3585
  outline stays off until the pointer crosses another element, which on a
3059
3586
  hand that has not moved is never. */
3060
- if (mode && hovered && document.contains(hovered)) showHighlight(hovered);
3587
+ if (mode && hovered && document.contains(hovered) && pickable(hovered)) showHighlight(hovered);
3061
3588
  };
3062
3589
 
3063
3590
  const openPop = (title, fill) => {
@@ -3821,6 +4348,13 @@
3821
4348
  const el = event.target;
3822
4349
  if (!el || el.nodeType !== 1 || inTool(el)) return;
3823
4350
  if (el === document.body || el === document.documentElement) return;
4351
+ /* Outside the zone the aim goes out: an outline there offers a remark
4352
+ the click is going to refuse. */
4353
+ if (!pickable(el)) {
4354
+ hovered = null;
4355
+ hideHighlight();
4356
+ return;
4357
+ }
3824
4358
  hovered = el;
3825
4359
  showHighlight(el);
3826
4360
  };
@@ -3848,7 +4382,7 @@
3848
4382
  back UNDER THE HAND rather than on the element it was left on three
3849
4383
  scrolls ago. */
3850
4384
  if (el && el.nodeType === 1 && el !== document.body
3851
- && el !== document.documentElement) hovered = el;
4385
+ && el !== document.documentElement) hovered = pickable(el) ? el : null;
3852
4386
  closePop();
3853
4387
  return;
3854
4388
  }
@@ -3865,6 +4399,15 @@
3865
4399
  }
3866
4400
  if (!el || el.nodeType !== 1) return;
3867
4401
  if (el === document.body || el === document.documentElement) return;
4402
+ /* OUTSIDE THE ZONE, NOTHING IS CREATED, and a form already open stays as
4403
+ it is: it is about an element inside. The click was still captured
4404
+ above, so a link out there does not carry the reader away either. */
4405
+ if (!pickable(el)) {
4406
+ const nowhere = pickVerdict(judgeZone(), el) === 'nowhere' || zoneMissing();
4407
+ sayOutsideZone(event, nowhere ? 'zone.none' : 'zone.outside');
4408
+ return;
4409
+ }
4410
+ hideZoneNotice();
3868
4411
  openForm(el);
3869
4412
  };
3870
4413
 
@@ -3923,6 +4466,7 @@
3923
4466
  observer.observe(document.body, { childList: true, subtree: true });
3924
4467
  }
3925
4468
  domDirty = false;
4469
+ zoneMissing();
3926
4470
 
3927
4471
  // The markers for what we ALREADY know, straight away; the server is
3928
4472
  // asked next and will correct if there is anything new. Waiting for the
@@ -3941,6 +4485,8 @@
3941
4485
  hideHighlight();
3942
4486
  hovered = null;
3943
4487
  empty(ui.markers);
4488
+ empty(ui.zones);
4489
+ hideZoneNotice();
3944
4490
 
3945
4491
  document.removeEventListener('pointerover', onHover, true);
3946
4492
  document.removeEventListener('pointerdown', onClick, true);
@@ -4010,10 +4556,11 @@
4010
4556
  // We stand down for this page load. Nothing is remembered: on the
4011
4557
  // next reload the screen comes back, because the problem itself has
4012
4558
  // not been dealt with.
4013
- if (host) host.remove();
4014
- host = null;
4015
- root = null;
4016
- ui = null;
4559
+ //
4560
+ // withdraw() and not the three lines it replaces: the host is now
4561
+ // also WATCHED (85-pages), and a list of what to take down written in
4562
+ // two places is the list that drifts.
4563
+ withdraw();
4017
4564
  });
4018
4565
  header.appendChild(close);
4019
4566
  const body = create('div', 'ap-panel-body');
@@ -4441,6 +4988,11 @@
4441
4988
  // usually nothing to remove -- which is the whole point of checking
4442
4989
  // before the work rather than after it.
4443
4990
  withdraw();
4991
+ /* AND THE DOCUMENT IS GIVEN BACK, or the newer copy would find it held
4992
+ and stand down (00-preamble), leaving the page with no tool at all. It
4993
+ is the one release there is, and it records this copy's configuration,
4994
+ so that the old tag executed again stays silent (85-pages). */
4995
+ releaseDocument(document, thisCopy);
4444
4996
 
4445
4997
  const fresh = document.createElement('script');
4446
4998
  const attributes = script.attributes;
@@ -4451,7 +5003,12 @@
4451
5003
  fresh.src = url;
4452
5004
  fresh.addEventListener('error', () => {
4453
5005
  handingOver = false;
4454
- onFailure();
5006
+ /* Taken back only if still free. While the new version was being
5007
+ fetched, a tag with another configuration may have booted and taken
5008
+ the document: two tools on one page is what the slot exists to
5009
+ prevent, so this one stays down. The old tag executed again cannot
5010
+ be that copy: it stands down on the record releaseDocument left. */
5011
+ if (claimDocument(document, thisCopy)) onFailure();
4455
5012
  });
4456
5013
  (document.head || document.documentElement).appendChild(fresh);
4457
5014
  return true;
@@ -4531,6 +5088,422 @@
4531
5088
  const labelsFileFor = (declared, src, language) =>
4532
5089
  declared || shippedLabelsUrl(src, language);
4533
5090
 
5091
+ /* ==== 85-pages.js ==== */
5092
+
5093
+ /* -- 19 ter. The page changes, the document does not --------------------
5094
+ Everything in this client was written for one page per document: the path
5095
+ was read at boot, the host element was appended to the body once, and
5096
+ nothing looked again. Two families of sites break that, in two different
5097
+ ways, and both are common enough to be the default of whole frameworks:
5098
+
5099
+ THE ADDRESS CHANGES, THE BODY STAYS -- Next.js, Nuxt, Vue Router,
5100
+ SvelteKit, Inertia. history.pushState, replaceState, the back button. The
5101
+ tool stayed, with the first page's notes, on every page after it.
5102
+
5103
+ THE BODY IS REPLACED -- Turbo, Astro's ClientRouter, htmx's hx-boost,
5104
+ Livewire's wire:navigate. The host element went away with the old body,
5105
+ and a tag sitting inside the body was executed again and built a second
5106
+ tool.
5107
+
5108
+ WHAT COUNTS AS ANOTHER PAGE IS THE PATH, AND ONLY THE PATH: it is what the
5109
+ page index is computed from (20-crypto), so it is the only change that can
5110
+ move a note. A body swapped under the same address is the same page -- the
5111
+ anchoring already degrades an element that is gone into an orphan, and
5112
+ takes it back when it returns (50-anchors). A query string or a fragment
5113
+ that changes is the same page too, for the same reason.
5114
+
5115
+ NOTHING HERE TOUCHES THE DERIVATION. pagePath() and indexOfPath() are
5116
+ called exactly as the boot calls them; what changed is how often. */
5117
+
5118
+ /* -- The slot on the document -------------------------------------------
5119
+ Declared in 00-preamble, which is the first reader of it: a second copy has
5120
+ to find it before doing anything at all. Written here, by the copy that
5121
+ stays. Everything below takes the document and the window as parameters so
5122
+ that client/tools/check.mjs can hand it plain objects. */
5123
+
5124
+ const slotOf = (doc) => {
5125
+ if (!doc[INSTANCE_SLOT]) doc[INSTANCE_SLOT] = { copy: null, listening: false };
5126
+ return doc[INSTANCE_SLOT];
5127
+ };
5128
+
5129
+ /** Takes the document for `copy`. False when another copy already holds it. */
5130
+ const claimDocument = (doc, copy) => {
5131
+ const slot = slotOf(doc);
5132
+ if (slot.copy && slot.copy !== copy) return false;
5133
+ slot.copy = copy;
5134
+ return true;
5135
+ };
5136
+
5137
+ /* Given back ONLY by a copy handing over to a newer version (80-upgrade). A
5138
+ copy that went silent keeps the slot, and that is deliberate: silent is
5139
+ still this document's answer, and a re-executed tag that booted again would
5140
+ ask the same server the same question at every navigation. So does a copy
5141
+ standing down outside its data-path: see NO TAKEOVER in 00-preamble.
5142
+
5143
+ AND WHAT IT WAS CONFIGURED WITH IS REMEMBERED. The newer version arrives
5144
+ under another address, so the old tag executed again by a router no longer
5145
+ matches the copy holding the document. Without this record it would read
5146
+ as another configuration: warned about as a second tool, or -- during the
5147
+ fetch, with nobody holding the slot -- booting and handing over a second
5148
+ time. */
5149
+ const releaseDocument = (doc, copy) => {
5150
+ const slot = slotOf(doc);
5151
+ if (slot.copy !== copy) return;
5152
+ slot.copy = null;
5153
+ if (!slot.handedOver) slot.handedOver = [];
5154
+ slot.handedOver.push(copy.identity);
5155
+ };
5156
+
5157
+ /**
5158
+ * Hears every change of address, ONCE PER DOCUMENT, and forwards it to
5159
+ * whichever copy holds the slot at that moment.
5160
+ *
5161
+ * ONCE, because a copy that hands over to a newer version cannot take a
5162
+ * wrapper back off history -- the site may have wrapped it again since -- and
5163
+ * the newer copy wrapping on top would announce every navigation twice. The
5164
+ * listeners installed here never belong to a copy: they read the slot when
5165
+ * they fire.
5166
+ *
5167
+ * THE NAVIGATION API WHERE THERE IS ONE. `currententrychange` fires for
5168
+ * pushState, replaceState and a traversal alike, and it costs the site
5169
+ * nothing. history is only wrapped where that API is missing, since wrapping
5170
+ * a method of somebody else's page is the more intrusive of the two. popstate
5171
+ * is heard in both cases: it is free, and the path comparison makes a second
5172
+ * announcement of the same change a no-op.
5173
+ *
5174
+ * @returns {boolean} whether this call installed anything
5175
+ */
5176
+ const listenForPages = (win, doc) => {
5177
+ const slot = slotOf(doc);
5178
+ if (slot.listening) return false;
5179
+ slot.listening = true;
5180
+
5181
+ const tell = () => {
5182
+ if (slot.copy) slot.copy.recheck();
5183
+ };
5184
+
5185
+ win.addEventListener('popstate', tell);
5186
+
5187
+ const nav = win.navigation;
5188
+ if (nav && typeof nav.addEventListener === 'function') {
5189
+ nav.addEventListener('currententrychange', tell);
5190
+ return true;
5191
+ }
5192
+
5193
+ /* A LIMIT, SAID HERE BECAUSE THIS IS WHERE IT COMES FROM. A router that
5194
+ kept its own reference to history.pushState before this tag loaded --
5195
+ `const push = history.pushState.bind(history)` at module load is a
5196
+ common way to write one -- calls that reference and never the wrapper
5197
+ below. Its navigations are not heard through history: only through
5198
+ popstate, a re-executed tag, a swapped body, or the Navigation API where
5199
+ the browser has it. Nothing a script loaded later can do reaches a
5200
+ reference taken earlier, and loading first is not this tag's to
5201
+ decide. */
5202
+ const history = win.history;
5203
+ ['pushState', 'replaceState'].forEach((name) => {
5204
+ const original = history && history[name];
5205
+ if (typeof original !== 'function') return;
5206
+ const wrapper = function () {
5207
+ // The site's call first, untouched, and its exception with it: a
5208
+ // refused URL is the site's to hear about, and a navigation that
5209
+ // did not happen is not one to follow.
5210
+ const result = original.apply(this, arguments);
5211
+ /* THE ONE try IN THIS SECTION, AND IT IS NOT A HABIT. This line
5212
+ runs INSIDE the site's own call to pushState, in its router, in
5213
+ the middle of its render. Anything thrown here would break the
5214
+ site's navigation -- which is the one failure this tool may
5215
+ never cause. A listener that throws only reaches the console;
5216
+ this does not have that luxury. */
5217
+ try {
5218
+ tell();
5219
+ } catch (e) {
5220
+ /* The page moved on without us: the next sign of navigation
5221
+ compares the path again. */
5222
+ }
5223
+ return result;
5224
+ };
5225
+ /* A HISTORY THE SITE FROZE. Object.freeze(History.prototype) -- a
5226
+ hardening script does it -- makes this assignment throw, since the
5227
+ bundle is strict, and it threw before the boot had started: the
5228
+ tool never appeared, on a page that had done nothing wrong. It is
5229
+ not worked around with defineProperty on the instance either: a
5230
+ site that froze its history has said it is not to be wrapped. This
5231
+ copy boots without hearing pushState, and hears the rest. */
5232
+ try {
5233
+ history[name] = wrapper;
5234
+ } catch (e) {
5235
+ /* Refused: the site's history stays exactly as the site froze it. */
5236
+ }
5237
+ });
5238
+ return true;
5239
+ };
5240
+
5241
+ /**
5242
+ * WHAT A CHANGE OF ADDRESS ASKS OF THIS COPY -- the whole decision, with no
5243
+ * DOM in it, so it is checked rather than described.
5244
+ *
5245
+ * none nothing to do: same path, or a copy that must not move
5246
+ * note out of scope and already standing down there: remember the path
5247
+ * leave the path left the declared prefix: take everything down
5248
+ * enter the path came back into it: boot, as a full load of it would
5249
+ * follow another page for a running tool: its index, its notes
5250
+ * wait another page, but the tool is not in its normal shape -- a boot
5251
+ * under way, a key being asked for, a silence. Nothing is recorded,
5252
+ * so the boot looks again when it lands (proceed, 90-boot).
5253
+ *
5254
+ * `frozen` is a configuration that was refused, or a copy that has handed
5255
+ * over: neither depends on the page, and neither may act on one.
5256
+ */
5257
+ const pageStep = (s) => {
5258
+ if (s.frozen) return 'none';
5259
+ if (s.path === s.known) return 'none';
5260
+ if (!s.inScope) return s.outOfScope ? 'note' : 'leave';
5261
+ if (s.outOfScope) return 'enter';
5262
+ return s.running ? 'follow' : 'wait';
5263
+ };
5264
+
5265
+ /**
5266
+ * WHETHER AN ANSWER STILL BELONGS TO THE BOOT THAT ASKED FOR IT.
5267
+ *
5268
+ * A boot is a derivation, a request and a label file, and the reader can
5269
+ * leave the declared prefix and come back into it before it lands. Coming
5270
+ * back starts a second boot (pageStep: enter) while the first is still on
5271
+ * the network, and the first one's list, applied, is page A's notes opened
5272
+ * with page B's index: every one of them "unreadable". So each boot carries
5273
+ * the number it was started under (`run`, against bootRun in 30-state) and
5274
+ * the index it asked with, and an answer that lands under another of either
5275
+ * is dropped whole. `index` undefined is a step taken before there is one.
5276
+ */
5277
+ const bootIsStale = (s) => s.run !== s.current
5278
+ || (s.index !== undefined && s.index !== s.pageIndex);
5279
+
5280
+ /* -- What the running copy does about it --------------------------------- */
5281
+
5282
+ /** Everything that belongs to ONE page and to no other. The key, the project
5283
+ totals and the side of the panel are not in it: they belong to the
5284
+ project and to the browser, and a navigation changes neither. */
5285
+ const forgetPage = () => {
5286
+ notes = [];
5287
+ anchored = [];
5288
+ orphans = [];
5289
+ historyOpen = false;
5290
+ currentFailure = null;
5291
+ skipped = { newer: 0, unreadable: 0, unknown: 0 };
5292
+ };
5293
+
5294
+ /**
5295
+ * Another page, and the tool is running: the notes of this one, from now.
5296
+ *
5297
+ * THE PANEL STAYS OPEN IF IT WAS. In annotation mode every click on the page
5298
+ * is captured, so a navigation that happens then is the back button or the
5299
+ * site's own doing -- and a reviewer who pressed Back while reading the list
5300
+ * wants the list of where they landed, not to have the tool closed on them.
5301
+ *
5302
+ * WHAT DOES NOT SURVIVE is whatever was aimed at the page that left: the
5303
+ * window of a remark, the form half written, the outline. The element they
5304
+ * point at is gone, and a remark sent from that form now would be filed under
5305
+ * the NEW page's index -- a note on the wrong page, which is worse than a
5306
+ * note not written.
5307
+ *
5308
+ * THE OLD NOTES GO BEFORE THE NEW ONES ARRIVE. The panel is redrawn empty at
5309
+ * once, and PAGE_INDEX is cleared until the new one is computed: a reload
5310
+ * started in that gap (entering the mode, a reply landing) asks for nothing
5311
+ * rather than for the page that left, and one already in flight is discarded
5312
+ * when it lands (reload, 90-boot).
5313
+ */
5314
+ const changePage = () => {
5315
+ const path = PAGE_PATH;
5316
+ const derived = keys;
5317
+ closePop();
5318
+ closeForm();
5319
+ hideHighlight();
5320
+ hovered = null;
5321
+ forgetPage();
5322
+ PAGE_INDEX = '';
5323
+ redraw();
5324
+ return indexOfPath(derived.indexKey, path).then((index) => {
5325
+ // Moved again meanwhile, or the key was forgotten or replaced: the
5326
+ // later change owns the page now.
5327
+ if (path !== PAGE_PATH || keys !== derived) return null;
5328
+ PAGE_INDEX = index;
5329
+ return reload();
5330
+ });
5331
+ };
5332
+
5333
+ /** Out of the declared prefix: exactly what a full load of that page shows,
5334
+ which is nothing. The key stays: coming back must not ask for it. */
5335
+ const stepAside = () => {
5336
+ // A boot still on the network belongs to the page that left (bootIsStale).
5337
+ bootRun += 1;
5338
+ withdraw();
5339
+ forgetPage();
5340
+ PAGE_INDEX = '';
5341
+ outOfScope = true;
5342
+ };
5343
+
5344
+ /** Compares the address with the page this copy is on, and acts. */
5345
+ const followPage = () => {
5346
+ const path = pagePath();
5347
+ const step = pageStep({
5348
+ frozen: !!CONFIG_FAILURE || handingOver,
5349
+ path: path,
5350
+ known: PAGE_PATH,
5351
+ inScope: inScope(),
5352
+ outOfScope: outOfScope,
5353
+ running: !!(keys && ui)
5354
+ });
5355
+ if (step === 'none' || step === 'wait') return step;
5356
+ PAGE_PATH = path;
5357
+ if (step === 'leave') stepAside();
5358
+ else if (step === 'enter') start();
5359
+ else if (step === 'follow') changePage();
5360
+ return step;
5361
+ };
5362
+
5363
+ /* -- The host element, kept in the document ------------------------------
5364
+ The host is a child of <body>, and a body that is replaced -- or emptied and
5365
+ refilled -- takes it along. It is PUT BACK rather than moved somewhere a
5366
+ swap cannot reach: its shadow root, its stylesheet and its listeners are
5367
+ all intact on the detached element, so reattaching it is the whole repair,
5368
+ and the one element the site receives stays where it always was.
5369
+
5370
+ WATCHED ON TWO NODES, NEITHER OF THEM IN DEPTH. <html>'s children, which is
5371
+ where a body is swapped whole; the body's own children, which is where one
5372
+ is emptied. childList without subtree: the callback runs for a change at
5373
+ those two levels and for nothing else the page does, however busy. */
5374
+
5375
+ let hostWatch = null;
5376
+ let watchedBody = null;
5377
+
5378
+ /* HOW OFTEN THE HOST IS PUT BACK, AND WHEN THAT STOPS.
5379
+
5380
+ A site can remove, on purpose, every child of <body> it does not know --
5381
+ a MutationObserver of its own, a "clean the DOM" script. Each removal is a
5382
+ mutation this copy answers by putting the host back, and each putting back
5383
+ is a mutation the site answers by removing it. Both callbacks are
5384
+ microtasks: the browser never gets to paint or to take a click again, and
5385
+ the page is frozen. Unbounded, this repair is the one failure the tool may
5386
+ never cause.
5387
+
5388
+ So what is COUNTED is the ping-pong itself: a host found removed less than
5389
+ CONTESTED_WITHIN milliseconds after it was put back. REATTACH_LIMIT of
5390
+ those IN A ROW is somebody removing the element on purpose, and the tool
5391
+ then stops, takes everything it holds down with it, and says so once: an
5392
+ element that vanishes with nothing said is the failure nobody finds.
5393
+
5394
+ NOT A NUMBER OF SWAPS PER WINDOW, which is what this was, and it switched
5395
+ the tool off on a site doing nothing wrong. Turbo visiting a page it has
5396
+ cached swaps the body twice -- the preview, then the response -- so five
5397
+ quick pagination clicks, or ten presses on Back, spent a budget of ten in
5398
+ two seconds. Those two swaps can land within a few milliseconds of each
5399
+ other, but the next navigation waits for a person: any removal later than
5400
+ CONTESTED_WITHIN starts the count again. A loop that removes the element
5401
+ more slowly than that is not refused, and does not need to be: the browser
5402
+ paints and takes clicks between two of its rounds. */
5403
+ const REATTACH_LIMIT = 10;
5404
+ const CONTESTED_WITHIN = 100;
5405
+ const reattached = { at: -Infinity, contested: 0 };
5406
+ let reattachRefusalSaid = false;
5407
+
5408
+ /** Records one putting back at `now` in `record`. False when REATTACH_LIMIT
5409
+ removals in a row each came within CONTESTED_WITHIN of the putting back
5410
+ before it. */
5411
+ const reattachAllowed = (record, now) => {
5412
+ record.contested = now - record.at < CONTESTED_WITHIN ? record.contested + 1 : 0;
5413
+ if (record.contested >= REATTACH_LIMIT) return false;
5414
+ record.at = now;
5415
+ return true;
5416
+ };
5417
+
5418
+ const watchFrame = () => {
5419
+ hostWatch.disconnect();
5420
+ watchedBody = document.body;
5421
+ hostWatch.observe(document.documentElement, { childList: true });
5422
+ if (watchedBody) hostWatch.observe(watchedBody, { childList: true });
5423
+ };
5424
+
5425
+ /* A mutation is a sign the page may have changed: the same question a
5426
+ re-executed tag or a history change asks, answered in the same place. */
5427
+ const watchHost = () => {
5428
+ if (hostWatch || typeof MutationObserver !== 'function') return;
5429
+ hostWatch = new MutationObserver(() => recheck());
5430
+ watchFrame();
5431
+ };
5432
+
5433
+ const unwatchHost = () => {
5434
+ if (hostWatch) hostWatch.disconnect();
5435
+ hostWatch = null;
5436
+ watchedBody = null;
5437
+ };
5438
+
5439
+ const keepHostAttached = () => {
5440
+ const body = document.body;
5441
+ if (!body) return;
5442
+ const swapped = !!hostWatch && watchedBody !== body;
5443
+ if (swapped) {
5444
+ watchFrame();
5445
+ /* ANNOTATION MODE WATCHES THE BODY IN DEPTH (enterMode), and the one
5446
+ it watches has just left the document: it would never raise
5447
+ domDirty again. It moves to the body that is there, and the
5448
+ anchoring is redone once, since every element it held is gone. */
5449
+ if (observer) {
5450
+ observer.disconnect();
5451
+ observer.observe(body, { childList: true, subtree: true });
5452
+ domDirty = true;
5453
+ }
5454
+ }
5455
+ if (!host) return;
5456
+ const detached = !host.isConnected;
5457
+ if (!detached && !swapped) return;
5458
+
5459
+ /* COPIES OF THE HOST THAT ARE NOT THE HOST. Turbo keeps a snapshot of
5460
+ every page it leaves as body.cloneNode(true), and htmx keeps its history
5461
+ as the body's markup: both put back, on Back, a body carrying an
5462
+ <annotepage-notes> with the inline style and without the shadow root --
5463
+ a full-screen element with nothing in it. Removed, because it is ours;
5464
+ and only when it has no shadow root, because one that has is a tool,
5465
+ and not this copy's to remove. */
5466
+ const found = document.querySelectorAll('annotepage-notes');
5467
+ for (let i = 0; i < found.length; i += 1) {
5468
+ if (found[i] !== host && !found[i].shadowRoot) found[i].remove();
5469
+ }
5470
+ if (!detached) return;
5471
+ if (!reattachAllowed(reattached, Date.now())) {
5472
+ /* THE BOOT UNDER WAY ENDS HERE TOO. The ping-pong runs in microtasks,
5473
+ so it can spend the budget while a label file is still on the
5474
+ network -- and that boot, landing, would build its interface into
5475
+ the shadow root withdraw() has just dropped: a TypeError in the
5476
+ site's error tracker. Raising the run makes every later turn of
5477
+ it a stale one (bootIsStale), which is how stepAside stops a boot
5478
+ as well. */
5479
+ bootRun += 1;
5480
+ withdraw();
5481
+ if (!reattachRefusalSaid) {
5482
+ reattachRefusalSaid = true;
5483
+ complain('something on this page removes the element this client draws in '
5484
+ + '(<annotepage-notes>) each time it is put back. It was put back '
5485
+ + REATTACH_LIMIT + ' times in a row, each removed again within '
5486
+ + CONTESTED_WITHIN + ' ms, and the tool has stopped rather than freeze '
5487
+ + 'the page. Whatever removes unknown children of <body> has to leave '
5488
+ + 'that element alone.');
5489
+ }
5490
+ return;
5491
+ }
5492
+ body.appendChild(host);
5493
+ };
5494
+
5495
+ /**
5496
+ * THE ONE ANSWER to every sign that the page may have changed: a history
5497
+ * entry, a traversal, a body swapped, a tag executed again. Each of them asks
5498
+ * both questions, since none of them says which one it is about: Turbo swaps
5499
+ * the body AND pushes a history entry, and a re-executed tag says nothing at
5500
+ * all about which.
5501
+ */
5502
+ function recheck() {
5503
+ keepHostAttached();
5504
+ followPage();
5505
+ }
5506
+
4534
5507
  /* ==== 90-boot.js ==== */
4535
5508
 
4536
5509
  /* -- 20. Reading the notes ----------------------------------------------- */
@@ -4542,8 +5515,18 @@
4542
5515
  drawMarkers();
4543
5516
  };
4544
5517
 
4545
- const reload = () =>
4546
- call('list').then((r) => {
5518
+ /* A LIST BELONGS TO THE PAGE IT WAS ASKED FOR. The tool now outlives its
5519
+ first page (85-pages), so an answer can land after the reader has moved on:
5520
+ a slow list, or a reply sent just before Back. Applied, it would put the
5521
+ notes of the page that left on the page that came -- the very defect being
5522
+ fixed -- so the index is remembered at the question and compared at the
5523
+ answer, twice, since decrypting takes a turn of its own. No index at all is
5524
+ the gap while the next one is computed: nothing is asked then. */
5525
+ const reload = () => {
5526
+ const index = PAGE_INDEX;
5527
+ if (!index) return Promise.resolve(null);
5528
+ return call('list').then((r) => {
5529
+ if (index !== PAGE_INDEX) return null;
4547
5530
  if (!r.ok) {
4548
5531
  // The tool is already in place: we no longer keep quiet. The
4549
5532
  // notes already on screen stay, with the warning that they may
@@ -4559,12 +5542,14 @@
4559
5542
  expired = readExpired(r.data);
4560
5543
  serverWide = readServerTotals(r.data);
4561
5544
  return readList(r.data).then((read) => {
5545
+ if (index !== PAGE_INDEX) return null;
4562
5546
  notes = read;
4563
5547
  currentFailure = null;
4564
5548
  redraw();
4565
5549
  return null;
4566
5550
  });
4567
5551
  });
5552
+ };
4568
5553
 
4569
5554
  /* -- 21. Startup ----------------------------------------------------------
4570
5555
  The order matters: we ask the API BEFORE touching the DOM. If it does not
@@ -4633,15 +5618,28 @@
4633
5618
  const withdraw = () => {
4634
5619
  if (ui && mode) leaveMode();
4635
5620
  if (host) host.remove();
5621
+ // The watch that puts the host back (85-pages) goes with it, or the next
5622
+ // body swap would find nothing to restore and keep observing for ever.
5623
+ unwatchHost();
4636
5624
  host = null;
4637
5625
  root = null;
4638
5626
  ui = null;
4639
5627
  };
4640
5628
 
4641
- /** A blocking screen: the host exists from now on, the labels come first. */
5629
+ /** The one reading of bootIsStale (85-pages) this file makes, against the
5630
+ boot and the page as they are now. */
5631
+ const staleBoot = (run, index) => bootIsStale({
5632
+ run: run, current: bootRun, index: index, pageIndex: PAGE_INDEX });
5633
+
5634
+ /** A blocking screen: the host exists from now on, the labels come first.
5635
+ A screen whose labels land after the reader left the prefix is not opened:
5636
+ stepAside has already taken its host down. */
4642
5637
  const showScreen = (open) => {
5638
+ const run = bootRun;
4643
5639
  buildHost();
4644
- loadLabels().then(open);
5640
+ loadLabels().then(() => {
5641
+ if (!staleBoot(run)) open();
5642
+ });
4645
5643
  };
4646
5644
 
4647
5645
  /**
@@ -4668,12 +5666,20 @@
4668
5666
  keyText = text;
4669
5667
  keys = derived;
4670
5668
 
4671
- return indexOfPath(keys.indexKey, pagePath())
4672
- .then((index) => {
4673
- PAGE_INDEX = index;
4674
- return call('list');
4675
- })
4676
- .then((first) => {
5669
+ /* The path is read HERE and not at the top of start(): a key pasted on
5670
+ the key screen can arrive several pages after the boot began. */
5671
+ PAGE_PATH = pagePath();
5672
+ const run = bootRun;
5673
+ return indexOfPath(keys.indexKey, PAGE_PATH).then((index) => {
5674
+ if (staleBoot(run)) return null;
5675
+ PAGE_INDEX = index;
5676
+ return call('list').then((first) => {
5677
+ /* The reader left the declared prefix while this boot was on the
5678
+ network -- and may already be back in it, under a boot of its
5679
+ own (bootIsStale, 85-pages). Either way this answer is about a
5680
+ page that left, and nothing is done with it: not shown, and not
5681
+ a silence that would withdraw the newer boot's tool. */
5682
+ if (staleBoot(run, index)) return null;
4677
5683
  if (!first.ok && !speaksAtStartup(first)) {
4678
5684
  // Complete silence: no node, no pixel, no message. If a key
4679
5685
  // screen was open, it goes away with the rest.
@@ -4706,11 +5712,12 @@
4706
5712
  it comes from, and replacing ourselves from a CDN would undo
4707
5713
  that choice behind their back. */
4708
5714
  const cdn = newer ? cdnServing(SCRIPT_SRC) : null;
4709
- if (cdn && handOverTo(cdn, newer, () => { proceed(first); })) return null;
5715
+ if (cdn && handOverTo(cdn, newer, () => { proceed(first, run, index); })) return null;
4710
5716
  if (newer) upgradeAvailable = newer;
4711
5717
 
4712
- return proceed(first);
5718
+ return proceed(first, run, index);
4713
5719
  });
5720
+ });
4714
5721
  }
4715
5722
 
4716
5723
  /**
@@ -4741,24 +5748,25 @@
4741
5748
  keyText = '';
4742
5749
  keys = null;
4743
5750
  PAGE_INDEX = '';
4744
- notes = [];
4745
- anchored = [];
4746
- orphans = [];
4747
- historyOpen = false;
4748
- currentFailure = null;
4749
- skipped = { newer: 0, unreadable: 0, unknown: 0 };
5751
+ // The page's own state, from the one list of it (85-pages): a navigation
5752
+ // drops the same things, and two copies of that list would drift.
5753
+ forgetPage();
4750
5754
 
4751
5755
  // And the tool is back where it was before the key was pasted: the
4752
5756
  // screen that asks for it. openSaltScreen clears the layer it replaces.
4753
5757
  openSaltScreen();
4754
5758
  };
4755
5759
 
4756
- /** Everything the tool does once it has decided to stay. */
4757
- function proceed(first) {
5760
+ /** Everything the tool does once it has decided to stay -- for the boot
5761
+ numbered `run`, which asked with `index`. Checked at every turn it takes:
5762
+ it is also called late, when a hand-over fails (80-upgrade). */
5763
+ function proceed(first, run, index) {
5764
+ if (staleBoot(run, index)) return Promise.resolve(null);
4758
5765
  // From here on the tool EXISTS, and will no longer keep quiet
4759
5766
  // about its failures.
4760
5767
  buildHost();
4761
5768
  return loadLabels().then(() => {
5769
+ if (staleBoot(run, index)) return null;
4762
5770
  clearLayer();
4763
5771
  buildUi();
4764
5772
  if (first.ok) {
@@ -4767,6 +5775,7 @@
4767
5775
  expired = readExpired(first.data);
4768
5776
  serverWide = readServerTotals(first.data);
4769
5777
  return readList(first.data).then((read) => {
5778
+ if (staleBoot(run, index)) return null;
4770
5779
  notes = read;
4771
5780
  redraw();
4772
5781
  return null;
@@ -4775,10 +5784,23 @@
4775
5784
  currentFailure = failureFrom(first, 'error.title_read');
4776
5785
  redraw();
4777
5786
  return null;
5787
+ }).then(() => {
5788
+ if (staleBoot(run, index)) return null;
5789
+ /* THE ADDRESS MAY HAVE MOVED DURING THE BOOT: a derivation, a request
5790
+ and a label file is long enough for a router to push a page. The
5791
+ signs that arrived meanwhile were told to wait (pageStep), so this
5792
+ is where they are answered -- and on a page that did not move it
5793
+ compares two equal strings. */
5794
+ followPage();
5795
+ return null;
4778
5796
  });
4779
5797
  }
4780
5798
 
4781
5799
  const start = () => {
5800
+ // A boot of its own: whatever an earlier one still has on the network is
5801
+ // dropped when it lands (bootIsStale, 85-pages).
5802
+ bootRun += 1;
5803
+ const run = bootRun;
4782
5804
  author = readAuthor();
4783
5805
  // Read ONCE, here, and never again: the side is asked of the storage at
4784
5806
  // startup like the name, not at every draw.
@@ -4801,7 +5823,12 @@
4801
5823
 
4802
5824
  // Outside the project's scope: silence. So the declaration can live in a
4803
5825
  // template shared by the whole site.
4804
- if (!inScope()) return;
5826
+ //
5827
+ // And the reason is REMEMBERED: it is the only silence that a later
5828
+ // navigation can lift (85-pages).
5829
+ PAGE_PATH = pagePath();
5830
+ outOfScope = !inScope();
5831
+ if (outOfScope) return;
4805
5832
 
4806
5833
  if (!CRYPTO) {
4807
5834
  // Without a secure context nothing is possible -- but if somebody
@@ -4828,6 +5855,7 @@
4828
5855
  }
4829
5856
 
4830
5857
  derive(keyBytes).then((derived) => {
5858
+ if (staleBoot(run)) return null;
4831
5859
  /* Both attributes on one tag: they have to AGREE, and the id is
4832
5860
  the one thing the key can check itself against (FORMAT.md
4833
5861
  1.2). Disagreement is refused exactly as a wrongly pasted key
@@ -4845,7 +5873,7 @@
4845
5873
  }, () => {
4846
5874
  // derive() only fails when WebCrypto itself does, which is what
4847
5875
  // that screen is about.
4848
- showScreen(openContextScreen);
5876
+ if (!staleBoot(run)) showScreen(openContextScreen);
4849
5877
  });
4850
5878
  return;
4851
5879
  }
@@ -4863,6 +5891,7 @@
4863
5891
  }
4864
5892
 
4865
5893
  derive(bytes).then((derived) => {
5894
+ if (staleBoot(run)) return null;
4866
5895
  if (derived.id !== PROJECT) {
4867
5896
  // The key stored under this key does not derive this id: the
4868
5897
  // tag has changed project, or the storage was tampered with. We
@@ -4872,10 +5901,24 @@
4872
5901
  }
4873
5902
  return startWithSalt(text, derived);
4874
5903
  }, () => {
4875
- showScreen(openSaltScreen);
5904
+ if (!staleBoot(run)) showScreen(openSaltScreen);
4876
5905
  });
4877
5906
  };
4878
5907
 
5908
+ /* THIS COPY, AS OTHER COPIES SEE IT. The shape is a contract with versions
5909
+ that do not exist yet: see 00-preamble. The claim cannot fail here -- a copy
5910
+ that found the document held has already returned from the preamble, and
5911
+ nothing between the two is asynchronous. `identity` is what a later copy
5912
+ compares its own configuration with, to know whether it is this one
5913
+ executed again or a second tool it must refuse. */
5914
+ const thisCopy = { version: TOOL_VERSION, identity: COPY_IDENTITY, recheck: recheck };
5915
+ claimDocument(document, thisCopy);
5916
+
5917
+ /* Listening starts before the boot and whatever the boot decides: a page
5918
+ outside the declared prefix is exactly the one that needs to hear the next
5919
+ navigation. */
5920
+ listenForPages(window, document);
5921
+
4879
5922
  if (document.body) {
4880
5923
  start();
4881
5924
  } else {