// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT

/**
 * TagWriter orchestrates the complete tag writing pipeline:
 * file write → DB sync → event emission.
 * @module
 */

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Call as $Call, CancellablePromise as $CancellablePromise } from "@wailsio/runtime";

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as $models from "./models.js";

/**
 * BatchWriteTrackTags applies the same TagChanges to every file in
 * filePaths.  It processes tracks sequentially, emits a
 * BatchWriteProgress event after each track, and continues past
 * individual failures.  Returns a BatchResult summarising outcomes.
 */
export function BatchWriteTrackTags(filePaths: string[] | null, changes: $models.TagChanges): $CancellablePromise<$models.BatchResult> {
    return $Call.ByID(2772510056, filePaths, changes);
}

/**
 * CancelBatchWrite signals the in-progress batch write to stop after
 * the current track completes.
 */
export function CancelBatchWrite(): $CancellablePromise<void> {
    return $Call.ByID(3075727604);
}

/**
 * WriteTrackTags is the single entry point for writing metadata to
 * a track's audio file and synchronising all changes to the
 * database.  It accepts a track ID (audio_file.id) and a diff map
 * of changed fields.
 * 
 * The pipeline:
 *  1. Look up track from DB.
 *  2. Detect audio format.
 *  3. Acquire pipeline lock (mutual exclusion with scan).
 *  4. Stop player if this file is currently playing.
 *  5. Write tags to file (format-specific writer).
 *  6. Sync database (entity relink, FTS5, orphan cleanup).
 *  7. Emit TrackMetadataChanged event.
 */
export function WriteTrackTags(trackID: number, changes: $models.TagChanges): $CancellablePromise<void> {
    return $Call.ByID(1881385878, trackID, changes);
}

/**
 * WriteTrackTagsByPath resolves a file path to its audio_file.id and
 * delegates to WriteTrackTags.  This is the frontend-facing entry
 * point since the frontend identifies tracks by FilePath.
 */
export function WriteTrackTagsByPath(filePath: string, changes: $models.TagChanges): $CancellablePromise<void> {
    return $Call.ByID(3526432184, filePath, changes);
}

/**
 * WriteUntrackedFileTags writes tags to a file that is not in the
 * library, skipping every step of the full pipeline that assumes it is:
 * no audio_file lookup, no database sync, no event.
 * 
 * This exists for the download import path, which tags files while they
 * are still in the staging directory.  Tagging before the move is what
 * makes the import atomic from the library's point of view — the
 * scanner only ever sees a finished, correctly tagged file, instead of
 * ingesting a mislabelled one and being corrected afterwards.
 * 
 * Callers are responsible for ensuring the file is not in a library
 * path; using this on a tracked file would leave the database stale.
 */
export function WriteUntrackedFileTags(filePath: string, changes: $models.TagChanges): $CancellablePromise<void> {
    return $Call.ByID(3625602876, filePath, changes);
}
