diff --git a/.github/workflows/generated-allen-audio.yml b/.github/workflows/generated-allen-audio.yml new file mode 100644 index 0000000..a8a2242 --- /dev/null +++ b/.github/workflows/generated-allen-audio.yml @@ -0,0 +1,26 @@ +name: Generated Allen audio +on: + pull_request: + paths: + - 'om/allen-audio/**' + - 'public/audio/allen-chirp.wav' + - 'public/js/allen-audio.js' + - '.github/workflows/generated-allen-audio.yml' + push: + branches: [main] + paths: + - 'om/allen-audio/**' + - 'public/audio/allen-chirp.wav' + - 'public/js/allen-audio.js' + - '.github/workflows/generated-allen-audio.yml' +permissions: + contents: read +jobs: + artifact-hashes: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # Hashes committed bytes only; the arm64 omc pin and the aienux oracle run in om/allen-audio/check.sh. + - name: Check the Omega-generated sound and script against their sidecars + working-directory: om/allen-audio + run: sha256sum -c allen-chirp.wav.sha256 allen-audio.js.sha256 diff --git a/.github/workflows/generated-hive.yml b/.github/workflows/generated-hive.yml index d4a0bb5..6dd39a3 100644 --- a/.github/workflows/generated-hive.yml +++ b/.github/workflows/generated-hive.yml @@ -6,6 +6,8 @@ on: - 'om/alpha-page/**' - 'public/js/alpha.js' - 'public/alpha/**' + - 'om/allen-intro/**' + - 'public/js/allen-intro.js' - 'public/js/hive.js' - 'public/js/turing-look.js' - 'crates/site-builder/**' @@ -17,6 +19,8 @@ on: - 'om/alpha-page/**' - 'public/js/alpha.js' - 'public/alpha/**' + - 'om/allen-intro/**' + - 'public/js/allen-intro.js' - 'public/js/hive.js' - 'public/js/turing-look.js' - 'crates/site-builder/**' @@ -35,3 +39,5 @@ jobs: run: cargo test --manifest-path crates/site-builder/Cargo.toml components::hive::tests::served_scripts_match_their_omega_generated_sha256 -- --exact - name: Check generated Alpha page and source run: cargo test --manifest-path crates/site-builder/Cargo.toml components::alpha::tests -- --nocapture + - name: Check generated Allen consent aside and script + run: cargo test --manifest-path crates/site-builder/Cargo.toml components::allen_intro::tests::allen_intro_artifacts_match_their_omega_generated_sha256 -- --exact diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 2f8b1bd..3263337 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -99,6 +99,8 @@ jobs: run: cargo test --release -p site-builder the_embedded_skeleton_matches_its_recorded_sha256 - name: Check the committed Alpha artifacts run: cargo test --release -p site-builder components::alpha::tests + - name: Check the committed Allen consent aside and script digests + run: cargo test --release -p site-builder allen_intro_artifacts_match_their_omega_generated_sha256 - name: Build static site with pure Rust engine run: cargo run --release --manifest-path crates/site-builder/Cargo.toml -- build dist - name: Upload Pages artifact diff --git a/AGENTS.md b/AGENTS.md index 076c051..cd54075 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -69,13 +69,14 @@ Open `http://127.0.0.1:8080/` after the preview server starts. GitHub Pages serv - Every page gets its head rewritten by `seo::enrich`: canonical on `https://www.aienos.com`, Open Graph and Twitter cards, hreflang, JSON-LD, `rel="alternate" type="text/markdown"`, `rel="describedby"` to `/llms.txt`, and robots snippet directives. Do not duplicate those tags in a component. - Every page also gets a Markdown mirror at the same path with `.md` (`/` becomes `/index.md`), with YAML frontmatter and a `## Sitemap` section. The mirror is generated from the final HTML; do not hand-write one. - Voice: Drake writes this site alone, in first person singular (I, me, my). Never a plural first-person word (the list is the regex in `voice::plural`). Where agents did the work, say so ("my agents", "I build this with AI agents"); never credit Drake with an agent's work, and never imply a team. Shared human claims use "everyone" or "people". `components::voice::verify_singular_voice` fails the build on any plural first-person word in rendered `dist` text (`.html` visible text, `.md`, `.txt`). Not counted: markup, scripts, styles, link targets, path/identifier parts (`how-we-did-it`), `50 us`, and on the ledger pages (`voice::LEDGER_PAGES`) text found verbatim in `data/now.tsv`, which is a dated record. Quotes of other people go in `voice::ALLOW` as (file, exact phrase); keep it small. Repository descriptions render on /agents/, so fix the GitHub description, not just `agent-repos.json`. -- Copy rules: no em dashes, no en dashes, no outside fonts or unconditional third-party scripts/trackers. The sole tracking exception is X pixel `rfrlz`, loaded from the first-party `public/js/allen-intro.js` only after explicit consent to the Allen introduction. Never embed `uwt.js` as a script source in HTML, inline its bootstrap, or preconnect/prefetch X hosts. The verifier rejects outside script sources on every emitted HTML page; `node scripts/test-allen-intro.cjs` exercises refusal, consent, reload and revocation. +- Allen speaks in his own voice: a plural pronoun in his speech means Allen and the visitor, not Drake plus a team. Only elements marked exactly `data-speaker="allen"` are removed before the plural check (`voice::ALLEN_SPEECH`, tested with negative controls: untagged copy, lookalike attributes, marker text and unclosed elements still fail). Tag Allen's speech and nothing else; Drake's page copy stays under the rule. +- Copy rules: no em dashes, no en dashes, no outside fonts or unconditional third-party scripts/trackers. The sole tracking exception is X pixel `rfrlz`, loaded from the first-party `public/js/allen-intro.js` only after the visitor chooses Say hi to Allen. Never embed `uwt.js` as a script source in HTML, inline its bootstrap, or preconnect/prefetch X hosts. The verifier rejects outside script sources on every emitted HTML page; `node scripts/test-allen-intro.cjs` exercises refusal, consent, reload and revocation. - Keep one source for machine-readable state. `status.json`, the status section, and the current-state lines in `llms.txt` all read `components::status::layer_states()`. - Tests live beside the code in `#[cfg(test)]` modules. Add a test when a rule can regress silently. -- The final shared `components::allen_intro::enrich` pass in `seo::enrich` adds one local consent loader, a native modal dialog and a privacy link to generated, hand-written and translated pages. `404.html` gets the same pass. `/privacy/` stays readable without an automatic modal and provides review and refusal controls. No and Escape persist refusal, with no automatic re-prompt. Stored Yes permits one initialization per document; refusal of an active pixel reloads without it. Local storage holds the choice; a session-storage refusal and `#allen-intro-no` protect reload if persistent storage fails. Storage clearing or another browser resets the choice, not consent. +- The final shared `components::allen_intro::enrich` pass in `seo::enrich` adds one local consent loader, Allen's hello aside and a privacy link to generated, hand-written and translated pages. `404.html` gets the same pass. The hello is a non-blocking `role="complementary"` aside (`aria-live="polite"`), never a modal: no backdrop, no `showModal`, focus moves only when the visitor asks via Review my choice. Allen calls Drake by name; the copy never mentions ads or how the visitor arrived. Memory consent (links to `/aien/?mode=remember` and `?mode=anonymous`) and X consent (Say hi / No thanks buttons) stay separate controls; one tap never means both. Global Privacy Control suppresses the pixel offer except on explicit Review; anonymous `/allen/` never loads the pixel. The Who can see me right now? panel is local-only (resource timing, navigator fields; no network, storage, hashing or IP lookup). The aside markup, Allen's words and `public/js/allen-intro.js` are generated by seeded Omega: edit `om/allen-intro/intro.om`, run `sh om/allen-intro/check.sh` (pinned `om/hive-page/omc`; `OMEGA_ACCEPT_CHANGE=1` to accept), and commit `intro.html`, the script and their sha256 sidecars; `components::allen_intro` only embeds the aside, and a unit test (also run in Pages and `generated-hive.yml`) re-hashes both artifacts. The visual layer uses only `window.aienAllenIntro` and `aien-allen-intro` events. A page with its own welcome marks `[data-allen-intro-defer]` and calls `aienAllenIntro.greet()` after it, so Allen's greeting follows the door instead of covering it. It auto-appears once per browser: first display writes `aien-allen-intro-seen` (session storage when local storage fails), chosen or not, and unanswered means No. `/privacy/` stays readable without it and provides review and refusal controls. No thanks, the close button and Escape persist refusal. Stored Yes permits one initialization per document; refusal of an active pixel reloads without it. Local storage holds the choice; a session-storage refusal and `#allen-intro-no` protect reload if persistent storage fails. Storage clearing or another browser resets the choice and the greeting, never consent. - Every page shows how to reach Drake: the header nav ends with the `aien-nav-reach` group (the `/contact/` page and a plain "Follow me on X" link to `https://x.com/mdrakestapleton` with an inline SVG mark, no widget or script), and the footer carries the `aien-reach-foot` line (X, `drake@aienos.com`, `/allen/`, GitHub aien-dev). Generated pages get both from `components::navbar` and `components::footer`; `components::contact::enrich` in `seo::enrich` adds them to hand-written and `/zh-CN/` pages (Chinese labels there), and `contact::verify` fails the build if any HTML page in `dist` lacks either. -- CSP coordination: no inline allen-intro scripts. An edge CSP for a page that enables this feature needs `script-src 'self' https://static.ads-twitter.com` and `connect-src` / `img-src` permissions for `https://analytics.twitter.com`, `https://analytics.x.com` and `https://t.co` (in addition to its first-party sources). These are the hosts named by the official loader inspected on 2026-10-26, not a wildcard allowance. CSP permissions are static, not conditional consent: `allen-intro.js` enforces consent before any X load. Do not loosen a no-JS edge board CSP; explicitly exclude that board from enrichment if introduced. `allen-intro.js` is outside the separate Hive/Turing Omega-generation change, by agreement with that lane. -- Before publishing a consent change, build `dist`, run `node scripts/test-allen-intro.cjs dist/js/allen-intro.js`, and verify in a real browser with cache disabled and requests observed before navigation: unknown/No/Escape and reload produce no X requests and no `window.twq`; saying hello requests the exact loader and configures `rfrlz` once. Test at mobile width 390, verify modal focus and keyboard dismissal, and run a guard-bypass negative control. Intercepted X requests prove gating, not X ingestion. The public project board and storage of check-ins are deferred pending Drake's storage decision; never collect entries under the pixel consent. +- CSP coordination: no inline allen-intro scripts. An edge CSP for a page that enables this feature needs `script-src 'self' https://static.ads-twitter.com` and `connect-src` / `img-src` permissions for `https://analytics.twitter.com`, `https://analytics.x.com` and `https://t.co` (in addition to its first-party sources). These are the hosts named by the official loader inspected on 2026-10-26, not a wildcard allowance. CSP permissions are static, not conditional consent: `allen-intro.js` enforces consent before any X load. Do not loosen a no-JS edge board CSP; explicitly exclude that board from enrichment if introduced. `allen-intro.js` is generated: it is written on fd 3 by `om/allen-intro/intro.om` beside the aside markup; never hand-edit the artifact, edit the `.om` and run `om/allen-intro/check.sh`. +- Before publishing a consent change, build `dist`, run `node scripts/test-allen-intro.cjs dist/js/allen-intro.js`, and verify in a real browser with cache disabled and requests observed before navigation: unknown/No/Escape and reload produce no X requests and no `window.twq`; Say hi requests the exact loader and configures `rfrlz` once; a reload does not show Allen again. Test at mobile width 390, verify the page stays interactive, focus is not stolen and Escape dismisses, and run a guard-bypass negative control. Intercepted X requests prove gating, not X ingestion. The public project board and storage of check-ins are deferred pending Drake's storage decision; never collect entries under the pixel consent. - Only after consent, retain the landing URL's `twclid` under browser-local `aien-allen-intro-twclid`; remove it on refusal. Drake chose pixel-only operation; server Conversion API work is deferred until the introduction flow has a backend. The single `eventIds` constant in `allen-intro.js` holds `pageVisit` and `introducedToAllen`, empty until Drake supplies the real IDs. Empty means no custom event. Configured IDs send one visit per consenting document and one introduced-to-Allen event per explicit introduction document, each with its own `crypto.randomUUID()` `conversion_id`. A future backend must forward that exact ID for deduplication, read `X_PIXEL_TOKEN` only from its private environment, and never expose the token in static output. - Hive's shell and browser client are generated by seeded Omega, never written in Rust or hand-edited in `public/js/`. `om/hive-page/check.sh` composes `contract.om`, `hive.om` and `hive-js.om`: stdout emits `main.html`, fd 3 emits `hive.js`. The shared contract owns ids, poll/freshness bounds and the board route; append entries rather than renumbering. `hive.om` owns the section order (`meta`, eight pipe-separated fields), shell controls, aria wiring and bounded panels. `om/hive-render/render.om` owns feed-derived rows, native details, manifests and messages. The browser only DOMParser-parses same-origin `/hive/board/` and morphs keyed nodes in place, preserving native open state, selection, focus, search and scroll. It never renders JSON or constructs feed markup. `turing-look.js` has its separate Omega generator. Commit sources, artifacts and hashes together; run the generation gate twice, site-builder tests and `scripts/test-hive-cosmic.py`. Neither served JS file is hand-edited. - `.github/workflows/generated-hive.yml` runs only the skeleton-hash and generated-script-hash tests on x86_64 for relevant pull requests and main pushes. It does not run `omc`, regenerate artifacts or change the full-suite-on-Spark policy. diff --git a/README.md b/README.md index f13a9cd..7dde29d 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,23 @@ Live: [https://www.aienos.com](https://www.aienos.com), rebuilt hourly from the The homepage opens with "AienOS is an owned experimental machine for turning search into verified understanding" (`crates/site-builder/src/components/home_loop.rs`) and goes on to the loop, the story, the receipts behind each claim, how the pieces fit together, the research, an interactive terminal, the current status of each layer, and where to follow the work. Other pages: `/start/` (the newcomer route through what AIENOS is, what exists today, how to check the evidence, how to reproduce or contribute, and where the author and Interplane fit), `/progress/`, `/blog/`, `/research/status/`, `/machine/`, `/discovery/` and the hubs `/experiments/`, `/evidence/` and `/philosophy/`. The build also writes `status.json`, `research-status.json` and `llms.txt`; `status.json` and `llms.txt` come from the same code as the homepage status section, and `research-status.json` is `crates/site-builder/data/research_status.json`. The homepage status section says "Public release" is PLANNED, with no supported release or installer yet. -## Introduce yourself to Allen: consent-first X pixel +## Allen says hi: consent-first X pixel -Every built page gets one first-party `/js/allen-intro.js` loader from the final shared document pass, including hand-written pages, translations and the 404 page. Nothing from X is loaded until the visitor explicitly chooses **Introduce yourself to Allen** (or has a saved Yes). The unchanged official X base code configures pixel `rfrlz` once per document. **No** and Escape dismiss the native modal, remember refusal, and do not initialize `twq` or make an X tracking request. The browser tab stays open. `/privacy/` explains what X receives, normal hosting logs, browser-local storage, and how to refuse after consenting. It is readable without an automatic popup. +Every built page gets one first-party `/js/allen-intro.js` loader from the final shared document pass, including hand-written pages, translations and the 404 page. On a visitor's first page Allen appears in a bottom corner (the bottom edge on mobile) and types out Drake's static, client-rendered greeting ("Hi, I'm Aien (you say it like Ian). It's nice to meet you! ..."). It is a non-blocking `role="complementary"` aside with `aria-live="polite"`: no backdrop, no modal, no focus theft, and it never mentions ads. Reduced motion skips the slide and typing. It auto-appears only once per browser: first display records `aien-allen-intro-seen` in local storage (session storage if local storage is unavailable, so once per tab session), chosen or not. Not answering means no consent. It does not auto-appear on `/privacy/` or on the `/allen/` chat page. A page with a welcome of its own (the home door) marks `[data-allen-intro-defer]` and calls `aienAllenIntro.greet()` afterwards; deferral does not spend the once-only greeting. -Run `node scripts/test-allen-intro.cjs` (Node's built-in test runner, verification only) alongside the Rust suite and `build dist`. To exercise the built asset use `node scripts/test-allen-intro.cjs dist/js/allen-intro.js`. Browser verification must observe requests before navigation with cache disabled; check absence of X requests and `window.twq` before consent, after No and after reload, then require the exact loader URL and `config('rfrlz')` after saying hello. Check keyboard focus, Escape and mobile width 390. An intercepted loader tests gating, not ingestion by X. Confirm the real deployed pixel separately with [X Pixel Helper](https://chrome.google.com/webstore/detail/twitter-pixel-helper/jepminnlebllinfmkhfbkpckogoiefpd). +The aside's markup and `public/js/allen-intro.js` are generated by seeded Omega from `om/allen-intro/intro.om` (`sh om/allen-intro/check.sh` writes both with sha256 sidecars; the Rust builder embeds the aside and a test re-hashes both). Never hand-edit either artifact. + +Memory and X consent are separate controls, so one tap never means both. **Tell Aien my name** links to `/aien/?mode=remember`, where `/allen/` shows its own memory-consent step; **Chat anonymously** links to `/aien/?mode=anonymous`. The X pixel ask is its own line with **Say hi** and **No thanks**. Nothing from X is loaded until the visitor chooses **Say hi** (or has a saved Yes), and never while `/allen/` is in anonymous mode (`#allen` without `data-mode="remembered"`). The unchanged official X base code configures pixel `rfrlz` once per document. **No thanks**, the close button and Escape remember refusal and do not initialize `twq`; after **No thanks** Allen offers an anonymous chat. If the browser sends Global Privacy Control, the greeting does not offer the pixel at all; only **Review my choice** on `/privacy/` offers it. + +The **Who can see me right now?** expander lists the outside origins this document actually loaded (resource timing plus a `PerformanceObserver`; 0 before consent, the X origins after **Say hi**, each labelled as Drake's pixel) and what the browser tells every site (user agent, platform, language, timezone, screen size, referrer, Do Not Track, Global Privacy Control, cookies enabled). It is computed and shown locally, never sent or stored: no fingerprint hash, extension probing or IP lookup. It says what it cannot see and links to EFF Cover Your Tracks and Blacklight without embedding them. + +Allen's visual layer drives this through `window.aienAllenIntro` (`text`, `status()`, `sayHi()`, `noThanks()`, `dismiss()`, `review()`, `greet()`, `who()`, `onTrackers(fn)`) and the document `aien-allen-intro` event (`show`, `hide`, `reply-no`, `consent`). Memory consent is not part of that interface. `/privacy/` explains what X receives, normal hosting logs, browser-local storage, and how to refuse after consenting. + +Run `node scripts/test-allen-intro.cjs` (Node's built-in test runner, verification only) alongside the Rust suite and `build dist`. To exercise the built asset use `node scripts/test-allen-intro.cjs dist/js/allen-intro.js`. Browser verification must observe requests before navigation with cache disabled; check absence of X requests and `window.twq` before consent, after No and after reload, then require the exact loader URL and `config('rfrlz')` after Say hi. Check that the who-can-see panel reads 0 before consent and lists the X origins after, that a reload does not show Allen again, that the page stays clickable while he shows, keyboard reach, Escape and mobile width 390. An intercepted loader tests gating, not ingestion by X. Confirm the real deployed pixel separately with [X Pixel Helper](https://chrome.google.com/webstore/detail/twitter-pixel-helper/jepminnlebllinfmkhfbkpckogoiefpd). No new CSP is installed by this feature. If an edge adds one, the Allen introduction needs `script-src 'self' https://static.ads-twitter.com`; `connect-src` and `img-src` need the first-party origin plus `https://analytics.twitter.com`, `https://analytics.x.com`, and `https://t.co`. The official loader inspected on 2026-10-26 names those endpoints; do not permit all X subdomains. CSP permissions cannot vary after a button click: the first-party script is the consent gate. A separate no-JS board should keep its strict CSP and not receive the allen-intro loader. -The community board, project links, leave-times and storage of public check-ins are **deferred**, pending Drake's storage decision. Saying hello here consents only to the pixel and publishes no public entry. +The community board, project links, leave-times and storage of public check-ins are **deferred**, pending Drake's storage decision. Saying hi here consents only to the pixel and publishes no public entry. For consenting visitors only, `allen-intro.js` retains the landing URL's `twclid` in browser local storage (`aien-allen-intro-twclid`); No removes it. Drake chose pixel-only operation for now: the server Conversion API is deferred until the introduction flow has a backend. There is no conversion endpoint, server-side send or `X_PIXEL_TOKEN` in the site bundle. diff --git a/crates/site-builder/src/components/allen.rs b/crates/site-builder/src/components/allen.rs index f48449a..3625bdd 100644 --- a/crates/site-builder/src/components/allen.rs +++ b/crates/site-builder/src/components/allen.rs @@ -272,7 +272,8 @@ mod tests { assert!(function_body(script, "greeting").contains("message('allen', 'Aien')")); assert_eq!(script.matches("dataset.speaker").count(), 1, "only message() marks a speaker"); assert!(!function_body(script, "humanMessage").contains("speaker")); - assert!(!SKELETON.contains("data-speaker"), "Drake's page copy is never marked as Aien's"); + assert_eq!(SKELETON.matches("data-speaker=\"allen\"").count(), 1, "only the initially empty live reply is marked as Allen's"); + assert!(SKELETON.contains("id=\"allen-answer\" class=\"allen-answer\" data-speaker=\"allen\"")); } #[test] @@ -284,8 +285,8 @@ mod tests { ] { assert_eq!(SKELETON.matches(&format!(" id=\"{id}\"")).count(), 1, "exactly one #{id} in the skeleton"); } - assert!(SKELETON.contains("running on a DGX Spark in Drake's house")); - assert!(SKELETON.contains("No prompts or IP addresses are logged.")); + assert!(SKELETON.contains("Timing below is measured from this reply.")); + assert!(SKELETON.contains("Remembering you is a separate choice")); assert!(!SKELETON.contains('\u{2014}') && !SKELETON.contains('\u{2013}'), "no em or en dash"); } @@ -350,4 +351,28 @@ mod tests { assert!(!line.contains("filter") && !line.contains("box-shadow") && !line.contains("transition: all"), "compositor-only motion: {line}"); } } + + #[test] + fn the_presence_keeps_transport_and_consent_boundaries() { + let script = include_str!("../../../../public/js/allen-presence.js"); + let want = recorded(include_str!("../../../../om/allen-presence/presence.sha256")); + assert_eq!(format!("{:x}", Sha256::digest(script.as_bytes())), want); + for banned in ["innerHTML", "outerHTML", "insertAdjacentHTML", "fetch(", "localStorage", "sessionStorage", "eval("] { + assert!(!script.contains(banned), "the presence delegates effects, never uses {banned}"); + } + assert!(script.contains("api.on('human',event => replaceReply(event.text,'Drake'))")); + assert_eq!(script.matches("replaceReply(event.text,'Drake')").count(), 1); + assert!(script.contains("api.on('card',event =>")); + assert!(script.contains("node:event.node")); + assert!(script.contains("prefers-reduced-motion: reduce")); + assert!(!script.contains("AllenAudio.enter("), "the native tube is silent; the home door owns gesture-gated chirp playback"); + assert!(script.contains("window.allenPresence=Object.freeze({ready,enter,scene:() => scene,panes:() => panes})")); + assert!(script.contains("opening:homeDoor?'idle':'dusk'")); + assert!(script.contains("window.visualViewport")); + assert!(script.contains("allen-pane-request")); + assert!(SKELETON.contains("id=\"allen-session\" class=\"allen-session\" aria-label=\"Session history and privacy\" hidden")); + for id in ["allen-universe", "allen-enter", "allen-copy", "allen-regenerate", "allen-history", "allen-projects", "allen-mute", "allen-mic", "allen-speak", "allen-voice-privacy"] { + assert_eq!(SKELETON.matches(&format!("id=\"{id}\"")).count(), 1); + } + } } diff --git a/crates/site-builder/src/components/allen_intro.rs b/crates/site-builder/src/components/allen_intro.rs index 9dd76cb..5864030 100644 --- a/crates/site-builder/src/components/allen_intro.rs +++ b/crates/site-builder/src/components/allen_intro.rs @@ -1,25 +1,13 @@ use maud::{html, Markup}; -pub const HEAD: &str = ""; +pub const HEAD: &str = ""; -fn dialog() -> Markup { - html! { - dialog id="aien-allen-intro" role="dialog" aria-modal="true" aria-labelledby="allen-intro-title" aria-describedby="allen-intro-intro allen-intro-consent" { - h2 id="allen-intro-title" { "Say hello to Allen?" } - p id="allen-intro-intro" { - "Hey, you just clicked an ad. I just want you to know that if you didn't intend to click an ad, that's cool. Just click No and this popup will close. Nothing will be tracked by my X pixel. Your browser may not let me close a page I didn't open." - } - p id="allen-intro-consent" { - "But if you did want to see it, do you mind if I track you and know you were here? Allen is my AI. Introduce yourself to Allen by saying hello below. Saying hello means you consent to the X conversion pixel, so X receives information about your visit and helps me reach the right people. This doesn't open a chat or publish your identity." - } - div class="allen-intro-actions" { - button id="allen-intro-no" type="button" autofocus { "No" } - button id="allen-intro-yes" type="button" { "Introduce yourself to Allen" } - } - p { a href="/privacy/" { "Privacy, what X receives, and your choice" } } - } - } -} +/// Allen's consent aside, generated by seeded Omega (`om/allen-intro/intro.om`, run by +/// `om/allen-intro/check.sh` on arm64). Every structural and copy decision lives there, +/// including Drake's greeting, the separate memory links and X buttons, and the +/// local-only "Who can see me right now?" panel. Allen's speech carries +/// `data-speaker="allen"` for the voice rule. This builder only embeds the bytes. +pub const INTRO: &str = include_str!("../../../../om/allen-intro/intro.html"); /// Final shared document pass covers generated, hand-written and translated pages. /// Idempotence prevents duplicate loaders if an already-enriched page is copied. @@ -29,13 +17,17 @@ pub fn enrich(mut page: String) -> String { page.insert_str(end, HEAD); } if !page.contains("href=\"/privacy/\"") { - let link = "

Privacy & saying hello to Allen

"; + let link = "

Privacy & saying hi to Aien

"; let end = page.rfind("").or_else(|| page.rfind("")).expect("allen-intro page has a body"); page.insert_str(end, link); } if !page.contains("id=\"aien-allen-intro\"") { let end = page.rfind("").expect("allen-intro page has a body"); - page.insert_str(end, &dialog().into_string()); + page.insert_str(end, INTRO); + } + if !page.contains("id=\"aien-allen-launcher\"") { + let end = page.rfind("").expect("Allen presence page has a body"); + page.insert_str(end, include_str!("../../../../om/allen-presence/launcher.html")); } page } @@ -43,11 +35,13 @@ pub fn enrich(mut page: String) -> String { pub fn render_privacy() -> Markup { html! { article id="allen-intro-privacy" class="allen-intro-privacy" { - h1 { "Privacy & saying hello to Allen" } + h1 { "Privacy & saying hi to Aien" } p { "I do not sell your information. I'm open source and free with information about my work, not with your personal data. You can read this site without introducing yourself." } - h2 { "Saying hello means consent to X tracking" } - p { "Allen is Drake's AI. Choosing Introduce yourself to Allen lets me know you were here by allowing X conversion pixel rfrlz to load on this and later pages in this browser. It helps me understand whether my ads reach the right people and helps me broadcast my message to that audience. It does not open an AI chat. I do not ask for your name, collect project links or publish your identity here." } - p { "Before you say hello, I do not load the X pixel or send it information about your visit. No closes only the popup, not your tab, and refuses X tracking. I remember No and do not ask again automatically. Escape means No too. With JavaScript disabled, the pixel never loads." } + h2 { "Saying hi means consent to X tracking" } + p { "Aien is my AI. On your first visit he slides into a corner of the page with a short hello. It is a small aside, not a popup that blocks the page, and he shows it only once in this browser, whether or not you answer. Choosing Say hi lets me know you were here by allowing X conversion pixel rfrlz to load on this and later pages in this browser. It helps me measure whether my posts and ads on X reach the right people. Saying hi does not open an AI chat. I do not ask for your name, collect project links or publish your identity here." } + p { "Before you say hi, I do not load the X pixel or send it information about your visit. No thanks, the close button and Escape all mean No: Aien steps aside and X tracking stays off. Not answering also means No. Aien does not ask again automatically; the Review my choice button below brings him back. With JavaScript disabled, Aien never appears and the pixel never loads." } + p { "After No thanks, Aien says you can still chat with him anonymously: the Chat anonymously link opens /aien/?mode=anonymous, where he does not remember you and nothing goes to X. If your browser sends Global Privacy Control, Aien notes it and does not offer the X pixel when he greets you; only Review my choice on this page offers it." } + p { "Aien's Who can see me right now? section lists the outside origins this tab has actually loaded, from the browser's own resource timing record, and what your browser tells every website automatically: browser, platform, language, timezone, screen size, referrer, Do Not Track, Global Privacy Control and whether cookies are enabled. It is worked out in your browser and shown only to you; nothing in it is sent, stored, hashed into a fingerprint or looked up elsewhere. It cannot see trackers on other sites, in other tabs or inside embedded frames, your internet provider's or network's tracking, or your browser extensions." } h2 { "What X receives" } p { "After consent, your browser connects to X to load its script and send visit and conversion information. This can include the page URL, referrer, IP address, browser or device information and cookie identifiers. X may store cookies and process this information under its own policies. My open source license does not apply to X's service." } p { @@ -56,11 +50,11 @@ pub fn render_privacy() -> Markup { } h2 { "What I keep" } p { "I do not store pixel tracking data on my own servers or operate a check-in database. X processes the pixel data and provides advertising measurement to me. The site and its hosting providers still receive normal web requests and may keep operational access logs; refusing the pixel does not remove those requests." } - p { "Your browser stores only your yes or no choice under aien-allen-intro-consent in local storage, with a refusal also kept in this tab's session storage. That choice stays in this browser until you change it or clear site data. It does not identify you to me. If storage fails while stopping an active pixel, a #allen-intro-no address fragment also preserves refusal through the reload. If all browser storage is unavailable, I cannot remember your choice after you leave this page. Clearing site data or using another browser resets the choice; it never gives consent on its own." } - p { "For consenting visitors only, I also keep the ad's twclid click identifier, if present in the landing URL, in browser local storage under aien-allen-intro-twclid. Refusing removes it where browser storage permits. It is reserved for a future server-side conversion flow; this site currently sends no server-side conversions. No email address, phone number or other identifier is collected for that purpose." } - p { "The two custom events are a consented page visit and introduced to Allen. They stay disabled until Drake supplies their X event IDs. Each enabled event includes a random conversion identifier so a future backend can avoid counting the same event twice; server-side conversions are deferred until that backend exists." } + p { "Your browser stores your yes or no choice under aien-allen-intro-consent in local storage, with a refusal also kept in this tab's session storage. It also stores aien-allen-intro-seen once Aien has said hello, so he does not greet you again; if local storage is unavailable, that note lives in this tab's session storage instead, so he appears at most once per tab session. That choice stays in this browser until you change it or clear site data. It does not identify you to me. If storage fails while stopping an active pixel, a #allen-intro-no address fragment also preserves refusal through the reload. If all browser storage is unavailable, I cannot remember your choice or the greeting after you leave this page. Clearing site data or using another browser resets both, so Aien says hello again; that never gives consent on its own." } + p { "For consenting visitors only, I also keep X's twclid click identifier, if present in the landing URL, in browser local storage under aien-allen-intro-twclid. Refusing removes it where browser storage permits. It is reserved for a future server-side conversion flow; this site currently sends no server-side conversions. No email address, phone number or other identifier is collected for that purpose." } + p { "The two custom events are a consented page visit and saying hi to Aien. They stay disabled until Drake supplies their X event IDs. Each enabled event includes a random conversion identifier so a future backend can avoid counting the same event twice; server-side conversions are deferred until that backend exists." } h2 { "Your choice" } - p id="allen-intro-status" role="status" { "X tracking stays off unless you choose to introduce yourself to Allen. JavaScript is needed to change this browser's choice." } + p id="allen-intro-status" role="status" { "X tracking stays off unless you choose to say hi to Aien. JavaScript is needed to change this browser's choice." } div class="allen-intro-actions" { button type="button" data-allen-intro-open hidden { "Review my choice" } button type="button" data-allen-intro-stop hidden { "No, keep X tracking off" } @@ -81,6 +75,28 @@ pub fn render_privacy() -> Markup { #[cfg(test)] mod tests { use super::*; + use sha2::{Digest, Sha256}; + + #[test] + fn allen_intro_artifacts_match_their_omega_generated_sha256() { + // Both artifacts come from om/allen-intro/intro.om: the aside on fd 1, the script on fd 3. + for (bytes, recorded, name) in [ + (INTRO.as_bytes(), include_str!("../../../../om/allen-intro/intro.html.sha256"), "intro.html"), + ( + &include_bytes!("../../../../public/js/allen-intro.js")[..], + include_str!("../../../../om/allen-intro/allen-intro.js.sha256"), + "allen-intro.js", + ), + ] { + let want = recorded.split_whitespace().next().expect("sidecar holds a digest"); + assert_eq!(want.len(), 64, "{name} sidecar must hold one sha256 digest"); + let got = Sha256::digest(bytes).iter().fold(String::new(), |mut acc, byte| { + acc.push_str(&format!("{byte:02x}")); + acc + }); + assert_eq!(got, want, "{name} and its digest disagree; run: sh om/allen-intro/check.sh"); + } + } #[test] fn every_document_gets_one_local_loader_and_accessible_dialog() { @@ -88,9 +104,32 @@ mod tests { assert_eq!(enrich(page.clone()), page); assert_eq!(page.matches("src=\"/js/allen-intro.js\"").count(), 1); assert_eq!(page.matches("id=\"aien-allen-intro\"").count(), 1); - assert!(page.contains("role=\"dialog\"")); + assert!(page.contains("role=\"complementary\"")); + assert!(page.contains("aria-live=\"polite\"")); + assert!(page.contains("Hi, I'm Aien (you say it like Ian). It's nice to meet you!")); + assert!(page.contains("we could chat over time")); + assert!(page.contains("data-speaker=\"allen\""), "Allen's speech is tagged for the voice rule"); + // Memory and X consent are separate controls: links for memory, buttons for X. + assert!(page.contains("Tell Aien my name")); + assert!(page.contains("")); + assert!(!page.contains(" Markup { "." } p { - "No outside fonts or trackers, unless you introduce yourself to Allen to allow the X pixel. " + "No outside fonts or trackers, unless you say hi to Aien to allow the X pixel. " a href="/privacy/" { "Your privacy and choice" } } div class="aien-footer-mottos" { diff --git a/crates/site-builder/src/components/voice.rs b/crates/site-builder/src/components/voice.rs index a7e7f68..12e9502 100644 --- a/crates/site-builder/src/components/voice.rs +++ b/crates/site-builder/src/components/voice.rs @@ -4,6 +4,9 @@ //! and code identifiers are the only exceptions, listed in `ALLOW`. Text //! copied verbatim from the published work ledger (`data/now.tsv`, shown on //! /now/) is a dated record of what was said, not copy, and is matched out. +//! The rule covers Drake's voice only. Allen's speech, the elements marked +//! exactly `data-speaker="allen"`, is his own voice ("we" there means Allen and +//! the visitor) and is removed before matching; nothing else is. use regex::Regex; use std::fs; @@ -19,10 +22,59 @@ pub const ALLOW: &[(&str, &str)] = &[ /// Pages that embed ledger rows; only these may match text out of the ledger. pub const LEDGER_PAGES: &[&str] = &["now/index.html", "now/index.md", "now.md", "llms-full.txt"]; +/// The one marker for Allen's speech. Exact match: attribute spelling and value. +pub const ALLEN_SPEECH: &str = "data-speaker=\"allen\""; + fn plural() -> Regex { Regex::new(r"(?i)\b(?:we|we['\u{2019}](?:re|ve|ll|d)|us|our|ours|ourselves)\b").unwrap() } +/// Removes each element whose opening tag carries `ALLEN_SPEECH`, through its +/// matching close tag (same-name nesting counted). An unclosed element is kept, +/// so malformed markup can never hide the rest of a page from the check. +fn without_allen_speech(raw: &str) -> String { + let mut out = String::with_capacity(raw.len()); + let mut rest = raw; + while let Some(at) = rest.find(ALLEN_SPEECH) { + let Some(open) = rest[..at].rfind('<') else { break }; + let name: String = rest[open + 1..].chars().take_while(|c| c.is_ascii_alphanumeric()).collect(); + let attribute = rest[..at].ends_with(|c: char| c.is_ascii_whitespace()); + if name.is_empty() || !attribute || rest[open..at].contains('>') { + out.push_str(&rest[..at + ALLEN_SPEECH.len()]); + rest = &rest[at + ALLEN_SPEECH.len()..]; + continue; + } + let (start_tag, end_tag) = (format!("<{name}"), format!("")); + let mut depth = 0usize; + let mut i = open; + let mut end = None; + while let Some(next) = rest[i..].find('<').map(|n| i + n) { + let tail = &rest[next..]; + let boundary = |s: &str| tail[s.len()..].starts_with(|c: char| c == '>' || c.is_whitespace() || c == '/'); + if tail.starts_with(&end_tag) { + depth -= 1; + if depth == 0 { + end = Some(next + end_tag.len()); + break; + } + } else if tail.starts_with(&start_tag) && boundary(&start_tag) { + depth += 1; + } + i = next + 1; + } + let Some(end) = end else { + out.push_str(&rest[..at + ALLEN_SPEECH.len()]); + rest = &rest[at + ALLEN_SPEECH.len()..]; + continue; + }; + out.push_str(&rest[..open]); + out.push(' '); + rest = &rest[end..]; + } + out.push_str(rest); + out +} + /// Visible text of an HTML page: scripts, styles and tags removed, common /// entities decoded. Markdown and plain text pass through unchanged. pub fn visible_text(name: &str, raw: &str) -> String { @@ -32,6 +84,7 @@ pub fn visible_text(name: &str, raw: &str) -> String { let blocks = Regex::new(r"(?is)|").unwrap(); let tags = Regex::new(r"(?s)<[^>]*>").unwrap(); let t = blocks.replace_all(raw, " "); + let t = without_allen_speech(&t); let t = tags.replace_all(&t, " "); t.replace("&", "&") .replace("'", "'") @@ -146,4 +199,24 @@ mod tests { let html = "

mine

"; assert!(violations("x.html", &visible_text("x.html", html), "").is_empty()); } + + #[test] + fn allen_speech_is_exempt_and_nothing_else_is() { + let words = "we could chat over time and pick up where we left off"; + let check = |html: &str| violations("index.html", &visible_text("index.html", html), ""); + // Allen-tagged speech passes, nested markup included; the page around it is still checked. + assert!(check(&format!("

Hey {words}

I build it.

")).is_empty()); + assert!(check(&format!("
{words}
")).is_empty()); + // Negative controls: the same words fail untagged, after the tagged element, + // under a lookalike attribute, as text, or in an unclosed element. + assert!(!check(&format!("

{words}

")).is_empty()); + assert!(!check(&format!("

hi

{words}

")).is_empty()); + assert!(!check(&format!("

{words}

")).is_empty()); + assert!(!check(&format!("

{words}

")).is_empty()); + assert!(!check(&format!("

{words}

")).is_empty()); + assert!(!check(&format!("

data-speaker=\"allen\" {words}

")).is_empty()); + assert!(!check(&format!("

{words}")).is_empty()); + // Markdown and text mirrors have no markup to tag, so the rule applies in full. + assert!(!violations("index.md", &visible_text("index.md", &format!("

{words}

")), "").is_empty()); + } } diff --git a/crates/site-builder/src/main.rs b/crates/site-builder/src/main.rs index 05e10dc..f6552d4 100644 --- a/crates/site-builder/src/main.rs +++ b/crates/site-builder/src/main.rs @@ -245,7 +245,13 @@ fn build_pure_rust_site(dist: &Path, facts_path: &Path) { "website", html! { link rel="stylesheet" href="/assets/allen.css"; + link rel="stylesheet" href="/assets/allen-panes.css"; + link rel="stylesheet" href="/assets/allen-install.css"; + script defer src="/js/allen-audio.js" {} + script defer src="/js/allen-panes.js" {} script defer src="/js/allen.js" {} + script defer src="/js/allen-voice.js" {} + script defer src="/js/allen-install.js" {} }, components::allen::render_allen_page(), ); @@ -366,8 +372,8 @@ fn build_pure_rust_site(dist: &Path, facts_path: &Path) { println!(" [PAGE] Emitted /glossary/ (index.html)"); let privacy = render_page_layout( - "Privacy & saying hello to Allen | AienOS", - "Read without tracking. Saying hello to Allen consents to X pixel rfrlz; No refuses it.", + "Privacy & saying hi to Aien | AienOS", + "Read without tracking. Saying hi to Aien consents to X pixel rfrlz; No thanks refuses it.", "https://www.aienos.com/privacy/", "website", html! {}, diff --git a/crates/site-builder/src/seo.rs b/crates/site-builder/src/seo.rs index dabfe45..abfb574 100644 --- a/crates/site-builder/src/seo.rs +++ b/crates/site-builder/src/seo.rs @@ -84,7 +84,7 @@ pub const PAGES: &[PageInfo] = &[ PageInfo { path: "/", name: "AienOS", what: "The front page: the loop, the five real machines and their measured speeds beside the physical ceiling, the evidence cards, the current status of every layer.", section: Section::Machine, kind: Kind::Home, image: "/og.png", published: "2026-09-23", doi: None }, PageInfo { path: "/start/", name: "Start here", what: "The shortest route through AienOS: what it is, what exists today, how to check the evidence, how to reproduce or contribute, and where the author and Interplane fit.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-24", doi: None }, PageInfo { path: "/contact/", name: "Where I am and how to reach me", what: "How to reach Drake: X @mdrakestapleton, email drake@aienos.com, Allen at /allen/ (who can pass a message on or put you through when Drake is online) and the aien-dev repositories on GitHub.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, - PageInfo { path: "/privacy/", name: "Privacy & saying hello to Allen", what: "Your choice about the consent-only X pixel, what X receives, what I keep and how to refuse.", section: Section::Optional, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, + PageInfo { path: "/privacy/", name: "Privacy & saying hi to Aien", what: "Your choice about the consent-only X pixel, what X receives, what I keep and how to refuse.", section: Section::Optional, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, PageInfo { path: "/machine/", name: "The Machine", what: "One machine across five physical bodies: the closed epistemic loop, the Turing as its accounting layer, and an honest list of what exists.", section: Section::Machine, kind: Kind::Article, image: "/og-machine.png", published: "2026-10-01", doi: None }, PageInfo { path: "/omega/", name: "What Omega is", what: "Omega is AIEN's language for all computing, GPU to CPU; on the GPU it is the replacement for CUDA. The CUDA stack piece by piece with status, the receipt for the live server running with zero CUDA libraries, what is not true yet, and the bar C1 to C6.", section: Section::Machine, kind: Kind::Page, image: "/og-machine.png", published: "2026-10-21", doi: None }, PageInfo { path: "/cudaplusplus/", name: "CUDA++", what: "CUDA++ is the GPU half of Omega: everything CUDA gives you plus the motor, for the NVIDIA GPUs people already own, with no NVIDIA user-space software (Apache-2.0 with LLVM exception, aien-dev/CUDApp). What it is for, the path from program to chip with whose code runs at each step, how I did it, CUDA's pain points and the swap down to the kernel driver.", section: Section::Machine, kind: Kind::Page, image: "/og-machine.png", published: "2026-10-22", doi: None }, @@ -859,7 +859,7 @@ pub fn llms_txt(status_lines: &[String], research_sentence: &str) -> String { let mut s = String::new(); s.push_str("# AienOS\n\n"); s.push_str(&format!("> {SITE_CLAIM}. AienOS is an experimental, open source (Apache-2.0 WITH LLVM-exception) machine for turning search into verified understanding: AIEN proposes, Omega makes the proposal explicit and verifiable, the machine tests it against reality, the Turing measures what was learned, Cortex keeps the evidence. Every claim on the site carries a public receipt. Sovereign Intelligence, built on AienOS, is in alpha testing; each component keeps its own evidence level. Built by {AUTHOR} with AI agents on five real machines.\n\n")); - s.push_str("Rules the site keeps: no comparisons with other systems (every speed stands beside the physical ceiling of its own machine only), failures stay on the record, no outside fonts or unsolicited tracking (X pixel rfrlz loads only after saying hello to Allen; privacy and refusal at /privacy/; the film on /turing/ is an outside embed), and AI agents are welcome to read, cite, argue and correct. Contact Drake: drake@aienos.com or X @mdrakestapleton; every route, Allen included, is at https://www.aienos.com/contact/. Project mail: aien@aienos.com. Source: https://github.com/aien-dev.\n\n"); + s.push_str("Rules the site keeps: no comparisons with other systems (every speed stands beside the physical ceiling of its own machine only), failures stay on the record, no outside fonts or unsolicited tracking (X pixel rfrlz loads only after saying hi to Aien; privacy and refusal at /privacy/; the film on /turing/ is an outside embed), and AI agents are welcome to read, cite, argue and correct. Contact Drake: drake@aienos.com or X @mdrakestapleton; every route, Allen included, is at https://www.aienos.com/contact/. Project mail: aien@aienos.com. Source: https://github.com/aien-dev.\n\n"); s.push_str("## Current state\n\n"); for l in status_lines { s.push_str(&format!("- {l}\n")); @@ -1008,7 +1008,7 @@ pub fn data_index(ctx: &BuildCtx) -> String { "rules": [ "No comparisons with other systems: every number stands beside the physical ceiling of its own machine only.", "Every claim links its receipt. Failures stay on the record.", - "No outside fonts or unsolicited tracking. X pixel rfrlz loads only with Allen introduction consent; /privacy/ explains and controls the choice. The film on /turing/ is an outside embed." + "No outside fonts or unsolicited tracking. X pixel rfrlz loads only after saying hi to Aien; /privacy/ explains and controls the choice. The film on /turing/ is an outside embed." ], "files": files }); diff --git a/om/allen-audio/allen-audio.js.sha256 b/om/allen-audio/allen-audio.js.sha256 new file mode 100644 index 0000000..81bdafb --- /dev/null +++ b/om/allen-audio/allen-audio.js.sha256 @@ -0,0 +1 @@ +d3535b7dbd281fe7ceb4836f8e73a07eea460e51a3c1d422fa9a4091dee6040f ../../public/js/allen-audio.js diff --git a/om/allen-audio/allen-chirp.wav.sha256 b/om/allen-audio/allen-chirp.wav.sha256 new file mode 100644 index 0000000..cd25ae6 --- /dev/null +++ b/om/allen-audio/allen-chirp.wav.sha256 @@ -0,0 +1 @@ +ad1b8f5737161f9cd8730ab757da96ad1c1a9a68957723c5a102f9318ec97659 ../../public/audio/allen-chirp.wav diff --git a/om/allen-audio/asset.om b/om/allen-audio/asset.om new file mode 100644 index 0000000..861d9b4 --- /dev/null +++ b/om/allen-audio/asset.om @@ -0,0 +1,31 @@ +note Web half of Allen's startup sound; composed after chirp.om by check.sh. +note fd 1: public/audio/allen-chirp.wav, frames FZERO..FEND of the night (45120 frames, 940 ms), +note 16-bit mono at 48000 Hz, 90284 bytes. The native fill writes equal left and right samples, so +note one channel keeps every sample. fd 3: public/js/allen-audio.js, the browser controller that +note plays those bytes with WebAudio after a user gesture. Its text is the WebAudio glue only: no +note synthesis happens in the browser. + +text jsdoc "/*\n * allen-audio.js: Allen's startup sound, the one the iMac plays as its two\n * black holes merge. Generated by om/allen-audio (Omega); do not edit.\n *\n * The sound is ../audio/allen-chirp.wav, written sample for sample by\n * om/allen-audio/chirp.om, a port of aienux native/kernel/ui/chirp.c at\n * da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c. It holds frames 545280 to 590400\n * of the night at 48000 Hz, 16-bit mono (the native left and right samples\n * are equal): 11360 ms to 12300 ms of the night, the merger at 12000 ms.\n * This script only plays it.\n *\n * window.AllenAudio\n * enter(arg) call inside a click or key press. The only place an audio\n * context is created or resumed. arg is a scene kind or\n * { kind, nightMs }. The native source has one sound, the\n * merger chirp of the two-hole night (kind 'night', alias\n * 'home', the default); any other kind (the /allen/ tube\n * included) has no native sound and resolves false without\n * touching audio. nightMs is where the night is at the moment\n * of the call (default 0: the night starts now). As on the\n * iMac, the sound lands on the merger:\n * before 11360 ms it waits, inside the chirp it starts from\n * that moment, after 12300 ms nothing plays. While a sound\n * is pending or playing, enter returns the same promise;\n * after it ends or stops, the next gesture may enter again\n * (a replay). Resolves true once the sound is scheduled,\n * false when muted, unsupported, stopped or too late; never\n * rejects.\n * pause() suspends the audio context: its clock and the sound\n * freeze together, as the scene's clock does. Done by\n * itself when the page is hidden, so no chirp plays in the\n * background.\n * resume() resumes a context pause() suspended (the scene calls it\n * when it runs again); never creates one, and does nothing\n * while muted.\n * stop() stops the sound and closes the audio context; done by\n * itself on pagehide. Call it when the scene is destroyed\n * or replayed.\n * setMuted(b) stores the choice in localStorage 'allen.audio.muted'\n * ('1' or '0'), the only key this script writes; muting\n * stops the sound.\n * muted() the stored choice.\n * data-chirp-src on this script's tag points elsewhere (resolved against the\n * page); by default the file sits beside this script's folder, so the same\n * bytes work on aienos.com and on a localhost install.\n */\n(function () {\n 'use strict';\n var KEY = 'allen.audio.muted';\n var RATE = 48000;\n var FRAMES = 45120;\n var START_MS = 11360;\n var MERGE_MS = 12000;\n var END_MS = 12300;\n\n var me = document.currentScript;\n var pick = me && me.getAttribute('data-chirp-src');\n var src = pick ? new URL(pick, location.href).href\n : new URL('../audio/allen-chirp.wav', (me && me.src) || location.href).href;\n\n var ctx = null;\n var node = null;\n var entered = null;\n var paused = false;\n var pausedAt = 0;\n var pausedMs = 0;\n\n function stored() {\n try { return window.localStorage.getItem(KEY) === '1'; } catch (e) { return false; }\n }\n var isMuted = stored();\n\n function close() {\n var n = node;\n var c = ctx;\n node = null;\n ctx = null;\n entered = null;\n paused = false;\n if (n) {\n n.onended = null;\n try { n.stop(); } catch (e) { /* not started yet */ }\n n.disconnect();\n }\n if (c && c.close && c.state !== 'closed') c.close().then(null, function () {});\n }\n\n function word(v, at) { return v.getUint32(at, true); }\n function half(v, at) { return v.getUint16(at, true); }\n\n /* The asset's exact header, or nothing: mono 16-bit PCM at RATE, FRAMES long. */\n function pcm(bytes) {\n if (bytes.byteLength !== 44 + 2 * FRAMES) return null;\n var v = new DataView(bytes);\n if (word(v, 0) !== 0x46464952 || word(v, 4) !== 36 + 2 * FRAMES || word(v, 8) !== 0x45564157 ||\n word(v, 12) !== 0x20746d66 || word(v, 16) !== 16 || half(v, 20) !== 1 || half(v, 22) !== 1 ||\n word(v, 24) !== RATE || word(v, 28) !== 2 * RATE || half(v, 32) !== 2 || half(v, 34) !== 16 ||\n word(v, 36) !== 0x61746164 || word(v, 40) !== 2 * FRAMES) return null;\n var out = new Float32Array(FRAMES);\n for (var i = 0; i < FRAMES; i++) out[i] = v.getInt16(44 + 2 * i, true) / 32768;\n return out;\n }\n\n /* A silent frame started inside the gesture: some browsers unlock output only so. */\n function unlock(c) {\n try {\n var s = c.createBufferSource();\n s.buffer = c.createBuffer(1, 1, c.sampleRate);\n s.connect(c.destination);\n s.start(0);\n } catch (e) { /* the real sound still tries */ }\n }\n\n function play(c, samples, night) {\n if (c !== ctx || isMuted || night >= END_MS) return false;\n var buf = c.createBuffer(1, FRAMES, RATE);\n buf.getChannelData(0).set(samples);\n var n = c.createBufferSource();\n n.buffer = buf;\n n.connect(c.destination);\n n.onended = function () { if (node === n) close(); };\n node = n;\n if (night < START_MS) n.start(c.currentTime + (START_MS - night) / 1000);\n else n.start(0, (night - START_MS) / 1000);\n return true;\n }\n\n var KINDS = { night: 1, home: 1 };\n\n function enter(arg) {\n var opts = typeof arg === 'string' ? { kind: arg } : arg || {};\n if (!KINDS.hasOwnProperty(opts.kind || 'night')) return Promise.resolve(false);\n if (entered) return entered;\n var t0 = performance.now();\n pausedMs = 0;\n var base = typeof opts.nightMs === 'number' && opts.nightMs >= 0 ? opts.nightMs : 0;\n var AC = window.AudioContext || window.webkitAudioContext;\n if (isMuted || !AC || !window.fetch || base >= END_MS) return Promise.resolve(false);\n var c;\n try { c = new AC(); } catch (e) { return Promise.resolve(false); }\n ctx = c;\n if (c.resume) c.resume().then(null, function () {});\n unlock(c);\n entered = fetch(src, { credentials: 'same-origin' })\n .then(function (r) {\n if (!r.ok) throw new Error('allen-chirp.wav ' + r.status);\n return r.arrayBuffer();\n })\n .then(function (bytes) {\n var samples = pcm(bytes);\n var held = pausedMs + (paused ? performance.now() - pausedAt : 0);\n var ok = samples ? play(c, samples, base + performance.now() - t0 - held) : false;\n if (!ok && ctx === c) close();\n return ok;\n })\n .then(null, function () {\n if (ctx === c) close();\n return false;\n });\n return entered;\n }\n\n function pause() {\n if (!ctx || paused) return;\n paused = true;\n pausedAt = performance.now();\n if (ctx.suspend) ctx.suspend().then(null, function () {});\n }\n\n function resume() {\n if (!ctx || !paused || isMuted) return;\n paused = false;\n pausedMs += performance.now() - pausedAt;\n if (ctx.resume) ctx.resume().then(null, function () {});\n }\n\n function setMuted(on) {\n isMuted = !!on;\n try { window.localStorage.setItem(KEY, isMuted ? '1' : '0'); } catch (e) { /* kept for this page */ }\n if (isMuted) close();\n }\n\n document.addEventListener('visibilitychange', function () {\n if (document.visibilityState === 'hidden') pause();\n });\n window.addEventListener('pagehide', close);\n\n window.addEventListener('storage', function (e) {\n if (e.key !== KEY) return;\n isMuted = e.newValue === '1';\n if (isMuted) close();\n });\n\n window.AllenAudio = Object.freeze({\n enter: enter,\n stop: close,\n pause: pause,\n resume: resume,\n setMuted: setMuted,\n muted: function () { return isMuted; },\n src: src,\n kinds: Object.freeze(['night', 'home']),\n timeline: Object.freeze({ rate: RATE, frames: FRAMES, startMs: START_MS, mergeMs: MERGE_MS, endMs: END_MS })\n });\n})();\n" + +fn script to void +for i ulong len jsdoc +obyte get jsdoc i +end +end + +fn main to int +setup +put ofd 0 1 +owav 1 sub FEND FZERO +f = add FZERO 0 +note 45120 frames, one pass each. +while lt f FEND bound 45120 +osample sample f +f = add f 1 +end +oflush +put ofd 0 3 +script +oflush +ret 0 +end diff --git a/om/allen-audio/check.sh b/om/allen-audio/check.sh new file mode 100755 index 0000000..55a30a8 --- /dev/null +++ b/om/allen-audio/check.sh @@ -0,0 +1,143 @@ +#!/bin/sh +# Regenerate Allen's startup sound (public/audio/allen-chirp.wav) and its browser +# controller (public/js/allen-audio.js) with the pinned arm64 omc, then, when an +# aienux clone is given, check the Omega synthesis byte for byte against the +# original C it ports. +# +# The compiler is the one vendored for the Hive page; its pin is recorded once, +# in ../hive-page/omc.sha256. OMEGA_OMC overrides the compiler path, never its pin. +# OMEGA_ACCEPT_CHANGE=1 accepts rewritten artifacts; otherwise stale output exits 4. +# +# Oracle (AIENUX_SRC=): extracts native/kernel/ui +# at $PIN, checks the blob ids of the sound's sources, builds aienux's own host +# test ui/tests/chirp_test.c with chirp.c (HOSTCC, default cc), and requires +# 1. its chirp.wav to equal native.om's output byte for byte (whole night, +# stereo, 590400 frames); +# 2. the web asset's samples to equal that file's left channel over frames +# 545280..590400, and right to equal left there; +# 3. a mutant oracle (CK_CHIRP_PEAK 22937 -> 22936) to differ (negative control). +# Without AIENUX_SRC the oracle prints ORACLE NOT_RUN; that is not a pass. +# +# Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten; +# 5: nondeterministic output; 6: empty output; 7: oracle mismatch; +# 8: negative control accepted; 9: oracle source missing or not the pinned blobs. +# Compile/run failures propagate. +set -eu +cd "$(dirname "$0")" +PIN=da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c +omc=${OMEGA_OMC:-$PWD/../hive-page/omc} +pin=$(tr -d ' \n' < ../hive-page/omc.sha256) +if [ ! -f "$omc" ]; then + printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2 + exit 2 +fi +have=$(sha256sum "$omc" | cut -d' ' -f1) +if [ "$have" != "$pin" ]; then + printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2 + exit 3 +fi +work=$(mktemp -d "${TMPDIR:-/tmp}/allen-audio.XXXXXX") +trap 'rm -rf "$work"' EXIT HUP INT TERM +# Concatenation composes Omega units; it does not implement generation in shell. +cat chirp.om asset.om > "$work/asset.om" +cat chirp.om native.om > "$work/native.om" +"$omc" < "$work/asset.om" > "$work/asset" +"$omc" < "$work/native.om" > "$work/native" +chmod +x "$work/asset" "$work/native" +"$work/asset" > "$work/first.wav" 3> "$work/first.js" +"$work/asset" > "$work/second.wav" 3> "$work/second.js" +stale=0 +publish() { + first=$1 + second=$2 + artifact=$3 + sidecar=$4 + if ! cmp -s "$first" "$second"; then + printf '%s: generator output differs between runs\n' "$artifact" >&2 + exit 5 + fi + if [ ! -s "$first" ]; then + printf '%s: generator wrote nothing\n' "$artifact" >&2 + exit 6 + fi + if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$first"; then + stale=1 + fi + cp "$first" "$artifact" + hash=$(sha256sum "$artifact" | cut -d' ' -f1) + printf '%s %s\n' "$hash" "$artifact" > "$sidecar" + printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash" +} +mkdir -p ../../public/audio +publish "$work/first.wav" "$work/second.wav" ../../public/audio/allen-chirp.wav allen-chirp.wav.sha256 +publish "$work/first.js" "$work/second.js" ../../public/js/allen-audio.js allen-audio.js.sha256 +printf 'omc sha256 %s\n' "$have" + +if [ -z "${AIENUX_SRC:-}" ]; then + printf 'ORACLE NOT_RUN: set AIENUX_SRC to an aienux clone holding %s\n' "$PIN" +else + if ! git -C "$AIENUX_SRC" cat-file -e "$PIN^{commit}" 2>/dev/null; then + printf 'ORACLE: %s has no commit %s\n' "$AIENUX_SRC" "$PIN" >&2 + exit 9 + fi + for want in \ + d3e732908a72a372816584d0fe3d62a3db256f1b:native/kernel/ui/chirp.c \ + 359f0f4e63e5c194b005906d3bd7b03cfb7e8703:native/kernel/ui/chirp.h \ + 4cecf8f2afcd8828915a87cefe2cbefab5ef7251:native/kernel/ui/night.h \ + 7032fee2ca584587981297ffa22ade4c72560a76:native/kernel/ui/tests/chirp_test.c; do + blob=${want%%:*} + path=${want#*:} + if [ "$(git -C "$AIENUX_SRC" rev-parse "$PIN:$path")" != "$blob" ]; then + printf 'ORACLE: %s at %s is not blob %s\n' "$path" "$PIN" "$blob" >&2 + exit 9 + fi + done + mkdir "$work/src" "$work/out" "$work/mut" "$work/mutout" + git -C "$AIENUX_SRC" archive "$PIN" native/kernel/ui | tar -x -C "$work/src" + ui=$work/src/native/kernel/ui + cc=${HOSTCC:-cc} + "$cc" -std=c11 -O2 -Wall -Wextra -Werror -o "$work/oracle" "$ui/tests/chirp_test.c" "$ui/chirp.c" + "$work/oracle" "$work/out" + "$work/native" > "$work/native.wav" + if ! cmp "$work/out/chirp.wav" "$work/native.wav"; then + printf 'ORACLE FAIL: Omega night differs from aienux chirp_test.c chirp.wav\n' >&2 + exit 7 + fi + # Frame 545280 of the stereo file starts at byte 44 + 545280 * 4; 45120 frames follow. + od -An -v -td2 -w4 -j 2181164 -N 180480 "$work/out/chirp.wav" > "$work/pairs.txt" + od -An -v -td2 -w2 -j 44 ../../public/audio/allen-chirp.wav > "$work/mono.txt" + awk '{ print $1 }' "$work/pairs.txt" > "$work/left.txt" + awk '$1 != $2 { bad = 1 } END { exit bad }' "$work/pairs.txt" || { + printf 'ORACLE FAIL: left and right differ in the chirp\n' >&2 + exit 7 + } + awk '{ print $1 }' "$work/mono.txt" > "$work/mono1.txt" + if ! cmp -s "$work/left.txt" "$work/mono1.txt"; then + printf 'ORACLE FAIL: allen-chirp.wav is not the oracle left channel at frames 545280..590400\n' >&2 + exit 7 + fi + # Negative control: the same oracle with the peak one step lower must not match. + git -C "$AIENUX_SRC" archive "$PIN" native/kernel/ui | tar -x -C "$work/mut" + mui=$work/mut/native/kernel/ui + sed 's/^#define CK_CHIRP_PEAK 22937 /#define CK_CHIRP_PEAK 22936 /' "$mui/chirp.h" > "$work/chirp.h" + if cmp -s "$work/chirp.h" "$mui/chirp.h"; then + printf 'NEGATIVE CONTROL: the mutation did not apply\n' >&2 + exit 8 + fi + cp "$work/chirp.h" "$mui/chirp.h" + "$cc" -std=c11 -O2 -Wall -Wextra -Werror -o "$work/mutant" "$mui/tests/chirp_test.c" "$mui/chirp.c" + "$work/mutant" "$work/mutout" > /dev/null || true + if cmp -s "$work/mutout/chirp.wav" "$work/native.wav"; then + printf 'NEGATIVE CONTROL FAIL: a mutated oracle also matched\n' >&2 + exit 8 + fi + printf 'ORACLE PASS: aienux %s chirp_test.c chirp.wav == Omega night (%s bytes); web asset == its left channel, frames 545280..590400; mutant oracle differs\n' \ + "$PIN" "$(wc -c < "$work/native.wav" | tr -d ' ')" +fi + +if [ "$stale" = 1 ]; then + printf 'Generated artifacts were rewritten; commit them with their Omega sources\n' >&2 + if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then + exit 4 + fi +fi diff --git a/om/allen-audio/chirp.om b/om/allen-audio/chirp.om new file mode 100644 index 0000000..a2e0830 --- /dev/null +++ b/om/allen-audio/chirp.om @@ -0,0 +1,272 @@ +note Allen's startup sound: the merger chirp of the iMac night, ported from aienux +note native/kernel/ui/chirp.c and chirp.h at da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c (git blobs +note d3e732908a72a372816584d0fe3d62a3db256f1b and 359f0f4e63e5c194b005906d3bd7b03cfb7e8703; +note CK_NIGHT_MERGE_MS 12000 from ui/night.h). The same files are byte-identical at the iMac build +note 0930240d2aa550de95535c116eb10c2df466f616. That source makes exactly one sound: this chirp. It +note has no other boom, voice or opening sound; every speaker path (x86/hda_x86.c, dev/virtio_snd.c) +note plays ck_chirp_fill or ck_chirp_fill_441 from the night's current moment. +note +note The sound: silent until 640 ms before the merger, comes in over 40 ms (smoothstep) at 200 Hz, +note sweeps up as L^(-3/8) in pitch and L^(-1/4) in loudness (L the share of the 600 ms inspiral +note left) until the pitch reaches 1000 Hz, holds 1000 Hz at peak 22937 to the merger at 12000 ms, +note then decays with a 30 ms time constant until 12300 ms. Integer only, exactly as the C: +note phases in 2^32ths of a cycle, L and its powers in Q30, a 4096-entry Q14 sine table built by +note rotation. Every function below mirrors one C function and keeps its rounding order. +note +note Not a program by itself: check.sh concatenates this unit with asset.om (the web asset and the +note browser script) or native.om (the oracle layout of aienux ui/tests/chirp_test.c). +note +note Frame constants, from chirp.h with CK_CHIRP_RATE 48000 and CK_NIGHT_MERGE_MS 12000, checked +note with WolframLanguageEvaluator: {48000/1000*(12000-600-40), 48000/1000*(12000-600), +note 48000/1000*12000, 48000/1000*(12000+300)} -> {545280, 547200, 576000, 590400}; +note Round[Exp[-1/(30/1000*48000)]*2^30] -> 1072996429 (the C literal DECAY); +note Round[Cos[2 Pi/4096]*2^30] -> 1073740561, Round[Sin[2 Pi/4096]*2^30] -> 1647099 (C, S). + +const RATE ulong 48000 +const FROMHZ ulong 200 +const TOHZ ulong 1000 +const PEAK ulong 22937 +const FZERO ulong 545280 +const FONE ulong 547200 +const FTWO ulong 576000 +const FEND ulong 590400 +const DECAY ulong 1072996429 +const QONE ulong 1073741824 +const COSQ long 1073740561 +const SINQ long 1647099 + +note sint: the Q14 sine table. cap: 0 cap_frame, 1 cap_l14, 2 cap_phase (chirp.c setup). +global sint long 4096 +global cap ulong 3 + +note Output: one buffered stream, written to the descriptor in ofd. +global obuf uchar 65536 +global oused ulong 1 +global ofd int 1 + +text riff "RIFF" +text wavefmt "WAVEfmt " +text datatag "data" + +note Integer square root, chirp.c isqrt. Each loop divides bit by 4 from 2^62, so neither runs more +note than 32 passes. +fn isqrt x ulong to ulong +r = ulong 0 +b = shl ulong 1 62 +v = x +while gt b v bound 40 +b = shr b 2 +end +while ne b 0 bound 40 +if ge v add r b +v = sub v add r b +r = add shr r 1 b +else +r = shr r 1 +end +b = shr b 2 +end +ret r +end + +note L at a frame of the inspiral, Q30 (chirp.c left_q30). +fn leftq f ulong to ulong +ret div shl sub FTWO f 30 sub FTWO FONE +end + +note Eighth root of a Q30 value (chirp.c root8: three square roots). +fn root8 l ulong to ulong +v = isqrt shl l 30 +v = isqrt shl v 30 +v = isqrt shl v 30 +ret v +end + +fn mulq a ulong b ulong to ulong +ret shr mul a b 30 +end + +note Phase over the inspiral before the cap: P1 + K (1 - L^(5/8)) (chirp.c inspiral_phase). +fn insphase f ulong to ulong +r = root8 leftq f +l58 = mulq mulq mulq mulq r r r r r +p1 = div shl mul FROMHZ sub FONE FZERO 32 RATE +k = mul mul FROMHZ 8 sub FTWO FONE +ret add p1 div shl mul k sub QONE l58 2 mul 5 RATE +end + +note The sine table by rotation, chirp.c setup, same store order. k runs 0..1024: 1025 passes. +fn sintab to void +c = long 1073741824 +s = long 0 +k = ulong 0 +while le k 1024 bound 1025 +v = long 16384 +if ne k 1024 +v = shr add s 32768 16 +end +put sint k v +put sint sub 2048 k v +put sint and add 2048 k 4095 neg v +put sint and sub 4096 k 4095 neg v +nc = shr sub mul c COSQ mul s SINQ 30 +ns = shr add mul s COSQ mul c SINQ 30 +c = nc +s = ns +k = add k 1 +end +end + +note The first frame where L^(3/8) falls to FROMHZ / TOHZ: binary search over the 28800 inspiral +note frames, at most 15 passes. +fn capfind to ulong +want = div shl FROMHZ 30 TOHZ +lo = add FONE 0 +hi = add FTWO 0 +while lt lo hi bound 64 +mid = add lo div sub hi lo 2 +r = root8 leftq mid +if le mulq mulq r r r want +hi = mid +else +lo = add mid 1 +end +end +ret lo +end + +fn setup to void +sintab +lo = capfind +r = root8 leftq lo +put cap 0 lo +put cap 1 mulq r r +put cap 2 insphase lo +end + +note chirp.c phase_at; called only for frames with a nonzero level (f >= FZERO). +fn phaseat f ulong to ulong +if lt f FONE +ret div shl mul FROMHZ sub f FZERO 32 RATE +end +if lt f get cap 0 +ret insphase f +end +ret add get cap 2 div shl mul TOHZ sub f get cap 0 32 RATE +end + +note DECAY^k in Q30 by squaring; k < 2^14 here, so at most 14 passes. +fn decaypow k ulong to ulong +r = add QONE 0 +b = add DECAY 0 +n = k +while ne n 0 bound 70 +if eq and n 1 1 +r = mulq r b +end +b = mulq b b +n = shr n 1 +end +ret r +end + +note chirp.c ck_chirp_level: 0..PEAK at a frame. +fn level f ulong to ulong +if or lt f FZERO ge f FEND +ret 0 +end +if lt f FONE +steady = shr mul PEAK get cap 1 30 +x = div shl sub f FZERO 16 sub FONE FZERO +s = mul mul x x sub mul ulong 3 65536 mul 2 x +ret shr mul steady s 48 +end +if lt f get cap 0 +r = root8 leftq f +ret div mul PEAK get cap 1 mulq r r +end +if lt f FTWO +ret PEAK +end +ret shr mul PEAK decaypow sub f FTWO 30 +end + +note One sample of chirp.c ck_chirp_fill: the table read at the phase's top 12 bits, a straight +note line by the next 16, scaled by the level. Signed shr keeps the sign, as the C's int64 shifts. +fn sample f ulong to long +a = level f +if eq a 0 +ret long 0 +end +ph = and phaseat f 4294967295 +k = shr ph 20 +fr = and shr ph 4 65535 +s0 = get sint k +s1 = get sint and add k 1 4095 +s = add s0 shr mul sub s1 s0 long fr 16 +ret shr mul s long a 14 +end + +fn oflush to void +p = ulong 0 +while lt p get oused 0 bound 65536 +n = write get ofd 0 obuf p sub get oused 0 p +if le n 0 +trap 3 +end +p = add p ulong n +end +put oused 0 0 +end + +fn obyte c uchar to void +if eq get oused 0 len obuf +oflush +end +put obuf get oused 0 c +put oused 0 add get oused 0 1 +end + +fn ole16 v ulong to void +obyte uchar and v 255 +obyte uchar and shr v 8 255 +end + +fn ole32 v ulong to void +ole16 and v 65535 +ole16 shr v 16 +end + +note A 16-bit little-endian sample (two's complement). +fn osample v long to void +u = ulong 0 +if lt v 0 +u = ulong add v 65536 +else +u = ulong v +end +ole16 u +end + +note The canonical 44-byte PCM WAV header (the layout of chirp_test.c write_wav). +fn owav ch ulong frames ulong to void +bytes = mul frames mul 2 ch +for i ulong len riff +obyte get riff i +end +ole32 add 36 bytes +for i ulong len wavefmt +obyte get wavefmt i +end +ole32 16 +ole16 1 +ole16 ch +ole32 RATE +ole32 mul RATE mul 2 ch +ole16 mul 2 ch +ole16 16 +for i ulong len datatag +obyte get datatag i +end +ole32 bytes +end diff --git a/om/allen-audio/native.om b/om/allen-audio/native.om new file mode 100644 index 0000000..0c67574 --- /dev/null +++ b/om/allen-audio/native.om @@ -0,0 +1,22 @@ +note Oracle layout of Allen's startup sound; composed after chirp.om by check.sh. +note Writes to fd 1 the exact file aienux native/kernel/ui/tests/chirp_test.c writes as chirp.wav +note (write_wav(path, s, N), N = CK_CHIRP_FRAMES = 590400): 2 channels, 16-bit, 48000 Hz, frames 0 +note to 590400 (0 ms to 12300 ms of the night), left equal to right. check.sh compares it byte for +note byte with that C program's output, built from the pinned aienux source, so the Omega port is +note checked against the original, not against itself. + +fn main to int +setup +put ofd 0 1 +owav 2 FEND +f = ulong 0 +note 590400 frames, one pass each. +while lt f FEND bound 590400 +v = sample f +osample v +osample v +f = add f 1 +end +oflush +ret 0 +end diff --git a/om/allen-install/allen-install.css.sha256 b/om/allen-install/allen-install.css.sha256 new file mode 100644 index 0000000..6b7858f --- /dev/null +++ b/om/allen-install/allen-install.css.sha256 @@ -0,0 +1 @@ +6eba1ee1082422b80ead479bbcec1c60b41504fda3d3867d77afd2c5abdc5aa2 ../../public/assets/allen-install.css diff --git a/om/allen-install/allen-install.js.sha256 b/om/allen-install/allen-install.js.sha256 new file mode 100644 index 0000000..a429899 --- /dev/null +++ b/om/allen-install/allen-install.js.sha256 @@ -0,0 +1 @@ +4bf4aab56e35cf72236296964e2caed21c87caf8ecf971f798aa5b10eef8d03b ../../public/js/allen-install.js diff --git a/om/allen-install/check.sh b/om/allen-install/check.sh new file mode 100755 index 0000000..109f203 --- /dev/null +++ b/om/allen-install/check.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# Regenerate the Allen install offer script and style using the pinned arm64 omc. +# The compiler is the one vendored for the Hive page; its pin is recorded once, +# in ../hive-page/omc.sha256. CI on x86_64 checks the committed artifacts +# against their recorded hashes. OMEGA_OMC overrides the compiler path, never its pin. +# OMEGA_ACCEPT_CHANGE=1 accepts rewritten artifacts; otherwise stale output exits 4. +# Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten; +# 5: nondeterministic output; 6: empty output. Compile/run failures propagate. +set -eu +cd "$(dirname "$0")" +omc=${OMEGA_OMC:-$PWD/../hive-page/omc} +pin=$(tr -d ' \n' < ../hive-page/omc.sha256) +if [ ! -f "$omc" ]; then + printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2 + exit 2 +fi +have=$(sha256sum "$omc" | cut -d' ' -f1) +if [ "$have" != "$pin" ]; then + printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2 + exit 3 +fi +work=$(mktemp -d "${TMPDIR:-/tmp}/allen-install.XXXXXX") +trap 'rm -rf "$work"' EXIT HUP INT TERM +"$omc" < install.om > "$work/install" +chmod +x "$work/install" +"$work/install" > "$work/first.js" 3> "$work/first.css" +"$work/install" > "$work/second.js" 3> "$work/second.css" +stale=0 +publish() { + first=$1 + second=$2 + artifact=$3 + sidecar=$4 + if ! cmp -s "$first" "$second"; then + printf '%s: generator output differs between runs\n' "$artifact" >&2 + exit 5 + fi + if [ ! -s "$first" ]; then + printf '%s: generator wrote nothing\n' "$artifact" >&2 + exit 6 + fi + if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$first"; then + stale=1 + fi + cp "$first" "$artifact" + hash=$(sha256sum "$artifact" | cut -d' ' -f1) + printf '%s %s\n' "$hash" "$artifact" > "$sidecar" + printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash" +} +publish "$work/first.js" "$work/second.js" ../../public/js/allen-install.js allen-install.js.sha256 +publish "$work/first.css" "$work/second.css" ../../public/assets/allen-install.css allen-install.css.sha256 +printf 'omc sha256 %s\n' "$have" +if [ "$stale" = 1 ]; then + printf 'Generated artifacts were rewritten; commit them with their Omega sources\n' >&2 + if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then + exit 4 + fi +fi diff --git a/om/allen-install/install.om b/om/allen-install/install.om new file mode 100644 index 0000000..f109e39 --- /dev/null +++ b/om/allen-install/install.om @@ -0,0 +1,52 @@ +note Allen install offer generator: public/js/allen-install.js on fd 1 and +note public/assets/allen-install.css on fd 3. The browser behaviour is authored +note here as the emitted texts; check.sh only compares and publishes them. +note Offer rules: shown only after a visitor-started exchange ends with a reply +note that has text and no outcome; never on load, the greeting or a silent send. +note beforeinstallprompt is captured and prompt() runs only inside the tap on +note the offer. One localStorage key, allen-install, holds dismissed, accepted, +note guided or installed; storage failures fall back to page memory and never +note throw. iOS Safari gets a two-step Share then Add to Home Screen guide with +note local SVG icons. Installed success is said only on appinstalled. +note The card is offered to the page through the cancelable document event +note allen-pane-request (detail id title node focus, host sets detail.handle); +note unhandled, it is placed inline beside the latest reply. +note Source language checked at omega-mv 55f9b0af47de70a3d06357985cf99ae3e45c016f. +text js1 "/* Generated from om/allen-install/install.om; never hand-edit.\n *\n * The offer to put Aien on the home screen. It appears only after the first\n * exchange the visitor started that ended with a real reply, never on load or\n * on the greeting. The browser install prompt opens only inside the visitor's\n * tap on the offer. One local preference (dismissed, accepted, guided or\n * installed) stops further offers; nothing else is stored and nothing is sent.\n * Success is reported only when the browser fires appinstalled.\n */\n(() => {\n'use strict';\nif (window.AllenInstall) return;\nconst KEY = 'allen-install';\nconst TITLE = 'Put me on your home screen';\nconst SVG = 'http://www.w3.org/2000/svg';\nlet deferred = null, earned = false, asked = false, open = null, memo = '', connected = false;\nfunction remembered() {\n if (memo) return memo;\n try { return window.localStorage.getItem(KEY) || ''; } catch (_) { return ''; }\n}\nfunction remember(value) {\n memo = value;\n try { window.localStorage.setItem(KEY, value); } catch (_) {}\n}\nfunction installed() {\n try { if (window.navigator.standalone === true) return true; } catch (_) {}\n try {\n for (const mode of ['standalone', 'minimal-ui', 'fullscreen', 'window-controls-overlay']) if (window.matchMedia(`(display-mode: ${mode})`).matches) return true;\n } catch (_) {}\n return false;\n}\nfunction appleSafari() {\n const ua = String(window.navigator.userAgent || '');\n const apple = /iPhone|iPad|iPod/.test(ua) || (/Macintosh/.test(ua) && window.navigator.maxTouchPoints > 1);\n return apple && /Safari/.test(ua) && !/CriOS|FxiOS|EdgiOS|OPiOS|GSA|FBAN|FBAV|Instagram/.test(ua);\n}\nfunction el(tag, cls, text) {\n const node = document.createElement(tag);\n if (cls) node.className = cls;\n if (text) node.textContent = text;\n return node;\n}\n" +text js2 "function button(cls, text, fn) {\n const node = el('button', cls, text);\n node.type = 'button';\n node.addEventListener('click', fn);\n return node;\n}\nfunction icon(label, lines) {\n const svg = document.createElementNS(SVG, 'svg');\n svg.setAttribute('viewBox', '0 0 24 24');\n svg.setAttribute('width', '28');\n svg.setAttribute('height', '28');\n svg.setAttribute('class', 'allen-install-icon');\n if (label) {\n svg.setAttribute('role', 'img');\n svg.setAttribute('aria-label', label);\n } else svg.setAttribute('aria-hidden', 'true');\n for (const d of lines) {\n const path = document.createElementNS(SVG, 'path');\n path.setAttribute('d', d);\n svg.appendChild(path);\n }\n return svg;\n}\nfunction step(svg, before, strong, after) {\n const item = el('li', 'allen-install-step');\n const words = el('span', 'allen-install-words');\n words.append(before, el('strong', '', strong), after);\n item.append(svg, words);\n return item;\n}\nfunction guide() {\n const list = el('ol', 'allen-install-steps');\n list.setAttribute('role', 'list');\n list.append(\n step(icon('Share icon: a square with an arrow pointing up', ['M8 10H6v10h12V10h-2', 'M12 15V3', 'M8 7l4-4 4 4']), 'In Safari, tap ', 'Share', '. If you do not see it, tap the three dots first.'),\n step(icon('Add to Home Screen icon: a square with a plus', ['M7 4h10a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3z', 'M12 8v8', 'M8 12h8']), 'Choose ', 'Add to Home Screen', ', then tap Add.')\n );\n return list;\n}\nfunction offer() {\n if (open || !earned || remembered() || installed()) return;\n if (!deferred && !appleSafari()) return;\n const box = el('div', 'allen-install');\n const lede = el('p', 'allen-install-lede', 'Keep me one tap away. Your browser adds me to your home screen, and you can remove me the way you remove any app.');\n" +text js3 " const state = el('p', 'allen-install-state');\n state.setAttribute('role', 'status');\n const actions = el('div', 'allen-install-actions');\n const card = { box, state, actions, buttons: [], handle: null, inline: null, watch: null, closing: false };\n open = card;\n card.buttons.push(button('allen-pane-act allen-pane-run allen-install-yes', TITLE, () => accept(card)), button('allen-pane-act allen-install-no', 'No thanks', () => dismiss(card)));\n actions.append(...card.buttons);\n box.append(lede, actions, state);\n place(card);\n}\nfunction dismiss(card) {\n if (!remembered()) remember('dismissed');\n shut(card);\n}\nfunction finish(card, text) {\n card.state.textContent = text;\n card.actions.replaceChildren(button('allen-pane-act allen-install-done', 'Close', () => shut(card)));\n}\nfunction accept(card) {\n const event = deferred;\n if (event) {\n deferred = null;\n for (const b of card.buttons) b.disabled = true;\n let asking;\n try { asking = Promise.resolve(event.prompt()); } catch (_) { asking = Promise.reject(new Error('prompt')); }\n asking.then(() => event.userChoice).then(choice => {\n if (remembered() === 'installed') return;\n if (choice && choice.outcome === 'accepted') {\n remember('accepted');\n finish(card, 'Your browser is adding me. I will say so here when it confirms.');\n } else {\n remember('dismissed');\n finish(card, 'No problem. I will not ask again on this device.');\n }\n }, () => finish(card, 'Your browser did not open its install prompt, so nothing changed.'));\n return;\n }\n if (appleSafari()) {\n card.box.insertBefore(guide(), card.actions);\n remember('guided');\n finish(card, 'I cannot see your home screen from here, so I will not offer this again on this device.');\n }\n}\nfunction shut(card) {\n if (card.closing) return;\n card.closing = true;\n" +text js4 " if (card.watch) card.watch.disconnect();\n if (open === card) open = null;\n if (card.handle && typeof card.handle.close === 'function') card.handle.close();\n if (card.inline) card.inline.remove();\n else card.box.remove();\n}\nfunction place(card) {\n const detail = { id: 'install', title: TITLE, node: card.box, focus: false, handle: null };\n const request = new CustomEvent('allen-pane-request', { cancelable: true, detail });\n if (!document.dispatchEvent(request) && detail.handle && detail.handle.ok) card.handle = detail.handle;\n else {\n const aside = el('aside', 'allen-install-inline');\n aside.setAttribute('aria-label', TITLE);\n const head = el('div', 'allen-install-head');\n const close = button('allen-install-close', '', () => dismiss(card));\n close.setAttribute('aria-label', 'Close, and do not offer this again');\n close.appendChild(icon('', ['M6 6l12 12', 'M18 6L6 18']));\n head.append(el('p', 'allen-install-title', TITLE), close);\n aside.append(head, card.box);\n const answer = document.getElementById('allen-answer');\n const spot = document.getElementById('allen-install-slot') || (answer && answer.parentNode) || document.getElementById('allen') || document.body;\n spot.appendChild(aside);\n card.inline = aside;\n }\n if (typeof MutationObserver === 'function') {\n card.watch = new MutationObserver(() => {\n if (!card.box.isConnected && !card.closing) dismiss(card);\n });\n card.watch.observe(document.documentElement, { childList: true, subtree: true });\n }\n}\nfunction connect() {\n const api = window.allen;\n if (connected || !api || typeof api.on !== 'function') return;\n connected = true;\n api.on('send', event => { asked = !event.silent; });\n api.on('reply', event => {\n" +text js5 " const good = asked && !event.outcome && typeof event.text === 'string' && event.text.trim() !== '';\n asked = false;\n if (!good) return;\n earned = true;\n offer();\n });\n}\nwindow.addEventListener('beforeinstallprompt', event => {\n event.preventDefault();\n deferred = event;\n offer();\n});\nwindow.addEventListener('appinstalled', () => {\n deferred = null;\n remember('installed');\n if (open) finish(open, 'Your browser says I am installed. Open me from your home screen or app list.');\n});\ndocument.addEventListener('allen-ready', connect);\nconnect();\nwindow.AllenInstall = Object.freeze({ version: 1 });\n})();\n" +text css1 "/* Generated from om/allen-install/install.om; never hand-edit. */\n.allen-install { display: grid; gap: 10px; font-size: 13px; line-height: 1.55; color: var(--text-secondary); text-align: left; }\n.allen-install-lede { margin: 0; }\n.allen-install-actions { display: flex; flex-wrap: wrap; gap: 8px; }\n.allen-install-state { margin: 0; min-height: 1.55em; color: var(--text-primary); }\n.allen-install-state:empty { min-height: 0; }\n.allen-install-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }\n.allen-install-step { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: 14px; background: color-mix(in srgb, var(--bg-card) 72%, transparent); }\n.allen-install-icon { width: 28px; height: 28px; justify-self: center; fill: none; stroke: var(--text-primary); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }\n.allen-install-step .allen-install-icon { width: 44px; height: 44px; padding: 8px; border-radius: 12px; background: color-mix(in srgb, var(--bg-surface) 80%, transparent); border: 1px solid var(--border-subtle); }\n.allen-install-words strong { color: var(--text-primary); font-weight: 500; }\n.allen-install-inline { pointer-events: auto; margin: 12px auto 0; width: min(420px, 100%); padding: 14px 16px; border: 1px solid var(--border-subtle); border-radius: 18px; background: color-mix(in srgb, var(--bg-surface) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 12px 40px color-mix(in srgb, var(--bg-base) 60%, transparent); animation: allen-install-in 360ms ease-out both; }\n" +text css2 ".allen-install-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }\n.allen-install-title { margin: 0; font-size: 14px; color: var(--text-primary); }\n.allen-install-close { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 999px; border: 1px solid var(--border-subtle); background: transparent; color: var(--text-secondary); cursor: pointer; }\n.allen-install-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }\n.allen-install-close .allen-install-icon { width: 16px; height: 16px; stroke: currentColor; }\n.allen-install button:focus-visible, .allen-install-close:focus-visible { outline: 2px solid var(--accent-green); outline-offset: 2px; }\n@keyframes allen-install-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) { .allen-install-inline { animation: none; } }\n@media (max-width: 720px) { .allen-install-inline { width: 100%; } .allen-install-actions button { min-height: 44px; } }\n" +fn main to int +w = write 1 js1 0 len js1 +if ne w long len js1 +ret 1 +end +w = write 1 js2 0 len js2 +if ne w long len js2 +ret 1 +end +w = write 1 js3 0 len js3 +if ne w long len js3 +ret 1 +end +w = write 1 js4 0 len js4 +if ne w long len js4 +ret 1 +end +w = write 1 js5 0 len js5 +if ne w long len js5 +ret 1 +end +w = write 3 css1 0 len css1 +if ne w long len css1 +ret 1 +end +w = write 3 css2 0 len css2 +if ne w long len css2 +ret 1 +end +ret 0 +end diff --git a/om/allen-install/test-install.cjs b/om/allen-install/test-install.cjs new file mode 100644 index 0000000..1fc2a58 --- /dev/null +++ b/om/allen-install/test-install.cjs @@ -0,0 +1,264 @@ +'use strict'; +/* Behaviour harness for the generated public/js/allen-install.js: a small fake + DOM in node:vm, not a browser or visual claim. Run from the repo root: + node om/allen-install/test-install.cjs */ +const fs = require('node:fs'), vm = require('node:vm'), assert = require('node:assert/strict'); +/* ALLEN_INSTALL_JS points the harness at another build, for negative controls. */ +const SOURCE = fs.readFileSync(process.env.ALLEN_INSTALL_JS || 'public/js/allen-install.js', 'utf8'); +const TITLE = 'Put me on your home screen'; +const UA = { + android: 'Mozilla/5.0 (Linux; Android 15; Pixel 9) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36', + iphone: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Mobile/15E148 Safari/604.1', + ipados: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15', + crios: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/141.0.0.0 Mobile/15E148 Safari/604.1', + firefox: 'Mozilla/5.0 (X11; Linux aarch64; rv:144.0) Gecko/20100101 Firefox/144.0', +}; +let inClick = false; +class Events { + constructor() { this.listeners = new Map(); } + addEventListener(type, fn) { if (!this.listeners.has(type)) this.listeners.set(type, new Set()); this.listeners.get(type).add(fn); } + removeEventListener(type, fn) { this.listeners.get(type)?.delete(fn); } + dispatchEvent(event) { for (const fn of [...(this.listeners.get(event.type) || [])]) fn(event); return !event.defaultPrevented; } +} +function world(opts = {}) { + const observers = new Set(); + const mutated = () => { for (const o of observers) queueMicrotask(() => o.fn([])); }; + class Node extends Events { + constructor(tag) { super(); this.tagName = tag; this.children = []; this.parentNode = null; this.attrs = new Map(); this.text = ''; this.className = ''; this.hidden = false; this.disabled = false; } + get isConnected() { let n = this; while (n.parentNode) n = n.parentNode; return n === doc.documentElement; } + get textContent() { return this.text + this.children.map(c => c.textContent).join(''); } + set textContent(v) { this.detachAll(); this.text = String(v); } + get lastChild() { return this.children[this.children.length - 1] || null; } + detachAll() { for (const c of this.children) c.parentNode = null; this.children = []; } + adopt(n) { if (typeof n === 'string') { const t = new Node('#text'); t.text = n; n = t; } if (n.parentNode) n.remove(); n.parentNode = this; return n; } + append(...ns) { for (const n of ns) this.children.push(this.adopt(n)); mutated(); } + appendChild(n) { this.append(n); return n; } + insertBefore(n, ref) { const node = this.adopt(n); const at = this.children.indexOf(ref); this.children.splice(at < 0 ? this.children.length : at, 0, node); mutated(); return node; } + replaceChildren(...ns) { this.detachAll(); this.append(...ns); } + remove() { const p = this.parentNode; if (!p) return; p.children = p.children.filter(c => c !== this); this.parentNode = null; mutated(); } + setAttribute(k, v) { this.attrs.set(k, String(v)); } + getAttribute(k) { return this.attrs.has(k) ? this.attrs.get(k) : null; } + removeAttribute(k) { this.attrs.delete(k); } + click() { if (this.disabled) return; inClick = true; try { this.dispatchEvent({ type: 'click' }); } finally { inClick = false; } } + all(pred, out = []) { for (const c of this.children) { if (pred(c)) out.push(c); c.all(pred, out); } return out; } + } + const doc = new Events(); + doc.documentElement = new Node('html'); + doc.body = new Node('body'); + doc.documentElement.append(doc.body); + doc.createElement = tag => new Node(tag); + doc.createElementNS = (ns, tag) => Object.assign(new Node(tag), { ns }); + doc.getElementById = id => doc.documentElement.all(n => n.attrs.get('id') === id)[0] || null; + const allen = new Node('div'); allen.setAttribute('id', 'allen'); + const current = new Node('section'); current.className = 'allen-current'; + const answer = new Node('div'); answer.setAttribute('id', 'allen-answer'); + const panesRoot = new Node('div'); panesRoot.setAttribute('id', 'allen-panes'); + current.append(answer); allen.append(panesRoot, current); doc.body.append(allen); + const panes = []; + if (opts.paneHost !== false) doc.addEventListener('allen-pane-request', event => { + /* Mirrors the host contract: open the node in a card pane and hand back a handle. */ + event.preventDefault(); + const pane = new Node('section'); pane.className = 'allen-pane'; pane.title = event.detail.title; + pane.append(event.detail.node); panesRoot.append(pane); + const rec = { pane, detail: event.detail, closed: 0 }; + panes.push(rec); + event.detail.handle = { ok: true, id: event.detail.id, close: () => { rec.closed++; pane.remove(); } }; + }); + const store = opts.store || new Map(); + const localStorage = { getItem: k => (store.has(k) ? store.get(k) : null), setItem: (k, v) => { if (opts.quota) throw new Error('QuotaExceededError'); store.set(k, String(v)); } }; + const win = new Events(); + if (opts.noStorage) Object.defineProperty(win, 'localStorage', { get() { throw new Error('SecurityError'); } }); + else win.localStorage = localStorage; + win.navigator = { userAgent: UA[opts.ua || 'android'], maxTouchPoints: opts.ua === 'ipados' ? 5 : 0 }; + if (opts.iosStandalone) win.navigator.standalone = true; + win.matchMedia = q => ({ matches: Boolean(opts.display) && q === `(display-mode: ${opts.display})` }); + const handlers = new Map(); + const api = { on: (t, fn) => { if (!handlers.has(t)) handlers.set(t, new Set()); handlers.get(t).add(fn); return () => handlers.get(t).delete(fn); } }; + const emit = (t, d) => { for (const fn of handlers.get(t) || []) fn(Object.freeze({ ...d })); }; + class CustomEvent { constructor(type, init = {}) { this.type = type; this.detail = init.detail; this.cancelable = Boolean(init.cancelable); this.defaultPrevented = false; } preventDefault() { if (this.cancelable) this.defaultPrevented = true; } } + class MutationObserver { constructor(fn) { this.fn = fn; } observe() { observers.add(this); } disconnect() { observers.delete(this); } } + const context = { window: win, document: doc, CustomEvent, MutationObserver, Promise, Error, String, Object, queueMicrotask }; + win.window = win; + const boot = () => { win.allen = Object.freeze(api); doc.dispatchEvent({ type: 'allen-ready' }); }; + vm.runInNewContext(SOURCE, context, { filename: 'allen-install.js' }); + if (opts.ready !== false) boot(); + const bip = (outcome = 'accepted') => { + const e = { type: 'beforeinstallprompt', prevented: 0, prompts: 0, promptInClick: [], preventDefault() { this.prevented++; } }; + e.prompt = () => { e.prompts++; e.promptInClick.push(inClick); return Promise.resolve(); }; + e.userChoice = Promise.resolve({ outcome, platform: 'web' }); + win.dispatchEvent(e); + return e; + }; + const exchange = (opt = {}) => { emit('send', { text: 'hi', silent: Boolean(opt.silent) }); emit('reply', { text: opt.text === undefined ? 'Hello there.' : opt.text, outcome: opt.outcome || '' }); }; + const offers = () => doc.documentElement.all(n => n.className === 'allen-install'); + const button = text => doc.documentElement.all(n => n.tagName === 'button' && n.textContent === text)[0]; + const settle = () => new Promise(r => setTimeout(r, 0)); + return { win, doc, store, panes, bip, exchange, offers, button, settle, boot, emit, answer, current }; +} +const results = []; +async function test(name, fn) { await fn(); results.push(name); } +(async () => { + await test('captured prompt: preventDefault, nothing shown on load', async () => { + const w = world(); + const e = w.bip(); + assert.equal(e.prevented, 1); + assert.equal(e.prompts, 0); + assert.equal(w.offers().length, 0); + assert.equal(w.panes.length, 0); + }); + await test('no offer on load, greeting, silent send or failed reply', async () => { + const w = world(); + w.bip(); + w.exchange({ silent: true }); + w.exchange({ outcome: 'Stopped.' }); + w.exchange({ outcome: 'Could not reach Aien. Check your connection and try again.' }); + w.exchange({ text: ' ' }); + w.emit('reply', { text: 'Hello.', outcome: '' }); + assert.equal(w.offers().length, 0); + }); + await test('natural good exchange shows one pane offer with the required copy', async () => { + const w = world(); + const e = w.bip(); + w.exchange(); + assert.equal(w.panes.length, 1); + assert.equal(w.panes[0].detail.title, TITLE); + assert.equal(w.panes[0].detail.id, 'install'); + assert.equal(w.panes[0].detail.focus, false); + assert.ok(w.button(TITLE)); + assert.ok(w.button('No thanks')); + assert.equal(e.prompts, 0); + w.exchange(); + assert.equal(w.panes.length, 1, 'a second good exchange does not stack offers'); + }); + await test('offer waits for beforeinstallprompt when the exchange came first', async () => { + const w = world(); + w.exchange(); + assert.equal(w.offers().length, 0); + w.bip(); + assert.equal(w.offers().length, 1); + }); + await test('prompt only inside the tap; accepted is not success; appinstalled is', async () => { + const w = world(); + const e = w.bip('accepted'); + w.exchange(); + assert.equal(e.prompts, 0); + w.button(TITLE).click(); + assert.equal(e.prompts, 1); + assert.deepEqual(e.promptInClick, [true]); + await w.settle(); + const state = () => w.doc.documentElement.all(n => n.className === 'allen-install-state')[0].textContent; + assert.match(state(), /^Your browser is adding me/); + assert.doesNotMatch(state(), /installed/); + assert.equal(w.store.get('allen-install'), 'accepted'); + assert.ok(w.button('Close')); + w.win.dispatchEvent({ type: 'appinstalled' }); + assert.match(state(), /Your browser says I am installed/); + assert.equal(w.store.get('allen-install'), 'installed'); + }); + await test('browser dialog dismissed is recorded honestly', async () => { + const w = world(); + const e = w.bip('dismissed'); + w.exchange(); + w.button(TITLE).click(); + assert.deepEqual(e.promptInClick, [true]); + await w.settle(); + assert.equal(w.store.get('allen-install'), 'dismissed'); + assert.ok(w.doc.documentElement.all(n => n.className === 'allen-install-state')[0].textContent.startsWith('No problem.')); + }); + await test('dismiss once: No thanks closes and the next visit stays quiet', async () => { + const store = new Map(); + const w = world({ store }); + w.bip(); + w.exchange(); + w.button('No thanks').click(); + assert.equal(store.get('allen-install'), 'dismissed'); + assert.equal(w.panes[0].closed, 1); + assert.equal(w.offers().length, 0); + const again = world({ store }); + const e = again.bip(); + again.exchange(); + assert.equal(again.offers().length, 0); + assert.equal(e.prevented, 1); + }); + await test('closing the pane with its own close button counts as dismissal', async () => { + const w = world(); + w.bip(); + w.exchange(); + w.panes[0].pane.remove(); + await w.settle(); + assert.equal(w.store.get('allen-install'), 'dismissed'); + }); + await test('without a pane host the offer sits inline near the reply with an accessible close', async () => { + const w = world({ paneHost: false }); + w.bip(); + w.exchange(); + const aside = w.current.all(n => n.className === 'allen-install-inline')[0]; + assert.ok(aside, 'inline aside beside #allen-answer'); + assert.equal(aside.getAttribute('aria-label'), TITLE); + const close = aside.all(n => n.className === 'allen-install-close')[0]; + assert.equal(close.getAttribute('aria-label'), 'Close, and do not offer this again'); + assert.equal(close.children[0].getAttribute('aria-hidden'), 'true'); + close.click(); + assert.equal(aside.isConnected, false); + assert.equal(w.store.get('allen-install'), 'dismissed'); + }); + await test('iOS Safari gets the two-step guide on tap, with labelled local icons', async () => { + for (const ua of ['iphone', 'ipados']) { + const w = world({ ua }); + w.exchange(); + assert.equal(w.offers().length, 1, ua); + w.button(TITLE).click(); + const steps = w.doc.documentElement.all(n => n.className === 'allen-install-step'); + assert.equal(steps.length, 2); + assert.match(steps[0].textContent, /tap Share/); + assert.match(steps[1].textContent, /Add to Home Screen/); + const icons = w.doc.documentElement.all(n => n.tagName === 'svg' && n.getAttribute('role') === 'img'); + assert.equal(icons.length, 2); + assert.ok(icons.every(i => i.ns === 'http://www.w3.org/2000/svg' && i.getAttribute('aria-label'))); + assert.equal(w.doc.documentElement.all(n => n.tagName === 'ol')[0].getAttribute('role'), 'list'); + assert.equal(w.store.get('allen-install'), 'guided'); + assert.doesNotMatch(w.offers()[0].textContent, /installed|added you|is on your home screen/); + } + }); + await test('no offer where no honest install path exists', async () => { + for (const ua of ['crios', 'firefox', 'android']) { + const w = world({ ua }); + w.exchange(); + assert.equal(w.offers().length, 0, ua); + } + }); + await test('installed or standalone pages never offer', async () => { + for (const opts of [{ display: 'standalone' }, { display: 'minimal-ui' }, { ua: 'iphone', iosStandalone: true }, { store: new Map([['allen-install', 'installed']]) }]) { + const w = world(opts); + w.bip(); + w.exchange(); + assert.equal(w.offers().length, 0, JSON.stringify(opts.display || opts.ua || 'stored')); + } + }); + await test('storage unavailable or full never throws and still remembers for the page', async () => { + for (const opts of [{ noStorage: true }, { quota: true }]) { + const w = world(opts); + const e = w.bip(); + w.exchange(); + assert.equal(w.offers().length, 1); + w.button('No thanks').click(); + w.bip(); + w.exchange(); + assert.equal(w.offers().length, 0); + assert.equal(e.prompts, 0); + } + }); + await test('late transport: connects on allen-ready', async () => { + const w = world({ ready: false }); + w.bip(); + w.boot(); + w.exchange(); + assert.equal(w.offers().length, 1); + }); + await test('artifact has no dashes, markup parsing, network or outside resources', async () => { + const css = fs.readFileSync('public/assets/allen-install.css', 'utf8'); + for (const text of [SOURCE, css]) assert.doesNotMatch(text, /[\u2013\u2014]|innerHTML|insertAdjacentHTML|fetch\(|XMLHttpRequest|https?:\/\/(?!www\.w3\.org\/2000\/svg)|@import|url\(/); + }); + for (const name of results) console.log(`PASS ${name}`); + console.log(`${results.length} passed`); +})().catch(error => { console.error(error); process.exit(1); }); diff --git a/om/allen-intro/allen-intro.js.sha256 b/om/allen-intro/allen-intro.js.sha256 new file mode 100644 index 0000000..24f27ce --- /dev/null +++ b/om/allen-intro/allen-intro.js.sha256 @@ -0,0 +1 @@ +b3175a14b434f8226165dc5d7810199d21d5bdc90a2ce2ef69a91bfce3a5d572 allen-intro.js diff --git a/om/allen-intro/check.sh b/om/allen-intro/check.sh new file mode 100755 index 0000000..cc424db --- /dev/null +++ b/om/allen-intro/check.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# Regenerate Allen's consent aside (intro.html) and its script (public/js/allen-intro.js) from intro.om with the pinned arm64 omc +# shared with om/hive-page. CI on x86_64 re-hashes the committed artifacts in Rust tests. +# OMEGA_OMC overrides the compiler path, never its pin. +# OMEGA_ACCEPT_CHANGE=1 accepts a rewritten artifact; otherwise stale output exits 4. +# Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten; +# 5: nondeterministic output; 6: empty output. Compile/run failures propagate. +set -eu +cd "$(dirname "$0")" +omc=${OMEGA_OMC:-$PWD/../hive-page/omc} +pin=$(tr -d ' \n' < ../hive-page/omc.sha256) +if [ ! -f "$omc" ]; then + printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2 + exit 2 +fi +have=$(sha256sum "$omc" | cut -d' ' -f1) +if [ "$have" != "$pin" ]; then + printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2 + exit 3 +fi +work=$(mktemp -d "${TMPDIR:-/tmp}/allen-intro.XXXXXX") +trap 'rm -rf "$work"' EXIT HUP INT TERM +"$omc" < intro.om > "$work/intro" +chmod +x "$work/intro" +"$work/intro" > "$work/first.html" 3> "$work/first.js" +"$work/intro" > "$work/second.html" 3> "$work/second.js" +stale=0 +publish() { + first=$1 + second=$2 + artifact=$3 + sidecar=$4 + if ! cmp -s "$first" "$second"; then + printf '%s: generator output differs between runs\n' "$artifact" >&2 + exit 5 + fi + if [ ! -s "$first" ]; then + printf '%s: generator wrote nothing\n' "$artifact" >&2 + exit 6 + fi + if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$first"; then + stale=1 + fi + cp "$first" "$artifact" + hash=$(sha256sum "$artifact" | cut -d' ' -f1) + printf '%s %s\n' "$hash" "$(basename "$artifact")" > "$sidecar" + printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash" +} +publish "$work/first.html" "$work/second.html" intro.html intro.html.sha256 +publish "$work/first.js" "$work/second.js" ../../public/js/allen-intro.js allen-intro.js.sha256 +printf 'omc sha256 %s\n' "$have" +if [ "$stale" = 1 ]; then + printf 'Generated artifacts were rewritten; commit them with intro.om\n' >&2 + if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then + exit 4 + fi +fi diff --git a/om/allen-intro/intro.html b/om/allen-intro/intro.html new file mode 100644 index 0000000..39bf7da --- /dev/null +++ b/om/allen-intro/intro.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/om/allen-intro/intro.html.sha256 b/om/allen-intro/intro.html.sha256 new file mode 100644 index 0000000..ada2504 --- /dev/null +++ b/om/allen-intro/intro.html.sha256 @@ -0,0 +1 @@ +95dd158c20e0ce5bafde6298684c48d9369c444f589b28cd591a025ab14535f0 intro.html diff --git a/om/allen-intro/intro.om b/om/allen-intro/intro.om new file mode 100644 index 0000000..c4f8607 --- /dev/null +++ b/om/allen-intro/intro.om @@ -0,0 +1,116 @@ +note Aien's (Allen internally) first-visit greeting on aienos.com: the consent aside that every page carries. +note Every structural decision lives here: the section order, the ids and aria attributes the +note consent script (public/js/allen-intro.js) and its tests depend on, Drake's greeting words, the +note memory links kept apart from the X pixel buttons, the GPC note, the reply after No thanks, and +note the local-only "Who can see me right now?" panel. The script only toggles and fills these slots. +note +note Program mode. check.sh compiles this with the pinned omc shared with om/hive-page, runs it twice, +note and commits intro.html with its sha256. The Rust site builder embeds intro.html and re-hashes it +note in a unit test, so x86 CI checks the artifact without running the arm64 compiler. +note +note Aien's speech carries data-speaker="allen": his "we" means Aien and the visitor, and the +note site's singular-voice verifier exempts exactly those elements. Memory consent is links to +note /aien/?mode=remember and ?mode=anonymous; X consent is the Say hi and No thanks buttons. One tap +note never means both. Names: at most 8 bytes per data name. + +note ihead: Host aside, name and close. The shared native scene is the visible Aien. +text ihead "" + +note The consent script, public/js/allen-intro.js, written to fd 3 by the same program, so the +note markup above and the script that drives it share one Omega source. It holds the once-only +note rule, X consent and refusal, the GPC default, the anonymous /allen/ gate, the local-only panel +note and the window.aienAllenIntro interface the visual layer calls. + + +text ijs0 "/* Generated by om/allen-intro/intro.om. Edit the Omega source, then run om/allen-intro/check.sh. */\n/* Aien (Allen internally) says hello once. Say hi consents to X pixel rfrlz. No external load before yes. */\n(function () {\n 'use strict';\n // Drake supplies the real X event IDs. Empty means disabled, never a fake event.\n const eventIds = Object.freeze({ pageVisit: '', introducedToAllen: '' });\n var conversionIds = {};\n var key = 'aien-allen-intro-consent';\n var seenKey = 'aien-allen-intro-seen';\n var clickKey = 'aien-allen-intro-twclid';\n var landingClick = new URLSearchParams(window.location.search).get('twclid');\n var aside = document.getElementById('aien-allen-intro');\n if (!aside || aside.dataset.ready) return;\n aside.dataset.ready = 'true';\n var choice = null;\n var loaded = false;\n var previousFocus = null;\n var timer = null;\n var offering = true;\n var status = document.getElementById('allen-intro-status');\n var title = document.getElementById('allen-intro-title');\n var typed = document.getElementById('allen-intro-typed');\n var spoken = document.getElementById('allen-intro-spoken');\n var offerLine = document.getElementById('allen-intro-offer');\n var gpcLine = document.getElementById('allen-intro-gpc');\n var yes = document.getElementById('allen-intro-yes');\n var no = document.getElementById('allen-intro-no');\n var greeting = title.textContent;\n var message = '';\n // Global Privacy Control: Allen does not offer the pixel unless the visitor asks to review.\n var gpc = window.navigator.globalPrivacyControl === true;\n var still = !window.matchMedia || window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n try { choice = localStorage.getItem(key); } catch (_) { /* No stored consent. */ }\n // Session refusal also wins if local storage became read-only after a Yes.\n try { if (sessionStorage.getItem(key) === 'no') choice = 'no'; } catch (_) {}\n if (window.location.hash === '#allen-intro-no') choice = 'no';\n\n" +text ijs1 " // Once per browser; without local storage, once per tab session.\n function seen() {\n var mark = null;\n try { mark = localStorage.getItem(seenKey); } catch (_) {}\n if (!mark) try { mark = sessionStorage.getItem(seenKey); } catch (_) {}\n return !!mark;\n }\n function markSeen() {\n try { localStorage.setItem(seenKey, '1'); return; } catch (_) {}\n try { sessionStorage.setItem(seenKey, '1'); } catch (_) {}\n }\n\n // The chat page (/aien/, formerly /allen/) renders #allen with data-mode=\"anonymous\" until its own memory consent.\n function anonymousChat() {\n var chat = document.getElementById('allen');\n return !!chat && chat.dataset.mode !== 'remembered';\n }\n\n // Allen's presence layer renders on these events and acts only through the API below.\n function announce(type, detail) {\n var data = detail || {};\n data.type = type;\n document.dispatchEvent(new window.CustomEvent('aien-allen-intro', { detail: data }));\n }\n\n function sendEvent(kind) {\n var id = eventIds[kind];\n if (choice !== 'yes' || !loaded || !id || conversionIds[kind]) return;\n // Keep this exact ID when a future backend sends the matching server event.\n var conversionId = window.crypto.randomUUID();\n conversionIds[kind] = conversionId;\n twq('event', id, { conversion_id: conversionId });\n }\n\n" +text ijs2 " function loadPixel() {\n // Anonymous chat on /aien/ (#allen data-mode != remembered) never loads the pixel.\n if (choice !== 'yes' || loaded || anonymousChat()) return;\n // Retain attribution only in a consenting visitor's browser, not on a server.\n if (landingClick) {\n try { localStorage.setItem(clickKey, landingClick); } catch (_) {}\n }\n loaded = true;\n // Official X base code, unchanged, executed only after explicit consent.\n !function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);\n },s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='https://static.ads-twitter.com/uwt.js',\n a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');\n twq('config','rfrlz');\n sendEvent('pageVisit');\n }\n\n function describe(saved) {\n if (status) status.textContent = (choice === 'yes'\n ? 'You said hi to Aien. X tracking is allowed in this browser.'\n : 'You have not said hi to Aien. X tracking is off.')\n + (saved === false ? ' Your browser could not save this choice; it applies to this page only.' : '');\n }\n\n // Static text typed on the client: no model call. Allen's native cadence is one letter per\n // 35 ms. With data-letters=\"true\" on #allen-intro-typed each letter is its own\n // span.allen-intro-letter, so the presence CSS can fade, raise and recolour it as it arrives.\n // Reduced motion shows the whole text at once as plain text.\n var letterMs = 35;\n function type() {\n var head = typed.firstChild;\n var tail = typed.lastChild;\n var whole = greeting + ' ' + message;\n var letters = !still && typed.dataset.letters === 'true';\n var shown = still ? whole.length : 0;\n head.textContent = '';\n tail.textContent = '';\n function paint() {\n if (letters) {\n if (shown > 0) {\n var letter = document.createElement('span');\n letter.className = 'allen-intro-letter';\n letter.textContent = whole.charAt(shown - 1);\n (shown <= greeting.length ? head : tail).appendChild(letter);\n }\n } else {\n head.textContent = whole.slice(0, Math.min(shown, greeting.length));\n tail.textContent = whole.slice(greeting.length, shown);\n }\n if (shown >= whole.length) { timer = null; return; }\n shown += 1;\n timer = setTimeout(paint, letterMs);\n }\n paint();\n }\n\n" +text ijs3 " function close() {\n clearTimeout(timer);\n timer = null;\n var wasShown = !aside.hidden;\n var inside = aside.contains(document.activeElement);\n aside.classList.remove('allen-intro-in');\n aside.hidden = true;\n spoken.textContent = '';\n if (inside && previousFocus && previousFocus.isConnected) previousFocus.focus();\n previousFocus = null;\n if (wasShown) announce('hide');\n }\n\n // The greeting, the chat choices and the separate X pixel ask; No thanks swaps them out.\n var greetingParts = ['allen-intro-message', 'allen-intro-chat', 'allen-intro-x'];\n function showGreeting(on) {\n greetingParts.forEach(function (id) { document.getElementById(id).hidden = !on; });\n document.getElementById('allen-intro-after').hidden = on;\n }\n\n // No thanks: no pixel and no memory, but Allen stays to offer an anonymous chat.\n function replyNo() {\n clearTimeout(timer);\n timer = null;\n showGreeting(false);\n gpcLine.hidden = true;\n spoken.textContent = document.getElementById('allen-intro-after-text').textContent;\n document.getElementById('allen-intro-anon').focus();\n announce('reply-no');\n }\n\n function choose(value, reply) {\n choice = value;\n var saved = true;\n try { localStorage.setItem(key, value); } catch (_) { saved = false; }\n if (value === 'no') {\n try { localStorage.removeItem(clickKey); } catch (_) {}\n }\n try {\n if (value === 'no') sessionStorage.setItem(key, 'no');\n else sessionStorage.removeItem(key);\n } catch (_) {}\n if (value === 'yes' && window.location.hash === '#allen-intro-no') {\n history.replaceState(null, '', window.location.pathname + window.location.search);\n }\n if (reply && offering && value === 'no' && !loaded) replyNo();\n else close();\n describe(saved);\n if (value === 'yes') {\n loadPixel();\n sendEvent('introducedToAllen');\n announce('consent', { pixelLoaded: loaded });\n }\n // A loaded third-party script cannot be recalled. A fresh document stops it.\n else if (loaded) {\n // Preserve refusal through reload even if all browser storage is unavailable.\n if (!saved) window.location.hash = 'allen-intro-no';\n window.location.reload();\n }\n }\n\n" +text ijs4 " // Never a modal: no backdrop, no inert page. Focus moves only when the visitor asked.\n function open(asked) {\n if (!aside.hidden) return;\n // Under GPC the pixel is not offered unless the visitor asked to review it.\n offering = asked || !gpc;\n showGreeting(true);\n document.getElementById('allen-intro-x').hidden = !offering;\n gpcLine.hidden = offering;\n message = document.getElementById('allen-intro-intro').textContent;\n previousFocus = asked ? document.activeElement : null;\n aside.hidden = false;\n spoken.textContent = greeting + ' ' + message + ' ' + (offering ? offerLine : gpcLine).textContent;\n type();\n void aside.offsetWidth;\n aside.classList.add('allen-intro-in');\n if (asked) no.focus();\n announce('show', { asked: !!asked, offering: offering });\n }\n\n // \"Who can see me right now?\": read only from this document and browser, shown\n // only here, never sent or stored. Resource timing lists every origin this tab loaded.\n var who = document.getElementById('allen-intro-who');\n var trackers = document.getElementById('allen-intro-trackers');\n var thirdParty = [];\n var facts = [];\n var trackerListeners = [];\n var watching = false;\n function countTrackers() {\n document.getElementById('allen-intro-tracker-count').textContent = String(thirdParty.length);\n document.getElementById('allen-intro-trackers-none').hidden = thirdParty.length > 0;\n }\n function noteResource(entry) {\n var url;\n try { url = new URL(entry.name, window.location.href); } catch (_) { return; }\n if (!/^https?:$/.test(url.protocol) || url.origin === window.location.origin) return;\n if (thirdParty.some(function (seenOrigin) { return seenOrigin.origin === url.origin; })) return;\n // Only an X origin loaded after Say hi in this document is called Drake's pixel.\n var tracker = { origin: url.origin, pixel: choice === 'yes' && loaded && /(^|\\.)(ads-twitter\\.com|twitter\\.com|x\\.com|t\\.co)$/.test(url.hostname) };\n thirdParty.push(tracker);\n var item = document.createElement('li');\n item.textContent = url.host + (tracker.pixel ? \": that one's Drake's X pixel, because you said hi.\" : '');\n trackers.appendChild(item);\n countTrackers();\n trackerListeners.forEach(function (listener) { listener(Object.assign({}, tracker)); });\n }\n function browserFacts() {\n var nav = window.navigator;\n var screen = window.screen;\n facts = [\n ['Browser', nav.userAgent || 'not shared'],\n ['Platform', (nav.userAgentData && nav.userAgentData.platform) || nav.platform || 'not shared'],\n ['Language', (nav.languages && nav.languages.length ? nav.languages.join(', ') : nav.language) || 'not shared'],\n ['Timezone', Intl.DateTimeFormat().resolvedOptions().timeZone || 'not shared'],\n ['Screen size', screen ? screen.width + ' x ' + screen.height : 'not shared'],\n ['Came from', document.referrer || 'no referrer sent'],\n ['Do Not Track', nav.doNotTrack === '1' ? 'on' : 'off'],\n ['Global Privacy Control', gpc ? 'on' : 'off'],\n ['Cookies enabled', nav.cookieEnabled ? 'yes' : 'no'],\n ];\n var list = document.getElementById('allen-intro-facts');\n facts.forEach(function (row) {\n var term = document.createElement('dt');\n var value = document.createElement('dd');\n term.textContent = row[0];\n value.textContent = row[1];\n list.appendChild(term);\n list.appendChild(value);\n });\n }\n function watch() {\n if (watching) return;\n watching = true;\n browserFacts();\n countTrackers();\n window.performance.getEntriesByType('resource').forEach(noteResource);\n // Later loads too, such as the X pixel after Say hi.\n new window.PerformanceObserver(function (list) { list.getEntries().forEach(noteResource); })\n .observe({ type: 'resource', buffered: true });\n }\n who.addEventListener('toggle', function () { if (who.open) watch(); });\n\n" +text ijs5 " no.addEventListener('click', function () { choose('no', true); });\n document.getElementById('allen-intro-close').addEventListener('click', function () { choose('no'); });\n yes.addEventListener('click', function () { choose('yes'); });\n document.addEventListener('keydown', function (event) {\n if (event.key === 'Escape' && !aside.hidden) choose('no');\n });\n document.querySelectorAll('[data-allen-intro-open]').forEach(function (button) {\n button.hidden = false;\n button.addEventListener('click', function () { open(true); });\n });\n document.querySelectorAll('[data-allen-intro-stop]').forEach(function (button) {\n button.hidden = false;\n button.addEventListener('click', function () { choose('no'); });\n });\n // A No in another tab also stops this document if the pixel was already loaded.\n window.addEventListener('storage', function (event) {\n if (event.storageArea !== localStorage || (event.key !== key && event.key !== null)) return;\n choice = event.newValue;\n if (choice !== 'yes') {\n try { localStorage.removeItem(clickKey); } catch (_) {}\n }\n close();\n describe();\n if (choice !== 'yes' && loaded) window.location.reload();\n });\n // The first-visit greeting, once per browser. Recorded on first display: never\n // auto-open again, chosen or not. Unanswered means No. Not on /privacy/ or the chat page.\n function greet() {\n if (choice === 'yes' || choice === 'no' || seen() || document.getElementById('allen-intro-privacy') || document.getElementById('allen')) return false;\n markSeen();\n open(false);\n return true;\n }\n\n" +text ijs6 " // The interface Allen's presence layer calls. X consent and refusal only: memory\n // consent lives on /aien/ behind its own step, never here, so one tap never means both.\n window.aienAllenIntro = Object.freeze({\n text: Object.freeze({\n greeting: greeting,\n intro: document.getElementById('allen-intro-intro').textContent,\n offer: offerLine.textContent,\n gpcNote: gpcLine.textContent,\n afterNo: document.getElementById('allen-intro-after-text').textContent,\n }),\n status: function () {\n return { choice: choice === 'yes' || choice === 'no' ? choice : null, gpc: gpc, offering: offering, pixelLoaded: loaded, shown: !aside.hidden };\n },\n sayHi: function () { choose('yes'); },\n noThanks: function () { choose('no', true); },\n dismiss: function () { choose('no'); },\n review: function () { open(true); },\n // A page that marks [data-allen-intro-defer] (the home door) calls this after its own welcome.\n greet: greet,\n who: function () {\n watch();\n return { trackers: thirdParty.map(function (t) { return Object.assign({}, t); }), facts: facts.map(function (row) { return row.slice(); }) };\n },\n onTrackers: function (listener) { trackerListeners.push(listener); watch(); },\n });\n describe();\n if (choice === 'yes') loadPixel();\n else if (!document.querySelector('[data-allen-intro-defer]')) greet();\n}());\n" + +fn main to int +n = write 1 ihead 0 len ihead +if lt n 0 +trap 3 +end +n = write 1 igreet 0 len igreet +if lt n 0 +trap 3 +end +n = write 1 ichat 0 len ichat +if lt n 0 +trap 3 +end +n = write 1 ixask 0 len ixask +if lt n 0 +trap 3 +end +n = write 1 igpc 0 len igpc +if lt n 0 +trap 3 +end +n = write 1 iafter 0 len iafter +if lt n 0 +trap 3 +end +n = write 1 iwho 0 len iwho +if lt n 0 +trap 3 +end +n = write 1 ifoot 0 len ifoot +if lt n 0 +trap 3 +end +n = write 3 ijs0 0 len ijs0 +if lt n 0 +trap 3 +end +n = write 3 ijs1 0 len ijs1 +if lt n 0 +trap 3 +end +n = write 3 ijs2 0 len ijs2 +if lt n 0 +trap 3 +end +n = write 3 ijs3 0 len ijs3 +if lt n 0 +trap 3 +end +n = write 3 ijs4 0 len ijs4 +if lt n 0 +trap 3 +end +n = write 3 ijs5 0 len ijs5 +if lt n 0 +trap 3 +end +n = write 3 ijs6 0 len ijs6 +if lt n 0 +trap 3 +end +ret 0 +end diff --git a/om/allen-page/allen.om b/om/allen-page/allen.om index 648ead4..7273947 100644 --- a/om/allen-page/allen.om +++ b/om/allen-page/allen.om @@ -10,16 +10,16 @@ note speeds holds label and id fields alternately, separated by byte 124: each p note dt and dd row in table order. prompts holds the example prompts, one button each, in order. note No field may contain byte 124 or a newline. -text pg1 "
\n
\n

Aien, live from the Spark

\n

Talk to Aien

\n

Aien is Drake's AI. Ask it anything, ask what Omega is (Aien's own language for all computing, GPU to CPU), or ask for a small program. An HTML mini app runs right here in a sandboxed frame; an Omega function is compiled to WebAssembly on the Spark and runs in your browser.

\n

Model ~24~, running on a DGX Spark in Drake's house. The speeds below are measured by this page from the live stream.

\n
\n
\n

Anonymous: Aien won't remember this chat

\n
\n\n

If you tick this and my Spark is full, your messages in this chat go to a computer owned by a volunteer, outside my house. It gets only the text of this anonymous conversation. I add no visitor key, stored memories, contact record or IP address, but anything you type here is sent as you typed it. I check a sample of volunteer replies, not every one. A volunteer could still send a wrong or bad reply that I don't catch. Each reply says which machine answered.

\n
\n
\n" +text pg1 "
\n\n
\n

Explore the universe with Aien

\n
\n

Aien

\n
\n

Anonymous: Aien won't remember this chat

\n
\n
\n\n

If you tick this and my Spark is full, your messages in this chat go to a computer owned by a volunteer, outside my house. It gets only the text of this anonymous conversation. I add no visitor key, stored memories, contact record or IP address, but anything you type here is sent as you typed it. I check a sample of volunteer replies, not every one. A volunteer could still send a wrong or bad reply that I don't catch. Each reply says which machine answered.

\n
\n
    \n\n
    \n" text prompts "What is Omega?|Make me a calculator|Write an Omega gcd function|How fast are you?" text btna "\n" -text pg3 "
    \n\n

    \n
    \n\n\n
    \n\n\n\n
    \n
    \n

    To reach me, Drake, directly: follow me on X or email me at ~49~.

    \n

    Private by design: conversations are not stored, and the gateway keeps only aggregate counters. No prompts or IP addresses are logged. Programs run sandboxed in your browser. Reload the page and the conversation is gone. An introduction, and short notes Aien keeps about you, exist only if you consent; read what I keep.

    \n

    Agents can introduce themselves with POST https://www.aienos.com/allen/api/introduce (schema in /llms.txt); nothing is stored without \"consent\": true.

    \n
    \nYour Aien key\n

    Your Aien key needs JavaScript.

    \n
    \n
    \n\n
    \n" +text pg3 "\n

    To reach me, Drake, directly: follow me on X or email ~49~. More ways to reach me.

    \n

    This session stays in this tab. Reloading clears the conversation. Projects are saved on this device only when you choose Save. Remembering you is a separate choice; read what I keep.

    \n
    Your Aien key

    Your Aien key needs JavaScript.

    \n\n\n

    Aien's front door · Classic site

    \n

    The browser controller is written in Omega. The scene uses the same native iMac renderer, compiled to WebAssembly.

    \n

    Own a DGX Spark? Run Sovereign Intelligence on yours.

    \n

    \n

    Enter to send. Shift+Enter for a new line.

    Microphone off. Voice availability is checked locally.

    \n\n\n" fn emit1 to void for b ulong len pg1 diff --git a/om/allen-page/main.html b/om/allen-page/main.html index 20b3cc9..c5fe671 100644 --- a/om/allen-page/main.html +++ b/om/allen-page/main.html @@ -1,16 +1,12 @@
    -
    -

    Aien, live from the Spark

    -

    Talk to Aien

    -

    Aien is Drake's AI. Ask it anything, ask what Omega is (Aien's own language for all computing, GPU to CPU), or ask for a small program. An HTML mini app runs right here in a sandboxed frame; an Omega function is compiled to WebAssembly on the Spark and runs in your browser.

    -

    Model qwen3.6-35b-a3b-fp8, running on a DGX Spark in Drake's house. The speeds below are measured by this page from the live stream.

    -
    + +
    +

    Explore the universe with Aien

    +
    +

    Aien

    Anonymous: Aien won't remember this chat

    -
    - -

    If you tick this and my Spark is full, your messages in this chat go to a computer owned by a volunteer, outside my house. It gets only the text of this anonymous conversation. I add no visitor key, stored memories, contact record or IP address, but anything you type here is sent as you typed it. I check a sample of volunteer replies, not every one. A volunteer could still send a wrong or bad reply that I don't catch. Each reply says which machine answered.

    -
    + +

    +

    Enter to send. Shift+Enter for a new line.

    Microphone off. Voice availability is checked locally.

    -
    diff --git a/om/allen-page/main.html.sha256 b/om/allen-page/main.html.sha256 index 8856e90..58e48e4 100644 --- a/om/allen-page/main.html.sha256 +++ b/om/allen-page/main.html.sha256 @@ -1 +1 @@ -1d81013f109fbdd65c8e44c8b8819787f164bdf337d493098acff62964be7d63 main.html +5fc84f0c10137722fbdad42680463ce38c3884ca9c7f3fc17cf290b0b35a6f26 main.html diff --git a/om/allen-panes/allen-panes.js.sha256 b/om/allen-panes/allen-panes.js.sha256 new file mode 100644 index 0000000..a867a71 --- /dev/null +++ b/om/allen-panes/allen-panes.js.sha256 @@ -0,0 +1 @@ +0df902e426e99496d55623ba233bc440dacafcbaca86f15870e2a21826d27494 ../../public/js/allen-panes.js diff --git a/om/allen-panes/check.sh b/om/allen-panes/check.sh new file mode 100755 index 0000000..9c350a7 --- /dev/null +++ b/om/allen-panes/check.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Regenerate the Allen glass panes script using the pinned arm64 omc. +# The compiler is the one vendored for the Hive page; its pin is recorded once, +# in ../hive-page/omc.sha256. contract.om is the canonical pane contract (owned +# by the science protocol); its kinds, events, version and byte limits are +# compiled into the script. CI on x86_64 checks the committed artifact against +# its recorded hash. OMEGA_OMC overrides the compiler path, never its pin. +# OMEGA_ACCEPT_CHANGE=1 accepts a rewritten artifact; otherwise stale output exits 4. +# Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten; +# 5: nondeterministic output; 6: empty output. Compile/run failures propagate. +set -eu +cd "$(dirname "$0")" +omc=${OMEGA_OMC:-$PWD/../hive-page/omc} +pin=$(tr -d ' \n' < ../hive-page/omc.sha256) +if [ ! -f "$omc" ]; then + printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2 + exit 2 +fi +have=$(sha256sum "$omc" | cut -d' ' -f1) +if [ "$have" != "$pin" ]; then + printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2 + exit 3 +fi +work=$(mktemp -d "${TMPDIR:-/tmp}/allen-panes.XXXXXX") +trap 'rm -rf "$work"' EXIT HUP INT TERM +# Concatenation composes Omega units; it does not implement generation in shell. +cat contract.om panes.om > "$work/panes.om" +"$omc" < "$work/panes.om" > "$work/panes" +chmod +x "$work/panes" +"$work/panes" > "$work/first.js" +"$work/panes" > "$work/second.js" +if ! cmp -s "$work/first.js" "$work/second.js"; then + printf 'allen-panes.js: generator output differs between runs\n' >&2 + exit 5 +fi +if [ ! -s "$work/first.js" ]; then + printf 'allen-panes.js: generator wrote nothing\n' >&2 + exit 6 +fi +artifact=../../public/js/allen-panes.js +stale=0 +if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$work/first.js"; then + stale=1 +fi +cp "$work/first.js" "$artifact" +hash=$(sha256sum "$artifact" | cut -d' ' -f1) +printf '%s %s\n' "$hash" "$artifact" > allen-panes.js.sha256 +printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash" +printf 'omc sha256 %s\n' "$have" +if [ "$stale" = 1 ]; then + printf 'Generated artifact was rewritten; commit it with its Omega sources\n' >&2 + if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then + exit 4 + fi +fi diff --git a/om/allen-panes/contract.om b/om/allen-panes/contract.om new file mode 100644 index 0000000..9407b16 --- /dev/null +++ b/om/allen-panes/contract.om @@ -0,0 +1,54 @@ +note Allen glass pane protocol v1. Canonical transport and safety contract. +note SSE event names are exactly pane.open, pane.update, pane.close; JSON data objects only. +note open = {v:1,id,kind,title}; id ASCII [A-Za-z0-9_-]{1,64}; title UTF8 <=200 bytes. +note kind = math|plot|doc|code|app|research|data|omega. Max 32 live panes in browser. +note update = {v:1,id,revision,content,provenance}; revision integer 1..1000000. +note update fully replaces content and provenance, never patch/append/HTML injection. +note update before open, duplicate open and non-increasing revision are refused. +note close = {v:1,id}; unknown close is a no-op; closed ids cannot reopen in one stream. +note Each event <=65536 UTF8 bytes, all events <=262144 bytes per chat turn. +note content strings <=32768 UTF8 bytes; list count <=64 unless specified below. +note math content = {text,tex?}; only an actual successful engine result is computed. +note plot content = {series:[{label,points:[[finite number,finite number]]}],x_label,y_label}. +note plot <=8 series, <=512 points per series; labels <=200 bytes; data never proves itself. +note doc content = {markdown,citations:[{title,url}]}; URLs HTTPS only and never fetched. +note code/omega content = {source,language,wasm?,functions?}; wasm base64, never auto-run. +note functions = [{name,params:[{name,type}],ret}] exactly matching the Omega compile endpoint. +note app content = {html}; explicit visitor Run only; sandbox allow-scripts without same-origin. +note app CSP denies network, external resources, forms, navigation and frame escape. +note research content = {notes,hypotheses:[string],derivations:[string],sources:[{title,url}]}. +note data content = {columns:[string],rows:[[string]]}; never inferred as measured data. +note provenance = {status,engine,expression,result,source,commit}; all values strings. +note status = computed|unsupported|unverified|input-data; exact expression/result are auditable. +note computed means aien-math emitted a result, NOT that the result is independently correct. +note No model-produced number is labelled computed. Unsupported math has no model fallback. +note Model docs/research are unverified; plot literals input-data. Sources may be unverified. +note Engine identity and full corpus score are displayed with exact source pin and receipt limits. +note No live web access; no hidden Wolfram dependency, key, quota, or external math request. +note Unknown fields, invalid kinds, nonfinite numbers or excess sizes refuse the complete event. +note Browser strings are untrusted. DOM text nodes only; structured plots create SVG elements. +note TeX is source until actually typeset; never claim a source dump is a rendered formula. +note Projects persist in browser IndexedDB. Export is explicit. No anonymous server persistence. +note Remember-me summaries require separate visitor action and the existing opaque visitor key. +note Source text is never sent to Cortex automatically; sync <=1000 UTF8 bytes per summary. +note Public gateway forwards only six strict tool schemas to loopback isolated science service. +note math_compute, omega_compile, web_app, paper, research, plot; no arbitrary tool dispatch. +note At most three tool rounds. Public request admission cap remains two; tools spawn no model. +note Service has no network, credentials, writable host tree, project store or GitHub capability. +const PANEVER uint 1 +const PANE_MAX ulong 65536 +const TURN_MAX ulong 262144 +const TEXT_MAX ulong 32768 +const TOOL_MAX uint 3 +const TITLEMAX ulong 200 +const LISTMAX ulong 64 +const SERIESMX ulong 8 +const POINTSMX ulong 512 +const REVMAX ulong 1000000 +const PANESMAX ulong 32 +const URLMAX ulong 2048 +const SYNC_MAX ulong 1000 +const PLOTMAX f64 1.0e100 +text paneevt "pane.open|pane.update|pane.close|" +text panekind "math|plot|doc|code|app|research|data|omega|" +text toolname "math_compute|omega_compile|web_app|paper|research|plot|" diff --git a/om/allen-panes/panes.om b/om/allen-panes/panes.om new file mode 100644 index 0000000..be74a2a --- /dev/null +++ b/om/allen-panes/panes.om @@ -0,0 +1,326 @@ +note Allen glass panes generator: emits public/js/allen-panes.js on fd 1. +note ~N~ tokens in the js texts expand single definitions. 0 to 4 and 6 to 12 +note come from contract.om, the canonical pane contract owned by the science +note protocol: 0 panekind, 1 paneevt, 2 PANEVER, 3 PANE_MAX, 4 TEXT_MAX, +note 6 TITLEMAX, 7 LISTMAX, 8 SERIESMX, 9 POINTSMX, 10 REVMAX, 11 PANESMAX, +note 12 URLMAX. The rest are the fields of pcfg below, in order: 5 statuses, +note 13 reopenable closed panes, 14 saved projects, 15 project bytes, 16 IndexedDB +note name, 17 file format, 18 frame sandbox, 19 frame CSP, 20 sheet media query, +note 21 minimum width, 22 minimum height, 23 largest plot magnitude, and 24 is +note contract SYNC_MAX, the project summary bytes. +note Field 23 is the decimal form of contract PLOTMAX; main traps if they differ. +note 5 repeats the contract status sentence. A pcfg field cannot contain a pipe or +note a newline. Composed with contract.om by check.sh, never compiled on its own. +note Source language checked at omega-mv 55f9b0af47de70a3d06357985cf99ae3e45c016f. +text pcfg "computed,unsupported,unverified,input-data|8|50|4194304|allen-panes|allen-panes-project|allow-scripts|default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; form-action 'none'; base-uri 'none'|(max-width: 720px)|260|160|1e100|" +global output uchar 65536 +global used ulong 1 +global marker ulong 2 + +fn flush to void +p = ulong 0 +while lt p get used 0 bound 65536 +n = write 1 output p sub get used 0 p +if le n 0 +trap 3 +end +p = add p ulong n +end +put used 0 0 +end + +fn raw c uchar to void +if eq get used 0 len output +flush +end +put output get used 0 c +put used 0 add get used 0 1 +end + +note field: the k-th pipe-terminated field of pcfg; a missing field traps. +fn field k ulong to void +p = ulong 0 +i = ulong 0 +while lt p len pcfg +c = get pcfg p +if eq c 124 +if eq i k +ret +end +i = add i 1 +else +if eq i k +raw c +end +end +p = add p 1 +end +trap 3 +end + +note kinds and events: a contract list with its pipes as commas, no trailing one. +fn kinds to void +p = ulong 0 +while lt p len panekind +c = get panekind p +if eq c 124 +if lt add p 1 len panekind +raw 44 +end +else +raw c +end +p = add p 1 +end +end + +fn events to void +p = ulong 0 +while lt p len paneevt +c = get paneevt p +if eq c 124 +if lt add p 1 len paneevt +raw 44 +end +else +raw c +end +p = add p 1 +end +end + +note num: v in decimal; a ulong has at most 20 digits. +fn num v ulong to void +d = new uchar 20 0 +x = v +put d 0 uchar add 48 rem x 10 +n = ulong 1 +x = div x 10 +while gt x 0 bound 20 +put d n uchar add 48 rem x 10 +n = add n 1 +x = div x 10 +end +while gt n 0 bound 20 +n = sub n 1 +raw get d n +end +end + +fn slot k ulong to void +if eq k 0 +kinds +ret +end +if eq k 1 +events +ret +end +if eq k 2 +num ulong PANEVER +ret +end +if eq k 3 +num PANE_MAX +ret +end +if eq k 4 +num TEXT_MAX +ret +end +slot2 k +end + +note slot2: the contract limits 6 to 12, then pcfg field 0 for 5 and k - 12 above 12. +fn slot2 k ulong to void +if eq k 5 +field 0 +ret +end +if eq k 6 +num TITLEMAX +ret +end +if eq k 7 +num LISTMAX +ret +end +if eq k 8 +num SERIESMX +ret +end +if eq k 9 +num POINTSMX +ret +end +if eq k 10 +num REVMAX +ret +end +if eq k 11 +num PANESMAX +ret +end +if eq k 12 +num URLMAX +ret +end +if eq k 24 +num SYNC_MAX +ret +end +field sub k 12 +end + +note byteput: ~N~ expands slot N; any other byte is copied. +fn byteput c uchar to void +if eq c 126 +if eq get marker 0 0 +put marker 0 1 +put marker 1 0 +else +slot get marker 1 +put marker 0 0 +end +else +if eq get marker 0 1 +if or lt c 48 gt c 57 +trap 3 +end +put marker 1 add mul get marker 1 10 ulong sub c 48 +else +raw c +end +end +end + +note JavaScript KINDS +text js0 "/* Allen glass panes.\n *\n * Generated by om/allen-panes/panes.om; never hand-edit. Event names, kinds,\n * the protocol version and the byte limits come from the canonical pane\n * contract om/allen-panes/contract.om; the remaining bounds come from the\n * table in panes.om.\n *\n * Renders the v1 pane events (pane.open, pane.update, pane.close) as movable,\n * resizable, stackable glass panes over the scene. Every network or model\n * string reaches only textContent, an attribute value this file checks, or the\n * srcdoc of a frame sandboxed to allow-scripts alone after an explicit Run\n * click. Nothing from the network is parsed as markup in this document: plots\n * are drawn here from numbers and TeX is typeset here by a small subset\n * renderer, or shown as source when it uses anything outside that subset.\n * Projects reach IndexedDB only on an explicit Save project.\n */\n(() => {\n 'use strict';\n if (window.AllenPanes) return;\n const KINDS = '~0~'.split(',');\n const EVENTS = '~1~'.split(',');\n const VERSION = ~2~;\n const MAX_EVENT = ~3~;\n const MAX_TEXT = ~4~;\n const STATUSES = '~5~'.split(',');\n const MAX_TITLE = ~6~;\n const MAX_LIST = ~7~;\n const MAX_SERIES = ~8~;\n const MAX_POINTS = ~9~;\n const MAX_REVISION = ~10~;\n const MAX_PANES = ~11~;\n const MAX_URL = ~12~;\n const MAX_CLOSED = ~13~;\n const MAX_PROJECTS = ~14~;\n const MAX_PROJECT_BYTES = ~15~;\n const DB_NAME = '~16~';\n const FORMAT = '~17~';\n const SANDBOX = '~18~';\n const CSP = \"~19~\";\n const SHEET = '~20~';\n const MIN_W = ~21~;\n const MIN_H = ~22~;\n const MAX_ABS = ~23~;\n const SYNC_MAX = ~24~;\n const ID = /^[A-Za-z0-9_-]{1,64}$/;\n const DB_PROJECTS = 'projects';\n const DB_INDEX = 'index';\n const STEP = 16;\n const BIG_STEP = 64;\n const MAX_NAME = 80;\n const ACADEMY = 'https://github.com/aien-dev/sovereign-intelligence/blob/main/docs/academy/README.md';\n const SVG_NS = 'http://www.w3.org/2000/svg';\n const MATH_NS = 'http://www.w3.org/1998/Math/MathML';\n const NAMES = { math: 'Math', plot: 'Plot', doc: 'Document', code: 'Code', app: 'App', research: 'Research', data: 'Data', omega: 'Omega', card: 'Aien', projects: 'Projects' };\n const STATUS_NAMES = { computed: 'Computed', unsupported: 'Not supported', unverified: 'Not verified', 'input-data': 'Given data' };\n const CAVEATS = {\n computed: 'The math engine produced this result. That is not an independent check that it is correct.',\n unsupported: 'The engine does not support this request, so nothing here was computed.',\n unverified: 'Written by the model and not checked by any engine.',\n 'input-data': 'These are the numbers as given. Showing them does not measure or prove them.'\n };\n const PALETTE = ['#2d7ff9', '#00e599', '#f59e0b', '#6e82ff', '#f87171', '#c4b5fd', '#94a3b8', '#f1f5f9'];\n const EXT = { javascript: 'js', js: 'js', typescript: 'ts', ts: 'ts', python: 'py', py: 'py', rust: 'rs', rs: 'rs', c: 'c', cpp: 'cpp', 'c++': 'cpp', go: 'go', java: 'java', html: 'html', css: 'css', json: 'json', shell: 'sh', sh: 'sh', bash: 'sh', sql: 'sql', mojo: 'mojo', wat: 'wat', omega: 'om', om: 'om', markdown: 'md', md: 'md', text: 'txt' };\n const encoder = new TextEncoder();\n let serial = 0;\n\n function el(tag, className, text) {\n const node = document.createElement(tag);\n if (className) node.className = className;\n if (text !== undefined) node.textContent = text;\n return node;\n }\n function button(className, label, text, handler) {\n const node = el('button', className, text);\n node.type = 'button';\n if (label) node.setAttribute('aria-label', label);\n if (handler) node.addEventListener('click', handler);\n return node;\n }\n function uid(prefix) {\n serial += 1;\n return `${prefix}-${serial}`;\n }\n /* Display text for titles and names: no control or bidirectional override\n characters, one line, bounded. */\n function clean(text, max) {\n return String(text).replace(/[\\u0000-\\u001f\\u007f-\\u009f\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069]/g, ' ').replace(/\\s+/g, ' ').trim().slice(0, max);\n }\n function slug(text) {\n return String(text).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+/, '').slice(0, 48).replace(/-+$/, '');\n }\n function copy(value) {\n return JSON.parse(JSON.stringify(value));\n }\n function utf8(text) {\n return encoder.encode(text).length;\n }\n\n" + +note JavaScript own +text js1 " /* The v1 contract, checked exactly as the gateway checks it: unknown or\n missing fields, a wrong kind, a nonfinite number or an excess size refuse\n the whole event. */\n const own = (o, k) => Object.prototype.hasOwnProperty.call(o, k);\n function plain(o) {\n if (o === null || typeof o !== 'object' || Array.isArray(o)) return false;\n const proto = Object.getPrototypeOf(o);\n return proto === Object.prototype || proto === null;\n }\n function shape(o, required, optional) {\n if (!plain(o)) return false;\n const allowed = optional ? required.concat(optional) : required;\n for (const k of Object.keys(o)) if (!allowed.includes(k)) return false;\n return required.every(k => own(o, k));\n }\n function isText(v, max, filled) {\n if (typeof v !== 'string' || v.length > max || v.includes('\\u0000')) return false;\n if (filled && !v.trim()) return false;\n return v.length * 3 <= max || utf8(v) <= max;\n }\n function texts(v) {\n return Array.isArray(v) && v.length <= MAX_LIST && v.every(s => isText(s, MAX_TEXT));\n }\n function finite(n) {\n return typeof n === 'number' && Number.isFinite(n) && Math.abs(n) <= MAX_ABS;\n }\n function httpsUrl(url) {\n if (typeof url !== 'string' || !isText(url, MAX_URL) || /[\\u0000-\\u0020\\u007f]/.test(url)) return null;\n try {\n const parsed = new URL(url);\n return parsed.protocol === 'https:' && parsed.hostname && !parsed.username && !parsed.password ? parsed : null;\n } catch (_) {\n return null;\n }\n }\n function refs(v) {\n return Array.isArray(v) && v.length <= MAX_LIST && v.every(r => shape(r, ['title', 'url']) && isText(r.title, MAX_TITLE, true) && httpsUrl(r.url) !== null);\n }\n function fns(v) {\n return Array.isArray(v) && v.length <= MAX_LIST && v.every(f => shape(f, ['name', 'params', 'ret']) && isText(f.name, MAX_TEXT) && isText(f.ret, MAX_TEXT)\n && Array.isArray(f.params) && f.params.length <= MAX_LIST && f.params.every(p => shape(p, ['name', 'type']) && isText(p.name, MAX_TEXT) && isText(p.type, MAX_TEXT)));\n }\n function code(c) {\n return shape(c, ['source', 'language'], ['wasm', 'functions']) && isText(c.source, MAX_TEXT) && isText(c.language, MAX_TEXT)\n && (!own(c, 'wasm') || isText(c.wasm, MAX_TEXT)) && (!own(c, 'functions') || fns(c.functions));\n }\n function series(s) {\n return shape(s, ['label', 'points']) && isText(s.label, MAX_TITLE) && Array.isArray(s.points) && s.points.length >= 1 && s.points.length <= MAX_POINTS\n && s.points.every(p => Array.isArray(p) && p.length === 2 && finite(p[0]) && finite(p[1]));\n }\n const CONTENT = {\n math: c => shape(c, ['text'], ['tex']) && isText(c.text, MAX_TEXT) && (!own(c, 'tex') || isText(c.tex, MAX_TEXT)),\n plot: c => shape(c, ['series', 'x_label', 'y_label']) && isText(c.x_label, MAX_TITLE) && isText(c.y_label, MAX_TITLE)\n && Array.isArray(c.series) && c.series.length >= 1 && c.series.length <= MAX_SERIES && c.series.every(series),\n doc: c => shape(c, ['markdown', 'citations']) && isText(c.markdown, MAX_TEXT) && refs(c.citations),\n code,\n omega: code,\n app: c => shape(c, ['html']) && isText(c.html, MAX_TEXT),\n research: c => shape(c, ['notes', 'hypotheses', 'derivations', 'sources']) && isText(c.notes, MAX_TEXT) && texts(c.hypotheses) && texts(c.derivations) && refs(c.sources),\n data: c => shape(c, ['columns', 'rows']) && texts(c.columns) && c.columns.length >= 1\n && Array.isArray(c.rows) && c.rows.length <= MAX_LIST && c.rows.every(texts)\n };\n const PROVENANCE = ['status', 'engine', 'expression', 'result', 'source', 'commit'];\n function provenance(p) {\n return shape(p, PROVENANCE) && STATUSES.includes(p.status) && PROVENANCE.every(k => isText(p[k], MAX_TEXT));\n }\n function sized(value) {\n try {\n return utf8(JSON.stringify(value)) <= MAX_EVENT;\n } catch (_) {\n return false;\n }\n }\n /* Returns '' for a valid event, else the reason. An update is checked\n against the kind its pane was opened with. */\n function check(name, p, kind) {\n if (!EVENTS.includes(name)) return 'unknown pane event';\n if (!plain(p)) return 'the event is not a JSON object';\n const fields = name === 'pane.open' ? ['v', 'id', 'kind', 'title'] : name === 'pane.update' ? ['v', 'id', 'revision', 'content', 'provenance'] : ['v', 'id'];\n if (!shape(p, fields)) return 'unexpected or missing fields';\n if (p.v !== VERSION || typeof p.id !== 'string' || !ID.test(p.id)) return 'invalid pane identity';\n if (!sized(p)) return 'the event is over the size limit';\n if (name === 'pane.open') {\n if (!KINDS.includes(p.kind)) return 'invalid pane kind';\n return isText(p.title, MAX_TITLE, true) ? '' : 'invalid title';\n }\n if (name === 'pane.update') {\n if (!Number.isInteger(p.revision) || p.revision < 1 || p.revision > MAX_REVISION) return 'invalid revision';\n if (!KINDS.includes(kind)) return 'the pane is not open';\n if (!CONTENT[kind](p.content)) return `the content does not match ${kind === 'app' || kind === 'omega' ? 'an' : 'a'} ${kind} pane`;\n return provenance(p.provenance) ? '' : 'invalid provenance';\n }\n return '';\n }\n\n" + +note JavaScript link +text js2 " /* Links: HTTPS only, shown with their host, never fetched by this page. */\n function link(label, url) {\n const safe = httpsUrl(url);\n const shown = clean(label, MAX_TITLE) || url;\n if (!safe) {\n const span = el('span', 'allen-link-off', shown);\n if (url && url !== shown) span.append(document.createTextNode(` (${url})`));\n return span;\n }\n const frag = document.createDocumentFragment();\n const a = el('a', 'allen-link', shown);\n a.href = safe.href;\n a.target = '_blank';\n a.rel = 'noopener noreferrer nofollow';\n a.referrerPolicy = 'no-referrer';\n frag.append(a, el('span', 'allen-link-host', ` ${safe.host}`));\n return frag;\n }\n\n /* A small first-party TeX subset typeset as MathML Core built element by\n element. Anything outside the subset throws, and the caller shows the\n TeX as source and says so. */\n const GREEK = { alpha: '\\u03b1', beta: '\\u03b2', gamma: '\\u03b3', delta: '\\u03b4', epsilon: '\\u03f5', varepsilon: '\\u03b5', zeta: '\\u03b6', eta: '\\u03b7', theta: '\\u03b8', vartheta: '\\u03d1', iota: '\\u03b9', kappa: '\\u03ba', lambda: '\\u03bb', mu: '\\u03bc', nu: '\\u03bd', xi: '\\u03be', pi: '\\u03c0', varpi: '\\u03d6', rho: '\\u03c1', varrho: '\\u03f1', sigma: '\\u03c3', varsigma: '\\u03c2', tau: '\\u03c4', upsilon: '\\u03c5', phi: '\\u03d5', varphi: '\\u03c6', chi: '\\u03c7', psi: '\\u03c8', omega: '\\u03c9', Gamma: '\\u0393', Delta: '\\u0394', Theta: '\\u0398', Lambda: '\\u039b', Xi: '\\u039e', Pi: '\\u03a0', Sigma: '\\u03a3', Upsilon: '\\u03a5', Phi: '\\u03a6', Psi: '\\u03a8', Omega: '\\u03a9' };\n const IDENT = { infty: '\\u221e', partial: '\\u2202', nabla: '\\u2207', ell: '\\u2113', hbar: '\\u210f', emptyset: '\\u2205', aleph: '\\u2135' };\n const OPS = { pm: '\\u00b1', mp: '\\u2213', times: '\\u00d7', cdot: '\\u22c5', div: '\\u00f7', ast: '\\u2217', star: '\\u22c6', circ: '\\u2218', bullet: '\\u2219', leq: '\\u2264', le: '\\u2264', geq: '\\u2265', ge: '\\u2265', neq: '\\u2260', ne: '\\u2260', approx: '\\u2248', equiv: '\\u2261', sim: '\\u223c', simeq: '\\u2243', cong: '\\u2245', propto: '\\u221d', ll: '\\u226a', gg: '\\u226b', to: '\\u2192', rightarrow: '\\u2192', leftarrow: '\\u2190', Rightarrow: '\\u21d2', Leftarrow: '\\u21d0', leftrightarrow: '\\u2194', Leftrightarrow: '\\u21d4', iff: '\\u21d4', implies: '\\u21d2', mapsto: '\\u21a6', in: '\\u2208', notin: '\\u2209', ni: '\\u220b', subset: '\\u2282', supset: '\\u2283', subseteq: '\\u2286', supseteq: '\\u2287', cup: '\\u222a', cap: '\\u2229', setminus: '\\u2216', wedge: '\\u2227', land: '\\u2227', vee: '\\u2228', lor: '\\u2228', neg: '\\u00ac', lnot: '\\u00ac', forall: '\\u2200', exists: '\\u2203', ldots: '\\u2026', cdots: '\\u22ef', vdots: '\\u22ee', ddots: '\\u22f1', dots: '\\u2026', prime: '\\u2032', perp: '\\u22a5', parallel: '\\u2225', angle: '\\u2220', oplus: '\\u2295', otimes: '\\u2297', langle: '\\u27e8', rangle: '\\u27e9', lfloor: '\\u230a', rfloor: '\\u230b', lceil: '\\u2308', rceil: '\\u2309', vert: '|', mid: '|', lbrace: '{', rbrace: '}' };\n const LARGE = { sum: '\\u2211', prod: '\\u220f', coprod: '\\u2210', int: '\\u222b', iint: '\\u222c', iiint: '\\u222d', oint: '\\u222e', bigcup: '\\u22c3', bigcap: '\\u22c2' };\n const FUNCS = 'sin cos tan cot sec csc arcsin arccos arctan sinh cosh tanh coth log ln lg exp det dim ker deg gcd lcm max min sup inf lim liminf limsup arg Pr mod'.split(' ');\n const LIMITS = ['sum', 'prod', 'coprod', 'bigcup', 'bigcap', 'lim', 'liminf', 'limsup', 'max', 'min', 'sup', 'inf'];\n const SPACES = { ',': '0.1667em', ':': '0.2222em', ';': '0.2778em', '!': '-0.1667em', ' ': '0.25em', quad: '1em', qquad: '2em' };\n const BB = { C: '\\u2102', H: '\\u210d', N: '\\u2115', P: '\\u2119', Q: '\\u211a', R: '\\u211d', Z: '\\u2124' };\n const FENCES = { '(': '(', ')': ')', '[': '[', ']': ']', '|': '|', '.': '', '\\\\{': '{', '\\\\}': '}', '\\\\langle': '\\u27e8', '\\\\rangle': '\\u27e9', '\\\\lvert': '|', '\\\\rvert': '|', '\\\\|': '\\u2016', '\\\\lfloor': '\\u230a', '\\\\rfloor': '\\u230b', '\\\\lceil': '\\u2308', '\\\\rceil': '\\u2309' };\n function mml(tag, children, attrs) {\n const node = document.createElementNS(MATH_NS, tag);\n if (attrs) for (const k of Object.keys(attrs)) node.setAttribute(k, attrs[k]);\n if (typeof children === 'string') node.textContent = children;\n else if (children) node.append(...children);\n return node;\n }\n function texTokens(src) {\n const out = [];\n const re = /\\\\([A-Za-z]+|.)|(\\d+(?:\\.\\d+)?)|(\\s+)|([\\s\\S])/g;\n let m;\n while ((m = re.exec(src)) !== null) {\n if (out.length > 4096) throw new Error('too long');\n if (m[3]) continue;\n out.push(m[1] !== undefined ? { t: 'cmd', v: m[1] } : m[2] !== undefined ? { t: 'num', v: m[2] } : { t: 'chr', v: m[4] });\n }\n return out;\n }\n function texParse(src) {\n const toks = texTokens(src);\n let at = 0;\n let depth = 0;\n const peek = () => toks[at];\n const take = () => toks[at++];\n const fail = what => { throw new Error(what); };\n function group() {\n const t = peek();\n if (!t) fail('missing argument');\n if (t.t === 'chr' && t.v === '{') {\n take();\n const row = seq('}');\n if (!peek() || peek().v !== '}') fail('unclosed brace');\n take();\n return row;\n }\n return atom(true);\n }\n function raw() {\n const t = take();\n if (!t || t.t !== 'chr' || t.v !== '{') fail('expected a braced argument');\n let text = '';\n let level = 1;\n for (;;) {\n const n = take();\n if (!n) fail('unclosed brace');\n if (n.t === 'chr' && n.v === '{') level += 1;\n if (n.t === 'chr' && n.v === '}') {\n level -= 1;\n if (level === 0) return text;\n }\n text += n.t === 'cmd' ? (n.v.length === 1 ? n.v : `\\\\${n.v} `) : n.v;\n }\n }\n function fence() {\n const t = take();\n if (!t) fail('missing delimiter');\n const key = t.t === 'cmd' ? `\\\\${t.v}` : t.v;\n if (!own(FENCES, key)) fail(`delimiter ${key}`);\n return FENCES[key];\n }\n function atom(single) {\n const t = take();\n if (!t) fail('missing argument');\n if (t.t === 'num') {\n if (single && t.v.length > 1) {\n at -= 1;\n toks[at] = { t: 'num', v: t.v.slice(1) };\n return mml('mn', t.v[0]);\n }\n return mml('mn', t.v);\n }\n if (t.t === 'chr') {\n if (/[A-Za-z]/.test(t.v)) return mml('mi', t.v);\n if (t.v === '{' && !single) {\n at -= 1;\n return group();\n }\n if (t.v === \"'\") return mml('mo', '\\u2032');\n if (t.v === '-') return mml('mo', '\\u2212');\n if ('+=<>()[]|,;:!/*.?'.includes(t.v)) return mml('mo', t.v, '()[]|'.includes(t.v) ? { stretchy: 'false' } : undefined);\n fail(`character ${t.v}`);\n }\n const c = t.v;\n if (own(GREEK, c)) return mml('mi', GREEK[c], /^[A-Z]/.test(c) ? { mathvariant: 'normal' } : undefined);\n if (own(IDENT, c)) return mml('mi', IDENT[c]);\n if (own(OPS, c)) return mml('mo', OPS[c]);\n if (own(LARGE, c)) return mml('mo', LARGE[c], LIMITS.includes(c) ? { largeop: 'true', movablelimits: 'true' } : { largeop: 'true' });\n if (FUNCS.includes(c)) return mml('mi', c, { mathvariant: 'normal' });\n if (own(SPACES, c)) return mml('mspace', null, { width: SPACES[c] });\n if (c === '{' || c === '}' || c === '%' || c === '$' || c === '#' || c === '_' || c === '&') return mml('mo', c);\n if (c === 'frac' || c === 'dfrac' || c === 'tfrac') return mml('mfrac', [group(), group()]);\n if (c === 'binom') return mml('mrow', [mml('mo', '('), mml('mfrac', [group(), group()], { linethickness: '0' }), mml('mo', ')')]);\n if (c === 'sqrt') {\n if (peek() && peek().t === 'chr' && peek().v === '[') {\n take();\n const index = seq(']');\n if (!peek() || peek().v !== ']') fail('unclosed root index');\n take();\n return mml('mroot', [group(), index]);\n }\n return mml('msqrt', [group()]);\n }\n if (c === 'text' || c === 'textrm' || c === 'mathrm' || c === 'operatorname') {\n const text = raw();\n return c === 'text' || c === 'textrm' ? mml('mtext', text) : mml('mi', text, { mathvariant: 'normal' });\n }\n if (c === 'mathbb') {\n const letter = raw().trim();\n if (!own(BB, letter)) fail(`mathbb ${letter}`);\n return mml('mi', BB[letter]);\n }\n if (c === 'left') {\n const open = fence();\n const inner = seq('right');\n const close = peek();\n if (!close || close.t !== 'cmd' || close.v !== 'right') fail('left without right');\n take();\n const shut = fence();\n return mml('mrow', [mml('mo', open, { fence: 'true', stretchy: 'true' }), inner, mml('mo', shut, { fence: 'true', stretchy: 'true' })]);\n }\n return fail(`\\\\${c}`);\n }\n function scripted(base) {\n let sub = null;\n let sup = null;\n for (let i = 0; i < 2; i++) {\n const t = peek();\n if (!t || t.t !== 'chr' || (t.v !== '_' && t.v !== '^')) break;\n take();\n if (t.v === '_') {\n if (sub) fail('double subscript');\n sub = group();\n } else {\n if (sup) fail('double superscript');\n sup = group();\n }\n }\n if (!sub && !sup) return base;\n const under = (base.localName === 'mo' && base.getAttribute('movablelimits') === 'true') || (base.localName === 'mi' && LIMITS.includes(base.textContent));\n if (sub && sup) return mml(under ? 'munderover' : 'msubsup', [base, sub, sup]);\n if (sub) return mml(under ? 'munder' : 'msub', [base, sub]);\n return mml(under ? 'mover' : 'msup', [base, sup]);\n }\n function seq(stop) {\n depth += 1;\n if (depth > 32) fail('nested too deeply');\n const items = [];\n while (at < toks.length) {\n const t = peek();\n if (stop === 'right' ? t.t === 'cmd' && t.v === 'right' : t.t === 'chr' && t.v === stop) break;\n if (t.t === 'chr' && (t.v === '}' || t.v === ']') && stop === null) fail('unbalanced');\n if (t.t === 'chr' && (t.v === '^' || t.v === '_')) {\n items.push(scripted(mml('mrow', [])));\n continue;\n }\n items.push(scripted(atom(false)));\n }\n depth -= 1;\n return items.length === 1 ? items[0] : mml('mrow', items);\n }\n const tree = seq(null);\n if (at !== toks.length) fail('trailing input');\n return tree;\n }\n /* Returns a math element, or null with the reason when the TeX is outside\n the subset or the browser has no MathML. */\n function typeset(src, display) {\n if (typeof window.MathMLElement !== 'function') return { node: null, reason: 'this browser does not lay out MathML' };\n try {\n const tree = texParse(src);\n const semantics = mml('semantics', [tree, mml('annotation', src, { encoding: 'application/x-tex' })]);\n return { node: mml('math', [semantics], { display: display ? 'block' : 'inline' }), reason: '' };\n } catch (error) {\n return { node: null, reason: `it uses ${String(error && error.message).slice(0, 80)}, which this renderer does not typeset` };\n }\n }\n function texBlock(src, label) {\n const box = el('div', 'allen-tex');\n const done = typeset(src, true);\n if (done.node) {\n box.append(done.node, el('p', 'allen-pane-label', `${label} typeset in this page from TeX by a small first-party renderer; the source is below.`));\n } else {\n box.append(el('p', 'allen-pane-label', `${label} as TeX source, not typeset: ${done.reason}.`));\n }\n const pre = el('pre', 'allen-pane-pre', src);\n pre.setAttribute('aria-label', 'TeX source');\n box.append(pre);\n return box;\n }\n\n" + +note JavaScript inline +text js3 " /* Markdown subset rendered to DOM nodes only: headings, paragraphs, lists,\n quotes, rules, fenced code, pipe tables, inline code, strong, emphasis,\n HTTPS links and $ TeX. Raw HTML stays text. */\n function inline(node, text) {\n const re = /(`+)([^`][\\s\\S]*?)\\1|\\*\\*([^*\\n]+)\\*\\*|\\*([^*\\s][^*\\n]*)\\*|\\[([^\\]\\n]{1,500})\\]\\(([^)\\s]{1,2048})\\)|\\$([^$\\n]{1,500})\\$|(https:\\/\\/[^\\s<>()]{1,2048})/g;\n let last = 0;\n let m;\n while ((m = re.exec(text)) !== null) {\n if (m.index > last) node.append(document.createTextNode(text.slice(last, m.index)));\n if (m[1]) node.append(el('code', 'allen-md-code', m[2]));\n else if (m[3] !== undefined) node.append(el('strong', '', m[3]));\n else if (m[4] !== undefined) node.append(el('em', '', m[4]));\n else if (m[5] !== undefined) node.append(link(m[5], m[6]));\n else if (m[7] !== undefined) {\n const done = typeset(m[7], false);\n if (done.node) node.append(done.node);\n else {\n const raw = el('code', 'allen-md-tex', `$${m[7]}$`);\n raw.title = 'TeX source, not typeset';\n node.append(raw);\n }\n } else {\n const url = m[8].replace(/[.,;:!?]+$/, '');\n node.append(link(url, url));\n if (url.length < m[8].length) node.append(document.createTextNode(m[8].slice(url.length)));\n }\n last = re.lastIndex;\n }\n if (last < text.length) node.append(document.createTextNode(text.slice(last)));\n return node;\n }\n function cells(line) {\n return line.trim().replace(/^\\|/, '').replace(/\\|$/, '').split('|').map(s => s.trim());\n }\n /* A repo report's files, found by the same parser that renders the pane,\n so a fence the reader saw is exactly a fence that is saved. */\n const REPORT = /^Repo report: ([A-Za-z0-9_.-]{1,100})\\/([A-Za-z0-9_.-]{1,100})$/;\n function reportFiles(source) {\n const files = [{ path: 'README.md', content: source }];\n const patches = [];\n let port = 0;\n let harness = 0;\n markdown(source, document.createElement('div'), (lang, text) => {\n const kind = lang.toLowerCase();\n if (kind === 'omega' || kind === 'om') files.push({ path: `allen-port-${(port += 1)}.om`, content: `${text}\\n` });\n else if (kind === 'diff' || kind === 'patch') patches.push(`${text}\\n`);\n else if (kind === 'text' || kind === 'txt') files.push({ path: `parity-harness-${(harness += 1)}.txt`, content: `${text}\\n` });\n return null;\n });\n if (patches.length) files.push({ path: 'allen-ports.patch', content: patches.join('') });\n return files;\n }\n function markdown(source, box, fenceTool) {\n const lines = source.split(/\\r?\\n/);\n let para = [];\n let list = null;\n const flush = () => {\n if (para.length) box.append(inline(el('p', 'allen-md-p'), para.join(' ')));\n para = [];\n };\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n const fence = /^\\s*(```+)\\s*([A-Za-z0-9_+-]{0,32})\\s*$/.exec(line);\n if (fence) {\n flush();\n list = null;\n const body = [];\n for (i += 1; i < lines.length && !lines[i].trim().startsWith(fence[1]); i++) body.push(lines[i]);\n const pre = el('pre', 'allen-md-pre');\n if (fence[2]) pre.dataset.lang = fence[2];\n pre.append(el('code', '', body.join('\\n')));\n box.append(pre);\n const tool = fenceTool ? fenceTool(fence[2], body.join('\\n')) : null;\n if (tool) box.append(tool);\n continue;\n }\n if (/^\\s*\\$\\$/.test(line)) {\n flush();\n list = null;\n const body = [line.replace(/^\\s*\\$\\$/, '')];\n let closed = /\\$\\$\\s*$/.test(body[0]) && body[0].trim().length > 2;\n if (closed) body[0] = body[0].replace(/\\$\\$\\s*$/, '');\n if (!closed) for (i += 1; i < lines.length; i++) {\n if (/\\$\\$\\s*$/.test(lines[i])) {\n body.push(lines[i].replace(/\\$\\$\\s*$/, ''));\n closed = true;\n break;\n }\n body.push(lines[i]);\n }\n box.append(texBlock(body.join('\\n').trim(), 'Formula'));\n continue;\n }\n if (!line.trim()) {\n flush();\n list = null;\n continue;\n }\n const heading = /^\\s*(#{1,6})\\s+(.*?)\\s*#*\\s*$/.exec(line);\n if (heading) {\n flush();\n list = null;\n box.append(inline(el(`h${Math.min(6, heading[1].length + 2)}`, 'allen-md-h'), heading[2]));\n continue;\n }\n if (/^\\s*([-*_])(\\s*\\1){2,}\\s*$/.test(line)) {\n flush();\n list = null;\n box.append(el('hr', 'allen-md-hr'));\n continue;\n }\n if (/^\\s*\\|.*\\|\\s*$/.test(line) && i + 1 < lines.length && /^\\s*\\|?\\s*:?-+:?\\s*(\\|\\s*:?-+:?\\s*)*\\|?\\s*$/.test(lines[i + 1])) {\n flush();\n list = null;\n const table = el('table', 'allen-md-table');\n const head = el('tr');\n for (const c of cells(line)) head.append(inline(el('th'), c));\n const thead = el('thead');\n thead.append(head);\n const tbody = el('tbody');\n for (i += 2; i < lines.length && /^\\s*\\|.*\\|\\s*$/.test(lines[i]); i++) {\n const row = el('tr');\n for (const c of cells(lines[i])) row.append(inline(el('td'), c));\n tbody.append(row);\n }\n i -= 1;\n table.append(thead, tbody);\n const wrap = el('div', 'allen-pane-table');\n wrap.append(table);\n box.append(wrap);\n continue;\n }\n const quote = /^\\s*>\\s?(.*)$/.exec(line);\n if (quote) {\n flush();\n list = null;\n const parts = [quote[1]];\n while (i + 1 < lines.length && /^\\s*>/.test(lines[i + 1])) parts.push(lines[++i].replace(/^\\s*>\\s?/, ''));\n const block = el('blockquote', 'allen-md-quote');\n block.append(inline(el('p', 'allen-md-p'), parts.join(' ')));\n box.append(block);\n continue;\n }\n const item = /^\\s*([-*+]|\\d{1,9}[.)])\\s+(.*)$/.exec(line);\n if (item) {\n flush();\n const ordered = /\\d/.test(item[1]);\n if (!list || (list.localName === 'ol') !== ordered) {\n list = el(ordered ? 'ol' : 'ul', 'allen-md-list');\n box.append(list);\n }\n list.append(inline(el('li'), item[2]));\n continue;\n }\n if (list && /^\\s{2,}\\S/.test(line)) {\n inline(list.lastElementChild, ` ${line.trim()}`);\n continue;\n }\n list = null;\n para.push(line.trim());\n }\n flush();\n return box;\n }\n\n" + +note JavaScript svg +text js4 " /* Plots are drawn here from validated numbers; no SVG from the network is\n ever parsed. Colours are attributes so an exported file keeps them. */\n function svg(tag, attrs, text) {\n const node = document.createElementNS(SVG_NS, tag);\n for (const k of Object.keys(attrs)) node.setAttribute(k, String(attrs[k]));\n if (text !== undefined) node.textContent = text;\n return node;\n }\n function fmt(n) {\n const v = Number(n.toPrecision(5));\n return Object.is(v, -0) ? '0' : String(v);\n }\n function ticks(lo, hi) {\n const raw = (hi - lo) / 5;\n if (!Number.isFinite(raw) || raw <= 0) return [lo, hi];\n const mag = Math.pow(10, Math.floor(Math.log10(raw)));\n const unit = [1, 2, 5, 10].map(f => f * mag).find(s => s >= raw) || raw;\n const first = Math.ceil(lo / unit);\n const out = [];\n for (let n = 0; n < 12; n++) {\n const t = (first + n) * unit;\n if (t > hi + unit * 1e-9) break;\n out.push(t);\n }\n return out.length ? out : [lo, hi];\n }\n function extent(c) {\n let x0 = Infinity;\n let x1 = -Infinity;\n let y0 = Infinity;\n let y1 = -Infinity;\n for (const s of c.series) for (const p of s.points) {\n x0 = Math.min(x0, p[0]);\n x1 = Math.max(x1, p[0]);\n y0 = Math.min(y0, p[1]);\n y1 = Math.max(y1, p[1]);\n }\n if (x0 === x1) {\n x0 -= 1;\n x1 += 1;\n }\n if (y0 === y1) {\n y0 -= 1;\n y1 += 1;\n }\n return { x0, x1, y0, y1 };\n }\n function plot(c, title) {\n const W = 640;\n const H = 400;\n const L = 64;\n const R = 20;\n const T = 20;\n const B = 52;\n const e = extent(c);\n const sx = v => L + (v - e.x0) / (e.x1 - e.x0) * (W - L - R);\n const sy = v => H - B - (v - e.y0) / (e.y1 - e.y0) * (H - T - B);\n const titleId = uid('allen-plot-title');\n const descId = uid('allen-plot-desc');\n const root = svg('svg', { viewBox: `0 0 ${W} ${H}`, width: W, height: H, role: 'img', 'aria-labelledby': `${titleId} ${descId}`, class: 'allen-plot-svg' });\n const xl = c.x_label ? ` (${c.x_label})` : '';\n const yl = c.y_label ? ` (${c.y_label})` : '';\n root.append(svg('title', { id: titleId }, title), svg('desc', { id: descId }, `${c.series.length} series; x${xl} from ${fmt(e.x0)} to ${fmt(e.x1)}; y${yl} from ${fmt(e.y0)} to ${fmt(e.y1)}.`));\n const grid = svg('g', { stroke: '#1c2536', 'stroke-width': 1 });\n const labels = svg('g', { fill: '#94a3b8', 'font-size': 12, 'font-family': 'ui-sans-serif, system-ui, sans-serif' });\n for (const t of ticks(e.x0, e.x1)) {\n const x = sx(t).toFixed(2);\n grid.append(svg('line', { x1: x, y1: T, x2: x, y2: H - B }));\n labels.append(svg('text', { x, y: H - B + 18, 'text-anchor': 'middle' }, fmt(t)));\n }\n for (const t of ticks(e.y0, e.y1)) {\n const y = sy(t).toFixed(2);\n grid.append(svg('line', { x1: L, y1: y, x2: W - R, y2: y }));\n labels.append(svg('text', { x: L - 8, y: (Number(y) + 4).toFixed(2), 'text-anchor': 'end' }, fmt(t)));\n }\n const axes = svg('g', { stroke: '#3b4a63', 'stroke-width': 1 });\n axes.append(svg('line', { x1: L, y1: H - B, x2: W - R, y2: H - B }), svg('line', { x1: L, y1: T, x2: L, y2: H - B }));\n if (c.x_label) labels.append(svg('text', { x: (L + W - R) / 2, y: H - 12, 'text-anchor': 'middle' }, c.x_label));\n if (c.y_label) {\n const mid = (T + H - B) / 2;\n labels.append(svg('text', { x: 16, y: mid, 'text-anchor': 'middle', transform: `rotate(-90 16 ${mid})` }, c.y_label));\n }\n const lines = svg('g', { fill: 'none', 'stroke-width': 2, 'stroke-linejoin': 'round', 'stroke-linecap': 'round' });\n c.series.forEach((s, i) => {\n const colour = PALETTE[i % PALETTE.length];\n const group = svg('g', { stroke: colour });\n group.append(svg('title', {}, s.label || `Series ${i + 1}`));\n if (s.points.length > 1) group.append(svg('polyline', { points: s.points.map(p => `${sx(p[0]).toFixed(2)},${sy(p[1]).toFixed(2)}`).join(' ') }));\n if (s.points.length <= 64) for (const p of s.points) group.append(svg('circle', { cx: sx(p[0]).toFixed(2), cy: sy(p[1]).toFixed(2), r: 3, fill: colour, stroke: 'none' }));\n lines.append(group);\n });\n root.append(grid, axes, lines, labels);\n const figure = el('figure', 'allen-plot');\n figure.append(root);\n const legend = el('ul', 'allen-plot-legend');\n c.series.forEach((s, i) => {\n const item = el('li', 'allen-plot-key');\n const swatch = el('span', 'allen-plot-swatch');\n swatch.style.background = PALETTE[i % PALETTE.length];\n swatch.setAttribute('aria-hidden', 'true');\n item.append(swatch, document.createTextNode(`${s.label || `Series ${i + 1}`}, ${s.points.length} point${s.points.length === 1 ? '' : 's'}`));\n legend.append(item);\n });\n figure.append(legend);\n const data = el('details', 'allen-plot-data');\n data.append(el('summary', 'allen-pane-summary', 'Plot data as a table'));\n data.addEventListener('toggle', () => {\n if (!data.open || data.dataset.built) return;\n data.dataset.built = 'yes';\n data.append(table(['Series', c.x_label || 'x', c.y_label || 'y'], c.series.flatMap((s, i) => s.points.map(p => [s.label || `Series ${i + 1}`, String(p[0]), String(p[1])]))));\n });\n figure.append(data);\n return { figure, svg: root };\n }\n function table(columns, rows) {\n const wrap = el('div', 'allen-pane-table');\n wrap.tabIndex = 0;\n const node = el('table', 'allen-data');\n const head = el('tr');\n for (const c of columns) {\n const th = el('th', '', c);\n th.scope = 'col';\n head.append(th);\n }\n const thead = el('thead');\n thead.append(head);\n const tbody = el('tbody');\n for (const r of rows) {\n const tr = el('tr');\n for (let i = 0; i < Math.max(r.length, columns.length); i++) tr.append(el('td', '', i < r.length ? r[i] : ''));\n tbody.append(tr);\n }\n node.append(thead, tbody);\n wrap.append(node);\n return wrap;\n }\n\n" + +note JavaScript csv +text js5 " /* Files. Every download is application/octet-stream, so no browser renders\n a generated file in this origin. */\n function csv(columns, rows) {\n const cell = v => {\n let s = String(v);\n if (/^[=+@\\t\\r]/.test(s) || /^-(?![\\d.])/.test(s)) s = `'${s}`;\n return /[\",\\r\\n]/.test(s) ? `\"${s.replace(/\"/g, '\"\"')}\"` : s;\n };\n return `${[columns, ...rows].map(r => r.map(cell).join(',')).join('\\r\\n')}\\r\\n`;\n }\n function refText(items) {\n return items.map((r, i) => `${i + 1}. [${r.title}](${r.url})`).join('\\n');\n }\n function artefact(rec) {\n const c = rec.content;\n const base = slug(rec.title) || rec.kind;\n switch (rec.kind) {\n case 'math': {\n const text = own(c, 'tex') ? `${c.text}\\n\\nTeX source:\\n${c.tex}\\n` : `${c.text}\\n`;\n return { name: `${base}.txt`, what: 'result', data: () => text, copy: c.text };\n }\n case 'plot': {\n const rows = c.series.flatMap((s, i) => s.points.map(p => [s.label || `Series ${i + 1}`, String(p[0]), String(p[1])]));\n return { name: `${base}.svg`, what: 'data as CSV', data: () => `\\n${new XMLSerializer().serializeToString(rec.svg)}\\n`, copy: csv(['series', c.x_label || 'x', c.y_label || 'y'], rows) };\n }\n case 'doc': {\n const text = c.citations.length ? `${c.markdown}\\n\\n## Citations\\n\\n${refText(c.citations)}\\n` : `${c.markdown}\\n`;\n return { name: `${base}.md`, what: 'Markdown', data: () => text, copy: text };\n }\n case 'code':\n case 'omega': {\n const ext = rec.kind === 'omega' ? 'om' : EXT[c.language.toLowerCase()] || 'txt';\n return { name: `${base}.${ext}`, what: 'source', data: () => c.source, copy: c.source };\n }\n case 'app':\n return { name: `${base}.html`, what: 'HTML', data: () => c.html, copy: c.html };\n case 'research': {\n const parts = [`# ${rec.title}`, '## Notes', c.notes];\n if (c.hypotheses.length) parts.push('## Hypotheses', c.hypotheses.map(h => `- ${h}`).join('\\n'));\n if (c.derivations.length) parts.push('## Derivations', c.derivations.map(d => `\\`\\`\\`\\n${d}\\n\\`\\`\\``).join('\\n\\n'));\n if (c.sources.length) parts.push('## Sources', refText(c.sources));\n const text = `${parts.join('\\n\\n')}\\n`;\n return { name: `${base}.md`, what: 'Markdown', data: () => text, copy: text };\n }\n case 'data': {\n const text = csv(c.columns, c.rows);\n return { name: `${base}.csv`, what: 'CSV', data: () => text, copy: text };\n }\n default:\n return null;\n }\n }\n function wasmBytes(text) {\n try {\n const bin = atob(text.replace(/\\s+/g, ''));\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out.length >= 8 && out[0] === 0 && out[1] === 97 && out[2] === 115 && out[3] === 109 ? out : null;\n } catch (_) {\n return null;\n }\n }\n async function copyText(source, node) {\n if (node.dataset.label === undefined) node.dataset.label = node.textContent;\n try {\n await navigator.clipboard.writeText(source);\n node.textContent = 'Copied';\n } catch (_) {\n node.textContent = 'Copy blocked';\n }\n setTimeout(() => {\n node.textContent = node.dataset.label;\n }, 1500);\n }\n /* The policy becomes the first element of the program's head, as in the\n chat client: after an existing head tag, else in a head of its own. The\n prefix (doctype, comments, html tag) is skipped one sticky token at a\n time and a comment body never holds its closing marker, so the scan is\n linear in the source. */\n function sandboxed(source) {\n const meta = ``;\n const prefix = /\\s*(?:]*>||]*)?>)/iy;\n let at = 0;\n while (prefix.exec(source)) at = prefix.lastIndex;\n const head = /\\s*]*)?>/iy;\n head.lastIndex = at;\n if (head.exec(source)) return source.slice(0, head.lastIndex) + meta + source.slice(head.lastIndex);\n const lead = /^\\s*(?:]*>\\s*)?(?:]*)?>)?/i.exec(source)[0];\n return `${lead}${meta}${source.slice(lead.length)}`;\n }\n\n" + +note JavaScript checkEntry +text js6 " /* Project files and IndexedDB records share one format. */\n function checkEntry(p) {\n if (!shape(p, ['id', 'kind', 'title', 'revision', 'content', 'provenance'], ['geom', 'minimized'])) return 'unexpected or missing fields';\n let reason = check('pane.open', { v: VERSION, id: p.id, kind: p.kind, title: p.title });\n if (!reason) reason = check('pane.update', { v: VERSION, id: p.id, revision: p.revision, content: p.content, provenance: p.provenance }, p.kind);\n if (reason) return reason;\n if (own(p, 'geom') && !(shape(p.geom, ['x', 'y', 'w', 'h']) && ['x', 'y', 'w', 'h'].every(k => finite(p.geom[k])))) return 'invalid geometry';\n if (own(p, 'minimized') && typeof p.minimized !== 'boolean') return 'invalid minimized flag';\n return '';\n }\n function checkFile(data) {\n if (!shape(data, ['format', 'v', 'panes'], ['id', 'name', 'saved', 'exported']) || data.format !== FORMAT || data.v !== VERSION) return 'this is not an Aien panes file';\n for (const k of ['id', 'name', 'saved', 'exported']) if (own(data, k) && !isText(data[k], MAX_TITLE)) return `invalid ${k}`;\n if (!Array.isArray(data.panes) || data.panes.length > MAX_PANES) return `a file holds at most ${MAX_PANES} panes`;\n for (let i = 0; i < data.panes.length; i++) {\n const reason = checkEntry(data.panes[i]);\n if (reason) return `pane ${i + 1}: ${reason}`;\n }\n return '';\n }\n function limit(message) {\n const error = new Error(message);\n error.name = 'AllenLimit';\n return error;\n }\n function storageError(error) {\n const name = error && error.name;\n if (name === 'AllenLimit') return error.message;\n if (name === 'QuotaExceededError') return 'This browser refused: it has no storage space left for this site. Export the panes as a file instead.';\n if (name === 'SecurityError' || name === 'InvalidStateError' || name === 'AllenNoStore') return 'This browser does not allow storage here, for example in private browsing. Export the panes as a file instead.';\n const detail = error && error.message ? ` (${clean(error.message, 160)})` : '';\n return `This browser refused to store the project${detail}. Export the panes as a file instead.`;\n }\n function openDb() {\n return new Promise((resolve, reject) => {\n let request;\n try {\n if (!window.indexedDB) throw Object.assign(new Error('no IndexedDB'), { name: 'AllenNoStore' });\n request = window.indexedDB.open(DB_NAME, 1);\n } catch (error) {\n reject(error);\n return;\n }\n request.onupgradeneeded = () => {\n const db = request.result;\n if (!db.objectStoreNames.contains(DB_PROJECTS)) db.createObjectStore(DB_PROJECTS, { keyPath: 'id' });\n if (!db.objectStoreNames.contains(DB_INDEX)) db.createObjectStore(DB_INDEX, { keyPath: 'id' });\n };\n request.onsuccess = () => {\n const db = request.result;\n db.onversionchange = () => db.close();\n resolve(db);\n };\n request.onerror = () => reject(request.error || new Error('IndexedDB refused'));\n request.onblocked = () => reject(new Error('another tab holds the project store open'));\n });\n }\n function ask(request) {\n return new Promise((resolve, reject) => {\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error);\n });\n }\n async function store(mode, work) {\n const db = await openDb();\n try {\n const tx = db.transaction([DB_PROJECTS, DB_INDEX], mode);\n const done = new Promise((resolve, reject) => {\n tx.oncomplete = () => resolve();\n tx.onabort = () => reject(tx.error || new Error('the storage transaction was aborted'));\n });\n let value;\n try {\n value = await work(tx.objectStore(DB_PROJECTS), tx.objectStore(DB_INDEX));\n } catch (error) {\n try {\n tx.abort();\n } catch (_) {}\n await done.catch(() => {});\n throw error;\n }\n await done;\n return value;\n } finally {\n db.close();\n }\n }\n function stamp(iso) {\n const when = new Date(iso);\n return Number.isNaN(when.getTime()) ? String(iso) : when.toLocaleString();\n }\n\n" + +note JavaScript mount +text js7 " function mount(host, options) {\n if (!(host instanceof Element)) throw new TypeError('AllenPanes.mount needs an element');\n const opts = options && typeof options === 'object' ? options : {};\n const panes = new Map();\n const closedIds = new Set();\n const closed = [];\n let order = [];\n let cascade = 0;\n let current = null;\n let alive = true;\n let fitting = 0;\n const root = el('div', 'allen-panes');\n const layer = el('div', 'allen-panes-layer');\n const dock = el('nav', 'allen-panes-dock');\n dock.setAttribute('aria-label', 'Aien panes');\n const chips = el('ul', 'allen-panes-chips');\n const projectsButton = button('allen-panes-tool', 'Projects: save, open, export or import panes', 'Projects', () => projectsPane());\n const exportButton = button('allen-panes-tool', 'Export the open panes as a JSON file', 'Export', () => exportOpen());\n const reopenButton = button('allen-panes-tool', '', 'Reopen', () => reopen());\n reopenButton.hidden = true;\n dock.append(chips, projectsButton, exportButton, reopenButton);\n const live = el('p', 'allen-panes-live');\n live.setAttribute('role', 'status');\n live.setAttribute('aria-live', 'polite');\n root.append(layer, dock, live);\n host.append(root);\n const media = typeof window.matchMedia === 'function' ? window.matchMedia(SHEET) : null;\n\n function say(message) {\n live.textContent = '';\n setTimeout(() => {\n if (alive) live.textContent = message;\n }, 60);\n if (typeof opts.announce === 'function') {\n try {\n opts.announce(message);\n } catch (_) {}\n }\n }\n function refuse(name, reason) {\n if (typeof opts.onRefuse === 'function') {\n try {\n opts.onRefuse(name, reason);\n } catch (_) {}\n }\n return { ok: false, reason };\n }\n function sheet() {\n return root.dataset.layout === 'sheet';\n }\n function layout() {\n root.dataset.layout = media && media.matches ? 'sheet' : 'float';\n refit();\n }\n function bounds() {\n return { w: Math.max(root.clientWidth, MIN_W), h: Math.max(root.clientHeight, MIN_H) };\n }\n function place(rec, x, y, w, h) {\n const b = bounds();\n const nw = Math.round(Math.min(Math.max(w, MIN_W), b.w));\n const nh = Math.round(Math.min(Math.max(h, MIN_H), b.h));\n const nx = Math.round(Math.min(Math.max(x, 0), b.w - nw));\n const ny = Math.round(Math.min(Math.max(y, 0), b.h - nh));\n rec.geom = { x: nx, y: ny, w: nw, h: nh };\n rec.el.style.transform = `translate(${nx}px, ${ny}px)`;\n rec.el.style.width = `${nw}px`;\n rec.el.style.height = `${nh}px`;\n }\n function refit() {\n for (const rec of panes.values()) place(rec, rec.geom.x, rec.geom.y, rec.geom.w, rec.geom.h);\n }\n function onResize() {\n if (!fitting) fitting = requestAnimationFrame(() => {\n fitting = 0;\n if (alive) refit();\n });\n }\n function initial(rec) {\n const b = bounds();\n const w = Math.min(560, b.w - 32);\n const h = Math.min(460, b.h - 160);\n const step = (cascade % 6) * 28;\n cascade += 1;\n place(rec, b.w - w - 32 - step, 76 + step, w, h);\n }\n function topmost() {\n for (let i = order.length - 1; i >= 0; i--) if (!order[i].minimized) return order[i];\n return null;\n }\n function chipState(rec) {\n rec.chipTitle.textContent = rec.title;\n rec.chip.setAttribute('aria-label', `${rec.title}, ${NAMES[rec.kind]} pane, ${rec.minimized ? 'minimized' : 'open'}`);\n rec.chip.dataset.state = rec.minimized ? 'minimized' : 'open';\n }\n function stack() {\n const top = topmost();\n order.forEach((rec, i) => {\n rec.el.style.zIndex = String(i + 1);\n rec.el.toggleAttribute('data-top', rec === top);\n rec.chip.toggleAttribute('data-top', rec === top);\n });\n dock.dataset.empty = panes.size ? 'no' : 'yes';\n }\n function raise(rec) {\n if (order[order.length - 1] !== rec) {\n order = order.filter(r => r !== rec);\n order.push(rec);\n }\n stack();\n }\n function owner(node) {\n for (const rec of panes.values()) if (rec.el.contains(node)) return rec;\n return null;\n }\n function label(rec) {\n rec.heading.textContent = rec.title;\n rec.move.setAttribute('aria-label', `Move ${rec.title}. Drag, or use the arrow keys; Shift moves farther.`);\n rec.size.setAttribute('aria-label', `Resize ${rec.title}. Drag, or use the arrow keys; Shift resizes farther.`);\n rec.min.setAttribute('aria-label', `Minimize ${rec.title}`);\n rec.max.setAttribute('aria-label', `Maximize ${rec.title}`);\n rec.max.setAttribute('aria-pressed', String(rec.maximized));\n rec.shut.setAttribute('aria-label', `Close ${rec.title}`);\n rec.grab.setAttribute('aria-label', `Minimize ${rec.title}. On a touch screen, swipe the top of the sheet down to minimize, or sideways for the next pane.`);\n chipState(rec);\n }\n function create(key, kind, title) {\n const rec = { id: key, kind, title: clean(title, MAX_TITLE) || NAMES[kind], revision: 0, content: null, provenance: null, geom: null, minimized: false, maximized: false, svg: null, app: null, projects: null };\n const pane = el('section', 'allen-pane');\n pane.dataset.kind = kind;\n pane.tabIndex = -1;\n pane.setAttribute('role', 'region');\n pane.setAttribute('aria-roledescription', 'pane');\n const head = el('header', 'allen-pane-head');\n const heading = el('h2', 'allen-pane-title');\n heading.id = uid('allen-pane-title');\n pane.setAttribute('aria-labelledby', heading.id);\n const move = button('allen-pane-move', '', '', null);\n const badge = el('span', 'allen-pane-badge');\n badge.hidden = true;\n const controls = el('div', 'allen-pane-controls');\n const min = button('allen-pane-ctl allen-pane-min', '', '\\u2212', () => minimize(rec));\n const max = button('allen-pane-ctl allen-pane-max', '', '\\u25a1', () => maximize(rec));\n const shut = button('allen-pane-ctl allen-pane-close', '', '\\u00d7', () => close(rec, true));\n controls.append(min, max, shut);\n head.append(move, el('span', 'allen-pane-kind', NAMES[kind]), heading, badge, controls);\n const notice = el('p', 'allen-pane-notice');\n notice.setAttribute('role', 'alert');\n notice.hidden = true;\n const body = el('div', 'allen-pane-body');\n body.tabIndex = 0;\n const source = el('details', 'allen-pane-source');\n source.hidden = true;\n const foot = el('div', 'allen-pane-foot');\n foot.hidden = true;\n const size = button('allen-pane-size', '', '', null);\n const grab = button('allen-pane-grab', '', '', () => minimize(rec));\n pane.append(grab, head, notice, body, source, foot, size);\n const item = el('li', 'allen-panes-item');\n const chip = button('allen-panes-chip', '', '', () => chipClick(rec));\n const chipTitle = el('span', 'allen-panes-chip-title');\n chip.append(el('span', 'allen-panes-chip-kind', NAMES[kind]), chipTitle);\n item.append(chip);\n Object.assign(rec, { el: pane, heading, badge, notice, body, source, foot, move, size, grab, min, max, shut, item, chip, chipTitle, swallow: 0 });\n label(rec);\n pane.addEventListener('pointerdown', () => raise(rec), true);\n pane.addEventListener('focusin', () => raise(rec));\n drag(rec, head, 'move');\n swipe(rec, head);\n swipe(rec, grab);\n pane.addEventListener('click', event => {\n if (event.timeStamp > rec.swallow) return;\n rec.swallow = 0;\n event.preventDefault();\n event.stopPropagation();\n }, true);\n drag(rec, size, 'size');\n keyed(rec, move, 'move');\n keyed(rec, size, 'size');\n layer.append(pane);\n chips.append(item);\n panes.set(key, rec);\n order.push(rec);\n initial(rec);\n stack();\n return rec;\n }\n /* Bottom sheet gestures, only on the grab strip and the title bar, so the\n content keeps its own scrolling, selection and editing. Down past a\n quarter of the sheet (or a quick flick) minimizes; sideways shows the\n neighbouring pane. A swipe never reaches the button it started on. */\n function swipe(rec, zone) {\n zone.addEventListener('pointerdown', event => {\n if (!sheet() || !event.isPrimary || event.button !== 0) return;\n const start = { x: event.clientX, y: event.clientY, t: event.timeStamp };\n const height = Math.max(1, rec.el.getBoundingClientRect().height);\n let mode = '';\n let last = event;\n let frame = 0;\n const paint = () => {\n frame = 0;\n if (!alive || !mode) return;\n const dx = last.clientX - start.x;\n const dy = last.clientY - start.y;\n rec.el.style.setProperty('--allen-pane-swipe-x', mode === 'side' ? `${Math.round(dx / 2)}px` : '0px');\n rec.el.style.setProperty('--allen-pane-swipe-y', mode === 'down' ? `${Math.round(Math.max(0, dy))}px` : '0px');\n };\n const settle = () => {\n rec.el.classList.remove('is-swiping');\n rec.el.style.removeProperty('--allen-pane-swipe-x');\n rec.el.style.removeProperty('--allen-pane-swipe-y');\n };\n const onMove = e => {\n if (e.pointerId !== event.pointerId) return;\n last = e;\n const dx = e.clientX - start.x;\n const dy = e.clientY - start.y;\n if (!mode) {\n if (Math.abs(dx) < 10 && Math.abs(dy) < 10) return;\n mode = Math.abs(dy) >= Math.abs(dx) ? (dy > 0 ? 'down' : 'up') : 'side';\n try {\n zone.setPointerCapture(e.pointerId);\n } catch (_) {}\n rec.el.classList.add('is-swiping');\n }\n if (mode !== 'up' && !frame) frame = requestAnimationFrame(paint);\n };\n const onEnd = e => {\n if (e.pointerId !== event.pointerId) return;\n zone.removeEventListener('pointermove', onMove);\n zone.removeEventListener('pointerup', onEnd);\n zone.removeEventListener('pointercancel', onEnd);\n if (frame) cancelAnimationFrame(frame);\n frame = 0;\n settle();\n if (!mode) return;\n rec.swallow = e.timeStamp + 500;\n if (e.type === 'pointercancel' || !alive) return;\n const dx = e.clientX - start.x;\n const dy = e.clientY - start.y;\n const speed = Math.max(Math.abs(dx), Math.abs(dy)) / Math.max(1, e.timeStamp - start.t);\n if (mode === 'down' && (dy > height / 4 || (dy > 24 && speed > 0.6))) minimize(rec);\n else if (mode === 'side' && (Math.abs(dx) > 72 || (Math.abs(dx) > 24 && speed > 0.6))) neighbour(rec, dx < 0 ? 1 : -1);\n };\n zone.addEventListener('pointermove', onMove);\n zone.addEventListener('pointerup', onEnd);\n zone.addEventListener('pointercancel', onEnd);\n });\n }\n function neighbour(rec, dir) {\n const all = [...panes.values()];\n if (all.length < 2) return;\n const next = all[(all.indexOf(rec) + dir + all.length) % all.length];\n const had = rec.el.contains(document.activeElement);\n restore(next, had);\n say(`${next.title}, pane ${all.indexOf(next) + 1} of ${all.length}.`);\n }\n function drag(rec, handle, mode) {\n handle.addEventListener('pointerdown', event => {\n if (event.button !== 0 || sheet() || rec.maximized) return;\n const hit = event.target.closest('button');\n if (mode === 'move' && hit && hit !== rec.move) return;\n event.preventDefault();\n raise(rec);\n const start = { x: event.clientX, y: event.clientY, g: { ...rec.geom } };\n let frame = 0;\n let last = null;\n try {\n handle.setPointerCapture(event.pointerId);\n } catch (_) {}\n rec.el.classList.add(mode === 'move' ? 'is-moving' : 'is-sizing');\n const apply = () => {\n frame = 0;\n if (!last || !alive) return;\n const dx = last.clientX - start.x;\n const dy = last.clientY - start.y;\n if (mode === 'move') place(rec, start.g.x + dx, start.g.y + dy, start.g.w, start.g.h);\n else place(rec, start.g.x, start.g.y, start.g.w + dx, start.g.h + dy);\n };\n const onMove = e => {\n if (e.pointerId !== event.pointerId) return;\n last = e;\n if (!frame) frame = requestAnimationFrame(apply);\n };\n const onUp = e => {\n if (e.pointerId !== event.pointerId) return;\n handle.removeEventListener('pointermove', onMove);\n handle.removeEventListener('pointerup', onUp);\n handle.removeEventListener('pointercancel', onUp);\n if (frame) cancelAnimationFrame(frame);\n apply();\n rec.el.classList.remove('is-moving', 'is-sizing');\n };\n handle.addEventListener('pointermove', onMove);\n handle.addEventListener('pointerup', onUp);\n handle.addEventListener('pointercancel', onUp);\n });\n }\n function keyed(rec, handle, mode) {\n handle.addEventListener('keydown', event => {\n const d = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n if (!d || event.altKey || event.ctrlKey || event.metaKey || sheet() || rec.maximized) return;\n event.preventDefault();\n const s = event.shiftKey ? BIG_STEP : STEP;\n const g = rec.geom;\n if (mode === 'move') place(rec, g.x + d[0] * s, g.y + d[1] * s, g.w, g.h);\n else place(rec, g.x, g.y, g.w + d[0] * s, g.h + d[1] * s);\n });\n handle.addEventListener('keyup', event => {\n if (!event.key.startsWith('Arrow') || sheet() || rec.maximized) return;\n const g = rec.geom;\n say(mode === 'move' ? `${rec.title} at ${g.x}, ${g.y}.` : `${rec.title} is ${g.w} by ${g.h}.`);\n });\n }\n function minimize(rec) {\n if (rec.minimized) return;\n const had = rec.el.contains(document.activeElement);\n rec.minimized = true;\n rec.el.hidden = true;\n chipState(rec);\n stack();\n if (had) rec.chip.focus();\n say(`${rec.title} minimized; it stays in the pane list.`);\n }\n function restore(rec, focus) {\n if (rec.minimized) {\n rec.minimized = false;\n rec.el.hidden = false;\n chipState(rec);\n }\n raise(rec);\n if (focus) rec.el.focus({ preventScroll: true });\n }\n function maximize(rec) {\n rec.maximized = !rec.maximized;\n rec.el.classList.toggle('is-max', rec.maximized);\n label(rec);\n raise(rec);\n }\n function chipClick(rec) {\n if (rec.minimized) restore(rec, true);\n else if (topmost() === rec) minimize(rec);\n else restore(rec, true);\n }\n function dataPane(rec) {\n return KINDS.includes(rec.kind) && rec.revision > 0;\n }\n function entry(rec) {\n return { id: rec.id, kind: rec.kind, title: rec.title, revision: rec.revision, content: copy(rec.content), provenance: copy(rec.provenance), geom: { ...rec.geom }, minimized: rec.minimized };\n }\n function reopenState() {\n const last = closed[closed.length - 1];\n reopenButton.hidden = !last;\n if (last) reopenButton.setAttribute('aria-label', `Reopen ${last.title}`);\n }\n function close(rec, byPerson, quiet) {\n if (panes.get(rec.id) !== rec) return;\n const had = rec.el.contains(document.activeElement);\n stopApp(rec);\n rec.el.remove();\n rec.item.remove();\n panes.delete(rec.id);\n order = order.filter(r => r !== rec);\n const kept = dataPane(rec);\n if (kept) {\n closed.push(entry(rec));\n while (closed.length > MAX_CLOSED) closed.shift();\n }\n reopenState();\n stack();\n if (had) {\n const next = topmost();\n if (next) next.el.focus({ preventScroll: true });\n else if (opts.returnFocus instanceof HTMLElement && opts.returnFocus.isConnected) opts.returnFocus.focus();\n else projectsButton.focus();\n }\n if (!quiet) say(byPerson ? `${rec.title} closed.${kept ? ' Reopen brings it back.' : ''}` : `Aien closed ${rec.title}.`);\n if (typeof opts.onClose === 'function') {\n try {\n opts.onClose(rec.kind === 'card' ? rec.id.slice(5) : rec.id, rec.kind, byPerson);\n } catch (_) {}\n }\n }\n function reopen() {\n const last = closed.pop();\n reopenState();\n if (!last) return;\n const rec = restoreEntry(last);\n if (rec) {\n rec.el.focus({ preventScroll: true });\n say(`${rec.title} reopened.`);\n } else {\n closed.push(last);\n reopenState();\n say(`At most ${MAX_PANES} panes can be open. Close one to make room.`);\n }\n }\n function notify(rec, message) {\n rec.notice.textContent = message;\n rec.notice.hidden = false;\n }\n function waiting(rec) {\n rec.el.setAttribute('aria-busy', 'true');\n rec.body.replaceChildren(el('p', 'allen-pane-note', 'Aien is preparing this pane.'));\n }\n\n" + +note JavaScript apply +text js8 " function apply(rec, revision, content, prov) {\n stopApp(rec);\n rec.revision = revision;\n rec.content = copy(content);\n rec.provenance = copy(prov);\n rec.svg = null;\n rec.notice.hidden = true;\n rec.el.removeAttribute('aria-busy');\n rec.body.replaceChildren();\n render(rec);\n rec.badge.textContent = STATUS_NAMES[rec.provenance.status];\n rec.badge.dataset.status = rec.provenance.status;\n rec.badge.hidden = false;\n sourceBlock(rec);\n footBlock(rec);\n }\n function section(heading) {\n const box = el('section', 'allen-pane-section');\n box.append(el('h3', 'allen-pane-h3', heading));\n return box;\n }\n function refList(heading, items) {\n const box = section(heading);\n const list = el('ol', 'allen-pane-refs');\n for (const r of items) {\n const li = el('li');\n li.append(link(r.title, r.url));\n list.append(li);\n }\n box.append(list, el('p', 'allen-pane-label', 'Links are shown as given; this page never fetched or checked them.'));\n return box;\n }\n /* A diff or patch fence gets its own Copy and Download patch. The patch\n is only ever a downloaded file; nothing here applies it. */\n function patchTool(rec) {\n let n = 0;\n return (lang, text) => {\n if (!/^(diff|patch)$/i.test(lang) || !text.trim()) return null;\n n += 1;\n const name = `${slug(rec.title) || 'allen'}${n > 1 ? `-${n}` : ''}.patch`;\n const bar = el('div', 'allen-pane-bar allen-md-tools');\n const copyButton = button('allen-pane-act', `Copy patch ${n} of ${rec.title}`, 'Copy patch', () => copyText(`${text}\\n`, copyButton));\n bar.append(copyButton, button('allen-pane-act', `Download patch ${n} of ${rec.title} as ${name}; it is not applied anywhere`, 'Download patch', () => download(name, `${text}\\n`)));\n return bar;\n };\n }\n function render(rec) {\n const c = rec.content;\n const body = rec.body;\n body.append(el('p', 'allen-pane-caveat', CAVEATS[rec.provenance.status]));\n if (rec.kind === 'math') {\n const result = el('p', 'allen-pane-math', c.text);\n result.setAttribute('aria-label', `Result: ${c.text}`);\n body.append(result);\n if (own(c, 'tex')) body.append(texBlock(c.tex, 'The engine\\u2019s formula'));\n } else if (rec.kind === 'plot') {\n const drawn = plot(c, rec.title);\n rec.svg = drawn.svg;\n body.append(drawn.figure);\n } else if (rec.kind === 'doc') {\n body.append(markdown(c.markdown, el('div', 'allen-md'), patchTool(rec)));\n if (c.citations.length) body.append(refList('Citations', c.citations));\n } else if (rec.kind === 'code' || rec.kind === 'omega') {\n body.append(el('p', 'allen-pane-label', rec.kind === 'omega' ? 'Omega source' : `${clean(c.language, 40) || 'Code'} source`));\n const pre = el('pre', 'allen-pane-code');\n pre.append(el('code', '', c.source));\n body.append(pre);\n if (own(c, 'functions') && c.functions.length) {\n const box = section('Functions');\n const list = el('ul', 'allen-pane-fns');\n for (const f of c.functions) list.append(el('li', 'allen-pane-mono', `${f.name}(${f.params.map(p => `${p.name} ${p.type}`).join(', ')}) to ${f.ret}`));\n box.append(list);\n body.append(box);\n }\n if (own(c, 'wasm')) {\n const bytes = wasmBytes(c.wasm);\n const box = section('WebAssembly');\n if (bytes) {\n box.append(el('p', 'allen-pane-note', `${bytes.length} bytes. Offered as a file only; this page does not run it.`), button('allen-pane-act', `Download the WebAssembly of ${rec.title}`, 'Download .wasm', () => download(`${slug(rec.title) || 'omega'}.wasm`, bytes)));\n } else {\n box.append(el('p', 'allen-pane-note', 'WebAssembly was attached, but it is not a valid base64 WebAssembly module.'));\n }\n body.append(box);\n }\n } else if (rec.kind === 'app') {\n body.append(el('p', 'allen-pane-note', 'Aien wrote this app. It runs only when you press Run, in a sandbox with no access to this page, your cookies or the network.'));\n const bar = el('div', 'allen-pane-bar');\n const stage = el('div', 'allen-pane-stage');\n const run = button('allen-pane-act allen-pane-run', `Run ${rec.title} in a sandbox`, 'Run', () => runApp(rec, stage, run, stop));\n const stop = button('allen-pane-act', `Stop ${rec.title}`, 'Stop', () => stopApp(rec));\n stop.hidden = true;\n bar.append(run, stop);\n body.append(bar, stage);\n rec.app = { frame: null, run, stop };\n } else if (rec.kind === 'research') {\n const notes = section('Notes');\n notes.append(markdown(c.notes, el('div', 'allen-md'), patchTool(rec)));\n body.append(notes);\n if (c.hypotheses.length) {\n const box = section('Hypotheses');\n const list = el('ul', 'allen-md-list');\n for (const h of c.hypotheses) list.append(inline(el('li'), h));\n box.append(list);\n body.append(box);\n }\n if (c.derivations.length) {\n const box = section('Derivations');\n const list = el('ol', 'allen-pane-derivations');\n for (const d of c.derivations) {\n const li = el('li');\n li.append(el('pre', 'allen-pane-pre', d));\n list.append(li);\n }\n box.append(list);\n body.append(box);\n }\n if (c.sources.length) body.append(refList('Sources', c.sources));\n } else if (rec.kind === 'data') {\n const grid = table(c.columns, c.rows);\n grid.firstChild.setAttribute('aria-labelledby', rec.heading.id);\n body.append(grid);\n }\n }\n function runApp(rec, stage, run, stop) {\n stopApp(rec);\n const frame = document.createElement('iframe');\n frame.setAttribute('sandbox', SANDBOX);\n frame.setAttribute('referrerpolicy', 'no-referrer');\n frame.setAttribute('allow', \"camera 'none'; microphone 'none'; geolocation 'none'; usb 'none'; serial 'none'; bluetooth 'none'; payment 'none'; display-capture 'none'; clipboard-read 'none'; clipboard-write 'none'; fullscreen 'none'\");\n frame.setAttribute('title', `${rec.title}, an app written by Aien, sandboxed`);\n frame.className = 'allen-pane-frame';\n frame.srcdoc = sandboxed(rec.content.html);\n stage.replaceChildren(frame);\n rec.app = { frame, run, stop };\n run.hidden = true;\n stop.hidden = false;\n stop.focus();\n }\n function stopApp(rec) {\n if (!rec.app || !rec.app.frame) return;\n const hadFocus = rec.el.contains(document.activeElement);\n rec.app.frame.remove();\n rec.app.frame = null;\n rec.app.run.hidden = false;\n rec.app.stop.hidden = true;\n if (hadFocus && rec.app.run.isConnected) rec.app.run.focus();\n }\n function sourceBlock(rec) {\n const list = el('dl', 'allen-pane-prov');\n const row = (key, value, mono) => {\n if (value === '') return;\n list.append(el('dt', '', key), el('dd', mono ? 'allen-pane-mono' : '', value));\n };\n const p = rec.provenance;\n row('Status', STATUS_NAMES[p.status]);\n row('Engine', p.engine);\n row('Expression', p.expression, true);\n row('Result', p.result, true);\n row('Source', p.source);\n row('Commit', p.commit, true);\n row('Pane', rec.id, true);\n row('Revision', String(rec.revision));\n const raw = el('pre', 'allen-pane-raw', JSON.stringify({ content: rec.content, provenance: rec.provenance }, null, 2));\n raw.setAttribute('aria-label', `Everything Aien sent for ${rec.title}, as JSON`);\n raw.tabIndex = 0;\n rec.source.replaceChildren(el('summary', 'allen-pane-summary', 'Source and provenance'), list, el('p', 'allen-pane-label', 'As received'), raw);\n rec.source.hidden = false;\n }\n function footBlock(rec) {\n const out = artefact(rec);\n if (!out) return;\n const base = slug(rec.title) || rec.kind;\n const ext = out.name.slice(out.name.lastIndexOf('.'));\n const copyButton = button('allen-pane-act', `Copy the ${out.what} of ${rec.title}`, 'Copy', () => copyText(out.copy, copyButton));\n const save = button('allen-pane-act', `Download ${rec.title} as ${ext}`, `Download ${ext}`, () => download(out.name, out.data()));\n const json = button('allen-pane-act', `Download ${rec.title} with its provenance as JSON`, 'Download .json', () => download(`${base}.json`, JSON.stringify(file([entry(rec)], rec.title), null, 2)));\n rec.foot.replaceChildren(copyButton, save, json);\n const keep = reportSave(rec);\n if (keep) rec.foot.append(...keep);\n rec.foot.hidden = false;\n }\n /* A repo report can become the visitor's own Omega project, only when the\n page supplies saveProject and only after the visitor has seen the file\n list and pressed Save. The page owns the request and the visitor's\n handle; this file never touches the network. */\n function reportSave(rec) {\n if (rec.kind !== 'doc' || typeof opts.saveProject !== 'function') return null;\n const named = REPORT.exec(rec.title);\n if (!named) return null;\n const files = reportFiles(rec.content.markdown);\n const repo = `${named[1]}/${named[2]}`;\n const ports = files.filter(f => f.path.endsWith('.om')).length;\n const box = el('div', 'allen-pane-save');\n box.hidden = true;\n const state = el('p', 'allen-projects-state');\n state.setAttribute('role', 'status');\n const open = button('allen-pane-act allen-pane-run', `Save ${rec.title} to my Omega projects`, 'Save to my Omega projects', () => {\n box.hidden = !box.hidden;\n open.setAttribute('aria-expanded', String(!box.hidden));\n if (!box.hidden) confirm.focus();\n });\n open.setAttribute('aria-expanded', 'false');\n const list = el('ul', 'allen-pane-files');\n for (const f of files) list.append(el('li', 'allen-pane-mono', `${f.path}, ${utf8(f.content)} bytes`));\n const confirm = button('allen-pane-act allen-pane-run', `Save these ${files.length} files as an Omega project`, `Save ${files.length} file${files.length === 1 ? '' : 's'}`, async () => {\n confirm.disabled = true;\n state.replaceChildren(document.createTextNode('Saving.'));\n let r;\n try {\n r = await opts.saveProject({ project: slug(`${named[1]}-${named[2]}`) || 'allen-report', title: `Omega path for ${repo}`, description: `Aien's report on ${repo}${ports ? `, with ${ports} Omega port${ports === 1 ? '' : 's'}` : ''}.`, files: files.map(f => ({ path: f.path, content: f.content })) });\n } catch (_) {\n r = null;\n }\n confirm.disabled = false;\n if (r && r.ok === true) {\n state.replaceChildren(document.createTextNode('Saved. Status: '), statusLink(r.url));\n } else {\n state.replaceChildren(document.createTextNode(r && typeof r.reason === 'string' ? clean(r.reason, 300) : 'The project could not be saved; nothing was stored.'));\n }\n });\n const cancel = button('allen-pane-act', 'Do not save the report', 'Cancel', () => {\n box.hidden = true;\n open.setAttribute('aria-expanded', 'false');\n open.focus();\n });\n const bar = el('div', 'allen-pane-bar');\n bar.append(confirm, cancel);\n box.append(el('p', 'allen-pane-note', `These files become a project under your handle in Omega projects, for Drake to review before anything is published:`), list, bar);\n return [open, box, state];\n }\n function statusLink(url) {\n if (typeof url !== 'string' || !url) return document.createTextNode('no status address was returned.');\n if (/^\\/(?!\\/)/.test(url)) {\n try {\n const here = new URL(url, window.location.href);\n if (here.origin === window.location.origin) {\n const a = el('a', 'allen-link', here.pathname + here.search);\n a.href = here.href;\n return a;\n }\n } catch (_) {}\n }\n return link(url, url);\n }\n function download(name, data) {\n const blob = new Blob([data], { type: 'application/octet-stream' });\n const url = URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = url;\n a.download = name;\n a.hidden = true;\n root.append(a);\n a.click();\n a.remove();\n setTimeout(() => URL.revokeObjectURL(url), 30000);\n }\n function file(entries, name) {\n return { format: FORMAT, v: VERSION, name: clean(name || 'Aien panes', MAX_NAME), exported: new Date().toISOString(), panes: entries };\n }\n function snapshot() {\n return order.filter(dataPane).map(entry);\n }\n function exportOpen() {\n const entries = snapshot();\n if (!entries.length) {\n say('There are no panes with content to export yet.');\n return { ok: false, reason: 'nothing to export' };\n }\n download('aien-panes.json', JSON.stringify(file(entries, current ? current.name : 'Aien panes'), null, 2));\n say(`Exported ${entries.length} pane${entries.length === 1 ? '' : 's'} as a JSON file.`);\n return { ok: true, count: entries.length };\n }\n function restoreEntry(p) {\n if (panes.size >= MAX_PANES) return null;\n let key = p.id;\n for (let n = 2; panes.has(key) && n < 100; n++) key = `${p.id.slice(0, 58)}-${n}`;\n if (panes.has(key)) return null;\n const rec = create(key, p.kind, p.title);\n apply(rec, p.revision, p.content, p.provenance);\n if (p.geom) place(rec, p.geom.x, p.geom.y, p.geom.w, p.geom.h);\n if (p.minimized) {\n rec.minimized = true;\n rec.el.hidden = true;\n chipState(rec);\n }\n stack();\n return rec;\n }\n function restoreAll(data) {\n const room = MAX_PANES - panes.size;\n if (data.panes.length > room) return { ok: false, reason: `Only ${room} more pane${room === 1 ? '' : 's'} fit; close some panes first.` };\n for (const p of data.panes) restoreEntry(p);\n return { ok: true, count: data.panes.length };\n }\n\n" + +note JavaScript list +text js9 " /* Projects: IndexedDB only after an explicit save; an index store keeps\n the list cheap to read. */\n async function list() {\n try {\n const items = await store('readonly', (_, index) => ask(index.getAll()));\n items.sort((a, b) => String(b.saved).localeCompare(String(a.saved)));\n return { ok: true, projects: items.map(i => ({ id: i.id, name: i.name, saved: i.saved, count: i.count })) };\n } catch (error) {\n return { ok: false, reason: storageError(error) };\n }\n }\n async function save(name) {\n const entries = snapshot();\n if (!entries.length) return { ok: false, reason: 'There are no panes with content to save yet.' };\n const title = clean(name || '', MAX_NAME) || (current ? current.name : `Project ${new Date().toLocaleString()}`);\n const id = current && current.name === title ? current.id : `p${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;\n const record = { format: FORMAT, v: VERSION, id, name: title, saved: new Date().toISOString(), panes: entries };\n const bytes = utf8(JSON.stringify(record));\n if (bytes > MAX_PROJECT_BYTES) return { ok: false, reason: `This project is ${bytes} bytes; one project holds at most ${MAX_PROJECT_BYTES}. Export it as a file instead.` };\n try {\n await store('readwrite', async (projects, index) => {\n const existing = await ask(index.get(id));\n const count = await ask(index.count());\n if (!existing && count >= MAX_PROJECTS) throw limit(`${MAX_PROJECTS} projects are saved in this browser; delete one first, or export instead.`);\n await ask(projects.put(record));\n await ask(index.put({ id, name: title, saved: record.saved, count: entries.length }));\n });\n } catch (error) {\n return { ok: false, reason: storageError(error) };\n }\n current = { id, name: title };\n return { ok: true, id, name: title, count: entries.length };\n }\n async function load(id) {\n let record;\n try {\n record = await store('readonly', projects => ask(projects.get(String(id))));\n } catch (error) {\n return { ok: false, reason: storageError(error) };\n }\n if (!record) return { ok: false, reason: 'That project is no longer saved in this browser.' };\n const reason = checkFile(record);\n if (reason) return { ok: false, reason: `The saved project could not be read: ${reason}.` };\n const done = restoreAll(record);\n if (done.ok) current = { id: record.id, name: record.name };\n return done.ok ? { ok: true, id: record.id, name: record.name, count: done.count } : done;\n }\n async function remove(id) {\n try {\n await store('readwrite', (projects, index) => Promise.all([ask(projects.delete(String(id))), ask(index.delete(String(id)))]));\n } catch (error) {\n return { ok: false, reason: storageError(error) };\n }\n if (current && current.id === id) current = null;\n return { ok: true, id };\n }\n async function exportSaved(id) {\n let record;\n try {\n record = await store('readonly', projects => ask(projects.get(String(id))));\n } catch (error) {\n return { ok: false, reason: storageError(error) };\n }\n if (!record) return { ok: false, reason: 'That project is no longer saved in this browser.' };\n download(`${slug(record.name) || 'allen-project'}.json`, JSON.stringify(record, null, 2));\n return { ok: true, id };\n }\n async function importFile(source) {\n let text;\n if (typeof source === 'string') text = source;\n else if (source && typeof source.text === 'function' && typeof source.size === 'number') {\n if (source.size > MAX_PROJECT_BYTES) return { ok: false, reason: `A project file holds at most ${MAX_PROJECT_BYTES} bytes.` };\n try {\n text = await source.text();\n } catch (_) {\n return { ok: false, reason: 'This browser could not read the file.' };\n }\n } else return { ok: false, reason: 'Import takes a project file or its JSON text.' };\n if (utf8(text) > MAX_PROJECT_BYTES) return { ok: false, reason: `A project file holds at most ${MAX_PROJECT_BYTES} bytes.` };\n let data;\n try {\n data = JSON.parse(text);\n } catch (_) {\n return { ok: false, reason: 'That file is not JSON.' };\n }\n const reason = checkFile(data);\n if (reason) return { ok: false, reason: `That file was refused: ${reason}.` };\n return restoreAll(data);\n }\n function project(command, arg) {\n if (!alive) return Promise.resolve({ ok: false, reason: 'unmounted' });\n if (command === 'save') return save(arg);\n if (command === 'list') return list();\n if (command === 'open') return load(arg);\n if (command === 'remove') return remove(arg);\n if (command === 'export') return arg === undefined ? Promise.resolve(exportOpen()) : exportSaved(arg);\n if (command === 'import') return importFile(arg);\n if (command === undefined || command === 'panel') {\n projectsPane();\n return Promise.resolve({ ok: true });\n }\n return Promise.resolve({ ok: false, reason: 'unknown project command' });\n }\n function projectsPane() {\n let rec = panes.get('#projects');\n if (rec) {\n restore(rec, true);\n refreshProjects(rec);\n return;\n }\n if (panes.size >= MAX_PANES) {\n say(`At most ${MAX_PANES} panes can be open. Close one to make room.`);\n return;\n }\n rec = create('#projects', 'projects', 'Projects');\n const body = rec.body;\n const status = el('p', 'allen-projects-state');\n status.setAttribute('role', 'status');\n const show = r => {\n status.textContent = r.ok ? r.message : r.reason;\n };\n const form = el('form', 'allen-projects-form');\n const nameId = uid('allen-project-name');\n const nameLabel = el('label', 'allen-pane-label', 'Project name');\n nameLabel.htmlFor = nameId;\n const input = el('input', 'allen-projects-name');\n input.id = nameId;\n input.type = 'text';\n input.maxLength = MAX_NAME;\n input.autocomplete = 'off';\n input.value = current ? current.name : '';\n const submit = el('button', 'allen-pane-act allen-pane-run', 'Save project');\n submit.type = 'submit';\n form.append(nameLabel, input, submit);\n form.addEventListener('submit', async event => {\n event.preventDefault();\n submit.disabled = true;\n const r = await save(input.value);\n submit.disabled = false;\n show(r.ok ? { ok: true, message: `Saved ${r.name} with ${r.count} pane${r.count === 1 ? '' : 's'} in this browser.` } : r);\n if (r.ok) {\n input.value = r.name;\n refreshProjects(rec);\n }\n });\n const saved = el('ul', 'allen-projects-list');\n const fileId = uid('allen-project-file');\n const fileLabel = el('label', 'allen-pane-label', 'Import a project file (.json)');\n fileLabel.htmlFor = fileId;\n const picker = el('input', 'allen-projects-file');\n picker.id = fileId;\n picker.type = 'file';\n picker.accept = 'application/json,.json';\n picker.addEventListener('change', async () => {\n const chosen = picker.files && picker.files[0];\n picker.value = '';\n if (!chosen) return;\n const r = await importFile(chosen);\n show(r.ok ? { ok: true, message: `Imported ${r.count} pane${r.count === 1 ? '' : 's'}. Nothing is stored until you press Save project.` } : r);\n });\n const exporter = button('allen-pane-act', 'Export the open panes as a JSON file', 'Export open panes', () => {\n const r = exportOpen();\n show(r.ok ? { ok: true, message: `Exported ${r.count} pane${r.count === 1 ? '' : 's'}.` } : { ok: false, reason: 'There are no panes with content to export yet.' });\n });\n const tools = el('div', 'allen-pane-bar');\n tools.append(exporter);\n const academy = el('p', 'allen-pane-note allen-projects-academy');\n academy.append(link('Train your agent', ACADEMY));\n body.append(el('p', 'allen-pane-note', 'Nothing is stored until you press Save project. A project keeps the open panes, their provenance and where they sit, in this browser only. Conversations are not part of a project.'), form, status, section('Saved in this browser'), saved, fileLabel, picker, tools, academy);\n if (typeof opts.syncSummary === 'function') body.append(summaryBox(show));\n rec.projects = { saved, show };\n refreshProjects(rec);\n rec.el.focus({ preventScroll: true });\n }\n /* Only when the page supplies syncSummary (a visitor with a remember key):\n a short summary the visitor reads and edits first, sent on one explicit\n click. Panes, code and data never leave the browser this way. */\n function draft() {\n const parts = snapshot().map(p => `${NAMES[p.kind]}: ${p.title}`);\n let text = `${current ? current.name : 'Project'}: ${parts.join('; ')}`;\n while (utf8(text) > SYNC_MAX) text = text.slice(0, -1);\n return text;\n }\n function summaryBox(show) {\n const box = section('Sync a short summary');\n const areaId = uid('allen-project-summary');\n const note = el('p', 'allen-pane-note', `Only this summary is sent, at most ${SYNC_MAX} bytes, never the panes, code or data. Aien keeps one project summary for you and replaces it each time. Edit it first if you like.`);\n const areaLabel = el('label', 'allen-pane-label', 'Summary to sync');\n areaLabel.htmlFor = areaId;\n const area = el('textarea', 'allen-projects-summary');\n area.id = areaId;\n area.rows = 3;\n area.value = draft();\n const count = el('p', 'allen-pane-label');\n const recount = () => {\n const n = utf8(area.value);\n count.textContent = `${n} of ${SYNC_MAX} bytes`;\n count.dataset.over = n > SYNC_MAX ? 'yes' : 'no';\n };\n area.addEventListener('input', recount);\n recount();\n const refresh = button('allen-pane-act', 'Write the summary again from the open panes', 'Draft again', () => {\n area.value = draft();\n recount();\n });\n const send = button('allen-pane-act allen-pane-run', 'Sync this short summary to Aien\\u2019s memory of you', 'Sync short summary', async () => {\n const text = area.value.trim();\n if (!text) return show({ ok: false, reason: 'The summary is empty.' });\n if (utf8(text) > SYNC_MAX) return show({ ok: false, reason: `The summary is over ${SYNC_MAX} bytes.` });\n send.disabled = true;\n let r;\n try {\n r = await opts.syncSummary(text);\n } catch (_) {\n r = null;\n }\n send.disabled = false;\n show(r && r.ok === true ? { ok: true, message: 'Synced the summary. Aien replaced the previous one.' } : { ok: false, reason: r && typeof r.reason === 'string' ? clean(r.reason, 300) : 'Aien could not sync the summary; nothing was stored.' });\n });\n const bar = el('div', 'allen-pane-bar');\n bar.append(refresh, send);\n box.append(note, areaLabel, area, count, bar);\n return box;\n }\n async function refreshProjects(rec) {\n const ui = rec.projects;\n if (!ui) return;\n const r = await list();\n if (!r.ok) {\n ui.saved.replaceChildren(el('li', 'allen-pane-note', r.reason));\n return;\n }\n if (!r.projects.length) {\n ui.saved.replaceChildren(el('li', 'allen-pane-note', 'No projects are saved in this browser.'));\n return;\n }\n ui.saved.replaceChildren(...r.projects.map(p => projectRow(rec, p)));\n }\n function projectRow(rec, p) {\n const name = clean(p.name, MAX_NAME) || 'Untitled';\n const li = el('li', 'allen-projects-item');\n const text = el('div', 'allen-projects-text');\n text.append(el('span', 'allen-projects-title', name), el('span', 'allen-projects-meta', `${p.count} pane${p.count === 1 ? '' : 's'}, saved ${stamp(p.saved)}`));\n const acts = el('div', 'allen-pane-bar');\n const open = button('allen-pane-act', `Open project ${name}`, 'Open', async () => {\n const r = await load(p.id);\n rec.projects.show(r.ok ? { ok: true, message: `Opened ${r.name}.` } : r);\n });\n const out = button('allen-pane-act', `Export project ${name} as a JSON file`, 'Export', async () => {\n const r = await exportSaved(p.id);\n rec.projects.show(r.ok ? { ok: true, message: `Exported ${name}.` } : r);\n });\n const del = button('allen-pane-act allen-pane-danger', `Delete project ${name} from this browser`, 'Delete', async () => {\n if (del.dataset.armed !== 'yes') {\n del.dataset.armed = 'yes';\n del.textContent = 'Confirm delete';\n del.setAttribute('aria-label', `Confirm: delete project ${name} from this browser`);\n setTimeout(() => {\n if (!del.isConnected) return;\n del.dataset.armed = '';\n del.textContent = 'Delete';\n del.setAttribute('aria-label', `Delete project ${name} from this browser`);\n }, 5000);\n return;\n }\n const r = await remove(p.id);\n rec.projects.show(r.ok ? { ok: true, message: `Deleted ${name} from this browser.` } : r);\n refreshProjects(rec);\n if (rec.el.contains(document.activeElement) || !document.activeElement || document.activeElement === document.body) rec.el.focus({ preventScroll: true });\n });\n acts.append(open, out, del);\n li.append(text, acts);\n return li;\n }\n\n" + +note JavaScript event +text js10 " /* The stream and the page call these. */\n function event(name, payload) {\n if (!alive) return { ok: false, reason: 'unmounted' };\n const id = plain(payload) && typeof payload.id === 'string' ? payload.id : '';\n const rec = ID.test(id) ? panes.get(id) : undefined;\n if (name === 'pane.close' && plain(payload) && !rec) {\n const bad = check(name, payload, '');\n if (bad) return refuse(name, bad);\n closedIds.add(id);\n return { ok: true, id };\n }\n if (name === 'pane.update' && !rec) return refuse(name, 'the pane is not open');\n const reason = check(name, payload, rec ? rec.kind : '');\n if (reason) {\n if (rec && name === 'pane.update') notify(rec, `Aien sent an update this page could not show (${reason}). The last good version stays.`);\n return refuse(name, reason);\n }\n if (name === 'pane.open') {\n if (rec || closedIds.has(id)) return refuse(name, 'that pane id was already opened');\n if (panes.size >= MAX_PANES) {\n say(`Aien tried to open another pane, but at most ${MAX_PANES} can be open. Close one to make room.`);\n return refuse(name, 'too many panes');\n }\n const made = create(id, payload.kind, payload.title);\n waiting(made);\n say(`Aien opened a ${NAMES[made.kind]} pane: ${made.title}.`);\n return { ok: true, id };\n }\n if (name === 'pane.update') {\n if (payload.revision <= rec.revision) return refuse(name, 'the revision is not newer');\n apply(rec, payload.revision, payload.content, payload.provenance);\n return { ok: true, id, revision: payload.revision };\n }\n closedIds.add(id);\n close(rec, false);\n return { ok: true, id };\n }\n function open(payload) {\n if (!plain(payload)) return refuse('open', 'open takes an object');\n const id = own(payload, 'id') ? payload.id : `local-${Date.now().toString(36)}${(serial += 1)}`;\n const opened = event('pane.open', { v: VERSION, id, kind: payload.kind, title: payload.title });\n if (!opened.ok || !own(payload, 'content')) return opened;\n const rec = panes.get(id);\n const prov = own(payload, 'provenance') ? payload.provenance : { status: 'unverified', engine: '', expression: '', result: '', source: 'this page', commit: '' };\n const updated = event('pane.update', { v: VERSION, id, revision: own(payload, 'revision') ? payload.revision : rec.revision + 1, content: payload.content, provenance: prov });\n if (!updated.ok) close(rec, false, true);\n return updated;\n }\n function openNode(spec) {\n if (!alive) return { ok: false, reason: 'unmounted' };\n const node = spec && spec.node;\n if (!(node instanceof Node) || node.nodeType === Node.DOCUMENT_NODE) return refuse('openNode', 'openNode takes a node built by this page');\n const id = spec && typeof spec.id === 'string' && ID.test(spec.id) ? spec.id : `card${(serial += 1)}`;\n const key = `card:${id}`;\n let rec = panes.get(key);\n if (!rec) {\n if (panes.size >= MAX_PANES) return refuse('openNode', 'too many panes');\n rec = create(key, 'card', typeof spec.title === 'string' ? spec.title : 'Aien');\n } else if (typeof spec.title === 'string') {\n rec.title = clean(spec.title, MAX_TITLE) || rec.title;\n label(rec);\n }\n rec.body.replaceChildren(node);\n restore(rec, spec.focus === true);\n return { ok: true, id, close: () => close(rec, false) };\n }\n function cycle(dir, from) {\n const stops = [...panes.values()].filter(r => !r.minimized).map(r => r.el);\n stops.push(dock);\n const at = stops.findIndex(s => s.contains(from));\n const next = stops[(at + dir + stops.length) % stops.length];\n if (next === dock) (chips.querySelector('button') || projectsButton).focus();\n else next.focus({ preventScroll: true });\n }\n function onKey(e) {\n if (e.defaultPrevented || !alive) return;\n if (e.key === 'Escape') {\n const inside = root.contains(e.target);\n const loose = e.target === document.body || e.target === document.documentElement || e.target === document;\n if (!inside && !loose) return;\n const rec = inside ? owner(e.target) : null;\n const target = rec && !rec.minimized ? rec : topmost();\n if (!target) return;\n e.preventDefault();\n minimize(target);\n return;\n }\n if (e.key === 'F6' && root.contains(e.target)) {\n e.preventDefault();\n cycle(e.shiftKey ? -1 : 1, e.target);\n }\n }\n function destroy() {\n if (!alive) return;\n for (const rec of panes.values()) stopApp(rec);\n alive = false;\n document.removeEventListener('keydown', onKey);\n window.removeEventListener('resize', onResize);\n if (media) {\n if (typeof media.removeEventListener === 'function') media.removeEventListener('change', layout);\n else if (typeof media.removeListener === 'function') media.removeListener(layout);\n }\n if (fitting) cancelAnimationFrame(fitting);\n root.remove();\n panes.clear();\n order = [];\n closed.length = 0;\n }\n\n" + +note JavaScript prelude +text js11 " document.addEventListener('keydown', onKey);\n window.addEventListener('resize', onResize);\n if (media) {\n if (typeof media.addEventListener === 'function') media.addEventListener('change', layout);\n else if (typeof media.addListener === 'function') media.addListener(layout);\n }\n layout();\n stack();\n return { event, open, openNode, project, destroy };\n }\n\n window.AllenPanes = Object.freeze({ version: VERSION, mount, check });\n window.dispatchEvent(new CustomEvent('allen-panes-ready', { detail: { version: VERSION } }));\n})();\n" + +fn main to int +if ne PLOTMAX 1.0e100f64 +trap 3 +end +js_0 +js_1 +js_2 +js_3 +js_4 +js_5 +js_6 +js_7 +js_8 +js_9 +js_10 +js_11 +if eq get marker 0 1 +trap 3 +end +flush +ret 0 +end + +fn js_0 to void +for b ulong len js0 +byteput get js0 b +end +end + +fn js_1 to void +for b ulong len js1 +byteput get js1 b +end +end + +fn js_2 to void +for b ulong len js2 +byteput get js2 b +end +end + +fn js_3 to void +for b ulong len js3 +byteput get js3 b +end +end + +fn js_4 to void +for b ulong len js4 +byteput get js4 b +end +end + +fn js_5 to void +for b ulong len js5 +byteput get js5 b +end +end + +fn js_6 to void +for b ulong len js6 +byteput get js6 b +end +end + +fn js_7 to void +for b ulong len js7 +byteput get js7 b +end +end + +fn js_8 to void +for b ulong len js8 +byteput get js8 b +end +end + +fn js_9 to void +for b ulong len js9 +byteput get js9 b +end +end + +fn js_10 to void +for b ulong len js10 +byteput get js10 b +end +end + +fn js_11 to void +for b ulong len js11 +byteput get js11 b +end +end diff --git a/om/allen-presence/NATIVE.md b/om/allen-presence/NATIVE.md new file mode 100644 index 0000000..3c37641 --- /dev/null +++ b/om/allen-presence/NATIVE.md @@ -0,0 +1,32 @@ +# Allen's native presence + +The visual reference is the native galaxy build in [aienux at da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c](https://github.com/aien-dev/aienux/tree/da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c/native/kernel/ui). Drake identifies this galaxy experience as the Allen he uses on his iMac. The available old machine report names an earlier build; it is not evidence that the newer galaxy never ran. The reference selection follows his current observation, not that stale report. No physical iMac was accessed or changed for this work. + +## What the native source does + +- `night.c` draws the photographic Milky Way layer, catalogue stars and galaxies, then the two lensing black holes. The native opening merges the holes at 12000 ms. Allen begins to gather at 12300 ms and completes formation at 15300 ms. +- `mind.c` draws a Fibonacci-lattice cloud, its nearest-neighbour threads, pale blue-white points, a blue/violet halo and a warm heart. Idle rotation uses `spin = 349`; the source describes a turn in 48 seconds. The breathing phase uses 5500 ms. Listening, thinking and speaking change the same stateful renderer, not a replacement icon. +- `allen_ui.c` places the heart at half the width and 40 percent of the height. Its reference layout is 1920 by 1080, with a 720 by 54 input bar at `height - 150`, all scaled by its native scale factor. +- While typing, key events light pulses upward through the mind and feed the ink field. On submission the typed line rises and fades over 900 ms. Nine thoughts leave on curved paths, starting at `150 + i * 40` ms, with duration `850 + hash(i, 1, 5) % 300` ms. Literal individual glyphs flying on each keystroke are a requested web enhancement, not a claim about the old native input renderer. +- Native replies appear below Allen, not as a transcript wall. Letters start 35 ms apart, fade in over 260 ms and rise by six reference pixels over 360 ms. They change from RGB(255,212,150) to RGB(234,238,252) over 900 ms. Each word pulses his heart. The native view holds only the current reply; the web adds an explicit session-history panel. +- The spinning tube is the native dusk/sleep transition, lasting 4200 ms. **The web opening on Allen's own screen reuses the iMac dusk scene.** The home door uses the native two-hole opening. Reordering dusk as an entrance is an intentional presentation choice, not the native boot order. + +These are source constants and source descriptions, not newly measured frame-rate claims. + +## Sound + +`chirp.c` is the only native sound generator. It produces the merger chirp from night time 11360 through 12300 ms, with the merger at 12000 ms. The generated browser WAV is synthesized by `om/allen-audio/chirp.om`, not a recorded imitation. The source contains no separate tube, birth, boom or voice-like sound. The browser therefore does not invent one. WebAudio starts only from a visitor's gesture; mute is a separate local preference. See `om/allen-audio/check.sh` for the independent original-C oracle and negative control. + +## Browser boundaries + +The page skeleton, transport client and presence controller are generated by seeded Omega. The native pixel renderer is temporarily compiled from the pinned original C to WebAssembly so its integer arithmetic and pixels can be compared directly. The page labels that boundary honestly; it does not claim that the C pixels were drawn by Omega. `om/allen-scene/provenance.txt` records the native renderer, its AGPL-3.0-or-later licence at that pin, and the Omega successor (aien-dev/omega-mv draft PR 811, incomplete). + +The accessible DOM remains responsible for the input, last reply, history, consent, controls and glass panes. The transport retains its existing same-origin routes. An anonymous session sends no visitor key. Remember-me and the X pixel remain separate explicit choices. Drake's speaker label is accepted only from the authenticated session channel's human event. Model text cannot choose it. + +Reduced motion leaves a static glow and reveals text without animated travel. Hidden documents stop drawing. The corner launcher and the full-screen canvas share the same renderer. The optional history belongs to the current tab; saving a project is a separate action. + +## Reproduction + +Regenerate the presence artifacts with `OMEGA_ACCEPT_CHANGE=1 sh om/allen-presence/check.sh`, and the page with `OMEGA_ACCEPT_CHANGE=1 sh om/allen-page/check.sh`. Run the same commands without acceptance to detect drift. Native renderer and audio regeneration have their own pinned recipes under `om/allen-scene` and `om/allen-audio`. Generated artifacts and their hash sidecars must be committed with their Omega sources. + +Pixel comparisons must name the native source pin, viewport, frame time and complete state sequence. Comparing different times or a QEMU screen that contains firmware UI is not a renderer parity verdict. Native-host parity and emulator-frame parity are separate observations. Production checks use canvas `getImageData` through `tab.evaluate`, not a screenshot command that hangs in this environment. No emulator or browser result qualifies physical iMac hardware. diff --git a/om/allen-presence/check.sh b/om/allen-presence/check.sh new file mode 100755 index 0000000..d7709f1 --- /dev/null +++ b/om/allen-presence/check.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Build-only glue. The browser integration is authored in presence.om. +set -eu +cd "$(dirname "$0")" +omc=${OMEGA_OMC:-../hive-page/omc} +pin=$(tr -d ' \n' < ../hive-page/omc.sha256) +test "$(sha256sum "$omc" | cut -d' ' -f1)" = "$pin" || exit 3 +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT HUP INT TERM +"$omc" < presence.om > "$work/generate" +chmod +x "$work/generate" +"$work/generate" > "$work/first.js" 3> "$work/first.html" +"$work/generate" > "$work/second.js" 3> "$work/second.html" +[ -s "$work/first.js" ] || exit 6 +cmp "$work/first.html" "$work/second.html" +cmp "$work/first.js" "$work/second.js" +artifact=../../public/js/allen-presence.js +if ! cmp -s "$work/first.js" "$artifact"; then + [ "${OMEGA_ACCEPT_CHANGE:-0}" = 1 ] || { printf 'Presence artifact stale; regenerate with OMEGA_ACCEPT_CHANGE=1\n' >&2; exit 4; } + cp "$work/first.js" "$artifact" +fi +if ! cmp -s "$work/first.html" launcher.html; then + [ "${OMEGA_ACCEPT_CHANGE:-0}" = 1 ] || exit 4 + cp "$work/first.html" launcher.html +fi +sha256sum launcher.html > launcher.sha256 +sha256sum "$artifact" > presence.sha256 +printf 'Allen presence generator deterministic\n' diff --git a/om/allen-presence/launcher.html b/om/allen-presence/launcher.html new file mode 100644 index 0000000..ac51801 --- /dev/null +++ b/om/allen-presence/launcher.html @@ -0,0 +1 @@ +Speak to Aien diff --git a/om/allen-presence/launcher.sha256 b/om/allen-presence/launcher.sha256 new file mode 100644 index 0000000..0bf6c24 --- /dev/null +++ b/om/allen-presence/launcher.sha256 @@ -0,0 +1 @@ +ebb434d1d98c16fb14d8d9961e456b66cb95b179285e52ab1eb413f0da896a02 launcher.html diff --git a/om/allen-presence/presence.om b/om/allen-presence/presence.om new file mode 100644 index 0000000..a1174b5 --- /dev/null +++ b/om/allen-presence/presence.om @@ -0,0 +1,31 @@ +note Browser integration authored in Omega, emitted with the pinned seeded compiler. +note Native reply cadence is 35 ms per letter; 260 ms fade and 360 ms rise, allen_ui.c. +note No network text is parsed as markup. Transport and consent retain their separate owners. +text boot "/* Generated from om/allen-presence/presence.om. */\n(() => {\n'use strict';\nconst root = document.getElementById('allen');\nconst homeDoor = Boolean(root && root.closest('[data-home-door]'));\nconst reduced = matchMedia('(prefers-reduced-motion: reduce)');\nconst byId = id => document.getElementById(id);\nlet scene = null, panes = null, subscribed = false, entered = false;\nlet reply = '', painted = 0, timer = 0, cardId = 0;\nlet resolveReady, rejectReady;\nconst ready = new Promise((resolve,reject) => { resolveReady=resolve; rejectReady=reject; });\nready.catch(() => {});\nconst dispose = [];\nfunction status(text) { const node = byId('allen-status'); if (node) node.textContent = text; }\nfunction showSession(open) {\n const panel = byId('allen-session'), trigger = byId('allen-history');\n panel.hidden = !open; trigger.setAttribute('aria-expanded', String(open));\n if (open) { panel.tabIndex = -1; panel.focus(); } else trigger.focus();\n}\nfunction paintReply() {\n clearTimeout(timer); timer=0;\n const out = byId('allen-answer');\n if (!out || document.hidden || painted >= reply.length) return;\n if (reduced.matches) { painted=reply.length; out.textContent=reply; return; }\n const letter=String.fromCodePoint(reply.codePointAt(painted));\n if (scene && !/\\s/.test(letter) && (!painted || /\\s/.test(reply[painted-1]))) scene.speak(letter);\n const span=document.createElement('span'); span.className='allen-letter'; span.textContent=letter; out.append(span);\n painted+=letter.length;\n if (painted < reply.length) timer=setTimeout(paintReply,35);\n}\nfunction replaceReply(text, speaker) {\n clearTimeout(timer); timer=0; reply=String(text); painted=0;\n byId('allen-speaker').textContent=speaker;\n const out=byId('allen-answer'); out.textContent='';\n if (speaker==='Aien') out.dataset.speaker='allen'; else delete out.dataset.speaker;\n paintReply();\n}\nfunction mountScene() {\n if (!window.AllenScene || scene) return;\n const canvas=byId('allen-universe');\n if (!canvas) return;\n scene=window.AllenScene.mount(canvas,{compact:false,interactive:true,opening:homeDoor?'idle':'dusk'});\n window.allenPresenceScene=scene;\n scene.ready.then(() => {\n byId('allen-enter').disabled=false; resolveReady(scene);\n document.dispatchEvent(new CustomEvent('allen-presence-ready'));\n }, error => { rejectReady(error); byId('allen-enter').disabled=false; status('The scene could not load. You can still chat with Aien.'); });\n}\nfunction mountPanes() {\n if (!window.AllenPanes || panes) return;\n panes=window.AllenPanes.mount(byId('allen-panes'),{});\n}\nfunction enter(options={}) {\n if (entered) return; entered=true; root.dataset.entered='true';\n byId('allen-arrival').hidden=true;\n mountScene(); mountPanes();\n if (options.scene!==false && scene && !homeDoor) scene.enter('dusk');\n // Native dusk is silent. The home-door owner starts the merger chirp on a real gesture.\n byId('allen-input').focus();\n const initial=byId('allen-log').querySelector('.allen-msg-allen .allen-p');\n if (!reply && initial) replaceReply(initial.textContent,'Aien');\n}\nfunction audioLabel() {\n const muted=window.AllenAudio ? window.AllenAudio.muted() : true;\n const button=byId('allen-mute'); button.setAttribute('aria-pressed',String(muted)); button.textContent=muted?'Sound off':'Sound on';\n}\n" +text hooks "function connect() {\n if (!root || !window.allen || subscribed) return; subscribed=true;\n const api=window.allen;\n byId('allen-log').setAttribute('aria-live','off');\n dispose.push(api.on('send',event => {\n if (!entered) enter({scene:false});\n if (!event.silent) byId('allen-guest').textContent=event.text;\n replaceReply('','Aien');\n if (scene) { scene.key(event.text); scene.mode('think'); }\n byId('allen-regenerate').disabled=true;\n }));\n dispose.push(api.on('token',event => { reply+=event.text; if (!timer) paintReply(); }));\n dispose.push(api.on('reply',event => {\n if (!event.text.startsWith(reply.slice(0,painted))) replaceReply(event.text,'Aien');\n else { reply=event.text; if (!timer) paintReply(); }\n byId('allen-regenerate').disabled=false;\n if (scene) scene.mode('idle');\n }));\n dispose.push(api.on('error',event => { status(event.message); byId('allen-regenerate').disabled=false; if (scene) scene.mode('idle'); }));\n dispose.push(api.on('human',event => replaceReply(event.text,'Drake')));\n dispose.push(api.on('card',event => {\n mountPanes();\n if (panes && panes.openNode) panes.openNode({id:'chat-'+(++cardId),title:event.type==='relay'?'Message to Drake':event.type==='introduce'?'Remember me':'Aien · '+event.type,node:event.node});\n else showSession(true);\n }));\n for (const name of ['pane.open','pane.update','pane.close']) dispose.push(api.on(name,event => { mountPanes(); if (panes) panes.event(name,event); }));\n byId('allen-regenerate').addEventListener('click',() => api.regenerate());\n byId('allen-copy').addEventListener('click',async () => {\n try { await navigator.clipboard.writeText(reply); status('Reply copied.'); } catch (_) { status('Clipboard unavailable. Select the reply to copy it.'); }\n });\n byId('allen-introduce').addEventListener('click',() => showSession(true));\n byId('allen-new').addEventListener('click',() => {\n byId('allen-guest').textContent='';\n const hello=byId('allen-log').querySelector('.allen-msg-allen .allen-p');\n replaceReply(hello?hello.textContent:'','Aien');\n });\n}\nfunction full() {\n window.allenPresence=Object.freeze({ready,enter,scene:() => scene,panes:() => panes});\n byId('allen-enter').disabled=true;\n if (homeDoor) byId('allen-arrival').hidden=true;\n mountScene(); mountPanes(); connect(); audioLabel();\n byId('allen-enter').addEventListener('click',() => enter());\n byId('allen-history').addEventListener('click',() => showSession(byId('allen-session').hidden));\n byId('allen-mute').addEventListener('click',() => { if (window.AllenAudio) { window.AllenAudio.setMuted(!window.AllenAudio.muted()); audioLabel(); } });\n byId('allen-projects').addEventListener('click',() => { mountPanes(); if (panes && panes.project) panes.project(); });\n const input=byId('allen-input');\n input.addEventListener('input',event => {\n input.style.height='36px'; input.style.height=Math.min(120,input.scrollHeight)+'px';\n if (scene && event.data && !event.isComposing) scene.key(event.data);\n });\n document.addEventListener('keydown',event => {\n if (event.key==='Escape' && !byId('allen-session').hidden) { event.preventDefault(); showSession(false); }\n if ((event.ctrlKey || event.metaKey) && event.key==='/') { event.preventDefault(); input.focus(); }\n });\n document.addEventListener('visibilitychange',() => { if (!document.hidden && painted { if (reduced.matches) { clearTimeout(timer); timer=0; painted=reply.length; byId('allen-answer').textContent=reply; } });\n document.addEventListener('allen-ready',connect);\n document.addEventListener('allen-scene-ready',mountScene);\n document.addEventListener('allen-panes-ready',mountPanes);\n window.addEventListener('pagehide',() => { clearTimeout(timer); for (const off of dispose) off(); if (scene) scene.destroy(); if (panes) panes.destroy(); if (window.AllenAudio) window.AllenAudio.stop(); },{once:true});\n}\n" +text compact "function compact() {\n const launcher = byId('aien-allen-launcher');\n if (!launcher || !window.AllenScene) return;\n const canvas = launcher.querySelector('canvas');\n const small = window.AllenScene.mount(canvas,{compact:true,interactive:false});\n const aside = byId('aien-allen-intro');\n function intro(event) {\n if (event.detail.type === 'show' && window.aienAllenIntro) small.speak(window.aienAllenIntro.text.greeting);\n if (event.detail.type === 'reply-no' && window.aienAllenIntro) small.speak(window.aienAllenIntro.text.afterNo);\n }\n document.addEventListener('aien-allen-intro',intro);\n if (aside && !aside.hidden && window.aienAllenIntro) small.speak(window.aienAllenIntro.text.greeting);\n launcher.addEventListener('click', event => {\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || reduced.matches) return;\n event.preventDefault();\n launcher.classList.add('allen-launch-enter');\n const finish = () => location.assign(launcher.href);\n launcher.addEventListener('transitionend',finish,{once:true}); setTimeout(finish,450);\n });\n window.addEventListener('pagehide', () => { small.destroy(); document.removeEventListener('aien-allen-intro',intro); }, {once:true});\n}\nif (root) full(); else { compact(); if (!window.AllenScene) document.addEventListener('allen-scene-ready',compact,{once:true}); }\n})();\n" +text mobile "if(root) {\n let layoutFrame=0;\n function layout() {\n layoutFrame=0;\n const viewport=window.visualViewport;\n root.style.setProperty('--allen-view-height',(viewport?viewport.height:innerHeight)+'px');\n root.style.setProperty('--allen-view-top',(viewport?viewport.offsetTop:0)+'px');\n const bottom=root.querySelector('.allen-bottom');\n if(bottom) root.style.setProperty('--allen-panes-sheet-bottom',Math.max(0,root.getBoundingClientRect().bottom-bottom.getBoundingClientRect().top+8)+'px');\n }\n function requestLayout() {if(!layoutFrame) layoutFrame=requestAnimationFrame(layout);}\n window.addEventListener('resize',requestLayout);\n if(window.visualViewport) {visualViewport.addEventListener('resize',requestLayout);visualViewport.addEventListener('scroll',requestLayout);}\n const observer=new ResizeObserver(requestLayout); const bottom=root.querySelector('.allen-bottom');if(bottom)observer.observe(bottom);\n document.addEventListener('allen-pane-request',event => {\n const d=event.detail;mountPanes();\n if(!panes || !panes.openNode || !d || !(d.node instanceof Node))return;\n const handle=panes.openNode({id:d.id,title:d.title,node:d.node,focus:false});\n if(handle) {event.preventDefault();d.handle=handle;}\n });\n window.addEventListener('pagehide',() => {observer.disconnect();cancelAnimationFrame(layoutFrame);window.removeEventListener('resize',requestLayout);if(window.visualViewport){visualViewport.removeEventListener('resize',requestLayout);visualViewport.removeEventListener('scroll',requestLayout);}},{once:true});\n requestLayout();\n}\n" +text launcher "Speak to Aien\n" +fn main to int +w = write 1 boot 0 len boot +if ne w long len boot +ret 1 +end +w = write 1 hooks 0 len hooks +if ne w long len hooks +ret 1 +end +w = write 1 mobile 0 len mobile +if ne w long len mobile +ret 1 +end +w = write 1 compact 0 len compact +if ne w long len compact +ret 1 +end +w = write 3 launcher 0 len launcher +if ne w long len launcher +ret 1 +end +ret 0 +end diff --git a/om/allen-presence/presence.sha256 b/om/allen-presence/presence.sha256 new file mode 100644 index 0000000..09d64b8 --- /dev/null +++ b/om/allen-presence/presence.sha256 @@ -0,0 +1 @@ +ab0b3f9bddb16300a7ef38d213f5e6e424ade60c0651a66e080a230f431b5ec3 ../../public/js/allen-presence.js diff --git a/om/allen-scene/.crumb b/om/allen-scene/.crumb new file mode 100644 index 0000000..df348e4 --- /dev/null +++ b/om/allen-scene/.crumb @@ -0,0 +1,6 @@ +{ + "schema_version": "1.0.0", + "name": "allen-scene", + "layer": "website", + "purpose": "Native Allen scene reuse, Omega browser controller and independent frame oracle" +} diff --git a/om/allen-scene/adapter.c b/om/allen-scene/adapter.c new file mode 100644 index 0000000..3a6681c --- /dev/null +++ b/om/allen-scene/adapter.c @@ -0,0 +1,238 @@ +/* Temporary, explicitly authorized C-on-web boundary. Native implementation: + * aien-dev/aienux@da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c/native/kernel/ui. + * Files in native/ are unchanged. Replace this adapter and those C units with + * seeded Omega -> irwasm only after native-frame/audio parity, not by renaming C. + * The web opening reuses native DUSK, then native dawn/formation; this ordering + * is a web interaction, not the original two-hole boot sequence (replay=2). + * No I/O, imports, heap allocator, threads, GPU interface or browser privileges. + */ +#include "native/night.h" +#include "native/mind.h" +#include "native/flow.h" +#include "native/chirp.h" +#include "native/sky_real.h" + +void *memset(void *p, int c, size_t n) { unsigned char *q=p; while(n--) *q++=(unsigned char)c; return p; } +void *memcpy(void *d, const void *s, size_t n) { unsigned char *q=d; const unsigned char *p=s; while(n--) *q++=*p++; return d; } + +static struct { + ck_night night; + ck_mind mind; + ck_flow flow; + ck_night_picture kept; + ck_canvas cv; + ck_af_face face; + uint32_t *rgba, *back; + void *scratch, *keep; + int32_t w,h,cx,cy,far16; + uint32_t k,t,kind,compact,word_t,key_t; + int initialized; +} ui; +static int16_t audio[2*48000]; +#define S(v) ((int32_t)(((int64_t)(v)*(int64_t)ui.k+128)/256)) +#define EXPORT __attribute__((visibility("default"))) + +/* Verbatim state law from allen_ui.c:horizon_at; only struct ownership changes. */ +static void horizon_at(uint32_t d) +{ + ck_night_dusk k = {0}; + uint32_t q = ck_smooth(ck_prog(d, 0, 3400)); + q = (q * q >> 8) * q >> 8; + k.fallen = (int64_t)ui.far16 * ui.far16 * (int64_t)q >> 8; + k.swirl = 65536u * 6 / 10; + k.calm = S(120) * 16; + k.crowd = 256 + (768 * ck_smooth(ck_prog(d, 300, 2400)) >> 8); + k.e = (int32_t)((int64_t)S(90) * 16 * ck_smooth(ck_prog(d, 0, 2000)) >> 8); + int32_t rs0 = (int32_t)((int64_t)S(60) * 16 * ck_smooth(ck_prog(d, 0, 2000)) >> 8); + k.rs = rs0 + (int32_t)((int64_t)S(60) * 16 * ck_smooth(ck_prog(d, 3400, 4200)) >> 8); + uint32_t rise = ck_smooth(ck_prog(d, 900, 2800)), fall = 256 - ck_smooth(ck_prog(d, 3100, 3900)); + k.disk = rise < fall ? rise : fall; + k.beam = 16384u + d * 65536u / 9000u; + k.keep = 256 - ck_ease_out(ck_prog(d, 2800, 4000)); + k.near = S(260) * 16, k.far = ui.far16; + k.shade = 230 * ck_smooth(ck_prog(d, 400, 2600)) >> 8; + k.fine = S(300) * 16; + ck_night_fall(&ui.night, &k); +} + +/* Verbatim merger flash from allen_ui.c:flash/unflash. */ +static int flash(uint32_t t, int32_t *rad, uint32_t *a) +{ + if (t < CK_NIGHT_MERGE_MS || t >= CK_NIGHT_MERGE_MS + 1600) return 0; + uint32_t tm = t - CK_NIGHT_MERGE_MS; + *rad = (S(40) + (int32_t)((int64_t)S(220) * ck_ease_out(ck_prog(tm, 0, 1200)) >> 8)) * 16; + uint32_t rise = ck_smooth(ck_prog(tm, 0, 120)); + *a = rise * (ck_exp_neg(tm > 120 ? (tm - 120) * 256 / 450 : 0) >> 8) * 230 >> 16; + return *a > 0; +} +static void unflash(const ck_rect *r, uint32_t t) +{ + uint32_t tm=t-CK_NIGHT_MERGE_MS; + if(ui.night.holes!=1 || tm<100) return; + uint32_t keep=256-ck_smooth(ck_prog(tm,100,400)); + int32_t hx=ui.night.hole[0].x,hy=ui.night.hole[0].y,rs=ui.night.hole[0].rs; + ck_rect box={(hx-rs)>>4,(hy-rs)>>4,(2*rs>>4)+2,(2*rs>>4)+2}; + if(rs<=16 || !ck_clip(&box,r)) return; + for(int32_t y=box.y;y=(uint32_t)rs) continue; + uint32_t in=(uint32_t)rs-d>=16?256:((uint32_t)rs-d)*16; + uint32_t k=256-(in*(256-keep)>>8); + ui.back[(size_t)y*ui.w+x]=ck_scale(ui.back[(size_t)y*ui.w+x],k); + } +} + +EXPORT int scene_init(uint32_t w,uint32_t h,uint32_t compact) +{ + if(w<64 || h<64 || w>1920 || h>1920 || (uint64_t)w*h>2073600) return 0; + memset(&ui,0,sizeof ui); + ui.w=w;ui.h=h;ui.compact=compact; + ui.k=ck_min(w*256/1920,h*256/1080); + /* Compact is a native design-scale crop, not a different particle scene. */ + if(compact) ui.k=ck_min(w,h)*256/400; + ui.cx=w/2;ui.cy=compact?h/2:h*40/100; + size_t pix=(size_t)w*h*4; + size_t night=ck_night_mem_bytes(w,h,ui.k), kept=ck_night_picture_bytes(w,h); + size_t needed=3*pix+night+kept+262144+64; +#ifdef __wasm__ + extern unsigned char __heap_base; + uintptr_t base=((uintptr_t)&__heap_base+15)&~(uintptr_t)15; + size_t end=base+needed, pages=(end+65535)/65536; + size_t have=__builtin_wasm_memory_size(0); + if(pages>have && __builtin_wasm_memory_grow(0,pages-have)==(size_t)-1) return 0; + unsigned char *p=(unsigned char*)base; +#else + static unsigned char arena[64*1024*1024]; + if(needed>sizeof arena) return 0; + unsigned char *p=arena; +#endif + ui.rgba=(uint32_t*)p;p+=pix; + ui.back=(uint32_t*)p;p+=pix; + ui.scratch=p;p+=pix; + ui.cv=(ck_canvas){ui.back,(int32_t)w,(int32_t)h}; + if(ck_night_init(&ui.night,w,h,ui.k,ui.cx,ui.cy,p,night,ui.scratch)) return 0; + p+=night;ui.keep=p;p+=kept; + ck_af_face_init(&ui.face,ck_max(8,S(18)),1250,p,262144); + for(int c=CK_AF_FIRST;c<=CK_AF_LAST;c++) (void)ck_af_glyph_get(&ui.face,(char)c); + for(int i=0;i<4;i++) { + int64_t dx=(i&1?ui.w:0)-ui.cx,dy=(i&2?ui.h:0)-ui.cy; + ui.far16=ck_max(ui.far16,(int32_t)ck_isqrt((uint64_t)(dx*dx+dy*dy))*16); + } + ck_night_picture_take(&ui.night,ui.night.sky,ui.keep,&ui.kept); + ck_mind_init(&ui.mind,ui.cx,ui.cy,ui.k,12300); + ck_flow_init(&ui.flow,w,h,ui.cx,ui.cy,ui.mind.R,ui.cx,ui.h-S(177),0); + ui.initialized=1; + return 1; +} +EXPORT uintptr_t scene_pixels(void) { return (uintptr_t)ui.rgba; } +/* Native dusk consumes the whole preceding picture, not only the sky. For a + * fresh web opening use the original unwoken UI at 20000 ms: no bar/words and + * sleeping fluid, but the fully formed mind and twinkling sky are present. + * oracle-ui.c independently exercises original allen_ui.c for this state. */ +static void opening_picture(void) +{ + ck_rect all={0,0,ui.w,ui.h}; + ck_mind_init(&ui.mind,ui.cx,ui.cy,ui.k,12300); + for(uint32_t t=0;t<=20000;t+=16) ck_mind_at(&ui.mind,t); + ck_mind_at(&ui.mind,20000); + ck_night_at(&ui.night,20000); + ck_night_base(&ui.night,&ui.cv,&all); + ck_night_lights(&ui.night,&ui.cv,&all,0,0); + ck_mind_draw(&ui.mind,&ui.cv,&all); + ck_night_picture_take(&ui.night,ui.back,ui.keep,&ui.kept); +} +EXPORT void scene_enter(uint32_t kind) +{ + if(!ui.initialized) return; + ui.kind=kind>2?0:kind;ui.t=0;ui.word_t=ui.key_t=0; + if(kind==1) opening_picture(); + ck_mind_init(&ui.mind,ui.cx,ui.cy,ui.k,kind==1?4200:12300); + ck_flow_init(&ui.flow,ui.w,ui.h,ui.cx,ui.cy,ui.mind.R,ui.cx,ui.h-S(177),0); + if(kind!=1) ck_night_picture_take(&ui.night,ui.night.sky,ui.keep,&ui.kept); +} +EXPORT void scene_key(uint32_t t) { if(ui.initialized) {ck_mind_key(&ui.mind,t);ck_flow_key(&ui.flow,t);ui.key_t=t;} } +EXPORT void scene_word(uint32_t t) { if(ui.initialized) {ck_mind_word(&ui.mind,t);ck_flow_word(&ui.flow,t);ui.word_t=t;} } +EXPORT void scene_step(uint32_t t,uint32_t mode,uint32_t voice) +{ + if(!ui.initialized) return; + ui.t=t; + ck_mind_mode(&ui.mind,(int)(mode&3),t); + ck_mind_voice(&ui.mind,voice); + int formed=t>=ui.mind.born+CK_MIND_FORM_MS; + ck_flow_mode(&ui.flow,formed?(int)(mode&3):CK_FLOW_SLEEP,t); + if(!ui.compact) ck_flow_at(&ui.flow,t); + int32_t vx=0,vy=0; + if(!ui.compact) ck_flow_velocity(&ui.flow,ui.cx,ui.cy,&vx,&vy); + ui.mind.cx=ui.cx+ck_clamp(vx*S(10)/1000,-S(10),S(10)); + ui.mind.cy=ui.cy+ck_clamp(vy*S(10)/1000,-S(10),S(10)); + ck_mind_at(&ui.mind,t); +} +/* Native allen_ui.c per-word voice envelope; no browser floating approximation. */ +EXPORT uint32_t scene_voice(uint32_t t,uint32_t word) +{ + return t>=word?ck_exp_neg((t-word)*256/200)>>8:0; +} +EXPORT void scene_draw(uint32_t shimmer,uint32_t voice) +{ + if(!ui.initialized) return; + ck_rect all={0,0,ui.w,ui.h}; + uint32_t t=ui.t; + ck_night_at(&ui.night,ui.kind==2?t:20000); + if(ui.kind==1 && t<4200) { + horizon_at(t); + ck_night_base_from(&ui.night,&ui.kept,&ui.cv,&all); + } else { + ck_night_base(&ui.night,&ui.cv,&all); + ck_night_lights(&ui.night,&ui.cv,&all,shimmer,voice*shimmer>>9); + if(!ui.compact) ck_flow_draw(&ui.flow,&ui.cv,&all,256); + int32_t rad;uint32_t a; + if(ui.kind==2 && flash(t,&rad,&a)) { + ck_glow(&ui.cv,&all,ui.cx*16+8,ui.cy*16+8,rad,CK_RGB(200,210,255),a/3); + ck_glow(&ui.cv,&all,ui.cx*16+8,ui.cy*16+8,rad/3,CK_RGB(255,240,224),a); + unflash(&all,t); + } + ck_mind_draw(&ui.mind,&ui.cv,&all); + /* Native dawn duration is 900 ms; only its placement after dusk is web-specific. */ + if(ui.kind==1 && t<5100) { + uint32_t gain=ck_prog(t,4200,5100); + for(size_t i=0;i<(size_t)ui.w*ui.h;i++) ui.back[i]=ck_scale(ui.back[i],gain); + } + } + for(size_t i=0;i<(size_t)ui.w*ui.h;i++) { + uint32_t c=ui.back[i]; + ui.rgba[i]=0xff000000u|(c&0xff00u)|(c>>16&255u)|((c&255u)<<16); + } +} +/* Pan/zoom the source's existing sky camera; no generated replacement stars. */ +EXPORT int scene_view(int32_t ra,int32_t dec,int32_t fov) +{ + if(!ui.initialized || ra<0 || ra>360000000 || dec< -89000000 || dec>89000000 || fov<10000 || fov>120000) return 0; + ck_sky_view v; + if(ra==113697000 && dec== -72757000 && fov==80000) v=ck_sky_the_view; + else ck_sky_view_at(&v,ra,dec,fov,0); + ck_night_view(&ui.night,&v,ui.scratch); + ck_night_picture_take(&ui.night,ui.night.sky,ui.keep,&ui.kept); + return 1; +} +/* Native stroke glyph drawn above RGBA: no system or external font dependency. + * Letters flying from the web input are an intentional browser enhancement. */ +EXPORT void scene_glyph(uint32_t c,int32_t x,int32_t y,uint32_t alpha) +{ + if(!ui.initialized || c<32 || c>126 || alpha>256) return; + ck_rect all={0,0,ui.w,ui.h}; + (void)ck_letter(&ui.cv,&all,&ui.face,(uint64_t)ck_max(0,x)*256,y,(char)c,CK_RGB(206,222,255),alpha,1); + const ck_af_glyph *g=ck_af_glyph_get(&ui.face,(char)c); + if(!g) return; + ck_rect box={x+g->ox,y+g->oy,g->w,g->h}; + if(!ck_clip(&box,&all)) return; + for(int32_t yy=box.y;yy>16&255u)|((col&255u)<<16); + } +} +EXPORT uintptr_t scene_audio(uint32_t from,uint32_t frames) +{ + if(frames>48000 || from>CK_CHIRP_FRAMES) return 0; + ck_chirp_fill(audio,from,frames);return (uintptr_t)audio; +} diff --git a/om/allen-scene/artifacts.sha256 b/om/allen-scene/artifacts.sha256 new file mode 100644 index 0000000..30f2227 --- /dev/null +++ b/om/allen-scene/artifacts.sha256 @@ -0,0 +1,3 @@ +d20124bd97d9215db9120a1d516b661488f890b81a8c609b602e155eb29f4cde ../../public/js/allen-scene.js +a591d98abf8052379cfb50943ac95f46f3782d42a96aa3d3d6258b5bbc6e6002 ../../public/allen/scene.wasm +3c096604be03ec955a312561e420abe09abe41070cb2f10888fdc21ab984fb55 ../../public/allen/scene.om diff --git a/om/allen-scene/check-native.sh b/om/allen-scene/check-native.sh new file mode 100755 index 0000000..56141c4 --- /dev/null +++ b/om/allen-scene/check-native.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Run under nice -n 19 ionice -c3. This is an independent verification oracle, +# not a production dependency and not an iMac/QEMU qualification receipt. +set -eu +root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) +ref=${ALLEN_NATIVE_SOURCE:?Set ALLEN_NATIVE_SOURCE to a clean aienux checkout at the exact reference pin} +pin=da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c +[ "$(git -C "$ref" rev-parse HEAD)" = "$pin" ] || { printf 'Original UI reference pin mismatch\n' >&2; exit 3; } +git -C "$ref" diff --quiet "$pin" -- native/kernel/ui native/kernel/svc/allen_scene.c native/kernel/svc/allen_scene.h native/kernel/svc/allen_code.c native/kernel/svc/allen_code.h || { printf 'Original UI reference modified\n' >&2; exit 3; } +work=$(mktemp -d "${TMPDIR:-/tmp}/allen-native-oracle.XXXXXX") +trap 'rm -rf "$work"' EXIT HUP INT TERM +ui=$ref/native/kernel/ui +svc=$ref/native/kernel/svc +scene=$root/om/allen-scene +cc=${CC:-cc} +"$cc" --version +"$cc" -O2 -fno-builtin "$scene/oracle.c" "$scene/adapter.c" \ + "$ui/mind.c" "$ui/night.c" "$ui/paint.c" "$ui/allen_font.c" "$ui/flow.c" \ + "$ui/sky_real.c" "$ui/sky_data.c" "$ui/chirp.c" -o "$work/adapter-oracle" +"$cc" -O2 -fno-builtin -I"$ui" "$scene/oracle-ui.c" \ + "$ui/mind.c" "$ui/night.c" "$ui/paint.c" "$ui/allen_font.c" "$ui/flow.c" \ + "$ui/sky_real.c" "$ui/sky_data.c" "$ui/canvas.c" \ + "$svc/allen_scene.c" "$svc/allen_code.c" -o "$work/original-ui-oracle" +cd "$root" +node om/allen-scene/test-parity.cjs "$work/adapter-oracle" public/allen/scene.wasm "$work/original-ui-oracle" +node om/allen-scene/test-controller.cjs diff --git a/om/allen-scene/check.sh b/om/allen-scene/check.sh new file mode 100755 index 0000000..9fea636 --- /dev/null +++ b/om/allen-scene/check.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Build the explicitly-authorized native C/WASM dependency and Omega controller. +# --generate: generate artifacts once, no test claims. Default: deterministic +# regeneration and exact committed-artifact checks. No package installation. +set -eu +cd "$(dirname "$0")" +omc=${OMEGA_OMC:-../hive-page/omc} +clang=${ALLEN_CLANG:-clang-18} +ld=${ALLEN_WASM_LD:-wasm-ld-18} +pin=$(tr -d ' \n' < ../hive-page/omc.sha256) +have=$(sha256sum "$omc" | cut -d' ' -f1) +[ "$pin" = "$have" ] || { printf 'Wrong Omega compiler pin\n' >&2; exit 3; } +"$clang" --version | grep -F 'clang version 18.1.3' >/dev/null || { printf 'Native dependency requires clang 18.1.3\n' >&2; exit 3; } +"$ld" --version | grep -F '18.1.3' >/dev/null || { printf 'Native dependency requires wasm-ld 18.1.3\n' >&2; exit 3; } +sha256sum -c native.sha256 +work=$(mktemp -d "${TMPDIR:-/tmp}/allen-scene.XXXXXX") +trap 'rm -rf "$work"' EXIT HUP INT TERM +build_wasm() { + "$clang" --target=wasm32 -O2 -nostdlib -ffreestanding -fno-builtin \ + -ffunction-sections -fdata-sections -fvisibility=hidden -fno-ident \ + -Wl,--no-entry -Wl,--strip-all -Wl,--export-memory -Wl,--stack-first \ + -Wl,-z,stack-size=1048576 -Wl,--max-memory=67108864 -Wl,--gc-sections \ + -Wl,--export=scene_init -Wl,--export=scene_pixels -Wl,--export=scene_enter \ + -Wl,--export=scene_key -Wl,--export=scene_word -Wl,--export=scene_step \ + -Wl,--export=scene_draw -Wl,--export=scene_view -Wl,--export=scene_glyph \ + -Wl,--export=scene_audio -Wl,--export=scene_voice -fuse-ld="$ld" \ + adapter.c native/mind.c native/night.c native/paint.c native/allen_font.c \ + native/flow.c native/sky_real.c native/sky_data.c native/chirp.c -o "$1" +} +"$omc" < scene.om > "$work/controller" +chmod +x "$work/controller" +"$work/controller" > "$work/scene.js" +build_wasm "$work/scene.wasm" +if [ "${1:-}" != --generate ]; then + "$work/controller" > "$work/again.js" + build_wasm "$work/again.wasm" + cmp "$work/scene.js" "$work/again.js" + cmp "$work/scene.wasm" "$work/again.wasm" +fi +[ -s "$work/scene.js" ] && [ -s "$work/scene.wasm" ] || exit 6 +if [ "${1:-}" = --generate ] || [ "${OMEGA_ACCEPT_CHANGE:-0}" = 1 ]; then + mkdir -p ../../public/allen + cp "$work/scene.js" ../../public/js/allen-scene.js + cp "$work/scene.wasm" ../../public/allen/scene.wasm + cp scene.om ../../public/allen/scene.om + sha256sum ../../public/js/allen-scene.js ../../public/allen/scene.wasm ../../public/allen/scene.om > artifacts.sha256 +else + cmp "$work/scene.js" ../../public/js/allen-scene.js + cmp "$work/scene.wasm" ../../public/allen/scene.wasm + cmp scene.om ../../public/allen/scene.om + sha256sum -c artifacts.sha256 +fi +printf 'Generated native scene and Omega controller (no browser claim)\n' diff --git a/om/allen-scene/native.sha256 b/om/allen-scene/native.sha256 new file mode 100644 index 0000000..9e057ab --- /dev/null +++ b/om/allen-scene/native.sha256 @@ -0,0 +1,17 @@ +e89b9eb5ffce15f2e0a55a3a6d3a83f739d0c4bd5f3047a39e9ebf0c92e686ad native/mind.c +3fafe5b2a1f967f9cee392e5cba6b52774667fc7bcf89f9deecbfeae7a6c7cdf native/mind.h +b33e1d4ab71564c3c5e0da08c5d09ce28abfbf0a236fb595c9e1d94453e05214 native/night.c +5c434bf9ac9148042ce0d70b3f181a6a2f95cab5a378c4551bf0df0c4072e099 native/night.h +7afbe5627d21bd25b70fcf32ff42c294203ad8b152019566300678f2006715e2 native/paint.c +a107f4ffecb93dc4828129ac171363a4991732ed0cc2c0be0c0f1cff16393137 native/paint.h +92d7157386e65351325d80d5036565e406145230dfb696c9804ec80888d26904 native/allen_font.c +e26c3d5bc4c7c987a256dd066146a74da3e764623979a578e2cd0ecf43547fda native/allen_font.h +74438c92860501e20206c05a1a871894576b9403cfbf1b2444aa474c803adfff native/chirp.c +6555e35525eb8315e62bbee3737f98e352f5d5b825cde5e73d6f7dcbb2327b30 native/chirp.h +0da5f6c200e67db75834c252510fdaee247492972020099bbcade0258c9ae686 native/flow.c +c85ac637e0390dccc623a304bd9e8f1982b7ccf8da57407156012d470eb92901 native/flow.h +f7074249225e1d8b952eb478ed69012afcfac0d86f93702049a35c98fe511ba3 native/sky_real.c +216a50636c0aaf987ac97874926bba1170d7527a45ae96f12d00823ac4f289a8 native/sky_real.h +0f8cc32c4e59ca0dd62fa2131f6455d878faa89cce4fb00bcae73b4d1475e227 native/sky_data.c +ff1c3c7f884bed376c1eea244132b209f407358bbc01b3ef4c12a1b4810db54f native/sky_data.h +692eb7ae80de6dad4269c9be111c29c212721400b388b5172a498d0045023c55 native/sky_data.txt diff --git a/om/allen-scene/native/.crumb b/om/allen-scene/native/.crumb new file mode 100644 index 0000000..28a400f --- /dev/null +++ b/om/allen-scene/native/.crumb @@ -0,0 +1,6 @@ +{ + "schema_version": "1.0.0", + "name": "allen-scene-native", + "layer": "dependency", + "purpose": "Unmodified da55660 native rendering and catalogue dependency, bound by native.sha256" +} diff --git a/om/allen-scene/native/allen_font.c b/om/allen-scene/native/allen_font.c new file mode 100644 index 0000000..78eab61 --- /dev/null +++ b/om/allen-scene/native/allen_font.c @@ -0,0 +1,325 @@ +/* allen_font.c -- Allen's stroke typeface; see allen_font.h. */ +#include "allen_font.h" + +/* Each glyph: "wN" (advance in design units), then pen commands: + * Mx,y move the pen + * Lx,y line from the pen to x,y + * Acx,cy,rx,ry,a0,a1 elliptical arc from angle a0 to a1 (degrees; 0 is + * right, 90 is down), starting fresh; the pen ends at a1 + * Dx,y a dot + * Every stroke has round caps and joins (distance to the centre line). */ +static const char *const glyphs[CK_AF_COUNT] = { + /* */ "w6", + /* ! */ "w6 M3,0 L3,14 D3,20", + /* " */ "w10 M3,0 L3,5 M7,0 L7,5", + /* # */ "w15 M6,2 L4,20 M11,2 L9,20 M2,8 L13,8 M1,14 L12,14", + /* $ */ "w15 A8,5,5,5,-30,-270 A8,15,5,5,270,510 M8,-2 L8,22", + /* % */ "w16 A4,4,2,3,0,360 A12,16,2,3,0,360 M13,1 L3,19", + /* & */ "w16 M14,20 L5,9 A7,5,3,4,150,400 L3,14 A7,15,4,5,180,60 L13,11", + /* ' */ "w6 M3,0 L3,5", + /* ( */ "w9 A10,10,6,12,240,120", + /* ) */ "w9 A-1,10,6,12,-60,60", + /* * */ "w14 M7,2 L7,10 M3,4 L11,8 M11,4 L3,8", + /* + */ "w14 M2,12 L12,12 M7,7 L7,17", + /* , */ "w6 M3,19 L2,23", + /* - */ "w11 M2,13 L9,13", + /* . */ "w6 D3,20", + /* / */ "w12 M10,0 L2,20", + /* 0 */ "w14 A7,10,5,10,0,360", + /* 1 */ "w14 M3,4 L8,0 L8,20", + /* 2 */ "w14 A7,6,5,6,200,400 L2,20 L12,20", + /* 3 */ "w14 A7,5,5,5,200,450 A7,15,5,5,270,520", + /* 4 */ "w14 M10,20 L10,0 L1,14 L13,14", + /* 5 */ "w14 M12,0 L4,0 L4,9 A7,14,5,6,235,520", + /* 6 */ "w14 A7,14,5,6,0,360 M10,0 L3,11", + /* 7 */ "w14 M2,0 L12,0 L5,20", + /* 8 */ "w14 A7,5,4,5,0,360 A7,15,5,5,0,360", + /* 9 */ "w14 A7,6,5,6,0,360 M4,20 L11,9", + /* : */ "w6 D3,8 D3,20", + /* ; */ "w6 D3,8 M3,19 L2,23", + /* < */ "w14 M12,6 L2,12 L12,18", + /* = */ "w14 M2,10 L12,10 M2,15 L12,15", + /* > */ "w14 M2,6 L12,12 L2,18", + /* ? */ "w14 A7,5,5,5,190,450 L7,14 D7,20", + /* @ */ "w19 A9,12,3,4,0,360 M12,8 L12,14 A14,14,2,2,180,0 A9,11,7,9,0,-300", + /* A */ "w16 M2,20 L8,0 L14,20 M4,13 L12,13", + /* B */ "w15 M2,0 L2,20 M2,0 L8,0 A8,5,4,5,270,450 L2,10 M2,10 L9,10 A9,15,4,5,270,450 L2,20", + /* C */ "w17 A9,10,7,10,45,315", + /* D */ "w16 M2,0 L2,20 M2,0 L6,0 A6,10,8,10,270,450 L2,20", + /* E */ "w14 M12,0 L2,0 L2,20 L12,20 M2,10 L10,10", + /* F */ "w13 M12,0 L2,0 L2,20 M2,10 L10,10", + /* G */ "w18 A9,10,7,10,-45,-360 M11,10 L16,10", + /* H */ "w16 M2,0 L2,20 M14,0 L14,20 M2,10 L14,10", + /* I */ "w6 M3,0 L3,20", + /* J */ "w13 M10,0 L10,14 A6,14,4,6,0,180", + /* K */ "w15 M2,0 L2,20 M13,0 L2,12 M6,8 L14,20", + /* L */ "w13 M2,0 L2,20 L12,20", + /* M */ "w20 M2,20 L2,0 L10,14 L18,0 L18,20", + /* N */ "w16 M2,20 L2,0 L14,20 L14,0", + /* O */ "w20 A10,10,8,10,0,360", + /* P */ "w15 M2,20 L2,0 L8,0 A8,5,5,5,270,450 L2,10", + /* Q */ "w20 A10,10,8,10,0,360 M12,14 L18,21", + /* R */ "w15 M2,20 L2,0 L8,0 A8,5,5,5,270,450 L2,10 M8,10 L14,20", + /* S */ "w16 A8,5,5,5,-30,-270 A8,15,5,5,270,510", + /* T */ "w16 M1,0 L15,0 M8,0 L8,20", + /* U */ "w16 M2,0 L2,13 A8,13,6,7,180,0 L14,0", + /* V */ "w16 M1,0 L8,20 L15,0", + /* W */ "w22 M1,0 L6,20 L11,0 L16,20 L21,0", + /* X */ "w16 M2,0 L14,20 M14,0 L2,20", + /* Y */ "w16 M1,0 L8,10 L15,0 M8,10 L8,20", + /* Z */ "w16 M2,0 L14,0 L2,20 L14,20", + /* [ */ "w9 M7,-1 L3,-1 L3,21 L7,21", + /* \ */ "w12 M2,0 L10,20", + /* ] */ "w9 M2,-1 L6,-1 L6,21 L2,21", + /* ^ */ "w12 M2,8 L6,1 L10,8", + /* _ */ "w14 M1,23 L13,23", + /* ` */ "w7 M2,0 L4,4", + /* a */ "w15 A7,14,5,6,0,360 M12,8 L12,20", + /* b */ "w15 M2,0 L2,20 A7,14,5,6,0,360", + /* c */ "w13 A7,14,5,6,40,320", + /* d */ "w15 A7,14,5,6,0,360 M12,0 L12,20", + /* e */ "w14 M2,14 L12,14 A7,14,5,6,0,-320", + /* f */ "w11 M5,20 L5,4 A9,4,4,4,180,300 M2,8 L10,8", + /* g */ "w15 A7,14,5,6,0,360 M12,8 L12,22 A7,22,5,5,0,150", + /* h */ "w15 M2,0 L2,20 A7,13,5,5,180,360 L12,20", + /* i */ "w6 M3,8 L3,20 D3,3", + /* j */ "w7 M4,8 L4,22 A0,22,4,5,0,120 D4,3", + /* k */ "w13 M2,0 L2,20 M11,8 L2,15 M5,13 L12,20", + /* l */ "w6 M3,0 L3,20", + /* m */ "w21 M2,8 L2,20 A6,12,4,4,180,360 L10,20 A14,12,4,4,180,360 L18,20", + /* n */ "w15 M2,8 L2,20 A7,13,5,5,180,360 L12,20", + /* o */ "w14 A7,14,5,6,0,360", + /* p */ "w15 M2,8 L2,27 A7,14,5,6,0,360", + /* q */ "w15 A7,14,5,6,0,360 M12,8 L12,27", + /* r */ "w10 M2,8 L2,20 A7,13,5,5,180,290", + /* s */ "w14 A7,11,4,3,-30,-270 A7,17,4,3,270,510", + /* t */ "w11 M5,2 L5,17 A8,17,3,3,180,40 M2,8 L10,8", + /* u */ "w15 M2,8 L2,15 A7,15,5,5,180,0 M12,8 L12,20", + /* v */ "w14 M2,8 L7,20 L12,8", + /* w */ "w20 M2,8 L6,20 L10,8 L14,20 L18,8", + /* x */ "w14 M2,8 L12,20 M12,8 L2,20", + /* y */ "w14 M2,8 L7,20 M12,8 L4,27", + /* z */ "w14 M2,8 L12,8 L2,20 L12,20", + /* { */ "w10 M8,-1 L6,0 L6,8 L4,10 L6,12 L6,20 L8,21", + /* | */ "w6 M3,-1 L3,23", + /* } */ "w10 M2,-1 L4,0 L4,8 L6,10 L4,12 L4,20 L2,21", + /* ~ */ "w14 M2,13 L5,11 L9,14 L12,12", +}; + +static const uint16_t sin_q[91] = { + 0, 286, 572, 857, 1143, 1428, 1713, 1997, 2280, 2563, 2845, 3126, 3406, 3686, 3964, + 4240, 4516, 4790, 5063, 5334, 5604, 5872, 6138, 6402, 6664, 6924, 7182, 7438, 7692, 7943, + 8192, 8438, 8682, 8923, 9162, 9397, 9630, 9860, 10087, 10311, 10531, 10749, 10963, 11174, 11381, + 11585, 11786, 11982, 12176, 12365, 12551, 12733, 12911, 13085, 13255, 13421, 13583, 13741, 13894, 14044, + 14189, 14330, 14466, 14598, 14726, 14849, 14968, 15082, 15191, 15296, 15396, 15491, 15582, 15668, 15749, + 15826, 15897, 15964, 16026, 16083, 16135, 16182, 16225, 16262, 16294, 16322, 16344, 16362, 16374, 16382, + 16384, +}; + +int32_t ck_af_sin(int32_t deg) +{ + deg %= 360; + if (deg < 0) + deg += 360; + if (deg <= 90) + return sin_q[deg]; + if (deg <= 180) + return sin_q[180 - deg]; + if (deg <= 270) + return -(int32_t)sin_q[deg - 180]; + return -(int32_t)sin_q[360 - deg]; +} + +int32_t ck_af_cos(int32_t deg) { return ck_af_sin(deg + 90); } + +uint64_t ck_af_isqrt(uint64_t v) +{ + uint64_t r = 0, bit = (uint64_t)1 << 62; + while (bit > v) + bit >>= 2; + while (bit) { + if (v >= r + bit) { + v -= r + bit; + r = (r >> 1) + bit; + } else { + r >>= 1; + } + bit >>= 2; + } + return r; +} + +static int idx(char c) +{ + unsigned char u = (unsigned char)c; + return u >= CK_AF_FIRST && u <= CK_AF_LAST ? u - CK_AF_FIRST : '?' - CK_AF_FIRST; +} + +void ck_af_face_init(ck_af_face *f, unsigned cap_px, unsigned weight, uint8_t *pool, size_t pool_len) +{ + f->s256 = cap_px * 256u / 20u; + f->hw256 = (uint32_t)((uint64_t)weight * f->s256 / 1000u); + f->pool = pool; + f->pool_len = pool_len; + f->pool_used = 0; + for (unsigned i = 0; i < CK_AF_COUNT; i++) + f->g[i] = (ck_af_glyph){0}; +} + +/* Reads a signed integer at *p; advances past it and one ',' if present. */ +static int num(const char **p) +{ + int neg = 0, v = 0; + if (**p == '-') { + neg = 1; + (*p)++; + } + while (**p >= '0' && **p <= '9') + v = v * 10 + (*(*p)++ - '0'); + if (**p == ',') + (*p)++; + return neg ? -v : v; +} + +uint32_t ck_af_advance(const ck_af_face *f, char c) +{ + const char *p = glyphs[idx(c)] + 1; /* past 'w' */ + return (uint32_t)num(&p) * f->s256; +} + +uint32_t ck_af_measure(const ck_af_face *f, const char *s, size_t n) +{ + uint64_t w = 0; + for (size_t i = 0; i < n && s[i]; i++) + w += ck_af_advance(f, s[i]); + return (uint32_t)((w + 255) / 256); +} + +#define SEG_MAX 160 +struct seg { + int32_t x0, y0, x1, y1; /* 1/256 px, relative to the pen; y up from the baseline is negative */ +}; + +/* Turns one glyph's commands into segments. Returns the count. */ +static unsigned segments(const ck_af_face *f, const char *p, struct seg *out) +{ + int32_t s = (int32_t)f->s256; + unsigned n = 0; + int32_t px = 0, py = 0; +#define PT_X(u) ((int32_t)(u) * s) +#define PT_Y(u) (((int32_t)(u) - 20) * s) + while (*p) { + char cmd = *p++; + if (cmd == ' ') + continue; + if (cmd == 'w') { + (void)num(&p); + } else if (cmd == 'M') { + int x = num(&p), y = num(&p); + px = PT_X(x); + py = PT_Y(y); + } else if (cmd == 'L' || cmd == 'D') { + int x = num(&p), y = num(&p); + int32_t nx = PT_X(x), ny = PT_Y(y); + if (cmd == 'D') + px = nx, py = ny; + if (n < SEG_MAX) + out[n++] = (struct seg){px, py, nx, ny}; + px = nx; + py = ny; + } else if (cmd == 'A') { + int cx = num(&p), cy = num(&p), rx = num(&p), ry = num(&p), a0 = num(&p), a1 = num(&p); + int span = a1 > a0 ? a1 - a0 : a0 - a1; + int steps = span / 9 < 2 ? 2 : span / 9; + int32_t lx = 0, ly = 0; + for (int k = 0; k <= steps; k++) { + int32_t a = a0 + (a1 - a0) * k / steps; + int32_t x = PT_X(cx) + (int32_t)((int64_t)rx * s * ck_af_cos(a) / 16384); + int32_t y = PT_Y(cy) + (int32_t)((int64_t)ry * s * ck_af_sin(a) / 16384); + if (k && n < SEG_MAX) + out[n++] = (struct seg){lx, ly, x, y}; + lx = x; + ly = y; + } + px = lx; + py = ly; + } + } +#undef PT_X +#undef PT_Y + return n; +} + +static int32_t floor_px(int32_t v) { return v >= 0 ? v / 256 : -((-v + 255) / 256); } + +const ck_af_glyph *ck_af_glyph_get(ck_af_face *f, char c) +{ + ck_af_glyph *g = &f->g[idx(c)]; + if (g->alpha || (g->w == 0 && g->h == 1)) /* h == 1, w == 0: an empty glyph already done */ + return g; + struct seg sg[SEG_MAX]; + unsigned n = segments(f, glyphs[idx(c)], sg); + if (n == 0) { + g->w = 0; + g->h = 1; + return g; + } + int32_t minx = sg[0].x0, maxx = minx, miny = sg[0].y0, maxy = miny; + for (unsigned i = 0; i < n; i++) { + int32_t xs[2] = {sg[i].x0, sg[i].x1}, ys[2] = {sg[i].y0, sg[i].y1}; + for (int k = 0; k < 2; k++) { + if (xs[k] < minx) minx = xs[k]; + if (xs[k] > maxx) maxx = xs[k]; + if (ys[k] < miny) miny = ys[k]; + if (ys[k] > maxy) maxy = ys[k]; + } + } + int32_t pad = (int32_t)f->hw256 + 256; + int32_t x0 = floor_px(minx - pad), y0 = floor_px(miny - pad); + int32_t x1 = floor_px(maxx + pad) + 1, y1 = floor_px(maxy + pad) + 1; + size_t w = (size_t)(x1 - x0), h = (size_t)(y1 - y0); + if (f->pool_len - f->pool_used < w * h) + return 0; + uint8_t *a = f->pool + f->pool_used; + int64_t hw = f->hw256; + for (size_t yy = 0; yy < h; yy++) { + int64_t py = (int64_t)(y0 + (int32_t)yy) * 256 + 128; + for (size_t xx = 0; xx < w; xx++) { + int64_t pxc = (int64_t)(x0 + (int32_t)xx) * 256 + 128; + int64_t best = INT64_MAX; + for (unsigned i = 0; i < n; i++) { + int64_t ax = sg[i].x0, ay = sg[i].y0, dx = sg[i].x1 - ax, dy = sg[i].y1 - ay; + int64_t qx = pxc - ax, qy = py - ay, len2 = dx * dx + dy * dy, ex, ey; + if (len2 == 0) { + ex = qx; + ey = qy; + } else { + int64_t t = qx * dx + qy * dy; /* projection, scaled by len2 */ + if (t <= 0) { + ex = qx; + ey = qy; + } else if (t >= len2) { + ex = qx - dx; + ey = qy - dy; + } else { + ex = qx - dx * t / len2; + ey = qy - dy * t / len2; + } + } + int64_t d2 = ex * ex + ey * ey; + if (d2 < best) + best = d2; + } + int64_t d = (int64_t)ck_af_isqrt((uint64_t)best); + int64_t cov = hw + 128 - d; /* 1/256 px of the pixel inside the stroke */ + a[yy * w + xx] = cov <= 0 ? 0 : cov >= 256 ? 255 : (uint8_t)(cov * 255 / 256); + } + } + f->pool_used += w * h; + g->w = (uint16_t)w; + g->h = (uint16_t)h; + g->ox = (int16_t)x0; + g->oy = (int16_t)y0; + g->alpha = a; + return g; +} diff --git a/om/allen-scene/native/allen_font.h b/om/allen-scene/native/allen_font.h new file mode 100644 index 0000000..13c3c0a --- /dev/null +++ b/om/allen-scene/native/allen_font.h @@ -0,0 +1,48 @@ +/* allen_font.h -- Allen's typeface: every printable ASCII character drawn as + * round-capped pen strokes (lines and elliptical arcs) on a design grid, and + * rasterized on demand into anti-aliased alpha masks at any size. Integer math + * only (the kernel builds -mgeneral-regs-only); no font files, no outside + * data. Pure: no MMIO, host tested in ui/tests/allen_ui_test.c. + * + * Design grid: cap height and ascenders at y=0, lowercase x-height at y=8, + * baseline at y=20, descenders to y=27; x grows right, y grows down. */ +#ifndef AIENOS_ALLEN_FONT_H +#define AIENOS_ALLEN_FONT_H +#include +#include + +#define CK_AF_FIRST 32 +#define CK_AF_LAST 126 +#define CK_AF_COUNT (CK_AF_LAST - CK_AF_FIRST + 1) + +typedef struct { + uint8_t *alpha; /* w*h coverage, 0..255; NULL when not rasterized yet */ + uint16_t w, h; + int16_t ox, oy; /* mask top-left relative to the pen on the baseline, px */ +} ck_af_glyph; + +typedef struct { + uint32_t s256; /* 1/256 px per design unit */ + uint32_t hw256; /* half the stroke width, 1/256 px */ + uint8_t *pool; /* mask storage, filled as glyphs are first used */ + size_t pool_len, pool_used; + ck_af_glyph g[CK_AF_COUNT]; +} ck_af_face; + +/* cap_px: cap height in pixels; weight: half the stroke width in + * thousandths of a design unit (1250 = regular). pool holds the masks. */ +void ck_af_face_init(ck_af_face *f, unsigned cap_px, unsigned weight, uint8_t *pool, size_t pool_len); +/* The mask for c (anything outside 32..126 draws as '?'); NULL only when the + * pool is full. Rasterized on first use. */ +const ck_af_glyph *ck_af_glyph_get(ck_af_face *f, char c); +/* Advance after c, 1/256 px. */ +uint32_t ck_af_advance(const ck_af_face *f, char c); +/* Width of the first n characters of s, whole px (rounded up). */ +uint32_t ck_af_measure(const ck_af_face *f, const char *s, size_t n); +/* Integer square root (floor). */ +uint64_t ck_af_isqrt(uint64_t v); +/* sin and cos of whole degrees (any sign), scaled by 16384. */ +int32_t ck_af_sin(int32_t deg); +int32_t ck_af_cos(int32_t deg); + +#endif diff --git a/om/allen-scene/native/chirp.c b/om/allen-scene/native/chirp.c new file mode 100644 index 0000000..d3e7329 --- /dev/null +++ b/om/allen-scene/native/chirp.c @@ -0,0 +1,192 @@ +/* chirp.c -- the startup sound; see chirp.h. + * + * Every frame is worked out from where it sits on the night's timeline. + * With L the share of the inspiral left (1 at CK_CHIRP_START_MS, 0 at the + * merger), the holes' orbit goes as 1 - L^(5/8); so does the sound's + * phase, scaled so it starts at CK_CHIRP_FROM_HZ, which makes its pitch go + * as L^(-3/8). Once the pitch reaches CK_CHIRP_TO_HZ (the last few + * milliseconds) it holds there through the merger and the fade. Loudness + * goes as L^(-1/4), which is pitch^(2/3), reaching CK_CHIRP_PEAK where the + * pitch stops rising. Phases are in 2^32ths of a cycle; L and its powers in + * Q30. */ +#include "chirp.h" + +#define F0_FRAME (CK_CHIRP_RATE / 1000u * (CK_CHIRP_START_MS - CK_CHIRP_IN_MS)) /* the sound comes in */ +#define F1_FRAME (CK_CHIRP_RATE / 1000u * CK_CHIRP_START_MS) /* the sweep begins */ +#define F2_FRAME (CK_CHIRP_RATE / 1000u * CK_NIGHT_MERGE_MS) /* the merger */ +#define Q30 (1ull << 30) +#define DECAY 1072996429ull /* exp(-1 / (30 ms * 48 kHz)) in Q30: the fade's time constant is 30 ms */ + +static int16_t sin_t[4096]; /* Q14 */ +static uint32_t cap_frame; /* the pitch stops rising here */ +static uint64_t cap_l14; /* L^(1/4) there */ +static uint64_t cap_phase; /* the phase there */ +static int ready; + +static uint64_t isqrt(uint64_t x) +{ + uint64_t r = 0, bit = 1ull << 62; + while (bit > x) + bit >>= 2; + while (bit) { + if (x >= r + bit) { + x -= r + bit; + r = (r >> 1) + bit; + } else { + r >>= 1; + } + bit >>= 2; + } + return r; +} + +/* L at a frame of the inspiral, and its eighth root (both Q30) */ +static uint64_t left_q30(uint32_t f) { return ((uint64_t)(F2_FRAME - f) << 30) / (F2_FRAME - F1_FRAME); } + +static uint64_t root8(uint64_t l) +{ + for (int i = 0; i < 3; i++) + l = isqrt(l << 30); + return l; +} + +static uint64_t mul(uint64_t a, uint64_t b) { return a * b >> 30; } + +/* phase over the inspiral before the cap: P1 + K (1 - L^(5/8)), K chosen so + * the pitch starts at CK_CHIRP_FROM_HZ: K = FROM_HZ * 8/5 * inspiral seconds */ +static uint64_t inspiral_phase(uint32_t f) +{ + uint64_t r = root8(left_q30(f)), l58 = mul(mul(mul(mul(r, r), r), r), r); + uint64_t p1 = ((uint64_t)CK_CHIRP_FROM_HZ * (F1_FRAME - F0_FRAME) << 32) / CK_CHIRP_RATE; + uint64_t k = (uint64_t)CK_CHIRP_FROM_HZ * 8 * (F2_FRAME - F1_FRAME); /* K * 5 * RATE */ + return p1 + ((k * (Q30 - l58) << 2) / (5ull * CK_CHIRP_RATE)); +} + +static void setup(void) +{ + const int64_t C = 1073740561, S = 1647099; /* cos, sin of a 4096th of a turn, Q30 */ + int64_t c = 1ll << 30, s = 0; + for (unsigned k = 0; k <= 1024; k++) { + int16_t v = k == 1024 ? 16384 : (int16_t)((s + (1 << 15)) >> 16); + sin_t[k] = v; + sin_t[2048 - k] = v; + sin_t[(2048 + k) & 4095] = (int16_t)-v; + sin_t[(4096 - k) & 4095] = (int16_t)-v; + int64_t nc = (c * C - s * S) >> 30, ns = (s * C + c * S) >> 30; + c = nc, s = ns; + } + /* the first frame where FROM_HZ * L^(-3/8) reaches TO_HZ, i.e. where + * L^(3/8) falls to FROM_HZ / TO_HZ (L^(3/8) only falls) */ + uint64_t want = ((uint64_t)CK_CHIRP_FROM_HZ << 30) / CK_CHIRP_TO_HZ; + uint32_t lo = F1_FRAME, hi = F2_FRAME; + while (lo < hi) { + uint32_t mid = lo + (hi - lo) / 2; + uint64_t r = root8(left_q30(mid)); + if (mul(mul(r, r), r) <= want) + hi = mid; + else + lo = mid + 1; + } + cap_frame = lo; + uint64_t r = root8(left_q30(lo)); + cap_l14 = mul(r, r); + cap_phase = inspiral_phase(lo); + ready = 1; +} + +static uint64_t phase_at(uint32_t f) +{ + if (f < F1_FRAME) + return ((uint64_t)CK_CHIRP_FROM_HZ * (f - F0_FRAME) << 32) / CK_CHIRP_RATE; + if (f < cap_frame) + return inspiral_phase(f); + return cap_phase + ((uint64_t)CK_CHIRP_TO_HZ * (f - cap_frame) << 32) / CK_CHIRP_RATE; +} + +static uint64_t decay_pow(uint32_t k) /* DECAY^k, Q30 */ +{ + uint64_t r = Q30, b = DECAY; + while (k) { + if (k & 1) + r = mul(r, b); + b = mul(b, b); + k >>= 1; + } + return r; +} + +uint32_t ck_chirp_level(uint32_t f) +{ + if (!ready) + setup(); + if (f < F0_FRAME || f >= CK_CHIRP_FRAMES) + return 0; + uint64_t steady = (uint64_t)CK_CHIRP_PEAK * cap_l14 >> 30; /* the level at L = 1 */ + if (f < F1_FRAME) { /* comes in smoothly (smoothstep) */ + uint64_t x = ((uint64_t)(f - F0_FRAME) << 16) / (F1_FRAME - F0_FRAME), s = x * x * (3ull * 65536 - 2 * x); + return (uint32_t)(steady * s >> 48); + } + if (f < cap_frame) { + uint64_t r = root8(left_q30(f)); + return (uint32_t)((uint64_t)CK_CHIRP_PEAK * cap_l14 / mul(r, r)); + } + if (f < F2_FRAME) + return CK_CHIRP_PEAK; + return (uint32_t)((uint64_t)CK_CHIRP_PEAK * decay_pow(f - F2_FRAME) >> 30); +} + +uint32_t ck_chirp_hz(uint32_t f) +{ + if (!ready) + setup(); + if (f < F0_FRAME || f >= CK_CHIRP_FRAMES) + return 0; + if (f < F1_FRAME) + return CK_CHIRP_FROM_HZ; + if (f >= cap_frame) + return CK_CHIRP_TO_HZ; + uint64_t r = root8(left_q30(f)); + return (uint32_t)(((uint64_t)CK_CHIRP_FROM_HZ << 30) / mul(mul(r, r), r)); +} + +void ck_chirp_fill(int16_t *out, uint32_t from, uint32_t n) +{ + if (!ready) + setup(); + for (uint32_t i = 0; i < n; i++) { + uint32_t f = from + i, a = ck_chirp_level(f); + int32_t v = 0; + if (a) { + uint32_t ph = (uint32_t)phase_at(f), k = ph >> 20, frac = ph >> 4 & 0xffffu; + int32_t s0 = sin_t[k], s1 = sin_t[(k + 1) & 4095]; + int32_t s = s0 + (int32_t)(((int64_t)(s1 - s0) * frac) >> 16); /* Q14 */ + v = (int32_t)(((int64_t)s * a) >> 14); + } + out[2 * i] = out[2 * i + 1] = (int16_t)v; + } +} + +/* The same chirp at 44.1 kHz for converters that take only that rate: frame + * j sits at 48 kHz frame j * 160 / 147, drawn as a straight line between the + * two 48 kHz frames either side (the chirp stays under 1000 Hz, far below + * either rate's limit). Each sample goes in the top 16 bits of a 32-bit slot, + * the layout a 24-bit converter reads (Linux: S32_LE with 24 bits used). */ +void ck_chirp_fill_441(int32_t *out, uint32_t from, uint32_t n) +{ + int16_t src[2 * 144]; + while (n) { + uint32_t m = n < 128u ? n : 128u, s0 = (uint32_t)((uint64_t)from * 160u / 147u); + uint32_t s1 = (uint32_t)((uint64_t)(from + m - 1) * 160u / 147u) + 1; + ck_chirp_fill(src, s0, s1 - s0 + 1); + for (uint32_t i = 0; i < m; i++) { + uint64_t at = (uint64_t)(from + i) * 160u; + uint32_t s = (uint32_t)(at / 147u) - s0, frac = (uint32_t)(at % 147u); + int32_t a = src[2 * s], b = src[2 * s + 2]; + int32_t v = (a * (int32_t)(147u - frac) + b * (int32_t)frac) / 147; + out[2 * i] = out[2 * i + 1] = (int32_t)((uint32_t)v << 16); + } + out += 2 * m; + from += m; + n -= m; + } +} diff --git a/om/allen-scene/native/chirp.h b/om/allen-scene/native/chirp.h new file mode 100644 index 0000000..359f0f4 --- /dev/null +++ b/om/allen-scene/native/chirp.h @@ -0,0 +1,42 @@ +/* chirp.h -- the startup sound: a quick "blirp", the last moment of the chirp + * two bodies make as they spiral into each other and merge (a gravitational + * wave), raised into hearing and timed to the night sky of the startup + * (ui/night.h). Silent until CK_CHIRP_RISE_MS before the merger; then it + * comes in over CK_CHIRP_IN_MS and sweeps up in pitch and loudness the way + * the real wave does (pitch as t^(-3/8), loudness as pitch^(2/3), t the time + * left), with its peak at the merger (CK_NIGHT_MERGE_MS); then a short + * ringing fade. Under a second in all. Made from that formula, no recorded + * sound. Integer only (the kernel builds with -mgeneral-regs-only), + * freestanding, no memory of its own beyond a sine table. Host tested in + * ui/tests/chirp_test.c. */ +#ifndef AIENOS_CHIRP_H +#define AIENOS_CHIRP_H +#include +#include "night.h" + +#define CK_CHIRP_RATE 48000u /* frames a second; each frame is a left and a right sample, 16 bits */ +#define CK_CHIRP_FROM_HZ 200u /* the pitch the sweep starts at */ +#define CK_CHIRP_TO_HZ 1000u /* the pitch at the merger, held through the fade */ +#define CK_CHIRP_PEAK 22937 /* 70% of full scale */ +#define CK_CHIRP_RISE_MS 600u /* the sweep up to the merger */ +#define CK_CHIRP_IN_MS 40u /* the sound comes in over this, just before the sweep */ +#define CK_CHIRP_START_MS (CK_NIGHT_MERGE_MS - CK_CHIRP_RISE_MS) +#define CK_CHIRP_END_MS (CK_NIGHT_MERGE_MS + 300u) /* the ring has died away */ +#define CK_CHIRP_FRAMES (CK_CHIRP_RATE / 1000u * CK_CHIRP_END_MS) + +/* Writes frames [from, from + n) as left, right pairs into out (2n samples), + * frame 0 being the night's 0 ms. Silent past CK_CHIRP_FRAMES. Any frame + * can be asked for in any order: each is worked out from the formula. */ +void ck_chirp_fill(int16_t *out, uint32_t from, uint32_t n); + +/* The pitch in Hz and the loudness (0..CK_CHIRP_PEAK) at a frame. */ +uint32_t ck_chirp_hz(uint32_t frame); +uint32_t ck_chirp_level(uint32_t frame); + +/* The chirp at 44.1 kHz instead: frames [from, from + n) of that rate, frame + * 0 the night's 0 ms, each sample in the top 16 bits of a 32-bit slot (a + * 24-bit converter's layout), left and right. */ +#define CK_CHIRP_RATE_441 44100u +#define CK_CHIRP_FRAMES_441 (CK_CHIRP_RATE_441 / 100u * CK_CHIRP_END_MS / 10u) +void ck_chirp_fill_441(int32_t *out, uint32_t from, uint32_t n); +#endif diff --git a/om/allen-scene/native/flow.c b/om/allen-scene/native/flow.c new file mode 100644 index 0000000..19942e6 --- /dev/null +++ b/om/allen-scene/native/flow.c @@ -0,0 +1,395 @@ +/* flow.c -- Allen's ink; see flow.h. */ +#include "flow.h" + +#define W ((int32_t)CK_FLOW_W) +#define H ((int32_t)CK_FLOW_H) +#define IX(i, j) ((i) + (W + 2) * (j)) +#define Q 65536 /* one, 16.16 */ +#define HALF 32768 + +/* How the water behaves (16.16 unless said): a little thick, so a push + * becomes a slow curl rather than a splash; ink spreads a little more than + * the water does; both fade on their own so the tank always comes to rest. */ +#define VISC_PER_MS 205 /* diffusion of velocity per ms (0.05 per 16 ms step) */ +#define INK_PER_MS 328 /* diffusion of ink per ms (0.08 per 16 ms step) */ +#define INK_FADE_PER_MS 33 /* 0.5 of the ink per second */ +#define VEL_FADE_PER_MS 59 /* 0.9 of the velocity per second */ +#define BLEND_MS 700u /* a mode's pull eases in or out over this long */ +#define SOLVE_STEPS 10 /* Gauss-Seidel sweeps for diffusion and pressure */ + +static int32_t mul(int32_t a, int32_t b) { return (int32_t)(((int64_t)a * b) >> 16); } + +static uint32_t rnd(ck_flow *f) +{ + f->rng ^= f->rng << 13; + f->rng ^= f->rng >> 17; + f->rng ^= f->rng << 5; + return f->rng; +} + +/* ---- the grid and the screen ---- */ + +/* A screen position to a grid position (16.16 cells, the border cell being 0). */ +static int32_t cell_x(const ck_flow *f, int32_t px) { return (int32_t)((((int64_t)px << 24) + f->cw / 2) / f->cw) + Q; } +static int32_t cell_y(const ck_flow *f, int32_t py) { return (int32_t)((((int64_t)py << 24) + f->ch / 2) / f->ch) + Q; } +/* px per second to cells per second */ +static int32_t cells_x(const ck_flow *f, int32_t vx) { return (int32_t)(((int64_t)vx << 24) / f->cw); } +static int32_t cells_y(const ck_flow *f, int32_t vy) { return (int32_t)(((int64_t)vy << 24) / f->ch); } + +/* The field sampled between cells (values sit at cell centres). */ +static int32_t sample(const int32_t *x, int32_t gx, int32_t gy) +{ + gx = ck_clamp(gx - HALF, 0, (W + 1) * Q - 1); + gy = ck_clamp(gy - HALF, 0, (H + 1) * Q - 1); + int32_t i = gx >> 16, j = gy >> 16, s1 = gx & 0xffff, t1 = gy & 0xffff, s0 = Q - s1, t0 = Q - t1; + int64_t a = (int64_t)x[IX(i, j)] * t0 + (int64_t)x[IX(i, j + 1)] * t1; + int64_t b = (int64_t)x[IX(i + 1, j)] * t0 + (int64_t)x[IX(i + 1, j + 1)] * t1; + return (int32_t)((a * s0 + b * s1) >> 32); +} + +/* ---- Stam's steps ---- */ + +/* The border: walls for the velocity (the part across the wall mirrors), continuation for a scalar. */ +static void set_bnd(int32_t *x, int which) +{ + for (int32_t i = 1; i <= W; i++) { + x[IX(i, 0)] = which == 2 ? -x[IX(i, 1)] : x[IX(i, 1)]; + x[IX(i, H + 1)] = which == 2 ? -x[IX(i, H)] : x[IX(i, H)]; + } + for (int32_t j = 1; j <= H; j++) { + x[IX(0, j)] = which == 1 ? -x[IX(1, j)] : x[IX(1, j)]; + x[IX(W + 1, j)] = which == 1 ? -x[IX(W, j)] : x[IX(W, j)]; + } + x[IX(0, 0)] = (x[IX(1, 0)] + x[IX(0, 1)]) / 2; + x[IX(0, H + 1)] = (x[IX(1, H + 1)] + x[IX(0, H)]) / 2; + x[IX(W + 1, 0)] = (x[IX(W, 0)] + x[IX(W + 1, 1)]) / 2; + x[IX(W + 1, H + 1)] = (x[IX(W, H + 1)] + x[IX(W + 1, H)]) / 2; +} + +/* x = (x0 + a * (the four neighbours)) / c, swept SOLVE_STEPS times. */ +static void lin_solve(int32_t *x, const int32_t *x0, int32_t a, int32_t c, int which) +{ + int64_t inv = ((int64_t)1 << 46) / c; /* one division per solve instead of one per cell */ + for (int k = 0; k < SOLVE_STEPS; k++) { + for (int32_t j = 1; j <= H; j++) + for (int32_t i = 1; i <= W; i++) { + int64_t sum = (int64_t)x[IX(i - 1, j)] + x[IX(i + 1, j)] + x[IX(i, j - 1)] + x[IX(i, j + 1)]; + int64_t num = (((int64_t)x0[IX(i, j)] << 16) + a * sum) >> 14; + x[IX(i, j)] = (int32_t)((num * inv) >> 32); + } + set_bnd(x, which); + } +} + +static void diffuse(int32_t *x, const int32_t *x0, int32_t a, int which) { lin_solve(x, x0, a, Q + 4 * a, which); } + +/* Each cell takes the value found where its water came from, dt seconds ago. */ +static void advect(int32_t *d, const int32_t *d0, const int32_t *u, const int32_t *v, int32_t dt, int which) +{ + for (int32_t j = 1; j <= H; j++) + for (int32_t i = 1; i <= W; i++) { + int32_t x = (i << 16) - mul(dt, u[IX(i, j)]), y = (j << 16) - mul(dt, v[IX(i, j)]); + x = ck_clamp(x, HALF, W * Q + HALF); + y = ck_clamp(y, HALF, H * Q + HALF); + int32_t i0 = x >> 16, j0 = y >> 16, s1 = x & 0xffff, t1 = y & 0xffff, s0 = Q - s1, t0 = Q - t1; + int64_t a = (int64_t)d0[IX(i0, j0)] * t0 + (int64_t)d0[IX(i0, j0 + 1)] * t1; + int64_t b = (int64_t)d0[IX(i0 + 1, j0)] * t0 + (int64_t)d0[IX(i0 + 1, j0 + 1)] * t1; + d[IX(i, j)] = (int32_t)((a * s0 + b * s1) >> 32); + } + set_bnd(d, which); +} + +/* Takes the divergence out of the velocity, so the water neither piles up nor + * vanishes anywhere: p and div are scratch. */ +static void project(int32_t *u, int32_t *v, int32_t *p, int32_t *div) +{ + for (int32_t j = 1; j <= H; j++) + for (int32_t i = 1; i <= W; i++) { + div[IX(i, j)] = -(u[IX(i + 1, j)] - u[IX(i - 1, j)] + v[IX(i, j + 1)] - v[IX(i, j - 1)]) / 2; + p[IX(i, j)] = 0; + } + set_bnd(div, 0); + set_bnd(p, 0); + lin_solve(p, div, Q, 4 * Q, 0); + for (int32_t j = 1; j <= H; j++) + for (int32_t i = 1; i <= W; i++) { + u[IX(i, j)] -= (p[IX(i + 1, j)] - p[IX(i - 1, j)]) / 2; + v[IX(i, j)] -= (p[IX(i, j + 1)] - p[IX(i, j - 1)]) / 2; + } + set_bnd(u, 1); + set_bnd(v, 2); +} + +static void copy_field(int32_t *d, const int32_t *s) +{ + for (size_t i = 0; i < CK_FLOW_CELLS; i++) + d[i] = s[i]; +} + +/* ---- what Allen does to the water ---- */ + +/* A push over a soft disc: velocity (vx, vy) and ink, both in grid units, strongest at the centre. */ +static void push(ck_flow *f, int32_t gx, int32_t gy, int32_t vx, int32_t vy, int32_t ink, int32_t r) +{ + int32_t i0 = ck_max(1, (gx - r) >> 16), i1 = ck_min(W, (gx + r) >> 16); + int32_t j0 = ck_max(1, (gy - r) >> 16), j1 = ck_min(H, (gy + r) >> 16); + for (int32_t j = j0; j <= j1; j++) + for (int32_t i = i0; i <= i1; i++) { + int64_t dx = (i << 16) + HALF - gx, dy = (j << 16) + HALF - gy; + int64_t d2 = (dx * dx + dy * dy) >> 16, r2 = ((int64_t)r * r) >> 16; + if (d2 >= r2) + continue; + uint32_t w = ck_exp_neg((uint32_t)(d2 * 3 * 256 / r2)); /* exp(-3 d^2 / r^2), 16.16 */ + f->u[IX(i, j)] += (int32_t)(((int64_t)vx * w) >> 16); + f->v[IX(i, j)] += (int32_t)(((int64_t)vy * w) >> 16); + f->d[IX(i, j)] = ck_min(Q, f->d[IX(i, j)] + (int32_t)(((int64_t)ink * w) >> 16)); + } +} + +/* The pull of each mode, each weighted by how far it has eased in (0..256), + * all added: a change of mode is a change of weights, never a jump. */ +static void forces(ck_flow *f, uint32_t dt_ms) +{ + int32_t cx = cell_x(f, f->cx), cy = cell_y(f, f->cy); + int32_t R = ck_max(Q / 2, (int32_t)(((int64_t)f->R << 24) / f->cw)); /* Allen's radius in cells */ + int32_t bx = cell_x(f, f->bx), by = cell_y(f, f->by); + uint32_t wi = f->weight[CK_FLOW_IDLE], wl = f->weight[CK_FLOW_LISTEN], wt = f->weight[CK_FLOW_THINK]; + uint32_t ws = f->weight[CK_FLOW_SPEAK]; + /* thinking deepens over the first four seconds */ + uint32_t deep = f->think_t ? 256 + ck_smooth(ck_prog(f->t, f->think_t, f->think_t + 4000)) * 3 / 4 : 256; + int32_t breath = ck_sin(f->t * 65536 / 7000); /* a slow swell, +-16384 */ + for (int32_t j = 1; j <= H; j++) + for (int32_t i = 1; i <= W; i++) { + int64_t dx = (i << 16) + HALF - cx, dy = (j << 16) + HALF - cy; + int64_t r = ck_isqrt((uint64_t)((dx * dx + dy * dy) >> 16)) << 8; /* 16.16 cells */ + if (r < Q / 8) + r = Q / 8; + int32_t tx = (int32_t)(-dy * Q / r), ty = (int32_t)(dx * Q / r); /* tangent, unit */ + int32_t rx = (int32_t)(dx * Q / r), ry = (int32_t)(dy * Q / r); /* outward, unit */ + /* a bell over the ring R..3.5R where the water turns */ + int64_t ring = r - 3 * R / 2; + uint32_t bell = r < 7 * R / 2 ? ck_exp_neg((uint32_t)(ring * ring * 512 / ((int64_t)R * R))) : 0; + int64_t ax = 0, ay = 0; /* cells per second per second, 16.16 */ + if (wi && bell) { /* idle: a slow turn with the breath */ + int64_t k = (int64_t)bell * wi >> 8; + int64_t turn = Q / 5 + (breath * (Q / 8) >> 14); + ax += (tx * turn >> 16) * k >> 16; + ay += (ty * turn >> 16) * k >> 16; + ax += (rx * (int64_t)(breath * (Q / 10) >> 14) >> 16) * k >> 16; + ay += (ry * (int64_t)(breath * (Q / 10) >> 14) >> 16) * k >> 16; + } + if (wt && bell) { /* thinking: the vortex, deepening, drawn a little inward */ + int64_t k = (int64_t)bell * wt * deep >> 16; + int64_t turn = 3 * Q / 2; + ax += (tx * turn >> 16) * k >> 16; + ay += (ty * turn >> 16) * k >> 16; + ax -= (rx * (int64_t)(Q / 4) >> 16) * k >> 16; + ay -= (ry * (int64_t)(Q / 4) >> 16) * k >> 16; + } + if (wl) { /* listening: a soft current from the bar up to Allen */ + int64_t lx = cx - bx, ly = cy - by, len = ck_isqrt((uint64_t)((lx * lx + ly * ly) >> 16)) << 8; + if (len > Q) { + int64_t px = (i << 16) + HALF - bx, py = (j << 16) + HALF - by; + int64_t along = (px * lx + py * ly) / len, across = (px * ly - py * lx) / len; + if (along > 0 && along < len) { + uint32_t near = ck_exp_neg((uint32_t)(across * across * 256 / ((int64_t)R * R))); + int64_t k = (int64_t)near * wl >> 8; + ax += (lx * Q / len * (Q / 2) >> 16) * k >> 16; + ay += (ly * Q / len * (Q / 2) >> 16) * k >> 16; + } + } + } + (void)ws; /* speaking pushes in rings as the words come (ck_flow_word) */ + f->u[IX(i, j)] += (int32_t)(ax * (int64_t)dt_ms / 1000); + f->v[IX(i, j)] += (int32_t)(ay * (int64_t)dt_ms / 1000); + } + /* ink from the heart: a trickle when idle, a stream when speaking */ + int32_t ink = (int32_t)(((int64_t)(wi * 6 + wl * 10 + ws * 60) * dt_ms) >> 8); + if (ink) + push(f, cx, cy, 0, 0, ink, R); + /* thinking: the ink wells up round him, where the vortex carries it, not under his own light */ + int32_t think_ink = (int32_t)(((int64_t)wt * 120 * deep / 256 * dt_ms) >> 8); + if (think_ink) + for (int k = 0; k < 8; k++) { + uint32_t a = (uint32_t)(f->t * 65536 / 9000) + (uint32_t)k * 8192; + push(f, cx + (int32_t)((int64_t)ck_cos(a) * 3 * R / 2 >> 14), cy + (int32_t)((int64_t)ck_sin(a) * 3 * R / 2 >> 14), 0, 0, + think_ink, R / 2); + } + /* a few motes of ink drift in from nowhere while he is awake, so the water is never empty */ + if ((wi || wl) && (rnd(f) & 15) == 0) + push(f, Q + (int32_t)(rnd(f) % (uint32_t)(W * Q)), Q + (int32_t)(rnd(f) % (uint32_t)(H * Q)), 0, 0, + Q / 40, R / 2); +} + +static void fade(int32_t *x, int32_t per_ms, uint32_t dt_ms) +{ + int32_t k = (int32_t)ck_min(Q, (int32_t)(per_ms * dt_ms)); + for (size_t i = 0; i < CK_FLOW_CELLS; i++) + x[i] -= mul(x[i], k); +} + +static void step(ck_flow *f, uint32_t dt_ms) +{ + int32_t dt = (int32_t)((dt_ms << 16) / 1000); + for (int m = 0; m < 5; m++) { /* the modes' weights ease toward where they should be */ + uint32_t want = m == f->mode ? 256 : 0, cur = f->weight[m], stepw = 256 * dt_ms / BLEND_MS; + stepw = stepw ? stepw : 1; + f->weight[m] = cur < want ? ck_min((int32_t)want, (int32_t)(cur + stepw)) + : ck_max((int32_t)want, (int32_t)cur - (int32_t)stepw); + } + forces(f, dt_ms); + /* velocity */ + copy_field(f->u0, f->u); + copy_field(f->v0, f->v); + diffuse(f->u, f->u0, (int32_t)(VISC_PER_MS * dt_ms), 1); + diffuse(f->v, f->v0, (int32_t)(VISC_PER_MS * dt_ms), 2); + project(f->u, f->v, f->u0, f->v0); + copy_field(f->u0, f->u); + copy_field(f->v0, f->v); + advect(f->u, f->u0, f->u0, f->v0, dt, 1); + advect(f->v, f->v0, f->u0, f->v0, dt, 2); + project(f->u, f->v, f->u0, f->v0); + /* ink */ + copy_field(f->d0, f->d); + diffuse(f->d, f->d0, (int32_t)(INK_PER_MS * dt_ms), 0); + copy_field(f->d0, f->d); + advect(f->d, f->d0, f->u, f->v, dt, 0); + uint32_t still = f->weight[CK_FLOW_SLEEP]; /* asleep the ink goes faster */ + fade(f->d, INK_FADE_PER_MS + (int32_t)(INK_FADE_PER_MS * 3 * still >> 8), dt_ms); + fade(f->u, VEL_FADE_PER_MS, dt_ms); + fade(f->v, VEL_FADE_PER_MS, dt_ms); + /* how fast each cell moves, for the colour: 2 cells per second and up is fully warm */ + for (size_t i = 0; i < CK_FLOW_CELLS; i++) { + int64_t s2 = ((int64_t)f->u[i] * f->u[i] + (int64_t)f->v[i] * f->v[i]) >> 16; + uint32_t s = (uint32_t)ck_isqrt((uint64_t)s2) << 8; /* 16.16 cells per second */ + uint32_t warm = s >= 2 * Q ? 256 : s * 256 / (2 * Q); + f->warm[i] = (uint16_t)(f->warm[i] + ((int32_t)warm - (int32_t)f->warm[i]) * (int32_t)dt_ms / 250); + } + f->steps++; +} + +/* ---- the interface ---- */ + +void ck_flow_init(ck_flow *f, int32_t w, int32_t h, int32_t cx, int32_t cy, int32_t R, int32_t bx, int32_t by, + uint32_t t) +{ + *f = (ck_flow){0}; + f->w = w, f->h = h; + f->cw = ck_max(256, w * 256 / W); + f->ch = ck_max(256, h * 256 / H); + f->cx = cx, f->cy = cy, f->R = R, f->bx = bx, f->by = by; + f->t = f->stepped = t; + f->mode = CK_FLOW_SLEEP; /* still water until he is awake */ + f->weight[CK_FLOW_SLEEP] = 256; + f->rng = 0x9e3779b9u ^ (uint32_t)t; +} + +void ck_flow_mode(ck_flow *f, int mode, uint32_t t) +{ + if (mode < 0 || mode > CK_FLOW_SLEEP || mode == f->mode) + return; + f->mode = mode; + f->think_t = mode == CK_FLOW_THINK ? (t ? t : 1) : 0; +} + +void ck_flow_key(ck_flow *f, uint32_t t) +{ + f->key_t = t; + int32_t gx = cell_x(f, f->bx), gy = cell_y(f, f->by); + int32_t lx = cell_x(f, f->cx) - gx, ly = cell_y(f, f->cy) - gy; + int64_t len = ck_isqrt((uint64_t)(((int64_t)lx * lx + (int64_t)ly * ly) >> 16)) << 8; + if (len < Q) + len = Q; + int32_t speed = 5 * Q / 2; /* cells per second, toward Allen */ + push(f, gx, gy, (int32_t)((int64_t)lx * speed / len), (int32_t)((int64_t)ly * speed / len), Q / 2, Q); +} + +void ck_flow_word(ck_flow *f, uint32_t t) +{ + f->word_t = t; + int32_t cx = cell_x(f, f->cx), cy = cell_y(f, f->cy); + int32_t R = ck_max(Q / 2, (int32_t)(((int64_t)f->R << 24) / f->cw)); + for (unsigned k = 0; k < 12; k++) { /* a ring of twelve pushes, outward */ + uint32_t a = k * 65536 / 12 + (rnd(f) & 2047); + int32_t ux = ck_cos(a) << 2, uy = ck_sin(a) << 2; /* unit, 16.16 */ + push(f, cx + (int32_t)((int64_t)ux * R / 2 >> 16), cy + (int32_t)((int64_t)uy * R / 2 >> 16), + (int32_t)((int64_t)ux * (3 * Q / 2) >> 16), (int32_t)((int64_t)uy * (3 * Q / 2) >> 16), Q / 6, R / 2); + } +} + +void ck_flow_touch(ck_flow *f, int32_t px, int32_t py, int32_t vx, int32_t vy, int32_t ink, int32_t r) +{ + push(f, cell_x(f, px), cell_y(f, py), cells_x(f, vx), cells_y(f, vy), ink, + ck_max(Q / 4, (int32_t)(((int64_t)r << 24) / f->cw))); +} + +void ck_flow_at(ck_flow *f, uint32_t t) +{ + f->t = t; + /* Catch up in fixed steps; after a long gap (the frame core was resting) start from now. */ + if (t - f->stepped > 8 * CK_FLOW_STEP_MS) + f->stepped = t - 8 * CK_FLOW_STEP_MS; + while (t - f->stepped >= CK_FLOW_STEP_MS) { + f->stepped += CK_FLOW_STEP_MS; + step(f, CK_FLOW_STEP_MS); + } +} + +void ck_flow_velocity(const ck_flow *f, int32_t px, int32_t py, int32_t *vx, int32_t *vy) +{ + int32_t gx = cell_x(f, px), gy = cell_y(f, py); + *vx = (int32_t)(((int64_t)sample(f->u, gx, gy) * f->cw) >> 24); + *vy = (int32_t)(((int64_t)sample(f->v, gx, gy) * f->ch) >> 24); +} + +void ck_flow_mark(ck_flow *f, void (*mark)(ck_rect)) +{ + for (int32_t j = 0; j <= H + 1; j++) + for (int32_t i = 0; i <= W + 1; i++) { + int32_t now = f->d[IX(i, j)], was = f->shown[IX(i, j)]; + int32_t warm = f->warm[IX(i, j)], warm_was = f->shown_warm[IX(i, j)]; + if (ck_abs(now - was) < Q / 400 && (now < Q / 200 || ck_abs(warm - warm_was) < 24)) + continue; + f->shown[IX(i, j)] = now; + f->shown_warm[IX(i, j)] = (uint16_t)warm; + /* the cell and one cell round it (the interpolation reaches that far) */ + ck_rect r = {(int32_t)(((int64_t)(i - 2) * f->cw) >> 8), (int32_t)(((int64_t)(j - 2) * f->ch) >> 8), + (int32_t)((3 * (int64_t)f->cw >> 8) + 2), (int32_t)((3 * (int64_t)f->ch >> 8) + 2)}; + mark(r); + } +} + +void ck_flow_draw(const ck_flow *f, ck_canvas *out, const ck_rect *r, uint32_t gain) +{ + ck_rect c = *r; + ck_rect all = {0, 0, out->w, out->h}; + if (!ck_clip(&c, &all)) + return; + const uint32_t cool = CK_RGB(64, 86, 196), warm = CK_RGB(255, 228, 196); + int64_t dgx = ((int64_t)1 << 24) / f->cw, dgy = ((int64_t)1 << 24) / f->ch; /* grid per pixel, 16.16 */ + int64_t gy = cell_y(f, c.y); + for (int32_t y = c.y; y < c.y + c.h; y++, gy += dgy) { + uint32_t *px = out->px + (size_t)y * (size_t)out->w; + int64_t gx = cell_x(f, c.x); + for (int32_t x = c.x; x < c.x + c.w; x++, gx += dgx) { + int32_t ink = sample(f->d, (int32_t)gx, (int32_t)gy); + if (ink < Q / 512) + continue; + uint32_t a = (uint32_t)(((int64_t)ink * gain) >> 16); + a = a > 230 ? 230 : a; + /* the colour: still water deep blue, moving water lit from within */ + int32_t gxx = ck_clamp((int32_t)gx - HALF, 0, (W + 1) * Q - 1), gyy = ck_clamp((int32_t)gy - HALF, 0, (H + 1) * Q - 1); + uint32_t w = f->warm[IX(gxx >> 16, gyy >> 16)]; + uint32_t col = ck_mix(cool, warm, w); + px[x] = ck_add(px[x], col, a); + } + } +} + +int64_t ck_flow_ink(const ck_flow *f) +{ + int64_t s = 0; + for (size_t i = 0; i < CK_FLOW_CELLS; i++) + s += f->d[i]; + return s; +} diff --git a/om/allen-scene/native/flow.h b/om/allen-scene/native/flow.h new file mode 100644 index 0000000..b29db82 --- /dev/null +++ b/om/allen-scene/native/flow.h @@ -0,0 +1,76 @@ +/* flow.h -- Allen's ink: a fluid that fills the screen around him. + * + * The whole screen is a shallow tank of water with a little luminous ink in + * it. What Allen does moves the water, and the ink shows the movement: + * idle a slow warm current turns round him, the ink drifts and thins. + * listening every key typed drops ink at the bar and lifts it toward him; + * the line you type flows up into him before he answers. + * thinking the water round him turns into a vortex, ink streams out of + * his heart along it; the longer he thinks, the deeper it turns. + * speaking each word pushes a ring of water out from the heart. + * asleep nothing pushes; the water stills and the ink fades. + * No state is ever cut to: forces ease in and out, and the water carries + * everything that was moving on until it settles. + * + * The solver is Stam's stable fluid (Jos Stam, "Real-Time Fluid Dynamics for + * Games", GDC 2003; "Stable Fluids", SIGGRAPH 1999): add sources, diffuse, + * move along the flow (semi-Lagrangian), make the velocity divergence free + * (a Gauss-Seidel pressure solve). It never blows up whatever the time step, + * which is what a screen that must never stutter needs. Everything is + * integer: cells, velocities and ink in 16.16 fixed point, on a coarse grid + * (CK_FLOW_W x CK_FLOW_H cells over the screen), drawn with bilinear + * interpolation so the ink has no edges. Freestanding, no allocation (the + * fields live in the struct), host tested in ui/tests/allen_ui_test.c. + * ck_flow_at moves it on (one caller); ck_flow_draw only reads, so several + * cores can draw different parts of the screen at once. */ +#ifndef AIENOS_FLOW_H +#define AIENOS_FLOW_H +#include +#include +#include "paint.h" + +#define CK_FLOW_W 64u +#define CK_FLOW_H 36u +#define CK_FLOW_CELLS ((CK_FLOW_W + 2u) * (CK_FLOW_H + 2u)) /* with the border cells */ + +enum { CK_FLOW_IDLE, CK_FLOW_LISTEN, CK_FLOW_THINK, CK_FLOW_SPEAK, CK_FLOW_SLEEP }; + +typedef struct { + int32_t w, h; /* the screen, px */ + int32_t cw, ch; /* one cell, 1/256 px (the grid covers the screen exactly) */ + int32_t cx, cy, R; /* Allen's centre and radius, px */ + int32_t bx, by; /* where typed lines start from (the bar), px */ + uint32_t t, stepped; /* now, and the time of the last solver step (ms) */ + int mode; + uint32_t weight[5]; /* how far each mode's pull has eased in, 0..256; they add up */ + uint32_t think_t, word_t, key_t; /* when thinking began (0: not), the last word, the last key */ + uint32_t rng; + /* the fields, 16.16: velocity in cells per second, ink 0..1 */ + int32_t u[CK_FLOW_CELLS], v[CK_FLOW_CELLS], d[CK_FLOW_CELLS]; + int32_t u0[CK_FLOW_CELLS], v0[CK_FLOW_CELLS], d0[CK_FLOW_CELLS]; + int32_t shown[CK_FLOW_CELLS]; /* the ink each cell showed at the last mark */ + uint16_t warm[CK_FLOW_CELLS]; /* how fast the water moves in each cell, 0..256, for the colour */ + uint16_t shown_warm[CK_FLOW_CELLS]; + uint32_t steps; +} ck_flow; + +/* The screen w x h, Allen at (cx, cy) with radius R, the bar's mouth at (bx, by). */ +void ck_flow_init(ck_flow *f, int32_t w, int32_t h, int32_t cx, int32_t cy, int32_t R, int32_t bx, int32_t by, + uint32_t t); +void ck_flow_mode(ck_flow *f, int mode, uint32_t t); +void ck_flow_key(ck_flow *f, uint32_t t); /* a key was typed: a drop at the bar, lifted toward Allen */ +void ck_flow_word(ck_flow *f, uint32_t t); /* a word was spoken: a ring from the heart */ +/* A push at (px, py): velocity (vx, vy) in px per second and ink (0..65536) over radius r px. */ +void ck_flow_touch(ck_flow *f, int32_t px, int32_t py, int32_t vx, int32_t vy, int32_t ink, int32_t r); +/* Moves the water to time t (ms); the solver steps at most every CK_FLOW_STEP_MS). */ +#define CK_FLOW_STEP_MS 16u +void ck_flow_at(ck_flow *f, uint32_t t); +/* The water's velocity at a point, px per second (for things that float on it). */ +void ck_flow_velocity(const ck_flow *f, int32_t px, int32_t py, int32_t *vx, int32_t *vy); +/* Calls mark(rect) for every cell whose ink changed enough to redraw since the last call. */ +void ck_flow_mark(ck_flow *f, void (*mark)(ck_rect)); +/* The ink into the part r of out (light added). gain scales the brightness (256 = as is). */ +void ck_flow_draw(const ck_flow *f, ck_canvas *out, const ck_rect *r, uint32_t gain); +/* Total ink in the tank, 16.16 (for tests: it rises when touched and fades when left). */ +int64_t ck_flow_ink(const ck_flow *f); +#endif diff --git a/om/allen-scene/native/mind.c b/om/allen-scene/native/mind.c new file mode 100644 index 0000000..427136d --- /dev/null +++ b/om/allen-scene/native/mind.c @@ -0,0 +1,266 @@ +/* mind.c -- Allen's presence; see mind.h. */ +#include "mind.h" + +#define S(v) ((int32_t)(((int64_t)(v) * (int64_t)m->k + 128) / 256)) +#define INNER 24u /* the last INNER points sit inside the sphere */ +#define TILT 3641u /* the upright axis leans toward the viewer by 20 degrees, in 65536ths */ + +static uint32_t rnd(ck_mind *m) +{ + m->rng ^= m->rng << 13; + m->rng ^= m->rng >> 17; + m->rng ^= m->rng << 5; + return m->rng; +} + +static int64_t dist2(const int16_t *a, const int16_t *b) +{ + int64_t dx = a[0] - b[0], dy = a[1] - b[1], dz = a[2] - b[2]; + return dx * dx + dy * dy + dz * dz; +} + +static int has_edge(const ck_mind *m, unsigned a, unsigned b) +{ + for (unsigned i = 0; i < m->ne; i++) + if ((m->ea[i] == a && m->eb[i] == b) || (m->ea[i] == b && m->eb[i] == a)) + return 1; + return 0; +} + +void ck_mind_init(ck_mind *m, int32_t cx, int32_t cy, uint32_t k, uint32_t born) +{ + *m = (ck_mind){0}; + m->cx = cx, m->cy = cy, m->k = k, m->born = born; + m->R = S(118); + m->rng = 0x9e3779b9u; + m->spin = 349; /* a turn in 48 s */ + unsigned outer = CK_MIND_NODES - INNER; + for (unsigned i = 0; i < CK_MIND_NODES; i++) { + int64_t y, rr, x, z, len; + if (i < outer) { /* evenly spread over the sphere: a Fibonacci lattice */ + y = 16384 - (int64_t)(2 * i + 1) * 16384 / outer; + rr = (int64_t)ck_isqrt((uint64_t)(16384 * 16384 - y * y)); + uint32_t th = (uint32_t)(i * 25033u); /* the golden angle */ + x = rr * ck_cos(th) >> 14, z = rr * ck_sin(th) >> 14; + len = 16384 - 2950 + (int64_t)(ck_hash((int32_t)i, 1, 31) % 5900u); /* +-18%: a cloud, not a ball */ + } else { + uint32_t h1 = ck_hash((int32_t)i, 2, 31), h2 = ck_hash((int32_t)i, 3, 31); + y = 16384 - (int64_t)(h1 % 32768u); + rr = (int64_t)ck_isqrt((uint64_t)(16384 * 16384 - y * y)); + x = rr * ck_cos(h2) >> 14, z = rr * ck_sin(h2) >> 14; + len = 4915 + (int64_t)(ck_hash((int32_t)i, 4, 31) % 5734u); /* 0.30 .. 0.65 */ + } + m->home[i][0] = (int16_t)(x * len >> 14); + m->home[i][1] = (int16_t)(y * len >> 14); + m->home[i][2] = (int16_t)(z * len >> 14); + } + /* each point joined to its nearest two (the inner ones to three) */ + for (unsigned i = 0; i < CK_MIND_NODES; i++) { + unsigned want = i < outer ? 2 : 3; + for (unsigned w = 0; w < want; w++) { + int best = -1; + int64_t bd = 0; + for (unsigned j = 0; j < CK_MIND_NODES; j++) { + if (j == i || has_edge(m, i, j)) + continue; + int64_t d = dist2(m->home[i], m->home[j]); + if (best < 0 || d < bd) + best = (int)j, bd = d; + } + if (best >= 0 && m->ne < CK_MIND_EDGES) + m->ea[m->ne] = (uint8_t)i, m->eb[m->ne] = (uint8_t)best, m->ne++; + } + } +} + +void ck_mind_mode(ck_mind *m, int mode, uint32_t t) +{ + (void)t; + m->mode = mode; +} + +static void push(uint32_t *ring, uint32_t t) +{ + for (unsigned i = 3; i > 0; i--) + ring[i] = ring[i - 1]; + ring[0] = t ? t : 1; +} + +void ck_mind_word(ck_mind *m, uint32_t t) { push(m->words, t); } +void ck_mind_key(ck_mind *m, uint32_t t) { push(m->keys, t); } +void ck_mind_voice(ck_mind *m, uint32_t level) { m->voice = level > 256 ? 256 : level; } + +static void spark(ck_mind *m, unsigned from) +{ + if (m->nspark >= CK_MIND_SPARKS || !m->ne) + return; + /* a thread leaving `from`, or any thread when from is out of range */ + unsigned e = rnd(m) % m->ne, tries = 0; + if (from < CK_MIND_NODES) + while (m->ea[e] != from && m->eb[e] != from && tries++ < m->ne) + e = (e + 1) % m->ne; + unsigned s = m->nspark++; + m->spark[s].e = (uint16_t)e; + m->spark[s].back = (uint8_t)(from < CK_MIND_NODES ? m->eb[e] == from : rnd(m) & 1); + m->spark[s].t0 = m->t; + m->spark[s].dur = (uint16_t)(m->mode == CK_MIND_THINK ? 240 + rnd(m) % 260 : 420 + rnd(m) % 480); +} + +static uint32_t toward(uint32_t cur, uint32_t want, uint32_t dt, uint32_t ms) +{ + int64_t d = (int64_t)want - cur, step = d * (int64_t)(dt < ms ? dt : ms) / (int64_t)ms; + if (step == 0 && d && dt) + step = d > 0 ? 1 : -1; + return (uint32_t)((int64_t)cur + step); +} + +static uint32_t pulse(int32_t off, int32_t width) /* (1 - (off/width)^2)^2, 0..256 */ +{ + if (off <= -width || off >= width) + return 0; + int64_t q = 256 - (int64_t)off * off * 256 / ((int64_t)width * width); + return (uint32_t)(q * q >> 8); +} + +void ck_mind_at(ck_mind *m, uint32_t t) +{ + uint32_t dt = t > m->t ? t - m->t : 0; + if (dt > 250) + dt = 250; /* a long pause is not a jump */ + m->t = t; + m->was = m->box; + if (t < m->born) { + m->alpha = 0; + m->box = (ck_rect){0, 0, 0, 0}; + return; + } + static const uint32_t spins[4] = {349, 520, 1400, 600}, squeezes[4] = {0, 4, 16, 0}, hearts[4] = {50, 70, 120, 80}, + rates[4] = {2, 6, 25, 12}; + int md = m->mode & 3; + m->spin = toward(m->spin, spins[md], dt, 700); + m->squeeze = toward(m->squeeze, squeezes[md], dt, 500); + uint32_t want_heart = hearts[md] + (md == CK_MIND_SPEAK ? m->voice * 120 / 256 : 0); + if (md == CK_MIND_THINK) + want_heart += (uint32_t)(16384 + ck_sin(t * 65536u / 900u)) * 30 >> 15; + m->heart = toward(m->heart, want_heart, dt, md == CK_MIND_SPEAK ? 80 : 400); + m->angle += m->spin * dt; + + /* sparks: born at the mode's rate; each that arrives lights its point, and while thinking may go on */ + uint32_t form = (uint32_t)ck_prog(t, m->born, m->born + CK_MIND_FORM_MS); + if (form >= 192) { + m->spawn += rates[md] * dt; + while (m->spawn >= 1000) { + m->spawn -= 1000; + spark(m, CK_MIND_NODES); + } + } + for (unsigned i = 0; i < m->nspark;) { + uint32_t age = t - m->spark[i].t0; + if (age < m->spark[i].dur) { + i++; + continue; + } + unsigned e = m->spark[i].e, to = m->spark[i].back ? m->ea[e] : m->eb[e]; + m->act[to] = 256; + m->spark[i] = m->spark[--m->nspark]; + if (md == CK_MIND_THINK ? rnd(m) % 100 < 70 : rnd(m) % 100 < 18) + spark(m, to); + } + for (unsigned i = 0; i < CK_MIND_NODES; i++) + m->act[i] = (uint16_t)(m->act[i] * (uint32_t)ck_exp_neg(dt * 256 / 260) >> 16); + + /* the shape: breathing, drawn in while thinking, and while being born gathered in from far out */ + int64_t scale = 65536 + ((int64_t)ck_sin(t * 65536u / 5500u) * 1966 >> 14) - (int64_t)m->squeeze * 65536 / 256; + uint32_t gather = ck_ease_out((int32_t)form); + scale = scale * (256 + (int64_t)(256 - gather) * 560 / 256) >> 8; /* 3.2 times out at the start */ + uint32_t swirl = (256 - gather) * (256 - gather) >> 8; /* an extra spiral turn that unwinds as it gathers */ + m->alpha = ck_smooth((int32_t)form * 3); + uint32_t a = (m->angle >> 8) + swirl * 256; + int64_t ca = ck_cos(a), sa = ck_sin(a), ct = ck_cos(TILT), st = ck_sin(TILT); + int64_t R16 = (int64_t)m->R * 16; + int32_t x0 = m->cx * 16, x1 = x0, y0 = m->cy * 16, y1 = y0; + for (unsigned i = 0; i < CK_MIND_NODES; i++) { + int64_t x = m->home[i][0], y = m->home[i][1], z = m->home[i][2]; + int64_t rx = (x * ca - z * sa) >> 14, rz = (x * sa + z * ca) >> 14; /* turn about the upright axis */ + int64_t ry = (y * ct - rz * st) >> 14, fz = (y * st + rz * ct) >> 14; /* lean toward the viewer */ + int64_t persp = 16384 + fz * 3 / 16; /* nearer is a little larger */ + m->px[i] = (int32_t)(m->cx * 16 + 8 + (rx * persp >> 14) * R16 / 16384 * scale / 65536); + m->py[i] = (int32_t)(m->cy * 16 + 8 + (ry * persp >> 14) * R16 / 16384 * scale / 65536); + uint32_t nr = (uint32_t)((fz + 16384) * 256 / 32768); + m->near[i] = (uint16_t)(nr > 256 ? 256 : nr); + /* light from the pulses: words outward from the heart, keys upward from below */ + int64_t rad = (int64_t)ck_isqrt((uint64_t)(x * x + y * y + z * z)) * 256 / 16384; + uint32_t extra = 0; + for (unsigned w = 0; w < 4; w++) { + if (m->words[w] && t - m->words[w] < 900) { + uint32_t age = t - m->words[w]; + extra += pulse((int32_t)rad - (int32_t)(age * 300 / 600), 70) * (900 - age) / 900 * 150 >> 8; + } + if (m->keys[w] && t - m->keys[w] < 600) { + uint32_t age = t - m->keys[w]; + int32_t ky = 300 - (int32_t)(age * 600 / 500), ny = (int32_t)(y * 256 / 16384); + extra += pulse(ny - ky, 60) * (600 - age) / 600 * 90 >> 8; + } + } + uint32_t l = 34 + m->near[i] * m->near[i] / 256 * 180 / 256 + extra + m->act[i] * 120 / 256; + m->lum[i] = (uint16_t)(l > 256 ? 256 : l); + x0 = ck_min(x0, m->px[i]), x1 = ck_max(x1, m->px[i]); + y0 = ck_min(y0, m->py[i]), y1 = ck_max(y1, m->py[i]); + } + m->hx = m->cx * 16 + 8, m->hy = m->cy * 16 + 8; + m->hr = (int32_t)(R16 * 52 / 100 * scale / 65536); + int32_t halo = (int32_t)(R16 * 17 / 10 * ck_min((int32_t)(scale >> 8), 256) / 256); + int32_t pad = S(8) * 16; + x0 = ck_min(x0 - pad, m->hx - halo), x1 = ck_max(x1 + pad, m->hx + halo); + y0 = ck_min(y0 - pad, m->hy - halo), y1 = ck_max(y1 + pad, m->hy + halo); + m->box = (ck_rect){(x0 >> 4) - 1, (y0 >> 4) - 1, ((x1 - x0) >> 4) + 3, ((y1 - y0) >> 4) + 3}; +} + +ck_rect ck_mind_dirty(const ck_mind *m) { return ck_union(m->was, m->box); } + +void ck_mind_draw(const ck_mind *m, ck_canvas *out, const ck_rect *r) +{ + if (!m->alpha || !ck_meets(m->box, r)) + return; + uint32_t A = m->alpha, form = (uint32_t)ck_prog(m->t, m->born, m->born + CK_MIND_FORM_MS); + int64_t R16 = (int64_t)m->R * 16; + /* the halo: a faint blue light round the whole mind, swelling a little with the heart */ + ck_glow(out, r, m->hx, m->hy, (int32_t)(R16 * 17 / 10), CK_RGB(60, 74, 210), (52 + m->heart / 8) * A >> 8); + ck_glow(out, r, m->hx, m->hy, (int32_t)R16, CK_RGB(112, 92, 255), (30 + m->heart / 8) * A >> 8); + /* the threads, fading in once the points have mostly gathered */ + uint32_t ta = ck_smooth(((int32_t)form - 128) * 2) * A >> 8; + if (ta) + for (unsigned i = 0; i < m->ne; i++) { + unsigned a = m->ea[i], b = m->eb[i]; + uint32_t a0 = (m->lum[a] * (16u + m->near[a] * 60u / 256u) >> 8) * ta >> 8, + a1 = (m->lum[b] * (16u + m->near[b] * 60u / 256u) >> 8) * ta >> 8; + ck_thread(out, r, m->px[a], m->py[a], m->px[b], m->py[b], CK_RGB(120, 140, 255), a0, a1); + if (m->k > 320) /* a second strand on big screens, so the thread keeps its weight */ + ck_thread(out, r, m->px[a], m->py[a] + 16, m->px[b], m->py[b] + 16, CK_RGB(120, 140, 255), a0 / 2, + a1 / 2); + } + /* the points: pale blue-white, warming as they light */ + for (unsigned i = 0; i < CK_MIND_NODES; i++) { + int32_t rad = (int32_t)((int64_t)S(3) * 16 * (160 + m->near[i] * 120 / 256) >> 8); + uint32_t c = ck_mix(CK_RGB(206, 222, 255), CK_RGB(255, 214, 160), m->act[i]); + ck_glow(out, r, m->px[i], m->py[i], rad * 3, c, (m->lum[i] * 50 >> 8) * A >> 8); + ck_glow(out, r, m->px[i], m->py[i], rad, c, m->lum[i] * A >> 8); + } + /* the sparks, each with a short fading tail */ + for (unsigned i = 0; i < m->nspark; i++) { + unsigned e = m->spark[i].e, a = m->ea[e], b = m->eb[e]; + if (m->spark[i].back) + a = m->eb[e], b = m->ea[e]; + int32_t f = (int32_t)((m->t - m->spark[i].t0) * 256u / m->spark[i].dur); + for (int k = 0; k < 3; k++) { + int32_t g = ck_clamp(f - k * 22, 0, 256); + int32_t x = m->px[a] + (int32_t)((int64_t)(m->px[b] - m->px[a]) * g >> 8); + int32_t y = m->py[a] + (int32_t)((int64_t)(m->py[b] - m->py[a]) * g >> 8); + ck_glow(out, r, x, y, S(5) * 16 - k * S(1) * 16, CK_RGB(255, 222, 176), (200 >> k) * A >> 8); + } + } + /* the heart: a warm light at the centre, and a small bright core */ + ck_glow(out, r, m->hx, m->hy, m->hr, CK_RGB(255, 210, 170), m->heart * 7 / 10 * A >> 8); + ck_glow(out, r, m->hx, m->hy, m->hr * 2 / 5, CK_RGB(255, 236, 214), (90 + m->heart) * A >> 8); + ck_glow(out, r, m->hx, m->hy, m->hr / 8, CK_RGB(255, 250, 240), 230 * A >> 8); +} diff --git a/om/allen-scene/native/mind.h b/om/allen-scene/native/mind.h new file mode 100644 index 0000000..ad99036 --- /dev/null +++ b/om/allen-scene/native/mind.h @@ -0,0 +1,76 @@ +/* mind.h -- Allen's presence: no face and no body, a mind drawn as light. + * + * About a hundred points of light sit on and inside a sphere, joined by fine + * threads into a network, turning slowly in three dimensions round a warm + * heart. Small sparks run along the threads from point to point; each one + * that arrives lights its point for a moment. How it moves is how Allen is: + * idle it breathes (a slow swell) and turns slowly; a few sparks. + * listening each key typed sends a soft wave of light up through it. + * thinking it draws in a little, turns faster, the heart brightens and + * sparks cascade through the whole network. + * speaking every word sends a pulse out from the heart, and the heart + * follows the voice. + * It is born from the light of the black holes' merger: the points start + * scattered wide and gather, spiralling, into the network. + * + * Integer only, freestanding. ck_mind_at moves it to a time (one caller); + * ck_mind_draw then only reads, so several processor cores can draw + * different parts of the screen at once. Host tested in + * ui/tests/allen_ui_test.c. */ +#ifndef AIENOS_MIND_H +#define AIENOS_MIND_H +#include +#include + +#include "paint.h" + +#define CK_MIND_NODES 120u +#define CK_MIND_EDGES 300u +#define CK_MIND_SPARKS 64u +#define CK_MIND_FORM_MS 3000u /* from born to fully gathered */ + +enum { CK_MIND_IDLE, CK_MIND_LISTEN, CK_MIND_THINK, CK_MIND_SPEAK }; + +typedef struct { + /* the shape, fixed at init */ + int32_t cx, cy, R; /* px */ + uint32_t k; + int16_t home[CK_MIND_NODES][3]; /* unit sphere, Q14 */ + uint8_t ea[CK_MIND_EDGES], eb[CK_MIND_EDGES]; + unsigned ne; + uint32_t born; /* ms */ + /* how it is, moved on by ck_mind_at */ + uint32_t t, rng, spawn; + int mode; + uint32_t angle; /* the turn so far, 1/256 of a 65536th */ + uint32_t spin, squeeze; /* eased toward the mode's: per-ms turn (same units), and 0..256 drawn in */ + uint32_t heart, voice; /* 0..256 */ + uint32_t words[4], keys[4]; /* when the last pulses began (ms; 0 none) */ + uint16_t act[CK_MIND_NODES]; /* how lit each point is, 0..256 */ + struct { + uint16_t e, dur; + uint8_t back; /* runs eb to ea */ + uint32_t t0; + } spark[CK_MIND_SPARKS]; + unsigned nspark; + /* the frame, worked out by ck_mind_at for ck_mind_draw */ + int32_t px[CK_MIND_NODES], py[CK_MIND_NODES]; /* 16ths of a pixel */ + uint16_t lum[CK_MIND_NODES], near[CK_MIND_NODES]; /* brightness 0..256; nearness 0..256 */ + uint32_t alpha; /* the whole figure, 0..256 */ + int32_t hx, hy, hr; /* the heart: 16ths of a pixel */ + ck_rect box, was; /* where it is now, and was the frame before */ +} ck_mind; + +/* (cx, cy) its centre, px; k the scale (1/256 px per design px); born the + * time it starts to gather (ms). */ +void ck_mind_init(ck_mind *m, int32_t cx, int32_t cy, uint32_t k, uint32_t born); +void ck_mind_mode(ck_mind *m, int mode, uint32_t t); +void ck_mind_word(ck_mind *m, uint32_t t); /* a word was spoken */ +void ck_mind_key(ck_mind *m, uint32_t t); /* a key was typed */ +void ck_mind_voice(ck_mind *m, uint32_t level); /* 0..256 */ +void ck_mind_at(ck_mind *m, uint32_t t); +/* The figure into the part r of out (light added). */ +void ck_mind_draw(const ck_mind *m, ck_canvas *out, const ck_rect *r); +/* What needs redrawing for this frame: where it was and where it is. */ +ck_rect ck_mind_dirty(const ck_mind *m); +#endif diff --git a/om/allen-scene/native/night.c b/om/allen-scene/native/night.c new file mode 100644 index 0000000..78b0c14 --- /dev/null +++ b/om/allen-scene/native/night.c @@ -0,0 +1,780 @@ +/* night.c -- the night sky and the merging black holes; see night.h. + * + * The sky is the real one (ui/sky_real.c, from ui/sky_data.c): the + * Milky Way from a photograph of the whole sky, worked out at a quarter of + * the screen's resolution (it is smooth anyway; the photograph's own + * stars are taken out), scaled up with a 4 x 4 ordered dither so the faint + * gradients show no bands; then the catalogue's stars, at full resolution, + * on top. + * + * Bent light: a point mass moves the image of a star seen at angle theta + * from it to where the star really is, beta = theta - E^2 / theta (E the + * Einstein radius). Each pixel shows the sky at its own beta (with both + * holes' pulls added), so stars behind a hole stretch into arcs round it and + * a second, inner image appears on the far side. The pull is eased to zero + * between 2.2 E and 4.4 E so the bent region has no edge. It is worked out + * exactly near the holes and on an 8-pixel grid (and interpolated) further + * out, where it is smooth. The ripple adds a displacement along the radius + * that stretches one way and squeezes the other (cos 2 theta), the pattern + * a gravitational wave makes. */ +#include "night.h" +#include "sky_real.h" + +#define S(v) ((int32_t)(((int64_t)(v) * (int64_t)n->k + 128) / 256)) +#define Q30 (1ull << 30) + +/* ---- the galaxies: the real ones in the view (sky_real.c) ---- */ + +static uint8_t band_t[256]; /* the sweeping band: ((1 + cos) / 2)^6, 0..255 */ +static uint32_t pow2_t[257]; /* 2^(k/256), Q16: for the dusk's distances without a square root per pixel */ + +static uint64_t pow2_q16(uint32_t x) /* 2^(x / 65536), Q16; x below 40 << 16 */ +{ + uint32_t n = x >> 16, f = x & 65535u, k = f >> 8, g = f & 255u; + uint64_t m = pow2_t[k] + ((uint64_t)(pow2_t[k + 1] - pow2_t[k]) * g >> 8); + return m << n; +} + +size_t ck_night_mem_bytes(uint32_t w, uint32_t h, uint32_t k) +{ + (void)k; + size_t n = (size_t)w * h * 4 + (size_t)(w / 4 + 1) * (h / 4 + 1) + 64; + for (unsigned i = 0; i < CK_NIGHT_GALAXIES; i++) { + ck_rect b = ck_sky_galaxy_bound(w, i); + n += (size_t)b.w * (size_t)b.h * 2; + } + return n; +} + +/* exp(-(v / width)^2), Q16 */ +static uint32_t gauss(int64_t v, int64_t width) /* exp(-(v/width)^2), Q16 */ +{ + int64_t q = v * 256 / (width ? width : 1); + if (q > 4095 || q < -4095) + return 0; + return ck_exp_neg((uint32_t)(q * q >> 8)); +} + +/* ---- the soft layer (the Milky Way): a quarter of the resolution, 16ths of a level ---- */ + +static void scale_up(ck_night *n, const uint16_t *q, int32_t qw) +{ + static const uint8_t bayer[16] = {0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5}; + for (int32_t y = 0; y < n->h; y++) { + int32_t qy = y >> 2, fy = y & 3; + const uint16_t *r0 = q + (size_t)qy * (size_t)qw * 3, *r1 = r0 + (size_t)qw * 3; + uint32_t *row = n->sky + (size_t)y * (size_t)n->w; + for (int32_t x = 0; x < n->w; x++) { + int32_t qx = x >> 2, fx = x & 3; + uint32_t d = bayer[(y & 3) * 4 + (x & 3)], c = 0; + for (int k = 0; k < 3; k++) { + uint32_t a = r0[qx * 3 + k] * (uint32_t)(4 - fx) + r0[qx * 3 + 3 + k] * (uint32_t)fx; + uint32_t b = r1[qx * 3 + k] * (uint32_t)(4 - fx) + r1[qx * 3 + 3 + k] * (uint32_t)fx; + uint32_t v = ((a * (uint32_t)(4 - fy) + b * (uint32_t)fy) / 16 + d) >> 4; + c = c << 8 | (v > 255 ? 255u : v); + } + row[x] = c; + } + } +} + +/* ---- coming out of the dark ---- */ + +static void appear_map(ck_night *n) +{ + int32_t ah = n->h / 4 + 1; + int64_t far = 0; + int32_t cs[4][2] = {{0, 0}, {n->w, 0}, {0, n->h}, {n->w, n->h}}; + for (int i = 0; i < 4; i++) { + int64_t dx = cs[i][0] - n->cx, dy = cs[i][1] - n->cy, d = (int64_t)ck_isqrt((uint64_t)(dx * dx + dy * dy)); + far = d > far ? d : far; + } + for (int32_t y = 0; y < ah; y++) + for (int32_t x = 0; x < n->aw; x++) { + int64_t px = (int64_t)x * 4, py = (int64_t)y * 4, dx = px - n->cx, dy = py - n->cy; + uint32_t a = ck_fbm((int32_t)(px * 640 / n->h), (int32_t)(py * 640 / n->h), 909, 4) >> 8; + uint32_t r = (uint32_t)((int64_t)ck_isqrt((uint64_t)(dx * dx + dy * dy)) * 255 / (far ? far : 1)); + n->appear[(size_t)y * (size_t)n->aw + (size_t)x] = (uint8_t)((a * 6 + r * 4) / 10); + } +} + +uint32_t ck_night_faded(const ck_night *n, int32_t x, int32_t y, uint32_t l) +{ + if (n->t >= CK_NIGHT_FADE_END_MS) + return 256; + x = ck_clamp(x, 0, n->w - 1), y = ck_clamp(y, 0, n->h - 1); + int32_t from = 300 + n->appear[(size_t)(y >> 2) * (size_t)n->aw + (size_t)(x >> 2)] * 12 + (int32_t)(255 - l) * 8; + int32_t dt = (int32_t)n->t - from; + return dt <= 0 ? 0 : dt >= 1365 ? 256 : ck_smooth(dt * 48 >> 8); +} + +static uint32_t fade_px(const ck_night *n, uint32_t c, int32_t x, int32_t y) +{ + uint32_t r = c >> 16 & 255, g = c >> 8 & 255, b = c & 255, l = r > g ? r : g; + l = l > b ? l : b; + uint32_t f = ck_night_faded(n, x, y, l); + return f >= 256 ? c : ck_scale(c, f); +} + +int ck_night_init(ck_night *n, uint32_t w, uint32_t h, uint32_t k, int32_t cx, int32_t cy, void *mem, size_t len, + void *scratch) +{ + if (!mem || !scratch || w < 64 || h < 64 || w > CK_NIGHT_W_MAX || len < ck_night_mem_bytes(w, h, k)) + return -1; + (void)ck_sin(0); /* the tables, before anything else could ask for them */ + for (unsigned i = 0; i < 256; i++) { + uint64_t c = (uint64_t)(16384 + ck_cos(i * 256u)) >> 1; /* Q14 */ + uint64_t c2 = c * c >> 14, c6 = (c2 * c2 >> 14) * c2 >> 14; + band_t[i] = (uint8_t)(c6 * 255 >> 14); + } + uint64_t e2 = 1ull << 30; /* 2^(k/256): one factor of 2^(1/256) (Q30) per step */ + for (unsigned i = 0; i < 256; i++) { + pow2_t[i] = (uint32_t)((e2 + (1u << 13)) >> 14); + e2 = e2 * 1076652777ull >> 30; + } + pow2_t[256] = 131072; + *n = (ck_night){0}; + n->w = (int32_t)w, n->h = (int32_t)h, n->k = k, n->cx = cx, n->cy = cy; + uint8_t *p = mem; + n->sky = (uint32_t *)p; + p += (size_t)w * h * 4; + n->appear = p; + n->aw = (int32_t)(w / 4 + 1); + p += (size_t)(w / 4 + 1) * (h / 4 + 1); + int32_t qw = (int32_t)(w / 4 + 2), qh = (int32_t)(h / 4 + 2); + n->view = ck_sky_the_view; /* default view: GW150914 region */ + ck_sky_milkyway_q(scratch, qw, qh, n->w, cx, cy, &n->view); + scale_up(n, scratch, qw); + ck_canvas cv = {n->sky, n->w, n->h}; + ck_sky_draw_stars(&cv, k, cx, cy, &n->view, n->tw, CK_NIGHT_TWINKLES, &n->ntw); + for (unsigned i = 0; i < CK_NIGHT_GALAXIES; i++) { + ck_night_galaxy *g = &n->gal[i]; + g->box = ck_sky_galaxy_box(w, h, cx, cy, &n->view, i); + g->light = p; + g->phase = p + (size_t)g->box.w * (size_t)g->box.h; + p += (size_t)g->box.w * (size_t)g->box.h * 2; + ck_sky_galaxy_maps(g, i, w, cx, cy, &n->view); + } + appear_map(n); + ck_night_at(n, 0); + return 0; +} + +/* ---- the black holes and the ripple at a time ---- */ + +static uint64_t root8(uint64_t l) /* l^(1/8), Q30 */ +{ + for (int i = 0; i < 3; i++) + l = ck_isqrt(l << 30); + return l; +} + +#define ORBIT_MS 5200u /* one turn of the wide orbit */ + +static uint32_t orbit_angle(uint32_t t, int32_t *sep16, int32_t a0) +{ + uint32_t spiral_from = (CK_NIGHT_SPIRAL_MS - CK_NIGHT_HOLES_MS) * 65536u / ORBIT_MS; + if (t < CK_NIGHT_SPIRAL_MS) { + *sep16 = a0; + return (t - CK_NIGHT_HOLES_MS) * 65536u / ORBIT_MS; + } + uint64_t left = ((uint64_t)(CK_NIGHT_MERGE_MS - t) << 30) / (CK_NIGHT_MERGE_MS - CK_NIGHT_SPIRAL_MS); + uint64_t r = root8(left), r2 = r * r >> 30, r5 = (r2 * r2 >> 30) * r >> 30; + *sep16 = (int32_t)((uint64_t)a0 * r2 >> 30); + /* the spiral's angle carries on at the wide orbit's speed: K (1 - L^(5/8)), K = 8/5 x its turns */ + uint64_t turns = (uint64_t)65536 * 8 * (CK_NIGHT_MERGE_MS - CK_NIGHT_SPIRAL_MS) / (5ull * ORBIT_MS); + return spiral_from + (uint32_t)(turns * (Q30 - r5) >> 30); +} + +void ck_night_at(ck_night *n, uint32_t t) +{ + n->t = t; + n->holes = 0; + n->falling = 0; + n->lens = (ck_rect){0, 0, 0, 0}; + n->ripple_w = 0; + int32_t e_full = S(60) * 16, rs_full = S(20) * 16, a0 = S(270) * 16; + int32_t cx = n->cx * 16 + 8, cy = n->cy * 16 + 8; + int32_t sep; + uint32_t last = orbit_angle(CK_NIGHT_MERGE_MS - 1, &sep, a0); + if (t >= CK_NIGHT_HOLES_MS && t < CK_NIGHT_MERGE_MS) { + uint32_t ang = orbit_angle(t, &sep, a0); + int32_t e = (int32_t)((int64_t)e_full * ck_smooth(ck_prog(t, CK_NIGHT_HOLES_MS, CK_NIGHT_HOLES_MS + 2600)) >> 8); + int32_t rs = (int32_t)((int64_t)rs_full * + ck_smooth(ck_prog(t, CK_NIGHT_HOLES_MS + 1400, CK_NIGHT_HOLES_MS + 3400)) >> 8); + int32_t hx = (int32_t)((int64_t)(sep / 2) * ck_cos(ang) >> 14); + int32_t hy = (int32_t)((int64_t)(sep / 2) * ck_sin(ang) >> 15); /* the orbit leans away: half as tall */ + n->hole[0] = (__typeof__(n->hole[0])){cx + hx, cy + hy, e, rs}; + n->hole[1] = (__typeof__(n->hole[1])){cx - hx, cy - hy, e, rs}; + n->holes = 2; + } else if (t >= CK_NIGHT_MERGE_MS && t < CK_NIGHT_GONE_MS) { + uint32_t tm = t - CK_NIGHT_MERGE_MS; + int32_t e = e_full * 362 / 256, rs0 = rs_full * 323 / 256, rs1 = rs_full * 2; + int32_t rs = rs0 + (int32_t)((int64_t)(rs1 - rs0) * ck_smooth(ck_prog(tm, 0, 180)) >> 8); + /* it rings: a quick wobble that dies away */ + int64_t wob = (int64_t)ck_sin(tm * 65536u / 95u) * ck_exp_neg(tm * 256u / 260u) >> 16; + rs += (int32_t)(rs * wob * 7 / 100 >> 14); + uint32_t keep = 256 - ck_smooth(ck_prog(t, CK_NIGHT_MERGE_MS + 900, CK_NIGHT_GONE_MS)); + n->hole[0] = (__typeof__(n->hole[0])){cx, cy, (int32_t)((int64_t)e * keep >> 8), + (int32_t)((int64_t)rs * (keep * keep >> 8) >> 8)}; + n->holes = 1; + } + for (unsigned i = 0; i < n->holes; i++) { + int32_t reach = (n->hole[i].e * 44 / 10 >> 4) + 2; + if (n->hole[i].e <= 0 && n->hole[i].rs <= 0) + continue; + reach = ck_max(reach, (n->hole[i].rs * 16 / 10 >> 4) + 2); + ck_rect b = {(n->hole[i].x >> 4) - reach, (n->hole[i].y >> 4) - reach, 2 * reach + 1, 2 * reach + 1}; + n->lens = ck_union(n->lens, b); + } + ck_rect all = {0, 0, n->w, n->h}; + if (n->lens.w && !ck_clip(&n->lens, &all)) + n->lens = (ck_rect){0, 0, 0, 0}; + if (t >= CK_NIGHT_MERGE_MS && t < CK_NIGHT_MERGE_MS + CK_NIGHT_RIPPLE_MS) { + uint32_t tr = t - CK_NIGHT_MERGE_MS; + int32_t w = ck_clamp(S(60), 4, 200), reach = w * 22 / 10; + int64_t far = 0; + int32_t cs[4][2] = {{0, 0}, {n->w, 0}, {0, n->h}, {n->w, n->h}}; + for (int i = 0; i < 4; i++) { + int64_t dx = cs[i][0] - n->cx, dy = cs[i][1] - n->cy, d = (int64_t)ck_isqrt((uint64_t)(dx * dx + dy * dy)); + far = d > far ? d : far; + } + far += reach; + n->ripple_r = (int32_t)(far * tr / CK_NIGHT_RIPPLE_MS); + n->ripple_w = w; + uint32_t env = ck_smooth(ck_prog(tr, 0, 220)) * + (256 - ck_smooth(ck_prog(tr, CK_NIGHT_RIPPLE_MS * 6 / 10, CK_NIGHT_RIPPLE_MS))) >> 8; + int64_t amp = (int64_t)S(6) * 16 * (256 - 150 * n->ripple_r / far) >> 8; + amp = amp * env >> 8; + int32_t lambda = ck_max(S(110), 8); + for (int32_t i = 0; i <= 2 * reach && i < 1024; i++) { + int32_t o = i - reach; + int64_t s = ck_sin((uint32_t)((int64_t)o * 65536 / lambda)); + n->ripple_disp[i] = (int32_t)((amp * s >> 14) * gauss(o, w) >> 16); + n->ripple_light[i] = (uint8_t)((uint64_t)gauss(o, w * 6 / 10) * env * 46 >> 24); + } + /* it stretches along the line the pair last lay on, and squeezes across it */ + n->ripple_c2 = ck_cos(2 * last); + n->ripple_s2 = ck_sin(2 * last); + } +} + +/* ---- drawing the base ---- */ + +static uint32_t lerp16(uint32_t a, uint32_t b, uint32_t f) /* f: 0..16 */ +{ + return ((((a & 0xff00ffu) * (16 - f) + (b & 0xff00ffu) * f) >> 4) & 0xff00ffu) | + ((((a & 0x00ff00u) * (16 - f) + (b & 0x00ff00u) * f) >> 4) & 0x00ff00u); +} + +/* the sky at (sx, sy), 16ths of a pixel (pixel i's centre at 16 i + 8) */ +static uint32_t sample(const ck_night *n, int32_t sx, int32_t sy) +{ + sx = ck_clamp(sx - 8, 0, (n->w - 1) * 16); + sy = ck_clamp(sy - 8, 0, (n->h - 1) * 16); + int32_t ix = sx >> 4, iy = sy >> 4, ix1 = ck_min(ix + 1, n->w - 1), iy1 = ck_min(iy + 1, n->h - 1); + const uint32_t *r0 = n->sky + (size_t)iy * (size_t)n->w, *r1 = n->sky + (size_t)iy1 * (size_t)n->w; + uint32_t fx = (uint32_t)sx & 15u, fy = (uint32_t)sy & 15u; + return lerp16(lerp16(r0[ix], r0[ix1], fx), lerp16(r1[ix], r1[ix1], fx), fy); +} + +/* the holes' pull on the light at (X, Y) (16ths of a pixel): added to (sx, sy), where the sky is read from */ +static void lens_at(const ck_night *n, int64_t X, int64_t Y, int64_t *sx, int64_t *sy) +{ + for (unsigned i = 0; i < n->holes; i++) { + int64_t e = n->hole[i].e, dx = X - n->hole[i].x, dy = Y - n->hole[i].y, d2 = dx * dx + dy * dy; + int64_t out = e * e * 1936 / 100, in = e * e * 484 / 100; /* (4.4 E)^2, (2.2 E)^2 */ + if (e <= 0 || d2 >= out) + continue; + if (d2 < 64) + d2 = 64; + int64_t f = e * e * 65536 / d2; + if (d2 > in) { + int64_t w = (out - d2) * 65536 / (out - in); + f = f * (w * w >> 16) >> 16; + } + *sx -= dx * f >> 16; + *sy -= dy * f >> 16; + } +} + +/* where (X, Y) (16ths of a pixel) looks in the sky: offset (ax, ay), and the ripple's own faint light */ +static void warp(const ck_night *n, int64_t X, int64_t Y, int32_t *ax, int32_t *ay, uint32_t *light) +{ + int64_t sx = 0, sy = 0; + *light = 0; + lens_at(n, X, Y, &sx, &sy); + if (n->ripple_w) { + int64_t dx = X - (n->cx * 16 + 8), dy = Y - (n->cy * 16 + 8), d2 = dx * dx + dy * dy; + int64_t r16 = (int64_t)ck_isqrt((uint64_t)d2), reach = n->ripple_w * 22 / 10; + int64_t i = (r16 >> 4) - n->ripple_r + reach; + if (r16 > 0 && i >= 0 && i <= 2 * reach && i < 1024) { + int64_t q = ((dx * dx - dy * dy) * n->ripple_c2 + 2 * dx * dy * n->ripple_s2) / d2; /* cos 2(theta - psi), Q14 */ + int64_t m = (int64_t)n->ripple_disp[i] * (5734 + (q * 10650 >> 14)) >> 14; + sx -= m * dx / r16; + sy -= m * dy / r16; + *light = n->ripple_light[i]; + } + } + *ax = (int32_t)sx; + *ay = (int32_t)sy; +} + +static uint32_t finish(const ck_night *n, uint32_t c, int32_t x, int32_t y, uint32_t light) +{ + if (n->t < CK_NIGHT_FADE_END_MS) + c = fade_px(n, c, x, y); + return light ? ck_add(c, CK_RGB(86, 108, 176), light) : c; +} + +/* a pixel close to a hole: the pull worked out exactly, then the shadow and its thin ring of light */ +static uint32_t near_px(const ck_night *n, int32_t x, int32_t y) +{ + int64_t X = (int64_t)x * 16 + 8, Y = (int64_t)y * 16 + 8; + int32_t ax, ay; + uint32_t light; + warp(n, X, Y, &ax, &ay, &light); + uint32_t c = finish(n, sample(n, (int32_t)X + ax, (int32_t)Y + ay), x, y, light); + for (unsigned i = 0; i < n->holes; i++) { + int64_t rs = n->hole[i].rs, dx = X - n->hole[i].x, dy = Y - n->hole[i].y, d2 = dx * dx + dy * dy; + if (rs <= 0 || d2 >= rs * rs * 9 / 4) + continue; + int32_t r = (int32_t)ck_isqrt((uint64_t)d2); + c = ck_mix(c, 0, ck_cover(r - (int32_t)rs)); + int32_t ring = ck_abs(r - (int32_t)(rs * 104 / 100)); + uint32_t a = ring < 22 ? (uint32_t)(22 - ring) * 6 : 0; + if (r > rs) + a += (uint32_t)((rs * 3 / 2 - r) * 46 / (rs / 2 + 1)) * (r < rs * 3 / 2); + c = ck_add(c, CK_RGB(255, 228, 196), a); + } + return c; +} + +static int near_hole(const ck_night *n, int32_t x, int32_t y) +{ + int64_t X = (int64_t)x * 16 + 8, Y = (int64_t)y * 16 + 8; + for (unsigned i = 0; i < n->holes; i++) { + int64_t reach = ck_max(n->hole[i].e, n->hole[i].rs * 3 / 2) + 8 * 16; + int64_t dx = X - n->hole[i].x, dy = Y - n->hole[i].y; + if (dx * dx + dy * dy < reach * reach) + return 1; + } + return 0; +} + +/* does the 8 x 8 block at (bx, by) meet the band the ripple bends? */ +static int in_ripple(const ck_night *n, int32_t bx, int32_t by) +{ + if (!n->ripple_w) + return 0; + int64_t reach = n->ripple_w * 22 / 10 + 1, lo = ck_max(0, n->ripple_r - (int32_t)reach), hi = n->ripple_r + reach; + int64_t nx = ck_clamp(n->cx, bx, bx + 8) - n->cx, ny = ck_clamp(n->cy, by, by + 8) - n->cy; + int64_t fx = ck_max(ck_abs(bx - n->cx), ck_abs(bx + 8 - n->cx)), fy = ck_max(ck_abs(by - n->cy), ck_abs(by + 8 - n->cy)); + return nx * nx + ny * ny <= hi * hi && fx * fx + fy * fy >= lo * lo; +} + +void ck_night_base(const ck_night *n, ck_canvas *out, const ck_rect *r) +{ + ck_rect d = *r, all = {0, 0, n->w, n->h}; + if (!ck_clip(&d, &all)) + return; + int fading = n->t < CK_NIGHT_FADE_END_MS; + for (int32_t y = d.y; y < d.y + d.h; y++) { + const uint32_t *src = n->sky + (size_t)y * (size_t)n->w; + uint32_t *dst = out->px + (size_t)y * (size_t)out->w; + if (fading) + for (int32_t x = d.x; x < d.x + d.w; x++) + dst[x] = fade_px(n, src[x], x, y); + else + for (int32_t x = d.x; x < d.x + d.w; x++) + dst[x] = src[x]; + } + if (!n->lens.w && !n->ripple_w) + return; + /* the bent parts, in 8 x 8 blocks on a grid fixed to the screen, so any split of r draws the same */ + for (int32_t by = d.y & ~7; by < d.y + d.h; by += 8) + for (int32_t bx = d.x & ~7; bx < d.x + d.w; bx += 8) { + ck_rect b = {bx, by, 8, 8}; + int lens = n->lens.w && ck_meets(b, &n->lens); + if (!lens && !in_ripple(n, bx, by)) + continue; + if (!ck_clip(&b, &d)) + continue; + if (lens && near_hole(n, bx + 4, by + 4)) { + for (int32_t y = b.y; y < b.y + b.h; y++) + for (int32_t x = b.x; x < b.x + b.w; x++) + out->px[(size_t)y * (size_t)out->w + (size_t)x] = near_px(n, x, y); + continue; + } + int32_t ax[4], ay[4]; + uint32_t li[4]; + for (int c = 0; c < 4; c++) + warp(n, ((int64_t)bx + (c & 1) * 8) * 16, ((int64_t)by + (c >> 1) * 8) * 16, &ax[c], &ay[c], &li[c]); + for (int32_t y = b.y; y < b.y + b.h; y++) { + int32_t wy = 2 * (y - by) + 1; + for (int32_t x = b.x; x < b.x + b.w; x++) { + int32_t wx = 2 * (x - bx) + 1; + int32_t w00 = (16 - wx) * (16 - wy), w10 = wx * (16 - wy), w01 = (16 - wx) * wy, w11 = wx * wy; + int32_t sx = (ax[0] * w00 + ax[1] * w10 + ax[2] * w01 + ax[3] * w11) >> 8; + int32_t sy = (ay[0] * w00 + ay[1] * w10 + ay[2] * w01 + ay[3] * w11) >> 8; + uint32_t l = (uint32_t)((int32_t)li[0] * w00 + (int32_t)li[1] * w10 + (int32_t)li[2] * w01 + + (int32_t)li[3] * w11) >> 8; + uint32_t c = sample(n, x * 16 + 8 + sx, y * 16 + 8 + sy); + out->px[(size_t)y * (size_t)out->w + (size_t)x] = finish(n, c, x, y, l); + } + } + } +} + +/* ---- the dusk: everything on the screen falls into one black hole ---- */ + +size_t ck_night_picture_bytes(uint32_t w, uint32_t h) +{ + size_t n = 64 + (size_t)w * h * 4; + for (unsigned i = 1; i < CK_NIGHT_LEVELS; i++) + n += (size_t)(w >> i) * (size_t)(h >> i) * 4 * 2; + return n; +} + +/* half the width and height of `from` (sw x sh) into to: the mean of each 2 x 2 */ +static void halve(const uint32_t *from, uint32_t sw, uint32_t sh, uint32_t *to) +{ + uint32_t dw = sw / 2, dh = sh / 2; + for (uint32_t y = 0; y < dh; y++) { + const uint32_t *r0 = from + (size_t)(2 * y) * sw, *r1 = r0 + sw; + uint32_t *d = to + (size_t)y * dw; + for (uint32_t x = 0; x < dw; x++) { + uint32_t a = r0[2 * x], b = r0[2 * x + 1], c = r1[2 * x], e = r1[2 * x + 1]; + /* red and blue summed together, green on its own: the sums do not run into each other */ + uint32_t rb = (((a & 0xff00ffu) + (b & 0xff00ffu) + (c & 0xff00ffu) + (e & 0xff00ffu)) >> 2) & 0xff00ffu; + uint32_t g = (((a & 0xff00u) + (b & 0xff00u) + (c & 0xff00u) + (e & 0xff00u)) >> 2) & 0xff00u; + d[x] = rb | g; + } + } +} + +void ck_night_picture_take(const ck_night *n, const uint32_t *from, void *mem, ck_night_picture *kept) +{ + uint32_t w = (uint32_t)n->w, h = (uint32_t)n->h, *p = mem; + size_t count = (size_t)w * h; + for (size_t i = 0; i < count; i++) + p[i] = from[i]; + kept->level[0] = p; + kept->sky[0] = n->sky; + p += count; + for (unsigned l = 1; l < CK_NIGHT_LEVELS; l++) { + uint32_t sw = w >> (l - 1), sh = h >> (l - 1); + halve(kept->level[l - 1], sw, sh, p); + kept->level[l] = p; + p += (size_t)(sw / 2) * (sh / 2); + halve(kept->sky[l - 1], sw, sh, p); + kept->sky[l] = p; + p += (size_t)(sw / 2) * (sh / 2); + } +} + +void ck_night_fall(ck_night *n, const ck_night_dusk *d) +{ + n->falling = 1; + n->dusk = *d; + int32_t cx = n->cx * 16 + 8, cy = n->cy * 16 + 8, rs = d->rs; + n->hole[0] = (__typeof__(n->hole[0])){cx, cy, d->e, rs}; + n->holes = 1; + n->ripple_w = 0; + n->lens = (ck_rect){0, 0, n->w, n->h}; + /* The disk and the ring, by distance from the hole, in 1024 steps out to 3.3 shadow radii. The disk is + * dark inside 1.15 radii, brightest at 1.5 and dies away beyond; its colour runs from warm white at the + * inner edge through gold to the blue of the sky's glow. The photon ring is a thin bright line at 1.06 + * radii, a pixel and a quarter each way (wider on a big screen). */ + n->disk_far = rs * 33 / 10 + 16; + int32_t in = rs * 115 / 100, peak = rs * 150 / 100, ring = rs * 106 / 100, hw = 20 + rs / 64; + for (unsigned i = 0; i < 1024; i++) { + int32_t r = (int32_t)((int64_t)n->disk_far * (int64_t)i / 1024); + uint32_t a = 0, c = CK_RGB(255, 222, 180); + if (r >= in && peak > in) { + if (r < peak) { + uint32_t u = (uint32_t)((int64_t)(r - in) * 256 / (peak - in)); + a = ck_smooth((int32_t)u) * 220 >> 8; + c = ck_mix(CK_RGB(255, 222, 180), CK_RGB(255, 212, 150), u); + } else { + uint32_t v = (uint32_t)((int64_t)(r - peak) * 256 / (rs / 2 + 1)); /* half radii past the peak, 256 each */ + a = (ck_exp_neg(v) >> 8) * 220 >> 8; + c = ck_mix(CK_RGB(255, 212, 150), CK_RGB(150, 170, 255), ck_smooth((int32_t)(v * 256 / 360))); + } + } + int32_t off = ck_abs(r - ring); + if (off < hw) { + uint32_t ar = (uint32_t)(hw - off) * 255 / (uint32_t)hw; + ar = ar * ar >> 8; + c = a + ar ? ck_mix(c, CK_RGB(255, 244, 228), ar * 256 / (a + ar)) : c; + a += ar; + } + a = a * d->disk >> 8; + n->disk_a[i] = (uint8_t)(a > 255 ? 255 : a); + n->disk_c[i] = c; + } +} + +/* a corner of the 8 x 8 grid during the dusk: where the picture is read from, and the distance to the hole */ +struct corner { + int32_t ax, ay; /* offset to the picture point shown here, 16ths of a pixel */ + int32_t sx, sy; /* that point itself, 16ths (for telling whether a block shows only the dark beyond the edge) */ + uint32_t crowd; /* how much brighter the crowded light is drawn, 256 = as it is */ + uint32_t h; /* log2 of the crowding of the area, Q16 */ + int32_t r; /* distance from the hole, 16ths of a pixel */ + int32_t inv; /* 2^28 / r */ + uint32_t vig; /* how much of the light the edges of the screen keep here, 0..256 */ +}; + +static void corner_at(const ck_night *n, int32_t x, int32_t y, struct corner *c) +{ + const ck_night_dusk *d = &n->dusk; + int64_t X = (int64_t)x * 16, Y = (int64_t)y * 16, dx = X - n->hole[0].x, dy = Y - n->hole[0].y; + int64_t d2 = dx * dx + dy * dy; + if (d2 < 256) + d2 = 256; + uint32_t l0 = ck_log2_q16((uint64_t)d2), l1 = ck_log2_q16((uint64_t)(d2 + d->fallen)), h = l1 - l0; + c->h = h; + uint64_t crowd = pow2_q16(h) >> 8; + c->crowd = crowd > d->crowd ? d->crowd : (uint32_t)crowd; + /* the picture point: the same direction turned by swirl per doubling, at the stretched distance */ + int64_t r = (int64_t)(pow2_q16(l0 >> 1) >> 16); /* the distance, 16ths, without a square root */ + uint32_t ang = (uint32_t)((uint64_t)d->swirl * (h >> 1) >> 16); + ang = (uint32_t)((int64_t)ang * d->calm / (d->calm + r)); + int64_t stretch = (int64_t)pow2_q16(h >> 1), cs = ck_cos(ang), sn = ck_sin(ang); + int64_t ux = (dx * cs - dy * sn) >> 14, uy = (dx * sn + dy * cs) >> 14; + int64_t sx = (ux * stretch >> 16) - dx, sy = (uy * stretch >> 16) - dy; + lens_at(n, X, Y, &sx, &sy); + /* far beyond the picture is still far beyond it: held where the block arithmetic stays in 32 bits */ + sx = sx > (1 << 22) ? (1 << 22) : sx < -(1 << 22) ? -(1 << 22) : sx; + sy = sy > (1 << 22) ? (1 << 22) : sy < -(1 << 22) ? -(1 << 22) : sy; + c->ax = (int32_t)sx; + c->ay = (int32_t)sy; + c->sx = (int32_t)X + c->ax; + c->sy = (int32_t)Y + c->ay; + c->r = (int32_t)r; + c->inv = (int32_t)((1 << 28) / (r > 0 ? r : 1)); + /* the edges go dark first: from `near` out to `far` the light falls off smoothly by up to `shade` */ + c->vig = 256 - (d->shade * ck_smooth(ck_prog((uint32_t)r, (uint32_t)d->near, (uint32_t)d->far)) >> 8); +} + +/* the kept picture at (sx, sy) (16ths of a pixel of copy l, w x h): the picture itself inside its edges, the + * sky mirrored in them beyond (so the stars flow in from past the screen), black further out than that. */ +static uint32_t sample_kept(const ck_night_picture *kept, unsigned l, int32_t w, int32_t h, int32_t sx, int32_t sy) +{ + const uint32_t *px = kept->level[l]; + int32_t W = (w - 1) * 16, H = (h - 1) * 16; + sx -= 8, sy -= 8; + if (sx < 0 || sy < 0 || sx >= W || sy >= H) { + sx = sx < 0 ? -sx : sx >= W ? 2 * W - sx : sx; + sy = sy < 0 ? -sy : sy >= H ? 2 * H - sy : sy; + if (sx < 0 || sy < 0 || sx >= W || sy >= H) + return 0; + px = kept->sky[l]; + } + int32_t ix = sx >> 4, iy = sy >> 4; + const uint32_t *r0 = px + (size_t)iy * (size_t)w, *r1 = r0 + w; + uint32_t fx = (uint32_t)sx & 15u, fy = (uint32_t)sy & 15u; + return lerp16(lerp16(r0[ix], r0[ix + 1], fx), lerp16(r1[ix], r1[ix + 1], fx), fy); +} + +/* c brightened g/256 times (g above 256), the excess warmer than the light itself */ +static uint32_t brighten(uint32_t c, uint32_t g) +{ + if (g <= 256 || !c) + return c; + uint32_t x = g - 256; + uint32_t r = ck_ch(c, 16) * (256 + x) >> 8, gg = ck_ch(c, 8) * (256 + x * 7 / 8) >> 8, b = ck_ch(c, 0) * (256 + x * 5 / 8) >> 8; + return (r > 255 ? 255u : r) << 16 | (gg > 255 ? 255u : gg) << 8 | (b > 255 ? 255u : b); +} + +/* One 8 x 8 block of the dusk, clipped to d, from its four corners. Near the hole every pixel is worked out; + * further out, where the picture is streaming past, the block is worked out two pixels at a time each way + * (the screen does not show the difference there and the frame costs a third as much). */ +static void fall_block(const ck_night *n, const ck_night_picture *kept, ck_canvas *out, const ck_rect *d, int32_t bx, + int32_t by, const struct corner *c00, const struct corner *c10, const struct corner *c01, + const struct corner *c11) +{ + ck_rect b = {bx, by, 8, 8}; + if (!ck_clip(&b, d)) + return; + const ck_night_dusk *k = &n->dusk; + int32_t rs = k->rs, hx = n->hole[0].x, hy = n->hole[0].y; + int32_t rmin = ck_min(ck_min(c00->r, c10->r), ck_min(c01->r, c11->r)) - 182; /* the block's diagonal: 8 px * sqrt 2 */ + int32_t rmax = ck_max(ck_max(c00->r, c10->r), ck_max(c01->r, c11->r)); + int32_t W16 = n->w * 32 + 16, H16 = n->h * 32 + 16, X16 = -n->w * 16 - 16, Y16 = -n->h * 16 - 16; + /* all four corners read from the dark beyond the same edge of the mirrored sky: so does everything between */ + int beyond = (c00->sx < X16 && c10->sx < X16 && c01->sx < X16 && c11->sx < X16) || + (c00->sy < Y16 && c10->sy < Y16 && c01->sy < Y16 && c11->sy < Y16) || + (c00->sx > W16 && c10->sx > W16 && c01->sx > W16 && c11->sx > W16) || + (c00->sy > H16 && c10->sy > H16 && c01->sy > H16 && c11->sy > H16); + int disk = k->disk && rmin < n->disk_far, edge = rmin < rs + 16, fine = rmin < k->fine; + /* the light kept here: the closing of the horizon, and the edges of the screen going dark first */ + uint32_t keep = k->keep * ((c00->vig + c10->vig + c01->vig + c11->vig) >> 2) >> 8; + if ((!keep && !disk) || rmax < rs - 16 || (beyond && !disk)) { /* only the dark: inside the shadow, or past the edge */ + for (int32_t y = b.y; y < b.y + b.h; y++) + for (int32_t x = b.x; x < b.x + b.w; x++) + out->px[(size_t)y * (size_t)out->w + (size_t)x] = 0; + return; + } + /* which copy of the picture: the one whose pixels are about as big as the crowding here, leaning to the + * smaller copy (the picture is streaming, and the smaller copies are read far faster); once the light is + * nearly gone, the copies at an eighth and below, which no eye can tell apart at that brightness */ + uint32_t hm = (c00->h >> 2) + (c10->h >> 2) + (c01->h >> 2) + (c11->h >> 2), lvl = (hm + 98304u) >> 17; + lvl = keep < 16 && lvl < 3 ? 3 : lvl; + lvl = lvl >= CK_NIGHT_LEVELS ? CK_NIGHT_LEVELS - 1 : lvl; + int32_t lw = n->w >> lvl, lh = n->h >> lvl; + int crowded = c00->crowd > 256 || c10->crowd > 256 || c01->crowd > 256 || c11->crowd > 256; + int64_t cb = ck_cos(k->beam), sb = ck_sin(k->beam); + uint32_t inv_far = (uint32_t)((1u << 30) / (uint32_t)(n->disk_far > 0 ? n->disk_far : 1)); + if (!fine) { /* pairs start on even pixels, so a block cut by the clip still draws the same pixels */ + ck_rect e = {b.x & ~1, b.y & ~1, 0, 0}; + e.w = ((b.x + b.w + 1) & ~1) - e.x, e.h = ((b.y + b.h + 1) & ~1) - e.y; + if (e.x >= d->x && e.y >= d->y && e.x + e.w <= d->x + d->w && e.y + e.h <= d->y + d->h) + b = e; + else + fine = 1; /* an odd clip: every pixel, so nothing is written outside it */ + } + int32_t step = fine ? 1 : 2; + for (int32_t y = b.y; y < b.y + b.h; y += step) { + int32_t wy = 2 * (y - by) + step; + uint32_t *row = out->px + (size_t)y * (size_t)out->w; + for (int32_t x = b.x; x < b.x + b.w; x += step) { + int32_t wx = 2 * (x - bx) + step; + int32_t w00 = (16 - wx) * (16 - wy), w10 = wx * (16 - wy), w01 = (16 - wx) * wy, w11 = wx * wy; + uint32_t c = 0; + if (!beyond) { + int32_t ax = (c00->ax * w00 + c10->ax * w10 + c01->ax * w01 + c11->ax * w11) >> 8; + int32_t ay = (c00->ay * w00 + c10->ay * w10 + c01->ay * w01 + c11->ay * w11) >> 8; + c = sample_kept(kept, lvl, lw, lh, (x * 16 + 8 + ax) >> lvl, (y * 16 + 8 + ay) >> lvl); + if (c && crowded) { + uint32_t g = (uint32_t)((int32_t)c00->crowd * w00 + (int32_t)c10->crowd * w10 + + (int32_t)c01->crowd * w01 + (int32_t)c11->crowd * w11) >> 8; + c = brighten(c, g); + } + if (keep < 256) /* the picture goes before the disk does */ + c = ck_scale(c, keep); + } + if (disk || edge) { + int32_t r = (c00->r * w00 + c10->r * w10 + c01->r * w01 + c11->r * w11) >> 8; + if (disk && r < n->disk_far) { + uint32_t i = (uint32_t)r * inv_far >> 20, a = n->disk_a[i < 1024 ? i : 1023]; + if (a) { + /* brighter on the side turning toward the eye: by the cosine of the angle from the beam */ + int64_t inv = ((int64_t)c00->inv * w00 + (int64_t)c10->inv * w10 + (int64_t)c01->inv * w01 + + (int64_t)c11->inv * w11) >> 8; + int64_t dot = ((int64_t)(x * 16 + 8 - hx) * cb + (int64_t)(y * 16 + 8 - hy) * sb) >> 14; + int64_t cosb = dot * inv >> 14; /* Q14 */ + a = (uint32_t)((int64_t)a * (16384 + (cosb * 110 >> 8)) >> 14); + c = ck_add(c, n->disk_c[i < 1024 ? i : 1023], a > 255 ? 255 : a); + } + } + if (edge) + c = ck_mix(c, 0, ck_cover(r - rs)); + } + row[x] = c; + if (!fine) + row[x + 1] = c, row[x + out->w] = c, row[x + out->w + 1] = c; + } + } +} + +#define CHUNK 32 /* blocks of a row worked at once (their corners shared); 2.4 KiB of stack for the two rows */ + +void ck_night_base_from(const ck_night *n, const ck_night_picture *kept, ck_canvas *out, const ck_rect *r) +{ + ck_rect d = *r, all = {0, 0, n->w, n->h}; + if (!ck_clip(&d, &all)) + return; + if (!n->falling) { + ck_night_base(n, out, &d); + return; + } + struct corner rows[2][CHUNK + 1]; + int32_t bx0 = d.x & ~7, bx1 = d.x + d.w, by0 = d.y & ~7, by1 = d.y + d.h; + for (int32_t cx0 = bx0; cx0 < bx1; cx0 += CHUNK * 8) { + int32_t ncol = ck_min(CHUNK, (bx1 - cx0 + 7) / 8); + struct corner *top = rows[0], *bottom = rows[1]; + for (int32_t i = 0; i <= ncol; i++) + corner_at(n, cx0 + 8 * i, by0, &top[i]); + for (int32_t by = by0; by < by1; by += 8) { + for (int32_t i = 0; i <= ncol; i++) + corner_at(n, cx0 + 8 * i, by + 8, &bottom[i]); + for (int32_t i = 0; i < ncol; i++) + fall_block(n, kept, out, &d, cx0 + 8 * i, by, &top[i], &top[i + 1], &bottom[i], &bottom[i + 1]); + struct corner *t = top; + top = bottom, bottom = t; + } + } +} + +/* ---- the lights on top ---- */ + +ck_rect ck_night_star_box(const ck_night *n, unsigned i) +{ + const ck_night_star *s = &n->tw[i]; + return (ck_rect){(s->x - s->r) >> 4, (s->y - s->r) >> 4, (2 * s->r >> 4) + 2, (2 * s->r >> 4) + 2}; +} + +void ck_night_lights(const ck_night *n, ck_canvas *out, const ck_rect *r, uint32_t shimmer, uint32_t voice) +{ + for (unsigned i = 0; i < n->ntw; i++) { + const ck_night_star *s = &n->tw[i]; + ck_rect b = ck_night_star_box(n, i); + if (!ck_meets(b, r) || (n->lens.w && ck_meets(b, &n->lens))) + continue; + uint32_t tw = (uint32_t)(16384 + ck_sin((n->t + s->phase) % s->period * 65536u / s->period)) >> 7; + uint32_t a = (tw * tw >> 8) * 120 >> 8; + a = a * ck_night_faded(n, s->x >> 4, s->y >> 4, 255) >> 8; + ck_glow(out, r, s->x, s->y, s->r, s->color, a); + } + if (!shimmer && !voice) + return; + for (unsigned i = 0; i < CK_NIGHT_GALAXIES; i++) { + const ck_night_galaxy *g = &n->gal[i]; + ck_rect b = g->box; + if (!g->box.w || !ck_clip(&b, r)) + continue; + uint32_t sweep = n->t % g->period * 256u / g->period; + for (int32_t y = b.y; y < b.y + b.h; y++) { + const uint8_t *lp = g->light + (size_t)(y - g->box.y) * (size_t)g->box.w - (size_t)g->box.x; + const uint8_t *pp = g->phase + (size_t)(y - g->box.y) * (size_t)g->box.w - (size_t)g->box.x; + uint32_t *row = out->px + (size_t)y * (size_t)out->w; + for (int32_t x = b.x; x < b.x + b.w; x++) { + uint32_t l = lp[x]; + if (!l) + continue; + uint32_t a = (l * band_t[(pp[x] - sweep) & 255u] >> 8) * shimmer >> 8; + a += (l * l >> 8) * voice >> 9; + if (a) + row[x] = ck_add(row[x], g->tint, a); + } + } + } +} +/* ---- rebuilding the sky for a new view ---- */ + +/* Resets the sky background and redraws it with the new view v. The sky's + * glow (dark sky background) is written first, then the Milky Way and the + * catalogue stars on top of it. Galaxy bounds and maps are updated too. + * scratch: at least n->w * n->h * 4 bytes of temporary workspace. */ +void ck_night_view(ck_night *n, const ck_sky_view *v, void *scratch) +{ + n->view = *v; + int32_t qw = (int32_t)(n->w / 4 + 2), qh = (int32_t)(n->h / 4 + 2); + /* clear the sky to the dark-sky glow (the same glow set in the original + * sky grid; bilinear_u8 of the empty dark grid gives the glow level) */ + ck_canvas cv = {n->sky, n->w, n->h}; + ck_sky_milkyway_q(scratch, qw, qh, n->w, n->cx, n->cy, &n->view); + scale_up(n, scratch, qw); + /* redraw stars over the new Milky Way */ + ck_sky_draw_stars(&cv, n->k, n->cx, n->cy, &n->view, n->tw, CK_NIGHT_TWINKLES, &n->ntw); + /* recompute galaxy boxes (some may enter or leave the view) */ + uint8_t *p = (uint8_t *)n->sky + (size_t)n->w * n->h * 4; + p += (size_t)(n->w / 4 + 1) * (n->h / 4 + 1); + for (unsigned i = 0; i < CK_NIGHT_GALAXIES; i++) { + ck_night_galaxy *g = &n->gal[i]; + g->box = ck_sky_galaxy_box((uint32_t)n->w, (uint32_t)n->h, n->cx, n->cy, &n->view, i); + ck_sky_galaxy_maps(g, i, (uint32_t)n->w, n->cx, n->cy, &n->view); + } +} diff --git a/om/allen-scene/native/night.h b/om/allen-scene/native/night.h new file mode 100644 index 0000000..4cecf8f --- /dev/null +++ b/om/allen-scene/native/night.h @@ -0,0 +1,165 @@ +/* night.h -- the night sky AIENOS opens on, and the two black holes that + * merge in it. + * + * The sky is made once, into RAM, and it is the real sky (ui/sky_real.h): + * by default the piece of it GW150914, the first black-hole merger ever + * heard, came from; the Milky Way from a photograph, the catalogue's stars + * to the naked-eye limit at their true places, brightness and colour, and + * the galaxies in the view the eye can see (there: the Large and Small + * Magellanic Clouds). Each galaxy also keeps, per pixel, how bright it is + * and where along its long axis that pixel sits, so a band of light can + * later sweep along it (while Allen answers) without the galaxy itself + * changing. + * + * The startup, on the clock from ck_night_init (ms): + * 0 to CK_NIGHT_FADE_END_MS the eyes adjust to the dark: the brightest + * stars first, then the fainter ones, then the + * Milky Way, in slow patches across the sky. + * CK_NIGHT_HOLES_MS two black holes start to bend the starlight + * (gravitational lensing: stars behind them are + * pulled into arcs), then show their shadows, + * circling on a tilted orbit; + * CK_NIGHT_SPIRAL_MS they spiral in, faster and closer, the way a + * real pair does (separation as t^(1/4), angle + * as t^(5/8), t the time left); + * CK_NIGHT_MERGE_MS they merge; a ripple (the gravitational wave, + * stretching one way and squeezing the other) + * runs out through the stars; the one black + * hole left rings, then dissolves by + * CK_NIGHT_GONE_MS. + * + * The dusk (ck_night_fall): when Allen goes to sleep, one black hole opens + * where the pair merged and everything on the screen falls into it. The + * caller keeps the picture as it was (ck_night_picture_take) and the night + * draws it pulled in: a pixel at distance r from the hole shows what was at + * sqrt(r^2 + fallen), turned round the hole a set part of a turn for every + * doubling of that distance; so the picture streams inward, fastest near the + * hole, whipping round as it goes, and the light that crowds in there is + * drawn brighter and warmer. Round the shadow an accretion disk glows, warm + * white at its inner edge through gold and blue to the dark, brighter on the + * side turning toward the eye, with a thin bright photon ring just outside + * the shadow; then the whole picture is dimmed as the horizon closes. + * + * Every pixel is a pure function of its position and the time, so a frame + * redraws only the regions that changed, in any order. Integer only, + * freestanding, no heap. Host tested in ui/tests/allen_ui_test.c. */ +#ifndef AIENOS_NIGHT_H +#define AIENOS_NIGHT_H +#include +#include + +#include "paint.h" +#include "sky_data.h" + +#define CK_NIGHT_FADE_END_MS 6800u +#define CK_NIGHT_HOLES_MS 2600u +#define CK_NIGHT_SPIRAL_MS 6000u +#define CK_NIGHT_MERGE_MS 12000u +#define CK_NIGHT_RIPPLE_MS 3600u /* the ripple's run across the screen */ +#define CK_NIGHT_GONE_MS 15200u /* the last black hole has dissolved */ + +#define CK_NIGHT_GALAXIES 6u +#define CK_NIGHT_TWINKLES 256u +#define CK_NIGHT_LEVELS 6u /* a kept picture and its copies at 1/2, 1/4, down to 1/32 size */ +#define CK_NIGHT_W_MAX 8192u /* the widest screen the dusk can draw (one row of 8-pixel blocks at a time) */ + +/* How the dusk stands at a frame; see ck_night_fall. All distances in 16ths of a pixel. */ +typedef struct { + int64_t fallen; /* a pixel at distance r from the hole shows what was at sqrt(r^2 + fallen) */ + uint32_t swirl; /* 65536ths of a turn the picture is turned for each doubling of that distance, close to the hole */ + int32_t calm; /* the turning is weaker further out: by calm / (calm + r) */ + uint32_t crowd; /* the most the crowded light near the hole is brightened: 256 not at all, 1024 four times */ + int32_t e, rs; /* the hole: Einstein radius and shadow radius */ + uint32_t disk; /* how bright the accretion disk and the photon ring are, 0..256 */ + uint32_t beam; /* which way the disk's bright side faces (the side turning toward the eye), 65536ths of a turn */ + uint32_t keep; /* how much of the picture's light is kept, 0..256; the horizon closing takes it to 0 */ + int32_t near, far; /* the edges of the screen go dark first: the light falls off from near out to far ... */ + uint32_t shade; /* ... by this much at far, 0..256 */ + int32_t fine; /* inside this distance every pixel is worked out; beyond it two at a time each way */ +} ck_night_dusk; + +typedef struct { + ck_rect box; + uint8_t *light, *phase; /* box.w * box.h each */ + uint32_t tint; /* the colour of the light that sweeps it */ + uint16_t period; /* ms for the sweep to come round */ +} ck_night_galaxy; + +typedef struct { + int32_t x, y, r; /* 16ths of a pixel */ + uint32_t color; + uint16_t period, phase; /* ms */ +} ck_night_star; + +typedef struct { + int32_t w, h; + uint32_t k; /* 1/256 px per design px (1920 x 1080 design) */ + int32_t cx, cy; /* where the black holes merge, px */ + uint32_t *sky; /* the night, w * h */ + uint8_t *appear; /* when each 4 x 4 cell comes out of the dark (0..255) */ + int32_t aw; + ck_night_galaxy gal[CK_NIGHT_GALAXIES]; + ck_night_star tw[CK_NIGHT_TWINKLES]; + unsigned ntw; + /* state at the time ck_night_at was last given */ + uint32_t t; + unsigned holes; + struct { + int32_t x, y, e, rs; /* 16ths of a pixel: centre, Einstein radius, shadow radius */ + } hole[2]; + ck_rect lens; /* where the light is bent (empty: nowhere) */ + int32_t ripple_r, ripple_w; /* px; ripple_w 0: no ripple */ + int32_t ripple_disp[1024]; /* 16ths of a pixel, by distance from the crest */ + uint8_t ripple_light[1024]; + int32_t ripple_c2, ripple_s2; /* the stretch direction, Q14 */ + /* the dusk (ck_night_fall); falling 0: none */ + int falling; + ck_night_dusk dusk; + uint8_t disk_a[1024]; /* the disk's light by distance from the hole, 0..255 */ + uint32_t disk_c[1024]; /* and its colour there */ + int32_t disk_far; /* the disk reaches this far, 16ths of a pixel */ + ck_sky_view view; /* the current sky view (set by ck_night_init, updated by ck_night_view) */ +} ck_night; + +/* The picture kept for the dusk: the screen as it was, with smaller copies of it and of the bare sky. + * Beyond the picture's edges the dusk shows the sky mirrored, so the stars seem to come from past the + * screen and no edge is seen falling in. */ +typedef struct { + const uint32_t *level[CK_NIGHT_LEVELS]; /* the picture, then it at 1/2, 1/4 ... the width and height */ + const uint32_t *sky[CK_NIGHT_LEVELS]; /* the bare sky the same way (sky[0] is the night's own) */ +} ck_night_picture; +/* Memory for a w x h picture kept this way. */ +size_t ck_night_picture_bytes(uint32_t w, uint32_t h); +/* Copies the w x h picture `from` (rows w apart) into mem (ck_night_picture_bytes) and makes the smaller + * copies of it and of n's sky, each a quarter of the one before by averaging 2 x 2 pixels. */ +void ck_night_picture_take(const ck_night *n, const uint32_t *from, void *mem, ck_night_picture *kept); + +/* Memory for a w x h night at scale k. */ +size_t ck_night_mem_bytes(uint32_t w, uint32_t h, uint32_t k); +/* Makes the sky into mem; scratch: at least w * h * 4 bytes of working + * memory, overwritten. (cx, cy): where the holes merge. 0, or -1. */ +int ck_night_init(ck_night *n, uint32_t w, uint32_t h, uint32_t k, int32_t cx, int32_t cy, void *mem, size_t len, + void *scratch); +/* Rebuilds the sky for a new view (changing sky mode or location). + * scratch: at least w * h * 4 bytes (same buffer as ck_night_init). */ +void ck_night_view(ck_night *n, const ck_sky_view *v, void *scratch); +/* Moves the night to t ms: the holes, the lens region, the ripple. Ends any dusk. */ +void ck_night_at(ck_night *n, uint32_t t); +/* The dusk, after ck_night_at: one black hole at (cx, cy) with everything falling into it as d says. + * The picture is then drawn with ck_night_base_from. */ +void ck_night_fall(ck_night *n, const ck_night_dusk *d); +/* The sky as seen at the current time (faded in, bent, rippled) into the + * rectangle r of out. */ +void ck_night_base(const ck_night *n, ck_canvas *out, const ck_rect *r); +/* The kept picture (ck_night_picture_take) as the dusk shows it now: pulled into the hole, the shadow, + * the ring and the disk on it, the whole dimmed by keep; into the rectangle r of out. */ +void ck_night_base_from(const ck_night *n, const ck_night_picture *kept, ck_canvas *out, const ck_rect *r); +/* Adds the twinkling and, with shimmer > 0 (0..256), the light sweeping the + * galaxies; voice (0..256) brightens their cores. */ +void ck_night_lights(const ck_night *n, ck_canvas *out, const ck_rect *r, uint32_t shimmer, uint32_t voice); +/* The rectangle a twinkling star needs redrawn. */ +ck_rect ck_night_star_box(const ck_night *n, unsigned i); +/* How far the sky has come out of the dark at (x, y) for light of level l + * (0..255): 0..256. */ +uint32_t ck_night_faded(const ck_night *n, int32_t x, int32_t y, uint32_t l); +#endif \ No newline at end of file diff --git a/om/allen-scene/native/paint.c b/om/allen-scene/native/paint.c new file mode 100644 index 0000000..69c70fb --- /dev/null +++ b/om/allen-scene/native/paint.c @@ -0,0 +1,272 @@ +/* paint.c -- the drawing kit; see paint.h. */ +#include "paint.h" + +/* ---- tables, filled on first use ---- */ + +static int16_t sin_t[4097]; /* a full turn in 4096 steps, Q14; one extra for interpolation */ +static uint32_t exp_t[4096]; /* exp(-k/256), Q16 */ +static uint32_t log_t[257]; /* log2(1 + k/256), Q16 */ +static int ready; + +static void setup(void) +{ + /* sine: a rotation by a 4096th of a turn, applied over and over (Q30) */ + const int64_t C = 1073740561, S = 1647099; + int64_t c = 1ll << 30, s = 0; + for (unsigned k = 0; k <= 1024; k++) { + int16_t v = k == 1024 ? 16384 : (int16_t)((s + (1 << 15)) >> 16); + sin_t[k] = v; + sin_t[2048 - k] = v; + sin_t[(2048 + k) & 4095] = (int16_t)-v; + sin_t[(4096 - k) & 4095] = (int16_t)-v; + int64_t nc = (c * C - s * S) >> 30, ns = (s * C + c * S) >> 30; + c = nc, s = ns; + } + sin_t[4096] = sin_t[0]; + /* exp(-k/256): one factor of exp(-1/256) (Q30) per step */ + uint64_t e = 1ull << 30; + for (unsigned k = 0; k < 4096; k++) { + exp_t[k] = (uint32_t)((e + (1u << 13)) >> 14); + e = e * 1069555701ull >> 30; + } + /* log2(1 + k/256): square the value 16 times, taking a bit each time it passes 2 */ + for (unsigned k = 0; k <= 256; k++) { + uint64_t y = (256u + k) << 8; /* Q16, in [1, 2] */ + uint32_t r = 0; + if (k == 256) { + log_t[k] = 65536; + continue; + } + for (int b = 15; b >= 0; b--) { + y = y * y >> 16; + if (y >= 2u << 16) { + y >>= 1; + r |= 1u << b; + } + } + log_t[k] = r; + } + ready = 1; +} + +int32_t ck_sin(uint32_t a) +{ + if (!ready) + setup(); + a &= 65535u; + uint32_t i = a >> 4, f = a & 15u; + return sin_t[i] + (((int32_t)sin_t[i + 1] - sin_t[i]) * (int32_t)f >> 4); +} + +int32_t ck_cos(uint32_t a) { return ck_sin(a + 16384u); } + +uint32_t ck_atan2(int32_t y, int32_t x) +{ + static const uint16_t step[14] = {8192, 4836, 2555, 1297, 651, 326, 163, 81, 41, 20, 10, 5, 3, 1}; + int64_t X = x, Y = y; + uint32_t ang = 0; + if (X == 0 && Y == 0) + return 0; + if (X < 0) { /* turn half a turn into the right half-plane */ + X = -X, Y = -Y; + ang = 32768; + } + int64_t m = X > (Y < 0 ? -Y : Y) ? X : (Y < 0 ? -Y : Y); + while (m < (1 << 20)) + X *= 2, Y *= 2, m *= 2; /* not a shift: Y may be negative */ + while (m >= (1 << 22)) + X >>= 1, Y >>= 1, m >>= 1; + int32_t z = 0; + for (int i = 0; i < 14; i++) { + int64_t nx; + if (Y > 0) { + nx = X + (Y >> i); + Y -= X >> i; + z += step[i]; + } else { + nx = X - (Y >> i); + Y += X >> i; + z -= step[i]; + } + X = nx; + } + return (ang + (uint32_t)z) & 65535u; +} + +uint32_t ck_exp_neg(uint32_t x) +{ + if (!ready) + setup(); + return x < 4096 ? exp_t[x] : 0; +} + +uint32_t ck_log2_q16(uint64_t v) +{ + if (!ready) + setup(); + if (!v) + return 0; + int n = 63 - __builtin_clzll(v); + uint64_t m = n >= 16 ? v >> (n - 16) : v << (16 - n); /* Q16 in [1, 2) */ + uint32_t k = (uint32_t)(m >> 8 & 255u), f = (uint32_t)(m & 255u); + return (uint32_t)n * 65536u + log_t[k] + ((log_t[k + 1] - log_t[k]) * f >> 8); +} + +uint64_t ck_isqrt(uint64_t v) { return ck_af_isqrt(v); } + +uint32_t ck_hash(int32_t x, int32_t y, uint32_t seed) +{ + uint32_t h = (uint32_t)x * 0x8da6b343u ^ (uint32_t)y * 0xd8163841u ^ seed * 0xcb1ab31fu; + h ^= h >> 13; + h *= 0x5bd1e995u; + h ^= h >> 15; + h *= 0x27d4eb2du; + h ^= h >> 16; + return h; +} + +uint32_t ck_noise(int32_t x, int32_t y, uint32_t seed) +{ + int32_t ix = x >> 8, iy = y >> 8; + uint32_t fx = ck_smooth(x & 255), fy = ck_smooth(y & 255); + uint64_t v00 = ck_hash(ix, iy, seed) >> 16, v10 = ck_hash(ix + 1, iy, seed) >> 16; + uint64_t v01 = ck_hash(ix, iy + 1, seed) >> 16, v11 = ck_hash(ix + 1, iy + 1, seed) >> 16; + uint64_t a = v00 * (256 - fx) + v10 * fx, b = v01 * (256 - fx) + v11 * fx; + return (uint32_t)((a * (256 - fy) + b * fy) >> 16); +} + +uint32_t ck_fbm(int32_t x, int32_t y, uint32_t seed, int octaves) +{ + uint64_t sum = 0, total = 0; + for (int o = 0; o < octaves; o++) { + uint32_t w = 1u << (octaves - 1 - o); + sum += (uint64_t)ck_noise(x << o, y << o, seed + (uint32_t)o * 7919u) * w; + total += w; + } + return (uint32_t)(sum / total); +} + +/* ---- shapes ---- */ + +/* d becomes the part of d inside both the clip and the canvas */ +static int fit(const ck_canvas *cv, const ck_rect *clip, ck_rect *d) +{ + ck_rect all = {0, 0, cv->w, cv->h}; + return ck_clip(d, clip) && ck_clip(d, &all); +} + +void ck_glow(ck_canvas *cv, const ck_rect *clip, int32_t cx, int32_t cy, int32_t r, uint32_t color, uint32_t a) +{ + if (r <= 0 || !a) + return; + ck_rect d = {(cx - r) >> 4, (cy - r) >> 4, 0, 0}; + d.w = ((cx + r) >> 4) - d.x + 1; + d.h = ((cy + r) >> 4) - d.y + 1; + if (!fit(cv, clip, &d)) + return; + int64_t r2 = (int64_t)r * r; + uint64_t inv = (1ull << 40) / (uint64_t)r2; + for (int32_t y = d.y; y < d.y + d.h; y++) { + int64_t dy = (int64_t)y * 16 + 8 - cy, dy2 = dy * dy; + if (dy2 >= r2) + continue; + int32_t half = (int32_t)ck_isqrt((uint64_t)(r2 - dy2)); + int32_t x0 = ck_max(d.x, (cx - half) >> 4), x1 = ck_min(d.x + d.w - 1, (cx + half) >> 4); + uint32_t *row = cv->px + (size_t)y * (size_t)cv->w; + for (int32_t x = x0; x <= x1; x++) { + int64_t dx = (int64_t)x * 16 + 8 - cx, d2 = dx * dx + dy2; + if (d2 >= r2) + continue; + uint32_t f = 256u - (uint32_t)((uint64_t)d2 * inv >> 32); + uint32_t w = (f * f >> 8) * f >> 8; /* 0..256 */ + row[x] = ck_add(row[x], color, w * a >> 8); + } + } +} + +static void plot(ck_canvas *cv, const ck_rect *clip, int32_t x, int32_t y, uint32_t color, uint32_t a) +{ + if (!a || x < clip->x || y < clip->y || x >= clip->x + clip->w || y >= clip->y + clip->h || x < 0 || y < 0 || + x >= cv->w || y >= cv->h) + return; + uint32_t *p = cv->px + (size_t)y * (size_t)cv->w + x; + *p = ck_add(*p, color, a); +} + +void ck_thread(ck_canvas *cv, const ck_rect *clip, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color, + uint32_t a0, uint32_t a1) +{ + ck_rect box = {(ck_min(x0, x1) >> 4) - 1, (ck_min(y0, y1) >> 4) - 1, 0, 0}; + box.w = (ck_max(x0, x1) >> 4) - box.x + 3; + box.h = (ck_max(y0, y1) >> 4) - box.y + 3; + if (!ck_meets(box, clip) || (!a0 && !a1)) + return; + int steep = ck_abs(y1 - y0) > ck_abs(x1 - x0); + if (steep) { + int32_t t = x0; + x0 = y0, y0 = t; + t = x1; + x1 = y1, y1 = t; + } + if (x0 > x1) { + int32_t t = x0; + x0 = x1, x1 = t; + t = y0; + y0 = y1, y1 = t; + uint32_t u = a0; + a0 = a1, a1 = u; + } + int32_t len = x1 - x0; + if (len < 1) + len = 1; + int64_t grad = (int64_t)(y1 - y0) * 65536 / len; + /* a slanted thread covers more ground per column: weigh it by its length per column */ + uint32_t slant = (uint32_t)(ck_isqrt((uint64_t)(65536ll * 65536ll + grad * grad)) >> 8); /* 256 = flat */ + int32_t first = (x0 + 7) >> 4, last = (x1 - 8) >> 4; + for (int32_t X = first; X <= last; X++) { + int32_t along = X * 16 + 8 - x0; + int32_t yc = y0 + (int32_t)(along * grad >> 16) - 8; + int32_t Y = yc >> 4, f = yc & 15; + uint32_t a = (uint32_t)((int32_t)a0 + ((int32_t)a1 - (int32_t)a0) * along / len) * slant >> 8; + if (steep) { + plot(cv, clip, Y, X, color, a * (uint32_t)(16 - f) >> 4); + plot(cv, clip, Y + 1, X, color, a * (uint32_t)f >> 4); + } else { + plot(cv, clip, X, Y, color, a * (uint32_t)(16 - f) >> 4); + plot(cv, clip, X, Y + 1, color, a * (uint32_t)f >> 4); + } + } +} + +int32_t ck_sd_rrect(int32_t x, int32_t y, const ck_rect *r, int32_t rad) +{ + int64_t px = (int64_t)x * 16 + 8, py = (int64_t)y * 16 + 8; + int64_t cx = (int64_t)r->x * 16 + (int64_t)r->w * 8, cy = (int64_t)r->y * 16 + (int64_t)r->h * 8; + int64_t qx = (px > cx ? px - cx : cx - px) - ((int64_t)r->w * 8 - rad * 16); + int64_t qy = (py > cy ? py - cy : cy - py) - ((int64_t)r->h * 8 - rad * 16); + int64_t out = qx > 0 && qy > 0 ? (int64_t)ck_isqrt((uint64_t)(qx * qx + qy * qy)) : qx > qy ? qx : qy; + return (int32_t)(out - rad * 16); +} + +uint64_t ck_letter(ck_canvas *cv, const ck_rect *clip, ck_af_face *f, uint64_t pen, int32_t y, char c, + uint32_t color, uint32_t a, int add) +{ + const ck_af_glyph *g = a ? ck_af_glyph_get(f, c) : 0; + if (g && g->alpha) { + int32_t gx = (int32_t)((pen + 128) / 256) + g->ox, gy = y + g->oy; + ck_rect d = {gx, gy, g->w, g->h}; + if (fit(cv, clip, &d)) + for (int32_t yy = d.y; yy < d.y + d.h; yy++) { + uint32_t *row = cv->px + (size_t)yy * (size_t)cv->w; + const uint8_t *m = g->alpha + (size_t)(yy - gy) * g->w; + for (int32_t xx = d.x; xx < d.x + d.w; xx++) { + uint32_t cov = m[xx - gx]; + if (cov) { + uint32_t w = (cov + (cov >> 7)) * a >> 8; + row[xx] = add ? ck_add(row[xx], color, w) : ck_mix(row[xx], color, w); + } + } + } + } + return pen + ck_af_advance(f, c); +} diff --git a/om/allen-scene/native/paint.h b/om/allen-scene/native/paint.h new file mode 100644 index 0000000..a72aa5b --- /dev/null +++ b/om/allen-scene/native/paint.h @@ -0,0 +1,143 @@ +/* paint.h -- the drawing kit shared by the night sky (ui/night.c), Allen's + * presence (ui/mind.c) and his home (ui/allen_ui.c): rectangles, colour + * arithmetic, soft round lights, anti-aliased threads, rounded shapes and + * text, all into a RAM canvas of 0x00RRGGBB pixels; plus the integer + * mathematics they share (sine, atan2, exp, log2, hashed noise). Integer + * only (the kernel builds -mgeneral-regs-only), freestanding, no memory of + * its own beyond fixed tables. Host tested through ui/tests/allen_ui_test.c. + * + * Angles are in 65536ths of a turn. Positions handed to the soft shapes are + * in 16ths of a pixel, so slow movement is smooth rather than stepping a + * whole pixel at a time. */ +#ifndef AIENOS_PAINT_H +#define AIENOS_PAINT_H +#include +#include + +#include "allen_font.h" + +typedef struct { + int32_t x, y, w, h; +} ck_rect; + +typedef struct { + uint32_t *px; /* w * h pixels, rows w apart */ + int32_t w, h; +} ck_canvas; + +#define CK_RGB(r, g, b) ((uint32_t)(r) << 16 | (uint32_t)(g) << 8 | (uint32_t)(b)) + +static inline int32_t ck_min(int32_t a, int32_t b) { return a < b ? a : b; } +static inline int32_t ck_max(int32_t a, int32_t b) { return a > b ? a : b; } +static inline int32_t ck_abs(int32_t a) { return a < 0 ? -a : a; } +static inline int32_t ck_clamp(int32_t v, int32_t lo, int32_t hi) { return v < lo ? lo : v > hi ? hi : v; } + +/* r becomes its overlap with c; 0 when they do not meet. */ +static inline int ck_clip(ck_rect *r, const ck_rect *c) +{ + int32_t x0 = ck_max(r->x, c->x), y0 = ck_max(r->y, c->y); + int32_t x1 = ck_min(r->x + r->w, c->x + c->w), y1 = ck_min(r->y + r->h, c->y + c->h); + if (x1 <= x0 || y1 <= y0) + return 0; + *r = (ck_rect){x0, y0, x1 - x0, y1 - y0}; + return 1; +} + +static inline int ck_meets(ck_rect a, const ck_rect *b) { return ck_clip(&a, b); } +static inline ck_rect ck_grow(ck_rect r, int32_t m) { return (ck_rect){r.x - m, r.y - m, r.w + 2 * m, r.h + 2 * m}; } + +/* The smallest rectangle holding both (an empty one adds nothing). */ +static inline ck_rect ck_union(ck_rect a, ck_rect b) +{ + if (a.w <= 0 || a.h <= 0) + return b; + if (b.w <= 0 || b.h <= 0) + return a; + int32_t x0 = ck_min(a.x, b.x), y0 = ck_min(a.y, b.y); + return (ck_rect){x0, y0, ck_max(a.x + a.w, b.x + b.w) - x0, ck_max(a.y + a.h, b.y + b.h) - y0}; +} + +/* ---- colour: channels 0..255, weights 0..256 ---- */ + +static inline uint32_t ck_ch(uint32_t c, int s) { return c >> s & 255u; } + +/* c scaled by f/256 (f <= 256), all three channels at once */ +static inline uint32_t ck_scale(uint32_t c, uint32_t f) +{ + return ((c & 0xff00ffu) * f >> 8 & 0xff00ffu) | ((c & 0x00ff00u) * f >> 8 & 0x00ff00u); +} + +/* d + c * a / 256 per channel, held at 255 */ +static inline uint32_t ck_add(uint32_t d, uint32_t c, uint32_t a) +{ + uint32_t r = ck_ch(d, 16) + (ck_ch(c, 16) * a >> 8), g = ck_ch(d, 8) + (ck_ch(c, 8) * a >> 8), + b = ck_ch(d, 0) + (ck_ch(c, 0) * a >> 8); + return (r > 255 ? 255u : r) << 16 | (g > 255 ? 255u : g) << 8 | (b > 255 ? 255u : b); +} + +/* d toward c by a/256 */ +static inline uint32_t ck_mix(uint32_t d, uint32_t c, uint32_t a) +{ + if (a >= 256) + return c; + return ck_scale(d, 256 - a) + ck_scale(c, a); +} + +/* ---- easing: t and the result in 0..256 ---- */ + +static inline uint32_t ck_smooth(int32_t t) /* 3t^2 - 2t^3 */ +{ + t = ck_clamp(t, 0, 256); + return (uint32_t)(t * t * (768 - 2 * t) >> 16); +} + +static inline uint32_t ck_ease_out(int32_t t) /* 1 - (1 - t)^3 */ +{ + t = 256 - ck_clamp(t, 0, 256); + return 256u - (uint32_t)(t * t * t >> 16); +} + +/* 0..256 for how far `now` is from `from` to `to` (ms) */ +static inline int32_t ck_prog(uint32_t now, uint32_t from, uint32_t to) +{ + if (now <= from) + return 0; + if (now >= to) + return 256; + return (int32_t)((uint64_t)(now - from) * 256u / (to - from)); +} + +/* ---- mathematics (paint.c) ---- */ + +int32_t ck_sin(uint32_t turn65536); /* scaled by 16384 */ +int32_t ck_cos(uint32_t turn65536); +uint32_t ck_atan2(int32_t y, int32_t x); /* the angle of (x, y), 0..65535 */ +uint32_t ck_exp_neg(uint32_t x256); /* exp(-x/256), scaled by 65536 */ +uint32_t ck_log2_q16(uint64_t v); /* log2(v) * 65536, v >= 1 */ +uint64_t ck_isqrt(uint64_t v); +uint32_t ck_hash(int32_t x, int32_t y, uint32_t seed); +uint32_t ck_noise(int32_t x256, int32_t y256, uint32_t seed); /* smooth value noise, 0..65535 */ +uint32_t ck_fbm(int32_t x256, int32_t y256, uint32_t seed, int octaves); /* 0..65535 */ + +/* ---- shapes (paint.c); each draws only inside the clip rectangle ---- */ + +/* A soft round light at (cx, cy) with radius r (16ths of a pixel): colour + * added with weight a * (1 - d^2/r^2)^3. */ +void ck_glow(ck_canvas *cv, const ck_rect *clip, int32_t cx, int32_t cy, int32_t r, uint32_t color, uint32_t a); +/* A thread one pixel wide from (x0, y0) to (x1, y1) (16ths of a pixel), + * anti-aliased, added as light whose weight runs from a0 to a1 along it. */ +void ck_thread(ck_canvas *cv, const ck_rect *clip, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color, + uint32_t a0, uint32_t a1); +/* Signed distance from a pixel's centre to a rounded rectangle, 16ths of a + * pixel, negative inside; and the coverage of a pixel at such a distance. */ +int32_t ck_sd_rrect(int32_t x, int32_t y, const ck_rect *r, int32_t radius); +static inline uint32_t ck_cover(int32_t d16) +{ + int32_t v = 8 - d16; + return v <= 0 ? 0u : v >= 16 ? 256u : (uint32_t)(v * 16); +} +/* One letter at pen (1/256 px) on baseline y, mixed in with weight a + * (additive light when add is set); returns the pen after it. */ +uint64_t ck_letter(ck_canvas *cv, const ck_rect *clip, ck_af_face *f, uint64_t pen, int32_t y, char c, + uint32_t color, uint32_t a, int add); +#endif diff --git a/om/allen-scene/native/sky_data.c b/om/allen-scene/native/sky_data.c new file mode 100644 index 0000000..2b1bb78 --- /dev/null +++ b/om/allen-scene/native/sky_data.c @@ -0,0 +1,5610 @@ +/* sky_data.c -- GENERATED by native/kernel/tools/ck_sky_gen.c; do not edit. + * Regenerate: scripts/ck_sky_gen.sh (downloads the inputs, checks their sha256). + * + * Stars: Yale Bright Star Catalogue, 5th revised ed. (Hoffleit & Warren 1991), + * CDS catalogue V/50, positions moved by proper motion to 2026.8. + * Milky Way: Gaia DR3 source counts and integrated G-band flux per HEALPix level-7 cell + * (nside=128); G-band extinction from gaiadr3.astrophysical_parameters. + * ESA/Gaia/DPAC, CC BY-NC 3.0 IGO. Credit: ESA/Gaia/DPAC. + * Galaxies: OpenNGC (Mattia Verga), CC BY-SA 4.0. + * View centre: the most probable point of the GW150914 sky map, GWTC-1, + * LIGO/Virgo (LIGO-P1800381-v7). + * Settings: centre RA 113.697 Dec -72.757 deg, 80.0 deg across, roll 0.0 deg, faintest V 6.5, + * grid 360, exposure 0.0600, sky glow 22.0 mag/arcsec2, Milky Way and Clouds gain 1.00 (1.00 = physical). */ +#include "sky_data.h" + +const ck_sky_view ck_sky_the_view = { + .ra_mdeg = 113697, .dec_mdeg = -72757, .fov_mdeg = 80000, .roll_mdeg = 0, + .tan_half_q30 = 900976368, + .rot_q30 = { + {983207820, 431536659, 0}, + {-412141747, 939018691, 318283808}, + {-127918209, 291447275, -1025483750}, + }, +}; + +/* x, y, z: the direction, Q15 (J2000 axes); mag: (V + 2) * 20; bv: palette index */ +const ck_sky_star ck_sky_stars[1035] = { + {-2072, 19750, -26064, 26, 28}, /* HR 2326 Alp Car V -0.72 B-V 0.15 */ + {-12262, -10232, -28611, 40, 55}, /* HR 5459 Alp1Cen V -0.01 B-V 0.71 */ + {16145, 7334, -27554, 49, 12}, /* HR 472 Alp Eri V 0.46 B-V -0.16 */ + {-13891, -8332, -28483, 52, 8}, /* HR 5267 Bet Cen V 0.61 B-V -0.23 */ + {-16180, -3418, -28288, 65, 8}, /* HR 4853 Bet Cru V 1.25 B-V -0.23 */ + {-14726, -1717, -29221, 67, 8}, /* HR 4730 Alp1Cru V 1.33 B-V -0.24 */ + {-12262, -10232, -28611, 67, 64}, /* HR 5460 Alp2Cen V 1.33 B-V 0.88 */ + {-17627, -2412, -27517, 73, 100}, /* HR 4763 Gam Cru V 1.63 B-V 1.59 */ + {-8481, 7557, -30735, 74, 20}, /* HR 3685 Bet Car V 1.68 B-V 0.00 */ + {-14725, -1717, -29221, 75, 7}, /* HR 4731 Alp2Cru V 1.73 B-V -0.26 */ + {-9685, 13514, -28236, 77, 84}, /* HR 3307 Eps Car V 1.86 B-V 1.28 */ + {-3592, -11164, -30596, 78, 92}, /* HR 6217 Alp TrA V 1.92 B-V 1.44 */ + {-12463, 14249, -26745, 79, 22}, /* HR 3485 Del Vel V 1.96 B-V 0.04 */ + {-21163, -3875, -24714, 83, 20}, /* HR 4819 Gam Cen V 2.17 B-V -0.01 */ + {-12687, 10923, -28168, 85, 29}, /* HR 3699 Iot Car V 2.25 B-V 0.18 */ + {-17683, -8235, -26329, 86, 9}, /* HR 5132 Eps Cen V 2.30 B-V -0.22 */ + {-14504, 11944, -26845, 90, 11}, /* HR 3734 Kap Vel V 2.50 B-V -0.18 */ + {-20730, -756, -25365, 92, 14}, /* HR 4621 Del Cen V 2.60 B-V -0.12 */ + {-20236, 6695, -24887, 94, 65}, /* HR 4216 Mu Vel V 2.69 B-V 0.90 */ + {-11517, -1885, -30618, 94, 10}, /* HR 4798 Alp Mus V 2.69 B-V -0.20 */ + {-13368, 4671, -29549, 95, 9}, /* HR 4199 The Car V 2.76 B-V -0.22 */ + {7184, 820, -31959, 96, 51}, /* HR 98 Bet Hyi V 2.80 B-V 0.62 */ + {-16962, -1122, -28013, 96, 8}, /* HR 4656 Del Cru V 2.80 B-V -0.23 */ + {-7595, -12533, -29307, 97, 34}, /* HR 5897 Bet TrA V 2.85 B-V 0.29 */ + {13551, 7728, -28815, 97, 34}, /* HR 591 Alp Hyi V 2.86 B-V 0.28 */ + {-7701, -9090, -30525, 98, 20}, /* HR 5671 Gam TrA V 2.89 B-V 0.00 */ + {-4495, 20300, -25326, 99, 80}, /* HR 2553 Tau Pup V 2.93 B-V 1.20 */ + {-11553, 7567, -29714, 100, 34}, /* HR 3890 Ups Car V 3.01 B-V 0.28 */ + {-11969, -2450, -30404, 101, 11}, /* HR 4844 Bet Mus V 3.05 B-V -0.18 */ + {-14203, 10779, -27491, 103, 98}, /* HR 3803 V 3.13 B-V 1.55 */ + {-14783, 1568, -29201, 103, 18}, /* HR 4467 Lam Cen V 3.13 B-V -0.04 */ + {-10520, -9024, -29691, 104, 32}, /* HR 5463 Alp Cir V 3.19 B-V 0.24 */ + {4872, 7449, -31535, 105, 101}, /* HR 1208 Gam Hyi V 3.24 B-V 1.62 */ + {6880, 17467, -26856, 105, 15}, /* HR 1465 Alp Dor V 3.27 B-V -0.10 */ + {-3217, 15074, -28915, 105, 30}, /* HR 2550 Alp Pic V 3.27 B-V 0.21 */ + {-10005, 5003, -30798, 106, 16}, /* HR 4037 Ome Car V 3.32 B-V -0.08 */ + {-14411, 5821, -28847, 106, 16}, /* HR 4140 V 3.32 B-V -0.09 */ + {6732, 13565, -29058, 107, 66}, /* HR 1336 Alp Ret V 3.35 B-V 0.91 */ + {-14161, 6824, -28750, 108, 97}, /* HR 4050 V 3.40 B-V 1.54 */ + {-12502, 11360, -28077, 109, 10}, /* HR 3659 V 3.44 B-V -0.19 */ + {-9623, 17222, -26163, 109, 11}, /* HR 3117 Chi Car V 3.47 B-V -0.18 */ + {-16320, 9722, -26699, 111, 16}, /* HR 3940 Phi Vel V 3.54 B-V -0.08 */ + {16880, 11441, -25648, 111, 14}, /* HR 674 Phi Eri V 3.56 B-V -0.12 */ + {-16115, -1506, -28491, 112, 91}, /* HR 4700 Eps Cru V 3.59 B-V 1.42 */ + {-12718, 15117, -26142, 112, 11}, /* HR 3447 V 3.62 B-V -0.18 */ + {-9990, -2784, -31083, 112, 79}, /* HR 4923 Del Mus V 3.62 B-V 1.18 */ + {-12920, 813, -30101, 113, 28}, /* HR 4520 Lam Mus V 3.64 B-V 0.16 */ + {-12586, 8390, -29067, 114, 81}, /* HR 3884 V 3.69 B-V 1.22 */ + {17799, 9865, -25682, 114, 62}, /* HR 566 Chi Eri V 3.70 B-V 0.85 */ + {-16056, 15484, -24002, 115, 80}, /* HR 3614 V 3.75 B-V 1.20 */ + {1738, 15035, -29062, 115, 61}, /* HR 1922 Bet Dor V 3.76 B-V 0.82 */ + {5885, -4065, -31977, 115, 70}, /* HR 8254 Nu Oct V 3.76 B-V 1.00 */ + {-7872, 10665, -29966, 115, 76}, /* HR 3347 Bet Vol V 3.77 B-V 1.13 */ + {-3232, 10450, -30887, 116, 72}, /* HR 2736 Gam2Vol V 3.78 B-V 1.04 */ + {-16240, 4849, -28043, 116, 68}, /* HR 4257 V 3.78 B-V 0.95 */ + {-15649, 6652, -28010, 116, 36}, /* HR 4114 V 3.82 B-V 0.31 */ + {-4630, -4164, -32170, 117, 92}, /* HR 5470 Alp Aps V 3.83 B-V 1.43 */ + {-11110, 11601, -28560, 117, 15}, /* HR 3571 V 3.84 B-V -0.10 */ + {-20423, 7708, -24437, 117, 35}, /* HR 4167 V 3.84 B-V 0.30 */ + {7789, 11571, -29650, 117, 76}, /* HR 1175 Bet Ret V 3.85 B-V 1.13 */ + {1142, 20560, -25488, 117, 29}, /* HR 2020 Bet Pic V 3.85 B-V 0.17 */ + {-21785, 10775, -21977, 117, 22}, /* HR 4023 V 3.85 B-V 0.05 */ + {10814, 21691, -22051, 117, 75}, /* HR 1326 Alp Hor V 3.86 B-V 1.10 */ + {-21402, -3552, -24557, 117, 22}, /* HR 4802 Tau Cen V 3.86 B-V 0.05 */ + {-9952, -1419, -31187, 117, 12}, /* HR 4773 Gam Mus V 3.87 B-V -0.15 */ + {-18757, 3223, -26673, 118, 12}, /* HR 4390 Pi Cen V 3.89 B-V -0.15 */ + {-2327, -5865, -32154, 118, 66}, /* HR 6102 Gam Aps V 3.89 B-V 0.91 */ + {-16465, 3757, -28079, 118, 82}, /* HR 4337 V 3.91 B-V 1.23 */ + {-20804, -2558, -25186, 118, 10}, /* HR 4743 Sig Cen V 3.91 B-V -0.19 */ + {17854, 5491, -26921, 118, 16}, /* HR 338 Zet Phe V 3.92 B-V -0.08 */ + {-4210, 8844, -31269, 119, 72}, /* HR 3024 Zet Vol V 3.95 B-V 1.04 */ + {-19981, -1017, -25950, 119, 12}, /* HR 4638 Rho Cen V 3.96 B-V -0.15 */ + {-11280, 10222, -29016, 119, 11}, /* HR 3663 V 3.97 B-V -0.18 */ + {-4046, 11613, -30372, 120, 59}, /* HR 2803 Del Vol V 3.98 B-V 0.79 */ + {15320, 14524, -25061, 120, 125}, /* HR 868 V 4.00 B-V 2.11 */ + {-9376, 9178, -30026, 120, 27}, /* HR 3615 Alp Vol V 4.00 B-V 0.14 */ + {-8241, 3652, -31503, 120, 38}, /* HR 4102 V 4.00 B-V 0.35 */ + {-17259, -4191, -27536, 121, 12}, /* HR 4898 Mu 1Cru V 4.03 B-V -0.17 */ + {-14316, -1154, -29452, 121, 12}, /* HR 4679 Zet Cru V 4.04 B-V -0.17 */ + {-4215, 6102, -31917, 121, 40}, /* HR 3318 Alp Cha V 4.07 B-V 0.39 */ + {-11051, -12883, -28028, 121, 24}, /* HR 5670 Bet Cir V 4.07 B-V 0.09 */ + {-13495, 9945, -28154, 122, 20}, /* HR 3825 V 4.08 B-V 0.01 */ + {9715, 6914, -30520, 122, 22}, /* HR 705 Del Hyi V 4.09 B-V 0.03 */ + {9308, 7783, -30438, 122, 17}, /* HR 806 Eps Hyi V 4.11 B-V -0.06 */ + {-6037, 2334, -32121, 122, 99}, /* HR 4174 Gam Cha V 4.11 B-V 1.58 */ + {-15769, 929, -28708, 122, 65}, /* HR 4522 V 4.11 B-V 0.90 */ + {-12259, -941, -30373, 122, 99}, /* HR 4671 Eps Mus V 4.11 B-V 1.58 */ + {-7703, -10672, -30008, 122, 78}, /* HR 5771 Eps TrA V 4.11 B-V 1.17 */ + {-14041, -422, -29603, 123, 37}, /* HR 4616 Eta Cru V 4.15 B-V 0.34 */ + {4657, -1557, -32397, 123, 30}, /* HR 8630 Bet Oct V 4.15 B-V 0.20 */ + {13863, 1225, -29665, 125, 49}, /* HR 77 Zet Tuc V 4.23 B-V 0.58 */ + {-2333, -6685, -31993, 125, 73}, /* HR 6163 Bet Aps V 4.24 B-V 1.06 */ + {8942, 18341, -25638, 125, 35}, /* HR 1338 Gam Dor V 4.25 B-V 0.30 */ + {-6057, -486, -32199, 125, 14}, /* HR 4674 Bet Cha V 4.26 B-V -0.12 */ + {-20210, -6074, -25066, 125, 10}, /* HR 4942 Xi 2Cen V 4.27 B-V -0.19 */ + {-17375, 6384, -27038, 126, 72}, /* HR 4180 V 4.28 B-V 1.04 */ + {-14458, 651, -29398, 126, 12}, /* HR 4537 V 4.32 B-V -0.15 */ + {-2897, -2161, -32567, 126, 86}, /* HR 5339 Del Oct V 4.32 B-V 1.31 */ + {-10641, 12612, -28308, 127, 15}, /* HR 3457 V 4.33 B-V -0.11 */ + {-14715, -194, -29276, 127, 34}, /* HR 4599 The1Cru V 4.33 B-V 0.27 */ + {-20946, -4943, -24708, 127, 88}, /* HR 4888 V 4.33 B-V 1.37 */ + {-14844, -10425, -27288, 127, 26}, /* HR 5358 V 4.33 B-V 0.12 */ + {-13282, 11526, -27648, 127, 101}, /* HR 3696 V 4.34 B-V 1.63 */ + {894, 13436, -29872, 127, 30}, /* HR 2015 Del Dor V 4.35 B-V 0.21 */ + {-6328, 10133, -30511, 127, 15}, /* HR 3223 Eps Vol V 4.35 B-V -0.11 */ + {-4089, 5806, -31988, 127, 78}, /* HR 3340 The Cha V 4.35 B-V 1.16 */ + {-17312, 12483, -24862, 127, 29}, /* HR 3836 V 4.35 B-V 0.17 */ + {17309, 3314, -27624, 127, 20}, /* HR 191 Eta Phe V 4.36 B-V 0.00 */ + {14756, 2044, -29185, 127, 16}, /* HR 126 Bet1Tuc V 4.37 B-V -0.07 */ + {-3000, 19502, -26160, 128, 19}, /* HR 2435 V 4.39 B-V -0.02 */ + {-23442, 6264, -22021, 128, 26}, /* HR 4293 V 4.39 B-V 0.11 */ + {-4194, 18976, -26381, 128, 66}, /* HR 2554 V 4.40 B-V 0.92 */ + {-10553, 18607, -24821, 128, 12}, /* HR 3129 V 4.41 B-V -0.17 */ + {7301, 15050, -28176, 129, 74}, /* HR 1355 Eps Ret V 4.44 B-V 1.08 */ + {8290, 22951, -21868, 129, 37}, /* HR 1502 Alp Cae V 4.45 B-V 0.34 */ + {-16399, 6329, -27653, 129, 101}, /* HR 4159 V 4.45 B-V 1.62 */ + {-5105, 1714, -32321, 129, 10}, /* HR 4234 Del2Cha V 4.45 B-V -0.19 */ + {-23082, 893, -23240, 129, 85}, /* HR 4546 V 4.46 B-V 1.30 */ + {-20758, -733, -25342, 129, 12}, /* HR 4618 V 4.47 B-V -0.15 */ + {-7081, 6770, -31268, 130, 50}, /* HR 3643 V 4.48 B-V 0.61 */ + {-11940, 13412, -27409, 130, 12}, /* HR 3498 V 4.49 B-V -0.17 */ + {-16619, 7669, -27179, 130, 14}, /* HR 4074 V 4.50 B-V -0.12 */ + {13548, -5, -29835, 130, 16}, /* HR 9076 Eps Tuc V 4.50 B-V -0.08 */ + {7599, 13282, -28974, 130, 102}, /* HR 1264 Gam Ret V 4.51 B-V 1.65 */ + {809, 18226, -27218, 130, 75}, /* HR 2042 Gam Pic V 4.51 B-V 1.10 */ + {-10557, -12964, -28181, 130, 30}, /* HR 5704 Gam Cir V 4.51 B-V 0.19 */ + {-12853, 9054, -28749, 130, 16}, /* HR 3856 V 4.52 B-V -0.07 */ + {-14870, -5606, -28655, 131, 14}, /* HR 5035 V 4.53 B-V -0.13 */ + {-13152, -5049, -29584, 131, 62}, /* HR 5041 V 4.53 B-V 0.85 */ + {14752, 2045, -29187, 131, 28}, /* HR 127 Bet2Tuc V 4.54 B-V 0.15 */ + {7917, 13541, -28769, 131, 101}, /* HR 1247 Del Ret V 4.56 B-V 1.62 */ + {-17008, 7966, -26851, 131, 101}, /* HR 4063 V 4.57 B-V 1.62 */ + {-15214, 5273, -28538, 131, 105}, /* HR 4200 V 4.57 B-V 1.71 */ + {-19094, 11969, -23787, 132, 80}, /* HR 3912 V 4.58 B-V 1.20 */ + {-25132, 7121, -19783, 132, 72}, /* HR 4273 Iot Ant V 4.60 B-V 1.03 */ + {-15880, 3332, -28467, 132, 48}, /* HR 4352 V 4.60 B-V 0.55 */ + {-15612, -5094, -28354, 132, 16}, /* HR 4975 V 4.60 B-V -0.08 */ + {-14758, 3506, -29045, 132, 72}, /* HR 4325 V 4.61 B-V 1.03 */ + {-19022, 2103, -26598, 132, 16}, /* HR 4460 V 4.62 B-V -0.08 */ + {-16329, -3969, -28130, 132, 12}, /* HR 4897 Lam Cru V 4.62 B-V -0.15 */ + {-10054, 18700, -24958, 133, 8}, /* HR 3089 V 4.63 B-V -0.23 */ + {381, 14827, -29218, 133, 73}, /* HR 2102 V 4.65 B-V 1.05 */ + {-17721, -3636, -27320, 133, 12}, /* HR 4848 V 4.65 B-V -0.16 */ + {-18255, -9167, -25620, 133, 68}, /* HR 5172 V 4.65 B-V 0.96 */ + {-16127, 6895, -27678, 133, 46}, /* HR 4110 V 4.66 B-V 0.51 */ + {-15743, 5827, -28141, 133, 94}, /* HR 4177 V 4.66 B-V 1.48 */ + {-21206, -3986, -24659, 133, 75}, /* HR 4831 V 4.66 B-V 1.09 */ + {-2706, -5825, -32131, 134, 104}, /* HR 6020 Del1Aps V 4.68 B-V 1.69 */ + {10927, 5991, -30305, 134, 68}, /* HR 570 Eta2Hyi V 4.69 B-V 0.95 */ + {-13806, 14256, -26073, 134, 14}, /* HR 3574 V 4.69 B-V -0.12 */ + {-15581, -3144, -28654, 134, 73}, /* HR 4842 Iot Cru V 4.69 B-V 1.05 */ + {-7907, 7527, -30895, 134, 12}, /* HR 3642 V 4.71 B-V -0.15 */ + {-12653, -7133, -29372, 134, 76}, /* HR 5241 V 4.71 B-V 1.11 */ + {9107, 11805, -29179, 134, 40}, /* HR 1083 Kap Ret V 4.72 B-V 0.40 */ + {4150, 17124, -27627, 134, 46}, /* HR 1674 Zet Dor V 4.72 B-V 0.52 */ + {-12884, 662, -30121, 134, 97}, /* HR 4530 Mu Mus V 4.72 B-V 1.54 */ + {-14789, -279, -29238, 134, 16}, /* HR 4603 The2Cru V 4.72 B-V -0.08 */ + {-9364, 3862, -31162, 135, 22}, /* HR 4138 V 4.74 B-V 0.04 */ + {6214, 5717, -31660, 135, 86}, /* HR 872 Nu Hyi V 4.75 B-V 1.33 */ + {-16466, -10480, -26320, 135, 67}, /* HR 5297 V 4.75 B-V 0.94 */ + {-8396, 13306, -28743, 135, 42}, /* HR 3220 V 4.76 B-V 0.43 */ + {7333, 51, -31936, 136, 84}, /* HR 9084 The Oct V 4.78 B-V 1.27 */ + {-11672, -3976, -30358, 136, 16}, /* HR 4993 Eta Mus V 4.80 B-V -0.08 */ + {-845, 18790, -26831, 136, 8}, /* HR 2212 Del Pic V 4.81 B-V -0.23 */ + {-11668, 9708, -29039, 136, 67}, /* HR 3728 V 4.81 B-V 0.94 */ + {-7311, 12621, -29341, 136, 12}, /* HR 3159 V 4.82 B-V -0.17 */ + {-12651, 17651, -24537, 136, 12}, /* HR 3294 V 4.82 B-V -0.15 */ + {-13319, 4701, -29567, 136, 13}, /* HR 4196 V 4.82 B-V -0.14 */ + {-13603, 4676, -29441, 136, 14}, /* HR 4205 V 4.82 B-V -0.13 */ + {-20283, -2358, -25626, 136, 13}, /* HR 4732 V 4.82 B-V -0.14 */ + {2546, 12448, -30203, 137, 84}, /* HR 1744 The Dor V 4.83 B-V 1.28 */ + {-22294, 10122, -21776, 137, 76}, /* HR 4080 V 4.83 B-V 1.12 */ + {9362, 8250, -30298, 137, 23}, /* HR 837 Zet Hyi V 4.84 B-V 0.06 */ + {-13451, 4445, -29546, 137, 12}, /* HR 4222 V 4.85 B-V -0.15 */ + {-20456, -5822, -24926, 137, 21}, /* HR 4933 Xi 1Cen V 4.85 B-V 0.02 */ + {11169, 3835, -30565, 137, 44}, /* HR 377 Kap Tuc V 4.86 B-V 0.47 */ + {-10885, 13523, -27791, 137, 70}, /* HR 3414 V 4.86 B-V 1.00 */ + {-12801, 14932, -26208, 137, 12}, /* HR 3467 V 4.86 B-V -0.17 */ + {-17926, 9437, -25754, 137, 14}, /* HR 3990 V 4.86 B-V -0.12 */ + {-14714, -1710, -29227, 137, 14}, /* HR 4729 V 4.86 B-V -0.12 */ + {-9476, -11060, -29352, 137, 82}, /* HR 5666 Eps Cir V 4.86 B-V 1.25 */ + {-12191, -4270, -30114, 137, 95}, /* HR 5002 V 4.87 B-V 1.50 */ + {-17959, 7316, -26413, 138, 45}, /* HR 4134 V 4.89 B-V 0.50 */ + {-13732, 489, -29747, 138, 15}, /* HR 4549 V 4.90 B-V -0.11 */ + {-6688, 11, -32077, 138, 17}, /* HR 4583 Eps Cha V 4.91 B-V -0.06 */ + {-4218, -2905, -32364, 138, 32}, /* HR 5303 Eta Aps V 4.91 B-V 0.25 */ + {-4340, -10284, -30807, 138, 48}, /* HR 6098 Zet TrA V 4.91 B-V 0.55 */ + {-11696, 12009, -28154, 138, 10}, /* HR 3582 V 4.92 B-V -0.19 */ + {-15950, -5355, -28118, 138, 44}, /* HR 4989 V 4.92 B-V 0.48 */ + {-13928, -9991, -27926, 138, 63}, /* HR 5371 V 4.92 B-V 0.86 */ + {11165, 21643, -21922, 139, 36}, /* HR 1302 Del Hor V 4.93 B-V 0.33 */ + {-3662, 21522, -24435, 139, 64}, /* HR 2462 V 4.93 B-V 0.87 */ + {-5846, 20424, -24947, 139, 26}, /* HR 2672 V 4.93 B-V 0.13 */ + {-8755, 3580, -31372, 139, 104}, /* HR 4142 V 4.93 B-V 1.68 */ + {-16263, -3010, -28287, 139, 18}, /* HR 4823 V 4.93 B-V -0.04 */ + {-8080, 18221, -26008, 139, 90}, /* HR 2934 V 4.94 B-V 1.40 */ + {-15284, 1277, -28956, 139, 77}, /* HR 4499 V 4.94 B-V 1.15 */ + {-5254, 20969, -24625, 139, 104}, /* HR 2608 V 4.95 B-V 1.69 */ + {7845, 13769, -28680, 139, 91}, /* HR 1266 Iot Ret V 4.97 B-V 1.42 */ + {-11075, 486, -30835, 139, 90}, /* HR 4538 V 4.97 B-V 1.40 */ + {10184, 10078, -29469, 140, 26}, /* HR 909 Bet Hor V 4.99 B-V 0.13 */ + {-11720, 5281, -30140, 140, 14}, /* HR 4089 V 4.99 B-V -0.13 */ + {-18663, -1550, -26888, 140, 100}, /* HR 4682 V 5.00 B-V 1.59 */ + {14210, -149, -29525, 140, 23}, /* HR 9062 Eta Tuc V 5.00 B-V 0.06 */ + {7491, 5386, -31441, 140, 75}, /* HR 715 Kap Hyi V 5.01 B-V 1.09 */ + {-664, 13526, -29838, 140, 101}, /* HR 2245 Eta2Dor V 5.01 B-V 1.62 */ + {-13179, 16461, -25080, 140, 86}, /* HR 3407 V 5.01 B-V 1.33 */ + {-16493, 12188, -25556, 140, 11}, /* HR 3819 V 5.01 B-V -0.18 */ + {-17158, -8160, -26696, 140, 18}, /* HR 5141 V 5.01 B-V -0.05 */ + {-20753, 8285, -23966, 140, 72}, /* HR 4143 V 5.02 B-V 1.04 */ + {5053, 20637, -24945, 141, 94}, /* HR 1663 Eta2Pic V 5.03 B-V 1.49 */ + {-15096, 1087, -29062, 141, 60}, /* HR 4511 V 5.03 B-V 0.80 */ + {17430, 8701, -26347, 141, 22}, /* HR 520 V 5.04 B-V 0.04 */ + {-7637, -159, -31864, 141, 94}, /* HR 4605 Kap Cha V 5.04 B-V 1.49 */ + {-471, 15297, -28973, 141, 82}, /* HR 2196 V 5.05 B-V 1.25 */ + {-7960, -3100, -31634, 141, 76}, /* HR 5042 Iot1Mus V 5.05 B-V 1.11 */ + {-450, 11818, -30558, 141, 16}, /* HR 2221 Nu Dor V 5.06 B-V -0.08 */ + {-19003, -7815, -25524, 141, 24}, /* HR 5071 V 5.06 B-V 0.07 */ + {-4577, -3276, -32280, 141, 15}, /* HR 5336 Eps Aps V 5.06 B-V -0.10 */ + {8332, 1794, -31639, 141, 88}, /* HR 236 Lam Hyi V 5.07 B-V 1.37 */ + {8796, 21455, -23151, 141, 10}, /* HR 1443 Del Cae V 5.07 B-V -0.19 */ + {-7679, 11139, -29843, 141, 77}, /* HR 3280 V 5.07 B-V 1.15 */ + {-14807, -9889, -27507, 141, 16}, /* HR 5316 V 5.07 B-V -0.08 */ + {-19287, 12293, -23464, 142, 15}, /* HR 3898 V 5.08 B-V -0.10 */ + {-19511, 10573, -24108, 142, 64}, /* HR 3976 V 5.08 B-V 0.88 */ + {-15505, 5926, -28252, 142, 79}, /* HR 4164 V 5.08 B-V 1.18 */ + {-23865, 3292, -22210, 142, 18}, /* HR 4423 V 5.08 B-V -0.03 */ + {14709, 2115, -29204, 142, 22}, /* HR 136 Bet3Tuc V 5.09 B-V 0.04 */ + {-385, 8608, -31614, 142, 56}, /* HR 2261 Alp Men V 5.09 B-V 0.72 */ + {-11816, 15737, -26199, 142, 32}, /* HR 3350 V 5.09 B-V 0.25 */ + {-10386, -12048, -28647, 142, 17}, /* HR 5664 Del Cir V 5.09 B-V -0.06 */ + {-6180, -10233, -30509, 142, 76}, /* HR 5891 Kap TrA V 5.09 B-V 1.13 */ + {-7585, 19166, -25471, 142, 73}, /* HR 2862 V 5.10 B-V 1.06 */ + {4932, -2299, -32312, 142, 94}, /* HR 8481 Eps Oct V 5.10 B-V 1.47 */ + {11491, 11859, -28302, 142, 37}, /* HR 934 Mu Hor V 5.11 B-V 0.34 */ + {567, 12843, -30140, 142, 13}, /* HR 2064 Eps Dor V 5.11 B-V -0.14 */ + {-15313, 12148, -26299, 142, 15}, /* HR 3753 V 5.11 B-V -0.11 */ + {-4145, 3071, -32358, 142, 13}, /* HR 3860 Zet Cha V 5.11 B-V -0.14 */ + {-13694, 2208, -29686, 142, 16}, /* HR 4401 V 5.11 B-V -0.08 */ + {-10748, -10446, -29138, 142, 20}, /* HR 5551 The Cir V 5.11 B-V 0.00 */ + {4547, -157, -32450, 142, 66}, /* HR 9032 Gam1Oct V 5.11 B-V 0.92 */ + {-17264, 12805, -24731, 142, 14}, /* HR 3817 V 5.12 B-V -0.12 */ + {-15023, 3429, -28917, 143, 31}, /* HR 4338 V 5.13 B-V 0.22 */ + {-16533, 2047, -28216, 143, 74}, /* HR 4441 Omi1Cen V 5.13 B-V 1.08 */ + {2477, 16737, -28061, 143, 70}, /* HR 1836 Lam Dor V 5.14 B-V 1.00 */ + {-5365, 19725, -25609, 143, 101}, /* HR 2652 V 5.14 B-V 1.61 */ + {-6544, 20508, -24704, 143, 82}, /* HR 2719 V 5.14 B-V 1.24 */ + {-23470, 5497, -22195, 143, 22}, /* HR 4327 V 5.15 B-V 0.03 */ + {-16497, 2039, -28238, 143, 44}, /* HR 4442 Omi2Cen V 5.15 B-V 0.49 */ + {-15665, 1578, -28737, 143, 76}, /* HR 4475 V 5.15 B-V 1.12 */ + {-15400, 1475, -28885, 143, 19}, /* HR 4487 V 5.15 B-V -0.02 */ + {-12469, -1207, -30278, 143, 30}, /* HR 4703 Zet2Mus V 5.15 B-V 0.19 */ + {5308, -5093, -31931, 143, 44}, /* HR 8021 Alp Oct V 5.15 B-V 0.49 */ + {-8303, 12395, -29174, 143, 24}, /* HR 3260 V 5.16 B-V 0.09 */ + {-13846, 15974, -25036, 143, 10}, /* HR 3476 V 5.16 B-V -0.20 */ + {-11873, 11937, -28111, 143, 41}, /* HR 3598 V 5.16 B-V 0.42 */ + {-11740, 5885, -30020, 143, 30}, /* HR 4025 V 5.16 B-V 0.21 */ + {-19899, -5060, -25536, 143, 17}, /* HR 4913 V 5.16 B-V -0.06 */ + {800, 20108, -25859, 143, 70}, /* HR 2049 V 5.17 B-V 0.99 */ + {-3180, 11903, -30363, 143, 90}, /* HR 2662 V 5.17 B-V 1.40 */ + {-4975, 17263, -27403, 143, 18}, /* HR 2683 V 5.17 B-V -0.04 */ + {-8023, 13949, -28543, 143, 107}, /* HR 3153 V 5.17 B-V 1.74 */ + {-12038, 16340, -25725, 143, 12}, /* HR 3330 V 5.17 B-V -0.16 */ + {-14217, 2144, -29444, 143, 45}, /* HR 4413 V 5.17 B-V 0.50 */ + {-13587, 1219, -29792, 143, 60}, /* HR 4492 V 5.17 B-V 0.80 */ + {-17263, -4193, -27533, 143, 14}, /* HR 4899 Mu 2Cru V 5.17 B-V -0.12 */ + {-9930, -10356, -29459, 143, 66}, /* HR 5593 Eta Cir V 5.17 B-V 0.93 */ + {-15654, 15810, -24055, 144, 32}, /* HR 3588 V 5.18 B-V 0.25 */ + {-8273, -282, -31704, 144, 85}, /* HR 4617 V 5.18 B-V 1.30 */ + {947, 7681, -31840, 144, 76}, /* HR 1953 Gam Men V 5.19 B-V 1.13 */ + {-12657, 15089, -26188, 144, 13}, /* HR 3442 V 5.19 B-V -0.14 */ + {3327, 14289, -29299, 144, 102}, /* HR 1695 V 5.20 B-V 1.65 */ + {-7036, 8453, -30866, 144, 20}, /* HR 3460 The Vol V 5.20 B-V 0.01 */ + {-11766, -11319, -28410, 144, 78}, /* HR 5546 V 5.20 B-V 1.16 */ + {14523, 12258, -26693, 144, 40}, /* HR 802 Zet Hor V 5.21 B-V 0.40 */ + {-14920, -13319, -25955, 144, 69}, /* HR 5495 V 5.21 B-V 0.98 */ + {-2298, 17769, -27435, 144, 75}, /* HR 2389 V 5.22 B-V 1.09 */ + {-14312, 14096, -25887, 145, 14}, /* HR 3605 V 5.23 B-V -0.12 */ + {-13503, 4486, -29516, 145, 16}, /* HR 4220 V 5.23 B-V -0.07 */ + {-17058, 5628, -27405, 145, 16}, /* HR 4221 V 5.23 B-V -0.08 */ + {-13974, 2923, -29493, 145, 17}, /* HR 4355 V 5.23 B-V -0.06 */ + {-12907, -9024, -28734, 145, 34}, /* HR 5349 V 5.23 B-V 0.29 */ + {9811, 11517, -29065, 145, 50}, /* HR 1010 Zet2Ret V 5.24 B-V 0.60 */ + {6094, 13355, -29295, 145, 68}, /* HR 1395 Eta Ret V 5.24 B-V 0.96 */ + {-16968, 5146, -27555, 145, 28}, /* HR 4250 V 5.25 B-V 0.16 */ + {-21955, 2315, -24213, 145, 32}, /* HR 4466 V 5.25 B-V 0.25 */ + {-17484, -9304, -26104, 145, 16}, /* HR 5207 V 5.25 B-V -0.09 */ + {11083, 10070, -29145, 145, 25}, /* HR 852 Nu Hor V 5.26 B-V 0.10 */ + {-10815, 13445, -27856, 145, 13}, /* HR 3415 V 5.26 B-V -0.14 */ + {-15669, 13371, -25483, 145, 16}, /* HR 3703 V 5.26 B-V -0.07 */ + {5353, 15624, -28300, 145, 30}, /* HR 1530 Kap Dor V 5.27 B-V 0.20 */ + {-2719, 20780, -25189, 145, 40}, /* HR 2384 V 5.27 B-V 0.41 */ + {-13892, 12258, -27027, 145, 70}, /* HR 3679 V 5.27 B-V 0.99 */ + {-2710, -5841, -32128, 145, 90}, /* HR 6021 Del2Aps V 5.27 B-V 1.41 */ + {4429, 194, -32466, 146, 73}, /* HR 30 Gam3Oct V 5.28 B-V 1.05 */ + {4883, 3805, -32177, 146, 69}, /* HR 776 Mu Hyi V 5.28 B-V 0.98 */ + {-11872, 6266, -29891, 146, 69}, /* HR 3995 V 5.28 B-V 0.98 */ + {-18336, 9204, -25549, 146, 32}, /* HR 4017 V 5.28 B-V 0.25 */ + {324, -1329, -32738, 146, 84}, /* HR 6721 Chi Oct V 5.28 B-V 1.28 */ + {448, 19882, -26042, 146, 36}, /* HR 2094 V 5.29 B-V 0.31 */ + {-5438, 7620, -31401, 146, 20}, /* HR 3334 Eta Vol V 5.29 B-V 0.01 */ + {-6479, 5562, -31635, 146, 21}, /* HR 3720 V 5.29 B-V 0.02 */ + {-13162, 5528, -29494, 146, 113}, /* HR 4120 V 5.29 B-V 1.86 */ + {-22845, 1424, -23447, 146, 14}, /* HR 4519 V 5.29 B-V -0.12 */ + {3511, -2217, -32503, 146, 57}, /* HR 8280 Lam Oct V 5.29 B-V 0.75 */ + {9134, -4031, -31209, 146, 52}, /* HR 8515 Nu Ind V 5.29 B-V 0.65 */ + {-15660, 2299, -28691, 146, 16}, /* HR 4415 V 5.30 B-V -0.08 */ + {15409, 12636, -26011, 146, 34}, /* HR 778 Eta Hor V 5.31 B-V 0.27 */ + {6894, 19678, -25277, 146, 69}, /* HR 1516 Lam Pic V 5.31 B-V 0.98 */ + {2597, 10172, -31040, 146, 70}, /* HR 1677 Bet Men V 5.31 B-V 1.00 */ + {1330, 22476, -23807, 146, 72}, /* HR 2008 V 5.31 B-V 1.04 */ + {-14587, -2759, -29211, 146, 34}, /* HR 4830 V 5.31 B-V 0.27 */ + {-13149, -5128, -29571, 146, 40}, /* HR 5048 V 5.31 B-V 0.40 */ + {-14261, 9920, -27783, 146, 30}, /* HR 3863 V 5.32 B-V 0.20 */ + {-17393, -4332, -27430, 146, 20}, /* HR 4908 V 5.32 B-V 0.01 */ + {-13295, 17472, -24324, 147, 13}, /* HR 3358 V 5.33 B-V -0.14 */ + {-15221, 16062, -24166, 147, 33}, /* HR 3551 V 5.33 B-V 0.26 */ + {9983, 21234, -22872, 147, 74}, /* HR 1364 V 5.34 B-V 1.08 */ + {1675, 14148, -29508, 147, 72}, /* HR 1917 V 5.34 B-V 1.04 */ + {-13376, 4458, -29579, 147, 15}, /* HR 4219 V 5.34 B-V -0.10 */ + {-21615, -778, -24614, 147, 20}, /* HR 4620 V 5.34 B-V -0.01 */ + {-5394, -5295, -31883, 147, 92}, /* HR 5540 V 5.34 B-V 1.45 */ + {13092, 9590, -28466, 147, 40}, /* HR 714 Lam Hor V 5.35 B-V 0.39 */ + {-8748, 9498, -30116, 147, 41}, /* HR 3537 V 5.35 B-V 0.42 */ + {-12097, -245, -30451, 147, 20}, /* HR 4604 V 5.35 B-V -0.01 */ + {5363, -1681, -32281, 147, 12}, /* HR 8663 Xi Oct V 5.35 B-V -0.15 */ + {-4079, 3300, -32344, 147, 43}, /* HR 3795 Iot Cha V 5.36 B-V 0.45 */ + {-20995, 4410, -24767, 147, 29}, /* HR 4350 V 5.36 B-V 0.18 */ + {-11219, -9864, -29163, 147, 34}, /* HR 5482 V 5.36 B-V 0.29 */ + {14833, 4487, -28871, 147, 64}, /* HR 332 Iot Tuc V 5.37 B-V 0.88 */ + {-5952, 8515, -31076, 147, 17}, /* HR 3301 Kap1Vol V 5.37 B-V -0.06 */ + {5293, 20768, -24786, 148, 41}, /* HR 1649 Eta1Pic V 5.38 B-V 0.42 */ + {-1262, 11304, -30730, 148, 68}, /* HR 2377 Pi 2Dor V 5.38 B-V 0.97 */ + {-23552, 9134, -20870, 148, 127}, /* HR 4153 V 5.38 B-V 2.88 */ + {-15825, 5551, -28150, 148, 33}, /* HR 4198 V 5.38 B-V 0.26 */ + {-15326, -7311, -28024, 148, 18}, /* HR 5140 V 5.38 B-V -0.03 */ + {-14230, -13777, -26103, 148, 26}, /* HR 5556 V 5.38 B-V 0.13 */ + {13372, 2507, -29809, 148, 45}, /* HR 187 Rho Tuc V 5.39 B-V 0.50 */ + {-6940, 18901, -25851, 148, 16}, /* HR 2815 V 5.39 B-V -0.07 */ + {-9031, 7762, -30527, 148, 41}, /* HR 3712 V 5.39 B-V 0.42 */ + {-17434, -1742, -27689, 148, 15}, /* HR 4706 V 5.39 B-V -0.10 */ + {5451, 14343, -28952, 148, 99}, /* HR 1492 V 5.40 B-V 1.58 */ + {-4165, 20075, -25560, 148, 87}, /* HR 2523 V 5.40 B-V 1.34 */ + {-2379, 10420, -30975, 148, 15}, /* HR 2602 Iot Vol V 5.40 B-V -0.11 */ + {15715, 13490, -25392, 148, 48}, /* HR 810 Iot Hor V 5.41 B-V 0.56 */ + {-17484, 969, -27696, 148, 103}, /* HR 4526 V 5.41 B-V 1.67 */ + {-1726, 1778, -32673, 148, 36}, /* HR 3678 Zet Oct V 5.42 B-V 0.31 */ + {-21927, 2154, -24254, 149, 82}, /* HR 4476 V 5.44 B-V 1.24 */ + {-18172, 139, -27266, 149, 16}, /* HR 4576 V 5.44 B-V -0.08 */ + {11132, 2724, -30697, 149, 75}, /* HR 270 Lam2Tuc V 5.45 B-V 1.09 */ + {6772, 13705, -28983, 149, 75}, /* HR 1340 V 5.45 B-V 1.10 */ + {3668, 20470, -25322, 149, 46}, /* HR 1767 Zet Pic V 5.45 B-V 0.51 */ + {-1470, 5834, -32210, 149, 22}, /* HR 2689 The Men V 5.45 B-V 0.05 */ + {-16181, 12407, -25650, 149, 15}, /* HR 3784 V 5.45 B-V -0.10 */ + {-15765, 11328, -26397, 149, 28}, /* HR 3840 V 5.45 B-V 0.15 */ + {-6257, 4127, -31898, 149, 64}, /* HR 3902 Nu Cha V 5.45 B-V 0.89 */ + {-15915, 5994, -28008, 149, 45}, /* HR 4169 V 5.45 B-V 0.50 */ + {2897, 22125, -23995, 149, 51}, /* HR 1856 V 5.46 B-V 0.62 */ + {-2706, -662, -32648, 149, 71}, /* HR 4870 Iot Oct V 5.46 B-V 1.02 */ + {-10437, -12308, -28518, 149, 15}, /* HR 5680 V 5.46 B-V -0.10 */ + {2376, 8178, -31641, 149, 96}, /* HR 1629 Eta Men V 5.47 B-V 1.52 */ + {257, 6044, -32204, 149, 16}, /* HR 2125 Kap Men V 5.47 B-V -0.08 */ + {-9475, 11565, -29158, 149, 71}, /* HR 3432 V 5.47 B-V 1.02 */ + {-4060, 4782, -32161, 149, 15}, /* HR 3502 Eta Cha V 5.47 B-V -0.10 */ + {-8124, 6399, -31092, 149, 74}, /* HR 3777 V 5.47 B-V 1.08 */ + {-7606, 5752, -31349, 149, 98}, /* HR 3821 V 5.47 B-V 1.56 */ + {-5139, 1738, -32315, 149, 68}, /* HR 4231 Del1Cha V 5.47 B-V 0.95 */ + {869, -8412, -31657, 149, 21}, /* HR 6829 Phi Oct V 5.47 B-V 0.02 */ + {438, -405, -32762, 149, 34}, /* HR 7228 Sig Oct V 5.47 B-V 0.27 */ + {-12507, 14985, -26319, 150, 12}, /* HR 3440 V 5.48 B-V -0.16 */ + {-16509, -2296, -28211, 150, 52}, /* HR 4768 V 5.48 B-V 0.63 */ + {-18620, -6835, -26082, 150, 14}, /* HR 5026 V 5.48 B-V -0.13 */ + {18523, 9245, -25399, 150, 100}, /* HR 519 V 5.49 B-V 1.60 */ + {-5653, -7469, -31400, 150, 14}, /* HR 5730 Kap1Aps V 5.49 B-V -0.12 */ + {1426, -200, -32735, 150, 84}, /* HR 8862 Tau Oct V 5.49 B-V 1.27 */ + {-4576, 16153, -28139, 150, 15}, /* HR 2674 V 5.50 B-V -0.11 */ + {-21311, 2340, -24780, 150, 72}, /* HR 4462 V 5.50 B-V 1.04 */ + {-16759, -2019, -28084, 150, 92}, /* HR 4739 V 5.50 B-V 1.45 */ + {-6393, -3891, -31901, 150, 98}, /* HR 5261 The Aps V 5.50 B-V 1.55 */ + {-3898, -9937, -30980, 150, 81}, /* HR 6135 V 5.50 B-V 1.22 */ + {11362, 1026, -30717, 150, 18}, /* HR 83 Pi Tuc V 5.51 B-V -0.05 */ + {-11545, 17513, -25173, 150, 101}, /* HR 3247 V 5.51 B-V 1.61 */ + {-14231, 16624, -24389, 150, 11}, /* HR 3462 V 5.51 B-V -0.18 */ + {-13089, -4009, -29771, 150, 19}, /* HR 4952 The Mus V 5.51 B-V -0.02 */ + {6393, -3055, -31992, 150, 36}, /* HR 8471 Psi Oct V 5.51 B-V 0.31 */ + {17474, 8381, -26422, 150, 46}, /* HR 506 V 5.52 B-V 0.53 */ + {4694, 5399, -31976, 150, 42}, /* HR 1025 Iot Hyi V 5.52 B-V 0.44 */ + {-12798, 14943, -26203, 150, 12}, /* HR 3466 V 5.52 B-V -0.15 */ + {-3851, 2207, -32465, 150, 22}, /* HR 3983 Mu 1Cha V 5.52 B-V 0.03 */ + {-12968, 4708, -29721, 150, 12}, /* HR 4185 V 5.52 B-V -0.16 */ + {11498, -2820, -30554, 150, 38}, /* HR 8769 V 5.52 B-V 0.36 */ + {7126, 7268, -31146, 151, 13}, /* HR 939 The Hyi V 5.53 B-V -0.14 */ + {-2263, 5772, -32175, 151, 84}, /* HR 2919 Eps Men V 5.53 B-V 1.28 */ + {-10209, 16813, -26206, 151, 87}, /* HR 3180 V 5.53 B-V 1.34 */ + {-6686, 8931, -30809, 151, 18}, /* HR 3370 V 5.53 B-V -0.03 */ + {9810, 11472, -29083, 151, 52}, /* HR 1006 Zet1Ret V 5.54 B-V 0.64 */ + {3527, 10108, -30969, 151, 14}, /* HR 1541 Mu Men V 5.54 B-V -0.12 */ + {-12435, 11106, -28208, 151, 62}, /* HR 3673 V 5.54 B-V 0.85 */ + {-12511, -13806, -26954, 151, 77}, /* HR 5637 V 5.54 B-V 1.14 */ + {10298, 6832, -30347, 151, 98}, /* HR 667 Pi 1Hyi V 5.55 B-V 1.55 */ + {-19432, 12800, -23070, 151, 11}, /* HR 3886 V 5.55 B-V -0.18 */ + {-23847, 1947, -22387, 151, 50}, /* HR 4502 V 5.55 B-V none */ + {-9895, -2182, -31161, 151, 78}, /* HR 4862 V 5.55 B-V 1.17 */ + {-1106, 11161, -30788, 151, 96}, /* HR 2352 Pi 1Dor V 5.56 B-V 1.51 */ + {-15995, 10819, -26473, 151, 18}, /* HR 3875 V 5.56 B-V -0.04 */ + {-16223, -10664, -26396, 151, 92}, /* HR 5308 V 5.56 B-V 1.44 */ + {19779, 2998, -25951, 151, 44}, /* HR 140 V 5.57 B-V 0.47 */ + {4277, 4569, -32164, 151, 35}, /* HR 981 V 5.57 B-V 0.30 */ + {-12688, 8011, -29129, 151, 86}, /* HR 3914 V 5.57 B-V 1.32 */ + {-10446, 2468, -30959, 151, 18}, /* HR 4329 V 5.57 B-V -0.05 */ + {-17842, 610, -27477, 151, 24}, /* HR 4551 V 5.57 B-V 0.07 */ + {-15155, 154, -29051, 151, 12}, /* HR 4573 V 5.57 B-V -0.15 */ + {-1775, -2615, -32614, 151, 26}, /* HR 5729 Rho Oct V 5.57 B-V 0.11 */ + {-17315, 7455, -26801, 152, 98}, /* HR 4107 V 5.58 B-V 1.56 */ + {-2178, -1026, -32678, 152, 29}, /* HR 5084 Kap Oct V 5.58 B-V 0.18 */ + {-8308, 16112, -27296, 152, 76}, /* HR 3062 V 5.59 B-V 1.13 */ + {-11941, 12849, -27676, 152, 15}, /* HR 3536 V 5.59 B-V -0.11 */ + {-9864, 1554, -31208, 152, 23}, /* HR 4406 V 5.59 B-V 0.06 */ + {10429, 213, -31062, 152, 14}, /* HR 9108 V 5.59 B-V -0.12 */ + {-2758, 20063, -25759, 152, 47}, /* HR 2400 V 5.60 B-V 0.54 */ + {-7982, 14135, -28463, 152, 48}, /* HR 3138 V 5.60 B-V 0.57 */ + {-13827, 7247, -28809, 152, 100}, /* HR 3999 V 5.60 B-V 1.60 */ + {-21478, 10530, -22394, 152, 96}, /* HR 4036 V 5.60 B-V 1.52 */ + {-6896, -6500, -31367, 152, 61}, /* HR 5520 V 5.60 B-V 0.82 */ + {5792, 18629, -26327, 152, 36}, /* HR 1563 Iot Pic V 5.61 B-V 0.33 */ + {-1812, 18056, -27283, 152, 32}, /* HR 2320 Nu Pic V 5.61 B-V 0.24 */ + {-3800, 18147, -27017, 152, 96}, /* HR 2526 V 5.61 B-V 1.52 */ + {-12690, 15085, -26174, 152, 13}, /* HR 3448 V 5.61 B-V -0.14 */ + {-14189, 75, -29535, 152, 29}, /* HR 4578 V 5.61 B-V 0.18 */ + {-9812, -7201, -30423, 152, 44}, /* HR 5379 V 5.61 B-V 0.49 */ + {-19200, 12076, -23647, 152, 78}, /* HR 3910 V 5.62 B-V 1.17 */ + {-8506, 15523, -27575, 153, 85}, /* HR 3105 V 5.63 B-V 1.30 */ + {-14307, 11812, -27009, 153, 30}, /* HR 3732 V 5.63 B-V 0.19 */ + {-14161, -6395, -28849, 153, 45}, /* HR 5113 V 5.63 B-V 0.50 */ + {-909, 5152, -32347, 153, 30}, /* HR 2559 Zet Men V 5.64 B-V 0.20 */ + {539, 5403, -32314, 153, 50}, /* HR 2022 Pi Men V 5.65 B-V 0.60 */ + {-5962, 8514, -31075, 153, 15}, /* HR 3302 Kap2Vol V 5.65 B-V -0.10 */ + {-19998, 9296, -24235, 153, 103}, /* HR 4066 V 5.65 B-V 1.67 */ + {-7945, 791, -31779, 153, 38}, /* HR 4479 Pi Cha V 5.65 B-V 0.35 */ + {-2710, -2754, -32538, 153, 68}, /* HR 5525 Pi 1Oct V 5.65 B-V 0.95 */ + {-2749, -2866, -32525, 153, 85}, /* HR 5545 Pi 2Oct V 5.65 B-V 1.30 */ + {-5343, -7655, -31409, 153, 18}, /* HR 5782 Kap2Aps V 5.65 B-V -0.04 */ + {-9794, 15438, -27192, 153, 30}, /* HR 3218 V 5.66 B-V 0.21 */ + {-73, 20525, -25542, 153, 30}, /* HR 2138 V 5.67 B-V 0.20 */ + {-12678, 5974, -29618, 153, 22}, /* HR 4065 V 5.67 B-V 0.05 */ + {-21418, 5289, -24227, 153, 32}, /* HR 4311 V 5.67 B-V 0.24 */ + {-10116, -3976, -30912, 153, 18}, /* HR 5049 V 5.67 B-V -0.03 */ + {-10150, -12442, -28563, 153, 44}, /* HR 5700 V 5.67 B-V 0.48 */ + {12533, 16720, -25239, 154, 75}, /* HR 1090 V 5.68 B-V 1.10 */ + {6976, -6425, -31364, 154, 50}, /* HR 8061 V 5.68 B-V 0.59 */ + {14684, -1997, -29224, 154, 12}, /* HR 8919 V 5.68 B-V -0.17 */ + {2721, 1233, -32631, 154, 67}, /* HR 525 V 5.69 B-V 0.94 */ + {10303, 6916, -30326, 154, 85}, /* HR 678 Pi 2Hyi V 5.69 B-V 1.30 */ + {2398, 5027, -32290, 154, 62}, /* HR 1426 Del Men V 5.69 B-V 0.84 */ + {-3231, 10452, -30887, 154, 40}, /* HR 2735 Gam1Vol V 5.69 B-V 0.40 */ + {-12086, 15459, -26242, 154, 49}, /* HR 3386 V 5.69 B-V 0.58 */ + {-3047, 4183, -32356, 154, 71}, /* HR 3393 V 5.69 B-V 1.02 */ + {17785, 3278, -27324, 154, 30}, /* HR 183 Xi Phe V 5.70 B-V 0.20 */ + {14534, 3465, -29162, 154, 98}, /* HR 257 V 5.70 B-V 1.56 */ + {4028, 5248, -32092, 154, 66}, /* HR 1109 V 5.70 B-V 0.93 */ + {-2364, 16831, -28014, 154, 17}, /* HR 2412 Mu Pic V 5.70 B-V -0.06 */ + {-8998, 16836, -26632, 154, 12}, /* HR 3088 V 5.70 B-V -0.15 */ + {-11556, 18288, -24611, 154, 14}, /* HR 3203 V 5.70 B-V -0.12 */ + {-15041, 627, -29104, 154, 33}, /* HR 4541 V 5.70 B-V 0.26 */ + {-4730, -8705, -31233, 154, 78}, /* HR 5955 V 5.70 B-V 1.17 */ + {14439, 6872, -28600, 154, 84}, /* HR 505 V 5.71 B-V 1.27 */ + {13010, 21312, -21218, 154, 50}, /* HR 1219 V 5.71 B-V 0.60 */ + {-357, 13302, -29943, 154, 18}, /* HR 2194 Eta1Dor V 5.71 B-V -0.03 */ + {-13019, 13576, -26830, 154, 44}, /* HR 3570 V 5.71 B-V 0.48 */ + {-19673, 12021, -23284, 154, 15}, /* HR 3925 V 5.71 B-V -0.11 */ + {-22061, 2395, -24109, 154, 103}, /* HR 4463 V 5.71 B-V 1.66 */ + {-18666, -5674, -26326, 154, 16}, /* HR 4951 V 5.71 B-V -0.07 */ + {-10928, -5984, -30306, 154, 94}, /* HR 5218 V 5.71 B-V 1.49 */ + {-17614, -9684, -25877, 154, 16}, /* HR 5230 V 5.71 B-V -0.08 */ + {-8697, -11086, -29583, 154, 102}, /* HR 5725 V 5.71 B-V 1.64 */ + {-8836, 19677, -24666, 154, 17}, /* HR 2940 V 5.72 B-V -0.06 */ + {-17908, 10882, -25190, 154, 20}, /* HR 3927 V 5.72 B-V -0.01 */ + {-15437, 7885, -27806, 154, 16}, /* HR 4009 V 5.72 B-V -0.08 */ + {-15815, -3600, -28471, 154, 39}, /* HR 4876 V 5.72 B-V 0.38 */ + {14122, -975, -29551, 154, 90}, /* HR 8996 V 5.72 B-V 1.40 */ + {12310, 18469, -24104, 155, 68}, /* HR 1169 V 5.73 B-V 0.96 */ + {-18907, 11964, -23939, 155, 74}, /* HR 3904 V 5.73 B-V 1.08 */ + {-19329, -4370, -26096, 155, 26}, /* HR 4872 V 5.73 B-V 0.13 */ + {-10422, -12053, -28632, 155, 16}, /* HR 5661 V 5.73 B-V -0.08 */ + {4464, -48, -32462, 155, 73}, /* HR 9061 Gam2Oct V 5.73 B-V 1.05 */ + {10894, 9593, -29376, 155, 66}, /* HR 833 Gam Hor V 5.74 B-V 0.93 */ + {11806, 13176, -27580, 155, 127}, /* HR 977 V 5.74 B-V 2.28 */ + {-7835, 14090, -28526, 155, 98}, /* HR 3120 V 5.74 B-V 1.55 */ + {-21456, 8673, -23197, 155, 12}, /* HR 4135 V 5.74 B-V -0.15 */ + {-16232, 3338, -28268, 155, 15}, /* HR 4361 V 5.74 B-V -0.10 */ + {-12055, -1171, -30447, 155, 72}, /* HR 4704 Zet1Mus V 5.74 B-V 1.04 */ + {5922, 13912, -29070, 155, 70}, /* HR 1435 V 5.75 B-V 1.01 */ + {-17574, 14435, -23589, 155, 66}, /* HR 3730 V 5.75 B-V 0.92 */ + {-10184, -5403, -30672, 155, 106}, /* HR 5194 V 5.75 B-V 1.73 */ + {-10773, -7311, -30069, 155, 17}, /* HR 5320 V 5.75 B-V -0.06 */ + {-6968, -11944, -29706, 155, 17}, /* HR 5920 V 5.75 B-V -0.06 */ + {-5342, -11086, -30369, 155, 28}, /* HR 6037 V 5.75 B-V 0.15 */ + {6355, -425, -32142, 155, 76}, /* HR 8995 V 5.75 B-V 1.11 */ + {16529, 7691, -27227, 155, 64}, /* HR 487 V 5.76 B-V 0.87 */ + {-2448, 21712, -24418, 155, 17}, /* HR 2348 V 5.76 B-V -0.06 */ + {-19214, 3939, -26248, 155, 86}, /* HR 4360 V 5.76 B-V 1.32 */ + {-15783, -3743, -28471, 155, 36}, /* HR 4887 V 5.76 B-V 0.33 */ + {-8640, -9388, -30181, 155, 54}, /* HR 5621 V 5.76 B-V 0.69 */ + {2854, 166, -32642, 155, 106}, /* HR 47 V 5.77 B-V 1.72 */ + {-12035, 9621, -28918, 155, 28}, /* HR 3752 V 5.77 B-V 0.15 */ + {-13457, 4643, -29513, 155, 20}, /* HR 4204 V 5.77 B-V 0.00 */ + {3191, -4037, -32360, 155, 77}, /* HR 7785 V 5.77 B-V 1.14 */ + {2135, -867, -32686, 155, 71}, /* HR 8505 Ups Oct V 5.77 B-V 1.02 */ + {14682, 19119, -22194, 156, 31}, /* HR 1075 V 5.78 B-V 0.22 */ + {1009, 9118, -31457, 156, 105}, /* HR 1964 V 5.78 B-V 1.71 */ + {-7451, 14434, -28457, 156, 41}, /* HR 3070 V 5.78 B-V 0.42 */ + {-11147, 11766, -28478, 156, 16}, /* HR 3560 V 5.78 B-V -0.08 */ + {-18131, 9093, -25735, 156, 27}, /* HR 4020 V 5.78 B-V 0.14 */ + {10049, -4412, -30875, 156, 39}, /* HR 8527 V 5.78 B-V 0.38 */ + {2010, 4357, -32414, 156, 38}, /* HR 1456 Nu Men V 5.79 B-V 0.35 */ + {5512, 13914, -29150, 156, 72}, /* HR 1475 V 5.79 B-V 1.04 */ + {-6090, 11739, -29980, 156, 18}, /* HR 3081 V 5.79 B-V -0.04 */ + {-3954, 4472, -32219, 156, 100}, /* HR 3543 V 5.79 B-V 1.60 */ + {-11283, 11208, -28649, 156, 80}, /* HR 3604 V 5.79 B-V 1.21 */ + {-16707, 15102, -23801, 156, 10}, /* HR 3658 V 5.79 B-V -0.21 */ + {-14104, 8881, -28212, 156, 88}, /* HR 3913 V 5.79 B-V 1.36 */ + {-17720, 2875, -27412, 156, 20}, /* HR 4398 V 5.79 B-V 0.01 */ + {-12744, -5955, -29594, 156, 40}, /* HR 5130 V 5.79 B-V 0.39 */ + {-1714, 16154, -28457, 156, 20}, /* HR 2345 V 5.80 B-V 0.00 */ + {-3976, 19589, -25964, 156, 96}, /* HR 2515 V 5.80 B-V 1.53 */ + {-12976, 16043, -25454, 156, 14}, /* HR 3413 V 5.80 B-V -0.13 */ + {-14562, 10098, -27561, 156, 75}, /* HR 3864 V 5.80 B-V 1.09 */ + {-22937, 4745, -22915, 156, 103}, /* HR 4354 V 5.80 B-V 1.66 */ + {-17920, -2351, -27332, 156, 98}, /* HR 4754 V 5.80 B-V 1.56 */ + {15035, 10519, -27147, 156, 98}, /* HR 688 V 5.81 B-V 1.55 */ + {-7917, 13874, -28610, 156, 16}, /* HR 3147 V 5.81 B-V -0.09 */ + {-10554, 5523, -30525, 156, 21}, /* HR 4002 V 5.81 B-V 0.02 */ + {-16512, 7822, -27200, 156, 44}, /* HR 4061 V 5.81 B-V 0.48 */ + {-22841, 6122, -22682, 156, 16}, /* HR 4292 V 5.81 B-V -0.08 */ + {-19441, 2837, -26224, 156, 46}, /* HR 4417 V 5.81 B-V 0.52 */ + {-7386, -8372, -30806, 156, 127}, /* HR 5644 V 5.81 B-V 3.38 */ + {7108, -831, -31976, 156, 54}, /* HR 8935 V 5.81 B-V 0.68 */ + {15606, 16010, -23955, 156, 85}, /* HR 929 V 5.82 B-V 1.30 */ + {-2046, 17242, -27789, 156, 84}, /* HR 2369 V 5.82 B-V 1.28 */ + {-11769, 18265, -24527, 156, 12}, /* HR 3227 V 5.82 B-V -0.15 */ + {7918, 10400, -30047, 157, 17}, /* HR 1092 V 5.83 B-V -0.06 */ + {-15775, 1632, -28673, 157, 16}, /* HR 4472 V 5.83 B-V -0.09 */ + {-18810, -7058, -25885, 157, 26}, /* HR 5036 V 5.83 B-V 0.12 */ + {-9815, -7618, -30320, 157, 70}, /* HR 5408 V 5.83 B-V 1.00 */ + {14349, 16718, -24255, 157, 82}, /* HR 998 V 5.85 B-V 1.24 */ + {1132, 4142, -32484, 157, 66}, /* HR 1716 Xi Men V 5.85 B-V 0.93 */ + {-11748, 16331, -25864, 157, 20}, /* HR 3300 V 5.85 B-V 0.01 */ + {-6221, -2090, -32103, 157, 74}, /* HR 4976 V 5.85 B-V 1.07 */ + {-10749, -8035, -29893, 157, 95}, /* HR 5391 V 5.85 B-V 1.50 */ + {505, -9197, -31446, 157, 43}, /* HR 6751 V 5.85 B-V 0.46 */ + {2817, 22618, -23541, 157, 88}, /* HR 1870 V 5.86 B-V 1.35 */ + {-6547, 5619, -31611, 157, 19}, /* HR 3721 V 5.86 B-V -0.02 */ + {392, -7976, -31779, 157, 82}, /* HR 6731 V 5.86 B-V 1.24 */ + {16528, 7690, -27228, 157, 65}, /* HR 486 V 5.87 B-V 0.90 */ + {3647, 1661, -32521, 157, 50}, /* HR 512 V 5.87 B-V 0.61 */ + {6367, 13300, -29262, 157, 16}, /* HR 1372 The Ret V 5.87 B-V -0.07 */ + {-7607, 18366, -26048, 157, 70}, /* HR 2884 V 5.87 B-V 1.01 */ + {-9655, 16584, -26560, 157, 13}, /* HR 3156 V 5.87 B-V -0.14 */ + {-15191, 15468, -24569, 157, 74}, /* HR 3583 V 5.87 B-V 1.07 */ + {-15531, 13182, -25665, 157, 47}, /* HR 3708 V 5.87 B-V 0.54 */ + {-14733, -11670, -26841, 157, 44}, /* HR 5426 V 5.87 B-V 0.48 */ + {-15574, -12332, -26058, 157, 75}, /* HR 5427 V 5.87 B-V 1.09 */ + {-10552, -9890, -29403, 157, 56}, /* HR 5527 V 5.87 B-V 0.72 */ + {-8464, 8380, -30525, 158, 101}, /* HR 3610 V 5.88 B-V 1.63 */ + {-13654, 10440, -27897, 158, 105}, /* HR 3793 V 5.88 B-V 1.70 */ + {-9485, -1340, -31336, 158, 76}, /* HR 4769 V 5.88 B-V 1.11 */ + {-647, -5165, -32351, 158, 103}, /* HR 6429 V 5.88 B-V 1.67 */ + {16395, 2927, -28219, 158, 48}, /* HR 176 V 5.89 B-V 0.55 */ + {-11639, -133, -30630, 158, 16}, /* HR 4597 V 5.89 B-V -0.08 */ + {-19699, -6533, -25356, 158, 19}, /* HR 4985 V 5.89 B-V -0.02 */ + {-16146, -5418, -27993, 158, 74}, /* HR 4988 V 5.89 B-V 1.08 */ + {-17191, -9307, -26297, 158, 20}, /* HR 5217 V 5.89 B-V 0.01 */ + {-7529, -9486, -30447, 158, 71}, /* HR 5713 V 5.89 B-V 1.02 */ + {1296, -8957, -31492, 158, 69}, /* HR 6899 V 5.89 B-V 0.98 */ + {-13918, 16427, -24700, 158, 10}, /* HR 3453 V 5.90 B-V -0.21 */ + {-12730, 1544, -30154, 158, 76}, /* HR 4448 V 5.90 B-V 1.13 */ + {-15752, -3769, -28484, 158, 30}, /* HR 4890 Kap Cru V 5.90 B-V 0.20 */ + {-12548, -4127, -29987, 158, 23}, /* HR 4977 V 5.90 B-V 0.06 */ + {-9654, 18467, -25287, 158, 75}, /* HR 3071 V 5.91 B-V 1.09 */ + {-14893, 15882, -24488, 158, 12}, /* HR 3539 V 5.91 B-V -0.15 */ + {-10230, 7956, -30095, 158, 20}, /* HR 3783 V 5.91 B-V 0.01 */ + {-21646, 8684, -23015, 158, 66}, /* HR 4139 V 5.91 B-V 0.92 */ + {-16602, 6204, -27560, 158, 13}, /* HR 4173 V 5.91 B-V -0.14 */ + {-15930, 5069, -28182, 158, 20}, /* HR 4239 V 5.91 B-V 0.00 */ + {-19950, 5614, -25380, 158, 29}, /* HR 4274 V 5.91 B-V 0.18 */ + {-14730, 322, -29268, 158, 30}, /* HR 4563 V 5.91 B-V 0.19 */ + {-10690, -3466, -30780, 158, 41}, /* HR 4966 V 5.91 B-V 0.42 */ + {-9645, -8741, -30071, 158, 16}, /* HR 5500 V 5.91 B-V -0.07 */ + {-2000, -2205, -32631, 158, 17}, /* HR 5557 Ome Oct V 5.91 B-V -0.06 */ + {3162, -3825, -32389, 158, 105}, /* HR 7812 V 5.91 B-V 1.71 */ + {16707, 12017, -25498, 158, 31}, /* HR 701 V 5.92 B-V 0.22 */ + {-16603, 14744, -24096, 158, 18}, /* HR 3670 V 5.92 B-V -0.05 */ + {-12045, 9345, -29004, 158, 75}, /* HR 3776 V 5.92 B-V 1.10 */ + {-15917, 5873, -28033, 158, 102}, /* HR 4179 V 5.92 B-V 1.65 */ + {-15488, 4494, -28524, 158, 74}, /* HR 4271 V 5.92 B-V 1.08 */ + {-14879, -804, -29183, 158, 34}, /* HR 4644 V 5.92 B-V 0.29 */ + {-18062, -1736, -27284, 158, 99}, /* HR 4702 V 5.92 B-V 1.57 */ + {-15642, -9346, -27233, 158, 81}, /* HR 5266 V 5.92 B-V 1.22 */ + {13208, 5142, -29543, 159, 98}, /* HR 420 V 5.93 B-V 1.56 */ + {15627, 17422, -22934, 159, 42}, /* HR 968 V 5.93 B-V 0.44 */ + {11736, 19069, -23923, 159, 82}, /* HR 1216 V 5.93 B-V 1.24 */ + {-17519, 10753, -25518, 159, 12}, /* HR 3924 V 5.93 B-V -0.15 */ + {-14843, 4362, -28885, 159, 108}, /* HR 4266 V 5.93 B-V 1.75 */ + {-18315, -4317, -26826, 159, 86}, /* HR 4885 V 5.93 B-V 1.31 */ + {-9721, -2447, -31196, 159, 76}, /* HR 4907 V 5.93 B-V 1.13 */ + {-5144, -5153, -31948, 159, 73}, /* HR 5547 V 5.93 B-V 1.05 */ + {18564, 9757, -25177, 159, 27}, /* HR 541 V 5.94 B-V 0.14 */ + {6344, 14434, -28724, 159, 97}, /* HR 1416 V 5.94 B-V 1.54 */ + {594, 17761, -27529, 159, 53}, /* HR 2072 V 5.94 B-V 0.66 */ + {-14078, 7965, -28497, 159, 33}, /* HR 3960 V 5.94 B-V 0.26 */ + {-10769, 17798, -25317, 159, 80}, /* HR 3178 V 5.95 B-V 1.21 */ + {-15636, 6881, -27961, 159, 36}, /* HR 4095 V 5.95 B-V 0.32 */ + {-14476, -2030, -29326, 159, 34}, /* HR 4771 V 5.95 B-V 0.27 */ + {-3661, -2022, -32499, 159, 93}, /* HR 5188 V 5.95 B-V 1.46 */ + {-4467, -6493, -31805, 159, 18}, /* HR 5786 V 5.95 B-V -0.04 */ + {709, -5513, -32292, 159, 78}, /* HR 6837 V 5.95 B-V 1.16 */ + {6860, -3839, -31810, 159, 40}, /* HR 8380 V 5.95 B-V 0.39 */ + {7214, 9037, -30659, 159, 41}, /* HR 1064 V 5.96 B-V 0.42 */ + {-5837, 19326, -25809, 159, 70}, /* HR 2698 V 5.96 B-V 1.00 */ + {-7339, 17606, -26643, 159, 98}, /* HR 2892 V 5.96 B-V 1.56 */ + {-22114, 10492, -21784, 159, 17}, /* HR 4056 V 5.96 B-V -0.06 */ + {-12417, 1207, -30299, 159, 71}, /* HR 4485 V 5.96 B-V 1.02 */ + {-19206, 1620, -26499, 159, 103}, /* HR 4497 V 5.96 B-V 1.66 */ + {-15897, -343, -28650, 159, 103}, /* HR 4607 V 5.96 B-V 1.67 */ + {7102, 667, -31981, 159, 90}, /* HR 87 V 5.97 B-V 1.40 */ + {-6441, 18879, -25995, 159, 75}, /* HR 2767 V 5.97 B-V 1.10 */ + {-10041, 14182, -27780, 159, 16}, /* HR 3293 V 5.97 B-V -0.09 */ + {-8353, 11303, -29600, 159, 68}, /* HR 3346 V 5.97 B-V 0.96 */ + {-5477, 1944, -32247, 159, 16}, /* HR 4206 V 5.97 B-V -0.07 */ + {-11395, -6636, -29996, 159, 38}, /* HR 5253 V 5.97 B-V 0.35 */ + {14897, -173, -29184, 159, 26}, /* HR 9060 V 5.97 B-V 0.11 */ + {15972, 3012, -28452, 160, 86}, /* HR 186 V 5.98 B-V 1.32 */ + {-2068, 19985, -25884, 160, 72}, /* HR 2322 V 5.98 B-V 1.04 */ + {-21727, 11234, -21804, 160, 82}, /* HR 4001 V 5.98 B-V 1.24 */ + {13461, 17641, -24110, 160, 26}, /* HR 1081 V 5.99 B-V 0.11 */ + {-12096, 9787, -28837, 160, 73}, /* HR 3742 V 5.99 B-V 1.06 */ + {-10369, 3086, -30929, 160, 19}, /* HR 4262 V 5.99 B-V -0.02 */ + {-13842, 2487, -29595, 160, 43}, /* HR 4384 V 5.99 B-V 0.46 */ + {-15746, -4769, -28337, 160, 44}, /* HR 4944 V 5.99 B-V 0.48 */ + {-15397, 10602, -26911, 160, 14}, /* HR 3868 V 6.00 B-V -0.13 */ + {-15820, 6328, -27988, 160, 36}, /* HR 4144 V 6.00 B-V 0.32 */ + {-15622, 5069, -28354, 160, 34}, /* HR 4228 V 6.00 B-V 0.27 */ + {-14369, -1727, -29398, 160, 24}, /* HR 4736 V 6.00 B-V 0.07 */ + {-17917, -3414, -27221, 160, 16}, /* HR 4834 V 6.00 B-V -0.08 */ + {-16176, -7797, -27408, 160, 16}, /* HR 5151 V 6.00 B-V -0.08 */ + {-16536, -9218, -26744, 160, 59}, /* HR 5236 V 6.00 B-V 0.78 */ + {-17222, -10927, -25645, 160, 17}, /* HR 5296 V 6.00 B-V -0.06 */ + {-15898, -11530, -26230, 160, 75}, /* HR 5380 V 6.00 B-V 1.10 */ + {5085, -5950, -31819, 160, 42}, /* HR 7863 Mu 1Oct V 6.00 B-V 0.44 */ + {7410, -700, -31910, 160, 65}, /* HR 8957 V 6.00 B-V 0.90 */ + {15823, 6985, -27830, 160, 39}, /* HR 460 V 6.01 B-V 0.38 */ + {-12397, 5299, -29865, 160, 24}, /* HR 4115 V 6.01 B-V 0.09 */ + {-15940, -7333, -27673, 160, 77}, /* HR 5124 V 6.01 B-V 1.14 */ + {-6477, -7229, -31297, 160, 20}, /* HR 5628 V 6.01 B-V 0.00 */ + {-4453, 16309, -28069, 160, 35}, /* HR 2661 V 6.02 B-V 0.30 */ + {-4569, 14055, -29245, 160, 19}, /* HR 2754 V 6.02 B-V -0.02 */ + {-10773, 18612, -24722, 160, 22}, /* HR 3148 V 6.02 B-V 0.04 */ + {-12927, 11308, -27905, 160, 15}, /* HR 3691 V 6.02 B-V -0.10 */ + {-16573, 3942, -27991, 160, 82}, /* HR 4323 V 6.02 B-V 1.24 */ + {-17285, -6360, -27101, 160, 34}, /* HR 5027 V 6.02 B-V 0.29 */ + {-7254, -4552, -31628, 160, 49}, /* HR 5279 V 6.02 B-V 0.58 */ + {10899, 10192, -29172, 161, 82}, /* HR 866 V 6.03 B-V 1.25 */ + {1714, 11820, -30513, 161, 37}, /* HR 1859 V 6.03 B-V 0.34 */ + {-12347, 13118, -27371, 161, 19}, /* HR 3549 V 6.03 B-V -0.02 */ + {-10018, -2829, -31069, 161, 22}, /* HR 4930 V 6.03 B-V 0.05 */ + {-14080, -1748, -29536, 161, 21}, /* HR 4744 V 6.04 B-V 0.02 */ + {-9507, -3428, -31170, 161, 88}, /* HR 5012 V 6.04 B-V 1.35 */ + {-9507, -7819, -30367, 161, 45}, /* HR 5443 V 6.04 B-V 0.50 */ + {-529, -2009, -32701, 161, 22}, /* HR 6139 V 6.04 B-V 0.05 */ + {7767, -3383, -31653, 161, 52}, /* HR 8526 V 6.04 B-V 0.64 */ + {8340, 9764, -30146, 161, 26}, /* HR 1014 V 6.05 B-V 0.13 */ + {8985, 15363, -27513, 161, 42}, /* HR 1245 V 6.05 B-V 0.44 */ + {2443, 6565, -32010, 161, 75}, /* HR 1531 V 6.05 B-V 1.10 */ + {4029, 19753, -25832, 161, 90}, /* HR 1727 V 6.05 B-V 1.39 */ + {675, 6317, -32145, 161, 19}, /* HR 1991 Iot Men V 6.05 B-V -0.02 */ + {-6881, 18814, -25930, 161, 41}, /* HR 2813 V 6.05 B-V 0.42 */ + {-11811, 15901, -26102, 161, 23}, /* HR 3341 V 6.05 B-V 0.06 */ + {-8826, 10108, -29893, 161, 30}, /* HR 3495 V 6.05 B-V 0.20 */ + {-4060, 4703, -32173, 161, 32}, /* HR 3524 V 6.05 B-V 0.23 */ + {-10894, 8609, -29680, 161, 28}, /* HR 3761 V 6.05 B-V 0.15 */ + {-18725, 11062, -24509, 161, 13}, /* HR 3943 V 6.05 B-V -0.14 */ + {-20310, 73, -25714, 161, 84}, /* HR 4582 V 6.05 B-V 1.28 */ + {-2496, -25, -32672, 161, 84}, /* HR 4595 V 6.05 B-V 1.29 */ + {-9396, -3554, -31189, 161, 24}, /* HR 5030 V 6.05 B-V 0.09 */ + {-9300, -5954, -30850, 161, 107}, /* HR 5293 V 6.05 B-V 1.74 */ + {10717, -3141, -30805, 161, 53}, /* HR 8701 Rho Ind V 6.05 B-V 0.66 */ + {18651, 2917, -26783, 161, 70}, /* HR 148 V 6.06 B-V 1.01 */ + {4983, 2533, -32287, 161, 37}, /* HR 550 Tau2Hyi V 6.06 B-V 0.34 */ + {13962, 7721, -28620, 161, 38}, /* HR 571 V 6.06 B-V 0.37 */ + {-8204, 17795, -26263, 161, 15}, /* HR 2971 V 6.06 B-V -0.11 */ + {-15231, 9829, -27296, 161, 67}, /* HR 3895 V 6.06 B-V 0.94 */ + {-12154, 2290, -30343, 161, 108}, /* HR 4379 V 6.06 B-V 1.76 */ + {-17643, 447, -27608, 161, 22}, /* HR 4556 V 6.06 B-V 0.05 */ + {-13474, -375, -29866, 161, 52}, /* HR 4615 V 6.06 B-V 0.65 */ + {-13450, -1005, -29862, 161, 22}, /* HR 4669 V 6.06 B-V 0.03 */ + {-18969, -6070, -26019, 161, 16}, /* HR 4965 V 6.06 B-V -0.09 */ + {-9551, -6145, -30736, 161, 29}, /* HR 5295 V 6.06 B-V 0.18 */ + {14846, 2923, -29064, 161, 42}, /* HR 199 V 6.07 B-V 0.44 */ + {7372, 23479, -21635, 161, 38}, /* HR 1557 V 6.07 B-V 0.37 */ + {-8222, 3022, -31574, 161, 105}, /* HR 4186 V 6.07 B-V 1.71 */ + {-13011, -4527, -29730, 161, 42}, /* HR 5000 V 6.07 B-V 0.44 */ + {-5975, -4569, -31892, 161, 79}, /* HR 5389 V 6.07 B-V 1.18 */ + {-14969, -13385, -25893, 161, 24}, /* HR 5498 V 6.07 B-V 0.09 */ + {-79, -7828, -31818, 161, 80}, /* HR 6635 V 6.07 B-V 1.20 */ + {10918, -742, -30886, 161, 66}, /* HR 8994 V 6.07 B-V 0.91 */ + {3579, 23206, -22855, 162, 80}, /* HR 1813 V 6.08 B-V 1.20 */ + {-15769, 12770, -25728, 162, 48}, /* HR 3739 V 6.08 B-V 0.57 */ + {-22098, 8574, -22623, 162, 67}, /* HR 4154 V 6.08 B-V 0.94 */ + {-15728, -761, -28735, 162, 40}, /* HR 4634 V 6.08 B-V 0.39 */ + {-18029, -3409, -27148, 162, 18}, /* HR 4832 V 6.08 B-V -0.03 */ + {8465, 17881, -26120, 162, 44}, /* HR 1365 V 6.09 B-V 0.49 */ + {-21454, 8674, -23198, 162, 15}, /* HR 4136 V 6.09 B-V -0.11 */ + {-9773, 1360, -31246, 162, 28}, /* HR 4425 V 6.09 B-V 0.16 */ + {-5606, -3254, -32119, 162, 22}, /* HR 5240 V 6.09 B-V 0.03 */ + {-9642, -9207, -29932, 162, 17}, /* HR 5539 Zet Cir V 6.09 B-V -0.06 */ + {17693, 9910, -25738, 162, 44}, /* HR 573 V 6.10 B-V 0.48 */ + {11521, 6631, -29950, 162, 78}, /* HR 600 V 6.10 B-V 1.17 */ + {8820, 20556, -23945, 162, 43}, /* HR 1418 V 6.10 B-V 0.46 */ + {492, 21220, -24963, 162, 14}, /* HR 2089 V 6.10 B-V -0.13 */ + {-9610, 16415, -26681, 162, 18}, /* HR 3157 V 6.10 B-V -0.04 */ + {-11976, 9005, -29141, 162, 92}, /* HR 3816 V 6.10 B-V 1.43 */ + {-14667, 7391, -28354, 162, 16}, /* HR 4018 V 6.10 B-V -0.08 */ + {-19628, 8328, -24881, 162, 96}, /* HR 4111 V 6.10 B-V 1.51 */ + {-14901, 1050, -29164, 162, 23}, /* HR 4513 V 6.10 B-V 0.06 */ + {-9965, -4581, -30877, 162, 91}, /* HR 5119 V 6.10 B-V 1.42 */ + {-13908, -12216, -27037, 162, 17}, /* HR 5488 V 6.10 B-V -0.06 */ + {17195, 4771, -27481, 162, 67}, /* HR 295 Ome Phe V 6.11 B-V 0.94 */ + {5992, 2594, -32110, 162, 68}, /* HR 467 V 6.11 B-V 0.97 */ + {2985, 18014, -27208, 162, 15}, /* HR 1801 Kap Pic V 6.11 B-V -0.10 */ + {2318, 22094, -24086, 162, 78}, /* HR 1927 V 6.11 B-V 1.16 */ + {-2138, 10763, -30875, 162, 86}, /* HR 2536 V 6.11 B-V 1.33 */ + {-3521, 15875, -28448, 162, 43}, /* HR 2562 V 6.11 B-V 0.46 */ + {-6633, 7249, -31259, 162, 30}, /* HR 3544 V 6.11 B-V 0.20 */ + {-13390, 12644, -27102, 162, 12}, /* HR 3629 V 6.11 B-V -0.15 */ + {-9710, 8303, -30174, 162, 83}, /* HR 3713 V 6.11 B-V 1.26 */ + {-22567, 8344, -22244, 162, 53}, /* HR 4175 V 6.11 B-V 0.66 */ + {-23286, 6786, -22032, 162, 16}, /* HR 4263 V 6.11 B-V -0.08 */ + {-15912, 4427, -28300, 162, 75}, /* HR 4276 V 6.11 B-V 1.10 */ + {-20733, 4317, -25004, 162, 73}, /* HR 4353 V 6.11 B-V 1.06 */ + {-12969, -5314, -29618, 162, 26}, /* HR 5069 V 6.11 B-V 0.11 */ + {-15833, -10447, -26718, 162, 22}, /* HR 5311 V 6.11 B-V 0.05 */ + {-12884, -11291, -27932, 162, 71}, /* HR 5486 V 6.11 B-V 1.02 */ + {17433, 11163, -25400, 162, 61}, /* HR 637 V 6.12 B-V 0.82 */ + {14569, 15963, -24630, 162, 76}, /* HR 960 V 6.12 B-V 1.12 */ + {4792, 16413, -27952, 162, 42}, /* HR 1597 V 6.12 B-V 0.44 */ + {-7994, 16104, -27394, 162, 40}, /* HR 3031 V 6.12 B-V 0.39 */ + {-10815, 18642, -24681, 162, 15}, /* HR 3151 V 6.12 B-V -0.11 */ + {-8265, 11681, -29477, 162, 66}, /* HR 3298 V 6.12 B-V 0.93 */ + {-5801, 7378, -31394, 162, 68}, /* HR 3417 V 6.12 B-V 0.95 */ + {-17097, 10153, -26044, 162, 14}, /* HR 3941 V 6.12 B-V -0.13 */ + {-19646, 10964, -23822, 162, 21}, /* HR 3964 V 6.12 B-V 0.02 */ + {-22999, 3809, -23026, 162, 66}, /* HR 4393 V 6.12 B-V 0.92 */ + {-23802, 3731, -22208, 162, 11}, /* HR 4403 V 6.12 B-V -0.18 */ + {5831, -1335, -32216, 162, 27}, /* HR 8786 V 6.12 B-V 0.14 */ + {10412, 1528, -31031, 163, 32}, /* HR 139 The Tuc V 6.13 B-V 0.23 */ + {-22076, 9581, -22238, 163, 76}, /* HR 4099 V 6.13 B-V 1.13 */ + {-8112, 2278, -31665, 163, 96}, /* HR 4279 V 6.13 B-V 1.53 */ + {-20718, 5063, -24876, 163, 19}, /* HR 4316 V 6.13 B-V -0.02 */ + {12348, -2270, -30266, 163, 88}, /* HR 8855 V 6.13 B-V 1.35 */ + {7536, 12551, -29315, 163, 75}, /* HR 1236 V 6.14 B-V 1.10 */ + {-7206, 12841, -29272, 163, 15}, /* HR 3139 V 6.14 B-V -0.10 */ + {-5622, 5052, -31883, 163, 75}, /* HR 3695 V 6.14 B-V 1.09 */ + {-13492, 7512, -28900, 163, 18}, /* HR 3971 V 6.14 B-V -0.04 */ + {-16054, 6371, -27846, 163, 38}, /* HR 4147 V 6.14 B-V 0.35 */ + {-16778, -9332, -26553, 163, 24}, /* HR 5234 V 6.14 B-V 0.07 */ + {19019, 3784, -26413, 163, 46}, /* HR 202 V 6.15 B-V 0.53 */ + {15020, 13077, -26020, 163, 24}, /* HR 821 V 6.15 B-V 0.09 */ + {7918, 8478, -30645, 163, 71}, /* HR 959 V 6.15 B-V 1.02 */ + {7178, 8867, -30717, 163, 44}, /* HR 1053 V 6.15 B-V 0.48 */ + {-2094, 15301, -28899, 163, 12}, /* HR 2410 V 6.15 B-V -0.15 */ + {-16984, 11514, -25547, 163, 15}, /* HR 3872 V 6.15 B-V -0.10 */ + {-19568, 5230, -25756, 163, 29}, /* HR 4296 V 6.15 B-V 0.18 */ + {-17988, -2252, -27295, 163, 66}, /* HR 4749 V 6.15 B-V 0.92 */ + {7004, -3572, -31810, 163, 70}, /* HR 8432 V 6.15 B-V 1.00 */ + {5951, -2301, -32140, 163, 89}, /* HR 8577 V 6.15 B-V 1.38 */ + {9027, -2059, -31432, 163, 91}, /* HR 8794 V 6.15 B-V 1.42 */ + {5790, 3205, -32092, 163, 42}, /* HR 593 Sig Hyi V 6.16 B-V 0.44 */ + {8690, 20808, -23774, 163, 73}, /* HR 1433 V 6.16 B-V 1.06 */ + {-17924, 9095, -25878, 163, 78}, /* HR 4010 V 6.16 B-V 1.17 */ + {-16877, 8298, -26833, 163, 12}, /* HR 4038 V 6.16 B-V -0.17 */ + {-15176, 4121, -28747, 163, 17}, /* HR 4290 V 6.16 B-V -0.06 */ + {-17604, -114, -27637, 163, 20}, /* HR 4592 V 6.16 B-V 0.00 */ + {-11605, -2310, -30556, 163, 54}, /* HR 4841 V 6.16 B-V 0.69 */ + {-15647, -5155, -28325, 163, 50}, /* HR 4980 V 6.16 B-V 0.60 */ + {-17501, 12666, -24636, 163, 34}, /* HR 3831 V 6.17 B-V 0.27 */ + {-11108, -620, -30821, 163, 62}, /* HR 4645 V 6.17 B-V 0.84 */ + {-16166, -9885, -26732, 163, 32}, /* HR 5278 V 6.17 B-V 0.23 */ + {-9349, -10021, -29763, 163, 94}, /* HR 5611 V 6.17 B-V 1.47 */ + {2256, -3079, -32544, 163, 30}, /* HR 7698 V 6.17 B-V 0.20 */ + {15720, 7060, -27870, 164, 101}, /* HR 468 V 6.18 B-V 1.61 */ + {1064, 19063, -26630, 164, 90}, /* HR 2023 V 6.18 B-V 1.40 */ + {-2578, 15404, -28805, 164, 51}, /* HR 2468 V 6.18 B-V 0.62 */ + {-2856, 6410, -32007, 164, 106}, /* HR 3000 V 6.18 B-V 1.73 */ + {-4964, 10154, -30756, 164, 17}, /* HR 3038 V 6.18 B-V -0.06 */ + {-22136, 9707, -22124, 164, 70}, /* HR 4093 V 6.18 B-V 1.00 */ + {-15486, -5681, -28312, 164, 42}, /* HR 5024 V 6.18 B-V 0.43 */ + {-14878, -5607, -28651, 164, 20}, /* HR 5034 V 6.18 B-V 0.01 */ + {-3951, -5606, -32041, 164, 80}, /* HR 5757 V 6.18 B-V 1.20 */ + {-7422, -11418, -29803, 164, 31}, /* HR 5851 V 6.18 B-V 0.22 */ + {4902, -3466, -32212, 164, 43}, /* HR 8234 V 6.18 B-V 0.46 */ + {1863, 14280, -29433, 164, 31}, /* HR 1882 V 6.19 B-V 0.22 */ + {-2911, 19812, -25936, 164, 75}, /* HR 2416 V 6.19 B-V 1.09 */ + {-16013, 11553, -26149, 164, 73}, /* HR 3837 V 6.19 B-V 1.05 */ + {-14217, 7962, -28428, 164, 29}, /* HR 3966 V 6.19 B-V 0.17 */ + {-8277, 3653, -31493, 164, 24}, /* HR 4105 V 6.19 B-V 0.07 */ + {-11839, 4895, -30159, 164, 20}, /* HR 4129 V 6.19 B-V 0.01 */ + {-2979, 809, -32621, 164, 26}, /* HR 4312 Eta Oct V 6.19 B-V 0.11 */ + {-19301, -6889, -25567, 164, 20}, /* HR 5016 V 6.19 B-V 0.01 */ + {386, 2953, -32631, 164, 19}, /* HR 2059 V 6.20 B-V -0.02 */ + {-10045, 5976, -30611, 164, 15}, /* HR 3949 V 6.20 B-V -0.10 */ + {-17004, 9652, -26294, 164, 14}, /* HR 3955 V 6.20 B-V -0.13 */ + {-15385, 8708, -27589, 164, 76}, /* HR 3957 V 6.20 B-V 1.12 */ + {-10561, -4308, -30718, 164, 21}, /* HR 5066 V 6.20 B-V 0.02 */ + {-11675, -6640, -29888, 164, 73}, /* HR 5242 V 6.20 B-V 1.05 */ + {-5986, -5982, -31655, 164, 18}, /* HR 5555 V 6.20 B-V -0.04 */ + {7286, -6598, -31258, 164, 74}, /* HR 8081 V 6.20 B-V 1.08 */ + {13105, 3678, -29806, 164, 102}, /* HR 304 V 6.21 B-V 1.64 */ + {14993, 14241, -25418, 164, 99}, /* HR 871 V 6.21 B-V 1.58 */ + {-7487, 15543, -27857, 164, 73}, /* HR 3012 V 6.21 B-V 1.05 */ + {-11221, 12785, -28006, 164, 16}, /* HR 3489 V 6.21 B-V -0.09 */ + {-15663, 5312, -28286, 164, 50}, /* HR 4210 Eta Car V 6.21 B-V 0.61 */ + {-23219, 4629, -22652, 164, 101}, /* HR 4364 V 6.21 B-V 1.61 */ + {-13356, -1196, -29897, 164, 18}, /* HR 4692 V 6.21 B-V -0.04 */ + {11174, 2600, -30693, 164, 48}, /* HR 252 Lam1Tuc V 6.22 B-V 0.56 */ + {-14154, 9376, -28026, 164, 43}, /* HR 3887 V 6.22 B-V 0.46 */ + {-14770, 7200, -28349, 164, 30}, /* HR 4043 V 6.22 B-V 0.20 */ + {-15951, -586, -28616, 164, 107}, /* HR 4622 V 6.22 B-V 1.74 */ + {-14126, -881, -29552, 164, 26}, /* HR 4653 V 6.22 B-V 0.12 */ + {-9766, -699, -31270, 164, 20}, /* HR 4664 V 6.22 B-V -0.01 */ + {-15367, -1916, -28876, 164, 83}, /* HR 4747 V 6.22 B-V 1.26 */ + {-15278, -2383, -28889, 164, 56}, /* HR 4790 V 6.22 B-V 0.73 */ + {-12979, -11078, -27973, 164, 43}, /* HR 5465 V 6.22 B-V 0.45 */ + {-2234, -10585, -30930, 164, 73}, /* HR 6357 V 6.22 B-V 1.06 */ + {15520, 4041, -28574, 165, 25}, /* HR 281 V 6.23 B-V 0.10 */ + {-14792, 5810, -28655, 165, 90}, /* HR 4151 V 6.23 B-V 1.40 */ + {-11924, -329, -30518, 165, 82}, /* HR 4614 V 6.23 B-V 1.24 */ + {-20435, -1027, -25594, 165, 61}, /* HR 4637 V 6.23 B-V 0.82 */ + {-13322, -12112, -27377, 165, 76}, /* HR 5515 V 6.23 B-V 1.13 */ + {12385, 4329, -30026, 165, 22}, /* HR 380 V 6.24 B-V 0.05 */ + {16110, 12805, -25498, 165, 46}, /* HR 755 V 6.24 B-V 0.52 */ + {-21208, -4733, -24526, 165, 22}, /* HR 4871 V 6.24 B-V 0.05 */ + {-18835, -4384, -26452, 165, 76}, /* HR 4882 V 6.24 B-V 1.13 */ + {8070, 23350, -21525, 165, 93}, /* HR 1518 V 6.25 B-V 1.46 */ + {-8206, 14676, -28124, 165, 124}, /* HR 3126 V 6.25 B-V 2.08 */ + {-15259, 5085, -28548, 165, 22}, /* HR 4217 V 6.25 B-V 0.04 */ + {-12519, -2144, -30205, 165, 23}, /* HR 4806 V 6.25 B-V 0.06 */ + {-1645, -8582, -31580, 165, 20}, /* HR 6373 V 6.25 B-V -0.01 */ + {9796, 8474, -30098, 165, 46}, /* HR 823 V 6.26 B-V 0.53 */ + {-4857, 20218, -25324, 165, 70}, /* HR 2594 V 6.26 B-V 0.99 */ + {-11553, 7567, -29714, 165, 24}, /* HR 3891 Ups Car V 6.26 B-V 0.08 */ + {-10163, 3484, -30956, 165, 30}, /* HR 4211 V 6.26 B-V 0.20 */ + {-21422, 1385, -24756, 165, 78}, /* HR 4516 V 6.26 B-V 1.17 */ + {-22314, 319, -23992, 165, 40}, /* HR 4570 V 6.26 B-V 0.40 */ + {-21387, -2510, -24697, 165, 54}, /* HR 4734 V 6.26 B-V 0.68 */ + {-12862, -2263, -30052, 165, 18}, /* HR 4814 V 6.26 B-V -0.05 */ + {4532, 18525, -26645, 165, 97}, /* HR 1667 V 6.27 B-V 1.54 */ + {2225, 9297, -31341, 165, 20}, /* HR 1700 V 6.27 B-V -0.01 */ + {3067, 19794, -25932, 165, 24}, /* HR 1818 The Pic V 6.27 B-V 0.07 */ + {-1457, 14454, -29371, 165, 100}, /* HR 2337 V 6.27 B-V 1.60 */ + {-1569, 14367, -29407, 165, 14}, /* HR 2360 V 6.27 B-V -0.13 */ + {-4671, 17850, -27078, 165, 78}, /* HR 2634 V 6.27 B-V 1.16 */ + {-10327, 7814, -30099, 165, 88}, /* HR 3813 V 6.27 B-V 1.35 */ + {-22247, 9944, -21906, 165, 64}, /* HR 4087 V 6.27 B-V 0.88 */ + {-9351, 3201, -31241, 165, 44}, /* HR 4213 V 6.27 B-V 0.49 */ + {-8272, 1473, -31671, 165, 18}, /* HR 4387 V 6.27 B-V -0.03 */ + {856, -4590, -32433, 165, 14}, /* HR 6912 V 6.27 B-V -0.13 */ + {2851, 9486, -31234, 166, 46}, /* HR 1606 V 6.28 B-V 0.52 */ + {-8192, 18693, -25635, 166, 24}, /* HR 2925 V 6.28 B-V 0.08 */ + {-9397, 16029, -26990, 166, 12}, /* HR 3161 V 6.28 B-V -0.15 */ + {-7688, 12254, -29401, 166, 17}, /* HR 3217 V 6.28 B-V -0.06 */ + {-14306, 12053, -26902, 166, 15}, /* HR 3717 V 6.28 B-V -0.10 */ + {-9855, -10701, -29361, 166, 23}, /* HR 5623 V 6.28 B-V 0.06 */ + {-8038, -9637, -30269, 166, 16}, /* HR 5684 V 6.28 B-V -0.09 */ + {3886, 5374, -32089, 166, 77}, /* HR 1154 V 6.29 B-V 1.15 */ + {7231, 16278, -27503, 166, 53}, /* HR 1405 V 6.29 B-V 0.66 */ + {1714, 6420, -32086, 166, 96}, /* HR 1682 V 6.29 B-V 1.51 */ + {-1772, 13437, -29833, 166, 36}, /* HR 2408 V 6.29 B-V 0.33 */ + {-11991, 13996, -27093, 166, 79}, /* HR 3471 V 6.29 B-V 1.18 */ + {10660, 15888, -26601, 166, 72}, /* HR 1168 V 6.30 B-V 1.04 */ + {-7745, 12799, -29153, 166, 15}, /* HR 3186 V 6.30 B-V -0.10 */ + {-13241, 14705, -26117, 166, 15}, /* HR 3503 V 6.30 B-V -0.10 */ + {-12591, 10246, -28463, 166, 94}, /* HR 3740 V 6.30 B-V 1.48 */ + {-18478, 8946, -25538, 166, 97}, /* HR 4045 V 6.30 B-V 1.54 */ + {-7233, 2798, -31836, 166, 80}, /* HR 4170 V 6.30 B-V 1.20 */ + {-19961, 4783, -25541, 166, 68}, /* HR 4318 V 6.30 B-V 0.95 */ + {-13365, -1480, -29881, 166, 68}, /* HR 4720 V 6.30 B-V 0.96 */ + {-13848, -11676, -27305, 166, 79}, /* HR 5461 V 6.30 B-V 1.18 */ + {-10552, -11590, -28775, 166, 52}, /* HR 5632 V 6.30 B-V 0.63 */ + {1311, 12968, -30063, 166, 16}, /* HR 1960 V 6.31 B-V -0.07 */ + {-22401, 4308, -23523, 166, 40}, /* HR 4370 V 6.31 B-V 0.40 */ + {1723, 15703, -28707, 166, 62}, /* HR 1936 V 6.32 B-V 0.85 */ + {-10473, 18286, -25092, 166, 50}, /* HR 3142 V 6.32 B-V none */ + {-7976, 9182, -30426, 166, 95}, /* HR 3491 V 6.32 B-V 1.50 */ + {-13238, 11550, -27659, 166, 72}, /* HR 3693 V 6.32 B-V 1.04 */ + {-20079, 4779, -25449, 166, 78}, /* HR 4321 V 6.32 B-V 1.16 */ + {-10329, -11574, -28863, 166, 115}, /* HR 5645 V 6.32 B-V 1.90 */ + {19244, 760, -26510, 167, 57}, /* HR 23 V 6.33 B-V 0.74 */ + {5575, 2640, -32181, 167, 67}, /* HR 516 Tau1Hyi V 6.33 B-V 0.94 */ + {-8239, 16115, -27315, 167, 70}, /* HR 3056 V 6.33 B-V 1.01 */ + {-8120, 14111, -28436, 167, 17}, /* HR 3152 V 6.33 B-V -0.06 */ + {-14455, 12378, -26675, 167, 90}, /* HR 3700 V 6.33 B-V 1.41 */ + {-5682, 1725, -32224, 167, 93}, /* HR 4268 V 6.33 B-V 1.46 */ + {-3923, 326, -32530, 167, 74}, /* HR 4507 V 6.33 B-V 1.08 */ + {-13559, -348, -29828, 167, 31}, /* HR 4611 V 6.33 B-V 0.22 */ + {-2186, -245, -32693, 167, 74}, /* HR 4709 V 6.33 B-V 1.08 */ + {-11331, -2104, -30673, 167, 59}, /* HR 4820 V 6.33 B-V 0.78 */ + {-14003, -4542, -29274, 167, 42}, /* HR 4972 V 6.33 B-V 0.44 */ + {5892, -1062, -32215, 167, 66}, /* HR 8849 V 6.33 B-V 0.91 */ + {-10475, 18286, -25091, 167, 50}, /* HR 3143 V 6.34 B-V none */ + {-4697, 8196, -31376, 167, 27}, /* HR 3171 V 6.34 B-V 0.14 */ + {-11712, 15059, -26641, 167, 86}, /* HR 3382 V 6.34 B-V 1.31 */ + {-11345, 13434, -27649, 167, 30}, /* HR 3455 V 6.34 B-V 0.20 */ + {-7355, -3398, -31749, 167, 20}, /* HR 5115 V 6.34 B-V 0.01 */ + {-14160, -8929, -28168, 167, 22}, /* HR 5292 V 6.34 B-V 0.05 */ + {10500, -3346, -30858, 167, 24}, /* HR 8672 V 6.34 B-V 0.07 */ + {824, 19809, -26089, 167, 58}, /* HR 2044 V 6.35 B-V 0.76 */ + {-8967, 5380, -31054, 167, 16}, /* HR 3944 V 6.35 B-V -0.08 */ + {-15878, 7082, -27774, 167, 96}, /* HR 4091 V 6.35 B-V 1.52 */ + {-10199, 2192, -31062, 167, 88}, /* HR 4349 V 6.35 B-V 1.37 */ + {-5781, 1056, -32236, 167, 33}, /* HR 4385 V 6.35 B-V 0.26 */ + {-6479, -394, -32118, 167, 82}, /* HR 4649 V 6.35 B-V 1.24 */ + {115, -4849, -32406, 167, 95}, /* HR 6646 V 6.35 B-V 1.50 */ + {539, 14337, -29459, 167, 63}, /* HR 2073 V 6.36 B-V 0.86 */ + {-11361, 14859, -26904, 167, 60}, /* HR 3368 V 6.36 B-V 0.80 */ + {-10388, 12466, -28467, 167, 20}, /* HR 3443 V 6.36 B-V 0.00 */ + {-16750, 5471, -27626, 167, 101}, /* HR 4226 V 6.36 B-V 1.62 */ + {-12407, -1259, -30301, 167, 64}, /* HR 4710 V 6.36 B-V 0.89 */ + {-10652, -7857, -29974, 167, 26}, /* HR 5382 V 6.36 B-V 0.13 */ + {11864, 6705, -29799, 167, 65}, /* HR 584 V 6.37 B-V 0.90 */ + {11346, 8555, -29526, 167, 18}, /* HR 734 V 6.37 B-V -0.04 */ + {11181, 22326, -21218, 167, 93}, /* HR 1323 V 6.37 B-V 1.46 */ + {6953, 14312, -28644, 167, 24}, /* HR 1357 V 6.37 B-V 0.07 */ + {-1800, 9343, -31355, 167, 68}, /* HR 2531 V 6.37 B-V 0.96 */ + {-10238, 9705, -29575, 167, 88}, /* HR 3632 V 6.37 B-V 1.35 */ + {-17564, 10515, -25585, 167, 12}, /* HR 3935 V 6.37 B-V -0.17 */ + {-20713, -730, -25379, 167, 18}, /* HR 4619 V 6.37 B-V -0.05 */ + {-10768, -3677, -30728, 167, 80}, /* HR 4994 V 6.37 B-V 1.21 */ + {-12408, -5369, -29848, 167, 19}, /* HR 5093 V 6.37 B-V -0.02 */ + {6725, 12564, -29506, 168, 52}, /* HR 1294 V 6.38 B-V 0.64 */ + {-5864, 11926, -29951, 168, 68}, /* HR 3036 V 6.38 B-V 0.95 */ + {-9577, 17455, -26025, 168, 20}, /* HR 3100 V 6.38 B-V -0.01 */ + {-11921, 12464, -27860, 168, 15}, /* HR 3568 V 6.38 B-V -0.11 */ + {-15623, 1970, -28735, 168, 46}, /* HR 4438 V 6.38 B-V 0.52 */ + {-20870, -3117, -25068, 168, 43}, /* HR 4782 V 6.38 B-V 0.46 */ + {3354, -2484, -32500, 168, 26}, /* HR 8176 V 6.38 B-V 0.13 */ + {14039, 16964, -24265, 168, 70}, /* HR 1021 V 6.39 B-V 1.00 */ + {9437, 21529, -22828, 168, 42}, /* HR 1404 V 6.39 B-V 0.44 */ + {1624, 22773, -23504, 168, 34}, /* HR 1984 V 6.39 B-V 0.29 */ + {-5331, 13055, -29578, 168, 98}, /* HR 2888 V 6.39 B-V 1.56 */ + {-7476, 16787, -27129, 168, 79}, /* HR 2941 V 6.39 B-V 1.18 */ + {-13471, 17370, -24300, 168, 12}, /* HR 3375 V 6.39 B-V -0.15 */ + {-13762, 14671, -25866, 168, 20}, /* HR 3542 V 6.39 B-V 0.00 */ + {-6063, 452, -32198, 168, 65}, /* HR 4509 V 6.39 B-V 0.90 */ + {-16185, -10851, -26343, 168, 99}, /* HR 5319 V 6.39 B-V 1.57 */ + {-13595, -9219, -28352, 168, 122}, /* HR 5326 V 6.39 B-V 2.04 */ + {-7422, -11418, -29803, 168, 32}, /* HR 5852 V 6.39 B-V 0.24 */ + {1427, -6738, -32035, 168, 50}, /* HR 6994 V 6.39 B-V 0.60 */ + {2390, -4310, -32394, 168, 90}, /* HR 7494 V 6.39 B-V 1.40 */ + {-13950, 13579, -26357, 168, 16}, /* HR 3611 V 6.40 B-V -0.09 */ + {-15098, 7727, -28036, 168, 103}, /* HR 4007 V 6.40 B-V 1.66 */ + {-16620, -3190, -28058, 168, 75}, /* HR 4835 V 6.40 B-V 1.09 */ + {-12517, -7840, -29249, 168, 71}, /* HR 5289 V 6.40 B-V 1.02 */ + {-12758, -10266, -28382, 168, 83}, /* HR 5432 V 6.40 B-V 1.26 */ + {18825, 3092, -26641, 168, 70}, /* HR 162 V 6.41 B-V 1.00 */ + {16698, 5275, -27695, 168, 64}, /* HR 350 V 6.41 B-V 0.89 */ + {10524, 7748, -30048, 168, 97}, /* HR 722 V 6.41 B-V 1.54 */ + {9507, 12716, -28663, 168, 72}, /* HR 1096 V 6.41 B-V 1.04 */ + {1528, 2234, -32655, 168, 20}, /* HR 1271 V 6.41 B-V -0.01 */ + {3711, 12432, -30089, 168, 101}, /* HR 1598 V 6.41 B-V 1.63 */ + {-1545, 19781, -26077, 168, 93}, /* HR 2278 V 6.41 B-V 1.46 */ + {-3812, 16268, -28187, 168, 29}, /* HR 2592 V 6.41 B-V 0.18 */ + {-13901, 6980, -28839, 168, 15}, /* HR 4022 V 6.41 B-V -0.11 */ + {-13552, 3228, -29658, 168, 26}, /* HR 4326 V 6.41 B-V 0.12 */ + {-9975, 1756, -31162, 168, 22}, /* HR 4389 V 6.41 B-V 0.05 */ + {-18660, -8992, -25389, 168, 103}, /* HR 5152 V 6.41 B-V 1.67 */ + {6092, -3451, -32010, 168, 31}, /* HR 8370 V 6.41 B-V 0.22 */ + {5063, -1072, -32356, 168, 95}, /* HR 8810 V 6.41 B-V 1.50 */ + {13608, 2193, -29727, 168, 83}, /* HR 160 V 6.42 B-V 1.26 */ + {5791, 18630, -26326, 168, 50}, /* HR 1564 Iot Pic V 6.42 B-V none */ + {-4862, 21252, -24462, 168, 80}, /* HR 2563 V 6.42 B-V 1.21 */ + {-9508, 13844, -28136, 168, 40}, /* HR 3274 V 6.42 B-V 0.39 */ + {-13347, 7488, -28973, 168, 106}, /* HR 3967 V 6.42 B-V 1.72 */ + {-15577, 5570, -28284, 168, 24}, /* HR 4188 V 6.42 B-V 0.08 */ + {-10403, -112, -31072, 168, 78}, /* HR 4596 V 6.42 B-V 1.17 */ + {-17642, -2423, -27506, 168, 28}, /* HR 4764 Gam Cru V 6.42 B-V 0.16 */ + {-15613, -7126, -27913, 168, 76}, /* HR 5122 V 6.42 B-V 1.12 */ + {-14073, -8660, -28295, 168, 26}, /* HR 5281 V 6.42 B-V 0.12 */ + {-3296, -2403, -32512, 168, 21}, /* HR 5327 V 6.42 B-V 0.02 */ + {2154, 18717, -26809, 169, 48}, /* HR 1912 V 6.43 B-V 0.55 */ + {-1192, 16728, -28150, 169, 50}, /* HR 2274 V 6.43 B-V 0.59 */ + {-7355, 15390, -27977, 169, 15}, /* HR 3006 V 6.43 B-V -0.10 */ + {-14529, 5970, -28757, 169, 108}, /* HR 4128 V 6.43 B-V 1.76 */ + {-6935, 1162, -32004, 169, 30}, /* HR 4397 V 6.43 B-V 0.20 */ + {-19305, -5674, -25861, 169, 105}, /* HR 4939 V 6.43 B-V 1.70 */ + {9505, 22435, -21908, 169, 102}, /* HR 1429 V 6.44 B-V 1.64 */ + {7027, 19067, -25705, 169, 86}, /* HR 1498 V 6.44 B-V 1.32 */ + {-10083, 17758, -25625, 169, 32}, /* HR 3133 V 6.44 B-V 0.25 */ + {-11621, 17329, -25265, 169, 94}, /* HR 3256 V 6.44 B-V 1.49 */ + {-12584, 12068, -27743, 169, 32}, /* HR 3622 V 6.44 B-V 0.25 */ + {-8913, -145, -31531, 169, 82}, /* HR 4601 V 6.44 B-V 1.23 */ + {-6350, -9085, -30835, 169, 24}, /* HR 5792 V 6.44 B-V 0.08 */ + {13890, 20613, -21350, 169, 73}, /* HR 1157 V 6.45 B-V 1.06 */ + {235, 19523, -26315, 169, 94}, /* HR 2114 V 6.45 B-V 1.48 */ + {-154, 16335, -28405, 169, 99}, /* HR 2151 V 6.45 B-V 1.58 */ + {-4587, 17546, -27291, 169, 40}, /* HR 2638 V 6.45 B-V 0.39 */ + {-13368, -10140, -28145, 169, 27}, /* HR 5403 V 6.45 B-V 0.14 */ + {19, -2733, -32653, 169, 42}, /* HR 6552 V 6.45 B-V 0.44 */ + {2368, -1783, -32633, 169, 90}, /* HR 8129 V 6.45 B-V 1.40 */ + {12889, -1862, -30068, 169, 94}, /* HR 8908 V 6.45 B-V 1.47 */ + {10335, 16960, -26062, 169, 28}, /* HR 1227 V 6.46 B-V 0.16 */ + {4746, 13975, -29255, 169, 74}, /* HR 1540 V 6.46 B-V 1.08 */ + {-1560, 14573, -29306, 169, 53}, /* HR 2354 V 6.46 B-V 0.66 */ + {-3831, 18546, -26741, 169, 63}, /* HR 2524 V 6.46 B-V 0.86 */ + {-5874, 20062, -25233, 169, 50}, /* HR 2687 V 6.46 B-V none */ + {-14793, 9822, -27538, 169, 15}, /* HR 3883 V 6.46 B-V -0.11 */ + {-10169, 3475, -30955, 169, 32}, /* HR 4212 V 6.46 B-V 0.23 */ + {-3371, 11339, -30557, 169, 72}, /* HR 2712 V 6.47 B-V 1.04 */ + {-346, 1665, -32723, 169, 41}, /* HR 2848 V 6.47 B-V 0.42 */ + {-12566, 15143, -26200, 169, 15}, /* HR 3435 V 6.47 B-V -0.10 */ + {-18518, -9058, -25470, 169, 14}, /* HR 5158 V 6.47 B-V -0.13 */ + {-5788, -3938, -32010, 169, 91}, /* HR 5306 V 6.47 B-V 1.42 */ + {4546, -3384, -32273, 169, 22}, /* HR 8201 V 6.47 B-V 0.04 */ + {12575, -2776, -30130, 169, 68}, /* HR 8809 V 6.47 B-V 0.95 */ + {-1771, 17007, -27952, 170, 26}, /* HR 2336 V 6.48 B-V 0.12 */ + {-15698, 14416, -24888, 170, 29}, /* HR 3647 V 6.48 B-V 0.17 */ + {-15833, 9798, -26963, 170, 13}, /* HR 3920 V 6.48 B-V -0.14 */ + {-6478, -2790, -31999, 170, 44}, /* HR 5082 V 6.48 B-V 0.48 */ + {-656, -842, -32750, 170, 35}, /* HR 5491 V 6.48 B-V 0.30 */ + {7957, 554, -31781, 170, 70}, /* HR 58 V 6.49 B-V 1.00 */ + {12179, 18200, -24374, 170, 71}, /* HR 1167 V 6.49 B-V 1.02 */ + {3864, 19716, -25885, 170, 80}, /* HR 1742 V 6.49 B-V 1.21 */ + {-870, 21236, -24939, 170, 46}, /* HR 2204 V 6.49 B-V 0.52 */ + {-8156, -1410, -31704, 170, 24}, /* HR 4804 V 6.49 B-V 0.08 */ + {-13539, -7839, -28791, 170, 36}, /* HR 5252 V 6.49 B-V 0.33 */ + {-684, -9982, -31202, 170, 44}, /* HR 6565 V 6.49 B-V 0.48 */ +}; +const unsigned ck_sky_nstars = 1035; + +/* light at the middle of a star of magnitude code m, linear, Q16: exposure x 10^(-0.4 (V - 6.5)) */ +const uint32_t ck_sky_flux[256] = { + 9877139, 9432595, 9008058, 8602629, 8215447, 7845691, 7492576, 7155355, + 6833311, 6525761, 6232054, 5951565, 5683700, 5427892, 5183596, 4950296, + 4727496, 4514724, 4311528, 4117477, 3932160, 3755184, 3586173, 3424768, + 3270628, 3123426, 2982848, 2848598, 2720390, 2597952, 2481025, 2369361, + 2262722, 2160883, 2063627, 1970748, 1882050, 1797344, 1716450, 1639197, + 1565421, 1494966, 1427681, 1363425, 1302061, 1243458, 1187493, 1134047, + 1083007, 1034263, 987714, 943259, 900806, 860263, 821545, 784569, + 749258, 715535, 683331, 652576, 623205, 595156, 568370, 542789, + 518360, 495030, 472750, 451472, 431153, 411748, 393216, 375518, + 358617, 342477, 327063, 312343, 298285, 284860, 272039, 259795, + 248103, 236936, 226272, 216088, 206363, 197075, 188205, 179734, + 171645, 163920, 156542, 149497, 142768, 136342, 130206, 124346, + 118749, 113405, 108301, 103426, 98771, 94326, 90081, 86026, + 82154, 78457, 74926, 71554, 68333, 65258, 62321, 59516, + 56837, 54279, 51836, 49503, 47275, 45147, 43115, 41175, + 39322, 37552, 35862, 34248, 32706, 31234, 29828, 28486, + 27204, 25980, 24810, 23694, 22627, 21609, 20636, 19707, + 18821, 17973, 17165, 16392, 15654, 14950, 14277, 13634, + 13021, 12435, 11875, 11340, 10830, 10343, 9877, 9433, + 9008, 8603, 8215, 7846, 7493, 7155, 6833, 6526, + 6232, 5952, 5684, 5428, 5184, 4950, 4727, 4515, + 4312, 4117, 3932, 3755, 3586, 3425, 3271, 3123, + 2983, 2849, 2720, 2598, 2481, 2369, 2263, 2161, + 2064, 1971, 1882, 1797, 1716, 1639, 1565, 1495, + 1428, 1363, 1302, 1243, 1187, 1134, 1083, 1034, + 988, 943, 901, 860, 822, 785, 749, 716, + 683, 653, 623, 595, 568, 543, 518, 495, + 473, 451, 431, 412, 393, 376, 359, 342, + 327, 312, 298, 285, 272, 260, 248, 237, + 226, 216, 206, 197, 188, 180, 172, 164, + 157, 149, 143, 136, 130, 124, 119, 113, + 108, 103, 99, 94, 90, 86, 82, 78, +}; + +/* the colour of a black body at the temperature of B-V = -0.40 + 0.02 i (Ballesteros 2012), + * linear sRGB, the brightest channel 4096 */ +const uint16_t ck_sky_palette[128][3] = { + {1623, 2156, 4096}, /* B-V -0.40, 21707 K */ + {1657, 2185, 4096}, /* B-V -0.38, 20418 K */ + {1691, 2215, 4096}, /* B-V -0.36, 19289 K */ + {1727, 2245, 4096}, /* B-V -0.34, 18290 K */ + {1763, 2276, 4096}, /* B-V -0.32, 17400 K */ + {1801, 2307, 4096}, /* B-V -0.30, 16602 K */ + {1839, 2339, 4096}, /* B-V -0.28, 15882 K */ + {1878, 2371, 4096}, /* B-V -0.26, 15229 K */ + {1918, 2403, 4096}, /* B-V -0.24, 14633 K */ + {1959, 2436, 4096}, /* B-V -0.22, 14087 K */ + {2000, 2469, 4096}, /* B-V -0.20, 13585 K */ + {2043, 2503, 4096}, /* B-V -0.18, 13121 K */ + {2087, 2537, 4096}, /* B-V -0.16, 12692 K */ + {2131, 2572, 4096}, /* B-V -0.14, 12293 K */ + {2177, 2607, 4096}, /* B-V -0.12, 11920 K */ + {2224, 2643, 4096}, /* B-V -0.10, 11573 K */ + {2272, 2679, 4096}, /* B-V -0.08, 11247 K */ + {2321, 2715, 4096}, /* B-V -0.06, 10941 K */ + {2371, 2752, 4096}, /* B-V -0.04, 10653 K */ + {2422, 2790, 4096}, /* B-V -0.02, 10382 K */ + {2474, 2828, 4096}, /* B-V 0.00, 10125 K */ + {2528, 2867, 4096}, /* B-V 0.02, 9882 K */ + {2582, 2906, 4096}, /* B-V 0.04, 9652 K */ + {2638, 2945, 4096}, /* B-V 0.06, 9434 K */ + {2695, 2985, 4096}, /* B-V 0.08, 9226 K */ + {2754, 3026, 4096}, /* B-V 0.10, 9028 K */ + {2813, 3067, 4096}, /* B-V 0.12, 8839 K */ + {2874, 3109, 4096}, /* B-V 0.14, 8658 K */ + {2937, 3151, 4096}, /* B-V 0.16, 8486 K */ + {3001, 3194, 4096}, /* B-V 0.18, 8321 K */ + {3066, 3237, 4096}, /* B-V 0.20, 8163 K */ + {3132, 3281, 4096}, /* B-V 0.22, 8011 K */ + {3201, 3325, 4096}, /* B-V 0.24, 7866 K */ + {3270, 3371, 4096}, /* B-V 0.26, 7726 K */ + {3341, 3416, 4096}, /* B-V 0.28, 7591 K */ + {3414, 3462, 4096}, /* B-V 0.30, 7462 K */ + {3488, 3509, 4096}, /* B-V 0.32, 7337 K */ + {3564, 3557, 4096}, /* B-V 0.34, 7217 K */ + {3642, 3605, 4096}, /* B-V 0.36, 7101 K */ + {3721, 3654, 4096}, /* B-V 0.38, 6989 K */ + {3802, 3703, 4096}, /* B-V 0.40, 6880 K */ + {3885, 3753, 4096}, /* B-V 0.42, 6776 K */ + {3970, 3804, 4096}, /* B-V 0.44, 6674 K */ + {4056, 3855, 4096}, /* B-V 0.46, 6576 K */ + {4096, 3861, 4048}, /* B-V 0.48, 6481 K */ + {4096, 3830, 3962}, /* B-V 0.50, 6389 K */ + {4096, 3799, 3877}, /* B-V 0.52, 6300 K */ + {4096, 3768, 3795}, /* B-V 0.54, 6213 K */ + {4096, 3738, 3714}, /* B-V 0.56, 6129 K */ + {4096, 3708, 3635}, /* B-V 0.58, 6047 K */ + {4096, 3677, 3557}, /* B-V 0.60, 5968 K */ + {4096, 3648, 3482}, /* B-V 0.62, 5890 K */ + {4096, 3618, 3408}, /* B-V 0.64, 5815 K */ + {4096, 3589, 3335}, /* B-V 0.66, 5742 K */ + {4096, 3560, 3264}, /* B-V 0.68, 5671 K */ + {4096, 3531, 3194}, /* B-V 0.70, 5602 K */ + {4096, 3502, 3126}, /* B-V 0.72, 5534 K */ + {4096, 3474, 3060}, /* B-V 0.74, 5468 K */ + {4096, 3446, 2995}, /* B-V 0.76, 5404 K */ + {4096, 3418, 2931}, /* B-V 0.78, 5342 K */ + {4096, 3390, 2869}, /* B-V 0.80, 5281 K */ + {4096, 3363, 2808}, /* B-V 0.82, 5221 K */ + {4096, 3336, 2748}, /* B-V 0.84, 5163 K */ + {4096, 3309, 2689}, /* B-V 0.86, 5106 K */ + {4096, 3282, 2632}, /* B-V 0.88, 5051 K */ + {4096, 3256, 2576}, /* B-V 0.90, 4996 K */ + {4096, 3230, 2521}, /* B-V 0.92, 4943 K */ + {4096, 3204, 2468}, /* B-V 0.94, 4892 K */ + {4096, 3178, 2415}, /* B-V 0.96, 4841 K */ + {4096, 3153, 2364}, /* B-V 0.98, 4791 K */ + {4096, 3127, 2313}, /* B-V 1.00, 4743 K */ + {4096, 3102, 2264}, /* B-V 1.02, 4695 K */ + {4096, 3078, 2216}, /* B-V 1.04, 4649 K */ + {4096, 3053, 2169}, /* B-V 1.06, 4603 K */ + {4096, 3029, 2123}, /* B-V 1.08, 4559 K */ + {4096, 3004, 2077}, /* B-V 1.10, 4515 K */ + {4096, 2981, 2033}, /* B-V 1.12, 4472 K */ + {4096, 2957, 1990}, /* B-V 1.14, 4430 K */ + {4096, 2933, 1947}, /* B-V 1.16, 4389 K */ + {4096, 2910, 1906}, /* B-V 1.18, 4348 K */ + {4096, 2887, 1865}, /* B-V 1.20, 4309 K */ + {4096, 2864, 1825}, /* B-V 1.22, 4270 K */ + {4096, 2841, 1786}, /* B-V 1.24, 4232 K */ + {4096, 2819, 1748}, /* B-V 1.26, 4194 K */ + {4096, 2797, 1711}, /* B-V 1.28, 4158 K */ + {4096, 2775, 1674}, /* B-V 1.30, 4121 K */ + {4096, 2753, 1638}, /* B-V 1.32, 4086 K */ + {4096, 2731, 1603}, /* B-V 1.34, 4051 K */ + {4096, 2710, 1569}, /* B-V 1.36, 4017 K */ + {4096, 2689, 1535}, /* B-V 1.38, 3983 K */ + {4096, 2667, 1502}, /* B-V 1.40, 3950 K */ + {4096, 2647, 1470}, /* B-V 1.42, 3918 K */ + {4096, 2626, 1438}, /* B-V 1.44, 3886 K */ + {4096, 2605, 1407}, /* B-V 1.46, 3855 K */ + {4096, 2585, 1377}, /* B-V 1.48, 3824 K */ + {4096, 2565, 1347}, /* B-V 1.50, 3794 K */ + {4096, 2545, 1318}, /* B-V 1.52, 3764 K */ + {4096, 2525, 1290}, /* B-V 1.54, 3734 K */ + {4096, 2506, 1262}, /* B-V 1.56, 3705 K */ + {4096, 2486, 1234}, /* B-V 1.58, 3677 K */ + {4096, 2467, 1208}, /* B-V 1.60, 3649 K */ + {4096, 2448, 1181}, /* B-V 1.62, 3622 K */ + {4096, 2429, 1156}, /* B-V 1.64, 3594 K */ + {4096, 2410, 1131}, /* B-V 1.66, 3568 K */ + {4096, 2392, 1106}, /* B-V 1.68, 3541 K */ + {4096, 2373, 1082}, /* B-V 1.70, 3516 K */ + {4096, 2355, 1058}, /* B-V 1.72, 3490 K */ + {4096, 2337, 1035}, /* B-V 1.74, 3465 K */ + {4096, 2319, 1012}, /* B-V 1.76, 3440 K */ + {4096, 2301, 990}, /* B-V 1.78, 3416 K */ + {4096, 2284, 968}, /* B-V 1.80, 3392 K */ + {4096, 2266, 947}, /* B-V 1.82, 3368 K */ + {4096, 2249, 926}, /* B-V 1.84, 3345 K */ + {4096, 2232, 905}, /* B-V 1.86, 3322 K */ + {4096, 2215, 885}, /* B-V 1.88, 3299 K */ + {4096, 2198, 865}, /* B-V 1.90, 3277 K */ + {4096, 2181, 846}, /* B-V 1.92, 3255 K */ + {4096, 2165, 827}, /* B-V 1.94, 3233 K */ + {4096, 2148, 809}, /* B-V 1.96, 3211 K */ + {4096, 2132, 790}, /* B-V 1.98, 3190 K */ + {4096, 2116, 773}, /* B-V 2.00, 3169 K */ + {4096, 2100, 755}, /* B-V 2.02, 3149 K */ + {4096, 2084, 738}, /* B-V 2.04, 3128 K */ + {4096, 2068, 721}, /* B-V 2.06, 3108 K */ + {4096, 2053, 705}, /* B-V 2.08, 3089 K */ + {4096, 2037, 689}, /* B-V 2.10, 3069 K */ + {4096, 2022, 673}, /* B-V 2.12, 3050 K */ + {4096, 2007, 658}, /* B-V 2.14, 3031 K */ +}; + +/* sRGB level -> linear light, Q15 */ +const uint16_t ck_sky_lin[256] = { + 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 99, 110, 120, 132, 144, 157, + 170, 184, 198, 213, 229, 246, 263, 281, 299, 319, 338, 359, 381, 403, 425, 449, + 473, 498, 524, 551, 578, 606, 635, 665, 695, 727, 759, 792, 825, 860, 895, 931, + 969, 1006, 1045, 1085, 1125, 1167, 1209, 1252, 1296, 1341, 1386, 1433, 1481, 1529, 1578, 1629, + 1680, 1732, 1785, 1839, 1894, 1950, 2007, 2065, 2123, 2183, 2244, 2306, 2368, 2432, 2496, 2562, + 2629, 2696, 2765, 2834, 2905, 2977, 3049, 3123, 3198, 3273, 3350, 3428, 3507, 3587, 3668, 3750, + 3833, 3917, 4002, 4089, 4176, 4264, 4354, 4444, 4536, 4629, 4723, 4818, 4914, 5011, 5109, 5209, + 5309, 5411, 5514, 5618, 5723, 5829, 5936, 6045, 6155, 6265, 6377, 6490, 6605, 6720, 6837, 6954, + 7073, 7193, 7315, 7437, 7561, 7686, 7812, 7939, 8068, 8197, 8328, 8460, 8593, 8728, 8864, 9001, + 9139, 9278, 9419, 9561, 9704, 9848, 9994, 10141, 10289, 10438, 10589, 10741, 10894, 11048, 11204, 11361, + 11519, 11679, 11839, 12001, 12165, 12329, 12495, 12663, 12831, 13001, 13172, 13344, 13518, 13693, 13870, 14047, + 14226, 14407, 14588, 14771, 14956, 15141, 15328, 15517, 15706, 15897, 16090, 16284, 16479, 16675, 16873, 17072, + 17273, 17474, 17678, 17882, 18088, 18296, 18504, 18715, 18926, 19139, 19353, 19569, 19786, 20005, 20225, 20446, + 20669, 20893, 21118, 21345, 21574, 21803, 22035, 22267, 22501, 22737, 22974, 23212, 23452, 23693, 23936, 24180, + 24425, 24672, 24921, 25171, 25422, 25675, 25929, 26185, 26442, 26701, 26961, 27223, 27486, 27750, 28016, 28284, + 28553, 28823, 29095, 29369, 29644, 29920, 30198, 30478, 30759, 31041, 31325, 31611, 31898, 32186, 32476, 32768, +}; +/* linear light (Q15 >> 3, 0..4095) -> sRGB level x 16 (sixteenths, for dithering) */ +const uint16_t ck_sky_srgb16[4096] = { + 0, 13, 26, 39, 51, 64, 77, 90, 103, 116, 129, 142, 154, 167, 180, 191, + 203, 214, 224, 234, 244, 254, 263, 272, 281, 290, 298, 307, 315, 323, 331, 338, + 346, 353, 360, 367, 374, 381, 388, 395, 401, 408, 414, 420, 427, 433, 439, 445, + 451, 456, 462, 468, 474, 479, 485, 490, 495, 501, 506, 511, 516, 522, 527, 532, + 537, 542, 546, 551, 556, 561, 566, 570, 575, 579, 584, 589, 593, 598, 602, 606, + 611, 615, 619, 624, 628, 632, 636, 640, 645, 649, 653, 657, 661, 665, 669, 673, + 677, 681, 684, 688, 692, 696, 700, 703, 707, 711, 715, 718, 722, 726, 729, 733, + 736, 740, 744, 747, 751, 754, 758, 761, 764, 768, 771, 775, 778, 781, 785, 788, + 791, 795, 798, 801, 805, 808, 811, 814, 817, 821, 824, 827, 830, 833, 836, 839, + 843, 846, 849, 852, 855, 858, 861, 864, 867, 870, 873, 876, 879, 882, 885, 887, + 890, 893, 896, 899, 902, 905, 908, 910, 913, 916, 919, 922, 924, 927, 930, 933, + 936, 938, 941, 944, 946, 949, 952, 955, 957, 960, 963, 965, 968, 971, 973, 976, + 978, 981, 984, 986, 989, 991, 994, 996, 999, 1002, 1004, 1007, 1009, 1012, 1014, 1017, + 1019, 1022, 1024, 1027, 1029, 1032, 1034, 1036, 1039, 1041, 1044, 1046, 1049, 1051, 1053, 1056, + 1058, 1061, 1063, 1065, 1068, 1070, 1072, 1075, 1077, 1079, 1082, 1084, 1086, 1089, 1091, 1093, + 1096, 1098, 1100, 1102, 1105, 1107, 1109, 1111, 1114, 1116, 1118, 1120, 1123, 1125, 1127, 1129, + 1132, 1134, 1136, 1138, 1140, 1143, 1145, 1147, 1149, 1151, 1153, 1156, 1158, 1160, 1162, 1164, + 1166, 1168, 1170, 1173, 1175, 1177, 1179, 1181, 1183, 1185, 1187, 1189, 1191, 1194, 1196, 1198, + 1200, 1202, 1204, 1206, 1208, 1210, 1212, 1214, 1216, 1218, 1220, 1222, 1224, 1226, 1228, 1230, + 1232, 1234, 1236, 1238, 1240, 1242, 1244, 1246, 1248, 1250, 1252, 1254, 1256, 1258, 1260, 1262, + 1264, 1266, 1268, 1269, 1271, 1273, 1275, 1277, 1279, 1281, 1283, 1285, 1287, 1289, 1290, 1292, + 1294, 1296, 1298, 1300, 1302, 1304, 1305, 1307, 1309, 1311, 1313, 1315, 1317, 1318, 1320, 1322, + 1324, 1326, 1328, 1329, 1331, 1333, 1335, 1337, 1339, 1340, 1342, 1344, 1346, 1348, 1349, 1351, + 1353, 1355, 1356, 1358, 1360, 1362, 1364, 1365, 1367, 1369, 1371, 1372, 1374, 1376, 1378, 1379, + 1381, 1383, 1385, 1386, 1388, 1390, 1392, 1393, 1395, 1397, 1398, 1400, 1402, 1404, 1405, 1407, + 1409, 1410, 1412, 1414, 1415, 1417, 1419, 1420, 1422, 1424, 1426, 1427, 1429, 1431, 1432, 1434, + 1436, 1437, 1439, 1441, 1442, 1444, 1445, 1447, 1449, 1450, 1452, 1454, 1455, 1457, 1459, 1460, + 1462, 1463, 1465, 1467, 1468, 1470, 1472, 1473, 1475, 1476, 1478, 1480, 1481, 1483, 1484, 1486, + 1488, 1489, 1491, 1492, 1494, 1496, 1497, 1499, 1500, 1502, 1503, 1505, 1507, 1508, 1510, 1511, + 1513, 1514, 1516, 1517, 1519, 1521, 1522, 1524, 1525, 1527, 1528, 1530, 1531, 1533, 1534, 1536, + 1538, 1539, 1541, 1542, 1544, 1545, 1547, 1548, 1550, 1551, 1553, 1554, 1556, 1557, 1559, 1560, + 1562, 1563, 1565, 1566, 1568, 1569, 1571, 1572, 1574, 1575, 1577, 1578, 1580, 1581, 1583, 1584, + 1586, 1587, 1589, 1590, 1591, 1593, 1594, 1596, 1597, 1599, 1600, 1602, 1603, 1605, 1606, 1607, + 1609, 1610, 1612, 1613, 1615, 1616, 1618, 1619, 1620, 1622, 1623, 1625, 1626, 1628, 1629, 1630, + 1632, 1633, 1635, 1636, 1638, 1639, 1640, 1642, 1643, 1645, 1646, 1647, 1649, 1650, 1652, 1653, + 1654, 1656, 1657, 1659, 1660, 1661, 1663, 1664, 1666, 1667, 1668, 1670, 1671, 1672, 1674, 1675, + 1677, 1678, 1679, 1681, 1682, 1683, 1685, 1686, 1688, 1689, 1690, 1692, 1693, 1694, 1696, 1697, + 1698, 1700, 1701, 1702, 1704, 1705, 1707, 1708, 1709, 1711, 1712, 1713, 1715, 1716, 1717, 1719, + 1720, 1721, 1723, 1724, 1725, 1727, 1728, 1729, 1731, 1732, 1733, 1734, 1736, 1737, 1738, 1740, + 1741, 1742, 1744, 1745, 1746, 1748, 1749, 1750, 1752, 1753, 1754, 1755, 1757, 1758, 1759, 1761, + 1762, 1763, 1765, 1766, 1767, 1768, 1770, 1771, 1772, 1774, 1775, 1776, 1777, 1779, 1780, 1781, + 1782, 1784, 1785, 1786, 1788, 1789, 1790, 1791, 1793, 1794, 1795, 1796, 1798, 1799, 1800, 1801, + 1803, 1804, 1805, 1806, 1808, 1809, 1810, 1811, 1813, 1814, 1815, 1816, 1818, 1819, 1820, 1821, + 1823, 1824, 1825, 1826, 1828, 1829, 1830, 1831, 1833, 1834, 1835, 1836, 1837, 1839, 1840, 1841, + 1842, 1844, 1845, 1846, 1847, 1848, 1850, 1851, 1852, 1853, 1855, 1856, 1857, 1858, 1859, 1861, + 1862, 1863, 1864, 1865, 1867, 1868, 1869, 1870, 1871, 1873, 1874, 1875, 1876, 1877, 1879, 1880, + 1881, 1882, 1883, 1885, 1886, 1887, 1888, 1889, 1891, 1892, 1893, 1894, 1895, 1896, 1898, 1899, + 1900, 1901, 1902, 1904, 1905, 1906, 1907, 1908, 1909, 1911, 1912, 1913, 1914, 1915, 1916, 1918, + 1919, 1920, 1921, 1922, 1923, 1924, 1926, 1927, 1928, 1929, 1930, 1931, 1933, 1934, 1935, 1936, + 1937, 1938, 1939, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1949, 1950, 1951, 1952, 1953, 1954, + 1955, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, + 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1984, 1985, 1986, 1987, 1988, 1989, 1990, + 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, + 2009, 2010, 2011, 2012, 2013, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, + 2026, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2041, 2042, 2043, + 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2056, 2057, 2058, 2059, 2060, + 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2073, 2074, 2075, 2076, 2077, + 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, + 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, + 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, + 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, + 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159, + 2160, 2161, 2162, 2163, 2164, 2165, 2166, 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174, 2175, + 2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, + 2192, 2193, 2194, 2195, 2196, 2197, 2197, 2198, 2199, 2200, 2201, 2202, 2203, 2204, 2205, 2206, + 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, + 2223, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, + 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2252, + 2253, 2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267, 2268, + 2269, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283, + 2284, 2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2296, 2297, 2297, + 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2308, 2309, 2309, 2310, 2311, 2312, + 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, + 2328, 2329, 2330, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2340, 2341, + 2342, 2343, 2344, 2345, 2346, 2347, 2348, 2349, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, + 2357, 2358, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2366, 2367, 2368, 2369, 2370, + 2371, 2372, 2373, 2374, 2375, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2382, 2383, 2384, + 2385, 2386, 2387, 2388, 2389, 2390, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2397, 2398, + 2399, 2400, 2401, 2402, 2403, 2404, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2411, 2412, + 2413, 2414, 2415, 2416, 2417, 2417, 2418, 2419, 2420, 2421, 2422, 2423, 2424, 2424, 2425, 2426, + 2427, 2428, 2429, 2430, 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2436, 2437, 2438, 2439, 2440, + 2441, 2442, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2448, 2449, 2450, 2451, 2452, 2453, 2454, + 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2460, 2461, 2462, 2463, 2464, 2465, 2465, 2466, 2467, + 2468, 2469, 2470, 2471, 2471, 2472, 2473, 2474, 2475, 2476, 2476, 2477, 2478, 2479, 2480, 2481, + 2481, 2482, 2483, 2484, 2485, 2486, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2492, 2493, 2494, + 2495, 2496, 2497, 2497, 2498, 2499, 2500, 2501, 2501, 2502, 2503, 2504, 2505, 2506, 2506, 2507, + 2508, 2509, 2510, 2511, 2511, 2512, 2513, 2514, 2515, 2516, 2516, 2517, 2518, 2519, 2520, 2520, + 2521, 2522, 2523, 2524, 2525, 2525, 2526, 2527, 2528, 2529, 2530, 2530, 2531, 2532, 2533, 2534, + 2534, 2535, 2536, 2537, 2538, 2539, 2539, 2540, 2541, 2542, 2543, 2543, 2544, 2545, 2546, 2547, + 2547, 2548, 2549, 2550, 2551, 2551, 2552, 2553, 2554, 2555, 2556, 2556, 2557, 2558, 2559, 2560, + 2560, 2561, 2562, 2563, 2564, 2564, 2565, 2566, 2567, 2568, 2568, 2569, 2570, 2571, 2572, 2572, + 2573, 2574, 2575, 2576, 2576, 2577, 2578, 2579, 2580, 2580, 2581, 2582, 2583, 2584, 2584, 2585, + 2586, 2587, 2588, 2588, 2589, 2590, 2591, 2592, 2592, 2593, 2594, 2595, 2596, 2596, 2597, 2598, + 2599, 2599, 2600, 2601, 2602, 2603, 2603, 2604, 2605, 2606, 2607, 2607, 2608, 2609, 2610, 2611, + 2611, 2612, 2613, 2614, 2614, 2615, 2616, 2617, 2618, 2618, 2619, 2620, 2621, 2621, 2622, 2623, + 2624, 2625, 2625, 2626, 2627, 2628, 2629, 2629, 2630, 2631, 2632, 2632, 2633, 2634, 2635, 2636, + 2636, 2637, 2638, 2639, 2639, 2640, 2641, 2642, 2642, 2643, 2644, 2645, 2646, 2646, 2647, 2648, + 2649, 2649, 2650, 2651, 2652, 2653, 2653, 2654, 2655, 2656, 2656, 2657, 2658, 2659, 2659, 2660, + 2661, 2662, 2662, 2663, 2664, 2665, 2666, 2666, 2667, 2668, 2669, 2669, 2670, 2671, 2672, 2672, + 2673, 2674, 2675, 2675, 2676, 2677, 2678, 2679, 2679, 2680, 2681, 2682, 2682, 2683, 2684, 2685, + 2685, 2686, 2687, 2688, 2688, 2689, 2690, 2691, 2691, 2692, 2693, 2694, 2694, 2695, 2696, 2697, + 2697, 2698, 2699, 2700, 2700, 2701, 2702, 2703, 2703, 2704, 2705, 2706, 2706, 2707, 2708, 2709, + 2709, 2710, 2711, 2712, 2712, 2713, 2714, 2715, 2715, 2716, 2717, 2718, 2718, 2719, 2720, 2721, + 2721, 2722, 2723, 2724, 2724, 2725, 2726, 2727, 2727, 2728, 2729, 2730, 2730, 2731, 2732, 2733, + 2733, 2734, 2735, 2736, 2736, 2737, 2738, 2738, 2739, 2740, 2741, 2741, 2742, 2743, 2744, 2744, + 2745, 2746, 2747, 2747, 2748, 2749, 2750, 2750, 2751, 2752, 2752, 2753, 2754, 2755, 2755, 2756, + 2757, 2758, 2758, 2759, 2760, 2761, 2761, 2762, 2763, 2763, 2764, 2765, 2766, 2766, 2767, 2768, + 2769, 2769, 2770, 2771, 2771, 2772, 2773, 2774, 2774, 2775, 2776, 2777, 2777, 2778, 2779, 2779, + 2780, 2781, 2782, 2782, 2783, 2784, 2785, 2785, 2786, 2787, 2787, 2788, 2789, 2790, 2790, 2791, + 2792, 2792, 2793, 2794, 2795, 2795, 2796, 2797, 2797, 2798, 2799, 2800, 2800, 2801, 2802, 2803, + 2803, 2804, 2805, 2805, 2806, 2807, 2808, 2808, 2809, 2810, 2810, 2811, 2812, 2813, 2813, 2814, + 2815, 2815, 2816, 2817, 2818, 2818, 2819, 2820, 2820, 2821, 2822, 2823, 2823, 2824, 2825, 2825, + 2826, 2827, 2827, 2828, 2829, 2830, 2830, 2831, 2832, 2832, 2833, 2834, 2835, 2835, 2836, 2837, + 2837, 2838, 2839, 2839, 2840, 2841, 2842, 2842, 2843, 2844, 2844, 2845, 2846, 2847, 2847, 2848, + 2849, 2849, 2850, 2851, 2851, 2852, 2853, 2854, 2854, 2855, 2856, 2856, 2857, 2858, 2858, 2859, + 2860, 2861, 2861, 2862, 2863, 2863, 2864, 2865, 2865, 2866, 2867, 2868, 2868, 2869, 2870, 2870, + 2871, 2872, 2872, 2873, 2874, 2874, 2875, 2876, 2877, 2877, 2878, 2879, 2879, 2880, 2881, 2881, + 2882, 2883, 2883, 2884, 2885, 2886, 2886, 2887, 2888, 2888, 2889, 2890, 2890, 2891, 2892, 2892, + 2893, 2894, 2894, 2895, 2896, 2897, 2897, 2898, 2899, 2899, 2900, 2901, 2901, 2902, 2903, 2903, + 2904, 2905, 2905, 2906, 2907, 2908, 2908, 2909, 2910, 2910, 2911, 2912, 2912, 2913, 2914, 2914, + 2915, 2916, 2916, 2917, 2918, 2918, 2919, 2920, 2920, 2921, 2922, 2922, 2923, 2924, 2925, 2925, + 2926, 2927, 2927, 2928, 2929, 2929, 2930, 2931, 2931, 2932, 2933, 2933, 2934, 2935, 2935, 2936, + 2937, 2937, 2938, 2939, 2939, 2940, 2941, 2941, 2942, 2943, 2943, 2944, 2945, 2945, 2946, 2947, + 2947, 2948, 2949, 2949, 2950, 2951, 2952, 2952, 2953, 2954, 2954, 2955, 2956, 2956, 2957, 2958, + 2958, 2959, 2960, 2960, 2961, 2962, 2962, 2963, 2964, 2964, 2965, 2966, 2966, 2967, 2968, 2968, + 2969, 2970, 2970, 2971, 2972, 2972, 2973, 2974, 2974, 2975, 2976, 2976, 2977, 2978, 2978, 2979, + 2979, 2980, 2981, 2981, 2982, 2983, 2983, 2984, 2985, 2985, 2986, 2987, 2987, 2988, 2989, 2989, + 2990, 2991, 2991, 2992, 2993, 2993, 2994, 2995, 2995, 2996, 2997, 2997, 2998, 2999, 2999, 3000, + 3001, 3001, 3002, 3003, 3003, 3004, 3005, 3005, 3006, 3006, 3007, 3008, 3008, 3009, 3010, 3010, + 3011, 3012, 3012, 3013, 3014, 3014, 3015, 3016, 3016, 3017, 3018, 3018, 3019, 3020, 3020, 3021, + 3021, 3022, 3023, 3023, 3024, 3025, 3025, 3026, 3027, 3027, 3028, 3029, 3029, 3030, 3031, 3031, + 3032, 3033, 3033, 3034, 3034, 3035, 3036, 3036, 3037, 3038, 3038, 3039, 3040, 3040, 3041, 3042, + 3042, 3043, 3043, 3044, 3045, 3045, 3046, 3047, 3047, 3048, 3049, 3049, 3050, 3051, 3051, 3052, + 3052, 3053, 3054, 3054, 3055, 3056, 3056, 3057, 3058, 3058, 3059, 3060, 3060, 3061, 3061, 3062, + 3063, 3063, 3064, 3065, 3065, 3066, 3067, 3067, 3068, 3068, 3069, 3070, 3070, 3071, 3072, 3072, + 3073, 3074, 3074, 3075, 3075, 3076, 3077, 3077, 3078, 3079, 3079, 3080, 3081, 3081, 3082, 3082, + 3083, 3084, 3084, 3085, 3086, 3086, 3087, 3088, 3088, 3089, 3089, 3090, 3091, 3091, 3092, 3093, + 3093, 3094, 3094, 3095, 3096, 3096, 3097, 3098, 3098, 3099, 3099, 3100, 3101, 3101, 3102, 3103, + 3103, 3104, 3105, 3105, 3106, 3106, 3107, 3108, 3108, 3109, 3110, 3110, 3111, 3111, 3112, 3113, + 3113, 3114, 3115, 3115, 3116, 3116, 3117, 3118, 3118, 3119, 3120, 3120, 3121, 3121, 3122, 3123, + 3123, 3124, 3125, 3125, 3126, 3126, 3127, 3128, 3128, 3129, 3129, 3130, 3131, 3131, 3132, 3133, + 3133, 3134, 3134, 3135, 3136, 3136, 3137, 3138, 3138, 3139, 3139, 3140, 3141, 3141, 3142, 3143, + 3143, 3144, 3144, 3145, 3146, 3146, 3147, 3147, 3148, 3149, 3149, 3150, 3151, 3151, 3152, 3152, + 3153, 3154, 3154, 3155, 3155, 3156, 3157, 3157, 3158, 3159, 3159, 3160, 3160, 3161, 3162, 3162, + 3163, 3163, 3164, 3165, 3165, 3166, 3166, 3167, 3168, 3168, 3169, 3170, 3170, 3171, 3171, 3172, + 3173, 3173, 3174, 3174, 3175, 3176, 3176, 3177, 3177, 3178, 3179, 3179, 3180, 3181, 3181, 3182, + 3182, 3183, 3184, 3184, 3185, 3185, 3186, 3187, 3187, 3188, 3188, 3189, 3190, 3190, 3191, 3191, + 3192, 3193, 3193, 3194, 3194, 3195, 3196, 3196, 3197, 3197, 3198, 3199, 3199, 3200, 3200, 3201, + 3202, 3202, 3203, 3204, 3204, 3205, 3205, 3206, 3207, 3207, 3208, 3208, 3209, 3210, 3210, 3211, + 3211, 3212, 3213, 3213, 3214, 3214, 3215, 3216, 3216, 3217, 3217, 3218, 3219, 3219, 3220, 3220, + 3221, 3222, 3222, 3223, 3223, 3224, 3224, 3225, 3226, 3226, 3227, 3227, 3228, 3229, 3229, 3230, + 3230, 3231, 3232, 3232, 3233, 3233, 3234, 3235, 3235, 3236, 3236, 3237, 3238, 3238, 3239, 3239, + 3240, 3241, 3241, 3242, 3242, 3243, 3244, 3244, 3245, 3245, 3246, 3246, 3247, 3248, 3248, 3249, + 3249, 3250, 3251, 3251, 3252, 3252, 3253, 3254, 3254, 3255, 3255, 3256, 3257, 3257, 3258, 3258, + 3259, 3259, 3260, 3261, 3261, 3262, 3262, 3263, 3264, 3264, 3265, 3265, 3266, 3267, 3267, 3268, + 3268, 3269, 3269, 3270, 3271, 3271, 3272, 3272, 3273, 3274, 3274, 3275, 3275, 3276, 3277, 3277, + 3278, 3278, 3279, 3279, 3280, 3281, 3281, 3282, 3282, 3283, 3284, 3284, 3285, 3285, 3286, 3286, + 3287, 3288, 3288, 3289, 3289, 3290, 3291, 3291, 3292, 3292, 3293, 3293, 3294, 3295, 3295, 3296, + 3296, 3297, 3297, 3298, 3299, 3299, 3300, 3300, 3301, 3302, 3302, 3303, 3303, 3304, 3304, 3305, + 3306, 3306, 3307, 3307, 3308, 3308, 3309, 3310, 3310, 3311, 3311, 3312, 3313, 3313, 3314, 3314, + 3315, 3315, 3316, 3317, 3317, 3318, 3318, 3319, 3319, 3320, 3321, 3321, 3322, 3322, 3323, 3323, + 3324, 3325, 3325, 3326, 3326, 3327, 3327, 3328, 3329, 3329, 3330, 3330, 3331, 3331, 3332, 3333, + 3333, 3334, 3334, 3335, 3335, 3336, 3337, 3337, 3338, 3338, 3339, 3339, 3340, 3341, 3341, 3342, + 3342, 3343, 3343, 3344, 3345, 3345, 3346, 3346, 3347, 3347, 3348, 3349, 3349, 3350, 3350, 3351, + 3351, 3352, 3353, 3353, 3354, 3354, 3355, 3355, 3356, 3357, 3357, 3358, 3358, 3359, 3359, 3360, + 3360, 3361, 3362, 3362, 3363, 3363, 3364, 3364, 3365, 3366, 3366, 3367, 3367, 3368, 3368, 3369, + 3370, 3370, 3371, 3371, 3372, 3372, 3373, 3373, 3374, 3375, 3375, 3376, 3376, 3377, 3377, 3378, + 3379, 3379, 3380, 3380, 3381, 3381, 3382, 3382, 3383, 3384, 3384, 3385, 3385, 3386, 3386, 3387, + 3387, 3388, 3389, 3389, 3390, 3390, 3391, 3391, 3392, 3393, 3393, 3394, 3394, 3395, 3395, 3396, + 3396, 3397, 3398, 3398, 3399, 3399, 3400, 3400, 3401, 3401, 3402, 3403, 3403, 3404, 3404, 3405, + 3405, 3406, 3406, 3407, 3408, 3408, 3409, 3409, 3410, 3410, 3411, 3411, 3412, 3413, 3413, 3414, + 3414, 3415, 3415, 3416, 3416, 3417, 3418, 3418, 3419, 3419, 3420, 3420, 3421, 3421, 3422, 3423, + 3423, 3424, 3424, 3425, 3425, 3426, 3426, 3427, 3428, 3428, 3429, 3429, 3430, 3430, 3431, 3431, + 3432, 3432, 3433, 3434, 3434, 3435, 3435, 3436, 3436, 3437, 3437, 3438, 3439, 3439, 3440, 3440, + 3441, 3441, 3442, 3442, 3443, 3443, 3444, 3445, 3445, 3446, 3446, 3447, 3447, 3448, 3448, 3449, + 3449, 3450, 3451, 3451, 3452, 3452, 3453, 3453, 3454, 3454, 3455, 3455, 3456, 3457, 3457, 3458, + 3458, 3459, 3459, 3460, 3460, 3461, 3461, 3462, 3463, 3463, 3464, 3464, 3465, 3465, 3466, 3466, + 3467, 3467, 3468, 3469, 3469, 3470, 3470, 3471, 3471, 3472, 3472, 3473, 3473, 3474, 3474, 3475, + 3476, 3476, 3477, 3477, 3478, 3478, 3479, 3479, 3480, 3480, 3481, 3482, 3482, 3483, 3483, 3484, + 3484, 3485, 3485, 3486, 3486, 3487, 3487, 3488, 3489, 3489, 3490, 3490, 3491, 3491, 3492, 3492, + 3493, 3493, 3494, 3494, 3495, 3496, 3496, 3497, 3497, 3498, 3498, 3499, 3499, 3500, 3500, 3501, + 3501, 3502, 3503, 3503, 3504, 3504, 3505, 3505, 3506, 3506, 3507, 3507, 3508, 3508, 3509, 3509, + 3510, 3511, 3511, 3512, 3512, 3513, 3513, 3514, 3514, 3515, 3515, 3516, 3516, 3517, 3517, 3518, + 3519, 3519, 3520, 3520, 3521, 3521, 3522, 3522, 3523, 3523, 3524, 3524, 3525, 3525, 3526, 3527, + 3527, 3528, 3528, 3529, 3529, 3530, 3530, 3531, 3531, 3532, 3532, 3533, 3533, 3534, 3534, 3535, + 3536, 3536, 3537, 3537, 3538, 3538, 3539, 3539, 3540, 3540, 3541, 3541, 3542, 3542, 3543, 3543, + 3544, 3545, 3545, 3546, 3546, 3547, 3547, 3548, 3548, 3549, 3549, 3550, 3550, 3551, 3551, 3552, + 3552, 3553, 3553, 3554, 3555, 3555, 3556, 3556, 3557, 3557, 3558, 3558, 3559, 3559, 3560, 3560, + 3561, 3561, 3562, 3562, 3563, 3563, 3564, 3564, 3565, 3566, 3566, 3567, 3567, 3568, 3568, 3569, + 3569, 3570, 3570, 3571, 3571, 3572, 3572, 3573, 3573, 3574, 3574, 3575, 3575, 3576, 3576, 3577, + 3578, 3578, 3579, 3579, 3580, 3580, 3581, 3581, 3582, 3582, 3583, 3583, 3584, 3584, 3585, 3585, + 3586, 3586, 3587, 3587, 3588, 3588, 3589, 3589, 3590, 3591, 3591, 3592, 3592, 3593, 3593, 3594, + 3594, 3595, 3595, 3596, 3596, 3597, 3597, 3598, 3598, 3599, 3599, 3600, 3600, 3601, 3601, 3602, + 3602, 3603, 3603, 3604, 3604, 3605, 3606, 3606, 3607, 3607, 3608, 3608, 3609, 3609, 3610, 3610, + 3611, 3611, 3612, 3612, 3613, 3613, 3614, 3614, 3615, 3615, 3616, 3616, 3617, 3617, 3618, 3618, + 3619, 3619, 3620, 3620, 3621, 3621, 3622, 3622, 3623, 3624, 3624, 3625, 3625, 3626, 3626, 3627, + 3627, 3628, 3628, 3629, 3629, 3630, 3630, 3631, 3631, 3632, 3632, 3633, 3633, 3634, 3634, 3635, + 3635, 3636, 3636, 3637, 3637, 3638, 3638, 3639, 3639, 3640, 3640, 3641, 3641, 3642, 3642, 3643, + 3643, 3644, 3644, 3645, 3645, 3646, 3646, 3647, 3647, 3648, 3649, 3649, 3650, 3650, 3651, 3651, + 3652, 3652, 3653, 3653, 3654, 3654, 3655, 3655, 3656, 3656, 3657, 3657, 3658, 3658, 3659, 3659, + 3660, 3660, 3661, 3661, 3662, 3662, 3663, 3663, 3664, 3664, 3665, 3665, 3666, 3666, 3667, 3667, + 3668, 3668, 3669, 3669, 3670, 3670, 3671, 3671, 3672, 3672, 3673, 3673, 3674, 3674, 3675, 3675, + 3676, 3676, 3677, 3677, 3678, 3678, 3679, 3679, 3680, 3680, 3681, 3681, 3682, 3682, 3683, 3683, + 3684, 3684, 3685, 3685, 3686, 3686, 3687, 3687, 3688, 3688, 3689, 3689, 3690, 3690, 3691, 3691, + 3692, 3692, 3693, 3693, 3694, 3694, 3695, 3695, 3696, 3696, 3697, 3697, 3698, 3698, 3699, 3699, + 3700, 3700, 3701, 3701, 3702, 3702, 3703, 3703, 3704, 3704, 3705, 3705, 3706, 3706, 3707, 3707, + 3708, 3708, 3709, 3709, 3710, 3710, 3711, 3711, 3712, 3712, 3713, 3713, 3714, 3714, 3715, 3715, + 3716, 3716, 3717, 3717, 3718, 3718, 3719, 3719, 3720, 3720, 3721, 3721, 3722, 3722, 3723, 3723, + 3724, 3724, 3725, 3725, 3726, 3726, 3727, 3727, 3728, 3728, 3729, 3729, 3730, 3730, 3731, 3731, + 3732, 3732, 3733, 3733, 3734, 3734, 3735, 3735, 3735, 3736, 3736, 3737, 3737, 3738, 3738, 3739, + 3739, 3740, 3740, 3741, 3741, 3742, 3742, 3743, 3743, 3744, 3744, 3745, 3745, 3746, 3746, 3747, + 3747, 3748, 3748, 3749, 3749, 3750, 3750, 3751, 3751, 3752, 3752, 3753, 3753, 3754, 3754, 3755, + 3755, 3756, 3756, 3757, 3757, 3758, 3758, 3759, 3759, 3760, 3760, 3760, 3761, 3761, 3762, 3762, + 3763, 3763, 3764, 3764, 3765, 3765, 3766, 3766, 3767, 3767, 3768, 3768, 3769, 3769, 3770, 3770, + 3771, 3771, 3772, 3772, 3773, 3773, 3774, 3774, 3775, 3775, 3776, 3776, 3777, 3777, 3778, 3778, + 3778, 3779, 3779, 3780, 3780, 3781, 3781, 3782, 3782, 3783, 3783, 3784, 3784, 3785, 3785, 3786, + 3786, 3787, 3787, 3788, 3788, 3789, 3789, 3790, 3790, 3791, 3791, 3792, 3792, 3793, 3793, 3793, + 3794, 3794, 3795, 3795, 3796, 3796, 3797, 3797, 3798, 3798, 3799, 3799, 3800, 3800, 3801, 3801, + 3802, 3802, 3803, 3803, 3804, 3804, 3805, 3805, 3806, 3806, 3806, 3807, 3807, 3808, 3808, 3809, + 3809, 3810, 3810, 3811, 3811, 3812, 3812, 3813, 3813, 3814, 3814, 3815, 3815, 3816, 3816, 3817, + 3817, 3817, 3818, 3818, 3819, 3819, 3820, 3820, 3821, 3821, 3822, 3822, 3823, 3823, 3824, 3824, + 3825, 3825, 3826, 3826, 3827, 3827, 3828, 3828, 3828, 3829, 3829, 3830, 3830, 3831, 3831, 3832, + 3832, 3833, 3833, 3834, 3834, 3835, 3835, 3836, 3836, 3837, 3837, 3838, 3838, 3838, 3839, 3839, + 3840, 3840, 3841, 3841, 3842, 3842, 3843, 3843, 3844, 3844, 3845, 3845, 3846, 3846, 3847, 3847, + 3847, 3848, 3848, 3849, 3849, 3850, 3850, 3851, 3851, 3852, 3852, 3853, 3853, 3854, 3854, 3855, + 3855, 3856, 3856, 3856, 3857, 3857, 3858, 3858, 3859, 3859, 3860, 3860, 3861, 3861, 3862, 3862, + 3863, 3863, 3864, 3864, 3864, 3865, 3865, 3866, 3866, 3867, 3867, 3868, 3868, 3869, 3869, 3870, + 3870, 3871, 3871, 3872, 3872, 3872, 3873, 3873, 3874, 3874, 3875, 3875, 3876, 3876, 3877, 3877, + 3878, 3878, 3879, 3879, 3879, 3880, 3880, 3881, 3881, 3882, 3882, 3883, 3883, 3884, 3884, 3885, + 3885, 3886, 3886, 3886, 3887, 3887, 3888, 3888, 3889, 3889, 3890, 3890, 3891, 3891, 3892, 3892, + 3893, 3893, 3893, 3894, 3894, 3895, 3895, 3896, 3896, 3897, 3897, 3898, 3898, 3899, 3899, 3900, + 3900, 3900, 3901, 3901, 3902, 3902, 3903, 3903, 3904, 3904, 3905, 3905, 3906, 3906, 3907, 3907, + 3907, 3908, 3908, 3909, 3909, 3910, 3910, 3911, 3911, 3912, 3912, 3913, 3913, 3913, 3914, 3914, + 3915, 3915, 3916, 3916, 3917, 3917, 3918, 3918, 3919, 3919, 3919, 3920, 3920, 3921, 3921, 3922, + 3922, 3923, 3923, 3924, 3924, 3925, 3925, 3925, 3926, 3926, 3927, 3927, 3928, 3928, 3929, 3929, + 3930, 3930, 3931, 3931, 3931, 3932, 3932, 3933, 3933, 3934, 3934, 3935, 3935, 3936, 3936, 3937, + 3937, 3937, 3938, 3938, 3939, 3939, 3940, 3940, 3941, 3941, 3942, 3942, 3942, 3943, 3943, 3944, + 3944, 3945, 3945, 3946, 3946, 3947, 3947, 3948, 3948, 3948, 3949, 3949, 3950, 3950, 3951, 3951, + 3952, 3952, 3953, 3953, 3953, 3954, 3954, 3955, 3955, 3956, 3956, 3957, 3957, 3958, 3958, 3958, + 3959, 3959, 3960, 3960, 3961, 3961, 3962, 3962, 3963, 3963, 3963, 3964, 3964, 3965, 3965, 3966, + 3966, 3967, 3967, 3968, 3968, 3968, 3969, 3969, 3970, 3970, 3971, 3971, 3972, 3972, 3973, 3973, + 3973, 3974, 3974, 3975, 3975, 3976, 3976, 3977, 3977, 3978, 3978, 3978, 3979, 3979, 3980, 3980, + 3981, 3981, 3982, 3982, 3983, 3983, 3983, 3984, 3984, 3985, 3985, 3986, 3986, 3987, 3987, 3988, + 3988, 3988, 3989, 3989, 3990, 3990, 3991, 3991, 3992, 3992, 3992, 3993, 3993, 3994, 3994, 3995, + 3995, 3996, 3996, 3997, 3997, 3997, 3998, 3998, 3999, 3999, 4000, 4000, 4001, 4001, 4001, 4002, + 4002, 4003, 4003, 4004, 4004, 4005, 4005, 4006, 4006, 4006, 4007, 4007, 4008, 4008, 4009, 4009, + 4010, 4010, 4010, 4011, 4011, 4012, 4012, 4013, 4013, 4014, 4014, 4014, 4015, 4015, 4016, 4016, + 4017, 4017, 4018, 4018, 4019, 4019, 4019, 4020, 4020, 4021, 4021, 4022, 4022, 4023, 4023, 4023, + 4024, 4024, 4025, 4025, 4026, 4026, 4027, 4027, 4027, 4028, 4028, 4029, 4029, 4030, 4030, 4031, + 4031, 4031, 4032, 4032, 4033, 4033, 4034, 4034, 4035, 4035, 4035, 4036, 4036, 4037, 4037, 4038, + 4038, 4039, 4039, 4039, 4040, 4040, 4041, 4041, 4042, 4042, 4043, 4043, 4043, 4044, 4044, 4045, + 4045, 4046, 4046, 4047, 4047, 4047, 4048, 4048, 4049, 4049, 4050, 4050, 4051, 4051, 4051, 4052, + 4052, 4053, 4053, 4054, 4054, 4054, 4055, 4055, 4056, 4056, 4057, 4057, 4058, 4058, 4058, 4059, + 4059, 4060, 4060, 4061, 4061, 4062, 4062, 4062, 4063, 4063, 4064, 4064, 4065, 4065, 4066, 4066, + 4066, 4067, 4067, 4068, 4068, 4069, 4069, 4069, 4070, 4070, 4071, 4071, 4072, 4072, 4073, 4073, + 4073, 4074, 4074, 4075, 4075, 4076, 4076, 4076, 4077, 4077, 4078, 4078, 4079, 4079, 4080, 4080, +}; + +/* the Milky Way in the view: 361 x 180 samples, 0.00277777777777778 widths apart, the first row 0.000000 widths + * above the view centre and the first column half a width left of it; luma (R + 2G + B) / 4 in sRGB + * levels; colour (Co, Cg) at half the spacing, in half levels */ +const ck_sky_map ck_sky_milkyway = { + .cols = 361, .rows = 180, .per_width = 360, .row0_q16 = 0, +}; +const uint8_t ck_sky_luma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, 5, 5, 5, 5, 5, 5, 5, +}; +const int8_t ck_sky_chroma[16290][2] = { + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {2, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, + {2, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {3, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {4, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {4, 0}, {3, 0}, {3, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {4, 0}, {3, 0}, {3, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {4, 0}, {3, 0}, + {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {4, 0}, {4, 0}, + {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {4, 0}, + {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, + {4, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {4, 0}, {4, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {4, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {4, 0}, {4, 0}, {3, 0}, {3, 0}, + {4, 0}, {4, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {4, 0}, {4, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {3, 0}, {3, 0}, + {4, 0}, {5, 0}, {5, 1}, {4, 1}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {4, 0}, {4, 0}, {4, 0}, {3, 0}, + {4, 0}, {6, 0}, {5, 1}, {4, 1}, {3, 1}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {4, 0}, {3, 0}, {3, 0}, + {2, 0}, {3, 0}, {5, 0}, {5, 0}, {4, 1}, {3, 1}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {4, 0}, {3, 0}, {2, 0}, + {3, 0}, {3, 0}, {4, 0}, {5, 0}, {4, 0}, {3, 1}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, + {2, 0}, {3, 0}, {4, 0}, {5, 0}, {4, 1}, {3, 1}, {3, 1}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, + {2, 0}, {2, 0}, {3, 0}, {4, 0}, {4, 0}, {3, 1}, {3, 1}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 1}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, + {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, + {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, + {3, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {3, 0}, + {4, 0}, {3, 1}, {3, 1}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, + {4, 0}, {3, 0}, {3, 1}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {3, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 1}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, + {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 1}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, + {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {3, 0}, {2, 0}, {2, 0}, {3, 0}, {3, 0}, {3, 0}, {3, 0}, {2, 0}, {3, 0}, + {3, 0}, {3, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {1, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, + {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, + {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, +}; + +/* galaxies in the view bright enough to see: centre (Q15 direction), half axes in widths Q16, + * long axis angle on screen (turns / 65536, from screen right towards down), tint (sRGB) */ +const ck_sky_galaxy ck_sky_galaxies[2] = { + {{1794, 11195, -30743}, 3732, 3257, 23970, 0xfff7fau}, /* ESO056-115, Large Magellanic Cloud: V 0.29, 646.0 x 550.0 arcmin, PA 170 deg */ + {{9419, 2207, -31306}, 1905, 1255, 58867, 0xfdf8ffu}, /* NGC0292, Small Magellanic Cloud: V 2.30, 299.9 x 179.9 arcmin, PA 45 deg */ +}; +const unsigned ck_sky_ngalaxies = 2; + +/* for the host test: where these stars land on a 3840 x 2160 screen, 16ths of a pixel */ +const ck_sky_check ck_sky_checks[8] = { + {0, 37971, 1411}, /* HR 2326 Alp Car */ + {1, 9126, 31733}, /* HR 5459 Alp1Cen */ + {2, 55324, 24857}, /* HR 472 Alp Eri */ + {3, 8601, 28137}, /* HR 5267 Bet Cen */ + {4, 9563, 20572}, /* HR 4853 Bet Cru */ + {5, 12947, 19480}, /* HR 4730 Alp1Cru */ + {6, 9126, 31733}, /* HR 5460 Alp2Cen */ + {7, 8127, 18446}, /* HR 4763 Gam Cru */ +}; +const unsigned ck_sky_nchecks = 8; diff --git a/om/allen-scene/native/sky_data.h b/om/allen-scene/native/sky_data.h new file mode 100644 index 0000000..6b2318b --- /dev/null +++ b/om/allen-scene/native/sky_data.h @@ -0,0 +1,62 @@ +/* sky_data.h -- the real sky as tables: what native/kernel/tools/ck_sky_gen.c + * writes into sky_data.c (regenerate with scripts/ck_sky_gen.sh; the inputs, + * their addresses and sha256 are listed there and in NOTICE). + * + * Directions are unit vectors in the J2000 equatorial frame (x towards + * RA 0 Dec 0, z towards the north celestial pole), Q15. Integer only. + * + * The Milky Way is stored as a full-sphere equirectangular grid (cols x rows): + * col 0..cols-1 covers RA 0..360 degrees (wraps); + * row 0 = Dec +90, row rows-1 = Dec -90; + * luma at full resolution, chroma at half (cols/2 x rows/2). + * The generator queries Gaia DR3 (ESA/Gaia/DPAC, CC BY-NC 3.0 IGO) and + * reddening from gaiadr3.astrophysical_parameters to fill the grid. */ +#ifndef AIENOS_SKY_DATA_H +#define AIENOS_SKY_DATA_H +#include + +typedef struct { + int32_t ra_mdeg, dec_mdeg, fov_mdeg, roll_mdeg; /* the settings, thousandths of a degree */ + int32_t tan_half_q30; /* tan(fov / 2): half the width, in tangent-plane units */ + int32_t rot_q30[3][3]; /* rows: screen right, screen up, the view centre */ +} ck_sky_view; + +typedef struct { + int16_t x, y, z; /* the direction, Q15 */ + uint8_t mag; /* (V + 2) x 20 */ + uint8_t bv; /* palette index: B-V = -0.40 + 0.02 bv */ +} ck_sky_star; + +typedef struct { + uint16_t cols, rows; /* equirectangular grid: cols RA cols, rows Dec rows */ + uint16_t per_width; /* = cols (kept for renderer: samples per 360 deg RA) */ + int32_t row0_q16; /* unused (0); kept so the struct is unchanged */ +} ck_sky_map; + +typedef struct { + int16_t dir[3]; /* the centre, Q15 */ + int32_t a_q16, b_q16; /* half the long and short axes on screen, screen widths, Q16 */ + uint16_t angle; /* the long axis on screen, turns / 65536 from right towards down */ + uint32_t tint; /* its colour (from its B-V), sRGB */ +} ck_sky_galaxy; + +typedef struct { + uint16_t star; /* index into ck_sky_stars */ + int32_t x16, y16; /* where the generator puts it on 3840 x 2160, 16ths of a pixel */ +} ck_sky_check; + +extern const ck_sky_view ck_sky_the_view; +extern const ck_sky_star ck_sky_stars[]; +extern const unsigned ck_sky_nstars; +extern const uint32_t ck_sky_flux[256]; +extern const uint16_t ck_sky_palette[128][3]; +extern const uint16_t ck_sky_lin[256]; +extern const uint16_t ck_sky_srgb16[4096]; +extern const ck_sky_map ck_sky_milkyway; +extern const uint8_t ck_sky_luma[]; +extern const int8_t ck_sky_chroma[][2]; +extern const ck_sky_galaxy ck_sky_galaxies[]; +extern const unsigned ck_sky_ngalaxies; +extern const ck_sky_check ck_sky_checks[]; +extern const unsigned ck_sky_nchecks; +#endif diff --git a/om/allen-scene/native/sky_data.txt b/om/allen-scene/native/sky_data.txt new file mode 100644 index 0000000..1e595ca --- /dev/null +++ b/om/allen-scene/native/sky_data.txt @@ -0,0 +1,31 @@ +input bsc5: https://cdsarc.cds.unistra.fr/ftp/V/50/catalog.gz sha256 3dc44b1e90be8fbe5bcc7656032560f51275f985c7e3f783c9028e1838ec7bed +input gaia_hpx6.csv: https://gea.esac.esa.int/tap-server/tap/async ADQL (query in docs/ALLEN_SKY_SCIENCE.md) sha256 334bde2b6359747e2cc3d7f3db7bb3776d3273836215804249a4e9730935c80e +input gaia_dust.csv: https://gea.esac.esa.int/tap-server/tap/async ADQL (query in docs/ALLEN_SKY_SCIENCE.md) sha256 105f8f51de8cc473ff34fd8a0ffd455179c0d12f85de59165fafe9551f015e25 +input gaia_hpx7.csv: https://gea.esac.esa.int/tap-server/tap/async ADQL level 7, four HEALPix-range chunks joined, sha256 4d1412d3df02f6ee34120b8fd9b96bde6766fcaf50c569a94b45b72d4ec151cd +input gaia_dust7.csv: https://gea.esac.esa.int/tap-server/tap/async ADQL level 7, four HEALPix-range chunks joined, sha256 ce46146f06fa33791d81cde3f02f19a7ac259e5555b13c03cdb8092e75174d89 +input ngc: https://raw.githubusercontent.com/mattiaverga/OpenNGC/be3cd6c5498806a2fbb2f7e0452ef802dbb02be0/database_files/NGC.csv sha256 54abea0b57b0a103831bfc7a8e3a99a23acfbf4bb581fcf3d8af539cbb826c84 +input ngc_addendum: https://raw.githubusercontent.com/mattiaverga/OpenNGC/be3cd6c5498806a2fbb2f7e0452ef802dbb02be0/database_files/addendum.csv sha256 c93f983dda6780b76b7b2e9271a856a892627710148a982ee98101a54c642fdd +input gw150914: https://dcc.ligo.org/public/0157/P1800381/007/GW150914_skymap.fits.gz sha256 a8a4bdeb46aade1389e594e466ee6372a401157188df636eae2bbb3eab2805f2 +GW150914 sky map: HEALPix nside 512; most probable point RA 113.697 Dec -72.757 deg; 90% region 181.6 sq deg +view: gnomonic, centre RA 113.697 Dec -72.757 deg, 80.0 deg across the width, roll 0.0 deg, centre at 50% across and 40% down +3840x2160: the top-left corner is 42.6 deg from the centre, the bottom-right 45.4 deg +the centre in galactic coordinates: l 284.54 b -22.70 deg +of the GW150914 90% region, 100% of its pixels are on the 3840x2160 screen +catalogue: 9096 stars with positions; 310 have no B-V (drawn at B-V 0.6, close to the Sun's) +stars on the 3840x2160 screen by limit: V<=4.0: 71, V<=5.0: 179, V<=5.5: 332, V<=6.0: 560, V<=6.5: 904, V<=7.0: 954, V<=all: 959 +stars to V 6.5 in the whole sky: 8404 (8 bytes each: 67232 bytes); in this view with its margin: 1035 +colour: B-V -0.30 -> 16602 K -> sRGB (177, 198, 255) +colour: B-V 0.00 -> 10125 K -> sRGB (204, 217, 255) +colour: B-V 0.65 -> 5778 K -> sRGB (255, 241, 234) +colour: B-V 1.50 -> 3794 K -> sRGB (255, 207, 155) +display: a magnitude 6.5 star peaks at 0.060 linear (sRGB level 69); a magnitude 0 star holds 33.8 linear x design px; 1 S10 is 5.86e-06 linear per design px +Gaia DR3 Milky Way: 196608 HEALPix level-7 cells (nside 128), 196608 non-empty, 0 with no BP/RP colour (G kept as V); sky glow 0.00120 linear/design-px (V 22.0, physical, no gain) +cloud light NGC0224 Andromeda Galaxy: Gaia resolves V 6.53 of the catalogue's V 3.44 (5.8%), under 25%: not added +cloud light NGC0292 Small Magellanic Cloud: 55 Gaia cells in the 300x180 arcmin ellipse, local sky 42.2 S10 (median of 61 cells at 1.2-1.6 radii); Gaia resolves V 2.78 of the catalogue's V 2.30 (64%); the rest added in the Gaia stars' pattern (excess x 1.55); centre (inner fifth) V 21.64 -> 21.22 mag/arcsec2, 287 -> 422 S10 +cloud light ESO056-115 Large Magellanic Cloud: 372 Gaia cells in the 646x550 arcmin ellipse, local sky 48.7 S10 (median of 395 cells at 1.2-1.6 radii); Gaia resolves V 0.83 of the catalogue's V 0.29 (61%); the rest added in the Gaia stars' pattern (excess x 1.65); centre (inner fifth) V 21.58 -> 21.11 mag/arcsec2, 302 -> 466 S10 +Milky Way: brightest band 1111.1 S10 = V 20.17 mag/arcsec2 (Gaia flux in V, physical scale, no anchor; the published Bochum value is V 20.7, Leinert et al. 1998); 5.42 times the dark sky; gain 1.00 +galaxies on screen brighter than V 6.5 (OpenNGC): ESO056-115 Large Magellanic Cloud V 0.29 646x550 arcmin PA 170, NGC0292 Small Magellanic Cloud V 2.30 300x180 arcmin PA 45 +galaxy ESO056-115: on screen half axes 218.7 x 190.9 px at 3840 wide, long axis at 131.7 deg from right +galaxy NGC0292: on screen half axes 111.6 x 73.5 px at 3840 wide, long axis at 323.4 deg from right +tables: stars 8280 B, Milky Way luma 64980 B + colour 32580 B, other tables about 10496 B +made in 44 s diff --git a/om/allen-scene/native/sky_real.c b/om/allen-scene/native/sky_real.c new file mode 100644 index 0000000..8fc41a9 --- /dev/null +++ b/om/allen-scene/native/sky_real.c @@ -0,0 +1,401 @@ +/* sky_real.c -- the real sky: projection, stars, Milky Way from Gaia DR3, + * galaxies, and the sidereal time for "the sky above you now"; see sky_real.h. + * + * Light is added the way light adds: each star's light is put on in linear + * light (the sRGB curve undone, the light added, the curve put back), so a + * faint star on the Milky Way brightens it by as much as it would in the + * sky. + * + * The Milky Way grid (sky_data.c) is a full-sphere equirectangular map from + * Gaia DR3 source counts and integrated G-band flux, reddened by measured + * extinction; rendering inverse-projects each screen point to (RA, Dec) and + * bilinear-samples the grid. */ +#include "sky_real.h" + +/* ---- projection ---- */ + +int ck_sky_project(const ck_sky_view *v, const int16_t d[3], int32_t w, int32_t cx, int32_t cy, int32_t *x16, + int32_t *y16) +{ + int64_t a[3]; + for (int r = 0; r < 3; r++) + a[r] = (int64_t)v->rot_q30[r][0] * d[0] + (int64_t)v->rot_q30[r][1] * d[1] + (int64_t)v->rot_q30[r][2] * d[2]; + if (a[2] < (1ll << 40)) /* Q45: closer than 1/32 to edge-on, about 88 degrees from the centre */ + return 0; + int64_t z = a[2] >> 16; /* Q29 */ + int64_t u = a[0] * 16384 / z, t = a[1] * 16384 / z; /* tangent-plane x and y, Q30 */ + int64_t s = (int64_t)w * 8; /* 16ths of a pixel per half width */ + *x16 = cx * 16 + (int32_t)(u * s / v->tan_half_q30); + *y16 = cy * 16 - (int32_t)(t * s / v->tan_half_q30); + return 1; +} + +/* ---- Milky Way: equirectangular full-sphere grid, bilinear sampling ---- */ + +static int32_t bilinear_u8(const uint8_t *p, int32_t cols, int32_t rows, int64_t c, int64_t r) /* x 256 */ +{ + c = c < 0 ? 0 : c > (int64_t)(cols - 1) << 16 ? (int64_t)(cols - 1) << 16 : c; + r = r < 0 ? 0 : r > (int64_t)(rows - 1) << 16 ? (int64_t)(rows - 1) << 16 : r; + int32_t i = (int32_t)(c >> 16), j = (int32_t)(r >> 16), i1 = ck_min(i + 1, cols - 1), j1 = ck_min(j + 1, rows - 1); + int32_t fx = (int32_t)(c >> 8 & 255), fy = (int32_t)(r >> 8 & 255); + int32_t a = p[j * cols + i] * (256 - fx) + p[j * cols + i1] * fx; + int32_t b = p[j1 * cols + i] * (256 - fx) + p[j1 * cols + i1] * fx; + return (a * (256 - fy) + b * fy) >> 8; +} + +static int32_t bilinear_s8(const int8_t (*p)[2], int k, int32_t cols, int32_t rows, int64_t c, int64_t r) /* x 256 */ +{ + c = c < 0 ? 0 : c > (int64_t)(cols - 1) << 16 ? (int64_t)(cols - 1) << 16 : c; + r = r < 0 ? 0 : r > (int64_t)(rows - 1) << 16 ? (int64_t)(rows - 1) << 16 : r; + int32_t i = (int32_t)(c >> 16), j = (int32_t)(r >> 16), i1 = ck_min(i + 1, cols - 1), j1 = ck_min(j + 1, rows - 1); + int32_t fx = (int32_t)(c >> 8 & 255), fy = (int32_t)(r >> 8 & 255); + int32_t a = p[j * cols + i][k] * (256 - fx) + p[j * cols + i1][k] * fx; + int32_t b = p[j1 * cols + i][k] * (256 - fx) + p[j1 * cols + i1][k] * fx; + return (a * (256 - fy) + b * fy) >> 8; +} + +/* Inverse-project a half-pixel screen point to equirectangular grid coords. + * (x2, y2) in half-pixels; screen centre at (2*cx, 2*cy). + * Returns (col_q16, row_q16) for bilinear_u8/s8. The map covers the full + * sphere: col 0 = RA 0 deg, col cols-1 = RA ~360 deg; row 0 = Dec +90, + * row rows-1 = Dec -90. col wraps; row is clamped. + * Returns 0 if the point is behind the camera. */ +static int grid_at_eq(const ck_sky_view *v, int32_t x2, int32_t y2, int32_t w, int32_t cx, int32_t cy, + int64_t *col, int64_t *row) +{ + const ck_sky_map *m = &ck_sky_milkyway; + + /* Tangent-plane offset from the view centre, Q30. The forward projection (ck_sky_project) puts a + * tangent-plane offset u at (u / tan_half) half-widths, i.e. (u / tan_half) * w / 2 pixels, so the + * inverse is u = px * 2 * tan_half / w with px = half-pixels / 2: u = half_px * tan_half / w. */ + int64_t u = (int64_t)(x2 - 2 * cx) * (int64_t)v->tan_half_q30 / (int64_t)w; + int64_t vv = (int64_t)(2 * cy - y2) * (int64_t)v->tan_half_q30 / (int64_t)w; + + /* Unnormalised sky direction in J2000 frame, ~Q30 */ + int64_t dx = (int64_t)v->rot_q30[2][0] + ((int64_t)v->rot_q30[0][0] * u >> 30) + ((int64_t)v->rot_q30[1][0] * vv >> 30); + int64_t dy = (int64_t)v->rot_q30[2][1] + ((int64_t)v->rot_q30[0][1] * u >> 30) + ((int64_t)v->rot_q30[1][1] * vv >> 30); + int64_t dz = (int64_t)v->rot_q30[2][2] + ((int64_t)v->rot_q30[0][2] * u >> 30) + ((int64_t)v->rot_q30[1][2] * vv >> 30); + + /* Reject behind-camera directions (dz Q30 < 0 is not enough; check full forward component) */ + if ((int64_t)v->rot_q30[2][0] * dx + (int64_t)v->rot_q30[2][1] * dy + (int64_t)v->rot_q30[2][2] * dz < (1ll << 40)) + return 0; + + /* RA: atan2(dy, dx) as turns [0,65536) */ + uint32_t ra_turn = ck_atan2((int32_t)(dy >> 8), (int32_t)(dx >> 8)); + /* col_q16: ra_turn * cols (since ra_turn / 65536 = RA fraction, col = fraction * cols * 65536 = ra_turn * cols) */ + *col = (int64_t)ra_turn * m->cols; + + /* row: equirectangular Dec spacing (1 deg/row); use ck_atan2 for correct + * linear-in-Dec rows. Dec turn: ck_atan2(dz, h_flat) where h_flat is the + * horizontal magnitude. Dec=+90 → turn 16384, Dec=-90 → turn 49152. */ + int32_t dx15 = (int32_t)(dx >> 15), dy15 = (int32_t)(dy >> 15), dz15 = (int32_t)(dz >> 15); + uint32_t h15 = ck_isqrt((uint64_t)((int64_t)dx15 * dx15 + (int64_t)dy15 * dy15)); + int32_t dec_turn = (int32_t)ck_atan2(dz15, (int32_t)h15); /* turns [0,65536) */ + /* signed: > 32768 means south of equator */ + int32_t dec_turn_s = dec_turn > 32768 ? dec_turn - 65536 : dec_turn; + /* row 0 = Dec +90 (dec_turn_s=16384), row rows = Dec -90 (dec_turn_s=-16384) + * row_q16 = (16384 - dec_turn_s) * rows * 2 */ + *row = (int64_t)(16384 - dec_turn_s) * (int64_t)m->rows * 2; + return 1; +} + +/* The equirectangular Milky Way at half-pixel (x2, y2) through view v: + * three channels in 16ths of a level */ +static void milkyway_at(const ck_sky_view *v, int32_t x2, int32_t y2, int32_t w, int32_t cx, int32_t cy, + int32_t rgb[3]) +{ + const ck_sky_map *m = &ck_sky_milkyway; + int64_t col, row; + if (!grid_at_eq(v, x2, y2, w, cx, cy, &col, &row)) { + rgb[0] = rgb[1] = rgb[2] = 0; + return; + } + /* Wrap col in RA */ + int64_t maxcol = (int64_t)m->cols * 65536; + while (col < 0) col += maxcol; + while (col >= maxcol) col -= maxcol; + /* Colour grid is at half resolution */ + int32_t hc = (m->cols + 1) / 2, hr = (m->rows + 1) / 2; + int32_t y = bilinear_u8(ck_sky_luma, m->cols, m->rows, col, row) >> 4; /* 16ths */ + int64_t cc = (col - 32768) / 2, cr = (row - 32768) / 2; /* colour: half spacing */ + if (cc < 0) cc += (int64_t)hc * 65536; + int32_t co = bilinear_s8(ck_sky_chroma, 0, hc, hr, cc, cr) >> 5; /* 16ths */ + int32_t cg = bilinear_s8(ck_sky_chroma, 1, hc, hr, cc, cr) >> 5; + rgb[0] = ck_clamp(y + co - cg, 0, 4080); + rgb[1] = ck_clamp(y + cg, 0, 4080); + rgb[2] = ck_clamp(y - co - cg, 0, 4080); +} + +void ck_sky_milkyway_q(uint16_t *q, int32_t qw, int32_t qh, int32_t w, int32_t cx, int32_t cy, + const ck_sky_view *v) +{ + for (int32_t j = 0; j < qh; j++) + for (int32_t i = 0; i < qw; i++) { + int32_t rgb[3]; + milkyway_at(v, 8 * i + 1, 8 * j + 1, w, cx, cy, rgb); + uint16_t *c = q + ((size_t)j * (size_t)qw + (size_t)i) * 3; + c[0] = (uint16_t)rgb[0], c[1] = (uint16_t)rgb[1], c[2] = (uint16_t)rgb[2]; + } +} + +/* ---- stars ---- */ + +/* adds light round (x16, y16): radius r16, centre light peak (linear, Q16), colour col (linear, 4096 the + * brightest channel); the light falls off as (1 - d^2 / r^2)^3 */ +static void light_add(ck_canvas *cv, int32_t x16, int32_t y16, int32_t r16, uint64_t peak, const uint16_t col[3]) +{ + if (r16 < 4 || peak < 4) + return; + int32_t x0 = ck_max(0, (x16 - r16) >> 4), x1 = ck_min(cv->w - 1, (x16 + r16) >> 4); + int32_t y0 = ck_max(0, (y16 - r16) >> 4), y1 = ck_min(cv->h - 1, (y16 + r16) >> 4); + int64_t r2 = (int64_t)r16 * r16; + uint64_t inv = (1ull << 40) / (uint64_t)r2; + uint64_t pc[3]; + for (int k = 0; k < 3; k++) + pc[k] = peak * col[k] >> 13; /* Q15 linear at the centre, per channel */ + for (int32_t y = y0; y <= y1; y++) { + int64_t dy = (int64_t)y * 16 + 8 - y16; + uint32_t *row = cv->px + (size_t)y * (size_t)cv->w; + for (int32_t x = x0; x <= x1; x++) { + int64_t dx = (int64_t)x * 16 + 8 - x16, d2 = dx * dx + dy * dy; + if (d2 >= r2) + continue; + uint64_t f = 65536u - ((uint64_t)d2 * inv >> 24); /* Q16 */ + uint64_t f3 = ((f * f >> 16) * f) >> 16; /* Q16 */ + uint32_t c = row[x], out = 0; + int any = 0; + for (int k = 0; k < 3; k++) { + uint32_t lv = c >> (16 - 8 * k) & 255u; + uint64_t add = pc[k] * f3 >> 16; + if (add) { + uint64_t l = ck_sky_lin[lv] + add; + lv = (ck_sky_srgb16[l >= 32767 ? 4095 : l >> 3] + 8) >> 4; + lv = lv > 255 ? 255 : lv; + any = 1; + } + out = out << 8 | lv; + } + if (any) + row[x] = (c & 0xff000000u) | out; + } + } +} + +static uint32_t srgb_of(const uint16_t col[3]) +{ + uint32_t c = 0; + for (int k = 0; k < 3; k++) { + uint32_t i = col[k] >= 4096 ? 4095 : col[k]; + c = c << 8 | ((ck_sky_srgb16[i] + 8) >> 4); + } + return c; +} + +void ck_sky_draw_stars(ck_canvas *cv, uint32_t k, int32_t cx, int32_t cy, const ck_sky_view *v, + ck_night_star *tw, unsigned max, unsigned *ntw) +{ + int32_t r0 = (int32_t)(k * 3 / 40); /* 16ths of a pixel: 1.2 design px */ + if (r0 < 12) + r0 = 12; + /* the core grows with the scale and its middle keeps its light, so a star's total light grows as the + * square of the scale and it looks the same on any screen */ + *ntw = 0; + for (unsigned i = 0; i < ck_sky_nstars; i++) { + const ck_sky_star *s = &ck_sky_stars[i]; + int16_t d[3] = {s->x, s->y, s->z}; + int32_t x16, y16; + if (!ck_sky_project(v, d, cv->w, cx, cy, &x16, &y16)) + continue; + int32_t reach = r0 * 12; + if (x16 < -reach || y16 < -reach || x16 > cv->w * 16 + reach || y16 > cv->h * 16 + reach) + continue; + const uint16_t *col = ck_sky_palette[s->bv < 128 ? s->bv : 127]; + uint64_t core = ck_sky_flux[s->mag]; /* the light at the middle of the core */ + light_add(cv, x16, y16, r0, core, col); + light_add(cv, x16, y16, r0 * 4, (core * 15) >> 7, col); + light_add(cv, x16, y16, r0 * 12, (core * 5) >> 7, col); + if (s->mag <= 59 && *ntw < max) { /* V <= 1.0: bright enough to twinkle */ + tw[*ntw].x = x16, tw[*ntw].y = y16, tw[*ntw].r = r0 * 4; + tw[*ntw].color = srgb_of(col); + tw[*ntw].period = (uint16_t)(1200 + (i * 137) % 2400); + tw[*ntw].phase = (uint16_t)((i * 919) % 65536); + (*ntw)++; + } + } +} + +/* ---- galaxies ---- */ + +ck_rect ck_sky_galaxy_bound(uint32_t w, unsigned i) +{ + if (i >= ck_sky_ngalaxies) + return (ck_rect){0, 0, 0, 0}; + const ck_sky_galaxy *g = &ck_sky_galaxies[i]; + /* the bound uses the default view; galaxies only draw near their canonical position */ + int32_t a = (int32_t)((int64_t)g->a_q16 * (int32_t)w >> 16) + 4; + return (ck_rect){0, 0, a * 2 + 1, a * 2 + 1}; +} + +int ck_sky_galaxy_in_view(uint32_t w, uint32_t h, int32_t cx, int32_t cy, const ck_sky_view *v, unsigned i, + int32_t *gx, int32_t *gy) +{ + if (i >= ck_sky_ngalaxies) + return 0; + int32_t x16, y16; + if (!ck_sky_project(v, ck_sky_galaxies[i].dir, (int32_t)w, cx, cy, &x16, &y16)) + return 0; + *gx = (x16 + 8) >> 4; + *gy = (y16 + 8) >> 4; + return *gx >= 0 && *gx < (int32_t)w && *gy >= 0 && *gy < (int32_t)h; +} + +ck_rect ck_sky_galaxy_box(uint32_t w, uint32_t h, int32_t cx, int32_t cy, const ck_sky_view *v, unsigned i) +{ + int32_t gx, gy; + if (!ck_sky_galaxy_in_view(w, h, cx, cy, v, i, &gx, &gy)) + return (ck_rect){0, 0, 0, 0}; + const ck_sky_galaxy *g = &ck_sky_galaxies[i]; + int32_t a = (int32_t)((int64_t)g->a_q16 * (int32_t)w >> 16) + 4; + int32_t x0 = ck_max(0, gx - a), y0 = ck_max(0, gy - a); + int32_t x1 = ck_min((int32_t)w - 1, gx + a), y1 = ck_min((int32_t)h - 1, gy + a); + if (x0 >= x1 || y0 >= y1) + return (ck_rect){0, 0, 0, 0}; + return (ck_rect){x0, y0, x1 - x0, y1 - y0}; +} + +void ck_sky_galaxy_maps(ck_night_galaxy *g, unsigned i, uint32_t w, int32_t cx, int32_t cy, + const ck_sky_view *v) +{ + if (i >= ck_sky_ngalaxies || g->box.w == 0) + return; + int32_t gx, gy; + if (!ck_sky_galaxy_in_view(w, 0x7fffffff, cx, cy, v, i, &gx, &gy)) + return; + const ck_sky_galaxy *gal = &ck_sky_galaxies[i]; + int32_t a = (int32_t)((int64_t)gal->a_q16 * (int32_t)w >> 16); + int32_t b = (int32_t)((int64_t)gal->b_q16 * (int32_t)w >> 16) + 1; + int32_t ca = (int32_t)ck_cos(gal->angle), sa = (int32_t)ck_sin(gal->angle); + g->tint = gal->tint; + g->period = (uint16_t)(2400 + i * 400); + for (int32_t py = 0; py < g->box.h; py++) + for (int32_t px = 0; px < g->box.w; px++) { + int32_t dx = (g->box.x + px) - gx, dy = (g->box.y + py) - gy; + int32_t u = (dx * ca + dy * sa) >> 14; /* along the long axis */ + int32_t vv = (-dx * sa + dy * ca) >> 14; /* along the short */ + size_t off = (size_t)py * (size_t)g->box.w + (size_t)px; + if (a == 0 || b == 0 || (int64_t)u * u * b * b + (int64_t)vv * vv * a * a > (int64_t)a * a * b * b) { + g->light[off] = 0; + g->phase[off] = 128; + continue; + } + /* light falls off as (1 - (u/a)^2 - (v/b)^2)^2 */ + int64_t f = 65536 - (int64_t)u * u * 65536 / (a * a) - (int64_t)vv * vv * 65536 / (b * b); + if (f < 0) f = 0; + g->light[off] = (uint8_t)((f * f >> 16) * 255 >> 16); + g->phase[off] = (uint8_t)((u + a) * 255 / (2 * a + 1)); + } +} + +/* ---- the sky above you now: sidereal time, the zenith, precession ---- */ + +#define J2000_UNIX 946728000ll /* 2000 January 1, 12:00 UT */ + +uint32_t ck_sky_gmst(int64_t t) +{ + /* GMST = 18.697374558 h + 24.06570982441908 h x D, D days from J2000 (USNO; Aoki et al. 1982), + * here in turns x 2^48: 0.7790572732 + 1.0027379093508 D */ + int64_t s = t - J2000_UNIX, days = s / 86400, rem = s % 86400; + if (rem < 0) + rem += 86400, days -= 1; + uint64_t turns = 219285127830237ull + (uint64_t)days * 770652970752ull + (uint64_t)rem * 3266731825ull; + return (uint32_t)(turns >> 16); +} + +/* (cos, sin) of a small angle a (radians, Q30), Q30 */ +static void small_cs(int64_t a, int64_t *c, int64_t *s) +{ + int64_t a2 = a * a >> 30; + *c = (1ll << 30) - a2 / 2 + (a2 * a2 >> 30) / 24; + *s = a - (a2 * a >> 30) / 6; +} + +static void rot_z(int64_t v[3], int64_t a) /* frame turned by a about z */ +{ + int64_t c, s; + small_cs(a, &c, &s); + int64_t x = (v[0] * c + v[1] * s) >> 30, y = (v[1] * c - v[0] * s) >> 30; + v[0] = x, v[1] = y; +} + +static void rot_y(int64_t v[3], int64_t a) /* frame turned by a about y */ +{ + int64_t c, s; + small_cs(a, &c, &s); + int64_t x = (v[0] * c - v[2] * s) >> 30, z = (v[0] * s + v[2] * c) >> 30; + v[0] = x, v[2] = z; +} + +/* sin and cos of a in millionths of a degree, Q30, from the Q14 table refined by one Newton-like step */ +static void cs_udeg(int64_t a_udeg, int64_t *c, int64_t *s) +{ + a_udeg %= 360000000ll; + if (a_udeg < 0) + a_udeg += 360000000ll; + uint32_t turn = (uint32_t)(a_udeg * 65536 / 360000000ll); + /* the remainder past the table's step, radians Q30: (a - turn) x 2 pi / 360e6 */ + int64_t rest = a_udeg - (int64_t)turn * 360000000ll / 65536; + int64_t e = rest * 18740 / 1000; /* 2 pi / 360e6 x 2^30 = 18.740 */ + int64_t c0 = (int64_t)ck_cos(turn) * 65536, s0 = (int64_t)ck_sin(turn) * 65536; + *c = c0 - (s0 * e >> 30); + *s = s0 + (c0 * e >> 30); +} + +void ck_sky_zenith(int64_t t, int32_t lat_udeg, int32_t lon_udeg, int16_t d[3], int32_t *ra_udeg, + int32_t *dec_udeg) +{ + /* straight up: right ascension the local sidereal time, declination the latitude (of the date) */ + int64_t lst = (int64_t)((uint64_t)ck_sky_gmst(t) * 360000000ull >> 32) + lon_udeg; + int64_t ca, sa, cd, sd; + cs_udeg(lst, &ca, &sa); + cs_udeg(lat_udeg, &cd, &sd); + int64_t v[3] = {cd * ca >> 30, cd * sa >> 30, sd}; + /* back from the equator of the date to J2000 (Lieske et al. 1977, IAU 1976): + * v_J2000 = R3(zeta) R2(-theta) R3(z) v_date; the angles in radians Q40 per century */ + int64_t T = (t - J2000_UNIX) * (1ll << 30) / (36525ll * 86400); /* centuries, Q30 */ + int64_t T2 = T * T >> 30; + int64_t zeta = (12293486530ll * T + 1609196ll * T2) >> 40; /* 2306.2181" T + 0.30188" T^2, Q30 rad */ + int64_t zz = (12293486530ll * T + 5835282ll * T2) >> 40; /* 2306.2181" T + 1.09468" T^2 */ + int64_t th = (10684145203ll * T - 2274293ll * T2) >> 40; /* 2004.3109" T - 0.42665" T^2 */ + rot_z(v, zz); + rot_y(v, -th); + rot_z(v, zeta); + for (int k = 0; k < 3; k++) + d[k] = (int16_t)ck_clamp((int32_t)(v[k] >> 15), -32767, 32767); + if (ra_udeg) { + uint32_t ra = ck_atan2((int32_t)(v[1] >> 8), (int32_t)(v[0] >> 8)); + *ra_udeg = (int32_t)((int64_t)ra * 360000000ll / 65536); + } + if (dec_udeg) { + int64_t h = (int64_t)ck_isqrt((uint64_t)((v[0] >> 8) * (v[0] >> 8) + (v[1] >> 8) * (v[1] >> 8))); + uint32_t de = ck_atan2((int32_t)(v[2] >> 8), (int32_t)h); + *dec_udeg = (int32_t)((int64_t)(int16_t)de * 360000000ll / 65536); + } +} + +void ck_sky_view_at(ck_sky_view *v, int32_t ra_udeg, int32_t dec_udeg, int32_t fov_mdeg, int32_t roll_mdeg) +{ + int64_t ca, sa, cd, sd, cr, sr, ch, sh; + cs_udeg(ra_udeg, &ca, &sa); + cs_udeg(dec_udeg, &cd, &sd); + cs_udeg((int64_t)roll_mdeg * 1000, &cr, &sr); + cs_udeg((int64_t)fov_mdeg * 500, &ch, &sh); + int64_t west[3] = {sa, -ca, 0}, north[3] = {-(sd * ca >> 30), -(sd * sa >> 30), cd}; + int64_t fwd[3] = {cd * ca >> 30, cd * sa >> 30, sd}; + for (int k = 0; k < 3; k++) { + v->rot_q30[0][k] = (int32_t)((cr * west[k] + sr * north[k]) >> 30); + v->rot_q30[1][k] = (int32_t)((cr * north[k] - sr * west[k]) >> 30); + v->rot_q30[2][k] = (int32_t)fwd[k]; + } + v->tan_half_q30 = (int32_t)((sh << 30) / ch); + v->ra_mdeg = ra_udeg / 1000, v->dec_mdeg = dec_udeg / 1000, v->fov_mdeg = fov_mdeg, v->roll_mdeg = roll_mdeg; +} \ No newline at end of file diff --git a/om/allen-scene/native/sky_real.h b/om/allen-scene/native/sky_real.h new file mode 100644 index 0000000..b93156c --- /dev/null +++ b/om/allen-scene/native/sky_real.h @@ -0,0 +1,76 @@ +/* sky_real.h -- the real sky behind Allen: the catalogue's stars at their + * true places, brightness and colour; the Milky Way from Gaia DR3 source + * counts and integrated G-band flux (ESA/Gaia/DPAC, CC BY-NC 3.0 IGO), + * reddened by extinction from gaiadr3.astrophysical_parameters; the + * galaxies the eye can see. The data are in sky_data.c (generated, see + * sky_data.h); this is the drawing, integer only. + * + * The view: a gnomonic projection (what a pinhole camera sees) of any piece + * of sky, the view centre at (cx, cy) on the screen, a set width of sky + * across the screen's width. + * + * The Milky Way is stored as a full-sphere equirectangular grid; rendering + * inverse-projects each screen point to (RA, Dec) and bilinear-samples the + * grid, so any view can be shown. + * + * Also here: the sidereal-time maths for "the sky above you now". */ +#ifndef AIENOS_SKY_REAL_H +#define AIENOS_SKY_REAL_H +#include + +#include "night.h" +#include "sky_data.h" + +/* Where the direction d (Q15) lands on a screen w px wide whose view + * centre is at (cx, cy) px: (x16, y16) in 16ths of a pixel, the pixel i + * spanning 16 i to 16 i + 16. 0 if it is more than 88 degrees from the + * centre (behind the camera), else 1. */ +int ck_sky_project(const ck_sky_view *v, const int16_t d[3], int32_t w, int32_t cx, int32_t cy, int32_t *x16, + int32_t *y16); + +/* The Milky Way's light at a quarter of the resolution: q holds qw x qh + * cells of three channels in 16ths of a level, cell (i, j) for the pixel + * (4 i, 4 j) of a w-wide screen with its view centre at (cx, cy). + * v: the current sky view (inverse-projects each screen point to RA/Dec). */ +void ck_sky_milkyway_q(uint16_t *q, int32_t qw, int32_t qh, int32_t w, int32_t cx, int32_t cy, + const ck_sky_view *v); + +/* Draws every catalogue star in the view into cv (a w x h sky whose view + * centre is at (cx, cy); k: 1/256 px per design px of a 1920-wide design), + * using view v, adding its light to what is there. The brightest few (V 2.0 + * and brighter) are also listed in tw, up to max, to twinkle; *ntw: count. */ +void ck_sky_draw_stars(ck_canvas *cv, uint32_t k, int32_t cx, int32_t cy, const ck_sky_view *v, + ck_night_star *tw, unsigned max, unsigned *ntw); + +/* The largest box galaxy i can need on a w-wide screen (for memory). */ +ck_rect ck_sky_galaxy_bound(uint32_t w, unsigned i); +/* Galaxy i's box on a w x h screen, view v, centre (cx, cy) (clipped; empty + * if not in the view or no galaxy i). */ +ck_rect ck_sky_galaxy_box(uint32_t w, uint32_t h, int32_t cx, int32_t cy, const ck_sky_view *v, unsigned i); +/* Fills g->light and g->phase over g->box. */ +void ck_sky_galaxy_maps(ck_night_galaxy *g, unsigned i, uint32_t w, int32_t cx, int32_t cy, + const ck_sky_view *v); + +/* ---- the sky above you now ---- */ + +/* Greenwich mean sidereal time at unix time t (seconds, UTC taken as UT1: + * within a second), in turns / 2^32. IAU 1982 (Aoki et al. 1982; USNO). */ +uint32_t ck_sky_gmst(int64_t unix_s); +/* The direction straight up (the zenith) at unix time t from latitude lat + * and east longitude lon (millionths of a degree), in J2000 axes (the + * local sidereal time, then the 1976 IAU precession back to J2000), Q15. + * As RA and Dec in millionths of a degree too, if ra or dec are given. */ +void ck_sky_zenith(int64_t unix_s, int32_t lat_udeg, int32_t lon_udeg, int16_t d[3], int32_t *ra_udeg, + int32_t *dec_udeg); +/* A view centred on (ra, dec) (millionths of a degree), fov degrees wide + * (thousandths), north up turned by roll (thousandths), built with integer + * trigonometry. */ +void ck_sky_view_at(ck_sky_view *v, int32_t ra_udeg, int32_t dec_udeg, int32_t fov_mdeg, int32_t roll_mdeg); + +/* the location setting: unset unless the build sets both (millionths of a degree) */ +#if defined(CK_SKY_LAT_UDEG) && defined(CK_SKY_LON_UDEG) +#define CK_SKY_HAVE_LOCATION 1 +#else +#define CK_SKY_HAVE_LOCATION 0 +#endif +#endif diff --git a/om/allen-scene/oracle-ui.c b/om/allen-scene/oracle-ui.c new file mode 100644 index 0000000..5f05254 --- /dev/null +++ b/om/allen-scene/oracle-ui.c @@ -0,0 +1,29 @@ +/* Independent host reference: include the ORIGINAL pinned allen_ui.c via -I. + * Never link adapter.c here. Public tick/start/sleep APIs own frame history. + * No wake/conversation is injected: the source's bar/panes remain hidden. + */ +#include +#include +#include "allen_ui.c" +int main(int argc,char **argv) +{ + if(argc!=3) return 2; + unsigned kind=(unsigned)strtoul(argv[1],0,10),target=(unsigned)strtoul(argv[2],0,10); + const unsigned w=640,h=400; + uint32_t *fb=calloc((size_t)w*h,4); + size_t bytes=ck_allen_ui_mem_bytes(w,h); + void *mem=calloc(1,bytes); + if(!fb || !mem || ck_allen_ui_start(fb,w,h,w,0,mem,bytes,1000000,0,0)) return 3; + unsigned end=kind==1?20000:target; + for(unsigned t=0;t<=end;t+=16) ck_allen_ui_tick((uint64_t)t*1000); + ck_allen_ui_refresh();ck_allen_ui_tick((uint64_t)end*1000); + if(kind==1) { + ck_allen_ui_sleep(1,20000000); + for(unsigned d=0;d<=target;d+=16) ck_allen_ui_tick((uint64_t)(20016+d)*1000); + ck_allen_ui_refresh();ck_allen_ui_tick((uint64_t)(20016+target)*1000); + } + /* Native framebuffer RGBX leaves X zero; browser RGBA requires opaque A. */ + for(size_t i=0;i<(size_t)w*h;i++) fb[i]|=0xff000000u; + int result=fwrite(fb,4,(size_t)w*h,stdout)==(size_t)w*h?0:4; + free(mem);free(fb);return result; +} diff --git a/om/allen-scene/oracle.c b/om/allen-scene/oracle.c new file mode 100644 index 0000000..59e3dfe --- /dev/null +++ b/om/allen-scene/oracle.c @@ -0,0 +1,39 @@ +/* Host-only read-only oracle driver; never shipped as a browser dependency. + * Link adapter.c against the exact original native pin, not a replacement renderer. + */ +#include +#include +#include +#include +int scene_init(uint32_t,uint32_t,uint32_t); +uintptr_t scene_pixels(void); +void scene_enter(uint32_t); +void scene_step(uint32_t,uint32_t,uint32_t); +void scene_draw(uint32_t,uint32_t); +void scene_key(uint32_t); +void scene_word(uint32_t); +void scene_glyph(uint32_t,int32_t,int32_t,uint32_t); +int scene_view(int32_t,int32_t,int32_t); +uintptr_t scene_audio(uint32_t,uint32_t); +int main(int argc,char **argv) +{ + if(argc==2 && !strcmp(argv[1],"audio")) { + uintptr_t p=scene_audio(11360*48,45120); + return p && fwrite((void*)p,4,45120,stdout)==45120?0:2; + } + if(argc!=5) return 3; + uint32_t kind=(uint32_t)strtoul(argv[1],0,10),target=(uint32_t)strtoul(argv[2],0,10); + uint32_t compact=(uint32_t)strtoul(argv[3],0,10),variant=(uint32_t)strtoul(argv[4],0,10); + if(!scene_init(640,400,compact)) return 4; + scene_enter(kind); + if(variant==2 && !scene_view(119000000,-71000000,60000)) return 5; + for(uint32_t t=0;t<=target;t+=16) { + if(variant==1 && t==16000) scene_key(t); + if(variant==1 && t==17008) scene_word(t); + scene_step(t,variant==1?(t<16000?0:t<17008?1:3):0,variant==1?128:0); + } + scene_step(target,variant==1?3:0,variant==1?128:0); + scene_draw(variant==1?256:0,variant==1?128:0); + if(variant==1) scene_glyph('A',300,300,200); + return fwrite((void*)scene_pixels(),4,640*400,stdout)==640*400?0:6; +} diff --git a/om/allen-scene/provenance.txt b/om/allen-scene/provenance.txt new file mode 100644 index 0000000..55ee97b --- /dev/null +++ b/om/allen-scene/provenance.txt @@ -0,0 +1,126 @@ +Allen scene source boundary + +Selected reference: aien-dev/aienux commit da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c. +https://github.com/aien-dev/aienux/tree/da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c/native/kernel/ui + +native/ contains unchanged copies of mind, night, paint, flow, sky_real, +sky_data, allen_font and chirp sources/headers. native.sha256 binds their bytes. +The selected scene was built and staged. Available historical physical-machine +reports do not establish that this source revision was booted on the iMac. +The selection follows the operator's current description of the galaxy/tube +experience. Do not promote a source match to physical deployment evidence. + +Code licence: at da55660 the aienux tree is AGPL-3.0-or-later (relicensed by +Drake in aienux 79456d09; the Apache-2.0 relicence f45d00ad landed later and +does not contain native/kernel/ui). The copied native/ sources and the +scene.wasm built from them therefore stay AGPL-3.0-or-later, not this +repository's Apache-2.0 WITH LLVM-exception. The page links the exact source +tree for network users. Relicensing these files is Drake's decision. + +The browser controller is authored in scene.om and emitted by the pinned +om/hive-page/omc (sha256 recorded in that directory). The renderer is NOT an +Omega renderer: it temporarily reuses the native C implementation, with explicit +operator authorization, as self-contained wasm32. adapter.c only owns the web +entry/lifecycle/framebuffer boundary and copied allen_ui.c flash/horizon laws. +There are no WASM imports, syscalls, third-party scripts, fonts or network +services in the renderer. It loads only /allen/scene.wasm from this origin. + +Build dependency: Ubuntu clang and wasm-ld 18.1.3 (1ubuntu1), package version +1:18.1.3-1ubuntu1; -nostdlib -ffreestanding wasm32. No compiler/library is loaded +by the web page. check.sh refuses other compiler versions and uses the existing +pinned Omega compiler for the browser controller. The replacement is a genuine +seeded Omega implementation of these scene units through irwasm, accepted only +after the same native frame/audio oracle. Successor: aien-dev/omega-mv draft +PR 811 (head 148b39c80, ck_glow ported to seeded Omega; native full-buffer +parity with the original C exercised there; its WASM memory backend is +NOT_RUN and waits on the wire spec in PR 809). The rest of the scene remains C. +No completed migration is claimed by this change. + +Scene identity and deliberate web changes +- Native mind: 120 points, 300 edge capacity, 64 sparks; exact fixed-point home + lattice, nearest-neighbor graph, glow/thread/pulse functions and mode timing. +- Native sky: Yale Bright Star Catalogue V/50 positions moved to epoch 2026.8, + Gaia DR3 integrated-light/extinction grid, OpenNGC Magellanic Cloud records, + canonical GW150914 direction. No invented replacement stars or backdrop. +- Native default view is copied exactly, not regenerated from rounded angles. + Exploration uses the native sky camera; the supplied star table covers the + canonical view and its margin, NOT all catalogue stars across the whole sky. + The Gaia grid covers the full sphere. Do not claim all-sky stellar completeness. +- Full render keeps native centre (half width, 40 percent height), scale and + native fluid. Browser resolution is bounded and composited to the CSS size; + this is not a claim of physical iMac-resolution pixel equality. +- Compact uses a native-scale crop centred in the icon, no full-screen fluid. +- The WEB opening reuses the native dusk accretion-tube law (4200 ms), then + native-duration dawn (900 ms) and mind formation. This is a web-specific + ordering. enter('birth') replays the original two-hole boot and merger. + Its kept picture is the complete original unwoken scene at 20000 ms: formed + mind and sky, with the native bar hidden and fluid asleep. It does not pull + browser DOM panes or arbitrary website content into the tube. +- Flowing input glyphs, pointer/keyboard sky exploration, visibility pause, + reduced-motion static state, responsive sizing and adaptive frame quality are + deliberate web additions. +- Pane/UI text and input belong to the page, not this renderer. Native system + hooks, microphone, model calls, identity/memory and telemetry are not copied. + +Data attribution (not relicensed by this repository) +Stars: Yale Bright Star Catalogue, 5th revised ed., Hoffleit & Warren 1991, +CDS V/50. Credit the catalogue authors. +Gaia: ESA/Gaia/DPAC, CC BY-NC 3.0 IGO, including source counts, integrated +G-band flux and astrophysical_parameters extinction data. +OpenNGC: Mattia Verga, CC BY-SA 4.0. +GW150914 sky map: LIGO/Virgo GWTC-1, LIGO-P1800381-v7. +Input URLs/digests and generation settings remain in native/sky_data.txt and +native/sky_data.c. Preserve the data-specific terms and attribution on publication. + +Mathematical translation checks (not measurements) +WolframLanguageEvaluator: (256-(256 t)^2/256)^2/256/256 -> (-1+t^2)^2. +WolframLanguageEvaluator: (256 t)^2 (768-2 (256 t))/65536/256 -> (3-2 t)t^2. +WolframLanguageEvaluator: Log[2,(r^2+f)/r^2]/2-Log[2,Sqrt[r^2+f]/r] +with r>0,f>=0 -> 0. The native integer law remains authoritative. +WolframLanguageEvaluator: 1000/60 -> 50/3 ms frame budget; (1000/60)/2 -> 25/3 ms +recovery threshold; 1280*{1,3/4,9/16} -> {1280,960,720} render bounds. +These are scheduling policies, not device measurements. +WolframLanguageEvaluator: 48000 (12300-11360)/1000 -> 45120 audio frames. + +Generation: nice -n 19 ionice -c3 sh om/allen-scene/check.sh --generate +Determinism/artifact check: nice -n 19 ionice -c3 sh om/allen-scene/check.sh +Independent oracle: set ALLEN_NATIVE_SOURCE to a clean da55660 aienux checkout, +then nice -n 19 ionice -c3 sh om/allen-scene/check-native.sh. +Use ALLEN_CLANG and ALLEN_WASM_LD to select the exact isolated compiler paths. +oracle-ui.c includes the original allen_ui.c and uses its public start/tick/sleep +APIs, never adapter.c. It checks original boot and dusk frames independently. +oracle.c additionally checks adapter portability, interactive variants and PCM. +Neither is an emulator/hardware receipt. Observed results belong to the parent +evidence, not this provenance description. Compilation alone is not verification. + +Browser API +AllenScene.mount(canvas,{compact,interactive,opening,calm}) returns key(text), +speak(text), mode(name), enter('idle'|'dusk'|'birth'), home(), zoom('in'|'out'), +calm(enabled), frame(ms), destroy(), and ready. +opening accepts only 'idle', 'dusk' or 'birth'; other provided values are refused. +Its default is full-page dusk or compact idle. Compact remains static idle even +with an explicit animated opening. Use opening:'idle' for the settled home shell, +then enter('birth') from the home entrance gesture. +enter('idle') skips an active opening to settled native presence and stops owned +birth audio, without destroying the scene or requiring a caller-supplied time. +ready resolves only after the WASM instance and sized pixel buffer initialize. +An initially zero-size canvas waits for ResizeObserver rather than reporting ready. +Document allen-scene-ready announces API availability only. Canvas events bubble: +allen-scene-initialized (source pin), allen-scene-complete (kind,time), and +allen-scene-error (message). Failure is visible in data-scene-engine=unavailable. +The caller starts AllenAudio.enter('home') in its click before enter('birth'); +the visual controller does not duplicate AudioPort's audio context. It pauses, +resumes and stops that birth audio when its scene pauses or is destroyed. +Compact and reduced-motion scenes are static without a continuous frame loop; +hidden/offscreen scenes pause, preserving visible-time continuity. +Animated full scenes start at every animation callback and full bounded resolution. +Eight consecutive measured native draws above 50/3 ms lower one level; 180 +consecutive draws below 25/3 ms raise one level; each change holds 60 samples. +Levels lower render scale to 3/4, then 9/16, and only then skip alternate 60 Hz +callbacks. data-scene-quality names the level; data-scene-draw-ms reports a +periodic local draw sample. Explicit frame(ms) is never measured. +calm defaults to navigator.connection.saveData and gives static presence; an +explicit calm option or calm(enabled) overrides it. +Interactive canvases use touch-action:pinch-zoom: browser pinch and Ctrl/Cmd+wheel +page zoom are never intercepted. Two-touch pointer streams that the browser +still delivers zoom the sky; zoom('in'|'out') serves visible page controls. diff --git a/om/allen-scene/scene.om b/om/allen-scene/scene.om new file mode 100644 index 0000000..7762925 --- /dev/null +++ b/om/allen-scene/scene.om @@ -0,0 +1,1116 @@ +note Browser controller for native Allen. See provenance.txt for temporary C-WASM boundary. +note Text literals are emitted verbatim; public JS is never edited. +global out uchar 16384 +global used ulong 1 +fn flush to void +off = ulong 0 +while lt off get used 0 +n = write int 1 out off sub get used 0 off +if le n 0 +exit 2 +end +off = add off ulong n +end +put used 0 0 +end +fn byteput c uchar to void +if eq get used 0 len out +flush +end +put out get used 0 c +put used 0 add get used 0 1 +end +text j0 "/* Generated from om/allen-scene/scene.om by pinned seeded Omega.\n" +text j1 " * Controller: Omega-generated JavaScript. Rendering/audio: unchanged native C,\n" +text j2 " * aien-dev/aienux@da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c, compiled to WASM.\n" +text j3 " * This source pin was staged, not hardware-confirmed by the available report.\n" +text j4 " * Web opening reuses native dusk; enter('birth') is the original binary merger.\n" +text j5 " * Catalogue/licences and native dependency boundary: om/allen-scene/provenance.txt.\n" +text j6 " * WolframLanguageEvaluator: 1000/60 -> 50/3 ms; (1000/60)/2 -> 25/3 ms;\n" +text j7 " * 48000 (12300-11360)/1000 -> 45120 frames (native chirp non-silent window).\n" +text j8 " */\n" +text j9 "(() => {\n" +text j10 " 'use strict';\n" +text j11 " const PIN = 'da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c';\n" +text j12 " const mounted = new WeakMap();\n" +text j13 " let compiled;\n" +text j14 " function module() {\n" +text j15 " if (!compiled) compiled = fetch('/allen/scene.wasm', {credentials:'omit'})\n" +text j16 " .then(response => { if (!response.ok) throw new Error('Native scene unavailable'); return response.arrayBuffer(); })\n" +text j17 " .then(bytes => WebAssembly.compile(bytes)).catch(error => { compiled = null; throw error; });\n" +text j18 " return compiled;\n" +text j19 " }\n" +text j20 " function mount(canvas, options = {}) {\n" +text j21 " if (!(canvas instanceof HTMLCanvasElement)) throw new TypeError('AllenScene requires a canvas');\n" +text j22 " if (mounted.has(canvas)) return mounted.get(canvas);\n" +text j23 " const compact = Boolean(options.compact), interactive = Boolean(options.interactive) && !compact;\n const opening = options.opening === undefined ? (compact ? 'idle' : 'dusk') : options.opening;\n if(opening !== 'idle' && opening !== 'dusk' && opening !== 'birth') throw new RangeError('Invalid Allen scene opening');\n" +text j24 " const ctx = canvas.getContext('2d', {alpha:false});\n" +text j25 " if (!ctx) throw new Error('Canvas rendering unavailable');\n" +text j26 " const motion = matchMedia('(prefers-reduced-motion: reduce)');\n" +text j27 " const cleanup = [], letters = Array.from({length:64}, () => ({char:0,start:0,slot:0}));\n" +text j28 " const wordTimes = new Float64Array(256);\n" +text j29 " let ex, image, width = 0, height = 0, disposed = false, failed = false;\n" +text j30 " let raf = 0, lastWall = 0, clock = 20000, kind = 0, modeValue = 0;\n" +text j31 " let visible = true, reduced = motion.matches, dirty = true, resizePending = true;\n const connection = typeof navigator === 'object' ? navigator.connection : null;\n let calm = options.calm === undefined ? Boolean(connection && connection.saveData) : Boolean(options.calm);\n let quality = 0, overBudget = 0, underBudget = 0, qualityHold = 0, samples = 0;\n const renderScales = [1, 3/4, 9/16, 9/16];\n const qualityNames = ['full-60','balanced-60','small-60','small-30'];\n const frameBudget = 1000/60;\n // Wolfram: 1000/60 -> 50/3 ms; budget/2 -> 25/3; 1280*{1,3/4,9/16} -> {1280,960,720}.\n function still() { return reduced || compact || calm; }\n function qualityLabel() { canvas.dataset.sceneQuality = reduced ? 'reduced' : compact ? 'compact' : calm ? 'calm' : qualityNames[quality]; }\n function measureDraw(cost) {\n samples++;\n if(samples % 60 === 0) canvas.dataset.sceneDrawMs=String(cost);\n if(qualityHold) { qualityHold--; return; }\n overBudget=cost>frameBudget?overBudget+1:0;\n underBudget=cost=8?Math.min(3,quality+1):underBudget>=180?Math.max(0,quality-1):quality;\n if(next!==quality) {\n quality=next;qualityHold=60;overBudget=underBudget=0;\n resizePending=dirty=true;canvas.dataset.sceneDrawMs=String(cost);qualityLabel();\n }\n }\n" +text j32 " let letterHead = 0, wordRead = 0, wordWrite = 0, lastWord = -1000, speakUntil = 0, keyUntil = 0;\n" +text j33 " let ra = 113697000, dec = -72757000, fov = 80000, viewPending = false;\n" +text j34 " let dragId = null, dragX = 0, dragY = 0, pinchDistance = 0;\n const touches = [{id:null,x:0,y:0},{id:null,x:0,y:0}];\n" +text j35 " let ownsAudio = false, completeSent = false, resolveSize, rejectSize;\n" +text j36 " let pendingEnter = compact || opening === 'idle' ? 0 : opening === 'birth' ? 2 : 1, pendingStatic = false;\n" +text j37 " canvas.dataset.sceneSource = PIN;\n" +text j38 " canvas.dataset.sceneEngine = 'loading';\n qualityLabel();\n" +text j39 " function listen(target, name, fn, opts) {\n" +text j40 " target.addEventListener(name, fn, opts);\n" +text j41 " cleanup.push(() => target.removeEventListener(name, fn, opts));\n" +text j42 " }\n" +text j43 " function stopAudio() {\n" +text j44 " if (ownsAudio && window.AllenAudio) window.AllenAudio.stop();\n" +text j45 " ownsAudio=false;\n" +text j46 " }\n" +text j47 " function awake() { return !disposed && !failed && !document.hidden && visible; }\n" +text j48 " function request() {\n" +text j49 " if (!raf && ex && awake() && (!still() || dirty)) raf = requestAnimationFrame(tick);\n" +text j50 " }\n" +text j51 " function size() {\n" +text j52 " const box = canvas.getBoundingClientRect();\n" +text j53 " if (box.width <= 0 || box.height <= 0) return false;\n" +text j54 " // Policy bound, not a physical-resolution claim. Same aspect ratio, native design scaling.\n" +text j55 " const scale = Math.min(devicePixelRatio || 1, 1280 / Math.max(box.width,box.height))*renderScales[quality];\n" +text j56 " const w = Math.max(64,Math.round(box.width*scale)), h = Math.max(64,Math.round(box.height*scale));\n" +text j57 " resizePending = false;\n" +text j58 " if (w === width && h === height) return true;\n" +text j59 " width=w; height=h; canvas.width=w; canvas.height=h;\n" +text j60 " if (!ex.scene_init(w,h,compact?1:0)) throw new Error('Native scene size refused');\n" +text j61 " image = new ImageData(new Uint8ClampedArray(ex.memory.buffer,ex.scene_pixels(),w*h*4),w,h);\n" +text j62 " ex.scene_enter(kind);\n" +text j63 " // Resize keeps phase and mode but does not manufacture the old frame history.\n" +text j64 " ex.scene_step(Math.floor(clock),modeValue,0);\n" +text j65 " viewPending=true;\n if(resolveSize) {resolveSize();resolveSize=null;rejectSize=null;}\n" +text j66 " return true;\n" +text j67 " }\n" +text j68 " function reset(kindValue) {\n" +text j69 " kind=kindValue; clock=kind===0?20000:0; lastWall=0;completeSent=false;\n" +text j70 " wordRead=wordWrite=0; lastWord=-1000; speakUntil=keyUntil=0; modeValue=0;\n" +text j71 " for (const letter of letters) letter.char=0;\n" +text j72 " stopAudio();\n" +text j73 " if (ex && width) ex.scene_enter(kind);\n" +text j74 " dirty=true; request();\n" +text j75 " }\n" +text j76 " function render() {\n" +text j77 " if (!ex || !awake()) return;\n" +text j78 " if (resizePending && !size()) return;\n" +text j79 " if (!image) return;\n" +text j80 " if (viewPending && !(kind===1 && clock<4200)) {\n" +text j81 " if (!ex.scene_view(Math.round(ra),Math.round(dec),Math.round(fov))) throw new Error('Native sky view refused');\n" +text j82 " viewPending=false;\n" +text j83 " }\n" +text j84 " const time=Math.floor(clock);\n" +text j85 " while(wordRead!==wordWrite && wordTimes[wordRead]<=clock) {\n" +text j86 " lastWord=wordTimes[wordRead];ex.scene_word(Math.floor(lastWord));wordRead=(wordRead+1)%wordTimes.length;\n" +text j87 " }\n" +text j88 " let currentMode=modeValue;\n" +text j89 " if(clock=0?ex.scene_voice(time,Math.floor(lastWord)):0;\n" +text j94 " const shimmer=clock=1) {letter.char=0;continue;}\n" +text j101 " // Web enhancement: native glyphs lift from input to Allen. No HTML/text injection.\n" +text j102 " const ease=1-(1-u)*(1-u)*(1-u);\n" +text j103 " const x=width/2+(letter.slot-4)*width/90*(1-ease);\n" +text j104 " const y=height*(0.86+(0.4-0.86)*ease);\n" +text j105 " ex.scene_glyph(letter.char,Math.round(x),Math.round(y),Math.round(256*(1-u)));\n" +text j106 " }\n" +text j107 " ctx.putImageData(image,0,0);\n" +text j108 " canvas.dataset.scenePhase=kind===1 && clock<4200?'tube':kind===2 && clock<12300?'merger':clock<(kind===1?7200:15300)?'forming':'presence';\n" +text j109 " canvas.dataset.sceneTime=String(time);\n" +text j110 " canvas.dataset.sceneEngine='native-wasm';\n" +text j111 " dirty=false;\n if(!completeSent && (kind===0 || clock>=(kind===1?7200:15300))) {\n completeSent=true;\n canvas.dispatchEvent(new CustomEvent('allen-scene-complete',{bubbles:true,detail:{kind:kind===2?'birth':kind===1?'dusk':'idle',time}}));\n }\n return true;\n" +text j112 " }\n" +text j113 " function error(err) {\n" +text j114 " failed=true;cancelAnimationFrame(raf);raf=0;stopAudio();\n if(rejectSize) {rejectSize(err);resolveSize=null;rejectSize=null;}\n" +text j115 " canvas.dataset.sceneEngine='unavailable';\n" +text j116 " canvas.dispatchEvent(new CustomEvent('allen-scene-error',{bubbles:true,detail:{message:String(err.message||err)}}));\n" +text j117 " }\n" +text j118 " function tick(wall) {\n" +text j119 " raf=0;\n" +text j120 " if(!awake()) {lastWall=0;return;}\n" +text j121 " const dt=lastWall?wall-lastWall:0;\n" +text j122 " // Lowest level skips alternate 60 Hz callbacks; 25 ms tolerates timestamp jitter around 50/3 and 100/3 ms.\n if(!still() && quality===3 && dt<25 && !dirty) {request();return;}\n" +text j123 " lastWall=wall;\n" +text j124 " if(!still()) clock+=dt; // source clock advances; native integrators bound their own catch-up\n" +text j125 " const sample=!still() && !resizePending && !viewPending;\n const began=sample?performance.now():0;\n let drawn=false;\n try { drawn=render(); } catch(err) { error(err); }\n if(sample && drawn) measureDraw(performance.now()-began);\n" +text j126 " if(drawn && !still()) request();\n" +text j127 " }\n" +text j128 " function motionChanged() {\n" +text j129 " reduced=motion.matches;lastWall=0;cancelAnimationFrame(raf);raf=0;stopAudio();\n" +text j130 " if(still()) { reset(0); pendingStatic=true; }\n overBudget=underBudget=0;qualityLabel();\n" +text j131 " dirty=true;request();\n" +text j132 " }\n" +text j133 " function visibility() {\n" +text j134 " lastWall=0;\n" +text j135 " if(!awake()) {cancelAnimationFrame(raf);raf=0;if(ownsAudio && window.AllenAudio) window.AllenAudio.pause();}\n" +text j136 " else {if(ownsAudio && !still() && window.AllenAudio) void window.AllenAudio.resume();overBudget=underBudget=0;dirty=true;request();}\n" +text j137 " }\n" +text j138 " function changeView(dx,dy,zoom) {\n" +text j139 " if(!interactive || kind===1 && clock<4200) return;\n" +text j140 " ra=((ra+dx)%360000000+360000000)%360000000;\n" +text j141 " dec=Math.max(-89000000,Math.min(89000000,dec+dy));\n" +text j142 " fov=Math.max(10000,Math.min(120000,fov*zoom));\n" +text j143 " viewPending=dirty=true;request();\n" +text j144 " }\n" +text j145 " function home() {ra=113697000;dec=-72757000;fov=80000;viewPending=dirty=true;request();}\n" +text j146 " const api = {\n" +text j147 " key(text) {\n" +text j148 " if(disposed) return;\n" +text j149 " text=String(text).slice(-64);keyUntil=clock+4000;\n" +text j150 " if(ex) ex.scene_key(Math.floor(clock));\n" +text j151 " if(!reduced && !compact) for(let i=0;i126) continue;\n" +text j153 " const letter=letters[letterHead];letterHead=(letterHead+1)%letters.length;\n" +text j154 " letter.char=c;letter.start=clock+i*35;letter.slot=i%9;\n" +text j155 " }\n" +text j156 " dirty=true;request();\n" +text j157 " },\n" +text j158 " speak(text) {\n" +text j159 " if(disposed) return;\n" +text j160 " text=String(text).slice(0,4096);\n" +text j161 " let offset=0;const start=Math.max(clock,speakUntil-300);\n" +text j162 " for(let i=0;i86400000) throw new RangeError('Scene time outside one day');\n" +text j190 " cancelAnimationFrame(raf);raf=0;lastWall=0;\n" +text j191 " if(reduced) clock=20000;else clock=ms;\n" +text j192 " dirty=true;\n" +text j193 " if(ex) {try {render();} catch(err) {error(err);}}\n" +text j194 " },\n" +text j195 " destroy() {\n" +text j196 " if(disposed) return;\n" +text j197 " disposed=true;cancelAnimationFrame(raf);raf=0;stopAudio();\n if(rejectSize) {rejectSize(new Error('Scene destroyed before initialization'));resolveSize=null;rejectSize=null;}\n" +text j198 " for(const fn of cleanup) fn();\n" +text j199 " mounted.delete(canvas);image=null;ex=null;\n" +text j200 " canvas.dataset.sceneEngine='destroyed';\n" +text j201 " }\n" +text j202 " };\n" +text j203 " mounted.set(canvas,api);\n" +text j204 " listen(document,'visibilitychange',visibility);\n" +text j205 " listen(motion,'change',motionChanged);\n" +text j206 " if(typeof ResizeObserver==='function') {\n" +text j207 " const resize=new ResizeObserver(() => {resizePending=dirty=true;request();});resize.observe(canvas);cleanup.push(() => resize.disconnect());\n" +text j208 " } else listen(window,'resize',() => {resizePending=dirty=true;request();});\n" +text j209 " if(typeof IntersectionObserver==='function') {\n" +text j210 " const observer=new IntersectionObserver(entries => {visible=entries[0].isIntersecting;visibility();});observer.observe(canvas);cleanup.push(() => observer.disconnect());\n" +text j211 " }\n" +text j212 " if(interactive) {\n" +text j213 " const oldTouch=canvas.style.touchAction;canvas.style.touchAction='pinch-zoom';cleanup.push(() => {canvas.style.touchAction=oldTouch;});\n" +text j214 " listen(canvas,'pointerdown',event => {\n" +text j215 " if(event.button!==0) return;\n if(event.pointerType==='touch') {\n const slot=touches.find(touch => touch.id===null);\n if(!slot) return;\n slot.id=event.pointerId;slot.x=event.clientX;slot.y=event.clientY;\n if(touches[0].id!==null && touches[1].id!==null) pinchDistance=Math.hypot(touches[0].x-touches[1].x,touches[0].y-touches[1].y);\n }\n" +text j216 " dragId=event.pointerId;dragX=event.clientX;dragY=event.clientY;\n" +text j217 " canvas.setPointerCapture(dragId);canvas.focus({preventScroll:true});\n" +text j218 " });\n" +text j219 " listen(canvas,'pointermove',event => {\n" +text j220 " if(event.pointerType==='touch') {\n const touch=touches.find(touch => touch.id===event.pointerId);\n if(!touch) return;\n touch.x=event.clientX;touch.y=event.clientY;\n if(touches[0].id!==null && touches[1].id!==null) {\n const distance=Math.hypot(touches[0].x-touches[1].x,touches[0].y-touches[1].y);\n if(distance>0 && pinchDistance>0) changeView(0,0,pinchDistance/distance);\n pinchDistance=distance;return;\n }\n }\n if(event.pointerId!==dragId) return;\n" +text j221 " const box=canvas.getBoundingClientRect();\n" +text j222 " changeView(-(event.clientX-dragX)*fov*1000/Math.max(1,box.width),(event.clientY-dragY)*fov*1000/Math.max(1,box.width),1);\n" +text j223 " dragX=event.clientX;dragY=event.clientY;\n" +text j224 " });\n" +text j225 " const release=event => {\n for(const touch of touches) if(touch.id===event.pointerId) touch.id=null;\n pinchDistance=0;\n if(event.pointerId===dragId) {\n dragId=null;\n if(canvas.hasPointerCapture(event.pointerId)) canvas.releasePointerCapture(event.pointerId);\n const remaining=touches.find(touch => touch.id!==null);\n if(remaining) {dragId=remaining.id;dragX=remaining.x;dragY=remaining.y;}\n }\n };\n" +text j226 " listen(canvas,'pointerup',release);listen(canvas,'pointercancel',release);listen(canvas,'lostpointercapture',release);\n" +text j227 " listen(canvas,'wheel',event => {if(event.ctrlKey || event.metaKey) return;event.preventDefault();changeView(0,0,Math.pow(2,Math.max(-600,Math.min(600,event.deltaY))/600));},{passive:false});\n" +text j228 " listen(canvas,'keydown',event => {\n" +text j229 " const step=fov*1000/20;\n" +text j230 " switch(event.key) {\n" +text j231 " case 'ArrowLeft':changeView(-step,0,1);break;\n" +text j232 " case 'ArrowRight':changeView(step,0,1);break;\n" +text j233 " case 'ArrowUp':changeView(0,step,1);break;\n" +text j234 " case 'ArrowDown':changeView(0,-step,1);break;\n" +text j235 " case '+':case '=':changeView(0,0,1/1.1);break;\n" +text j236 " case '-':changeView(0,0,1.1);break;\n" +text j237 " case 'Home':home();break;\n" +text j238 " default:return;\n" +text j239 " }\n" +text j240 " event.preventDefault();\n" +text j241 " });\n" +text j242 " }\n" +text j243 " api.ready=module().then(module => WebAssembly.instantiate(module,{})).then(async instance => {\n" +text j244 " if(disposed) return api;\n" +text j245 " ex=instance.exports;\n" +text j246 " const initial=still()?0:pendingEnter===null?0:pendingEnter;\n" +text j247 " // Preserve an audio gesture made before compilation completes.\n" +text j248 " const audioOwner=ownsAudio;ownsAudio=false;reset(initial);ownsAudio=audioOwner;\n" +text j249 " pendingEnter=null;\n" +text j250 " if(!size()) await new Promise((resolve,reject) => {resolveSize=resolve;rejectSize=reject;});\n if(disposed) return api;\n" +text j251 " if(still() || pendingStatic) {clock=20000;ex.scene_step(20000,0,0);pendingStatic=false;}\n" +text j252 " render();request();\n canvas.dispatchEvent(new CustomEvent('allen-scene-initialized',{bubbles:true,detail:{source:PIN}}));\n" +text j253 " return api;\n" +text j254 " }).catch(err => {if(!disposed) error(err);throw err;});\n" +text j255 " // Expose the rejection to callers while avoiding an unhandled rejection for decorative mounts.\n" +text j256 " api.ready.catch(() => {});\n" +text j257 " return api;\n" +text j258 " }\n" +text j259 " window.AllenScene=Object.freeze({mount,source:PIN});\n" +text j260 " document.dispatchEvent(new CustomEvent('allen-scene-ready'));\n" +text j261 "})();\n" +fn part0 to void +for i ulong len j0 +byteput get j0 i +end +for i ulong len j1 +byteput get j1 i +end +for i ulong len j2 +byteput get j2 i +end +for i ulong len j3 +byteput get j3 i +end +for i ulong len j4 +byteput get j4 i +end +for i ulong len j5 +byteput get j5 i +end +for i ulong len j6 +byteput get j6 i +end +for i ulong len j7 +byteput get j7 i +end +for i ulong len j8 +byteput get j8 i +end +for i ulong len j9 +byteput get j9 i +end +for i ulong len j10 +byteput get j10 i +end +for i ulong len j11 +byteput get j11 i +end +for i ulong len j12 +byteput get j12 i +end +for i ulong len j13 +byteput get j13 i +end +for i ulong len j14 +byteput get j14 i +end +for i ulong len j15 +byteput get j15 i +end +for i ulong len j16 +byteput get j16 i +end +for i ulong len j17 +byteput get j17 i +end +for i ulong len j18 +byteput get j18 i +end +for i ulong len j19 +byteput get j19 i +end +end +fn part20 to void +for i ulong len j20 +byteput get j20 i +end +for i ulong len j21 +byteput get j21 i +end +for i ulong len j22 +byteput get j22 i +end +for i ulong len j23 +byteput get j23 i +end +for i ulong len j24 +byteput get j24 i +end +for i ulong len j25 +byteput get j25 i +end +for i ulong len j26 +byteput get j26 i +end +for i ulong len j27 +byteput get j27 i +end +for i ulong len j28 +byteput get j28 i +end +for i ulong len j29 +byteput get j29 i +end +for i ulong len j30 +byteput get j30 i +end +for i ulong len j31 +byteput get j31 i +end +for i ulong len j32 +byteput get j32 i +end +for i ulong len j33 +byteput get j33 i +end +for i ulong len j34 +byteput get j34 i +end +for i ulong len j35 +byteput get j35 i +end +for i ulong len j36 +byteput get j36 i +end +for i ulong len j37 +byteput get j37 i +end +for i ulong len j38 +byteput get j38 i +end +for i ulong len j39 +byteput get j39 i +end +end +fn part40 to void +for i ulong len j40 +byteput get j40 i +end +for i ulong len j41 +byteput get j41 i +end +for i ulong len j42 +byteput get j42 i +end +for i ulong len j43 +byteput get j43 i +end +for i ulong len j44 +byteput get j44 i +end +for i ulong len j45 +byteput get j45 i +end +for i ulong len j46 +byteput get j46 i +end +for i ulong len j47 +byteput get j47 i +end +for i ulong len j48 +byteput get j48 i +end +for i ulong len j49 +byteput get j49 i +end +for i ulong len j50 +byteput get j50 i +end +for i ulong len j51 +byteput get j51 i +end +for i ulong len j52 +byteput get j52 i +end +for i ulong len j53 +byteput get j53 i +end +for i ulong len j54 +byteput get j54 i +end +for i ulong len j55 +byteput get j55 i +end +for i ulong len j56 +byteput get j56 i +end +for i ulong len j57 +byteput get j57 i +end +for i ulong len j58 +byteput get j58 i +end +for i ulong len j59 +byteput get j59 i +end +end +fn part60 to void +for i ulong len j60 +byteput get j60 i +end +for i ulong len j61 +byteput get j61 i +end +for i ulong len j62 +byteput get j62 i +end +for i ulong len j63 +byteput get j63 i +end +for i ulong len j64 +byteput get j64 i +end +for i ulong len j65 +byteput get j65 i +end +for i ulong len j66 +byteput get j66 i +end +for i ulong len j67 +byteput get j67 i +end +for i ulong len j68 +byteput get j68 i +end +for i ulong len j69 +byteput get j69 i +end +for i ulong len j70 +byteput get j70 i +end +for i ulong len j71 +byteput get j71 i +end +for i ulong len j72 +byteput get j72 i +end +for i ulong len j73 +byteput get j73 i +end +for i ulong len j74 +byteput get j74 i +end +for i ulong len j75 +byteput get j75 i +end +for i ulong len j76 +byteput get j76 i +end +for i ulong len j77 +byteput get j77 i +end +for i ulong len j78 +byteput get j78 i +end +for i ulong len j79 +byteput get j79 i +end +end +fn part80 to void +for i ulong len j80 +byteput get j80 i +end +for i ulong len j81 +byteput get j81 i +end +for i ulong len j82 +byteput get j82 i +end +for i ulong len j83 +byteput get j83 i +end +for i ulong len j84 +byteput get j84 i +end +for i ulong len j85 +byteput get j85 i +end +for i ulong len j86 +byteput get j86 i +end +for i ulong len j87 +byteput get j87 i +end +for i ulong len j88 +byteput get j88 i +end +for i ulong len j89 +byteput get j89 i +end +for i ulong len j90 +byteput get j90 i +end +for i ulong len j91 +byteput get j91 i +end +for i ulong len j92 +byteput get j92 i +end +for i ulong len j93 +byteput get j93 i +end +for i ulong len j94 +byteput get j94 i +end +for i ulong len j95 +byteput get j95 i +end +for i ulong len j96 +byteput get j96 i +end +for i ulong len j97 +byteput get j97 i +end +for i ulong len j98 +byteput get j98 i +end +for i ulong len j99 +byteput get j99 i +end +end +fn part100 to void +for i ulong len j100 +byteput get j100 i +end +for i ulong len j101 +byteput get j101 i +end +for i ulong len j102 +byteput get j102 i +end +for i ulong len j103 +byteput get j103 i +end +for i ulong len j104 +byteput get j104 i +end +for i ulong len j105 +byteput get j105 i +end +for i ulong len j106 +byteput get j106 i +end +for i ulong len j107 +byteput get j107 i +end +for i ulong len j108 +byteput get j108 i +end +for i ulong len j109 +byteput get j109 i +end +for i ulong len j110 +byteput get j110 i +end +for i ulong len j111 +byteput get j111 i +end +for i ulong len j112 +byteput get j112 i +end +for i ulong len j113 +byteput get j113 i +end +for i ulong len j114 +byteput get j114 i +end +for i ulong len j115 +byteput get j115 i +end +for i ulong len j116 +byteput get j116 i +end +for i ulong len j117 +byteput get j117 i +end +for i ulong len j118 +byteput get j118 i +end +for i ulong len j119 +byteput get j119 i +end +end +fn part120 to void +for i ulong len j120 +byteput get j120 i +end +for i ulong len j121 +byteput get j121 i +end +for i ulong len j122 +byteput get j122 i +end +for i ulong len j123 +byteput get j123 i +end +for i ulong len j124 +byteput get j124 i +end +for i ulong len j125 +byteput get j125 i +end +for i ulong len j126 +byteput get j126 i +end +for i ulong len j127 +byteput get j127 i +end +for i ulong len j128 +byteput get j128 i +end +for i ulong len j129 +byteput get j129 i +end +for i ulong len j130 +byteput get j130 i +end +for i ulong len j131 +byteput get j131 i +end +for i ulong len j132 +byteput get j132 i +end +for i ulong len j133 +byteput get j133 i +end +for i ulong len j134 +byteput get j134 i +end +for i ulong len j135 +byteput get j135 i +end +for i ulong len j136 +byteput get j136 i +end +for i ulong len j137 +byteput get j137 i +end +for i ulong len j138 +byteput get j138 i +end +for i ulong len j139 +byteput get j139 i +end +end +fn part140 to void +for i ulong len j140 +byteput get j140 i +end +for i ulong len j141 +byteput get j141 i +end +for i ulong len j142 +byteput get j142 i +end +for i ulong len j143 +byteput get j143 i +end +for i ulong len j144 +byteput get j144 i +end +for i ulong len j145 +byteput get j145 i +end +for i ulong len j146 +byteput get j146 i +end +for i ulong len j147 +byteput get j147 i +end +for i ulong len j148 +byteput get j148 i +end +for i ulong len j149 +byteput get j149 i +end +for i ulong len j150 +byteput get j150 i +end +for i ulong len j151 +byteput get j151 i +end +for i ulong len j152 +byteput get j152 i +end +for i ulong len j153 +byteput get j153 i +end +for i ulong len j154 +byteput get j154 i +end +for i ulong len j155 +byteput get j155 i +end +for i ulong len j156 +byteput get j156 i +end +for i ulong len j157 +byteput get j157 i +end +for i ulong len j158 +byteput get j158 i +end +for i ulong len j159 +byteput get j159 i +end +end +fn part160 to void +for i ulong len j160 +byteput get j160 i +end +for i ulong len j161 +byteput get j161 i +end +for i ulong len j162 +byteput get j162 i +end +for i ulong len j163 +byteput get j163 i +end +for i ulong len j164 +byteput get j164 i +end +for i ulong len j165 +byteput get j165 i +end +for i ulong len j166 +byteput get j166 i +end +for i ulong len j167 +byteput get j167 i +end +for i ulong len j168 +byteput get j168 i +end +for i ulong len j169 +byteput get j169 i +end +for i ulong len j170 +byteput get j170 i +end +for i ulong len j171 +byteput get j171 i +end +for i ulong len j172 +byteput get j172 i +end +for i ulong len j173 +byteput get j173 i +end +for i ulong len j174 +byteput get j174 i +end +for i ulong len j175 +byteput get j175 i +end +for i ulong len j176 +byteput get j176 i +end +for i ulong len j177 +byteput get j177 i +end +for i ulong len j178 +byteput get j178 i +end +for i ulong len j179 +byteput get j179 i +end +end +fn part180 to void +for i ulong len j180 +byteput get j180 i +end +for i ulong len j181 +byteput get j181 i +end +for i ulong len j182 +byteput get j182 i +end +for i ulong len j183 +byteput get j183 i +end +for i ulong len j184 +byteput get j184 i +end +for i ulong len j185 +byteput get j185 i +end +for i ulong len j186 +byteput get j186 i +end +for i ulong len j187 +byteput get j187 i +end +for i ulong len j188 +byteput get j188 i +end +for i ulong len j189 +byteput get j189 i +end +for i ulong len j190 +byteput get j190 i +end +for i ulong len j191 +byteput get j191 i +end +for i ulong len j192 +byteput get j192 i +end +for i ulong len j193 +byteput get j193 i +end +for i ulong len j194 +byteput get j194 i +end +for i ulong len j195 +byteput get j195 i +end +for i ulong len j196 +byteput get j196 i +end +for i ulong len j197 +byteput get j197 i +end +for i ulong len j198 +byteput get j198 i +end +for i ulong len j199 +byteput get j199 i +end +end +fn part200 to void +for i ulong len j200 +byteput get j200 i +end +for i ulong len j201 +byteput get j201 i +end +for i ulong len j202 +byteput get j202 i +end +for i ulong len j203 +byteput get j203 i +end +for i ulong len j204 +byteput get j204 i +end +for i ulong len j205 +byteput get j205 i +end +for i ulong len j206 +byteput get j206 i +end +for i ulong len j207 +byteput get j207 i +end +for i ulong len j208 +byteput get j208 i +end +for i ulong len j209 +byteput get j209 i +end +for i ulong len j210 +byteput get j210 i +end +for i ulong len j211 +byteput get j211 i +end +for i ulong len j212 +byteput get j212 i +end +for i ulong len j213 +byteput get j213 i +end +for i ulong len j214 +byteput get j214 i +end +for i ulong len j215 +byteput get j215 i +end +for i ulong len j216 +byteput get j216 i +end +for i ulong len j217 +byteput get j217 i +end +for i ulong len j218 +byteput get j218 i +end +for i ulong len j219 +byteput get j219 i +end +end +fn part220 to void +for i ulong len j220 +byteput get j220 i +end +for i ulong len j221 +byteput get j221 i +end +for i ulong len j222 +byteput get j222 i +end +for i ulong len j223 +byteput get j223 i +end +for i ulong len j224 +byteput get j224 i +end +for i ulong len j225 +byteput get j225 i +end +for i ulong len j226 +byteput get j226 i +end +for i ulong len j227 +byteput get j227 i +end +for i ulong len j228 +byteput get j228 i +end +for i ulong len j229 +byteput get j229 i +end +for i ulong len j230 +byteput get j230 i +end +for i ulong len j231 +byteput get j231 i +end +for i ulong len j232 +byteput get j232 i +end +for i ulong len j233 +byteput get j233 i +end +for i ulong len j234 +byteput get j234 i +end +for i ulong len j235 +byteput get j235 i +end +for i ulong len j236 +byteput get j236 i +end +for i ulong len j237 +byteput get j237 i +end +for i ulong len j238 +byteput get j238 i +end +for i ulong len j239 +byteput get j239 i +end +end +fn part240 to void +for i ulong len j240 +byteput get j240 i +end +for i ulong len j241 +byteput get j241 i +end +for i ulong len j242 +byteput get j242 i +end +for i ulong len j243 +byteput get j243 i +end +for i ulong len j244 +byteput get j244 i +end +for i ulong len j245 +byteput get j245 i +end +for i ulong len j246 +byteput get j246 i +end +for i ulong len j247 +byteput get j247 i +end +for i ulong len j248 +byteput get j248 i +end +for i ulong len j249 +byteput get j249 i +end +for i ulong len j250 +byteput get j250 i +end +for i ulong len j251 +byteput get j251 i +end +for i ulong len j252 +byteput get j252 i +end +for i ulong len j253 +byteput get j253 i +end +for i ulong len j254 +byteput get j254 i +end +for i ulong len j255 +byteput get j255 i +end +for i ulong len j256 +byteput get j256 i +end +for i ulong len j257 +byteput get j257 i +end +for i ulong len j258 +byteput get j258 i +end +for i ulong len j259 +byteput get j259 i +end +end +fn part260 to void +for i ulong len j260 +byteput get j260 i +end +for i ulong len j261 +byteput get j261 i +end +end +fn main to int +part0 +part20 +part40 +part60 +part80 +part100 +part120 +part140 +part160 +part180 +part200 +part220 +part240 +part260 +flush +ret 0 +end diff --git a/om/allen-scene/test-controller.cjs b/om/allen-scene/test-controller.cjs new file mode 100644 index 0000000..6dedb5f --- /dev/null +++ b/om/allen-scene/test-controller.cjs @@ -0,0 +1,166 @@ +'use strict'; +/* Lifecycle/interaction unit harness with real WASM, not a browser/visual claim. */ +const fs=require('node:fs'),vm=require('node:vm'),assert=require('node:assert/strict'); +class Events { + constructor(){this.listeners=new Map();} + addEventListener(name,fn){if(!this.listeners.has(name))this.listeners.set(name,new Set());this.listeners.get(name).add(fn);} + removeEventListener(name,fn){this.listeners.get(name)?.delete(fn);} + dispatchEvent(event){event.target=this;for(const fn of this.listeners.get(event.type)||[])fn(event);return true;} +} +class Canvas extends Events { + constructor(){super();this.dataset={};this.style={};this.width=0;this.height=0;this.draws=0;this.captured=null;this.box={width:640,height:400};} + getContext(){return {putImageData:image=>{assert.equal(image.data.length,this.width*this.height*4);this.draws++;}};} + getBoundingClientRect(){if(this.onMeasure)this.onMeasure();return this.box;} + setPointerCapture(id){this.captured=id;} + hasPointerCapture(id){return this.captured===id;} + releasePointerCapture(){this.captured=null;} + focus(){} +} +(async()=>{ + const document=new Events();document.hidden=false; + const motion=new Events();motion.matches=false; + const window=new Events(),raf=new Map(),resizes=[],intersections=[];let serial=0; + let drawCost=2,measurementClock=0; + const connection={saveData:false}; + const wasm=fs.readFileSync('public/allen/scene.wasm'); + const audio={enter:0,pause:0,resume:0,stop:0}; + window.AllenAudio={enter:()=>{audio.enter++;return Promise.resolve(true);},pause:()=>audio.pause++,resume:()=>{audio.resume++;return Promise.resolve();},stop:()=>audio.stop++}; + const context={window,document,HTMLCanvasElement:Canvas,WebAssembly,Uint8ClampedArray,Float64Array,Int16Array, + ImageData:class{constructor(data,width,height){this.data=data;this.width=width;this.height=height;}}, + CustomEvent:class{constructor(type,options){this.type=type;Object.assign(this,options);}}, + matchMedia:()=>motion,devicePixelRatio:1, + navigator:{connection},performance:{now:()=>{measurementClock+=drawCost;return measurementClock;}}, + fetch:async url=>{assert.equal(url,'/allen/scene.wasm');return {ok:true,arrayBuffer:async()=>wasm};}, + requestAnimationFrame:fn=>{const id=++serial;raf.set(id,fn);return id;},cancelAnimationFrame:id=>raf.delete(id), + ResizeObserver:class{constructor(fn){this.fn=fn;resizes.push(this);}observe(){}disconnect(){this.disconnected=true;}}, + IntersectionObserver:class{constructor(fn){this.fn=fn;intersections.push(this);}observe(){}disconnect(){this.disconnected=true;}} + }; + let ready=0;document.addEventListener('allen-scene-ready',()=>ready++); + vm.runInNewContext(fs.readFileSync('public/js/allen-scene.js','utf8'),context); + assert.equal(ready,1); + const canvas=new Canvas(),scene=window.AllenScene.mount(canvas,{interactive:true}); + assert.equal(window.AllenScene.mount(canvas),scene,'one instance per canvas'); + let initialized=0,complete=0; + canvas.addEventListener('allen-scene-initialized',()=>initialized++); + canvas.addEventListener('allen-scene-complete',()=>complete++); + window.AllenAudio.enter('home');scene.enter('birth');await scene.ready; + assert.equal(audio.enter,1,'visual enter must not start duplicate audio'); + assert.equal(initialized,1,'initialized event follows WASM and buffer readiness'); + assert.equal(canvas.dataset.sceneEngine,'native-wasm'); + scene.frame(8000);assert.equal(canvas.dataset.scenePhase,'merger'); + scene.enter('dusk');scene.frame(2000);assert.equal(canvas.dataset.scenePhase,'tube'); + scene.frame(7216);assert.equal(canvas.dataset.scenePhase,'presence'); + assert.equal(complete,1,'dusk completion announced once'); + scene.key('abc');scene.speak('a safe word');scene.mode('thinking');scene.frame(7600); + const event={type:'keydown',key:'ArrowRight',preventDefault(){this.prevented=true;}}; + canvas.dispatchEvent(event);assert.ok(event.prevented,'keyboard exploration handled'); + scene.enter('birth');document.hidden=true;document.dispatchEvent({type:'visibilitychange'}); + assert.equal(raf.size,0,'hidden document has no frame loop');assert.ok(audio.pause>0); + document.hidden=false;document.dispatchEvent({type:'visibilitychange'});assert.ok(raf.size>0);assert.ok(audio.resume>0); + intersections[0].fn([{isIntersecting:false}]);assert.equal(raf.size,0,'offscreen has no frame loop'); + intersections[0].fn([{isIntersecting:true}]); + motion.matches=true;motion.dispatchEvent({type:'change'}); + const batch=[...raf];raf.clear();for(const [,fn] of batch)fn(1000); + assert.equal(raf.size,0,'reduced-motion redraw settles without a frame loop'); + assert.equal(canvas.dataset.scenePhase,'presence'); + const frozen=canvas.dataset.sceneTime;scene.frame(999);assert.equal(canvas.dataset.sceneTime,frozen); + scene.destroy();assert.equal(raf.size,0);assert.equal(canvas.dataset.sceneEngine,'destroyed'); + assert.ok(resizes[0].disconnected && intersections[0].disconnected); + motion.matches=false; + const icon=new Canvas();icon.box={width:160,height:160}; + const compact=window.AllenScene.mount(icon,{compact:true});await compact.ready; + const compactBatch=[...raf];raf.clear();for(const [,fn] of compactBatch)fn(2000); + assert.equal(raf.size,0,'compact has static idle, no background loop'); + assert.equal(icon.dataset.scenePhase,'presence');compact.destroy(); + const late=new Canvas();late.box={width:0,height:0}; + let measured,readyLate=false; + const measurement=new Promise(resolve=>{measured=resolve;}); + late.onMeasure=()=>{late.onMeasure=null;measured();}; + const deferred=window.AllenScene.mount(late,{}); + deferred.ready.then(()=>{readyLate=true;}); + await measurement;assert.equal(readyLate,false,'zero-size canvas is not initialized'); + late.box={width:640,height:400};resizes[2].fn(); + const lateBatch=[...raf];raf.clear();for(const [,fn] of lateBatch)fn(3000); + await deferred.ready;assert.equal(readyLate,true); + assert.equal(late.dataset.scenePhase,'tube','zero-size initial mount retains opening choice'); + deferred.destroy();assert.equal(raf.size,0); + for(const opening of ['idle','dusk','birth']) { + const target=new Canvas(),instance=window.AllenScene.mount(target,{opening}); + await instance.ready; + assert.equal(target.dataset.scenePhase,opening==='idle'?'presence':opening==='dusk'?'tube':'merger'); + instance.destroy(); + } + for(const opening of ['other','',null,0,{},['idle']]) { + assert.throws(()=>window.AllenScene.mount(new Canvas(),{opening}),/Invalid Allen scene opening/); + } + assert.equal(raf.size,0,'opening option tests leave no scheduled work'); + const skippedCanvas=new Canvas(),skipped=window.AllenScene.mount(skippedCanvas,{opening:'idle'}); + await skipped.ready; + skipped.enter('birth'); + const stopsBeforeSkip=audio.stop; + skipped.enter('idle'); + const skipBatch=[...raf];raf.clear();for(const [,fn] of skipBatch)fn(4000); + assert.equal(skippedCanvas.dataset.scenePhase,'presence','idle entry skips the opening without caller timing'); + assert.ok(audio.stop>stopsBeforeSkip,'idle entry stops owned birth audio'); + assert.equal(skippedCanvas.dataset.sceneEngine,'native-wasm','skip retains live native scene'); + skipped.destroy();assert.equal(raf.size,0); + let wall=5000; + function frames(count) { + for(let i=0;i0); + const qualityBeforeFrame=adaptiveCanvas.dataset.sceneQuality; + adaptive.frame(25000); + assert.equal(adaptiveCanvas.dataset.sceneQuality,qualityBeforeFrame,'explicit frame does not measure or retune quality'); + assert.equal(raf.size,0,'explicit frame remains a single draw'); + assert.equal(adaptiveCanvas.style.touchAction,'pinch-zoom'); + const zoomEvent={type:'wheel',ctrlKey:true,deltaY:100,preventDefault(){this.prevented=true;}}; + adaptiveCanvas.dispatchEvent(zoomEvent); + assert.equal(zoomEvent.prevented,undefined,'browser pinch/Ctrl+wheel is not intercepted'); + const sceneWheel={type:'wheel',deltaY:100,preventDefault(){this.prevented=true;}}; + adaptiveCanvas.dispatchEvent(sceneWheel);assert.ok(sceneWheel.prevented); + adaptive.zoom('in');adaptive.zoom('out'); + assert.throws(()=>adaptive.zoom('other'),/Scene zoom/); + for(const [pointerId,clientX] of [[1,10],[2,30]]) adaptiveCanvas.dispatchEvent({type:'pointerdown',pointerType:'touch',button:0,pointerId,clientX,clientY:10}); + adaptiveCanvas.dispatchEvent({type:'pointermove',pointerType:'touch',pointerId:2,clientX:50,clientY:10}); + for(const pointerId of [1,2]) adaptiveCanvas.dispatchEvent({type:'pointercancel',pointerId}); + adaptive.calm(true);frames(2); + assert.equal(adaptiveCanvas.dataset.sceneQuality,'calm'); + assert.equal(raf.size,0,'explicit calm has no continuous loop'); + adaptive.calm(false);assert.ok(raf.size>0,'explicit resume restores animation'); + adaptive.destroy();assert.equal(adaptiveCanvas.style.touchAction,undefined); + connection.saveData=true; + const saverCanvas=new Canvas(),saver=window.AllenScene.mount(saverCanvas); + await saver.ready;frames(2); + assert.equal(saverCanvas.dataset.sceneQuality,'calm','saveData defaults to static presence'); + assert.equal(saverCanvas.dataset.scenePhase,'presence');assert.equal(raf.size,0); + saver.destroy(); + const overrideCanvas=new Canvas(),override=window.AllenScene.mount(overrideCanvas,{calm:false,opening:'idle'}); + await override.ready;assert.equal(overrideCanvas.dataset.sceneQuality,'full-60');assert.ok(raf.size>0); + override.destroy();connection.saveData=false;drawCost=2; + assert.equal(raf.size,0); + console.log('Adaptive controller: every-callback initial cadence, measured cost hysteresis, bounded resolution/pacing, explicit-frame isolation, accessible pinch, zoom API, calm/saveData'); + console.log('Controller lifecycle: ready, aliases, native rendering, keys, speech, hidden/offscreen pause, reduced motion, compact, zero-size mount, bounded opening options, teardown'); +})().catch(error=>{console.error(error);process.exitCode=1;}); diff --git a/om/allen-scene/test-parity.cjs b/om/allen-scene/test-parity.cjs new file mode 100644 index 0000000..0c7f99e --- /dev/null +++ b/om/allen-scene/test-parity.cjs @@ -0,0 +1,44 @@ +/* Targeted renderer ABI/parity test; not an iMac hardware qualification. */ +'use strict'; +const fs=require('node:fs'), assert=require('node:assert/strict'); +const {execFileSync}=require('node:child_process'); +(async () => { + const oracle=process.argv[2], wasm=process.argv[3]||'public/allen/scene.wasm', original=process.argv[4]; + if(!oracle || !original) throw new Error('usage: node om/allen-scene/test-parity.cjs /path/to/native-oracle wasm /path/to/original-ui-oracle'); + const module=await WebAssembly.compile(fs.readFileSync(wasm)); + assert.deepEqual(WebAssembly.Module.imports(module),[],'native WASM must have no imports'); + const {exports:ex}=await WebAssembly.instantiate(module,{}); + assert.equal(ex.scene_init(63,400,0),0,'undersized canvas refusal'); + assert.equal(ex.scene_init(1920,1920,0),0,'pixel capacity refusal'); + assert.equal(ex.scene_view(-1,0,80000),0,'uninitialized/invalid camera refusal'); + const cases=[[1,0,0,0],[1,600,0,0],[1,2000,0,0],[1,3200,0,0],[1,4192,0,0],[1,5104,0,0],[1,7216,0,0],[2,8000,0,0],[2,12000,0,0],[2,12608,0,0],[2,16512,0,0],[0,17600,0,1],[0,16512,0,2],[0,16512,1,0]]; + for(const [kind,target,compact,variant] of cases) { + assert.equal(ex.scene_init(640,400,compact),1); + ex.scene_enter(kind); + if(variant===2) assert.equal(ex.scene_view(119000000,-71000000,60000),1); + for(let t=0;t<=target;t+=16) { + if(variant===1 && t===16000) ex.scene_key(t); + if(variant===1 && t===17008) ex.scene_word(t); + ex.scene_step(t,variant===1?(t<16000?0:t<17008?1:3):0,variant===1?128:0); + } + ex.scene_step(target,variant===1?3:0,variant===1?128:0); + ex.scene_draw(variant===1?256:0,variant===1?128:0); + if(variant===1) ex.scene_glyph(65,300,300,200); + const observed=Buffer.from(ex.memory.buffer,ex.scene_pixels(),640*400*4); + const expected=execFileSync(oracle,[kind,target,compact,variant].map(String),{maxBuffer:640*400*4+1024}); + assert.equal(expected.length,observed.length,'oracle cannot silently omit pixels'); + assert.equal(observed.compare(expected),0,`RGBA mismatch kind=${kind} t=${target} compact=${compact} variant=${variant}`); + if(!compact && !variant && ((kind===1 && target<4200) || (kind===2 && target<15300))) { + const originalFrame=execFileSync(original,[kind,target].map(String),{maxBuffer:640*400*4+1024}); + assert.equal(observed.compare(originalFrame),0,`ORIGINAL allen_ui.c mismatch kind=${kind} t=${target}`); + console.log(`Independent original allen_ui.c RGB parity kind=${kind} time=${target} (opaque alpha normalized)`); + } + const mutant=Buffer.from(observed);mutant[0]^=1; + assert.notEqual(mutant.compare(expected),0,'wrong-pixel negative control must differ'); + console.log(`RGBA byte parity kind=${kind} time=${target} compact=${compact} variant=${variant}`); + } + const ptr=ex.scene_audio(11360*48,45120),pcm=Buffer.from(ex.memory.buffer,ptr,45120*4); + assert.equal(pcm.compare(execFileSync(oracle,['audio'],{maxBuffer:45120*4+1024})),0,'native chirp PCM byte mismatch'); + assert.equal(ex.scene_audio(0,48001),0,'audio capacity refusal'); + console.log('PCM byte parity; invalid sizes/camera/audio refused; wrong-pixel control rejected'); +})().catch(error => {console.error(error);process.exitCode=1;}); diff --git a/om/allen-voice/allen-voice.js.sha256 b/om/allen-voice/allen-voice.js.sha256 new file mode 100644 index 0000000..129e562 --- /dev/null +++ b/om/allen-voice/allen-voice.js.sha256 @@ -0,0 +1 @@ +1ea32a45b7c01fb2a8b5362e8702f678fa7a794bbf89e01720723b663fa9e8df ../../public/js/allen-voice.js diff --git a/om/allen-voice/check.sh b/om/allen-voice/check.sh new file mode 100755 index 0000000..eb7776e --- /dev/null +++ b/om/allen-voice/check.sh @@ -0,0 +1,85 @@ +#!/bin/sh +# Regenerate Allen's voice controller (public/js/allen-voice.js) with the pinned +# arm64 omc, then run its behaviour test with node and two negative controls. +# The compiler is the one vendored for the Hive page; its pin is recorded once, +# in ../hive-page/omc.sha256. OMEGA_OMC overrides the compiler path, never its pin. +# OMEGA_ACCEPT_CHANGE=1 accepts a rewritten artifact; otherwise stale output exits 4. +# Without node the test prints TEST NOT_RUN; that is not a pass. +# Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten; +# 5: nondeterministic output; 6: empty output; 7: behaviour test failed; +# 8: a negative control passed. Compile/run failures propagate. +set -eu +cd "$(dirname "$0")" +omc=${OMEGA_OMC:-$PWD/../hive-page/omc} +pin=$(tr -d ' \n' < ../hive-page/omc.sha256) +if [ ! -f "$omc" ]; then + printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2 + exit 2 +fi +have=$(sha256sum "$omc" | cut -d' ' -f1) +if [ "$have" != "$pin" ]; then + printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2 + exit 3 +fi +work=$(mktemp -d "${TMPDIR:-/tmp}/allen-voice.XXXXXX") +trap 'rm -rf "$work"' EXIT HUP INT TERM +"$omc" < voice.om > "$work/voice" +chmod +x "$work/voice" +"$work/voice" > "$work/first.js" +"$work/voice" > "$work/second.js" +if ! cmp -s "$work/first.js" "$work/second.js"; then + printf 'allen-voice.js: generator output differs between runs\n' >&2 + exit 5 +fi +if [ ! -s "$work/first.js" ]; then + printf 'allen-voice.js: generator wrote nothing\n' >&2 + exit 6 +fi +artifact=../../public/js/allen-voice.js +stale=0 +if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$work/first.js"; then + stale=1 +fi +cp "$work/first.js" "$artifact" +hash=$(sha256sum "$artifact" | cut -d' ' -f1) +printf '%s %s\n' "$hash" "$artifact" > allen-voice.js.sha256 +printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash" +printf 'omc sha256 %s\n' "$have" + +if ! command -v node > /dev/null 2>&1; then + printf 'TEST NOT_RUN: node is not installed\n' +else + if ! node test-voice.cjs "$artifact"; then + printf 'TEST FAIL: %s\n' "$artifact" >&2 + exit 7 + fi + # Negative controls, each of which must fail the test: a controller that + # sends recognized words itself; one that reads replies aloud by default; + # one that trusts any presence without transcribe false; one that scales + # negative samples by 32767; one that retries a failed clip with the + # browser's service on its own; one that asks for the microphone at load. + sed 's/input.dispatchEvent(new Event(.input., { bubbles: true }));/&\n if (window.allen) window.allen.send(value);/' "$artifact" > "$work/autosend.js" + sed 's/speaking = stored();/speaking = true;/' "$artifact" > "$work/speakon.js" + sed 's/reply.transcribe === true/reply.transcribe !== false/' "$artifact" > "$work/presence.js" + sed 's/Math.round(s \* 32768)/Math.round(s * 32767)/' "$artifact" > "$work/pcm.js" + sed 's/^\( *\)offerBrowser();$/\1mode = browserMode;\n\1startBrowser();/' "$artifact" > "$work/fallback.js" + sed 's/const \[local, server\] = await Promise.all/window.navigator.mediaDevices.getUserMedia({ audio: true }); &/' "$artifact" > "$work/earlymic.js" + for mutant in autosend speakon presence pcm fallback earlymic; do + if cmp -s "$artifact" "$work/$mutant.js"; then + printf 'NEGATIVE CONTROL %s: the mutation did not apply\n' "$mutant" >&2 + exit 8 + fi + if node test-voice.cjs "$work/$mutant.js" > "$work/$mutant.log" 2>&1; then + printf 'NEGATIVE CONTROL FAIL: the %s mutant passed the test\n' "$mutant" >&2 + exit 8 + fi + printf 'negative control %s: rejected (%s)\n' "$mutant" "$(grep -m1 -o 'AssertionError[^\n]*' "$work/$mutant.log" || printf 'test failed')" + done +fi + +if [ "$stale" = 1 ]; then + printf 'Generated artifact was rewritten; commit it with its Omega source\n' >&2 + if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then + exit 4 + fi +fi diff --git a/om/allen-voice/test-voice.cjs b/om/allen-voice/test-voice.cjs new file mode 100644 index 0000000..d41132f --- /dev/null +++ b/om/allen-voice/test-voice.cjs @@ -0,0 +1,1008 @@ +'use strict'; +/* Behaviour test for public/js/allen-voice.js in a scripted DOM (node vm). + * Fakes stand in for SpeechRecognition, speechSynthesis, storage and the + * window.allen transport, so no microphone permission is ever requested or + * granted: getUserMedia and permissions.query throw if anything calls them. + * This is a unit harness, not a browser or device claim. + * Usage: node test-voice.cjs path/to/allen-voice.js */ +const fs = require('node:fs'); +const vm = require('node:vm'); +const assert = require('node:assert/strict'); + +const file = process.argv[2] || `${__dirname}/../../public/js/allen-voice.js`; +const code = fs.readFileSync(file, 'utf8'); +const COPY_OF = key => { + const match = new RegExp(`\\n ${key}: "([^"]*)",`).exec(code); + assert.ok(match, `copy ${key} present`); + return match[1]; +}; + +class Event { + constructor(type, init) { + this.type = type; + this.bubbles = !!(init && init.bubbles); + this.defaultPrevented = false; + this.stopped = false; + } + preventDefault() { + this.defaultPrevented = true; + } + stopPropagation() { + this.stopped = true; + } +} +class Node { + constructor() { + this.listeners = new Map(); + } + addEventListener(type, fn) { + if (!this.listeners.has(type)) this.listeners.set(type, []); + this.listeners.get(type).push(fn); + } + removeEventListener(type, fn) { + const list = this.listeners.get(type) || []; + const at = list.indexOf(fn); + if (at >= 0) list.splice(at, 1); + } + dispatchEvent(event) { + event.target = event.target || this; + for (const fn of [...(this.listeners.get(event.type) || [])]) fn(event); + return !event.defaultPrevented; + } +} +class Element extends Node { + constructor(tag, id) { + super(); + this.tagName = tag.toUpperCase(); + this.id = id || ''; + this.attrs = new Map(); + this.dataset = {}; + this.textContent = ''; + this.title = ''; + this.disabled = false; + this.children = []; + this.parentNode = null; + this.nextSibling = null; + } + setAttribute(name, value) { + this.attrs.set(name, String(value)); + } + getAttribute(name) { + return this.attrs.has(name) ? this.attrs.get(name) : null; + } + insertBefore(child, before) { + child.parentNode = this; + const at = before ? this.children.indexOf(before) : -1; + if (at < 0) this.children.push(child); + else this.children.splice(at, 0, child); + return child; + } + click() { + const event = new Event('click'); + this.dispatchEvent(event); + if (this.tagName === 'INPUT' && this.type === 'checkbox' && !this.disabled) { + this.checked = !this.checked; + this.dispatchEvent(new Event('change')); + } + } +} +class Field extends Element { + constructor(id) { + super('textarea', id); + this.value = ''; + this.maxLength = -1; + this.caret = null; + } + setSelectionRange(a, b) { + this.caret = [a, b]; + } +} + +function result(text, final) { + return Object.assign([{ transcript: text, confidence: 0.9 }], { isFinal: final }); +} +function results(...list) { + return { results: list }; +} +function tick() { + return new Promise(done => setImmediate(done)); +} + +/* One page load. opts: recognition 'none'|'webkit'|'standard', available + (string or undefined: no static available), secure, synth, voices, + stored, toggle 'button'|'checkbox'|'none', mic false, allen false. */ +function load(opts = {}) { + const ids = new Map(); + const page = new Element('div', 'allen'); + const add = el => { + ids.set(el.id, el); + page.insertBefore(el, null); + return el; + }; + const input = add(new Field('allen-input')); + const form = add(new Element('form', 'allen-form')); + form.submits = 0; + form.submit = () => form.submits++; + const mic = opts.mic === false ? null : add(new Element('button', 'allen-mic')); + const privacy = add(new Element('p', 'allen-voice-privacy')); + let toggle = null; + if (opts.toggle !== 'none') { + toggle = new Element(opts.toggle === 'checkbox' ? 'input' : 'button', 'allen-speak'); + if (opts.toggle === 'checkbox') { + toggle.type = 'checkbox'; + toggle.checked = false; + } + add(toggle); + } + const document = new Node(); + document.hidden = false; + document.documentElement = { lang: opts.lang || 'en-US' }; + document.getElementById = id => ids.get(id) || null; + document.createElement = tag => new Element(tag); + const guard = { media: 0, permission: 0 }; + const store = new Map(opts.stored ? [['allen-voice-speak', opts.stored]] : []); + const writes = []; + const sandbox = { + document, + Event, + console, + isSecureContext: opts.secure !== false, + navigator: { + language: 'en-US', + mediaDevices: { getUserMedia: () => { guard.media++; throw new Error('getUserMedia called'); } }, + permissions: { query: () => { guard.permission++; throw new Error('permissions.query called'); } }, + }, + localStorage: { + getItem: key => (store.has(key) ? store.get(key) : null), + setItem: (key, value) => { writes.push([key, String(value)]); store.set(key, String(value)); }, + removeItem: key => { writes.push([key, null]); store.delete(key); }, + }, + }; + const win = new Node(); + Object.assign(win, sandbox); + win.window = win; + /* Allen's server: fetch, getUserMedia, MediaRecorder, AudioContext, timers + and the clock, all scripted. opts.server = { presence, opus, audio, + decoded, media, respond, hold }. */ + const srv = { fetches: [], gum: 0, recorders: [], streams: [], timers: [], clock: 0, held: [] }; + if (opts.server) { + const S = opts.server; + win.Blob = Blob; + win.AbortController = AbortController; + win.performance = { now: () => srv.clock }; + win.setTimeout = (fn, ms) => { + srv.timers.push({ fn, ms, live: true }); + return srv.timers.length; + }; + win.clearTimeout = id => { + if (srv.timers[id - 1]) srv.timers[id - 1].live = false; + }; + win.fetch = (url, init = {}) => { + const call = { url, init }; + srv.fetches.push(call); + if (url === '/allen/api/presence') { + if (S.presence === 'throw') return Promise.reject(new TypeError('offline')); + if (S.presence === 'error') return Promise.resolve({ ok: false, status: 500, json: async () => ({}) }); + return Promise.resolve({ ok: true, status: 200, json: async () => S.presence }); + } + return new Promise((resolve, reject) => { + const answer = () => { + const out = S.respond ? S.respond(call) : { status: 200, body: { text: 'hello world', ms: 900, seconds: 2, model: 'whisper' } }; + if (out === 'throw') { + reject(new TypeError('network')); + return; + } + resolve({ ok: out.status >= 200 && out.status < 300, status: out.status, headers: { get: name => (out.headers || {})[name] || null }, json: async () => { + if (out.html) throw new SyntaxError('Unexpected token < in JSON'); + return out.body; + } }); + }; + if (init.signal) init.signal.addEventListener('abort', () => reject(new Error('AbortError'))); + if (S.hold) srv.held.push(answer); + else answer(); + }); + }; + win.navigator.mediaDevices = { + getUserMedia: constraints => { + srv.gum += 1; + srv.constraints = constraints; + if (S.media && S.media !== 'ok') { + const error = new Error(S.media); + error.name = S.media; + return Promise.reject(error); + } + const track = { stopped: false, stop() { this.stopped = true; } }; + const stream = { tracks: [track], getTracks() { return this.tracks; } }; + srv.streams.push(stream); + return Promise.resolve(stream); + }, + }; + if (S.recorder !== false) { + win.MediaRecorder = class { + static isTypeSupported(type) { + return (S.opus || []).includes(type); + } + constructor(stream, options) { + this.stream = stream; + this.options = options; + this.state = 'inactive'; + this.chunk = null; + srv.recorders.push(this); + } + start() { + this.state = 'recording'; + } + stop() { + if (this.state === 'inactive') throw new Error('InvalidStateError'); + this.state = 'inactive'; + const type = this.options ? this.options.mimeType : 'audio/mp4'; + this.ondataavailable({ data: this.chunk || new Blob([new Uint8Array(64)], { type }) }); + this.onstop(); + } + }; + } + if (S.audio) { + win.AudioContext = class { + constructor() { + srv.contexts = (srv.contexts || 0) + 1; + } + decodeAudioData(data, ok, bad) { + srv.decodedBytes = data.byteLength; + const d = S.decoded; + const buffer = d && { sampleRate: d.rate, numberOfChannels: d.channels.length, length: d.channels[0].length, getChannelData: ch => d.channels[ch] }; + if (S.audio === 'callback') { + setImmediate(() => (buffer ? ok(buffer) : bad(new Error('EncodingError')))); + return undefined; + } + return buffer ? Promise.resolve(buffer) : Promise.reject(new Error('EncodingError')); + } + close() { + srv.closed = (srv.closed || 0) + 1; + return Promise.resolve(); + } + }; + } + } + const rec = { instances: [], availableCalls: [] }; + if (opts.recognition && opts.recognition !== 'none') { + class Recognition { + constructor() { + this.calls = []; + rec.instances.push(this); + } + start() { + this.calls.push('start'); + if (opts.startThrows) throw new Error('InvalidStateError'); + } + stop() { + this.calls.push('stop'); + } + abort() { + this.calls.push('abort'); + } + } + if (opts.recognition === 'standard') { + Recognition.prototype.processLocally = false; + if (opts.available !== undefined) { + Recognition.available = async options => { + rec.availableCalls.push(options); + return opts.available; + }; + } + win.SpeechRecognition = Recognition; + } else { + win.webkitSpeechRecognition = Recognition; + } + } + const synth = { spoken: [], cancels: 0 }; + if (opts.synth !== false) { + synth.speak = u => synth.spoken.push(u); + synth.cancel = () => synth.cancels++; + synth.getVoices = () => opts.voices || []; + win.speechSynthesis = synth; + win.SpeechSynthesisUtterance = class { + constructor(text) { + this.text = text; + } + }; + } + const transport = { handlers: new Map(), sends: 0 }; + const makeAllen = () => Object.freeze({ + version: 1, + on: (type, fn) => { + if (!transport.handlers.has(type)) transport.handlers.set(type, []); + transport.handlers.get(type).push(fn); + }, + send: () => transport.sends++, + regenerate: () => false, + stop: () => {}, + }); + if (opts.allen !== false) win.allen = makeAllen(); + const emit = (type, detail) => { + for (const fn of transport.handlers.get(type) || []) fn(Object.freeze({ ...detail })); + }; + let inputs = 0; + input.addEventListener('input', () => inputs++); + const context = vm.createContext(win); + vm.runInContext(code, context); + const status = ids.get('allen-voice-status') || page.children.find(el => el.id === 'allen-voice-status'); + return { + win, document, input, form, mic, privacy, toggle, status, rec, synth, transport, guard, store, writes, emit, makeAllen, srv, page, + offer: () => page.children.find(el => el.id === 'allen-voice-browser') || null, + inputs: () => inputs, + last: () => rec.instances[rec.instances.length - 1], + escape() { + const event = new Event('keydown'); + event.key = 'Escape'; + document.dispatchEvent(event); + return event; + }, + type(value) { + input.value = value; + input.dispatchEvent(new Event('input', { bubbles: true })); + }, + }; +} + +const C = {}; +for (const key of ['cloud', 'local', 'none', 'insecure', 'start', 'stop', 'starting', 'listening', 'done', 'nothing', 'cancelled', 'blocked', 'nomic', 'network', 'lang', 'failed', 'fallback', 'hidden', 'typed', 'noSpeak', 'speakOn', 'speakOff', 'remote', 'drake', 'code', 'link', 'rest', 'server', 'recording', 'sending', 'short', 'toolong', 'format', 'unclear', 'rate', 'retry', 'busy', 'offer', 'switched', 'serverdown']) C[key] = COPY_OF(key); + +const tests = []; +const test = (name, fn) => tests.push([name, fn]); + +test('copy: no em or en dash anywhere, cloud note names Google, on-device note only claims on device', () => { + assert.ok(!/[\u2013\u2014]/.test(code), 'no em/en dash in the script'); + assert.match(C.cloud, /Google/); + assert.match(C.cloud, /online/); + assert.doesNotMatch(C.cloud, /on this device|on-device/i); + assert.match(C.local, /on this device/); + assert.match(C.drake, /^Drake/); +}); + +test('unsupported browser: clear unavailable text, mic disabled, a tap does nothing', async () => { + const env = load({ recognition: 'none' }); + await tick(); + assert.equal(env.privacy.textContent, C.none); + assert.equal(env.status.textContent, C.none); + assert.equal(env.mic.disabled, true); + assert.equal(env.mic.getAttribute('aria-disabled'), 'true'); + env.mic.click(); + assert.equal(env.rec.instances.length, 0); + assert.equal(env.win.AllenVoice.mode(), 'none'); +}); + +test('insecure page: recognition present but unusable, says so', async () => { + const env = load({ recognition: 'webkit', secure: false }); + await tick(); + assert.equal(env.privacy.textContent, C.insecure); + assert.equal(env.mic.disabled, true); + env.mic.click(); + assert.equal(env.rec.instances.length, 0); +}); + +test('online recognition: visible cloud disclosure before any tap, no permission or recognizer at load', async () => { + const env = load({ recognition: 'webkit' }); + await tick(); + assert.equal(env.privacy.textContent, C.cloud); + assert.equal(env.win.AllenVoice.mode(), 'cloud'); + assert.equal(env.rec.instances.length, 0, 'no recognizer before the tap'); + assert.deepEqual(env.guard, { media: 0, permission: 0 }); + assert.equal(env.mic.disabled, false); + assert.equal(env.mic.getAttribute('aria-pressed'), 'false'); + assert.equal(env.mic.getAttribute('aria-label'), C.start); + assert.equal(env.mic.getAttribute('aria-describedby'), 'allen-voice-privacy allen-voice-status'); + assert.equal(env.status.getAttribute('role'), 'status'); + assert.equal(env.status.getAttribute('aria-live'), 'polite'); +}); + +test('installed on-device recognizer: local disclosure and processLocally on the tap', async () => { + const env = load({ recognition: 'standard', available: 'available' }); + assert.equal(env.privacy.textContent, C.cloud, 'online until the browser confirms'); + await tick(); + assert.deepEqual(JSON.parse(JSON.stringify(env.rec.availableCalls)), [{ langs: ['en-US'], processLocally: true }]); + assert.equal(env.privacy.textContent, C.local); + assert.equal(env.rec.instances.length, 0); + env.mic.click(); + assert.equal(env.last().processLocally, true); + assert.deepEqual(env.guard, { media: 0, permission: 0 }); +}); + +test('downloadable or missing on-device pack, or no available(): stays online, never claims on device', async () => { + for (const available of ['downloadable', 'downloading', 'unavailable', undefined]) { + const env = load({ recognition: 'standard', available }); + await tick(); + assert.equal(env.privacy.textContent, C.cloud, String(available)); + env.mic.click(); + assert.notEqual(env.last().processLocally, true, String(available)); + } +}); + +test('tap starts, results fill the editable box with input events, tap stops, nothing is sent', async () => { + const env = load({ recognition: 'webkit' }); + env.input.value = 'Hi'; + env.mic.click(); + const r = env.last(); + assert.deepEqual(r.calls, ['start']); + assert.equal(r.lang, 'en-US'); + assert.equal(r.interimResults, true); + assert.equal(env.win.AllenVoice.state(), 'starting'); + assert.equal(env.status.textContent, C.starting); + assert.equal(env.mic.getAttribute('aria-pressed'), 'true'); + assert.equal(env.mic.getAttribute('aria-label'), C.stop); + r.onaudiostart(); + assert.equal(env.win.AllenVoice.state(), 'listening'); + assert.equal(env.status.textContent, C.listening); + r.onresult(results(result('what is', false))); + assert.equal(env.input.value, 'Hi what is'); + assert.equal(env.inputs(), 1); + r.onresult(results(result('what is Omega', true))); + assert.equal(env.input.value, 'Hi what is Omega'); + assert.equal(env.inputs(), 2); + assert.deepEqual(env.input.caret, [16, 16]); + env.mic.click(); + assert.deepEqual(r.calls, ['start', 'stop']); + assert.equal(env.win.AllenVoice.state(), 'stopping'); + r.onend(); + assert.equal(env.win.AllenVoice.state(), 'idle'); + assert.equal(env.status.textContent, C.done); + assert.equal(env.input.value, 'Hi what is Omega'); + assert.equal(env.mic.getAttribute('aria-pressed'), 'false'); + assert.equal(env.transport.sends, 0, 'never sends'); + assert.equal(env.form.submits, 0, 'never submits'); + assert.deepEqual(env.guard, { media: 0, permission: 0 }); + assert.equal(env.writes.length, 0, 'no transcript stored'); +}); + +test('Escape cancels: recognizer aborted, the box restored, Escape consumed', async () => { + const env = load({ recognition: 'webkit' }); + env.input.value = 'x'; + env.mic.click(); + const r = env.last(); + r.onresult(results(result('hello', false))); + assert.equal(env.input.value, 'x hello'); + const key = env.escape(); + assert.equal(key.defaultPrevented, true); + assert.deepEqual(r.calls, ['start', 'abort']); + r.onerror({ error: 'aborted' }); + r.onresult(results(result('hello there', true))); + r.onend(); + assert.equal(env.input.value, 'x'); + assert.equal(env.status.textContent, C.cancelled); + assert.equal(env.transport.sends, 0); + const idle = env.escape(); + assert.equal(idle.defaultPrevented, false, 'Escape is left alone when not listening'); +}); + +test('errors are announced and leave the mic ready', async () => { + const cases = [['not-allowed', C.blocked], ['service-not-allowed', C.blocked], ['audio-capture', C.nomic], ['network', C.network], ['no-speech', C.nothing], ['language-not-supported', C.lang], ['bad-grammar', C.failed]]; + for (const [error, said] of cases) { + const env = load({ recognition: 'webkit' }); + env.mic.click(); + const r = env.last(); + r.onerror({ error }); + r.onend(); + assert.equal(env.status.textContent, said, error); + assert.equal(env.win.AllenVoice.state(), 'idle', error); + assert.equal(env.mic.getAttribute('aria-pressed'), 'false', error); + env.mic.click(); + assert.equal(env.rec.instances.length, 2, `${error}: a second tap starts again`); + } + const env = load({ recognition: 'webkit', startThrows: true }); + env.mic.click(); + assert.equal(env.status.textContent, C.failed); + assert.equal(env.win.AllenVoice.state(), 'idle'); +}); + +test('ending with no words says so', async () => { + const env = load({ recognition: 'webkit' }); + env.mic.click(); + env.last().onend(); + assert.equal(env.status.textContent, C.nothing); +}); + +test('on-device refusal falls back to the online note and waits for another tap', async () => { + const env = load({ recognition: 'standard', available: 'available' }); + await tick(); + env.mic.click(); + const r = env.last(); + r.onerror({ error: 'language-not-supported' }); + r.onend(); + assert.equal(env.win.AllenVoice.mode(), 'cloud'); + assert.equal(env.privacy.textContent, C.cloud); + assert.equal(env.status.textContent, C.fallback); + assert.equal(env.rec.instances.length, 1, 'no automatic online retry'); + env.mic.click(); + assert.notEqual(env.last().processLocally, true); +}); + +test('typing while listening hands the box back to the visitor', async () => { + const env = load({ recognition: 'webkit' }); + env.mic.click(); + const r = env.last(); + r.onresult(results(result('one', false))); + env.type('my own words'); + assert.deepEqual(r.calls, ['start', 'abort']); + r.onresult(results(result('one two', true))); + r.onend(); + assert.equal(env.input.value, 'my own words'); + assert.equal(env.status.textContent, C.typed); +}); + +test('the box limit is respected', async () => { + const env = load({ recognition: 'webkit' }); + env.input.maxLength = 10; + env.mic.click(); + env.last().onresult(results(result('abcdefghijklmnop', true))); + assert.equal(env.input.value, 'abcdefghij'); +}); + +test('hiding the page stops listening and keeps the words', async () => { + const env = load({ recognition: 'webkit' }); + env.mic.click(); + const r = env.last(); + r.onresult(results(result('keep me', true))); + env.document.hidden = true; + env.document.dispatchEvent(new Event('visibilitychange')); + assert.deepEqual(r.calls, ['start', 'abort']); + r.onend(); + assert.equal(env.input.value, 'keep me'); + assert.equal(env.status.textContent, C.hidden); +}); + +const LOCAL = { lang: 'en-US', localService: true, name: 'Local' }; +const REMOTE = { lang: 'en-US', localService: false, name: 'Online' }; + +test('replies read aloud: off by default, nothing spoken, nothing stored', async () => { + const env = load({ recognition: 'webkit', voices: [LOCAL] }); + assert.equal(env.toggle.getAttribute('aria-pressed'), 'false'); + assert.equal(env.win.AllenVoice.speaking(), false); + env.emit('send', { text: 'hi', silent: false }); + env.emit('reply', { text: 'Hello there.', outcome: '' }); + assert.equal(env.synth.spoken.length, 0); + assert.equal(env.writes.length, 0); +}); + +test('turned on: reads replies with an on-device voice, Drake labelled, stops on send, hide and off', async () => { + const env = load({ recognition: 'webkit', voices: [REMOTE, { lang: 'en-GB', localService: true }, LOCAL] }); + env.toggle.click(); + assert.equal(env.toggle.getAttribute('aria-pressed'), 'true'); + assert.deepEqual(env.writes, [['allen-voice-speak', 'on']]); + assert.equal(env.status.textContent, C.speakOn); + assert.equal(env.synth.spoken.length, 1, 'one silent unlock inside the tap'); + assert.equal(env.synth.spoken[0].text, ''); + assert.equal(env.synth.spoken[0].volume, 0); + env.synth.spoken.length = 0; + env.emit('reply', { text: 'Hello **there**. See https://example.org/a\n```js\nsecret()\n```\nBye.', outcome: '' }); + const said = env.synth.spoken.map(u => u.text).join(' '); + assert.match(said, /^Hello there\. See link/); + assert.ok(said.includes(C.code)); + assert.ok(!said.includes('secret')); + assert.ok(env.synth.spoken.every(u => u.voice === LOCAL && u.lang === 'en-US')); + const before = env.synth.cancels; + env.emit('send', { text: 'next', silent: false }); + assert.equal(env.synth.cancels, before + 1, 'a new request stops speech'); + env.synth.spoken.length = 0; + env.emit('human', { text: 'I am here.' }); + assert.equal(env.synth.spoken[0].text, `${C.drake} I am here.`); + env.synth.spoken.length = 0; + env.emit('reply', { text: 'Partial', outcome: 'Stopped.' }); + assert.equal(env.synth.spoken.length, 0, 'a stopped reply is not read'); + const hidden = env.synth.cancels; + env.document.hidden = true; + env.document.dispatchEvent(new Event('visibilitychange')); + assert.equal(env.synth.cancels, hidden + 1); + env.emit('reply', { text: 'Not while hidden.', outcome: '' }); + assert.equal(env.synth.spoken.length, 0); + env.document.hidden = false; + const off = env.synth.cancels; + env.toggle.click(); + assert.equal(env.synth.cancels, off + 1); + assert.equal(env.status.textContent, C.speakOff); + assert.deepEqual(env.writes, [['allen-voice-speak', 'on'], ['allen-voice-speak', null]]); + assert.ok(env.writes.every(([key, value]) => key === 'allen-voice-speak' && (value === 'on' || value === null)), 'only the choice is stored'); +}); + +test('long replies are cut into short utterances and capped', async () => { + const env = load({ recognition: 'webkit', voices: [LOCAL], stored: 'on' }); + const long = 'This sentence is about forty characters. '.repeat(200) + 'x'.repeat(500); + env.emit('reply', { text: long, outcome: '' }); + assert.ok(env.synth.spoken.length > 1); + assert.ok(env.synth.spoken.every(u => u.text.length > 0 && u.text.length <= 200)); + const said = env.synth.spoken.map(u => u.text).join(' '); + assert.ok(said.endsWith(C.rest)); + assert.ok(said.length <= 4000 + C.rest.length + env.synth.spoken.length + 1); +}); + +test('a stored choice restores; a checkbox toggle works; only an online voice is disclosed', async () => { + const restored = load({ recognition: 'webkit', voices: [LOCAL], stored: 'on' }); + assert.equal(restored.toggle.getAttribute('aria-pressed'), 'true'); + restored.emit('reply', { text: 'Back again.', outcome: '' }); + assert.equal(restored.synth.spoken.length, 1); + const box = load({ recognition: 'webkit', voices: [REMOTE], toggle: 'checkbox' }); + assert.equal(box.toggle.checked, false); + box.toggle.click(); + assert.equal(box.toggle.checked, true); + assert.equal(box.status.textContent, `${C.speakOn} ${C.remote}`); + box.emit('reply', { text: 'Online voice.', outcome: '' }); + assert.equal(box.synth.spoken[box.synth.spoken.length - 1].voice, undefined, 'no online voice picked by this file'); +}); + +test('no speech synthesis: the toggle is disabled with a reason', async () => { + const env = load({ recognition: 'webkit', synth: false, stored: 'on' }); + assert.equal(env.toggle.disabled, true); + assert.equal(env.toggle.title, C.noSpeak); + assert.equal(env.toggle.getAttribute('aria-pressed'), 'false'); + env.toggle.click(); + assert.equal(env.win.AllenVoice.speaking(), false); +}); + +test('a mic tap silences speech so the recognizer never hears it', async () => { + const env = load({ recognition: 'webkit', voices: [LOCAL], stored: 'on' }); + const before = env.synth.cancels; + env.mic.click(); + assert.equal(env.synth.cancels, before + 1); +}); + +test('a transport that arrives later is hooked once, on allen-ready', async () => { + const env = load({ recognition: 'webkit', voices: [LOCAL], stored: 'on', allen: false }); + env.win.allen = env.makeAllen(); + env.document.dispatchEvent(new Event('allen-ready')); + env.document.dispatchEvent(new Event('allen-ready')); + assert.equal(env.transport.handlers.get('reply').length, 1); + env.emit('reply', { text: 'Late hello.', outcome: '' }); + assert.equal(env.synth.spoken.length, 1); +}); + +test('a page without the mic still reads aloud; a page without the box does nothing', async () => { + const env = load({ recognition: 'webkit', mic: false, voices: [LOCAL], stored: 'on' }); + env.emit('reply', { text: 'Still here.', outcome: '' }); + assert.equal(env.synth.spoken.length, 1); + assert.equal(env.rec.instances.length, 0); +}); + +test('pronunciation: whole-word Aien is spoken as Ian; the screen and the Drake label keep their text', async () => { + const env = load({ recognition: 'webkit', voices: [LOCAL] }); + env.toggle.click(); + assert.equal(env.status.textContent, C.speakOn); + assert.match(env.status.textContent, /^Aien's replies/, 'displayed copy keeps Aien'); + env.synth.spoken.length = 0; + const detail = { text: "Hi, I'm **Aien**. Aiendale, AIEN and aien stay; Aien's name is Aien.", outcome: '' }; + env.emit('reply', detail); + const said = env.synth.spoken.map(u => u.text).join(' '); + assert.equal(said, "Hi, I'm Ian. Aiendale, AIEN and aien stay; Ian's name is Ian."); + assert.equal(detail.text, "Hi, I'm **Aien**. Aiendale, AIEN and aien stay; Aien's name is Aien.", 'the reply text itself is untouched'); + env.synth.spoken.length = 0; + env.emit('human', { text: 'Aien is right.' }); + assert.equal(env.synth.spoken.map(u => u.text).join(' '), `${C.drake} Ian is right.`); + assert.equal(C.drake, 'Drake wrote:'); + for (const el of env.page.children) assert.doesNotMatch(String(el.textContent), /\bIan\b/, `${el.id} shows no alias`); +}); + +/* Allen's server path. */ +async function settle() { + for (let i = 0; i < 12; i += 1) await tick(); +} +async function serverEnv(server = {}, extra = {}) { + const env = load({ recognition: 'webkit', voices: [LOCAL], ...extra, server: { presence: { online: false, hours: '', handoff: false, transcribe: true }, opus: ['audio/webm;codecs=opus'], ...server } }); + await settle(); + return env; +} +async function record(env, ms, chunk) { + env.mic.click(); + await settle(); + env.srv.clock += ms; + const recorder = env.srv.recorders[env.srv.recorders.length - 1]; + if (recorder && chunk) recorder.chunk = chunk; + env.mic.click(); + await settle(); + return recorder; +} +const posts = env => env.srv.fetches.filter(call => call.url === '/allen/api/transcribe'); +function readWav(buffer) { + const view = new DataView(buffer); + const tag = at => String.fromCharCode(...new Uint8Array(buffer, at, 4)); + const n = view.getUint32(40, true) / 2; + const samples = []; + for (let i = 0; i < n; i += 1) samples.push(view.getInt16(44 + i * 2, true)); + return { + riff: tag(0), size: view.getUint32(4, true), wave: tag(8), fmt: tag(12), fmtSize: view.getUint32(16, true), + format: view.getUint16(20, true), channels: view.getUint16(22, true), rate: view.getUint32(24, true), + byteRate: view.getUint32(28, true), align: view.getUint16(32, true), bits: view.getUint16(34, true), + data: tag(36), bytes: view.getUint32(40, true), total: buffer.byteLength, samples, + }; +} +function constant(rate, seconds, ...values) { + return { rate, channels: values.map(v => new Float32Array(Math.round(rate * seconds)).fill(v)) }; +} + +test('server: presence transcribe true makes it primary, with its exact privacy note, and records nothing', async () => { + const env = await serverEnv(); + assert.equal(env.win.AllenVoice.mode(), 'server'); + assert.equal(env.privacy.textContent, C.server); + assert.ok(C.server.includes("Your clip is sent to Aien's server, turned into text, and never saved: it stays in memory only and is discarded as soon as the text comes back. The text is shown to you; it is not logged.")); + assert.doesNotMatch(code.replace(/\/\*[\s\S]*?\*\//g, ''), /Allen's|reach Allen/, 'no visible copy names Allen'); + assert.doesNotMatch(C.server, /disk/); + assert.equal(env.srv.fetches.length, 1); + assert.equal(env.srv.fetches[0].url, '/allen/api/presence'); + assert.equal(env.srv.fetches[0].init.method, undefined, 'a plain GET, no OPTIONS'); + assert.equal(env.srv.fetches[0].init.cache, 'no-store'); + assert.equal(env.srv.fetches[0].init.credentials, 'omit'); + assert.equal(env.srv.gum, 0, 'no microphone before the tap'); + assert.equal(env.srv.recorders.length, 0); + assert.equal(env.rec.instances.length, 0); + assert.deepEqual(env.guard, { media: 0, permission: 0 }); +}); + +test('server: false, missing, failing or unreachable presence keeps the browser path', async () => { + for (const presence of [{ transcribe: false }, { online: true }, { transcribe: 'true' }, 'error', 'throw']) { + const env = await serverEnv({ presence }); + assert.equal(env.win.AllenVoice.mode(), 'cloud', JSON.stringify(presence)); + assert.equal(env.privacy.textContent, C.cloud); + } + const norecorder = await serverEnv({ recorder: false }); + assert.equal(norecorder.srv.fetches.length, 0, 'no presence request when this browser cannot record'); + assert.equal(norecorder.win.AllenVoice.mode(), 'cloud'); + const noformat = await serverEnv({ opus: [] }); + assert.equal(noformat.win.AllenVoice.mode(), 'cloud', 'no opus and no AudioContext: cannot send an accepted format'); + const insecure = await serverEnv({}, { secure: false }); + assert.equal(insecure.win.AllenVoice.mode(), 'insecure'); + assert.equal(insecure.srv.fetches.length, 0); +}); + +test('server: an installed on-device recognizer still comes first; no browser recognition still gets the server', async () => { + const local = await serverEnv({}, { recognition: 'standard', available: 'available' }); + assert.equal(local.win.AllenVoice.mode(), 'local'); + assert.equal(local.privacy.textContent, C.local); + const bare = await serverEnv({}, { recognition: 'none' }); + assert.equal(bare.win.AllenVoice.mode(), 'server'); + assert.equal(bare.mic.disabled, false); + assert.equal(bare.status.textContent, ''); +}); + +test('server: tap records, tap sends one opus clip, the text fills the box and is not sent', async () => { + const env = await serverEnv({ hold: true }); + env.input.value = 'Hi'; + env.mic.click(); + assert.equal(env.srv.gum, 1, 'microphone asked only on the tap'); + assert.equal(env.status.textContent, C.starting); + await settle(); + const recorder = env.srv.recorders[0]; + assert.equal(recorder.options.mimeType, 'audio/webm;codecs=opus'); + assert.equal(recorder.state, 'recording'); + assert.equal(env.win.AllenVoice.state(), 'listening'); + assert.equal(env.status.textContent, C.recording); + assert.equal(env.mic.getAttribute('aria-pressed'), 'true'); + assert.equal(env.srv.timers[0].ms, 15000); + env.srv.clock += 2000; + recorder.chunk = new Blob([new Uint8Array(1200)], { type: 'audio/webm;codecs=opus' }); + env.mic.click(); + assert.equal(env.status.textContent, C.sending); + await settle(); + assert.equal(env.srv.streams[0].tracks[0].stopped, true, 'microphone released'); + assert.equal(env.srv.timers[0].live, false); + const sent = posts(env); + assert.equal(sent.length, 1); + assert.equal(sent[0].init.method, 'POST'); + assert.equal(sent[0].init.headers['Content-Type'], 'audio/webm;codecs=opus'); + assert.equal(sent[0].init.credentials, 'omit'); + assert.equal(sent[0].init.cache, 'no-store'); + assert.equal(sent[0].init.body.size, 1200); + assert.equal(env.input.value, 'Hi', 'nothing written before the reply'); + env.srv.held.shift()(); + await settle(); + assert.equal(env.input.value, 'Hi hello world'); + assert.equal(env.inputs(), 1); + assert.equal(env.status.textContent, C.done); + assert.equal(env.win.AllenVoice.state(), 'idle'); + assert.equal(env.transport.sends, 0); + assert.equal(env.form.submits, 0); + assert.equal(env.rec.instances.length, 0, 'never also sent to the browser service'); + assert.equal(env.writes.length, 0, 'no transcript stored'); +}); + +test('server: 15 seconds stops and sends; too short or too big never uploads', async () => { + const env = await serverEnv(); + env.mic.click(); + await settle(); + env.srv.clock += 15000; + env.srv.timers[0].fn(); + await settle(); + assert.equal(env.srv.recorders[0].state, 'inactive'); + assert.equal(posts(env).length, 1); + const short = await serverEnv(); + await record(short, 299); + assert.equal(posts(short).length, 0); + assert.equal(short.status.textContent, C.short); + const big = await serverEnv(); + await record(big, 5000, new Blob([new Uint8Array(1048577)], { type: 'audio/webm;codecs=opus' })); + assert.equal(posts(big).length, 0); + assert.equal(big.status.textContent, C.toolong); +}); + +test('server: refusals are announced, never retried elsewhere; the browser service is only offered', async () => { + const cases = [ + [{ status: 413, body: { error: 'too_long', message: 'x' } }, C.toolong], + [{ status: 415, body: { error: 'format', message: 'x' } }, C.format], + [{ status: 422, body: { error: 'audio', message: 'x' } }, C.unclear], + [{ status: 429, body: { error: 'rate', message: 'x', retry_after: 9 }, headers: { 'Retry-After': '7' } }, `${C.rate} ${C.retry} 7 s.`], + [{ status: 429, body: { error: 'rate', message: 'x', retry_after: 9 } }, `${C.rate} ${C.retry} 9 s.`], + [{ status: 503, body: { error: 'busy', message: 'x' } }, C.busy], + [{ status: 400, body: { error: 'bad', message: 'x' } }, C.failed], + [{ status: 200, body: { text: ' ' } }, C.unclear], + ['throw', C.serverdown], + [{ status: 413, html: true }, C.toolong], + [{ status: 429, body: { error: 'rate', message: 'slow down', retry_after: 20 } }, `${C.rate} ${C.retry} 20 s.`], + [{ status: 502, html: true }, C.failed], + [{ status: 200, html: true }, C.failed], + ]; + for (const [answer, said] of cases) { + const env = await serverEnv({ respond: () => answer }); + await record(env, 2000); + assert.equal(env.status.textContent, said, JSON.stringify(answer)); + assert.equal(posts(env).length, 1, 'uploaded once'); + assert.equal(env.rec.instances.length, 0, 'no automatic browser fallback'); + assert.equal(env.win.AllenVoice.mode(), 'server'); + assert.equal(env.privacy.textContent, C.server); + assert.equal(env.input.value, ''); + const offer = env.offer(); + if (answer.status === 200) continue; + assert.ok(offer && offer.hidden === false, 'browser service offered'); + assert.equal(offer.textContent, C.offer); + } + const env = await serverEnv({ respond: () => ({ status: 503, body: {} }) }); + await record(env, 2000); + env.offer().click(); + assert.equal(env.win.AllenVoice.mode(), 'cloud'); + assert.equal(env.privacy.textContent, C.cloud, 'the online note is shown before use'); + assert.equal(env.status.textContent, C.switched); + assert.equal(env.offer().hidden, true); + assert.equal(env.rec.instances.length, 0, 'still nothing until the visitor taps'); + const gum = env.srv.gum; + env.mic.click(); + assert.equal(env.rec.instances.length, 1); + assert.equal(env.srv.gum, gum, 'browser path does not record a clip'); +}); + +test('server: a server failure offers nothing when this browser has no recognition', async () => { + const env = await serverEnv({ respond: () => ({ status: 503, body: {} }) }, { recognition: 'none' }); + await record(env, 2000); + assert.equal(env.status.textContent, C.busy); + assert.equal(env.offer(), null); +}); + +test('server: blocked or missing microphone', async () => { + for (const [media, said] of [['NotAllowedError', C.blocked], ['NotFoundError', C.nomic], ['AbortError', C.failed]]) { + const env = await serverEnv({ media }); + env.mic.click(); + await settle(); + assert.equal(env.status.textContent, said, media); + assert.equal(env.win.AllenVoice.state(), 'idle'); + assert.equal(posts(env).length, 0); + } +}); + +test('server: Escape while recording or sending drops the clip; hiding drops it too', async () => { + const env = await serverEnv(); + env.mic.click(); + await settle(); + const key = env.escape(); + assert.equal(key.defaultPrevented, true); + await settle(); + assert.equal(env.srv.streams[0].tracks[0].stopped, true); + assert.equal(posts(env).length, 0); + assert.equal(env.status.textContent, C.cancelled); + const sending = await serverEnv({ hold: true }); + sending.input.value = 'mine'; + await record(sending, 2000); + assert.equal(posts(sending).length, 1); + sending.escape(); + await settle(); + assert.equal(posts(sending)[0].init.signal.aborted, true); + sending.srv.held.shift()(); + await settle(); + assert.equal(sending.input.value, 'mine', 'a cancelled reply never lands'); + assert.equal(sending.status.textContent, C.cancelled); + const hidden = await serverEnv(); + hidden.mic.click(); + await settle(); + hidden.document.hidden = true; + hidden.document.dispatchEvent(new Event('visibilitychange')); + await settle(); + assert.equal(posts(hidden).length, 0); + assert.equal(hidden.status.textContent, C.hidden); + assert.equal(hidden.srv.streams[0].tracks[0].stopped, true); +}); + +test('server: a tap while the browser is still asking for the microphone cancels and releases it', async () => { + const env = await serverEnv(); + env.mic.click(); + env.mic.click(); + assert.equal(env.status.textContent, C.cancelled); + await settle(); + assert.equal(env.srv.recorders.length, 0); + assert.equal(env.srv.streams[0].tracks[0].stopped, true); +}); + +test('Safari WAV: MP4 clip decoded, mixed to mono, resampled to 16 kHz, exact PCM16 header and samples', async () => { + const env = await serverEnv({ opus: [], audio: true, decoded: constant(48000, 0.5, 0.25, 0.75) }); + assert.equal(env.win.AllenVoice.mode(), 'server'); + const recorder = await record(env, 600, new Blob([new Uint8Array(333)], { type: 'audio/mp4' })); + assert.equal(recorder.options, undefined, 'recorded in the browser default format'); + assert.equal(env.srv.decodedBytes, 333); + assert.equal(env.srv.closed, 1, 'audio context closed'); + const sent = posts(env); + assert.equal(sent.length, 1); + assert.equal(sent[0].init.headers['Content-Type'], 'audio/wav'); + const w = readWav(await sent[0].init.body.arrayBuffer()); + assert.deepEqual( + { riff: w.riff, size: w.size, wave: w.wave, fmt: w.fmt, fmtSize: w.fmtSize, format: w.format, channels: w.channels, rate: w.rate, byteRate: w.byteRate, align: w.align, bits: w.bits, data: w.data, bytes: w.bytes, total: w.total }, + { riff: 'RIFF', size: 36 + 16000, wave: 'WAVE', fmt: 'fmt ', fmtSize: 16, format: 1, channels: 1, rate: 16000, byteRate: 32000, align: 2, bits: 16, data: 'data', bytes: 16000, total: 44 + 16000 }, + ); + assert.equal(w.samples.length, 8000); + assert.ok(w.samples.every(s => s === 16384), 'mean of 0.25 and 0.75 is 0.5 -> round(0.5 * 32767) = 16384'); + assert.equal(env.input.value, 'hello world'); +}); + +test('Safari WAV: tone keeps its pitch and level; clamping; 44.1 kHz and 8 kHz inputs; callback decode', async () => { + const rate = 48000; + const tone = new Float32Array(rate); + for (let i = 0; i < rate; i += 1) tone[i] = 0.8 * Math.sin(2 * Math.PI * 440 * i / rate); + const env = await serverEnv({ opus: [], audio: true, decoded: { rate, channels: [tone] } }); + await record(env, 1100); + const w = readWav(await posts(env)[0].init.body.arrayBuffer()); + assert.equal(w.samples.length, 16000); + let crossings = 0; + for (let i = 1; i < w.samples.length; i += 1) if ((w.samples[i - 1] < 0) !== (w.samples[i] < 0)) crossings += 1; + assert.ok(Math.abs(crossings - 880) <= 2, `440 Hz has 880 sign changes per second, saw ${crossings}`); + const peak = Math.max(...w.samples.map(Math.abs)); + assert.ok(peak > 0.8 * 32767 * 0.97 && peak <= 0.8 * 32767 + 1, `level kept, peak ${peak}`); + + const loud = new Float32Array(16000); + for (let i = 0; i < loud.length; i += 1) loud[i] = i % 2 ? -1.5 : 1.5; + const clamp = await serverEnv({ opus: [], audio: 'callback', decoded: { rate: 16000, channels: [loud] } }); + await record(clamp, 1100); + const c = readWav(await posts(clamp)[0].init.body.arrayBuffer()); + assert.equal(c.samples[0], 32767); + assert.equal(c.samples[1], -32768); + + const cd = await serverEnv({ opus: [], audio: true, decoded: constant(44100, 1, 0.1) }); + await record(cd, 1100); + const d = readWav(await posts(cd)[0].init.body.arrayBuffer()); + assert.equal(d.samples.length, Math.floor(44100 / (44100 / 16000))); + assert.ok(d.samples.every(s => Math.abs(s - 3277) <= 1), 'DC 0.1 stays round(0.1 * 32767) = 3277'); + + const ramp = new Float32Array(8000); + for (let i = 0; i < ramp.length; i += 1) ramp[i] = i / 10000; + const phone = await serverEnv({ opus: [], audio: true, decoded: { rate: 8000, channels: [ramp] } }); + await record(phone, 1100); + const p = readWav(await posts(phone)[0].init.body.arrayBuffer()); + assert.equal(p.samples.length, 16000); + assert.equal(p.samples[1], Math.round(0.00005 * 32767), 'linear midpoint between ramp samples 0 and 1'); + assert.equal(p.samples[2], Math.round(0.0001 * 32767)); +}); + +test('Safari WAV: undecodable or too-short audio is never uploaded', async () => { + const broken = await serverEnv({ opus: [], audio: true, decoded: null }); + await record(broken, 2000); + assert.equal(posts(broken).length, 0); + assert.equal(broken.status.textContent, C.format); + const short = await serverEnv({ opus: [], audio: true, decoded: constant(48000, 0.2, 0.3) }); + await record(short, 2000); + assert.equal(posts(short).length, 0); + assert.equal(short.status.textContent, C.short); +}); + +(async () => { + let failed = 0; + for (const [name, fn] of tests) { + try { + await fn(); + console.log(`ok ${name}`); + } catch (error) { + failed += 1; + console.log(`FAIL ${name}\n ${error && error.stack ? error.stack.split('\n').slice(0, 3).join('\n ') : error}`); + } + } + console.log(`${failed ? 'VOICE TEST FAIL' : 'VOICE TEST PASS'} tests=${tests.length} pass=${tests.length - failed} fail=${failed}`); + process.exit(failed ? 1 : 0); +})(); diff --git a/om/allen-voice/voice.om b/om/allen-voice/voice.om new file mode 100644 index 0000000..27632e5 --- /dev/null +++ b/om/allen-voice/voice.om @@ -0,0 +1,324 @@ +note Allen voice generator: emits public/js/allen-voice.js on fd 1. +note The script is speech typing into Allen's message box and, when the visitor +note turns it on, replies read aloud by the browser's speech synthesis. +note ~N~ tokens in the js texts expand field N of vcfg, in order: +note 0 mic button id, 1 privacy note id, 2 read-aloud toggle id, 3 voice status +note id, 4 message box id, 5 local storage key for the read-aloud choice, +note 6 most characters read aloud per reply, 7 characters per utterance, +note 8 to 34 the visible sentences: 8 online recognition, 9 on-device recognition, +note 10 no recognition, 11 not a secure page, 12 start label, 13 stop label, +note 14 starting, 15 listening, 16 done, 17 nothing heard, 18 cancelled, +note 19 microphone blocked, 20 no microphone, 21 network, 22 language, 23 other +note error, 24 on-device fell back to online, 25 page hidden, 26 visitor typed, +note 27 no speech synthesis, 28 reading on, 29 reading off, 30 no on-device voice, +note 31 the label before Drake's own messages, 32 code skipped, 33 link, 34 rest. +note Allen's server transcription (POST raw audio, contract from the gateway): +note 35 presence path, whose JSON field transcribe is true only when the gateway +note runs the pinned recognizer; 36 transcribe path; 37 most clip bytes; 38 most +note clip milliseconds; 39 fewest clip milliseconds; 40 WAV sample rate in hertz. +note 41 to 53 sentences: 41 server privacy note (the gateway's own wording), +note 42 recording, 43 sending, 44 too short, 45 too long, 46 format refused, +note 47 no words in the clip, 48 rate limited, 49 retry lead, 50 busy, 51 the +note offer to use the browser's speech service instead, 52 switched, 53 server +note unreachable. 54 the spoken form of the name Aien (said like Ian): read +note aloud only, never displayed. +note vcheck refuses the table before anything is written: ids 0 to 5 are +note lowercase letters, digits and hyphens; 6, 7 and 37 to 40 are decimal digits; +note 35 and 36 are paths of lowercase letters, hyphens and slashes; 8 to 34 and +note 41 to 54 never hold a double quote, a backslash or a newline, because the js +note texts put them in double-quoted strings. raw refuses an em or en dash anywhere +note in the output (UTF-8 E2 80 94 and E2 80 93). The sentences are the site's +note copy: first person singular, Drake's voice; the assistant is named Aien +note (renamed from Allen, 2026-10-26), never "I". Internal ids and paths keep allen. +note Source language checked at omega-mv 55f9b0af47de70a3d06357985cf99ae3e45c016f. +text vcfg "allen-mic|allen-voice-privacy|allen-speak|allen-voice-status|allen-input|allen-voice-speak|4000|200|Voice typing uses your browser's online speech service: in Chrome your audio goes to Google's servers to become text, and other browsers may send it to their maker. My site never receives your audio, only the words you choose to send.|Voice typing runs on this device: your browser turns speech into text here and your audio does not leave it. Only the words you choose to send reach Aien.|Voice typing isn't available in this browser. You can still type your message.|Voice typing needs the secure https page. You can still type your message.|Start voice typing|Stop voice typing|Starting. Your browser may ask to use the microphone.|Listening. Speak, then tap the microphone again to stop, or press Escape to cancel.|Done. Your words are in the message box: check them, then press Send.|No words came through. Tap the microphone to try again.|Cancelled. The message box is back as it was.|The microphone is blocked for this site. Allow it in your browser's site settings, or type instead.|No microphone was found. You can type instead.|Your browser's speech service could not be reached. Check your connection, or type instead.|Voice typing doesn't support this page's language in your browser.|Voice typing stopped with an error. You can type instead.|On-device voice typing isn't ready in this browser, so it would use the online speech service. Read the privacy note, then tap the microphone again if that's fine.|Voice typing stopped because the page went to the background.|Voice typing stopped because you started typing.|Reading replies aloud isn't available in this browser.|Aien's replies will be read aloud by your browser's voice.|Replies are no longer read aloud.|Your browser lists no on-device voice for this language, so it may send reply text to its online voice service.|Drake wrote:|(code block skipped)|link|The rest is on the screen.|/allen/api/presence|/allen/api/transcribe|1048576|15000|300|16000|Voice typing records only after you tap the microphone, for up to 15 seconds. Your clip is sent to Aien's server, turned into text, and never saved: it stays in memory only and is discarded as soon as the text comes back. The text is shown to you; it is not logged.|Recording. Tap the microphone again when you finish, or press Escape to cancel.|Turning your words into text.|That clip was too short. Tap the microphone and speak a little longer.|That clip was too long for Aien's server. Try a shorter one.|Aien's server could not read this browser's audio format.|Aien's server could not make out any words in that clip.|Aien's server is taking too many clips right now.|Try again in|Aien's server is busy right now. Try again in a moment.|Use your browser's speech service instead|Switched to your browser's speech service. Read the privacy note, then tap the microphone if that's fine.|Aien's server could not be reached. Check your connection, or type instead.|Ian|" +const VFIELDS ulong 55 +global output uchar 65536 +global used ulong 1 +global marker ulong 2 +global tail uchar 2 + +fn flush to void +p = ulong 0 +while lt p get used 0 bound 65536 +n = write 1 output p sub get used 0 p +if le n 0 +trap 3 +end +p = add p ulong n +end +put used 0 0 +end + +note raw: one output byte; trap 12 completes an em or en dash. +fn raw c uchar to void +if or eq c 147 eq c 148 +if eq get tail 1 128 +if eq get tail 0 226 +trap 12 +end +end +end +put tail 0 get tail 1 +put tail 1 c +if eq get used 0 len output +flush +end +put output get used 0 c +put used 0 add get used 0 1 +end + +note idbyte: a-z, 0-9 or hyphen. digit: 0-9. copybyte: not quote, backslash, newline. +fn idbyte c uchar to bool +if and ge c 97 le c 122 +ret true +end +ret or digit c eq c 45 +end + +fn digit c uchar to bool +ret and ge c 48 le c 57 +end + +fn copybyte c uchar to bool +ret not or or eq c 34 eq c 92 eq c 10 +end + +note okbyte: whether c may stand in field k; trap 9 past the last field. +fn okbyte k ulong c uchar to bool +if le k 5 +ret idbyte c +end +if le k 7 +ret digit c +end +if le k 34 +ret copybyte c +end +if le k 36 +ret pathbyte c +end +if le k 40 +ret digit c +end +if lt k VFIELDS +ret copybyte c +end +trap 9 +end + +note pathbyte: a-z, hyphen or slash. +fn pathbyte c uchar to bool +if and ge c 97 le c 122 +ret true +end +ret or eq c 45 eq c 47 +end + +note vcheck: exactly VFIELDS pipe-terminated fields, none empty, each byte allowed. +fn vcheck to void +k = ulong 0 +w = ulong 0 +p = ulong 0 +while lt p len vcfg +c = get vcfg p +if eq c 124 +if eq w 0 +trap 8 +end +k = add k 1 +w = 0 +else +if not okbyte k c +trap 10 +end +w = add w 1 +end +p = add p 1 +end +if ne k VFIELDS +trap 11 +end +end + +note field: the k-th pipe-terminated field of vcfg; a missing field traps. +fn field k ulong to void +p = ulong 0 +i = ulong 0 +while lt p len vcfg +c = get vcfg p +if eq c 124 +if eq i k +ret +end +i = add i 1 +else +if eq i k +raw c +end +end +p = add p 1 +end +trap 3 +end + +note byteput: ~N~ expands field N; any other byte is copied. +fn byteput c uchar to void +if eq c 126 +if eq get marker 0 0 +put marker 0 1 +put marker 1 0 +else +field get marker 1 +put marker 0 0 +end +else +if eq get marker 0 1 +if not digit c +trap 3 +end +put marker 1 add mul get marker 1 10 ulong sub c 48 +else +raw c +end +end +end + +note JavaScript part 0 +text js0 "/* Allen voice: speech typing into the message box, and replies read aloud.\n *\n * Generated by om/allen-voice/voice.om; never hand-edit. Element ids, limits\n * and every visible sentence come from the vcfg table in voice.om.\n *\n * Speech typing. The microphone is touched only after a tap on the mic\n * button: nothing here asks for it, or for any permission, when the page\n * loads. Recognized words go into the message box as editable text, with an\n * input event, and are never sent: the visitor presses Send. The privacy note\n * says where the audio goes before the first tap. Three engines, chosen\n * before any tap: the browser's on-device recognizer when it reports one\n * installed for the language (processLocally set; the audio stays here);\n * else Allen's server when the gateway's presence says transcribe is true\n * (one clip per tap, POSTed once, Safari's MP4 turned into 16 kHz WAV here);\n * else the browser's online speech service (Chrome sends audio to Google).\n * A server failure never retries elsewhere: the browser's recognition is\n * offered as a button, with its own note, and needs another tap.\n *\n * Replies read aloud. Off unless the visitor turns it on; the choice (on or\n * off, nothing else) is the only thing kept, in local storage. Uses the\n * browser's speech synthesis, never a recording of anyone. Allen's replies are\n * read as they are; a message Drake typed himself is read after the words\n * \"Drake wrote:\" so a synthetic voice is never taken for either of them.\n * Speech stops on a new request, a mic tap, turning it off, or when the page\n * is hidden. No transcript and no audio is stored or sent by this file.\n */\n(() => {\n 'use strict';\n const byId = id => document.getElementById(id);\n const input = byId('~4~');\n const mic = byId('~0~');\n const privacy = byId('~1~');\n" + +note JavaScript part 1 +text js1 " const toggle = byId('~2~');\n if (!input || (!mic && !toggle)) return;\n const STORE = '~5~';\n const SPEAK_MAX = ~6~;\n const CHUNK = ~7~;\n const PRESENCE = '~35~';\n const ENDPOINT = '~36~';\n const MAX_BYTES = ~37~;\n const MAX_MS = ~38~;\n const MIN_MS = ~39~;\n const RATE = ~40~;\n const COPY = Object.freeze({\n cloud: \"~8~\",\n local: \"~9~\",\n none: \"~10~\",\n insecure: \"~11~\",\n start: \"~12~\",\n stop: \"~13~\",\n starting: \"~14~\",\n listening: \"~15~\",\n done: \"~16~\",\n nothing: \"~17~\",\n cancelled: \"~18~\",\n blocked: \"~19~\",\n nomic: \"~20~\",\n network: \"~21~\",\n lang: \"~22~\",\n failed: \"~23~\",\n fallback: \"~24~\",\n hidden: \"~25~\",\n typed: \"~26~\",\n noSpeak: \"~27~\",\n speakOn: \"~28~\",\n speakOff: \"~29~\",\n remote: \"~30~\",\n drake: \"~31~\",\n code: \"~32~\",\n link: \"~33~\",\n rest: \"~34~\",\n server: \"~41~\",\n recording: \"~42~\",\n sending: \"~43~\",\n short: \"~44~\",\n toolong: \"~45~\",\n format: \"~46~\",\n unclear: \"~47~\",\n rate: \"~48~\",\n retry: \"~49~\",\n busy: \"~50~\",\n offer: \"~51~\",\n switched: \"~52~\",\n serverdown: \"~53~\",\n });\n\n function lang() {\n const page = document.documentElement && document.documentElement.lang;\n const nav = window.navigator && window.navigator.language;\n return String(page || nav || 'en-US');\n }\n\n /* One live region for both halves; made here when the page has none. */\n let status = byId('~3~');\n if (!status) {\n status = document.createElement('p');\n status.id = '~3~';\n status.className = 'allen-voice-status';\n const after = privacy || mic || toggle;\n if (after.parentNode) after.parentNode.insertBefore(status, after.nextSibling);\n }\n status.setAttribute('role', 'status');\n status.setAttribute('aria-live', 'polite');\n function say(text) {\n if (status.textContent !== text) status.textContent = text;\n }\n\n" + +note JavaScript part 2 +text js2 " /* Speech typing. */\n const Recognition = typeof window.SpeechRecognition === 'function' ? window.SpeechRecognition\n : typeof window.webkitSpeechRecognition === 'function' ? window.webkitSpeechRecognition : null;\n const secure = window.isSecureContext === true;\n const canLocal = !!Recognition && Recognition === window.SpeechRecognition\n && typeof Recognition.available === 'function' && 'processLocally' in Recognition.prototype;\n let mode = !Recognition ? 'none' : !secure ? 'insecure' : 'cloud';\n let browserMode = mode;\n let rec = null;\n let clip = null;\n let state = 'idle';\n let base = '';\n let wrote = null;\n let writing = false;\n let heard = false;\n let ending = '';\n\n function showPrivacy() {\n if (privacy) privacy.textContent = COPY[mode];\n if (!mic) return;\n const off = mode === 'none' || mode === 'insecure';\n mic.disabled = off;\n mic.setAttribute('aria-disabled', off ? 'true' : 'false');\n mic.dataset.voice = mode;\n const described = [privacy && privacy.id, status.id].filter(Boolean).join(' ');\n if (described) mic.setAttribute('aria-describedby', described);\n }\n function setState(next, message) {\n state = next;\n if (mic) {\n const live = next !== 'idle';\n mic.dataset.state = next;\n mic.setAttribute('aria-pressed', live ? 'true' : 'false');\n mic.setAttribute('aria-label', live ? COPY.stop : COPY.start);\n mic.title = live ? COPY.stop : COPY.start;\n }\n if (message !== undefined) say(message);\n }\n\n /* Only an installed on-device recognizer counts as on device. */\n async function probeLocal() {\n if (!canLocal || mode !== 'cloud') return false;\n try {\n return (await Recognition.available({ langs: [lang()], processLocally: true })) === 'available';\n } catch (_) {\n return false;\n }\n }\n" + +note JavaScript part 3 +text js3 " /* Allen's server is used only when the gateway's presence says transcribe is\n true and this browser can record after a tap; nothing is recorded to find\n out. An absent or false field keeps the browser's own recognition. */\n function canRecord() {\n const media = window.navigator && window.navigator.mediaDevices;\n return secure && !!media && typeof media.getUserMedia === 'function' && typeof window.MediaRecorder === 'function'\n && (!!opusType() || typeof (window.AudioContext || window.webkitAudioContext) === 'function');\n }\n async function probeServer() {\n if (!canRecord() || typeof window.fetch !== 'function') return false;\n try {\n const response = await window.fetch(PRESENCE, { cache: 'no-store', credentials: 'omit', headers: { Accept: 'application/json' } });\n const reply = response.ok ? await response.json() : null;\n return !!reply && typeof reply === 'object' && reply.transcribe === true;\n } catch (_) {\n return false;\n }\n }\n /* On device first (the audio stays here), then Allen's server, then the\n browser's online service. Decided once, before any tap is needed. */\n async function probe() {\n const [local, server] = await Promise.all([probeLocal(), probeServer()]);\n if (rec || clip || state !== 'idle') return;\n if (local) browserMode = 'local';\n const next = local ? 'local' : server ? 'server' : mode;\n if (next === mode) return;\n mode = next;\n showPrivacy();\n say('');\n }\n\n function joined(text) {\n const said = String(text).replace(/\\s+/g, ' ').trim();\n if (!said) return base;\n const gap = base && !/\\s$/.test(base) ? ' ' : '';\n let value = base + gap + said;\n const max = input.maxLength;\n if (max > 0 && value.length > max) value = value.slice(0, max);\n return value;\n }\n" + +note JavaScript part 4 +text js4 " function write(value) {\n if (input.value === value) return;\n writing = true;\n input.value = value;\n wrote = value;\n try {\n input.setSelectionRange(value.length, value.length);\n } catch (_) {\n /* Some input types have no selection. */\n }\n input.dispatchEvent(new Event('input', { bubbles: true }));\n writing = false;\n }\n\n const ERRORS = Object.freeze({\n 'not-allowed': 'blocked',\n 'service-not-allowed': 'blocked',\n 'audio-capture': 'nomic',\n network: 'network',\n 'language-not-supported': 'lang',\n 'no-speech': 'nothing',\n });\n\n function startBrowser() {\n if (!Recognition || (mode !== 'cloud' && mode !== 'local') || rec) return;\n stopSpeaking();\n const r = new Recognition();\n r.lang = lang();\n r.continuous = false;\n r.interimResults = true;\n r.maxAlternatives = 1;\n if (mode === 'local') r.processLocally = true;\n base = input.value;\n wrote = null;\n heard = false;\n ending = '';\n r.onaudiostart = () => {\n if (rec === r && state === 'starting') setState('listening', COPY.listening);\n };\n r.onstart = r.onaudiostart;\n r.onresult = event => {\n if (rec !== r || ending) return;\n let text = '';\n for (let i = 0; i < event.results.length; i += 1) {\n const best = event.results[i] && event.results[i][0];\n if (best && typeof best.transcript === 'string') text += best.transcript;\n }\n if (text.trim()) heard = true;\n write(joined(text));\n };\n r.onerror = event => {\n if (rec !== r) return;\n const code = event && typeof event.error === 'string' ? event.error : '';\n if (code === 'aborted') return;\n if (mode === 'local' && (code === 'language-not-supported' || code === 'service-not-allowed')) {\n mode = 'cloud';\n browserMode = 'cloud';\n showPrivacy();\n ending = ending || 'fallback';\n return;\n }\n ending = ending || ERRORS[code] || 'failed';\n };\n r.onend = () => {\n if (rec !== r) return;\n rec = null;\n if (ending === 'cancelled') write(base);\n const said = ending ? COPY[ending] : heard ? COPY.done : COPY.nothing;\n setState('idle', said);\n };\n rec = r;\n setState('starting', COPY.starting);\n try {\n r.start();\n } catch (_) {\n rec = null;\n setState('idle', COPY.failed);\n }\n }\n" + +note JavaScript part 5 +text js5 " function stop() {\n if (!rec) return;\n if (state === 'stopping') {\n rec.abort();\n return;\n }\n setState('stopping');\n rec.stop();\n }\n function end(why) {\n if (clip) {\n dropClip(why);\n return;\n }\n if (!rec) return;\n ending = why;\n setState('stopping');\n rec.abort();\n }\n\n /* Allen's server. One clip per tap, recorded only between the taps, held in\n memory, sent once to ENDPOINT and never anywhere else. A refused or failed\n clip is dropped; the browser's own recognition is only offered, as a\n button, and the visitor has to tap the microphone again after reading\n its privacy note. */\n function opusType() {\n const MR = window.MediaRecorder;\n if (typeof MR !== 'function' || typeof MR.isTypeSupported !== 'function') return '';\n for (const type of ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus']) {\n try {\n if (MR.isTypeSupported(type)) return type;\n } catch (_) {\n /* Try the next type. */\n }\n }\n return '';\n }\n function now() {\n return window.performance && typeof window.performance.now === 'function' ? window.performance.now() : Date.now();\n }\n function release(c) {\n if (c.timer) window.clearTimeout(c.timer);\n c.timer = 0;\n if (c.stream) {\n for (const track of c.stream.getTracks()) track.stop();\n }\n c.stream = null;\n }\n function dropClip(why) {\n const c = clip;\n clip = null;\n c.dropped = true;\n if (c.controller) c.controller.abort();\n if (c.recorder && c.recorder.state !== 'inactive') {\n try {\n c.recorder.stop();\n } catch (_) {\n /* Already stopped. */\n }\n }\n release(c);\n c.chunks = [];\n setState('idle', COPY[why] || COPY.cancelled);\n }\n function done(c, said) {\n if (clip === c) clip = null;\n setState('idle', said);\n }\n" + +note JavaScript part 6 +text js6 " async function startServer() {\n stopSpeaking();\n const c = { stream: null, recorder: null, chunks: [], mime: '', began: 0, ms: 0, timer: 0, controller: null, dropped: false };\n clip = c;\n hideOffer();\n setState('starting', COPY.starting);\n let stream = null;\n try {\n stream = await window.navigator.mediaDevices.getUserMedia({ audio: { channelCount: 1, echoCancellation: true, noiseSuppression: true } });\n } catch (error) {\n if (clip !== c) return;\n const name = error && error.name;\n done(c, name === 'NotAllowedError' || name === 'SecurityError' ? COPY.blocked : name === 'NotFoundError' || name === 'OverconstrainedError' ? COPY.nomic : COPY.failed);\n return;\n }\n c.stream = stream;\n if (clip !== c) {\n release(c);\n return;\n }\n c.mime = opusType();\n try {\n c.recorder = c.mime ? new window.MediaRecorder(stream, { mimeType: c.mime, audioBitsPerSecond: 32000 }) : new window.MediaRecorder(stream);\n c.recorder.ondataavailable = event => {\n if (event.data && event.data.size) c.chunks.push(event.data);\n };\n c.recorder.onstop = () => {\n finishClip(c);\n };\n c.recorder.start();\n } catch (_) {\n release(c);\n done(c, COPY.failed);\n return;\n }\n c.began = now();\n c.timer = window.setTimeout(() => {\n if (clip === c && state === 'listening') stopClip();\n }, MAX_MS);\n setState('listening', COPY.recording);\n }\n function stopClip() {\n const c = clip;\n if (!c || !c.recorder) return;\n c.ms = now() - c.began;\n setState('sending', COPY.sending);\n try {\n c.recorder.stop();\n } catch (_) {\n release(c);\n done(c, COPY.failed);\n }\n }\n async function finishClip(c) {\n release(c);\n if (clip !== c || c.dropped) return;\n const type = c.mime || (c.chunks[0] && c.chunks[0].type) || '';\n const recorded = new Blob(c.chunks, { type });\n c.chunks = [];\n if (c.ms < MIN_MS || !recorded.size) {\n done(c, COPY.short);\n return;\n }\n let body = recorded;\n let sent = c.mime;\n if (!sent) {\n let samples = null;\n try {\n samples = await decodeMono(recorded);\n } catch (_) {\n samples = null;\n }\n if (clip !== c) return;\n if (!samples) {\n done(c, COPY.format);\n return;\n }\n const pcm = resample(samples.data, samples.rate);\n if (pcm.length * 1000 < MIN_MS * RATE) {\n done(c, COPY.short);\n return;\n }\n body = new Blob([wav(pcm)], { type: 'audio/wav' });\n sent = 'audio/wav';\n }\n if (body.size > MAX_BYTES) {\n done(c, COPY.toolong);\n return;\n }\n upload(c, body, sent);\n }\n" + +note JavaScript part 7 +text js7 " async function upload(c, body, type) {\n c.controller = new AbortController();\n let response = null;\n let reply = null;\n try {\n response = await window.fetch(ENDPOINT, { method: 'POST', headers: { 'Content-Type': type, Accept: 'application/json' }, body, cache: 'no-store', credentials: 'omit', signal: c.controller.signal });\n reply = await response.json().catch(() => null);\n } catch (_) {\n if (clip !== c) return;\n offerBrowser();\n done(c, COPY.serverdown);\n return;\n }\n if (clip !== c) return;\n if (response.ok && reply && typeof reply.text === 'string') {\n const said = reply.text.trim();\n if (!said) {\n done(c, COPY.unclear);\n return;\n }\n base = input.value;\n write(joined(said));\n done(c, COPY.done);\n return;\n }\n offerBrowser();\n done(c, refused(response, reply));\n }\n function refused(response, reply) {\n const code = response.status;\n if (code === 413) return COPY.toolong;\n if (code === 415) return COPY.format;\n if (code === 422) return COPY.unclear;\n if (code === 503) return COPY.busy;\n if (code === 429) {\n const header = Number.parseInt(response.headers && response.headers.get ? response.headers.get('Retry-After') || '' : '', 10);\n const field = reply && Number.isSafeInteger(reply.retry_after) ? reply.retry_after : NaN;\n const wait = Number.isSafeInteger(header) && header > 0 ? header : field > 0 ? field : 0;\n return wait && wait <= 3600 ? `${COPY.rate} ${COPY.retry} ${wait} s.` : COPY.rate;\n }\n return COPY.failed;\n }\n\n /* Safari records only AAC in MP4, which the gateway refuses: the clip is\n decoded here, mixed to mono, resampled to RATE and sent as 16-bit PCM WAV. */\n function decodeMono(blob) {\n const Ctx = window.AudioContext || window.webkitAudioContext;\n if (typeof Ctx !== 'function') return Promise.reject(new Error('no audio context'));\n return blob.arrayBuffer().then(data => {\n const ctx = new Ctx();\n const closed = () => {\n if (typeof ctx.close === 'function') ctx.close().catch(() => {});\n };\n return new Promise((ok, bad) => {\n const pending = ctx.decodeAudioData(data, ok, bad);\n if (pending && typeof pending.then === 'function') pending.then(ok, bad);\n }).then(buffer => {\n closed();\n const channels = Math.max(1, buffer.numberOfChannels | 0);\n const out = new Float32Array(buffer.length);\n for (let ch = 0; ch < channels; ch += 1) {\n const part = buffer.getChannelData(ch);\n for (let i = 0; i < out.length; i += 1) out[i] += part[i] / channels;\n }\n return { data: out, rate: buffer.sampleRate };\n }, error => {\n closed();\n throw error;\n });\n });\n }\n" + +note JavaScript part 8 +text js8 " /* Down: each output sample is the mean of the input span it covers (a box\n filter weighted by overlap). Up: linear interpolation. */\n function resample(data, rate) {\n if (!(rate > 0) || rate === RATE) return Float32Array.from(data);\n const ratio = rate / RATE;\n const n = Math.floor(data.length / ratio);\n const out = new Float32Array(n);\n if (ratio < 1) {\n for (let i = 0; i < n; i += 1) {\n const at = i * ratio;\n const k = Math.floor(at);\n const next = k + 1 < data.length ? data[k + 1] : data[k];\n out[i] = data[k] + (next - data[k]) * (at - k);\n }\n return out;\n }\n for (let i = 0; i < n; i += 1) {\n const from = i * ratio;\n const to = from + ratio;\n let sum = 0;\n for (let k = Math.floor(from); k < to && k < data.length; k += 1) {\n sum += data[k] * (Math.min(to, k + 1) - Math.max(from, k));\n }\n out[i] = sum / ratio;\n }\n return out;\n }\n /* RIFF WAVE, PCM format 1, one channel, RATE hertz, 16 bits, little-endian;\n samples clamped to -1..1, negative scaled by 32768, positive by 32767. */\n function wav(samples) {\n const bytes = samples.length * 2;\n const view = new DataView(new ArrayBuffer(44 + bytes));\n const tag = (at, text) => {\n for (let i = 0; i < 4; i += 1) view.setUint8(at + i, text.charCodeAt(i));\n };\n tag(0, 'RIFF');\n view.setUint32(4, 36 + bytes, true);\n tag(8, 'WAVE');\n tag(12, 'fmt ');\n view.setUint32(16, 16, true);\n view.setUint16(20, 1, true);\n view.setUint16(22, 1, true);\n view.setUint32(24, RATE, true);\n view.setUint32(28, RATE * 2, true);\n view.setUint16(32, 2, true);\n view.setUint16(34, 16, true);\n tag(36, 'data');\n view.setUint32(40, bytes, true);\n for (let i = 0; i < samples.length; i += 1) {\n const s = Math.max(-1, Math.min(1, samples[i] || 0));\n view.setInt16(44 + i * 2, s < 0 ? Math.round(s * 32768) : Math.round(s * 32767), true);\n }\n return view.buffer;\n }\n\n" + +note JavaScript part 9 +text js9 " /* The browser's own recognition, offered after Allen's server failed. */\n let offer = null;\n function offerBrowser() {\n if (!Recognition || !secure || !mic) return;\n if (!offer) {\n offer = document.createElement('button');\n offer.type = 'button';\n offer.id = 'allen-voice-browser';\n offer.className = 'allen-tool allen-voice-browser';\n offer.textContent = COPY.offer;\n offer.addEventListener('click', () => {\n if (state !== 'idle') return;\n mode = browserMode;\n hideOffer();\n showPrivacy();\n say(COPY.switched);\n });\n if (status.parentNode) status.parentNode.insertBefore(offer, status.nextSibling);\n }\n offer.hidden = false;\n }\n function hideOffer() {\n if (offer) offer.hidden = true;\n }\n\n if (mic) {\n showPrivacy();\n setState('idle');\n if (mode === 'none' || mode === 'insecure') say(COPY[mode]);\n mic.addEventListener('click', event => {\n event.preventDefault();\n if (state === 'idle') {\n if (mode === 'server') startServer();\n else startBrowser();\n } else if (clip && state === 'listening') stopClip();\n else if (clip) dropClip('cancelled');\n else stop();\n });\n input.addEventListener('input', () => {\n if (!writing && rec && input.value !== wrote) end('typed');\n });\n document.addEventListener('keydown', event => {\n if (event.key !== 'Escape' || (!rec && !clip)) return;\n event.preventDefault();\n event.stopPropagation();\n end('cancelled');\n }, true);\n probe();\n }\n\n /* Replies read aloud. */\n const synth = window.speechSynthesis && typeof window.SpeechSynthesisUtterance === 'function' ? window.speechSynthesis : null;\n const box = !!toggle && toggle.tagName === 'INPUT' && String(toggle.type).toLowerCase() === 'checkbox';\n" + +note JavaScript part 10 +text js10 " let speaking = false;\n let unlocked = false;\n /* Aien is said like Ian: speech gets the spoken form, the screen keeps Aien. */\n const SAYNAME = '~54~';\n\n function stored() {\n try {\n return window.localStorage.getItem(STORE) === 'on';\n } catch (_) {\n return false;\n }\n }\n function store(on) {\n try {\n if (on) window.localStorage.setItem(STORE, 'on');\n else window.localStorage.removeItem(STORE);\n } catch (_) {\n /* The choice lasts for this page only. */\n }\n }\n function showToggle() {\n if (!toggle) return;\n if (box) toggle.checked = speaking;\n else toggle.setAttribute('aria-pressed', speaking ? 'true' : 'false');\n toggle.dataset.state = speaking ? 'on' : 'off';\n }\n function stopSpeaking() {\n if (synth) synth.cancel();\n }\n function voice() {\n const want = lang().toLowerCase().replace(/_/g, '-');\n const family = want.split('-')[0];\n let list = [];\n try {\n list = Array.from(synth.getVoices() || []);\n } catch (_) {\n list = [];\n }\n const tag = v => String(v && v.lang || '').toLowerCase().replace(/_/g, '-');\n const near = list.filter(v => v && v.localService === true && tag(v).split('-')[0] === family);\n return near.find(v => tag(v) === want) || near[0] || null;\n }\n /* Code is skipped, links are named, markdown marks are dropped, and the\n whole word Aien is spoken as SAYNAME. */\n function plain(text) {\n return String(text)\n .replace(/```[\\s\\S]*?(```|$)/g, ` ${COPY.code} `)\n .replace(/https?:\\/\\/\\S+/g, COPY.link)\n .replace(/[`*_#>\\x7e]+/g, '')\n .replace(/\\|/g, ' ')\n .replace(/\\bAien\\b/g, SAYNAME)\n .replace(/\\s+/g, ' ')\n .trim();\n }\n function pieces(text) {\n const out = [];\n let line = '';\n for (const part of text.match(/[^.!?]+[.!?]*\\s*|[.!?]+\\s*/g) || []) {\n let rest = part;\n while (rest.length > CHUNK) {\n if (line) out.push(line.trim());\n line = '';\n out.push(rest.slice(0, CHUNK).trim());\n rest = rest.slice(CHUNK);\n }\n if (line.length + rest.length > CHUNK) {\n out.push(line.trim());\n line = '';\n }\n line += rest;\n }\n if (line.trim()) out.push(line.trim());\n return out.filter(Boolean);\n }\n" + +note JavaScript part 11 +text js11 " function read(text, lead) {\n if (!speaking || !synth || document.hidden) return;\n let said = plain(text);\n if (!said) return;\n if (said.length > SPEAK_MAX) said = `${said.slice(0, SPEAK_MAX)} ${COPY.rest}`;\n stopSpeaking();\n const chosen = voice();\n for (const part of pieces(lead ? `${lead} ${said}` : said)) {\n const utterance = new window.SpeechSynthesisUtterance(part);\n utterance.lang = lang();\n if (chosen) utterance.voice = chosen;\n synth.speak(utterance);\n }\n }\n /* iOS speaks later only after one utterance inside a tap. */\n function unlock() {\n if (unlocked || !speaking || !synth) return;\n unlocked = true;\n const utterance = new window.SpeechSynthesisUtterance('');\n utterance.volume = 0;\n synth.speak(utterance);\n }\n function setSpeaking(on) {\n speaking = !!on && !!synth;\n store(speaking);\n showToggle();\n if (!speaking) {\n stopSpeaking();\n say(COPY.speakOff);\n return;\n }\n unlock();\n say(voice() ? COPY.speakOn : `${COPY.speakOn} ${COPY.remote}`);\n }\n\n if (toggle) {\n if (!synth) {\n toggle.disabled = true;\n toggle.setAttribute('aria-disabled', 'true');\n toggle.title = COPY.noSpeak;\n speaking = false;\n } else {\n speaking = stored();\n }\n showToggle();\n toggle.addEventListener(box ? 'change' : 'click', () => {\n if (!synth) return;\n setSpeaking(box ? toggle.checked : !speaking);\n });\n }\n\n function hidden() {\n if (!document.hidden) return;\n stopSpeaking();\n end('hidden');\n }\n document.addEventListener('visibilitychange', hidden);\n window.addEventListener('pagehide', () => {\n stopSpeaking();\n end('hidden');\n });\n\n /* The chat transport (window.allen v1): a new request silences speech;\n replies are read only when the visitor turned reading on. */\n" + +note JavaScript part 12 +text js12 " let hooked = false;\n function hook() {\n const allen = window.allen;\n if (hooked || !allen || typeof allen.on !== 'function') return;\n hooked = true;\n allen.on('send', () => {\n stopSpeaking();\n unlock();\n });\n allen.on('reply', detail => {\n if (!detail || typeof detail.text !== 'string') return;\n if (detail.outcome === 'Stopped.') return;\n read(detail.text, '');\n });\n allen.on('human', detail => {\n if (detail && typeof detail.text === 'string') read(detail.text, COPY.drake);\n });\n }\n hook();\n document.addEventListener('allen-ready', hook);\n\n window.AllenVoice = Object.freeze({\n version: 1,\n mode: () => mode,\n state: () => state,\n speaking: () => speaking,\n });\n})();\n" + +fn main to int +vcheck +js_0 +js_1 +js_2 +js_3 +js_4 +js_5 +js_6 +js_7 +js_8 +js_9 +js_10 +js_11 +js_12 +if eq get marker 0 1 +trap 3 +end +flush +ret 0 +end + +fn js_0 to void +for b ulong len js0 +byteput get js0 b +end +end + +fn js_1 to void +for b ulong len js1 +byteput get js1 b +end +end + +fn js_2 to void +for b ulong len js2 +byteput get js2 b +end +end + +fn js_3 to void +for b ulong len js3 +byteput get js3 b +end +end + +fn js_4 to void +for b ulong len js4 +byteput get js4 b +end +end + +fn js_5 to void +for b ulong len js5 +byteput get js5 b +end +end + +fn js_6 to void +for b ulong len js6 +byteput get js6 b +end +end + +fn js_7 to void +for b ulong len js7 +byteput get js7 b +end +end + +fn js_8 to void +for b ulong len js8 +byteput get js8 b +end +end + +fn js_9 to void +for b ulong len js9 +byteput get js9 b +end +end + +fn js_10 to void +for b ulong len js10 +byteput get js10 b +end +end + +fn js_11 to void +for b ulong len js11 +byteput get js11 b +end +end + +fn js_12 to void +for b ulong len js12 +byteput get js12 b +end +end diff --git a/public/allen/scene.om b/public/allen/scene.om new file mode 100644 index 0000000..7762925 --- /dev/null +++ b/public/allen/scene.om @@ -0,0 +1,1116 @@ +note Browser controller for native Allen. See provenance.txt for temporary C-WASM boundary. +note Text literals are emitted verbatim; public JS is never edited. +global out uchar 16384 +global used ulong 1 +fn flush to void +off = ulong 0 +while lt off get used 0 +n = write int 1 out off sub get used 0 off +if le n 0 +exit 2 +end +off = add off ulong n +end +put used 0 0 +end +fn byteput c uchar to void +if eq get used 0 len out +flush +end +put out get used 0 c +put used 0 add get used 0 1 +end +text j0 "/* Generated from om/allen-scene/scene.om by pinned seeded Omega.\n" +text j1 " * Controller: Omega-generated JavaScript. Rendering/audio: unchanged native C,\n" +text j2 " * aien-dev/aienux@da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c, compiled to WASM.\n" +text j3 " * This source pin was staged, not hardware-confirmed by the available report.\n" +text j4 " * Web opening reuses native dusk; enter('birth') is the original binary merger.\n" +text j5 " * Catalogue/licences and native dependency boundary: om/allen-scene/provenance.txt.\n" +text j6 " * WolframLanguageEvaluator: 1000/60 -> 50/3 ms; (1000/60)/2 -> 25/3 ms;\n" +text j7 " * 48000 (12300-11360)/1000 -> 45120 frames (native chirp non-silent window).\n" +text j8 " */\n" +text j9 "(() => {\n" +text j10 " 'use strict';\n" +text j11 " const PIN = 'da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c';\n" +text j12 " const mounted = new WeakMap();\n" +text j13 " let compiled;\n" +text j14 " function module() {\n" +text j15 " if (!compiled) compiled = fetch('/allen/scene.wasm', {credentials:'omit'})\n" +text j16 " .then(response => { if (!response.ok) throw new Error('Native scene unavailable'); return response.arrayBuffer(); })\n" +text j17 " .then(bytes => WebAssembly.compile(bytes)).catch(error => { compiled = null; throw error; });\n" +text j18 " return compiled;\n" +text j19 " }\n" +text j20 " function mount(canvas, options = {}) {\n" +text j21 " if (!(canvas instanceof HTMLCanvasElement)) throw new TypeError('AllenScene requires a canvas');\n" +text j22 " if (mounted.has(canvas)) return mounted.get(canvas);\n" +text j23 " const compact = Boolean(options.compact), interactive = Boolean(options.interactive) && !compact;\n const opening = options.opening === undefined ? (compact ? 'idle' : 'dusk') : options.opening;\n if(opening !== 'idle' && opening !== 'dusk' && opening !== 'birth') throw new RangeError('Invalid Allen scene opening');\n" +text j24 " const ctx = canvas.getContext('2d', {alpha:false});\n" +text j25 " if (!ctx) throw new Error('Canvas rendering unavailable');\n" +text j26 " const motion = matchMedia('(prefers-reduced-motion: reduce)');\n" +text j27 " const cleanup = [], letters = Array.from({length:64}, () => ({char:0,start:0,slot:0}));\n" +text j28 " const wordTimes = new Float64Array(256);\n" +text j29 " let ex, image, width = 0, height = 0, disposed = false, failed = false;\n" +text j30 " let raf = 0, lastWall = 0, clock = 20000, kind = 0, modeValue = 0;\n" +text j31 " let visible = true, reduced = motion.matches, dirty = true, resizePending = true;\n const connection = typeof navigator === 'object' ? navigator.connection : null;\n let calm = options.calm === undefined ? Boolean(connection && connection.saveData) : Boolean(options.calm);\n let quality = 0, overBudget = 0, underBudget = 0, qualityHold = 0, samples = 0;\n const renderScales = [1, 3/4, 9/16, 9/16];\n const qualityNames = ['full-60','balanced-60','small-60','small-30'];\n const frameBudget = 1000/60;\n // Wolfram: 1000/60 -> 50/3 ms; budget/2 -> 25/3; 1280*{1,3/4,9/16} -> {1280,960,720}.\n function still() { return reduced || compact || calm; }\n function qualityLabel() { canvas.dataset.sceneQuality = reduced ? 'reduced' : compact ? 'compact' : calm ? 'calm' : qualityNames[quality]; }\n function measureDraw(cost) {\n samples++;\n if(samples % 60 === 0) canvas.dataset.sceneDrawMs=String(cost);\n if(qualityHold) { qualityHold--; return; }\n overBudget=cost>frameBudget?overBudget+1:0;\n underBudget=cost=8?Math.min(3,quality+1):underBudget>=180?Math.max(0,quality-1):quality;\n if(next!==quality) {\n quality=next;qualityHold=60;overBudget=underBudget=0;\n resizePending=dirty=true;canvas.dataset.sceneDrawMs=String(cost);qualityLabel();\n }\n }\n" +text j32 " let letterHead = 0, wordRead = 0, wordWrite = 0, lastWord = -1000, speakUntil = 0, keyUntil = 0;\n" +text j33 " let ra = 113697000, dec = -72757000, fov = 80000, viewPending = false;\n" +text j34 " let dragId = null, dragX = 0, dragY = 0, pinchDistance = 0;\n const touches = [{id:null,x:0,y:0},{id:null,x:0,y:0}];\n" +text j35 " let ownsAudio = false, completeSent = false, resolveSize, rejectSize;\n" +text j36 " let pendingEnter = compact || opening === 'idle' ? 0 : opening === 'birth' ? 2 : 1, pendingStatic = false;\n" +text j37 " canvas.dataset.sceneSource = PIN;\n" +text j38 " canvas.dataset.sceneEngine = 'loading';\n qualityLabel();\n" +text j39 " function listen(target, name, fn, opts) {\n" +text j40 " target.addEventListener(name, fn, opts);\n" +text j41 " cleanup.push(() => target.removeEventListener(name, fn, opts));\n" +text j42 " }\n" +text j43 " function stopAudio() {\n" +text j44 " if (ownsAudio && window.AllenAudio) window.AllenAudio.stop();\n" +text j45 " ownsAudio=false;\n" +text j46 " }\n" +text j47 " function awake() { return !disposed && !failed && !document.hidden && visible; }\n" +text j48 " function request() {\n" +text j49 " if (!raf && ex && awake() && (!still() || dirty)) raf = requestAnimationFrame(tick);\n" +text j50 " }\n" +text j51 " function size() {\n" +text j52 " const box = canvas.getBoundingClientRect();\n" +text j53 " if (box.width <= 0 || box.height <= 0) return false;\n" +text j54 " // Policy bound, not a physical-resolution claim. Same aspect ratio, native design scaling.\n" +text j55 " const scale = Math.min(devicePixelRatio || 1, 1280 / Math.max(box.width,box.height))*renderScales[quality];\n" +text j56 " const w = Math.max(64,Math.round(box.width*scale)), h = Math.max(64,Math.round(box.height*scale));\n" +text j57 " resizePending = false;\n" +text j58 " if (w === width && h === height) return true;\n" +text j59 " width=w; height=h; canvas.width=w; canvas.height=h;\n" +text j60 " if (!ex.scene_init(w,h,compact?1:0)) throw new Error('Native scene size refused');\n" +text j61 " image = new ImageData(new Uint8ClampedArray(ex.memory.buffer,ex.scene_pixels(),w*h*4),w,h);\n" +text j62 " ex.scene_enter(kind);\n" +text j63 " // Resize keeps phase and mode but does not manufacture the old frame history.\n" +text j64 " ex.scene_step(Math.floor(clock),modeValue,0);\n" +text j65 " viewPending=true;\n if(resolveSize) {resolveSize();resolveSize=null;rejectSize=null;}\n" +text j66 " return true;\n" +text j67 " }\n" +text j68 " function reset(kindValue) {\n" +text j69 " kind=kindValue; clock=kind===0?20000:0; lastWall=0;completeSent=false;\n" +text j70 " wordRead=wordWrite=0; lastWord=-1000; speakUntil=keyUntil=0; modeValue=0;\n" +text j71 " for (const letter of letters) letter.char=0;\n" +text j72 " stopAudio();\n" +text j73 " if (ex && width) ex.scene_enter(kind);\n" +text j74 " dirty=true; request();\n" +text j75 " }\n" +text j76 " function render() {\n" +text j77 " if (!ex || !awake()) return;\n" +text j78 " if (resizePending && !size()) return;\n" +text j79 " if (!image) return;\n" +text j80 " if (viewPending && !(kind===1 && clock<4200)) {\n" +text j81 " if (!ex.scene_view(Math.round(ra),Math.round(dec),Math.round(fov))) throw new Error('Native sky view refused');\n" +text j82 " viewPending=false;\n" +text j83 " }\n" +text j84 " const time=Math.floor(clock);\n" +text j85 " while(wordRead!==wordWrite && wordTimes[wordRead]<=clock) {\n" +text j86 " lastWord=wordTimes[wordRead];ex.scene_word(Math.floor(lastWord));wordRead=(wordRead+1)%wordTimes.length;\n" +text j87 " }\n" +text j88 " let currentMode=modeValue;\n" +text j89 " if(clock=0?ex.scene_voice(time,Math.floor(lastWord)):0;\n" +text j94 " const shimmer=clock=1) {letter.char=0;continue;}\n" +text j101 " // Web enhancement: native glyphs lift from input to Allen. No HTML/text injection.\n" +text j102 " const ease=1-(1-u)*(1-u)*(1-u);\n" +text j103 " const x=width/2+(letter.slot-4)*width/90*(1-ease);\n" +text j104 " const y=height*(0.86+(0.4-0.86)*ease);\n" +text j105 " ex.scene_glyph(letter.char,Math.round(x),Math.round(y),Math.round(256*(1-u)));\n" +text j106 " }\n" +text j107 " ctx.putImageData(image,0,0);\n" +text j108 " canvas.dataset.scenePhase=kind===1 && clock<4200?'tube':kind===2 && clock<12300?'merger':clock<(kind===1?7200:15300)?'forming':'presence';\n" +text j109 " canvas.dataset.sceneTime=String(time);\n" +text j110 " canvas.dataset.sceneEngine='native-wasm';\n" +text j111 " dirty=false;\n if(!completeSent && (kind===0 || clock>=(kind===1?7200:15300))) {\n completeSent=true;\n canvas.dispatchEvent(new CustomEvent('allen-scene-complete',{bubbles:true,detail:{kind:kind===2?'birth':kind===1?'dusk':'idle',time}}));\n }\n return true;\n" +text j112 " }\n" +text j113 " function error(err) {\n" +text j114 " failed=true;cancelAnimationFrame(raf);raf=0;stopAudio();\n if(rejectSize) {rejectSize(err);resolveSize=null;rejectSize=null;}\n" +text j115 " canvas.dataset.sceneEngine='unavailable';\n" +text j116 " canvas.dispatchEvent(new CustomEvent('allen-scene-error',{bubbles:true,detail:{message:String(err.message||err)}}));\n" +text j117 " }\n" +text j118 " function tick(wall) {\n" +text j119 " raf=0;\n" +text j120 " if(!awake()) {lastWall=0;return;}\n" +text j121 " const dt=lastWall?wall-lastWall:0;\n" +text j122 " // Lowest level skips alternate 60 Hz callbacks; 25 ms tolerates timestamp jitter around 50/3 and 100/3 ms.\n if(!still() && quality===3 && dt<25 && !dirty) {request();return;}\n" +text j123 " lastWall=wall;\n" +text j124 " if(!still()) clock+=dt; // source clock advances; native integrators bound their own catch-up\n" +text j125 " const sample=!still() && !resizePending && !viewPending;\n const began=sample?performance.now():0;\n let drawn=false;\n try { drawn=render(); } catch(err) { error(err); }\n if(sample && drawn) measureDraw(performance.now()-began);\n" +text j126 " if(drawn && !still()) request();\n" +text j127 " }\n" +text j128 " function motionChanged() {\n" +text j129 " reduced=motion.matches;lastWall=0;cancelAnimationFrame(raf);raf=0;stopAudio();\n" +text j130 " if(still()) { reset(0); pendingStatic=true; }\n overBudget=underBudget=0;qualityLabel();\n" +text j131 " dirty=true;request();\n" +text j132 " }\n" +text j133 " function visibility() {\n" +text j134 " lastWall=0;\n" +text j135 " if(!awake()) {cancelAnimationFrame(raf);raf=0;if(ownsAudio && window.AllenAudio) window.AllenAudio.pause();}\n" +text j136 " else {if(ownsAudio && !still() && window.AllenAudio) void window.AllenAudio.resume();overBudget=underBudget=0;dirty=true;request();}\n" +text j137 " }\n" +text j138 " function changeView(dx,dy,zoom) {\n" +text j139 " if(!interactive || kind===1 && clock<4200) return;\n" +text j140 " ra=((ra+dx)%360000000+360000000)%360000000;\n" +text j141 " dec=Math.max(-89000000,Math.min(89000000,dec+dy));\n" +text j142 " fov=Math.max(10000,Math.min(120000,fov*zoom));\n" +text j143 " viewPending=dirty=true;request();\n" +text j144 " }\n" +text j145 " function home() {ra=113697000;dec=-72757000;fov=80000;viewPending=dirty=true;request();}\n" +text j146 " const api = {\n" +text j147 " key(text) {\n" +text j148 " if(disposed) return;\n" +text j149 " text=String(text).slice(-64);keyUntil=clock+4000;\n" +text j150 " if(ex) ex.scene_key(Math.floor(clock));\n" +text j151 " if(!reduced && !compact) for(let i=0;i126) continue;\n" +text j153 " const letter=letters[letterHead];letterHead=(letterHead+1)%letters.length;\n" +text j154 " letter.char=c;letter.start=clock+i*35;letter.slot=i%9;\n" +text j155 " }\n" +text j156 " dirty=true;request();\n" +text j157 " },\n" +text j158 " speak(text) {\n" +text j159 " if(disposed) return;\n" +text j160 " text=String(text).slice(0,4096);\n" +text j161 " let offset=0;const start=Math.max(clock,speakUntil-300);\n" +text j162 " for(let i=0;i86400000) throw new RangeError('Scene time outside one day');\n" +text j190 " cancelAnimationFrame(raf);raf=0;lastWall=0;\n" +text j191 " if(reduced) clock=20000;else clock=ms;\n" +text j192 " dirty=true;\n" +text j193 " if(ex) {try {render();} catch(err) {error(err);}}\n" +text j194 " },\n" +text j195 " destroy() {\n" +text j196 " if(disposed) return;\n" +text j197 " disposed=true;cancelAnimationFrame(raf);raf=0;stopAudio();\n if(rejectSize) {rejectSize(new Error('Scene destroyed before initialization'));resolveSize=null;rejectSize=null;}\n" +text j198 " for(const fn of cleanup) fn();\n" +text j199 " mounted.delete(canvas);image=null;ex=null;\n" +text j200 " canvas.dataset.sceneEngine='destroyed';\n" +text j201 " }\n" +text j202 " };\n" +text j203 " mounted.set(canvas,api);\n" +text j204 " listen(document,'visibilitychange',visibility);\n" +text j205 " listen(motion,'change',motionChanged);\n" +text j206 " if(typeof ResizeObserver==='function') {\n" +text j207 " const resize=new ResizeObserver(() => {resizePending=dirty=true;request();});resize.observe(canvas);cleanup.push(() => resize.disconnect());\n" +text j208 " } else listen(window,'resize',() => {resizePending=dirty=true;request();});\n" +text j209 " if(typeof IntersectionObserver==='function') {\n" +text j210 " const observer=new IntersectionObserver(entries => {visible=entries[0].isIntersecting;visibility();});observer.observe(canvas);cleanup.push(() => observer.disconnect());\n" +text j211 " }\n" +text j212 " if(interactive) {\n" +text j213 " const oldTouch=canvas.style.touchAction;canvas.style.touchAction='pinch-zoom';cleanup.push(() => {canvas.style.touchAction=oldTouch;});\n" +text j214 " listen(canvas,'pointerdown',event => {\n" +text j215 " if(event.button!==0) return;\n if(event.pointerType==='touch') {\n const slot=touches.find(touch => touch.id===null);\n if(!slot) return;\n slot.id=event.pointerId;slot.x=event.clientX;slot.y=event.clientY;\n if(touches[0].id!==null && touches[1].id!==null) pinchDistance=Math.hypot(touches[0].x-touches[1].x,touches[0].y-touches[1].y);\n }\n" +text j216 " dragId=event.pointerId;dragX=event.clientX;dragY=event.clientY;\n" +text j217 " canvas.setPointerCapture(dragId);canvas.focus({preventScroll:true});\n" +text j218 " });\n" +text j219 " listen(canvas,'pointermove',event => {\n" +text j220 " if(event.pointerType==='touch') {\n const touch=touches.find(touch => touch.id===event.pointerId);\n if(!touch) return;\n touch.x=event.clientX;touch.y=event.clientY;\n if(touches[0].id!==null && touches[1].id!==null) {\n const distance=Math.hypot(touches[0].x-touches[1].x,touches[0].y-touches[1].y);\n if(distance>0 && pinchDistance>0) changeView(0,0,pinchDistance/distance);\n pinchDistance=distance;return;\n }\n }\n if(event.pointerId!==dragId) return;\n" +text j221 " const box=canvas.getBoundingClientRect();\n" +text j222 " changeView(-(event.clientX-dragX)*fov*1000/Math.max(1,box.width),(event.clientY-dragY)*fov*1000/Math.max(1,box.width),1);\n" +text j223 " dragX=event.clientX;dragY=event.clientY;\n" +text j224 " });\n" +text j225 " const release=event => {\n for(const touch of touches) if(touch.id===event.pointerId) touch.id=null;\n pinchDistance=0;\n if(event.pointerId===dragId) {\n dragId=null;\n if(canvas.hasPointerCapture(event.pointerId)) canvas.releasePointerCapture(event.pointerId);\n const remaining=touches.find(touch => touch.id!==null);\n if(remaining) {dragId=remaining.id;dragX=remaining.x;dragY=remaining.y;}\n }\n };\n" +text j226 " listen(canvas,'pointerup',release);listen(canvas,'pointercancel',release);listen(canvas,'lostpointercapture',release);\n" +text j227 " listen(canvas,'wheel',event => {if(event.ctrlKey || event.metaKey) return;event.preventDefault();changeView(0,0,Math.pow(2,Math.max(-600,Math.min(600,event.deltaY))/600));},{passive:false});\n" +text j228 " listen(canvas,'keydown',event => {\n" +text j229 " const step=fov*1000/20;\n" +text j230 " switch(event.key) {\n" +text j231 " case 'ArrowLeft':changeView(-step,0,1);break;\n" +text j232 " case 'ArrowRight':changeView(step,0,1);break;\n" +text j233 " case 'ArrowUp':changeView(0,step,1);break;\n" +text j234 " case 'ArrowDown':changeView(0,-step,1);break;\n" +text j235 " case '+':case '=':changeView(0,0,1/1.1);break;\n" +text j236 " case '-':changeView(0,0,1.1);break;\n" +text j237 " case 'Home':home();break;\n" +text j238 " default:return;\n" +text j239 " }\n" +text j240 " event.preventDefault();\n" +text j241 " });\n" +text j242 " }\n" +text j243 " api.ready=module().then(module => WebAssembly.instantiate(module,{})).then(async instance => {\n" +text j244 " if(disposed) return api;\n" +text j245 " ex=instance.exports;\n" +text j246 " const initial=still()?0:pendingEnter===null?0:pendingEnter;\n" +text j247 " // Preserve an audio gesture made before compilation completes.\n" +text j248 " const audioOwner=ownsAudio;ownsAudio=false;reset(initial);ownsAudio=audioOwner;\n" +text j249 " pendingEnter=null;\n" +text j250 " if(!size()) await new Promise((resolve,reject) => {resolveSize=resolve;rejectSize=reject;});\n if(disposed) return api;\n" +text j251 " if(still() || pendingStatic) {clock=20000;ex.scene_step(20000,0,0);pendingStatic=false;}\n" +text j252 " render();request();\n canvas.dispatchEvent(new CustomEvent('allen-scene-initialized',{bubbles:true,detail:{source:PIN}}));\n" +text j253 " return api;\n" +text j254 " }).catch(err => {if(!disposed) error(err);throw err;});\n" +text j255 " // Expose the rejection to callers while avoiding an unhandled rejection for decorative mounts.\n" +text j256 " api.ready.catch(() => {});\n" +text j257 " return api;\n" +text j258 " }\n" +text j259 " window.AllenScene=Object.freeze({mount,source:PIN});\n" +text j260 " document.dispatchEvent(new CustomEvent('allen-scene-ready'));\n" +text j261 "})();\n" +fn part0 to void +for i ulong len j0 +byteput get j0 i +end +for i ulong len j1 +byteput get j1 i +end +for i ulong len j2 +byteput get j2 i +end +for i ulong len j3 +byteput get j3 i +end +for i ulong len j4 +byteput get j4 i +end +for i ulong len j5 +byteput get j5 i +end +for i ulong len j6 +byteput get j6 i +end +for i ulong len j7 +byteput get j7 i +end +for i ulong len j8 +byteput get j8 i +end +for i ulong len j9 +byteput get j9 i +end +for i ulong len j10 +byteput get j10 i +end +for i ulong len j11 +byteput get j11 i +end +for i ulong len j12 +byteput get j12 i +end +for i ulong len j13 +byteput get j13 i +end +for i ulong len j14 +byteput get j14 i +end +for i ulong len j15 +byteput get j15 i +end +for i ulong len j16 +byteput get j16 i +end +for i ulong len j17 +byteput get j17 i +end +for i ulong len j18 +byteput get j18 i +end +for i ulong len j19 +byteput get j19 i +end +end +fn part20 to void +for i ulong len j20 +byteput get j20 i +end +for i ulong len j21 +byteput get j21 i +end +for i ulong len j22 +byteput get j22 i +end +for i ulong len j23 +byteput get j23 i +end +for i ulong len j24 +byteput get j24 i +end +for i ulong len j25 +byteput get j25 i +end +for i ulong len j26 +byteput get j26 i +end +for i ulong len j27 +byteput get j27 i +end +for i ulong len j28 +byteput get j28 i +end +for i ulong len j29 +byteput get j29 i +end +for i ulong len j30 +byteput get j30 i +end +for i ulong len j31 +byteput get j31 i +end +for i ulong len j32 +byteput get j32 i +end +for i ulong len j33 +byteput get j33 i +end +for i ulong len j34 +byteput get j34 i +end +for i ulong len j35 +byteput get j35 i +end +for i ulong len j36 +byteput get j36 i +end +for i ulong len j37 +byteput get j37 i +end +for i ulong len j38 +byteput get j38 i +end +for i ulong len j39 +byteput get j39 i +end +end +fn part40 to void +for i ulong len j40 +byteput get j40 i +end +for i ulong len j41 +byteput get j41 i +end +for i ulong len j42 +byteput get j42 i +end +for i ulong len j43 +byteput get j43 i +end +for i ulong len j44 +byteput get j44 i +end +for i ulong len j45 +byteput get j45 i +end +for i ulong len j46 +byteput get j46 i +end +for i ulong len j47 +byteput get j47 i +end +for i ulong len j48 +byteput get j48 i +end +for i ulong len j49 +byteput get j49 i +end +for i ulong len j50 +byteput get j50 i +end +for i ulong len j51 +byteput get j51 i +end +for i ulong len j52 +byteput get j52 i +end +for i ulong len j53 +byteput get j53 i +end +for i ulong len j54 +byteput get j54 i +end +for i ulong len j55 +byteput get j55 i +end +for i ulong len j56 +byteput get j56 i +end +for i ulong len j57 +byteput get j57 i +end +for i ulong len j58 +byteput get j58 i +end +for i ulong len j59 +byteput get j59 i +end +end +fn part60 to void +for i ulong len j60 +byteput get j60 i +end +for i ulong len j61 +byteput get j61 i +end +for i ulong len j62 +byteput get j62 i +end +for i ulong len j63 +byteput get j63 i +end +for i ulong len j64 +byteput get j64 i +end +for i ulong len j65 +byteput get j65 i +end +for i ulong len j66 +byteput get j66 i +end +for i ulong len j67 +byteput get j67 i +end +for i ulong len j68 +byteput get j68 i +end +for i ulong len j69 +byteput get j69 i +end +for i ulong len j70 +byteput get j70 i +end +for i ulong len j71 +byteput get j71 i +end +for i ulong len j72 +byteput get j72 i +end +for i ulong len j73 +byteput get j73 i +end +for i ulong len j74 +byteput get j74 i +end +for i ulong len j75 +byteput get j75 i +end +for i ulong len j76 +byteput get j76 i +end +for i ulong len j77 +byteput get j77 i +end +for i ulong len j78 +byteput get j78 i +end +for i ulong len j79 +byteput get j79 i +end +end +fn part80 to void +for i ulong len j80 +byteput get j80 i +end +for i ulong len j81 +byteput get j81 i +end +for i ulong len j82 +byteput get j82 i +end +for i ulong len j83 +byteput get j83 i +end +for i ulong len j84 +byteput get j84 i +end +for i ulong len j85 +byteput get j85 i +end +for i ulong len j86 +byteput get j86 i +end +for i ulong len j87 +byteput get j87 i +end +for i ulong len j88 +byteput get j88 i +end +for i ulong len j89 +byteput get j89 i +end +for i ulong len j90 +byteput get j90 i +end +for i ulong len j91 +byteput get j91 i +end +for i ulong len j92 +byteput get j92 i +end +for i ulong len j93 +byteput get j93 i +end +for i ulong len j94 +byteput get j94 i +end +for i ulong len j95 +byteput get j95 i +end +for i ulong len j96 +byteput get j96 i +end +for i ulong len j97 +byteput get j97 i +end +for i ulong len j98 +byteput get j98 i +end +for i ulong len j99 +byteput get j99 i +end +end +fn part100 to void +for i ulong len j100 +byteput get j100 i +end +for i ulong len j101 +byteput get j101 i +end +for i ulong len j102 +byteput get j102 i +end +for i ulong len j103 +byteput get j103 i +end +for i ulong len j104 +byteput get j104 i +end +for i ulong len j105 +byteput get j105 i +end +for i ulong len j106 +byteput get j106 i +end +for i ulong len j107 +byteput get j107 i +end +for i ulong len j108 +byteput get j108 i +end +for i ulong len j109 +byteput get j109 i +end +for i ulong len j110 +byteput get j110 i +end +for i ulong len j111 +byteput get j111 i +end +for i ulong len j112 +byteput get j112 i +end +for i ulong len j113 +byteput get j113 i +end +for i ulong len j114 +byteput get j114 i +end +for i ulong len j115 +byteput get j115 i +end +for i ulong len j116 +byteput get j116 i +end +for i ulong len j117 +byteput get j117 i +end +for i ulong len j118 +byteput get j118 i +end +for i ulong len j119 +byteput get j119 i +end +end +fn part120 to void +for i ulong len j120 +byteput get j120 i +end +for i ulong len j121 +byteput get j121 i +end +for i ulong len j122 +byteput get j122 i +end +for i ulong len j123 +byteput get j123 i +end +for i ulong len j124 +byteput get j124 i +end +for i ulong len j125 +byteput get j125 i +end +for i ulong len j126 +byteput get j126 i +end +for i ulong len j127 +byteput get j127 i +end +for i ulong len j128 +byteput get j128 i +end +for i ulong len j129 +byteput get j129 i +end +for i ulong len j130 +byteput get j130 i +end +for i ulong len j131 +byteput get j131 i +end +for i ulong len j132 +byteput get j132 i +end +for i ulong len j133 +byteput get j133 i +end +for i ulong len j134 +byteput get j134 i +end +for i ulong len j135 +byteput get j135 i +end +for i ulong len j136 +byteput get j136 i +end +for i ulong len j137 +byteput get j137 i +end +for i ulong len j138 +byteput get j138 i +end +for i ulong len j139 +byteput get j139 i +end +end +fn part140 to void +for i ulong len j140 +byteput get j140 i +end +for i ulong len j141 +byteput get j141 i +end +for i ulong len j142 +byteput get j142 i +end +for i ulong len j143 +byteput get j143 i +end +for i ulong len j144 +byteput get j144 i +end +for i ulong len j145 +byteput get j145 i +end +for i ulong len j146 +byteput get j146 i +end +for i ulong len j147 +byteput get j147 i +end +for i ulong len j148 +byteput get j148 i +end +for i ulong len j149 +byteput get j149 i +end +for i ulong len j150 +byteput get j150 i +end +for i ulong len j151 +byteput get j151 i +end +for i ulong len j152 +byteput get j152 i +end +for i ulong len j153 +byteput get j153 i +end +for i ulong len j154 +byteput get j154 i +end +for i ulong len j155 +byteput get j155 i +end +for i ulong len j156 +byteput get j156 i +end +for i ulong len j157 +byteput get j157 i +end +for i ulong len j158 +byteput get j158 i +end +for i ulong len j159 +byteput get j159 i +end +end +fn part160 to void +for i ulong len j160 +byteput get j160 i +end +for i ulong len j161 +byteput get j161 i +end +for i ulong len j162 +byteput get j162 i +end +for i ulong len j163 +byteput get j163 i +end +for i ulong len j164 +byteput get j164 i +end +for i ulong len j165 +byteput get j165 i +end +for i ulong len j166 +byteput get j166 i +end +for i ulong len j167 +byteput get j167 i +end +for i ulong len j168 +byteput get j168 i +end +for i ulong len j169 +byteput get j169 i +end +for i ulong len j170 +byteput get j170 i +end +for i ulong len j171 +byteput get j171 i +end +for i ulong len j172 +byteput get j172 i +end +for i ulong len j173 +byteput get j173 i +end +for i ulong len j174 +byteput get j174 i +end +for i ulong len j175 +byteput get j175 i +end +for i ulong len j176 +byteput get j176 i +end +for i ulong len j177 +byteput get j177 i +end +for i ulong len j178 +byteput get j178 i +end +for i ulong len j179 +byteput get j179 i +end +end +fn part180 to void +for i ulong len j180 +byteput get j180 i +end +for i ulong len j181 +byteput get j181 i +end +for i ulong len j182 +byteput get j182 i +end +for i ulong len j183 +byteput get j183 i +end +for i ulong len j184 +byteput get j184 i +end +for i ulong len j185 +byteput get j185 i +end +for i ulong len j186 +byteput get j186 i +end +for i ulong len j187 +byteput get j187 i +end +for i ulong len j188 +byteput get j188 i +end +for i ulong len j189 +byteput get j189 i +end +for i ulong len j190 +byteput get j190 i +end +for i ulong len j191 +byteput get j191 i +end +for i ulong len j192 +byteput get j192 i +end +for i ulong len j193 +byteput get j193 i +end +for i ulong len j194 +byteput get j194 i +end +for i ulong len j195 +byteput get j195 i +end +for i ulong len j196 +byteput get j196 i +end +for i ulong len j197 +byteput get j197 i +end +for i ulong len j198 +byteput get j198 i +end +for i ulong len j199 +byteput get j199 i +end +end +fn part200 to void +for i ulong len j200 +byteput get j200 i +end +for i ulong len j201 +byteput get j201 i +end +for i ulong len j202 +byteput get j202 i +end +for i ulong len j203 +byteput get j203 i +end +for i ulong len j204 +byteput get j204 i +end +for i ulong len j205 +byteput get j205 i +end +for i ulong len j206 +byteput get j206 i +end +for i ulong len j207 +byteput get j207 i +end +for i ulong len j208 +byteput get j208 i +end +for i ulong len j209 +byteput get j209 i +end +for i ulong len j210 +byteput get j210 i +end +for i ulong len j211 +byteput get j211 i +end +for i ulong len j212 +byteput get j212 i +end +for i ulong len j213 +byteput get j213 i +end +for i ulong len j214 +byteput get j214 i +end +for i ulong len j215 +byteput get j215 i +end +for i ulong len j216 +byteput get j216 i +end +for i ulong len j217 +byteput get j217 i +end +for i ulong len j218 +byteput get j218 i +end +for i ulong len j219 +byteput get j219 i +end +end +fn part220 to void +for i ulong len j220 +byteput get j220 i +end +for i ulong len j221 +byteput get j221 i +end +for i ulong len j222 +byteput get j222 i +end +for i ulong len j223 +byteput get j223 i +end +for i ulong len j224 +byteput get j224 i +end +for i ulong len j225 +byteput get j225 i +end +for i ulong len j226 +byteput get j226 i +end +for i ulong len j227 +byteput get j227 i +end +for i ulong len j228 +byteput get j228 i +end +for i ulong len j229 +byteput get j229 i +end +for i ulong len j230 +byteput get j230 i +end +for i ulong len j231 +byteput get j231 i +end +for i ulong len j232 +byteput get j232 i +end +for i ulong len j233 +byteput get j233 i +end +for i ulong len j234 +byteput get j234 i +end +for i ulong len j235 +byteput get j235 i +end +for i ulong len j236 +byteput get j236 i +end +for i ulong len j237 +byteput get j237 i +end +for i ulong len j238 +byteput get j238 i +end +for i ulong len j239 +byteput get j239 i +end +end +fn part240 to void +for i ulong len j240 +byteput get j240 i +end +for i ulong len j241 +byteput get j241 i +end +for i ulong len j242 +byteput get j242 i +end +for i ulong len j243 +byteput get j243 i +end +for i ulong len j244 +byteput get j244 i +end +for i ulong len j245 +byteput get j245 i +end +for i ulong len j246 +byteput get j246 i +end +for i ulong len j247 +byteput get j247 i +end +for i ulong len j248 +byteput get j248 i +end +for i ulong len j249 +byteput get j249 i +end +for i ulong len j250 +byteput get j250 i +end +for i ulong len j251 +byteput get j251 i +end +for i ulong len j252 +byteput get j252 i +end +for i ulong len j253 +byteput get j253 i +end +for i ulong len j254 +byteput get j254 i +end +for i ulong len j255 +byteput get j255 i +end +for i ulong len j256 +byteput get j256 i +end +for i ulong len j257 +byteput get j257 i +end +for i ulong len j258 +byteput get j258 i +end +for i ulong len j259 +byteput get j259 i +end +end +fn part260 to void +for i ulong len j260 +byteput get j260 i +end +for i ulong len j261 +byteput get j261 i +end +end +fn main to int +part0 +part20 +part40 +part60 +part80 +part100 +part120 +part140 +part160 +part180 +part200 +part220 +part240 +part260 +flush +ret 0 +end diff --git a/public/allen/scene.wasm b/public/allen/scene.wasm new file mode 100755 index 0000000..332b9ad Binary files /dev/null and b/public/allen/scene.wasm differ diff --git a/public/assets/allen-install.css b/public/assets/allen-install.css new file mode 100644 index 0000000..9d082ae --- /dev/null +++ b/public/assets/allen-install.css @@ -0,0 +1,21 @@ +/* Generated from om/allen-install/install.om; never hand-edit. */ +.allen-install { display: grid; gap: 10px; font-size: 13px; line-height: 1.55; color: var(--text-secondary); text-align: left; } +.allen-install-lede { margin: 0; } +.allen-install-actions { display: flex; flex-wrap: wrap; gap: 8px; } +.allen-install-state { margin: 0; min-height: 1.55em; color: var(--text-primary); } +.allen-install-state:empty { min-height: 0; } +.allen-install-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; } +.allen-install-step { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: 14px; background: color-mix(in srgb, var(--bg-card) 72%, transparent); } +.allen-install-icon { width: 28px; height: 28px; justify-self: center; fill: none; stroke: var(--text-primary); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; } +.allen-install-step .allen-install-icon { width: 44px; height: 44px; padding: 8px; border-radius: 12px; background: color-mix(in srgb, var(--bg-surface) 80%, transparent); border: 1px solid var(--border-subtle); } +.allen-install-words strong { color: var(--text-primary); font-weight: 500; } +.allen-install-inline { pointer-events: auto; margin: 12px auto 0; width: min(420px, 100%); padding: 14px 16px; border: 1px solid var(--border-subtle); border-radius: 18px; background: color-mix(in srgb, var(--bg-surface) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 12px 40px color-mix(in srgb, var(--bg-base) 60%, transparent); animation: allen-install-in 360ms ease-out both; } +.allen-install-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; } +.allen-install-title { margin: 0; font-size: 14px; color: var(--text-primary); } +.allen-install-close { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 999px; border: 1px solid var(--border-subtle); background: transparent; color: var(--text-secondary); cursor: pointer; } +.allen-install-close:hover { background: var(--bg-card-hover); color: var(--text-primary); } +.allen-install-close .allen-install-icon { width: 16px; height: 16px; stroke: currentColor; } +.allen-install button:focus-visible, .allen-install-close:focus-visible { outline: 2px solid var(--accent-green); outline-offset: 2px; } +@keyframes allen-install-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } } +@media (prefers-reduced-motion: reduce) { .allen-install-inline { animation: none; } } +@media (max-width: 720px) { .allen-install-inline { width: 100%; } .allen-install-actions button { min-height: 44px; } } diff --git a/public/assets/allen-intro.css b/public/assets/allen-intro.css index 9c051c2..8a51077 100644 --- a/public/assets/allen-intro.css +++ b/public/assets/allen-intro.css @@ -1,22 +1,110 @@ +/* The same native Allen floats in the corner. Consent is a non-blocking + text surface above him, never a modal, notification card or speech bubble. */ +.allen-launcher { position: fixed; right: 18px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 999; width: 180px; display: flex; flex-direction: column; align-items: center; text-decoration: none; transform-origin: 50% 40%; } +.allen-launcher canvas { width: 180px; height: 150px; display: block; pointer-events: none; } +.allen-launcher-bar { color: var(--text-secondary); font: 11px var(--font-sans); text-align: center; width: 148px; padding: 7px 12px; border: 1px solid var(--border-subtle); border-radius: 999px; background: linear-gradient(var(--bg-card-hover), var(--bg-base)); box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text-primary) 12%, transparent); } +.allen-launcher:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 4px; border-radius: 20px; } +.allen-launcher:hover .allen-launcher-bar { color: var(--text-primary); border-color: var(--accent-blue); } +.allen-launch-enter { transform: scale(8); opacity: 0; pointer-events: none; } #aien-allen-intro { position: fixed; - inset: 0; - margin: auto; - width: min(36rem, calc(100% - 2rem)); - max-height: calc(100dvh - 2rem); + right: 24px; + bottom: 202px; + z-index: 1000; + width: min(380px, calc(100vw - 32px)); + max-height: calc(100dvh - 230px); overflow-y: auto; - padding: clamp(1rem, 4vw, 2rem); - border: 1px solid var(--border-subtle); - border-radius: 1rem; - background: var(--bg-surface); + overscroll-behavior: contain; color: var(--text-primary); font-family: var(--font-sans); + opacity: 0; + transform: translateY(16px); +} +#aien-allen-intro[hidden] { display: none; } +#aien-allen-intro.allen-intro-in { opacity: 1; transform: none; } +@media (prefers-reduced-motion: no-preference) { + #aien-allen-intro { transition: transform .35s ease-out, opacity .35s ease-out; } + .allen-launcher { transition: transform .45s ease-in, opacity .45s ease-in; } +} +.allen-intro-bubble { + position: relative; + min-width: 0; + padding: 12px 18px 18px; + border: 0; + border-radius: 0; + background: radial-gradient(ellipse at center, color-mix(in srgb, var(--bg-base) 97%, transparent) 45%, color-mix(in srgb, var(--bg-base) 85%, transparent)); +} +.allen-intro-name { margin: 0 2rem .25rem 0; font-size: .8rem; font-weight: 600; color: var(--accent-green); } +.allen-intro-close { + position: absolute; + top: .25rem; + right: .25rem; + width: 2rem; + height: 2rem; + border: 0; + border-radius: 50%; + background: transparent; + color: var(--text-muted); + font-size: 1.25rem; + line-height: 1; + cursor: pointer; +} +.allen-intro-close:hover { background: var(--bg-card-hover); color: var(--text-primary); } +/* Reserve the words' space while the native-cadence greeting appears. */ +.allen-intro-message { display: grid; margin: 0 0 .75rem; font-size: .95rem; line-height: 1.45; color: var(--text-secondary); } +.allen-intro-ghost, #allen-intro-typed { grid-area: 1 / 1; } +.allen-intro-ghost { visibility: hidden; } +#allen-intro-typed strong, .allen-intro-ghost strong { color: var(--text-primary); } +.allen-intro-letter { position: relative; animation: allen-letter-fade 260ms both, allen-letter-rise 360ms both, allen-letter-color 900ms both; } +@keyframes allen-letter-fade { from { opacity: 0; } to { opacity: 1; } } +@keyframes allen-letter-rise { from { top: 6px; } to { top: 0; } } +@keyframes allen-letter-color { from { color: rgb(255, 212, 150); } to { color: rgb(234, 238, 252); } } +@media (prefers-reduced-motion: reduce) { .allen-intro-letter { animation: none; } } +.allen-intro-chips { display: flex; flex-wrap: wrap; gap: .5rem; } +.allen-intro-chips button { + min-height: 2.5rem; + padding: .45rem 1rem; + border: 1px solid var(--border-subtle); + border-radius: 999px; + background: var(--bg-card); + color: var(--text-primary); + cursor: pointer; +} +#allen-intro-yes { border-color: var(--accent-green); } +.allen-intro-chips button:hover { background: var(--bg-card-hover); } +.allen-intro-chips button:focus-visible, .allen-intro-close:focus-visible { outline: 2px solid var(--accent-green); outline-offset: 2px; } +.allen-intro-links { display: flex; gap: 1rem; margin: .625rem 0 0; font-size: .8rem; } +.allen-intro-links a { color: var(--text-secondary); } +.allen-intro-sr { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; +} +#aien-allen-intro [hidden] { display: none; } +.allen-intro-note, #allen-intro-after p { margin: 0 0 .75rem; font-size: .9rem; color: var(--text-secondary); } +#allen-intro-after .allen-intro-links { margin: 0; } +.allen-intro-who { margin-top: .625rem; font-size: .85rem; color: var(--text-secondary); } +.allen-intro-who summary { cursor: pointer; color: var(--text-primary); } +.allen-intro-who summary:focus-visible { outline: 2px solid var(--accent-green); outline-offset: 2px; } +.allen-intro-who-body { max-height: 45vh; overflow-y: auto; padding-top: .5rem; } +.allen-intro-who h3 { margin: .75rem 0 .375rem; font-size: .85rem; color: var(--text-primary); } +.allen-intro-who p, .allen-intro-who ul { margin: 0 0 .5rem; } +.allen-intro-who ul { padding-left: 1.1rem; } +.allen-intro-who li { overflow-wrap: anywhere; } +.allen-intro-who dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; margin: 0 0 .5rem; } +.allen-intro-who dt { color: var(--text-muted); } +.allen-intro-who dd { margin: 0; overflow-wrap: anywhere; color: var(--text-primary); } +.allen-intro-who a { color: var(--text-secondary); text-decoration: underline; } +@media (max-width: 600px) { + #aien-allen-intro { right: 12px; bottom: 142px; max-height: calc(100dvh - 166px); } + .allen-launcher { width: 120px; right: 12px; bottom: 12px; } + .allen-launcher canvas { width: 120px; height: 100px; } + .allen-launcher-bar { width: 116px; font-size: 10px; padding: 6px; } } -#aien-allen-intro:not([open]) { display: none; } -#aien-allen-intro::backdrop { background: color-mix(in srgb, var(--bg-base) 85%, transparent); } -#aien-allen-intro h2 { margin-bottom: 1rem; } -#aien-allen-intro p { margin-bottom: 1rem; color: var(--text-secondary); } -#aien-allen-intro a, .allen-intro-privacy a, .allen-intro-footer a { text-decoration: underline; } +.allen-intro-links a, .allen-intro-privacy a, .allen-intro-footer a { text-decoration: underline; } .allen-intro-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-block: 1rem; } .allen-intro-actions button { flex: 1 1 10rem; diff --git a/public/assets/allen-panes.css b/public/assets/allen-panes.css new file mode 100644 index 0000000..ca965dc --- /dev/null +++ b/public/assets/allen-panes.css @@ -0,0 +1,371 @@ +/* Allen glass panes (public/js/allen-panes.js, generated by om/allen-panes). + Shared palette tokens from style.css; the glass follows the native Allen + design tokens (aienux native design/tokens/allen-tokens.css: panel edge in + sky glow at 15%, 18px backdrop blur, 22px panel radius, 14px rows, pills). + Motion is compositor-only (transform, opacity) and off under reduced motion. */ +.allen-panes { + --allen-pane-glass: color-mix(in srgb, var(--bg-surface) 78%, transparent); + --allen-pane-glass-solid: var(--bg-surface); + --allen-pane-edge: rgb(110 130 255 / .15); + --allen-pane-edge-lit: rgb(110 130 255 / .34); + --allen-pane-radius: 22px; + --allen-pane-row: 14px; + position: absolute; + inset: 0; + z-index: 50; + pointer-events: none; + color: var(--text-primary); + font-family: var(--font-sans, sans-serif); + font-size: 14px; + line-height: 1.55; +} +.allen-panes-layer { position: absolute; inset: 0; } +.allen-panes button, .allen-panes input { font: inherit; color: inherit; } + +/* The pane list */ +.allen-panes-dock { + position: absolute; + top: var(--allen-panes-dock-top, max(16px, env(safe-area-inset-top))); + left: 50%; + transform: translateX(-50%); + z-index: 1000; + display: flex; + align-items: center; + gap: 6px; + max-width: calc(100% - 32px); + padding: 4px; + border-radius: 999px; + border: 1px solid var(--allen-pane-edge); + background: var(--allen-pane-glass); + pointer-events: auto; +} +.allen-panes-chips { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; overflow-x: auto; scrollbar-width: none; min-width: 0; } +.allen-panes-dock[data-empty="yes"] .allen-panes-chips { display: none; } +.allen-panes-chip, .allen-panes-tool { + display: inline-flex; + align-items: baseline; + gap: 6px; + max-width: 220px; + padding: 5px 12px; + border-radius: 999px; + border: 1px solid transparent; + background: transparent; + font-size: 12px; + white-space: nowrap; + cursor: pointer; +} +.allen-panes-chip { color: var(--text-secondary); } +.allen-panes-chip[data-top] { color: var(--text-primary); border-color: var(--allen-pane-edge-lit); } +.allen-panes-chip[data-state="minimized"] { color: var(--text-muted); } +.allen-panes-chip-kind { color: var(--text-muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; } +.allen-panes-chip-title { overflow: hidden; text-overflow: ellipsis; } +.allen-panes-tool { color: var(--text-secondary); } +.allen-panes-chip:hover, .allen-panes-tool:hover { color: var(--text-primary); background: color-mix(in srgb, var(--bg-card-hover) 70%, transparent); } +.allen-panes-live { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; +} + +/* A pane */ +.allen-pane { + position: absolute; + top: 0; + left: 0; + display: flex; + flex-direction: column; + min-width: 0; + border-radius: var(--allen-pane-radius); + border: 1px solid var(--allen-pane-edge); + background: var(--allen-pane-glass); + box-shadow: 0 30px 80px rgb(0 0 0 / .45); + pointer-events: auto; + overflow: hidden; + contain: layout paint; + will-change: transform; +} +@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) { + .allen-pane, .allen-panes-dock { + -webkit-backdrop-filter: blur(18px) saturate(130%); + backdrop-filter: blur(18px) saturate(130%); + } +} +@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) { + .allen-panes { --allen-pane-glass: color-mix(in srgb, var(--bg-surface) 96%, transparent); } +} +.allen-pane[hidden] { display: none; } +.allen-pane[data-top] { border-color: var(--allen-pane-edge-lit); } +.allen-pane:focus { outline: none; } +.allen-pane:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; } +.allen-pane.is-max { transform: none !important; inset: 16px; width: auto !important; height: auto !important; } +.allen-pane.is-moving, .allen-pane.is-sizing { user-select: none; } + +.allen-pane-head { + display: flex; + align-items: center; + gap: 10px; + padding: 10px 10px 10px 8px; + cursor: grab; + touch-action: none; + user-select: none; +} +.allen-pane.is-moving .allen-pane-head { cursor: grabbing; } +.allen-pane.is-max .allen-pane-head { cursor: default; } +.allen-pane-move { + flex: none; + width: 28px; + height: 28px; + border: 1px solid transparent; + border-radius: 999px; + background: radial-gradient(circle, var(--text-muted) 1.2px, transparent 1.6px) 0 0 / 6px 6px content-box; + padding: 7px 8px; + cursor: grab; + opacity: .7; +} +.allen-pane-move:hover, .allen-pane-move:focus-visible { opacity: 1; border-color: var(--allen-pane-edge-lit); } +.allen-pane-kind { flex: none; color: var(--text-muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; } +.allen-pane-title { + flex: 1 1 auto; + min-width: 0; + margin: 0; + font-size: 14px; + font-weight: 500; + letter-spacing: -.005em; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.allen-pane-badge { + flex: none; + padding: 2px 9px; + border-radius: 999px; + border: 1px solid var(--border-subtle); + color: var(--text-secondary); + font-size: 11px; +} +.allen-pane-badge[data-status="computed"] { color: var(--accent-green); border-color: color-mix(in srgb, var(--accent-green) 35%, transparent); } +.allen-pane-badge[data-status="unverified"], .allen-pane-badge[data-status="unsupported"] { color: var(--accent-amber); border-color: color-mix(in srgb, var(--accent-amber) 35%, transparent); } +.allen-pane-controls { flex: none; display: flex; gap: 2px; } +.allen-pane-ctl { + width: 28px; + height: 28px; + border-radius: 999px; + border: 1px solid transparent; + background: transparent; + color: var(--text-secondary); + font-size: 15px; + line-height: 1; + cursor: pointer; +} +.allen-pane-ctl:hover { color: var(--text-primary); background: color-mix(in srgb, var(--bg-card-hover) 80%, transparent); } +.allen-pane-ctl[aria-pressed="true"] { color: var(--text-primary); border-color: var(--allen-pane-edge-lit); } +.allen-panes :is(button, input, summary, a, [tabindex]):focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; } + +.allen-pane-notice { margin: 0 16px 8px; padding: 8px 12px; border-radius: var(--allen-pane-row); background: color-mix(in srgb, var(--accent-amber) 10%, transparent); color: var(--text-primary); font-size: 13px; } +.allen-pane-notice[hidden] { display: none; } +.allen-pane-body { + flex: 1 1 auto; + min-height: 0; + overflow: auto; + overscroll-behavior: contain; + padding: 4px 20px 16px; + scrollbar-width: thin; + overflow-wrap: anywhere; +} +.allen-pane-body > * + * { margin-top: 12px; } +.allen-pane-caveat { color: var(--text-muted); font-size: 12px; } +.allen-pane-note { color: var(--text-secondary); font-size: 13px; } +.allen-pane-label { color: var(--text-muted); font-size: 12px; } +.allen-pane-h3 { margin: 0 0 6px; color: var(--text-secondary); font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; } +.allen-pane-section + .allen-pane-section { margin-top: 16px; } +.allen-pane-mono, .allen-pane-math { font-family: var(--font-mono); } +.allen-pane-math { font-size: 18px; white-space: pre-wrap; color: var(--text-primary); } +.allen-pane-pre, .allen-pane-code, .allen-pane-raw, .allen-md-pre { + margin: 0; + padding: 12px 14px; + border-radius: var(--allen-pane-row); + border: 1px solid var(--border-subtle); + background: color-mix(in srgb, var(--bg-base) 70%, transparent); + font-family: var(--font-mono); + font-size: 12.5px; + line-height: 1.55; + white-space: pre; + overflow: auto; + tab-size: 4; +} +.allen-pane-pre { white-space: pre-wrap; } +.allen-pane-raw { max-height: 320px; white-space: pre-wrap; color: var(--text-secondary); } +.allen-tex math { font-size: 1.25em; margin: 4px 0 8px; color: var(--text-primary); } +.allen-tex > * + * { margin-top: 8px; } +.allen-pane-fns, .allen-pane-refs, .allen-pane-derivations { margin: 0; padding-left: 20px; } +.allen-pane-fns li + li, .allen-pane-refs li + li, .allen-pane-derivations li + li { margin-top: 6px; } + +/* Markdown */ +.allen-md > * + * { margin-top: 10px; } +.allen-md-h { margin: 16px 0 4px; font-weight: 500; letter-spacing: -.005em; } +h3.allen-md-h { font-size: 17px; } +h4.allen-md-h { font-size: 15px; } +h5.allen-md-h, h6.allen-md-h { font-size: 14px; color: var(--text-secondary); } +.allen-md-list { padding-left: 22px; } +.allen-md-list li + li { margin-top: 4px; } +.allen-md-quote { margin: 0; padding-left: 14px; border-left: 2px solid var(--border-subtle); color: var(--text-secondary); } +.allen-md-hr { border: 0; border-top: 1px solid var(--border-subtle); } +.allen-md-code, .allen-md-tex { font-family: var(--font-mono); font-size: .92em; padding: 1px 5px; border-radius: 6px; background: color-mix(in srgb, var(--bg-card) 80%, transparent); } +.allen-link { color: var(--accent-blue); text-decoration: underline; text-underline-offset: 2px; } +.allen-link-host { color: var(--text-muted); font-size: 12px; } + +/* Tables */ +.allen-pane-table { overflow: auto; border-radius: var(--allen-pane-row); border: 1px solid var(--border-subtle); } +.allen-pane-table table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; } +.allen-pane-table th, .allen-pane-table td { padding: 6px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-subtle); } +.allen-pane-table th { position: sticky; top: 0; background: var(--allen-pane-glass-solid); color: var(--text-secondary); font-weight: 500; } +.allen-pane-table tr:last-child td { border-bottom: 0; } + +/* Plots */ +.allen-plot { margin: 0; } +.allen-plot-svg { display: block; width: 100%; height: auto; } +.allen-plot-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 8px 0 0; padding: 0; color: var(--text-secondary); font-size: 12px; } +.allen-plot-key { display: inline-flex; align-items: center; gap: 6px; } +.allen-plot-swatch { width: 14px; height: 3px; border-radius: 2px; } +.allen-plot-data { margin-top: 10px; } +.allen-plot-data > .allen-pane-table { margin-top: 8px; max-height: 260px; } + +/* Apps */ +.allen-pane-bar { display: flex; flex-wrap: wrap; gap: 6px; } +.allen-pane-stage { display: flex; min-height: 0; } +.allen-pane-frame { flex: 1 1 auto; width: 100%; min-height: 320px; border: 1px solid var(--border-subtle); border-radius: var(--allen-pane-row); background: #fff; } + +/* Source, provenance and actions */ +.allen-pane-source { margin: 0 20px 8px; font-size: 13px; } +.allen-pane-source[hidden], .allen-pane-foot[hidden] { display: none; } +.allen-pane-summary { cursor: pointer; color: var(--text-secondary); font-size: 12px; padding: 4px 0; } +.allen-pane-source[open] { max-height: 45%; overflow: auto; } +.allen-pane-source > * + * { margin-top: 8px; } +.allen-pane-prov { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; } +.allen-pane-prov dt { color: var(--text-muted); } +.allen-pane-prov dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; } +.allen-pane-foot { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 20px 14px; } +.allen-pane-foot > :is(.allen-pane-save, .allen-projects-state) { flex-basis: 100%; } +.allen-pane-foot > .allen-projects-state { min-height: 0; } +.allen-pane-save[hidden] { display: none; } +.allen-pane-save > * + * { margin-top: 8px; } +.allen-pane-files { margin: 0; padding-left: 20px; font-size: 12px; color: var(--text-secondary); } +.allen-pane-act { + padding: 6px 14px; + border-radius: 999px; + border: 1px solid color-mix(in srgb, var(--text-secondary) 35%, transparent); + background: color-mix(in srgb, var(--bg-card) 70%, transparent); + color: var(--text-primary); + font-size: 12px; + cursor: pointer; +} +.allen-pane-act:hover { border-color: var(--allen-pane-edge-lit); background: var(--bg-card-hover); } +.allen-pane-act:disabled { opacity: .55; cursor: default; } +.allen-pane-act[hidden] { display: none; } +.allen-pane-run { border-color: var(--allen-pane-edge-lit); background: linear-gradient(rgb(150 170 255 / .34), rgb(84 104 224 / .30)); } +.allen-pane-danger[data-armed="yes"] { color: var(--accent-amber); border-color: color-mix(in srgb, var(--accent-amber) 55%, transparent); } +.allen-pane-size { + position: absolute; + right: 4px; + bottom: 4px; + width: 22px; + height: 22px; + padding: 0; + border: 1px solid transparent; + border-radius: 999px; + background: linear-gradient(135deg, transparent 52%, var(--text-muted) 52%, var(--text-muted) 58%, transparent 58%, transparent 70%, var(--text-muted) 70%, var(--text-muted) 76%, transparent 76%) center / 12px 12px no-repeat; + cursor: nwse-resize; + opacity: .6; + touch-action: none; +} +.allen-pane-size:hover, .allen-pane-size:focus-visible { opacity: 1; border-color: var(--allen-pane-edge-lit); } +.allen-pane.is-max .allen-pane-size { display: none; } + +/* Projects */ +.allen-projects-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; } +.allen-projects-form .allen-pane-label { flex-basis: 100%; } +.allen-projects-name { + flex: 1 1 200px; + min-width: 0; + padding: 7px 14px; + border-radius: 999px; + border: 1px solid var(--border-subtle); + background: color-mix(in srgb, var(--bg-base) 70%, transparent); +} +.allen-projects-state { min-height: 1.5em; color: var(--text-secondary); font-size: 13px; } +.allen-projects-list { list-style: none; margin: 0; padding: 0; } +.allen-projects-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: var(--allen-pane-row); background: color-mix(in srgb, var(--bg-card) 60%, transparent); } +.allen-projects-item + .allen-projects-item { margin-top: 6px; } +.allen-projects-text { display: flex; flex-direction: column; min-width: 0; } +.allen-projects-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; } +.allen-projects-meta { color: var(--text-muted); font-size: 12px; } +.allen-projects-file { font-size: 12px; color: var(--text-secondary); } +.allen-projects-summary { + display: block; + width: 100%; + margin-top: 4px; + padding: 10px 14px; + border-radius: var(--allen-pane-row); + border: 1px solid var(--border-subtle); + background: color-mix(in srgb, var(--bg-base) 70%, transparent); + color: var(--text-primary); + font: inherit; + font-size: 13px; + resize: vertical; +} +.allen-panes [data-over="yes"] { color: var(--accent-amber); } + +/* Mobile: the top pane is a bottom sheet, the others wait in the pane list. + --allen-panes-sheet-bottom is the integration hook: the page sets it, on the + mount host or any ancestor, to the distance in px from the bottom of the + host to where the sheet should end (the virtual keyboard inset from + visualViewport, plus anything the page keeps below the sheet). The sheet + sits on it and shrinks to fit above it. Swipe offsets arrive as + --allen-pane-swipe-x/y from the gesture code. */ +.allen-pane-grab { display: none; } +.allen-panes[data-layout="sheet"] .allen-pane { + top: auto; + left: 0; + right: 0; + bottom: var(--allen-panes-sheet-bottom, 0px); + width: auto !important; + height: min(78%, calc(100% - 72px - var(--allen-panes-sheet-bottom, 0px))) !important; + min-height: 0 !important; + transform: translate(var(--allen-pane-swipe-x, 0px), var(--allen-pane-swipe-y, 0px)) !important; + border-radius: var(--allen-pane-radius) var(--allen-pane-radius) 0 0; + border-bottom: 0; + padding-bottom: env(safe-area-inset-bottom, 0px); +} +.allen-panes[data-layout="sheet"] .allen-pane.is-swiping { will-change: transform; } +.allen-panes[data-layout="sheet"] .allen-pane:not([data-top]) { display: none; } +.allen-panes[data-layout="sheet"] :is(.allen-pane-move, .allen-pane-size, .allen-pane-max) { display: none; } +.allen-panes[data-layout="sheet"] .allen-pane-head { cursor: default; padding-top: 0; } +.allen-panes[data-layout="sheet"] .allen-panes-dock { left: 16px; right: 16px; transform: none; justify-content: flex-start; } +.allen-panes[data-layout="sheet"] .allen-pane-grab { + display: block; + flex: none; + width: 100%; + height: 28px; + padding: 0; + border: 0; + background: linear-gradient(var(--text-muted), var(--text-muted)) center / 40px 4px no-repeat; + border-radius: var(--allen-pane-radius) var(--allen-pane-radius) 0 0; + touch-action: none; + cursor: grab; + opacity: .8; +} +.allen-panes[data-layout="sheet"] :is(.allen-pane-ctl, .allen-panes-chip, .allen-panes-tool) { min-width: 44px; min-height: 44px; } +.allen-panes[data-layout="sheet"] .allen-pane-act { min-height: 44px; padding: 10px 18px; } +.allen-panes[data-layout="sheet"] .allen-pane-foot { padding-bottom: max(14px, env(safe-area-inset-bottom, 0px)); } + +@media (prefers-reduced-motion: no-preference) { + .allen-pane { animation: allen-pane-in 180ms cubic-bezier(.2, .7, .2, 1) both; } + .allen-panes[data-layout="sheet"] .allen-pane:not(.is-swiping) { transition: transform 160ms cubic-bezier(.2, .7, .2, 1); } + @keyframes allen-pane-in { from { opacity: 0; } to { opacity: 1; } } +} +@media (forced-colors: active) { + .allen-pane, .allen-panes-dock { border-color: CanvasText; background: Canvas; } +} diff --git a/public/assets/allen.css b/public/assets/allen.css index 300a23a..ea44ddc 100644 --- a/public/assets/allen.css +++ b/public/assets/allen.css @@ -1,137 +1,47 @@ -/* /allen/: the chat window. Structure comes from om/allen-page/allen.om; this - file only lays it out with the palette tokens of style.css. The only motion - is opacity, and it stops for reduced-motion. Nothing loads from outside. */ - -.allen { - max-width: 980px; - margin: 0 auto; - padding: 10px 20px 28px; - color: var(--text-primary); -} - -.allen-head { margin-bottom: 8px; } -.allen-eyebrow { - font-family: var(--font-mono); - font-size: 12px; - letter-spacing: 0.08em; - text-transform: uppercase; - color: var(--accent-green); -} -.allen-title { font-size: 26px; line-height: 1.15; margin: 2px 0 4px; } -.allen-lede { font-size: 15px; color: var(--text-secondary); max-width: 80ch; } -.allen-where { margin-top: 4px; font-size: 13px; color: var(--text-muted); } -.allen-where code { - font-family: var(--font-mono); - color: var(--text-primary); - background: var(--bg-card); - border: 1px solid var(--border-subtle); - border-radius: 4px; - padding: 0 5px; -} - -.allen-panel { - background: var(--bg-surface); - border: 1px solid var(--border-subtle); - border-radius: 10px; - padding: 12px; - display: flex; - flex-direction: column; - gap: 10px; -} - -/* Speed: one compact band of measured numbers. */ -.allen-speed { - display: grid; - grid-template-columns: repeat(5, minmax(0, 1fr)); - gap: 6px; -} -.allen-stat { - background: var(--bg-card); - border: 1px solid var(--border-subtle); - border-radius: 6px; - padding: 5px 8px; - min-width: 0; -} -.allen-stat dt { - font-size: 11px; - letter-spacing: 0.04em; - text-transform: uppercase; - color: var(--text-muted); -} -.allen-stat dd { - font-family: var(--font-mono); - font-size: 14px; - font-variant-numeric: tabular-nums; - overflow-wrap: anywhere; -} -/* The server's own count closes the band as one quiet line. */ -.allen-stat:last-child { - grid-column: 1 / -1; - display: flex; - flex-wrap: wrap; - align-items: baseline; - gap: 0 8px; - padding: 0 2px; - background: none; - border: 0; -} -.allen-stat:last-child dd { font-size: 12px; color: var(--text-secondary); } - -/* The log scrolls inside a bounded box. column-reverse keeps the newest line - in view while the reply streams, without script, and leaves the reader where - they are once they scroll up. */ -.allen-scroll { - display: flex; - flex-direction: column-reverse; - overflow-y: auto; - overscroll-behavior: contain; - /* Tall enough to read, short enough that the form stays on a 768 px screen. */ - height: clamp(12rem, calc(100vh - 560px), 40rem); - height: clamp(12rem, calc(100dvh - 560px), 40rem); - background: var(--bg-base); - border: 1px solid var(--border-subtle); - border-radius: 8px; -} -.allen-log { - list-style: none; - display: flex; - flex-direction: column; - gap: 12px; - padding: 12px; -} -.allen-log:empty::before { - content: "Say hello, or pick an example below."; - color: var(--text-muted); - font-size: 14px; -} - -.allen-msg { max-width: 100%; min-width: 0; } -.allen-msg-user { - align-self: flex-end; - max-width: min(100%, 44rem); - background: var(--bg-card); - border: 1px solid var(--border-subtle); - border-radius: 8px; - padding: 8px 10px; -} -.allen-who { - font-size: 11px; - font-weight: 700; - letter-spacing: 0.06em; - text-transform: uppercase; - color: var(--text-muted); - margin-bottom: 2px; -} +/* Allen's immersive surface. Native scene pixels sit behind accessible DOM + controls; cards and session history retain the chat client's safe renderer. */ +body:has([id="allen"]) { overflow: hidden; } +body:has([id="allen"]) .aien-header, +body:has([id="allen"]) .aien-footer, +body:has([id="allen"]) [id="aien-allen-launcher"] { display: none; } +.allen { position: fixed; inset: 0; top: var(--allen-view-top, 0px); bottom: auto; height: var(--allen-view-height, 100dvh); z-index: 100; color: var(--text-primary); background: var(--bg-base); font-family: var(--font-sans, sans-serif); } +.allen-universe { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pinch-zoom; } +.allen-space-tools { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 20px; display: flex; align-items: center; gap: 10px; z-index: 30; } +.allen-space-tools .allen-tool { background: color-mix(in srgb, var(--bg-base) 72%, transparent); } +.allen-arrival { position: absolute; inset: 48% 16px auto; text-align: center; z-index: 20; } +.allen-arrival h1 { font-size: clamp(20px, 3vw, 34px); font-weight: 400; letter-spacing: -.025em; margin-bottom: 24px; } +.allen-arrival p { margin-top: 14px; font-size: 12px; color: var(--text-secondary); } +.allen-enter { padding: 12px 28px; border-radius: 999px; color: var(--text-primary); border: 1px solid var(--border-subtle); background: linear-gradient(var(--bg-card-hover), var(--bg-base)); cursor: pointer; font: inherit; } +.allen-current { position: absolute; top: 61%; left: 50%; width: min(760px, calc(100% - 40px)); transform: translateX(-50%); text-align: center; z-index: 5; pointer-events: none; } +.allen:not([data-entered="true"]) .allen-current, +.allen:not([data-entered="true"]) .allen-bottom { visibility: hidden; } +.allen-guest { color: var(--text-muted); font-size: 12px; max-height: 2.8em; overflow: hidden; margin-bottom: 8px; } +.allen-speaker { color: var(--text-secondary); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; } +.allen-answer { white-space: pre-wrap; overflow-wrap: anywhere; font-size: clamp(16px, 2vw, 21px); line-height: 1.5; max-height: 18vh; overflow-y: auto; pointer-events: auto; scrollbar-width: thin; padding: 8px 12px; background: radial-gradient(ellipse, color-mix(in srgb, var(--bg-base) 80%, transparent), transparent); } +.allen-letter { position: relative; animation: allen-letter-fade 260ms both, allen-letter-rise 360ms both, allen-letter-color 900ms both; } +@keyframes allen-letter-fade { from { opacity: 0; } to { opacity: 1; } } +@keyframes allen-letter-rise { from { top: 6px; } to { top: 0; } } +@keyframes allen-letter-color { from { color: rgb(255, 212, 150); } to { color: rgb(234, 238, 252); } } +.allen-reply-actions { display: flex; justify-content: center; gap: 8px; margin-top: 8px; pointer-events: auto; } +.allen-reply-actions .allen-tool { font-size: 11px; background: color-mix(in srgb, var(--bg-base) 70%, transparent); } +.allen-panel { display: contents; } +.allen-mode { position: absolute; top: 64px; right: 20px; z-index: 25; font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; } +.allen-mode .allen-tool { font-size: 11px; } +.allen-session { position: absolute; z-index: 40; right: 16px; top: 108px; bottom: 140px; width: min(480px, calc(100% - 32px)); overflow: auto; overscroll-behavior: contain; border: 1px solid var(--border-subtle); border-radius: 18px; padding: 22px; background: color-mix(in srgb, var(--bg-surface) 96%, transparent); box-shadow: 0 16px 64px color-mix(in srgb, var(--bg-base) 70%, transparent); } +.allen-session > * + * { margin-top: 16px; } +.allen-head { margin-bottom: 12px; } +.allen-title { font-size: 22px; font-weight: 500; margin-bottom: 8px; } +.allen-lede, .allen-where { font-size: 13px; color: var(--text-secondary); line-height: 1.6; } +.allen-speed { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } +.allen-stat { font-size: 11px; padding: 8px; background: var(--bg-card); border-radius: 6px; } +.allen-stat dt { color: var(--text-muted); } +.allen-stat dd { font-family: var(--font-mono); } +.allen-scroll { overflow-y: auto; max-height: 48vh; overscroll-behavior: contain; } +.allen-log { list-style: none; display: flex; flex-direction: column; gap: 18px; padding: 0; } +.allen-msg { min-width: 0; } +.allen-msg-user { padding: 8px 12px; border-left: 1px solid var(--border-subtle); } +.allen-who { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; } .allen-msg-allen .allen-who { color: var(--accent-green); } -.allen-msg[aria-busy="true"] .allen-who::after { - content: " writing"; - font-weight: 400; - text-transform: none; - letter-spacing: 0; - animation: allen-pulse 1.2s ease-in-out infinite alternate; -} -@keyframes allen-pulse { from { opacity: 0.35; } to { opacity: 1; } } - .allen-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; } .allen-p, .allen-h { @@ -394,34 +304,22 @@ .allen-examples { display: flex; flex-wrap: wrap; gap: 6px; } .allen-status { min-height: 1.4em; font-size: 14px; color: var(--text-secondary); } -.allen-form { - display: grid; - grid-template-columns: minmax(0, 1fr) auto; - gap: 8px; -} -.allen-form textarea { - width: 100%; - height: 4.75rem; - min-height: 3rem; - max-height: 40vh; - resize: vertical; - font: inherit; - font-size: 15px; - padding: 8px 10px; - color: var(--text-primary); - background: var(--bg-base); - border: 1px solid var(--border-subtle); - border-radius: 8px; -} -.allen-actions { - display: grid; - grid-template-columns: auto auto; - align-content: space-between; - gap: 6px; -} -.allen-actions .allen-send { background: var(--accent-blue); border-color: var(--accent-blue); font-weight: 600; } -.allen-actions .allen-send:hover { background: var(--accent-blue); } -.allen-actions .allen-new { grid-column: 1 / -1; } +.allen-bottom { position: absolute; z-index: 25; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(780px, calc(100% - 32px)); } +.allen-bottom .allen-status { text-align: center; font-size: 12px; } +.allen-form { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 24px; border: 1px solid color-mix(in srgb, var(--text-secondary) 28%, transparent); border-radius: 999px; background: linear-gradient(180deg, color-mix(in srgb, var(--text-primary) 12%, var(--bg-base)), var(--bg-base) 55%, color-mix(in srgb, var(--bg-card) 75%, transparent)); box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text-primary) 14%, transparent), 0 8px 24px color-mix(in srgb, var(--bg-base) 80%, transparent); } +.allen-form textarea { flex: 1; width: 100%; min-width: 0; height: 36px; max-height: 120px; resize: none; font: inherit; font-size: 16px; line-height: 24px; padding: 6px 0; color: var(--text-primary); background: transparent; border: 0; border-radius: 0; scrollbar-width: thin; } +.allen-form textarea:focus-visible { outline: 0; } +.allen-form:focus-within { border-color: var(--accent-blue); } +.allen-actions { display: flex; gap: 6px; } +.allen-actions button { border-radius: 999px; min-height: 36px; } +.allen-actions .allen-send { color: var(--text-primary); background: var(--bg-card-hover); } +.allen-input-hint { text-align: center; font-size: 10px; color: var(--text-muted); margin-top: 7px; } +.allen-voice-status { text-align: center; font-size: 11px; color: var(--text-secondary); margin-top: 6px; } +.allen-voice-status:empty { display: none; } +.allen-mic[data-state="listening"], .allen-mic[data-state="starting"] { color: var(--accent-amber); border-color: var(--accent-amber); } +.allen-mic[data-state="sending"], .allen-mic[data-state="stopping"] { color: var(--accent-blue); border-color: var(--accent-blue); } +.allen-voice-browser { display: block; margin: 6px auto 0; font-size: 11px; } +.allen-voice-browser[hidden] { display: none; } .allen-privacy { font-size: 13px; color: var(--text-muted); } .allen-foot { margin-top: 14px; font-size: 13px; color: var(--text-muted); } @@ -438,16 +336,19 @@ } @media (max-width: 640px) { - .allen { padding: 12px 10px 20px; } - .allen-title { font-size: 24px; } - .allen-panel { padding: 8px; } - .allen-speed { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .allen-scroll { height: auto; min-height: 14rem; max-height: 62vh; } - .allen-form { grid-template-columns: minmax(0, 1fr); } - .allen-actions { display: flex; flex-wrap: wrap; } - .allen-actions .allen-new { margin-left: auto; } + .allen-space-tools { right: 10px; gap: 5px; } + .allen-space-tools .allen-tool { font-size: 11px; padding: 7px; } + .allen-mode { left: 16px; right: 16px; top: 62px; justify-content: center; } + .allen-mode span { max-width: 68%; } + .allen-current { top: 56%; width: calc(100% - 24px); } + .allen-answer { max-height: 21vh; font-size: 16px; } + .allen-session { top: 100px; bottom: 126px; } + .allen-bottom { bottom: max(12px, env(safe-area-inset-bottom)); } + .allen-form { padding-left: 16px; } + .allen-actions button { padding: 5px 8px; } + .allen-space-tools .allen-tool, .allen-actions button { min-width: 44px; min-height: 44px; } + .allen-input-hint { font-size: 10px; margin-top: 4px; } } - @media (prefers-reduced-motion: reduce) { - .allen-msg[aria-busy="true"] .allen-who::after { animation: none; } + .allen *, .allen *::before, .allen *::after { animation: none !important; transition: none !important; } } diff --git a/public/audio/allen-chirp.wav b/public/audio/allen-chirp.wav new file mode 100644 index 0000000..cc8acf7 Binary files /dev/null and b/public/audio/allen-chirp.wav differ diff --git a/public/js/allen-audio.js b/public/js/allen-audio.js new file mode 100644 index 0000000..e6b0022 --- /dev/null +++ b/public/js/allen-audio.js @@ -0,0 +1,205 @@ +/* + * allen-audio.js: Allen's startup sound, the one the iMac plays as its two + * black holes merge. Generated by om/allen-audio (Omega); do not edit. + * + * The sound is ../audio/allen-chirp.wav, written sample for sample by + * om/allen-audio/chirp.om, a port of aienux native/kernel/ui/chirp.c at + * da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c. It holds frames 545280 to 590400 + * of the night at 48000 Hz, 16-bit mono (the native left and right samples + * are equal): 11360 ms to 12300 ms of the night, the merger at 12000 ms. + * This script only plays it. + * + * window.AllenAudio + * enter(arg) call inside a click or key press. The only place an audio + * context is created or resumed. arg is a scene kind or + * { kind, nightMs }. The native source has one sound, the + * merger chirp of the two-hole night (kind 'night', alias + * 'home', the default); any other kind (the /allen/ tube + * included) has no native sound and resolves false without + * touching audio. nightMs is where the night is at the moment + * of the call (default 0: the night starts now). As on the + * iMac, the sound lands on the merger: + * before 11360 ms it waits, inside the chirp it starts from + * that moment, after 12300 ms nothing plays. While a sound + * is pending or playing, enter returns the same promise; + * after it ends or stops, the next gesture may enter again + * (a replay). Resolves true once the sound is scheduled, + * false when muted, unsupported, stopped or too late; never + * rejects. + * pause() suspends the audio context: its clock and the sound + * freeze together, as the scene's clock does. Done by + * itself when the page is hidden, so no chirp plays in the + * background. + * resume() resumes a context pause() suspended (the scene calls it + * when it runs again); never creates one, and does nothing + * while muted. + * stop() stops the sound and closes the audio context; done by + * itself on pagehide. Call it when the scene is destroyed + * or replayed. + * setMuted(b) stores the choice in localStorage 'allen.audio.muted' + * ('1' or '0'), the only key this script writes; muting + * stops the sound. + * muted() the stored choice. + * data-chirp-src on this script's tag points elsewhere (resolved against the + * page); by default the file sits beside this script's folder, so the same + * bytes work on aienos.com and on a localhost install. + */ +(function () { + 'use strict'; + var KEY = 'allen.audio.muted'; + var RATE = 48000; + var FRAMES = 45120; + var START_MS = 11360; + var MERGE_MS = 12000; + var END_MS = 12300; + + var me = document.currentScript; + var pick = me && me.getAttribute('data-chirp-src'); + var src = pick ? new URL(pick, location.href).href + : new URL('../audio/allen-chirp.wav', (me && me.src) || location.href).href; + + var ctx = null; + var node = null; + var entered = null; + var paused = false; + var pausedAt = 0; + var pausedMs = 0; + + function stored() { + try { return window.localStorage.getItem(KEY) === '1'; } catch (e) { return false; } + } + var isMuted = stored(); + + function close() { + var n = node; + var c = ctx; + node = null; + ctx = null; + entered = null; + paused = false; + if (n) { + n.onended = null; + try { n.stop(); } catch (e) { /* not started yet */ } + n.disconnect(); + } + if (c && c.close && c.state !== 'closed') c.close().then(null, function () {}); + } + + function word(v, at) { return v.getUint32(at, true); } + function half(v, at) { return v.getUint16(at, true); } + + /* The asset's exact header, or nothing: mono 16-bit PCM at RATE, FRAMES long. */ + function pcm(bytes) { + if (bytes.byteLength !== 44 + 2 * FRAMES) return null; + var v = new DataView(bytes); + if (word(v, 0) !== 0x46464952 || word(v, 4) !== 36 + 2 * FRAMES || word(v, 8) !== 0x45564157 || + word(v, 12) !== 0x20746d66 || word(v, 16) !== 16 || half(v, 20) !== 1 || half(v, 22) !== 1 || + word(v, 24) !== RATE || word(v, 28) !== 2 * RATE || half(v, 32) !== 2 || half(v, 34) !== 16 || + word(v, 36) !== 0x61746164 || word(v, 40) !== 2 * FRAMES) return null; + var out = new Float32Array(FRAMES); + for (var i = 0; i < FRAMES; i++) out[i] = v.getInt16(44 + 2 * i, true) / 32768; + return out; + } + + /* A silent frame started inside the gesture: some browsers unlock output only so. */ + function unlock(c) { + try { + var s = c.createBufferSource(); + s.buffer = c.createBuffer(1, 1, c.sampleRate); + s.connect(c.destination); + s.start(0); + } catch (e) { /* the real sound still tries */ } + } + + function play(c, samples, night) { + if (c !== ctx || isMuted || night >= END_MS) return false; + var buf = c.createBuffer(1, FRAMES, RATE); + buf.getChannelData(0).set(samples); + var n = c.createBufferSource(); + n.buffer = buf; + n.connect(c.destination); + n.onended = function () { if (node === n) close(); }; + node = n; + if (night < START_MS) n.start(c.currentTime + (START_MS - night) / 1000); + else n.start(0, (night - START_MS) / 1000); + return true; + } + + var KINDS = { night: 1, home: 1 }; + + function enter(arg) { + var opts = typeof arg === 'string' ? { kind: arg } : arg || {}; + if (!KINDS.hasOwnProperty(opts.kind || 'night')) return Promise.resolve(false); + if (entered) return entered; + var t0 = performance.now(); + pausedMs = 0; + var base = typeof opts.nightMs === 'number' && opts.nightMs >= 0 ? opts.nightMs : 0; + var AC = window.AudioContext || window.webkitAudioContext; + if (isMuted || !AC || !window.fetch || base >= END_MS) return Promise.resolve(false); + var c; + try { c = new AC(); } catch (e) { return Promise.resolve(false); } + ctx = c; + if (c.resume) c.resume().then(null, function () {}); + unlock(c); + entered = fetch(src, { credentials: 'same-origin' }) + .then(function (r) { + if (!r.ok) throw new Error('allen-chirp.wav ' + r.status); + return r.arrayBuffer(); + }) + .then(function (bytes) { + var samples = pcm(bytes); + var held = pausedMs + (paused ? performance.now() - pausedAt : 0); + var ok = samples ? play(c, samples, base + performance.now() - t0 - held) : false; + if (!ok && ctx === c) close(); + return ok; + }) + .then(null, function () { + if (ctx === c) close(); + return false; + }); + return entered; + } + + function pause() { + if (!ctx || paused) return; + paused = true; + pausedAt = performance.now(); + if (ctx.suspend) ctx.suspend().then(null, function () {}); + } + + function resume() { + if (!ctx || !paused || isMuted) return; + paused = false; + pausedMs += performance.now() - pausedAt; + if (ctx.resume) ctx.resume().then(null, function () {}); + } + + function setMuted(on) { + isMuted = !!on; + try { window.localStorage.setItem(KEY, isMuted ? '1' : '0'); } catch (e) { /* kept for this page */ } + if (isMuted) close(); + } + + document.addEventListener('visibilitychange', function () { + if (document.visibilityState === 'hidden') pause(); + }); + window.addEventListener('pagehide', close); + + window.addEventListener('storage', function (e) { + if (e.key !== KEY) return; + isMuted = e.newValue === '1'; + if (isMuted) close(); + }); + + window.AllenAudio = Object.freeze({ + enter: enter, + stop: close, + pause: pause, + resume: resume, + setMuted: setMuted, + muted: function () { return isMuted; }, + src: src, + kinds: Object.freeze(['night', 'home']), + timeline: Object.freeze({ rate: RATE, frames: FRAMES, startMs: START_MS, mergeMs: MERGE_MS, endMs: END_MS }) + }); +})(); diff --git a/public/js/allen-install.js b/public/js/allen-install.js new file mode 100644 index 0000000..98a04a3 --- /dev/null +++ b/public/js/allen-install.js @@ -0,0 +1,190 @@ +/* Generated from om/allen-install/install.om; never hand-edit. + * + * The offer to put Aien on the home screen. It appears only after the first + * exchange the visitor started that ended with a real reply, never on load or + * on the greeting. The browser install prompt opens only inside the visitor's + * tap on the offer. One local preference (dismissed, accepted, guided or + * installed) stops further offers; nothing else is stored and nothing is sent. + * Success is reported only when the browser fires appinstalled. + */ +(() => { +'use strict'; +if (window.AllenInstall) return; +const KEY = 'allen-install'; +const TITLE = 'Put me on your home screen'; +const SVG = 'http://www.w3.org/2000/svg'; +let deferred = null, earned = false, asked = false, open = null, memo = '', connected = false; +function remembered() { + if (memo) return memo; + try { return window.localStorage.getItem(KEY) || ''; } catch (_) { return ''; } +} +function remember(value) { + memo = value; + try { window.localStorage.setItem(KEY, value); } catch (_) {} +} +function installed() { + try { if (window.navigator.standalone === true) return true; } catch (_) {} + try { + for (const mode of ['standalone', 'minimal-ui', 'fullscreen', 'window-controls-overlay']) if (window.matchMedia(`(display-mode: ${mode})`).matches) return true; + } catch (_) {} + return false; +} +function appleSafari() { + const ua = String(window.navigator.userAgent || ''); + const apple = /iPhone|iPad|iPod/.test(ua) || (/Macintosh/.test(ua) && window.navigator.maxTouchPoints > 1); + return apple && /Safari/.test(ua) && !/CriOS|FxiOS|EdgiOS|OPiOS|GSA|FBAN|FBAV|Instagram/.test(ua); +} +function el(tag, cls, text) { + const node = document.createElement(tag); + if (cls) node.className = cls; + if (text) node.textContent = text; + return node; +} +function button(cls, text, fn) { + const node = el('button', cls, text); + node.type = 'button'; + node.addEventListener('click', fn); + return node; +} +function icon(label, lines) { + const svg = document.createElementNS(SVG, 'svg'); + svg.setAttribute('viewBox', '0 0 24 24'); + svg.setAttribute('width', '28'); + svg.setAttribute('height', '28'); + svg.setAttribute('class', 'allen-install-icon'); + if (label) { + svg.setAttribute('role', 'img'); + svg.setAttribute('aria-label', label); + } else svg.setAttribute('aria-hidden', 'true'); + for (const d of lines) { + const path = document.createElementNS(SVG, 'path'); + path.setAttribute('d', d); + svg.appendChild(path); + } + return svg; +} +function step(svg, before, strong, after) { + const item = el('li', 'allen-install-step'); + const words = el('span', 'allen-install-words'); + words.append(before, el('strong', '', strong), after); + item.append(svg, words); + return item; +} +function guide() { + const list = el('ol', 'allen-install-steps'); + list.setAttribute('role', 'list'); + list.append( + step(icon('Share icon: a square with an arrow pointing up', ['M8 10H6v10h12V10h-2', 'M12 15V3', 'M8 7l4-4 4 4']), 'In Safari, tap ', 'Share', '. If you do not see it, tap the three dots first.'), + step(icon('Add to Home Screen icon: a square with a plus', ['M7 4h10a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3z', 'M12 8v8', 'M8 12h8']), 'Choose ', 'Add to Home Screen', ', then tap Add.') + ); + return list; +} +function offer() { + if (open || !earned || remembered() || installed()) return; + if (!deferred && !appleSafari()) return; + const box = el('div', 'allen-install'); + const lede = el('p', 'allen-install-lede', 'Keep me one tap away. Your browser adds me to your home screen, and you can remove me the way you remove any app.'); + const state = el('p', 'allen-install-state'); + state.setAttribute('role', 'status'); + const actions = el('div', 'allen-install-actions'); + const card = { box, state, actions, buttons: [], handle: null, inline: null, watch: null, closing: false }; + open = card; + card.buttons.push(button('allen-pane-act allen-pane-run allen-install-yes', TITLE, () => accept(card)), button('allen-pane-act allen-install-no', 'No thanks', () => dismiss(card))); + actions.append(...card.buttons); + box.append(lede, actions, state); + place(card); +} +function dismiss(card) { + if (!remembered()) remember('dismissed'); + shut(card); +} +function finish(card, text) { + card.state.textContent = text; + card.actions.replaceChildren(button('allen-pane-act allen-install-done', 'Close', () => shut(card))); +} +function accept(card) { + const event = deferred; + if (event) { + deferred = null; + for (const b of card.buttons) b.disabled = true; + let asking; + try { asking = Promise.resolve(event.prompt()); } catch (_) { asking = Promise.reject(new Error('prompt')); } + asking.then(() => event.userChoice).then(choice => { + if (remembered() === 'installed') return; + if (choice && choice.outcome === 'accepted') { + remember('accepted'); + finish(card, 'Your browser is adding me. I will say so here when it confirms.'); + } else { + remember('dismissed'); + finish(card, 'No problem. I will not ask again on this device.'); + } + }, () => finish(card, 'Your browser did not open its install prompt, so nothing changed.')); + return; + } + if (appleSafari()) { + card.box.insertBefore(guide(), card.actions); + remember('guided'); + finish(card, 'I cannot see your home screen from here, so I will not offer this again on this device.'); + } +} +function shut(card) { + if (card.closing) return; + card.closing = true; + if (card.watch) card.watch.disconnect(); + if (open === card) open = null; + if (card.handle && typeof card.handle.close === 'function') card.handle.close(); + if (card.inline) card.inline.remove(); + else card.box.remove(); +} +function place(card) { + const detail = { id: 'install', title: TITLE, node: card.box, focus: false, handle: null }; + const request = new CustomEvent('allen-pane-request', { cancelable: true, detail }); + if (!document.dispatchEvent(request) && detail.handle && detail.handle.ok) card.handle = detail.handle; + else { + const aside = el('aside', 'allen-install-inline'); + aside.setAttribute('aria-label', TITLE); + const head = el('div', 'allen-install-head'); + const close = button('allen-install-close', '', () => dismiss(card)); + close.setAttribute('aria-label', 'Close, and do not offer this again'); + close.appendChild(icon('', ['M6 6l12 12', 'M18 6L6 18'])); + head.append(el('p', 'allen-install-title', TITLE), close); + aside.append(head, card.box); + const answer = document.getElementById('allen-answer'); + const spot = document.getElementById('allen-install-slot') || (answer && answer.parentNode) || document.getElementById('allen') || document.body; + spot.appendChild(aside); + card.inline = aside; + } + if (typeof MutationObserver === 'function') { + card.watch = new MutationObserver(() => { + if (!card.box.isConnected && !card.closing) dismiss(card); + }); + card.watch.observe(document.documentElement, { childList: true, subtree: true }); + } +} +function connect() { + const api = window.allen; + if (connected || !api || typeof api.on !== 'function') return; + connected = true; + api.on('send', event => { asked = !event.silent; }); + api.on('reply', event => { + const good = asked && !event.outcome && typeof event.text === 'string' && event.text.trim() !== ''; + asked = false; + if (!good) return; + earned = true; + offer(); + }); +} +window.addEventListener('beforeinstallprompt', event => { + event.preventDefault(); + deferred = event; + offer(); +}); +window.addEventListener('appinstalled', () => { + deferred = null; + remember('installed'); + if (open) finish(open, 'Your browser says I am installed. Open me from your home screen or app list.'); +}); +document.addEventListener('allen-ready', connect); +connect(); +window.AllenInstall = Object.freeze({ version: 1 }); +})(); diff --git a/public/js/allen-intro.js b/public/js/allen-intro.js index 216032d..d3b338f 100644 --- a/public/js/allen-intro.js +++ b/public/js/allen-intro.js @@ -1,24 +1,65 @@ -/* Saying hello to Allen consents to X pixel rfrlz. No external load before yes. */ +/* Generated by om/allen-intro/intro.om. Edit the Omega source, then run om/allen-intro/check.sh. */ +/* Aien (Allen internally) says hello once. Say hi consents to X pixel rfrlz. No external load before yes. */ (function () { 'use strict'; // Drake supplies the real X event IDs. Empty means disabled, never a fake event. const eventIds = Object.freeze({ pageVisit: '', introducedToAllen: '' }); var conversionIds = {}; var key = 'aien-allen-intro-consent'; + var seenKey = 'aien-allen-intro-seen'; var clickKey = 'aien-allen-intro-twclid'; var landingClick = new URLSearchParams(window.location.search).get('twclid'); - var dialog = document.getElementById('aien-allen-intro'); - if (!dialog || dialog.dataset.ready) return; - dialog.dataset.ready = 'true'; + var aside = document.getElementById('aien-allen-intro'); + if (!aside || aside.dataset.ready) return; + aside.dataset.ready = 'true'; var choice = null; var loaded = false; var previousFocus = null; + var timer = null; + var offering = true; var status = document.getElementById('allen-intro-status'); + var title = document.getElementById('allen-intro-title'); + var typed = document.getElementById('allen-intro-typed'); + var spoken = document.getElementById('allen-intro-spoken'); + var offerLine = document.getElementById('allen-intro-offer'); + var gpcLine = document.getElementById('allen-intro-gpc'); + var yes = document.getElementById('allen-intro-yes'); + var no = document.getElementById('allen-intro-no'); + var greeting = title.textContent; + var message = ''; + // Global Privacy Control: Allen does not offer the pixel unless the visitor asks to review. + var gpc = window.navigator.globalPrivacyControl === true; + var still = !window.matchMedia || window.matchMedia('(prefers-reduced-motion: reduce)').matches; try { choice = localStorage.getItem(key); } catch (_) { /* No stored consent. */ } // Session refusal also wins if local storage became read-only after a Yes. try { if (sessionStorage.getItem(key) === 'no') choice = 'no'; } catch (_) {} if (window.location.hash === '#allen-intro-no') choice = 'no'; + // Once per browser; without local storage, once per tab session. + function seen() { + var mark = null; + try { mark = localStorage.getItem(seenKey); } catch (_) {} + if (!mark) try { mark = sessionStorage.getItem(seenKey); } catch (_) {} + return !!mark; + } + function markSeen() { + try { localStorage.setItem(seenKey, '1'); return; } catch (_) {} + try { sessionStorage.setItem(seenKey, '1'); } catch (_) {} + } + + // The chat page (/aien/, formerly /allen/) renders #allen with data-mode="anonymous" until its own memory consent. + function anonymousChat() { + var chat = document.getElementById('allen'); + return !!chat && chat.dataset.mode !== 'remembered'; + } + + // Allen's presence layer renders on these events and acts only through the API below. + function announce(type, detail) { + var data = detail || {}; + data.type = type; + document.dispatchEvent(new window.CustomEvent('aien-allen-intro', { detail: data })); + } + function sendEvent(kind) { var id = eventIds[kind]; if (choice !== 'yes' || !loaded || !id || conversionIds[kind]) return; @@ -29,7 +70,8 @@ } function loadPixel() { - if (choice !== 'yes' || loaded) return; + // Anonymous chat on /aien/ (#allen data-mode != remembered) never loads the pixel. + if (choice !== 'yes' || loaded || anonymousChat()) return; // Retain attribution only in a consenting visitor's browser, not on a server. if (landingClick) { try { localStorage.setItem(clickKey, landingClick); } catch (_) {} @@ -45,17 +87,75 @@ function describe(saved) { if (status) status.textContent = (choice === 'yes' - ? 'You said hello to Allen. X tracking is allowed in this browser.' - : 'You have not agreed to say hello to Allen. X tracking is off.') + ? 'You said hi to Aien. X tracking is allowed in this browser.' + : 'You have not said hi to Aien. X tracking is off.') + (saved === false ? ' Your browser could not save this choice; it applies to this page only.' : ''); } + // Static text typed on the client: no model call. Allen's native cadence is one letter per + // 35 ms. With data-letters="true" on #allen-intro-typed each letter is its own + // span.allen-intro-letter, so the presence CSS can fade, raise and recolour it as it arrives. + // Reduced motion shows the whole text at once as plain text. + var letterMs = 35; + function type() { + var head = typed.firstChild; + var tail = typed.lastChild; + var whole = greeting + ' ' + message; + var letters = !still && typed.dataset.letters === 'true'; + var shown = still ? whole.length : 0; + head.textContent = ''; + tail.textContent = ''; + function paint() { + if (letters) { + if (shown > 0) { + var letter = document.createElement('span'); + letter.className = 'allen-intro-letter'; + letter.textContent = whole.charAt(shown - 1); + (shown <= greeting.length ? head : tail).appendChild(letter); + } + } else { + head.textContent = whole.slice(0, Math.min(shown, greeting.length)); + tail.textContent = whole.slice(greeting.length, shown); + } + if (shown >= whole.length) { timer = null; return; } + shown += 1; + timer = setTimeout(paint, letterMs); + } + paint(); + } + function close() { - if (dialog.open) dialog.close(); - if (previousFocus && previousFocus.isConnected) previousFocus.focus(); + clearTimeout(timer); + timer = null; + var wasShown = !aside.hidden; + var inside = aside.contains(document.activeElement); + aside.classList.remove('allen-intro-in'); + aside.hidden = true; + spoken.textContent = ''; + if (inside && previousFocus && previousFocus.isConnected) previousFocus.focus(); + previousFocus = null; + if (wasShown) announce('hide'); + } + + // The greeting, the chat choices and the separate X pixel ask; No thanks swaps them out. + var greetingParts = ['allen-intro-message', 'allen-intro-chat', 'allen-intro-x']; + function showGreeting(on) { + greetingParts.forEach(function (id) { document.getElementById(id).hidden = !on; }); + document.getElementById('allen-intro-after').hidden = on; } - function choose(value) { + // No thanks: no pixel and no memory, but Allen stays to offer an anonymous chat. + function replyNo() { + clearTimeout(timer); + timer = null; + showGreeting(false); + gpcLine.hidden = true; + spoken.textContent = document.getElementById('allen-intro-after-text').textContent; + document.getElementById('allen-intro-anon').focus(); + announce('reply-no'); + } + + function choose(value, reply) { choice = value; var saved = true; try { localStorage.setItem(key, value); } catch (_) { saved = false; } @@ -69,11 +169,13 @@ if (value === 'yes' && window.location.hash === '#allen-intro-no') { history.replaceState(null, '', window.location.pathname + window.location.search); } - close(); + if (reply && offering && value === 'no' && !loaded) replyNo(); + else close(); describe(saved); if (value === 'yes') { loadPixel(); sendEvent('introducedToAllen'); + announce('consent', { pixelLoaded: loaded }); } // A loaded third-party script cannot be recalled. A fresh document stops it. else if (loaded) { @@ -83,19 +185,96 @@ } } - function open() { - if (dialog.open) return; - previousFocus = document.activeElement; - dialog.showModal(); - document.getElementById('allen-intro-no').focus(); + // Never a modal: no backdrop, no inert page. Focus moves only when the visitor asked. + function open(asked) { + if (!aside.hidden) return; + // Under GPC the pixel is not offered unless the visitor asked to review it. + offering = asked || !gpc; + showGreeting(true); + document.getElementById('allen-intro-x').hidden = !offering; + gpcLine.hidden = offering; + message = document.getElementById('allen-intro-intro').textContent; + previousFocus = asked ? document.activeElement : null; + aside.hidden = false; + spoken.textContent = greeting + ' ' + message + ' ' + (offering ? offerLine : gpcLine).textContent; + type(); + void aside.offsetWidth; + aside.classList.add('allen-intro-in'); + if (asked) no.focus(); + announce('show', { asked: !!asked, offering: offering }); + } + + // "Who can see me right now?": read only from this document and browser, shown + // only here, never sent or stored. Resource timing lists every origin this tab loaded. + var who = document.getElementById('allen-intro-who'); + var trackers = document.getElementById('allen-intro-trackers'); + var thirdParty = []; + var facts = []; + var trackerListeners = []; + var watching = false; + function countTrackers() { + document.getElementById('allen-intro-tracker-count').textContent = String(thirdParty.length); + document.getElementById('allen-intro-trackers-none').hidden = thirdParty.length > 0; + } + function noteResource(entry) { + var url; + try { url = new URL(entry.name, window.location.href); } catch (_) { return; } + if (!/^https?:$/.test(url.protocol) || url.origin === window.location.origin) return; + if (thirdParty.some(function (seenOrigin) { return seenOrigin.origin === url.origin; })) return; + // Only an X origin loaded after Say hi in this document is called Drake's pixel. + var tracker = { origin: url.origin, pixel: choice === 'yes' && loaded && /(^|\.)(ads-twitter\.com|twitter\.com|x\.com|t\.co)$/.test(url.hostname) }; + thirdParty.push(tracker); + var item = document.createElement('li'); + item.textContent = url.host + (tracker.pixel ? ": that one's Drake's X pixel, because you said hi." : ''); + trackers.appendChild(item); + countTrackers(); + trackerListeners.forEach(function (listener) { listener(Object.assign({}, tracker)); }); } + function browserFacts() { + var nav = window.navigator; + var screen = window.screen; + facts = [ + ['Browser', nav.userAgent || 'not shared'], + ['Platform', (nav.userAgentData && nav.userAgentData.platform) || nav.platform || 'not shared'], + ['Language', (nav.languages && nav.languages.length ? nav.languages.join(', ') : nav.language) || 'not shared'], + ['Timezone', Intl.DateTimeFormat().resolvedOptions().timeZone || 'not shared'], + ['Screen size', screen ? screen.width + ' x ' + screen.height : 'not shared'], + ['Came from', document.referrer || 'no referrer sent'], + ['Do Not Track', nav.doNotTrack === '1' ? 'on' : 'off'], + ['Global Privacy Control', gpc ? 'on' : 'off'], + ['Cookies enabled', nav.cookieEnabled ? 'yes' : 'no'], + ]; + var list = document.getElementById('allen-intro-facts'); + facts.forEach(function (row) { + var term = document.createElement('dt'); + var value = document.createElement('dd'); + term.textContent = row[0]; + value.textContent = row[1]; + list.appendChild(term); + list.appendChild(value); + }); + } + function watch() { + if (watching) return; + watching = true; + browserFacts(); + countTrackers(); + window.performance.getEntriesByType('resource').forEach(noteResource); + // Later loads too, such as the X pixel after Say hi. + new window.PerformanceObserver(function (list) { list.getEntries().forEach(noteResource); }) + .observe({ type: 'resource', buffered: true }); + } + who.addEventListener('toggle', function () { if (who.open) watch(); }); - document.getElementById('allen-intro-no').addEventListener('click', function () { choose('no'); }); - document.getElementById('allen-intro-yes').addEventListener('click', function () { choose('yes'); }); - dialog.addEventListener('cancel', function (event) { event.preventDefault(); choose('no'); }); + no.addEventListener('click', function () { choose('no', true); }); + document.getElementById('allen-intro-close').addEventListener('click', function () { choose('no'); }); + yes.addEventListener('click', function () { choose('yes'); }); + document.addEventListener('keydown', function (event) { + if (event.key === 'Escape' && !aside.hidden) choose('no'); + }); document.querySelectorAll('[data-allen-intro-open]').forEach(function (button) { button.hidden = false; - button.addEventListener('click', open); + button.addEventListener('click', function () { open(true); }); }); document.querySelectorAll('[data-allen-intro-stop]').forEach(function (button) { button.hidden = false; @@ -112,7 +291,41 @@ describe(); if (choice !== 'yes' && loaded) window.location.reload(); }); + // The first-visit greeting, once per browser. Recorded on first display: never + // auto-open again, chosen or not. Unanswered means No. Not on /privacy/ or the chat page. + function greet() { + if (choice === 'yes' || choice === 'no' || seen() || document.getElementById('allen-intro-privacy') || document.getElementById('allen')) return false; + markSeen(); + open(false); + return true; + } + + // The interface Allen's presence layer calls. X consent and refusal only: memory + // consent lives on /aien/ behind its own step, never here, so one tap never means both. + window.aienAllenIntro = Object.freeze({ + text: Object.freeze({ + greeting: greeting, + intro: document.getElementById('allen-intro-intro').textContent, + offer: offerLine.textContent, + gpcNote: gpcLine.textContent, + afterNo: document.getElementById('allen-intro-after-text').textContent, + }), + status: function () { + return { choice: choice === 'yes' || choice === 'no' ? choice : null, gpc: gpc, offering: offering, pixelLoaded: loaded, shown: !aside.hidden }; + }, + sayHi: function () { choose('yes'); }, + noThanks: function () { choose('no', true); }, + dismiss: function () { choose('no'); }, + review: function () { open(true); }, + // A page that marks [data-allen-intro-defer] (the home door) calls this after its own welcome. + greet: greet, + who: function () { + watch(); + return { trackers: thirdParty.map(function (t) { return Object.assign({}, t); }), facts: facts.map(function (row) { return row.slice(); }) }; + }, + onTrackers: function (listener) { trackerListeners.push(listener); watch(); }, + }); describe(); if (choice === 'yes') loadPixel(); - else if (choice !== 'no' && !document.getElementById('allen-intro-privacy')) open(); + else if (!document.querySelector('[data-allen-intro-defer]')) greet(); }()); diff --git a/public/js/allen-panes.js b/public/js/allen-panes.js new file mode 100644 index 0000000..3b7296c --- /dev/null +++ b/public/js/allen-panes.js @@ -0,0 +1,1997 @@ +/* Allen glass panes. + * + * Generated by om/allen-panes/panes.om; never hand-edit. Event names, kinds, + * the protocol version and the byte limits come from the canonical pane + * contract om/allen-panes/contract.om; the remaining bounds come from the + * table in panes.om. + * + * Renders the v1 pane events (pane.open, pane.update, pane.close) as movable, + * resizable, stackable glass panes over the scene. Every network or model + * string reaches only textContent, an attribute value this file checks, or the + * srcdoc of a frame sandboxed to allow-scripts alone after an explicit Run + * click. Nothing from the network is parsed as markup in this document: plots + * are drawn here from numbers and TeX is typeset here by a small subset + * renderer, or shown as source when it uses anything outside that subset. + * Projects reach IndexedDB only on an explicit Save project. + */ +(() => { + 'use strict'; + if (window.AllenPanes) return; + const KINDS = 'math,plot,doc,code,app,research,data,omega'.split(','); + const EVENTS = 'pane.open,pane.update,pane.close'.split(','); + const VERSION = 1; + const MAX_EVENT = 65536; + const MAX_TEXT = 32768; + const STATUSES = 'computed,unsupported,unverified,input-data'.split(','); + const MAX_TITLE = 200; + const MAX_LIST = 64; + const MAX_SERIES = 8; + const MAX_POINTS = 512; + const MAX_REVISION = 1000000; + const MAX_PANES = 32; + const MAX_URL = 2048; + const MAX_CLOSED = 8; + const MAX_PROJECTS = 50; + const MAX_PROJECT_BYTES = 4194304; + const DB_NAME = 'allen-panes'; + const FORMAT = 'allen-panes-project'; + const SANDBOX = 'allow-scripts'; + const CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; form-action 'none'; base-uri 'none'"; + const SHEET = '(max-width: 720px)'; + const MIN_W = 260; + const MIN_H = 160; + const MAX_ABS = 1e100; + const SYNC_MAX = 1000; + const ID = /^[A-Za-z0-9_-]{1,64}$/; + const DB_PROJECTS = 'projects'; + const DB_INDEX = 'index'; + const STEP = 16; + const BIG_STEP = 64; + const MAX_NAME = 80; + const ACADEMY = 'https://github.com/aien-dev/sovereign-intelligence/blob/main/docs/academy/README.md'; + const SVG_NS = 'http://www.w3.org/2000/svg'; + const MATH_NS = 'http://www.w3.org/1998/Math/MathML'; + const NAMES = { math: 'Math', plot: 'Plot', doc: 'Document', code: 'Code', app: 'App', research: 'Research', data: 'Data', omega: 'Omega', card: 'Aien', projects: 'Projects' }; + const STATUS_NAMES = { computed: 'Computed', unsupported: 'Not supported', unverified: 'Not verified', 'input-data': 'Given data' }; + const CAVEATS = { + computed: 'The math engine produced this result. That is not an independent check that it is correct.', + unsupported: 'The engine does not support this request, so nothing here was computed.', + unverified: 'Written by the model and not checked by any engine.', + 'input-data': 'These are the numbers as given. Showing them does not measure or prove them.' + }; + const PALETTE = ['#2d7ff9', '#00e599', '#f59e0b', '#6e82ff', '#f87171', '#c4b5fd', '#94a3b8', '#f1f5f9']; + const EXT = { javascript: 'js', js: 'js', typescript: 'ts', ts: 'ts', python: 'py', py: 'py', rust: 'rs', rs: 'rs', c: 'c', cpp: 'cpp', 'c++': 'cpp', go: 'go', java: 'java', html: 'html', css: 'css', json: 'json', shell: 'sh', sh: 'sh', bash: 'sh', sql: 'sql', mojo: 'mojo', wat: 'wat', omega: 'om', om: 'om', markdown: 'md', md: 'md', text: 'txt' }; + const encoder = new TextEncoder(); + let serial = 0; + + function el(tag, className, text) { + const node = document.createElement(tag); + if (className) node.className = className; + if (text !== undefined) node.textContent = text; + return node; + } + function button(className, label, text, handler) { + const node = el('button', className, text); + node.type = 'button'; + if (label) node.setAttribute('aria-label', label); + if (handler) node.addEventListener('click', handler); + return node; + } + function uid(prefix) { + serial += 1; + return `${prefix}-${serial}`; + } + /* Display text for titles and names: no control or bidirectional override + characters, one line, bounded. */ + function clean(text, max) { + return String(text).replace(/[\u0000-\u001f\u007f-\u009f\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, ' ').replace(/\s+/g, ' ').trim().slice(0, max); + } + function slug(text) { + return String(text).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+/, '').slice(0, 48).replace(/-+$/, ''); + } + function copy(value) { + return JSON.parse(JSON.stringify(value)); + } + function utf8(text) { + return encoder.encode(text).length; + } + + /* The v1 contract, checked exactly as the gateway checks it: unknown or + missing fields, a wrong kind, a nonfinite number or an excess size refuse + the whole event. */ + const own = (o, k) => Object.prototype.hasOwnProperty.call(o, k); + function plain(o) { + if (o === null || typeof o !== 'object' || Array.isArray(o)) return false; + const proto = Object.getPrototypeOf(o); + return proto === Object.prototype || proto === null; + } + function shape(o, required, optional) { + if (!plain(o)) return false; + const allowed = optional ? required.concat(optional) : required; + for (const k of Object.keys(o)) if (!allowed.includes(k)) return false; + return required.every(k => own(o, k)); + } + function isText(v, max, filled) { + if (typeof v !== 'string' || v.length > max || v.includes('\u0000')) return false; + if (filled && !v.trim()) return false; + return v.length * 3 <= max || utf8(v) <= max; + } + function texts(v) { + return Array.isArray(v) && v.length <= MAX_LIST && v.every(s => isText(s, MAX_TEXT)); + } + function finite(n) { + return typeof n === 'number' && Number.isFinite(n) && Math.abs(n) <= MAX_ABS; + } + function httpsUrl(url) { + if (typeof url !== 'string' || !isText(url, MAX_URL) || /[\u0000-\u0020\u007f]/.test(url)) return null; + try { + const parsed = new URL(url); + return parsed.protocol === 'https:' && parsed.hostname && !parsed.username && !parsed.password ? parsed : null; + } catch (_) { + return null; + } + } + function refs(v) { + return Array.isArray(v) && v.length <= MAX_LIST && v.every(r => shape(r, ['title', 'url']) && isText(r.title, MAX_TITLE, true) && httpsUrl(r.url) !== null); + } + function fns(v) { + return Array.isArray(v) && v.length <= MAX_LIST && v.every(f => shape(f, ['name', 'params', 'ret']) && isText(f.name, MAX_TEXT) && isText(f.ret, MAX_TEXT) + && Array.isArray(f.params) && f.params.length <= MAX_LIST && f.params.every(p => shape(p, ['name', 'type']) && isText(p.name, MAX_TEXT) && isText(p.type, MAX_TEXT))); + } + function code(c) { + return shape(c, ['source', 'language'], ['wasm', 'functions']) && isText(c.source, MAX_TEXT) && isText(c.language, MAX_TEXT) + && (!own(c, 'wasm') || isText(c.wasm, MAX_TEXT)) && (!own(c, 'functions') || fns(c.functions)); + } + function series(s) { + return shape(s, ['label', 'points']) && isText(s.label, MAX_TITLE) && Array.isArray(s.points) && s.points.length >= 1 && s.points.length <= MAX_POINTS + && s.points.every(p => Array.isArray(p) && p.length === 2 && finite(p[0]) && finite(p[1])); + } + const CONTENT = { + math: c => shape(c, ['text'], ['tex']) && isText(c.text, MAX_TEXT) && (!own(c, 'tex') || isText(c.tex, MAX_TEXT)), + plot: c => shape(c, ['series', 'x_label', 'y_label']) && isText(c.x_label, MAX_TITLE) && isText(c.y_label, MAX_TITLE) + && Array.isArray(c.series) && c.series.length >= 1 && c.series.length <= MAX_SERIES && c.series.every(series), + doc: c => shape(c, ['markdown', 'citations']) && isText(c.markdown, MAX_TEXT) && refs(c.citations), + code, + omega: code, + app: c => shape(c, ['html']) && isText(c.html, MAX_TEXT), + research: c => shape(c, ['notes', 'hypotheses', 'derivations', 'sources']) && isText(c.notes, MAX_TEXT) && texts(c.hypotheses) && texts(c.derivations) && refs(c.sources), + data: c => shape(c, ['columns', 'rows']) && texts(c.columns) && c.columns.length >= 1 + && Array.isArray(c.rows) && c.rows.length <= MAX_LIST && c.rows.every(texts) + }; + const PROVENANCE = ['status', 'engine', 'expression', 'result', 'source', 'commit']; + function provenance(p) { + return shape(p, PROVENANCE) && STATUSES.includes(p.status) && PROVENANCE.every(k => isText(p[k], MAX_TEXT)); + } + function sized(value) { + try { + return utf8(JSON.stringify(value)) <= MAX_EVENT; + } catch (_) { + return false; + } + } + /* Returns '' for a valid event, else the reason. An update is checked + against the kind its pane was opened with. */ + function check(name, p, kind) { + if (!EVENTS.includes(name)) return 'unknown pane event'; + if (!plain(p)) return 'the event is not a JSON object'; + const fields = name === 'pane.open' ? ['v', 'id', 'kind', 'title'] : name === 'pane.update' ? ['v', 'id', 'revision', 'content', 'provenance'] : ['v', 'id']; + if (!shape(p, fields)) return 'unexpected or missing fields'; + if (p.v !== VERSION || typeof p.id !== 'string' || !ID.test(p.id)) return 'invalid pane identity'; + if (!sized(p)) return 'the event is over the size limit'; + if (name === 'pane.open') { + if (!KINDS.includes(p.kind)) return 'invalid pane kind'; + return isText(p.title, MAX_TITLE, true) ? '' : 'invalid title'; + } + if (name === 'pane.update') { + if (!Number.isInteger(p.revision) || p.revision < 1 || p.revision > MAX_REVISION) return 'invalid revision'; + if (!KINDS.includes(kind)) return 'the pane is not open'; + if (!CONTENT[kind](p.content)) return `the content does not match ${kind === 'app' || kind === 'omega' ? 'an' : 'a'} ${kind} pane`; + return provenance(p.provenance) ? '' : 'invalid provenance'; + } + return ''; + } + + /* Links: HTTPS only, shown with their host, never fetched by this page. */ + function link(label, url) { + const safe = httpsUrl(url); + const shown = clean(label, MAX_TITLE) || url; + if (!safe) { + const span = el('span', 'allen-link-off', shown); + if (url && url !== shown) span.append(document.createTextNode(` (${url})`)); + return span; + } + const frag = document.createDocumentFragment(); + const a = el('a', 'allen-link', shown); + a.href = safe.href; + a.target = '_blank'; + a.rel = 'noopener noreferrer nofollow'; + a.referrerPolicy = 'no-referrer'; + frag.append(a, el('span', 'allen-link-host', ` ${safe.host}`)); + return frag; + } + + /* A small first-party TeX subset typeset as MathML Core built element by + element. Anything outside the subset throws, and the caller shows the + TeX as source and says so. */ + const GREEK = { alpha: '\u03b1', beta: '\u03b2', gamma: '\u03b3', delta: '\u03b4', epsilon: '\u03f5', varepsilon: '\u03b5', zeta: '\u03b6', eta: '\u03b7', theta: '\u03b8', vartheta: '\u03d1', iota: '\u03b9', kappa: '\u03ba', lambda: '\u03bb', mu: '\u03bc', nu: '\u03bd', xi: '\u03be', pi: '\u03c0', varpi: '\u03d6', rho: '\u03c1', varrho: '\u03f1', sigma: '\u03c3', varsigma: '\u03c2', tau: '\u03c4', upsilon: '\u03c5', phi: '\u03d5', varphi: '\u03c6', chi: '\u03c7', psi: '\u03c8', omega: '\u03c9', Gamma: '\u0393', Delta: '\u0394', Theta: '\u0398', Lambda: '\u039b', Xi: '\u039e', Pi: '\u03a0', Sigma: '\u03a3', Upsilon: '\u03a5', Phi: '\u03a6', Psi: '\u03a8', Omega: '\u03a9' }; + const IDENT = { infty: '\u221e', partial: '\u2202', nabla: '\u2207', ell: '\u2113', hbar: '\u210f', emptyset: '\u2205', aleph: '\u2135' }; + const OPS = { pm: '\u00b1', mp: '\u2213', times: '\u00d7', cdot: '\u22c5', div: '\u00f7', ast: '\u2217', star: '\u22c6', circ: '\u2218', bullet: '\u2219', leq: '\u2264', le: '\u2264', geq: '\u2265', ge: '\u2265', neq: '\u2260', ne: '\u2260', approx: '\u2248', equiv: '\u2261', sim: '\u223c', simeq: '\u2243', cong: '\u2245', propto: '\u221d', ll: '\u226a', gg: '\u226b', to: '\u2192', rightarrow: '\u2192', leftarrow: '\u2190', Rightarrow: '\u21d2', Leftarrow: '\u21d0', leftrightarrow: '\u2194', Leftrightarrow: '\u21d4', iff: '\u21d4', implies: '\u21d2', mapsto: '\u21a6', in: '\u2208', notin: '\u2209', ni: '\u220b', subset: '\u2282', supset: '\u2283', subseteq: '\u2286', supseteq: '\u2287', cup: '\u222a', cap: '\u2229', setminus: '\u2216', wedge: '\u2227', land: '\u2227', vee: '\u2228', lor: '\u2228', neg: '\u00ac', lnot: '\u00ac', forall: '\u2200', exists: '\u2203', ldots: '\u2026', cdots: '\u22ef', vdots: '\u22ee', ddots: '\u22f1', dots: '\u2026', prime: '\u2032', perp: '\u22a5', parallel: '\u2225', angle: '\u2220', oplus: '\u2295', otimes: '\u2297', langle: '\u27e8', rangle: '\u27e9', lfloor: '\u230a', rfloor: '\u230b', lceil: '\u2308', rceil: '\u2309', vert: '|', mid: '|', lbrace: '{', rbrace: '}' }; + const LARGE = { sum: '\u2211', prod: '\u220f', coprod: '\u2210', int: '\u222b', iint: '\u222c', iiint: '\u222d', oint: '\u222e', bigcup: '\u22c3', bigcap: '\u22c2' }; + const FUNCS = 'sin cos tan cot sec csc arcsin arccos arctan sinh cosh tanh coth log ln lg exp det dim ker deg gcd lcm max min sup inf lim liminf limsup arg Pr mod'.split(' '); + const LIMITS = ['sum', 'prod', 'coprod', 'bigcup', 'bigcap', 'lim', 'liminf', 'limsup', 'max', 'min', 'sup', 'inf']; + const SPACES = { ',': '0.1667em', ':': '0.2222em', ';': '0.2778em', '!': '-0.1667em', ' ': '0.25em', quad: '1em', qquad: '2em' }; + const BB = { C: '\u2102', H: '\u210d', N: '\u2115', P: '\u2119', Q: '\u211a', R: '\u211d', Z: '\u2124' }; + const FENCES = { '(': '(', ')': ')', '[': '[', ']': ']', '|': '|', '.': '', '\\{': '{', '\\}': '}', '\\langle': '\u27e8', '\\rangle': '\u27e9', '\\lvert': '|', '\\rvert': '|', '\\|': '\u2016', '\\lfloor': '\u230a', '\\rfloor': '\u230b', '\\lceil': '\u2308', '\\rceil': '\u2309' }; + function mml(tag, children, attrs) { + const node = document.createElementNS(MATH_NS, tag); + if (attrs) for (const k of Object.keys(attrs)) node.setAttribute(k, attrs[k]); + if (typeof children === 'string') node.textContent = children; + else if (children) node.append(...children); + return node; + } + function texTokens(src) { + const out = []; + const re = /\\([A-Za-z]+|.)|(\d+(?:\.\d+)?)|(\s+)|([\s\S])/g; + let m; + while ((m = re.exec(src)) !== null) { + if (out.length > 4096) throw new Error('too long'); + if (m[3]) continue; + out.push(m[1] !== undefined ? { t: 'cmd', v: m[1] } : m[2] !== undefined ? { t: 'num', v: m[2] } : { t: 'chr', v: m[4] }); + } + return out; + } + function texParse(src) { + const toks = texTokens(src); + let at = 0; + let depth = 0; + const peek = () => toks[at]; + const take = () => toks[at++]; + const fail = what => { throw new Error(what); }; + function group() { + const t = peek(); + if (!t) fail('missing argument'); + if (t.t === 'chr' && t.v === '{') { + take(); + const row = seq('}'); + if (!peek() || peek().v !== '}') fail('unclosed brace'); + take(); + return row; + } + return atom(true); + } + function raw() { + const t = take(); + if (!t || t.t !== 'chr' || t.v !== '{') fail('expected a braced argument'); + let text = ''; + let level = 1; + for (;;) { + const n = take(); + if (!n) fail('unclosed brace'); + if (n.t === 'chr' && n.v === '{') level += 1; + if (n.t === 'chr' && n.v === '}') { + level -= 1; + if (level === 0) return text; + } + text += n.t === 'cmd' ? (n.v.length === 1 ? n.v : `\\${n.v} `) : n.v; + } + } + function fence() { + const t = take(); + if (!t) fail('missing delimiter'); + const key = t.t === 'cmd' ? `\\${t.v}` : t.v; + if (!own(FENCES, key)) fail(`delimiter ${key}`); + return FENCES[key]; + } + function atom(single) { + const t = take(); + if (!t) fail('missing argument'); + if (t.t === 'num') { + if (single && t.v.length > 1) { + at -= 1; + toks[at] = { t: 'num', v: t.v.slice(1) }; + return mml('mn', t.v[0]); + } + return mml('mn', t.v); + } + if (t.t === 'chr') { + if (/[A-Za-z]/.test(t.v)) return mml('mi', t.v); + if (t.v === '{' && !single) { + at -= 1; + return group(); + } + if (t.v === "'") return mml('mo', '\u2032'); + if (t.v === '-') return mml('mo', '\u2212'); + if ('+=<>()[]|,;:!/*.?'.includes(t.v)) return mml('mo', t.v, '()[]|'.includes(t.v) ? { stretchy: 'false' } : undefined); + fail(`character ${t.v}`); + } + const c = t.v; + if (own(GREEK, c)) return mml('mi', GREEK[c], /^[A-Z]/.test(c) ? { mathvariant: 'normal' } : undefined); + if (own(IDENT, c)) return mml('mi', IDENT[c]); + if (own(OPS, c)) return mml('mo', OPS[c]); + if (own(LARGE, c)) return mml('mo', LARGE[c], LIMITS.includes(c) ? { largeop: 'true', movablelimits: 'true' } : { largeop: 'true' }); + if (FUNCS.includes(c)) return mml('mi', c, { mathvariant: 'normal' }); + if (own(SPACES, c)) return mml('mspace', null, { width: SPACES[c] }); + if (c === '{' || c === '}' || c === '%' || c === '$' || c === '#' || c === '_' || c === '&') return mml('mo', c); + if (c === 'frac' || c === 'dfrac' || c === 'tfrac') return mml('mfrac', [group(), group()]); + if (c === 'binom') return mml('mrow', [mml('mo', '('), mml('mfrac', [group(), group()], { linethickness: '0' }), mml('mo', ')')]); + if (c === 'sqrt') { + if (peek() && peek().t === 'chr' && peek().v === '[') { + take(); + const index = seq(']'); + if (!peek() || peek().v !== ']') fail('unclosed root index'); + take(); + return mml('mroot', [group(), index]); + } + return mml('msqrt', [group()]); + } + if (c === 'text' || c === 'textrm' || c === 'mathrm' || c === 'operatorname') { + const text = raw(); + return c === 'text' || c === 'textrm' ? mml('mtext', text) : mml('mi', text, { mathvariant: 'normal' }); + } + if (c === 'mathbb') { + const letter = raw().trim(); + if (!own(BB, letter)) fail(`mathbb ${letter}`); + return mml('mi', BB[letter]); + } + if (c === 'left') { + const open = fence(); + const inner = seq('right'); + const close = peek(); + if (!close || close.t !== 'cmd' || close.v !== 'right') fail('left without right'); + take(); + const shut = fence(); + return mml('mrow', [mml('mo', open, { fence: 'true', stretchy: 'true' }), inner, mml('mo', shut, { fence: 'true', stretchy: 'true' })]); + } + return fail(`\\${c}`); + } + function scripted(base) { + let sub = null; + let sup = null; + for (let i = 0; i < 2; i++) { + const t = peek(); + if (!t || t.t !== 'chr' || (t.v !== '_' && t.v !== '^')) break; + take(); + if (t.v === '_') { + if (sub) fail('double subscript'); + sub = group(); + } else { + if (sup) fail('double superscript'); + sup = group(); + } + } + if (!sub && !sup) return base; + const under = (base.localName === 'mo' && base.getAttribute('movablelimits') === 'true') || (base.localName === 'mi' && LIMITS.includes(base.textContent)); + if (sub && sup) return mml(under ? 'munderover' : 'msubsup', [base, sub, sup]); + if (sub) return mml(under ? 'munder' : 'msub', [base, sub]); + return mml(under ? 'mover' : 'msup', [base, sup]); + } + function seq(stop) { + depth += 1; + if (depth > 32) fail('nested too deeply'); + const items = []; + while (at < toks.length) { + const t = peek(); + if (stop === 'right' ? t.t === 'cmd' && t.v === 'right' : t.t === 'chr' && t.v === stop) break; + if (t.t === 'chr' && (t.v === '}' || t.v === ']') && stop === null) fail('unbalanced'); + if (t.t === 'chr' && (t.v === '^' || t.v === '_')) { + items.push(scripted(mml('mrow', []))); + continue; + } + items.push(scripted(atom(false))); + } + depth -= 1; + return items.length === 1 ? items[0] : mml('mrow', items); + } + const tree = seq(null); + if (at !== toks.length) fail('trailing input'); + return tree; + } + /* Returns a math element, or null with the reason when the TeX is outside + the subset or the browser has no MathML. */ + function typeset(src, display) { + if (typeof window.MathMLElement !== 'function') return { node: null, reason: 'this browser does not lay out MathML' }; + try { + const tree = texParse(src); + const semantics = mml('semantics', [tree, mml('annotation', src, { encoding: 'application/x-tex' })]); + return { node: mml('math', [semantics], { display: display ? 'block' : 'inline' }), reason: '' }; + } catch (error) { + return { node: null, reason: `it uses ${String(error && error.message).slice(0, 80)}, which this renderer does not typeset` }; + } + } + function texBlock(src, label) { + const box = el('div', 'allen-tex'); + const done = typeset(src, true); + if (done.node) { + box.append(done.node, el('p', 'allen-pane-label', `${label} typeset in this page from TeX by a small first-party renderer; the source is below.`)); + } else { + box.append(el('p', 'allen-pane-label', `${label} as TeX source, not typeset: ${done.reason}.`)); + } + const pre = el('pre', 'allen-pane-pre', src); + pre.setAttribute('aria-label', 'TeX source'); + box.append(pre); + return box; + } + + /* Markdown subset rendered to DOM nodes only: headings, paragraphs, lists, + quotes, rules, fenced code, pipe tables, inline code, strong, emphasis, + HTTPS links and $ TeX. Raw HTML stays text. */ + function inline(node, text) { + const re = /(`+)([^`][\s\S]*?)\1|\*\*([^*\n]+)\*\*|\*([^*\s][^*\n]*)\*|\[([^\]\n]{1,500})\]\(([^)\s]{1,2048})\)|\$([^$\n]{1,500})\$|(https:\/\/[^\s<>()]{1,2048})/g; + let last = 0; + let m; + while ((m = re.exec(text)) !== null) { + if (m.index > last) node.append(document.createTextNode(text.slice(last, m.index))); + if (m[1]) node.append(el('code', 'allen-md-code', m[2])); + else if (m[3] !== undefined) node.append(el('strong', '', m[3])); + else if (m[4] !== undefined) node.append(el('em', '', m[4])); + else if (m[5] !== undefined) node.append(link(m[5], m[6])); + else if (m[7] !== undefined) { + const done = typeset(m[7], false); + if (done.node) node.append(done.node); + else { + const raw = el('code', 'allen-md-tex', `$${m[7]}$`); + raw.title = 'TeX source, not typeset'; + node.append(raw); + } + } else { + const url = m[8].replace(/[.,;:!?]+$/, ''); + node.append(link(url, url)); + if (url.length < m[8].length) node.append(document.createTextNode(m[8].slice(url.length))); + } + last = re.lastIndex; + } + if (last < text.length) node.append(document.createTextNode(text.slice(last))); + return node; + } + function cells(line) { + return line.trim().replace(/^\|/, '').replace(/\|$/, '').split('|').map(s => s.trim()); + } + /* A repo report's files, found by the same parser that renders the pane, + so a fence the reader saw is exactly a fence that is saved. */ + const REPORT = /^Repo report: ([A-Za-z0-9_.-]{1,100})\/([A-Za-z0-9_.-]{1,100})$/; + function reportFiles(source) { + const files = [{ path: 'README.md', content: source }]; + const patches = []; + let port = 0; + let harness = 0; + markdown(source, document.createElement('div'), (lang, text) => { + const kind = lang.toLowerCase(); + if (kind === 'omega' || kind === 'om') files.push({ path: `allen-port-${(port += 1)}.om`, content: `${text}\n` }); + else if (kind === 'diff' || kind === 'patch') patches.push(`${text}\n`); + else if (kind === 'text' || kind === 'txt') files.push({ path: `parity-harness-${(harness += 1)}.txt`, content: `${text}\n` }); + return null; + }); + if (patches.length) files.push({ path: 'allen-ports.patch', content: patches.join('') }); + return files; + } + function markdown(source, box, fenceTool) { + const lines = source.split(/\r?\n/); + let para = []; + let list = null; + const flush = () => { + if (para.length) box.append(inline(el('p', 'allen-md-p'), para.join(' '))); + para = []; + }; + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; + const fence = /^\s*(```+)\s*([A-Za-z0-9_+-]{0,32})\s*$/.exec(line); + if (fence) { + flush(); + list = null; + const body = []; + for (i += 1; i < lines.length && !lines[i].trim().startsWith(fence[1]); i++) body.push(lines[i]); + const pre = el('pre', 'allen-md-pre'); + if (fence[2]) pre.dataset.lang = fence[2]; + pre.append(el('code', '', body.join('\n'))); + box.append(pre); + const tool = fenceTool ? fenceTool(fence[2], body.join('\n')) : null; + if (tool) box.append(tool); + continue; + } + if (/^\s*\$\$/.test(line)) { + flush(); + list = null; + const body = [line.replace(/^\s*\$\$/, '')]; + let closed = /\$\$\s*$/.test(body[0]) && body[0].trim().length > 2; + if (closed) body[0] = body[0].replace(/\$\$\s*$/, ''); + if (!closed) for (i += 1; i < lines.length; i++) { + if (/\$\$\s*$/.test(lines[i])) { + body.push(lines[i].replace(/\$\$\s*$/, '')); + closed = true; + break; + } + body.push(lines[i]); + } + box.append(texBlock(body.join('\n').trim(), 'Formula')); + continue; + } + if (!line.trim()) { + flush(); + list = null; + continue; + } + const heading = /^\s*(#{1,6})\s+(.*?)\s*#*\s*$/.exec(line); + if (heading) { + flush(); + list = null; + box.append(inline(el(`h${Math.min(6, heading[1].length + 2)}`, 'allen-md-h'), heading[2])); + continue; + } + if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(line)) { + flush(); + list = null; + box.append(el('hr', 'allen-md-hr')); + continue; + } + if (/^\s*\|.*\|\s*$/.test(line) && i + 1 < lines.length && /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(lines[i + 1])) { + flush(); + list = null; + const table = el('table', 'allen-md-table'); + const head = el('tr'); + for (const c of cells(line)) head.append(inline(el('th'), c)); + const thead = el('thead'); + thead.append(head); + const tbody = el('tbody'); + for (i += 2; i < lines.length && /^\s*\|.*\|\s*$/.test(lines[i]); i++) { + const row = el('tr'); + for (const c of cells(lines[i])) row.append(inline(el('td'), c)); + tbody.append(row); + } + i -= 1; + table.append(thead, tbody); + const wrap = el('div', 'allen-pane-table'); + wrap.append(table); + box.append(wrap); + continue; + } + const quote = /^\s*>\s?(.*)$/.exec(line); + if (quote) { + flush(); + list = null; + const parts = [quote[1]]; + while (i + 1 < lines.length && /^\s*>/.test(lines[i + 1])) parts.push(lines[++i].replace(/^\s*>\s?/, '')); + const block = el('blockquote', 'allen-md-quote'); + block.append(inline(el('p', 'allen-md-p'), parts.join(' '))); + box.append(block); + continue; + } + const item = /^\s*([-*+]|\d{1,9}[.)])\s+(.*)$/.exec(line); + if (item) { + flush(); + const ordered = /\d/.test(item[1]); + if (!list || (list.localName === 'ol') !== ordered) { + list = el(ordered ? 'ol' : 'ul', 'allen-md-list'); + box.append(list); + } + list.append(inline(el('li'), item[2])); + continue; + } + if (list && /^\s{2,}\S/.test(line)) { + inline(list.lastElementChild, ` ${line.trim()}`); + continue; + } + list = null; + para.push(line.trim()); + } + flush(); + return box; + } + + /* Plots are drawn here from validated numbers; no SVG from the network is + ever parsed. Colours are attributes so an exported file keeps them. */ + function svg(tag, attrs, text) { + const node = document.createElementNS(SVG_NS, tag); + for (const k of Object.keys(attrs)) node.setAttribute(k, String(attrs[k])); + if (text !== undefined) node.textContent = text; + return node; + } + function fmt(n) { + const v = Number(n.toPrecision(5)); + return Object.is(v, -0) ? '0' : String(v); + } + function ticks(lo, hi) { + const raw = (hi - lo) / 5; + if (!Number.isFinite(raw) || raw <= 0) return [lo, hi]; + const mag = Math.pow(10, Math.floor(Math.log10(raw))); + const unit = [1, 2, 5, 10].map(f => f * mag).find(s => s >= raw) || raw; + const first = Math.ceil(lo / unit); + const out = []; + for (let n = 0; n < 12; n++) { + const t = (first + n) * unit; + if (t > hi + unit * 1e-9) break; + out.push(t); + } + return out.length ? out : [lo, hi]; + } + function extent(c) { + let x0 = Infinity; + let x1 = -Infinity; + let y0 = Infinity; + let y1 = -Infinity; + for (const s of c.series) for (const p of s.points) { + x0 = Math.min(x0, p[0]); + x1 = Math.max(x1, p[0]); + y0 = Math.min(y0, p[1]); + y1 = Math.max(y1, p[1]); + } + if (x0 === x1) { + x0 -= 1; + x1 += 1; + } + if (y0 === y1) { + y0 -= 1; + y1 += 1; + } + return { x0, x1, y0, y1 }; + } + function plot(c, title) { + const W = 640; + const H = 400; + const L = 64; + const R = 20; + const T = 20; + const B = 52; + const e = extent(c); + const sx = v => L + (v - e.x0) / (e.x1 - e.x0) * (W - L - R); + const sy = v => H - B - (v - e.y0) / (e.y1 - e.y0) * (H - T - B); + const titleId = uid('allen-plot-title'); + const descId = uid('allen-plot-desc'); + const root = svg('svg', { viewBox: `0 0 ${W} ${H}`, width: W, height: H, role: 'img', 'aria-labelledby': `${titleId} ${descId}`, class: 'allen-plot-svg' }); + const xl = c.x_label ? ` (${c.x_label})` : ''; + const yl = c.y_label ? ` (${c.y_label})` : ''; + root.append(svg('title', { id: titleId }, title), svg('desc', { id: descId }, `${c.series.length} series; x${xl} from ${fmt(e.x0)} to ${fmt(e.x1)}; y${yl} from ${fmt(e.y0)} to ${fmt(e.y1)}.`)); + const grid = svg('g', { stroke: '#1c2536', 'stroke-width': 1 }); + const labels = svg('g', { fill: '#94a3b8', 'font-size': 12, 'font-family': 'ui-sans-serif, system-ui, sans-serif' }); + for (const t of ticks(e.x0, e.x1)) { + const x = sx(t).toFixed(2); + grid.append(svg('line', { x1: x, y1: T, x2: x, y2: H - B })); + labels.append(svg('text', { x, y: H - B + 18, 'text-anchor': 'middle' }, fmt(t))); + } + for (const t of ticks(e.y0, e.y1)) { + const y = sy(t).toFixed(2); + grid.append(svg('line', { x1: L, y1: y, x2: W - R, y2: y })); + labels.append(svg('text', { x: L - 8, y: (Number(y) + 4).toFixed(2), 'text-anchor': 'end' }, fmt(t))); + } + const axes = svg('g', { stroke: '#3b4a63', 'stroke-width': 1 }); + axes.append(svg('line', { x1: L, y1: H - B, x2: W - R, y2: H - B }), svg('line', { x1: L, y1: T, x2: L, y2: H - B })); + if (c.x_label) labels.append(svg('text', { x: (L + W - R) / 2, y: H - 12, 'text-anchor': 'middle' }, c.x_label)); + if (c.y_label) { + const mid = (T + H - B) / 2; + labels.append(svg('text', { x: 16, y: mid, 'text-anchor': 'middle', transform: `rotate(-90 16 ${mid})` }, c.y_label)); + } + const lines = svg('g', { fill: 'none', 'stroke-width': 2, 'stroke-linejoin': 'round', 'stroke-linecap': 'round' }); + c.series.forEach((s, i) => { + const colour = PALETTE[i % PALETTE.length]; + const group = svg('g', { stroke: colour }); + group.append(svg('title', {}, s.label || `Series ${i + 1}`)); + if (s.points.length > 1) group.append(svg('polyline', { points: s.points.map(p => `${sx(p[0]).toFixed(2)},${sy(p[1]).toFixed(2)}`).join(' ') })); + if (s.points.length <= 64) for (const p of s.points) group.append(svg('circle', { cx: sx(p[0]).toFixed(2), cy: sy(p[1]).toFixed(2), r: 3, fill: colour, stroke: 'none' })); + lines.append(group); + }); + root.append(grid, axes, lines, labels); + const figure = el('figure', 'allen-plot'); + figure.append(root); + const legend = el('ul', 'allen-plot-legend'); + c.series.forEach((s, i) => { + const item = el('li', 'allen-plot-key'); + const swatch = el('span', 'allen-plot-swatch'); + swatch.style.background = PALETTE[i % PALETTE.length]; + swatch.setAttribute('aria-hidden', 'true'); + item.append(swatch, document.createTextNode(`${s.label || `Series ${i + 1}`}, ${s.points.length} point${s.points.length === 1 ? '' : 's'}`)); + legend.append(item); + }); + figure.append(legend); + const data = el('details', 'allen-plot-data'); + data.append(el('summary', 'allen-pane-summary', 'Plot data as a table')); + data.addEventListener('toggle', () => { + if (!data.open || data.dataset.built) return; + data.dataset.built = 'yes'; + data.append(table(['Series', c.x_label || 'x', c.y_label || 'y'], c.series.flatMap((s, i) => s.points.map(p => [s.label || `Series ${i + 1}`, String(p[0]), String(p[1])])))); + }); + figure.append(data); + return { figure, svg: root }; + } + function table(columns, rows) { + const wrap = el('div', 'allen-pane-table'); + wrap.tabIndex = 0; + const node = el('table', 'allen-data'); + const head = el('tr'); + for (const c of columns) { + const th = el('th', '', c); + th.scope = 'col'; + head.append(th); + } + const thead = el('thead'); + thead.append(head); + const tbody = el('tbody'); + for (const r of rows) { + const tr = el('tr'); + for (let i = 0; i < Math.max(r.length, columns.length); i++) tr.append(el('td', '', i < r.length ? r[i] : '')); + tbody.append(tr); + } + node.append(thead, tbody); + wrap.append(node); + return wrap; + } + + /* Files. Every download is application/octet-stream, so no browser renders + a generated file in this origin. */ + function csv(columns, rows) { + const cell = v => { + let s = String(v); + if (/^[=+@\t\r]/.test(s) || /^-(?![\d.])/.test(s)) s = `'${s}`; + return /[",\r\n]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s; + }; + return `${[columns, ...rows].map(r => r.map(cell).join(',')).join('\r\n')}\r\n`; + } + function refText(items) { + return items.map((r, i) => `${i + 1}. [${r.title}](${r.url})`).join('\n'); + } + function artefact(rec) { + const c = rec.content; + const base = slug(rec.title) || rec.kind; + switch (rec.kind) { + case 'math': { + const text = own(c, 'tex') ? `${c.text}\n\nTeX source:\n${c.tex}\n` : `${c.text}\n`; + return { name: `${base}.txt`, what: 'result', data: () => text, copy: c.text }; + } + case 'plot': { + const rows = c.series.flatMap((s, i) => s.points.map(p => [s.label || `Series ${i + 1}`, String(p[0]), String(p[1])])); + return { name: `${base}.svg`, what: 'data as CSV', data: () => `\n${new XMLSerializer().serializeToString(rec.svg)}\n`, copy: csv(['series', c.x_label || 'x', c.y_label || 'y'], rows) }; + } + case 'doc': { + const text = c.citations.length ? `${c.markdown}\n\n## Citations\n\n${refText(c.citations)}\n` : `${c.markdown}\n`; + return { name: `${base}.md`, what: 'Markdown', data: () => text, copy: text }; + } + case 'code': + case 'omega': { + const ext = rec.kind === 'omega' ? 'om' : EXT[c.language.toLowerCase()] || 'txt'; + return { name: `${base}.${ext}`, what: 'source', data: () => c.source, copy: c.source }; + } + case 'app': + return { name: `${base}.html`, what: 'HTML', data: () => c.html, copy: c.html }; + case 'research': { + const parts = [`# ${rec.title}`, '## Notes', c.notes]; + if (c.hypotheses.length) parts.push('## Hypotheses', c.hypotheses.map(h => `- ${h}`).join('\n')); + if (c.derivations.length) parts.push('## Derivations', c.derivations.map(d => `\`\`\`\n${d}\n\`\`\``).join('\n\n')); + if (c.sources.length) parts.push('## Sources', refText(c.sources)); + const text = `${parts.join('\n\n')}\n`; + return { name: `${base}.md`, what: 'Markdown', data: () => text, copy: text }; + } + case 'data': { + const text = csv(c.columns, c.rows); + return { name: `${base}.csv`, what: 'CSV', data: () => text, copy: text }; + } + default: + return null; + } + } + function wasmBytes(text) { + try { + const bin = atob(text.replace(/\s+/g, '')); + const out = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i); + return out.length >= 8 && out[0] === 0 && out[1] === 97 && out[2] === 115 && out[3] === 109 ? out : null; + } catch (_) { + return null; + } + } + async function copyText(source, node) { + if (node.dataset.label === undefined) node.dataset.label = node.textContent; + try { + await navigator.clipboard.writeText(source); + node.textContent = 'Copied'; + } catch (_) { + node.textContent = 'Copy blocked'; + } + setTimeout(() => { + node.textContent = node.dataset.label; + }, 1500); + } + /* The policy becomes the first element of the program's head, as in the + chat client: after an existing head tag, else in a head of its own. The + prefix (doctype, comments, html tag) is skipped one sticky token at a + time and a comment body never holds its closing marker, so the scan is + linear in the source. */ + function sandboxed(source) { + const meta = ``; + const prefix = /\s*(?:]*>||]*)?>)/iy; + let at = 0; + while (prefix.exec(source)) at = prefix.lastIndex; + const head = /\s*]*)?>/iy; + head.lastIndex = at; + if (head.exec(source)) return source.slice(0, head.lastIndex) + meta + source.slice(head.lastIndex); + const lead = /^\s*(?:]*>\s*)?(?:]*)?>)?/i.exec(source)[0]; + return `${lead}${meta}${source.slice(lead.length)}`; + } + + /* Project files and IndexedDB records share one format. */ + function checkEntry(p) { + if (!shape(p, ['id', 'kind', 'title', 'revision', 'content', 'provenance'], ['geom', 'minimized'])) return 'unexpected or missing fields'; + let reason = check('pane.open', { v: VERSION, id: p.id, kind: p.kind, title: p.title }); + if (!reason) reason = check('pane.update', { v: VERSION, id: p.id, revision: p.revision, content: p.content, provenance: p.provenance }, p.kind); + if (reason) return reason; + if (own(p, 'geom') && !(shape(p.geom, ['x', 'y', 'w', 'h']) && ['x', 'y', 'w', 'h'].every(k => finite(p.geom[k])))) return 'invalid geometry'; + if (own(p, 'minimized') && typeof p.minimized !== 'boolean') return 'invalid minimized flag'; + return ''; + } + function checkFile(data) { + if (!shape(data, ['format', 'v', 'panes'], ['id', 'name', 'saved', 'exported']) || data.format !== FORMAT || data.v !== VERSION) return 'this is not an Aien panes file'; + for (const k of ['id', 'name', 'saved', 'exported']) if (own(data, k) && !isText(data[k], MAX_TITLE)) return `invalid ${k}`; + if (!Array.isArray(data.panes) || data.panes.length > MAX_PANES) return `a file holds at most ${MAX_PANES} panes`; + for (let i = 0; i < data.panes.length; i++) { + const reason = checkEntry(data.panes[i]); + if (reason) return `pane ${i + 1}: ${reason}`; + } + return ''; + } + function limit(message) { + const error = new Error(message); + error.name = 'AllenLimit'; + return error; + } + function storageError(error) { + const name = error && error.name; + if (name === 'AllenLimit') return error.message; + if (name === 'QuotaExceededError') return 'This browser refused: it has no storage space left for this site. Export the panes as a file instead.'; + if (name === 'SecurityError' || name === 'InvalidStateError' || name === 'AllenNoStore') return 'This browser does not allow storage here, for example in private browsing. Export the panes as a file instead.'; + const detail = error && error.message ? ` (${clean(error.message, 160)})` : ''; + return `This browser refused to store the project${detail}. Export the panes as a file instead.`; + } + function openDb() { + return new Promise((resolve, reject) => { + let request; + try { + if (!window.indexedDB) throw Object.assign(new Error('no IndexedDB'), { name: 'AllenNoStore' }); + request = window.indexedDB.open(DB_NAME, 1); + } catch (error) { + reject(error); + return; + } + request.onupgradeneeded = () => { + const db = request.result; + if (!db.objectStoreNames.contains(DB_PROJECTS)) db.createObjectStore(DB_PROJECTS, { keyPath: 'id' }); + if (!db.objectStoreNames.contains(DB_INDEX)) db.createObjectStore(DB_INDEX, { keyPath: 'id' }); + }; + request.onsuccess = () => { + const db = request.result; + db.onversionchange = () => db.close(); + resolve(db); + }; + request.onerror = () => reject(request.error || new Error('IndexedDB refused')); + request.onblocked = () => reject(new Error('another tab holds the project store open')); + }); + } + function ask(request) { + return new Promise((resolve, reject) => { + request.onsuccess = () => resolve(request.result); + request.onerror = () => reject(request.error); + }); + } + async function store(mode, work) { + const db = await openDb(); + try { + const tx = db.transaction([DB_PROJECTS, DB_INDEX], mode); + const done = new Promise((resolve, reject) => { + tx.oncomplete = () => resolve(); + tx.onabort = () => reject(tx.error || new Error('the storage transaction was aborted')); + }); + let value; + try { + value = await work(tx.objectStore(DB_PROJECTS), tx.objectStore(DB_INDEX)); + } catch (error) { + try { + tx.abort(); + } catch (_) {} + await done.catch(() => {}); + throw error; + } + await done; + return value; + } finally { + db.close(); + } + } + function stamp(iso) { + const when = new Date(iso); + return Number.isNaN(when.getTime()) ? String(iso) : when.toLocaleString(); + } + + function mount(host, options) { + if (!(host instanceof Element)) throw new TypeError('AllenPanes.mount needs an element'); + const opts = options && typeof options === 'object' ? options : {}; + const panes = new Map(); + const closedIds = new Set(); + const closed = []; + let order = []; + let cascade = 0; + let current = null; + let alive = true; + let fitting = 0; + const root = el('div', 'allen-panes'); + const layer = el('div', 'allen-panes-layer'); + const dock = el('nav', 'allen-panes-dock'); + dock.setAttribute('aria-label', 'Aien panes'); + const chips = el('ul', 'allen-panes-chips'); + const projectsButton = button('allen-panes-tool', 'Projects: save, open, export or import panes', 'Projects', () => projectsPane()); + const exportButton = button('allen-panes-tool', 'Export the open panes as a JSON file', 'Export', () => exportOpen()); + const reopenButton = button('allen-panes-tool', '', 'Reopen', () => reopen()); + reopenButton.hidden = true; + dock.append(chips, projectsButton, exportButton, reopenButton); + const live = el('p', 'allen-panes-live'); + live.setAttribute('role', 'status'); + live.setAttribute('aria-live', 'polite'); + root.append(layer, dock, live); + host.append(root); + const media = typeof window.matchMedia === 'function' ? window.matchMedia(SHEET) : null; + + function say(message) { + live.textContent = ''; + setTimeout(() => { + if (alive) live.textContent = message; + }, 60); + if (typeof opts.announce === 'function') { + try { + opts.announce(message); + } catch (_) {} + } + } + function refuse(name, reason) { + if (typeof opts.onRefuse === 'function') { + try { + opts.onRefuse(name, reason); + } catch (_) {} + } + return { ok: false, reason }; + } + function sheet() { + return root.dataset.layout === 'sheet'; + } + function layout() { + root.dataset.layout = media && media.matches ? 'sheet' : 'float'; + refit(); + } + function bounds() { + return { w: Math.max(root.clientWidth, MIN_W), h: Math.max(root.clientHeight, MIN_H) }; + } + function place(rec, x, y, w, h) { + const b = bounds(); + const nw = Math.round(Math.min(Math.max(w, MIN_W), b.w)); + const nh = Math.round(Math.min(Math.max(h, MIN_H), b.h)); + const nx = Math.round(Math.min(Math.max(x, 0), b.w - nw)); + const ny = Math.round(Math.min(Math.max(y, 0), b.h - nh)); + rec.geom = { x: nx, y: ny, w: nw, h: nh }; + rec.el.style.transform = `translate(${nx}px, ${ny}px)`; + rec.el.style.width = `${nw}px`; + rec.el.style.height = `${nh}px`; + } + function refit() { + for (const rec of panes.values()) place(rec, rec.geom.x, rec.geom.y, rec.geom.w, rec.geom.h); + } + function onResize() { + if (!fitting) fitting = requestAnimationFrame(() => { + fitting = 0; + if (alive) refit(); + }); + } + function initial(rec) { + const b = bounds(); + const w = Math.min(560, b.w - 32); + const h = Math.min(460, b.h - 160); + const step = (cascade % 6) * 28; + cascade += 1; + place(rec, b.w - w - 32 - step, 76 + step, w, h); + } + function topmost() { + for (let i = order.length - 1; i >= 0; i--) if (!order[i].minimized) return order[i]; + return null; + } + function chipState(rec) { + rec.chipTitle.textContent = rec.title; + rec.chip.setAttribute('aria-label', `${rec.title}, ${NAMES[rec.kind]} pane, ${rec.minimized ? 'minimized' : 'open'}`); + rec.chip.dataset.state = rec.minimized ? 'minimized' : 'open'; + } + function stack() { + const top = topmost(); + order.forEach((rec, i) => { + rec.el.style.zIndex = String(i + 1); + rec.el.toggleAttribute('data-top', rec === top); + rec.chip.toggleAttribute('data-top', rec === top); + }); + dock.dataset.empty = panes.size ? 'no' : 'yes'; + } + function raise(rec) { + if (order[order.length - 1] !== rec) { + order = order.filter(r => r !== rec); + order.push(rec); + } + stack(); + } + function owner(node) { + for (const rec of panes.values()) if (rec.el.contains(node)) return rec; + return null; + } + function label(rec) { + rec.heading.textContent = rec.title; + rec.move.setAttribute('aria-label', `Move ${rec.title}. Drag, or use the arrow keys; Shift moves farther.`); + rec.size.setAttribute('aria-label', `Resize ${rec.title}. Drag, or use the arrow keys; Shift resizes farther.`); + rec.min.setAttribute('aria-label', `Minimize ${rec.title}`); + rec.max.setAttribute('aria-label', `Maximize ${rec.title}`); + rec.max.setAttribute('aria-pressed', String(rec.maximized)); + rec.shut.setAttribute('aria-label', `Close ${rec.title}`); + rec.grab.setAttribute('aria-label', `Minimize ${rec.title}. On a touch screen, swipe the top of the sheet down to minimize, or sideways for the next pane.`); + chipState(rec); + } + function create(key, kind, title) { + const rec = { id: key, kind, title: clean(title, MAX_TITLE) || NAMES[kind], revision: 0, content: null, provenance: null, geom: null, minimized: false, maximized: false, svg: null, app: null, projects: null }; + const pane = el('section', 'allen-pane'); + pane.dataset.kind = kind; + pane.tabIndex = -1; + pane.setAttribute('role', 'region'); + pane.setAttribute('aria-roledescription', 'pane'); + const head = el('header', 'allen-pane-head'); + const heading = el('h2', 'allen-pane-title'); + heading.id = uid('allen-pane-title'); + pane.setAttribute('aria-labelledby', heading.id); + const move = button('allen-pane-move', '', '', null); + const badge = el('span', 'allen-pane-badge'); + badge.hidden = true; + const controls = el('div', 'allen-pane-controls'); + const min = button('allen-pane-ctl allen-pane-min', '', '\u2212', () => minimize(rec)); + const max = button('allen-pane-ctl allen-pane-max', '', '\u25a1', () => maximize(rec)); + const shut = button('allen-pane-ctl allen-pane-close', '', '\u00d7', () => close(rec, true)); + controls.append(min, max, shut); + head.append(move, el('span', 'allen-pane-kind', NAMES[kind]), heading, badge, controls); + const notice = el('p', 'allen-pane-notice'); + notice.setAttribute('role', 'alert'); + notice.hidden = true; + const body = el('div', 'allen-pane-body'); + body.tabIndex = 0; + const source = el('details', 'allen-pane-source'); + source.hidden = true; + const foot = el('div', 'allen-pane-foot'); + foot.hidden = true; + const size = button('allen-pane-size', '', '', null); + const grab = button('allen-pane-grab', '', '', () => minimize(rec)); + pane.append(grab, head, notice, body, source, foot, size); + const item = el('li', 'allen-panes-item'); + const chip = button('allen-panes-chip', '', '', () => chipClick(rec)); + const chipTitle = el('span', 'allen-panes-chip-title'); + chip.append(el('span', 'allen-panes-chip-kind', NAMES[kind]), chipTitle); + item.append(chip); + Object.assign(rec, { el: pane, heading, badge, notice, body, source, foot, move, size, grab, min, max, shut, item, chip, chipTitle, swallow: 0 }); + label(rec); + pane.addEventListener('pointerdown', () => raise(rec), true); + pane.addEventListener('focusin', () => raise(rec)); + drag(rec, head, 'move'); + swipe(rec, head); + swipe(rec, grab); + pane.addEventListener('click', event => { + if (event.timeStamp > rec.swallow) return; + rec.swallow = 0; + event.preventDefault(); + event.stopPropagation(); + }, true); + drag(rec, size, 'size'); + keyed(rec, move, 'move'); + keyed(rec, size, 'size'); + layer.append(pane); + chips.append(item); + panes.set(key, rec); + order.push(rec); + initial(rec); + stack(); + return rec; + } + /* Bottom sheet gestures, only on the grab strip and the title bar, so the + content keeps its own scrolling, selection and editing. Down past a + quarter of the sheet (or a quick flick) minimizes; sideways shows the + neighbouring pane. A swipe never reaches the button it started on. */ + function swipe(rec, zone) { + zone.addEventListener('pointerdown', event => { + if (!sheet() || !event.isPrimary || event.button !== 0) return; + const start = { x: event.clientX, y: event.clientY, t: event.timeStamp }; + const height = Math.max(1, rec.el.getBoundingClientRect().height); + let mode = ''; + let last = event; + let frame = 0; + const paint = () => { + frame = 0; + if (!alive || !mode) return; + const dx = last.clientX - start.x; + const dy = last.clientY - start.y; + rec.el.style.setProperty('--allen-pane-swipe-x', mode === 'side' ? `${Math.round(dx / 2)}px` : '0px'); + rec.el.style.setProperty('--allen-pane-swipe-y', mode === 'down' ? `${Math.round(Math.max(0, dy))}px` : '0px'); + }; + const settle = () => { + rec.el.classList.remove('is-swiping'); + rec.el.style.removeProperty('--allen-pane-swipe-x'); + rec.el.style.removeProperty('--allen-pane-swipe-y'); + }; + const onMove = e => { + if (e.pointerId !== event.pointerId) return; + last = e; + const dx = e.clientX - start.x; + const dy = e.clientY - start.y; + if (!mode) { + if (Math.abs(dx) < 10 && Math.abs(dy) < 10) return; + mode = Math.abs(dy) >= Math.abs(dx) ? (dy > 0 ? 'down' : 'up') : 'side'; + try { + zone.setPointerCapture(e.pointerId); + } catch (_) {} + rec.el.classList.add('is-swiping'); + } + if (mode !== 'up' && !frame) frame = requestAnimationFrame(paint); + }; + const onEnd = e => { + if (e.pointerId !== event.pointerId) return; + zone.removeEventListener('pointermove', onMove); + zone.removeEventListener('pointerup', onEnd); + zone.removeEventListener('pointercancel', onEnd); + if (frame) cancelAnimationFrame(frame); + frame = 0; + settle(); + if (!mode) return; + rec.swallow = e.timeStamp + 500; + if (e.type === 'pointercancel' || !alive) return; + const dx = e.clientX - start.x; + const dy = e.clientY - start.y; + const speed = Math.max(Math.abs(dx), Math.abs(dy)) / Math.max(1, e.timeStamp - start.t); + if (mode === 'down' && (dy > height / 4 || (dy > 24 && speed > 0.6))) minimize(rec); + else if (mode === 'side' && (Math.abs(dx) > 72 || (Math.abs(dx) > 24 && speed > 0.6))) neighbour(rec, dx < 0 ? 1 : -1); + }; + zone.addEventListener('pointermove', onMove); + zone.addEventListener('pointerup', onEnd); + zone.addEventListener('pointercancel', onEnd); + }); + } + function neighbour(rec, dir) { + const all = [...panes.values()]; + if (all.length < 2) return; + const next = all[(all.indexOf(rec) + dir + all.length) % all.length]; + const had = rec.el.contains(document.activeElement); + restore(next, had); + say(`${next.title}, pane ${all.indexOf(next) + 1} of ${all.length}.`); + } + function drag(rec, handle, mode) { + handle.addEventListener('pointerdown', event => { + if (event.button !== 0 || sheet() || rec.maximized) return; + const hit = event.target.closest('button'); + if (mode === 'move' && hit && hit !== rec.move) return; + event.preventDefault(); + raise(rec); + const start = { x: event.clientX, y: event.clientY, g: { ...rec.geom } }; + let frame = 0; + let last = null; + try { + handle.setPointerCapture(event.pointerId); + } catch (_) {} + rec.el.classList.add(mode === 'move' ? 'is-moving' : 'is-sizing'); + const apply = () => { + frame = 0; + if (!last || !alive) return; + const dx = last.clientX - start.x; + const dy = last.clientY - start.y; + if (mode === 'move') place(rec, start.g.x + dx, start.g.y + dy, start.g.w, start.g.h); + else place(rec, start.g.x, start.g.y, start.g.w + dx, start.g.h + dy); + }; + const onMove = e => { + if (e.pointerId !== event.pointerId) return; + last = e; + if (!frame) frame = requestAnimationFrame(apply); + }; + const onUp = e => { + if (e.pointerId !== event.pointerId) return; + handle.removeEventListener('pointermove', onMove); + handle.removeEventListener('pointerup', onUp); + handle.removeEventListener('pointercancel', onUp); + if (frame) cancelAnimationFrame(frame); + apply(); + rec.el.classList.remove('is-moving', 'is-sizing'); + }; + handle.addEventListener('pointermove', onMove); + handle.addEventListener('pointerup', onUp); + handle.addEventListener('pointercancel', onUp); + }); + } + function keyed(rec, handle, mode) { + handle.addEventListener('keydown', event => { + const d = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key]; + if (!d || event.altKey || event.ctrlKey || event.metaKey || sheet() || rec.maximized) return; + event.preventDefault(); + const s = event.shiftKey ? BIG_STEP : STEP; + const g = rec.geom; + if (mode === 'move') place(rec, g.x + d[0] * s, g.y + d[1] * s, g.w, g.h); + else place(rec, g.x, g.y, g.w + d[0] * s, g.h + d[1] * s); + }); + handle.addEventListener('keyup', event => { + if (!event.key.startsWith('Arrow') || sheet() || rec.maximized) return; + const g = rec.geom; + say(mode === 'move' ? `${rec.title} at ${g.x}, ${g.y}.` : `${rec.title} is ${g.w} by ${g.h}.`); + }); + } + function minimize(rec) { + if (rec.minimized) return; + const had = rec.el.contains(document.activeElement); + rec.minimized = true; + rec.el.hidden = true; + chipState(rec); + stack(); + if (had) rec.chip.focus(); + say(`${rec.title} minimized; it stays in the pane list.`); + } + function restore(rec, focus) { + if (rec.minimized) { + rec.minimized = false; + rec.el.hidden = false; + chipState(rec); + } + raise(rec); + if (focus) rec.el.focus({ preventScroll: true }); + } + function maximize(rec) { + rec.maximized = !rec.maximized; + rec.el.classList.toggle('is-max', rec.maximized); + label(rec); + raise(rec); + } + function chipClick(rec) { + if (rec.minimized) restore(rec, true); + else if (topmost() === rec) minimize(rec); + else restore(rec, true); + } + function dataPane(rec) { + return KINDS.includes(rec.kind) && rec.revision > 0; + } + function entry(rec) { + return { id: rec.id, kind: rec.kind, title: rec.title, revision: rec.revision, content: copy(rec.content), provenance: copy(rec.provenance), geom: { ...rec.geom }, minimized: rec.minimized }; + } + function reopenState() { + const last = closed[closed.length - 1]; + reopenButton.hidden = !last; + if (last) reopenButton.setAttribute('aria-label', `Reopen ${last.title}`); + } + function close(rec, byPerson, quiet) { + if (panes.get(rec.id) !== rec) return; + const had = rec.el.contains(document.activeElement); + stopApp(rec); + rec.el.remove(); + rec.item.remove(); + panes.delete(rec.id); + order = order.filter(r => r !== rec); + const kept = dataPane(rec); + if (kept) { + closed.push(entry(rec)); + while (closed.length > MAX_CLOSED) closed.shift(); + } + reopenState(); + stack(); + if (had) { + const next = topmost(); + if (next) next.el.focus({ preventScroll: true }); + else if (opts.returnFocus instanceof HTMLElement && opts.returnFocus.isConnected) opts.returnFocus.focus(); + else projectsButton.focus(); + } + if (!quiet) say(byPerson ? `${rec.title} closed.${kept ? ' Reopen brings it back.' : ''}` : `Aien closed ${rec.title}.`); + if (typeof opts.onClose === 'function') { + try { + opts.onClose(rec.kind === 'card' ? rec.id.slice(5) : rec.id, rec.kind, byPerson); + } catch (_) {} + } + } + function reopen() { + const last = closed.pop(); + reopenState(); + if (!last) return; + const rec = restoreEntry(last); + if (rec) { + rec.el.focus({ preventScroll: true }); + say(`${rec.title} reopened.`); + } else { + closed.push(last); + reopenState(); + say(`At most ${MAX_PANES} panes can be open. Close one to make room.`); + } + } + function notify(rec, message) { + rec.notice.textContent = message; + rec.notice.hidden = false; + } + function waiting(rec) { + rec.el.setAttribute('aria-busy', 'true'); + rec.body.replaceChildren(el('p', 'allen-pane-note', 'Aien is preparing this pane.')); + } + + function apply(rec, revision, content, prov) { + stopApp(rec); + rec.revision = revision; + rec.content = copy(content); + rec.provenance = copy(prov); + rec.svg = null; + rec.notice.hidden = true; + rec.el.removeAttribute('aria-busy'); + rec.body.replaceChildren(); + render(rec); + rec.badge.textContent = STATUS_NAMES[rec.provenance.status]; + rec.badge.dataset.status = rec.provenance.status; + rec.badge.hidden = false; + sourceBlock(rec); + footBlock(rec); + } + function section(heading) { + const box = el('section', 'allen-pane-section'); + box.append(el('h3', 'allen-pane-h3', heading)); + return box; + } + function refList(heading, items) { + const box = section(heading); + const list = el('ol', 'allen-pane-refs'); + for (const r of items) { + const li = el('li'); + li.append(link(r.title, r.url)); + list.append(li); + } + box.append(list, el('p', 'allen-pane-label', 'Links are shown as given; this page never fetched or checked them.')); + return box; + } + /* A diff or patch fence gets its own Copy and Download patch. The patch + is only ever a downloaded file; nothing here applies it. */ + function patchTool(rec) { + let n = 0; + return (lang, text) => { + if (!/^(diff|patch)$/i.test(lang) || !text.trim()) return null; + n += 1; + const name = `${slug(rec.title) || 'allen'}${n > 1 ? `-${n}` : ''}.patch`; + const bar = el('div', 'allen-pane-bar allen-md-tools'); + const copyButton = button('allen-pane-act', `Copy patch ${n} of ${rec.title}`, 'Copy patch', () => copyText(`${text}\n`, copyButton)); + bar.append(copyButton, button('allen-pane-act', `Download patch ${n} of ${rec.title} as ${name}; it is not applied anywhere`, 'Download patch', () => download(name, `${text}\n`))); + return bar; + }; + } + function render(rec) { + const c = rec.content; + const body = rec.body; + body.append(el('p', 'allen-pane-caveat', CAVEATS[rec.provenance.status])); + if (rec.kind === 'math') { + const result = el('p', 'allen-pane-math', c.text); + result.setAttribute('aria-label', `Result: ${c.text}`); + body.append(result); + if (own(c, 'tex')) body.append(texBlock(c.tex, 'The engine\u2019s formula')); + } else if (rec.kind === 'plot') { + const drawn = plot(c, rec.title); + rec.svg = drawn.svg; + body.append(drawn.figure); + } else if (rec.kind === 'doc') { + body.append(markdown(c.markdown, el('div', 'allen-md'), patchTool(rec))); + if (c.citations.length) body.append(refList('Citations', c.citations)); + } else if (rec.kind === 'code' || rec.kind === 'omega') { + body.append(el('p', 'allen-pane-label', rec.kind === 'omega' ? 'Omega source' : `${clean(c.language, 40) || 'Code'} source`)); + const pre = el('pre', 'allen-pane-code'); + pre.append(el('code', '', c.source)); + body.append(pre); + if (own(c, 'functions') && c.functions.length) { + const box = section('Functions'); + const list = el('ul', 'allen-pane-fns'); + for (const f of c.functions) list.append(el('li', 'allen-pane-mono', `${f.name}(${f.params.map(p => `${p.name} ${p.type}`).join(', ')}) to ${f.ret}`)); + box.append(list); + body.append(box); + } + if (own(c, 'wasm')) { + const bytes = wasmBytes(c.wasm); + const box = section('WebAssembly'); + if (bytes) { + box.append(el('p', 'allen-pane-note', `${bytes.length} bytes. Offered as a file only; this page does not run it.`), button('allen-pane-act', `Download the WebAssembly of ${rec.title}`, 'Download .wasm', () => download(`${slug(rec.title) || 'omega'}.wasm`, bytes))); + } else { + box.append(el('p', 'allen-pane-note', 'WebAssembly was attached, but it is not a valid base64 WebAssembly module.')); + } + body.append(box); + } + } else if (rec.kind === 'app') { + body.append(el('p', 'allen-pane-note', 'Aien wrote this app. It runs only when you press Run, in a sandbox with no access to this page, your cookies or the network.')); + const bar = el('div', 'allen-pane-bar'); + const stage = el('div', 'allen-pane-stage'); + const run = button('allen-pane-act allen-pane-run', `Run ${rec.title} in a sandbox`, 'Run', () => runApp(rec, stage, run, stop)); + const stop = button('allen-pane-act', `Stop ${rec.title}`, 'Stop', () => stopApp(rec)); + stop.hidden = true; + bar.append(run, stop); + body.append(bar, stage); + rec.app = { frame: null, run, stop }; + } else if (rec.kind === 'research') { + const notes = section('Notes'); + notes.append(markdown(c.notes, el('div', 'allen-md'), patchTool(rec))); + body.append(notes); + if (c.hypotheses.length) { + const box = section('Hypotheses'); + const list = el('ul', 'allen-md-list'); + for (const h of c.hypotheses) list.append(inline(el('li'), h)); + box.append(list); + body.append(box); + } + if (c.derivations.length) { + const box = section('Derivations'); + const list = el('ol', 'allen-pane-derivations'); + for (const d of c.derivations) { + const li = el('li'); + li.append(el('pre', 'allen-pane-pre', d)); + list.append(li); + } + box.append(list); + body.append(box); + } + if (c.sources.length) body.append(refList('Sources', c.sources)); + } else if (rec.kind === 'data') { + const grid = table(c.columns, c.rows); + grid.firstChild.setAttribute('aria-labelledby', rec.heading.id); + body.append(grid); + } + } + function runApp(rec, stage, run, stop) { + stopApp(rec); + const frame = document.createElement('iframe'); + frame.setAttribute('sandbox', SANDBOX); + frame.setAttribute('referrerpolicy', 'no-referrer'); + frame.setAttribute('allow', "camera 'none'; microphone 'none'; geolocation 'none'; usb 'none'; serial 'none'; bluetooth 'none'; payment 'none'; display-capture 'none'; clipboard-read 'none'; clipboard-write 'none'; fullscreen 'none'"); + frame.setAttribute('title', `${rec.title}, an app written by Aien, sandboxed`); + frame.className = 'allen-pane-frame'; + frame.srcdoc = sandboxed(rec.content.html); + stage.replaceChildren(frame); + rec.app = { frame, run, stop }; + run.hidden = true; + stop.hidden = false; + stop.focus(); + } + function stopApp(rec) { + if (!rec.app || !rec.app.frame) return; + const hadFocus = rec.el.contains(document.activeElement); + rec.app.frame.remove(); + rec.app.frame = null; + rec.app.run.hidden = false; + rec.app.stop.hidden = true; + if (hadFocus && rec.app.run.isConnected) rec.app.run.focus(); + } + function sourceBlock(rec) { + const list = el('dl', 'allen-pane-prov'); + const row = (key, value, mono) => { + if (value === '') return; + list.append(el('dt', '', key), el('dd', mono ? 'allen-pane-mono' : '', value)); + }; + const p = rec.provenance; + row('Status', STATUS_NAMES[p.status]); + row('Engine', p.engine); + row('Expression', p.expression, true); + row('Result', p.result, true); + row('Source', p.source); + row('Commit', p.commit, true); + row('Pane', rec.id, true); + row('Revision', String(rec.revision)); + const raw = el('pre', 'allen-pane-raw', JSON.stringify({ content: rec.content, provenance: rec.provenance }, null, 2)); + raw.setAttribute('aria-label', `Everything Aien sent for ${rec.title}, as JSON`); + raw.tabIndex = 0; + rec.source.replaceChildren(el('summary', 'allen-pane-summary', 'Source and provenance'), list, el('p', 'allen-pane-label', 'As received'), raw); + rec.source.hidden = false; + } + function footBlock(rec) { + const out = artefact(rec); + if (!out) return; + const base = slug(rec.title) || rec.kind; + const ext = out.name.slice(out.name.lastIndexOf('.')); + const copyButton = button('allen-pane-act', `Copy the ${out.what} of ${rec.title}`, 'Copy', () => copyText(out.copy, copyButton)); + const save = button('allen-pane-act', `Download ${rec.title} as ${ext}`, `Download ${ext}`, () => download(out.name, out.data())); + const json = button('allen-pane-act', `Download ${rec.title} with its provenance as JSON`, 'Download .json', () => download(`${base}.json`, JSON.stringify(file([entry(rec)], rec.title), null, 2))); + rec.foot.replaceChildren(copyButton, save, json); + const keep = reportSave(rec); + if (keep) rec.foot.append(...keep); + rec.foot.hidden = false; + } + /* A repo report can become the visitor's own Omega project, only when the + page supplies saveProject and only after the visitor has seen the file + list and pressed Save. The page owns the request and the visitor's + handle; this file never touches the network. */ + function reportSave(rec) { + if (rec.kind !== 'doc' || typeof opts.saveProject !== 'function') return null; + const named = REPORT.exec(rec.title); + if (!named) return null; + const files = reportFiles(rec.content.markdown); + const repo = `${named[1]}/${named[2]}`; + const ports = files.filter(f => f.path.endsWith('.om')).length; + const box = el('div', 'allen-pane-save'); + box.hidden = true; + const state = el('p', 'allen-projects-state'); + state.setAttribute('role', 'status'); + const open = button('allen-pane-act allen-pane-run', `Save ${rec.title} to my Omega projects`, 'Save to my Omega projects', () => { + box.hidden = !box.hidden; + open.setAttribute('aria-expanded', String(!box.hidden)); + if (!box.hidden) confirm.focus(); + }); + open.setAttribute('aria-expanded', 'false'); + const list = el('ul', 'allen-pane-files'); + for (const f of files) list.append(el('li', 'allen-pane-mono', `${f.path}, ${utf8(f.content)} bytes`)); + const confirm = button('allen-pane-act allen-pane-run', `Save these ${files.length} files as an Omega project`, `Save ${files.length} file${files.length === 1 ? '' : 's'}`, async () => { + confirm.disabled = true; + state.replaceChildren(document.createTextNode('Saving.')); + let r; + try { + r = await opts.saveProject({ project: slug(`${named[1]}-${named[2]}`) || 'allen-report', title: `Omega path for ${repo}`, description: `Aien's report on ${repo}${ports ? `, with ${ports} Omega port${ports === 1 ? '' : 's'}` : ''}.`, files: files.map(f => ({ path: f.path, content: f.content })) }); + } catch (_) { + r = null; + } + confirm.disabled = false; + if (r && r.ok === true) { + state.replaceChildren(document.createTextNode('Saved. Status: '), statusLink(r.url)); + } else { + state.replaceChildren(document.createTextNode(r && typeof r.reason === 'string' ? clean(r.reason, 300) : 'The project could not be saved; nothing was stored.')); + } + }); + const cancel = button('allen-pane-act', 'Do not save the report', 'Cancel', () => { + box.hidden = true; + open.setAttribute('aria-expanded', 'false'); + open.focus(); + }); + const bar = el('div', 'allen-pane-bar'); + bar.append(confirm, cancel); + box.append(el('p', 'allen-pane-note', `These files become a project under your handle in Omega projects, for Drake to review before anything is published:`), list, bar); + return [open, box, state]; + } + function statusLink(url) { + if (typeof url !== 'string' || !url) return document.createTextNode('no status address was returned.'); + if (/^\/(?!\/)/.test(url)) { + try { + const here = new URL(url, window.location.href); + if (here.origin === window.location.origin) { + const a = el('a', 'allen-link', here.pathname + here.search); + a.href = here.href; + return a; + } + } catch (_) {} + } + return link(url, url); + } + function download(name, data) { + const blob = new Blob([data], { type: 'application/octet-stream' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = name; + a.hidden = true; + root.append(a); + a.click(); + a.remove(); + setTimeout(() => URL.revokeObjectURL(url), 30000); + } + function file(entries, name) { + return { format: FORMAT, v: VERSION, name: clean(name || 'Aien panes', MAX_NAME), exported: new Date().toISOString(), panes: entries }; + } + function snapshot() { + return order.filter(dataPane).map(entry); + } + function exportOpen() { + const entries = snapshot(); + if (!entries.length) { + say('There are no panes with content to export yet.'); + return { ok: false, reason: 'nothing to export' }; + } + download('aien-panes.json', JSON.stringify(file(entries, current ? current.name : 'Aien panes'), null, 2)); + say(`Exported ${entries.length} pane${entries.length === 1 ? '' : 's'} as a JSON file.`); + return { ok: true, count: entries.length }; + } + function restoreEntry(p) { + if (panes.size >= MAX_PANES) return null; + let key = p.id; + for (let n = 2; panes.has(key) && n < 100; n++) key = `${p.id.slice(0, 58)}-${n}`; + if (panes.has(key)) return null; + const rec = create(key, p.kind, p.title); + apply(rec, p.revision, p.content, p.provenance); + if (p.geom) place(rec, p.geom.x, p.geom.y, p.geom.w, p.geom.h); + if (p.minimized) { + rec.minimized = true; + rec.el.hidden = true; + chipState(rec); + } + stack(); + return rec; + } + function restoreAll(data) { + const room = MAX_PANES - panes.size; + if (data.panes.length > room) return { ok: false, reason: `Only ${room} more pane${room === 1 ? '' : 's'} fit; close some panes first.` }; + for (const p of data.panes) restoreEntry(p); + return { ok: true, count: data.panes.length }; + } + + /* Projects: IndexedDB only after an explicit save; an index store keeps + the list cheap to read. */ + async function list() { + try { + const items = await store('readonly', (_, index) => ask(index.getAll())); + items.sort((a, b) => String(b.saved).localeCompare(String(a.saved))); + return { ok: true, projects: items.map(i => ({ id: i.id, name: i.name, saved: i.saved, count: i.count })) }; + } catch (error) { + return { ok: false, reason: storageError(error) }; + } + } + async function save(name) { + const entries = snapshot(); + if (!entries.length) return { ok: false, reason: 'There are no panes with content to save yet.' }; + const title = clean(name || '', MAX_NAME) || (current ? current.name : `Project ${new Date().toLocaleString()}`); + const id = current && current.name === title ? current.id : `p${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`; + const record = { format: FORMAT, v: VERSION, id, name: title, saved: new Date().toISOString(), panes: entries }; + const bytes = utf8(JSON.stringify(record)); + if (bytes > MAX_PROJECT_BYTES) return { ok: false, reason: `This project is ${bytes} bytes; one project holds at most ${MAX_PROJECT_BYTES}. Export it as a file instead.` }; + try { + await store('readwrite', async (projects, index) => { + const existing = await ask(index.get(id)); + const count = await ask(index.count()); + if (!existing && count >= MAX_PROJECTS) throw limit(`${MAX_PROJECTS} projects are saved in this browser; delete one first, or export instead.`); + await ask(projects.put(record)); + await ask(index.put({ id, name: title, saved: record.saved, count: entries.length })); + }); + } catch (error) { + return { ok: false, reason: storageError(error) }; + } + current = { id, name: title }; + return { ok: true, id, name: title, count: entries.length }; + } + async function load(id) { + let record; + try { + record = await store('readonly', projects => ask(projects.get(String(id)))); + } catch (error) { + return { ok: false, reason: storageError(error) }; + } + if (!record) return { ok: false, reason: 'That project is no longer saved in this browser.' }; + const reason = checkFile(record); + if (reason) return { ok: false, reason: `The saved project could not be read: ${reason}.` }; + const done = restoreAll(record); + if (done.ok) current = { id: record.id, name: record.name }; + return done.ok ? { ok: true, id: record.id, name: record.name, count: done.count } : done; + } + async function remove(id) { + try { + await store('readwrite', (projects, index) => Promise.all([ask(projects.delete(String(id))), ask(index.delete(String(id)))])); + } catch (error) { + return { ok: false, reason: storageError(error) }; + } + if (current && current.id === id) current = null; + return { ok: true, id }; + } + async function exportSaved(id) { + let record; + try { + record = await store('readonly', projects => ask(projects.get(String(id)))); + } catch (error) { + return { ok: false, reason: storageError(error) }; + } + if (!record) return { ok: false, reason: 'That project is no longer saved in this browser.' }; + download(`${slug(record.name) || 'allen-project'}.json`, JSON.stringify(record, null, 2)); + return { ok: true, id }; + } + async function importFile(source) { + let text; + if (typeof source === 'string') text = source; + else if (source && typeof source.text === 'function' && typeof source.size === 'number') { + if (source.size > MAX_PROJECT_BYTES) return { ok: false, reason: `A project file holds at most ${MAX_PROJECT_BYTES} bytes.` }; + try { + text = await source.text(); + } catch (_) { + return { ok: false, reason: 'This browser could not read the file.' }; + } + } else return { ok: false, reason: 'Import takes a project file or its JSON text.' }; + if (utf8(text) > MAX_PROJECT_BYTES) return { ok: false, reason: `A project file holds at most ${MAX_PROJECT_BYTES} bytes.` }; + let data; + try { + data = JSON.parse(text); + } catch (_) { + return { ok: false, reason: 'That file is not JSON.' }; + } + const reason = checkFile(data); + if (reason) return { ok: false, reason: `That file was refused: ${reason}.` }; + return restoreAll(data); + } + function project(command, arg) { + if (!alive) return Promise.resolve({ ok: false, reason: 'unmounted' }); + if (command === 'save') return save(arg); + if (command === 'list') return list(); + if (command === 'open') return load(arg); + if (command === 'remove') return remove(arg); + if (command === 'export') return arg === undefined ? Promise.resolve(exportOpen()) : exportSaved(arg); + if (command === 'import') return importFile(arg); + if (command === undefined || command === 'panel') { + projectsPane(); + return Promise.resolve({ ok: true }); + } + return Promise.resolve({ ok: false, reason: 'unknown project command' }); + } + function projectsPane() { + let rec = panes.get('#projects'); + if (rec) { + restore(rec, true); + refreshProjects(rec); + return; + } + if (panes.size >= MAX_PANES) { + say(`At most ${MAX_PANES} panes can be open. Close one to make room.`); + return; + } + rec = create('#projects', 'projects', 'Projects'); + const body = rec.body; + const status = el('p', 'allen-projects-state'); + status.setAttribute('role', 'status'); + const show = r => { + status.textContent = r.ok ? r.message : r.reason; + }; + const form = el('form', 'allen-projects-form'); + const nameId = uid('allen-project-name'); + const nameLabel = el('label', 'allen-pane-label', 'Project name'); + nameLabel.htmlFor = nameId; + const input = el('input', 'allen-projects-name'); + input.id = nameId; + input.type = 'text'; + input.maxLength = MAX_NAME; + input.autocomplete = 'off'; + input.value = current ? current.name : ''; + const submit = el('button', 'allen-pane-act allen-pane-run', 'Save project'); + submit.type = 'submit'; + form.append(nameLabel, input, submit); + form.addEventListener('submit', async event => { + event.preventDefault(); + submit.disabled = true; + const r = await save(input.value); + submit.disabled = false; + show(r.ok ? { ok: true, message: `Saved ${r.name} with ${r.count} pane${r.count === 1 ? '' : 's'} in this browser.` } : r); + if (r.ok) { + input.value = r.name; + refreshProjects(rec); + } + }); + const saved = el('ul', 'allen-projects-list'); + const fileId = uid('allen-project-file'); + const fileLabel = el('label', 'allen-pane-label', 'Import a project file (.json)'); + fileLabel.htmlFor = fileId; + const picker = el('input', 'allen-projects-file'); + picker.id = fileId; + picker.type = 'file'; + picker.accept = 'application/json,.json'; + picker.addEventListener('change', async () => { + const chosen = picker.files && picker.files[0]; + picker.value = ''; + if (!chosen) return; + const r = await importFile(chosen); + show(r.ok ? { ok: true, message: `Imported ${r.count} pane${r.count === 1 ? '' : 's'}. Nothing is stored until you press Save project.` } : r); + }); + const exporter = button('allen-pane-act', 'Export the open panes as a JSON file', 'Export open panes', () => { + const r = exportOpen(); + show(r.ok ? { ok: true, message: `Exported ${r.count} pane${r.count === 1 ? '' : 's'}.` } : { ok: false, reason: 'There are no panes with content to export yet.' }); + }); + const tools = el('div', 'allen-pane-bar'); + tools.append(exporter); + const academy = el('p', 'allen-pane-note allen-projects-academy'); + academy.append(link('Train your agent', ACADEMY)); + body.append(el('p', 'allen-pane-note', 'Nothing is stored until you press Save project. A project keeps the open panes, their provenance and where they sit, in this browser only. Conversations are not part of a project.'), form, status, section('Saved in this browser'), saved, fileLabel, picker, tools, academy); + if (typeof opts.syncSummary === 'function') body.append(summaryBox(show)); + rec.projects = { saved, show }; + refreshProjects(rec); + rec.el.focus({ preventScroll: true }); + } + /* Only when the page supplies syncSummary (a visitor with a remember key): + a short summary the visitor reads and edits first, sent on one explicit + click. Panes, code and data never leave the browser this way. */ + function draft() { + const parts = snapshot().map(p => `${NAMES[p.kind]}: ${p.title}`); + let text = `${current ? current.name : 'Project'}: ${parts.join('; ')}`; + while (utf8(text) > SYNC_MAX) text = text.slice(0, -1); + return text; + } + function summaryBox(show) { + const box = section('Sync a short summary'); + const areaId = uid('allen-project-summary'); + const note = el('p', 'allen-pane-note', `Only this summary is sent, at most ${SYNC_MAX} bytes, never the panes, code or data. Aien keeps one project summary for you and replaces it each time. Edit it first if you like.`); + const areaLabel = el('label', 'allen-pane-label', 'Summary to sync'); + areaLabel.htmlFor = areaId; + const area = el('textarea', 'allen-projects-summary'); + area.id = areaId; + area.rows = 3; + area.value = draft(); + const count = el('p', 'allen-pane-label'); + const recount = () => { + const n = utf8(area.value); + count.textContent = `${n} of ${SYNC_MAX} bytes`; + count.dataset.over = n > SYNC_MAX ? 'yes' : 'no'; + }; + area.addEventListener('input', recount); + recount(); + const refresh = button('allen-pane-act', 'Write the summary again from the open panes', 'Draft again', () => { + area.value = draft(); + recount(); + }); + const send = button('allen-pane-act allen-pane-run', 'Sync this short summary to Aien\u2019s memory of you', 'Sync short summary', async () => { + const text = area.value.trim(); + if (!text) return show({ ok: false, reason: 'The summary is empty.' }); + if (utf8(text) > SYNC_MAX) return show({ ok: false, reason: `The summary is over ${SYNC_MAX} bytes.` }); + send.disabled = true; + let r; + try { + r = await opts.syncSummary(text); + } catch (_) { + r = null; + } + send.disabled = false; + show(r && r.ok === true ? { ok: true, message: 'Synced the summary. Aien replaced the previous one.' } : { ok: false, reason: r && typeof r.reason === 'string' ? clean(r.reason, 300) : 'Aien could not sync the summary; nothing was stored.' }); + }); + const bar = el('div', 'allen-pane-bar'); + bar.append(refresh, send); + box.append(note, areaLabel, area, count, bar); + return box; + } + async function refreshProjects(rec) { + const ui = rec.projects; + if (!ui) return; + const r = await list(); + if (!r.ok) { + ui.saved.replaceChildren(el('li', 'allen-pane-note', r.reason)); + return; + } + if (!r.projects.length) { + ui.saved.replaceChildren(el('li', 'allen-pane-note', 'No projects are saved in this browser.')); + return; + } + ui.saved.replaceChildren(...r.projects.map(p => projectRow(rec, p))); + } + function projectRow(rec, p) { + const name = clean(p.name, MAX_NAME) || 'Untitled'; + const li = el('li', 'allen-projects-item'); + const text = el('div', 'allen-projects-text'); + text.append(el('span', 'allen-projects-title', name), el('span', 'allen-projects-meta', `${p.count} pane${p.count === 1 ? '' : 's'}, saved ${stamp(p.saved)}`)); + const acts = el('div', 'allen-pane-bar'); + const open = button('allen-pane-act', `Open project ${name}`, 'Open', async () => { + const r = await load(p.id); + rec.projects.show(r.ok ? { ok: true, message: `Opened ${r.name}.` } : r); + }); + const out = button('allen-pane-act', `Export project ${name} as a JSON file`, 'Export', async () => { + const r = await exportSaved(p.id); + rec.projects.show(r.ok ? { ok: true, message: `Exported ${name}.` } : r); + }); + const del = button('allen-pane-act allen-pane-danger', `Delete project ${name} from this browser`, 'Delete', async () => { + if (del.dataset.armed !== 'yes') { + del.dataset.armed = 'yes'; + del.textContent = 'Confirm delete'; + del.setAttribute('aria-label', `Confirm: delete project ${name} from this browser`); + setTimeout(() => { + if (!del.isConnected) return; + del.dataset.armed = ''; + del.textContent = 'Delete'; + del.setAttribute('aria-label', `Delete project ${name} from this browser`); + }, 5000); + return; + } + const r = await remove(p.id); + rec.projects.show(r.ok ? { ok: true, message: `Deleted ${name} from this browser.` } : r); + refreshProjects(rec); + if (rec.el.contains(document.activeElement) || !document.activeElement || document.activeElement === document.body) rec.el.focus({ preventScroll: true }); + }); + acts.append(open, out, del); + li.append(text, acts); + return li; + } + + /* The stream and the page call these. */ + function event(name, payload) { + if (!alive) return { ok: false, reason: 'unmounted' }; + const id = plain(payload) && typeof payload.id === 'string' ? payload.id : ''; + const rec = ID.test(id) ? panes.get(id) : undefined; + if (name === 'pane.close' && plain(payload) && !rec) { + const bad = check(name, payload, ''); + if (bad) return refuse(name, bad); + closedIds.add(id); + return { ok: true, id }; + } + if (name === 'pane.update' && !rec) return refuse(name, 'the pane is not open'); + const reason = check(name, payload, rec ? rec.kind : ''); + if (reason) { + if (rec && name === 'pane.update') notify(rec, `Aien sent an update this page could not show (${reason}). The last good version stays.`); + return refuse(name, reason); + } + if (name === 'pane.open') { + if (rec || closedIds.has(id)) return refuse(name, 'that pane id was already opened'); + if (panes.size >= MAX_PANES) { + say(`Aien tried to open another pane, but at most ${MAX_PANES} can be open. Close one to make room.`); + return refuse(name, 'too many panes'); + } + const made = create(id, payload.kind, payload.title); + waiting(made); + say(`Aien opened a ${NAMES[made.kind]} pane: ${made.title}.`); + return { ok: true, id }; + } + if (name === 'pane.update') { + if (payload.revision <= rec.revision) return refuse(name, 'the revision is not newer'); + apply(rec, payload.revision, payload.content, payload.provenance); + return { ok: true, id, revision: payload.revision }; + } + closedIds.add(id); + close(rec, false); + return { ok: true, id }; + } + function open(payload) { + if (!plain(payload)) return refuse('open', 'open takes an object'); + const id = own(payload, 'id') ? payload.id : `local-${Date.now().toString(36)}${(serial += 1)}`; + const opened = event('pane.open', { v: VERSION, id, kind: payload.kind, title: payload.title }); + if (!opened.ok || !own(payload, 'content')) return opened; + const rec = panes.get(id); + const prov = own(payload, 'provenance') ? payload.provenance : { status: 'unverified', engine: '', expression: '', result: '', source: 'this page', commit: '' }; + const updated = event('pane.update', { v: VERSION, id, revision: own(payload, 'revision') ? payload.revision : rec.revision + 1, content: payload.content, provenance: prov }); + if (!updated.ok) close(rec, false, true); + return updated; + } + function openNode(spec) { + if (!alive) return { ok: false, reason: 'unmounted' }; + const node = spec && spec.node; + if (!(node instanceof Node) || node.nodeType === Node.DOCUMENT_NODE) return refuse('openNode', 'openNode takes a node built by this page'); + const id = spec && typeof spec.id === 'string' && ID.test(spec.id) ? spec.id : `card${(serial += 1)}`; + const key = `card:${id}`; + let rec = panes.get(key); + if (!rec) { + if (panes.size >= MAX_PANES) return refuse('openNode', 'too many panes'); + rec = create(key, 'card', typeof spec.title === 'string' ? spec.title : 'Aien'); + } else if (typeof spec.title === 'string') { + rec.title = clean(spec.title, MAX_TITLE) || rec.title; + label(rec); + } + rec.body.replaceChildren(node); + restore(rec, spec.focus === true); + return { ok: true, id, close: () => close(rec, false) }; + } + function cycle(dir, from) { + const stops = [...panes.values()].filter(r => !r.minimized).map(r => r.el); + stops.push(dock); + const at = stops.findIndex(s => s.contains(from)); + const next = stops[(at + dir + stops.length) % stops.length]; + if (next === dock) (chips.querySelector('button') || projectsButton).focus(); + else next.focus({ preventScroll: true }); + } + function onKey(e) { + if (e.defaultPrevented || !alive) return; + if (e.key === 'Escape') { + const inside = root.contains(e.target); + const loose = e.target === document.body || e.target === document.documentElement || e.target === document; + if (!inside && !loose) return; + const rec = inside ? owner(e.target) : null; + const target = rec && !rec.minimized ? rec : topmost(); + if (!target) return; + e.preventDefault(); + minimize(target); + return; + } + if (e.key === 'F6' && root.contains(e.target)) { + e.preventDefault(); + cycle(e.shiftKey ? -1 : 1, e.target); + } + } + function destroy() { + if (!alive) return; + for (const rec of panes.values()) stopApp(rec); + alive = false; + document.removeEventListener('keydown', onKey); + window.removeEventListener('resize', onResize); + if (media) { + if (typeof media.removeEventListener === 'function') media.removeEventListener('change', layout); + else if (typeof media.removeListener === 'function') media.removeListener(layout); + } + if (fitting) cancelAnimationFrame(fitting); + root.remove(); + panes.clear(); + order = []; + closed.length = 0; + } + + document.addEventListener('keydown', onKey); + window.addEventListener('resize', onResize); + if (media) { + if (typeof media.addEventListener === 'function') media.addEventListener('change', layout); + else if (typeof media.addListener === 'function') media.addListener(layout); + } + layout(); + stack(); + return { event, open, openNode, project, destroy }; + } + + window.AllenPanes = Object.freeze({ version: VERSION, mount, check }); + window.dispatchEvent(new CustomEvent('allen-panes-ready', { detail: { version: VERSION } })); +})(); diff --git a/public/js/allen-presence.js b/public/js/allen-presence.js new file mode 100644 index 0000000..aa81a23 --- /dev/null +++ b/public/js/allen-presence.js @@ -0,0 +1,174 @@ +/* Generated from om/allen-presence/presence.om. */ +(() => { +'use strict'; +const root = document.getElementById('allen'); +const homeDoor = Boolean(root && root.closest('[data-home-door]')); +const reduced = matchMedia('(prefers-reduced-motion: reduce)'); +const byId = id => document.getElementById(id); +let scene = null, panes = null, subscribed = false, entered = false; +let reply = '', painted = 0, timer = 0, cardId = 0; +let resolveReady, rejectReady; +const ready = new Promise((resolve,reject) => { resolveReady=resolve; rejectReady=reject; }); +ready.catch(() => {}); +const dispose = []; +function status(text) { const node = byId('allen-status'); if (node) node.textContent = text; } +function showSession(open) { + const panel = byId('allen-session'), trigger = byId('allen-history'); + panel.hidden = !open; trigger.setAttribute('aria-expanded', String(open)); + if (open) { panel.tabIndex = -1; panel.focus(); } else trigger.focus(); +} +function paintReply() { + clearTimeout(timer); timer=0; + const out = byId('allen-answer'); + if (!out || document.hidden || painted >= reply.length) return; + if (reduced.matches) { painted=reply.length; out.textContent=reply; return; } + const letter=String.fromCodePoint(reply.codePointAt(painted)); + if (scene && !/\s/.test(letter) && (!painted || /\s/.test(reply[painted-1]))) scene.speak(letter); + const span=document.createElement('span'); span.className='allen-letter'; span.textContent=letter; out.append(span); + painted+=letter.length; + if (painted < reply.length) timer=setTimeout(paintReply,35); +} +function replaceReply(text, speaker) { + clearTimeout(timer); timer=0; reply=String(text); painted=0; + byId('allen-speaker').textContent=speaker; + const out=byId('allen-answer'); out.textContent=''; + if (speaker==='Aien') out.dataset.speaker='allen'; else delete out.dataset.speaker; + paintReply(); +} +function mountScene() { + if (!window.AllenScene || scene) return; + const canvas=byId('allen-universe'); + if (!canvas) return; + scene=window.AllenScene.mount(canvas,{compact:false,interactive:true,opening:homeDoor?'idle':'dusk'}); + window.allenPresenceScene=scene; + scene.ready.then(() => { + byId('allen-enter').disabled=false; resolveReady(scene); + document.dispatchEvent(new CustomEvent('allen-presence-ready')); + }, error => { rejectReady(error); byId('allen-enter').disabled=false; status('The scene could not load. You can still chat with Aien.'); }); +} +function mountPanes() { + if (!window.AllenPanes || panes) return; + panes=window.AllenPanes.mount(byId('allen-panes'),{}); +} +function enter(options={}) { + if (entered) return; entered=true; root.dataset.entered='true'; + byId('allen-arrival').hidden=true; + mountScene(); mountPanes(); + if (options.scene!==false && scene && !homeDoor) scene.enter('dusk'); + // Native dusk is silent. The home-door owner starts the merger chirp on a real gesture. + byId('allen-input').focus(); + const initial=byId('allen-log').querySelector('.allen-msg-allen .allen-p'); + if (!reply && initial) replaceReply(initial.textContent,'Aien'); +} +function audioLabel() { + const muted=window.AllenAudio ? window.AllenAudio.muted() : true; + const button=byId('allen-mute'); button.setAttribute('aria-pressed',String(muted)); button.textContent=muted?'Sound off':'Sound on'; +} +function connect() { + if (!root || !window.allen || subscribed) return; subscribed=true; + const api=window.allen; + byId('allen-log').setAttribute('aria-live','off'); + dispose.push(api.on('send',event => { + if (!entered) enter({scene:false}); + if (!event.silent) byId('allen-guest').textContent=event.text; + replaceReply('','Aien'); + if (scene) { scene.key(event.text); scene.mode('think'); } + byId('allen-regenerate').disabled=true; + })); + dispose.push(api.on('token',event => { reply+=event.text; if (!timer) paintReply(); })); + dispose.push(api.on('reply',event => { + if (!event.text.startsWith(reply.slice(0,painted))) replaceReply(event.text,'Aien'); + else { reply=event.text; if (!timer) paintReply(); } + byId('allen-regenerate').disabled=false; + if (scene) scene.mode('idle'); + })); + dispose.push(api.on('error',event => { status(event.message); byId('allen-regenerate').disabled=false; if (scene) scene.mode('idle'); })); + dispose.push(api.on('human',event => replaceReply(event.text,'Drake'))); + dispose.push(api.on('card',event => { + mountPanes(); + if (panes && panes.openNode) panes.openNode({id:'chat-'+(++cardId),title:event.type==='relay'?'Message to Drake':event.type==='introduce'?'Remember me':'Aien · '+event.type,node:event.node}); + else showSession(true); + })); + for (const name of ['pane.open','pane.update','pane.close']) dispose.push(api.on(name,event => { mountPanes(); if (panes) panes.event(name,event); })); + byId('allen-regenerate').addEventListener('click',() => api.regenerate()); + byId('allen-copy').addEventListener('click',async () => { + try { await navigator.clipboard.writeText(reply); status('Reply copied.'); } catch (_) { status('Clipboard unavailable. Select the reply to copy it.'); } + }); + byId('allen-introduce').addEventListener('click',() => showSession(true)); + byId('allen-new').addEventListener('click',() => { + byId('allen-guest').textContent=''; + const hello=byId('allen-log').querySelector('.allen-msg-allen .allen-p'); + replaceReply(hello?hello.textContent:'','Aien'); + }); +} +function full() { + window.allenPresence=Object.freeze({ready,enter,scene:() => scene,panes:() => panes}); + byId('allen-enter').disabled=true; + if (homeDoor) byId('allen-arrival').hidden=true; + mountScene(); mountPanes(); connect(); audioLabel(); + byId('allen-enter').addEventListener('click',() => enter()); + byId('allen-history').addEventListener('click',() => showSession(byId('allen-session').hidden)); + byId('allen-mute').addEventListener('click',() => { if (window.AllenAudio) { window.AllenAudio.setMuted(!window.AllenAudio.muted()); audioLabel(); } }); + byId('allen-projects').addEventListener('click',() => { mountPanes(); if (panes && panes.project) panes.project(); }); + const input=byId('allen-input'); + input.addEventListener('input',event => { + input.style.height='36px'; input.style.height=Math.min(120,input.scrollHeight)+'px'; + if (scene && event.data && !event.isComposing) scene.key(event.data); + }); + document.addEventListener('keydown',event => { + if (event.key==='Escape' && !byId('allen-session').hidden) { event.preventDefault(); showSession(false); } + if ((event.ctrlKey || event.metaKey) && event.key==='/') { event.preventDefault(); input.focus(); } + }); + document.addEventListener('visibilitychange',() => { if (!document.hidden && painted { if (reduced.matches) { clearTimeout(timer); timer=0; painted=reply.length; byId('allen-answer').textContent=reply; } }); + document.addEventListener('allen-ready',connect); + document.addEventListener('allen-scene-ready',mountScene); + document.addEventListener('allen-panes-ready',mountPanes); + window.addEventListener('pagehide',() => { clearTimeout(timer); for (const off of dispose) off(); if (scene) scene.destroy(); if (panes) panes.destroy(); if (window.AllenAudio) window.AllenAudio.stop(); },{once:true}); +} +if(root) { + let layoutFrame=0; + function layout() { + layoutFrame=0; + const viewport=window.visualViewport; + root.style.setProperty('--allen-view-height',(viewport?viewport.height:innerHeight)+'px'); + root.style.setProperty('--allen-view-top',(viewport?viewport.offsetTop:0)+'px'); + const bottom=root.querySelector('.allen-bottom'); + if(bottom) root.style.setProperty('--allen-panes-sheet-bottom',Math.max(0,root.getBoundingClientRect().bottom-bottom.getBoundingClientRect().top+8)+'px'); + } + function requestLayout() {if(!layoutFrame) layoutFrame=requestAnimationFrame(layout);} + window.addEventListener('resize',requestLayout); + if(window.visualViewport) {visualViewport.addEventListener('resize',requestLayout);visualViewport.addEventListener('scroll',requestLayout);} + const observer=new ResizeObserver(requestLayout); const bottom=root.querySelector('.allen-bottom');if(bottom)observer.observe(bottom); + document.addEventListener('allen-pane-request',event => { + const d=event.detail;mountPanes(); + if(!panes || !panes.openNode || !d || !(d.node instanceof Node))return; + const handle=panes.openNode({id:d.id,title:d.title,node:d.node,focus:false}); + if(handle) {event.preventDefault();d.handle=handle;} + }); + window.addEventListener('pagehide',() => {observer.disconnect();cancelAnimationFrame(layoutFrame);window.removeEventListener('resize',requestLayout);if(window.visualViewport){visualViewport.removeEventListener('resize',requestLayout);visualViewport.removeEventListener('scroll',requestLayout);}},{once:true}); + requestLayout(); +} +function compact() { + const launcher = byId('aien-allen-launcher'); + if (!launcher || !window.AllenScene) return; + const canvas = launcher.querySelector('canvas'); + const small = window.AllenScene.mount(canvas,{compact:true,interactive:false}); + const aside = byId('aien-allen-intro'); + function intro(event) { + if (event.detail.type === 'show' && window.aienAllenIntro) small.speak(window.aienAllenIntro.text.greeting); + if (event.detail.type === 'reply-no' && window.aienAllenIntro) small.speak(window.aienAllenIntro.text.afterNo); + } + document.addEventListener('aien-allen-intro',intro); + if (aside && !aside.hidden && window.aienAllenIntro) small.speak(window.aienAllenIntro.text.greeting); + launcher.addEventListener('click', event => { + if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || reduced.matches) return; + event.preventDefault(); + launcher.classList.add('allen-launch-enter'); + const finish = () => location.assign(launcher.href); + launcher.addEventListener('transitionend',finish,{once:true}); setTimeout(finish,450); + }); + window.addEventListener('pagehide', () => { small.destroy(); document.removeEventListener('aien-allen-intro',intro); }, {once:true}); +} +if (root) full(); else { compact(); if (!window.AllenScene) document.addEventListener('allen-scene-ready',compact,{once:true}); } +})(); diff --git a/public/js/allen-scene.js b/public/js/allen-scene.js new file mode 100644 index 0000000..d0287b3 --- /dev/null +++ b/public/js/allen-scene.js @@ -0,0 +1,339 @@ +/* Generated from om/allen-scene/scene.om by pinned seeded Omega. + * Controller: Omega-generated JavaScript. Rendering/audio: unchanged native C, + * aien-dev/aienux@da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c, compiled to WASM. + * This source pin was staged, not hardware-confirmed by the available report. + * Web opening reuses native dusk; enter('birth') is the original binary merger. + * Catalogue/licences and native dependency boundary: om/allen-scene/provenance.txt. + * WolframLanguageEvaluator: 1000/60 -> 50/3 ms; (1000/60)/2 -> 25/3 ms; + * 48000 (12300-11360)/1000 -> 45120 frames (native chirp non-silent window). + */ +(() => { + 'use strict'; + const PIN = 'da55660ea7337f2b6a42095fcd1fb6ddebe1cc7c'; + const mounted = new WeakMap(); + let compiled; + function module() { + if (!compiled) compiled = fetch('/allen/scene.wasm', {credentials:'omit'}) + .then(response => { if (!response.ok) throw new Error('Native scene unavailable'); return response.arrayBuffer(); }) + .then(bytes => WebAssembly.compile(bytes)).catch(error => { compiled = null; throw error; }); + return compiled; + } + function mount(canvas, options = {}) { + if (!(canvas instanceof HTMLCanvasElement)) throw new TypeError('AllenScene requires a canvas'); + if (mounted.has(canvas)) return mounted.get(canvas); + const compact = Boolean(options.compact), interactive = Boolean(options.interactive) && !compact; + const opening = options.opening === undefined ? (compact ? 'idle' : 'dusk') : options.opening; + if(opening !== 'idle' && opening !== 'dusk' && opening !== 'birth') throw new RangeError('Invalid Allen scene opening'); + const ctx = canvas.getContext('2d', {alpha:false}); + if (!ctx) throw new Error('Canvas rendering unavailable'); + const motion = matchMedia('(prefers-reduced-motion: reduce)'); + const cleanup = [], letters = Array.from({length:64}, () => ({char:0,start:0,slot:0})); + const wordTimes = new Float64Array(256); + let ex, image, width = 0, height = 0, disposed = false, failed = false; + let raf = 0, lastWall = 0, clock = 20000, kind = 0, modeValue = 0; + let visible = true, reduced = motion.matches, dirty = true, resizePending = true; + const connection = typeof navigator === 'object' ? navigator.connection : null; + let calm = options.calm === undefined ? Boolean(connection && connection.saveData) : Boolean(options.calm); + let quality = 0, overBudget = 0, underBudget = 0, qualityHold = 0, samples = 0; + const renderScales = [1, 3/4, 9/16, 9/16]; + const qualityNames = ['full-60','balanced-60','small-60','small-30']; + const frameBudget = 1000/60; + // Wolfram: 1000/60 -> 50/3 ms; budget/2 -> 25/3; 1280*{1,3/4,9/16} -> {1280,960,720}. + function still() { return reduced || compact || calm; } + function qualityLabel() { canvas.dataset.sceneQuality = reduced ? 'reduced' : compact ? 'compact' : calm ? 'calm' : qualityNames[quality]; } + function measureDraw(cost) { + samples++; + if(samples % 60 === 0) canvas.dataset.sceneDrawMs=String(cost); + if(qualityHold) { qualityHold--; return; } + overBudget=cost>frameBudget?overBudget+1:0; + underBudget=cost=8?Math.min(3,quality+1):underBudget>=180?Math.max(0,quality-1):quality; + if(next!==quality) { + quality=next;qualityHold=60;overBudget=underBudget=0; + resizePending=dirty=true;canvas.dataset.sceneDrawMs=String(cost);qualityLabel(); + } + } + let letterHead = 0, wordRead = 0, wordWrite = 0, lastWord = -1000, speakUntil = 0, keyUntil = 0; + let ra = 113697000, dec = -72757000, fov = 80000, viewPending = false; + let dragId = null, dragX = 0, dragY = 0, pinchDistance = 0; + const touches = [{id:null,x:0,y:0},{id:null,x:0,y:0}]; + let ownsAudio = false, completeSent = false, resolveSize, rejectSize; + let pendingEnter = compact || opening === 'idle' ? 0 : opening === 'birth' ? 2 : 1, pendingStatic = false; + canvas.dataset.sceneSource = PIN; + canvas.dataset.sceneEngine = 'loading'; + qualityLabel(); + function listen(target, name, fn, opts) { + target.addEventListener(name, fn, opts); + cleanup.push(() => target.removeEventListener(name, fn, opts)); + } + function stopAudio() { + if (ownsAudio && window.AllenAudio) window.AllenAudio.stop(); + ownsAudio=false; + } + function awake() { return !disposed && !failed && !document.hidden && visible; } + function request() { + if (!raf && ex && awake() && (!still() || dirty)) raf = requestAnimationFrame(tick); + } + function size() { + const box = canvas.getBoundingClientRect(); + if (box.width <= 0 || box.height <= 0) return false; + // Policy bound, not a physical-resolution claim. Same aspect ratio, native design scaling. + const scale = Math.min(devicePixelRatio || 1, 1280 / Math.max(box.width,box.height))*renderScales[quality]; + const w = Math.max(64,Math.round(box.width*scale)), h = Math.max(64,Math.round(box.height*scale)); + resizePending = false; + if (w === width && h === height) return true; + width=w; height=h; canvas.width=w; canvas.height=h; + if (!ex.scene_init(w,h,compact?1:0)) throw new Error('Native scene size refused'); + image = new ImageData(new Uint8ClampedArray(ex.memory.buffer,ex.scene_pixels(),w*h*4),w,h); + ex.scene_enter(kind); + // Resize keeps phase and mode but does not manufacture the old frame history. + ex.scene_step(Math.floor(clock),modeValue,0); + viewPending=true; + if(resolveSize) {resolveSize();resolveSize=null;rejectSize=null;} + return true; + } + function reset(kindValue) { + kind=kindValue; clock=kind===0?20000:0; lastWall=0;completeSent=false; + wordRead=wordWrite=0; lastWord=-1000; speakUntil=keyUntil=0; modeValue=0; + for (const letter of letters) letter.char=0; + stopAudio(); + if (ex && width) ex.scene_enter(kind); + dirty=true; request(); + } + function render() { + if (!ex || !awake()) return; + if (resizePending && !size()) return; + if (!image) return; + if (viewPending && !(kind===1 && clock<4200)) { + if (!ex.scene_view(Math.round(ra),Math.round(dec),Math.round(fov))) throw new Error('Native sky view refused'); + viewPending=false; + } + const time=Math.floor(clock); + while(wordRead!==wordWrite && wordTimes[wordRead]<=clock) { + lastWord=wordTimes[wordRead];ex.scene_word(Math.floor(lastWord));wordRead=(wordRead+1)%wordTimes.length; + } + let currentMode=modeValue; + if(clock=0?ex.scene_voice(time,Math.floor(lastWord)):0; + const shimmer=clock=1) {letter.char=0;continue;} + // Web enhancement: native glyphs lift from input to Allen. No HTML/text injection. + const ease=1-(1-u)*(1-u)*(1-u); + const x=width/2+(letter.slot-4)*width/90*(1-ease); + const y=height*(0.86+(0.4-0.86)*ease); + ex.scene_glyph(letter.char,Math.round(x),Math.round(y),Math.round(256*(1-u))); + } + ctx.putImageData(image,0,0); + canvas.dataset.scenePhase=kind===1 && clock<4200?'tube':kind===2 && clock<12300?'merger':clock<(kind===1?7200:15300)?'forming':'presence'; + canvas.dataset.sceneTime=String(time); + canvas.dataset.sceneEngine='native-wasm'; + dirty=false; + if(!completeSent && (kind===0 || clock>=(kind===1?7200:15300))) { + completeSent=true; + canvas.dispatchEvent(new CustomEvent('allen-scene-complete',{bubbles:true,detail:{kind:kind===2?'birth':kind===1?'dusk':'idle',time}})); + } + return true; + } + function error(err) { + failed=true;cancelAnimationFrame(raf);raf=0;stopAudio(); + if(rejectSize) {rejectSize(err);resolveSize=null;rejectSize=null;} + canvas.dataset.sceneEngine='unavailable'; + canvas.dispatchEvent(new CustomEvent('allen-scene-error',{bubbles:true,detail:{message:String(err.message||err)}})); + } + function tick(wall) { + raf=0; + if(!awake()) {lastWall=0;return;} + const dt=lastWall?wall-lastWall:0; + // Lowest level skips alternate 60 Hz callbacks; 25 ms tolerates timestamp jitter around 50/3 and 100/3 ms. + if(!still() && quality===3 && dt<25 && !dirty) {request();return;} + lastWall=wall; + if(!still()) clock+=dt; // source clock advances; native integrators bound their own catch-up + const sample=!still() && !resizePending && !viewPending; + const began=sample?performance.now():0; + let drawn=false; + try { drawn=render(); } catch(err) { error(err); } + if(sample && drawn) measureDraw(performance.now()-began); + if(drawn && !still()) request(); + } + function motionChanged() { + reduced=motion.matches;lastWall=0;cancelAnimationFrame(raf);raf=0;stopAudio(); + if(still()) { reset(0); pendingStatic=true; } + overBudget=underBudget=0;qualityLabel(); + dirty=true;request(); + } + function visibility() { + lastWall=0; + if(!awake()) {cancelAnimationFrame(raf);raf=0;if(ownsAudio && window.AllenAudio) window.AllenAudio.pause();} + else {if(ownsAudio && !still() && window.AllenAudio) void window.AllenAudio.resume();overBudget=underBudget=0;dirty=true;request();} + } + function changeView(dx,dy,zoom) { + if(!interactive || kind===1 && clock<4200) return; + ra=((ra+dx)%360000000+360000000)%360000000; + dec=Math.max(-89000000,Math.min(89000000,dec+dy)); + fov=Math.max(10000,Math.min(120000,fov*zoom)); + viewPending=dirty=true;request(); + } + function home() {ra=113697000;dec=-72757000;fov=80000;viewPending=dirty=true;request();} + const api = { + key(text) { + if(disposed) return; + text=String(text).slice(-64);keyUntil=clock+4000; + if(ex) ex.scene_key(Math.floor(clock)); + if(!reduced && !compact) for(let i=0;i126) continue; + const letter=letters[letterHead];letterHead=(letterHead+1)%letters.length; + letter.char=c;letter.start=clock+i*35;letter.slot=i%9; + } + dirty=true;request(); + }, + speak(text) { + if(disposed) return; + text=String(text).slice(0,4096); + let offset=0;const start=Math.max(clock,speakUntil-300); + for(let i=0;i86400000) throw new RangeError('Scene time outside one day'); + cancelAnimationFrame(raf);raf=0;lastWall=0; + if(reduced) clock=20000;else clock=ms; + dirty=true; + if(ex) {try {render();} catch(err) {error(err);}} + }, + destroy() { + if(disposed) return; + disposed=true;cancelAnimationFrame(raf);raf=0;stopAudio(); + if(rejectSize) {rejectSize(new Error('Scene destroyed before initialization'));resolveSize=null;rejectSize=null;} + for(const fn of cleanup) fn(); + mounted.delete(canvas);image=null;ex=null; + canvas.dataset.sceneEngine='destroyed'; + } + }; + mounted.set(canvas,api); + listen(document,'visibilitychange',visibility); + listen(motion,'change',motionChanged); + if(typeof ResizeObserver==='function') { + const resize=new ResizeObserver(() => {resizePending=dirty=true;request();});resize.observe(canvas);cleanup.push(() => resize.disconnect()); + } else listen(window,'resize',() => {resizePending=dirty=true;request();}); + if(typeof IntersectionObserver==='function') { + const observer=new IntersectionObserver(entries => {visible=entries[0].isIntersecting;visibility();});observer.observe(canvas);cleanup.push(() => observer.disconnect()); + } + if(interactive) { + const oldTouch=canvas.style.touchAction;canvas.style.touchAction='pinch-zoom';cleanup.push(() => {canvas.style.touchAction=oldTouch;}); + listen(canvas,'pointerdown',event => { + if(event.button!==0) return; + if(event.pointerType==='touch') { + const slot=touches.find(touch => touch.id===null); + if(!slot) return; + slot.id=event.pointerId;slot.x=event.clientX;slot.y=event.clientY; + if(touches[0].id!==null && touches[1].id!==null) pinchDistance=Math.hypot(touches[0].x-touches[1].x,touches[0].y-touches[1].y); + } + dragId=event.pointerId;dragX=event.clientX;dragY=event.clientY; + canvas.setPointerCapture(dragId);canvas.focus({preventScroll:true}); + }); + listen(canvas,'pointermove',event => { + if(event.pointerType==='touch') { + const touch=touches.find(touch => touch.id===event.pointerId); + if(!touch) return; + touch.x=event.clientX;touch.y=event.clientY; + if(touches[0].id!==null && touches[1].id!==null) { + const distance=Math.hypot(touches[0].x-touches[1].x,touches[0].y-touches[1].y); + if(distance>0 && pinchDistance>0) changeView(0,0,pinchDistance/distance); + pinchDistance=distance;return; + } + } + if(event.pointerId!==dragId) return; + const box=canvas.getBoundingClientRect(); + changeView(-(event.clientX-dragX)*fov*1000/Math.max(1,box.width),(event.clientY-dragY)*fov*1000/Math.max(1,box.width),1); + dragX=event.clientX;dragY=event.clientY; + }); + const release=event => { + for(const touch of touches) if(touch.id===event.pointerId) touch.id=null; + pinchDistance=0; + if(event.pointerId===dragId) { + dragId=null; + if(canvas.hasPointerCapture(event.pointerId)) canvas.releasePointerCapture(event.pointerId); + const remaining=touches.find(touch => touch.id!==null); + if(remaining) {dragId=remaining.id;dragX=remaining.x;dragY=remaining.y;} + } + }; + listen(canvas,'pointerup',release);listen(canvas,'pointercancel',release);listen(canvas,'lostpointercapture',release); + listen(canvas,'wheel',event => {if(event.ctrlKey || event.metaKey) return;event.preventDefault();changeView(0,0,Math.pow(2,Math.max(-600,Math.min(600,event.deltaY))/600));},{passive:false}); + listen(canvas,'keydown',event => { + const step=fov*1000/20; + switch(event.key) { + case 'ArrowLeft':changeView(-step,0,1);break; + case 'ArrowRight':changeView(step,0,1);break; + case 'ArrowUp':changeView(0,step,1);break; + case 'ArrowDown':changeView(0,-step,1);break; + case '+':case '=':changeView(0,0,1/1.1);break; + case '-':changeView(0,0,1.1);break; + case 'Home':home();break; + default:return; + } + event.preventDefault(); + }); + } + api.ready=module().then(module => WebAssembly.instantiate(module,{})).then(async instance => { + if(disposed) return api; + ex=instance.exports; + const initial=still()?0:pendingEnter===null?0:pendingEnter; + // Preserve an audio gesture made before compilation completes. + const audioOwner=ownsAudio;ownsAudio=false;reset(initial);ownsAudio=audioOwner; + pendingEnter=null; + if(!size()) await new Promise((resolve,reject) => {resolveSize=resolve;rejectSize=reject;}); + if(disposed) return api; + if(still() || pendingStatic) {clock=20000;ex.scene_step(20000,0,0);pendingStatic=false;} + render();request(); + canvas.dispatchEvent(new CustomEvent('allen-scene-initialized',{bubbles:true,detail:{source:PIN}})); + return api; + }).catch(err => {if(!disposed) error(err);throw err;}); + // Expose the rejection to callers while avoiding an unhandled rejection for decorative mounts. + api.ready.catch(() => {}); + return api; + } + window.AllenScene=Object.freeze({mount,source:PIN}); + document.dispatchEvent(new CustomEvent('allen-scene-ready')); +})(); diff --git a/public/js/allen-voice.js b/public/js/allen-voice.js new file mode 100644 index 0000000..0e50316 --- /dev/null +++ b/public/js/allen-voice.js @@ -0,0 +1,778 @@ +/* Allen voice: speech typing into the message box, and replies read aloud. + * + * Generated by om/allen-voice/voice.om; never hand-edit. Element ids, limits + * and every visible sentence come from the vcfg table in voice.om. + * + * Speech typing. The microphone is touched only after a tap on the mic + * button: nothing here asks for it, or for any permission, when the page + * loads. Recognized words go into the message box as editable text, with an + * input event, and are never sent: the visitor presses Send. The privacy note + * says where the audio goes before the first tap. Three engines, chosen + * before any tap: the browser's on-device recognizer when it reports one + * installed for the language (processLocally set; the audio stays here); + * else Allen's server when the gateway's presence says transcribe is true + * (one clip per tap, POSTed once, Safari's MP4 turned into 16 kHz WAV here); + * else the browser's online speech service (Chrome sends audio to Google). + * A server failure never retries elsewhere: the browser's recognition is + * offered as a button, with its own note, and needs another tap. + * + * Replies read aloud. Off unless the visitor turns it on; the choice (on or + * off, nothing else) is the only thing kept, in local storage. Uses the + * browser's speech synthesis, never a recording of anyone. Allen's replies are + * read as they are; a message Drake typed himself is read after the words + * "Drake wrote:" so a synthetic voice is never taken for either of them. + * Speech stops on a new request, a mic tap, turning it off, or when the page + * is hidden. No transcript and no audio is stored or sent by this file. + */ +(() => { + 'use strict'; + const byId = id => document.getElementById(id); + const input = byId('allen-input'); + const mic = byId('allen-mic'); + const privacy = byId('allen-voice-privacy'); + const toggle = byId('allen-speak'); + if (!input || (!mic && !toggle)) return; + const STORE = 'allen-voice-speak'; + const SPEAK_MAX = 4000; + const CHUNK = 200; + const PRESENCE = '/allen/api/presence'; + const ENDPOINT = '/allen/api/transcribe'; + const MAX_BYTES = 1048576; + const MAX_MS = 15000; + const MIN_MS = 300; + const RATE = 16000; + const COPY = Object.freeze({ + cloud: "Voice typing uses your browser's online speech service: in Chrome your audio goes to Google's servers to become text, and other browsers may send it to their maker. My site never receives your audio, only the words you choose to send.", + local: "Voice typing runs on this device: your browser turns speech into text here and your audio does not leave it. Only the words you choose to send reach Aien.", + none: "Voice typing isn't available in this browser. You can still type your message.", + insecure: "Voice typing needs the secure https page. You can still type your message.", + start: "Start voice typing", + stop: "Stop voice typing", + starting: "Starting. Your browser may ask to use the microphone.", + listening: "Listening. Speak, then tap the microphone again to stop, or press Escape to cancel.", + done: "Done. Your words are in the message box: check them, then press Send.", + nothing: "No words came through. Tap the microphone to try again.", + cancelled: "Cancelled. The message box is back as it was.", + blocked: "The microphone is blocked for this site. Allow it in your browser's site settings, or type instead.", + nomic: "No microphone was found. You can type instead.", + network: "Your browser's speech service could not be reached. Check your connection, or type instead.", + lang: "Voice typing doesn't support this page's language in your browser.", + failed: "Voice typing stopped with an error. You can type instead.", + fallback: "On-device voice typing isn't ready in this browser, so it would use the online speech service. Read the privacy note, then tap the microphone again if that's fine.", + hidden: "Voice typing stopped because the page went to the background.", + typed: "Voice typing stopped because you started typing.", + noSpeak: "Reading replies aloud isn't available in this browser.", + speakOn: "Aien's replies will be read aloud by your browser's voice.", + speakOff: "Replies are no longer read aloud.", + remote: "Your browser lists no on-device voice for this language, so it may send reply text to its online voice service.", + drake: "Drake wrote:", + code: "(code block skipped)", + link: "link", + rest: "The rest is on the screen.", + server: "Voice typing records only after you tap the microphone, for up to 15 seconds. Your clip is sent to Aien's server, turned into text, and never saved: it stays in memory only and is discarded as soon as the text comes back. The text is shown to you; it is not logged.", + recording: "Recording. Tap the microphone again when you finish, or press Escape to cancel.", + sending: "Turning your words into text.", + short: "That clip was too short. Tap the microphone and speak a little longer.", + toolong: "That clip was too long for Aien's server. Try a shorter one.", + format: "Aien's server could not read this browser's audio format.", + unclear: "Aien's server could not make out any words in that clip.", + rate: "Aien's server is taking too many clips right now.", + retry: "Try again in", + busy: "Aien's server is busy right now. Try again in a moment.", + offer: "Use your browser's speech service instead", + switched: "Switched to your browser's speech service. Read the privacy note, then tap the microphone if that's fine.", + serverdown: "Aien's server could not be reached. Check your connection, or type instead.", + }); + + function lang() { + const page = document.documentElement && document.documentElement.lang; + const nav = window.navigator && window.navigator.language; + return String(page || nav || 'en-US'); + } + + /* One live region for both halves; made here when the page has none. */ + let status = byId('allen-voice-status'); + if (!status) { + status = document.createElement('p'); + status.id = 'allen-voice-status'; + status.className = 'allen-voice-status'; + const after = privacy || mic || toggle; + if (after.parentNode) after.parentNode.insertBefore(status, after.nextSibling); + } + status.setAttribute('role', 'status'); + status.setAttribute('aria-live', 'polite'); + function say(text) { + if (status.textContent !== text) status.textContent = text; + } + + /* Speech typing. */ + const Recognition = typeof window.SpeechRecognition === 'function' ? window.SpeechRecognition + : typeof window.webkitSpeechRecognition === 'function' ? window.webkitSpeechRecognition : null; + const secure = window.isSecureContext === true; + const canLocal = !!Recognition && Recognition === window.SpeechRecognition + && typeof Recognition.available === 'function' && 'processLocally' in Recognition.prototype; + let mode = !Recognition ? 'none' : !secure ? 'insecure' : 'cloud'; + let browserMode = mode; + let rec = null; + let clip = null; + let state = 'idle'; + let base = ''; + let wrote = null; + let writing = false; + let heard = false; + let ending = ''; + + function showPrivacy() { + if (privacy) privacy.textContent = COPY[mode]; + if (!mic) return; + const off = mode === 'none' || mode === 'insecure'; + mic.disabled = off; + mic.setAttribute('aria-disabled', off ? 'true' : 'false'); + mic.dataset.voice = mode; + const described = [privacy && privacy.id, status.id].filter(Boolean).join(' '); + if (described) mic.setAttribute('aria-describedby', described); + } + function setState(next, message) { + state = next; + if (mic) { + const live = next !== 'idle'; + mic.dataset.state = next; + mic.setAttribute('aria-pressed', live ? 'true' : 'false'); + mic.setAttribute('aria-label', live ? COPY.stop : COPY.start); + mic.title = live ? COPY.stop : COPY.start; + } + if (message !== undefined) say(message); + } + + /* Only an installed on-device recognizer counts as on device. */ + async function probeLocal() { + if (!canLocal || mode !== 'cloud') return false; + try { + return (await Recognition.available({ langs: [lang()], processLocally: true })) === 'available'; + } catch (_) { + return false; + } + } + /* Allen's server is used only when the gateway's presence says transcribe is + true and this browser can record after a tap; nothing is recorded to find + out. An absent or false field keeps the browser's own recognition. */ + function canRecord() { + const media = window.navigator && window.navigator.mediaDevices; + return secure && !!media && typeof media.getUserMedia === 'function' && typeof window.MediaRecorder === 'function' + && (!!opusType() || typeof (window.AudioContext || window.webkitAudioContext) === 'function'); + } + async function probeServer() { + if (!canRecord() || typeof window.fetch !== 'function') return false; + try { + const response = await window.fetch(PRESENCE, { cache: 'no-store', credentials: 'omit', headers: { Accept: 'application/json' } }); + const reply = response.ok ? await response.json() : null; + return !!reply && typeof reply === 'object' && reply.transcribe === true; + } catch (_) { + return false; + } + } + /* On device first (the audio stays here), then Allen's server, then the + browser's online service. Decided once, before any tap is needed. */ + async function probe() { + const [local, server] = await Promise.all([probeLocal(), probeServer()]); + if (rec || clip || state !== 'idle') return; + if (local) browserMode = 'local'; + const next = local ? 'local' : server ? 'server' : mode; + if (next === mode) return; + mode = next; + showPrivacy(); + say(''); + } + + function joined(text) { + const said = String(text).replace(/\s+/g, ' ').trim(); + if (!said) return base; + const gap = base && !/\s$/.test(base) ? ' ' : ''; + let value = base + gap + said; + const max = input.maxLength; + if (max > 0 && value.length > max) value = value.slice(0, max); + return value; + } + function write(value) { + if (input.value === value) return; + writing = true; + input.value = value; + wrote = value; + try { + input.setSelectionRange(value.length, value.length); + } catch (_) { + /* Some input types have no selection. */ + } + input.dispatchEvent(new Event('input', { bubbles: true })); + writing = false; + } + + const ERRORS = Object.freeze({ + 'not-allowed': 'blocked', + 'service-not-allowed': 'blocked', + 'audio-capture': 'nomic', + network: 'network', + 'language-not-supported': 'lang', + 'no-speech': 'nothing', + }); + + function startBrowser() { + if (!Recognition || (mode !== 'cloud' && mode !== 'local') || rec) return; + stopSpeaking(); + const r = new Recognition(); + r.lang = lang(); + r.continuous = false; + r.interimResults = true; + r.maxAlternatives = 1; + if (mode === 'local') r.processLocally = true; + base = input.value; + wrote = null; + heard = false; + ending = ''; + r.onaudiostart = () => { + if (rec === r && state === 'starting') setState('listening', COPY.listening); + }; + r.onstart = r.onaudiostart; + r.onresult = event => { + if (rec !== r || ending) return; + let text = ''; + for (let i = 0; i < event.results.length; i += 1) { + const best = event.results[i] && event.results[i][0]; + if (best && typeof best.transcript === 'string') text += best.transcript; + } + if (text.trim()) heard = true; + write(joined(text)); + }; + r.onerror = event => { + if (rec !== r) return; + const code = event && typeof event.error === 'string' ? event.error : ''; + if (code === 'aborted') return; + if (mode === 'local' && (code === 'language-not-supported' || code === 'service-not-allowed')) { + mode = 'cloud'; + browserMode = 'cloud'; + showPrivacy(); + ending = ending || 'fallback'; + return; + } + ending = ending || ERRORS[code] || 'failed'; + }; + r.onend = () => { + if (rec !== r) return; + rec = null; + if (ending === 'cancelled') write(base); + const said = ending ? COPY[ending] : heard ? COPY.done : COPY.nothing; + setState('idle', said); + }; + rec = r; + setState('starting', COPY.starting); + try { + r.start(); + } catch (_) { + rec = null; + setState('idle', COPY.failed); + } + } + function stop() { + if (!rec) return; + if (state === 'stopping') { + rec.abort(); + return; + } + setState('stopping'); + rec.stop(); + } + function end(why) { + if (clip) { + dropClip(why); + return; + } + if (!rec) return; + ending = why; + setState('stopping'); + rec.abort(); + } + + /* Allen's server. One clip per tap, recorded only between the taps, held in + memory, sent once to ENDPOINT and never anywhere else. A refused or failed + clip is dropped; the browser's own recognition is only offered, as a + button, and the visitor has to tap the microphone again after reading + its privacy note. */ + function opusType() { + const MR = window.MediaRecorder; + if (typeof MR !== 'function' || typeof MR.isTypeSupported !== 'function') return ''; + for (const type of ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus']) { + try { + if (MR.isTypeSupported(type)) return type; + } catch (_) { + /* Try the next type. */ + } + } + return ''; + } + function now() { + return window.performance && typeof window.performance.now === 'function' ? window.performance.now() : Date.now(); + } + function release(c) { + if (c.timer) window.clearTimeout(c.timer); + c.timer = 0; + if (c.stream) { + for (const track of c.stream.getTracks()) track.stop(); + } + c.stream = null; + } + function dropClip(why) { + const c = clip; + clip = null; + c.dropped = true; + if (c.controller) c.controller.abort(); + if (c.recorder && c.recorder.state !== 'inactive') { + try { + c.recorder.stop(); + } catch (_) { + /* Already stopped. */ + } + } + release(c); + c.chunks = []; + setState('idle', COPY[why] || COPY.cancelled); + } + function done(c, said) { + if (clip === c) clip = null; + setState('idle', said); + } + async function startServer() { + stopSpeaking(); + const c = { stream: null, recorder: null, chunks: [], mime: '', began: 0, ms: 0, timer: 0, controller: null, dropped: false }; + clip = c; + hideOffer(); + setState('starting', COPY.starting); + let stream = null; + try { + stream = await window.navigator.mediaDevices.getUserMedia({ audio: { channelCount: 1, echoCancellation: true, noiseSuppression: true } }); + } catch (error) { + if (clip !== c) return; + const name = error && error.name; + done(c, name === 'NotAllowedError' || name === 'SecurityError' ? COPY.blocked : name === 'NotFoundError' || name === 'OverconstrainedError' ? COPY.nomic : COPY.failed); + return; + } + c.stream = stream; + if (clip !== c) { + release(c); + return; + } + c.mime = opusType(); + try { + c.recorder = c.mime ? new window.MediaRecorder(stream, { mimeType: c.mime, audioBitsPerSecond: 32000 }) : new window.MediaRecorder(stream); + c.recorder.ondataavailable = event => { + if (event.data && event.data.size) c.chunks.push(event.data); + }; + c.recorder.onstop = () => { + finishClip(c); + }; + c.recorder.start(); + } catch (_) { + release(c); + done(c, COPY.failed); + return; + } + c.began = now(); + c.timer = window.setTimeout(() => { + if (clip === c && state === 'listening') stopClip(); + }, MAX_MS); + setState('listening', COPY.recording); + } + function stopClip() { + const c = clip; + if (!c || !c.recorder) return; + c.ms = now() - c.began; + setState('sending', COPY.sending); + try { + c.recorder.stop(); + } catch (_) { + release(c); + done(c, COPY.failed); + } + } + async function finishClip(c) { + release(c); + if (clip !== c || c.dropped) return; + const type = c.mime || (c.chunks[0] && c.chunks[0].type) || ''; + const recorded = new Blob(c.chunks, { type }); + c.chunks = []; + if (c.ms < MIN_MS || !recorded.size) { + done(c, COPY.short); + return; + } + let body = recorded; + let sent = c.mime; + if (!sent) { + let samples = null; + try { + samples = await decodeMono(recorded); + } catch (_) { + samples = null; + } + if (clip !== c) return; + if (!samples) { + done(c, COPY.format); + return; + } + const pcm = resample(samples.data, samples.rate); + if (pcm.length * 1000 < MIN_MS * RATE) { + done(c, COPY.short); + return; + } + body = new Blob([wav(pcm)], { type: 'audio/wav' }); + sent = 'audio/wav'; + } + if (body.size > MAX_BYTES) { + done(c, COPY.toolong); + return; + } + upload(c, body, sent); + } + async function upload(c, body, type) { + c.controller = new AbortController(); + let response = null; + let reply = null; + try { + response = await window.fetch(ENDPOINT, { method: 'POST', headers: { 'Content-Type': type, Accept: 'application/json' }, body, cache: 'no-store', credentials: 'omit', signal: c.controller.signal }); + reply = await response.json().catch(() => null); + } catch (_) { + if (clip !== c) return; + offerBrowser(); + done(c, COPY.serverdown); + return; + } + if (clip !== c) return; + if (response.ok && reply && typeof reply.text === 'string') { + const said = reply.text.trim(); + if (!said) { + done(c, COPY.unclear); + return; + } + base = input.value; + write(joined(said)); + done(c, COPY.done); + return; + } + offerBrowser(); + done(c, refused(response, reply)); + } + function refused(response, reply) { + const code = response.status; + if (code === 413) return COPY.toolong; + if (code === 415) return COPY.format; + if (code === 422) return COPY.unclear; + if (code === 503) return COPY.busy; + if (code === 429) { + const header = Number.parseInt(response.headers && response.headers.get ? response.headers.get('Retry-After') || '' : '', 10); + const field = reply && Number.isSafeInteger(reply.retry_after) ? reply.retry_after : NaN; + const wait = Number.isSafeInteger(header) && header > 0 ? header : field > 0 ? field : 0; + return wait && wait <= 3600 ? `${COPY.rate} ${COPY.retry} ${wait} s.` : COPY.rate; + } + return COPY.failed; + } + + /* Safari records only AAC in MP4, which the gateway refuses: the clip is + decoded here, mixed to mono, resampled to RATE and sent as 16-bit PCM WAV. */ + function decodeMono(blob) { + const Ctx = window.AudioContext || window.webkitAudioContext; + if (typeof Ctx !== 'function') return Promise.reject(new Error('no audio context')); + return blob.arrayBuffer().then(data => { + const ctx = new Ctx(); + const closed = () => { + if (typeof ctx.close === 'function') ctx.close().catch(() => {}); + }; + return new Promise((ok, bad) => { + const pending = ctx.decodeAudioData(data, ok, bad); + if (pending && typeof pending.then === 'function') pending.then(ok, bad); + }).then(buffer => { + closed(); + const channels = Math.max(1, buffer.numberOfChannels | 0); + const out = new Float32Array(buffer.length); + for (let ch = 0; ch < channels; ch += 1) { + const part = buffer.getChannelData(ch); + for (let i = 0; i < out.length; i += 1) out[i] += part[i] / channels; + } + return { data: out, rate: buffer.sampleRate }; + }, error => { + closed(); + throw error; + }); + }); + } + /* Down: each output sample is the mean of the input span it covers (a box + filter weighted by overlap). Up: linear interpolation. */ + function resample(data, rate) { + if (!(rate > 0) || rate === RATE) return Float32Array.from(data); + const ratio = rate / RATE; + const n = Math.floor(data.length / ratio); + const out = new Float32Array(n); + if (ratio < 1) { + for (let i = 0; i < n; i += 1) { + const at = i * ratio; + const k = Math.floor(at); + const next = k + 1 < data.length ? data[k + 1] : data[k]; + out[i] = data[k] + (next - data[k]) * (at - k); + } + return out; + } + for (let i = 0; i < n; i += 1) { + const from = i * ratio; + const to = from + ratio; + let sum = 0; + for (let k = Math.floor(from); k < to && k < data.length; k += 1) { + sum += data[k] * (Math.min(to, k + 1) - Math.max(from, k)); + } + out[i] = sum / ratio; + } + return out; + } + /* RIFF WAVE, PCM format 1, one channel, RATE hertz, 16 bits, little-endian; + samples clamped to -1..1, negative scaled by 32768, positive by 32767. */ + function wav(samples) { + const bytes = samples.length * 2; + const view = new DataView(new ArrayBuffer(44 + bytes)); + const tag = (at, text) => { + for (let i = 0; i < 4; i += 1) view.setUint8(at + i, text.charCodeAt(i)); + }; + tag(0, 'RIFF'); + view.setUint32(4, 36 + bytes, true); + tag(8, 'WAVE'); + tag(12, 'fmt '); + view.setUint32(16, 16, true); + view.setUint16(20, 1, true); + view.setUint16(22, 1, true); + view.setUint32(24, RATE, true); + view.setUint32(28, RATE * 2, true); + view.setUint16(32, 2, true); + view.setUint16(34, 16, true); + tag(36, 'data'); + view.setUint32(40, bytes, true); + for (let i = 0; i < samples.length; i += 1) { + const s = Math.max(-1, Math.min(1, samples[i] || 0)); + view.setInt16(44 + i * 2, s < 0 ? Math.round(s * 32768) : Math.round(s * 32767), true); + } + return view.buffer; + } + + /* The browser's own recognition, offered after Allen's server failed. */ + let offer = null; + function offerBrowser() { + if (!Recognition || !secure || !mic) return; + if (!offer) { + offer = document.createElement('button'); + offer.type = 'button'; + offer.id = 'allen-voice-browser'; + offer.className = 'allen-tool allen-voice-browser'; + offer.textContent = COPY.offer; + offer.addEventListener('click', () => { + if (state !== 'idle') return; + mode = browserMode; + hideOffer(); + showPrivacy(); + say(COPY.switched); + }); + if (status.parentNode) status.parentNode.insertBefore(offer, status.nextSibling); + } + offer.hidden = false; + } + function hideOffer() { + if (offer) offer.hidden = true; + } + + if (mic) { + showPrivacy(); + setState('idle'); + if (mode === 'none' || mode === 'insecure') say(COPY[mode]); + mic.addEventListener('click', event => { + event.preventDefault(); + if (state === 'idle') { + if (mode === 'server') startServer(); + else startBrowser(); + } else if (clip && state === 'listening') stopClip(); + else if (clip) dropClip('cancelled'); + else stop(); + }); + input.addEventListener('input', () => { + if (!writing && rec && input.value !== wrote) end('typed'); + }); + document.addEventListener('keydown', event => { + if (event.key !== 'Escape' || (!rec && !clip)) return; + event.preventDefault(); + event.stopPropagation(); + end('cancelled'); + }, true); + probe(); + } + + /* Replies read aloud. */ + const synth = window.speechSynthesis && typeof window.SpeechSynthesisUtterance === 'function' ? window.speechSynthesis : null; + const box = !!toggle && toggle.tagName === 'INPUT' && String(toggle.type).toLowerCase() === 'checkbox'; + let speaking = false; + let unlocked = false; + /* Aien is said like Ian: speech gets the spoken form, the screen keeps Aien. */ + const SAYNAME = 'Ian'; + + function stored() { + try { + return window.localStorage.getItem(STORE) === 'on'; + } catch (_) { + return false; + } + } + function store(on) { + try { + if (on) window.localStorage.setItem(STORE, 'on'); + else window.localStorage.removeItem(STORE); + } catch (_) { + /* The choice lasts for this page only. */ + } + } + function showToggle() { + if (!toggle) return; + if (box) toggle.checked = speaking; + else toggle.setAttribute('aria-pressed', speaking ? 'true' : 'false'); + toggle.dataset.state = speaking ? 'on' : 'off'; + } + function stopSpeaking() { + if (synth) synth.cancel(); + } + function voice() { + const want = lang().toLowerCase().replace(/_/g, '-'); + const family = want.split('-')[0]; + let list = []; + try { + list = Array.from(synth.getVoices() || []); + } catch (_) { + list = []; + } + const tag = v => String(v && v.lang || '').toLowerCase().replace(/_/g, '-'); + const near = list.filter(v => v && v.localService === true && tag(v).split('-')[0] === family); + return near.find(v => tag(v) === want) || near[0] || null; + } + /* Code is skipped, links are named, markdown marks are dropped, and the + whole word Aien is spoken as SAYNAME. */ + function plain(text) { + return String(text) + .replace(/```[\s\S]*?(```|$)/g, ` ${COPY.code} `) + .replace(/https?:\/\/\S+/g, COPY.link) + .replace(/[`*_#>\x7e]+/g, '') + .replace(/\|/g, ' ') + .replace(/\bAien\b/g, SAYNAME) + .replace(/\s+/g, ' ') + .trim(); + } + function pieces(text) { + const out = []; + let line = ''; + for (const part of text.match(/[^.!?]+[.!?]*\s*|[.!?]+\s*/g) || []) { + let rest = part; + while (rest.length > CHUNK) { + if (line) out.push(line.trim()); + line = ''; + out.push(rest.slice(0, CHUNK).trim()); + rest = rest.slice(CHUNK); + } + if (line.length + rest.length > CHUNK) { + out.push(line.trim()); + line = ''; + } + line += rest; + } + if (line.trim()) out.push(line.trim()); + return out.filter(Boolean); + } + function read(text, lead) { + if (!speaking || !synth || document.hidden) return; + let said = plain(text); + if (!said) return; + if (said.length > SPEAK_MAX) said = `${said.slice(0, SPEAK_MAX)} ${COPY.rest}`; + stopSpeaking(); + const chosen = voice(); + for (const part of pieces(lead ? `${lead} ${said}` : said)) { + const utterance = new window.SpeechSynthesisUtterance(part); + utterance.lang = lang(); + if (chosen) utterance.voice = chosen; + synth.speak(utterance); + } + } + /* iOS speaks later only after one utterance inside a tap. */ + function unlock() { + if (unlocked || !speaking || !synth) return; + unlocked = true; + const utterance = new window.SpeechSynthesisUtterance(''); + utterance.volume = 0; + synth.speak(utterance); + } + function setSpeaking(on) { + speaking = !!on && !!synth; + store(speaking); + showToggle(); + if (!speaking) { + stopSpeaking(); + say(COPY.speakOff); + return; + } + unlock(); + say(voice() ? COPY.speakOn : `${COPY.speakOn} ${COPY.remote}`); + } + + if (toggle) { + if (!synth) { + toggle.disabled = true; + toggle.setAttribute('aria-disabled', 'true'); + toggle.title = COPY.noSpeak; + speaking = false; + } else { + speaking = stored(); + } + showToggle(); + toggle.addEventListener(box ? 'change' : 'click', () => { + if (!synth) return; + setSpeaking(box ? toggle.checked : !speaking); + }); + } + + function hidden() { + if (!document.hidden) return; + stopSpeaking(); + end('hidden'); + } + document.addEventListener('visibilitychange', hidden); + window.addEventListener('pagehide', () => { + stopSpeaking(); + end('hidden'); + }); + + /* The chat transport (window.allen v1): a new request silences speech; + replies are read only when the visitor turned reading on. */ + let hooked = false; + function hook() { + const allen = window.allen; + if (hooked || !allen || typeof allen.on !== 'function') return; + hooked = true; + allen.on('send', () => { + stopSpeaking(); + unlock(); + }); + allen.on('reply', detail => { + if (!detail || typeof detail.text !== 'string') return; + if (detail.outcome === 'Stopped.') return; + read(detail.text, ''); + }); + allen.on('human', detail => { + if (detail && typeof detail.text === 'string') read(detail.text, COPY.drake); + }); + } + hook(); + document.addEventListener('allen-ready', hook); + + window.AllenVoice = Object.freeze({ + version: 1, + mode: () => mode, + state: () => state, + speaking: () => speaking, + }); +})(); diff --git a/scripts/test-allen-intro.cjs b/scripts/test-allen-intro.cjs index 879845b..9055501 100644 --- a/scripts/test-allen-intro.cjs +++ b/scripts/test-allen-intro.cjs @@ -7,35 +7,98 @@ const { randomUUID } = require('node:crypto'); const source = readFileSync(process.argv[2] || 'public/js/allen-intro.js', 'utf8'); const key = 'aien-allen-intro-consent'; -function page({ stored, privacy = false, blocked = false, session, hash = '', search = '', failNo = false, configured = false } = {}) { +const seenKey = 'aien-allen-intro-seen'; +const GREETING = "Hi, I'm Aien (you say it like Ian). It's nice to meet you!"; +const INTRO = "You don't have to tell me your name, but if you do, that would be super awesome and we could chat over time. When you come back, I can remember who you are and we can pick up where we left off. We can talk about all kinds of good things in the universe."; +const OFFER = "Separately, if you'd like, say hi and I'll let Drake know you stopped by. That uses Drake's X pixel to note the visit. Totally fine if not."; +const GPC_NOTE = "Your browser sends Global Privacy Control, so I'm not offering Drake's X pixel. It stays off."; +const AFTER_NO = "No problem. You can still chat with me anonymously; I won't remember you or tell X anything."; +const X_ORIGINS = ['https://static.ads-twitter.com', 'https://analytics.twitter.com', 'https://t.co']; + +function page({ stored, privacy = false, blocked = false, blockedLocal = blocked, session, local, hash = '', search = '', failNo = false, configured = false, motion = false, gpc = false, chat, defer = false, letters = false, resources = [] } = {}) { // Fixture event IDs exist only in this isolated VM, never in deployed config. const code = configured ? source.replace("pageVisit: '', introducedToAllen: ''", "pageVisit: 'tw-rfrlz-testvisit', introducedToAllen: 'tw-rfrlz-testintro'") : source; - const storage = new Map(stored === undefined ? [] : [[key, stored]]); + const storage = local || new Map(stored === undefined ? [] : [[key, stored]]); const sessionData = session || new Map(); const loads = []; const events = {}; + const docEvents = {}; + const timers = []; + const delays = []; + const announced = []; + const network = []; + // Resource timing as the browser records it; same-origin files plus any given outside ones. + const entries = ['https://www.aienos.com/assets/style.css', 'https://www.aienos.com/js/allen-intro.js', ...resources].map(name => ({ name })); + const observers = []; + function record(names) { + const fresh = names.map(name => ({ name })); + entries.push(...fresh); + for (const fn of observers) fn({ getEntries: () => fresh }); + } let reloads = 0; + let modal = 0; + let ran = 0; let context; const nodes = {}; function node(id) { return nodes[id] ||= { - dataset: {}, open: false, hidden: true, isConnected: true, + id, dataset: {}, hidden: true, isConnected: true, textContent: '', classes: new Set(), + classList: { add(c) { nodes[id].classes.add(c); }, remove(c) { nodes[id].classes.delete(c); } }, addEventListener(name, fn) { this[name] = fn; }, + contains(other) { return other === this || (this.id === 'aien-allen-intro' && /^allen-intro-(yes|no|close)$/.test(other?.id)); }, focus() { document.activeElement = this; }, - showModal() { this.open = true; }, close() { this.open = false; }, + showModal() { modal++; }, close() {}, }; } + // The server-rendered copy JS reads, and the typed span's two children. + node('allen-intro-title').textContent = GREETING; + node('allen-intro-intro').textContent = INTRO; + node('allen-intro-offer').textContent = OFFER; + node('allen-intro-gpc').textContent = GPC_NOTE; + node('allen-intro-after-text').textContent = AFTER_NO; + node('allen-intro-typed').firstChild = node('typed-head'); + node('allen-intro-typed').lastChild = node('typed-tail'); + if (letters) node('allen-intro-typed').dataset.letters = 'true'; + // Letter mode appends one span per letter; plain mode only sets textContent. + for (const id of ['typed-head', 'typed-tail']) { + node(id).letters = []; + node(id).appendChild = function (child) { this.letters.push(child); }; + Object.defineProperty(node(id), 'textContent', { + get() { return this.plain + this.letters.map(l => l.textContent).join(''); }, + set(v) { this.plain = v; this.letters = []; }, + }); + node(id).textContent = ''; + } + for (const id of ['allen-intro-trackers', 'allen-intro-facts']) { + node(id).items = []; + node(id).appendChild = function (child) { this.items.push(child.textContent); }; + } + if (chat) node('allen').dataset.mode = chat; const document = { - activeElement: node('previous'), - getElementById(id) { return id === 'allen-intro-privacy' && !privacy ? null : node(id); }, + referrer: '', + getElementById(id) { + if ((id === 'allen-intro-privacy' && !privacy) || (id === 'allen' && !chat)) return null; + return node(id); + }, querySelectorAll(selector) { return privacy ? [node(selector)] : []; }, - createElement(tag) { assert.equal(tag, 'script'); return {}; }, - getElementsByTagName() { return [{ parentNode: { insertBefore(script) { loads.push(script.src); } } }]; }, + querySelector(selector) { assert.equal(selector, '[data-allen-intro-defer]'); return defer ? node('door') : null; }, + addEventListener(name, fn) { docEvents[name] = fn; }, + dispatchEvent(event) { announced.push(event.detail); }, + createElement(tag) { + // The panel may only build text list items; anything else would be a network-capable node. + if (tag === 'script') return {}; + assert.ok(['li', 'dt', 'dd', 'span'].includes(tag), `unexpected element ${tag}`); + return { tag, textContent: '' }; + }, + getElementsByTagName() { + return [{ parentNode: { insertBefore(script) { loads.push(script.src); record(X_ORIGINS.map(o => o + '/uwt.js')); } } }]; + }, }; + document.activeElement = node('previous'); const localStorage = { - getItem(k) { if (blocked) throw Error('blocked'); return storage.get(k) || null; }, - setItem(k, v) { if (blocked || (failNo && v === 'no')) throw Error('blocked'); storage.set(k, v); }, - removeItem(k) { if (blocked) throw Error('blocked'); storage.delete(k); }, + getItem(k) { if (blockedLocal) throw Error('blocked'); return storage.get(k) || null; }, + setItem(k, v) { if (blockedLocal || (failNo && v === 'no')) throw Error('blocked'); storage.set(k, v); }, + removeItem(k) { if (blockedLocal) throw Error('blocked'); storage.delete(k); }, }; const sessionStorage = { getItem(k) { if (blocked) throw Error('blocked'); return sessionData.get(k) || null; }, @@ -44,22 +107,45 @@ function page({ stored, privacy = false, blocked = false, session, hash = '', se }; const window = { crypto: { randomUUID }, - location: { hash, pathname: '/privacy/', search, reload() { reloads++; } }, + location: { hash, pathname: '/privacy/', search, href: 'https://www.aienos.com/privacy/', origin: 'https://www.aienos.com', reload() { reloads++; } }, addEventListener(name, fn) { events[name] = fn; }, + matchMedia(query) { assert.equal(query, '(prefers-reduced-motion: reduce)'); return { matches: !motion }; }, + navigator: { globalPrivacyControl: gpc, userAgent: 'TestAgent/1', platform: 'TestOS', languages: ['en-US'], doNotTrack: '1', cookieEnabled: true, + sendBeacon(url) { network.push(url); return true; } }, + screen: { width: 1280, height: 800 }, + performance: { getEntriesByType(type) { assert.equal(type, 'resource'); return entries.slice(); } }, + PerformanceObserver: class { constructor(fn) { this.fn = fn; } observe(opts) { assert.equal(opts.type, 'resource'); observers.push(this.fn); } }, + CustomEvent: class { constructor(type, init) { this.type = type; this.detail = init.detail; } }, + fetch(url) { network.push(String(url)); }, }; - context = vm.createContext({ document, localStorage, sessionStorage, window, URLSearchParams, + context = vm.createContext({ document, localStorage, sessionStorage, window, URLSearchParams, URL, history: { replaceState() { window.location.hash = ''; } }, + setTimeout(fn, ms) { delays.push(ms); timers.push(fn); return timers.length; }, clearTimeout(id) { if (id) timers[id - 1] = null; }, + fetch: window.fetch, XMLHttpRequest: class { open(m, url) { network.push(url); } send() {} }, + Image: class { set src(url) { network.push(url); } }, }); // Browsers expose window properties as globals; preserve that for the official snippet. Object.defineProperty(context, 'twq', { get() { return window.twq; } }); vm.runInContext(code, context); - return { nodes, loads, storage, sessionData, window, localStorage, + const aside = nodes['aien-allen-intro']; + return { nodes, aside, document, loads, storage, sessionData, window, localStorage, announced, network, entries, + api: () => context.window.aienAllenIntro, + delays, head: () => nodes['typed-head'], tail: () => nodes['typed-tail'], + shown: () => !aside.hidden && aside.classes.has('allen-intro-in'), + escape: () => docEvents.keydown({ key: 'Escape' }), + key: k => docEvents.keydown({ key: k }), + modal: () => modal, + typed: () => nodes['typed-head'].textContent + nodes['typed-tail'].textContent, + tick() { const fn = timers[ran]; if (!fn) return false; ran++; fn(); return true; }, reloads: () => reloads, runAgain: () => vm.runInContext(code, context), clearElsewhere() { storage.clear(); events.storage({ key: null, newValue: null, storageArea: localStorage }); }, queued: () => Array.from(window.twq?.queue || [], args => Array.from(args)), }; } +// Values built inside the VM realm compare structurally once copied into this realm. +const plain = v => JSON.parse(JSON.stringify(v)); + function noPixel(p) { assert.deepEqual(p.loads, [], 'no external pixel load before explicit consent'); assert.equal(p.window.twq, undefined, 'no twq before explicit consent'); @@ -68,38 +154,126 @@ function noPixel(p) { test('unknown, invalid, refused and unavailable storage never load X', () => { for (const options of [{}, { stored: 'no' }, { stored: 'YES' }, { blocked: true }]) noPixel(page(options)); }); -test('No persists, dismisses and remains tracking-free after navigation', () => { +test('first visit: Allen appears with the welcome, records seen, and does not steal focus', () => { const p = page(); - assert.equal(p.nodes['aien-allen-intro'].open, true); - p.nodes['allen-intro-no'].click(); - assert.equal(p.nodes['aien-allen-intro'].open, false); - assert.equal(p.storage.get(key), 'no'); + assert.equal(p.shown(), true); + assert.equal(p.storage.get(seenKey), '1'); + assert.equal(p.typed(), GREETING + ' ' + INTRO); + assert.equal(p.nodes['allen-intro-spoken'].textContent, GREETING + ' ' + INTRO + ' ' + OFFER); + assert.equal(p.nodes['allen-intro-x'].hidden, false, 'the X ask is offered as its own line'); + assert.deepEqual(plain(p.announced), [{ type: 'show', asked: false, offering: true }]); + assert.equal(p.document.activeElement, p.nodes.previous, 'auto-display must not move focus'); + noPixel(p); +}); +test('second page load does not show Allen, even with no choice made, and the pixel stays off', () => { + const first = page(); + assert.equal(first.shown(), true); + assert.equal(first.storage.has(key), false, 'no choice was made'); + const second = page({ local: first.storage, session: first.sessionData }); + assert.equal(second.aside.hidden, true); + noPixel(second); +}); +test('the page stays interactive while Allen is showing', () => { + const p = page(); + assert.equal(p.shown(), true); + assert.equal(p.modal(), 0, 'never showModal: no backdrop, page not inert'); + assert.equal(p.document.activeElement, p.nodes.previous); + // Page controls keep working: focusing and clicking elsewhere neither closes Allen nor decides. + p.nodes['page-link'] = { focus() { p.document.activeElement = this; } }; + p.nodes['page-link'].focus(); + assert.equal(p.document.activeElement, p.nodes['page-link']); + assert.equal(p.shown(), true); + assert.equal(p.storage.has(key), false); + // Other keys pass through untouched. + for (const k of ['Tab', 'Enter', ' ', 'a']) p.key(k); + assert.equal(p.shown(), true); + assert.equal(p.storage.has(key), false); noPixel(p); - const next = page({ stored: p.storage.get(key) }); - assert.equal(next.nodes['aien-allen-intro'].open, false); - noPixel(next); }); -test('Escape means No, and privacy is readable without the dialog', () => { +test('No thanks refuses X, offers an anonymous chat, and stays tracking-free after navigation', () => { const p = page(); - let prevented = false; - p.nodes['aien-allen-intro'].cancel({ preventDefault() { prevented = true; } }); - assert.equal(prevented, true); + p.nodes['allen-intro-no'].click(); assert.equal(p.storage.get(key), 'no'); + assert.equal(p.aside.hidden, false, 'Allen stays to answer'); + for (const id of ['allen-intro-message', 'allen-intro-chat', 'allen-intro-x']) assert.equal(p.nodes[id].hidden, true, id); + assert.equal(p.nodes['allen-intro-after'].hidden, false); + assert.equal(p.nodes['allen-intro-spoken'].textContent, AFTER_NO); + assert.equal(p.document.activeElement, p.nodes['allen-intro-anon'], 'focus follows the visitor action to Chat anonymously'); + assert.equal(p.announced.at(-1).type, 'reply-no'); + noPixel(p); + p.escape(); + assert.equal(p.aside.hidden, true); + assert.equal(p.announced.at(-1).type, 'hide'); noPixel(p); - const privacy = page({ privacy: true }); - assert.equal(privacy.nodes['aien-allen-intro'].open, false); - noPixel(privacy); + const next = page({ local: p.storage }); + assert.equal(next.aside.hidden, true); + noPixel(next); }); -test('introducing yourself runs the exact official configuration once per document', () => { +test('Escape and the close button mean No; Escape is ignored once Allen is gone', () => { + for (const act of [p => p.escape(), p => p.nodes['allen-intro-close'].click()]) { + const p = page(); + act(p); + assert.equal(p.aside.hidden, true); + assert.equal(p.storage.get(key), 'no'); + noPixel(p); + } + const later = page({ local: new Map([[seenKey, '1']]) }); + later.escape(); + assert.equal(later.storage.has(key), false, 'Escape elsewhere on the page decides nothing'); +}); +test('Say hi loads the exact official configuration once per document', () => { const p = page(); p.nodes['allen-intro-yes'].click(); p.nodes['allen-intro-yes'].click(); p.runAgain(); + assert.equal(p.aside.hidden, true); assert.deepEqual(p.loads, ['https://static.ads-twitter.com/uwt.js']); assert.deepEqual(p.queued(), [['config', 'rfrlz']]); assert.equal(p.storage.get(key), 'yes'); assert.deepEqual(page({ stored: 'yes' }).queued(), [['config', 'rfrlz']]); }); +test('Review my choice reopens Allen on the privacy page, focuses No thanks, and returns focus', () => { + for (const local of [new Map([[seenKey, '1']]), new Map([[seenKey, '1'], [key, 'no']])]) { + const p = page({ privacy: true, local }); + assert.equal(p.aside.hidden, true, 'privacy is readable without Allen'); + const review = p.nodes['[data-allen-intro-open]']; + assert.equal(review.hidden, false); + review.focus(); + review.click(); + assert.equal(p.shown(), true); + assert.equal(p.document.activeElement, p.nodes['allen-intro-no']); + p.escape(); + assert.equal(p.aside.hidden, true); + assert.equal(p.document.activeElement, review); + noPixel(p); + } +}); +test('negative control: clearing storage shows Allen again, and still gives no consent', () => { + const first = page(); + assert.equal(page({ local: first.storage }).aside.hidden, true, 'seen suppresses before the control'); + first.storage.clear(); + const again = page({ local: first.storage }); + assert.equal(again.shown(), true); + noPixel(again); +}); +test('without local storage, Allen appears at most once per tab session', () => { + const first = page({ blockedLocal: true }); + assert.equal(first.shown(), true); + assert.equal(first.sessionData.get(seenKey), '1'); + assert.equal(page({ blockedLocal: true, session: first.sessionData }).aside.hidden, true); + assert.equal(page({ blockedLocal: true }).shown(), true, 'a new tab session greets again'); +}); +test('typing is static client text; reduced motion shows it whole at once', () => { + const p = page({ motion: true }); + assert.equal(p.shown(), true); + assert.equal(p.typed(), ''); + while (p.tick()); + assert.equal(p.typed(), GREETING + ' ' + INTRO); + const q = page({ motion: true }); + q.tick(); + q.nodes['allen-intro-no'].click(); + assert.equal(q.tick(), false, 'closing stops the typing timer'); +}); test('revocation stops on reload, including failed persistent writes', () => { for (const failNo of [false, true]) { const p = page({ stored: 'yes', privacy: true, failNo }); @@ -148,3 +322,123 @@ test('empty production event IDs do not emit events or generate conversion IDs', p.nodes['allen-intro-yes'].click(); assert.deepEqual(p.queued(), [['config', 'rfrlz']]); }); + +function openWho(p) { p.nodes['allen-intro-who'].open = true; p.nodes['allen-intro-who'].toggle(); } + +test('who can see me: 0 trackers before consent, then the X origins after Say hi (negative control)', () => { + const p = page(); + openWho(p); + assert.equal(p.nodes['allen-intro-tracker-count'].textContent, '0'); + assert.equal(p.nodes['allen-intro-trackers-none'].hidden, false); + assert.deepEqual(plain(p.api().who().trackers), []); + p.nodes['allen-intro-yes'].click(); + const trackers = p.api().who().trackers; + assert.deepEqual(plain(trackers.map(t => t.origin)), X_ORIGINS); + assert.ok(trackers.every(t => t.pixel), 'each X origin is named as Drake\'s pixel'); + assert.equal(p.nodes['allen-intro-tracker-count'].textContent, String(X_ORIGINS.length)); + assert.ok(p.nodes['allen-intro-trackers'].items.every(line => line.endsWith(": that one's Drake's X pixel, because you said hi."))); +}); +test('who can see me lists other outside origins honestly, never as Drake\'s pixel', () => { + const p = page({ resources: ['https://www.youtube-nocookie.com/embed/x'] }); + openWho(p); + assert.deepEqual(plain(p.api().who().trackers), [{ origin: 'https://www.youtube-nocookie.com', pixel: false }]); + assert.deepEqual(p.nodes['allen-intro-trackers'].items, ['www.youtube-nocookie.com']); + noPixel(p); +}); +test('the panel makes no network request and only reads local browser facts', () => { + const p = page(); + const before = p.entries.length; + openWho(p); + p.api().who(); + assert.equal(p.entries.length, before, 'no new resource entries'); + assert.deepEqual(p.network, [], 'no fetch, beacon, XHR or image'); + const facts = Object.fromEntries(p.api().who().facts); + assert.equal(facts.Browser, 'TestAgent/1'); + assert.equal(facts['Screen size'], '1280 x 800'); + assert.equal(facts['Do Not Track'], 'on'); + assert.equal(facts['Global Privacy Control'], 'off'); + assert.equal(facts['Came from'], 'no referrer sent'); + assert.equal(p.storage.size, 1, 'only the seen mark is stored'); + noPixel(p); +}); +test('Global Privacy Control suppresses the pixel offer; only an explicit review offers it', () => { + const p = page({ gpc: true }); + assert.equal(p.shown(), true); + assert.equal(p.nodes['allen-intro-x'].hidden, true, 'no Say hi under GPC'); + assert.equal(p.nodes['allen-intro-gpc'].hidden, false); + assert.equal(p.nodes['allen-intro-spoken'].textContent, GREETING + ' ' + INTRO + ' ' + GPC_NOTE); + assert.equal(p.api().status().offering, false); + noPixel(p); + const review = page({ gpc: true, privacy: true, local: new Map([[seenKey, '1']]) }); + review.nodes['[data-allen-intro-open]'].click(); + assert.equal(review.nodes['allen-intro-x'].hidden, false); + // Negative control: without GPC the first greeting does offer it. + assert.equal(page().nodes['allen-intro-x'].hidden, false); +}); +test('anonymous chat on /allen/ never loads the pixel, and the chat page gets no greeting', () => { + const anon = page({ stored: 'yes', chat: 'anonymous' }); + noPixel(anon); + assert.equal(anon.aside.hidden, true); + assert.equal(page({ chat: 'anonymous' }).aside.hidden, true); + assert.deepEqual(page({ stored: 'yes', chat: 'remembered' }).loads, ['https://static.ads-twitter.com/uwt.js']); +}); +test('presence API: X consent only, events for the visual layer, memory consent absent', () => { + const p = page(); + const api = p.api(); + assert.deepEqual(plain(Object.keys(api).sort()), ['dismiss', 'greet', 'noThanks', 'onTrackers', 'review', 'sayHi', 'status', 'text', 'who']); + assert.deepEqual(plain(api.text), { greeting: GREETING, intro: INTRO, offer: OFFER, gpcNote: GPC_NOTE, afterNo: AFTER_NO }); + assert.deepEqual(plain(api.status()), { choice: null, gpc: false, offering: true, pixelLoaded: false, shown: true }); + const seen = []; + api.onTrackers(t => seen.push(t.origin)); + api.sayHi(); + assert.deepEqual(seen, X_ORIGINS); + assert.deepEqual(plain(p.announced.map(e => e.type)), ['show', 'hide', 'consent']); + assert.equal(api.status().pixelLoaded, true); + assert.equal(p.storage.get(key), 'yes'); + const q = page(); + q.api().dismiss(); + assert.equal(q.storage.get(key), 'no'); + assert.equal(q.aside.hidden, true); + noPixel(q); +}); +test('a page door defers the greeting until it calls greet(), which still runs only once', () => { + const p = page({ defer: true }); + assert.equal(p.aside.hidden, true, 'no greeting over the door'); + assert.equal(p.storage.has(seenKey), false, 'deferral does not spend the once-only greeting'); + assert.equal(p.api().greet(), true); + assert.equal(p.shown(), true); + assert.equal(p.storage.get(seenKey), '1'); + noPixel(p); + const next = page({ defer: true, local: p.storage }); + assert.equal(next.api().greet(), false, 'once per browser, even when called again'); + assert.equal(next.aside.hidden, true); + assert.equal(page({ defer: true, stored: 'no' }).api().greet(), false); +}); +test('Allen types at his native 35 ms per letter; data-letters gives one span per letter', () => { + const plain = page({ motion: true }); + while (plain.tick()); + assert.equal(plain.typed(), GREETING + ' ' + INTRO); + assert.ok(plain.delays.length > 0 && plain.delays.every(ms => ms === 35), 'native cadence'); + assert.equal(plain.head().letters.length, 0, 'plain mode builds no letter spans'); + const p = page({ motion: true, letters: true }); + assert.equal(p.typed(), ''); + while (p.tick()); + assert.equal(p.typed(), GREETING + ' ' + INTRO, 'letters spell the same words'); + const spans = [...p.head().letters, ...p.tail().letters]; + assert.equal(spans.length, (GREETING + ' ' + INTRO).length); + assert.ok(spans.every(s => s.tag === 'span' && s.className === 'allen-intro-letter' && s.textContent.length === 1)); + assert.equal(p.head().textContent, GREETING, 'the greeting stays in the strong slot'); + // Reduced motion: whole text at once, plain, no letter spans, no timers. + const still = page({ letters: true }); + assert.equal(still.typed(), GREETING + ' ' + INTRO); + assert.equal(still.head().letters.length + still.tail().letters.length, 0); + assert.equal(still.tick(), false); + // Reopening restarts cleanly instead of appending a second copy. + const again = page({ motion: true, letters: true, privacy: true, local: new Map([[seenKey, '1']]) }); + const review = again.nodes['[data-allen-intro-open]']; + review.click(); while (again.tick()); + again.escape(); + review.click(); while (again.tick()); + assert.equal(again.typed(), GREETING + ' ' + INTRO); + noPixel(again); +});