// @bun
import {
  init_launchCommand,
  launchCommand
} from "./chunk-n2nc3x52.js";
import {
  TextInput,
  deleteSecret,
  getSecret,
  init_TextInput,
  init_localValidate,
  init_store1 as init_store,
  isValidKey,
  listKeys,
  maskSecret,
  setSecret
} from "./chunk-4vz571bb.js";
import"./chunk-14p6wvsq.js";
import"./chunk-8hseq8b1.js";
import"./chunk-ddtxq6k5.js";
import"./chunk-28jd8qjx.js";
import"./chunk-djt39ze3.js";
import"./chunk-ptxteaeh.js";
import"./chunk-wd53a7m4.js";
import"./chunk-hms8ge0k.js";
import"./chunk-whpphypt.js";
import"./chunk-pht800m5.js";
import"./chunk-pjkqh1kq.js";
import"./chunk-9a9g5hbj.js";
import"./chunk-9hn8e6h1.js";
import"./chunk-rgyzsbs3.js";
import"./chunk-qn6me9n1.js";
import"./chunk-qd3r2s2n.js";
import"./chunk-djzd7tef.js";
import"./chunk-gyhnpbkx.js";
import"./chunk-71sdcaq6.js";
import"./chunk-60gf7p5s.js";
import"./chunk-sj3d0nqx.js";
import"./chunk-9pk9rk2w.js";
import"./chunk-javpza6a.js";
import"./chunk-6v7bre98.js";
import"./chunk-24kv69g3.js";
import"./chunk-fcqebw9m.js";
import"./chunk-dnfd3c9s.js";
import"./chunk-15ezj4ww.js";
import"./chunk-1h284c6e.js";
import"./chunk-582g9yce.js";
import"./chunk-y3ztgztb.js";
import"./chunk-4spgkgr3.js";
import"./chunk-n8kbhswc.js";
import"./chunk-60fkafk2.js";
import"./chunk-fgbkrbk3.js";
import"./chunk-ssw61jfd.js";
import"./chunk-093ej2sf.js";
import"./chunk-7tfdhkpy.js";
import"./chunk-nde5ym6a.js";
import"./chunk-k8wq4qsj.js";
import"./chunk-g7d3xx1p.js";
import"./chunk-3wrx2943.js";
import"./chunk-7p9kkh0f.js";
import"./chunk-qp8cgz66.js";
import"./chunk-1mg610h2.js";
import"./chunk-93hc149s.js";
import"./chunk-935nrvdb.js";
import"./chunk-8zz4z1q3.js";
import"./chunk-nnat9jw5.js";
import"./chunk-hqxp6b72.js";
import"./chunk-4jzkqgf1.js";
import"./chunk-33rd41ng.js";
import"./chunk-f257kqw9.js";
import"./chunk-w5hnghah.js";
import"./chunk-36twraxy.js";
import"./chunk-1bkvnj0y.js";
import"./chunk-akdpcc5p.js";
import"./chunk-7rrkrej7.js";
import"./chunk-6r0bxrh6.js";
import"./chunk-d6500tvx.js";
import"./chunk-jg4bw4hp.js";
import"./chunk-epvbnq43.js";
import"./chunk-tn2sx7j6.js";
import"./chunk-6tzyv21c.js";
import"./chunk-8kf8h7xf.js";
import"./chunk-bgan4cpf.js";
import"./chunk-jmv7k0jn.js";
import"./chunk-ch4pgvwq.js";
import"./chunk-99jc4tcw.js";
import"./chunk-fghczfqt.js";
import"./chunk-vwenx8ke.js";
import"./chunk-f86mwfyd.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-nt5dmk8q.js";
import"./chunk-e3abfxpy.js";
import"./chunk-q44zc68f.js";
import"./chunk-fejeqe61.js";
import"./chunk-0gp4q8aq.js";
import"./chunk-hn4w9pkj.js";
import {
  Dialog,
  ThemedBox_default,
  ThemedText,
  init_src,
  require_react,
  use_input_default
} from "./chunk-0r6npc3t.js";
import {
  require_jsx_runtime
} from "./chunk-gxyx8b8w.js";
import"./chunk-j1mep9ck.js";
import"./chunk-6x35ffpx.js";
import"./chunk-1zbwhcbt.js";
import"./chunk-t0450ma3.js";
import"./chunk-0cqw3y8h.js";
import"./chunk-k1sw7km0.js";
import"./chunk-e3j7m7k2.js";
import"./chunk-sc9ycxra.js";
import"./chunk-hhta0nge.js";
import"./chunk-8wsj9fff.js";
import"./chunk-m28vg9w4.js";
import"./chunk-f8prtxs3.js";
import"./chunk-41a6f2kv.js";
import"./chunk-c1yc761e.js";
import"./chunk-c5g9shkw.js";
import"./chunk-byd20vdq.js";
import"./chunk-kb3758f7.js";
import"./chunk-3j8w0rq8.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/commands/local-vault/LocalVaultView.tsx
function LocalVaultView(props) {
  if (props.mode === "list") {
    if (props.keys.length === 0) {
      return /* @__PURE__ */ jsx_runtime.jsx(ThemedBox_default, {
        children: /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          dimColor: true,
          children: "No secrets stored. Use /local-vault set <key> <value> to add one."
        })
      });
    }
    return /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
      flexDirection: "column",
      children: [
        /* @__PURE__ */ jsx_runtime.jsx(ThemedBox_default, {
          marginBottom: 1,
          children: /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            bold: true,
            children: [
              "Local Vault Keys (",
              props.keys.length,
              ")"
            ]
          })
        }),
        props.keys.map((k) => /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
          children: [
            /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
              children: " "
            }),
            /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
              color: "success",
              children: "\u25CF"
            }),
            /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
              children: [
                " ",
                k
              ]
            })
          ]
        }, k))
      ]
    });
  }
  if (props.mode === "set-ok") {
    return /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
      children: [
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          color: "success",
          children: "\u2713"
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          children: " Secret stored: "
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          bold: true,
          children: props.key
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          dimColor: true,
          children: " = [REDACTED]"
        })
      ]
    });
  }
  if (props.mode === "get-masked") {
    return /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
      flexDirection: "column",
      children: [
        /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
          children: [
            /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
              bold: true,
              children: props.key
            }),
            /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
              dimColor: true,
              children: ": "
            }),
            /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
              children: props.masked
            })
          ]
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedBox_default, {
          marginTop: 1,
          children: /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "Use /local-vault get ",
              props.key,
              " --reveal to see the full value."
            ]
          })
        })
      ]
    });
  }
  if (props.mode === "get-revealed") {
    return /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
      flexDirection: "column",
      children: [
        /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
          children: [
            /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
              bold: true,
              children: props.key
            }),
            /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
              dimColor: true,
              children: ": "
            }),
            /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
              color: "warning",
              children: props.value
            })
          ]
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedBox_default, {
          marginTop: 1,
          children: /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            dimColor: true,
            color: "warning",
            children: "\u26A0 Secret revealed in terminal \u2014 clear scrollback if this session is shared."
          })
        })
      ]
    });
  }
  if (props.mode === "not-found") {
    return /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
      children: [
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          color: "error",
          children: "Key not found: "
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          bold: true,
          children: props.key
        })
      ]
    });
  }
  if (props.mode === "deleted") {
    return /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
      children: [
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          color: "success",
          children: "\u2713"
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          children: " Deleted: "
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          bold: true,
          children: props.key
        })
      ]
    });
  }
  return /* @__PURE__ */ jsx_runtime.jsx(ThemedBox_default, {
    children: /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
      color: "error",
      children: [
        "Error: ",
        props.message
      ]
    })
  });
}
var jsx_runtime;
var init_LocalVaultView = __esm(() => {
  init_src();
  jsx_runtime = __toESM(require_jsx_runtime(), 1);
});

// src/commands/local-vault/parseArgs.ts
function parseLocalVaultArgs(args) {
  const trimmed = args.trim();
  if (trimmed === "" || trimmed === "list") {
    return { action: "list" };
  }
  const tokens = trimmed.split(/\s+/);
  const subCmd = tokens[0];
  if (subCmd === "list") {
    return { action: "list" };
  }
  if (subCmd === "set") {
    const key = tokens[1];
    if (!key) {
      return { action: "invalid", reason: `set requires a key name. ${USAGE}` };
    }
    if (HYPHEN_LIKE_PREFIX_REGEX.test(key)) {
      return {
        action: "invalid",
        reason: `Key name must not start with "-" or a hyphen-like character (reserved for flags). ${USAGE}`
      };
    }
    const rest = tokens.slice(2).join(" ");
    if (!rest) {
      return {
        action: "invalid",
        reason: `set requires a value. ${USAGE}`
      };
    }
    return { action: "set", key, value: rest };
  }
  if (subCmd === "get") {
    const flags = ["--reveal"];
    const argsWithoutFlags = tokens.filter((t) => !flags.includes(t));
    const key = argsWithoutFlags[1];
    if (!key) {
      return { action: "invalid", reason: `get requires a key name. ${USAGE}` };
    }
    const reveal = tokens.includes("--reveal");
    return { action: "get", key, reveal };
  }
  if (subCmd === "delete") {
    const key = tokens[1];
    if (!key) {
      return {
        action: "invalid",
        reason: `delete requires a key name. ${USAGE}`
      };
    }
    return { action: "delete", key };
  }
  return {
    action: "invalid",
    reason: `Unknown sub-command "${subCmd}". ${USAGE}`
  };
}
var USAGE = "Usage: /local-vault list | set KEY VALUE | get KEY [--reveal] | delete KEY", HYPHEN_LIKE_PREFIX_REGEX;
var init_parseArgs = __esm(() => {
  HYPHEN_LIKE_PREFIX_REGEX = /^[-\u2010-\u2015\u2212\uFE58\uFE63\uFF0D]/;
});

// src/commands/local-vault/launchLocalVault.tsx
function formatKeyList(keys) {
  if (keys.length === 0) {
    return "No secrets stored.";
  }
  return ["Local Vault Keys", ...keys.map((key) => `- ${key}`)].join(`
`);
}
function LocalVaultPanel({ onDone }) {
  const [step, setStep] = import_react.default.useState({ kind: "menu" });
  const [selectedIndex, setSelectedIndex] = import_react.default.useState(0);
  const [textValue, setTextValue] = import_react.default.useState("");
  const [cursorOffset, setCursorOffset] = import_react.default.useState(0);
  const [error, setError] = import_react.default.useState(null);
  const [inFlight, setInFlight] = import_react.default.useState(false);
  const transition = import_react.default.useCallback((next) => {
    setStep(next);
    setTextValue("");
    setCursorOffset(0);
    setError(null);
  }, []);
  const closeWith = import_react.default.useCallback((msg) => onDone(msg, { display: "system" }), [onDone]);
  use_input_default((input, key) => {
    if (step.kind !== "menu" || inFlight)
      return;
    if (key.upArrow) {
      setSelectedIndex((idx) => Math.max(0, idx - 1));
      return;
    }
    if (key.downArrow) {
      setSelectedIndex((idx) => Math.min(VAULT_MENU.length - 1, idx + 1));
      return;
    }
    if (key.return) {
      const choice = VAULT_MENU[selectedIndex];
      if (!choice)
        return;
      if (choice.kind === "about") {
        closeWith(USAGE2);
        return;
      }
      if (choice.kind === "list") {
        setInFlight(true);
        listKeys().then((keys) => {
          closeWith(formatKeyList(keys));
        });
        return;
      }
      transition({ kind: "collect-key", action: choice.kind });
      return;
    }
    const n = Number(input);
    if (Number.isInteger(n) && n >= 1 && n <= VAULT_MENU.length) {
      setSelectedIndex(n - 1);
    }
  }, { isActive: step.kind === "menu" && !inFlight });
  use_input_default((input, key) => {
    if (step.kind !== "confirm-overwrite" && step.kind !== "confirm-delete") {
      return;
    }
    if (key.escape) {
      transition({ kind: "menu" });
      return;
    }
    const ch = input.toLowerCase();
    if (ch === "y" || key.return) {
      if (step.kind === "confirm-delete") {
        setInFlight(true);
        const key2 = step.key;
        deleteSecret(key2).then((removed) => {
          closeWith(removed ? `Deleted: ${key2}` : `Key not found: ${key2}`);
        });
      } else {
        setInFlight(true);
        const k = step.key;
        const v = step.value;
        setSecret(k, v).then(() => closeWith(`Secret stored: ${k} = [REDACTED]`)).catch((e) => closeWith(`Failed to store ${k}: ${e instanceof Error ? e.message : String(e)}`));
      }
    } else if (ch === "n") {
      transition({ kind: "menu" });
    }
  }, {
    isActive: (step.kind === "confirm-overwrite" || step.kind === "confirm-delete") && !inFlight
  });
  use_input_default((_input, key) => {
    if (step.kind !== "collect-key" && step.kind !== "collect-value")
      return;
    if (key.escape) {
      if (step.kind === "collect-value") {
        transition({ kind: "collect-key", action: "set" });
        return;
      }
      transition({ kind: "menu" });
    }
  }, {
    isActive: (step.kind === "collect-key" || step.kind === "collect-value") && !inFlight
  });
  const handleKeySubmit = (raw) => {
    const key = raw.trim();
    if (!key) {
      setError("Key required");
      return;
    }
    if (!isValidKey(key)) {
      setError("Invalid key (allowed: letters/digits/._- only; no leading dot; not a Windows reserved name)");
      return;
    }
    if (step.kind !== "collect-key")
      return;
    if (step.action === "get") {
      setInFlight(true);
      getSecret(key).then((v) => {
        if (v === null) {
          closeWith(`Key not found: ${key}`);
        } else {
          closeWith(`Key found: ${key} = ${maskSecret(v)}`);
        }
      });
      return;
    }
    if (step.action === "delete") {
      transition({ kind: "confirm-delete", key });
      return;
    }
    if (step.action === "set") {
      transition({ kind: "collect-value", key });
      return;
    }
  };
  const handleValueSubmit = (rawValue) => {
    if (step.kind !== "collect-value")
      return;
    if (rawValue.length === 0) {
      setError("Secret value cannot be empty");
      return;
    }
    const k = step.key;
    setInFlight(true);
    getSecret(k).then((existing) => {
      if (existing !== null) {
        setInFlight(false);
        transition({
          kind: "confirm-overwrite",
          key: k,
          value: rawValue
        });
        return;
      }
      return setSecret(k, rawValue).then(() => closeWith(`Secret stored: ${k} = [REDACTED]`));
    }).catch((e) => closeWith(`Failed to store ${k}: ${e instanceof Error ? e.message : String(e)}`));
  };
  if (step.kind === "menu") {
    return /* @__PURE__ */ jsx_runtime2.jsx(Dialog, {
      title: "Local Vault",
      subtitle: `${VAULT_MENU.length} actions`,
      onCancel: () => closeWith("Local vault panel dismissed"),
      color: "background",
      hideInputGuide: true,
      children: /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
        flexDirection: "column",
        children: [
          VAULT_MENU.map((m, i) => /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
            flexDirection: "row",
            children: [
              /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                children: `${i === selectedIndex ? "\u203A" : " "} ${m.label}`.padEnd(ACTION_LABEL_COLUMN_WIDTH)
              }),
              /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                dimColor: true,
                children: m.description
              })
            ]
          }, m.kind)),
          inFlight && /* @__PURE__ */ jsx_runtime2.jsx(ThemedBox_default, {
            marginTop: 1,
            children: /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
              dimColor: true,
              children: "Working..."
            })
          }),
          /* @__PURE__ */ jsx_runtime2.jsx(ThemedBox_default, {
            marginTop: 1,
            children: /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
              dimColor: true,
              children: "\u2191/\u2193 or 1-5 select \xB7 Enter run \xB7 Esc close"
            })
          })
        ]
      })
    });
  }
  if (step.kind === "confirm-delete") {
    return /* @__PURE__ */ jsx_runtime2.jsx(Dialog, {
      title: "Confirm Delete",
      onCancel: () => transition({ kind: "menu" }),
      color: "warning",
      hideInputGuide: true,
      children: /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
        flexDirection: "column",
        children: [
          /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
            children: [
              'Delete secret "',
              step.key,
              '"? This cannot be undone.'
            ]
          }),
          /* @__PURE__ */ jsx_runtime2.jsx(ThemedBox_default, {
            marginTop: 1,
            children: /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
              dimColor: true,
              children: "y/Enter = delete \xB7 n/Esc = cancel"
            })
          }),
          inFlight && /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
            dimColor: true,
            children: "Deleting..."
          })
        ]
      })
    });
  }
  if (step.kind === "confirm-overwrite") {
    return /* @__PURE__ */ jsx_runtime2.jsx(Dialog, {
      title: "Confirm Overwrite",
      onCancel: () => transition({ kind: "menu" }),
      color: "warning",
      hideInputGuide: true,
      children: /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
        flexDirection: "column",
        children: [
          /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
            children: [
              'Secret "',
              step.key,
              '" already exists. Overwrite? Old value is lost.'
            ]
          }),
          /* @__PURE__ */ jsx_runtime2.jsx(ThemedBox_default, {
            marginTop: 1,
            children: /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
              dimColor: true,
              children: "y/Enter = overwrite \xB7 n/Esc = cancel"
            })
          }),
          inFlight && /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
            dimColor: true,
            children: "Storing..."
          })
        ]
      })
    });
  }
  const fieldLabel = step.kind === "collect-key" ? "KEY NAME" : "SECRET VALUE";
  const placeholder = step.kind === "collect-key" ? "e.g. github-token" : "(masked input \u2014 value never displayed)";
  const onSubmit = step.kind === "collect-key" ? handleKeySubmit : handleValueSubmit;
  const isMasked = step.kind === "collect-value";
  return /* @__PURE__ */ jsx_runtime2.jsx(Dialog, {
    title: `Local Vault \xB7 ${step.kind === "collect-key" ? "KEY" : "VALUE"}`,
    onCancel: () => transition({ kind: "menu" }),
    color: "background",
    hideInputGuide: true,
    children: /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
      flexDirection: "column",
      children: [
        /* @__PURE__ */ jsx_runtime2.jsx(ThemedBox_default, {
          children: /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
            dimColor: true,
            children: fieldLabel
          })
        }),
        /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
          children: [
            /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
              children: "> "
            }),
            /* @__PURE__ */ jsx_runtime2.jsx(TextInput, {
              value: textValue,
              onChange: (v) => {
                setTextValue(v);
                setError(null);
              },
              cursorOffset,
              onChangeCursorOffset: setCursorOffset,
              onSubmit,
              placeholder,
              columns: 70,
              showCursor: true,
              mask: isMasked ? "*" : undefined
            })
          ]
        }),
        error !== null && /* @__PURE__ */ jsx_runtime2.jsx(ThemedBox_default, {
          marginTop: 0,
          children: /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
            color: "warning",
            children: [
              "\u2717 ",
              error
            ]
          })
        }),
        inFlight && /* @__PURE__ */ jsx_runtime2.jsx(ThemedBox_default, {
          marginTop: 0,
          children: /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
            dimColor: true,
            children: "Working..."
          })
        }),
        /* @__PURE__ */ jsx_runtime2.jsx(ThemedBox_default, {
          marginTop: 1,
          children: /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
            dimColor: true,
            children: "Enter = next \xB7 Esc = back"
          })
        })
      ]
    })
  });
}
async function dispatchLocalVault(parsed, onDone) {
  if (parsed.action === "list") {
    const keys = await listKeys();
    onDone(formatKeyList(keys), { display: "system" });
    return null;
  }
  if (parsed.action === "set") {
    const { key, value } = parsed;
    await setSecret(key, value);
    onDone(`Secret stored: ${key} = [REDACTED]`, { display: "system" });
    return null;
  }
  if (parsed.action === "get") {
    const { key, reveal } = parsed;
    const value = await getSecret(key);
    if (value === null) {
      onDone(`Key not found: ${key}`, { display: "system" });
      return null;
    }
    if (reveal) {
      onDone([`Secret revealed for: ${key}`, "Warning: secret revealed in terminal.", `${key} = ${value}`].join(`
`), {
        display: "system"
      });
      return null;
    }
    const masked = maskSecret(value);
    onDone(`Key found: ${key} = ${masked}`, { display: "system" });
    return null;
  }
  if (parsed.action === "delete") {
    const { key } = parsed;
    const deleted = await deleteSecret(key);
    if (!deleted) {
      onDone(`Key not found: ${key}`, { display: "system" });
      return null;
    }
    onDone(`Deleted: ${key}`, { display: "system" });
    return null;
  }
  onDone(USAGE2, { display: "system" });
  return null;
}
var import_react, jsx_runtime2, USAGE2 = "Usage: /local-vault list | set KEY VALUE | get KEY [--reveal] | delete KEY", ACTION_LABEL_COLUMN_WIDTH = 26, VAULT_MENU, callLocalVaultDirect, callLocalVault = async (onDone, context, args) => {
  if ((args ?? "").trim() === "") {
    return /* @__PURE__ */ jsx_runtime2.jsx(LocalVaultPanel, {
      onDone
    });
  }
  return callLocalVaultDirect(onDone, context, args);
};
var init_launchLocalVault = __esm(() => {
  init_src();
  init_store();
  init_localValidate();
  init_TextInput();
  init_LocalVaultView();
  init_parseArgs();
  init_launchCommand();
  import_react = __toESM(require_react(), 1);
  jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
  VAULT_MENU = [
    { kind: "list", label: "List", description: "Show stored secret keys" },
    {
      kind: "set",
      label: "Set",
      description: "Store a secret: KEY + VALUE (input is masked)"
    },
    {
      kind: "get",
      label: "Get",
      description: "Look up a secret (returns masked preview)"
    },
    {
      kind: "delete",
      label: "Delete",
      description: "Delete a stored secret by KEY"
    },
    {
      kind: "about",
      label: "About",
      description: "Show command syntax"
    }
  ];
  callLocalVaultDirect = launchCommand({
    commandName: "local-vault",
    parseArgs: (raw) => {
      const result = parseLocalVaultArgs(raw);
      if (result.action === "invalid") {
        return { action: "invalid", reason: `${USAGE2}
${result.reason}` };
      }
      return result;
    },
    dispatch: dispatchLocalVault,
    View: LocalVaultView,
    errorView: (msg) => import_react.default.createElement(LocalVaultView, { mode: "error", message: msg })
  });
});
init_launchLocalVault();

export {
  callLocalVault
};

//# debugId=EE7DDA5215C6336364756E2164756E21
//# sourceMappingURL=chunk-b35ng7yy.js.map
