import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
import { Box, Button, Typography } from '@mui/material';
import PropTypes from 'prop-types';
import { joinURL } from 'ufo';
import getSafeUrlWithToast from '../../../util/get-safe-url';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
function UploadedToast({
  endpoint,
  published
}) {
  const {
    t
  } = useLocaleContext();
  const handleOpenUrl = () => {
    window.open(getSafeUrlWithToast(`${joinURL(endpoint.url)}`, {
      allowDomains: null
    }));
  };
  return /*#__PURE__*/_jsxs(Box, {
    children: [/*#__PURE__*/_jsx(Typography, {
      variant: "subtitle2",
      children: t(published ? 'blocklet.publish.endpoint.publishToEndpointSuccess' : 'blocklet.publish.endpoint.uploadToEndpointSuccess', {
        name: endpoint.appName
      })
    }), /*#__PURE__*/_jsx(Button, {
      size: "small",
      sx: {
        mt: 1
      },
      onClick: handleOpenUrl,
      variant: "contained",
      color: "success",
      children: t('common.visitTarget', {
        name: endpoint.appName
      })
    })]
  });
}
UploadedToast.propTypes = {
  endpoint: PropTypes.object.isRequired,
  published: PropTypes.bool.isRequired
};
export default UploadedToast;