import { buildLocalExcelHttpUrl, parseExcelHttpPort } from './http-url.js';
import { readXllSessionFromDisk } from './session.js';
export function resolveEffectiveExcelHttpUrl(options) {
    const session = options?.session ?? readXllSessionFromDisk();
    if (!session) {
        throw new Error('ShortcutXL session.json was not found. Start Excel with ShortcutXL loaded.');
    }
    try {
        return buildLocalExcelHttpUrl(parseExcelHttpPort(session.port));
    }
    catch {
        throw new Error(`ShortcutXL session.json contains an invalid port: ${String(session.port)}. Restart Excel.`);
    }
}
export function getEffectiveExcelHttpUrl() {
    return resolveEffectiveExcelHttpUrl();
}
//# sourceMappingURL=endpoint.js.map