import { parseTimeToMs } from "./parseTimeToMs.js";
const durationConverter = {
	fromAttribute: (value) => value === null ? null : parseTimeToMs(value),
	toAttribute: (value) => value === null ? null : `${value}s`
};
const positiveDurationConverter = (error) => {
	return {
		fromAttribute: (value) => {
			if (value === null) return null;
			if (value.startsWith("-")) throw new Error(error);
			return parseTimeToMs(value);
		},
		toAttribute: (value) => value === null ? null : `${value}s`
	};
};
const trimDurationConverter = positiveDurationConverter("Trimstart & trimend must be a positive value in milliseconds or seconds (1s, 1000ms)");
const imageDurationConverter = positiveDurationConverter("Image duration must be a positive value in milliseconds or seconds (1s, 1000ms)");
const sourceDurationConverter = positiveDurationConverter("Sourcein & sourceout must be a positive value in milliseconds or seconds (1s, 1000ms)");
export { durationConverter };
