import 'album.dart'; import 'artist.dart'; import 'page.dart'; import 'track.dart'; /// Mirrors internal/api/search.go SearchResponse — three pages keyed by /// facet, each independently paged. The mobile UI usually only walks /// the first page of each facet (limit 20-50); infinite scroll within a /// facet is a future enhancement, not v1. class SearchResponse { const SearchResponse({ required this.artists, required this.albums, required this.tracks, }); final Paged artists; final Paged albums; final Paged tracks; factory SearchResponse.fromJson(Map j) => SearchResponse( artists: Paged.fromJson( (j['artists'] as Map?)?.cast() ?? const {}, ArtistRef.fromJson, ), albums: Paged.fromJson( (j['albums'] as Map?)?.cast() ?? const {}, AlbumRef.fromJson, ), tracks: Paged.fromJson( (j['tracks'] as Map?)?.cast() ?? const {}, TrackRef.fromJson, ), ); bool get isEmpty => artists.items.isEmpty && albums.items.isEmpty && tracks.items.isEmpty; }