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.

36.2 KB
Raw Blame
<!doctype html>
<html lang="en">
	<head>
		<script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
		<script src="/referral-capture.js"></script>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1" />
		<title data-i18n="register.meta_title">Create account · three.ws</title>
		<link rel="icon" href="/favicon.ico" />
		<link rel="stylesheet" href="/wallet-connect.css" />
		<link rel="stylesheet" href="/auth.css" />
		<link rel="stylesheet" href="/mobile.css" />
		<script
			type="module"
			src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"
		></script>
		<style>
			:root {
				color-scheme: dark;
				--accent: #ffffff;
				--accent2: #cccccc;
			}
			* {
				box-sizing: border-box;
			}
			body {
				font:
					15px/1.5 -apple-system,
					system-ui,
					Segoe UI,
					Roboto,
					sans-serif;
				background: #000;
				color: #eee;
				margin: 0;
				min-height: 100vh;
				display: flex;
				align-items: center;
				justify-content: center;
				padding: 24px;
			}
			.shell {
				display: flex;
				width: 100%;
				max-width: 1080px;
				min-height: 640px;
				border-radius: 24px;
				overflow: hidden;
				background: #0a0a0a;
				border: 1px solid #222;
				box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8);
			}
			.panel {
				flex: 1;
				position: relative;
				display: flex;
				align-items: center;
				justify-content: center;
				background:
					radial-gradient(120% 90% at 30% 20%, rgba(255, 255, 255, 0.06), transparent 60%),
					radial-gradient(120% 90% at 80% 90%, rgba(255, 255, 255, 0.04), transparent 55%),
					linear-gradient(135deg, #111 0%, #000 100%);
				overflow: hidden;
			}
			.agent-avatar {
				position: relative;
				width: 320px;
				height: 320px;
				pointer-events: none;
			}
			@media (max-width: 860px) {
				.shell {
					flex-direction: column;
					min-height: 0;
				}
				.panel {
					min-height: 220px;
					order: -1;
				}
				.agent-avatar {
					width: 180px;
					height: 180px;
				}
			}
			.agent-avatar model-viewer {
				width: 100%;
				height: 100%;
				--poster-color: transparent;
				background: transparent;
			}
			.agent-avatar::after {
				content: '';
				position: absolute;
				left: 50%;
				bottom: -2px;
				width: 90px;
				height: 10px;
				background: radial-gradient(ellipse, rgba(255, 255, 255, 0.2), transparent 70%);
				transform: translateX(-50%);
				filter: blur(4px);
			}
			a {
				color: #fff;
			}
			.card {
				background: #0a0a0a;
				border: 0;
				border-radius: 0;
				padding: 56px 56px;
				flex: 1;
				width: 100%;
				max-width: 520px;
				box-shadow: none;
				display: flex;
				flex-direction: column;
				justify-content: center;
				overflow-y: auto;
			}
			@media (max-width: 860px) {
				.card {
					padding: 32px 28px;
					max-width: none;
				}
			}
			h1 {
				font-size: 22px;
				margin: 0 0 4px;
				letter-spacing: -0.01em;
			}
			.sub {
				color: #888;
				margin: 0 0 24px;
				font-size: 14px;
				display: flex;
				align-items: center;
				gap: 8px;
				flex-wrap: wrap;
			}
			.badge {
				display: inline-flex;
				align-items: center;
				gap: 4px;
				font-size: 11px;
				font-weight: 600;
				padding: 2px 8px;
				border-radius: 20px;
				background: rgba(255, 255, 255, 0.08);
				border: 1px solid rgba(255, 255, 255, 0.2);
				color: #ccc;
				letter-spacing: 0.02em;
				white-space: nowrap;
			}
			label {
				display: block;
				font-size: 13px;
				color: #aaa;
				margin: 14px 0 6px;
			}
			input {
				width: 100%;
				padding: 11px 13px;
				background: #000;
				border: 1px solid #333;
				border-radius: 9px;
				color: #eee;
				font-size: 15px;
				transition: border-color 0.15s, box-shadow 0.15s;
			}
			input:focus {
				outline: none;
				border-color: #fff;
				box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
			}
			.hint {
				font-size: 12px;
				color: #666;
				margin-top: 4px;
				transition: color 0.15s;
			}
			.hint.invalid { color: #ff7a7a; }
			.hint.valid { color: #7ddf7d; }
			.strength-bar {
				height: 3px;
				border-radius: 2px;
				background: #222;
				margin-top: 6px;
				overflow: hidden;
			}
			.strength-fill {
				height: 100%;
				width: 0%;
				border-radius: 2px;
				transition: width 0.2s, background 0.2s;
			}
			.strength-label {
				font-size: 11px;
				margin-top: 3px;
				color: #555;
				transition: color 0.2s;
			}
			button[type="submit"] {
				width: 100%;
				margin-top: 20px;
				padding: 12px 16px;
				border: 0;
				border-radius: 10px;
				background: #fff;
				color: #000;
				font-weight: 600;
				font-size: 15px;
				cursor: pointer;
				transition: filter 0.15s, transform 0.1s;
			}
			button[type="submit"]:hover:not(:disabled) {
				filter: brightness(1.12);
				transform: translateY(-1px);
			}
			button[type="submit"]:active:not(:disabled) {
				transform: translateY(0);
				filter: brightness(0.95);
			}
			button[type="submit"]:disabled {
				opacity: 0.6;
				cursor: default;
			}
			.err {
				margin-top: 14px;
				padding: 10px 12px;
				background: rgba(255, 92, 92, 0.1);
				border: 1px solid rgba(255, 92, 92, 0.3);
				border-radius: 8px;
				color: #ffb3b3;
				font-size: 13px;
				display: none;
			}
			.foot {
				margin-top: 20px;
				text-align: center;
				font-size: 13px;
				color: #888;
			}
			.legal {
				margin-top: 10px;
				text-align: center;
				font-size: 11px;
				color: #555;
			}
			.legal a { color: #888; }
			.tos-row {
				display: flex;
				align-items: flex-start;
				gap: 8px;
				margin: 14px 0 12px;
				font-size: 12.5px;
				line-height: 1.5;
				color: #999;
				cursor: pointer;
			}
			.tos-row input[type='checkbox'] {
				width: 15px;
				height: 15px;
				margin: 2px 0 0;
				flex: none;
				accent-color: #7c8cff;
				cursor: pointer;
			}
			.tos-row a { color: #ccc; }
			.tos-row a:hover { color: #fff; }
			.tos-row input[type='checkbox']:focus-visible {
				outline: 2px solid #7c8cff;
				outline-offset: 2px;
			}
			.brand {
				font-size: 12px;
				letter-spacing: 0.1em;
				text-transform: uppercase;
				color: #fff;
				margin: 0 0 8px;
				text-decoration: none;
				display: inline-block;
			}
			.brand:hover {
				color: #ccc;
			}
			.divider {
				display: flex;
				align-items: center;
				gap: 12px;
				margin: 22px 0 4px;
				color: #444;
				font-size: 12px;
				text-transform: uppercase;
				letter-spacing: 0.08em;
			}
			.divider::before,
			.divider::after {
				content: '';
				flex: 1;
				height: 1px;
				background: #222;
			}
			.field-err {
				margin: 6px 0 0;
				font-size: 12px;
				color: #ff7a7a;
				display: none;
			}
			.field-err.show { display: block; }
			.chain-tab[disabled] { opacity: 0.4; cursor: not-allowed; }
			/* ── On-chain features toggle ── */
			.onchain-toggle-row {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin: 20px 0 0;
			}
			.onchain-toggle-label {
				font-size: 12px;
				color: #444;
				letter-spacing: 0.02em;
				user-select: none;
			}
			.onchain-toggle-btn {
				width: auto;
				margin: 0;
				padding: 4px 12px;
				background: transparent;
				border: 1px solid rgba(255, 255, 255, 0.1);
				border-radius: 6px;
				color: #555;
				font-size: 12px;
				font-weight: 500;
				cursor: pointer;
				transition: color 0.15s, border-color 0.15s, background 0.15s;
				letter-spacing: 0.01em;
			}
			.onchain-toggle-btn:hover:not(:disabled) {
				color: #bbb;
				border-color: rgba(255, 255, 255, 0.2);
				background: rgba(255, 255, 255, 0.03);
			}
			.onchain-toggle-btn.active {
				color: #e0e0e0;
				border-color: rgba(255, 255, 255, 0.25);
				background: rgba(255, 255, 255, 0.06);
			}
			.onchain-section {
				overflow: hidden;
				max-height: 0;
				opacity: 0;
				transition: max-height 0.3s ease, opacity 0.22s ease, margin-top 0.22s ease;
				margin-top: 0;
			}
			.onchain-section.open {
				max-height: 300px;
				opacity: 1;
				margin-top: 14px;
			}
			#wallet-mount:empty::before,
			#solana-wallet-mount:empty::before {
				content: '';
				display: block;
				height: 44px;
				border-radius: 10px;
				background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 100%);
				background-size: 200% 100%;
				animation: wallet-skel 1.4s linear infinite;
			}
			@keyframes wallet-skel {
				0%   { background-position: 200% 0; }
				100% { background-position: -200% 0; }
			}
			@media (prefers-reduced-motion: reduce) {
				#wallet-mount:empty::before,
				#solana-wallet-mount:empty::before { animation: none; }
			}
			.chain-tabs {
				display: flex;
				gap: 4px;
				background: #000;
				border: 1px solid #222;
				border-radius: 10px;
				padding: 3px;
				margin-bottom: 12px;
			}
			.chain-tab {
				flex: 1;
				padding: 7px 10px;
				border: none;
				border-radius: 7px;
				background: transparent;
				color: #666;
				font-size: 13px;
				font-weight: 500;
				cursor: pointer;
				transition: background 0.15s, color 0.15s;
				margin-top: 0;
				width: auto;
			}
			.chain-tab.active {
				background: #1a1a1a;
				color: #eee;
				border: 1px solid #333;
			}
			.chain-tab:hover:not(.active) {
				color: #bbb;
			}
			.chain-panel { display: none; }
			.chain-panel.active { display: block; }
			.wallet-hint-btn {
				width: auto;
				margin-top: 0;
				padding: 4px 10px;
				background: transparent;
				border: 1px solid #222;
				border-radius: 6px;
				color: #555;
				font-size: 11px;
				font-weight: 400;
				cursor: pointer;
			}
			.wallet-hint-btn:hover { border-color: #fff; color: #eee; }
			.wallet-hint-btn.active { border-color: #fff; color: #eee; background: rgba(255,255,255,0.06); }
			/* ── Privy section ── */
			#privy-section { margin: 0 0 2px; }
			#privy-toggle-btn {
				width: 100%; margin-top: 0; padding: 11px 16px;
				background: #0e0e0e; border: 1px solid rgba(255,255,255,0.1);
				border-radius: 10px; color: #d0d0d0; font-size: 14px; font-weight: 500;
				cursor: pointer; display: flex; align-items: center; justify-content: center;
				gap: 9px; transition: background 0.12s, border-color 0.12s, color 0.12s;
				letter-spacing: -0.01em;
			}
			#privy-toggle-btn:hover { background: #161616; border-color: rgba(255,255,255,0.18); color: #fff; }
			#privy-toggle-btn svg { flex-shrink: 0; }
			.privy-toggle-chev { opacity: 0.55; transition: transform 0.18s ease; }
			#privy-toggle-btn[aria-expanded='true'] .privy-toggle-chev { transform: rotate(180deg); }
			@media (prefers-reduced-motion: reduce) {
				.privy-toggle-chev { transition: none; }
			}
			#privy-expanded { margin-top: 8px; }
			.privy-row { display: flex; gap: 8px; align-items: flex-start; }
			.privy-row input { flex: 1; margin: 0; }
			.privy-row-btn {
				width: auto; margin: 0; padding: 11px 16px;
				background: #fff; color: #000; border-radius: 10px;
				font-size: 14px; font-weight: 600; border: none; cursor: pointer;
				white-space: nowrap; flex-shrink: 0;
				transition: background 0.12s, opacity 0.12s;
			}
			.privy-row-btn:hover:not(:disabled) { background: #e6e6e6; }
			.privy-row-btn:disabled { opacity: 0.4; cursor: default; }
			#privy-inline-err { margin: 6px 0 0; font-size: 12px; color: #ff7a7a; }
			#privy-captcha-slot:not(:empty) { margin-top: 10px; display: flex; justify-content: center; }
			.privy-back-link {
				display: inline-block; margin-top: 8px; font-size: 12px;
				color: #555; cursor: pointer; background: none; border: none;
				padding: 0; text-decoration: underline; text-underline-offset: 2px; width: auto;
			}
			.privy-back-link:hover { color: #888; }
			.privy-wallet-divider { margin: 10px 0 8px; text-align: center; font-size: 11px; color: #8a8a8a; letter-spacing: 0.04em; }
			.privy-chain-btns { display: flex; gap: 8px; }
			.privy-chain-btn {
				flex: 1; margin: 0; padding: 10px 12px;
				background: transparent; border: 1px solid rgba(255,255,255,0.12);
				border-radius: 10px; color: #ccc; font-size: 13px; font-weight: 500;
				cursor: pointer; display: flex; align-items: center; justify-content: center;
				gap: 7px; transition: background 0.12s, border-color 0.12s, color 0.12s;
				white-space: nowrap;
			}
			.privy-chain-btn:hover:not(:disabled) { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.22); color: #fff; }
			.privy-chain-btn:disabled { opacity: 0.4; cursor: default; }
			#privy-wallet-status { margin: 6px 0 0; font-size: 12px; color: #888; }
		</style>
	
	<meta name="description" content="Create a new three.ws account." data-i18n-attr="content:register.meta_description">
	<link rel="canonical" href="https://three.ws/register">
	<meta property="og:type" content="website">
	<meta property="og:site_name" content="three.ws">
	<meta property="og:title" content="Create account · three.ws" data-i18n-attr="content:register.meta_og_title">
	<meta property="og:description" content="Create a new three.ws account." data-i18n-attr="content:register.meta_og_description">
	<meta property="og:url" content="https://three.ws/register">
	<meta property="og:image" content="https://three.ws/api/page-og?s=account&amp;t=Create+account&amp;d=Create+a+new+three.ws+account.&amp;p=%2Fregister">
	<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="Create account · three.ws" data-i18n-attr="content:register.meta_twitter_title">
	<meta name="twitter:description" content="Create a new three.ws account." data-i18n-attr="content:register.meta_twitter_description">
	<meta name="twitter:image" content="https://three.ws/api/page-og?s=account&amp;t=Create+account&amp;d=Create+a+new+three.ws+account.&amp;p=%2Fregister">
	<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Create account","description":"Create a new three.ws account.","url":"https://three.ws/register","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>

	<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="Create account — three.ws">
	<meta name="twitter:site" content="@trythreews">
	<script src="/model-viewer-meshopt.js"></script>
</head>
	<body>
		<div class="shell">
			<form class="card" id="f" autocomplete="on">
			<a href="/" class="brand"><img src="/three.svg" alt="" class="header-logo" aria-hidden="true" />three.ws</a>
			<h1 data-i18n="register.create_account">Create account</h1>
			<p class="sub" data-i18n-html="register.get_started_free_no_wallet_needed">Get started free. <span class="badge">✓ No wallet needed</span></p>

			<!-- Privy social / email-OTP login -->
			<div id="privy-section">
				<button type="button" id="privy-toggle-btn" aria-expanded="false" aria-controls="privy-expanded">
					<svg width="18" height="18" viewBox="0 0 36 36" fill="none" aria-hidden="true"><rect width="36" height="36" rx="8" fill="#2563EB"/><path d="M18 8C12.477 8 8 12.477 8 18s4.477 10 10 10 10-4.477 10-10S23.523 8 18 8zm0 3a7 7 0 110 14A7 7 0 0118 11zm0 2a5 5 0 100 10A5 5 0 0018 13zm0 2a3 3 0 110 6 3 3 0 010-6z" fill="#fff" opacity=".9"/></svg>
					<span data-i18n="register.continue_with_privy">Continue with Privy</span>
					<svg class="privy-toggle-chev" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg>
				</button>
				<div id="privy-expanded" hidden>
					<div id="privy-step-email">
						<div class="privy-row">
							<input id="privy-email-input" type="email" inputmode="email" placeholder="Email address" aria-label="Email address" data-i18n-attr="placeholder:register.email_address_placeholder;aria-label:register.email_address_arialabel" autocomplete="email" autocapitalize="none" />
							<button type="button" id="privy-send-btn" class="privy-row-btn" data-i18n="register.send_code">Send code</button>
						</div>
						<div id="privy-captcha-slot" aria-live="polite"></div>
					</div>
					<div id="privy-step-code" hidden>
						<div class="privy-row">
							<input id="privy-code-input" type="text" inputmode="numeric" placeholder="6-digit code" aria-label="6-digit code" data-i18n-attr="placeholder:register.6_digit_code_placeholder;aria-label:register.6_digit_code_arialabel" maxlength="6" autocomplete="one-time-code" />
							<button type="button" id="privy-verify-btn" class="privy-row-btn" data-i18n="register.verify">Verify</button>
						</div>
					</div>
					<div id="privy-wallet-wrap">
						<p class="privy-wallet-divider" data-i18n="register.or_connect_wallet">or connect wallet</p>
						<div class="privy-chain-btns">
							<button type="button" id="privy-evm-btn" class="privy-chain-btn">
								<svg width="14" height="14" viewBox="0 0 32 32" fill="none" aria-hidden="true"><path d="M16 2L4 16.5 16 22l12-5.5L16 2z" fill="currentColor" opacity=".55"/><path d="M16 2v12.5L4 16.5 16 2z" fill="currentColor" opacity=".9"/><path d="M16 22v8l12-11L16 22z" fill="currentColor" opacity=".55"/><path d="M16 22L4 19l12 11V22z" fill="currentColor" opacity=".9"/><path d="M16 14.5v5.5L4 16.5l12-2z" fill="currentColor" opacity=".35"/><path d="M28 16.5l-12 3.5v-5.5l12 2z" fill="currentColor" opacity=".9"/></svg>
								EVM
							</button>
							<button type="button" id="privy-solana-btn" class="privy-chain-btn">
								<svg width="14" height="14" viewBox="0 0 32 32" fill="none" aria-hidden="true"><path d="M6 22.5h20.3a.6.6 0 0 0 .4-.7l-2-3.5a.6.6 0 0 0-.5-.3H3.9a.6.6 0 0 0-.4.7l2 3.5c.1.2.3.3.5.3z" fill="currentColor" opacity=".55"/><path d="M6 13.5h20.3a.6.6 0 0 0 .4-.7l-2-3.5a.6.6 0 0 0-.5-.3H3.9a.6.6 0 0 0-.4.7l2 3.5c.1.2.3.3.5.3z" fill="currentColor" opacity=".55"/><path d="M26.3 18H6a.6.6 0 0 0-.5.3l-2 3.5a.6.6 0 0 0 .4.7h20.3c.2 0 .4-.1.5-.3l2-3.5a.6.6 0 0 0-.4-.7z" fill="currentColor" opacity=".9"/></svg>
								Solana
							</button>
						</div>
						<p id="privy-wallet-status" hidden></p>
					</div>
					<p id="privy-inline-err" hidden></p>
					<button type="button" id="privy-back-btn" class="privy-back-link" data-i18n="register.back">← Back</button>
				</div>
			</div>
			<div class="divider" id="privy-or-divider">or</div>

			<label for="username" data-i18n="register.username">Username</label>
			<input
				id="username"
				name="username"
				type="text"
				inputmode="text"
				autocapitalize="none"
				autocomplete="username"
				autofocus
				required
				minlength="3"
				maxlength="30"
				pattern="[a-zA-Z0-9_\-]+"
				placeholder="e.g. cool_agent"
				aria-describedby="username-hint err"
			/>
			<p class="hint" id="username-hint" data-i18n="register.3_30_characters_letters_numbers_or">3–30 characters, letters, numbers, _ or -</p>
			<label for="password" data-i18n="register.password">Password</label>
			<div class="password-wrap">
				<input
					id="password"
					name="password"
					type="password"
					autocomplete="new-password"
					required
					minlength="10"
					maxlength="200"
					aria-describedby="strength-label caps-warn err"
				/>
				<button type="button" class="password-toggle" id="password-toggle" aria-label="Show password" aria-pressed="false" data-i18n-attr="aria-label:register.show_password_arialabel">
					<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
						<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z" />
						<circle cx="12" cy="12" r="3" />
					</svg>
				</button>
			</div>
			<p class="caps-warn" id="caps-warn" data-i18n="register.caps_lock_is_on">Caps Lock is on</p>
			<div class="strength-bar"><div class="strength-fill" id="strength-fill"></div></div>
			<p class="strength-label" id="strength-label" data-i18n="register.minimum_10_characters">Minimum 10 characters</p>
			<label class="tos-row" for="tos-accept">
				<input id="tos-accept" name="tos-accept" type="checkbox" required aria-describedby="err" />
				<span data-i18n-html="register.i_have_read_and_agree_to_the">I have read and agree to the <a href="/legal/tos" target="_blank" rel="noopener">Terms of Service</a> and <a href="/legal/privacy" target="_blank" rel="noopener">Privacy Policy</a>.</span>
			</label>
			<button id="submit" type="submit" data-i18n="register.create_account_2">Create account</button>

			<div class="err" id="err" role="alert" aria-live="polite"></div>

			<div class="onchain-toggle-row">
				<span class="onchain-toggle-label" data-i18n="register.using_on_chain_features">Using on-chain features?</span>
				<button type="button" class="onchain-toggle-btn" id="onchain-toggle" aria-expanded="false" aria-controls="onchain-section" data-i18n="register.connect_wallet">
					Connect wallet
				</button>
			</div>

			<div class="onchain-section" id="onchain-section" aria-hidden="true">
				<div class="chain-tabs" role="tablist" aria-label="Wallet chain">
					<button type="button" class="chain-tab active" data-chain="solana" role="tab" aria-selected="true" aria-controls="solana-panel" data-i18n="register.solana">Solana</button>
					<button type="button" class="chain-tab" data-chain="evm" role="tab" aria-selected="false" aria-controls="evm-panel" data-i18n="register.evm">EVM</button>
				</div>
				<div id="solana-panel" class="chain-panel active" role="tabpanel">
					<div id="solana-wallet-mount"></div>
				</div>
				<div id="evm-panel" class="chain-panel" role="tabpanel">
					<div id="wallet-mount"></div>
				</div>
				<p class="hint" style="margin-top:10px;text-align:center;font-size:11px;color:#555;cursor:help" title="Your wallet will prompt twice — once to connect, once to sign." data-i18n="register.wallet_prompts_to_connect_then_to_sign" data-i18n-attr="title:register.your_wallet_will_prompt_twic_title">Wallet prompts to connect, then to sign.</p>
			</div>

			<p class="foot" data-i18n-html="register.already_have_an_account_sign_in">Already have an account? <a href="/login">Sign in</a></p>
			<p class="legal" data-i18n-html="register.by_creating_an_account_including_with_privy">By creating an account (including with Privy or a connected wallet) you agree to the <a href="/legal/tos" target="_blank" rel="noopener">Terms of Service</a> and <a href="/legal/privacy" target="_blank" rel="noopener">Privacy Policy</a>.</p>
		</form>
			<div class="panel">
				<a href="/" class="panel-brand" aria-label="three.ws home" data-i18n-attr="aria-label:register.three_ws_home_arialabel"><img src="/three.svg" alt="" class="header-logo" aria-hidden="true" />three.ws</a>
				<div class="agent-avatar loading" id="register-avatar-wrap" aria-hidden="true">
					<model-viewer
						id="register-avatar"
						src="/avatars/cz.glb"
						alt=""
						autoplay
						animation-name="IdleV4.2(maya_head)"
						disable-zoom
						interaction-prompt="none"
						shadow-intensity="0.6"
						shadow-softness="1"
						exposure="1.05"
						tone-mapping="aces"
						environment-image="neutral"
						camera-orbit="0deg 88deg 4.8m"
						field-of-view="32deg"
						loading="eager"
					></model-viewer>
				</div>
			</div>
		</div>

		<script type="module" src="/wallet-login.js"></script>
		<script type="module" src="/src/privy-login.js"></script>

		<script>
			// Avatar mouse tracking + parallax + skeleton
			(function () {
				const viewer = document.getElementById('register-avatar');
				const wrap = document.getElementById('register-avatar-wrap');
				if (!viewer) return;
				viewer.addEventListener('load', () => wrap?.classList.remove('loading'));
				const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
				const BASE_AZ = 0, BASE_POL = 88, AZ_RANGE = 30, POL_RANGE = 14;
				let targetAz = BASE_AZ, targetPol = BASE_POL;
				let curAz = BASE_AZ, curPol = BASE_POL;
				let targetTx = 0, targetTy = 0, curTx = 0, curTy = 0;
				let nod = 0;
				const lerp = (a, b, t) => a + (b - a) * t;
				function tick() {
					curAz = lerp(curAz, targetAz, 0.1);
					curPol = lerp(curPol, targetPol + nod, 0.18);
					curTx = lerp(curTx, targetTx, 0.08);
					curTy = lerp(curTy, targetTy, 0.08);
					nod *= 0.85;
					viewer.setAttribute('camera-orbit', `${curAz}deg ${curPol}deg 4.8m`);
					if (wrap) wrap.style.transform = `translate(${curTx.toFixed(2)}px, ${curTy.toFixed(2)}px)`;
					requestAnimationFrame(tick);
				}
				if (reducedMotion) return;
				requestAnimationFrame(tick);
				window.addEventListener('mousemove', (e) => {
					const nx = e.clientX / window.innerWidth - 0.5;
					const ny = e.clientY / window.innerHeight - 0.5;
					targetAz = BASE_AZ - nx * AZ_RANGE * 2;
					targetPol = BASE_POL + ny * POL_RANGE * 2;
					targetTx = -nx * 10;
					targetTy = -ny * 8;
				}, { passive: true });
				document.querySelectorAll('#f input').forEach((el) => {
					el.addEventListener('keydown', (e) => {
						if (typeof e.key === 'string' && (e.key.length === 1 || e.key === 'Backspace')) {
							nod = (nod >= 0 ? -1 : 1) * 4;
						}
					});
				});
			})();

			// Privy disclosure.
			// The passwordless / wallet block ships collapsed so the username +
			// password form stays the visual default, but nothing ever opened it:
			// #privy-expanded kept its `hidden` attribute for the life of the page,
			// so email-OTP, EVM and Solana signup were all unreachable here.
			(function () {
				const btn = document.getElementById('privy-toggle-btn');
				const panel = document.getElementById('privy-expanded');
				const inlineErr = document.getElementById('privy-inline-err');
				if (!btn || !panel) return;

				function setOpen(open, moveFocus) {
					panel.hidden = !open;
					btn.setAttribute('aria-expanded', open ? 'true' : 'false');
					if (!moveFocus) return;
					if (open) document.getElementById('privy-email-input')?.focus();
					else btn.focus();
				}

				btn.addEventListener('click', () => setOpen(panel.hidden, true));

				// "Back" steps out of code entry first: privy-login.js resets the form
				// to the email step on this same click, and this handler runs before it
				// (inline script beats the deferred module), so read the step that is
				// still on screen. From the email step there is nowhere further back to
				// go, so the disclosure closes.
				document.getElementById('privy-back-btn')?.addEventListener('click', () => {
					const codeStep = document.getElementById('privy-step-code');
					if (!codeStep || codeStep.hidden) setOpen(false, true);
				});

				// privy-login.js reports a failed /api/config probe by unhiding this
				// line, which lives inside the collapsed panel. Open the panel so the
				// explanation is readable, without stealing focus from the form.
				if (inlineErr) {
					new MutationObserver(() => {
						if (!inlineErr.hidden && panel.hidden) setOpen(true, false);
					}).observe(inlineErr, { attributes: true, attributeFilter: ['hidden'] });
				}
			})();

			// Password show/hide toggle
			(function () {
				const pw = document.getElementById('password');
				const tog = document.getElementById('password-toggle');
				if (!pw || !tog) return;
				tog.addEventListener('click', () => {
					const show = pw.type === 'password';
					pw.type = show ? 'text' : 'password';
					tog.setAttribute('aria-pressed', show ? 'true' : 'false');
					tog.setAttribute('aria-label', show ? 'Hide password' : 'Show password');
				});
			})();

			// Caps Lock warning on password
			(function () {
				const pw = document.getElementById('password');
				const warn = document.getElementById('caps-warn');
				if (!pw || !warn) return;
				function check(e) {
					const on = e.getModifierState && e.getModifierState('CapsLock');
					warn.classList.toggle('show', !!on);
				}
				pw.addEventListener('keydown', check);
				pw.addEventListener('keyup', check);
				pw.addEventListener('blur', () => warn.classList.remove('show'));
			})();

			// Inline username validation
			(function () {
				const u = document.getElementById('username');
				const hint = document.getElementById('username-hint');
				if (!u || !hint) return;
				const re = /^[a-zA-Z0-9_-]{3,30}$/;
				u.addEventListener('input', () => {
					const v = u.value;
					if (!v) { hint.classList.remove('valid', 'invalid'); hint.textContent = '3–30 characters, letters, numbers, _ or -'; return; }
					if (re.test(v)) {
						hint.classList.add('valid'); hint.classList.remove('invalid');
						hint.textContent = '✓ Looks good';
					} else {
						hint.classList.add('invalid'); hint.classList.remove('valid');
						if (v.length < 3) hint.textContent = 'Too short — 3 characters minimum.';
						else if (v.length > 30) hint.textContent = 'Too long — 30 characters maximum.';
						else hint.textContent = 'Only letters, numbers, _ and - allowed.';
					}
				});
			})();

			// Password strength indicator
			(function () {
				const pw = document.getElementById('password');
				const fill = document.getElementById('strength-fill');
				const label = document.getElementById('strength-label');
				const levels = [
					{ color: '#555', text: 'Too short' },
					{ color: '#777', text: 'Weak' },
					{ color: '#999', text: 'Fair' },
					{ color: '#ccc', text: 'Strong' },
					{ color: '#fff', text: 'Very strong' },
				];
				function score(v) {
					if (v.length < 10) return 0;
					let s = 1;
					if (v.length >= 14) s++;
					if (/[A-Z]/.test(v) && /[a-z]/.test(v)) s++;
					if (/[0-9]/.test(v)) s++;
					if (/[^A-Za-z0-9]/.test(v)) s++;
					return Math.min(s, 4);
				}
				pw.addEventListener('input', () => {
					const v = pw.value;
					if (!v) { fill.style.width = '0%'; label.textContent = 'Minimum 10 characters'; label.style.color = '#555'; return; }
					const s = score(v);
					const pct = [15, 35, 55, 75, 100][s];
					const lvl = levels[s];
					fill.style.width = pct + '%';
					fill.style.background = lvl.color;
					label.textContent = lvl.text;
					label.style.color = lvl.color;
				});
			})();

			// On-chain features toggle
			(function () {
				const btn = document.getElementById('onchain-toggle');
				const section = document.getElementById('onchain-section');
				if (!btn || !section) return;
				let open = false;
				function setOpen(val) {
					open = val;
					section.classList.toggle('open', open);
					section.setAttribute('aria-hidden', open ? 'false' : 'true');
					btn.setAttribute('aria-expanded', open ? 'true' : 'false');
					btn.classList.toggle('active', open);
					btn.textContent = open ? 'Hide wallet' : 'Connect wallet';
					try { sessionStorage.setItem('register:onchain', open ? '1' : '0'); } catch { /* ignore */ }
				}
				btn.addEventListener('click', () => setOpen(!open));
				try {
					if (sessionStorage.getItem('register:onchain') === '1') setOpen(true);
				} catch { /* ignore */ }
			})();

			// Wallet chain tabs + Solana detection
			(function () {
				const solanaTab = document.querySelector('.chain-tab[data-chain="solana"]');
				function activateChain(chain) {
					document.querySelectorAll('.chain-tab').forEach((x) => {
						const on = x.dataset.chain === chain;
						x.classList.toggle('active', on);
						x.setAttribute('aria-selected', on ? 'true' : 'false');
					});
					document.getElementById('evm-panel').classList.toggle('active', chain === 'evm');
					document.getElementById('solana-panel').classList.toggle('active', chain === 'solana');
				}
				const hasSolana = !!(window.solana || window.phantom?.solana || window.backpack || window.solflare);
				if (solanaTab && !hasSolana) {
					solanaTab.disabled = true;
					solanaTab.title = 'Install Phantom, Backpack, or Solflare to use Solana';
					activateChain('evm');
				}
				document.querySelectorAll('.chain-tab').forEach((t) => {
					t.addEventListener('click', () => {
						if (t.disabled) return;
						activateChain(t.dataset.chain);
					});
				});

				// Mobile scroll-into-view on focus
				const isTouch = matchMedia('(hover: none)').matches;
				if (isTouch) {
					document.querySelectorAll('#f input').forEach((input) => {
						input.addEventListener('focus', () => {
							setTimeout(() => input.scrollIntoView({ block: 'center', behavior: 'smooth' }), 250);
						});
					});
				}
			})();

			// Registration form submit
			const params = new URLSearchParams(location.search);
			// safeNext: inline copy of src/safe-next.js (tests/safe-next.test.js drift-guards it).
function safeNext(raw, fallback = '/dashboard') {
	if (typeof raw !== 'string' || raw.length === 0) return fallback;
	// Require a single leading '/': '//evil.com' is protocol-relative, and a
	// backslash anywhere lets '/\evil.com' normalize to '//evil.com' in the
	// URL parser.
	if (!raw.startsWith('/') || raw.startsWith('//')) return fallback;
	if (raw.includes('\\')) return fallback;
	// Control characters can smuggle a scheme past naive prefix checks.
	// eslint-disable-next-line no-control-regex
	if (/[\u0000-\u001f]/.test(raw)) return fallback;
	return raw;
}
			const next = safeNext(
				params.get('next') || sessionStorage.getItem('login_redirect'),
				'/create',
			);
			sessionStorage.removeItem('login_redirect');
			window.__loginNext = next;
			const form = document.getElementById('f');
			const err = document.getElementById('err');
			const btn = document.getElementById('submit');

			// Already-authenticated guard (parity with /login): a signed-in user
			// landing on the signup form is bounced straight to their destination.
			// A 401 means "not signed in" and is expected; only a transport failure
			// surfaces a notice so the user isn't left guessing.
			if (performance.getEntriesByType('navigation')[0]?.type !== 'back_forward') {
				fetch('/api/auth/me', { credentials: 'include' })
					.then((r) => {
						if (r.ok) return r.json();
						if (r.status === 401) return null;
						throw new Error('session-check-failed');
					})
					.then((data) => {
						if (data?.user) location.replace(next);
					})
					.catch(() => {
						err.textContent =
							"Couldn't verify your session — check your connection. You can still create an account below.";
						err.style.display = 'block';
					});
			}

			form.addEventListener('submit', async (e) => {
				e.preventDefault();
				err.style.display = 'none';
				btn.disabled = true;
				btn.textContent = 'Creating account…';
				try {
					const res = await fetch('/api/auth/register', {
						method: 'POST',
						credentials: 'include',
						headers: { 'content-type': 'application/json' },
						body: JSON.stringify({
							username: document.getElementById('username').value,
							password: document.getElementById('password').value,
							// Clickwrap: the required checkbox above the submit button.
							// Native form validation blocks submit until it is checked,
							// and the server rejects account creation without it.
							tosAccepted: document.getElementById('tos-accept').checked === true,
						}),
					});
					const data = await res.json().catch(() => ({}));
					if (!res.ok) {
						const msg = res.status === 429
							? 'Too many attempts. Try again in a moment.'
							: res.status === 409
								? 'That username is taken.'
								: res.status === 400
									? (data.error_description || 'Check your username and password and try again.')
									: res.status === 422
										? (data.error_description || 'That username or password isn’t allowed — try another.')
										: res.status >= 500
											? 'Something went wrong on our end. Try again in a moment.'
											: (data.error_description || 'Registration failed');
						throw new Error(msg);
					}
					try {
						localStorage.setItem('3dagent:auth-hint', JSON.stringify({ authed: true, ts: Date.now() }));
					} catch { /* ignore */ }
					location.replace(next);
				} catch (e) {
					// A thrown Error from the !res.ok branch carries human copy; a
					// raw fetch rejection (offline / DNS / CORS) does not, so map it
					// to a clear, actionable network message instead of "Failed to fetch".
					const isNetwork = e instanceof TypeError;
					err.textContent = isNetwork
						? "Couldn't reach the server — check your connection and try again."
						: e.message;
					err.style.display = 'block';
					btn.disabled = false;
					btn.textContent = 'Create account';
				}
			});
		</script>
		<script src="/brand.js" defer></script>
	<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
	<script type="module" src="/i18n.js"></script>
</body>
</html>