// @bun
import {
  ConfigurableShortcutHint,
  estimateSkillFrontmatterTokens,
  getCommandName,
  init_ConfigurableShortcutHint,
  init_commands1 as init_commands,
  init_loadSkillsDir
} from "./chunk-e91vvygt.js";
import"./chunk-k60b56gr.js";
import"./chunk-14p6wvsq.js";
import"./chunk-n66h7gtd.js";
import"./chunk-28jd8qjx.js";
import"./chunk-djt39ze3.js";
import"./chunk-9a9g5hbj.js";
import"./chunk-ptxteaeh.js";
import"./chunk-ftrj0crk.js";
import"./chunk-yrpthe2x.js";
import"./chunk-10fpzkhd.js";
import"./chunk-awz3dq2e.js";
import"./chunk-2tabctw9.js";
import"./chunk-z21x0z3h.js";
import"./chunk-9hn8e6h1.js";
import"./chunk-rgyzsbs3.js";
import"./chunk-qn6me9n1.js";
import"./chunk-9rwstxn3.js";
import"./chunk-td4ter5p.js";
import"./chunk-71sdcaq6.js";
import"./chunk-cb6yemrf.js";
import"./chunk-tj8te4np.js";
import"./chunk-jjh8y2m7.js";
import"./chunk-dr2x4ze7.js";
import"./chunk-8ad8jmrf.js";
import"./chunk-24kv69g3.js";
import"./chunk-68n1gfc7.js";
import"./chunk-1w7c5hws.js";
import"./chunk-4gyjc4jm.js";
import"./chunk-4spgkgr3.js";
import"./chunk-e8dhxycp.js";
import"./chunk-hf0jvnz1.js";
import"./chunk-9pygs2bc.js";
import"./chunk-60fkafk2.js";
import"./chunk-gaazk5m4.js";
import"./chunk-vgmsapsy.js";
import"./chunk-093ej2sf.js";
import"./chunk-7tfdhkpy.js";
import"./chunk-nde5ym6a.js";
import"./chunk-zypcr179.js";
import"./chunk-etcs82b2.js";
import"./chunk-7wy0nfkf.js";
import"./chunk-1emjj9xz.js";
import"./chunk-m1hz377a.js";
import"./chunk-4nctdw69.js";
import"./chunk-vhghhw4q.js";
import"./chunk-935nrvdb.js";
import"./chunk-8zz4z1q3.js";
import"./chunk-hdwp8fte.js";
import"./chunk-hqxp6b72.js";
import"./chunk-3cwfww0q.js";
import"./chunk-xqc9bbe3.js";
import"./chunk-w5hnghah.js";
import"./chunk-qm7pdcft.js";
import"./chunk-x59e8cv0.js";
import"./chunk-s76nvx50.js";
import"./chunk-7jyr5758.js";
import {
  getSettingSourceName,
  init_constants,
  init_stringUtils,
  plural
} from "./chunk-zrpa39fh.js";
import"./chunk-nkg1b3qw.js";
import"./chunk-c1kx8bry.js";
import"./chunk-epvbnq43.js";
import"./chunk-swgt1px0.js";
import"./chunk-8kf8h7xf.js";
import"./chunk-swz6krys.js";
import"./chunk-7eywm3ed.js";
import"./chunk-bgan4cpf.js";
import"./chunk-jmv7k0jn.js";
import"./chunk-25w7rxtr.js";
import"./chunk-5xfj4jkd.js";
import"./chunk-c1t99xmt.js";
import"./chunk-vwenx8ke.js";
import"./chunk-8thwr7p8.js";
import"./chunk-v4ypszbb.js";
import"./chunk-bk6ck5c2.js";
import"./chunk-ym6j0wv1.js";
import"./chunk-hjmatcgt.js";
import"./chunk-6mdh70q0.js";
import"./chunk-ch92ycde.js";
import"./chunk-e4dsy4g1.js";
import"./chunk-326zehp8.js";
import"./chunk-kc67kt75.js";
import"./chunk-40t1d75v.js";
import"./chunk-rt34thxn.js";
import"./chunk-e3abfxpy.js";
import"./chunk-q44zc68f.js";
import"./chunk-fejeqe61.js";
import {
  formatTokens,
  init_format
} from "./chunk-kgkdmr0x.js";
import"./chunk-hn4w9pkj.js";
import {
  Dialog,
  FuzzyPicker,
  ThemedBox_default,
  ThemedText,
  init_src,
  require_react
} from "./chunk-cswpvb8x.js";
import {
  require_jsx_runtime
} from "./chunk-gxyx8b8w.js";
import"./chunk-j1mep9ck.js";
import"./chunk-6x35ffpx.js";
import"./chunk-1zbwhcbt.js";
import"./chunk-ddaxg4xh.js";
import"./chunk-vvh31np8.js";
import"./chunk-tywrrc1m.js";
import"./chunk-e3j7m7k2.js";
import"./chunk-4p0hxk2c.js";
import"./chunk-c4dyxsat.js";
import"./chunk-34rn09za.js";
import"./chunk-m28vg9w4.js";
import"./chunk-rk9fgqmg.js";
import"./chunk-nw4zt0y4.js";
import"./chunk-c1yc761e.js";
import"./chunk-c5g9shkw.js";
import"./chunk-k9jzhhww.js";
import"./chunk-kb3758f7.js";
import"./chunk-xqs9r7pg.js";
import"./chunk-tj0dzck2.js";
import"./chunk-aeysytks.js";
import"./chunk-ns1htxgd.js";
import"./chunk-ztqzmfx1.js";
import"./chunk-6k1rsk85.js";
import"./chunk-nxzx0ey9.js";
import"./chunk-yes1my80.js";
import"./chunk-pecy49yr.js";
import"./chunk-azbab59e.js";
import"./chunk-3nk9q8dr.js";
import {
  __esm,
  __toESM
} from "./chunk-hhsxm2yr.js";

// src/components/skills/filterSkills.ts
function filterSkills(skills, query) {
  const trimmed = query.trim();
  if (trimmed === "") {
    return skills.slice();
  }
  const words = trimmed.toLowerCase().split(/\s+/);
  return skills.filter((skill) => {
    const haystack = `${skill.name} ${skill.description}`.toLowerCase();
    return words.every((word) => haystack.includes(word));
  });
}
var init_filterSkills = () => {};

// src/components/skills/SkillsMenu.tsx
function getSourceLabel(source) {
  if (source === "plugin")
    return "plugin";
  if (source === "mcp")
    return "mcp";
  return getSettingSourceName(source);
}
function SkillsMenu({ onExit, commands }) {
  const [searchQuery, setSearchQuery] = import_react.useState("");
  const skills = import_react.useMemo(() => {
    return commands.filter((cmd) => cmd.type === "prompt" && (cmd.loadedFrom === "skills" || cmd.loadedFrom === "commands_DEPRECATED" || cmd.loadedFrom === "plugin" || cmd.loadedFrom === "mcp"));
  }, [commands]);
  const filteredSkills = import_react.useMemo(() => {
    return filterSkills(skills.map((s) => ({
      ...s,
      name: getCommandName(s),
      description: s.description ?? ""
    })), searchQuery);
  }, [skills, searchQuery]);
  const skillsBySource = import_react.useMemo(() => {
    const groups = {
      policySettings: [],
      userSettings: [],
      projectSettings: [],
      localSettings: [],
      flagSettings: [],
      plugin: [],
      mcp: []
    };
    for (const skill of filteredSkills) {
      const source = skill.source;
      if (source in groups) {
        groups[source].push(skill);
      }
    }
    for (const group of Object.values(groups)) {
      group.sort((a, b) => getCommandName(a).localeCompare(getCommandName(b)));
    }
    return groups;
  }, [filteredSkills]);
  const handleCancel = () => {
    onExit("Skills dialog dismissed", { display: "system" });
  };
  if (skills.length === 0) {
    return /* @__PURE__ */ jsx_runtime.jsxs(Dialog, {
      title: "Skills",
      subtitle: "No skills found",
      onCancel: handleCancel,
      hideInputGuide: true,
      children: [
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          dimColor: true,
          children: "Create skills in .claude/skills/ or ~/.claude/skills/"
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          dimColor: true,
          italic: true,
          children: /* @__PURE__ */ jsx_runtime.jsx(ConfigurableShortcutHint, {
            action: "confirm:no",
            context: "Confirmation",
            fallback: "Esc",
            description: "close"
          })
        })
      ]
    });
  }
  const getScopeTag = (source) => {
    switch (source) {
      case "projectSettings":
      case "localSettings":
        return { label: "local", color: "yellow" };
      case "userSettings":
        return { label: "global", color: "cyan" };
      case "policySettings":
        return { label: "managed", color: "magenta" };
      default:
        return;
    }
  };
  const renderSkillItem = (skill, isFocused) => {
    const estimatedTokens = estimateSkillFrontmatterTokens(skill);
    const tokenDisplay = `~${formatTokens(estimatedTokens)}`;
    const pluginName = skill.source === "plugin" ? skill.pluginInfo?.pluginManifest.name : undefined;
    const scopeTag = getScopeTag(skill.source);
    return /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
      children: [
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          color: isFocused ? "suggestion" : undefined,
          children: getCommandName(skill)
        }),
        scopeTag && /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
          color: scopeTag.color,
          children: [
            " [",
            scopeTag.label,
            "]"
          ]
        }),
        /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
          dimColor: true,
          children: [
            pluginName ? ` \xB7 ${pluginName}` : "",
            " \xB7 ",
            getSourceLabel(skill.source),
            " \xB7 ",
            tokenDisplay,
            " tokens"
          ]
        })
      ]
    });
  };
  const orderedFilteredSkills = import_react.useMemo(() => {
    return ORDERED_SOURCES.flatMap((source) => skillsBySource[source]);
  }, [skillsBySource]);
  const subtitle = searchQuery.trim() === "" ? `${skills.length} ${plural(skills.length, "skill")}` : `${filteredSkills.length}/${skills.length} ${plural(skills.length, "skill")}`;
  return /* @__PURE__ */ jsx_runtime.jsx(FuzzyPicker, {
    title: "Skills",
    placeholder: "Type to filter skills\u2026",
    items: orderedFilteredSkills,
    getKey: (s) => `${s.name}-${s.source}`,
    visibleCount: 12,
    direction: "down",
    onQueryChange: setSearchQuery,
    onSelect: (skill) => {
      onExit(`/${getCommandName(skill)}`, { display: "user" });
    },
    onCancel: handleCancel,
    emptyMessage: (q) => q.trim() ? `No skills matching "${q.trim()}"` : "No skills found",
    matchLabel: subtitle,
    selectAction: "invoke skill",
    renderItem: (skill, isFocused) => renderSkillItem(skill, isFocused)
  });
}
var import_react, jsx_runtime, ORDERED_SOURCES;
var init_SkillsMenu = __esm(() => {
  init_commands();
  init_src();
  init_loadSkillsDir();
  init_format();
  init_constants();
  init_stringUtils();
  init_ConfigurableShortcutHint();
  init_src();
  init_filterSkills();
  import_react = __toESM(require_react(), 1);
  jsx_runtime = __toESM(require_jsx_runtime(), 1);
  ORDERED_SOURCES = [
    "projectSettings",
    "localSettings",
    "userSettings",
    "flagSettings",
    "policySettings",
    "plugin",
    "mcp"
  ];
});

// src/commands/skills/skills.tsx
async function call(onDone, context) {
  return /* @__PURE__ */ jsx_runtime2.jsx(SkillsMenu, {
    onExit: onDone,
    commands: context.options.commands
  });
}
var jsx_runtime2;
var init_skills = __esm(() => {
  init_SkillsMenu();
  jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
});
init_skills();

export {
  call
};

//# debugId=C3F355BADA6EFD4664756E2164756E21
//# sourceMappingURL=chunk-66384w8v.js.map
