javascript-ampache 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/albums/index.d.ts +7 -13
  2. package/dist/albums/types.d.ts +9 -4
  3. package/dist/artists/index.d.ts +8 -14
  4. package/dist/artists/types.d.ts +10 -5
  5. package/dist/auth/index.d.ts +1 -1
  6. package/dist/bookmarks/index.d.ts +20 -21
  7. package/dist/bookmarks/types.d.ts +7 -2
  8. package/dist/catalogs/index.d.ts +9 -11
  9. package/dist/catalogs/types.d.ts +8 -3
  10. package/dist/genres/index.d.ts +4 -6
  11. package/dist/genres/types.d.ts +6 -1
  12. package/dist/index.d.ts +19 -19
  13. package/dist/index.js +1 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.m.js +1 -1
  16. package/dist/index.m.js.map +1 -1
  17. package/dist/index.modern.mjs +1 -1
  18. package/dist/index.modern.mjs.map +1 -1
  19. package/dist/index.umd.js +1 -1
  20. package/dist/index.umd.js.map +1 -1
  21. package/dist/labels/index.d.ts +4 -6
  22. package/dist/labels/types.d.ts +6 -1
  23. package/dist/licenses/index.d.ts +4 -6
  24. package/dist/licenses/types.d.ts +6 -1
  25. package/dist/live-streams/index.d.ts +8 -10
  26. package/dist/live-streams/types.d.ts +6 -1
  27. package/dist/playlists/index.d.ts +15 -25
  28. package/dist/playlists/types.d.ts +7 -2
  29. package/dist/podcasts/index.d.ts +10 -16
  30. package/dist/podcasts/types.d.ts +20 -5
  31. package/dist/preferences/index.d.ts +8 -16
  32. package/dist/preferences/types.d.ts +6 -1
  33. package/dist/shares/index.d.ts +7 -9
  34. package/dist/shares/types.d.ts +6 -1
  35. package/dist/shouts/index.d.ts +4 -4
  36. package/dist/shouts/types.d.ts +1 -1
  37. package/dist/songs/index.d.ts +12 -28
  38. package/dist/songs/types.d.ts +12 -2
  39. package/dist/system/index.d.ts +24 -24
  40. package/dist/system/types.d.ts +9 -9
  41. package/dist/users/index.d.ts +10 -10
  42. package/dist/users/types.d.ts +7 -2
  43. package/dist/videos/index.d.ts +5 -9
  44. package/dist/videos/types.d.ts +12 -2
  45. package/package.json +1 -1
  46. package/src/bookmarks/index.ts +2 -1
  47. package/src/playlists/index.ts +1 -3
@@ -1,5 +1,5 @@
1
- import { Album } from './types';
2
- import { Base, BinaryBoolean, ExtendedPagination, UID } from '../base';
1
+ import { AlbumResponse, AlbumsResponse } from "./types";
2
+ import { Base, BinaryBoolean, ExtendedPagination, UID } from "../base";
3
3
  export declare class Albums extends Base {
4
4
  /**
5
5
  * This returns albums based on the provided search filters
@@ -21,9 +21,7 @@ export declare class Albums extends Base {
21
21
  add?: Date;
22
22
  update?: Date;
23
23
  include?: "albums" | "songs";
24
- } & ExtendedPagination): Promise<Album[] | {
25
- album: Album[];
26
- }>;
24
+ } & ExtendedPagination): Promise<AlbumsResponse>;
27
25
  /**
28
26
  * This returns a single album based on the UID provided
29
27
  * @remarks MINIMUM_API_VERSION=380001
@@ -33,8 +31,8 @@ export declare class Albums extends Base {
33
31
  */
34
32
  album(params: {
35
33
  filter: UID;
36
- include?: 'songs';
37
- }): Promise<Album>;
34
+ include?: "songs";
35
+ }): Promise<AlbumResponse>;
38
36
  /**
39
37
  * This returns the albums of an artist
40
38
  * @remarks MINIMUM_API_VERSION=380001
@@ -47,9 +45,7 @@ export declare class Albums extends Base {
47
45
  */
48
46
  artistAlbums(params: {
49
47
  filter: UID;
50
- } & ExtendedPagination): Promise<Album[] | {
51
- album: Album[];
52
- }>;
48
+ } & ExtendedPagination): Promise<AlbumsResponse>;
53
49
  /**
54
50
  * This returns the albums associated with the genre in question
55
51
  * @remarks MINIMUM_API_VERSION=380001
@@ -62,7 +58,5 @@ export declare class Albums extends Base {
62
58
  */
63
59
  genreAlbums(params?: {
64
60
  filter: UID;
65
- } & ExtendedPagination): Promise<Album[] | {
66
- album: Album[];
67
- }>;
61
+ } & ExtendedPagination): Promise<AlbumsResponse>;
68
62
  }
@@ -1,14 +1,14 @@
1
- import { UID } from '../base';
1
+ import { UID } from "../base";
2
2
  import { GenreSummary } from "../genres/types";
3
3
  import { ArtistSummary } from "../artists/types";
4
- import { Song } from "../songs/types";
4
+ import { SongResponse } from "../songs/types";
5
5
  export type AlbumSummary = {
6
6
  id: UID;
7
7
  name: string;
8
8
  prefix: string | null;
9
9
  basename: string;
10
10
  };
11
- export type Album = {
11
+ export type AlbumResponse = {
12
12
  id: UID;
13
13
  name: string;
14
14
  prefix: string | null;
@@ -16,7 +16,7 @@ export type Album = {
16
16
  artist: ArtistSummary;
17
17
  time: number;
18
18
  year: number | string;
19
- tracks?: Song[];
19
+ tracks?: SongResponse[];
20
20
  songcount: number;
21
21
  disccount: number;
22
22
  type: string | null;
@@ -28,3 +28,8 @@ export type Album = {
28
28
  averagerating: number | null;
29
29
  mbid: string | null;
30
30
  };
31
+ export type AlbumsResponse = {
32
+ total_count: number;
33
+ md5: string;
34
+ album: AlbumResponse[];
35
+ };
@@ -1,5 +1,5 @@
1
- import { Artist } from './types';
2
- import { Base, BinaryBoolean, ExtendedPagination, UID } from '../base';
1
+ import { ArtistResponse, ArtistsResponse } from "./types";
2
+ import { Base, BinaryBoolean, ExtendedPagination, UID } from "../base";
3
3
  export declare class Artists extends Base {
4
4
  /**
5
5
  * This takes a collection of inputs and returns artist objects
@@ -21,11 +21,9 @@ export declare class Artists extends Base {
21
21
  exact?: BinaryBoolean;
22
22
  add?: Date;
23
23
  update?: Date;
24
- include?: 'albums' | 'songs';
24
+ include?: "albums" | "songs";
25
25
  album_artist?: BinaryBoolean;
26
- } & ExtendedPagination): Promise<Artist[] | {
27
- artist: Artist[];
28
- }>;
26
+ } & ExtendedPagination): Promise<ArtistsResponse>;
29
27
  /**
30
28
  * This returns a single artist based on the UID of said artist
31
29
  * @remarks MINIMUM_API_VERSION=380001
@@ -35,8 +33,8 @@ export declare class Artists extends Base {
35
33
  */
36
34
  artist(params: {
37
35
  filter: UID;
38
- include?: 'albums' | 'songs';
39
- }): Promise<Artist>;
36
+ include?: "albums" | "songs";
37
+ }): Promise<ArtistResponse>;
40
38
  /**
41
39
  * This returns the artists associated with the genre in question as defined by the UID
42
40
  * @remarks MINIMUM_API_VERSION=380001
@@ -49,9 +47,7 @@ export declare class Artists extends Base {
49
47
  */
50
48
  genreArtists(params: {
51
49
  filter: UID;
52
- } & ExtendedPagination): Promise<Artist[] | {
53
- artist: Artist[];
54
- }>;
50
+ } & ExtendedPagination): Promise<ArtistsResponse>;
55
51
  /**
56
52
  * This returns the artists associated with the label in question as defined by the UID
57
53
  * @remarks MINIMUM_API_VERSION=420000
@@ -64,7 +60,5 @@ export declare class Artists extends Base {
64
60
  */
65
61
  labelArtists(params: {
66
62
  filter: UID;
67
- } & ExtendedPagination): Promise<Artist[] | {
68
- artist: Artist[];
69
- }>;
63
+ } & ExtendedPagination): Promise<ArtistsResponse>;
70
64
  }
@@ -1,22 +1,22 @@
1
- import { Album } from "../albums/types";
1
+ import { AlbumResponse } from "../albums/types";
2
2
  import { Song } from "../songs/types";
3
- import { Genre } from "../genres/types";
3
+ import { GenreResponse } from "../genres/types";
4
4
  export type ArtistSummary = {
5
5
  id: string;
6
6
  name: string;
7
7
  prefix: string | null;
8
8
  basename: string;
9
9
  };
10
- export type Artist = {
10
+ export type ArtistResponse = {
11
11
  id: string;
12
12
  name: string;
13
13
  prefix: string | null;
14
14
  basename: string;
15
- albums: Album[];
15
+ albums: AlbumResponse[];
16
16
  albumcount: number;
17
17
  songs: Song[];
18
18
  songcount: number;
19
- genre: Genre[];
19
+ genre: GenreResponse[];
20
20
  art: string;
21
21
  has_art: boolean;
22
22
  flag: boolean;
@@ -28,3 +28,8 @@ export type Artist = {
28
28
  yearformed: number;
29
29
  placeformed: string;
30
30
  };
31
+ export type ArtistsResponse = {
32
+ total_count: number;
33
+ md5: string;
34
+ artist: ArtistResponse[];
35
+ };
@@ -1,5 +1,5 @@
1
1
  import { Base, Success } from "../base";
2
- import { AuthResponse } from './types';
2
+ import { AuthResponse } from "./types";
3
3
  export declare class Auth extends Base {
4
4
  /**
5
5
  * Handles verifying a new handshake
@@ -1,5 +1,5 @@
1
- import { Bookmark } from './types';
2
- import { Base, BinaryBoolean, Success, UID } from '../base';
1
+ import { BookmarkResponse, BookmarksResponse } from "./types";
2
+ import { Base, BinaryBoolean, Success, UID } from "../base";
3
3
  export declare class Bookmarks extends Base {
4
4
  /**
5
5
  * Get a single bookmark by bookmark_id
@@ -11,7 +11,7 @@ export declare class Bookmarks extends Base {
11
11
  bookmark(params: {
12
12
  filter: UID;
13
13
  include?: BinaryBoolean;
14
- }): Promise<Bookmark>;
14
+ }): Promise<BookmarkResponse>;
15
15
  /**
16
16
  * Get information about bookmarked media this user is allowed to manage
17
17
  * @remarks MINIMUM_API_VERSION=5.0.0
@@ -22,11 +22,9 @@ export declare class Bookmarks extends Base {
22
22
  bookmarks(params: {
23
23
  client?: string;
24
24
  include?: BinaryBoolean;
25
- }): Promise<Bookmark[] | {
26
- bookmark: Bookmark[];
27
- }>;
25
+ }): Promise<BookmarksResponse>;
28
26
  /**
29
- * Get the bookmark from its object_id and object_type.
27
+ * Get the bookmark/s from its object_id and object_type.
30
28
  * @remarks MINIMUM_API_VERSION=5.0.0
31
29
  * @param params.filter UID to find
32
30
  * @param params.type Object type
@@ -35,9 +33,10 @@ export declare class Bookmarks extends Base {
35
33
  */
36
34
  getBookmark(params: {
37
35
  filter: UID;
38
- type: 'song' | 'video' | 'podcast_episode';
36
+ type: "song" | "video" | "podcast_episode";
39
37
  include?: BinaryBoolean;
40
- }): Promise<Bookmark>;
38
+ all?: BinaryBoolean;
39
+ }): Promise<BookmarkResponse>;
41
40
  /**
42
41
  * Create a placeholder for the current media that you can return to later.
43
42
  * @remarks MINIMUM_API_VERSION=5.0.0
@@ -51,12 +50,12 @@ export declare class Bookmarks extends Base {
51
50
  */
52
51
  bookmarkCreate(params: {
53
52
  filter: UID;
54
- type: 'song' | 'video' | 'podcast_episode';
53
+ type: "song" | "video" | "podcast_episode";
55
54
  position: number;
56
55
  client?: string;
57
56
  date?: number;
58
57
  include?: BinaryBoolean;
59
- }): Promise<Bookmark>;
58
+ }): Promise<BookmarkResponse>;
60
59
  /**
61
60
  * Edit a placeholder for the current media that you can return to later.
62
61
  * @remarks MINIMUM_API_VERSION=5.0.0
@@ -70,23 +69,23 @@ export declare class Bookmarks extends Base {
70
69
  */
71
70
  bookmarkEdit(params: {
72
71
  filter: UID;
73
- type: 'song' | 'video' | 'podcast_episode';
72
+ type: "song" | "video" | "podcast_episode";
74
73
  position: number;
75
74
  client?: string;
76
75
  date?: number;
77
76
  include?: BinaryBoolean;
78
- }): Promise<Bookmark>;
77
+ }): Promise<BookmarkResponse>;
79
78
  /**
80
- * Delete an existing bookmark. (if it exists)
81
- * @remarks MINIMUM_API_VERSION=5.0.0
82
- * @param params.filter UID to find
83
- * @param params.type Object type
84
- * @param [params.client] Agent string. (Default: 'AmpacheAPI')
85
- @see {@link https://ampache.org/api/api-json-methods#bookmark_delete}
86
- */
79
+ * Delete an existing bookmark. (if it exists)
80
+ * @remarks MINIMUM_API_VERSION=5.0.0
81
+ * @param params.filter UID to find
82
+ * @param params.type Object type
83
+ * @param [params.client] Agent string. (Default: 'AmpacheAPI')
84
+ @see {@link https://ampache.org/api/api-json-methods#bookmark_delete}
85
+ */
87
86
  bookmarkDelete(params: {
88
87
  filter: UID;
89
- type: 'song' | 'video' | 'podcast_episode';
88
+ type: "song" | "video" | "podcast_episode";
90
89
  client?: string;
91
90
  }): Promise<Success>;
92
91
  }
@@ -1,8 +1,13 @@
1
1
  import { UID } from "../base";
2
- export type Bookmark = {
2
+ export type BookmarkResponse = {
3
3
  id: UID;
4
- type: 'song' | 'video' | 'podcast_episode';
4
+ type: "song" | "video" | "podcast_episode";
5
5
  position: number;
6
6
  client?: string;
7
7
  date?: number;
8
8
  };
9
+ export type BookmarksResponse = {
10
+ total_count: number;
11
+ md5: string;
12
+ bookmark: BookmarkResponse[];
13
+ };
@@ -1,5 +1,5 @@
1
- import { Catalog } from './types';
2
- import { Base, ExtendedPagination, Success, UID } from '../base';
1
+ import { CatalogResponse, CatalogsResponse } from "./types";
2
+ import { Base, ExtendedPagination, Success, UID } from "../base";
3
3
  export declare class Catalogs extends Base {
4
4
  /**
5
5
  * This searches the catalogs and returns... catalogs
@@ -12,10 +12,8 @@ export declare class Catalogs extends Base {
12
12
  * @see {@link https://ampache.org/api/api-json-methods#catalogs}
13
13
  */
14
14
  catalogs(params?: {
15
- filter?: 'music' | 'clip' | 'tvshow' | 'movie' | 'personal_video' | 'podcast';
16
- } & ExtendedPagination): Promise<Catalog[] | {
17
- catalog: Catalog[];
18
- }>;
15
+ filter?: "music" | "clip" | "tvshow" | "movie" | "personal_video" | "podcast";
16
+ } & ExtendedPagination): Promise<CatalogsResponse>;
19
17
  /**
20
18
  * Return catalog by UID
21
19
  * @remarks MINIMUM_API_VERSION=420000
@@ -24,7 +22,7 @@ export declare class Catalogs extends Base {
24
22
  */
25
23
  catalog(params: {
26
24
  filter: UID;
27
- }): Promise<Catalog>;
25
+ }): Promise<CatalogResponse>;
28
26
  /**
29
27
  * Kick off a catalog update or clean for the selected catalog
30
28
  * ACCESS REQUIRED: 75 (Catalog Manager)
@@ -34,7 +32,7 @@ export declare class Catalogs extends Base {
34
32
  * @see {@link https://ampache.org/api/api-json-methods#catalog_action}
35
33
  */
36
34
  catalogAction(params: {
37
- task: 'add_to_catalog' | 'clean_catalog';
35
+ task: "add_to_catalog" | "clean_catalog";
38
36
  catalog: UID;
39
37
  }): Promise<Success>;
40
38
  /**
@@ -69,13 +67,13 @@ export declare class Catalogs extends Base {
69
67
  catalogAdd(params: {
70
68
  name: string;
71
69
  path: string;
72
- type?: 'local' | 'beets' | 'remote' | 'subsonic' | 'seafile' | 'beetsremote';
73
- media_type?: 'music' | 'podcast' | 'clip' | 'tvshow' | 'movie' | 'personal_video';
70
+ type?: "local" | "beets" | "remote" | "subsonic" | "seafile" | "beetsremote";
71
+ media_type?: "music" | "podcast" | "clip" | "tvshow" | "movie" | "personal_video";
74
72
  file_pattern?: string;
75
73
  folder_pattern?: string;
76
74
  username?: string;
77
75
  password?: string;
78
- }): Promise<Catalog>;
76
+ }): Promise<CatalogResponse>;
79
77
  /**
80
78
  * Delete an existing catalog. (if it exists)
81
79
  * ACCESS REQUIRED: 75 (Catalog Manager)
@@ -1,9 +1,9 @@
1
1
  import { UID } from "../base";
2
- export type Catalog = {
2
+ export type CatalogResponse = {
3
3
  id: UID;
4
4
  name: string;
5
- type: 'local' | 'remote';
6
- gather_types: 'podcast' | 'clip' | 'tvshow' | 'movie' | 'personal_video' | 'music';
5
+ type: "local" | "remote";
6
+ gather_types: "podcast" | "clip" | "tvshow" | "movie" | "personal_video" | "music";
7
7
  enabled: boolean;
8
8
  last_add: number;
9
9
  last_clean: number;
@@ -12,3 +12,8 @@ export type Catalog = {
12
12
  rename_pattern: string;
13
13
  sort_pattern: string;
14
14
  };
15
+ export type CatalogsResponse = {
16
+ total_count: number;
17
+ md5: string;
18
+ catalog: CatalogResponse[];
19
+ };
@@ -1,5 +1,5 @@
1
- import { Genre } from './types';
2
- import { Base, BinaryBoolean, ExtendedPagination, UID } from '../base';
1
+ import { GenreResponse, GenresResponse } from "./types";
2
+ import { Base, BinaryBoolean, ExtendedPagination, UID } from "../base";
3
3
  export declare class Genres extends Base {
4
4
  /**
5
5
  * This returns the genres (Tags) based on the specified filter
@@ -15,9 +15,7 @@ export declare class Genres extends Base {
15
15
  genres(params?: {
16
16
  filter?: string;
17
17
  exact?: BinaryBoolean;
18
- } & ExtendedPagination): Promise<Genre[] | {
19
- genre: Genre[];
20
- }>;
18
+ } & ExtendedPagination): Promise<GenresResponse>;
21
19
  /**
22
20
  * This returns a single genre based on UID
23
21
  * @remarks MINIMUM_API_VERSION=380001
@@ -26,5 +24,5 @@ export declare class Genres extends Base {
26
24
  */
27
25
  genre(params: {
28
26
  filter: UID;
29
- }): Promise<Genre>;
27
+ }): Promise<GenreResponse>;
30
28
  }
@@ -3,7 +3,7 @@ export type GenreSummary = {
3
3
  id: UID;
4
4
  name: string;
5
5
  };
6
- export type Genre = {
6
+ export type GenreResponse = {
7
7
  id: UID;
8
8
  name: string;
9
9
  albums: number;
@@ -13,3 +13,8 @@ export type Genre = {
13
13
  playlists: number;
14
14
  live_streams: number;
15
15
  };
16
+ export type GenresResponse = {
17
+ total_count: number;
18
+ md5: string;
19
+ genre: GenreResponse[];
20
+ };
package/dist/index.d.ts CHANGED
@@ -1,22 +1,22 @@
1
- import { Albums } from './albums';
2
- import { Artists } from './artists';
3
- import { Auth } from './auth';
4
- import { Bookmarks } from './bookmarks';
5
- import { Catalogs } from './catalogs';
6
- import { Genres } from './genres';
7
- import { Labels } from './labels';
8
- import { Licenses } from './licenses';
9
- import { LiveStreams } from './live-streams';
10
- import { Playlists } from './playlists';
11
- import { Podcasts } from './podcasts';
12
- import { Preferences } from './preferences';
13
- import { Shares } from './shares';
14
- import { Shouts } from './shouts';
15
- import { Songs } from './songs';
16
- import { System } from './system';
17
- import { Users } from './users';
18
- import { Videos } from './videos';
19
- import { Base } from './base';
1
+ import { Albums } from "./albums";
2
+ import { Artists } from "./artists";
3
+ import { Auth } from "./auth";
4
+ import { Bookmarks } from "./bookmarks";
5
+ import { Catalogs } from "./catalogs";
6
+ import { Genres } from "./genres";
7
+ import { Labels } from "./labels";
8
+ import { Licenses } from "./licenses";
9
+ import { LiveStreams } from "./live-streams";
10
+ import { Playlists } from "./playlists";
11
+ import { Podcasts } from "./podcasts";
12
+ import { Preferences } from "./preferences";
13
+ import { Shares } from "./shares";
14
+ import { Shouts } from "./shouts";
15
+ import { Songs } from "./songs";
16
+ import { System } from "./system";
17
+ import { Users } from "./users";
18
+ import { Videos } from "./videos";
19
+ import { Base } from "./base";
20
20
  declare class AmpacheAPI extends Base {
21
21
  }
22
22
  interface AmpacheAPI extends Albums, Artists, Auth, Bookmarks, Catalogs, Genres, Labels, Licenses, LiveStreams, Playlists, Podcasts, Preferences, Shares, Shouts, Songs, System, Users, Videos {
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- function e(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,t(e,r)}function t(e,r){return t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},t(e,r)}var r=Object.prototype.hasOwnProperty;function n(e){try{return encodeURIComponent(e)}catch(e){return null}}var s=function(e,t){t=t||"";var s,o,i=[];for(o in"string"!=typeof t&&(t="?"),e)if(r.call(e,o)){if((s=e[o])||null!=s&&!isNaN(s)||(s=""),o=n(o),s=n(s),null===o||null===s)continue;i.push(o+"="+s)}return i.length?t+i.join("&"):""},o={__proto__:null,default:function(e,t){return t=t||{},new Promise(function(r,n){var s=new XMLHttpRequest,o=[],i=[],u={},a=function(){return{ok:2==(s.status/100|0),statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:a,headers:{keys:function(){return o},entries:function(){return i},get:function(e){return u[e.toLowerCase()]},has:function(e){return e.toLowerCase()in u}}}};for(var c in s.open(t.method||"get",e,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,r){o.push(t=t.toLowerCase()),i.push([t,r]),u[t]=u[t]?u[t]+","+r:r}),r(a())},s.onerror=n,s.withCredentials="include"==t.credentials,t.headers)s.setRequestHeader(c,t.headers[c]);s.send(t.body||null)})}},i=self.fetch||(self.fetch=o.default||o),u=/*#__PURE__*/function(){function e(e){this.sessionKey=void 0,this.url=void 0,this.version="6.3.0",this.debug=void 0,this.sessionKey=e.sessionKey||null,this.url=e.url,this.debug=e.debug||!1}var t=e.prototype;return t.request=function(e){var t=this.url+"/server/json.server.php?action="+e+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+t+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),i(t,{method:"GET",headers:{Authorization:"Bearer "+this.sessionKey}}).then(function(e){if(e.ok)return e.json();throw new Error(e.statusText)})},t.binary=function(e){var t=this.url+"/server/json.server.php?action="+e+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+t+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),i(t,{method:"GET",headers:{Authorization:"Bearer "+this.sessionKey}}).then(function(e){return e.blob()}).then(function(e){return e})},t.setSessionKey=function(e){this.sessionKey=e},t.rawURL=function(e,t){var r=e;r+=s(t,"&");var n=this.url+"/server/json.server.php?action="+r+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+n+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),n},e}(),a=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.albums=function(e){try{var t="albums";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},n.album=function(e){var t="album";return t+=s(e,"&"),this.request(t)},n.artistAlbums=function(e){try{var t="artist_albums";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},n.genreAlbums=function(e){try{var t="genre_albums";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},r}(u),c=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.artists=function(e){try{var t="artists";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},n.artist=function(e){var t="artist";return t+=s(e,"&"),this.request(t)},n.genreArtists=function(e){try{var t="genre_artists";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},n.labelArtists=function(e){try{var t="label_artists";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},r}(u);const h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l="ARRAYBUFFER not supported by this environment",f="UINT8ARRAY not supported by this environment";function p(e,t,r,n){let s,o,i;const u=t||[0],a=(r=r||0)>>>3,c=-1===n?3:0;for(s=0;s<e.length;s+=1)i=s+a,o=i>>>2,u.length<=o&&u.push(0),u[o]|=e[s]<<8*(c+n*(i%4));return{value:u,binLen:8*e.length+r}}function v(e,t,r){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,n){return function(e,t,r,n){let s,o,i,u;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const a=t||[0],c=(r=r||0)>>>3,h=-1===n?3:0;for(s=0;s<e.length;s+=2){if(o=parseInt(e.substr(s,2),16),isNaN(o))throw new Error("String of HEX type contains invalid characters");for(u=(s>>>1)+c,i=u>>>2;a.length<=i;)a.push(0);a[i]|=o<<8*(h+n*(u%4))}return{value:a,binLen:4*e.length+r}}(e,t,n,r)};case"TEXT":return function(e,n,s){return function(e,t,r,n,s){let o,i,u,a,c,h,l,f,p=0;const v=r||[0],d=(n=n||0)>>>3;if("UTF8"===t)for(l=-1===s?3:0,u=0;u<e.length;u+=1)for(o=e.charCodeAt(u),i=[],128>o?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||57344<=o?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(u+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(u)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),a=0;a<i.length;a+=1){for(h=p+d,c=h>>>2;v.length<=c;)v.push(0);v[c]|=i[a]<<8*(l+s*(h%4)),p+=1}else for(l=-1===s?2:0,f="UTF16LE"===t&&1!==s||"UTF16LE"!==t&&1===s,u=0;u<e.length;u+=1){for(o=e.charCodeAt(u),!0===f&&(a=255&o,o=a<<8|o>>>8),h=p+d,c=h>>>2;v.length<=c;)v.push(0);v[c]|=o<<8*(l+s*(h%4)),p+=2}return{value:v,binLen:8*p+n}}(e,t,n,s,r)};case"B64":return function(e,t,n){return function(e,t,r,n){let s,o,i,u,a,c,l,f=0;const p=t||[0],v=(r=r||0)>>>3,d=-1===n?3:0,m=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==m&&m<e.length)throw new Error("Invalid '=' found in base-64 string");for(o=0;o<e.length;o+=4){for(a=e.substr(o,4),u=0,i=0;i<a.length;i+=1)s=h.indexOf(a.charAt(i)),u|=s<<18-6*i;for(i=0;i<a.length-1;i+=1){for(l=f+v,c=l>>>2;p.length<=c;)p.push(0);p[c]|=(u>>>16-8*i&255)<<8*(d+n*(l%4)),f+=1}}return{value:p,binLen:8*f+r}}(e,t,n,r)};case"BYTES":return function(e,t,n){return function(e,t,r,n){let s,o,i,u;const a=t||[0],c=(r=r||0)>>>3,h=-1===n?3:0;for(o=0;o<e.length;o+=1)s=e.charCodeAt(o),u=o+c,i=u>>>2,a.length<=i&&a.push(0),a[i]|=s<<8*(h+n*(u%4));return{value:a,binLen:8*e.length+r}}(e,t,n,r)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error(l)}return function(e,t,n){return function(e,t,r,n){return p(new Uint8Array(e),t,r,n)}(e,t,n,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error(f)}return function(e,t,n){return p(e,t,n,r)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function d(e,t,r,n){switch(e){case"HEX":return function(e){return function(e,t,r,n){const s="0123456789abcdef";let o,i,u="";const a=t/8,c=-1===r?3:0;for(o=0;o<a;o+=1)i=e[o>>>2]>>>8*(c+r*(o%4)),u+=s.charAt(i>>>4&15)+s.charAt(15&i);return n.outputUpper?u.toUpperCase():u}(e,t,r,n)};case"B64":return function(e){return function(e,t,r,n){let s,o,i,u,a,c="";const l=t/8,f=-1===r?3:0;for(s=0;s<l;s+=3)for(u=s+1<l?e[s+1>>>2]:0,a=s+2<l?e[s+2>>>2]:0,i=(e[s>>>2]>>>8*(f+r*(s%4))&255)<<16|(u>>>8*(f+r*((s+1)%4))&255)<<8|a>>>8*(f+r*((s+2)%4))&255,o=0;o<4;o+=1)c+=8*s+6*o<=t?h.charAt(i>>>6*(3-o)&63):n.b64Pad;return c}(e,t,r,n)};case"BYTES":return function(e){return function(e,t,r){let n,s,o="";const i=t/8,u=-1===r?3:0;for(n=0;n<i;n+=1)s=e[n>>>2]>>>8*(u+r*(n%4))&255,o+=String.fromCharCode(s);return o}(e,t,r)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error(l)}return function(e){return function(e,t,r){let n;const s=t/8,o=new ArrayBuffer(s),i=new Uint8Array(o),u=-1===r?3:0;for(n=0;n<s;n+=1)i[n]=e[n>>>2]>>>8*(u+r*(n%4))&255;return o}(e,t,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error(f)}return function(e){return function(e,t,r){let n;const s=t/8,o=-1===r?3:0,i=new Uint8Array(s);for(n=0;n<s;n+=1)i[n]=e[n>>>2]>>>8*(o+r*(n%4))&255;return i}(e,t,r)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],y=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],g=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function P(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},r=e||{},n="Output length must be a multiple of 8";if(t.outputUpper=r.outputUpper||!1,r.b64Pad&&(t.b64Pad=r.b64Pad),r.outputLen){if(r.outputLen%8!=0)throw new Error(n);t.outputLen=r.outputLen}else if(r.shakeLen){if(r.shakeLen%8!=0)throw new Error(n);t.outputLen=r.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}class q{constructor(e,t,r){const n=r||{};if(this.t=t,this.i=n.encoding||"UTF8",this.numRounds=n.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.U=[],this.R=[]}update(e){let t,r=0;const n=this.T>>>5,s=this.F(e,this.h,this.u),o=s.binLen,i=s.value,u=o>>>5;for(t=0;t<u;t+=n)r+this.T<=o&&(this.m=this.g(i.slice(t,t+n),this.m),r+=this.T);return this.A+=r,this.h=i.slice(r>>>5),this.u=o%this.T,this.l=!0,this}getHash(e,t){let r,n,s=this.H;const o=P(t);if(this.B){if(-1===o.outputLen)throw new Error("Output length must be specified in options");s=o.outputLen}const i=d(e,s,this.v,o);if(this.p&&this.C)return i(this.C(o));for(n=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),s),r=1;r<this.numRounds;r+=1)this.B&&s%32!=0&&(n[n.length-1]&=16777215>>>24-s%32),n=this.Y(n,s,0,this.I(this.o),s);return i(n)}setHMACKey(e,t,r){if(!this.L)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const n=v(t,(r||{}).encoding||"UTF8",this.v);this.M(n(e))}M(e){const t=this.T>>>3,r=t/4-1;let n;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.Y(e.value,e.binLen,0,this.I(this.o),this.H));e.value.length<=r;)e.value.push(0);for(n=0;n<=r;n+=1)this.U[n]=909522486^e.value[n],this.R[n]=1549556828^e.value[n];this.m=this.g(this.U,this.m),this.A=this.T,this.p=!0}getHMAC(e,t){const r=P(t);return d(e,this.H,this.v,r)(this.N())}N(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),this.H);return e=this.g(this.R,this.I(this.o)),e=this.Y(t,this.H,this.T,e,this.H),e}}function _(e,t){return e>>>t|e<<32-t}function b(e,t){return e>>>t}function w(e,t,r){return e&t^~e&r}function A(e,t,r){return e&t^e&r^t&r}function j(e){return _(e,2)^_(e,13)^_(e,22)}function E(e,t){const r=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(r>>>16))<<16|65535&r}function R(e,t,r,n){const s=(65535&e)+(65535&t)+(65535&r)+(65535&n);return(65535&(e>>>16)+(t>>>16)+(r>>>16)+(n>>>16)+(s>>>16))<<16|65535&s}function T(e,t,r,n,s){const o=(65535&e)+(65535&t)+(65535&r)+(65535&n)+(65535&s);return(65535&(e>>>16)+(t>>>16)+(r>>>16)+(n>>>16)+(s>>>16)+(o>>>16))<<16|65535&o}function U(e){return _(e,7)^_(e,18)^b(e,3)}function k(e){return _(e,6)^_(e,11)^_(e,25)}function S(e){let t;return t="SHA-224"==e?y.slice():g.slice(),t}function C(e,t){let r,n,s,o,i,u,a,c,h,l,f;const p=[];for(r=t[0],n=t[1],s=t[2],o=t[3],i=t[4],u=t[5],a=t[6],c=t[7],f=0;f<64;f+=1)p[f]=f<16?e[f]:R(_(v=p[f-2],17)^_(v,19)^b(v,10),p[f-7],U(p[f-15]),p[f-16]),h=T(c,k(i),w(i,u,a),m[f],p[f]),l=E(j(r),A(r,n,s)),c=a,a=u,u=i,i=E(o,h),o=s,s=n,n=r,r=E(h,l);var v;return t[0]=E(r,t[0]),t[1]=E(n,t[1]),t[2]=E(s,t[2]),t[3]=E(o,t[3]),t[4]=E(i,t[4]),t[5]=E(u,t[5]),t[6]=E(a,t[6]),t[7]=E(c,t[7]),t}class L extends q{constructor(e,t,r){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,r);const n=r||{};this.C=this.N,this.L=!0,this.v=-1,this.F=v(this.t,this.i,this.v),this.g=C,this.S=function(e){return e.slice()},this.I=S,this.Y=function(t,r,n,s){return function(e,t,r,n,s){let o,i;const u=15+(t+65>>>9<<4),a=t+r;for(;e.length<=u;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[u]=4294967295&a,e[u-1]=a/4294967296|0,o=0;o<e.length;o+=16)n=C(e.slice(o,o+16),n);return i="SHA-224"===s?[n[0],n[1],n[2],n[3],n[4],n[5],n[6]]:n,i}(t,r,n,s,e)},this.m=S(e),this.T=512,this.H="SHA-224"===e?224:256,this.B=!1,n.hmacKey&&this.M(function(e,t,r,n){const s="hmacKey must include a value and format";if(!t)throw new Error(s);if(void 0===t.value||!t.format)throw new Error(s);return v(t.format,t.encoding||"UTF8",r)(t.value)}(0,n.hmacKey,this.v))}}var H,F=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.handshake=function(e){var t=this;e.timestamp||(e.timestamp=Math.floor((new Date).getTime()/1e3)),e.version&&(this.version=e.version),e.user||delete e.timestamp;var r=this.url+"/server/json.server.php?action=handshake";return r+=s(e,"&"),i(r).then(function(e){return e.json()}).then(function(e){return e.auth&&(t.sessionKey=e.auth),e})},n.ping=function(e){var t="ping";return t+=s(e,"&"),this.request(t)},n.goodbye=function(e){var t="goodbye";return t+=s(e,"&"),this.request(t)},n.lostPassword=function(e){var t="lost_password";return t+=s(e,"&"),this.request(t)},n.encryptPassword=function(e){var t=r(e.password);return r(e.time+t);function r(e){var t=new L("SHA-256","TEXT",{encoding:"UTF8"});return t.update(e),t.getHash("HEX")}},r}(u),B=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.bookmark=function(e){try{var t="bookmark";return t+=s(e,"&"),Promise.resolve(this.request(t))}catch(e){return Promise.reject(e)}},n.bookmarks=function(e){try{var t="bookmarks";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.bookmark?e.bookmark:e})}catch(e){return Promise.reject(e)}},n.getBookmark=function(e){var t="get_bookmark";return t+=s(e,"&"),this.request(t)},n.bookmarkCreate=function(e){var t="bookmark_create";return t+=s(e,"&"),this.request(t)},n.bookmarkEdit=function(e){var t="bookmark_edit";return t+=s(e,"&"),this.request(t)},n.bookmarkDelete=function(e){var t="bookmark_delete";return t+=s(e,"&"),this.request(t)},r}(u),Y=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.catalogs=function(e){try{var t="catalogs";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.catalog?e.catalog:e})}catch(e){return Promise.reject(e)}},n.catalog=function(e){var t="catalog";return t+=s(e,"&"),this.request(t)},n.catalogAction=function(e){var t="catalog_action";return t+=s(e,"&"),this.request(t)},n.catalogFile=function(e){var t="catalog_file";return t+=s(e,"&"),this.request(t)},n.catalogAdd=function(e){var t="catalog_add";return t+=s(e,"&"),this.request(t)},n.catalogDelete=function(e){var t="catalog_delete";return t+=s(e,"&"),this.request(t)},r}(u),I=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.genres=function(e){try{var t="genres";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.genre?e.genre:e})}catch(e){return Promise.reject(e)}},n.genre=function(e){try{var t="genre";return t+=s(e,"&"),Promise.resolve(this.request(t))}catch(e){return Promise.reject(e)}},r}(u),x=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.labels=function(e){try{var t="labels";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.label?e.label:e})}catch(e){return Promise.reject(e)}},n.label=function(e){var t="label";return t+=s(e,"&"),this.request(t)},r}(u),O=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.licenses=function(e){try{var t="licenses";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.license?e.license:e})}catch(e){return Promise.reject(e)}},n.license=function(e){var t="license";return t+=s(e,"&"),this.request(t)},r}(u),N=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.liveStreams=function(e){try{var t="live_streams";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.live_stream?e.live_stream:e})}catch(e){return Promise.reject(e)}},n.liveStream=function(e){var t="live_stream";return t+=s(e,"&"),this.request(t)},n.liveStreamCreate=function(e){var t="live_stream_create";return t+=s(e,"&"),this.request(t)},n.liveStreamEdit=function(e){var t="live_stream_edit";return t+=s(e,"&"),this.request(t)},n.liveStreamDelete=function(e){var t="live_stream_delete";return t+=s(e,"&"),this.request(t)},r}(u),K=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.playlists=function(e){try{var t="playlists";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.playlist?e.playlist:e})}catch(e){return Promise.reject(e)}},n.smartlists=function(e){try{var t="playlists";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){var t=e.playlist?e.playlist:e;return Array.isArray(t)&&(t=t.filter(function(e){return e.id.toString().match(/^smart_/)})),t})}catch(e){return Promise.reject(e)}},n.playlist=function(e){var t="playlist";return t+=s(e,"&"),this.request(t)},n.userPlaylists=function(e){try{var t="user_playlists";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.playlist?e.playlist:e})}catch(e){return Promise.reject(e)}},n.userSmartlists=function(e){try{var t="user_smartlists";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.playlist?e.playlist:e})}catch(e){return Promise.reject(e)}},n.playlistCreate=function(e){var t="playlist_create";return t+=s(e,"&"),this.request(t)},n.playlistAdd=function(e){var t="playlist_add";return t+=s(e,"&"),this.request(t)},n.playlistEdit=function(e){var t="playlist_edit";return t+=s(e,"&"),this.request(t)},n.playlistDelete=function(e){var t="playlist_delete";return t+=s(e,"&"),this.request(t)},n.playlistAddSong=function(e){var t="playlist_add_song";return t+=s(e,"&"),this.request(t)},n.playlistRemoveSong=function(e){var t="playlist_remove_song";return t+=s(e,"&"),this.request(t)},n.playlistGenerate=function(e){try{var t="playlist_generate";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},r}(u),M=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.podcasts=function(e){try{var t="podcasts";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.podcast?e.podcast:e})}catch(e){return Promise.reject(e)}},n.podcast=function(e){try{var t="podcast";return t+=s(e,"&"),Promise.resolve(this.request(t))}catch(e){return Promise.reject(e)}},n.podcastCreate=function(e){var t="podcast_create";return t+=s(e,"&"),this.request(t)},n.podcastEdit=function(e){var t="podcast_edit";return t+=s(e,"&"),this.request(t)},n.podcastDelete=function(e){var t="podcast_delete";return t+=s(e,"&"),this.request(t)},n.podcastEpisodes=function(e){try{var t="podcast_episodes";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.podcast_episode?e.podcast_episode:e})}catch(e){return Promise.reject(e)}},n.podcastEpisode=function(e){var t="podcast_episode";return t+=s(e,"&"),this.request(t)},n.podcastEpisodeDelete=function(e){var t="podcast_episode_delete";return t+=s(e,"&"),this.request(t)},n.updatePodcast=function(e){var t="update_podcast";return t+=s(e,"&"),this.request(t)},n.deletedPodcastEpisodes=function(e){try{var t="deleted_podcast_episodes";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.deleted_podcast_episode?e.deleted_podcast_episode:e})}catch(e){return Promise.reject(e)}},r}(u),D=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.systemPreferences=function(){try{return Promise.resolve(this.request("system_preferences")).then(function(e){return e.preference?e.preference:e})}catch(e){return Promise.reject(e)}},n.systemPreference=function(e){try{var t="system_preference";return t+=s(e,"&"),Promise.resolve(this.request(t))}catch(e){return Promise.reject(e)}},n.userPreferences=function(){try{return Promise.resolve(this.request("user_preferences")).then(function(e){return e.preference?e.preference:e})}catch(e){return Promise.reject(e)}},n.userPreference=function(e){try{var t="user_preference";return t+=s(e,"&"),Promise.resolve(this.request(t))}catch(e){return Promise.reject(e)}},n.preferenceCreate=function(e){var t="preference_create";return t+=s(e,"&"),this.request(t)},n.preferenceEdit=function(e){var t="preference_edit";return t+=s(e,"&"),this.request(t)},n.preferenceDelete=function(e){var t="preference_delete";return t+=s(e,"&"),this.request(t)},r}(u),X=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.shares=function(e){try{var t="shares";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.share?e.share:e})}catch(e){return Promise.reject(e)}},n.share=function(e){var t="share";return t+=s(e,"&"),this.request(t)},n.shareCreate=function(e){var t="share_create";return t+=s(e,"&"),this.request(t)},n.shareEdit=function(e){var t="share_edit";return t+=s(e,"&"),this.request(t)},n.shareDelete=function(e){var t="share_delete";return t+=s(e,"&"),this.request(t)},r}(u),z=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r.prototype.last_shouts=function(e){try{var t="last_shouts";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.shout?e.shout:e})}catch(e){return Promise.reject(e)}},r}(u),G=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.songs=function(e){try{var t="songs";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},n.song=function(e){var t="song";return t+=s(e,"&"),this.request(t)},n.artistSongs=function(e){try{var t="artist_songs";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},n.albumSongs=function(e){try{var t="album_songs";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},n.genreSongs=function(e){try{var t="genre_songs";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},n.playlistSongs=function(e){try{var t="playlist_songs";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},n.licenseSongs=function(e){try{var t="license_songs";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},n.songDelete=function(e){var t="song_delete";return t+=s(e,"&"),this.request(t)},n.urlToSong=function(e){var t="url_to_song";return e.url=encodeURIComponent(e.url),t+=s(e,"&"),this.request(t)},n.searchSongs=function(e){try{var t="search_songs";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},n.deletedSongs=function(e){try{var t="deleted_songs";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.deleted_song?e.deleted_song:e})}catch(e){return Promise.reject(e)}},r}(u),V=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.systemUpdate=function(){return this.request("system_update")},n.getIndexes=function(e){try{var t,r=this,n="get_indexes";switch(n+=s(e,"&"),e.type){case"song":return Promise.resolve(r.request(n)).then(function(e){return(t=e).song?t.song:t});case"album":return Promise.resolve(r.request(n)).then(function(e){return(t=e).album?t.album:t});case"artist":case"album_artist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).artist?t.artist:t});case"playlist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).playlist?t.playlist:t});case"podcast":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast?t.podcast:t});case"podcast_episode":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast_episode?t.podcast_episode:t});case"live_stream":return Promise.resolve(r.request(n)).then(function(e){return(t=e).live_stream?t.live_stream:t});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},n.list=function(e){try{var t="list";return t+=s(e,"&"),Promise.resolve(this.request(t))}catch(e){return Promise.reject(e)}},n.index=function(e){try{var t="index";return t+=s(e,"&"),Promise.resolve(this.request(t))}catch(e){return Promise.reject(e)}},n.browse=function(e){try{var t="browse";return t+=s(e,"&"),Promise.resolve(this.request(t))}catch(e){return Promise.reject(e)}},n.getSimilar=function(e){try{var t,r="get_similar";switch(r+=s(e,"&"),e.type){case"song":return Promise.resolve(this.request(r)).then(function(e){return(t=e).song?t.song:t});case"artist":return Promise.resolve(this.request(r)).then(function(e){return(t=e).artist?t.artist:t});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},n.stats=function(e){try{var t,r=this,n="stats";switch(n+=s(e,"&"),e.type){case"song":return Promise.resolve(r.request(n)).then(function(e){return(t=e).song?t.song:t});case"album":return Promise.resolve(r.request(n)).then(function(e){return(t=e).album?t.album:t});case"artist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).artist?t.artist:t});case"video":return Promise.resolve(r.request(n)).then(function(e){return(t=e).video?t.video:t});case"playlist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).playlist?t.playlist:t});case"podcast":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast?t.podcast:t});case"podcast_episode":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast_episode?t.podcast_episode:t});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},n.rate=function(e){var t="rate";return t+=s(e,"&"),this.request(t)},n.flag=function(e){var t="flag";return t+=s(e,"&"),this.request(t)},n.recordPlay=function(e){var t="record_play";return t+=s(e,"&"),this.request(t)},n.scrobble=function(e){var t="scrobble";return t+=s(e,"&"),this.request(t)},n.updateFromTags=function(e){var t="update_from_tags";return t+=s(e,"&"),this.request(t)},n.updateArtistInfo=function(e){var t="update_artist_info";return t+=s(e,"&"),this.request(t)},n.updateArt=function(e){var t="update_art";return t+=s(e,"&"),this.request(t)},n.stream=function(e){var t="stream";return t+=s(e,"&"),this.binary(t)},n.download=function(e){var t="download";return t+=s(e,"&"),this.binary(t)},n.getArt=function(e){var t="get_art";return t+=s(e,"&"),this.binary(t)},n.localplay=function(e){var t="localplay";return t+=s(e,"&"),this.request(t)},n.localplaySongs=function(){return this.request("localplay_songs")},n.democratic=function(e){var t="democratic";return t+=s(e,"&"),this.request(t)},n.advancedSearch=function(e){try{for(var t,r=this,n="advanced_search",o=0;o<e.rules.length;o++){var i=e.rules[o],u=o+1;e["rule_"+u]=i[0],e["rule_"+u+"_operator"]=i[1],e["rule_"+u+"_input"]=i[2],"metadata"===i[0]&&(e["rule_"+u+"_subtype"]=i[3])}switch(delete e.rules,n+=s(e,"&"),e.type){case"song":return Promise.resolve(r.request(n)).then(function(e){return(t=e).song?t.song:t});case"album":return Promise.resolve(r.request(n)).then(function(e){return(t=e).album?t.album:t});case"artist":case"album_artist":case"song_artist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).artist?t.artist:t});case"label":return Promise.resolve(r.request(n)).then(function(e){return(t=e).label?t.label:t});case"playlist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).playlist?t.playlist:t});case"podcast":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast?t.podcast:t});case"podcast_episode":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast_episode?t.podcast_episode:t});case"genre":return Promise.resolve(r.request(n)).then(function(e){return(t=e).genre?t.genre:t});case"user":return Promise.resolve(r.request(n)).then(function(e){return(t=e).user?t.user:t});case"video":return Promise.resolve(r.request(n)).then(function(e){return(t=e).video?t.video:t});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},r}(u),J=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.users=function(){try{return Promise.resolve(this.request("users")).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},n.user=function(e){try{var t="user";return t+=s(e,"&"),Promise.resolve(this.request(t))}catch(e){return Promise.reject(e)}},n.userCreate=function(e){var t="user_create";return t+=s(e,"&"),this.request(t)},n.register=function(e){var t="register";return t+=s(e,"&"),this.request(t)},n.userUpdate=function(e){var t="user_update";return t+=s(e,"&"),this.request(t)},n.userEdit=function(e){var t="user_edit";return t+=s(e,"&"),this.request(t)},n.userDelete=function(e){var t="user_delete";return t+=s(e,"&"),this.request(t)},n.followers=function(e){try{var t="followers";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},n.following=function(e){try{var t="following";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},n.toggleFollow=function(e){var t="toggle_follow";return t+=s(e,"&"),this.request(t)},n.timeline=function(e){try{var t="timeline";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.activity?e.activity:e})}catch(e){return Promise.reject(e)}},n.friendsTimeline=function(e){try{var t="friends_timeline";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.activity?e.activity:e})}catch(e){return Promise.reject(e)}},r}(u),Z=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.videos=function(e){try{var t="videos";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.video?e.video:e})}catch(e){return Promise.reject(e)}},n.video=function(e){var t="video";return t+=s(e,"&"),this.request(t)},n.deletedVideos=function(e){try{var t="deleted_videos";return t+=s(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.deleted_video?e.deleted_video:e})}catch(e){return Promise.reject(e)}},r}(u),$=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r}(u);H=$,[a,c,F,B,Y,I,x,O,N,K,M,D,X,z,G,V,J,Z].forEach(function(e){Object.getOwnPropertyNames(e.prototype).forEach(function(t){Object.defineProperty(H.prototype,t,Object.getOwnPropertyDescriptor(e.prototype,t))})}),module.exports=$;
1
+ function t(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,e(t,r)}function e(t,r){return e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},e(t,r)}var r=Object.prototype.hasOwnProperty;function n(t){try{return encodeURIComponent(t)}catch(t){return null}}var s=function(t,e){e=e||"";var s,i,u=[];for(i in"string"!=typeof e&&(e="?"),t)if(r.call(t,i)){if((s=t[i])||null!=s&&!isNaN(s)||(s=""),i=n(i),s=n(s),null===i||null===s)continue;u.push(i+"="+s)}return u.length?e+u.join("&"):""},i={__proto__:null,default:function(t,e){return e=e||{},new Promise(function(r,n){var s=new XMLHttpRequest,i=[],u=[],o={},a=function(){return{ok:2==(s.status/100|0),statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:a,headers:{keys:function(){return i},entries:function(){return u},get:function(t){return o[t.toLowerCase()]},has:function(t){return t.toLowerCase()in o}}}};for(var c in s.open(e.method||"get",t,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(t,e,r){i.push(e=e.toLowerCase()),u.push([e,r]),o[e]=o[e]?o[e]+","+r:r}),r(a())},s.onerror=n,s.withCredentials="include"==e.credentials,e.headers)s.setRequestHeader(c,e.headers[c]);s.send(e.body||null)})}},u=self.fetch||(self.fetch=i.default||i),o=/*#__PURE__*/function(){function t(t){this.sessionKey=void 0,this.url=void 0,this.version="6.3.0",this.debug=void 0,this.sessionKey=t.sessionKey||null,this.url=t.url,this.debug=t.debug||!1}var e=t.prototype;return e.request=function(t){var e=this.url+"/server/json.server.php?action="+t+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+e+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),u(e,{method:"GET",headers:{Authorization:"Bearer "+this.sessionKey}}).then(function(t){if(t.ok)return t.json();throw new Error(t.statusText)})},e.binary=function(t){var e=this.url+"/server/json.server.php?action="+t+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+e+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),u(e,{method:"GET",headers:{Authorization:"Bearer "+this.sessionKey}}).then(function(t){return t.blob()}).then(function(t){return t})},e.setSessionKey=function(t){this.sessionKey=t},e.rawURL=function(t,e){var r=t;r+=s(e,"&");var n=this.url+"/server/json.server.php?action="+r+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+n+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),n},t}(),a=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.albums=function(t){var e="albums";return e+=s(t,"&"),this.request(e)},n.album=function(t){var e="album";return e+=s(t,"&"),this.request(e)},n.artistAlbums=function(t){var e="artist_albums";return e+=s(t,"&"),this.request(e)},n.genreAlbums=function(t){var e="genre_albums";return e+=s(t,"&"),this.request(e)},r}(o),c=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.artists=function(t){var e="artists";return e+=s(t,"&"),this.request(e)},n.artist=function(t){var e="artist";return e+=s(t,"&"),this.request(e)},n.genreArtists=function(t){var e="genre_artists";return e+=s(t,"&"),this.request(e)},n.labelArtists=function(t){var e="label_artists";return e+=s(t,"&"),this.request(e)},r}(o);const h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l="ARRAYBUFFER not supported by this environment",f="UINT8ARRAY not supported by this environment";function p(t,e,r,n){let s,i,u;const o=e||[0],a=(r=r||0)>>>3,c=-1===n?3:0;for(s=0;s<t.length;s+=1)u=s+a,i=u>>>2,o.length<=i&&o.push(0),o[i]|=t[s]<<8*(c+n*(u%4));return{value:o,binLen:8*t.length+r}}function d(t,e,r){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,n){return function(t,e,r,n){let s,i,u,o;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const a=e||[0],c=(r=r||0)>>>3,h=-1===n?3:0;for(s=0;s<t.length;s+=2){if(i=parseInt(t.substr(s,2),16),isNaN(i))throw new Error("String of HEX type contains invalid characters");for(o=(s>>>1)+c,u=o>>>2;a.length<=u;)a.push(0);a[u]|=i<<8*(h+n*(o%4))}return{value:a,binLen:4*t.length+r}}(t,e,n,r)};case"TEXT":return function(t,n,s){return function(t,e,r,n,s){let i,u,o,a,c,h,l,f,p=0;const d=r||[0],v=(n=n||0)>>>3;if("UTF8"===e)for(l=-1===s?3:0,o=0;o<t.length;o+=1)for(i=t.charCodeAt(o),u=[],128>i?u.push(i):2048>i?(u.push(192|i>>>6),u.push(128|63&i)):55296>i||57344<=i?u.push(224|i>>>12,128|i>>>6&63,128|63&i):(o+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(o)),u.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),a=0;a<u.length;a+=1){for(h=p+v,c=h>>>2;d.length<=c;)d.push(0);d[c]|=u[a]<<8*(l+s*(h%4)),p+=1}else for(l=-1===s?2:0,f="UTF16LE"===e&&1!==s||"UTF16LE"!==e&&1===s,o=0;o<t.length;o+=1){for(i=t.charCodeAt(o),!0===f&&(a=255&i,i=a<<8|i>>>8),h=p+v,c=h>>>2;d.length<=c;)d.push(0);d[c]|=i<<8*(l+s*(h%4)),p+=2}return{value:d,binLen:8*p+n}}(t,e,n,s,r)};case"B64":return function(t,e,n){return function(t,e,r,n){let s,i,u,o,a,c,l,f=0;const p=e||[0],d=(r=r||0)>>>3,v=-1===n?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&g<t.length)throw new Error("Invalid '=' found in base-64 string");for(i=0;i<t.length;i+=4){for(a=t.substr(i,4),o=0,u=0;u<a.length;u+=1)s=h.indexOf(a.charAt(u)),o|=s<<18-6*u;for(u=0;u<a.length-1;u+=1){for(l=f+d,c=l>>>2;p.length<=c;)p.push(0);p[c]|=(o>>>16-8*u&255)<<8*(v+n*(l%4)),f+=1}}return{value:p,binLen:8*f+r}}(t,e,n,r)};case"BYTES":return function(t,e,n){return function(t,e,r,n){let s,i,u,o;const a=e||[0],c=(r=r||0)>>>3,h=-1===n?3:0;for(i=0;i<t.length;i+=1)s=t.charCodeAt(i),o=i+c,u=o>>>2,a.length<=u&&a.push(0),a[u]|=s<<8*(h+n*(o%4));return{value:a,binLen:8*t.length+r}}(t,e,n,r)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error(l)}return function(t,e,n){return function(t,e,r,n){return p(new Uint8Array(t),e,r,n)}(t,e,n,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error(f)}return function(t,e,n){return p(t,e,n,r)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function v(t,e,r,n){switch(t){case"HEX":return function(t){return function(t,e,r,n){const s="0123456789abcdef";let i,u,o="";const a=e/8,c=-1===r?3:0;for(i=0;i<a;i+=1)u=t[i>>>2]>>>8*(c+r*(i%4)),o+=s.charAt(u>>>4&15)+s.charAt(15&u);return n.outputUpper?o.toUpperCase():o}(t,e,r,n)};case"B64":return function(t){return function(t,e,r,n){let s,i,u,o,a,c="";const l=e/8,f=-1===r?3:0;for(s=0;s<l;s+=3)for(o=s+1<l?t[s+1>>>2]:0,a=s+2<l?t[s+2>>>2]:0,u=(t[s>>>2]>>>8*(f+r*(s%4))&255)<<16|(o>>>8*(f+r*((s+1)%4))&255)<<8|a>>>8*(f+r*((s+2)%4))&255,i=0;i<4;i+=1)c+=8*s+6*i<=e?h.charAt(u>>>6*(3-i)&63):n.b64Pad;return c}(t,e,r,n)};case"BYTES":return function(t){return function(t,e,r){let n,s,i="";const u=e/8,o=-1===r?3:0;for(n=0;n<u;n+=1)s=t[n>>>2]>>>8*(o+r*(n%4))&255,i+=String.fromCharCode(s);return i}(t,e,r)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error(l)}return function(t){return function(t,e,r){let n;const s=e/8,i=new ArrayBuffer(s),u=new Uint8Array(i),o=-1===r?3:0;for(n=0;n<s;n+=1)u[n]=t[n>>>2]>>>8*(o+r*(n%4))&255;return i}(t,e,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error(f)}return function(t){return function(t,e,r){let n;const s=e/8,i=-1===r?3:0,u=new Uint8Array(s);for(n=0;n<s;n+=1)u[n]=t[n>>>2]>>>8*(i+r*(n%4))&255;return u}(t,e,r)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],y=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],m=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function q(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},r=t||{},n="Output length must be a multiple of 8";if(e.outputUpper=r.outputUpper||!1,r.b64Pad&&(e.b64Pad=r.b64Pad),r.outputLen){if(r.outputLen%8!=0)throw new Error(n);e.outputLen=r.outputLen}else if(r.shakeLen){if(r.shakeLen%8!=0)throw new Error(n);e.outputLen=r.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}class b{constructor(t,e,r){const n=r||{};if(this.t=e,this.i=n.encoding||"UTF8",this.numRounds=n.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.U=[],this.R=[]}update(t){let e,r=0;const n=this.T>>>5,s=this.F(t,this.h,this.u),i=s.binLen,u=s.value,o=i>>>5;for(e=0;e<o;e+=n)r+this.T<=i&&(this.m=this.g(u.slice(e,e+n),this.m),r+=this.T);return this.A+=r,this.h=u.slice(r>>>5),this.u=i%this.T,this.l=!0,this}getHash(t,e){let r,n,s=this.H;const i=q(e);if(this.B){if(-1===i.outputLen)throw new Error("Output length must be specified in options");s=i.outputLen}const u=v(t,s,this.v,i);if(this.p&&this.C)return u(this.C(i));for(n=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),s),r=1;r<this.numRounds;r+=1)this.B&&s%32!=0&&(n[n.length-1]&=16777215>>>24-s%32),n=this.Y(n,s,0,this.I(this.o),s);return u(n)}setHMACKey(t,e,r){if(!this.L)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const n=d(e,(r||{}).encoding||"UTF8",this.v);this.M(n(t))}M(t){const e=this.T>>>3,r=e/4-1;let n;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.Y(t.value,t.binLen,0,this.I(this.o),this.H));t.value.length<=r;)t.value.push(0);for(n=0;n<=r;n+=1)this.U[n]=909522486^t.value[n],this.R[n]=1549556828^t.value[n];this.m=this.g(this.U,this.m),this.A=this.T,this.p=!0}getHMAC(t,e){const r=q(e);return v(t,this.H,this.v,r)(this.N())}N(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),this.H);return t=this.g(this.R,this.I(this.o)),t=this.Y(e,this.H,this.T,t,this.H),t}}function _(t,e){return t>>>e|t<<32-e}function w(t,e){return t>>>e}function A(t,e,r){return t&e^~t&r}function E(t,e,r){return t&e^t&r^e&r}function R(t){return _(t,2)^_(t,13)^_(t,22)}function T(t,e){const r=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(r>>>16))<<16|65535&r}function U(t,e,r,n){const s=(65535&t)+(65535&e)+(65535&r)+(65535&n);return(65535&(t>>>16)+(e>>>16)+(r>>>16)+(n>>>16)+(s>>>16))<<16|65535&s}function k(t,e,r,n,s){const i=(65535&t)+(65535&e)+(65535&r)+(65535&n)+(65535&s);return(65535&(t>>>16)+(e>>>16)+(r>>>16)+(n>>>16)+(s>>>16)+(i>>>16))<<16|65535&i}function S(t){return _(t,7)^_(t,18)^w(t,3)}function C(t){return _(t,6)^_(t,11)^_(t,25)}function L(t){let e;return e="SHA-224"==t?y.slice():m.slice(),e}function H(t,e){let r,n,s,i,u,o,a,c,h,l,f;const p=[];for(r=e[0],n=e[1],s=e[2],i=e[3],u=e[4],o=e[5],a=e[6],c=e[7],f=0;f<64;f+=1)p[f]=f<16?t[f]:U(_(d=p[f-2],17)^_(d,19)^w(d,10),p[f-7],S(p[f-15]),p[f-16]),h=k(c,C(u),A(u,o,a),g[f],p[f]),l=T(R(r),E(r,n,s)),c=a,a=o,o=u,u=T(i,h),i=s,s=n,n=r,r=T(h,l);var d;return e[0]=T(r,e[0]),e[1]=T(n,e[1]),e[2]=T(s,e[2]),e[3]=T(i,e[3]),e[4]=T(u,e[4]),e[5]=T(o,e[5]),e[6]=T(a,e[6]),e[7]=T(c,e[7]),e}class F extends b{constructor(t,e,r){if("SHA-224"!==t&&"SHA-256"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,r);const n=r||{};this.C=this.N,this.L=!0,this.v=-1,this.F=d(this.t,this.i,this.v),this.g=H,this.S=function(t){return t.slice()},this.I=L,this.Y=function(e,r,n,s){return function(t,e,r,n,s){let i,u;const o=15+(e+65>>>9<<4),a=e+r;for(;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[o]=4294967295&a,t[o-1]=a/4294967296|0,i=0;i<t.length;i+=16)n=H(t.slice(i,i+16),n);return u="SHA-224"===s?[n[0],n[1],n[2],n[3],n[4],n[5],n[6]]:n,u}(e,r,n,s,t)},this.m=L(t),this.T=512,this.H="SHA-224"===t?224:256,this.B=!1,n.hmacKey&&this.M(function(t,e,r,n){const s="hmacKey must include a value and format";if(!e)throw new Error(s);if(void 0===e.value||!e.format)throw new Error(s);return d(e.format,e.encoding||"UTF8",r)(e.value)}(0,n.hmacKey,this.v))}}var P,B=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.handshake=function(t){var e=this;t.timestamp||(t.timestamp=Math.floor((new Date).getTime()/1e3)),t.version&&(this.version=t.version),t.user||delete t.timestamp;var r=this.url+"/server/json.server.php?action=handshake";return r+=s(t,"&"),u(r).then(function(t){return t.json()}).then(function(t){return t.auth&&(e.sessionKey=t.auth),t})},n.ping=function(t){var e="ping";return e+=s(t,"&"),this.request(e)},n.goodbye=function(t){var e="goodbye";return e+=s(t,"&"),this.request(e)},n.lostPassword=function(t){var e="lost_password";return e+=s(t,"&"),this.request(e)},n.encryptPassword=function(t){var e=r(t.password);return r(t.time+e);function r(t){var e=new F("SHA-256","TEXT",{encoding:"UTF8"});return e.update(t),e.getHash("HEX")}},r}(o),Y=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.bookmark=function(t){var e="bookmark";return e+=s(t,"&"),this.request(e)},n.bookmarks=function(t){var e="bookmarks";return e+=s(t,"&"),this.request(e)},n.getBookmark=function(t){var e="get_bookmark";return e+=s(t,"&"),this.request(e)},n.bookmarkCreate=function(t){var e="bookmark_create";return e+=s(t,"&"),this.request(e)},n.bookmarkEdit=function(t){var e="bookmark_edit";return e+=s(t,"&"),this.request(e)},n.bookmarkDelete=function(t){var e="bookmark_delete";return e+=s(t,"&"),this.request(e)},r}(o),I=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.catalogs=function(t){var e="catalogs";return e+=s(t,"&"),this.request(e)},n.catalog=function(t){var e="catalog";return e+=s(t,"&"),this.request(e)},n.catalogAction=function(t){var e="catalog_action";return e+=s(t,"&"),this.request(e)},n.catalogFile=function(t){var e="catalog_file";return e+=s(t,"&"),this.request(e)},n.catalogAdd=function(t){var e="catalog_add";return e+=s(t,"&"),this.request(e)},n.catalogDelete=function(t){var e="catalog_delete";return e+=s(t,"&"),this.request(e)},r}(o),j=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.genres=function(t){var e="genres";return e+=s(t,"&"),this.request(e)},n.genre=function(t){var e="genre";return e+=s(t,"&"),this.request(e)},r}(o),x=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.labels=function(t){var e="labels";return e+=s(t,"&"),this.request(e)},n.label=function(t){var e="label";return e+=s(t,"&"),this.request(e)},r}(o),O=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.licenses=function(t){var e="licenses";return e+=s(t,"&"),this.request(e)},n.license=function(t){var e="license";return e+=s(t,"&"),this.request(e)},r}(o),N=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.liveStreams=function(t){var e="live_streams";return e+=s(t,"&"),this.request(e)},n.liveStream=function(t){var e="live_stream";return e+=s(t,"&"),this.request(e)},n.liveStreamCreate=function(t){var e="live_stream_create";return e+=s(t,"&"),this.request(e)},n.liveStreamEdit=function(t){var e="live_stream_edit";return e+=s(t,"&"),this.request(e)},n.liveStreamDelete=function(t){var e="live_stream_delete";return e+=s(t,"&"),this.request(e)},r}(o),K=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.playlists=function(t){var e="playlists";return e+=s(t,"&"),this.request(e)},n.smartlists=function(t){var e="playlists";return e+=s(t,"&"),this.request(e).then(function(t){return Array.isArray(t.playlist)&&(t.playlist=t.playlist.filter(function(t){return t.id.toString().startsWith("smart_")})),t})},n.playlist=function(t){var e="playlist";return e+=s(t,"&"),this.request(e)},n.userPlaylists=function(t){var e="user_playlists";return e+=s(t,"&"),this.request(e)},n.userSmartlists=function(t){var e="user_smartlists";return e+=s(t,"&"),this.request(e)},n.playlistCreate=function(t){var e="playlist_create";return e+=s(t,"&"),this.request(e)},n.playlistAdd=function(t){var e="playlist_add";return e+=s(t,"&"),this.request(e)},n.playlistEdit=function(t){var e="playlist_edit";return e+=s(t,"&"),this.request(e)},n.playlistDelete=function(t){var e="playlist_delete";return e+=s(t,"&"),this.request(e)},n.playlistAddSong=function(t){var e="playlist_add_song";return e+=s(t,"&"),this.request(e)},n.playlistRemoveSong=function(t){var e="playlist_remove_song";return e+=s(t,"&"),this.request(e)},n.playlistGenerate=function(t){var e="playlist_generate";return e+=s(t,"&"),this.request(e)},r}(o),M=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.podcasts=function(t){var e="podcasts";return e+=s(t,"&"),this.request(e)},n.podcast=function(t){var e="podcast";return e+=s(t,"&"),this.request(e)},n.podcastCreate=function(t){var e="podcast_create";return e+=s(t,"&"),this.request(e)},n.podcastEdit=function(t){var e="podcast_edit";return e+=s(t,"&"),this.request(e)},n.podcastDelete=function(t){var e="podcast_delete";return e+=s(t,"&"),this.request(e)},n.podcastEpisodes=function(t){var e="podcast_episodes";return e+=s(t,"&"),this.request(e)},n.podcastEpisode=function(t){var e="podcast_episode";return e+=s(t,"&"),this.request(e)},n.podcastEpisodeDelete=function(t){var e="podcast_episode_delete";return e+=s(t,"&"),this.request(e)},n.updatePodcast=function(t){var e="update_podcast";return e+=s(t,"&"),this.request(e)},n.deletedPodcastEpisodes=function(t){var e="deleted_podcast_episodes";return e+=s(t,"&"),this.request(e)},r}(o),D=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.systemPreferences=function(){return this.request("system_preferences")},n.systemPreference=function(t){var e="system_preference";return e+=s(t,"&"),this.request(e)},n.userPreferences=function(){return this.request("user_preferences")},n.userPreference=function(t){var e="user_preference";return e+=s(t,"&"),this.request(e)},n.preferenceCreate=function(t){var e="preference_create";return e+=s(t,"&"),this.request(e)},n.preferenceEdit=function(t){var e="preference_edit";return e+=s(t,"&"),this.request(e)},n.preferenceDelete=function(t){var e="preference_delete";return e+=s(t,"&"),this.request(e)},r}(o),X=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.shares=function(t){var e="shares";return e+=s(t,"&"),this.request(e)},n.share=function(t){var e="share";return e+=s(t,"&"),this.request(e)},n.shareCreate=function(t){var e="share_create";return e+=s(t,"&"),this.request(e)},n.shareEdit=function(t){var e="share_edit";return e+=s(t,"&"),this.request(e)},n.shareDelete=function(t){var e="share_delete";return e+=s(t,"&"),this.request(e)},r}(o),z=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}return t(r,e),r.prototype.last_shouts=function(t){var e="last_shouts";return e+=s(t,"&"),this.request(e)},r}(o),G=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.songs=function(t){var e="songs";return e+=s(t,"&"),this.request(e)},n.song=function(t){var e="song";return e+=s(t,"&"),this.request(e)},n.artistSongs=function(t){var e="artist_songs";return e+=s(t,"&"),this.request(e)},n.albumSongs=function(t){var e="album_songs";return e+=s(t,"&"),this.request(e)},n.genreSongs=function(t){var e="genre_songs";return e+=s(t,"&"),this.request(e)},n.playlistSongs=function(t){var e="playlist_songs";return e+=s(t,"&"),this.request(e)},n.licenseSongs=function(t){var e="license_songs";return e+=s(t,"&"),this.request(e)},n.songDelete=function(t){var e="song_delete";return e+=s(t,"&"),this.request(e)},n.urlToSong=function(t){var e="url_to_song";return t.url=encodeURIComponent(t.url),e+=s(t,"&"),this.request(e)},n.searchSongs=function(t){var e="search_songs";return e+=s(t,"&"),this.request(e)},n.deletedSongs=function(t){var e="deleted_songs";return e+=s(t,"&"),this.request(e)},r}(o),V=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.systemUpdate=function(){return this.request("system_update")},n.getIndexes=function(t){var e,r="get_indexes";switch(r+=s(t,"&"),t.type){case"song":case"album":case"artist":case"album_artist":case"playlist":case"podcast":case"podcast_episode":case"live_stream":e=this.request(r);break;default:return!1}return e},n.list=function(t){var e="list";return e+=s(t,"&"),this.request(e)},n.index=function(t){var e="index";return e+=s(t,"&"),this.request(e)},n.browse=function(t){var e="browse";return e+=s(t,"&"),this.request(e)},n.getSimilar=function(t){var e,r="get_similar";switch(r+=s(t,"&"),t.type){case"song":case"artist":e=this.request(r);break;default:return!1}return e},n.stats=function(t){var e,r="stats";switch(r+=s(t,"&"),t.type){case"song":case"album":case"artist":case"video":case"playlist":case"podcast":case"podcast_episode":e=this.request(r);break;default:return!1}return e},n.rate=function(t){var e="rate";return e+=s(t,"&"),this.request(e)},n.flag=function(t){var e="flag";return e+=s(t,"&"),this.request(e)},n.recordPlay=function(t){var e="record_play";return e+=s(t,"&"),this.request(e)},n.scrobble=function(t){var e="scrobble";return e+=s(t,"&"),this.request(e)},n.updateFromTags=function(t){var e="update_from_tags";return e+=s(t,"&"),this.request(e)},n.updateArtistInfo=function(t){var e="update_artist_info";return e+=s(t,"&"),this.request(e)},n.updateArt=function(t){var e="update_art";return e+=s(t,"&"),this.request(e)},n.stream=function(t){var e="stream";return e+=s(t,"&"),this.binary(e)},n.download=function(t){var e="download";return e+=s(t,"&"),this.binary(e)},n.getArt=function(t){var e="get_art";return e+=s(t,"&"),this.binary(e)},n.localplay=function(t){var e="localplay";return e+=s(t,"&"),this.request(e)},n.localplaySongs=function(){return this.request("localplay_songs")},n.democratic=function(t){var e="democratic";return e+=s(t,"&"),this.request(e)},n.advancedSearch=function(t){for(var e,r="advanced_search",n=0;n<t.rules.length;n++){var i=t.rules[n],u=n+1;t["rule_"+u]=i[0],t["rule_"+u+"_operator"]=i[1],t["rule_"+u+"_input"]=i[2],"metadata"===i[0]&&(t["rule_"+u+"_subtype"]=i[3])}switch(delete t.rules,r+=s(t,"&"),t.type){case"song":case"album":case"artist":case"album_artist":case"song_artist":case"label":case"playlist":case"podcast":case"podcast_episode":case"genre":case"user":case"video":e=this.request(r);break;default:return!1}return e},r}(o),J=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.users=function(){return this.request("users")},n.user=function(t){var e="user";return e+=s(t,"&"),this.request(e)},n.userCreate=function(t){var e="user_create";return e+=s(t,"&"),this.request(e)},n.register=function(t){var e="register";return e+=s(t,"&"),this.request(e)},n.userUpdate=function(t){var e="user_update";return e+=s(t,"&"),this.request(e)},n.userEdit=function(t){var e="user_edit";return e+=s(t,"&"),this.request(e)},n.userDelete=function(t){var e="user_delete";return e+=s(t,"&"),this.request(e)},n.followers=function(t){var e="followers";return e+=s(t,"&"),this.request(e)},n.following=function(t){var e="following";return e+=s(t,"&"),this.request(e)},n.toggleFollow=function(t){var e="toggle_follow";return e+=s(t,"&"),this.request(e)},n.timeline=function(t){var e="timeline";return e+=s(t,"&"),this.request(e)},n.friendsTimeline=function(t){var e="friends_timeline";return e+=s(t,"&"),this.request(e)},r}(o),W=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.videos=function(t){var e="videos";return e+=s(t,"&"),this.request(e)},n.video=function(t){var e="video";return e+=s(t,"&"),this.request(e)},n.deletedVideos=function(t){var e="deleted_videos";return e+=s(t,"&"),this.request(e)},r}(o),Z=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}return t(r,e),r}(o);P=Z,[a,c,B,Y,I,j,x,O,N,K,M,D,X,z,G,V,J,W].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(P.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})}),module.exports=Z;
2
2
  //# sourceMappingURL=index.js.map