"use strict";

/**
 * @class Check
 * @constructor
 * @returns {void}
 * @access public
 * @static
 */
export const Check = (function(){

    /**
     * @constructs Check
     * @returns {void}
     * @access private
     * @static
     */
    const Check = function(){};

    /**
     * @param {?any} item 
     * @returns {boolean}
     * @access public
     * @static
     */
    Check.is_string = item => typeof item == "string";

    /**
     * @param {?any} item 
     * @returns {boolean}
     * @access public
     * @static
     */
    Check.is_key = item => item && Check.is_string(item) && /^[a-z_][a-z0-9_]*$/i.test(item);

    /**
     * @param {?any} item 
     * @returns {boolean}
     * @access public
     * @static
     */
    Check.is_array = item => item instanceof Array;

    /**
     * @param {?any} item 
     * @returns {boolean}
     * @access public
     * @static
     */
    Check.is_dictionary = item => item && item.constructor == Object;

    /**
     * @param {?any} item 
     * @returns {boolean}
     * @access public
     * @static
     */
    Check.is_function = item => typeof item == "function";

    /**
     * @param {?any} item 
     * @returns {boolean}
     * @access public
     * @static
     */
    Check.is_html_item = item => item && (item.tagName || item.nodeName);

    /**
     * @param {?any} item 
     * @returns {boolean}
     * @access public
     * @static
     */
    Check.is_number = item => typeof item == "number";

    /**
     * @param {?any} item 
     * @returns {boolean}
     * @access public
     * @static
     */
    Check.is_integer = item => Check.is_number(item) && item == item >> 0;

    /**
     * @returns {boolean}
     * @access public
     * @static
     */
    Check.is_dark_mode = () => !!window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;

    /**
     * @param {?any} item 
     * @returns {boolean}
     * @access public
     * @static
     */
    Check.is_null_or_undefined = item => item === null || item === undefined;

    return Check;
})();