import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  PreviewCommand
} from "./chunk-2LIAUACY.js";
import {
  useDevCenterOverridesClient
} from "./chunk-ZY6UYJ7A.js";
import "./chunk-VS2OAVVQ.js";
import "./chunk-ICWL3WXV.js";
import "./chunk-R5WNFZTS.js";
import "./chunk-RFWFU5ZV.js";
import "./chunk-C7TVBDR6.js";
import "./chunk-KDZXPOOF.js";
import "./chunk-QRGKMYDD.js";
import "./chunk-I2LFFO2M.js";
import "./chunk-KUSCYV4K.js";
import "./chunk-NMCF7XG5.js";
import "./chunk-MHV22UIU.js";
import {
  useProjectModel
} from "./chunk-BYP4JZFS.js";
import "./chunk-AAUVYJJT.js";
import "./chunk-K6JLY75P.js";
import "./chunk-BRX4HWJE.js";
import "./chunk-ZBFOAJ5H.js";
import "./chunk-YNEGRO3E.js";
import "./chunk-YHFCDWGT.js";
import "./chunk-IVQPYJ5M.js";
import "./chunk-MDUBZZTI.js";
import "./chunk-RPTAJN5Y.js";
import {
  Alert,
  Box_default,
  Spinner,
  Text,
  useAsyncCallback
} from "./chunk-QK47PIWK.js";
import {
  require_react
} from "./chunk-TODKQSCF.js";
import "./chunk-AFPDHQYI.js";
import "./chunk-HYKBBZLS.js";
import "./chunk-C5RTKQVL.js";
import "./chunk-DGJS6KZB.js";
import "./chunk-YT5BPQDJ.js";
import "./chunk-LU3R3EBR.js";
import "./chunk-XZUGLEBK.js";
import "./chunk-AYCGCYN3.js";
import "./chunk-SDLCFZRL.js";
import {
  require_lib
} from "./chunk-WGV2XQSB.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-UFYFN2YK.js.map