"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasExactFlagValue = exports.getImmediateFlagValue = exports.splitArgsAtTerminator = void 0;
function splitArgsAtTerminator(args) {
    const terminatorIndex = args.indexOf('--');
    if (terminatorIndex === -1) {
        return { optionArgs: args, trailingArgs: [] };
    }
    return {
        optionArgs: args.slice(0, terminatorIndex),
        trailingArgs: args.slice(terminatorIndex),
    };
}
exports.splitArgsAtTerminator = splitArgsAtTerminator;
function getImmediateFlagValue(args, index) {
    const value = args[index + 1];
    if (value === undefined || value === '--' || value.startsWith('--')) {
        return null;
    }
    return value;
}
exports.getImmediateFlagValue = getImmediateFlagValue;
function hasExactFlagValue(args, flag, expectedValue) {
    for (let index = 0; index < args.length; index += 1) {
        const arg = args[index];
        if (arg === flag) {
            const value = getImmediateFlagValue(args, index);
            if (value === expectedValue) {
                return true;
            }
            continue;
        }
        if (arg === `${flag}=${expectedValue}`) {
            return true;
        }
        if (arg.startsWith(`${flag}=`) && arg.slice(flag.length + 1) === expectedValue) {
            return true;
        }
    }
    return false;
}
exports.hasExactFlagValue = hasExactFlagValue;
//# sourceMappingURL=claude-tool-args.js.map