{"version":3,"file":"utils.js","sources":["../../../../../../packages/components/time-select/src/utils.ts"],"sourcesContent":["interface Time {\n hours: number\n minutes: number\n}\n\nexport const parseTime = (time: string): null | Time => {\n const values = (time || '').split(':')\n if (values.length >= 2) {\n let hours = Number.parseInt(values[0], 10)\n const minutes = Number.parseInt(values[1], 10)\n const timeUpper = time.toUpperCase()\n if (timeUpper.includes('AM') && hours === 12) {\n hours = 0\n } else if (timeUpper.includes('PM') && hours !== 12) {\n hours += 12\n }\n return {\n hours,\n minutes,\n }\n }\n\n return null\n}\n\nexport const compareTime = (time1: string, time2: string): number => {\n const value1 = parseTime(time1)\n if (!value1) return -1\n const value2 = parseTime(time2)\n if (!value2) return -1\n const minutes1 = value1.minutes + value1.hours * 60\n const minutes2 = value2.minutes + value2.hours * 60\n if (minutes1 === minutes2) {\n return 0\n }\n return minutes1 > minutes2 ? 1 : -1\n}\n\nexport const padTime = (time: number | string) => {\n return `${time}`.padStart(2, '0')\n}\nexport const formatTime = (time: Time): string => {\n return `${padTime(time.hours)}:${padTime(time.minutes)}`\n}\n\nexport const nextTime = (time: string, step: string): string => {\n const timeValue = parseTime(time)\n if (!timeValue) return ''\n\n const stepValue = parseTime(step)\n if (!stepValue) return ''\n\n const next = {\n hours: timeValue.hours,\n minutes: timeValue.minutes,\n }\n next.minutes += stepValue.minutes\n next.hours += stepValue.hours\n next.hours += Math.floor(next.minutes / 60)\n next.minutes = next.minutes % 60\n return formatTime(next)\n}\n"],"names":[],"mappings":";;;;AAAY,MAAC,SAAS,GAAG,CAAC,IAAI,KAAK;AACnC,EAAE,MAAM,MAAM,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;AACzC,EAAE,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;AAC1B,IAAI,IAAI,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/C,IAAI,MA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