"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 PromptAddChoice_exports = {};
__export(PromptAddChoice_exports, {
  default: () => PromptAddChoice_default
});
module.exports = __toCommonJS(PromptAddChoice_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = require("react");
var import_ink = require("ink");
var import_BaseSelector = require("../base/BaseSelector.js");
const CHOICES = [
  {
    id: "agent",
    scope: "agent",
    label: "For this agent only",
    description: "Stored in agent config directory",
    recommended: true
  },
  {
    id: "shared",
    scope: "shared",
    label: "For all agents (shared)",
    description: "Stored in ~/.dexto/commands/"
  }
];
const PromptAddChoice = (0, import_react.forwardRef)(
  function PromptAddChoice2({ isVisible, onSelect, onClose }, ref) {
    const baseSelectorRef = (0, import_react.useRef)(null);
    const [selectedIndex, setSelectedIndex] = (0, import_react.useState)(0);
    (0, import_react.useEffect)(() => {
      if (isVisible) {
        setSelectedIndex(0);
      }
    }, [isVisible]);
    (0, import_react.useImperativeHandle)(
      ref,
      () => ({
        handleInput: (input, key) => {
          return baseSelectorRef.current?.handleInput(input, key) ?? false;
        }
      }),
      []
    );
    const formatItem = (item, isSelected) => {
      return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: isSelected ? "cyan" : "white", bold: isSelected, children: item.label }),
        item.recommended && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: isSelected ? "green" : "gray", children: " (Recommended)" }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
          " \xB7 ",
          item.description
        ] })
      ] });
    };
    const handleSelect = (item) => {
      onSelect(item.scope);
    };
    return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      import_BaseSelector.BaseSelector,
      {
        ref: baseSelectorRef,
        items: CHOICES,
        isVisible,
        selectedIndex,
        onSelectIndex: setSelectedIndex,
        onSelect: handleSelect,
        onClose,
        formatItem,
        title: "Add Prompt",
        borderColor: "yellowBright",
        emptyMessage: "No options available"
      }
    );
  }
);
var PromptAddChoice_default = PromptAddChoice;
