"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigSchema = exports.CapabilitiesSchema = exports.IocdInternalsSchema = exports.IocdOptionsSchema = void 0;
const zod_1 = require("zod");
const CommonOptionsSchema = zod_1.z.object({
    enableLogging: zod_1.z.boolean().optional(),
    systemJson: zod_1.z.string().optional(),
    configOverrides: zod_1.z.array(zod_1.z.string()).optional(),
});
const IocdOptionsExeSchema = CommonOptionsSchema.extend({
    binary: zod_1.z.string().min(1, 'binary must be provided'),
    source: zod_1.z.never().optional(), // explicitly forbid `source`
});
const IocdOptionsSourceSchema = CommonOptionsSchema.extend({
    source: zod_1.z.object({
        cwd: zod_1.z.string().min(1, 'source.cwd is required'),
        entry: zod_1.z.string().min(1, 'source.entry is required'),
        inspect: zod_1.z.boolean().optional(),
    }),
    binary: zod_1.z.never().optional(), // explicitly forbid `binary`
});
exports.IocdOptionsSchema = zod_1.z.union([IocdOptionsExeSchema, IocdOptionsSourceSchema]);
exports.IocdInternalsSchema = zod_1.z.union([
    zod_1.z.object({
        runFromExe: zod_1.z.object({
            electronVersion: zod_1.z.string(),
            binaryPathAbsolute: zod_1.z.string(),
            startArgs: zod_1.z.array(zod_1.z.string()),
        }),
    }),
    zod_1.z.object({
        runFromSource: zod_1.z.object({
            electronVersion: zod_1.z.string(),
            cwdPathAbsolute: zod_1.z.string(),
            inspect: zod_1.z.boolean(),
            entry: zod_1.z.string(),
            startArgs: zod_1.z.array(zod_1.z.string()),
        }),
    }),
]);
exports.CapabilitiesSchema = zod_1.z.object({
    browserName: zod_1.z.literal('iocd').describe("Must be 'iocd' or a standard browser name"),
    'iocd:options': exports.IocdOptionsSchema,
    'iocd:__internals__': exports.IocdInternalsSchema.optional(),
});
exports.ConfigSchema = zod_1.z.object({
    capabilities: zod_1.z.array(exports.CapabilitiesSchema),
});
