@serifpersia/dango 3.7.6 → 3.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +3 -1
  2. package/client/dist/assets/{AnimeCard-a7KkMGQv.js → AnimeCard-B_eNHj3Q.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-De3gudGy.js → AnimeInfo-B4DtKpJi.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-adJHjnqz.js → AnimeInfoPage-BTJBbJx7.js} +2 -2
  5. package/client/dist/assets/Asmr-DB4F0zQm.js +2 -0
  6. package/client/dist/assets/{AsmrResetProgressModal-CZGzmnlI.js → AsmrResetProgressModal-BkO6uAVo.js} +1 -1
  7. package/client/dist/assets/Home-BYtjQAAm.js +1 -0
  8. package/client/dist/assets/Insights-kd8R5HFL.js +1 -0
  9. package/client/dist/assets/{LibraryListPage-CgZiYRmp.js → LibraryListPage-BXCoAwO-.js} +1 -1
  10. package/client/dist/assets/{ListeningList-DX_Imiie.js → ListeningList-B58inkaW.js} +1 -1
  11. package/client/dist/assets/Manga-B09DXrt3.js +1 -0
  12. package/client/dist/assets/{MangaInfoPage-D_3Rx6rr.js → MangaInfoPage-HniBD97j.js} +1 -1
  13. package/client/dist/assets/MangaReadPage-XTo4eB8e.js +1 -0
  14. package/client/dist/assets/{MangaResetProgressModal-Bd_lIuFo.js → MangaResetProgressModal-DgD2JJiz.js} +1 -1
  15. package/client/dist/assets/Mature--NRjmFgA.js +1 -0
  16. package/client/dist/assets/{MatureConsentModal-RZ_j_2BD.js → MatureConsentModal-BxCEXBbj.js} +1 -1
  17. package/client/dist/assets/{MediaCard-BODgA6ir.js → MediaCard-BXWAjpwt.js} +1 -1
  18. package/client/dist/assets/OptionListMenu-DHzVKmrw.js +1 -0
  19. package/client/dist/assets/Player-BopSS6Gv.js +56 -0
  20. package/client/dist/assets/PlayerProvider-Cj4nkG1Z.js +1 -0
  21. package/client/dist/assets/PlayerSettings-BEorvGw8.js +1 -0
  22. package/client/dist/assets/{QueueOptionsButton-C-y5QFrT.js → QueueOptionsButton-E2SuRJH_.js} +1 -1
  23. package/client/dist/assets/{QueueRail-DGFI6xTM.js → QueueRail-ZlyY6iwq.js} +1 -1
  24. package/client/dist/assets/{ReadingList-BB_fA_j0.js → ReadingList-DEOzfsq9.js} +1 -1
  25. package/client/dist/assets/{ResetProgressModal-DEnbScHS.js → ResetProgressModal-B4qmiw-m.js} +1 -1
  26. package/client/dist/assets/Search-C2mxeTuG.js +1 -0
  27. package/client/dist/assets/Settings-BqOAQxhe.js +21 -0
  28. package/client/dist/assets/Settings-D37LNfis.css +1 -0
  29. package/client/dist/assets/{SkeletonGrid-w6TsxWu7.js → SkeletonGrid-Od92F7If.js} +1 -1
  30. package/client/dist/assets/Trackers-CyWVHtOz.js +2 -0
  31. package/client/dist/assets/Tv-B8tWYqQt.js +4 -0
  32. package/client/dist/assets/TvInfo-CYh7oICz.js +1 -0
  33. package/client/dist/assets/TvPopup-8uQGvzWG.js +1 -0
  34. package/client/dist/assets/TvSearch-DMc5DzU4.js +1 -0
  35. package/client/dist/assets/{TvWatchlist-er5RKLmv.js → TvWatchlist-fPe4D63a.js} +1 -1
  36. package/client/dist/assets/VirtualKeyboard-CjOEv-Zs.js +1 -0
  37. package/client/dist/assets/WatchAlong-Cd_rNUGz.js +1 -0
  38. package/client/dist/assets/WatchAlongPanel-BKprdx-w.js +1 -0
  39. package/client/dist/assets/WatchAlongPanel-DbJuLqxU.css +1 -0
  40. package/client/dist/assets/{Watchlist-BiJ1SCAH.js → Watchlist-DMj82PtZ.js} +1 -1
  41. package/client/dist/assets/index-B_2ppn5P.js +178 -0
  42. package/client/dist/assets/index-DP9TtvZX.css +1 -0
  43. package/client/dist/assets/{libraryInvalidation-CVK2SYUR.js → libraryInvalidation-DeUzK6TJ.js} +1 -1
  44. package/client/dist/assets/playbackCompletion-_kwPgoZi.js +1 -0
  45. package/client/dist/assets/{useAnimeInfoData-8RI9qMzw.js → useAnimeInfoData-CH9hmj5A.js} +1 -1
  46. package/client/dist/assets/{useAsmr-ClAcWwjW.js → useAsmr-DQsv1SQT.js} +1 -1
  47. package/client/dist/assets/{useAsmrPopup-CDcDqi0C.js → useAsmrPopup-6kWviNqn.js} +1 -1
  48. package/client/dist/assets/{useMangaLibrary-D3Foz2m_.js → useMangaLibrary-DlU4Z9JL.js} +1 -1
  49. package/client/dist/assets/{useMangaPopup-kZzwoCN6.js → useMangaPopup-3MuX6uO9.js} +1 -1
  50. package/client/dist/assets/{useProviders-OKWPunZg.js → useProviders-Dx9rG8FY.js} +1 -1
  51. package/client/dist/assets/useTv-DZQzHJgO.js +1 -0
  52. package/client/dist/assets/useTvLibrary-DVpLBz5c.js +1 -0
  53. package/client/dist/assets/useWatchAlongPlayer-KZT7d2pQ.js +10 -0
  54. package/client/dist/index.html +2 -2
  55. package/package.json +2 -2
  56. package/server/dist/config.js +1 -1
  57. package/server/dist/profile-scope.js +1 -0
  58. package/server/dist/server.js +257 -249
  59. package/server/dist/shipped-defaults.js +1 -1
  60. package/server/package.json +2 -2
  61. package/client/dist/assets/Asmr-BH3j9n5n.js +0 -2
  62. package/client/dist/assets/Home-4lO9InFx.js +0 -1
  63. package/client/dist/assets/Insights-Co9pEzWb.js +0 -1
  64. package/client/dist/assets/Manga-tDOa59vQ.js +0 -1
  65. package/client/dist/assets/MangaReadPage-D0satiXp.js +0 -1
  66. package/client/dist/assets/Mature-DhozU6BP.js +0 -1
  67. package/client/dist/assets/OptionListMenu-CGazCg0C.js +0 -1
  68. package/client/dist/assets/Player-M3yMiFzg.js +0 -56
  69. package/client/dist/assets/PlayerProvider-pi0at080.js +0 -1
  70. package/client/dist/assets/PlayerSettings-k4bqwbns.js +0 -1
  71. package/client/dist/assets/Search-Dikasx2q.js +0 -1
  72. package/client/dist/assets/Settings-CCoAhBc0.js +0 -21
  73. package/client/dist/assets/Settings-DYjRBgpE.css +0 -1
  74. package/client/dist/assets/Trackers-CoM-8Hz9.js +0 -2
  75. package/client/dist/assets/Tv-BLUeZ2n8.js +0 -4
  76. package/client/dist/assets/TvInfo-BjFZ57fG.js +0 -1
  77. package/client/dist/assets/TvPopup-D6UvGI7M.js +0 -1
  78. package/client/dist/assets/TvSearch-BDNZjbZo.js +0 -1
  79. package/client/dist/assets/VirtualKeyboard-DeP7fb3P.js +0 -1
  80. package/client/dist/assets/index-5x1mF1nD.css +0 -1
  81. package/client/dist/assets/index-BP1z44Uk.js +0 -178
  82. package/client/dist/assets/playbackCompletion-IPHm9fp5.js +0 -1
  83. package/client/dist/assets/usePlaybackEnd-DmvZ__Ut.js +0 -10
  84. package/client/dist/assets/useTv-BgO7EV-p.js +0 -1
  85. package/client/dist/assets/useTvLibrary-C6rSJQi_.js +0 -1
  86. /package/client/dist/assets/{usePlaybackEnd-BMf_H2dw.css → useWatchAlongPlayer-BMf_H2dw.css} +0 -0
@@ -1,56 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-k4bqwbns.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-icons-DrybRNxP.js","assets/OptionListMenu-CGazCg0C.js","assets/usePlaybackEnd-DmvZ__Ut.js","assets/index-BP1z44Uk.js","assets/vendor-query-BBT5_sHx.js","assets/index-5x1mF1nD.css","assets/PlayerProvider-pi0at080.js","assets/PlayerProvider-N2pT5gty.css","assets/playbackCompletion-IPHm9fp5.js","assets/usePlaybackEnd-BMf_H2dw.css","assets/PlayerSettings-BXGe3F5k.css"])))=>i.map(i=>d[i]);
2
- import{u as t,g as dt,h as F,P as zt,z as jt,d as ae,A as R,q as O,y as Ht,T as Me,o as Yt,a as Xt,c as Jt,_ as Zt,S as ct}from"./vendor-core-DfaOB3Rn.js";import{P as er,a as tr,b as rr,F as nr,s as sr,c as or}from"./PlayerProvider-pi0at080.js";import{u as Rt,b as Tt,a as yt}from"./vendor-query-BBT5_sHx.js";import{p as St,s as ar,C as ir,P as lr,a as cr,b as Ie,c as Ct,f as Nt,d as ur,e as dr,g as mr,r as fr,u as pr,h as hr,i as vr,j as gr,k as yr,l as br,m as Sr,n as be,A as Er,o as wr,R as kr,E as Tr,q as Cr,t as w,v as Mr,w as Rr,x as Nr}from"./usePlaybackEnd-DmvZ__Ut.js";import{I as me}from"./vendor-icons-DrybRNxP.js";import{_ as Pt,S as Ye,i as Pr,q as oe,t as de,A as we,O as Ar,P as Ve,M as mt,e as _r,m as xr,n as Br,o as Lr,p as Dr,d as $r,u as Ir,B as ut,Q as Fr,f as Or}from"./index-BP1z44Uk.js";import{l as Wr,i as Ur,s as Vr}from"./playbackCompletion-IPHm9fp5.js";import{M as Qr}from"./MatureConsentModal-RZ_j_2BD.js";import{u as Kr}from"./useIsMobile-Dvx1uJ82.js";import{s as Ee,Q as Gr}from"./QueueRail-DGFI6xTM.js";import{u as qr,Q as zr}from"./QueueOptionsButton-C-y5QFrT.js";import{u as At}from"./useProviders-OKWPunZg.js";import{A as jr}from"./AnimeMetaDetails-B3-A7O5H.js";import{S as Hr}from"./SynopsisText-B3Sa5pRv.js";import"./vendor-ui-3qrARCPr.js";const Yr="_controlsOverlay_cejny_1",Xr="_hidden_cejny_21",Jr="_topControls_cejny_27",Zr="_backBtn_cejny_47",en="_videoTitleInfo_cejny_67",tn="_animeTitle_cejny_73",rn="_episodeNumber_cejny_83",nn="_bottomControls_cejny_91",sn="_progressBarContainer_cejny_110",on="_progressBar_cejny_110",an="_thumb_cejny_129",ln="_scrubbing_cejny_144",cn="_watchedBar_cejny_148",un="_bufferedBar_cejny_149",dn="_timeBubble_cejny_187",mn="_skipSegment_cejny_221",fn="_bottomControlsRow_cejny_231",pn="_leftControls_cejny_239",hn="_rightControls_cejny_240",vn="_controlBtn_cejny_247",gn="_theaterBtn_cejny_288",yn="_nextEpisodeBtn_cejny_292",bn="_active_cejny_313",Sn="_timeDisplay_cejny_317",En="_skipControls_cejny_325",x={controlsOverlay:Yr,hidden:Xr,topControls:Jr,backBtn:Zr,videoTitleInfo:en,animeTitle:tn,episodeNumber:rn,bottomControls:nn,progressBarContainer:sn,progressBar:on,thumb:an,scrubbing:ln,watchedBar:cn,bufferedBar:un,timeBubble:dn,skipSegment:mn,bottomControlsRow:fn,leftControls:pn,rightControls:hn,controlBtn:vn,theaterBtn:gn,nextEpisodeBtn:yn,active:bn,timeDisplay:Sn,skipControls:En},wn=({player:r,handlers:n,visible:l,skipIntervals:m,showNextEpisodeButton:i,onNextEpisode:o,isTheaterMode:s,onTheaterModeToggle:c,settingsBtnRef:u,timeDisplayRef:f})=>{const{state:k,refs:e,actions:a}=r,{showSettings:A}=k;return t("div",{className:`${x.controlsOverlay} ${l?"":x.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:x.bottomControls,"data-speed-boost-ignore":"true",onClick:h=>h.stopPropagation(),children:[t(er,{classes:{container:x.progressBarContainer,scrubbing:x.scrubbing,timeBubble:x.timeBubble,bar:x.progressBar,buffered:x.bufferedBar,watched:x.watchedBar,thumb:x.thumb},timeLabelRef:f,children:[k.duration>0&&r.state.currentSkipInterval&&t("div",{className:`${x.skipSegment} ${x[r.state.currentSkipInterval.skip_type]} `,style:{left:`${r.state.currentSkipInterval.start_time/k.duration*100}% `,width:`${(r.state.currentSkipInterval.end_time-r.state.currentSkipInterval.start_time)/k.duration*100}% `}}),m.map(h=>{const C=h.start_time/k.duration*100,M=(h.end_time-h.start_time)/k.duration*100;return t("div",{className:`${x.skipSegment} ${x[h.skip_type]} `,style:{left:`${C}% `,width:`${M}% `},title:h.skip_type.toUpperCase()},h.skip_id)})]}),t("div",{className:x.bottomControlsRow,children:[t("div",{className:x.leftControls,children:[t(tr,{className:x.controlBtn}),t(rr,{buttonClassName:x.controlBtn,onExpandedChange:a.setShowVolumeSlider}),t("span",{className:x.timeDisplay,ref:f,children:[a.formatTime(0)," / ",a.formatTime(k.duration)]}),k.currentSkipInterval&&!k.isAutoSkipEnabled&&t("button",{className:x.controlBtn,onClick:()=>{e.videoRef.current&&k.currentSkipInterval&&(e.videoRef.current.currentTime=k.currentSkipInterval.end_time,a.setCurrentSkipInterval(null))},children:["Skip ",k.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),t("div",{className:x.rightControls,children:[t("div",{className:x.skipControls,children:i&&t("button",{className:x.nextEpisodeBtn,onClick:o,title:"Play next episode",children:"Next EP"})}),t("button",{className:`${x.controlBtn} ${n.isSubtitleActive?x.active:""}`,onClick:n.handleCCToggle,title:n.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:t(me,{name:"closed-captioning",size:22})}),t("button",{ref:u,className:`${x.controlBtn} ${A?x.active:""} `,onClick:()=>a.setShowSettings(!A),"aria-label":"Settings",children:t(me,{name:"cog"})}),t("button",{className:`${x.controlBtn} ${x.theaterBtn} ${s?x.active:""} `,onClick:h=>{h.stopPropagation(),c()},title:s?"Exit Theater Mode":"Theater Mode","aria-label":s?"Exit Theater Mode":"Theater Mode",children:t(me,{name:"tv"})}),t(nr,{className:x.controlBtn})]})]})]})})};function kn(r){const{state:n,refs:l,actions:m}=r,i=c=>{if(!l.videoRef.current)return;m.setActiveSubtitleTrack(c);try{if(c===null||c==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const f=n.availableSubtitles.find(k=>k.label===c||k.lang===c);f?localStorage.setItem("playerLastSubtitle",ar(f)):localStorage.setItem("playerLastSubtitle",c)}}catch{}let u=!1;Array.from(l.videoRef.current.textTracks).forEach(f=>{const e=c!==null&&c!=="off"&&(f.language===c||f.label===c)&&!u;f.mode=e?"showing":"hidden",e&&(u=!0)})},o=n.activeSubtitleTrack!==null&&n.activeSubtitleTrack!=="off";return{handleSubtitleSelection:i,isSubtitleActive:o,handleCCToggle:()=>{if(!l.videoRef.current)return;if(o){i("off");return}if(n.availableSubtitles.length===0)return;let c=null;try{c=localStorage.getItem("playerLastSubtitle")}catch{}const u=St(n.availableSubtitles,{lastKey:c,enabled:!0});if(u<0)return;const f=n.availableSubtitles[u];i(f.label||f.lang)}}}const Tn=jt(()=>Pt(()=>import("./PlayerSettings-k4bqwbns.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),Cn=({player:r,isAutoplayEnabled:n,onAutoplayChange:l,showNextEpisodeButton:m,onNextEpisode:i,videoSources:o,selectedSource:s,selectedLink:c,onSourceChange:u,loadingVideo:f,skipIntervals:k,animeTitle:e,episodeNumber:a,isTheaterMode:A,onTheaterModeToggle:h,anime4kEnabled:C,onAnime4kToggle:M,anime4kSupported:N,anime4kProfile:B,onAnime4kProfileChange:y,anime4kInitializing:p,anime4kError:P,videoDelayEnabled:d,onVideoDelayToggle:S,videoDelayMs:_,onVideoDelayChange:z,onCalibrateAvSync:W,fallbackChoice:H,onFallbackChoiceChange:j,ambientSettings:D,onAmbientChange:L,children:K,overlays:U,isInteractingExtra:b=!1,className:g,hideChrome:T=!1})=>{const{state:E,actions:Y}=r,{showSettings:X}=E,{setShowSettings:V}=Y,Q=kn(r),Z=dt.useRef(null),Se=dt.useRef(null),Ae=dt.useRef(null);F(()=>{const q=he=>{Z.current&&!Z.current.contains(he.target)&&Se.current&&!Se.current.contains(he.target)&&X&&V(!1)};return X&&document.addEventListener("mousedown",q),()=>{document.removeEventListener("mousedown",q)}},[X,V]);const Re=E.showControls||X||E.isScrubbing,ee=t(cr,{visible:Re,title:e,episode:a?`Episode ${a}`:void 0,onBack:()=>window.history.back(),classes:{overlay:x.controlsOverlay,hidden:x.hidden,top:x.topControls,backBtn:x.backBtn,titleInfo:x.videoTitleInfo,title:x.animeTitle,episode:x.episodeNumber}}),G=!f&&!E.isBuffering&&E.duration>0?t(ir,{}):null,ke=t(wn,{player:r,handlers:Q,visible:Re,skipIntervals:k,showNextEpisodeButton:m,onNextEpisode:i,isTheaterMode:A,onTheaterModeToggle:h,settingsBtnRef:Se,timeDisplayRef:Ae}),_e=t(zt,{fallback:null,children:t(Tn,{ref:Z,isOpen:X,onClose:()=>V(!1),videoSources:o,currentSource:s,currentLink:c,onSourceChange:u,subtitles:E.availableSubtitles,activeSubtitleTrack:E.activeSubtitleTrack,onSubtitleChange:Q.handleSubtitleSelection,subtitleSettings:{fontSize:E.subtitleFontSize,position:E.subtitlePosition,bgOpacity:E.subtitleBgOpacity,bgColor:E.subtitleBgColor,textColor:E.subtitleTextColor,edge:E.subtitleEdge,bold:E.subtitleBold},onSubtitleSettingsChange:Y.setSubtitleStyle,useNativeControls:E.useNativeControls,onNativeControlsToggle:Y.setUseNativeControls,anime4kEnabled:C,onAnime4kToggle:M,anime4kSupported:N,anime4kProfile:B,onAnime4kProfileChange:y,anime4kInitializing:p,anime4kError:P,videoDelayEnabled:d,onVideoDelayToggle:S,videoDelayMs:_,onVideoDelayChange:z,onCalibrateAvSync:W,isAutoSkipEnabled:E.isAutoSkipEnabled,onAutoSkipChange:q=>{Y.setIsAutoSkipEnabled(q);try{localStorage.setItem("autoSkipEnabled",q.toString())}catch{}},isAutoplayEnabled:n,onAutoplayChange:l,fallbackChoice:H,onFallbackChoiceChange:j,isTheaterMode:A,ambientSettings:D,onAmbientChange:L})}),te=X?t("div",{"data-speed-boost-ignore":"true",onClick:q=>q.stopPropagation(),children:_e}):null;return t(lr,{engine:r.engine,topBar:ee,centerControls:G,bottomBar:!f&&E.duration>0?ke:null,settingsPanel:te,overlays:U,isInteracting:b||E.showSettings||E.showVolumeSlider,nativeControls:E.useNativeControls,className:g,chromeDisabled:T,children:K})},Mn=({count:r=3})=>t("section",{className:Ee.section,children:[t("div",{className:Ee.header,children:t("button",{className:Ee.headerToggle,disabled:!0,children:[t("span",{className:Ee.title,children:t(Ye,{width:"60px",height:"1.2rem",variant:"text"})}),t(me,{name:"chevron-down",style:{opacity:.3}})]})}),t("div",{className:Ee.list,children:Array.from({length:r}).map((n,l)=>t("div",{className:Ee.item,style:{pointerEvents:"none"},children:[t("div",{className:Ee.dragHandle,style:{opacity:.2},children:t(Ye,{width:"16px",height:"16px",variant:"rectangular"})}),t("div",{className:Ee.thumbnail,style:{overflow:"hidden",background:"transparent"},children:t(Ye,{width:"100%",height:"100%",variant:"rectangular"})}),t("div",{className:Ee.meta,children:[t(Ye,{width:"80%",height:"1.2rem",variant:"text",className:Ee.metaGap}),t(Ye,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},l))})]}),Rn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Nn={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Pn=["direct","cookie","embed"],An=({selectedProvider:r,onProviderChange:n,isAdult:l,options:m})=>{const o=(m&&m.length>0?m:[]).filter(s=>s.mature===(l===!0));return t("div",{className:Ie.providerSelectContainer,children:[t("h4",{children:"Provider"}),t("select",{className:Ie.providerSelect,value:r,onChange:s=>n(s.currentTarget.value),children:Pn.map(s=>{const c=o.filter(u=>(u.tier??"direct")===s);return c.length===0?null:t("optgroup",{label:Nn[s],children:c.map(u=>t("option",{value:u.id,children:u.sub?`${u.label} (${Rn[u.sub]})`:u.label},u.id))},s)})})]})},_n=({videoSources:r,selectedSource:n,selectedLink:l,onSourceChange:m,onLinkChange:i})=>{const o=Array.isArray(r)?r:[];if(o.length===0)return null;const s=n?.type==="iframe"&&(n.links?.length??0)>1;return t("div",{className:Ie.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:Ie.sourceButtons,children:o.map((c,u)=>t("button",{className:`${Ie.sourceButton} ${n?.sourceName===c.sourceName?Ie.active:""} `,onClick:()=>m(c),children:c.sourceName},`${c.sourceName}-${u}`))}),s&&t("select",{className:Ie.sourceSelect,"aria-label":"Fallback embed quality",value:l?.link??n.links[0]?.link??"",onChange:c=>{const u=n.links.find(f=>f.link===c.currentTarget.value);u&&i(u)},children:n.links.map(c=>t("option",{value:c.link,children:c.resolutionStr},c.link))})]})},xn=dt.memo(_n,(r,n)=>r.selectedSource?.sourceName===n.selectedSource?.sourceName&&r.selectedLink?.link===n.selectedLink?.link&&r.videoSources===n.videoSources),Bn={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}},Ln={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Dn=5,$n=15e3,In=`
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 Fn({videoRef:r,canvasRef:n,profile:l="balanced",delayMs:m=0}){const[i,o]=ae(!1),[s,c]=ae(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[u,f]=ae(!1),[k,e]=ae(null),[a,A]=ae(0),h=R(0),C=R(null),M=R(null),N=R(null),B=R(null),y=R(null),p=R(null),P=R(null),d=R(null),S=R(null),_=R(!1),z=R(-1),W=R(0),H=R(m);H.current=m;const j=R([]),D=R(!1),L=R(!1),K=R(!1),U=R(null),b=R(-1),g=R(-1),T=R(!1),E=R(0);F(()=>{async function V(){if(typeof navigator>"u"||!navigator.gpu){o(!1);return}try{const Q=await navigator.gpu.requestAdapter();o(!!Q)}catch{o(!1)}}V()},[]),F(()=>{if(!s||!i)return;let V=!1;const Q=++h.current,Z=G=>{if(G)try{G.close()}catch{}},Se=()=>{for(const G of j.current)Z(G.bitmap);j.current=[]},Ae=G=>Math.max(8,Math.min(40,Math.ceil(G/16.7)+4));function Re(){S.current!==null&&(cancelAnimationFrame(S.current),S.current=null)}async function ee(){let G=r.current;const ke=n.current;if(!G||!ke||h.current!==Q)return;const _e=performance.now()+$n;for(;(!G||G.videoWidth===0)&&performance.now()<_e;){if(await new Promise(le=>requestAnimationFrame(le)),V||h.current!==Q)return;G=r.current}if(!G||G.videoWidth===0){!V&&h.current===Q&&(e("Timed out waiting for video metadata"),f(!1),c(!1));return}const te=G.videoWidth,q=G.videoHeight,he=Math.max(te,q),ft=window.innerWidth,xe=window.innerHeight,Je=Math.max(ft,xe),Ze=he<Je?Je/he:1,Qe=Bn[l],pt=he<=480?Qe.sd:he<=720?Qe.hd:he<=1080?Qe.fhd:1,ie=Math.min(pt,Ze);ke.width=Math.round(te*ie),ke.height=Math.round(q*ie),f(!0),e(null),W.current=0,z.current=-1,b.current=-1,g.current=-1,T.current=!1,E.current=0,Se(),_.current=!1;try{let le=function(){V||h.current!==Q||(Re(),S.current=requestAnimationFrame(()=>{at()}))};const{ModeA:ht,ModeB:Te,ModeC:et,ModeAA:Ke}=await Pt(async()=>{const{ModeA:I,ModeB:re,ModeC:fe,ModeAA:ce}=await import("./index-BOKlZEHq.js").then(ue=>ue.i);return{ModeA:I,ModeB:re,ModeC:fe,ModeAA:ce}},[]);if(V||h.current!==Q)return;if(!navigator.gpu)throw new Error("WebGPU not available");const tt=await navigator.gpu.requestAdapter();if(V||h.current!==Q)return;if(!tt)throw new Error("No GPU adapter found");const $=await tt.requestDevice();if(!$)throw new Error("Failed to get GPU device");if(V||h.current!==Q){$.destroy();return}C.current=$;const Ne=ke.getContext("webgpu");if(!Ne)throw new Error("Failed to get WebGPU context");M.current=Ne;const Ge=navigator.gpu.getPreferredCanvasFormat();Ne.configure({device:$,format:Ge,alphaMode:"premultiplied"});const ve=$.createTexture({size:[te,q],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),rt=Ln[l],Fe=Math.round(te*ie),Oe=Math.round(q*ie),qe=(()=>{switch(rt){case"ModeB":return new Te({device:$,inputTexture:ve,nativeDimensions:{width:te,height:q},targetDimensions:{width:Fe,height:Oe}});case"ModeC":return new et({device:$,inputTexture:ve,nativeDimensions:{width:te,height:q},targetDimensions:{width:Fe,height:Oe}});case"ModeAA":return new Ke({device:$,inputTexture:ve,nativeDimensions:{width:te,height:q},targetDimensions:{width:Fe,height:Oe}});default:return new ht({device:$,inputTexture:ve,nativeDimensions:{width:te,height:q},targetDimensions:{width:Fe,height:Oe}})}})(),Be=qe.getOutputTexture(),ze=$.createSampler({magFilter:"linear",minFilter:"linear"}),nt=$.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
- `}),Le=$.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),De=$.createRenderPipeline({layout:$.createPipelineLayout({bindGroupLayouts:[Le]}),vertex:{module:nt,entryPoint:"vs"},fragment:{module:nt,entryPoint:"fs",targets:[{format:Ge}]},primitive:{topology:"triangle-list"}}),st=$.createBindGroup({layout:Le,entries:[{binding:0,resource:Be.createView()},{binding:1,resource:ze}]});try{const I=$.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),re=$.createShaderModule({code:In}),fe=$.createRenderPipeline({layout:$.createPipelineLayout({bindGroupLayouts:[I]}),vertex:{module:re,entryPoint:"vs"},fragment:{module:re,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});U.current={pipeline:fe,layout:I,inputView:ve.createView()}}catch{U.current=null}N.current=qe,B.current=ve,y.current=Be,p.current=De,P.current=ze,d.current=Le,L.current=!1,K.current=!1;async function ot(){const I=U.current;if(!I||L.current)return!1;const re=r.current;if(!re)return!1;const fe=!K.current;fe&&$.pushErrorScope("validation");try{const ce=$.importExternalTexture({source:re}),ue=$.createBindGroup({layout:I.layout,entries:[{binding:0,resource:ce},{binding:1,resource:ze}]}),pe=$.createCommandEncoder(),ge=pe.beginRenderPass({colorAttachments:[{view:I.inputView,loadOp:"load",storeOp:"store"}]});ge.setPipeline(I.pipeline),ge.setBindGroup(0,ue),ge.draw(6),ge.end(),$.queue.submit([pe.finish()])}catch{return L.current=!0,U.current=null,!1}if(fe){const ce=await $.popErrorScope().catch(()=>null);if(ce)return console.warn("[anime4k] blit probe failed:",ce.message),L.current=!0,U.current=null,!1;K.current=!0}return!0}f(!1);async function at(){if(V||h.current!==Q||!Ne)return;const I=r.current;if(!I||I.videoWidth===0){le();return}if(I!==G||I.videoWidth!==te||I.videoHeight!==q){A(ue=>ue+1);return}if(I.paused||I.ended||document.hidden||I.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){le();return}const re=I.getVideoPlaybackQuality().totalVideoFrames;if(re===g.current){le();return}if(_.current){le();return}const fe=I.currentTime;(I.seeking||b.current>=0&&Math.abs(fe-b.current)>.5)&&(Se(),T.current=!1,E.current=0,g.current=-1),b.current=fe;const ce=Math.max(0,H.current||0);ce>E.current&&(T.current=!1),_.current=!0;try{const ue=performance.now();let pe=null,ge=!1;if(ce<=0){j.current.length>0&&Se(),T.current=!1,E.current=0;let ye=!1;if(!D.current)try{$.queue.copyExternalImageToTexture({source:I},{texture:ve},[te,q]),g.current=re,ye=!0}catch(ne){if(ne instanceof TypeError)D.current=!0;else throw ne}if(!ye&&!L.current&&U.current&&await ot()&&(g.current=re,ye=!0),!ye){const ne=await createImageBitmap(I);g.current=re,$.queue.copyExternalImageToTexture({source:ne},{texture:ve},[te,q]),Z(ne)}}else{const ye=await createImageBitmap(I);g.current=re;const ne=j.current;ne.push({bitmap:ye,capture:ue});const it=Ae(ce);for(;ne.length>it;)Z(ne.shift()?.bitmap);let Ue=-1;for(let se=ne.length-1;se>=0;se--)if(ue-ne[se].capture>=ce){Ue=se;break}if(Ue!==-1){for(let He=0;He<Ue;He++)Z(ne.shift()?.bitmap);const se=ne.shift();se?(pe=se.bitmap,T.current=!0,E.current=ce):(pe=ye,ge=!0)}else if(!T.current)pe=ye,ge=!0;else{const se=ne.shift();pe=se?se.bitmap:ye,se||(ge=!0)}if(!pe){_.current=!1,le();return}$.queue.copyExternalImageToTexture({source:pe},{texture:ve},[te,q]),ge||Z(pe)}const je=$.createCommandEncoder();await qe.pass(je);const We=je.beginRenderPass({colorAttachments:[{view:Ne.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});We.setPipeline(De),We.setBindGroup(0,st),We.draw(6),We.end(),$.queue.submit([je.finish()]),z.current=re,W.current=0,$.queue.onSubmittedWorkDone().then(()=>{h.current===Q&&(_.current=!1)})}catch(ue){if(_.current=!1,W.current+=1,W.current>=Dn&&!V&&h.current===Q){console.error(ue),e(ue instanceof Error?ue.message:"Render error"),c(!1);return}}le()}le()}catch(le){!V&&h.current===Q&&(M.current?.unconfigure(),C.current?.destroy(),C.current=null,M.current=null,e(le instanceof Error?le.message:"Failed to initialize upscaler"),f(!1),c(!1))}}return ee(),()=>{V=!0,h.current+=1,Re(),Se(),M.current?.unconfigure(),B.current&&(B.current.destroy(),B.current=null),y.current&&(y.current.destroy(),y.current=null),C.current&&(C.current.destroy(),C.current=null),N.current=null,p.current=null,P.current=null,d.current=null,U.current=null,M.current=null,_.current=!1}},[s,i,r,n,l,a]);const Y=O(V=>{c(V);try{localStorage.setItem("anime4kEnabled",String(V))}catch{}},[]),X=O(()=>{c(V=>{const Q=!V;try{localStorage.setItem("anime4kEnabled",String(Q))}catch{}return Q})},[]);return{isWebGPUSupported:i,isEnabled:s,isInitializing:u,error:k,toggle:X,setEnabled:Y}}function On({videoRef:r,episodeKey:n,isEnabled:l,isSupported:m,mediaReady:i,isIframeSource:o,setEnabled:s}){const c=R(null),u=R(!1),f=R(!1),k=R(s);k.current=s,F(()=>{const e=c.current;c.current=n,!(e===null||e===n)&&(!l||!m||(u.current=!0,f.current=!1,k.current(!1)))},[n,l,m]),F(()=>{if(!u.current)return;if(l){f.current&&(u.current=!1);return}if(f.current=!0,!i)return;if(o){u.current=!1,k.current(!0);return}const e=r.current;if(!e)return;let a,A=!1;const h=()=>{A||(A=!0,u.current=!1,k.current(!0))};if(e.readyState>=2)return a=window.setTimeout(h,500),()=>window.clearTimeout(a);const C=()=>{window.setTimeout(h,500)};return e.addEventListener("canplay",C,{once:!0}),e.addEventListener("playing",C,{once:!0}),a=window.setTimeout(h,5e3),()=>{window.clearTimeout(a),e.removeEventListener("canplay",C),e.removeEventListener("playing",C)}},[l,i,o,r])}const Wn=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Un=/^[a-z0-9-]+$/i,_t=r=>r?"preferredProviderMature":"preferredProvider",xt=r=>{const n=localStorage.getItem(_t(r));return n&&Un.test(n)?n:null},Bt=(r,n)=>{localStorage.setItem(_t(n),r)},Vn=()=>xt(!1)??"megaplay",Qn=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:Wn(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:Wr(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Vn(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Kn(r,n){switch(n.type){case"SET_STATE":return{...r,...n.payload};case"SET_MODE":return{...r,currentMode:n.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...r,selectedProvider:n.payload};default:return r}}async function Mt(r,n,l,m,i=!1){if(!r||!n)throw new Error("Missing params");try{const[o,s,c,u]=await Promise.all([de.data.video.query({showId:r,episodeNumber:n,mode:l.currentMode,provider:l.selectedProvider}).catch(y=>{const p=y.data?.cause;return y.message==="AUTH_REQUIRED"&&p?.provider==="mkissa"&&m({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:"mkissa"}}),null}),de.progress.getEpisode.query({showId:r,episodeNumber:n}).catch(()=>null),de.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),de.data.skipTimes.query({showId:r,episodeNumber:n}).catch(()=>[])]),f=c?.value,k=o?.filter(y=>{const p=y.sourceName.toLowerCase();return l.currentMode==="dub"?p.includes("eng")||p.includes("dub"):p.includes("jpn")||p.includes("sub")||!p.includes("eng")&&!p.includes("dub")})??[],e=k.length>0?k:o??[];let a=e.length>0?e[0]:null;if(f){const y=e.find(p=>p.sourceName===f);y&&(a=y)}const A=a&&a.links.length>0?a.links.sort((y,p)=>(parseInt(p.resolutionStr)||0)-(parseInt(y.resolutionStr)||0))[0]:null,h=s?.currentTime||0,C=s?.duration||0,M=h,B=(Array.isArray(u)?u:u?.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(!o||o.length===0)&&(i||we.error(`No video sources found for ${l.selectedProvider}`)),{videoSources:o,selectedSource:a,selectedLink:A,resumeTime:M,resumeDuration:C,showResumeModal:M>5&&a?.type!=="iframe",skipIntervals:B,fetchedEpisodeNumber:n}}catch(o){const s=o;if(s.message==="AUTH_REQUIRED")return m({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:s.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:n};throw o}}const Gn=(r,n,l,m)=>{const[i,o]=Ht(Kn,l,b=>({...Qn(),showMeta:b?.name?{name:b.name,thumbnail:b.thumbnail,nativeName:b.nativeName,englishName:b.englishName,names:{romaji:b.name||b.englishName,english:b.englishName||b.name,native:b.nativeName}}:{}})),s=Rt(),c=Pr(),u=R(null),f=R(null),{options:k}=At(),e=Me(()=>k.filter(b=>(b.kind??"anime")==="anime"),[k]),a=n||i.initialEpisode,A=R(a);F(()=>{A.current!==a&&(A.current=a,o({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[a,o]),F(()=>{r&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)&&i.selectedProvider!=="animepahe"&&u.current!==r&&(u.current=r,o({type:"SET_PROVIDER",payload:"animepahe"}))},[r,i.selectedProvider]);const{data:h,isLoading:C,error:M}=qr(r),{data:N}=Tt({queryKey:[oe.playerData,r,i.currentMode,i.selectedProvider],queryFn:async()=>{if(!r)throw new Error("No showId");const b=async()=>{try{const X=await de.data.episodes.query({showId:r,mode:i.currentMode,provider:i.selectedProvider}).catch(()=>null);if(X?.episodes?.length)return X}catch{}return null},[g,T,E]=await Promise.all([b(),de.watchlist.check.query({showId:r}).catch(()=>({inWatchlist:!1,status:null})),de.progress.getWatchedEpisodes.query({showId:r}).catch(()=>[])]),Y=g?.episodes?g.episodes.sort((X,V)=>parseFloat(X)-parseFloat(V)):[];return{description:g?.description||"",episodes:Y,inWatchlist:T.inWatchlist,watchlistStatus:T.status??null,watchedEpisodes:E}},enabled:!!r});F(()=>{!n&&N?.episodes&&N.episodes.length>0&&!n&&o({type:"SET_STATE",payload:{initialEpisode:N.episodes[0]}})},[N,n]),F(()=>{if(h?.isAdult===void 0||f.current===r)return;const b=h.isAdult===!0,g=e.filter(E=>E.mature===b);if(g.length===0||e.find(E=>E.id===i.selectedProvider)?.mature===b)return;const T=xt(b);f.current=r??null,o({type:"SET_PROVIDER",payload:g.find(E=>E.id===T)?.id??g[0].id})},[h?.isAdult,i.selectedProvider,r,e]),F(()=>{if(!r||!/^dango-mt-\d+$/.test(r)||f.current===`temp:${r}`)return;const b=h?.provider;b&&(f.current=`temp:${r}`,b!==i.selectedProvider&&o({type:"SET_PROVIDER",payload:b}))},[r,h,i.selectedProvider]);const{data:B,isLoading:y,error:p}=Tt({queryKey:[oe.videoSources,r,a,i.selectedProvider,i.currentMode],queryFn:()=>Mt(r,a,i,o),enabled:!!r&&!!a&&!(i.showMeta?.isAdult===!0&&!m?.hasMatureConsent)}),{mutateAsync:P}=yt({mutationFn:async({wasIn:b,showMeta:g})=>{if(!r)throw new Error("Missing showId");if(b)await de.watchlist.remove.mutate({id:r});else{const T=g.name||g.names?.romaji;if(!T)throw new Error("Missing show name");await de.watchlist.add.mutate({id:r,name:T,thumbnail:g.thumbnail,nativeName:g.names?.native,englishName:g.names?.english,type:g.type,isAdult:g.isAdult})}return!b},onSuccess:b=>{we.success(b?"Added to watchlist":"Removed from watchlist"),s.invalidateQueries({queryKey:[oe.playerData,r]}),s.invalidateQueries({queryKey:[oe.showData,r]}),s.invalidateQueries({queryKey:[oe.watchlist]})},onError:b=>we.error(b instanceof Error?b.message:"Failed to update watchlist")}),d=O(async()=>{!r||!h||await P({wasIn:!!N?.inWatchlist,showMeta:h})},[r,h,N?.inWatchlist,P]),S=O(async b=>{try{await de.settings.set.mutate({key:"preferredSource",value:b})}catch(g){console.error(g)}},[]),{mutateAsync:_,isPending:z}=yt({mutationFn:async({status:b})=>{if(!r)throw new Error("Missing showId");if(N?.inWatchlist)return await de.watchlist.setStatus.mutate({id:r,status:b}),b;const g=h,T=g?.name||g?.names?.romaji;if(!g||!T)throw new Error("Missing show name");return await de.watchlist.add.mutate({id:r,name:T,thumbnail:g.thumbnail,nativeName:g.names?.native,englishName:g.names?.english,type:g.type,isAdult:g.isAdult,status:b}),b},onSuccess:b=>{o({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:b}}),we.success(`Moved to ${b}`),s.invalidateQueries({queryKey:[oe.showData,r]}),s.invalidateQueries({queryKey:[oe.watchlist]}),s.invalidateQueries({queryKey:[oe.continueWatching]})},onError:()=>we.error("Failed to update watchlist status")}),W=O(async()=>{await _({status:"Completed"})},[_]),{mutateAsync:H,isPending:j}=yt({mutationFn:async({episodeNumber:b,duration:g,showMeta:T,episodes:E})=>{await de.progress.updateProgress.mutate({showId:r??"",episodeNumber:b,currentTime:g,duration:g,showName:T.name,showThumbnail:T.thumbnail,nativeName:T.names?.native,englishName:T.names?.english,genres:T.genres?.map(Y=>Y.name),popularityScore:Ar(T.score)??void 0,type:T.type,status:T.status,episodeCount:E.length,isAdult:T.isAdult})},onSuccess:(b,g)=>{we.success(`Episode ${g.episodeNumber} marked as watched`),s.invalidateQueries({queryKey:[oe.playerData,r]}),s.invalidateQueries({queryKey:[oe.showMeta,r]}),s.invalidateQueries({queryKey:[oe.videoSources,r,g.episodeNumber]}),s.invalidateQueries({queryKey:[oe.continueWatching]}),s.invalidateQueries({queryKey:[oe.thisWeekSchedule]}),s.invalidateQueries(c.continueWatching.pathFilter())},onError:()=>we.error("Failed to mark episode as watched")}),D=O(async(b,g)=>{!r||!h||await H({episodeNumber:b,duration:g,showMeta:h,episodes:N?.episodes||[]})},[r,h,N?.episodes,H]),L=O(async()=>{o({type:"SET_STATE",payload:{showCombinedDetails:!i.showCombinedDetails}})},[i.showCombinedDetails]),K=Me(()=>{const b=M||p,g=b?b.message:null,T=g==="AUTH_REQUIRED"?null:g,E=B&&B.fetchedEpisodeNumber===a?B:null,Y=!!B&&!E;return{...i,currentEpisode:a,showMeta:{...i.showMeta||{},...h||{}},episodes:N?.episodes||[],watchedEpisodes:N?.watchedEpisodes||[],inWatchlist:!!N?.inWatchlist,watchlistStatus:N?.watchlistStatus??i.watchlistStatus??null,videoSources:E?.videoSources||[],selectedSource:i.selectedSource||E?.selectedSource||null,selectedLink:i.selectedLink||E?.selectedLink||null,resumeTime:E?.resumeTime||0,resumeDuration:E?.resumeDuration||0,showResumeModal:i.showResumeModal&&(E?.showResumeModal??!1),skipIntervals:E?.skipIntervals||[],loadingShowData:C,loadingVideo:y||Y,error:T,fetchedEpisodeNumber:E?.fetchedEpisodeNumber}},[i,h,N,B,C,y,M,p,a]),U=O((b,g)=>{const T=g||r;if(!T||!b||T===r&&b===a)return;const Y=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(T)&&i.selectedProvider!=="animepahe"?"animepahe":i.selectedProvider,X=["video-sources",T,b,Y,i.currentMode];s.getQueryState(X)?.status!=="success"&&s.prefetchQuery({queryKey:X,queryFn:()=>Mt(T,b,{selectedProvider:Y,currentMode:i.currentMode},o,!0),staleTime:300*1e3,gcTime:1800*1e3})},[r,a,s,i,o]);return{state:K,dispatch:o,toggleWatchlist:d,moveToCompleted:W,setPreferredSource:S,handleToggleDetails:L,markEpisodeWatched:D,prefetchEpisodeSources:U,isMarkingWatched:j,isUpdatingWatchlistStatus:z}};function qn({onNext:r,onToggleTheater:n,flashControls:l}){F(()=>{const m=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())&&l(),i.key.toLowerCase()==="n"&&r(),i.key.toLowerCase()==="t"&&n())};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m)}},[l,r,n])}const Xe=(r,n,l)=>r.showId===n||!!l&&r.showId===l;function zn({testClipActive:r,selectedSourceType:n,onEnded:l,queue:m,removeFromQueue:i,showId:o,showMetaId:s,currentEpisode:c,isAutoplayEnabled:u,nextEpisode:f,previousEpisode:k,navigate:e,invalidateContinueWatching:a,dispatch:A}){const[h,C]=ae(!1),[M,N]=ae(null),[B,y]=ae(null),p=R(i);p.current=i;const P=R(!1);F(()=>{P.current=!1,C(!1)},[o,c]);const d=O(()=>{if(r||P.current)return;P.current=!0,l();const D=m.find(L=>Xe(L,o,s)&&L.episodeNumber===c);if(m.length>0){const L=m.findIndex(U=>Xe(U,o,s)&&U.episodeNumber===c),K=L>=0?m[L+1]||null:m[0];y({nextItem:K,playedItem:D||null}),N(2);return}if(D&&p.current({showId:D.showId,episodeNumber:D.episodeNumber}),u&&f){a(),e(`/watch/${o}/${f}`);return}f||C(!0)},[l,e,m,o,s,c,f,u,a,r]),S=O(()=>{if(m.length===0)return;l();const D=m.find(U=>Xe(U,o,s)&&U.episodeNumber===c),L=m.findIndex(U=>Xe(U,o,s)&&U.episodeNumber===c),K=L>=0?m[L+1]||null:m[0];D&&i({showId:D.showId,episodeNumber:D.episodeNumber}),K?e(`/watch/${K.showId}/${K.episodeNumber}`):f||C(!0)},[l,e,m,i,o,s,c,f]),_=O(()=>{f&&(a(),e(`/watch/${o}/${f}`)),C(!1),A({type:"SET_STATE",payload:{showResumeModal:!1}})},[f,e,o,A,a]),z=O(()=>{m.length>0?S():f?_():we.error("No next episode available")},[m.length,S,_,f]),W=O(()=>C(!1),[]),H=O(()=>{y(null),N(null)},[]),j=O(()=>{k&&e(`/watch/${o}/${k}`)},[k,e,o]);return F(()=>{const D=L=>{L.origin===window.location.origin&&n==="iframe"&&L.data?.type==="ANI_WEB_MEDIA_ENDED"&&d()};return window.addEventListener("message",D),()=>window.removeEventListener("message",D)},[d,n]),F(()=>{if(!B||M===null)return;if(M<=0){const{nextItem:L,playedItem:K}=B;y(null),N(null),K&&p.current({showId:K.showId,episodeNumber:K.episodeNumber}),L?e(`/watch/${L.showId}/${L.episodeNumber}`):f||C(!0);return}const D=window.setTimeout(()=>{N(L=>L===null?null:L-1)},1e3);return()=>window.clearTimeout(D)},[B,M,e,f]),{showCompleteModal:h,queueCountdown:M,pendingQueueTransition:B,handleQueueTransition:S,handleNextEpisode:_,handleNShortcut:z,handlePreviousEpisode:j,handlePlaybackFinished:d,closeCompleteModal:W,cancelQueueTransition:H}}function jn({videoRef:r,queue:n,showId:l,showMetaId:m,currentEpisode:i,selectedSource:o,hasNextEpisode:s,nextEpisode:c,prefetchEpisodeSources:u,matchesQueueItem:f}){const[k,e]=ae(!1),a=R(u);a.current=u;const A=R("");F(()=>{e(!1)},[i]);const h=O(()=>{const C=r.current;if(!C||o?.type==="iframe")return;const M=C.duration,N=C.currentTime;if(!M||Number.isNaN(M)){e(!1);return}if(M-N<=60){const B=n.findIndex(P=>f(P,l,m)&&P.episodeNumber===i),y=n.length>0?B>=0?n[B+1]||null:n[0]:null,p=y?`${y.showId}:${y.episodeNumber}`:s?`${l}:${c}`:"";p&&A.current!==p&&(A.current=p,y?a.current(y.episodeNumber,y.showId):a.current(c??""))}e(s&&Ur(N,M))},[r,o,n,l,m,i,s,c,f]);return{showNextEpisodePrompt:k,handleThresholds:h}}const bt="fallbackChoice";function Hn(){try{const r=localStorage.getItem(bt);return r==="iframe"||r==="retry"?r:null}catch{return null}}function Yn(r){try{r===null?localStorage.removeItem(bt):localStorage.setItem(bt,r)}catch{}}function Xn({showId:r,episodeNumber:n,currentMode:l,selectedProvider:m,selectedSourceType:i,videoSources:o,isAdult:s,providerOrder:c,matureProviders:u,setPreferredSource:f,dispatch:k,showControls:e}){const a=R(!1),A=R([]),h=R(!1),[C,M]=ae(null),[N,B]=ae(!1),[y,p]=ae(!1),[P,d]=ae(()=>Hn()??"ask"),S=O(g=>{d(g),Yn(g==="ask"?null:g)},[]),_=R(P);F(()=>{_.current=P},[P]);const z=R(o);z.current=o;const W=O(()=>{a.current=!1,A.current=[],h.current=!1,M(null),B(!1)},[]);F(()=>{W()},[W,r,n]);const H=O(g=>{if(a.current)return;a.current=!0;const T=g.links[0];f(g.sourceName),k({type:"SET_STATE",payload:{selectedSource:g,selectedLink:T}}),M(null)},[k,f]),j=O(()=>{const T=z.current.find(E=>E.type==="iframe");return T?.links?.length?T:null},[]),D=O(async()=>{const g=c.filter(T=>{if(A.current.includes(T))return!1;const E=u.has(T);return s===void 0?!0:E===s});B(!0);try{for(const T of g){A.current.push(T);let E=null;try{E=await de.data.video.query({showId:r,episodeNumber:n,mode:l,provider:T})}catch{continue}const Y=(E??[]).filter(Q=>{const Z=Q.sourceName.toLowerCase();return l==="dub"?Z.includes("eng")||Z.includes("dub"):Z.includes("jpn")||Z.includes("sub")||!Z.includes("eng")&&!Z.includes("dub")});if((Y.length>0?Y:E??[]).find(Q=>Q.type!=="iframe"&&Q.links?.length)){A.current=[m],h.current=!1,k({type:"SET_STATE",payload:{selectedProvider:T,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Bt(T,s===!0),M(null),we.success(`Switched to ${T} (direct stream)`);return}}M({retryFailed:!0}),we.error("No working direct stream found on other providers")}finally{B(!1)}},[r,n,l,s,m,k,c,u]),L=O(()=>{if(a.current||h.current||i!=="player")return;const g=j();if(!g)return;A.current.includes(m)||A.current.push(m);const T=_.current;if(T==="iframe"){H(g);return}if(T==="retry"){D();return}e(!0),M({retryFailed:!1})},[i,m,j,H,D,e]),K=O(()=>{h.current=!0,M(null),p(!1)},[]),U=O(()=>{y&&S("iframe");const g=j();g?H(g):M(null)},[y,S,j,H]),b=O(()=>{y&&S("retry"),D()},[y,S,D]);return{fallbackPrompt:C,isRetryingProvider:N,rememberFallbackChoice:y,setRememberFallbackChoice:p,fallbackChoice:P,updateFallbackChoice:S,dismissFallbackPrompt:K,chooseIframeFallback:U,chooseProviderRetry:b,handleVideoSourceError:L,resetFallback:W}}function Jn({engine:r,videoRef:n,selectedSource:l,selectedLink:m,loadingVideo:i,testClipActive:o,resumeTime:s,showResumeModal:c,calibReturnRef:u,setAvailableSubtitles:f,setActiveSubtitleTrack:k,onFatalError:e}){const a=R(null),A=R(s),h=R(c),C=R(e);return C.current=e,F(()=>{A.current=s,h.current=c},[s,c]),F(()=>{const M=n.current;if(!M)return;for(;M.firstChild;)M.removeChild(M.firstChild);if(o)return r.loadSource({url:"/av-sync-test.mp4"},{autoPlay:!0});if(i||!l||!m||l.type==="iframe"){r.unload();return}u.current!=null?(a.current=u.current,u.current=null):a.current===null&&A.current>5&&!h.current?a.current=A.current:a.current===null&&h.current&&(a.current=0);let N=m.link;if(N.startsWith("/api/proxy")||(N=`/api/proxy?url=${encodeURIComponent(N)}`,m.headers?.Referer&&(N+=`&referer=${encodeURIComponent(m.headers.Referer)}`)),l.subtitles){const p=localStorage.getItem("playerSubtitlesEnabled")!=="false";let P=null;try{P=localStorage.getItem("playerLastSubtitle")}catch{}const d=St(l.subtitles,{lastKey:P,enabled:p}),S=d>=0?l.subtitles[d]:null;l.subtitles.forEach(_=>{const z=document.createElement("track");z.kind="subtitles",z.label=_.label,z.srclang=_.lang;const W=_.src??_.url;if(W){let H=`/api/subtitle-proxy?url=${encodeURIComponent(W)}`;const j=m.headers?.Referer;j&&(H+=`&referer=${encodeURIComponent(j)}`),z.src=H}S&&_.label===S.label&&_.lang===S.lang&&(z.default=!0),M.appendChild(z)}),p||k("off"),f(l.subtitles)}const B=a.current??0;a.current=null;const y=document.body.classList.contains("low-end");return r.loadSource({url:N,hls:m.hls},{initialTime:B,autoPlay:!(h.current&&A.current>5),hlsConfig:{maxBufferLength:y?15:30,maxMaxBufferLength:y?30:60,maxBufferSize:(y?25:60)*1e3*1e3,startLevel:-1},onHls:(p,P)=>{if(!l.subtitles?.length)return;const d=()=>{p.subtitleTrack!==-1&&(p.subtitleTrack=-1)};p.on(P.Events.SUBTITLE_TRACK_SWITCH,d),d()},onError:()=>C.current()})},[r,l,m,n,u,i,o,k,f]),{seekToTimeRef:a}}function Zn({videoRef:r,availableSubtitles:n,activeSubtitleTrack:l,setAvailableSubtitles:m,setActiveSubtitleTrack:i}){F(()=>{const o=r.current;if(!o)return;const s=()=>{const c=Array.from(o.textTracks).map(u=>({label:u.label,lang:u.language,src:void 0,mode:u.mode}));m(c)};return o.textTracks.addEventListener("addtrack",s),o.textTracks.addEventListener("removetrack",s),s(),()=>{o.textTracks.removeEventListener("addtrack",s),o.textTracks.removeEventListener("removetrack",s)}},[r,m]),F(()=>{if(l===null&&n.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let o=null;try{o=localStorage.getItem("playerLastSubtitle")}catch{}const s=St(n,{lastKey:o,enabled:!0});if(s<0){i("off");return}const c=n[s];i(c.lang||c.label)}},[l,n,i]),F(()=>{const o=r.current;if(!o||n.length===0)return;const s=l;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(o.textTracks).forEach(f=>{f.mode="hidden"});return}let u=!1;if(Array.from(o.textTracks).forEach(f=>{const e=(f.language===s||f.label===s)&&!u;f.mode=e?"showing":"hidden",e&&(u=!0)}),!u&&o.textTracks.length>0){const f=Array.from(o.textTracks).find(k=>k.language==="en"||k.label==="English")||o.textTracks[0];f&&(f.mode="showing")}},[l,n,r])}function es({videoRef:r,videoBoxH:n,style:l,sourceKey:m,activeSubtitleTrack:i,availableSubtitles:o}){F(()=>{const s="dynamic-subtitle-styles";let c=document.getElementById(s);c||(c=document.createElement("style"),c.id=s,document.head.appendChild(c)),c.textContent=Ct(l);const u=r.current;if(!u)return;const f=Nt(l.fontSize,n||u.clientHeight||720);c.textContent=Ct({...l,fontSize:f});const k=()=>{const p=Number(l.position),P=isNaN(p)?0:Math.max(0,Math.min(100,p));return Math.max(0,Math.min(100,100-P))},e=(p,P)=>{try{const d=p;d.snapToLines=!1,d.line=P}catch{}},a=()=>{const p=f*16,P=u.videoHeight||u.clientHeight||720,d=u.videoWidth||u.clientWidth||1280;return{step:p*1.3/P*100,chars:Math.max(20,Math.floor(d/(p*.55)))}},A=p=>{const P=k(),d=Array.from(p.activeCues??[]);if(d.length<=1){d.forEach(W=>e(W,P));return}const{step:S,chars:_}=a();let z=P;for(let W=d.length-1;W>=0;W--){const j=String(d[W].text??"").replace(/<[^>]*>/g,"").split(`
55
- `).reduce((L,K)=>L+Math.max(1,Math.ceil(K.length/_)),0),D=z-j*S;e(d[W],Math.max(0,D)),z=D-S*.4}},h=p=>{if(!p.cues)return;const P=k();Array.from(p.cues).forEach(d=>e(d,P)),p.mode==="showing"&&A(p)},C=()=>{Array.from(u.textTracks).forEach(h)};C();const M=p=>{const P=p.target;P.mode==="showing"&&A(P)};Array.from(u.textTracks).forEach(p=>{p.addEventListener("cuechange",M)});const N=()=>{Array.from(u.textTracks).forEach(p=>{p.removeEventListener("cuechange",M),p.addEventListener("cuechange",M)}),C()};u.textTracks.addEventListener("addtrack",N),u.textTracks.addEventListener("removetrack",N);const B=Array.from(u.querySelectorAll("track")),y=()=>{C()};return B.forEach(p=>{p.addEventListener("load",y)}),()=>{Array.from(u.textTracks).forEach(p=>{p.removeEventListener("cuechange",M)}),u.textTracks.removeEventListener("addtrack",N),u.textTracks.removeEventListener("removetrack",N),B.forEach(p=>{p.removeEventListener("load",y)})}},[l,n,r,m,i,o])}function ts({videoRef:r,overlayRef:n,style:l,activeSubtitleTrack:m,delayMs:i,enabled:o}){F(()=>{if(!o)return;const s=r.current,c=n.current;if(!s||!c)return;const u=localStorage.getItem("playerSubtitlesEnabled")!=="false",f=()=>{if(c.innerHTML="",!u||m==="off"||m===null)return;const a=Array.from(s.textTracks).find(y=>y.language===m||y.label===m);if(!a||a.mode!=="showing")return;const A=i/1e3;let h;if(A>0&&a.cues){const y=s.currentTime-A;h=Array.from(a.cues).filter(p=>p.startTime<=y&&y<=p.endTime)}else h=Array.from(a.activeCues??[]);if(h.length===0)return;const C={...l,fontSize:Nt(l.fontSize,s.clientHeight||0)},M=ur(C),N=dr(s,C.position),B=Array.from(h);B.forEach((y,p)=>{const P=String(y.text??"");if(!mr(P).trim())return;const d=document.createElement("div"),S=(B.length-1-p)*1.7;d.style.cssText=`${M}
56
- bottom: calc(${N}px + ${S}em);`,d.innerHTML=fr(P),c.appendChild(d)})},k=()=>f(),e=()=>f();return Array.from(s.textTracks).forEach(a=>{a.addEventListener("cuechange",k)}),s.addEventListener("timeupdate",e),f(),()=>{Array.from(s.textTracks).forEach(a=>{a.removeEventListener("cuechange",k)}),s.removeEventListener("timeupdate",e),c.innerHTML=""}},[m,i,o,n,l,r])}const rs=({isOpen:r,onClose:n,onSuccess:l})=>{const m=()=>{l?.(),n()};return t(mt,{isOpen:r,onClose:n,title:"MKissa Browser Verification",children:t("div",{className:Ve.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:Ve.actions,children:t("a",{className:Ve.link,href:"https://mkissa.to/anime",target:"_blank",rel:"noreferrer",children:"Open MKissa anime"})}),t("div",{className:Ve.actions,children:[t("button",{className:Ve.secondaryButton,onClick:n,children:"Cancel"}),t("button",{className:Ve.button,onClick:m,children:"Refresh Dango"})]})]})})},bs=()=>{const{id:r,episodeNumber:n}=Yt(),l=Xt(),m=Rt(),i=Jt(),{hasConsent:o,grant:s}=_r(),{options:c}=At(),u=Me(()=>c.filter(v=>(v.kind??"anime")==="anime"),[c]),f=Me(()=>u.map(v=>v.id),[u]),k=Me(()=>new Set(u.filter(v=>v.mature).map(v=>v.id)),[u]),{state:e,dispatch:a,toggleWatchlist:A,moveToCompleted:h,setPreferredSource:C,handleToggleDetails:M,markEpisodeWatched:N,prefetchEpisodeSources:B,isMarkingWatched:y,isUpdatingWatchlistStatus:p}=Gn(r,n,i.state||null,{hasMatureConsent:o});F(()=>{if(r&&e.showMeta?.id&&e.showMeta.id!==r){const v=n?`/watch/${e.showMeta.id}/${n}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;l(v,{replace:!0})}},[r,e.showMeta?.id,n,l]);const P=Me(()=>{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]),d=pr({skipIntervals:e.skipIntervals,showId:r,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:P}),{refs:S,actions:_}=d,z=Kr(),W=R(null),H=R(null),j=R(null),[D,L]=ae(()=>{try{const v=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(v)?v:"balanced"}catch{return"balanced"}}),{videoDelayMs:K,videoDelayEnabled:U,setDelayEnabled:b,handleVideoDelayChange:g,isCalibrating:T,testClipActive:E,stopCalibration:Y,openAvSyncCalibrator:X,cancelAvSyncCalibrator:V,applyAvSyncCalibrator:Q,toggleTestClip:Z,calibReturnRef:Se,effectiveVideoDelayMs:Ae}=hr(S.videoRef,()=>_.setShowSettings(!1)),Re=R(null),ee=Fn({videoRef:S.videoRef,canvasRef:H,profile:D,delayMs:Ae}),G=ee.isEnabled&&ee.isWebGPUSupported;On({videoRef:S.videoRef,episodeKey:`${r??""}:${e.currentEpisode??""}`,isEnabled:ee.isEnabled,isSupported:ee.isWebGPUSupported,mediaReady:!e.loadingVideo&&!!e.selectedLink,isIframeSource:e.selectedSource?.type==="iframe",setEnabled:ee.setEnabled}),vr({videoRef:S.videoRef,canvasRef:Re,delayMs:Ae,enabled:U&&!G});const ke=U&&!G,_e=G||ke,[te,q]=ae(!1),he=R(n);F(()=>{he.current!==n&&(he.current=n,Y())},[n,Y]);const ft=O(()=>{m.invalidateQueries({queryKey:[oe.continueWatching]})},[m]),{data:xe=[],isLoading:Je}=xr(),Ze=Br(),Qe=Lr(),pt=Dr(),{isTheaterMode:ie,toggleTheaterMode:le,handleLayoutClick:ht}=gr();Zt(()=>{if(d.state.isFullscreen||ie)return;const v=S.playerContainerRef.current,J=W.current;if(!v||!J)return;const $e=()=>{const gt=v.getBoundingClientRect().height;J.style.height=`${gt}px`};$e();const lt=new ResizeObserver($e);return lt.observe(v),()=>lt.disconnect()},[d.state.isFullscreen,ie,S.playerContainerRef]);const Te=Me(()=>e.episodes.findIndex(v=>v===e.currentEpisode),[e.episodes,e.currentEpisode]),et=Te>0?e.episodes[Te-1]:null,Ke=Te>=0&&Te<e.episodes.length-1?e.episodes[Te+1]:null,tt=Te>-1&&Te<e.episodes.length-1,{showCompleteModal:$,queueCountdown:Ne,pendingQueueTransition:Ge,handleQueueTransition:ve,handleNextEpisode:rt,handleNShortcut:Fe,handlePreviousEpisode:Oe,handlePlaybackFinished:qe,closeCompleteModal:Be,cancelQueueTransition:ze}=zn({testClipActive:E,selectedSourceType:e.selectedSource?.type,onEnded:_.onEnded,queue:xe,removeFromQueue:Ze.mutate,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,isAutoplayEnabled:e.isAutoplayEnabled,nextEpisode:Ke,previousEpisode:et,navigate:l,invalidateContinueWatching:ft,dispatch:a}),{showNextEpisodePrompt:nt,handleThresholds:Le}=jn({videoRef:S.videoRef,queue:xe,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,selectedSource:e.selectedSource,hasNextEpisode:tt,nextEpisode:Ke,prefetchEpisodeSources:B,matchesQueueItem:Xe}),{checkEnd:De,logDuration:st}=yr({videoRef:S.videoRef,sourceType:e.selectedSource?.type,resetKey:`${r}:${e.currentEpisode}`,onEnd:qe}),ot=e.showResumeModal,at=$,I=ot||at;br(d,!!e.selectedLink&&!ie&&!I);const{fallbackPrompt:re,isRetryingProvider:fe,rememberFallbackChoice:ce,setRememberFallbackChoice:ue,fallbackChoice:pe,updateFallbackChoice:ge,dismissFallbackPrompt:je,chooseIframeFallback:We,chooseProviderRetry:ye,handleVideoSourceError:ne,resetFallback:it}=Xn({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:f,matureProviders:k,setPreferredSource:C,showControls:_.setShowControls,dispatch:a}),{seekToTimeRef:Ue}=Jn({engine:d.engine,videoRef:S.videoRef,selectedSource:e.selectedSource,selectedLink:e.selectedLink,loadingVideo:e.loadingVideo,testClipActive:E,resumeTime:e.resumeTime,showResumeModal:e.showResumeModal,calibReturnRef:Se,setAvailableSubtitles:_.setAvailableSubtitles,setActiveSubtitleTrack:_.setActiveSubtitleTrack,onFatalError:ne});F(()=>{I&&d.state.isFullscreen&&d.actions.toggleFullscreen()},[I,d.state.isFullscreen,d.actions]),F(()=>{I&&S.videoRef.current&&S.videoRef.current.pause()},[I,S.videoRef]);const{titlePreference:se}=$r(),{lowEndMode:He}=Ir(),{settings:vt,update:Lt}=Sr(),Dt=ie&&vt.enabled&&!He&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,Pe=Me(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:v,names:J}=e.showMeta;return se==="name"?v||"Loading...":se==="nativeName"?J?.native||v||"Loading...":se==="englishName"?J?.english||v||"Loading...":v||"Loading..."},[e.showMeta,se,e.loadingShowData]);F(()=>{Pe&&Pe!=="Loading..."&&e.currentEpisode&&(document.title=`► ${Pe} Episode ${e.currentEpisode} - dango`)},[Pe,e.currentEpisode]),qn({onNext:Fe,onToggleTheater:le,flashControls:d.actions.flashControls});const{setAvailableSubtitles:$t,setActiveSubtitleTrack:It}=_,Et=Me(()=>({fontSize:d.state.subtitleFontSize,position:d.state.subtitlePosition,bgOpacity:d.state.subtitleBgOpacity,bgColor:d.state.subtitleBgColor,textColor:d.state.subtitleTextColor,edge:d.state.subtitleEdge,bold:d.state.subtitleBold}),[d.state.subtitleFontSize,d.state.subtitlePosition,d.state.subtitleBgOpacity,d.state.subtitleBgColor,d.state.subtitleTextColor,d.state.subtitleEdge,d.state.subtitleBold]);Zn({videoRef:S.videoRef,availableSubtitles:d.state.availableSubtitles,activeSubtitleTrack:d.state.activeSubtitleTrack,setAvailableSubtitles:$t,setActiveSubtitleTrack:It});const[Ft,Ot]=ae(0);F(()=>{const v=S.videoRef.current;if(!v)return;const J=()=>Ot(v.clientHeight||0);J();const $e=new ResizeObserver(J);return $e.observe(v),()=>$e.disconnect()},[S.videoRef,e.selectedSource,e.selectedLink]),es({videoRef:S.videoRef,videoBoxH:Ft,style:Et,sourceKey:`${e.selectedSource?.sourceName??""}:${e.selectedLink?.link??""}`,activeSubtitleTrack:d.state.activeSubtitleTrack,availableSubtitles:d.state.availableSubtitles}),ts({videoRef:S.videoRef,overlayRef:j,style:Et,activeSubtitleTrack:d.state.activeSubtitleTrack,delayMs:Ae,enabled:_e}),F(()=>{try{localStorage.setItem("anime4kProfile",D)}catch{}},[D]);const Wt=()=>{S.videoRef.current&&(S.videoRef.current.currentTime=e.resumeTime,S.videoRef.current.play()),a({type:"SET_STATE",payload:{showResumeModal:!1}})},Ut=()=>{S.videoRef.current&&(S.videoRef.current.currentTime=0,S.videoRef.current.play()),a({type:"SET_STATE",payload:{showResumeModal:!1}})},Vt=O(()=>{a({type:"SET_STATE",payload:{showResumeModal:!1}})},[a]),Qt=O(async()=>{try{await h(),Be(),a({type:"SET_STATE",payload:{showResumeModal:!1}}),l("/")}catch{}},[h,Be,a,l]),wt=(v,J)=>t("div",{className:v,children:[t("button",{className:`${w.episodeNavBtn} ${w.secondary}`,onClick:Oe,disabled:!et,type:"button",children:[t(me,{name:"chevron-left",size:12}),"Prev EP"]}),t("button",{className:`${w.episodeNavBtn} ${w.primary}`,onClick:rt,disabled:!Ke,type:"button",children:["Next EP",t(me,{name:"chevron-right",size:12})]}),J==="mobile"&&z&&t("button",{className:`${w.episodeNavBtn} ${w.episodePickerBtn}`,onClick:()=>q(!0),type:"button",children:[t(me,{name:"list-ul",size:12}),"Episodes"]})]}),Kt=v=>{a({type:"SET_STATE",payload:{isAutoplayEnabled:v}}),Vr(v)},kt=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),Gt=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",qt=O(async()=>{if(!r||!e.currentEpisode||!e.showMeta.name||y)return;const v=S.videoRef.current?.duration,J=Math.max(v||0,e.resumeDuration||0,Number(e.showMeta.episodeDuration||0)*60,1);await N(e.currentEpisode,J)},[r,e.currentEpisode,e.showMeta,e.resumeDuration,N,y,S.videoRef]);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 Ce=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!o?t("div",{className:be.playerPageLayout,children:t(Qr,{isOpen:!0,onClose:()=>l("/home"),onGrant:s})}):t("div",{className:`${be.playerPageLayout} ${ie?be.theaterMode:""}`,onClick:ht,children:[ie&&t(Er,{videoRef:S.videoRef,active:Dt,settings:vt}),t(wr,{isOpen:at,onClose:Be,title:"Show Completed!",heading:Pe,message:"Congratulations! You finished all available episodes.",children:[t(ut,{variant:"secondary",onClick:Be,children:"Close"}),t(ut,{onClick:Qt,disabled:p,children:p?"Saving...":"Move to Completed"})]}),t(kr,{isOpen:ot,onClose:Vt,title:"Resume Playback?",message:t(ct,{children:["You were watching at ",t("strong",{children:d.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:Wt,onRestart:Ut}),t(mt,{isOpen:!!re,onClose:je,title:"Direct stream failed",width:"sm",children:[t(mt.Body,{children:[t("p",{children:[t("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),re?.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:ce,onChange:v=>ue(v.currentTarget.checked)}),"Remember my choice"]})]}),t(mt.Actions,{children:[t(ut,{variant:"secondary",onClick:We,children:"Continue with iframe"}),t(ut,{onClick:ye,disabled:fe,children:fe?"Searching…":"Try another provider"})]})]}),t(Fr,{isOpen:!!e.showCookieModal&&e.cookieProvider!=="mkissa",onClose:()=>a({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{m.invalidateQueries({queryKey:[oe.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),t(rs,{isOpen:!!e.showCookieModal&&e.cookieProvider==="mkissa",onClose:()=>a({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{m.invalidateQueries({queryKey:[oe.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!ie&&t("aside",{ref:W,className:be.episodeSidebar,children:e.loadingShowData?t(Tr,{variant:"sidebar"}):t(Cr,{episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:v=>l(`/watch/${r}/${v}`)})}),t("div",{className:be.playerMain,children:[t("div",{className:`${w.videoContainer} ${d.state.isFullscreen?"":be.videoPlayerWrapper} ${d.state.isFullscreen?w.fullscreenActive:""}`,style:{...I?{visibility:"hidden"}:{}},onContextMenu:v=>v.preventDefault(),children:t(Cn,{player:d,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Kt,fallbackChoice:pe,onFallbackChoiceChange:ge,ambientSettings:vt,onAmbientChange:Lt,showNextEpisodeButton:!I&&nt&&xe.length===0,onNextEpisode:rt,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(v,J)=>{S.videoRef.current&&!isNaN(S.videoRef.current.currentTime)&&(Ue.current=S.videoRef.current.currentTime),C(v.sourceName),a({type:"SET_STATE",payload:{selectedSource:v,selectedLink:J,showResumeModal:e.showResumeModal&&v.type!=="iframe"}})},loadingVideo:Ce,skipIntervals:e.skipIntervals,animeTitle:Pe,episodeNumber:e.currentEpisode??void 0,isTheaterMode:ie,onTheaterModeToggle:le,anime4kEnabled:ee.isEnabled,onAnime4kToggle:ee.toggle,anime4kSupported:ee.isWebGPUSupported,anime4kProfile:D,onAnime4kProfileChange:L,anime4kInitializing:ee.isInitializing,anime4kError:ee.error,videoDelayEnabled:U,onVideoDelayToggle:b,videoDelayMs:K,onVideoDelayChange:g,onCalibrateAvSync:X,isInteractingExtra:te||T,className:sr.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:t(ct,{children:[d.state.isSpeedBoostActive&&t("div",{className:w.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(me,{name:"forward",size:12})]}),Ne!==null&&Ge?.nextItem&&t("div",{className:w.queueCountdown,children:["Queue next in ",Ne,"s"]})]}),children:[Ce&&t("div",{className:w.loadingOverlay,children:t("div",{className:w.loadingDots,children:[t("div",{className:w.dot}),t("div",{className:w.dot}),t("div",{className:w.dot})]})}),d.state.isBuffering&&!Ce&&e.selectedSource?.type!=="iframe"&&t("div",{className:w.bufferingOverlay,children:t("div",{className:w.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!Ce&&t("iframe",{src:e.selectedLink?.link,className:w.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(ct,{children:[!Ce&&e.videoSources.length===0&&t("div",{className:w.errorOverlay,children:[t("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),t("p",{className:w.errorSubtext,children:"Please try selecting a different provider below."}),t("button",{className:w.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Ce&&e.videoSources.length>0&&t(or,{controls:d.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:_.onPlay,onPause:_.onPause,onEnded:()=>{E||De(!0)},onDurationChange:()=>{st()},onSeeked:()=>{E||(Le(),De())},onLoadedMetadata:()=>{Le(),st(),E||De()},onTimeUpdate:()=>{E||(_.onTimeUpdate(),Le(),De(),Ge&&S.videoRef.current&&S.videoRef.current.currentTime<S.videoRef.current.duration-1&&ze())},onError:ne,onContextMenu:v=>v.preventDefault(),className:_e?w.videoElementHidden:""}),ee.isWebGPUSupported&&!Ce&&e.videoSources.length>0&&t("canvas",{ref:H,className:`${w.upscalerCanvas} ${G?w.upscalerActive:""}`}),!G&&!Ce&&e.videoSources.length>0&&t("canvas",{ref:Re,className:`${w.upscalerCanvas} ${ke?w.upscalerActive:""}`}),ee.isEnabled&&ee.isWebGPUSupported&&ee.isInitializing&&t("div",{className:w.upscalerStatusBadge,children:"Preparing upscaler…"}),_e&&t("div",{ref:j,className:w.subtitleOverlay}),t(Mr,{isOpen:T,ms:K,onChange:g,onApply:Q,onClose:V,testClipActive:E,onTestClip:Z})]})]})}),!ie&&t(Rr,{}),!ie&&t(ct,{children:[Je&&xe.length===0?t(Mn,{count:3}):t(Gr,{title:"Queue",items:xe,currentShowId:r,currentEpisode:e.currentEpisode??void 0,onNextQueue:ve,onRemove:v=>Ze.mutate({showId:v.showId,episodeNumber:v.episodeNumber}),onClear:()=>Qe.mutate(),showClearAll:!0,onReorder:v=>pt.mutate(v.map(J=>({id:J.id,showId:J.showId,episodeNumber:J.episodeNumber})))}),t("div",{className:w.streamPanel,children:[t(An,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:u,onProviderChange:v=>{it(),a({type:"SET_STATE",payload:{selectedProvider:v,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Bt(v,e.showMeta?.isAdult===!0)}}),wt(`${w.episodeActions} ${w.desktopEpisodeActions}`,"desktop"),Ce?t("div",{className:w.sourceLoader,children:t("div",{className:w.spinner})}):t(xn,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:v=>{S.videoRef.current&&!isNaN(S.videoRef.current.currentTime)&&(Ue.current=S.videoRef.current.currentTime);const $e=(v.links||[]).sort((lt,gt)=>(parseInt(gt.resolutionStr)||0)-(parseInt(lt.resolutionStr)||0))[0]||null;C(v.sourceName),a({type:"SET_STATE",payload:{selectedSource:v,selectedLink:$e,showResumeModal:e.showResumeModal&&v.type!=="iframe"}})},onLinkChange:v=>{e.selectedSource&&(C(e.selectedSource.sourceName),a({type:"SET_STATE",payload:{selectedLink:v}}))}})]}),t("div",{className:be.playerInfoContainer,children:[t("div",{className:be.playerInfoHeader,children:[t("div",{className:be.playerAnimeCard,children:t("img",{src:Or(e.showMeta.thumbnail||""),alt:Pe,loading:"lazy",decoding:"async",onError:v=>{v.target.src="/placeholder.svg"}})}),t("div",{className:be.videoTitleSection,children:[t("div",{className:w.titleContainer,children:[t("h1",{children:Pe}),t("div",{className:w.scheduleInfo,children:[e.showMeta.status&&t("span",{className:w.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&t("span",{className:w.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),t("div",{className:w.controls,children:[t("button",{className:`${w.watchlistBtn} ${e.inWatchlist?w.inList:""}`,onClick:A,children:[e.inWatchlist?t(me,{name:"check",size:14}):t(me,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),t(zr,{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:`${w.watchlistBtn} ${w.queueBtn}`,activeClassName:w.queueActive}),Gt&&t("button",{className:`${w.watchlistBtn} ${w.markWatchedBtn} ${kt?w.markWatchedDone:""}`,onClick:qt,disabled:y||!e.currentEpisode,children:[t(me,{name:"check",size:14}),y?"Saving...":kt?"Watched":"Mark Watched"]}),t("button",{className:`${w.watchlistBtn} ${w.modeToggleBtn} ${e.currentMode==="dub"?w.modeToggleActive:""}`,onClick:()=>{const v=e.currentMode==="dub"?"sub":"dub";it(),a({type:"SET_MODE",payload:v}),localStorage.setItem("preferredMode",v)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),He&&t("button",{className:`${w.watchlistBtn} ${w.modeToggleBtn} ${d.state.useNativeControls?w.modeToggleActive:""}`,onClick:()=>{const v=!d.state.useNativeControls;d.actions.setUseNativeControls(v),localStorage.setItem("playerUseNativeControls",v.toString())},type:"button",children:d.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),wt(`${w.episodeActions} ${w.mobileEpisodeActions}`,"mobile"),t("div",{className:be.infoColumns,children:[t("div",{className:`${w.descriptionSection} ${w.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t(Hr,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."}),t("button",{className:w.detailsToggleBtn,onClick:M,children:[e.showCombinedDetails?t(me,{name:"chevron-up"}):t(me,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]})]}),e.showCombinedDetails&&t(jr,{showMeta:e.showMeta,styles:w})]})]})]})]}),t(Nr,{isOpen:te,onClose:()=>q(!1),episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:v=>{q(!1),l(`/watch/${r}/${v}`)}})]})};export{bs as default};
@@ -1 +0,0 @@
1
- import{X as ke,x as he,u as y,A as C,q as fe,h as j,d as ie,T as ce,_ as Ee,C as de}from"./vendor-core-DfaOB3Rn.js";import{I as Z}from"./vendor-icons-DrybRNxP.js";import{_ as we,g as me}from"./index-BP1z44Uk.js";const pe=ke(null);function N(){const n=he(pe);if(!n)throw new Error("Player controls must be inside a PlayerProvider.");return n}function ve(n,i){const t=N(),r=C(i);r.current=i;const l=n?.url,m=n?.hls,s=fe(g=>{t.mediaRef.current=g,t.connect()},[t]);return j(()=>{if(l)return t.loadSource({url:l,hls:m},r.current)},[t,l,m]),s}function Xe({source:n,sourceOptions:i,...t}){const r=ve(n,i);return y("video",{playsInline:!0,...t,ref:r})}function Qe({source:n,sourceOptions:i,...t}){const r=ve(n,i);return y("audio",{...t,ref:r})}const Te="_shell_u5gii_1",Pe="_stage_u5gii_38",Se="_shellFill_u5gii_87",Le="_shellFullscreen_u5gii_95",Fe="_uiLayer_u5gii_110",Me="_engineStatus_u5gii_121",xe="_volumeWrap_u5gii_134",Re="_volumeSlider_u5gii_140",oe={shell:Te,stage:Pe,shellFill:Se,shellFullscreen:Le,uiLayer:Fe,engineStatus:Me,volumeWrap:xe,volumeSlider:Re},Ce=({classes:n,videoRef:i,duration:t,formatTime:r,isScrubbing:l,buffered:m="auto",onSeek:s,onScrubStart:g,onScrubMove:h,onScrubEnd:M,timeLabelRef:E,children:w})=>{const v=C(null),S=C(null),P=C(null),k=C(null),c=C(null),f=C(!1),p=C(l);p.current=l;const d=C({onScrubMove:h,onScrubEnd:M});d.current={onScrubMove:h,onScrubEnd:M};const[H,A]=ie({time:0,position:null});j(()=>{const a=i.current;if(!a)return;const b=_=>{const e=_/t*100||0;v.current?.setAttribute("aria-valuenow",String(Math.round(_))),v.current?.setAttribute("aria-valuetext",`${r(_)} of ${r(t)}`),S.current&&(S.current.style.width=`${e}%`),P.current&&(P.current.style.left=`${e}%`),E?.current&&(E.current.innerText=`${r(_)} / ${r(t)}`)},x=()=>{l||b(a.currentTime)},$=()=>{if(m==="auto"&&a.buffered.length>0){const e=a.buffered.end(a.buffered.length-1)/t*100||0;k.current&&(k.current.style.width=`${e}%`)}};return b(a.currentTime),$(),a.addEventListener("timeupdate",x),a.addEventListener("progress",$),()=>{a.removeEventListener("timeupdate",x),a.removeEventListener("progress",$)}},[i,t,l,m,r,E]);const V=a=>{if(!v.current)return 0;const b=v.current.getBoundingClientRect();return b.width<=0?0:Math.min(1,Math.max(0,(a-b.left)/b.width))},ee=a=>{const b=a*t;v.current?.setAttribute("aria-valuenow",String(Math.round(b))),v.current?.setAttribute("aria-valuetext",`${r(b)} of ${r(t)}`);const x=b/t*100||0;S.current&&(S.current.style.width=`${x}%`),P.current&&(P.current.style.left=`${x}%`),E?.current&&(E.current.innerText=`${r(b)} / ${r(t)}`);const $=v.current?.getBoundingClientRect();A({time:b,position:$?a*$.width:null})};j(()=>{if(!l){c.current=null;return}const a=x=>{if(c.current!==null&&x.pointerId!==c.current||!t)return;const $=V(x.clientX);d.current.onScrubMove($);const _=$*t;v.current?.setAttribute("aria-valuenow",String(Math.round(_))),v.current?.setAttribute("aria-valuetext",`${r(_)} of ${r(t)}`);const e=_/t*100||0;S.current&&(S.current.style.width=`${e}%`),P.current&&(P.current.style.left=`${e}%`),E?.current&&(E.current.innerText=`${r(_)} / ${r(t)}`);const u=v.current?.getBoundingClientRect();A({time:_,position:u?$*u.width:null})},b=x=>{c.current!==null&&x.pointerId!==c.current||(c.current=null,f.current=!0,x.pointerType!=="mouse"&&A({time:0,position:null}),d.current.onScrubEnd())};return document.addEventListener("pointermove",a),document.addEventListener("pointerup",b),document.addEventListener("pointercancel",b),()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",b),document.removeEventListener("pointercancel",b)}},[l,t,r,E]);const Q=a=>{if(a.pointerType==="mouse"&&a.button!==0||!i.current||!t)return;a.preventDefault(),c.current=a.pointerId;try{v.current?.setPointerCapture(a.pointerId)}catch{}p.current||(p.current=!0,g());const b=V(a.clientX);h(b),ee(b)},te=a=>{if(!t||p.current||a.pointerType!=="mouse")return;const b=V(a.clientX);A({time:b*t,position:a.clientX-(v.current?.getBoundingClientRect().left??0)})},G=a=>{if(!(c.current!==null&&a.pointerId!==c.current)&&p.current){c.current=null,f.current=!0,a.pointerType!=="mouse"&&A({time:0,position:null});try{v.current?.hasPointerCapture(a.pointerId)&&v.current.releasePointerCapture(a.pointerId)}catch{}M()}};return y("div",{className:`${n.container} ${l&&n.scrubbing?n.scrubbing:""}`,ref:v,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.round(t||0),"aria-valuenow":Math.round(i.current?.currentTime||0),"aria-disabled":!t,tabIndex:0,onClick:a=>{if(f.current){f.current=!1;return}!i.current||isNaN(t)||t===0||s(V(a.clientX))},onPointerDown:Q,onPointerMove:te,onPointerUp:G,onPointerCancel:G,onMouseMove:a=>{if(l||!t)return;const b=V(a.clientX);A({time:b*t,position:a.clientX-(v.current?.getBoundingClientRect().left??0)})},onMouseLeave:()=>{l||A({time:0,position:null})},onKeyDown:a=>{if(!(!i.current||!t)&&((a.key==="Home"||a.key==="End")&&(a.preventDefault(),s(a.key==="Home"?0:1)),a.key==="ArrowRight"||a.key==="ArrowLeft")){a.preventDefault();const b=(a.key==="ArrowRight"?5:-5)/t,x=i.current.currentTime/t||0;s(Math.min(1,Math.max(0,x+b)))}},children:[H.position!==null&&y("div",{className:n.timeBubble,style:{left:H.position},children:r(H.time)}),y("div",{className:n.bar,children:[y("div",{className:n.buffered,ref:k,style:m==="full"?{width:"100%"}:void 0}),y("div",{className:n.watched,ref:S}),y("div",{className:n.thumb,ref:P,onMouseDown:a=>{a.preventDefault(),i.current&&(p.current||g())}}),w]})]})};function ne(){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 _e(){const[n,i]=ie(ne);return j(()=>{i(ne());let t=null;const r=()=>i(ne());try{t=window.matchMedia("(pointer: coarse)"),t.addEventListener?t.addEventListener("change",r):t.addListener(r)}catch{}return window.addEventListener("touchstart",r,{passive:!0,once:!0}),()=>{try{t&&(t.removeEventListener?t.removeEventListener("change",r):t.removeListener(r))}catch{}window.removeEventListener("touchstart",r)}},[]),n}const Be=450,Ae=({muted:n,volume:i,volumeIcon:t,buttonClassName:r,sliderClassName:l,onToggleMute:m,onVolumeChange:s,onExpandedChange:g})=>{const h=_e(),[M,E]=ie(!1),w=C(null),v=C(!1),S=C(null),P=fe(d=>{E(d),g?.(d)},[g]);j(()=>()=>{w.current&&window.clearTimeout(w.current)},[]),j(()=>{if(!M)return;const d=H=>{S.current&&!S.current.contains(H.target)&&P(!1)};return document.addEventListener("pointerdown",d),()=>document.removeEventListener("pointerdown",d)},[M,P]);const k=n?0:i,c=()=>{v.current=!1,w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{v.current=!0,P(!0)},Be)},f=()=>{w.current&&(window.clearTimeout(w.current),w.current=null)},p=d=>{if(d.stopPropagation(),v.current){v.current=!1;return}if(h){M?m():P(!0);return}m()};return y("div",{ref:S,className:oe.volumeWrap,"data-expanded":M?"true":"false",onContextMenu:d=>d.preventDefault(),children:[y("button",{type:"button",className:r,onClick:p,onPointerDown:c,onPointerUp:f,onPointerLeave:f,onContextMenu:d=>d.preventDefault(),"aria-label":n?"Unmute":"Mute","aria-expanded":M,children:t}),y("input",{type:"range",min:"0",max:"1",step:"0.05",value:k,onChange:d=>s(parseFloat(d.currentTarget.value)),onClick:d=>d.stopPropagation(),onPointerDown:d=>d.stopPropagation(),onContextMenu:d=>d.preventDefault(),className:`${oe.volumeSlider} ${l??""}`,style:{"--volume-percent":`${k*100}%`},"aria-label":"Volume"})]})};let Y=null,re=null;async function $e(){return Y||(re||(re=we(()=>import("./hls-BOLXTnjL.js"),[]).then(n=>(Y=n.default,Y)).catch(()=>null)),re)}function De(n){return n.canPlayType("application/vnd.apple.mpegurl")!==""||n.canPlayType("application/x-mpegURL")!==""}function ue(){return document}function le(n){const i=ue();if(document.fullscreenElement)return document.fullscreenElement;if(i.webkitFullscreenElement)return i.webkitFullscreenElement;const t=n;return t?.webkitDisplayingFullscreen?t:null}function be(n){return le(n)!==null}async function Ie(n,i){if(le(i))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 r=i;if(r&&typeof r.webkitEnterFullscreen=="function"){if(r.webkitSupportsFullscreen===!1)return;try{await r.webkitEnterFullscreen()}catch{}}}async function Ne(n){const i=ue();try{if(document.fullscreenElement&&typeof document.exitFullscreen=="function"){await document.exitFullscreen();return}if(i.webkitFullscreenElement&&typeof i.webkitExitFullscreen=="function"){await i.webkitExitFullscreen();return}}catch{}const t=n;if(t?.webkitDisplayingFullscreen&&typeof t.webkitExitFullscreen=="function"){try{t.webkitExitFullscreen()}catch{}return}try{typeof i.webkitCancelFullScreen=="function"?i.webkitCancelFullScreen():!document.fullscreenElement&&typeof document.exitFullscreen=="function"&&(document.fullscreenElement??i.webkitFullscreenElement)&&await document.exitFullscreen()}catch{}}async function Ve(n,i){!n&&!i||(be(i)?await Ne(i):n&&await Ie(n,i))}function qe(n,i){const t=()=>{try{i(be(n()))}catch{}},r=ue(),l=t;r.addEventListener("fullscreenchange",t),r.addEventListener("webkitfullscreenchange",l),r.addEventListener("webkitbeginfullscreen",l,!0),r.addEventListener("webkitendfullscreen",l,!0);const m=n();return m?.addEventListener("webkitbeginfullscreen",l),m?.addEventListener("webkitendfullscreen",l),()=>{r.removeEventListener("fullscreenchange",t),r.removeEventListener("webkitfullscreenchange",l),r.removeEventListener("webkitbeginfullscreen",l,!0),r.removeEventListener("webkitendfullscreen",l,!0),m?.removeEventListener("webkitbeginfullscreen",l),m?.removeEventListener("webkitendfullscreen",l)}}let U=null;function se(n){try{return n?localStorage.getItem(n):null}catch{return null}}function J(n,i){try{n&&localStorage.setItem(n,String(i))}catch{}}function Ue(n={}){const i=Number.parseFloat(se(n.volumeKey)??"");let t={isPlaying:!1,isBuffering:!1,isMuted:se(n.mutedKey)==="true",volume:Number.isFinite(i)?Math.max(0,Math.min(1,i)):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},r={currentTime:0,bufferedEnd:0};const l=new Set,m=new Set,s={current:null},g={current:null};let h=null,M=()=>{},E=()=>{},w=0,v=!1,S=1,P=!1,k=null;function c(e){Object.entries(e).every(([u,o])=>Object.is(t[u],o))||(t={...t,...e},l.forEach(u=>u()))}function f(e){r.currentTime===e.currentTime&&r.bufferedEnd===e.bufferedEnd||(r=e,m.forEach(u=>u()))}function p(e){if(!e)return;let u=0;for(let o=0;o<e.buffered.length;o++)if(e.buffered.start(o)<=e.currentTime&&e.buffered.end(o)>=e.currentTime){u=e.buffered.end(o);break}f({currentTime:Number.isFinite(e.currentTime)?e.currentTime:0,bufferedEnd:u})}function d(){p(s.current)}function H(){const e=s.current;if(h===e||(h&&(U===h&&(U=e),p(h),E(),h.pause(),h.removeAttribute("src"),h.load()),M(),h=e,!e))return;P=!1,U||(U=e),e.volume=t.volume,e.muted=t.isMuted,e.playbackRate=t.playbackRate;const u=()=>{const T=Array.from(e.textTracks);if(!T.length)return;const q=T.findIndex(O=>O.mode==="showing");c({subtitleTracks:T.map((O,X)=>({id:X,label:O.label||O.language||`Track ${X+1}`,language:O.language})),...q>=0?{activeSubtitleTrack:q}:{}})},o={play:()=>{U=e,c({isPlaying:!0,playBlocked:!1,error:null})},playing:()=>c({isPlaying:!0,isBuffering:!1,playBlocked:!1}),pause:()=>c({isPlaying:!1,isBuffering:!1}),ended:()=>{c({isPlaying:!1,isBuffering:!1}),d()},waiting:()=>{!e.paused&&(e.readyState<3||e.seeking)&&c({isBuffering:!0})},canplay:()=>c({isBuffering:!1}),seeking:()=>{e.paused||c({isBuffering:!0}),d()},seeked:()=>{c({isBuffering:!1}),d()},timeupdate:()=>{d(),!e.paused&&!e.seeking&&c({isBuffering:!1})},progress:d,loadedmetadata:()=>{e.playbackRate=t.playbackRate,c({duration:Number.isFinite(e.duration)?e.duration:0}),u()},durationchange:()=>c({duration:Number.isFinite(e.duration)?e.duration:0}),ratechange:()=>{t.isSpeedBoostActive||(S=e.playbackRate),e.defaultPlaybackRate!==e.playbackRate&&(e.defaultPlaybackRate=e.playbackRate),c({playbackRate:e.playbackRate})},volumechange:()=>{c({volume:e.volume,isMuted:e.muted}),J(n.volumeKey,e.volume),J(n.mutedKey,e.muted)},error:()=>c({error:e.error?.message||"Unable to play this source.",isPlaying:!1,isBuffering:!1})};Object.entries(o).forEach(([T,q])=>e.addEventListener(T,q)),e.textTracks.addEventListener("addtrack",u),e.textTracks.addEventListener("removetrack",u),e.textTracks.addEventListener("change",u);const L=()=>e.tagName==="VIDEO"?e:null,K=()=>{const T=le(L());c({isFullscreen:T!==null&&(T===e||T===g.current)})},B=typeof document>"u"?()=>{}:qe(L,K);typeof document<"u"&&K(),M=()=>{Object.entries(o).forEach(([T,q])=>e.removeEventListener(T,q)),B(),e.textTracks.removeEventListener("addtrack",u),e.textTracks.removeEventListener("removetrack",u),e.textTracks.removeEventListener("change",u)}}async function A(){const e=s.current;if(!e)return!1;U=e;const u=w;try{return await e.play(),u===w}catch(o){if(u===w){const L=o instanceof Error&&o.name==="NotAllowedError",K=o instanceof Error&&o.name==="AbortError";c({isPlaying:!1,isBuffering:!1,playBlocked:L,...!L&&!K?{error:o instanceof Error?o.message:"Playback failed."}:{}})}return!1}}function V(){s.current?.pause()}function ee(){s.current?.paused?A():V()}function Q(e){const u=s.current;if(!u||!Number.isFinite(e))return;let o=Math.max(0,e);if(Number.isFinite(u.duration))o=Math.min(u.duration,o);else if(u.seekable.length)for(let L=0;L<u.seekable.length;L++){if(o<=u.seekable.end(L)){o=Math.max(u.seekable.start(L),o);break}L===u.seekable.length-1&&(o=u.seekable.end(L))}u.currentTime=o,d()}function te(e){Q((s.current?.currentTime??r.currentTime)+e)}function G(e){if(!Number.isFinite(e))return;const u=Math.max(0,Math.min(1,e));c({volume:u,isMuted:u===0}),s.current&&(s.current.volume=u,s.current.muted=u===0),J(n.volumeKey,u),J(n.mutedKey,u===0)}function a(){const e=!t.isMuted;!e&&t.volume===0&&G(.5),c({isMuted:e}),s.current&&(s.current.muted=e),J(n.mutedKey,e)}function b(e){if(!Number.isFinite(e)||e<.25||e>4)return;S=e;const u=t.isSpeedBoostActive?2:e;c({playbackRate:u}),s.current&&(s.current.playbackRate=u)}function x(){t.isScrubbing||(v=!!s.current&&!s.current.paused,c({isScrubbing:!0}),V())}function $(){t.isScrubbing&&(c({isScrubbing:!1}),v&&A(),v=!1)}function _(e,u={}){E(),H();const o=s.current,L=++w;if(!o)return()=>{};let K=!1,B=null;const T=()=>!K&&w===L&&s.current===o;o.pause(),o.removeAttribute("src"),o.load(),c({duration:0,isPlaying:!1,isBuffering:!0,isScrubbing:!1,error:null,playBlocked:!1,audioTracks:[],subtitleTracks:[],qualities:[],activeAudioTrack:-1,activeSubtitleTrack:-1,activeQuality:-1}),f({currentTime:0,bufferedEnd:0});const q=()=>{T()&&u.initialTime&&u.initialTime>0&&Q(u.initialTime)};o.addEventListener("loadedmetadata",q,{once:!0});const O=()=>{T()&&(u.onReady?.(),u.autoPlay&&T()&&A())},X=F=>{if(!T())return;const D=F instanceof Error?F:new Error(String(F));c({error:D.message,isPlaying:!1,isBuffering:!1}),u.onError?.(D)},z=()=>{K||(K=!0,o.removeEventListener("loadedmetadata",q),o.removeEventListener("error",ae),B?.destroy(),k===B&&(k=null),B=null,w===L&&w++)},ae=()=>{X(new Error(o.error?.message||"Unable to play this source.")),z()};return o.addEventListener("error",ae),E=z,(async()=>{if(e.hls){const F=await $e();if(!T())return;if(F?.isSupported()){B=new F({enableWorker:!0,startPosition:u.initialTime??-1,...u.hlsConfig}),k=B;const D=B,ge=()=>{T()&&c({audioTracks:D.audioTracks.map((R,I)=>({id:I,label:R.name||R.lang||`Track ${I+1}`,language:R.lang})),...o.querySelector("track")?{}:{subtitleTracks:D.subtitleTracks.map((R,I)=>({id:I,label:R.name||R.lang||`Track ${I+1}`,language:R.lang}))},qualities:D.levels.map((R,I)=>({id:I,label:R.height?`${R.height}p`:`${Math.round(R.bitrate/1e3)}k`})),activeAudioTrack:D.audioTrack,...o.querySelector("track")?{}:{activeSubtitleTrack:D.subtitleTrack},activeQuality:D.currentLevel})};for(const R of[F.Events.MANIFEST_PARSED,F.Events.AUDIO_TRACKS_UPDATED,F.Events.AUDIO_TRACK_SWITCHED,F.Events.SUBTITLE_TRACKS_UPDATED,F.Events.SUBTITLE_TRACK_SWITCH,F.Events.LEVEL_SWITCHED])D.on(R,ge);if(B.on(F.Events.ERROR,(R,I)=>{I.fatal&&T()&&(X(new Error(`Stream failed (${I.details}). Try another source or reload.`)),z())}),B.once(F.Events.MANIFEST_PARSED,O),u.onHls?.(B,F),!T())return;B.loadSource(e.url),B.attachMedia(o);return}if(!De(o))throw new Error("HLS playback is unavailable in this browser.")}T()&&(o.src=e.url,o.load(),O())})().catch(F=>{X(F),z()}),z}return{mediaRef:s,containerRef:g,connect:H,getState:()=>t,getTimeline:()=>r,getHls:()=>k,isActive:()=>U===s.current,subscribe:e=>(l.add(e),()=>{l.delete(e)}),subscribeTimeline:e=>(m.add(e),()=>{m.delete(e)}),play:A,pause:V,togglePlay:ee,seek:Q,seekRelative:te,setVolume:G,toggleMute:a,setPlaybackRate:b,setAudioTrack:e=>{k&&t.audioTracks.some(u=>u.id===e)&&(k.audioTrack=e,c({activeAudioTrack:e}))},setSubtitleTrack:e=>{if(e!==-1&&!t.subtitleTracks.some(o=>o.id===e))return;const u=s.current;u?.querySelector("track")?Array.from(u.textTracks).forEach((o,L)=>{o.mode=L===e?"showing":"disabled"}):k&&(k.subtitleTrack=e),c({activeSubtitleTrack:e})},setQuality:e=>{k&&(e===-1||t.qualities.some(u=>u.id===e))&&(k.currentLevel=e,c({activeQuality:e}))},setSpeedBoost:e=>{const u=e?2:S;c({isSpeedBoostActive:e,playbackRate:u}),s.current&&(s.current.playbackRate=u)},setShowControls:e=>c({showControls:e}),startScrubbing:x,endScrubbing:$,loadSource:_,unload:()=>{const e=s.current;p(e),E(),e&&(e.pause(),e.removeAttribute("src"),e.load()),c({isPlaying:!1,isBuffering:!1,duration:0,error:null}),f({currentTime:0,bufferedEnd:0})},toggleFullscreen:()=>{const e=s.current;Ve(g.current,e?.tagName==="VIDEO"?e:null).catch(u=>c({error:u instanceof Error?u.message:"Fullscreen failed."}))},reset:()=>{c({duration:0,isBuffering:!1,error:null}),f({currentTime:0,bufferedEnd:0})},destroy:()=>{if(P)return;P=!0;const e=h??s.current;p(e),M(),h=null,E(),e?.pause(),e?.removeAttribute("src"),e?.load(),U===e&&(U=null)}}}function W(n){return de(n.subscribe,n.getState)}function ye(n){return de(n.subscribeTimeline,n.getTimeline)}function Ge(n={}){const i=C(n),t=ce(()=>Ue(i.current),[]);return Ee(()=>{t.connect()}),j(()=>()=>t.destroy(),[t]),ce(()=>({engine:t,mediaRef:t.mediaRef}),[t])}function He({children:n,...i}){const t=N(),{isPlaying:r}=W(t);return y("button",{type:"button","aria-label":r?"Pause":"Play",...i,onClick:t.togglePlay,children:n??y(Z,{name:r?"pause":"play"})})}function ze({seconds:n,children:i,...t}){const r=N();return y("button",{type:"button","aria-label":`Seek ${n<0?"back":"forward"} ${Math.abs(n)} seconds`,...t,onClick:()=>r.seekRelative(n),children:i??y(Z,{name:n<0?"replay-10":"forward-10"})})}function Je(n){const i=N(),{isFullscreen:t}=W(i);return y("button",{type:"button","aria-label":t?"Exit Fullscreen":"Fullscreen",...n,onClick:i.toggleFullscreen,children:y(Z,{name:t?"compress":"expand"})})}function Ye({buttonClassName:n,onExpandedChange:i}){const t=N(),{isMuted:r,volume:l}=W(t);return y(Ae,{muted:r,volume:l,volumeIcon:y(Z,{name:r||l===0?"volume-mute":l<.5?"volume-down":"volume-up"}),buttonClassName:n,onToggleMute:t.toggleMute,onVolumeChange:t.setVolume,onExpandedChange:i})}function Ze({className:n}){const i=N(),{volume:t,isMuted:r}=W(i);return y("input",{type:"range",min:0,max:1,step:.01,value:r?0:t,onChange:l=>i.setVolume(Number(l.currentTarget.value)),className:n,style:{"--volume-percent":`${(r?0:t)*100}%`},"aria-label":"Volume"})}function et({classes:n,timeLabelRef:i,children:t}){const r=N(),{duration:l,isScrubbing:m}=W(r);return y(Ce,{classes:n,videoRef:r.mediaRef,duration:l,formatTime:me,isScrubbing:m,onSeek:s=>r.seek(s*l),onScrubStart:r.startScrubbing,onScrubMove:s=>r.seek(s*l),onScrubEnd:r.endScrubbing,timeLabelRef:i,children:t})}function tt({className:n}){const i=N(),{currentTime:t,bufferedEnd:r}=ye(i),{duration:l}=W(i),m=l?Math.min(100,t/l*100):0,s=l?Math.min(100,Math.max(m,r/l*100)):0;return y("input",{type:"range",min:0,max:l,step:.1,value:Math.min(t,l),onChange:g=>i.seek(Number(g.currentTarget.value)),onPointerDown:g=>{g.currentTarget.setPointerCapture(g.pointerId),i.startScrubbing()},onPointerUp:i.endScrubbing,onPointerCancel:i.endScrubbing,onLostPointerCapture:i.endScrubbing,className:n,style:{"--played-percent":`${m}%`,"--buffered-percent":`${s}%`},"aria-label":"Seek"})}function nt({className:n,durationOnly:i=!1}){const t=N(),{currentTime:r}=ye(t),{duration:l}=W(t);return y("span",{className:n,children:me(i?l:r)})}function rt(){const n=N(),{error:i,playBlocked:t,isBuffering:r}=W(n);return i?y("div",{role:"alert",children:i}):t?y(He,{children:"Tap to play"}):r?y("div",{role:"status","aria-label":"Buffering",children:"Loading…"}):null}const Ke='input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable]:not([contenteditable="false"]), [data-player-ui="true"], [data-speed-boost-ignore="true"]';function it(n,i,t=!0){const r=C(i);r.current=i,j(()=>{if(!t)return;let l=!1,m=!1,s=!1,g,h,M=!1;const E=()=>{const f=m||s;f!==M&&(M=f,n.setSpeedBoost(f))},w=f=>f instanceof Element&&!!f.closest(Ke),v=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,g=setTimeout(()=>{g=void 0,m=!0,E()},180),r.current();return}const p=f.key.toLowerCase();["k","j","l","arrowleft","arrowright","arrowup","arrowdown","m","f"].includes(p)&&(f.preventDefault(),!(f.repeat&&["k","m","f"].includes(p))&&(p==="k"&&n.togglePlay(),(p==="j"||p==="arrowleft")&&n.seekRelative(-10),(p==="l"||p==="arrowright")&&n.seekRelative(10),p==="arrowup"&&n.setVolume(n.getState().volume+.1),p==="arrowdown"&&n.setVolume(n.getState().volume-.1),p==="m"&&n.toggleMute(),p==="f"&&n.toggleFullscreen(),r.current()))},S=f=>{f.code!=="Space"||!l||(f.preventDefault(),l=!1,clearTimeout(g),g=void 0,m?(m=!1,E()):n.togglePlay(),r.current())},P=f=>{const p=f.target;f.button!==0||!(p instanceof Element)||w(p)||!n.containerRef.current?.contains(p)||(clearTimeout(h),h=setTimeout(()=>{h=void 0,s=!0,E()},180))},k=()=>{clearTimeout(h),h=void 0,s=!1,E()},c=()=>{clearTimeout(g),g=void 0,l=!1,m=!1,k()};return document.addEventListener("keydown",v),document.addEventListener("keyup",S),document.addEventListener("pointerdown",P),document.addEventListener("pointerup",k),document.addEventListener("pointercancel",k),window.addEventListener("blur",c),()=>{document.removeEventListener("keydown",v),document.removeEventListener("keyup",S),document.removeEventListener("pointerdown",P),document.removeEventListener("pointerup",k),document.removeEventListener("pointercancel",k),window.removeEventListener("blur",c),c()}},[n,t])}function ut({engine:n,children:i}){return y(pe.Provider,{value:n,children:i})}export{Je as F,et as P,ze as S,Ze as V,He as a,Ye as b,Xe as c,ut as d,N as e,W as f,ye as g,it as h,nt as i,tt as j,rt as k,Qe as l,_e as m,be as n,oe as s,Ge 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{I as o}from"./vendor-icons-DrybRNxP.js";import{S as ae,O as A,a as se,A as le,b as ie}from"./OptionListMenu-CGazCg0C.js";import{u as re}from"./index-BP1z44Uk.js";import"./usePlaybackEnd-DmvZ__Ut.js";import"./PlayerProvider-pi0at080.js";import"./vendor-query-BBT5_sHx.js";import"./playbackCompletion-IPHm9fp5.js";const ce="_settingsPanel_1dymm_1",oe="_header_1dymm_33",me="_backBtn_1dymm_56",de="_contentWrapper_1dymm_76",ue="_menuContent_1dymm_82",he="_menuItem_1dymm_89",pe="_selected_1dymm_114",be="_currentValue_1dymm_134",ye="_menuNote_1dymm_141",ge="_menuError_1dymm_150",n={settingsPanel:ce,header:oe,backBtn:me,contentWrapper:de,menuContent:ue,menuItem:he,selected:pe,currentValue:be,menuNote:ye,menuError:ge},ve=($,P)=>{const{isOpen:y,onClose:ke,videoSources:Ce,currentSource:C,currentLink:N,onSourceChange:V,subtitles:O,activeSubtitleTrack:g,onSubtitleChange:E,subtitleSettings:z,onSubtitleSettingsChange:T,useNativeControls:v,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:f,anime4kProfile:r,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:k}=$,{lowEndMode:F}=re(),[a,i]=ne("main");w.useEffect(()=>{if(!y){const t=setTimeout(()=>i("main"),300);return()=>clearTimeout(t)}},[y]);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:N?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:g||"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),localStorage.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),v&&e(o,{name:"check",size:12})]}),f&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),f&&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&&k&&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,c)=>(parseInt(c.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.resolutionStr,label:s.resolutionStr,selected:N?.resolutionStr===s.resolutionStr})),onSelect:s=>{const c=t.find(l=>l.resolutionStr===s);c&&V(C,c)}})})},H=()=>e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:g==="off"},...O.map(t=>({key:t.label||t.lang,label:t.label,selected:g===(t.label||t.lang)}))],onSelect:t=>E(t)})}),K=()=>e("div",{className:n.menuContent,children:e(se,{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 c=navigator.userAgent.toLowerCase();return c.includes("chrome")||c.includes("chromium")||c.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} ${r==="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"})]}),r==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="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"})]}),r==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="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"})]}),r==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="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"})]}),r==="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(le,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:_,delayMs:I,onToggle:M,onDelayChange:D,onCalibrate:x})}),ee=()=>b&&k?e("div",{className:n.menuContent,children:e(ie,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},values:b,onChange:k})}):null;return y?e(ae,{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},Pe=w.forwardRef(ve);export{Pe as default};
@@ -1 +0,0 @@
1
- import{h as x,p as pe,a as fe,d as o,A as ge,g as Le,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as f}from"./vendor-icons-DrybRNxP.js";import{P as ae}from"./MediaCard-BODgA6ir.js";import{A as Ae}from"./AnimeCard-a7KkMGQv.js";import{S as Se}from"./SkeletonGrid-w6TsxWu7.js";import{t as ye,u as be,x as Ne,R as te,B as _,U as Te}from"./index-BP1z44Uk.js";import{E as Ce}from"./ErrorMessage-DAxegITP.js";import{A as Ee}from"./ActiveFilterChips-olGfwxle.js";import{s as t}from"./Search.module-C_qwCdHS.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-RZ_j_2BD.js";import"./useAnimeInfoData-8RI9qMzw.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-C-y5QFrT.js";import"./playbackCompletion-IPHm9fp5.js";const Re=[{value:"ALL",label:"All Types"},{value:"TV",label:"TV Series"},{value:"Movie",label:"Movie"},{value:"OVA",label:"OVA"},{value:"ONA",label:"ONA"},{value:"TV_SHORT",label:"TV Short"},{value:"SPECIAL",label:"Special"},{value:"ADULT",label:"Mature"}],Ie=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],De=[{value:"ALL",label:"All Countries"},{value:"JP",label:"Japan"},{value:"CN",label:"China"}],Pe=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"START_DATE_ASC",label:"Oldest"},{value:"EPISODES_DESC",label:"Most Episodes"},{value:"FAVOURITES_DESC",label:"Favourites"}],Oe=[{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"},{value:"CANCELLED",label:"Cancelled"},{value:"HIATUS",label:"Hiatus"}];function We(){x(()=>{document.title="Search - dango"},[]);const[r,le]=pe(),se=fe(),[m,B]=o(r.get("query")||""),[v,G]=o(parseInt(r.get("page")||"1")),[d,g]=o(r.get("type")||"ALL"),[L,A]=o(r.get("season")||"ALL"),[S,y]=o(r.get("year")||"ALL"),[Y,R]=o(r.get("country")||"ALL"),[k,re]=o(r.get("provider")||"anilist"),[U,I]=o(r.get("sortBy")||"POPULARITY_DESC"),[$,D]=o(r.get("status")||""),[b,ne]=o(!1),[ie,F]=o(null);x(()=>{let e=!1;return ye.data.anilistStatus.query().then(s=>{e||F(s.available)}).catch(()=>{e||F(!0)}),()=>{e=!0}},[]);const{lowEndMode:oe}=be(),P=ge(null),{data:ce}=Ne(),M=ce?.genres||[],[N,T]=o(()=>{const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],n=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return s.forEach(l=>l&&(e[l]="include")),n.forEach(l=>l&&(e[l]="exclude")),e}),V=new URLSearchParams(r);V.delete("page");const j=V.toString(),{data:p=[],isLoading:C,isError:ue,error:de}=te(j,v,14),{data:q}=te(j,v+1,14),[O,he]=o(!1),E=Le.useMemo(()=>k==="anilist"&&d==="ADULT"||O?p:p.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[p,O,k,d]);x(()=>{B(r.get("query")||""),g(r.get("type")||"ALL"),A(r.get("season")||"ALL"),y(r.get("year")||"ALL"),R(r.get("country")||"ALL"),re(r.get("provider")||"anilist"),I(r.get("sortBy")||"POPULARITY_DESC"),D(r.get("status")||""),G(parseInt(r.get("page")||"1"));const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],n=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];s.forEach(l=>l&&(e[l]="include")),n.forEach(l=>l&&(e[l]="exclude")),T(e)},[r]);const c=(e=1,s={})=>{Te();const n=s.type??d,l=s.status??$,W=s.season??L,J=s.year??S,K=s.country??Y,Q=s.sort??U,X=s.genreState??N,ve=s.showMature??O,i=new URLSearchParams;m.trim()&&i.set("query",m.trim()),n!=="ALL"&&i.set("type",n),l&&i.set("status",l),W!=="ALL"&&i.set("season",W),J!=="ALL"&&i.set("year",J),K!=="ALL"&&i.set("country",K),Q!=="POPULARITY_DESC"&&i.set("sortBy",Q);const Z=Object.entries(X).filter(([,u])=>u==="include").map(([u])=>u),ee=Object.entries(X).filter(([,u])=>u==="exclude").map(([u])=>u);Z.length>0&&i.set("genres",Z.join(",")),ee.length>0&&i.set("excludeGenres",ee.join(",")),n!=="ADULT"&&!ve&&i.set("adult","false"),i.set("provider","anilist"),e>1&&i.set("page",e.toString()),le(i),e!==v&&G(e)},z=e=>{if(c(e),P.current){const s=P.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:s,behavior:"smooth"})}},w=new Date().getFullYear(),me=[{value:"ALL",label:"All Years"},...Array.from({length:w-1980+1},(e,s)=>({value:String(w-s),label:String(w-s)}))],H=p.length>=14&&q&&q.length>0,h=[];d!=="ALL"&&h.push({key:"type",label:`Type: ${d}`,onRemove:()=>{g("ALL"),c(1,{type:"ALL"})}}),L!=="ALL"&&h.push({key:"season",label:`Season: ${L}`,onRemove:()=>{A("ALL"),c(1,{season:"ALL"})}}),S!=="ALL"&&h.push({key:"year",label:`Year: ${S}`,onRemove:()=>{y("ALL"),c(1,{year:"ALL"})}});for(const[e,s]of Object.entries(N))h.push({key:e,label:s==="include"?`+ ${e}`:`-${e}`,tone:s==="include"?"primary":"danger",onRemove:()=>{const n={...N};delete n[e],T(n),c(1,{genreState:n})}});return a("div",{className:"page-container",children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:"Search Anime"}),a("p",{className:t.pageSubtitle,children:"Search through thousands of titles and discover your next favorite"})]}),a("div",{className:t.filterContainer,children:[a("div",{className:t.searchBarWrapper,children:[a("div",{className:t.inputIconWrapper,children:[a(f,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search by title, character, or studio...",value:m,onInput:e=>B(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&c()})]}),a("div",{className:t.searchActions,children:[a(_,{onClick:()=>c(),className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${b?t.active:""}`,onClick:()=>ne(!b),children:[a(f,{name:"filter",size:14}),a("span",{children:"Filters"}),b?a(f,{name:"chevron-up",size:12}):a(f,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${b?t.show:""}`,children:[a("div",{className:t.filterDivider}),a("div",{className:t.filterGrid,children:[a("div",{className:t.filterItem,children:[a("label",{children:"Type"}),a("select",{value:d,onChange:e=>{if(e.currentTarget.value==="ADULT"){se("/mature?provider=mal");return}g(e.currentTarget.value)},children:Re.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Status"}),a("select",{value:$,onChange:e=>D(e.currentTarget.value),children:[a("option",{value:"",children:"All Status"}),Oe.map(e=>a("option",{value:e.value,children:e.label},e.value))]})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Season"}),a("select",{value:L,onChange:e=>A(e.currentTarget.value),children:Ie.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Year"}),a("select",{value:S,onChange:e=>y(e.currentTarget.value),children:me.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:["Country",ie===!1&&a("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:400},children:"AniList only - ignored by fallback providers"})]}),a("select",{value:Y,onChange:e=>R(e.currentTarget.value),children:De.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Sort By"}),a("select",{value:U,onChange:e=>I(e.currentTarget.value),children:Pe.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),M.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:M.map(e=>a("button",{className:`${t.genreButton} ${t[N[e]||""]}`,onClick:()=>{T(s=>{const n=s[e],l={...s};return n==="include"?l[e]="exclude":n==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(_,{variant:"secondary",onClick:()=>{T({}),g("ALL"),A("ALL"),y("ALL"),R("ALL"),I("POPULARITY_DESC"),D(""),he(!1),c(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(_,{onClick:()=>c(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),ue&&a(Ce,{message:de?.message||"Error"}),h.length>0&&a(Ee,{chips:h}),a("div",{className:t.resultsHeader,ref:P,children:[a("h2",{className:t.resultsTitle,children:m?`Search Results for "${m}"`:"Discover Anime"}),E.length>0&&a(ae,{page:v,canGoNext:H,onChange:z,isLoading:C})]}),a("div",{className:`${t.resultsGrid} ${oe?t.lowEnd:""}`,children:C?a(Se,{}):E.map(e=>a(Ae,{anime:e},e._id))}),!C&&E.length===0&&a("div",{className:t.noResults,children:[a(f,{name:"search",size:48,className:t.noResultsIcon}),a("h3",{children:"No results found"}),a("p",{children:"Try adjusting your search or filters to find what you're looking for."})]}),E.length>0&&a("div",{className:t.bottomPagination,children:a(ae,{page:v,canGoNext:H,onChange:z,isLoading:C,variant:"labeled"})})]})}export{We as default};
@@ -1,21 +0,0 @@
1
- import{d as s,A as j,h as O,u as e,q as le,S as Ne,T as Te,p as Ie,g as ue,_ as Le}from"./vendor-core-DfaOB3Rn.js";import{d as Re,D as pe,t as b,B as T,M as q,k as fe,i as xe,A as he,H as V,q as $,I as ge,J as Pe,K as De,T as Ae,u as Oe,e as Ge,L as Me,C as ne,V as ze,N as Ue}from"./index-BP1z44Uk.js";import{u as ce}from"./vendor-query-BBT5_sHx.js";import{T as K}from"./ToggleSwitch-CN_ppEc9.js";import{I as X}from"./vendor-icons-DrybRNxP.js";const se={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},re=["name","nativeName","englishName"],ie={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},Ee=()=>{const{titlePreference:t,setTitlePreference:r,loading:o}=Re(),c=pe(),[l,y]=s(ie[t]),[v,m]=s(!1),a=j(null);O(()=>{o||y(ie[t])},[t,o]);const i=async()=>{if(v)return;m(!0);const p=(re.indexOf(t)+1)%re.length,d=re[p],I=ie[d];a.current&&(a.current.style.transform="translateX(-100%)",a.current.style.opacity="0"),setTimeout(async()=>{y(I),r(d),a.current&&(a.current.style.transition="none",a.current.style.transform="translateX(100%)",a.current.style.opacity="0",a.current.offsetWidth,a.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",a.current.style.transform="translateX(0)",a.current.style.opacity="1");try{await c.mutateAsync({key:"titlePreference",value:d})}catch(h){console.error("Error saving title preference:",h)}finally{m(!1)}},300)};return o?e("p",{children:"Loading title preference..."}):e("div",{className:se["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:i,className:se["toggle-button"],disabled:v,children:e("span",{ref:a,className:se["toggle-label"],children:l})})]})},qe="_settingsHeader_ik3bf_1",Fe="_pageTitle_ik3bf_6",Ke="_pageSubtitle_ik3bf_14",$e="_settingsLayout_ik3bf_20",He="_sidebar_ik3bf_27",We="_sidebarIndicator_ik3bf_35",Be="_sidebarItem_ik3bf_50",Ve="_active_ik3bf_72",je="_mainContent_ik3bf_80",Qe="_tabContent_ik3bf_85",Ye="_settingItem_ik3bf_103",Je="_controls_ik3bf_108",Xe="_status_ik3bf_114",S={settingsHeader:qe,pageTitle:Fe,pageSubtitle:Ke,settingsLayout:$e,sidebar:He,sidebarIndicator:We,sidebarItem:Be,active:Ve,mainContent:je,tabContent:Qe,settingItem:Ye,controls:Je,status:Xe},Ze="_title_tm30b_11",et="_signIn_tm30b_18",tt="_userInfo_tm30b_25",at="_warning_tm30b_47",nt="_formGroup_tm30b_54",st="_label_tm30b_58",rt="_inputWrapper_tm30b_68",it="_input_tm30b_68",ot="_select_tm30b_92",lt="_actions_tm30b_109",ct="_hr_tm30b_117",g={title:Ze,signIn:et,userInfo:tt,warning:at,formGroup:nt,label:st,inputWrapper:rt,input:it,select:ot,actions:lt,hr:ct},dt="_sectionCard_1axuo_1",ut="_dangerCard_1axuo_23",ht="_settingRow_1axuo_31",N={sectionCard:dt,dangerCard:ut,settingRow:ht},gt=()=>{const[t,r]=s(!0),[o,c]=s(!1),[l,y]=s(!1),[v,m]=s(null),[a,i]=s({status:"idle"}),[u,p]=s(!1),[d,I]=s(""),[h,k]=s(!1),L=j(null),[R,x]=s({show:!1,message:"",type:"info"}),A=()=>{L.current&&(window.clearInterval(L.current),L.current=null)},w=le(f=>{y(f.authenticated),m(f.user||f.device.user||null),i(f.device),p(!!f.hasCustomClientId)},[]),C=le(async()=>{const f=await b.auth.githubStatus.query();w(f)},[w]),G=async()=>{try{const f=await b.auth.githubPoll.query();i(f),f.status==="success"?(A(),await C(),x({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):f.status==="error"&&(A(),x({show:!0,message:f.error||"GitHub authentication failed.",type:"error"}))}catch{A(),x({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},z=(f=5)=>{A(),L.current=window.setInterval(G,Math.max(f,5)*1e3)};O(()=>(C().catch(()=>{x({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>r(!1)),A),[C]);const _=async()=>{c(!0);try{const f=await b.auth.githubStart.mutate();i(f),z(f.verification?.interval)}catch(f){x({show:!0,message:f instanceof Error?f.message:"Failed to start GitHub authentication.",type:"error"})}finally{c(!1)}},D=async()=>{try{await b.auth.githubLogout.mutate(),y(!1),m(null),i({status:"idle"}),x({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{x({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},U=async()=>{k(!0);try{await b.auth.saveGithubAuth.mutate({clientId:d}),I(""),await C(),x({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{x({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},W=async()=>{k(!0);try{await b.auth.saveGithubAuth.mutate({clientId:""}),I(""),await C(),x({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{x({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:N.sectionCard,children:[e("h3",{className:g.title,children:"GitHub Cloud Sync"}),e("p",{className:g.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),l&&v?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:v.name||v.login})]}),e(T,{variant:"danger",onClick:D,children:"Sign Out"})]}):e("div",{className:g.signIn,children:e(T,{onClick:_,disabled:o||a.status==="pending",children:o||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(Ne,{children:[e("hr",{className:g.hr}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Verification URL"}),e("div",{className:g.inputWrapper,children:[e("input",{className:g.input,value:a.verification.verification_uri,readOnly:!0}),e(T,{onClick:()=>{const f=a.verification?.verification_uri;f&&/^https?:\/\//i.test(f)&&window.open(f,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Device Code"}),e("input",{className:g.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:g.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 ",u?"(override active)":""]}),e("div",{className:g.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:g.label,children:"Client ID (optional)"}),e("input",{className:g.input,value:d,onChange:f=>I(f.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:g.actions,children:[e(T,{onClick:U,disabled:h,children:"Save override"}),e(T,{variant:"secondary",onClick:W,disabled:h,children:"Use dango defaults"})]})]}),e(q,{isOpen:R.show,onClose:()=>x(f=>({...f,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:R.message})}),e(q.Actions,{children:e(T,{onClick:()=>x(f=>({...f,show:!1})),children:"OK"})})]})]})},mt=()=>{const[t,r]=s(!0),[o,c]=s(null),[l,y]=s(!1),[v,m]=s(!1),[a,i]=s(""),[u,p]=s(""),[d,I]=s(""),[h,k]=s(!1),[L,R]=s({show:!1,message:"",type:"info"}),x=async()=>{try{const D=await b.auth.user.query();c(D?.email?D:null)}catch{c(null)}},A=async()=>{try{const[_,D]=await Promise.all([b.auth.configStatus.query(),b.auth.googleAuth.query()]);y(!!_.hasConfig),m(!!(D.hasCustomWorkerUrl||D.hasCustomClientId||D.hasClientSecret))}catch(_){console.error("Failed to fetch config status",_)}};O(()=>{(async()=>{r(!0),await Promise.all([x(),A()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await x(),window.history.replaceState(null,"",window.location.pathname))}catch{}r(!1)})();const D=U=>{U.origin===window.location.origin&&typeof U.data=="object"&&U.data!==null&&U.data.type==="GOOGLE_AUTH_SUCCESS"&&(c(U.data.user),window.location.reload())};return window.addEventListener("message",D),()=>window.removeEventListener("message",D)},[]);const w=async()=>{try{const _=await b.auth.googleLogin.mutate();if(_.authenticated){window.location.reload();return}if(_.url){if(typeof window.DangoBridge<"u"){window.location.href=_.url;return}const U=600,W=700,f=window.innerWidth/2-U/2,Z=window.innerHeight/2-W/2;window.open(_.url,"GoogleAuth",`width=${U},height=${W},top=${Z},left=${f}`)}else throw new Error("Auth URL not available")}catch{R({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},C=async()=>{try{await b.auth.logout.mutate(),c(null),R({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(_){console.error("Sign out failed",_),R({show:!0,message:"Failed to sign out.",type:"error"})}},G=async()=>{k(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:a,clientId:u,clientSecret:d}),i(""),p(""),I(""),await A(),R({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{R({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},z=async()=>{k(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),i(""),p(""),I(""),await A(),R({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{R({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:N.sectionCard,children:[e("h3",{className:g.title,children:"Google Drive Sync"}),o?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:o.name})," (",o.email,")"]}),e(T,{variant:"danger",onClick:C,children:"Sign Out"})]}):e("div",{className:g.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(T,{onClick:w,disabled:!l,children:"Sign in with Google"}),!l&&e("p",{className:g.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 ",v?"(override active)":""]}),e("div",{className:g.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:g.label,children:"Worker URL (optional)"}),e("input",{className:g.input,value:a,onChange:_=>i(_.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Client ID (optional)"}),e("input",{className:g.input,value:u,onChange:_=>p(_.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:g.input,value:d,onChange:_=>I(_.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:g.actions,children:[e(T,{onClick:G,disabled:h,children:"Save override"}),e(T,{variant:"secondary",onClick:z,disabled:h,children:"Use dango defaults"})]})]}),e(q,{isOpen:L.show,onClose:()=>R(_=>({..._,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:L.message})}),e(q.Actions,{children:e(T,{onClick:()=>R(_=>({..._,show:!1})),children:"OK"})})]})]})},pt="_settingItem_3qq0n_1",ft="_modalOverlay_3qq0n_6",yt="_modal_3qq0n_6",vt="_modalActions_3qq0n_41",bt="_modalSecondary_3qq0n_47",wt="_modalPrimary_3qq0n_57",H={settingItem:pt,modalOverlay:ft,modal:yt,modalActions:vt,modalSecondary:bt,modalPrimary:wt},kt={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"]]}},Ct=(t,r)=>{if(t==null)return r;const o=String(t);return o==="true"||o==="1"?!0:o==="false"||o==="0"?!1:r},me=(t,r,o)=>{const[c,l]=s(r),[y,v]=s(!1),m=ce();return O(()=>{(async()=>{try{const u=await b.settings.getByKey.query({key:t});l(Ct(u.value,r))}catch(u){console.error("Failed to fetch setting",u)}})()},[t,r]),{value:c,setValue:l,isUpdating:y,toggle:async()=>{if(y)return;v(!0);const i=!c;l(i);try{await b.settings.set.mutate({key:t,value:i});for(const u of o)m.invalidateQueries({queryKey:u})}catch(u){console.error("Error saving setting:",u),l(!i)}finally{v(!1)}}}},St=()=>{const{contentType:t}=fe(),r=kt[t],[o,c]=s(!1),[l,y]=s(!0),[v,m]=s(!1),a=me(r.ignoreKey,!0,r.invalidateKeys),i=me(r.listOnlyKey,!1,r.invalidateKeys),[u,p]=s(null),[d,I]=s(!1),h=ce(),k=xe();O(()=>{y(!0),(async()=>{try{const C=await b.settings.getByKey.query({key:r.skipKey});String(C.value)==="true"||String(C.value)==="1"?c(!0):c(!1)}catch(C){console.error("Failed to fetch setting",C)}finally{y(!1)}})()},[r.skipKey]);const L=async()=>{if(v)return;m(!0);const w=!o;c(w);try{await b.settings.set.mutate({key:r.skipKey,value:w})}catch(C){console.error("Error saving setting:",C),c(!w)}finally{m(!1)}},R=async()=>{if(!a.isUpdating){if(a.value)try{let w;if(t==="anime"?w=(await b.continueWatching.adultCount.query()).count:t==="manga"?w=(await b.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await b.asmrProgress.adultCount.query()).count:w=(await b.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){p(w);return}}catch(w){console.error("Failed to fetch adult count",w)}a.toggle()}},x=()=>{p(null),a.toggle()},A=async()=>{if(!d){I(!0);try{let w;t==="anime"?w=(await b.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await b.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await b.asmrProgress.purgeAdult.mutate()).removed:w=(await b.tvProgress.purgeAdult.mutate()).removed,he.success(r.purgeDoneText(w??0));for(const C of r.invalidateKeys)h.invalidateQueries({queryKey:C});t==="anime"&&h.invalidateQueries(k.continueWatching.pathFilter()),t==="manga"&&h.invalidateQueries(k.mangaProgress.pathFilter()),t==="asmr"&&h.invalidateQueries(k.asmrProgress.pathFilter()),t==="tv"&&h.invalidateQueries(k.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),he.error("Failed to remove adult entries")}finally{I(!1),p(null)}a.toggle()}};return l?e("div",{children:"Loading settings..."}):e("div",{className:N.sectionCard,children:[e("h3",{children:r.heading}),e("p",{children:r.blurb}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:r.skipLabel}),e(K,{isChecked:o,onChange:L,id:"skip-confirmation-toggle",disabled:v})]})}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:r.ignoreLabel}),e(K,{isChecked:a.value,onChange:R,id:"ignore-adult-toggle",disabled:a.isUpdating})]})}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:r.listOnlyLabel}),e(K,{isChecked:i.value,onChange:i.toggle,id:"cw-watchlist-only-toggle",disabled:i.isUpdating})]})}),u!==null&&e("div",{className:H.modalOverlay,onClick:()=>p(null),children:e("div",{className:H.modal,onClick:w=>w.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[u," adult ",u===1?"entry":"entries"," not in your"," ",r.listNoun," ",u===1?"is":"are"," currently hidden from"," ",r.continueNoun,". You can purge ",u===1?"it":"them"," from the database instead of showing ",u===1?"it":"them","."]}),e("div",{className:H.modalActions,children:[e("button",{type:"button",className:H.modalSecondary,onClick:x,disabled:d,children:"Show them"}),e("button",{type:"button",className:H.modalPrimary,onClick:A,disabled:d,children:d?"Purging...":`Purge ${u}`})]})]})})]})},_t="_statsGrid_o4nf0_1",Nt="_statCard_o4nf0_8",Tt="_statLabel_o4nf0_18",It="_statValue_o4nf0_26",Lt="_statMeta_o4nf0_32",Rt="_statusBanner_o4nf0_38",xt="_statusSuccess_o4nf0_49",Pt="_statusUpdating_o4nf0_55",Dt="_statusError_o4nf0_61",At="_sha_o4nf0_67",Ot="_settingItem_o4nf0_74",Gt="_settingTitle_o4nf0_79",Mt="_settingSubtitle_o4nf0_85",zt="_actionsRow_o4nf0_92",P={statsGrid:_t,statCard:Nt,statLabel:Tt,statValue:It,statMeta:Lt,statusBanner:Rt,statusSuccess:xt,statusUpdating:Pt,statusError:Dt,sha:At,settingItem:Ot,settingTitle:Gt,settingSubtitle:Mt,actionsRow:zt},Ut=()=>{const[t,r]=s(null),[o,c]=s(!0),[l,y]=s(!1),[v,m]=s(!1),a=j(null),i=async()=>{try{const h=await b.settings.offlineDbInfo.query();return r(h),h}catch(h){console.error("Failed to fetch offline DB info:",h)}finally{c(!1)}return null};O(()=>(i(),()=>{a.current&&window.clearInterval(a.current)}),[]),O(()=>{t?.isRefreshing?a.current||(a.current=window.setInterval(async()=>{const h=await i();h&&!h.isRefreshing&&a.current&&(window.clearInterval(a.current),a.current=null)},2e3)):a.current&&(window.clearInterval(a.current),a.current=null)},[t?.isRefreshing]);const u=async()=>{if(!t||l)return;const h=!t.autoUpdateEnabled;y(!0),r({...t,autoUpdateEnabled:h});try{await b.settings.setOfflineDbAutoUpdate.mutate({enabled:h})}catch(k){console.error("Failed to update auto update setting:",k),r({...t,autoUpdateEnabled:!h})}finally{y(!1)}},p=async()=>{if(!(t?.isRefreshing||v)){m(!0);try{await b.settings.triggerOfflineDbUpdate.mutate(),r(h=>h?{...h,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(h){console.error("Failed to trigger offline DB update:",h)}finally{m(!1)}}},d=h=>{if(!h)return"Never";try{return new Date(h).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return h}},I=t?.isRefreshing||v;return e("div",{className:N.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:P.statsGrid,children:[e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"MAL Mapped"}),e("span",{className:P.statValue,children:o?"-":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Release"}),e("span",{className:P.statMeta,children:o?"-":t?.releaseTag??"Never"})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Checked"}),e("span",{className:P.statMeta,children:o?"-":d(t?.lastCheckedAt??null)})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Updated"}),e("span",{className:P.statMeta,children:o?"-":d(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${P.statusBanner} ${t.lastStatus==="failed"?P.statusError:t.lastStatus==="updating"?P.statusUpdating:P.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:P.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:P.settingItem,children:e("div",{className:N.settingRow,children:[e("div",{children:[e("span",{className:P.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:P.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(K,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:u,disabled:o||l})]})}),e("div",{className:P.actionsRow,children:e(T,{onClick:p,disabled:o||I,children:I?"Updating Database...":"Update Offline Database Now"})})]})},Et="_status_1wbo0_1",qt="_warningText_1wbo0_7",Ft="_ackLabel_1wbo0_11",oe={status:Et,warningText:qt,ackLabel:Ft},Kt=()=>{const t=ce(),[r,o]=s(!1),[c,l]=s(!1),[y,v]=s(!1),[m,a]=s(""),i=()=>{l(!1),a(""),o(!0)},u=()=>{y||(o(!1),l(!1))},p=async()=>{if(!(!c||y)){v(!0),a("");try{const d=await V("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),I=await d.json();if(!d.ok)throw new Error(I.error||"Failed to clear database");const h=I.deleted,k=I.deletedManga,L=I.deletedTv,R=I.deletedAsmr,x=Object.values(h).reduce((G,z)=>G+(z||0),0)+Object.values(k??{}).reduce((G,z)=>G+(z||0),0)+Object.values(L??{}).reduce((G,z)=>G+(z||0),0)+Object.values(R??{}).reduce((G,z)=>G+(z||0),0),A=(k?.manga_library??0)+(k?.manga_progress??0),w=(L?.tv_library??0)+(L?.tv_progress??0),C=(R?.asmr_library??0)+(R?.asmr_progress??0);a(`Library cleared - ${h.watchlist??0} watchlist entries, ${A} manga rows, ${w} TV rows, ${C} ASMR rows and ${x} total rows removed.`),t.invalidateQueries({queryKey:[$.watchlist]}),t.invalidateQueries({queryKey:[$.continueWatching]}),t.invalidateQueries({queryKey:[$.mangaLibrary]}),t.invalidateQueries({queryKey:[$.mangaContinueReading]}),t.invalidateQueries({queryKey:[$.tvLibrary]}),t.invalidateQueries({queryKey:[$.tvContinueWatching]}),t.invalidateQueries({queryKey:[$.asmrLibrary]}),t.invalidateQueries({queryKey:[$.asmrContinueListening]}),o(!1)}catch(d){a(d.message)}finally{v(!1),l(!1)}}};return e("div",{className:`${N.sectionCard} ${N.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(T,{variant:"danger",onClick:i,children:"Clear Library Data"}),m&&e("p",{className:oe.status,children:m}),e(q,{isOpen:r,onClose:u,title:"Clear library data?",width:"sm",children:[e(q.Body,{children:[e("p",{className:oe.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:oe.ackLabel,children:[e("input",{type:"checkbox",checked:c,onChange:d=>l(d.currentTarget.checked),disabled:y}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(q.Actions,{children:[e(T,{variant:"secondary",onClick:u,disabled:y,children:"Cancel"}),e(T,{variant:"danger",onClick:p,disabled:!c||y,children:y?"Clearing...":"Yes, delete everything"})]})]})]})},$t=()=>{const[t,r]=s(""),[o,c]=s([]),[l,y]=s(null),[v,m]=s(!0),[a,i]=s({show:!1,message:"",type:"info"}),u=async()=>{try{m(!0);const d=await b.auth.rcloneSettings.query();r(d.remote||""),c(d.availableRemotes||[]),y(d.activeRemote||null)}catch(d){console.error("Failed to fetch Rclone settings",d)}finally{m(!1)}};O(()=>{u()},[]);const p=async()=>{try{await b.auth.saveRclone.mutate({remote:t}),i({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),u()}catch{i({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return v?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:N.sectionCard,children:[e("h3",{className:g.title,children:"Rclone Cloud Sync"}),e("p",{className:g.signIn,children:"Configure which Rclone remote to use for database synchronization."}),l?e("div",{className:g.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:l})]})}):e("p",{className:g.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Remote Name"}),e("div",{className:g.inputWrapper,children:e("select",{className:g.select,value:t,onChange:d=>r(d.currentTarget.value),children:[e("option",{value:"",children:"(Disabled / None)"}),o.map(d=>e("option",{value:d,children:d},d)),t&&!o.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:g.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:g.actions,children:e(T,{onClick:p,children:"Save Rclone Settings"})}),e(q,{isOpen:a.show,onClose:()=>i(d=>({...d,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:a.message})}),e(q.Actions,{children:e(T,{onClick:()=>i(d=>({...d,show:!1})),children:"OK"})})]})]})},Ht=()=>{const[t,r]=s(null),[o,c]=s(!0),l=async()=>{try{const a=await b.auth.syncSettings.query();r(a)}catch(a){console.error("Failed to fetch sync settings",a)}finally{c(!1)}};O(()=>{l()},[]);const y=async a=>{const i=a.currentTarget.value;try{const u=await b.auth.saveSyncProvider.mutate({provider:i});r(p=>p?{...p,activeProvider:u.activeProvider}:null),await l(),ge.success(`Sync provider updated to ${i==="default"?"Default Order":i}`)}catch{ge.error("Failed to update sync provider")}};if(o||!t)return null;const v=[{value:"default",label:"Default (Priority Based)"}];t.authenticatedProviders.github&&v.push({value:"github",label:"GitHub"}),t.authenticatedProviders.google&&v.push({value:"google",label:"Google Drive"}),t.authenticatedProviders.rclone&&v.push({value:"rclone",label:"Rclone"}),v.push({value:"none",label:"None (Local Only)"});const m=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:N.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:m(t.actualActiveProvider)})]}),e("div",{className:N.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:t.activeProvider,onChange:y,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:v.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function Wt(){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 Bt=()=>{const t=Te(Wt,[]);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:c=>{c.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(X,{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(T,{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.`})]})},Vt="_settingItem_68mz3_1",jt="_field_68mz3_6",Qt="_input_68mz3_19",Yt="_actions_68mz3_39",Jt="_status_68mz3_45",E={settingItem:Vt,field:jt,input:Qt,actions:Yt,status:Jt},Xt=()=>{const[t,r]=s(!1),[o,c]=s(""),[l,y]=s(""),[v,m]=s(!0),[a,i]=s(!1),[u,p]=s("");O(()=>{(async()=>{try{const R=await(await V("/api/auth/app-status")).json();r(R.hasPassword)}catch{console.error("Failed to fetch LAN auth status")}finally{m(!1)}})()},[]);const d=async()=>{if(p(""),o!==l){p("Passwords do not match");return}if(o.length<4){p("Password must be at least 4 characters");return}i(!0);try{const k=await V("/api/auth/app-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:o})}),L=await k.json();if(!k.ok){p(L.error||"Failed to update password");return}r(L.hasPassword),c(""),y(""),p(L.hasPassword?"Password set successfully":"Password removed")}catch{p("Network error")}finally{i(!1)}},I=async()=>{i(!0);try{const k=await V("/api/auth/app-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:""})}),L=await k.json();if(!k.ok){p(L.error||"Failed to remove password");return}r(!1),c(""),y(""),p("Password removed")}catch{p("Network error")}finally{i(!1)}},h=async()=>{i(!0);try{await V("/api/auth/app-logout",{method:"POST"}),p("Logged out"),window.location.reload()}catch{p("Logout failed")}finally{i(!1)}};return v?e("div",{className:N.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:N.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:E.settingItem,children:[e("div",{className:E.field,children:[e("label",{htmlFor:"lan-password",children:"New Password"}),e("input",{id:"lan-password",type:"password",value:o,onChange:k=>c(k.currentTarget.value),placeholder:t?"Leave empty to keep current password":"Enter a password...",className:E.input})]}),e("div",{className:E.field,children:[e("label",{htmlFor:"lan-confirm-password",children:"Confirm Password"}),e("input",{id:"lan-confirm-password",type:"password",value:l,onChange:k=>y(k.currentTarget.value),placeholder:"Confirm password...",className:E.input})]}),e("div",{className:E.actions,children:[e(T,{variant:"primary",onClick:d,loading:a,disabled:a,children:t?"Update Password":"Set Password"}),t&&e(T,{variant:"danger",onClick:h,loading:a,disabled:a,children:"Logout"}),t&&e(T,{variant:"secondary",onClick:I,loading:a,disabled:a,children:"Remove Password"})]}),u&&e("p",{className:E.status,children:u})]})]})},Zt=()=>{const[t,r]=s(""),[o,c]=s(!0),[l,y]=s(!1),[v,m]=s("");O(()=>{Pe("/api/auth/app-status").then(i=>r(String(i.port??3e3))).catch(()=>m("Failed to load current port")).finally(()=>c(!1))},[]);const a=async()=>{const i=Number(t);if(!Number.isInteger(i)||i<1||i>65535){m("Enter a port between 1 and 65535");return}y(!0),m("");try{await b.auth.setServerPort.mutate({port:i}),m(`Saved. Restart dango, then open http://localhost:${i} - this overrides the PORT environment variable.`)}catch(u){m(u.message)}finally{y(!1)}};return o?e("div",{className:N.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:N.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:E.settingItem,children:[e("div",{className:E.field,children:[e("label",{htmlFor:"server-port",children:"Port"}),e("input",{id:"server-port",type:"number",min:1,max:65535,value:t,onChange:i=>r(i.currentTarget.value),className:E.input})]}),e("div",{className:E.actions,children:e(T,{variant:"primary",onClick:a,loading:l,disabled:l,children:"Save Port"})}),v&&e("p",{className:E.status,children:v})]})]})},ea=()=>{const{theme:t,setTheme:r,loading:o}=De();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:Ae.map(c=>{const l=t===c.id;return e("button",{role:"radio","aria-checked":l,disabled:o,onClick:()=>r(c.id),style:{display:"flex",gap:"0.6rem",alignItems:"center",textAlign:"left",padding:"0.65rem 0.75rem",borderRadius:"10px",cursor:"pointer",background:l?"var(--accent-subtle)":"var(--bg-tertiary)",border:l?"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:c.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:c.label}),e("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.blurb})]})]},c.id)})})]})};function ta({variant:t="info",children:r,className:o=""}){return e("div",{className:`alert alert-${t} ${o}`,children:r})}const aa={anime:"Watchlist",manga:"Reading List",tv:"TV Watchlist",asmr:"Listening List"},la=()=>{const[t,r]=Ie(),{contentType:o}=fe(),c=t.get("tab"),[l,y]=s(c&&["general","sync","watchlist","database"].includes(c)?c:"general"),[v,m]=s(""),a=j(null),i=j(null),u=j(new Map),[p,d]=s({top:0,height:0,left:0,width:0}),{lowEndMode:I,setLowEndMode:h}=Oe(),{hasConsent:k,revoke:L}=Ge(),[R,x]=s(Me),[A,w]=s(!0),{data:C}=ne("discordRPCEnabled"),G=pe(),[z,_]=s(!0),{data:D}=ne("dangoGaze"),[U,W]=s(!0),{data:f}=ne("discordRPCHideMature"),[Z,ee]=s(""),[Q,ae]=s(null);O(()=>{b.discord.gatewayStatus.query().then(n=>{ae(n),n.masked&&n.masked!=="none"&&ee(n.masked)}).catch(()=>{})},[]),O(()=>{C!==void 0&&w(C==="true"||C===!0||C===null)},[C]),O(()=>{f!==void 0&&W(f==="true"||f===!0||f===null)},[f]);const ye=n=>{w(n),G.mutate({key:"discordRPCEnabled",value:String(n)})};O(()=>{D!==void 0&&_(D!=="false"&&D!==!1)},[D]);const ve=n=>{_(n),G.mutate({key:"dangoGaze",value:String(n)})},be=n=>{W(n),G.mutate({key:"discordRPCHideMature",value:String(n)})},we=n=>{x(n),localStorage.setItem(ze,String(n)),window.dispatchEvent(new CustomEvent(Ue))};ue.useEffect(()=>{document.title="Settings - dango"},[]),ue.useEffect(()=>{const n=t.get("tab");n&&["general","sync","watchlist","database"].includes(n)&&y(n)},[t]);const te=n=>{y(n),r(n==="general"?{}:{tab:n})},Y=le(()=>{const n=u.current.get(l),M=i.current;if(n&&M){const B=M.getBoundingClientRect(),F=n.getBoundingClientRect(),J=window.matchMedia("(max-width: 900px)").matches;d(J?{top:F.top-B.top,height:F.height,left:F.left-B.left,width:F.width}:{top:F.top-B.top,height:F.height,left:0,width:0})}},[l]);Le(()=>{Y()},[l,Y]),O(()=>{const n=()=>Y();window.addEventListener("resize",n);let M=!1;return document.fonts?.ready&&document.fonts.ready.then(()=>{M||Y()}),()=>{M=!0,window.removeEventListener("resize",n)}},[l,Y]);const ke=()=>{m("Exporting databases...");const n=window.DangoBridge;if(n?.downloadFile){n.downloadFile("/api/backup-db","dango-backup.json"),setTimeout(()=>{m("Databases exported successfully!")},1500);return}const M=document.createElement("a");M.href="/api/backup-db",M.download="dango-backup.json",document.body.appendChild(M),M.click(),M.remove(),setTimeout(()=>{m("Databases exported successfully!")},1500)},Ce=async n=>{const M=n.currentTarget.files?.[0];if(!M)return;m("Importing databases...");const B=new FormData;B.append("dbfile",M);try{const F=await V("/api/restore-db",{method:"POST",body:B}),J=await F.json();if(F.ok){const de=Array.isArray(J.restored)?J.restored.join(", "):null;m(de?`Databases imported successfully (${de})!`:"Database imported successfully!"),setTimeout(()=>window.location.reload(),2e3)}else m(`Import failed: ${J.error}`)}catch{m("Import failed: An unexpected error occurred.")}finally{n.currentTarget.value=""}},Se=()=>{a.current?.click()},_e=()=>{switch(l){case"general":return e("div",{className:S.tabContent,children:e("div",{className:N.sectionCard,children:[e("h3",{children:"Appearance & Preferences"}),e("p",{children:"Configure how titles are displayed and other general preferences."}),e("div",{className:S.settingItem,children:e(Ee,{})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e(ea,{})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.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(K,{isChecked:I,onChange:n=>h(n.currentTarget.checked),id:"low-end-mode"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Dango Animations"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Lets the dango logo look around, blink and react when you pet it. Always off in Low End Mode."})]}),e(K,{isChecked:z,onChange:n=>ve(n.currentTarget.checked),id:"dango-gaze"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.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(K,{isChecked:R,onChange:n=>we(n.currentTarget.checked),id:"virtual-keyboard-enabled"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.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(K,{isChecked:A,onChange:n=>ye(n.currentTarget.checked),id:"discord-rpc-enabled"})]})}),e("div",{style:{marginTop:"2rem"},children:e(Xt,{})}),e("div",{style:{marginTop:"2rem"},children:e(Zt,{})}),A&&e("div",{className:S.settingItem,style:{marginTop:"1rem"},children:e("div",{className:N.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(K,{isChecked:U,onChange:n=>be(n.currentTarget.checked),id:"discord-hide-mature"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem",background:"var(--bg-tertiary)",padding:"1rem",borderRadius:"8px",border:"1px solid var(--border-color)"},children:[e("div",{className:N.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(ta,{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:Z,onChange:n=>ee(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(T,{variant:"primary",size:"sm",onClick:async()=>{try{const n=await b.discord.gatewaySave.mutate({token:Z});ae({hasToken:!0,masked:n.masked,enabled:!0}),ee(n.masked)}catch(n){alert(n instanceof Error?n.message:"Failed to save token")}},children:"Save"}),e(T,{variant:"secondary",size:"sm",onClick:async()=>{await b.discord.gatewayRemove.mutate().catch(()=>{}),ee(""),ae({hasToken:!1,masked:null,enabled:!1})},children:"Remove"})]}),Q&&e("p",{style:{marginTop:"0.5rem",fontSize:"0.8rem",color:Q.hasToken?"green":"var(--text-secondary)"},children:["Status:"," ",Q.hasToken?`Token saved (${Q.masked})`:"No token saved",Q.enabled?" - Gateway active":""]}),e(Bt,{})]}),k&&e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.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:"You have previously agreed to view 18+ content. Toggle this off to re-enable the blur gate and filtering."})]}),e(K,{isChecked:!0,onChange:n=>{n.currentTarget.checked||(L(),window.location.reload())},id:"mature-content-enabled"})]})})]})});case"sync":return e("div",{className:S.tabContent,children:[e(Ht,{}),e(gt,{}),e(mt,{}),e($t,{})]});case"watchlist":return e("div",{className:S.tabContent,children:e(St,{})});case"database":return e("div",{className:S.tabContent,children:[e("div",{className:N.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:S.controls,children:[e(T,{onClick:ke,children:"Backup Database"}),e(T,{variant:"secondary",onClick:Se,children:"Restore Database"})]}),e("input",{type:"file",ref:a,onChange:Ce,style:{position:"absolute",width:1,height:1,opacity:0,overflow:"hidden"},accept:".json,.db,application/octet-stream"}),v&&e("p",{className:S.status,children:v})]}),e(Ut,{}),e(Kt,{})]});default:return null}};return e("div",{className:"page-container",children:[e("div",{className:S.settingsHeader,children:[e("h1",{className:S.pageTitle,children:"Settings"}),e("p",{className:S.pageSubtitle,children:"Manage your preferences and data synchronization"})]}),e("div",{className:S.settingsLayout,children:[e("aside",{className:S.sidebar,ref:i,children:[e("div",{className:S.sidebarIndicator,style:{top:p.top,height:p.height,left:p.left,...p.width?{width:p.width}:{}}}),e("button",{ref:n=>{n&&u.current.set("general",n)},className:`${S.sidebarItem} ${l==="general"?S.active:""}`,onClick:()=>te("general"),children:[e(X,{name:"cog"})," ",e("span",{children:"General"})]}),e("button",{ref:n=>{n&&u.current.set("sync",n)},className:`${S.sidebarItem} ${l==="sync"?S.active:""}`,onClick:()=>te("sync"),children:[e(X,{name:"cloud"})," ",e("span",{children:"Synchronization"})]}),e("button",{ref:n=>{n&&u.current.set("watchlist",n)},className:`${S.sidebarItem} ${l==="watchlist"?S.active:""}`,onClick:()=>te("watchlist"),children:[e(X,{name:"list"})," ",e("span",{children:aa[o]})]}),e("button",{ref:n=>{n&&u.current.set("database",n)},className:`${S.sidebarItem} ${l==="database"?S.active:""}`,onClick:()=>te("database"),children:[e(X,{name:"database"})," ",e("span",{children:"Database"})]})]}),e("main",{className:S.mainContent,children:e("div",{className:S.tabContent,children:_e()},l)})]})]})};export{la as default};
@@ -1 +0,0 @@
1
- ._title-preference-container_sdqgs_1{margin-bottom:var(--space-6);padding:var(--space-4);border:1px solid var(--border-primary);border-radius:var(--radius-md);background-color:var(--bg-tertiary)}._title-preference-container_sdqgs_1 h4{margin-top:0;margin-bottom:var(--space-4);color:var(--text-primary);font-size:var(--font-size-base);font-weight:var(--font-weight-semibold)}._error_sdqgs_17{color:var(--danger)}._toggle-button_sdqgs_21{position:relative;width:200px;height:40px;background:linear-gradient(135deg,var(--accent) 0%,var(--accent-dark) 100%);border:none;border-radius:20px;cursor:pointer;overflow:hidden;display:flex;align-items:center;justify-content:center;color:var(--accent-text);font-size:var(--font-size-base);font-weight:var(--font-weight-semibold);transition:var(--transition-base);box-shadow:var(--shadow-md)}._toggle-button_sdqgs_21:hover:not(:disabled){transform:translateY(-2px);box-shadow:var(--shadow-lg);filter:brightness(1.1)}._toggle-button_sdqgs_21:disabled{opacity:.7;cursor:not-allowed}._toggle-label_sdqgs_51{position:absolute;white-space:nowrap;transition:var(--transition-base)}._settingsHeader_ik3bf_1{margin-bottom:var(--space-8);animation:_fadeIn_ik3bf_1 .8s var(--ease-smooth)}._pageTitle_ik3bf_6{font-size:var(--font-size-xl);font-weight:800;color:var(--text-primary);margin:0 0 var(--space-2);letter-spacing:-.02em}._pageSubtitle_ik3bf_14{color:var(--text-tertiary);font-size:var(--font-size-sm);margin:0}._settingsLayout_ik3bf_20{display:flex;gap:var(--space-8);align-items:flex-start;animation:_slideUpIn_ik3bf_1 .8s var(--ease-smooth)}._sidebar_ik3bf_27{width:240px;display:flex;flex-direction:column;gap:var(--space-2);position:relative}._sidebarIndicator_ik3bf_35{position:absolute;left:0;right:0;border-radius:var(--radius-lg);background:var(--accent);transition:top .22s cubic-bezier(.2,1.2,.3,1),height .22s cubic-bezier(.2,1.2,.3,1),left .22s cubic-bezier(.2,1.2,.3,1),width .22s cubic-bezier(.2,1.2,.3,1);z-index:0;pointer-events:none}._sidebarItem_ik3bf_50{display:flex;align-items:center;gap:var(--space-3);padding:var(--space-4) var(--space-5);background:transparent;border:1px solid transparent;border-radius:var(--radius-lg);color:var(--text-tertiary);font-weight:600;font-size:var(--font-size-sm);cursor:pointer;transition:color .22s ease;text-align:left;position:relative;z-index:1}._sidebarItem_ik3bf_50:hover{color:var(--text-primary)}._sidebarItem_ik3bf_50._active_ik3bf_72{color:var(--accent-text)}._sidebarItem_ik3bf_50 svg{font-size:1.1rem}._mainContent_ik3bf_80{flex:1;min-width:0}._tabContent_ik3bf_85{display:flex;flex-direction:column;gap:var(--space-6);animation:_tabFadeIn_ik3bf_1 .3s ease}@keyframes _tabFadeIn_ik3bf_1{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}._settingItem_ik3bf_103{border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._controls_ik3bf_108{display:flex;gap:var(--space-4);flex-wrap:wrap}._status_ik3bf_114{margin-top:var(--space-4);padding:var(--space-3) var(--space-4);background:color-mix(in srgb,var(--accent) 10%,transparent);border-radius:var(--radius-md);color:var(--accent-light);font-size:var(--font-size-sm);font-weight:500}@keyframes _fadeIn_ik3bf_1{0%{opacity:0}to{opacity:1}}@keyframes _slideUpIn_ik3bf_1{0%{opacity:0;transform:translateY(30px)}to{opacity:1;transform:translateY(0)}}@media(max-width:900px){._settingsLayout_ik3bf_20{flex-direction:column}._sidebar_ik3bf_27{width:100%;flex-direction:row;overflow-x:auto;padding-bottom:var(--space-2)}._sidebarIndicator_ik3bf_35{right:auto;top:auto!important;bottom:0;height:3px!important}._sidebarItem_ik3bf_50{padding:var(--space-3) var(--space-4);white-space:nowrap;flex-shrink:0}._sidebarItem_ik3bf_50 span{display:block}}@media(max-width:480px){._sidebarItem_ik3bf_50 span{display:none}._sidebarItem_ik3bf_50{padding:var(--space-4);justify-content:center}}._sectionCard_tm30b_1{background:var(--glass-bg);backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);border:1px solid var(--glass-border);padding:var(--space-8);border-radius:var(--radius-xl);box-shadow:var(--glass-shadow)}._title_tm30b_11{margin:0 0 var(--space-2);font-size:var(--font-size-lg);font-weight:700;color:var(--text-primary)}._signIn_tm30b_18{color:var(--text-secondary);font-size:var(--font-size-sm);margin:0 0 var(--space-6);line-height:1.6}._userInfo_tm30b_25{padding:var(--space-4) var(--space-5);background:color-mix(in srgb,var(--color-success) 5%,transparent);border:1px solid color-mix(in srgb,var(--color-success) 20%,transparent);border-radius:var(--radius-lg);margin-bottom:var(--space-6);display:flex;align-items:center;justify-content:space-between;gap:var(--space-4)}._userInfo_tm30b_25 p{margin:0;color:var(--text-secondary);font-size:var(--font-size-sm)}._userInfo_tm30b_25 strong{color:var(--color-success)}._warning_tm30b_47{color:var(--color-warning);font-size:var(--font-size-xs);margin:var(--space-3) 0 0;font-weight:500}._formGroup_tm30b_54{margin-bottom:var(--space-5)}._label_tm30b_58{display:block;margin-bottom:var(--space-2);color:var(--text-tertiary);font-size:.7rem;font-weight:700;text-transform:uppercase;letter-spacing:.05em}._inputWrapper_tm30b_68{display:flex;gap:var(--space-2)}._input_tm30b_68{flex-grow:1;height:48px;padding:0 var(--space-4);background:var(--bg-tertiary);color:var(--text-primary);border:1px solid var(--border-primary);border-radius:var(--radius-lg);font-size:var(--font-size-base);transition:all var(--transition-fast)}._input_tm30b_68:focus{outline:none;border-color:var(--accent);background:var(--bg-elevated);box-shadow:0 0 0 4px var(--accent-glow)}._select_tm30b_92{flex-grow:1;height:48px;padding:0 var(--space-4);background:var(--bg-tertiary);color:var(--text-primary);border:1px solid var(--border-primary);border-radius:var(--radius-lg);font-size:var(--font-size-base);cursor:pointer;transition:all var(--transition-fast);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}._actions_tm30b_109{display:flex;gap:var(--space-3);margin-top:var(--space-6);border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._hr_tm30b_117{border:none;border-top:1px solid var(--border-primary);margin:var(--space-8) 0}@media(max-width:600px){._userInfo_tm30b_25{flex-direction:column;align-items:flex-start}._actions_tm30b_109{flex-direction:column}}._sectionCard_1axuo_1{background:var(--bg-tertiary);border:1px solid var(--border-secondary);border-radius:var(--radius-lg);padding:var(--space-5);margin-bottom:var(--space-4)}._sectionCard_1axuo_1 h3{margin:0 0 var(--space-3);font-size:var(--font-size-base);font-weight:700;color:var(--text-primary)}._sectionCard_1axuo_1 p{margin:0 0 var(--space-3);font-size:var(--font-size-sm);color:var(--text-secondary);line-height:1.5}._dangerCard_1axuo_23{border-color:color-mix(in srgb,var(--color-danger) 40%,transparent)}._dangerCard_1axuo_23 h3{color:var(--color-danger)}._settingRow_1axuo_31{display:flex;align-items:center;justify-content:space-between;gap:var(--space-4);padding:var(--space-3) 0;border-bottom:1px solid var(--border-secondary)}._settingRow_1axuo_31:last-child{border-bottom:none}._settingRow_1axuo_31 label{display:flex;flex-direction:column;gap:var(--space-1);font-size:var(--font-size-sm);color:var(--text-primary)}._settingItem_3qq0n_1{border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._modalOverlay_3qq0n_6{position:fixed;inset:0;background:#0009;display:flex;align-items:center;justify-content:center;z-index:1000;padding:var(--space-4)}._modal_3qq0n_6{background:var(--bg-secondary, #1a1a2e);border:1px solid var(--glass-border);border-radius:var(--radius-xl);padding:var(--space-8);max-width:420px;width:100%;box-shadow:var(--glass-shadow)}._modal_3qq0n_6 h4{margin:0 0 var(--space-2);font-size:var(--font-size-lg);font-weight:700;color:var(--text-primary)}._modal_3qq0n_6 p{color:var(--text-secondary);font-size:var(--font-size-sm);line-height:1.6;margin:0 0 var(--space-6)}._modalActions_3qq0n_41{display:flex;justify-content:flex-end;gap:var(--space-3)}._modalSecondary_3qq0n_47{background:transparent;border:1px solid var(--border-primary);color:var(--text-primary);border-radius:var(--radius-md);padding:var(--space-2) var(--space-4);cursor:pointer;font-size:var(--font-size-sm)}._modalPrimary_3qq0n_57{background:var(--accent, var(--color-danger));border:none;color:var(--accent-text, var(--color-danger-text));border-radius:var(--radius-md);padding:var(--space-2) var(--space-4);cursor:pointer;font-size:var(--font-size-sm);font-weight:600}._modalSecondary_3qq0n_47:disabled,._modalPrimary_3qq0n_57:disabled{opacity:.6;cursor:default}._statsGrid_o4nf0_1{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:var(--space-3);margin-bottom:var(--space-4)}._statCard_o4nf0_8{background:var(--bg-tertiary);border:1px solid var(--border-primary);border-radius:var(--radius-md);padding:var(--space-4);display:flex;flex-direction:column;gap:var(--space-1)}._statLabel_o4nf0_18{font-size:var(--font-size-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--text-tertiary);font-weight:600}._statValue_o4nf0_26{font-size:var(--font-size-xl);font-weight:700;color:var(--text-primary)}._statMeta_o4nf0_32{font-size:var(--font-size-sm);font-weight:500;color:var(--text-primary)}._statusBanner_o4nf0_38{display:flex;align-items:center;gap:var(--space-2);padding:var(--space-3) var(--space-4);border-radius:var(--radius-md);font-size:var(--font-size-sm);margin-bottom:var(--space-4);flex-wrap:wrap}._statusSuccess_o4nf0_49{background:color-mix(in srgb,var(--color-success, #22c55e) 10%,transparent);border:1px solid color-mix(in srgb,var(--color-success, #22c55e) 25%,transparent);color:var(--text-primary)}._statusUpdating_o4nf0_55{background:#6366f11a;border:1px solid rgba(99,102,241,.3);color:var(--text-primary)}._statusError_o4nf0_61{background:color-mix(in srgb,var(--color-danger) 10%,transparent);border:1px solid color-mix(in srgb,var(--color-danger) 20%,transparent);color:var(--text-primary)}._sha_o4nf0_67{margin-left:auto;font-family:monospace;font-size:var(--font-size-xs);color:var(--text-tertiary)}._settingItem_o4nf0_74{border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._settingTitle_o4nf0_79{font-weight:600;color:var(--text-primary);font-size:var(--font-size-sm)}._settingSubtitle_o4nf0_85{font-size:var(--font-size-sm);color:var(--text-secondary);margin-top:var(--space-1);line-height:1.5}._actionsRow_o4nf0_92{margin-top:var(--space-6);display:flex;gap:var(--space-3)}._status_1wbo0_1{margin-top:var(--space-4);font-size:var(--font-size-sm);color:var(--text-primary)}._warningText_1wbo0_7{margin:0 0 var(--space-4)!important}._ackLabel_1wbo0_11{display:flex;align-items:flex-start;gap:var(--space-2);font-size:var(--font-size-sm);color:var(--text-primary);cursor:pointer}._ackLabel_1wbo0_11 input{margin-top:2px}._settingItem_68mz3_1{border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._field_68mz3_6{display:flex;flex-direction:column;gap:.5rem;margin-bottom:var(--space-4)}._field_68mz3_6 label{font-size:.9rem;color:var(--text-secondary);font-weight:500}._input_68mz3_19{background:var(--bg-secondary);border:1px solid var(--border-primary);color:var(--text-primary);padding:.6rem;border-radius:4px;width:100%;max-width:400px}._input_68mz3_19:hover{border-color:var(--border-secondary)}._input_68mz3_19:focus{outline:none;border-color:var(--accent);box-shadow:var(--shadow-input-focus)}._actions_68mz3_39{display:flex;gap:var(--space-3);flex-wrap:wrap}._status_68mz3_45{margin-top:var(--space-4);padding:var(--space-3) var(--space-4);background:color-mix(in srgb,var(--accent) 10%,transparent);border-radius:var(--radius-md);color:var(--accent-light);font-size:var(--font-size-sm);font-weight:500}.alert{display:flex;align-items:flex-start;gap:var(--space-3);padding:var(--space-4);border-radius:var(--radius-md);font-size:var(--font-size-sm);border:1px solid transparent}.alert-info{background:color-mix(in srgb,var(--accent) 10%,transparent);border-color:var(--accent);color:var(--text-primary)}.alert-success{background:color-mix(in srgb,var(--color-success) 10%,transparent);border-color:var(--color-success);color:var(--color-success)}.alert-warning{background:color-mix(in srgb,var(--color-warning) 10%,transparent);border-color:var(--color-warning);color:var(--color-warning)}.alert-error{background:color-mix(in srgb,var(--color-danger) 10%,transparent);border-color:var(--color-danger);color:var(--color-danger)}