/**
 * @since Last modified: 2024-01-16 09:02:57
 * @function clampValue
 * @description Limit the value to a range.
 * @param {object} options - Parameters of clampValue.
 * @param  {string|number} options.value - The value passed in.
 * @param  {""|null|string|number} [options.max=100] - The max value.
 * @param  {""|null|string|number} [options.min=0] - The min value.
 * @returns  {number}  - The new value.
 * @see {@link https://codepen.io/axui/pen/gOEgWPb|demo @ codepen}
 * @example
 * ax.clampValue({val:2000});
 * <!--return 100-->
 */
'use strict';
import toNumber from "./toNumber";
const clampValue = ({ val = 0, min = 0, max = 100 }: { val: number | string, min?: any, max?: any }): number => {
    let tmpVal = (toNumber(val) as number),
        tmpMin = (toNumber(min) as number),
        tmpMax = (toNumber(max) as number);console.log(min,!['', null, undefined].includes(min),tmpMin,tmpVal)
    return (!['', null, undefined].includes(min) && tmpVal < tmpMin) ? tmpMin :
        (!['', null, undefined].includes(max) && tmpVal > tmpMax) ? tmpMax : tmpVal;
}
export default clampValue;
