#pragma once
// render_bounds_gate — the exact-bounds verdict on a landed offline render, and what
// happens to a render that fails it. Split out of capture.cpp on the responsibility
// seam: that TU drives the render, this one judges the file it produced.
// No REAPER types — pure core plus the filesystem.

#include <string>

#include "shell/capture/capture.h"

namespace reasampler::capture {

// On the Bank destination, a refused render is MOVED out of the bank, not deleted: while
// the root cause of a short render is open (docs/TODO.md), the frames it did print are
// the evidence — and nothing may index a file the bank never accepted. On ProjectMedia,
// the render is the project's own media (docs/product/render-in-place.md "Where the file
// goes"), so a refusal leaves it exactly where it was written — no move, no bank folder.
struct BoundsVerdict {
    bool        refused = false;
    std::string message;   // console text; meaningful only when refused
};

// Judges `renderedPath` against `request`'s window. Refuses on two counts: the file's
// frame count is not the window's (render_window::renderHonoredBounds owns the
// tolerance and its limits), or the file cannot be measured at all — an unmeasured
// render is not a verified one. TailMode::Auto/Manual add frames by design and are
// never judged here. `projectDir` and `request.destination` together decide where a
// refused render is parked.
BoundsVerdict checkRenderedBounds(const std::string& renderedPath,
                                  const std::string& projectDir,
                                  const CaptureRequest& request);

// A 0-byte render is refused on every tail mode (Auto/Manual add frames by design but
// never legitimately produce zero), independent of and ahead of the TailMode::None-only
// gate above, which does not run on Auto/Manual at all.
BoundsVerdict checkRenderedFileNotEmpty(const std::string& renderedPath,
                                        const std::string& projectDir,
                                        CaptureDestination destination);

// Where a refused Bank-destination render is retained -- exposed so a multi-unit caller
// (batch capture, Bank-only) can name the folder once without duplicating the subfolder
// name `checkRenderedBounds` and `checkRenderedFileNotEmpty` already use internally.
std::string refusedRenderFolder(const std::string& projectDir);

} // namespace reasampler::capture
