"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var StatusBar_exports = {};
__export(StatusBar_exports, {
  StatusBar: () => StatusBar
});
module.exports = __toCommonJS(StatusBar_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_ink = require("ink");
var import_usePhraseCycler = require("../hooks/usePhraseCycler.js");
var import_useElapsedTime = require("../hooks/useElapsedTime.js");
var import_useTokenCounter = require("../hooks/useTokenCounter.js");
var import_useAnimationTick = require("../hooks/useAnimationTick.js");
var import_spinnerFrames = require("../constants/spinnerFrames.js");
function StatusSpinner({ enabled, color }) {
  const tick = (0, import_useAnimationTick.useAnimationTick)({ enabled, intervalMs: 80 });
  const frame = import_spinnerFrames.BRAILLE_SPINNER_FRAMES[tick % import_spinnerFrames.BRAILLE_SPINNER_FRAMES.length];
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color, children: frame });
}
function StatusBar({
  agent,
  isProcessing,
  isThinking,
  isCompacting,
  approvalQueueCount,
  copyModeEnabled = false,
  isAwaitingApproval = false,
  todoExpanded = true,
  hasTodos = false,
  planModeActive = false,
  autoApproveEdits = false,
  backgroundTasksRunning = 0
}) {
  const animationsActive = isProcessing && !isAwaitingApproval && !copyModeEnabled;
  const { phrase } = (0, import_usePhraseCycler.usePhraseCycler)({ isActive: animationsActive && !isCompacting });
  const { formatted: elapsedTime, elapsedMs } = (0, import_useElapsedTime.useElapsedTime)({
    isActive: animationsActive,
    intervalMs: 1e3
  });
  const { formatted: tokenCount } = (0, import_useTokenCounter.useTokenCounter)({ agent, isActive: animationsActive });
  const showTime = elapsedMs >= 3e4;
  if (copyModeEnabled) {
    return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Box, { paddingX: 1, marginBottom: 0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "yellowBright", bold: true, children: "\u{1F4CB} Copy Mode - Select text with mouse. Press any key to exit." }) });
  }
  if (!isProcessing) {
    return null;
  }
  if (isAwaitingApproval) {
    return null;
  }
  const todoHint = hasTodos ? todoExpanded ? "ctrl+t to hide todos" : "ctrl+t to show todos" : null;
  const backgroundHint = backgroundTasksRunning > 0 ? "ctrl+b to view bg tasks" : null;
  if (isCompacting) {
    const metaParts2 = [];
    if (showTime) metaParts2.push(`(${elapsedTime})`);
    if (backgroundTasksRunning > 0) {
      metaParts2.push(
        `${backgroundTasksRunning} bg task${backgroundTasksRunning > 1 ? "s" : ""}`
      );
    }
    if (backgroundHint) metaParts2.push(backgroundHint);
    metaParts2.push("Esc to cancel");
    if (todoHint) metaParts2.push(todoHint);
    const metaContent2 = metaParts2.join(" \u2022 ");
    return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { paddingX: 1, marginTop: 1, flexDirection: "column", children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "row", alignItems: "center", children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusSpinner, { enabled: true, color: "yellow" }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "yellow", children: " \u{1F4E6} Compacting context..." })
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Box, { marginLeft: 2, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "gray", children: metaContent2 }) })
    ] });
  }
  if (isThinking) {
    const metaParts2 = [];
    if (showTime) metaParts2.push(`(${elapsedTime})`);
    if (tokenCount) metaParts2.push(tokenCount);
    if (backgroundTasksRunning > 0) {
      metaParts2.push(
        `${backgroundTasksRunning} bg task${backgroundTasksRunning > 1 ? "s" : ""}`
      );
    }
    if (backgroundHint) metaParts2.push(backgroundHint);
    metaParts2.push("Esc to cancel");
    if (todoHint) metaParts2.push(todoHint);
    const metaContent2 = metaParts2.join(" \u2022 ");
    return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { paddingX: 1, marginTop: 1, flexDirection: "column", children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "row", alignItems: "center", children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusSpinner, { enabled: true, color: "green" }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "green", children: [
          " ",
          phrase
        ] })
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Box, { marginLeft: 2, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "gray", children: metaContent2 }) })
    ] });
  }
  const metaParts = [];
  if (showTime) metaParts.push(`(${elapsedTime})`);
  if (tokenCount) metaParts.push(tokenCount);
  if (backgroundTasksRunning > 0) {
    metaParts.push(`${backgroundTasksRunning} bg task${backgroundTasksRunning > 1 ? "s" : ""}`);
  }
  if (backgroundHint) metaParts.push(backgroundHint);
  metaParts.push("Esc to cancel");
  if (todoHint) metaParts.push(todoHint);
  const metaContent = metaParts.join(" \u2022 ");
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { paddingX: 1, marginTop: 1, flexDirection: "column", children: [
    /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "row", alignItems: "center", children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusSpinner, { enabled: true, color: "green" }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "green", children: [
        " ",
        phrase
      ] }),
      approvalQueueCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "yellowBright", children: [
        " \u2022 ",
        approvalQueueCount,
        " queued"
      ] })
    ] }),
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Box, { marginLeft: 2, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "gray", children: metaContent }) })
  ] });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  StatusBar
});
