@serifpersia/dango 4.0.5 → 4.0.7

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 (87) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/AnimeCard-CcvD-9Bi.js +1 -0
  3. package/client/dist/assets/AnimeInfo-t3qfap0B.js +1 -0
  4. package/client/dist/assets/AnimeInfoPage-D3vtcWL7.js +2 -0
  5. package/client/dist/assets/Asmr-GHxClLoM.js +2 -0
  6. package/client/dist/assets/AsmrPopup-Bt7wZkV8.js +1 -0
  7. package/client/dist/assets/{AsmrResetProgressModal-cCyCqM0y.js → AsmrResetProgressModal-Di6VgAZx.js} +1 -1
  8. package/client/dist/assets/Home-C9caLBqU.js +1 -0
  9. package/client/dist/assets/{Insights-BEpf49rM.js → Insights-B-jf5_UY.js} +1 -1
  10. package/client/dist/assets/{LibraryListPage-BUkJ9MFn.js → LibraryListPage-B5q00Vno.js} +1 -1
  11. package/client/dist/assets/ListeningList-BNUrMPyA.js +1 -0
  12. package/client/dist/assets/Manga-SYhXSYV_.js +1 -0
  13. package/client/dist/assets/{MangaInfoPage-C6xCfHOM.js → MangaInfoPage-CsGcpQ4g.js} +1 -1
  14. package/client/dist/assets/{MangaReadPage-BjqdvaOh.js → MangaReadPage-B0BKdQeU.js} +1 -1
  15. package/client/dist/assets/{MangaResetProgressModal-BFAJChnc.js → MangaResetProgressModal-8Q_Jp8Tk.js} +1 -1
  16. package/client/dist/assets/Mature-B_0sseRY.css +1 -0
  17. package/client/dist/assets/Mature-DtyWIW42.js +1 -0
  18. package/client/dist/assets/{MatureConsentModal-DNd8p-k1.js → MatureConsentModal-DoPl5ONK.js} +1 -1
  19. package/client/dist/assets/MediaCard-Ce90T0yC.js +1 -0
  20. package/client/dist/assets/MediaCard-DsoEaANc.css +1 -0
  21. package/client/dist/assets/OptionListMenu-CHqo2pTO.js +1 -0
  22. package/client/dist/assets/Player-CYrY9dNs.js +56 -0
  23. package/client/dist/assets/PlayerControls.module-D5c6Q5Ln.js +1 -0
  24. package/client/dist/assets/PlayerProvider-CjctET1A.js +1 -0
  25. package/client/dist/assets/PlayerSettings-uDMPYAlP.js +1 -0
  26. package/client/dist/assets/PlayerSurface-B_rgFBYD.js +1 -0
  27. package/client/dist/assets/PlayerSurface-LthWKdFi.css +1 -0
  28. package/client/dist/assets/{QueueOptionsButton-CRl4Dhom.js → QueueOptionsButton-BHkP1DB_.js} +1 -1
  29. package/client/dist/assets/{QueueRail-J8ert-Ey.js → QueueRail-CxtCW4xn.js} +1 -1
  30. package/client/dist/assets/{ReadingList-JpAZ_9Mj.js → ReadingList-C0hu5BhB.js} +1 -1
  31. package/client/dist/assets/{ResetProgressModal-CU2ithpX.js → ResetProgressModal-CncQLVw1.js} +1 -1
  32. package/client/dist/assets/Search-DM1vfczV.css +1 -0
  33. package/client/dist/assets/{Search-D-DnJTst.js → Search-J3jIU8gd.js} +1 -1
  34. package/client/dist/assets/Search.module-DjQZ0jox.js +1 -0
  35. package/client/dist/assets/Settings-B8jClutS.js +21 -0
  36. package/client/dist/assets/SettingsShell-ByVlsU3X.js +1 -0
  37. package/client/dist/assets/{SkeletonGrid-B3sPNp5O.js → SkeletonGrid-zCAxRZIz.js} +1 -1
  38. package/client/dist/assets/{Trackers-CUlPOXTN.js → Trackers-DTlCK6Gw.js} +2 -2
  39. package/client/dist/assets/{Tv-DPBpdr3A.js → Tv-CnahgiVt.js} +4 -4
  40. package/client/dist/assets/{TvInfo-zdAQ3Wup.js → TvInfo-Co-CnIbQ.js} +1 -1
  41. package/client/dist/assets/TvPopup-Ci4SXMWf.js +1 -0
  42. package/client/dist/assets/{TvSearch-BuNWu2c4.js → TvSearch-dkkP831q.js} +1 -1
  43. package/client/dist/assets/{TvWatchlist-BpCDLs_Z.js → TvWatchlist-CTxHqUB9.js} +1 -1
  44. package/client/dist/assets/{VirtualKeyboard-RZ5whICJ.js → VirtualKeyboard-ClY9H0vl.js} +1 -1
  45. package/client/dist/assets/{WatchAlong-BQEEQ8qq.js → WatchAlong-RAJe62YS.js} +1 -1
  46. package/client/dist/assets/{WatchAlongPanel-COrLE1p0.js → WatchAlongPanel-G2j2eopw.js} +1 -1
  47. package/client/dist/assets/{Watchlist-McU_iHmN.js → Watchlist-D8prt4l1.js} +1 -1
  48. package/client/dist/assets/index-BOJFs4B4.js +180 -0
  49. package/client/dist/assets/{index-BBbcJwUD.css → index-BpCEsLT2.css} +1 -1
  50. package/client/dist/assets/{libraryInvalidation-Ch1g3QJS.js → libraryInvalidation-1xwHWgGv.js} +1 -1
  51. package/client/dist/assets/{playbackCompletion-B_Zin5ZR.js → playbackCompletion-BpEGpC-Z.js} +1 -1
  52. package/client/dist/assets/{useAnimeInfoData-BJmkWDD2.js → useAnimeInfoData-CvV6vRjn.js} +1 -1
  53. package/client/dist/assets/{useMangaLibrary-BMPk0isK.js → useMangaLibrary-OgS0RRdO.js} +1 -1
  54. package/client/dist/assets/{useMangaPopup-Dp5HcQJ-.js → useMangaPopup-Eyed-Gg3.js} +1 -1
  55. package/client/dist/assets/{useTv-zmGPcjV-.js → useTv-SLXsIWFQ.js} +1 -1
  56. package/client/dist/assets/{useTvLibrary-DV4KK5BN.js → useTvLibrary-F0S6WnwD.js} +1 -1
  57. package/client/dist/assets/{useWatchAlongPlayer-Dk7zB7P4.css → useWatchAlongPlayer-BsaopdPw.css} +1 -1
  58. package/client/dist/assets/useWatchAlongPlayer-D-fPdbp2.js +10 -0
  59. package/client/dist/index.html +2 -2
  60. package/orchestrator.js +1 -1
  61. package/package.json +2 -2
  62. package/server/dist/server.js +169 -169
  63. package/server/package.json +1 -1
  64. package/client/dist/assets/AnimeCard-Dejl41Y9.js +0 -1
  65. package/client/dist/assets/AnimeInfo-Knd2smb5.js +0 -1
  66. package/client/dist/assets/AnimeInfoPage-CJ-sJXzb.js +0 -2
  67. package/client/dist/assets/Asmr-D2BKNSNd.js +0 -2
  68. package/client/dist/assets/AsmrPopup-gLM0JlGP.js +0 -1
  69. package/client/dist/assets/Home-CsMgWycR.js +0 -1
  70. package/client/dist/assets/ListeningList-H-WkS0VL.js +0 -1
  71. package/client/dist/assets/Manga-6FX-ny6n.js +0 -1
  72. package/client/dist/assets/Mature-Bwpv7C--.js +0 -1
  73. package/client/dist/assets/Mature-DJmUUtlF.css +0 -1
  74. package/client/dist/assets/MediaCard-Bffh2g9C.js +0 -1
  75. package/client/dist/assets/MediaCard-Co-j57uA.css +0 -1
  76. package/client/dist/assets/OptionListMenu-NiWeAIHX.js +0 -1
  77. package/client/dist/assets/Player-NNpxqQwi.js +0 -56
  78. package/client/dist/assets/PlayerProvider-NhvkxBzK.js +0 -1
  79. package/client/dist/assets/PlayerSettings-Dw7NDCnm.js +0 -1
  80. package/client/dist/assets/Search-DCKK3seW.css +0 -1
  81. package/client/dist/assets/Search.module-C_qwCdHS.js +0 -1
  82. package/client/dist/assets/Settings-F4CGjK1n.js +0 -21
  83. package/client/dist/assets/TvPopup-BQPSFeCs.js +0 -1
  84. package/client/dist/assets/index-BkgRRmBf.js +0 -179
  85. package/client/dist/assets/useProviders-Byo6s6Ss.js +0 -1
  86. package/client/dist/assets/useWatchAlongPlayer-B4f1qXt_.js +0 -10
  87. /package/client/dist/assets/{Player-1LfYnRyR.css → PlayerControls-1LfYnRyR.css} +0 -0
@@ -1,56 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-Dw7NDCnm.js","assets/vendor-core-DfaOB3Rn.js","assets/index-BkgRRmBf.js","assets/vendor-query-BBT5_sHx.js","assets/vendor-icons-C1Pj_eSX.js","assets/index-BBbcJwUD.css","assets/OptionListMenu-NiWeAIHX.js","assets/useWatchAlongPlayer-B4f1qXt_.js","assets/PlayerProvider-NhvkxBzK.js","assets/PlayerProvider-ZeplRma-.css","assets/playbackCompletion-B_Zin5ZR.js","assets/useWatchAlongPlayer-Dk7zB7P4.css","assets/PlayerSettings-CbGkvNJq.css"])))=>i.map(i=>d[i]);
2
- import{u as t,g as St,h as U,P as Nr,z as _r,d as ne,A as N,q as K,y as Ar,T as Ae,o as xr,a as Lr,c as $r,_ as Br,S as at}from"./vendor-core-DfaOB3Rn.js";import{p as te,a3 as zt,a4 as lt,o as Dr,q as ae,t as ue,K as ke,a5 as Ir,a6 as et,R as wt,a7 as Fr,e as Or,x as Wr,y as Ur,z as Qr,A as Vr,d as Kr,u as qr,B as Ne,h as Qt,a8 as Gr,F as zr,f as Hr}from"./index-BkgRRmBf.js";import{P as jr,a as Yr,b as Xr,F as Jr,s as Zr,c as en}from"./PlayerProvider-NhvkxBzK.js";import{u as Ht,b as Vt,a as bt}from"./vendor-query-BBT5_sHx.js";import{p as _t,s as tn,C as rn,a as nn,P as sn,b as Ye,c as Kt,f as jt,d as on,e as an,g as ln,r as cn,u as un,h as dn,i as mn,j as pn,k as hn,l as fn,m as vn,n as gn,o as _e,A as yn,q as qt,R as bn,E as Sn,t as wn,v as b,w as En,x as kn,y as Tn}from"./useWatchAlongPlayer-B4f1qXt_.js";import{I as ye}from"./vendor-icons-C1Pj_eSX.js";import{a as Cn,i as ut,b as Yt,l as Rn,c as Mn}from"./playbackCompletion-B_Zin5ZR.js";import{M as Pn}from"./MatureConsentModal-DNd8p-k1.js";import{u as Nn}from"./useIsMobile-Dvx1uJ82.js";import{s as Le,Q as _n}from"./QueueRail-J8ert-Ey.js";import{u as An,Q as xn}from"./QueueOptionsButton-CRl4Dhom.js";import{u as Xt}from"./useProviders-Byo6s6Ss.js";import{A as Ln}from"./AnimeMetaDetails-B3-A7O5H.js";import{S as $n}from"./SynopsisText-B3Sa5pRv.js";import{W as Bn}from"./WatchAlongPanel-COrLE1p0.js";import"./vendor-ui-3qrARCPr.js";const Dn="_controlsOverlay_6uapd_1",In="_hidden_6uapd_21",Fn="_topControls_6uapd_27",On="_backBtn_6uapd_47",Wn="_videoTitleInfo_6uapd_67",Un="_animeTitle_6uapd_73",Qn="_episodeNumber_6uapd_83",Vn="_bottomControls_6uapd_91",Kn="_progressBarContainer_6uapd_110",qn="_progressBar_6uapd_110",Gn="_thumb_6uapd_129",zn="_scrubbing_6uapd_144",Hn="_watchedBar_6uapd_148",jn="_bufferedBar_6uapd_149",Yn="_timeBubble_6uapd_191",Xn="_skipSegment_6uapd_225",Jn="_op_6uapd_235",Zn="_mixed_op_6uapd_236",es="_ed_6uapd_240",ts="_mixed_ed_6uapd_241",rs="_recap_6uapd_245",ns="_mixed_recap_6uapd_246",ss="_bottomControlsRow_6uapd_250",os="_leftControls_6uapd_258",is="_rightControls_6uapd_259",as="_controlBtn_6uapd_266",ls="_theaterBtn_6uapd_307",cs="_nextEpisodeBtn_6uapd_311",us="_active_6uapd_332",ds="_timeDisplay_6uapd_336",ms="_skipControls_6uapd_344",B={controlsOverlay:Dn,hidden:In,topControls:Fn,backBtn:On,videoTitleInfo:Wn,animeTitle:Un,episodeNumber:Qn,bottomControls:Vn,progressBarContainer:Kn,progressBar:qn,thumb:Gn,scrubbing:zn,watchedBar:Hn,bufferedBar:jn,timeBubble:Yn,skipSegment:Xn,op:Jn,mixed_op:Zn,ed:es,mixed_ed:ts,recap:rs,mixed_recap:ns,bottomControlsRow:ss,leftControls:os,rightControls:is,controlBtn:as,theaterBtn:ls,nextEpisodeBtn:cs,active:us,timeDisplay:ds,skipControls:ms},ps=({player:r,handlers:o,visible:c,skipIntervals:d,showNextEpisodeButton:C,onNextEpisode:i,isTheaterMode:s,onTheaterModeToggle:n,settingsBtnRef:a,timeDisplayRef:g})=>{const{state:p,actions:v}=r,{showSettings:S}=p;return t("div",{className:`${B.controlsOverlay} ${c?"":B.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:B.bottomControls,"data-speed-boost-ignore":"true",onClick:E=>E.stopPropagation(),children:[t(jr,{classes:{container:B.progressBarContainer,scrubbing:B.scrubbing,timeBubble:B.timeBubble,bar:B.progressBar,buffered:B.bufferedBar,watched:B.watchedBar,thumb:B.thumb},timeLabelRef:g,children:[p.duration>0&&r.state.currentSkipInterval&&t("div",{className:`${B.skipSegment} ${B[r.state.currentSkipInterval.skip_type]} `,style:{left:`${r.state.currentSkipInterval.start_time/p.duration*100}% `,width:`${(r.state.currentSkipInterval.end_time-r.state.currentSkipInterval.start_time)/p.duration*100}% `}}),d.map(E=>{const e=E.start_time/p.duration*100,w=(E.end_time-E.start_time)/p.duration*100;return t("div",{className:`${B.skipSegment} ${B[E.skip_type]} `,style:{left:`${e}% `,width:`${w}% `},title:E.skip_type.toUpperCase()},E.skip_id)})]}),t("div",{className:B.bottomControlsRow,children:[t("div",{className:B.leftControls,children:[t(Yr,{className:B.controlBtn}),t(Xr,{buttonClassName:B.controlBtn,onExpandedChange:v.setShowVolumeSlider}),t("span",{className:B.timeDisplay,ref:g,children:[v.formatTime(0)," / ",v.formatTime(p.duration)]}),p.currentSkipInterval&&!p.isAutoSkipEnabled&&!p.playbackLocked&&t("button",{className:B.controlBtn,onClick:()=>{p.currentSkipInterval&&(r.engine.seek(p.currentSkipInterval.end_time),v.setCurrentSkipInterval(null))},children:["Skip ",p.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),t("div",{className:B.rightControls,children:[t("div",{className:B.skipControls,children:C&&t("button",{className:B.nextEpisodeBtn,onClick:i,title:"Play next episode",children:"Next EP"})}),t("button",{className:`${B.controlBtn} ${o.isSubtitleActive?B.active:""}`,onClick:o.handleCCToggle,title:o.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:t(ye,{name:"closed-captioning",size:22})}),t("button",{ref:a,className:`${B.controlBtn} ${S?B.active:""} `,onClick:()=>v.setShowSettings(!S),"aria-label":"Settings",children:t(ye,{name:"cog"})}),t("button",{className:`${B.controlBtn} ${B.theaterBtn} ${s?B.active:""} `,onClick:E=>{E.stopPropagation(),n()},title:s?"Exit Theater Mode":"Theater Mode","aria-label":s?"Exit Theater Mode":"Theater Mode",children:t(ye,{name:"tv"})}),t(Jr,{className:B.controlBtn})]})]})]})})};function hs(r){const{state:o,refs:c,actions:d}=r,C=n=>{if(!c.videoRef.current)return;d.setActiveSubtitleTrack(n);try{if(n===null||n==="off")te.setItem("playerSubtitlesEnabled","false");else{te.setItem("playerSubtitlesEnabled","true");const g=o.availableSubtitles.find(p=>p.label===n||p.lang===n);g?te.setItem("playerLastSubtitle",tn(g)):te.setItem("playerLastSubtitle",n)}}catch{}let a=!1;Array.from(c.videoRef.current.textTracks).forEach(g=>{const v=n!==null&&n!=="off"&&(g.language===n||g.label===n)&&!a;g.mode=v?"showing":"hidden",v&&(a=!0)})},i=o.activeSubtitleTrack!==null&&o.activeSubtitleTrack!=="off";return{handleSubtitleSelection:C,isSubtitleActive:i,handleCCToggle:()=>{if(!c.videoRef.current)return;if(i){C("off");return}if(o.availableSubtitles.length===0)return;let n=null;try{n=te.getItem("playerLastSubtitle")}catch{}const a=_t(o.availableSubtitles,{lastKey:n,enabled:!0});if(a<0)return;const g=o.availableSubtitles[a];C(g.label||g.lang)}}}const fs=_r(()=>zt(()=>import("./PlayerSettings-Dw7NDCnm.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),vs=({player:r,isAutoplayEnabled:o,onAutoplayChange:c,showNextEpisodeButton:d,onNextEpisode:C,videoSources:i,selectedSource:s,selectedLink:n,onSourceChange:a,loadingVideo:g,skipIntervals:p,animeTitle:v,episodeNumber:S,mode:E,isTheaterMode:e,onTheaterModeToggle:w,anime4kEnabled:T,onAnime4kToggle:_,anime4kSupported:$,anime4kProfile:M,onAnime4kProfileChange:h,anime4kInitializing:P,anime4kError:y,videoDelayEnabled:R,onVideoDelayToggle:W,videoDelayMs:q,onVideoDelayChange:D,onCalibrateAvSync:I,fallbackChoice:G,onFallbackChoiceChange:ee,ambientSettings:m,onAmbientChange:f,children:A,overlays:Y,isInteractingExtra:x=!1,className:z,hideChrome:se=!1})=>{const{state:F,actions:we}=r,{showSettings:V}=F,{setShowSettings:H}=we,u=hs(r),k=St.useRef(null),O=St.useRef(null),j=St.useRef(null);U(()=>{const ve=Oe=>{k.current&&!k.current.contains(Oe.target)&&O.current&&!O.current.contains(Oe.target)&&V&&H(!1)};return V&&document.addEventListener("mousedown",ve),()=>{document.removeEventListener("mousedown",ve)}},[V,H]);const de=F.showControls||V||F.isScrubbing,L=F.activeSubtitleTrack!=="off"?F.availableSubtitles.find(ve=>ve.lang===F.activeSubtitleTrack||ve.label===F.activeSubtitleTrack):void 0,be=t(rn,{visible:de,title:v,episode:S?`Episode ${S}`:void 0,mode:E,server:g?void 0:s?.sourceName,subtitles:g?void 0:L?.label||L?.lang,onBack:()=>window.history.back(),classes:{overlay:B.controlsOverlay,hidden:B.hidden,top:B.topControls,backBtn:B.backBtn,titleInfo:B.videoTitleInfo,title:B.animeTitle,episode:B.episodeNumber}}),Ve=!g&&!F.isBuffering&&F.duration>0?t(nn,{}):null,X=t(ps,{player:r,handlers:u,visible:de,skipIntervals:p,showNextEpisodeButton:d,onNextEpisode:C,isTheaterMode:e,onTheaterModeToggle:w,settingsBtnRef:O,timeDisplayRef:j}),oe=t(Nr,{fallback:null,children:t(fs,{ref:k,isOpen:V,onClose:()=>H(!1),videoSources:i,currentSource:s,currentLink:n,onSourceChange:a,subtitles:F.availableSubtitles,activeSubtitleTrack:F.activeSubtitleTrack,onSubtitleChange:u.handleSubtitleSelection,subtitleSettings:{fontSize:F.subtitleFontSize,position:F.subtitlePosition,bgOpacity:F.subtitleBgOpacity,bgColor:F.subtitleBgColor,textColor:F.subtitleTextColor,edge:F.subtitleEdge,bold:F.subtitleBold},onSubtitleSettingsChange:we.setSubtitleStyle,useNativeControls:!F.playbackLocked&&F.useNativeControls,onNativeControlsToggle:we.setUseNativeControls,anime4kEnabled:T,onAnime4kToggle:_,anime4kSupported:$,anime4kProfile:M,onAnime4kProfileChange:h,anime4kInitializing:P,anime4kError:y,videoDelayEnabled:R,onVideoDelayToggle:W,videoDelayMs:q,onVideoDelayChange:D,onCalibrateAvSync:I,isAutoSkipEnabled:F.isAutoSkipEnabled,onAutoSkipChange:ve=>{we.setIsAutoSkipEnabled(ve);try{te.setItem("autoSkipEnabled",ve.toString())}catch{}},isAutoplayEnabled:o,onAutoplayChange:c,fallbackChoice:G,onFallbackChoiceChange:ee,isTheaterMode:e,ambientSettings:m,onAmbientChange:f})}),$e=V?t("div",{"data-speed-boost-ignore":"true",onClick:ve=>ve.stopPropagation(),children:oe}):null;return t(sn,{engine:r.engine,topBar:be,centerControls:Ve,bottomBar:!g&&F.duration>0?X:null,settingsPanel:$e,overlays:Y,isInteracting:x||F.showSettings||F.showVolumeSlider,nativeControls:!F.playbackLocked&&F.useNativeControls,className:z,chromeDisabled:se,children:A})},gs=({count:r=3})=>t("section",{className:Le.section,children:[t("div",{className:Le.header,children:t("button",{className:Le.headerToggle,disabled:!0,children:[t("span",{className:Le.title,children:t(lt,{width:"60px",height:"1.2rem",variant:"text"})}),t(ye,{name:"chevron-down",style:{opacity:.3}})]})}),t("div",{className:Le.list,children:Array.from({length:r}).map((o,c)=>t("div",{className:Le.item,style:{pointerEvents:"none"},children:[t("div",{className:Le.dragHandle,style:{opacity:.2},children:t(lt,{width:"16px",height:"16px",variant:"rectangular"})}),t("div",{className:Le.thumbnail,style:{overflow:"hidden",background:"transparent"},children:t(lt,{width:"100%",height:"100%",variant:"rectangular"})}),t("div",{className:Le.meta,children:[t(lt,{width:"80%",height:"1.2rem",variant:"text",className:Le.metaGap}),t(lt,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},c))})]}),ys={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},bs={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Ss=["direct","cookie","embed"],ws=({selectedProvider:r,onProviderChange:o,isAdult:c,options:d})=>{const i=(d&&d.length>0?d:[]).filter(s=>s.mature===(c===!0));return t("div",{className:Ye.providerSelectContainer,children:[t("h4",{children:"Provider"}),t("select",{className:Ye.providerSelect,value:r,onChange:s=>o(s.currentTarget.value),children:Ss.map(s=>{const n=i.filter(a=>(a.tier??"direct")===s);return n.length===0?null:t("optgroup",{label:bs[s],children:n.map(a=>t("option",{value:a.id,children:a.sub?`${a.label} (${ys[a.sub]})`:a.label},a.id))},s)})})]})},Es=({videoSources:r,selectedSource:o,selectedLink:c,onSourceChange:d,onLinkChange:C})=>{const i=Array.isArray(r)?r:[];if(i.length===0)return null;const s=o?.type==="iframe"&&(o.links?.length??0)>1;return t("div",{className:Ye.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:Ye.sourceButtons,children:i.map((n,a)=>t("button",{className:`${Ye.sourceButton} ${o?.sourceName===n.sourceName?Ye.active:""} `,onClick:()=>d(n),children:n.sourceName},`${n.sourceName}-${a}`))}),s&&t("select",{className:Ye.sourceSelect,"aria-label":"Fallback embed quality",value:c?.link??o.links[0]?.link??"",onChange:n=>{const a=o.links.find(g=>g.link===n.currentTarget.value);a&&C(a)},children:o.links.map(n=>t("option",{value:n.link,children:n.resolutionStr},n.link))})]})},ks=St.memo(Es,(r,o)=>r.selectedSource?.sourceName===o.selectedSource?.sourceName&&r.selectedLink?.link===o.selectedLink?.link&&r.videoSources===o.videoSources),Ts={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}},Cs={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Rs=5,Ms=15e3,Ps=`
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 Ns({videoRef:r,canvasRef:o,profile:c="balanced",delayMs:d=0}){const[C,i]=ne(!1),[s,n]=ne(()=>{try{return te.getItem("anime4kEnabled")==="true"}catch{return!1}}),[a,g]=ne(!1),[p,v]=ne(null),[S,E]=ne(0),e=N(0),w=N(null),T=N(null),_=N(null),$=N(null),M=N(null),h=N(null),P=N(null),y=N(null),R=N(null),W=N(!1),q=N(-1),D=N(0),I=N(d);I.current=d;const G=N([]),ee=N(!1),m=N(!1),f=N(!1),A=N(null),Y=N(-1),x=N(-1),z=N(!1),se=N(0);U(()=>{async function V(){if(typeof navigator>"u"||!navigator.gpu){i(!1);return}try{const H=await navigator.gpu.requestAdapter();i(!!H)}catch{i(!1)}}V()},[]),U(()=>{if(!s||!C)return;let V=!1;const H=++e.current,u=L=>{if(L)try{L.close()}catch{}},k=()=>{for(const L of G.current)u(L.bitmap);G.current=[]},O=L=>Math.max(8,Math.min(40,Math.ceil(L/16.7)+4));function j(){R.current!==null&&(cancelAnimationFrame(R.current),R.current=null)}async function de(){let L=r.current;const be=o.current;if(!L||!be||e.current!==H)return;const Ve=performance.now()+Ms;for(;(!L||L.videoWidth===0)&&performance.now()<Ve;){if(await new Promise(le=>requestAnimationFrame(le)),V||e.current!==H)return;L=r.current}if(!L||L.videoWidth===0){!V&&e.current===H&&(v("Timed out waiting for video metadata"),g(!1),n(!1));return}const X=L.videoWidth,oe=L.videoHeight,$e=Math.max(X,oe),ve=window.innerWidth,Oe=window.innerHeight,tt=Math.max(ve,Oe),rt=$e<tt?tt/$e:1,Ke=Ts[c],dt=$e<=480?Ke.sd:$e<=720?Ke.hd:$e<=1080?Ke.fhd:1,We=Math.min(dt,rt);be.width=Math.round(X*We),be.height=Math.round(oe*We),g(!0),v(null),D.current=0,q.current=-1,Y.current=-1,x.current=-1,z.current=!1,se.current=0,k(),W.current=!1;try{let le=function(){V||e.current!==H||(j(),R.current=requestAnimationFrame(()=>{Ct()}))};const{ModeA:mt,ModeB:Et,ModeC:kt,ModeAA:Xe}=await zt(async()=>{const{ModeA:J,ModeB:me,ModeC:Te,ModeAA:re}=await import("./index-BOKlZEHq.js").then(he=>he.i);return{ModeA:J,ModeB:me,ModeC:Te,ModeAA:re}},[]);if(V||e.current!==H)return;if(!navigator.gpu)throw new Error("WebGPU not available");const pt=await navigator.gpu.requestAdapter();if(V||e.current!==H)return;if(!pt)throw new Error("No GPU adapter found");const Q=await pt.requestDevice();if(!Q)throw new Error("Failed to get GPU device");if(V||e.current!==H){Q.destroy();return}w.current=Q;const Ue=be.getContext("webgpu");if(!Ue)throw new Error("Failed to get WebGPU context");T.current=Ue;const Be=navigator.gpu.getPreferredCanvasFormat();Ue.configure({device:Q,format:Be,alphaMode:"premultiplied"});const Se=Q.createTexture({size:[X,oe],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),ht=Cs[c],qe=Math.round(X*We),ie=Math.round(oe*We),De=(()=>{switch(ht){case"ModeB":return new Et({device:Q,inputTexture:Se,nativeDimensions:{width:X,height:oe},targetDimensions:{width:qe,height:ie}});case"ModeC":return new kt({device:Q,inputTexture:Se,nativeDimensions:{width:X,height:oe},targetDimensions:{width:qe,height:ie}});case"ModeAA":return new Xe({device:Q,inputTexture:Se,nativeDimensions:{width:X,height:oe},targetDimensions:{width:qe,height:ie}});default:return new mt({device:Q,inputTexture:Se,nativeDimensions:{width:X,height:oe},targetDimensions:{width:qe,height:ie}})}})(),nt=De.getOutputTexture(),Ge=Q.createSampler({magFilter:"linear",minFilter:"linear"}),st=Q.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
- `}),ze=Q.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),ot=Q.createRenderPipeline({layout:Q.createPipelineLayout({bindGroupLayouts:[ze]}),vertex:{module:st,entryPoint:"vs"},fragment:{module:st,entryPoint:"fs",targets:[{format:Be}]},primitive:{topology:"triangle-list"}}),Tt=Q.createBindGroup({layout:ze,entries:[{binding:0,resource:nt.createView()},{binding:1,resource:Ge}]});try{const J=Q.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),me=Q.createShaderModule({code:Ps}),Te=Q.createRenderPipeline({layout:Q.createPipelineLayout({bindGroupLayouts:[J]}),vertex:{module:me,entryPoint:"vs"},fragment:{module:me,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});A.current={pipeline:Te,layout:J,inputView:Se.createView()}}catch{A.current=null}_.current=De,$.current=Se,M.current=nt,h.current=ot,P.current=Ge,y.current=ze,m.current=!1,f.current=!1;async function He(){const J=A.current;if(!J||m.current)return!1;const me=r.current;if(!me)return!1;const Te=!f.current;Te&&Q.pushErrorScope("validation");try{const re=Q.importExternalTexture({source:me}),he=Q.createBindGroup({layout:J.layout,entries:[{binding:0,resource:re},{binding:1,resource:Ge}]}),Ee=Q.createCommandEncoder(),ce=Ee.beginRenderPass({colorAttachments:[{view:J.inputView,loadOp:"load",storeOp:"store"}]});ce.setPipeline(J.pipeline),ce.setBindGroup(0,he),ce.draw(6),ce.end(),Q.queue.submit([Ee.finish()])}catch{return m.current=!0,A.current=null,!1}if(Te){const re=await Q.popErrorScope().catch(()=>null);if(re)return console.warn("[anime4k] blit probe failed:",re.message),m.current=!0,A.current=null,!1;f.current=!0}return!0}g(!1);async function Ct(){if(V||e.current!==H||!Ue)return;const J=r.current;if(!J||J.videoWidth===0){le();return}if(J!==L||J.videoWidth!==X||J.videoHeight!==oe){E(he=>he+1);return}if(J.paused||J.ended||document.hidden||J.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){le();return}const me=J.getVideoPlaybackQuality().totalVideoFrames;if(me===x.current){le();return}if(W.current){le();return}const Te=J.currentTime;(J.seeking||Y.current>=0&&Math.abs(Te-Y.current)>.5)&&(k(),z.current=!1,se.current=0,x.current=-1),Y.current=Te;const re=Math.max(0,I.current||0);re>se.current&&(z.current=!1),W.current=!0;try{const he=performance.now();let Ee=null,ce=!1;if(re<=0){G.current.length>0&&k(),z.current=!1,se.current=0;let Ce=!1;if(!ee.current)try{Q.queue.copyExternalImageToTexture({source:J},{texture:Se},[X,oe]),x.current=me,Ce=!0}catch(pe){if(pe instanceof TypeError)ee.current=!0;else throw pe}if(!Ce&&!m.current&&A.current&&await He()&&(x.current=me,Ce=!0),!Ce){const pe=await createImageBitmap(J);x.current=me,Q.queue.copyExternalImageToTexture({source:pe},{texture:Se},[X,oe]),u(pe)}}else{const Ce=await createImageBitmap(J);x.current=me;const pe=G.current;pe.push({bitmap:Ce,capture:he});const Ie=O(re);for(;pe.length>Ie;)u(pe.shift()?.bitmap);let Ze=-1;for(let fe=pe.length-1;fe>=0;fe--)if(he-pe[fe].capture>=re){Ze=fe;break}if(Ze!==-1){for(let it=0;it<Ze;it++)u(pe.shift()?.bitmap);const fe=pe.shift();fe?(Ee=fe.bitmap,z.current=!0,se.current=re):(Ee=Ce,ce=!0)}else if(!z.current)Ee=Ce,ce=!0;else{const fe=pe.shift();Ee=fe?fe.bitmap:Ce,fe||(ce=!0)}if(!Ee){W.current=!1,le();return}Q.queue.copyExternalImageToTexture({source:Ee},{texture:Se},[X,oe]),ce||u(Ee)}const Je=Q.createCommandEncoder();await De.pass(Je);const ge=Je.beginRenderPass({colorAttachments:[{view:Ue.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});ge.setPipeline(ot),ge.setBindGroup(0,Tt),ge.draw(6),ge.end(),Q.queue.submit([Je.finish()]),q.current=me,D.current=0,Q.queue.onSubmittedWorkDone().then(()=>{e.current===H&&(W.current=!1)})}catch(he){if(W.current=!1,D.current+=1,D.current>=Rs&&!V&&e.current===H){console.error(he),v(he instanceof Error?he.message:"Render error"),n(!1);return}}le()}le()}catch(le){!V&&e.current===H&&(T.current?.unconfigure(),w.current?.destroy(),w.current=null,T.current=null,v(le instanceof Error?le.message:"Failed to initialize upscaler"),g(!1),n(!1))}}return de(),()=>{V=!0,e.current+=1,j(),k(),T.current?.unconfigure(),$.current&&($.current.destroy(),$.current=null),M.current&&(M.current.destroy(),M.current=null),w.current&&(w.current.destroy(),w.current=null),_.current=null,h.current=null,P.current=null,y.current=null,A.current=null,T.current=null,W.current=!1}},[s,C,r,o,c,S]);const F=K(V=>{n(V);try{te.setItem("anime4kEnabled",String(V))}catch{}},[]),we=K(()=>{n(V=>{const H=!V;try{te.setItem("anime4kEnabled",String(H))}catch{}return H})},[]);return{isWebGPUSupported:C,isEnabled:s,isInitializing:a,error:p,toggle:we,setEnabled:F}}function _s({videoRef:r,episodeKey:o,isEnabled:c,isSupported:d,mediaReady:C,isIframeSource:i,setEnabled:s}){const n=N(null),a=N(!1),g=N(!1),p=N(s);p.current=s,U(()=>{const v=n.current;n.current=o,!(v===null||v===o)&&(!c||!d||(a.current=!0,g.current=!1,p.current(!1)))},[o,c,d]),U(()=>{if(!a.current)return;if(c){g.current&&(a.current=!1);return}if(g.current=!0,!C)return;if(i){a.current=!1,p.current(!0);return}const v=r.current;if(!v)return;let S,E=!1;const e=()=>{E||(E=!0,a.current=!1,p.current(!0))};if(v.readyState>=2)return S=window.setTimeout(e,500),()=>window.clearTimeout(S);const w=()=>{window.setTimeout(e,500)};return v.addEventListener("canplay",w,{once:!0}),v.addEventListener("playing",w,{once:!0}),S=window.setTimeout(e,5e3),()=>{window.clearTimeout(S),v.removeEventListener("canplay",w),v.removeEventListener("playing",w)}},[c,C,i,r])}const As=()=>te.getItem("preferredMode")==="dub"?"dub":"sub",xs=/^[a-z0-9-]+$/i,Jt=r=>r?"preferredProviderMature":"preferredProvider",Zt=r=>{const o=te.getItem(Jt(r));return o&&xs.test(o)?o:null},er=(r,o)=>{te.setItem(Jt(o),r)},Ls=()=>Zt(!1)??"megaplay",$s=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:As(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:Cn(),showResumeModal:!0,resumeProgressPending:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Ls(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Bs(r,o){switch(o.type){case"SET_STATE":return{...r,...o.payload};case"SET_MODE":return{...r,currentMode:o.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...r,selectedProvider:o.payload};default:return r}}async function Gt(r,o,c,d,C=!1){if(!r||!o)throw new Error("Missing params");try{const[i,s,n,a,g]=await Promise.all([ue.data.video.query({showId:r,episodeNumber:o,mode:c.currentMode,provider:c.selectedProvider}).catch(y=>{const R=y.data?.cause;return y.message==="AUTH_REQUIRED"&&R?.provider==="mkissa"&&d({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:"mkissa"}}),null}),ue.progress.getEpisode.query({showId:r,episodeNumber:o}).catch(()=>null),ue.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),ue.settings.getByKey.query({key:"preferredLink"}).catch(()=>null),ue.data.skipTimes.query({showId:r,episodeNumber:o}).catch(()=>[])]),p=n?.value,v=i?.filter(y=>{const R=y.sourceName.toLowerCase();return c.currentMode==="dub"?R.includes("eng")||R.includes("dub"):R.includes("jpn")||R.includes("sub")||!R.includes("eng")&&!R.includes("dub")})??[],S=v.length>0?v:i??[];let E=S.length>0?S[0]:null;if(p){const y=S.find(R=>R.sourceName===p);y&&(E=y)}const e=a?.value,w=y=>{const R=/(\d{3,4})/.exec(y||"");return R?parseInt(R[1],10):0},T=E&&E.links.length>0?(e?E.links.find(y=>y.resolutionStr===e):null)??(()=>{const y=w(e);if(!y)return null;let R=null,W=1/0;for(const q of E.links){const D=w(q.resolutionStr),I=Math.abs(D-y);D>0&&I<W&&(W=I,R=q)}return R})()??[...E.links].sort((y,R)=>(parseInt(R.resolutionStr)||0)-(parseInt(y.resolutionStr)||0))[0]:null,_=s?.currentTime||0,$=s?.duration||0,M=_,P=(Array.isArray(g)?g:g?.results||[]).map(y=>({skip_id:y.skip_id||"",skip_type:y.skip_type||"",start_time:y.interval?.start_time??y.start_time??0,end_time:y.interval?.end_time??y.end_time??0})).filter(y=>y.end_time>0);return(!i||i.length===0)&&(C||ke.error(`No video sources found for ${c.selectedProvider}`)),{videoSources:i,selectedSource:E,selectedLink:T,resumeTime:M,resumeDuration:$,showResumeModal:M>5&&!ut(M,$)&&E?.type!=="iframe",skipIntervals:P,fetchedEpisodeNumber:o}}catch(i){const s=i;if(s.message==="AUTH_REQUIRED")return d({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:s.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:o};throw i}}const Ds=(r,o,c,d)=>{const[C,i]=Ar(Bs,c,u=>({...$s(),showMeta:u?.name?{name:u.name,thumbnail:u.thumbnail,nativeName:u.nativeName,englishName:u.englishName,names:{romaji:u.name||u.englishName,english:u.englishName||u.name,native:u.nativeName}}:{}})),s=d?.watchSelection,n=Ae(()=>s?{...C,selectedProvider:s.provider,currentMode:s.mode}:C,[C,s]),a=Ht(),g=Dr(),p=N(null),v=N(null),{options:S}=Xt(),E=Ae(()=>S.filter(u=>(u.kind??"anime")==="anime"),[S]),e=o||n.initialEpisode,w=`${r}:${e}`,T=N(w);U(()=>{T.current!==w&&(T.current=w,i({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[w,i]),U(()=>{!s&&r&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)&&n.selectedProvider!=="animepahe"&&p.current!==r&&(p.current=r,i({type:"SET_PROVIDER",payload:"animepahe"}))},[r,n.selectedProvider,s]);const{data:_,isLoading:$,error:M}=An(r),{data:h}=Vt({queryKey:[ae.playerData,r,n.currentMode,n.selectedProvider],queryFn:async()=>{if(!r)throw new Error("No showId");const u=async()=>{try{const L=await ue.data.episodes.query({showId:r,mode:n.currentMode,provider:n.selectedProvider}).catch(()=>null);if(L?.episodes?.length)return L}catch{}return null},[k,O,j]=await Promise.all([u(),ue.watchlist.check.query({showId:r}).catch(()=>({inWatchlist:!1,status:null})),ue.progress.getWatchedEpisodes.query({showId:r}).catch(()=>[])]),de=k?.episodes?k.episodes.sort((L,be)=>parseFloat(L)-parseFloat(be)):[];return{description:k?.description||"",episodes:de,inWatchlist:O.inWatchlist,watchlistStatus:O.status??null,watchedEpisodes:j}},enabled:!!r});U(()=>{!o&&h?.episodes&&h.episodes.length>0&&!o&&i({type:"SET_STATE",payload:{initialEpisode:h.episodes[0]}})},[h,o]),U(()=>{if(s||_?.isAdult===void 0||v.current===r)return;const u=_.isAdult===!0,k=E.filter(j=>j.mature===u);if(k.length===0||E.find(j=>j.id===n.selectedProvider)?.mature===u)return;const O=Zt(u);v.current=r??null,i({type:"SET_PROVIDER",payload:k.find(j=>j.id===O)?.id??k[0].id})},[_?.isAdult,n.selectedProvider,r,E,s]),U(()=>{if(s||!r||!/^dango-mt-\d+$/.test(r)||v.current===`temp:${r}`)return;const u=_?.provider;u&&(v.current=`temp:${r}`,u!==n.selectedProvider&&i({type:"SET_PROVIDER",payload:u}))},[r,_,n.selectedProvider,s]);const{data:P,isLoading:y,isFetching:R,error:W}=Vt({queryKey:[ae.videoSources,r,e,n.selectedProvider,n.currentMode],queryFn:()=>Gt(r,e,n,i),enabled:!!r&&!!e&&!(n.showMeta?.isAdult===!0&&!d?.hasMatureConsent)}),{mutateAsync:q}=bt({mutationFn:async({wasIn:u,showMeta:k})=>{if(!r)throw new Error("Missing showId");if(u)await ue.watchlist.remove.mutate({id:r});else{const O=k.name||k.names?.romaji;if(!O)throw new Error("Missing show name");await ue.watchlist.add.mutate({id:r,name:O,thumbnail:k.thumbnail,nativeName:k.names?.native,englishName:k.names?.english,type:k.type,isAdult:k.isAdult})}return!u},onSuccess:u=>{ke.success(u?"Added to watchlist":"Removed from watchlist"),a.invalidateQueries({queryKey:[ae.playerData,r]}),a.invalidateQueries({queryKey:[ae.showData,r]}),a.invalidateQueries({queryKey:[ae.watchlist]})},onError:u=>ke.error(u instanceof Error?u.message:"Failed to update watchlist")}),D=K(async()=>{!r||!_||await q({wasIn:!!h?.inWatchlist,showMeta:_})},[r,_,h?.inWatchlist,q]),I=K(async u=>{try{await ue.settings.set.mutate({key:"preferredSource",value:u})}catch(k){console.error(k)}},[]),G=K(async u=>{try{await ue.settings.set.mutate({key:"preferredLink",value:u})}catch(k){console.error(k)}},[]),{mutateAsync:ee,isPending:m}=bt({mutationFn:async({status:u})=>{if(!r)throw new Error("Missing showId");if(h?.inWatchlist)return await ue.watchlist.setStatus.mutate({id:r,status:u}),u;const k=_,O=k?.name||k?.names?.romaji;if(!k||!O)throw new Error("Missing show name");return await ue.watchlist.add.mutate({id:r,name:O,thumbnail:k.thumbnail,nativeName:k.names?.native,englishName:k.names?.english,type:k.type,isAdult:k.isAdult,status:u}),u},onSuccess:u=>{i({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:u}}),ke.success(`Moved to ${u}`),a.invalidateQueries({queryKey:[ae.showData,r]}),a.invalidateQueries({queryKey:[ae.watchlist]}),a.invalidateQueries({queryKey:[ae.continueWatching]})},onError:()=>ke.error("Failed to update watchlist status")}),f=K(async()=>{await ee({status:"Completed"})},[ee]),{mutateAsync:A,isPending:Y}=bt({mutationFn:async({episodeNumber:u,duration:k,showMeta:O,episodes:j})=>{await ue.progress.updateProgress.mutate({showId:r??"",episodeNumber:u,currentTime:k,duration:k,showName:O.name,showThumbnail:O.thumbnail,nativeName:O.names?.native,englishName:O.names?.english,genres:O.genres?.map(de=>de.name),popularityScore:Ir(O.score)??void 0,type:O.type,status:O.status,episodeCount:j.length,isAdult:O.isAdult})},onSuccess:(u,k)=>{ke.success(`Episode ${k.episodeNumber} marked as watched`),a.invalidateQueries({queryKey:[ae.playerData,r]}),a.invalidateQueries({queryKey:[ae.showMeta,r]}),a.invalidateQueries({queryKey:[ae.videoSources,r,k.episodeNumber]}),a.invalidateQueries({queryKey:[ae.continueWatching]}),a.invalidateQueries({queryKey:[ae.thisWeekSchedule]}),a.invalidateQueries(g.continueWatching.pathFilter())},onError:()=>ke.error("Failed to mark episode as watched")}),x=K(async(u,k)=>{!r||!_||await A({episodeNumber:u,duration:k,showMeta:_,episodes:h?.episodes||[]})},[r,_,h?.episodes,A]),{mutateAsync:z,isPending:se}=bt({mutationFn:async({episodeNumber:u})=>{await ue.progress.resetProgress.mutate({showId:r??"",episodeNumber:u})},onSuccess:()=>{ke.success("Episode progress reset"),a.invalidateQueries({queryKey:[ae.playerData,r]}),a.invalidateQueries({queryKey:[ae.showMeta,r]}),a.invalidateQueries({queryKey:[ae.continueWatching]})},onError:()=>ke.error("Failed to reset progress")}),F=K(async u=>{r&&await z({episodeNumber:u})},[r,z]),we=K(async()=>{i({type:"SET_STATE",payload:{showCombinedDetails:!n.showCombinedDetails}})},[n.showCombinedDetails]),V=Ae(()=>{const u=M||W,k=u?u.message:null,O=k==="AUTH_REQUIRED"?null:k,j=P&&P.fetchedEpisodeNumber===e?P:null,de=!!P&&!j,L=s?j?.videoSources?.find(X=>X.sourceName===s.source&&X.type!=="iframe"&&X.links.some(oe=>oe.hls))??null:null,Ve=(n.selectedSource?.sourceName===L?.sourceName?L?.links.find(X=>X.hls&&X.link===n.selectedLink?.link):null)??L?.links.filter(X=>X.hls).slice().sort((X,oe)=>(parseInt(oe.resolutionStr)||0)-(parseInt(X.resolutionStr)||0))[0]??null;return{...n,currentEpisode:e,showMeta:{...n.showMeta||{},..._||{}},episodes:h?.episodes||[],watchedEpisodes:h?.watchedEpisodes||[],inWatchlist:!!h?.inWatchlist,watchlistStatus:h?.watchlistStatus??n.watchlistStatus??null,videoSources:j?.videoSources||[],selectedSource:s?L:n.selectedSource||j?.selectedSource||null,selectedLink:s?Ve:n.selectedLink||j?.selectedLink||null,resumeTime:s?0:j?.resumeTime||0,resumeDuration:j?.resumeDuration||0,resumeProgressPending:R,showResumeModal:!s&&n.showResumeModal&&(j?.showResumeModal??!1),skipIntervals:j?.skipIntervals||[],loadingShowData:$,loadingVideo:y||de,error:O,fetchedEpisodeNumber:j?.fetchedEpisodeNumber}},[n,_,h,P,$,y,R,M,W,e,s]),H=K((u,k)=>{const O=k||r;if(!O||!u||O===r&&u===e)return;const de=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(O)&&n.selectedProvider!=="animepahe"?"animepahe":n.selectedProvider,L=["video-sources",O,u,de,n.currentMode];a.getQueryState(L)?.status!=="success"&&a.prefetchQuery({queryKey:L,queryFn:()=>Gt(O,u,{selectedProvider:de,currentMode:n.currentMode},i,!0),staleTime:300*1e3,gcTime:1800*1e3})},[r,e,a,n,i]);return{state:V,dispatch:i,toggleWatchlist:D,moveToCompleted:f,setPreferredSource:I,setPreferredLink:G,handleToggleDetails:we,markEpisodeWatched:x,resetEpisodeProgress:F,prefetchEpisodeSources:H,isMarkingWatched:Y,isResettingProgress:se,isUpdatingWatchlistStatus:m}};function Is({onPrevious:r,onNext:o,onToggleTheater:c,flashControls:d}){U(()=>{const C=i=>{i.defaultPrevented||i.ctrlKey||i.metaKey||i.altKey||i.repeat||i.target.closest('input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(i.key.toLowerCase())&&d(),i.key.toLowerCase()==="n"&&o(),i.key.toLowerCase()==="p"&&r(),i.key.toLowerCase()==="t"&&c())};return document.addEventListener("keydown",C),()=>{document.removeEventListener("keydown",C)}},[d,o,r,c])}const ct=(r,o,c)=>r.showId===o||!!c&&r.showId===c;function Fs({testClipActive:r,selectedSourceType:o,onEnded:c,queue:d,removeFromQueue:C,showId:i,showMetaId:s,showStatus:n,currentEpisode:a,isAutoplayEnabled:g,nextEpisode:p,previousEpisode:v,navigate:S,invalidateContinueWatching:E,dispatch:e}){const[w,T]=ne(!1),[_,$]=ne(null),[M,h]=ne(null),P=N(C);P.current=C;const y=N(!1),R=Yt(n);U(()=>{y.current=!1,T(!1)},[i,a]);const W=K(()=>{if(r||y.current)return;y.current=!0,c();const f=d.find(A=>ct(A,i,s)&&A.episodeNumber===a);if(d.length>0){const A=d.findIndex(x=>ct(x,i,s)&&x.episodeNumber===a),Y=A>=0?d[A+1]||null:d[0];h({nextItem:Y,playedItem:f||null}),$(2);return}if(f&&P.current({showId:f.showId,episodeNumber:f.episodeNumber}),g&&p){E(),S(`/watch/${i}/${p}`);return}!p&&R&&T(!0)},[c,S,d,i,s,a,p,g,E,r,R]),q=K(()=>{if(d.length===0)return;c();const f=d.find(x=>ct(x,i,s)&&x.episodeNumber===a),A=d.findIndex(x=>ct(x,i,s)&&x.episodeNumber===a),Y=A>=0?d[A+1]||null:d[0];f&&C({showId:f.showId,episodeNumber:f.episodeNumber}),Y?S(`/watch/${Y.showId}/${Y.episodeNumber}`):!p&&R&&T(!0)},[c,S,d,C,i,s,a,p,R]),D=K(()=>{p&&(E(),S(`/watch/${i}/${p}`)),T(!1),e({type:"SET_STATE",payload:{showResumeModal:!1}})},[p,S,i,e,E]),I=K(()=>{d.length>0?q():p?D():ke.error("No next episode available")},[d.length,q,D,p]),G=K(()=>T(!1),[]),ee=K(()=>{h(null),$(null)},[]),m=K(()=>{v&&S(`/watch/${i}/${v}`)},[v,S,i]);return U(()=>{const f=A=>{A.origin===window.location.origin&&o==="iframe"&&A.data?.type==="ANI_WEB_MEDIA_ENDED"&&W()};return window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[W,o]),U(()=>{if(!M||_===null)return;if(_<=0){const{nextItem:A,playedItem:Y}=M;h(null),$(null),Y&&P.current({showId:Y.showId,episodeNumber:Y.episodeNumber}),A?S(`/watch/${A.showId}/${A.episodeNumber}`):!p&&R&&T(!0);return}const f=window.setTimeout(()=>{$(A=>A===null?null:A-1)},1e3);return()=>window.clearTimeout(f)},[M,_,S,p,R]),{showCompleteModal:w,queueCountdown:_,pendingQueueTransition:M,handleQueueTransition:q,handleNextEpisode:D,handleNShortcut:I,handlePreviousEpisode:m,handlePlaybackFinished:W,closeCompleteModal:G,cancelQueueTransition:ee}}function Os({videoRef:r,queue:o,showId:c,showMetaId:d,currentEpisode:C,selectedSource:i,hasNextEpisode:s,nextEpisode:n,prefetchEpisodeSources:a,matchesQueueItem:g}){const[p,v]=ne(!1),S=N(a);S.current=a;const E=N("");U(()=>{v(!1)},[C]);const e=K(()=>{const w=r.current;if(!w||i?.type==="iframe")return;const T=w.duration,_=w.currentTime;if(!T||Number.isNaN(T)){v(!1);return}if(T-_<=60){const $=o.findIndex(P=>g(P,c,d)&&P.episodeNumber===C),M=o.length>0?$>=0?o[$+1]||null:o[0]:null,h=M?`${M.showId}:${M.episodeNumber}`:s?`${c}:${n}`:"";h&&E.current!==h&&(E.current=h,M?S.current(M.episodeNumber,M.showId):S.current(n??""))}v(s&&ut(_,T))},[r,i,o,c,d,C,s,n,g]);return{showNextEpisodePrompt:p,handleThresholds:e}}const Nt="fallbackChoice";function Ws(){try{const r=te.getItem(Nt);return r==="iframe"||r==="retry"?r:null}catch{return null}}function Us(r){try{r===null?te.removeItem(Nt):te.setItem(Nt,r)}catch{}}function Qs({showId:r,episodeNumber:o,currentMode:c,selectedProvider:d,selectedSourceType:C,videoSources:i,isAdult:s,providerOrder:n,matureProviders:a,setPreferredSource:g,dispatch:p,showControls:v}){const S=N(!1),E=N([]),e=N(!1),[w,T]=ne(null),[_,$]=ne(!1),[M,h]=ne(!1),[P,y]=ne(()=>Ws()??"ask"),R=K(x=>{y(x),Us(x==="ask"?null:x)},[]),W=N(P);U(()=>{W.current=P},[P]);const q=N(i);q.current=i;const D=K(()=>{S.current=!1,E.current=[],e.current=!1,T(null),$(!1)},[]);U(()=>{D()},[D,r,o]);const I=K(x=>{if(S.current)return;S.current=!0;const z=x.links[0];g(x.sourceName),p({type:"SET_STATE",payload:{selectedSource:x,selectedLink:z}}),T(null)},[p,g]),G=K(()=>{const z=q.current.find(se=>se.type==="iframe");return z?.links?.length?z:null},[]),ee=K(async()=>{const x=n.filter(z=>{if(E.current.includes(z))return!1;const se=a.has(z);return s===void 0?!0:se===s});$(!0);try{for(const z of x){E.current.push(z);let se=null;try{se=await ue.data.video.query({showId:r,episodeNumber:o,mode:c,provider:z})}catch{continue}const F=(se??[]).filter(H=>{const u=H.sourceName.toLowerCase();return c==="dub"?u.includes("eng")||u.includes("dub"):u.includes("jpn")||u.includes("sub")||!u.includes("eng")&&!u.includes("dub")});if((F.length>0?F:se??[]).find(H=>H.type!=="iframe"&&H.links?.length)){E.current=[d],e.current=!1,p({type:"SET_STATE",payload:{selectedProvider:z,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),er(z,s===!0),T(null),ke.success(`Switched to ${z} (direct stream)`);return}}T({retryFailed:!0}),ke.error("No working direct stream found on other providers")}finally{$(!1)}},[r,o,c,s,d,p,n,a]),m=K(()=>{if(S.current||e.current||C!=="player")return;const x=G();if(!x)return;E.current.includes(d)||E.current.push(d);const z=W.current;if(z==="iframe"){I(x);return}if(z==="retry"){ee();return}v(!0),T({retryFailed:!1})},[C,d,G,I,ee,v]),f=K(()=>{e.current=!0,T(null),h(!1)},[]),A=K(()=>{M&&R("iframe");const x=G();x?I(x):T(null)},[M,R,G,I]),Y=K(()=>{M&&R("retry"),ee()},[M,R,ee]);return{fallbackPrompt:w,isRetryingProvider:_,rememberFallbackChoice:M,setRememberFallbackChoice:h,fallbackChoice:P,updateFallbackChoice:R,dismissFallbackPrompt:f,chooseIframeFallback:A,chooseProviderRetry:Y,handleVideoSourceError:m,resetFallback:D}}function Vs({engine:r,videoRef:o,selectedSource:c,selectedLink:d,loadingVideo:C,testClipActive:i,resumeTime:s,resumeDuration:n=0,showResumeModal:a,disabled:g=!1,startOver:p=!1,resumeAt:v=null,calibReturnRef:S,setAvailableSubtitles:E,setActiveSubtitleTrack:e,onFatalError:w}){const T=N(null),_=N(s),$=N(n),M=N(a),h=N(w);return h.current=w,U(()=>{_.current=s,$.current=n,M.current=a},[s,n,a]),U(()=>{if(g){r.unload();return}const P=o.current;if(!P)return;for(;P.firstChild;)P.removeChild(P.firstChild);if(i)return r.loadSource({url:"/av-sync-test.mp4"},{autoPlay:!0});if(C||!c||!d||c.type==="iframe"){r.unload();return}p?T.current=0:S.current!=null?(T.current=S.current,S.current=null):T.current===null&&v!=null?T.current=v:T.current===null&&_.current>5&&!M.current&&!ut(_.current,$.current)?T.current=_.current:T.current===null&&M.current&&(T.current=0);let y=d.link;if(y.startsWith("/api/proxy")||(y=`/api/proxy?url=${encodeURIComponent(y)}`,d.headers?.Referer&&(y+=`&referer=${encodeURIComponent(d.headers.Referer)}`)),c.subtitles){const q=te.getItem("playerSubtitlesEnabled")!=="false";let D=null;try{D=te.getItem("playerLastSubtitle")}catch{}const I=c.subtitles.map(m=>({...m,lang:m.lang||m.language||m.label||"en",label:m.label||m.lang||m.language||"en"})),G=_t(I,{lastKey:D,enabled:q}),ee=G>=0?I[G]:null;I.forEach(m=>{const f=document.createElement("track");f.kind="subtitles",f.label=m.label,f.srclang=m.lang||"en";const A=m.src??m.url;if(A){let Y=`/api/subtitle-proxy?url=${encodeURIComponent(A)}`;const x=d.headers?.Referer;x&&(Y+=`&referer=${encodeURIComponent(x)}`),f.src=Y}ee&&m.label===ee.label&&m.lang===ee.lang&&(f.default=!0),P.appendChild(f)}),q||e("off"),E(I)}const R=T.current??0;T.current=null;const W=document.body.classList.contains("low-end");return r.loadSource({url:y,hls:d.hls,dash:d.dash},{initialTime:R,autoPlay:p||v!=null||!(M.current&&_.current>5)&&!ut(_.current,$.current),hlsConfig:{maxBufferLength:W?15:30,maxMaxBufferLength:W?30:60,maxBufferSize:(W?25:60)*1e3*1e3,startLevel:-1},onHls:(q,D)=>{if(!c.subtitles?.length)return;const I=()=>{q.subtitleTrack!==-1&&(q.subtitleTrack=-1)};q.on(D.Events.SUBTITLE_TRACK_SWITCH,I),I()},onDash:q=>{const D=d.headers?.Referer;D&&q.addRequestInterceptor(I=>{const G=I?.url??"";if(!G||G.includes("/api/proxy?")||G.includes("/api/subtitle-proxy?")||G.includes("/api/tv/stream-proxy?"))return I;try{const m=new URL(G);if(m.protocol!=="http:"&&m.protocol!=="https:")return I}catch{return I}const ee=`/api/proxy?url=${encodeURIComponent(G)}&referer=${encodeURIComponent(D)}`;return{...I,url:ee}})},onError:()=>h.current()})},[r,c,d,o,S,C,i,g,p,v,e,E]),{seekToTimeRef:T}}function Ks({videoRef:r,availableSubtitles:o,activeSubtitleTrack:c,setAvailableSubtitles:d,setActiveSubtitleTrack:C}){U(()=>{const i=r.current;if(!i)return;const s=()=>{const n=Array.from(i.textTracks).map(a=>({label:a.label,lang:a.language==="undefined"?"":a.language,src:void 0,mode:a.mode}));d(n)};return i.textTracks.addEventListener("addtrack",s),i.textTracks.addEventListener("removetrack",s),s(),()=>{i.textTracks.removeEventListener("addtrack",s),i.textTracks.removeEventListener("removetrack",s)}},[r,d]),U(()=>{if(c===null&&o.length>0&&te.getItem("playerSubtitlesEnabled")!=="false"){let i=null;try{i=te.getItem("playerLastSubtitle")}catch{}const s=_t(o,{lastKey:i,enabled:!0});if(s<0){C("off");return}const n=o[s];C(n.label||n.lang)}},[c,o,C]),U(()=>{const i=r.current;if(!i||o.length===0)return;const s=c;if(!(te.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(i.textTracks).forEach(g=>{g.mode="hidden"});return}let a=!1;if(Array.from(i.textTracks).forEach(g=>{const v=(g.language===s||g.label===s)&&!a;g.mode=v?"showing":"hidden",v&&(a=!0)}),!a&&i.textTracks.length>0){const g=Array.from(i.textTracks).find(p=>p.language==="en"||p.label==="English")||i.textTracks[0];g&&(g.mode="showing")}},[c,o,r])}function qs({videoRef:r,videoBoxH:o,style:c,sourceKey:d,activeSubtitleTrack:C,availableSubtitles:i}){U(()=>{const s="dynamic-subtitle-styles";let n=document.getElementById(s);n||(n=document.createElement("style"),n.id=s,document.head.appendChild(n)),n.textContent=Kt(c);const a=r.current;if(!a)return;const g=jt(c.fontSize,o||a.clientHeight||720);n.textContent=Kt({...c,fontSize:g});const p=()=>{const h=Number(c.position),P=isNaN(h)?0:Math.max(0,Math.min(100,h));return Math.max(0,Math.min(100,100-P))},v=(h,P)=>{try{const y=h;y.snapToLines=!1,y.line=P}catch{}},S=()=>{const h=g*16,P=a.videoHeight||a.clientHeight||720,y=a.videoWidth||a.clientWidth||1280;return{step:h*1.3/P*100,chars:Math.max(20,Math.floor(y/(h*.55)))}},E=h=>{const P=p(),y=Array.from(h.activeCues??[]);if(y.length<=1){y.forEach(D=>v(D,P));return}const{step:R,chars:W}=S();let q=P;for(let D=y.length-1;D>=0;D--){const G=String(y[D].text??"").replace(/<[^>]*>/g,"").split(`
55
- `).reduce((m,f)=>m+Math.max(1,Math.ceil(f.length/W)),0),ee=q-G*R;v(y[D],Math.max(0,ee)),q=ee-R*.4}},e=h=>{if(!h.cues)return;const P=p();Array.from(h.cues).forEach(y=>v(y,P)),h.mode==="showing"&&E(h)},w=()=>{Array.from(a.textTracks).forEach(e)};w();const T=h=>{const P=h.target;P.mode==="showing"&&E(P)};Array.from(a.textTracks).forEach(h=>{h.addEventListener("cuechange",T)});const _=()=>{Array.from(a.textTracks).forEach(h=>{h.removeEventListener("cuechange",T),h.addEventListener("cuechange",T)}),w()};a.textTracks.addEventListener("addtrack",_),a.textTracks.addEventListener("removetrack",_);const $=Array.from(a.querySelectorAll("track")),M=()=>{w()};return $.forEach(h=>{h.addEventListener("load",M)}),()=>{Array.from(a.textTracks).forEach(h=>{h.removeEventListener("cuechange",T)}),a.textTracks.removeEventListener("addtrack",_),a.textTracks.removeEventListener("removetrack",_),$.forEach(h=>{h.removeEventListener("load",M)})}},[c,o,r,d,C,i])}function Gs({videoRef:r,overlayRef:o,style:c,activeSubtitleTrack:d,delayMs:C,enabled:i}){U(()=>{if(!i)return;const s=r.current,n=o.current;if(!s||!n)return;const a=te.getItem("playerSubtitlesEnabled")!=="false",g=()=>{if(n.innerHTML="",!a||d==="off"||d===null)return;const S=Array.from(s.textTracks).find(M=>M.language===d||M.label===d);if(!S||S.mode!=="showing")return;const E=C/1e3;let e;if(E>0&&S.cues){const M=s.currentTime-E;e=Array.from(S.cues).filter(h=>h.startTime<=M&&M<=h.endTime)}else e=Array.from(S.activeCues??[]);if(e.length===0)return;const w={...c,fontSize:jt(c.fontSize,s.clientHeight||0)},T=on(w),_=an(s,w.position),$=Array.from(e);$.forEach((M,h)=>{const P=String(M.text??"");if(!ln(P).trim())return;const y=document.createElement("div"),R=($.length-1-h)*1.7;y.style.cssText=`${T}
56
- bottom: calc(${_}px + ${R}em);`,y.innerHTML=cn(P),n.appendChild(y)})},p=()=>g(),v=()=>g();return Array.from(s.textTracks).forEach(S=>{S.addEventListener("cuechange",p)}),s.addEventListener("timeupdate",v),g(),()=>{Array.from(s.textTracks).forEach(S=>{S.removeEventListener("cuechange",p)}),s.removeEventListener("timeupdate",v),n.innerHTML=""}},[d,C,i,o,c,r])}const zs=({isOpen:r,onClose:o,onSuccess:c})=>{const d=()=>{c?.(),o()};return t(wt,{isOpen:r,onClose:o,title:"MKissa Browser Verification",children:t("div",{className:et.container,children:[t("p",{children:"Open MKissa in this browser, play an anime episode, and complete any Cloudflare verification it shows. Once playback works there, return to Dango and click Refresh."}),t("div",{className:et.actions,children:t("a",{className:et.link,href:"https://mkissa.to/anime",target:"_blank",rel:"noreferrer",children:"Open MKissa anime"})}),t("div",{className:et.actions,children:[t("button",{className:et.secondaryButton,onClick:o,children:"Cancel"}),t("button",{className:et.button,onClick:d,children:"Refresh Dango"})]})]})})},mo=()=>{const{id:r,episodeNumber:o}=xr(),c=Lr(),d=Ht(),C=$r(),i=Fr(),s=!!i.session,n=s&&!i.session?.host,{hasConsent:a,grant:g}=Or(),{options:p}=Xt(),v=Ae(()=>p.filter(l=>(l.kind??"anime")==="anime"),[p]),S=Ae(()=>v.map(l=>l.id),[v]),E=Ae(()=>new Set(v.filter(l=>l.mature).map(l=>l.id)),[v]),{state:e,dispatch:w,toggleWatchlist:T,moveToCompleted:_,setPreferredSource:$,setPreferredLink:M,handleToggleDetails:h,resetEpisodeProgress:P,prefetchEpisodeSources:y,isResettingProgress:R,isUpdatingWatchlistStatus:W}=Ds(r,o,C.state||null,{hasMatureConsent:a,watchSelection:n?i.room?.selection:null}),[q,D]=ne(()=>Date.now()),I=e.showMeta.nextAiring?.airingAt,G=typeof I=="number"?I*1e3:null;U(()=>{if(G==null||G<=Date.now())return;const l=setInterval(()=>D(Date.now()),1e3);return()=>clearInterval(l)},[G]),U(()=>{if(r&&e.showMeta?.id&&e.showMeta.id!==r){const l=o?`/watch/${e.showMeta.id}/${o}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;c(l,{replace:!0})}},[r,e.showMeta?.id,o,c]);const ee=Ae(()=>{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]),m=un({skipIntervals:e.skipIntervals,showId:r,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:ee}),{refs:f,actions:A}=m,Y=Ae(()=>!r||r.startsWith("dango-mt-")||!e.currentEpisode||e.selectedSource?.type==="iframe"||!e.selectedLink?.hls||!e.selectedSource?null:{showId:r,episode:e.currentEpisode,provider:e.selectedProvider,mode:e.currentMode,source:e.selectedSource.sourceName,title:e.showMeta.name||r},[r,e.currentEpisode,e.selectedProvider,e.currentMode,e.selectedSource,e.selectedLink,e.showMeta.name]),x=dn(m.engine,Y,e.loadingVideo||e.loadingShowData),z=Nn(),se=N(null),F=N(null),we=N(null),[V,H]=ne(()=>{try{const l=te.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(l)?l:"balanced"}catch{return"balanced"}}),{videoDelayMs:u,videoDelayEnabled:k,setDelayEnabled:O,handleVideoDelayChange:j,isCalibrating:de,testClipActive:L,stopCalibration:be,openAvSyncCalibrator:Ve,cancelAvSyncCalibrator:X,applyAvSyncCalibrator:oe,toggleTestClip:$e,calibReturnRef:ve,effectiveVideoDelayMs:Oe}=mn(f.videoRef,()=>A.setShowSettings(!1)),tt=N(null),[rt,Ke]=ne(!1),[dt,We]=ne(null);U(()=>{Ke(!1),We(null)},[r,e.currentEpisode]);const le=`${r??""}:${e.currentEpisode??""}`,[mt,Et]=ne(null);U(()=>{e.loadingVideo||e.videoSources.length===0||Et(l=>l?.key===le?l:{key:le,watched:ut(e.resumeTime,e.resumeDuration)})},[le,e.loadingVideo,e.videoSources.length,e.resumeTime,e.resumeDuration]);const kt=mt?.key===le&&mt.watched,[Xe]=ne(Rn),[pt,Q]=ne(!1);U(()=>{Q(!1)},[r,e.currentEpisode]);const Ue=!s&&!L&&kt&&e.videoSources.length>0&&!rt,Be=Ue&&Xe,Se=Ue&&!Xe&&!pt,ht=K(()=>{We(null),Ke(!0)},[]),qe=K(()=>{We(e.resumeTime),Ke(!0)},[e.resumeTime]),ie=Ns({videoRef:f.videoRef,canvasRef:F,profile:V,delayMs:Oe}),De=ie.isEnabled&&ie.isWebGPUSupported;_s({videoRef:f.videoRef,episodeKey:`${r??""}:${e.currentEpisode??""}`,isEnabled:ie.isEnabled,isSupported:ie.isWebGPUSupported,mediaReady:!e.loadingVideo&&!!e.selectedLink,isIframeSource:e.selectedSource?.type==="iframe",setEnabled:ie.setEnabled}),pn({videoRef:f.videoRef,canvasRef:tt,delayMs:Oe,enabled:k&&!De});const nt=k&&!De,Ge=De||nt,[st,ze]=ne(!1),ot=N(o);U(()=>{ot.current!==o&&(ot.current=o,be())},[o,be]);const Tt=K(()=>{d.invalidateQueries({queryKey:[ae.continueWatching]})},[d]),{data:He=[],isLoading:Ct}=Wr(),J=Ur(),me=Qr(),Te=Vr(),{isTheaterMode:re,toggleTheaterMode:he,handleLayoutClick:Ee}=hn();Br(()=>{if(m.state.isFullscreen||re)return;const l=f.playerContainerRef.current,Z=se.current;if(!l||!Z)return;const Me=()=>{const Pe=l.getBoundingClientRect().height;Z.style.height=`${Pe}px`};Me();const xe=new ResizeObserver(Me);return xe.observe(l),()=>xe.disconnect()},[m.state.isFullscreen,re,f.playerContainerRef]);const ce=Ae(()=>e.episodes.findIndex(l=>l===e.currentEpisode),[e.episodes,e.currentEpisode]),Je=ce>0?e.episodes[ce-1]:null,ge=ce>=0&&ce<e.episodes.length-1?e.episodes[ce+1]:null,Ce=ce>-1&&ce<e.episodes.length-1,pe=Yt(e.showMeta?.status),Ie=!ge&&pe,Ze=!ge&&!Ie,{showCompleteModal:fe,queueCountdown:it,pendingQueueTransition:At,handleQueueTransition:tr,handleNextEpisode:ft,handleNShortcut:rr,handlePreviousEpisode:xt,handlePlaybackFinished:nr,closeCompleteModal:vt,cancelQueueTransition:sr}=Fs({testClipActive:L,selectedSourceType:e.selectedSource?.type,onEnded:A.onEnded,queue:He,removeFromQueue:J.mutate,showId:r,showMetaId:e.showMeta?.id,showStatus:e.showMeta?.status,currentEpisode:e.currentEpisode,isAutoplayEnabled:!n&&e.isAutoplayEnabled,nextEpisode:ge,previousEpisode:Je,navigate:c,invalidateContinueWatching:Tt,dispatch:w}),{showNextEpisodePrompt:or,handleThresholds:Rt}=Os({videoRef:f.videoRef,queue:He,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,selectedSource:e.selectedSource,hasNextEpisode:Ce,nextEpisode:ge,prefetchEpisodeSources:y,matchesQueueItem:ct}),{checkEnd:gt,logDuration:Lt}=fn({videoRef:f.videoRef,sourceType:e.selectedSource?.type,resetKey:`${r}:${e.currentEpisode}:${rt}`,onEnd:n?A.onEnded:nr}),$t=!s&&e.showResumeModal&&!e.resumeProgressPending,Qe=fe&&Xe,ir=fe&&!Xe,je=$t||fe||Se;vn(m,!!e.selectedLink&&!re&&!je&&!Be&&!Qe&&!Se);const{fallbackPrompt:Bt,isRetryingProvider:Dt,rememberFallbackChoice:ar,setRememberFallbackChoice:lr,fallbackChoice:cr,updateFallbackChoice:ur,dismissFallbackPrompt:dr,chooseIframeFallback:mr,chooseProviderRetry:pr,handleVideoSourceError:It,resetFallback:Ft}=Qs({showId:r,episodeNumber:e.currentEpisode??void 0,currentMode:e.currentMode,selectedProvider:e.selectedProvider,selectedSourceType:e.selectedSource?.type,videoSources:e.videoSources,isAdult:e.showMeta?.isAdult,providerOrder:S,matureProviders:E,setPreferredSource:$,showControls:A.setShowControls,dispatch:w}),{seekToTimeRef:Ot}=Vs({engine:m.engine,videoRef:f.videoRef,selectedSource:e.selectedSource,selectedLink:e.selectedLink,loadingVideo:e.loadingVideo,testClipActive:!s&&L,resumeTime:s?0:e.resumeTime,resumeDuration:e.resumeDuration,showResumeModal:!s&&e.showResumeModal,disabled:Be||Qe,startOver:rt&&dt==null,resumeAt:dt,calibReturnRef:ve,setAvailableSubtitles:A.setAvailableSubtitles,setActiveSubtitleTrack:A.setActiveSubtitleTrack,onFatalError:s?()=>{}:It});U(()=>{(je||Be||Qe)&&m.state.isFullscreen&&m.actions.toggleFullscreen()},[je,Be,Qe,m.state.isFullscreen,m.actions]),U(()=>{je&&f.videoRef.current&&f.videoRef.current.pause()},[je,f.videoRef]);const{titlePreference:yt}=Kr(),{lowEndMode:hr}=qr(),{settings:Mt,update:fr}=gn(),vr=re&&Mt.enabled&&!hr&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,Fe=Ae(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:l,names:Z}=e.showMeta;return yt==="name"?l||"Loading...":yt==="nativeName"?Z?.native||l||"Loading...":yt==="englishName"?Z?.english||l||"Loading...":l||"Loading..."},[e.showMeta,yt,e.loadingShowData]);U(()=>{Fe&&Fe!=="Loading..."&&e.currentEpisode&&(document.title=`► ${Fe} Episode ${e.currentEpisode} - dango`)},[Fe,e.currentEpisode]),Is({onPrevious:n?()=>{}:xt,onNext:n?()=>{}:rr,onToggleTheater:he,flashControls:m.actions.flashControls});const{setAvailableSubtitles:gr,setActiveSubtitleTrack:yr}=A,Wt=Ae(()=>({fontSize:m.state.subtitleFontSize,position:m.state.subtitlePosition,bgOpacity:m.state.subtitleBgOpacity,bgColor:m.state.subtitleBgColor,textColor:m.state.subtitleTextColor,edge:m.state.subtitleEdge,bold:m.state.subtitleBold}),[m.state.subtitleFontSize,m.state.subtitlePosition,m.state.subtitleBgOpacity,m.state.subtitleBgColor,m.state.subtitleTextColor,m.state.subtitleEdge,m.state.subtitleBold]);Ks({videoRef:f.videoRef,availableSubtitles:m.state.availableSubtitles,activeSubtitleTrack:m.state.activeSubtitleTrack,setAvailableSubtitles:gr,setActiveSubtitleTrack:yr});const[br,Sr]=ne(0);U(()=>{const l=f.videoRef.current;if(!l)return;const Z=()=>Sr(l.clientHeight||0);Z();const Me=new ResizeObserver(Z);return Me.observe(l),()=>Me.disconnect()},[f.videoRef,e.selectedSource,e.selectedLink]),qs({videoRef:f.videoRef,videoBoxH:br,style:Wt,sourceKey:`${e.selectedSource?.sourceName??""}:${e.selectedLink?.link??""}`,activeSubtitleTrack:m.state.activeSubtitleTrack,availableSubtitles:m.state.availableSubtitles}),Gs({videoRef:f.videoRef,overlayRef:we,style:Wt,activeSubtitleTrack:m.state.activeSubtitleTrack,delayMs:Oe,enabled:Ge}),U(()=>{try{te.setItem("anime4kProfile",V)}catch{}},[V]);const wr=()=>{f.videoRef.current&&(f.videoRef.current.currentTime=e.resumeTime,f.videoRef.current.play()),w({type:"SET_STATE",payload:{showResumeModal:!1}})},Er=()=>{f.videoRef.current&&(f.videoRef.current.currentTime=0,f.videoRef.current.play()),w({type:"SET_STATE",payload:{showResumeModal:!1}})},kr=K(()=>{w({type:"SET_STATE",payload:{showResumeModal:!1}})},[w]),Pt=K(async()=>{try{await _(),vt(),w({type:"SET_STATE",payload:{showResumeModal:!1}}),c("/")}catch{}},[_,vt,w,c]),Ut=(l,Z)=>t("div",{className:l,children:[t("button",{className:`${b.episodeNavBtn} ${b.secondary}`,onClick:xt,disabled:n||!Je,type:"button",children:[t(ye,{name:"chevron-left",size:12}),"Prev EP"]}),t("button",{className:`${b.episodeNavBtn} ${b.primary}`,onClick:ft,disabled:n||!ge,type:"button",children:["Next EP",t(ye,{name:"chevron-right",size:12})]}),Z==="mobile"&&z&&t("button",{className:`${b.episodeNavBtn} ${b.episodePickerBtn}`,onClick:()=>ze(!0),type:"button",children:[t(ye,{name:"list-ul",size:12}),"Episodes"]})]}),Tr=l=>{w({type:"SET_STATE",payload:{isAutoplayEnabled:l}}),Mn(l)};if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return t("p",{className:"error-message",children:["Error: ",e.error]});const Re=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!a?t("div",{className:_e.playerPageLayout,children:t(Pn,{isOpen:!0,onClose:()=>c("/home"),onGrant:g})}):t("div",{className:`${_e.playerPageLayout} ${re?_e.theaterMode:""}`,onClick:Ee,children:[re&&t(yn,{videoRef:f.videoRef,active:vr,settings:Mt}),t(qt,{isOpen:ir,onClose:vt,title:"Show Completed!",heading:Fe,message:"Congratulations! You finished all available episodes.",children:t(Ne,{onClick:Pt,disabled:W,children:W?"Saving...":"Move to Completed"})}),t(qt,{isOpen:Se,onClose:()=>Q(!0),title:Ie?"Show Completed!":"Episode Completed",heading:e.currentEpisode?`Episode ${e.currentEpisode}`:Fe,message:Ie?"Congratulations! You finished all available episodes.":"You've already watched this episode. Resume where you left off, replay it, or continue with the next episode.",children:[e.resumeTime>5&&t(Ne,{variant:Ze?void 0:"secondary",onClick:qe,children:`Resume ${Qt(e.resumeTime)}`}),t(Ne,{variant:"secondary",onClick:ht,children:"Replay"}),ge&&t(Ne,{onClick:ft,children:`Watch EP ${ge}`}),Ie&&t(Ne,{onClick:Pt,disabled:W,children:W?"Saving...":"Move to Completed"})]}),t(bn,{isOpen:$t,onClose:kr,title:"Resume Playback?",message:t(at,{children:["You were watching at ",t("strong",{children:m.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:wr,onRestart:Er}),t(wt,{isOpen:!!Bt,onClose:dr,title:"Direct stream failed",width:"sm",children:[t(wt.Body,{children:[t("p",{children:[t("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),Bt?.retryFailed&&t("p",{children:"No working direct stream was found on the other providers either."}),t("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",t("strong",{children:"ads and pop-ups"}),"."]}),t("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[t("input",{type:"checkbox",checked:ar,onChange:l=>lr(l.currentTarget.checked)}),"Remember my choice"]})]}),t(wt.Actions,{children:[t(Ne,{variant:"secondary",onClick:mr,children:"Continue with iframe"}),t(Ne,{onClick:pr,disabled:Dt,children:Dt?"Searching…":"Try another provider"})]})]}),t(Gr,{isOpen:!!e.showCookieModal&&e.cookieProvider!=="mkissa",onClose:()=>w({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{d.invalidateQueries({queryKey:[ae.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),t(zs,{isOpen:!!e.showCookieModal&&e.cookieProvider==="mkissa",onClose:()=>w({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{d.invalidateQueries({queryKey:[ae.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!re&&t("aside",{ref:se,className:_e.episodeSidebar,children:e.loadingShowData?t(Sn,{variant:"sidebar"}):t(wn,{episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:l=>{n||c(`/watch/${r}/${l}`)}})}),t("div",{className:_e.playerMain,children:[t("div",{className:`${b.videoContainer} ${m.state.isFullscreen?"":_e.videoPlayerWrapper} ${m.state.isFullscreen?b.fullscreenActive:""}`,style:{...je?{visibility:"hidden"}:{}},onContextMenu:l=>l.preventDefault(),children:t(vs,{player:m,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Tr,fallbackChoice:cr,onFallbackChoiceChange:ur,ambientSettings:Mt,onAmbientChange:fr,showNextEpisodeButton:!n&&!je&&or&&He.length===0,onNextEpisode:ft,videoSources:n?[]:s?e.videoSources.filter(l=>l.type!=="iframe"&&l.links.some(Z=>Z.hls)):e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(l,Z)=>{n&&l.sourceName!==i.room?.selection.source||s&&(l.type==="iframe"||!Z.hls)||(f.videoRef.current&&!isNaN(f.videoRef.current.currentTime)&&(Ot.current=f.videoRef.current.currentTime),$(l.sourceName),M(Z.resolutionStr),w({type:"SET_STATE",payload:{selectedSource:l,selectedLink:Z,showResumeModal:e.showResumeModal&&l.type!=="iframe"}}))},loadingVideo:Re,skipIntervals:e.skipIntervals,animeTitle:Fe,episodeNumber:e.currentEpisode??void 0,mode:e.currentMode,isTheaterMode:re,onTheaterModeToggle:he,anime4kEnabled:ie.isEnabled,onAnime4kToggle:ie.toggle,anime4kSupported:ie.isWebGPUSupported,anime4kProfile:V,onAnime4kProfileChange:H,anime4kInitializing:ie.isInitializing,anime4kError:ie.error,videoDelayEnabled:k,onVideoDelayToggle:O,videoDelayMs:u,onVideoDelayChange:j,onCalibrateAvSync:s?()=>{}:Ve,isInteractingExtra:st||de,className:Zr.shellFill,hideChrome:Be||Qe||e.selectedSource?.type==="iframe",overlays:t(at,{children:[m.state.isSpeedBoostActive&&t("div",{className:b.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(ye,{name:"forward",size:12})]}),it!==null&&At?.nextItem&&t("div",{className:b.queueCountdown,children:["Queue next in ",it,"s"]})]}),children:t(at,{children:[Re&&t("div",{className:b.loadingOverlay,children:t("div",{className:b.loadingDots,children:[t("div",{className:b.dot}),t("div",{className:b.dot}),t("div",{className:b.dot})]})}),m.state.isBuffering&&!Re&&e.selectedSource?.type!=="iframe"&&t("div",{className:b.bufferingOverlay,children:t("div",{className:b.bufferingSpinner})}),e.selectedSource?.type==="iframe"&&!s?!Re&&t("iframe",{src:e.selectedLink?.link,className:b.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}):t(at,{children:[!Re&&e.videoSources.length===0&&t("div",{className:b.errorOverlay,children:[t("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),t("p",{className:b.errorSubtext,children:"Please try selecting a different provider below."}),t("button",{className:b.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Re&&e.videoSources.length>0&&t(en,{controls:!m.state.playbackLocked&&m.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:A.onPlay,onPause:A.onPause,onEnded:()=>{L||gt(!0)},onDurationChange:()=>{Lt()},onSeeked:()=>{L||(Rt(),gt())},onLoadedMetadata:()=>{Rt(),Lt(),L||gt()},onTimeUpdate:()=>{L||(A.onTimeUpdate(),Rt(),gt(),At&&f.videoRef.current&&f.videoRef.current.currentTime<f.videoRef.current.duration-1&&sr())},onError:s?void 0:It,onContextMenu:l=>l.preventDefault(),className:Ge?b.videoElementHidden:""}),ie.isWebGPUSupported&&!Re&&e.videoSources.length>0&&t("canvas",{ref:F,className:`${b.upscalerCanvas} ${De?b.upscalerActive:""}`}),!De&&!Re&&e.videoSources.length>0&&t("canvas",{ref:tt,className:`${b.upscalerCanvas} ${nt?b.upscalerActive:""}`}),ie.isEnabled&&ie.isWebGPUSupported&&ie.isInitializing&&t("div",{className:b.upscalerStatusBadge,children:"Preparing upscaler…"}),Ge&&t("div",{ref:we,className:b.subtitleOverlay}),t(En,{isOpen:de,ms:u,onChange:j,onApply:oe,onClose:X,testClipActive:L,onTestClip:$e})]}),(Be||Qe)&&t("div",{className:b.watchedOverlay,children:[t(ye,{name:"check-circle",size:48,style:{color:"var(--accent-lighter)"}}),t("p",{className:b.watchedTitle,children:Ie?"Show Completed!":e.currentEpisode?`Episode ${e.currentEpisode} watched`:"Watched"}),t("p",{className:b.watchedSubtext,children:Ie?"Congratulations! You finished all available episodes.":"Resume where you left off, replay from the beginning, or continue with the next episode."}),t("div",{className:`${b.watchedActions} ${Qe?b.watchedActionsCentered:""}`,children:[t("div",{children:e.resumeTime>5&&!Qe&&t(Ne,{variant:Ze?void 0:"secondary",onClick:qe,children:`Resume ${Qt(e.resumeTime)}`})}),t("div",{children:[ge&&t(Ne,{onClick:ft,children:`Watch EP ${ge}`}),Ie&&t(Ne,{onClick:Pt,disabled:W,children:W?"Saving...":"Move to Completed"})]}),t("div",{children:t(Ne,{variant:"secondary",onClick:()=>{vt(),ht()},children:"Replay"})})]})]})]})})}),t(Bn,{playback:Y&&!Re?{selection:Y,position:f.videoRef.current?.currentTime||0,playing:!1,rate:m.engine.getState().playbackRate}:null,onCreate:()=>{be(),m.engine.pause()},needsPlayback:x.needsPlayback,onEnablePlayback:x.enablePlayback}),s&&!Re&&!Y&&t("p",{role:"alert",children:"This room requires the host's direct HLS source. It is unavailable here. Retry the episode or leave the room to use another source."}),!re&&t(kn,{}),!re&&t(at,{children:[t("div",{className:b.streamPanel,children:[!n&&t(ws,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:v,onProviderChange:l=>{Ft(),w({type:"SET_STATE",payload:{selectedProvider:l,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),er(l,e.showMeta?.isAdult===!0)}}),Ut(`${b.episodeActions} ${b.desktopEpisodeActions}`,"desktop"),Re?t("div",{className:b.sourceLoader,children:t("div",{className:b.spinner})}):n?t("p",{children:["Provider: ",e.selectedProvider," · Source: ",i.room?.selection.source," ·"," ",e.currentMode]}):t(ks,{videoSources:s?e.videoSources.filter(l=>l.type!=="iframe"&&l.links.some(Z=>Z.hls)):e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:l=>{if(s&&(l.type==="iframe"||!l.links.some(xe=>xe.hls)))return;f.videoRef.current&&!isNaN(f.videoRef.current.currentTime)&&(Ot.current=f.videoRef.current.currentTime);const Me=(s?l.links.filter(xe=>xe.hls):l.links||[]).sort((xe,Pe)=>(parseInt(Pe.resolutionStr)||0)-(parseInt(xe.resolutionStr)||0))[0]||null;$(l.sourceName),w({type:"SET_STATE",payload:{selectedSource:l,selectedLink:Me,showResumeModal:e.showResumeModal&&l.type!=="iframe"}})},onLinkChange:l=>{e.selectedSource&&($(e.selectedSource.sourceName),M(l.resolutionStr),w({type:"SET_STATE",payload:{selectedLink:l}}))}})]}),Ct&&He.length===0?t(gs,{count:3}):t(_n,{title:"Queue",items:He,currentShowId:r,currentEpisode:e.currentEpisode??void 0,onNextQueue:n?()=>{}:tr,onRemove:l=>J.mutate({showId:l.showId,episodeNumber:l.episodeNumber}),onClear:()=>me.mutate(),showClearAll:!0,onReorder:l=>Te.mutate(l.map(Z=>({id:Z.id,showId:Z.showId,episodeNumber:Z.episodeNumber})))}),t("div",{className:_e.playerInfoContainer,children:[t("div",{className:_e.playerInfoHeader,children:[t("div",{className:_e.playerAnimeCard,children:t(zr,{src:Hr(e.showMeta.thumbnail||""),alt:Fe,loading:"lazy",decoding:"async",onError:l=>{l.target.src="/placeholder.svg"}})}),t("div",{className:_e.videoTitleSection,children:[t("div",{className:b.titleContainer,children:[t("h1",{children:Fe}),t("div",{className:b.scheduleInfo,children:[e.showMeta.status&&t("span",{className:b.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&(()=>{const l=e.showMeta.nextAiring,Z=I!=null?I*1e3:null;let Me="";if(Z!=null){let Pe=Math.floor((Z-q)/1e3);if(Pe<=0)return null;const Cr=Math.floor(Pe/86400);Pe%=86400;const Rr=Math.floor(Pe/3600);Pe%=3600;const Mr=Math.floor(Pe/60),Pr=Pe%60;Me=`in ${Cr}d ${Rr}h ${String(Mr).padStart(2,"0")}m ${String(Pr).padStart(2,"0")}s`}const xe=l?.episode!=null?`E${l.episode} · `:"";return t("span",{className:b.nextEpisode,children:["Next episode: ",xe,e.showMeta.nextEpisodeAirDate,Me?` · ${Me}`:""]})})()]})]}),t("div",{className:b.controls,children:[t("button",{className:`${b.watchlistBtn} ${e.inWatchlist?b.inList:""}`,onClick:T,children:[e.inWatchlist?t(ye,{name:"check",size:14}):t(ye,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),t(xn,{showId:r,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:`${b.watchlistBtn} ${b.queueBtn}`,activeClassName:b.queueActive}),t("button",{className:`${b.watchlistBtn} ${b.modeToggleBtn} ${e.currentMode==="dub"?b.modeToggleActive:""}`,disabled:n,onClick:()=>{const l=e.currentMode==="dub"?"sub":"dub";Ft(),w({type:"SET_MODE",payload:l}),te.setItem("preferredMode",l)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),t("button",{className:`${b.watchlistBtn} ${b.modeToggleBtn}`,onClick:()=>e.currentEpisode&&P(e.currentEpisode),disabled:R||!e.currentEpisode,type:"button",children:[t(ye,{name:"undo",size:14}),R?"Resetting...":"Reset Progress"]})]})]})]}),Ut(`${b.episodeActions} ${b.mobileEpisodeActions}`,"mobile"),t("div",{className:_e.infoColumns,children:[t("div",{className:`${b.descriptionSection} ${b.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t($n,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."}),t("button",{className:b.detailsToggleBtn,onClick:h,children:[e.showCombinedDetails?t(ye,{name:"chevron-up"}):t(ye,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]})]}),e.showCombinedDetails&&t(Ln,{showMeta:e.showMeta,styles:b})]})]})]})]}),t(Tn,{isOpen:st,onClose:()=>ze(!1),episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:l=>{ze(!1),c(`/watch/${r}/${l}`)}})]})};export{mo as default};
@@ -1 +0,0 @@
1
- import{X as Se,x as Le,u as m,A,q as be,h as X,d as oe,T as me,_ as Fe,C as ve}from"./vendor-core-DfaOB3Rn.js";import{I as re}from"./vendor-icons-C1Pj_eSX.js";import{a3 as ke,p as ge,h as he}from"./index-BkgRRmBf.js";const Ee=Se(null);function q(){const n=Le(Ee);if(!n)throw new Error("Player controls must be inside a PlayerProvider.");return n}function we(n,r){const t=q(),a=A(r);a.current=r;const l=n?.url,p=n?.hls,s=be(k=>{t.mediaRef.current=k,t.connect()},[t]);return X(()=>{if(l)return t.loadSource({url:l,hls:p},a.current)},[t,l,p]),s}function rt({source:n,sourceOptions:r,...t}){const a=we(n,r);return m("video",{playsInline:!0,...t,ref:a})}function at({source:n,sourceOptions:r,...t}){const a=we(n,r);return m("audio",{...t,ref:a})}const _e="_shell_qjnah_1",Me="_stage_qjnah_38",Re="_topBarTitleInfo_qjnah_59",xe="_streamDetails_qjnah_65",Ce="_modeTag_qjnah_86",Ae="_shellFill_qjnah_122",Be="_shellFullscreen_qjnah_130",De="_uiLayer_qjnah_145",Ie="_engineStatus_qjnah_156",$e="_volumeWrap_qjnah_169",Ne="_volumeSlider_qjnah_175",pe={shell:_e,stage:Me,topBarTitleInfo:Re,streamDetails:xe,modeTag:Ce,shellFill:Ae,shellFullscreen:Be,uiLayer:De,engineStatus:Ie,volumeWrap:$e,volumeSlider:Ne},qe=({classes:n,videoRef:r,duration:t,formatTime:a,isScrubbing:l,buffered:p="auto",onSeek:s,onScrubStart:k,onScrubMove:v,onScrubEnd:M,timeLabelRef:E,children:w})=>{const y=A(null),L=A(null),S=A(null),g=A(null),T=A(null),f=A(!1),u=A(l);u.current=l;const b=A({onScrubMove:v,onScrubEnd:M});b.current={onScrubMove:v,onScrubEnd:M};const[N,C]=oe({time:0,position:null});X(()=>{const c=r.current;if(!c)return;const d=D=>{const V=D/t*100||0;y.current?.setAttribute("aria-valuenow",String(Math.round(D))),y.current?.setAttribute("aria-valuetext",`${a(D)} of ${a(t)}`),L.current&&(L.current.style.width=`${V}%`),S.current&&(S.current.style.left=`${V}%`),E?.current&&(E.current.innerText=`${a(D)} / ${a(t)}`)},x=()=>{l||d(c.currentTime)},B=()=>{if(p==="auto"&&c.buffered.length>0){const V=c.buffered.end(c.buffered.length-1)/t*100||0;g.current&&(g.current.style.width=`${V}%`)}};return d(c.currentTime),B(),c.addEventListener("timeupdate",x),c.addEventListener("progress",B),()=>{c.removeEventListener("timeupdate",x),c.removeEventListener("progress",B)}},[r,t,l,p,a,E]);const O=c=>{if(!y.current)return 0;const d=y.current.getBoundingClientRect();return d.width<=0?0:Math.min(1,Math.max(0,(c-d.left)/d.width))},Q=c=>{const d=c*t;y.current?.setAttribute("aria-valuenow",String(Math.round(d))),y.current?.setAttribute("aria-valuetext",`${a(d)} of ${a(t)}`);const x=d/t*100||0;L.current&&(L.current.style.width=`${x}%`),S.current&&(S.current.style.left=`${x}%`),E?.current&&(E.current.innerText=`${a(d)} / ${a(t)}`);const B=y.current?.getBoundingClientRect();C({time:d,position:B?c*B.width:null})};X(()=>{if(!l){T.current=null;return}const c=x=>{if(T.current!==null&&x.pointerId!==T.current||!t)return;const B=O(x.clientX);b.current.onScrubMove(B);const D=B*t;y.current?.setAttribute("aria-valuenow",String(Math.round(D))),y.current?.setAttribute("aria-valuetext",`${a(D)} of ${a(t)}`);const V=D/t*100||0;L.current&&(L.current.style.width=`${V}%`),S.current&&(S.current.style.left=`${V}%`),E?.current&&(E.current.innerText=`${a(D)} / ${a(t)}`);const ee=y.current?.getBoundingClientRect();C({time:D,position:ee?B*ee.width:null})},d=x=>{T.current!==null&&x.pointerId!==T.current||(T.current=null,f.current=!0,x.pointerType!=="mouse"&&C({time:0,position:null}),b.current.onScrubEnd())};return document.addEventListener("pointermove",c),document.addEventListener("pointerup",d),document.addEventListener("pointercancel",d),()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",d),document.removeEventListener("pointercancel",d)}},[l,t,a,E]);const J=c=>{if(c.pointerType==="mouse"&&c.button!==0||!r.current||!t)return;c.preventDefault(),T.current=c.pointerId;try{y.current?.setPointerCapture(c.pointerId)}catch{}u.current||(u.current=!0,k());const d=O(c.clientX);v(d),Q(d)},ae=c=>{if(!t||u.current||c.pointerType!=="mouse")return;const d=O(c.clientX);C({time:d*t,position:c.clientX-(y.current?.getBoundingClientRect().left??0)})},G=c=>{if(!(T.current!==null&&c.pointerId!==T.current)&&u.current){T.current=null,f.current=!0,c.pointerType!=="mouse"&&C({time:0,position:null});try{y.current?.hasPointerCapture(c.pointerId)&&y.current.releasePointerCapture(c.pointerId)}catch{}M()}};return m("div",{className:`${n.container} ${l&&n.scrubbing?n.scrubbing:""}`,ref:y,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.round(t||0),"aria-valuenow":Math.round(r.current?.currentTime||0),"aria-disabled":!t,tabIndex:0,onClick:c=>{if(f.current){f.current=!1;return}!r.current||isNaN(t)||t===0||s(O(c.clientX))},onPointerDown:J,onPointerMove:ae,onPointerUp:G,onPointerCancel:G,onMouseMove:c=>{if(l||!t)return;const d=O(c.clientX);C({time:d*t,position:c.clientX-(y.current?.getBoundingClientRect().left??0)})},onMouseLeave:()=>{l||C({time:0,position:null})},onKeyDown:c=>{if(!(!r.current||!t)&&((c.key==="Home"||c.key==="End")&&(c.preventDefault(),s(c.key==="Home"?0:1)),c.key==="ArrowRight"||c.key==="ArrowLeft")){c.preventDefault();const d=(c.key==="ArrowRight"?5:-5)/t,x=r.current.currentTime/t||0;s(Math.min(1,Math.max(0,x+d)))}},children:[N.position!==null&&m("div",{className:n.timeBubble,style:{left:N.position},children:a(N.time)}),m("div",{className:n.bar,children:[m("div",{className:n.buffered,ref:g,style:p==="full"?{width:"100%"}:void 0}),m("div",{className:n.watched,ref:L}),m("div",{className:n.thumb,ref:S,onMouseDown:c=>{c.preventDefault(),r.current&&(u.current||k())}}),w]})]})};function le(){try{if(typeof window>"u")return!1;const n=window.matchMedia?.("(pointer: coarse)").matches??!1,t=(navigator.maxTouchPoints??0)>0||"ontouchstart"in window;return n||t}catch{return!1}}function Ve(){const[n,r]=oe(le);return X(()=>{r(le());let t=null;const a=()=>r(le());try{t=window.matchMedia("(pointer: coarse)"),t.addEventListener?t.addEventListener("change",a):t.addListener(a)}catch{}return window.addEventListener("touchstart",a,{passive:!0,once:!0}),()=>{try{t&&(t.removeEventListener?t.removeEventListener("change",a):t.removeListener(a))}catch{}window.removeEventListener("touchstart",a)}},[]),n}const je=450,He=({muted:n,volume:r,volumeIcon:t,buttonClassName:a,sliderClassName:l,onToggleMute:p,onVolumeChange:s,onExpandedChange:k})=>{const v=Ve(),[M,E]=oe(!1),w=A(null),y=A(!1),L=A(null),S=be(b=>{E(b),k?.(b)},[k]);X(()=>()=>{w.current&&window.clearTimeout(w.current)},[]),X(()=>{if(!M)return;const b=N=>{L.current&&!L.current.contains(N.target)&&S(!1)};return document.addEventListener("pointerdown",b),()=>document.removeEventListener("pointerdown",b)},[M,S]);const g=n?0:r,T=()=>{y.current=!1,w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{y.current=!0,S(!0)},je)},f=()=>{w.current&&(window.clearTimeout(w.current),w.current=null)},u=b=>{if(b.stopPropagation(),y.current){y.current=!1;return}if(v){M?p():S(!0);return}p()};return m("div",{ref:L,className:pe.volumeWrap,"data-expanded":M?"true":"false",onContextMenu:b=>b.preventDefault(),children:[m("button",{type:"button",className:a,onClick:u,onPointerDown:T,onPointerUp:f,onPointerLeave:f,onContextMenu:b=>b.preventDefault(),"aria-label":n?"Unmute":"Mute","aria-expanded":M,children:t}),m("input",{type:"range",min:"0",max:"1",step:"0.05",value:g,onChange:b=>s(parseFloat(b.currentTarget.value)),onClick:b=>b.stopPropagation(),onPointerDown:b=>b.stopPropagation(),onContextMenu:b=>b.preventDefault(),className:`${pe.volumeSlider} ${l??""}`,style:{"--volume-percent":`${g*100}%`},"aria-label":"Volume"})]})};let te=null,ue=null;async function Ue(){return te||(ue||(ue=ke(()=>import("./hls-BOLXTnjL.js"),[]).then(n=>(te=n.default,te)).catch(()=>null)),ue)}function Ke(n){return n.canPlayType("application/vnd.apple.mpegurl")!==""||n.canPlayType("application/x-mpegURL")!==""}let ne=null,ce=null;async function Oe(){return ne||(ce||(ce=ke(()=>import("./dash.all.min-CsDAls03.js"),[]).then(n=>(ne=We(n),ne)).catch(()=>null)),ce)}function We(n){const r=n,t=r?.default?.MediaPlayer??r?.MediaPlayer??r?.default;return typeof t!="function"?null:{MediaPlayer:t}}function se(){return document}function fe(n){const r=se();if(document.fullscreenElement)return document.fullscreenElement;if(r.webkitFullscreenElement)return r.webkitFullscreenElement;const t=n;return t?.webkitDisplayingFullscreen?t:null}function Te(n){return fe(n)!==null}async function Xe(n,r){if(fe(r))return;const t=n;try{if(typeof n.requestFullscreen=="function"){await n.requestFullscreen();return}if(typeof t.webkitRequestFullscreen=="function"){await t.webkitRequestFullscreen();return}if(typeof t.webkitRequestFullScreen=="function"){await t.webkitRequestFullScreen();return}}catch{}const a=r;if(a&&typeof a.webkitEnterFullscreen=="function"){if(a.webkitSupportsFullscreen===!1)return;try{await a.webkitEnterFullscreen()}catch{}}}async function Qe(n){const r=se();try{if(document.fullscreenElement&&typeof document.exitFullscreen=="function"){await document.exitFullscreen();return}if(r.webkitFullscreenElement&&typeof r.webkitExitFullscreen=="function"){await r.webkitExitFullscreen();return}}catch{}const t=n;if(t?.webkitDisplayingFullscreen&&typeof t.webkitExitFullscreen=="function"){try{t.webkitExitFullscreen()}catch{}return}try{typeof r.webkitCancelFullScreen=="function"?r.webkitCancelFullScreen():!document.fullscreenElement&&typeof document.exitFullscreen=="function"&&(document.fullscreenElement??r.webkitFullscreenElement)&&await document.exitFullscreen()}catch{}}async function Ge(n,r){!n&&!r||(Te(r)?await Qe(r):n&&await Xe(n,r))}function ze(n,r){const t=()=>{try{r(Te(n()))}catch{}},a=se(),l=t;a.addEventListener("fullscreenchange",t),a.addEventListener("webkitfullscreenchange",l),a.addEventListener("webkitbeginfullscreen",l,!0),a.addEventListener("webkitendfullscreen",l,!0);const p=n();return p?.addEventListener("webkitbeginfullscreen",l),p?.addEventListener("webkitendfullscreen",l),()=>{a.removeEventListener("fullscreenchange",t),a.removeEventListener("webkitfullscreenchange",l),a.removeEventListener("webkitbeginfullscreen",l,!0),a.removeEventListener("webkitendfullscreen",l,!0),p?.removeEventListener("webkitbeginfullscreen",l),p?.removeEventListener("webkitendfullscreen",l)}}let U=null;function ye(n){try{return n?ge.getItem(n):null}catch{return null}}function Z(n,r){try{n&&ge.setItem(n,String(r))}catch{}}function Je(n={}){const r=Number.parseFloat(ye(n.volumeKey)??"");let t={isPlaying:!1,isBuffering:!1,isMuted:ye(n.mutedKey)==="true",volume:Number.isFinite(r)?Math.max(0,Math.min(1,r)):1,duration:0,playbackRate:1,isScrubbing:!1,isFullscreen:!1,showControls:!0,isSpeedBoostActive:!1,audioTracks:[],subtitleTracks:[],qualities:[],activeAudioTrack:-1,activeSubtitleTrack:-1,activeQuality:-1,error:null,playBlocked:!1,playbackLocked:!1},a={currentTime:0,bufferedEnd:0};const l=new Set,p=new Set,s={current:null},k={current:null};let v=null,M=()=>{},E=()=>{},w=0,y=!1,L=1,S=!1,g=null,T=null,f=!1;function u(e){Object.entries(e).every(([i,o])=>Object.is(t[i],o))||(t={...t,...e},l.forEach(i=>i()))}function b(e){a.currentTime===e.currentTime&&a.bufferedEnd===e.bufferedEnd||(a=e,p.forEach(i=>i()))}function N(e){if(!e)return;let i=0;for(let o=0;o<e.buffered.length;o++)if(e.buffered.start(o)<=e.currentTime&&e.buffered.end(o)>=e.currentTime){i=e.buffered.end(o);break}b({currentTime:Number.isFinite(e.currentTime)?e.currentTime:0,bufferedEnd:i})}function C(){N(s.current)}function O(){const e=s.current;if(v===e||(v&&(U===v&&(U=e),N(v),E(),v.pause(),v.removeAttribute("src"),v.load()),M(),v=e,!e))return;S=!1,U||(U=e),e.volume=t.volume,e.muted=t.isMuted,e.playbackRate=t.playbackRate;const i=()=>{const h=Array.from(e.textTracks);if(!h.length)return;const j=h.findIndex(H=>H.mode==="showing");u({subtitleTracks:h.map((H,z)=>({id:z,label:H.label||H.language||`Track ${z+1}`,language:H.language})),...j>=0?{activeSubtitleTrack:j}:{}})},o={play:()=>{U=e,u({isPlaying:!0,playBlocked:!1,error:null})},playing:()=>u({isPlaying:!0,isBuffering:!1,playBlocked:!1}),pause:()=>u({isPlaying:!1,isBuffering:!1}),ended:()=>{u({isPlaying:!1,isBuffering:!1}),C()},waiting:()=>{!e.paused&&(e.readyState<3||e.seeking)&&u({isBuffering:!0})},canplay:()=>u({isBuffering:!1}),seeking:()=>{e.paused||u({isBuffering:!0}),C()},seeked:()=>{u({isBuffering:!1}),C()},timeupdate:()=>{C(),!e.paused&&!e.seeking&&u({isBuffering:!1})},progress:C,loadedmetadata:()=>{e.playbackRate=t.playbackRate,u({duration:Number.isFinite(e.duration)?e.duration:0}),i()},durationchange:()=>u({duration:Number.isFinite(e.duration)?e.duration:0}),ratechange:()=>{t.isSpeedBoostActive||(L=e.playbackRate),e.defaultPlaybackRate!==e.playbackRate&&(e.defaultPlaybackRate=e.playbackRate),u({playbackRate:e.playbackRate})},volumechange:()=>{u({volume:e.volume,isMuted:e.muted}),Z(n.volumeKey,e.volume),Z(n.mutedKey,e.muted)},error:()=>u({error:e.error?.message||"Unable to play this source.",isPlaying:!1,isBuffering:!1})};Object.entries(o).forEach(([h,j])=>e.addEventListener(h,j)),e.textTracks.addEventListener("addtrack",i),e.textTracks.addEventListener("removetrack",i),e.textTracks.addEventListener("change",i);const F=()=>e.tagName==="VIDEO"?e:null,W=()=>{const h=fe(F());u({isFullscreen:h!==null&&(h===e||h===k.current)})},I=typeof document>"u"?()=>{}:ze(F,W);typeof document<"u"&&W(),M=()=>{Object.entries(o).forEach(([h,j])=>e.removeEventListener(h,j)),I(),e.textTracks.removeEventListener("addtrack",i),e.textTracks.removeEventListener("removetrack",i),e.textTracks.removeEventListener("change",i)}}async function Q(){if(t.playbackLocked&&!f)return!1;const e=s.current;if(!e)return!1;U=e;const i=w;try{return await e.play(),i===w}catch(o){if(i===w){const F=o instanceof Error&&o.name==="NotAllowedError",W=o instanceof Error&&o.name==="AbortError";u({isPlaying:!1,isBuffering:!1,playBlocked:F,...!F&&!W?{error:o instanceof Error?o.message:"Playback failed."}:{}})}return!1}}function J(){t.playbackLocked&&!f||s.current?.pause()}function ae(){s.current?.paused?Q():J()}function G(e){if(t.playbackLocked&&!f)return;const i=s.current;if(!i||!Number.isFinite(e))return;let o=Math.max(0,e);if(Number.isFinite(i.duration))o=Math.min(i.duration,o);else if(i.seekable.length)for(let F=0;F<i.seekable.length;F++){if(o<=i.seekable.end(F)){o=Math.max(i.seekable.start(F),o);break}F===i.seekable.length-1&&(o=i.seekable.end(F))}i.currentTime=o,C()}function c(e){G((s.current?.currentTime??a.currentTime)+e)}function d(e){if(!Number.isFinite(e))return;const i=Math.max(0,Math.min(1,e));u({volume:i,isMuted:i===0}),s.current&&(s.current.volume=i,s.current.muted=i===0),Z(n.volumeKey,i),Z(n.mutedKey,i===0)}function x(){const e=!t.isMuted;!e&&t.volume===0&&d(.5),u({isMuted:e}),s.current&&(s.current.muted=e),Z(n.mutedKey,e)}function B(e){if(t.playbackLocked&&!f||!Number.isFinite(e)||e<.25||e>4)return;L=e;const i=t.isSpeedBoostActive?2:e;u({playbackRate:i}),s.current&&(s.current.playbackRate=i)}function D(){t.playbackLocked||t.isScrubbing||(y=!!s.current&&!s.current.paused,u({isScrubbing:!0}),J())}function V(){t.isScrubbing&&(u({isScrubbing:!1}),y&&Q(),y=!1)}function ee(e,i={}){E(),O();const o=s.current,F=++w;if(!o)return()=>{};let W=!1,I=null;const h=()=>!W&&w===F&&s.current===o;o.pause(),o.removeAttribute("src"),o.load(),u({duration:0,isPlaying:!1,isBuffering:!0,isScrubbing:!1,error:null,playBlocked:!1,audioTracks:[],subtitleTracks:[],qualities:[],activeAudioTrack:-1,activeSubtitleTrack:-1,activeQuality:-1}),b({currentTime:0,bufferedEnd:0});const j=()=>{h()&&i.initialTime&&i.initialTime>0&&G(i.initialTime)};o.addEventListener("loadedmetadata",j,{once:!0});const H=()=>{h()&&(i.onReady?.(),i.autoPlay&&h()&&Q())},z=P=>{if(!h())return;const R=P instanceof Error?P:new Error(String(P));u({error:R.message,isPlaying:!1,isBuffering:!1}),i.onError?.(R)},Y=()=>{W||(W=!0,o.removeEventListener("loadedmetadata",j),o.removeEventListener("error",de),I?.destroy(),g===I&&(g=null),I=null,T?.destroy(),T=null,w===F&&w++)},de=()=>{z(new Error(o.error?.message||"Unable to play this source.")),Y()};return o.addEventListener("error",de),E=Y,(async()=>{if(e.dash){const P=await Oe();if(!h())return;if(!P)throw new Error("DASH playback is unavailable in this browser.");const R=P.MediaPlayer().create();if(T=R,R.on("streamActivated",H),R.on("error",ie=>{const _=ie,$=_?.error?.message||_?.message||"DASH stream failed.";z(new Error($)),Y()}),!h())return;i.onDash?.(R),R.initialize(o,e.url);return}if(e.hls){const P=await Ue();if(!h())return;if(P?.isSupported()){I=new P({enableWorker:!0,startPosition:i.initialTime??-1,...i.hlsConfig}),g=I;const R=I,ie=()=>{h()&&u({audioTracks:R.audioTracks.map((_,$)=>({id:$,label:_.name||_.lang||`Track ${$+1}`,language:_.lang})),...o.querySelector("track")?{}:{subtitleTracks:R.subtitleTracks.map((_,$)=>({id:$,label:_.name||_.lang||`Track ${$+1}`,language:_.lang}))},qualities:R.levels.map((_,$)=>({id:$,label:_.height?`${_.height}p`:`${Math.round(_.bitrate/1e3)}k`})),activeAudioTrack:R.audioTrack,...o.querySelector("track")?{}:{activeSubtitleTrack:R.subtitleTrack},activeQuality:R.currentLevel})};for(const _ of[P.Events.MANIFEST_PARSED,P.Events.AUDIO_TRACKS_UPDATED,P.Events.AUDIO_TRACK_SWITCHED,P.Events.SUBTITLE_TRACKS_UPDATED,P.Events.SUBTITLE_TRACK_SWITCH,P.Events.LEVEL_SWITCHED])R.on(_,ie);if(I.on(P.Events.ERROR,(_,$)=>{$.fatal&&h()&&(z(new Error(`Stream failed (${$.details}). Try another source or reload.`)),Y())}),I.once(P.Events.MANIFEST_PARSED,H),i.onHls?.(I,P),!h())return;I.loadSource(e.url),I.attachMedia(o);return}if(!Ke(o))throw new Error("HLS playback is unavailable in this browser.")}h()&&(o.src=e.url,o.load(),H())})().catch(P=>{z(P),Y()}),Y}return{mediaRef:s,containerRef:k,connect:O,getState:()=>t,getTimeline:()=>a,getHls:()=>g,isActive:()=>U===s.current,subscribe:e=>(l.add(e),()=>{l.delete(e)}),subscribeTimeline:e=>(p.add(e),()=>{p.delete(e)}),play:Q,pause:J,togglePlay:ae,seek:G,seekRelative:c,setVolume:d,toggleMute:x,setPlaybackRate:B,setPlaybackLocked:e=>u({playbackLocked:e}),applyRemotePlayback:(e,i,o)=>{f=!0;try{e!==void 0&&G(e),Math.abs(t.playbackRate-o)>.001&&B(o),i&&s.current?.paused?Q():!i&&!s.current?.paused&&J()}finally{f=!1}},setAudioTrack:e=>{g&&t.audioTracks.some(i=>i.id===e)&&(g.audioTrack=e,u({activeAudioTrack:e}))},setSubtitleTrack:e=>{if(e!==-1&&!t.subtitleTracks.some(o=>o.id===e))return;const i=s.current;i?.querySelector("track")?Array.from(i.textTracks).forEach((o,F)=>{o.mode=F===e?"showing":"disabled"}):g&&(g.subtitleTrack=e),u({activeSubtitleTrack:e})},setQuality:e=>{g&&(e===-1||t.qualities.some(i=>i.id===e))&&(g.currentLevel=e,u({activeQuality:e}))},setSpeedBoost:e=>{if(t.playbackLocked)return;const i=e?2:L;u({isSpeedBoostActive:e,playbackRate:i}),s.current&&(s.current.playbackRate=i)},setShowControls:e=>u({showControls:e}),startScrubbing:D,endScrubbing:V,loadSource:ee,unload:()=>{const e=s.current;N(e),E(),e&&(e.pause(),e.removeAttribute("src"),e.load()),u({isPlaying:!1,isBuffering:!1,duration:0,error:null}),b({currentTime:0,bufferedEnd:0})},toggleFullscreen:()=>{const e=s.current;Ge(k.current,e?.tagName==="VIDEO"?e:null).catch(i=>u({error:i instanceof Error?i.message:"Fullscreen failed."}))},reset:()=>{u({duration:0,isBuffering:!1,error:null}),b({currentTime:0,bufferedEnd:0})},destroy:()=>{if(S)return;S=!0;const e=v??s.current;N(e),M(),v=null,E(),e?.pause(),e?.removeAttribute("src"),e?.load(),U===e&&(U=null)}}}function K(n){return ve(n.subscribe,n.getState)}function Pe(n){return ve(n.subscribeTimeline,n.getTimeline)}function it(n={}){const r=A(n),t=me(()=>Je(r.current),[]);return Fe(()=>{t.connect()}),X(()=>()=>t.destroy(),[t]),me(()=>({engine:t,mediaRef:t.mediaRef}),[t])}function Ye({children:n,...r}){const t=q(),{isPlaying:a,playbackLocked:l}=K(t);return m("button",{type:"button","aria-label":a?"Pause":"Play",...r,disabled:l||r.disabled,onClick:t.togglePlay,children:n??m(re,{name:a?"pause":"play"})})}function lt({seconds:n,children:r,...t}){const a=q(),{playbackLocked:l}=K(a);return m("button",{type:"button","aria-label":`Seek ${n<0?"back":"forward"} ${Math.abs(n)} seconds`,...t,disabled:l||t.disabled,onClick:()=>a.seekRelative(n),children:r??m(re,{name:n<0?"replay-10":"forward-10"})})}function ut(n){const r=q(),{isFullscreen:t}=K(r);return m("button",{type:"button","aria-label":t?"Exit Fullscreen":"Fullscreen",...n,onClick:r.toggleFullscreen,children:m(re,{name:t?"compress":"expand"})})}function ct({buttonClassName:n,onExpandedChange:r}){const t=q(),{isMuted:a,volume:l}=K(t);return m(He,{muted:a,volume:l,volumeIcon:m(re,{name:a||l===0?"volume-mute":l<.5?"volume-down":"volume-up"}),buttonClassName:n,onToggleMute:t.toggleMute,onVolumeChange:t.setVolume,onExpandedChange:r})}function ot({className:n}){const r=q(),{volume:t,isMuted:a}=K(r);return m("input",{type:"range",min:0,max:1,step:.01,value:a?0:t,onChange:l=>r.setVolume(Number(l.currentTarget.value)),className:n,style:{"--volume-percent":`${(a?0:t)*100}%`},"aria-label":"Volume"})}function st({classes:n,timeLabelRef:r,children:t}){const a=q(),{duration:l,isScrubbing:p,playbackLocked:s}=K(a);return m("div",{inert:s||void 0,style:{display:"contents"},children:m(qe,{classes:n,videoRef:a.mediaRef,duration:l,formatTime:he,isScrubbing:p,onSeek:k=>a.seek(k*l),onScrubStart:a.startScrubbing,onScrubMove:k=>a.seek(k*l),onScrubEnd:a.endScrubbing,timeLabelRef:r,children:t})})}function ft({className:n}){const r=q(),{currentTime:t,bufferedEnd:a}=Pe(r),{duration:l,playbackLocked:p}=K(r),s=l?Math.min(100,t/l*100):0,k=l?Math.min(100,Math.max(s,a/l*100)):0;return m("input",{type:"range",disabled:p,min:0,max:l,step:.1,value:Math.min(t,l),onChange:v=>r.seek(Number(v.currentTarget.value)),onPointerDown:v=>{v.currentTarget.setPointerCapture(v.pointerId),r.startScrubbing()},onPointerUp:r.endScrubbing,onPointerCancel:r.endScrubbing,onLostPointerCapture:r.endScrubbing,className:n,style:{"--played-percent":`${s}%`,"--buffered-percent":`${k}%`},"aria-label":"Seek"})}function dt({className:n,durationOnly:r=!1}){const t=q(),{currentTime:a}=Pe(t),{duration:l}=K(t);return m("span",{className:n,children:he(r?l:a)})}function mt(){const n=q(),{error:r,playBlocked:t,isBuffering:a,playbackLocked:l}=K(n);return r?m("div",{role:"alert",children:r}):t&&l?m("span",{children:"Enable playback from the watch-along panel."}):t?m(Ye,{children:"Tap to play"}):a?m("div",{role:"status","aria-label":"Buffering",children:"Loading…"}):null}const Ze='input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable]:not([contenteditable="false"]), [data-player-ui="true"], [data-speed-boost-ignore="true"]';function pt(n,r,t=!0){const a=A(r);a.current=r,X(()=>{if(!t)return;let l=!1,p=!1,s=!1,k,v,M=!1;const E=()=>{const f=p||s;f!==M&&(M=f,n.setSpeedBoost(f))},w=f=>f instanceof Element&&!!f.closest(Ze),y=f=>{if(!n.isActive()||!n.mediaRef.current||f.defaultPrevented||f.ctrlKey||f.metaKey||f.altKey||w(f.target))return;if(f.code==="Space"){if(f.preventDefault(),l)return;l=!0,k=setTimeout(()=>{k=void 0,p=!0,E()},180),a.current();return}const u=f.key.toLowerCase();["k","j","l","arrowleft","arrowright","arrowup","arrowdown","m","f"].includes(u)&&(f.preventDefault(),!(f.repeat&&["k","m","f"].includes(u))&&(u==="k"&&n.togglePlay(),(u==="j"||u==="arrowleft")&&n.seekRelative(-10),(u==="l"||u==="arrowright")&&n.seekRelative(10),u==="arrowup"&&n.setVolume(n.getState().volume+.1),u==="arrowdown"&&n.setVolume(n.getState().volume-.1),u==="m"&&n.toggleMute(),u==="f"&&n.toggleFullscreen(),a.current()))},L=f=>{f.code!=="Space"||!l||(f.preventDefault(),l=!1,clearTimeout(k),k=void 0,p?(p=!1,E()):n.togglePlay(),a.current())},S=f=>{const u=f.target;f.button!==0||!(u instanceof Element)||w(u)||!n.containerRef.current?.contains(u)||(clearTimeout(v),v=setTimeout(()=>{v=void 0,s=!0,E()},180))},g=()=>{clearTimeout(v),v=void 0,s=!1,E()},T=()=>{clearTimeout(k),k=void 0,l=!1,p=!1,g()};return document.addEventListener("keydown",y),document.addEventListener("keyup",L),document.addEventListener("pointerdown",S),document.addEventListener("pointerup",g),document.addEventListener("pointercancel",g),window.addEventListener("blur",T),()=>{document.removeEventListener("keydown",y),document.removeEventListener("keyup",L),document.removeEventListener("pointerdown",S),document.removeEventListener("pointerup",g),document.removeEventListener("pointercancel",g),window.removeEventListener("blur",T),T()}},[n,t])}function yt({engine:n,children:r}){return m(Ee.Provider,{value:n,children:r})}export{ut as F,st as P,lt as S,ot as V,Ye as a,ct as b,rt as c,yt as d,q as e,K as f,Pe as g,pt as h,dt as i,ft as j,mt as k,at as l,Ve as m,Te as n,pe as s,it as u};
@@ -1 +0,0 @@
1
- import{g as w,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{u as ae,p as se}from"./index-BkgRRmBf.js";import{I as o}from"./vendor-icons-C1Pj_eSX.js";import{S as le,O as A,a as ie,A as ce,b as re}from"./OptionListMenu-NiWeAIHX.js";import"./vendor-query-BBT5_sHx.js";import"./useWatchAlongPlayer-B4f1qXt_.js";import"./PlayerProvider-NhvkxBzK.js";import"./playbackCompletion-B_Zin5ZR.js";const oe="_settingsPanel_mcacu_1",me="_header_mcacu_35",de="_backBtn_mcacu_58",ue="_contentWrapper_mcacu_78",he="_menuContent_mcacu_84",pe="_menuItem_mcacu_91",be="_selected_mcacu_116",ge="_currentValue_mcacu_136",ke="_menuNote_mcacu_143",ve="_menuError_mcacu_152",n={settingsPanel:oe,header:me,backBtn:de,contentWrapper:ue,menuContent:he,menuItem:pe,selected:be,currentValue:ge,menuNote:ke,menuError:ve},ye=($,P)=>{const{isOpen:g,onClose:Ce,videoSources:fe,currentSource:C,currentLink:f,onSourceChange:V,subtitles:O,activeSubtitleTrack:k,onSubtitleChange:E,subtitleSettings:z,onSubtitleSettingsChange:T,useNativeControls:v,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:N,anime4kProfile:c,onAnime4kProfileChange:h,anime4kInitializing:L,anime4kError:S,videoDelayEnabled:_,onVideoDelayToggle:M,videoDelayMs:I,onVideoDelayChange:D,onCalibrateAvSync:x,isAutoSkipEnabled:m,onAutoSkipChange:W,isAutoplayEnabled:d,onAutoplayChange:G,fallbackChoice:p,onFallbackChoiceChange:j,isTheaterMode:q,ambientSettings:b,onAmbientChange:y}=$,{lowEndMode:F}=ae(),[a,i]=ne("main");w.useEffect(()=>{if(!g){const t=setTimeout(()=>i("main"),300);return()=>clearTimeout(t)}},[g]);const Q=()=>e("div",{className:n.menuContent,children:[e("button",{className:n.menuItem,onClick:()=>i("quality"),children:[e("span",{children:"Quality"}),e("span",{className:n.currentValue,children:f?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:k||"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitle-style"),children:e("span",{children:"Subtitle Style"})}),F&&e("button",{className:`${n.menuItem} ${v?n.selected:""}`,onClick:()=>{const t=!v;U(t),se.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),v&&e(o,{name:"check",size:12})]}),N&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),N&&u&&e("button",{className:n.menuItem,onClick:()=>i("upscaler"),children:e("span",{children:"Upscaler Settings"})}),e("button",{className:n.menuItem,onClick:()=>i("av-sync"),children:[e("span",{children:"A/V Sync"}),e("span",{className:n.currentValue,children:_?`${I}ms`:"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("playback"),children:[e("span",{children:"Playback"}),e("span",{className:n.currentValue,children:[m?"Auto-skip On":null,d?"Autoplay On":null].filter(Boolean).join(" • ")||"Off"})]}),q&&b&&y&&e("button",{className:n.menuItem,onClick:()=>i("ambient"),children:[e("span",{children:"Ambient Light"}),e("span",{className:n.currentValue,children:b.enabled?"On":"Off"})]})]}),R=()=>{const t=[...C?.links??[]].sort((s,r)=>(parseInt(r.resolutionStr)||0)-(parseInt(s.resolutionStr)||0));return e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:t.map(s=>({key:s.link,label:s.resolutionStr,selected:f?.link===s.link})),onSelect:s=>{const r=t.find(l=>l.link===s);r&&V(C,r)}})})},H=()=>e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:k==="off"},...O.map(t=>({key:t.label||t.lang,label:t.label,selected:k===(t.label||t.lang)}))],onSelect:t=>E(t)})}),K=()=>e("div",{className:n.menuContent,children:e(ie,{classes:{item:n.menuItem,active:n.selected},values:z,onChange:T})}),J=te(()=>{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 r=navigator.userAgent.toLowerCase();return r.includes("chrome")||r.includes("chromium")||r.includes("edg")}catch{return!0}},[]),X=()=>e("div",{className:n.menuContent,children:[L&&e("div",{className:n.menuNote,role:"status",children:"Preparing GPU, this can take a few seconds…"}),S&&e("div",{className:n.menuError,role:"alert",children:["Upscaler failed: ",S]}),!J&&e("div",{className:n.menuNote,children:"Upscaling performs best in Chrome-based browsers."}),e("button",{className:`${n.menuItem} ${c==="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"})]}),c==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${c==="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"})]}),c==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${c==="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"})]}),c==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${c==="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"})]}),c==="denoise"&&e(o,{name:"check",size:12})]})]}),Y=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${m?n.selected:""}`,onClick:()=>W(!m),"aria-pressed":m,children:[e("span",{children:"Auto-skip openings and endings"}),e("span",{className:n.currentValue,children:m?"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} ${d?n.selected:""}`,onClick:()=>G(!d),"aria-pressed":d,children:[e("span",{children:"Autoplay next episode"}),e("span",{className:n.currentValue,children:d?"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:()=>j(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."})]}),Z=()=>e("div",{className:n.menuContent,children:e(ce,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:_,delayMs:I,onToggle:M,onDelayChange:D,onCalibrate:x})}),ee=()=>b&&y?e("div",{className:n.menuContent,children:e(re,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},values:b,onChange:y})}):null;return g?e(le,{classes:{panel:n.settingsPanel,header:n.header,backBtn:n.backBtn,title:"",content:n.contentWrapper},title:a==="main"?"Settings":a==="ambient"?"Ambient Light":a.charAt(0).toUpperCase()+a.slice(1).replace("-"," "),titleTag:"h3",showBack:a!=="main",onBack:()=>i("main"),panelRef:P,onPanelClick:t=>t.stopPropagation(),children:[a==="main"&&Q(),a==="quality"&&R(),a==="subtitles"&&H(),a==="subtitle-style"&&K(),a==="upscaler"&&X(),a==="av-sync"&&Z(),a==="playback"&&Y(),a==="ambient"&&ee()]}):null},Ve=w.forwardRef(ye);export{Ve as default};
@@ -1 +0,0 @@
1
- ._header_1i2qn_1{margin-bottom:var(--space-8);animation:_fadeIn_1i2qn_1 .8s var(--ease-smooth)}._pageTitle_1i2qn_6{font-size:var(--font-size-xl);font-weight:800;color:var(--text-primary);margin:0 0 var(--space-2);letter-spacing:-.02em}._pageSubtitle_1i2qn_14{color:var(--text-tertiary);font-size:var(--font-size-sm);margin:0}._filterContainer_1i2qn_20{background:var(--glass-bg);backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);border:1px solid var(--glass-border);padding:var(--space-6);border-radius:var(--radius-xl);margin-bottom:var(--space-10);box-shadow:var(--glass-shadow);animation:_slideUpIn_1i2qn_1 .8s var(--ease-smooth)}._searchBarWrapper_1i2qn_32{display:flex;gap:var(--space-4);align-items:center}._inputIconWrapper_1i2qn_38{flex:1;position:relative}._searchIcon_1i2qn_43{position:absolute;left:var(--space-4);top:50%;transform:translateY(-50%);color:var(--text-tertiary);pointer-events:none;transition:color var(--transition-fast)}._searchInput_1i2qn_53{width:100%;height:52px;padding:0 var(--space-4) 0 3.2rem;background:var(--bg-tertiary);border:1px solid var(--border-primary);border-radius:var(--radius-lg);color:var(--text-primary);font-size:var(--font-size-base);font-family:inherit;transition:all var(--transition-fast)}._searchInput_1i2qn_53:focus{outline:none;border-color:var(--accent);background:var(--bg-elevated);box-shadow:0 0 0 4px var(--accent-glow)}._searchInput_1i2qn_53:focus+._searchIcon_1i2qn_43{color:var(--accent)}._searchActions_1i2qn_77{display:flex;gap:var(--space-3)}._providerSelect_1i2qn_82{height:52px;padding:0 var(--space-4);background:var(--bg-tertiary);border:1px solid var(--border-primary);border-radius:var(--radius-lg);color:var(--text-primary);font-size:var(--font-size-sm);font-family:inherit;cursor:pointer;appearance:none;transition:all var(--transition-fast)}._providerSelect_1i2qn_82:hover{border-color:var(--border-secondary);background-color:var(--bg-elevated)}._providerSelect_1i2qn_82:focus{outline:none;border-color:var(--accent)}._searchBtn_1i2qn_106{height:52px;padding:0 var(--space-8)!important}._filterToggleBtn_1i2qn_111{display:flex;align-items:center;gap:var(--space-2);height:52px;padding:0 var(--space-4);background:#ffffff0d;border:1px solid var(--border-secondary);border-radius:var(--radius-lg);color:var(--text-primary);font-weight:600;font-size:var(--font-size-sm);cursor:pointer;transition:all var(--transition-fast)}._filterToggleBtn_1i2qn_111:hover{background:#ffffff1a;border-color:var(--text-secondary)}._filterToggleBtn_1i2qn_111._active_1i2qn_132{background:var(--accent);border-color:var(--accent);color:var(--accent-text);box-shadow:0 4px 15px var(--accent-glow)}._advancedFilters_1i2qn_139{max-height:0;overflow:hidden;transition:all .4s cubic-bezier(.4,0,.2,1);opacity:0}._advancedFilters_1i2qn_139._show_1i2qn_146{max-height:1000px;opacity:1;margin-top:var(--space-6)}._filterDivider_1i2qn_152{height:1px;background:var(--border-primary);margin-bottom:var(--space-6)}._filterGrid_1i2qn_158{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:var(--space-6);margin-bottom:var(--space-8)}._filterItem_1i2qn_165{display:flex;flex-direction:column;gap:var(--space-2)}._filterItem_1i2qn_165 label{font-size:.7rem;font-weight:700;color:var(--text-tertiary);text-transform:uppercase;letter-spacing:.05em}._filterItem_1i2qn_165 select{height:44px;padding:0 var(--space-4);background:var(--bg-tertiary);border:1px solid var(--border-primary);border-radius:var(--radius-md);color:var(--text-primary);font-size:var(--font-size-sm);font-family:inherit;cursor:pointer;appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2371717a' stroke-width='2' viewBox='0 0 12 12'%3E%3Cpolyline points='3 5 6 8 9 5'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 1rem center;transition:all var(--transition-fast)}._filterItem_1i2qn_165 select:hover{border-color:var(--border-secondary);background-color:var(--bg-elevated)}._filterItem_1i2qn_165 select:focus{outline:none;border-color:var(--accent)}._genreSection_1i2qn_206{border-top:1px solid var(--border-primary);padding-top:var(--space-6);margin-bottom:var(--space-8)}._genreLabel_1i2qn_212{display:block;font-size:.7rem;font-weight:700;color:var(--text-tertiary);text-transform:uppercase;letter-spacing:.05em;margin-bottom:var(--space-4)}._genreContainer_1i2qn_222{display:flex;flex-wrap:wrap;gap:var(--space-2)}._genreButton_1i2qn_228{background:#ffffff0d;border:1px solid var(--border-primary);color:var(--text-secondary);padding:.5rem 1rem;border-radius:var(--radius-full);font-size:var(--font-size-xs);font-weight:600;cursor:pointer;transition:all var(--transition-fast)}._genreButton_1i2qn_228:hover{border-color:var(--accent);color:var(--text-primary)}._genreButton_1i2qn_228._include_1i2qn_245{background:color-mix(in srgb,var(--color-success) 10%,transparent);border-color:var(--color-success);color:var(--color-success)}._genreButton_1i2qn_228._exclude_1i2qn_251{background:color-mix(in srgb,var(--color-danger) 10%,transparent);border-color:var(--color-danger);color:var(--color-danger);text-decoration:line-through}._filterActions_1i2qn_258{display:flex;justify-content:flex-end;gap:var(--space-4);border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._resultsGrid_1i2qn_266{display:grid;grid-template-columns:repeat(7,1fr);gap:var(--space-6);animation:_fadeIn_1i2qn_1 .5s var(--ease-smooth)}@media(max-width:1400px){._resultsGrid_1i2qn_266{grid-template-columns:repeat(6,1fr)}}@media(max-width:1200px){._resultsGrid_1i2qn_266{grid-template-columns:repeat(5,1fr)}}@media(max-width:1024px){._resultsGrid_1i2qn_266{grid-template-columns:repeat(4,1fr)}}@media(max-width:768px){._resultsGrid_1i2qn_266{grid-template-columns:repeat(3,1fr);gap:var(--space-2);align-items:start}}@media(max-width:480px){._resultsGrid_1i2qn_266{grid-template-columns:repeat(3,1fr);gap:8px;align-items:start}._filterContainer_1i2qn_20{padding:var(--space-4)}}._resultsHeader_1i2qn_311{display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--space-6);gap:var(--space-4);flex-wrap:wrap}._resultsTitle_1i2qn_320{font-size:var(--font-size-lg);font-weight:700;color:var(--text-primary);margin:0}._pagination_1i2qn_327{display:flex;align-items:center;gap:var(--space-3);background:var(--bg-secondary);padding:6px 12px;border-radius:var(--radius-full);border:1px solid var(--border-secondary)}._pageBtn_1i2qn_337{background:none;border:none;color:var(--text-primary);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:6px;border-radius:var(--radius-full);transition:all var(--transition-fast);gap:var(--space-2)}._pageBtn_1i2qn_337:hover:not(:disabled){background:var(--bg-tertiary);color:var(--accent)}._pageBtn_1i2qn_337:disabled{opacity:.3;cursor:not-allowed}._pageBtn_1i2qn_337 span{font-size:var(--font-size-xs);font-weight:600}._pageInfo_1i2qn_366{font-size:var(--font-size-sm);color:var(--text-secondary);min-width:80px;text-align:center}._pageInfo_1i2qn_366 strong{color:var(--text-primary)}._bottomPagination_1i2qn_377{display:flex;justify-content:center;margin-top:var(--space-10);padding-top:var(--space-6);border-top:1px solid var(--border-primary)}._noResults_1i2qn_385{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--space-16);text-align:center;color:var(--text-tertiary);animation:_fadeIn_1i2qn_1 .5s var(--ease-smooth)}._noResultsIcon_1i2qn_396{color:var(--border-secondary);margin-bottom:var(--space-6)}._noResults_1i2qn_385 h3{color:var(--text-primary);margin:0 0 var(--space-2)}._noResults_1i2qn_385 p{max-width:400px;margin:0}@keyframes _fadeIn_1i2qn_1{0%{opacity:0}to{opacity:1}}@keyframes _slideUpIn_1i2qn_1{0%{opacity:0;transform:translateY(30px)}to{opacity:1;transform:translateY(0)}}@media(max-width:768px){._searchBarWrapper_1i2qn_32{flex-direction:column;align-items:stretch}._searchActions_1i2qn_77{display:grid;grid-template-columns:1fr 1fr}._searchBtn_1i2qn_106{padding:0!important}._filterGrid_1i2qn_158{grid-template-columns:repeat(2,1fr)}}@media(max-width:480px){._filterGrid_1i2qn_158{grid-template-columns:1fr}}._applyBtn_1i2qn_460{align-self:flex-start}._lowEnd_1i2qn_464{grid-template-columns:repeat(4,1fr);gap:var(--space-4)}@media(max-width:768px){._lowEnd_1i2qn_464{grid-template-columns:repeat(3,1fr)}}
@@ -1 +0,0 @@
1
- const n="_header_1i2qn_1",e="_fadeIn_1i2qn_1",t="_pageTitle_1i2qn_6",i="_pageSubtitle_1i2qn_14",_="_filterContainer_1i2qn_20",s="_slideUpIn_1i2qn_1",o="_searchBarWrapper_1i2qn_32",r="_inputIconWrapper_1i2qn_38",c="_searchIcon_1i2qn_43",a="_searchInput_1i2qn_53",l="_searchActions_1i2qn_77",p="_providerSelect_1i2qn_82",d="_searchBtn_1i2qn_106",q="_filterToggleBtn_1i2qn_111",g="_active_1i2qn_132",u="_advancedFilters_1i2qn_139",f="_show_1i2qn_146",I="_filterDivider_1i2qn_152",h="_filterGrid_1i2qn_158",B="_filterItem_1i2qn_165",v="_genreSection_1i2qn_206",b="_genreLabel_1i2qn_212",S="_genreContainer_1i2qn_222",T="_genreButton_1i2qn_228",m="_include_1i2qn_245",w="_exclude_1i2qn_251",A="_filterActions_1i2qn_258",C="_resultsGrid_1i2qn_266",G="_resultsHeader_1i2qn_311",R="_resultsTitle_1i2qn_320",W="_pagination_1i2qn_327",x="_pageBtn_1i2qn_337",y="_pageInfo_1i2qn_366",D="_bottomPagination_1i2qn_377",E="_noResults_1i2qn_385",F="_noResultsIcon_1i2qn_396",H="_applyBtn_1i2qn_460",L="_lowEnd_1i2qn_464",P={header:n,fadeIn:e,pageTitle:t,pageSubtitle:i,filterContainer:_,slideUpIn:s,searchBarWrapper:o,inputIconWrapper:r,searchIcon:c,searchInput:a,searchActions:l,providerSelect:p,searchBtn:d,filterToggleBtn:q,active:g,advancedFilters:u,show:f,filterDivider:I,filterGrid:h,filterItem:B,genreSection:v,genreLabel:b,genreContainer:S,genreButton:T,include:m,exclude:w,filterActions:A,resultsGrid:C,resultsHeader:G,resultsTitle:R,pagination:W,pageBtn:x,pageInfo:y,bottomPagination:D,noResults:E,noResultsIcon:F,applyBtn:H,lowEnd:L};export{P as s};
@@ -1,21 +0,0 @@
1
- import{d as r,u as e,S as le,A as X,h as z,q as pe,T as qe,p as ze,g as be,_ as Ke}from"./vendor-core-DfaOB3Rn.js";import{b as fe,u as ee}from"./vendor-query-BBT5_sHx.js";import{S as Z,U as Q,V as K,W as Ce,B as C,X as Ue,R as E,d as Ee,N as Te,t as k,v as Fe,o as $e,K as ke,Y as J,q as H,Z as Se,_ as We,$ as He,u as Be,e as je,a0 as Qe,L as de,p as Ve,a1 as Ye,a2 as Je}from"./index-BkgRRmBf.js";import{I as j}from"./vendor-icons-C1Pj_eSX.js";import{T as F}from"./ToggleSwitch-CN_ppEc9.js";import{l as Xe,s as Ze}from"./playbackCompletion-B_Zin5ZR.js";import{M as et}from"./MatureConsentModal-DNd8p-k1.js";const tt="_sectionCard_1vuib_1",at="_dangerCard_1vuib_20",nt="_settingRow_1vuib_31",_={sectionCard:tt,dangerCard:at,settingRow:nt};function rt(){const{data:t}=fe(Z),{data:s}=fe({queryKey:["profiles"],queryFn:()=>Q("/api/profiles/status"),enabled:!!t?.owner}),c=ee(),[p,d]=r(null),[y,S]=r(""),[h,o]=r(""),[a,g]=r(""),[v,m]=r(""),[x,l]=r(""),[f,T]=r(!1),[I,G]=r(null),[P,w]=r(null),[L,A]=r(""),M=async i=>{T(!0),l("");try{await Q("/api/profiles/update",{method:"POST",body:JSON.stringify(i)}),await c.invalidateQueries({queryKey:Z.queryKey}),S(""),o(""),l("Profile saved")}catch(R){l(R.message)}finally{T(!1)}};return t?e("section",{className:_.sectionCard,children:[e("h3",{children:"Your profile"}),e("p",{children:"Keep using this profile, rename it, or add another person with their own library and connections."}),e("div",{className:K.avatarRow,children:[e(Ce,{image:t.image,name:t.name}),e("label",{className:K.uploadButton,children:[e(j,{name:"upload"}),e("span",{children:"Upload image"}),e("input",{className:K.fileInput,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",disabled:f,onChange:async i=>{const R=i.currentTarget.files?.[0];if(i.currentTarget.value="",!R)return;if(R.size>2*1024*1024){l("Image must be smaller than 2 MB");return}const D=new FileReader;D.onerror=()=>l("Could not read image"),D.onload=()=>{M({avatar:D.result})},D.readAsDataURL(R)}})]}),t.avatar&&e(C,{variant:"secondary",disabled:f,onClick:()=>M({avatar:null}),children:"Clear uploaded image"})]}),e("p",{children:"Your uploaded image takes priority, followed by your active cloud account image, then the default user icon."}),e("form",{className:K.form,onSubmit:i=>{i.preventDefault(),M({name:p??t.name})},children:[e("label",{className:K.field,children:["Profile name",e("input",{value:p??t.name,maxLength:60,required:!0,onChange:i=>d(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f,children:"Save name"})]}),e("form",{className:K.form,onSubmit:i=>{i.preventDefault(),M({password:y,currentPassword:h})},children:[t.protected&&e("label",{className:K.field,children:["Current password",e("input",{type:"password",autoComplete:"current-password",value:h,required:!0,maxLength:256,onChange:i=>o(i.currentTarget.value)})]}),e("label",{className:K.field,children:[t.protected?"New password (empty removes protection)":"Protect this profile",e("input",{type:"password",autoComplete:"new-password",value:y,minLength:8,maxLength:256,onChange:i=>S(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f,children:"Save password"})]}),e(C,{variant:"secondary",disabled:f,onClick:async()=>{T(!0);try{await Q("/api/profiles/logout",{method:"POST"}),Ue()}catch(i){l(i.message),T(!1)}},children:"Switch profile / sign out"}),t.owner&&e("form",{className:K.form,onSubmit:async i=>{i.preventDefault(),T(!0),l("");try{await Q("/api/profiles/create",{method:"POST",body:JSON.stringify({name:a,password:v})}),g(""),m(""),await c.invalidateQueries({queryKey:["profiles"]}),l("Profile created. Sign out to switch to it.")}catch(R){l(R.message)}finally{T(!1)}},children:[e("h3",{children:"Add another profile"}),e("p",{children:"Protect your owner profile first. New profiles start empty and do not inherit your accounts. A profile without a password is accessible to anyone who passes the LAN lock."}),e("label",{className:K.field,children:["Name",e("input",{required:!0,maxLength:60,value:a,onChange:i=>g(i.currentTarget.value)})]}),e("label",{className:K.field,children:["Password (optional)",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,value:v,onChange:i=>m(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f||!t.protected,children:"Create profile"})]}),t.owner&&s?.profiles.some(i=>!i.owner)&&e(le,{children:[e("h3",{children:"Other profiles"}),e("ul",{className:K.profileList,children:s.profiles.filter(i=>!i.owner).map(i=>e("li",{children:[e("span",{className:K.smallAvatar,children:e(Ce,{image:i.avatar??i.cloudAvatar,name:i.name})}),e("span",{className:K.profileName,children:i.name}),e(C,{variant:"secondary",size:"sm",disabled:f,onClick:()=>{l(""),A(""),w(i)},children:"Reset password"}),e(C,{variant:"danger",size:"sm",disabled:f,onClick:()=>{l(""),G(i)},children:"Delete"})]},i.id))})]}),e(E,{isOpen:!!P,onClose:f?void 0:()=>w(null),title:"Reset password",width:"sm",footer:e(le,{children:[e(C,{variant:"secondary",disabled:f,onClick:()=>w(null),children:"Cancel"}),e(C,{loading:f,onClick:async()=>{if(P){T(!0),l("");try{await Q("/api/profiles/reset-password",{method:"POST",body:JSON.stringify({id:P.id,password:L})}),await c.invalidateQueries({queryKey:["profiles"]}),w(null),A(""),l("Password updated. The profile has been signed out.")}catch(i){l(i.message)}finally{T(!1)}}},children:"Save password"})]}),children:[e("p",{children:["Set a new password for ",e("strong",{children:P?.name}),". They will be signed out and must use the new password next time."]}),e("label",{className:K.field,children:["New password",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,placeholder:"Leave empty to remove their password",value:L,onChange:i=>A(i.currentTarget.value)})]})]}),e(E,{isOpen:!!I,onClose:f?void 0:()=>G(null),title:"Delete profile?",width:"sm",footer:e(le,{children:[e(C,{variant:"secondary",disabled:f,onClick:()=>G(null),children:"Cancel"}),e(C,{variant:"danger",loading:f,onClick:async()=>{if(I){T(!0);try{await Q("/api/profiles/delete",{method:"POST",body:JSON.stringify({id:I.id,confirm:!0})}),await c.invalidateQueries({queryKey:["profiles"]}),G(null),l("Profile deleted. Local files will be removed when Dango restarts.")}catch(i){l(i.message),G(null)}finally{T(!1)}}},children:"Delete profile"})]}),children:[e("p",{children:["Delete ",e("strong",{children:I?.name}),"? This signs them out immediately. Their local libraries, settings and connections will be removed when Dango next restarts."]}),e("p",{children:"Cloud backups and tracker lists will stay intact. Export any library you want to keep before deleting."})]}),x&&e("p",{role:"status",children:x})]}):null}const ue={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},he=["name","nativeName","englishName"],ge={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},st=()=>{const{titlePreference:t,setTitlePreference:s,loading:c}=Ee(),p=Te(),[d,y]=r(ge[t]),[S,h]=r(!1),o=X(null);z(()=>{c||y(ge[t])},[t,c]);const a=async()=>{if(S)return;h(!0);const v=(he.indexOf(t)+1)%he.length,m=he[v],x=ge[m];o.current&&(o.current.style.transform="translateX(-100%)",o.current.style.opacity="0"),setTimeout(async()=>{y(x),s(m),o.current&&(o.current.style.transition="none",o.current.style.transform="translateX(100%)",o.current.style.opacity="0",o.current.offsetWidth,o.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",o.current.style.transform="translateX(0)",o.current.style.opacity="1");try{await p.mutateAsync({key:"titlePreference",value:m})}catch(l){console.error("Error saving title preference:",l)}finally{h(!1)}},300)};return c?e("p",{children:"Loading title preference..."}):e("div",{className:ue["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:a,className:ue["toggle-button"],disabled:S,children:e("span",{ref:o,className:ue["toggle-label"],children:d})})]})},it="_settingsHeader_gfwoa_1",ot="_pageTitle_gfwoa_6",lt="_pageSubtitle_gfwoa_14",ct="_settingsLayout_gfwoa_20",dt="_sidebar_gfwoa_27",ut="_sidebarIndicator_gfwoa_35",ht="_sidebarItem_gfwoa_50",gt="_active_gfwoa_72",mt="_mainContent_gfwoa_80",pt="_tabContent_gfwoa_85",ft="_settingItem_gfwoa_103",yt="_shortcutContainer_gfwoa_108",vt="_shortcutGroup_gfwoa_115",wt="_shortcutGroupTitle_gfwoa_121",bt="_shortcutGrid_gfwoa_130",Ct="_shortcutCard_gfwoa_136",kt="_controls_gfwoa_170",St="_status_gfwoa_176",u={settingsHeader:it,pageTitle:ot,pageSubtitle:lt,settingsLayout:ct,sidebar:dt,sidebarIndicator:ut,sidebarItem:ht,active:gt,mainContent:mt,tabContent:pt,settingItem:ft,shortcutContainer:yt,shortcutGroup:vt,shortcutGroupTitle:wt,shortcutGrid:bt,shortcutCard:Ct,controls:kt,status:St},Nt="_title_tm30b_11",_t="_signIn_tm30b_18",Tt="_userInfo_tm30b_25",Pt="_warning_tm30b_47",It="_formGroup_tm30b_54",Lt="_label_tm30b_58",xt="_inputWrapper_tm30b_68",Rt="_input_tm30b_68",Dt="_select_tm30b_92",Ot="_actions_tm30b_109",At="_hr_tm30b_117",b={title:Nt,signIn:_t,userInfo:Tt,warning:Pt,formGroup:It,label:Lt,inputWrapper:xt,input:Rt,select:Dt,actions:Ot,hr:At},Mt=()=>{const t=ee(),[s,c]=r(!0),[p,d]=r(!1),[y,S]=r(!1),[h,o]=r(null),[a,g]=r({status:"idle"}),[v,m]=r(!1),[x,l]=r(""),[f,T]=r(!1),I=X(null),[G,P]=r({show:!1,message:"",type:"info"}),w=()=>{I.current&&(window.clearInterval(I.current),I.current=null)},L=pe(N=>{S(N.authenticated),o(N.user||N.device.user||null),g(N.device),m(!!N.hasCustomClientId)},[]),A=pe(async()=>{const N=await k.auth.githubStatus.query();L(N)},[L]),M=async()=>{try{const N=await k.auth.githubPoll.query();g(N),N.status==="success"?(w(),await t.invalidateQueries({queryKey:Z.queryKey}),await A(),P({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):N.status==="error"&&(w(),P({show:!0,message:N.error||"GitHub authentication failed.",type:"error"}))}catch{w(),P({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},i=(N=5)=>{w(),I.current=window.setInterval(M,Math.max(N,5)*1e3)};z(()=>(A().catch(()=>{P({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>c(!1)),w),[A]);const R=async()=>{d(!0);try{const N=await k.auth.githubStart.mutate();g(N),i(N.verification?.interval)}catch(N){P({show:!0,message:N instanceof Error?N.message:"Failed to start GitHub authentication.",type:"error"})}finally{d(!1)}},D=async()=>{try{await k.auth.githubLogout.mutate(),await t.invalidateQueries({queryKey:Z.queryKey}),S(!1),o(null),g({status:"idle"}),P({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{P({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},W=async()=>{T(!0);try{await k.auth.saveGithubAuth.mutate({clientId:x}),l(""),await A(),P({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{P({show:!0,message:"Failed to save override.",type:"error"})}finally{T(!1)}},te=async()=>{T(!0);try{await k.auth.saveGithubAuth.mutate({clientId:""}),l(""),await A(),P({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{P({show:!0,message:"Failed to clear override.",type:"error"})}finally{T(!1)}};return s?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"GitHub Cloud Sync"}),e("p",{className:b.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),y&&h?e("div",{className:b.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:h.name||h.login})]}),e(C,{variant:"danger",onClick:D,children:"Sign Out"})]}):e("div",{className:b.signIn,children:e(C,{onClick:R,disabled:p||a.status==="pending",children:p||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(le,{children:[e("hr",{className:b.hr}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Verification URL"}),e("div",{className:b.inputWrapper,children:[e("input",{className:b.input,value:a.verification.verification_uri,readOnly:!0}),e(C,{onClick:()=>{const N=a.verification?.verification_uri;N&&/^https?:\/\//i.test(N)&&window.open(N,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Device Code"}),e("input",{className:b.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:b.warning,children:a.error}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",v?"(override active)":""]}),e("div",{className:b.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:b.label,children:"Client ID (optional)"}),e("input",{className:b.input,value:x,onChange:N=>l(N.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:b.actions,children:[e(C,{onClick:W,disabled:f,children:"Save override"}),e(C,{variant:"secondary",onClick:te,disabled:f,children:"Use dango defaults"})]})]}),e(E,{isOpen:G.show,onClose:()=>P(N=>({...N,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:G.message})}),e(E.Actions,{children:e(C,{onClick:()=>P(N=>({...N,show:!1})),children:"OK"})})]})]})},Gt=()=>{const[t,s]=r(!0),[c,p]=r(null),[d,y]=r(!1),[S,h]=r(!1),[o,a]=r(""),[g,v]=r(""),[m,x]=r(""),[l,f]=r(!1),[T,I]=r({show:!1,message:"",type:"info"}),G=async()=>{try{const R=await k.auth.user.query();p(R?.email?R:null)}catch{p(null)}},P=async()=>{try{const[i,R]=await Promise.all([k.auth.configStatus.query(),k.auth.googleAuth.query()]);y(!!i.hasConfig),h(!!(R.hasCustomWorkerUrl||R.hasCustomClientId||R.hasClientSecret))}catch(i){console.error("Failed to fetch config status",i)}};z(()=>{(async()=>{s(!0),await Promise.all([G(),P()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await G(),window.history.replaceState(null,"",window.location.pathname))}catch{}s(!1)})();const R=D=>{D.origin===window.location.origin&&typeof D.data=="object"&&D.data!==null&&D.data.type==="GOOGLE_AUTH_SUCCESS"&&(p(D.data.user),window.location.reload())};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[]);const w=async()=>{try{const i=await k.auth.googleLogin.mutate();if(i.authenticated){window.location.reload();return}if(i.url){if(typeof window.DangoBridge<"u"){window.location.href=i.url;return}const D=600,W=700,te=window.innerWidth/2-D/2,N=window.innerHeight/2-W/2;window.open(i.url,"GoogleAuth",`width=${D},height=${W},top=${N},left=${te}`)}else throw new Error("Auth URL not available")}catch{I({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},L=async()=>{try{await k.auth.logout.mutate(),p(null),I({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(i){console.error("Sign out failed",i),I({show:!0,message:"Failed to sign out.",type:"error"})}},A=async()=>{f(!0);try{await k.auth.saveGoogleAuth.mutate({workerUrl:o,clientId:g,clientSecret:m}),a(""),v(""),x(""),await P(),I({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{I({show:!0,message:"Failed to save override.",type:"error"})}finally{f(!1)}},M=async()=>{f(!0);try{await k.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),a(""),v(""),x(""),await P(),I({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{I({show:!0,message:"Failed to clear override.",type:"error"})}finally{f(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"Google Drive Sync"}),c?e("div",{className:b.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:c.name})," (",c.email,")"]}),e(C,{variant:"danger",onClick:L,children:"Sign Out"})]}):e("div",{className:b.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(C,{onClick:w,disabled:!d,children:"Sign in with Google"}),!d&&e("p",{className:b.warning,children:"Google sync is not configured on the server."})]}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",S?"(override active)":""]}),e("div",{className:b.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:b.label,children:"Worker URL (optional)"}),e("input",{className:b.input,value:o,onChange:i=>a(i.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Client ID (optional)"}),e("input",{className:b.input,value:g,onChange:i=>v(i.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:b.input,value:m,onChange:i=>x(i.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:b.actions,children:[e(C,{onClick:A,disabled:l,children:"Save override"}),e(C,{variant:"secondary",onClick:M,disabled:l,children:"Use dango defaults"})]})]}),e(E,{isOpen:T.show,onClose:()=>I(i=>({...i,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:T.message})}),e(E.Actions,{children:e(C,{onClick:()=>I(i=>({...i,show:!1})),children:"OK"})})]})]})},qt="_settingItem_3qq0n_1",zt="_modalOverlay_3qq0n_6",Kt="_modal_3qq0n_6",Ut="_modalActions_3qq0n_41",Et="_modalSecondary_3qq0n_47",Ft="_modalPrimary_3qq0n_57",B={settingItem:qt,modalOverlay:zt,modal:Kt,modalActions:Ut,modalSecondary:Et,modalPrimary:Ft},$t={anime:{heading:"Watchlist Preferences",blurb:"Customize your experience when managing your watchlist and series entries.",skipKey:"skipRemoveConfirmation",ignoreKey:"ignoreAdultContent",listOnlyKey:"cwWatchlistOnly",skipLabel:"Skip confirmation when removing from watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in watchlist",listNoun:"watchlist",continueNoun:"continue watching",adultCountUrl:"/api/continue-watching/adult-count",purgeUrl:"/api/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["allContinueWatching"]]},manga:{heading:"Reading List Preferences",blurb:"Customize your experience when managing your reading list and manga entries.",skipKey:"mangaSkipRemoveConfirmation",ignoreKey:"mangaIgnoreAdultContent",listOnlyKey:"mangaCwWatchlistOnly",skipLabel:"Skip confirmation when removing from reading list",ignoreLabel:"Hide adult content from continue reading",listOnlyLabel:"Only show continue reading for manga in reading list",listNoun:"reading list",continueNoun:"continue reading",adultCountUrl:"/api/manga/continue-reading/adult-count",purgeUrl:"/api/manga/continue-reading/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue reading`,invalidateKeys:[["manga-continue-reading"]]},tv:{heading:"TV Watchlist Preferences",blurb:"Customize your experience when managing your TV watchlist and series entries.",skipKey:"tvSkipRemoveConfirmation",ignoreKey:"tvIgnoreAdultContent",listOnlyKey:"tvCwWatchlistOnly",skipLabel:"Skip confirmation when removing from TV watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in TV watchlist",listNoun:"TV watchlist",continueNoun:"continue watching",adultCountUrl:"/api/tv/continue-watching/adult-count",purgeUrl:"/api/tv/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["tv-continue-watching"]]},asmr:{heading:"Listening List Preferences",blurb:"Customize your experience when managing your listening list and work entries.",skipKey:"asmrSkipRemoveConfirmation",ignoreKey:"asmrIgnoreAdultContent",listOnlyKey:"asmrCwWatchlistOnly",skipLabel:"Skip confirmation when removing from listening list",ignoreLabel:"Hide adult content from continue listening",listOnlyLabel:"Only show continue listening for works in listening list",listNoun:"listening list",continueNoun:"continue listening",adultCountUrl:"/api/asmr/continue-listening/adult-count",purgeUrl:"/api/asmr/continue-listening/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue listening`,invalidateKeys:[["asmr-continue-listening"]]}},Wt=(t,s)=>{if(t==null)return s;const c=String(t);return c==="true"||c==="1"?!0:c==="false"||c==="0"?!1:s},Ne=(t,s,c)=>{const[p,d]=r(s),[y,S]=r(!1),h=ee();return z(()=>{(async()=>{try{const g=await k.settings.getByKey.query({key:t});d(Wt(g.value,s))}catch(g){console.error("Failed to fetch setting",g)}})()},[t,s]),{value:p,setValue:d,isUpdating:y,toggle:async()=>{if(y)return;S(!0);const a=!p;d(a);try{await k.settings.set.mutate({key:t,value:a});for(const g of c)h.invalidateQueries({queryKey:g})}catch(g){console.error("Error saving setting:",g),d(!a)}finally{S(!1)}}}},Ht=()=>{const{contentType:t}=Fe(),s=$t[t],[c,p]=r(!1),[d,y]=r(!0),[S,h]=r(!1),o=Ne(s.ignoreKey,!0,s.invalidateKeys),a=Ne(s.listOnlyKey,!1,s.invalidateKeys),[g,v]=r(null),[m,x]=r(!1),l=ee(),f=$e();z(()=>{y(!0),(async()=>{try{const L=await k.settings.getByKey.query({key:s.skipKey});String(L.value)==="true"||String(L.value)==="1"?p(!0):p(!1)}catch(L){console.error("Failed to fetch setting",L)}finally{y(!1)}})()},[s.skipKey]);const T=async()=>{if(S)return;h(!0);const w=!c;p(w);try{await k.settings.set.mutate({key:s.skipKey,value:w})}catch(L){console.error("Error saving setting:",L),p(!w)}finally{h(!1)}},I=async()=>{if(!o.isUpdating){if(o.value)try{let w;if(t==="anime"?w=(await k.continueWatching.adultCount.query()).count:t==="manga"?w=(await k.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await k.asmrProgress.adultCount.query()).count:w=(await k.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){v(w);return}}catch(w){console.error("Failed to fetch adult count",w)}o.toggle()}},G=()=>{v(null),o.toggle()},P=async()=>{if(!m){x(!0);try{let w;t==="anime"?w=(await k.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await k.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await k.asmrProgress.purgeAdult.mutate()).removed:w=(await k.tvProgress.purgeAdult.mutate()).removed,ke.success(s.purgeDoneText(w??0));for(const L of s.invalidateKeys)l.invalidateQueries({queryKey:L});t==="anime"&&l.invalidateQueries(f.continueWatching.pathFilter()),t==="manga"&&l.invalidateQueries(f.mangaProgress.pathFilter()),t==="asmr"&&l.invalidateQueries(f.asmrProgress.pathFilter()),t==="tv"&&l.invalidateQueries(f.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),ke.error("Failed to remove adult entries")}finally{x(!1),v(null)}o.toggle()}};return d?e("div",{children:"Loading settings..."}):e("div",{className:_.sectionCard,children:[e("h3",{children:s.heading}),e("p",{children:s.blurb}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:s.skipLabel}),e(F,{isChecked:c,onChange:T,id:"skip-confirmation-toggle",disabled:S})]})}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:s.ignoreLabel}),e(F,{isChecked:o.value,onChange:I,id:"ignore-adult-toggle",disabled:o.isUpdating})]})}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:s.listOnlyLabel}),e(F,{isChecked:a.value,onChange:a.toggle,id:"cw-watchlist-only-toggle",disabled:a.isUpdating})]})}),g!==null&&e("div",{className:B.modalOverlay,onClick:()=>v(null),children:e("div",{className:B.modal,onClick:w=>w.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[g," adult ",g===1?"entry":"entries"," not in your"," ",s.listNoun," ",g===1?"is":"are"," currently hidden from"," ",s.continueNoun,". You can purge ",g===1?"it":"them"," from the database instead of showing ",g===1?"it":"them","."]}),e("div",{className:B.modalActions,children:[e("button",{type:"button",className:B.modalSecondary,onClick:G,disabled:m,children:"Show them"}),e("button",{type:"button",className:B.modalPrimary,onClick:P,disabled:m,children:m?"Purging...":`Purge ${g}`})]})]})})]})},Bt="_statsGrid_o4nf0_1",jt="_statCard_o4nf0_8",Qt="_statLabel_o4nf0_18",Vt="_statValue_o4nf0_26",Yt="_statMeta_o4nf0_32",Jt="_statusBanner_o4nf0_38",Xt="_statusSuccess_o4nf0_49",Zt="_statusUpdating_o4nf0_55",ea="_statusError_o4nf0_61",ta="_sha_o4nf0_67",aa="_settingItem_o4nf0_74",na="_settingTitle_o4nf0_79",ra="_settingSubtitle_o4nf0_85",sa="_actionsRow_o4nf0_92",O={statsGrid:Bt,statCard:jt,statLabel:Qt,statValue:Vt,statMeta:Yt,statusBanner:Jt,statusSuccess:Xt,statusUpdating:Zt,statusError:ea,sha:ta,settingItem:aa,settingTitle:na,settingSubtitle:ra,actionsRow:sa},ia=()=>{const[t,s]=r(null),[c,p]=r(!0),[d,y]=r(!1),[S,h]=r(!1),o=X(null),a=async()=>{try{const l=await k.settings.offlineDbInfo.query();return s(l),l}catch(l){console.error("Failed to fetch offline DB info:",l)}finally{p(!1)}return null};z(()=>(a(),()=>{o.current&&window.clearInterval(o.current)}),[]),z(()=>{t?.isRefreshing?o.current||(o.current=window.setInterval(async()=>{const l=await a();l&&!l.isRefreshing&&o.current&&(window.clearInterval(o.current),o.current=null)},2e3)):o.current&&(window.clearInterval(o.current),o.current=null)},[t?.isRefreshing]);const g=async()=>{if(!t||d)return;const l=!t.autoUpdateEnabled;y(!0),s({...t,autoUpdateEnabled:l});try{await k.settings.setOfflineDbAutoUpdate.mutate({enabled:l})}catch(f){console.error("Failed to update auto update setting:",f),s({...t,autoUpdateEnabled:!l})}finally{y(!1)}},v=async()=>{if(!(t?.isRefreshing||S)){h(!0);try{await k.settings.triggerOfflineDbUpdate.mutate(),s(l=>l?{...l,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(l){console.error("Failed to trigger offline DB update:",l)}finally{h(!1)}}},m=l=>{if(!l)return"Never";try{return new Date(l).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return l}},x=t?.isRefreshing||S;return e("div",{className:_.sectionCard,children:[e("h3",{children:"Offline Metadata Database"}),e("p",{children:"Local MAL to AniList ID map used for instant imports and metadata enrichment without hitting rate-limited APIs. Updates automatically every Saturday in the background."}),e("div",{className:O.statsGrid,children:[e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"MAL Mapped"}),e("span",{className:O.statValue,children:c?"-":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Release"}),e("span",{className:O.statMeta,children:c?"-":t?.releaseTag??"Never"})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Last Checked"}),e("span",{className:O.statMeta,children:c?"-":m(t?.lastCheckedAt??null)})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Last Updated"}),e("span",{className:O.statMeta,children:c?"-":m(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${O.statusBanner} ${t.lastStatus==="failed"?O.statusError:t.lastStatus==="updating"?O.statusUpdating:O.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:O.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:O.settingItem,children:e("div",{className:_.settingRow,children:[e("div",{children:[e("span",{className:O.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:O.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(F,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:g,disabled:c||d})]})}),e("div",{className:O.actionsRow,children:e(C,{onClick:v,disabled:c||x,children:x?"Updating Database...":"Update Offline Database Now"})})]})},oa="_status_1wbo0_1",la="_warningText_1wbo0_7",ca="_ackLabel_1wbo0_11",me={status:oa,warningText:la,ackLabel:ca},da=()=>{const t=ee(),[s,c]=r(!1),[p,d]=r(!1),[y,S]=r(!1),[h,o]=r(""),a=()=>{d(!1),o(""),c(!0)},g=()=>{y||(c(!1),d(!1))},v=async()=>{if(!(!p||y)){S(!0),o("");try{const m=await J("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),x=await m.json();if(!m.ok)throw new Error(x.error||"Failed to clear database");const l=x.deleted,f=x.deletedManga,T=x.deletedTv,I=x.deletedAsmr,G=Object.values(l).reduce((A,M)=>A+(M||0),0)+Object.values(f??{}).reduce((A,M)=>A+(M||0),0)+Object.values(T??{}).reduce((A,M)=>A+(M||0),0)+Object.values(I??{}).reduce((A,M)=>A+(M||0),0),P=(f?.manga_library??0)+(f?.manga_progress??0),w=(T?.tv_library??0)+(T?.tv_progress??0),L=(I?.asmr_library??0)+(I?.asmr_progress??0);o(`Library cleared - ${l.watchlist??0} watchlist entries, ${P} manga rows, ${w} TV rows, ${L} ASMR rows and ${G} total rows removed.`),t.invalidateQueries({queryKey:[H.watchlist]}),t.invalidateQueries({queryKey:[H.continueWatching]}),t.invalidateQueries({queryKey:[H.mangaLibrary]}),t.invalidateQueries({queryKey:[H.mangaContinueReading]}),t.invalidateQueries({queryKey:[H.tvLibrary]}),t.invalidateQueries({queryKey:[H.tvContinueWatching]}),t.invalidateQueries({queryKey:[H.asmrLibrary]}),t.invalidateQueries({queryKey:[H.asmrContinueListening]}),c(!1)}catch(m){o(m.message)}finally{S(!1),d(!1)}}};return e("div",{className:`${_.sectionCard} ${_.dangerCard}`,children:[e("h3",{children:"Danger Zone"}),e("p",{children:"Permanently delete your library (watchlist, watched episodes, queue, cached show metadata, manga reading list and reading progress, TV watchlist and watch progress, ASMR listening list and listening progress) to start fresh. Your settings, sync state and the offline metadata cache are preserved."}),e(C,{variant:"danger",onClick:a,children:"Clear Library Data"}),h&&e("p",{className:me.status,children:h}),e(E,{isOpen:s,onClose:g,title:"Clear library data?",width:"sm",children:[e(E.Body,{children:[e("p",{className:me.warningText,children:"This permanently deletes everything in your library. It acts on the active database (dev or prod, per server config) and cannot be undone. Settings, sync state and the offline metadata cache are kept."}),e("label",{className:me.ackLabel,children:[e("input",{type:"checkbox",checked:p,onChange:m=>d(m.currentTarget.checked),disabled:y}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(E.Actions,{children:[e(C,{variant:"secondary",onClick:g,disabled:y,children:"Cancel"}),e(C,{variant:"danger",onClick:v,disabled:!p||y,children:y?"Clearing...":"Yes, delete everything"})]})]})]})},ua=()=>{const[t,s]=r(""),[c,p]=r([]),[d,y]=r(null),[S,h]=r(!0),[o,a]=r({show:!1,message:"",type:"info"}),g=async()=>{try{h(!0);const m=await k.auth.rcloneSettings.query();s(m.remote||""),p(m.availableRemotes||[]),y(m.activeRemote||null)}catch(m){console.error("Failed to fetch Rclone settings",m)}finally{h(!1)}};z(()=>{g()},[]);const v=async()=>{try{await k.auth.saveRclone.mutate({remote:t}),a({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),g()}catch{a({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return S?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"Rclone Cloud Sync"}),e("p",{className:b.signIn,children:"Configure which Rclone remote to use for database synchronization."}),d?e("div",{className:b.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:d})]})}):e("p",{className:b.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Remote Name"}),e("div",{className:b.inputWrapper,children:e("select",{className:b.select,value:t,onChange:m=>s(m.currentTarget.value),children:[e("option",{value:"",children:"(Disabled / None)"}),c.map(m=>e("option",{value:m,children:m},m)),t&&!c.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:b.warning,style:{marginTop:"12px"},children:[e("strong",{children:"Note:"})," You can choose which provider is active using the selector at the top of the page."]})]}),e("div",{className:b.actions,children:e(C,{onClick:v,children:"Save Rclone Settings"})}),e(E,{isOpen:o.show,onClose:()=>a(m=>({...m,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:o.message})}),e(E.Actions,{children:e(C,{onClick:()=>a(m=>({...m,show:!1})),children:"OK"})})]})]})},ha=()=>{const t=ee(),[s,c]=r(null),[p,d]=r(!0),y=async()=>{try{const a=await k.auth.syncSettings.query();c(a)}catch(a){console.error("Failed to fetch sync settings",a)}finally{d(!1)}};z(()=>{y()},[]);const S=async a=>{const g=a.currentTarget.value;try{const v=await k.auth.saveSyncProvider.mutate({provider:g});c(m=>m?{...m,activeProvider:v.activeProvider}:null),await y(),await t.invalidateQueries({queryKey:Z.queryKey}),Se.success(`Sync provider updated to ${g==="default"?"Default Order":g}`)}catch{Se.error("Failed to update sync provider")}};if(p||!s)return null;const h=[{value:"default",label:"Default (Priority Based)"}];s.authenticatedProviders.github&&h.push({value:"github",label:"GitHub"}),s.authenticatedProviders.google&&h.push({value:"google",label:"Google Drive"}),s.authenticatedProviders.rclone&&h.push({value:"rclone",label:"Rclone"}),h.push({value:"none",label:"None (Local Only)"});const o=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:_.sectionCard,children:[e("h3",{children:"Active Sync Provider"}),e("p",{children:'Choose which provider to use for synchronization. "Default" uses the first available provider you are logged into.'}),e("div",{style:{marginBottom:"1.5rem",padding:"0.75rem",background:"rgba(255, 255, 255, 0.03)",borderRadius:"var(--radius-md)",borderLeft:"4px solid var(--accent)",fontSize:"var(--font-size-sm)"},children:["Current Status:"," ",e("strong",{style:{color:"var(--accent-light)",textTransform:"capitalize"},children:o(s.actualActiveProvider)})]}),e("div",{className:_.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:s.activeProvider,onChange:S,style:{padding:"0.5rem",borderRadius:"var(--radius-md)",background:"rgba(255, 255, 255, 0.05)",color:"var(--text-primary)",border:"1px solid var(--glass-border)",fontSize:"var(--font-size-sm)",minWidth:"220px",outline:"none",cursor:"pointer"},children:h.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function ga(){return"javascript:"+encodeURIComponent(`(function(){
2
- if(!/(^|\\.)discord\\.com$/.test(location.hostname)){alert('Dango: use this bookmarklet while on discord.com');return}
3
- var t=null;
4
- try{
5
- window.webpackChunkdiscord_app.push([[Symbol()],{},function(req){
6
- if(!req.c)return;
7
- var ms=Object.values(req.c);
8
- for(var i=0;i<ms.length;i++){var m=ms[i];
9
- try{
10
- if(!m.exports||m.exports===window)continue;
11
- if(typeof m.exports.getToken==='function'){var x=m.exports.getToken();if(x){t=x;return}}
12
- for(var k in m.exports){try{var ex=m.exports[k];if(ex&&typeof ex.getToken==='function'&&ex[Symbol.toStringTag]!=='IntlMessagesProxy'){var y=ex.getToken();if(y){t=y;return}}}catch(e1){}}
13
- }catch(e2){}}
14
- }]);
15
- window.webpackChunkdiscord_app.pop();
16
- }catch(e3){}
17
- if(!t){alert('Dango: could not grab your token. Make sure you are logged in to Discord in this tab, then run the bookmarklet again.');return}
18
- function copyFallback(){var a=document.createElement('textarea');a.value=t;a.style.position='fixed';a.style.opacity='0';document.body.appendChild(a);a.select();try{document.execCommand('copy')}catch(e4){}document.body.removeChild(a)}
19
- var done=function(){window.close();setTimeout(function(){if(!window.closed){alert('Dango: token copied to clipboard! Could not close this tab, so just close it, go back to Dango Settings, paste the token and press Save.')}},250)};
20
- if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(t).then(done,function(){copyFallback();done()})}else{copyFallback();done()}
21
- })()`)}const ma=()=>{const t=qe(ga,[]);return e("div",{style:{marginTop:"0.9rem",paddingTop:"0.9rem",borderTop:"1px dashed var(--border-color)"},children:[e("h4",{style:{margin:"0 0 0.35rem",fontSize:"0.95rem"},children:"Grab the token automatically (bookmarklet)"}),e("p",{style:{margin:"0 0 0.6rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Set this up once and you never have to dig through DevTools: the bookmarklet copies your Discord token to the clipboard and closes the Discord tab - then you just paste it above and press Save."}),e("ol",{style:{margin:"0 0 0.75rem",paddingLeft:"1.25rem",fontSize:"0.85rem",color:"var(--text-secondary)",display:"grid",gap:"0.3rem"},children:[e("li",{children:["Drag the ",e("strong",{style:{color:"var(--text-primary)"},children:"Dango Token Grabber"})," ","button below onto your bookmarks bar (press ",e("kbd",{children:"Ctrl"}),"+",e("kbd",{children:"Shift"}),"+",e("kbd",{children:"B"})," ","first if the bar is hidden)."]}),e("li",{children:["Click ",e("strong",{style:{color:"var(--text-primary)"},children:"Open Discord"})," and log in (skip this if you are already logged in)."]}),e("li",{children:["On the Discord tab, click the"," ",e("strong",{style:{color:"var(--text-primary)"},children:"Dango Token Grabber"})," bookmark. The token lands in your clipboard and the tab closes on its own - come back here, paste it above and press ",e("strong",{children:"Save"}),"."]})]}),e("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",flexWrap:"wrap"},children:[e("a",{href:t,onClick:p=>{p.preventDefault(),alert("Drag this button onto your bookmarks bar instead of clicking it, then click it while you are on discord.com.")},title:"Drag me to your bookmarks bar",draggable:!0,style:{display:"inline-flex",alignItems:"center",padding:"0.4rem 0.8rem",borderRadius:"999px",border:"1px dashed var(--accent)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:"0.85rem",textDecoration:"none",cursor:"grab",userSelect:"none"},children:[e(j,{name:"bookmark",style:{marginRight:"0.45rem",color:"var(--accent)"}}),"Dango Token Grabber"]}),e("a",{className:"btn btn-secondary btn-sm",href:"https://discord.com/channels/@me",target:"_blank",rel:"noopener noreferrer",children:"Open Discord"}),e(C,{variant:"ghost",size:"sm",onClick:async()=>{try{await navigator.clipboard.writeText(t),alert('Bookmarklet code copied. Create a new bookmark on your bookmarks bar, name it "Dango Token" and paste the code as its URL.')}catch{alert(`Could not copy automatically. Right-click the "Dango Token Grabber" button and choose "Copy link address" instead, then paste that into a new bookmark's URL.`)}},children:"Copy code"})]}),e("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:`"Copy code" is a fallback for browsers that won't drag bookmarklets: create any bookmark, then paste the copied code as its URL.`})]})},pa="_settingItem_68mz3_1",fa="_field_68mz3_6",ya="_input_68mz3_19",va="_actions_68mz3_39",wa="_status_68mz3_45",q={settingItem:pa,field:fa,input:ya,actions:va,status:wa},ba=()=>{const[t,s]=r(!1),[c,p]=r(""),[d,y]=r(""),[S,h]=r(!0),[o,a]=r(!1),[g,v]=r("");z(()=>{(async()=>{try{const I=await(await J("/api/auth/app-status")).json();s(I.hasPassword)}catch{console.error("Failed to fetch LAN auth status")}finally{h(!1)}})()},[]);const m=async()=>{if(v(""),c!==d){v("Passwords do not match");return}if(c.length<4){v("Password must be at least 4 characters");return}a(!0);try{const f=await J("/api/auth/app-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:c})}),T=await f.json();if(!f.ok){v(T.error||"Failed to update password");return}s(T.hasPassword),p(""),y(""),v(T.hasPassword?"Password set successfully":"Password removed")}catch{v("Network error")}finally{a(!1)}},x=async()=>{a(!0);try{const f=await J("/api/auth/app-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:""})}),T=await f.json();if(!f.ok){v(T.error||"Failed to remove password");return}s(!1),p(""),y(""),v("Password removed")}catch{v("Network error")}finally{a(!1)}},l=async()=>{a(!0);try{await J("/api/auth/app-logout",{method:"POST"}),v("Logged out"),window.location.reload()}catch{v("Logout failed")}finally{a(!1)}};return S?e("div",{className:_.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:_.sectionCard,children:[e("h3",{children:"LAN Lock"}),e("p",{children:"Require a password to access this instance from any device, including this one. Sessions persist across server restarts until logout or password change."}),e("div",{className:q.settingItem,children:[e("div",{className:q.field,children:[e("label",{htmlFor:"lan-password",children:"New Password"}),e("input",{id:"lan-password",type:"password",value:c,onChange:f=>p(f.currentTarget.value),placeholder:t?"Leave empty to keep current password":"Enter a password...",className:q.input})]}),e("div",{className:q.field,children:[e("label",{htmlFor:"lan-confirm-password",children:"Confirm Password"}),e("input",{id:"lan-confirm-password",type:"password",value:d,onChange:f=>y(f.currentTarget.value),placeholder:"Confirm password...",className:q.input})]}),e("div",{className:q.actions,children:[e(C,{variant:"primary",onClick:m,loading:o,disabled:o,children:t?"Update Password":"Set Password"}),t&&e(C,{variant:"danger",onClick:l,loading:o,disabled:o,children:"Logout"}),t&&e(C,{variant:"secondary",onClick:x,loading:o,disabled:o,children:"Remove Password"})]}),g&&e("p",{className:q.status,children:g})]})]})},Ca=()=>{const[t,s]=r(""),[c,p]=r(!0),[d,y]=r(!1),[S,h]=r("");z(()=>{Q("/api/auth/app-status").then(a=>s(String(a.port??3e3))).catch(()=>h("Failed to load current port")).finally(()=>p(!1))},[]);const o=async()=>{const a=Number(t);if(!Number.isInteger(a)||a<1||a>65535){h("Enter a port between 1 and 65535");return}y(!0),h("");try{await k.auth.setServerPort.mutate({port:a}),h(`Saved. Restart dango, then open http://localhost:${a} - this overrides the PORT environment variable.`)}catch(g){h(g.message)}finally{y(!1)}};return c?e("div",{className:_.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:_.sectionCard,children:[e("h3",{children:"Server Port"}),e("p",{children:"Port the backend listens on. Takes effect after a restart. Google and AniList sign-in need the matching redirect URI registered with the provider."}),e("div",{className:q.settingItem,children:[e("div",{className:q.field,children:[e("label",{htmlFor:"server-port",children:"Port"}),e("input",{id:"server-port",type:"number",min:1,max:65535,value:t,onChange:a=>s(a.currentTarget.value),className:q.input})]}),e("div",{className:q.actions,children:e(C,{variant:"primary",onClick:o,loading:d,disabled:d,children:"Save Port"})}),S&&e("p",{className:q.status,children:S})]})]})},ka=()=>{const[t,s]=r(""),[c,p]=r(!0),[d,y]=r(!1),[S,h]=r("");z(()=>{k.auth.allowedOrigins.query().then(a=>s(a.origins.join(", "))).catch(()=>h("Failed to load allowed origins")).finally(()=>p(!1))},[]);const o=async()=>{y(!0),h("");try{const a=await k.auth.setAllowedOrigins.mutate({origins:t});s(a.origins.join(", ")),h("Saved.")}catch(a){h(a.message)}finally{y(!1)}};return c?e("div",{className:_.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:_.sectionCard,children:[e("h3",{children:"Allowed Origins"}),e("p",{children:["Extra browser origins allowed to call the API, comma-separated. Include the scheme (e.g."," ",e("code",{children:"https://example.com"}),"). Same-origin access and reverse proxies that forward X-Forwarded-Host/X-Forwarded-Proto work automatically."]}),e("div",{className:q.settingItem,children:[e("div",{className:q.field,children:[e("label",{htmlFor:"allowed-origins",children:"Origins"}),e("input",{id:"allowed-origins",value:t,onChange:a=>s(a.currentTarget.value),className:q.input,placeholder:"https://example.com"})]}),e("div",{className:q.actions,children:e(C,{variant:"primary",onClick:o,loading:d,disabled:d,children:"Save Origins"})}),S&&e("p",{className:q.status,children:S})]})]})},Sa=()=>{const{theme:t,setTheme:s,loading:c}=We();return e("div",{children:[e("h4",{style:{margin:"0 0 0.25rem",fontSize:"1rem"},children:"Palette"}),e("p",{style:{margin:"0 0 0.75rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Taro is the default. Pick a palette that suits you."}),e("div",{role:"radiogroup","aria-label":"Palette",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"0.6rem"},children:He.map(p=>{const d=t===p.id;return e("button",{role:"radio","aria-checked":d,disabled:c,onClick:()=>s(p.id),style:{display:"flex",gap:"0.6rem",alignItems:"center",textAlign:"left",padding:"0.65rem 0.75rem",borderRadius:"10px",cursor:"pointer",background:d?"var(--accent-subtle)":"var(--bg-tertiary)",border:d?"1px solid var(--accent)":"1px solid var(--border-primary)",color:"var(--text-primary)"},children:[e("span",{"aria-hidden":!0,style:{width:26,height:26,borderRadius:"50%",flex:"none",background:p.swatch,border:"1px solid rgba(0,0,0,0.35)"}}),e("span",{style:{minWidth:0},children:[e("span",{style:{display:"block",fontSize:"0.85rem",fontWeight:700},children:p.label}),e("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.blurb})]})]},p.id)})})]})};function Na({variant:t="info",children:s,className:c=""}){return e("div",{className:`alert alert-${t} ${c}`,children:s})}const _a=["profile","appearance","presence","server","sync","watchlist"],Ta={general:"profile",database:"sync"},_e=t=>t?_a.includes(t)?t:Ta[t]??null:null,Aa=()=>{const{data:t}=fe(Z),[s,c]=ze(),p=_e(s.get("tab")),[d,y]=r(p??"profile"),[S,h]=r(""),o=X(null),a=X(null),g=X(new Map),[v,m]=r({top:0,height:0,left:0,width:0}),{lowEndMode:x,setLowEndMode:l}=Be(),{hasConsent:f,grant:T,revoke:I}=je(),[G,P]=r(!1),[w,L]=r(Qe),[A,M]=r(Xe),[i,R]=r(!0),{data:D}=de("discordRPCEnabled"),W=Te(),[te,N]=r(!1),{data:ie}=de("frozenMode"),[Pe,ye]=r(!0),{data:ae}=de("discordRPCHideMature"),[ve,oe]=r(""),[ne,ce]=r(null);z(()=>{t?.owner&&k.discord.gatewayStatus.query().then(n=>{ce(n),n.masked&&n.masked!=="none"&&oe(n.masked)}).catch(()=>{})},[t?.owner]),z(()=>{D!==void 0&&R(D==="true"||D===!0||D===null)},[D]),z(()=>{ae!==void 0&&ye(ae==="true"||ae===!0||ae===null)},[ae]);const Ie=n=>{R(n),W.mutate({key:"discordRPCEnabled",value:String(n)})};z(()=>{ie!==void 0&&N(ie==="true"||ie===!0)},[ie]);const Le=n=>{N(n),W.mutate({key:"frozenMode",value:String(n)})},xe=n=>{ye(n),W.mutate({key:"discordRPCHideMature",value:String(n)})},Re=n=>{L(n),Ve.setItem(Ye,String(n)),window.dispatchEvent(new CustomEvent(Je))},De=n=>{M(n),Ze(n)};be.useEffect(()=>{document.title="Settings - dango"},[]),be.useEffect(()=>{const n=_e(s.get("tab"));n&&y(n)},[s]);const V=n=>{y(n),c(n==="profile"?{}:{tab:n})},re=pe(()=>{const n=g.current.get(d),U=a.current;if(n&&U){const Y=U.getBoundingClientRect(),$=n.getBoundingClientRect(),se=window.matchMedia("(max-width: 900px)").matches;m(se?{top:$.top-Y.top,height:$.height,left:$.left-Y.left,width:$.width}:{top:$.top-Y.top,height:$.height,left:0,width:0})}},[d]);Ke(()=>{re()},[d,re]),z(()=>{const n=()=>re();window.addEventListener("resize",n);let U=!1;return document.fonts?.ready&&document.fonts.ready.then(()=>{U||re()}),()=>{U=!0,window.removeEventListener("resize",n)}},[d,re]);const Oe=()=>{h("Exporting databases...");const n=window.DangoBridge;if(n?.downloadFile){n.downloadFile("/api/backup-db","dango-backup.json"),setTimeout(()=>{h("Databases exported successfully!")},1500);return}const U=document.createElement("a");U.href="/api/backup-db",U.download="dango-backup.json",document.body.appendChild(U),U.click(),U.remove(),setTimeout(()=>{h("Databases exported successfully!")},1500)},Ae=async n=>{const U=n.currentTarget.files?.[0];if(!U)return;h("Importing databases...");const Y=new FormData;Y.append("dbfile",U);try{const $=await J("/api/restore-db",{method:"POST",body:Y}),se=await $.json();if($.ok){const we=Array.isArray(se.restored)?se.restored.join(", "):null;h(we?`Databases imported successfully (${we})!`:"Database imported successfully!"),setTimeout(()=>window.location.reload(),2e3)}else h(`Import failed: ${se.error}`)}catch{h("Import failed: An unexpected error occurred.")}finally{n.currentTarget.value=""}},Me=()=>{o.current?.click()},Ge=()=>{switch(d){case"profile":return e("div",{className:u.tabContent,children:[e(rt,{}),e("div",{className:_.sectionCard,children:[e("h3",{children:"Mature Content"}),e("p",{children:"Allow mature content intended for adults 18 and older. Turning this off restores filtering and blur gates."}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:_.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Mature Content"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Allow mature content intended for adults 18 and older. Turning this off restores filtering and blur gates."})]}),e(F,{isChecked:f,onChange:n=>{n.currentTarget.checked?P(!0):(I(),window.location.reload())},id:"mature-content-enabled"})]})})]})]});case"appearance":return e("div",{className:u.tabContent,children:[e("div",{className:_.sectionCard,children:[e("h3",{children:"Appearance & Preferences"}),e("p",{children:"Configure how titles are displayed and other general preferences."}),e("div",{className:u.settingItem,children:e(st,{})}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e(Sa,{})}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:_.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Low End Mode"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Disables animations and heavy visual effects for better performance on older hardware."})]}),e(F,{isChecked:x,onChange:n=>l(n.currentTarget.checked),id:"low-end-mode"})]})}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:_.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Watched Episode Overlay"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Shows watched and completed episodes as an overlay on the player. Turn this off to use a popup instead."})]}),e(F,{isChecked:A,onChange:n=>De(n.currentTarget.checked),id:"watched-overlay-enabled"})]})}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:_.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Virtual Keyboard"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Shows an on-screen keyboard when text search fields are focused."})]}),e(F,{isChecked:w,onChange:n=>Re(n.currentTarget.checked),id:"virtual-keyboard-enabled"})]})})]}),e("section",{className:_.sectionCard,children:[e("h3",{children:"Keyboard Shortcuts"}),e("p",{children:"Use S or Ctrl+K to focus search anywhere, or use player keys while watching."}),e("div",{className:u.shortcutContainer,children:[e("div",{className:u.shortcutGroup,children:[e("h4",{className:u.shortcutGroupTitle,children:"Search"}),e("div",{className:u.shortcutGrid,children:[e("div",{className:u.shortcutCard,children:[e("kbd",{children:"S"}),e("span",{children:"Focus search"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"Ctrl + K / ⌘ + K"}),e("span",{children:"Focus search"})]})]})]}),e("div",{className:u.shortcutGroup,children:[e("h4",{className:u.shortcutGroupTitle,children:"Player"}),e("div",{className:u.shortcutGrid,children:[e("div",{className:u.shortcutCard,children:[e("kbd",{children:"Space / K"}),e("span",{children:"Play / pause"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"J / L · ← / →"}),e("span",{children:"Seek back / fwd"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"↑ / ↓"}),e("span",{children:"Adjust volume"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"M / F"}),e("span",{children:"Mute / fullscreen"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"N / P"}),e("span",{children:"Next / prev episode"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"T"}),e("span",{children:"Theater mode"})]})]})]})]})]})]});case"presence":return e("div",{className:u.tabContent,children:e("div",{className:_.sectionCard,children:[e("h3",{children:"Discord Presence"}),e("p",{children:"Control what Dango shares on Discord."}),t?.owner&&e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:_.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Discord Rich Presence"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Show your current anime and watch progress on your Discord profile status."})]}),e(F,{isChecked:i,onChange:n=>Ie(n.currentTarget.checked),id:"discord-rpc-enabled"})]})}),t?.owner&&i&&e("div",{className:u.settingItem,style:{marginTop:"1rem"},children:e("div",{className:_.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Hide Mature Content"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Hide mature content (18+) from Discord Rich Presence."})]}),e(F,{isChecked:Pe,onChange:n=>xe(n.currentTarget.checked),id:"discord-hide-mature"})]})}),t?.owner&&e("div",{className:u.settingItem,style:{marginTop:"1.5rem",background:"var(--bg-tertiary)",padding:"1rem",borderRadius:"8px",border:"1px solid var(--border-color)"},children:[e("div",{className:_.settingRow,children:e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Discord Mobile Presence (Gateway)"}),e("p",{style:{margin:"0.25rem 0 0.75rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Paste your Discord authentication token to enable presence on mobile devices. If no token is saved, the default desktop Rich Presence is used. The token is stored locally in your configuration and never shared."})]})}),e(Na,{variant:"warning",style:{marginTop:"1.25rem",paddingTop:"1.25rem"},children:[e("strong",{children:"Use at your own risk."})," This feature uses the Discord Gateway API with your user token, which violates Discord's Terms of Service. Discord may detect this usage and take action against your account, including phone number locks, temporary suspensions, or permanent bans. While the risk is generally low, it is not zero. Only use this if you understand and accept the risks."]}),e("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem",alignItems:"center",flexWrap:"wrap"},children:[e("input",{type:"password",value:ve,onChange:n=>oe(n.currentTarget.value),placeholder:"Paste Discord token here...",style:{flex:"1 1 200px",padding:"0.5rem",borderRadius:"4px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)",fontFamily:"monospace",minWidth:0}}),e(C,{variant:"primary",size:"sm",onClick:async()=>{try{const n=await k.discord.gatewaySave.mutate({token:ve});ce({hasToken:!0,masked:n.masked,enabled:!0}),oe(n.masked)}catch(n){alert(n instanceof Error?n.message:"Failed to save token")}},children:"Save"}),e(C,{variant:"secondary",size:"sm",onClick:async()=>{await k.discord.gatewayRemove.mutate().catch(()=>{}),oe(""),ce({hasToken:!1,masked:null,enabled:!1})},children:"Remove"})]}),ne&&e("p",{style:{marginTop:"0.5rem",fontSize:"0.8rem",color:ne.hasToken?"green":"var(--text-secondary)"},children:["Status:"," ",ne.hasToken?`Token saved (${ne.masked})`:"No token saved",ne.enabled?" - Gateway active":""]}),t?.owner&&e(ma,{})]})]})});case"server":return e("div",{className:u.tabContent,children:[t?.owner&&e(ba,{}),t?.owner&&e(Ca,{}),t?.owner&&e(ka,{}),e(da,{})]});case"sync":return e("div",{className:u.tabContent,children:[e(ha,{}),e(Mt,{}),e(Gt,{}),t?.owner&&e(ua,{}),e("div",{className:_.sectionCard,children:[e("h3",{children:"Frozen Mode"}),e("p",{children:"When on, nothing is saved or synced."}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:_.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Frozen Mode"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"When on, nothing is saved or synced: no watchlist, progress, resume, or settings changes, and no cloud sync (GitHub/Google/rclone) or tracker push. Useful for experimentation and private sessions."})]}),e(F,{isChecked:te,onChange:n=>Le(n.currentTarget.checked),id:"frozen-mode"})]})})]}),e("div",{className:_.sectionCard,children:[e("h3",{children:"Database Management"}),e("p",{children:"Download a backup of all databases (anime, manga, TV and ASMR) or restore from a backup file. Legacy single-file anime (.db) backups can still be restored."}),e("div",{className:u.controls,children:[e(C,{onClick:Oe,children:"Backup Database"}),e(C,{variant:"secondary",onClick:Me,children:"Restore Database"})]}),e("input",{type:"file",ref:o,onChange:Ae,style:{position:"absolute",width:1,height:1,opacity:0,overflow:"hidden"},accept:".json,.db,application/octet-stream"}),S&&e("p",{className:u.status,children:S})]}),t?.owner&&e(ia,{})]});case"watchlist":return e("div",{className:u.tabContent,children:e(Ht,{})});default:return null}};return e("div",{className:"page-container",children:[e("div",{className:u.settingsHeader,children:[e("h1",{className:u.pageTitle,children:"Settings"}),e("p",{className:u.pageSubtitle,children:"Manage your preferences and data synchronization"})]}),e("div",{className:u.settingsLayout,children:[e("aside",{className:u.sidebar,ref:a,children:[e("div",{className:u.sidebarIndicator,style:{top:v.top,height:v.height,left:v.left,...v.width?{width:v.width}:{}}}),e("button",{ref:n=>{n&&g.current.set("profile",n)},className:`${u.sidebarItem} ${d==="profile"?u.active:""}`,onClick:()=>V("profile"),children:[e(j,{name:"user-astronaut"})," ",e("span",{children:"Profile"})]}),e("button",{ref:n=>{n&&g.current.set("appearance",n)},className:`${u.sidebarItem} ${d==="appearance"?u.active:""}`,onClick:()=>V("appearance"),children:[e(j,{name:"image"})," ",e("span",{children:"Appearance"})]}),e("button",{ref:n=>{n&&g.current.set("presence",n)},className:`${u.sidebarItem} ${d==="presence"?u.active:""}`,onClick:()=>V("presence"),children:[e(j,{name:"discord"})," ",e("span",{children:"Presence"})]}),e("button",{ref:n=>{n&&g.current.set("server",n)},className:`${u.sidebarItem} ${d==="server"?u.active:""}`,onClick:()=>V("server"),children:[e(j,{name:"server"})," ",e("span",{children:"Server"})]}),e("button",{ref:n=>{n&&g.current.set("sync",n)},className:`${u.sidebarItem} ${d==="sync"?u.active:""}`,onClick:()=>V("sync"),children:[e(j,{name:"cloud"})," ",e("span",{children:"Sync & Data"})]}),e("button",{ref:n=>{n&&g.current.set("watchlist",n)},className:`${u.sidebarItem} ${d==="watchlist"?u.active:""}`,onClick:()=>V("watchlist"),children:[e(j,{name:"list"})," ",e("span",{children:"Lists"})]})]}),e("main",{className:u.mainContent,children:e("div",{className:u.tabContent,children:Ge()},d)})]}),e(et,{isOpen:G,onClose:()=>P(!1),onGrant:()=>{T(),P(!1)},scope:"section"})]})};export{Aa as default};
@@ -1 +0,0 @@
1
- import{d as n,h as b,T as k,u as T}from"./vendor-core-DfaOB3Rn.js";import{ak as _,t as m,k as w,i as I,l as P}from"./index-BkgRRmBf.js";import{d as D}from"./useTvLibrary-DV4KK5BN.js";import{a as W}from"./MediaCard-Bffh2g9C.js";const S=({item:e,anchorRect:l,onMouseEnter:i,onMouseLeave:c,onRequestClose:p})=>{const[a,u]=n(null),[d,r]=n(!0),{toggle:v,bookmarkedIds:g}=D(),y=_(e.type,e.id),f=g.has(y);b(()=>{let o=!1;return r(!0),m.tv.details.query({type:e.type,id:String(e.id)}).then(s=>{o||(u({overview:s.overview,vote_average:s.vote_average,number_of_seasons:s.number_of_seasons}),r(!1))}).catch(()=>{o||r(!1)}),()=>{o=!0}},[e.id,e.type]);const h=k(()=>a?.genres?a.genres.slice(0,4).map(o=>o.name):[],[a?.genres]),t=[];return a?.vote_average!=null&&a.vote_average>0&&t.push({icon:"star",label:Number(a.vote_average).toFixed(1),accent:!0}),t.push({icon:"tv",label:e.type==="tv"?"TV Show":"Movie"}),e.year&&t.push({label:e.year}),a?.status&&t.push({label:a.status}),T(W,{anchorRect:l,title:e.title,loading:d,meta:t,genres:h,synopsis:P(a?.overview,200),primaryAction:{to:I(e.type,e.id),label:"Watch now",icon:"play"},secondaryAction:{to:w(e.type,e.id),label:"Details",icon:"info-circle"},bookmarked:f,onToggleBookmark:()=>v({tmdbId:e.id,mediaType:e.type,title:e.title,poster:e.image,year:e.year}),onMouseEnter:i,onMouseLeave:c,onRequestClose:p})};export{S as T};