decord/alpha/source/modules/games/autocomplete/useGameAutocomplete.tsx

523 lines
14 KiB
TypeScript
Raw Normal View History

2026-10-08 09:57:35 +00:00
// Module ID: 8682
// Function ID: 8683
// Name: useGameAutocomplete
2026-10-08 09:57:35 +00:00
// Dependencies: [32, 19, 8211, 1085, 504, 8212, 8683, 558, 576, 8684, 2]
2026-07-20 16:05:17 +00:00
2026-10-08 09:57:35 +00:00
// Module 8682 (useGameAutocomplete)
2026-10-03 08:58:59 +00:00
import react2 from "react" /* 576 */;
import Constants from "Constants" /* 1085 */;
2026-10-08 09:57:35 +00:00
import GameAutocompleteUtils from "GameAutocompleteUtils" /* 8212 */;
import GameAutocompleteActionCreators from "GameAutocompleteActionCreators" /* 8683 */;
import GameSearchSession from "GameSearchSession" /* 8684 */;
2026-10-06 11:16:32 +00:00
import _slicedToArray_mod from "_slicedToArray" /* 32 */;
2026-10-03 08:58:59 +00:00
import react from "react" /* 19 */;
2026-10-08 09:57:35 +00:00
import GameAutocompleteStore from "GameAutocompleteStore" /* 8211 */;
2026-10-03 08:58:59 +00:00
import get_initialized from "get initialized" /* 504 */;
import ReactCompilerGating_mod from "ReactCompilerGating" /* 558 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-06 11:16:32 +00:00
const require = globalThis.__r;
let _slicedToArray = _slicedToArray_mod;
2026-10-03 08:58:59 +00:00
const QueryIds = Constants.QueryIds;
let obj = {
2026-10-08 09:57:35 +00:00
getQueryId(name, arg1) {
2026-10-03 08:58:59 +00:00
const GAME_AUTOCOMPLETE = QueryIds.GAME_AUTOCOMPLETE;
const obj = GameAutocompleteUtils;
2026-10-08 09:57:35 +00:00
return GAME_AUTOCOMPLETE(obj.normalizeGameAutocompleteQuery(name), arg1);
2026-07-20 16:05:17 +00:00
},
get(arg0, arg1) {
let results = GameAutocompleteStore.getResults(arg0, arg1);
2026-07-29 08:29:29 +00:00
if (results == null) {
results = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return results;
2026-07-20 16:05:17 +00:00
},
load(arg0, arg1) {
2026-10-03 08:58:59 +00:00
const obj = GameAutocompleteActionCreators;
return obj.fetchGameAutocomplete(arg0, arg1);
2026-07-20 16:05:17 +00:00
},
getIsLoading(arg0, arg1) {
return GameAutocompleteStore.isFetching(arg0, arg1);
2026-07-20 16:05:17 +00:00
},
retryConfig: {
retryableErrors: function isRetryableError(status) {
status = status.status;
let tmp = null != status;
if (tmp) {
let tmp2 = 429 === status;
if (!tmp2) {
2026-10-03 08:58:59 +00:00
tmp2 = status >= 500 && 503 !== status;
const tmp3 = status >= 500 && 503 !== status;
2026-07-20 16:05:17 +00:00
}
tmp = tmp2;
2026-07-20 16:05:17 +00:00
}
return tmp;
2026-07-20 16:05:17 +00:00
}
},
staleAfter: 3600,
failureStaleAfter: 60
2026-10-03 08:58:59 +00:00
};
const fetchStore = get_initialized.createFetchStore(GameAutocompleteStore, obj);
let ReactCompilerGating = ReactCompilerGating_mod;
2026-10-08 09:57:35 +00:00
let closure_7 = ReactCompilerGating.isReactCompilerEnabled() ? (function useDebouncedQueryValue(arg0) {
2026-10-03 08:58:59 +00:00
let closure_129_1;
let tmp3;
let tmp4;
let tmp5;
let closure_0 = arg0;
const obj = react2;
const cResult = obj.c(3);
[tmp3, closure_129_1] = _slicedToArray(react.useState(arg0), 2);
const tmp2 = _slicedToArray(react.useState(arg0), 2);
let closure_2 = react.useRef(tmp3);
let closure_3 = react.useRef(0);
const obj2 = react;
if (cResult[0] !== arg0) {
const fn = function n() {
let current;
if (current !== ref.current) {
if (null != current) {
if (null != ref.current) {
const _Date2 = Date;
function emit() {
ref2.current = Date.now();
ref.current = current;
closure_1_1(current);
}
const _Math = Math;
const _Math2 = Math;
const _setTimeout = setTimeout;
current = setTimeout(emit, Math.min(200, Math.max(0, 500 - (Date.now() - ref2.current))));
return () => {
clearTimeout(current);
};
}
}
const _Date = Date;
ref2.current = Date.now();
ref.current = current;
closure_1(current);
}
};
const items = [arg0];
cResult[0] = arg0;
cResult[1] = fn;
cResult[2] = items;
tmp5 = items;
tmp4 = fn;
} else {
tmp4 = cResult[1];
tmp5 = cResult[2];
}
2026-10-03 08:58:59 +00:00
const effect = obj2.useEffect(tmp4, tmp5);
return tmp3;
2026-10-08 09:57:35 +00:00
}) : (function useDebouncedQueryValue(arg0) {
2026-10-03 08:58:59 +00:00
let closure_129_1;
let tmp2;
let closure_0 = arg0;
const tmp = _slicedToArray(react.useState(arg0), 2);
[tmp2, closure_129_1] = tmp;
let closure_2 = react.useRef(tmp2);
let closure_3 = react.useRef(0);
const items = [arg0];
const effect = react.useEffect(() => {
let current;
if (current !== ref.current) {
2026-10-03 08:58:59 +00:00
if (null != current) {
if (null != ref.current) {
2026-07-29 08:29:29 +00:00
const _Date2 = Date;
function emit() {
ref2.current = Date.now();
ref.current = current;
2026-10-03 08:58:59 +00:00
closure_1_1(current);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const _Math = Math;
const _Math2 = Math;
const _setTimeout = setTimeout;
current = setTimeout(emit, Math.min(200, Math.max(0, 500 - (Date.now() - ref2.current))));
2026-07-29 08:29:29 +00:00
return () => {
2026-10-03 08:58:59 +00:00
clearTimeout(current);
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
const _Date = Date;
ref2.current = Date.now();
2026-10-03 08:58:59 +00:00
ref.current = current;
closure_1(current);
2026-07-29 08:29:29 +00:00
}
}, items);
2026-10-03 08:58:59 +00:00
return tmp2;
});
ReactCompilerGating = ReactCompilerGating_mod;
2026-10-08 09:57:35 +00:00
let tmp4 = ReactCompilerGating.isReactCompilerEnabled() ? (function useDebouncedGameAutocomplete(name, surface) {
2026-10-06 11:16:32 +00:00
let closure_2;
2026-10-03 08:58:59 +00:00
let data;
2026-10-08 09:57:35 +00:00
let filterGroup;
2026-10-03 08:58:59 +00:00
let isLoading;
2026-10-06 11:16:32 +00:00
let query;
2026-10-03 08:58:59 +00:00
let tmp10;
2026-10-06 11:16:32 +00:00
let tmp11;
2026-10-03 08:58:59 +00:00
let tmp4;
2026-10-06 11:16:32 +00:00
let tmp = surface;
2026-10-08 09:57:35 +00:00
let tmp2 = filterGroup;
const obj = surface(filterGroup[8]);
2026-10-06 11:16:32 +00:00
const cResult = obj.c(27);
surface = surface.surface;
2026-10-08 09:57:35 +00:00
filterGroup = surface.filterGroup;
2026-10-06 11:16:32 +00:00
if (cResult[0] !== name) {
2026-10-08 09:57:35 +00:00
const tmpResult = tmp(tmp2[5]);
2026-10-06 11:16:32 +00:00
const result = tmpResult.normalizeGameAutocompleteQuery(name);
cResult[0] = name;
2026-10-03 08:58:59 +00:00
cResult[1] = result;
tmp4 = result;
} else {
tmp4 = cResult[1];
}
2026-10-06 11:16:32 +00:00
_slicedToArray = tmp4;
2026-10-03 08:58:59 +00:00
const tmp6 = closure_7(tmp4);
2026-10-08 09:57:35 +00:00
({ data, isLoading } = fetchStore(tmp6, filterGroup));
fetchStore(tmp6, filterGroup);
2026-10-06 11:16:32 +00:00
[tmp10, tmp11] = query.useState(null);
_slicedToArray(query.useState(null), 2);
const tmp8 = _slicedToArray;
if (cResult[2] === data) {
let tmp12;
if (cResult[3] === tmp6) {
tmp12 = cResult[4];
2026-07-20 16:05:17 +00:00
}
2026-10-06 11:16:32 +00:00
if (null == tmp4) {
if (null != tmp10) {
tmp11(null);
}
} else {
2026-10-08 09:57:35 +00:00
let tmp15 = null != tmp12;
if (tmp15) {
2026-10-06 11:16:32 +00:00
let results1;
const results = tmp12.results;
if (tmp10 != null) {
results1 = tmp10.results;
}
2026-10-08 09:57:35 +00:00
tmp15 = results !== results1;
2026-10-06 11:16:32 +00:00
}
2026-10-08 09:57:35 +00:00
if (tmp15) {
2026-10-06 11:16:32 +00:00
tmp11(tmp12);
}
2026-07-20 16:05:17 +00:00
}
2026-10-08 09:57:35 +00:00
let tmp19 = null;
2026-10-06 11:16:32 +00:00
if (null != tmp4) {
if (tmp12 == null) {
tmp12 = tmp10;
}
2026-10-08 09:57:35 +00:00
tmp19 = tmp12;
2026-07-20 16:05:17 +00:00
}
2026-10-06 11:16:32 +00:00
query = undefined;
2026-10-08 09:57:35 +00:00
if (tmp19 != null) {
query = tmp19.query;
2026-10-06 11:16:32 +00:00
}
if (query == null) {
query = null;
}
let results2;
2026-10-08 09:57:35 +00:00
if (tmp19 != null) {
results2 = tmp19.results;
2026-10-06 11:16:32 +00:00
}
if (results2 == null) {
results2 = null;
}
2026-10-08 09:57:35 +00:00
if (cResult[5] === filterGroup) {
let tmp22;
2026-10-06 11:16:32 +00:00
if (cResult[6] === surface) {
2026-10-08 09:57:35 +00:00
tmp22 = cResult[7];
2026-10-06 11:16:32 +00:00
}
2026-10-08 09:57:35 +00:00
const first = tmp8(obj3.useState(tmp22), 1)[0];
2026-10-06 11:16:32 +00:00
if (cResult[8] === tmp4) {
let tmp24;
2026-10-08 09:57:35 +00:00
let tmp25;
2026-10-06 11:16:32 +00:00
if (cResult[9] === first) {
2026-10-08 09:57:35 +00:00
tmp24 = cResult[10];
tmp25 = cResult[11];
2026-10-06 11:16:32 +00:00
}
2026-10-08 09:57:35 +00:00
const effect = obj3.useEffect(tmp24, tmp25);
2026-10-06 11:16:32 +00:00
if (cResult[12] === query) {
if (cResult[13] === results2) {
let tmp27;
2026-10-08 09:57:35 +00:00
let tmp28;
let tmp30;
2026-10-06 11:16:32 +00:00
if (cResult[14] === first) {
2026-10-08 09:57:35 +00:00
tmp27 = cResult[15];
tmp28 = cResult[16];
2026-10-06 11:16:32 +00:00
}
2026-10-08 09:57:35 +00:00
const effect1 = obj3.useEffect(tmp27, tmp28);
2026-10-06 11:16:32 +00:00
if (cResult[17] !== first.end) {
2026-10-08 09:57:35 +00:00
class P {
constructor() {
return first.end;
}
}
2026-10-06 11:16:32 +00:00
cResult[17] = first.end;
2026-10-08 09:57:35 +00:00
class U {
2026-10-06 11:16:32 +00:00
constructor() {
let tmp2 = null != query;
const tmp = query;
if (tmp2) {
tmp2 = null != results2;
}
if (tmp2) {
first.onResults(tmp, results2);
}
}
}
2026-10-08 09:57:35 +00:00
cResult[18] = P;
tmp30 = P;
2026-10-06 11:16:32 +00:00
} else {
2026-10-08 09:57:35 +00:00
class P {
constructor() {
return first.end;
}
}
2026-10-06 11:16:32 +00:00
}
2026-10-08 09:57:35 +00:00
class U {
2026-10-06 11:16:32 +00:00
constructor() {
let tmp2 = null != query;
const tmp = query;
if (tmp2) {
tmp2 = null != results2;
}
if (tmp2) {
first.onResults(tmp, results2);
}
}
}
2026-10-08 09:57:35 +00:00
const effect2 = obj3.useEffect(tmp30, tmp31);
2026-10-06 11:16:32 +00:00
if (!isLoading) {
2026-10-08 09:57:35 +00:00
class P {
constructor() {
return first.end;
}
}
2026-10-06 11:16:32 +00:00
}
if (tmp6 === tmp4) {
2026-10-08 09:57:35 +00:00
class P {
constructor() {
return first.end;
}
}
2026-10-06 11:16:32 +00:00
}
if (cResult[21] === results2) {
2026-10-08 09:57:35 +00:00
class P {
constructor() {
return first.end;
2026-10-06 11:16:32 +00:00
}
}
}
2026-10-08 09:57:35 +00:00
const obj2 = { results: results2, isLoading, error: null, onSelect: null, endSession: first.end };
class O {
2026-10-06 11:16:32 +00:00
constructor() {
2026-10-08 09:57:35 +00:00
const gameSearchSession = new GameSearchSession.GameSearchSession(surface, filterGroup);
2026-10-06 11:16:32 +00:00
return gameSearchSession;
}
}
cResult[21] = results2;
cResult[22] = first.end;
cResult[23] = first.select;
cResult[24] = isLoading;
2026-10-08 09:57:35 +00:00
cResult[25] = null;
2026-10-06 11:16:32 +00:00
cResult[26] = obj2;
}
}
2026-10-08 09:57:35 +00:00
class U {
2026-10-06 11:16:32 +00:00
constructor() {
let tmp2 = null != query;
const tmp = query;
if (tmp2) {
tmp2 = null != results2;
}
if (tmp2) {
first.onResults(tmp, results2);
}
}
}
const items = [first, query, results2];
cResult[12] = query;
cResult[13] = results2;
2026-10-08 09:57:35 +00:00
class O {
2026-10-06 11:16:32 +00:00
constructor() {
2026-10-08 09:57:35 +00:00
const gameSearchSession = new GameSearchSession.GameSearchSession(surface, filterGroup);
2026-10-06 11:16:32 +00:00
return gameSearchSession;
}
}
2026-10-08 09:57:35 +00:00
cResult[15] = U;
2026-10-06 11:16:32 +00:00
cResult[16] = items;
2026-10-08 09:57:35 +00:00
tmp28 = items;
tmp27 = U;
2026-10-06 11:16:32 +00:00
}
2026-10-08 09:57:35 +00:00
const fn = function w() {
2026-10-06 11:16:32 +00:00
first.onQuery(closure_2);
};
const items1 = [first, tmp4];
cResult[8] = tmp4;
cResult[9] = first;
2026-10-08 09:57:35 +00:00
class O {
2026-10-06 11:16:32 +00:00
constructor() {
2026-10-08 09:57:35 +00:00
const gameSearchSession = new GameSearchSession.GameSearchSession(surface, filterGroup);
2026-10-06 11:16:32 +00:00
return gameSearchSession;
}
}
cResult[10] = fn;
cResult[11] = items1;
2026-10-08 09:57:35 +00:00
tmp25 = items1;
tmp24 = fn;
2026-10-06 11:16:32 +00:00
}
2026-10-08 09:57:35 +00:00
class O {
2026-10-06 11:16:32 +00:00
constructor() {
2026-10-08 09:57:35 +00:00
const gameSearchSession = new GameSearchSession.GameSearchSession(surface, filterGroup);
2026-10-06 11:16:32 +00:00
return gameSearchSession;
}
}
2026-10-08 09:57:35 +00:00
cResult[5] = filterGroup;
2026-10-06 11:16:32 +00:00
cResult[6] = surface;
2026-10-08 09:57:35 +00:00
cResult[7] = O;
tmp22 = O;
2026-10-03 08:58:59 +00:00
}
2026-10-06 11:16:32 +00:00
if (null != data) {
2026-10-08 09:57:35 +00:00
class P {
constructor() {
return first.end;
}
}
2026-10-06 11:16:32 +00:00
if (null != tmp6) {
2026-10-08 09:57:35 +00:00
class P {
constructor() {
return first.end;
}
}
tmp14[0] = tmp6;
tmp14[1] = data;
class U {
2026-10-06 11:16:32 +00:00
constructor() {
let tmp2 = null != query;
const tmp = query;
if (tmp2) {
tmp2 = null != results2;
}
if (tmp2) {
first.onResults(tmp, results2);
}
}
2026-10-03 08:58:59 +00:00
}
}
}
2026-10-06 11:16:32 +00:00
cResult[2] = data;
cResult[3] = tmp6;
2026-10-08 09:57:35 +00:00
cResult[4] = null;
2026-10-06 11:16:32 +00:00
tmp12 = tmp13;
2026-10-08 09:57:35 +00:00
}) : (function useDebouncedGameAutocomplete(name, arg1) {
2026-10-06 11:16:32 +00:00
let c2;
2026-10-03 08:58:59 +00:00
let data;
2026-10-08 09:57:35 +00:00
let filterGroup;
2026-10-03 08:58:59 +00:00
let isLoading;
2026-10-06 11:16:32 +00:00
let require;
2026-10-08 09:57:35 +00:00
let tmp20;
let tmp6;
let tmp7;
({ surface: require, filterGroup } = arg1);
2026-10-06 11:16:32 +00:00
let query;
let results2;
let first;
const obj = require("GameAutocompleteUtils");
const result = obj.normalizeGameAutocompleteQuery(name);
_slicedToArray = result;
2026-10-08 09:57:35 +00:00
let tmp2 = closure_7(result);
const tmp3 = fetchStore(tmp2, filterGroup);
({ data, isLoading } = tmp3);
const error = tmp3.error;
[tmp6, tmp7] = _slicedToArray(query.useState(null), 2);
let tmp8 = null;
const tmp4 = _slicedToArray;
const tmp5 = _slicedToArray(query.useState(null), 2);
2026-10-06 11:16:32 +00:00
if (null != data) {
2026-10-08 09:57:35 +00:00
tmp8 = null;
if (null != tmp2) {
tmp8 = { query: tmp2, results: data };
const obj3 = { query: tmp2, results: data };
2026-10-06 11:16:32 +00:00
}
}
2026-10-03 08:58:59 +00:00
if (null == result) {
2026-10-08 09:57:35 +00:00
if (null != tmp6) {
tmp7(null);
2026-10-03 08:58:59 +00:00
}
} else {
2026-10-08 09:57:35 +00:00
let tmp9 = null != tmp8;
if (tmp9) {
2026-10-06 11:16:32 +00:00
let results1;
2026-10-08 09:57:35 +00:00
const results = tmp8.results;
if (tmp6 != null) {
results1 = tmp6.results;
2026-10-06 11:16:32 +00:00
}
2026-10-08 09:57:35 +00:00
tmp9 = results !== results1;
2026-10-06 11:16:32 +00:00
}
2026-10-08 09:57:35 +00:00
if (tmp9) {
tmp7(tmp8);
2026-10-03 08:58:59 +00:00
}
}
2026-10-08 09:57:35 +00:00
let tmp13 = null;
2026-10-03 08:58:59 +00:00
if (null != result) {
2026-10-08 09:57:35 +00:00
if (tmp8 == null) {
tmp8 = tmp6;
2026-10-03 08:58:59 +00:00
}
2026-10-08 09:57:35 +00:00
tmp13 = tmp8;
2026-10-03 08:58:59 +00:00
}
2026-10-06 11:16:32 +00:00
query = undefined;
2026-10-08 09:57:35 +00:00
if (tmp13 != null) {
query = tmp13.query;
2026-10-06 11:16:32 +00:00
}
if (query == null) {
query = null;
}
results2 = undefined;
2026-10-08 09:57:35 +00:00
if (tmp13 != null) {
results2 = tmp13.results;
2026-10-06 11:16:32 +00:00
}
if (results2 == null) {
results2 = null;
}
2026-10-08 09:57:35 +00:00
first = tmp4(obj2.useState(() => {
const gameSearchSession = new GameSearchSession.GameSearchSession(_require, filterGroup);
2026-10-06 11:16:32 +00:00
return gameSearchSession;
}), 1)[0];
const items = [first, result];
const effect = obj2.useEffect(() => {
first.onQuery(c2);
}, items);
const items1 = [first, query, results2];
const effect1 = obj2.useEffect(() => {
let tmp2 = null != query;
const tmp = query;
if (tmp2) {
tmp2 = null != results2;
}
if (tmp2) {
first.onResults(tmp, results2);
}
}, items1);
const items2 = [first];
const effect2 = obj2.useEffect(() => first.end, items2);
2026-10-08 09:57:35 +00:00
const obj6 = { results: results2, isLoading, error: tmp20, onSelect: null, endSession: null };
2026-10-03 08:58:59 +00:00
if (!isLoading) {
2026-10-08 09:57:35 +00:00
isLoading = tmp2 !== result;
2026-07-20 16:05:17 +00:00
}
2026-10-08 09:57:35 +00:00
tmp20 = null;
if (tmp2 === result) {
tmp20 = error;
2026-07-20 16:05:17 +00:00
}
2026-10-06 11:16:32 +00:00
({ select: obj4.onSelect, end: obj4.endSession } = first);
return obj6;
2026-10-03 08:58:59 +00:00
});
let result = size.fileFinishedImporting("modules/games/autocomplete/useGameAutocomplete.tsx");
export const GAME_AUTOCOMPLETE_DEBOUNCE_MS = 200;
export const GAME_AUTOCOMPLETE_DEBOUNCE_MAX_WAIT_MS = 500;
export const useGameAutocomplete = fetchStore;
export const useDebouncedGameAutocomplete = tmp4;