import { CONVERSATION_TURN_CONTAINER_SELECTOR, CONVERSATION_TURN_SELECTOR } from "./constants.js";
/** Build a browser-context expression that returns one DOM node per conversation turn. */
export function buildConversationTurnListExpression(rootExpression = "document") {
    const containerSelector = JSON.stringify(CONVERSATION_TURN_CONTAINER_SELECTOR);
    const fallbackSelector = JSON.stringify(CONVERSATION_TURN_SELECTOR);
    return `(() => {
    const root = ${rootExpression};
    const containers = Array.from(root.querySelectorAll(${containerSelector}));
    return containers.length > 0
      ? containers
      : Array.from(root.querySelectorAll(${fallbackSelector}));
  })()`;
}
export function buildConversationTurnCountExpression(rootExpression = "document") {
    return `(${buildConversationTurnListExpression(rootExpression)}).length`;
}
