{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../src/duration.ts"],"names":[],"mappings":"AAOA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA0BnD","sourcesContent":["const UNITS: Record<string, number> = {\n\ts: 1000,\n\tm: 60_000,\n\th: 3_600_000,\n\td: 86_400_000,\n};\n\nexport function parseDuration(input: string): number {\n\tconst trimmed = input.trim();\n\tif (trimmed.length === 0) {\n\t\tthrow new Error(`Invalid duration '${input}'`);\n\t}\n\tconst total = trimmed.match(/(\\d+(?:\\.\\d+)?)([a-zA-Z]+)/g);\n\tif (!total || total.join(\"\") !== trimmed) {\n\t\tthrow new Error(`Invalid duration '${input}'`);\n\t}\n\tlet ms = 0;\n\tfor (const part of total) {\n\t\tconst match = part.match(/^(\\d+(?:\\.\\d+)?)([a-zA-Z]+)$/);\n\t\tif (!match) {\n\t\t\tthrow new Error(`Invalid duration '${input}'`);\n\t\t}\n\t\tconst value = Number.parseFloat(match[1]);\n\t\tconst unit = UNITS[match[2].toLowerCase()];\n\t\tif (unit === undefined) {\n\t\t\tthrow new Error(`Unknown duration unit '${match[2]}' in '${input}' (use s, m, h, d)`);\n\t\t}\n\t\tms += value * unit;\n\t}\n\tif (!(ms > 0)) {\n\t\tthrow new Error(`Duration must be positive, got '${input}'`);\n\t}\n\treturn ms;\n}\n"]}