import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  useCreatePreview
} from "./chunk-JHA55BW5.js";
import {
  DeploymentStatus
} from "./chunk-QVQMIH5X.js";
import "./chunk-22SU6O2P.js";
import "./chunk-MYWHJYA3.js";
import "./chunk-BSHLAJFZ.js";
import "./chunk-4EUYO6LF.js";
import "./chunk-DZ3U3XXP.js";
import "./chunk-4HM4GXIT.js";
import "./chunk-MK2ZHK32.js";
import "./chunk-526J7NQD.js";
import "./chunk-XCIXZDFH.js";
import "./chunk-QRGKMYDD.js";
import "./chunk-HEKVXBWZ.js";
import "./chunk-JJWBWHWO.js";
import "./chunk-YTGCPERW.js";
import {
  ErrorViewer
} from "./chunk-VZ3FZHJK.js";
import "./chunk-OWRWPLVG.js";
import {
  Trans
} from "./chunk-CIOBCAOI.js";
import "./chunk-RPTAJN5Y.js";
import {
  Alert,
  Badge,
  Box_default,
  Link,
  Spinner,
  useAsync
} from "./chunk-2DKXIL7C.js";
import {
  require_react
} from "./chunk-7ZOEVDW3.js";
import "./chunk-AFPDHQYI.js";
import "./chunk-HYKBBZLS.js";
import "./chunk-C5RTKQVL.js";
import "./chunk-LFX6WS3B.js";
import "./chunk-XTVDTH5G.js";
import "./chunk-TMZBOD2B.js";
import "./chunk-DR2IE2NL.js";
import "./chunk-JWVFFICN.js";
import "./chunk-YRSNPU5L.js";
import {
  require_lib
} from "./chunk-PIOT47FJ.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-site/src/components/PreviewCommand/PreviewCommand.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
var import_variant = __toESM(require_lib(), 1);
var PreviewCommand = ({ force }) => {
  const createPreview = useCreatePreview();
  const { status } = useAsync(async () => {
    const { previewUrl, deploymentStatus } = await createPreview();
    if (!force && (0, import_variant.isType)(deploymentStatus, DeploymentStatus.Error)) {
      throw deploymentStatus.deploymentError;
    }
    return { previewUrl, deploymentStatus };
  }, []);
  return (0, import_variant.match)(status, {
    Error: () => null,
    Loading: () => /* @__PURE__ */ import_react.default.createElement(Spinner, { text: /* @__PURE__ */ import_react.default.createElement(Trans, { i18nKey: "preview_command.loading" }) }),
    Success: ({ result: { previewUrl, deploymentStatus } }) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, (0, import_variant.isType)(deploymentStatus, DeploymentStatus.Error) ? /* @__PURE__ */ import_react.default.createElement(Box_default, { marginBottom: 1, flexDirection: "column" }, /* @__PURE__ */ import_react.default.createElement(ErrorViewer, { error: deploymentStatus.deploymentError })) : null, /* @__PURE__ */ import_react.default.createElement(Alert, { type: "success" }, /* @__PURE__ */ import_react.default.createElement(Badge, { skin: "success" }, /* @__PURE__ */ import_react.default.createElement(Trans, { i18nKey: "general.success" })), " ", /* @__PURE__ */ import_react.default.createElement(
      Trans,
      {
        i18nKey: "preview_command.success",
        components: [/* @__PURE__ */ import_react.default.createElement(Link, { url: previewUrl })]
      }
    )))
  });
};
export {
  PreviewCommand
};
//# sourceMappingURL=PreviewCommand-Q67HDEB3.js.map