/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 7fdaeed4d2bf
 */
import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { smartUnion } from "../../types/smartUnion.js";
import { FilterCondition$inboundSchema, FilterCondition$outboundSchema, } from "./filtercondition.js";
/** @internal */
export const Or$inboundSchema = smartUnion([
    FilterCondition$inboundSchema,
    z.lazy(() => FilterGroup$inboundSchema),
]);
/** @internal */
export const Or$outboundSchema = smartUnion([
    FilterCondition$outboundSchema,
    z.lazy(() => FilterGroup$outboundSchema),
]);
export function orToJSON(or) {
    return JSON.stringify(Or$outboundSchema.parse(or));
}
export function orFromJSON(jsonString) {
    return safeParse(jsonString, (x) => Or$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Or' from JSON`);
}
/** @internal */
export const FilterGroup$inboundSchema = z
    .object({
    AND: z.nullable(z.array(smartUnion([
        FilterCondition$inboundSchema,
        z.lazy(() => FilterGroup$inboundSchema),
    ]))).optional(),
    OR: z.nullable(z.array(smartUnion([
        FilterCondition$inboundSchema,
        z.lazy(() => FilterGroup$inboundSchema),
    ]))).optional(),
}).transform((v) => {
    return remap$(v, {
        "AND": "and",
        "OR": "or",
    });
});
/** @internal */
export const FilterGroup$outboundSchema = z.object({
    and: z.nullable(z.array(smartUnion([
        FilterCondition$outboundSchema,
        z.lazy(() => FilterGroup$outboundSchema),
    ]))).optional(),
    or: z.nullable(z.array(smartUnion([
        FilterCondition$outboundSchema,
        z.lazy(() => FilterGroup$outboundSchema),
    ]))).optional(),
}).transform((v) => {
    return remap$(v, {
        and: "AND",
        or: "OR",
    });
});
export function filterGroupToJSON(filterGroup) {
    return JSON.stringify(FilterGroup$outboundSchema.parse(filterGroup));
}
export function filterGroupFromJSON(jsonString) {
    return safeParse(jsonString, (x) => FilterGroup$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FilterGroup' from JSON`);
}
/** @internal */
export const And$inboundSchema = smartUnion([
    FilterCondition$inboundSchema,
    z.lazy(() => FilterGroup$inboundSchema),
]);
/** @internal */
export const And$outboundSchema = smartUnion([
    FilterCondition$outboundSchema,
    z.lazy(() => FilterGroup$outboundSchema),
]);
export function andToJSON(and) {
    return JSON.stringify(And$outboundSchema.parse(and));
}
export function andFromJSON(jsonString) {
    return safeParse(jsonString, (x) => And$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'And' from JSON`);
}
//# sourceMappingURL=filtergroup.js.map