import { BooleanComparisonOperator, DateComparisonOperator, NumericComparisonOperator, StringComparisonOperator } from '@data-wrangling-components/core';
import { columnTypes, DataType } from '@essex/arquero';
import { useMemo } from 'react';
export function useIsEmpty(criterion) {
    return useMemo(()=>{
        const { operator  } = criterion;
        return operator === NumericComparisonOperator.IsEmpty || operator === NumericComparisonOperator.IsNotEmpty || operator === StringComparisonOperator.IsEmpty || operator === StringComparisonOperator.IsNotEmpty || operator === BooleanComparisonOperator.IsTrue || operator === BooleanComparisonOperator.IsFalse || operator === BooleanComparisonOperator.IsEmpty || operator === BooleanComparisonOperator.IsNotEmpty || operator === DateComparisonOperator.IsEmpty || operator === DateComparisonOperator.IsNotEmpty;
    }, [
        criterion
    ]);
}
export function usePlaceholderText(type) {
    return useMemo(()=>{
        switch(type){
            case DataType.String:
                return 'text or column';
            case DataType.Number:
                return 'number or column';
            case DataType.Boolean:
                return 'boolean or column';
        }
    }, [
        type
    ]);
}
export function useColumnTyping(table, column) {
    const tps = useMemo(()=>{
        return table ? columnTypes(table) : {};
    }, [
        table
    ]);
    const type = useMemo(()=>tps[column], [
        tps,
        column
    ]);
    const columnFilter = useMemo(()=>{
        return (name)=>tps[name] === type;
    }, [
        tps,
        type
    ]);
    return {
        type,
        columnFilter
    };
}
