/**
 * BrowserConfirmOverlay — modal confirmation for safety-gated browser actions.
 * y / Enter  -> confirm
 * n / Esc    -> deny
 */
import { Container, Spacer, Text } from "@dotkaio/avis-tui";
import { theme } from "../theme/theme.js";
import { DynamicBorder } from "./dynamic-border.js";
export class BrowserConfirmOverlay extends Container {
    constructor(cfg) {
        super();
        this.addChild(new DynamicBorder());
        this.addChild(new Spacer(1));
        this.addChild(new Text(theme.bold(theme.fg("warning", "  Browser action requires confirmation")), 0, 0));
        this.addChild(new Spacer(1));
        this.addChild(new Text(theme.fg("accent", `  Action: ${cfg.action}`), 0, 0));
        this.addChild(new Text(theme.fg("muted", `  Reason: ${cfg.reason}`), 0, 0));
        if (cfg.url)
            this.addChild(new Text(theme.fg("muted", `  URL:    ${cfg.url}`), 0, 0));
        this.addChild(new Spacer(1));
        this.addChild(new Text(theme.fg("dim", "  [y] allow once   [n] deny   [Esc] cancel"), 0, 0));
        this.addChild(new Spacer(1));
        this.addChild(new DynamicBorder());
    }
    handleInput(data) {
        // y / Y / Enter -> allow
        if (data === "y" || data === "Y" || data === "\r" || data === "\n") {
            this.onDecision?.(true);
            return;
        }
        // n / N / Esc / Ctrl+C -> deny
        if (data === "n" || data === "N" || data === "\x1b" || data === "\x1b\x1b" || data === "\x03") {
            this.onDecision?.(false);
            return;
        }
    }
}
//# sourceMappingURL=browser-confirm-overlay.js.map