"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.submitFormSchema = exports.extractContentSchema = exports.captureAuthenticatedPagesSchema = exports.capturePageSchema = exports.loginAndCaptureSchema = void 0;
const zod_1 = require("zod");
exports.loginAndCaptureSchema = zod_1.z.object({
    url: zod_1.z.string().describe('Login page URL'),
    username_selector: zod_1.z.string().describe('CSS selector for username input (e.g. #username)'),
    password_selector: zod_1.z.string().describe('CSS selector for password input (e.g. #password)'),
    username: zod_1.z.string().describe('Username value'),
    password: zod_1.z.string().describe('Password value'),
    submit_selector: zod_1.z.string().describe('CSS selector for submit button (e.g. button[type="submit"])'),
    wait_after_login: zod_1.z.string().optional()
        .describe('CSS selector or URL substring to wait for after login. For SPAs, use a URL pattern like "/dashboard" to wait until the URL changes.'),
    screenshot_path: zod_1.z.string().optional()
        .describe('Path to save a post-login screenshot'),
    full_page: zod_1.z.boolean().optional().describe('Full-page screenshot (default: false)'),
    timeout: zod_1.z.number().optional().describe('Max wait time in ms (default: 30000)'),
});
exports.capturePageSchema = zod_1.z.object({
    url: zod_1.z.string().describe('URL to navigate to and capture'),
    screenshot_path: zod_1.z.string().optional()
        .describe('Storage path for the screenshot PNG (persisted to file storage). If omitted, auto-derived from the URL path (e.g., /admin/users → screenshots/admin-users.png). The screenshot is saved automatically — no separate write_file call is needed.'),
    page_id: zod_1.z.string().optional().describe('Reuse an existing page to preserve session (e.g., from login_and_capture)'),
    full_page: zod_1.z.boolean().optional().describe('Capture full scrollable page (default: true)'),
    wait_for_selector: zod_1.z.string().optional()
        .describe('CSS selector to wait for before capturing (ensures content is loaded)'),
    wait_ms: zod_1.z.number().optional()
        .describe('Fixed delay in ms after page load before capturing (default: 2000). Use when no specific selector to wait for.'),
    wait_until: zod_1.z.enum(['load', 'domcontentloaded', 'networkidle']).optional()
        .describe('Navigation wait strategy (default: load)'),
    timeout: zod_1.z.number().optional().describe('Max navigation timeout in ms (default: 30000)'),
});
exports.captureAuthenticatedPagesSchema = zod_1.z.object({
    login: zod_1.z.object({
        url: zod_1.z.string(),
        username_selector: zod_1.z.string(),
        password_selector: zod_1.z.string(),
        username: zod_1.z.string(),
        password: zod_1.z.string(),
        submit_selector: zod_1.z.string(),
        wait_after_login: zod_1.z.string().optional(),
        timeout: zod_1.z.number().optional(),
    }).describe('Login parameters — same shape as login_and_capture'),
    pages: zod_1.z.array(zod_1.z.object({
        url: zod_1.z.string().describe('URL to navigate to'),
        screenshot_path: zod_1.z.string().describe('Path to save screenshot'),
        wait_for_selector: zod_1.z.string().optional(),
        wait_ms: zod_1.z.number().optional(),
        full_page: zod_1.z.boolean().optional(),
    })).describe('Pages to capture after login — session is shared across all'),
});
exports.extractContentSchema = zod_1.z.object({
    url: zod_1.z.string().optional().describe('URL to navigate to. Omit to extract from an existing page (requires page_id).'),
    page_id: zod_1.z.string().optional().describe('Reuse an existing page (e.g., from login_and_capture). Skips navigation if url is also omitted.'),
    selector: zod_1.z.string().optional().describe('CSS selector to extract text from'),
    script: zod_1.z.string().optional().describe('Custom JavaScript to evaluate and return data'),
    extract_links: zod_1.z.boolean().optional().describe('Also extract all links from the page'),
    extract_metadata: zod_1.z.boolean().optional().describe('Also extract meta title, description, and OG tags'),
    wait_for_selector: zod_1.z.string().optional().describe('Wait for this selector before extracting'),
    wait_ms: zod_1.z.number().optional().describe('Fixed delay before extraction (default: 1000)'),
    timeout: zod_1.z.number().optional(),
});
exports.submitFormSchema = zod_1.z.object({
    url: zod_1.z.string().describe('Form page URL'),
    fields: zod_1.z.array(zod_1.z.object({
        selector: zod_1.z.string().describe('CSS selector for the input'),
        value: zod_1.z.string().describe('Value to fill'),
    })).describe('Fields to fill before submitting'),
    submit_selector: zod_1.z.string().describe('CSS selector for the submit button'),
    wait_after_submit: zod_1.z.string().optional()
        .describe('CSS selector or URL pattern to wait for after submit'),
    screenshot_path: zod_1.z.string().optional().describe('Path to save post-submit screenshot'),
    full_page: zod_1.z.boolean().optional(),
    timeout: zod_1.z.number().optional(),
});
