A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.
JavaScript claude-code-pluginclaude-code-skillscode-appsgithub-copilot-pluginpower-appspower-pagespower-platform
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<!--
The carousel inserts screen mockups whose text comes from the user's own requirements, so this
page treats that markup as untrusted. The sanitizer below strips scripts and handlers; this
policy is the backstop that holds even if the sanitizer is wrong.
- `default-src 'none'` so anything not named here simply cannot load.
- `script-src` is the nonce alone. The Mermaid tag carries it, and a nonce admits an external
script as well as an inline one. Naming the CDN host as well would admit every script on
jsDelivr, so an injected script tag whose src named any npm package there would run; with the
nonce alone, an injected script element carries no nonce and will not run. Inline
event-handler attributes are refused because 'unsafe-inline' is absent from script-src.
- `style-src 'unsafe-inline'` is required: this page ships a `<style>` block, the mockups carry
`style=` attributes, and Mermaid injects stylesheets. Inline CSS cannot execute.
- `img-src data:` only - the brand mark and the QR are both inlined, so no image is ever
fetched, and an injected `<img src=...>` cannot call out.
- No `connect-src` or `object-src`: the plan itself never talks to the network. The mockup
carousel uses an inline `srcdoc` document, not a fetched frame.
- `frame-src` is the one exception, and it is loopback-only: the live stage frames the app
served on loopback by the dev server the skill started (`npm run dev`), for example
`http://localhost:8082`. Only `http://localhost:*` and `http://127.0.0.1:*` are named, so an
injected frame cannot load remote content. `app-docs.js` (normalizePreviewUrl) refuses any
other URL before it reaches this page, and the page checks it again before drawing the frame.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-src
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-__ATTR_CSP_NONCE__'; style-src 'unsafe-inline'; img-src data:; font-src data:; frame-src http://localhost:* http://127.0.0.1:*; base-uri 'none'; form-action 'none'"/>
<title>__PLAN_TITLE__ - __APP_NAME__</title>
<!--
Mermaid is pinned to an exact version and checked against a hash of its bytes.
`@11` floated: it resolved to whatever the latest 11.x was at the moment the plan was opened,
so the code running inside a page that holds the environment URL, tenant id and the whole plan
could change without anything changing here. The CSP pins where a script may come from; only
integrity pins what it is. A file that does not match is refused, and the page already falls
back to showing each diagram's source, so a refusal degrades rather than breaks.
`crossorigin="anonymous"` is required for integrity to be enforced on a cross-origin script.
To upgrade: pick the new version, then
curl -sSL https://cdn.jsdelivr.net/npm/mermaid@<version>/dist/mermaid.min.js \
| openssl dgst -sha384 -binary | openssl base64 -A
and put "sha384-<output>" here. Cross-check jsDelivr's published hash for the same file at
https://data.jsdelivr.com/v1/packages/npm/mermaid@<version>?structure=flat before trusting it.
-->
<script nonce="__ATTR_CSP_NONCE__"
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"
integrity="sha384-EOXBFmc3gx5mb+vn0vPvvGqACToJD24hhacX5Yx+8NUUQrHIle/Qi5Bg9o3zKwW2"
crossorigin="anonymous"></script>
<style>
:root{
--bg:#faf9f8; --surface:#ffffff; --surface2:#f3f2f1; --border:#e1dfdd; --border-light:#c8c6c4;
--text:#323130; --text-dim:#605e5c; --text-bright:#201f1e; --accent:#0078d4; --accent-bg:#0078d40a; --accent-border:#0078d425;
--pass:#107c10; --pass-bg:#107c100a; --pass-border:#107c1020;
--purple:#8764b8; --purple-bg:#8764b80a; --purple-border:#8764b820;
--warn:#ca5010; --warn-bg:#ca50100a; --warn-border:#ca501020;
--footer-h:38px;
--topbar-h:72px;
--fail:#a4262c; --fail-bg:#a4262c0a; --fail-border:#a4262c20;
--mono:'Cascadia Code','Consolas',monospace; --sans:'Segoe UI','Segoe UI Web (West European)',-apple-system,system-ui,sans-serif;
--radius:8px; --radius-sm:4px; --shadow-4:0 1.6px 3.6px 0 rgba(0,0,0,0.132),0 0.3px 0.9px 0 rgba(0,0,0,0.108);
}
*{margin:0;padding:0;box-sizing:border-box;}
html{scroll-behavior:smooth;}
body{font-family:var(--sans);background:var(--bg);color:var(--text);font-size:14px;line-height:1.6;padding-bottom:var(--footer-h);}
.topbar{z-index:100;background:var(--surface);box-shadow:var(--shadow-4);padding:14px 28px;display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;position:sticky;top:0;}
.topbar-left{display:flex;align-items:center;gap:14px;}
.logo{width:36px;height:36px;object-fit:contain;display:block;flex-shrink:0;}
.topbar-title{font-size:16px;font-weight:700;color:var(--text-bright);}
.topbar-sub{font-size:11px;color:var(--text-dim);margin-top:1px;display:flex;align-items:center;gap:6px;flex-wrap:wrap;}
.topbar-sep{opacity:0.5;}
.topbar-right{display:flex;gap:6px;flex-wrap:wrap;align-items:center;}
.pill{font-size:11px;padding:4px 10px;border-radius:999px;font-weight:600;letter-spacing:0.2px;border:1px solid transparent;}
.pill-platform{background:var(--accent-bg);color:var(--accent);border-color:var(--accent-border);}
.pill-progress{background:var(--purple-bg);color:var(--purple);border-color:var(--purple-border);}
.pill-live{background:var(--pass-bg);color:var(--pass);border-color:var(--pass-border);}
.shell{display:flex;align-items:flex-start;}
.layout{display:flex;min-height:calc(100vh - var(--topbar-h));flex:1;min-width:0;}
.rail{width:430px;flex-shrink:0;position:sticky;top:var(--topbar-h);height:calc(100vh - var(--topbar-h) - var(--footer-h));display:flex;flex-direction:column;align-items:center;justify-content:safe center;gap:14px;padding:24px 20px;overflow-y:auto;border-left:1px solid var(--border);background:var(--surface);}
.rail-title{font-size:11px;font-weight:700;color:var(--text-dim);text-transform:uppercase;letter-spacing:1.2px;}
/* The sticky rail is shorter than the viewport because the topbar and footer remain visible.
The phone is the only rail item that can give up height, so it flex-shrinks into whatever the
label, caption, preview link and store buttons leave. A fixed budget cannot work here: the QR
stage adds the link and store row, so a budget sized for the building stage pushes the label
under the topbar and the store row behind the footer on a 720px-tall window. Below 360px the
phone stops shrinking and the rail scrolls, because a smaller phone cannot show the QR copy. */
/* The phone: an iPhone 18 Pro shell from scripts/lib/phone-shell.js, shared with the edit page.
Its sizes are the screen's; the bezel sits outside them. */
__RAW_PHONE_SHELL_CSS__
/* Stage 1 - building */
.bld{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:22px;background:#faf9f8;padding:0 28px;text-align:center;}
.bld-orbit{position:relative;width:132px;height:132px;display:grid;place-items:center;}
.bld-ring{position:absolute;border:1px solid rgba(32,31,30,.12);border-radius:50%;animation:railSpin linear infinite;}
.bld-ring:nth-child(1){width:96px;height:96px;animation-duration:9s;}
.bld-ring:nth-child(2){width:132px;height:132px;animation-duration:16s;animation-direction:reverse;border-style:dashed;}
@keyframes railSpin{to{transform:rotate(360deg);}}
.bld-core{width:72px;height:72px;display:grid;place-items:center;animation:railFloat 4s ease-in-out infinite;}
.bld-core img{width:62px;height:62px;}
@keyframes railFloat{0%,100%{transform:translateY(0);}50%{transform:translateY(-6px);}}
.bld-title{color:#201f1e;font-size:16px;font-weight:650;}
.bld-msg{color:#605e5c;font-size:13px;min-height:36px;}
.bld-bar{width:100%;height:4px;border-radius:4px;background:#eceaea;overflow:hidden;}
.bld-bar span{display:block;height:100%;background:#0078d4;transition:width .5s ease;}
.bld-caps{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;}
.bld-cap{font-size:10.5px;color:#605e5c;background:#ffffff;border:1px solid #e1dfdd;border-radius:999px;padding:3px 9px;opacity:0;animation:railFade .6s ease forwards;}
@keyframes railFade{to{opacity:1;}}
/* Stage 2 - carousel */
.car{position:absolute;inset:0;background:#fff;}
/* The mockup is drawn into the phone's app area (.device-app) as a scaled, sandboxed document, so
its selectors, media queries, and fixed tab bars stay independent of the plan.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox */
.car-nav{width:300px;display:flex;align-items:center;justify-content:space-between;gap:8px;}
.car-btn{width:30px;height:30px;border-radius:50%;border:1px solid var(--border);background:var(--surface);color:var(--text-bright);font-size:15px;cursor:pointer;display:grid;place-items:center;box-shadow:var(--shadow-4);}
.car-btn:disabled{opacity:.35;cursor:default;}
.car-dots{display:flex;gap:5px;}
.car-dot{width:6px;height:6px;border-radius:50%;background:var(--border-light);}
.car-dot.on{background:var(--accent);}
/* Live stage - the running app from the local Expo web server, in the same app area as the
mockups. A browser reports zero safe-area insets, so the app would draw its header under the
Dynamic Island and its tab bar under the home indicator; the app area keeps it between them, as
the phone's own insets would. The strips around it take the app's likely background: the app
follows the browser's colour scheme (useColorScheme), and so does this. */
.live{position:absolute;inset:0;background:#fff;}
@media (prefers-color-scheme:dark){.live{background:#000;}}
.rail-caption{font-size:12px;color:var(--text-dim);text-align:center;min-height:32px;padding:0 10px;}
/* Stage 3 - QR */
/* On a short window the phone shrinks (see .device), so the QR screen must fit a smaller frame:
the code gives up height first, the content clears the status bar and home indicator, and the
copy tightens when the phone is short. Without this the code slides under the Dynamic Island
and the Metro URL is cut off. */
.qr{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:safe center;gap:16px;background:#fff;padding:calc(var(--device-status-bar) + 8px) 22px calc(var(--device-home-bar) + 8px);text-align:center;}
.qr img{flex:0 1 196px;min-height:84px;max-height:196px;width:auto;max-width:100%;aspect-ratio:1/1;object-fit:contain;}
.qr-title{font-size:16px;font-weight:700;color:#201f1e;}
.qr-sub{font-size:12.5px;color:#605e5c;line-height:1.55;}
.qr-url{font-family:var(--mono);font-size:11px;color:#0078d4;word-break:break-all;}
@container (max-height:520px){.qr{gap:8px;padding:calc(var(--device-status-bar) + 4px) 12px calc(var(--device-home-bar) + 4px);}.qr-title{font-size:14px;}.qr-sub{font-size:11px;line-height:1.4;}.qr-url{font-size:10px;}}
@media(max-width:1180px){.shell{flex-direction:column;}.rail{width:100%;position:static;height:auto;border-left:none;border-top:1px solid var(--border);}.device{flex:none;height:auto;min-height:0;max-height:none;width:min(286px,calc(100vw - 72px));}}
.sidebar{width:240px;background:var(--surface);border-right:1px solid var(--border);padding:20px 0;flex-shrink:0;}
.nav-group-label{font-size:10px;font-weight:700;color:var(--text-dim);text-transform:uppercase;letter-spacing:1.2px;padding:16px 22px 6px;}
.nav-btn{display:flex;align-items:center;gap:10px;width:100%;padding:11px 22px;background:none;border:none;border-left:2px solid transparent;color:var(--text-dim);font-size:13px;font-weight:500;cursor:pointer;font-family:var(--sans);text-align:left;transition:all 0.15s;}
.nav-btn:hover{color:var(--text);background:var(--surface2);}
.nav-btn.active{color:var(--accent);font-weight:600;border-left-color:var(--accent);background:var(--accent-bg);}
.nav-btn .nav-icon{font-size:15px;opacity:0.5;width:18px;text-align:center;}
.nav-btn.active .nav-icon{opacity:0.9;}
.content{flex:1;padding:32px 40px 72px;max-width:1060px;}
.section{display:none;}
.section.active{display:block;animation:fadeIn 0.3s ease;}
@keyframes fadeIn{from{opacity:0;transform:translateY(8px);}to{opacity:1;transform:translateY(0);}}
h2{font-size:21px;font-weight:800;color:var(--text-bright);letter-spacing:-0.3px;margin-bottom:5px;}
.section-desc{font-size:13px;color:var(--text-dim);margin-bottom:20px;}
.section-desc code{color:var(--accent);background:var(--accent-bg);padding:1px 6px;border-radius:3px;font-family:var(--mono);font-size:12px;}
h3{font-size:15px;font-weight:700;color:var(--text-bright);margin-top:24px;margin-bottom:12px;}
.summary-box{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:22px;margin-bottom:22px;font-size:14px;color:var(--text);line-height:1.75;}
.stats-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:24px;}
.stat-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:18px 16px;text-align:center;position:relative;overflow:hidden;box-shadow:var(--shadow-4);}
.stat-card::after{content:'';position:absolute;top:0;left:50%;transform:translateX(-50%);width:40px;height:2px;border-radius:0 0 2px 2px;background:var(--accent);}
.stat-card:nth-child(2)::after{background:var(--purple);}
.stat-card:nth-child(3)::after{background:var(--warn);}
.stat-num{font-size:30px;font-weight:800;font-family:var(--mono);line-height:1;color:var(--text-bright);}
.stat-label{font-size:10px;color:var(--text-dim);text-transform:uppercase;letter-spacing:1px;margin-top:6px;}
.progress-track{height:6px;border-radius:999px;background:var(--surface2);border:1px solid var(--border);overflow:hidden;margin-bottom:8px;}
.progress-fill{display:block;height:100%;background:var(--accent);transition:width 0.4s ease;}
.progress-meta{display:flex;justify-content:space-between;font-size:12px;color:var(--text-dim);margin-bottom:24px;}
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:16px 20px;margin-bottom:10px;display:grid;grid-template-columns:22px 1fr auto;gap:14px;align-items:start;box-shadow:var(--shadow-4);}
.card.is-active{border-color:var(--accent-border);background:var(--accent-bg);}
.card.is-skipped{opacity:0.55;}
.mark{width:18px;height:18px;border-radius:50%;border:2px solid var(--border-light);margin-top:3px;flex-shrink:0;}
.is-done .mark{border-color:var(--pass);background:var(--pass);position:relative;}
/* Tick drawn from two borders on a rotated box rather than a glyph, so it cannot fall back
to a missing character and needs no extra element in the card markup. */
.is-done .mark::after{content:'';position:absolute;left:4.5px;top:1px;width:3.5px;height:8px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg);}
.is-active .mark{border-color:var(--accent);border-right-color:transparent;animation:spin 1s linear infinite;}
.is-failed .mark{border-color:var(--fail);background:var(--fail);}
.is-skipped .mark{border-style:dashed;}
@keyframes spin{to{transform:rotate(360deg);}}
.step-title{font-weight:600;color:var(--text-bright);}
.step-detail{font-size:12.5px;color:var(--text-dim);}
.step-note{font-size:12.5px;color:var(--accent);margin-top:4px;}
.step-ref{font-size:11px;color:var(--text-dim);font-family:var(--mono);margin-top:4px;opacity:0.75;}
.chip{display:inline-flex;align-items:center;gap:5px;font-size:11px;padding:3px 10px;border-radius:4px;font-weight:600;background:var(--surface2);border:1px solid var(--border);color:var(--text-dim);white-space:nowrap;}
.chip-done{background:var(--pass-bg);border-color:var(--pass-border);color:var(--pass);}
.chip-active{background:var(--accent-bg);border-color:var(--accent-border);color:var(--accent);}
.chip-failed{background:var(--fail-bg);border-color:var(--fail-border);color:var(--fail);}
.empty{color:var(--text-dim);font-size:13px;padding:18px 20px;background:var(--surface);border:1px dashed var(--border);border-radius:var(--radius);}
.cap{background:var(--surface);border:1px solid var(--border);border-left:3px solid var(--accent);border-radius:var(--radius);padding:16px 20px;margin-bottom:10px;box-shadow:var(--shadow-4);}
.cap-connector{border-left-color:var(--purple);}
.cap-offline-on{border-left-color:var(--pass);}
.cap-offline-off{border-left-color:var(--border-light);}
.cap-head{display:flex;align-items:center;gap:10px;margin-bottom:6px;}
.cap-icon{flex:0 0 28px;height:28px;border-radius:8px;}
.cap-icon svg{width:17px;height:17px;}
.cap-connector .cap-icon{background:var(--purple-bg);color:var(--purple);}
.cap-name{font-size:14px;font-weight:700;color:var(--text-bright);}
.cap-kind{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:0.6px;padding:2px 8px;border-radius:3px;background:var(--accent-bg);color:var(--accent);border:1px solid var(--accent-border);}
.cap-kind-connector{background:var(--purple-bg);color:var(--purple);border-color:var(--purple-border);}
.cap-why{font-size:13px;color:var(--text-dim);line-height:1.6;}
.perm{display:flex;gap:14px;align-items:flex-start;padding:14px 0;border-bottom:1px solid var(--border);}
.perm:last-child{border-bottom:none;}
.perm-icon{flex:0 0 34px;height:34px;display:grid;place-items:center;border-radius:9px;background:var(--surface2);color:var(--text-dim);}
.perm-icon svg{width:19px;height:19px;display:block;}
.perm-body{flex:1;min-width:0;}
.perm-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:3px;}
.perm-name{font-size:13.5px;font-weight:600;color:var(--text-bright);}
.perm-badge{font-size:10.5px;font-weight:700;letter-spacing:.06em;padding:2px 8px;border-radius:999px;border:1px solid transparent;}
.perm-good{background:var(--pass-bg);color:var(--pass);border-color:var(--pass-border);}
.perm-info{background:var(--accent-bg);color:var(--accent);border-color:var(--accent-border);}
.perm-warn{background:var(--warn-bg);color:var(--warn);border-color:var(--warn-border);}
.perm-muted{background:var(--surface2);color:var(--text-dim);border-color:var(--border);}
.perm-act{font-size:12.5px;color:var(--text-dim);margin-top:4px;opacity:.85;}
.perm-why{font-size:13px;color:var(--text-dim);line-height:1.6;}
.boundary-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:14px;}
.boundary{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:16px 18px;box-shadow:var(--shadow-4);}
.boundary h4{margin:0 0 10px;font-size:13.5px;color:var(--text-bright);}
.boundary .bullets{font-size:13px;color:var(--text-dim);}
.ai-footer{position:fixed;bottom:0;left:0;right:0;text-align:center;padding:10px;font-size:12px;
color:var(--text-dim);border-top:1px solid var(--border);background:var(--surface);z-index:100;}
.input-banner{position:fixed;top:78px;right:24px;z-index:100;display:flex;align-items:center;gap:12px;
background:var(--warn-bg);border:1px solid var(--warn-border);color:var(--warn);padding:12px 14px 12px 18px;
border-radius:999px;font-size:13.5px;max-width:min(380px,calc(100vw - 48px));
box-shadow:0 6px 20px rgba(0,0,0,.12);background-color:#fff8f2;}
.input-banner[hidden]{display:none;}
/* While the phone rail is a side column, keep the banner over the plan instead of the phone: the
preview gate raises it exactly when the user needs to use the live app. */
@media(min-width:1181px){.input-banner{right:454px;}}
.input-banner-icon{font-size:11px;flex-shrink:0;animation:bannerPulse 1.6s ease-in-out infinite;}
.input-banner-text{line-height:1.35;flex:1;min-width:0;}
.input-banner-text b{display:block;font-weight:650;}
.input-banner-text small{display:block;font-size:12px;opacity:.85;margin-top:2px;color:var(--text-dim);}
.input-banner-close{width:24px;height:24px;border:0;border-radius:50%;background:rgba(202,80,16,.12);
color:var(--warn);cursor:pointer;font-size:17px;line-height:1;flex-shrink:0;}
.input-banner-close:hover{background:rgba(202,80,16,.22);}
@keyframes bannerPulse{0%,100%{opacity:1;}50%{opacity:.35;}}
.store-row{display:flex;gap:8px;justify-content:center;margin-top:6px;}
.store-btn{display:flex;align-items:center;gap:9px;padding:7px 13px;border-radius:9px;
background:#000;color:#fff;text-decoration:none;line-height:1.15;
border:1px solid rgba(255,255,255,.22);}
.store-btn:hover{background:#141414;}
.store-logo{flex:0 0 auto;display:grid;place-items:center;}
.store-logo svg{width:21px;height:21px;display:block;}
.store-text{display:flex;flex-direction:column;}
.store-kicker{font-size:8.5px;letter-spacing:.03em;opacity:.9;}
.store-name{font-size:14px;font-weight:600;letter-spacing:-.01em;}
.rail-note{font-size:11.5px;color:var(--text-dim);text-align:center;max-width:300px;line-height:1.45;
padding:6px 10px;border-radius:8px;background:var(--surface2);}
.rail-note[hidden]{display:none;}
.rail-link{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;color:var(--accent);
text-decoration:none;padding:6px 12px;border-radius:999px;border:1px solid transparent;}
.rail-link:hover{border-color:var(--accent-border);background:var(--accent-bg);}
/* The QR under the live phone: compact and horizontal, so the phone above it gives up as little
height as possible on a short window. */
.rail-qr{display:flex;align-items:center;gap:12px;width:300px;max-width:100%;padding:10px 12px;
border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);text-align:left;}
.rail-qr img{width:76px;height:76px;flex-shrink:0;image-rendering:pixelated;display:block;}
.rail-qr-full{flex-shrink:0;}
.rail-qr-copy{min-width:0;}
.rail-qr-title{font-size:12.5px;font-weight:650;color:var(--text-bright);}
.rail-qr-sub{font-size:11.5px;color:var(--text-dim);line-height:1.4;margin-top:2px;}
.rail-qr-stores{font-size:11.5px;margin-top:4px;color:var(--text-dim);}
.rail-qr-stores a{color:var(--accent);text-decoration:none;}
.rail-qr-stores a:hover{text-decoration:underline;}
.plan-doc{display:inline-flex;align-items:center;gap:8px;margin-bottom:14px;padding:8px 14px;
background:var(--surface);border:1px solid var(--border);border-radius:999px;
font-size:13px;color:var(--accent);text-decoration:none;box-shadow:var(--shadow-4);}
.plan-doc:hover{border-color:var(--accent-border);background:var(--accent-bg);}
.plan-doc-raw{font-family:var(--mono);font-size:12px;color:var(--text-dim);text-decoration:none;margin-left:8px;align-self:center;}
.plan-doc-raw:hover{color:var(--accent);text-decoration:underline;}
.bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:6px;}
.bullets li{line-height:1.55;}
.bullets li::marker{color:var(--text-dim);}
.cap-why strong{color:var(--text);font-weight:600;}
.approval{display:flex;align-items:center;gap:10px;padding:12px 16px;border-radius:var(--radius);margin-bottom:18px;font-size:13px;font-weight:600;}
.approval-proposed{background:var(--warn-bg);border:1px solid var(--warn-border);color:var(--warn);}
.approval-approved{background:var(--pass-bg);border:1px solid var(--pass-border);color:var(--pass);}
.approval-dot{width:8px;height:8px;border-radius:50%;background:currentColor;flex-shrink:0;}
.approval-proposed .approval-dot{animation:approvalPulse 1.6s ease-in-out infinite;}
@keyframes approvalPulse{0%,100%{opacity:.35;}50%{opacity:1;}}
.facts{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:10px;margin-bottom:8px;}
.fact{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px;box-shadow:var(--shadow-4);}
.fact-label{font-size:11px;font-weight:600;color:var(--text-dim);text-transform:uppercase;letter-spacing:0.5px;margin-bottom:4px;}
.fact-value{font-size:13.5px;color:var(--text-bright);word-break:break-word;}
.fact-value.mono{font-family:var(--mono);font-size:12.5px;}
.diagram{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow-4);overflow:auto;margin-bottom:8px;}
.diagram pre{font-family:var(--mono);font-size:12px;color:var(--text-dim);white-space:pre;margin:0;}
.diagram-note{font-size:11.5px;color:var(--text-dim);margin-bottom:18px;}
.badge{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:0.6px;padding:2px 8px;border-radius:3px;}
.badge-create{background:var(--pass-bg);color:var(--pass);border:1px solid var(--pass-border);}
.badge-reuse{background:var(--accent-bg);color:var(--accent);border:1px solid var(--accent-border);}
.badge-extend{background:var(--warn-bg);color:var(--warn);border:1px solid var(--warn-border);}
.status-pill{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:0.6px;padding:3px 9px;border-radius:999px;white-space:nowrap;}
.status-new{color:var(--accent);background:var(--accent-bg);border:1px solid var(--accent-border);}
.status-modified{color:var(--warn);background:var(--warn-bg);border:1px solid var(--warn-border);}
.status-reused{color:var(--pass);background:var(--pass-bg);border:1px solid var(--pass-border);}
.key-badge{font-size:9px;font-weight:700;padding:1px 5px;border-radius:3px;font-family:var(--mono);}
.key-PK{color:var(--accent);background:var(--accent-bg);}
.key-FK{color:var(--purple);background:var(--purple-bg);}
.type-chip{font-size:10px;font-family:var(--mono);color:var(--text-dim);background:var(--surface2);padding:1px 6px;border-radius:3px;border:1px solid var(--border);}
.entity{background:var(--surface);border:1px solid var(--border);border-left:3px solid var(--border-light);border-radius:var(--radius);margin-bottom:10px;box-shadow:var(--shadow-4);overflow:hidden;}
.entity.new{border-left-color:var(--accent);}
.entity.modified{border-left-color:var(--warn);}
.entity.reused{border-left-color:var(--pass);}
.entity-head{display:flex;align-items:center;gap:10px;padding:14px 18px;cursor:pointer;}
.entity-name{font-family:var(--mono);font-size:13px;font-weight:700;color:var(--text-bright);}
.entity-display{font-size:12.5px;color:var(--text-dim);}
.entity-spacer{flex:1;}
.expand-chevron{color:var(--text-dim);font-size:12px;transition:transform 0.2s;}
.entity.open .expand-chevron{transform:rotate(90deg);}
.entity-summary{padding:0 18px 14px;display:grid;gap:6px;}
.entity-body{display:none;padding:0 18px 16px;border-top:1px solid var(--border);margin-top:2px;padding-top:14px;}
.entity.open .entity-body{display:block;}
.col-table{width:100%;border-collapse:collapse;margin-top:4px;}
.col-table th{text-align:left;font-size:10px;font-weight:600;color:var(--text-dim);text-transform:uppercase;letter-spacing:0.5px;padding:6px 8px;border-bottom:2px solid var(--border);background:var(--surface2);}
.col-table td{padding:6px 8px;border-bottom:1px solid var(--border);font-size:12.5px;}
.col-table .col-logical{font-family:var(--mono);font-size:11px;color:var(--text-bright);}
.rel-line{font-size:12.5px;color:var(--text);padding:4px 0;}
.rel-arrow{color:var(--accent);font-weight:700;font-family:var(--mono);}
.er-toolbar{display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin-bottom:10px;}
.er-legend{display:flex;gap:14px;flex-wrap:wrap;}
.er-legend-item{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--text-dim);font-weight:500;}
.er-legend-swatch{width:12px;height:12px;border-radius:2px;border:2px solid;}
.er-toggle{padding:5px 12px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);color:var(--text-dim);font-size:12px;font-weight:600;cursor:pointer;font-family:var(--sans);transition:all 0.15s;}
.er-toggle:hover{border-color:var(--accent);color:var(--accent);}
.er-toggle.active{background:var(--accent-bg);border-color:var(--accent);color:var(--accent);}
.palette-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px;}
.swatch-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;box-shadow:var(--shadow-4);}
.swatch{height:64px;width:100%;display:block;}
.swatch-meta{padding:9px 12px;}
.swatch-name{font-size:12px;font-weight:600;color:var(--text-bright);}
.swatch-value{font-size:11px;color:var(--text-dim);font-family:var(--mono);}
@media(max-width:860px){
.layout{flex-direction:column;}
.sidebar{width:100%;display:flex;flex-wrap:wrap;border-right:none;border-bottom:1px solid var(--border);padding:8px;}
.nav-group-label{width:100%;}
.nav-btn{width:auto;border-left:none;border-bottom:2px solid transparent;padding:10px 14px;}
.nav-btn.active{border-left:none;border-bottom-color:var(--accent);}
.content{padding:24px 18px 60px;}
.stats-grid{grid-template-columns:1fr;}
}
</style>
</head>
<body>
<div class="topbar">
<div class="topbar-left">
<img class="logo" id="brandLogo" src="__ATTR_BRAND_ICON__" alt="Power Apps"/>
<div>
<div class="topbar-title">__PLAN_TITLE__</div>
<div class="topbar-sub">
<span>__HTML_APP_NAME__</span>
<span class="topbar-sep">|</span>
<span id="updatedAt" data-generated="__ATTR_GENERATED_ISO__">Updated __HTML_GENERATED_AT__ UTC</span>
</div>
<div class="topbar-sub">
<span id="refreshStatus" role="status"></span>
</div>
</div>
</div>
<div class="topbar-right">
<span class="pill pill-platform">Data: __HTML_DATA_PLATFORM__</span>
<span class="pill pill-progress" id="pillProgress">Step 0 of 0</span>
</div>
</div>
<div class="input-banner" id="inputBanner" hidden>
<span class="input-banner-icon">●</span>
<div class="input-banner-text">
<b>Waiting for your input</b>
<small id="inputBannerPrompt"></small>
</div>
<button type="button" class="input-banner-close" id="inputBannerClose" aria-label="Dismiss">×</button>
</div>
<div class="shell">
<div class="layout">
<div class="sidebar">
<div class="nav-group-label">Plan</div>
<button class="nav-btn active" data-tab="overview"><span class="nav-icon">◉</span> Overview</button>
<button class="nav-btn" data-tab="steps"><span class="nav-icon">▦</span> Build steps</button>
<button class="nav-btn" data-tab="requirements"><span class="nav-icon">✎</span> Requirements</button>
<button class="nav-btn" data-tab="datamodel"><span class="nav-icon">▤</span> Data model</button>
<button class="nav-btn" data-tab="capabilities"><span class="nav-icon">●</span> Capabilities</button>
<button class="nav-btn" data-tab="screens"><span class="nav-icon">▣</span> Screens</button>
<button class="nav-btn" data-tab="design"><span class="nav-icon">☀</span> Design</button>
<button class="nav-btn" data-tab="trust"><span class="nav-icon">◆</span> Trust report</button>
</div>
<div class="content">
<div class="section active" id="tab-overview">
<h2>Overview</h2>
<div class="section-desc">
How <code>/create-mobile-app</code> is building this app. This page is rewritten as each
phase completes and stays in <code>docs/</code> afterwards.
</div>
<div class="summary-box" id="summaryBox"></div>
<div class="progress-track"><span class="progress-fill" id="progressFill"></span></div>
<div class="progress-meta">
<span id="progressCurrent"></span>
<span id="progressCount"></span>
</div>
<div class="stats-grid">
<div class="stat-card"><div class="stat-num" id="statDone">0</div><div class="stat-label">Completed</div></div>
<div class="stat-card"><div class="stat-num" id="statRemaining">0</div><div class="stat-label">Remaining</div></div>
<div class="stat-card"><div class="stat-num" id="statSkipped">0</div><div class="stat-label">Not needed</div></div>
</div>
<h3>Environment</h3>
<div class="facts" id="environmentFacts"></div>
<h3>Architecture</h3>
<div id="approval-architecture"></div>
<div class="facts" id="architectureFacts"></div>
<div id="overviewPlanDoc"></div>
</div>
<div class="section" id="tab-steps">
<h2>Build steps</h2>
<div class="section-desc">
Each row groups several skill steps; the reference shows which ones.
</div>
<div id="stepsContainer"></div>
</div>
<div class="section" id="tab-requirements">
<h2>Requirements</h2>
<div class="section-desc">What you asked for, and the choices confirmed during the wizard.</div>
<div class="summary-box" id="briefBox"></div>
<h3>Your choices</h3>
<div class="facts" id="requirementsFacts"></div>
</div>
<div class="section" id="tab-datamodel">
<h2>Data model</h2>
<div class="section-desc">Tables approved at the data model gate, and how each one was sourced.</div>
<div id="approval-datamodel"></div>
<div class="stats-grid">
<div class="stat-card"><div class="stat-num" id="statNew">0</div><div class="stat-label">New tables</div></div>
<div class="stat-card"><div class="stat-num" id="statReused">0</div><div class="stat-label">Reused</div></div>
<div class="stat-card"><div class="stat-num" id="statModified">0</div><div class="stat-label">Extended</div></div>
</div>
<div class="er-toolbar">
<div class="er-legend">
<div class="er-legend-item"><span class="er-legend-swatch" style="background:rgba(0,120,212,0.08);border-color:#0078d4;"></span> New</div>
<div class="er-legend-item"><span class="er-legend-swatch" style="background:rgba(202,80,16,0.08);border-color:#ca5010;"></span> Extended</div>
<div class="er-legend-item"><span class="er-legend-swatch" style="background:rgba(16,124,16,0.08);border-color:#107c10;"></span> Reused</div>
</div>
<button id="erCompactBtn" class="er-toggle">Compact view</button>
</div>
<div id="erContainer"></div>
<h3>Tables</h3>
<div id="tablesContainer"></div>
</div>
<div class="section" id="tab-capabilities">
<h2>Capabilities</h2>
<div class="section-desc">
What this app can do, and why each capability was chosen. An app can run entirely on
connectors with no Dataverse at all.
</div>
<h3>Device capabilities</h3>
<div id="deviceCapabilities"></div>
<h3>Connectors</h3>
<div id="connectorList"></div>
<h3>Offline</h3>
<div id="offlineBlock"></div>
</div>
<div class="section" id="tab-screens">
<h2>Screens</h2>
<div class="section-desc">The screen graph approved at the screen graph gate, and the per-screen specs built from it.</div>
<div id="approval-screens"></div>
<div id="screensPlanDoc"></div>
<div id="graphContainer"></div>
<h3>Screen specs</h3>
<div id="screensContainer"></div>
</div>
<div class="section" id="tab-design">
<h2>Design</h2>
<div class="section-desc">The design direction applied to every generated screen.</div>
<div id="approval-design"></div>
<div class="facts" id="designFacts"></div>
<h3>Palette</h3>
<div class="palette-grid" id="paletteContainer"></div>
</div>
<div class="section" id="tab-trust">
<h2>Trust report</h2>
<div id="approval-trust"></div>
<div class="section-desc">
What this app can reach on the device, what it keeps, and what it does while you are not
looking. Every entry comes from the approved plan and the capabilities actually wired up,
not from what the shared template could theoretically do.
</div>
<h3>Permission behavior</h3>
<div class="section-desc">
How each permission is acquired, and when. The badge names the pattern - a permission asked
for beside the feature that needs it reads differently from one taken at launch, even
though both end in the same grant.
</div>
<div id="permissionList"></div>
<h3>Privacy and data boundaries</h3>
<div class="boundary-grid">
<div class="boundary" id="handlesCard"></div>
<div class="boundary" id="notCollectedCard"></div>
</div>
<h3>Battery-conscious behavior</h3>
<div class="section-desc">
What this app does while it is not on screen: polling, sensor subscriptions, sync
intervals, and any work that outlives a visible screen.
</div>
<div id="batteryList"></div>
</div>
</div>
</div>
<aside class="rail">
<div class="rail-title" id="railTitle">Your app</div>
__RAW_PHONE_SHELL__
<div id="railControls" hidden></div>
<div class="rail-caption" id="railCaption"></div>
<div class="rail-note" id="railNote" hidden></div>
<div id="railPreviewLink"></div>
</aside>
</div>
<script id="phasesData" type="application/json">__JSON_PHASES__</script>
<script id="summaryData" type="application/json">__JSON_SUMMARY__</script>
<script id="sectionsData" type="application/json">__JSON_SECTIONS__</script>
<script id="sectionStatesData" type="application/json">__JSON_SECTION_STATES__</script>
<script id="phoneData" type="application/json">__JSON_PHONE__</script>
<script nonce="__ATTR_CSP_NONCE__">
(function () {
var phases = JSON.parse(document.getElementById('phasesData').textContent);
var summary = JSON.parse(document.getElementById('summaryData').textContent);
var sections = JSON.parse(document.getElementById('sectionsData').textContent);
var sectionStates = JSON.parse(document.getElementById('sectionStatesData').textContent);
var phone = JSON.parse(document.getElementById('phoneData').textContent);
// Code-owned, substituted at render time; never plan data.
var brandIcon = document.getElementById('brandLogo').getAttribute('src') || '';
var capabilities = __JSON_CAPABILITIES__;
// The phone's app area in points, between its status bar and home indicator (phone-shell.js).
var APP_AREA = __JSON_PHONE_APP_AREA__;
// The user's display name; JSON-encoded at render time and only ever used as text.
var appName = __JSON_APP_NAME__;
var STATUS_CLASS = {
done: 'is-done', active: 'is-active', failed: 'is-failed',
skipped: 'is-skipped', pending: 'is-pending'
};
var STATUS_CHIP = {
done: 'chip chip-done', active: 'chip chip-active',
failed: 'chip chip-failed', skipped: 'chip', pending: 'chip'
};
var STATUS_LABEL = {
done: 'complete', active: 'in progress', failed: 'failed',
skipped: 'not needed', pending: 'pending'
};
function el(tag, className, text) {
var node = document.createElement(tag);
if (className) node.className = className;
// textContent everywhere: phase notes are author-written today, but keeping the whole
// tree as text means a future free-text note can never become markup.
if (text !== undefined) node.textContent = text;
return node;
}
/**
* Each gated section is written to this page while it is still a *proposal*, so the user can
* read the rendered diagram before answering the gate in the terminal. The banner says which
* state it is in; without it a proposal and an approved decision look identical.
*/
function approvalBanner(containerId, sectionName, proposedText) {
var container = document.getElementById(containerId);
if (!container) return;
container.textContent = '';
var state = sectionStates[sectionName];
if (!state) return;
var banner = el('div', 'approval approval-' + state);
banner.appendChild(el('span', 'approval-dot'));
banner.appendChild(el('span', null, state === 'proposed'
? (proposedText || 'Proposed \u2014 review this, then answer the approval prompt in your terminal')
: 'Approved'));
container.appendChild(banner);
}
function facts(containerId, rows) {
var container = document.getElementById(containerId);
container.textContent = '';
var present = rows.filter(function (row) {
if (Array.isArray(row[1])) return row[1].length > 0;
return row[1] !== undefined && row[1] !== null && row[1] !== '';
});
if (!present.length) {
container.appendChild(el('div', 'empty', 'Not captured yet.'));
return;
}
present.forEach(function (row) {
var card = el('div', 'fact');
card.appendChild(el('div', 'fact-label', row[0]));
var value;
if (Array.isArray(row[1])) {
value = el('div', 'fact-value' + (row[2] ? ' mono' : ''));
value.appendChild(bullets(row[1]));
} else {
value = el('div', 'fact-value' + (row[2] ? ' mono' : ''), String(row[1]));
}
// row[3] renders the value in the typeface it names, so a font choice is something the
// reader can see rather than a string they have to imagine - the same reason the palette
// shows swatches instead of hex codes.
if (row[3]) applyFontFamily(value, row[3]);
card.appendChild(value);
container.appendChild(card);
});
}
function list(value) {
return Array.isArray(value) && value.length ? entryNames(value).join(', ') : '';
}
/**
* Render an element in a plan-named typeface.
*
* The name comes from the plan, so it is not interpolated into CSS unchecked: anything outside
* letters, digits, space, hyphen and period is rejected outright rather than escaped, which
* keeps a crafted value from closing the quoted family and appending further declarations.
* A generic fallback follows the family so an uninstalled font degrades to the system UI face
* instead of rendering as the browser default serif.
*/
function applyFontFamily(node, family) {
var name = String(family == null ? '' : family).trim();
if (!name || !/^[A-Za-z0-9 .-]+$/.test(name)) return;
node.style.fontFamily = '"' + name + '", system-ui, sans-serif';
}
/**
* Render an array as a bulleted list.
*
* Several of these fields are genuinely enumerable - a feature list, the distinct rules that
* make up an offline decision - and joining them with commas produced a paragraph nobody could
* scan. Items go in as textContent, so a free-text feature can never become markup.
*/
function bullets(items, className) {
var ul = el('ul', 'bullets' + (className ? ' ' + className : ''));
items.forEach(function (item) {
ul.appendChild(el('li', null, entryLabel(item)));
});
return ul;
}
/**
* Capabilities and connectors are recorded either as a bare name or as `{ name, reason }`.
* `/create-mobile-app` asks for the reason, but an older plan or a partial write can carry
* only the name, so every list of them has to accept both shapes. Going through String()
* instead is what put "[object Object]" on the overview.
*/
function entryLabel(entry) {
if (typeof entry === 'string') return entry;
if (entry && typeof entry === 'object' && entry.name) return String(entry.name);
return '';
}
function entryNames(entries) {
return (entries || []).map(entryLabel).filter(Boolean);
}
/**
* Split author-written prose into the paragraphs it was written as.
*
* The plan records a rationale as one string with blank lines between points. One chunk means
* the author wrote a single paragraph, and forcing that into a one-item list reads worse than
* leaving it as prose - so the caller decides based on how many chunks come back.
*/
function paragraphs(value) {
return String(value == null ? '' : value)
.split(/\n\s*\n/)
.map(function (part) { return part.replace(/\s+/g, ' ').trim(); })
.filter(Boolean);
}
/**
* Render a mermaid source into a container, or show its definition if that is impossible.
*
* Both diagrams go through here. They used to differ - the ER called mermaid.render() while
* the screen graph relied on startOnLoad - so turning startOnLoad off to control ER rendering
* silently left the screen graph as raw source. One path means one behaviour.
*/
function renderMermaid(containerId, source, emptyText, onRendered) {
var container = document.getElementById(containerId);
container.textContent = '';
if (!source) {
container.appendChild(el('div', 'empty', emptyText));
return;
}
var panel = el('div', 'diagram');
container.appendChild(panel);
if (typeof mermaid === 'undefined') {
showSource(container, panel, source, { message: 'Mermaid could not load' });
return;
}
try {
mermaid.render('mmd' + Math.random().toString(36).slice(2), source).then(function (result) {
// Mermaid's output is built from plan data (table and screen names), so it goes through
// the same cleaning as the mockups rather than straight into the document.
// Its own stylesheet is kept: Mermaid scopes every rule to this SVG's id and builds them
// from the theme, not from plan data, and without it the diagram renders unstyled.
panel.textContent = '';
panel.appendChild(sanitizeMockup(result.svg, { keepStyle: true }));
if (onRendered) onRendered(panel);
}).catch(function (error) {
showSource(container, panel, source, error);
});
} catch (error) {
showSource(container, panel, source, error);
}
}
function showSource(container, panel, source, error) {
panel.textContent = '';
panel.appendChild(el('pre', null, source));
// Say why. A silent fall back to source reads like an intended view rather than a failure.
container.appendChild(el('div', 'diagram-note',
'Diagram could not be drawn, showing its definition instead'
+ (error && error.message ? ' \u2014 ' + error.message : '') + '.'));
}
/**
* Power Apps Mobile Preview - the app that scans the Metro QR and runs the build on a device.
* Locale-neutral forms: the plan is a file people share, and a hard-coded storefront would
* bounce a reader in another market through a redirect or an unavailable page.
*/
var STORE_LINKS = [
{
kicker: 'Download on the',
name: 'App Store',
href: 'https://apps.apple.com/app/id6753083462',
// Apple mark, single path, filled with the button's text colour.
logo: '<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M16.365 1.43c0 1.14-.47 2.2-1.24 2.98-.83.85-2.19 1.5-3.31 1.41-.13-1.1.44-2.26 1.2-3.01.85-.87 2.31-1.5 3.35-1.38zM20.5 17.1c-.5 1.15-.74 1.66-1.38 2.68-.9 1.42-2.16 3.19-3.73 3.2-1.39.01-1.75-.91-3.64-.9-1.89.01-2.28.92-3.67.9-1.57-.01-2.77-1.6-3.67-3.02-2.52-3.98-2.78-8.65-1.23-11.13 1.1-1.76 2.84-2.79 4.47-2.79 1.66 0 2.7.91 4.08.91 1.33 0 2.14-.91 4.06-.91 1.45 0 2.99.79 4.09 2.16-3.6 1.97-3.02 7.11.62 8.9z"/></svg>'
},
{
kicker: 'GET IT ON',
name: 'Google Play',
href: 'https://play.google.com/store/apps/details?id=com.microsoft.PreviewApp',
// Play mark: four faces of the same folded triangle, so the colours are fixed rather
// than inherited - it is the mark's identity, not decoration.
logo: '<svg viewBox="0 0 24 24" aria-hidden="true">'
+ '<path fill="#00A0FF" d="M3.06 1.54A1.5 1.5 0 0 0 2.5 2.72v18.12c0 .47.22.89.56 1.18l10.24-10.24L3.06 1.54z"/>'
+ '<path fill="#00E676" d="M3.06 1.54a1.5 1.5 0 0 1 1.5-.06l12.2 6.9-3.46 3.4L3.06 1.54z"/>'
+ '<path fill="#FFCE00" d="M16.76 8.38l3.5 1.98c1 .57 1 1.7 0 2.27l-3.5 1.98-3.46-3.11 3.46-3.12z"/>'
+ '<path fill="#FF3A44" d="M4.56 22.08a1.5 1.5 0 0 1-1.5-.06l10.24-10.24 3.46 3.4-12.2 6.9z"/>'
+ '</svg>'
}
];
/**
* Link out to the full-size mockups instead of opening them in a browser tab mid-run. The
* carousel already shows these screens in the phone frame, so a tab that steals focus while
* the user is reading the plan is an interruption rather than information.
*/
function railPreviewLink() {
// The carousel shows HTML mockups rendered from the screen specs, not the built Tamagui
// screens. They are close enough to approve a layout on and not close enough to be held to,
// so say which one the user is looking at - but only while they are looking at it.
var note = document.getElementById('railNote');
if (note) {
var showing = phone.stage === 'screens' && phone.screens && phone.screens.length;
note.textContent = showing
? 'Plan-time mockups. The built app will differ in places from what is shown here.'
: '';
note.hidden = !showing;
}
var container = document.getElementById('railPreviewLink');
if (!container) return;
container.textContent = '';
function add(href, label, rel) {
if (!href) return;
var link = el('a', 'rail-link', label);
link.setAttribute('href', href);
link.setAttribute('target', '_blank');
link.setAttribute('rel', rel || 'noopener');
container.appendChild(link);
}
// The phone draws the live app at phone width; a tab gives it the whole window and the
// browser's dev tools. noreferrer as well as noopener: it is a different origin from this
// page, and the plan's own path is nothing the app needs to see.
var live = phone.stage === 'live' && isLoopbackPreview(phone.previewUrl);
if (live) {
add(phone.previewUrl, 'Open the live preview in a browser tab \u2197', 'noopener noreferrer');
}
// From the preview gate the dev server that feeds the phone frame also serves the app to a
// real phone, so the code is offered while the browser preview is still showing. It sits
// under the frame, small, because the frame is what the user is reviewing; Step 14 moves the
// code into the frame once the app needs a signed-in host. Only an inlined PNG is drawn: the
// page's CSP admits data: images and nothing else.
var liveQr = live && isQrImage(phone.qrImage);
if (liveQr) {
var card = el('div', 'rail-qr');
var code = document.createElement('img');
code.src = phone.qrImage;
code.alt = 'Metro QR code';
// The code is the full-size link here, so the rail needs no separate link row: on a short
// window that row would land behind the footer.
if (phone.qrHref) {
var full = el('a', 'rail-qr-full');
full.setAttribute('href', phone.qrHref);
full.setAttribute('target', '_blank');
full.setAttribute('rel', 'noopener');
full.setAttribute('title', 'Open QR code full size');
full.appendChild(code);
card.appendChild(full);
} else {
card.appendChild(code);
}
var copy = el('div', 'rail-qr-copy');
copy.appendChild(el('div', 'rail-qr-title', 'Try it on your phone'));
copy.appendChild(el('div', 'rail-qr-sub',
'Scan with Power Apps Mobile Preview, on the same network as this machine.'));
var get = el('div', 'rail-qr-stores');
STORE_LINKS.forEach(function (store, index) {
if (index) get.appendChild(document.createTextNode(' \u00b7 '));
var link = el('a', null, store.name);
link.setAttribute('href', store.href);
link.setAttribute('target', '_blank');
link.setAttribute('rel', 'noopener noreferrer');
get.appendChild(link);
});
copy.appendChild(get);
card.appendChild(copy);
container.appendChild(card);
}
add(phone.previewHref || summary.screenPreviewHref, 'Open screens full size \u2197');
// The QR is already drawn in the phone; this is for scanning it larger, and it links the
// PNG rather than the inlined data URI because browsers block top-level navigation to a
// data: URL. It drops away once `.expo/` is cleaned, leaving the inlined copy.
if (!liveQr) add(phone.qrHref, 'Open QR code full size \u2197');
// The QR stage is the end of the run, and a code is useless without the app that reads it.
// Only shown here: offering a store download while the app is still being generated would
// send the user off to install something they cannot use yet.
if (phone.stage !== 'qr') return;
var stores = el('div', 'store-row');
STORE_LINKS.forEach(function (store) {
var button = el('a', 'store-btn');
button.setAttribute('href', store.href);
button.setAttribute('target', '_blank');
// noopener/noreferrer: these are the only links in the plan that leave the machine.
button.setAttribute('rel', 'noopener noreferrer');
var mark = el('span', 'store-logo');
// Code-owned constant markup - no plan data reaches it - so it may be set as markup.
mark.innerHTML = store.logo;
button.appendChild(mark);
var text = el('span', 'store-text');
text.appendChild(el('span', 'store-kicker', store.kicker));
text.appendChild(el('span', 'store-name', store.name));
button.appendChild(text);
stores.appendChild(button);
});
container.appendChild(stores);
}
// Elements that execute, navigate, or reach the network. `link`/`meta`/`base` are included
// because a mockup is a fragment of a document and must not redefine this one's head.
// Styles are permitted only in isolated screen documents and Mermaid's scoped SVG.
// Inserting a mockup stylesheet into the plan itself would let its selectors hide approvals.
// `ANIMATE` and `SET` are SVG animation elements, which can rewrite another element's `href`
// after this pass has checked it.
var MOCKUP_BANNED_TAGS = ['SCRIPT', 'IFRAME', 'OBJECT', 'EMBED', 'LINK', 'META', 'BASE', 'FORM', 'STYLE',
'ANIMATE', 'SET'];
// `javascript:` executes; `data:text/html` navigates to attacker-controlled markup with this
// document's privileges. Images as `data:` are fine and are how the QR is drawn.
var MOCKUP_BANNED_URL = /^(javascript:|data:text\/html)/i;
/**
* Make generated mockup markup inert before it enters the document.
*
* The blocks come from `/design-system`, but their text is the user's own requirements, so a
* handler or SVG payload that survived into the mockup would run when the plan is opened. The
* page's CSP already refuses unnonced scripts and inline handlers; this is the second line, so
* a policy that is ever loosened does not immediately become an execution path.
*
* Fragments use an inert `<template>`; complete screen documents use a detached DOMParser
* document so html/body attributes survive. Neither is inserted into the live plan.
*/
function sanitizeMockup(markup, options) {
var keepStyle = !!(options && options.keepStyle);
var source = String(markup == null ? '' : markup);
var content;
if (options && options.asDocument) {
content = new DOMParser().parseFromString(source, 'text/html');
} else {
var holder = document.createElement('template');
holder.innerHTML = source;
content = holder.content;
}
var nodes = content.querySelectorAll('*');
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
// `tagName` is upper case only for HTML elements. Inside inline SVG an element keeps its
// own case, so `<svg><style>` reports "style" and passed an upper-case list untouched.
var tag = String(node.tagName || '').toUpperCase();
if (MOCKUP_BANNED_TAGS.indexOf(tag) >= 0 && !(keepStyle && tag === 'STYLE')) {
if (node.parentNode) node.parentNode.removeChild(node);
continue;
}
var attrs = node.attributes;
for (var j = attrs.length - 1; j >= 0; j--) {
var name = attrs[j].name;
// Test the URL the browser will actually follow. It drops tabs and newlines from
// anywhere in a URL and leading control characters and spaces, so `java	script:`
// still navigates: https://url.spec.whatwg.org/#concept-basic-url-parser
var value = attrs[j].value.replace(/[\u0000-\u0020]/g, '');
// Every event handler, however it is spelled.
if (/^on/i.test(name)) { node.removeAttribute(name); continue; }
// Screens are static: even a safe link must not navigate the sandbox to a remote page.
// Local SVG references such as href="#check" remain available for icon rendering.
if (options && options.asDocument && /^(href|xlink:href)$/i.test(name) && value.charAt(0) !== '#') {
node.removeAttribute(name);
continue;
}
if (/^(href|src|xlink:href|action|formaction)$/i.test(name) && MOCKUP_BANNED_URL.test(value)) {
node.removeAttribute(name);
}
}
}
return content;
}
function previewScreens(markup) {
var source = sanitizeMockup(markup, { keepStyle: true, asDocument: true });
var tabs = Array.from(source.querySelectorAll('[data-screen]'));
return Array.from(source.querySelectorAll('.screen')).map(function (entry) {
var root = source.documentElement.cloneNode(false);
var head = document.createElement('head');
source.querySelectorAll('style').forEach(function (style) { head.appendChild(style.cloneNode(true)); });
var body = source.body.cloneNode(false);
var selected = entry.cloneNode(true);
selected.classList.add('active');
selected.removeAttribute('hidden');
selected.style.setProperty('display', 'flex', 'important');
// Preserve ancestor classes and inline tokens, but leave out the gallery's tabs, labels,
// status bar and home indicator: the plan already supplies its own phone shell.
for (var ancestor = entry.parentElement; ancestor && ancestor !== source.body; ancestor = ancestor.parentElement) {
var wrapper = ancestor.cloneNode(false);
wrapper.appendChild(selected);
selected = wrapper;
}
body.appendChild(selected);
root.appendChild(head);
root.appendChild(body);
var reset = document.createElement('style');
// The gallery's page and phone backgrounds are dark. Scaled into the phone, the frame's last
// partial pixel row samples them and draws a grey rule under the screen, so they go too.
reset.textContent = 'html,body{width:100%;height:100%;margin:0!important;padding:0!important;min-height:0!important;overflow:hidden;background:transparent!important;}'
+ '.phone{width:100%!important;height:100%!important;margin:0!important;padding:0!important;border:0!important;border-radius:0!important;box-shadow:none!important;background:transparent!important;}'
+ '.screen-wrap{border-radius:0!important;}';
head.appendChild(reset);
var tab = tabs.find(function (button) { return button.getAttribute('data-screen') === entry.id; });
return {
name: (tab && tab.textContent.trim()) || entry.getAttribute('data-name') || entry.getAttribute('aria-label') || entry.id,
html: '<!DOCTYPE html>' + root.outerHTML,
};
});
}
function mockupDocument(markup) {
var source = sanitizeMockup(markup, { keepStyle: true, asDocument: true });
var policy = source.createElement('meta');
policy.setAttribute('http-equiv', 'Content-Security-Policy');
policy.setAttribute('content', "default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src data:; font-src data:; base-uri 'none'; form-action 'none'");
source.head.prepend(policy);
return '<!DOCTYPE html>' + source.documentElement.outerHTML;
}
/**
* Re-check the live-preview URL before it becomes a frame `src`.
*
* `app-docs.js` already refuses anything but the local Expo web server, and the CSP `frame-src`
* names only the two loopback hosts. This is the third line, so a plan state edited by hand or
* written by a future bug still cannot frame something else. A prefix test is not enough:
* `http://localhost:8082@example.com/` starts with `http://localhost:`, but everything before
* the `@` is userinfo and its host is example.com. So the port must be followed by `/` or the
* end of the string, which leaves no room for userinfo, and a query or fragment is refused as
* normalizePreviewUrl refuses them.
* https://url.spec.whatwg.org/#concept-basic-url-parser
*/
function isLoopbackPreview(url) {
return typeof url === 'string'
&& /^http:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}(?:\/[^\s?#\\]*)?$/.test(url);
}
function isQrImage(value) {
return typeof value === 'string' && value.indexOf('data:image/png;base64,') === 0;
}
/**
* Scale the phone's app area into the device screen instead of reflowing it into the narrower
* rail. The carousel and the live preview both use it, so a mockup and the running app are laid
* out at the same phone width. Mockups are drawn for exactly the app area, so they keep that
* size and are letterboxed if the box ever differs. `fillHeight` gives the running app whatever
* height fills the box, as a real phone of another size would.
*/
function fitViewport(box, viewport, fillHeight) {
var fit = function () {
var height = fillHeight ? box.clientHeight * APP_AREA.width / box.clientWidth : APP_AREA.height;
var scale = Math.min(box.clientWidth / APP_AREA.width, box.clientHeight / height);
viewport.style.height = height + 'px';
viewport.style.transform = 'scale(' + scale + ')';
viewport.style.left = (box.clientWidth - APP_AREA.width * scale) / 2 + 'px';
viewport.style.top = (box.clientHeight - height * scale) / 2 + 'px';
};
fit();
window.addEventListener('resize', fit);
if (typeof ResizeObserver !== 'undefined') new ResizeObserver(fit).observe(box);
}
// The live preview's frame, once drawn. The reload guard at the bottom of the page watches it.
var liveFrame = null;
function renderPhone() {
if (phone.stage === 'screens' && phone.previewHtml) phone.screens = previewScreens(phone.previewHtml);
railPreviewLink();
var screen = document.getElementById('deviceScreen');
var showsLive = phone.stage === 'live' && isLoopbackPreview(phone.previewUrl);
// The status bar's ink: dark on every light stage, and the running app's own scheme when live.
document.getElementById('device').setAttribute('data-tone', showsLive ? 'system' : 'light');
var title = document.getElementById('railTitle');
var caption = document.getElementById('railCaption');
var controls = document.getElementById('railControls');
screen.textContent = '';
caption.textContent = '';
controls.textContent = '';
controls.hidden = true;
if (phone.stage === 'screens' && phone.previewHtml && !phone.screens.length) {
title.textContent = 'Screen preview unavailable';
caption.textContent = 'The preview contains no .screen blocks. Regenerate _plan_preview.html.';
console.error(caption.textContent);
return;
}
if (phone.stage === 'qr' && phone.qrImage) {
title.textContent = 'Open it on your phone';
var qr = el('div', 'qr');
var img = document.createElement('img');
img.src = phone.qrImage;
img.alt = 'Metro QR code';
qr.appendChild(img);
qr.appendChild(el('div', 'qr-title', 'Scan to run the app'));
qr.appendChild(el('div', 'qr-sub', 'Open the Power Apps Mobile Preview app and scan this code. Your phone and this machine need to be on the same network.'));
if (phone.qrUrl) qr.appendChild(el('div', 'qr-url', phone.qrUrl));
screen.appendChild(qr);
caption.textContent = 'Edits hot-reload straight onto the device.';
return;
}
// An unchecked URL falls through to the building animation rather than drawing a frame.
if (showsLive) {
title.textContent = 'Live preview';
var live = el('div', 'live');
var liveBox = el('div', 'device-app');
liveFrame = document.createElement('iframe');
// allow-scripts: this is the real app, and it is nothing without its JavaScript.
// allow-same-origin: normally unsafe beside allow-scripts, because a same-origin frame can
// remove its own sandbox. Here the frame is cross-origin to this file:// page, so it keeps
// its own http://localhost origin and still cannot reach the plan. Without it the frame
// gets an opaque origin and loses localStorage, IndexedDB and cookies, which Expo web and
// its sign-in rely on.
// allow-forms and allow-popups: the app's forms submit, and sign-in may open a window.
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox
liveFrame.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-popups');
liveFrame.setAttribute('referrerpolicy', 'no-referrer');
liveFrame.setAttribute('title', 'Live preview of ' + appName);
liveFrame.setAttribute('src', phone.previewUrl);
liveBox.appendChild(liveFrame);
live.appendChild(liveBox);
screen.appendChild(live);
fitViewport(liveBox, liveFrame, true);
caption.textContent = 'Sample data. Edits hot-reload here.';
return;
}
if (phone.stage === 'screens' && phone.screens && phone.screens.length) {
title.textContent = 'Your screens';
var index = 0;
var car = el('div', 'car');
var frame = el('div', 'device-app');
var viewport = document.createElement('iframe');
viewport.setAttribute('sandbox', '');
viewport.setAttribute('referrerpolicy', 'no-referrer');
frame.appendChild(viewport);
var nav = el('div', 'car-nav');
var prev = el('button', 'car-btn', '\u2039');
prev.setAttribute('aria-label', 'Previous screen');
var next = el('button', 'car-btn', '\u203a');
next.setAttribute('aria-label', 'Next screen');
var dots = el('div', 'car-dots');
nav.appendChild(prev); nav.appendChild(dots); nav.appendChild(next);
car.appendChild(frame);
screen.appendChild(car);
controls.appendChild(nav);
controls.hidden = false;
fitViewport(frame, viewport);
var show = function (i) {
index = Math.max(0, Math.min(phone.screens.length - 1, i));
var current = phone.screens[index] || {};
// No allow-scripts or allow-same-origin: the retained stylesheet belongs only to this
// frame. The child CSP also blocks fetches, including CSS imports and external images.
viewport.setAttribute('title', current.name || 'Screen preview');
viewport.srcdoc = mockupDocument(current.html);
caption.textContent = (current.name ? current.name + ' \u00b7 ' : '')
+ (index + 1) + ' of ' + phone.screens.length;
prev.disabled = index === 0;
next.disabled = index === phone.screens.length - 1;
dots.textContent = '';
phone.screens.forEach(function (unused, i2) {
dots.appendChild(el('span', 'car-dot' + (i2 === index ? ' on' : '')));
});
};
prev.addEventListener('click', function () { show(index - 1); });
next.addEventListener('click', function () { show(index + 1); });
show(0);
return;
}
title.textContent = 'Building your app';
var bld = el('div', 'bld');
var orbit = el('div', 'bld-orbit');
orbit.appendChild(el('div', 'bld-ring'));
orbit.appendChild(el('div', 'bld-ring'));
var core = el('div', 'bld-core');
var logo = document.createElement('img');
logo.src = brandIcon;
logo.alt = '';
core.appendChild(logo);
orbit.appendChild(core);
bld.appendChild(orbit);
bld.appendChild(el('div', 'bld-title', 'Step ' + Math.min(summary.done + 1, summary.total) + ' of ' + summary.total));
bld.appendChild(el('div', 'bld-msg', summary.currentTitle));
var bar = el('div', 'bld-bar');
var fill = el('span');
fill.style.width = summary.percent + '%';
bar.appendChild(fill);
bld.appendChild(bar);
var caps = el('div', 'bld-caps');
capabilities.forEach(function (label, i) {
var chip = el('span', 'bld-cap', label);
chip.style.animationDelay = (0.25 + i * 0.16) + 's';
caps.appendChild(chip);
});
bld.appendChild(caps);
screen.appendChild(bld);
// A recorded preview address on the `building` stage means the preview has already run and
// the app is now connecting real data with no QR code to show yet (the dev server found no
// LAN address, so the phone app waits for the dev server step). The browser frame has no
// signed-in Power Apps host, so the wired app would only show errors there, and nothing frames
// or links it; the caption says what comes next instead. Plans from older runs, which stopped the
// server at Step 14, land here as well. A `live` stage whose address failed the page check lands here too,
// and keeps the default caption.
caption.textContent = phone.stage === 'building' && phone.previewUrl
? 'Connecting real data. The QR code to open the app on your phone appears here next.'
: 'A live preview of your app appears here once its screens are built.';
}
/**
* Surface a blocked run the way `/create-site` does: a persistent pill, not a toast, because
* the answer is wanted in the terminal and the user may be reading another tab when the prompt
* appears. Dismissal is keyed to the prompt text, so closing one gate's banner does not
* suppress the next gate's, and it is forgotten once nothing is waiting.
*/
// Kept in sessionStorage because the page reloads itself every few seconds; a dismissal held
// only in memory came back on the next reload.
var STORE_DISMISSED = 'mobile-plan-dismissed-prompt';
var dismissedPrompt = null;
try { dismissedPrompt = sessionStorage.getItem(STORE_DISMISSED); } catch (e) { /* private mode */ }
function renderInputBanner() {
var banner = document.getElementById('inputBanner');
if (!banner) return;
var prompt = summary.awaitingInput || '';
if (!prompt) {
dismissedPrompt = null;
try { sessionStorage.removeItem(STORE_DISMISSED); } catch (e) { /* private mode */ }
}
document.getElementById('inputBannerPrompt').textContent = prompt;
banner.hidden = !prompt || dismissedPrompt === prompt;
}
function renderOverview() {
approvalBanner('approval-architecture', 'architecture');
document.getElementById('summaryBox').textContent = summary.narrative;
document.getElementById('progressFill').style.width = summary.percent + '%';
document.getElementById('progressCurrent').textContent = summary.currentTitle;
document.getElementById('progressCount').textContent =
summary.done + ' of ' + summary.total + ' steps done' +
(summary.failed ? ' · ' + summary.failed + ' failed' : '');
document.getElementById('statDone').textContent = summary.done;
document.getElementById('statRemaining').textContent = summary.total - summary.done;
document.getElementById('statSkipped').textContent = summary.skipped;
document.getElementById('pillProgress').textContent =
'Step ' + Math.min(summary.done + 1, summary.total) + ' of ' + summary.total;
var env = sections.environment || {};
facts('environmentFacts', [
['Environment', env.displayName],
['Environment ID', env.environmentId, true],
['Environment URL', env.environmentUrl, true],
['Tenant', env.tenantId, true],
['Publisher prefix', env.publisherPrefix, true],
['App registration', (sections.auth || {}).status]
]);
planDocLink('overviewPlanDoc', 'Read the full plan');
var arch = sections.architecture || {};
facts('architectureFacts', [
['Data platform', arch.dataPlatform],
['Device capabilities', entryNames(arch.nativeCapabilities)],
['Connectors', entryNames(arch.connectors)]
]);
}
function renderRequirements() {
var req = sections.requirements || {};
document.getElementById('briefBox').textContent =
req.brief || 'The confirmed feature brief will appear here once requirements are agreed.';
facts('requirementsFacts', [
['App name', req.appName],
['Folder', req.slug, true],
['Platforms', list(req.platforms) || req.platforms],
['Aesthetic', req.aesthetic],
['Industry', req.industry],
['Features', req.features]
]);
}
var REASON_LABEL = {
new: 'Why create it:', reused: 'Why reuse it:', modified: 'Why extend it:',
};
var STATUS_ALIAS = { create: 'new', created: 'new', extend: 'modified', modify: 'modified', reuse: 'reused', existing: 'reused' };
function tableStatus(table) {
var raw = String(table.status || table.action || 'new').toLowerCase();
return STATUS_ALIAS[raw] || (['new', 'modified', 'reused'].indexOf(raw) >= 0 ? raw : 'new');
}
// Mermaid's erDiagram grammar accepts a narrow ATTRIBUTE_WORD. Dataverse type names such as
// "Yes/No" contain characters that abort the whole parse, so strip anything outside the
// allowed set rather than letting one column blank the diagram.
function erWord(value) {
return String(value == null ? '' : value).replace(/[^A-Za-z0-9_]/g, '_');
}
function erLabel(value) {
// Newlines, quotes and angle brackets all end a mermaid label early. Truncate too: an
// over-long label wraps the box and pushes the diagram off screen.
return String(value == null ? '' : value)
.replace(/[\r\n]+/g, ' ')
.replace(/"/g, "'")
.replace(/[<>]/g, '')
.slice(0, 40);
}
/**
* Emit one of exactly three known-good cardinality tokens - never a value from the plan.
* `native-app-plan.md` writes human shorthand ("N:1"), and a single unrecognised token aborts
* the whole erDiagram parse, which is how a complete model ends up displayed as source. An
* allowlist makes an unrenderable diagram impossible rather than merely unlikely.
*/
function erCardinality(value) {
var raw = String(value == null ? '' : value).trim().toLowerCase();
if (raw === '1:1' || raw === '||--||' || raw === 'one-to-one') return '||--||';
if (raw === 'n:n' || raw === 'm:n' || raw === '}o--o{' || raw === 'many-to-many') return '}o--o{';
if (raw === 'n:1' || raw === 'm:1' || raw === '}o--||' || raw === 'many-to-one') return '}o--||';
// One-to-many is what a lookup column produces, so it is the safe default for anything else.
return '||--o{';
}
function buildErDiagram(tables, compact) {
var lines = ['erDiagram'];
var ids = {};
tables.forEach(function (table) {
var name = String(table.logicalName || table.name || '');
var id = erWord(name).toUpperCase();
ids[name] = id;
lines.push(' ' + id + '["' + erLabel(name) + (table.displayName ? ' (' + erLabel(table.displayName) + ')' : '') + '"] {');
var columns = table.columns || [];
if (compact) columns = columns.filter(function (c) { return (c.key || '') === 'PK'; });
columns.forEach(function (column) {
if (typeof column === 'string') { lines.push(' string ' + erWord(column)); return; }
var key = column.key === 'PK' || column.key === 'FK' ? ' ' + column.key : '';
lines.push(' ' + (erWord(column.type) || 'string') + ' ' + erWord(column.logicalName || column.name) + key);
});
lines.push(' }');
});
var seen = {};
tables.forEach(function (table) {
var from = ids[String(table.logicalName || table.name || '')];
(table.relationships || []).forEach(function (rel) {
var to = ids[rel.relatedTable];
// A relationship whose related table is not in the model has nowhere to point, so it is
// skipped. A table relating to itself is not that: parent account, manager, and category
// hierarchies are ordinary Dataverse models, and Mermaid draws the same entity on both
// ends, so dropping them made the plan misstate the approved model.
if (!from || !to) return;
// Both tables declare the same relationship from their own side, so the reverse
// declaration is a duplicate and is suppressed - but only for that same relationship.
// The name is part of the identity, or a second lookup between the same two tables is
// lost.
var pairKey = [from, to].sort().join('|') + '|' + erLabel(rel.name || 'related');
if (seen[pairKey]) return;
seen[pairKey] = true;
lines.push(' ' + from + ' ' + erCardinality(rel.cardinality) + ' ' + to + ' : "' + erLabel(rel.name || 'related') + '"');
});
});
return lines.join('\n');
}
/**
* Derive the screen graph from the approved screen list.
*
* Deliberately NOT read from a planner-authored mermaid string. The ER diagram used to work
* that way and a single bad token rendered the whole model as source; the same field here was
* never populated by anything, so the graph silently showed its empty state instead. Route
* nesting is already present in `list[]`, so deriving the graph from the same data the cards
* render means the two cannot disagree, and there is no token the plan can supply that breaks
* the parse.
*/
function buildScreenGraph(items, navigation) {
var nodes = items.map(function (screen, index) {
var route = String(screen.route || '');
return {
id: 'S' + index,
// Normalize to a trailing slash so prefix tests are unambiguous: without it
// "/(app)/sites" would parent "/(app)/sites-admin" as well as "/(app)/sites/[id]".
prefix: route.replace(/\/+$/, '') + '/',
name: erLabel(screen.name || route || 'Screen'),
// Everything under the (app) route group hangs off the signed-in shell; anything else
// (login, onboarding) is an entry point that leads into it.
inShell: route.indexOf('/(app)') === 0
};
});
nodes.forEach(function (node) {
var parent = null;
nodes.forEach(function (other) {
if (other === node || node.prefix === other.prefix) return;
if (node.prefix.indexOf(other.prefix) !== 0) return;
// The deepest matching route is the real parent: /a/[id]/scan belongs to /a/[id], not /a.
if (!parent || other.prefix.length > parent.prefix.length) parent = other;
});
node.parent = parent;
});
// `navigation` is a full sentence ("Bottom tabs (Today, Schedule...) with a stack pushed
// from each tab"). erLabel's hard 40-char cut would slice it mid-word, so take the leading
// phrase before the first bracket or full stop, which is the shell's actual name.
var shellLabel = erLabel(String(navigation || '').split(/[(.]/)[0].trim()) || 'App shell';
var lines = ['flowchart LR'];
lines.push(' SHELL{{"' + shellLabel + '"}}');
nodes.forEach(function (node) {
lines.push(' ' + node.id + '["' + node.name + '"]');
});
nodes.forEach(function (node) {
if (node.parent) lines.push(' ' + node.parent.id + ' --> ' + node.id);
else if (node.inShell) lines.push(' SHELL --> ' + node.id);
else lines.push(' ' + node.id + ' --> SHELL');
});
return lines.join('\n');
}
/**
* Tint the rendered entity boxes by status so the diagram carries the same new/extended/reused
* meaning as the legend and the cards. Mermaid v11 prefixes node ids with the svg element id
* (erSvg123-entity-INSPECTION-0), so match on the suffix rather than an exact id.
*/
function colorErDiagram(container, tables) {
var svg = container.querySelector('svg');
if (!svg) return;
// Header, both alternating row bands, and the dividers between them. Tinting the header
// alone left every table's body the same lavender Mermaid ships, so the status read as a
// stripe at the top rather than as a property of the table - which is how a reader loses
// track of which table is which once the diagram is more than a screen tall. Matches the
// power-pages data-model plan, which these values are taken from.
var fills = { new: '#d0e4f5', modified: '#f5dcc8', reused: '#c8e6c9' };
var rowOddFills = { new: '#e8f2fc', modified: '#fdf0e6', reused: '#e8f5e9' };
var rowEvenFills = { new: '#f0f7fe', modified: '#fef6ee', reused: '#f1f9f1' };
var strokes = { new: '#0078d4', modified: '#ca5010', reused: '#107c10' };
var statusById = {};
tables.forEach(function (table) {
var id = erWord(table.logicalName || table.name || '').toUpperCase();
statusById[id] = tableStatus(table);
});
svg.querySelectorAll('g.node').forEach(function (node) {
var match = (node.getAttribute('id') || '').match(/entity-(.+)-\d+$/);
if (!match) return;
var status = statusById[match[1]];
if (!status) return;
var group = node.querySelector('.outer-path') || node.children[0];
if (!group || group.tagName !== 'g') return;
var paths = group.querySelectorAll('path');
if (paths[0]) paths[0].setAttribute('fill', fills[status]);
if (paths[1]) {
paths[1].setAttribute('stroke', strokes[status]);
paths[1].setAttribute('stroke-width', '2');
}
node.querySelectorAll('.row-rect-odd, .row-rect-even').forEach(function (row) {
var fill = row.classList.contains('row-rect-odd') ? rowOddFills : rowEvenFills;
var rect = row.querySelector('path');
if (rect) rect.setAttribute('fill', fill[status]);
});
node.querySelectorAll('.divider path').forEach(function (line) {
// A divider Mermaid drew as `none` is a spacer, not a rule; leaving it alone keeps the
// box from gaining lines it was not meant to have.
if (line.getAttribute('stroke') !== 'none') line.setAttribute('stroke', strokes[status]);
});
});
}
function drawEr(source, tables) {
renderMermaid('erContainer', source,
'No data model \u2014 this app uses connectors only.',
function (panel) { colorErDiagram(panel, tables || []); });
}
function renderDataModel() {
approvalBanner('approval-datamodel', 'dataModel');
var model = sections.dataModel || {};
var tables = model.tables || [];
var counts = { new: 0, modified: 0, reused: 0 };
tables.forEach(function (table) { counts[tableStatus(table)] += 1; });
document.getElementById('statNew').textContent = counts.new;
document.getElementById('statReused').textContent = counts.reused;
document.getElementById('statModified').textContent = counts.modified;
// Built from the table data so the ER stays in step with what was actually approved. A
// hand-written `mermaid` source is drawn only when the plan has no structured tables.
var compact = false;
function paint() {
drawEr(tables.length ? buildErDiagram(tables, compact) : (model.mermaid || ''), tables);
}
paint();
var toggle = document.getElementById('erCompactBtn');
toggle.addEventListener('click', function () {
compact = !compact;
toggle.classList.toggle('active', compact);
paint();
});
var container = document.getElementById('tablesContainer');
container.textContent = '';
if (!tables.length) {
container.appendChild(el('div', 'empty',
model.connectorOnly
? 'This app has no Dataverse tables — it runs on connectors. See the Capabilities tab.'
: 'No tables approved yet.'));
return;
}
tables.forEach(function (table) {
var status = tableStatus(table);
var entity = el('div', 'entity ' + status);
var head = el('div', 'entity-head');
head.appendChild(el('span', 'expand-chevron', '\u276f'));
head.appendChild(el('span', 'entity-name', table.logicalName || table.name || ''));
if (table.displayName) head.appendChild(el('span', 'entity-display', table.displayName));
head.appendChild(el('span', 'entity-spacer'));
head.appendChild(el('span', 'status-pill status-' + status, status === 'modified' ? 'extended' : status));
// A real button, not a clickable div: the row is a disclosure control, and a div cannot
// be focused or activated from the keyboard.
head.setAttribute('role', 'button');
head.setAttribute('tabindex', '0');
head.setAttribute('aria-expanded', 'false');
var toggle = function () {
var open = entity.classList.toggle('open');
head.setAttribute('aria-expanded', open ? 'true' : 'false');
};
head.addEventListener('click', toggle);
head.addEventListener('keydown', function (event) {
if (event.key !== 'Enter' && event.key !== ' ') return;
// Space scrolls the page by default, which is not what a disclosure control should do.
event.preventDefault();
toggle();
});
entity.appendChild(head);
// Visible without expanding: what the table holds, and why it is being created, reused or
// extended. The columns and relationships below are detail; this is the decision.
if (table.purpose || table.reason) {
var summary = el('div', 'entity-summary');
if (table.purpose) summary.appendChild(el('div', 'step-detail', table.purpose));
if (table.reason) {
var why = el('div', 'cap-why');
why.appendChild(el('strong', null, REASON_LABEL[status] + ' '));
why.appendChild(document.createTextNode(table.reason));
summary.appendChild(why);
}
entity.appendChild(summary);
}
var body = el('div', 'entity-body');
var columns = table.columns || [];
if (columns.length) {
var tableEl = el('table', 'col-table');
var thead = el('thead');
var headRow = el('tr');
['Column', 'Display', 'Type', 'Key'].forEach(function (label) {
headRow.appendChild(el('th', null, label));
});
thead.appendChild(headRow);
tableEl.appendChild(thead);
var tbody = el('tbody');
columns.forEach(function (column) {
var normalized = typeof column === 'string' ? { logicalName: column } : column;
var row = el('tr');
row.appendChild(el('td', 'col-logical', normalized.logicalName || normalized.name || ''));
row.appendChild(el('td', null, normalized.displayName || ''));
var typeCell = el('td');
if (normalized.type) typeCell.appendChild(el('span', 'type-chip', normalized.type));
row.appendChild(typeCell);
var keyCell = el('td');
if (normalized.key === 'PK' || normalized.key === 'FK') {
keyCell.appendChild(el('span', 'key-badge key-' + normalized.key, normalized.key));
}
row.appendChild(keyCell);
tbody.appendChild(row);
});
tableEl.appendChild(tbody);
body.appendChild(tableEl);
}
(table.relationships || []).forEach(function (rel) {
var line = el('div', 'rel-line');
line.appendChild(el('span', 'rel-arrow', '\u2192 '));
line.appendChild(document.createTextNode((rel.name || 'related') + ' \u00b7 ' + rel.relatedTable));
body.appendChild(line);
});
entity.appendChild(body);
container.appendChild(entity);
});
}
/**
* Capabilities carry a reason, not just a name. "Camera" tells the user nothing; "Camera -
* technicians photograph meter damage at the visit" tells them whether the choice was right,
* which is the only question an approval gate is really asking.
*
* Accepts a plain string too, so an older plan that recorded bare names still renders.
*/
function capabilityCards(containerId, entries, kind, emptyText) {
var container = document.getElementById(containerId);
container.textContent = '';
var list = (entries || []).map(function (entry) {
return typeof entry === 'string' ? { name: entry } : (entry || {});
}).filter(function (entry) { return entryLabel(entry); });
if (!list.length) {
container.appendChild(el('div', 'empty', emptyText));
return;
}
list.forEach(function (entry) {
var card = el('div', 'cap' + (kind === 'connector' ? ' cap-connector' : ''));
var head = el('div', 'cap-head');
head.appendChild(permissionIcon(entry.name, kind === 'connector' ? 'plug' : 'device', 'cap-icon'));
head.appendChild(el('span', 'cap-name', entry.name));
// No "device"/"connector" pill: the section heading above already says which list this is,
// and the coloured left border carries it visually. A label that only repeats its heading
// is noise on every row. The offline card keeps its pill because the sync *mode* is real
// information the heading does not give.
card.appendChild(head);
card.appendChild(el('div', 'cap-why', entry.reason || 'No rationale recorded.'));
container.appendChild(card);
});
}
function renderCapabilities() {
var arch = sections.architecture || {};
capabilityCards('deviceCapabilities', arch.nativeCapabilities, 'device',
'No device capabilities — this app uses data and navigation only.');
capabilityCards('connectorList', arch.connectors, 'connector',
'No connectors — this app reads its data from Dataverse directly.');
var container = document.getElementById('offlineBlock');
container.textContent = '';
var offline = sections.offline;
if (!offline) {
container.appendChild(el('div', 'empty', 'Offline has not been decided yet.'));
return;
}
var on = offline.enabled === true;
var card = el('div', 'cap ' + (on ? 'cap-offline-on' : 'cap-offline-off'));
var head = el('div', 'cap-head');
head.appendChild(el('span', 'cap-name', on ? 'Offline sync enabled' : 'Online only'));
if (offline.mode) head.appendChild(el('span', 'cap-kind', offline.mode));
card.appendChild(head);
var reasons = paragraphs(offline.rationale);
if (reasons.length > 1) {
var why = el('div', 'cap-why');
why.appendChild(bullets(reasons));
card.appendChild(why);
} else {
card.appendChild(el('div', 'cap-why', reasons[0] || 'No rationale recorded.'));
}
if (on && offline.tables && offline.tables.length) {
card.appendChild(el('div', 'step-ref', 'Synced tables: ' + list(offline.tables)));
}
container.appendChild(card);
}
/**
* Link the planner's own markdown. The tabs summarise it; the file has the full per-screen
* specs, and it is the artifact `/edit-app` reads on a later run. The href is code-owned
* ('../native-app-plan.md'), and the renderer leaves it empty until the file exists.
*/
function planDocLink(containerId, label) {
var container = document.getElementById(containerId);
if (!container) return;
container.textContent = '';
if (!summary.planDocHref) return;
// Markdown is a document, not a web page: a browser either dumps it as plain text or
// downloads it. The editor scheme opens it where it is meant to be read. It is offered
// first but not alone - a reader without a handler for it would otherwise hit a dead end,
// so the plain file link stays beside it.
var link = el('a', 'plan-doc');
link.setAttribute('href', summary.planDocEditorHref || summary.planDocHref);
link.textContent = label;
// This page stays open and reloads itself for the whole run, so a link that navigates must
// open beside it rather than replace it. The editor link is the exception: a `vscode://`
// click hands the file to the editor and leaves this page where it is, and giving it a new
// tab would only strand an empty one.
if (!summary.planDocEditorHref) {
link.setAttribute('target', '_blank');
link.setAttribute('rel', 'noopener');
}
var raw = el('a', 'plan-doc-raw', 'native-app-plan.md');
raw.setAttribute('href', summary.planDocHref);
raw.setAttribute('title', 'Open as plain text in a new tab instead');
raw.setAttribute('target', '_blank');
raw.setAttribute('rel', 'noopener');
container.appendChild(link);
container.appendChild(raw);
}
function renderScreens() {
approvalBanner('approval-screens', 'screens');
planDocLink('screensPlanDoc', 'Full screen specs');
var screens = sections.screens || {};
var items = screens.list || [];
renderMermaid('graphContainer',
items.length ? buildScreenGraph(items, screens.navigation) : '',
'The screen graph will appear here after the screen graph gate.');
var container = document.getElementById('screensContainer');
container.textContent = '';
if (!items.length) {
container.appendChild(el('div', 'empty', 'No screens planned yet.'));
return;
}
items.forEach(function (screen) {
var card = el('div', 'card');
card.appendChild(el('div', 'mark'));
var body = el('div');
body.appendChild(el('div', 'step-title', screen.name));
if (screen.purpose) body.appendChild(el('div', 'step-detail', screen.purpose));
var meta = [];
if (screen.route) meta.push(screen.route);
if (screen.data) meta.push(screen.data);
if (screen.capabilities && screen.capabilities.length) meta.push(list(screen.capabilities));
if (meta.length) body.appendChild(el('div', 'step-ref', meta.join(' \u00b7 ')));
card.appendChild(body);
if (screen.status) card.appendChild(el('span', 'chip', screen.status));
container.appendChild(card);
});
}
/**
* Outline icons for the trust report, drawn as inline SVG on a 24x24 grid.
*
* Geometric unicode shapes were tried first and failed the job: at 15px a filled square, a
* fisheye and a lozenge are indistinguishable, so the column read as decoration rather than
* telling you at a glance which permission a row is about. SVG also renders identically
* everywhere, which is the reason the nav icons are pinned to a proven unicode block.
*
* Every string here is a code-owned constant - no plan data reaches them - which is why they
* may be assigned as markup.
*/
var ICON_PATHS = {
camera: '<rect x="3.2" y="7" width="17.6" height="12" rx="2.5"/><path d="M9 7l1-2h4l1 2"/><circle cx="12" cy="13" r="3"/>',
barcode: '<path d="M4 6v12M7.2 6v12M10.4 6v12M13.6 6v12M16.8 6v12M20 6v12"/>',
location: '<path d="M12 21c3.8-4 6-7.2 6-10a6 6 0 1 0-12 0c0 2.8 2.2 6 6 10z"/><circle cx="12" cy="11" r="2.2"/>',
gps: '<circle cx="12" cy="12" r="6.6"/><circle cx="12" cy="12" r="2.1"/><path d="M12 2.6v2.8M12 18.6v2.8M2.6 12h2.8M18.6 12h2.8"/>',
microphone: '<rect x="9.4" y="3.4" width="5.2" height="10.2" rx="2.6"/><path d="M6.4 11.6a5.6 5.6 0 0 0 11.2 0"/><path d="M12 17.2v3.4"/>',
contacts: '<circle cx="12" cy="8.4" r="3.6"/><path d="M5.2 19.8a6.8 6.8 0 0 1 13.6 0"/>',
bell: '<path d="M18 16.2v-5.2a6 6 0 1 0-12 0v5.2l-1.6 2.2h15.2z"/><path d="M10 20.2a2 2 0 0 0 4 0"/>',
faceid: '<path d="M4 9V6.6A2.6 2.6 0 0 1 6.6 4H9M15 4h2.4A2.6 2.6 0 0 1 20 6.6V9M20 15v2.4a2.6 2.6 0 0 1-2.6 2.6H15M9 20H6.6A2.6 2.6 0 0 1 4 17.4V15"/><path d="M9.6 10.6v1.2M14.4 10.6v1.2"/><path d="M9.6 15a3.6 3.6 0 0 0 4.8 0"/>',
photos: '<rect x="3.2" y="7.4" width="13.4" height="11.4" rx="2"/><circle cx="7.4" cy="11.4" r="1.2"/><path d="M3.2 16.2l3.6-3 4.2 3.6"/><path d="M7.4 7.4V6a1.6 1.6 0 0 1 1.6-1.6h10.4A1.6 1.6 0 0 1 21 6v9a1.6 1.6 0 0 1-1.6 1.6h-2.8"/>',
cloud: '<path d="M7.2 18.4h10.2a3.6 3.6 0 0 0 .4-7.2 5.6 5.6 0 0 0-10.8-1 4.1 4.1 0 0 0 .2 8.2z"/>',
globe: '<circle cx="12" cy="12" r="8"/><path d="M4 12h16"/><ellipse cx="12" cy="12" rx="3.6" ry="8"/>',
battery: '<rect x="3" y="8" width="15.4" height="8.8" rx="2.4"/><path d="M21 11.4v2.4"/><rect x="5.4" y="10.4" width="5.2" height="4" rx="1" fill="currentColor" stroke="none"/>',
refresh: '<path d="M20 12a8 8 0 1 1-2.4-5.7"/><path d="M20 4.2v4.2h-4.2"/>',
shield: '<path d="M12 3.4l7.2 2.8v5.2c0 4.4-3 7.8-7.2 9.2-4.2-1.4-7.2-4.8-7.2-9.2V6.2z"/>',
mail: '<rect x="3" y="5.5" width="18" height="13" rx="2.2"/><path d="M3.6 7.2l7.5 5.2a1.6 1.6 0 0 0 1.8 0l7.5-5.2"/>',
documents: '<path d="M13.5 3.5H7.6A2.1 2.1 0 0 0 5.5 5.6v12.8a2.1 2.1 0 0 0 2.1 2.1h8.8a2.1 2.1 0 0 0 2.1-2.1V8.5z"/><path d="M13.5 3.5V8.5h5"/><path d="M9 13.2h6M9 16.4h4"/>',
database: '<ellipse cx="12" cy="6.4" rx="7" ry="2.8"/><path d="M5 6.4v11.2c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8V6.4"/><path d="M5 12c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8"/>',
chat: '<path d="M20 12.4a7.2 7.2 0 0 1-9.8 6.7L4.6 20.4 6 15A7.2 7.2 0 1 1 20 12.4z"/>',
plug: '<path d="M10.2 13.8a3.6 3.6 0 0 0 5.1 0l3-3a3.6 3.6 0 0 0-5.1-5.1l-1.3 1.3"/><path d="M13.8 10.2a3.6 3.6 0 0 0-5.1 0l-3 3a3.6 3.6 0 0 0 5.1 5.1l1.3-1.3"/>',
device: '<rect x="6.5" y="2.8" width="11" height="18.4" rx="2.4"/><path d="M10.4 5.6h3.2"/><path d="M11 18.6h2"/>'
};
// Keyed off the capability name because the plan records a human label ("Barcode & QR
// scanning"), not an enum. Order matters: "background location" must be tested before the
// plain location pattern, or a background-tracking row would claim the on-demand pin icon.
var PERMISSION_ICONS = [
[/photo librar|gallery|picker/, 'photos'],
[/camera|image capture|photo/, 'camera'],
[/barcode|scanner|scanning|qr/, 'barcode'],
[/background location|continuous gps|\bgps\b/, 'gps'],
[/location|geofence|geo/, 'location'],
[/microphone|audio|voice/, 'microphone'],
[/contact|calendar|address book/, 'contacts'],
[/notification|push|alert/, 'bell'],
[/biometric|face id|touch id|fingerprint|unlock/, 'faceid'],
[/offline|sqlite|sync|upload/, 'cloud'],
[/network|connectivity|online|signal/, 'globe'],
[/outlook|\bmail\b|email|smtp/, 'mail'],
[/sharepoint|document|\blibrary\b|\bfiles?\b/, 'documents'],
[/blob|storage account|\bsql\b|dataverse|database|\btables?\b/, 'database'],
[/teams|\bchat\b|message/, 'chat'],
[/refresh|poll/, 'refresh'],
[/battery|power|background/, 'battery']
];
function permissionIconName(name, fallback) {
var value = String(name == null ? '' : name).toLowerCase();
for (var i = 0; i < PERMISSION_ICONS.length; i++) {
if (PERMISSION_ICONS[i][0].test(value)) return PERMISSION_ICONS[i][1];
}
// The fallback says what kind of list this is, so an unmatched connector reads as a
// connector rather than as a device permission.
return ICON_PATHS[fallback] ? fallback : 'shield';
}
function permissionIcon(name, fallback, className) {
var span = el('span', 'perm-icon' + (className ? ' ' + className : ''));
span.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"'
+ ' stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">'
+ ICON_PATHS[permissionIconName(name, fallback)] + '</svg>';
return span;
}
/**
* How a permission is acquired, not merely whether it is. These are the seven cross-platform
* acquisition patterns plus "never asked for"; which one an app uses is the substance of a
* least-privilege claim, because "on demand" and "at startup" grant the same access while
* asking for it very differently.
*
* `tone` drives the badge colour: `good` for patterns that tie access to an explicit user
* action or avoid a standing grant entirely, `warn` for ones that take the grant before the
* user has context, `info` for the rest.
*/
var PERMISSION_STATUSES = {
'on-demand': { label: 'ON DEMAND', tone: 'good' },
'on-startup': { label: 'AT STARTUP', tone: 'warn' },
'on-first-access': { label: 'ON FIRST ACCESS', tone: 'info' },
'per-operation': { label: 'PER OPERATION', tone: 'good' },
'incremental': { label: 'INCREMENTAL', tone: 'info' },
'system-settings': { label: 'VIA SETTINGS', tone: 'warn' },
'system-mediated': { label: 'SYSTEM-MEDIATED', tone: 'good' },
'not-requested': { label: 'NOT REQUESTED', tone: 'muted' }
};
var STATUS_ALIASES = {
ondemand: 'on-demand', requested: 'on-demand', 'on-use': 'on-demand',
startup: 'on-startup', 'on-launch': 'on-startup', 'on-load': 'on-startup', onboarding: 'on-startup',
'first-access': 'on-first-access', automatic: 'on-first-access', implicit: 'on-first-access',
'per-use': 'per-operation', 'every-time': 'per-operation', ephemeral: 'per-operation',
escalating: 'incremental', 'incremental-escalation': 'incremental',
settings: 'system-settings', 'via-settings': 'system-settings',
'system-picker': 'system-mediated', picker: 'system-mediated', mediated: 'system-mediated',
'not-used': 'not-requested', none: 'not-requested', never: 'not-requested'
};
/**
* Anything unrecognised resolves to `not-requested` - the claim that promises least - so a
* typo or a stale status can never overstate what the app reaches for.
*/
function permissionStatus(raw) {
var value = String(raw == null ? '' : raw).toLowerCase().trim().replace(/[\s_]+/g, '-');
value = STATUS_ALIASES[value] || value;
return PERMISSION_STATUSES[value] ? value : 'not-requested';
}
function boundaryCard(containerId, heading, items) {
var container = document.getElementById(containerId);
container.textContent = '';
container.appendChild(el('h4', null, heading));
var entries = (items || []).filter(Boolean);
if (!entries.length) {
container.appendChild(el('div', 'empty', 'Recorded once the data sources are wired.'));
return;
}
container.appendChild(bullets(entries));
}
function renderTrust() {
// The trust report is drafted at the architecture gate and finalised once the capabilities
// are wired (Step 13), but no gate puts it to the user, so the default wording would send
// them to the terminal for a prompt that never comes.
approvalBanner('approval-trust', 'trust',
'Draft - written from the approved plan, and finalised once the capabilities are wired');
var trust = sections.trust || {};
var permissions = document.getElementById('permissionList');
permissions.textContent = '';
var entries = trust.permissions || [];
if (!entries.length) {
permissions.appendChild(el('div', 'empty',
'Permission behaviour appears here once the capabilities are approved.'));
} else {
entries.forEach(function (entry) {
var name = entryLabel(entry) || 'Capability';
var row = el('div', 'perm');
row.appendChild(permissionIcon(name));
var body = el('div', 'perm-body');
var head = el('div', 'perm-head');
head.appendChild(el('span', 'perm-name', name));
var status = permissionStatus(entry.status);
var meta = PERMISSION_STATUSES[status];
head.appendChild(el('span', 'perm-badge perm-' + meta.tone, meta.label));
body.appendChild(head);
body.appendChild(el('div', 'perm-why',
entry.detail || entry.reason || 'No access behaviour recorded.'));
// Authorization and activation are different events: holding a camera grant is not the
// same as the lens being on. Shown separately so a reader can see both.
if (entry.activation) {
body.appendChild(el('div', 'perm-act', 'Hardware: ' + entry.activation));
}
row.appendChild(body);
permissions.appendChild(row);
});
}
boundaryCard('handlesCard', 'What the app handles', trust.handles);
boundaryCard('notCollectedCard', 'What the app does not collect', trust.notCollected);
var battery = document.getElementById('batteryList');
battery.textContent = '';
var behaviours = trust.battery || [];
if (!behaviours.length) {
battery.appendChild(el('div', 'empty', 'Background behaviour appears here once the capabilities are approved.'));
return;
}
behaviours.forEach(function (entry) {
var name = entryLabel(entry) || 'Behaviour';
var row = el('div', 'perm');
row.appendChild(permissionIcon(name));
var body = el('div', 'perm-body');
body.appendChild(el('div', 'perm-name', name));
body.appendChild(el('div', 'perm-why', entry.detail || entry.reason || ''));
row.appendChild(body);
battery.appendChild(row);
});
}
function renderDesign() {
approvalBanner('approval-design', 'design');
var design = sections.design || {};
facts('designFacts', [
['Direction', design.direction],
['Heading font', design.headingFont, false, design.headingFont],
['Body font', design.bodyFont, false, design.bodyFont],
['Dark mode', design.darkMode]
]);
var container = document.getElementById('paletteContainer');
container.textContent = '';
var palette = design.palette || [];
if (!palette.length) {
container.appendChild(el('div', 'empty', 'No palette captured yet.'));
return;
}
palette.forEach(function (entry) {
var card = el('div', 'swatch-card');
var swatch = el('div', 'swatch');
// Only accept a literal hex colour; anything else stays unset rather than becoming
// an arbitrary CSS value.
if (/^#[0-9a-fA-F]{3,8}$/.test(entry.value || '')) swatch.style.backgroundColor = entry.value;
card.appendChild(swatch);
var meta = el('div', 'swatch-meta');
meta.appendChild(el('div', 'swatch-name', entry.name || ''));
meta.appendChild(el('div', 'swatch-value', entry.value || ''));
card.appendChild(meta);
container.appendChild(card);
});
}
function renderSteps() {
var container = document.getElementById('stepsContainer');
container.textContent = '';
if (!phases.length) {
container.appendChild(el('div', 'empty', 'No steps recorded yet.'));
return;
}
phases.forEach(function (phase) {
var card = el('div', 'card ' + (STATUS_CLASS[phase.status] || 'is-pending'));
card.appendChild(el('div', 'mark'));
var body = el('div');
body.appendChild(el('div', 'step-title', phase.title));
body.appendChild(el('div', 'step-detail', phase.detail));
if (phase.note) body.appendChild(el('div', 'step-note', phase.note));
if (phase.skillSteps) body.appendChild(el('div', 'step-ref', 'Step ' + phase.skillSteps));
card.appendChild(body);
card.appendChild(el('span', STATUS_CHIP[phase.status] || 'chip', STATUS_LABEL[phase.status] || phase.status));
container.appendChild(card);
});
}
if (typeof mermaid !== 'undefined') {
mermaid.initialize({ startOnLoad: false, securityLevel: 'strict', theme: 'default', er: { fontSize: 16, useMaxWidth: true } });
}
// The renderer stamps UTC. Show the reader's own clock; the UTC text stays if this cannot run.
var updatedAt = document.getElementById('updatedAt');
var generated = new Date(updatedAt.getAttribute('data-generated') || '');
if (!isNaN(generated.getTime())) {
updatedAt.textContent = 'Updated ' + generated.toLocaleString(undefined,
{ year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' });
}
// The sticky rail is offset by the topbar, whose height grows when its pills wrap on a narrow
// window. Mirror the real height into --topbar-h so the rail neither slides under the topbar
// nor runs behind the fixed footer; the CSS default covers the single-row topbar.
var topbarEl = document.querySelector ? document.querySelector('.topbar') : null;
var rootStyle = document.documentElement && document.documentElement.style;
if (topbarEl && rootStyle && rootStyle.setProperty) {
var syncTopbar = function () { rootStyle.setProperty('--topbar-h', topbarEl.offsetHeight + 'px'); };
syncTopbar();
window.addEventListener('resize', syncTopbar);
}
renderPhone();
renderOverview();
renderRequirements();
renderDataModel();
renderCapabilities();
renderScreens();
renderDesign();
renderTrust();
renderInputBanner();
document.getElementById('inputBannerClose').addEventListener('click', function () {
dismissedPrompt = summary.awaitingInput || '';
try { sessionStorage.setItem(STORE_DISMISSED, dismissedPrompt); } catch (e) { /* private mode */ }
document.getElementById('inputBanner').hidden = true;
});
renderSteps();
// Both automatic and manual refreshes replace the document. Keep the reader's
// tab and scroll position; the shared controller below owns when to refresh.
var STORE_TAB = 'mobile-plan-tab';
var STORE_SCROLL = 'mobile-plan-scroll';
function showTab(tab) {
var button = document.querySelector('.nav-btn[data-tab="' + tab + '"]');
var section = document.getElementById('tab-' + tab);
if (!button || !section) return;
document.querySelectorAll('.nav-btn').forEach(function (b) { b.classList.remove('active'); });
document.querySelectorAll('.section').forEach(function (x) { x.classList.remove('active'); });
button.classList.add('active');
section.classList.add('active');
}
document.querySelectorAll('.nav-btn').forEach(function (btn) {
btn.addEventListener('click', function () {
showTab(btn.dataset.tab);
try { sessionStorage.setItem(STORE_TAB, btn.dataset.tab); } catch (e) { /* private mode */ }
});
});
// The live preview is a cross-origin frame, so the clicks, keys and scrolls a reader makes
// inside it go to that frame's document and never reach the refresh controller's listeners.
// Without this, someone trying out their app would have it reset under them by the next
// reload. Pointer entry is the one signal that crosses the frame boundary, so the page is busy
// while the pointer is over the frame, and leaving counts as an interaction, so a reload still
// waits the quiet window after the reader is done. Keyboard focus does not count: it stays in the
// frame after the reader goes to the terminal to answer, and counting it held off every update
// until the browser was reloaded by hand.
var pointerInPreview = false;
function touched() {
if (typeof window.planRefreshTouch === 'function') window.planRefreshTouch();
}
if (liveFrame) {
liveFrame.addEventListener('pointerenter', function () {
pointerInPreview = true;
touched();
});
liveFrame.addEventListener('pointerleave', function () {
pointerInPreview = false;
touched();
});
}
window.planRefreshBusy = function () { return pointerInPreview; };
window.addEventListener('beforeunload', function () {
try { sessionStorage.setItem(STORE_SCROLL, String(window.scrollY)); } catch (e) { /* ignore */ }
});
try {
var savedTab = sessionStorage.getItem(STORE_TAB);
if (savedTab) showTab(savedTab);
var savedScroll = Number(sessionStorage.getItem(STORE_SCROLL) || 0);
if (savedScroll > 0) window.scrollTo(0, savedScroll);
} catch (e) { /* sessionStorage unavailable; first-tab default is fine */ }
})();
</script>
<script nonce="__ATTR_CSP_NONCE__" id="planRefreshScript">__RAW_AUTO_REFRESH__</script>
<footer class="ai-footer">AI-generated content may be incorrect</footer>
</body>
</html>