"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const zod_1 = require("zod");
const field_1 = require("../../../../types/field");
const filter_1 = require("../../../../types/filter");
const fieldId_1 = require("../fieldId");
const commonNumberFilterRuleSchema = zod_1.z.object({
    fieldId: (0, fieldId_1.getFieldIdSchema)({ additionalDescription: null }),
    fieldType: zod_1.z.union([
        zod_1.z.literal(field_1.DimensionType.NUMBER),
        zod_1.z.literal(field_1.MetricType.NUMBER),
        zod_1.z.literal(field_1.MetricType.PERCENTILE),
        zod_1.z.literal(field_1.MetricType.MEDIAN),
        zod_1.z.literal(field_1.MetricType.AVERAGE),
        zod_1.z.literal(field_1.MetricType.COUNT),
        zod_1.z.literal(field_1.MetricType.COUNT_DISTINCT),
        zod_1.z.literal(field_1.MetricType.SUM),
        zod_1.z.literal(field_1.MetricType.SUM_DISTINCT),
        zod_1.z.literal(field_1.MetricType.AVERAGE_DISTINCT),
        zod_1.z.literal(field_1.MetricType.MIN),
        zod_1.z.literal(field_1.MetricType.MAX),
    ]),
    fieldFilterType: zod_1.z.literal(filter_1.FilterType.NUMBER),
});
const numberFilterSchema = zod_1.z.union([
    commonNumberFilterRuleSchema.extend({
        operator: zod_1.z.union([
            zod_1.z.literal(filter_1.FilterOperator.NULL),
            zod_1.z.literal(filter_1.FilterOperator.NOT_NULL),
        ]),
    }),
    commonNumberFilterRuleSchema.extend({
        operator: zod_1.z.union([
            zod_1.z.literal(filter_1.FilterOperator.EQUALS),
            zod_1.z.literal(filter_1.FilterOperator.NOT_EQUALS),
        ]),
        values: zod_1.z.array(zod_1.z.number()),
    }),
    commonNumberFilterRuleSchema.extend({
        operator: zod_1.z.union([
            zod_1.z.literal(filter_1.FilterOperator.LESS_THAN),
            zod_1.z.literal(filter_1.FilterOperator.LESS_THAN_OR_EQUAL),
            zod_1.z.literal(filter_1.FilterOperator.GREATER_THAN),
            zod_1.z.literal(filter_1.FilterOperator.GREATER_THAN_OR_EQUAL),
        ]),
        values: zod_1.z.array(zod_1.z.number()).length(1),
    }),
    commonNumberFilterRuleSchema.extend({
        operator: zod_1.z.union([
            zod_1.z.literal(filter_1.FilterOperator.IN_BETWEEN),
            zod_1.z.literal(filter_1.FilterOperator.NOT_IN_BETWEEN),
        ]),
        values: zod_1.z.array(zod_1.z.number()).length(2),
    }),
]);
exports.default = numberFilterSchema;
//# sourceMappingURL=numberFilters.js.map