@serifpersia/dango 3.3.6 → 3.3.8

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 (86) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-OKU7LaSN.js → AnimeCard-D4qo4289.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-BCyLw0yz.js → AnimeInfo-BdRRm4So.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-BZWl-TJY.js → AnimeInfoPage-DeJNAKMR.js} +2 -2
  5. package/client/dist/assets/{Asmr-4S6uoevp.js → Asmr-D0EGRYsv.js} +1 -1
  6. package/client/dist/assets/{AsmrResetProgressModal-C8i6weqW.js → AsmrResetProgressModal-Gs0GmVaT.js} +1 -1
  7. package/client/dist/assets/{AvSyncCalibrator-oK6LlG61.js → AvSyncCalibrator-D8hqarVB.js} +1 -1
  8. package/client/dist/assets/Home-BnBzjFkW.js +1 -0
  9. package/client/dist/assets/Insights-Dc8xLmsr.css +1 -0
  10. package/client/dist/assets/Insights-i9QgY3nE.js +1 -0
  11. package/client/dist/assets/LibraryListPage-D3hTqTRU.js +1 -0
  12. package/client/dist/assets/{ListeningList-Dxkhy6E2.js → ListeningList-BgWsfu40.js} +1 -1
  13. package/client/dist/assets/{Manga-pJEpcUpo.js → Manga-Dn-CYins.js} +1 -1
  14. package/client/dist/assets/MangaInfoPage-EmQoK7Bv.js +1 -0
  15. package/client/dist/assets/MangaReadPage-xJB8K2YU.js +1 -0
  16. package/client/dist/assets/{MangaResetProgressModal-WjKH_G_f.js → MangaResetProgressModal-Dian37PQ.js} +1 -1
  17. package/client/dist/assets/Mature-DQtXKOXc.js +1 -0
  18. package/client/dist/assets/{MediaCard-DszKDA4s.js → MediaCard-DpKoY-1j.js} +1 -1
  19. package/client/dist/assets/{Music-CU6TBHF5.js → Music-BP43Zqmq.js} +1 -1
  20. package/client/dist/assets/{OptionListMenu-CkK2BvEz.js → OptionListMenu-Bj9ebsW3.js} +1 -1
  21. package/client/dist/assets/Player-O2Cy2GF1.js +56 -0
  22. package/client/dist/assets/PlayerSettings-DYZ272Yp.js +1 -0
  23. package/client/dist/assets/{QueueOptionsButton-DKWi-9kd.js → QueueOptionsButton-lv26-6jp.js} +1 -1
  24. package/client/dist/assets/{QueueRail-DAcIex5B.js → QueueRail-B7DeSFoA.js} +1 -1
  25. package/client/dist/assets/{Radio-BhTsgGGd.js → Radio-qQBYnVfY.js} +1 -1
  26. package/client/dist/assets/{ReadingList-BLnkwB--.js → ReadingList-BT8kUjCB.js} +1 -1
  27. package/client/dist/assets/{ResetProgressModal-8mcLXaAb.js → ResetProgressModal-DWeiO-hs.js} +1 -1
  28. package/client/dist/assets/Search-BkvPYN33.js +1 -0
  29. package/client/dist/assets/{Settings-bSA7BG7h.js → Settings-CyZEBF6S.js} +1 -1
  30. package/client/dist/assets/SkeletonGrid-B5loz7ii.js +1 -0
  31. package/client/dist/assets/SkeletonGrid-Bge3aRl2.css +1 -0
  32. package/client/dist/assets/Trackers-JK-aXBYC.js +2 -0
  33. package/client/dist/assets/{Tv-DJTbg4VW.js → Tv-BwXWJxMy.js} +1 -1
  34. package/client/dist/assets/{TvInfo-Z0c1Wh3i.js → TvInfo-Dzyq6ucH.js} +1 -1
  35. package/client/dist/assets/{TvPopup-CP41CncZ.js → TvPopup-PlCU30FO.js} +1 -1
  36. package/client/dist/assets/TvSearch-BYwCf5kO.js +1 -0
  37. package/client/dist/assets/{TvWatchlist-COCWPkgh.js → TvWatchlist-BiJU6pKT.js} +1 -1
  38. package/client/dist/assets/Watchlist-BOEeGXH9.js +1 -0
  39. package/client/dist/assets/{hls-B_yo8-yR.js → hls-C11FOWHj.js} +1 -1
  40. package/client/dist/assets/index-CtoKRNLc.js +178 -0
  41. package/client/dist/assets/{useAnimeInfoData-CbNnHRj8.js → useAnimeInfoData-kr3WOIWH.js} +1 -1
  42. package/client/dist/assets/{useAsmr-BEcgHwxg.js → useAsmr-CB9THf0m.js} +1 -1
  43. package/client/dist/assets/{useAsmrPopup-BXD3y2m1.js → useAsmrPopup-cT_Uu41e.js} +1 -1
  44. package/client/dist/assets/useMangaLibrary-rM6z3_0E.js +1 -0
  45. package/client/dist/assets/{useMangaPopup-BvgtZ53s.js → useMangaPopup-PnmSctHu.js} +1 -1
  46. package/client/dist/assets/{useProviders-xlftutIo.js → useProviders-B3VB7A9M.js} +1 -1
  47. package/client/dist/assets/{useTv-DTqrJEWp.js → useTv-BTUKMH7Q.js} +1 -1
  48. package/client/dist/assets/{useTvLibrary-BHeWSd1F.js → useTvLibrary-C0sX-ilZ.js} +1 -1
  49. package/client/dist/index.html +1 -1
  50. package/package.json +2 -2
  51. package/server/dist/controllers/data.controller.js +1 -0
  52. package/server/dist/controllers/insights.controller.js +8 -3
  53. package/server/dist/controllers/manga-library.controller.js +54 -0
  54. package/server/dist/controllers/proxy.controller.js +94 -23
  55. package/server/dist/controllers/watchlist.controller.js +55 -1
  56. package/server/dist/lib/anilist.js +36 -3
  57. package/server/dist/lib/discord-roles-sync.service.js +237 -2
  58. package/server/dist/lib/mal.js +69 -0
  59. package/server/dist/lib/tracker/anilist-tracker.js +66 -0
  60. package/server/dist/lib/tracker/manga-sync.service.js +792 -0
  61. package/server/dist/repositories/insights.repository.js +10 -0
  62. package/server/dist/repositories/manga.repository.js +17 -2
  63. package/server/dist/repositories/shows-meta.repository.js +4 -1
  64. package/server/dist/repositories/watchlist.repository.js +1 -0
  65. package/server/dist/routes/insights.routes.js +1 -0
  66. package/server/dist/routes/manga-library.routes.js +2 -0
  67. package/server/dist/routes/tracker.routes.js +123 -0
  68. package/server/dist/sync.js +8 -1
  69. package/server/package.json +1 -1
  70. package/client/dist/assets/Home-CQ4Ikeja.js +0 -1
  71. package/client/dist/assets/Insights-DKtoVe6L.css +0 -1
  72. package/client/dist/assets/Insights-DiAo0UAc.js +0 -1
  73. package/client/dist/assets/LibraryListPage-B0MDTnEc.js +0 -1
  74. package/client/dist/assets/MangaInfoPage-BEQsjTHH.js +0 -1
  75. package/client/dist/assets/MangaReadPage-C0WAtK-1.js +0 -1
  76. package/client/dist/assets/Mature-Ckx99wFj.js +0 -1
  77. package/client/dist/assets/Player-C3yWQkXb.js +0 -56
  78. package/client/dist/assets/PlayerSettings-CBdTzo0E.js +0 -1
  79. package/client/dist/assets/Search-DxX021dj.js +0 -1
  80. package/client/dist/assets/SkeletonGrid-DhPYefXr.css +0 -1
  81. package/client/dist/assets/SkeletonGrid-Du10CNfq.js +0 -1
  82. package/client/dist/assets/Trackers-BXSONaRD.js +0 -2
  83. package/client/dist/assets/TvSearch-BlqTQYJa.js +0 -1
  84. package/client/dist/assets/Watchlist-BHLshSPX.js +0 -1
  85. package/client/dist/assets/index-lo-bz7f2.js +0 -178
  86. package/client/dist/assets/useMangaLibrary-BXhgN-dl.js +0 -1
@@ -1,56 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-CBdTzo0E.js","assets/vendor-core-8R2fFbyN.js","assets/vendor-icons-CDMuNDeL.js","assets/OptionListMenu-CkK2BvEz.js","assets/AvSyncCalibrator-oK6LlG61.js","assets/index-lo-bz7f2.js","assets/vendor-query-BXRECSI6.js","assets/index-CUm1meqr.css","assets/AvSyncCalibrator-BPa6KaGC.css","assets/PlayerSettings-Bj6SsmQ2.css"])))=>i.map(i=>d[i]);
2
- import{g as Dt,h as x,u as r,P as Br,z as Ir,d as q,A as f,q as O,y as Lr,T as ct,n as $r,a as Dr,c as Fr,_ as Or,S as Et}from"./vendor-core-8R2fFbyN.js";import{_ as ur,S as Nt,q as $e,z as Qe,N as Wr,j as Vr,k as Ur,l as Qr,m as qr,d as zr,M as Ae,B as Ze,O as Gr,f as Hr}from"./index-lo-bz7f2.js";import{u as dr,b as ar,a as Gt}from"./vendor-query-BXRECSI6.js";import{C as Kr,S as jr,U as Yr,a as Jr,p as Ht,s as Xr,l as Zr,u as en,b as tn,i as rn,c as nn,d as ir,f as lr,e as sn,g as on,h as an,r as ln,j as Ue,E as cn,k as un,m as u,n as dn,A as pn,P as mn,o as hn,q as fn}from"./AvSyncCalibrator-oK6LlG61.js";import{I as W}from"./vendor-icons-CDMuNDeL.js";import{l as vn}from"./hls-B_yo8-yR.js";import{u as gn}from"./useMatureConsent-CT7-KfzG.js";import{u as bn}from"./useIsMobile-Dm_b6Ob3.js";import{s as et,Q as yn}from"./QueueRail-DAcIex5B.js";import{u as Sn,Q as En}from"./QueueOptionsButton-DKWi-9kd.js";import{u as pr}from"./useProviders-xlftutIo.js";import{A as wn}from"./AnimeMetaDetails-BPvv5xIl.js";import{S as kn}from"./SynopsisText-BcpwT5iw.js";import"./vendor-ui-CUDCvRS_.js";const Tn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Cn={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Mn=["direct","cookie","embed"],Rn="_controlsOverlay_1b7ea_1",_n="_hidden_1b7ea_21",Nn="_topControls_1b7ea_27",xn="_backBtn_1b7ea_47",Pn="_videoTitleInfo_1b7ea_67",An="_animeTitle_1b7ea_73",Bn="_episodeNumber_1b7ea_81",In="_bottomControls_1b7ea_89",Ln="_progressBarContainer_1b7ea_108",$n="_progressBar_1b7ea_108",Dn="_thumb_1b7ea_127",Fn="_scrubbing_1b7ea_142",On="_watchedBar_1b7ea_146",Wn="_bufferedBar_1b7ea_147",Vn="_timeBubble_1b7ea_185",Un="_skipSegment_1b7ea_219",Qn="_op_1b7ea_229",qn="_ed_1b7ea_232",zn="_recap_1b7ea_235",Gn="_bottomControlsRow_1b7ea_239",Hn="_leftControls_1b7ea_247",Kn="_rightControls_1b7ea_248",jn="_controlBtn_1b7ea_255",Yn="_theaterBtn_1b7ea_296",Jn="_nextEpisodeBtn_1b7ea_300",Xn="_active_1b7ea_317",Zn="_timeDisplay_1b7ea_321",es="_skipControls_1b7ea_329",ts="_skipBtn_1b7ea_335",rs="_volumeContainer_1b7ea_376",ns="_volumeSlider_1b7ea_382",ss="_playerPageLayout_1b7ea_440",os="_videoPlayerWrapper_1b7ea_444",as="_playerInfoContainer_1b7ea_449",is="_visible_1b7ea_566",ls="_shortcuts_1b7ea_584",E={controlsOverlay:Rn,hidden:_n,topControls:Nn,backBtn:xn,videoTitleInfo:Pn,animeTitle:An,episodeNumber:Bn,bottomControls:In,progressBarContainer:Ln,progressBar:$n,thumb:Dn,scrubbing:Fn,watchedBar:On,bufferedBar:Wn,timeBubble:Vn,skipSegment:Un,op:Qn,ed:qn,recap:zn,bottomControlsRow:Gn,leftControls:Hn,rightControls:Kn,controlBtn:jn,theaterBtn:Yn,nextEpisodeBtn:Jn,active:Xn,timeDisplay:Zn,skipControls:es,skipBtn:ts,volumeContainer:rs,volumeSlider:ns,playerPageLayout:ss,videoPlayerWrapper:os,playerInfoContainer:as,visible:is,shortcuts:ls},cs=Ir(()=>ur(()=>import("./PlayerSettings-CBdTzo0E.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),us=({player:n,isAutoplayEnabled:v,onAutoplayChange:w,showNextEpisodeButton:K,onNextEpisode:b,videoSources:C,selectedSource:S,selectedLink:P,onSourceChange:R,skipIntervals:ie,animeTitle:ye,episodeNumber:e,isTheaterMode:g,onTheaterModeToggle:V,anime4kEnabled:U,onAnime4kToggle:le,anime4kSupported:z,anime4kProfile:ve,onAnime4kProfileChange:A,anime4kInitializing:$,anime4kError:De,videoDelayEnabled:qe,onVideoDelayToggle:a,videoDelayMs:m,onVideoDelayChange:k,onCalibrateAvSync:Se,fallbackChoice:Fe,onFallbackChoiceChange:Be,children:Ie,overlays:ze,isInteractingExtra:ee=!1,className:Re,hideChrome:l=!1})=>{const{state:o,refs:d,actions:p}=n,{showSettings:B}=o,{setShowSettings:Q,setShowVolumeSlider:j}=p,te=Dt.useRef(null),Ee=Dt.useRef(null);x(()=>{const h=_=>{te.current&&!te.current.contains(_.target)&&Ee.current&&!Ee.current.contains(_.target)&&B&&Q(!1)};return B&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[B,Q]);const we=Dt.useRef(null),Ge=h=>{d.videoRef.current&&(d.videoRef.current.volume=h,d.videoRef.current.muted=h===0,localStorage.setItem("playerVolume",h.toString()))},He=h=>{!d.videoRef.current||isNaN(o.duration)||o.duration===0||(d.videoRef.current.currentTime=h*o.duration,p.sendProgressUpdate(!1,!0))},tt=()=>{d.videoRef.current&&(p.setIsScrubbing(!0),p.wasPlayingBeforeScrub.current=!d.videoRef.current.paused,d.videoRef.current.pause())},G=h=>{!d.videoRef.current||!o.duration||(d.videoRef.current.currentTime=h*o.duration)},Ke=()=>{p.setIsScrubbing(!1),p.wasPlayingBeforeScrub.current&&d.videoRef.current?.play()},ut=h=>{if(!d.videoRef.current)return;p.setActiveSubtitleTrack(h);try{if(h===null||h==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const I=o.availableSubtitles.find(Y=>Y.label===h||Y.lang===h);I?localStorage.setItem("playerLastSubtitle",Xr(I)):localStorage.setItem("playerLastSubtitle",h)}}catch{}let _=!1;Array.from(d.videoRef.current.textTracks).forEach(I=>{const nt=h!==null&&h!=="off"&&(I.language===h||I.label===h)&&!_;I.mode=nt?"showing":"hidden",nt&&(_=!0)})},re=o.activeSubtitleTrack!==null&&o.activeSubtitleTrack!=="off",pe=()=>{if(!d.videoRef.current)return;if(re){ut("off");return}if(o.availableSubtitles.length===0)return;let h=null;try{h=localStorage.getItem("playerLastSubtitle")}catch{}const _=Ht(o.availableSubtitles,{lastKey:h,enabled:!0});if(_<0)return;const I=o.availableSubtitles[_];ut(I.label||I.lang)},je=()=>o.isMuted||o.volume===0?r(W,{name:"volume-mute"}):o.volume<.5?r(W,{name:"volume-down"}):r(W,{name:"volume-up"}),rt=r("div",{className:`${E.controlsOverlay} ${!o.showControls&&!B&&!o.isScrubbing?E.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none"},children:r("div",{className:E.topControls,onClick:h=>h.stopPropagation(),children:[r("button",{className:E.backBtn,onClick:h=>{h.stopPropagation(),window.history.back()},title:"Back","aria-label":"Back",children:r(W,{name:"chevron-left"})}),r("div",{className:E.videoTitleInfo,children:[r("span",{className:E.animeTitle,children:ye}),e&&r("span",{className:E.episodeNumber,children:["Episode ",e]})]})]})}),ft=r(Kr,{isPlaying:o.isPlaying,onTogglePlay:p.togglePlay,onSkipBack:()=>p.seek(-10),onSkipForward:()=>p.seek(10)}),ne=r("div",{className:`${E.controlsOverlay} ${!o.showControls&&!B&&!o.isScrubbing?E.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:E.bottomControls,"data-speed-boost-ignore":"true",onClick:h=>h.stopPropagation(),children:[r(jr,{classes:{container:E.progressBarContainer,scrubbing:E.scrubbing,timeBubble:E.timeBubble,bar:E.progressBar,buffered:E.bufferedBar,watched:E.watchedBar,thumb:E.thumb},videoRef:d.videoRef,duration:o.duration,formatTime:p.formatTime,isScrubbing:o.isScrubbing,onSeek:He,onScrubStart:tt,onScrubMove:G,onScrubEnd:Ke,timeLabelRef:we,children:[o.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${E.skipSegment} ${E[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/o.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/o.duration*100}% `}}),ie.map(h=>{const _=h.start_time/o.duration*100,I=(h.end_time-h.start_time)/o.duration*100;return r("div",{className:`${E.skipSegment} ${E[h.skip_type]} `,style:{left:`${_}% `,width:`${I}% `},title:h.skip_type.toUpperCase()},h.skip_id)})]}),r("div",{className:E.bottomControlsRow,children:[r("div",{className:E.leftControls,children:[r("button",{className:E.controlBtn,onClick:p.togglePlay,"aria-label":o.isPlaying?"Pause":"Play",children:o.isPlaying?r(W,{name:"pause"}):r(W,{name:"play"})}),r(Yr,{muted:o.isMuted,volume:o.volume,volumeIcon:je(),buttonClassName:E.controlBtn,onToggleMute:p.toggleMute,onVolumeChange:Ge,onExpandedChange:h=>j(h)}),r("span",{className:E.timeDisplay,ref:we,children:[p.formatTime(0)," / ",p.formatTime(o.duration)]}),o.currentSkipInterval&&!o.isAutoSkipEnabled&&r("button",{className:E.controlBtn,onClick:()=>{d.videoRef.current&&o.currentSkipInterval&&(d.videoRef.current.currentTime=o.currentSkipInterval.end_time,p.setCurrentSkipInterval(null))},children:["Skip ",o.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:E.rightControls,children:[r("div",{className:E.skipControls,children:K&&r("button",{className:E.nextEpisodeBtn,onClick:b,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${E.controlBtn} ${re?E.active:""}`,onClick:pe,title:re?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(W,{name:"closed-captioning",size:22})}),r("button",{ref:Ee,className:`${E.controlBtn} ${B?E.active:""} `,onClick:()=>Q(!B),"aria-label":"Settings",children:r(W,{name:"cog"})}),r("button",{className:`${E.controlBtn} ${E.theaterBtn} ${g?E.active:""} `,onClick:h=>{h.stopPropagation(),V()},title:g?"Exit Theater Mode":"Theater Mode","aria-label":g?"Exit Theater Mode":"Theater Mode",children:r(W,{name:"tv"})}),r("button",{className:E.controlBtn,onClick:p.toggleFullscreen,"aria-label":o.isFullscreen?"Exit Fullscreen":"Fullscreen",children:o.isFullscreen?r(W,{name:"compress"}):r(W,{name:"expand"})})]})]})]})}),Ye=r(Br,{fallback:null,children:r(cs,{ref:te,isOpen:B,onClose:()=>Q(!1),videoSources:C,currentSource:S,currentLink:P,onSourceChange:R,subtitles:o.availableSubtitles,activeSubtitleTrack:o.activeSubtitleTrack,onSubtitleChange:ut,subtitleSettings:{fontSize:o.subtitleFontSize,position:o.subtitlePosition,bgOpacity:o.subtitleBgOpacity,bgColor:o.subtitleBgColor,textColor:o.subtitleTextColor,edge:o.subtitleEdge,bold:o.subtitleBold},onSubtitleSettingsChange:(h,_)=>{const I=(Y,nt)=>{try{localStorage.setItem(Y,String(nt))}catch{}};switch(h){case"fontSize":p.setSubtitleFontSize(_),I("subtitleFontSize",_);break;case"position":p.setSubtitlePosition(_),I("subtitlePosition",_);break;case"bgOpacity":p.setSubtitleBgOpacity(_),I("subtitleBgOpacity",_);break;case"bgColor":p.setSubtitleBgColor(_),I("subtitleBgColor",_);break;case"textColor":p.setSubtitleTextColor(_),I("subtitleTextColor",_);break;case"edge":p.setSubtitleEdge(_),I("subtitleEdge",_);break;case"bold":p.setSubtitleBold(_),I("subtitleBold",_);break}},useNativeControls:o.useNativeControls,onNativeControlsToggle:p.setUseNativeControls,anime4kEnabled:U,onAnime4kToggle:le,anime4kSupported:z,anime4kProfile:ve,onAnime4kProfileChange:A,anime4kInitializing:$,anime4kError:De,videoDelayEnabled:qe,onVideoDelayToggle:a,videoDelayMs:m,onVideoDelayChange:k,onCalibrateAvSync:Se,isAutoSkipEnabled:o.isAutoSkipEnabled,onAutoSkipChange:h=>{p.setIsAutoSkipEnabled(h);try{localStorage.setItem("autoSkipEnabled",h.toString())}catch{}},isAutoplayEnabled:v,onAutoplayChange:w,fallbackChoice:Fe,onFallbackChoiceChange:Be})});return r(Jr,{player:n,topBar:rt,centerControls:ft,bottomBar:ne,settingsPanel:Ye,overlays:ze,isInteracting:ee,className:Re,chromeDisabled:l,children:Ie})},ds=({count:n=3})=>r("section",{className:et.section,children:[r("div",{className:et.header,children:r("button",{className:et.headerToggle,disabled:!0,children:[r("span",{className:et.title,children:r(Nt,{width:"60px",height:"1.2rem",variant:"text"})}),r(W,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:et.list,children:Array.from({length:n}).map((v,w)=>r("div",{className:et.item,style:{pointerEvents:"none"},children:[r("div",{className:et.dragHandle,style:{opacity:.2},children:r(Nt,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:et.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(Nt,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:et.meta,children:[r(Nt,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(Nt,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},w))})]}),ps="_sourceSelectionContainer_c5tub_76",ms="_providerSelectContainer_c5tub_89",hs="_providerSelect_c5tub_89",fs="_sourceSelect_c5tub_76",vs="_sourceButtons_c5tub_145",gs="_sourceButton_c5tub_145",bs="_active_c5tub_170",ht={sourceSelectionContainer:ps,providerSelectContainer:ms,providerSelect:hs,sourceSelect:fs,sourceButtons:vs,sourceButton:gs,active:bs},ys=({selectedProvider:n,onProviderChange:v,isAdult:w,options:K})=>{const b=K&&K.length>0?K:[],C=w===void 0?b:b.filter(S=>S.mature===w);return r("div",{className:ht.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:ht.providerSelect,value:n,onChange:S=>v(S.target.value),children:Mn.map(S=>{const P=C.filter(R=>(R.tier??"direct")===S);return P.length===0?null:r("optgroup",{label:Cn[S],children:P.map(R=>r("option",{value:R.value,children:R.sub?`${R.label} (${Tn[R.sub]})`:R.label},R.value))},S)})})]})},Ss=({videoSources:n,selectedSource:v,selectedLink:w,onSourceChange:K,onLinkChange:b})=>{const C=Array.isArray(n)?n:[];if(C.length===0)return null;const S=v?.type==="iframe"&&(v.links?.length??0)>1;return r("div",{className:ht.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:ht.sourceButtons,children:C.map((P,R)=>r("button",{className:`${ht.sourceButton} ${v?.sourceName===P.sourceName?ht.active:""} `,onClick:()=>K(P),children:P.sourceName},`${P.sourceName}-${R}`))}),S&&r("select",{className:ht.sourceSelect,"aria-label":"Fallback embed quality",value:w?.link??v.links[0]?.link??"",onChange:P=>{const R=v.links.find(ie=>ie.link===P.target.value);R&&b(R)},children:v.links.map(P=>r("option",{value:P.link,children:P.resolutionStr},P.link))})]})},Es=Dt.memo(Ss,(n,v)=>n.selectedSource?.sourceName===v.selectedSource?.sourceName&&n.selectedLink?.link===v.selectedLink?.link&&n.videoSources===v.videoSources),ws={low:{sd:1.5,hd:1.3,fhd:1.25},balanced:{sd:2,hd:1.5,fhd:1.25},high:{sd:2.5,hd:2,fhd:1.5},denoise:{sd:1.5,hd:1.5,fhd:1.5}},ks={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Ts=5,Cs=15e3,Ms=`
3
- @group(0) @binding(0) var extTex: texture_external;
4
- @group(0) @binding(1) var extSamp: sampler;
5
- struct VSOut {
6
- @builtin(position) pos: vec4f,
7
- @location(0) uv: vec2f,
8
- };
9
- @vertex
10
- fn vs(@builtin(vertex_index) idx: u32) -> VSOut {
11
- var positions = array<vec2f, 6>(
12
- vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
13
- vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
14
- );
15
- var uvs = array<vec2f, 6>(
16
- vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
17
- vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
18
- );
19
- var out: VSOut;
20
- out.pos = vec4f(positions[idx], 0.0, 1.0);
21
- out.uv = uvs[idx];
22
- return out;
23
- }
24
- @fragment
25
- fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
26
- return textureSampleBaseClampToEdge(extTex, extSamp, uv);
27
- }
28
- `;function Rs({videoRef:n,canvasRef:v,profile:w="balanced",delayMs:K=0}){const[b,C]=q(!1),[S,P]=q(!1),[R,ie]=q(!1),[ye,e]=q(null),[g,V]=q(0),U=f(0),le=f(null),z=f(null),ve=f(null),A=f(null),$=f(null),De=f(null),qe=f(null),a=f(null),m=f(null),k=f(!1),Se=f(-1),Fe=f(0),Be=f(K);Be.current=K;const Ie=f([]),ze=f(!1),ee=f(!1),Re=f(!1),l=f(null),o=f(-1),d=f(-1),p=f(!1),B=f(0);x(()=>{async function j(){if(typeof navigator>"u"||!navigator.gpu){C(!1);return}try{const te=await navigator.gpu.requestAdapter();C(!!te)}catch{C(!1)}}j()},[]),x(()=>{if(!S||!b)return;let j=!1;const te=++U.current,Ee=G=>{if(G)try{G.close()}catch{}},we=()=>{for(const G of Ie.current)Ee(G.bitmap);Ie.current=[]},Ge=G=>Math.max(8,Math.min(40,Math.ceil(G/16.7)+4));function He(){m.current!==null&&(cancelAnimationFrame(m.current),m.current=null)}async function tt(){let G=n.current;const Ke=v.current;if(!G||!Ke||U.current!==te)return;const ut=performance.now()+Cs;for(;(!G||G.videoWidth===0)&&performance.now()<ut;){if(await new Promise(Y=>requestAnimationFrame(Y)),j||U.current!==te)return;G=n.current}if(!G||G.videoWidth===0){!j&&U.current===te&&(e("Timed out waiting for video metadata"),ie(!1),P(!1));return}const re=G.videoWidth,pe=G.videoHeight,je=Math.max(re,pe),rt=window.innerWidth,ft=window.innerHeight,ne=Math.max(rt,ft),Ye=je<ne?ne/je:1,h=ws[w],_=je<=480?h.sd:je<=720?h.hd:je<=1080?h.fhd:1,I=Math.min(_,Ye);Ke.width=Math.round(re*I),Ke.height=Math.round(pe*I),ie(!0),e(null),Fe.current=0,Se.current=-1,k.current=!1;try{let Y=function(){j||U.current!==te||(He(),m.current=requestAnimationFrame(()=>{dt()}))};const{ModeA:nt,ModeB:wt,ModeC:st,ModeAA:ot}=await ur(async()=>{const{ModeA:L,ModeB:ce,ModeC:Ne,ModeAA:D}=await import("./index-BOKlZEHq.js").then(ue=>ue.i);return{ModeA:L,ModeB:ce,ModeC:Ne,ModeAA:D}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const kt=await navigator.gpu.requestAdapter();if(!kt)throw new Error("No GPU adapter found");const M=await kt.requestDevice();if(!M)throw new Error("Failed to get GPU device");const Oe=Ke.getContext("webgpu");if(!Oe)throw new Error("Failed to get WebGPU context");const at=navigator.gpu.getPreferredCanvasFormat();Oe.configure({device:M,format:at,alphaMode:"premultiplied"});const me=M.createTexture({size:[re,pe],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),Je=ks[w],ke=Math.round(re*I),Le=Math.round(pe*I),vt=(()=>{switch(Je){case"ModeB":return new wt({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}});case"ModeC":return new st({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}});case"ModeAA":return new ot({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}});default:return new nt({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}})}})(),_e=vt.getOutputTexture(),gt=M.createSampler({magFilter:"linear",minFilter:"linear"}),bt=M.createShaderModule({code:`
29
- @group(0) @binding(0) var tex: texture_2d<f32>;
30
- @group(0) @binding(1) var samp: sampler;
31
- struct VertexOutput {
32
- @builtin(position) pos: vec4f,
33
- @location(0) uv: vec2f,
34
- }
35
- @vertex
36
- fn vs(@builtin(vertex_index) idx: u32) -> VertexOutput {
37
- var positions = array<vec2f, 6>(
38
- vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
39
- vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
40
- );
41
- var uvs = array<vec2f, 6>(
42
- vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
43
- vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
44
- );
45
- var out: VertexOutput;
46
- out.pos = vec4f(positions[idx], 0.0, 1.0);
47
- out.uv = uvs[idx];
48
- return out;
49
- }
50
- @fragment
51
- fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
52
- return textureSample(tex, samp, uv);
53
- }
54
- `}),Xe=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Tt=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[Xe]}),vertex:{module:bt,entryPoint:"vs"},fragment:{module:bt,entryPoint:"fs",targets:[{format:at}]},primitive:{topology:"triangle-list"}}),Ct=M.createBindGroup({layout:Xe,entries:[{binding:0,resource:_e.createView()},{binding:1,resource:gt}]});try{const L=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),ce=M.createShaderModule({code:Ms}),Ne=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[L]}),vertex:{module:ce,entryPoint:"vs"},fragment:{module:ce,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});l.current={pipeline:Ne,layout:L,inputView:me.createView()}}catch{l.current=null}if(U.current!==te){me.destroy(),M.destroy();return}le.current=M,z.current=Oe,ve.current=vt,A.current=me,$.current=_e,De.current=Tt,qe.current=gt,a.current=Xe,ee.current=!1,Re.current=!1;async function Ft(){const L=l.current;if(!L||ee.current)return!1;const ce=n.current;if(!ce)return!1;const Ne=!Re.current;Ne&&M.pushErrorScope("validation");try{const D=M.importExternalTexture({source:ce}),ue=M.createBindGroup({layout:L.layout,entries:[{binding:0,resource:D},{binding:1,resource:gt}]}),Te=M.createCommandEncoder(),T=Te.beginRenderPass({colorAttachments:[{view:L.inputView,loadOp:"load",storeOp:"store"}]});T.setPipeline(L.pipeline),T.setBindGroup(0,ue),T.draw(6),T.end(),M.queue.submit([Te.finish()])}catch{return ee.current=!0,l.current=null,!1}if(Ne){const D=await M.popErrorScope().catch(()=>null);if(D)return console.warn("[anime4k] blit probe failed:",D.message),ee.current=!0,l.current=null,!1;Re.current=!0}return!0}ie(!1);async function dt(){if(j||U.current!==te)return;const L=n.current;if(!L||L.videoWidth===0){Y();return}if(L!==G||L.videoWidth!==re||L.videoHeight!==pe){V(ue=>ue+1);return}if(L.paused||L.ended||document.hidden||L.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){Y();return}const ce=L.getVideoPlaybackQuality().totalVideoFrames;if(ce===d.current){Y();return}if(k.current){Y();return}const Ne=L.currentTime;(L.seeking||o.current>=0&&Math.abs(Ne-o.current)>.5)&&(we(),p.current=!1,B.current=0,d.current=-1),o.current=Ne;const D=Math.max(0,Be.current||0);D>B.current&&(p.current=!1),k.current=!0;try{const ue=performance.now();let Te=null,T=!1;if(D<=0){Ie.current.length>0&&we(),p.current=!1,B.current=0;let Ce=!1;if(!ze.current)try{M.queue.copyExternalImageToTexture({source:L},{texture:me},[re,pe]),d.current=ce,Ce=!0}catch(he){if(he instanceof TypeError)ze.current=!0;else throw he}if(!Ce&&!ee.current&&l.current&&await Ft()&&(d.current=ce,Ce=!0),!Ce){const he=await createImageBitmap(L);d.current=ce,M.queue.copyExternalImageToTexture({source:he},{texture:me},[re,pe]),Ee(he)}}else{const Ce=await createImageBitmap(L);d.current=ce;const he=Ie.current;he.push({bitmap:Ce,capture:ue});const Ot=Ge(D);for(;he.length>Ot;)Ee(he.shift()?.bitmap);let se=-1;for(let ge=he.length-1;ge>=0;ge--)if(ue-he[ge].capture>=D){se=ge;break}if(se!==-1){for(let Ve=0;Ve<se;Ve++)Ee(he.shift()?.bitmap);const ge=he.shift();ge?(Te=ge.bitmap,p.current=!0,B.current=D):(Te=Ce,T=!0)}else if(!p.current)Te=Ce,T=!0;else{const ge=he.shift();Te=ge?ge.bitmap:Ce,ge||(T=!0)}if(!Te){k.current=!1,Y();return}M.queue.copyExternalImageToTexture({source:Te},{texture:me},[re,pe]),T||Ee(Te)}const Mt=M.createCommandEncoder();await vt.pass(Mt);const We=Mt.beginRenderPass({colorAttachments:[{view:Oe.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});We.setPipeline(Tt),We.setBindGroup(0,Ct),We.draw(6),We.end(),M.queue.submit([Mt.finish()]),Se.current=ce,Fe.current=0,M.queue.onSubmittedWorkDone().then(()=>{U.current===te&&(k.current=!1)})}catch(ue){if(k.current=!1,Fe.current+=1,Fe.current>=Ts&&!j&&U.current===te){console.error(ue),e(ue instanceof Error?ue.message:"Render error"),P(!1);return}}Y()}Y()}catch(Y){!j&&U.current===te&&(e(Y instanceof Error?Y.message:"Failed to initialize upscaler"),ie(!1),P(!1))}}return tt(),()=>{j=!0,U.current+=1,He(),we(),A.current&&(A.current.destroy(),A.current=null),$.current&&($.current.destroy(),$.current=null),le.current&&(le.current.destroy(),le.current=null),ve.current=null,De.current=null,qe.current=null,a.current=null,l.current=null,z.current=null,k.current=!1}},[S,b,n,v,w,g]);const Q=O(()=>{P(j=>!j)},[]);return{isWebGPUSupported:b,isEnabled:S,isInitializing:R,error:ye,toggle:Q}}const _s=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Ns=()=>{const n=localStorage.getItem("preferredProvider");return n&&/^[a-z0-9-]+$/i.test(n)?n:"megaplay"},mr=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:_s(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,forceNativePlayer:localStorage.getItem("forceNativePlayer")==="true",isAutoplayEnabled:Zr(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Ns(),loadingShowData:!0,loadingVideo:!1,loadingDetails:!1,error:null,detailsError:null,showCookieModal:!1,cookieProvider:null});mr();function xs(n,v){switch(v.type){case"SET_STATE":return{...n,...v.payload};case"SET_MODE":return{...n,currentMode:v.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...n,selectedProvider:v.payload};case"SET_OVERRIDE_SOURCE":return{...n,selectedSource:v.payload?.source??null,selectedLink:v.payload?.link??null};default:return n}}async function cr(n,v,w,K,b=!1){if(!n||!v)throw new Error("Missing params");try{const[C,S,P,R]=await Promise.all([$e(`/api/video?showId=${n}&episodeNumber=${v}&mode=${w.currentMode}&provider=${w.selectedProvider}`).catch(()=>null),$e(`/api/episode-progress/${n}/${v}`).catch(()=>null),$e("/api/settings?key=preferredSource").catch(()=>null),$e(`/api/skip-times/${n}/${v}`).catch(()=>[])]),ie=P?.value,ye=C?.filter(A=>{const $=A.sourceName.toLowerCase();return w.currentMode==="dub"?$.includes("eng")||$.includes("dub"):$.includes("jpn")||$.includes("sub")||!$.includes("eng")&&!$.includes("dub")})??[],e=ye.length>0?ye:C??[];let g=e.length>0?e[0]:null;if(ie){const A=e.find($=>$.sourceName===ie);A&&(g=A)}const V=g&&g.links.length>0?g.links.sort((A,$)=>(parseInt($.resolutionStr)||0)-(parseInt(A.resolutionStr)||0))[0]:null,U=S?.currentTime||0,le=S?.duration||0,ve=(Array.isArray(R)?R:R?.results||[]).map(A=>({skip_id:A.skip_id||"",skip_type:A.skip_type||"",start_time:A.interval?.start_time??A.start_time??0,end_time:A.interval?.end_time??A.end_time??0})).filter(A=>A.end_time>0);return(!C||C.length===0)&&(b||Qe.error(`No video sources found for ${w.selectedProvider}`)),{videoSources:C,selectedSource:g,selectedLink:V,resumeTime:U,resumeDuration:le,showResumeModal:U>5&&g?.type!=="iframe",skipIntervals:ve,fetchedEpisodeNumber:v}}catch(C){const S=C;if(S.message==="AUTH_REQUIRED")return K({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:S.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:v};throw C}}const Ps=(n,v,w,K)=>{const[b,C]=Lr(xs,w,l=>({...mr(),showMeta:l?.name?{name:l.name,thumbnail:l.thumbnail,nativeName:l.nativeName,englishName:l.englishName,names:{romaji:l.name||l.englishName,english:l.englishName||l.name,native:l.nativeName}}:{}})),S=dr(),P=f(null),R=f(null),{options:ie}=pr(),ye=ct(()=>ie.filter(l=>(l.kind??"anime")==="anime"),[ie]),e=v||b.initialEpisode,g=f(e);x(()=>{g.current!==e&&(g.current=e,C({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[e,C]),x(()=>{n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)&&b.selectedProvider!=="animepahe"&&P.current!==n&&(P.current=n,C({type:"SET_PROVIDER",payload:"animepahe"}))},[n,b.selectedProvider]);const{data:V,isLoading:U,error:le}=Sn(n),{data:z}=ar({queryKey:["player-data",n,b.currentMode,b.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const l=async()=>{try{const Q=await $e(`/api/episodes?showId=${n}&mode=${b.currentMode}&provider=${b.selectedProvider}`);if(Q?.episodes?.length)return Q}catch{}return null},[o,d,p]=await Promise.all([l(),$e(`/api/watchlist/check/${n}`).catch(()=>({inWatchlist:!1})),$e(`/api/watched-episodes/${n}`).catch(()=>[])]),B=o?.episodes?o.episodes.sort((Q,j)=>parseFloat(Q)-parseFloat(j)):[];return{description:o?.description||"",episodes:B,inWatchlist:d.inWatchlist,watchlistStatus:d.status??null,watchedEpisodes:p}},enabled:!!n});x(()=>{!v&&z?.episodes&&z.episodes.length>0&&!v&&C({type:"SET_STATE",payload:{initialEpisode:z.episodes[0]}})},[z,v]),x(()=>{if(V?.isAdult===void 0)return;const o=new Set(ye.filter(d=>d.mature).map(d=>d.value)).has(b.selectedProvider);if(R.current!==n){if(V.isAdult&&!o){R.current=n;const d=ye.find(p=>p.mature);if(!d)return;C({type:"SET_PROVIDER",payload:d.value}),localStorage.setItem("preferredProvider",d.value)}if(!V.isAdult&&o){R.current=n;const d=ye.find(p=>!p.mature);if(!d)return;C({type:"SET_PROVIDER",payload:d.value}),localStorage.setItem("preferredProvider",d.value)}}},[V?.isAdult,b.selectedProvider,n,ye]),x(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||R.current===`temp:${n}`)return;const l=V?.provider;l&&(R.current=`temp:${n}`,l!==b.selectedProvider&&C({type:"SET_PROVIDER",payload:l}))},[n,V,b.selectedProvider]);const{data:ve,isLoading:A,error:$}=ar({queryKey:["video-sources",n,e,b.selectedProvider,b.currentMode],queryFn:()=>cr(n,e,b,C),enabled:!!n&&!!e&&!(b.showMeta?.isAdult===!0&&!K?.hasMatureConsent)}),De=!1,{mutateAsync:qe}=Gt({mutationFn:async({wasIn:l,showMeta:o})=>{const d=l?"/api/watchlist/remove":"/api/watchlist/add",p={id:n,name:o.name||o.names?.romaji,thumbnail:o.thumbnail,nativeName:o.names?.native,englishName:o.names?.english,type:o.type,isAdult:o.isAdult},B=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!B.ok){const Q=await B.json().catch(()=>null);throw new Error(Q?.error||"Failed to update watchlist")}return!l},onSuccess:l=>{Qe.success(l?"Added to watchlist":"Removed from watchlist"),S.invalidateQueries({queryKey:["player-data",n]}),S.invalidateQueries({queryKey:["show-data",n]}),S.invalidateQueries({queryKey:["watchlist"]})},onError:l=>Qe.error(l instanceof Error?l.message:"Failed to update watchlist")}),a=O(async()=>{!n||!V||await qe({wasIn:!!z?.inWatchlist,showMeta:V})},[n,V,z?.inWatchlist,qe]),m=O(async l=>{try{await $e("/api/settings",{method:"POST",body:JSON.stringify({key:"preferredSource",value:l})})}catch(o){console.error(o)}},[]),{mutateAsync:k,isPending:Se}=Gt({mutationFn:async({status:l})=>{if(!n)throw new Error("Missing showId");return await $e("/api/watchlist/status",{method:"POST",body:JSON.stringify({id:n,status:l})}),l},onSuccess:l=>{C({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:l}}),Qe.success(`Moved to ${l}`),S.invalidateQueries({queryKey:["show-data",n]}),S.invalidateQueries({queryKey:["watchlist"]}),S.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>Qe.error("Failed to update watchlist status")}),Fe=O(async()=>{await k({status:"Completed"})},[k]),{mutateAsync:Be}=Gt({mutationFn:async({episodeNumber:l,duration:o,showMeta:d,episodes:p})=>{await $e("/api/update-progress",{method:"POST",body:JSON.stringify({showId:n,episodeNumber:l,currentTime:o,duration:o,showName:d.name,showThumbnail:d.thumbnail,nativeName:d.names?.native,englishName:d.names?.english,genres:d.genres?.map(B=>B.name),popularityScore:Wr(d.score??d.stats?.averageScore),type:d.type,status:d.status,episodeCount:p.length,isAdult:d.isAdult}),keepalive:!0})},onSuccess:(l,o)=>{Qe.success(`Episode ${o.episodeNumber} marked as watched`),S.invalidateQueries({queryKey:["player-data",n]}),S.invalidateQueries({queryKey:["show-meta",n]}),S.invalidateQueries({queryKey:["video-sources",n,o.episodeNumber]}),S.invalidateQueries({queryKey:["allContinueWatching"]}),S.invalidateQueries({queryKey:["thisWeekSchedule"]})},onError:()=>Qe.error("Failed to mark episode as watched")}),Ie=O(async(l,o)=>{!n||!V||await Be({episodeNumber:l,duration:o,showMeta:V,episodes:z?.episodes||[]})},[n,V,z?.episodes,Be]),ze=O(async()=>{C({type:"SET_STATE",payload:{showCombinedDetails:!b.showCombinedDetails}})},[b.showCombinedDetails]),ee=ct(()=>{const l=le||$,o=l?l.message:null,d=o==="AUTH_REQUIRED"?null:o,p=ve&&ve.fetchedEpisodeNumber===e?ve:null,B=!!ve&&!p;return{...b,currentEpisode:e,showMeta:{...b.showMeta||{},...V||{}},episodes:z?.episodes||[],watchedEpisodes:z?.watchedEpisodes||[],inWatchlist:!!z?.inWatchlist,watchlistStatus:z?.watchlistStatus??b.watchlistStatus??null,videoSources:p?.videoSources||[],selectedSource:b.selectedSource||p?.selectedSource||null,selectedLink:b.selectedLink||p?.selectedLink||null,resumeTime:p?.resumeTime||0,resumeDuration:p?.resumeDuration||0,showResumeModal:b.showResumeModal&&(p?.showResumeModal??!1),skipIntervals:p?.skipIntervals||[],loadingShowData:U,loadingVideo:A||B,loadingDetails:De,error:d,fetchedEpisodeNumber:p?.fetchedEpisodeNumber}},[b,V,z,ve,U,A,De,le,$,e]),Re=O((l,o)=>{const d=o||n;if(!d||!l||d===n&&l===e)return;const B=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(d)&&b.selectedProvider!=="animepahe"?"animepahe":b.selectedProvider,Q=["video-sources",d,l,B,b.currentMode];S.getQueryState(Q)?.status!=="success"&&S.prefetchQuery({queryKey:Q,queryFn:()=>cr(d,l,{selectedProvider:B,currentMode:b.currentMode},C,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,e,S,b,C]);return{state:ee,dispatch:C,toggleWatchlist:a,moveToCompleted:Fe,setPreferredSource:m,handleToggleDetails:ze,markEpisodeWatched:Ie,prefetchEpisodeSources:Re,isMarkingWatched:Be.isPending,isUpdatingWatchlistStatus:Se}},Kt="fallbackChoice";function As(){try{const n=localStorage.getItem(Kt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function Bs(n){try{n===null?localStorage.removeItem(Kt):localStorage.setItem(Kt,n)}catch{}}const Xs=()=>{const{id:n,episodeNumber:v}=$r(),w=Dr(),K=dr(),b=Fr(),{hasConsent:C,grant:S}=gn(),{options:P}=pr(),R=ct(()=>P.filter(t=>(t.kind??"anime")==="anime"),[P]),ie=ct(()=>R.map(t=>t.value),[R]),ye=ct(()=>new Set(R.filter(t=>t.mature).map(t=>t.value)),[R]),{state:e,dispatch:g,toggleWatchlist:V,moveToCompleted:U,setPreferredSource:le,handleToggleDetails:z,markEpisodeWatched:ve,prefetchEpisodeSources:A,isMarkingWatched:$,isUpdatingWatchlistStatus:De}=Ps(n,v,b.state||null,{hasMatureConsent:C});x(()=>{if(n&&e.showMeta?.id&&e.showMeta.id!==n){const t=v?`/watch/${e.showMeta.id}/${v}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;w(t,{replace:!0})}},[n,e.showMeta?.id,v,w]);const qe=ct(()=>{if(e.showMeta.name)return{name:e.showMeta.name,thumbnail:e.showMeta.thumbnail,names:e.showMeta.names,genres:e.showMeta.genres,score:e.showMeta.score,isAdult:e.showMeta.isAdult}},[e.showMeta.name,e.showMeta.thumbnail,e.showMeta.names,e.showMeta.genres,e.showMeta.score,e.showMeta.isAdult]),a=en({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:qe}),{refs:m,actions:k}=a,Se=f(null),Fe=bn(),Be=f(null),Ie=f(null),ze=f(null),ee=f(0),Re=f(e.resumeTime),l=f(e.showResumeModal),[o,d]=q(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),[p,B]=q(()=>{try{const t=Number(localStorage.getItem("playerVideoDelayMs"));if(Number.isFinite(t)&&t>=0&&t<=500)return Math.round(t)}catch{}return 180}),[Q,j]=q(()=>{try{return localStorage.getItem("playerVideoDelayEnabled")==="true"}catch{return!1}}),[te,Ee]=q(!1),[we,Ge]=q(!1),He=f(null),tt=f(null),G=(t,s)=>{try{localStorage.setItem("playerVideoDelayMs",String(t)),localStorage.setItem("playerVideoDelayEnabled",String(s))}catch{}},Ke=t=>{const s=Math.max(0,Math.min(500,Math.round(t)));B(s);try{localStorage.setItem("playerVideoDelayMs",String(s))}catch{}},ut=()=>{He.current={enabled:Q,ms:p},j(!0);try{localStorage.setItem("playerVideoDelayEnabled","true")}catch{}k.setShowSettings(!1),Ee(!0)},re=()=>{const t=He.current;He.current=null,t&&(B(t.ms),j(t.enabled),G(t.ms,t.enabled)),Ge(!1),Ee(!1)},pe=()=>{He.current=null,j(!0),G(p,!0),Ge(!1),Ee(!1)},je=()=>{if(we){Ge(!1);return}const t=m.videoRef.current;t&&!isNaN(t.currentTime)&&(tt.current=t.currentTime),Ge(!0)},rt=Q?p:0,ft=f(null),ne=Rs({videoRef:m.videoRef,canvasRef:Ie,profile:o,delayMs:rt}),Ye=ne.isEnabled&&ne.isWebGPUSupported;tn({videoRef:m.videoRef,canvasRef:ft,delayMs:rt,enabled:Q&&!Ye});const h=Q&&!Ye,_=Ye||h;x(()=>{Re.current=e.resumeTime,l.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[I,Y]=q(null),[nt,wt]=q(!1),[st,ot]=q(!1),[kt,M]=q(!1),Oe=f(!1),[at,me]=q(null),Je=f(!1),ke=f([]),Le=f(!1),[vt,_e]=q(null),[gt,bt]=q(!1),[Xe,Tt]=q(!1),[Ct,Ft]=q(()=>As()??"ask"),dt=O(t=>{Ft(t),Bs(t==="ask"?null:t)},[]),L=f(Ct);L.current=Ct;const ce=f(e.videoSources);ce.current=e.videoSources;const Ne=f(()=>{}),[D,ue]=q(null),Te=f(v);x(()=>{Te.current!==v&&(Te.current=v,ue(null),me(null),Oe.current=!1,Ge(!1),Ee(!1))},[v]),x(()=>{Je.current=!1,ke.current=[],Le.current=!1,_e(null),bt(!1)},[n,e.currentEpisode]),x(()=>{st||(Oe.current=!1)},[st]);const{data:T=[],isLoading:Mt}=Vr(),We=Ur(),Ce=f(We);Ce.current=We;const he=Qr(),Ot=qr(),[se,ge]=q(()=>{try{return localStorage.getItem("playerTheaterMode")==="true"}catch{return!1}});x(()=>{try{se?document.body.classList.add("theater-mode"):document.body.classList.remove("theater-mode")}catch(t){console.error(t)}return()=>{try{document.body.classList.remove("theater-mode")}catch(t){console.error(t)}}},[se]),Or(()=>{if(a.state.isFullscreen||se)return;const t=m.playerContainerRef.current,s=Be.current;if(!t||!s)return;const i=()=>{const N=t.getBoundingClientRect().height;s.style.height=`${N}px`};i();const c=new ResizeObserver(i);return c.observe(t),()=>c.disconnect()},[a.state.isFullscreen,se,m.playerContainerRef]);const Ve=ct(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),Wt=Ve>0?e.episodes[Ve-1]:null,xe=Ve>=0&&Ve<e.episodes.length-1?e.episodes[Ve+1]:null,Vt=Ve>-1&&Ve<e.episodes.length-1,hr=e.episodes.length>0&&!!e.currentEpisode&&e.episodes[e.episodes.length-1]===e.currentEpisode,fr=String(e.showMeta.status||"").trim().toLowerCase(),vr=["finished","completed","complete","ended"].some(t=>fr.includes(t)),Ut=rn(e.resumeTime,e.resumeDuration)||st,it=hr&&vr&&Ut,jt=e.showResumeModal&&(it||!Ut),xt=Ut&&!it&&T.length===0&&!D&&(e.showResumeModal||st),pt=jt||xt;nn(a,!!e.selectedLink&&!se&&!pt),x(()=>{const t=m.videoRef.current;if(!t)return;let s=!1;for(Se.current&&(Se.current.destroy(),Se.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(we)return t.src="/av-sync-test.mp4",t.play().catch(()=>{k.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){ee.current=0;return}tt.current!=null?(ee.current=tt.current,tt.current=null):Re.current>5&&!l.current?ee.current=Re.current:l.current&&(ee.current=0);let i=e.selectedLink.link;if(i.startsWith("/api/proxy")||(i=`/api/proxy?url=${encodeURIComponent(i)}`,e.selectedLink.headers?.Referer&&(i+=`&referer=${encodeURIComponent(e.selectedLink.headers.Referer)}`)),e.selectedSource.subtitles){const fe=localStorage.getItem("playerSubtitlesEnabled")!=="false";let Me=null;try{Me=localStorage.getItem("playerLastSubtitle")}catch{}const J=Ht(e.selectedSource.subtitles,{lastKey:Me,enabled:fe}),Pe=J>=0?e.selectedSource.subtitles[J]:null;e.selectedSource.subtitles.forEach(be=>{const X=document.createElement("track");X.kind="subtitles",X.label=be.label,X.srclang=be.lang;const y=be.src??be.url;if(y){let Z=`/api/subtitle-proxy?url=${encodeURIComponent(y)}`;const ae=e.selectedLink?.headers?.Referer,yt=y.includes("anilight.live")?"https://anilight.live/":"",$t=ae||yt;$t&&(Z+=`&referer=${encodeURIComponent($t)}`),X.src=Z}Pe&&be.label===Pe.label&&be.lang===Pe.lang&&(X.default=!0),t.appendChild(X)}),fe||k.setActiveSubtitleTrack("off"),k.setAvailableSubtitles(e.selectedSource.subtitles)}const c=ee.current;ee.current=0;const N=()=>{c>0&&(t.currentTime=c)};t.addEventListener("loadedmetadata",N,{once:!0});const de=!(l.current&&Re.current>5),H=()=>{de&&t.play().catch(()=>{k.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const fe=await vn();if(s)return;if(!fe||!fe.isSupported()){t.src=i,H();return}const Me=document.body.classList.contains("low-end"),J=new fe({maxBufferLength:Me?15:30,maxMaxBufferLength:Me?30:60,maxBufferSize:Me?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});Se.current=J,J.on(fe.Events.ERROR,(X,y)=>{y.fatal&&!Je.current&&Ne.current()});const Pe=(e.selectedSource?.subtitles?.length??0)>0,be=()=>{try{Pe&&typeof J.subtitleTrack=="number"&&J.subtitleTrack!==-1&&(J.subtitleTrack=-1)}catch{}};J.on(fe.Events.SUBTITLE_TRACK_SWITCH,(X,y)=>{y?.id!==-1&&be()}),be(),J.loadSource(i),J.attachMedia(t),J.once(fe.Events.MANIFEST_PARSED,()=>{s||H()})})():(t.src=i,H());const F=localStorage.getItem("playerVolume"),oe=localStorage.getItem("playerMuted");return F!==null&&(t.volume=parseFloat(F)),oe!==null&&(t.muted=oe==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",N),Se.current&&(Se.current.destroy(),Se.current=null)}},[e.selectedSource,e.selectedLink,m.videoRef,k,e.loadingVideo,we]);const Pt=O(t=>{if(Je.current)return;Je.current=!0;const s=t.links[0];le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),_e(null)},[g,le]),At=O(()=>{const s=ce.current.find(i=>i.type==="iframe");return s?.links?.length?s:null},[]),Bt=O(async()=>{const t=e.showMeta?.isAdult,s=ie.filter(i=>{if(ke.current.includes(i))return!1;const c=ye.has(i);return t===void 0?!0:c===t});bt(!0);try{for(const i of s){ke.current.push(i);let c=null;try{c=await $e(`/api/video?showId=${n}&episodeNumber=${e.currentEpisode}&mode=${e.currentMode}&provider=${i}`)}catch{continue}const N=(c??[]).filter(F=>{const oe=F.sourceName.toLowerCase();return e.currentMode==="dub"?oe.includes("eng")||oe.includes("dub"):oe.includes("jpn")||oe.includes("sub")||!oe.includes("eng")&&!oe.includes("dub")});if((N.length>0?N:c??[]).find(F=>F.type!=="iframe"&&F.links?.length)){ke.current=[e.selectedProvider],Le.current=!1,g({type:"SET_STATE",payload:{selectedProvider:i,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",i),_e(null),Qe.success(`Switched to ${i} (direct stream)`);return}}_e({retryFailed:!0}),Qe.error("No working direct stream found on other providers")}finally{bt(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,g,ie,ye]),Yt=O(()=>{if(Je.current||Le.current||e.selectedSource?.type!=="player")return;const t=At();if(!t)return;ke.current.includes(e.selectedProvider)||ke.current.push(e.selectedProvider);const s=L.current;if(s==="iframe"){Pt(t);return}if(s==="retry"){Bt();return}k.setShowControls(!0),_e({retryFailed:!1})},[e.selectedSource,e.selectedProvider,At,Pt,Bt,k]);Ne.current=Yt;const gr=O(()=>{Le.current=!0,_e(null),Tt(!1)},[]),br=O(()=>{Xe&&dt("iframe");const t=At();t?Pt(t):_e(null)},[Xe,dt,At,Pt]),yr=O(()=>{Xe&&dt("retry"),Bt()},[Xe,dt,Bt]),Rt=(t,s,i)=>t.showId===s||!!i&&t.showId===i,It=O(()=>{k.onEnded();const t=T.find(i=>Rt(i,n,e.showMeta?.id)&&i.episodeNumber===e.currentEpisode);if(T.length>0){const i=T.findIndex(N=>Rt(N,n,e.showMeta?.id)&&N.episodeNumber===e.currentEpisode),c=i>=0?T[i+1]||null:T[0];ue({nextItem:c,playedItem:t||null}),me(2)}else t&&Ce.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&T.length===0){const i=e.episodes.findIndex(c=>c===e.currentEpisode);if(i>-1&&i<e.episodes.length-1){const c=e.episodes[i+1];K.invalidateQueries({queryKey:["allContinueWatching"]}),w(`/watch/${n}/${c}`),s=!0}}if(!s&&T.length===0&&!D&&!Oe.current){const i=e.episodes.length>0&&!!e.currentEpisode&&e.episodes[e.episodes.length-1]===e.currentEpisode,c=String(e.showMeta.status||"").trim().toLowerCase(),N=["finished","completed","complete","ended"].some(de=>c.includes(de));i&&N&&g({type:"SET_STATE",payload:{showResumeModal:!0}})}},[k,w,T,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,D,g,K]),Qt=O(()=>{if(T.length===0)return;k.onEnded();const t=T.find(c=>Rt(c,n,e.showMeta?.id)&&c.episodeNumber===e.currentEpisode),s=T.findIndex(c=>Rt(c,n,e.showMeta?.id)&&c.episodeNumber===e.currentEpisode),i=s>=0?T[s+1]||null:T[0];t&&We.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),i?w(`/watch/${i.showId}/${i.episodeNumber}`):t&&g({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,w,T,We,n,e.showMeta?.id,e.currentEpisode,g]),_t=O(()=>{xe&&(K.invalidateQueries({queryKey:["allContinueWatching"]}),ot(!1),w(`/watch/${n}/${xe}`)),g({type:"SET_STATE",payload:{showResumeModal:!1}})},[xe,w,n,g,K]),Jt=O(()=>{T.length>0?Qt():xe?_t():Qe.error("No next episode available")},[T.length,Qt,_t,xe]),Sr=()=>{Wt&&w(`/watch/${n}/${Wt}`)};x(()=>{const t=m.videoRef.current;if(!t)return;const s=()=>{we||It()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[It,m.videoRef,we]),x(()=>{const t=s=>{s.origin===window.location.origin&&e.selectedSource?.type==="iframe"&&s.data?.type==="ANI_WEB_MEDIA_ENDED"&&It()};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[It,e.selectedSource?.type]),x(()=>{if(!D||at===null)return;if(at<=0){const{nextItem:s,playedItem:i}=D;ue(null),me(null),i&&Ce.current.mutate({showId:i.showId,episodeNumber:i.episodeNumber}),s?w(`/watch/${s.showId}/${s.episodeNumber}`):i&&g({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{me(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[D,at,w,g]),x(()=>{pt&&a.state.isFullscreen&&a.actions.toggleFullscreen()},[pt,a.state.isFullscreen,a.actions]),x(()=>{pt&&m.videoRef.current&&m.videoRef.current.pause()},[pt,m.videoRef]);const{titlePreference:Lt}=zr(),mt=ct(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:t,names:s}=e.showMeta;return Lt==="name"?t||"Loading...":Lt==="nativeName"?s?.native||t||"Loading...":Lt==="englishName"?s?.english||t||"Loading...":t||"Loading..."},[e.showMeta,Lt,e.loadingShowData]);x(()=>{mt&&mt!=="Loading..."&&e.currentEpisode&&(document.title=`► ${mt} Episode ${e.currentEpisode} - dango`)},[mt,e.currentEpisode]),x(()=>{const t=s=>{if(!s.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')&&(["arrowup","arrowdown","arrowleft","arrowright"].includes(s.key.toLowerCase())&&(k.setShowControls(!0),a.actions.inactivityTimer.current&&clearTimeout(a.actions.inactivityTimer.current),a.actions.inactivityTimer.current=window.setTimeout(()=>{k.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&Jt(),s.key.toLowerCase()==="t")){const c=!se;ge(c),localStorage.setItem("playerTheaterMode",c.toString())}};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[k,a.actions.inactivityTimer,Jt,se]);const{setAvailableSubtitles:Xt,setActiveSubtitleTrack:qt}=k;x(()=>{const t=m.videoRef.current;if(!t)return;const s=()=>{const i=Array.from(t.textTracks).map(c=>({label:c.label,lang:c.language,src:void 0,mode:c.mode}));Xt(i)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[m.videoRef,Xt]),x(()=>{if(a.state.activeSubtitleTrack===null&&a.state.availableSubtitles.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let t=null;try{t=localStorage.getItem("playerLastSubtitle")}catch{}const s=Ht(a.state.availableSubtitles,{lastKey:t,enabled:!0});if(s<0){qt("off");return}const i=a.state.availableSubtitles[s];qt(i.lang||i.label)}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,qt]),x(()=>{const t=m.videoRef.current;if(!t||a.state.availableSubtitles.length===0)return;const s=a.state.activeSubtitleTrack;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(t.textTracks).forEach(N=>{N.mode="hidden"});return}let c=!1;if(Array.from(t.textTracks).forEach(N=>{const H=(N.language===s||N.label===s)&&!c;N.mode=H?"showing":"hidden",H&&(c=!0)}),!c&&t.textTracks.length>0){const N=Array.from(t.textTracks).find(de=>de.language==="en"||de.label==="English")||t.textTracks[0];N&&(N.mode="showing")}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,m.videoRef]);const[Zt,Er]=q(0);x(()=>{const t=m.videoRef.current;if(!t)return;const s=()=>Er(t.clientHeight||0);s();const i=new ResizeObserver(s);return i.observe(t),()=>i.disconnect()},[m.videoRef,e.selectedSource,e.selectedLink]),x(()=>{const t="dynamic-subtitle-styles";let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,document.head.appendChild(s));const i={fontSize:a.state.subtitleFontSize,position:a.state.subtitlePosition,bgOpacity:a.state.subtitleBgOpacity,bgColor:a.state.subtitleBgColor,textColor:a.state.subtitleTextColor,edge:a.state.subtitleEdge,bold:a.state.subtitleBold};s.textContent=ir(i);const c=m.videoRef.current;if(!c)return;const N=lr(a.state.subtitleFontSize,Zt||c.clientHeight||720);s.textContent=ir({...i,fontSize:N});const de=()=>{const y=Number(a.state.subtitlePosition),Z=isNaN(y)?0:Math.max(0,Math.min(100,y));return Math.max(0,Math.min(100,100-Z))},H=(y,Z)=>{try{const ae=y;ae.snapToLines=!1,ae.line=Z}catch{}},F=()=>{const y=N*16,Z=c.videoHeight||c.clientHeight||720,ae=c.videoWidth||c.clientWidth||1280;return{step:y*1.3/Z*100,chars:Math.max(20,Math.floor(ae/(y*.55)))}},oe=y=>{const Z=de(),ae=Array.from(y.activeCues??[]);if(ae.length<=1){ae.forEach(St=>H(St,Z));return}const{step:yt,chars:$t}=F();let sr=Z;for(let St=ae.length-1;St>=0;St--){const xr=String(ae[St].text??"").replace(/<[^>]*>/g,"").split(`
55
- `).reduce((Pr,Ar)=>Pr+Math.max(1,Math.ceil(Ar.length/$t)),0),or=sr-xr*yt;H(ae[St],Math.max(0,or)),sr=or-yt*.4}},fe=y=>{if(!y.cues)return;const Z=de();Array.from(y.cues).forEach(ae=>H(ae,Z)),y.mode==="showing"&&oe(y)},Me=()=>{Array.from(c.textTracks).forEach(fe)};Me();const J=y=>{const Z=y.target;Z.mode==="showing"&&oe(Z)};Array.from(c.textTracks).forEach(y=>{y.addEventListener("cuechange",J)});const Pe=()=>{Array.from(c.textTracks).forEach(y=>{y.removeEventListener("cuechange",J),y.addEventListener("cuechange",J)}),Me()};c.textTracks.addEventListener("addtrack",Pe),c.textTracks.addEventListener("removetrack",Pe);const be=Array.from(c.querySelectorAll("track")),X=()=>{Me()};return be.forEach(y=>{y.addEventListener("load",X)}),()=>{Array.from(c.textTracks).forEach(y=>{y.removeEventListener("cuechange",J)}),c.textTracks.removeEventListener("addtrack",Pe),c.textTracks.removeEventListener("removetrack",Pe),be.forEach(y=>{y.removeEventListener("load",X)})}},[a.state.subtitleFontSize,a.state.subtitlePosition,a.state.subtitleBgOpacity,a.state.subtitleBgColor,a.state.subtitleTextColor,a.state.subtitleEdge,a.state.subtitleBold,a.state.activeSubtitleTrack,a.state.availableSubtitles,e.selectedSource,e.selectedLink,m.videoRef,Zt]),x(()=>{if(!_)return;const t=m.videoRef.current,s=ze.current;if(!t||!s)return;const i=localStorage.getItem("playerSubtitlesEnabled")!=="false",c=a.state.activeSubtitleTrack;function N(){if(s.innerHTML="",!i||c==="off"||c===null)return;const F=Array.from(t.textTracks).find(X=>X.language===c||X.label===c);if(!F||F.mode!=="showing")return;const oe=rt/1e3;let fe;if(oe>0&&F.cues){const X=t.currentTime-oe;fe=Array.from(F.cues).filter(y=>y.startTime<=X&&X<=y.endTime)}else fe=Array.from(F.activeCues??[]);if(fe.length===0)return;const Me={fontSize:lr(a.state.subtitleFontSize,t.clientHeight||0),position:a.state.subtitlePosition,bgOpacity:a.state.subtitleBgOpacity,bgColor:a.state.subtitleBgColor,textColor:a.state.subtitleTextColor,edge:a.state.subtitleEdge,bold:a.state.subtitleBold},J=sn(Me),Pe=on(t,Me.position),be=Array.from(fe);be.forEach((X,y)=>{const Z=String(X.text??"");if(!an(Z).trim())return;const ae=document.createElement("div"),yt=(be.length-1-y)*1.7;ae.style.cssText=`${J}
56
- bottom: calc(${Pe}px + ${yt}em);`,ae.innerHTML=ln(Z),s.appendChild(ae)})}const de=()=>N(),H=()=>N();return Array.from(t.textTracks).forEach(F=>{F.addEventListener("cuechange",de)}),t.addEventListener("timeupdate",H),N(),()=>{Array.from(t.textTracks).forEach(F=>{F.removeEventListener("cuechange",de)}),t.removeEventListener("timeupdate",H),s.innerHTML=""}},[ne.isEnabled,ne.isWebGPUSupported,a.state.subtitleFontSize,a.state.subtitlePosition,a.state.subtitleBgOpacity,a.state.subtitleBgColor,a.state.subtitleTextColor,a.state.subtitleEdge,a.state.subtitleBold,a.state.activeSubtitleTrack,m.videoRef,_,rt]),x(()=>{try{localStorage.setItem("anime4kProfile",o)}catch{}},[o]);const wr=()=>{m.videoRef.current&&(m.videoRef.current.currentTime=e.resumeTime,m.videoRef.current.play()),g({type:"SET_STATE",payload:{showResumeModal:!1}})},kr=()=>{m.videoRef.current&&(m.videoRef.current.currentTime=0,m.videoRef.current.play()),g({type:"SET_STATE",payload:{showResumeModal:!1}})},er=O(()=>{it&&(Oe.current=!0),xt&&ot(!1),g({type:"SET_STATE",payload:{showResumeModal:!1}})},[g,it,xt]),Tr=O(()=>{if(ot(!1),m.videoRef.current)try{m.videoRef.current.currentTime=0,m.videoRef.current.play().catch(()=>{})}catch{}g({type:"SET_STATE",payload:{showResumeModal:!1}})},[g,m]),Cr=O(async()=>{try{await U(),g({type:"SET_STATE",payload:{showResumeModal:!1}}),w("/")}catch{}},[U,g,w]),tr=(t,s)=>r("div",{className:t,children:[r("button",{className:`${u.episodeNavBtn} ${u.secondary}`,onClick:Sr,disabled:!Wt,type:"button",children:[r(W,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${u.episodeNavBtn} ${u.primary}`,onClick:_t,disabled:!xe,type:"button",children:["Next EP",r(W,{name:"chevron-right",size:12})]}),s==="mobile"&&Fe&&r("button",{className:`${u.episodeNavBtn} ${u.episodePickerBtn}`,onClick:()=>M(!0),type:"button",children:[r(W,{name:"list-ul",size:12}),"Episodes"]})]});x(()=>{st&&(e.showResumeModal||T.length>0||D||Oe.current||it&&g({type:"SET_STATE",payload:{showResumeModal:!0}}))},[st,it,e.showResumeModal,T.length,D,g]);const Mr=t=>{g({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),fn(t)},rr=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),Rr=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",zt=f(A);zt.current=A;const nr=f("");x(()=>{const t=m.videoRef.current;if(wt(!1),ot(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const i=t.duration,c=t.currentTime;if(!i||Number.isNaN(i)){wt(!1),ot(!1);return}const N=c/i;if(i-c<=60){const de=T.findIndex(oe=>Rt(oe,n,e.showMeta?.id)&&oe.episodeNumber===e.currentEpisode),H=T.length>0?de>=0?T[de+1]||null:T[0]:null,F=H?`${H.showId}:${H.episodeNumber}`:Vt?`${n}:${xe}`:"";F&&nr.current!==F&&(nr.current=F,H?zt.current(H.episodeNumber,H.showId):zt.current(xe))}wt(Vt&&N>=.8),ot(c>=Math.max(i*.98,i-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[m.videoRef,Vt,e.currentEpisode,e.selectedSource,xe,n,T,e.showMeta?.id]);const _r=O(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||$)return;const t=m.videoRef.current?.duration,s=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await ve(e.currentEpisode,s)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,ve,$,m.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return r("p",{className:"error-message",children:["Error: ",e.error]});const lt=e.loadingShowData||e.loadingVideo,Nr=t=>{se&&t.target===t.currentTarget&&(ge(!1),localStorage.setItem("playerTheaterMode","false"))};return e.showMeta?.isAdult===!0&&!C?r("div",{className:Ue.playerPageLayout,children:r(Ae,{isOpen:!0,title:"Content Warning",onClose:()=>w("/home"),children:r("div",{style:{padding:"1rem",textAlign:"center"},children:[r("p",{children:"This title contains mature content intended for adult audiences."}),r("p",{children:["By proceeding, you confirm that you are ",r("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),r("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[r(Ze,{variant:"secondary",onClick:()=>w("/home"),children:"Go Back"}),r(Ze,{onClick:S,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${Ue.playerPageLayout} ${se?Ue.theaterMode:""}`,onClick:Nr,children:[r(Ae,{isOpen:jt,onClose:er,title:it?"Show Completed!":"Resume Playback?",width:"sm",children:it?r(Et,{children:[r(Ae.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r(Ae.Actions,{children:r(Ze,{onClick:Cr,disabled:De,children:De?"Saving...":"Move to Completed"})})]}):r(Et,{children:[r(Ae.Body,{children:r("p",{children:["You were watching at ",r("strong",{children:a.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]})}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:kr,children:"Start Over"}),r(Ze,{onClick:wr,children:"Resume"})]})]})}),r(Ae,{isOpen:xt,onClose:er,title:"Episode Completed",width:"sm",children:[r(Ae.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",xe?" Would you like to watch the next episode?":""]})}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:Tr,children:"Replay"}),xe&&r(Ze,{onClick:_t,children:`Watch EP ${xe}`})]})]}),r(Ae,{isOpen:!!vt,onClose:gr,title:"Direct stream failed",width:"sm",children:[r(Ae.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),vt?.retryFailed&&r("p",{children:"No working direct stream was found on the other providers either."}),r("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",r("strong",{children:"ads and pop-ups"}),"."]}),r("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[r("input",{type:"checkbox",checked:Xe,onChange:t=>Tt(t.target.checked)}),"Remember my choice"]})]}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:br,children:"Continue with iframe"}),r(Ze,{onClick:yr,disabled:gt,children:gt?"Searching…":"Try another provider"})]})]}),r(Gr,{isOpen:!!e.showCookieModal,onClose:()=>g({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{K.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!se&&r("aside",{ref:Be,className:Ue.episodeSidebar,children:e.loadingShowData?r(cn,{variant:"sidebar"}):r(un,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>w(`/watch/${n}/${t}`)})}),r("div",{className:Ue.playerMain,children:[r("div",{className:`${u.videoContainer} ${a.state.isFullscreen?"":Ue.videoPlayerWrapper} ${a.state.isFullscreen?u.fullscreenActive:""}`,style:{...pt?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(us,{player:a,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Mr,fallbackChoice:Ct,onFallbackChoiceChange:dt,showNextEpisodeButton:!pt&&nt&&T.length===0,onNextEpisode:_t,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{m.videoRef.current&&!isNaN(m.videoRef.current.currentTime)&&(ee.current=m.videoRef.current.currentTime),le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:e.loadingVideo,skipIntervals:e.skipIntervals,animeTitle:mt,episodeNumber:e.currentEpisode,isTheaterMode:se,onTheaterModeToggle:()=>{const t=!se;ge(t),localStorage.setItem("playerTheaterMode",t.toString())},anime4kEnabled:ne.isEnabled,onAnime4kToggle:ne.toggle,anime4kSupported:ne.isWebGPUSupported,anime4kProfile:o,onAnime4kProfileChange:d,anime4kInitializing:ne.isInitializing,anime4kError:ne.error,videoDelayEnabled:Q,onVideoDelayToggle:t=>{j(t);try{localStorage.setItem("playerVideoDelayEnabled",String(t))}catch{}},videoDelayMs:p,onVideoDelayChange:Ke,onCalibrateAvSync:ut,isInteractingExtra:kt||te,className:dn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(Et,{children:[a.state.isSpeedBoostActive&&r("div",{className:u.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(W,{name:"forward",size:12})]}),at!==null&&D?.nextItem&&r("div",{className:u.queueCountdown,children:["Queue next in ",at,"s"]})]}),children:[I&&r("div",{className:`${u.skipIndicatorContainer} ${I.side==="left"?u.leftSkip:u.rightSkip} `,children:r("div",{className:u.skipBubble,children:[r("div",{className:u.skipIcon,children:I.side==="left"?r(W,{name:"backward"}):r(W,{name:"forward"})}),r("div",{className:u.skipText,children:"15s"})]})}),lt&&r("div",{className:u.loadingOverlay,children:r("div",{className:u.loadingDots,children:[r("div",{className:u.dot}),r("div",{className:u.dot}),r("div",{className:u.dot})]})}),a.state.isBuffering&&!lt&&e.selectedSource?.type!=="iframe"&&r("div",{className:u.bufferingOverlay,children:r("div",{className:u.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!lt&&r("iframe",{src:e.selectedLink?.link,className:u.videoIframe,allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,sandbox:e.selectedSource.sandbox?`${e.selectedSource.sandbox} allow-fullscreen allow-popups allow-popups-to-escape-sandbox`:void 0}):r(Et,{children:[!lt&&e.videoSources.length===0&&r("div",{className:u.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:u.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:u.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!lt&&e.videoSources.length>0&&r("video",{ref:m.videoRef,controls:a.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:k.onPlay,onPause:k.onPause,onLoadedMetadata:k.onLoadedMetadata,onTimeUpdate:()=>{we||(k.onTimeUpdate(),D&&m.videoRef.current&&m.videoRef.current.currentTime<m.videoRef.current.duration-1&&(ue(null),me(null)))},onProgress:k.onProgress,onVolumeChange:k.onVolumeChange,onWaiting:k.onWaiting,onPlaying:k.onPlaying,onError:Yt,onContextMenu:t=>t.preventDefault(),className:_?u.videoElementHidden:""}),ne.isWebGPUSupported&&!lt&&e.videoSources.length>0&&r("canvas",{ref:Ie,className:`${u.upscalerCanvas} ${Ye?u.upscalerActive:""}`}),!Ye&&!lt&&e.videoSources.length>0&&r("canvas",{ref:ft,className:`${u.upscalerCanvas} ${h?u.upscalerActive:""}`}),ne.isEnabled&&ne.isWebGPUSupported&&ne.isInitializing&&r("div",{className:u.upscalerStatusBadge,children:"Preparing upscaler…"}),_&&r("div",{ref:ze,className:u.subtitleOverlay}),r(pn,{isOpen:te,ms:p,onChange:Ke,onApply:pe,onClose:re,testClipActive:we,onTestClip:je})]})]})}),!se&&r(mn,{}),!se&&r(Et,{children:[Mt&&T.length===0?r(ds,{count:3}):r(yn,{title:"Queue",items:T,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:Qt,onRemove:t=>We.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>he.mutate(),showClearAll:!0,onReorder:t=>Ot.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:u.providerAndEpisodeRow,children:[r(ys,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:R,onProviderChange:t=>{Je.current=!1,ke.current=[],Le.current=!1,_e(null),g({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",t)}}),tr(`${u.episodeActions} ${u.desktopEpisodeActions}`,"desktop")]}),lt?r("div",{className:u.sourceLoader,children:r("div",{className:u.spinner})}):r(Et,{children:r(Es,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{m.videoRef.current&&!isNaN(m.videoRef.current.currentTime)&&(ee.current=m.videoRef.current.currentTime);const i=(t.links||[]).sort((c,N)=>(parseInt(N.resolutionStr)||0)-(parseInt(c.resolutionStr)||0))[0]||null;le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:i,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(le(e.selectedSource.sourceName),g({type:"SET_STATE",payload:{selectedLink:t}}))}})}),r("div",{className:Ue.playerInfoContainer,children:[r("div",{className:Ue.playerInfoHeader,children:[r("div",{className:Ue.playerAnimeCard,children:r("img",{src:Hr(e.showMeta.thumbnail||""),alt:mt,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:Ue.videoTitleSection,children:[r("div",{className:u.titleContainer,children:[r("h1",{children:mt}),r("div",{className:u.scheduleInfo,children:[e.showMeta.status&&r("span",{className:u.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:u.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:u.controls,children:[r("button",{className:`${u.watchlistBtn} ${e.inWatchlist?u.inList:""}`,onClick:V,children:[e.inWatchlist?r(W,{name:"check",size:14}):r(W,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(En,{showId:n,showName:e.showMeta.name||e.showMeta.names?.romaji,showThumbnail:e.showMeta.thumbnail,nativeName:e.showMeta.names?.native,englishName:e.showMeta.names?.english,showType:e.showMeta.type,className:`${u.watchlistBtn} ${u.queueBtn}`,activeClassName:u.queueActive}),Rr&&r("button",{className:`${u.watchlistBtn} ${u.markWatchedBtn} ${rr?u.markWatchedDone:""}`,onClick:_r,disabled:$||!e.currentEpisode,children:[r(W,{name:"check",size:14}),$?"Saving...":rr?"Watched":"Mark Watched"]}),r("button",{className:`${u.watchlistBtn} ${u.modeToggleBtn} ${e.currentMode==="dub"?u.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";Je.current=!1,ke.current=[],Le.current=!1,_e(null),g({type:"SET_MODE",payload:t}),localStorage.setItem("preferredMode",t)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),r("button",{className:`${u.watchlistBtn} ${u.modeToggleBtn} ${a.state.useNativeControls?u.modeToggleActive:""}`,onClick:()=>{const t=!a.state.useNativeControls;a.actions.setUseNativeControls(t),localStorage.setItem("playerUseNativeControls",t.toString())},type:"button",children:a.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),tr(`${u.episodeActions} ${u.mobileEpisodeActions}`,"mobile"),r("div",{className:u.descriptionSection,children:[r("h3",{children:"Synopsis"}),r(kn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."})]}),r("button",{className:u.detailsToggleBtn,onClick:z,children:[e.showCombinedDetails?r(W,{name:"chevron-up"}):r(W,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]}),e.showCombinedDetails&&r(wn,{showMeta:e.showMeta,styles:u})]})]})]}),r(hn,{isOpen:kt,onClose:()=>M(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{M(!1),w(`/watch/${n}/${t}`)}})]})};export{Xs as default};
@@ -1 +0,0 @@
1
- import{g as I,d as J,T as X,u as e}from"./vendor-core-8R2fFbyN.js";import{I as o}from"./vendor-icons-CDMuNDeL.js";import{S as Y,O as _,a as Z,A as ee}from"./OptionListMenu-CkK2BvEz.js";import"./AvSyncCalibrator-oK6LlG61.js";import"./index-lo-bz7f2.js";import"./vendor-query-BXRECSI6.js";const ne="_settingsPanel_y6z3b_1",te="_header_y6z3b_33",ae="_backBtn_y6z3b_56",se="_contentWrapper_y6z3b_76",le="_menuContent_y6z3b_82",ie="_menuItem_y6z3b_89",re="_selected_y6z3b_114",ce="_currentValue_y6z3b_134",oe="_menuNote_y6z3b_141",de="_menuError_y6z3b_150",n={settingsPanel:ne,header:te,backBtn:ae,contentWrapper:se,menuContent:le,menuItem:ie,selected:re,currentValue:ce,menuNote:oe,menuError:de},me=(A,z)=>{const{isOpen:b,onClose:ue,videoSources:he,currentSource:v,currentLink:k,onSourceChange:w,subtitles:$,activeSubtitleTrack:y,onSubtitleChange:P,subtitleSettings:V,onSubtitleSettingsChange:O,useNativeControls:g,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:C,anime4kProfile:i,onAnime4kProfileChange:h,anime4kInitializing:E,anime4kError:f,videoDelayEnabled:N,onVideoDelayToggle:T,videoDelayMs:S,onVideoDelayChange:D,onCalibrateAvSync:x,isAutoSkipEnabled:d,onAutoSkipChange:L,isAutoplayEnabled:m,onAutoplayChange:M,fallbackChoice:p,onFallbackChoiceChange:W}=A,[a,r]=J("main");I.useEffect(()=>{if(!b){const t=setTimeout(()=>r("main"),300);return()=>clearTimeout(t)}},[b]);const G=()=>e("div",{className:n.menuContent,children:[e("button",{className:n.menuItem,onClick:()=>r("quality"),children:[e("span",{children:"Quality"}),e("span",{className:n.currentValue,children:k?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>r("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:y||"Off"})]}),e("button",{className:n.menuItem,onClick:()=>r("subtitle-style"),children:e("span",{children:"Subtitle Style"})}),e("button",{className:`${n.menuItem} ${g?n.selected:""}`,onClick:()=>{const t=!g;U(t),localStorage.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),g&&e(o,{name:"check",size:12})]}),C&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),C&&u&&e("button",{className:n.menuItem,onClick:()=>r("upscaler"),children:e("span",{children:"Upscaler Settings"})}),e("button",{className:n.menuItem,onClick:()=>r("av-sync"),children:[e("span",{children:"A/V Sync"}),e("span",{className:n.currentValue,children:N?`${S}ms`:"Off"})]}),e("button",{className:n.menuItem,onClick:()=>r("playback"),children:[e("span",{children:"Playback"}),e("span",{className:n.currentValue,children:[d?"Auto-skip On":null,m?"Autoplay On":null].filter(Boolean).join(" • ")||"Off"})]})]}),j=()=>{const t=v?.links.sort((s,c)=>(parseInt(c.resolutionStr)||0)-(parseInt(s.resolutionStr)||0))||[];return e("div",{className:n.menuContent,children:e(_,{classes:{item:n.menuItem,active:n.selected},options:t.map(s=>({key:s.resolutionStr,label:s.resolutionStr,selected:k?.resolutionStr===s.resolutionStr})),onSelect:s=>{const c=t.find(l=>l.resolutionStr===s);c&&w(v,c)}})})},q=()=>e("div",{className:n.menuContent,children:e(_,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:y==="off"},...$.map(t=>({key:t.label||t.lang,label:t.label,selected:y===(t.label||t.lang)}))],onSelect:t=>P(t)})}),F=()=>e("div",{className:n.menuContent,children:e(Z,{classes:{item:n.menuItem,active:n.selected},values:V,onChange:O})}),Q=X(()=>{try{const s=navigator.userAgentData?.brands?.map(l=>l.brand.toLowerCase())??[];if(s.length>0)return s.some(l=>l.includes("chromium")||l.includes("chrome")||l.includes("edge")||l.includes("opera")||l.includes("brave")||l.includes("vivaldi"));const c=navigator.userAgent.toLowerCase();return c.includes("chrome")||c.includes("chromium")||c.includes("edg")}catch{return!0}},[]),R=()=>e("div",{className:n.menuContent,children:[E&&e("div",{className:n.menuNote,role:"status",children:"Preparing GPU, this can take a few seconds…"}),f&&e("div",{className:n.menuError,role:"alert",children:["Upscaler failed: ",f]}),!Q&&e("div",{className:n.menuNote,children:"Upscaling performs best in Chrome-based browsers."}),e("button",{className:`${n.menuItem} ${i==="low"?n.selected:""}`,onClick:()=>h("low"),children:[e("div",{children:[e("div",{children:"Low"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Lightest, best for weaker GPUs"})]}),i==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="balanced"?n.selected:""}`,onClick:()=>h("balanced"),children:[e("div",{children:[e("div",{children:"Balanced"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Source + display aware"})]}),i==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="high"?n.selected:""}`,onClick:()=>h("high"),children:[e("div",{children:[e("div",{children:"High"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Aggressive, needs strong GPU"})]}),i==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="denoise"?n.selected:""}`,onClick:()=>h("denoise"),children:[e("div",{children:[e("div",{children:"Denoise"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Denoise + upscale noisy, compressed sources"})]}),i==="denoise"&&e(o,{name:"check",size:12})]})]}),H=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${d?n.selected:""}`,onClick:()=>L(!d),"aria-pressed":d,children:[e("span",{children:"Auto-skip openings and endings"}),e("span",{className:n.currentValue,children:d?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically jump past opening, ending and recap segments when detected."}),e("button",{type:"button",className:`${n.menuItem} ${m?n.selected:""}`,onClick:()=>M(!m),"aria-pressed":m,children:[e("span",{children:"Autoplay next episode"}),e("span",{className:n.currentValue,children:m?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically start the next episode when this one ends."}),e("button",{type:"button",className:n.menuItem,onClick:()=>W(p==="ask"?"iframe":p==="iframe"?"retry":"ask"),children:[e("span",{children:"Failed direct stream"}),e("span",{className:n.currentValue,children:p==="iframe"?"Use iframe":p==="retry"?"Try provider":"Ask me"})]}),e("div",{className:n.menuNote,children:"When a direct stream fails: ask each time, go straight to the embedded player (may show ads), or automatically try another provider."})]}),K=()=>e("div",{className:n.menuContent,children:e(ee,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:N,delayMs:S,onToggle:T,onDelayChange:D,onCalibrate:x})});return b?e(Y,{classes:{panel:n.settingsPanel,header:n.header,backBtn:n.backBtn,title:"",content:n.contentWrapper},title:a==="main"?"Settings":a.charAt(0).toUpperCase()+a.slice(1).replace("-"," "),titleTag:"h3",showBack:a!=="main",onBack:()=>r("main"),panelRef:z,onPanelClick:t=>t.stopPropagation(),children:[a==="main"&&G(),a==="quality"&&j(),a==="subtitles"&&q(),a==="subtitle-style"&&F(),a==="upscaler"&&R(),a==="av-sync"&&K(),a==="playback"&&H()]}):null},Ce=I.forwardRef(me);export{Ce as default};
@@ -1 +0,0 @@
1
- import{h as k,o as pe,a as ge,d as o,A as me,g as ve,u as a}from"./vendor-core-8R2fFbyN.js";import{I as d}from"./vendor-icons-CDMuNDeL.js";import{A as fe}from"./AnimeCard-OKU7LaSN.js";import{S as be}from"./SkeletonGrid-Du10CNfq.js";import{u as Le,r as Ae,P as ee,B as w,Q as ye}from"./index-lo-bz7f2.js";import{E as Se}from"./ErrorMessage-z4f4WGgP.js";import{s as t}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-CbNnHRj8.js";import"./vendor-query-BXRECSI6.js";import"./QueueOptionsButton-DKWi-9kd.js";import"./vendor-ui-CUDCvRS_.js";import"./MediaCard-DszKDA4s.js";import"./useIsMobile-Dm_b6Ob3.js";const Ne=[{value:"ALL",label:"All Types"},{value:"TV",label:"TV Series"},{value:"Movie",label:"Movie"},{value:"OVA",label:"OVA"},{value:"ONA",label:"ONA"},{value:"TV_SHORT",label:"TV Short"},{value:"SPECIAL",label:"Special"},{value:"ADULT",label:"Mature"}],Ce=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],Te=[{value:"ALL",label:"All Countries"},{value:"JP",label:"Japan"},{value:"CN",label:"China"}],Ee=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"START_DATE_ASC",label:"Oldest"},{value:"EPISODES_DESC",label:"Most Episodes"},{value:"FAVOURITES_DESC",label:"Favourites"}],Ie=[{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"},{value:"CANCELLED",label:"Cancelled"},{value:"HIATUS",label:"Hiatus"}];function Me(){k(()=>{document.title="Search - dango"},[]);const[r,ae]=pe(),te=ge(),[m,B]=o(r.get("query")||""),[c,_]=o(parseInt(r.get("page")||"1")),[h,A]=o(r.get("type")||"ALL"),[v,y]=o(r.get("season")||"ALL"),[f,S]=o(r.get("year")||"ALL"),[G,I]=o(r.get("country")||"ALL"),[Y,le]=o(r.get("provider")||"anilist"),[U,P]=o(r.get("sortBy")||"POPULARITY_DESC"),[F,x]=o(r.get("status")||""),[N,ne]=o(!1),[re,M]=o(null);k(()=>{let e=!1;return fetch("/api/anilist-status").then(n=>n.json()).then(n=>{e||M(n.available)}).catch(()=>{e||M(!0)}),()=>{e=!0}},[]);const{lowEndMode:se}=Le(),D=me(null),{data:ie}=Ae(),$=ie?.genres||[],[b,C]=o(()=>{const e={},n=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],s=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return n.forEach(l=>l&&(e[l]="include")),s.forEach(l=>l&&(e[l]="exclude")),e}),z=new URLSearchParams(r);z.delete("page");const j=z.toString(),{data:L=[],isLoading:g,isError:oe,error:ce}=ee(j,c,14),{data:V}=ee(j,c+1,14),[O,ue]=o(!1),T=ve.useMemo(()=>Y==="anilist"&&h==="ADULT"||O?L:L.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[L,O,Y,h]);k(()=>{B(r.get("query")||""),A(r.get("type")||"ALL"),y(r.get("season")||"ALL"),S(r.get("year")||"ALL"),I(r.get("country")||"ALL"),le(r.get("provider")||"anilist"),P(r.get("sortBy")||"POPULARITY_DESC"),x(r.get("status")||""),_(parseInt(r.get("page")||"1"));const e={},n=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],s=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];n.forEach(l=>l&&(e[l]="include")),s.forEach(l=>l&&(e[l]="exclude")),C(e)},[r]);const u=(e=1,n={})=>{ye();const s=n.type??h,l=n.status??F,H=n.season??v,q=n.year??f,J=n.country??G,K=n.sort??U,Q=n.genreState??b,he=n.showMature??O,i=new URLSearchParams;m.trim()&&i.set("query",m.trim()),s!=="ALL"&&i.set("type",s),l&&i.set("status",l),H!=="ALL"&&i.set("season",H),q!=="ALL"&&i.set("year",q),J!=="ALL"&&i.set("country",J),K!=="POPULARITY_DESC"&&i.set("sortBy",K);const X=Object.entries(Q).filter(([,p])=>p==="include").map(([p])=>p),Z=Object.entries(Q).filter(([,p])=>p==="exclude").map(([p])=>p);X.length>0&&i.set("genres",X.join(",")),Z.length>0&&i.set("excludeGenres",Z.join(",")),s!=="ADULT"&&!he&&i.set("adult","false"),i.set("provider","anilist"),e>1&&i.set("page",e.toString()),ae(i),e!==c&&_(e)},E=e=>{if(u(e),D.current){const n=D.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:n,behavior:"smooth"})}},R=new Date().getFullYear(),de=[{value:"ALL",label:"All Years"},...Array.from({length:R-1980+1},(e,n)=>({value:String(R-n),label:String(R-n)}))],W=L.length>=14&&V&&V.length>0;return a("div",{className:"page-container",children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:"Search Anime"}),a("p",{className:t.pageSubtitle,children:"Search through thousands of titles and discover your next favorite"})]}),a("div",{className:t.filterContainer,children:[a("div",{className:t.searchBarWrapper,children:[a("div",{className:t.inputIconWrapper,children:[a(d,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search by title, character, or studio...",value:m,onInput:e=>B(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&u()})]}),a("div",{className:t.searchActions,children:[a(w,{onClick:()=>u(),className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${N?t.active:""}`,onClick:()=>ne(!N),children:[a(d,{name:"filter",size:14}),a("span",{children:"Filters"}),N?a(d,{name:"chevron-up",size:12}):a(d,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${N?t.show:""}`,children:[a("div",{className:t.filterDivider}),a("div",{className:t.filterGrid,children:[a("div",{className:t.filterItem,children:[a("label",{children:"Type"}),a("select",{value:h,onChange:e=>{if(e.currentTarget.value==="ADULT"){te("/mature?provider=mal");return}A(e.currentTarget.value)},children:Ne.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Status"}),a("select",{value:F,onChange:e=>x(e.currentTarget.value),children:[a("option",{value:"",children:"All Status"}),Ie.map(e=>a("option",{value:e.value,children:e.label},e.value))]})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Season"}),a("select",{value:v,onChange:e=>y(e.currentTarget.value),children:Ce.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Year"}),a("select",{value:f,onChange:e=>S(e.currentTarget.value),children:de.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:["Country",re===!1&&a("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:400},children:"AniList only — ignored by fallback providers"})]}),a("select",{value:G,onChange:e=>I(e.currentTarget.value),children:Te.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Sort By"}),a("select",{value:U,onChange:e=>P(e.currentTarget.value),children:Ee.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),$.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:$.map(e=>a("button",{className:`${t.genreButton} ${t[b[e]||""]}`,onClick:()=>{C(n=>{const s=n[e],l={...n};return s==="include"?l[e]="exclude":s==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(w,{variant:"secondary",onClick:()=>{C({}),A("ALL"),y("ALL"),S("ALL"),I("ALL"),P("POPULARITY_DESC"),x(""),ue(!1),u(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(w,{onClick:()=>u(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),oe&&a(Se,{message:ce?.message||"Error"}),(h!=="ALL"||v!=="ALL"||f!=="ALL"||Object.keys(b).length>0)&&a("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",marginBottom:"1.5rem"},children:[a("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontWeight:600},children:"Active Filters:"}),h!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Type: ",h,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),A("ALL"),u(1,{type:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),v!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Season: ",v,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),y("ALL"),u(1,{season:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),f!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Year: ",f,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),S("ALL"),u(1,{year:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),Object.entries(b).map(([e,n])=>a("span",{className:`badge ${n==="include"?"badge-primary":"badge-danger"}`,style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[n==="include"?`+ ${e}`:`- ${e}`,a("button",{onClick:s=>{s.stopPropagation(),s.preventDefault();const l={...b};delete l[e],C(l),u(1,{genreState:l})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]},e))]}),a("div",{className:t.resultsHeader,ref:D,children:[a("h2",{className:t.resultsTitle,children:m?`Search Results for "${m}"`:"Discover Anime"}),T.length>0&&a("div",{className:t.pagination,children:[a("button",{className:t.pageBtn,onClick:()=>E(c-1),disabled:c===1||g,"aria-label":"Previous page",children:a(d,{name:"chevron-left",size:14})}),a("span",{className:t.pageInfo,children:["Page ",a("strong",{children:c})]}),a("button",{className:t.pageBtn,onClick:()=>E(c+1),disabled:!W||g,"aria-label":"Next page",children:a(d,{name:"chevron-right",size:14})})]})]}),a("div",{className:`${t.resultsGrid} ${se?t.lowEnd:""}`,children:g?a(be,{}):T.map(e=>a(fe,{anime:e},e._id))}),!g&&T.length===0&&a("div",{className:t.noResults,children:[a(d,{name:"search",size:48,className:t.noResultsIcon}),a("h3",{children:"No results found"}),a("p",{children:"Try adjusting your search or filters to find what you're looking for."})]}),T.length>0&&a("div",{className:t.bottomPagination,children:a("div",{className:t.pagination,children:[a("button",{className:t.pageBtn,onClick:()=>E(c-1),disabled:c===1||g,children:[a(d,{name:"chevron-left",size:14}),a("span",{children:"Previous"})]}),a("span",{className:t.pageInfo,children:["Page ",a("strong",{children:c})]}),a("button",{className:t.pageBtn,onClick:()=>E(c+1),disabled:!W||g,children:[a("span",{children:"Next"}),a(d,{name:"chevron-right",size:14})]})]})})]})}export{Me as default};
@@ -1 +0,0 @@
1
- ._skeletonCard_1b0hr_1{display:flex;flex-direction:column;background-color:var(--bg-secondary);border-radius:var(--radius-md);overflow:hidden;height:100%;border:1px solid var(--border-secondary)}._poster_1b0hr_11{width:100%;aspect-ratio:3 / 4;background-color:var(--bg-tertiary);position:relative;overflow:hidden}._poster_1b0hr_11:after,._line_1b0hr_20:after{content:"";position:absolute;inset:0;transform:translate(-100%);background-image:linear-gradient(90deg,#fff0 0,#ffffff0d 20%,#ffffff1f 60%,#fff0);animation:_skeleton-wave_1b0hr_1 1.8s infinite ease-in-out}._info_1b0hr_38{padding:var(--space-3);display:flex;flex-direction:column;gap:var(--space-2);flex-grow:1}._line_1b0hr_20{position:relative;overflow:hidden;height:18px;border-radius:var(--radius-sm);background-color:var(--bg-tertiary)}._line_1b0hr_20._short_1b0hr_54{width:60%;height:14px}@media(max-width:768px){._skeletonCard_1b0hr_1._horizontal_1b0hr_60{flex-direction:row;height:auto;min-height:100px}._skeletonCard_1b0hr_1._horizontal_1b0hr_60 ._poster_1b0hr_11{width:85px;height:100%;aspect-ratio:auto;flex-shrink:0}._skeletonCard_1b0hr_1._horizontal_1b0hr_60 ._info_1b0hr_38{padding:var(--space-2) var(--space-3);justify-content:center}._skeletonCard_1b0hr_1._vertical_1b0hr_78 ._poster_1b0hr_11{width:100%;aspect-ratio:3 / 4}._skeletonCard_1b0hr_1._vertical_1b0hr_78 ._info_1b0hr_38{padding:var(--space-2);align-items:center}._line_1b0hr_20{height:16px}._line_1b0hr_20._short_1b0hr_54{height:12px}}._skeletonCard_1b0hr_1._lowEnd_1b0hr_97{min-height:0}._skeletonCard_1b0hr_1._lowEnd_1b0hr_97 ._poster_1b0hr_11:after,._skeletonCard_1b0hr_1._lowEnd_1b0hr_97 ._line_1b0hr_20:after{animation:none}._skeletonCard_1b0hr_1._lowEnd_1b0hr_97 ._line_1b0hr_20{opacity:.6}._skeletonCard_1b0hr_1._lowEnd_1b0hr_97 ._info_1b0hr_38{padding:var(--space-3)}
@@ -1 +0,0 @@
1
- import{u as e,g as t}from"./vendor-core-8R2fFbyN.js";import{u as l}from"./index-lo-bz7f2.js";const a="_skeletonCard_1b0hr_1",i="_poster_1b0hr_11",c="_line_1b0hr_20",_="_info_1b0hr_38",d="_short_1b0hr_54",h="_horizontal_1b0hr_60",m="_vertical_1b0hr_78",v="_lowEnd_1b0hr_97",o={skeletonCard:a,poster:i,line:c,"skeleton-wave":"_skeleton-wave_1b0hr_1",info:_,short:d,horizontal:h,vertical:m,lowEnd:v},b=({layout:n="vertical"})=>{const{lowEndMode:r}=l();return e("div",{className:`${o.skeletonCard} ${o[n]} ${r?o.lowEnd:""}`,children:[e("div",{className:o.poster}),e("div",{className:o.info,children:[e("div",{className:o.line}),e("div",{className:`${o.line} ${o.short}`})]})]})},k=({count:n=14,layout:r="vertical"})=>e("div",{className:"grid-container",children:Array.from({length:n}).map((p,s)=>e(b,{layout:r},s))}),E=t.memo(k);export{b as A,E as S};
@@ -1,2 +0,0 @@
1
- import{d as a,h as me,g as ce,A as le,q as je,u as e,S as I}from"./vendor-core-8R2fFbyN.js";import{u as ue,b as de,a as R}from"./vendor-query-BXRECSI6.js";import{z as s,W as Se,B as pe}from"./index-lo-bz7f2.js";import{I as h}from"./vendor-icons-CDMuNDeL.js";function Ce(){const B=ue(),[r,m]=a(!1);return me(()=>{const g=new URLSearchParams(window.location.search),u=g.get("anilist");if(u){const i=g.get("user"),b=g.get("reason");window.history.replaceState(null,"",window.location.pathname),u==="success"?(s.success(i?`Connected to AniList as ${decodeURIComponent(i)}`:"Connected to AniList"),B.invalidateQueries({queryKey:["trackerStatus"]})):s.error(b?decodeURIComponent(b):"AniList authentication failed");return}const w=new URLSearchParams(window.location.hash.substring(1)),c=w.get("access_token"),D=g.get("code");if(!c&&!D){const i=w.get("error");i&&(s.error(`AniList error: ${i}`),window.history.replaceState(null,"",window.location.pathname));return}const j=window.location.origin+window.location.pathname;window.history.replaceState(null,"",window.location.pathname),m(!0),s("Connecting to AniList..."),fetch("/api/tracker/anilist/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c?{token:c}:{code:D,redirectUri:j})}).then(async i=>{const b=await i.json().catch(()=>({}));if(!i.ok)throw new Error(b.error||"Authentication failed");s.success(`Connected to AniList as ${b.user?.name??"AniList user"}`),B.invalidateQueries({queryKey:["trackerStatus"]})}).catch(i=>{s.error(i instanceof Error?i.message:"Failed to authenticate with AniList")}).finally(()=>{m(!1)})},[B]),r}const Te="_header_j1lbh_1",xe="_fadeIn_j1lbh_1",Le="_pageTitle_j1lbh_6",Ae="_pageSubtitle_j1lbh_14",Pe="_importCard_j1lbh_20",Ee="_slideUpIn_j1lbh_1",Be="_cardHeader_j1lbh_37",De="_uploadArea_j1lbh_55",Me="_fileInputWrapper_j1lbh_59",Oe="_fileInput_j1lbh_59",Fe="_fileDisplay_j1lbh_87",$e="_fileIcon_j1lbh_95",Ue="_fileName_j1lbh_100",Re="_browseButton_j1lbh_109",qe="_optionsArea_j1lbh_120",Ke="_checkboxLabel_j1lbh_128",He="_checkbox_j1lbh_128",Qe="_checkboxCustom_j1lbh_141",Ge="_optionText_j1lbh_169",We="_optionTitle_j1lbh_175",ze="_optionDesc_j1lbh_181",Je="_actions_j1lbh_187",Xe="_importBtn_j1lbh_195",Ve="_cancelBtn_j1lbh_201",Ye="_statusMessage_j1lbh_215",Ze="_success_j1lbh_225",en="_error_j1lbh_231",nn="_progressSection_j1lbh_237",tn="_progressBar_j1lbh_242",sn="_progressFill_j1lbh_250",an="_progressInfo_j1lbh_257",on="_progressCount_j1lbh_264",rn="_progressTitle_j1lbh_271",cn="_sourceBadge_j1lbh_289",ln="_anilist_j1lbh_301",dn="_kitsu_j1lbh_307",pn="_offline_j1lbh_313",hn="_skipped_j1lbh_319",mn="_cardTitleRow_j1lbh_324",un="_anilistIcon_j1lbh_334",_n="_malIcon_j1lbh_340",gn="_badgeOnline_j1lbh_346",bn="_badgeOffline_j1lbh_358",fn="_connectedProfile_j1lbh_370",yn="_avatar_j1lbh_379",wn="_connectedInfo_j1lbh_386",Nn="_connectedName_j1lbh_394",kn="_connectedHint_j1lbh_400",vn="_loginPrompt_j1lbh_405",In="_loginSection_j1lbh_413",jn="_fieldLabel_j1lbh_419",Sn="_helpText_j1lbh_438",Cn="_loginText_j1lbh_455",Tn="_primaryBtn_j1lbh_464",xn="_secondaryBtn_j1lbh_465",Ln="_syncBtn_j1lbh_466",An="_divider_j1lbh_518",Pn="_actionSection_j1lbh_524",En="_inputGroup_j1lbh_538",Bn="_input_j1lbh_538",Dn="_syncSummary_j1lbh_559",Mn="_syncErrors_j1lbh_565",On="_spin_j1lbh_569",Fn="_radioGroup_j1lbh_598",$n="_radioLabel_j1lbh_604",Un="_syncHint_j1lbh_642",Rn="_importLoading_j1lbh_649",n={header:Te,fadeIn:xe,pageTitle:Le,pageSubtitle:Ae,importCard:Pe,slideUpIn:Ee,cardHeader:Be,uploadArea:De,fileInputWrapper:Me,fileInput:Oe,fileDisplay:Fe,fileIcon:$e,fileName:Ue,browseButton:Re,optionsArea:qe,checkboxLabel:Ke,checkbox:He,checkboxCustom:Qe,optionText:Ge,optionTitle:We,optionDesc:ze,actions:Je,importBtn:Xe,cancelBtn:Ve,statusMessage:Ye,success:Ze,error:en,progressSection:nn,progressBar:tn,progressFill:sn,progressInfo:an,progressCount:on,progressTitle:rn,sourceBadge:cn,anilist:ln,kitsu:dn,offline:pn,skipped:hn,cardTitleRow:mn,anilistIcon:un,malIcon:_n,badgeOnline:gn,badgeOffline:bn,connectedProfile:fn,avatar:yn,connectedInfo:wn,connectedName:Nn,connectedHint:kn,loginPrompt:vn,loginSection:In,fieldLabel:jn,helpText:Sn,loginText:Cn,primaryBtn:Tn,secondaryBtn:xn,syncBtn:Ln,divider:An,actionSection:Pn,inputGroup:En,input:Bn,syncSummary:Dn,syncErrors:Mn,spin:On,radioGroup:Fn,radioLabel:$n,syncHint:Un,importLoading:Rn},W="tracker_anilist_client_id",he="49887".trim(),Gn=()=>{const{setIsOpen:B}=Se(),r=ue();ce.useEffect(()=>{document.title="Trackers - dango"},[]);const[m,g]=a(""),[u,w]=a("username"),[c,D]=a(null),[j,i]=a(""),b=Ce(),{data:z,isLoading:_e}=de({queryKey:["trackerStatus"],queryFn:async()=>{const t=await fetch("/api/tracker/status");if(!t.ok)throw new Error("Failed to load tracker status");return t.json()}}),{data:N}=de({queryKey:["anilistClientId"],queryFn:async()=>(await(await fetch(`/api/settings?key=${W}`)).json()).value||""}),J=le(!1);ce.useEffect(()=>{J.current||N!==void 0&&(N&&i(N),J.current=!0)},[N]);const S=z?.anilist?.connected??!1;me(()=>{S&&w("sync")},[S]);const M=z?.anilist?.user??null,q=!!he,ge=(N||"").trim(),be=async()=>{const t=j.trim(),o=t||he;if(!o){s.error("Enter your AniList client ID first");return}const _=async(y,Q)=>{if(!(await fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:y,value:Q})})).ok)throw new Error(`Failed to save ${y}`)};try{t?t!==N&&await _(W,t):q&&ge&&await _(W,""),r.invalidateQueries({queryKey:["anilistClientId"]})}catch(y){s.error(y.message);return}const p=window.location.origin+window.location.pathname,A=encodeURIComponent(p);window.location.href=`https://anilist.co/api/v2/oauth/authorize?client_id=${encodeURIComponent(o)}&response_type=token&state=${A}`},X=R({mutationFn:async()=>{const t=await fetch("/api/tracker/anilist/disconnect",{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect");return t.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["trackerStatus"]}),s.success("Disconnected from AniList")},onError:t=>s.error(t.message)}),O=R({mutationFn:async()=>{const t=await fetch("/api/tracker/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:"anilist"})}),o=await t.json();if(!t.ok)throw new Error(o.error||"Sync failed");return o.summary},onSuccess:t=>{r.invalidateQueries({queryKey:["watchlist"]}),r.invalidateQueries({queryKey:["allContinueWatching"]}),D(t),s.success(`Sync complete — pushed ${t.pushed}, pulled ${t.pulled}, merged ${t.merged}, unchanged ${t.unchanged}`,{duration:6e3})},onError:t=>s.error(t.message)}),k=R({mutationFn:async()=>{if(!m.trim())throw new Error("Please enter a username");const t=await fetch("/api/tracker/anilist/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:m.trim(),erase:f})}),o=await t.json();if(!t.ok)throw new Error(o.error||"Import failed");return o.count},onSuccess:t=>{r.invalidateQueries({queryKey:["watchlist"]}),r.invalidateQueries({queryKey:["allContinueWatching"]}),s.success(`Imported ${t} anime entries from AniList`),g("")},onError:t=>s.error(t.message)}),[C,V]=a(""),d=R({mutationFn:async t=>{if(!C.trim())throw new Error("Please enter a MAL username");const o=await fetch("/api/tracker/mal/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:C.trim(),erase:t.erase,useOfflineDb:t.useOfflineDb,skipFallback:t.skipFallback})}),_=await o.json();if(!o.ok)throw new Error(_.error||"Import failed");return _.count},onSuccess:t=>{r.invalidateQueries({queryKey:["watchlist"]}),r.invalidateQueries({queryKey:["allContinueWatching"]}),s.success(`Imported ${t} anime entries from MAL`),V("")},onError:t=>s.error(t.message)}),[f,Y]=a(!1),[T,fe]=a(!0),[x,ye]=a(!1),[Z,ee]=a(""),[v,ne]=a(!1),[l,te]=a(null),[K,se]=a(null),[ae,F]=a(""),H=le(null),we=t=>{t.target.files&&t.target.files.length>0?ee(t.target.files[0].name):ee("")},Ne=je(async()=>{const t=document.getElementById("malFile");if(!t.files||t.files.length===0){F("Please select a file first.");return}const o=t.files[0];ne(!0),te(null),se(null),F("");const _=new AbortController;H.current=_;try{const p=new FormData;p.append("xmlfile",o),p.append("erase",String(f)),p.append("useOfflineDb",String(T)),p.append("skipFallback",String(x));const A=await fetch("/api/import/mal-xml",{method:"POST",body:p,signal:_.signal});if(!A.ok){const G=await A.text();let P="Failed to import";try{P=JSON.parse(G).error||P}catch{}throw new Error(P)}const y=A.body?.getReader();if(!y)throw new Error("No response stream");const Q=new TextDecoder;let $="",U="";for(;;){const{done:G,value:P}=await y.read();if(G)break;$+=Q.decode(P,{stream:!0});const oe=$.split(`
2
- `);$=oe.pop()||"";for(const E of oe)if(E.startsWith("event: "))U=E.slice(7).trim();else if(E.startsWith("data: ")){const Ie=E.slice(6);try{const re=JSON.parse(Ie);U==="progress"?te(re):U==="complete"&&se(re)}catch{}}else E===""&&(U="")}r.invalidateQueries({queryKey:["watchlist"]})}catch(p){p instanceof DOMException&&p.name==="AbortError"?F("Import cancelled."):F(p.message)}finally{ne(!1),H.current=null}},[f,T,x,r]),ke=()=>{H.current?.abort(),fetch("/api/import/mal-xml/cancel",{method:"POST"}).catch(()=>{})},ve=l?Math.round(l.current/l.total*100):0,[L,ie]=a("username");return e("div",{className:"page-container",children:[e("div",{className:n.header,children:[e("h1",{className:n.pageTitle,children:"Trackers"}),e("p",{className:n.pageSubtitle,children:"Import & sync your anime watchlists with tracking services"})]}),e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(h,{name:"anilist",className:n.anilistIcon}),e("h3",{children:"AniList"}),_e?null:S?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),S&&M?e("div",{className:n.connectedProfile,children:[M.avatar&&e("img",{src:M.avatar,alt:"Avatar",className:n.avatar,loading:"lazy",decoding:"async"}),e("div",{className:n.connectedInfo,children:[e("span",{className:n.connectedName,children:M.name}),e("span",{className:n.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:n.secondaryBtn,onClick:()=>X.mutate(),disabled:X.isPending,children:[e(h,{name:"sign-out-alt"})," Disconnect"]})]}):e("div",{className:n.loginSection,children:[e("p",{className:n.loginText,children:["Log in with AniList to enable bidirectional progress & status synchronization.",b&&e("span",{style:{marginLeft:8,color:"var(--accent)"},children:"Finishing login…"})]}),e("div",{className:n.fieldLabel,children:["AniList client ID — defaults to Dango's app"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:["create your own app ",e(h,{name:"external-link-alt",size:9})]})]}),e("div",{className:n.inputGroup,children:[e("input",{type:"text",placeholder:"Client ID",value:j,onChange:t=>i(t.target.value),className:n.input}),e("button",{className:n.primaryBtn,onClick:be,disabled:!(j.trim()||q),children:[e(h,{name:"external-link-alt"})," Connect"]})]}),e("p",{className:n.helpText,children:q?e(I,{children:["By default uses Dango's client. To use your own AniList app: create it at"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:"anilist.co/settings/developer"}),", set its ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:window.location.port==="5173"?`${window.location.protocol}//${window.location.hostname}:3000/api/tracker/anilist/callback`:`${window.location.origin}/api/tracker/anilist/callback`}),", then paste only the ",e("strong",{children:"Client ID"})," above (leave empty to use Dango's)."]}):e(I,{children:["No shipped client in this build — create your own app at"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:"anilist.co/settings/developer"}),", set ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:window.location.port==="5173"?`${window.location.protocol}//${window.location.hostname}:3000/api/tracker/anilist/callback`:`${window.location.origin}/api/tracker/anilist/callback`}),", then paste the ",e("strong",{children:"Client ID"})," above."]})})]}),S&&e(I,{children:[e("hr",{className:n.divider}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"username",checked:u==="username",onChange:()=>w("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"sync",checked:u==="sync",onChange:()=>w("sync")}),e("span",{children:"Two-way Sync"})]})]}),u==="username"?e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:m,onChange:t=>g(t.target.value),className:n.input,disabled:k.isPending,onKeyDown:t=>{t.key==="Enter"&&m.trim()&&k.mutate()}})}):e("p",{className:n.syncHint,children:"Merges progress non-destructively: pushes shows and episodes you watched on dango to AniList, and pulls anything you updated on AniList into dango."}),u==="username"&&e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:f,onChange:t=>Y(t.target.checked),className:n.checkbox,disabled:k.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Erase current watchlist"}),e("span",{className:n.optionDesc,children:"Delete existing watchlist before importing."})]})]})}),u==="username"?e("button",{className:n.syncBtn,onClick:()=>k.mutate(),disabled:!m.trim()||k.isPending,children:[e(h,{name:"download"}),k.isPending?"Importing...":"Start Import"]}):e(I,{children:[e("button",{className:n.syncBtn,onClick:()=>O.mutate(),disabled:O.isPending,children:[e(h,{name:"sync-alt",className:O.isPending?n.spin:""}),O.isPending?"Syncing...":"Start Sync"]}),c&&e("div",{className:n.syncSummary,children:["Pushed: ",c.pushed," · Pulled: ",c.pulled," · Merged:"," ",c.merged," · Unchanged: ",c.unchanged,c.errors.length>0&&e("span",{className:n.syncErrors,children:[" ","· ",c.errors.length," error",c.errors.length>1?"s":""]})]})]}),e("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"8px"},children:["AniList ",e("code",{children:"Rewatching (REPEATING)"})," is not tracked — entries with this status are ignored."]})]})]}),e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(h,{name:"myanimelist",className:n.malIcon}),e("h3",{children:"MyAnimeList"})]})}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"username",checked:L==="username",onChange:()=>ie("username")}),e("span",{children:"Username"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"xml",checked:L==="xml",onChange:()=>ie("xml")}),e("span",{children:"XML File"})]})]}),L==="username"?e(I,{children:[e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:C,onChange:t=>V(t.target.value),className:n.input,disabled:d.isPending,onKeyDown:t=>{t.key==="Enter"&&C.trim()&&d.mutate({erase:f,useOfflineDb:T,skipFallback:x})}})}),d.isPending&&e("div",{className:n.importLoading,children:[e(h,{name:"sync-alt",className:n.spin}),e("span",{children:"Importing from MAL..."})]})]}):e("div",{className:n.uploadArea,children:e("div",{className:n.fileInputWrapper,children:[e("input",{type:"file",id:"malFile",accept:".xml,application/xml",className:n.fileInput,onChange:we,disabled:v}),e("div",{className:n.fileDisplay,children:[e(h,{name:"file-alt",className:n.fileIcon}),e("span",{className:n.fileName,children:Z||"Choose XML file..."})]}),e("label",{htmlFor:"malFile",className:n.browseButton,children:"Browse"})]})}),e("div",{className:n.optionsArea,children:[e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:f,onChange:t=>Y(t.target.checked),className:n.checkbox,disabled:v||d.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Erase current watchlist"}),e("span",{className:n.optionDesc,children:"Delete existing watchlist before importing."})]})]}),e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:T,onChange:t=>fe(t.target.checked),className:n.checkbox,disabled:v||d.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Use offline database (fast)"}),e("span",{className:n.optionDesc,children:"Match by MAL ID locally first — instant and avoids AniList rate limits."})]})]}),e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:x,onChange:t=>ye(t.target.checked),className:n.checkbox,disabled:v||d.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Skip online fallback"}),e("span",{className:n.optionDesc,children:"Only import offline matches. Unmatched titles are skipped without API calls."})]})]})]}),L==="username"?e("button",{className:n.syncBtn,onClick:()=>d.mutate({erase:f,useOfflineDb:T,skipFallback:x}),disabled:!C.trim()||d.isPending,children:[e(h,{name:"download"}),d.isPending?"Importing...":"Start Import"]}):e("div",{className:n.actions,children:v?e(pe,{onClick:ke,className:n.cancelBtn,children:"Cancel Import"}):e(pe,{onClick:Ne,className:n.importBtn,disabled:!Z,children:[e(h,{name:"upload"})," Start Import"]})}),L==="username"&&d.isError&&e("div",{className:`${n.statusMessage} ${n.error}`,children:d.error.message}),v&&l&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressBar,children:e("div",{className:n.progressFill,style:{width:`${ve}%`}})}),e("div",{className:n.progressInfo,children:[e("span",{className:n.progressCount,children:[l.current," / ",l.total]}),e("span",{className:n.progressTitle,children:l.found?e(I,{children:[l.matchedTitle,e("span",{className:`${n.sourceBadge} ${n[l.source||"anilist"]}`,children:l.source==="kitsu"?"Kitsu":l.source==="offline"?"Offline DB":"AniList"})]}):e("span",{className:n.skipped,children:["Skipped: ",l.title]})})]})]}),K&&e("div",{className:`${n.statusMessage} ${n.success}`,children:["Import complete! Imported: ",K.imported,", Skipped: ",K.skipped,"."]}),ae&&e("div",{className:`${n.statusMessage} ${n.error}`,children:ae})]})]})};export{Gn as default};
@@ -1 +0,0 @@
1
- import{h as D,o as ae,A as te,d as c,T as I,q as A,u as a}from"./vendor-core-8R2fFbyN.js";import{I as d}from"./vendor-icons-CDMuNDeL.js";import{a as ne,T as re}from"./useTv-DTqrJEWp.js";import{S as se}from"./SkeletonGrid-Du10CNfq.js";import{u as le,Q as ie,B as _}from"./index-lo-bz7f2.js";import{E as oe}from"./ErrorMessage-z4f4WGgP.js";import{s as t}from"./Search.module-CMEai-B-.js";import"./MediaCard-DszKDA4s.js";import"./vendor-ui-CUDCvRS_.js";import"./useIsMobile-Dm_b6Ob3.js";import"./TvPopup-CP41CncZ.js";import"./useTvLibrary-BHeWSd1F.js";import"./vendor-query-BXRECSI6.js";const ce=[{value:"multi",label:"All"},{value:"tv",label:"TV Shows"},{value:"movie",label:"Movies"}],de=[{value:"popularity.desc",label:"Popularity"},{value:"vote_average.desc",label:"Top Rated"},{value:"primary_release_date.desc",label:"Newest"},{value:"primary_release_date.asc",label:"Oldest"},{value:"vote_count.desc",label:"Most Voted"}],V={10759:"Action & Adventure",16:"Animation",35:"Comedy",80:"Crime",99:"Documentary",18:"Drama",10751:"Family",10762:"Kids",9648:"Mystery",10765:"Sci-Fi & Fantasy",37:"Western"},W={28:"Action",12:"Adventure",16:"Animation",35:"Comedy",80:"Crime",99:"Documentary",18:"Drama",10751:"Family",14:"Fantasy",36:"History",27:"Horror",9648:"Mystery",10749:"Romance",878:"Sci-Fi",53:"Thriller",10752:"War",37:"Western"},M=new Date().getFullYear(),me=[{value:"ALL",label:"All Years"},...Array.from({length:M-1980+1},(i,h)=>({value:String(M-h),label:String(M-h)}))];function Ae(){D(()=>{document.title="Search TV & Movies - dango"},[]);const[i,h]=ae(),{lowEndMode:Y}=le(),k=te(null),[v,Q]=c(i.get("q")||""),[g,H]=c(i.get("q")||""),[s,y]=c(parseInt(i.get("page")||"1",10)||1),[o,K]=c(i.get("type")||"multi"),[x,O]=c(i.get("genre")||""),[f,$]=c(i.get("year")||"ALL"),[b,F]=c(i.get("sort_by")||"popularity.desc"),[N,U]=c(!1),[m,S]=c(()=>{const e={},n=i.get("genre")||"";return n&&(e[n]="include"),e}),P=I(()=>{if(o==="tv")return Object.entries(V).map(([n,r])=>({id:n,name:r}));if(o==="movie")return Object.entries(W).map(([n,r])=>({id:n,name:r}));const e=new Map;for(const[n,r]of Object.entries(V))e.set(n,r);for(const[n,r]of Object.entries(W))e.set(n,r);return Array.from(e.entries()).map(([n,r])=>({id:n,name:r}))},[o]),w=I(()=>Object.entries(m).filter(([,n])=>n==="include").map(([n])=>n).join(","),[m]),{data:B,isLoading:p,isError:J,error:X}=ne({query:g,type:o,genre:w,year:f,sort_by:b,page:s}),T=B?.results||[],Z=B?.total_pages||0,E=B?.total_results||0,R=s<Math.min(Z,500),u=A((e={})=>{const n=new URLSearchParams,r=e.q!==void 0?e.q:g,l=e.type!==void 0?e.type:o,j=e.year!==void 0?e.year:f,q=e.sort!==void 0?e.sort:b,z=e.page!==void 0?e.page:String(s),G=e.genre!==void 0?e.genre:w;r.trim()&&n.set("q",r.trim()),l!=="multi"&&n.set("type",l),G&&n.set("genre",G),j!=="ALL"&&n.set("year",j),q!=="popularity.desc"&&n.set("sort_by",q),z!=="1"&&n.set("page",z),h(n,{replace:!0})},[g,o,f,b,s,w,h]),L=A(()=>{ie(),y(1),H(v),u({q:v,page:"1"}),window.scrollTo({top:0,behavior:"smooth"})},[v,u]),C=A(e=>{if(y(e),u({page:String(e)}),k.current){const n=k.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:n,behavior:"smooth"})}},[u]),ee=A(e=>{S(n=>{const r=n[e],l={...n};return r==="include"?l[e]="exclude":r==="exclude"?delete l[e]:l[e]="include",l}),y(1)},[]);return D(()=>{const n=Object.entries(m).filter(([,r])=>r==="include").map(([r])=>r).join(",");n!==x&&(O(n),u({genre:n,page:"1"}))},[m,x,O,u]),a("div",{className:"page-container",children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:"Search TV & Movies"}),a("p",{className:t.pageSubtitle,children:"Discover trending shows, movies, and more powered by TMDB"})]}),a("div",{className:t.filterContainer,children:[a("div",{className:t.searchBarWrapper,children:[a("div",{className:t.inputIconWrapper,children:[a(d,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search titles...",value:v,onInput:e=>Q(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&L()})]}),a("div",{className:t.searchActions,children:[a("select",{value:o,onChange:e=>{K(e.target.value),S({})},className:t.providerSelect,"aria-label":"Media type",children:ce.map(e=>a("option",{value:e.value,children:e.label},e.value))}),a(_,{onClick:L,className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${N?t.active:""}`,onClick:()=>U(!N),children:[a(d,{name:"filter",size:14}),a("span",{children:"Filters"}),N?a(d,{name:"chevron-up",size:12}):a(d,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${N?t.show:""}`,children:[a("div",{className:t.filterDivider}),a("div",{className:t.filterGrid,children:[a("div",{className:t.filterItem,children:[a("label",{children:"Sort By"}),a("select",{value:b,onChange:e=>F(e.currentTarget.value),children:de.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Year"}),a("select",{value:f,onChange:e=>$(e.currentTarget.value),children:me.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),P.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:P.map(e=>a("button",{className:`${t.genreButton} ${t[m[e.id]||""]}`,onClick:()=>ee(e.id),children:e.name},e.id))})]}),a("div",{className:t.filterActions,children:[a(_,{variant:"secondary",onClick:()=>{S({}),$("ALL"),F("popularity.desc"),y(1),u({genre:"",year:"ALL",sort:"popularity.desc",page:"1"})},children:"Reset All"}),a(_,{onClick:L,className:t.searchBtn,children:"Apply Filters"})]})]})]}),J&&a(oe,{message:X?.message||"Search failed"}),Object.keys(m).length>0&&a("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"1.5rem"},children:[a("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontWeight:600},children:"Active Filters:"}),Object.entries(m).map(([e,n])=>{const r=P.find(l=>l.id===e)?.name||e;return a("span",{className:`badge ${n==="include"?"badge-primary":"badge-danger"}`,style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[n==="include"?`+ ${r}`:`- ${r}`,a("button",{onClick:()=>{const l={...m};delete l[e],S(l)},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]},e)})]}),a("div",{className:t.resultsHeader,ref:k,children:[a("h2",{className:t.resultsTitle,children:[g?`Results for "${g}"`:w?"Browsing genres":o==="tv"?"Popular TV Shows":o==="movie"?"Popular Movies":"Trending",E>0&&a("span",{style:{fontWeight:400,color:"var(--text-tertiary)",fontSize:"0.85em",marginLeft:"0.5em"},children:["(",E.toLocaleString(),")"]})]}),T.length>0&&a("div",{className:t.pagination,children:[a("button",{className:t.pageBtn,onClick:()=>C(s-1),disabled:s===1||p,"aria-label":"Previous page",children:a(d,{name:"chevron-left",size:14})}),a("span",{className:t.pageInfo,children:["Page ",a("strong",{children:s})]}),a("button",{className:t.pageBtn,onClick:()=>C(s+1),disabled:!R||p,"aria-label":"Next page",children:a(d,{name:"chevron-right",size:14})})]})]}),a("div",{className:`${t.resultsGrid} ${Y?t.lowEnd:""}`,children:p?a(se,{}):T.map(e=>a(re,{item:{id:e.id,title:e.title,year:e.year,type:e.type,image:e.image,vote_average:e.vote_average,adult:e.adult}},`${e.type}-${e.id}`))}),!p&&T.length===0&&a("div",{className:t.noResults,children:[a(d,{name:"search",size:48,className:t.noResultsIcon}),a("h3",{children:"No results found"}),a("p",{children:"Try adjusting your search or filters to find what you're looking for."})]}),T.length>0&&a("div",{className:t.bottomPagination,children:a("div",{className:t.pagination,children:[a("button",{className:t.pageBtn,onClick:()=>C(s-1),disabled:s===1||p,children:[a(d,{name:"chevron-left",size:14}),a("span",{children:"Previous"})]}),a("span",{className:t.pageInfo,children:["Page ",a("strong",{children:s})]}),a("button",{className:t.pageBtn,onClick:()=>C(s+1),disabled:!R||p,children:[a("span",{children:"Next"}),a(d,{name:"chevron-right",size:14})]})]})})]})}export{Ae as default};
@@ -1 +0,0 @@
1
- import{h as he,n as je,a as qe,o as Ke,d as u,A as pe,T as j,u as t,S as Ve}from"./vendor-core-8R2fFbyN.js";import{u as Qe,a as ge}from"./vendor-query-BXRECSI6.js";import{u as He,d as Je,r as Ze,t as ve,v as fe,z as Xe,q as ye,i as et,w as tt,x as at,y as nt,A as st,C as lt,B,M as ae}from"./index-lo-bz7f2.js";import{I as h}from"./vendor-icons-CDMuNDeL.js";import{A as rt}from"./AnimeCard-OKU7LaSN.js";import{S as it}from"./SkeletonGrid-Du10CNfq.js";import{E as ct}from"./ErrorMessage-z4f4WGgP.js";import{s as a}from"./Watchlist.module-XGtVQr1d.js";import"./useAnimeInfoData-CbNnHRj8.js";import"./QueueOptionsButton-DKWi-9kd.js";import"./vendor-ui-CUDCvRS_.js";import"./MediaCard-DszKDA4s.js";import"./useIsMobile-Dm_b6Ob3.js";const ot=(d,v)=>{const l=new URLSearchParams(v);return l.delete("page"),l.sort(),`${d}|${l.toString()}`},dt=(d,v)=>{const l=new Set(d);return v.forEach(A=>l.add(A)),l},mt=(d,v)=>{const l=new Set(d);return v.forEach(A=>l.delete(A)),l},Se=["All","Continue Watching","Watching","Completed","On-Hold","Dropped","Planned"],be=Se.slice(2),ut=[{value:"ALL",label:"All Types"},{value:"TV",label:"TV Series"},{value:"Movie",label:"Movie"},{value:"OVA",label:"OVA"},{value:"ONA",label:"ONA"},{value:"TV_SHORT",label:"TV Short"},{value:"SPECIAL",label:"Special"},{value:"ADULT",label:"Adult (18+)"}],ht=[{value:"ALL",label:"All Seasons"},{value:"WINTER",label:"Winter"},{value:"SPRING",label:"Spring"},{value:"SUMMER",label:"Summer"},{value:"FALL",label:"Fall"}],xt=()=>{he(()=>{document.title="Watchlist - dango"},[]);const{filter:d="All"}=je(),v=qe(),[l,A]=Ke(),ne=Qe(),[m,R]=u(parseInt(l.get("page")||"1")),[f,T]=u(l.get("query")||""),[C,q]=u(l.get("sortBy")||"last_added"),[y,P]=u(l.get("type")||"ALL"),[b,W]=u(l.get("season")||"ALL"),[S,I]=u(l.get("year")||"ALL"),[k,$]=u(()=>{const e={},n=l.get("genres")?.split(",").map(r=>r.trim()).filter(Boolean)||[],s=l.get("excludeGenres")?.split(",").map(r=>r.trim()).filter(Boolean)||[];return n.forEach(r=>r&&(e[r]="include")),s.forEach(r=>r&&(e[r]="exclude")),e}),[O,Ne]=u(()=>["type","season","year","genres","excludeGenres"].some(e=>l.has(e))),{lowEndMode:Le}=He(),{titlePreference:F}=Je(),{data:Ae}=Ze(),se=Ae?.genres||[],K=pe(null),[c,w]=u(null),[V,z]=u(!1),[le,D]=u(!1),[M,Ce]=u(!1),[g,N]=u(new Set),Q=pe(null),i=d==="Continue Watching",E=j(()=>{const e=new URLSearchParams(l);return e.delete("page"),e.set("titlePreference",F),e.toString()},[l,F]),{data:G,isLoading:ke,error:we}=ve(E,m,14),{data:_,isLoading:xe,error:Be}=fe(d,E,m,14),{data:Re}=ve(E,m+1,14),{data:Te}=fe(d,E,m+1,14),H=j(()=>(i?G?.data:_?.data)||[],[i,G,_]),J=j(()=>(i?G?.total:_?.total)||0,[i,G,_]),x=i?ke:xe,re=i?we:Be,ie=i?Re:Te;he(()=>{T(l.get("query")||""),q(l.get("sortBy")||"last_added"),P(l.get("type")||"ALL"),W(l.get("season")||"ALL"),I(l.get("year")||"ALL");const e={},n=l.get("genres")?.split(",").map(o=>o.trim()).filter(Boolean)||[],s=l.get("excludeGenres")?.split(",").map(o=>o.trim()).filter(Boolean)||[];n.forEach(o=>o&&(e[o]="include")),s.forEach(o=>o&&(e[o]="exclude")),$(e),R(parseInt(l.get("page")||"1"));const r=ot(d,l);Q.current!==null&&Q.current!==r&&N(new Set),Q.current=r},[l,d]);const Pe=ge({mutationFn:async({id:e,status:n})=>{await ye("/api/watchlist/status",{method:"POST",body:JSON.stringify({id:e,status:n})})},onSuccess:()=>{ne.invalidateQueries({queryKey:["watchlist"]}),Xe.success("Status updated")}}),We=ge({mutationFn:async e=>{await ye("/api/continue-watching/remove",{method:"POST",body:JSON.stringify({showId:e})})},onSuccess:()=>ne.invalidateQueries({queryKey:["allContinueWatching"]})}),Z=et(),{data:ce}=tt("skipRemoveConfirmation"),Ie=at(),X=j(()=>{const e=n=>n[F]||n.name||"";return[...H].sort((n,s)=>C==="name_asc"?e(n).localeCompare(e(s)):C==="name_desc"?e(s).localeCompare(e(n)):0)},[H,C,F]),ee=new Date().getFullYear(),$e=[{value:"ALL",label:"All Years"},...Array.from({length:ee-1980+1},(e,n)=>({value:String(ee-n),label:String(ee-n)}))],p=(e=C,n=1)=>{const s=new URLSearchParams;f.trim()&&s.set("query",f.trim()),e!=="last_added"&&s.set("sortBy",e),y!=="ALL"&&s.set("type",y),b!=="ALL"&&s.set("season",b),S!=="ALL"&&s.set("year",S);const r=Object.entries(k).filter(([,L])=>L==="include").map(([L])=>L),o=Object.entries(k).filter(([,L])=>L==="exclude").map(([L])=>L);r.length>0&&s.set("genres",r.join(",")),o.length>0&&s.set("excludeGenres",o.join(",")),n>1&&s.set("page",n.toString()),A(s),n!==m&&R(n)},U=e=>{if(p(C,e),K.current){const n=K.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:n,behavior:"smooth"})}},Oe=()=>{T(""),q("last_added"),P("ALL"),W("ALL"),I("ALL"),$({}),A(new URLSearchParams),R(1)},Fe=e=>{$(n=>{const s=n[e],r={...n};return s==="include"?r[e]="exclude":s==="exclude"?delete r[e]:r[e]="include",r})},oe=(e,n)=>{if(i){w({id:e,name:n});return}String(ce)==="true"||String(ce)==="1"?Z.mutate(e):w({id:e,name:n})},ze=()=>{if(c){if(c.ids){i?(De.mutate(c.ids),V&&me.mutate(c.ids)):me.mutate(c.ids),N(new Set),w(null),z(!1),D(!1);return}i?(We.mutate(c.id),V&&Z.mutate(c.id)):Z.mutate(c.id),le&&Ie.mutate({key:"skipRemoveConfirmation",value:!0}),w(null),z(!1),D(!1)}},de=()=>{w(null),z(!1),D(!1)},me=nt(),De=st(),Me=lt(),Ee=()=>{Ce(e=>{const n=!e;return n||N(new Set),n})},Ge=e=>{N(n=>{const s=new Set(n);return s.has(e)?s.delete(e):s.add(e),s})},Y=X.map(e=>e.id),te=Y.length>0&&Y.every(e=>g.has(e)),_e=()=>{N(te?e=>mt(e,Y):e=>dt(e,Y))},Ue=e=>{g.size!==0&&(Me.mutate({ids:[...g],status:e}),N(new Set))},Ye=()=>{g.size!==0&&w({ids:[...g]})},ue=H.length>=14&&ie&&ie.data.length>0;return t("div",{className:"page-container",children:[t("header",{className:a.header,children:[t("h2",{className:a.title,children:"My Watchlist"}),t("p",{className:a.subtitle,children:"Track and manage your anime collection"})]}),t("div",{className:a.controls,children:[t("div",{className:a.filters,children:Se.map(e=>t("button",{className:`${a.filterBtn} ${d===e?a.active:""}`,onClick:()=>{const n=new URLSearchParams(l);n.delete("page"),v({pathname:`/watchlist/${e}`,search:n.toString()}),R(1)},children:e},e))}),t("div",{children:t("select",{className:a.sortSelect,value:C,onChange:e=>{const n=e.currentTarget.value;q(n),p(n,m)},children:[t("option",{value:"last_added",children:"Recently Added"}),t("option",{value:"name_asc",children:"Name (A-Z)"}),t("option",{value:"name_desc",children:"Name (Z-A)"})]})})]}),t("div",{className:a.filterContainer,children:[t("div",{className:a.searchBarWrapper,children:[t("div",{className:a.inputIconWrapper,children:[t(h,{name:"search",className:a.searchIcon}),t("input",{className:a.searchInput,placeholder:"Search your watchlist by title...",value:f,onInput:e=>T(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&p()})]}),t("div",{className:a.searchActions,children:[t(B,{onClick:()=>p(),className:a.searchBtn,children:"Search"}),t("button",{className:`${a.filterToggleBtn} ${O?a.active:""}`,onClick:()=>Ne(!O),children:[t(h,{name:"filter",size:14}),t("span",{children:"Filters"}),O?t(h,{name:"chevron-up",size:12}):t(h,{name:"chevron-down",size:12})]})]})]}),t("div",{className:`${a.advancedFilters} ${O?a.show:""}`,children:[t("div",{className:a.filterDivider}),t("div",{className:a.filterGrid,children:[t("div",{className:a.filterItem,children:[t("label",{children:"Type"}),t("select",{value:y,onChange:e=>P(e.currentTarget.value),children:ut.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Season"}),t("select",{value:b,onChange:e=>W(e.currentTarget.value),children:ht.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Year"}),t("select",{value:S,onChange:e=>I(e.currentTarget.value),children:$e.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),se.length>0&&t("div",{className:a.genreSection,children:[t("label",{className:a.genreLabel,children:"Genres"}),t("div",{className:a.genreContainer,children:se.map(e=>t("button",{className:`${a.genreButton} ${a[k[e]||""]}`,onClick:()=>Fe(e),children:e},e))})]}),t("div",{className:a.filterActions,children:[t(B,{variant:"secondary",onClick:Oe,children:"Reset All"}),t(B,{onClick:()=>p(),className:a.applyBtn,children:"Apply Filters"})]})]})]}),t("div",{className:a.resultsHeader,ref:K,children:[t("h3",{className:a.resultsTitle,children:[i?"Continue Watching":d,t("span",{className:a.itemCount,children:["(",J," items)"]})]}),t("div",{className:a.headerActions,children:[t("button",{className:`${a.manageBtn} ${M?a.active:""}`,onClick:Ee,children:[t(h,{name:"pencil-alt",size:13}),t("span",{children:"Bulk Manage"})]}),J>0&&t("div",{className:a.pagination,children:[t("button",{className:a.pageBtn,onClick:()=>U(m-1),disabled:m===1||x,"aria-label":"Previous page",children:t(h,{name:"chevron-left",size:14})}),t("span",{className:a.pageInfo,children:["Page ",t("strong",{children:m})]}),t("button",{className:a.pageBtn,onClick:()=>U(m+1),disabled:!ue||x,"aria-label":"Next page",children:t(h,{name:"chevron-right",size:14})})]})]})]}),M&&t("div",{className:a.manageBar,children:[t("button",{className:a.selectAllBtn,onClick:_e,children:[t("span",{className:`${a.selectAllBox} ${te?a.selectAllBoxChecked:""}`,"aria-hidden":"true"}),t("span",{children:te?"Clear Page":"Select All"})]}),t("span",{className:a.manageCount,children:[g.size," selected"]}),t("div",{className:a.manageSpacer}),!i&&t("select",{className:a.manageStatusSelect,value:"",onChange:e=>{e.currentTarget.value&&Ue(e.currentTarget.value)},disabled:g.size===0,title:"Set status for selected items",children:[t("option",{value:"",children:"Set status…"}),be.map(e=>t("option",{value:e,children:e},e))]}),t("button",{className:a.manageRemoveBtn,onClick:Ye,disabled:g.size===0,children:[t(h,{name:"trash",size:13}),t("span",{children:"Remove Selected"})]})]}),x?t(it,{}):re?t(ct,{message:re.message}):t(Ve,{children:[(y!=="ALL"||b!=="ALL"||S!=="ALL"||Object.keys(k).length>0||f.trim())&&t("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",marginBottom:"1.5rem"},children:[t("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontWeight:600},children:"Active Filters:"}),f.trim()&&t("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Search: ",f,t("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),T(""),p()},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),y!=="ALL"&&t("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Type: ",y,t("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),P("ALL"),p()},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),b!=="ALL"&&t("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Season: ",b,t("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),W("ALL"),p()},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),S!=="ALL"&&t("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Year: ",S,t("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),I("ALL"),p()},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),Object.entries(k).map(([e,n])=>t("span",{className:`badge ${n==="include"?"badge-primary":"badge-danger"}`,style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[n==="include"?`+ ${e}`:`- ${e}`,t("button",{onClick:s=>{s.stopPropagation(),s.preventDefault(),$(r=>{const o={...r};return delete o[e],o}),p()},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]},e))]}),t("div",{className:`${a.grid} ${Le?a.lowEnd:""}`,children:X.map(e=>{const n=g.has(e.id);return t("div",{className:`${a.itemWrapper} ${n?a.selected:""}`,children:[M&&t("div",{className:a.selectOverlay,onClick:()=>Ge(e.id),title:n?"Deselect":"Select",children:t("span",{className:a.selectBadge,children:n?t(h,{name:"check",size:12}):null})}),t(rt,{anime:e,continueWatching:i,onRemove:()=>oe(e.id,e.name),layout:"vertical"}),!i&&!M&&t("div",{className:a.cardActions,children:[t("select",{className:a.statusSelect,value:e.status,onChange:s=>Pe.mutate({id:e.id,status:s.currentTarget.value}),children:be.map(s=>t("option",{value:s,children:s},s))}),t("button",{className:a.removeBtn,onClick:()=>oe(e.id,e.name),title:"Remove from Watchlist","aria-label":"Remove from Watchlist",children:t(h,{name:"trash",size:12})})]})]},e._id)})})]}),!x&&X.length===0&&t("div",{className:a.emptyState,children:[t("h3",{className:a.emptyTitle,children:"Your watchlist is looking a bit lonely"}),t("p",{className:a.emptyText,children:d!=="All"||f||y!=="ALL"||b!=="ALL"||S!=="ALL"||Object.keys(k).length>0?"No anime match these filters. Try adjusting them to see more titles.":"Let's find something to watch!"}),t("button",{className:a.emptyBtn,onClick:()=>v("/search"),children:[t(h,{name:"search",size:14}),t("span",{children:"Browse Anime"})]})]}),J>0&&t("div",{className:a.bottomPagination,children:t("div",{className:a.pagination,children:[t("button",{className:a.pageBtn,onClick:()=>U(m-1),disabled:m===1||x,children:[t(h,{name:"chevron-left",size:14}),t("span",{children:"Previous"})]}),t("span",{className:a.pageInfo,children:["Page ",t("strong",{children:m})]}),t("button",{className:a.pageBtn,onClick:()=>U(m+1),disabled:!ue||x,children:[t("span",{children:"Next"}),t(h,{name:"chevron-right",size:14})]})]})}),t(ae,{isOpen:!!c,onClose:de,title:i?"Reset Progress":"Remove from Watchlist",children:[t(ae.Body,{children:[t("p",{children:c?.ids&&c.ids.length>1?i?`Are you sure you want to remove watch progress for ${c.ids.length} items?`:`Are you sure you want to remove ${c.ids.length} items from your watchlist?`:i?`Are you sure you want to remove your watch progress for "${c?.name}"?`:`Are you sure you want to remove "${c?.name}" from your watchlist?`}),i&&t("label",{children:[t("input",{type:"checkbox",checked:V,onChange:e=>z(e.target.checked)}),"Also remove from my watchlist"]}),!i&&!(c?.ids&&c.ids.length>1)&&t("label",{children:[t("input",{type:"checkbox",checked:le,onChange:e=>D(e.target.checked)}),"Remember my choice"]})]}),t(ae.Actions,{children:[t(B,{variant:"secondary",onClick:de,children:"No"}),t(B,{variant:"danger",onClick:ze,children:"Yes"})]})]})]})};export{xt as default};