import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { CardHeaderContainer, CardHeaderText } from './style';
import { useTranslation } from 'react-i18next';
import pl from 'dayjs/locale/pl';
import en from 'dayjs/locale/en';
import cs from 'dayjs/locale/cs';
// packages
import dayjs from 'dayjs';
import 'dayjs/locale/en-ca';
const CardHeader = (props) => {
    const arrayOfAvailableLang = [pl.name, en.name, cs.name];
    const { t } = useTranslation();
    const { due, orderType, venueConfig: { channelConstraints, lang }, } = props;
    const setLang = arrayOfAvailableLang.find((l) => l === lang);
    const minHours = channelConstraints &&
        orderType &&
        channelConstraints[orderType] &&
        channelConstraints[orderType].minDeliveryTime &&
        channelConstraints[orderType].minDeliveryTime.length >= 5
        ? channelConstraints[orderType].minDeliveryTime.substring(0, 2)
        : 0;
    const minMinutes = channelConstraints &&
        orderType &&
        channelConstraints[orderType] &&
        channelConstraints[orderType].minDeliveryTime &&
        channelConstraints[orderType].minDeliveryTime.length >= 5
        ? channelConstraints[orderType].minDeliveryTime.substring(3, 5)
        : 0;
    let minTime = dayjs();
    minTime.add(minHours, 'h');
    minTime.add(minMinutes, 'm');
    if (due) {
        minTime = dayjs(due);
    }
    return (_jsx(CardHeaderContainer, { children: _jsxs(CardHeaderText, { children: [orderType === 'DELIVERY'
                    ? `${t('OS.KDS.Card.DeliveryType.Delivery')}: `
                    : `${t('OS.KDS.Card.DeliveryType.TakeAway')}: `, minTime.locale(setLang).format('HH:mm dddd')] }, void 0) }, void 0));
};
export default CardHeader;
//# sourceMappingURL=index.js.map