import { jsx, jsxs } from "react/jsx-runtime";
import { forwardRef, useImperativeHandle } from "react";
import { Box, Text } from "ink";
import { getChatGPTRateLimitHint } from "../../utils/chatgpt-rate-limit.js";
const ChatGPTUsageCapOverlay = forwardRef(function ChatGPTUsageCapOverlay2({
  isVisible,
  currentModelDisplayName,
  fallbackModelDisplayName,
  usedDefaultFallback,
  apiKeyConfigured,
  status,
  onConfirm,
  onClose
}, ref) {
  useImperativeHandle(
    ref,
    () => ({
      handleInput: (_input, key) => {
        if (!isVisible) {
          return false;
        }
        if (key.escape) {
          onClose();
          return true;
        }
        if (key.return) {
          onConfirm();
          return true;
        }
        return true;
      }
    }),
    [isVisible, onClose, onConfirm]
  );
  if (!isVisible) {
    return null;
  }
  const actionLabel = apiKeyConfigured ? `Switch this session to ${fallbackModelDisplayName} via OpenAI API key` : `Add an OpenAI API key and switch this session to ${fallbackModelDisplayName}`;
  return /* @__PURE__ */ jsxs(
    Box,
    {
      flexDirection: "column",
      borderStyle: "round",
      borderColor: "yellow",
      paddingX: 1,
      marginTop: 1,
      children: [
        /* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { bold: true, color: "yellowBright", children: "ChatGPT usage cap reached" }) }),
        status && /* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { color: "gray", children: getChatGPTRateLimitHint(status) }) }),
        /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
          /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
            currentModelDisplayName,
            " is currently running through ChatGPT Login."
          ] }),
          /* @__PURE__ */ jsx(Text, { children: actionLabel })
        ] }),
        usedDefaultFallback && /* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
          "The current ChatGPT model is not available through the OpenAI API path, so Dexto will use ",
          fallbackModelDisplayName,
          " for this session."
        ] }) }),
        /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { color: "gray", children: "Enter to continue \u2022 Esc to dismiss" }) })
      ]
    }
  );
});
var ChatGPTUsageCapOverlay_default = ChatGPTUsageCapOverlay;
export {
  ChatGPTUsageCapOverlay_default as default
};
