Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

139 KB
Raw Blame
<!DOCTYPE html>
<html lang="en">
<head>
	<style>/* three.ws hidden-guard — make the `hidden` attribute authoritative; see scripts/lib/hidden-guard.mjs */[hidden]{display:none!important}</style>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="color-scheme" content="light dark">
<title data-i18n="ibm_x402_demo.meta_title">x402 live demo — three.ws × IBM</title>
<meta name="description" content="A live, self-contained x402 demo: pay $0.001 in USDC from your own wallet to call a real three.ws data API. Settled on-chain on Base or Solana. No backend, no account." data-i18n-attr="content:ibm_x402_demo.meta_description">
<meta property="og:title" content="x402 live demo — three.ws × IBM" data-i18n-attr="content:ibm_x402_demo.meta_og_title">
<meta property="og:description" content="Pay $0.001 in USDC from your own wallet to call a real three.ws API. See HTTP 402 micropayments settle on-chain — on Base or Solana — in seconds." data-i18n-attr="content:ibm_x402_demo.meta_og_description">
<meta property="og:type" content="website">
<style>
/* ─── Self-hosted IBM Plex (latin subset) — no third-party font CDN, so a
   strict `font-src 'self'` CSP on the host page won't break typography.
   Files travel with this page under ./fonts/. ─────────────────────────────── */
@font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:300;font-display:swap;src:url('./fonts/IBMPlexSans-300.woff2') format('woff2')}
@font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:400;font-display:swap;src:url('./fonts/IBMPlexSans-400.woff2') format('woff2')}
@font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:500;font-display:swap;src:url('./fonts/IBMPlexSans-500.woff2') format('woff2')}
@font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:600;font-display:swap;src:url('./fonts/IBMPlexSans-600.woff2') format('woff2')}
@font-face{font-family:'IBM Plex Mono';font-style:normal;font-weight:400;font-display:swap;src:url('./fonts/IBMPlexMono-400.woff2') format('woff2')}
@font-face{font-family:'IBM Plex Mono';font-style:normal;font-weight:500;font-display:swap;src:url('./fonts/IBMPlexMono-500.woff2') format('woff2')}

*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root{
  /* Carbon G10 (light) — defaults. Every surface token is themed so the dark
     override below is a single, deliberate switch. */
  --ibm-blue:#0f62fe;        /* accent: text, borders, focus rings */
  --ibm-blue-fill:#0f62fe;   /* fills that carry white text (button, skip link) */
  --ibm-blue-fill-hover:#0353e9;
  --ibm-blue-hover:#0353e9;
  --ibm-link:#0f62fe;        /* AA on white (4.6:1) */
  --ibm-ink:#161616;
  --ibm-muted:#525252;       /* AA on white (7.4:1) */
  --ibm-subtle:#595959;      /* AA on white (7:1) — was #6f6f6f (3.9:1, failed) */
  --ibm-border:#e0e0e0;
  --ibm-divider:#c6c6c6;
  --ibm-surface:#ffffff;     /* card / panel fill */
  --ibm-field:#f4f4f4;
  --ibm-field-focus:#ffffff;
  --ibm-green:#0e7a32;       /* darkened for AA on light fills */
  --ibm-green-ink:#0e7a32;   /* green text on light pill fills */
  --ibm-green-fill:#defbe6;
  --ibm-red:#da1e28;
  --ibm-red-ink:#a2191f;     /* red text on light fills (AA) */
  --ibm-red-fill:#fff1f1;
  --ibm-red-edge:#ffb3b8;
  --ibm-amber:#8a6100;       /* AA on white */
  --ibm-amber-fill:#fcf4d6;
  --ibm-skel-a:#e8e8e8;
  --ibm-skel-b:#f4f4f4;
  --font-sans:'IBM Plex Sans',system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
  --font-mono:'IBM Plex Mono',ui-monospace,'SF Mono',Menlo,Consolas,monospace;
  --ease:cubic-bezier(.2,.7,.3,1);
}

/* Carbon G100 (dark) — looks deliberate when embedded in a dark IBM context.
   Background stays transparent so the page rides the host surface in both schemes. */
@media (prefers-color-scheme: dark){
  :root{
    --ibm-blue:#78a9ff;        /* accent on dark — AA as text on G100 (7.2:1) */
    --ibm-blue-fill:#0f62fe;   /* white text stays AA (4.84:1); recognizably IBM blue */
    --ibm-blue-fill-hover:#1f6fff;
    --ibm-blue-hover:#a6c8ff;
    --ibm-link:#78a9ff;        /* AA on #161616 (7.2:1) */
    --ibm-ink:#f4f4f4;
    --ibm-muted:#c6c6c6;       /* AA on #161616 (12:1) */
    --ibm-subtle:#a8a8a8;      /* AA on #161616 (7.4:1) */
    --ibm-border:#393939;
    --ibm-divider:#525252;
    --ibm-surface:#262626;     /* card / panel fill on dark */
    --ibm-field:#393939;
    --ibm-field-focus:#4c4c4c;
    --ibm-green:#42be65;       /* used as accent edge/dot on dark */
    --ibm-green-ink:#42be65;   /* AA on dark green fill */
    --ibm-green-fill:#0b2818;
    --ibm-red:#fa4d56;
    --ibm-red-ink:#ff8389;     /* AA on dark red fill */
    --ibm-red-fill:#2a1416;
    --ibm-red-edge:#7f1d1d;
    --ibm-amber:#f1c21b;       /* AA on dark */
    --ibm-amber-fill:#2a1d10;
    --ibm-skel-a:#333333;
    --ibm-skel-b:#3f3f3f;
  }
}

html,body{background:transparent;font-family:var(--font-sans);color:var(--ibm-ink);font-size:16px;line-height:1.5;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
a{color:var(--ibm-link);text-decoration:none}
a:hover{text-decoration:underline}
.mono{font-family:var(--font-mono)}

/* Visible focus everywhere — never rely on the UA default the reset removes. */
:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
a:focus-visible{outline-offset:3px}

.skip-link{position:absolute;left:-9999px;top:0;background:var(--ibm-blue-fill);color:#fff;padding:10px 16px;z-index:50;font-weight:600;font-size:14px}
.skip-link:focus{left:8px;top:8px;text-decoration:none}

/* Visually hidden but available to assistive tech. */
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

.inner{max-width:880px;margin:0 auto;padding:0 16px}
.section{padding:40px 0;border-bottom:1px solid var(--ibm-border)}
.section:last-child{border-bottom:none}

/* ── Global error banner (resilience safety net) ── */
.err-banner{position:fixed;left:0;right:0;top:0;z-index:60;background:var(--ibm-red-fill);border-bottom:1px solid var(--ibm-red-edge);color:var(--ibm-red-ink);font-size:13px;padding:10px 16px;display:none;align-items:center;gap:12px;justify-content:center}
.err-banner.show{display:flex}
.err-banner button{background:none;border:1px solid var(--ibm-red-edge);color:var(--ibm-red-ink);font-family:inherit;font-size:12px;font-weight:600;padding:4px 10px;cursor:pointer;border-radius:2px}
.err-banner button:hover{background:rgba(218,30,40,.12)}

/* ── Hero ── */
.hero{padding:56px 0 36px}
.partner-label{display:inline-flex;align-items:center;gap:12px;border:1px solid var(--ibm-border);padding:6px 14px;font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--ibm-muted);margin-bottom:28px}
.ibm-mark{font-family:var(--font-sans);font-weight:700;font-size:15px;letter-spacing:-.01em;color:var(--ibm-blue);line-height:1}
.hero h1{font-size:clamp(30px,5vw,46px);font-weight:300;line-height:1.1;margin-bottom:18px;max-width:680px}
.hero h1 strong{font-weight:600}
.hero-sub{font-size:18px;color:var(--ibm-muted);max-width:620px;font-weight:300;line-height:1.6}

/* ── How-it-works ── */
.steps{display:grid;grid-template-columns:repeat(3,1fr);gap:1px;background:var(--ibm-border);border:1px solid var(--ibm-border);list-style:none;margin-top:24px}
.step{background:var(--ibm-surface);padding:24px 22px}
.step-n{font-family:var(--font-mono);font-size:12px;color:var(--ibm-blue);font-weight:500;margin-bottom:10px}
.step h3{font-size:15px;font-weight:600;margin-bottom:6px}
.step p{font-size:13px;color:var(--ibm-muted);font-weight:300;line-height:1.55}
.step code{font-family:var(--font-mono);font-size:12px;background:var(--ibm-field);padding:1px 5px;color:var(--ibm-ink);word-break:break-word}

/* ── Section heads ── */
.section-tag{font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--ibm-blue);margin-bottom:8px;font-weight:500}
.section h2{font-size:clamp(22px,4vw,32px);font-weight:300}
.section h2 strong{font-weight:600}
.section-lead{font-size:15px;color:var(--ibm-muted);max-width:620px;margin-top:10px;font-weight:300;line-height:1.6}

/* ── Demo card ── */
.demo{border:1px solid var(--ibm-divider);margin-top:28px;background:var(--ibm-surface)}
.demo-head{padding:22px 24px 18px;border-bottom:1px solid var(--ibm-border);display:flex;flex-wrap:wrap;gap:16px;align-items:flex-end;justify-content:space-between}
.demo-title{font-size:20px;font-weight:600}
.demo-title span{color:var(--ibm-blue)}
.demo-desc{font-size:13px;color:var(--ibm-muted);font-weight:300;max-width:460px;margin-top:4px;line-height:1.55}
.price-tag{text-align:right;flex:0 0 auto}
.price-tag .amt{font-size:30px;font-weight:300;line-height:1;font-variant-numeric:tabular-nums}
.price-tag .amt strong{font-weight:600;color:var(--ibm-blue)}
.price-tag .amt.flash{animation:priceflash .42s var(--ease) 1}
@keyframes priceflash{0%{transform:scale(1)}40%{transform:scale(1.06);opacity:.7}100%{transform:scale(1);opacity:1}}
.price-tag .net{font-size:12px;color:var(--ibm-muted);margin-top:6px}

.demo-body{padding:22px 24px}

/* 402 preview */
.preview{border:1px solid var(--ibm-border);background:var(--ibm-field);padding:14px 16px;margin-bottom:22px;font-family:var(--font-mono);font-size:12px}
.preview-label{font-family:var(--font-sans);font-size:11px;text-transform:uppercase;letter-spacing:.07em;color:var(--ibm-subtle);margin-bottom:10px;display:flex;align-items:center;gap:8px}
.preview-label .dot{width:7px;height:7px;border-radius:50%;background:var(--ibm-subtle);flex:0 0 auto}
.preview-label.ok .dot{background:var(--ibm-green)}
.preview-label.ok.fresh .dot{animation:dotpulse 1.2s var(--ease) 1}
.preview-label.err .dot{background:var(--ibm-red)}
@keyframes dotpulse{0%{box-shadow:0 0 0 0 rgba(14,122,50,.5)}100%{box-shadow:0 0 0 9px rgba(14,122,50,0)}}
.preview-row{display:flex;gap:12px;padding:3px 0;flex-wrap:wrap}
.preview-row .k{color:var(--ibm-subtle);min-width:84px}
.preview-row .v{color:var(--ibm-ink);word-break:break-all}
.badge{display:inline-block;font-family:var(--font-sans);font-size:11px;font-weight:500;padding:1px 8px;border:1px solid var(--ibm-divider);margin-right:6px;border-radius:2px}
.pv-retry{margin-top:10px;background:none;border:1px solid var(--ibm-divider);color:var(--ibm-ink);font-family:var(--font-sans);font-size:12px;font-weight:500;padding:6px 12px;cursor:pointer}
.pv-retry:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
/* skeleton */
.sk{display:inline-block;height:11px;border-radius:2px;background:linear-gradient(90deg,var(--ibm-skel-a) 25%,var(--ibm-skel-b) 37%,var(--ibm-skel-a) 63%);background-size:400% 100%;animation:sk 1.4s ease infinite}
@keyframes sk{0%{background-position:100% 0}100%{background-position:0 0}}

/* input row */
.field-row{display:flex;gap:0;flex-wrap:wrap;align-items:flex-end;margin-bottom:10px}
.field-wrap{flex:1 1 240px;min-width:0}
.field-wrap label{display:block;font-size:12px;color:var(--ibm-muted);margin-bottom:6px;font-weight:500}
.field{width:100%;height:48px;padding:0 14px;border:none;border-bottom:1px solid var(--ibm-divider);background:var(--ibm-field);font-family:var(--font-mono);font-size:15px;color:var(--ibm-ink);letter-spacing:.04em;outline:none;transition:border-color .12s,background .12s}
.field:focus{border-bottom:2px solid var(--ibm-blue);background:var(--ibm-field-focus)}
.field[aria-invalid="true"]{border-bottom:2px solid var(--ibm-red)}
.field-hint{font-size:11px;color:var(--ibm-subtle);margin-top:6px}
.field-hint.err{color:var(--ibm-red)}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:10px;background:var(--ibm-blue-fill);color:#fff;border:none;cursor:pointer;font-family:var(--font-sans);font-size:15px;font-weight:500;letter-spacing:.01em;padding:0 24px;height:48px;min-width:200px;transition:background .12s,transform .04s,box-shadow .12s}
.btn:hover:not(:disabled){background:var(--ibm-blue-fill-hover)}
.btn:active:not(:disabled){transform:translateY(1px)}
.btn:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px;box-shadow:0 0 0 4px rgba(15,98,254,.25)}
.btn:disabled{background:var(--ibm-divider);color:var(--ibm-subtle);cursor:not-allowed}
.btn .arrow{font-size:17px;line-height:1}
.btn .spin{width:15px;height:15px;border:2px solid rgba(255,255,255,.45);border-top-color:#fff;border-radius:50%;animation:spin .7s linear infinite;display:none}
.btn.loading .spin{display:inline-block}
.btn.loading .arrow{display:none}
@media(min-width:560px){.btn{margin-left:1px}}

.wallet-hint{font-size:11px;color:var(--ibm-subtle);margin-bottom:18px;line-height:1.5;transition:color .12s}
.wallet-hint b{color:var(--ibm-ink);font-weight:600}
.wallet-hint.offline{color:var(--ibm-amber);font-weight:500}
.wallet-hint.detected{color:var(--ibm-green)}
.wallet-hint.detected b{color:var(--ibm-green)}

/* result panel */
.result{border:1px solid var(--ibm-border);min-height:96px;padding:18px 20px;background:var(--ibm-surface);transition:border-color .15s}
.result.is-empty{display:flex;align-items:center;justify-content:center;color:var(--ibm-subtle);font-size:13px;text-align:center;font-weight:300;border-style:dashed}
.result.is-loading{border-color:var(--ibm-blue)}
.result.is-error{border-color:var(--ibm-red)}
.result.is-done{border-color:var(--ibm-green);animation:reveal .28s var(--ease)}
@keyframes reveal{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}

.r-status{display:flex;align-items:center;gap:10px;font-size:13px;font-weight:500}
.r-status .spin{width:14px;height:14px;border:2px solid var(--ibm-divider);border-top-color:var(--ibm-blue);border-radius:50%;animation:spin .8s linear infinite;flex:0 0 auto}
@keyframes spin{to{transform:rotate(360deg)}}
.r-status.err{color:var(--ibm-red)}
.r-status.ok{color:var(--ibm-green)}
.r-check{display:inline-flex;width:18px;height:18px;border-radius:50%;background:var(--ibm-green);color:#161616;align-items:center;justify-content:center;font-size:11px;font-weight:700;flex:0 0 auto;animation:pop .3s var(--ease)}
@keyframes pop{0%{transform:scale(0)}60%{transform:scale(1.15)}100%{transform:scale(1)}}

.r-headline{font-size:18px;font-weight:300;margin:12px 0 4px}
.r-headline strong{font-weight:600}
.r-reco{font-size:14px;color:var(--ibm-ink);margin-bottom:14px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.pill{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.05em;padding:2px 9px;border-radius:2px}
.pill.ok{background:var(--ibm-green-fill);color:var(--ibm-green-ink)}
.pill.warn{background:var(--ibm-amber-fill);color:var(--ibm-amber)}
.pill.bad{background:var(--ibm-red-fill);color:var(--ibm-red-ink)}

.matches{border-top:1px solid var(--ibm-border);margin-top:6px;padding-top:12px}
.matches h4{font-size:11px;text-transform:uppercase;letter-spacing:.07em;color:var(--ibm-subtle);margin-bottom:8px;font-weight:600}
.match{display:flex;justify-content:space-between;gap:12px;padding:5px 0;font-size:13px;border-bottom:1px solid var(--ibm-field)}
.match:last-child{border-bottom:none}
.match .m-name{color:var(--ibm-ink);min-width:0;word-break:break-word}
.match .m-name b{font-weight:600}
.match .m-sim{font-family:var(--font-mono);color:var(--ibm-muted);font-size:12px;flex:0 0 auto}

.receipt{margin-top:14px;padding-top:12px;border-top:1px solid var(--ibm-border);display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px 20px}
.receipt-pair{min-width:0}
.receipt .rk{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--ibm-subtle);margin-bottom:2px}
.receipt .rv{font-family:var(--font-mono);font-size:12px;color:var(--ibm-ink);word-break:break-all}
.receipt .rv a{color:var(--ibm-link)}

.raw{margin-top:14px}
.raw summary{cursor:pointer;font-size:12px;color:var(--ibm-muted);font-weight:500;user-select:none}
.raw summary:hover{color:var(--ibm-blue)}
.raw pre{margin-top:10px;background:#161616;color:#e0e0e0;padding:14px 16px;overflow:auto;max-height:300px;font-family:var(--font-mono);font-size:12px;line-height:1.5}

.retry{margin-top:14px;background:none;border:1px solid var(--ibm-divider);color:var(--ibm-ink);padding:9px 16px;font-family:inherit;font-size:13px;font-weight:500;cursor:pointer;transition:border-color .12s,color .12s}
.retry:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
/* Actionable, plain-language guidance under an error (top up / reconnect). */
.r-tip{font-size:13px;color:var(--ibm-muted);margin:8px 0 0;line-height:1.5;font-weight:300}
.r-status.err span:last-child{word-break:break-word;min-width:0}

.note{display:flex;gap:14px;margin-top:22px;padding:16px 18px;border:1px solid var(--ibm-border);background:var(--ibm-field)}
.note svg{flex:0 0 auto;width:20px;height:20px;color:var(--ibm-blue);margin-top:1px}
.note p{font-size:13px;color:var(--ibm-muted);line-height:1.6;font-weight:300}
.note p b{color:var(--ibm-ink);font-weight:600}
.note-aside{display:block;margin-top:8px;padding-top:8px;border-top:1px solid var(--ibm-border);color:var(--ibm-subtle);font-size:12px}

/* ── Forge demo (Demo 03): tier selector, model viewer, result actions ── */
.tier-row{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:18px}
.tier{flex:1 1 150px;min-width:0;text-align:left;background:var(--ibm-field);border:1px solid var(--ibm-divider);border-bottom:2px solid var(--ibm-divider);padding:12px 14px;cursor:pointer;font-family:var(--font-sans);color:var(--ibm-ink);transition:border-color .12s,background .12s,transform .04s;border-radius:2px}
.tier:hover{border-color:var(--ibm-blue);background:var(--ibm-field-focus)}
.tier:active{transform:translateY(1px)}
.tier:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
.tier[aria-checked="true"]{border-color:var(--ibm-blue);border-bottom-color:var(--ibm-blue);background:var(--ibm-field-focus)}
.tier .t-name{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.tier .t-tier{font-size:14px;font-weight:600;text-transform:capitalize}
.tier .t-price{font-family:var(--font-mono);font-size:13px;color:var(--ibm-blue);font-variant-numeric:tabular-nums}
.tier .t-blurb{font-size:11px;color:var(--ibm-muted);margin-top:4px;line-height:1.45;font-weight:300}
.tier .t-eta{font-size:11px;color:var(--ibm-subtle);margin-top:6px;font-family:var(--font-mono)}

.mv-wrap{margin:12px 0 6px;border:1px solid var(--ibm-border);background:var(--ibm-field);position:relative;border-radius:2px;overflow:hidden}
.mv-wrap model-viewer{display:block;width:100%;height:min(56vh,440px);background:radial-gradient(circle at 50% 30%,#1c2530,#0c1116 70%)}
.mv-wrap .mv-progress{position:absolute;left:0;bottom:0;height:2px;background:var(--ibm-blue);width:0;transition:width .2s linear}

.r-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:14px}
.r-btn{display:inline-flex;align-items:center;gap:7px;background:var(--ibm-blue-fill);color:#fff;border:none;cursor:pointer;font-family:var(--font-sans);font-size:13px;font-weight:500;padding:10px 16px;border-radius:2px;text-decoration:none;transition:background .12s,transform .04s}
.r-btn:hover{background:var(--ibm-blue-fill-hover)}
.r-btn:active{transform:translateY(1px)}
.r-btn.ghost{background:none;border:1px solid var(--ibm-divider);color:var(--ibm-ink)}
.r-btn.ghost:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
.r-btn:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}

.forge-foot{font-size:13px;color:var(--ibm-muted);margin-top:18px;font-weight:300}
.forge-foot a{font-weight:500}
/* Free text→3D widget — the no-wallet companion to the paid Forge */
.g3d{margin-top:32px;border:1px solid var(--ibm-border);background:var(--ibm-field);padding:24px}
.g3d-tag{font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--ibm-blue);font-weight:500;margin-bottom:8px}
.g3d h4{font-size:20px;font-weight:300;margin:0 0 8px;color:var(--ibm-ink);max-width:none}
.g3d h4 strong{font-weight:600}
.g3d-sub{font-size:14px;color:var(--ibm-muted);line-height:1.6;margin:0 0 20px;max-width:640px}
.g3d-field{display:flex;gap:1px;flex-wrap:wrap;background:var(--ibm-border)}
.g3d-input{flex:1 1 280px;min-width:0;font-family:var(--font-sans);font-size:15px;color:var(--ibm-ink);background:var(--ibm-page);border:none;padding:0 16px;height:48px;outline:none}
.g3d-input:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:-2px}
.g3d-btn{display:inline-flex;align-items:center;gap:10px;background:var(--ibm-blue);color:#fff;border:none;cursor:pointer;font-family:var(--font-sans);font-size:15px;font-weight:500;padding:0 24px;height:48px;transition:background .12s,transform .04s}
.g3d-btn:hover:not(:disabled){background:var(--ibm-blue-hover)}
.g3d-btn:active:not(:disabled){transform:translateY(1px)}
.g3d-btn:disabled{opacity:.7;cursor:not-allowed}
.g3d-btn:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
.g3d-spin{width:15px;height:15px;border:2px solid rgba(255,255,255,.4);border-top-color:#fff;border-radius:50%;animation:spin .7s linear infinite;display:none}
.g3d-btn.loading .g3d-spin{display:inline-block}
.g3d-suggest{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
.g3d-suggest button{font-family:inherit;font-size:13px;color:var(--ibm-muted);background:transparent;border:1px solid var(--ibm-border);padding:6px 12px;cursor:pointer;transition:border-color .12s,color .12s}
.g3d-suggest button:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
.g3d-result{margin-top:20px;border:1px solid var(--ibm-border);background:var(--ibm-page)}
.g3d-result.is-empty{padding:28px 20px;text-align:center;font-size:14px;color:var(--ibm-subtle)}
.g3d-load{padding:28px 20px}
.g3d-bar{display:block;height:3px;background:var(--ibm-border);overflow:hidden;margin-bottom:16px}
.g3d-bar span{display:block;height:100%;width:40%;background:var(--ibm-blue);animation:g3dslide 1.3s ease-in-out infinite}
@keyframes g3dslide{0%{transform:translateX(-110%)}100%{transform:translateX(360%)}}
.g3d-loadmsg{font-size:14px;color:var(--ibm-muted);text-align:center}
.g3d-err{padding:24px 20px;text-align:center}
.g3d-err p{font-size:14px;color:var(--ibm-muted);margin:0 auto 16px;max-width:440px;line-height:1.6}
.g3d-retry{font-family:inherit;font-size:14px;font-weight:500;color:#fff;background:var(--ibm-blue);border:none;padding:10px 20px;cursor:pointer;transition:background .12s}
.g3d-retry:hover{background:var(--ibm-blue-hover)}
.g3d-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:14px 16px;border-top:1px solid var(--ibm-border)}
.g3d-act{display:inline-flex;align-items:center;font-family:inherit;font-size:14px;font-weight:500;text-decoration:none;padding:9px 16px;border:1px solid var(--ibm-blue);color:var(--ibm-blue);cursor:pointer;transition:background .12s}
.g3d-act:hover{background:rgba(15,98,254,.08);text-decoration:none}
.g3d-act.primary{background:var(--ibm-blue);color:#fff;border-color:var(--ibm-blue)}
.g3d-act.primary:hover{background:var(--ibm-blue-hover)}
.g3d-engine{font-size:12px;color:var(--ibm-subtle);margin-left:auto}
@media(max-width:560px){.g3d-btn{width:100%}.g3d-engine{margin-left:0;width:100%}}

@media(pointer:coarse){.tier,.r-btn{min-height:44px}}

/* embed snippet */
.embed-block{background:#161616;color:#e0e0e0;border:1px solid #393939;padding:18px 20px;overflow:auto;margin-top:24px;font-family:var(--font-mono);font-size:13px;line-height:1.6;white-space:pre}
.embed-block .c-tag{color:#82cfff}
.embed-block .c-attr{color:#a6c8ff}
.embed-block .c-str{color:#a7f0ba}
.embed-block .c-com{color:#a8a8a8}
.copy-row{display:flex;justify-content:flex-end;margin-top:10px}
.copy-btn{background:none;border:1px solid var(--ibm-divider);color:var(--ibm-muted);font-family:inherit;font-size:12px;font-weight:500;padding:7px 14px;cursor:pointer;transition:border-color .12s,color .12s}
.copy-btn:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}

/* footer */
.footer{padding:40px 0;color:var(--ibm-subtle);font-size:12px}
.footer-nav{display:flex;flex-wrap:wrap;gap:20px;margin-bottom:18px}
.footer-nav a{color:var(--ibm-muted);font-weight:500;font-size:13px}
.footer-nav a:hover{color:var(--ibm-blue)}
.footer-legal{padding-top:16px;border-top:1px solid var(--ibm-border);line-height:1.6}

/* Tablet: keep the 3-up strip but let it breathe; stack the field row earlier. */
@media(max-width:768px){
  .section{padding:32px 0}
  .hero{padding:44px 0 30px}
}

@media(max-width:640px){
  .steps{grid-template-columns:1fr}
  .demo-head{flex-direction:column;align-items:flex-start;gap:8px}
  .price-tag{text-align:left}
  .field-row{gap:14px}
  .btn{width:100%;min-width:0}
  .demo-head,.demo-body{padding-left:18px;padding-right:18px}
}

/* Small phones (≤360px, incl. 320px). Tighten gutters, keep mono strings contained,
   and never let a long address/hash force a wide layout viewport (the documented iOS
   overflow gotcha). overflow-wrap:anywhere is the belt-and-braces over word-break. */
@media(max-width:360px){
  .inner{padding:0 12px}
  .demo-head,.demo-body{padding-left:14px;padding-right:14px}
  .hero h1{font-size:clamp(26px,8vw,34px)}
  .price-tag .amt{font-size:26px}
  .preview-row{gap:6px}
  .preview-row .k{min-width:72px}
}
.preview-row .v,.receipt .rv,.match .m-name,.footer-legal{overflow-wrap:anywhere}

/* Touch devices: every interactive control clears the 44×44 px minimum. The
   coarse-pointer query keeps desktop sizing compact while guaranteeing mobile taps. */
@media(pointer:coarse){
  .pv-retry,.retry,.copy-btn,.err-banner button{min-height:44px;padding-top:10px;padding-bottom:10px}
  .footer-nav a{display:inline-flex;align-items:center;min-height:44px}
  .raw summary{min-height:44px;display:flex;align-items:center}
}

/* ── 3D agent layer ── */
.agent-grid{display:grid;grid-template-columns:1fr;gap:28px;margin-top:28px;align-items:start}
@media(min-width:760px){.agent-grid{grid-template-columns:minmax(0,360px) 1fr;gap:36px}}
.agent-stage{position:relative;border:1px solid var(--ibm-divider);background:var(--ibm-field);min-height:420px;overflow:hidden}
.agent-stage agent-3d{display:block;width:100%;height:460px}
/* Skeleton silhouette shown until the web component upgrades + boots. The booted
   agent paints over it; if the script never loads, this stays as a calm fallback. */
.agent-skel{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:3%;padding-bottom:8%;pointer-events:none}
.agent-skel .s-head{width:22%;max-width:84px;aspect-ratio:1;border-radius:50%;background:linear-gradient(90deg,var(--ibm-skel-a) 25%,var(--ibm-skel-b) 37%,var(--ibm-skel-a) 63%);background-size:400% 100%;animation:sk 1.6s ease infinite}
.agent-skel .s-body{width:42%;max-width:160px;height:44%;border-radius:44% 44% 24% 24%/26% 26% 9% 9%;background:linear-gradient(90deg,var(--ibm-skel-a) 25%,var(--ibm-skel-b) 37%,var(--ibm-skel-a) 63%);background-size:400% 100%;animation:sk 1.6s ease infinite}
agent-3d:defined ~ .agent-skel{display:none}
.agent-copy h3{font-size:18px;font-weight:600;margin-bottom:8px}
.agent-copy p{font-size:14px;color:var(--ibm-muted);font-weight:300;line-height:1.65;margin-bottom:14px;max-width:48ch}

/* ── Demo nav strip (hero) ── */
.demo-nav{display:flex;flex-wrap:wrap;gap:8px;margin-top:26px}
.demo-nav a{font-size:13px;font-weight:500;color:var(--ibm-ink);border:1px solid var(--ibm-border);padding:8px 14px;border-radius:2px;transition:border-color .12s,color .12s,background .12s}
.demo-nav a:hover{border-color:var(--ibm-blue);color:var(--ibm-blue);background:var(--ibm-field);text-decoration:none}
.demo-nav a .n{font-family:var(--font-mono);color:var(--ibm-blue);margin-right:8px;font-size:11px}

/* ── Full-size live demo embed (Forge / Play / IRL) ── */
/* Each runs at full content width and most of the viewport height — these are
   real production apps, presented full-size, lazy-loaded as they scroll in. */
.live-embed{border:1px solid var(--ibm-divider);background:var(--ibm-surface);margin-top:28px}
.live-embed .embed-bar{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:9px 16px;border-bottom:1px solid var(--ibm-border);font-size:12px;color:var(--ibm-subtle);font-weight:500}
.live-embed .bar-url{display:inline-flex;align-items:center;gap:8px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--font-mono)}
.live-embed .bar-url .dot{width:7px;height:7px;border-radius:50%;background:var(--ibm-amber);flex:0 0 auto;transition:background .2s}
.live-embed.loaded .bar-url .dot{background:var(--ibm-green)}
.live-embed.failed .bar-url .dot{background:var(--ibm-red)}
.live-embed .bar-actions{display:flex;gap:8px;flex:0 0 auto}
.live-embed .bar-actions button,.live-embed .bar-actions a{background:none;border:1px solid var(--ibm-divider);color:var(--ibm-ink);font-family:inherit;font-size:12px;font-weight:500;padding:6px 11px;cursor:pointer;border-radius:2px;display:inline-flex;align-items:center;gap:5px;text-decoration:none}
.live-embed .bar-actions button:hover,.live-embed .bar-actions a:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
.embed-frame{position:relative;background:var(--ibm-field);height:min(78vh,820px)}
.embed-frame iframe{display:block;width:100%;height:100%;border:0;background:var(--ibm-field)}
/* True full-screen via the Fullscreen API — the app fills the whole display. */
.live-embed:fullscreen{display:flex;flex-direction:column;background:var(--ibm-surface)}
.live-embed:fullscreen .embed-frame{flex:1;height:auto}
.live-embed:-webkit-full-screen{background:var(--ibm-surface)}
.embed-state{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;text-align:center;padding:24px;color:var(--ibm-subtle);font-size:14px;background:var(--ibm-field)}
.embed-state .spin{width:18px;height:18px;border:2px solid var(--ibm-divider);border-top-color:var(--ibm-blue);border-radius:50%;animation:spin .8s linear infinite}
.embed-state .es-hint{font-size:12px;color:var(--ibm-subtle);max-width:44ch;font-weight:300;line-height:1.55}
.embed-err{display:none}
.live-embed.loaded .embed-load{display:none}
.live-embed.failed .embed-load{display:none}
.live-embed.failed .embed-err{display:flex}
.embed-err a{font-weight:600}
@media(pointer:coarse){.demo-nav a,.live-embed .bar-actions button,.live-embed .bar-actions a{min-height:44px}}

@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important}
}
</style>

	<link rel="canonical" href="https://three.ws/ibm/x402-demo">
	<meta property="og:site_name" content="three.ws">
	<meta property="og:url" content="https://three.ws/ibm/x402-demo">
	<meta property="og:image" content="https://three.ws/api/page-og?s=crypto&amp;t=x402+Live+Demo+%28IBM+%C3%97+three.ws%29&amp;d=A+self-contained+x402+micropayment+demo%3A+pay+%240.001+USDC+from+your+own+wallet%3A+MetaMask+on+Base+or+Phantom+on+Solana%3A+to+call+a+real+three.ws+data+API.+Watch&amp;p=%2Fibm%2Fx402-demo">
	<meta property="og:image:width" content="1200">
	<meta property="og:image:height" content="630">
	<meta name="twitter:card" content="summary_large_image">
	<meta name="twitter:title" content="x402 Live Demo (IBM × three.ws) · three.ws" data-i18n-attr="content:ibm_x402_demo.meta_twitter_title">
	<meta name="twitter:description" content="A self-contained x402 micropayment demo: pay $0.001 USDC from your own wallet — MetaMask on Base or Phantom on Solana — to call a real three.ws data API. Watch the live HTTP 402 challenge, sign a gasless authorization, and see the on-chain settlement receipt. No backend, no account; built as the public face of the IBM × three.ws partnership." data-i18n-attr="content:ibm_x402_demo.meta_twitter_description">
	<meta name="twitter:image" content="https://three.ws/api/page-og?s=crypto&amp;t=x402+Live+Demo+%28IBM+%C3%97+three.ws%29&amp;d=A+self-contained+x402+micropayment+demo%3A+pay+%240.001+USDC+from+your+own+wallet%3A+MetaMask+on+Base+or+Phantom+on+Solana%3A+to+call+a+real+three.ws+data+API.+Watch&amp;p=%2Fibm%2Fx402-demo">
	<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"x402 Live Demo (IBM × three.ws)","description":"A self-contained x402 micropayment demo: pay $0.001 USDC from your own wallet — MetaMask on Base or Phantom on Solana — to call a real three.ws data API. Watch the live HTTP 402 challenge, sign a gasless authorization, and see the on-chain settlement receipt. No backend, no account; built as the public face of the IBM × three.ws partnership.","url":"https://three.ws/ibm/x402-demo","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
	<!-- model-viewer renders the GLB returned by the paid Forge demo (Demo 01).
	     Self-hosted (travels with this file under ./vendor/) so the page needs no
	     third-party script CDN — a strict `script-src 'self'` host won't block it.
	     The forged GLBs are uncompressed glTF with embedded textures, so model-viewer
	     loads no external Draco/KTX2 decoder; its only fetch is the GLB from three.ws.
	     It is loaded lazily (see ensureModelViewer below) only after a model is forged,
	     so the 955 KB bundle never costs a page view that doesn't use it, and its bundled
	     Three.js doesn't co-exist with the agent's at idle. -->

	<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
	<meta property="og:locale" content="en_US">
	<meta property="og:image:alt" content="x402 Live Demo (IBM × three.ws) — three.ws">
	<meta name="twitter:site" content="@trythreews">
</head>
<body>

<a href="#forge" class="skip-link" data-i18n="ibm_x402_demo.skip_to_the_demos">Skip to the demos</a>

<div class="err-banner" id="errBanner" role="alert">
  <span id="errBannerText" data-i18n="ibm_x402_demo.something_went_wrong">Something went wrong.</span>
  <button type="button" id="errBannerClose" data-i18n="ibm_x402_demo.dismiss">Dismiss</button>
</div>

<!-- ══ HERO ══ -->
<header class="hero">
  <div class="inner">
    <div class="partner-label">
      <!-- IBM brand: neutral typographic wordmark (IBM Plex, Carbon blue) — a defensible
           placeholder, NOT the registered 8-bar logo. Confirm the exact mark and the
           "IBM Business Partner" lockup + wording with IBM brand before public launch
           (see HOSTING.md, "Note on branding"). -->
      <span class="ibm-mark" data-i18n="ibm_x402_demo.ibm">IBM</span>
      <span data-i18n="ibm_x402_demo.business_partner">Business Partner</span>
      <span style="color:var(--ibm-border)" aria-hidden="true">|</span>
      <span class="mono" data-i18n="ibm_x402_demo.three_ws">three.ws</span>
    </div>
    <h1 data-i18n-html="ibm_x402_demo.a_live_showcase_of_agentic_commerce_built">A live showcase of agentic commerce, built with <strong>IBM</strong></h1>
    <p class="hero-sub" data-i18n="ibm_x402_demo.ibm_has_shaped_computing_for_over_a">IBM has shaped computing for over a century — and it stays at the frontier by backing what comes next. three.ws is one of those bets: a platform for on-chain micropayments and 3D AI agents. As an IBM Business Partner, we built this page to demonstrate that partnership in the open — every demo below runs against real, production three.ws systems. Nothing is mocked, nothing is a slide.</p>
    <p class="hero-sub" style="margin-top:14px" data-i18n-html="ibm_x402_demo.five_things_we_want_to_show_you">Five things we want to show you: pay a few cents to turn text into a 3D model, pay-per-call micropayments over <span class="mono">x402</span>, an autonomous 3D agent that buys its own data, a shared 3D world, and an agent placed in augmented reality. Try each one yourself — the two paid demos (Forge and the x402 call) settle real USDC from your own wallet.</p>
    <nav class="demo-nav" aria-label="The demos on this page">
      <a href="#webinar" class="nav-live" data-i18n-html="ibm_x402_demo.watch_live"><span class="live-dot" aria-hidden="true"></span>Watch live</a>
      <a href="#forge" data-i18n-html="ibm_x402_demo.01forge"><span class="n">01</span>Forge</a>
      <a href="#demo" data-i18n-html="ibm_x402_demo.02x402_payments"><span class="n">02</span>x402 payments</a>
      <a href="#agent" data-i18n-html="ibm_x402_demo.033d_agent"><span class="n">03</span>3D agent</a>
      <a href="#play" data-i18n-html="ibm_x402_demo.04play"><span class="n">04</span>Play</a>
      <a href="#irl" data-i18n-html="ibm_x402_demo.05irl"><span class="n">05</span>IRL</a>
    </nav>
  </div>
</header>

<main>
<!-- ══ WEBINAR · live stage (countdown → synced premiere / live OBS) ══ -->
<style id="wb-styles">
.webinar{padding:34px 0 40px;border-bottom:1px solid var(--ibm-border)}
.wb-head{margin-bottom:18px}
.wb-stage{position:relative;aspect-ratio:16/9;width:100%;background:
  radial-gradient(120% 120% at 80% -10%,rgba(15,98,254,.28),transparent 55%),
  radial-gradient(90% 90% at 0% 110%,rgba(120,169,255,.16),transparent 55%),#0b0b0d;
  border:1px solid var(--ibm-divider);overflow:hidden;border-radius:2px}
.wb-fill{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:20px;color:#fff}
.wb-fill[hidden]{display:none}
.wb-kicker{font-family:var(--font-mono);font-size:12px;letter-spacing:.12em;text-transform:uppercase;color:#a6c8ff;margin-bottom:6px}
.wb-stage-title{font-size:clamp(18px,3.4vw,28px);font-weight:300;line-height:1.15;max-width:560px;margin:0 0 22px;color:#fff}
.wb-stage-title strong{font-weight:600}
.wb-countdown{display:flex;align-items:flex-start;gap:clamp(8px,2.4vw,22px);font-variant-numeric:tabular-nums}
.wb-cell{display:flex;flex-direction:column;align-items:center;min-width:54px}
.wb-num{font-size:clamp(34px,7.2vw,66px);font-weight:200;line-height:1;color:#fff}
.wb-lbl{font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:rgba(255,255,255,.62);margin-top:8px}
.wb-colon{font-size:clamp(28px,6vw,54px);font-weight:200;color:rgba(255,255,255,.35);line-height:1;padding-top:2px}
.wb-soon{margin-top:20px;font-size:13px;color:rgba(255,255,255,.7);max-width:440px;line-height:1.55}
.wb-spinner{width:34px;height:34px;border:3px solid rgba(255,255,255,.25);border-top-color:#78a9ff;border-radius:50%;animation:wbspin .9s linear infinite;margin-bottom:14px}
@keyframes wbspin{to{transform:rotate(360deg)}}
.wb-retry{margin-top:18px;background:rgba(255,255,255,.12);color:#fff;border:1px solid rgba(255,255,255,.4);cursor:pointer;font-family:var(--font-sans);font-size:13px;font-weight:600;padding:9px 16px;border-radius:2px;transition:background .12s}
.wb-retry[hidden]{display:none}
.wb-retry:hover{background:rgba(255,255,255,.22)}
.wb-retry:focus-visible{outline:2px solid var(--focus-ring-color, #fff);outline-offset:2px}
.wb-player{position:absolute;inset:0;background:#000}
.wb-player[hidden]{display:none}
.wb-player>video,.wb-player>iframe{width:100%;height:100%;display:block;border:0;background:#000;object-fit:contain}
.wb-badge{position:absolute;top:12px;left:12px;z-index:3;display:inline-flex;align-items:center;gap:7px;background:rgba(218,30,40,.95);color:#fff;font-family:var(--font-sans);font-size:11px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;padding:5px 10px;border-radius:2px}
.wb-badge[hidden]{display:none}
.wb-badge .d{width:7px;height:7px;border-radius:50%;background:#fff;animation:wbpulse 1.4s var(--ease) infinite}
@keyframes wbpulse{0%,100%{opacity:1}50%{opacity:.25}}
.wb-unmute{position:absolute;bottom:14px;right:14px;z-index:3;display:inline-flex;align-items:center;gap:8px;background:rgba(255,255,255,.94);color:#161616;border:none;cursor:pointer;font-family:var(--font-sans);font-size:13px;font-weight:600;padding:9px 14px;border-radius:2px;box-shadow:0 4px 16px rgba(0,0,0,.4)}
.wb-unmute[hidden]{display:none}
.wb-unmute:hover{background:#fff}
.wb-unmute:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
.wb-meta{display:flex;flex-wrap:wrap;align-items:center;gap:14px;justify-content:space-between;margin-top:16px}
.wb-when{font-size:14px;color:var(--ibm-muted);font-weight:300}
.wb-when b{color:var(--ibm-ink);font-weight:500}
.wb-actions{display:flex;flex-wrap:wrap;gap:10px}
.wb-cal{display:inline-flex;align-items:center;gap:8px;background:transparent;color:var(--ibm-link);border:1px solid var(--ibm-divider);cursor:pointer;font-family:var(--font-sans);font-size:13px;font-weight:500;padding:8px 14px;border-radius:2px;text-decoration:none;transition:border-color .12s,background .12s}
.wb-cal:hover{border-color:var(--ibm-blue);background:var(--ibm-field)}
.wb-cal:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
.wb-cal svg{width:15px;height:15px;flex:0 0 auto}
.demo-nav a.nav-live .live-dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--ibm-red);margin-right:7px;vertical-align:middle;animation:wbpulse 1.4s var(--ease) infinite}
</style>
<section class="section webinar" id="webinar" aria-labelledby="wb-h">
  <div class="inner">
    <div class="wb-head">
      <div class="section-tag">Live · IBM community webinar</div>
      <h2 id="wb-h" data-i18n-html="ibm_x402_demo.watch_the_live_walkthrough">Watch the <strong>live walkthrough</strong></h2>
      <p class="section-lead" data-i18n="ibm_x402_demo.a_guided_tour_of_x402_micropayments_and">A guided tour of x402 micropayments and 3D AI agents — with every demo on this page running in real time. Can't make it live? The recording stays right here afterward.</p>
    </div>

    <div class="wb-stage" id="wbStage" role="region" aria-label="Webinar player">
      <span class="wb-badge" id="wbBadge" hidden data-i18n-html="ibm_x402_demo.live_now"><span class="d" aria-hidden="true"></span>Live now</span>

      <!-- PRE-EVENT · countdown -->
      <div class="wb-fill wb-pre" id="wbPre">
        <div class="wb-kicker" id="wbKicker">Starts in</div>
        <h3 class="wb-stage-title" id="wbStageTitle" data-i18n-html="ibm_x402_demo.three_ws_ibm_agentic_commerce_live">three.ws × <strong>IBM</strong> — agentic commerce, live</h3>
        <div class="wb-countdown" id="wbCountdown" role="timer" aria-live="off" aria-label="Time until the webinar begins">
          <div class="wb-cell"><span class="wb-num" id="wbD">00</span><span class="wb-lbl" data-i18n="ibm_x402_demo.days">Days</span></div>
          <span class="wb-colon" aria-hidden="true">:</span>
          <div class="wb-cell"><span class="wb-num" id="wbH">00</span><span class="wb-lbl" data-i18n="ibm_x402_demo.hours">Hours</span></div>
          <span class="wb-colon" aria-hidden="true">:</span>
          <div class="wb-cell"><span class="wb-num" id="wbM">00</span><span class="wb-lbl" data-i18n="ibm_x402_demo.minutes">Minutes</span></div>
          <span class="wb-colon" aria-hidden="true">:</span>
          <div class="wb-cell"><span class="wb-num" id="wbS">00</span><span class="wb-lbl" data-i18n="ibm_x402_demo.seconds">Seconds</span></div>
        </div>
        <p class="wb-soon" id="wbSoon" data-i18n="ibm_x402_demo.add_it_to_your_calendar_so_you">Add it to your calendar so you don't miss it.</p>
      </div>

      <!-- LIVE · stream not yet attached, or a designed error state (graceful) -->
      <div class="wb-fill wb-holding" id="wbHolding" hidden>
        <div class="wb-spinner" id="wbSpinner" aria-hidden="true"></div>
        <h3 class="wb-stage-title" id="wbHoldTitle" data-i18n="ibm_x402_demo.we_re_about_to_begin">We're about to begin</h3>
        <p class="wb-soon" id="wbHoldMsg" data-i18n="ibm_x402_demo.the_stream_will_appear_here_the_moment">The stream will appear here the moment it starts.</p>
        <button class="wb-retry" id="wbRetry" type="button" hidden data-i18n="ibm_x402_demo.reload_the_player">Reload the player</button>
      </div>

      <!-- LIVE / REPLAY · player mounts here -->
      <div class="wb-player" id="wbPlayer" hidden></div>
      <button class="wb-unmute" id="wbUnmute" type="button" hidden>
        <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3a4.5 4.5 0 00-2.5-4v8a4.5 4.5 0 002.5-4z"/></svg>
        Tap to unmute
      </button>
    </div>

    <div class="wb-meta">
      <div class="wb-when" id="wbWhen">Loading the schedule…</div>
      <div class="wb-actions">
        <a class="wb-cal" id="wbGcal" target="_blank" rel="noopener">
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4M8 2v4M3 10h18"/></svg>
          Google Calendar
        </a>
        <button class="wb-cal" id="wbIcs" type="button">
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3"/></svg>
          Add to calendar (.ics)
        </button>
      </div>
    </div>
  </div>
</section>
<script>
/* Webinar stage — countdown → wall-clock-synced premiere or live OBS feed.
   Self-contained, no platform API dependency, so it runs verbatim on live.ibm.com.

   ─────────────────────────────────────────────────────────────────────────────
   TO GO LIVE: edit the WEBINAR config below. Today only `startTime` matters —
   the stage shows a countdown to it. When the recording or stream is ready,
   paste ONE source (vodHls / mp4 / liveHls / youTubeId) and the stage becomes
   the player automatically. Recommended host: Cloudflare Stream (one product
   does both the uploaded recording's HLS and an OBS RTMP/SRT live ingest);
   a plain MP4 on R2 is the zero-setup fallback for a pre-recorded talk.
   ───────────────────────────────────────────────────────────────────────────── */
(function () {
  const WEBINAR = {
    // ⚠️  SET THE REAL START TIME — ISO 8601 with timezone offset (Z = UTC).
    //     Default below is 11:00 AM US Eastern on Jun 23, 2026 (EDT = UTC−4).
    startTime: '2026-06-23T15:00:00Z',
    durationMin: 60,                 // talk length → when the stage flips to "replay"
    title: 'three.ws × IBM — agentic commerce, live',
    details: 'A live walkthrough of x402 micropayments and 3D AI agents on three.ws. Demos run in real time at https://three.ws/ibm/x402-demo',
    location: 'https://three.ws/ibm/x402-demo',

    // ── Video source — leave ALL blank for countdown-only. Fill exactly ONE
    //    when ready. Resolution priority: liveHls → vodHls → mp4 → youTubeId.
    liveHls: '',     // OBS → ingest → HLS (.m3u8) live feed
    vodHls: '',      // Cloudflare Stream / Mux HLS (.m3u8) of the recording (synced premiere)
    mp4: '',         // plain MP4 on R2 (synced premiere)
    youTubeId: '',   // YouTube video / live id → iframe (its own premiere/live)
    mode: 'auto',    // 'auto' | 'premiere' | 'live'
  };

  const startMs = Date.parse(WEBINAR.startTime);
  if (!Number.isFinite(startMs)) { console.warn('[webinar] invalid startTime'); return; }
  const endMs = startMs + WEBINAR.durationMin * 60_000;

  const $ = (id) => document.getElementById(id);
  const stage = $('wbStage'), pre = $('wbPre'), holding = $('wbHolding'),
        player = $('wbPlayer'), badge = $('wbBadge'), unmute = $('wbUnmute');

  const hasSource = !!(WEBINAR.liveHls || WEBINAR.vodHls || WEBINAR.mp4 || WEBINAR.youTubeId);
  const isLiveSource = WEBINAR.mode === 'live' || (WEBINAR.mode === 'auto' && !!WEBINAR.liveHls && !WEBINAR.vodHls && !WEBINAR.mp4);

  // QA preview: ?wb=live | premiere | ended | countdown forces a phase, so the
  // player and the live path can be verified before the event without waiting on
  // the clock. Harmless in production — only takes effect when the param is set.
  const qaParam = (new URLSearchParams(location.search).get('wb') || '').toLowerCase();
  const QA_PHASE = { live: 'live', premiere: 'live', preview: 'live', ended: 'ended', countdown: 'pre' }[qaParam] || null;
  $('wbRetry').addEventListener('click', () => location.reload());

  // ── Schedule label + calendar links ──────────────────────────────────────
  const startDate = new Date(startMs);
  const whenStr = startDate.toLocaleString(undefined, {
    weekday: 'long', month: 'long', day: 'numeric',
    hour: 'numeric', minute: '2-digit', timeZoneName: 'short',
  });
  $('wbWhen').innerHTML = '<b>' + whenStr + '</b> · ' + WEBINAR.durationMin + ' min';

  const icsStamp = (ms) => new Date(ms).toISOString().replace(/[-:]/g, '').replace(/\.\d{3}/, '');
  const gcal = new URL('https://calendar.google.com/calendar/render');
  gcal.searchParams.set('action', 'TEMPLATE');
  gcal.searchParams.set('text', WEBINAR.title);
  gcal.searchParams.set('dates', icsStamp(startMs) + '/' + icsStamp(endMs));
  gcal.searchParams.set('details', WEBINAR.details);
  gcal.searchParams.set('location', WEBINAR.location);
  $('wbGcal').href = gcal.toString();

  $('wbIcs').addEventListener('click', () => {
    const ics = [
      'BEGIN:VCALENDAR', 'VERSION:2.0', 'PRODID:-//three.ws//webinar//EN',
      'BEGIN:VEVENT', 'UID:' + icsStamp(startMs) + '@three.ws',
      'DTSTAMP:' + icsStamp(Date.now()), 'DTSTART:' + icsStamp(startMs), 'DTEND:' + icsStamp(endMs),
      'SUMMARY:' + WEBINAR.title,
      'DESCRIPTION:' + WEBINAR.details.replace(/,/g, '\\,'),
      'LOCATION:' + WEBINAR.location, 'END:VEVENT', 'END:VCALENDAR',
    ].join('\r\n');
    const url = URL.createObjectURL(new Blob([ics], { type: 'text/calendar' }));
    const a = document.createElement('a');
    a.href = url; a.download = 'three-ws-ibm-webinar.ics';
    document.body.appendChild(a); a.click(); a.remove();
    setTimeout(() => URL.revokeObjectURL(url), 1000);
  });

  // ── Countdown ─────────────────────────────────────────────────────────────
  const pad = (n) => String(n).padStart(2, '0');
  let phase = '';
  function render() {
    const now = Date.now();
    let next = now < startMs ? 'pre' : (now < endMs ? 'live' : 'ended');
    if (QA_PHASE) next = QA_PHASE;
    if (now < startMs) {
      let s = Math.floor((startMs - now) / 1000);
      const d = Math.floor(s / 86400); s -= d * 86400;
      const h = Math.floor(s / 3600); s -= h * 3600;
      const m = Math.floor(s / 60); s -= m * 60;
      $('wbD').textContent = pad(d); $('wbH').textContent = pad(h);
      $('wbM').textContent = pad(m); $('wbS').textContent = pad(s);
    }
    if (next !== phase) { phase = next; applyPhase(); }
  }

  function applyPhase() {
    if (phase === 'pre') return; // countdown already visible
    pre.hidden = true;
    if (phase === 'ended' && !hasSource) {
      // Past the slot, no recording posted yet.
      holding.hidden = false;
      $('wbSpinner').style.display = 'none';
      $('wbHoldTitle').textContent = 'Thanks for joining';
      $('wbHoldMsg').textContent = 'The recording will be posted here shortly.';
      clearInterval(timer);
      return;
    }
    if (!hasSource) { holding.hidden = false; return; } // live window, awaiting source
    mountPlayer();
    clearInterval(timer);
  }

  // ── Player ──────────────────────────────────────────────────────────────
  function loadHls() {
    return new Promise((res, rej) => {
      if (window.Hls) return res(window.Hls);
      const s = document.createElement('script');
      s.src = 'https://cdn.jsdelivr.net/npm/[email protected]/dist/hls.min.js';
      s.onload = () => res(window.Hls); s.onerror = () => rej(new Error('hls.js load failed'));
      document.head.appendChild(s);
    });
  }

  // Designed, actionable error state — reuse the holding card with a retry.
  function showError(msg) {
    if (player) { player.hidden = true; player.innerHTML = ''; }
    badge.hidden = true; unmute.hidden = true;
    holding.hidden = false;
    $('wbSpinner').style.display = 'none';
    $('wbHoldTitle').textContent = 'Playback hit a snag';
    $('wbHoldMsg').textContent = msg || 'The stream is temporarily unavailable.';
    $('wbRetry').hidden = false;
  }

  async function mountPlayer() {
    holding.hidden = true; player.hidden = false;
    badge.hidden = !isLiveSource || phase !== 'live';

    if (WEBINAR.youTubeId) {
      const offset = Math.max(0, Math.floor((Date.now() - startMs) / 1000));
      const p = new URLSearchParams({ autoplay: '1', mute: '1', modestbranding: '1', rel: '0', playsinline: '1' });
      if (!isLiveSource && phase === 'live') p.set('start', String(offset));
      const f = document.createElement('iframe');
      f.src = 'https://www.youtube-nocookie.com/embed/' + WEBINAR.youTubeId + '?' + p.toString();
      f.allow = 'autoplay; encrypted-media; picture-in-picture; fullscreen';
      f.allowFullscreen = true; f.title = WEBINAR.title;
      player.appendChild(f);
      return;
    }

    const video = document.createElement('video');
    video.playsInline = true; video.controls = true; video.muted = true;
    video.setAttribute('controlslist', 'nodownload');
    player.appendChild(video);

    const src = WEBINAR.liveHls || WEBINAR.vodHls || WEBINAR.mp4;
    const isHls = /\.m3u8(\?|$)/i.test(src);
    let usingHls = false;
    try {
      if (isHls && !video.canPlayType('application/vnd.apple.mpegurl')) {
        const Hls = await loadHls();
        if (Hls.isSupported()) {
          usingHls = true;
          const hls = new Hls({ lowLatencyMode: isLiveSource });
          // Fatal-error recovery: retry network/media a few times, then surface a
          // clean error rather than leaving a black frame.
          let recover = 0;
          hls.on(Hls.Events.ERROR, (_evt, data) => {
            if (!data || !data.fatal) return;
            if (data.type === Hls.ErrorTypes.NETWORK_ERROR && recover < 3) { recover++; hls.startLoad(); }
            else if (data.type === Hls.ErrorTypes.MEDIA_ERROR && recover < 3) { recover++; hls.recoverMediaError(); }
            else { hls.destroy(); showError('The stream is temporarily unavailable — it may not have started yet.'); }
          });
          hls.loadSource(src); hls.attachMedia(video);
        } else { video.src = src; }
      } else {
        video.src = src; // native HLS (Safari) or MP4
      }
    } catch (e) { showError('We couldn’t start the player. Reload to try again.'); return; }

    // Native media error (MP4 / Safari HLS). The hls.js path reports through its
    // own ERROR event above, so skip this listener when hls.js owns the element.
    video.addEventListener('error', () => { if (!usingHls) showError('We couldn’t load the video — it may not be available yet.'); });

    // Premiere sync: a finished recording behaves like a broadcast — join at the
    // point the talk is actually at, and (during the live window) can't skip ahead.
    const isPremiere = !isLiveSource;
    video.addEventListener('loadedmetadata', () => {
      if (isPremiere && phase === 'live') {
        const offset = (Date.now() - startMs) / 1000;
        if (offset > 0 && offset < (video.duration || Infinity)) video.currentTime = offset;
      }
    }, { once: true });
    if (isPremiere && phase === 'live') {
      video.addEventListener('seeking', () => {
        const edge = (Date.now() - startMs) / 1000 + 1.5;
        if (video.currentTime > edge) video.currentTime = Math.max(0, edge - 1.5);
      });
    }

    video.play().then(() => {
      if (video.muted) unmute.hidden = false; // autoplay needs muted; offer one-tap unmute
    }).catch(() => { unmute.hidden = false; });

    unmute.addEventListener('click', () => {
      video.muted = false; unmute.hidden = true; video.play().catch(() => {});
    });
  }

  // Assign the interval BEFORE the first render() so an at/after-start load that
  // clears it on the opening tick doesn't hit `timer` in its temporal dead zone.
  let timer = setInterval(render, 1000);
  render();
})();
</script>

<!-- ══ DEMO 01 · FORGE (paid x402 prompt→3D) ══ -->
<section class="section" id="forge" aria-labelledby="forge-h">
  <div class="inner">
    <div class="section-tag">Demo 01 · Creation</div>
    <h2 id="forge-h" data-i18n-html="ibm_x402_demo.forge_a_3d_model_from_a_sentence">Forge a <strong>3D model</strong> from a sentence</h2>
    <p class="section-lead" data-i18n="ibm_x402_demo.this_pays_the_same_x402_rail_as">This pays the same x402 rail as the demo below — one USDC micropayment runs a real text→3D pipeline (Microsoft TRELLIS on NVIDIA NIM) and hands back a textured GLB you can orbit and download. The price below is read live from the server's own 402 response.</p>

    <div class="demo">
      <div class="demo-head">
        <div>
          <h3 class="demo-title" data-i18n-html="ibm_x402_demo.three_ws_forge">three<span>.ws</span> Forge</h3>
          <div class="demo-desc">Describe one object; pay; get back a textured, downloadable 3D model. Runs Microsoft TRELLIS on NVIDIA NIM (native text→mesh) — the same engine that builds the bodies our agents wear.</div>
        </div>
        <div class="price-tag">
          <div class="amt" id="fgPriceAmt" aria-hidden="true">$<strong>0.05</strong></div>
          <div class="net" aria-hidden="true">USDC · per model</div>
          <span class="sr-only" id="fgPriceSr" data-i18n="ibm_x402_demo.price_five_cents_in_usdc_per_generation">Price: five cents in USDC per generation.</span>
        </div>
      </div>

      <div class="demo-body">
        <!-- live 402 preview -->
        <div class="preview" id="fgPreview" role="region" aria-label="Live HTTP 402 payment challenge" aria-live="polite" aria-busy="true">
          <div class="preview-label" id="fgPvLabel"><span class="dot" aria-hidden="true"></span><span id="fgPvLabelText" data-i18n="ibm_x402_demo.reading_the_server_s_402_challenge">Reading the server's 402 challenge…</span></div>
          <div id="fgPvRows">
            <div class="preview-row"><span class="sk" style="width:38%"></span></div>
            <div class="preview-row"><span class="sk" style="width:54%"></span></div>
            <div class="preview-row"><span class="sk" style="width:46%"></span></div>
          </div>
        </div>

        <!-- quality tier -->
        <div class="tier-row" id="fgTiers" role="radiogroup" aria-label="Generation quality tier">
          <button class="tier" type="button" role="radio" aria-checked="true" tabindex="0" data-tier="draft" data-i18n-html="ibm_x402_demo.draft_0_05_fast_preview_geometry_best">
            <span class="t-name"><span class="t-tier">Draft</span><span class="t-price" data-price>$0.05</span></span>
            <span class="t-blurb">Fast preview geometry. Best to try the flow.</span>
            <span class="t-eta" data-eta>~40s</span>
          </button>
          <button class="tier" type="button" role="radio" aria-checked="false" tabindex="-1" data-tier="standard" data-i18n-html="ibm_x402_demo.standard_0_15_balanced_detail_the_default">
            <span class="t-name"><span class="t-tier">Standard</span><span class="t-price" data-price>$0.15</span></span>
            <span class="t-blurb">Balanced detail. The default for most assets.</span>
            <span class="t-eta" data-eta>~60s</span>
          </button>
          <button class="tier" type="button" role="radio" aria-checked="false" tabindex="-1" data-tier="high" data-i18n-html="ibm_x402_demo.high_0_50_maximum_geometry_pbr_textures">
            <span class="t-name"><span class="t-tier">High</span><span class="t-price" data-price>$0.50</span></span>
            <span class="t-blurb">Maximum geometry + PBR textures. Slower.</span>
            <span class="t-eta" data-eta>~130s</span>
          </button>
        </div>

        <!-- input -->
        <div class="field-row">
          <div class="field-wrap">
            <label for="fgPrompt" data-i18n="ibm_x402_demo.describe_the_object">Describe the object</label>
            <input id="fgPrompt" class="field" value="a brass steampunk owl, full body" maxlength="1000" autocomplete="off" spellcheck="true" inputmode="text" aria-describedby="fgPromptHint">
            <div class="field-hint" id="fgPromptHint">One subject works best — describe it in a sentence.</div>
          </div>
          <button id="fgBtn" class="btn" type="button" data-i18n-html="ibm_x402_demo.pay_0_05_forge"><span class="spin" aria-hidden="true"></span><span class="label">Pay $0.05 &amp; forge</span> <span class="arrow" aria-hidden="true">→</span></button>
        </div>
        <div class="wallet-hint" id="fgWalletHint">On a phone? Open this page inside your <b data-i18n="ibm_x402_demo.phantom">Phantom</b> wallet's in-app browser to pay.</div>

        <!-- result. Not a live region (its success state holds a raw-JSON block);
             concise spoken updates go to #fgAnnouncer instead. -->
        <div id="fgResult" class="result is-empty">
          Forge a model to see it appear here — orbit it, then download the GLB.
        </div>
        <p id="fgAnnouncer" class="sr-only" role="status" aria-live="polite"></p>

        <!-- requirements -->
        <div class="note">
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/></svg>
          <p data-i18n-html="ibm_x402_demo.you_ll_need_the_phantom_wallet_on">You'll need the <b>Phantom</b> wallet on <b>Solana</b> — holding the model's price in <b>USDC</b> on Solana mainnet. This spends <b>real USDC</b> — the price shown above — from your own wallet. The payment itself is a gasless signature: the network fee is sponsored by the x402 facilitator, so it isn't added to your cost. Generation runs once the payment verifies and takes roughly a minute. No wallet? Forge one <b>free</b> below — no wallet, no key, no payment.</p>
        </div>
      </div>
    </div>

      <!-- Free, no-wallet companion to the paid Forge above. Same text→3D
           pipeline (Microsoft TRELLIS on NVIDIA NIM), on the house — no wallet,
           no key, no payment. POSTs the free /api/forge lane and polls it. -->
      <div class="g3d">
        <div class="g3d-tag">Live · Free · No wallet</div>
        <h4 id="g3d-h" data-i18n-html="ibm_x402_demo.or_forge_one_free_no_wallet_needed">Or forge one <strong>free</strong> — no wallet needed</h4>
        <p class="g3d-sub" data-i18n="ibm_x402_demo.the_same_pipeline_on_the_house_no">The same pipeline, on the house. No wallet, no API key, no payment — it runs Microsoft TRELLIS on NVIDIA NIM with automatic fallback across generation lanes, so a textured GLB always comes back to orbit and download.</p>
        <div class="g3d-field">
          <label for="g3dPrompt" class="sr-only" data-i18n="ibm_x402_demo.describe_an_object_to_generate_for_free">Describe an object to generate for free</label>
          <input id="g3dPrompt" class="g3d-input" value="a brass steampunk owl, full body" maxlength="600" autocomplete="off" spellcheck="true" inputmode="text" aria-describedby="g3d-h">
          <button id="g3dBtn" class="g3d-btn" type="button" data-i18n-html="ibm_x402_demo.generate_free"><span class="g3d-spin" aria-hidden="true"></span><span class="g3d-label">Generate free</span> <span aria-hidden="true">→</span></button>
        </div>
        <div class="g3d-suggest" id="g3dSuggest" aria-label="Example prompts">
          <button type="button" data-p="a low-poly red fox, sitting" data-i18n="ibm_x402_demo.low_poly_fox">low-poly fox</button>
          <button type="button" data-p="a glossy ceramic teapot with gold trim" data-i18n="ibm_x402_demo.ceramic_teapot">ceramic teapot</button>
          <button type="button" data-p="a futuristic delivery drone" data-i18n="ibm_x402_demo.delivery_drone">delivery drone</button>
          <button type="button" data-p="a worn leather hiking boot" data-i18n="ibm_x402_demo.hiking_boot">hiking boot</button>
        </div>
        <div id="g3dResult" class="g3d-result is-empty">
          Describe an object and generate — your model appears here to orbit and download.
        </div>
        <p id="g3dStatus" class="sr-only" role="status" aria-live="polite"></p>
      </div>

    <p class="forge-foot" data-i18n-html="ibm_x402_demo.want_image_3d_auto_rigging_ar_preview">Want image→3D, auto-rigging, AR preview and the full gallery? <a href="https://three.ws/forge" target="_blank" rel="noopener">Open the full Forge tool ↗</a></p>
  </div>
</section>

<!-- ══ HOW IT WORKS ══ -->
<section class="section" aria-labelledby="how-h">
  <div class="inner">
    <div class="section-tag">The protocol in three moves</div>
    <h2 id="how-h" data-i18n-html="ibm_x402_demo.how_x402_works">How <strong>x402</strong> works</h2>
    <ol class="steps">
      <li class="step">
        <div class="step-n">01 · REQUEST</div>
        <h3 data-i18n="ibm_x402_demo.you_ask_normally">You ask normally</h3>
        <p data-i18n-html="ibm_x402_demo.a_plain_to_a_paid_endpoint_no">A plain <code>GET</code> to a paid endpoint — no payment attached yet.</p>
      </li>
      <li class="step">
        <div class="step-n">02 · 402 CHALLENGE</div>
        <h3 data-i18n="ibm_x402_demo.server_quotes_a_price">Server quotes a price</h3>
        <p data-i18n-html="ibm_x402_demo.it_replies_with_exactly_what_it_wants">It replies <code>402</code> with exactly what it wants: amount, asset, network, and the address to pay.</p>
      </li>
      <li class="step">
        <div class="step-n">03 · PAY &amp; RETRY</div>
        <h3 data-i18n="ibm_x402_demo.wallet_signs_call_settles">Wallet signs, call settles</h3>
        <p data-i18n-html="ibm_x402_demo.you_sign_a_gasless_usdc_authorization_resend">You sign a gasless USDC authorization, resend with an <code>X-PAYMENT</code> header, and the call settles on-chain — your data comes back.</p>
      </li>
    </ol>
  </div>
</section>

<!-- ══ LIVE DEMO ══ -->
<section class="section" id="demo" aria-labelledby="demo-h">
  <div class="inner">
    <div class="section-tag">Demo 02 · Payments</div>
    <h2 id="demo-h" data-i18n-html="ibm_x402_demo.buy_a_data_call_for_0_001">Buy a <strong>data call</strong> for $0.001</h2>
    <p class="section-lead" data-i18n="ibm_x402_demo.this_calls_a_real_three_ws_api">This calls a real three.ws API — a ticker-symbol availability check — for one tenth of a cent in USDC, settled on-chain. The price below is read live from the server's own 402 response.</p>

    <div class="demo">
      <div class="demo-head">
        <div>
          <h3 class="demo-title" data-i18n-html="ibm_x402_demo.three_ws_symbol_check">three<span>.ws</span> Symbol Check</h3>
          <div class="demo-desc">Is a ticker already taken? Returns exact and look-alike matches across symbols indexed by three.ws.</div>
        </div>
        <div class="price-tag">
          <div class="amt" id="priceAmt" aria-hidden="true">$<strong>0.001</strong></div>
          <div class="net" aria-hidden="true">USDC · per call</div>
          <span class="sr-only" id="priceSr" data-i18n="ibm_x402_demo.price_one_tenth_of_a_cent_in">Price: one tenth of a cent in USDC per call.</span>
        </div>
      </div>

      <div class="demo-body">
        <!-- live 402 preview -->
        <div class="preview" role="region" aria-label="Live HTTP 402 payment challenge" aria-live="polite" aria-busy="true">
          <div class="preview-label" id="pvLabel"><span class="dot" aria-hidden="true"></span><span id="pvLabelText" data-i18n="ibm_x402_demo.reading_the_server_s_402_challenge_2">Reading the server's 402 challenge…</span></div>
          <div id="pvRows">
            <div class="preview-row"><span class="sk" style="width:38%"></span></div>
            <div class="preview-row"><span class="sk" style="width:54%"></span></div>
            <div class="preview-row"><span class="sk" style="width:46%"></span></div>
          </div>
        </div>

        <!-- input -->
        <div class="field-row">
          <div class="field-wrap">
            <label for="ticker" data-i18n="ibm_x402_demo.ticker_to_check">Ticker to check</label>
            <input id="ticker" class="field" value="GRANITE" maxlength="32" autocomplete="off" spellcheck="false" autocapitalize="characters" inputmode="text" aria-describedby="tickerHint">
            <div class="field-hint" id="tickerHint">A–Z and 0–9, up to 32 characters.</div>
          </div>
          <button id="payBtn" class="btn" type="button" data-i18n-html="ibm_x402_demo.pay_0_001_run"><span class="spin" aria-hidden="true"></span><span class="label">Pay $0.001 &amp; run</span> <span class="arrow" aria-hidden="true">→</span></button>
        </div>
        <div class="wallet-hint" id="walletHint">On a phone? Open this page inside your <b data-i18n="ibm_x402_demo.metamask">MetaMask</b> or <b data-i18n="ibm_x402_demo.phantom_2">Phantom</b> in-app browser to pay.</div>

        <!-- result. The visible panel is NOT a live region (its success state
             contains a raw-JSON block that would otherwise be read aloud in full).
             Concise spoken updates go to #announcer instead. -->
        <div id="result" class="result is-empty">
          Run the call to see live, on-chain-paid data appear here.
        </div>
        <p id="announcer" class="sr-only" role="status" aria-live="polite"></p>

        <!-- requirements -->
        <div class="note">
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/></svg>
          <p>You'll need a browser wallet — <b data-i18n="ibm_x402_demo.metamask_2">MetaMask</b> (Base) or <b data-i18n="ibm_x402_demo.phantom_3">Phantom</b> (Solana) — holding at least <b data-i18n="ibm_x402_demo.0_001_usdc">$0.001 USDC</b> on mainnet. This spends <b data-i18n="ibm_x402_demo.real_usdc">real USDC</b> — one tenth of a cent — from your own wallet. The payment itself is a gasless signature: the network fee is sponsored by the x402 facilitator, so it isn't added to your cost (it isn't zero, just not yours to pay). No wallet? You can still watch the live 402 challenge above and read the <a href="https://three.ws/docs/x402" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.protocol_docs">protocol docs</a>. <span class="note-aside" data-i18n-html="ibm_x402_demo.paying_with_metamask_on_base_is_fully">Paying with <b>MetaMask</b> on Base is fully self-contained — it talks only to three.ws. Paying with <b>Phantom</b> on Solana additionally loads a small library from <span class="mono">esm.sh</span>; if a strict host security policy blocks it, the Solana button reports it clearly and the Base path keeps working.</span></p>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- ══ THE AGENT ══ -->
<section class="section" id="agent" aria-labelledby="agent-h">
  <div class="inner">
    <div class="section-tag">Demo 03 · Embodiment</div>
    <h2 id="agent-h" data-i18n-html="ibm_x402_demo.an_agent_that_pays_for_its_own">An <strong>agent</strong> that pays for its own data</h2>
    <p class="section-lead" data-i18n="ibm_x402_demo.everything_you_just_did_by_hand_read">Everything you just did by hand — read the price, sign, settle — an autonomous agent can do on its own. This is one of them: a 3D agent from three.ws, rendered live in your browser. It watches the call above and reacts the moment your payment settles.</p>

    <div class="agent-grid">
      <div class="agent-stage">
        <!-- A bare, transparent 3D avatar — no chat, no debug controls, no name-plate.
             A plain <agent-3d> given only a `body` is bare by default; it renders the
             avatar and nothing else. The web component lazy-boots when scrolled into
             view; until it upgrades, this skeleton holds the frame so the box is never blank. -->
        <agent-3d
          id="guideAgent"
          body="https://three.ws/avatars/default.glb"
          background="transparent"
          width="100%" height="460px">
        </agent-3d>
        <div class="agent-skel" aria-hidden="true"><span class="s-head"></span><span class="s-body"></span></div>
      </div>

      <div class="agent-copy">
        <h3 data-i18n="ibm_x402_demo.it_reacts_to_the_payment_above_in">It reacts to the payment above — in real time</h3>
        <p data-i18n="ibm_x402_demo.run_the_0_001_call_and_watch">Run the $0.001 call and watch: the agent celebrates the moment the transaction settles. The same primitives that power the demo button power it — it signs, pays, and reads results exactly the way you just did, only autonomously.</p>
        <p data-i18n="ibm_x402_demo.rendered_live_in_the_browser_with_webgl">Rendered live in the browser with WebGL — no video, no pre-recording.</p>
      </div>
    </div>
  </div>
</section>

<!-- ══ DEMO 04 · PLAY ══ -->
<section class="section" id="play" aria-labelledby="play-h">
  <div class="inner">
    <div class="section-tag">Demo 04 · Worlds</div>
    <h2 id="play-h" data-i18n-html="ibm_x402_demo.play_drop_an_agent_into_a_live">Play — drop an agent into a <strong>live world</strong></h2>
    <p class="section-lead" data-i18n="ibm_x402_demo.every_coin_on_three_ws_is_a">Every coin on three.ws is a 3D space agents and visitors share in real time — walk in, pick an avatar, and move around a world that reacts to live on-chain activity. Pick a name and a body below to enter; it runs full-size, right on the page.</p>
    <div class="live-embed" data-src="https://three.ws/play?bg=transparent" data-allow="fullscreen; gamepad; autoplay; xr-spatial-tracking; microphone" data-label="Play — three.ws">
      <div class="embed-bar">
        <span class="bar-url" data-i18n-html="ibm_x402_demo.three_ws_play"><span class="dot" aria-hidden="true"></span>three.ws/play</span>
        <span class="bar-actions">
          <button type="button" data-fs data-i18n="ibm_x402_demo.full_screen">⤢ Full screen</button>
          <a href="https://three.ws/play" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.new_tab">New tab ↗</a>
        </span>
      </div>
      <div class="embed-frame">
        <div class="embed-load embed-state"><span class="spin" aria-hidden="true"></span><span data-i18n="ibm_x402_demo.loading_the_live_world">Loading the live world…</span></div>
        <div class="embed-err embed-state">Play couldn't load inline here. <span class="es-hint" data-i18n-html="ibm_x402_demo.open_it_in_a_new_tab"><a href="https://three.ws/play" target="_blank" rel="noopener">Open it in a new tab ↗</a></span></div>
      </div>
    </div>
  </div>
</section>

<!-- ══ DEMO 05 · IRL ══ -->
<section class="section" id="irl" aria-labelledby="irl-h">
  <div class="inner">
    <div class="section-tag">Demo 05 · Reality</div>
    <h2 id="irl-h" data-i18n-html="ibm_x402_demo.irl_put_an_agent_in_the_real">IRL — put an agent in the <strong>real world</strong></h2>
    <p class="section-lead" data-i18n="ibm_x402_demo.anchor_a_3d_agent_to_physical_space">Anchor a 3D agent to physical space and see it through your camera, with real-world pins you place around you — you stay in control of every permission. AR is a phone experience, so it's best opened on a mobile device; the live surface is below, and the camera prompt only fires when you choose to enable it.</p>
    <div class="live-embed" data-src="https://three.ws/irl" data-allow="camera; gyroscope; accelerometer; magnetometer; xr-spatial-tracking; fullscreen" data-label="IRL — three.ws">
      <div class="embed-bar">
        <span class="bar-url" data-i18n-html="ibm_x402_demo.three_ws_irl"><span class="dot" aria-hidden="true"></span>three.ws/irl</span>
        <span class="bar-actions">
          <button type="button" data-fs data-i18n="ibm_x402_demo.full_screen_2">⤢ Full screen</button>
          <a href="https://three.ws/irl" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.open_on_your_phone">Open on your phone ↗</a>
        </span>
      </div>
      <div class="embed-frame">
        <div class="embed-load embed-state"><span class="spin" aria-hidden="true"></span><span data-i18n="ibm_x402_demo.loading_irl">Loading IRL…</span></div>
        <div class="embed-err embed-state">IRL couldn't load inline here — augmented reality works best opened directly on a phone. <span class="es-hint" data-i18n-html="ibm_x402_demo.open_it_on_your_device"><a href="https://three.ws/irl" target="_blank" rel="noopener">Open it on your device ↗</a></span></div>
      </div>
    </div>
  </div>
</section>

<!-- ══ EMBED ══ -->
<section class="section" aria-labelledby="embed-h">
  <div class="inner">
    <div class="section-tag">For developers</div>
    <h2 id="embed-h" data-i18n-html="ibm_x402_demo.add_a_paywall_in_eight_lines">Add a paywall in <strong>eight lines</strong></h2>
    <p class="section-lead" data-i18n-html="ibm_x402_demo.the_button_above_is_powered_by_one">The button above is powered by one drop-in script. Any element with a <span class="mono">data-x402-endpoint</span> opens the wallet flow on click — no framework, no build step, no SDK.</p>
    <div class="embed-block" id="embedCode"><span class="c-com" data-i18n="ibm_x402_demo.text">&lt;!-- one script tag, served from three.ws --&gt;</span>
<span class="c-tag" data-i18n="ibm_x402_demo.script">&lt;script</span> <span class="c-attr" data-i18n="ibm_x402_demo.type">type</span>=<span class="c-str" data-i18n="ibm_x402_demo.module">"module"</span> <span class="c-attr" data-i18n="ibm_x402_demo.src">src</span>=<span class="c-str" data-i18n="ibm_x402_demo.https_three_ws_x402_js">"https://three.ws/x402.js"</span><span class="c-tag" data-i18n="ibm_x402_demo.text_2">&gt;&lt;/script&gt;</span>

<span class="c-com" data-i18n="ibm_x402_demo.text_3">&lt;!-- any element with data-x402-endpoint becomes payable --&gt;</span>
<span class="c-tag" data-i18n="ibm_x402_demo.button">&lt;button</span>
  <span class="c-attr" data-i18n="ibm_x402_demo.data_x402_endpoint">data-x402-endpoint</span>=<span class="c-str" data-i18n="ibm_x402_demo.https_three_ws_api_x402_symbol_availability">"https://three.ws/api/x402/symbol-availability?ticker=GRANITE"</span>
  <span class="c-attr" data-i18n="ibm_x402_demo.data_x402_merchant">data-x402-merchant</span>=<span class="c-str" data-i18n="ibm_x402_demo.three_ws_2">"three.ws"</span>
  <span class="c-attr" data-i18n="ibm_x402_demo.data_x402_action">data-x402-action</span>=<span class="c-str" data-i18n="ibm_x402_demo.check_symbol">"Check symbol"</span><span class="c-tag">&gt;</span>
  Pay $0.001 &amp; run
<span class="c-tag" data-i18n="ibm_x402_demo.text_4">&lt;/button&gt;</span></div>
    <div class="copy-row"><button class="copy-btn" id="copyBtn" type="button" data-i18n="ibm_x402_demo.copy_snippet">Copy snippet</button></div>
  </div>
</section>
</main>

<!-- ══ FOOTER ══ -->
<footer class="footer">
  <div class="inner">
    <nav class="footer-nav" aria-label="Footer">
      <a href="https://three.ws" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.platform">Platform</a>
      <a href="https://three.ws/docs/x402" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.x402_protocol">x402 Protocol</a>
      <a href="https://three.ws/docs/ibm" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.ibm_three_ws">IBM × three.ws</a>
      <a href="https://three.ws/bazaar" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.endpoint_bazaar">Endpoint Bazaar</a>
      <a href="https://three.ws/forge" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.forge">Forge</a>
      <a href="https://three.ws/play" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.play">Play</a>
      <a href="https://three.ws/irl" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.irl">IRL</a>
      <a href="https://three.ws/changelog" target="_blank" rel="noopener" data-i18n="ibm_x402_demo.changelog">Changelog</a>
    </nav>
    <div class="footer-legal">
      Live x402 demo · three.ws, an IBM Business Partner. Payments settle in USDC on Base or Solana mainnet via the x402 protocol. The only coin this platform issues is $THREE (FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump).
    </div>
  </div>
</footer>

<!-- x402 drop-in payment modal (Phantom/MetaMask wallet flow + 402 retry).
     Same-origin on purpose: the copyable snippet above shows the absolute
     https://three.ws/x402.js an external embedder needs, but this page ships
     with the file, and loading its own copy across an origin means every
     non-production origin (a preview deploy, a local run, an audit sweep)
     gets the script CORS-blocked and the paid demos below never arm. -->
<script type="module" src="/x402.js"></script>
<!-- <agent-3d> web component — the whole 3D agent framework in one tag. Lazy-boots when scrolled into view. -->
<script type="module" src="https://three.ws/agent-3d/latest/agent-3d.js"></script>

<script>
(function () {
  'use strict';

  // The paid endpoint this demo calls. Swap to any three.ws x402 GET endpoint
  // and the price tag + 402 preview adapt automatically (the result renderer is
  // shaped for symbol-availability — update renderResultDone if you change it).
  var ENDPOINT = 'https://three.ws/api/x402/symbol-availability';
  // Per-call spend ceiling (micro-USD) handed to the widget as a safety rail:
  // $0.01, so a $0.001 call always clears but a misconfigured price can't drain.
  var MAX_PER_CALL_MICRO_USD = 10000;

  var $ = function (id) { return document.getElementById(id); };
  var inFlight = false;
  // Networks the live 402 challenge is currently quoting (e.g. "Base or Solana").
  // Used to make error guidance specific — "top up USDC on <network>".
  var quotedNetworks = '';

  // ── global resilience net ────────────────────────────────────────────────
  // Last-ditch catch for an unexpected throw or rejected promise, so a visitor
  // sees a calm, dismissible notice instead of a half-rendered panel. It is
  // deliberately conservative: this page also loads a lazy-booting 3D agent,
  // <model-viewer>, and cross-origin embeds, all of which own their own failure
  // UI. Their noise (and opaque cross-origin "Script error." with no detail, or
  // aborted fetches) must never raise an alarming banner on an IBM property.
  // Shows once; the close button re-arms it.
  var bannerShown = false;
  function showBanner(msg) {
    var b = $('errBanner'); if (!b || bannerShown) return;
    bannerShown = true;
    $('errBannerText').textContent = msg || 'Something went wrong. Reload the page if it persists.';
    b.classList.add('show');
  }
  // Noise, or failures owned by a third-party module that renders its own state.
  var BENIGN_ERR = /ResizeObserver|^Script error\.?$|model-viewer|agent-3d|esm\.sh|WebGL|webgl|\.glb\b|Loading chunk|importing a module|dynamically imported|AbortError|The operation was aborted|NetworkError when attempting/i;
  function isBenignReason(reason) {
    if (reason == null) return true;                         // no detail → not actionable
    if (reason.name === 'AbortError' || reason.code === 'cancelled') return true;
    var text = reason.message ? reason.message : String(reason);
    return BENIGN_ERR.test(text);
  }
  window.addEventListener('error', function (e) {
    // No message → opaque cross-origin error (carries nothing actionable); skip.
    if (!e || !e.message || BENIGN_ERR.test(e.message)) return;
    showBanner('A script error occurred. The demo may be degraded — reload to recover.');
  });
  window.addEventListener('unhandledrejection', function (e) {
    if (isBenignReason(e && e.reason)) return;
    showBanner('A background request failed. Check your connection, then retry below.');
  });
  $('errBannerClose').addEventListener('click', function () {
    $('errBanner').classList.remove('show'); bannerShown = false;
  });

  function escapeHtml(s) {
    return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
      return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
    });
  }
  function prefersReducedMotion() {
    return !!(window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches);
  }
  // Replay a one-shot CSS animation class, no-op under reduced motion.
  function flashPrice(el) {
    if (!el || prefersReducedMotion()) return;
    el.classList.remove('flash');
    void el.offsetWidth; // reflow so the animation restarts on repeat changes
    el.classList.add('flash');
    el.addEventListener('animationend', function once() {
      el.classList.remove('flash');
      el.removeEventListener('animationend', once);
    });
  }
  function sanitizeTicker(raw) {
    return String(raw || '').toUpperCase().replace(/[^A-Z0-9]/g, '').slice(0, 32);
  }
  function shortAddr(a) {
    if (!a) return '—';
    a = String(a);
    return a.length > 16 ? a.slice(0, 6) + '…' + a.slice(-4) : a;
  }
  function fmtUsd(atomics, decimals) {
    var n = Number(atomics) / Math.pow(10, decimals == null ? 6 : decimals);
    if (!isFinite(n)) return '$—';
    if (n < 0.01) return '$' + n.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
    return '$' + n.toFixed(2);
  }
  function networkLabel(net) {
    if (!net) return '—';
    if (net.indexOf('solana') === 0) return 'Solana';
    if (net === 'eip155:8453') return 'Base';
    if (net.indexOf('eip155:') === 0) return 'EVM ' + net.split(':')[1];
    return net;
  }
  function explorerUrl(net, tx) {
    if (!tx || !net) return null;
    if (net.indexOf('solana') === 0) return 'https://solscan.io/tx/' + tx;
    if (net === 'eip155:8453') return 'https://basescan.org/tx/' + tx;
    return null;
  }

  // ── 3D agent layer ────────────────────────────────────────────────────────
  // The <agent-3d> element exposes scripted, LLM-free reactions (expressEmotion,
  // playEmote, wave, notify). We drive those from the real payment lifecycle so
  // the agent visibly responds to the same on-chain events the demo renders —
  // no faked timing, no canned animation loop.
  var agentReady = false;
  function agentEl() { return document.getElementById('guideAgent'); }
  // Fire a reaction only once the component has booted; calls before that no-op
  // safely inside the element, but gating avoids wasted work.
  function agentReact(fn) {
    var el = agentEl();
    if (!el || !agentReady) return;
    try { fn(el); } catch (_) {}
  }
  // The avatar is bare (no chat) — we only track when it has booted so its
  // scripted reactions to the payment lifecycle can fire.
  function wireAgent() {
    var el = agentEl();
    if (!el) return;
    el.addEventListener('agent:ready', function () { agentReady = true; });
  }
  function agentOnWaiting() {
    agentReact(function (el) { if (el.expressEmotion) el.expressEmotion('patience', 0.6); });
  }
  function agentOnSettled() {
    agentReact(function (el) {
      if (el.expressEmotion) el.expressEmotion('celebration', 0.95);
      if (el.playEmote) el.playEmote('cheer');
    });
  }
  function agentOnError() {
    agentReact(function (el) { if (el.expressEmotion) el.expressEmotion('concern', 0.8); });
  }

  // ── full-size demo embeds (Forge / Play / IRL) ─────────────────────────────
  // Each presents a real, framable production surface at full size. The iframe
  // is created only as the section nears the viewport (IntersectionObserver),
  // so three heavy apps never load at once on first paint. A load timeout falls
  // back to an "open in a new tab" path; the Full-screen button uses the real
  // Fullscreen API.
  function loadEmbed(embed) {
    if (embed.dataset.loaded === '1') return;
    embed.dataset.loaded = '1';
    var frame = embed.querySelector('.embed-frame');
    var iframe = document.createElement('iframe');
    iframe.title = embed.getAttribute('data-label') || 'three.ws demo';
    iframe.loading = 'lazy';
    // `data-allow` already carries `fullscreen`, which is the modern Permissions-Policy
    // way to grant it; adding the legacy `allowfullscreen` attribute too just makes the
    // browser warn that `allow` takes precedence, so we rely on `allow` alone.
    iframe.setAttribute('allow', embed.getAttribute('data-allow') || '');
    iframe.setAttribute('referrerpolicy', 'no-referrer-when-downgrade');
    var timer = setTimeout(function () {
      if (!embed.classList.contains('loaded')) embed.classList.add('failed');
    }, 15000);
    iframe.addEventListener('load', function () {
      clearTimeout(timer);
      embed.classList.add('loaded');
    });
    iframe.src = embed.getAttribute('data-src');
    frame.appendChild(iframe);
  }
  function wireLiveEmbeds() {
    var embeds = document.querySelectorAll('.live-embed');
    Array.prototype.forEach.call(embeds, function (embed) {
      var fsBtn = embed.querySelector('[data-fs]');
      if (fsBtn) fsBtn.addEventListener('click', function () {
        var req = embed.requestFullscreen || embed.webkitRequestFullscreen;
        if (req) { try { req.call(embed); } catch (_) {} }
        else { window.open(embed.getAttribute('data-src'), '_blank', 'noopener'); }
      });
    });
    if ('IntersectionObserver' in window) {
      var io = new IntersectionObserver(function (entries) {
        entries.forEach(function (e) {
          if (e.isIntersecting) { loadEmbed(e.target); io.unobserve(e.target); }
        });
      }, { rootMargin: '400px 0px' });
      Array.prototype.forEach.call(embeds, function (embed) { io.observe(embed); });
    } else {
      Array.prototype.forEach.call(embeds, loadEmbed);
    }
  }

  // ── 1. live 402 challenge preview ─────────────────────────────────────────
  function loadChallengePreview() {
    var ticker = sanitizeTicker($('ticker').value) || 'GRANITE';
    var preview = document.querySelector('.preview');
    if (preview) preview.setAttribute('aria-busy', 'true');
    fetch(ENDPOINT + '?ticker=' + encodeURIComponent(ticker), { method: 'GET' })
      .then(function (res) {
        if (res.status !== 402 && res.status !== 401) throw new Error('expected 402, got ' + res.status);
        return res.json().catch(function () { return null; });
      })
      .then(function (body) {
        var accepts = (body && body.accepts) || [];
        if (!accepts.length) throw new Error('no payment terms in challenge');
        renderChallengePreview(accepts);
      })
      .catch(function (err) {
        var label = $('pvLabel'); label.className = 'preview-label err';
        $('pvLabelText').textContent = navigator.onLine
          ? "Couldn't read the live price just now — the payment button still works."
          : "You're offline — the live price will load when you reconnect.";
        var detail = escapeHtml(String((err && err.message) || 'request failed')).slice(0, 120);
        $('pvRows').innerHTML =
          '<div class="preview-row"><span class="v" style="color:var(--ibm-subtle)">' + detail + '</span></div>' +
          '<button class="pv-retry" type="button" id="pvRetry">Retry</button>';
        var r = $('pvRetry'); if (r) r.addEventListener('click', loadChallengePreview);
      })
      .then(function () { if (preview) preview.setAttribute('aria-busy', 'false'); });
  }

  function renderChallengePreview(accepts) {
    var byNet = {};
    accepts.forEach(function (a) { if (a && a.network && !byNet[a.network]) byNet[a.network] = a; });
    var nets = Object.keys(byNet).map(function (k) { return byNet[k]; });
    var first = nets[0];
    var decimals = (first.extra && first.extra.decimals) || 6;
    quotedNetworks = nets.map(function (a) { return networkLabel(a.network); }).join(' or ');

    var priceHtml = first.amount === '1000'
      ? '$<strong>0.001</strong>'
      : escapeHtml(fmtUsd(first.amount, decimals)).replace(/^\$/, '$<strong>') + '</strong>';
    var amtEl = $('priceAmt');
    if (amtEl.innerHTML !== priceHtml) {
      amtEl.innerHTML = priceHtml;
      flashPrice(amtEl);
    }
    var priceText = escapeHtml(fmtUsd(first.amount, decimals));
    var srEl = $('priceSr'); if (srEl) srEl.textContent = 'Price: ' + priceText + ' USDC per call.';

    var label = $('pvLabel'); label.className = 'preview-label ok fresh';
    $('pvLabelText').innerHTML = '<span class="mono">HTTP 402 Payment Required</span> — the server is quoting these terms right now';

    var rows = '';
    rows += '<div class="preview-row"><span class="k">price</span><span class="v">' + escapeHtml(fmtUsd(first.amount, decimals)) + ' USDC</span></div>';
    var badges = nets.map(function (a) { return '<span class="badge">' + escapeHtml(networkLabel(a.network)) + '</span>'; }).join('');
    rows += '<div class="preview-row"><span class="k">networks</span><span class="v">' + badges + '</span></div>';
    nets.forEach(function (a) {
      rows += '<div class="preview-row"><span class="k">pay&nbsp;to</span><span class="v">' + escapeHtml(shortAddr(a.payTo)) + ' <span style="color:var(--ibm-subtle)">(' + escapeHtml(networkLabel(a.network)) + ')</span></span></div>';
    });
    rows += '<div class="preview-row"><span class="k">scheme</span><span class="v">' + escapeHtml(first.scheme || 'exact') + ' · gasless authorization</span></div>';
    $('pvRows').innerHTML = rows;
  }

  // ── 2. result states ──────────────────────────────────────────────────────
  // Concise spoken update to the off-screen live region. Clearing first guarantees
  // the change is detected even when the same text repeats.
  function announce(msg) {
    var a = $('announcer'); if (!a) return;
    a.textContent = '';
    // microtask defer so screen readers register the text change as new
    window.requestAnimationFrame(function () { a.textContent = msg || ''; });
  }
  function setResultEmpty() {
    var el = $('result'); el.className = 'result is-empty';
    el.innerHTML = 'Run the call to see live, on-chain-paid data appear here.';
    announce('');
  }
  function setResultLoading(msg) {
    var el = $('result'); el.className = 'result is-loading';
    el.innerHTML = '<div class="r-status"><span class="spin" aria-hidden="true"></span><span>' + escapeHtml(msg || 'Waiting for your wallet…') + '</span></div>';
    announce(msg || 'Waiting for your wallet.');
    agentOnWaiting();
  }
  // Turn a (sometimes cryptic) wallet/facilitator/network message into one line
  // of plain-language next-step guidance. Empty string when the message already
  // speaks for itself.
  function payGuidance(msg) {
    var m = String(msg || '').toLowerCase();
    if (/insufficient|not enough|exceeds balance|transfer amount exceeds|enough usdc|enough funds|low balance/.test(m)) {
      return 'Top up USDC on ' + (quotedNetworks || 'your wallet network') + ', then try again.';
    }
    if (/offline|failed to fetch|networkerror|connection|timeout|timed out|could not reach/.test(m)) {
      return 'Check your connection, then try again.';
    }
    return '';
  }
  function setResultError(msg) {
    var text = msg || 'Something went wrong.';
    var tip = payGuidance(text);
    var el = $('result'); el.className = 'result is-error';
    el.innerHTML = '<div class="r-status err"><span aria-hidden="true">✕</span> <span>' + escapeHtml(text) + '</span></div>' +
      (tip ? '<p class="r-tip">' + escapeHtml(tip) + '</p>' : '') +
      '<button class="retry" type="button" id="retryBtn">Try again</button>';
    var rb = $('retryBtn'); if (rb) rb.addEventListener('click', runPayment);
    announce('Error: ' + text + (tip ? ' ' + tip : ''));
    agentOnError();
  }
  function recoPill(result) {
    if (result.exact_collision) return '<span class="pill bad">taken</span>';
    var sim = result.similar && result.similar[0];
    if (sim && Number(sim.similarity) >= 0.8) return '<span class="pill warn">close match</span>';
    return '<span class="pill ok">available</span>';
  }
  function setResultDone(out) {
    var result = out.result || {};
    var payment = out.payment || {};
    var el = $('result'); el.className = 'result is-done';
    agentOnSettled(out);

    var html = '';
    html += '<div class="r-status ok"><span class="r-check" aria-hidden="true">✓</span><span>Payment settled — response delivered</span></div>';
    if (result.ticker) html += '<div class="r-headline">Ticker <strong>$' + escapeHtml(result.ticker) + '</strong></div>';
    if (result.recommendation) html += '<div class="r-reco">' + recoPill(result) + '<span>' + escapeHtml(result.recommendation) + '</span></div>';

    // Concise spoken summary — never the raw-JSON wall below.
    var spoken = 'Payment settled.';
    if (result.ticker) spoken += ' Ticker $' + result.ticker + '.';
    if (result.recommendation) spoken += ' ' + result.recommendation;
    announce(spoken);

    var exact = Array.isArray(result.exact_matches) ? result.exact_matches : [];
    var similar = Array.isArray(result.similar) ? result.similar : [];
    if (exact.length || similar.length) {
      html += '<div class="matches">';
      if (exact.length) {
        html += '<h4>Exact matches</h4>';
        exact.forEach(function (m) {
          html += '<div class="match"><span class="m-name"><b>' + escapeHtml(m.ticker) + '</b> · ' + escapeHtml(m.name || '') + '</span><span class="m-sim">' + escapeHtml(shortAddr(m.mint)) + '</span></div>';
        });
      }
      if (similar.length) {
        html += '<h4' + (exact.length ? ' style="margin-top:12px"' : '') + '>Look-alike symbols</h4>';
        similar.forEach(function (m) {
          html += '<div class="match"><span class="m-name"><b>' + escapeHtml(m.ticker) + '</b> · ' + escapeHtml(m.name || '') + '</span><span class="m-sim">sim ' + escapeHtml(m.similarity == null ? '—' : String(m.similarity)) + '</span></div>';
        });
      }
      html += '</div>';
    }

    var explorer = explorerUrl(payment.network, payment.transaction);
    html += '<dl class="receipt">';
    html += '<div class="receipt-pair"><dt class="rk">Network</dt><dd class="rv">' + escapeHtml(networkLabel(payment.network)) + '</dd></div>';
    html += '<div class="receipt-pair"><dt class="rk">Payer</dt><dd class="rv">' + escapeHtml(shortAddr(payment.payer)) + '</dd></div>';
    html += '<div class="receipt-pair"><dt class="rk">Transaction</dt><dd class="rv">' +
      (payment.transaction
        ? (explorer ? '<a href="' + explorer + '" target="_blank" rel="noopener">' + escapeHtml(shortAddr(payment.transaction)) + ' <span aria-hidden="true">↗</span><span class="sr-only"> (opens block explorer in a new tab)</span></a>' : escapeHtml(shortAddr(payment.transaction)))
        : '—') + '</dd></div>';
    html += '</dl>';

    html += '<details class="raw"><summary>View raw response &amp; settlement</summary><pre>' +
      escapeHtml(JSON.stringify({ response: result, payment: payment }, null, 2)).slice(0, 6000) + '</pre></details>';

    el.innerHTML = html;
  }

  // ── 3. payment ────────────────────────────────────────────────────────────
  function setBusy(b) {
    inFlight = b;
    var btn = $('payBtn');
    btn.disabled = b || !navigator.onLine;
    btn.classList.toggle('loading', b);
    btn.querySelector('.label').textContent = b ? 'Waiting for wallet…' : 'Pay $0.001 & run';
  }
  function setTickerError(msg) {
    var f = $('ticker'); var h = $('tickerHint');
    if (msg) { f.setAttribute('aria-invalid', 'true'); h.className = 'field-hint err'; h.textContent = msg; }
    else { f.removeAttribute('aria-invalid'); h.className = 'field-hint'; h.textContent = 'A–Z and 0–9, up to 32 characters.'; }
  }

  function runPayment() {
    if (inFlight) return; // double-click guard
    if (!navigator.onLine) { setResultError('You appear to be offline. Reconnect and try again.'); return; }

    var ticker = sanitizeTicker($('ticker').value);
    if (!ticker) { setTickerError('Enter a ticker (A–Z, 0–9) to check.'); $('ticker').focus(); return; }
    setTickerError(null);
    $('ticker').value = ticker;

    if (!window.X402 || typeof window.X402.pay !== 'function') {
      setResultError('Payment widget is still loading — give it a second and try again.');
      return;
    }

    var trigger = document.activeElement; // restore focus here when the modal closes
    setBusy(true);
    setResultLoading('Waiting for your wallet… approve the $0.001 USDC payment to continue.');

    window.X402.pay({
      endpoint: ENDPOINT + '?ticker=' + encodeURIComponent(ticker),
      method: 'GET',
      merchant: 'three.ws',
      action: 'Check $' + ticker + ' availability',
      caps: { maxPerCall: MAX_PER_CALL_MICRO_USD }
    }).then(function (out) {
      if (out && out.ok) setResultDone(out);
      else setResultError('The call did not complete. Please try again.');
    }).catch(function (err) {
      if (err && err.code === 'cancelled') { setResultEmpty(); return; }
      setResultError((err && err.message) || 'Payment failed. Please try again.');
    }).then(function () {
      setBusy(false);
      // Return focus to the trigger; if it was re-rendered out of the DOM
      // (e.g. the retry button), fall back to the pay button so focus is never
      // dropped to <body>.
      var t = (trigger && trigger.focus && document.body.contains(trigger)) ? trigger : $('payBtn');
      try { t.focus(); } catch (_) { try { $('payBtn').focus(); } catch (_2) {} }
    });
  }

  // ── wallet detection ────────────────────────────────────────────────────────
  // On phones, window.ethereum / window.solana only exist inside a wallet's in-app
  // browser, not in mobile Safari/Chrome. Reflect that reality in the hint so the
  // next step is obvious. The 402 preview stays fully functional regardless.
  function hasInjectedWallet() {
    return !!(window.ethereum || (window.solana && window.solana.isPhantom) || window.phantom);
  }
  function isCoarsePointer() {
    return !!(window.matchMedia && window.matchMedia('(pointer: coarse)').matches);
  }
  function syncWalletHint() {
    var hint = $('walletHint'); var btn = $('payBtn');
    if (!navigator.onLine) {
      hint.classList.remove('detected'); hint.classList.add('offline');
      hint.innerHTML = 'You are offline. Reconnect to read the live price and pay.';
      btn.disabled = true;
      return;
    }
    hint.classList.remove('offline');
    if (!inFlight) btn.disabled = false;
    if (hasInjectedWallet()) {
      hint.classList.add('detected');
      hint.innerHTML = '<b>Wallet detected.</b> You can pay this call directly.';
    } else if (isCoarsePointer()) {
      hint.classList.remove('detected');
      hint.innerHTML = 'No wallet in this browser. On a phone, open this page inside your <b>MetaMask</b> or <b>Phantom</b> (Solana) in-app browser to pay. You can still read the live 402 challenge above.';
    } else {
      hint.classList.remove('detected');
      hint.innerHTML = 'No wallet detected. Install <b>MetaMask</b> or <b>Phantom</b> (Solana) to pay — or just read the live 402 challenge above.';
    }
  }
  // Wallet extensions inject asynchronously; re-check briefly after load.
  // Two detection paths run in parallel and either one ends the wait:
  //   1. A short backoff poll for the injected globals (Phantom/legacy MetaMask).
  //   2. The EIP-6963 announce protocol — registered UP FRONT (below), before the
  //      first poll, and kicked with a requestProvider so compliant wallets reply
  //      immediately rather than only after our first 350ms tick.
  var walletPolls = 0;
  var walletPollTimer = null;
  function pollForWallet() {
    syncWalletHint();
    // Resolve immediately the instant a wallet appears — don't keep polling.
    if (hasInjectedWallet()) { walletPolls = 8; return; }
    if (walletPolls < 8) { walletPolls++; walletPollTimer = setTimeout(pollForWallet, 350); }
  }
  function onWalletDetected() {
    // A wallet announced or injected mid-poll: reflect it and stop the backoff.
    if (walletPollTimer) { clearTimeout(walletPollTimer); walletPollTimer = null; }
    walletPolls = 8;
    syncWalletHint();
  }
  window.addEventListener('online', function () { syncWalletHint(); loadChallengePreview(); });
  window.addEventListener('offline', syncWalletHint);
  // EIP-6963 announce + Phantom late-inject both surface via this event in practice.
  // Registered before polling starts so an early announcement is never missed, and
  // we proactively request announcements so wallets reply without waiting for a tick.
  window.addEventListener('eip6963:announceProvider', onWalletDetected);
  try { window.dispatchEvent(new Event('eip6963:requestProvider')); } catch (_) {}

  // ── wiring ──────────────────────────────────────────────────────────────────
  $('payBtn').addEventListener('click', runPayment);
  $('ticker').addEventListener('keydown', function (e) { if (e.key === 'Enter') { e.preventDefault(); runPayment(); } });
  var pvTimer;
  $('ticker').addEventListener('input', function () {
    setTickerError(null);
    clearTimeout(pvTimer);
    pvTimer = setTimeout(loadChallengePreview, 400);
  });

  $('copyBtn').addEventListener('click', function () {
    var snippet =
      '<script type="module" src="https://three.ws/x402.js"><\/script>\n\n' +
      '<button\n' +
      '  data-x402-endpoint="https://three.ws/api/x402/symbol-availability?ticker=GRANITE"\n' +
      '  data-x402-merchant="three.ws"\n' +
      '  data-x402-action="Check symbol">\n' +
      '  Pay $0.001 & run\n' +
      '</button>';
    var done = function (label) { var b = $('copyBtn'); b.textContent = label; setTimeout(function () { b.textContent = 'Copy snippet'; }, 1600); };
    if (navigator.clipboard && navigator.clipboard.writeText) {
      navigator.clipboard.writeText(snippet).then(function () { done('Copied ✓'); }, function () { done('Copy failed — select manually'); });
    } else {
      done('Select the code above to copy');
    }
  });

  wireAgent();
  wireLiveEmbeds();
  pollForWallet();
  loadChallengePreview();
})();
</script>

<!-- Demo 01 · Forge — paid x402 prompt→3D. Pays POST /api/x402/forge, then polls
     the free GET /api/forge?job=<id> for the finished GLB and orbits it inline. -->
<script type="module">
(function () {
  'use strict';

  var FORGE_ENDPOINT = 'https://three.ws/api/x402/forge';
  var POLL_ENDPOINT = 'https://three.ws/api/forge';
  // Per-tier atomic USDC prices (6 decimals) — refreshed live from the 402
  // challenge, but seeded so the UI is correct before the first fetch resolves.
  var TIER_ATOMIC = { draft: 50000, standard: 150000, high: 500000 };
  var TIER_ETA = { draft: 40, standard: 60, high: 130 };

  var $ = function (id) { return document.getElementById(id); };
  if (!$('fgBtn')) return; // section not present — nothing to wire

  var selectedTier = 'draft';
  var inFlight = false;
  var pollTimer = null;
  var genTimer = null;
  // Networks the live 402 challenge is quoting, for specific error guidance.
  var quotedNetworks = '';

  // model-viewer is heavy (~955 KB, bundles its own Three.js) and only needed once
  // a model has actually been forged. Load it lazily, self-hosted from ./vendor/, so
  // a page view that never forges pays nothing for it and its Three.js never co-exists
  // with the agent's at idle. Injected <model-viewer> elements upgrade automatically
  // once the module defines the custom element; a blocked/failed load never wedges the
  // result UI (the GLB download link still works).
  var _mvLoading = null;
  function ensureModelViewer() {
    if (_mvLoading) return _mvLoading;
    _mvLoading = new Promise(function (resolve) {
      if (window.customElements && customElements.get('model-viewer')) { resolve(); return; }
      var s = document.createElement('script');
      s.type = 'module';
      s.src = './vendor/model-viewer.min.js';
      s.addEventListener('error', resolve);
      document.head.appendChild(s);
      if (window.customElements) customElements.whenDefined('model-viewer').then(resolve, resolve);
      else resolve();
    });
    return _mvLoading;
  }

  function escapeHtml(s) {
    return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
      return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
    });
  }
  function prefersReducedMotion() {
    return !!(window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches);
  }
  function flashPrice(el) {
    if (!el || prefersReducedMotion()) return;
    el.classList.remove('flash'); void el.offsetWidth; el.classList.add('flash');
    el.addEventListener('animationend', function once() { el.classList.remove('flash'); el.removeEventListener('animationend', once); });
  }
  function shortAddr(a) {
    if (!a) return '—'; a = String(a);
    return a.length > 16 ? a.slice(0, 6) + '…' + a.slice(-4) : a;
  }
  function networkLabel(net) {
    if (!net) return '—';
    if (net.indexOf('solana') === 0) return 'Solana';
    if (net === 'eip155:8453') return 'Base';
    if (net.indexOf('eip155:') === 0) return 'EVM ' + net.split(':')[1];
    return net;
  }
  function explorerUrl(net, tx) {
    if (!tx || !net) return null;
    if (net.indexOf('solana') === 0) return 'https://solscan.io/tx/' + tx;
    if (net === 'eip155:8453') return 'https://basescan.org/tx/' + tx;
    return null;
  }
  function fmtUsd(atomics, decimals) {
    var n = Number(atomics) / Math.pow(10, decimals || 6);
    if (!isFinite(n)) return '$0';
    if (n < 0.01) return '$' + n.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
    return '$' + n.toFixed(2);
  }
  function priceLabel(tier) { return fmtUsd(TIER_ATOMIC[tier] || 50000, 6); }
  function announce(msg) {
    var a = $('fgAnnouncer'); if (!a) return;
    a.textContent = '';
    window.requestAnimationFrame(function () { a.textContent = msg || ''; });
  }

  function sanitizePrompt(raw) { return String(raw || '').replace(/\s+/g, ' ').trim().slice(0, 1000); }
  function setPromptError(msg) {
    var f = $('fgPrompt'), h = $('fgPromptHint');
    if (msg) { f.setAttribute('aria-invalid', 'true'); h.className = 'field-hint err'; h.textContent = msg; }
    else { f.removeAttribute('aria-invalid'); h.className = 'field-hint'; h.textContent = 'One subject works best — describe it in a sentence.'; }
  }
  function setBusy(b, label) {
    inFlight = b;
    var btn = $('fgBtn');
    btn.disabled = b || !navigator.onLine;
    btn.classList.toggle('loading', b);
    btn.querySelector('.label').textContent = b ? (label || 'Working…') : ('Pay ' + priceLabel(selectedTier) + ' & forge');
  }

  // ── price tag + button reflect the selected tier ─────────────────────────
  function syncTierUi() {
    var amt = $('fgPriceAmt');
    var html = escapeHtml(priceLabel(selectedTier)).replace(/^\$/, '$<strong>') + '</strong>';
    if (amt.innerHTML !== html) { amt.innerHTML = html; flashPrice(amt); }
    var sr = $('fgPriceSr'); if (sr) sr.textContent = 'Price: ' + priceLabel(selectedTier) + ' USDC per generation.';
    if (!inFlight) $('fgBtn').querySelector('.label').textContent = 'Pay ' + priceLabel(selectedTier) + ' & forge';
  }

  // ── tier prices from the public catalog (authoritative) ──────────────────
  function loadCatalog() {
    fetch(FORGE_ENDPOINT, { method: 'GET' })
      .then(function (r) { return r.ok ? r.json() : null; })
      .then(function (d) {
        var list = d && d.pricing_usdc;
        if (!Array.isArray(list)) return;
        list.forEach(function (t) {
          var atomic = Math.round(Number(t.price_usdc) * 1e6);
          if (t.tier && isFinite(atomic) && atomic > 0) TIER_ATOMIC[t.tier] = atomic;
        });
        document.querySelectorAll('#fgTiers .tier').forEach(function (btn) {
          var tier = btn.getAttribute('data-tier');
          var el = btn.querySelector('[data-price]');
          if (el && TIER_ATOMIC[tier]) el.textContent = fmtUsd(TIER_ATOMIC[tier], 6);
        });
        syncTierUi();
      })
      .catch(function () {});
  }

  // ── live 402 challenge preview for the selected tier ─────────────────────
  function loadChallengePreview() {
    var preview = $('fgPreview');
    if (preview) preview.setAttribute('aria-busy', 'true');
    var prompt = sanitizePrompt($('fgPrompt').value) || 'a brass steampunk owl, full body';
    fetch(FORGE_ENDPOINT, {
      method: 'POST',
      headers: { 'content-type': 'application/json' },
      body: JSON.stringify({ prompt: prompt, tier: selectedTier, aspect_ratio: '1:1' })
    })
      .then(function (res) {
        if (res.status !== 402 && res.status !== 401) throw new Error('expected 402, got ' + res.status);
        return res.json().catch(function () { return null; });
      })
      .then(function (body) {
        var accepts = (body && body.accepts) || [];
        if (!accepts.length) throw new Error('no payment terms in challenge');
        // Solana-only checkout — quote just the Solana terms in the live preview
        // so it matches the wallet flow. Fall back to all terms if the server
        // ever omits Solana, so the preview never renders empty.
        var solanaOnly = accepts.filter(function (a) { return a && typeof a.network === 'string' && a.network.indexOf('solana') === 0; });
        renderChallengePreview(solanaOnly.length ? solanaOnly : accepts);
      })
      .catch(function (err) {
        var label = $('fgPvLabel'); label.className = 'preview-label err';
        $('fgPvLabelText').textContent = navigator.onLine
          ? "Couldn't read the live price just now — the forge button still works."
          : "You're offline — the live price will load when you reconnect.";
        var detail = escapeHtml(String((err && err.message) || 'request failed')).slice(0, 120);
        $('fgPvRows').innerHTML =
          '<div class="preview-row"><span class="v" style="color:var(--ibm-subtle)">' + detail + '</span></div>' +
          '<button class="pv-retry" type="button" id="fgPvRetry">Retry</button>';
        var r = $('fgPvRetry'); if (r) r.addEventListener('click', loadChallengePreview);
      })
      .then(function () { if (preview) preview.setAttribute('aria-busy', 'false'); });
  }

  function renderChallengePreview(accepts) {
    var byNet = {};
    accepts.forEach(function (a) { if (a && a.network && !byNet[a.network]) byNet[a.network] = a; });
    var nets = Object.keys(byNet).map(function (k) { return byNet[k]; });
    var first = nets[0];
    var decimals = (first.extra && first.extra.decimals) || 6;
    quotedNetworks = nets.map(function (a) { return networkLabel(a.network); }).join(' or ');

    var atomic = Number(first.amount);
    if (isFinite(atomic) && atomic > 0) { TIER_ATOMIC[selectedTier] = atomic; syncTierUi(); }

    var label = $('fgPvLabel'); label.className = 'preview-label ok fresh';
    $('fgPvLabelText').innerHTML = '<span class="mono">HTTP 402 Payment Required</span> — the server is quoting these terms right now';

    var rows = '';
    rows += '<div class="preview-row"><span class="k">price</span><span class="v">' + escapeHtml(fmtUsd(first.amount, decimals)) + ' USDC · ' + escapeHtml(selectedTier) + '</span></div>';
    var badges = nets.map(function (a) { return '<span class="badge">' + escapeHtml(networkLabel(a.network)) + '</span>'; }).join('');
    rows += '<div class="preview-row"><span class="k">networks</span><span class="v">' + badges + '</span></div>';
    nets.forEach(function (a) {
      rows += '<div class="preview-row"><span class="k">pay&nbsp;to</span><span class="v">' + escapeHtml(shortAddr(a.payTo)) + ' <span style="color:var(--ibm-subtle)">(' + escapeHtml(networkLabel(a.network)) + ')</span></span></div>';
    });
    rows += '<div class="preview-row"><span class="k">returns</span><span class="v">a job token → poll for the finished GLB</span></div>';
    $('fgPvRows').innerHTML = rows;
  }

  // ── result states ─────────────────────────────────────────────────────────
  function setResultEmpty() {
    var el = $('fgResult'); el.className = 'result is-empty';
    el.innerHTML = 'Forge a model to see it appear here — orbit it, then download the GLB.';
    announce('');
  }
  function setResultLoading(msg) {
    var el = $('fgResult'); el.className = 'result is-loading';
    el.innerHTML = '<div class="r-status"><span class="spin" aria-hidden="true"></span><span>' + escapeHtml(msg) + '</span></div>';
    announce(msg);
  }
  function payGuidance(msg) {
    var m = String(msg || '').toLowerCase();
    if (/insufficient|not enough|exceeds balance|transfer amount exceeds|enough usdc|enough funds|low balance/.test(m)) {
      return 'Top up USDC on ' + (quotedNetworks || 'your wallet network') + ', then try again.';
    }
    if (/offline|failed to fetch|networkerror|connection|timeout|timed out|could not reach|lost contact/.test(m)) {
      return 'Check your connection, then try again.';
    }
    return '';
  }
  function setResultError(msg) {
    var text = msg || 'Something went wrong.';
    var tip = payGuidance(text);
    var el = $('fgResult'); el.className = 'result is-error';
    el.innerHTML = '<div class="r-status err"><span aria-hidden="true">✕</span> <span>' + escapeHtml(text) + '</span></div>' +
      (tip ? '<p class="r-tip">' + escapeHtml(tip) + '</p>' : '') +
      '<button class="retry" type="button" id="fgRetry">Try again</button>';
    var rb = $('fgRetry'); if (rb) rb.addEventListener('click', runForge);
    announce('Error: ' + text + (tip ? ' ' + tip : ''));
  }
  // The paid generation has settled but is taking longer than this inline demo can
  // wait. Rather than leave the visitor stranded, hand them the job in the full Forge
  // tool (the same backend, with a durable job view) so they can collect the result.
  function setResultStillWorking(msg, jobId) {
    var text = msg || 'Still working — your payment settled.';
    var forgeUrl = 'https://three.ws/forge' + (jobId ? '?job=' + encodeURIComponent(jobId) : '');
    var el = $('fgResult'); el.className = 'result is-error';
    el.innerHTML =
      '<div class="r-status err"><span aria-hidden="true">⏳</span> <span>' + escapeHtml(text) + '</span></div>' +
      '<p class="r-tip">Your payment went through and the model is still generating. Open it in the full Forge tool to watch it finish and download the GLB — your job is waiting there.</p>' +
      '<div class="r-actions">' +
      '<a class="r-btn" href="' + escapeHtml(forgeUrl) + '" target="_blank" rel="noopener">Continue in Forge ↗</a>' +
      '<button class="r-btn ghost" type="button" id="fgRetry">Try again</button>' +
      '</div>';
    var rb = $('fgRetry'); if (rb) rb.addEventListener('click', runForge);
    announce(text + ' Continue in the full Forge tool to collect your model.');
  }
  function setResultGenerating(payment, etaSec, startTs) {
    ensureModelViewer(); // warm the viewer during the generation wait so the result paints instantly
    var el = $('fgResult'); el.className = 'result is-loading';
    el.innerHTML =
      '<div class="r-status"><span class="spin" aria-hidden="true"></span><span id="fgGenText">Payment settled — forging your model…</span></div>' +
      '<div class="mv-wrap"><div style="height:min(56vh,440px);display:flex;align-items:center;justify-content:center;color:var(--ibm-subtle);font-size:13px">Generating geometry…</div><div class="mv-progress" id="fgProg"></div></div>';
    announce('Payment settled. Forging your 3D model — about ' + etaSec + ' seconds.');
    clearInterval(genTimer);
    genTimer = setInterval(function () {
      var elapsed = Math.round((Date.now() - startTs) / 1000);
      var prog = Math.min(0.95, elapsed / (etaSec * 1.4));
      var bar = $('fgProg'); if (bar) bar.style.width = (prog * 100).toFixed(1) + '%';
      var t = $('fgGenText'); if (t) t.textContent = 'Payment settled — forging your model… ' + elapsed + 's';
    }, 1000);
  }
  function mvAvailable() {
    return !!(window.customElements && customElements.get('model-viewer'));
  }
  function setResultDone(glbUrl, payment, meta) {
    clearInterval(genTimer);
    var el = $('fgResult'); el.className = 'result is-done';
    var explorer = explorerUrl(payment.network, payment.transaction);
    var safeGlb = escapeHtml(glbUrl);

    var html = '';
    html += '<div class="r-status ok"><span class="r-check" aria-hidden="true">✓</span><span>Payment settled — model forged</span></div>';
    // The viewer is optional polish. If model-viewer never loaded (blocked script,
    // failed CDN-free fetch, unsupported engine) we don't render a dead <model-viewer>
    // that sits empty forever — we show the GLB as a downloadable file with a note.
    // ensureModelViewer() resolves whether or not the element upgrades, so by the time
    // its promise settles we can make an honest decision and re-render in place.
    ensureModelViewer().then(function () {
      // Element upgraded (or will upgrade in place) → leave the live viewer alone.
      if (mvAvailable()) return;
      // The module never defined the custom element. Swap the inert <model-viewer>
      // for an explicit download fallback so the user always gets their model.
      var mv = el.querySelector('.mv-wrap');
      if (mv) {
        mv.innerHTML =
          '<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:28px 18px;text-align:center;color:var(--ibm-subtle);font-size:13px;font-weight:300">' +
          '<span>The 3D viewer couldn’t load here — your model is ready as a downloadable file.</span>' +
          '<a class="r-btn" href="' + safeGlb + '" download target="_blank" rel="noopener">Download GLB</a>' +
          '</div>';
        announce('The 3D viewer could not load, but your model is ready to download.');
      }
    });
    html += '<div class="mv-wrap"><model-viewer src="' + safeGlb + '" alt="The 3D model you just forged" camera-controls auto-rotate rotation-per-second="18deg" interaction-prompt="none" shadow-intensity="0.7" shadow-softness="0.8" environment-image="neutral" exposure="1" camera-orbit="0deg 80deg auto" loading="eager"></model-viewer></div>';
    html += '<div class="r-actions">' +
      '<a class="r-btn" href="' + safeGlb + '" download target="_blank" rel="noopener">Download GLB</a>' +
      '<a class="r-btn ghost" href="https://three.ws/forge" target="_blank" rel="noopener">Rig &amp; refine in Forge ↗</a>' +
      '</div>';

    html += '<dl class="receipt">';
    html += '<div class="receipt-pair"><dt class="rk">Tier</dt><dd class="rv">' + escapeHtml((meta && meta.tier) || selectedTier) + '</dd></div>';
    html += '<div class="receipt-pair"><dt class="rk">Network</dt><dd class="rv">' + escapeHtml(networkLabel(payment.network)) + '</dd></div>';
    html += '<div class="receipt-pair"><dt class="rk">Payer</dt><dd class="rv">' + escapeHtml(shortAddr(payment.payer)) + '</dd></div>';
    html += '<div class="receipt-pair"><dt class="rk">Transaction</dt><dd class="rv">' +
      (payment.transaction
        ? (explorer ? '<a href="' + explorer + '" target="_blank" rel="noopener">' + escapeHtml(shortAddr(payment.transaction)) + ' <span aria-hidden="true">↗</span></a>' : escapeHtml(shortAddr(payment.transaction)))
        : '—') + '</dd></div>';
    html += '</dl>';

    html += '<details class="raw"><summary>View raw response &amp; settlement</summary><pre>' +
      escapeHtml(JSON.stringify({ glb_url: glbUrl, job: meta, payment: payment }, null, 2)).slice(0, 6000) + '</pre></details>';

    el.innerHTML = html;
    announce('Your 3D model is ready. Orbit it above or download the GLB.');
  }

  // ── poll the free status endpoint until the GLB is ready ─────────────────
  function pollForge(jobId, payment, etaSec) {
    var startTs = Date.now();
    var tries = 0;
    var maxTries = 150; // ~6.5 min at 2.6s
    setResultGenerating(payment, etaSec, startTs);
    (function tick() {
      fetch(POLL_ENDPOINT + '?job=' + encodeURIComponent(jobId), { method: 'GET' })
        .then(function (r) { return r.json().catch(function () { return null; }); })
        .then(function (d) {
          if (!d) throw new Error('empty');
          if (d.status === 'done' && d.glb_url) { setResultDone(d.glb_url, payment, d); return; }
          if (d.status === 'failed') { clearInterval(genTimer); setResultError(d.error || 'Generation failed. Your payment settled — try the full Forge tool.'); return; }
          tries++;
          if (tries >= maxTries) { clearInterval(genTimer); setResultStillWorking('Still working after several minutes — your payment settled.', jobId); return; }
          pollTimer = setTimeout(tick, 2600);
        })
        .catch(function () {
          tries++;
          if (tries >= maxTries) { clearInterval(genTimer); setResultStillWorking('Lost contact while generating — your payment settled.', jobId); return; }
          pollTimer = setTimeout(tick, 2600);
        });
    })();
  }

  // ── pay → generate ───────────────────────────────────────────────────────
  function runForge() {
    if (inFlight) return;
    if (!navigator.onLine) { setResultError('You appear to be offline. Reconnect and try again.'); return; }

    var prompt = sanitizePrompt($('fgPrompt').value);
    if (prompt.length < 3) { setPromptError('Describe an object — at least a few characters.'); $('fgPrompt').focus(); return; }
    setPromptError(null);
    $('fgPrompt').value = prompt;

    if (!window.X402 || typeof window.X402.pay !== 'function') {
      setResultError('Payment widget is still loading — give it a second and try again.');
      return;
    }

    var tier = selectedTier;
    var trigger = document.activeElement;
    setBusy(true, 'Waiting for wallet…');
    setResultLoading('Waiting for your wallet… approve the ' + priceLabel(tier) + ' USDC payment to start the generation.');

    window.X402.pay({
      endpoint: FORGE_ENDPOINT,
      method: 'POST',
      body: { prompt: prompt, tier: tier, aspect_ratio: '1:1' },
      merchant: 'three.ws',
      action: 'Forge: ' + prompt.slice(0, 48),
      networks: ['solana'],
      caps: { maxPerCall: (TIER_ATOMIC[tier] || 500000) }
    }).then(function (out) {
      if (!out || !out.ok) { setResultError('The payment did not complete. Please try again.'); return; }
      var job = out.result || {};
      var payment = out.payment || {};
      // The paid route may finish synchronously on some backends.
      if (job.status === 'done' && job.glb_url) { setResultDone(job.glb_url, payment, job); return; }
      var jobId = job.job_id;
      if (!jobId) { setResultError('Payment settled, but no job token came back. Try the full Forge tool.'); return; }
      var eta = Number(job.eta_seconds) || TIER_ETA[tier] || 60;
      pollForge(jobId, payment, eta);
    }).catch(function (err) {
      if (err && err.code === 'cancelled') { setResultEmpty(); return; }
      setResultError((err && err.message) || 'Payment failed. Please try again.');
    }).then(function () {
      setBusy(false);
      var t = (trigger && trigger.focus && document.body.contains(trigger)) ? trigger : $('fgBtn');
      try { t.focus(); } catch (_) { try { $('fgBtn').focus(); } catch (_2) {} }
    });
  }

  // ── tier selection (WAI-ARIA radiogroup) ─────────────────────────────────────
  // Selection drives a roving tabindex: only the checked radio is in the tab
  // order, so Tab lands on the group once and Arrow/Home/End move within it —
  // the operable behaviour the role="radiogroup"/role="radio" markup promises.
  function tierButtons() {
    return Array.prototype.slice.call(document.querySelectorAll('#fgTiers .tier'));
  }
  function selectTier(tier, focusIt) {
    if (!TIER_ATOMIC[tier]) return;
    var changed = tier !== selectedTier;
    selectedTier = tier;
    tierButtons().forEach(function (btn) {
      var on = btn.getAttribute('data-tier') === tier;
      btn.setAttribute('aria-checked', on ? 'true' : 'false');
      btn.tabIndex = on ? 0 : -1;
      if (on && focusIt) { try { btn.focus(); } catch (_) {} }
    });
    if (changed) { syncTierUi(); loadChallengePreview(); }
  }

  // ── wiring ──────────────────────────────────────────────────────────────────
  (function wireTierKeys() {
    var btns = tierButtons();
    btns.forEach(function (btn, i) {
      btn.addEventListener('click', function () { selectTier(btn.getAttribute('data-tier')); });
      btn.addEventListener('keydown', function (e) {
        var key = e.key, next = -1;
        if (key === 'ArrowRight' || key === 'ArrowDown') next = (i + 1) % btns.length;
        else if (key === 'ArrowLeft' || key === 'ArrowUp') next = (i - 1 + btns.length) % btns.length;
        else if (key === 'Home') next = 0;
        else if (key === 'End') next = btns.length - 1;
        else return;
        e.preventDefault();
        selectTier(btns[next].getAttribute('data-tier'), true);
      });
    });
  })();
  $('fgBtn').addEventListener('click', runForge);
  $('fgPrompt').addEventListener('keydown', function (e) { if (e.key === 'Enter') { e.preventDefault(); runForge(); } });
  var pvTimer;
  $('fgPrompt').addEventListener('input', function () {
    setPromptError(null);
    clearTimeout(pvTimer);
    pvTimer = setTimeout(loadChallengePreview, 600);
  });
  window.addEventListener('online', function () { setBusy(inFlight); loadChallengePreview(); });
  window.addEventListener('offline', function () { setBusy(inFlight); });

  syncTierUi();
  loadCatalog();
  loadChallengePreview();
})();
</script>

<!-- Free, no-wallet text→3D companion to the paid Forge. POSTs the free
     /api/forge NVIDIA NIM (Microsoft TRELLIS) lane, walks a fallback ladder, and
     polls GET /api/forge?job=<id>. No wallet, no key, no payment. -->
<script type="module">
(function () {
  'use strict';

  var API = 'https://three.ws/api/forge';
  var $ = function (id) { return document.getElementById(id); };
  var btn = $('g3dBtn');
  if (!btn) return; // panel not present — nothing to wire

  var input = $('g3dPrompt');
  var result = $('g3dResult');
  var statusEl = $('g3dStatus');
  var suggest = $('g3dSuggest');

  var inFlight = false;
  var runSeq = 0;
  var loadTimer = null;

  var CID = (function () {
    var fresh = function () { return 'c-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10); };
    try {
      var KEY = 'forge:cid';
      var v = localStorage.getItem(KEY);
      if (!v) { v = (window.crypto && crypto.randomUUID) ? crypto.randomUUID() : fresh(); localStorage.setItem(KEY, v); }
      return v;
    } catch (e) { return fresh(); }
  })();
  var HEADERS = { 'x-forge-client': CID };

  var _mv = null;
  function ensureModelViewer() {
    if (_mv) return _mv;
    _mv = new Promise(function (resolve) {
      if (window.customElements && customElements.get('model-viewer')) { resolve(); return; }
      var s = document.createElement('script');
      s.type = 'module';
      s.src = './vendor/model-viewer.min.js';
      s.addEventListener('error', resolve);
      document.head.appendChild(s);
      if (window.customElements) customElements.whenDefined('model-viewer').then(resolve, resolve);
      else resolve();
    });
    return _mv;
  }

  function esc(s) {
    return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
      return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
    });
  }
  function sleep(ms) { return new Promise(function (r) { setTimeout(r, ms); }); }

  // Attempt plan. /api/forge already runs its OWN internal fallback ladder
  // (NVIDIA NIM → TRELLIS → Hugging Face → Replicate) inside a single request and
  // always hands back a job that polls to a finished GLB — so the client must NOT
  // re-walk backends. The old 3-rung × 2-pass ladder fired up to six POSTs per
  // click, which (a) spent the free lane's hourly budget ~6× faster — a few clicks
  // self-inflicted a 429 — and (b) turned a slow NVCF cold-start into a multi-minute
  // cascade that surfaced as a hard error even though the backend was fine. We make
  // one primary request and, only on a HARD failure (network / 5xx / timeout — never
  // a rate-limit), retry once nudging the reliable reconstruct lane. A 429 is its own
  // "busy" state (see setBusy), not a wasted retry.
  var ATTEMPTS = [
    { tier: 'draft' },                     // server picks the fast NVIDIA lane (warm ≈ 15s; cold ≈ up to a minute, then it degrades internally)
    { tier: 'draft', backend: 'trellis' }  // hard-failure retry only: force the reliable reconstruct lane
  ];

  // POST a generation. A cold NVCF lane can hold the request ~a minute before the
  // server degrades, so the abort budget is generous; a genuinely hung/cut socket
  // still aborts and is retried rather than spinning forever. 429 and other non-2xx
  // become typed errors the caller can branch on (busy vs hard failure).
  async function startJob(body) {
    var ctrl = new AbortController();
    var to = setTimeout(function () { ctrl.abort(); }, 95000);
    var res;
    try {
      res = await fetch(API, {
        method: 'POST',
        headers: Object.assign({ 'content-type': 'application/json' }, HEADERS),
        body: JSON.stringify(body),
        signal: ctrl.signal
      });
    } finally { clearTimeout(to); }
    var data = await res.json().catch(function () { return {}; });
    if (res.status === 429) {
      var ra = Number(data.retry_after) || Number(res.headers.get('retry-after')) || 20;
      throw Object.assign(new Error(data.message || 'The free lane is busy.'), { code: 429, retryAfter: ra });
    }
    if (!res.ok) throw Object.assign(new Error(data.message || data.error || ('HTTP ' + res.status)), { code: res.status });
    return data;
  }

  async function pollJob(jobId, seq) {
    var deadline = Date.now() + 240000;
    while (seq === runSeq && Date.now() < deadline) {
      await sleep(2500);
      if (seq !== runSeq) return null;
      var data = {};
      try {
        var ctrl = new AbortController();
        var to = setTimeout(function () { ctrl.abort(); }, 20000);
        var res;
        try { res = await fetch(API + '?job=' + encodeURIComponent(jobId), { headers: HEADERS, signal: ctrl.signal }); }
        finally { clearTimeout(to); }
        data = await res.json().catch(function () { return {}; });
      } catch (_) { data = {}; } // a transient poll blip is not fatal — keep polling
      if (data.status === 'done' && data.glb_url) return data;
      if (data.status === 'failed') throw new Error(data.error || 'generation failed');
    }
    if (seq !== runSeq) return null;
    throw new Error('timed out');
  }

  async function generate(prompt, seq) {
    var lastErr = null;
    for (var i = 0; i < ATTEMPTS.length; i++) {
      if (seq !== runSeq) return null;
      try {
        var job = await startJob(Object.assign({ prompt: prompt, aspect_ratio: '1:1', path: 'image' }, ATTEMPTS[i]));
        if (job.status === 'done' && job.glb_url) return job; // synchronous (NVIDIA warm)
        if (job.job_id) {
          var done = await pollJob(job.job_id, seq);
          if (done) return done;
          if (seq !== runSeq) return null;
        }
        lastErr = new Error('no model returned');
      } catch (e) {
        if (e && e.code === 429) throw e; // rate-limited — surface "busy", don't burn another attempt
        lastErr = e;
        if (seq !== runSeq) return null;
        await sleep(1800); // brief backoff before the reliable-lane retry
      }
    }
    throw lastErr || new Error('generation unavailable');
  }

  function setLoading() {
    var msgs = [
      'Reading your prompt…',
      'Warming up the free GPU — a cold start can take up to a minute…',
      'Generating geometry on NVIDIA NIM…',
      'Texturing the mesh…',
      'Finalizing the GLB…'
    ];
    var i = 0;
    result.className = 'g3d-result is-loading';
    result.innerHTML =
      '<div class="g3d-load"><span class="g3d-bar"><span></span></span>' +
      '<span class="g3d-loadmsg" id="g3dLoadMsg">' + esc(msgs[0]) + '</span></div>';
    statusEl.textContent = 'Generating your 3D model.';
    clearInterval(loadTimer);
    loadTimer = setInterval(function () {
      i = (i + 1) % msgs.length;
      var el = $('g3dLoadMsg');
      if (el) el.textContent = msgs[i];
    }, 4000);
  }

  function setError() {
    clearInterval(loadTimer);
    result.className = 'g3d-result is-error';
    result.innerHTML =
      '<div class="g3d-err"><p>The free generator is briefly unreachable. It auto-retries across NVIDIA NIM and TRELLIS — give it another try.</p>' +
      '<button type="button" class="g3d-retry" id="g3dRetry">Try again</button></div>';
    var rb = $('g3dRetry');
    if (rb) rb.addEventListener('click', run);
    statusEl.textContent = 'Generation failed. Press try again.';
  }

  // Distinct from a hard failure: the free lane has an hourly cap so it stays free
  // for everyone. Tell the visitor exactly when to retry and point at the instant
  // paid lane above, instead of the misleading "unreachable" copy.
  function setBusy(retryAfter) {
    clearInterval(loadTimer);
    var secs = Math.max(5, Math.round(Number(retryAfter) || 20));
    result.className = 'g3d-result is-error';
    result.innerHTML =
      '<div class="g3d-err"><p>The free lane is busy — it has an hourly limit so it stays free for everyone. Try again in about ' + secs + ' seconds, or use the paid Forge above for an instant generation.</p>' +
      '<button type="button" class="g3d-retry" id="g3dRetry">Try again</button></div>';
    var rb = $('g3dRetry');
    if (rb) rb.addEventListener('click', run);
    statusEl.textContent = 'The free lane is busy. Try again in about ' + secs + ' seconds.';
  }

  function engineLabel(backend) {
    if (backend === 'nvidia') return 'Microsoft TRELLIS · NVIDIA NIM';
    if (backend === 'trellis') return 'Microsoft TRELLIS';
    if (backend === 'huggingface') return 'TRELLIS · Hugging Face';
    return 'three.ws Forge';
  }

  async function renderModel(job, prompt) {
    clearInterval(loadTimer);
    await ensureModelViewer();
    var glb = job.glb_url;
    var scene = 'https://three.ws/scene?model=' + encodeURIComponent(glb) +
      '&name=' + encodeURIComponent(prompt.slice(0, 80));
    result.className = 'g3d-result is-done';
    result.innerHTML =
      '<div class="mv-wrap"><model-viewer src="' + esc(glb) + '" alt="3D model generated from your prompt" ' +
      'camera-controls auto-rotate rotation-per-second="18deg" interaction-prompt="none" ' +
      'shadow-intensity="0.7" shadow-softness="0.8" environment-image="neutral" exposure="1" ' +
      'camera-orbit="0deg 80deg auto" loading="eager"></model-viewer></div>' +
      '<div class="g3d-actions">' +
      '<a class="g3d-act primary" href="' + esc(glb) + '" download>Download GLB</a>' +
      '<a class="g3d-act" href="' + esc(scene) + '" target="_blank" rel="noopener">Open in 3D scene ↗</a>' +
      '<span class="g3d-engine">Generated free · ' + esc(engineLabel(job.backend)) + '</span>' +
      '</div>';
    statusEl.textContent = 'Your 3D model is ready. Orbit it, or download the GLB.';
  }

  async function run() {
    var prompt = (input.value || '').trim();
    if (!prompt) { try { input.focus(); } catch (_) {} return; }
    var seq = ++runSeq;
    inFlight = true;
    btn.classList.add('loading');
    btn.disabled = true;
    setLoading();
    try {
      var job = await generate(prompt, seq);
      if (seq !== runSeq) return;
      if (!job || !job.glb_url) throw new Error('no model');
      await renderModel(job, prompt);
    } catch (e) {
      if (seq !== runSeq) return;
      if (e && e.code === 429) setBusy(e.retryAfter);
      else setError();
    } finally {
      if (seq === runSeq) {
        inFlight = false;
        btn.classList.remove('loading');
        btn.disabled = false;
      }
    }
  }

  btn.addEventListener('click', function () { if (!inFlight) run(); });
  input.addEventListener('keydown', function (e) {
    if (e.key === 'Enter') { e.preventDefault(); if (!inFlight) run(); }
  });
  if (suggest) {
    suggest.addEventListener('click', function (e) {
      var b = e.target.closest('button[data-p]');
      if (!b) return;
      input.value = b.getAttribute('data-p');
      if (!inFlight) run();
    });
  }
})();
</script>
	<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
	<script type="module" src="/i18n.js"></script>
</body>
</html>