@serifpersia/dango 3.7.7 → 3.7.9

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-aZA4-g8o.js → AnimeCard-DWnU-rCc.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-CFGRb1OW.js → AnimeInfo-Ck-fMvdY.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-CozJH4AM.js → AnimeInfoPage-_iM5y3E4.js} +2 -2
  5. package/client/dist/assets/Asmr-CzqLNY2c.js +2 -0
  6. package/client/dist/assets/{AsmrResetProgressModal-NKywttOY.js → AsmrResetProgressModal-73jUOcAL.js} +1 -1
  7. package/client/dist/assets/Home--RCZI3_q.js +1 -0
  8. package/client/dist/assets/Insights-B5oANHfN.js +1 -0
  9. package/client/dist/assets/{LibraryListPage-CJxNJYC3.js → LibraryListPage-CV2FpbUe.js} +1 -1
  10. package/client/dist/assets/{ListeningList-VZTVSt_i.js → ListeningList-Bb7qLeQy.js} +1 -1
  11. package/client/dist/assets/Manga-RzxC02lH.js +1 -0
  12. package/client/dist/assets/{MangaInfoPage-DzaSKarW.js → MangaInfoPage-DLANpxOs.js} +1 -1
  13. package/client/dist/assets/MangaReadPage-DuMOiKID.js +1 -0
  14. package/client/dist/assets/{MangaResetProgressModal-DrqN7OF0.js → MangaResetProgressModal-Y2PuLQHz.js} +1 -1
  15. package/client/dist/assets/Mature-DfO3sop8.js +1 -0
  16. package/client/dist/assets/{MatureConsentModal-DLVOORqW.js → MatureConsentModal-DiWSp3Of.js} +1 -1
  17. package/client/dist/assets/{MediaCard-DJNRuWDJ.js → MediaCard-ChUKs5Sb.js} +1 -1
  18. package/client/dist/assets/OptionListMenu-Cwb6MHoZ.js +1 -0
  19. package/client/dist/assets/Player-JA7rXoBD.js +56 -0
  20. package/client/dist/assets/PlayerProvider--aaVRFly.js +1 -0
  21. package/client/dist/assets/PlayerSettings-CxlbcdU4.js +1 -0
  22. package/client/dist/assets/{QueueOptionsButton-ByAwxtJ-.js → QueueOptionsButton-C6ArqpM5.js} +1 -1
  23. package/client/dist/assets/{QueueRail-BLf4fWOA.js → QueueRail-Derl5yzz.js} +1 -1
  24. package/client/dist/assets/{ReadingList-Cm5omw5j.js → ReadingList-BYbV0CvS.js} +1 -1
  25. package/client/dist/assets/{ResetProgressModal-Dq-B23o_.js → ResetProgressModal-DtUE-wCy.js} +1 -1
  26. package/client/dist/assets/Search-CzTO0VVY.js +1 -0
  27. package/client/dist/assets/Settings-D37LNfis.css +1 -0
  28. package/client/dist/assets/Settings-DKGEpLWL.js +21 -0
  29. package/client/dist/assets/{SkeletonGrid-sA6_IQY1.js → SkeletonGrid-BO0am1za.js} +1 -1
  30. package/client/dist/assets/Trackers-uUzceJl6.js +2 -0
  31. package/client/dist/assets/Tv-CuM6Jhjn.js +4 -0
  32. package/client/dist/assets/TvInfo-4DOit0hL.js +1 -0
  33. package/client/dist/assets/TvPopup-DYYtMp7D.js +1 -0
  34. package/client/dist/assets/TvSearch-C-IYU0V4.js +1 -0
  35. package/client/dist/assets/{TvWatchlist-SjHmyo2P.js → TvWatchlist--kFfdVIF.js} +1 -1
  36. package/client/dist/assets/VirtualKeyboard-BYc_6hb4.js +1 -0
  37. package/client/dist/assets/WatchAlong-zZPGaH2D.js +1 -0
  38. package/client/dist/assets/WatchAlongPanel-DbJuLqxU.css +1 -0
  39. package/client/dist/assets/WatchAlongPanel-DxC7pX1I.js +1 -0
  40. package/client/dist/assets/{Watchlist-BnmsAcx0.js → Watchlist-CX9qGh-b.js} +1 -1
  41. package/client/dist/assets/index-DP9TtvZX.css +1 -0
  42. package/client/dist/assets/index-DbRDs7tF.js +178 -0
  43. package/client/dist/assets/{libraryInvalidation-2sAPXNhJ.js → libraryInvalidation-cJ1WjrJq.js} +1 -1
  44. package/client/dist/assets/playbackCompletion-CnxK6_Vz.js +1 -0
  45. package/client/dist/assets/{useAnimeInfoData-Ai39I_f0.js → useAnimeInfoData-YbePqj-M.js} +1 -1
  46. package/client/dist/assets/{useAsmr-XBCV7iDw.js → useAsmr-DO5DUI_t.js} +1 -1
  47. package/client/dist/assets/{useAsmrPopup-DViHcQnO.js → useAsmrPopup-S_XfgKDh.js} +1 -1
  48. package/client/dist/assets/{useMangaLibrary-DrPp5K_1.js → useMangaLibrary-B4ZJLZXD.js} +1 -1
  49. package/client/dist/assets/{useMangaPopup-VGTfdKEu.js → useMangaPopup-B4ntcNg0.js} +1 -1
  50. package/client/dist/assets/{useProviders-Bt-p5Jxv.js → useProviders-Bnw0sBAP.js} +1 -1
  51. package/client/dist/assets/useTv-gF7SJCl9.js +1 -0
  52. package/client/dist/assets/useTvLibrary-DTWM3iOC.js +1 -0
  53. package/client/dist/assets/useWatchAlongPlayer-Do0c9QsI.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-AxjnBdsh.js +0 -2
  62. package/client/dist/assets/Home-CkdWZK2L.js +0 -1
  63. package/client/dist/assets/Insights-DgnlUFjW.js +0 -1
  64. package/client/dist/assets/Manga-dDQAtejO.js +0 -1
  65. package/client/dist/assets/MangaReadPage-CT6THZho.js +0 -1
  66. package/client/dist/assets/Mature-BGitA9fy.js +0 -1
  67. package/client/dist/assets/OptionListMenu-CRaHF9k4.js +0 -1
  68. package/client/dist/assets/Player-CdSjfMoO.js +0 -56
  69. package/client/dist/assets/PlayerProvider-D02-hqdz.js +0 -1
  70. package/client/dist/assets/PlayerSettings-CXmAyRJh.js +0 -1
  71. package/client/dist/assets/Search-C8rfGyYH.js +0 -1
  72. package/client/dist/assets/Settings-DYjRBgpE.css +0 -1
  73. package/client/dist/assets/Settings-Do5F5e2c.js +0 -21
  74. package/client/dist/assets/Trackers-DeJr1sbR.js +0 -2
  75. package/client/dist/assets/Tv-BkApELpu.js +0 -4
  76. package/client/dist/assets/TvInfo-C5cVdHka.js +0 -1
  77. package/client/dist/assets/TvPopup-DyFUi32m.js +0 -1
  78. package/client/dist/assets/TvSearch-BBYYrww5.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-vb4WPdcb.js +0 -178
  82. package/client/dist/assets/playbackCompletion-IPHm9fp5.js +0 -1
  83. package/client/dist/assets/usePlaybackEnd-C5EyqR1L.js +0 -10
  84. package/client/dist/assets/useTv-BpVapcT5.js +0 -1
  85. package/client/dist/assets/useTvLibrary-BFRidauf.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-CXmAyRJh.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-icons-DrybRNxP.js","assets/OptionListMenu-CRaHF9k4.js","assets/usePlaybackEnd-C5EyqR1L.js","assets/index-vb4WPdcb.js","assets/vendor-query-BBT5_sHx.js","assets/index-5x1mF1nD.css","assets/PlayerProvider-D02-hqdz.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 W,P as jt,z as Ht,d as oe,A as C,q as U,y as Yt,T as Me,o as Xt,a as Jt,c as Zt,_ as er,S as ct}from"./vendor-core-DfaOB3Rn.js";import{P as tr,a as rr,b as nr,F as sr,s as or,c as ar}from"./PlayerProvider-D02-hqdz.js";import{u as Nt,b as Ct,a as bt}from"./vendor-query-BBT5_sHx.js";import{p as Et,s as ir,C as lr,P as cr,a as ur,b as Ie,c as Mt,f as Pt,d as dr,e as mr,g as fr,r as hr,u as pr,h as vr,i as gr,j as yr,k as br,l as Sr,m as Er,n as be,A as wr,o as kr,R as Tr,E as Cr,q as Mr,t as w,v as Rr,w as Nr,x as Pr}from"./usePlaybackEnd-C5EyqR1L.js";import{I as de}from"./vendor-icons-DrybRNxP.js";import{_ as At,S as Ye,i as Ar,q as se,t as ue,A as we,O as _r,P as Ve,M as mt,e as xr,m as Br,n as Lr,o as Dr,p as $r,d as Ir,u as Fr,B as ut,Q as Or,f as Wr}from"./index-vb4WPdcb.js";import{l as Ur,i as ft,s as Vr}from"./playbackCompletion-IPHm9fp5.js";import{M as Qr}from"./MatureConsentModal-DLVOORqW.js";import{u as Kr}from"./useIsMobile-Dvx1uJ82.js";import{s as Ee,Q as Gr}from"./QueueRail-BLf4fWOA.js";import{u as qr,Q as zr}from"./QueueOptionsButton-ByAwxtJ-.js";import{u as _t}from"./useProviders-Bt-p5Jxv.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",hn="_leftControls_cejny_239",pn="_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",_={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:hn,rightControls:pn,controlBtn:vn,theaterBtn:gn,nextEpisodeBtn:yn,active:bn,timeDisplay:Sn,skipControls:En},wn=({player:r,handlers:n,visible:i,skipIntervals:h,showNextEpisodeButton:a,onNextEpisode:o,isTheaterMode:s,onTheaterModeToggle:l,settingsBtnRef:u,timeDisplayRef:f})=>{const{state:k,refs:e,actions:d}=r,{showSettings:R}=k;return t("div",{className:`${_.controlsOverlay} ${i?"":_.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:_.bottomControls,"data-speed-boost-ignore":"true",onClick:p=>p.stopPropagation(),children:[t(tr,{classes:{container:_.progressBarContainer,scrubbing:_.scrubbing,timeBubble:_.timeBubble,bar:_.progressBar,buffered:_.bufferedBar,watched:_.watchedBar,thumb:_.thumb},timeLabelRef:f,children:[k.duration>0&&r.state.currentSkipInterval&&t("div",{className:`${_.skipSegment} ${_[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}% `}}),h.map(p=>{const T=p.start_time/k.duration*100,M=(p.end_time-p.start_time)/k.duration*100;return t("div",{className:`${_.skipSegment} ${_[p.skip_type]} `,style:{left:`${T}% `,width:`${M}% `},title:p.skip_type.toUpperCase()},p.skip_id)})]}),t("div",{className:_.bottomControlsRow,children:[t("div",{className:_.leftControls,children:[t(rr,{className:_.controlBtn}),t(nr,{buttonClassName:_.controlBtn,onExpandedChange:d.setShowVolumeSlider}),t("span",{className:_.timeDisplay,ref:f,children:[d.formatTime(0)," / ",d.formatTime(k.duration)]}),k.currentSkipInterval&&!k.isAutoSkipEnabled&&t("button",{className:_.controlBtn,onClick:()=>{e.videoRef.current&&k.currentSkipInterval&&(e.videoRef.current.currentTime=k.currentSkipInterval.end_time,d.setCurrentSkipInterval(null))},children:["Skip ",k.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),t("div",{className:_.rightControls,children:[t("div",{className:_.skipControls,children:a&&t("button",{className:_.nextEpisodeBtn,onClick:o,title:"Play next episode",children:"Next EP"})}),t("button",{className:`${_.controlBtn} ${n.isSubtitleActive?_.active:""}`,onClick:n.handleCCToggle,title:n.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:t(de,{name:"closed-captioning",size:22})}),t("button",{ref:u,className:`${_.controlBtn} ${R?_.active:""} `,onClick:()=>d.setShowSettings(!R),"aria-label":"Settings",children:t(de,{name:"cog"})}),t("button",{className:`${_.controlBtn} ${_.theaterBtn} ${s?_.active:""} `,onClick:p=>{p.stopPropagation(),l()},title:s?"Exit Theater Mode":"Theater Mode","aria-label":s?"Exit Theater Mode":"Theater Mode",children:t(de,{name:"tv"})}),t(sr,{className:_.controlBtn})]})]})]})})};function kn(r){const{state:n,refs:i,actions:h}=r,a=l=>{if(!i.videoRef.current)return;h.setActiveSubtitleTrack(l);try{if(l===null||l==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const f=n.availableSubtitles.find(k=>k.label===l||k.lang===l);f?localStorage.setItem("playerLastSubtitle",ir(f)):localStorage.setItem("playerLastSubtitle",l)}}catch{}let u=!1;Array.from(i.videoRef.current.textTracks).forEach(f=>{const e=l!==null&&l!=="off"&&(f.language===l||f.label===l)&&!u;f.mode=e?"showing":"hidden",e&&(u=!0)})},o=n.activeSubtitleTrack!==null&&n.activeSubtitleTrack!=="off";return{handleSubtitleSelection:a,isSubtitleActive:o,handleCCToggle:()=>{if(!i.videoRef.current)return;if(o){a("off");return}if(n.availableSubtitles.length===0)return;let l=null;try{l=localStorage.getItem("playerLastSubtitle")}catch{}const u=Et(n.availableSubtitles,{lastKey:l,enabled:!0});if(u<0)return;const f=n.availableSubtitles[u];a(f.label||f.lang)}}}const Tn=Ht(()=>At(()=>import("./PlayerSettings-CXmAyRJh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),Cn=({player:r,isAutoplayEnabled:n,onAutoplayChange:i,showNextEpisodeButton:h,onNextEpisode:a,videoSources:o,selectedSource:s,selectedLink:l,onSourceChange:u,loadingVideo:f,skipIntervals:k,animeTitle:e,episodeNumber:d,isTheaterMode:R,onTheaterModeToggle:p,anime4kEnabled:T,onAnime4kToggle:M,anime4kSupported:N,anime4kProfile:A,onAnime4kProfileChange:S,anime4kInitializing:y,anime4kError:P,videoDelayEnabled:m,onVideoDelayToggle:E,videoDelayMs:B,onVideoDelayChange:H,onCalibrateAvSync:O,fallbackChoice:K,onFallbackChoiceChange:G,ambientSettings:L,onAmbientChange:x,children:q,overlays:Q,isInteractingExtra:me=!1,className:c,hideChrome:b=!1})=>{const{state:v,actions:D}=r,{showSettings:Y}=v,{setShowSettings:I}=D,V=kn(r),J=dt.useRef(null),Se=dt.useRef(null),Ae=dt.useRef(null);W(()=>{const j=pe=>{J.current&&!J.current.contains(pe.target)&&Se.current&&!Se.current.contains(pe.target)&&Y&&I(!1)};return Y&&document.addEventListener("mousedown",j),()=>{document.removeEventListener("mousedown",j)}},[Y,I]);const Re=v.showControls||Y||v.isScrubbing,Z=t(ur,{visible:Re,title:e,episode:d?`Episode ${d}`:void 0,onBack:()=>window.history.back(),classes:{overlay:_.controlsOverlay,hidden:_.hidden,top:_.topControls,backBtn:_.backBtn,titleInfo:_.videoTitleInfo,title:_.animeTitle,episode:_.episodeNumber}}),z=!f&&!v.isBuffering&&v.duration>0?t(lr,{}):null,ke=t(wn,{player:r,handlers:V,visible:Re,skipIntervals:k,showNextEpisodeButton:h,onNextEpisode:a,isTheaterMode:R,onTheaterModeToggle:p,settingsBtnRef:Se,timeDisplayRef:Ae}),_e=t(jt,{fallback:null,children:t(Tn,{ref:J,isOpen:Y,onClose:()=>I(!1),videoSources:o,currentSource:s,currentLink:l,onSourceChange:u,subtitles:v.availableSubtitles,activeSubtitleTrack:v.activeSubtitleTrack,onSubtitleChange:V.handleSubtitleSelection,subtitleSettings:{fontSize:v.subtitleFontSize,position:v.subtitlePosition,bgOpacity:v.subtitleBgOpacity,bgColor:v.subtitleBgColor,textColor:v.subtitleTextColor,edge:v.subtitleEdge,bold:v.subtitleBold},onSubtitleSettingsChange:D.setSubtitleStyle,useNativeControls:v.useNativeControls,onNativeControlsToggle:D.setUseNativeControls,anime4kEnabled:T,onAnime4kToggle:M,anime4kSupported:N,anime4kProfile:A,onAnime4kProfileChange:S,anime4kInitializing:y,anime4kError:P,videoDelayEnabled:m,onVideoDelayToggle:E,videoDelayMs:B,onVideoDelayChange:H,onCalibrateAvSync:O,isAutoSkipEnabled:v.isAutoSkipEnabled,onAutoSkipChange:j=>{D.setIsAutoSkipEnabled(j);try{localStorage.setItem("autoSkipEnabled",j.toString())}catch{}},isAutoplayEnabled:n,onAutoplayChange:i,fallbackChoice:K,onFallbackChoiceChange:G,isTheaterMode:R,ambientSettings:L,onAmbientChange:x})}),ee=Y?t("div",{"data-speed-boost-ignore":"true",onClick:j=>j.stopPropagation(),children:_e}):null;return t(cr,{engine:r.engine,topBar:Z,centerControls:z,bottomBar:!f&&v.duration>0?ke:null,settingsPanel:ee,overlays:Q,isInteracting:me||v.showSettings||v.showVolumeSlider,nativeControls:v.useNativeControls,className:c,chromeDisabled:b,children:q})},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(de,{name:"chevron-down",style:{opacity:.3}})]})}),t("div",{className:Ee.list,children:Array.from({length:r}).map((n,i)=>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)"}})]})]},i))})]}),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:i,options:h})=>{const o=(h&&h.length>0?h:[]).filter(s=>s.mature===(i===!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 l=o.filter(u=>(u.tier??"direct")===s);return l.length===0?null:t("optgroup",{label:Nn[s],children:l.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:i,onSourceChange:h,onLinkChange:a})=>{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((l,u)=>t("button",{className:`${Ie.sourceButton} ${n?.sourceName===l.sourceName?Ie.active:""} `,onClick:()=>h(l),children:l.sourceName},`${l.sourceName}-${u}`))}),s&&t("select",{className:Ie.sourceSelect,"aria-label":"Fallback embed quality",value:i?.link??n.links[0]?.link??"",onChange:l=>{const u=n.links.find(f=>f.link===l.currentTarget.value);u&&a(u)},children:n.links.map(l=>t("option",{value:l.link,children:l.resolutionStr},l.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:i="balanced",delayMs:h=0}){const[a,o]=oe(!1),[s,l]=oe(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[u,f]=oe(!1),[k,e]=oe(null),[d,R]=oe(0),p=C(0),T=C(null),M=C(null),N=C(null),A=C(null),S=C(null),y=C(null),P=C(null),m=C(null),E=C(null),B=C(!1),H=C(-1),O=C(0),K=C(h);K.current=h;const G=C([]),L=C(!1),x=C(!1),q=C(!1),Q=C(null),me=C(-1),c=C(-1),b=C(!1),v=C(0);W(()=>{async function I(){if(typeof navigator>"u"||!navigator.gpu){o(!1);return}try{const V=await navigator.gpu.requestAdapter();o(!!V)}catch{o(!1)}}I()},[]),W(()=>{if(!s||!a)return;let I=!1;const V=++p.current,J=z=>{if(z)try{z.close()}catch{}},Se=()=>{for(const z of G.current)J(z.bitmap);G.current=[]},Ae=z=>Math.max(8,Math.min(40,Math.ceil(z/16.7)+4));function Re(){E.current!==null&&(cancelAnimationFrame(E.current),E.current=null)}async function Z(){let z=r.current;const ke=n.current;if(!z||!ke||p.current!==V)return;const _e=performance.now()+$n;for(;(!z||z.videoWidth===0)&&performance.now()<_e;){if(await new Promise(ie=>requestAnimationFrame(ie)),I||p.current!==V)return;z=r.current}if(!z||z.videoWidth===0){!I&&p.current===V&&(e("Timed out waiting for video metadata"),f(!1),l(!1));return}const ee=z.videoWidth,j=z.videoHeight,pe=Math.max(ee,j),ht=window.innerWidth,xe=window.innerHeight,Je=Math.max(ht,xe),Ze=pe<Je?Je/pe:1,Qe=Bn[i],pt=pe<=480?Qe.sd:pe<=720?Qe.hd:pe<=1080?Qe.fhd:1,ae=Math.min(pt,Ze);ke.width=Math.round(ee*ae),ke.height=Math.round(j*ae),f(!0),e(null),O.current=0,H.current=-1,me.current=-1,c.current=-1,b.current=!1,v.current=0,Se(),B.current=!1;try{let ie=function(){I||p.current!==V||(Re(),E.current=requestAnimationFrame(()=>{at()}))};const{ModeA:vt,ModeB:Te,ModeC:et,ModeAA:Ke}=await At(async()=>{const{ModeA:F,ModeB:te,ModeC:fe,ModeAA:le}=await import("./index-BOKlZEHq.js").then(ce=>ce.i);return{ModeA:F,ModeB:te,ModeC:fe,ModeAA:le}},[]);if(I||p.current!==V)return;if(!navigator.gpu)throw new Error("WebGPU not available");const tt=await navigator.gpu.requestAdapter();if(I||p.current!==V)return;if(!tt)throw new Error("No GPU adapter found");const $=await tt.requestDevice();if(!$)throw new Error("Failed to get GPU device");if(I||p.current!==V){$.destroy();return}T.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:[ee,j],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),rt=Ln[i],Fe=Math.round(ee*ae),Oe=Math.round(j*ae),qe=(()=>{switch(rt){case"ModeB":return new Te({device:$,inputTexture:ve,nativeDimensions:{width:ee,height:j},targetDimensions:{width:Fe,height:Oe}});case"ModeC":return new et({device:$,inputTexture:ve,nativeDimensions:{width:ee,height:j},targetDimensions:{width:Fe,height:Oe}});case"ModeAA":return new Ke({device:$,inputTexture:ve,nativeDimensions:{width:ee,height:j},targetDimensions:{width:Fe,height:Oe}});default:return new vt({device:$,inputTexture:ve,nativeDimensions:{width:ee,height:j},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 F=$.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),te=$.createShaderModule({code:In}),fe=$.createRenderPipeline({layout:$.createPipelineLayout({bindGroupLayouts:[F]}),vertex:{module:te,entryPoint:"vs"},fragment:{module:te,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});Q.current={pipeline:fe,layout:F,inputView:ve.createView()}}catch{Q.current=null}N.current=qe,A.current=ve,S.current=Be,y.current=De,P.current=ze,m.current=Le,x.current=!1,q.current=!1;async function ot(){const F=Q.current;if(!F||x.current)return!1;const te=r.current;if(!te)return!1;const fe=!q.current;fe&&$.pushErrorScope("validation");try{const le=$.importExternalTexture({source:te}),ce=$.createBindGroup({layout:F.layout,entries:[{binding:0,resource:le},{binding:1,resource:ze}]}),he=$.createCommandEncoder(),ge=he.beginRenderPass({colorAttachments:[{view:F.inputView,loadOp:"load",storeOp:"store"}]});ge.setPipeline(F.pipeline),ge.setBindGroup(0,ce),ge.draw(6),ge.end(),$.queue.submit([he.finish()])}catch{return x.current=!0,Q.current=null,!1}if(fe){const le=await $.popErrorScope().catch(()=>null);if(le)return console.warn("[anime4k] blit probe failed:",le.message),x.current=!0,Q.current=null,!1;q.current=!0}return!0}f(!1);async function at(){if(I||p.current!==V||!Ne)return;const F=r.current;if(!F||F.videoWidth===0){ie();return}if(F!==z||F.videoWidth!==ee||F.videoHeight!==j){R(ce=>ce+1);return}if(F.paused||F.ended||document.hidden||F.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){ie();return}const te=F.getVideoPlaybackQuality().totalVideoFrames;if(te===c.current){ie();return}if(B.current){ie();return}const fe=F.currentTime;(F.seeking||me.current>=0&&Math.abs(fe-me.current)>.5)&&(Se(),b.current=!1,v.current=0,c.current=-1),me.current=fe;const le=Math.max(0,K.current||0);le>v.current&&(b.current=!1),B.current=!0;try{const ce=performance.now();let he=null,ge=!1;if(le<=0){G.current.length>0&&Se(),b.current=!1,v.current=0;let ye=!1;if(!L.current)try{$.queue.copyExternalImageToTexture({source:F},{texture:ve},[ee,j]),c.current=te,ye=!0}catch(re){if(re instanceof TypeError)L.current=!0;else throw re}if(!ye&&!x.current&&Q.current&&await ot()&&(c.current=te,ye=!0),!ye){const re=await createImageBitmap(F);c.current=te,$.queue.copyExternalImageToTexture({source:re},{texture:ve},[ee,j]),J(re)}}else{const ye=await createImageBitmap(F);c.current=te;const re=G.current;re.push({bitmap:ye,capture:ce});const it=Ae(le);for(;re.length>it;)J(re.shift()?.bitmap);let Ue=-1;for(let ne=re.length-1;ne>=0;ne--)if(ce-re[ne].capture>=le){Ue=ne;break}if(Ue!==-1){for(let He=0;He<Ue;He++)J(re.shift()?.bitmap);const ne=re.shift();ne?(he=ne.bitmap,b.current=!0,v.current=le):(he=ye,ge=!0)}else if(!b.current)he=ye,ge=!0;else{const ne=re.shift();he=ne?ne.bitmap:ye,ne||(ge=!0)}if(!he){B.current=!1,ie();return}$.queue.copyExternalImageToTexture({source:he},{texture:ve},[ee,j]),ge||J(he)}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()]),H.current=te,O.current=0,$.queue.onSubmittedWorkDone().then(()=>{p.current===V&&(B.current=!1)})}catch(ce){if(B.current=!1,O.current+=1,O.current>=Dn&&!I&&p.current===V){console.error(ce),e(ce instanceof Error?ce.message:"Render error"),l(!1);return}}ie()}ie()}catch(ie){!I&&p.current===V&&(M.current?.unconfigure(),T.current?.destroy(),T.current=null,M.current=null,e(ie instanceof Error?ie.message:"Failed to initialize upscaler"),f(!1),l(!1))}}return Z(),()=>{I=!0,p.current+=1,Re(),Se(),M.current?.unconfigure(),A.current&&(A.current.destroy(),A.current=null),S.current&&(S.current.destroy(),S.current=null),T.current&&(T.current.destroy(),T.current=null),N.current=null,y.current=null,P.current=null,m.current=null,Q.current=null,M.current=null,B.current=!1}},[s,a,r,n,i,d]);const D=U(I=>{l(I);try{localStorage.setItem("anime4kEnabled",String(I))}catch{}},[]),Y=U(()=>{l(I=>{const V=!I;try{localStorage.setItem("anime4kEnabled",String(V))}catch{}return V})},[]);return{isWebGPUSupported:a,isEnabled:s,isInitializing:u,error:k,toggle:Y,setEnabled:D}}function On({videoRef:r,episodeKey:n,isEnabled:i,isSupported:h,mediaReady:a,isIframeSource:o,setEnabled:s}){const l=C(null),u=C(!1),f=C(!1),k=C(s);k.current=s,W(()=>{const e=l.current;l.current=n,!(e===null||e===n)&&(!i||!h||(u.current=!0,f.current=!1,k.current(!1)))},[n,i,h]),W(()=>{if(!u.current)return;if(i){f.current&&(u.current=!1);return}if(f.current=!0,!a)return;if(o){u.current=!1,k.current(!0);return}const e=r.current;if(!e)return;let d,R=!1;const p=()=>{R||(R=!0,u.current=!1,k.current(!0))};if(e.readyState>=2)return d=window.setTimeout(p,500),()=>window.clearTimeout(d);const T=()=>{window.setTimeout(p,500)};return e.addEventListener("canplay",T,{once:!0}),e.addEventListener("playing",T,{once:!0}),d=window.setTimeout(p,5e3),()=>{window.clearTimeout(d),e.removeEventListener("canplay",T),e.removeEventListener("playing",T)}},[i,a,o,r])}const Wn=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Un=/^[a-z0-9-]+$/i,xt=r=>r?"preferredProviderMature":"preferredProvider",Bt=r=>{const n=localStorage.getItem(xt(r));return n&&Un.test(n)?n:null},Lt=(r,n)=>{localStorage.setItem(xt(n),r)},Vn=()=>Bt(!1)??"megaplay",Qn=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:Wn(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:Ur(),showResumeModal:!0,resumeProgressPending:!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 Rt(r,n,i,h,a=!1){if(!r||!n)throw new Error("Missing params");try{const[o,s,l,u]=await Promise.all([ue.data.video.query({showId:r,episodeNumber:n,mode:i.currentMode,provider:i.selectedProvider}).catch(S=>{const y=S.data?.cause;return S.message==="AUTH_REQUIRED"&&y?.provider==="mkissa"&&h({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:"mkissa"}}),null}),ue.progress.getEpisode.query({showId:r,episodeNumber:n}).catch(()=>null),ue.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),ue.data.skipTimes.query({showId:r,episodeNumber:n}).catch(()=>[])]),f=l?.value,k=o?.filter(S=>{const y=S.sourceName.toLowerCase();return i.currentMode==="dub"?y.includes("eng")||y.includes("dub"):y.includes("jpn")||y.includes("sub")||!y.includes("eng")&&!y.includes("dub")})??[],e=k.length>0?k:o??[];let d=e.length>0?e[0]:null;if(f){const S=e.find(y=>y.sourceName===f);S&&(d=S)}const R=d&&d.links.length>0?d.links.sort((S,y)=>(parseInt(y.resolutionStr)||0)-(parseInt(S.resolutionStr)||0))[0]:null,p=s?.currentTime||0,T=s?.duration||0,M=p,A=(Array.isArray(u)?u:u?.results||[]).map(S=>({skip_id:S.skip_id||"",skip_type:S.skip_type||"",start_time:S.interval?.start_time??S.start_time??0,end_time:S.interval?.end_time??S.end_time??0})).filter(S=>S.end_time>0);return(!o||o.length===0)&&(a||we.error(`No video sources found for ${i.selectedProvider}`)),{videoSources:o,selectedSource:d,selectedLink:R,resumeTime:M,resumeDuration:T,showResumeModal:M>5&&!ft(M,T)&&d?.type!=="iframe",skipIntervals:A,fetchedEpisodeNumber:n}}catch(o){const s=o;if(s.message==="AUTH_REQUIRED")return h({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,i,h)=>{const[a,o]=Yt(Kn,i,c=>({...Qn(),showMeta:c?.name?{name:c.name,thumbnail:c.thumbnail,nativeName:c.nativeName,englishName:c.englishName,names:{romaji:c.name||c.englishName,english:c.englishName||c.name,native:c.nativeName}}:{}})),s=Nt(),l=Ar(),u=C(null),f=C(null),{options:k}=_t(),e=Me(()=>k.filter(c=>(c.kind??"anime")==="anime"),[k]),d=n||a.initialEpisode,R=C(d);W(()=>{R.current!==d&&(R.current=d,o({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[d,o]),W(()=>{r&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)&&a.selectedProvider!=="animepahe"&&u.current!==r&&(u.current=r,o({type:"SET_PROVIDER",payload:"animepahe"}))},[r,a.selectedProvider]);const{data:p,isLoading:T,error:M}=qr(r),{data:N}=Ct({queryKey:[se.playerData,r,a.currentMode,a.selectedProvider],queryFn:async()=>{if(!r)throw new Error("No showId");const c=async()=>{try{const I=await ue.data.episodes.query({showId:r,mode:a.currentMode,provider:a.selectedProvider}).catch(()=>null);if(I?.episodes?.length)return I}catch{}return null},[b,v,D]=await Promise.all([c(),ue.watchlist.check.query({showId:r}).catch(()=>({inWatchlist:!1,status:null})),ue.progress.getWatchedEpisodes.query({showId:r}).catch(()=>[])]),Y=b?.episodes?b.episodes.sort((I,V)=>parseFloat(I)-parseFloat(V)):[];return{description:b?.description||"",episodes:Y,inWatchlist:v.inWatchlist,watchlistStatus:v.status??null,watchedEpisodes:D}},enabled:!!r});W(()=>{!n&&N?.episodes&&N.episodes.length>0&&!n&&o({type:"SET_STATE",payload:{initialEpisode:N.episodes[0]}})},[N,n]),W(()=>{if(p?.isAdult===void 0||f.current===r)return;const c=p.isAdult===!0,b=e.filter(D=>D.mature===c);if(b.length===0||e.find(D=>D.id===a.selectedProvider)?.mature===c)return;const v=Bt(c);f.current=r??null,o({type:"SET_PROVIDER",payload:b.find(D=>D.id===v)?.id??b[0].id})},[p?.isAdult,a.selectedProvider,r,e]),W(()=>{if(!r||!/^dango-mt-\d+$/.test(r)||f.current===`temp:${r}`)return;const c=p?.provider;c&&(f.current=`temp:${r}`,c!==a.selectedProvider&&o({type:"SET_PROVIDER",payload:c}))},[r,p,a.selectedProvider]);const{data:A,isLoading:S,isFetching:y,error:P}=Ct({queryKey:[se.videoSources,r,d,a.selectedProvider,a.currentMode],queryFn:()=>Rt(r,d,a,o),enabled:!!r&&!!d&&!(a.showMeta?.isAdult===!0&&!h?.hasMatureConsent)}),{mutateAsync:m}=bt({mutationFn:async({wasIn:c,showMeta:b})=>{if(!r)throw new Error("Missing showId");if(c)await ue.watchlist.remove.mutate({id:r});else{const v=b.name||b.names?.romaji;if(!v)throw new Error("Missing show name");await ue.watchlist.add.mutate({id:r,name:v,thumbnail:b.thumbnail,nativeName:b.names?.native,englishName:b.names?.english,type:b.type,isAdult:b.isAdult})}return!c},onSuccess:c=>{we.success(c?"Added to watchlist":"Removed from watchlist"),s.invalidateQueries({queryKey:[se.playerData,r]}),s.invalidateQueries({queryKey:[se.showData,r]}),s.invalidateQueries({queryKey:[se.watchlist]})},onError:c=>we.error(c instanceof Error?c.message:"Failed to update watchlist")}),E=U(async()=>{!r||!p||await m({wasIn:!!N?.inWatchlist,showMeta:p})},[r,p,N?.inWatchlist,m]),B=U(async c=>{try{await ue.settings.set.mutate({key:"preferredSource",value:c})}catch(b){console.error(b)}},[]),{mutateAsync:H,isPending:O}=bt({mutationFn:async({status:c})=>{if(!r)throw new Error("Missing showId");if(N?.inWatchlist)return await ue.watchlist.setStatus.mutate({id:r,status:c}),c;const b=p,v=b?.name||b?.names?.romaji;if(!b||!v)throw new Error("Missing show name");return await ue.watchlist.add.mutate({id:r,name:v,thumbnail:b.thumbnail,nativeName:b.names?.native,englishName:b.names?.english,type:b.type,isAdult:b.isAdult,status:c}),c},onSuccess:c=>{o({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:c}}),we.success(`Moved to ${c}`),s.invalidateQueries({queryKey:[se.showData,r]}),s.invalidateQueries({queryKey:[se.watchlist]}),s.invalidateQueries({queryKey:[se.continueWatching]})},onError:()=>we.error("Failed to update watchlist status")}),K=U(async()=>{await H({status:"Completed"})},[H]),{mutateAsync:G,isPending:L}=bt({mutationFn:async({episodeNumber:c,duration:b,showMeta:v,episodes:D})=>{await ue.progress.updateProgress.mutate({showId:r??"",episodeNumber:c,currentTime:b,duration:b,showName:v.name,showThumbnail:v.thumbnail,nativeName:v.names?.native,englishName:v.names?.english,genres:v.genres?.map(Y=>Y.name),popularityScore:_r(v.score)??void 0,type:v.type,status:v.status,episodeCount:D.length,isAdult:v.isAdult})},onSuccess:(c,b)=>{we.success(`Episode ${b.episodeNumber} marked as watched`),s.invalidateQueries({queryKey:[se.playerData,r]}),s.invalidateQueries({queryKey:[se.showMeta,r]}),s.invalidateQueries({queryKey:[se.videoSources,r,b.episodeNumber]}),s.invalidateQueries({queryKey:[se.continueWatching]}),s.invalidateQueries({queryKey:[se.thisWeekSchedule]}),s.invalidateQueries(l.continueWatching.pathFilter())},onError:()=>we.error("Failed to mark episode as watched")}),x=U(async(c,b)=>{!r||!p||await G({episodeNumber:c,duration:b,showMeta:p,episodes:N?.episodes||[]})},[r,p,N?.episodes,G]),q=U(async()=>{o({type:"SET_STATE",payload:{showCombinedDetails:!a.showCombinedDetails}})},[a.showCombinedDetails]),Q=Me(()=>{const c=M||P,b=c?c.message:null,v=b==="AUTH_REQUIRED"?null:b,D=A&&A.fetchedEpisodeNumber===d?A:null,Y=!!A&&!D;return{...a,currentEpisode:d,showMeta:{...a.showMeta||{},...p||{}},episodes:N?.episodes||[],watchedEpisodes:N?.watchedEpisodes||[],inWatchlist:!!N?.inWatchlist,watchlistStatus:N?.watchlistStatus??a.watchlistStatus??null,videoSources:D?.videoSources||[],selectedSource:a.selectedSource||D?.selectedSource||null,selectedLink:a.selectedLink||D?.selectedLink||null,resumeTime:D?.resumeTime||0,resumeDuration:D?.resumeDuration||0,resumeProgressPending:y,showResumeModal:a.showResumeModal&&(D?.showResumeModal??!1),skipIntervals:D?.skipIntervals||[],loadingShowData:T,loadingVideo:S||Y,error:v,fetchedEpisodeNumber:D?.fetchedEpisodeNumber}},[a,p,N,A,T,S,y,M,P,d]),me=U((c,b)=>{const v=b||r;if(!v||!c||v===r&&c===d)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(v)&&a.selectedProvider!=="animepahe"?"animepahe":a.selectedProvider,I=["video-sources",v,c,Y,a.currentMode];s.getQueryState(I)?.status!=="success"&&s.prefetchQuery({queryKey:I,queryFn:()=>Rt(v,c,{selectedProvider:Y,currentMode:a.currentMode},o,!0),staleTime:300*1e3,gcTime:1800*1e3})},[r,d,s,a,o]);return{state:Q,dispatch:o,toggleWatchlist:E,moveToCompleted:K,setPreferredSource:B,handleToggleDetails:q,markEpisodeWatched:x,prefetchEpisodeSources:me,isMarkingWatched:L,isUpdatingWatchlistStatus:O}};function qn({onNext:r,onToggleTheater:n,flashControls:i}){W(()=>{const h=a=>{a.defaultPrevented||a.ctrlKey||a.metaKey||a.altKey||a.repeat||a.target.closest('input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(a.key.toLowerCase())&&i(),a.key.toLowerCase()==="n"&&r(),a.key.toLowerCase()==="t"&&n())};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[i,r,n])}const Xe=(r,n,i)=>r.showId===n||!!i&&r.showId===i;function zn({testClipActive:r,selectedSourceType:n,onEnded:i,queue:h,removeFromQueue:a,showId:o,showMetaId:s,currentEpisode:l,isAutoplayEnabled:u,nextEpisode:f,previousEpisode:k,navigate:e,invalidateContinueWatching:d,dispatch:R}){const[p,T]=oe(!1),[M,N]=oe(null),[A,S]=oe(null),y=C(a);y.current=a;const P=C(!1);W(()=>{P.current=!1,T(!1)},[o,l]);const m=U(()=>{if(r||P.current)return;P.current=!0,i();const L=h.find(x=>Xe(x,o,s)&&x.episodeNumber===l);if(h.length>0){const x=h.findIndex(Q=>Xe(Q,o,s)&&Q.episodeNumber===l),q=x>=0?h[x+1]||null:h[0];S({nextItem:q,playedItem:L||null}),N(2);return}if(L&&y.current({showId:L.showId,episodeNumber:L.episodeNumber}),u&&f){d(),e(`/watch/${o}/${f}`);return}f||T(!0)},[i,e,h,o,s,l,f,u,d,r]),E=U(()=>{if(h.length===0)return;i();const L=h.find(Q=>Xe(Q,o,s)&&Q.episodeNumber===l),x=h.findIndex(Q=>Xe(Q,o,s)&&Q.episodeNumber===l),q=x>=0?h[x+1]||null:h[0];L&&a({showId:L.showId,episodeNumber:L.episodeNumber}),q?e(`/watch/${q.showId}/${q.episodeNumber}`):f||T(!0)},[i,e,h,a,o,s,l,f]),B=U(()=>{f&&(d(),e(`/watch/${o}/${f}`)),T(!1),R({type:"SET_STATE",payload:{showResumeModal:!1}})},[f,e,o,R,d]),H=U(()=>{h.length>0?E():f?B():we.error("No next episode available")},[h.length,E,B,f]),O=U(()=>T(!1),[]),K=U(()=>{S(null),N(null)},[]),G=U(()=>{k&&e(`/watch/${o}/${k}`)},[k,e,o]);return W(()=>{const L=x=>{x.origin===window.location.origin&&n==="iframe"&&x.data?.type==="ANI_WEB_MEDIA_ENDED"&&m()};return window.addEventListener("message",L),()=>window.removeEventListener("message",L)},[m,n]),W(()=>{if(!A||M===null)return;if(M<=0){const{nextItem:x,playedItem:q}=A;S(null),N(null),q&&y.current({showId:q.showId,episodeNumber:q.episodeNumber}),x?e(`/watch/${x.showId}/${x.episodeNumber}`):f||T(!0);return}const L=window.setTimeout(()=>{N(x=>x===null?null:x-1)},1e3);return()=>window.clearTimeout(L)},[A,M,e,f]),{showCompleteModal:p,queueCountdown:M,pendingQueueTransition:A,handleQueueTransition:E,handleNextEpisode:B,handleNShortcut:H,handlePreviousEpisode:G,handlePlaybackFinished:m,closeCompleteModal:O,cancelQueueTransition:K}}function jn({videoRef:r,queue:n,showId:i,showMetaId:h,currentEpisode:a,selectedSource:o,hasNextEpisode:s,nextEpisode:l,prefetchEpisodeSources:u,matchesQueueItem:f}){const[k,e]=oe(!1),d=C(u);d.current=u;const R=C("");W(()=>{e(!1)},[a]);const p=U(()=>{const T=r.current;if(!T||o?.type==="iframe")return;const M=T.duration,N=T.currentTime;if(!M||Number.isNaN(M)){e(!1);return}if(M-N<=60){const A=n.findIndex(P=>f(P,i,h)&&P.episodeNumber===a),S=n.length>0?A>=0?n[A+1]||null:n[0]:null,y=S?`${S.showId}:${S.episodeNumber}`:s?`${i}:${l}`:"";y&&R.current!==y&&(R.current=y,S?d.current(S.episodeNumber,S.showId):d.current(l??""))}e(s&&ft(N,M))},[r,o,n,i,h,a,s,l,f]);return{showNextEpisodePrompt:k,handleThresholds:p}}const St="fallbackChoice";function Hn(){try{const r=localStorage.getItem(St);return r==="iframe"||r==="retry"?r:null}catch{return null}}function Yn(r){try{r===null?localStorage.removeItem(St):localStorage.setItem(St,r)}catch{}}function Xn({showId:r,episodeNumber:n,currentMode:i,selectedProvider:h,selectedSourceType:a,videoSources:o,isAdult:s,providerOrder:l,matureProviders:u,setPreferredSource:f,dispatch:k,showControls:e}){const d=C(!1),R=C([]),p=C(!1),[T,M]=oe(null),[N,A]=oe(!1),[S,y]=oe(!1),[P,m]=oe(()=>Hn()??"ask"),E=U(c=>{m(c),Yn(c==="ask"?null:c)},[]),B=C(P);W(()=>{B.current=P},[P]);const H=C(o);H.current=o;const O=U(()=>{d.current=!1,R.current=[],p.current=!1,M(null),A(!1)},[]);W(()=>{O()},[O,r,n]);const K=U(c=>{if(d.current)return;d.current=!0;const b=c.links[0];f(c.sourceName),k({type:"SET_STATE",payload:{selectedSource:c,selectedLink:b}}),M(null)},[k,f]),G=U(()=>{const b=H.current.find(v=>v.type==="iframe");return b?.links?.length?b:null},[]),L=U(async()=>{const c=l.filter(b=>{if(R.current.includes(b))return!1;const v=u.has(b);return s===void 0?!0:v===s});A(!0);try{for(const b of c){R.current.push(b);let v=null;try{v=await ue.data.video.query({showId:r,episodeNumber:n,mode:i,provider:b})}catch{continue}const D=(v??[]).filter(V=>{const J=V.sourceName.toLowerCase();return i==="dub"?J.includes("eng")||J.includes("dub"):J.includes("jpn")||J.includes("sub")||!J.includes("eng")&&!J.includes("dub")});if((D.length>0?D:v??[]).find(V=>V.type!=="iframe"&&V.links?.length)){R.current=[h],p.current=!1,k({type:"SET_STATE",payload:{selectedProvider:b,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Lt(b,s===!0),M(null),we.success(`Switched to ${b} (direct stream)`);return}}M({retryFailed:!0}),we.error("No working direct stream found on other providers")}finally{A(!1)}},[r,n,i,s,h,k,l,u]),x=U(()=>{if(d.current||p.current||a!=="player")return;const c=G();if(!c)return;R.current.includes(h)||R.current.push(h);const b=B.current;if(b==="iframe"){K(c);return}if(b==="retry"){L();return}e(!0),M({retryFailed:!1})},[a,h,G,K,L,e]),q=U(()=>{p.current=!0,M(null),y(!1)},[]),Q=U(()=>{S&&E("iframe");const c=G();c?K(c):M(null)},[S,E,G,K]),me=U(()=>{S&&E("retry"),L()},[S,E,L]);return{fallbackPrompt:T,isRetryingProvider:N,rememberFallbackChoice:S,setRememberFallbackChoice:y,fallbackChoice:P,updateFallbackChoice:E,dismissFallbackPrompt:q,chooseIframeFallback:Q,chooseProviderRetry:me,handleVideoSourceError:x,resetFallback:O}}function Jn({engine:r,videoRef:n,selectedSource:i,selectedLink:h,loadingVideo:a,testClipActive:o,resumeTime:s,resumeDuration:l=0,showResumeModal:u,calibReturnRef:f,setAvailableSubtitles:k,setActiveSubtitleTrack:e,onFatalError:d}){const R=C(null),p=C(s),T=C(l),M=C(u),N=C(d);return N.current=d,W(()=>{p.current=s,T.current=l,M.current=u},[s,l,u]),W(()=>{const A=n.current;if(!A)return;for(;A.firstChild;)A.removeChild(A.firstChild);if(o)return r.loadSource({url:"/av-sync-test.mp4"},{autoPlay:!0});if(a||!i||!h||i.type==="iframe"){r.unload();return}f.current!=null?(R.current=f.current,f.current=null):R.current===null&&p.current>5&&!M.current&&!ft(p.current,T.current)?R.current=p.current:R.current===null&&M.current&&(R.current=0);let S=h.link;if(S.startsWith("/api/proxy")||(S=`/api/proxy?url=${encodeURIComponent(S)}`,h.headers?.Referer&&(S+=`&referer=${encodeURIComponent(h.headers.Referer)}`)),i.subtitles){const m=localStorage.getItem("playerSubtitlesEnabled")!=="false";let E=null;try{E=localStorage.getItem("playerLastSubtitle")}catch{}const B=Et(i.subtitles,{lastKey:E,enabled:m}),H=B>=0?i.subtitles[B]:null;i.subtitles.forEach(O=>{const K=document.createElement("track");K.kind="subtitles",K.label=O.label,K.srclang=O.lang;const G=O.src??O.url;if(G){let L=`/api/subtitle-proxy?url=${encodeURIComponent(G)}`;const x=h.headers?.Referer;x&&(L+=`&referer=${encodeURIComponent(x)}`),K.src=L}H&&O.label===H.label&&O.lang===H.lang&&(K.default=!0),A.appendChild(K)}),m||e("off"),k(i.subtitles)}const y=R.current??0;R.current=null;const P=document.body.classList.contains("low-end");return r.loadSource({url:S,hls:h.hls},{initialTime:y,autoPlay:!(M.current&&p.current>5)&&!ft(p.current,T.current),hlsConfig:{maxBufferLength:P?15:30,maxMaxBufferLength:P?30:60,maxBufferSize:(P?25:60)*1e3*1e3,startLevel:-1},onHls:(m,E)=>{if(!i.subtitles?.length)return;const B=()=>{m.subtitleTrack!==-1&&(m.subtitleTrack=-1)};m.on(E.Events.SUBTITLE_TRACK_SWITCH,B),B()},onError:()=>N.current()})},[r,i,h,n,f,a,o,e,k]),{seekToTimeRef:R}}function Zn({videoRef:r,availableSubtitles:n,activeSubtitleTrack:i,setAvailableSubtitles:h,setActiveSubtitleTrack:a}){W(()=>{const o=r.current;if(!o)return;const s=()=>{const l=Array.from(o.textTracks).map(u=>({label:u.label,lang:u.language,src:void 0,mode:u.mode}));h(l)};return o.textTracks.addEventListener("addtrack",s),o.textTracks.addEventListener("removetrack",s),s(),()=>{o.textTracks.removeEventListener("addtrack",s),o.textTracks.removeEventListener("removetrack",s)}},[r,h]),W(()=>{if(i===null&&n.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let o=null;try{o=localStorage.getItem("playerLastSubtitle")}catch{}const s=Et(n,{lastKey:o,enabled:!0});if(s<0){a("off");return}const l=n[s];a(l.lang||l.label)}},[i,n,a]),W(()=>{const o=r.current;if(!o||n.length===0)return;const s=i;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")}},[i,n,r])}function es({videoRef:r,videoBoxH:n,style:i,sourceKey:h,activeSubtitleTrack:a,availableSubtitles:o}){W(()=>{const s="dynamic-subtitle-styles";let l=document.getElementById(s);l||(l=document.createElement("style"),l.id=s,document.head.appendChild(l)),l.textContent=Mt(i);const u=r.current;if(!u)return;const f=Pt(i.fontSize,n||u.clientHeight||720);l.textContent=Mt({...i,fontSize:f});const k=()=>{const y=Number(i.position),P=isNaN(y)?0:Math.max(0,Math.min(100,y));return Math.max(0,Math.min(100,100-P))},e=(y,P)=>{try{const m=y;m.snapToLines=!1,m.line=P}catch{}},d=()=>{const y=f*16,P=u.videoHeight||u.clientHeight||720,m=u.videoWidth||u.clientWidth||1280;return{step:y*1.3/P*100,chars:Math.max(20,Math.floor(m/(y*.55)))}},R=y=>{const P=k(),m=Array.from(y.activeCues??[]);if(m.length<=1){m.forEach(O=>e(O,P));return}const{step:E,chars:B}=d();let H=P;for(let O=m.length-1;O>=0;O--){const G=String(m[O].text??"").replace(/<[^>]*>/g,"").split(`
55
- `).reduce((x,q)=>x+Math.max(1,Math.ceil(q.length/B)),0),L=H-G*E;e(m[O],Math.max(0,L)),H=L-E*.4}},p=y=>{if(!y.cues)return;const P=k();Array.from(y.cues).forEach(m=>e(m,P)),y.mode==="showing"&&R(y)},T=()=>{Array.from(u.textTracks).forEach(p)};T();const M=y=>{const P=y.target;P.mode==="showing"&&R(P)};Array.from(u.textTracks).forEach(y=>{y.addEventListener("cuechange",M)});const N=()=>{Array.from(u.textTracks).forEach(y=>{y.removeEventListener("cuechange",M),y.addEventListener("cuechange",M)}),T()};u.textTracks.addEventListener("addtrack",N),u.textTracks.addEventListener("removetrack",N);const A=Array.from(u.querySelectorAll("track")),S=()=>{T()};return A.forEach(y=>{y.addEventListener("load",S)}),()=>{Array.from(u.textTracks).forEach(y=>{y.removeEventListener("cuechange",M)}),u.textTracks.removeEventListener("addtrack",N),u.textTracks.removeEventListener("removetrack",N),A.forEach(y=>{y.removeEventListener("load",S)})}},[i,n,r,h,a,o])}function ts({videoRef:r,overlayRef:n,style:i,activeSubtitleTrack:h,delayMs:a,enabled:o}){W(()=>{if(!o)return;const s=r.current,l=n.current;if(!s||!l)return;const u=localStorage.getItem("playerSubtitlesEnabled")!=="false",f=()=>{if(l.innerHTML="",!u||h==="off"||h===null)return;const d=Array.from(s.textTracks).find(S=>S.language===h||S.label===h);if(!d||d.mode!=="showing")return;const R=a/1e3;let p;if(R>0&&d.cues){const S=s.currentTime-R;p=Array.from(d.cues).filter(y=>y.startTime<=S&&S<=y.endTime)}else p=Array.from(d.activeCues??[]);if(p.length===0)return;const T={...i,fontSize:Pt(i.fontSize,s.clientHeight||0)},M=dr(T),N=mr(s,T.position),A=Array.from(p);A.forEach((S,y)=>{const P=String(S.text??"");if(!fr(P).trim())return;const m=document.createElement("div"),E=(A.length-1-y)*1.7;m.style.cssText=`${M}
56
- bottom: calc(${N}px + ${E}em);`,m.innerHTML=hr(P),l.appendChild(m)})},k=()=>f(),e=()=>f();return Array.from(s.textTracks).forEach(d=>{d.addEventListener("cuechange",k)}),s.addEventListener("timeupdate",e),f(),()=>{Array.from(s.textTracks).forEach(d=>{d.removeEventListener("cuechange",k)}),s.removeEventListener("timeupdate",e),l.innerHTML=""}},[h,a,o,n,i,r])}const rs=({isOpen:r,onClose:n,onSuccess:i})=>{const h=()=>{i?.(),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:h,children:"Refresh Dango"})]})]})})},bs=()=>{const{id:r,episodeNumber:n}=Xt(),i=Jt(),h=Nt(),a=Zt(),{hasConsent:o,grant:s}=xr(),{options:l}=_t(),u=Me(()=>l.filter(g=>(g.kind??"anime")==="anime"),[l]),f=Me(()=>u.map(g=>g.id),[u]),k=Me(()=>new Set(u.filter(g=>g.mature).map(g=>g.id)),[u]),{state:e,dispatch:d,toggleWatchlist:R,moveToCompleted:p,setPreferredSource:T,handleToggleDetails:M,markEpisodeWatched:N,prefetchEpisodeSources:A,isMarkingWatched:S,isUpdatingWatchlistStatus:y}=Gn(r,n,a.state||null,{hasMatureConsent:o});W(()=>{if(r&&e.showMeta?.id&&e.showMeta.id!==r){const g=n?`/watch/${e.showMeta.id}/${n}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;i(g,{replace:!0})}},[r,e.showMeta?.id,n,i]);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]),m=pr({skipIntervals:e.skipIntervals,showId:r,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:P}),{refs:E,actions:B}=m,H=Kr(),O=C(null),K=C(null),G=C(null),[L,x]=oe(()=>{try{const g=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(g)?g:"balanced"}catch{return"balanced"}}),{videoDelayMs:q,videoDelayEnabled:Q,setDelayEnabled:me,handleVideoDelayChange:c,isCalibrating:b,testClipActive:v,stopCalibration:D,openAvSyncCalibrator:Y,cancelAvSyncCalibrator:I,applyAvSyncCalibrator:V,toggleTestClip:J,calibReturnRef:Se,effectiveVideoDelayMs:Ae}=vr(E.videoRef,()=>B.setShowSettings(!1)),Re=C(null),Z=Fn({videoRef:E.videoRef,canvasRef:K,profile:L,delayMs:Ae}),z=Z.isEnabled&&Z.isWebGPUSupported;On({videoRef:E.videoRef,episodeKey:`${r??""}:${e.currentEpisode??""}`,isEnabled:Z.isEnabled,isSupported:Z.isWebGPUSupported,mediaReady:!e.loadingVideo&&!!e.selectedLink,isIframeSource:e.selectedSource?.type==="iframe",setEnabled:Z.setEnabled}),gr({videoRef:E.videoRef,canvasRef:Re,delayMs:Ae,enabled:Q&&!z});const ke=Q&&!z,_e=z||ke,[ee,j]=oe(!1),pe=C(n);W(()=>{pe.current!==n&&(pe.current=n,D())},[n,D]);const ht=U(()=>{h.invalidateQueries({queryKey:[se.continueWatching]})},[h]),{data:xe=[],isLoading:Je}=Br(),Ze=Lr(),Qe=Dr(),pt=$r(),{isTheaterMode:ae,toggleTheaterMode:ie,handleLayoutClick:vt}=yr();er(()=>{if(m.state.isFullscreen||ae)return;const g=E.playerContainerRef.current,X=O.current;if(!g||!X)return;const $e=()=>{const yt=g.getBoundingClientRect().height;X.style.height=`${yt}px`};$e();const lt=new ResizeObserver($e);return lt.observe(g),()=>lt.disconnect()},[m.state.isFullscreen,ae,E.playerContainerRef]);const Te=Me(()=>e.episodes.findIndex(g=>g===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:v,selectedSourceType:e.selectedSource?.type,onEnded:B.onEnded,queue:xe,removeFromQueue:Ze.mutate,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,isAutoplayEnabled:e.isAutoplayEnabled,nextEpisode:Ke,previousEpisode:et,navigate:i,invalidateContinueWatching:ht,dispatch:d}),{showNextEpisodePrompt:nt,handleThresholds:Le}=jn({videoRef:E.videoRef,queue:xe,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,selectedSource:e.selectedSource,hasNextEpisode:tt,nextEpisode:Ke,prefetchEpisodeSources:A,matchesQueueItem:Xe}),{checkEnd:De,logDuration:st}=br({videoRef:E.videoRef,sourceType:e.selectedSource?.type,resetKey:`${r}:${e.currentEpisode}`,onEnd:qe}),ot=e.showResumeModal&&!e.resumeProgressPending,at=$,F=ot||at;Sr(m,!!e.selectedLink&&!ae&&!F);const{fallbackPrompt:te,isRetryingProvider:fe,rememberFallbackChoice:le,setRememberFallbackChoice:ce,fallbackChoice:he,updateFallbackChoice:ge,dismissFallbackPrompt:je,chooseIframeFallback:We,chooseProviderRetry:ye,handleVideoSourceError:re,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:T,showControls:B.setShowControls,dispatch:d}),{seekToTimeRef:Ue}=Jn({engine:m.engine,videoRef:E.videoRef,selectedSource:e.selectedSource,selectedLink:e.selectedLink,loadingVideo:e.loadingVideo,testClipActive:v,resumeTime:e.resumeTime,resumeDuration:e.resumeDuration,showResumeModal:e.showResumeModal,calibReturnRef:Se,setAvailableSubtitles:B.setAvailableSubtitles,setActiveSubtitleTrack:B.setActiveSubtitleTrack,onFatalError:re});W(()=>{F&&m.state.isFullscreen&&m.actions.toggleFullscreen()},[F,m.state.isFullscreen,m.actions]),W(()=>{F&&E.videoRef.current&&E.videoRef.current.pause()},[F,E.videoRef]);const{titlePreference:ne}=Ir(),{lowEndMode:He}=Fr(),{settings:gt,update:Dt}=Er(),$t=ae&&gt.enabled&&!He&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,Pe=Me(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:g,names:X}=e.showMeta;return ne==="name"?g||"Loading...":ne==="nativeName"?X?.native||g||"Loading...":ne==="englishName"?X?.english||g||"Loading...":g||"Loading..."},[e.showMeta,ne,e.loadingShowData]);W(()=>{Pe&&Pe!=="Loading..."&&e.currentEpisode&&(document.title=`► ${Pe} Episode ${e.currentEpisode} - dango`)},[Pe,e.currentEpisode]),qn({onNext:Fe,onToggleTheater:ie,flashControls:m.actions.flashControls});const{setAvailableSubtitles:It,setActiveSubtitleTrack:Ft}=B,wt=Me(()=>({fontSize:m.state.subtitleFontSize,position:m.state.subtitlePosition,bgOpacity:m.state.subtitleBgOpacity,bgColor:m.state.subtitleBgColor,textColor:m.state.subtitleTextColor,edge:m.state.subtitleEdge,bold:m.state.subtitleBold}),[m.state.subtitleFontSize,m.state.subtitlePosition,m.state.subtitleBgOpacity,m.state.subtitleBgColor,m.state.subtitleTextColor,m.state.subtitleEdge,m.state.subtitleBold]);Zn({videoRef:E.videoRef,availableSubtitles:m.state.availableSubtitles,activeSubtitleTrack:m.state.activeSubtitleTrack,setAvailableSubtitles:It,setActiveSubtitleTrack:Ft});const[Ot,Wt]=oe(0);W(()=>{const g=E.videoRef.current;if(!g)return;const X=()=>Wt(g.clientHeight||0);X();const $e=new ResizeObserver(X);return $e.observe(g),()=>$e.disconnect()},[E.videoRef,e.selectedSource,e.selectedLink]),es({videoRef:E.videoRef,videoBoxH:Ot,style:wt,sourceKey:`${e.selectedSource?.sourceName??""}:${e.selectedLink?.link??""}`,activeSubtitleTrack:m.state.activeSubtitleTrack,availableSubtitles:m.state.availableSubtitles}),ts({videoRef:E.videoRef,overlayRef:G,style:wt,activeSubtitleTrack:m.state.activeSubtitleTrack,delayMs:Ae,enabled:_e}),W(()=>{try{localStorage.setItem("anime4kProfile",L)}catch{}},[L]);const Ut=()=>{E.videoRef.current&&(E.videoRef.current.currentTime=e.resumeTime,E.videoRef.current.play()),d({type:"SET_STATE",payload:{showResumeModal:!1}})},Vt=()=>{E.videoRef.current&&(E.videoRef.current.currentTime=0,E.videoRef.current.play()),d({type:"SET_STATE",payload:{showResumeModal:!1}})},Qt=U(()=>{d({type:"SET_STATE",payload:{showResumeModal:!1}})},[d]),Kt=U(async()=>{try{await p(),Be(),d({type:"SET_STATE",payload:{showResumeModal:!1}}),i("/")}catch{}},[p,Be,d,i]),kt=(g,X)=>t("div",{className:g,children:[t("button",{className:`${w.episodeNavBtn} ${w.secondary}`,onClick:Oe,disabled:!et,type:"button",children:[t(de,{name:"chevron-left",size:12}),"Prev EP"]}),t("button",{className:`${w.episodeNavBtn} ${w.primary}`,onClick:rt,disabled:!Ke,type:"button",children:["Next EP",t(de,{name:"chevron-right",size:12})]}),X==="mobile"&&H&&t("button",{className:`${w.episodeNavBtn} ${w.episodePickerBtn}`,onClick:()=>j(!0),type:"button",children:[t(de,{name:"list-ul",size:12}),"Episodes"]})]}),Gt=g=>{d({type:"SET_STATE",payload:{isAutoplayEnabled:g}}),Vr(g)},Tt=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),qt=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",zt=U(async()=>{if(!r||!e.currentEpisode||!e.showMeta.name||S)return;const g=E.videoRef.current?.duration,X=Math.max(g||0,e.resumeDuration||0,Number(e.showMeta.episodeDuration||0)*60,1);await N(e.currentEpisode,X)},[r,e.currentEpisode,e.showMeta,e.resumeDuration,N,S,E.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:()=>i("/home"),onGrant:s})}):t("div",{className:`${be.playerPageLayout} ${ae?be.theaterMode:""}`,onClick:vt,children:[ae&&t(wr,{videoRef:E.videoRef,active:$t,settings:gt}),t(kr,{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:Kt,disabled:y,children:y?"Saving...":"Move to Completed"})]}),t(Tr,{isOpen:ot,onClose:Qt,title:"Resume Playback?",message:t(ct,{children:["You were watching at ",t("strong",{children:m.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:Ut,onRestart:Vt}),t(mt,{isOpen:!!te,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."]}),te?.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:le,onChange:g=>ce(g.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(Or,{isOpen:!!e.showCookieModal&&e.cookieProvider!=="mkissa",onClose:()=>d({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{h.invalidateQueries({queryKey:[se.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),t(rs,{isOpen:!!e.showCookieModal&&e.cookieProvider==="mkissa",onClose:()=>d({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{h.invalidateQueries({queryKey:[se.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!ae&&t("aside",{ref:O,className:be.episodeSidebar,children:e.loadingShowData?t(Cr,{variant:"sidebar"}):t(Mr,{episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:g=>i(`/watch/${r}/${g}`)})}),t("div",{className:be.playerMain,children:[t("div",{className:`${w.videoContainer} ${m.state.isFullscreen?"":be.videoPlayerWrapper} ${m.state.isFullscreen?w.fullscreenActive:""}`,style:{...F?{visibility:"hidden"}:{}},onContextMenu:g=>g.preventDefault(),children:t(Cn,{player:m,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Gt,fallbackChoice:he,onFallbackChoiceChange:ge,ambientSettings:gt,onAmbientChange:Dt,showNextEpisodeButton:!F&&nt&&xe.length===0,onNextEpisode:rt,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(g,X)=>{E.videoRef.current&&!isNaN(E.videoRef.current.currentTime)&&(Ue.current=E.videoRef.current.currentTime),T(g.sourceName),d({type:"SET_STATE",payload:{selectedSource:g,selectedLink:X,showResumeModal:e.showResumeModal&&g.type!=="iframe"}})},loadingVideo:Ce,skipIntervals:e.skipIntervals,animeTitle:Pe,episodeNumber:e.currentEpisode??void 0,isTheaterMode:ae,onTheaterModeToggle:ie,anime4kEnabled:Z.isEnabled,onAnime4kToggle:Z.toggle,anime4kSupported:Z.isWebGPUSupported,anime4kProfile:L,onAnime4kProfileChange:x,anime4kInitializing:Z.isInitializing,anime4kError:Z.error,videoDelayEnabled:Q,onVideoDelayToggle:me,videoDelayMs:q,onVideoDelayChange:c,onCalibrateAvSync:Y,isInteractingExtra:ee||b,className:or.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:t(ct,{children:[m.state.isSpeedBoostActive&&t("div",{className:w.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(de,{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})]})}),m.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(ar,{controls:m.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:B.onPlay,onPause:B.onPause,onEnded:()=>{v||De(!0)},onDurationChange:()=>{st()},onSeeked:()=>{v||(Le(),De())},onLoadedMetadata:()=>{Le(),st(),v||De()},onTimeUpdate:()=>{v||(B.onTimeUpdate(),Le(),De(),Ge&&E.videoRef.current&&E.videoRef.current.currentTime<E.videoRef.current.duration-1&&ze())},onError:re,onContextMenu:g=>g.preventDefault(),className:_e?w.videoElementHidden:""}),Z.isWebGPUSupported&&!Ce&&e.videoSources.length>0&&t("canvas",{ref:K,className:`${w.upscalerCanvas} ${z?w.upscalerActive:""}`}),!z&&!Ce&&e.videoSources.length>0&&t("canvas",{ref:Re,className:`${w.upscalerCanvas} ${ke?w.upscalerActive:""}`}),Z.isEnabled&&Z.isWebGPUSupported&&Z.isInitializing&&t("div",{className:w.upscalerStatusBadge,children:"Preparing upscaler…"}),_e&&t("div",{ref:G,className:w.subtitleOverlay}),t(Rr,{isOpen:b,ms:q,onChange:c,onApply:V,onClose:I,testClipActive:v,onTestClip:J})]})]})}),!ae&&t(Nr,{}),!ae&&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:g=>Ze.mutate({showId:g.showId,episodeNumber:g.episodeNumber}),onClear:()=>Qe.mutate(),showClearAll:!0,onReorder:g=>pt.mutate(g.map(X=>({id:X.id,showId:X.showId,episodeNumber:X.episodeNumber})))}),t("div",{className:w.streamPanel,children:[t(An,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:u,onProviderChange:g=>{it(),d({type:"SET_STATE",payload:{selectedProvider:g,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Lt(g,e.showMeta?.isAdult===!0)}}),kt(`${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:g=>{E.videoRef.current&&!isNaN(E.videoRef.current.currentTime)&&(Ue.current=E.videoRef.current.currentTime);const $e=(g.links||[]).sort((lt,yt)=>(parseInt(yt.resolutionStr)||0)-(parseInt(lt.resolutionStr)||0))[0]||null;T(g.sourceName),d({type:"SET_STATE",payload:{selectedSource:g,selectedLink:$e,showResumeModal:e.showResumeModal&&g.type!=="iframe"}})},onLinkChange:g=>{e.selectedSource&&(T(e.selectedSource.sourceName),d({type:"SET_STATE",payload:{selectedLink:g}}))}})]}),t("div",{className:be.playerInfoContainer,children:[t("div",{className:be.playerInfoHeader,children:[t("div",{className:be.playerAnimeCard,children:t("img",{src:Wr(e.showMeta.thumbnail||""),alt:Pe,loading:"lazy",decoding:"async",onError:g=>{g.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:R,children:[e.inWatchlist?t(de,{name:"check",size:14}):t(de,{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}),qt&&t("button",{className:`${w.watchlistBtn} ${w.markWatchedBtn} ${Tt?w.markWatchedDone:""}`,onClick:zt,disabled:S||!e.currentEpisode,children:[t(de,{name:"check",size:14}),S?"Saving...":Tt?"Watched":"Mark Watched"]}),t("button",{className:`${w.watchlistBtn} ${w.modeToggleBtn} ${e.currentMode==="dub"?w.modeToggleActive:""}`,onClick:()=>{const g=e.currentMode==="dub"?"sub":"dub";it(),d({type:"SET_MODE",payload:g}),localStorage.setItem("preferredMode",g)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),He&&t("button",{className:`${w.watchlistBtn} ${w.modeToggleBtn} ${m.state.useNativeControls?w.modeToggleActive:""}`,onClick:()=>{const g=!m.state.useNativeControls;m.actions.setUseNativeControls(g),localStorage.setItem("playerUseNativeControls",g.toString())},type:"button",children:m.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),kt(`${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(de,{name:"chevron-up"}):t(de,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]})]}),e.showCombinedDetails&&t(jr,{showMeta:e.showMeta,styles:w})]})]})]})]}),t(Pr,{isOpen:ee,onClose:()=>j(!1),episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:g=>{j(!1),i(`/watch/${r}/${g}`)}})]})};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-vb4WPdcb.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-CRaHF9k4.js";import{u as re}from"./index-vb4WPdcb.js";import"./usePlaybackEnd-C5EyqR1L.js";import"./PlayerProvider-D02-hqdz.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-DJNRuWDJ.js";import{A as Ae}from"./AnimeCard-aZA4-g8o.js";import{S as Se}from"./SkeletonGrid-sA6_IQY1.js";import{t as ye,u as be,x as Ne,R as te,B as _,U as Te}from"./index-vb4WPdcb.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-DLVOORqW.js";import"./useAnimeInfoData-Ai39I_f0.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-ByAwxtJ-.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 +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)}
@@ -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-vb4WPdcb.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};