import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  usePlatform
} from "./chunk-NUHN5M5Q.js";
import {
  useResolveDashboardExtensionUrl,
  useResolvePlatformUrl,
  useSite
} from "./chunk-D7O6F2SQ.js";
import {
  PlatformType,
  getAppBuildFolder,
  getAppManifestPath,
  pathExists,
  useExtensions
} from "./chunk-UVMRGZ5H.js";
import {
  Box_default,
  CliError,
  CliErrorCode,
  Link,
  PointerSmallIcon,
  Text,
  Trans,
  require_react,
  useTranslation
} from "./chunk-32MMFZ46.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-PYIAC2GK.js";

// src/files/assert-build-output-exists.ts
init_esm_shims();
async function assertBuildOutputExists(projectFolder) {
  const buildFolder = getAppBuildFolder(projectFolder);
  const manifestPath = getAppManifestPath(projectFolder);
  if (!await pathExists(buildFolder) || !await pathExists(manifestPath)) {
    throw new CliError({
      code: CliErrorCode.BuiltProjectNeeded(),
      cause: null
    });
  }
}

// src/components/Platform/PlatformViewer.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
var PlatformLink = ({
  url,
  label,
  withPointer = true
}) => {
  return /* @__PURE__ */ import_react.default.createElement(Box_default, null, /* @__PURE__ */ import_react.default.createElement(Box_default, { marginRight: 1 }, withPointer && /* @__PURE__ */ import_react.default.createElement(PointerSmallIcon, null), /* @__PURE__ */ import_react.default.createElement(Box_default, { marginLeft: 1 }, /* @__PURE__ */ import_react.default.createElement(Link, { url }, label))));
};
var PlatformViewer = () => {
  const { t } = useTranslation();
  const { isPlatformExists, hasSinglePlatform } = usePlatform();
  const { dashboardExtensions } = useExtensions();
  const { site } = useSite();
  const resolvePlatformUrl = useResolvePlatformUrl();
  const resolveDashboardExtensionUrl = useResolveDashboardExtensionUrl();
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, hasSinglePlatform(PlatformType.Dashboard()) ? /* @__PURE__ */ import_react.default.createElement(Box_default, { flexDirection: "row" }, /* @__PURE__ */ import_react.default.createElement(Trans, { i18nKey: "general.open_preview.title_single" }), /* @__PURE__ */ import_react.default.createElement(
    PlatformLink,
    {
      withPointer: false,
      url: resolveDashboardExtensionUrl(dashboardExtensions[0]),
      label: t("general.platform.dashboard")
    }
  )) : /* @__PURE__ */ import_react.default.createElement(Box_default, { flexDirection: "column" }, /* @__PURE__ */ import_react.default.createElement(Trans, { i18nKey: "general.open_preview.title_multiple" }), /* @__PURE__ */ import_react.default.createElement(Box_default, { paddingLeft: 2, flexDirection: "column" }, isPlatformExists(PlatformType.Site()) && (site.viewUrl ? /* @__PURE__ */ import_react.default.createElement(
    PlatformLink,
    {
      url: resolvePlatformUrl(PlatformType.Site()),
      label: t("general.platform.site")
    }
  ) : /* @__PURE__ */ import_react.default.createElement(Box_default, { marginRight: 1 }, /* @__PURE__ */ import_react.default.createElement(PointerSmallIcon, null), /* @__PURE__ */ import_react.default.createElement(Box_default, { marginLeft: 1 }, /* @__PURE__ */ import_react.default.createElement(Text, { skin: "secondary", underline: true }, t("general.platform.unpublished_site"))))), isPlatformExists(PlatformType.Editor()) && /* @__PURE__ */ import_react.default.createElement(
    PlatformLink,
    {
      url: resolvePlatformUrl(PlatformType.Editor()),
      label: t("general.platform.editor")
    }
  ), isPlatformExists(PlatformType.Dashboard()) && /* @__PURE__ */ import_react.default.createElement(
    PlatformLink,
    {
      url: resolveDashboardExtensionUrl(dashboardExtensions[0]),
      label: t("general.platform.dashboard")
    }
  ))));
};

export {
  assertBuildOutputExists,
  PlatformViewer
};
//# sourceMappingURL=chunk-O6WUNJLD.js.map