'use strict';

var datatables_types = require('./datatables.types.cjs');
var dayjs_min = require('../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.cjs');
var isSameOrAfter = require('../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/plugin/isSameOrAfter.cjs');
var isSameOrBefore = require('../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/plugin/isSameOrBefore.cjs');

dayjs_min.default.extend(isSameOrAfter.default);
dayjs_min.default.extend(isSameOrBefore.default);
const operationsOptions = {
    [datatables_types.columnTypesMap.select]: [
        {
            label: "is",
            value: "is",
            fn: (row, columnId, filterValue) => {
                return row.getValue(columnId) === filterValue.value;
            },
        },
        {
            label: "is not",
            value: "is not",
            fn: (row, columnId, filterValue) => {
                return row.getValue(columnId) !== filterValue.value;
            },
        },
    ],
    [datatables_types.columnTypesMap.number]: [
        {
            label: "=",
            value: "=",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) === Number(filterValue.value);
            },
        },
        {
            label: "!=",
            value: "!=",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) !== Number(filterValue.value);
            },
        },
        {
            label: ">",
            value: ">",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) > Number(filterValue.value);
            },
        },
        {
            label: ">=",
            value: ">=",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) >= Number(filterValue.value);
            },
        },
        {
            label: "<",
            value: "<",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) < Number(filterValue.value);
            },
        },
        {
            label: "<=",
            value: "<=",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) <= Number(filterValue.value);
            },
        },
    ],
    [datatables_types.columnTypesMap.text]: [
        {
            label: "contains",
            value: "contains",
            fn: (row, columnId, filterValue) => {
                const columnValue = row.getValue(columnId).toLowerCase();
                const filterStr = filterValue.value.toLowerCase();
                return columnValue.includes(filterStr);
            },
        },
        {
            label: "does not contains",
            value: "does not contains",
            fn: (row, columnId, filterValue) => {
                const columnValue = row.getValue(columnId).toLowerCase();
                const filterStr = filterValue.value.toLowerCase();
                return !columnValue.includes(filterStr);
            },
        },
        {
            label: "starts with",
            value: "starts with",
            fn: (row, columnId, filterValue) => {
                const columnValue = row.getValue(columnId).toLowerCase();
                const filterStr = filterValue.value.toLowerCase();
                return columnValue.startsWith(filterStr);
            },
        },
        {
            label: "ends with",
            value: "ends with",
            fn: (row, columnId, filterValue) => {
                const columnValue = row.getValue(columnId).toLowerCase();
                const filterStr = filterValue.value.toLowerCase();
                return columnValue.endsWith(filterStr);
            },
        },
        {
            label: "is empty",
            value: "is empty",
            fn: (row, columnId, filterValue) => {
                return row.getValue(columnId).length === 0;
            },
            hideValueField: true,
        },
        {
            label: "is not empty",
            value: "is not empty",
            fn: (row, columnId, filterValue) => {
                return row.getValue(columnId).length > 0;
            },
            hideValueField: true,
        },
    ],
    [datatables_types.columnTypesMap.date]: [
        {
            label: "is",
            value: "is",
            fn: (row, columnId, filterValue) => {
                return dayjs_min.default(row.getValue(columnId)).isSame(dayjs_min.default(filterValue.date), "day");
            },
        },
        {
            label: "is before",
            value: "is before",
            fn: (row, columnId, filterValue) => {
                return dayjs_min.default(row.getValue(columnId)).isBefore(dayjs_min.default(filterValue.date), "day");
            },
        },
        {
            label: "is after",
            value: "is after",
            fn: (row, columnId, filterValue) => {
                return dayjs_min.default(row.getValue(columnId)).isAfter(dayjs_min.default(filterValue.date), "day");
            },
        },
        {
            label: "is between",
            value: "is between",
            fn: (row, columnId, filterValue) => {
                return (dayjs_min.default(row.getValue(columnId)).isSameOrAfter(dayjs_min.default(filterValue.dateRange?.from), "day") &&
                    dayjs_min.default(row.getValue(columnId)).isSameOrBefore(dayjs_min.default(filterValue.dateRange?.to), "day"));
            },
            component: "rangePicker",
        },
    ],
};

exports.operationsOptions = operationsOptions;
//# sourceMappingURL=filterFns.cjs.map
