@serifpersia/dango 3.9.6 → 3.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-BMhqfrkR.js → AnimeCard-q5F_tD6Q.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-Dpvt4Bfs.js → AnimeInfo-Y4TzTq4q.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-CE1CxT-q.js → AnimeInfoPage-Bu8q7_fN.js} +2 -2
  5. package/client/dist/assets/{Asmr-Doj5jfXK.js → Asmr-DuW_Jtwk.js} +1 -1
  6. package/client/dist/assets/{AsmrPopup-Dj-Fzc8U.js → AsmrPopup-DmXAjIpT.js} +1 -1
  7. package/client/dist/assets/{AsmrResetProgressModal-DgFLBUSO.js → AsmrResetProgressModal-YlpGKOw-.js} +1 -1
  8. package/client/dist/assets/{Home-D163aa5L.js → Home-B2O7RdNh.js} +1 -1
  9. package/client/dist/assets/{Insights-C1P7cKeY.js → Insights-CT77CDrU.js} +1 -1
  10. package/client/dist/assets/{LibraryListPage-D-SFU6Ob.js → LibraryListPage-AJ6hG1L-.js} +1 -1
  11. package/client/dist/assets/{ListeningList-oyVVadHX.js → ListeningList-GOx1Ir_v.js} +1 -1
  12. package/client/dist/assets/{Manga-B3jtSBx5.js → Manga-CQKVrxz_.js} +1 -1
  13. package/client/dist/assets/{MangaInfoPage-DRVn2mAe.js → MangaInfoPage-BB5cQkBO.js} +1 -1
  14. package/client/dist/assets/{MangaReadPage-BnlHoZaL.js → MangaReadPage-BDpps3lc.js} +1 -1
  15. package/client/dist/assets/{MangaResetProgressModal-BUz2MLDA.js → MangaResetProgressModal-CaJT2NHH.js} +1 -1
  16. package/client/dist/assets/{Mature-C_6AL77P.js → Mature-BMXpX3iD.js} +1 -1
  17. package/client/dist/assets/{MatureConsentModal-CC0bqpsd.js → MatureConsentModal-C5vPRV5i.js} +1 -1
  18. package/client/dist/assets/{MediaCard-CeCsiCpy.js → MediaCard-MAnVN0Zz.js} +1 -1
  19. package/client/dist/assets/{OptionListMenu-BRI8vna9.js → OptionListMenu-CcJ9TOV5.js} +1 -1
  20. package/client/dist/assets/Player-BTtTwYJ2.js +56 -0
  21. package/client/dist/assets/PlayerProvider-BpSlL46d.js +1 -0
  22. package/client/dist/assets/{PlayerSettings-C9Tk-5ye.js → PlayerSettings-delaSmdG.js} +1 -1
  23. package/client/dist/assets/{QueueOptionsButton-COnNd8B1.js → QueueOptionsButton-DzBTJGGX.js} +1 -1
  24. package/client/dist/assets/{QueueRail-C3V7Dxkj.js → QueueRail-BT1sLDAw.js} +1 -1
  25. package/client/dist/assets/{ReadingList-CHjjXLoX.js → ReadingList-DmbVYPKy.js} +1 -1
  26. package/client/dist/assets/{ResetProgressModal-2EZzznJV.js → ResetProgressModal-BDobxv1I.js} +1 -1
  27. package/client/dist/assets/{Search-3BVWhbFk.js → Search-CxUcaFfI.js} +1 -1
  28. package/client/dist/assets/{Settings-BTFQ9byk.js → Settings-CoTHeSKq.js} +1 -1
  29. package/client/dist/assets/{SkeletonGrid-B3ip19ry.js → SkeletonGrid-9Q4VuO4S.js} +1 -1
  30. package/client/dist/assets/{Trackers-DQRyjPAR.js → Trackers-DC4EDgyt.js} +1 -1
  31. package/client/dist/assets/{Tv-BTz52FUb.js → Tv-DCnM78Kk.js} +1 -1
  32. package/client/dist/assets/{TvInfo-BKOS8AmG.js → TvInfo-foHQYICS.js} +1 -1
  33. package/client/dist/assets/{TvPopup-DRGj0Mk8.js → TvPopup-DkLU-7pw.js} +1 -1
  34. package/client/dist/assets/{TvSearch-BjA0C3q7.js → TvSearch-BwEGJcbq.js} +1 -1
  35. package/client/dist/assets/{TvWatchlist-DG1RbmE4.js → TvWatchlist-CP92PPZB.js} +1 -1
  36. package/client/dist/assets/{VirtualKeyboard-BIXYg3GQ.js → VirtualKeyboard-CsmRu3E6.js} +1 -1
  37. package/client/dist/assets/{WatchAlong-XefYySuV.js → WatchAlong-CpfZx3Le.js} +1 -1
  38. package/client/dist/assets/{WatchAlongPanel-C2JcUz-e.js → WatchAlongPanel-Bhu29HGV.js} +1 -1
  39. package/client/dist/assets/{Watchlist-D7u_6_Rx.js → Watchlist-9ikxJknw.js} +1 -1
  40. package/client/dist/assets/dash.all.min-CsDAls03.js +21 -0
  41. package/client/dist/assets/{index-BVkDKnzf.js → index-CipsDH5j.js} +2 -2
  42. package/client/dist/assets/{libraryInvalidation-ar7SX0CJ.js → libraryInvalidation-DGrdMoRs.js} +1 -1
  43. package/client/dist/assets/{playbackCompletion-Bgy18e-S.js → playbackCompletion-Z40dSXOE.js} +1 -1
  44. package/client/dist/assets/{useAnimeInfoData-Bf5W2JqV.js → useAnimeInfoData-CD7YsaT8.js} +1 -1
  45. package/client/dist/assets/{useMangaLibrary-CD_MzvM_.js → useMangaLibrary--4Q_E3hs.js} +1 -1
  46. package/client/dist/assets/{useMangaPopup-C1YDuijt.js → useMangaPopup-E_GgQXOf.js} +1 -1
  47. package/client/dist/assets/{useProviders-CrYpQhz2.js → useProviders-jAVzdvgi.js} +1 -1
  48. package/client/dist/assets/{useTv-ChpwVixu.js → useTv-C5QkCKNu.js} +1 -1
  49. package/client/dist/assets/{useTvLibrary-DqLFBTa7.js → useTvLibrary-DPJOHbp1.js} +1 -1
  50. package/client/dist/assets/useWatchAlongPlayer-CGkmzN8r.js +10 -0
  51. package/client/dist/index.html +1 -1
  52. package/package.json +2 -2
  53. package/server/dist/server.js +168 -168
  54. package/server/package.json +1 -1
  55. package/client/dist/assets/Player-CWw0u5o2.js +0 -56
  56. package/client/dist/assets/PlayerProvider-9AfeIQ6B.js +0 -1
  57. package/client/dist/assets/useWatchAlongPlayer-BTSgNMqR.js +0 -10
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dango-server",
3
3
  "private": true,
4
- "version": "3.9.6",
4
+ "version": "3.9.7",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=22.12.0"
@@ -1,56 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-C9Tk-5ye.js","assets/vendor-core-DfaOB3Rn.js","assets/index-BVkDKnzf.js","assets/vendor-query-BBT5_sHx.js","assets/vendor-icons-C1Pj_eSX.js","assets/index-COFMCQUU.css","assets/OptionListMenu-BRI8vna9.js","assets/useWatchAlongPlayer-BTSgNMqR.js","assets/PlayerProvider-9AfeIQ6B.js","assets/PlayerProvider-ZeplRma-.css","assets/playbackCompletion-Bgy18e-S.js","assets/useWatchAlongPlayer-Dk7zB7P4.css","assets/PlayerSettings-CbGkvNJq.css"])))=>i.map(i=>d[i]);
2
- import{u as t,g as bt,h as I,P as Sr,z as Er,d as ne,A as R,q as U,y as wr,T as _e,o as kr,a as Tr,c as Cr,_ as Rr,S as st}from"./vendor-core-DfaOB3Rn.js";import{p as J,a2 as Kt,a3 as ot,o as Mr,q as ae,t as he,J as Te,a4 as Pr,a5 as Je,Q as St,a6 as Nr,e as _r,x as Ar,y as xr,z as Lr,A as Br,d as $r,u as Dr,B as Pe,h as Ot,a7 as Fr,a8 as Ir,f as Or}from"./index-BVkDKnzf.js";import{P as Wr,a as Ur,b as Qr,F as Vr,s as Kr,c as qr}from"./PlayerProvider-9AfeIQ6B.js";import{u as qt,b as Wt,a as yt}from"./vendor-query-BBT5_sHx.js";import{p as Nt,s as Gr,C as zr,a as Hr,P as jr,b as He,c as Ut,f as Gt,d as Yr,e as Xr,g as Jr,r as Zr,u as en,h as tn,i as rn,j as nn,k as sn,l as on,m as an,n as ln,o as Ne,A as cn,q as Qt,R as un,E as dn,t as mn,v as E,w as pn,x as hn,y as fn}from"./useWatchAlongPlayer-BTSgNMqR.js";import{I as ge}from"./vendor-icons-C1Pj_eSX.js";import{a as vn,i as at,b as zt,l as gn,c as yn}from"./playbackCompletion-Bgy18e-S.js";import{M as bn}from"./MatureConsentModal-CC0bqpsd.js";import{u as Sn}from"./useIsMobile-Dvx1uJ82.js";import{s as xe,Q as En}from"./QueueRail-C3V7Dxkj.js";import{u as wn,Q as kn}from"./QueueOptionsButton-COnNd8B1.js";import{u as Ht}from"./useProviders-CrYpQhz2.js";import{A as Tn}from"./AnimeMetaDetails-B3-A7O5H.js";import{S as Cn}from"./SynopsisText-B3Sa5pRv.js";import{W as Rn}from"./WatchAlongPanel-C2JcUz-e.js";import"./vendor-ui-3qrARCPr.js";const Mn="_controlsOverlay_6uapd_1",Pn="_hidden_6uapd_21",Nn="_topControls_6uapd_27",_n="_backBtn_6uapd_47",An="_videoTitleInfo_6uapd_67",xn="_animeTitle_6uapd_73",Ln="_episodeNumber_6uapd_83",Bn="_bottomControls_6uapd_91",$n="_progressBarContainer_6uapd_110",Dn="_progressBar_6uapd_110",Fn="_thumb_6uapd_129",In="_scrubbing_6uapd_144",On="_watchedBar_6uapd_148",Wn="_bufferedBar_6uapd_149",Un="_timeBubble_6uapd_191",Qn="_skipSegment_6uapd_225",Vn="_op_6uapd_235",Kn="_mixed_op_6uapd_236",qn="_ed_6uapd_240",Gn="_mixed_ed_6uapd_241",zn="_recap_6uapd_245",Hn="_mixed_recap_6uapd_246",jn="_bottomControlsRow_6uapd_250",Yn="_leftControls_6uapd_258",Xn="_rightControls_6uapd_259",Jn="_controlBtn_6uapd_266",Zn="_theaterBtn_6uapd_307",es="_nextEpisodeBtn_6uapd_311",ts="_active_6uapd_332",rs="_timeDisplay_6uapd_336",ns="_skipControls_6uapd_344",B={controlsOverlay:Mn,hidden:Pn,topControls:Nn,backBtn:_n,videoTitleInfo:An,animeTitle:xn,episodeNumber:Ln,bottomControls:Bn,progressBarContainer:$n,progressBar:Dn,thumb:Fn,scrubbing:In,watchedBar:On,bufferedBar:Wn,timeBubble:Un,skipSegment:Qn,op:Vn,mixed_op:Kn,ed:qn,mixed_ed:Gn,recap:zn,mixed_recap:Hn,bottomControlsRow:jn,leftControls:Yn,rightControls:Xn,controlBtn:Jn,theaterBtn:Zn,nextEpisodeBtn:es,active:ts,timeDisplay:rs,skipControls:ns},ss=({player:r,handlers:o,visible:c,skipIntervals:m,showNextEpisodeButton:T,onNextEpisode:i,isTheaterMode:s,onTheaterModeToggle:n,settingsBtnRef:a,timeDisplayRef:y})=>{const{state:p,actions:h}=r,{showSettings:S}=p;return t("div",{className:`${B.controlsOverlay} ${c?"":B.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:B.bottomControls,"data-speed-boost-ignore":"true",onClick:C=>C.stopPropagation(),children:[t(Wr,{classes:{container:B.progressBarContainer,scrubbing:B.scrubbing,timeBubble:B.timeBubble,bar:B.progressBar,buffered:B.bufferedBar,watched:B.watchedBar,thumb:B.thumb},timeLabelRef:y,children:[p.duration>0&&r.state.currentSkipInterval&&t("div",{className:`${B.skipSegment} ${B[r.state.currentSkipInterval.skip_type]} `,style:{left:`${r.state.currentSkipInterval.start_time/p.duration*100}% `,width:`${(r.state.currentSkipInterval.end_time-r.state.currentSkipInterval.start_time)/p.duration*100}% `}}),m.map(C=>{const e=C.start_time/p.duration*100,w=(C.end_time-C.start_time)/p.duration*100;return t("div",{className:`${B.skipSegment} ${B[C.skip_type]} `,style:{left:`${e}% `,width:`${w}% `},title:C.skip_type.toUpperCase()},C.skip_id)})]}),t("div",{className:B.bottomControlsRow,children:[t("div",{className:B.leftControls,children:[t(Ur,{className:B.controlBtn}),t(Qr,{buttonClassName:B.controlBtn,onExpandedChange:h.setShowVolumeSlider}),t("span",{className:B.timeDisplay,ref:y,children:[h.formatTime(0)," / ",h.formatTime(p.duration)]}),p.currentSkipInterval&&!p.isAutoSkipEnabled&&!p.playbackLocked&&t("button",{className:B.controlBtn,onClick:()=>{p.currentSkipInterval&&(r.engine.seek(p.currentSkipInterval.end_time),h.setCurrentSkipInterval(null))},children:["Skip ",p.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),t("div",{className:B.rightControls,children:[t("div",{className:B.skipControls,children:T&&t("button",{className:B.nextEpisodeBtn,onClick:i,title:"Play next episode",children:"Next EP"})}),t("button",{className:`${B.controlBtn} ${o.isSubtitleActive?B.active:""}`,onClick:o.handleCCToggle,title:o.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:t(ge,{name:"closed-captioning",size:22})}),t("button",{ref:a,className:`${B.controlBtn} ${S?B.active:""} `,onClick:()=>h.setShowSettings(!S),"aria-label":"Settings",children:t(ge,{name:"cog"})}),t("button",{className:`${B.controlBtn} ${B.theaterBtn} ${s?B.active:""} `,onClick:C=>{C.stopPropagation(),n()},title:s?"Exit Theater Mode":"Theater Mode","aria-label":s?"Exit Theater Mode":"Theater Mode",children:t(ge,{name:"tv"})}),t(Vr,{className:B.controlBtn})]})]})]})})};function os(r){const{state:o,refs:c,actions:m}=r,T=n=>{if(!c.videoRef.current)return;m.setActiveSubtitleTrack(n);try{if(n===null||n==="off")J.setItem("playerSubtitlesEnabled","false");else{J.setItem("playerSubtitlesEnabled","true");const y=o.availableSubtitles.find(p=>p.label===n||p.lang===n);y?J.setItem("playerLastSubtitle",Gr(y)):J.setItem("playerLastSubtitle",n)}}catch{}let a=!1;Array.from(c.videoRef.current.textTracks).forEach(y=>{const h=n!==null&&n!=="off"&&(y.language===n||y.label===n)&&!a;y.mode=h?"showing":"hidden",h&&(a=!0)})},i=o.activeSubtitleTrack!==null&&o.activeSubtitleTrack!=="off";return{handleSubtitleSelection:T,isSubtitleActive:i,handleCCToggle:()=>{if(!c.videoRef.current)return;if(i){T("off");return}if(o.availableSubtitles.length===0)return;let n=null;try{n=J.getItem("playerLastSubtitle")}catch{}const a=Nt(o.availableSubtitles,{lastKey:n,enabled:!0});if(a<0)return;const y=o.availableSubtitles[a];T(y.label||y.lang)}}}const is=Er(()=>Kt(()=>import("./PlayerSettings-C9Tk-5ye.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),as=({player:r,isAutoplayEnabled:o,onAutoplayChange:c,showNextEpisodeButton:m,onNextEpisode:T,videoSources:i,selectedSource:s,selectedLink:n,onSourceChange:a,loadingVideo:y,skipIntervals:p,animeTitle:h,episodeNumber:S,mode:C,isTheaterMode:e,onTheaterModeToggle:w,anime4kEnabled:k,onAnime4kToggle:M,anime4kSupported:x,anime4kProfile:v,onAnime4kProfileChange:u,anime4kInitializing:P,anime4kError:A,videoDelayEnabled:D,onVideoDelayToggle:q,videoDelayMs:f,onVideoDelayChange:b,onCalibrateAvSync:W,fallbackChoice:G,onFallbackChoiceChange:z,ambientSettings:Y,onAmbientChange:O,children:L,overlays:H,isInteractingExtra:N=!1,className:V,hideChrome:se=!1})=>{const{state:$,actions:Ce}=r,{showSettings:Q}=$,{setShowSettings:l}=Ce,g=os(r),_=bt.useRef(null),K=bt.useRef(null),me=bt.useRef(null);I(()=>{const pe=De=>{_.current&&!_.current.contains(De.target)&&K.current&&!K.current.contains(De.target)&&Q&&l(!1)};return Q&&document.addEventListener("mousedown",pe),()=>{document.removeEventListener("mousedown",pe)}},[Q,l]);const ie=$.showControls||Q||$.isScrubbing,X=$.activeSubtitleTrack!=="off"?$.availableSubtitles.find(pe=>pe.lang===$.activeSubtitleTrack||pe.label===$.activeSubtitleTrack):void 0,Ae=t(zr,{visible:ie,title:h,episode:S?`Episode ${S}`:void 0,mode:C,server:y?void 0:s?.sourceName,subtitles:y?void 0:X?.label||X?.lang,onBack:()=>window.history.back(),classes:{overlay:B.controlsOverlay,hidden:B.hidden,top:B.topControls,backBtn:B.backBtn,titleInfo:B.videoTitleInfo,title:B.animeTitle,episode:B.episodeNumber}}),le=!y&&!$.isBuffering&&$.duration>0?t(Hr,{}):null,re=t(ss,{player:r,handlers:g,visible:ie,skipIntervals:p,showNextEpisodeButton:m,onNextEpisode:T,isTheaterMode:e,onTheaterModeToggle:w,settingsBtnRef:K,timeDisplayRef:me}),ce=t(Sr,{fallback:null,children:t(is,{ref:_,isOpen:Q,onClose:()=>l(!1),videoSources:i,currentSource:s,currentLink:n,onSourceChange:a,subtitles:$.availableSubtitles,activeSubtitleTrack:$.activeSubtitleTrack,onSubtitleChange:g.handleSubtitleSelection,subtitleSettings:{fontSize:$.subtitleFontSize,position:$.subtitlePosition,bgOpacity:$.subtitleBgOpacity,bgColor:$.subtitleBgColor,textColor:$.subtitleTextColor,edge:$.subtitleEdge,bold:$.subtitleBold},onSubtitleSettingsChange:Ce.setSubtitleStyle,useNativeControls:!$.playbackLocked&&$.useNativeControls,onNativeControlsToggle:Ce.setUseNativeControls,anime4kEnabled:k,onAnime4kToggle:M,anime4kSupported:x,anime4kProfile:v,onAnime4kProfileChange:u,anime4kInitializing:P,anime4kError:A,videoDelayEnabled:D,onVideoDelayToggle:q,videoDelayMs:f,onVideoDelayChange:b,onCalibrateAvSync:W,isAutoSkipEnabled:$.isAutoSkipEnabled,onAutoSkipChange:pe=>{Ce.setIsAutoSkipEnabled(pe);try{J.setItem("autoSkipEnabled",pe.toString())}catch{}},isAutoplayEnabled:o,onAutoplayChange:c,fallbackChoice:G,onFallbackChoiceChange:z,isTheaterMode:e,ambientSettings:Y,onAmbientChange:O})}),Re=Q?t("div",{"data-speed-boost-ignore":"true",onClick:pe=>pe.stopPropagation(),children:ce}):null;return t(jr,{engine:r.engine,topBar:Ae,centerControls:le,bottomBar:!y&&$.duration>0?re:null,settingsPanel:Re,overlays:H,isInteracting:N||$.showSettings||$.showVolumeSlider,nativeControls:!$.playbackLocked&&$.useNativeControls,className:V,chromeDisabled:se,children:L})},ls=({count:r=3})=>t("section",{className:xe.section,children:[t("div",{className:xe.header,children:t("button",{className:xe.headerToggle,disabled:!0,children:[t("span",{className:xe.title,children:t(ot,{width:"60px",height:"1.2rem",variant:"text"})}),t(ge,{name:"chevron-down",style:{opacity:.3}})]})}),t("div",{className:xe.list,children:Array.from({length:r}).map((o,c)=>t("div",{className:xe.item,style:{pointerEvents:"none"},children:[t("div",{className:xe.dragHandle,style:{opacity:.2},children:t(ot,{width:"16px",height:"16px",variant:"rectangular"})}),t("div",{className:xe.thumbnail,style:{overflow:"hidden",background:"transparent"},children:t(ot,{width:"100%",height:"100%",variant:"rectangular"})}),t("div",{className:xe.meta,children:[t(ot,{width:"80%",height:"1.2rem",variant:"text",className:xe.metaGap}),t(ot,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},c))})]}),cs={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},us={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},ds=["direct","cookie","embed"],ms=({selectedProvider:r,onProviderChange:o,isAdult:c,options:m})=>{const i=(m&&m.length>0?m:[]).filter(s=>s.mature===(c===!0));return t("div",{className:He.providerSelectContainer,children:[t("h4",{children:"Provider"}),t("select",{className:He.providerSelect,value:r,onChange:s=>o(s.currentTarget.value),children:ds.map(s=>{const n=i.filter(a=>(a.tier??"direct")===s);return n.length===0?null:t("optgroup",{label:us[s],children:n.map(a=>t("option",{value:a.id,children:a.sub?`${a.label} (${cs[a.sub]})`:a.label},a.id))},s)})})]})},ps=({videoSources:r,selectedSource:o,selectedLink:c,onSourceChange:m,onLinkChange:T})=>{const i=Array.isArray(r)?r:[];if(i.length===0)return null;const s=o?.type==="iframe"&&(o.links?.length??0)>1;return t("div",{className:He.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:He.sourceButtons,children:i.map((n,a)=>t("button",{className:`${He.sourceButton} ${o?.sourceName===n.sourceName?He.active:""} `,onClick:()=>m(n),children:n.sourceName},`${n.sourceName}-${a}`))}),s&&t("select",{className:He.sourceSelect,"aria-label":"Fallback embed quality",value:c?.link??o.links[0]?.link??"",onChange:n=>{const a=o.links.find(y=>y.link===n.currentTarget.value);a&&T(a)},children:o.links.map(n=>t("option",{value:n.link,children:n.resolutionStr},n.link))})]})},hs=bt.memo(ps,(r,o)=>r.selectedSource?.sourceName===o.selectedSource?.sourceName&&r.selectedLink?.link===o.selectedLink?.link&&r.videoSources===o.videoSources),fs={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}},vs={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},gs=5,ys=15e3,bs=`
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 Ss({videoRef:r,canvasRef:o,profile:c="balanced",delayMs:m=0}){const[T,i]=ne(!1),[s,n]=ne(()=>{try{return J.getItem("anime4kEnabled")==="true"}catch{return!1}}),[a,y]=ne(!1),[p,h]=ne(null),[S,C]=ne(0),e=R(0),w=R(null),k=R(null),M=R(null),x=R(null),v=R(null),u=R(null),P=R(null),A=R(null),D=R(null),q=R(!1),f=R(-1),b=R(0),W=R(m);W.current=m;const G=R([]),z=R(!1),Y=R(!1),O=R(!1),L=R(null),H=R(-1),N=R(-1),V=R(!1),se=R(0);I(()=>{async function Q(){if(typeof navigator>"u"||!navigator.gpu){i(!1);return}try{const l=await navigator.gpu.requestAdapter();i(!!l)}catch{i(!1)}}Q()},[]),I(()=>{if(!s||!T)return;let Q=!1;const l=++e.current,g=X=>{if(X)try{X.close()}catch{}},_=()=>{for(const X of G.current)g(X.bitmap);G.current=[]},K=X=>Math.max(8,Math.min(40,Math.ceil(X/16.7)+4));function me(){D.current!==null&&(cancelAnimationFrame(D.current),D.current=null)}async function ie(){let X=r.current;const Ae=o.current;if(!X||!Ae||e.current!==l)return;const le=performance.now()+ys;for(;(!X||X.videoWidth===0)&&performance.now()<le;){if(await new Promise(fe=>requestAnimationFrame(fe)),Q||e.current!==l)return;X=r.current}if(!X||X.videoWidth===0){!Q&&e.current===l&&(h("Timed out waiting for video metadata"),y(!1),n(!1));return}const re=X.videoWidth,ce=X.videoHeight,Re=Math.max(re,ce),pe=window.innerWidth,De=window.innerHeight,Ke=Math.max(pe,De),lt=Re<Ke?Ke/Re:1,Ze=fs[c],Et=Re<=480?Ze.sd:Re<=720?Ze.hd:Re<=1080?Ze.fhd:1,Le=Math.min(Et,lt);Ae.width=Math.round(re*Le),Ae.height=Math.round(ce*Le),y(!0),h(null),b.current=0,f.current=-1,H.current=-1,N.current=-1,V.current=!1,se.current=0,_(),q.current=!1;try{let fe=function(){Q||e.current!==l||(me(),D.current=requestAnimationFrame(()=>{ht()}))};const{ModeA:ct,ModeB:ut,ModeC:Fe,ModeAA:et}=await Kt(async()=>{const{ModeA:j,ModeB:Z,ModeC:Ee,ModeAA:ee}=await import("./index-BOKlZEHq.js").then(ve=>ve.i);return{ModeA:j,ModeB:Z,ModeC:Ee,ModeAA:ee}},[]);if(Q||e.current!==l)return;if(!navigator.gpu)throw new Error("WebGPU not available");const tt=await navigator.gpu.requestAdapter();if(Q||e.current!==l)return;if(!tt)throw new Error("No GPU adapter found");const F=await tt.requestDevice();if(!F)throw new Error("Failed to get GPU device");if(Q||e.current!==l){F.destroy();return}w.current=F;const oe=Ae.getContext("webgpu");if(!oe)throw new Error("Failed to get WebGPU context");k.current=oe;const Ie=navigator.gpu.getPreferredCanvasFormat();oe.configure({device:F,format:Ie,alphaMode:"premultiplied"});const be=F.createTexture({size:[re,ce],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),rt=vs[c],qe=Math.round(re*Le),Oe=Math.round(ce*Le),je=(()=>{switch(rt){case"ModeB":return new ut({device:F,inputTexture:be,nativeDimensions:{width:re,height:ce},targetDimensions:{width:qe,height:Oe}});case"ModeC":return new Fe({device:F,inputTexture:be,nativeDimensions:{width:re,height:ce},targetDimensions:{width:qe,height:Oe}});case"ModeAA":return new et({device:F,inputTexture:be,nativeDimensions:{width:re,height:ce},targetDimensions:{width:qe,height:Oe}});default:return new ct({device:F,inputTexture:be,nativeDimensions:{width:re,height:ce},targetDimensions:{width:qe,height:Oe}})}})(),dt=je.getOutputTexture(),Be=F.createSampler({magFilter:"linear",minFilter:"linear"}),mt=F.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
- `}),Ye=F.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),pt=F.createRenderPipeline({layout:F.createPipelineLayout({bindGroupLayouts:[Ye]}),vertex:{module:mt,entryPoint:"vs"},fragment:{module:mt,entryPoint:"fs",targets:[{format:Ie}]},primitive:{topology:"triangle-list"}}),wt=F.createBindGroup({layout:Ye,entries:[{binding:0,resource:dt.createView()},{binding:1,resource:Be}]});try{const j=F.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Z=F.createShaderModule({code:bs}),Ee=F.createRenderPipeline({layout:F.createPipelineLayout({bindGroupLayouts:[j]}),vertex:{module:Z,entryPoint:"vs"},fragment:{module:Z,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});L.current={pipeline:Ee,layout:j,inputView:be.createView()}}catch{L.current=null}M.current=je,x.current=be,v.current=dt,u.current=pt,P.current=Be,A.current=Ye,Y.current=!1,O.current=!1;async function Se(){const j=L.current;if(!j||Y.current)return!1;const Z=r.current;if(!Z)return!1;const Ee=!O.current;Ee&&F.pushErrorScope("validation");try{const ee=F.importExternalTexture({source:Z}),ve=F.createBindGroup({layout:j.layout,entries:[{binding:0,resource:ee},{binding:1,resource:Be}]}),we=F.createCommandEncoder(),ue=we.beginRenderPass({colorAttachments:[{view:j.inputView,loadOp:"load",storeOp:"store"}]});ue.setPipeline(j.pipeline),ue.setBindGroup(0,ve),ue.draw(6),ue.end(),F.queue.submit([we.finish()])}catch{return Y.current=!0,L.current=null,!1}if(Ee){const ee=await F.popErrorScope().catch(()=>null);if(ee)return console.warn("[anime4k] blit probe failed:",ee.message),Y.current=!0,L.current=null,!1;O.current=!0}return!0}y(!1);async function ht(){if(Q||e.current!==l||!oe)return;const j=r.current;if(!j||j.videoWidth===0){fe();return}if(j!==X||j.videoWidth!==re||j.videoHeight!==ce){C(ve=>ve+1);return}if(j.paused||j.ended||document.hidden||j.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){fe();return}const Z=j.getVideoPlaybackQuality().totalVideoFrames;if(Z===N.current){fe();return}if(q.current){fe();return}const Ee=j.currentTime;(j.seeking||H.current>=0&&Math.abs(Ee-H.current)>.5)&&(_(),V.current=!1,se.current=0,N.current=-1),H.current=Ee;const ee=Math.max(0,W.current||0);ee>se.current&&(V.current=!1),q.current=!0;try{const ve=performance.now();let we=null,ue=!1;if(ee<=0){G.current.length>0&&_(),V.current=!1,se.current=0;let ke=!1;if(!z.current)try{F.queue.copyExternalImageToTexture({source:j},{texture:be},[re,ce]),N.current=Z,ke=!0}catch(de){if(de instanceof TypeError)z.current=!0;else throw de}if(!ke&&!Y.current&&L.current&&await Se()&&(N.current=Z,ke=!0),!ke){const de=await createImageBitmap(j);N.current=Z,F.queue.copyExternalImageToTexture({source:de},{texture:be},[re,ce]),g(de)}}else{const ke=await createImageBitmap(j);N.current=Z;const de=G.current;de.push({bitmap:ke,capture:ve});const kt=K(ee);for(;de.length>kt;)g(de.shift()?.bitmap);let Ue=-1;for(let ye=de.length-1;ye>=0;ye--)if(ve-de[ye].capture>=ee){Ue=ye;break}if(Ue!==-1){for(let nt=0;nt<Ue;nt++)g(de.shift()?.bitmap);const ye=de.shift();ye?(we=ye.bitmap,V.current=!0,se.current=ee):(we=ke,ue=!0)}else if(!V.current)we=ke,ue=!0;else{const ye=de.shift();we=ye?ye.bitmap:ke,ye||(ue=!0)}if(!we){q.current=!1,fe();return}F.queue.copyExternalImageToTexture({source:we},{texture:be},[re,ce]),ue||g(we)}const Xe=F.createCommandEncoder();await je.pass(Xe);const We=Xe.beginRenderPass({colorAttachments:[{view:oe.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});We.setPipeline(pt),We.setBindGroup(0,wt),We.draw(6),We.end(),F.queue.submit([Xe.finish()]),f.current=Z,b.current=0,F.queue.onSubmittedWorkDone().then(()=>{e.current===l&&(q.current=!1)})}catch(ve){if(q.current=!1,b.current+=1,b.current>=gs&&!Q&&e.current===l){console.error(ve),h(ve instanceof Error?ve.message:"Render error"),n(!1);return}}fe()}fe()}catch(fe){!Q&&e.current===l&&(k.current?.unconfigure(),w.current?.destroy(),w.current=null,k.current=null,h(fe instanceof Error?fe.message:"Failed to initialize upscaler"),y(!1),n(!1))}}return ie(),()=>{Q=!0,e.current+=1,me(),_(),k.current?.unconfigure(),x.current&&(x.current.destroy(),x.current=null),v.current&&(v.current.destroy(),v.current=null),w.current&&(w.current.destroy(),w.current=null),M.current=null,u.current=null,P.current=null,A.current=null,L.current=null,k.current=null,q.current=!1}},[s,T,r,o,c,S]);const $=U(Q=>{n(Q);try{J.setItem("anime4kEnabled",String(Q))}catch{}},[]),Ce=U(()=>{n(Q=>{const l=!Q;try{J.setItem("anime4kEnabled",String(l))}catch{}return l})},[]);return{isWebGPUSupported:T,isEnabled:s,isInitializing:a,error:p,toggle:Ce,setEnabled:$}}function Es({videoRef:r,episodeKey:o,isEnabled:c,isSupported:m,mediaReady:T,isIframeSource:i,setEnabled:s}){const n=R(null),a=R(!1),y=R(!1),p=R(s);p.current=s,I(()=>{const h=n.current;n.current=o,!(h===null||h===o)&&(!c||!m||(a.current=!0,y.current=!1,p.current(!1)))},[o,c,m]),I(()=>{if(!a.current)return;if(c){y.current&&(a.current=!1);return}if(y.current=!0,!T)return;if(i){a.current=!1,p.current(!0);return}const h=r.current;if(!h)return;let S,C=!1;const e=()=>{C||(C=!0,a.current=!1,p.current(!0))};if(h.readyState>=2)return S=window.setTimeout(e,500),()=>window.clearTimeout(S);const w=()=>{window.setTimeout(e,500)};return h.addEventListener("canplay",w,{once:!0}),h.addEventListener("playing",w,{once:!0}),S=window.setTimeout(e,5e3),()=>{window.clearTimeout(S),h.removeEventListener("canplay",w),h.removeEventListener("playing",w)}},[c,T,i,r])}const ws=()=>J.getItem("preferredMode")==="dub"?"dub":"sub",ks=/^[a-z0-9-]+$/i,jt=r=>r?"preferredProviderMature":"preferredProvider",Yt=r=>{const o=J.getItem(jt(r));return o&&ks.test(o)?o:null},Xt=(r,o)=>{J.setItem(jt(o),r)},Ts=()=>Yt(!1)??"megaplay",Cs=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:ws(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:vn(),showResumeModal:!0,resumeProgressPending:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Ts(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Rs(r,o){switch(o.type){case"SET_STATE":return{...r,...o.payload};case"SET_MODE":return{...r,currentMode:o.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...r,selectedProvider:o.payload};default:return r}}async function Vt(r,o,c,m,T=!1){if(!r||!o)throw new Error("Missing params");try{const[i,s,n,a]=await Promise.all([he.data.video.query({showId:r,episodeNumber:o,mode:c.currentMode,provider:c.selectedProvider}).catch(v=>{const u=v.data?.cause;return v.message==="AUTH_REQUIRED"&&u?.provider==="mkissa"&&m({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:"mkissa"}}),null}),he.progress.getEpisode.query({showId:r,episodeNumber:o}).catch(()=>null),he.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),he.data.skipTimes.query({showId:r,episodeNumber:o}).catch(()=>[])]),y=n?.value,p=i?.filter(v=>{const u=v.sourceName.toLowerCase();return c.currentMode==="dub"?u.includes("eng")||u.includes("dub"):u.includes("jpn")||u.includes("sub")||!u.includes("eng")&&!u.includes("dub")})??[],h=p.length>0?p:i??[];let S=h.length>0?h[0]:null;if(y){const v=h.find(u=>u.sourceName===y);v&&(S=v)}const C=S&&S.links.length>0?[...S.links].sort((v,u)=>(parseInt(u.resolutionStr)||0)-(parseInt(v.resolutionStr)||0))[0]:null,e=s?.currentTime||0,w=s?.duration||0,k=e,x=(Array.isArray(a)?a:a?.results||[]).map(v=>({skip_id:v.skip_id||"",skip_type:v.skip_type||"",start_time:v.interval?.start_time??v.start_time??0,end_time:v.interval?.end_time??v.end_time??0})).filter(v=>v.end_time>0);return(!i||i.length===0)&&(T||Te.error(`No video sources found for ${c.selectedProvider}`)),{videoSources:i,selectedSource:S,selectedLink:C,resumeTime:k,resumeDuration:w,showResumeModal:k>5&&!at(k,w)&&S?.type!=="iframe",skipIntervals:x,fetchedEpisodeNumber:o}}catch(i){const s=i;if(s.message==="AUTH_REQUIRED")return m({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:s.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:o};throw i}}const Ms=(r,o,c,m)=>{const[T,i]=wr(Rs,c,l=>({...Cs(),showMeta:l?.name?{name:l.name,thumbnail:l.thumbnail,nativeName:l.nativeName,englishName:l.englishName,names:{romaji:l.name||l.englishName,english:l.englishName||l.name,native:l.nativeName}}:{}})),s=m?.watchSelection,n=_e(()=>s?{...T,selectedProvider:s.provider,currentMode:s.mode}:T,[T,s]),a=qt(),y=Mr(),p=R(null),h=R(null),{options:S}=Ht(),C=_e(()=>S.filter(l=>(l.kind??"anime")==="anime"),[S]),e=o||n.initialEpisode,w=`${r}:${e}`,k=R(w);I(()=>{k.current!==w&&(k.current=w,i({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[w,i]),I(()=>{!s&&r&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)&&n.selectedProvider!=="animepahe"&&p.current!==r&&(p.current=r,i({type:"SET_PROVIDER",payload:"animepahe"}))},[r,n.selectedProvider,s]);const{data:M,isLoading:x,error:v}=wn(r),{data:u}=Wt({queryKey:[ae.playerData,r,n.currentMode,n.selectedProvider],queryFn:async()=>{if(!r)throw new Error("No showId");const l=async()=>{try{const ie=await he.data.episodes.query({showId:r,mode:n.currentMode,provider:n.selectedProvider}).catch(()=>null);if(ie?.episodes?.length)return ie}catch{}return null},[g,_,K]=await Promise.all([l(),he.watchlist.check.query({showId:r}).catch(()=>({inWatchlist:!1,status:null})),he.progress.getWatchedEpisodes.query({showId:r}).catch(()=>[])]),me=g?.episodes?g.episodes.sort((ie,X)=>parseFloat(ie)-parseFloat(X)):[];return{description:g?.description||"",episodes:me,inWatchlist:_.inWatchlist,watchlistStatus:_.status??null,watchedEpisodes:K}},enabled:!!r});I(()=>{!o&&u?.episodes&&u.episodes.length>0&&!o&&i({type:"SET_STATE",payload:{initialEpisode:u.episodes[0]}})},[u,o]),I(()=>{if(s||M?.isAdult===void 0||h.current===r)return;const l=M.isAdult===!0,g=C.filter(K=>K.mature===l);if(g.length===0||C.find(K=>K.id===n.selectedProvider)?.mature===l)return;const _=Yt(l);h.current=r??null,i({type:"SET_PROVIDER",payload:g.find(K=>K.id===_)?.id??g[0].id})},[M?.isAdult,n.selectedProvider,r,C,s]),I(()=>{if(s||!r||!/^dango-mt-\d+$/.test(r)||h.current===`temp:${r}`)return;const l=M?.provider;l&&(h.current=`temp:${r}`,l!==n.selectedProvider&&i({type:"SET_PROVIDER",payload:l}))},[r,M,n.selectedProvider,s]);const{data:P,isLoading:A,isFetching:D,error:q}=Wt({queryKey:[ae.videoSources,r,e,n.selectedProvider,n.currentMode],queryFn:()=>Vt(r,e,n,i),enabled:!!r&&!!e&&!(n.showMeta?.isAdult===!0&&!m?.hasMatureConsent)}),{mutateAsync:f}=yt({mutationFn:async({wasIn:l,showMeta:g})=>{if(!r)throw new Error("Missing showId");if(l)await he.watchlist.remove.mutate({id:r});else{const _=g.name||g.names?.romaji;if(!_)throw new Error("Missing show name");await he.watchlist.add.mutate({id:r,name:_,thumbnail:g.thumbnail,nativeName:g.names?.native,englishName:g.names?.english,type:g.type,isAdult:g.isAdult})}return!l},onSuccess:l=>{Te.success(l?"Added to watchlist":"Removed from watchlist"),a.invalidateQueries({queryKey:[ae.playerData,r]}),a.invalidateQueries({queryKey:[ae.showData,r]}),a.invalidateQueries({queryKey:[ae.watchlist]})},onError:l=>Te.error(l instanceof Error?l.message:"Failed to update watchlist")}),b=U(async()=>{!r||!M||await f({wasIn:!!u?.inWatchlist,showMeta:M})},[r,M,u?.inWatchlist,f]),W=U(async l=>{try{await he.settings.set.mutate({key:"preferredSource",value:l})}catch(g){console.error(g)}},[]),{mutateAsync:G,isPending:z}=yt({mutationFn:async({status:l})=>{if(!r)throw new Error("Missing showId");if(u?.inWatchlist)return await he.watchlist.setStatus.mutate({id:r,status:l}),l;const g=M,_=g?.name||g?.names?.romaji;if(!g||!_)throw new Error("Missing show name");return await he.watchlist.add.mutate({id:r,name:_,thumbnail:g.thumbnail,nativeName:g.names?.native,englishName:g.names?.english,type:g.type,isAdult:g.isAdult,status:l}),l},onSuccess:l=>{i({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:l}}),Te.success(`Moved to ${l}`),a.invalidateQueries({queryKey:[ae.showData,r]}),a.invalidateQueries({queryKey:[ae.watchlist]}),a.invalidateQueries({queryKey:[ae.continueWatching]})},onError:()=>Te.error("Failed to update watchlist status")}),Y=U(async()=>{await G({status:"Completed"})},[G]),{mutateAsync:O,isPending:L}=yt({mutationFn:async({episodeNumber:l,duration:g,showMeta:_,episodes:K})=>{await he.progress.updateProgress.mutate({showId:r??"",episodeNumber:l,currentTime:g,duration:g,showName:_.name,showThumbnail:_.thumbnail,nativeName:_.names?.native,englishName:_.names?.english,genres:_.genres?.map(me=>me.name),popularityScore:Pr(_.score)??void 0,type:_.type,status:_.status,episodeCount:K.length,isAdult:_.isAdult})},onSuccess:(l,g)=>{Te.success(`Episode ${g.episodeNumber} marked as watched`),a.invalidateQueries({queryKey:[ae.playerData,r]}),a.invalidateQueries({queryKey:[ae.showMeta,r]}),a.invalidateQueries({queryKey:[ae.videoSources,r,g.episodeNumber]}),a.invalidateQueries({queryKey:[ae.continueWatching]}),a.invalidateQueries({queryKey:[ae.thisWeekSchedule]}),a.invalidateQueries(y.continueWatching.pathFilter())},onError:()=>Te.error("Failed to mark episode as watched")}),H=U(async(l,g)=>{!r||!M||await O({episodeNumber:l,duration:g,showMeta:M,episodes:u?.episodes||[]})},[r,M,u?.episodes,O]),{mutateAsync:N,isPending:V}=yt({mutationFn:async({episodeNumber:l})=>{await he.progress.resetProgress.mutate({showId:r??"",episodeNumber:l})},onSuccess:()=>{Te.success("Episode progress reset"),a.invalidateQueries({queryKey:[ae.playerData,r]}),a.invalidateQueries({queryKey:[ae.showMeta,r]}),a.invalidateQueries({queryKey:[ae.continueWatching]})},onError:()=>Te.error("Failed to reset progress")}),se=U(async l=>{r&&await N({episodeNumber:l})},[r,N]),$=U(async()=>{i({type:"SET_STATE",payload:{showCombinedDetails:!n.showCombinedDetails}})},[n.showCombinedDetails]),Ce=_e(()=>{const l=v||q,g=l?l.message:null,_=g==="AUTH_REQUIRED"?null:g,K=P&&P.fetchedEpisodeNumber===e?P:null,me=!!P&&!K,ie=s?K?.videoSources?.find(le=>le.sourceName===s.source&&le.type!=="iframe"&&le.links.some(re=>re.hls))??null:null,Ae=(n.selectedSource?.sourceName===ie?.sourceName?ie?.links.find(le=>le.hls&&le.link===n.selectedLink?.link):null)??ie?.links.filter(le=>le.hls).slice().sort((le,re)=>(parseInt(re.resolutionStr)||0)-(parseInt(le.resolutionStr)||0))[0]??null;return{...n,currentEpisode:e,showMeta:{...n.showMeta||{},...M||{}},episodes:u?.episodes||[],watchedEpisodes:u?.watchedEpisodes||[],inWatchlist:!!u?.inWatchlist,watchlistStatus:u?.watchlistStatus??n.watchlistStatus??null,videoSources:K?.videoSources||[],selectedSource:s?ie:n.selectedSource||K?.selectedSource||null,selectedLink:s?Ae:n.selectedLink||K?.selectedLink||null,resumeTime:s?0:K?.resumeTime||0,resumeDuration:K?.resumeDuration||0,resumeProgressPending:D,showResumeModal:!s&&n.showResumeModal&&(K?.showResumeModal??!1),skipIntervals:K?.skipIntervals||[],loadingShowData:x,loadingVideo:A||me,error:_,fetchedEpisodeNumber:K?.fetchedEpisodeNumber}},[n,M,u,P,x,A,D,v,q,e,s]),Q=U((l,g)=>{const _=g||r;if(!_||!l||_===r&&l===e)return;const me=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(_)&&n.selectedProvider!=="animepahe"?"animepahe":n.selectedProvider,ie=["video-sources",_,l,me,n.currentMode];a.getQueryState(ie)?.status!=="success"&&a.prefetchQuery({queryKey:ie,queryFn:()=>Vt(_,l,{selectedProvider:me,currentMode:n.currentMode},i,!0),staleTime:300*1e3,gcTime:1800*1e3})},[r,e,a,n,i]);return{state:Ce,dispatch:i,toggleWatchlist:b,moveToCompleted:Y,setPreferredSource:W,handleToggleDetails:$,markEpisodeWatched:H,resetEpisodeProgress:se,prefetchEpisodeSources:Q,isMarkingWatched:L,isResettingProgress:V,isUpdatingWatchlistStatus:z}};function Ps({onPrevious:r,onNext:o,onToggleTheater:c,flashControls:m}){I(()=>{const T=i=>{i.defaultPrevented||i.ctrlKey||i.metaKey||i.altKey||i.repeat||i.target.closest('input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(i.key.toLowerCase())&&m(),i.key.toLowerCase()==="n"&&o(),i.key.toLowerCase()==="p"&&r(),i.key.toLowerCase()==="t"&&c())};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[m,o,r,c])}const it=(r,o,c)=>r.showId===o||!!c&&r.showId===c;function Ns({testClipActive:r,selectedSourceType:o,onEnded:c,queue:m,removeFromQueue:T,showId:i,showMetaId:s,showStatus:n,currentEpisode:a,isAutoplayEnabled:y,nextEpisode:p,previousEpisode:h,navigate:S,invalidateContinueWatching:C,dispatch:e}){const[w,k]=ne(!1),[M,x]=ne(null),[v,u]=ne(null),P=R(T);P.current=T;const A=R(!1),D=zt(n);I(()=>{A.current=!1,k(!1)},[i,a]);const q=U(()=>{if(r||A.current)return;A.current=!0,c();const O=m.find(L=>it(L,i,s)&&L.episodeNumber===a);if(m.length>0){const L=m.findIndex(N=>it(N,i,s)&&N.episodeNumber===a),H=L>=0?m[L+1]||null:m[0];u({nextItem:H,playedItem:O||null}),x(2);return}if(O&&P.current({showId:O.showId,episodeNumber:O.episodeNumber}),y&&p){C(),S(`/watch/${i}/${p}`);return}!p&&D&&k(!0)},[c,S,m,i,s,a,p,y,C,r,D]),f=U(()=>{if(m.length===0)return;c();const O=m.find(N=>it(N,i,s)&&N.episodeNumber===a),L=m.findIndex(N=>it(N,i,s)&&N.episodeNumber===a),H=L>=0?m[L+1]||null:m[0];O&&T({showId:O.showId,episodeNumber:O.episodeNumber}),H?S(`/watch/${H.showId}/${H.episodeNumber}`):!p&&D&&k(!0)},[c,S,m,T,i,s,a,p,D]),b=U(()=>{p&&(C(),S(`/watch/${i}/${p}`)),k(!1),e({type:"SET_STATE",payload:{showResumeModal:!1}})},[p,S,i,e,C]),W=U(()=>{m.length>0?f():p?b():Te.error("No next episode available")},[m.length,f,b,p]),G=U(()=>k(!1),[]),z=U(()=>{u(null),x(null)},[]),Y=U(()=>{h&&S(`/watch/${i}/${h}`)},[h,S,i]);return I(()=>{const O=L=>{L.origin===window.location.origin&&o==="iframe"&&L.data?.type==="ANI_WEB_MEDIA_ENDED"&&q()};return window.addEventListener("message",O),()=>window.removeEventListener("message",O)},[q,o]),I(()=>{if(!v||M===null)return;if(M<=0){const{nextItem:L,playedItem:H}=v;u(null),x(null),H&&P.current({showId:H.showId,episodeNumber:H.episodeNumber}),L?S(`/watch/${L.showId}/${L.episodeNumber}`):!p&&D&&k(!0);return}const O=window.setTimeout(()=>{x(L=>L===null?null:L-1)},1e3);return()=>window.clearTimeout(O)},[v,M,S,p,D]),{showCompleteModal:w,queueCountdown:M,pendingQueueTransition:v,handleQueueTransition:f,handleNextEpisode:b,handleNShortcut:W,handlePreviousEpisode:Y,handlePlaybackFinished:q,closeCompleteModal:G,cancelQueueTransition:z}}function _s({videoRef:r,queue:o,showId:c,showMetaId:m,currentEpisode:T,selectedSource:i,hasNextEpisode:s,nextEpisode:n,prefetchEpisodeSources:a,matchesQueueItem:y}){const[p,h]=ne(!1),S=R(a);S.current=a;const C=R("");I(()=>{h(!1)},[T]);const e=U(()=>{const w=r.current;if(!w||i?.type==="iframe")return;const k=w.duration,M=w.currentTime;if(!k||Number.isNaN(k)){h(!1);return}if(k-M<=60){const x=o.findIndex(P=>y(P,c,m)&&P.episodeNumber===T),v=o.length>0?x>=0?o[x+1]||null:o[0]:null,u=v?`${v.showId}:${v.episodeNumber}`:s?`${c}:${n}`:"";u&&C.current!==u&&(C.current=u,v?S.current(v.episodeNumber,v.showId):S.current(n??""))}h(s&&at(M,k))},[r,i,o,c,m,T,s,n,y]);return{showNextEpisodePrompt:p,handleThresholds:e}}const Pt="fallbackChoice";function As(){try{const r=J.getItem(Pt);return r==="iframe"||r==="retry"?r:null}catch{return null}}function xs(r){try{r===null?J.removeItem(Pt):J.setItem(Pt,r)}catch{}}function Ls({showId:r,episodeNumber:o,currentMode:c,selectedProvider:m,selectedSourceType:T,videoSources:i,isAdult:s,providerOrder:n,matureProviders:a,setPreferredSource:y,dispatch:p,showControls:h}){const S=R(!1),C=R([]),e=R(!1),[w,k]=ne(null),[M,x]=ne(!1),[v,u]=ne(!1),[P,A]=ne(()=>As()??"ask"),D=U(N=>{A(N),xs(N==="ask"?null:N)},[]),q=R(P);I(()=>{q.current=P},[P]);const f=R(i);f.current=i;const b=U(()=>{S.current=!1,C.current=[],e.current=!1,k(null),x(!1)},[]);I(()=>{b()},[b,r,o]);const W=U(N=>{if(S.current)return;S.current=!0;const V=N.links[0];y(N.sourceName),p({type:"SET_STATE",payload:{selectedSource:N,selectedLink:V}}),k(null)},[p,y]),G=U(()=>{const V=f.current.find(se=>se.type==="iframe");return V?.links?.length?V:null},[]),z=U(async()=>{const N=n.filter(V=>{if(C.current.includes(V))return!1;const se=a.has(V);return s===void 0?!0:se===s});x(!0);try{for(const V of N){C.current.push(V);let se=null;try{se=await he.data.video.query({showId:r,episodeNumber:o,mode:c,provider:V})}catch{continue}const $=(se??[]).filter(l=>{const g=l.sourceName.toLowerCase();return c==="dub"?g.includes("eng")||g.includes("dub"):g.includes("jpn")||g.includes("sub")||!g.includes("eng")&&!g.includes("dub")});if(($.length>0?$:se??[]).find(l=>l.type!=="iframe"&&l.links?.length)){C.current=[m],e.current=!1,p({type:"SET_STATE",payload:{selectedProvider:V,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Xt(V,s===!0),k(null),Te.success(`Switched to ${V} (direct stream)`);return}}k({retryFailed:!0}),Te.error("No working direct stream found on other providers")}finally{x(!1)}},[r,o,c,s,m,p,n,a]),Y=U(()=>{if(S.current||e.current||T!=="player")return;const N=G();if(!N)return;C.current.includes(m)||C.current.push(m);const V=q.current;if(V==="iframe"){W(N);return}if(V==="retry"){z();return}h(!0),k({retryFailed:!1})},[T,m,G,W,z,h]),O=U(()=>{e.current=!0,k(null),u(!1)},[]),L=U(()=>{v&&D("iframe");const N=G();N?W(N):k(null)},[v,D,G,W]),H=U(()=>{v&&D("retry"),z()},[v,D,z]);return{fallbackPrompt:w,isRetryingProvider:M,rememberFallbackChoice:v,setRememberFallbackChoice:u,fallbackChoice:P,updateFallbackChoice:D,dismissFallbackPrompt:O,chooseIframeFallback:L,chooseProviderRetry:H,handleVideoSourceError:Y,resetFallback:b}}function Bs({engine:r,videoRef:o,selectedSource:c,selectedLink:m,loadingVideo:T,testClipActive:i,resumeTime:s,resumeDuration:n=0,showResumeModal:a,disabled:y=!1,startOver:p=!1,resumeAt:h=null,calibReturnRef:S,setAvailableSubtitles:C,setActiveSubtitleTrack:e,onFatalError:w}){const k=R(null),M=R(s),x=R(n),v=R(a),u=R(w);return u.current=w,I(()=>{M.current=s,x.current=n,v.current=a},[s,n,a]),I(()=>{if(y){r.unload();return}const P=o.current;if(!P)return;for(;P.firstChild;)P.removeChild(P.firstChild);if(i)return r.loadSource({url:"/av-sync-test.mp4"},{autoPlay:!0});if(T||!c||!m||c.type==="iframe"){r.unload();return}p?k.current=0:S.current!=null?(k.current=S.current,S.current=null):k.current===null&&h!=null?k.current=h:k.current===null&&M.current>5&&!v.current&&!at(M.current,x.current)?k.current=M.current:k.current===null&&v.current&&(k.current=0);let A=m.link;if(A.startsWith("/api/proxy")||(A=`/api/proxy?url=${encodeURIComponent(A)}`,m.headers?.Referer&&(A+=`&referer=${encodeURIComponent(m.headers.Referer)}`)),c.subtitles){const f=J.getItem("playerSubtitlesEnabled")!=="false";let b=null;try{b=J.getItem("playerLastSubtitle")}catch{}const W=Nt(c.subtitles,{lastKey:b,enabled:f}),G=W>=0?c.subtitles[W]:null;c.subtitles.forEach(z=>{const Y=document.createElement("track");Y.kind="subtitles",Y.label=z.label,Y.srclang=z.lang;const O=z.src??z.url;if(O){let L=`/api/subtitle-proxy?url=${encodeURIComponent(O)}`;const H=m.headers?.Referer;H&&(L+=`&referer=${encodeURIComponent(H)}`),Y.src=L}G&&z.label===G.label&&z.lang===G.lang&&(Y.default=!0),P.appendChild(Y)}),f||e("off"),C(c.subtitles)}const D=k.current??0;k.current=null;const q=document.body.classList.contains("low-end");return r.loadSource({url:A,hls:m.hls},{initialTime:D,autoPlay:p||h!=null||!(v.current&&M.current>5)&&!at(M.current,x.current),hlsConfig:{maxBufferLength:q?15:30,maxMaxBufferLength:q?30:60,maxBufferSize:(q?25:60)*1e3*1e3,startLevel:-1},onHls:(f,b)=>{if(!c.subtitles?.length)return;const W=()=>{f.subtitleTrack!==-1&&(f.subtitleTrack=-1)};f.on(b.Events.SUBTITLE_TRACK_SWITCH,W),W()},onError:()=>u.current()})},[r,c,m,o,S,T,i,y,p,h,e,C]),{seekToTimeRef:k}}function $s({videoRef:r,availableSubtitles:o,activeSubtitleTrack:c,setAvailableSubtitles:m,setActiveSubtitleTrack:T}){I(()=>{const i=r.current;if(!i)return;const s=()=>{const n=Array.from(i.textTracks).map(a=>({label:a.label,lang:a.language,src:void 0,mode:a.mode}));m(n)};return i.textTracks.addEventListener("addtrack",s),i.textTracks.addEventListener("removetrack",s),s(),()=>{i.textTracks.removeEventListener("addtrack",s),i.textTracks.removeEventListener("removetrack",s)}},[r,m]),I(()=>{if(c===null&&o.length>0&&J.getItem("playerSubtitlesEnabled")!=="false"){let i=null;try{i=J.getItem("playerLastSubtitle")}catch{}const s=Nt(o,{lastKey:i,enabled:!0});if(s<0){T("off");return}const n=o[s];T(n.lang||n.label)}},[c,o,T]),I(()=>{const i=r.current;if(!i||o.length===0)return;const s=c;if(!(J.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(i.textTracks).forEach(y=>{y.mode="hidden"});return}let a=!1;if(Array.from(i.textTracks).forEach(y=>{const h=(y.language===s||y.label===s)&&!a;y.mode=h?"showing":"hidden",h&&(a=!0)}),!a&&i.textTracks.length>0){const y=Array.from(i.textTracks).find(p=>p.language==="en"||p.label==="English")||i.textTracks[0];y&&(y.mode="showing")}},[c,o,r])}function Ds({videoRef:r,videoBoxH:o,style:c,sourceKey:m,activeSubtitleTrack:T,availableSubtitles:i}){I(()=>{const s="dynamic-subtitle-styles";let n=document.getElementById(s);n||(n=document.createElement("style"),n.id=s,document.head.appendChild(n)),n.textContent=Ut(c);const a=r.current;if(!a)return;const y=Gt(c.fontSize,o||a.clientHeight||720);n.textContent=Ut({...c,fontSize:y});const p=()=>{const u=Number(c.position),P=isNaN(u)?0:Math.max(0,Math.min(100,u));return Math.max(0,Math.min(100,100-P))},h=(u,P)=>{try{const A=u;A.snapToLines=!1,A.line=P}catch{}},S=()=>{const u=y*16,P=a.videoHeight||a.clientHeight||720,A=a.videoWidth||a.clientWidth||1280;return{step:u*1.3/P*100,chars:Math.max(20,Math.floor(A/(u*.55)))}},C=u=>{const P=p(),A=Array.from(u.activeCues??[]);if(A.length<=1){A.forEach(b=>h(b,P));return}const{step:D,chars:q}=S();let f=P;for(let b=A.length-1;b>=0;b--){const G=String(A[b].text??"").replace(/<[^>]*>/g,"").split(`
55
- `).reduce((Y,O)=>Y+Math.max(1,Math.ceil(O.length/q)),0),z=f-G*D;h(A[b],Math.max(0,z)),f=z-D*.4}},e=u=>{if(!u.cues)return;const P=p();Array.from(u.cues).forEach(A=>h(A,P)),u.mode==="showing"&&C(u)},w=()=>{Array.from(a.textTracks).forEach(e)};w();const k=u=>{const P=u.target;P.mode==="showing"&&C(P)};Array.from(a.textTracks).forEach(u=>{u.addEventListener("cuechange",k)});const M=()=>{Array.from(a.textTracks).forEach(u=>{u.removeEventListener("cuechange",k),u.addEventListener("cuechange",k)}),w()};a.textTracks.addEventListener("addtrack",M),a.textTracks.addEventListener("removetrack",M);const x=Array.from(a.querySelectorAll("track")),v=()=>{w()};return x.forEach(u=>{u.addEventListener("load",v)}),()=>{Array.from(a.textTracks).forEach(u=>{u.removeEventListener("cuechange",k)}),a.textTracks.removeEventListener("addtrack",M),a.textTracks.removeEventListener("removetrack",M),x.forEach(u=>{u.removeEventListener("load",v)})}},[c,o,r,m,T,i])}function Fs({videoRef:r,overlayRef:o,style:c,activeSubtitleTrack:m,delayMs:T,enabled:i}){I(()=>{if(!i)return;const s=r.current,n=o.current;if(!s||!n)return;const a=J.getItem("playerSubtitlesEnabled")!=="false",y=()=>{if(n.innerHTML="",!a||m==="off"||m===null)return;const S=Array.from(s.textTracks).find(v=>v.language===m||v.label===m);if(!S||S.mode!=="showing")return;const C=T/1e3;let e;if(C>0&&S.cues){const v=s.currentTime-C;e=Array.from(S.cues).filter(u=>u.startTime<=v&&v<=u.endTime)}else e=Array.from(S.activeCues??[]);if(e.length===0)return;const w={...c,fontSize:Gt(c.fontSize,s.clientHeight||0)},k=Yr(w),M=Xr(s,w.position),x=Array.from(e);x.forEach((v,u)=>{const P=String(v.text??"");if(!Jr(P).trim())return;const A=document.createElement("div"),D=(x.length-1-u)*1.7;A.style.cssText=`${k}
56
- bottom: calc(${M}px + ${D}em);`,A.innerHTML=Zr(P),n.appendChild(A)})},p=()=>y(),h=()=>y();return Array.from(s.textTracks).forEach(S=>{S.addEventListener("cuechange",p)}),s.addEventListener("timeupdate",h),y(),()=>{Array.from(s.textTracks).forEach(S=>{S.removeEventListener("cuechange",p)}),s.removeEventListener("timeupdate",h),n.innerHTML=""}},[m,T,i,o,c,r])}const Is=({isOpen:r,onClose:o,onSuccess:c})=>{const m=()=>{c?.(),o()};return t(St,{isOpen:r,onClose:o,title:"MKissa Browser Verification",children:t("div",{className:Je.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:Je.actions,children:t("a",{className:Je.link,href:"https://mkissa.to/anime",target:"_blank",rel:"noreferrer",children:"Open MKissa anime"})}),t("div",{className:Je.actions,children:[t("button",{className:Je.secondaryButton,onClick:o,children:"Cancel"}),t("button",{className:Je.button,onClick:m,children:"Refresh Dango"})]})]})})},ro=()=>{const{id:r,episodeNumber:o}=kr(),c=Tr(),m=qt(),T=Cr(),i=Nr(),s=!!i.session,n=s&&!i.session?.host,{hasConsent:a,grant:y}=_r(),{options:p}=Ht(),h=_e(()=>p.filter(d=>(d.kind??"anime")==="anime"),[p]),S=_e(()=>h.map(d=>d.id),[h]),C=_e(()=>new Set(h.filter(d=>d.mature).map(d=>d.id)),[h]),{state:e,dispatch:w,toggleWatchlist:k,moveToCompleted:M,setPreferredSource:x,handleToggleDetails:v,resetEpisodeProgress:u,prefetchEpisodeSources:P,isResettingProgress:A,isUpdatingWatchlistStatus:D}=Ms(r,o,T.state||null,{hasMatureConsent:a,watchSelection:n?i.room?.selection:null});I(()=>{if(r&&e.showMeta?.id&&e.showMeta.id!==r){const d=o?`/watch/${e.showMeta.id}/${o}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;c(d,{replace:!0})}},[r,e.showMeta?.id,o,c]);const q=_e(()=>{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]),f=en({skipIntervals:e.skipIntervals,showId:r,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:q}),{refs:b,actions:W}=f,G=_e(()=>!r||r.startsWith("dango-mt-")||!e.currentEpisode||e.selectedSource?.type==="iframe"||!e.selectedLink?.hls||!e.selectedSource?null:{showId:r,episode:e.currentEpisode,provider:e.selectedProvider,mode:e.currentMode,source:e.selectedSource.sourceName,title:e.showMeta.name||r},[r,e.currentEpisode,e.selectedProvider,e.currentMode,e.selectedSource,e.selectedLink,e.showMeta.name]),z=tn(f.engine,G,e.loadingVideo||e.loadingShowData),Y=Sn(),O=R(null),L=R(null),H=R(null),[N,V]=ne(()=>{try{const d=J.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(d)?d:"balanced"}catch{return"balanced"}}),{videoDelayMs:se,videoDelayEnabled:$,setDelayEnabled:Ce,handleVideoDelayChange:Q,isCalibrating:l,testClipActive:g,stopCalibration:_,openAvSyncCalibrator:K,cancelAvSyncCalibrator:me,applyAvSyncCalibrator:ie,toggleTestClip:X,calibReturnRef:Ae,effectiveVideoDelayMs:le}=rn(b.videoRef,()=>W.setShowSettings(!1)),re=R(null),[ce,Re]=ne(!1),[pe,De]=ne(null);I(()=>{Re(!1),De(null)},[r,e.currentEpisode]);const Ke=`${r??""}:${e.currentEpisode??""}`,[lt,Ze]=ne(null);I(()=>{e.loadingVideo||e.videoSources.length===0||Ze(d=>d?.key===Ke?d:{key:Ke,watched:at(e.resumeTime,e.resumeDuration)})},[Ke,e.loadingVideo,e.videoSources.length,e.resumeTime,e.resumeDuration]);const Et=lt?.key===Ke&&lt.watched,[Le]=ne(gn),[fe,ct]=ne(!1);I(()=>{ct(!1)},[r,e.currentEpisode]);const ut=!s&&!g&&Et&&e.videoSources.length>0&&!ce,Fe=ut&&Le,et=ut&&!Le&&!fe,tt=U(()=>{De(null),Re(!0)},[]),F=U(()=>{De(e.resumeTime),Re(!0)},[e.resumeTime]),oe=Ss({videoRef:b.videoRef,canvasRef:L,profile:N,delayMs:le}),Ie=oe.isEnabled&&oe.isWebGPUSupported;Es({videoRef:b.videoRef,episodeKey:`${r??""}:${e.currentEpisode??""}`,isEnabled:oe.isEnabled,isSupported:oe.isWebGPUSupported,mediaReady:!e.loadingVideo&&!!e.selectedLink,isIframeSource:e.selectedSource?.type==="iframe",setEnabled:oe.setEnabled}),nn({videoRef:b.videoRef,canvasRef:re,delayMs:le,enabled:$&&!Ie});const be=$&&!Ie,rt=Ie||be,[qe,Oe]=ne(!1),je=R(o);I(()=>{je.current!==o&&(je.current=o,_())},[o,_]);const dt=U(()=>{m.invalidateQueries({queryKey:[ae.continueWatching]})},[m]),{data:Be=[],isLoading:mt}=Ar(),Ye=xr(),pt=Lr(),wt=Br(),{isTheaterMode:Se,toggleTheaterMode:ht,handleLayoutClick:j}=sn();Rr(()=>{if(f.state.isFullscreen||Se)return;const d=b.playerContainerRef.current,te=O.current;if(!d||!te)return;const ze=()=>{const Mt=d.getBoundingClientRect().height;te.style.height=`${Mt}px`};ze();const Ve=new ResizeObserver(ze);return Ve.observe(d),()=>Ve.disconnect()},[f.state.isFullscreen,Se,b.playerContainerRef]);const Z=_e(()=>e.episodes.findIndex(d=>d===e.currentEpisode),[e.episodes,e.currentEpisode]),Ee=Z>0?e.episodes[Z-1]:null,ee=Z>=0&&Z<e.episodes.length-1?e.episodes[Z+1]:null,ve=Z>-1&&Z<e.episodes.length-1,we=zt(e.showMeta?.status),ue=!ee&&we,Xe=!ee&&!ue,{showCompleteModal:We,queueCountdown:ke,pendingQueueTransition:de,handleQueueTransition:kt,handleNextEpisode:Ue,handleNShortcut:ye,handlePreviousEpisode:nt,handlePlaybackFinished:Jt,closeCompleteModal:ft,cancelQueueTransition:Zt}=Ns({testClipActive:g,selectedSourceType:e.selectedSource?.type,onEnded:W.onEnded,queue:Be,removeFromQueue:Ye.mutate,showId:r,showMetaId:e.showMeta?.id,showStatus:e.showMeta?.status,currentEpisode:e.currentEpisode,isAutoplayEnabled:!n&&e.isAutoplayEnabled,nextEpisode:ee,previousEpisode:Ee,navigate:c,invalidateContinueWatching:dt,dispatch:w}),{showNextEpisodePrompt:er,handleThresholds:Tt}=_s({videoRef:b.videoRef,queue:Be,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,selectedSource:e.selectedSource,hasNextEpisode:ve,nextEpisode:ee,prefetchEpisodeSources:P,matchesQueueItem:it}),{checkEnd:vt,logDuration:_t}=on({videoRef:b.videoRef,sourceType:e.selectedSource?.type,resetKey:`${r}:${e.currentEpisode}:${ce}`,onEnd:n?W.onEnded:Jt}),At=!s&&e.showResumeModal&&!e.resumeProgressPending,Qe=We&&Le,tr=We&&!Le,Ge=At||We||et;an(f,!!e.selectedLink&&!Se&&!Ge&&!Fe&&!Qe&&!et);const{fallbackPrompt:xt,isRetryingProvider:Lt,rememberFallbackChoice:rr,setRememberFallbackChoice:nr,fallbackChoice:sr,updateFallbackChoice:or,dismissFallbackPrompt:ir,chooseIframeFallback:ar,chooseProviderRetry:lr,handleVideoSourceError:Bt,resetFallback:$t}=Ls({showId:r,episodeNumber:e.currentEpisode??void 0,currentMode:e.currentMode,selectedProvider:e.selectedProvider,selectedSourceType:e.selectedSource?.type,videoSources:e.videoSources,isAdult:e.showMeta?.isAdult,providerOrder:S,matureProviders:C,setPreferredSource:x,showControls:W.setShowControls,dispatch:w}),{seekToTimeRef:Dt}=Bs({engine:f.engine,videoRef:b.videoRef,selectedSource:e.selectedSource,selectedLink:e.selectedLink,loadingVideo:e.loadingVideo,testClipActive:!s&&g,resumeTime:s?0:e.resumeTime,resumeDuration:e.resumeDuration,showResumeModal:!s&&e.showResumeModal,disabled:Fe||Qe,startOver:ce&&pe==null,resumeAt:pe,calibReturnRef:Ae,setAvailableSubtitles:W.setAvailableSubtitles,setActiveSubtitleTrack:W.setActiveSubtitleTrack,onFatalError:s?()=>{}:Bt});I(()=>{(Ge||Fe||Qe)&&f.state.isFullscreen&&f.actions.toggleFullscreen()},[Ge,Fe,Qe,f.state.isFullscreen,f.actions]),I(()=>{Ge&&b.videoRef.current&&b.videoRef.current.pause()},[Ge,b.videoRef]);const{titlePreference:gt}=$r(),{lowEndMode:cr}=Dr(),{settings:Ct,update:ur}=ln(),dr=Se&&Ct.enabled&&!cr&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,$e=_e(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:d,names:te}=e.showMeta;return gt==="name"?d||"Loading...":gt==="nativeName"?te?.native||d||"Loading...":gt==="englishName"?te?.english||d||"Loading...":d||"Loading..."},[e.showMeta,gt,e.loadingShowData]);I(()=>{$e&&$e!=="Loading..."&&e.currentEpisode&&(document.title=`► ${$e} Episode ${e.currentEpisode} - dango`)},[$e,e.currentEpisode]),Ps({onPrevious:n?()=>{}:nt,onNext:n?()=>{}:ye,onToggleTheater:ht,flashControls:f.actions.flashControls});const{setAvailableSubtitles:mr,setActiveSubtitleTrack:pr}=W,Ft=_e(()=>({fontSize:f.state.subtitleFontSize,position:f.state.subtitlePosition,bgOpacity:f.state.subtitleBgOpacity,bgColor:f.state.subtitleBgColor,textColor:f.state.subtitleTextColor,edge:f.state.subtitleEdge,bold:f.state.subtitleBold}),[f.state.subtitleFontSize,f.state.subtitlePosition,f.state.subtitleBgOpacity,f.state.subtitleBgColor,f.state.subtitleTextColor,f.state.subtitleEdge,f.state.subtitleBold]);$s({videoRef:b.videoRef,availableSubtitles:f.state.availableSubtitles,activeSubtitleTrack:f.state.activeSubtitleTrack,setAvailableSubtitles:mr,setActiveSubtitleTrack:pr});const[hr,fr]=ne(0);I(()=>{const d=b.videoRef.current;if(!d)return;const te=()=>fr(d.clientHeight||0);te();const ze=new ResizeObserver(te);return ze.observe(d),()=>ze.disconnect()},[b.videoRef,e.selectedSource,e.selectedLink]),Ds({videoRef:b.videoRef,videoBoxH:hr,style:Ft,sourceKey:`${e.selectedSource?.sourceName??""}:${e.selectedLink?.link??""}`,activeSubtitleTrack:f.state.activeSubtitleTrack,availableSubtitles:f.state.availableSubtitles}),Fs({videoRef:b.videoRef,overlayRef:H,style:Ft,activeSubtitleTrack:f.state.activeSubtitleTrack,delayMs:le,enabled:rt}),I(()=>{try{J.setItem("anime4kProfile",N)}catch{}},[N]);const vr=()=>{b.videoRef.current&&(b.videoRef.current.currentTime=e.resumeTime,b.videoRef.current.play()),w({type:"SET_STATE",payload:{showResumeModal:!1}})},gr=()=>{b.videoRef.current&&(b.videoRef.current.currentTime=0,b.videoRef.current.play()),w({type:"SET_STATE",payload:{showResumeModal:!1}})},yr=U(()=>{w({type:"SET_STATE",payload:{showResumeModal:!1}})},[w]),Rt=U(async()=>{try{await M(),ft(),w({type:"SET_STATE",payload:{showResumeModal:!1}}),c("/")}catch{}},[M,ft,w,c]),It=(d,te)=>t("div",{className:d,children:[t("button",{className:`${E.episodeNavBtn} ${E.secondary}`,onClick:nt,disabled:n||!Ee,type:"button",children:[t(ge,{name:"chevron-left",size:12}),"Prev EP"]}),t("button",{className:`${E.episodeNavBtn} ${E.primary}`,onClick:Ue,disabled:n||!ee,type:"button",children:["Next EP",t(ge,{name:"chevron-right",size:12})]}),te==="mobile"&&Y&&t("button",{className:`${E.episodeNavBtn} ${E.episodePickerBtn}`,onClick:()=>Oe(!0),type:"button",children:[t(ge,{name:"list-ul",size:12}),"Episodes"]})]}),br=d=>{w({type:"SET_STATE",payload:{isAutoplayEnabled:d}}),yn(d)};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 Me=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!a?t("div",{className:Ne.playerPageLayout,children:t(bn,{isOpen:!0,onClose:()=>c("/home"),onGrant:y})}):t("div",{className:`${Ne.playerPageLayout} ${Se?Ne.theaterMode:""}`,onClick:j,children:[Se&&t(cn,{videoRef:b.videoRef,active:dr,settings:Ct}),t(Qt,{isOpen:tr,onClose:ft,title:"Show Completed!",heading:$e,message:"Congratulations! You finished all available episodes.",children:t(Pe,{onClick:Rt,disabled:D,children:D?"Saving...":"Move to Completed"})}),t(Qt,{isOpen:et,onClose:()=>ct(!0),title:ue?"Show Completed!":"Episode Completed",heading:e.currentEpisode?`Episode ${e.currentEpisode}`:$e,message:ue?"Congratulations! You finished all available episodes.":"You've already watched this episode. Resume where you left off, replay it, or continue with the next episode.",children:[e.resumeTime>5&&t(Pe,{variant:Xe?void 0:"secondary",onClick:F,children:`Resume ${Ot(e.resumeTime)}`}),t(Pe,{variant:"secondary",onClick:tt,children:"Replay"}),ee&&t(Pe,{onClick:Ue,children:`Watch EP ${ee}`}),ue&&t(Pe,{onClick:Rt,disabled:D,children:D?"Saving...":"Move to Completed"})]}),t(un,{isOpen:At,onClose:yr,title:"Resume Playback?",message:t(st,{children:["You were watching at ",t("strong",{children:f.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:vr,onRestart:gr}),t(St,{isOpen:!!xt,onClose:ir,title:"Direct stream failed",width:"sm",children:[t(St.Body,{children:[t("p",{children:[t("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),xt?.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:rr,onChange:d=>nr(d.currentTarget.checked)}),"Remember my choice"]})]}),t(St.Actions,{children:[t(Pe,{variant:"secondary",onClick:ar,children:"Continue with iframe"}),t(Pe,{onClick:lr,disabled:Lt,children:Lt?"Searching…":"Try another provider"})]})]}),t(Fr,{isOpen:!!e.showCookieModal&&e.cookieProvider!=="mkissa",onClose:()=>w({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{m.invalidateQueries({queryKey:[ae.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),t(Is,{isOpen:!!e.showCookieModal&&e.cookieProvider==="mkissa",onClose:()=>w({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{m.invalidateQueries({queryKey:[ae.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!Se&&t("aside",{ref:O,className:Ne.episodeSidebar,children:e.loadingShowData?t(dn,{variant:"sidebar"}):t(mn,{episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:d=>{n||c(`/watch/${r}/${d}`)}})}),t("div",{className:Ne.playerMain,children:[t("div",{className:`${E.videoContainer} ${f.state.isFullscreen?"":Ne.videoPlayerWrapper} ${f.state.isFullscreen?E.fullscreenActive:""}`,style:{...Ge?{visibility:"hidden"}:{}},onContextMenu:d=>d.preventDefault(),children:t(as,{player:f,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:br,fallbackChoice:sr,onFallbackChoiceChange:or,ambientSettings:Ct,onAmbientChange:ur,showNextEpisodeButton:!n&&!Ge&&er&&Be.length===0,onNextEpisode:Ue,videoSources:n?[]:s?e.videoSources.filter(d=>d.type!=="iframe"&&d.links.some(te=>te.hls)):e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(d,te)=>{n&&d.sourceName!==i.room?.selection.source||s&&(d.type==="iframe"||!te.hls)||(b.videoRef.current&&!isNaN(b.videoRef.current.currentTime)&&(Dt.current=b.videoRef.current.currentTime),x(d.sourceName),w({type:"SET_STATE",payload:{selectedSource:d,selectedLink:te,showResumeModal:e.showResumeModal&&d.type!=="iframe"}}))},loadingVideo:Me,skipIntervals:e.skipIntervals,animeTitle:$e,episodeNumber:e.currentEpisode??void 0,mode:e.currentMode,isTheaterMode:Se,onTheaterModeToggle:ht,anime4kEnabled:oe.isEnabled,onAnime4kToggle:oe.toggle,anime4kSupported:oe.isWebGPUSupported,anime4kProfile:N,onAnime4kProfileChange:V,anime4kInitializing:oe.isInitializing,anime4kError:oe.error,videoDelayEnabled:$,onVideoDelayToggle:Ce,videoDelayMs:se,onVideoDelayChange:Q,onCalibrateAvSync:s?()=>{}:K,isInteractingExtra:qe||l,className:Kr.shellFill,hideChrome:Fe||Qe||e.selectedSource?.type==="iframe",overlays:t(st,{children:[f.state.isSpeedBoostActive&&t("div",{className:E.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(ge,{name:"forward",size:12})]}),ke!==null&&de?.nextItem&&t("div",{className:E.queueCountdown,children:["Queue next in ",ke,"s"]})]}),children:t(st,{children:[Me&&t("div",{className:E.loadingOverlay,children:t("div",{className:E.loadingDots,children:[t("div",{className:E.dot}),t("div",{className:E.dot}),t("div",{className:E.dot})]})}),f.state.isBuffering&&!Me&&e.selectedSource?.type!=="iframe"&&t("div",{className:E.bufferingOverlay,children:t("div",{className:E.bufferingSpinner})}),e.selectedSource?.type==="iframe"&&!s?!Me&&t("iframe",{src:e.selectedLink?.link,className:E.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(st,{children:[!Me&&e.videoSources.length===0&&t("div",{className:E.errorOverlay,children:[t("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),t("p",{className:E.errorSubtext,children:"Please try selecting a different provider below."}),t("button",{className:E.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Me&&e.videoSources.length>0&&t(qr,{controls:!f.state.playbackLocked&&f.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:W.onPlay,onPause:W.onPause,onEnded:()=>{g||vt(!0)},onDurationChange:()=>{_t()},onSeeked:()=>{g||(Tt(),vt())},onLoadedMetadata:()=>{Tt(),_t(),g||vt()},onTimeUpdate:()=>{g||(W.onTimeUpdate(),Tt(),vt(),de&&b.videoRef.current&&b.videoRef.current.currentTime<b.videoRef.current.duration-1&&Zt())},onError:s?void 0:Bt,onContextMenu:d=>d.preventDefault(),className:rt?E.videoElementHidden:""}),oe.isWebGPUSupported&&!Me&&e.videoSources.length>0&&t("canvas",{ref:L,className:`${E.upscalerCanvas} ${Ie?E.upscalerActive:""}`}),!Ie&&!Me&&e.videoSources.length>0&&t("canvas",{ref:re,className:`${E.upscalerCanvas} ${be?E.upscalerActive:""}`}),oe.isEnabled&&oe.isWebGPUSupported&&oe.isInitializing&&t("div",{className:E.upscalerStatusBadge,children:"Preparing upscaler…"}),rt&&t("div",{ref:H,className:E.subtitleOverlay}),t(pn,{isOpen:l,ms:se,onChange:Q,onApply:ie,onClose:me,testClipActive:g,onTestClip:X})]}),(Fe||Qe)&&t("div",{className:E.watchedOverlay,children:[t(ge,{name:"check-circle",size:48,style:{color:"var(--accent-lighter)"}}),t("p",{className:E.watchedTitle,children:ue?"Show Completed!":e.currentEpisode?`Episode ${e.currentEpisode} watched`:"Watched"}),t("p",{className:E.watchedSubtext,children:ue?"Congratulations! You finished all available episodes.":"Resume where you left off, replay from the beginning, or continue with the next episode."}),t("div",{className:`${E.watchedActions} ${Qe?E.watchedActionsCentered:""}`,children:[t("div",{children:e.resumeTime>5&&!Qe&&t(Pe,{variant:Xe?void 0:"secondary",onClick:F,children:`Resume ${Ot(e.resumeTime)}`})}),t("div",{children:[ee&&t(Pe,{onClick:Ue,children:`Watch EP ${ee}`}),ue&&t(Pe,{onClick:Rt,disabled:D,children:D?"Saving...":"Move to Completed"})]}),t("div",{children:t(Pe,{variant:"secondary",onClick:()=>{ft(),tt()},children:"Replay"})})]})]})]})})}),t(Rn,{playback:G&&!Me?{selection:G,position:b.videoRef.current?.currentTime||0,playing:!1,rate:f.engine.getState().playbackRate}:null,onCreate:()=>{_(),f.engine.pause()},needsPlayback:z.needsPlayback,onEnablePlayback:z.enablePlayback}),s&&!Me&&!G&&t("p",{role:"alert",children:"This room requires the host's direct HLS source. It is unavailable here. Retry the episode or leave the room to use another source."}),!Se&&t(hn,{}),!Se&&t(st,{children:[mt&&Be.length===0?t(ls,{count:3}):t(En,{title:"Queue",items:Be,currentShowId:r,currentEpisode:e.currentEpisode??void 0,onNextQueue:n?()=>{}:kt,onRemove:d=>Ye.mutate({showId:d.showId,episodeNumber:d.episodeNumber}),onClear:()=>pt.mutate(),showClearAll:!0,onReorder:d=>wt.mutate(d.map(te=>({id:te.id,showId:te.showId,episodeNumber:te.episodeNumber})))}),t("div",{className:E.streamPanel,children:[!n&&t(ms,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:h,onProviderChange:d=>{$t(),w({type:"SET_STATE",payload:{selectedProvider:d,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Xt(d,e.showMeta?.isAdult===!0)}}),It(`${E.episodeActions} ${E.desktopEpisodeActions}`,"desktop"),Me?t("div",{className:E.sourceLoader,children:t("div",{className:E.spinner})}):n?t("p",{children:["Provider: ",e.selectedProvider," · Source: ",i.room?.selection.source," ·"," ",e.currentMode]}):t(hs,{videoSources:s?e.videoSources.filter(d=>d.type!=="iframe"&&d.links.some(te=>te.hls)):e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:d=>{if(s&&(d.type==="iframe"||!d.links.some(Ve=>Ve.hls)))return;b.videoRef.current&&!isNaN(b.videoRef.current.currentTime)&&(Dt.current=b.videoRef.current.currentTime);const ze=(s?d.links.filter(Ve=>Ve.hls):d.links||[]).sort((Ve,Mt)=>(parseInt(Mt.resolutionStr)||0)-(parseInt(Ve.resolutionStr)||0))[0]||null;x(d.sourceName),w({type:"SET_STATE",payload:{selectedSource:d,selectedLink:ze,showResumeModal:e.showResumeModal&&d.type!=="iframe"}})},onLinkChange:d=>{e.selectedSource&&(x(e.selectedSource.sourceName),w({type:"SET_STATE",payload:{selectedLink:d}}))}})]}),t("div",{className:Ne.playerInfoContainer,children:[t("div",{className:Ne.playerInfoHeader,children:[t("div",{className:Ne.playerAnimeCard,children:t(Ir,{src:Or(e.showMeta.thumbnail||""),alt:$e,loading:"lazy",decoding:"async",onError:d=>{d.target.src="/placeholder.svg"}})}),t("div",{className:Ne.videoTitleSection,children:[t("div",{className:E.titleContainer,children:[t("h1",{children:$e}),t("div",{className:E.scheduleInfo,children:[e.showMeta.status&&t("span",{className:E.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&t("span",{className:E.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),t("div",{className:E.controls,children:[t("button",{className:`${E.watchlistBtn} ${e.inWatchlist?E.inList:""}`,onClick:k,children:[e.inWatchlist?t(ge,{name:"check",size:14}):t(ge,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),t(kn,{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:`${E.watchlistBtn} ${E.queueBtn}`,activeClassName:E.queueActive}),t("button",{className:`${E.watchlistBtn} ${E.modeToggleBtn} ${e.currentMode==="dub"?E.modeToggleActive:""}`,disabled:n,onClick:()=>{const d=e.currentMode==="dub"?"sub":"dub";$t(),w({type:"SET_MODE",payload:d}),J.setItem("preferredMode",d)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),t("button",{className:`${E.watchlistBtn} ${E.modeToggleBtn}`,onClick:()=>e.currentEpisode&&u(e.currentEpisode),disabled:A||!e.currentEpisode,type:"button",children:[t(ge,{name:"undo",size:14}),A?"Resetting...":"Reset Progress"]})]})]})]}),It(`${E.episodeActions} ${E.mobileEpisodeActions}`,"mobile"),t("div",{className:Ne.infoColumns,children:[t("div",{className:`${E.descriptionSection} ${E.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t(Cn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."}),t("button",{className:E.detailsToggleBtn,onClick:v,children:[e.showCombinedDetails?t(ge,{name:"chevron-up"}):t(ge,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]})]}),e.showCombinedDetails&&t(Tn,{showMeta:e.showMeta,styles:E})]})]})]})]}),t(fn,{isOpen:qe,onClose:()=>Oe(!1),episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:d=>{Oe(!1),c(`/watch/${r}/${d}`)}})]})};export{ro as default};
@@ -1 +0,0 @@
1
- import{X as Ee,x as we,u as d,A as x,q as de,h as X,d as ae,T as oe,_ as Te,C as me}from"./vendor-core-DfaOB3Rn.js";import{I as te}from"./vendor-icons-C1Pj_eSX.js";import{a2 as Pe,p as pe,h as be}from"./index-BVkDKnzf.js";const ye=Ee(null);function j(){const n=we(ye);if(!n)throw new Error("Player controls must be inside a PlayerProvider.");return n}function ve(n,i){const t=j(),r=x(i);r.current=i;const l=n?.url,m=n?.hls,s=de(k=>{t.mediaRef.current=k,t.connect()},[t]);return X(()=>{if(l)return t.loadSource({url:l,hls:m},r.current)},[t,l,m]),s}function Ye({source:n,sourceOptions:i,...t}){const r=ve(n,i);return d("video",{playsInline:!0,...t,ref:r})}function Ze({source:n,sourceOptions:i,...t}){const r=ve(n,i);return d("audio",{...t,ref:r})}const Se="_shell_qjnah_1",Le="_stage_qjnah_38",Fe="_topBarTitleInfo_qjnah_59",_e="_streamDetails_qjnah_65",Re="_modeTag_qjnah_86",Me="_shellFill_qjnah_122",xe="_shellFullscreen_qjnah_130",Ce="_uiLayer_qjnah_145",Be="_engineStatus_qjnah_156",Ae="_volumeWrap_qjnah_169",De="_volumeSlider_qjnah_175",se={shell:Se,stage:Le,topBarTitleInfo:Fe,streamDetails:_e,modeTag:Re,shellFill:Me,shellFullscreen:xe,uiLayer:Ce,engineStatus:Be,volumeWrap:Ae,volumeSlider:De},Ie=({classes:n,videoRef:i,duration:t,formatTime:r,isScrubbing:l,buffered:m="auto",onSeek:s,onScrubStart:k,onScrubMove:v,onScrubEnd:_,timeLabelRef:E,children:w})=>{const p=x(null),S=x(null),P=x(null),g=x(null),h=x(null),a=x(!1),f=x(l);f.current=l;const b=x({onScrubMove:v,onScrubEnd:_});b.current={onScrubMove:v,onScrubEnd:_};const[A,$]=ae({time:0,position:null});X(()=>{const c=i.current;if(!c)return;const y=C=>{const V=C/t*100||0;p.current?.setAttribute("aria-valuenow",String(Math.round(C))),p.current?.setAttribute("aria-valuetext",`${r(C)} of ${r(t)}`),S.current&&(S.current.style.width=`${V}%`),P.current&&(P.current.style.left=`${V}%`),E?.current&&(E.current.innerText=`${r(C)} / ${r(t)}`)},R=()=>{l||y(c.currentTime)},D=()=>{if(m==="auto"&&c.buffered.length>0){const V=c.buffered.end(c.buffered.length-1)/t*100||0;g.current&&(g.current.style.width=`${V}%`)}};return y(c.currentTime),D(),c.addEventListener("timeupdate",R),c.addEventListener("progress",D),()=>{c.removeEventListener("timeupdate",R),c.removeEventListener("progress",D)}},[i,t,l,m,r,E]);const I=c=>{if(!p.current)return 0;const y=p.current.getBoundingClientRect();return y.width<=0?0:Math.min(1,Math.max(0,(c-y.left)/y.width))},Q=c=>{const y=c*t;p.current?.setAttribute("aria-valuenow",String(Math.round(y))),p.current?.setAttribute("aria-valuetext",`${r(y)} of ${r(t)}`);const R=y/t*100||0;S.current&&(S.current.style.width=`${R}%`),P.current&&(P.current.style.left=`${R}%`),E?.current&&(E.current.innerText=`${r(y)} / ${r(t)}`);const D=p.current?.getBoundingClientRect();$({time:y,position:D?c*D.width:null})};X(()=>{if(!l){h.current=null;return}const c=R=>{if(h.current!==null&&R.pointerId!==h.current||!t)return;const D=I(R.clientX);b.current.onScrubMove(D);const C=D*t;p.current?.setAttribute("aria-valuenow",String(Math.round(C))),p.current?.setAttribute("aria-valuetext",`${r(C)} of ${r(t)}`);const V=C/t*100||0;S.current&&(S.current.style.width=`${V}%`),P.current&&(P.current.style.left=`${V}%`),E?.current&&(E.current.innerText=`${r(C)} / ${r(t)}`);const e=p.current?.getBoundingClientRect();$({time:C,position:e?D*e.width:null})},y=R=>{h.current!==null&&R.pointerId!==h.current||(h.current=null,a.current=!0,R.pointerType!=="mouse"&&$({time:0,position:null}),b.current.onScrubEnd())};return document.addEventListener("pointermove",c),document.addEventListener("pointerup",y),document.addEventListener("pointercancel",y),()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",y),document.removeEventListener("pointercancel",y)}},[l,t,r,E]);const ne=c=>{if(c.pointerType==="mouse"&&c.button!==0||!i.current||!t)return;c.preventDefault(),h.current=c.pointerId;try{p.current?.setPointerCapture(c.pointerId)}catch{}f.current||(f.current=!0,k());const y=I(c.clientX);v(y),Q(y)},G=c=>{if(!t||f.current||c.pointerType!=="mouse")return;const y=I(c.clientX);$({time:y*t,position:c.clientX-(p.current?.getBoundingClientRect().left??0)})},Z=c=>{if(!(h.current!==null&&c.pointerId!==h.current)&&f.current){h.current=null,a.current=!0,c.pointerType!=="mouse"&&$({time:0,position:null});try{p.current?.hasPointerCapture(c.pointerId)&&p.current.releasePointerCapture(c.pointerId)}catch{}_()}};return d("div",{className:`${n.container} ${l&&n.scrubbing?n.scrubbing:""}`,ref:p,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:c=>{if(a.current){a.current=!1;return}!i.current||isNaN(t)||t===0||s(I(c.clientX))},onPointerDown:ne,onPointerMove:G,onPointerUp:Z,onPointerCancel:Z,onMouseMove:c=>{if(l||!t)return;const y=I(c.clientX);$({time:y*t,position:c.clientX-(p.current?.getBoundingClientRect().left??0)})},onMouseLeave:()=>{l||$({time:0,position:null})},onKeyDown:c=>{if(!(!i.current||!t)&&((c.key==="Home"||c.key==="End")&&(c.preventDefault(),s(c.key==="Home"?0:1)),c.key==="ArrowRight"||c.key==="ArrowLeft")){c.preventDefault();const y=(c.key==="ArrowRight"?5:-5)/t,R=i.current.currentTime/t||0;s(Math.min(1,Math.max(0,R+y)))}},children:[A.position!==null&&d("div",{className:n.timeBubble,style:{left:A.position},children:r(A.time)}),d("div",{className:n.bar,children:[d("div",{className:n.buffered,ref:g,style:m==="full"?{width:"100%"}:void 0}),d("div",{className:n.watched,ref:S}),d("div",{className:n.thumb,ref:P,onMouseDown:c=>{c.preventDefault(),i.current&&(f.current||k())}}),w]})]})};function re(){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]=ae(re);return X(()=>{i(re());let t=null;const r=()=>i(re());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 Ne=450,qe=({muted:n,volume:i,volumeIcon:t,buttonClassName:r,sliderClassName:l,onToggleMute:m,onVolumeChange:s,onExpandedChange:k})=>{const v=$e(),[_,E]=ae(!1),w=x(null),p=x(!1),S=x(null),P=de(b=>{E(b),k?.(b)},[k]);X(()=>()=>{w.current&&window.clearTimeout(w.current)},[]),X(()=>{if(!_)return;const b=A=>{S.current&&!S.current.contains(A.target)&&P(!1)};return document.addEventListener("pointerdown",b),()=>document.removeEventListener("pointerdown",b)},[_,P]);const g=n?0:i,h=()=>{p.current=!1,w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{p.current=!0,P(!0)},Ne)},a=()=>{w.current&&(window.clearTimeout(w.current),w.current=null)},f=b=>{if(b.stopPropagation(),p.current){p.current=!1;return}if(v){_?m():P(!0);return}m()};return d("div",{ref:S,className:se.volumeWrap,"data-expanded":_?"true":"false",onContextMenu:b=>b.preventDefault(),children:[d("button",{type:"button",className:r,onClick:f,onPointerDown:h,onPointerUp:a,onPointerLeave:a,onContextMenu:b=>b.preventDefault(),"aria-label":n?"Unmute":"Mute","aria-expanded":_,children:t}),d("input",{type:"range",min:"0",max:"1",step:"0.05",value:g,onChange:b=>s(parseFloat(b.currentTarget.value)),onClick:b=>b.stopPropagation(),onPointerDown:b=>b.stopPropagation(),onContextMenu:b=>b.preventDefault(),className:`${se.volumeSlider} ${l??""}`,style:{"--volume-percent":`${g*100}%`},"aria-label":"Volume"})]})};let ee=null,ie=null;async function je(){return ee||(ie||(ie=Pe(()=>import("./hls-BOLXTnjL.js"),[]).then(n=>(ee=n.default,ee)).catch(()=>null)),ie)}function Ve(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 ke(n){return le(n)!==null}async function Ue(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 He(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 Ke(n,i){!n&&!i||(ke(i)?await He(i):n&&await Ue(n,i))}function Oe(n,i){const t=()=>{try{i(ke(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 H=null;function fe(n){try{return n?pe.getItem(n):null}catch{return null}}function Y(n,i){try{n&&pe.setItem(n,String(i))}catch{}}function We(n={}){const i=Number.parseFloat(fe(n.volumeKey)??"");let t={isPlaying:!1,isBuffering:!1,isMuted:fe(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,playbackLocked:!1},r={currentTime:0,bufferedEnd:0};const l=new Set,m=new Set,s={current:null},k={current:null};let v=null,_=()=>{},E=()=>{},w=0,p=!1,S=1,P=!1,g=null,h=!1;function a(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 b(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 A(){b(s.current)}function $(){const e=s.current;if(v===e||(v&&(H===v&&(H=e),b(v),E(),v.pause(),v.removeAttribute("src"),v.load()),_(),v=e,!e))return;P=!1,H||(H=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 U=T.findIndex(W=>W.mode==="showing");a({subtitleTracks:T.map((W,z)=>({id:z,label:W.label||W.language||`Track ${z+1}`,language:W.language})),...U>=0?{activeSubtitleTrack:U}:{}})},o={play:()=>{H=e,a({isPlaying:!0,playBlocked:!1,error:null})},playing:()=>a({isPlaying:!0,isBuffering:!1,playBlocked:!1}),pause:()=>a({isPlaying:!1,isBuffering:!1}),ended:()=>{a({isPlaying:!1,isBuffering:!1}),A()},waiting:()=>{!e.paused&&(e.readyState<3||e.seeking)&&a({isBuffering:!0})},canplay:()=>a({isBuffering:!1}),seeking:()=>{e.paused||a({isBuffering:!0}),A()},seeked:()=>{a({isBuffering:!1}),A()},timeupdate:()=>{A(),!e.paused&&!e.seeking&&a({isBuffering:!1})},progress:A,loadedmetadata:()=>{e.playbackRate=t.playbackRate,a({duration:Number.isFinite(e.duration)?e.duration:0}),u()},durationchange:()=>a({duration:Number.isFinite(e.duration)?e.duration:0}),ratechange:()=>{t.isSpeedBoostActive||(S=e.playbackRate),e.defaultPlaybackRate!==e.playbackRate&&(e.defaultPlaybackRate=e.playbackRate),a({playbackRate:e.playbackRate})},volumechange:()=>{a({volume:e.volume,isMuted:e.muted}),Y(n.volumeKey,e.volume),Y(n.mutedKey,e.muted)},error:()=>a({error:e.error?.message||"Unable to play this source.",isPlaying:!1,isBuffering:!1})};Object.entries(o).forEach(([T,U])=>e.addEventListener(T,U)),e.textTracks.addEventListener("addtrack",u),e.textTracks.addEventListener("removetrack",u),e.textTracks.addEventListener("change",u);const L=()=>e.tagName==="VIDEO"?e:null,O=()=>{const T=le(L());a({isFullscreen:T!==null&&(T===e||T===k.current)})},B=typeof document>"u"?()=>{}:Oe(L,O);typeof document<"u"&&O(),_=()=>{Object.entries(o).forEach(([T,U])=>e.removeEventListener(T,U)),B(),e.textTracks.removeEventListener("addtrack",u),e.textTracks.removeEventListener("removetrack",u),e.textTracks.removeEventListener("change",u)}}async function I(){if(t.playbackLocked&&!h)return!1;const e=s.current;if(!e)return!1;H=e;const u=w;try{return await e.play(),u===w}catch(o){if(u===w){const L=o instanceof Error&&o.name==="NotAllowedError",O=o instanceof Error&&o.name==="AbortError";a({isPlaying:!1,isBuffering:!1,playBlocked:L,...!L&&!O?{error:o instanceof Error?o.message:"Playback failed."}:{}})}return!1}}function Q(){t.playbackLocked&&!h||s.current?.pause()}function ne(){s.current?.paused?I():Q()}function G(e){if(t.playbackLocked&&!h)return;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,A()}function Z(e){G((s.current?.currentTime??r.currentTime)+e)}function c(e){if(!Number.isFinite(e))return;const u=Math.max(0,Math.min(1,e));a({volume:u,isMuted:u===0}),s.current&&(s.current.volume=u,s.current.muted=u===0),Y(n.volumeKey,u),Y(n.mutedKey,u===0)}function y(){const e=!t.isMuted;!e&&t.volume===0&&c(.5),a({isMuted:e}),s.current&&(s.current.muted=e),Y(n.mutedKey,e)}function R(e){if(t.playbackLocked&&!h||!Number.isFinite(e)||e<.25||e>4)return;S=e;const u=t.isSpeedBoostActive?2:e;a({playbackRate:u}),s.current&&(s.current.playbackRate=u)}function D(){t.playbackLocked||t.isScrubbing||(p=!!s.current&&!s.current.paused,a({isScrubbing:!0}),Q())}function C(){t.isScrubbing&&(a({isScrubbing:!1}),p&&I(),p=!1)}function V(e,u={}){E(),$();const o=s.current,L=++w;if(!o)return()=>{};let O=!1,B=null;const T=()=>!O&&w===L&&s.current===o;o.pause(),o.removeAttribute("src"),o.load(),a({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 U=()=>{T()&&u.initialTime&&u.initialTime>0&&G(u.initialTime)};o.addEventListener("loadedmetadata",U,{once:!0});const W=()=>{T()&&(u.onReady?.(),u.autoPlay&&T()&&I())},z=F=>{if(!T())return;const N=F instanceof Error?F:new Error(String(F));a({error:N.message,isPlaying:!1,isBuffering:!1}),u.onError?.(N)},J=()=>{O||(O=!0,o.removeEventListener("loadedmetadata",U),o.removeEventListener("error",ce),B?.destroy(),g===B&&(g=null),B=null,w===L&&w++)},ce=()=>{z(new Error(o.error?.message||"Unable to play this source.")),J()};return o.addEventListener("error",ce),E=J,(async()=>{if(e.hls){const F=await je();if(!T())return;if(F?.isSupported()){B=new F({enableWorker:!0,startPosition:u.initialTime??-1,...u.hlsConfig}),g=B;const N=B,he=()=>{T()&&a({audioTracks:N.audioTracks.map((M,q)=>({id:q,label:M.name||M.lang||`Track ${q+1}`,language:M.lang})),...o.querySelector("track")?{}:{subtitleTracks:N.subtitleTracks.map((M,q)=>({id:q,label:M.name||M.lang||`Track ${q+1}`,language:M.lang}))},qualities:N.levels.map((M,q)=>({id:q,label:M.height?`${M.height}p`:`${Math.round(M.bitrate/1e3)}k`})),activeAudioTrack:N.audioTrack,...o.querySelector("track")?{}:{activeSubtitleTrack:N.subtitleTrack},activeQuality:N.currentLevel})};for(const M 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])N.on(M,he);if(B.on(F.Events.ERROR,(M,q)=>{q.fatal&&T()&&(z(new Error(`Stream failed (${q.details}). Try another source or reload.`)),J())}),B.once(F.Events.MANIFEST_PARSED,W),u.onHls?.(B,F),!T())return;B.loadSource(e.url),B.attachMedia(o);return}if(!Ve(o))throw new Error("HLS playback is unavailable in this browser.")}T()&&(o.src=e.url,o.load(),W())})().catch(F=>{z(F),J()}),J}return{mediaRef:s,containerRef:k,connect:$,getState:()=>t,getTimeline:()=>r,getHls:()=>g,isActive:()=>H===s.current,subscribe:e=>(l.add(e),()=>{l.delete(e)}),subscribeTimeline:e=>(m.add(e),()=>{m.delete(e)}),play:I,pause:Q,togglePlay:ne,seek:G,seekRelative:Z,setVolume:c,toggleMute:y,setPlaybackRate:R,setPlaybackLocked:e=>a({playbackLocked:e}),applyRemotePlayback:(e,u,o)=>{h=!0;try{e!==void 0&&G(e),Math.abs(t.playbackRate-o)>.001&&R(o),u&&s.current?.paused?I():!u&&!s.current?.paused&&Q()}finally{h=!1}},setAudioTrack:e=>{g&&t.audioTracks.some(u=>u.id===e)&&(g.audioTrack=e,a({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"}):g&&(g.subtitleTrack=e),a({activeSubtitleTrack:e})},setQuality:e=>{g&&(e===-1||t.qualities.some(u=>u.id===e))&&(g.currentLevel=e,a({activeQuality:e}))},setSpeedBoost:e=>{if(t.playbackLocked)return;const u=e?2:S;a({isSpeedBoostActive:e,playbackRate:u}),s.current&&(s.current.playbackRate=u)},setShowControls:e=>a({showControls:e}),startScrubbing:D,endScrubbing:C,loadSource:V,unload:()=>{const e=s.current;b(e),E(),e&&(e.pause(),e.removeAttribute("src"),e.load()),a({isPlaying:!1,isBuffering:!1,duration:0,error:null}),f({currentTime:0,bufferedEnd:0})},toggleFullscreen:()=>{const e=s.current;Ke(k.current,e?.tagName==="VIDEO"?e:null).catch(u=>a({error:u instanceof Error?u.message:"Fullscreen failed."}))},reset:()=>{a({duration:0,isBuffering:!1,error:null}),f({currentTime:0,bufferedEnd:0})},destroy:()=>{if(P)return;P=!0;const e=v??s.current;b(e),_(),v=null,E(),e?.pause(),e?.removeAttribute("src"),e?.load(),H===e&&(H=null)}}}function K(n){return me(n.subscribe,n.getState)}function ge(n){return me(n.subscribeTimeline,n.getTimeline)}function et(n={}){const i=x(n),t=oe(()=>We(i.current),[]);return Te(()=>{t.connect()}),X(()=>()=>t.destroy(),[t]),oe(()=>({engine:t,mediaRef:t.mediaRef}),[t])}function Xe({children:n,...i}){const t=j(),{isPlaying:r,playbackLocked:l}=K(t);return d("button",{type:"button","aria-label":r?"Pause":"Play",...i,disabled:l||i.disabled,onClick:t.togglePlay,children:n??d(te,{name:r?"pause":"play"})})}function tt({seconds:n,children:i,...t}){const r=j(),{playbackLocked:l}=K(r);return d("button",{type:"button","aria-label":`Seek ${n<0?"back":"forward"} ${Math.abs(n)} seconds`,...t,disabled:l||t.disabled,onClick:()=>r.seekRelative(n),children:i??d(te,{name:n<0?"replay-10":"forward-10"})})}function nt(n){const i=j(),{isFullscreen:t}=K(i);return d("button",{type:"button","aria-label":t?"Exit Fullscreen":"Fullscreen",...n,onClick:i.toggleFullscreen,children:d(te,{name:t?"compress":"expand"})})}function rt({buttonClassName:n,onExpandedChange:i}){const t=j(),{isMuted:r,volume:l}=K(t);return d(qe,{muted:r,volume:l,volumeIcon:d(te,{name:r||l===0?"volume-mute":l<.5?"volume-down":"volume-up"}),buttonClassName:n,onToggleMute:t.toggleMute,onVolumeChange:t.setVolume,onExpandedChange:i})}function it({className:n}){const i=j(),{volume:t,isMuted:r}=K(i);return d("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 at({classes:n,timeLabelRef:i,children:t}){const r=j(),{duration:l,isScrubbing:m,playbackLocked:s}=K(r);return d("div",{inert:s||void 0,style:{display:"contents"},children:d(Ie,{classes:n,videoRef:r.mediaRef,duration:l,formatTime:be,isScrubbing:m,onSeek:k=>r.seek(k*l),onScrubStart:r.startScrubbing,onScrubMove:k=>r.seek(k*l),onScrubEnd:r.endScrubbing,timeLabelRef:i,children:t})})}function ut({className:n}){const i=j(),{currentTime:t,bufferedEnd:r}=ge(i),{duration:l,playbackLocked:m}=K(i),s=l?Math.min(100,t/l*100):0,k=l?Math.min(100,Math.max(s,r/l*100)):0;return d("input",{type:"range",disabled:m,min:0,max:l,step:.1,value:Math.min(t,l),onChange:v=>i.seek(Number(v.currentTarget.value)),onPointerDown:v=>{v.currentTarget.setPointerCapture(v.pointerId),i.startScrubbing()},onPointerUp:i.endScrubbing,onPointerCancel:i.endScrubbing,onLostPointerCapture:i.endScrubbing,className:n,style:{"--played-percent":`${s}%`,"--buffered-percent":`${k}%`},"aria-label":"Seek"})}function lt({className:n,durationOnly:i=!1}){const t=j(),{currentTime:r}=ge(t),{duration:l}=K(t);return d("span",{className:n,children:be(i?l:r)})}function ct(){const n=j(),{error:i,playBlocked:t,isBuffering:r,playbackLocked:l}=K(n);return i?d("div",{role:"alert",children:i}):t&&l?d("span",{children:"Enable playback from the watch-along panel."}):t?d(Xe,{children:"Tap to play"}):r?d("div",{role:"status","aria-label":"Buffering",children:"Loading…"}):null}const Qe='input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable]:not([contenteditable="false"]), [data-player-ui="true"], [data-speed-boost-ignore="true"]';function ot(n,i,t=!0){const r=x(i);r.current=i,X(()=>{if(!t)return;let l=!1,m=!1,s=!1,k,v,_=!1;const E=()=>{const a=m||s;a!==_&&(_=a,n.setSpeedBoost(a))},w=a=>a instanceof Element&&!!a.closest(Qe),p=a=>{if(!n.isActive()||!n.mediaRef.current||a.defaultPrevented||a.ctrlKey||a.metaKey||a.altKey||w(a.target))return;if(a.code==="Space"){if(a.preventDefault(),l)return;l=!0,k=setTimeout(()=>{k=void 0,m=!0,E()},180),r.current();return}const f=a.key.toLowerCase();["k","j","l","arrowleft","arrowright","arrowup","arrowdown","m","f"].includes(f)&&(a.preventDefault(),!(a.repeat&&["k","m","f"].includes(f))&&(f==="k"&&n.togglePlay(),(f==="j"||f==="arrowleft")&&n.seekRelative(-10),(f==="l"||f==="arrowright")&&n.seekRelative(10),f==="arrowup"&&n.setVolume(n.getState().volume+.1),f==="arrowdown"&&n.setVolume(n.getState().volume-.1),f==="m"&&n.toggleMute(),f==="f"&&n.toggleFullscreen(),r.current()))},S=a=>{a.code!=="Space"||!l||(a.preventDefault(),l=!1,clearTimeout(k),k=void 0,m?(m=!1,E()):n.togglePlay(),r.current())},P=a=>{const f=a.target;a.button!==0||!(f instanceof Element)||w(f)||!n.containerRef.current?.contains(f)||(clearTimeout(v),v=setTimeout(()=>{v=void 0,s=!0,E()},180))},g=()=>{clearTimeout(v),v=void 0,s=!1,E()},h=()=>{clearTimeout(k),k=void 0,l=!1,m=!1,g()};return document.addEventListener("keydown",p),document.addEventListener("keyup",S),document.addEventListener("pointerdown",P),document.addEventListener("pointerup",g),document.addEventListener("pointercancel",g),window.addEventListener("blur",h),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",S),document.removeEventListener("pointerdown",P),document.removeEventListener("pointerup",g),document.removeEventListener("pointercancel",g),window.removeEventListener("blur",h),h()}},[n,t])}function st({engine:n,children:i}){return d(ye.Provider,{value:n,children:i})}export{nt as F,at as P,tt as S,it as V,Xe as a,rt as b,Ye as c,st as d,j as e,K as f,ge as g,ot as h,lt as i,ut as j,ct as k,Ze as l,$e as m,ke as n,se as s,et as u};
@@ -1,10 +0,0 @@
1
- import{u as t,A as C,q as A,h as F,d as P,T as te,$ as ct}from"./vendor-core-DfaOB3Rn.js";import{p as M,al as lt,Q as He,B as X,a3 as se,o as dt,am as Re,q as U,ac as ut,t as pt,h as ht,a6 as ft,an as Fe,ao as mt}from"./index-BVkDKnzf.js";import{I as j}from"./vendor-icons-C1Pj_eSX.js";import{S as De,a as gt,s as G,f as We,m as yt,h as _t,d as bt,k as vt,u as St,n as ie}from"./PlayerProvider-9AfeIQ6B.js";import{u as wt}from"./vendor-query-BBT5_sHx.js";import{i as ce,d as Ct}from"./playbackCompletion-Bgy18e-S.js";const kt="_controls_1ne4g_1",xt="_titleContainer_1ne4g_9",Tt="_scheduleInfo_1ne4g_15",Nt="_status_1ne4g_23",Lt="_nextEpisode_1ne4g_35",Pt="_watchlistBtn_1ne4g_45",Bt="_inList_1ne4g_73",At="_queueBtn_1ne4g_84",Et="_queueActive_1ne4g_96",$t="_modeToggleBtn_1ne4g_102",It="_modeToggleActive_1ne4g_109",Mt="_markWatchedBtn_1ne4g_130",Rt="_markWatchedDone_1ne4g_144",Ft="_streamPanel_1ne4g_155",Dt="_desktopEpisodeActions_1ne4g_169",Ot="_sourceLoader_1ne4g_175",qt="_episodeActions_1ne4g_188",Ht="_mobileEpisodeActions_1ne4g_202",Wt="_episodeNavBtn_1ne4g_206",zt="_primary_1ne4g_235",Vt="_secondary_1ne4g_245",Kt="_episodePickerBtn_1ne4g_249",Ut="_queueCountdown_1ne4g_253",Qt="_speedBoostBadge_1ne4g_268",Gt="_videoContainer_1ne4g_299",jt="_loadingOverlay_1ne4g_312",Yt="_loadingDots_1ne4g_326",Xt="_dot_1ne4g_331",Jt="_bounce_1ne4g_1",Zt="_bufferingOverlay_1ne4g_348",en="_bufferingSpinner_1ne4g_357",tn="_spin_1ne4g_459",nn="_videoIframe_1ne4g_381",rn="_videoElementHidden_1ne4g_404",sn="_upscalerCanvas_1ne4g_409",an="_upscalerActive_1ne4g_422",on="_upscalerStatusBadge_1ne4g_426",cn="_subtitleOverlay_1ne4g_441",ln="_spinner_1ne4g_459",dn="_errorOverlay_1ne4g_526",un="_retryButton_1ne4g_536",pn="_detailsToggleBtn_1ne4g_549",hn="_descriptionSection_1ne4g_572",fn="_synopsisFlat_1ne4g_580",mn="_fullscreenActive_1ne4g_614",gn="_errorSubtext_1ne4g_657",yn="_watchedOverlay_1ne4g_680",_n="_watchedTitle_1ne4g_702",bn="_watchedSubtext_1ne4g_708",vn="_watchedActions_1ne4g_714",Sn="_watchedActionsCentered_1ne4g_732",es={controls:kt,titleContainer:xt,scheduleInfo:Tt,status:Nt,nextEpisode:Lt,watchlistBtn:Pt,inList:Bt,queueBtn:At,queueActive:Et,modeToggleBtn:$t,modeToggleActive:It,markWatchedBtn:Mt,markWatchedDone:Rt,streamPanel:Ft,desktopEpisodeActions:Dt,sourceLoader:Ot,episodeActions:qt,mobileEpisodeActions:Ht,episodeNavBtn:Wt,primary:zt,secondary:Vt,episodePickerBtn:Kt,queueCountdown:Ut,speedBoostBadge:Qt,videoContainer:Gt,loadingOverlay:jt,loadingDots:Yt,dot:Xt,bounce:Jt,bufferingOverlay:Zt,bufferingSpinner:en,spin:tn,videoIframe:nn,videoElementHidden:rn,upscalerCanvas:sn,upscalerActive:an,upscalerStatusBadge:on,subtitleOverlay:cn,spinner:ln,errorOverlay:dn,retryButton:un,detailsToggleBtn:pn,descriptionSection:hn,synopsisFlat:fn,fullscreenActive:mn,errorSubtext:gn,watchedOverlay:yn,watchedTitle:_n,watchedSubtext:bn,watchedActions:vn,watchedActionsCentered:Sn},wn="_playerPageLayout_1rxx0_1",Cn="_noSidebar_1rxx0_15",kn="_episodeSidebar_1rxx0_19",xn="_playerMain_1rxx0_32",Tn="_videoPlayerWrapper_1rxx0_40",Nn="_playerInfoHeader_1rxx0_56",Ln="_playerAnimeCard_1rxx0_62",Pn="_playerInfoContainer_1rxx0_74",Bn="_infoColumns_1rxx0_104",An="_videoTitleSection_1rxx0_134",En="_theaterMode_1rxx0_308",ts={playerPageLayout:wn,noSidebar:Cn,episodeSidebar:kn,playerMain:xn,videoPlayerWrapper:Tn,playerInfoHeader:Nn,playerAnimeCard:Ln,playerInfoContainer:Pn,infoColumns:Bn,videoTitleSection:An,theaterMode:En},$n={fontSize:"subtitleFontSize",position:"subtitlePosition",bgOpacity:"subtitleBgOpacity",bgColor:"subtitleBgColor",textColor:"subtitleTextColor",edge:"subtitleEdge",bold:"subtitleBold"},Q={fontSize:1.8,position:0,bgOpacity:.5,bgColor:"#000000",textColor:"#ffffff",edge:"shadow",bold:!1},he=(e,n,s)=>Math.max(n,Math.min(s,e)),fe=e=>typeof e=="string"&&/^#[0-9a-fA-F]{6}$/.test(e),le=(e,n,s,o)=>{try{const r=M.getItem(e);if(r===null)return n;const i=parseFloat(r);return Number.isFinite(i)?he(i,s,o):n}catch{return n}};function In(){let e=Q.edge,n=Q.bgColor,s=Q.textColor,o=Q.bold;try{const r=M.getItem("subtitleEdge");(r==="shadow"||r==="outline"||r==="none")&&(e=r);const i=M.getItem("subtitleBgColor");fe(i)&&(n=i);const c=M.getItem("subtitleTextColor");fe(c)&&(s=c);const p=M.getItem("subtitleBold");p!==null&&(o=p==="true")}catch{}return{fontSize:le("subtitleFontSize",Q.fontSize,.5,10),position:le("subtitlePosition",Q.position,0,100),bgOpacity:le("subtitleBgOpacity",Q.bgOpacity,0,1),bgColor:n,textColor:s,edge:e,bold:o}}function ze(e,n){const s=`rgba(0, 0, 0, ${he(n,0,1)})`;if(!fe(e))return s;const o=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`rgba(${o}, ${r}, ${i}, ${he(n,0,1)})`}function Ve(e,n){return e==="none"?n<=0?"0 1px 3px rgba(0, 0, 0, 0.9)":"none":e==="outline"?["-1px 0 0 black","1px 0 0 black","0 -1px 0 black","0 1px 0 black","-1px -1px 0 black","1px -1px 0 black","-1px 1px 0 black","1px 1px 0 black","0 0 6px rgba(0, 0, 0, 0.9)"].join(", "):"0 0 4px black, 0 1px 2px rgba(0, 0, 0, 0.8)"}function ns(e){return`
2
- video::cue {
3
- font-size: ${e.fontSize}rem !important;
4
- color: ${e.textColor} !important;
5
- background-color: ${ze(e.bgColor,e.bgOpacity)} !important;
6
- font-weight: ${e.bold?"bold":"normal"} !important;
7
- text-shadow: ${Ve(e.edge,e.bgOpacity)} !important;
8
- }
9
- `}function rs(e){return[`font-size: ${e.fontSize}rem`,`color: ${e.textColor}`,`background-color: ${ze(e.bgColor,e.bgOpacity)}`,`font-weight: ${e.bold?"700":"400"}`,`text-shadow: ${Ve(e.edge,e.bgOpacity)}`,"padding: 0.2em 0.5em","border-radius: 0.25em","text-align: center","position: absolute","left: 50%","transform: translateX(-50%)","max-width: 92%","white-space: pre-wrap","overflow-wrap: break-word","line-height: 1.4"].join(`;
10
- `)+";"}const Mn=new Set(["b","i","u","strong","em"]);function ss(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/&lt;(\/?)([a-zA-Z]+)&gt;/g,(s,o,r)=>Mn.has(r.toLowerCase())?`<${o}${r.toLowerCase()}>`:s)}function as(e){return e.replace(/<[^>]*>/g,"")}const os=["#ffffff","#ffff00","#7CFC00","#00e5ff","#ff9ff3","#ffa502"],is=["#000000","#1e272e","#2f3542","#3d0c02","#0c3d2e","#ffffff"];function cs(e,n){const s=Number.isFinite(e)?e*16:Q.fontSize*16;return!Number.isFinite(n)||n<=0?s/16:Math.min(s,Math.max(13,n*.07))/16}function ls(e){const n=Math.abs(e/1e3).toFixed(1);return e>0?`+${n}s`:e<0?`-${n}s`:"0.0s"}function ds(e,n){const s=e.clientWidth||0,o=e.clientHeight||0,r=e.videoWidth>0&&e.videoHeight>0?e.videoWidth/e.videoHeight:0;let i=o;r>0&&s>0&&o>0&&(i=s/o>r?o:s/r);const c=Math.max(0,(o-i)/2),p=Math.max(0,Math.min(100,Number(n)||0))/100*i;return c+p}const us=({isOpen:e,onClose:n,title:s,heading:o,message:r,children:i})=>t(He,{isOpen:e,onClose:n,title:s,width:"sm",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("button",{type:"button",className:lt.closeButton,onClick:n,"aria-label":"Close",children:t(j,{name:"times",size:16})}),t(j,{name:"check-circle",size:48,style:{color:"var(--accent-lighter)",marginBottom:"0.5rem"}}),t("p",{style:{fontSize:"1.1rem",fontWeight:600},children:o}),t("p",{style:{color:"var(--text-secondary)"},children:r}),i&&t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center",flexWrap:"wrap"},children:i})]})}),ps=({isOpen:e,onClose:n,title:s,message:o,resumeLabel:r="Resume",restartLabel:i="Start Over",onResume:c,onRestart:p})=>t(He,{isOpen:e,onClose:n,title:s,width:"sm",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:o}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(X,{variant:"secondary",onClick:p,children:i}),t(X,{onClick:c,children:r})]})]})}),Rn="_centerControls_1oa5h_1",Fn="_centerSkipBtn_1oa5h_14",Dn="_centerPlayPause_1oa5h_15",ae={centerControls:Rn,centerSkipBtn:Fn,centerPlayPause:Dn},hs=()=>t("div",{className:ae.centerControls,onClick:e=>e.stopPropagation(),children:[t(De,{seconds:-10,className:ae.centerSkipBtn}),t(gt,{className:ae.centerPlayPause,"data-speed-boost-ignore":"true"}),t(De,{seconds:10,className:ae.centerSkipBtn})]}),fs=({visible:e,title:n,episode:s,server:o,mode:r,audio:i,subtitles:c,onBack:p,classes:a})=>t("div",{className:`${a.overlay} ${e?"":a.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none"},children:t("div",{className:a.top,onClick:u=>u.stopPropagation(),children:[t("button",{className:a.backBtn,onClick:u=>{u.stopPropagation(),p()},title:"Back","aria-label":"Back",children:t(j,{name:"chevron-left"})}),t("div",{className:`${a.titleInfo} ${G.topBarTitleInfo}`,children:[t("span",{className:a.title,children:n}),s&&t("span",{className:a.episode,children:s}),(r||o||i||c)&&t("div",{className:G.streamDetails,children:[r&&t("span",{className:G.modeTag,children:r.toUpperCase()}),o&&t("span",{title:`Server: ${o}`,children:["Server: ",o]}),i&&t("span",{title:`Audio: ${i}`,children:["Audio: ",i]}),c&&t("span",{title:`Subs: ${c}`,children:["Subs: ",c]})]})]})]})});function On(e){return e instanceof Element&&!!e.closest('button, input, select, textarea, a, [role="button"], [role="slider"], [data-player-ui="true"]')}function ms({engine:e,topBar:n,centerControls:s,bottomBar:o,settingsPanel:r,overlays:i,isInteracting:c=!1,nativeControls:p=!1,chromeDisabled:a=!1,className:u,onStageClick:b,children:x}){const _=We(e),E=yt(),l=C(void 0),d=C(void 0),k=C(0),h=C(c);h.current=c;const m=A(()=>{clearTimeout(l.current),l.current=void 0},[]),g=A(()=>{m();const L=e.getState();!L.isPlaying||L.isScrubbing||h.current||p||(l.current=setTimeout(()=>{const y=e.getState();h.current||y.isScrubbing||!y.isPlaying||e.setShowControls(!1)},E?5e3:3e3))},[e,E,p,m]),B=A(()=>{e.setShowControls(!0),g()},[e,g]);_t(e,B,!p&&!a),F(()=>(c||_.isScrubbing||!_.isPlaying?(e.setShowControls(!0),m()):g(),m),[e,c,_.isPlaying,_.isScrubbing,_.showControls,m,g]),F(()=>()=>{clearTimeout(d.current)},[]);const f=L=>{if(On(L.target)||p||a)return;b?.();const y=Date.now();if(y-k.current<280){clearTimeout(d.current),d.current=void 0,k.current=0,e.toggleFullscreen();return}k.current=y,clearTimeout(d.current),d.current=setTimeout(()=>{d.current=void 0,e.setShowControls(!e.getState().showControls),g()},280)},T=_.showControls||_.isScrubbing||c||!_.isPlaying;return t(bt,{engine:e,children:t("div",{ref:e.containerRef,"data-player-root":"true",className:`${G.shell} ${_.isFullscreen?G.shellFullscreen:""} ${u??""}`,style:{cursor:!T&&_.isFullscreen?"none":"default"},onContextMenu:L=>L.preventDefault(),onPointerMove:L=>{L.pointerType==="mouse"&&B()},onFocusIn:B,onMouseLeave:()=>{window.matchMedia?.("(hover: hover) and (pointer: fine)").matches&&e.getState().isPlaying&&!h.current&&e.setShowControls(!1)},children:[t("div",{className:G.stage,onClick:f,children:x}),i,(_.error||_.playBlocked)&&t("div",{className:G.engineStatus,"data-player-ui":"true",children:t(vt,{})}),!a&&!p&&t("div",{className:G.uiLayer,children:[t("div",{"data-player-ui":"true",children:n}),T&&s&&t("div",{"data-player-ui":"true",children:s}),t("div",{"data-player-ui":"true",children:o}),r&&t("div",{"data-player-ui":"true",children:r})]})]})})}const qn=e=>(e.language??e.lang??"").toLowerCase(),Hn=e=>(e.label??"").toLowerCase(),Wn=e=>`${e.language??e.lang??""}|||${e.label??""}`,zn=e=>qn(e).startsWith("en")||Hn(e).includes("english");function gs(e,n){if(e.length===0||n?.enabled===!1)return-1;const s=n?.lastKey??null;if(s){const r=e.findIndex(i=>Wn(i)===s);if(r>=0)return r}const o=e.findIndex(zn);return o>=0?o:0}const Vn="_statusArea_1xccu_1",Kn="_toggleBtn_1xccu_20",Un="_shortcuts_1xccu_46",Qn="_shortcutGroup_1xccu_56",Gn="_shortcut_1xccu_46",jn="_key_1xccu_70",Yn="_label_1xccu_91",S={statusArea:Vn,toggleBtn:Kn,shortcuts:Un,shortcutGroup:Qn,shortcut:Gn,key:jn,label:Yn},ys=({showTheater:e=!0})=>{const[n,s]=P(!1);return t("div",{className:S.statusArea,children:[t("button",{type:"button",className:S.toggleBtn,onClick:()=>s(o=>!o),"aria-expanded":n,"aria-controls":"player-shortcuts",children:[t(j,{name:"keyboard",size:14}),t("span",{children:"Keyboard Shortcuts"}),n?t(j,{name:"chevron-up",size:12}):t(j,{name:"chevron-down",size:12})]}),n&&t("div",{id:"player-shortcuts",className:S.shortcuts,children:[t("div",{className:S.shortcutGroup,children:[t("div",{className:S.shortcut,children:[t("span",{className:S.key,children:"↑"}),t("span",{className:S.key,children:"↓"}),t("span",{className:S.label,children:"Volume"})]}),t("div",{className:S.shortcut,children:[t("span",{className:S.key,children:"←"}),t("span",{className:S.key,children:"→"}),t("span",{className:S.label,children:"Seek"})]})]}),t("div",{className:S.shortcutGroup,children:[t("div",{className:S.shortcut,children:[t("span",{className:S.key,children:"Space"}),t("span",{className:S.label,children:"Play/Pause"})]}),t("div",{className:S.shortcut,children:[t("span",{className:S.key,children:"F"}),t("span",{className:S.label,children:"Fullscreen"})]}),t("div",{className:S.shortcut,children:[t("span",{className:S.key,children:"M"}),t("span",{className:S.label,children:"Mute"})]}),e&&t("div",{className:S.shortcut,children:[t("span",{className:S.key,children:"T"}),t("span",{className:S.label,children:"Theater"})]}),t("div",{className:S.shortcut,children:[t("span",{className:S.key,children:"P"}),t("span",{className:S.label,children:"Previous"})]}),t("div",{className:S.shortcut,children:[t("span",{className:S.key,children:"N"}),t("span",{className:S.label,children:"Next"})]})]})]})]})},Xn="_episodeListContainer_11isr_1",Jn="_drawerContainer_11isr_9",Zn="_episodeListHeader_11isr_14",er="_drawerHeader_11isr_20",tr="_episodeListTitle_11isr_29",nr="_rangeSelector_11isr_41",rr="_rangeButton_11isr_47",sr="_active_11isr_70",ar="_episodeList_11isr_1",or="_drawerList_11isr_90",ir="_episodeItem_11isr_119",cr="_watched_11isr_147",lr="_episodeThumb_11isr_175",dr="_episodeText_11isr_185",ur="_episodeLabel_11isr_193",pr="_episodeSub_11isr_198",N={episodeListContainer:Xn,drawerContainer:Jn,episodeListHeader:Zn,drawerHeader:er,episodeListTitle:tr,rangeSelector:nr,rangeButton:rr,active:sr,episodeList:ar,drawerList:or,episodeItem:ir,watched:cr,episodeThumb:lr,episodeText:dr,episodeLabel:ur,episodeSub:pr},hr=({episodes:e,currentEpisode:n,watchedEpisodes:s=[],onEpisodeClick:o,variant:r="sidebar",title:i="Episodes",header:c})=>{const[p,a]=P(0),u=C(null),b=te(()=>e.map(l=>typeof l=="string"?{id:l,label:`Episode ${l}`}:l),[e]),x=te(()=>new Set(s),[s]);F(()=>{const l=u.current;if(!l)return;let d=l.parentElement;for(;d;){const m=window.getComputedStyle(d);if((m.overflowY==="auto"||m.overflowY==="scroll")&&d.scrollHeight>d.clientHeight)break;d=d.parentElement}if(!d)return;const k=d.getBoundingClientRect(),h=l.getBoundingClientRect();d.scrollTop+=h.top+h.height/2-(k.top+d.clientHeight/2)},[n,p]);const _=te(()=>{if(b.length<=100)return[];const l=[];for(let d=0;d<b.length;d+=100){const k=d+1,h=Math.min(d+100,b.length);l.push(`${k}-${h}`)}return l},[b]),E=te(()=>{if(_.length===0)return b;const l=_[p];if(!l)return b;const[d,k]=l.split("-"),h=parseInt(d,10),m=parseInt(k,10);return b.slice(h-1,m)},[b,_,p]);return t("div",{className:`${N.episodeListContainer} ${r==="drawer"?N.drawerContainer:""}`,children:[t("div",{className:`${N.episodeListHeader} ${r==="drawer"?N.drawerHeader:""}`,children:[c,t("h3",{className:N.episodeListTitle,children:i}),_.length>0&&t("div",{className:N.rangeSelector,children:_.map((l,d)=>t("button",{className:`${N.rangeButton} ${p===d?N.active:""}`,onClick:()=>a(d),children:l},l))})]}),t("div",{className:`${N.episodeList} ${r==="drawer"?N.drawerList:""}`,children:E.map(l=>{const d=l.id===n,k=x.has(l.id)||l.watched===!0;return t("div",{ref:d?u:void 0,className:`${N.episodeItem} ${k?N.watched:""} ${d?N.active:""}`,onClick:()=>o(l.id),children:[l.thumbnail&&t("img",{src:l.thumbnail,alt:"",loading:"lazy",decoding:"async",className:N.episodeThumb}),t("span",{className:N.episodeText,children:[t("span",{className:N.episodeLabel,children:l.label??`Episode ${l.id}`}),l.sublabel&&t("span",{className:N.episodeSub,children:l.sublabel})]})]},l.id)})})]})},_s=({variant:e="sidebar",count:n=12})=>t("div",{className:`${N.episodeListContainer} ${e==="drawer"?N.drawerContainer:""}`,children:[t("div",{className:`${N.episodeListHeader} ${e==="drawer"?N.drawerHeader:""}`,children:[t("h3",{className:N.episodeListTitle,children:"Episodes"}),t("div",{className:N.rangeSelector,children:[t(se,{width:"60px",height:"28px",variant:"rectangular"}),t(se,{width:"60px",height:"28px",variant:"rectangular"}),t(se,{width:"60px",height:"28px",variant:"rectangular"})]})]}),t("div",{className:`${N.episodeList} ${e==="drawer"?N.drawerList:""}`,children:Array.from({length:n}).map((s,o)=>t("div",{className:N.episodeItem,style:{border:"none",background:"transparent"},children:t(se,{width:"120px",height:"1.2rem",variant:"text"})},o))})]}),fr="_shell_cys6s_1",mr="_overlay_cys6s_10",gr="_drawer_cys6s_21",yr="_handle_cys6s_56",_r="_header_cys6s_64",br="_headerCopy_cys6s_73",vr="_kicker_cys6s_79",Sr="_title_cys6s_87",wr="_closeBtn_cys6s_94",Cr="_body_cys6s_116",V={shell:fr,overlay:mr,drawer:gr,handle:yr,header:_r,headerCopy:br,kicker:vr,title:Sr,closeBtn:wr,body:Cr};function bs({isOpen:e,onClose:n,episodes:s,currentEpisode:o,watchedEpisodes:r=[],onEpisodeClick:i,title:c,header:p}){return F(()=>{if(!e)return;const a=b=>{b.key==="Escape"&&n()},u=document.body.style.overflow;return document.body.style.overflow="hidden",document.addEventListener("keydown",a),()=>{document.body.style.overflow=u,document.removeEventListener("keydown",a)}},[e,n]),e?ct(t("div",{className:V.shell,role:"dialog","aria-modal":"true","aria-label":"Episode picker",children:[t("button",{className:V.overlay,type:"button",onClick:n,"aria-label":"Close episodes"}),t("aside",{className:V.drawer,children:[t("div",{className:V.handle}),t("div",{className:V.header,children:[t("div",{className:V.headerCopy,children:[t("span",{className:V.kicker,children:"Episode picker"}),t("h3",{className:V.title,children:"Choose an episode"})]}),t("button",{className:V.closeBtn,type:"button",onClick:n,"aria-label":"Close",children:t(j,{name:"times"})})]}),t("div",{className:V.body,children:t(hr,{episodes:s,currentEpisode:o,watchedEpisodes:r,onEpisodeClick:i,variant:"drawer",title:c,header:p})})]})]}),document.body):null}const kr="_sourceSelectionContainer_g7xev_1",xr="_providerSelectContainer_g7xev_14",Tr="_providerSelect_g7xev_14",Nr="_sourceSelect_g7xev_1",Lr="_sourceButtons_g7xev_70",Pr="_sourceButton_g7xev_70",Br="_active_g7xev_95",vs={sourceSelectionContainer:kr,providerSelectContainer:xr,providerSelect:Tr,sourceSelect:Nr,sourceButtons:Lr,sourceButton:Pr,active:Br},Ss=({skipIntervals:e,showId:n,episodeNumber:s,episodeCount:o,sourceType:r,showMeta:i})=>{const c=wt(),p=dt(),{engine:a,mediaRef:u}=St({volumeKey:"playerVolume",mutedKey:"playerMuted"}),{isPlaying:b,isMuted:x,volume:_,duration:E,isScrubbing:l,isBuffering:d,isFullscreen:k,isSpeedBoostActive:h,showControls:m,playbackLocked:g}=We(a),B=a.containerRef,f=C(null),T=C(0),L=C(Math.random().toString(36).substring(2)),y=a.setShowControls,[I,q]=P(M.getItem("autoSkipEnabled")==="true"),[K,$]=P(null),[W]=P(In),[Ke,ge]=P(W.fontSize),[Ue,ye]=P(W.position),[Qe,_e]=P(W.bgOpacity),[Ge,be]=P(W.bgColor),[je,ve]=P(W.textColor),[Ye,Se]=P(W.edge),[Xe,we]=P(W.bold),Ce=A((v,R)=>{if({fontSize:w=>typeof w!="number"?!1:(ge(w),!0),position:w=>typeof w!="number"?!1:(ye(w),!0),bgOpacity:w=>typeof w!="number"?!1:(_e(w),!0),bgColor:w=>typeof w!="string"?!1:(be(w),!0),textColor:w=>typeof w!="string"?!1:(ve(w),!0),edge:w=>w!=="shadow"&&w!=="outline"&&w!=="none"?!1:(Se(w),!0),bold:w=>typeof w!="boolean"?!1:(we(w),!0)}[v](R))try{M.setItem($n[v],String(R))}catch{}},[]),[Je,Ze]=P([]),[et,tt]=P(null),[nt,rt]=P(!1),[st,at]=P(!1),[ot,ke]=P(()=>{try{return M.getItem("playerUseNativeControls")==="true"}catch{return!1}}),J=C(!1),ne=C(-1),re=A(()=>{const v=u.current;return!n||!s||!i?.name?null:{showId:n,episodeNumber:s,episodeCount:o,currentTime:a.getTimeline().currentTime,duration:a.getState().duration,showName:i.name,showThumbnail:i.thumbnail,nativeName:i.names?.native,englishName:i.names?.english,genres:Array.isArray(i.genres)?i.genres.map(R=>typeof R=="string"?R:R?.name).filter(Boolean):void 0,popularityScore:i.score,type:i.type,isPlaying:v?!v.paused:r==="iframe",sessionId:L.current,isAdult:i.isAdult}},[a,u,n,s,o,i,r]),D=A((v=!1,R=!1)=>{if(J.current)return!1;const H=re();if(!H)return!1;const w=u.current;if(!w&&!v&&r!=="iframe"||r!=="iframe"&&H.duration<=0)return!1;const z=a.getTimeline().currentTime;if(!R){if(z===0)return!1;const ee=w?Math.abs(z-ne.current):0;if(!v&&w&&z!==w.duration&&ee<5)return!1}return H.currentTime=z,ne.current=z,v?(async()=>{try{await Re("progress.updateProgress",H),c.invalidateQueries({queryKey:[U.playerData,n]}),c.invalidateQueries({queryKey:[U.videoSources,n,s]}),c.invalidateQueries({queryKey:[U.continueWatching]}),c.invalidateQueries({queryKey:[U.thisWeekSchedule]}),c.invalidateQueries(p.continueWatching.pathFilter())}catch(ee){console.error("Failed to update progress:",ee)}})():Re("progress.updateProgress",H).then(()=>{ce(H.currentTime,H.duration)&&c.invalidateQueries({queryKey:[U.playerData,n]})}).catch(ee=>console.error("Failed to update progress:",ee)),!0},[a,re,r,c,n,s,p.continueWatching,u]);F(()=>{const v=()=>{J.current||D(!0)};window.addEventListener("beforeunload",v),window.addEventListener("pagehide",v);const R=()=>{document.visibilityState==="hidden"&&v()};document.addEventListener("visibilitychange",R);const H=f;return()=>{window.removeEventListener("beforeunload",v),window.removeEventListener("pagehide",v),document.removeEventListener("visibilitychange",R),J.current||D(!0),H.current&&clearTimeout(H.current)}},[D]);const xe=A(()=>a.setShowControls(!0),[a]),Te=a.toggleFullscreen,Ne=A(()=>{a.togglePlay(),y(!0)},[a,y]),Le=A(()=>{a.toggleMute(),y(!0)},[a,y]),Pe=A(v=>{a.seekRelative(v),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>D(!1,!0),1500),y(!0)},[a,D,y]),Be=A(()=>{J.current=!1,D(!1,!0)},[D]),Ae=A(()=>{y(!0),D(!1,!0)},[D,y]);F(()=>{J.current=!1,ne.current=-1,T.current=0,L.current=Math.random().toString(36).substring(2),a.reset()},[a,n,s]);const Ee=a.reset;F(()=>{const v=L.current;return()=>{ut(v)}},[a,n,s]),F(()=>{if(r!=="iframe")return;D(!1,!0);const v=setInterval(()=>{D(!1,!0)},6e4);return()=>clearInterval(v)},[r,D]);const $e=A(()=>{const v=u.current;if(!v)return;const R=v.currentTime||0,H=Date.now(),w=ce(R,v.duration)&&!ce(ne.current,v.duration);(w||H-T.current>6e4)&&D(!1,w)&&(T.current=H);const z=e.find(Z=>R>=Z.start_time&&R<Z.end_time)||null;$(Z=>Z?.skip_id!==z?.skip_id?z:Z),I&&z&&!v.paused&&!a.getState().playbackLocked&&(a.seek(z.end_time),$(null))},[u,e,I,D,a]),Ie=A(()=>{const v=re();v&&(v.currentTime=v.duration,pt.progress.updateProgress.mutate(v).then(()=>{c.invalidateQueries({queryKey:[U.playerData,n]}),c.invalidateQueries({queryKey:[U.videoSources,n,s]}),c.invalidateQueries({queryKey:[U.continueWatching]})}).catch(R=>console.error("Failed to send final progress:",R)))},[re,c,n,s]),Me=A(()=>{J.current=!0,Ie()},[Ie]),it=te(()=>({togglePlay:Ne,seek:Pe,toggleMute:Le,toggleFullscreen:Te,onPlay:Be,onPause:Ae,formatTime:ht,onTimeUpdate:$e,onEnded:Me,setShowControls:y,setIsAutoSkipEnabled:q,setCurrentSkipInterval:$,setSubtitleFontSize:ge,setSubtitlePosition:ye,setSubtitleBgOpacity:_e,setSubtitleBgColor:be,setSubtitleTextColor:ve,setSubtitleEdge:Se,setSubtitleBold:we,setSubtitleStyle:Ce,setAvailableSubtitles:Ze,setActiveSubtitleTrack:tt,setShowSettings:rt,setShowVolumeSlider:at,flashControls:xe,sendProgressUpdate:D,setUseNativeControls:ke,resetMediaState:Ee}),[Ne,Pe,Le,Te,Be,Ae,$e,Me,D,ke,Ee,xe,Ce,y]);return{engine:a,refs:{videoRef:u,playerContainerRef:B},state:{playbackLocked:g,isPlaying:b,isMuted:x,volume:_,isFullscreen:k,duration:E,showControls:m,isScrubbing:l,isAutoSkipEnabled:I,currentSkipInterval:K,subtitleFontSize:Ke,subtitlePosition:Ue,subtitleBgOpacity:Qe,subtitleBgColor:Ge,subtitleTextColor:je,subtitleEdge:Ye,subtitleBold:Xe,availableSubtitles:Je,activeSubtitleTrack:et,showSettings:nt,showVolumeSlider:st,isBuffering:d,isSpeedBoostActive:h,useNativeControls:ot},actions:it}};function Ar(){try{return typeof navigator<"u"&&/android/i.test(navigator.userAgent)}catch{return!1}}function ws(e,n){const{refs:s,actions:o}=e,r=C(n);r.current=n;const i=C(!1),c=C(!1),p=a=>{try{if(a)return a.matches}catch{}try{return window.innerWidth>window.innerHeight}catch{return!1}};F(()=>{if(!Ar())return;let a=null;const u=()=>{const b=s.playerContainerRef.current;if(p(a)){if(!r.current||!b||ie(s.videoRef.current)||c.current)return;i.current=!0,o.toggleFullscreen()}else c.current=!1,i.current&&(i.current=!1,ie(s.videoRef.current)&&o.toggleFullscreen())};try{a=window.matchMedia("(orientation: landscape)"),a.addEventListener?a.addEventListener("change",u):a.addListener(u)}catch{}return u(),()=>{try{a&&(a.removeEventListener?a.removeEventListener("change",u):a.removeListener(u))}catch{}}},[o,s.playerContainerRef,s.videoRef,n]),F(()=>{const a=()=>{if(!ie(s.videoRef.current)){i.current=!1;try{window.matchMedia("(orientation: landscape)").matches&&(c.current=!0)}catch{c.current=!0}}};return document.addEventListener("fullscreenchange",a),document.addEventListener("webkitfullscreenchange",a),()=>{document.removeEventListener("fullscreenchange",a),document.removeEventListener("webkitfullscreenchange",a)}},[s.videoRef])}const Er=e=>Math.max(8,Math.min(40,Math.ceil(e/16.7)+4));function Cs({videoRef:e,canvasRef:n,delayMs:s,enabled:o}){const r=C(s);r.current=s;const i=C([]),c=C(-1),p=C(-1),a=C(!1),u=C(0),b=C(null);F(()=>{const x=h=>{if(h)try{h.close()}catch{}},_=()=>{for(const h of i.current)x(h.bitmap);i.current=[]};if(!o){_(),c.current=-1,p.current=-1,a.current=!1,u.current=0;return}let E=!1;const l=()=>{b.current!==null&&(cancelAnimationFrame(b.current),b.current=null)},d=()=>{E||(l(),b.current=requestAnimationFrame(()=>{k()}))};async function k(){if(E)return;const h=e.current,m=n.current;if(!h||!m||h.videoWidth===0){d();return}if(h.paused||h.ended||document.hidden||h.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){d();return}const g=h.getVideoPlaybackQuality().totalVideoFrames;if(g===c.current){d();return}(h.seeking||p.current>=0&&Math.abs(h.currentTime-p.current)>.5)&&(_(),a.current=!1,u.current=0,c.current=-1),p.current=h.currentTime,(m.width!==h.videoWidth||m.height!==h.videoHeight)&&(m.width=h.videoWidth,m.height=h.videoHeight);const B=Math.max(0,r.current||0);B>u.current&&(a.current=!1);try{const f=await createImageBitmap(h);if(E){x(f);return}c.current=g;const T=performance.now(),L=m.getContext("2d"),y=$=>{L&&L.drawImage($,0,0,m.width,m.height)};if(B<=0){_(),a.current=!1,u.current=0,y(f),x(f),d();return}const I=i.current;I.push({bitmap:f,capture:T});const q=Er(B);for(;I.length>q;)x(I.shift()?.bitmap);let K=-1;for(let $=I.length-1;$>=0;$--)if(T-I[$].capture>=B){K=$;break}if(K!==-1){for(let W=0;W<K;W++)x(I.shift()?.bitmap);const $=I.shift();$?(y($.bitmap),x($.bitmap),a.current=!0,u.current=B):y(f)}else if(!a.current)y(f);else{const $=I.shift();$?(y($.bitmap),x($.bitmap)):y(f)}}catch{}d()}return d(),()=>{E=!0,l();for(const h of i.current)try{h.bitmap.close()}catch{}i.current=[]}},[o,e,n])}const Oe=(e,n)=>{try{M.setItem("playerVideoDelayMs",String(e)),M.setItem("playerVideoDelayEnabled",String(n))}catch{}},qe=e=>{try{M.setItem("playerVideoDelayEnabled",String(e))}catch{}};function ks(e,n){const[s,o]=P(()=>{try{const g=Number(M.getItem("playerVideoDelayMs"));if(Number.isFinite(g)&&g>=0&&g<=500)return Math.round(g)}catch{}return 180}),[r,i]=P(()=>{try{return M.getItem("playerVideoDelayEnabled")==="true"}catch{return!1}}),[c,p]=P(!1),[a,u]=P(!1),b=C(null),x=C(null),_=g=>{const B=Math.max(0,Math.min(500,Math.round(g)));o(B);try{M.setItem("playerVideoDelayMs",String(B))}catch{}},E=g=>{i(g),qe(g)},l=A(()=>{u(!1),p(!1)},[]);return{videoDelayMs:s,videoDelayEnabled:r,setDelayEnabled:E,handleVideoDelayChange:_,isCalibrating:c,testClipActive:a,stopCalibration:l,openAvSyncCalibrator:()=>{b.current={enabled:r,ms:s},i(!0),qe(!0),n?.(),p(!0)},cancelAvSyncCalibrator:()=>{const g=b.current;b.current=null,g&&(o(g.ms),i(g.enabled),Oe(g.ms,g.enabled)),u(!1),p(!1)},applyAvSyncCalibrator:()=>{b.current=null,i(!0),Oe(s,!0),u(!1),p(!1)},toggleTestClip:()=>{if(a){u(!1);return}const g=e.current;g&&!isNaN(g.currentTime)&&(x.current=g.currentTime),u(!0)},calibReturnRef:x,effectiveVideoDelayMs:r?s:0}}function xs(){const[e,n]=P(()=>{try{return M.getItem("playerTheaterMode")==="true"}catch{return!1}});F(()=>{try{e?document.body.classList.add("theater-mode"):document.body.classList.remove("theater-mode")}catch(r){console.error(r)}return()=>{try{document.body.classList.remove("theater-mode")}catch(r){console.error(r)}}},[e]);const s=A(()=>{n(r=>{const i=!r;try{M.setItem("playerTheaterMode",i.toString())}catch{}return i})},[]),o=A(r=>{if(e&&r.target===r.currentTarget){n(!1);try{M.setItem("playerTheaterMode","false")}catch{}}},[e]);return{isTheaterMode:e,toggleTheaterMode:s,handleLayoutClick:o}}const Y={enabled:!0,blur:60,saturation:150,brightness:70,opacity:60};function $r(){try{const e=M.getItem("playerAmbientLight");if(!e)return Y;const n=JSON.parse(e),s=(o,r,i,c)=>{const p=Number(o);return Number.isFinite(p)?Math.max(i,Math.min(c,p)):r};return{enabled:n.enabled??Y.enabled,blur:s(n.blur,Y.blur,0,120),saturation:s(n.saturation,Y.saturation,0,200),brightness:s(n.brightness,Y.brightness,20,120),opacity:s(n.opacity,Y.opacity,10,100)}}catch{return Y}}function Ts(){const[e,n]=P($r),s=A(o=>{n(r=>{const i={...r,...o};try{M.setItem("playerAmbientLight",JSON.stringify(i))}catch{}return i})},[]);return{settings:e,update:s}}const Ir="_theaterAmbient_x9t0o_1",Mr={theaterAmbient:Ir},de=160,ue=90,Rr=120,Ns=({videoRef:e,active:n,settings:s,className:o})=>{const r=C(null);return F(()=>{if(!n)return;const i=r.current,c=e.current;if(!i||!c)return;const p=i.getContext("2d",{alpha:!1});if(!p)return;let a=0,u=0,b=!1;const x=()=>{if(!(c.readyState<2||!c.videoWidth))try{const d=c.videoWidth,k=c.videoHeight,h=de/ue,m=d/k;let g=d,B=k,f=0,T=0;m>h?(g=k*h,f=(d-g)/2):(B=d/h,T=(k-B)/2),p.drawImage(c,f,T,g,B,0,0,de,ue)}catch{}},_=d=>{b||c.paused||(a=requestAnimationFrame(_),!(d-u<Rr)&&(u=d,x()))},E=()=>{b||(cancelAnimationFrame(a),u=0,a=requestAnimationFrame(_))},l=()=>cancelAnimationFrame(a);return c.addEventListener("play",E),c.addEventListener("pause",l),c.addEventListener("seeked",x),c.addEventListener("loadeddata",x),a=requestAnimationFrame(_),()=>{b=!0,cancelAnimationFrame(a),c.removeEventListener("play",E),c.removeEventListener("pause",l),c.removeEventListener("seeked",x),c.removeEventListener("loadeddata",x)}},[n,e]),n?t("canvas",{ref:r,width:de,height:ue,"aria-hidden":"true",className:o??Mr.theaterAmbient,style:{filter:`blur(${s.blur}px) saturate(${s.saturation}%) brightness(${s.brightness}%)`,opacity:s.opacity/100}}):null},Fr="_row_1fq55_1",Dr="_rowHeader_1fq55_9",Or="_rowLabel_1fq55_17",qr="_rowValue_1fq55_28",Hr="_slider_1fq55_36",Wr="_swatches_1fq55_99",zr="_swatch_1fq55_99",Vr="_swatchPicked_1fq55_114",Kr="_colorInput_1fq55_120",Ur="_segmented_1fq55_131",O={row:Fr,rowHeader:Dr,rowLabel:Or,rowValue:qr,slider:Hr,swatches:Wr,swatch:zr,swatchPicked:Vr,colorInput:Kr,segmented:Ur},Qr=({label:e,display:n,min:s,max:o,step:r,value:i,percent:c,onChange:p,onCommit:a})=>t("div",{className:O.row,children:[t("div",{className:O.rowHeader,children:[t("span",{className:O.rowLabel,children:e}),t("span",{className:O.rowValue,children:n})]}),t("input",{type:"range",className:O.slider,min:s,max:o,step:r,value:i,"aria-label":e,"data-speed-boost-ignore":"true",onInput:u=>p(Number(u.target.value)),onMouseDown:u=>u.stopPropagation(),onPointerDown:u=>u.stopPropagation(),onTouchStart:u=>u.stopPropagation(),onPointerUp:a,onPointerCancel:a,onTouchEnd:a,onKeyUp:a,onBlur:a,style:{"--slider-percent":`${c}%`}})]}),Ls=({label:e,colors:n,value:s,onChange:o})=>t("div",{className:O.row,children:[t("div",{className:O.rowHeader,children:t("span",{className:O.rowLabel,children:e})}),t("div",{className:O.swatches,children:[n.map(r=>t("button",{type:"button","aria-label":`${e} ${r}`,"aria-pressed":s.toLowerCase()===r.toLowerCase(),onClick:()=>o(r),className:`${O.swatch} ${s.toLowerCase()===r.toLowerCase()?O.swatchPicked:""}`,style:{backgroundColor:r}},r)),t("input",{type:"color","aria-label":`Custom ${e.toLowerCase()}`,className:O.colorInput,value:s,"data-speed-boost-ignore":"true",onInput:r=>o(r.target.value),onMouseDown:r=>r.stopPropagation(),onPointerDown:r=>r.stopPropagation(),onTouchStart:r=>r.stopPropagation()})]})]});function Ps({label:e,options:n,value:s,onChange:o}){return t("div",{className:O.row,children:[t("div",{className:O.rowHeader,children:t("span",{className:O.rowLabel,children:e})}),t("div",{className:O.segmented,role:"group","aria-label":e,children:n.map(r=>t("button",{type:"button","aria-pressed":s===r,onClick:()=>o(r),children:[t("span",{children:r}),s===r&&t(j,{name:"check",size:10})]},r))})]})}const oe=10,me=500,pe=e=>Math.max(0,Math.min(me,Math.round(e))),Bs=({isOpen:e,ms:n,onChange:s,onApply:o,onClose:r,testClipActive:i,onTestClip:c})=>e?t("div",{role:"dialog","aria-label":"Calibrate audio video sync","data-speed-boost-ignore":"true",onClick:p=>p.stopPropagation(),style:{position:"absolute",right:8,bottom:112,width:"min(260px, calc(100% - 16px))",maxHeight:"calc(100% - 124px)",overflowY:"auto",overflowX:"hidden",zIndex:60,display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:12,borderRadius:"var(--radius-lg)",border:"1px solid var(--glass-border)",background:"rgba(18, 18, 22, 0.95)",boxShadow:"var(--glass-shadow)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxSizing:"border-box"},children:[t("div",{style:{fontSize:"0.8rem",fontWeight:800,color:"var(--text-primary)"},children:"A/V sync"}),t("div",{children:t(X,{size:"sm",variant:"secondary",onClick:c,children:i?"Back to video":"Preview test clip"})}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,flexWrap:"wrap"},children:[t(X,{size:"sm",onClick:()=>s(pe(n-oe)),"aria-label":"Decrease delay by 10 milliseconds",children:["− ",oe,"ms"]}),t("div",{style:{fontSize:"1.1rem",fontWeight:800,minWidth:64,textAlign:"center"},children:[n,"ms"]}),t(X,{size:"sm",onClick:()=>s(pe(n+oe)),"aria-label":"Increase delay by 10 milliseconds",children:["+ ",oe,"ms"]})]}),t(Qr,{label:"Video delay",display:`${n}ms`,min:0,max:me,step:5,value:n,percent:n/me*100,onChange:p=>s(pe(p))}),t("div",{style:{display:"flex",gap:8,justifyContent:"center",flexWrap:"wrap"},children:[t(X,{size:"sm",variant:"secondary",onClick:r,children:"Cancel"}),t(X,{size:"sm",onClick:o,children:["Apply ",n,"ms"]})]})]}):null;function As({videoRef:e,sourceType:n,resetKey:s,onEnd:o}){const r=C(!1),i=C(o);i.current=o,F(()=>{r.current=!1},[s]);const c=A(()=>{const a=e.current?.duration;!a||!Number.isFinite(a)||console.info(`[playback] duration ${a.toFixed(2)}s`)},[e]);return{checkEnd:A((a=!1)=>{const u=e.current;!u||n==="iframe"||r.current||!a&&!Ct(u.currentTime,u.duration)||(r.current=!0,console.info(`[playback] end reached at ${u.currentTime.toFixed(2)}s / ${u.duration.toFixed(2)}s`),i.current())},[n,e]),logDuration:c}}function Es(e,n,s){const o=ft(),r=C({watch:o,selection:n,loading:s});r.current={watch:o,selection:n,loading:s};const[i,c]=P(!1),p=C(""),a=C(""),u=C(""),b=C(!1),x=!!o.session&&!o.session.host;F(()=>(!o.session&&b.current&&e.applyRemotePlayback(void 0,!1,1),b.current=!!o.session,e.setPlaybackLocked(!!o.session&&(x||!o.connected)),o.session&&!o.connected&&e.applyRemotePlayback(void 0,!1,1),()=>e.setPlaybackLocked(!1)),[e,x,o.connected,o.session]);const _=A((E=!1)=>{const{watch:l,selection:d,loading:k}=r.current,h=e.mediaRef.current;if(!l.session||!l.room||!h)return;if(l.session.host){l.connected&&l.selfId!==u.current&&!k&&d&&h.readyState>=1&&(u.current=l.selfId,Fe(d,l.room.selection)&&e.applyRemotePlayback(l.room.position,!1,l.room.rate));return}const m=l.room,g=d&&Fe(d,m.selection);if(!l.connected||k||!g||h.readyState<1){e.applyRemotePlayback(void 0,!1,m.rate);return}const B=Date.now()+l.clock.offset-m.updatedAt<15e3;if(m.playing&&!B){e.applyRemotePlayback(void 0,!1,m.rate);return}const f=m.playing&&m.hostOnline&&B,T=Math.min(h.duration||1/0,mt({...m,playing:f},Date.now()+l.clock.offset)),L=T-h.currentTime,y=Math.abs(L)>(f?1.25:.15),I=f&&!y&&Math.abs(L)>.15?Math.min(4,Math.max(.25,m.rate*(L>0?1.03:.97))):m.rate,q=e.getState().playBlocked;e.applyRemotePlayback(y?T:void 0,f&&(!q||E),I),c(q&&f)},[e]);return F(()=>{if(!o.session)return;const E=()=>{const{watch:f,selection:T,loading:L}=r.current,y=e.mediaRef.current;if(!f.connected||!f.session?.host||!f.room)return;if(!T||L||!y||y.readyState<1){f.room.playing&&f.send({type:"update",...f.room,playing:!1});return}_();const I=e.getState(),q=!y.paused&&!y.ended&&!I.isBuffering,K={type:"update",selection:T,position:y.currentTime+(q?f.clock.latency/1e3*y.playbackRate:0),playing:q,rate:y.playbackRate},$=JSON.stringify(K);!q&&a.current===$||(a.current=$,f.send(K))},l=()=>{const{watch:f,selection:T,loading:L}=r.current,y=e.getState(),I=e.mediaRef.current,q=y.error||!L&&!T?"error":y.playBlocked?"blocked":L||!I||I.readyState<1?"loading":y.isBuffering?"buffering":"ready";f.connected&&`${f.selfId}:${q}`!==p.current&&(p.current=`${f.selfId}:${q}`,f.send({type:"status",status:q})),_()};let d=null;const k=["play","pause","seeked","ratechange","playing","waiting","canplay","ended"];let h;const m=()=>{clearTimeout(h),h=setTimeout(E,100)},g=setInterval(()=>{const f=e.mediaRef.current;d!==f&&(k.forEach(T=>d?.removeEventListener(T,m)),d=f,k.forEach(T=>d?.addEventListener(T,m))),l()},500),B=setInterval(E,3e3);return()=>{clearInterval(g),clearInterval(B),clearTimeout(h),k.forEach(T=>d?.removeEventListener(T,m));const{watch:f}=r.current;f.session?.host&&f.room&&f.connected&&f.send({type:"update",...f.room,playing:!1,position:e.mediaRef.current?.currentTime??f.room.position})}},[e,o.session,_]),F(()=>{_()},[o.room,o.connected,n,s,_]),{needsPlayback:i,enablePlayback:()=>_(!0)}}export{Ns as A,is as B,fs as C,Ps as D,_s as E,Q as F,Y as G,Qr as M,ms as P,ps as R,Ls as S,os as T,hs as a,vs as b,ns as c,rs as d,ds as e,cs as f,as as g,Es as h,ks as i,Cs as j,xs as k,As as l,ws as m,Ts as n,ts as o,gs as p,us as q,ss as r,Wn as s,hr as t,Ss as u,es as v,Bs as w,ys as x,bs as y,ls as z};