import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  useBackendAsAServiceClient
} from "./chunk-FEA7FYAB.js";
import {
  useProjectModel
} from "./chunk-RDF2RA4E.js";
import "./chunk-WFQIXGJV.js";
import "./chunk-ECBO3UFC.js";
import "./chunk-YNEGRO3E.js";
import {
  SiteAuthProvider
} from "./chunk-HWT3LUJJ.js";
import "./chunk-TOBTRYZF.js";
import "./chunk-7WVNO7VU.js";
import "./chunk-RPTAJN5Y.js";
import {
  Alert,
  Spinner,
  useAsync
} from "./chunk-YL4347CI.js";
import {
  require_react
} from "./chunk-TODKQSCF.js";
import "./chunk-AFPDHQYI.js";
import "./chunk-HYKBBZLS.js";
import "./chunk-C5RTKQVL.js";
import "./chunk-SVUXJRFD.js";
import "./chunk-YT5BPQDJ.js";
import "./chunk-LU3R3EBR.js";
import "./chunk-XZUGLEBK.js";
import "./chunk-VASURI4S.js";
import "./chunk-SDLCFZRL.js";
import {
  require_lib
} from "./chunk-MTT3QXBC.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-astro-commands/src/components/EnvSetCommand/index.ts
init_esm_shims();

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

// ../cli-astro-commands/src/components/EnvSetCommand/EnvSet.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
var import_variant = __toESM(require_lib(), 1);
var ENV_NAME = "prod";
var EnvSet = ({
  variable
}) => {
  const { model } = useProjectModel();
  const backendAsAServiceClient = useBackendAsAServiceClient();
  const { status } = useAsync(async () => {
    await backendAsAServiceClient.upsertAppEnvironment(
      model.config.appId,
      ENV_NAME,
      {
        [variable.key]: variable.value
      }
    );
  }, []);
  return (0, import_variant.match)(status, {
    Loading: () => /* @__PURE__ */ import_react.default.createElement(Spinner, { text: "Setting environment variable..." }),
    Success: () => /* @__PURE__ */ import_react.default.createElement(Alert, { type: "success" }, '"', variable.key, '" was successfully set'),
    Error: () => null,
    NotRequested: () => null
  });
};

// ../cli-astro-commands/src/components/EnvSetCommand/EnvSetCommand.tsx
var EnvSetCommand = ({ variable }) => {
  const {
    model: { config }
  } = useProjectModel();
  let commandTree = /* @__PURE__ */ import_react2.default.createElement(EnvSet, { variable });
  if (config.projectType === "Site") {
    commandTree = /* @__PURE__ */ import_react2.default.createElement(SiteAuthProvider, { siteId: config.siteId }, commandTree);
  }
  return commandTree;
};
export {
  EnvSetCommand
};
//# sourceMappingURL=EnvSetCommand-MTE6RTNV.js.map