@serifpersia/dango 3.3.8 → 3.4.0

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 (180) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-D4qo4289.js → AnimeCard-CJy1SXH3.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-BdRRm4So.js → AnimeInfo-BoXlVvZ-.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-DeJNAKMR.js → AnimeInfoPage-BxbA_7AV.js} +2 -2
  5. package/client/dist/assets/Asmr--Zc8G9zv.js +2 -0
  6. package/client/dist/assets/AsmrResetProgressModal-CKYm-8cp.js +1 -0
  7. package/client/dist/assets/AvSyncCalibrator-3yjZS7s6.js +10 -0
  8. package/client/dist/assets/Home-rrhOGQcg.js +1 -0
  9. package/client/dist/assets/Insights-Bay90Yeg.js +1 -0
  10. package/client/dist/assets/{LibraryListPage-D3hTqTRU.js → LibraryListPage-HzuDavbb.js} +1 -1
  11. package/client/dist/assets/{ListeningList-BgWsfu40.js → ListeningList-DYcQnnsG.js} +1 -1
  12. package/client/dist/assets/{Manga-Dn-CYins.js → Manga-D8CT9aO0.js} +1 -1
  13. package/client/dist/assets/{MangaInfoPage-EmQoK7Bv.js → MangaInfoPage-DGK6CYp1.js} +1 -1
  14. package/client/dist/assets/MangaReadPage-B9XoDKF9.js +1 -0
  15. package/client/dist/assets/{MangaResetProgressModal-Dian37PQ.js → MangaResetProgressModal-QjZyIAjl.js} +1 -1
  16. package/client/dist/assets/Mature-CHt_-Hz5.js +1 -0
  17. package/client/dist/assets/MediaCard-B5584Cq9.js +1 -0
  18. package/client/dist/assets/Music-HeLrEZ2d.js +1 -0
  19. package/client/dist/assets/OptionListMenu-CJ90CdwI.js +1 -0
  20. package/client/dist/assets/Player-BYtEax_z.js +56 -0
  21. package/client/dist/assets/PlayerSettings-4-cUAY4B.js +1 -0
  22. package/client/dist/assets/QueueOptionsButton-Ba0dg_82.js +1 -0
  23. package/client/dist/assets/{QueueRail-B7DeSFoA.js → QueueRail-O7f4RqjB.js} +1 -1
  24. package/client/dist/assets/Radio-DPZxQnyD.js +1 -0
  25. package/client/dist/assets/{ReadingList-BT8kUjCB.js → ReadingList-n6rr8ygy.js} +1 -1
  26. package/client/dist/assets/{ResetProgressModal-DWeiO-hs.js → ResetProgressModal-CcStlbhP.js} +1 -1
  27. package/client/dist/assets/Search-C2wrWOdy.js +1 -0
  28. package/client/dist/assets/Settings-CluUYs8U.js +21 -0
  29. package/client/dist/assets/{SkeletonGrid-B5loz7ii.js → SkeletonGrid-CLEPY9nP.js} +1 -1
  30. package/client/dist/assets/Trackers-CTGPxs0V.js +2 -0
  31. package/client/dist/assets/Tv-BwHlDdi8.js +4 -0
  32. package/client/dist/assets/Tv-ZEA45gXK.css +1 -0
  33. package/client/dist/assets/TvInfo-CXnrLekr.js +1 -0
  34. package/client/dist/assets/TvPopup-BekfiNcX.js +1 -0
  35. package/client/dist/assets/{TvSearch-BYwCf5kO.js → TvSearch-DuqR-z3v.js} +1 -1
  36. package/client/dist/assets/{TvWatchlist-BiJU6pKT.js → TvWatchlist-CBvgFrA0.js} +1 -1
  37. package/client/dist/assets/Watchlist-mj8mTOam.js +1 -0
  38. package/client/dist/assets/{hls-C11FOWHj.js → hls-Boje3IOE.js} +1 -1
  39. package/client/dist/assets/index-BXwhFWB_.js +178 -0
  40. package/client/dist/assets/useAnimeInfoData-DJ7A4B4T.js +1 -0
  41. package/client/dist/assets/useAsmr-DIwIsJXF.js +1 -0
  42. package/client/dist/assets/{useAsmrPopup-cT_Uu41e.js → useAsmrPopup-e4zNN9ig.js} +1 -1
  43. package/client/dist/assets/useMangaLibrary-C9Lci5N4.js +1 -0
  44. package/client/dist/assets/{useMangaPopup-PnmSctHu.js → useMangaPopup-B8nnpvyi.js} +1 -1
  45. package/client/dist/assets/useProviders-B5Qr4I1y.js +1 -0
  46. package/client/dist/assets/useTv-Dm8MCYlL.js +1 -0
  47. package/client/dist/assets/useTvLibrary-B7jEk2Q7.js +1 -0
  48. package/client/dist/assets/{vendor-query-BXRECSI6.js → vendor-query-BUTye89G.js} +1 -1
  49. package/client/dist/index.html +2 -2
  50. package/orchestrator.js +1 -2
  51. package/package.json +2 -6
  52. package/server/dist/app-auth.js +9 -29
  53. package/server/dist/app-hono.js +621 -0
  54. package/server/dist/config.js +0 -1
  55. package/server/dist/db/drizzle.js +32 -0
  56. package/server/dist/db/schema-anime.js +64 -0
  57. package/server/dist/db/schema-asmr.js +25 -0
  58. package/server/dist/db/schema-manga.js +31 -0
  59. package/server/dist/db/schema-tv.js +33 -0
  60. package/server/dist/db.js +75 -4
  61. package/server/dist/discord-gateway.js +1 -1
  62. package/server/dist/google.js +0 -7
  63. package/server/dist/hono/asmr.js +1 -0
  64. package/server/dist/hono/auth.js +56 -0
  65. package/server/dist/hono/music.js +419 -0
  66. package/server/dist/{controllers/proxy.controller.js → hono/proxy.js} +390 -394
  67. package/server/dist/hono/tv.js +197 -0
  68. package/server/dist/hono/watchlist.js +733 -0
  69. package/server/dist/lib/anilist.js +3 -3
  70. package/server/dist/lib/insights.js +185 -0
  71. package/server/dist/lib/ipc.js +1 -2
  72. package/server/dist/lib/kitsu.js +1 -28
  73. package/server/dist/lib/mal-import.js +291 -0
  74. package/server/dist/lib/migration.js +20 -34
  75. package/server/dist/lib/offline-db.js +36 -36
  76. package/server/dist/lib/tracker/manga-sync.service.js +21 -21
  77. package/server/dist/lib/tracker/sync.service.js +20 -20
  78. package/server/dist/lib/translate.js +79 -0
  79. package/server/dist/lib/ytmusic.js +15 -4
  80. package/server/dist/providers/title-matching.js +0 -1
  81. package/server/dist/repositories/asmr.repository.js +90 -87
  82. package/server/dist/repositories/insights.repository.js +24 -13
  83. package/server/dist/repositories/library.repository.js +33 -93
  84. package/server/dist/repositories/manga.repository.js +108 -116
  85. package/server/dist/repositories/notifications.repository.js +50 -31
  86. package/server/dist/repositories/queue.repository.js +36 -25
  87. package/server/dist/repositories/settings.repository.js +18 -8
  88. package/server/dist/repositories/shows-meta.repository.js +54 -41
  89. package/server/dist/repositories/temp-show-ids.repository.js +43 -31
  90. package/server/dist/repositories/tv.repository.js +98 -115
  91. package/server/dist/repositories/watched-episodes.repository.js +52 -20
  92. package/server/dist/repositories/watchlist.repository.js +36 -48
  93. package/server/dist/server.js +59 -151
  94. package/server/dist/sync.js +41 -4
  95. package/server/dist/trpc/context.js +7 -0
  96. package/server/dist/trpc/errors.js +21 -0
  97. package/server/dist/trpc/index.js +19 -0
  98. package/server/dist/trpc/router.js +49 -0
  99. package/server/dist/trpc/routers/asmr-library.js +122 -0
  100. package/server/dist/trpc/routers/asmr-progress.js +133 -0
  101. package/server/dist/trpc/routers/asmr.js +87 -0
  102. package/server/dist/trpc/routers/auth.js +247 -0
  103. package/server/dist/trpc/routers/continue-watching.js +83 -0
  104. package/server/dist/trpc/routers/data.js +1039 -0
  105. package/server/dist/trpc/routers/discord.js +288 -0
  106. package/server/dist/trpc/routers/discovery.js +15 -0
  107. package/server/dist/trpc/routers/insights.js +45 -0
  108. package/server/dist/trpc/routers/manga-library.js +280 -0
  109. package/server/dist/trpc/routers/manga-progress.js +181 -0
  110. package/server/dist/trpc/routers/manga.js +201 -0
  111. package/server/dist/{controllers/music.controller.js → trpc/routers/music.js} +235 -295
  112. package/server/dist/trpc/routers/notifications.js +80 -0
  113. package/server/dist/trpc/routers/progress.js +15 -0
  114. package/server/dist/trpc/routers/queue.js +95 -0
  115. package/server/dist/{routes/radio.routes.js → trpc/routers/radio.js} +30 -23
  116. package/server/dist/trpc/routers/settings.js +105 -0
  117. package/server/dist/trpc/routers/tracker.js +219 -0
  118. package/server/dist/trpc/routers/tv-library.js +145 -0
  119. package/server/dist/trpc/routers/tv-progress.js +171 -0
  120. package/server/dist/trpc/routers/tv.js +565 -0
  121. package/server/dist/trpc/routers/watchlist.js +564 -0
  122. package/server/dist/trpc/validation.js +159 -0
  123. package/server/dist/utils/security.utils.js +0 -18
  124. package/server/package.json +5 -10
  125. package/client/dist/assets/Asmr-D0EGRYsv.js +0 -2
  126. package/client/dist/assets/AsmrResetProgressModal-Gs0GmVaT.js +0 -1
  127. package/client/dist/assets/AvSyncCalibrator-D8hqarVB.js +0 -10
  128. package/client/dist/assets/Home-BnBzjFkW.js +0 -1
  129. package/client/dist/assets/Insights-i9QgY3nE.js +0 -1
  130. package/client/dist/assets/MangaReadPage-xJB8K2YU.js +0 -1
  131. package/client/dist/assets/Mature-DQtXKOXc.js +0 -1
  132. package/client/dist/assets/MediaCard-DpKoY-1j.js +0 -1
  133. package/client/dist/assets/Music-BP43Zqmq.js +0 -1
  134. package/client/dist/assets/OptionListMenu-Bj9ebsW3.js +0 -1
  135. package/client/dist/assets/Player-O2Cy2GF1.js +0 -56
  136. package/client/dist/assets/PlayerSettings-DYZ272Yp.js +0 -1
  137. package/client/dist/assets/QueueOptionsButton-lv26-6jp.js +0 -1
  138. package/client/dist/assets/Radio-qQBYnVfY.js +0 -1
  139. package/client/dist/assets/Search-BkvPYN33.js +0 -1
  140. package/client/dist/assets/Settings-CyZEBF6S.js +0 -21
  141. package/client/dist/assets/Trackers-JK-aXBYC.js +0 -2
  142. package/client/dist/assets/Tv-BwXWJxMy.js +0 -4
  143. package/client/dist/assets/Tv-C2SWcVzN.css +0 -1
  144. package/client/dist/assets/TvInfo-Dzyq6ucH.js +0 -1
  145. package/client/dist/assets/TvPopup-PlCU30FO.js +0 -1
  146. package/client/dist/assets/Watchlist-BOEeGXH9.js +0 -1
  147. package/client/dist/assets/index-CtoKRNLc.js +0 -178
  148. package/client/dist/assets/useAnimeInfoData-kr3WOIWH.js +0 -1
  149. package/client/dist/assets/useAsmr-CB9THf0m.js +0 -1
  150. package/client/dist/assets/useMangaLibrary-rM6z3_0E.js +0 -1
  151. package/client/dist/assets/useProviders-B3VB7A9M.js +0 -1
  152. package/client/dist/assets/useTv-BTUKMH7Q.js +0 -1
  153. package/client/dist/assets/useTvLibrary-C0sX-ilZ.js +0 -1
  154. package/server/dist/controllers/asmr-library.controller.js +0 -288
  155. package/server/dist/controllers/auth.controller.js +0 -225
  156. package/server/dist/controllers/data.controller.js +0 -767
  157. package/server/dist/controllers/insights.controller.js +0 -203
  158. package/server/dist/controllers/manga-library.controller.js +0 -350
  159. package/server/dist/controllers/settings.controller.js +0 -609
  160. package/server/dist/controllers/tv-library.controller.js +0 -314
  161. package/server/dist/controllers/watchlist.controller.js +0 -1069
  162. package/server/dist/request-logger.js +0 -16
  163. package/server/dist/routes/asmr-library.routes.js +0 -23
  164. package/server/dist/routes/asmr.routes.js +0 -81
  165. package/server/dist/routes/auth.routes.js +0 -25
  166. package/server/dist/routes/data.routes.js +0 -47
  167. package/server/dist/routes/discord-gateway.routes.js +0 -51
  168. package/server/dist/routes/insights.routes.js +0 -35
  169. package/server/dist/routes/lan-auth.routes.js +0 -46
  170. package/server/dist/routes/manga-library.routes.js +0 -25
  171. package/server/dist/routes/manga.routes.js +0 -141
  172. package/server/dist/routes/music.routes.js +0 -20
  173. package/server/dist/routes/providers.routes.js +0 -17
  174. package/server/dist/routes/proxy.routes.js +0 -12
  175. package/server/dist/routes/settings.routes.js +0 -24
  176. package/server/dist/routes/tracker.routes.js +0 -287
  177. package/server/dist/routes/translate.routes.js +0 -88
  178. package/server/dist/routes/tv-library.routes.js +0 -23
  179. package/server/dist/routes/tv.routes.js +0 -629
  180. package/server/dist/routes/watchlist.routes.js +0 -341
@@ -0,0 +1,159 @@
1
+ export function defineSchema(parse) {
2
+ return {
3
+ '~standard': {
4
+ version: 1,
5
+ vendor: 'dango',
6
+ types: undefined,
7
+ validate(value) {
8
+ try {
9
+ return { value: parse(value) };
10
+ }
11
+ catch (err) {
12
+ return { issues: [{ message: err instanceof Error ? err.message : 'Invalid input' }] };
13
+ }
14
+ },
15
+ },
16
+ };
17
+ }
18
+ function readKey(value) {
19
+ if (typeof value !== 'object' || value === null)
20
+ throw new Error('Expected an object');
21
+ const key = value.key;
22
+ if (typeof key !== 'string' || key.length === 0)
23
+ throw new Error('key must be a string');
24
+ return key;
25
+ }
26
+ export function reqStr(obj, name) {
27
+ const value = obj[name];
28
+ if (typeof value !== 'string' || value.length === 0) {
29
+ throw new Error(`${name} must be a string`);
30
+ }
31
+ return value;
32
+ }
33
+ export function optStr(obj, name) {
34
+ const value = obj[name];
35
+ if (value === undefined || value === null)
36
+ return undefined;
37
+ return String(value);
38
+ }
39
+ function reqEpNum(obj, name) {
40
+ const value = obj[name];
41
+ if ((typeof value !== 'string' && typeof value !== 'number') || String(value).length === 0) {
42
+ throw new Error(`${name} must be a string`);
43
+ }
44
+ return String(value);
45
+ }
46
+ export function reqStrArray(obj, name, nonEmpty) {
47
+ const value = obj[name];
48
+ if (!Array.isArray(value) || (nonEmpty && value.length === 0)) {
49
+ throw new Error(`${name} must be ${nonEmpty ? 'a non-empty ' : 'an '}array`);
50
+ }
51
+ return value.map((ep) => String(ep));
52
+ }
53
+ export function reqObj(value) {
54
+ if (typeof value !== 'object' || value === null)
55
+ throw new Error('Expected an object');
56
+ return value;
57
+ }
58
+ export const keyInput = () => defineSchema((value) => ({ key: readKey(value) }));
59
+ export const idInput = () => defineSchema((value) => ({ id: reqStr(reqObj(value), 'id') }));
60
+ export const showIdInput = () => defineSchema((value) => ({
61
+ showId: reqStr(reqObj(value), 'showId'),
62
+ }));
63
+ export const episodeProgressInput = () => defineSchema((value) => {
64
+ const obj = reqObj(value);
65
+ return { showId: reqStr(obj, 'showId'), episodeNumber: reqEpNum(obj, 'episodeNumber') };
66
+ });
67
+ export const idsInput = () => defineSchema((value) => ({
68
+ ids: [...new Set(reqStrArray(reqObj(value), 'ids', true))],
69
+ }));
70
+ export const watchlistAddInput = () => defineSchema((value) => {
71
+ const obj = reqObj(value);
72
+ const out = { id: reqStr(obj, 'id'), name: reqStr(obj, 'name') };
73
+ const status = optStr(obj, 'status');
74
+ if (status !== undefined)
75
+ out.status = status;
76
+ const thumbnail = optStr(obj, 'thumbnail');
77
+ if (thumbnail !== undefined)
78
+ out.thumbnail = thumbnail;
79
+ const nativeName = optStr(obj, 'nativeName');
80
+ if (nativeName !== undefined)
81
+ out.nativeName = nativeName;
82
+ const englishName = optStr(obj, 'englishName');
83
+ if (englishName !== undefined)
84
+ out.englishName = englishName;
85
+ const type = optStr(obj, 'type');
86
+ if (type !== undefined)
87
+ out.type = type;
88
+ if (typeof obj.isAdult === 'boolean')
89
+ out.isAdult = obj.isAdult;
90
+ return out;
91
+ });
92
+ export const watchlistStatusInput = () => defineSchema((value) => {
93
+ const obj = reqObj(value);
94
+ return { id: reqStr(obj, 'id'), status: reqStr(obj, 'status') };
95
+ });
96
+ export const watchlistBatchStatusInput = () => defineSchema((value) => {
97
+ const obj = reqObj(value);
98
+ return { ids: [...new Set(reqStrArray(obj, 'ids', true))], status: reqStr(obj, 'status') };
99
+ });
100
+ function readMeta(obj) {
101
+ return {
102
+ showName: optStr(obj, 'showName'),
103
+ showThumbnail: optStr(obj, 'showThumbnail'),
104
+ nativeName: optStr(obj, 'nativeName'),
105
+ englishName: optStr(obj, 'englishName'),
106
+ type: optStr(obj, 'type'),
107
+ };
108
+ }
109
+ export const queueAddInput = () => defineSchema((value) => {
110
+ const obj = reqObj(value);
111
+ return {
112
+ ...readMeta(obj),
113
+ showId: reqStr(obj, 'showId'),
114
+ episodeNumber: reqEpNum(obj, 'episodeNumber'),
115
+ };
116
+ });
117
+ export const queueBatchInput = () => defineSchema((value) => {
118
+ const obj = reqObj(value);
119
+ return {
120
+ ...readMeta(obj),
121
+ showId: reqStr(obj, 'showId'),
122
+ episodeNumbers: reqStrArray(obj, 'episodeNumbers', true),
123
+ };
124
+ });
125
+ export const queueRemoveInput = () => defineSchema((value) => {
126
+ const obj = reqObj(value);
127
+ return { showId: reqStr(obj, 'showId'), episodeNumber: reqEpNum(obj, 'episodeNumber') };
128
+ });
129
+ export const queueRemoveManyInput = () => defineSchema((value) => {
130
+ const obj = reqObj(value);
131
+ const out = { showId: reqStr(obj, 'showId') };
132
+ if (obj.episodeNumbers !== undefined)
133
+ out.episodeNumbers = reqStrArray(obj, 'episodeNumbers', false);
134
+ return out;
135
+ });
136
+ export const queueReorderInput = () => defineSchema((value) => {
137
+ if (!Array.isArray(value))
138
+ throw new Error('items must be an array');
139
+ return value.map((item) => {
140
+ const entry = reqObj(item);
141
+ const out = {};
142
+ if (typeof entry.id === 'number')
143
+ out.id = entry.id;
144
+ if (entry.showId !== undefined)
145
+ out.showId = String(entry.showId);
146
+ if (entry.episodeNumber !== undefined)
147
+ out.episodeNumber = String(entry.episodeNumber);
148
+ return out;
149
+ });
150
+ });
151
+ export const setSettingInput = () => defineSchema((value) => {
152
+ if (typeof value !== 'object' || value === null)
153
+ throw new Error('Expected an object');
154
+ return { key: readKey(value), value: value.value };
155
+ });
156
+ export const notificationDismissInput = () => defineSchema((value) => {
157
+ const obj = reqObj(value);
158
+ return { showId: reqStr(obj, 'showId'), episodeNumber: reqEpNum(obj, 'episodeNumber') };
159
+ });
@@ -74,21 +74,3 @@ export function isAllowedOrigin(origin) {
74
74
  return false;
75
75
  }
76
76
  }
77
- export function crossSiteProtectionMiddleware(req, res, next) {
78
- const method = req.method.toUpperCase();
79
- const isMutating = ['POST', 'PUT', 'DELETE', 'PATCH'].includes(method);
80
- if (!isMutating)
81
- return next();
82
- const secFetchSite = req.headers['sec-fetch-site'];
83
- if (secFetchSite === 'cross-site') {
84
- const origin = req.headers.origin;
85
- if (!isAllowedOrigin(origin)) {
86
- return res.status(403).json({ error: 'Forbidden: cross-site request rejected' });
87
- }
88
- }
89
- const origin = req.headers.origin;
90
- if (origin && !isAllowedOrigin(origin)) {
91
- return res.status(403).json({ error: 'Forbidden: cross-origin request rejected' });
92
- }
93
- next();
94
- }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dango-server",
3
3
  "private": true,
4
- "version": "3.3.8",
4
+ "version": "3.4.0",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=22.12.0"
@@ -14,28 +14,23 @@
14
14
  "lint": "eslint ."
15
15
  },
16
16
  "dependencies": {
17
+ "@hono/node-server": "^2.1.1",
17
18
  "@octokit/auth-oauth-device": "^8.0.3",
18
19
  "@octokit/rest": "^22.0.1",
20
+ "@trpc/server": "11.19.0",
19
21
  "@xhayper/discord-rpc": "^1.3.4",
20
22
  "cheerio": "^1.2.0",
21
- "compression": "^1.8.1",
22
- "cors": "^2.8.5",
23
23
  "dotenv": "^17.4.2",
24
- "express": "^5.1.0",
24
+ "drizzle-orm": "0.45.3",
25
25
  "fast-xml-parser": "^5.11.1",
26
26
  "got-scraping": "^3.2.9",
27
+ "hono": "^4.13.9",
27
28
  "lru-cache": "^11.5.2",
28
- "multer": "^2.0.2",
29
29
  "pino": "^10.3.1",
30
30
  "ws": "^8.18.0",
31
31
  "youtubei.js": "^18.1.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/compression": "^1.8.1",
35
- "@types/cors": "^2.8.19",
36
- "@types/express": "^5.0.0",
37
- "@types/express-serve-static-core": "^5.1.3",
38
- "@types/multer": "^2.1.0",
39
34
  "@types/node": "^22.5.0",
40
35
  "@types/ws": "^8.5.10",
41
36
  "pino-pretty": "^13.1.1",
@@ -1,2 +0,0 @@
1
- import{T as We,u as e,A as _,d as h,h as C,a as Ke,g as $e,q as W,S as O,$ as qe,n as ft,o as bt}from"./vendor-core-8R2fFbyN.js";import{I as y}from"./vendor-icons-CDMuNDeL.js";import{u as vt}from"./vendor-query-BXRECSI6.js";import{e as me,B as he,M as xe,R,z as oe,U as yt,T as Ve}from"./index-CtoKRNLc.js";import{M as kt}from"./MediaCard-DpKoY-1j.js";import{c as Ge,a as Qe,d as wt,e as Ze,f as Xe,g as Nt,h as Ct,i as St,j as Tt,k as ze,l as Re}from"./useAsmr-CB9THf0m.js";import{a as t}from"./Asmr.module-ChUXDZKx.js";import{u as At,A as Mt}from"./useAsmrPopup-cT_Uu41e.js";import{l as xt}from"./hls-C11FOWHj.js";import"./vendor-ui-CUDCvRS_.js";import"./useIsMobile-Dm_b6Ob3.js";const Bt=({work:s,onClose:o,onPlay:k,t:v})=>{const{data:c,isLoading:d}=Ge(s.id||null),f=Qe(s),{data:A}=wt(f||void 0),{toggle:w,bookmarkedIds:T}=Ze(),{data:I}=Xe(f||void 0),L=f?T.has(f):!!A?.inLibrary,S=We(()=>(c?.description||s.description||"").split(`
2
- `).map(l=>{const m=l.indexOf(":");return m===-1?null:{label:l.slice(0,m),value:l.slice(m+1).trim()}}).filter(l=>!!l&&!!l.value),[c?.description,s.description]),g=c?.tracks||[],N=We(()=>{const l=I?.progress??[];return l.length>0?l.reduce((m,u)=>m.updatedAt>=u.updatedAt?m:u):null},[I]),M=N&&N.trackIndex<g.length?N.trackIndex:null;return e("div",{className:t.detailOverlay,onClick:o,children:e("div",{className:t.detailModal,onClick:l=>l.stopPropagation(),children:[e("button",{className:t.detailClose,onClick:o,"aria-label":"Close",children:e(y,{name:"times"})}),e("div",{className:t.detailHeader,children:[s.thumbnail?e("img",{className:t.detailCover,src:s.thumbnail,alt:s.name,decoding:"async"}):e("div",{className:`${t.detailCover} ${t.thumbPlaceholder}`}),e("div",{className:t.detailInfo,children:[e("h2",{className:t.detailTitle,children:v?v(s.name):s.name}),e("p",{className:t.detailRj,children:s.id}),S.map(l=>l.label==="Tags"?e("p",{className:t.metaRow,children:[e("span",{className:t.metaLabel,children:"Tags"}),e("span",{className:t.tagChips,children:l.value.split(", ").map(m=>e("span",{className:t.tagChip,children:m},m))})]},l.label):e("p",{className:t.metaRow,children:[e("span",{className:t.metaLabel,children:l.label}),l.value]},l.label))]})]}),e("div",{className:t.tracksSection,children:[e("h3",{className:t.tracksHeading,children:d?"Loading tracks…":`Tracks (${g.length})`}),!d&&(g.length>0?e("ul",{className:t.trackList,children:g.map((l,m)=>e("li",{children:e("button",{className:t.trackRow,onClick:()=>k(s,g,m),children:[e(y,{name:"play",className:t.trackIcon}),e("span",{className:t.trackLabel,children:l.resolutionStr}),e("span",{className:t.trackType,children:l.hls?"HLS":"MP3"})]})},l.link))}):e("p",{className:t.noTracks,children:"No audio streams available for this work."}))]}),e("div",{className:t.detailActions,children:[!d&&g.length>0&&e("button",{className:t.playAllBtn,onClick:()=>k(s,g,0),children:[e(y,{name:"play"})," Play from start"]}),!d&&M!==null&&N&&e("button",{className:t.playAllBtn,onClick:()=>k(s,g,M),children:[e(y,{name:"history"})," Resume track ",M+1," ·"," ",me(N.currentTime),N.duration>0?` / ${me(N.duration)}`:""]}),f&&e("button",{className:t.playAllBtn,onClick:()=>w({rjCode:f,title:s.name,thumbnail:s.thumbnail||"",isAdult:!!s.isAdult}),"aria-pressed":L,children:[e(y,{name:L?"check":"plus"})," ",L?"In listening list":"Add to listening list"]})]})]})})},Lt=({title:s,images:o,chapters:k,tracks:v,trackIndex:c,expanded:d,isAdult:f,rjCode:A,t:w,onTrackChange:T,onExpandedChange:I,onClose:L})=>{const S=_(null),g=_(null),[N,M]=h(!1),[l,m]=h(0),[u,P]=h(0),[p,U]=h(0),[B,Y]=h(!0),[D,j]=h(0),[ae,ie]=h(new Set),[q,ne]=h(!1),[pe,$]=h(!0),re=_("");re.current||(re.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`asmr-${Date.now()}-${Math.random().toString(36).slice(2)}`);const[F,Ne]=h(()=>{const a=parseFloat(localStorage.getItem("asmrVolume")||"");return Number.isFinite(a)?a:1}),ge=_(F);C(()=>{ge.current=F},[F]);const fe=Ke(),V=$e.useMemo(()=>A?Nt(A):"",[A]),Ce=Ct(),ce=St(),{data:Se}=Xe(V||void 0),[Be,be]=h(!1),[H,Le]=h(0),[Pe,G]=h(!1),ve=_(""),J=_(null),K=_(0),Q=_(0),de=_(0),Z=v[c],X=Z?.link,Te=Z?.hls,n=Z?.resolutionStr||"",i=o.length>0,x=`${V}:${c}`,se=$e.useMemo(()=>(Se?.progress??[]).find(r=>r.trackIndex===c)??null,[Se,c]),ee=_({workId:"",trackIndex:0,trackLabel:""});ee.current={workId:V,trackIndex:c,trackLabel:n};const le=W((a,r,b,E=!1)=>{!a.workId||!b||b<10||!E&&Math.abs(r-K.current)<5||(K.current=r,Ce.mutate({workId:a.workId,trackIndex:a.trackIndex,trackLabel:a.trackLabel,currentTime:Math.floor(r),duration:Math.floor(b),title:s,thumbnail:o[0]||"",rjCode:a.workId,isAdult:f?1:0}))},[Ce,s,o,f]),z=W((a=!1)=>{J.current&&(clearTimeout(J.current),J.current=null),le(ee.current,Q.current,de.current,a)},[le]),ye=_(z);ye.current=z;const Ee=_(le);Ee.current=le;const ue=W(()=>{g.current&&(g.current.destroy(),g.current=null)},[]);C(()=>{const a=S.current;if(!a||!X)return;const r={workId:V,trackIndex:c,trackLabel:n},b=()=>{J.current&&(clearTimeout(J.current),J.current=null),Ee.current(r,Q.current,de.current,!0)};if(m(0),P(0),U(0),M(!1),Q.current=0,de.current=0,K.current=0,ue(),Te){let E=!1;return(async()=>{const te=await xt();if(!E)if(te&&te.isSupported()){const we=new te({enableWorker:!0});g.current=we,we.loadSource(X),we.attachMedia(a),a.play().catch(()=>M(!1))}else a.src=X,a.load(),a.volume=ge.current,a.play().catch(()=>M(!1))})(),()=>{E=!0,ue(),a.removeAttribute("src"),b()}}else a.src=X;return a.load(),a.volume=ge.current,a.play().catch(()=>M(!1)),()=>{ue(),a.removeAttribute("src"),b()}},[X,Te,ue,V,c,n]),C(()=>()=>ue(),[ue]),C(()=>{const a=()=>{document.visibilityState==="hidden"&&ye.current()},r=()=>ye.current();return document.addEventListener("visibilitychange",a),window.addEventListener("pagehide",r),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("pagehide",r)}},[]),C(()=>{if(!se||ve.current===x||!(u>0))return;const a=se.currentTime||0,r=se.duration||u;a>=10&&r-a>=15&&Q.current<a?(ve.current=x,Le(a),be(!0)):ve.current=x},[se,u,x]),C(()=>{const a=S.current;a&&(a.volume=F)},[F]),C(()=>{if(d)return document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")},[d]),C(()=>{j(0)},[o]),C(()=>{d&&$(!0)},[d]),C(()=>{q&&$(!0)},[q]);const Ae=W(a=>{if(!s||v.length===0)return;const r=v[c],b=r?`${r.resolutionStr} (${c+1}/${v.length})`:"",E=S.current,te=E?E.currentTime:0,we=E&&E.duration||0,gt=o[0]||"";fetch("/api/discord/asmr",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:s,trackLabel:b,isPlaying:a,thumbnail:gt,thumbnails:o,currentTime:te,duration:we,isAdult:!!f,rjCode:A||"",sessionId:re.current})}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:re.current})}).catch(()=>{})},[s,v,c,o,f,A]);C(()=>{Ae(N)},[Ae,N,c,s,d]),C(()=>{if(!N)return;const a=window.setInterval(()=>Ae(!0),15e3);return()=>window.clearInterval(a)},[N,Ae]),C(()=>{const a=re.current,r=()=>{if(!a)return;const te=JSON.stringify({sessionId:a});navigator.sendBeacon?(navigator.sendBeacon("/api/discord/clear",new Blob([te],{type:"application/json"})),navigator.sendBeacon("/api/discord/heartbeat",new Blob([JSON.stringify({sessionId:a,bye:!0})],{type:"application/json"}))):(fetch("/api/discord/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:te,keepalive:!0}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:a,bye:!0}),keepalive:!0}).catch(()=>{}))},b=()=>r(),E=()=>{document.visibilityState==="hidden"&&r()};return window.addEventListener("pagehide",b),window.addEventListener("beforeunload",b),document.addEventListener("visibilitychange",E),()=>{window.removeEventListener("pagehide",b),window.removeEventListener("beforeunload",b),document.removeEventListener("visibilitychange",E),r()}},[]);const Me=W(a=>{ie(r=>{if(r.has(a))return r;const b=new Set(r);return b.add(a),b})},[]),tt=W((a,r)=>{a&&a.complete&&a.naturalWidth>0&&Me(r)},[Me]);C(()=>{if(!d)return;const a=r=>{if(r.key==="Escape"){q?ne(!1):I(!1);return}!B||o.length<2||(r.key==="ArrowLeft"&&j(b=>Math.max(0,b-1)),r.key==="ArrowRight"&&j(b=>Math.min(o.length-1,b+1)))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[d,B,o.length,q,I]);const at=()=>{const a=S.current;a&&(a.paused?a.play().catch(()=>{}):a.pause())},nt=a=>{const r=S.current;if(!r||!u)return;const b=parseFloat(a.target.value);r.currentTime=b,m(b)},rt=()=>{z(!0),c<v.length-1?T(c+1):G(!0)},st=a=>{const r=a.currentTarget.currentTime;Q.current=r,m(r),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>ye.current(),5e3)},lt=()=>{M(!1),ye.current()},ot=a=>{const r=a.currentTarget.duration;de.current=Number.isFinite(r)?r:0,P(a.currentTarget.duration)},it=W(()=>{const a=S.current;a&&H>0&&(a.currentTime=H,Q.current=H,a.play().catch(()=>{})),be(!1)},[H]),je=W(()=>{be(!1)},[]),ct=W(()=>{V&&ce.mutate({rjCode:V,title:s,thumbnail:o[0]||"",status:"Completed",isAdult:!!f,silent:!0}),G(!1),L(),fe("/")},[V,ce,s,o,f,L,fe]),dt=k.reduce((a,r,b)=>l>=r.time?b:a,-1),ut=a=>{const r=S.current;r&&(r.currentTime=a,m(a))},_e=a=>{const r=S.current;if(!r)return;const b=Number.isFinite(r.currentTime)?r.currentTime:l,E=Math.max(0,Math.min(u||1/0,b+a));r.currentTime=E,m(E),$(!0)},Oe=u?Math.min(100,l/u*100):0,mt=u?Math.min(100,Math.max(Oe,p/u*100)):0,ht=e(O,{children:[e("div",{className:t.playerButtons,children:[e("button",{className:t.playerBtn,onClick:()=>T(Math.max(0,c-1)),disabled:c===0,"aria-label":"Previous track",children:e(y,{name:"step-backward"})}),e("button",{className:`${t.playerBtn} ${t.seekBtn}`,onClick:()=>_e(-10),"aria-label":"Seek back 10 seconds",title:"Back 10s",children:[e(y,{name:"undo"}),e("span",{className:t.seekBtnLabel,children:"10"})]}),e("button",{className:`${t.playerBtn} ${t.playBtn}`,onClick:at,"aria-label":N?"Pause":"Play",children:N?e(y,{name:"pause"}):e(y,{name:"play"})}),e("button",{className:`${t.playerBtn} ${t.seekBtn}`,onClick:()=>_e(10),"aria-label":"Seek forward 10 seconds",title:"Forward 10s",children:[e(y,{name:"redo"}),e("span",{className:t.seekBtnLabel,children:"10"})]}),e("button",{className:t.playerBtn,onClick:()=>T(Math.min(v.length-1,c+1)),disabled:c>=v.length-1,"aria-label":"Next track",children:e(y,{name:"step-forward"})})]}),e("div",{className:t.seekRow,children:[e("span",{className:t.timeLabel,children:me(l)}),e("input",{className:t.seekBar,type:"range",min:0,max:u||0,step:.1,value:Math.min(l,u||0),onChange:nt,style:{"--played-percent":`${Oe}%`,"--buffered-percent":`${mt}%`},"aria-label":"Seek"}),e("span",{className:t.timeLabel,children:me(u)})]})]}),Fe=e(O,{children:[e("button",{className:`${t.playerBtn} ${t.playerToggle}`,onClick:()=>I(!d),"aria-label":d?"Minimize player":"Expand player",title:d?"Minimize to browse":"Expand",children:d?e(y,{name:"chevron-down"}):e(y,{name:"chevron-up"})}),e("div",{className:t.playerInfo,children:[e("p",{className:t.playerTitle,title:s,children:w?w(s):s}),e("p",{className:t.playerTrack,children:[Z?.resolutionStr||"",v.length>1?` (${c+1}/${v.length})`:""]})]}),e("div",{className:t.playerControls,children:ht}),e("div",{className:t.playerRight,children:[F===0?e(y,{name:"volume-mute",className:t.volumeIcon}):F<.5?e(y,{name:"volume-down",className:t.volumeIcon}):e(y,{name:"volume-up",className:t.volumeIcon}),e("input",{className:t.volumeBar,type:"range",min:0,max:1,step:.01,value:F,onChange:a=>{const r=parseFloat(a.target.value);Ne(r),localStorage.setItem("asmrVolume",String(r))},style:{"--volume-percent":`${F*100}%`},"aria-label":"Volume"})]}),e("div",{className:t.playerActions,children:[d&&i&&e("button",{className:t.playerBtn,onClick:()=>Y(a=>!a),"aria-label":B?"Hide images":"Show images",title:B?"Hide images":"Show images",children:B?e(y,{name:"eye-slash"}):e(y,{name:"image"})}),d&&k.length>0&&e("button",{className:`${t.playerBtn} ${q?t.playerBtnActive:""}`,onClick:()=>ne(a=>!a),"aria-label":q?"Hide bookmarks":"Show bookmarks",title:"Timestamps",children:e(y,{name:"list-ol"})}),e("button",{className:t.playerBtn,onClick:L,"aria-label":"Close player",children:e(y,{name:"times"})})]})]}),He=e("audio",{ref:S,preload:"metadata",onPlay:()=>M(!0),onPause:lt,onTimeUpdate:st,onLoadedMetadata:ot,onProgress:a=>{const r=a.currentTarget;r.buffered.length>0&&U(r.buffered.end(r.buffered.length-1))},onEnded:rt}),Ue=e(xe,{isOpen:Be,onClose:je,title:"Resume Listening",children:e("div",{style:{padding:"1rem",textAlign:"center"},children:[e("p",{children:["You were at ",e("strong",{children:me(H)}),Z?.resolutionStr?` in ${Z.resolutionStr}`:""]}),e("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[e(he,{variant:"secondary",onClick:je,children:"Start from Beginning"}),e(he,{onClick:it,children:"Resume"})]})]})}),De=e(xe,{isOpen:Pe,onClose:()=>G(!1),title:"Finished!",children:e("div",{style:{padding:"1rem",textAlign:"center"},children:[e(y,{name:"check-circle",size:48,style:{color:"var(--accent-lighter)",marginBottom:"0.5rem"}}),e("p",{style:{fontSize:"1.1rem",fontWeight:600},children:w?w(s):s}),e("p",{style:{color:"var(--text-secondary)"},children:"You finished this work!"}),e("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[e(he,{variant:"secondary",onClick:()=>G(!1),children:"Close"}),e(he,{onClick:ct,children:"Mark Completed & Back to Home"})]})]})});if(!d)return qe(e(O,{children:[He,e("div",{className:t.playerBar,children:Fe}),Ue,De]}),document.body);const ke=Math.min(D,Math.max(0,o.length-1)),Je=o[ke],pt=B&&i&&!!Je&&!ae.has(Je);return qe(e(O,{children:[He,Ue,De,e("div",{className:`${t.npOverlay} ${pe?"":t.npOverlayControlsHidden}`,children:[e("div",{className:`${t.npStage} ${!B||!i?t.npStageBlank:""}`,onClick:()=>$(a=>!a),children:B&&i&&e(O,{children:[e("div",{className:t.sliderViewport,children:[e("div",{className:t.sliderTrack,style:{transform:`translateX(-${ke*100}%)`},children:o.map(a=>e("div",{className:t.slide,children:e("img",{ref:r=>tt(r,a),src:a,alt:`${w?w(s):s} — work image`,loading:"lazy",decoding:"async",draggable:!1,onLoad:()=>Me(a),onError:()=>Me(a),className:`${t.slideImg} ${ae.has(a)?t.slideImgLoaded:""}`})},a))}),pt&&e("span",{className:t.slideSpinner,"aria-label":"Loading image"})]}),o.length>1&&e(O,{children:[e("button",{className:`${t.npArrow} ${t.npArrowLeft}`,onClick:a=>{a.stopPropagation(),j(r=>Math.max(0,r-1)),$(!0)},disabled:ke===0,"aria-label":"Previous image",children:e(y,{name:"chevron-left"})}),e("button",{className:`${t.npArrow} ${t.npArrowRight}`,onClick:a=>{a.stopPropagation(),j(r=>Math.min(o.length-1,r+1)),$(!0)},disabled:ke===o.length-1,"aria-label":"Next image",children:e(y,{name:"chevron-right"})}),e("span",{className:t.npImageCount,onClick:a=>a.stopPropagation(),children:[ke+1," / ",o.length]})]})]})}),e("div",{className:`${t.playerBar} ${t.playerBarDocked} ${pe?"":t.playerBarDockedHidden}`,onClick:a=>a.stopPropagation(),children:[Fe,q&&e(O,{children:[e("div",{className:t.npBackdrop,onClick:()=>ne(!1)}),e("div",{className:t.chapterPanel,children:k.map((a,r)=>e("button",{className:`${t.chapterRow} ${r===dt?t.chapterRowActive:""}`,title:w?w(a.label):a.label,onClick:()=>{ut(a.time),ne(!1)},children:[e("span",{className:t.chapterRowTime,children:me(a.time)}),e("span",{className:t.chapterRowLabel,title:w?w(a.label):a.label,children:w?w(a.label):a.label})]},`${a.time}-${r}`))})]})]})]})]}),document.body)},Pt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Rt=s=>{try{return JSON.parse(s.detail)}catch{return null}},It=({isOpen:s,onClose:o,onSuccess:k})=>{const[v,c]=h(1),[d,f]=h(typeof navigator<"u"?navigator.userAgent:""),[A,w]=h(""),[T,I]=h(!1),[L,S]=h(!1),g=_(null),N=typeof navigator<"u"?navigator.userAgent:"",M=/android/i.test(N),l=/firefox|fxios/i.test(N)&&!M,m=!l&&!M&&/chrome|chromium|edg|brave/i.test(N),u=l||m;C(()=>{s&&(c(1),f(typeof navigator<"u"?navigator.userAgent:""),w(""),I(!1),S(!1))},[s]),C(()=>()=>{g.current&&(window.removeEventListener("dango:jasmr-cookie",g.current),g.current=null)},[]);const P=async()=>{localStorage.setItem("jasmr_ua",d),window.open("https://japaneseasmr.com","_blank","noopener,noreferrer"),c(2)},p=()=>{if(L)return;S(!0);const B=window.setTimeout(()=>{S(!1),g.current&&(window.removeEventListener("dango:jasmr-cookie",g.current),g.current=null),oe.error("Helper not detected — install it via about:debugging first.")},3e3),Y=D=>{window.clearTimeout(B),window.removeEventListener("dango:jasmr-cookie",Y),g.current=null,S(!1);const j=Rt(D);if(j?.ok&&j.cookie)w(j.cookie),oe.success("Cookie extracted from helper!");else if(j?.error==="NO_COOKIE"){const ae=j.debug?.stores?.length??0,ie=j.debug?.names??[];oe.error(`Helper found no cf_clearance (checked ${ae} stores, saw: ${ie.join(", ")||"none"}) — solve the challenge on the JapaneseASMR tab first.`)}else oe.error("Helper request failed — try again.")};g.current=Y,window.addEventListener("dango:jasmr-cookie",Y),window.dispatchEvent(new CustomEvent("dango:get-jasmr-cookie"))},U=async()=>{if(!A.trim()){oe.error("Please enter the cf_clearance cookie");return}I(!0);try{localStorage.setItem("jasmr_cookie",A.trim()),oe.success("Cookie updated successfully!"),k?.(),o()}catch{oe.error("Failed to save cookie")}finally{I(!1)}};return e(xe,{isOpen:s,onClose:o,title:"JapaneseASMR Verification Required",children:e("div",{className:R.container,children:v===1?e(O,{children:[e("p",{children:["JapaneseASMR is protected by a Cloudflare challenge. Solve it once in your browser and paste the ",e("strong",{children:"cf_clearance"})," cookie so the app can load the site for you."]}),e("div",{className:R.field,children:[e("label",{children:"Your User-Agent (must match the browser you solve the challenge with):"}),e("textarea",{value:d,onChange:B=>f(B.target.value),rows:3,className:R.textarea})]}),e("div",{className:R.actions,children:[e("button",{className:R.secondaryButton,onClick:o,children:"Cancel"}),e("button",{className:R.button,onClick:P,children:"Start Verification (Opens JapaneseASMR)"})]})]}):e(O,{children:[e("p",{children:["1. Solve the challenge on the ",e("strong",{children:"JapaneseASMR tab"})," (keep that tab open).",e("br",{}),"2. Copy the ",e("strong",{children:"cf_clearance"})," cookie value using one of these:",e("br",{}),e("br",{}),e("strong",{children:"Chrome / Edge — DevTools:"})," press ",e("code",{children:"F12"})," →"," ",e("strong",{children:"Application"})," → ",e("strong",{children:"Cookies"})," →"," ",e("code",{children:"https://japaneseasmr.com"}),". Find ",e("strong",{children:"cf_clearance"}),", double-click its ",e("strong",{children:"Value"})," to select it, then copy.",e("br",{}),e("br",{}),e("strong",{children:"Firefox — Storage Inspector:"})," press ",e("code",{children:"F12"})," →"," ",e("strong",{children:"Storage"})," → ",e("strong",{children:"Cookies"})," →"," ",e("code",{children:"https://japaneseasmr.com"}),". Find ",e("strong",{children:"cf_clearance"}),", right-click the value → ",e("strong",{children:"Copy Value"}),".",e("br",{}),e("br",{}),e("strong",{children:"Either browser — extension:"})," open"," ",e("strong",{children:"Cookie Manager"})," while on the JapaneseASMR tab, find"," ",e("strong",{children:"cf_clearance"}),", and copy its value (or use the extension's export).",e("br",{}),e("br",{}),"3. Paste it below. Copy ",e("strong",{children:"only the value"})," — remove any"," ",e("code",{children:"cf_clearance="})," prefix or quotes if they were included."]}),u&&e("div",{className:R.hint,children:[e("strong",{children:"Dango helper (one-time setup):"})," ",l?e(O,{children:["type ",e("code",{children:"about:debugging"})," in the address bar →"," ",e("strong",{children:"This Firefox"})," → ",e("strong",{children:"Load Temporary Add-on"})," ","→ open the ",e("code",{children:"dango-extension/firefox"})," folder and pick"," ",e("code",{children:"manifest.json"}),". (Temporary helpers unload when Firefox closes — repeat after a restart.)"]}):e(O,{children:["type ",e("code",{children:"chrome://extensions"})," in the address bar → enable"," ",e("strong",{children:"Developer mode"})," → ",e("strong",{children:"Load unpacked"})," → open the ",e("code",{children:"dango-extension/chrome"})," folder. (Unpacked helpers show a developer-mode notice — expected.)"]})," ","Use this link to download the extension and extract it:"," ",e("a",{href:Pt,target:"_blank",rel:"noreferrer",className:R.link,children:"dango-extension.zip"}),". Then click Extract below and the field fills itself.",e("div",{className:R.actions,children:e("button",{className:R.button,onClick:p,disabled:L,type:"button",children:L?"Extracting…":"Extract cookie from helper"})})]}),e("div",{className:R.field,children:[e("label",{children:"cf_clearance cookie value:"}),e("input",{type:"text",value:A,onChange:B=>w(B.target.value),placeholder:"e.g. xxxxxxxx.xxxxxxxx.xxxxxxx-xxxxxxx",className:R.input})]}),e("div",{className:R.actions,children:[e("button",{className:R.secondaryButton,onClick:o,children:"Cancel"}),e("button",{className:R.secondaryButton,onClick:()=>c(1),children:"Back"}),e("button",{className:R.button,onClick:U,disabled:T,children:T?"Saving...":"Submit"})]})]})})})},et="asmrTranslateCache",$t=10080*60*1e3;function Et(){try{const s=localStorage.getItem(et);if(!s)return new Map;const o=JSON.parse(s);return new Map(Object.entries(o))}catch{return new Map}}function jt(s){try{const o={};for(const[k,v]of s)o[k]=v;localStorage.setItem(et,JSON.stringify(o))}catch{}}function Ye(s){return/[\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FAF]/.test(s)}async function _t(s){const o=s.map(d=>d.trim()).filter(Boolean);if(o.length===0)return new Map;const k=await fetch("/api/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({texts:o,source:"ja",target:"en"})});if(!k.ok)throw new Error(`translate ${k.status}`);const v=await k.json(),c=new Map;for(const[d,f]of Object.entries(v.translations||{}))c.set(d,f);for(const d of o)c.has(d)||c.set(d,d);return c}function Ot(s,o){const[k,v]=h(new Map),[c,d]=h(!1),f=_(null),A=s.join("");return C(()=>{const T=A?A.split(""):[];if(!o||T.length===0){v(new Map),d(!1);return}const I=Array.from(new Set(T.map(l=>l.trim()).filter(Boolean).filter(Ye)));if(I.length===0){v(new Map);return}f.current||(f.current=Et());const L=Date.now(),S=new Map,g=[];for(const l of I){const m=f.current.get(l);m&&L-m.ts<$t?S.set(l,m.t):g.push(l)}if(g.length===0){v(S);return}let N=!1;d(!0);const M=[];for(let l=0;l<g.length;l+=15)M.push(g.slice(l,l+15));return(async()=>{const l=new Map;for(const u of M){try{const P=await _t(u);for(const[p,U]of P)l.set(p,U)}catch{}await new Promise(P=>setTimeout(P,120))}if(N)return;if(f.current){for(const[u,P]of l)f.current.set(u,{t:P,ts:Date.now()});jt(f.current)}const m=new Map([...S,...l]);v(m),d(!1)})(),()=>{N=!0}},[o,A]),{t:T=>!o||!T||!Ye(T)?T:k.get(T.trim())||T,map:k,isTranslating:c}}const Ft=[{label:"Date",options:[{value:"latest",label:"Latest"},{value:"oldest",label:"Oldest"}]},{label:"Title",options:[{value:"title_asc",label:"A → Z"},{value:"title_desc",label:"Z → A"}]},{label:"Popular (Views)",options:[{value:"popular_recent",label:"Recent"},{value:"popular_week",label:"Week"},{value:"popular_month",label:"Month"},{value:"popular_6_months",label:"6 Months"},{value:"popular_year",label:"Year"},{value:"popular",label:"All Time"}]},{label:"Most Commented",options:[{value:"comments_week",label:"Week"},{value:"comments_month",label:"Month"},{value:"comments_year",label:"Year"},{value:"comments",label:"All Time"}]},{label:"Other",options:[{value:"random",label:"Random"}]}],Ht=[{value:"",label:"All"},{value:"sfw",label:"SFW / 全年齢"},{value:"r-15",label:"R-15"},{value:"r-18",label:"NSFW / R18"},{value:"yuri",label:"Yuri / Girls love / 百合"},{value:"otokonoko",label:"Otoko no ko / 男の娘"},{value:"futanari",label:"Futanari / フタナリ"},{value:"r-18g",label:"R-18G / グロ"}],Ut=[{value:"sfw",label:"SFW / 全年齢"}],Ie="agreedToViewMature",Xt=()=>{const{rj:s}=ft(),o=Ke(),[k,v]=bt(),[c,d]=h(()=>localStorage.getItem(Ie)==="true"),[f,A]=h(!1),[w,T]=h(()=>k.get("q")||""),[I,L]=h(()=>k.get("q")||""),[S,g]=h("latest"),[N,M]=h("sfw"),[l,m]=h(1),[u,P]=h(null),[p,U]=h(null),[B,Y]=h(!0),[D,j]=h(()=>localStorage.getItem("asmrTranslateEN")==="true"),[ae,ie]=h(!1),q=vt(),{toggle:ne,bookmarkedIds:pe}=Ze(),{popup:$,openPopup:re,scheduleClose:F,cancelClose:Ne,closePopup:ge}=At();C(()=>yt("jasmr",()=>ie(!0)),[]),C(()=>{localStorage.setItem("asmrTranslateEN",String(D))},[D]),C(()=>{const n=()=>d(localStorage.getItem(Ie)==="true");return window.addEventListener("focus",n),window.addEventListener("storage",n),()=>{window.removeEventListener("focus",n),window.removeEventListener("storage",n)}},[]);const fe=c,V=fe?N:"sfw",Ce=fe?Ht:Ut,{data:ce,isLoading:Se,isError:Be,isFetching:be}=Tt(I,l,S,V),H=$e.useMemo(()=>ce?.shows??[],[ce?.shows]),Le=ce?.hasNext??!1;C(()=>{if(!s){u&&!p&&P(null);return}const n=s.toUpperCase();if(p&&(p.work.id?.toUpperCase()===n||p.work._id?.toUpperCase()===n)){u&&P(null);return}const i=H.find(x=>(x.id||x._id)?.toUpperCase()===n);i?(!u||(u.id||u._id)!==(i.id||i._id))&&P(i):(!u||(u.id||u._id)?.toUpperCase()!==n)&&P({_id:n,id:n,name:n})},[s,H,p,u]);const Pe=W(()=>{o("/asmr")},[o]);C(()=>{!s&&p&&U(null)},[s,p]);const{data:G}=Ge(p&&p.work.id||null),ve=p?[p.work.thumbnail,...G?.images||[]].filter(Boolean):[],J=[...H.map(n=>n.name),u?.name||"",p?.work.name||"",...G?.chapters?.map(n=>n.label)||[]].filter(Boolean),{t:K}=Ot(J,D);C(()=>{const n=p?p.work.name:u?u.name:s?s.toUpperCase():"",i=n?D?K(n):n:"",x=i?`${i} - dango`:"dango";document.title=x;try{window.history.replaceState(window.history.state,x,window.location.href)}catch{}},[u,p,s,D,K]);const Q=n=>{n.preventDefault(),L(w),m(1);const i=new URLSearchParams(k);w.trim()?i.set("q",w.trim()):i.delete("q"),i.delete("page"),v(i,{replace:!0})};C(()=>{const n=k.get("q")||"";T(i=>i===n?i:n),L(i=>i===n?i:n),m(1)},[k]);const de=n=>{n.target.checked&&!c&&A(!0)},Z=()=>{localStorage.setItem(Ie,"true"),d(!0),A(!1),m(1)},X=()=>{A(!1)},Te=W((n,i,x)=>{P(null),Y(!0),U({work:n,tracks:i,index:x})},[]);return e("div",{className:`${t.page} ${p?t.pageWithPlayer:""}`,children:[!(p&&B)&&e(O,{children:[e("header",{className:t.header,children:[e("h1",{className:t.pageTitle,children:[e(y,{name:"headphones"})," ASMR"]}),e("form",{className:t.searchForm,onSubmit:Q,children:[e("input",{className:t.searchInput,type:"text",value:w,onChange:n=>T(n.target.value),placeholder:"Search works, circles, CV… (-word excludes)","aria-label":"Search ASMR works"}),e("button",{className:t.searchBtn,type:"submit","aria-label":"Search",children:e(y,{name:"search"})})]})]}),e("div",{className:t.filterBar,children:[e("label",{className:t.filterLabel,htmlFor:"asmr-sort",children:"Sort"}),e("select",{id:"asmr-sort",className:t.sortSelect,value:S,onChange:n=>{g(n.target.value),m(1)},children:Ft.map(n=>e("optgroup",{label:n.label,children:n.options.map(i=>e("option",{value:i.value,children:i.label},i.value))},n.label))}),e("label",{className:t.filterLabel,htmlFor:"asmr-rating",children:"Type"}),e("select",{id:"asmr-rating",className:t.sortSelect,value:N,onChange:n=>{M(n.target.value),m(1)},children:Ce.map(n=>e("option",{value:n.value,children:n.label},n.value))}),e("div",{className:t.filterTogglesGroup,children:[e("div",{className:t.translateToggleWrap,children:[e("span",{className:t.filterLabel,children:"JP"}),e(Ve,{id:"asmr-translate-toggle",isChecked:D,onChange:n=>j(n.target.checked)}),e("span",{className:t.filterLabel,children:"EN"})]}),!c&&e("div",{className:t.matureToggleWrap,children:[e("label",{className:t.matureLabel,htmlFor:"asmr-mature-toggle",children:"Mature"}),e(Ve,{id:"asmr-mature-toggle",isChecked:!1,onChange:de})]})]})]}),Be?e("p",{className:t.statusMsg,children:"Failed to load works. Please try again."}):Se&&H.length===0?e("div",{className:t.grid,"aria-hidden":!0,children:Array.from({length:12}).map((n,i)=>e("div",{className:t.skeletonCard,children:[e("div",{className:`${t.skeletonThumb} ${t.shimmer}`}),e("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"88%"}}),e("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"55%"}})]},i))}):H.length===0?e("p",{className:t.statusMsg,children:"No works found."}):e(O,{children:[e("div",{className:`${t.grid} ${be?t.fetching:""}`,children:H.map(n=>{const i=D?{...n,name:K(n.name)}:n,x=Qe(n),se=ze(x),ee=pe.has(se),le=`/asmr/${encodeURIComponent(x)}`;return e("div",{className:t.asmrCardWrap,children:[e(kt,{item:{id:se,title:i.name,thumbnail:n.thumbnail||"",typeBadge:x||void 0,isAdult:Re(n)},linkTo:le,hoverIcon:"info",layout:"horizontal",showInfoButton:!0,display:{elements:{poster:{typeBadge:!0,chapterBadge:!1,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!1,meta:!1}}},onOpenDetails:z=>re(z,{rjCode:x,title:i.name,thumbnail:n.thumbnail||"",isAdult:Re(n),rating:n.rating,listenTarget:le}),onPopupHoverIntent:z=>z?Ne():F(),rawThumbnail:!0}),e("button",{className:`${t.bookmarkBtn} ${ee?t.bookmarked:""}`,onClick:z=>{z.preventDefault(),z.stopPropagation(),ne({rjCode:x,title:n.name,thumbnail:n.thumbnail||"",isAdult:Re(n)})},title:ee?"Remove from listening list":"Add to listening list","aria-label":ee?"Remove from listening list":"Add to listening list","aria-pressed":ee,children:e(y,{name:ee?"check":"plus",size:12})})]},n._id||n.id)})}),e("nav",{className:t.pagination,children:[e("button",{className:t.pageBtn,disabled:l<=1,onClick:()=>m(n=>Math.max(1,n-1)),children:"Previous"}),e("span",{className:t.pageIndicator,children:["Page ",l]}),e("button",{className:t.pageBtn,disabled:!Le,onClick:()=>m(n=>n+1),children:"Next"})]})]})]}),u&&e(Bt,{work:u,onClose:Pe,onPlay:Te,t:K}),$&&e(Mt,{data:$.data,anchorRect:$.rect,bookmarked:pe.has(ze($.data.rjCode)),onToggleBookmark:()=>ne({rjCode:$.data.rjCode,title:$.data.title,thumbnail:$.data.thumbnail||"",isAdult:$.data.isAdult}),onMouseEnter:Ne,onMouseLeave:F,onRequestClose:ge}),ae&&e(It,{isOpen:ae,onClose:()=>ie(!1),onSuccess:()=>{q.invalidateQueries({queryKey:["asmrBrowse"]}),q.invalidateQueries({queryKey:["asmrWork"]})}}),f&&e(xe,{isOpen:f,title:"Content Warning",onClose:X,children:e("div",{style:{padding:"var(--space-4)",textAlign:"center"},children:[e("p",{children:"This section contains mature content intended for adult audiences."}),e("p",{children:["By proceeding, you confirm that you are ",e("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),e("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-secondary)",marginTop:"var(--space-4)"},children:["You can reset this preference at any time in the ",e("strong",{children:"Settings"})," page."]}),e("div",{style:{marginTop:"var(--space-4)",display:"flex",gap:"var(--space-2-5)",justifyContent:"center"},children:[e(he,{variant:"secondary",onClick:X,children:"Go Back"}),e(he,{onClick:Z,children:"I'm 18+, Continue"})]})]})}),p&&e(Lt,{title:p.work.name,images:ve,chapters:G?.chapters||[],tracks:p.tracks,trackIndex:p.index,expanded:B,isAdult:!!p.work.isAdult,rjCode:p.work.id||p.work._id,t:K,onTrackChange:n=>U(i=>i&&{...i,index:n}),onExpandedChange:Y,onClose:()=>{U(null),Y(!0),s&&o("/asmr")}})]})};export{Xt as default};
@@ -1 +0,0 @@
1
- import{d as a,u as l}from"./vendor-core-8R2fFbyN.js";import{R as i}from"./ResetProgressModal-DWeiO-hs.js";import{s as f,n as R}from"./useAsmr-CB9THf0m.js";const A=({workId:e,title:m,onClose:o})=>{const[r,s]=a(!1),t=f(),n=R();return l(i,{isOpen:!!e,itemName:m,progressKind:"listening",listLabel:"my listening list",alsoRemove:r,onAlsoRemoveChange:s,onClose:()=>{s(!1),o()},onConfirm:()=>{e&&(t.mutate({workId:e}),r&&n.mutate(e),s(!1),o())}})};export{A};
@@ -1,10 +0,0 @@
1
- import{u as t,A as y,d as S,h as I,q as N,T as se,$ as kt}from"./vendor-core-8R2fFbyN.js";import{I as U}from"./vendor-icons-CDMuNDeL.js";import{S as fe,q as ve,e as xt,B as ne}from"./index-CtoKRNLc.js";import{u as Bt}from"./vendor-query-BXRECSI6.js";const Et="_controls_13898_1",Lt="_titleContainer_13898_9",Tt="_scheduleInfo_13898_15",Nt="_status_13898_23",It="_nextEpisode_13898_35",Pt="_watchlistBtn_13898_45",$t="_inList_13898_72",Mt="_queueBtn_13898_83",At="_queueActive_13898_95",Rt="_modeToggleBtn_13898_101",Ft="_modeToggleActive_13898_108",Ot="_nativeToggleBtn_13898_119",Dt="_nativeToggleActive_13898_132",qt="_markWatchedBtn_13898_153",Ht="_markWatchedDone_13898_167",zt="_completeSeriesBtn_13898_178",Wt="_providerAndEpisodeRow_13898_192",Vt="_episodeActions_13898_199",Ut="_desktopEpisodeActions_13898_206",Kt="_mobileEpisodeActions_13898_213",Gt="_episodeNavBtn_13898_217",Jt="_primary_13898_247",Qt="_secondary_13898_257",Xt="_episodePickerBtn_13898_261",jt="_queueCountdown_13898_265",Yt="_speedBoostBadge_13898_280",Zt="_videoContainer_13898_311",en="_loadingOverlay_13898_324",tn="_loadingDots_13898_338",nn="_dot_13898_343",rn="_bounce_13898_1",sn="_bufferingOverlay_13898_372",on="_bufferingSpinner_13898_381",cn="_spin_13898_920",an="_videoIframe_13898_396",ln="_videoElementHidden_13898_419",un="_upscalerCanvas_13898_424",dn="_upscalerActive_13898_437",pn="_upscalerStatusBadge_13898_441",fn="_subtitleOverlay_13898_456",_n="_controlsOverlay_13898_468",mn="_hidden_13898_498",hn="_centerPlayPause_13898_504",gn="_bottomControls_13898_536",yn="_progressBarContainer_13898_553",vn="_progressBar_13898_553",bn="_scrubbing_13898_576",wn="_watchedBar_13898_581",Sn="_bufferedBar_13898_582",Cn="_thumb_13898_604",kn="_timeBubble_13898_625",xn="_skipSegment_13898_647",Bn="_op_13898_661",En="_ed_13898_665",Ln="_recap_13898_669",Tn="_bottomControlsRow_13898_673",Nn="_controlBtn_13898_681",In="_timeDisplay_13898_705",Pn="_leftControls_13898_714",$n="_rightControls_13898_715",Mn="_middleControls_13898_716",An="_skipControls_13898_722",Rn="_skipBtn_13898_728",Fn="_volumeContainer_13898_752",On="_volumeSlider_13898_759",Dn="_settingsMenu_13898_837",qn="_slideUp_13898_1",Hn="_qualityListInMenu_13898_876",zn="_ccOptionsContainer_13898_877",Wn="_qualityItemInMenu_13898_885",Vn="_ccItem_13898_886",Un="_active_13898_907",Kn="_sourceLoader_13898_914",Gn="_spinner_13898_920",Jn="_skipBubble_13898_971",Qn="_skipIcon_13898_975",Xn="_skipText_13898_978",jn="_watchBtn_13898_990",Yn="_errorOverlay_13898_1036",Zn="_retryButton_13898_1046",er="_skipIndicatorContainer_13898_1073",tr="_leftSkip_13898_1073",nr="_rightSkip_13898_1076",rr="_sourceSelectionContainer_13898_1081",sr="_slideUpIn_13898_1",or="_providerSelectContainer_13898_1096",ir="_providerSelect_13898_1096",cr="_sourceSelect_13898_1081",ar="_sourceButtons_13898_1152",lr="_sourceButton_13898_1152",ur="_detailsBox_13898_1184",dr="_detailsToggleBtn_13898_1197",pr="_detailsGridContainer_13898_1221",fr="_fadeIn_13898_1",_r="_detailItem_13898_1233",mr="_animeStatus_13898_1253",hr="_genresList_13898_1266",gr="_genreTag_13898_1273",yr="_loadingDetails_13898_1291",vr="_descriptionSection_13898_1298",br="_description_13898_1298",wr="_epJumpControls_13898_1334",Sr="_epRangeButtons_13898_1345",Cr="_metaTags_13898_1351",kr="_epRangeBtn_13898_1358",xr="_epJumpInputGroup_13898_1373",Br="_fullscreenActive_13898_1405",Er="_skipRipple_13898_1",Lr="_errorSubtext_13898_1511",ao={controls:Et,titleContainer:Lt,scheduleInfo:Tt,status:Nt,nextEpisode:It,watchlistBtn:Pt,inList:$t,queueBtn:Mt,queueActive:At,modeToggleBtn:Rt,modeToggleActive:Ft,nativeToggleBtn:Ot,nativeToggleActive:Dt,markWatchedBtn:qt,markWatchedDone:Ht,completeSeriesBtn:zt,providerAndEpisodeRow:Wt,episodeActions:Vt,desktopEpisodeActions:Ut,mobileEpisodeActions:Kt,episodeNavBtn:Gt,primary:Jt,secondary:Qt,episodePickerBtn:Xt,queueCountdown:jt,speedBoostBadge:Yt,videoContainer:Zt,loadingOverlay:en,loadingDots:tn,dot:nn,bounce:rn,bufferingOverlay:sn,bufferingSpinner:on,spin:cn,videoIframe:an,videoElementHidden:ln,upscalerCanvas:un,upscalerActive:dn,upscalerStatusBadge:pn,subtitleOverlay:fn,controlsOverlay:_n,hidden:mn,centerPlayPause:hn,bottomControls:gn,progressBarContainer:yn,progressBar:vn,scrubbing:bn,watchedBar:wn,bufferedBar:Sn,thumb:Cn,timeBubble:kn,skipSegment:xn,op:Bn,ed:En,recap:Ln,bottomControlsRow:Tn,controlBtn:Nn,timeDisplay:In,leftControls:Pn,rightControls:$n,middleControls:Mn,skipControls:An,skipBtn:Rn,volumeContainer:Fn,volumeSlider:On,settingsMenu:Dn,slideUp:qn,qualityListInMenu:Hn,ccOptionsContainer:zn,qualityItemInMenu:Wn,ccItem:Vn,active:Un,sourceLoader:Kn,spinner:Gn,skipBubble:Jn,skipIcon:Qn,skipText:Xn,watchBtn:jn,errorOverlay:Yn,retryButton:Zn,skipIndicatorContainer:er,leftSkip:tr,rightSkip:nr,sourceSelectionContainer:rr,slideUpIn:sr,providerSelectContainer:or,providerSelect:ir,sourceSelect:cr,sourceButtons:ar,sourceButton:lr,detailsBox:ur,detailsToggleBtn:dr,detailsGridContainer:pr,fadeIn:fr,detailItem:_r,animeStatus:mr,genresList:hr,genreTag:gr,loadingDetails:yr,descriptionSection:vr,description:br,epJumpControls:wr,epRangeButtons:Sr,metaTags:Cr,epRangeBtn:kr,epJumpInputGroup:xr,fullscreenActive:Br,skipRipple:Er,errorSubtext:Lr},Tr="_playerPageLayout_xfhzl_1",Nr="_episodeSidebar_xfhzl_15",Ir="_playerMain_xfhzl_28",Pr="_videoPlayerWrapper_xfhzl_36",$r="_playerInfoHeader_xfhzl_52",Mr="_playerAnimeCard_xfhzl_58",Ar="_playerInfoContainer_xfhzl_70",Rr="_videoTitleSection_xfhzl_94",Fr="_theaterMode_xfhzl_276",lo={playerPageLayout:Tr,episodeSidebar:Nr,playerMain:Ir,videoPlayerWrapper:Pr,playerInfoHeader:$r,playerAnimeCard:Mr,playerInfoContainer:Ar,videoTitleSection:Rr,theaterMode:Fr},Or="_shell_41rxp_1",Dr="_stage_41rxp_37",qr="_shellFill_41rxp_85",Hr="_shellFullscreen_41rxp_93",zr="_uiLayer_41rxp_107",Wr="_volumeWrap_41rxp_118",Vr="_volumeSlider_41rxp_124",j={shell:Or,stage:Dr,shellFill:qr,shellFullscreen:Hr,uiLayer:zr,volumeWrap:Wr,volumeSlider:Vr},Ur=.8,Kr=5,uo=2e3,He="autoplayEnabled",Gr=(e,n)=>n>0&&e>=n*Ur,po=(e,n)=>e>Kr&&!Gr(e,n),fo=()=>{try{return localStorage.getItem(He)==="true"}catch{return!1}},_o=e=>{try{localStorage.setItem(He,String(e))}catch{}},mo=e=>e.seekInduced?"none":e.autoplayEnabled&&e.hasNext?"advance":e.hasNext?"prompt-next":e.isFinal?"prompt-complete":"none",Jr=e=>(e.language??e.lang??"").toLowerCase(),Qr=e=>(e.label??"").toLowerCase(),Xr=e=>`${e.language??e.lang??""}|||${e.label??""}`,jr=e=>Jr(e).startsWith("en")||Qr(e).includes("english");function ho(e,n){if(e.length===0||n?.enabled===!1)return-1;const r=n?.lastKey??null;if(r){const s=e.findIndex(a=>Xr(a)===r);if(s>=0)return s}const o=e.findIndex(jr);return o>=0?o:0}const K={fontSize:1.8,position:0,bgOpacity:.5,bgColor:"#000000",textColor:"#ffffff",edge:"shadow",bold:!1},Ce=(e,n,r)=>Math.max(n,Math.min(r,e)),ke=e=>typeof e=="string"&&/^#[0-9a-fA-F]{6}$/.test(e),be=(e,n,r,o)=>{try{const s=localStorage.getItem(e);if(s===null)return n;const a=parseFloat(s);return Number.isFinite(a)?Ce(a,r,o):n}catch{return n}};function Yr(){let e=K.edge,n=K.bgColor,r=K.textColor,o=K.bold;try{const s=localStorage.getItem("subtitleEdge");(s==="shadow"||s==="outline"||s==="none")&&(e=s);const a=localStorage.getItem("subtitleBgColor");ke(a)&&(n=a);const g=localStorage.getItem("subtitleTextColor");ke(g)&&(r=g);const c=localStorage.getItem("subtitleBold");c!==null&&(o=c==="true")}catch{}return{fontSize:be("subtitleFontSize",K.fontSize,.5,10),position:be("subtitlePosition",K.position,0,100),bgOpacity:be("subtitleBgOpacity",K.bgOpacity,0,1),bgColor:n,textColor:r,edge:e,bold:o}}function ze(e,n){const r=`rgba(0, 0, 0, ${Ce(n,0,1)})`;if(!ke(e))return r;const o=parseInt(e.slice(1,3),16),s=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${o}, ${s}, ${a}, ${Ce(n,0,1)})`}function We(e,n){return e==="none"?n<=0?"0 1px 3px rgba(0, 0, 0, 0.9)":"none":e==="outline"?["-1px 0 0 black","1px 0 0 black","0 -1px 0 black","0 1px 0 black","-1px -1px 0 black","1px -1px 0 black","-1px 1px 0 black","1px 1px 0 black","0 0 6px rgba(0, 0, 0, 0.9)"].join(", "):"0 0 4px black, 0 1px 2px rgba(0, 0, 0, 0.8)"}function go(e){return`
2
- video::cue {
3
- font-size: ${e.fontSize}rem !important;
4
- color: ${e.textColor} !important;
5
- background-color: ${ze(e.bgColor,e.bgOpacity)} !important;
6
- font-weight: ${e.bold?"bold":"normal"} !important;
7
- text-shadow: ${We(e.edge,e.bgOpacity)} !important;
8
- }
9
- `}function yo(e){return[`font-size: ${e.fontSize}rem`,`color: ${e.textColor}`,`background-color: ${ze(e.bgColor,e.bgOpacity)}`,`font-weight: ${e.bold?"700":"400"}`,`text-shadow: ${We(e.edge,e.bgOpacity)}`,"padding: 0.2em 0.5em","border-radius: 0.25em","text-align: center","position: absolute","left: 50%","transform: translateX(-50%)","max-width: 92%","white-space: pre-wrap","overflow-wrap: break-word","line-height: 1.4"].join(`;
10
- `)+";"}const Zr=new Set(["b","i","u","strong","em"]);function vo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/&lt;(\/?)([a-zA-Z]+)&gt;/g,(r,o,s)=>Zr.has(s.toLowerCase())?`<${o}${s.toLowerCase()}>`:r)}function bo(e){return e.replace(/<[^>]*>/g,"")}const wo=["#ffffff","#ffff00","#7CFC00","#00e5ff","#ff9ff3","#ffa502"],So=["#000000","#1e272e","#2f3542","#3d0c02","#0c3d2e","#ffffff"];function Co(e,n){const r=Number.isFinite(e)?e*16:K.fontSize*16;return!Number.isFinite(n)||n<=0?r/16:Math.min(r,Math.max(13,n*.07))/16}function ko(e){const n=Math.abs(e/1e3).toFixed(1);return e>0?`+${n}s`:e<0?`-${n}s`:"0.0s"}function xo(e,n){const r=e.clientWidth||0,o=e.clientHeight||0,s=e.videoWidth>0&&e.videoHeight>0?e.videoWidth/e.videoHeight:0;let a=o;s>0&&r>0&&o>0&&(a=r/o>s?o:r/s);const g=Math.max(0,(o-a)/2),c=Math.max(0,Math.min(100,Number(n)||0))/100*a;return g+c}const es="_centerControls_61n7k_1",ts="_centerSkipBtn_61n7k_15",ns="_centerPlayPause_61n7k_40",rs="_playIconOffset_61n7k_71",re={centerControls:es,centerSkipBtn:ts,centerPlayPause:ns,playIconOffset:rs},Bo=({isPlaying:e,onTogglePlay:n,onSkipBack:r,onSkipForward:o,skipSeconds:s=10})=>t("div",{className:re.centerControls,onClick:a=>a.stopPropagation(),children:[t("button",{className:re.centerSkipBtn,onClick:r,title:`Skip back ${s}s`,"aria-label":`Skip back ${s} seconds`,children:t(U,{name:"replay-10"})}),t("button",{className:re.centerPlayPause,"data-speed-boost-ignore":"true",onClick:n,"aria-label":e?"Pause":"Play",children:e?t(U,{name:"pause"}):t(U,{name:"play",className:re.playIconOffset})}),t("button",{className:re.centerSkipBtn,onClick:o,title:`Skip forward ${s}s`,"aria-label":`Skip forward ${s} seconds`,children:t(U,{name:"forward-10"})})]}),Eo=({classes:e,videoRef:n,duration:r,formatTime:o,isScrubbing:s,buffered:a="auto",onSeek:g,onScrubStart:c,onScrubMove:f,onScrubEnd:w,timeLabelRef:l,children:E})=>{const m=y(null),L=y(null),_=y(null),p=y(null),[v,u]=S({time:0,position:null});I(()=>{const d=n.current;if(!d)return;const B=M=>{const h=M/r*100||0;L.current&&(L.current.style.width=`${h}%`),_.current&&(_.current.style.left=`${h}%`),l?.current&&(l.current.innerText=`${o(M)} / ${o(r)}`)},$=()=>{s||B(d.currentTime)},O=()=>{if(a==="auto"&&d.buffered.length>0){const h=d.buffered.end(d.buffered.length-1)/r*100||0;p.current&&(p.current.style.width=`${h}%`)}};return B(d.currentTime),O(),d.addEventListener("timeupdate",$),d.addEventListener("progress",O),()=>{d.removeEventListener("timeupdate",$),d.removeEventListener("progress",O)}},[n,r,s,a,o,l]),I(()=>{if(!s)return;const d=O=>{if(!m.current||!r)return;const M=m.current.getBoundingClientRect(),h=Math.min(1,Math.max(0,(O.clientX-M.left)/M.width));f(h),$(h)},B=()=>w();return document.addEventListener("mousemove",d),document.addEventListener("mouseup",B),()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",B)};function $(O){const M=O*r,h=M/r*100||0;L.current&&(L.current.style.width=`${h}%`),_.current&&(_.current.style.left=`${h}%`),l?.current&&(l.current.innerText=`${o(M)} / ${o(r)}`);const A=m.current?.getBoundingClientRect();u({time:M,position:A?O*A.width:null})}},[s,r,f,w,o,l]);const C=d=>{if(!m.current)return 0;const B=m.current.getBoundingClientRect();return Math.min(1,Math.max(0,(d-B.left)/B.width))};return t("div",{className:`${e.container} ${s&&e.scrubbing?e.scrubbing:""}`,ref:m,onClick:d=>{!n.current||isNaN(r)||r===0||g(C(d.clientX))},onMouseMove:d=>{if(!r)return;const B=C(d.clientX);u({time:B*r,position:d.clientX-(m.current?.getBoundingClientRect().left??0)})},onMouseLeave:()=>{s||u({time:0,position:null})},children:[v.position!==null&&t("div",{className:e.timeBubble,style:{left:v.position},children:o(v.time)}),t("div",{className:e.bar,children:[t("div",{className:e.buffered,ref:p,style:a==="full"?{width:"100%"}:void 0}),t("div",{className:e.watched,ref:L}),t("div",{className:e.thumb,ref:_,onMouseDown:d=>{d.preventDefault(),n.current&&c()}}),E]})]})};function we(){try{if(typeof window>"u")return!1;const e=window.matchMedia?.("(pointer: coarse)").matches??!1,r=(navigator.maxTouchPoints??0)>0||"ontouchstart"in window;return e||r}catch{return!1}}function Ve(){const[e,n]=S(we);return I(()=>{n(we());let r=null;const o=()=>n(we());try{r=window.matchMedia("(pointer: coarse)"),r.addEventListener?r.addEventListener("change",o):r.addListener(o)}catch{}return window.addEventListener("touchstart",o,{passive:!0,once:!0}),()=>{try{r&&(r.removeEventListener?r.removeEventListener("change",o):r.removeListener(o))}catch{}window.removeEventListener("touchstart",o)}},[]),e}const qe=280;function ss(e){return e?!!e.closest('button, input, select, textarea, a, [role="button"], [data-player-ui="true"]'):!1}const Lo=({player:e,topBar:n,centerControls:r,bottomBar:o,settingsPanel:s,overlays:a,isInteracting:g=!1,className:c,chromeDisabled:f=!1,children:w})=>{const{state:l,refs:E,actions:m}=e,L=E.playerContainerRef,p=Ve()?5e3:3e3,v=y(0),u=y(null),C=y(g);C.current=g;const d=N(()=>{const h=m.inactivityTimer.current;h&&(window.clearTimeout(h),m.inactivityTimer.current=null)},[m]),B=N(()=>{d(),l.isPlaying&&(C.current||l.useNativeControls||(m.inactivityTimer.current=window.setTimeout(()=>{if(C.current)return;m.setShowControls(!1);const h=L.current;h&&l.isFullscreen&&(h.style.cursor="none")},p)))},[m,d,L,p,l.isFullscreen,l.isPlaying,l.useNativeControls]),$=N(()=>{const h=L.current;h&&(h.style.cursor="default"),!l.showControls&&!l.useNativeControls&&m.setShowControls(!0),B()},[m,L,B,l.showControls,l.useNativeControls]);I(()=>{if(l.showControls){if(!l.isPlaying){d();return}if(g||l.isScrubbing||l.showSettings||l.showVolumeSlider){m.setShowControls(!0),d();return}B()}},[m,d,g,B,l.isPlaying,l.isScrubbing,l.showControls,l.showSettings,l.showVolumeSlider]),I(()=>()=>d(),[d]);const O=N(h=>{const A=h.target;if(ss(A))return;const J=Date.now(),H=J-v.current<qe;if(v.current=J,H){u.current&&(window.clearTimeout(u.current),u.current=null),m.toggleFullscreen();return}u.current&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{u.current=null,m.setShowControls(!l.showControls),l.showControls?B():$()},qe)},[m,B,l.showControls,$]);I(()=>()=>{u.current&&window.clearTimeout(u.current)},[]);const M=l.showControls||l.isScrubbing||l.showSettings||l.showVolumeSlider;return t("div",{ref:L,className:`${j.shell} ${l.isFullscreen?j.shellFullscreen:""} ${c??""}`,onContextMenu:h=>h.preventDefault(),onPointerMove:h=>{h.pointerType==="mouse"&&$()},onMouseLeave:()=>{window.matchMedia?.("(hover: hover) and (pointer: fine)").matches&&l.isPlaying&&!C.current&&m.setShowControls(!1)},children:[t("div",{className:j.stage,onClick:O,onContextMenu:h=>h.preventDefault(),children:w}),a,!f&&!l.useNativeControls&&t("div",{className:j.uiLayer,onContextMenu:h=>h.preventDefault(),children:[t("div",{"data-player-ui":"true",children:n}),M&&r&&t("div",{"data-player-ui":"true",children:r}),t("div",{"data-player-ui":"true",children:o}),s&&t("div",{"data-player-ui":"true",children:s})]})]})},os=450,To=({muted:e,volume:n,volumeIcon:r,buttonClassName:o,sliderClassName:s,onToggleMute:a,onVolumeChange:g,onExpandedChange:c})=>{const f=Ve(),[w,l]=S(!1),E=y(null),m=y(!1),L=y(null),_=N(d=>{l(d),c?.(d)},[c]);I(()=>()=>{E.current&&window.clearTimeout(E.current)},[]),I(()=>{if(!w)return;const d=B=>{L.current&&!L.current.contains(B.target)&&_(!1)};return document.addEventListener("pointerdown",d),()=>document.removeEventListener("pointerdown",d)},[w,_]);const p=e?0:n,v=()=>{m.current=!1,E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{m.current=!0,_(!0)},os)},u=()=>{E.current&&(window.clearTimeout(E.current),E.current=null)},C=d=>{if(d.stopPropagation(),m.current){m.current=!1;return}if(f){w?a():_(!0);return}a()};return t("div",{ref:L,className:j.volumeWrap,"data-expanded":w?"true":"false",onContextMenu:d=>d.preventDefault(),children:[t("button",{type:"button",className:o,onClick:C,onPointerDown:v,onPointerUp:u,onPointerLeave:u,onContextMenu:d=>d.preventDefault(),"aria-label":e?"Unmute":"Mute","aria-expanded":w,children:r}),t("input",{type:"range",min:"0",max:"1",step:"0.05",value:p,onChange:d=>g(parseFloat(d.target.value)),onClick:d=>d.stopPropagation(),onPointerDown:d=>d.stopPropagation(),onContextMenu:d=>d.preventDefault(),className:`${j.volumeSlider} ${s??""}`,style:{"--volume-percent":`${p*100}%`},"aria-label":"Volume"})]})},is="_statusArea_1xccu_1",cs="_toggleBtn_1xccu_20",as="_shortcuts_1xccu_46",ls="_shortcutGroup_1xccu_56",us="_shortcut_1xccu_46",ds="_key_1xccu_70",ps="_label_1xccu_91",x={statusArea:is,toggleBtn:cs,shortcuts:as,shortcutGroup:ls,shortcut:us,key:ds,label:ps},No=({showTheater:e=!0})=>{const[n,r]=S(!1);return t("div",{className:x.statusArea,children:[t("button",{type:"button",className:x.toggleBtn,onClick:()=>r(o=>!o),"aria-expanded":n,"aria-controls":"player-shortcuts",children:[t(U,{name:"keyboard",size:14}),t("span",{children:"Keyboard Shortcuts"}),n?t(U,{name:"chevron-up",size:12}):t(U,{name:"chevron-down",size:12})]}),n&&t("div",{id:"player-shortcuts",className:x.shortcuts,children:[t("div",{className:x.shortcutGroup,children:[t("div",{className:x.shortcut,children:[t("span",{className:x.key,children:"↑"}),t("span",{className:x.key,children:"↓"}),t("span",{className:x.label,children:"Volume"})]}),t("div",{className:x.shortcut,children:[t("span",{className:x.key,children:"←"}),t("span",{className:x.key,children:"→"}),t("span",{className:x.label,children:"Seek"})]})]}),t("div",{className:x.shortcutGroup,children:[t("div",{className:x.shortcut,children:[t("span",{className:x.key,children:"Space"}),t("span",{className:x.label,children:"Play/Pause"})]}),t("div",{className:x.shortcut,children:[t("span",{className:x.key,children:"F"}),t("span",{className:x.label,children:"Fullscreen"})]}),t("div",{className:x.shortcut,children:[t("span",{className:x.key,children:"M"}),t("span",{className:x.label,children:"Mute"})]}),e&&t("div",{className:x.shortcut,children:[t("span",{className:x.key,children:"T"}),t("span",{className:x.label,children:"Theater"})]}),t("div",{className:x.shortcut,children:[t("span",{className:x.key,children:"N"}),t("span",{className:x.label,children:"Next"})]})]})]})]})},fs="_episodeListContainer_9tyin_1",_s="_drawerContainer_9tyin_9",ms="_episodeListHeader_9tyin_14",hs="_drawerHeader_9tyin_20",gs="_episodeListTitle_9tyin_29",ys="_rangeSelector_9tyin_41",vs="_rangeButton_9tyin_47",bs="_active_9tyin_70",ws="_episodeList_9tyin_1",Ss="_drawerList_9tyin_89",Cs="_episodeItem_9tyin_118",ks="_watched_9tyin_145",xs="_episodeThumb_9tyin_167",Bs="_episodeText_9tyin_176",Es="_episodeLabel_9tyin_184",Ls="_episodeSub_9tyin_189",T={episodeListContainer:fs,drawerContainer:_s,episodeListHeader:ms,drawerHeader:hs,episodeListTitle:gs,rangeSelector:ys,rangeButton:vs,active:bs,episodeList:ws,drawerList:Ss,episodeItem:Cs,watched:ks,episodeThumb:xs,episodeText:Bs,episodeLabel:Es,episodeSub:Ls},Ts=({episodes:e,currentEpisode:n,watchedEpisodes:r=[],onEpisodeClick:o,variant:s="sidebar",title:a="Episodes",header:g})=>{const[c,f]=S(0),w=y(null),l=se(()=>e.map(_=>typeof _=="string"?{id:_,label:`Episode ${_}`}:_),[e]),E=se(()=>new Set(r),[r]);I(()=>{const _=w.current;if(!_)return;let p=_.parentElement;for(;p;){const C=window.getComputedStyle(p);if((C.overflowY==="auto"||C.overflowY==="scroll")&&p.scrollHeight>p.clientHeight)break;p=p.parentElement}if(!p)return;const v=p.getBoundingClientRect(),u=_.getBoundingClientRect();p.scrollTop+=u.top+u.height/2-(v.top+p.clientHeight/2)},[n,c]);const m=se(()=>{if(l.length<=100)return[];const _=[];for(let p=0;p<l.length;p+=100){const v=p+1,u=Math.min(p+100,l.length);_.push(`${v}-${u}`)}return _},[l]),L=se(()=>{if(m.length===0)return l;const _=m[c];if(!_)return l;const[p,v]=_.split("-"),u=parseInt(p,10),C=parseInt(v,10);return l.slice(u-1,C)},[l,m,c]);return t("div",{className:`${T.episodeListContainer} ${s==="drawer"?T.drawerContainer:""}`,children:[t("div",{className:`${T.episodeListHeader} ${s==="drawer"?T.drawerHeader:""}`,children:[g,t("h3",{className:T.episodeListTitle,children:a}),m.length>0&&t("div",{className:T.rangeSelector,children:m.map((_,p)=>t("button",{className:`${T.rangeButton} ${c===p?T.active:""}`,onClick:()=>f(p),children:_},_))})]}),t("div",{className:`${T.episodeList} ${s==="drawer"?T.drawerList:""}`,children:L.map(_=>{const p=_.id===n,v=E.has(_.id)||_.watched===!0;return t("div",{ref:p?w:void 0,className:`${T.episodeItem} ${v?T.watched:""} ${p?T.active:""}`,onClick:()=>o(_.id),children:[_.thumbnail&&t("img",{src:_.thumbnail,alt:"",loading:"lazy",decoding:"async",className:T.episodeThumb}),t("span",{className:T.episodeText,children:[t("span",{className:T.episodeLabel,children:_.label??`Episode ${_.id}`}),_.sublabel&&t("span",{className:T.episodeSub,children:_.sublabel})]})]},_.id)})})]})},Io=({variant:e="sidebar",count:n=12})=>t("div",{className:`${T.episodeListContainer} ${e==="drawer"?T.drawerContainer:""}`,children:[t("div",{className:`${T.episodeListHeader} ${e==="drawer"?T.drawerHeader:""}`,children:[t("h3",{className:T.episodeListTitle,children:"Episodes"}),t("div",{className:T.rangeSelector,children:[t(fe,{width:"60px",height:"28px",variant:"rectangular"}),t(fe,{width:"60px",height:"28px",variant:"rectangular"}),t(fe,{width:"60px",height:"28px",variant:"rectangular"})]})]}),t("div",{className:`${T.episodeList} ${e==="drawer"?T.drawerList:""}`,children:Array.from({length:n}).map((r,o)=>t("div",{className:T.episodeItem,style:{border:"none",background:"transparent"},children:t(fe,{width:"120px",height:"1.2rem",variant:"text"})},o))})]}),Ns="_shell_cys6s_1",Is="_overlay_cys6s_10",Ps="_drawer_cys6s_21",$s="_handle_cys6s_56",Ms="_header_cys6s_64",As="_headerCopy_cys6s_73",Rs="_kicker_cys6s_79",Fs="_title_cys6s_87",Os="_closeBtn_cys6s_94",Ds="_body_cys6s_116",W={shell:Ns,overlay:Is,drawer:Ps,handle:$s,header:Ms,headerCopy:As,kicker:Rs,title:Fs,closeBtn:Os,body:Ds};function Po({isOpen:e,onClose:n,episodes:r,currentEpisode:o,watchedEpisodes:s=[],onEpisodeClick:a,title:g,header:c}){return I(()=>{if(!e)return;const f=l=>{l.key==="Escape"&&n()},w=document.body.style.overflow;return document.body.style.overflow="hidden",document.addEventListener("keydown",f),()=>{document.body.style.overflow=w,document.removeEventListener("keydown",f)}},[e,n]),e?kt(t("div",{className:W.shell,role:"dialog","aria-modal":"true","aria-label":"Episode picker",children:[t("button",{className:W.overlay,type:"button",onClick:n,"aria-label":"Close episodes"}),t("aside",{className:W.drawer,children:[t("div",{className:W.handle}),t("div",{className:W.header,children:[t("div",{className:W.headerCopy,children:[t("span",{className:W.kicker,children:"Episode picker"}),t("h3",{className:W.title,children:"Choose an episode"})]}),t("button",{className:W.closeBtn,type:"button",onClick:n,"aria-label":"Close",children:t(U,{name:"times"})})]}),t("div",{className:W.body,children:t(Ts,{episodes:r,currentEpisode:o,watchedEpisodes:s,onEpisodeClick:a,variant:"drawer",title:g,header:c})})]})]}),document.body):null}function Be(){return document}function Ue(e){const n=Be();if(document.fullscreenElement)return document.fullscreenElement;if(n.webkitFullscreenElement)return n.webkitFullscreenElement;const r=e;return r?.webkitDisplayingFullscreen?r:null}function Y(e){return Ue(e)!==null}async function qs(e,n){if(Ue(n))return;const r=e;try{if(typeof e.requestFullscreen=="function"){await e.requestFullscreen();return}if(typeof r.webkitRequestFullscreen=="function"){await r.webkitRequestFullscreen();return}if(typeof r.webkitRequestFullScreen=="function"){await r.webkitRequestFullScreen();return}}catch{}const o=n;if(o&&typeof o.webkitEnterFullscreen=="function"){if(o.webkitSupportsFullscreen===!1)return;try{await o.webkitEnterFullscreen()}catch{}}}async function Hs(e){const n=Be();try{if(document.fullscreenElement&&typeof document.exitFullscreen=="function"){await document.exitFullscreen();return}if(n.webkitFullscreenElement&&typeof n.webkitExitFullscreen=="function"){await n.webkitExitFullscreen();return}}catch{}const r=e;if(r?.webkitDisplayingFullscreen&&typeof r.webkitExitFullscreen=="function"){try{r.webkitExitFullscreen()}catch{}return}try{typeof n.webkitCancelFullScreen=="function"?n.webkitCancelFullScreen():!document.fullscreenElement&&typeof document.exitFullscreen=="function"&&(document.fullscreenElement??n.webkitFullscreenElement)&&await document.exitFullscreen()}catch{}}async function zs(e,n){!e&&!n||(Y(n)?await Hs(n):e&&await qs(e,n))}function Ws(e,n){const r=()=>{try{n(Y(e()))}catch{}},o=Be(),s=r;o.addEventListener("fullscreenchange",r),o.addEventListener("webkitfullscreenchange",s),o.addEventListener("webkitbeginfullscreen",s,!0),o.addEventListener("webkitendfullscreen",s,!0);const a=e();return a?.addEventListener("webkitbeginfullscreen",s),a?.addEventListener("webkitendfullscreen",s),()=>{o.removeEventListener("fullscreenchange",r),o.removeEventListener("webkitfullscreenchange",s),o.removeEventListener("webkitbeginfullscreen",s,!0),o.removeEventListener("webkitendfullscreen",s,!0),a?.removeEventListener("webkitbeginfullscreen",s),a?.removeEventListener("webkitendfullscreen",s)}}const $o=({skipIntervals:e,showId:n,episodeNumber:r,episodeCount:o,sourceType:s,showMeta:a})=>{const g=Bt(),c=y(null),f=y(null),w=y(null),l=y(null),E=y(!1),m=y(null),L=y(0),_=y(1),p=y({mouse:!1,keyboard:!1}),v=y(null),u=y(null),C=y(!1),d=y(Math.random().toString(36).substring(2)),[B,$]=S(!1),[O,M]=S(()=>{try{return localStorage.getItem("playerMuted")==="true"}catch{return!1}}),[h,A]=S(()=>{try{const i=parseFloat(localStorage.getItem("playerVolume")||"");return isNaN(i)?1:Math.max(0,Math.min(1,i))}catch{return 1}}),[J,H]=S(!1),[D,oe]=S(0),[Ke,z]=S(!0),[ie,Ee]=S(!1),[Ge,Le]=S({time:0,position:null}),[me,Je]=S(localStorage.getItem("autoSkipEnabled")==="true"),[Qe,he]=S(null),[Xe,je]=S(!1),[G]=S(Yr),[Ye,Ze]=S(G.fontSize),[et,tt]=S(G.position),[nt,rt]=S(G.bgOpacity),[st,ot]=S(G.bgColor),[it,ct]=S(G.textColor),[at,lt]=S(G.edge),[ut,dt]=S(G.bold),[pt,ft]=S([]),[_t,mt]=S(null),[ht,gt]=S(!1),[yt,vt]=S(!1),[bt,ge]=S(!1),[wt,ce]=S(!1),[St,Te]=S(()=>{try{return localStorage.getItem("playerUseNativeControls")==="true"}catch{return!1}}),Z=y(!1),ye=y(-1),ae=N(()=>{const i=c.current;return!n||!r||!a?.name?null:{showId:n,episodeNumber:r,episodeCount:o,currentTime:i?i.currentTime:0,duration:i?i.duration:0,showName:a.name,showThumbnail:a.thumbnail,nativeName:a.names?.native,englishName:a.names?.english,genres:Array.isArray(a.genres)?a.genres.map(b=>typeof b=="string"?b:b?.name).filter(Boolean):void 0,popularityScore:a.score,type:a.type,isPlaying:i?!i.paused:!0,sessionId:d.current,isAdult:a.isAdult}},[n,r,o,a]),R=N((i=!1,b=!1)=>{if(Z.current)return!1;const k=ae();if(!k)return!1;const P=c.current;if(!P&&s!=="iframe")return!1;const F=P?P.currentTime>=P.duration*.8:!1;let V=P?P.currentTime:0;if(i&&F&&(V=P?P.duration:0),!b){if(V===0&&!F)return!1;const te=P?Math.abs(V-ye.current):0;if(!i&&P&&V!==P.duration&&te<5)return!1}return k.currentTime=V,ye.current=V,i?(async()=>{try{await ve("/api/update-progress",{method:"POST",body:JSON.stringify(k)}),g.invalidateQueries({queryKey:["video-sources",n,r]}),g.invalidateQueries({queryKey:["allContinueWatching"]}),g.invalidateQueries({queryKey:["thisWeekSchedule"]})}catch(te){console.error("Failed to update progress:",te)}})():ve("/api/update-progress",{method:"POST",body:JSON.stringify(k),keepalive:!0}).catch(te=>console.error("Failed to update progress:",te)),!0},[ae,s,g,n,r]);I(()=>{const i=c.current;i&&(i.volume=h,i.muted=O)},[c,h,O]),I(()=>{const i=()=>{Z.current||R(!0)};window.addEventListener("beforeunload",i);const b=m,k=l;return()=>{window.removeEventListener("beforeunload",i),Z.current||R(!0),b.current&&clearTimeout(b.current),k.current&&clearTimeout(k.current)}},[R]);const le=N(()=>{const i=f.current;i&&zs(i,c.current).catch(b=>{console.error(`Error attempting to toggle full-screen mode: ${b?.message} (${b?.name})`)})},[]),ue=N(()=>{c.current&&(c.current.paused?c.current.play().catch(()=>console.warn("Autoplay was prevented.")):(c.current.pause(),z(!0)))},[z]),Q=N(()=>{const i=c.current;if(!i)return;const b=p.current.mouse||p.current.keyboard;i.playbackRate=b?2:_.current},[]),de=N(i=>{p.current.mouse!==i&&(p.current.mouse=i,ce(i||p.current.keyboard),Q())},[Q]),X=N(i=>{p.current.keyboard!==i&&(p.current.keyboard=i,ce(p.current.mouse||i),Q())},[Q]),ee=N(i=>{c.current&&(c.current.currentTime+=i,m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{R(!1,!0)},1500),z(!0))},[R,z]),pe=N(()=>{if(!c.current)return;const i=!c.current.muted;c.current.muted=i,M(i),localStorage.setItem("playerMuted",String(i)),!i&&c.current.volume===0&&(c.current.volume=.5,A(.5),localStorage.setItem("playerVolume",String(.5))),z(!0)},[z]);I(()=>{const i=()=>c.current,b=Ws(i,k=>{H(k),k&&z(!0)});return H(Y(i())),b},[z]),I(()=>{const i=k=>{if(!k.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')){if(k.code==="Space"){if(k.preventDefault(),C.current)return;C.current=!0,u.current&&clearTimeout(u.current),u.current=window.setTimeout(()=>{u.current=null,C.current&&X(!0)},180);return}switch(k.key.toLowerCase()){case"f":le();break;case"m":pe();break;case"arrowright":ee(10);break;case"arrowleft":ee(-10);break;case"arrowup":if(k.preventDefault(),c.current){const F=Math.min(1,c.current.volume+.1);c.current.volume=F,A(F)}break;case"arrowdown":if(k.preventDefault(),c.current){const F=Math.max(0,c.current.volume-.1);c.current.volume=F,A(F)}break}}},b=k=>{if(k.code==="Space"){if(k.preventDefault(),C.current=!1,p.current.keyboard){X(!1);return}u.current&&(clearTimeout(u.current),u.current=null,ue())}};return document.addEventListener("keydown",i),document.addEventListener("keyup",b),()=>{document.removeEventListener("keydown",i),document.removeEventListener("keyup",b),u.current&&(clearTimeout(u.current),u.current=null),C.current=!1,X(!1),ce(!1)}},[X,ue,le,pe,ee]),I(()=>{const i=P=>{if(P.button!==0)return;const F=P.target;if(!F||F.closest('[data-speed-boost-ignore="true"]'))return;const V=f.current;!V||!V.contains(F)||(v.current&&clearTimeout(v.current),v.current=window.setTimeout(()=>{v.current=null,de(!0)},180))},b=()=>{v.current&&(clearTimeout(v.current),v.current=null),de(!1)},k=()=>{v.current&&(clearTimeout(v.current),v.current=null),C.current=!1,u.current&&(clearTimeout(u.current),u.current=null),X(!1),de(!1),ce(!1)};return document.addEventListener("mousedown",i),document.addEventListener("mouseup",b),window.addEventListener("blur",k),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("mouseup",b),window.removeEventListener("blur",k),v.current&&(clearTimeout(v.current),v.current=null)}},[X,de]);const Ne=N(()=>{$(!0),ge(!1),setTimeout(()=>R(!1,!0),50)},[R]),Ie=N(()=>{ge(!1)},[]),Pe=N(()=>{ge(!0)},[]),$e=N(()=>{$(!1),z(!0),setTimeout(()=>R(!1,!0),50)},[R]);I(()=>{Z.current=!1,ye.current=-1,L.current=0,d.current=Math.random().toString(36).substring(2)},[n,r]),I(()=>{const i=d.current;return()=>{const b=JSON.stringify({sessionId:i}),k=new Blob([b],{type:"application/json"});navigator.sendBeacon("/api/discord/clear",k)}},[n,r]),I(()=>{if(s!=="iframe")return;R(!1,!0);const i=setInterval(()=>{R(!1,!0)},6e4);return()=>clearInterval(i)},[s,R]);const Me=N(()=>{oe(c.current?.duration||0),Q()},[Q]),Ae=N(()=>{if(c.current){const i=c.current.muted,b=c.current.volume;M(i),A(b),localStorage.setItem("playerMuted",String(i)),localStorage.setItem("playerVolume",String(b))}},[]),Re=N(()=>{},[]),Fe=N(()=>{const i=c.current;if(!i)return;const b=i.currentTime||0,k=Date.now();k-L.current>6e4&&R()&&(L.current=k);const P=e.find(F=>b>=F.start_time&&b<F.end_time)||null;he(F=>F?.skip_id!==P?.skip_id?P:F),me&&P&&!i.paused&&(i.currentTime=P.end_time,he(null))},[e,me,R]),Oe=N(()=>{const i=ae();i&&(i.currentTime=i.duration,ve("/api/update-progress",{method:"POST",body:JSON.stringify(i)}).then(()=>{g.invalidateQueries({queryKey:["video-sources",n,r]}),g.invalidateQueries({queryKey:["allContinueWatching"]})}).catch(b=>console.error("Failed to send final progress:",b)))},[ae,g,n,r]),De=N(()=>{Z.current=!0,Oe()},[Oe]);I(()=>{const i=()=>{ie&&(Ee(!1),Le({time:0,position:null}),E.current&&c.current?.play(),R(!1,!0))};return ie&&document.addEventListener("mouseup",i),()=>{document.removeEventListener("mouseup",i)}},[ie,R]);const Ct=se(()=>({togglePlay:ue,seek:ee,toggleMute:pe,toggleFullscreen:le,onPlay:Ne,onPause:$e,onLoadedMetadata:Me,formatTime:xt,onVolumeChange:Ae,onProgress:Re,onTimeUpdate:Fe,onEnded:De,setShowControls:z,setIsScrubbing:Ee,setHoverTime:Le,setIsAutoSkipEnabled:Je,setCurrentSkipInterval:he,setShowCCMenu:je,setSubtitleFontSize:Ze,setSubtitlePosition:tt,setSubtitleBgOpacity:rt,setSubtitleBgColor:ot,setSubtitleTextColor:ct,setSubtitleEdge:lt,setSubtitleBold:dt,setAvailableSubtitles:ft,setActiveSubtitleTrack:mt,setShowSettings:gt,setShowVolumeSlider:vt,wasPlayingBeforeScrub:E,inactivityTimer:l,setIsFullscreen:H,onWaiting:Pe,onPlaying:Ie,sendProgressUpdate:R,setUseNativeControls:Te}),[ue,ee,pe,le,Ne,$e,Me,Ae,Re,Fe,De,H,Pe,Ie,R,Te]);return{refs:{videoRef:c,playerContainerRef:f,progressBarRef:w},state:{isPlaying:B,isMuted:O,volume:h,isFullscreen:J,duration:D,showControls:Ke,isScrubbing:ie,hoverTime:Ge,isAutoSkipEnabled:me,currentSkipInterval:Qe,showCCMenu:Xe,subtitleFontSize:Ye,subtitlePosition:et,subtitleBgOpacity:nt,subtitleBgColor:st,subtitleTextColor:it,subtitleEdge:at,subtitleBold:ut,availableSubtitles:pt,activeSubtitleTrack:_t,showSettings:ht,showVolumeSlider:yt,isBuffering:bt,isSpeedBoostActive:wt,useNativeControls:St},actions:Ct}};function Vs(){try{return typeof navigator<"u"&&/android/i.test(navigator.userAgent)}catch{return!1}}function Mo(e,n){const{refs:r,actions:o}=e,s=y(n);s.current=n;const a=y(!1),g=y(!1),c=f=>{try{if(f)return f.matches}catch{}try{return window.innerWidth>window.innerHeight}catch{return!1}};I(()=>{if(!Vs())return;let f=null;const w=()=>{const l=r.playerContainerRef.current;if(c(f)){if(!s.current||!l||Y(r.videoRef.current)||g.current)return;a.current=!0,o.toggleFullscreen()}else g.current=!1,a.current&&(a.current=!1,Y(r.videoRef.current)&&o.toggleFullscreen())};try{f=window.matchMedia("(orientation: landscape)"),f.addEventListener?f.addEventListener("change",w):f.addListener(w)}catch{}return w(),()=>{try{f&&(f.removeEventListener?f.removeEventListener("change",w):f.removeListener(w))}catch{}}},[o,r.playerContainerRef,r.videoRef,n]),I(()=>{const f=()=>{if(!Y(r.videoRef.current)){a.current=!1;try{window.matchMedia("(orientation: landscape)").matches&&(g.current=!0)}catch{g.current=!0}}};return document.addEventListener("fullscreenchange",f),document.addEventListener("webkitfullscreenchange",f),()=>{document.removeEventListener("fullscreenchange",f),document.removeEventListener("webkitfullscreenchange",f)}},[r.videoRef])}const Us=e=>Math.max(8,Math.min(40,Math.ceil(e/16.7)+4));function Ao({videoRef:e,canvasRef:n,delayMs:r,enabled:o}){const s=y(r);s.current=r;const a=y([]),g=y(-1),c=y(-1),f=y(!1),w=y(0),l=y(null);I(()=>{const E=u=>{if(u)try{u.close()}catch{}},m=()=>{for(const u of a.current)E(u.bitmap);a.current=[]};if(!o){m(),g.current=-1,c.current=-1,f.current=!1,w.current=0;return}let L=!1;const _=()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)},p=()=>{L||(_(),l.current=requestAnimationFrame(()=>{v()}))};async function v(){if(L)return;const u=e.current,C=n.current;if(!u||!C||u.videoWidth===0){p();return}if(u.paused||u.ended||document.hidden||u.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){p();return}const d=u.getVideoPlaybackQuality().totalVideoFrames;if(d===g.current){p();return}(u.seeking||c.current>=0&&Math.abs(u.currentTime-c.current)>.5)&&(m(),f.current=!1,w.current=0,g.current=-1),c.current=u.currentTime,(C.width!==u.videoWidth||C.height!==u.videoHeight)&&(C.width=u.videoWidth,C.height=u.videoHeight);const B=Math.max(0,s.current||0);B>w.current&&(f.current=!1);try{const $=await createImageBitmap(u);if(L){E($);return}g.current=d;const O=performance.now(),M=C.getContext("2d"),h=D=>{M&&M.drawImage(D,0,0,C.width,C.height)};if(B<=0){m(),f.current=!1,w.current=0,h($),E($),p();return}const A=a.current;A.push({bitmap:$,capture:O});const J=Us(B);for(;A.length>J;)E(A.shift()?.bitmap);let H=-1;for(let D=A.length-1;D>=0;D--)if(O-A[D].capture>=B){H=D;break}if(H!==-1){for(let oe=0;oe<H;oe++)E(A.shift()?.bitmap);const D=A.shift();D?(h(D.bitmap),E(D.bitmap),f.current=!0,w.current=B):h($)}else if(!f.current)h($);else{const D=A.shift();D?(h(D.bitmap),E(D.bitmap)):h($)}}catch{}p()}return p(),()=>{L=!0,_();for(const u of a.current)try{u.bitmap.close()}catch{}a.current=[]}},[o,e,n])}const Ks="_row_1fq55_1",Gs="_rowHeader_1fq55_9",Js="_rowLabel_1fq55_17",Qs="_rowValue_1fq55_28",Xs="_slider_1fq55_36",js="_swatches_1fq55_99",Ys="_swatch_1fq55_99",Zs="_swatchPicked_1fq55_114",eo="_colorInput_1fq55_120",to="_segmented_1fq55_131",q={row:Ks,rowHeader:Gs,rowLabel:Js,rowValue:Qs,slider:Xs,swatches:js,swatch:Ys,swatchPicked:Zs,colorInput:eo,segmented:to},no=({label:e,display:n,min:r,max:o,step:s,value:a,percent:g,onChange:c,onCommit:f})=>t("div",{className:q.row,children:[t("div",{className:q.rowHeader,children:[t("span",{className:q.rowLabel,children:e}),t("span",{className:q.rowValue,children:n})]}),t("input",{type:"range",className:q.slider,min:r,max:o,step:s,value:a,"aria-label":e,onInput:w=>c(Number(w.target.value)),onPointerUp:f,onPointerCancel:f,onTouchEnd:f,onKeyUp:f,onBlur:f,style:{"--slider-percent":`${g}%`}})]}),Ro=({label:e,colors:n,value:r,onChange:o})=>t("div",{className:q.row,children:[t("div",{className:q.rowHeader,children:t("span",{className:q.rowLabel,children:e})}),t("div",{className:q.swatches,children:[n.map(s=>t("button",{type:"button","aria-label":`${e} ${s}`,"aria-pressed":r.toLowerCase()===s.toLowerCase(),onClick:()=>o(s),className:`${q.swatch} ${r.toLowerCase()===s.toLowerCase()?q.swatchPicked:""}`,style:{backgroundColor:s}},s)),t("input",{type:"color","aria-label":`Custom ${e.toLowerCase()}`,className:q.colorInput,value:r,onInput:s=>o(s.target.value)})]})]});function Fo({label:e,options:n,value:r,onChange:o}){return t("div",{className:q.row,children:[t("div",{className:q.rowHeader,children:t("span",{className:q.rowLabel,children:e})}),t("div",{className:q.segmented,role:"group","aria-label":e,children:n.map(s=>t("button",{type:"button","aria-pressed":r===s,onClick:()=>o(s),children:[t("span",{children:s}),r===s&&t(U,{name:"check",size:10})]},s))})]})}const _e=10,xe=500,Se=e=>Math.max(0,Math.min(xe,Math.round(e))),Oo=({isOpen:e,ms:n,onChange:r,onApply:o,onClose:s,testClipActive:a,onTestClip:g})=>e?t("div",{role:"dialog","aria-label":"Calibrate audio video sync","data-speed-boost-ignore":"true",onClick:c=>c.stopPropagation(),style:{position:"absolute",right:8,bottom:112,width:"min(260px, calc(100% - 16px))",maxHeight:"calc(100% - 124px)",overflowY:"auto",overflowX:"hidden",zIndex:60,display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:12,borderRadius:"var(--radius-lg)",border:"1px solid var(--glass-border)",background:"rgba(18, 18, 22, 0.95)",boxShadow:"var(--glass-shadow)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxSizing:"border-box"},children:[t("div",{style:{fontSize:"0.8rem",fontWeight:800,color:"var(--text-primary)"},children:"A/V sync"}),t("div",{children:t(ne,{size:"sm",variant:"secondary",onClick:g,children:a?"Back to video":"Preview test clip"})}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,flexWrap:"wrap"},children:[t(ne,{size:"sm",onClick:()=>r(Se(n-_e)),"aria-label":"Decrease delay by 10 milliseconds",children:["− ",_e,"ms"]}),t("div",{style:{fontSize:"1.1rem",fontWeight:800,minWidth:64,textAlign:"center"},children:[n,"ms"]}),t(ne,{size:"sm",onClick:()=>r(Se(n+_e)),"aria-label":"Increase delay by 10 milliseconds",children:["+ ",_e,"ms"]})]}),t(no,{label:"Video delay",display:`${n}ms`,min:0,max:xe,step:5,value:n,percent:n/xe*100,onChange:c=>r(Se(c))}),t("div",{style:{display:"flex",gap:8,justifyContent:"center",flexWrap:"wrap"},children:[t(ne,{size:"sm",variant:"secondary",onClick:s,children:"Cancel"}),t(ne,{size:"sm",onClick:o,children:["Apply ",n,"ms"]})]})]}):null;export{Oo as A,So as B,Bo as C,K as D,Io as E,no as M,No as P,Eo as S,wo as T,To as U,Lo as a,Ao as b,Mo as c,go as d,yo as e,Co as f,xo as g,bo as h,Gr as i,lo as j,Ts as k,fo as l,ao as m,j as n,Po as o,ho as p,_o as q,vo as r,Xr as s,ko as t,$o as u,mo as v,uo as w,po as x,Ro as y,Fo as z};
@@ -1 +0,0 @@
1
- import{d as D,A as U,h as O,q as E,g as q,u as e,L as Pe,T as Q,S as le,a as te,_ as je}from"./vendor-core-8R2fFbyN.js";import{b as Ke,u as Ze,a as Je}from"./vendor-query-BXRECSI6.js";import{S as Ee,A as De,P as et}from"./SkeletonGrid-B5loz7ii.js";import{A as re}from"./AnimeCard-D4qo4289.js";import{I as F}from"./vendor-icons-CDMuNDeL.js";import{u as ke,a as se,b as tt,c as at,d as ze,s as nt,f as Se,B as We,e as ne,g as Le,h as rt,i as ot,j as st,k as lt,l as it,m as ct,n as dt,o as ut,p as ht,q as mt}from"./index-CtoKRNLc.js";import{u as pt}from"./vendor-ui-CUDCvRS_.js";import{E as Ce}from"./ErrorMessage-z4f4WGgP.js";import{R as Oe}from"./ResetProgressModal-DWeiO-hs.js";import{Q as gt}from"./QueueRail-B7DeSFoA.js";import{M as _e}from"./MediaCard-DpKoY-1j.js";import{u as Fe,M as Ve}from"./useMangaPopup-PnmSctHu.js";import{M as vt}from"./MangaResetProgressModal-Dian37PQ.js";import{u as Ge,a as _t,m as we,i as Ue,b as qe,c as He,d as ft,e as bt}from"./useMangaLibrary-rM6z3_0E.js";import{u as yt}from"./useProviders-B3VB7A9M.js";import{u as Nt}from"./useMatureConsent-CT7-KfzG.js";import{u as Ye,a as $e,T as Tt}from"./useTv-BTUKMH7Q.js";import{T as St}from"./TvPopup-PlCU30FO.js";import{u as wt,a as kt,b as Ct,t as It,i as At,c as Rt}from"./useTvLibrary-C0sX-ilZ.js";import{A as Lt}from"./AsmrResetProgressModal-Gs0GmVaT.js";import{u as $t,a as xt,b as Mt}from"./useAsmr-CB9THf0m.js";import"./useAnimeInfoData-kr3WOIWH.js";import"./QueueOptionsButton-lv26-6jp.js";import"./useIsMobile-Dm_b6Ob3.js";const Bt="_sectionWrapper_2p2l1_9",Pt="_sectionTitleNoMargin_2p2l1_13",Et="_carousel_2p2l1_178",P={"section-header":"_section-header_2p2l1_1",sectionWrapper:Bt,sectionTitleNoMargin:Pt,"title-wrapper":"_title-wrapper_2p2l1_17","header-controls":"_header-controls_2p2l1_24","header-select":"_header-select_2p2l1_30","collapse-button":"_collapse-button_2p2l1_79","title-link":"_title-link_2p2l1_98","continue-watching":"_continue-watching_2p2l1_117","nav-arrows":"_nav-arrows_2p2l1_139","nav-button":"_nav-button_2p2l1_148","carousel-container":"_carousel-container_2p2l1_178",carousel:Et,"carousel-inner":"_carousel-inner_2p2l1_187","carousel-card":"_carousel-card_2p2l1_192"};function fe({align:a="start",containScroll:r="trimSnaps",scrollFraction:c=.8,threshold:t=.6,onReachThreshold:n}={}){const[i,s]=pt({align:a,containScroll:r,dragFree:!0}),[b,g]=D(!1),v=U({scrollFraction:c,threshold:t,onReachThreshold:n}),l=U(!1);O(()=>{v.current={scrollFraction:c,threshold:t,onReachThreshold:n}});const T=E(u=>{g(u.canScrollPrev()||u.canScrollNext())},[]);O(()=>{if(!s)return;const u=()=>{const d=s.scrollProgress();d>=v.current.threshold&&!l.current?(l.current=!0,v.current.onReachThreshold?.()):d<v.current.threshold&&(l.current=!1),T(s)};return s.on("init",u),s.on("reInit",u),s.on("scroll",u),s.on("resize",u),()=>{s.off("init",u),s.off("reInit",u),s.off("scroll",u),s.off("resize",u)}},[s,T]);const _=E(u=>{const d=u.containerNode().firstElementChild;if(!d)return 1;const h=u.rootNode().getBoundingClientRect().width,C=d.getBoundingClientRect().width;return C?Math.max(1,Math.round(h/C)):1},[]),o=E((u,d=!1)=>{if(!s)return;const h=Math.max(1,Math.round(_(s)*v.current.scrollFraction)),C=s.selectedScrollSnap()+(u==="left"?-h:h);s.scrollTo(C,d)},[s,_]),k=E((u=!1)=>{s?.scrollTo(0,u)},[s]);return{emblaRef:i,api:s,canScroll:b,stepBy:o,scrollToStart:k}}const ee=({title:a,eyebrow:r,titleLink:c,loading:t,emptyState:n,carousel:i,layout:s,collapsible:b,defaultExpanded:g=!0,onReachThreshold:v,scrollThreshold:l,isFetchingNextPage:T,resetScrollOnShrink:_,itemCount:o=0,highlight:k,headerActions:u,loadingSkeleton:d,skeletonCount:h=7,children:C})=>{const{lowEndMode:R}=ke(),{emblaRef:N,stepBy:L,scrollToStart:I}=fe({onReachThreshold:v,threshold:l}),[M,z]=q.useState(g);q.useEffect(()=>{z(g)},[g]);const B=q.useRef(0);return q.useEffect(()=>{_&&o>0&&M&&(o<=B.current||B.current===0)&&I(),o>0&&(B.current=o)},[o,_,M,I]),!t&&o===0&&!n&&!b?null:e("section",{className:`${P.sectionWrapper} ${k?P["continue-watching"]:""}`,children:[e("div",{className:P["section-header"],children:[e("div",{className:P["title-wrapper"],children:[e("div",{className:"title-stack",children:[r&&e("div",{className:"section-eyebrow",children:r}),c?e(Pe,{to:c,className:P["title-link"],children:e("div",{className:`section-title ${P.sectionTitleNoMargin}`,children:a})}):e("div",{className:`section-title ${P.sectionTitleNoMargin}`,children:a})]}),i&&o>0&&M&&e("div",{className:P["nav-arrows"],children:[e("button",{className:P["nav-button"],type:"button","aria-label":"Scroll left",onClick:$=>{$.preventDefault(),L("left",R)},children:e(F,{name:"chevron-left"})}),e("button",{className:P["nav-button"],type:"button","aria-label":"Scroll right",onClick:$=>{$.preventDefault(),L("right",R)},children:e(F,{name:"chevron-right"})})]})]}),e("div",{className:P["header-controls"],children:[u,b&&e("button",{className:P["collapse-button"],type:"button",onClick:()=>z($=>!$),"aria-expanded":M,"aria-label":M?`Collapse ${a}`:`Expand ${a}`,children:M?e(F,{name:"chevron-up"}):e(F,{name:"chevron-down"})})]})]}),M&&(i?!t&&o===0&&n?e("div",{children:n}):e("div",{className:P["carousel-container"],children:e("div",{className:P.carousel,ref:N,children:e("div",{className:P["carousel-inner"],children:[t&&o===0?Array.from({length:h}).map(($,A)=>e("div",{className:P["carousel-card"],children:d},A)):q.Children.map(C,($,A)=>e("div",{className:P["carousel-card"],children:$},q.isValidElement($)&&$.key!=null?$.key:`slide-${A}`)),T&&d&&e("div",{className:P["carousel-card"],children:d})]})})}):e("div",{className:"grid-container",children:t&&o===0?e(Ee,{count:6,layout:s}):o>0?C:t?null:e("div",{style:{gridColumn:"1 / -1"},children:n})}))]})},Dt=({title:a,eyebrow:r,animeList:c,continueWatching:t,titleLink:n,onRemove:i,loading:s,emptyState:b,carousel:g,cardConfig:v,layout:l,onReachThreshold:T,scrollThreshold:_,isFetchingNextPage:o,collapsible:k,defaultExpanded:u=!0})=>{const d=l||"vertical";return e(ee,{title:a,eyebrow:r,titleLink:n,loading:s,emptyState:b,carousel:g,layout:d,collapsible:k,defaultExpanded:u,onReachThreshold:T,scrollThreshold:_,isFetchingNextPage:o,resetScrollOnShrink:t,highlight:t,itemCount:c.length,loadingSkeleton:e(De,{layout:d}),skeletonCount:7,children:g?c.map(h=>e(re,{anime:h,continueWatching:t,onRemove:i,config:v,layout:d},h._id)):c.map(h=>e(re,{anime:h,continueWatching:t,onRemove:i,config:v,layout:d},h._id))})},xe=q.memo(Dt),zt="_sectionWrapper_c8uv6_2",Wt="_sectionTitleNoMargin_c8uv6_6",Ot="_timeSelect_c8uv6_80",Ft="_carouselContainer_c8uv6_111",Vt="_carousel_c8uv6_111",Gt="_carouselInner_c8uv6_122",Ut="_carouselItem_c8uv6_127",qt="_rankCard_c8uv6_164",Ht="_rankPill_c8uv6_168",Yt="_rankGold_c8uv6_179",Qt="_rankSilver_c8uv6_183",Xt="_rankBronze_c8uv6_187",jt="_skeletonPoster_c8uv6_198",Kt="_skeletonText_c8uv6_199",f={sectionWrapper:zt,sectionTitleNoMargin:Wt,"section-header":"_section-header_c8uv6_10","title-wrapper":"_title-wrapper_c8uv6_18","nav-arrows":"_nav-arrows_c8uv6_40","nav-button":"_nav-button_c8uv6_49",timeSelect:Ot,carouselContainer:Ft,carousel:Vt,carouselInner:Gt,carouselItem:Ut,rankCard:qt,rankPill:Ht,rankGold:Yt,rankSilver:Qt,rankBronze:Xt,skeletonPoster:jt,skeletonText:Kt},Me="TRENDING_DESC",Zt="POPULARITY_DESC",Jt=10;function ea({title:a,eyebrow:r}){const{lowEndMode:c}=ke(),[t,n]=se("trending_sort",Me),i=[{value:Me,label:"Trending"},{value:Zt,label:"All Time"}],{data:s,fetchNextPage:b,hasNextPage:g,isFetchingNextPage:v,isLoading:l,isError:T,error:_}=tt(t,Jt),o=Q(()=>s?.pages.flatMap(h=>h)||[],[s]),k=E(()=>{g&&!v&&!l&&b()},[g,v,l,b]),{emblaRef:u,stepBy:d}=fe({onReachThreshold:k});return e("section",{className:f.sectionWrapper,children:[e("div",{className:f["section-header"],children:[e("div",{className:f["title-wrapper"],children:[e("div",{className:"title-stack",children:[r&&e("div",{className:"section-eyebrow",children:r}),e("div",{className:`section-title ${f.sectionTitleNoMargin}`,children:a})]}),e("div",{className:f["nav-arrows"],children:[e("button",{className:f["nav-button"],type:"button",onClick:h=>{h.preventDefault(),d("left",c)},"aria-label":"Scroll left",children:e(F,{name:"chevron-left"})}),e("button",{className:f["nav-button"],type:"button",onClick:h=>{h.preventDefault(),d("right",c)},"aria-label":"Scroll right",children:e(F,{name:"chevron-right"})})]})]}),e("div",{className:f["header-actions"],children:e("select",{className:f.timeSelect,value:t,onChange:h=>n(h.currentTarget.value),children:i.map(h=>e("option",{value:h.value,children:h.label},h.value))})})]}),l?e("div",{className:f.carouselContainer,children:e("div",{className:f.carousel,children:e("div",{className:f.carouselInner,children:Array.from({length:7}).map((h,C)=>e("div",{className:f.carouselItem,children:[e("div",{className:f.skeletonPoster}),e("div",{className:f.skeletonText})]},C))})})}):T?e(Ce,{message:_ instanceof Error?_.message:"An unknown error occurred"}):e("div",{className:f.carouselContainer,children:e("div",{className:f.carousel,ref:u,children:e("div",{className:f.carouselInner,children:[o.map((h,C)=>e("div",{className:f.carouselItem,children:[e("div",{className:f.rankCard,children:e(re,{anime:h})}),e("div",{className:`${f.rankPill} ${C===0?f.rankGold:C===1?f.rankSilver:C===2?f.rankBronze:""}`,children:C+1})]},h._id)),v&&e("div",{className:f.carouselItem,style:{minWidth:"150px",display:"flex",alignItems:"center",justifyContent:"center"},children:e("div",{className:f.skeletonPoster})})]})})})]})}const ta=[{value:"TV",label:"TV"},{value:"ONA",label:"ONA"},{value:"OVA",label:"OVA"},{value:"MOVIE",label:"Movie"},{value:"ALL",label:"All"},{value:"ADULT",label:"Mature"}],aa=10;function na({eyebrow:a}){const{lowEndMode:r}=ke(),[c,t]=se("latest_releases_format","TV"),{data:n,fetchNextPage:i,hasNextPage:s,isFetchingNextPage:b,isLoading:g,isError:v,error:l}=at(c,aa),T=Q(()=>n?.pages.flatMap(u=>u)||[],[n]),_=E(()=>{s&&!b&&!g&&i()},[s,b,g,i]),{emblaRef:o,stepBy:k}=fe({onReachThreshold:_});return e("section",{className:f.sectionWrapper,children:[e("div",{className:f["section-header"],children:[e("div",{className:f["title-wrapper"],children:[e("div",{className:"title-stack",children:[a&&e("div",{className:"section-eyebrow",children:a}),e("div",{className:`section-title ${f.sectionTitleNoMargin}`,children:"Latest Releases"})]}),e("div",{className:f["nav-arrows"],children:[e("button",{className:f["nav-button"],type:"button",onClick:u=>{u.preventDefault(),k("left",r)},"aria-label":"Scroll left",children:e(F,{name:"chevron-left"})}),e("button",{className:f["nav-button"],type:"button",onClick:u=>{u.preventDefault(),k("right",r)},"aria-label":"Scroll right",children:e(F,{name:"chevron-right"})})]})]}),e("div",{className:f["header-actions"],children:e("select",{className:f.timeSelect,value:c,onChange:u=>t(u.currentTarget.value),children:ta.map(u=>e("option",{value:u.value,children:u.label},u.value))})})]}),g?e("div",{className:f.carouselContainer,children:e("div",{className:f.carousel,children:e("div",{className:f.carouselInner,children:Array.from({length:7}).map((u,d)=>e("div",{className:f.carouselItem,children:[e("div",{className:f.skeletonPoster}),e("div",{className:f.skeletonText})]},d))})})}):v?e(Ce,{message:l instanceof Error?l.message:"An unknown error occurred"}):e("div",{className:f.carouselContainer,children:e("div",{className:f.carousel,ref:o,children:e("div",{className:f.carouselInner,children:[T.map(u=>e("div",{className:f.carouselItem,children:e(re,{anime:u})},u._id)),b&&e("div",{className:f.carouselItem,style:{minWidth:"150px",display:"flex",alignItems:"center",justifyContent:"center"},children:e("div",{className:f.skeletonPoster})})]})})})]})}const ra="_scheduleSection_10dfe_1",oa="_sectionTitleRow_10dfe_5",sa="_sectionTitleNoMargin_10dfe_11",la="_sectionHeader_10dfe_15",ia="_headerActions_10dfe_25",ca="_timeSelect_10dfe_31",da="_daySelectorContainer_10dfe_62",ua="_daySelector_10dfe_62",ha="_daySelectorInner_10dfe_79",ma="_dayBtn_10dfe_90",pa="_active_10dfe_113",ga="_dayMonth_10dfe_121",va="_dayNum_10dfe_129",_a="_dayName_10dfe_135",fa="_navArrows_10dfe_148",ba="_navButton_10dfe_157",ya="_carouselContainer_10dfe_181",Na="_carousel_10dfe_181",Ta="_carouselInner_10dfe_193",Sa="_carouselCard_10dfe_198",x={scheduleSection:ra,sectionTitleRow:oa,sectionTitleNoMargin:sa,sectionHeader:la,headerActions:ia,timeSelect:ca,daySelectorContainer:da,daySelector:ua,daySelectorInner:ha,dayBtn:ma,active:pa,dayMonth:ga,dayNum:va,dayName:_a,navArrows:fa,navButton:ba,carouselContainer:ya,carousel:Na,carouselInner:Ta,carouselCard:Sa},ue=a=>{const r=a.getFullYear(),c=String(a.getMonth()+1).padStart(2,"0"),t=String(a.getDate()).padStart(2,"0");return`${r}-${c}-${t}`},wa=async(a,r)=>{const c=`/api/schedule/${a}?format=${r}`,t=await fetch(c);if(!t.ok)throw new Error("Failed to fetch episode schedule");return t.json()},ka=({eyebrow:a})=>{const[r,c]=D(()=>ue(new Date)),[t,n]=se("schedule_format","TV"),{emblaRef:i,canScroll:s,stepBy:b,scrollToStart:g}=fe(),v=U(null),l=U(!0),{data:T=[],isLoading:_,error:o}=Ke({queryKey:["schedule",r,t],queryFn:()=>wa(r,t),staleTime:1e3*60*5}),k=Q(()=>{const d=[],h=new Date,C=ue(h),R=new Date(h);R.setDate(h.getDate()-1);const N=ue(R),L=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let I=-6;I<=6;I++){const M=new Date;M.setDate(h.getDate()+I),d.push(M)}return d.map(I=>{const M=ue(I),$=M===C?"Today":M===N?"Yest":L[I.getDay()],A=I.getDate(),Z=new Intl.DateTimeFormat("en-US",{month:"short"}).format(I);return{dateString:M,dayLabel:$,dayNum:A,monthName:Z}})},[]);O(()=>{if(l.current){l.current=!1;return}if(v.current){const d=v.current.querySelector(`[data-date="${r}"]`);d&&d.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})}},[r]),O(()=>{g(!0)},[r,g]);const u=[{value:"TV",label:"TV"},{value:"ONA",label:"ONA"},{value:"OVA",label:"OVA"},{value:"MOVIE",label:"Movie"},{value:"ALL",label:"All"},{value:"ADULT",label:"Mature"}];return e("div",{className:x.scheduleSection,children:[e("div",{className:x.sectionHeader,children:[e("div",{className:x.sectionTitleRow,children:[e("div",{className:"title-stack",children:[a&&e("div",{className:"section-eyebrow",children:a}),e("h2",{className:`section-title ${x.sectionTitleNoMargin}`,children:"Episode Schedule"})]}),T.length>0&&s&&e("div",{className:x.navArrows,children:[e("button",{className:x.navButton,onClick:()=>b("left"),"aria-label":"Scroll left",children:e(F,{name:"chevron-left"})}),e("button",{className:x.navButton,onClick:()=>b("right"),"aria-label":"Scroll right",children:e(F,{name:"chevron-right"})})]})]}),e("div",{className:x.headerActions,children:e("select",{className:x.timeSelect,value:t,onChange:d=>n(d.target.value),children:u.map(d=>e("option",{value:d.value,children:d.label},d.value))})})]}),e("div",{className:x.daySelectorContainer,children:e("div",{className:x.daySelector,ref:v,children:e("div",{className:x.daySelectorInner,children:k.map(d=>e("button",{type:"button","data-date":d.dateString,className:`${x.dayBtn} ${r===d.dateString?x.active:""}`,onClick:()=>c(d.dateString),children:[e("span",{className:x.dayMonth,children:d.monthName}),e("span",{className:x.dayNum,children:d.dayNum}),e("span",{className:x.dayName,children:d.dayLabel})]},d.dateString))})})}),e("div",{className:x.carouselContainer,children:e("div",{className:x.carousel,ref:i,children:e("div",{className:x.carouselInner,children:_?Array.from({length:7}).map((d,h)=>e("div",{className:x.carouselCard,children:e(De,{layout:"vertical"})},h)):o?e("div",{style:{width:"100%"},children:e(Ce,{message:o instanceof Error?o.message:"An unknown error occurred"})}):T.length===0?e("p",{style:{textAlign:"center",marginTop:"1rem",width:"100%"},children:"No episodes scheduled for this day."}):T.map(d=>e("div",{className:x.carouselCard,children:e(re,{anime:d,continueWatching:!1,layout:"vertical"},d._id)},d._id))})})})]})},Ca="_bannerContainer_1r6xz_1",Ia="_hero_1r6xz_28",Aa="_ambient_1r6xz_37",Ra="_ambientShow_1r6xz_49",La="_scrim_1r6xz_53",$a="_progressLine_1r6xz_69",xa="_paused_1r6xz_89",Ma="_dots_1r6xz_103",Ba="_dot_1r6xz_103",Pa="_dotActive_1r6xz_132",Ea="_viewport_1r6xz_138",Da="_track_1r6xz_145",za="_slide_1r6xz_151",Wa="_slideInner_1r6xz_159",Oa="_poster_1r6xz_169",Fa="_info_1r6xz_179",Va="_kicker_1r6xz_183",Ga="_featureLabel_1r6xz_190",Ua="_scoreChip_1r6xz_202",qa="_rise_1r6xz_220",Ha="_active_1r6xz_224",Ya="_metaRow_1r6xz_280",Qa="_metaItem_1r6xz_291",Xa="_metaDivider_1r6xz_297",ja="_title_1r6xz_304",Ka="_genres_1r6xz_320",Za="_genreTag_1r6xz_328",Ja="_summary_1r6xz_339",en="_actions_1r6xz_351",tn="_watchBtn_1r6xz_358",an="_detailsBtn_1r6xz_380",nn="_navArrow_1r6xz_401",rn="_prevArrow_1r6xz_434",on="_nextArrow_1r6xz_438",y={bannerContainer:Ca,hero:Ia,ambient:Aa,ambientShow:Ra,scrim:La,progressLine:$a,paused:xa,dots:Ma,dot:Ba,dotActive:Pa,viewport:Ea,track:Da,slide:za,slideInner:Wa,poster:Oa,info:Fa,kicker:Va,featureLabel:Ga,scoreChip:Ua,rise:qa,active:Ha,metaRow:Ya,metaItem:Qa,metaDivider:Xa,title:ja,genres:Ka,genreTag:Za,summary:Ja,actions:en,watchBtn:tn,detailsBtn:an,navArrow:nn,prevArrow:rn,nextArrow:on},sn=8e3,he=()=>e("div",{className:"skeleton",style:{width:"100vw",maxWidth:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",height:"clamp(480px, 72vh, 660px)",marginTop:"calc(-1 * var(--header-height))",marginBottom:"2.5rem"}}),be=({slides:a,posterClassName:r})=>{const[c,t]=D(0),[n,i]=D(0),[s,b]=D(!1),[g,v]=D(null),[l,T]=D(0),[_,o]=D({front:"",back:"",flip:!1}),k=U(0),u=U(0),d=U(new Set),h=U(null),C=U(0),R=E(m=>m.bannerSrc,[]),N=E(()=>{i(m=>m+1)},[]),L=E(m=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null),v(null),N();const S=R(a[m]);o(w=>w.flip?{front:S,back:w.back,flip:!1}:{front:w.front,back:S,flip:!0}),t(m)},[N,a,R]),I=E(m=>{if(a.length===0)return;const S=(m%a.length+a.length)%a.length;d.current.has(R(a[S]))?L(S):v(S)},[a,R,L]);O(()=>{let m=!1;return a.forEach(S=>{const w=R(S);if(!w||d.current.has(w))return;const p=new Image;p.src=w;const G=()=>{m||d.current.has(w)||(d.current.add(w),T(V=>V+1))};p.onload=G,p.onerror=G}),()=>{m=!0}},[a,R]),O(()=>{if(a.length!==0&&!_.front){const m=R(a[0]);o({front:m,back:"",flip:!1})}},[a,_.front,R]),O(()=>{if(g!==null){if(g<0||g>=a.length){v(null);return}d.current.has(R(a[g]))&&L(g)}},[g,l,a,R,L]),O(()=>{if(g===null)return;h.current!==null&&window.clearTimeout(h.current);const m=g;return h.current=window.setTimeout(()=>{h.current=null,L(m)},2500),()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)}},[g,L]);const M=E(m=>{I(m)},[I]),z=E(()=>{I(C.current+1)},[I]),B=E(()=>{I(C.current-1)},[I]),$=U(null);if(O(()=>{const m=$.current;if(!m)return;const S=w=>{if(Math.abs(w.deltaY)>Math.abs(w.deltaX)&&Math.abs(w.deltaY)>5){w.preventDefault(),w.stopPropagation();const p=Date.now();if(p-k.current<300)return;k.current=p,N(),w.deltaY>0?z():B()}};return m.addEventListener("wheel",S,{passive:!1}),()=>m.removeEventListener("wheel",S)},[a.length,z,B,N]),O(()=>{if(a.length===0||s)return;const m=setTimeout(z,sn);return()=>clearTimeout(m)},[c,z,a.length,n,s]),O(()=>{const m=S=>{const w=S.target;w&&(w.tagName==="INPUT"||w.tagName==="TEXTAREA"||w.tagName==="SELECT"||w.isContentEditable)||(S.key==="ArrowRight"?(S.preventDefault(),z()):S.key==="ArrowLeft"&&(S.preventDefault(),B()))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[z,B]),O(()=>{c>=a.length&&t(0)},[a.length,c]),a.length===0)return null;const A=c>=a.length?0:c;C.current=A;const Z=m=>{u.current=m.touches[0].clientX},Y=m=>{const w=m.changedTouches[0].clientX-u.current;Math.abs(w)>50&&(N(),w>0?B():z())};return e("div",{className:y.bannerContainer,onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),children:e("div",{className:`${y.hero} ${s?y.paused:""}`,onTouchStart:Z,onTouchEnd:Y,children:[_.front&&e("img",{src:_.front,alt:"","aria-hidden":"true",className:`${y.ambient} ${_.flip?"":y.ambientShow}`}),_.back&&e("img",{src:_.back,alt:"","aria-hidden":"true",className:`${y.ambient} ${_.flip?y.ambientShow:""}`}),e("div",{className:y.scrim,"aria-hidden":"true"}),a.length>1&&e("div",{className:y.progressLine,"aria-hidden":"true"},`progress-${n}-${A}`),a.length>1&&e("div",{className:y.dots,ref:$,role:"tablist","aria-label":"Spotlight slides",children:a.map((m,S)=>e("button",{role:"tab","aria-selected":S===A,"aria-label":`Go to slide ${S+1}: ${m.title}`,className:`${y.dot} ${S===A?y.dotActive:""}`,onClick:()=>M(S),tabIndex:S===A?0:-1},m.key))}),e("div",{className:y.viewport,children:e("div",{className:y.track,style:{transform:`translateX(-${A*100}%)`},children:a.map((m,S)=>e("div",{className:`${y.slide} ${S===A?y.active:""}`,"aria-hidden":S!==A,children:e("div",{className:y.slideInner,children:[e("img",{src:m.posterSrc,alt:m.posterAlt,className:r??y.poster,decoding:"async"}),e("div",{className:y.info,children:[e("div",{className:`${y.kicker} ${y.rise}`,children:[e("span",{className:y.featureLabel,children:"Spotlight"}),m.score!==void 0&&m.score!==null&&m.score!==""&&e("span",{className:y.scoreChip,children:[e(F,{name:"star",size:12}),e("span",{children:m.score})]})]}),e(Pe,{to:m.detailTo,className:`${y.title} ${y.rise}`,"aria-label":`View details for ${m.title}`,tabIndex:S===A?0:-1,children:m.title}),m.metaItems.length>0&&e("div",{className:`${y.metaRow} ${y.rise}`,children:m.metaItems.map((w,p)=>e(q.Fragment,{children:[e("span",{className:y.metaItem,children:w}),p<m.metaItems.length-1&&e("div",{className:y.metaDivider})]},p))}),m.tags.length>0&&e("div",{className:`${y.genres} ${y.rise}`,children:m.tags.slice(0,3).map(w=>e("span",{className:y.genreTag,children:w},w))}),m.synopsis&&e("p",{className:`${y.summary} ${y.rise}`,children:m.synopsis}),e("div",{className:`${y.actions} ${y.rise}`,children:[e("button",{className:y.watchBtn,onClick:m.onPrimary,tabIndex:S===A?0:-1,children:[e(F,{name:m.primaryIcon,size:14}),e("span",{children:m.primaryLabel})]}),e("button",{className:y.detailsBtn,onClick:m.onDetails,tabIndex:S===A?0:-1,children:[e(F,{name:"info-circle",size:15}),e("span",{children:"Details"})]})]})]})]})},m.key))})}),a.length>1&&e(le,{children:[e("button",{className:`${y.navArrow} ${y.prevArrow}`,onClick:()=>{N(),B()},"aria-label":"Previous slide",children:e(F,{name:"chevron-left",size:20})}),e("button",{className:`${y.navArrow} ${y.nextArrow}`,onClick:()=>{N(),z()},"aria-label":"Next slide",children:e(F,{name:"chevron-right",size:20})})]})]})})},ln=({animeList:a})=>{const{titlePreference:r}=ze(),c=te(),t=Q(()=>a.slice(0,6).map(n=>{const i=r==="nativeName"?n.nativeName||n.name:r==="englishName"&&n.englishName||n.name;return{key:n._id,bannerSrc:n.bannerImage?Se(n.bannerImage,1280,560):Se(n.thumbnail,1280,450),posterSrc:Se(n.thumbnail,460,650),posterAlt:i,title:i,detailTo:`/anime/${n._id}`,score:n.score,metaItems:[n.type||"Anime",n.status,n.episodeCount?`${n.episodeCount} Episodes`:void 0,n.rating].filter(s=>!!s),tags:(n.genres??[]).slice(0,3).map(s=>typeof s=="string"?s:s?.name).filter(s=>!!s),synopsis:nt(n.description??""),primaryLabel:"Watch Now",primaryIcon:"play",onPrimary:()=>c(`/watch/${n._id}`),onDetails:()=>c(`/anime/${n._id}`)}}),[a,r,c]);return e(be,{slides:t})},cn="_emptyState_19tmt_1",dn="_emptyStateIcon_19tmt_16",un="_emptyStateTitle_19tmt_23",hn="_emptyStateText_19tmt_30",me={emptyState:cn,emptyStateIcon:dn,emptyStateTitle:un,emptyStateText:hn},ye=({icon:a,text:r,actionLabel:c,onAction:t,title:n="Nothing is here..."})=>e("div",{className:me.emptyState,children:[e(F,{name:a,size:48,className:me.emptyStateIcon}),e("div",{children:[e("h3",{className:me.emptyStateTitle,children:n}),e("p",{className:me.emptyStateText,children:r})]}),e(We,{variant:"primary",size:"sm",onClick:t,style:{marginTop:"1rem"},children:c})]}),mn="_select_1dw63_1",pn={select:mn},ge=({value:a,options:r,onChange:c,ariaLabel:t,width:n})=>e("select",{className:pn.select,style:n!==void 0?{width:n}:void 0,value:a,"aria-label":t,onChange:i=>c(i.currentTarget.value),children:r.map(i=>e("option",{value:i.value,children:i.label},i.value))}),gn="_tabBar_irwbm_1",vn="_tabIndicator_irwbm_24",_n="_tabButton_irwbm_38",fn="_tabActive_irwbm_64",pe={tabBar:gn,tabIndicator:vn,tabButton:_n,tabActive:fn};function bn({options:a,value:r,onChange:c,ariaLabel:t},n){const i=U(null),s=U(new Map),[b,g]=D({left:0,width:0}),v=E(l=>{const T=s.current.get(l),_=i.current;if(T&&_){const o=_.getBoundingClientRect(),k=T.getBoundingClientRect();g({left:k.left-o.left+_.scrollLeft,width:k.width}),T.scrollIntoView({block:"nearest",inline:"nearest"})}},[]);return je(()=>{v(r)},[r,a.length,v]),O(()=>{if(v(r),typeof ResizeObserver>"u")return;let l=0;const T=i.current;if(!T)return;const _=new ResizeObserver(()=>{cancelAnimationFrame(l),l=requestAnimationFrame(()=>v(r))});_.observe(T);let o=!1;return document.fonts?.ready&&document.fonts.ready.then(()=>{o||v(r)}),()=>{o=!0,cancelAnimationFrame(l),_.disconnect()}},[r,a.length,v]),e("div",{className:pe.tabBar,ref:l=>{i.current=l,typeof n=="function"?n(l):n&&(n.current=l)},"aria-label":t,children:[e("div",{className:pe.tabIndicator,style:{left:b.left,width:b.width}}),a.map(l=>e(We,{ref:T=>{T&&s.current.set(l.value,T)},variant:"secondary",size:"sm",className:`${pe.tabButton} ${r===l.value?pe.tabActive:""}`,onClick:()=>c(l.value),children:l.label},l.value))]})}const ve=q.forwardRef(bn),yn=[{value:"popular",label:"Popular"},{value:"followed",label:"Most Followed"},{value:"rating",label:"Top Rated"}];function Nn(){const{options:a}=yt();return Q(()=>a.filter(r=>r.kind==="manga").map(r=>r.value)[0]??"",[a])}const Be=({title:a,eyebrow:r,provider:c,sort:t,mature:n,headerActions:i})=>{const{toggle:s,bookmarkedIds:b}=Ge(),{popup:g,openPopup:v,scheduleClose:l,cancelClose:T,closePopup:_}=Fe(),{data:o,isLoading:k,fetchNextPage:u,hasNextPage:d,isFetchingNextPage:h}=_t({provider:c,query:"",sort:t,status:"",type:"",rating:n?"safe,suggestive,erotica,pornographic":"safe",mature:n}),C=Q(()=>o?.pages.flatMap(N=>N.items)??[],[o]),R=E(()=>{d&&!h&&!k&&u()},[d,h,k,u]);return c?e(le,{children:[e(ee,{title:a,eyebrow:r,loading:k,carousel:!0,itemCount:C.length,headerActions:i,onReachThreshold:R,isFetchingNextPage:h,loadingSkeleton:e("div",{className:"skeleton",style:{aspectRatio:"3 / 4"}}),skeletonCount:7,children:C.map(N=>{const L=we(N.provider,N.id);return e(_e,{item:{id:L,title:N.title,...He(N),thumbnail:qe(N.provider,N.cover),typeBadge:N.type||void 0,chapterBadge:N.latestChapter?`Ch. ${N.latestChapter}`:null,isAdult:Ue(N)},linkTo:`/manga/${N.provider}/${encodeURIComponent(N.id)}`,hoverIcon:"info",showInfoButton:!0,display:{elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!1,meta:!1}}},onOpenDetails:I=>v(I,{provider:N.provider,mangaId:N.id,title:N.title,altTitle:N.altTitle,cover:N.cover,contentRating:N.contentRating,readTarget:`/manga/${N.provider}/${encodeURIComponent(N.id)}`,mature:n}),onPopupHoverIntent:I=>I?T():l(),rawThumbnail:!0},`${N.provider}-${N.id}`)})}),g&&e(Ve,{data:g.data,anchorRect:g.rect,bookmarked:b.has(we(g.data.provider,g.data.mangaId)),onToggleBookmark:()=>s({id:g.data.mangaId,provider:g.data.provider,title:g.data.title,cover:g.data.cover,altTitle:g.data.altTitle??void 0,contentRating:g.data.contentRating}),onMouseEnter:T,onMouseLeave:l,onRequestClose:_})]}):null},Tn=()=>{const a=Nn(),{hasConsent:r}=Nt(),[c,t]=se("manga_discover_tab","latest"),[n,i]=se("manga_trending_sort","popular");return a?e(le,{children:[e(ve,{ariaLabel:"Discover manga",options:[{value:"latest",label:"Latest Releases"},{value:"trending",label:"Trending"}],value:c,onChange:t}),c==="latest"?e(Be,{title:"Latest Releases",eyebrow:"Fresh chapters",provider:a,sort:"latest",mature:r}):e(Be,{title:"Trending",eyebrow:"Discover",provider:a,sort:n,mature:r,headerActions:e("select",{className:P["header-select"],value:n,onChange:s=>i(s.currentTarget.value),"aria-label":"Trending sort",children:yn.map(s=>e("option",{value:s.value,children:s.label},s.value))})})]}):null},Sn=()=>{const a=te(),{data:r,isLoading:c}=ft(24),[t,n]=D(null),{popup:i,openPopup:s,scheduleClose:b,cancelClose:g,closePopup:v}=Fe(),{toggle:l,bookmarkedIds:T}=Ge(),_=r?.data??[];return e("div",{style:{paddingBottom:"2rem"},children:[e(ee,{title:"Continue Reading",eyebrow:"Pick up where you left off",titleLink:"/reading-list/Continue Reading",loading:c,carousel:!0,collapsible:!0,defaultExpanded:_.length>0,highlight:!0,itemCount:_.length,loadingSkeleton:e("div",{className:"skeleton",style:{aspectRatio:"3 / 4"}}),skeletonCount:7,emptyState:e(ye,{icon:"book",text:"You haven't read anything yet. Browse manga and open a chapter to start tracking.",actionLabel:"Browse Manga",onAction:()=>a("/manga")}),children:_.map(o=>{const k=o.page??0,u=o.pageCount??0,d=o.chapterId&&o.provider?`/manga/${o.provider}/${encodeURIComponent(o.mangaId)}/read?chapter=${encodeURIComponent(o.chapterId)}`:o.provider?`/manga/${o.provider}/${encodeURIComponent(o.mangaId)}`:"#";return e(_e,{item:{id:o.id,title:o.title,...He({title:o.title,altTitle:o.altTitle}),thumbnail:o.provider?qe(o.provider,o.cover||""):o.cover||"",chapterBadge:o.chapterNumber?`Ch. ${o.chapterNumber}`:null,isAdult:Ue(o)},linkTo:d,hoverIcon:"book",progress:u>0?{percent:k/u*100,label:`Ch. ${o.chapterNumber} · p. ${k}/${u}`}:void 0,showProgress:!0,display:{elements:{poster:{typeBadge:!1,chapterBadge:!0,adultBadge:!0,removeButton:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:()=>n({libId:o.id,title:o.title}),onOpenDetails:h=>s(h,{provider:o.provider||"",mangaId:o.mangaId||"",title:o.title||"",altTitle:o.altTitle,cover:o.cover||"",contentRating:o.contentRating||void 0,readTarget:d}),onPopupHoverIntent:h=>h?g():b(),rawThumbnail:!0},o.id)})}),e(vt,{mangaId:t?t.libId:null,title:t?.title,onClose:()=>n(null)}),i&&i.data.provider&&e(Ve,{data:i.data,anchorRect:i.rect,bookmarked:T.has(we(i.data.provider,i.data.mangaId)),onToggleBookmark:()=>l({id:i.data.mangaId,provider:i.data.provider,title:i.data.title,cover:i.data.cover,altTitle:i.data.altTitle??void 0,contentRating:i.data.contentRating}),onMouseEnter:g,onMouseLeave:b,onRequestClose:v}),e(Tn,{})]})},wn="_seasonGrid_bt5c7_76",kn="_emptyState_bt5c7_108",H={"section-header":"_section-header_bt5c7_1","title-wrapper":"_title-wrapper_bt5c7_8","pagination-controls":"_pagination-controls_bt5c7_14",seasonGrid:wn,emptyState:kn},Cn=[{value:"latest",label:"Latest Releases"},{value:"trending",label:"Trending"}],In=[{value:"trending_week",label:"Trending Now"},{value:"trending_day",label:"Trending Today"},{value:"popular",label:"Popular All Time"},{value:"top_rated",label:"Top Rated"}],An=()=>{const a=te(),{data:r,isLoading:c}=wt(24),t=kt(),n=Ct(),[i,s]=D(null),[b,g]=D(!1),[v,l]=D(()=>localStorage.getItem("tv_home_activeTab")||"latest"),[T,_]=D("tv"),[o,k]=D("trending_week"),[u,d]=D("multi"),h=r?.data??[];q.useEffect(()=>{localStorage.setItem("tv_home_activeTab",v)},[v]);const C=o.startsWith("trending_"),R=o==="trending_day"?"day":"week",N={popular:"popularity.desc",top_rated:"vote_average.desc"},{data:L,isLoading:I}=Ye(u==="multi"?"all":u,R,1,C&&v==="trending"),{data:M,isLoading:z}=$e({type:u,sort_by:N[o]||"popularity.desc",page:1}),B=C?L?.results||[]:M?.results||[],$=C?I:z,{data:A,isLoading:Z}=$e({type:T,sort_by:"primary_release_date.desc",page:1}),Y=A?.results||[],m=()=>{i&&(n.mutate({mediaId:i.libId}),b&&t.mutate(i.libId),s(null),g(!1))},S=E(p=>e(Tt,{item:{id:p.id,title:p.title,year:p.year,type:p.type,image:p.image,vote_average:p.vote_average,adult:p.adult}},`${p.type}-${p.id}`),[]),w=()=>{switch(v){case"latest":return e("section",{children:[e("div",{className:H["section-header"],children:[e("div",{className:H["title-wrapper"],children:e("div",{className:"title-stack",children:[e("div",{className:"section-eyebrow",children:"Fresh picks"}),e("div",{className:"section-title",style:{marginBottom:0},children:"Latest Releases"})]})}),e("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:e(ge,{ariaLabel:"Latest type",value:T,onChange:p=>_(p),options:[{value:"tv",label:"TV Shows"},{value:"movie",label:"Movies"}]})})]}),Z?e("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"var(--space-6)"},children:Array.from({length:7}).map((p,G)=>e("div",{className:"skeleton",style:{aspectRatio:"3 / 4",borderRadius:"var(--radius-lg)"}},G))}):Y.length>0?e(ee,{carousel:!0,itemCount:Y.length,children:Y.map(S)}):e("div",{className:H.emptyState,children:e("p",{children:"No latest releases available right now."})})]});case"trending":return e("section",{children:[e("div",{className:H["section-header"],children:[e("div",{className:H["title-wrapper"],children:e("div",{className:"title-stack",children:[e("div",{className:"section-eyebrow",children:"Discover"}),e("div",{className:"section-title",style:{marginBottom:0},children:"Trending"})]})}),e("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e(ge,{ariaLabel:"Trending sort",value:o,onChange:k,options:In.map(p=>({value:p.value,label:p.label}))}),e(ge,{ariaLabel:"Trending type",value:u,onChange:p=>d(p),options:[{value:"multi",label:"All"},{value:"tv",label:"TV Shows"},{value:"movie",label:"Movies"}]})]})]}),$?e("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"var(--space-6)"},children:Array.from({length:7}).map((p,G)=>e("div",{className:"skeleton",style:{aspectRatio:"3 / 4",borderRadius:"var(--radius-lg)"}},G))}):B.length>0?e(ee,{carousel:!0,itemCount:B.length,children:B.map(S)}):e("div",{className:H.emptyState,children:e("p",{children:"No trending content available right now."})})]})}};return e("div",{style:{paddingBottom:"2rem"},children:[e(ee,{title:"Continue Watching",eyebrow:"Pick up where you left off",titleLink:"/tv-watchlist/Continue Watching",loading:c,carousel:!0,collapsible:!0,defaultExpanded:h.length>0,highlight:!0,itemCount:h.length,loadingSkeleton:e("div",{className:"skeleton",style:{aspectRatio:"3 / 4"}}),skeletonCount:7,emptyState:e(ye,{icon:"tv",text:"You haven't watched anything yet. Search TV & Movies and start watching to track progress.",actionLabel:"Browse TV & Movies",onAction:()=>a("/tv-search")}),children:h.map(p=>{const G=p.currentTime??0,V=p.duration??0,ie=p.season??p.lastSeason??1,K=p.episode??p.lastEpisode??1,X=p.mediaType==="movie",ae=X?"Movie":`S${ie} E${K}`,J=p.completed===!0||p.completed===1||V>0&&G>=V*.8,ce=J?100:V>0&&G>0?G/V*100:0,de=J?"Watched":V>0?X?`${ne(G)} / ${ne(V)}`:`${ae} · ${ne(G)} / ${ne(V)}`:ae;return e(_e,{item:{id:p.id,title:p.title,thumbnail:p.poster||"",typeBadge:X?"Movie":"TV",chapterBadge:ae,isAdult:At({adult:p.adult===1})},linkTo:It(p.mediaType,p.tmdbId,X?void 0:ie,X?void 0:K),hoverIcon:"play",progress:(V>0||J)&&ce>0?{percent:ce,label:de}:void 0,showProgress:!0,metaRow:p.year?e("span",{style:{opacity:.75},children:p.year}):void 0,onRemove:()=>s({libId:p.id,title:p.title}),renderPopup:(Ne,oe)=>e(St,{item:{id:p.tmdbId??0,title:p.title||"",year:p.year||"",type:p.mediaType||"tv",image:p.poster||""},anchorRect:Ne,onMouseEnter:oe.onMouseEnter,onMouseLeave:oe.onMouseLeave,onRequestClose:oe.close})},p.id)})}),e(ve,{ariaLabel:"Browse TV",options:Cn,value:v,onChange:l}),e("div",{className:H.tabContent,children:w()}),e(Oe,{isOpen:!!i,itemName:i?.title,progressKind:"watch",listLabel:"my TV watchlist",alsoRemove:b,onAlsoRemoveChange:g,onClose:()=>{s(null),g(!1)},onConfirm:m})]})};function Rn(a){const r=a.currentTime??0,c=a.duration??0,t=(a.trackIndex??0)+1;return c>0?`Track ${t} · ${ne(r)} / ${ne(c)}`:a.trackLabel?`Track ${t} · ${a.trackLabel}`:`Track ${t}`}const Ln=({title:a="Continue Listening",limit:r=24,titleLink:c,showEmptyState:t=!0})=>{const n=te(),{data:i,isLoading:s}=$t(r),[b,g]=D(null),v=i?.data??[];return e(le,{children:[e(ee,{title:a,eyebrow:"Pick up where you left off",titleLink:c??"/listening-list/Continue Listening",loading:s,carousel:!0,collapsible:!0,defaultExpanded:v.length>0,highlight:!0,itemCount:v.length,loadingSkeleton:e("div",{className:"skeleton",style:{aspectRatio:"16 / 9"}}),skeletonCount:7,emptyState:t?e(ye,{icon:"headphones",text:"You haven't listened to anything yet. Browse ASMR and play a track to start tracking.",actionLabel:"Browse ASMR",onAction:()=>n("/asmr")}):void 0,children:v.map(l=>{const T=l.currentTime??0,_=l.duration??0,o=l.rjCode||l.id;return e(_e,{item:{id:l.id,title:l.title,thumbnail:l.thumbnail||"",chapterBadge:`Track ${(l.trackIndex??0)+1}`,isAdult:!!l.isAdult},linkTo:`/asmr/${encodeURIComponent(o)}`,hoverIcon:"play",layout:"horizontal",progress:_>0?{percent:Math.min(100,T/_*100),label:Rn(l)??""}:void 0,showProgress:!0,display:{elements:{poster:{typeBadge:!1,chapterBadge:!0,adultBadge:!0,removeButton:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:()=>g({workId:l.id,title:l.title}),rawThumbnail:!0},l.id)})}),e(Lt,{workId:b?b.workId:null,title:b?.title,onClose:()=>g(null)})]})},$n=()=>e("div",{style:{paddingBottom:"2rem"},children:e(Ln,{})}),xn={10759:"Action & Adventure",16:"Animation",35:"Comedy",80:"Crime",18:"Drama",10765:"Sci-Fi & Fantasy",9648:"Mystery",28:"Action",12:"Adventure",14:"Fantasy",27:"Horror",878:"Sci-Fi",53:"Thriller",10749:"Romance"},Mn=({items:a})=>{const r=te(),c=Q(()=>a.slice(0,6).map(t=>{const n=Rt(t.type,t.id);return{key:String(t.id),bannerSrc:t.backdrop?t.backdrop:t.image,posterSrc:t.image,posterAlt:t.title,title:t.title,detailTo:n,score:t.vote_average>0?Number(t.vote_average).toFixed(1):null,metaItems:[t.type==="tv"?"TV Show":"Movie",t.year].filter(Boolean),tags:t.genre_ids.slice(0,3).map(i=>xn[i]).filter(Boolean),synopsis:t.overview.length>200?t.overview.slice(0,200)+"...":t.overview,primaryLabel:"Watch Now",primaryIcon:"play",onPrimary:()=>r(n),onDetails:()=>r(n)}}),[a,r]);return e(be,{slides:c})},Bn=({mangaList:a})=>{const r=te(),c=Q(()=>a.slice(0,6).map(t=>({key:t.id,bannerSrc:t.cover||"",posterSrc:t.cover,posterAlt:t.title,title:t.title,detailTo:`/manga/mangadex/${t.id}`,metaItems:[t.year?String(t.year):void 0,t.status??void 0].filter(n=>!!n),tags:t.tags.slice(0,3),synopsis:t.description?.slice(0,200)||"",primaryLabel:"Read Now",primaryIcon:"book",onPrimary:()=>r(`/manga/mangadex/${t.id}`),onDetails:()=>r(`/manga/mangadex/${t.id}`)})),[a,r]);return e(be,{slides:c})},Pn="_posterLandscape_1smau_1",En={posterLandscape:Pn};function Dn(a){const r=a.availableEpisodes?.sub;if(typeof r=="number"&&r>0)return r;const c=a.availableEpisodesDetail?.sub,t=a.availableEpisodesDetail?.dub,n=(Array.isArray(c)?c.length:0)+(Array.isArray(t)?t.length:0);return n>0?n:null}const zn=({works:a})=>{const r=te(),c=Q(()=>a.slice(0,6).map((t,n)=>{const i=xt(t),s=`/asmr/${encodeURIComponent(i)}`,b=Dn(t);return{key:i||t._id||String(n),bannerSrc:t.thumbnail||"",posterSrc:t.thumbnail,posterAlt:t.name,title:t.name,detailTo:s,metaItems:[t.rating?t.rating.toUpperCase():void 0,b?`${b} track${b===1?"":"s"}`:void 0].filter(g=>!!g),tags:[],synopsis:t.description?.slice(0,160)||"",primaryLabel:"Listen Now",primaryIcon:"play",onPrimary:()=>r(s),onDetails:()=>r(s)}}),[a,r]);return e(be,{slides:c,posterClassName:En.posterLandscape})},Wn=[{value:"anime",label:"Anime"},{value:"manga",label:"Manga"},{value:"tv",label:"TV & Movies"},{value:"asmr",label:"ASMR"}],dr=()=>{const a=Ze(),[r,c]=q.useState(1),[t,n]=D(()=>localStorage.getItem("home_activeTab")||"latest"),[i,s]=D(()=>localStorage.getItem("season_format")||"TV"),b=U(null),{data:g}=Le(r+1,i,t==="season"),{titlePreference:v}=ze(),{contentType:l,setContentType:T}=rt(),[_,o]=q.useState(null),[k,u]=q.useState(!1),d=ot(),{data:h=[]}=st(),C=lt(),R=it(),N=ct();O(()=>{document.title="Home - dango"},[]);const{data:L,isLoading:I}=dt();O(()=>{localStorage.setItem("home_activeTab",t)},[t]),O(()=>{localStorage.setItem("season_format",i),c(1)},[i]),O(()=>{L!==void 0&&L.length===0&&t==="week"&&n("latest")},[L,t]);const{data:M,isLoading:z,fetchNextPage:B,hasNextPage:$,isFetchingNextPage:A}=ut(),Z=E(()=>{$&&!A&&!z&&B()},[$,A,z,B]),{data:Y,isLoading:m}=ht(),{data:S,isLoading:w}=Ye("all","week",1,l==="tv"),{data:p,isLoading:G}=Mt(l==="asmr"),{data:V,isLoading:ie}=bt(),K=Q(()=>M?.pages||[],[M]),{data:X,isLoading:ae}=Le(r,i,t==="season"),J=14,ce=X&&X.length>=J&&g&&g.length>0,de=Je({mutationFn:async W=>{await mt("/api/continue-watching/remove",{method:"POST",body:JSON.stringify({showId:W})})},onSuccess:async()=>{await a.invalidateQueries({queryKey:["allContinueWatching"]}),$&&K.length-1<14&&B()}}),Ne=E(W=>{const j=K?.find(Te=>String(Te.id)===String(W));if(j){const Te=j[v]||j.name;o({id:W,name:Te})}},[K,v]),oe=E(()=>{_&&(de.mutate(_.id),k&&d.mutate(_.id),o(null),u(!1))},[_,de,d,k]),Ie=[{key:"latest",label:"Latest Releases"},{key:"season",label:"Current Season"},{key:"popular",label:"Trending"}],Ae=L!==void 0&&L.length>0,Qe=Ae?[{key:"week",label:"This Week"},...Ie]:Ie,Re=t==="week"&&!Ae?"latest":t,Xe=()=>{switch(Re){case"latest":return e(na,{eyebrow:"Fresh episodes"});case"season":return e("section",{style:{marginBottom:"2.5rem"},children:[e("div",{className:H["section-header"],ref:b,children:[e("div",{className:H["title-wrapper"],children:e("div",{className:"title-stack",children:[e("div",{className:"section-eyebrow",children:"This season"}),e("div",{className:"section-title",style:{marginBottom:0},children:"Current Season"})]})}),e("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e(ge,{ariaLabel:"Season format",width:90,value:i,onChange:s,options:[{value:"TV",label:"TV"},{value:"ONA",label:"ONA"},{value:"OVA",label:"OVA"},{value:"MOVIE",label:"Movie"},{value:"ALL",label:"All"},{value:"ADULT",label:"Mature"}]}),e("div",{className:H["pagination-controls"],children:e(et,{page:r,canGoNext:ce,onChange:W=>{if(c(W),b.current){const j=b.current.getBoundingClientRect().top+window.scrollY-120;window.scrollTo({top:j,behavior:"smooth"})}},isLoading:ae})})]})]}),e("div",{className:`grid-container ${H.seasonGrid}`,style:{minHeight:"300px",alignContent:"start"},children:ae?e(Ee,{count:J}):X?.slice(0,J).map(W=>e(re,{anime:W},W._id))})]});case"popular":return e(ea,{title:"Trending",eyebrow:"Discover"});case"week":return e(xe,{title:"This Week",eyebrow:"Aired this week",animeList:L||[],continueWatching:!1,carousel:!0,loading:I});default:return null}};return e("div",{style:{paddingBottom:"2rem"},children:[l==="anime"&&(m&&!Y?.length?e(he,{}):Y&&Y.length>0&&e(ln,{animeList:Y})),l==="tv"&&(w&&!S?.results?.length?e(he,{}):S?.results&&S.results.length>0&&e(Mn,{items:S.results})),l==="manga"&&(ie&&!V?.length?e(he,{}):V&&V.length>0&&e(Bn,{mangaList:V})),l==="asmr"&&(G&&!p?.length?e(he,{}):p&&p.length>0&&e(zn,{works:p})),e(ve,{ariaLabel:"Content type",options:Wn,value:l,onChange:T}),l==="manga"?e(Sn,{}):l==="tv"?e(An,{}):l==="asmr"?e($n,{}):e(le,{children:[e(xe,{title:"Continue Watching",eyebrow:"Pick up where you left off",titleLink:"/watchlist/Continue Watching",animeList:K,continueWatching:!0,carousel:!0,collapsible:!0,defaultExpanded:K.length>0,onRemove:Ne,loading:z,onReachThreshold:Z,scrollThreshold:.7,isFetchingNextPage:A,emptyState:e(ye,{icon:"history",text:"You haven't watched anything yet. Start exploring and watch something first!",actionLabel:"Explore Trending",onAction:()=>n("popular")})}),e(gt,{title:"Queue",eyebrow:"Up next",items:h,onRemove:W=>C.mutate({showId:W.showId,episodeNumber:W.episodeNumber}),showClearAll:!0,onClear:()=>R.mutate(),onReorder:W=>N.mutate(W.map(j=>({id:j.id,showId:j.showId,episodeNumber:j.episodeNumber})))}),e(ve,{ariaLabel:"Browse anime",options:Qe.map(W=>({value:W.key,label:W.label})),value:Re,onChange:n}),e("div",{className:H.tabContent,children:Xe()}),e(ka,{eyebrow:"Never miss an episode"}),e(Oe,{isOpen:!!_,itemName:_?.name,progressKind:"watch",listLabel:"my watchlist",alsoRemove:k,onAlsoRemoveChange:u,onClose:()=>{o(null),u(!1)},onConfirm:oe})]})]})};export{dr as default};
@@ -1 +0,0 @@
1
- import{h as G,T as i,d as R,u as e,L as W}from"./vendor-core-8R2fFbyN.js";import{b as j,u as P,a as O}from"./vendor-query-BXRECSI6.js";import{X as F,d as A,z as S,q as V,f as C}from"./index-CtoKRNLc.js";import{I as o}from"./vendor-icons-CDMuNDeL.js";const Y="_header_1j07c_1",q="_fadeIn_1j07c_1",H="_personaBadge_1j07c_9",E="_personaInfo_1j07c_37",z="_personaLabel_1j07c_42",U="_personaValue_1j07c_51",K="_statsGrid_1j07c_57",Q="_slideUpIn_1j07c_1",J="_statCard_1j07c_65",X="_statIcon_1j07c_82",Z="_statInfo_1j07c_98",ee="_statValue_1j07c_103",ae="_statLabel_1j07c_112",te="_wideSection_1j07c_120",se="_sectionHeader_1j07c_132",ne="_yearSelect_1j07c_147",re="_heatmapLayout_1j07c_176",ce="_dayLabels_1j07c_183",oe="_heatmapWrapper_1j07c_195",le="_heatmapMonthLabels_1j07c_201",ie="_heatmapGrid_1j07c_212",de="_heatBox_1j07c_220",he="_hiddenBox_1j07c_229",me="_level0_1j07c_240",pe="_level1_1j07c_243",_e="_level2_1j07c_247",ue="_level3_1j07c_251",ge="_level4_1j07c_255",Ne="_heatmapFooter_1j07c_260",ve="_heatLegend_1j07c_267",ye="_chartsContainer_1j07c_277",be="_chartWrapper_1j07c_285",fe="_hourlyChart_1j07c_312",je="_hourlyBarContainer_1j07c_320",Se="_hourlyBar_1j07c_320",Ce="_hourlyLabel_1j07c_346",ke="_chartSubtext_1j07c_353",Le="_popScale_1j07c_365",we="_popTrack_1j07c_369",Be="_popThumb_1j07c_377",Ie="_popLabels_1j07c_389",De="_popDescription_1j07c_399",xe="_seasonalChart_1j07c_414",Te="_seasonalBarContainer_1j07c_422",Me="_seasonalBar_1j07c_422",$e="_seasonalLabel_1j07c_444",Ge="_genreList_1j07c_452",Re="_genreRow_1j07c_459",We="_genreInfo_1j07c_465",Pe="_genreName_1j07c_472",Oe="_genreCount_1j07c_479",Fe="_genreBarBg_1j07c_486",Ae="_genreBar_1j07c_486",Ve="_warningSection_1j07c_499",Ye="_warningHeader_1j07c_510",qe="_droppedGrid_1j07c_526",He="_droppedCard_1j07c_532",Ee="_droppedName_1j07c_549",ze="_droppedDate_1j07c_556",Ue="_genreGrid_1j07c_597",Ke="_genreCard_1j07c_609",Qe="_rankBadge_1j07c_618",Je="_rankNumber_1j07c_631",Xe="_genreTitle_1j07c_637",Ze="_genreStats_1j07c_645",ea="_posterRow_1j07c_653",aa="_miniPoster_1j07c_660",ta="_genreCardSkeleton_1j07c_674",sa="_pulse_1j07c_1",na="_skeletonRank_1j07c_682",ra="_skeletonTitle_1j07c_696",ca="_skeletonStats_1j07c_709",oa="_skeletonPosters_1j07c_721",la="_recSection_1j07c_752",ia="_recSubtext_1j07c_763",da="_recGrid_1j07c_769",ha="_recCard_1j07c_775",ma="_recCover_1j07c_790",pa="_recInfo_1j07c_798",_a="_recTitle_1j07c_805",ua="_recMatch_1j07c_816",ga="_recMeta_1j07c_822",Na="_recWhy_1j07c_827",va="_recNote_1j07c_832",ya="_recAddBtn_1j07c_838",a={header:Y,fadeIn:q,personaBadge:H,personaInfo:E,personaLabel:z,personaValue:U,statsGrid:K,slideUpIn:Q,statCard:J,statIcon:X,statInfo:Z,statValue:ee,statLabel:ae,wideSection:te,sectionHeader:se,yearSelect:ne,heatmapLayout:re,dayLabels:ce,heatmapWrapper:oe,heatmapMonthLabels:le,heatmapGrid:ie,heatBox:de,hiddenBox:he,level0:me,level1:pe,level2:_e,level3:ue,level4:ge,heatmapFooter:Ne,heatLegend:ve,chartsContainer:ye,chartWrapper:be,hourlyChart:fe,hourlyBarContainer:je,hourlyBar:Se,hourlyLabel:Ce,chartSubtext:ke,popScale:Le,popTrack:we,popThumb:Be,popLabels:Ie,popDescription:De,seasonalChart:xe,seasonalBarContainer:Te,seasonalBar:Me,seasonalLabel:$e,genreList:Ge,genreRow:Re,genreInfo:We,genreName:Pe,genreCount:Oe,genreBarBg:Fe,genreBar:Ae,warningSection:Ve,warningHeader:Ye,droppedGrid:qe,droppedCard:He,droppedName:Ee,droppedDate:ze,genreGrid:Ue,genreCard:Ke,rankBadge:Qe,rankNumber:Je,genreTitle:Xe,genreStats:Ze,posterRow:ea,miniPoster:aa,genreCardSkeleton:ta,pulse:sa,skeletonRank:na,skeletonTitle:ra,skeletonStats:ca,skeletonPosters:oa,recSection:la,recSubtext:ia,recGrid:da,recCard:ha,recCover:ma,recInfo:pa,recTitle:_a,recMatch:ua,recMeta:ga,recWhy:Na,recNote:va,recAddBtn:ya},Ca=()=>{G(()=>{document.title="Insights - dango"},[]);const{data:n,isLoading:k,isError:L}=j({queryKey:["insights"],queryFn:async()=>{const t=await fetch("/api/insights");if(!t.ok)throw new Error("Failed to fetch insights");return t.json()}}),{data:w,isLoading:p}=F(),{titlePreference:B}=A(),_=P(),{data:u}=j({queryKey:["insights-recommendations"],queryFn:async()=>{const t=await fetch("/api/insights/recommendations");if(!t.ok)throw new Error("Failed to fetch recommendations");return t.json()},staleTime:300*1e3,retry:1}),g=O({mutationFn:async t=>{await V("/api/watchlist/add",{method:"POST",body:JSON.stringify({id:String(t.id),name:t.title,thumbnail:t.cover||"",status:"Plan to Watch",type:t.format})})},onSuccess:()=>{_.invalidateQueries({queryKey:["watchlist"]}),_.invalidateQueries({queryKey:["insights-recommendations"]}),S.success("Added to Plan to Watch")},onError:()=>S.error("Could not add to watchlist")}),N=i(()=>[...u?.candidates||[]].sort((t,s)=>s.matchPct-t.matchPct).slice(0,6),[u]),v=t=>{const s=t.name||t.englishName||t.nativeName||"";switch(B){case"nativeName":return t.nativeName||s;case"englishName":return t.englishName||s;default:return s}},[d,I]=R(new Date().getFullYear()),D=i(()=>{if(!n?.activityGrid)return[new Date().getFullYear()];const t=new Set(n.activityGrid.map(s=>parseInt(s.day.split("-")[0])));return t.add(new Date().getFullYear()),Array.from(t).sort((s,r)=>r-s)},[n]),y=i(()=>{if(!n?.activityGrid)return[];const t=new Map(n.activityGrid.map(m=>[m.day,m.count])),s=[],r=new Date(d,0,1),l=new Date(d,11,31),h=r.getDay(),c=new Date(r);for(c.setDate(c.getDate()-h);(c<=l||c.getDay()!==0)&&!(c>l&&c.getDay()===0);){const m=c.getFullYear(),M=String(c.getMonth()+1).padStart(2,"0"),$=String(c.getDate()).padStart(2,"0"),b=`${m}-${M}-${$}`,f=c<r||c>l;s.push({date:b,count:f?0:t.get(b)||0,month:c.getMonth(),isOutOfRange:f}),c.setDate(c.getDate()+1)}return s},[n,d]),x=i(()=>n?.seasonality?.length?Math.max(...n.seasonality.map(t=>t.seconds),1):0,[n]),T=i(()=>n?.hourlyDist?.length?Math.max(...n.hourlyDist.map(t=>t.count),1):0,[n]);return k||p?e("div",{className:a.loading,children:"Analyzing your anime lifestyle..."}):L?e("div",{className:a.error,children:"Could not load insights. Data might be syncing."}):n?e("div",{className:"page-container",children:[e("div",{className:a.header,children:[e("h2",{className:"section-title",children:"Watch Insights"}),e("div",{className:a.personaBadge,children:[e(o,{name:"user-astronaut"}),e("div",{className:a.personaInfo,children:[e("span",{className:a.personaLabel,children:"Your Persona"}),e("span",{className:a.personaValue,children:n.persona})]})]})]}),e("div",{className:a.statsGrid,children:[e("div",{className:a.statCard,children:[e("div",{className:a.statIcon,style:{background:"rgba(138, 79, 255, 0.2)",color:"var(--accent)"},children:e(o,{name:"clock"})}),e("div",{className:a.statInfo,children:[e("span",{className:a.statValue,children:[n.totalHours,"h"]}),e("span",{className:a.statLabel,children:"Watch Time"})]})]}),e("div",{className:a.statCard,children:[e("div",{className:a.statIcon,style:{background:"rgba(167, 139, 250, 0.2)",color:"#a78bfa"},children:e(o,{name:"bookmark"})}),e("div",{className:a.statInfo,children:[e("span",{className:a.statValue,children:n.totalAnime}),e("span",{className:a.statLabel,children:"Total Anime"})]})]}),e("div",{className:a.statCard,children:[e("div",{className:a.statIcon,style:{background:"rgba(34, 197, 94, 0.2)",color:"#22c55e"},children:e(o,{name:"check-circle"})}),e("div",{className:a.statInfo,children:[e("span",{className:a.statValue,children:n.totalEpisodes}),e("span",{className:a.statLabel,children:"Episodes Watched"})]})]}),e("div",{className:a.statCard,children:[e("div",{className:a.statIcon,style:{background:"rgba(34, 197, 94, 0.2)",color:"#22c55e"},children:e(o,{name:"check-circle"})}),e("div",{className:a.statInfo,children:[e("span",{className:a.statValue,children:[n.completionRate,"%"]}),e("span",{className:a.statLabel,children:"Completion Rate"})]})]}),e("div",{className:a.statCard,children:[e("div",{className:a.statIcon,style:{background:"rgba(45, 212, 191, 0.2)",color:"#2dd4bf"},children:e(o,{name:"tv"})}),e("div",{className:a.statInfo,children:[e("span",{className:a.statValue,children:n.completedAnime}),e("span",{className:a.statLabel,children:"Completed Shows"})]})]}),e("div",{className:a.statCard,children:[e("div",{className:a.statIcon,style:{background:"rgba(239, 68, 68, 0.2)",color:"#ef4444"},children:e(o,{name:"fire"})}),e("div",{className:a.statInfo,children:[e("span",{className:a.statValue,children:n.bingeFactor}),e("span",{className:a.statLabel,children:"Max Daily Binge"})]})]}),e("div",{className:a.statCard,children:[e("div",{className:a.statIcon,style:{background:"rgba(59, 130, 246, 0.2)",color:"#3b82f6"},children:e(o,{name:"history"})}),e("div",{className:a.statInfo,children:[e("span",{className:a.statValue,children:[n.avgSessionMinutes,"m"]}),e("span",{className:a.statLabel,children:"Avg. Session"})]})]}),e("div",{className:a.statCard,children:[e("div",{className:a.statIcon,style:{background:"rgba(251, 191, 36, 0.2)",color:"#fbbf24"},children:e(o,{name:"layer-group"})}),e("div",{className:a.statInfo,children:[e("span",{className:a.statValue,children:[n.avgCompletionDays,"d"]}),e("span",{className:a.statLabel,children:"Avg. Speed"})]})]})]}),e("div",{className:a.wideSection,children:[e("div",{className:a.sectionHeader,children:[e("h3",{children:"Activity"}),e("select",{className:a.yearSelect,value:d,onChange:t=>I(Number(t.currentTarget.value)),children:D.map(t=>e("option",{value:t,children:t},t))})]}),e("div",{className:a.heatmapLayout,children:[e("div",{className:a.dayLabels,children:[e("span",{style:{gridRow:2},children:"Mon"}),e("span",{style:{gridRow:4},children:"Wed"}),e("span",{style:{gridRow:6},children:"Fri"})]}),e("div",{className:a.heatmapWrapper,children:[e("div",{className:a.heatmapMonthLabels,children:(()=>{const t=[];let s=-1;return y.forEach((r,l)=>{if(r.month!==s&&!r.isOutOfRange){const h=Math.floor(l/7)+1;h>(t.length>0?t[t.length-1].props.style.gridColumn+2:-1)&&(t.push(e("span",{style:{gridColumn:h,whiteSpace:"nowrap"},children:new Date(0,r.month).toLocaleString("default",{month:"short"})},l)),s=r.month)}}),t})()}),e("div",{className:a.heatmapGrid,children:y.map((t,s)=>{let r=0;return t.count>0&&!t.isOutOfRange&&(r=1),t.count>2&&!t.isOutOfRange&&(r=2),t.count>5&&!t.isOutOfRange&&(r=3),t.count>10&&!t.isOutOfRange&&(r=4),e("div",{className:`${a.heatBox} ${a[`level${r}`]} ${t.isOutOfRange?a.hiddenBox:""}`,title:t.isOutOfRange?"":`${t.count} episodes on ${t.date}`},s)})}),e("div",{className:a.heatmapFooter,children:e("div",{className:a.heatLegend,children:[e("span",{children:"Less"}),e("div",{className:`${a.heatBox} ${a.level0}`}),e("div",{className:`${a.heatBox} ${a.level1}`}),e("div",{className:`${a.heatBox} ${a.level2}`}),e("div",{className:`${a.heatBox} ${a.level3}`}),e("div",{className:`${a.heatBox} ${a.level4}`}),e("span",{children:"More"})]})})]})]})]}),e("div",{className:a.chartsContainer,children:[e("div",{className:a.chartWrapper,children:[e("h3",{children:"Time Distribution (24h)"}),e("div",{className:a.hourlyChart,children:n.hourlyDist?.map((t,s)=>e("div",{className:a.hourlyBarContainer,children:[e("div",{className:a.hourlyBar,style:{height:`${t.count/T*100||2}%`,width:"100%",maxWidth:"12px"},title:`${t.count} watches at ${t.hour}:00`}),e("span",{className:a.hourlyLabel,style:{visibility:s%4===0?"visible":"hidden"},children:t.hour})]},s))}),e("div",{className:a.chartSubtext,children:(()=>{if(!n.hourlyDist?.length)return"Watch more to see your peak hours!";const t=parseInt([...n.hourlyDist].sort((s,r)=>r.count-s.count)[0].hour);return t>=6&&t<19?"You prefer daytime watching ☀️":"You're a confirmed Night Owl 🦉"})()})]}),e("div",{className:a.chartWrapper,children:[e("h3",{children:"Popularity Bias"}),e("div",{className:a.popScale,children:[e("div",{className:a.popTrack,children:e("div",{className:a.popThumb,style:{left:`${Math.max(0,Math.min(100,100-n.popularityScore*10))}%`}})}),e("div",{className:a.popLabels,children:[e("span",{children:"Mainstream"}),e("span",{children:"Underground"})]})]}),e("p",{className:a.popDescription,children:["Your taste score is ",e("strong",{children:[n.popularityScore,"/10"]}),".",n.popularityScore>=5?" You follow the big hits!":" You're a connoisseur of the obscure!"]})]}),e("div",{className:a.chartWrapper,children:[e("h3",{children:"Monthly Activity"}),e("div",{className:a.seasonalChart,children:n.seasonality?.map((t,s)=>e("div",{className:a.seasonalBarContainer,children:[e("div",{className:a.seasonalBar,style:{height:`${t.seconds/x*100||5}%`,width:"100%",maxWidth:"24px"},title:`${Math.round(t.seconds/3600)}h in ${new Date(0,s).toLocaleString("default",{month:"long"})}`}),e("span",{className:a.seasonalLabel,children:new Date(0,s).toLocaleString("default",{month:"short"})})]},s))})]})]}),e("div",{className:a.genreGrid,children:p?Array.from({length:4}).map((t,s)=>e("div",{className:a.genreCardSkeleton,children:[e("div",{className:a.skeletonRank}),e("div",{className:a.skeletonTitle}),e("div",{className:a.skeletonStats}),e("div",{className:a.skeletonPosters})]},s)):w?.map(t=>e("div",{className:a.genreCard,children:[e("div",{className:a.rankBadge,children:e("span",{className:a.rankNumber,children:t.rank})}),e("h3",{className:a.genreTitle,children:t.name}),e("div",{className:a.genreStats,children:[e("span",{children:[t.count," episodes"]}),e("span",{children:t.meanScore>0?`${t.meanScore.toFixed(1)} avg score`:"—"}),e("span",{children:t.timeWatched})]}),e("div",{className:a.posterRow,children:t.topShows.map(s=>e("img",{src:C(s.thumbnail),alt:v(s),className:a.miniPoster,title:v(s),loading:"lazy",decoding:"async"},s.id))})]},t.name))}),N.length>0&&e("div",{className:a.recSection,children:[e("h3",{children:"Recommended For You"}),e("p",{className:a.recSubtext,children:"From your library taste — updates automatically as you watch"}),e("div",{className:a.recGrid,children:N.map(t=>e("div",{className:a.recCard,children:[t.cover&&e("img",{src:C(t.cover),alt:t.title,className:a.recCover,loading:"lazy",decoding:"async"}),e("div",{className:a.recInfo,children:[e(W,{to:`/anime/${t.id}`,className:a.recTitle,children:t.title}),e("span",{className:a.recMatch,children:[t.matchPct,"% match"]}),e("span",{className:a.recMeta,children:[t.year,t.format,t.episodes?`${t.episodes}ep`:null].filter(Boolean).join(" · ")}),e("span",{className:a.recWhy,children:["Shares ",t.sharedGenres.join(", "),t.exemplars.length>0&&` — like ${t.exemplars.join(", ")}`]}),t.kind==="continue"&&e("span",{className:a.recNote,children:"Continue — you watched the earlier part."}),t.kind==="sequel"&&t.prequelTitle&&e("span",{className:a.recNote,children:['Sequel — start with "',t.prequelTitle,'" first.']}),e("button",{className:a.recAddBtn,onClick:()=>g.mutate(t),disabled:g.isPending,children:"+ Plan to Watch"})]})]},t.id))})]}),n.droppedShows?.length>0&&e("div",{className:a.warningSection,children:[e("div",{className:a.warningHeader,children:[e(o,{name:"exclamation-triangle"}),e("h3",{children:"Dusty Watchlist (Inactive 90+ days)"})]}),e("div",{className:a.droppedGrid,children:n.droppedShows.map(t=>e("div",{className:a.droppedCard,children:[e("span",{className:a.droppedName,children:t.name}),e("span",{className:a.droppedDate,children:["Last watched: ",new Date(t.lastActivity).toLocaleDateString()]})]},t.id))})]})]}):null};export{Ca as default};