import { useRequest } from "ahooks";
import React, { useEffect, useRef, useContext, useImperativeHandle } from "react";
import DetailContent from "../resources/detail/detailContent";
import { Context } from "../model";
import { getOpenHoursSchedule } from "./serve";
import "./index.less";
var OpenHours = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var _useContext = useContext(Context),
    state = _useContext.state;
  var tabKey = state === null || state === void 0 ? void 0 : state.tabKey;
  var detailContentRef = useRef(null);
  var _getOpenHoursSchedule = useRequest(getOpenHoursSchedule, {
    manual: true,
    onSuccess: function onSuccess(result) {
      var _detailContentRef$cur, _detailContentRef$cur2;
      var data = (result === null || result === void 0 ? void 0 : result.data) || {};
      detailContentRef === null || detailContentRef === void 0 || (_detailContentRef$cur = detailContentRef.current) === null || _detailContentRef$cur === void 0 || (_detailContentRef$cur2 = _detailContentRef$cur.setFieldsValue) === null || _detailContentRef$cur2 === void 0 || _detailContentRef$cur2.call(_detailContentRef$cur, data);
    }
  });
  useImperativeHandle(ref, function () {
    return {
      getIsEdit: function getIsEdit() {
        return detailContentRef.current.getIsEdit();
      }
    };
  });
  useEffect(function () {
    _getOpenHoursSchedule.run();
  }, []);
  return /*#__PURE__*/React.createElement("div", {
    className: "pisell-lowcode__schedules-component-openHours"
  }, /*#__PURE__*/React.createElement(DetailContent, {
    isAutoSetCalendarData: tabKey === "openHours",
    tabKey: tabKey,
    ref: detailContentRef,
    loading: _getOpenHoursSchedule.loading,
    drawerContainer: document.querySelector(".pisell-lowcode__schedules-component-openHours")
  }));
});
export default OpenHours;