import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  PreviewCommand
} from "./chunk-JK5XXAQX.js";
import {
  useDevCenterOverridesClient
} from "./chunk-JKVSR6GG.js";
import "./chunk-X3JDCNCM.js";
import "./chunk-T6BKE35X.js";
import "./chunk-QTQWEMSZ.js";
import "./chunk-MK2ZHK32.js";
import "./chunk-526J7NQD.js";
import "./chunk-XCIXZDFH.js";
import "./chunk-QRGKMYDD.js";
import "./chunk-HEKVXBWZ.js";
import "./chunk-K72QYUHN.js";
import "./chunk-WSX7GEXO.js";
import "./chunk-MHV22UIU.js";
import "./chunk-IBOXARGJ.js";
import {
  useProjectModel
} from "./chunk-XJE267QM.js";
import "./chunk-AAUVYJJT.js";
import "./chunk-K6JLY75P.js";
import "./chunk-JJWBWHWO.js";
import "./chunk-YTGCPERW.js";
import "./chunk-VZ3FZHJK.js";
import "./chunk-OWRWPLVG.js";
import "./chunk-CIOBCAOI.js";
import "./chunk-RPTAJN5Y.js";
import {
  Alert,
  Box_default,
  Spinner,
  Text,
  useAsyncCallback
} 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-astro-commands/src/components/PromoteCommand/index.ts
init_esm_shims();

// ../cli-astro-commands/src/components/PromoteCommand/PromoteCommand.tsx
init_esm_shims();
var import_react2 = __toESM(require_react(), 1);
var import_variant = __toESM(require_lib(), 1);

// ../cli-astro-commands/src/components/PromoteCommand/Steps/CreatePreview.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
var CreatePreview = (props) => {
  const { baseUrl, label, onCreated } = props;
  return /* @__PURE__ */ import_react.default.createElement(Box_default, { flexDirection: "column", gap: 1 }, /* @__PURE__ */ import_react.default.createElement(Text, null, "Before promoting, let's create a preview of your app"), /* @__PURE__ */ import_react.default.createElement(Box_default, { flexDirection: "column" }, /* @__PURE__ */ import_react.default.createElement(
    PreviewCommand,
    {
      baseUrl,
      label,
      onPreviewCreated: onCreated,
      environment: "preview"
    }
  )));
};

// ../cli-astro-commands/src/components/PromoteCommand/PromoteCommand.tsx
var PromoteCommand = ({ baseUrl, label }) => {
  const {
    model: {
      config: { appId }
    }
  } = useProjectModel();
  const devCenterOverrides = useDevCenterOverridesClient();
  const promoteAction = useAsyncCallback(async (_, tag) => {
    await devCenterOverrides.createDraftVersion(appId, tag);
  });
  function onPreviewCreated({ previewId }) {
    return promoteAction.execute(previewId);
  }
  return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(
    CreatePreview,
    {
      baseUrl,
      label,
      onCreated: onPreviewCreated
    }
  ), (0, import_variant.match)(promoteAction.status, {
    Loading: () => /* @__PURE__ */ import_react2.default.createElement(Spinner, { text: `Promoting app draft...` }),
    Success: () => /* @__PURE__ */ import_react2.default.createElement(Alert, { type: "success" }, "App draft promoted successfully"),
    Error: () => null,
    NotRequested: () => null
  }));
};
export {
  PromoteCommand
};
//# sourceMappingURL=PromoteCommand-EHZ7IGKT.js.map