@behindthemusictree/app-kit 33.3.0 → 34.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,10 @@ __export(genre_tree_exports, {
42
42
  CriteriaUpdateSchema: () => CriteriaUpdateSchema,
43
43
  FORM_RATING_NULL_VALUE: () => FORM_RATING_NULL_VALUE,
44
44
  FUZZY_MIN_SIMILARITY: () => FUZZY_MIN_SIMILARITY,
45
+ GenreCatalogueCountsSchema: () => GenreCatalogueCountsSchema,
46
+ GenreCountsSchema: () => GenreCountsSchema,
47
+ GenreCoverageSchema: () => GenreCoverageSchema,
48
+ GenrePlaylistSummarySchema: () => GenrePlaylistSummarySchema,
45
49
  GenrePlaylistUuidSchema: () => GenrePlaylistUuidSchema,
46
50
  GenreSearchResultSchema: () => GenreSearchResultSchema,
47
51
  GenreSearchResultsSchema: () => GenreSearchResultsSchema,
@@ -50,6 +54,8 @@ __export(genre_tree_exports, {
50
54
  MbArtistDetailedSchema: () => MbArtistDetailedSchema,
51
55
  MbRecordingDetailedSchema: () => MbRecordingDetailedSchema,
52
56
  NO_VIDEO_LABEL: () => NO_VIDEO_LABEL,
57
+ ReferenceGenreDetailedSchema: () => ReferenceGenreDetailedSchema,
58
+ ReferenceGenrePlaylistSchema: () => ReferenceGenrePlaylistSchema,
53
59
  RegionGenreLexiconEntrySchema: () => RegionGenreLexiconEntrySchema,
54
60
  RegionGenreLexiconSchema: () => RegionGenreLexiconSchema,
55
61
  SEARCH_DEBOUNCE_MS: () => SEARCH_DEBOUNCE_MS,
@@ -59,6 +65,8 @@ __export(genre_tree_exports, {
59
65
  SongHistorySchema: () => SongHistorySchema,
60
66
  SongSearchResultSchema: () => SongSearchResultSchema,
61
67
  SongSearchResultsSchema: () => SongSearchResultsSchema,
68
+ SubgenreCountsSchema: () => SubgenreCountsSchema,
69
+ SubgenreScopeSchema: () => SubgenreScopeSchema,
62
70
  TrackBaseSchema: () => TrackBaseSchema,
63
71
  TrackList: () => TrackList,
64
72
  TrackListFromArtist: () => TrackListFromArtist,
@@ -67,6 +75,7 @@ __export(genre_tree_exports, {
67
75
  TrackListOrigin: () => TrackListOrigin,
68
76
  TrackListOriginFromArtist: () => TrackListOriginFromArtist,
69
77
  TrackListOriginFromCriteriaPlaylist: () => TrackListOriginFromCriteriaPlaylist,
78
+ TrackListOriginFromGenreCatalogue: () => TrackListOriginFromGenreCatalogue,
70
79
  TrackListOriginFromTrack: () => TrackListOriginFromTrack,
71
80
  TrackListOriginType: () => TrackListOriginType,
72
81
  TrackListProvider: () => TrackListProvider,
@@ -78,12 +87,17 @@ __export(genre_tree_exports, {
78
87
  artistEndpoints: () => artistEndpoints,
79
88
  artistQueryKeys: () => artistQueryKeys,
80
89
  capitalizeFirstLetter: () => capitalizeFirstLetter,
90
+ defaultGenreMusicSelection: () => defaultGenreMusicSelection,
81
91
  editGenreSongPages: () => editGenreSongPages,
82
92
  foldSearchText: () => foldSearchText,
83
93
  formatTime: () => formatTime,
84
94
  genreEndpoints: () => genreEndpoints,
95
+ genreMusicCount: () => genreMusicCount,
96
+ genreMusicQueryParams: () => genreMusicQueryParams,
97
+ genreMusicSelectionKey: () => genreMusicSelectionKey,
85
98
  genrePlaylistEndpoints: () => genrePlaylistEndpoints,
86
99
  genrePlaylistQueryKeys: () => genrePlaylistQueryKeys,
100
+ genrePlaylistTrackCount: () => genrePlaylistTrackCount,
87
101
  genreQueryKeys: () => genreQueryKeys,
88
102
  genreSearchQueryKeys: () => genreSearchQueryKeys,
89
103
  genreUpdateMutationKey: () => genreUpdateMutationKey,
@@ -135,15 +149,206 @@ __export(genre_tree_exports, {
135
149
  module.exports = __toCommonJS(genre_tree_exports);
136
150
 
137
151
  // src/genre-tree/useGenre.ts
138
- var import_zod23 = require("zod");
152
+ var import_zod24 = require("zod");
153
+
154
+ // src/genre-tree/schemas/criteria/detailed.ts
155
+ var import_zod11 = require("zod");
156
+
157
+ // src/genre-tree/schemas/genre-music.ts
158
+ var import_zod3 = require("zod");
159
+
160
+ // src/genre-tree/schemas/criteria-playlist/minimum.ts
161
+ var import_zod2 = require("zod");
162
+
163
+ // src/genre-tree/schemas/ids.ts
164
+ var import_zod = require("zod");
165
+ var GenreUuidSchema = import_zod.z.string().uuid().brand();
166
+ var GenrePlaylistUuidSchema = import_zod.z.string().uuid().brand();
167
+
168
+ // src/genre-tree/schemas/criteria-playlist/minimum.ts
169
+ var CriteriaPlaylistMinimumSchema = import_zod2.z.object({
170
+ uuid: GenrePlaylistUuidSchema,
171
+ name: import_zod2.z.string()
172
+ });
173
+
174
+ // src/genre-tree/schemas/genre-music.ts
175
+ var CountSchema = import_zod3.z.number().int().nonnegative();
176
+ var SubgenreCountsSchema = import_zod3.z.union([
177
+ import_zod3.z.object({ canonical: CountSchema, regional: CountSchema, all: CountSchema }).strict(),
178
+ import_zod3.z.object({ all: CountSchema }).strict()
179
+ ]).refine(
180
+ (counts) => !("canonical" in counts) || counts.all >= counts.canonical && counts.all >= counts.regional,
181
+ "The combined count must include both scoped selections"
182
+ );
183
+ var GenreCountsSchema = import_zod3.z.object({
184
+ genreOnlyTracksCount: CountSchema,
185
+ genreAndSubgenresTracksCount: SubgenreCountsSchema
186
+ });
187
+ var includesDirectSongs = (counts) => Object.values(counts.genreAndSubgenresTracksCount).every((count) => count >= counts.genreOnlyTracksCount);
188
+ var GenreCatalogueCountsSchema = GenreCountsSchema.refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
189
+ var GenrePlaylistSummarySchema = CriteriaPlaylistMinimumSchema.extend(GenreCountsSchema.shape).refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
190
+ var GenreCoverageSchema = import_zod3.z.enum(["genreOnly", "genreAndSubgenres"]);
191
+ var SubgenreScopeSchema = import_zod3.z.enum(["canonical", "regional", "all"]);
192
+
193
+ // src/genre-tree/schemas/criteria/minimum.ts
194
+ var import_zod4 = require("zod");
195
+ var CriteriaMinimumSchema = import_zod4.z.object({
196
+ uuid: GenreUuidSchema,
197
+ name: import_zod4.z.string(),
198
+ side: import_zod4.z.enum(["core", "pop"]).nullable().optional(),
199
+ wikidataId: import_zod4.z.string().nullable().optional()
200
+ });
201
+
202
+ // src/genre-tree/schemas/track/base.ts
203
+ var import_zod8 = require("zod");
204
+
205
+ // src/genre-tree/schemas/artist-minimum.ts
206
+ var import_zod5 = require("zod");
207
+ var ArtistMinimumSchema = import_zod5.z.object({
208
+ uuid: import_zod5.z.string().uuid(),
209
+ name: import_zod5.z.string(),
210
+ isSpecialPurpose: import_zod5.z.boolean().optional()
211
+ });
212
+
213
+ // src/genre-tree/schemas/album-minimum.ts
214
+ var import_zod6 = require("zod");
215
+ var AlbumMinimumSchema = import_zod6.z.object({
216
+ uuid: import_zod6.z.string().uuid(),
217
+ name: import_zod6.z.string(),
218
+ albumArtists: import_zod6.z.array(ArtistMinimumSchema).nullable().optional()
219
+ });
220
+
221
+ // src/genre-tree/schemas/uuid-resource.ts
222
+ var import_zod7 = require("zod");
223
+ var UuidResourceSchema = import_zod7.z.object({
224
+ uuid: import_zod7.z.string().uuid()
225
+ });
226
+
227
+ // src/genre-tree/schemas/track/base.ts
228
+ var TrackBaseSchema = UuidResourceSchema.extend({
229
+ title: import_zod8.z.string(),
230
+ artists: import_zod8.z.array(ArtistMinimumSchema).nullable().optional(),
231
+ album: AlbumMinimumSchema.nullable().optional(),
232
+ trackNumber: import_zod8.z.number().nullable().optional(),
233
+ // null for a song not yet linked to a genre.
234
+ genre: CriteriaMinimumSchema.nullable(),
235
+ rating: import_zod8.z.number().min(0).max(10).nullable().optional(),
236
+ language: import_zod8.z.string().nullable().optional(),
237
+ playCount: import_zod8.z.number().min(0),
238
+ createdOn: import_zod8.z.string().datetime(),
239
+ updatedOn: import_zod8.z.string().datetime().nullable().optional()
240
+ });
241
+
242
+ // src/genre-tree/schemas/track/minimum.ts
243
+ var TrackMinimumSchema = TrackBaseSchema.pick({
244
+ uuid: true,
245
+ title: true,
246
+ artists: true
247
+ });
248
+
249
+ // src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
250
+ var import_zod9 = require("zod");
251
+ var CriteriaLineageRelWithoutAscendantSchema = import_zod9.z.object({
252
+ descendant: CriteriaMinimumSchema,
253
+ degree: import_zod9.z.number()
254
+ });
255
+
256
+ // src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
257
+ var import_zod10 = require("zod");
258
+ var CriteriaLineageRelWithoutDescendantSchema = import_zod10.z.object({
259
+ ascendant: CriteriaMinimumSchema,
260
+ degree: import_zod10.z.number()
261
+ });
262
+
263
+ // src/genre-tree/schemas/criteria/detailed.ts
264
+ var CriteriaDetailedSchema = import_zod11.z.object({
265
+ uuid: GenreUuidSchema,
266
+ name: import_zod11.z.string(),
267
+ summary: import_zod11.z.string().nullable(),
268
+ // Optional until every deployed API serves it.
269
+ wikidataId: import_zod11.z.string().nullable().optional(),
270
+ parent: CriteriaMinimumSchema.nullable(),
271
+ ascendants: import_zod11.z.array(CriteriaLineageRelWithoutDescendantSchema),
272
+ descendants: import_zod11.z.array(CriteriaLineageRelWithoutAscendantSchema),
273
+ root: CriteriaMinimumSchema,
274
+ children: import_zod11.z.array(CriteriaMinimumSchema),
275
+ catalogue: GenreCatalogueCountsSchema.optional(),
276
+ criteriaPlaylist: import_zod11.z.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]),
277
+ tracks: import_zod11.z.array(TrackMinimumSchema),
278
+ essentialSongs: import_zod11.z.array(TrackMinimumSchema),
279
+ tracksCount: import_zod11.z.number(),
280
+ updatedOn: import_zod11.z.string().datetime().nullable()
281
+ });
282
+
283
+ // src/genre-tree/schemas/criteria-playlist/simple.ts
284
+ var import_zod13 = require("zod");
285
+
286
+ // src/genre-tree/schemas/criteria-playlist/detailed.ts
287
+ var import_zod12 = require("zod");
288
+ var CriteriaPlaylistDetailedSchema = import_zod12.z.object({
289
+ uuid: GenrePlaylistUuidSchema,
290
+ name: import_zod12.z.string(),
291
+ tracksCount: import_zod12.z.number(),
292
+ genreOnlyTracksCount: GenreCountsSchema.shape.genreOnlyTracksCount.optional(),
293
+ genreAndSubgenresTracksCount: GenreCountsSchema.shape.genreAndSubgenresTracksCount.optional(),
294
+ catalogue: GenreCatalogueCountsSchema.optional(),
295
+ // Summed YouTube views of the same songs as `tracksCount`. Optional: hear-api has no view counts.
296
+ viewsCount: import_zod12.z.number().optional(),
297
+ durationInSec: import_zod12.z.number().min(0).nullable().optional(),
298
+ durationStrInHourMinSec: import_zod12.z.string().nullable().optional(),
299
+ // Nullable: the "Genreless" root playlist has no criteria attached and is never updated.
300
+ criteria: CriteriaMinimumSchema.nullable(),
301
+ parent: CriteriaPlaylistMinimumSchema.nullable(),
302
+ root: CriteriaPlaylistMinimumSchema,
303
+ createdOn: import_zod12.z.string(),
304
+ updatedOn: import_zod12.z.string().nullable()
305
+ });
306
+
307
+ // src/genre-tree/schemas/criteria-playlist/simple.ts
308
+ var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
309
+ uuid: true,
310
+ name: true,
311
+ criteria: true,
312
+ parent: true,
313
+ root: true,
314
+ tracksCount: true,
315
+ genreOnlyTracksCount: true,
316
+ genreAndSubgenresTracksCount: true,
317
+ catalogue: true,
318
+ viewsCount: true,
319
+ createdOn: true,
320
+ updatedOn: true
321
+ }).extend({
322
+ // Only on the tree/list payloads, not the detail endpoint — hence not on the detailed schema.
323
+ isUnacceptedRoot: import_zod13.z.boolean(),
324
+ // Optional: a backend that does not curate umbrella genres omits it.
325
+ isUmbrella: import_zod13.z.boolean().optional(),
326
+ // Optional: only the grow tree payload carries it; null when the genre has no scene.
327
+ scene: import_zod13.z.enum(["commercial", "underground"]).nullable().optional()
328
+ });
329
+
330
+ // src/genre-tree/schemas/reference-genre.ts
331
+ var ReferenceGenreDetailedSchema = CriteriaDetailedSchema.extend({
332
+ catalogue: GenreCatalogueCountsSchema,
333
+ criteriaPlaylist: GenrePlaylistSummarySchema
334
+ });
335
+ var ReferenceGenrePlaylistSchema = CriteriaPlaylistSimpleSchema.extend({
336
+ ...GenreCountsSchema.shape,
337
+ catalogue: GenreCatalogueCountsSchema
338
+ }).superRefine((playlist, ctx) => {
339
+ const counts = GenreCatalogueCountsSchema.safeParse(playlist);
340
+ if (!counts.success) for (const issue of counts.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
341
+ });
342
+
343
+ // src/genre-tree/useGenre.ts
139
344
  var import_react_query5 = require("@tanstack/react-query");
140
345
  var import_react6 = require("react");
141
346
 
142
347
  // src/transport/PlaybackContext.tsx
143
348
  var import_react = require("react");
144
- var import_zod = require("zod");
349
+ var import_zod14 = require("zod");
145
350
  var import_jsx_runtime = require("react/jsx-runtime");
146
- var PlaybackContextSchema = import_zod.z.object({ country: import_zod.z.string().regex(/^[A-Z]{2}$/).nullable() });
351
+ var PlaybackContextSchema = import_zod14.z.object({ country: import_zod14.z.string().regex(/^[A-Z]{2}$/).nullable() });
147
352
  var unmanaged = {
148
353
  country: null,
149
354
  key: null,
@@ -652,14 +857,14 @@ var useFetchWrapper = (getBackendBaseUrl) => {
652
857
  };
653
858
 
654
859
  // src/genre-tree/useGenrePlaylist.ts
655
- var import_zod9 = require("zod");
860
+ var import_zod17 = require("zod");
656
861
  var import_react_query3 = require("@tanstack/react-query");
657
862
 
658
863
  // src/transport/lib/use-query-with-parse.ts
659
864
  var import_react_query2 = require("@tanstack/react-query");
660
865
 
661
866
  // src/transport/lib/parse-with-log.ts
662
- var import_zod2 = require("zod");
867
+ var import_zod15 = require("zod");
663
868
  function parseWithLog(schema, data, context) {
664
869
  const result = schema.safeParse(data);
665
870
  if (!result.success) {
@@ -667,7 +872,7 @@ function parseWithLog(schema, data, context) {
667
872
  if (data == null) {
668
873
  throw new Error(`${prefix} received null response before schema validation`);
669
874
  }
670
- console.error(`${prefix} schema validation failed`, import_zod2.z.flattenError(result.error));
875
+ console.error(`${prefix} schema validation failed`, import_zod15.z.flattenError(result.error));
671
876
  throw result.error;
672
877
  }
673
878
  return result.data;
@@ -689,80 +894,16 @@ function useQueryWithParse({
689
894
  });
690
895
  }
691
896
 
692
- // src/genre-tree/schemas/criteria-playlist/simple.ts
693
- var import_zod7 = require("zod");
694
-
695
- // src/genre-tree/schemas/criteria-playlist/detailed.ts
696
- var import_zod6 = require("zod");
697
-
698
- // src/genre-tree/schemas/ids.ts
699
- var import_zod3 = require("zod");
700
- var GenreUuidSchema = import_zod3.z.string().uuid().brand();
701
- var GenrePlaylistUuidSchema = import_zod3.z.string().uuid().brand();
702
-
703
- // src/genre-tree/schemas/criteria/minimum.ts
704
- var import_zod4 = require("zod");
705
- var CriteriaMinimumSchema = import_zod4.z.object({
706
- uuid: GenreUuidSchema,
707
- name: import_zod4.z.string(),
708
- side: import_zod4.z.enum(["core", "pop"]).nullable().optional(),
709
- wikidataId: import_zod4.z.string().nullable().optional()
710
- });
711
-
712
- // src/genre-tree/schemas/criteria-playlist/minimum.ts
713
- var import_zod5 = require("zod");
714
- var CriteriaPlaylistMinimumSchema = import_zod5.z.object({
715
- uuid: GenrePlaylistUuidSchema,
716
- name: import_zod5.z.string()
717
- });
718
-
719
- // src/genre-tree/schemas/criteria-playlist/detailed.ts
720
- var CriteriaPlaylistDetailedSchema = import_zod6.z.object({
721
- uuid: GenrePlaylistUuidSchema,
722
- name: import_zod6.z.string(),
723
- tracksCount: import_zod6.z.number(),
724
- // Summed YouTube views of the same songs as `tracksCount`. Optional: hear-api has no view counts.
725
- viewsCount: import_zod6.z.number().optional(),
726
- durationInSec: import_zod6.z.number().min(0).nullable().optional(),
727
- durationStrInHourMinSec: import_zod6.z.string().nullable().optional(),
728
- // Nullable: the "Genreless" root playlist has no criteria attached and is never updated.
729
- criteria: CriteriaMinimumSchema.nullable(),
730
- parent: CriteriaPlaylistMinimumSchema.nullable(),
731
- root: CriteriaPlaylistMinimumSchema,
732
- createdOn: import_zod6.z.string(),
733
- updatedOn: import_zod6.z.string().nullable()
734
- });
735
-
736
- // src/genre-tree/schemas/criteria-playlist/simple.ts
737
- var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
738
- uuid: true,
739
- name: true,
740
- criteria: true,
741
- parent: true,
742
- root: true,
743
- tracksCount: true,
744
- viewsCount: true,
745
- createdOn: true,
746
- updatedOn: true
747
- }).extend({
748
- // Only on the tree/list payloads, not the detail endpoint — hence not on the detailed schema.
749
- isUnacceptedRoot: import_zod7.z.boolean(),
750
- // Optional: a backend that does not curate umbrella genres omits it.
751
- isUmbrella: import_zod7.z.boolean().optional(),
752
- // Optional: only the grow tree payload carries it; null when the genre has no scene.
753
- scene: import_zod7.z.enum(["commercial", "underground"]).nullable().optional()
754
- });
755
-
756
897
  // src/transport/lib/paginated-response.ts
757
- var import_zod8 = require("zod");
758
- var PaginatedResponseSchema = (itemSchema) => import_zod8.z.object({
759
- overallTotal: import_zod8.z.number(),
760
- next: import_zod8.z.string().url().nullable(),
761
- previous: import_zod8.z.string().url().nullable(),
762
- results: import_zod8.z.array(itemSchema),
763
- page: import_zod8.z.number(),
764
- pageSize: import_zod8.z.number(),
765
- totalPages: import_zod8.z.number()
898
+ var import_zod16 = require("zod");
899
+ var PaginatedResponseSchema = (itemSchema) => import_zod16.z.object({
900
+ overallTotal: import_zod16.z.number(),
901
+ next: import_zod16.z.string().url().nullable(),
902
+ previous: import_zod16.z.string().url().nullable(),
903
+ results: import_zod16.z.array(itemSchema),
904
+ page: import_zod16.z.number(),
905
+ pageSize: import_zod16.z.number(),
906
+ totalPages: import_zod16.z.number()
766
907
  });
767
908
 
768
909
  // src/genre-tree/api/genre-playlists/queryKeys.ts
@@ -800,6 +941,30 @@ var genrePlaylistEndpoints = {
800
941
  reference: { ...makeGenrePlaylistEndpoints(""), tree: () => "genre-playlists/tree/" }
801
942
  };
802
943
 
944
+ // src/genre-tree/lib/genre-music-selection.ts
945
+ function defaultGenreMusicSelection(counts) {
946
+ return { coverage: "genreAndSubgenres", subgenres: "canonical" in counts.genreAndSubgenresTracksCount ? "canonical" : "all" };
947
+ }
948
+ function genreMusicCount(counts, selection = defaultGenreMusicSelection(counts)) {
949
+ if (selection.coverage === "genreOnly") return counts.genreOnlyTracksCount;
950
+ const scopes = counts.genreAndSubgenresTracksCount;
951
+ if (selection.subgenres === "all") return scopes.all;
952
+ if (!("canonical" in scopes)) throw new Error("Regional genres only support all subgenres");
953
+ return scopes[selection.subgenres];
954
+ }
955
+ function genreMusicQueryParams(selection) {
956
+ if (!selection) return {};
957
+ return selection.coverage === "genreOnly" ? { coverage: "genre_only" } : { coverage: "genre_and_subgenres", subgenres: selection.subgenres };
958
+ }
959
+ function genreMusicSelectionKey(selection) {
960
+ return selection ? [selection.coverage, ...selection.coverage === "genreAndSubgenres" ? [selection.subgenres] : []] : [];
961
+ }
962
+ function genrePlaylistTrackCount(playlist) {
963
+ if (playlist.genreOnlyTracksCount === void 0 && playlist.genreAndSubgenresTracksCount === void 0) return playlist.tracksCount;
964
+ if (playlist.genreOnlyTracksCount === void 0 || playlist.genreAndSubgenresTracksCount === void 0) throw new Error("Incomplete genre playlist counts");
965
+ return genreMusicCount({ genreOnlyTracksCount: playlist.genreOnlyTracksCount, genreAndSubgenresTracksCount: playlist.genreAndSubgenresTracksCount });
966
+ }
967
+
803
968
  // src/genre-tree/api/library/songs/queryKeys.ts
804
969
  var makeSongQueryKeys = (prefix) => ({
805
970
  all: [`${prefix}Songs`],
@@ -808,7 +973,7 @@ var makeSongQueryKeys = (prefix) => ({
808
973
  history: (uuid) => [`${prefix}Songs`, "history", uuid],
809
974
  search: (params) => [`${prefix}Songs`, "search", params],
810
975
  // baseUrl keeps distinct backends sharing a scope (e.g. grow and its prototype proxy) apart.
811
- byGenre: (baseUrl, genreUuid) => [`${prefix}Songs`, baseUrl, "genre", genreUuid]
976
+ byGenre: (baseUrl, genreUuid, selection) => [`${prefix}Songs`, baseUrl, "genre", genreUuid, ...genreMusicSelectionKey(selection)]
812
977
  });
813
978
 
814
979
  // src/genre-tree/api/library/songs/endpoints.ts
@@ -878,7 +1043,7 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
878
1043
  const queryClient2 = (0, import_react_query3.useQueryClient)();
879
1044
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
880
1045
  const { session, sessionRestored } = useSession();
881
- const queryKey = scope === "reference" ? genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()) : genrePlaylistQueryKeys.me.full;
1046
+ const queryKey = scope === "reference" ? [...genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()), "genreMusicV1"] : genrePlaylistQueryKeys.me.full;
882
1047
  const query = useQueryWithParse({
883
1048
  queryKey,
884
1049
  queryFn: () => scope === "reference" ? fetch2(genrePlaylistEndpoints.reference.tree(), true, false, {}, { treeName: "canonical" }) : fetchAllPages(
@@ -890,7 +1055,7 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
890
1055
  { page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "canonical" }
891
1056
  )
892
1057
  ),
893
- schema: import_zod9.z.array(CriteriaPlaylistSimpleSchema),
1058
+ schema: scope === "reference" ? import_zod17.z.array(ReferenceGenrePlaylistSchema) : import_zod17.z.array(CriteriaPlaylistSimpleSchema),
894
1059
  context: "useListFullGenrePlaylists",
895
1060
  enabled: scope === "reference" || sessionRestored && !!session?.accessToken
896
1061
  });
@@ -926,7 +1091,7 @@ var useInvalidateAllGenrePlaylistQueries = () => {
926
1091
  // src/transport/lib/use-validated-mutation.ts
927
1092
  var import_react_query4 = require("@tanstack/react-query");
928
1093
  var import_react5 = require("react");
929
- var import_zod10 = require("zod");
1094
+ var import_zod18 = require("zod");
930
1095
  function useValidatedMutation({
931
1096
  inputSchema,
932
1097
  outputSchema,
@@ -959,9 +1124,9 @@ function useValidatedMutation({
959
1124
  } catch (error) {
960
1125
  if (error instanceof Error && "json" in error) {
961
1126
  try {
962
- const errorResponse = import_zod10.z.object({
963
- details: import_zod10.z.object({
964
- fieldErrors: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.array(import_zod10.z.object({ message: import_zod10.z.string() })))
1127
+ const errorResponse = import_zod18.z.object({
1128
+ details: import_zod18.z.object({
1129
+ fieldErrors: import_zod18.z.record(import_zod18.z.string(), import_zod18.z.array(import_zod18.z.object({ message: import_zod18.z.string() })))
965
1130
  })
966
1131
  }).parse(error.json);
967
1132
  setFormErrors(
@@ -984,131 +1149,48 @@ function useValidatedMutation({
984
1149
  return { ...validatedMutation, formErrors };
985
1150
  }
986
1151
 
987
- // src/genre-tree/schemas/criteria/detailed.ts
988
- var import_zod17 = require("zod");
989
-
990
- // src/genre-tree/schemas/track/base.ts
991
- var import_zod14 = require("zod");
992
-
993
- // src/genre-tree/schemas/artist-minimum.ts
994
- var import_zod11 = require("zod");
995
- var ArtistMinimumSchema = import_zod11.z.object({
996
- uuid: import_zod11.z.string().uuid(),
997
- name: import_zod11.z.string(),
998
- isSpecialPurpose: import_zod11.z.boolean().optional()
999
- });
1000
-
1001
- // src/genre-tree/schemas/album-minimum.ts
1002
- var import_zod12 = require("zod");
1003
- var AlbumMinimumSchema = import_zod12.z.object({
1004
- uuid: import_zod12.z.string().uuid(),
1005
- name: import_zod12.z.string(),
1006
- albumArtists: import_zod12.z.array(ArtistMinimumSchema).nullable().optional()
1007
- });
1008
-
1009
- // src/genre-tree/schemas/uuid-resource.ts
1010
- var import_zod13 = require("zod");
1011
- var UuidResourceSchema = import_zod13.z.object({
1012
- uuid: import_zod13.z.string().uuid()
1013
- });
1014
-
1015
- // src/genre-tree/schemas/track/base.ts
1016
- var TrackBaseSchema = UuidResourceSchema.extend({
1017
- title: import_zod14.z.string(),
1018
- artists: import_zod14.z.array(ArtistMinimumSchema).nullable().optional(),
1019
- album: AlbumMinimumSchema.nullable().optional(),
1020
- trackNumber: import_zod14.z.number().nullable().optional(),
1021
- // null for a song not yet linked to a genre.
1022
- genre: CriteriaMinimumSchema.nullable(),
1023
- rating: import_zod14.z.number().min(0).max(10).nullable().optional(),
1024
- language: import_zod14.z.string().nullable().optional(),
1025
- playCount: import_zod14.z.number().min(0),
1026
- createdOn: import_zod14.z.string().datetime(),
1027
- updatedOn: import_zod14.z.string().datetime().nullable().optional()
1028
- });
1029
-
1030
- // src/genre-tree/schemas/track/minimum.ts
1031
- var TrackMinimumSchema = TrackBaseSchema.pick({
1032
- uuid: true,
1033
- title: true,
1034
- artists: true
1035
- });
1036
-
1037
- // src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
1038
- var import_zod15 = require("zod");
1039
- var CriteriaLineageRelWithoutAscendantSchema = import_zod15.z.object({
1040
- descendant: CriteriaMinimumSchema,
1041
- degree: import_zod15.z.number()
1042
- });
1043
-
1044
- // src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
1045
- var import_zod16 = require("zod");
1046
- var CriteriaLineageRelWithoutDescendantSchema = import_zod16.z.object({
1047
- ascendant: CriteriaMinimumSchema,
1048
- degree: import_zod16.z.number()
1049
- });
1050
-
1051
- // src/genre-tree/schemas/criteria/detailed.ts
1052
- var CriteriaDetailedSchema = import_zod17.z.object({
1053
- uuid: GenreUuidSchema,
1054
- name: import_zod17.z.string(),
1055
- summary: import_zod17.z.string().nullable(),
1056
- // Optional until every deployed API serves it.
1057
- wikidataId: import_zod17.z.string().nullable().optional(),
1058
- parent: CriteriaMinimumSchema.nullable(),
1059
- ascendants: import_zod17.z.array(CriteriaLineageRelWithoutDescendantSchema),
1060
- descendants: import_zod17.z.array(CriteriaLineageRelWithoutAscendantSchema),
1061
- root: CriteriaMinimumSchema,
1062
- children: import_zod17.z.array(CriteriaMinimumSchema),
1063
- criteriaPlaylist: CriteriaPlaylistMinimumSchema,
1064
- tracks: import_zod17.z.array(TrackMinimumSchema),
1065
- essentialSongs: import_zod17.z.array(TrackMinimumSchema),
1066
- tracksCount: import_zod17.z.number(),
1067
- updatedOn: import_zod17.z.string().datetime().nullable()
1068
- });
1069
-
1070
1152
  // src/genre-tree/schemas/criteria/overview.ts
1071
- var import_zod19 = require("zod");
1153
+ var import_zod20 = require("zod");
1072
1154
 
1073
1155
  // src/genre-tree/schemas/http-url.ts
1074
- var import_zod18 = require("zod");
1075
- var HttpUrlSchema = import_zod18.z.url({ protocol: /^https?$/ });
1156
+ var import_zod19 = require("zod");
1157
+ var HttpUrlSchema = import_zod19.z.url({ protocol: /^https?$/ });
1076
1158
 
1077
1159
  // src/genre-tree/schemas/criteria/overview.ts
1078
- var CriteriaOverviewSchema = import_zod19.z.object({
1160
+ var CriteriaOverviewSchema = import_zod20.z.object({
1079
1161
  uuid: GenreUuidSchema,
1080
- name: import_zod19.z.string(),
1081
- summary: import_zod19.z.string().nullable(),
1082
- description: import_zod19.z.string().nullable(),
1162
+ name: import_zod20.z.string(),
1163
+ summary: import_zod20.z.string().nullable(),
1164
+ description: import_zod20.z.string().nullable(),
1083
1165
  summarySourceUrl: HttpUrlSchema.nullable(),
1084
- essentialSongs: import_zod19.z.array(TrackMinimumSchema).optional()
1166
+ essentialSongs: import_zod20.z.array(TrackMinimumSchema).optional()
1085
1167
  });
1086
1168
 
1087
1169
  // src/genre-tree/schemas/criteria/simple.ts
1088
- var import_zod20 = require("zod");
1089
- var CriteriaSimpleSchema = import_zod20.z.object({
1170
+ var import_zod21 = require("zod");
1171
+ var CriteriaSimpleSchema = import_zod21.z.object({
1090
1172
  uuid: GenreUuidSchema,
1091
- name: import_zod20.z.string(),
1173
+ name: import_zod21.z.string(),
1092
1174
  parent: CriteriaMinimumSchema.nullable(),
1093
- createdOn: import_zod20.z.string().datetime(),
1094
- summary: import_zod20.z.string().nullable()
1175
+ createdOn: import_zod21.z.string().datetime(),
1176
+ summary: import_zod21.z.string().nullable()
1095
1177
  });
1096
1178
 
1097
1179
  // src/genre-tree/schemas/criteria/creation.ts
1098
- var import_zod21 = require("zod");
1099
- var CriteriaCreationSchema = import_zod21.z.object({
1100
- name: import_zod21.z.string().min(1, "Name is required"),
1180
+ var import_zod22 = require("zod");
1181
+ var CriteriaCreationSchema = import_zod22.z.object({
1182
+ name: import_zod22.z.string().min(1, "Name is required"),
1101
1183
  parent: GenreUuidSchema.optional(),
1102
- essentialSongs: import_zod21.z.array(import_zod21.z.string().uuid()).optional()
1184
+ essentialSongs: import_zod22.z.array(import_zod22.z.string().uuid()).optional()
1103
1185
  });
1104
1186
 
1105
1187
  // src/genre-tree/schemas/criteria/update.ts
1106
- var import_zod22 = require("zod");
1107
- var CriteriaUpdateSchema = import_zod22.z.object({
1108
- name: import_zod22.z.string().optional(),
1188
+ var import_zod23 = require("zod");
1189
+ var CriteriaUpdateSchema = import_zod23.z.object({
1190
+ name: import_zod23.z.string().optional(),
1109
1191
  parent: GenreUuidSchema.nullable().optional(),
1110
- essentialSongs: import_zod22.z.array(import_zod22.z.string().uuid()).optional(),
1111
- side: import_zod22.z.enum(["core", "pop"]).optional()
1192
+ essentialSongs: import_zod23.z.array(import_zod23.z.string().uuid()).optional(),
1193
+ side: import_zod23.z.enum(["core", "pop"]).optional()
1112
1194
  });
1113
1195
 
1114
1196
  // src/genre-tree/api/genres/queryKeys.ts
@@ -1169,18 +1251,18 @@ function useFetchGenre(scope, getBackendBaseUrl) {
1169
1251
  async (id) => {
1170
1252
  const endpoint = scope === "reference" ? genreEndpoints.reference.detail(id) : genreEndpoints.me.detail(id);
1171
1253
  const response = await fetch2(endpoint, true, scope === "me");
1172
- return parseWithLog(CriteriaDetailedSchema, response, "useFetchGenre");
1254
+ return parseWithLog(scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema, response, "useFetchGenre");
1173
1255
  },
1174
1256
  [fetch2, scope]
1175
1257
  );
1176
1258
  }
1177
- function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = CriteriaDetailedSchema) {
1259
+ function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema) {
1178
1260
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1179
1261
  const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
1180
1262
  const endpoints = scope === "reference" ? genreEndpoints.reference : genreEndpoints.me;
1181
1263
  const genreUuid = id ?? "";
1182
1264
  return useQueryWithParse({
1183
- queryKey: queryKeys.detail(genreUuid),
1265
+ queryKey: scope === "reference" ? [...queryKeys.detail(genreUuid), getBackendBaseUrl(), "genreMusicV1"] : queryKeys.detail(genreUuid),
1184
1266
  queryFn: () => fetch2(endpoints.detail(genreUuid), true, scope === "me"),
1185
1267
  schema,
1186
1268
  context: "useFetchGenreDetail",
@@ -1263,7 +1345,7 @@ function useUpdateGenre(scope, getBackendBaseUrl) {
1263
1345
  const refreshGenreTree = useRefreshGenreTree(scope);
1264
1346
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1265
1347
  const { mutate, mutateAsync, isPending, formErrors } = useValidatedMutation({
1266
- inputSchema: import_zod23.z.object({
1348
+ inputSchema: import_zod24.z.object({
1267
1349
  uuid: GenreUuidSchema,
1268
1350
  data: CriteriaUpdateSchema
1269
1351
  }),
@@ -1293,8 +1375,8 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
1293
1375
  const refreshGenreTree = useRefreshGenreTree(scope);
1294
1376
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1295
1377
  return useValidatedMutation({
1296
- inputSchema: import_zod23.z.object({ uuid: GenreUuidSchema }),
1297
- outputSchema: import_zod23.z.null(),
1378
+ inputSchema: import_zod24.z.object({ uuid: GenreUuidSchema }),
1379
+ outputSchema: import_zod24.z.null(),
1298
1380
  mutationFn: async ({ uuid }) => {
1299
1381
  const endpoint = scope === "reference" ? genreEndpoints.reference.delete(uuid) : genreEndpoints.me.delete(uuid);
1300
1382
  return fetch2(endpoint, true, scope === "me", { method: "DELETE" }, void 0, false, true);
@@ -1304,16 +1386,16 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
1304
1386
  }
1305
1387
 
1306
1388
  // src/genre-tree/useArtist.ts
1307
- var import_zod25 = require("zod");
1389
+ var import_zod26 = require("zod");
1308
1390
 
1309
1391
  // src/genre-tree/schemas/artist-detailed.ts
1310
- var import_zod24 = require("zod");
1311
- var ArtistMembershipSchema = import_zod24.z.object({
1392
+ var import_zod25 = require("zod");
1393
+ var ArtistMembershipSchema = import_zod25.z.object({
1312
1394
  artist: ArtistMinimumSchema,
1313
- beginYear: import_zod24.z.number().int().nullable(),
1314
- endYear: import_zod24.z.number().int().nullable(),
1315
- ended: import_zod24.z.boolean(),
1316
- roles: import_zod24.z.array(import_zod24.z.string())
1395
+ beginYear: import_zod25.z.number().int().nullable(),
1396
+ endYear: import_zod25.z.number().int().nullable(),
1397
+ ended: import_zod25.z.boolean(),
1398
+ roles: import_zod25.z.array(import_zod25.z.string())
1317
1399
  });
1318
1400
  var ARTIST_LINK_KINDS = [
1319
1401
  "official",
@@ -1326,35 +1408,35 @@ var ARTIST_LINK_KINDS = [
1326
1408
  "discogs",
1327
1409
  "social"
1328
1410
  ];
1329
- var ArtistImageSchema = import_zod24.z.object({
1411
+ var ArtistImageSchema = import_zod25.z.object({
1330
1412
  url: HttpUrlSchema,
1331
1413
  pageUrl: HttpUrlSchema,
1332
- author: import_zod24.z.string().nullable(),
1333
- license: import_zod24.z.string(),
1414
+ author: import_zod25.z.string().nullable(),
1415
+ license: import_zod25.z.string(),
1334
1416
  licenseUrl: HttpUrlSchema.nullable()
1335
1417
  });
1336
- var ArtistDetailedSchema = import_zod24.z.object({
1337
- uuid: import_zod24.z.string().uuid(),
1338
- name: import_zod24.z.string(),
1339
- musicbrainzArtistId: import_zod24.z.string().uuid().nullable(),
1340
- type: import_zod24.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
1341
- country: import_zod24.z.string().nullable(),
1342
- beginYear: import_zod24.z.number().int().nullable(),
1343
- endYear: import_zod24.z.number().int().nullable(),
1344
- ended: import_zod24.z.boolean(),
1345
- links: import_zod24.z.array(import_zod24.z.object({ kind: import_zod24.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
1346
- members: import_zod24.z.array(ArtistMembershipSchema),
1347
- memberOf: import_zod24.z.array(ArtistMembershipSchema),
1348
- albums: import_zod24.z.array(
1349
- import_zod24.z.object({
1350
- uuid: import_zod24.z.string().uuid(),
1351
- name: import_zod24.z.string(),
1352
- year: import_zod24.z.string().nullable(),
1353
- primaryType: import_zod24.z.string().nullable(),
1354
- secondaryTypes: import_zod24.z.array(import_zod24.z.string())
1418
+ var ArtistDetailedSchema = import_zod25.z.object({
1419
+ uuid: import_zod25.z.string().uuid(),
1420
+ name: import_zod25.z.string(),
1421
+ musicbrainzArtistId: import_zod25.z.string().uuid().nullable(),
1422
+ type: import_zod25.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
1423
+ country: import_zod25.z.string().nullable(),
1424
+ beginYear: import_zod25.z.number().int().nullable(),
1425
+ endYear: import_zod25.z.number().int().nullable(),
1426
+ ended: import_zod25.z.boolean(),
1427
+ links: import_zod25.z.array(import_zod25.z.object({ kind: import_zod25.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
1428
+ members: import_zod25.z.array(ArtistMembershipSchema),
1429
+ memberOf: import_zod25.z.array(ArtistMembershipSchema),
1430
+ albums: import_zod25.z.array(
1431
+ import_zod25.z.object({
1432
+ uuid: import_zod25.z.string().uuid(),
1433
+ name: import_zod25.z.string(),
1434
+ year: import_zod25.z.string().nullable(),
1435
+ primaryType: import_zod25.z.string().nullable(),
1436
+ secondaryTypes: import_zod25.z.array(import_zod25.z.string())
1355
1437
  })
1356
1438
  ),
1357
- tracksCount: import_zod24.z.number().int(),
1439
+ tracksCount: import_zod25.z.number().int(),
1358
1440
  image: ArtistImageSchema.nullable()
1359
1441
  });
1360
1442
 
@@ -1377,7 +1459,7 @@ var artistEndpoints = {
1377
1459
  var isNotFound = (error) => error instanceof AppError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */;
1378
1460
  function useArtist(uuid, getBackendBaseUrl) {
1379
1461
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1380
- const isUuid = uuid !== null && import_zod25.z.string().uuid().safeParse(uuid).success;
1462
+ const isUuid = uuid !== null && import_zod26.z.string().uuid().safeParse(uuid).success;
1381
1463
  const { data, isPending, error } = useQueryWithParse({
1382
1464
  queryKey: artistQueryKeys.detail(uuid),
1383
1465
  // A missing artist is shown in the panel, not raised as an app-wide connectivity error.
@@ -1395,19 +1477,19 @@ function useArtist(uuid, getBackendBaseUrl) {
1395
1477
  }
1396
1478
 
1397
1479
  // src/genre-tree/schemas/artist-search.ts
1398
- var import_zod26 = require("zod");
1399
- var ArtistSearchResultSchema = import_zod26.z.object({
1400
- uuid: import_zod26.z.string().uuid(),
1401
- name: import_zod26.z.string(),
1402
- disambiguation: import_zod26.z.string().nullable(),
1403
- type: import_zod26.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
1404
- country: import_zod26.z.string().nullable(),
1405
- beginYear: import_zod26.z.number().int().nullable(),
1406
- endYear: import_zod26.z.number().int().nullable(),
1407
- matchedAlias: import_zod26.z.string().nullable(),
1408
- recordingCount: import_zod26.z.number().int()
1480
+ var import_zod27 = require("zod");
1481
+ var ArtistSearchResultSchema = import_zod27.z.object({
1482
+ uuid: import_zod27.z.string().uuid(),
1483
+ name: import_zod27.z.string(),
1484
+ disambiguation: import_zod27.z.string().nullable(),
1485
+ type: import_zod27.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
1486
+ country: import_zod27.z.string().nullable(),
1487
+ beginYear: import_zod27.z.number().int().nullable(),
1488
+ endYear: import_zod27.z.number().int().nullable(),
1489
+ matchedAlias: import_zod27.z.string().nullable(),
1490
+ recordingCount: import_zod27.z.number().int()
1409
1491
  });
1410
- var ArtistSearchResultsSchema = import_zod26.z.array(ArtistSearchResultSchema);
1492
+ var ArtistSearchResultsSchema = import_zod27.z.array(ArtistSearchResultSchema);
1411
1493
 
1412
1494
  // src/genre-tree/useRemoteSearch.ts
1413
1495
  var import_react_query6 = require("@tanstack/react-query");
@@ -1461,10 +1543,10 @@ function useArtistSearch(getBackendBaseUrl, text) {
1461
1543
  }
1462
1544
 
1463
1545
  // src/genre-tree/useSong.ts
1464
- var import_zod28 = require("zod");
1546
+ var import_zod29 = require("zod");
1465
1547
 
1466
1548
  // src/genre-tree/schemas/song/detailed.ts
1467
- var import_zod27 = require("zod");
1549
+ var import_zod28 = require("zod");
1468
1550
  var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
1469
1551
  not_found: "Video unavailable",
1470
1552
  not_embeddable: "Embedding disabled",
@@ -1473,23 +1555,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
1473
1555
  region_whitelisted: "Region restricted"
1474
1556
  };
1475
1557
  var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
1476
- var YoutubeAvailabilitySchema = import_zod27.z.object({
1477
- status: import_zod27.z.enum(["eligible", "blocked", "unknown"]),
1478
- reason: import_zod27.z.string().nullable(),
1479
- country: import_zod27.z.string().nullable()
1558
+ var YoutubeAvailabilitySchema = import_zod28.z.object({
1559
+ status: import_zod28.z.enum(["eligible", "blocked", "unknown"]),
1560
+ reason: import_zod28.z.string().nullable(),
1561
+ country: import_zod28.z.string().nullable()
1480
1562
  });
1481
1563
  var SongDetailedSchema = TrackBaseSchema.extend({
1482
- youtubeVideo: import_zod27.z.object({
1483
- id: import_zod27.z.string(),
1564
+ youtubeVideo: import_zod28.z.object({
1565
+ id: import_zod28.z.string(),
1484
1566
  availability: YoutubeAvailabilitySchema.optional(),
1485
1567
  // null = playable
1486
- unplayableReason: import_zod27.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
1487
- viewCount: import_zod27.z.number().int().nullable().optional()
1568
+ unplayableReason: import_zod28.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
1569
+ viewCount: import_zod28.z.number().int().nullable().optional()
1488
1570
  }).nullable(),
1489
1571
  // null for hand-made/admin songs
1490
- musicbrainzRecordingId: import_zod27.z.string().uuid().nullable(),
1491
- firstReleaseYear: import_zod27.z.number().int().nullable().optional(),
1492
- essentialGenres: import_zod27.z.array(CriteriaMinimumSchema).optional()
1572
+ musicbrainzRecordingId: import_zod28.z.string().uuid().nullable(),
1573
+ firstReleaseYear: import_zod28.z.number().int().nullable().optional(),
1574
+ essentialGenres: import_zod28.z.array(CriteriaMinimumSchema).optional()
1493
1575
  });
1494
1576
  var NO_VIDEO_LABEL = "No video available";
1495
1577
  function isSong(track) {
@@ -1510,7 +1592,7 @@ var isNotFound2 = (error) => error instanceof AppError && error.code === "BAC404
1510
1592
  function useSong(uuid, getBackendBaseUrl) {
1511
1593
  const playback = usePlaybackContext();
1512
1594
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1513
- const isUuid = uuid !== null && import_zod28.z.string().uuid().safeParse(uuid).success;
1595
+ const isUuid = uuid !== null && import_zod29.z.string().uuid().safeParse(uuid).success;
1514
1596
  const { data, isPending, error } = useQueryWithParse({
1515
1597
  queryKey: [...libraryQueryKeys.reference.songs.detail(uuid), ...playback.key ? [playback.key] : []],
1516
1598
  // A missing song is shown in the panel, not raised as an app-wide connectivity error.
@@ -1528,16 +1610,16 @@ function useSong(uuid, getBackendBaseUrl) {
1528
1610
  }
1529
1611
 
1530
1612
  // src/genre-tree/schemas/song-history.ts
1531
- var import_zod29 = require("zod");
1532
- var SongHistoryEntrySchema = import_zod29.z.object({
1533
- uuid: import_zod29.z.string().uuid(),
1534
- action: import_zod29.z.string(),
1535
- actorPseudo: import_zod29.z.string().nullable(),
1536
- oldValue: import_zod29.z.string().nullable(),
1537
- newValue: import_zod29.z.string().nullable(),
1538
- createdOn: import_zod29.z.string()
1613
+ var import_zod30 = require("zod");
1614
+ var SongHistoryEntrySchema = import_zod30.z.object({
1615
+ uuid: import_zod30.z.string().uuid(),
1616
+ action: import_zod30.z.string(),
1617
+ actorPseudo: import_zod30.z.string().nullable(),
1618
+ oldValue: import_zod30.z.string().nullable(),
1619
+ newValue: import_zod30.z.string().nullable(),
1620
+ createdOn: import_zod30.z.string()
1539
1621
  });
1540
- var SongHistorySchema = import_zod29.z.array(SongHistoryEntrySchema);
1622
+ var SongHistorySchema = import_zod30.z.array(SongHistoryEntrySchema);
1541
1623
 
1542
1624
  // src/genre-tree/useSongHistory.ts
1543
1625
  function useSongHistory(uuid, getBackendBaseUrl, enabled) {
@@ -1557,20 +1639,20 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
1557
1639
  }
1558
1640
 
1559
1641
  // src/genre-tree/schemas/song-search.ts
1560
- var import_zod30 = require("zod");
1561
- var SongSearchResultSchema = import_zod30.z.object({
1562
- uuid: import_zod30.z.string().uuid(),
1563
- title: import_zod30.z.string(),
1564
- artists: import_zod30.z.array(ArtistMinimumSchema),
1642
+ var import_zod31 = require("zod");
1643
+ var SongSearchResultSchema = import_zod31.z.object({
1644
+ uuid: import_zod31.z.string().uuid(),
1645
+ title: import_zod31.z.string(),
1646
+ artists: import_zod31.z.array(ArtistMinimumSchema),
1565
1647
  // null for songs not yet linked to a genre.
1566
1648
  genre: CriteriaMinimumSchema.nullable(),
1567
- youtubeVideo: import_zod30.z.object({
1568
- id: import_zod30.z.string(),
1569
- unplayableReason: import_zod30.z.string().nullable()
1649
+ youtubeVideo: import_zod31.z.object({
1650
+ id: import_zod31.z.string(),
1651
+ unplayableReason: import_zod31.z.string().nullable()
1570
1652
  }).nullable(),
1571
- firstReleaseYear: import_zod30.z.number().int().nullable()
1653
+ firstReleaseYear: import_zod31.z.number().int().nullable()
1572
1654
  });
1573
- var SongSearchResultsSchema = import_zod30.z.array(SongSearchResultSchema);
1655
+ var SongSearchResultsSchema = import_zod31.z.array(SongSearchResultSchema);
1574
1656
  function isSongSearchResultPlayable(result) {
1575
1657
  return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
1576
1658
  }
@@ -1596,16 +1678,25 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
1596
1678
 
1597
1679
  // src/genre-tree/useArtistGenreCounts.ts
1598
1680
  var import_react_query7 = require("@tanstack/react-query");
1599
- var import_zod32 = require("zod");
1681
+ var import_zod33 = require("zod");
1600
1682
 
1601
1683
  // src/genre-tree/schemas/artist-genre-count.ts
1602
- var import_zod31 = require("zod");
1603
- var ArtistGenreCountSchema = import_zod31.z.object({
1684
+ var import_zod32 = require("zod");
1685
+ var ArtistGenreCountSchema = import_zod32.z.object({
1686
+ ...GenreCountsSchema.shape,
1687
+ catalogue: GenreCatalogueCountsSchema,
1604
1688
  genrePlaylist: GenrePlaylistUuidSchema,
1605
- /** All the artist's songs in the genre playlist's subtree; drives pruning. */
1606
- songsCount: import_zod31.z.number().int().nonnegative(),
1607
- /** The playable ones among them; drives node size and the play button. */
1608
- tracksCount: import_zod31.z.number().int().nonnegative()
1689
+ /** Legacy catalogue count for the default selection. */
1690
+ songsCount: import_zod32.z.number().int().nonnegative(),
1691
+ /** Legacy playlist count for the default selection. */
1692
+ tracksCount: import_zod32.z.number().int().nonnegative()
1693
+ }).superRefine((row, ctx) => {
1694
+ const counts = GenreCatalogueCountsSchema.safeParse(row);
1695
+ if (!counts.success) {
1696
+ for (const issue of counts.error.issues) {
1697
+ ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
1698
+ }
1699
+ }
1609
1700
  });
1610
1701
 
1611
1702
  // src/genre-tree/useArtistGenreCounts.ts
@@ -1613,10 +1704,10 @@ var isNotFound3 = (error) => error instanceof AppError && error.code === "BAC404
1613
1704
  function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
1614
1705
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1615
1706
  return useQueryWithParse({
1616
- queryKey: artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid),
1707
+ queryKey: [...artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid), "genreMusicV1"],
1617
1708
  // A missing artist is shown in the artist panel, not raised as an app-wide connectivity error.
1618
1709
  queryFn: () => fetch2(artistEndpoints.genreCounts(artistUuid), true, false, void 0, void 0, false, true),
1619
- schema: import_zod32.z.array(ArtistGenreCountSchema),
1710
+ schema: import_zod33.z.array(ArtistGenreCountSchema),
1620
1711
  enabled: artistUuid !== null,
1621
1712
  placeholderData: import_react_query7.keepPreviousData,
1622
1713
  retry: (failureCount, error) => !isNotFound3(error) && failureCount < 3,
@@ -1720,32 +1811,32 @@ function useGenreSearch({
1720
1811
  }
1721
1812
 
1722
1813
  // src/genre-tree/schemas/genre-search.ts
1723
- var import_zod33 = require("zod");
1724
- var GenreSearchTreeNameSchema = import_zod33.z.enum(["canonical", "regional"]);
1725
- var GenreSearchResultSchema = import_zod33.z.object({
1814
+ var import_zod34 = require("zod");
1815
+ var GenreSearchTreeNameSchema = import_zod34.z.enum(["canonical", "regional"]);
1816
+ var GenreSearchResultSchema = import_zod34.z.object({
1726
1817
  /** Criteria (genre) uuid. */
1727
1818
  uuid: GenreUuidSchema,
1728
- name: import_zod33.z.string(),
1819
+ name: import_zod34.z.string(),
1729
1820
  /** Null for app-created genres, which the Wikidata-keyed region index does not reference. */
1730
- wikidataId: import_zod33.z.string().nullable(),
1731
- treeName: import_zod33.z.string(),
1821
+ wikidataId: import_zod34.z.string().nullable(),
1822
+ treeName: import_zod34.z.string(),
1732
1823
  /** Null when the genre has no playlist in the tree, so it cannot be opened there. */
1733
1824
  genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
1734
- root: import_zod33.z.object({ uuid: GenreUuidSchema, name: import_zod33.z.string() }),
1735
- isUmbrella: import_zod33.z.boolean(),
1736
- viewsCount: import_zod33.z.number().int()
1825
+ root: import_zod34.z.object({ uuid: GenreUuidSchema, name: import_zod34.z.string() }),
1826
+ isUmbrella: import_zod34.z.boolean(),
1827
+ viewsCount: import_zod34.z.number().int()
1737
1828
  });
1738
- var GenreSearchResultsSchema = import_zod33.z.array(GenreSearchResultSchema);
1739
- var RegionGenreLexiconEntrySchema = import_zod33.z.object({
1740
- wikidataId: import_zod33.z.string(),
1829
+ var GenreSearchResultsSchema = import_zod34.z.array(GenreSearchResultSchema);
1830
+ var RegionGenreLexiconEntrySchema = import_zod34.z.object({
1831
+ wikidataId: import_zod34.z.string(),
1741
1832
  uuid: GenreUuidSchema,
1742
- name: import_zod33.z.string(),
1743
- treeName: import_zod33.z.string(),
1833
+ name: import_zod34.z.string(),
1834
+ treeName: import_zod34.z.string(),
1744
1835
  genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
1745
- isUmbrella: import_zod33.z.boolean(),
1746
- viewsCount: import_zod33.z.number().int()
1836
+ isUmbrella: import_zod34.z.boolean(),
1837
+ viewsCount: import_zod34.z.number().int()
1747
1838
  });
1748
- var RegionGenreLexiconSchema = import_zod33.z.array(RegionGenreLexiconEntrySchema);
1839
+ var RegionGenreLexiconSchema = import_zod34.z.array(RegionGenreLexiconEntrySchema);
1749
1840
 
1750
1841
  // src/genre-tree/useGenreRemoteSearch.ts
1751
1842
  var DEFAULT_RESULT_LIMIT2 = 8;
@@ -1792,7 +1883,7 @@ var pruneGenrePlaylistsForArtist = (playlists, counts) => {
1792
1883
  const kept = /* @__PURE__ */ new Set();
1793
1884
  for (const playlist of playlists) {
1794
1885
  const isPopRoot = playlist.parent === null && playlist.name === POP_ROOT_NAME;
1795
- if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.songsCount ?? 0) > 0) kept.add(playlist.uuid);
1886
+ if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.catalogue.genreAndSubgenresTracksCount.all ?? 0) > 0) kept.add(playlist.uuid);
1796
1887
  }
1797
1888
  const coreElectronicUuids = new Set(
1798
1889
  playlists.filter((playlist) => playlist.name === CORE_ELECTRONIC_NAME && kept.has(playlist.uuid)).map((p) => p.uuid)
@@ -1800,12 +1891,22 @@ var pruneGenrePlaylistsForArtist = (playlists, counts) => {
1800
1891
  for (const playlist of playlists) {
1801
1892
  if (playlist.parent && coreElectronicUuids.has(playlist.parent.uuid)) kept.add(playlist.uuid);
1802
1893
  }
1803
- return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) => ({
1804
- ...playlist,
1805
- tracksCount: countByPlaylist.get(playlist.uuid)?.tracksCount ?? 0,
1806
- // Per-artist view totals are not served, so the views metric is unavailable on a pruned tree.
1807
- viewsCount: 0
1808
- }));
1894
+ return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) => {
1895
+ const count = countByPlaylist.get(playlist.uuid);
1896
+ const catalogue = GenreCatalogueCountsSchema.parse(playlist.catalogue);
1897
+ const scopes = playlist.genreAndSubgenresTracksCount;
1898
+ if (!scopes) throw new Error("Artist projections require a reference genre summary");
1899
+ const zero = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: "canonical" in scopes ? { canonical: 0, regional: 0, all: 0 } : { all: 0 } };
1900
+ return {
1901
+ ...playlist,
1902
+ genreOnlyTracksCount: count?.genreOnlyTracksCount ?? 0,
1903
+ genreAndSubgenresTracksCount: count?.genreAndSubgenresTracksCount ?? zero.genreAndSubgenresTracksCount,
1904
+ catalogue: count?.catalogue ?? { ...catalogue, ...zero },
1905
+ tracksCount: count ? genreMusicCount(count) : 0,
1906
+ // Artist view totals are not served.
1907
+ viewsCount: void 0
1908
+ };
1909
+ });
1809
1910
  };
1810
1911
 
1811
1912
  // src/genre-tree/useVisibleGenrePlaylists.ts
@@ -1943,10 +2044,10 @@ function useGenreTreeViewState({
1943
2044
  var import_react13 = require("react");
1944
2045
 
1945
2046
  // src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
1946
- var import_zod34 = require("zod");
1947
- var makeTrackPlaylistRelSchema = (trackSchema) => import_zod34.z.object({
2047
+ var import_zod35 = require("zod");
2048
+ var makeTrackPlaylistRelSchema = (trackSchema) => import_zod35.z.object({
1948
2049
  track: trackSchema,
1949
- position: import_zod34.z.number().min(0)
2050
+ position: import_zod35.z.number().min(0)
1950
2051
  });
1951
2052
  var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
1952
2053
 
@@ -1995,6 +2096,7 @@ var TrackListFromArtist = class extends TrackList {
1995
2096
  var TrackListOriginType = /* @__PURE__ */ ((TrackListOriginType2) => {
1996
2097
  TrackListOriginType2["TRACK"] = "TRACK";
1997
2098
  TrackListOriginType2["GENRE_PLAYLIST"] = "GENRE_PLAYLIST";
2099
+ TrackListOriginType2["GENRE_CATALOGUE"] = "GENRE_CATALOGUE";
1998
2100
  TrackListOriginType2["ARTIST"] = "ARTIST";
1999
2101
  return TrackListOriginType2;
2000
2102
  })(TrackListOriginType || {});
@@ -2026,27 +2128,48 @@ var TrackListOriginFromTrack = class extends TrackListOrigin {
2026
2128
  };
2027
2129
  var TrackListOriginFromCriteriaPlaylist = class extends TrackListOrigin {
2028
2130
  /** `from`: the track the list starts at (server-side `?from=`), kept so later pages use it too. */
2029
- constructor(criteriaPlaylist, scope, from) {
2131
+ constructor(criteriaPlaylist, scope, from, selection, artistUuid) {
2030
2132
  super("GENRE_PLAYLIST" /* GENRE_PLAYLIST */, criteriaPlaylist.name, criteriaPlaylist.uuid, scope);
2031
2133
  this.criteriaPlaylist = criteriaPlaylist;
2032
2134
  this.from = from;
2135
+ this.selection = selection;
2136
+ this.artistUuid = artistUuid;
2033
2137
  }
2034
2138
  criteriaPlaylist;
2035
2139
  from;
2140
+ selection;
2141
+ artistUuid;
2036
2142
  };
2037
2143
  var TrackListOriginFromArtist = class extends TrackListOrigin {
2038
2144
  /** `ordering`/`from`: kept so later pages use the same order and start track. */
2039
- constructor(artist, scope, ordering, from, genreUuid) {
2145
+ constructor(artist, scope, ordering, from, genreUuid, selection) {
2040
2146
  super("ARTIST" /* ARTIST */, artist.name, artist.uuid, scope);
2041
2147
  this.artist = artist;
2042
2148
  this.ordering = ordering;
2043
2149
  this.from = from;
2044
2150
  this.genreUuid = genreUuid;
2151
+ this.selection = selection;
2045
2152
  }
2046
2153
  artist;
2047
2154
  ordering;
2048
2155
  from;
2049
2156
  genreUuid;
2157
+ selection;
2158
+ };
2159
+ var TrackListOriginFromGenreCatalogue = class extends TrackListOrigin {
2160
+ constructor(genre, scope, from, selection) {
2161
+ super("GENRE_CATALOGUE" /* GENRE_CATALOGUE */, genre.name, genre.uuid, scope);
2162
+ this.genre = genre;
2163
+ this.from = from;
2164
+ this.selection = selection;
2165
+ }
2166
+ genre;
2167
+ from;
2168
+ selection;
2169
+ ordering = "title";
2170
+ get genreUuid() {
2171
+ return this.genre.uuid;
2172
+ }
2050
2173
  };
2051
2174
 
2052
2175
  // src/player/PlayerContext.tsx
@@ -2172,9 +2295,10 @@ function TrackListProvider({
2172
2295
  [clearDelayedTrackLoad, loadTrackForPlayer]
2173
2296
  );
2174
2297
  const fetchTracksPage = (0, import_react13.useCallback)(
2175
- async (uuid, scope, page, from) => {
2298
+ async (uuid, scope, page, from, selection, artistUuid) => {
2176
2299
  const endpoint = genrePlaylistEndpoints[scope].tracks(uuid);
2177
- const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from } };
2300
+ if (scope === "me" && (selection || artistUuid)) throw new Error("Genre selections require reference scope");
2301
+ const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from }, ...genreMusicQueryParams(selection), ...artistUuid && { artist: artistUuid } };
2178
2302
  const response = await fetch2(endpoint, true, scope === "me", {}, params, false, !!from, page === 1);
2179
2303
  const parsed = parseWithLog(pageSchema, response, "fetchGenrePlaylistTracksPage");
2180
2304
  return {
@@ -2185,17 +2309,18 @@ function TrackListProvider({
2185
2309
  },
2186
2310
  [fetch2, pageSchema]
2187
2311
  );
2188
- const artistPageSchema = (0, import_react13.useMemo)(() => PaginatedResponseSchema(schema), [schema]);
2189
- const fetchArtistTracksPage = (0, import_react13.useCallback)(
2312
+ const cataloguePageSchema = (0, import_react13.useMemo)(() => PaginatedResponseSchema(schema), [schema]);
2313
+ const fetchCatalogueTracksPage = (0, import_react13.useCallback)(
2190
2314
  async (origin, page) => {
2191
2315
  const params = {
2192
- artist: origin.uuid,
2316
+ ...origin instanceof TrackListOriginFromArtist && { artist: origin.uuid },
2193
2317
  playable: true,
2194
2318
  ordering: origin.ordering,
2195
2319
  page,
2196
2320
  pageSize: TRACKS_PAGE_SIZE,
2197
2321
  ...origin.from && { from: origin.from },
2198
- ...origin.genreUuid && { genre: origin.genreUuid }
2322
+ ...origin.genreUuid && { genre: origin.genreUuid },
2323
+ ...genreMusicQueryParams(origin.selection)
2199
2324
  };
2200
2325
  const response = await fetch2(
2201
2326
  libraryEndpoints.reference.songs.list(),
@@ -2208,10 +2333,10 @@ function TrackListProvider({
2208
2333
  page === 1 && !!origin.from,
2209
2334
  page === 1
2210
2335
  );
2211
- const parsed = parseWithLog(artistPageSchema, response, "fetchArtistTracksPage");
2336
+ const parsed = parseWithLog(cataloguePageSchema, response, "fetchCatalogueTracksPage");
2212
2337
  return { tracks: parsed.results, total: parsed.overallTotal, nextPage: parsed.next ? parsed.page + 1 : null };
2213
2338
  },
2214
- [fetch2, artistPageSchema]
2339
+ [fetch2, cataloguePageSchema]
2215
2340
  );
2216
2341
  const advanceAfterTrackEnd = (0, import_react13.useCallback)(
2217
2342
  (event) => {
@@ -2283,7 +2408,7 @@ function TrackListProvider({
2283
2408
  const from = options?.startSongUuid;
2284
2409
  let page;
2285
2410
  try {
2286
- page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from);
2411
+ page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from, options?.selection, options?.artistUuid);
2287
2412
  } catch (error) {
2288
2413
  if (request !== latestPlayRequestRef.current) return;
2289
2414
  startingPlaybackRef.current = false;
@@ -2300,7 +2425,7 @@ function TrackListProvider({
2300
2425
  console.warn("No playable tracks found in genre playlist");
2301
2426
  return;
2302
2427
  }
2303
- const origin = new TrackListOriginFromCriteriaPlaylist(genrePlaylist, scope, from);
2428
+ const origin = new TrackListOriginFromCriteriaPlaylist(genrePlaylist, scope, from, options?.selection, options?.artistUuid);
2304
2429
  setAutoAdvanceScrollRequest(null);
2305
2430
  setTrackList(new TrackListFromCriteriaPlaylist(page.tracks, origin, page.total, page.nextPage));
2306
2431
  setSelectedTrack(startTrack);
@@ -2309,17 +2434,15 @@ function TrackListProvider({
2309
2434
  },
2310
2435
  [clearDelayedTrackLoad, fetchTracksPage, showTrackListSidebar, loadTrackForPlayer]
2311
2436
  );
2312
- const playNewTrackListFromArtist = (0, import_react13.useCallback)(
2313
- async (artist, scope, options) => {
2314
- if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
2437
+ const playCatalogue = (0, import_react13.useCallback)(
2438
+ async (origin) => {
2315
2439
  clearDelayedTrackLoad();
2316
2440
  const request = ++latestPlayRequestRef.current;
2317
2441
  startingPlaybackRef.current = true;
2318
- const from = options.startSongUuid;
2319
- const origin = new TrackListOriginFromArtist(artist, scope, options.ordering, from, options.genreUuid);
2442
+ const from = origin.from;
2320
2443
  let page;
2321
2444
  try {
2322
- page = await fetchArtistTracksPage(origin, 1);
2445
+ page = await fetchCatalogueTracksPage(origin, 1);
2323
2446
  } catch (error) {
2324
2447
  if (request !== latestPlayRequestRef.current) return;
2325
2448
  startingPlaybackRef.current = false;
@@ -2330,19 +2453,34 @@ function TrackListProvider({
2330
2453
  loadedContextRef.current = playback.snapshot().key;
2331
2454
  const startTrack = page.tracks[0];
2332
2455
  if (from && startTrack?.uuid !== from) {
2333
- throw new Error(`Artist ${artist.uuid} did not start at song ${from}`);
2456
+ throw new Error(`${origin instanceof TrackListOriginFromArtist ? "Artist" : "Catalogue"} ${origin.uuid} did not start at song ${from}`);
2334
2457
  }
2335
2458
  if (!startTrack) {
2336
- console.warn("No playable songs found for artist");
2459
+ console.warn("No playable songs found in catalogue");
2337
2460
  return;
2338
2461
  }
2339
- setTrackList(new TrackListFromArtist(page.tracks, origin, page.total, page.nextPage));
2462
+ setTrackList(origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(page.tracks, origin, page.total, page.nextPage) : new TrackList(page.tracks, origin, page.total, page.nextPage));
2340
2463
  setAutoAdvanceScrollRequest(null);
2341
2464
  setSelectedTrack(startTrack);
2342
2465
  showTrackListSidebar();
2343
2466
  loadTrackForPlayer(startTrack.uuid);
2344
2467
  },
2345
- [clearDelayedTrackLoad, fetchArtistTracksPage, showTrackListSidebar, loadTrackForPlayer]
2468
+ [clearDelayedTrackLoad, fetchCatalogueTracksPage, showTrackListSidebar, loadTrackForPlayer]
2469
+ );
2470
+ const playNewTrackListFromArtist = (0, import_react13.useCallback)(
2471
+ async (artist, scope, options) => {
2472
+ if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
2473
+ if (options.selection && !options.genreUuid) throw new Error("A genre selection requires a genre");
2474
+ return playCatalogue(new TrackListOriginFromArtist(artist, scope, options.ordering, options.startSongUuid, options.genreUuid, options.selection));
2475
+ },
2476
+ [playCatalogue]
2477
+ );
2478
+ const playNewTrackListFromGenreCatalogue = (0, import_react13.useCallback)(
2479
+ async (genre, scope, options) => {
2480
+ if (scope !== "reference") throw new Error("Genre catalogues only support the reference scope");
2481
+ return playCatalogue(new TrackListOriginFromGenreCatalogue(genre, scope, options?.startSongUuid, options?.selection));
2482
+ },
2483
+ [playCatalogue]
2346
2484
  );
2347
2485
  const contextKeyRef = (0, import_react13.useRef)(playback.key);
2348
2486
  (0, import_react13.useEffect)(() => {
@@ -2364,20 +2502,28 @@ function TrackListProvider({
2364
2502
  setTrackList(null);
2365
2503
  setSelectedTrack(null);
2366
2504
  if (origin instanceof TrackListOriginFromCriteriaPlaylist) {
2367
- void playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { startSongUuid: selected?.uuid }).catch((error) => {
2505
+ void playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { startSongUuid: selected?.uuid, selection: origin.selection, artistUuid: origin.artistUuid }).catch((error) => {
2368
2506
  if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
2369
- return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope).catch(() => {
2507
+ return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { selection: origin.selection, artistUuid: origin.artistUuid }).catch(() => {
2370
2508
  });
2371
2509
  }
2372
2510
  });
2373
2511
  } else if (origin instanceof TrackListOriginFromArtist) {
2374
- const options = { ordering: origin.ordering, genreUuid: origin.genreUuid };
2512
+ const options = { ordering: origin.ordering, genreUuid: origin.genreUuid, selection: origin.selection };
2375
2513
  void playNewTrackListFromArtist(origin.artist, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
2376
2514
  if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
2377
2515
  return playNewTrackListFromArtist(origin.artist, origin.scope, options).catch(() => {
2378
2516
  });
2379
2517
  }
2380
2518
  });
2519
+ } else if (origin instanceof TrackListOriginFromGenreCatalogue) {
2520
+ const options = { selection: origin.selection };
2521
+ void playNewTrackListFromGenreCatalogue(origin.genre, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
2522
+ if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
2523
+ return playNewTrackListFromGenreCatalogue(origin.genre, origin.scope, options).catch(() => {
2524
+ });
2525
+ }
2526
+ });
2381
2527
  } else if (origin instanceof TrackListOriginFromTrack && selected) {
2382
2528
  const request = latestPlayRequestRef.current;
2383
2529
  void (async () => {
@@ -2388,7 +2534,7 @@ function TrackListProvider({
2388
2534
  })().catch(() => {
2389
2535
  });
2390
2536
  }
2391
- }, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, schema, fetch2]);
2537
+ }, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, playNewTrackListFromGenreCatalogue, schema, fetch2]);
2392
2538
  const updateTrack = (0, import_react13.useCallback)((track) => {
2393
2539
  setTrackList((prev) => {
2394
2540
  if (!prev || !prev.tracks.some((listed) => listed.uuid === track.uuid)) return prev;
@@ -2400,22 +2546,22 @@ function TrackListProvider({
2400
2546
  const loadMore = (0, import_react13.useCallback)(async () => {
2401
2547
  if (!trackList || trackList.nextPage === null) return;
2402
2548
  const origin = trackList.origin;
2403
- if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist)) return;
2549
+ if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist || origin instanceof TrackListOriginFromGenreCatalogue)) return;
2404
2550
  if (loadingOriginRef.current === origin) return;
2405
2551
  const requestedPage = trackList.nextPage;
2406
2552
  loadingOriginRef.current = origin;
2407
2553
  try {
2408
- const page = origin instanceof TrackListOriginFromArtist ? await fetchArtistTracksPage(origin, requestedPage) : await fetchTracksPage(origin.criteriaPlaylist.uuid, origin.scope, requestedPage, origin.from);
2554
+ const page = origin instanceof TrackListOriginFromArtist || origin instanceof TrackListOriginFromGenreCatalogue ? await fetchCatalogueTracksPage(origin, requestedPage) : await fetchTracksPage(origin.criteriaPlaylist.uuid, origin.scope, requestedPage, origin.from, origin.selection, origin.artistUuid);
2409
2555
  setTrackList((prev) => {
2410
2556
  if (prev?.origin !== origin || prev.nextPage !== requestedPage) return prev;
2411
2557
  const loaded = new Set(prev.tracks.map((track) => track.uuid));
2412
2558
  const tracks = [...prev.tracks, ...page.tracks.filter((track) => !loaded.has(track.uuid))];
2413
- return origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(tracks, origin, page.total, page.nextPage) : new TrackListFromCriteriaPlaylist(tracks, origin, page.total, page.nextPage);
2559
+ return origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(tracks, origin, page.total, page.nextPage) : origin instanceof TrackListOriginFromGenreCatalogue ? new TrackList(tracks, origin, page.total, page.nextPage) : new TrackListFromCriteriaPlaylist(tracks, origin, page.total, page.nextPage);
2414
2560
  });
2415
2561
  } finally {
2416
2562
  if (loadingOriginRef.current === origin) loadingOriginRef.current = null;
2417
2563
  }
2418
- }, [trackList, fetchTracksPage, fetchArtistTracksPage]);
2564
+ }, [trackList, fetchTracksPage, fetchCatalogueTracksPage]);
2419
2565
  const selectedTrackIndex = trackList?.tracks.findIndex((track) => track.uuid === selectedTrack?.uuid) ?? -1;
2420
2566
  const nextTrack = trackList && selectedTrackIndex >= 0 ? trackList.tracks.slice(selectedTrackIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
2421
2567
  const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
@@ -2503,6 +2649,7 @@ function TrackListProvider({
2503
2649
  playNewTrackListFromTrackUuid,
2504
2650
  playNewTrackListFromGenrePlaylist,
2505
2651
  playNewTrackListFromArtist,
2652
+ playNewTrackListFromGenreCatalogue,
2506
2653
  fetchGenrePlaylistTracksPage: fetchTracksPage,
2507
2654
  loadMore,
2508
2655
  updateTrack
@@ -2520,6 +2667,7 @@ function TrackListProvider({
2520
2667
  playNewTrackListFromTrackUuid,
2521
2668
  playNewTrackListFromGenrePlaylist,
2522
2669
  playNewTrackListFromArtist,
2670
+ playNewTrackListFromGenreCatalogue,
2523
2671
  fetchTracksPage,
2524
2672
  loadMore,
2525
2673
  updateTrack
@@ -2550,24 +2698,24 @@ function ArtistNames({
2550
2698
  }
2551
2699
 
2552
2700
  // src/genre-tree/schemas/mb-artist.ts
2553
- var import_zod35 = require("zod");
2554
- var MbArtistDetailedSchema = import_zod35.z.object({
2555
- musicbrainzId: import_zod35.z.string().uuid(),
2556
- name: import_zod35.z.string(),
2701
+ var import_zod36 = require("zod");
2702
+ var MbArtistDetailedSchema = import_zod36.z.object({
2703
+ musicbrainzId: import_zod36.z.string().uuid(),
2704
+ name: import_zod36.z.string(),
2557
2705
  musicbrainzLink: HttpUrlSchema
2558
2706
  });
2559
2707
 
2560
2708
  // src/genre-tree/schemas/mb-recording.ts
2561
- var import_zod36 = require("zod");
2562
- var MbRecordingDetailedSchema = import_zod36.z.object({
2563
- musicbrainzId: import_zod36.z.string().uuid(),
2564
- title: import_zod36.z.string(),
2565
- score: import_zod36.z.number(),
2566
- musicbrainzArtists: import_zod36.z.array(MbArtistDetailedSchema),
2709
+ var import_zod37 = require("zod");
2710
+ var MbRecordingDetailedSchema = import_zod37.z.object({
2711
+ musicbrainzId: import_zod37.z.string().uuid(),
2712
+ title: import_zod37.z.string(),
2713
+ score: import_zod37.z.number(),
2714
+ musicbrainzArtists: import_zod37.z.array(MbArtistDetailedSchema),
2567
2715
  musicbrainzLink: HttpUrlSchema,
2568
- durationInSec: import_zod36.z.number().min(0).nullable().optional(),
2569
- durationStrInHourMinSec: import_zod36.z.string().nullable().optional(),
2570
- releaseDate: import_zod36.z.union([import_zod36.z.string().datetime(), import_zod36.z.string()]).transform((val) => {
2716
+ durationInSec: import_zod37.z.number().min(0).nullable().optional(),
2717
+ durationStrInHourMinSec: import_zod37.z.string().nullable().optional(),
2718
+ releaseDate: import_zod37.z.union([import_zod37.z.string().datetime(), import_zod37.z.string()]).transform((val) => {
2571
2719
  try {
2572
2720
  const date = new Date(val);
2573
2721
  if (isNaN(date.getTime())) {
@@ -2655,6 +2803,10 @@ function editGenreSongPages(data, edit) {
2655
2803
  CriteriaUpdateSchema,
2656
2804
  FORM_RATING_NULL_VALUE,
2657
2805
  FUZZY_MIN_SIMILARITY,
2806
+ GenreCatalogueCountsSchema,
2807
+ GenreCountsSchema,
2808
+ GenreCoverageSchema,
2809
+ GenrePlaylistSummarySchema,
2658
2810
  GenrePlaylistUuidSchema,
2659
2811
  GenreSearchResultSchema,
2660
2812
  GenreSearchResultsSchema,
@@ -2663,6 +2815,8 @@ function editGenreSongPages(data, edit) {
2663
2815
  MbArtistDetailedSchema,
2664
2816
  MbRecordingDetailedSchema,
2665
2817
  NO_VIDEO_LABEL,
2818
+ ReferenceGenreDetailedSchema,
2819
+ ReferenceGenrePlaylistSchema,
2666
2820
  RegionGenreLexiconEntrySchema,
2667
2821
  RegionGenreLexiconSchema,
2668
2822
  SEARCH_DEBOUNCE_MS,
@@ -2672,6 +2826,8 @@ function editGenreSongPages(data, edit) {
2672
2826
  SongHistorySchema,
2673
2827
  SongSearchResultSchema,
2674
2828
  SongSearchResultsSchema,
2829
+ SubgenreCountsSchema,
2830
+ SubgenreScopeSchema,
2675
2831
  TrackBaseSchema,
2676
2832
  TrackList,
2677
2833
  TrackListFromArtist,
@@ -2680,6 +2836,7 @@ function editGenreSongPages(data, edit) {
2680
2836
  TrackListOrigin,
2681
2837
  TrackListOriginFromArtist,
2682
2838
  TrackListOriginFromCriteriaPlaylist,
2839
+ TrackListOriginFromGenreCatalogue,
2683
2840
  TrackListOriginFromTrack,
2684
2841
  TrackListOriginType,
2685
2842
  TrackListProvider,
@@ -2691,12 +2848,17 @@ function editGenreSongPages(data, edit) {
2691
2848
  artistEndpoints,
2692
2849
  artistQueryKeys,
2693
2850
  capitalizeFirstLetter,
2851
+ defaultGenreMusicSelection,
2694
2852
  editGenreSongPages,
2695
2853
  foldSearchText,
2696
2854
  formatTime,
2697
2855
  genreEndpoints,
2856
+ genreMusicCount,
2857
+ genreMusicQueryParams,
2858
+ genreMusicSelectionKey,
2698
2859
  genrePlaylistEndpoints,
2699
2860
  genrePlaylistQueryKeys,
2861
+ genrePlaylistTrackCount,
2700
2862
  genreQueryKeys,
2701
2863
  genreSearchQueryKeys,
2702
2864
  genreUpdateMutationKey,