import { AKListFilter, LIST_FILTER_SEPARATOR } from './index.js';
export class AKSuffixListFilter extends AKListFilter {
    suffix;
    operator;
    constructor(suffix, operator) {
        super();
        this.suffix = suffix;
        this.operator = operator;
    }
    validFields(qsFilters) {
        return Object.keys(qsFilters).filter((field) => field.endsWith(LIST_FILTER_SEPARATOR + this.suffix));
    }
    matches(qsFilters) {
        return this.validFields(qsFilters).length > 0;
    }
    apply(dbQuery, qsFilters, model) {
        this.validFields(qsFilters).forEach((field) => {
            const fieldWithoutSuffix = this.suffix.length == 0
                ? field
                : field.slice(0, -(LIST_FILTER_SEPARATOR.length + this.suffix.length));
            this.operator(dbQuery, fieldWithoutSuffix, qsFilters[field], model);
        });
    }
    clear(qsFilters) {
        this.validFields(qsFilters).forEach((field) => delete qsFilters[field]);
    }
}
//# sourceMappingURL=suffix.js.map