"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _Accordion = _interopRequireDefault(require("@material-ui/core/Accordion"));
var _AccordionSummary = _interopRequireDefault(require("@material-ui/core/AccordionSummary"));
var _AccordionDetails = _interopRequireDefault(require("@material-ui/core/AccordionDetails"));
var _AccordionActions = _interopRequireDefault(require("@material-ui/core/AccordionActions"));
var _styles = require("@material-ui/core/styles");
var _classnames = _interopRequireDefault(require("classnames"));
var _Icon = _interopRequireDefault(require("./../DataDisplay/Icon"));
var _expansionPanelProps = require("./expansionPanelProps");
var _useViewState3 = _interopRequireDefault(require("../../../hooks/useViewState"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var useStyles = (0, _styles.makeStyles)(function (theme) {
  return {
    summaryRoot: {
      height: theme.spacing(8),
      backgroundColor: theme.palette.primary.lighter,
      flexDirection: "row-reverse",
      borderRadius: 0,
      "&:hover": {
        backgroundColor: theme.palette.hoverprimary.lighter
      },
      "&:focus": {
        borderRadius: 0
      }
    },
    resetPadding: {
      padding: "0 !important"
    },
    panelExpanded: {},
    summaryContent: {
      marginLeft: theme.spacing(1),
      "&$panelExpanded": {
        marginLeft: theme.spacing(1)
      }
    },
    panelRoot: {
      "&$panelExpanded": {
        margin: "0",
        position: "unset",
        "&:before": {
          opacity: "1"
        }
      },
      "&:before": {
        backgroundColor: theme.palette.secondary.light
      }
    },
    summaryExpandIconRoot: {
      color: theme.palette.grey.darker,
      minWidth: "auto"
    },
    constrainedSummaryRoot: {
      overflowX: "auto",
      overflowY: "hidden"
    },
    constrainedSummaryContent: {
      minWidth: theme.spacing(83)
    }
  };
});
var SectionExpansionPanel = function SectionExpansionPanel(_ref) {
  var _panelState$isExpande;
  var header = _ref.header,
    content = _ref.content,
    actions = _ref.actions,
    expansionPanelId = _ref.expansionPanelId,
    expansionPanelProps = _ref.expansionPanelProps,
    expansionPanelActionsProps = _ref.expansionPanelActionsProps;
  if ((0, _expansionPanelProps.isExpansionPanelProps)(expansionPanelProps) === false) {
    throw new TypeError("expansionPanelProps property is not of type ExpansionPanelProps");
  }
  if ((0, _expansionPanelProps.isExpansionPanelActionsProps)(expansionPanelActionsProps) === false) {
    throw new TypeError("expansionPanelActionsProps property is not of type ExpansionPanelActionsProps");
  }
  var classes = useStyles();

  // Expansion panel props
  var disabled = expansionPanelProps == null ? void 0 : expansionPanelProps.get(_expansionPanelProps.ExpansionPanelProps.propNames.disabled);
  var _useViewState = (0, _useViewState3.default)(expansionPanelId),
    _useViewState2 = _slicedToArray(_useViewState, 2),
    panelState = _useViewState2[0],
    updateViewState = _useViewState2[1];
  var defaultExpanded = (_panelState$isExpande = panelState["isExpanded"]) != null ? _panelState$isExpande : true;
  var _React$useState = _react.default.useState(defaultExpanded),
    _React$useState2 = _slicedToArray(_React$useState, 2),
    expanded = _React$useState2[0],
    setExpanded = _React$useState2[1];
  var internalOnChange = function internalOnChange(evt, isExpanded) {
    setExpanded(isExpanded);
    updateViewState("isExpanded", isExpanded);
  };

  // Expansion panel summary props
  var defaultSummaryStyles = {
    edge: false,
    size: "small",
    classes: {
      root: classes.summaryExpandIconRoot,
      sizeSmall: classes.resetPadding
    }
  };

  // Expansion panel actions props
  var disableSpacing = expansionPanelActionsProps == null ? void 0 : expansionPanelActionsProps.get(_expansionPanelProps.ExpansionPanelActionsProps.propNames.disableSpacing);
  var constrained = (expansionPanelProps == null ? void 0 : expansionPanelProps.get(_expansionPanelProps.ExpansionPanelProps.propNames.constrained)) || false;
  return /*#__PURE__*/_react.default.createElement(_Accordion.default, {
    defaultExpanded: defaultExpanded,
    disabled: disabled == null ? false : disabled,
    expanded: expanded,
    onChange: internalOnChange,
    classes: {
      root: (0, _classnames.default)(classes.panelRoot),
      expanded: (0, _classnames.default)(classes.panelExpanded)
    }
  }, /*#__PURE__*/_react.default.createElement(_AccordionSummary.default, {
    expandIcon: /*#__PURE__*/_react.default.createElement(_Icon.default, {
      id: "dropdown-chevron-down"
    }),
    IconButtonProps: defaultSummaryStyles,
    classes: {
      root: (0, _classnames.default)(classes.summaryRoot, constrained ? classes.constrainedSummaryRoot : ""),
      expanded: (0, _classnames.default)(classes.panelExpanded),
      content: (0, _classnames.default)(classes.summaryContent, constrained ? classes.constrainedSummaryContent : ""),
      expandIcon: (0, _classnames.default)(classes.summaryExpandIconRoot)
    }
  }, header), /*#__PURE__*/_react.default.createElement(_AccordionDetails.default, {
    classes: {
      root: (0, _classnames.default)(classes.resetPadding)
    }
  }, content), actions != null ? /*#__PURE__*/_react.default.createElement(_AccordionActions.default, {
    disableSpacing: disableSpacing == null ? false : disableSpacing
  }, actions) : null);
};
__signature__(SectionExpansionPanel, "useStyles{classes}\nuseViewState{[panelState, updateViewState]}\nuseState{[expanded, setExpanded](defaultExpanded)}", function () {
  return [useStyles, _useViewState3.default];
});
__signature__(SectionExpansionPanel, "useStyles{classes}\nuseViewState{[panelState, updateViewState]}\nuseState{[expanded, setExpanded](defaultExpanded)}", function () {
  return [useStyles, _useViewState3.default];
});
var _default = SectionExpansionPanel;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js");
  reactHotLoader.register(SectionExpansionPanel, "SectionExpansionPanel", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js");
  reactHotLoader.register(SectionExpansionPanel, "SectionExpansionPanel", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();