import { isValidDate } from './helpers';
const dateFormatter = new Intl.DateTimeFormat(undefined, {
    day: '2-digit',
    month: '2-digit',
    year: 'numeric',
});
const timeFormatter = new Intl.DateTimeFormat(undefined, {
    hour: 'numeric',
    minute: '2-digit',
});
export const formatDatePart = (value) => isValidDate(value) ? dateFormatter.format(value) : '';
export const formatTimePart = (value) => isValidDate(value) ? timeFormatter.format(value) : '';
const DATE_PLACEHOLDER_SAMPLE = new Date(2026, 0, 31);
const TIME_PLACEHOLDER_SAMPLE = new Date(2026, 0, 1, 13, 30);
/**
 * Derives an input placeholder from the current locale's date format by
 * replacing each part with its translated stand-in (DD, MM, YYYY). E.g.
 * `MM/DD/YYYY` in en-US, `DD.MM.YYYY` in de-DE, `YYYY/MM/DD` in ja-JP.
 */
export const datePlaceholder = (tokens) => dateFormatter
    .formatToParts(DATE_PLACEHOLDER_SAMPLE)
    .map((part) => {
    if (part.type === 'day')
        return tokens.day;
    if (part.type === 'month')
        return tokens.month;
    if (part.type === 'year')
        return tokens.year;
    return part.value;
})
    .join('');
/**
 * Derives a time input placeholder from the current locale's time format.
 * E.g. `HH:MM AM` in en-US (12-hour) or `HH:MM` in de-DE (24-hour).
 */
export const timePlaceholder = (tokens) => timeFormatter
    .formatToParts(TIME_PLACEHOLDER_SAMPLE)
    .map((part) => {
    if (part.type === 'hour')
        return tokens.hour;
    if (part.type === 'minute')
        return tokens.minute;
    return part.value;
})
    .join('');
//# sourceMappingURL=formatters.js.map