"use strict";
/**
 * Copyright: (c) Myia SAS 2026.
 * This file and its contents are licensed under the AGPLv3 License.
 * Please see the LICENSE file at the root of this repository
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.drawOverlay = drawOverlay;
exports.removeOverlay = removeOverlay;
const with_timeout_1 = require("../../util/with-timeout");
const DRAW_BORDER_SIZE = 4;
const DRAW_BORDER_COLOR = 'magenta';
// Near-invisible tint to match the CDP path's contentColor (a:0.08).
// The visible highlight is the border; the fill is just enough to
// keep the two paths visually aligned without obscuring the element.
const DRAW_FILL_COLOR = 'rgba(255, 0, 255, 0.08)';
async function drawOverlay(page, nodeId, box, timeoutMs) {
    await (0, with_timeout_1.withTimeout)(page.evaluate((params) => {
        const node = document.createElement('div');
        node.id = params.nodeId;
        node.style.pointerEvents = 'none';
        node.style.position = 'absolute';
        node.style.left = params.box.x + window.scrollX + 'px';
        node.style.top = params.box.y + window.scrollY + 'px';
        node.style.width = params.box.width + 'px';
        node.style.height = params.box.height + 'px';
        node.style.border = params.borderSize + 'px solid ' + params.borderColor;
        node.style.backgroundColor = params.fillColor;
        node.style.boxSizing = 'border-box';
        node.style.zIndex = '2147483647';
        document.body.appendChild(node);
    }, {
        nodeId,
        box,
        borderSize: DRAW_BORDER_SIZE,
        borderColor: DRAW_BORDER_COLOR,
        fillColor: DRAW_FILL_COLOR,
    }), timeoutMs, 'drawOverlay');
}
async function removeOverlay(page, nodeId, timeoutMs) {
    await (0, with_timeout_1.withTimeout)(page.evaluate((id) => {
        const el = document.getElementById(id);
        if (el)
            el.remove();
    }, nodeId), timeoutMs, 'removeOverlay');
}
