123456789101112import { ACCENT_COLORS, type PasswordPolicy, type SavedIdentity } from "../shared/types";13import { generatePassword, generateSmartPassword } from "../shared/generate";14import { generateTOTP } from "../crypto/totp";15import { detectPasswordPolicy } from "./policy";1617let accentHex = "#E8956D";18let popupTheme: "dark" | "light" = "dark";19chrome.runtime.sendMessage({ type: "GET_SETTINGS" }, (resp: { ok: boolean; data?: { accentColor?: string; theme?: string } } | undefined) => {20 const data = resp?.data;21 const name = data?.accentColor ?? "peach";22 accentHex = ACCENT_COLORS.find(c => c.name === name)?.hex ?? "#E8956D";23 popupTheme = data?.theme === "light" ? "light" : "dark";24});2526272829function withAlpha(hex: string, alpha: string): string {30 31 32 33 return /^#[0-9a-f]{6}$/i.test(hex) ? hex + alpha : hex;34}3536export interface SelectorEntry {37 id: string;38 title: string;39 username?: string;40 email?: string;41 url?: string;42 hasTotp?: boolean;43 44 hasPasskey?: boolean;45}4647interface SelectorOptions {48 domain?: string;49 searchableEntries?: SelectorEntry[];50 51 isSignup?: boolean;52 53545556 savedIdentities?: SavedIdentity[];57 5859606162 onFillFields?: (username: string, password: string) => void;63 6465666768 locked?: boolean;69 70717273 onUnlocked?: () => void;74 7576777879 onDismiss?: () => void;80}8182function getDomainFromUrl(url: string): string {83 try { return new URL(url).hostname.replace(/^www\./, ""); } catch { return ""; }84}8586function keySvgStr(): string {87 return `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="13" viewBox="0 0 12 13" fill="none" stroke="rgba(240,232,216,0.35)" stroke-width="0.95" stroke-linecap="round"><rect x="2" y="5.5" width="8" height="6" rx="1.5"/><path d="M4 5.5V4.25A2 2 0 0 1 6 2.25A2 2 0 0 1 8 4.25V5.5"/></svg>`;88}8990function plusSvgStr(): string {91 return `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"><path d="M6 1.5v9M1.5 6h9"/></svg>`;92}9394function peachIconSvg(): string {95 96 97 98 return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 64 64" fill="none" aria-hidden="true"><path d="M32 54C16 54 8 44 8 31C8 18 17 10 27 10C28 7 30 5.5 32 5.5C34 5.5 36 7 37 10C47 10 56 18 56 31C56 44 48 54 32 54Z" fill="#D96830"/><path d="M37 8.5C40.5 3.5 48 5 46 10.5C42 11 37 8.5 37 8.5Z" fill="#7B9060"/></svg>`;99}100101function genSvgStr(): string {102 return `<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 11 11" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round"><path d="M9.5 2A4.5 4.5 0 1 0 10.5 5.5"/><path d="M8.5 2H9.5V1"/></svg>`;103}104105function checkSvgStr(): string {106 return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="#7B9060" stroke-width="1.5" stroke-linecap="round"><path d="M4 10.5L8 14.5L16 6.5"/></svg>`;107}108109function smartUrl(): { origin: string; title: string; loginSubdomain: boolean } {110 const { hostname, origin } = location;111 const parts = hostname.split(".");112 const AUTH_PREFIXES = ["accounts", "auth", "login", "signin", "sign-in", "sso",113 "id", "identity", "secure", "portal", "my", "am", "idp", "connect", "oauth",114 "oidc", "federation", "saml", "cas", "ldap"];115 const loginSubdomain = parts.length > 2 && AUTH_PREFIXES.includes(parts[0]!.toLowerCase());116 const rootName = parts.length >= 2 ? parts[parts.length - 2]! : parts[0]!;117 const title = rootName.charAt(0).toUpperCase() + rootName.slice(1);118 return { origin, title, loginSubdomain };119}120121122123124125126export function showRememberSiteToast(127 pageDomain: string,128 entryId: string,129): void {130 const host = document.createElement("div");131 host.style.cssText = "position:fixed;bottom:22px;left:50%;transform:translateX(-50%);z-index:2147483647;pointer-events:auto;";132 host.style.setProperty("--peach-accent", accentHex);133 const shadow = host.attachShadow({ mode: "closed" });134135 const style = document.createElement("style");136 style.textContent = `137 .bar {138 display:flex;align-items:center;gap:10px;padding:10px 14px;139 background:#131109;border:1px solid rgba(240,232,216,0.09);140 border-radius:10px;box-shadow:0 8px 32px rgba(0,0,0,0.75);141 font-family:Inter,sans-serif;white-space:nowrap;142 animation:tf-in 180ms cubic-bezier(0.16,1,0.3,1) both;143 }144 @keyframes tf-in { from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none} }145 .txt { font-size:11px;color:rgba(240,232,216,0.55);font-family:"IBM Plex Mono",monospace; }146 .yes {147 padding:5px 12px;border-radius:6px;border:none;cursor:pointer;font-size:11px;148 background:var(--peach-accent);color:#fff;transition:background 100ms;font-family:Inter,sans-serif;149 }150 .yes:hover { background:color-mix(in srgb, var(--peach-accent) 82%, #000); }151 .no {152 padding:5px 10px;border-radius:6px;border:none;cursor:pointer;font-size:11px;153 background:rgba(240,232,216,0.07);color:rgba(240,232,216,0.45);font-family:Inter,sans-serif;154 }155 `;156 shadow.appendChild(style);157158 const bar = document.createElement("div"); bar.className = "bar";159 const txt = document.createElement("span"); txt.className = "txt";160 txt.textContent = `Remember ${pageDomain} for this entry?`;161 const yesBtn = document.createElement("button"); yesBtn.className = "yes";162 yesBtn.textContent = "Remember";163 yesBtn.addEventListener("click", async () => {164 await chrome.runtime.sendMessage({165 type: "ADD_ADDITIONAL_URL",166 payload: { id: entryId, url: location.origin },167 });168 host.remove();169 });170 const noBtn = document.createElement("button"); noBtn.className = "no";171 noBtn.textContent = "Not now";172 noBtn.addEventListener("click", () => host.remove());173 bar.append(txt, yesBtn, noBtn);174 shadow.appendChild(bar);175 document.body.appendChild(host);176 setTimeout(() => host.remove(), 9000);177}178179function generatePasswordForSite(policy: PasswordPolicy = {}): string {180 return generateSmartPassword(policy);181}182183interface SmartGenerator {184 root: HTMLElement;185 getPassword: () => string;186 187 copy: () => Promise<void>;188}189190interface SmartGeneratorOptions {191 192 policy: PasswordPolicy;193 194195196197198 initialPassword?: string;199 200 onChange?: (pw: string) => void;201}202203204205206207208209210function createSmartGenerator(opts: SmartGeneratorOptions): SmartGenerator {211 const policy = opts.policy ?? {};212213 214 let length = policy.maxLength ?? 64;215 if (policy.minLength) length = Math.max(length, policy.minLength);216 if (length < 8) length = 8;217 if (length > 128) length = 128;218219 let upper = true;220 let lower = true;221 let numbers = true;222 let symbols = !policy.forbidsSymbols;223 if (policy.requiresSymbols) symbols = true;224 const forbiddenChars = policy.forbiddenChars ?? "";225226 let password = "";227228 const root = document.createElement("div");229 root.className = "pwgen-block";230231 const displayRow = root.appendChild(document.createElement("div"));232 displayRow.className = "pwgen-display-row";233 const output = displayRow.appendChild(document.createElement("input")) as HTMLInputElement;234 output.type = "text";235 output.className = "pwgen-output";236 output.setAttribute("autocomplete", "off");237 output.setAttribute("spellcheck", "false");238 output.setAttribute("autocorrect", "off");239 output.setAttribute("autocapitalize", "off");240241 const regenBtn = displayRow.appendChild(document.createElement("button"));242 regenBtn.className = "pwgen-icon-btn";243 regenBtn.type = "button";244 regenBtn.setAttribute("aria-label", "Regenerate password");245 regenBtn.title = "Regenerate";246 regenBtn.innerHTML = `<svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round"><path d="M11 2.5A5.5 5.5 0 1 0 12.5 7"/><path d="M9.5 2.5H11V1"/></svg>`;247248 const copyBtn = displayRow.appendChild(document.createElement("button"));249 copyBtn.className = "pwgen-icon-btn";250 copyBtn.type = "button";251 copyBtn.setAttribute("aria-label", "Copy password");252 copyBtn.title = "Copy";253 copyBtn.innerHTML = `<svg width="12" height="12" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="8" height="9" rx="1.5"/><path d="M10 4V2.5A1.5 1.5 0 0 0 8.5 1h-6A1.5 1.5 0 0 0 1 2.5v7A1.5 1.5 0 0 0 2.5 11H4"/></svg>`;254255 const controls = root.appendChild(document.createElement("div"));256 controls.className = "pwgen-controls-row";257 const slider = controls.appendChild(document.createElement("input"));258 slider.type = "range";259 slider.className = "pwgen-slider";260 slider.min = "8";261 slider.max = "128";262 slider.value = String(length);263 if (policy.minLength) slider.min = String(Math.max(8, policy.minLength));264 if (policy.maxLength) slider.max = String(Math.min(128, policy.maxLength));265 const lenNum = controls.appendChild(document.createElement("span"));266 lenNum.className = "pwgen-len-num pwgen-len-num--edit";267 lenNum.textContent = String(length);268 lenNum.addEventListener("click", () => {269 const li = document.createElement("input");270 li.type = "text"; li.inputMode = "numeric";271 li.className = "pwgen-len-input"; li.value = String(length);272 lenNum.replaceWith(li);273 requestAnimationFrame(() => li.select());274 function commitLenEdit() {275 const n = parseInt(li.value, 10);276 if (!isNaN(n)) {277 length = Math.max(parseInt(slider.min, 10), Math.min(parseInt(slider.max, 10), n));278 slider.value = String(length);279 regenerate();280 }281 lenNum.textContent = String(length);282 li.replaceWith(lenNum);283 }284 li.addEventListener("keydown", (e) => { if (e.key === "Enter") { e.preventDefault(); commitLenEdit(); } else if (e.key === "Escape") { li.replaceWith(lenNum); } });285 li.addEventListener("blur", commitLenEdit);286 });287288 const pills = root.appendChild(document.createElement("div"));289 pills.className = "pwgen-pills";290291 function makePill(label: string, on: boolean, onToggle: (next: boolean) => void): HTMLButtonElement {292 const b = document.createElement("button");293 b.type = "button";294 b.className = `pwgen-pill ${on ? "is-on" : ""}`;295 b.textContent = label;296 b.addEventListener("click", () => {297 const next = !b.classList.contains("is-on");298 b.classList.toggle("is-on", next);299 onToggle(next);300 });301 return b;302 }303 pills.appendChild(makePill("A-Z", upper, (next) => { upper = next; regenerate(); }));304 pills.appendChild(makePill("a-z", lower, (next) => { lower = next; regenerate(); }));305 pills.appendChild(makePill("0-9", numbers, (next) => { numbers = next; regenerate(); }));306 pills.appendChild(makePill("!@#", symbols, (next) => {307 308 symbols = next;309 regenerate();310 }));311312 313 314 315 const hintParts: string[] = [];316 if (policy.minLength) hintParts.push(`min ${policy.minLength}`);317 if (policy.maxLength) hintParts.push(`max ${policy.maxLength}`);318 if (policy.requiresSymbols) hintParts.push("requires symbols");319 if (policy.forbidsSymbols) hintParts.push("no symbols");320 if (policy.forbiddenChars) hintParts.push(`excludes ${policy.forbiddenChars.slice(0, 6)}${policy.forbiddenChars.length > 6 ? "…" : ""}`);321 if (hintParts.length > 0) {322 const hint = root.appendChild(document.createElement("div"));323 hint.className = "pwgen-policy-hint";324 const accent = document.createElement("span");325 accent.className = "pwgen-hint-accent";326 accent.textContent = "site rules · ";327 const text = document.createTextNode(hintParts.join(" · "));328 hint.appendChild(accent);329 hint.appendChild(text);330 }331332 function regenerate() {333 334 335 password = generatePassword({336 length,337 includeUppercase: upper,338 includeLowercase: lower,339 includeNumbers: numbers,340 includeSymbols: symbols,341 forbiddenChars,342 });343 output.value = password;344 opts.onChange?.(password);345 }346347 output.addEventListener("input", () => {348 password = output.value;349 length = password.length;350 slider.value = String(Math.max(8, Math.min(128, length)));351 lenNum.textContent = String(length);352 opts.onChange?.(password);353 });354355 slider.addEventListener("input", () => {356 length = parseInt(slider.value, 10);357 lenNum.textContent = String(length);358 regenerate();359 });360 regenBtn.addEventListener("click", regenerate);361362 let copyResetTimer: ReturnType<typeof setTimeout> | null = null;363 async function copy(): Promise<void> {364 try {365 await navigator.clipboard.writeText(password);366 copyBtn.classList.add("is-copied");367 if (copyResetTimer) clearTimeout(copyResetTimer);368 copyResetTimer = setTimeout(() => copyBtn.classList.remove("is-copied"), 1400);369 } catch {370 371 }372 }373 copyBtn.addEventListener("click", () => { void copy(); });374375 if (opts.initialPassword) {376 password = opts.initialPassword;377 output.value = password;378 opts.onChange?.(password);379 } else {380 regenerate();381 }382383 return {384 root,385 getPassword: () => password,386 copy,387 };388}389390export function observeAnchorPosition(391 anchorEl: HTMLElement,392 onUpdate: () => void393): () => void {394 let rafId = 0;395 let burstUntil = 0;396397 const runUpdate = () => {398 rafId = 0;399 onUpdate();400 if (performance.now() < burstUntil) rafId = requestAnimationFrame(runUpdate);401 };402 const scheduleUpdate = () => { if (!rafId) rafId = requestAnimationFrame(runUpdate); };403 const scheduleBurst = (ms = 220) => {404 burstUntil = Math.max(burstUntil, performance.now() + ms);405 scheduleUpdate();406 };407408 const resizeObserver = new ResizeObserver(() => scheduleBurst());409 resizeObserver.observe(anchorEl);410 if (anchorEl.parentElement) resizeObserver.observe(anchorEl.parentElement);411412 const mutationObserver = new MutationObserver(() => scheduleBurst());413 mutationObserver.observe(anchorEl, { attributes: true, attributeFilter: ["class", "style", "type", "hidden"] });414 if (anchorEl.parentElement) {415 mutationObserver.observe(anchorEl.parentElement, { attributes: true, attributeFilter: ["class", "style", "hidden"] });416 }417418 const onScroll = () => scheduleUpdate();419 window.addEventListener("scroll", onScroll, true);420 window.addEventListener("resize", onScroll);421 window.visualViewport?.addEventListener("resize", onScroll);422 window.visualViewport?.addEventListener("scroll", onScroll);423 anchorEl.addEventListener("focus", () => scheduleBurst());424 anchorEl.addEventListener("input", () => scheduleBurst());425426 scheduleBurst(260);427428 return () => {429 if (rafId) cancelAnimationFrame(rafId);430 resizeObserver.disconnect();431 mutationObserver.disconnect();432 window.removeEventListener("scroll", onScroll, true);433 window.removeEventListener("resize", onScroll);434 window.visualViewport?.removeEventListener("resize", onScroll);435 window.visualViewport?.removeEventListener("scroll", onScroll);436 };437}438439export function injectFieldIcon(field: HTMLInputElement, onClick: () => void): () => void {440 const button = document.createElement("button");441 button.type = "button";442 button.setAttribute("aria-label", "Peach autofill");443 button.title = "Fill with Peach";444 button.innerHTML = peachIconSvg();445 446 447 448 449 button.style.cssText = `450 position: fixed; z-index: 2147483646;451 width: 26px; height: 26px; cursor: pointer;452 pointer-events: auto; border: none; padding: 3px;453 display: inline-flex; align-items: center; justify-content: center;454 background: transparent; border-radius: 999px;455 transition: opacity 140ms ease, background 120ms ease, box-shadow 120ms ease, transform 80ms ease;456 opacity: 0;457 `;458 button.addEventListener("mouseenter", () => {459 button.style.background = `color-mix(in srgb, ${accentHex} 12%, transparent)`;460 button.style.boxShadow = `0 0 0 1px color-mix(in srgb, ${accentHex} 18%, transparent), 0 0 14px color-mix(in srgb, ${accentHex} 12%, transparent)`;461 button.style.transform = "scale(1.08)";462 });463 button.addEventListener("mouseleave", () => {464 button.style.background = "transparent";465 button.style.boxShadow = "none";466 button.style.transform = "none";467 });468 button.addEventListener("pointerdown", e => { e.stopPropagation(); e.preventDefault(); });469 button.addEventListener("click", e => { e.stopPropagation(); e.preventDefault(); onClick(); });470471 document.body.appendChild(button);472473 function updatePosition() {474 const rect = field.getBoundingClientRect();475 if (rect.width === 0 || rect.height === 0) {476 button.style.opacity = "0"; button.style.pointerEvents = "none";477 return;478 }479 const sz = 26;480 const inset = Math.max(5, Math.min(10, rect.height * 0.22));481 const top = rect.top + rect.height / 2 - sz / 2;482 483 484 const minLeft = rect.left + 4;485 const left = Math.max(minLeft, rect.right - sz - inset);486 487 if (rect.width < 40) {488 button.style.opacity = "0"; button.style.pointerEvents = "none";489 return;490 }491 button.style.top = `${top}px`;492 button.style.left = `${left}px`;493 button.style.opacity = "1"; button.style.pointerEvents = "auto";494 }495 updatePosition();496 requestAnimationFrame(() => { button.style.opacity = "1"; });497 const stopObserving = observeAnchorPosition(field, updatePosition);498 return () => { stopObserving(); button.remove(); };499}500501502503504505506507const SELECTOR_STYLES = `508 :host { all: initial; }509 *,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }510511 .peach-inline-popup[data-theme="dark"] {512 --peach-bg: #1a1410;513 --peach-bg-card: #221c16;514 --peach-text: #f5f0ea;515 --peach-text-dim: #8a7a6a;516 --peach-text-muted: #4a3a2a;517 --peach-border: rgba(255,255,255,0.07);518 --peach-input-bg: rgba(255,255,255,0.05);519 --peach-input-border: rgba(255,255,255,0.08);520 }521 .peach-inline-popup[data-theme="light"] {522 --peach-bg: #fdf8f4;523 --peach-bg-card: #f5ede4;524 --peach-text: #1c1310;525 --peach-text-dim: #6b5a4a;526 --peach-text-muted: #a89080;527 --peach-border: rgba(0,0,0,0.08);528 --peach-input-bg: rgba(0,0,0,0.04);529 --peach-input-border: rgba(0,0,0,0.10);530 }531532 .peach-inline-popup {533 background: var(--peach-bg);534 border: 1px solid var(--peach-border-accent, var(--peach-border));535 border-radius: 14px;536 overflow: hidden;537 box-shadow:538 0 8px 40px var(--peach-glow, transparent),539 0 2px 12px rgba(0,0,0,0.5);540 font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;541 animation: peach-enter 200ms cubic-bezier(0.16,1,0.3,1) forwards;542 transition: height 220ms cubic-bezier(0.16,1,0.3,1);543 }544 /* Light theme: shadow against a light page is too strong otherwise — drop both545 the accent glow and the dark drop-shadow opacity to keep the popup elegant. */546 .peach-inline-popup[data-theme="light"] {547 box-shadow:548 0 8px 40px color-mix(in srgb, var(--peach-accent) 10%, transparent),549 0 2px 12px rgba(0,0,0,0.12);550 }551 .peach-inline-popup.is-exiting {552 animation: peach-exit 130ms cubic-bezier(0.4,0,1,1) forwards;553 pointer-events: none;554 }555556 @keyframes peach-enter {557 0% { opacity: 0; transform: translateY(-8px) scale(0.96); filter: blur(3px); }558 65% { opacity: 1; filter: blur(0); }559 100% { opacity: 1; transform: translateY(0) scale(1); }560 }561 @keyframes peach-exit {562 0% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }563 100% { opacity: 0; transform: translateY(-4px) scale(0.98); filter: blur(2px); }564 }565 @keyframes peach-slide-in {566 from { opacity: 0; transform: translateX(12px); }567 to { opacity: 1; transform: translateX(0); }568 }569 @keyframes peach-slide-back {570 from { opacity: 0; transform: translateX(-12px); }571 to { opacity: 1; transform: translateX(0); }572 }573 .peach-content[data-dir="forward"] { animation: peach-slide-in 150ms cubic-bezier(0.16,1,0.3,1) both; }574 .peach-content[data-dir="back"] { animation: peach-slide-back 150ms cubic-bezier(0.16,1,0.3,1) both; }575576 /* Domain header */577 .domain-header {578 padding: 9px 13px 7px;579 border-bottom: 1px solid var(--peach-border);580 display: flex; align-items: center; justify-content: space-between;581 gap: 8px;582 }583 .domain-header-text {584 display: flex; flex-direction: column; gap: 2px;585 min-width: 0; flex: 1;586 }587 .domain-eyebrow {588 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;589 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;590 }591 .domain-name {592 font-size: 10px; color: color-mix(in srgb, var(--peach-accent) 60%, transparent);593 font-family: "IBM Plex Mono", monospace;594 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;595 }596 .domain-add-btn {597 flex-shrink: 0;598 width: 22px; height: 22px;599 display: inline-flex; align-items: center; justify-content: center;600 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);601 border: 1px solid color-mix(in srgb, var(--peach-accent) 28%, transparent);602 border-radius: 6px;603 color: var(--peach-accent);604 cursor: pointer; padding: 0;605 transition: background 120ms, border-color 120ms, transform 80ms;606 font-family: "IBM Plex Mono", monospace;607 font-size: 14px; line-height: 1;608 }609 .domain-add-btn:hover {610 background: color-mix(in srgb, var(--peach-accent) 22%, transparent);611 border-color: color-mix(in srgb, var(--peach-accent) 48%, transparent);612 transform: scale(1.06);613 }614 .domain-add-btn:active { transform: scale(0.96); }615616 /* Search */617 .search-wrap {618 padding: 9px 12px 7px;619 border-bottom: 1px solid var(--peach-border);620 }621 .search {622 width: 100%; background: var(--peach-input-bg);623 border: 1px solid var(--peach-input-border);624 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;625 font-size: 12px; outline: none; font-family: "IBM Plex Mono", monospace;626 transition: border-color 120ms, box-shadow 120ms;627 }628 .search:focus {629 border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent);630 box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent);631 }632 .search::placeholder { color: var(--peach-text-muted); }633634 /* Results */635 .results { max-height: 256px; overflow-y: auto; scrollbar-width: none; }636 .results::-webkit-scrollbar { display: none; }637638 /* Entry rows */639 .entry {640 display: flex; align-items: center; padding: 8px 12px;641 cursor: pointer; border-bottom: 1px solid var(--peach-border);642 transition: background 70ms; position: relative; outline: none;643 }644 .entry:last-child { border-bottom: none; }645 .entry:hover { background: color-mix(in srgb, var(--peach-text) 4%, transparent); }646 .entry.focused { background: color-mix(in srgb, var(--peach-accent) 8%, transparent); }647 .entry.focused::before {648 content: ""; position: absolute; left: 0; top: 3px; bottom: 3px;649 width: 2px; border-radius: 2px;650 background: color-mix(in srgb, var(--peach-accent) 55%, transparent);651 }652653 .entry-icon {654 width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;655 background: var(--peach-input-bg); border: 1px solid var(--peach-border);656 display: flex; align-items: center; justify-content: center;657 overflow: hidden; margin-right: 10px;658 }659 .entry-icon img { width: 15px; height: 15px; border-radius: 2px; display: block; }660 .entry-icon.is-new {661 background: color-mix(in srgb, var(--peach-accent) 8%, transparent);662 border-color: color-mix(in srgb, var(--peach-accent) 15%, transparent);663 color: color-mix(in srgb, var(--peach-accent) 80%, transparent);664 }665666 .entry-info { flex: 1; min-width: 0; }667 .entry-title {668 font-size: 12.5px; color: var(--peach-text);669 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;670 line-height: 1.3;671 }672 .entry-title.is-new { color: color-mix(in srgb, var(--peach-accent) 90%, transparent); font-size: 12px; }673 .entry-sub {674 font-size: 10px; color: var(--peach-text-dim);675 font-family: "IBM Plex Mono", monospace;676 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;677 margin-top: 1px;678 }679680 .totp-badge {681 font-size: 8px; letter-spacing: 0.04em; padding: 2px 6px;682 border-radius: 4px; background: color-mix(in srgb, var(--peach-accent) 10%, transparent);683 color: color-mix(in srgb, var(--peach-accent) 75%, transparent);684 font-family: "IBM Plex Mono", monospace; flex-shrink: 0; margin-left: 8px;685 }686 .passkey-badge {687 font-size: 8px; letter-spacing: 0.04em; padding: 2px 6px;688 border-radius: 4px;689 background: color-mix(in srgb, var(--peach-accent) 14%, transparent);690 color: color-mix(in srgb, var(--peach-accent) 85%, transparent);691 border: 1px solid color-mix(in srgb, var(--peach-accent) 24%, transparent);692 font-family: "IBM Plex Mono", monospace; flex-shrink: 0; margin-left: 6px;693 }694695 .divider { height: 1px; background: var(--peach-border); margin: 2px 0; }696697 .empty-hint {698 padding: 14px 13px; font-size: 11px; color: var(--peach-text-dim);699 font-family: "IBM Plex Mono", monospace;700 }701702 /* Create form */703 .create-form-wrap {704 animation: peach-slide-in 180ms cubic-bezier(0.16,1,0.3,1) both;705 }706 .create-head {707 display: flex; align-items: center; gap: 8px;708 padding: 10px 12px; border-bottom: 1px solid var(--peach-border);709 }710 .back-btn {711 background: transparent; border: none; cursor: pointer;712 color: var(--peach-text-dim); padding: 3px; border-radius: 5px;713 display: flex; align-items: center; line-height: 0;714 transition: color 100ms, background 100ms;715 }716 .back-btn:hover { color: var(--peach-text); background: var(--peach-input-bg); }717 .create-label { font-size: 12px; color: var(--peach-text); font-weight: 500; flex: 1; }718 /* minmax(0, 1fr) caps the grid track at the popup width — without it,719 long monospace content (e.g. a 60-char generated password) would720 auto-size the track wider than the popup and overflow the right edge. */721 .create-body { padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }722 .f-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; }723 .f-label {724 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;725 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;726 }727 .f-input {728 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);729 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;730 font-size: 11px; font-family: "IBM Plex Mono", monospace;731 outline: none; width: 100%; transition: border-color 120ms, box-shadow 120ms;732 }733 .f-input:focus { border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent); }734 .f-input::placeholder { color: var(--peach-text-muted); }735 .f-input.url-f { font-size: 10px; color: var(--peach-text-dim); letter-spacing: 0.01em; }736 .f-row { display: flex; gap: 6px; }737 .f-row .f-input { flex: 1; min-width: 0; }738 .gen-btn {739 padding: 0 10px; border-radius: 7px; border: none;740 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);741 color: color-mix(in srgb, var(--peach-accent) 80%, transparent);742 font-size: 10px; font-family: "IBM Plex Mono", monospace;743 cursor: pointer; white-space: nowrap; flex-shrink: 0;744 display: flex; align-items: center; gap: 4px;745 transition: background 100ms;746 }747 .gen-btn:hover { background: color-mix(in srgb, var(--peach-accent) 18%, transparent); }748 .gen-toggle-link {749 background: none; border: none; padding: 2px 0;750 color: color-mix(in srgb, var(--peach-accent) 60%, transparent);751 font-size: 10px; font-family: "IBM Plex Mono", monospace;752 cursor: pointer; text-align: left; transition: color 100ms;753 }754 .gen-toggle-link:hover { color: var(--peach-accent); }755 .save-btn {756 width: 100%; padding: 8px; border-radius: 8px; border: none;757 background: var(--peach-accent); color: #fff; font-size: 12px;758 font-family: Inter, sans-serif; cursor: pointer; font-weight: 500;759 transition: background 120ms, box-shadow 120ms, transform 80ms;760 letter-spacing: 0.01em;761 }762 .save-btn:hover {763 background: color-mix(in srgb, var(--peach-accent) 82%, #000);764 box-shadow: 0 4px 20px var(--peach-glow, transparent);765 }766 .save-btn:disabled { opacity: 0.4; cursor: not-allowed; }767 .url-hint {768 font-size: 9px; color: color-mix(in srgb, var(--peach-accent) 45%, transparent);769 font-family: "IBM Plex Mono", monospace; font-style: italic;770 }771772 /* Success */773 .success-wrap {774 display: flex; flex-direction: column; align-items: center;775 padding: 24px 16px 20px; gap: 8px;776 animation: su-in 280ms cubic-bezier(0.16,1,0.3,1) both;777 }778 @keyframes su-in { from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:none} }779 .success-ring {780 width: 40px; height: 40px; border-radius: 50%;781 background: rgba(123,144,96,0.10); border: 1.5px solid rgba(123,144,96,0.25);782 display: flex; align-items: center; justify-content: center;783 }784 .success-text { font-size: 12.5px; color: var(--peach-text); font-weight: 500; }785 .success-sub { font-size: 10px; color: var(--peach-text-dim); font-family:"IBM Plex Mono",monospace; }786787 /* Silver platter (State 1 — single match) */788 .silver-platter {789 padding: 14px 14px 12px;790 display: flex; flex-direction: column; gap: 6px;791 }792 .sp-title {793 font-size: 14px; font-weight: 500; color: var(--peach-text);794 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;795 line-height: 1.25;796 }797 .sp-identity-row {798 display: flex; align-items: baseline; gap: 5px; margin-bottom: 3px;799 }800 .sp-identity-label {801 font-size: 9px; font-weight: 600; letter-spacing: 0.05em;802 text-transform: uppercase; color: var(--peach-text-muted); flex-shrink: 0;803 }804 .sp-username {805 font-size: 12px; color: var(--peach-text-dim);806 font-family: "IBM Plex Mono", monospace;807 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;808 margin-bottom: 0;809 }810 .sp-identity-row + .sp-fill-btn, .sp-username + .sp-fill-btn { margin-top: 6px; }811 .sp-fill-btn {812 width: 100%; padding: 11px; border-radius: 9px; border: none;813 background: var(--peach-accent); color: #fff;814 font-size: 13px; font-weight: 500; cursor: pointer;815 font-family: Inter, sans-serif; letter-spacing: 0.01em;816 display: flex; align-items: center; justify-content: center; min-height: 38px;817 transition: filter 120ms ease, transform 80ms ease, box-shadow 120ms ease, background 120ms ease;818 }819 .sp-fill-btn:hover {820 filter: brightness(1.1);821 box-shadow: 0 4px 20px var(--peach-glow, transparent);822 transform: translateY(-1px);823 }824 .sp-fill-btn:active { transform: translateY(0); filter: brightness(0.95); }825 .sp-fill-btn.filled {826 background: #16a34a; transform: none; filter: none;827 box-shadow: 0 4px 16px rgba(22,163,74,0.35);828 cursor: default;829 }830 .sp-fill-btn:disabled { cursor: default; }831 .sp-actions {832 display: flex; gap: 4px; justify-content: space-between; align-items: center;833 margin-top: 4px;834 }835 .sp-action-btn {836 flex: 1; height: 28px; border: none; border-radius: 6px;837 background: transparent; color: var(--peach-text-dim);838 font-size: 12px; cursor: pointer;839 transition: background 120ms ease, color 120ms ease;840 font-family: Inter, sans-serif; letter-spacing: 0.04em;841 display: inline-flex; align-items: center; justify-content: center; gap: 4px;842 white-space: nowrap; overflow: hidden;843 }844 .sp-action-btn:hover:not(:disabled) {845 background: color-mix(in srgb, var(--peach-text) 5%, transparent);846 color: var(--peach-text);847 }848 .sp-action-btn:disabled { opacity: 0.3; cursor: default; }849 .sp-action-btn.flashed {850 color: var(--peach-accent);851 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);852 }853854 /* TOTP tray — shown below the silver-platter secondary actions */855 .sp-tray {856 margin-top: 8px;857 padding: 10px 12px;858 border-radius: 9px;859 background: var(--peach-input-bg);860 border: 1px solid var(--peach-input-border);861 display: flex; align-items: center; gap: 12px;862 animation: peach-slide-in 180ms cubic-bezier(0.16,1,0.3,1) both;863 }864 .sp-tray-label {865 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;866 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;867 flex-shrink: 0;868 }869 .sp-totp-code {870 font-size: 18px; font-weight: 500;871 color: var(--peach-text);872 font-family: "IBM Plex Mono", monospace;873 letter-spacing: 0.12em;874 flex: 1;875 text-align: center;876 }877 .sp-totp-ring {878 width: 22px; height: 22px; flex-shrink: 0;879 }880 .sp-totp-ring .ring-track { stroke: var(--peach-input-border); }881 .sp-totp-ring .ring-fill {882 stroke: var(--peach-accent);883 transition: stroke-dashoffset 1s linear;884 transform: rotate(-90deg);885 transform-origin: center;886 }887 .sp-totp-copy {888 background: transparent; border: none; cursor: pointer;889 padding: 4px 8px; border-radius: 5px;890 color: var(--peach-text-dim); font-size: 11px;891 font-family: Inter, sans-serif;892 transition: background 120ms, color 120ms;893 }894 .sp-totp-copy:hover {895 background: color-mix(in srgb, var(--peach-text) 5%, transparent);896 color: var(--peach-text);897 }898899 /* Card silver platter (State 7) — reuses .sp-* primary action classes */900 .card-platter {901 padding: 12px 14px 10px;902 display: flex; flex-direction: column; gap: 4px;903 }904 .cp-network {905 font-size: 10px; font-weight: 600;906 color: var(--peach-accent);907 letter-spacing: 0.08em; text-transform: uppercase;908 font-family: Inter, sans-serif;909 }910 .cp-nickname {911 font-size: 14px; font-weight: 500; color: var(--peach-text);912 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;913 line-height: 1.2;914 }915 .cp-last4 {916 font-size: 12px; color: var(--peach-text-dim);917 font-family: "IBM Plex Mono", monospace;918 letter-spacing: 0.04em;919 margin-top: 2px;920 }921 .cp-meta {922 font-size: 11px; color: var(--peach-text-dim);923 font-family: "IBM Plex Mono", monospace;924 margin-top: 2px;925 display: flex; gap: 10px; align-items: center;926 }927 .cp-meta-sep { opacity: 0.5; }928 .cp-fill-wrap { margin-top: 10px; }929930 /* Locked state */931 .locked-wrap {932 display: flex; flex-direction: column; align-items: stretch;933 padding: 14px 13px 13px; gap: 9px;934 }935 .locked-head { display: flex; align-items: center; gap: 8px; padding-bottom: 2px; }936 .locked-icon {937 width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;938 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);939 display: flex; align-items: center; justify-content: center;940 }941 .locked-title { font-size: 11.5px; color: var(--peach-text); font-weight: 500; }942 .locked-input {943 width: 100%; background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);944 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;945 font-size: 11px; font-family: "IBM Plex Mono", monospace;946 outline: none; transition: border-color 120ms, box-shadow 120ms;947 }948 .locked-input:focus { border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent); }949 .locked-input::placeholder { color: var(--peach-text-muted); }950 .locked-btn {951 width: 100%; padding: 8px; border-radius: 8px; border: none;952 background: var(--peach-accent); color: #fff; font-size: 12px;953 font-family: Inter, sans-serif; cursor: pointer; font-weight: 500;954 transition: background 120ms;955 letter-spacing: 0.01em;956 box-shadow: 0 2px 16px var(--peach-glow, transparent);957 animation: peach-pulse-glow 2.4s ease-in-out infinite;958 }959 .locked-btn:hover { background: color-mix(in srgb, var(--peach-accent) 82%, #000); }960 .locked-btn:disabled { opacity: 0.4; cursor: not-allowed; animation: none; }961 .locked-error {962 font-size: 10px; color: rgba(220,80,60,0.85);963 font-family: "IBM Plex Mono", monospace;964 }965966 @keyframes peach-pulse-glow {967 0%, 100% { box-shadow: 0 2px 16px var(--peach-glow, transparent); }968 50% { box-shadow: 0 2px 28px var(--peach-glow, transparent),969 0 0 48px var(--peach-glow, transparent); }970 }971972 /* ── State 10: identity helper ─────────────────────────────── */973 .identity-list {974 max-height: 192px; overflow-y: auto; padding: 4px 0;975 scrollbar-width: none;976 }977 .identity-list::-webkit-scrollbar { display: none; }978 .peach-identity-row {979 display: flex; align-items: center; gap: 10px;980 padding: 9px 12px; cursor: pointer; border-radius: 8px;981 transition: background 100ms ease;982 }983 .peach-identity-row:hover { background: color-mix(in srgb, var(--peach-text) 6%, transparent); }984 .peach-identity-value {985 font-family: "IBM Plex Mono", monospace; font-size: 13px;986 color: var(--peach-text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;987 }988 .peach-identity-meta { font-size: 10px; color: var(--peach-text-muted); flex-shrink: 0; }989 .identity-alt-row {990 display: flex; align-items: center; padding: 8px 12px; cursor: pointer;991 border-radius: 8px; transition: background 100ms ease;992 color: var(--peach-text-dim); font-size: 12px; font-family: Inter, sans-serif;993 }994 .identity-alt-row:hover { background: color-mix(in srgb, var(--peach-text) 6%, transparent); }995 .identity-escape-row {996 display: flex; align-items: center; padding: 8px 12px; cursor: pointer;997 border-radius: 8px; transition: background 100ms ease; outline: none;998 color: var(--peach-accent); font-size: 11px; font-family: Inter, sans-serif;999 margin-top: 2px;1000 }1001 .identity-escape-row:hover, .identity-escape-row:focus { background: color-mix(in srgb, var(--peach-accent) 8%, transparent); }1002 .identity-alt-input-wrap { display: none; padding: 0 12px 8px; gap: 6px; align-items: center; }1003 .identity-alt-input-wrap.open { display: flex; }1004 .identity-alt-input {1005 flex: 1; height: 32px; padding: 0 10px; border-radius: 7px;1006 border: 1px solid var(--peach-input-border); background: var(--peach-input-bg);1007 color: var(--peach-text); font-family: "IBM Plex Mono", monospace; font-size: 12px;1008 outline: none; transition: border-color 120ms;1009 }1010 .identity-alt-input:focus {1011 border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent);1012 box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent);1013 }1014 .identity-alt-confirm {1015 height: 32px; padding: 0 12px; border-radius: 7px; border: none;1016 background: var(--peach-accent); color: #fff; font-size: 12px;1017 cursor: pointer; font-family: Inter, sans-serif; flex-shrink: 0;1018 }1019 /* ── Generator view (after identity picked) ────────────────── */1020 .gen-view { padding: 12px; display: flex; flex-direction: column; gap: 8px; }1021 .gen-confirmed {1022 display: flex; align-items: center; gap: 8px; padding: 7px 10px;1023 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1024 border-radius: 8px;1025 }1026 .gen-confirmed-check { color: var(--peach-accent); font-size: 13px; font-weight: 600; }1027 .gen-confirmed-val {1028 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1029 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;1030 }1031 .gen-label {1032 font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;1033 color: var(--peach-text-muted); font-family: "IBM Plex Mono", monospace;1034 }1035 .gen-pw-row { display: flex; gap: 6px; align-items: center; }1036 .gen-pw-val {1037 flex: 1; padding: 8px 10px; border-radius: 7px;1038 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);1039 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1040 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;1041 }1042 .gen-regen-btn {1043 height: 34px; padding: 0 10px; border-radius: 7px; border: none;1044 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1045 color: var(--peach-text-dim); font-size: 11px; cursor: pointer;1046 font-family: "IBM Plex Mono", monospace; transition: background 100ms ease;1047 }1048 .gen-regen-btn:hover { background: color-mix(in srgb, var(--peach-text) 14%, transparent); }1049 .gen-fill-btn {1050 padding: 10px; border-radius: 8px; border: none;1051 background: var(--peach-accent); color: #fff; font-size: 13px; font-weight: 500;1052 cursor: pointer; font-family: Inter, sans-serif; letter-spacing: 0.01em;1053 transition: filter 120ms ease, transform 80ms ease;1054 }1055 .gen-fill-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }1056 .gen-fill-btn:active { transform: translateY(0); }10571058 /* ── Smart password generator (parity with main UI compact mode) ─── */1059 .pwgen-block { display: flex; flex-direction: column; gap: 8px; }1060 .pwgen-display-row {1061 display: flex; align-items: center; gap: 6px;1062 padding: 8px 10px; border-radius: 7px;1063 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);1064 }1065 .pwgen-output {1066 flex: 1; min-width: 0; width: 0;1067 font-family: "IBM Plex Mono", monospace; font-size: 12px;1068 color: var(--peach-text);1069 background: transparent; border: none; outline: none; padding: 0;1070 }1071 .pwgen-icon-btn {1072 flex-shrink: 0;1073 width: 26px; height: 26px;1074 display: inline-flex; align-items: center; justify-content: center;1075 background: transparent; border: 1px solid var(--peach-input-border);1076 border-radius: 6px; color: var(--peach-text-dim); cursor: pointer;1077 padding: 0; transition: background 100ms, color 100ms, border-color 100ms;1078 }1079 .pwgen-icon-btn:hover {1080 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1081 color: var(--peach-accent);1082 border-color: color-mix(in srgb, var(--peach-accent) 30%, transparent);1083 }1084 .pwgen-icon-btn.is-copied {1085 background: color-mix(in srgb, var(--peach-accent) 18%, transparent);1086 color: var(--peach-accent);1087 border-color: color-mix(in srgb, var(--peach-accent) 45%, transparent);1088 }1089 .pwgen-controls-row {1090 display: flex; align-items: center; gap: 8px;1091 flex-wrap: wrap;1092 }1093 .pwgen-slider {1094 flex: 1; min-width: 110px;1095 accent-color: var(--peach-accent);1096 cursor: pointer; height: 2px; background: transparent;1097 }1098 .pwgen-len-num {1099 font-family: "IBM Plex Mono", monospace; font-size: 11px;1100 color: var(--peach-accent); min-width: 22px; text-align: right;1101 }1102 .pwgen-len-num--edit { cursor: text; border-bottom: 1px dotted color-mix(in srgb, var(--peach-accent) 50%, transparent); }1103 .pwgen-len-input {1104 font-family: "IBM Plex Mono", monospace; font-size: 11px;1105 color: var(--peach-accent); width: 28px; text-align: right;1106 background: transparent; border: none; border-bottom: 1px solid var(--peach-accent);1107 outline: none; padding: 0; min-width: 22px;1108 }1109 @keyframes identity-suggest-in {1110 from { opacity: 0; transform: translateY(-4px); }1111 to { opacity: 1; transform: none; }1112 }1113 .identity-suggest-list { display: flex; flex-direction: column; gap: 1px; margin-top: 3px;1114 animation: identity-suggest-in 180ms cubic-bezier(0.16,1,0.3,1) both; }1115 .identity-filter-row { display: flex; align-items: center; gap: 4px; padding: 2px 0 4px; }1116 .identity-collapse-btn {1117 margin-left: auto; background: transparent; border: none; cursor: pointer;1118 color: var(--peach-text-muted); padding: 2px 4px; display: flex; align-items: center;1119 line-height: 0; border-radius: 3px;1120 transition: color 100ms ease, transform 220ms cubic-bezier(0.16,1,0.3,1);1121 }1122 .identity-collapse-btn:hover { color: var(--peach-text); }1123 .identity-collapse-btn.is-collapsed { transform: rotate(-90deg); }1124 .identity-rows { display: grid; grid-template-rows: 1fr;1125 transition: grid-template-rows 220ms cubic-bezier(0.16,1,0.3,1); }1126 .identity-rows.is-collapsed { grid-template-rows: 0fr; }1127 .identity-rows-inner { overflow-y: auto; min-height: 0; max-height: 148px;1128 scrollbar-width: thin; scrollbar-color: var(--peach-text-muted) transparent;1129 mask-image: linear-gradient(to bottom, black calc(100% - 18px), transparent 100%);1130 -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 18px), transparent 100%); }1131 .identity-rows-inner::-webkit-scrollbar { width: 4px; }1132 .identity-rows-inner::-webkit-scrollbar-track { background: transparent; }1133 .identity-rows-inner::-webkit-scrollbar-thumb { background: var(--peach-text-muted); border-radius: 2px; }1134 .identity-filter-pill {1135 padding: 2px 7px; border-radius: 999px;1136 border: 1px solid var(--peach-input-border);1137 background: transparent; color: var(--peach-text-muted);1138 font-family: "IBM Plex Mono", monospace; font-size: 9px;1139 cursor: pointer; transition: border-color 80ms, background 80ms, color 80ms;1140 }1141 .identity-filter-pill.is-on {1142 border-color: color-mix(in srgb, var(--peach-accent) 50%, transparent);1143 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1144 color: var(--peach-accent);1145 }1146 .identity-suggest-row {1147 display: flex; align-items: center; gap: 5px;1148 width: 100%; padding: 4px 6px; border-radius: 5px; border: none;1149 background: transparent; cursor: pointer; text-align: left;1150 transition: background 80ms;1151 }1152 .identity-suggest-row:hover,1153 .identity-suggest-row:focus { background: color-mix(in srgb, var(--peach-accent) 10%, transparent); outline: none; }1154 .identity-suggest-val {1155 font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--peach-text);1156 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;1157 }1158 .identity-suggest-type {1159 font-family: "IBM Plex Mono", monospace; font-size: 8px; font-weight: 600;1160 flex-shrink: 0; padding: 1px 3px; border-radius: 3px;1161 }1162 .identity-suggest-type--email {1163 color: color-mix(in srgb, var(--peach-accent) 70%, transparent);1164 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);1165 }1166 .identity-suggest-type--username {1167 color: var(--peach-text-muted);1168 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1169 }1170 .identity-suggest-meta {1171 font-family: "IBM Plex Mono", monospace; font-size: 9px;1172 color: var(--peach-text-muted); flex-shrink: 0;1173 }1174 .pwgen-pills { display: flex; gap: 5px; flex-wrap: wrap; }1175 .pwgen-pill {1176 padding: 3px 8px; border-radius: 999px;1177 border: 1px solid var(--peach-input-border);1178 background: transparent; color: var(--peach-text-muted);1179 font-family: "IBM Plex Mono", monospace; font-size: 9px;1180 letter-spacing: 0.06em; cursor: pointer;1181 transition: all 130ms ease;1182 }1183 .pwgen-pill.is-on {1184 border-color: color-mix(in srgb, var(--peach-accent) 50%, transparent);1185 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1186 color: var(--peach-accent);1187 }1188 .pwgen-pill:not(.is-on):hover {1189 color: var(--peach-text-dim);1190 border-color: var(--peach-text-muted);1191 }1192 .pwgen-policy-hint {1193 font-size: 10px; color: var(--peach-text-muted);1194 font-family: "IBM Plex Mono", monospace; letter-spacing: 0.04em;1195 line-height: 1.3;1196 }1197 .pwgen-policy-hint .pwgen-hint-accent { color: var(--peach-accent); }11981199 /* ── Save offer (after password filled) ───────────────────── */1200 .save-offer { padding: 12px; display: flex; flex-direction: column; gap: 8px; }1201 .save-offer-title {1202 font-size: 12px; font-weight: 600; color: var(--peach-text); font-family: Inter, sans-serif;1203 }1204 .save-offer-row {1205 display: flex; align-items: center; gap: 8px; padding: 6px 8px;1206 border-radius: 7px; background: var(--peach-input-bg);1207 border: 1px solid var(--peach-input-border);1208 }1209 .save-offer-lbl {1210 font-size: 10px; color: var(--peach-text-muted); width: 54px; flex-shrink: 0;1211 font-family: "IBM Plex Mono", monospace;1212 }1213 .save-offer-val {1214 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1215 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;1216 }1217 .save-offer-btns { display: flex; gap: 8px; margin-top: 4px; }1218 .save-offer-save {1219 flex: 1; padding: 9px; border-radius: 8px; border: none;1220 background: var(--peach-accent); color: #fff; font-size: 13px;1221 cursor: pointer; font-family: Inter, sans-serif; transition: filter 120ms ease;1222 }1223 .save-offer-save:hover { filter: brightness(1.08); }1224 .save-offer-skip {1225 flex: 1; padding: 9px; border-radius: 8px; border: none;1226 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1227 color: var(--peach-text-dim); font-size: 13px; cursor: pointer;1228 font-family: Inter, sans-serif; transition: background 100ms ease;1229 }1230 .save-offer-skip:hover { background: color-mix(in srgb, var(--peach-text) 14%, transparent); }1231`;12321233export function showAutofillSelector(1234 anchorEl: HTMLInputElement,1235 entries: SelectorEntry[],1236 onSelect: (id: string) => void,1237 options: SelectorOptions = {}1238): () => void {1239 const host = document.createElement("div");1240 host.style.cssText = "position: absolute; z-index: 2147483647;";1241 host.style.setProperty("--peach-accent", accentHex);1242 host.style.setProperty("--peach-accent-dim", withAlpha(accentHex, "28"));1243 host.style.setProperty("--peach-glow", withAlpha(accentHex, "18"));1244 host.style.setProperty("--peach-border-accent", withAlpha(accentHex, "30"));1245 const shadow = host.attachShadow({ mode: "closed" });12461247 const style = shadow.appendChild(document.createElement("style"));1248 style.textContent = SELECTOR_STYLES;12491250 const rect = anchorEl.getBoundingClientRect();1251 host.style.top = `${rect.bottom + window.scrollY + 5}px`;1252 host.style.left = `${rect.left + window.scrollX}px`;1253 1254 1255 1256 1257 const popupWidth = Math.min(Math.max(rect.width, 320), 400);1258 host.style.width = `${popupWidth}px`;12591260 const container = shadow.appendChild(document.createElement("div"));1261 container.className = "peach-inline-popup";1262 container.setAttribute("data-theme", popupTheme);12631264 const searchableEntries = options.searchableEntries ?? [];1265 const { origin: sOrigin, title: sTitle, loginSubdomain } = smartUrl();12661267 let query = "";1268 let focusedIndex = -1;1269 let currentMode: "list" | "create" | "success" | "silver-platter" = "list";1270 let searchInput: HTMLInputElement | null = null;1271 1272 1273 const cleanupHooks: Array<() => void> = [];12741275 1276 1277 1278 {1279 let prevH = 0;1280 let blocked = false;1281 const heightRo = new ResizeObserver(([entry]) => {1282 if (blocked) return;1283 const h = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;1284 if (prevH > 0 && Math.abs(h - prevH) > 1) {1285 blocked = true;1286 container.style.height = `${prevH}px`;1287 requestAnimationFrame(() => requestAnimationFrame(() => {1288 container.style.height = `${h}px`;1289 prevH = h;1290 const onEnd = (e: TransitionEvent) => {1291 if (e.propertyName !== "height") return;1292 container.style.height = "";1293 blocked = false;1294 container.removeEventListener("transitionend", onEnd);1295 };1296 container.addEventListener("transitionend", onEnd);1297 }));1298 } else {1299 prevH = h;1300 }1301 });1302 heightRo.observe(container);1303 cleanupHooks.push(() => heightRo.disconnect());1304 }13051306 1307 const preUsername = (anchorEl.type !== "password") ? (anchorEl.value?.trim() ?? "") : "";1308 const pwInForm = anchorEl.closest("form")?.querySelector<HTMLInputElement>("input[type='password']");1309 const prePassword = pwInForm?.value?.trim() ?? (anchorEl.type === "password" ? anchorEl.value?.trim() : "") ?? "";13101311 function uniqueEntries(list: SelectorEntry[]): SelectorEntry[] {1312 const seen = new Set<string>();1313 return list.filter(e => { if (seen.has(e.id)) return false; seen.add(e.id); return true; });1314 }13151316 function filterEntries(source: SelectorEntry[], value: string): SelectorEntry[] {1317 const q = value.trim().toLowerCase();1318 const deduped = uniqueEntries(source);1319 if (!q) return deduped.slice(0, 8);1320 return deduped.filter(e =>1321 [e.title, e.username ?? "", e.url ?? ""].join(" ").toLowerCase().includes(q)1322 ).slice(0, 12);1323 }13241325 function activeEntries(): SelectorEntry[] {1326 1327 if (query.trim()) {1328 const merged = uniqueEntries([...entries, ...searchableEntries]);1329 return filterEntries(merged, query);1330 }1331 1332 if (entries.length > 0) return entries;1333 return filterEntries(searchableEntries, "").slice(0, 8);1334 }13351336 function makeEntryIcon(url?: string, isNew = false): HTMLDivElement {1337 const icon = document.createElement("div");1338 icon.className = `entry-icon${isNew ? " is-new" : ""}`;1339 if (isNew) {1340 icon.innerHTML = plusSvgStr();1341 } else {1342 1343 1344 1345 void url;1346 icon.innerHTML = keySvgStr();1347 }1348 return icon;1349 }13501351 function renderIdentityHelper() {1352 container.innerHTML = "";1353 const identities = options.savedIdentities ?? [];13541355 1356 const hdr = container.appendChild(document.createElement("div"));1357 hdr.className = "domain-header";1358 const eyebrow = hdr.appendChild(document.createElement("div"));1359 eyebrow.className = "domain-eyebrow";1360 eyebrow.textContent = "NEW ACCOUNT";1361 const domName = hdr.appendChild(document.createElement("div"));1362 domName.className = "domain-name";1363 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");13641365 1366 const list = container.appendChild(document.createElement("div"));1367 list.className = "identity-list";1368 for (const id of identities) {1369 const row = list.appendChild(document.createElement("div"));1370 row.className = "peach-identity-row";1371 row.setAttribute("tabindex", "-1");1372 const val = row.appendChild(document.createElement("div"));1373 val.className = "peach-identity-value";1374 val.textContent = id.value;1375 const meta = row.appendChild(document.createElement("div"));1376 meta.className = "peach-identity-meta";1377 meta.textContent = `used ${id.useCount}×`;1378 row.addEventListener("click", () => {1379 options.onFillFields?.(id.value, "");1380 renderGenerator(id.value);1381 });1382 }13831384 1385 if (identities.length > 0) {1386 container.appendChild(Object.assign(document.createElement("div"), { className: "divider" }));1387 }13881389 1390 const altRow = container.appendChild(document.createElement("div"));1391 altRow.className = "identity-alt-row";1392 altRow.textContent = "+ Use a different email…";13931394 const altInputWrap = container.appendChild(document.createElement("div"));1395 altInputWrap.className = "identity-alt-input-wrap";1396 const altInput = altInputWrap.appendChild(document.createElement("input"));1397 altInput.className = "identity-alt-input";1398 altInput.type = "email";1399 altInput.placeholder = "[email protected]";1400 altInput.setAttribute("autocomplete", "off");1401 const altConfirm = altInputWrap.appendChild(document.createElement("button"));1402 altConfirm.className = "identity-alt-confirm";1403 altConfirm.type = "button";1404 altConfirm.textContent = "✓";14051406 function fillCustomEmail() {1407 const v = altInput.value.trim();1408 if (!v) return;1409 options.onFillFields?.(v, "");1410 renderGenerator(v);1411 }14121413 altRow.addEventListener("click", () => {1414 altRow.style.display = "none";1415 altInputWrap.classList.add("open");1416 altInput.focus();1417 });1418 altConfirm.addEventListener("click", fillCustomEmail);1419 altInput.addEventListener("keydown", (e) => {1420 if (e.key === "Enter") { e.preventDefault(); fillCustomEmail(); }1421 });14221423 1424 1425 1426 1427 1428 if ((options.searchableEntries?.length ?? 0) > 0) {1429 const escapeRow = container.appendChild(document.createElement("div"));1430 escapeRow.className = "identity-escape-row";1431 escapeRow.textContent = "I already have an account →";1432 escapeRow.setAttribute("tabindex", "0");1433 escapeRow.addEventListener("click", () => renderList());1434 escapeRow.addEventListener("keydown", (e) => {1435 if (e.key === "Enter" || e.key === " ") { e.preventDefault(); renderList(); }1436 });1437 }1438 }14391440 function renderGenerator(filledEmail: string) {1441 container.innerHTML = "";1442 const sitePolicy = detectPasswordPolicy();14431444 const wrap = container.appendChild(document.createElement("div"));1445 wrap.className = "gen-view";14461447 1448 const hdrRow = wrap.appendChild(document.createElement("div"));1449 hdrRow.className = "domain-header";1450 const eyebrow2 = hdrRow.appendChild(document.createElement("div"));1451 eyebrow2.className = "domain-eyebrow";1452 eyebrow2.textContent = "NEW ACCOUNT";1453 const domName2 = hdrRow.appendChild(document.createElement("div"));1454 domName2.className = "domain-name";1455 domName2.textContent = options.domain ?? location.hostname.replace(/^www\./, "");14561457 1458 const conf = wrap.appendChild(document.createElement("div"));1459 conf.className = "gen-confirmed";1460 const confCheck = conf.appendChild(document.createElement("span"));1461 confCheck.className = "gen-confirmed-check";1462 confCheck.textContent = "✓";1463 const confVal = conf.appendChild(document.createElement("div"));1464 confVal.className = "gen-confirmed-val";1465 confVal.textContent = filledEmail;14661467 const lbl = wrap.appendChild(document.createElement("div"));1468 lbl.className = "gen-label";1469 lbl.textContent = "Generate a password";14701471 let currentPw = "";1472 const smartGen = createSmartGenerator({1473 policy: sitePolicy,1474 onChange: (pw) => { currentPw = pw; },1475 });1476 wrap.appendChild(smartGen.root);14771478 const fillBtn = wrap.appendChild(document.createElement("button"));1479 fillBtn.className = "gen-fill-btn";1480 fillBtn.type = "button";1481 fillBtn.textContent = "Copy & fill";1482 fillBtn.addEventListener("click", () => {1483 if (!currentPw) return;1484 options.onFillFields?.("", currentPw);1485 renderSaveOffer(filledEmail, currentPw);1486 });1487 }14881489 function renderSaveOffer(filledEmail: string, filledPassword: string) {1490 container.innerHTML = "";1491 const domain = options.domain ?? location.hostname.replace(/^www\./, "");14921493 const wrap = container.appendChild(document.createElement("div"));1494 wrap.className = "save-offer";14951496 const title = wrap.appendChild(document.createElement("div"));1497 title.className = "save-offer-title";1498 title.textContent = "Save this login to Peach?";14991500 function detailRow(label: string, value: string) {1501 const row = wrap.appendChild(document.createElement("div"));1502 row.className = "save-offer-row";1503 const lbl = row.appendChild(document.createElement("div"));1504 lbl.className = "save-offer-lbl";1505 lbl.textContent = label;1506 const val = row.appendChild(document.createElement("div"));1507 val.className = "save-offer-val";1508 val.textContent = value;1509 }15101511 detailRow("site", domain);1512 detailRow("email", filledEmail);1513 detailRow("password", "••••••••••••••••");15141515 const btns = wrap.appendChild(document.createElement("div"));1516 btns.className = "save-offer-btns";15171518 const saveBtn = btns.appendChild(document.createElement("button"));1519 saveBtn.className = "save-offer-save";1520 saveBtn.type = "button";1521 saveBtn.textContent = "Save";1522 saveBtn.addEventListener("click", async () => {1523 saveBtn.disabled = true;1524 saveBtn.textContent = "Saving…";1525 try {1526 const res = await chrome.runtime.sendMessage({1527 type: "ADD_ENTRY",1528 payload: { title: sTitle, url: sOrigin, username: filledEmail, password: filledPassword, type: "login" },1529 });1530 if ((res as { ok?: boolean }).ok) {1531 showSuccess(sTitle);1532 } else {1533 saveBtn.disabled = false;1534 saveBtn.textContent = "Save";1535 }1536 } catch { saveBtn.disabled = false; saveBtn.textContent = "Save"; }1537 });15381539 const skipBtn = btns.appendChild(document.createElement("button"));1540 skipBtn.className = "save-offer-skip";1541 skipBtn.type = "button";1542 skipBtn.textContent = "Not now";1543 skipBtn.addEventListener("click", () => { dismiss(true); });1544 }15451546 function renderList() {1547 container.innerHTML = "";1548 focusedIndex = -1;1549 searchInput = null;15501551 const current = activeEntries();15521553 1554 1555 1556 const domHdr = document.createElement("div");1557 domHdr.className = "domain-header";1558 const headText = document.createElement("div");1559 headText.className = "domain-header-text";1560 const eyebrow = document.createElement("div");1561 eyebrow.className = "domain-eyebrow";1562 eyebrow.textContent = options.isSignup1563 ? "Sign up as"1564 : entries.length > 0 ? "Saved for this site" : "No saved login";1565 const domName = document.createElement("div");1566 domName.className = "domain-name";1567 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");1568 headText.append(eyebrow, domName);1569 domHdr.appendChild(headText);15701571 if (!options.isSignup) {1572 const addBtn = document.createElement("button");1573 addBtn.className = "domain-add-btn";1574 addBtn.type = "button";1575 addBtn.setAttribute("aria-label", "Create new entry");1576 addBtn.title = "Create new entry";1577 addBtn.textContent = "+";1578 addBtn.addEventListener("click", (e) => { e.stopPropagation(); void showCreateForm(); });1579 domHdr.appendChild(addBtn);1580 }15811582 container.appendChild(domHdr);15831584 1585 const sw = document.createElement("div"); sw.className = "search-wrap";1586 searchInput = document.createElement("input");1587 searchInput.className = "search";1588 searchInput.placeholder = entries.length > 0 ? "search for another entry…" : "search vault…";1589 searchInput.value = query;1590 searchInput.addEventListener("input", () => {1591 query = searchInput?.value ?? "";1592 renderList();1593 searchInput?.focus();1594 searchInput?.setSelectionRange(query.length, query.length);1595 });1596 sw.appendChild(searchInput);1597 container.appendChild(sw);15981599 1600 const results = document.createElement("div");1601 results.className = "results";1602 container.appendChild(results);16031604 if (current.length === 0 && entries.length > 0) {1605 1606 }16071608 for (let i = 0; i < current.length; i++) {1609 const e = current[i]!;1610 const entryEl = document.createElement("div");1611 entryEl.className = "entry";1612 entryEl.dataset.id = e.id;1613 entryEl.dataset.index = String(i);1614 entryEl.setAttribute("tabindex", "-1");16151616 entryEl.appendChild(makeEntryIcon(e.url));16171618 const info = document.createElement("div"); info.className = "entry-info";1619 const titleEl = document.createElement("div"); titleEl.className = "entry-title"; titleEl.textContent = e.title;1620 const subEl = document.createElement("div"); subEl.className = "entry-sub";1621 const domain = e.url ? getDomainFromUrl(e.url) : "";1622 subEl.textContent = domain || e.username || "";1623 info.append(titleEl, subEl);1624 entryEl.appendChild(info);16251626 if (e.hasTotp) {1627 const badge = document.createElement("span"); badge.className = "totp-badge"; badge.textContent = "TOTP";1628 entryEl.appendChild(badge);1629 }1630 if (e.hasPasskey) {1631 const badge = document.createElement("span"); badge.className = "passkey-badge"; badge.textContent = "passkey";1632 entryEl.appendChild(badge);1633 }16341635 entryEl.addEventListener("click", () => {1636 if (options.isSignup && options.onFillFields) {1637 1638 options.onFillFields(e.username ?? "", "");1639 dismiss();1640 } else {1641 onSelect(e.id);1642 dismiss();1643 }1644 });1645 results.appendChild(entryEl);1646 }16471648 1649 if (current.length > 0) {1650 results.appendChild(Object.assign(document.createElement("div"), { className: "divider" }));1651 }16521653 1654 const newEl = document.createElement("div");1655 newEl.className = "entry";1656 newEl.setAttribute("tabindex", "-1");1657 newEl.appendChild(makeEntryIcon(undefined, true));16581659 const newInfo = document.createElement("div"); newInfo.className = "entry-info";1660 const newTitle = document.createElement("div");1661 newTitle.className = "entry-title is-new";1662 newTitle.textContent = `New entry for ${sTitle}`;1663 const newSub = document.createElement("div");1664 newSub.className = "entry-sub";1665 newSub.textContent = sOrigin;1666 newInfo.append(newTitle, newSub);1667 newEl.appendChild(newInfo);1668 newEl.addEventListener("click", showCreateForm);1669 results.appendChild(newEl);16701671 1672 if (searchInput) {1673 requestAnimationFrame(() => searchInput?.focus());1674 }1675 }16761677 function setFocused(idx: number) {1678 const all = container.querySelectorAll<HTMLElement>(".entry");1679 all.forEach((el, i) => el.classList.toggle("focused", i === idx));1680 focusedIndex = idx;1681 if (idx >= 0) (all[idx] as HTMLElement).scrollIntoView({ block: "nearest" });1682 }16831684 function attachIdentitySuggestions(g: HTMLDivElement, inp: HTMLInputElement, identities: SavedIdentity[], fieldType: "username" | "email"): void {1685 const typed = identities.filter(s => s.type === fieldType);1686 if (!typed.length) return;1687 let collapsed = false;1688 let suppressNextFocus = false;16891690 const list = g.appendChild(document.createElement("div"));1691 list.className = "identity-suggest-list";1692 list.style.display = "none";16931694 1695 const collapseRow = list.appendChild(document.createElement("div"));1696 collapseRow.className = "identity-filter-row";1697 collapseRow.style.justifyContent = "flex-end";1698 const collapseBtn = collapseRow.appendChild(document.createElement("button"));1699 collapseBtn.type = "button";1700 collapseBtn.className = "identity-collapse-btn";1701 collapseBtn.innerHTML = `<svg width="10" height="6" viewBox="0 0 10 6" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 1L5 5L9 1"/></svg>`;1702 collapseBtn.addEventListener("mousedown", (e) => {1703 e.preventDefault();1704 collapsed = !collapsed;1705 collapseBtn.classList.toggle("is-collapsed", collapsed);1706 rowsWrapper.classList.toggle("is-collapsed", collapsed);1707 });17081709 const rowsWrapper = list.appendChild(document.createElement("div"));1710 rowsWrapper.className = "identity-rows";1711 const rows = rowsWrapper.appendChild(document.createElement("div"));1712 rows.className = "identity-rows-inner";17131714 function pick(value: string) {1715 inp.value = value;1716 list.style.display = "none";1717 suppressNextFocus = true;1718 inp.focus();1719 }17201721 function render() {1722 const q = inp.value.toLowerCase();1723 const filtered = typed.filter(s => !q || s.value.toLowerCase().includes(q)).slice(0, 8);1724 rows.innerHTML = "";1725 if (!filtered.length) { list.style.display = "none"; return; }1726 for (const s of filtered) {1727 const row = rows.appendChild(document.createElement("button"));1728 row.type = "button"; row.className = "identity-suggest-row";1729 const val = row.appendChild(document.createElement("span"));1730 val.className = "identity-suggest-val"; val.textContent = s.value;1731 const meta = row.appendChild(document.createElement("span"));1732 meta.className = "identity-suggest-meta"; meta.textContent = `${s.useCount}×`;1733 row.addEventListener("mousedown", (e) => { e.preventDefault(); pick(s.value); });1734 row.addEventListener("keydown", (e) => {1735 if (e.key === "ArrowDown") {1736 e.preventDefault();1737 (row.nextElementSibling as HTMLElement | null)?.focus();1738 } else if (e.key === "ArrowUp") {1739 e.preventDefault();1740 const prev = row.previousElementSibling as HTMLElement | null;1741 if (prev) prev.focus();1742 else inp.focus();1743 } else if (e.key === "Enter" || e.key === " ") {1744 e.preventDefault();1745 pick(s.value);1746 } else if (e.key === "Escape") {1747 e.preventDefault();1748 list.style.display = "none";1749 suppressNextFocus = true;1750 inp.focus();1751 }1752 });1753 row.addEventListener("blur", (e) => {1754 const rt = (e as FocusEvent).relatedTarget as Node | null;1755 if (rt && (rt === inp || list.contains(rt))) return;1756 setTimeout(() => { list.style.display = "none"; }, 150);1757 });1758 }1759 list.style.display = "";1760 }17611762 inp.addEventListener("focus", () => {1763 if (suppressNextFocus) { suppressNextFocus = false; return; }1764 render();1765 });1766 inp.addEventListener("input", render);1767 inp.addEventListener("keydown", (e) => {1768 if (list.style.display === "none") return;1769 if (e.key === "ArrowDown" && !collapsed) {1770 e.preventDefault();1771 (rows.firstElementChild as HTMLElement | null)?.focus();1772 } else if (e.key === "Escape") {1773 e.preventDefault();1774 list.style.display = "none";1775 }1776 });1777 inp.addEventListener("blur", (e) => {1778 const rt = (e as FocusEvent).relatedTarget as Node | null;1779 if (rt && list.contains(rt)) return;1780 setTimeout(() => { list.style.display = "none"; }, 150);1781 });1782 }17831784 async function showCreateForm() {1785 currentMode = "create";1786 container.innerHTML = "";17871788 1789 1790 1791 const statusRes = await chrome.runtime.sendMessage({ type: "GET_VAULT_STATUS" }).catch(() => null) as { unlocked?: boolean } | null;1792 if (!statusRes?.unlocked) {1793 renderLocked();1794 return;1795 }17961797 1798 1799 const sitePolicy = detectPasswordPolicy();18001801 1802 1803 let formIdentities: SavedIdentity[] = options.savedIdentities ?? [];1804 if (!formIdentities.length) {1805 try {1806 const idRes = await chrome.runtime.sendMessage({ type: "GET_IDENTITIES" }).catch(() => null) as { ok: boolean; data?: SavedIdentity[] } | null;1807 if (idRes?.ok && Array.isArray(idRes.data)) formIdentities = idRes.data;1808 } catch { }1809 }18101811 const wrap = document.createElement("div");1812 wrap.className = "create-form-wrap";18131814 1815 const head = document.createElement("div"); head.className = "create-head";1816 const backBtn = document.createElement("button"); backBtn.className = "back-btn";1817 backBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="7" height="12" viewBox="0 0 8 14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"><path d="M6 1L1.5 7L6 13"/></svg>`;1818 backBtn.addEventListener("click", () => { currentMode = "list"; renderList(); });1819 const lbl = document.createElement("div"); lbl.className = "create-label"; lbl.textContent = "New entry";1820 head.append(backBtn, lbl);18211822 1823 const body = document.createElement("div"); body.className = "create-body";18241825 function fGroup(label: string): { g: HTMLDivElement; inp: HTMLInputElement } {1826 const g = document.createElement("div"); g.className = "f-group";1827 const l = document.createElement("div"); l.className = "f-label"; l.textContent = label;1828 const inp = document.createElement("input"); inp.className = "f-input";1829 g.append(l, inp); return { g, inp };1830 }18311832 1833 const tg = fGroup("title"); tg.inp.value = sTitle; tg.inp.placeholder = "e.g. Google";1834 body.appendChild(tg.g);18351836 1837 const ug = fGroup("website");1838 ug.inp.className = "f-input url-f"; ug.inp.value = sOrigin; ug.inp.placeholder = "https://";1839 if (loginSubdomain) {1840 const h = document.createElement("div"); h.className = "url-hint";1841 h.textContent = "⊘ Recognized sign-in subdomain"; ug.g.appendChild(h);1842 }1843 body.appendChild(ug.g);18441845 1846 const xg = fGroup("username");1847 xg.inp.value = preUsername && !preUsername.includes("@") ? preUsername : "";1848 xg.inp.placeholder = "johndoe";1849 xg.inp.setAttribute("autocomplete", "off");1850 if (formIdentities.length) attachIdentitySuggestions(xg.g, xg.inp, formIdentities, "username");1851 body.appendChild(xg.g);18521853 1854 const eg = fGroup("email");1855 (eg.inp as HTMLInputElement).type = "email";1856 eg.inp.value = preUsername && preUsername.includes("@") ? preUsername : "";1857 eg.inp.placeholder = "[email protected]";1858 eg.inp.setAttribute("autocomplete", "off");1859 if (formIdentities.length) attachIdentitySuggestions(eg.g, eg.inp, formIdentities, "email");1860 body.appendChild(eg.g);18611862 1863 1864 1865 const pg = fGroup("password");1866 pg.inp.remove(); 1867 let currentPassword = prePassword || "";1868 const smartGen = createSmartGenerator({1869 policy: sitePolicy,1870 initialPassword: prePassword || undefined,1871 onChange: (pw) => { currentPassword = pw; },1872 });1873 pg.g.appendChild(smartGen.root);1874 body.appendChild(pg.g);18751876 1877 const saveBtn = document.createElement("button"); saveBtn.className = "save-btn"; saveBtn.type = "button";1878 saveBtn.textContent = "Save entry";1879 const errEl = document.createElement("div"); errEl.className = "locked-error"; errEl.style.display = "none";1880 function showFormError(msg: string) { errEl.textContent = msg; errEl.style.display = ""; }1881 saveBtn.addEventListener("click", async () => {1882 const title = tg.inp.value.trim();1883 const pw = currentPassword.trim();1884 const username = xg.inp.value.trim();1885 const email = eg.inp.value.trim();1886 if (!title) {1887 tg.inp.style.borderColor = "rgba(220,70,60,0.5)"; tg.inp.focus();1888 showFormError("Entry needs a title");1889 return;1890 }1891 if (!pw) {1892 showFormError("Entry needs a password — tap regen to make one");1893 return;1894 }1895 errEl.style.display = "none";1896 saveBtn.disabled = true; saveBtn.textContent = "Saving…";1897 try {1898 const res = await chrome.runtime.sendMessage({1899 type: "ADD_ENTRY",1900 payload: { title, url: ug.inp.value.trim(), username, email: email || undefined, password: pw, type: "login" },1901 });1902 if ((res as { ok?: boolean }).ok) {1903 1904 1905 options.onFillFields?.(username || email, pw);1906 showSuccess(title);1907 } else {1908 const errMsg = (res as { error?: string }).error === "vault locked"1909 ? "Vault locked — open Peach to save"1910 : "Could not save entry";1911 showFormError(errMsg);1912 saveBtn.disabled = false; saveBtn.textContent = "Save entry";1913 }1914 } catch { showFormError("Could not reach Peach"); saveBtn.disabled = false; saveBtn.textContent = "Save entry"; }1915 });1916 body.appendChild(saveBtn);1917 body.appendChild(errEl);19181919 wrap.append(head, body);1920 container.appendChild(wrap);1921 requestAnimationFrame(() => { tg.inp.focus(); tg.inp.select(); });1922 }19231924 function showSuccess(title: string) {1925 currentMode = "success";1926 container.innerHTML = "";1927 const wrap = document.createElement("div"); wrap.className = "success-wrap";1928 const ring = document.createElement("div"); ring.className = "success-ring";1929 ring.innerHTML = checkSvgStr();1930 const t = document.createElement("div"); t.className = "success-text"; t.textContent = `${title} saved`;1931 const s = document.createElement("div"); s.className = "success-sub"; s.textContent = sOrigin;1932 wrap.append(ring, t, s);1933 container.appendChild(wrap);1934 setTimeout(() => dismiss(), 1600);1935 }19361937 function flashActionBtn(btn: HTMLButtonElement) {1938 btn.classList.add("flashed");1939 setTimeout(() => btn.classList.remove("flashed"), 700);1940 }19411942 function renderSilverPlatter(entry: SelectorEntry) {1943 container.innerHTML = "";1944 searchInput = null;1945 focusedIndex = -1;1946 currentMode = "silver-platter";19471948 const domHdr = document.createElement("div");1949 domHdr.className = "domain-header";1950 const headText = document.createElement("div");1951 headText.className = "domain-header-text";1952 const eyebrow = document.createElement("div");1953 eyebrow.className = "domain-eyebrow";1954 eyebrow.textContent = "Saved for this site";1955 const domName = document.createElement("div");1956 domName.className = "domain-name";1957 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");1958 headText.append(eyebrow, domName);1959 domHdr.appendChild(headText);1960 if (!options.isSignup) {1961 const addBtn = document.createElement("button");1962 addBtn.className = "domain-add-btn";1963 addBtn.type = "button";1964 addBtn.setAttribute("aria-label", "Create new entry");1965 addBtn.title = "Create new entry";1966 addBtn.textContent = "+";1967 addBtn.addEventListener("click", (e) => { e.stopPropagation(); void showCreateForm(); });1968 domHdr.appendChild(addBtn);1969 }1970 container.appendChild(domHdr);19711972 const platter = document.createElement("div");1973 platter.className = "silver-platter";19741975 const titleEl = document.createElement("div");1976 titleEl.className = "sp-title";1977 titleEl.textContent = entry.title;1978 platter.appendChild(titleEl);19791980 if (entry.email) {1981 const emailEl = document.createElement("div");1982 emailEl.className = "sp-identity-row";1983 const emailLbl = document.createElement("span");1984 emailLbl.className = "sp-identity-label";1985 emailLbl.textContent = "email";1986 const emailVal = document.createElement("span");1987 emailVal.className = "sp-username";1988 emailVal.textContent = entry.email;1989 emailEl.append(emailLbl, emailVal);1990 platter.appendChild(emailEl);1991 }19921993 if (entry.username) {1994 const userEl = document.createElement("div");1995 userEl.className = "sp-identity-row";1996 const userLbl = document.createElement("span");1997 userLbl.className = "sp-identity-label";1998 userLbl.textContent = entry.username.includes("@") ? "email" : "username";1999 const userVal = document.createElement("span");2000 userVal.className = "sp-username";2001 userVal.textContent = entry.username;2002 userEl.append(userLbl, userVal);2003 platter.appendChild(userEl);2004 }20052006 const fillBtn = document.createElement("button");2007 fillBtn.className = "sp-fill-btn";2008 fillBtn.type = "button";2009 fillBtn.textContent = "Fill credentials";2010 fillBtn.addEventListener("click", () => {2011 if (fillBtn.disabled) return;2012 fillBtn.disabled = true;2013 fillBtn.classList.add("filled");2014 fillBtn.innerHTML = checkSvgStr();2015 2016 2017 2018 2019 onSelect(entry.id);2020 setTimeout(() => dismiss(), 400);2021 });2022 platter.appendChild(fillBtn);20232024 const actions = document.createElement("div");2025 actions.className = "sp-actions";20262027 if (entry.email) {2028 const copyEmail = document.createElement("button");2029 copyEmail.className = "sp-action-btn";2030 copyEmail.type = "button";2031 copyEmail.title = "Copy email";2032 copyEmail.textContent = "Copy email";2033 copyEmail.addEventListener("click", async (e) => {2034 e.stopPropagation();2035 let alreadyWritten = false;2036 try { await navigator.clipboard.writeText(entry.email!); alreadyWritten = true; } catch {}2037 await chrome.runtime.sendMessage({2038 type: "COPY",2039 payload: { text: entry.email, label: "Email", alreadyWritten },2040 }).catch(() => {});2041 flashActionBtn(copyEmail);2042 });2043 actions.appendChild(copyEmail);2044 }20452046 const copyU = document.createElement("button");2047 copyU.className = "sp-action-btn";2048 copyU.type = "button";2049 const copyULabel = entry.username?.includes("@") ? "Copy email" : "Copy username";2050 copyU.title = copyULabel;2051 copyU.textContent = copyULabel;2052 copyU.disabled = !entry.username;2053 copyU.addEventListener("click", async (e) => {2054 e.stopPropagation();2055 if (!entry.username) return;2056 let alreadyWritten = false;2057 try { await navigator.clipboard.writeText(entry.username); alreadyWritten = true; } catch {}2058 await chrome.runtime.sendMessage({2059 type: "COPY",2060 payload: { text: entry.username, label: entry.username.includes("@") ? "Email" : "Username", alreadyWritten },2061 }).catch(() => {});2062 flashActionBtn(copyU);2063 });2064 actions.appendChild(copyU);20652066 const copyP = document.createElement("button");2067 copyP.className = "sp-action-btn";2068 copyP.type = "button";2069 copyP.title = "Copy password";2070 copyP.textContent = "Copy password";2071 copyP.addEventListener("click", async (e) => {2072 e.stopPropagation();2073 const resp = await chrome.runtime.sendMessage({2074 type: "GET_ENTRY_FOR_FILL",2075 payload: { id: entry.id },2076 }).catch(() => null) as { ok: boolean; data?: { password?: string } } | null;2077 if (!resp?.ok || !resp.data?.password) return;2078 let alreadyWritten = false;2079 try { await navigator.clipboard.writeText(resp.data.password); alreadyWritten = true; } catch {}2080 await chrome.runtime.sendMessage({2081 type: "COPY",2082 payload: { text: resp.data.password, label: "Password", alreadyWritten },2083 }).catch(() => {});2084 flashActionBtn(copyP);2085 });2086 actions.appendChild(copyP);20872088 let trayEl: HTMLDivElement | null = null;2089 let trayInterval: ReturnType<typeof setInterval> | null = null;20902091 function closeTray() {2092 if (trayInterval) { clearInterval(trayInterval); trayInterval = null; }2093 trayEl?.remove();2094 trayEl = null;2095 }2096 2097 2098 cleanupHooks.push(closeTray);20992100 async function openTOTPTray() {2101 2102 2103 2104 const resp = await chrome.runtime.sendMessage({2105 type: "GET_ENTRY_FOR_FILL",2106 payload: { id: entry.id },2107 }).catch(() => null) as { ok: boolean; data?: { totp?: string } } | null;2108 const secret = resp?.ok ? resp.data?.totp : undefined;2109 if (!secret) return;21102111 trayEl = document.createElement("div");2112 trayEl.className = "sp-tray";21132114 const label = document.createElement("span");2115 label.className = "sp-tray-label";2116 label.textContent = "2FA";2117 trayEl.appendChild(label);21182119 const codeEl = document.createElement("div");2120 codeEl.className = "sp-totp-code";2121 trayEl.appendChild(codeEl);21222123 const ringNs = "http://www.w3.org/2000/svg";2124 const ring = document.createElementNS(ringNs, "svg");2125 ring.setAttribute("class", "sp-totp-ring");2126 ring.setAttribute("viewBox", "0 0 24 24");2127 const trackC = document.createElementNS(ringNs, "circle");2128 trackC.setAttribute("class", "ring-track");2129 trackC.setAttribute("cx", "12"); trackC.setAttribute("cy", "12"); trackC.setAttribute("r", "10");2130 trackC.setAttribute("fill", "none"); trackC.setAttribute("stroke-width", "2");2131 const fillC = document.createElementNS(ringNs, "circle");2132 fillC.setAttribute("class", "ring-fill");2133 fillC.setAttribute("cx", "12"); fillC.setAttribute("cy", "12"); fillC.setAttribute("r", "10");2134 fillC.setAttribute("fill", "none"); fillC.setAttribute("stroke-width", "2");2135 fillC.setAttribute("stroke-linecap", "round");2136 fillC.setAttribute("stroke-dasharray", "62.83");2137 ring.append(trackC, fillC);2138 trayEl.appendChild(ring);21392140 const copyBtn = document.createElement("button");2141 copyBtn.className = "sp-totp-copy";2142 copyBtn.type = "button";2143 copyBtn.textContent = "Copy";2144 trayEl.appendChild(copyBtn);21452146 function refresh() {2147 const { code, remaining } = generateTOTP(secret!);2148 2149 codeEl.textContent = code.length === 62150 ? `${code.slice(0, 3)} ${code.slice(3)}`2151 : code;2152 2153 2154 const fraction = (30 - remaining) / 30;2155 fillC.setAttribute("stroke-dashoffset", String(62.83 * fraction));2156 }2157 refresh();2158 trayInterval = setInterval(refresh, 1000);21592160 copyBtn.addEventListener("click", async (e) => {2161 e.stopPropagation();2162 const { code } = generateTOTP(secret!);2163 let alreadyWritten = false;2164 try { await navigator.clipboard.writeText(code); alreadyWritten = true; } catch {}2165 await chrome.runtime.sendMessage({2166 type: "COPY",2167 payload: { text: code, label: "TOTP", alreadyWritten },2168 }).catch(() => {});2169 copyBtn.textContent = "Copied";2170 setTimeout(() => { if (copyBtn.isConnected) copyBtn.textContent = "Copy"; }, 1200);2171 });21722173 platter.appendChild(trayEl);2174 }21752176 const editBtn = document.createElement("button");2177 editBtn.className = "sp-action-btn sp-action-edit";2178 editBtn.type = "button";2179 editBtn.title = "Edit entry";2180 editBtn.textContent = "Edit";2181 editBtn.addEventListener("click", (e) => {2182 e.stopPropagation();2183 closeTray();2184 void renderInlineEdit(entry);2185 });2186 actions.appendChild(editBtn);21872188 2189 2190 2191 if (entry.hasTotp) void openTOTPTray();21922193 platter.appendChild(actions);2194 container.appendChild(platter);2195 }21962197 219821992200220122022203 async function renderInlineEdit(summary: SelectorEntry) {2204 container.innerHTML = "";2205 const wrap = document.createElement("div");2206 wrap.className = "create-form-wrap";22072208 const head = document.createElement("div");2209 head.className = "create-head";2210 const back = document.createElement("button");2211 back.className = "back-btn";2212 back.type = "button";2213 back.title = "Cancel";2214 back.innerHTML = `<svg width="11" height="11" viewBox="0 0 11 11" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"><path d="M7 2L3 5.5L7 9"/></svg>`;2215 back.addEventListener("click", () => renderSilverPlatter(summary));2216 head.appendChild(back);2217 const headLbl = document.createElement("div");2218 headLbl.className = "create-label";2219 headLbl.textContent = "Edit entry";2220 head.appendChild(headLbl);2221 wrap.appendChild(head);22222223 const body = document.createElement("div");2224 body.className = "create-body";22252226 2227 const loading = document.createElement("div");2228 loading.className = "empty-hint";2229 loading.textContent = "loading…";2230 body.appendChild(loading);2231 wrap.appendChild(body);2232 container.appendChild(wrap);22332234 const [res, idRes] = await Promise.all([2235 chrome.runtime.sendMessage({2236 type: "GET_ENTRY_FOR_FILL",2237 payload: { id: summary.id },2238 }).catch(() => null),2239 chrome.runtime.sendMessage({ type: "GET_IDENTITIES" }).catch(() => null),2240 ]);2241 const entryRes = res as { ok: boolean; data?: { title?: string; username?: string; email?: string; password?: string; url?: string; totp?: string; notes?: string } } | null;2242 const editIdentities: SavedIdentity[] = (idRes as { ok?: boolean; data?: SavedIdentity[] } | null)?.data ?? [];22432244 if (!entryRes || !entryRes.ok || !entryRes.data) {2245 loading.textContent = "couldn't load this entry. try again from the popup.";2246 return;2247 }2248 body.innerHTML = "";22492250 function field(label: string, value: string, type: "text" | "password" = "text"): { g: HTMLDivElement; inp: HTMLInputElement } {2251 const group = document.createElement("div");2252 group.className = "f-group";2253 const lbl = document.createElement("div");2254 lbl.className = "f-label";2255 lbl.textContent = label;2256 const input = document.createElement("input");2257 input.className = "f-input";2258 input.type = type;2259 input.value = value;2260 input.autocomplete = "off";2261 group.append(lbl, input);2262 body.appendChild(group);2263 return { g: group, inp: input };2264 }22652266 const titleInput = field("title", entryRes.data.title ?? "").inp;2267 const urlInput = field("url", entryRes.data.url ?? "").inp;2268 urlInput.classList.add("url-f");2269 const usernameLabel = (entryRes.data.username ?? "").includes("@") ? "email" : "username";2270 const { g: usernameGroup, inp: usernameInput } = field(usernameLabel, entryRes.data.username ?? "");2271 if (editIdentities.length) attachIdentitySuggestions(usernameGroup, usernameInput, editIdentities, "username");2272 const { g: emailGroup, inp: emailInput } = field("email", entryRes.data.email ?? "");2273 if (editIdentities.length) attachIdentitySuggestions(emailGroup, emailInput, editIdentities, "email");22742275 2276 const pwGroup = document.createElement("div");2277 pwGroup.className = "f-group";2278 const pwLbl = document.createElement("div");2279 pwLbl.className = "f-label";2280 pwLbl.textContent = "password";2281 const pwRow = document.createElement("div");2282 pwRow.className = "f-row";2283 const pwInput = document.createElement("input");2284 pwInput.className = "f-input";2285 pwInput.type = "password";2286 pwInput.value = entryRes.data.password ?? "";2287 pwInput.autocomplete = "new-password";2288 const revealBtn = document.createElement("button");2289 revealBtn.className = "gen-btn";2290 revealBtn.type = "button";2291 revealBtn.textContent = "show";2292 revealBtn.addEventListener("click", () => {2293 const reveal = pwInput.type === "password";2294 pwInput.type = reveal ? "text" : "password";2295 revealBtn.textContent = reveal ? "hide" : "show";2296 });2297 pwRow.append(pwInput, revealBtn);2298 const editSmartGen = createSmartGenerator({ policy: detectPasswordPolicy(), onChange: (pw) => { pwInput.value = pw; } });2299 editSmartGen.root.style.display = "none";2300 let editGenVisible = false;2301 const genToggleBtn = document.createElement("button");2302 genToggleBtn.className = "gen-toggle-link";2303 genToggleBtn.type = "button";2304 genToggleBtn.textContent = "⚙ generate";2305 genToggleBtn.addEventListener("click", () => {2306 editGenVisible = !editGenVisible;2307 pwRow.style.display = editGenVisible ? "none" : "";2308 editSmartGen.root.style.display = editGenVisible ? "" : "none";2309 genToggleBtn.textContent = editGenVisible ? "☰ hide generator" : "⚙ generate";2310 });2311 pwGroup.append(pwLbl, pwRow, genToggleBtn, editSmartGen.root);2312 body.appendChild(pwGroup);23132314 const totpInput = field("2fa secret", entryRes.data.totp ?? "").inp;23152316 2317 const notesGroup = document.createElement("div");2318 notesGroup.className = "f-group";2319 const notesLbl = document.createElement("div");2320 notesLbl.className = "f-label";2321 notesLbl.textContent = "notes";2322 const notesInput = document.createElement("textarea");2323 notesInput.className = "f-input";2324 notesInput.rows = 3;2325 notesInput.value = entryRes.data.notes ?? "";2326 notesInput.style.fontFamily = "Inter, sans-serif";2327 notesInput.style.resize = "vertical";2328 notesGroup.append(notesLbl, notesInput);2329 body.appendChild(notesGroup);23302331 2332 const actionsRow = document.createElement("div");2333 actionsRow.className = "f-row";2334 const saveBtn = document.createElement("button");2335 saveBtn.className = "save-btn";2336 saveBtn.type = "button";2337 saveBtn.textContent = "Save changes";2338 saveBtn.style.flex = "1";2339 const cancelBtn = document.createElement("button");2340 cancelBtn.className = "gen-btn";2341 cancelBtn.type = "button";2342 cancelBtn.textContent = "cancel";2343 cancelBtn.addEventListener("click", () => renderSilverPlatter(summary));2344 actionsRow.append(saveBtn, cancelBtn);2345 body.appendChild(actionsRow);23462347 saveBtn.addEventListener("click", async () => {2348 saveBtn.disabled = true;2349 const originalLabel = saveBtn.textContent;2350 saveBtn.textContent = "Saving…";2351 const patch: Record<string, unknown> = {2352 title: titleInput.value.trim(),2353 url: urlInput.value.trim(),2354 username: usernameInput.value.trim(),2355 email: emailInput.value.trim() || undefined,2356 password: pwInput.value,2357 totp: totpInput.value.trim(),2358 notes: notesInput.value,2359 };2360 const updateRes = (await chrome.runtime.sendMessage({2361 type: "UPDATE_ENTRY",2362 payload: { id: summary.id, patch },2363 }).catch(() => null)) as { ok: boolean; error?: string } | null;2364 if (!updateRes?.ok) {2365 saveBtn.disabled = false;2366 saveBtn.textContent = originalLabel;2367 const err = document.createElement("div");2368 err.className = "empty-hint";2369 err.style.color = "color-mix(in srgb, #e55 70%, transparent)";2370 err.textContent = updateRes?.error ?? "Couldn't save. Try the popup.";2371 body.appendChild(err);2372 setTimeout(() => err.remove(), 3000);2373 return;2374 }2375 2376 const refreshed: SelectorEntry = {2377 id: summary.id,2378 title: patch.title as string,2379 username: patch.username as string,2380 email: patch.email as string | undefined,2381 url: patch.url as string,2382 hasTotp: Boolean(patch.totp),2383 hasPasskey: summary.hasPasskey,2384 };2385 renderSilverPlatter(refreshed);2386 });23872388 queueMicrotask(() => titleInput.focus());2389 }23902391 function renderLocked() {2392 container.innerHTML = "";23932394 2395 const domHdr = document.createElement("div");2396 domHdr.className = "domain-header";2397 const eyebrow = document.createElement("div");2398 eyebrow.className = "domain-eyebrow";2399 eyebrow.textContent = "vault locked";2400 const domName = document.createElement("div");2401 domName.className = "domain-name";2402 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");2403 domHdr.append(eyebrow, domName);2404 container.appendChild(domHdr);24052406 const wrap = document.createElement("div");2407 wrap.className = "locked-wrap";24082409 2410 const head = document.createElement("div"); head.className = "locked-head";2411 const icon = document.createElement("div"); icon.className = "locked-icon";2412 icon.innerHTML = keySvgStr();2413 const title = document.createElement("div"); title.className = "locked-title";2414 title.textContent = "unlock to autofill";2415 head.append(icon, title);24162417 2418 const pwInp = document.createElement("input");2419 pwInp.className = "locked-input";2420 pwInp.type = "password";2421 pwInp.placeholder = "master password";2422 pwInp.setAttribute("autocomplete", "current-password");24232424 2425 const errEl = document.createElement("div");2426 errEl.className = "locked-error";2427 errEl.style.display = "none";24282429 2430 const unlockBtn = document.createElement("button");2431 unlockBtn.className = "locked-btn";2432 unlockBtn.type = "button";2433 unlockBtn.textContent = "unlock";24342435 async function tryUnlock() {2436 const pw = pwInp.value.trim();2437 if (!pw) { pwInp.focus(); return; }2438 unlockBtn.disabled = true;2439 unlockBtn.textContent = "unlocking…";2440 errEl.style.display = "none";2441 try {2442 const res = await chrome.runtime.sendMessage({2443 type: "UNLOCK",2444 payload: { password: pw },2445 });2446 if ((res as { ok?: boolean }).ok) {2447 dismiss();2448 options.onUnlocked?.();2449 } else {2450 errEl.textContent = "incorrect password";2451 errEl.style.display = "block";2452 pwInp.value = "";2453 pwInp.focus();2454 unlockBtn.disabled = false;2455 unlockBtn.textContent = "unlock";2456 }2457 } catch {2458 errEl.textContent = "could not reach Peach";2459 errEl.style.display = "block";2460 unlockBtn.disabled = false;2461 unlockBtn.textContent = "unlock";2462 }2463 }24642465 pwInp.addEventListener("keydown", (e) => {2466 e.stopPropagation();2467 if (e.key === "Enter") void tryUnlock();2468 });2469 pwInp.addEventListener("keyup", (e) => e.stopPropagation());2470 pwInp.addEventListener("keypress", (e) => e.stopPropagation());2471 unlockBtn.addEventListener("click", () => void tryUnlock());24722473 wrap.append(head, pwInp, errEl, unlockBtn);2474 container.appendChild(wrap);24752476 2477 2478 2479 2480 2481 const keepaliveId = setInterval(() => {2482 chrome.runtime.sendMessage({ type: "TOUCH_AUTO_LOCK" }).catch(() => {});2483 }, 20_000);2484 cleanupHooks.push(() => clearInterval(keepaliveId));24852486 2487 2488 2489 2490 2491 2492 const captureKeydown = (e: KeyboardEvent) => {2493 if (!host.isConnected) {2494 document.removeEventListener("keydown", captureKeydown, true);2495 return;2496 }2497 2498 if (e.ctrlKey || e.metaKey || e.altKey || e.key === "Tab") return;2499 2500 e.stopImmediatePropagation();2501 if (e.key === "Escape") { dismiss(true); return; }2502 if (e.key === "Enter") { void tryUnlock(); return; }2503 2504 2505 if (document.activeElement !== host) {2506 pwInp.focus({ preventScroll: true });2507 }2508 };2509 captureKeydownRef = captureKeydown;2510 document.addEventListener("keydown", captureKeydown, true);25112512 2513 2514 pwInp.focus({ preventScroll: true });2515 requestAnimationFrame(() => { if (host.isConnected) pwInp.focus({ preventScroll: true }); });2516 }25172518 function handleKeyDown(e: KeyboardEvent) {2519 if (options.locked) {2520 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }2521 return;2522 }2523 if (currentMode === "create" || currentMode === "success" || currentMode === "silver-platter") {2524 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }2525 return;2526 }2527 const allEntryEls = container.querySelectorAll(".entry:not(.empty-state)");2528 const count = allEntryEls.length;2529 if (document.activeElement === searchInput) {2530 if (e.key === "Escape" || e.key === "Tab") { e.preventDefault(); dismiss(true); return; }2531 if (count === 0) return;2532 if (!["ArrowDown", "ArrowUp", "Enter"].includes(e.key)) return;2533 }2534 if (count === 0) return;2535 switch (e.key) {2536 case "ArrowDown": e.preventDefault(); setFocused(focusedIndex < count - 1 ? focusedIndex + 1 : 0); break;2537 case "ArrowUp": e.preventDefault(); setFocused(focusedIndex > 0 ? focusedIndex - 1 : count - 1); break;2538 case "Enter": {2539 if (focusedIndex >= 0) {2540 const el = allEntryEls[focusedIndex] as HTMLElement;2541 const id = el.dataset.id;2542 if (id) { onSelect(id); dismiss(); }2543 else if (el.classList.contains("is-new") || !id) {2544 2545 showCreateForm();2546 }2547 }2548 break;2549 }2550 case "Escape": case "Tab": e.preventDefault(); dismiss(true); break;2551 }2552 }25532554 document.addEventListener("keydown", handleKeyDown);25552556 document.body.appendChild(host);25572558 function updatePosition() {2559 const r = anchorEl.getBoundingClientRect();2560 host.style.top = `${r.bottom + window.scrollY + 5}px`;2561 host.style.left = `${r.left + window.scrollX}px`;2562 host.style.width = `${popupWidth}px`;2563 }2564 2565 2566 2567 2568 2569 2570 2571 let captureKeydownRef: ((e: KeyboardEvent) => void) | null = null;2572 const stopObserving = observeAnchorPosition(anchorEl, updatePosition);25732574 if (options.locked) {2575 renderLocked();2576 } else if (options.isSignup && options.savedIdentities) {2577 2578 2579 renderIdentityHelper();2580 } else if (entries.length === 1 && !options.isSignup) {2581 2582 2583 renderSilverPlatter(entries[0]!);2584 } else {2585 renderList();2586 }25872588 let exitScheduled = false;2589 function dismiss(userAction = false) {2590 2591 2592 2593 if (exitScheduled) return;2594 exitScheduled = true;2595 2596 2597 2598 stopObserving();2599 document.removeEventListener("click", outsideClick, { capture: true });2600 document.removeEventListener("keydown", handleKeyDown);2601 if (captureKeydownRef) {2602 document.removeEventListener("keydown", captureKeydownRef, true);2603 captureKeydownRef = null;2604 }2605 for (const cleanup of cleanupHooks) {2606 try { cleanup(); } catch { }2607 }2608 if (userAction) options.onDismiss?.();2609 container.classList.add("is-exiting");2610 setTimeout(() => host.remove(), 130);2611 }26122613 function outsideClick(ev: MouseEvent) {2614 const path = ev.composedPath();2615 2616 2617 2618 if (!path.includes(host) && !path.includes(anchorEl)) dismiss(true);2619 }2620 2621 setTimeout(() => document.addEventListener("click", outsideClick, { capture: true }), 0);26222623 return dismiss;2624}26252626export interface CardSelectorEntry {2627 id: string;2628 title: string;2629 cardholderName?: string;2630 last4?: string;2631 expMonth?: string;2632 expYear?: string;2633 network?: import("../shared/types").CardNetwork;2634}26352636interface CardSelectorOptions {2637 domain?: string;2638 2639 onFill: (entry: import("../shared/types").VaultEntry) => void;2640 2641 onDismiss?: () => void;2642}26432644264526462647264826492650export function showPasskeyProGate(): void {2651 const domain = location.hostname.replace(/^www\./, "");26522653 const host = document.createElement("div");2654 host.setAttribute("data-peach-passkey-gate", "1");2655 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483646;pointer-events:none;";2656 const shadow = host.attachShadow({ mode: "closed" });26572658 const style = document.createElement("style");2659 style.textContent = `2660 :host { all: initial; }2661 .gate-wrap {2662 position: fixed;2663 top: 50%;2664 left: 50%;2665 transform: translate(-50%, -50%);2666 width: 280px;2667 pointer-events: auto;2668 animation: g-in 220ms cubic-bezier(0.16,1,0.3,1) both;2669 }2670 @keyframes g-in {2671 from { opacity:0; transform: translate(-50%,-52%); }2672 to { opacity:1; transform: translate(-50%,-50%); }2673 }2674 .gate-wrap.is-exiting {2675 animation: g-out 130ms ease-in forwards;2676 }2677 @keyframes g-out {2678 to { opacity:0; transform: translate(-50%,-52%); }2679 }2680 .gate {2681 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};2682 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};2683 border-radius: 12px;2684 box-shadow: 0 12px 48px rgba(0,0,0,0.75);2685 padding: 16px;2686 font-family: Inter, sans-serif;2687 }2688 .gate-header {2689 display: flex;2690 align-items: center;2691 gap: 7px;2692 margin-bottom: 12px;2693 padding-bottom: 10px;2694 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};2695 }2696 .gate-domain {2697 font-size: 12px;2698 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};2699 font-family: "IBM Plex Mono", monospace;2700 overflow: hidden;2701 text-overflow: ellipsis;2702 white-space: nowrap;2703 }2704 .gate-title {2705 font-size: 14px;2706 font-weight: 500;2707 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};2708 margin-bottom: 6px;2709 }2710 .gate-subtitle {2711 font-size: 12px;2712 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.45)"};2713 line-height: 1.5;2714 margin-bottom: 14px;2715 }2716 .gate-btn {2717 display: block;2718 width: 100%;2719 padding: 9px 0;2720 border-radius: 8px;2721 border: none;2722 cursor: pointer;2723 font-size: 13px;2724 font-family: Inter, sans-serif;2725 font-weight: 500;2726 transition: opacity 100ms;2727 margin-bottom: 7px;2728 text-align: center;2729 }2730 .gate-btn:last-child { margin-bottom: 0; }2731 .gate-btn--accent {2732 background: ${accentHex};2733 color: #fff;2734 }2735 .gate-btn--accent:hover { opacity: 0.88; }2736 .gate-btn--ghost {2737 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};2738 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.45)"};2739 }2740 .gate-btn--ghost:hover { opacity: 0.75; }2741 .backdrop {2742 position: fixed;2743 inset: 0;2744 pointer-events: auto;2745 }2746 `;2747 shadow.appendChild(style);27482749 const backdrop = document.createElement("div");2750 backdrop.className = "backdrop";2751 shadow.appendChild(backdrop);27522753 const wrap = document.createElement("div");2754 wrap.className = "gate-wrap";2755 shadow.appendChild(wrap);27562757 const gate = document.createElement("div");2758 gate.className = "gate";2759 wrap.appendChild(gate);27602761 2762 const header = document.createElement("div");2763 header.className = "gate-header";2764 const icon = document.createElement("span");2765 icon.innerHTML = peachIconSvg();2766 const domainEl = document.createElement("span");2767 domainEl.className = "gate-domain";2768 domainEl.textContent = domain;2769 header.append(icon, domainEl);2770 gate.appendChild(header);27712772 const title = document.createElement("div");2773 title.className = "gate-title";2774 title.textContent = "Passkeys are part of Peach Pro.";2775 gate.appendChild(title);27762777 const subtitle = document.createElement("div");2778 subtitle.className = "gate-subtitle";2779 subtitle.textContent = "Store and use passkeys across all your devices, securely.";2780 gate.appendChild(subtitle);27812782 const upgradeBtn = document.createElement("button");2783 upgradeBtn.className = "gate-btn gate-btn--accent";2784 upgradeBtn.type = "button";2785 upgradeBtn.textContent = "Upgrade to Pro";2786 gate.appendChild(upgradeBtn);27872788 const laterBtn = document.createElement("button");2789 laterBtn.className = "gate-btn gate-btn--ghost";2790 laterBtn.type = "button";2791 laterBtn.textContent = "Not right now";2792 gate.appendChild(laterBtn);27932794 function dismiss() {2795 wrap.classList.add("is-exiting");2796 setTimeout(() => host.remove(), 130);2797 }27982799 upgradeBtn.addEventListener("click", () => {2800 chrome.runtime.sendMessage({ type: "OPEN_PRO_GATE", payload: { feature: "passkeys" } }).catch(() => {});2801 dismiss();2802 });2803 laterBtn.addEventListener("click", dismiss);2804 backdrop.addEventListener("click", dismiss);28052806 document.addEventListener("keydown", function onEsc(e: KeyboardEvent) {2807 if (e.key === "Escape") { dismiss(); document.removeEventListener("keydown", onEsc); }2808 });28092810 document.body.appendChild(host);2811}281228132814281528162817281828192820export function showPasskeyRegistrationOffer(args: {2821 rpId: string;2822 rpName?: string;2823 userName?: string;2824 userDisplayName?: string;2825}): void {2826 const domain = location.hostname.replace(/^www\./, "");2827 const displayName = args.rpName || domain;28282829 const host = document.createElement("div");2830 host.setAttribute("data-peach-passkey-offer", "1");2831 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483645;pointer-events:none;";2832 const shadow = host.attachShadow({ mode: "closed" });28332834 const style = document.createElement("style");2835 style.textContent = `2836 :host { all: initial; }2837 .offer-wrap {2838 position: fixed;2839 top: 16px;2840 right: 16px;2841 width: 320px;2842 pointer-events: auto;2843 animation: o-in 220ms cubic-bezier(0.16,1,0.3,1) both;2844 }2845 @keyframes o-in {2846 from { opacity: 0; transform: translateY(-6px); }2847 to { opacity: 1; transform: translateY(0); }2848 }2849 .offer-wrap.is-exiting { animation: o-out 130ms ease-in forwards; }2850 @keyframes o-out { to { opacity: 0; transform: translateY(-6px); } }2851 .offer {2852 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};2853 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};2854 border-radius: 12px;2855 box-shadow: 0 12px 48px rgba(0,0,0,0.55);2856 padding: 14px 14px 12px;2857 font-family: Inter, sans-serif;2858 position: relative;2859 }2860 .offer-close {2861 position: absolute;2862 top: 8px;2863 right: 8px;2864 width: 18px;2865 height: 18px;2866 border: none;2867 background: transparent;2868 color: ${popupTheme === "light" ? "rgba(0,0,0,0.4)" : "rgba(240,232,216,0.4)"};2869 cursor: pointer;2870 font-size: 14px;2871 line-height: 1;2872 padding: 0;2873 }2874 .offer-close:hover { color: ${popupTheme === "light" ? "rgba(0,0,0,0.7)" : "rgba(240,232,216,0.7)"}; }2875 .offer-header {2876 display: flex;2877 align-items: center;2878 gap: 7px;2879 margin-bottom: 8px;2880 padding-bottom: 8px;2881 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};2882 }2883 .offer-domain {2884 font-size: 12px;2885 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};2886 font-family: "IBM Plex Mono", monospace;2887 overflow: hidden;2888 text-overflow: ellipsis;2889 white-space: nowrap;2890 }2891 .offer-title {2892 font-size: 13px;2893 font-weight: 500;2894 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};2895 margin-bottom: 4px;2896 }2897 .offer-subtitle {2898 font-size: 11px;2899 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.50)"};2900 line-height: 1.45;2901 margin-bottom: 12px;2902 }2903 .offer-btn {2904 display: block;2905 width: 100%;2906 padding: 8px 0;2907 border-radius: 7px;2908 border: none;2909 cursor: pointer;2910 font-size: 12px;2911 font-family: Inter, sans-serif;2912 font-weight: 500;2913 transition: opacity 100ms;2914 margin-bottom: 6px;2915 text-align: center;2916 }2917 .offer-btn:last-child { margin-bottom: 0; }2918 .offer-btn--accent { background: ${accentHex}; color: #fff; }2919 .offer-btn--accent:hover { opacity: 0.88; }2920 .offer-btn--ghost {2921 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};2922 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.50)"};2923 }2924 .offer-btn--ghost:hover { opacity: 0.75; }2925 `;2926 shadow.appendChild(style);29272928 const wrap = document.createElement("div");2929 wrap.className = "offer-wrap";2930 shadow.appendChild(wrap);29312932 const offer = document.createElement("div");2933 offer.className = "offer";2934 wrap.appendChild(offer);29352936 const closeBtn = document.createElement("button");2937 closeBtn.className = "offer-close";2938 closeBtn.type = "button";2939 closeBtn.setAttribute("aria-label", "Dismiss");2940 closeBtn.textContent = "✕";2941 offer.appendChild(closeBtn);29422943 const header = document.createElement("div");2944 header.className = "offer-header";2945 const icon = document.createElement("span");2946 icon.innerHTML = peachIconSvg();2947 const domainEl = document.createElement("span");2948 domainEl.className = "offer-domain";2949 domainEl.textContent = domain;2950 header.append(icon, domainEl);2951 offer.appendChild(header);29522953 const title = document.createElement("div");2954 title.className = "offer-title";2955 title.textContent = "This site supports passkeys.";2956 offer.appendChild(title);29572958 const subtitle = document.createElement("div");2959 subtitle.className = "offer-subtitle";2960 subtitle.textContent = "Save one to Peach for faster, passwordless sign-in.";2961 offer.appendChild(subtitle);29622963 const saveBtn = document.createElement("button");2964 saveBtn.className = "offer-btn offer-btn--accent";2965 saveBtn.type = "button";2966 saveBtn.textContent = "Save passkey to Peach";2967 offer.appendChild(saveBtn);29682969 const laterBtn = document.createElement("button");2970 laterBtn.className = "offer-btn offer-btn--ghost";2971 laterBtn.type = "button";2972 laterBtn.textContent = "Not now";2973 offer.appendChild(laterBtn);29742975 function dismiss(decline: boolean) {2976 if (decline) {2977 chrome.runtime.sendMessage({2978 type: "PASSKEY_OFFER_DECLINE",2979 payload: { domain },2980 }).catch(() => {});2981 }2982 wrap.classList.add("is-exiting");2983 setTimeout(() => host.remove(), 130);2984 }29852986 saveBtn.addEventListener("click", () => {2987 chrome.runtime.sendMessage({2988 type: "INITIATE_FIREFOX_PASSKEY_CREATE",2989 payload: {2990 rpId: args.rpId,2991 rpName: args.rpName ?? displayName,2992 userName: args.userName ?? "user",2993 userDisplayName: args.userDisplayName,2994 },2995 }).catch(() => {});2996 dismiss(false);2997 });2998 laterBtn.addEventListener("click", () => dismiss(true));2999 closeBtn.addEventListener("click", () => dismiss(true));30003001 document.body.appendChild(host);3002}3003300430053006300730083009301030113012export function showPasskeyAvailable(args: {3013 rpId: string;3014 userName: string;3015 fromBrowser?: "chrome" | "firefox";3016 currentBrowser?: "chrome" | "firefox" | "unknown";3017}): void {3018 const domain = location.hostname.replace(/^www\./, "");3019 const crossBrowser =3020 args.fromBrowser &&3021 args.currentBrowser &&3022 args.currentBrowser !== "unknown" &&3023 args.fromBrowser !== args.currentBrowser;30243025 const host = document.createElement("div");3026 host.setAttribute("data-peach-passkey-available", "1");3027 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483644;pointer-events:none;";3028 const shadow = host.attachShadow({ mode: "closed" });30293030 const style = document.createElement("style");3031 style.textContent = `3032 :host { all: initial; }3033 .avail-wrap {3034 position: fixed;3035 top: 16px;3036 right: 16px;3037 width: 320px;3038 pointer-events: auto;3039 animation: a-in 220ms cubic-bezier(0.16,1,0.3,1) both;3040 }3041 @keyframes a-in {3042 from { opacity: 0; transform: translateY(-6px); }3043 to { opacity: 1; transform: translateY(0); }3044 }3045 .avail-wrap.is-exiting { animation: a-out 130ms ease-in forwards; }3046 @keyframes a-out { to { opacity: 0; transform: translateY(-6px); } }3047 .avail {3048 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};3049 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};3050 border-radius: 12px;3051 box-shadow: 0 12px 48px rgba(0,0,0,0.55);3052 padding: 14px 14px 12px;3053 font-family: Inter, sans-serif;3054 position: relative;3055 }3056 .avail-close {3057 position: absolute;3058 top: 8px;3059 right: 8px;3060 width: 18px;3061 height: 18px;3062 border: none;3063 background: transparent;3064 color: ${popupTheme === "light" ? "rgba(0,0,0,0.4)" : "rgba(240,232,216,0.4)"};3065 cursor: pointer;3066 font-size: 14px;3067 line-height: 1;3068 padding: 0;3069 }3070 .avail-close:hover { color: ${popupTheme === "light" ? "rgba(0,0,0,0.7)" : "rgba(240,232,216,0.7)"}; }3071 .avail-header {3072 display: flex;3073 align-items: center;3074 gap: 7px;3075 margin-bottom: 8px;3076 padding-bottom: 8px;3077 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};3078 }3079 .avail-domain {3080 font-size: 12px;3081 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};3082 font-family: "IBM Plex Mono", monospace;3083 }3084 .avail-label {3085 font-size: 9px;3086 letter-spacing: 0.16em;3087 text-transform: uppercase;3088 color: ${accentHex};3089 margin-bottom: 4px;3090 }3091 .avail-user {3092 font-size: 13px;3093 font-weight: 500;3094 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};3095 margin-bottom: 12px;3096 overflow: hidden;3097 text-overflow: ellipsis;3098 white-space: nowrap;3099 }3100 .avail-cross {3101 font-size: 11px;3102 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.50)"};3103 line-height: 1.45;3104 margin-bottom: 12px;3105 padding: 8px;3106 background: ${popupTheme === "light" ? "rgba(0,0,0,0.04)" : "rgba(240,232,216,0.04)"};3107 border-radius: 6px;3108 }3109 .avail-btn {3110 display: block;3111 width: 100%;3112 padding: 8px 0;3113 border-radius: 7px;3114 border: none;3115 cursor: pointer;3116 font-size: 12px;3117 font-family: Inter, sans-serif;3118 font-weight: 500;3119 transition: opacity 100ms;3120 margin-bottom: 6px;3121 text-align: center;3122 }3123 .avail-btn:last-child { margin-bottom: 0; }3124 .avail-btn--accent { background: ${accentHex}; color: #fff; }3125 .avail-btn--accent:hover { opacity: 0.88; }3126 .avail-btn--ghost {3127 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};3128 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.50)"};3129 }3130 .avail-btn--ghost:hover { opacity: 0.75; }3131 `;3132 shadow.appendChild(style);31333134 const wrap = document.createElement("div");3135 wrap.className = "avail-wrap";3136 shadow.appendChild(wrap);31373138 const avail = document.createElement("div");3139 avail.className = "avail";3140 wrap.appendChild(avail);31413142 const closeBtn = document.createElement("button");3143 closeBtn.className = "avail-close";3144 closeBtn.type = "button";3145 closeBtn.setAttribute("aria-label", "Dismiss");3146 closeBtn.textContent = "✕";3147 avail.appendChild(closeBtn);31483149 const header = document.createElement("div");3150 header.className = "avail-header";3151 const icon = document.createElement("span");3152 icon.innerHTML = peachIconSvg();3153 const domainEl = document.createElement("span");3154 domainEl.className = "avail-domain";3155 domainEl.textContent = domain;3156 header.append(icon, domainEl);3157 avail.appendChild(header);31583159 const label = document.createElement("div");3160 label.className = "avail-label";3161 label.textContent = "PASSKEY";3162 avail.appendChild(label);31633164 const user = document.createElement("div");3165 user.className = "avail-user";3166 user.textContent = args.userName;3167 avail.appendChild(user);31683169 if (crossBrowser) {3170 const cross = document.createElement("div");3171 cross.className = "avail-cross";3172 cross.textContent =3173 args.fromBrowser === "chrome"3174 ? "This passkey was created on Chrome. To use it on Firefox, re-register it on this device."3175 : "This passkey was created on Firefox. To use it on Chrome, re-register it on this device.";3176 avail.appendChild(cross);3177 }31783179 const signInBtn = document.createElement("button");3180 signInBtn.className = "avail-btn avail-btn--accent";3181 signInBtn.type = "button";3182 signInBtn.textContent = "Sign in with passkey";3183 avail.appendChild(signInBtn);31843185 const passwordBtn = document.createElement("button");3186 passwordBtn.className = "avail-btn avail-btn--ghost";3187 passwordBtn.type = "button";3188 passwordBtn.textContent = "Use password instead";3189 avail.appendChild(passwordBtn);31903191 function dismiss() {3192 wrap.classList.add("is-exiting");3193 setTimeout(() => host.remove(), 130);3194 }31953196 signInBtn.addEventListener("click", () => {3197 3198 3199 3200 3201 3202 dismiss();3203 chrome.runtime.sendMessage({ type: "OPEN_PRO_GATE", payload: {} }).catch(() => {});3204 });3205 passwordBtn.addEventListener("click", dismiss);3206 closeBtn.addEventListener("click", dismiss);32073208 document.body.appendChild(host);3209}321032113212321332143215321632173218export function showCardSelector(3219 anchorEl: HTMLInputElement,3220 cards: CardSelectorEntry[],3221 options: CardSelectorOptions3222): () => void {3223 if (cards.length === 0) return () => {};3224 const card = cards[0]!;32253226 const host = document.createElement("div");3227 host.style.cssText = "position: absolute; z-index: 2147483647;";3228 host.style.setProperty("--peach-accent", accentHex);3229 host.style.setProperty("--peach-accent-dim", withAlpha(accentHex, "28"));3230 host.style.setProperty("--peach-glow", withAlpha(accentHex, "18"));3231 host.style.setProperty("--peach-border-accent", withAlpha(accentHex, "30"));3232 const shadow = host.attachShadow({ mode: "closed" });32333234 const style = shadow.appendChild(document.createElement("style"));3235 style.textContent = SELECTOR_STYLES;32363237 const rect = anchorEl.getBoundingClientRect();3238 host.style.top = `${rect.bottom + window.scrollY + 5}px`;3239 host.style.left = `${rect.left + window.scrollX}px`;3240 host.style.width = `${Math.min(Math.max(rect.width, 320), 400)}px`;32413242 const container = shadow.appendChild(document.createElement("div"));3243 container.className = "peach-inline-popup";3244 container.setAttribute("data-theme", popupTheme);32453246 3247 const domHdr = document.createElement("div");3248 domHdr.className = "domain-header";3249 const eyebrow = document.createElement("div");3250 eyebrow.className = "domain-eyebrow";3251 eyebrow.textContent = "Pay with Peach";3252 const domName = document.createElement("div");3253 domName.className = "domain-name";3254 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");3255 domHdr.append(eyebrow, domName);3256 container.appendChild(domHdr);32573258 const platter = document.createElement("div");3259 platter.className = "card-platter";32603261 if (card.network && card.network !== "unknown") {3262 const net = document.createElement("div");3263 net.className = "cp-network";3264 net.textContent = card.network;3265 platter.appendChild(net);3266 }32673268 const nick = document.createElement("div");3269 nick.className = "cp-nickname";3270 nick.textContent = card.title;3271 platter.appendChild(nick);32723273 if (card.last4) {3274 const l4 = document.createElement("div");3275 l4.className = "cp-last4";3276 l4.textContent = `•••• ${card.last4}`;3277 platter.appendChild(l4);3278 }32793280 const meta = document.createElement("div");3281 meta.className = "cp-meta";3282 if (card.cardholderName) {3283 const name = document.createElement("span");3284 name.textContent = card.cardholderName;3285 meta.appendChild(name);3286 }3287 if (card.expMonth && card.expYear) {3288 if (card.cardholderName) {3289 const sep = document.createElement("span");3290 sep.className = "cp-meta-sep";3291 sep.textContent = "·";3292 meta.appendChild(sep);3293 }3294 const exp = document.createElement("span");3295 const yy = card.expYear.length === 4 ? card.expYear.slice(-2) : card.expYear;3296 exp.textContent = `${card.expMonth.padStart(2, "0")}/${yy}`;3297 meta.appendChild(exp);3298 }3299 if (meta.childElementCount > 0) platter.appendChild(meta);33003301 const fillWrap = document.createElement("div");3302 fillWrap.className = "cp-fill-wrap";3303 const fillBtn = document.createElement("button");3304 fillBtn.className = "sp-fill-btn";3305 fillBtn.type = "button";3306 fillBtn.textContent = "Fill card details";3307 fillBtn.addEventListener("click", async () => {3308 if (fillBtn.disabled) return;3309 fillBtn.disabled = true;3310 fillBtn.classList.add("filled");3311 fillBtn.innerHTML = checkSvgStr();3312 const resp = await chrome.runtime.sendMessage({3313 type: "GET_ENTRY_FOR_FILL",3314 payload: { id: card.id },3315 }).catch(() => null) as { ok: boolean; data?: import("../shared/types").VaultEntry } | null;3316 if (resp?.ok && resp.data) options.onFill(resp.data);3317 setTimeout(() => dismiss(), 400);3318 });3319 fillWrap.appendChild(fillBtn);3320 platter.appendChild(fillWrap);33213322 3323 const actions = document.createElement("div");3324 actions.className = "sp-actions";33253326 function flashBtn(b: HTMLButtonElement) {3327 b.classList.add("flashed");3328 setTimeout(() => b.classList.remove("flashed"), 700);3329 }33303331 async function fetchFullCard(): Promise<import("../shared/types").VaultEntry | null> {3332 const resp = await chrome.runtime.sendMessage({3333 type: "GET_ENTRY_FOR_FILL",3334 payload: { id: card.id },3335 }).catch(() => null) as { ok: boolean; data?: import("../shared/types").VaultEntry } | null;3336 return resp?.ok && resp.data ? resp.data : null;3337 }33383339 const copyNum = document.createElement("button");3340 copyNum.className = "sp-action-btn";3341 copyNum.type = "button";3342 copyNum.title = "Copy card number";3343 copyNum.textContent = "Copy number";3344 copyNum.addEventListener("click", async (e) => {3345 e.stopPropagation();3346 const full = await fetchFullCard();3347 if (!full?.cardNumber) return;3348 let alreadyWritten = false;3349 try { await navigator.clipboard.writeText(full.cardNumber); alreadyWritten = true; } catch {}3350 await chrome.runtime.sendMessage({3351 type: "COPY",3352 payload: { text: full.cardNumber, label: "Card number", alreadyWritten },3353 }).catch(() => {});3354 flashBtn(copyNum);3355 });3356 actions.appendChild(copyNum);33573358 const copyCvc = document.createElement("button");3359 copyCvc.className = "sp-action-btn";3360 copyCvc.type = "button";3361 copyCvc.title = "Copy CVC";3362 copyCvc.textContent = "Copy CVC";3363 copyCvc.addEventListener("click", async (e) => {3364 e.stopPropagation();3365 const full = await fetchFullCard();3366 if (!full?.cvc) return;3367 let alreadyWritten = false;3368 try { await navigator.clipboard.writeText(full.cvc); alreadyWritten = true; } catch {}3369 await chrome.runtime.sendMessage({3370 type: "COPY",3371 payload: { text: full.cvc, label: "CVC", alreadyWritten },3372 }).catch(() => {});3373 flashBtn(copyCvc);3374 });3375 actions.appendChild(copyCvc);33763377 const closeBtn = document.createElement("button");3378 closeBtn.className = "sp-action-btn";3379 closeBtn.type = "button";3380 closeBtn.title = "Dismiss";3381 closeBtn.textContent = "✕";3382 closeBtn.addEventListener("click", (e) => {3383 e.stopPropagation();3384 dismiss(true);3385 });3386 actions.appendChild(closeBtn);33873388 platter.appendChild(actions);3389 container.appendChild(platter);33903391 document.body.appendChild(host);3392 function updatePosition() {3393 const r = anchorEl.getBoundingClientRect();3394 host.style.top = `${r.bottom + window.scrollY + 5}px`;3395 host.style.left = `${r.left + window.scrollX}px`;3396 }3397 const stopObserving = observeAnchorPosition(anchorEl, updatePosition);33983399 function onKeyDown(e: KeyboardEvent) {3400 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }3401 }3402 document.addEventListener("keydown", onKeyDown);34033404 let exitScheduled = false;3405 function dismiss(userAction = false) {3406 if (exitScheduled) return;3407 exitScheduled = true;3408 stopObserving();3409 document.removeEventListener("click", outsideClick, { capture: true });3410 document.removeEventListener("keydown", onKeyDown);3411 if (userAction) options.onDismiss?.();3412 container.classList.add("is-exiting");3413 setTimeout(() => host.remove(), 130);3414 }34153416 function outsideClick(ev: MouseEvent) {3417 const path = ev.composedPath();3418 if (!path.includes(host) && !path.includes(anchorEl)) dismiss(true);3419 }3420 setTimeout(() => document.addEventListener("click", outsideClick, { capture: true }), 0);34213422 return dismiss;3423}