'use strict';

// Approval prompt detection — multi-CLI provider dispatch.
// Used by headless-term-worker.js for auto-approval detection.

const { detectProvider, detectApprovalWithProvider } = require('../providers');

// Legacy patterns exported for backward compatibility with tests
const APPROVAL_RE = /Do you want to (proceed|make this edit to .+|create .+|overwrite .+)\??/;
const BROAD_APPROVAL_RE = /Do you want to .+\?/;
const YES_RE = /^\D*1\.\s*Yes\b/;
const ESC_CANCEL_RE = /Esc to cancel/;

// Detect approval prompt — delegates to provider registry.
// Returns true if any provider detects an approval prompt.
function detectApproval(text) {
  return detectProvider(text) !== null;
}

module.exports = { APPROVAL_RE, BROAD_APPROVAL_RE, YES_RE, ESC_CANCEL_RE, detectApproval, detectApprovalWithProvider };
