/// A FILE from the phone: the document picker with the caller's own MIME
/// filter, answered with a path the Rust side can open. A document already
/// on this phone's storage is handed over as it lies; one that has no path
/// is copied into the app's cache under its own name, and only as far as
/// `max_copy_bytes` allows — zero refuses the copy, which is what a pick
/// that could be hundreds of megabytes wants.
#[tauri::command]
async fn pick_file<R: Runtime>(
    app: tauri::AppHandle<R>,
    mime_types: Option<String>,
    max_copy_bytes: Option<u32>,
) -> Result<PickedFile, String> {
    #[cfg(mobile)]
    {
        use tauri::Manager;
        let storage = app.state::<Storage<R>>();
        storage
            .0
            .run_mobile_plugin::<PickedFile>(
                "pickFile",
                PickFileArgs {
                    mime_types,
                    max_copy_bytes: max_copy_bytes.unwrap_or(0),
                },
            )
            .map_err(|e| e.to_string())
    }
    #[cfg(not(mobile))]
    {
        let _ = (app, mime_types, max_copy_bytes);
        Err("the file picker here is the desktop's dialog".into())
    }
}
