const _excluded = ["children", "onClick"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
import React from "react";
import PropTypes from "prop-types";
import { useSelector } from "react-redux";
import IconButton from "@mui/material/IconButton";
import useTranslation from "../../utils/useTranslation";
import { ReactComponent as Pencil } from "../../img/pencil.svg";
function DrawButton(_ref) {
  let {
      children,
      onClick
    } = _ref,
    buttonProps = _objectWithoutProperties(_ref, _excluded);
  const mapsetUrl = useSelector(state => state.app.mapsetUrl);
  const {
    t
  } = useTranslation();
  return /*#__PURE__*/React.createElement(IconButton, _extends({
    title: t("Neue Zeichnung"),
    size: "medium"
    /* We use a function instead of href to be able to get the proper window.location value. */,
    onClick: () => {
      onClick === null || onClick === void 0 || onClick();
      // window.open is esaier to test.
      window.open("".concat(mapsetUrl, "?parent=").concat(encodeURIComponent(window.location)), "_self");
    }
  }, buttonProps), children || /*#__PURE__*/React.createElement(Pencil, {
    focusable: false
  }));
}
DrawButton.propTypes = {
  children: PropTypes.element,
  onClick: PropTypes.func
};
export default /*#__PURE__*/React.memo(DrawButton);
//# sourceMappingURL=DrawButton.js.map