import zod from 'zod';

/**
 * Creates manifest schema.
 *
 * @returns Manifest runtime validation schema
 */ function createManifestSchema() {
    return zod.object({
        declarative_net_request: zod.object({
            rule_resources: zod.array(zod.object({
                id: zod.string(),
                enabled: zod.boolean()
            }).passthrough()).optional()
        }).optional()
    }).passthrough();
}
/**
 * @see {@link ManifestParserInterface}
 */ class ManifestParser {
    /**
     * @inheritdoc
     * @throws {zod.ZodError} If input data is invalid.
     */ parse(input) {
        const json = JSON.parse(input);
        return this.schema.parse(json);
    }
    constructor(){
        /**
     * Manifest runtime validation schema
     */ this.schema = createManifestSchema();
    }
}

export { ManifestParser };
