import{t as e}from"./api-CtGubvBp.js";import{n as t}from"./format-fastapi-error-w24qoYO4.js";function n(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.has_token==`boolean`&&(typeof t.token==`string`||t.token===null)}async function r(e){let r=await e.json().catch(()=>null);if(!e.ok){let n=r&&`detail`in r?t(r.detail):null;throw Error(n||`Hugging Face credential request failed (${e.status})`)}if(!n(r))throw Error(`Hugging Face credential request returned an invalid response`);return r}async function i(){return r(await e(`/api/settings/hugging-face-token`))}async function a(t){return r(await e(`/api/settings/hugging-face-token`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:t})}))}async function o(t){return r(await e(`/api/settings/hugging-face-token/migrate`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:t})}))}async function s(){return r(await e(`/api/settings/hugging-face-token`,{method:`DELETE`}))}export{s as clearSavedHfToken,i as loadSavedHfToken,o as migrateHfToken,a as saveHfToken};