@behindthemusictree/app-kit 33.0.0 → 33.2.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.
@@ -41,11 +41,19 @@ __export(genre_tree_exports, {
41
41
  CriteriaSimpleSchema: () => CriteriaSimpleSchema,
42
42
  CriteriaUpdateSchema: () => CriteriaUpdateSchema,
43
43
  FORM_RATING_NULL_VALUE: () => FORM_RATING_NULL_VALUE,
44
+ FUZZY_MIN_SIMILARITY: () => FUZZY_MIN_SIMILARITY,
44
45
  GenrePlaylistUuidSchema: () => GenrePlaylistUuidSchema,
46
+ GenreSearchResultSchema: () => GenreSearchResultSchema,
47
+ GenreSearchResultsSchema: () => GenreSearchResultsSchema,
48
+ GenreSearchTreeNameSchema: () => GenreSearchTreeNameSchema,
45
49
  GenreUuidSchema: () => GenreUuidSchema,
46
50
  MbArtistDetailedSchema: () => MbArtistDetailedSchema,
47
51
  MbRecordingDetailedSchema: () => MbRecordingDetailedSchema,
48
52
  NO_VIDEO_LABEL: () => NO_VIDEO_LABEL,
53
+ RegionGenreLexiconEntrySchema: () => RegionGenreLexiconEntrySchema,
54
+ RegionGenreLexiconSchema: () => RegionGenreLexiconSchema,
55
+ SEARCH_DEBOUNCE_MS: () => SEARCH_DEBOUNCE_MS,
56
+ SEARCH_QUERY_MIN_LENGTH: () => SEARCH_QUERY_MIN_LENGTH,
49
57
  SongDetailedSchema: () => SongDetailedSchema,
50
58
  SongHistoryEntrySchema: () => SongHistoryEntrySchema,
51
59
  SongHistorySchema: () => SongHistorySchema,
@@ -66,15 +74,18 @@ __export(genre_tree_exports, {
66
74
  TrackMinimumSchema: () => TrackMinimumSchema,
67
75
  UuidResourceSchema: () => UuidResourceSchema,
68
76
  YOUTUBE_UNPLAYABLE_REASON_LABELS: () => YOUTUBE_UNPLAYABLE_REASON_LABELS,
77
+ YoutubeAvailabilitySchema: () => YoutubeAvailabilitySchema,
69
78
  artistEndpoints: () => artistEndpoints,
70
79
  artistQueryKeys: () => artistQueryKeys,
71
80
  capitalizeFirstLetter: () => capitalizeFirstLetter,
72
81
  editGenreSongPages: () => editGenreSongPages,
82
+ foldSearchText: () => foldSearchText,
73
83
  formatTime: () => formatTime,
74
84
  genreEndpoints: () => genreEndpoints,
75
85
  genrePlaylistEndpoints: () => genrePlaylistEndpoints,
76
86
  genrePlaylistQueryKeys: () => genrePlaylistQueryKeys,
77
87
  genreQueryKeys: () => genreQueryKeys,
88
+ genreSearchQueryKeys: () => genreSearchQueryKeys,
78
89
  genreUpdateMutationKey: () => genreUpdateMutationKey,
79
90
  getGenrePlaylistsGroupedByRoot: () => getGenrePlaylistsGroupedByRoot,
80
91
  getReparentCandidates: () => getReparentCandidates,
@@ -87,8 +98,10 @@ __export(genre_tree_exports, {
87
98
  makeTrackPlaylistRelSchema: () => makeTrackPlaylistRelSchema,
88
99
  musicBrainzRecordingUrl: () => musicBrainzRecordingUrl,
89
100
  pruneGenrePlaylistsForArtist: () => pruneGenrePlaylistsForArtist,
101
+ rankByName: () => rankByName,
90
102
  searchGenrePlaylistsByName: () => searchGenrePlaylistsByName,
91
103
  songUnplayableReason: () => songUnplayableReason,
104
+ trigramSimilarity: () => trigramSimilarity,
92
105
  useArtist: () => useArtist,
93
106
  useArtistGenreCounts: () => useArtistGenreCounts,
94
107
  useArtistSearch: () => useArtistSearch,
@@ -99,6 +112,7 @@ __export(genre_tree_exports, {
99
112
  useFetchGenreOverview: () => useFetchGenreOverview,
100
113
  useFetchGenrePlaylist: () => useFetchGenrePlaylist,
101
114
  useGenreByWikidataId: () => useGenreByWikidataId,
115
+ useGenreRemoteSearch: () => useGenreRemoteSearch,
102
116
  useGenreSearch: () => useGenreSearch,
103
117
  useGenreTreeViewState: () => useGenreTreeViewState,
104
118
  useInvalidateAllGenrePlaylistQueries: () => useInvalidateAllGenrePlaylistQueries,
@@ -107,6 +121,9 @@ __export(genre_tree_exports, {
107
121
  useListGenres: () => useListGenres,
108
122
  useListTracks: () => useListTracks,
109
123
  usePrefetchGenreOverview: () => usePrefetchGenreOverview,
124
+ useRegionGenreLexicon: () => useRegionGenreLexicon,
125
+ useRemoteSearch: () => useRemoteSearch,
126
+ useSearchQueryState: () => useSearchQueryState,
110
127
  useSong: () => useSong,
111
128
  useSongHistory: () => useSongHistory,
112
129
  useSongSearch: () => useSongSearch,
@@ -118,19 +135,36 @@ __export(genre_tree_exports, {
118
135
  module.exports = __toCommonJS(genre_tree_exports);
119
136
 
120
137
  // src/genre-tree/useGenre.ts
121
- var import_zod22 = require("zod");
138
+ var import_zod23 = require("zod");
122
139
  var import_react_query5 = require("@tanstack/react-query");
123
- var import_react5 = require("react");
140
+ var import_react6 = require("react");
141
+
142
+ // src/transport/PlaybackContext.tsx
143
+ var import_react = require("react");
144
+ var import_zod = require("zod");
145
+ 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() });
147
+ var unmanaged = {
148
+ country: null,
149
+ key: null,
150
+ ready: true,
151
+ error: null,
152
+ isCurrent: (_key) => true,
153
+ snapshot: () => ({ key: null, country: null }),
154
+ refresh: async (_force = false) => null
155
+ };
156
+ var PlaybackContext = (0, import_react.createContext)(unmanaged);
157
+ var usePlaybackContext = () => (0, import_react.useContext)(PlaybackContext);
124
158
 
125
159
  // src/transport/useFetchWrapper.ts
126
- var import_react3 = require("react");
160
+ var import_react4 = require("react");
127
161
 
128
162
  // src/transport/connectivity-error-context.tsx
129
- var import_react = require("react");
130
- var import_jsx_runtime = require("react/jsx-runtime");
131
- var ConnectivityErrorContext = (0, import_react.createContext)(void 0);
163
+ var import_react2 = require("react");
164
+ var import_jsx_runtime2 = require("react/jsx-runtime");
165
+ var ConnectivityErrorContext = (0, import_react2.createContext)(void 0);
132
166
  function useConnectivityError() {
133
- const context = (0, import_react.useContext)(ConnectivityErrorContext);
167
+ const context = (0, import_react2.useContext)(ConnectivityErrorContext);
134
168
  if (context === void 0) {
135
169
  throw new Error("useConnectivityError must be used within a ConnectivityErrorProvider");
136
170
  }
@@ -138,7 +172,7 @@ function useConnectivityError() {
138
172
  }
139
173
 
140
174
  // src/auth/SessionContext.tsx
141
- var import_react2 = require("react");
175
+ var import_react3 = require("react");
142
176
 
143
177
  // src/transport/query-client.ts
144
178
  var import_react_query = require("@tanstack/react-query");
@@ -153,10 +187,10 @@ var queryClient = new import_react_query.QueryClient({
153
187
  });
154
188
 
155
189
  // src/auth/SessionContext.tsx
156
- var import_jsx_runtime2 = require("react/jsx-runtime");
157
- var SessionContext = (0, import_react2.createContext)(void 0);
190
+ var import_jsx_runtime3 = require("react/jsx-runtime");
191
+ var SessionContext = (0, import_react3.createContext)(void 0);
158
192
  function useSession() {
159
- const context = (0, import_react2.useContext)(SessionContext);
193
+ const context = (0, import_react3.useContext)(SessionContext);
160
194
  if (context === void 0) {
161
195
  throw new Error("useSession must be used within a SessionProvider");
162
196
  }
@@ -480,7 +514,7 @@ var assertWellFormedRequest = (url, options) => {
480
514
  }
481
515
  };
482
516
  var isCallerAbort = (error, signal) => !!signal?.aborted && error?.name !== "TimeoutError";
483
- var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryParams, handleMissingRequiredSession, handleError, expectBinary = false, backendBaseUrl) => {
517
+ var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryParams, handleMissingRequiredSession, handleError, expectBinary = false, backendBaseUrl, onResponse) => {
484
518
  const urlWithParams = queryParams ? `${url}${url.includes("?") ? "&" : "?"}${new URLSearchParams(
485
519
  Object.entries(queryParams).map(([key, value]) => [key, String(value)])
486
520
  ).toString()}` : url;
@@ -498,9 +532,16 @@ var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryPar
498
532
  handleMissingRequiredSession?.();
499
533
  return null;
500
534
  }
535
+ let responseHookFailed = false;
501
536
  try {
502
537
  assertWellFormedRequest(finalUrl, finalOptions);
503
538
  const result = await fetchWithNetworkRetry(finalUrl, finalOptions);
539
+ try {
540
+ await onResponse?.(result);
541
+ } catch (error) {
542
+ responseHookFailed = true;
543
+ throw error;
544
+ }
504
545
  if (!result.ok) {
505
546
  const appError = await createAppErrorFromResult(result, backendBaseUrl);
506
547
  throw appError;
@@ -514,7 +555,7 @@ var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryPar
514
555
  return result.json();
515
556
  }
516
557
  } catch (caughtError) {
517
- if (isCallerAbort(caughtError, finalOptions.signal)) throw caughtError;
558
+ if (responseHookFailed || isCallerAbort(caughtError, finalOptions.signal)) throw caughtError;
518
559
  let appError = null;
519
560
  if (caughtError instanceof AppError) {
520
561
  appError = caughtError;
@@ -531,9 +572,10 @@ var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryPar
531
572
 
532
573
  // src/transport/useFetchWrapper.ts
533
574
  var useFetchWrapper = (getBackendBaseUrl) => {
575
+ const playback = usePlaybackContext();
534
576
  const { setConnectivityError } = useConnectivityError();
535
577
  const { clearSession, session, sessionRestored } = useSession();
536
- const handleError = (0, import_react3.useCallback)((error) => {
578
+ const handleError = (0, import_react4.useCallback)((error) => {
537
579
  if (error instanceof ConnectivityError) {
538
580
  const authDetailErrors = [
539
581
  "BAC4011" /* BACKEND_GOOGLE_OAUTH_CODE_INVALID_OR_EXPIRED */,
@@ -560,37 +602,64 @@ var useFetchWrapper = (getBackendBaseUrl) => {
560
602
  if (!sessionRestored) return;
561
603
  setConnectivityError(createAppErrorFromErrorCode("SES4012" /* SESSION_REQUIRED */));
562
604
  };
563
- const fetch2 = (0, import_react3.useCallback)((backendEndpointOrUrl, fromBackend = true, requiresAuth = true, options = {}, queryParams, expectBinary = false, skipGlobalError = false) => {
605
+ const fetch2 = (0, import_react4.useCallback)((backendEndpointOrUrl, fromBackend = true, requiresAuth = true, options = {}, queryParams, expectBinary = false, skipGlobalError = false, acceptRefreshedContext = false) => {
564
606
  const baseUrl = getBackendBaseUrl().replace(/\/+$/, "");
565
607
  const endpointPath = String(backendEndpointOrUrl);
566
608
  if (fromBackend && endpointPath.startsWith("/")) {
567
609
  throw new Error(`Endpoint path must be relative (no leading slash). Got: "${endpointPath}".`);
568
610
  }
569
611
  const url = fromBackend ? endpointPath ? `${baseUrl}/${endpointPath}` : baseUrl : backendEndpointOrUrl;
570
- return fetchWrapper(
571
- url,
572
- requiresAuth,
573
- options,
574
- session?.accessToken || void 0,
575
- queryParams,
576
- handleMissingRequiredSession,
577
- skipGlobalError ? void 0 : handleError,
578
- expectBinary,
579
- baseUrl
580
- );
581
- }, [session?.accessToken, handleError, getBackendBaseUrl, sessionRestored, setConnectivityError]);
612
+ const perform = async (retryContextChange) => {
613
+ const contextual = playback.key !== null && fromBackend && /^(?:me\/)?(library\/songs|genre-playlists|playlists|manual-playlists)\//.test(endpointPath);
614
+ let requestContext = { key: playback.key, country: playback.country };
615
+ if (contextual) {
616
+ await playback.refresh();
617
+ if (acceptRefreshedContext) requestContext = playback.snapshot();
618
+ if (!playback.isCurrent(requestContext.key)) throw new DOMException("Playback context changed", "AbortError");
619
+ }
620
+ try {
621
+ const result = await fetchWrapper(
622
+ url,
623
+ requiresAuth,
624
+ options,
625
+ session?.accessToken || void 0,
626
+ queryParams,
627
+ handleMissingRequiredSession,
628
+ skipGlobalError ? void 0 : handleError,
629
+ expectBinary,
630
+ baseUrl,
631
+ contextual ? async (response) => {
632
+ const responseCountry = response.headers.get("x-playback-country");
633
+ if (responseCountry !== null && responseCountry !== (requestContext.country ?? "unknown")) {
634
+ await playback.refresh(true);
635
+ throw new DOMException("Playback context changed", "AbortError");
636
+ }
637
+ if (!playback.isCurrent(requestContext.key)) throw new DOMException("Playback context changed", "AbortError");
638
+ } : void 0
639
+ );
640
+ if (contextual && !playback.isCurrent(requestContext.key)) throw new DOMException("Playback context changed", "AbortError");
641
+ return result;
642
+ } catch (error) {
643
+ if (retryContextChange && contextual && error instanceof DOMException && error.name === "AbortError" && !playback.isCurrent(requestContext.key)) {
644
+ return perform(false);
645
+ }
646
+ throw error;
647
+ }
648
+ };
649
+ return perform(acceptRefreshedContext);
650
+ }, [session?.accessToken, handleError, getBackendBaseUrl, sessionRestored, setConnectivityError, playback]);
582
651
  return { fetch: fetch2 };
583
652
  };
584
653
 
585
654
  // src/genre-tree/useGenrePlaylist.ts
586
- var import_zod8 = require("zod");
655
+ var import_zod9 = require("zod");
587
656
  var import_react_query3 = require("@tanstack/react-query");
588
657
 
589
658
  // src/transport/lib/use-query-with-parse.ts
590
659
  var import_react_query2 = require("@tanstack/react-query");
591
660
 
592
661
  // src/transport/lib/parse-with-log.ts
593
- var import_zod = require("zod");
662
+ var import_zod2 = require("zod");
594
663
  function parseWithLog(schema, data, context) {
595
664
  const result = schema.safeParse(data);
596
665
  if (!result.success) {
@@ -598,7 +667,7 @@ function parseWithLog(schema, data, context) {
598
667
  if (data == null) {
599
668
  throw new Error(`${prefix} received null response before schema validation`);
600
669
  }
601
- console.error(`${prefix} schema validation failed`, import_zod.z.flattenError(result.error));
670
+ console.error(`${prefix} schema validation failed`, import_zod2.z.flattenError(result.error));
602
671
  throw result.error;
603
672
  }
604
673
  return result.data;
@@ -621,47 +690,47 @@ function useQueryWithParse({
621
690
  }
622
691
 
623
692
  // src/genre-tree/schemas/criteria-playlist/simple.ts
624
- var import_zod6 = require("zod");
693
+ var import_zod7 = require("zod");
625
694
 
626
695
  // src/genre-tree/schemas/criteria-playlist/detailed.ts
627
- var import_zod5 = require("zod");
696
+ var import_zod6 = require("zod");
628
697
 
629
698
  // src/genre-tree/schemas/ids.ts
630
- var import_zod2 = require("zod");
631
- var GenreUuidSchema = import_zod2.z.string().uuid().brand();
632
- var GenrePlaylistUuidSchema = import_zod2.z.string().uuid().brand();
699
+ var import_zod3 = require("zod");
700
+ var GenreUuidSchema = import_zod3.z.string().uuid().brand();
701
+ var GenrePlaylistUuidSchema = import_zod3.z.string().uuid().brand();
633
702
 
634
703
  // src/genre-tree/schemas/criteria/minimum.ts
635
- var import_zod3 = require("zod");
636
- var CriteriaMinimumSchema = import_zod3.z.object({
704
+ var import_zod4 = require("zod");
705
+ var CriteriaMinimumSchema = import_zod4.z.object({
637
706
  uuid: GenreUuidSchema,
638
- name: import_zod3.z.string(),
639
- side: import_zod3.z.enum(["core", "pop"]).nullable().optional(),
640
- wikidataId: import_zod3.z.string().nullable().optional()
707
+ name: import_zod4.z.string(),
708
+ side: import_zod4.z.enum(["core", "pop"]).nullable().optional(),
709
+ wikidataId: import_zod4.z.string().nullable().optional()
641
710
  });
642
711
 
643
712
  // src/genre-tree/schemas/criteria-playlist/minimum.ts
644
- var import_zod4 = require("zod");
645
- var CriteriaPlaylistMinimumSchema = import_zod4.z.object({
713
+ var import_zod5 = require("zod");
714
+ var CriteriaPlaylistMinimumSchema = import_zod5.z.object({
646
715
  uuid: GenrePlaylistUuidSchema,
647
- name: import_zod4.z.string()
716
+ name: import_zod5.z.string()
648
717
  });
649
718
 
650
719
  // src/genre-tree/schemas/criteria-playlist/detailed.ts
651
- var CriteriaPlaylistDetailedSchema = import_zod5.z.object({
720
+ var CriteriaPlaylistDetailedSchema = import_zod6.z.object({
652
721
  uuid: GenrePlaylistUuidSchema,
653
- name: import_zod5.z.string(),
654
- tracksCount: import_zod5.z.number(),
722
+ name: import_zod6.z.string(),
723
+ tracksCount: import_zod6.z.number(),
655
724
  // Summed YouTube views of the same songs as `tracksCount`. Optional: hear-api has no view counts.
656
- viewsCount: import_zod5.z.number().optional(),
657
- durationInSec: import_zod5.z.number().min(0).nullable().optional(),
658
- durationStrInHourMinSec: import_zod5.z.string().nullable().optional(),
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(),
659
728
  // Nullable: the "Genreless" root playlist has no criteria attached and is never updated.
660
729
  criteria: CriteriaMinimumSchema.nullable(),
661
730
  parent: CriteriaPlaylistMinimumSchema.nullable(),
662
731
  root: CriteriaPlaylistMinimumSchema,
663
- createdOn: import_zod5.z.string(),
664
- updatedOn: import_zod5.z.string().nullable()
732
+ createdOn: import_zod6.z.string(),
733
+ updatedOn: import_zod6.z.string().nullable()
665
734
  });
666
735
 
667
736
  // src/genre-tree/schemas/criteria-playlist/simple.ts
@@ -677,23 +746,23 @@ var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
677
746
  updatedOn: true
678
747
  }).extend({
679
748
  // Only on the tree/list payloads, not the detail endpoint — hence not on the detailed schema.
680
- isUnacceptedRoot: import_zod6.z.boolean(),
749
+ isUnacceptedRoot: import_zod7.z.boolean(),
681
750
  // Optional: a backend that does not curate umbrella genres omits it.
682
- isUmbrella: import_zod6.z.boolean().optional(),
751
+ isUmbrella: import_zod7.z.boolean().optional(),
683
752
  // Optional: only the grow tree payload carries it; null when the genre has no scene.
684
- scene: import_zod6.z.enum(["commercial", "underground"]).nullable().optional()
753
+ scene: import_zod7.z.enum(["commercial", "underground"]).nullable().optional()
685
754
  });
686
755
 
687
756
  // src/transport/lib/paginated-response.ts
688
- var import_zod7 = require("zod");
689
- var PaginatedResponseSchema = (itemSchema) => import_zod7.z.object({
690
- overallTotal: import_zod7.z.number(),
691
- next: import_zod7.z.string().url().nullable(),
692
- previous: import_zod7.z.string().url().nullable(),
693
- results: import_zod7.z.array(itemSchema),
694
- page: import_zod7.z.number(),
695
- pageSize: import_zod7.z.number(),
696
- totalPages: import_zod7.z.number()
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()
697
766
  });
698
767
 
699
768
  // src/genre-tree/api/genre-playlists/queryKeys.ts
@@ -821,7 +890,7 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
821
890
  { page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "canonical" }
822
891
  )
823
892
  ),
824
- schema: import_zod8.z.array(CriteriaPlaylistSimpleSchema),
893
+ schema: import_zod9.z.array(CriteriaPlaylistSimpleSchema),
825
894
  context: "useListFullGenrePlaylists",
826
895
  enabled: scope === "reference" || sessionRestored && !!session?.accessToken
827
896
  });
@@ -856,15 +925,15 @@ var useInvalidateAllGenrePlaylistQueries = () => {
856
925
 
857
926
  // src/transport/lib/use-validated-mutation.ts
858
927
  var import_react_query4 = require("@tanstack/react-query");
859
- var import_react4 = require("react");
860
- var import_zod9 = require("zod");
928
+ var import_react5 = require("react");
929
+ var import_zod10 = require("zod");
861
930
  function useValidatedMutation({
862
931
  inputSchema,
863
932
  outputSchema,
864
933
  mutationFn,
865
934
  ...options
866
935
  }) {
867
- const [formErrors, setFormErrors] = (0, import_react4.useState)([]);
936
+ const [formErrors, setFormErrors] = (0, import_react5.useState)([]);
868
937
  const validatedMutation = (0, import_react_query4.useMutation)({
869
938
  ...options,
870
939
  mutationFn: async (data) => {
@@ -890,9 +959,9 @@ function useValidatedMutation({
890
959
  } catch (error) {
891
960
  if (error instanceof Error && "json" in error) {
892
961
  try {
893
- const errorResponse = import_zod9.z.object({
894
- details: import_zod9.z.object({
895
- fieldErrors: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.array(import_zod9.z.object({ message: import_zod9.z.string() })))
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() })))
896
965
  })
897
966
  }).parse(error.json);
898
967
  setFormErrors(
@@ -916,46 +985,46 @@ function useValidatedMutation({
916
985
  }
917
986
 
918
987
  // src/genre-tree/schemas/criteria/detailed.ts
919
- var import_zod16 = require("zod");
988
+ var import_zod17 = require("zod");
920
989
 
921
990
  // src/genre-tree/schemas/track/base.ts
922
- var import_zod13 = require("zod");
991
+ var import_zod14 = require("zod");
923
992
 
924
993
  // src/genre-tree/schemas/artist-minimum.ts
925
- var import_zod10 = require("zod");
926
- var ArtistMinimumSchema = import_zod10.z.object({
927
- uuid: import_zod10.z.string().uuid(),
928
- name: import_zod10.z.string(),
929
- isSpecialPurpose: import_zod10.z.boolean().optional()
930
- });
931
-
932
- // src/genre-tree/schemas/album-minimum.ts
933
994
  var import_zod11 = require("zod");
934
- var AlbumMinimumSchema = import_zod11.z.object({
995
+ var ArtistMinimumSchema = import_zod11.z.object({
935
996
  uuid: import_zod11.z.string().uuid(),
936
997
  name: import_zod11.z.string(),
937
- albumArtists: import_zod11.z.array(ArtistMinimumSchema).nullable().optional()
998
+ isSpecialPurpose: import_zod11.z.boolean().optional()
938
999
  });
939
1000
 
940
- // src/genre-tree/schemas/uuid-resource.ts
1001
+ // src/genre-tree/schemas/album-minimum.ts
941
1002
  var import_zod12 = require("zod");
942
- var UuidResourceSchema = import_zod12.z.object({
943
- uuid: import_zod12.z.string().uuid()
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()
944
1013
  });
945
1014
 
946
1015
  // src/genre-tree/schemas/track/base.ts
947
1016
  var TrackBaseSchema = UuidResourceSchema.extend({
948
- title: import_zod13.z.string(),
949
- artists: import_zod13.z.array(ArtistMinimumSchema).nullable().optional(),
1017
+ title: import_zod14.z.string(),
1018
+ artists: import_zod14.z.array(ArtistMinimumSchema).nullable().optional(),
950
1019
  album: AlbumMinimumSchema.nullable().optional(),
951
- trackNumber: import_zod13.z.number().nullable().optional(),
1020
+ trackNumber: import_zod14.z.number().nullable().optional(),
952
1021
  // null for a song not yet linked to a genre.
953
1022
  genre: CriteriaMinimumSchema.nullable(),
954
- rating: import_zod13.z.number().min(0).max(10).nullable().optional(),
955
- language: import_zod13.z.string().nullable().optional(),
956
- playCount: import_zod13.z.number().min(0),
957
- createdOn: import_zod13.z.string().datetime(),
958
- updatedOn: import_zod13.z.string().datetime().nullable().optional()
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()
959
1028
  });
960
1029
 
961
1030
  // src/genre-tree/schemas/track/minimum.ts
@@ -966,80 +1035,80 @@ var TrackMinimumSchema = TrackBaseSchema.pick({
966
1035
  });
967
1036
 
968
1037
  // src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
969
- var import_zod14 = require("zod");
970
- var CriteriaLineageRelWithoutAscendantSchema = import_zod14.z.object({
1038
+ var import_zod15 = require("zod");
1039
+ var CriteriaLineageRelWithoutAscendantSchema = import_zod15.z.object({
971
1040
  descendant: CriteriaMinimumSchema,
972
- degree: import_zod14.z.number()
1041
+ degree: import_zod15.z.number()
973
1042
  });
974
1043
 
975
1044
  // src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
976
- var import_zod15 = require("zod");
977
- var CriteriaLineageRelWithoutDescendantSchema = import_zod15.z.object({
1045
+ var import_zod16 = require("zod");
1046
+ var CriteriaLineageRelWithoutDescendantSchema = import_zod16.z.object({
978
1047
  ascendant: CriteriaMinimumSchema,
979
- degree: import_zod15.z.number()
1048
+ degree: import_zod16.z.number()
980
1049
  });
981
1050
 
982
1051
  // src/genre-tree/schemas/criteria/detailed.ts
983
- var CriteriaDetailedSchema = import_zod16.z.object({
1052
+ var CriteriaDetailedSchema = import_zod17.z.object({
984
1053
  uuid: GenreUuidSchema,
985
- name: import_zod16.z.string(),
986
- summary: import_zod16.z.string().nullable(),
1054
+ name: import_zod17.z.string(),
1055
+ summary: import_zod17.z.string().nullable(),
987
1056
  // Optional until every deployed API serves it.
988
- wikidataId: import_zod16.z.string().nullable().optional(),
1057
+ wikidataId: import_zod17.z.string().nullable().optional(),
989
1058
  parent: CriteriaMinimumSchema.nullable(),
990
- ascendants: import_zod16.z.array(CriteriaLineageRelWithoutDescendantSchema),
991
- descendants: import_zod16.z.array(CriteriaLineageRelWithoutAscendantSchema),
1059
+ ascendants: import_zod17.z.array(CriteriaLineageRelWithoutDescendantSchema),
1060
+ descendants: import_zod17.z.array(CriteriaLineageRelWithoutAscendantSchema),
992
1061
  root: CriteriaMinimumSchema,
993
- children: import_zod16.z.array(CriteriaMinimumSchema),
1062
+ children: import_zod17.z.array(CriteriaMinimumSchema),
994
1063
  criteriaPlaylist: CriteriaPlaylistMinimumSchema,
995
- tracks: import_zod16.z.array(TrackMinimumSchema),
996
- essentialSongs: import_zod16.z.array(TrackMinimumSchema),
997
- tracksCount: import_zod16.z.number(),
998
- updatedOn: import_zod16.z.string().datetime().nullable()
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()
999
1068
  });
1000
1069
 
1001
1070
  // src/genre-tree/schemas/criteria/overview.ts
1002
- var import_zod18 = require("zod");
1071
+ var import_zod19 = require("zod");
1003
1072
 
1004
1073
  // src/genre-tree/schemas/http-url.ts
1005
- var import_zod17 = require("zod");
1006
- var HttpUrlSchema = import_zod17.z.url({ protocol: /^https?$/ });
1074
+ var import_zod18 = require("zod");
1075
+ var HttpUrlSchema = import_zod18.z.url({ protocol: /^https?$/ });
1007
1076
 
1008
1077
  // src/genre-tree/schemas/criteria/overview.ts
1009
- var CriteriaOverviewSchema = import_zod18.z.object({
1078
+ var CriteriaOverviewSchema = import_zod19.z.object({
1010
1079
  uuid: GenreUuidSchema,
1011
- name: import_zod18.z.string(),
1012
- summary: import_zod18.z.string().nullable(),
1013
- description: import_zod18.z.string().nullable(),
1080
+ name: import_zod19.z.string(),
1081
+ summary: import_zod19.z.string().nullable(),
1082
+ description: import_zod19.z.string().nullable(),
1014
1083
  summarySourceUrl: HttpUrlSchema.nullable(),
1015
- essentialSongs: import_zod18.z.array(TrackMinimumSchema).optional()
1084
+ essentialSongs: import_zod19.z.array(TrackMinimumSchema).optional()
1016
1085
  });
1017
1086
 
1018
1087
  // src/genre-tree/schemas/criteria/simple.ts
1019
- var import_zod19 = require("zod");
1020
- var CriteriaSimpleSchema = import_zod19.z.object({
1088
+ var import_zod20 = require("zod");
1089
+ var CriteriaSimpleSchema = import_zod20.z.object({
1021
1090
  uuid: GenreUuidSchema,
1022
- name: import_zod19.z.string(),
1091
+ name: import_zod20.z.string(),
1023
1092
  parent: CriteriaMinimumSchema.nullable(),
1024
- createdOn: import_zod19.z.string().datetime(),
1025
- summary: import_zod19.z.string().nullable()
1093
+ createdOn: import_zod20.z.string().datetime(),
1094
+ summary: import_zod20.z.string().nullable()
1026
1095
  });
1027
1096
 
1028
1097
  // src/genre-tree/schemas/criteria/creation.ts
1029
- var import_zod20 = require("zod");
1030
- var CriteriaCreationSchema = import_zod20.z.object({
1031
- name: import_zod20.z.string().min(1, "Name is required"),
1098
+ var import_zod21 = require("zod");
1099
+ var CriteriaCreationSchema = import_zod21.z.object({
1100
+ name: import_zod21.z.string().min(1, "Name is required"),
1032
1101
  parent: GenreUuidSchema.optional(),
1033
- essentialSongs: import_zod20.z.array(import_zod20.z.string().uuid()).optional()
1102
+ essentialSongs: import_zod21.z.array(import_zod21.z.string().uuid()).optional()
1034
1103
  });
1035
1104
 
1036
1105
  // src/genre-tree/schemas/criteria/update.ts
1037
- var import_zod21 = require("zod");
1038
- var CriteriaUpdateSchema = import_zod21.z.object({
1039
- name: import_zod21.z.string().optional(),
1106
+ var import_zod22 = require("zod");
1107
+ var CriteriaUpdateSchema = import_zod22.z.object({
1108
+ name: import_zod22.z.string().optional(),
1040
1109
  parent: GenreUuidSchema.nullable().optional(),
1041
- essentialSongs: import_zod21.z.array(import_zod21.z.string().uuid()).optional(),
1042
- side: import_zod21.z.enum(["core", "pop"]).optional()
1110
+ essentialSongs: import_zod22.z.array(import_zod22.z.string().uuid()).optional(),
1111
+ side: import_zod22.z.enum(["core", "pop"]).optional()
1043
1112
  });
1044
1113
 
1045
1114
  // src/genre-tree/api/genres/queryKeys.ts
@@ -1059,6 +1128,10 @@ var genreQueryKeys = {
1059
1128
  overview: (id) => ["referenceGenres", "overview", id]
1060
1129
  }
1061
1130
  };
1131
+ var genreSearchQueryKeys = {
1132
+ search: (params) => ["genreSearch", params],
1133
+ regionLexicon: () => ["regionGenreLexicon"]
1134
+ };
1062
1135
  var genreUpdateMutationKey = ["genres", "update"];
1063
1136
 
1064
1137
  // src/genre-tree/api/genres/endpoints.ts
@@ -1072,7 +1145,9 @@ var makeGenreEndpoints = (prefix) => ({
1072
1145
  });
1073
1146
  var genreEndpoints = {
1074
1147
  me: makeGenreEndpoints("me/"),
1075
- reference: makeGenreEndpoints("")
1148
+ reference: makeGenreEndpoints(""),
1149
+ search: () => "genres/search/",
1150
+ regionLexicon: () => "regions/map/genres/"
1076
1151
  };
1077
1152
 
1078
1153
  // src/genre-tree/useGenre.ts
@@ -1090,7 +1165,7 @@ function useListGenres(page = 1, pageSize = 50, scope, getBackendBaseUrl) {
1090
1165
  }
1091
1166
  function useFetchGenre(scope, getBackendBaseUrl) {
1092
1167
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1093
- return (0, import_react5.useCallback)(
1168
+ return (0, import_react6.useCallback)(
1094
1169
  async (id) => {
1095
1170
  const endpoint = scope === "reference" ? genreEndpoints.reference.detail(id) : genreEndpoints.me.detail(id);
1096
1171
  const response = await fetch2(endpoint, true, scope === "me");
@@ -1129,7 +1204,7 @@ function useGenreByWikidataId(qid, scope, getBackendBaseUrl) {
1129
1204
  var GENRE_OVERVIEW_STALE_TIME_MS = 6e4;
1130
1205
  function useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema) {
1131
1206
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1132
- return (0, import_react5.useCallback)(
1207
+ return (0, import_react6.useCallback)(
1133
1208
  (id) => {
1134
1209
  const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
1135
1210
  const endpoints = scope === "reference" ? genreEndpoints.reference : genreEndpoints.me;
@@ -1149,7 +1224,7 @@ function useFetchGenreOverview(id, scope, getBackendBaseUrl, schema = CriteriaOv
1149
1224
  function usePrefetchGenreOverview(scope, getBackendBaseUrl, schema = CriteriaOverviewSchema) {
1150
1225
  const queryClient2 = (0, import_react_query5.useQueryClient)();
1151
1226
  const queryOptions = useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema);
1152
- return (0, import_react5.useCallback)((id) => queryClient2.prefetchQuery(queryOptions(id)), [queryClient2, queryOptions]);
1227
+ return (0, import_react6.useCallback)((id) => queryClient2.prefetchQuery(queryOptions(id)), [queryClient2, queryOptions]);
1153
1228
  }
1154
1229
  function useRefreshGenreTree(scope) {
1155
1230
  const queryClient2 = (0, import_react_query5.useQueryClient)();
@@ -1188,7 +1263,7 @@ function useUpdateGenre(scope, getBackendBaseUrl) {
1188
1263
  const refreshGenreTree = useRefreshGenreTree(scope);
1189
1264
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1190
1265
  const { mutate, mutateAsync, isPending, formErrors } = useValidatedMutation({
1191
- inputSchema: import_zod22.z.object({
1266
+ inputSchema: import_zod23.z.object({
1192
1267
  uuid: GenreUuidSchema,
1193
1268
  data: CriteriaUpdateSchema
1194
1269
  }),
@@ -1218,8 +1293,8 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
1218
1293
  const refreshGenreTree = useRefreshGenreTree(scope);
1219
1294
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1220
1295
  return useValidatedMutation({
1221
- inputSchema: import_zod22.z.object({ uuid: GenreUuidSchema }),
1222
- outputSchema: import_zod22.z.null(),
1296
+ inputSchema: import_zod23.z.object({ uuid: GenreUuidSchema }),
1297
+ outputSchema: import_zod23.z.null(),
1223
1298
  mutationFn: async ({ uuid }) => {
1224
1299
  const endpoint = scope === "reference" ? genreEndpoints.reference.delete(uuid) : genreEndpoints.me.delete(uuid);
1225
1300
  return fetch2(endpoint, true, scope === "me", { method: "DELETE" }, void 0, false, true);
@@ -1229,16 +1304,16 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
1229
1304
  }
1230
1305
 
1231
1306
  // src/genre-tree/useArtist.ts
1232
- var import_zod24 = require("zod");
1307
+ var import_zod25 = require("zod");
1233
1308
 
1234
1309
  // src/genre-tree/schemas/artist-detailed.ts
1235
- var import_zod23 = require("zod");
1236
- var ArtistMembershipSchema = import_zod23.z.object({
1310
+ var import_zod24 = require("zod");
1311
+ var ArtistMembershipSchema = import_zod24.z.object({
1237
1312
  artist: ArtistMinimumSchema,
1238
- beginYear: import_zod23.z.number().int().nullable(),
1239
- endYear: import_zod23.z.number().int().nullable(),
1240
- ended: import_zod23.z.boolean(),
1241
- roles: import_zod23.z.array(import_zod23.z.string())
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())
1242
1317
  });
1243
1318
  var ARTIST_LINK_KINDS = [
1244
1319
  "official",
@@ -1251,35 +1326,35 @@ var ARTIST_LINK_KINDS = [
1251
1326
  "discogs",
1252
1327
  "social"
1253
1328
  ];
1254
- var ArtistImageSchema = import_zod23.z.object({
1329
+ var ArtistImageSchema = import_zod24.z.object({
1255
1330
  url: HttpUrlSchema,
1256
1331
  pageUrl: HttpUrlSchema,
1257
- author: import_zod23.z.string().nullable(),
1258
- license: import_zod23.z.string(),
1332
+ author: import_zod24.z.string().nullable(),
1333
+ license: import_zod24.z.string(),
1259
1334
  licenseUrl: HttpUrlSchema.nullable()
1260
1335
  });
1261
- var ArtistDetailedSchema = import_zod23.z.object({
1262
- uuid: import_zod23.z.string().uuid(),
1263
- name: import_zod23.z.string(),
1264
- musicbrainzArtistId: import_zod23.z.string().uuid().nullable(),
1265
- type: import_zod23.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
1266
- country: import_zod23.z.string().nullable(),
1267
- beginYear: import_zod23.z.number().int().nullable(),
1268
- endYear: import_zod23.z.number().int().nullable(),
1269
- ended: import_zod23.z.boolean(),
1270
- links: import_zod23.z.array(import_zod23.z.object({ kind: import_zod23.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
1271
- members: import_zod23.z.array(ArtistMembershipSchema),
1272
- memberOf: import_zod23.z.array(ArtistMembershipSchema),
1273
- albums: import_zod23.z.array(
1274
- import_zod23.z.object({
1275
- uuid: import_zod23.z.string().uuid(),
1276
- name: import_zod23.z.string(),
1277
- year: import_zod23.z.string().nullable(),
1278
- primaryType: import_zod23.z.string().nullable(),
1279
- secondaryTypes: import_zod23.z.array(import_zod23.z.string())
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())
1280
1355
  })
1281
1356
  ),
1282
- tracksCount: import_zod23.z.number().int(),
1357
+ tracksCount: import_zod24.z.number().int(),
1283
1358
  image: ArtistImageSchema.nullable()
1284
1359
  });
1285
1360
 
@@ -1302,7 +1377,7 @@ var artistEndpoints = {
1302
1377
  var isNotFound = (error) => error instanceof AppError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */;
1303
1378
  function useArtist(uuid, getBackendBaseUrl) {
1304
1379
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1305
- const isUuid = uuid !== null && import_zod24.z.string().uuid().safeParse(uuid).success;
1380
+ const isUuid = uuid !== null && import_zod25.z.string().uuid().safeParse(uuid).success;
1306
1381
  const { data, isPending, error } = useQueryWithParse({
1307
1382
  queryKey: artistQueryKeys.detail(uuid),
1308
1383
  // A missing artist is shown in the panel, not raised as an app-wide connectivity error.
@@ -1319,61 +1394,73 @@ function useArtist(uuid, getBackendBaseUrl) {
1319
1394
  return { status: "success", artist: data };
1320
1395
  }
1321
1396
 
1322
- // src/genre-tree/useArtistSearch.ts
1323
- var import_react_query6 = require("@tanstack/react-query");
1324
- var import_react6 = require("react");
1325
-
1326
1397
  // src/genre-tree/schemas/artist-search.ts
1327
- var import_zod25 = require("zod");
1328
- var ArtistSearchResultSchema = import_zod25.z.object({
1329
- uuid: import_zod25.z.string().uuid(),
1330
- name: import_zod25.z.string(),
1331
- disambiguation: import_zod25.z.string().nullable(),
1332
- type: import_zod25.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
1333
- country: import_zod25.z.string().nullable(),
1334
- beginYear: import_zod25.z.number().int().nullable(),
1335
- endYear: import_zod25.z.number().int().nullable(),
1336
- matchedAlias: import_zod25.z.string().nullable(),
1337
- recordingCount: import_zod25.z.number().int()
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()
1338
1409
  });
1339
- var ArtistSearchResultsSchema = import_zod25.z.array(ArtistSearchResultSchema);
1410
+ var ArtistSearchResultsSchema = import_zod26.z.array(ArtistSearchResultSchema);
1340
1411
 
1341
- // src/genre-tree/useArtistSearch.ts
1342
- var DEBOUNCE_MS = 250;
1343
- var MIN_QUERY_LENGTH = 2;
1344
- var RESULT_LIMIT = 8;
1345
- function useArtistSearch(getBackendBaseUrl, text) {
1412
+ // src/genre-tree/useRemoteSearch.ts
1413
+ var import_react_query6 = require("@tanstack/react-query");
1414
+ var import_react7 = require("react");
1415
+ var SEARCH_DEBOUNCE_MS = 250;
1416
+ var SEARCH_QUERY_MIN_LENGTH = 2;
1417
+ function useRemoteSearch(getBackendBaseUrl, { queryKey, endpoint, params, schema, context, text, enabled: extraEnabled = true, keepPrevious = true }) {
1346
1418
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1347
1419
  const trimmed = text.trim();
1348
- const [query, setQuery] = (0, import_react6.useState)("");
1349
- (0, import_react6.useEffect)(() => {
1350
- const timer = setTimeout(() => setQuery(trimmed), DEBOUNCE_MS);
1420
+ const [query, setQuery] = (0, import_react7.useState)("");
1421
+ (0, import_react7.useEffect)(() => {
1422
+ const timer = setTimeout(() => setQuery(trimmed), SEARCH_DEBOUNCE_MS);
1351
1423
  return () => clearTimeout(timer);
1352
1424
  }, [trimmed]);
1353
- const enabled = query.length >= MIN_QUERY_LENGTH;
1425
+ const enabled = query.length >= SEARCH_QUERY_MIN_LENGTH && extraEnabled;
1354
1426
  const { data, isFetching, isError } = useQueryWithParse({
1355
- queryKey: artistQueryKeys.search(query),
1356
- queryFn: ({ signal }) => fetch2(artistEndpoints.search(), true, false, { signal }, { q: query, limit: RESULT_LIMIT }),
1357
- schema: ArtistSearchResultsSchema,
1358
- context: "useArtistSearch",
1427
+ queryKey: queryKey(query),
1428
+ queryFn: ({ signal }) => fetch2(endpoint, true, false, { signal }, params(query)),
1429
+ schema,
1430
+ context,
1359
1431
  enabled,
1360
- placeholderData: import_react_query6.keepPreviousData
1432
+ placeholderData: keepPrevious ? import_react_query6.keepPreviousData : void 0
1361
1433
  });
1362
1434
  const settled = enabled && !isFetching && query === trimmed;
1363
1435
  const failed = enabled && isError;
1436
+ const long = trimmed.length >= SEARCH_QUERY_MIN_LENGTH;
1364
1437
  return {
1365
- artists: trimmed.length >= MIN_QUERY_LENGTH ? data ?? [] : [],
1438
+ results: long ? data ?? [] : [],
1366
1439
  isError: failed,
1367
1440
  settled,
1368
- pending: trimmed.length >= MIN_QUERY_LENGTH && !settled && !failed
1441
+ pending: long && !settled && !failed
1369
1442
  };
1370
1443
  }
1371
1444
 
1445
+ // src/genre-tree/useArtistSearch.ts
1446
+ var RESULT_LIMIT = 8;
1447
+ function useArtistSearch(getBackendBaseUrl, text) {
1448
+ const { results, isError, settled, pending } = useRemoteSearch(getBackendBaseUrl, {
1449
+ queryKey: artistQueryKeys.search,
1450
+ endpoint: artistEndpoints.search(),
1451
+ params: (q) => ({ q, limit: RESULT_LIMIT }),
1452
+ schema: ArtistSearchResultsSchema,
1453
+ context: "useArtistSearch",
1454
+ text
1455
+ });
1456
+ return { artists: results, isError, settled, pending };
1457
+ }
1458
+
1372
1459
  // src/genre-tree/useSong.ts
1373
- var import_zod27 = require("zod");
1460
+ var import_zod28 = require("zod");
1374
1461
 
1375
1462
  // src/genre-tree/schemas/song/detailed.ts
1376
- var import_zod26 = require("zod");
1463
+ var import_zod27 = require("zod");
1377
1464
  var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
1378
1465
  not_found: "Video unavailable",
1379
1466
  not_embeddable: "Embedding disabled",
@@ -1382,17 +1469,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
1382
1469
  region_whitelisted: "Region restricted"
1383
1470
  };
1384
1471
  var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
1472
+ var YoutubeAvailabilitySchema = import_zod27.z.object({
1473
+ status: import_zod27.z.enum(["eligible", "blocked", "unknown"]),
1474
+ reason: import_zod27.z.string().nullable(),
1475
+ country: import_zod27.z.string().nullable()
1476
+ });
1385
1477
  var SongDetailedSchema = TrackBaseSchema.extend({
1386
- youtubeVideo: import_zod26.z.object({
1387
- id: import_zod26.z.string(),
1478
+ youtubeVideo: import_zod27.z.object({
1479
+ id: import_zod27.z.string(),
1480
+ availability: YoutubeAvailabilitySchema.optional(),
1388
1481
  // null = playable
1389
- unplayableReason: import_zod26.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
1390
- viewCount: import_zod26.z.number().int().nullable().optional()
1482
+ unplayableReason: import_zod27.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
1483
+ viewCount: import_zod27.z.number().int().nullable().optional()
1391
1484
  }).nullable(),
1392
1485
  // null for hand-made/admin songs
1393
- musicbrainzRecordingId: import_zod26.z.string().uuid().nullable(),
1394
- firstReleaseYear: import_zod26.z.number().int().nullable().optional(),
1395
- essentialGenres: import_zod26.z.array(CriteriaMinimumSchema).optional()
1486
+ musicbrainzRecordingId: import_zod27.z.string().uuid().nullable(),
1487
+ firstReleaseYear: import_zod27.z.number().int().nullable().optional(),
1488
+ essentialGenres: import_zod27.z.array(CriteriaMinimumSchema).optional()
1396
1489
  });
1397
1490
  var NO_VIDEO_LABEL = "No video available";
1398
1491
  function isSong(track) {
@@ -1400,6 +1493,7 @@ function isSong(track) {
1400
1493
  }
1401
1494
  function songUnplayableReason(song) {
1402
1495
  if (!song.youtubeVideo) return NO_VIDEO_LABEL;
1496
+ if (song.youtubeVideo.availability?.status === "blocked" && song.youtubeVideo.availability.reason === "region_blocked") return "Unavailable in your country";
1403
1497
  const reason = song.youtubeVideo.unplayableReason;
1404
1498
  return reason ? YOUTUBE_UNPLAYABLE_REASON_LABELS[reason] : null;
1405
1499
  }
@@ -1410,14 +1504,15 @@ function musicBrainzRecordingUrl(song) {
1410
1504
  // src/genre-tree/useSong.ts
1411
1505
  var isNotFound2 = (error) => error instanceof AppError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */;
1412
1506
  function useSong(uuid, getBackendBaseUrl) {
1507
+ const playback = usePlaybackContext();
1413
1508
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1414
- const isUuid = uuid !== null && import_zod27.z.string().uuid().safeParse(uuid).success;
1509
+ const isUuid = uuid !== null && import_zod28.z.string().uuid().safeParse(uuid).success;
1415
1510
  const { data, isPending, error } = useQueryWithParse({
1416
- queryKey: libraryQueryKeys.reference.songs.detail(uuid),
1511
+ queryKey: [...libraryQueryKeys.reference.songs.detail(uuid), ...playback.key ? [playback.key] : []],
1417
1512
  // A missing song is shown in the panel, not raised as an app-wide connectivity error.
1418
1513
  queryFn: ({ signal }) => fetch2(libraryEndpoints.reference.songs.detail(uuid), true, false, { signal }, void 0, false, true),
1419
1514
  schema: SongDetailedSchema,
1420
- enabled: isUuid,
1515
+ enabled: isUuid && playback.ready,
1421
1516
  retry: (failureCount, retryError) => !isNotFound2(retryError) && failureCount < 3,
1422
1517
  context: "useSong"
1423
1518
  });
@@ -1429,16 +1524,16 @@ function useSong(uuid, getBackendBaseUrl) {
1429
1524
  }
1430
1525
 
1431
1526
  // src/genre-tree/schemas/song-history.ts
1432
- var import_zod28 = require("zod");
1433
- var SongHistoryEntrySchema = import_zod28.z.object({
1434
- uuid: import_zod28.z.string().uuid(),
1435
- action: import_zod28.z.string(),
1436
- actorPseudo: import_zod28.z.string().nullable(),
1437
- oldValue: import_zod28.z.string().nullable(),
1438
- newValue: import_zod28.z.string().nullable(),
1439
- createdOn: import_zod28.z.string()
1527
+ var import_zod29 = require("zod");
1528
+ var SongHistoryEntrySchema = import_zod29.z.object({
1529
+ uuid: import_zod29.z.string().uuid(),
1530
+ action: import_zod29.z.string(),
1531
+ actorPseudo: import_zod29.z.string().nullable(),
1532
+ oldValue: import_zod29.z.string().nullable(),
1533
+ newValue: import_zod29.z.string().nullable(),
1534
+ createdOn: import_zod29.z.string()
1440
1535
  });
1441
- var SongHistorySchema = import_zod28.z.array(SongHistoryEntrySchema);
1536
+ var SongHistorySchema = import_zod29.z.array(SongHistoryEntrySchema);
1442
1537
 
1443
1538
  // src/genre-tree/useSongHistory.ts
1444
1539
  function useSongHistory(uuid, getBackendBaseUrl, enabled) {
@@ -1457,72 +1552,56 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
1457
1552
  return { status: "success", entries: data };
1458
1553
  }
1459
1554
 
1460
- // src/genre-tree/useSongSearch.ts
1461
- var import_react_query7 = require("@tanstack/react-query");
1462
- var import_react7 = require("react");
1463
-
1464
1555
  // src/genre-tree/schemas/song-search.ts
1465
- var import_zod29 = require("zod");
1466
- var SongSearchResultSchema = import_zod29.z.object({
1467
- uuid: import_zod29.z.string().uuid(),
1468
- title: import_zod29.z.string(),
1469
- artists: import_zod29.z.array(ArtistMinimumSchema),
1556
+ var import_zod30 = require("zod");
1557
+ var SongSearchResultSchema = import_zod30.z.object({
1558
+ uuid: import_zod30.z.string().uuid(),
1559
+ title: import_zod30.z.string(),
1560
+ artists: import_zod30.z.array(ArtistMinimumSchema),
1470
1561
  // null for songs not yet linked to a genre.
1471
1562
  genre: CriteriaMinimumSchema.nullable(),
1472
- youtubeVideo: import_zod29.z.object({
1473
- id: import_zod29.z.string(),
1474
- unplayableReason: import_zod29.z.string().nullable()
1563
+ youtubeVideo: import_zod30.z.object({
1564
+ id: import_zod30.z.string(),
1565
+ unplayableReason: import_zod30.z.string().nullable()
1475
1566
  }).nullable(),
1476
- firstReleaseYear: import_zod29.z.number().int().nullable()
1567
+ firstReleaseYear: import_zod30.z.number().int().nullable()
1477
1568
  });
1478
- var SongSearchResultsSchema = import_zod29.z.array(SongSearchResultSchema);
1569
+ var SongSearchResultsSchema = import_zod30.z.array(SongSearchResultSchema);
1479
1570
  function isSongSearchResultPlayable(result) {
1480
1571
  return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
1481
1572
  }
1482
1573
 
1483
1574
  // src/genre-tree/useSongSearch.ts
1484
- var DEBOUNCE_MS2 = 250;
1485
- var MIN_QUERY_LENGTH2 = 2;
1486
- var RESULT_LIMIT2 = 8;
1487
- function useSongSearch(getBackendBaseUrl, text) {
1488
- const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1489
- const trimmed = text.trim();
1490
- const [query, setQuery] = (0, import_react7.useState)("");
1491
- (0, import_react7.useEffect)(() => {
1492
- const timer = setTimeout(() => setQuery(trimmed), DEBOUNCE_MS2);
1493
- return () => clearTimeout(timer);
1494
- }, [trimmed]);
1495
- const enabled = query.length >= MIN_QUERY_LENGTH2;
1496
- const { data, isFetching, isError } = useQueryWithParse({
1497
- queryKey: libraryQueryKeys.reference.songs.search({ q: query, limit: RESULT_LIMIT2 }),
1498
- queryFn: ({ signal }) => fetch2(libraryEndpoints.reference.songs.search(), true, false, { signal }, { q: query, limit: RESULT_LIMIT2 }),
1575
+ var DEFAULT_RESULT_LIMIT = 8;
1576
+ function useSongSearch(getBackendBaseUrl, text, options = {}) {
1577
+ const playback = usePlaybackContext();
1578
+ const { limit = DEFAULT_RESULT_LIMIT, genre, playable } = options;
1579
+ const params = (q) => ({ q, limit, ...genre && { genre }, ...playable !== void 0 && { playable } });
1580
+ const { results, isError, settled, pending } = useRemoteSearch(getBackendBaseUrl, {
1581
+ queryKey: (q) => [...libraryQueryKeys.reference.songs.search(params(q)), ...playback.key ? [playback.key] : []],
1582
+ endpoint: libraryEndpoints.reference.songs.search(),
1583
+ params,
1499
1584
  schema: SongSearchResultsSchema,
1500
1585
  context: "useSongSearch",
1501
- enabled,
1502
- placeholderData: import_react_query7.keepPreviousData
1586
+ text,
1587
+ enabled: playback.ready,
1588
+ keepPrevious: playback.key === null
1503
1589
  });
1504
- const settled = enabled && !isFetching && query === trimmed;
1505
- const failed = enabled && isError;
1506
- return {
1507
- songs: trimmed.length >= MIN_QUERY_LENGTH2 ? data ?? [] : [],
1508
- isError: failed,
1509
- settled,
1510
- pending: trimmed.length >= MIN_QUERY_LENGTH2 && !settled && !failed
1511
- };
1590
+ return { songs: results, isError, settled, pending };
1512
1591
  }
1513
1592
 
1514
1593
  // src/genre-tree/useArtistGenreCounts.ts
1515
- var import_react_query8 = require("@tanstack/react-query");
1516
- var import_zod31 = require("zod");
1594
+ var import_react_query7 = require("@tanstack/react-query");
1595
+ var import_zod32 = require("zod");
1517
1596
 
1518
1597
  // src/genre-tree/schemas/artist-genre-count.ts
1519
- var import_zod30 = require("zod");
1520
- var ArtistGenreCountSchema = import_zod30.z.object({
1598
+ var import_zod31 = require("zod");
1599
+ var ArtistGenreCountSchema = import_zod31.z.object({
1521
1600
  genrePlaylist: GenrePlaylistUuidSchema,
1522
1601
  /** All the artist's songs in the genre playlist's subtree; drives pruning. */
1523
- songsCount: import_zod30.z.number().int().nonnegative(),
1602
+ songsCount: import_zod31.z.number().int().nonnegative(),
1524
1603
  /** The playable ones among them; drives node size and the play button. */
1525
- tracksCount: import_zod30.z.number().int().nonnegative()
1604
+ tracksCount: import_zod31.z.number().int().nonnegative()
1526
1605
  });
1527
1606
 
1528
1607
  // src/genre-tree/useArtistGenreCounts.ts
@@ -1533,56 +1612,166 @@ function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
1533
1612
  queryKey: artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid),
1534
1613
  // A missing artist is shown in the artist panel, not raised as an app-wide connectivity error.
1535
1614
  queryFn: () => fetch2(artistEndpoints.genreCounts(artistUuid), true, false, void 0, void 0, false, true),
1536
- schema: import_zod31.z.array(ArtistGenreCountSchema),
1615
+ schema: import_zod32.z.array(ArtistGenreCountSchema),
1537
1616
  enabled: artistUuid !== null,
1538
- placeholderData: import_react_query8.keepPreviousData,
1617
+ placeholderData: import_react_query7.keepPreviousData,
1539
1618
  retry: (failureCount, error) => !isNotFound3(error) && failureCount < 3,
1540
1619
  context: "useArtistGenreCounts"
1541
1620
  });
1542
1621
  }
1543
1622
 
1544
- // src/genre-tree/useGenreSearch.ts
1545
- var import_react8 = require("react");
1623
+ // src/genre-tree/lib/search-text.ts
1624
+ var foldSearchText = (text) => text.normalize("NFD").replace(/\p{M}+/gu, "").toLowerCase().replace(/\s+/g, " ").trim();
1625
+ var trigrams = (folded) => {
1626
+ const padded = ` ${folded} `;
1627
+ const grams = /* @__PURE__ */ new Set();
1628
+ for (let i = 0; i + 3 <= padded.length; i++) grams.add(padded.slice(i, i + 3));
1629
+ return grams;
1630
+ };
1631
+ var trigramSimilarity = (a, b) => {
1632
+ const ta = trigrams(foldSearchText(a));
1633
+ const tb = trigrams(foldSearchText(b));
1634
+ let shared = 0;
1635
+ for (const gram of ta) if (tb.has(gram)) shared++;
1636
+ const union = ta.size + tb.size - shared;
1637
+ return union === 0 ? 0 : shared / union;
1638
+ };
1639
+ var FUZZY_MIN_SIMILARITY = 0.3;
1640
+ var TIER_EXACT = 0;
1641
+ var TIER_PREFIX = 1;
1642
+ var TIER_SUBSTRING = 2;
1643
+ var TIER_FUZZY = 3;
1644
+ function rankByName(items, query, getName, getViews) {
1645
+ const folded = foldSearchText(query);
1646
+ if (!folded) return [];
1647
+ const scored = [];
1648
+ for (const item of items) {
1649
+ const name = getName(item);
1650
+ const foldedName = foldSearchText(name);
1651
+ let tier;
1652
+ let similarity = 0;
1653
+ if (foldedName === folded) tier = TIER_EXACT;
1654
+ else if (foldedName.startsWith(folded)) tier = TIER_PREFIX;
1655
+ else if (foldedName.includes(folded)) tier = TIER_SUBSTRING;
1656
+ else {
1657
+ similarity = trigramSimilarity(name, query);
1658
+ if (similarity < FUZZY_MIN_SIMILARITY) continue;
1659
+ tier = TIER_FUZZY;
1660
+ }
1661
+ scored.push({ item, tier, similarity, views: getViews?.(item) ?? 0, name: foldedName });
1662
+ }
1663
+ scored.sort(
1664
+ (a, b) => a.tier - b.tier || b.similarity - a.similarity || b.views - a.views || a.name.localeCompare(b.name)
1665
+ );
1666
+ return scored.map((entry) => entry.item);
1667
+ }
1546
1668
 
1547
1669
  // src/genre-tree/lib/genre-search.ts
1548
- var searchGenrePlaylistsByName = (genrePlaylists, query) => {
1549
- const trimmedQuery = query.trim().toLowerCase();
1550
- if (!trimmedQuery) return [];
1551
- return genrePlaylists.filter(
1552
- (genrePlaylist) => genrePlaylist.name.toLowerCase().includes(trimmedQuery)
1553
- );
1554
- };
1670
+ var searchGenrePlaylistsByName = (genrePlaylists, query) => rankByName(genrePlaylists, query, (genrePlaylist) => genrePlaylist.name, (genrePlaylist) => genrePlaylist.viewsCount ?? 0);
1555
1671
 
1556
- // src/genre-tree/useGenreSearch.ts
1557
- function useGenreSearch({
1558
- genrePlaylists,
1559
- onSelect,
1560
- selectedName = null,
1561
- onClear
1562
- }) {
1672
+ // src/genre-tree/useSearchQueryState.ts
1673
+ var import_react8 = require("react");
1674
+ function useSearchQueryState({ selectedName = null, onClear } = {}) {
1563
1675
  const [query, setQuery] = (0, import_react8.useState)(selectedName ?? "");
1564
1676
  const [prevSelectedName, setPrevSelectedName] = (0, import_react8.useState)(selectedName);
1565
1677
  if (selectedName !== prevSelectedName) {
1566
1678
  setPrevSelectedName(selectedName);
1567
1679
  setQuery(selectedName ?? "");
1568
1680
  }
1569
- const results = query !== "" && query !== selectedName ? searchGenrePlaylistsByName(genrePlaylists, query) : [];
1570
1681
  return {
1571
1682
  query,
1572
1683
  setQuery,
1573
- results,
1684
+ isTyping: query !== "" && query !== selectedName,
1574
1685
  canClear: query !== "" || selectedName !== null,
1575
1686
  clear: () => {
1576
1687
  setQuery("");
1577
1688
  onClear?.();
1578
1689
  },
1690
+ notifyPick: (pickedName) => {
1691
+ setQuery(pickedName === selectedName ? selectedName : "");
1692
+ }
1693
+ };
1694
+ }
1695
+
1696
+ // src/genre-tree/useGenreSearch.ts
1697
+ function useGenreSearch({
1698
+ genrePlaylists,
1699
+ onSelect,
1700
+ selectedName = null,
1701
+ onClear
1702
+ }) {
1703
+ const { query, setQuery, isTyping, canClear, clear, notifyPick } = useSearchQueryState({ selectedName, onClear });
1704
+ const results = isTyping ? searchGenrePlaylistsByName(genrePlaylists, query) : [];
1705
+ return {
1706
+ query,
1707
+ setQuery,
1708
+ results,
1709
+ canClear,
1710
+ clear,
1579
1711
  select: (genrePlaylist) => {
1580
- setQuery(genrePlaylist.name === selectedName ? selectedName : "");
1712
+ notifyPick(genrePlaylist.name);
1581
1713
  onSelect(genrePlaylist);
1582
1714
  }
1583
1715
  };
1584
1716
  }
1585
1717
 
1718
+ // src/genre-tree/schemas/genre-search.ts
1719
+ var import_zod33 = require("zod");
1720
+ var GenreSearchTreeNameSchema = import_zod33.z.enum(["canonical", "regional"]);
1721
+ var GenreSearchResultSchema = import_zod33.z.object({
1722
+ /** Criteria (genre) uuid. */
1723
+ uuid: GenreUuidSchema,
1724
+ name: import_zod33.z.string(),
1725
+ treeName: import_zod33.z.string(),
1726
+ /** Null when the genre has no playlist in the tree, so it cannot be opened there. */
1727
+ genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
1728
+ root: import_zod33.z.object({ uuid: GenreUuidSchema, name: import_zod33.z.string() }),
1729
+ isUmbrella: import_zod33.z.boolean(),
1730
+ viewsCount: import_zod33.z.number().int()
1731
+ });
1732
+ var GenreSearchResultsSchema = import_zod33.z.array(GenreSearchResultSchema);
1733
+ var RegionGenreLexiconEntrySchema = import_zod33.z.object({
1734
+ wikidataId: import_zod33.z.string(),
1735
+ uuid: GenreUuidSchema,
1736
+ name: import_zod33.z.string(),
1737
+ treeName: import_zod33.z.string(),
1738
+ genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
1739
+ isUmbrella: import_zod33.z.boolean(),
1740
+ viewsCount: import_zod33.z.number().int()
1741
+ });
1742
+ var RegionGenreLexiconSchema = import_zod33.z.array(RegionGenreLexiconEntrySchema);
1743
+
1744
+ // src/genre-tree/useGenreRemoteSearch.ts
1745
+ var DEFAULT_RESULT_LIMIT2 = 8;
1746
+ function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAULT_RESULT_LIMIT2, enabled } = {}) {
1747
+ const params = (q) => ({ q, limit, ...treeName && { treeName } });
1748
+ const { results, isError, settled, pending } = useRemoteSearch(getBackendBaseUrl, {
1749
+ queryKey: (q) => genreSearchQueryKeys.search(params(q)),
1750
+ endpoint: genreEndpoints.search(),
1751
+ params,
1752
+ schema: GenreSearchResultsSchema,
1753
+ context: "useGenreRemoteSearch",
1754
+ text,
1755
+ enabled
1756
+ });
1757
+ return { genres: results, isError, settled, pending };
1758
+ }
1759
+
1760
+ // src/genre-tree/useRegionGenreLexicon.ts
1761
+ function useRegionGenreLexicon(getBackendBaseUrl, enabled) {
1762
+ const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1763
+ const { data, isError, isPending } = useQueryWithParse({
1764
+ queryKey: genreSearchQueryKeys.regionLexicon(),
1765
+ queryFn: ({ signal }) => fetch2(genreEndpoints.regionLexicon(), true, false, { signal }),
1766
+ schema: RegionGenreLexiconSchema,
1767
+ context: "useRegionGenreLexicon",
1768
+ enabled,
1769
+ staleTime: Infinity
1770
+ });
1771
+ const entries = data ?? [];
1772
+ return { entries, isError, isPending: enabled && isPending };
1773
+ }
1774
+
1586
1775
  // src/genre-tree/useGenreTreeViewState.ts
1587
1776
  var import_react10 = require("react");
1588
1777
 
@@ -1748,10 +1937,10 @@ function useGenreTreeViewState({
1748
1937
  var import_react13 = require("react");
1749
1938
 
1750
1939
  // src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
1751
- var import_zod32 = require("zod");
1752
- var makeTrackPlaylistRelSchema = (trackSchema) => import_zod32.z.object({
1940
+ var import_zod34 = require("zod");
1941
+ var makeTrackPlaylistRelSchema = (trackSchema) => import_zod34.z.object({
1753
1942
  track: trackSchema,
1754
- position: import_zod32.z.number().min(0)
1943
+ position: import_zod34.z.number().min(0)
1755
1944
  });
1756
1945
  var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
1757
1946
 
@@ -1856,7 +2045,12 @@ var TrackListOriginFromArtist = class extends TrackListOrigin {
1856
2045
 
1857
2046
  // src/player/PlayerContext.tsx
1858
2047
  var import_react11 = require("react");
1859
- var import_jsx_runtime3 = require("react/jsx-runtime");
2048
+
2049
+ // src/player/PlaybackFailures.ts
2050
+ var TTL_MS = 10 * 6e4;
2051
+
2052
+ // src/player/PlayerContext.tsx
2053
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1860
2054
  var PlayerContext = (0, import_react11.createContext)(void 0);
1861
2055
  function usePlayer() {
1862
2056
  const context = (0, import_react11.useContext)(PlayerContext);
@@ -1868,7 +2062,7 @@ function usePlayer() {
1868
2062
 
1869
2063
  // src/genre-tree/TrackListSidebarVisibilityContext.tsx
1870
2064
  var import_react12 = require("react");
1871
- var import_jsx_runtime4 = require("react/jsx-runtime");
2065
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1872
2066
  var TrackListSidebarVisibilityContext = (0, import_react12.createContext)(void 0);
1873
2067
  function TrackListSidebarVisibilityProvider({ children }) {
1874
2068
  const [isTrackListSidebarVisible, setIsTrackListSidebarVisible] = (0, import_react12.useState)(false);
@@ -1890,7 +2084,7 @@ function TrackListSidebarVisibilityProvider({ children }) {
1890
2084
  }),
1891
2085
  [isTrackListSidebarVisible, toggleTrackListSidebar, showTrackListSidebar, hideTrackListSidebar]
1892
2086
  );
1893
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TrackListSidebarVisibilityContext.Provider, { value, children });
2087
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TrackListSidebarVisibilityContext.Provider, { value, children });
1894
2088
  }
1895
2089
  function useTrackListSidebarVisibility() {
1896
2090
  const context = (0, import_react12.useContext)(TrackListSidebarVisibilityContext);
@@ -1901,25 +2095,26 @@ function useTrackListSidebarVisibility() {
1901
2095
  }
1902
2096
 
1903
2097
  // src/genre-tree/TrackListContext.tsx
1904
- var import_jsx_runtime5 = require("react/jsx-runtime");
2098
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1905
2099
  var TRACKS_PAGE_SIZE = 100;
1906
2100
  var AUTO_LOAD_REMAINING_TRACKS = 10;
1907
2101
  var AUTO_SKIP_DELAY_MS = 1e3;
1908
- function isTrackPlayable(track, runtimeUnplayableTrackIds) {
1909
- return !runtimeUnplayableTrackIds.has(track.uuid) && (!isSong(track) || songUnplayableReason(track) === null);
2102
+ function isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure) {
2103
+ return !runtimeUnplayableTrackIds.has(track.uuid) && (!isSong(track) || songUnplayableReason(track) === null && (!track.youtubeVideo || !hasPlaybackFailure(track.youtubeVideo.id)));
1910
2104
  }
1911
2105
  function useListTracks(scope, getBackendBaseUrl, schema, listEndpoint, listQueryKey, page = 1, pageSize = 50) {
2106
+ const playback = usePlaybackContext();
1912
2107
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1913
2108
  const { session, sessionRestored } = useSession();
1914
2109
  return useQueryWithParse({
1915
- queryKey: listQueryKey(page),
2110
+ queryKey: [...listQueryKey(page), ...playback.key ? [playback.key] : []],
1916
2111
  queryFn: async () => {
1917
2112
  if (scope == null) return null;
1918
2113
  return fetch2(listEndpoint(page), true, scope === "me", {}, { page, pageSize });
1919
2114
  },
1920
2115
  schema: PaginatedResponseSchema(schema),
1921
2116
  context: "useListTracks",
1922
- enabled: scope != null && (scope === "reference" || sessionRestored && !!session?.accessToken)
2117
+ enabled: playback.ready && scope != null && (scope === "reference" || sessionRestored && !!session?.accessToken)
1923
2118
  });
1924
2119
  }
1925
2120
  var TrackListContext = (0, import_react13.createContext)(void 0);
@@ -1931,12 +2126,22 @@ function TrackListProvider({
1931
2126
  const [trackList, setTrackList] = (0, import_react13.useState)(null);
1932
2127
  const [selectedTrack, setSelectedTrack] = (0, import_react13.useState)(null);
1933
2128
  const [autoAdvanceScrollRequest, setAutoAdvanceScrollRequest] = (0, import_react13.useState)(null);
1934
- const [runtimeUnplayableTrackIds, setRuntimeUnplayableTrackIds] = (0, import_react13.useState)(() => /* @__PURE__ */ new Set());
1935
- const { loadTrackForPlayer, setOnTrackEnd } = usePlayer();
2129
+ const { loadTrackForPlayer, setOnTrackEnd, hasPlaybackFailure, playerTrackObject } = usePlayer();
2130
+ const [failureClock, setFailureClock] = (0, import_react13.useState)(0);
2131
+ (0, import_react13.useEffect)(() => {
2132
+ const timer = setInterval(() => setFailureClock((tick) => tick + 1), 3e4);
2133
+ return () => clearInterval(timer);
2134
+ }, []);
2135
+ const runtimeUnplayableTrackIds = (0, import_react13.useMemo)(() => new Set(
2136
+ (trackList?.tracks ?? []).filter((track) => isSong(track) && track.youtubeVideo && hasPlaybackFailure(track.youtubeVideo.id)).map((track) => track.uuid)
2137
+ ), [trackList, hasPlaybackFailure, playerTrackObject, failureClock]);
1936
2138
  const { showTrackListSidebar } = useTrackListSidebarVisibility();
2139
+ const playback = usePlaybackContext();
1937
2140
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1938
2141
  const pageSchema = (0, import_react13.useMemo)(() => makeTrackPlaylistRelPageSchema(schema), [schema]);
1939
2142
  const latestPlayRequestRef = (0, import_react13.useRef)(0);
2143
+ const startingPlaybackRef = (0, import_react13.useRef)(false);
2144
+ const loadedContextRef = (0, import_react13.useRef)(playback.key);
1940
2145
  const autoAdvanceScrollRequestIdRef = (0, import_react13.useRef)(0);
1941
2146
  const delayedTrackLoadRef = (0, import_react13.useRef)(null);
1942
2147
  const loadingOriginRef = (0, import_react13.useRef)(null);
@@ -1964,7 +2169,7 @@ function TrackListProvider({
1964
2169
  async (uuid, scope, page, from) => {
1965
2170
  const endpoint = genrePlaylistEndpoints[scope].tracks(uuid);
1966
2171
  const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from } };
1967
- const response = await fetch2(endpoint, true, scope === "me", {}, params);
2172
+ const response = await fetch2(endpoint, true, scope === "me", {}, params, false, !!from, page === 1);
1968
2173
  const parsed = parseWithLog(pageSchema, response, "fetchGenrePlaylistTracksPage");
1969
2174
  return {
1970
2175
  tracks: parsed.results.map((rel) => rel.track),
@@ -1994,7 +2199,8 @@ function TrackListProvider({
1994
2199
  params,
1995
2200
  false,
1996
2201
  // A start song that isn't playable 404s; surface it as a rejection, not the global error.
1997
- page === 1 && !!origin.from
2202
+ page === 1 && !!origin.from,
2203
+ page === 1
1998
2204
  );
1999
2205
  const parsed = parseWithLog(artistPageSchema, response, "fetchArtistTracksPage");
2000
2206
  return { tracks: parsed.results, total: parsed.overallTotal, nextPage: parsed.next ? parsed.page + 1 : null };
@@ -2006,14 +2212,13 @@ function TrackListProvider({
2006
2212
  const completedTrackId = event?.trackId ?? selectedTrack?.uuid;
2007
2213
  if (!completedTrackId || !trackList) return;
2008
2214
  if (selectedTrack && selectedTrack.uuid !== completedTrackId) return;
2009
- const isEmbeddingBlocked = event?.error?.code === 101 || event?.error?.code === 150;
2215
+ const isEmbeddingBlocked = event?.error?.code === 100 || event?.error?.code === 101 || event?.error?.code === 150;
2010
2216
  if (event?.error) {
2011
- setRuntimeUnplayableTrackIds((previous) => new Set(previous).add(completedTrackId));
2012
2217
  if (!isEmbeddingBlocked) return;
2013
2218
  }
2014
2219
  const currentIndex = trackList.tracks.findIndex((track) => track.uuid === completedTrackId);
2015
2220
  if (currentIndex === -1) return;
2016
- const nextTrack2 = trackList.tracks.slice(currentIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds));
2221
+ const nextTrack2 = trackList.tracks.slice(currentIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure));
2017
2222
  if (!nextTrack2) {
2018
2223
  pendingAdvanceRef.current = trackList.nextPage === null ? null : { trackId: completedTrackId, origin: trackList.origin, delayLoad: isEmbeddingBlocked };
2019
2224
  return;
@@ -2030,6 +2235,7 @@ function TrackListProvider({
2030
2235
  loadTrackForPlayer,
2031
2236
  requestAutoAdvanceScroll,
2032
2237
  runtimeUnplayableTrackIds,
2238
+ hasPlaybackFailure,
2033
2239
  selectedTrack
2034
2240
  ]
2035
2241
  );
@@ -2050,6 +2256,8 @@ function TrackListProvider({
2050
2256
  const playNewTrackListFromTrackUuid = (0, import_react13.useCallback)(
2051
2257
  (track, scope) => {
2052
2258
  latestPlayRequestRef.current++;
2259
+ startingPlaybackRef.current = false;
2260
+ loadedContextRef.current = playback.snapshot().key;
2053
2261
  clearDelayedTrackLoad();
2054
2262
  setAutoAdvanceScrollRequest(null);
2055
2263
  const origin = new TrackListOriginFromTrack(track, scope);
@@ -2065,15 +2273,19 @@ function TrackListProvider({
2065
2273
  async (genrePlaylist, scope, options) => {
2066
2274
  clearDelayedTrackLoad();
2067
2275
  const request = ++latestPlayRequestRef.current;
2276
+ startingPlaybackRef.current = true;
2068
2277
  const from = options?.startSongUuid;
2069
2278
  let page;
2070
2279
  try {
2071
2280
  page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from);
2072
2281
  } catch (error) {
2073
2282
  if (request !== latestPlayRequestRef.current) return;
2283
+ startingPlaybackRef.current = false;
2074
2284
  throw error;
2075
2285
  }
2076
2286
  if (request !== latestPlayRequestRef.current) return;
2287
+ startingPlaybackRef.current = false;
2288
+ loadedContextRef.current = playback.snapshot().key;
2077
2289
  const startTrack = page.tracks[0];
2078
2290
  if (from && startTrack?.uuid !== from) {
2079
2291
  throw new Error(`Genre playlist ${genrePlaylist.uuid} did not start at track ${from}`);
@@ -2096,6 +2308,7 @@ function TrackListProvider({
2096
2308
  if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
2097
2309
  clearDelayedTrackLoad();
2098
2310
  const request = ++latestPlayRequestRef.current;
2311
+ startingPlaybackRef.current = true;
2099
2312
  const from = options.startSongUuid;
2100
2313
  const origin = new TrackListOriginFromArtist(artist, scope, options.ordering, from, options.genreUuid);
2101
2314
  let page;
@@ -2103,9 +2316,12 @@ function TrackListProvider({
2103
2316
  page = await fetchArtistTracksPage(origin, 1);
2104
2317
  } catch (error) {
2105
2318
  if (request !== latestPlayRequestRef.current) return;
2319
+ startingPlaybackRef.current = false;
2106
2320
  throw error;
2107
2321
  }
2108
2322
  if (request !== latestPlayRequestRef.current) return;
2323
+ startingPlaybackRef.current = false;
2324
+ loadedContextRef.current = playback.snapshot().key;
2109
2325
  const startTrack = page.tracks[0];
2110
2326
  if (from && startTrack?.uuid !== from) {
2111
2327
  throw new Error(`Artist ${artist.uuid} did not start at song ${from}`);
@@ -2122,6 +2338,51 @@ function TrackListProvider({
2122
2338
  },
2123
2339
  [clearDelayedTrackLoad, fetchArtistTracksPage, showTrackListSidebar, loadTrackForPlayer]
2124
2340
  );
2341
+ const contextKeyRef = (0, import_react13.useRef)(playback.key);
2342
+ (0, import_react13.useEffect)(() => {
2343
+ if (contextKeyRef.current === playback.key) return;
2344
+ contextKeyRef.current = playback.key;
2345
+ if (loadedContextRef.current === playback.key) return;
2346
+ if (startingPlaybackRef.current) {
2347
+ pendingAdvanceRef.current = null;
2348
+ clearDelayedTrackLoad();
2349
+ setTrackList(null);
2350
+ setSelectedTrack(null);
2351
+ return;
2352
+ }
2353
+ const origin = trackList?.origin;
2354
+ const selected = selectedTrack;
2355
+ latestPlayRequestRef.current++;
2356
+ pendingAdvanceRef.current = null;
2357
+ clearDelayedTrackLoad();
2358
+ setTrackList(null);
2359
+ setSelectedTrack(null);
2360
+ if (origin instanceof TrackListOriginFromCriteriaPlaylist) {
2361
+ void playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { startSongUuid: selected?.uuid }).catch((error) => {
2362
+ if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
2363
+ return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope).catch(() => {
2364
+ });
2365
+ }
2366
+ });
2367
+ } else if (origin instanceof TrackListOriginFromArtist) {
2368
+ const options = { ordering: origin.ordering, genreUuid: origin.genreUuid };
2369
+ void playNewTrackListFromArtist(origin.artist, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
2370
+ if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
2371
+ return playNewTrackListFromArtist(origin.artist, origin.scope, options).catch(() => {
2372
+ });
2373
+ }
2374
+ });
2375
+ } else if (origin instanceof TrackListOriginFromTrack && selected) {
2376
+ const request = latestPlayRequestRef.current;
2377
+ void (async () => {
2378
+ const track = isSong(selected) && origin.scope === "reference" ? parseWithLog(schema, await fetch2(libraryEndpoints.reference.songs.detail(selected.uuid), true, false), "refreshSelectedTrack") : selected;
2379
+ if (request !== latestPlayRequestRef.current) return;
2380
+ setTrackList(new TrackListFromTrack([track], new TrackListOriginFromTrack(track, origin.scope)));
2381
+ setSelectedTrack(track);
2382
+ })().catch(() => {
2383
+ });
2384
+ }
2385
+ }, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, schema, fetch2]);
2125
2386
  const updateTrack = (0, import_react13.useCallback)((track) => {
2126
2387
  setTrackList((prev) => {
2127
2388
  if (!prev || !prev.tracks.some((listed) => listed.uuid === track.uuid)) return prev;
@@ -2150,8 +2411,8 @@ function TrackListProvider({
2150
2411
  }
2151
2412
  }, [trackList, fetchTracksPage, fetchArtistTracksPage]);
2152
2413
  const selectedTrackIndex = trackList?.tracks.findIndex((track) => track.uuid === selectedTrack?.uuid) ?? -1;
2153
- const nextTrack = trackList && selectedTrackIndex >= 0 ? trackList.tracks.slice(selectedTrackIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds)) ?? null : null;
2154
- const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds)) ?? null : null;
2414
+ const nextTrack = trackList && selectedTrackIndex >= 0 ? trackList.tracks.slice(selectedTrackIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
2415
+ const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
2155
2416
  const hasNextTrack = nextTrack !== null || selectedTrackIndex >= 0 && trackList?.nextPage != null;
2156
2417
  const hasPreviousTrack = previousTrack !== null;
2157
2418
  const playNextTrack = (0, import_react13.useCallback)(() => {
@@ -2191,7 +2452,7 @@ function TrackListProvider({
2191
2452
  pendingAdvanceRef.current = null;
2192
2453
  return;
2193
2454
  }
2194
- const nextTrack2 = trackList.tracks.slice(currentIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds));
2455
+ const nextTrack2 = trackList.tracks.slice(currentIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure));
2195
2456
  if (nextTrack2) {
2196
2457
  pendingAdvanceRef.current = null;
2197
2458
  requestAutoAdvanceScroll(nextTrack2.uuid);
@@ -2210,6 +2471,7 @@ function TrackListProvider({
2210
2471
  loadTrackForPlayer,
2211
2472
  requestAutoAdvanceScroll,
2212
2473
  runtimeUnplayableTrackIds,
2474
+ hasPlaybackFailure,
2213
2475
  selectedTrack
2214
2476
  ]);
2215
2477
  (0, import_react13.useEffect)(() => clearDelayedTrackLoad, [clearDelayedTrackLoad]);
@@ -2257,7 +2519,7 @@ function TrackListProvider({
2257
2519
  updateTrack
2258
2520
  ]
2259
2521
  );
2260
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TrackListContext.Provider, { value, children });
2522
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TrackListContext.Provider, { value, children });
2261
2523
  }
2262
2524
  function useTrackList() {
2263
2525
  const context = (0, import_react13.useContext)(TrackListContext);
@@ -2269,37 +2531,37 @@ function useTrackList() {
2269
2531
 
2270
2532
  // src/genre-tree/ArtistNames.tsx
2271
2533
  var import_react14 = require("react");
2272
- var import_jsx_runtime6 = require("react/jsx-runtime");
2534
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2273
2535
  function ArtistNames({
2274
2536
  artists,
2275
2537
  renderArtistLink
2276
2538
  }) {
2277
- if (!renderArtistLink) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: artists.map((artist) => artist.name).join(", ") });
2278
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: artists.map((artist, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react14.Fragment, { children: [
2539
+ if (!renderArtistLink) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: artists.map((artist) => artist.name).join(", ") });
2540
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: artists.map((artist, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react14.Fragment, { children: [
2279
2541
  index > 0 && ", ",
2280
2542
  renderArtistLink(artist)
2281
2543
  ] }, artist.uuid)) });
2282
2544
  }
2283
2545
 
2284
2546
  // src/genre-tree/schemas/mb-artist.ts
2285
- var import_zod33 = require("zod");
2286
- var MbArtistDetailedSchema = import_zod33.z.object({
2287
- musicbrainzId: import_zod33.z.string().uuid(),
2288
- name: import_zod33.z.string(),
2547
+ var import_zod35 = require("zod");
2548
+ var MbArtistDetailedSchema = import_zod35.z.object({
2549
+ musicbrainzId: import_zod35.z.string().uuid(),
2550
+ name: import_zod35.z.string(),
2289
2551
  musicbrainzLink: HttpUrlSchema
2290
2552
  });
2291
2553
 
2292
2554
  // src/genre-tree/schemas/mb-recording.ts
2293
- var import_zod34 = require("zod");
2294
- var MbRecordingDetailedSchema = import_zod34.z.object({
2295
- musicbrainzId: import_zod34.z.string().uuid(),
2296
- title: import_zod34.z.string(),
2297
- score: import_zod34.z.number(),
2298
- musicbrainzArtists: import_zod34.z.array(MbArtistDetailedSchema),
2555
+ var import_zod36 = require("zod");
2556
+ var MbRecordingDetailedSchema = import_zod36.z.object({
2557
+ musicbrainzId: import_zod36.z.string().uuid(),
2558
+ title: import_zod36.z.string(),
2559
+ score: import_zod36.z.number(),
2560
+ musicbrainzArtists: import_zod36.z.array(MbArtistDetailedSchema),
2299
2561
  musicbrainzLink: HttpUrlSchema,
2300
- durationInSec: import_zod34.z.number().min(0).nullable().optional(),
2301
- durationStrInHourMinSec: import_zod34.z.string().nullable().optional(),
2302
- releaseDate: import_zod34.z.union([import_zod34.z.string().datetime(), import_zod34.z.string()]).transform((val) => {
2562
+ durationInSec: import_zod36.z.number().min(0).nullable().optional(),
2563
+ durationStrInHourMinSec: import_zod36.z.string().nullable().optional(),
2564
+ releaseDate: import_zod36.z.union([import_zod36.z.string().datetime(), import_zod36.z.string()]).transform((val) => {
2303
2565
  try {
2304
2566
  const date = new Date(val);
2305
2567
  if (isNaN(date.getTime())) {
@@ -2386,11 +2648,19 @@ function editGenreSongPages(data, edit) {
2386
2648
  CriteriaSimpleSchema,
2387
2649
  CriteriaUpdateSchema,
2388
2650
  FORM_RATING_NULL_VALUE,
2651
+ FUZZY_MIN_SIMILARITY,
2389
2652
  GenrePlaylistUuidSchema,
2653
+ GenreSearchResultSchema,
2654
+ GenreSearchResultsSchema,
2655
+ GenreSearchTreeNameSchema,
2390
2656
  GenreUuidSchema,
2391
2657
  MbArtistDetailedSchema,
2392
2658
  MbRecordingDetailedSchema,
2393
2659
  NO_VIDEO_LABEL,
2660
+ RegionGenreLexiconEntrySchema,
2661
+ RegionGenreLexiconSchema,
2662
+ SEARCH_DEBOUNCE_MS,
2663
+ SEARCH_QUERY_MIN_LENGTH,
2394
2664
  SongDetailedSchema,
2395
2665
  SongHistoryEntrySchema,
2396
2666
  SongHistorySchema,
@@ -2411,15 +2681,18 @@ function editGenreSongPages(data, edit) {
2411
2681
  TrackMinimumSchema,
2412
2682
  UuidResourceSchema,
2413
2683
  YOUTUBE_UNPLAYABLE_REASON_LABELS,
2684
+ YoutubeAvailabilitySchema,
2414
2685
  artistEndpoints,
2415
2686
  artistQueryKeys,
2416
2687
  capitalizeFirstLetter,
2417
2688
  editGenreSongPages,
2689
+ foldSearchText,
2418
2690
  formatTime,
2419
2691
  genreEndpoints,
2420
2692
  genrePlaylistEndpoints,
2421
2693
  genrePlaylistQueryKeys,
2422
2694
  genreQueryKeys,
2695
+ genreSearchQueryKeys,
2423
2696
  genreUpdateMutationKey,
2424
2697
  getGenrePlaylistsGroupedByRoot,
2425
2698
  getReparentCandidates,
@@ -2432,8 +2705,10 @@ function editGenreSongPages(data, edit) {
2432
2705
  makeTrackPlaylistRelSchema,
2433
2706
  musicBrainzRecordingUrl,
2434
2707
  pruneGenrePlaylistsForArtist,
2708
+ rankByName,
2435
2709
  searchGenrePlaylistsByName,
2436
2710
  songUnplayableReason,
2711
+ trigramSimilarity,
2437
2712
  useArtist,
2438
2713
  useArtistGenreCounts,
2439
2714
  useArtistSearch,
@@ -2444,6 +2719,7 @@ function editGenreSongPages(data, edit) {
2444
2719
  useFetchGenreOverview,
2445
2720
  useFetchGenrePlaylist,
2446
2721
  useGenreByWikidataId,
2722
+ useGenreRemoteSearch,
2447
2723
  useGenreSearch,
2448
2724
  useGenreTreeViewState,
2449
2725
  useInvalidateAllGenrePlaylistQueries,
@@ -2452,6 +2728,9 @@ function editGenreSongPages(data, edit) {
2452
2728
  useListGenres,
2453
2729
  useListTracks,
2454
2730
  usePrefetchGenreOverview,
2731
+ useRegionGenreLexicon,
2732
+ useRemoteSearch,
2733
+ useSearchQueryState,
2455
2734
  useSong,
2456
2735
  useSongHistory,
2457
2736
  useSongSearch,