{"version":3,"file":"useColors.mjs","names":["colorVolumes","getColorVolume","className","parseInt","split","getColorName","setColorVolume","volume","color","calculateColorVolume","newVolume","length","find","v","getNextColorVolume","colorIndex","indexOf","newColorVolume","getNextColor","changeColorName"],"sources":["../../src/utils/useColors.ts"],"sourcesContent":["import type ColorName from '@/types/colors'\nimport colorVolumes from '@/assets/colorVolumes'\n\nexport const getColorVolume = (className: ColorName): number => {\n  if (className === 'black' || className === 'white') {\n    return 0\n  }\n  return parseInt(className.split('-')[1], 10)\n}\n\nexport const getColorName = (className: ColorName): ColorName => {\n  return className.split('-')[0] as ColorName\n}\n\nexport const setColorVolume = (\n  className: ColorName,\n  volume: number\n): ColorName => {\n  const color = getColorName(className)\n  if (color === 'black' || color === 'white' || volume === 0) {\n    return color as ColorName\n  }\n  return (color + '-' + volume) as ColorName\n}\n\nexport const calculateColorVolume = (\n  className: ColorName,\n  volume: number\n): number => {\n  if (className === 'black' || className === 'white') {\n    return 0\n  }\n  let newVolume = getColorVolume(className) + volume\n  if (newVolume <= colorVolumes[0]) {\n    newVolume = colorVolumes[0]\n  }\n\n  if (newVolume > colorVolumes[colorVolumes.length - 1]) {\n    newVolume = colorVolumes[colorVolumes.length - 1]\n  }\n\n  newVolume = colorVolumes.find((v) => v >= newVolume) || colorVolumes[0]\n\n  return newVolume\n}\n\nexport const getNextColorVolume = (className: ColorName): number => {\n  if (className === 'black' || className === 'white') {\n    return 0\n  }\n  const colorIndex = colorVolumes.indexOf(getColorVolume(className))\n  const newColorVolume = colorVolumes[colorIndex + 1]\n\n  if (colorIndex === colorVolumes.length - 1) {\n    return colorVolumes[colorIndex]\n  }\n\n  return newColorVolume\n}\n\nexport const getNextColor = (className: ColorName): ColorName => {\n  if (className === 'black' || className === 'white') {\n    return className\n  }\n  return setColorVolume(className, getNextColorVolume(className))\n}\n\nexport const changeColorName = (\n  className: ColorName,\n  volume: number\n): ColorName => {\n  if (className === 'black' || className === 'white') {\n    return className\n  }\n  return setColorVolume(className, calculateColor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