// Metro module 16651 (f16652). import { ContentInventoryFeedKey } from "./ContentInventoryConstants"; import { Endpoints } from "../../Constants"; import { HTTP, rejectWithMigratedError } from "../../_bundle/sendRequest"; import { APIError } from "../../errors/index"; import Dispatcher from "../../Dispatcher"; import { intl, t } from "../../intl/index.native"; export async function getMyContentInventory(c28484_0) { let r98; let c28484_3; let c28484_4 = 0; let c31091_0, c31091_1, c31091_2, c31091_3, c31091_4, c31091_5, c31091_6; try { c31091_0 = void 0; c31091_1 = void 0; c31091_2 = void 0; c31091_0 = c28484_0.token; c31091_1 = c28484_0.feedId; c31091_2 = c28484_0.feature; c31091_3 = void 0; c31091_4 = void 0; c31091_5 = void 0; await void 0; c28484_4 = 1; c31091_3 = (await HTTP.get({ url: Endpoints.MY_CONTENT_INVENTORY(c31091_0), query: { for_game_profile: c31091_1 === ContentInventoryFeedKey.GAME_PROFILE_FEED, feature: c31091_2 }, rejectWithError: rejectWithMigratedError() })).body; c31091_4 = c31091_3.wait_ms_until_next_fetch; if (c31091_4 != null) { c31091_5 = new Date(Date.now() + c31091_4); c31091_3.expired_at = c31091_5.toISOString(); } r98 = c31091_3; c28484_4 = 0; } catch ($e) { const r32 = $e; let r8 = r32; c28484_3 = r32; if (c28484_4 !== 0) { while (true) { try { const r120 = c28484_3; c28484_4 = 0; c31091_6 = r120; throw new APIError(c31091_6); } catch (r116) { r8 = r116; c28484_3 = r116; if (c28484_4 === 0) { break; } } } } throw r8; } return r98; } export async function getContentInventoryOutbox(userId, signal) { let r77; let c28485_4; let c28485_5 = 0; let c31092_0, c31092_1, c31092_2; try { c31092_0 = userId; c31092_1 = void 0; c28485_5 = 1; Dispatcher.dispatch({ type: "CONTENT_INVENTORY_FETCH_OUTBOX_START", userId }); c31092_1 = (await HTTP.get({ url: Endpoints.CONTENT_INVENTORY_OUTBOX(userId), signal, rejectWithError: rejectWithMigratedError() })).body; Dispatcher.dispatch({ type: "CONTENT_INVENTORY_FETCH_OUTBOX_SUCCESS", outbox: c31092_1, userId: c31092_0 }); r77 = c31092_1; c28485_5 = 0; } catch ($e) { const r27 = $e; let r8 = r27; c28485_4 = r27; if (c28485_5 !== 0) { while (true) { try { const r86 = c28485_4; c28485_5 = 0; c31092_2 = r86; Dispatcher.dispatch({ type: "CONTENT_INVENTORY_FETCH_OUTBOX_FAILURE", userId: c31092_0 }); throw new APIError(c31092_2); } catch (r82) { r8 = r82; c28485_4 = r82; if (c28485_5 === 0) { break; } } } } throw r8; } return r77; } export async function deleteContentInventoryEntryHistory(c28486_0, c28486_1, c28486_2) { let message, c28486_6; let c28486_7 = 0; let c31093_0, c31093_1, c31093_2, c31093_3; L12: { try { c31093_0 = c28486_0; c31093_1 = c28486_1; c31093_2 = c28486_2; c31093_3 = void 0; c28486_7 = 1; Dispatcher.dispatch({ type: "CONTENT_INVENTORY_DELETE_OUTBOX_ENTRY_START" }); await HTTP.del({ url: Endpoints.DELETE_MY_CONTENT_INVENTORY_OUTBOX_ENTRY_HISTORY(c28486_0.id), rejectWithError: rejectWithMigratedError() }); Dispatcher.dispatch({ type: "CONTENT_INVENTORY_DELETE_OUTBOX_ENTRY_SUCCESS", userId: c31093_1, entry: c31093_0 }); const r79 = c31093_2; if (r79 != null) { r79(); } c28486_7 = 0; } catch ($e) { const r26 = $e; let r8 = r26; c28486_6 = r26; if (c28486_7 !== 0) { while (true) { try { const r87 = c28486_6; c28486_7 = 0; message = r87 == null ? void 0 : r87.body?.message; if (message == null) { message = intl.string(t.FMbL3s); } c31093_3 = message; Dispatcher.dispatch({ type: "CONTENT_INVENTORY_DELETE_OUTBOX_ENTRY_FAILURE", error: c31093_3 }); break L12; } catch (r85) { r8 = r85; c28486_6 = r85; if (c28486_7 === 0) { break; } } } } throw r8; } } } export async function postTrackToContentInventory(connection_id, c28487_1) { let c28487_4; let c28487_5 = 0; let c31094_0; try { c28487_5 = 1; await HTTP.post({ url: Endpoints.MY_SPOTIFY_CONTENT_INVENTORY, body: { connection_id, tracks: [c28487_1] }, rejectWithError: rejectWithMigratedError() }); c28487_5 = 0; } catch ($e) { const r26 = $e; let r8 = r26; c28487_4 = r26; if (c28487_5 !== 0) { while (true) { try { const r67 = c28487_4; c28487_5 = 0; c31094_0 = r67; throw new APIError(c31094_0); } catch (r63) { r8 = r63; c28487_4 = r63; if (c28487_5 === 0) { break; } } } } throw r8; } }