{"version":3,"file":"useDurationFormatter-20a9988f.js","sources":["../../src/composables/useDurationFormatter.ts"],"sourcesContent":["import { useDayjs } from '@/plugins/dayjs'\nimport { useI18n } from '@/plugins/i18n'\n\n/**\n * Returns a function which accepts a service duration in minutes\n * and formats it (value: 90 -> 1h 30 min)\n */\nexport function useDurationFormatter() {\n const dayjs = useDayjs()\n const { t } = useI18n()\n\n const formatDuration = (value: number) => {\n const duration = dayjs.duration(value, 'minutes')\n\n const hours = duration.hours()\n const minutes = duration.minutes()\n\n const hoursFormatted = t('common.formatting.duration.hours_short', { value: hours })\n const minutesFormatted = t('common.formatting.duration.minutes_short', { value: minutes })\n\n if (hours && minutes) {\n return `${hoursFormatted} ${minutesFormatted}`\n }\n\n if (hours) {\n return hoursFormatted\n }\n\n return minutesFormatted\n }\n\n return formatDuration\n}\n"],"names":["useDurationFormatter","dayjs","useDayjs","t","useI18n","value","duration","hours","minutes","hoursFormatted","minutesFormatted"],"mappings":"uWAOO,SAASA,GAAuB,CACrC,MAAMC,EAAQC,IACR,CAAE,EAAAC,GAAMC,IAsBP,OApBiBC,GAAkB,CACxC,MAAMC,EAAWL,EAAM,SAASI,EAAO,SAAS,EAE1CE,EAAQD,EAAS,QACjBE,EAAUF,EAAS,UAEnBG,EAAiBN,EAAE,yCAA0C,CAAE,MAAOI,EAAO,EAC7EG,EAAmBP,EAAE,2CAA4C,CAAE,MAAOK,EAAS,EAEzF,OAAID,GAASC,EACJ,GAAGC,CAAc,IAAIC,CAAgB,GAG1CH,EACKE,EAGFC,CAAA,CAIX"}