#pragma once
// The file-side half of the realtime-record shell: discovers the file REAPER
// actually recorded, moves it into the bank, runs the Auto-tail decay-scan trim,
// and populates the finished Sample. The async record lifecycle (state
// snapshot/restore, begin/tick/abort) lives in capture_realtime_shell.cpp; this
// half talks to wav_codec and the filesystem, not the transport.
//
// The .cpp includes reaper_plugin_functions.h WITHOUT REAPERAPI_IMPLEMENT
// (main.cpp owns the API pointers). MediaTrack/ReaProject are forward-declared
// (via capture.h) so this header stays SDK-lite.

#include <string>

#include "shell/capture/capture.h"           // CaptureRequest / CaptureResult
#include "core/capture/capture_paths.h"      // BankPaths

namespace reasampler::capture {

// The first media item's active take's source file on the temp track, forward-
// slashed; empty if nothing was recorded. Also used by the lifecycle's flush wait
// (size-stable check) before finalize runs.
std::string recordedFilePath(MediaTrack* temp);

// Discovers the recorded file, moves it into the bank at `paths`, Auto-trims the
// tail decay in place when requested, and populates the Sample (project reads
// pinned to `proj`, the record's own project). Does NOT restore any snapshotted
// state — the caller restores unconditionally afterward, even on a finalize
// failure, so finalize and restore stay separate steps. `recordWindowEnd` is the
// recorded window end in project seconds (>= request.endSeconds when a tail was
// recorded).
CaptureResult finalizeRecording(ReaProject* proj, MediaTrack* temp,
                                const CaptureRequest& request,
                                const BankPaths& paths,
                                const std::string& uniqueTag,
                                double recordWindowEnd);

}  // namespace reasampler::capture
