import React from "react";
import PropTypes from "prop-types";
import { makeStyles } from "@mui/styles";
import useTranslation from "../../utils/useTranslation";
import Link from "../Link";
const useStyles = makeStyles(() => {
  return {
    fullWidth: {
      justifyContent: "space-between"
    }
  };
});
function DataLink(_ref) {
  let {
    children,
    layer,
    href,
    fullWidth = true
  } = _ref;
  const {
    t
  } = useTranslation();
  const classes = useStyles();
  if (!layer && !href) {
    return null;
  }
  const dataLink = href || layer.get("dataLink");
  const dataLinkPortalName = layer === null || layer === void 0 ? void 0 : layer.get("dataLinkPortalName");
  if (!dataLink) {
    return null;
  }
  return dataLink && /*#__PURE__*/React.createElement(Link, {
    href: dataLink,
    className: fullWidth ? classes.fullWidth : ""
  }, children || "".concat(t("Diesen Datensatz einbinden"), " (").concat(t(dataLinkPortalName) || dataLinkPortalName || "Open Data", ")"));
}
DataLink.propTypes = {
  layer: PropTypes.shape({
    get: PropTypes.func
  }),
  href: PropTypes.string,
  children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
  fullWidth: PropTypes.bool
};
export default DataLink;
//# sourceMappingURL=DataLink.js.map