import { writable } from 'svelte/store';

export interface PendingFile {
	file: File;
	previewUrl: string; // URL.createObjectURL result — revoke after use
}

export const pendingFiles = writable<PendingFile[]>([]);
export const pendingCaption = writable('');

export function clearPending() {
	pendingFiles.update((files) => {
		for (const f of files) URL.revokeObjectURL(f.previewUrl);
		return [];
	});
	pendingCaption.set('');
}
