"use strict";

require("core-js/modules/es.object.define-property.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FcrWindowControl = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = require("react");
var _button = require("../button");
var _icon = require("../icon");
var _type = require("../icon/type");
require("./index.css");
var _jsxRuntime = require("react/jsx-runtime");
var FcrWindowControl = exports.FcrWindowControl = function FcrWindowControl(props) {
  var _props$enableMaximize = props.enableMaximize,
    enableMaximize = _props$enableMaximize === void 0 ? false : _props$enableMaximize,
    _props$enableMinimize = props.enableMinimize,
    enableMinimize = _props$enableMinimize === void 0 ? false : _props$enableMinimize;
  var _useState = (0, _react.useState)(window.outerWidth === screen.availWidth && window.outerHeight === screen.availHeight),
    _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
    isWindowMaximized = _useState2[0],
    setIsWindowMaximized = _useState2[1];
  var changeMaximizeState = function changeMaximizeState() {
    var newState = window.outerWidth === screen.availWidth && window.outerHeight === screen.availHeight;
    if (newState !== isWindowMaximized) {
      setIsWindowMaximized(newState);
    }
  };
  (0, _react.useEffect)(function () {
    window.addEventListener('resize', changeMaximizeState);
    return function () {
      window.removeEventListener('resize', changeMaximizeState);
    };
  }, []);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: "fcr-window-control",
    children: [enableMinimize && /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
      onClick: props.onMinimize,
      type: "secondary",
      size: "XXS",
      className: "fcr-window-control-button-primary fcr-no-drag",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
        type: _type.FcrIconType.FCR_WEB_SMALLEST,
        size: 24,
        colors: {
          iconPrimary: 'var(--fcr_ui_scene_icontext1)'
        }
      })
    }), enableMaximize && isWindowMaximized ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
      size: "XXS",
      onClick: props.onReduction,
      className: "fcr-window-control-button-primary fcr-no-drag",
      type: "secondary",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
        type: _type.FcrIconType.FCR_WEB_RESTORATION,
        size: 24,
        colors: {
          iconPrimary: 'var(--fcr_ui_scene_icontext1)'
        }
      })
    }) : enableMaximize && /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
      onClick: props.onMaximize,
      size: "XXS",
      type: "secondary",
      className: "fcr-window-control-button-primary fcr-no-drag",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
        className: "fcr-icon-fullscream",
        type: _type.FcrIconType.FCR_WEB_FULLSCREAM,
        size: 24,
        colors: {
          iconPrimary: 'var(--fcr_ui_scene_icontext1)'
        }
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
      size: "XXS",
      onClick: props.onClose,
      className: "fcr-window-control-button-danger fcr-no-drag",
      type: "secondary",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
        type: _type.FcrIconType.FCR_CLOSE,
        size: 24,
        colors: {
          iconPrimary: 'var(--fcr_ui_scene_icontext1)'
        }
      })
    })]
  });
};