using System.Threading;
using System.Threading.Tasks;
namespace KillerPDF.Features
{
///
/// What OcrController needs from the window hosting it, beyond the shared shell services.
///
/// Every member is a value, a plain string, or an intent ("put up the busy overlay"), never a
/// control, so the controller holds no reference to a Border or a Dictionary of window state
/// and can be driven by a stub in a test.
///
internal interface IOcrHost : IShellServices
{
/// True while a document is open (both the live doc and its backing file).
bool HasDocument { get; }
/// Page count of the open document, 0 when none.
int PageCount { get; }
/// Path of the working (temp) file the renderer reads. Null when no document.
string? CurrentFile { get; }
/// Path of the file the user actually opened, for suggesting output names.
/// Null for a document that never had an original (e.g. built from images).
string? OriginalFile { get; }
/// The page's in-memory rotation in degrees, 0 when untouched. The working file
/// has /Rotate stripped, so renders must rotate the pixel buffer by this.
int RotationFor(int pageIdx);
/// Render-dim space of the page overlay (the (w,h) its canvas coordinates live
/// in), for mapping a canvas rect onto the OCR bitmap. False when the page has not
/// rendered yet.
bool TryGetRenderDims(int pageIdx, out int w, out int h);
/// The '+'-joined Tesseract language string, e.g. "eng" or "eng+spa".
string OcrLanguageString { get; }
/// Makes sure the selected language models are on disk, downloading behind a
/// heads-up dialog if not. False when the user declined or the download failed.
Task EnsureOcrModelsReadyAsync();
/// Commits any annotation text box still being edited, so the saved snapshot
/// matches what is on screen.
void CommitActiveTextBox();
/// Saves the live document to . Throws on failure.
void SaveDocumentTo(string path);
/// Registers the cancellable operation (Esc offers to cancel it) and puts up the
/// busy overlay. Returns the token to thread through the work.
CancellationToken BeginOp(string label, string busyMessage);
/// Updates the busy overlay's message line (per-page progress). UI thread only.
void SetBusyMessage(string message);
/// Takes the busy overlay down - before any completion dialog, so the overlay is
/// gone when the dialog appears. Safe to call when it is already down.
void HideBusy();
/// Disposes the cancellable-operation registration. Always called from finally.
void EndOp();
}
}