import { z } from "zod";
import { zDatum } from "../properties/index.js";
const zPartialSelector = zDatum;
const zFieldSelector = z.object({
    field: z.union([
        z.string(),
        z.array(z.string())
    ])
});
const zMeasureSelector = z.object({
    field: z.string(),
    operator: z["enum"]([
        '=',
        '==',
        '!=',
        '>',
        '<',
        '>=',
        '<=',
        'between'
    ]).nullish(),
    op: z["enum"]([
        '=',
        '==',
        '!=',
        '>',
        '<',
        '>=',
        '<=',
        'between'
    ]).nullish(),
    value: z.union([
        z.string(),
        z.number(),
        z.array(z.union([
            z.string(),
            z.number()
        ]))
    ])
});
const zDimensionSelector = z.object({
    field: z.string(),
    operator: z["enum"]([
        'in',
        'not in'
    ]).nullish(),
    op: z["enum"]([
        'in',
        'not in'
    ]).nullish(),
    value: z.union([
        z.string(),
        z.number(),
        z.array(z.union([
            z.string(),
            z.number()
        ]))
    ])
});
const zSelector = z.union([
    z.string(),
    z.number(),
    zFieldSelector,
    zMeasureSelector,
    zDimensionSelector,
    zPartialSelector
]);
const zSelectors = z.array(zSelector);
const zAreaSelector = z.union([
    zFieldSelector,
    zMeasureSelector,
    zDimensionSelector
]);
const zAreaSelectors = z.array(zAreaSelector);
const zCellSelector = z.object({
    __row_index: z.number(),
    field: z.union([
        z.string(),
        z.literal('*')
    ])
});
const zTableDynamicFilter = z.object({
    type: z.literal('row-with-field'),
    description: z.string().optional(),
    code: z.string(),
    fallback: z.union([
        zSelector,
        zSelectors
    ]).optional(),
    result: z.object({
        success: z.boolean(),
        data: z.array(zCellSelector).optional()
    }).optional()
});
const zChartDynamicFilter = z.object({
    type: z.literal('row-with-field'),
    description: z.string().optional(),
    code: z.string(),
    fallback: z.union([
        zSelector,
        zSelectors
    ]).optional(),
    result: z.object({
        success: z.boolean(),
        data: z.array(zCellSelector).optional()
    }).optional()
});
const zValueDynamicFilter = z.object({
    type: z.literal('value'),
    description: z.string().optional(),
    code: z.string(),
    fallback: z.union([
        z.string(),
        z.number()
    ]).optional(),
    result: z.object({
        success: z.boolean(),
        data: z.union([
            z.number(),
            z.string()
        ]).optional()
    }).optional()
});
const zDynamicFilter = z.union([
    zTableDynamicFilter,
    zChartDynamicFilter
]);
export { zAreaSelector, zAreaSelectors, zCellSelector, zChartDynamicFilter, zDimensionSelector, zDynamicFilter, zFieldSelector, zMeasureSelector, zPartialSelector, zSelector, zSelectors, zTableDynamicFilter, zValueDynamicFilter };

//# sourceMappingURL=selector.js.map