{"version":3,"file":"useCounterPropsValidation.mjs","sources":["../../../../../../src/components/va-counter/hooks/useCounterPropsValidation.ts"],"sourcesContent":["import { watch } from 'vue'\n\nimport { warn } from '../../../utils/console'\n\ninterface useCounterPropsValidationProps {\n  modelValue: string | number,\n  min?: number | string | undefined,\n  max?: number | string | undefined,\n  step: number | string,\n}\n\nexport default function useCounterPropsValidation (props: useCounterPropsValidationProps) {\n  const validateCounterProps = () => {\n    const val = Number(props.modelValue)\n    const max = Number(props.max)\n    const min = Number(props.min)\n    const step = Number(props.step)\n\n    if (Number.isNaN(val)) {\n      warn('The value is not a number or cannot be reduced to a number.')\n      return\n    }\n\n    if (min && max && min > max) {\n      warn(`The maximum value (${max}) can not be less than the minimum value (${min}).`)\n    }\n\n    if (min && val < min) {\n      warn(`The value of the counter (${val}) can not be less than the minimum value (${min}).`)\n    }\n\n    if (max && val > max) {\n      warn(`The value of the counter (${val}) can not be greater than the maximum value (${max}).`)\n    }\n\n    if (min && max && step > (max - min)) {\n      warn(`The value of the step (${step}) can not be greater than the difference (${max - min}) between maximum value (${max}) and minimum value (${min}).`)\n    }\n  }\n\n  watch(\n    [\n      () => props.step,\n      () => props.min,\n      () => props.max,\n    ],\n    validateCounterProps,\n    { immediate: true },\n  )\n}\n"],"names":[],"mappings":";;AAWA,SAAwB,0BAA2B,OAAuC;AACxF,QAAM,uBAAuB,MAAM;AAC3B,UAAA,MAAM,OAAO,MAAM,UAAU;AAC7B,UAAA,MAAM,OAAO,MAAM,GAAG;AACtB,UAAA,MAAM,OAAO,MAAM,GAAG;AACtB,UAAA,OAAO,OAAO,MAAM,IAAI;AAE1B,QAAA,OAAO,MAAM,GAAG,GAAG;AACrB,WAAK,6DAA6D;AAClE;AAAA,IACF;AAEI,QAAA,OAAO,OAAO,MAAM,KAAK;AAC3B,WAAK,sBAAsB,GAAG,6CAA6C,GAAG,IAAI;AAAA,IACpF;AAEI,QAAA,OAAO,MAAM,KAAK;AACpB,WAAK,6BAA6B,GAAG,6CAA6C,GAAG,IAAI;AAAA,IAC3F;AAEI,QAAA,OAAO,MAAM,KAAK;AACpB,WAAK,6BAA6B,GAAG,gDAAgD,GAAG,IAAI;AAAA,IAC9F;AAEA,QAAI,OAAO,OAAO,OAAQ,MAAM,KAAM;AAC/B,WAAA,0BAA0B,IAAI,6CAA6C,MAAM,GAAG,4BAA4B,GAAG,wBAAwB,GAAG,IAAI;AAAA,IACzJ;AAAA,EAAA;AAGF;AAAA,IACE;AAAA,MACE,MAAM,MAAM;AAAA,MACZ,MAAM,MAAM;AAAA,MACZ,MAAM,MAAM;AAAA,IACd;AAAA,IACA;AAAA,IACA,EAAE,WAAW,KAAK;AAAA,EAAA;AAEtB;"}