var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/ticketBooking/components/timeBar/index.tsx
var timeBar_exports = {};
__export(timeBar_exports, {
  default: () => timeBar_default
});
module.exports = __toCommonJS(timeBar_exports);
var import_react = __toESM(require("react"));
var import_icons = require("@ant-design/icons");
var import_materials = require("@pisell/materials");
var import_ahooks = require("ahooks");
var import_antd = require("antd");
var import_dayjs = __toESM(require("dayjs"));
var import_classnames = __toESM(require("classnames"));
var import_utils = require("@pisell/utils");
var import_index = require("./index.less");
var TimeBar = (props) => {
  var _a, _b;
  const { globalState: state, setGlobalState, locale } = props;
  const _onClickNext = (0, import_ahooks.useMemoizedFn)(() => {
    var _a2, _b2, _c, _d;
    const currentTime = (_b2 = (_a2 = state.modalState) == null ? void 0 : _a2.date) == null ? void 0 : _b2.value;
    const newTime = currentTime["add"](1, "day");
    (_c = props.onDateChange) == null ? void 0 : _c.call(props, newTime, newTime.format("YYYY-MM-DD HH:mm:ss"));
    (_d = props.setIntervalTime) == null ? void 0 : _d.call(props, false);
  });
  const _onClickPre = (0, import_ahooks.useMemoizedFn)(() => {
    var _a2, _b2, _c, _d;
    const currentTime = (_b2 = (_a2 = state.modalState) == null ? void 0 : _a2.date) == null ? void 0 : _b2.value;
    const newTime = currentTime["subtract"](1, "day");
    (_c = props.onDateChange) == null ? void 0 : _c.call(props, newTime, newTime.format("YYYY-MM-DD HH:mm:ss"));
    (_d = props.setIntervalTime) == null ? void 0 : _d.call(props, false);
  });
  const _onClickToday = (0, import_ahooks.useMemoizedFn)(() => {
    var _a2;
    (_a2 = props.setIntervalTime) == null ? void 0 : _a2.call(props, true);
  });
  const _onClickNow = (0, import_ahooks.useMemoizedFn)(() => {
    var _a2;
    (_a2 = props.setIntervalTime) == null ? void 0 : _a2.call(props, true);
  });
  const _onDateTimeChange = (0, import_ahooks.useMemoizedFn)((timeString) => {
    var _a2, _b2, _c, _d;
    const currentTime = (_b2 = (_a2 = state.modalState) == null ? void 0 : _a2.date) == null ? void 0 : _b2.value;
    const [hours, minutes] = timeString.split(":").map(Number);
    const newTime = currentTime.hour(hours).minute(minutes).second(0);
    (_c = props.onDateTimeChange) == null ? void 0 : _c.call(props, newTime, newTime.format("YYYY-MM-DD HH:mm:ss"));
    setGlobalState({
      isTimeChange: true
    });
    (_d = props.setIntervalTime) == null ? void 0 : _d.call(props, timeString === (0, import_dayjs.default)().format("HH:mm"));
  });
  return (0, import_react.useMemo)(() => {
    var _a2, _b2, _c, _d;
    return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-ticket-booking-time-bar" }, /* @__PURE__ */ import_react.default.createElement(
      import_antd.Button,
      {
        icon: /* @__PURE__ */ import_react.default.createElement(import_icons.LeftOutlined, null),
        onClick: _onClickPre,
        size: "large"
      }
    ), /* @__PURE__ */ import_react.default.createElement(
      import_antd.Button,
      {
        onClick: _onClickToday,
        size: "large",
        style: state.intervalSetTime ? { background: "#000", color: "#fff" } : void 0
      },
      import_utils.locales.getText("pisell2.ticket-booking.today")
    ), /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)({
          "booking-page-date-picker-select": state.isDateChange
        }),
        style: { width: 200, flexShrink: 0 }
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_materials.DatePicker,
        {
          inputReadOnly: true,
          value: (_b2 = (_a2 = state == null ? void 0 : state.modalState) == null ? void 0 : _a2.date) == null ? void 0 : _b2.value,
          format: locale === "en" ? "dddd, DD MMM YYYY" : "YYYY年MM月DD日",
          onChange: props == null ? void 0 : props.onDateChange,
          size: "large",
          style: { width: "100%" }
        }
      )
    ), /* @__PURE__ */ import_react.default.createElement(
      import_antd.Button,
      {
        icon: /* @__PURE__ */ import_react.default.createElement(import_icons.RightOutlined, null),
        onClick: _onClickNext,
        size: "large"
      }
    ), /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)({
          "booking-page-date-picker-select": state.isTimeChange
        })
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_materials.SelectTime,
        {
          value: (_d = (_c = state == null ? void 0 : state.modalState) == null ? void 0 : _c.date) == null ? void 0 : _d.value.format("HH:mm"),
          onChange: _onDateTimeChange,
          popoverProps: {
            style: { zoom: 0.8 }
          },
          timePickerProps: {},
          timeProps: {},
          slice: 5
        }
      )
    ), /* @__PURE__ */ import_react.default.createElement(
      import_antd.Button,
      {
        onClick: _onClickNow,
        size: "large",
        style: state.intervalSetTime ? { background: "#000", color: "#fff" } : void 0
      },
      import_utils.locales.getText("pisell2.ticket-booking.now")
    ));
  }, [(_b = (_a = state.modalState) == null ? void 0 : _a.date) == null ? void 0 : _b.value, state.intervalSetTime, state.isTimeChange, state.isDateChange, locale]);
};
var timeBar_default = TimeBar;
