!function(){try{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"f5a30ae5c234d85a55bf5a5818b0d80fd7936e7b"}}catch(e){}}();try{e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},(t=(new e.Error).stack)&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="92b57e50-9abd-433c-9f7c-513b21006d6d",e._sentryDebugIdIdentifier="sentry-dbid-92b57e50-9abd-433c-9f7c-513b21006d6d")}catch(e){}var e,t;import{j as o,f as s,b as r}from"./index.BrQ1AneF.js";const a=new class{getUrl(e=""){return o(`/api/v1/admin/history${e}`)}async createHistoryEntry(e){const t=e.outputAssets.map(e=>e.url),o=await s(this.getUrl(),{method:"POST",headers:r(),body:JSON.stringify({prompt:e.prompt,negative_prompt:e.negativePrompt||"",model_version:e.modelVersion,parameters:e.parameters,images:t,cost_estimate:e.costEstimate||0})});if(!o.ok){if(409===o.status)return e;if(401===o.status)throw localStorage.removeItem("access_token"),new Error("Your session has expired. Please log in again.");const t=await o.json().catch(()=>({}));throw new Error(t.detail||"Failed to save history entry")}const a=await o.json();return a.success?a.data:a}async getHistory(e=100,t=0){const o=`${this.getUrl()}?limit=${e}&offset=${t}`,a=await s(o,{method:"GET",headers:r()});if(!a.ok){if(401===a.status)throw localStorage.removeItem("access_token"),new Error("Your session has expired. Please log in again.");throw new Error("Failed to fetch history")}const n=await a.json();return n.success&&n.data?n.data:n}async getHistoryItem(e){const t=await s(this.getUrl(`/${e}`),{method:"GET",headers:r()});if(!t.ok){if(404===t.status)throw new Error("History entry not found");if(401===t.status)throw localStorage.removeItem("access_token"),new Error("Your session has expired. Please log in again.");throw new Error("Failed to fetch history entry")}const o=await t.json();return o.success?o.data:o}async deleteHistoryItem(e){const t=await s(this.getUrl(`/${e}`),{method:"DELETE",headers:r()});if(!t.ok){if(404===t.status)throw new Error("History entry not found");if(401===t.status)throw localStorage.removeItem("access_token"),new Error("Your session has expired. Please log in again.");throw new Error("Failed to delete history entry")}}async clearHistory(){const e=await s(this.getUrl(),{method:"DELETE",headers:r()});if(!e.ok){if(401===e.status)throw localStorage.removeItem("access_token"),new Error("Your session has expired. Please log in again.");throw new Error("Failed to clear history")}}};export{a as historyService};
//# sourceMappingURL=historyService.Deyj14CB.js.map
