import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__ from "@chakra-ui/react";
import * as __WEBPACK_EXTERNAL_MODULE_date_fns_locale_en_US__ from "date-fns/locale/en-US";
import * as __WEBPACK_EXTERNAL_MODULE_date_fns_tz_zonedTimeToUtc__ from "date-fns-tz/zonedTimeToUtc";
import * as __WEBPACK_EXTERNAL_MODULE_date_fns_tz_format__ from "date-fns-tz/format";
const timezoneOptions = [
    'Local',
    'UTC'
];
const DateTimePickerNative = ({ onChange, showTimezoneOptions = true, ...props })=>{
    const [timezone, setTimezone] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)('Local');
    const handleDateTimeChange = (event)=>{
        const dateTime = event?.target?.value;
        if (dateTime) {
            const dateToFormat = 'UTC' === timezone ? (0, __WEBPACK_EXTERNAL_MODULE_date_fns_tz_zonedTimeToUtc__["default"])(dateTime, 'Europe/Berlin') : new Date(dateTime);
            const dateString = (0, __WEBPACK_EXTERNAL_MODULE_date_fns_tz_format__["default"])(dateToFormat, 'dd.MM.yyyy HH:mm:ss (zzzz)', {
                locale: __WEBPACK_EXTERNAL_MODULE_date_fns_locale_en_US__["default"]
            });
            onChange(dateTime, dateString);
        }
    };
    return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Input, {
        ...props,
        type: "datetime-local",
        onChange: handleDateTimeChange
    }), /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.RadioGroup, {
        value: timezone,
        onChange: setTimezone
    }, showTimezoneOptions && /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Stack, {
        spacing: 4,
        direction: "row"
    }, timezoneOptions.map((timezone)=>/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Radio, {
            value: timezone,
            colorScheme: "brand"
        }, timezone)))));
};
/* ESM default export */ const DateTimePickerNative_rslib_entry_ = DateTimePickerNative;
export { DateTimePickerNative_rslib_entry_ as default };
