"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Sidebar = Sidebar;

var _react = require("react");

var _io = require("react-icons/io5");

var _mixinsModule = _interopRequireDefault(require("../../utils/mixins.module.css"));

var _jsxRuntime = require("react/jsx-runtime");

var _excluded = ["animated", "settings"];

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _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(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function Sidebar(_ref) {
  var _ref$animated = _ref.animated,
      animated = _ref$animated === void 0 ? false : _ref$animated,
      settings = _ref.settings,
      rest = _objectWithoutProperties(_ref, _excluded);

  var children = rest.children,
      className = rest.className;

  var _useState = (0, _react.useState)(false),
      _useState2 = _slicedToArray(_useState, 2),
      collapsed = _useState2[0],
      setCollapsed = _useState2[1];

  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: "border border-gray-200 h-screen sticky top-0 ".concat(collapsed ? "border-l-0" : ""),
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
      title: "".concat(collapsed ? "Show" : "Hide", " sidebar"),
      className: "z-10 transform absolute top-5 -left-3 ".concat(collapsed ? "" : "rotate-180"),
      type: "button",
      onClick: function onClick() {
        return setCollapsed(!collapsed);
      },
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_io.IoChevronBackCircle, {
        className: "h-6 w-6 text-gray-500"
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "flex-shrink-0 bg-gray-50 h-full overflow-x-hidden overflow-y-auto ".concat(animated ? "transform duration-200" : "", " ").concat(_mixinsModule.default.appleScrollbar, " ").concat(className || ""),
      style: {
        width: collapsed ? "0" : "310px"
      },
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: "p-4",
        style: {
          minWidth: animated ? "300px" : ""
        },
        children: !collapsed && children
      })
    })]
  });
}