/*!
 * KoliBri - The accessible HTML-Standard
 */
'use strict';

var common = require('./common-DAAt5YQ7.js');

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

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

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

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

const validateFixedCols = (component, value) => {
    common.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 common.parseJson(value);
        }
        catch (_a) {
            return undefined;
        }
    };
    const validateObject = (value) => {
        return value && common.isObject(value) && typeof value.label === 'function' && (!value.selectedKeys || Array.isArray(value.selectedKeys));
    };
    const objectValue = typeof value === 'string' ? parseSerializedValue() : value;
    if (validateObject(objectValue)) {
        common.setState(component, '_selection', value);
    }
};

exports.validateFixedCols = validateFixedCols;
exports.validateHasSettingsMenu = validateHasSettingsMenu;
exports.validateTableCallbacks = validateTableCallbacks;
exports.validateTableData = validateTableData;
exports.validateTableDataFoot = validateTableDataFoot;
exports.validateTableSelection = validateTableSelection;
exports.validateTableStatefulCallbacks = validateTableStatefulCallbacks;
//# sourceMappingURL=table-selection-BzjiHUz6.js.map

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