async function n(e){if(!e.ok){const t=await e.json();throw Error(t.error)}return await e.json()}async function o(e){const t=await fetch(`/apis/web/v1/listens?period=${e.period}&limit=${e.limit}&artist_id=${e.artist_id}&album_id=${e.album_id}&track_id=${e.track_id}&page=${e.page}`);return n(t)}async function c(e){let t=`/apis/web/v1/top-tracks?period=${e.period}&limit=${e.limit}&page=${e.page}`;e.artist_id?t+=`&artist_id=${e.artist_id}`:e.album_id&&(t+=`&album_id=${e.album_id}`);const a=await fetch(t);return n(a)}async function d(e){let t=`/apis/web/v1/top-albums?period=${e.period}&limit=${e.limit}&page=${e.page}`;e.artist_id&&(t+=`&artist_id=${e.artist_id}`);const a=await fetch(t);return n(a)}async function p(e){const t=`/apis/web/v1/top-artists?period=${e.period}&limit=${e.limit}&page=${e.page}`,a=await fetch(t);return n(a)}async function u(e){const t=await fetch(`/apis/web/v1/listen-activity?step=${e.step}&range=${e.range}&month=${e.month}&year=${e.year}&album_id=${e.album_id}&artist_id=${e.artist_id}&track_id=${e.track_id}`);return n(t)}async function m(e){const t=await fetch(`/apis/web/v1/interest?buckets=${e.buckets}&album_id=${e.album_id}&artist_id=${e.artist_id}&track_id=${e.track_id}`);return n(t)}async function f(e){const t=await fetch(`/apis/web/v1/stats?period=${e}`);return n(t)}function h(e){return e=encodeURIComponent(e),fetch(`/apis/web/v1/search?q=${e}`).then(t=>t.json())}function l(e,t){return e||(e="default"),`/images/${t}/${e}`}function b(e){return fetch("/apis/web/v1/replace-image",{method:"POST",body:e})}function w(e,t){return fetch(`/apis/web/v1/merge/tracks?from_id=${e}&to_id=${t}`,{method:"POST"})}function $(e,t,a){return fetch(`/apis/web/v1/merge/albums?from_id=${e}&to_id=${t}&replace_image=${a}`,{method:"POST"})}function _(e,t,a){return fetch(`/apis/web/v1/merge/artists?from_id=${e}&to_id=${t}&replace_image=${a}`,{method:"POST"})}function y(e,t,a){const i=new URLSearchParams;return i.append("username",e),i.append("password",t),i.append("remember_me",String(a)),fetch("/apis/web/v1/login",{method:"POST",body:i})}function v(){return fetch("/apis/web/v1/logout",{method:"POST"})}function g(){return fetch("/apis/web/v1/config").then(e=>e.json())}function S(e,t){const a=new URLSearchParams;a.append("track_id",e);const i=new Date(t).getTime(),s=Math.floor(i/1e3);return a.append("unix",s.toString()),fetch("/apis/web/v1/listen",{method:"POST",body:a})}function P(){return fetch("/apis/web/v1/user/apikeys").then(e=>e.json())}const T=async e=>{const t=new URLSearchParams;t.append("label",e);const a=await fetch("/apis/web/v1/user/apikeys",{method:"POST",body:t});if(!a.ok){let s=`error: ${a.status}`;try{const r=await a.json();r&&typeof r.error=="string"&&(s=r.error)}catch(r){console.error("unexpected api error:",r)}throw new Error(s)}return await a.json()};function k(e){return fetch(`/apis/web/v1/user/apikeys?id=${e}`,{method:"DELETE"})}function A(e,t){return fetch(`/apis/web/v1/${e}?id=${t}`,{method:"DELETE"})}function L(e,t){const a=new URLSearchParams;return a.append("username",e),a.append("password",t),fetch("/apis/web/v1/user",{method:"PATCH",body:a})}function j(e,t){return fetch(`/apis/web/v1/aliases?${e}_id=${t}`).then(a=>a.json())}function E(e,t,a){const i=new URLSearchParams;return i.append(`${e}_id`,String(t)),i.append("alias",a),fetch("/apis/web/v1/aliases",{method:"POST",body:i})}function O(e,t,a){const i=new URLSearchParams;return i.append(`${e}_id`,String(t)),i.append("alias",a),fetch("/apis/web/v1/aliases/delete",{method:"POST",body:i})}function U(e,t,a){const i=new URLSearchParams;return i.append(`${e}_id`,String(t)),i.append("alias",a),fetch("/apis/web/v1/aliases/primary",{method:"POST",body:i})}function R(e,t,a){const i=new URLSearchParams;return i.append(`${e}_id`,String(t)),i.append("mbz_id",a),fetch("/apis/web/v1/mbzid",{method:"PATCH",body:i})}function x(e){return fetch(`/apis/web/v1/album?id=${e}`).then(t=>t.json())}function D(e){const t=new Date(e.time).getTime(),a=Math.floor(t/1e3);return fetch(`/apis/web/v1/listen?track_id=${e.track.id}&unix=${a}`,{method:"DELETE"})}function C(){return fetch("/apis/web/v1/now-playing").then(e=>e.json())}export{u as A,o as B,C,g as D,v as a,d as b,T as c,k as d,$ as e,w as f,P as g,A as h,l as i,U as j,E as k,y as l,_ as m,O as n,j as o,x as p,R as q,b as r,h as s,S as t,L as u,m as v,D as w,f as x,p as y,c as z};
