/*!
 * KoliBri - The accessible HTML-Standard
 */
import { b as watchBoolean, a as watchValidator, N as emptyStringByArrayHandler, o as objectObjectHandler, p as parseJson, s as setState } from './prop.validators.js';
import { b as isObject } from './common.js';

const validateHasSettingsMenu = (component, value) => {
    watchBoolean(component, '_hasSettingsMenu', value);
};

const validateTableCallbacks = (component, value) => {
    watchValidator(component, `_on`, (value) => typeof value === 'object' && value !== null, new Set(['TableCallbacksPropType {Events.onSort, Events.onSelectionChange, Events.onChangeHeaderCells}']), value);
};
const validateTableStatefulCallbacks = (component, value) => {
    watchValidator(component, `_on`, (value) => typeof value === 'object' && value !== null, new Set(['TableStatefulCallbacksPropType {Events.onSelectionChange}']), value);
};

const validateTableData = (component, value, setStateHooks) => {
    emptyStringByArrayHandler(value, () => {
        objectObjectHandler(value, () => {
            if (typeof value === 'undefined') {
                value = [];
            }
            try {
                value = parseJson(value);
            }
            catch (_a) {
            }
            if (Array.isArray(value) && value.every((data) => typeof data === 'object' && data !== null)) {
                setState(component, '_data', value, setStateHooks);
            }
        });
    });
};

const validateTableDataFoot = (component, value, setStateHooks) => {
    emptyStringByArrayHandler(value, () => {
        objectObjectHandler(value, () => {
            if (typeof value === 'undefined') {
                value = [];
            }
            try {
                value = parseJson(value);
            }
            catch (_a) {
            }
            if (Array.isArray(value) && value.every((data) => typeof data === 'object' && data !== null)) {
                setState(component, '_dataFoot', value, setStateHooks);
            }
        });
    });
};

const validateFixedCols = (component, value) => {
    watchValidator(component, '_fixedCols', (value) => Array.isArray(value) &&
        value.length === 2 &&
        typeof value[0] === 'number' &&
        typeof value[1] === 'number' &&
        Number.isInteger(value[0]) &&
        Number.isInteger(value[1]) &&
        value[0] >= 0 &&
        value[1] >= 0, new Set(['FixedColsPropType [leftFixed: number, rightFixed: number]']), value);
};

const validateTableSelection = (component, value) => {
    const parseSerializedValue = () => {
        try {
            return parseJson(value);
        }
        catch (_a) {
            return undefined;
        }
    };
    const validateObject = (value) => {
        return value && isObject(value) && typeof value.label === 'function' && (!value.selectedKeys || Array.isArray(value.selectedKeys));
    };
    const objectValue = typeof value === 'string' ? parseSerializedValue() : value;
    if (validateObject(objectValue)) {
        setState(component, '_selection', value);
    }
};

export { validateTableDataFoot as a, validateFixedCols as b, validateHasSettingsMenu as c, validateTableSelection as d, validateTableStatefulCallbacks as e, validateTableCallbacks as f, validateTableData as v };
//# sourceMappingURL=table-selection.js.map

//# sourceMappingURL=table-selection.js.map