"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.DateTimePickerBase = exports.DateTimePicker = void 0;
var _kind = _interopRequireDefault(require("@enact/core/kind"));
var _Changeable = _interopRequireDefault(require("@enact/ui/Changeable"));
var _Layout = require("@enact/ui/Layout");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _compose = _interopRequireDefault(require("ramda/src/compose"));
var _DatePicker = _interopRequireDefault(require("../DatePicker"));
var _Skinnable = _interopRequireDefault(require("../Skinnable"));
var _TimePicker = _interopRequireDefault(require("../TimePicker"));
var _DateTimePickerModule = _interopRequireDefault(require("./DateTimePicker.module.css"));
var _jsxRuntime = require("react/jsx-runtime");
var _excluded = ["dayAriaLabel", "disabled", "hourAriaLabel", "meridiemAriaLabel", "minuteAriaLabel", "monthAriaLabel", "onChange", "onSpotlightDisappear", "spotlightDisabled", "value", "yearAriaLabel"];
/**
 * An Agate-themed date/time picker component.
 *
 * @example
 * <DateTimePicker />
 *
 * @module agate/DateTimePicker
 * @exports DateTimePicker
 * @exports DateTimePickerBase
 */
/**
 * A date/time Picker component.
 *
 * @class DateTimePickerBase
 * @memberof agate/DateTimePicker
 * @ui
 * @public
 */
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
var DateTimePickerBase = exports.DateTimePickerBase = (0, _kind["default"])({
  name: 'DateTimePickerBase',
  propTypes: /** @lends agate/DateTimePicker.DateTimePickerBase.prototype */{
    /**
     * The "aria-label" for the day picker.
     *
     * If not specified, the "aria-label" for the day picker will be
     * a combination of the current value and 'day change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    dayAriaLabel: _propTypes["default"].string,
    /**
     * Disables the `DateTimePicker`.
     *
     * @type {Boolean}
     * @public
     */
    disabled: _propTypes["default"].bool,
    /**
     * The "aria-label" for the hour picker
     *
     * If not specified, the "aria-label" for the hour picker will be
     * a combination of the current value and 'hour change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    hourAriaLabel: _propTypes["default"].string,
    /**
     * The "aria-label" for the meridiem picker.
     *
     * If not specified, the "aria-label" for the meridiem picker will be
     * a combination of the current value and 'change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    meridiemAriaLabel: _propTypes["default"].string,
    /**
     * The "aria-label" for the minute picker.
     *
     * If not specified, the "aria-label" for the minute picker will be
     * a combination of the current value and 'minute change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    minuteAriaLabel: _propTypes["default"].string,
    /**
     * The "aria-label" for the month picker.
     *
     * If not specified, the "aria-label" for the month picker will be
     * a combination of the current value and 'month change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    monthAriaLabel: _propTypes["default"].string,
    /**
     * Handler for `onChange` events
     *
     * @type {Function}
     * @public
     */
    onChange: _propTypes["default"].func,
    /**
     * Called when the component is removed when it had focus.
     *
     * @type {Function}
     * @param {Object} event
     * @public
     */
    onSpotlightDisappear: _propTypes["default"].func,
    /**
     * Disables 5-way spotlight from navigating into the component.
     *
     * @type {Boolean}
     * @public
     */
    spotlightDisabled: _propTypes["default"].bool,
    /**
     * The value of the DateTimePicker.
     *
     * @type {Date}
     * @public
     */
    value: _propTypes["default"].instanceOf(Date),
    /**
     * The "aria-label" for the year picker.
     *
     * If not specified, the "aria-label" for the year picker will be
     * a combination of the current value and 'year change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    yearAriaLabel: _propTypes["default"].string
  },
  styles: {
    css: _DateTimePickerModule["default"],
    className: 'dateTimePicker'
  },
  render: function render(_ref) {
    var dayAriaLabel = _ref.dayAriaLabel,
      disabled = _ref.disabled,
      hourAriaLabel = _ref.hourAriaLabel,
      meridiemAriaLabel = _ref.meridiemAriaLabel,
      minuteAriaLabel = _ref.minuteAriaLabel,
      monthAriaLabel = _ref.monthAriaLabel,
      onChange = _ref.onChange,
      onSpotlightDisappear = _ref.onSpotlightDisappear,
      spotlightDisabled = _ref.spotlightDisabled,
      value = _ref.value,
      yearAriaLabel = _ref.yearAriaLabel,
      rest = _objectWithoutProperties(_ref, _excluded);
    return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Layout.Row, _objectSpread(_objectSpread({}, rest), {}, {
      className: _DateTimePickerModule["default"].dateTimePicker,
      disabled: disabled,
      align: "center center",
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.Row, {
        align: "center center",
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TimePicker["default"], _objectSpread(_objectSpread({}, rest), {}, {
          css: _DateTimePickerModule["default"],
          disabled: disabled,
          hourAriaLabel: hourAriaLabel,
          meridiemAriaLabel: meridiemAriaLabel,
          minuteAriaLabel: minuteAriaLabel,
          onChange: onChange,
          onSpotlightDisappear: onSpotlightDisappear,
          spotlightDisabled: spotlightDisabled,
          value: value
        }))
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.Row, {
        align: "center center",
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker["default"], _objectSpread(_objectSpread({}, rest), {}, {
          css: _DateTimePickerModule["default"],
          dayAriaLabel: dayAriaLabel,
          disabled: disabled,
          monthAriaLabel: monthAriaLabel,
          onChange: onChange,
          onSpotlightDisappear: onSpotlightDisappear,
          spotlightDisabled: spotlightDisabled,
          value: value,
          yearAriaLabel: yearAriaLabel
        }))
      })]
    }));
  }
});

/**
 * Applies Agate specific behaviors to {@link agate/DateTimePicker.DateTimePickerBase|DateTimePickerBase} components.
 *
 * @hoc
 * @memberof agate/DateTimePicker
 * @mixes agate/Skinnable.Skinnable
 * @mixes ui/Changeable.Changeable
 * @public
 */
var DateTimePickerDecorator = (0, _compose["default"])(_Skinnable["default"], _Changeable["default"]);

/**
 * An Agate themed date/time Picker component.
 *
 * @class DateTimePicker
 * @memberof agate/DateTimePicker
 * @extends agate/DateTimePicker.DateTimePickerBase
 * @mixes agate/DateTimePicker.DateTimePickerDecorator
 * @ui
 * @public
 */
var DateTimePicker = exports.DateTimePicker = DateTimePickerDecorator(DateTimePickerBase);
var _default = exports["default"] = DateTimePicker;