import { ArrayValue, BooleanValue, RecordValue, Schema, StringValue, } from '@coveo/bueno';
import { facetValueStates } from '../../../../../features/facets/facet-api/value.js';
import { validateManualDateRanges } from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions.js';
import { rangeFacetRangeAlgorithm, rangeFacetSortCriteria, } from '../../../../../features/facets/range-facets/generic/interfaces/request.js';
import { validateOptions } from '../../../../../utils/validate-payload.js';
import { facetId, field, filterFacetCount, generateAutomaticRanges, injectionDepth, numberOfValues, } from '../../../../core/facets/_common/facet-option-definitions.js';
const dateRangeRequestDefinition = {
    start: new StringValue(),
    end: new StringValue(),
    endInclusive: new BooleanValue(),
    state: new StringValue({ constrainTo: facetValueStates }),
};
export const dateFacetOptionsSchema = new Schema({
    facetId,
    field,
    tabs: new RecordValue({
        options: {
            required: false,
        },
        values: {
            included: new ArrayValue({ each: new StringValue() }),
            excluded: new ArrayValue({ each: new StringValue() }),
        },
    }),
    generateAutomaticRanges,
    filterFacetCount,
    injectionDepth,
    numberOfValues,
    currentValues: new ArrayValue({
        each: new RecordValue({ values: dateRangeRequestDefinition }),
    }),
    sortCriteria: new StringValue({ constrainTo: rangeFacetSortCriteria }),
    rangeAlgorithm: new StringValue({ constrainTo: rangeFacetRangeAlgorithm }),
});
export function validateDateFacetOptions(engine, options) {
    validateOptions(engine, dateFacetOptionsSchema, options, 'buildDateFacet');
    validateManualDateRanges(options);
}
