import "../../chunks/chunk.QU3DSPNU.js";
function parseArgs(argv) {
  const positional = [];
  const flags = {};
  let i = 0;
  while (i < argv.length) {
    const arg = argv[i];
    if (arg === "--") {
      positional.push(...argv.slice(i + 1));
      break;
    }
    if (arg.startsWith("--")) {
      const eqIndex = arg.indexOf("=");
      if (eqIndex !== -1) {
        const key = arg.slice(2, eqIndex);
        flags[key] = arg.slice(eqIndex + 1);
      } else {
        const key = arg.slice(2);
        if (key.startsWith("no-")) {
          flags[key.slice(3)] = false;
        } else {
          const next = argv[i + 1];
          if (next !== void 0 && !next.startsWith("-")) {
            flags[key] = next;
            i++;
          } else {
            flags[key] = true;
          }
        }
      }
    } else if (arg.startsWith("-") && arg.length === 2) {
      flags[arg.slice(1)] = true;
    } else {
      positional.push(arg);
    }
    i++;
  }
  return {
    command: positional.length > 0 ? positional[0] : null,
    positional: positional.slice(1),
    flags
  };
}
export {
  parseArgs
};
