@serifpersia/dango 3.6.5 → 3.6.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.
- package/README.md +1 -1
- package/client/dist/assets/{AnimeCard-JkXG40Es.js → AnimeCard-C3P9zWi9.js} +1 -1
- package/client/dist/assets/{AnimeInfo-2L0UJkbB.js → AnimeInfo-Et6687Tl.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-BDs03vKk.js → AnimeInfoPage-DX4eNnlH.js} +2 -2
- package/client/dist/assets/{Asmr-D2mVKEl9.js → Asmr-CCdEWrFi.js} +1 -1
- package/client/dist/assets/{AsmrResetProgressModal-MQA_bNQM.js → AsmrResetProgressModal-DgEWBJOw.js} +1 -1
- package/client/dist/assets/AvSyncCalibrator-CQ2fjf2E.js +10 -0
- package/client/dist/assets/{Home-DxMBHFmc.js → Home-DUkUTTTy.js} +1 -1
- package/client/dist/assets/{Insights-hmLWsSXY.js → Insights-QCh4xW12.js} +1 -1
- package/client/dist/assets/{LibraryListPage-CWI7hgUh.js → LibraryListPage-BoTxRqHz.js} +1 -1
- package/client/dist/assets/{ListeningList-NOc28KAV.js → ListeningList-DguKjI_t.js} +1 -1
- package/client/dist/assets/{Manga-B5qNhI7v.js → Manga-HydR-L7o.js} +1 -1
- package/client/dist/assets/{MangaInfoPage-D4wIyb-V.js → MangaInfoPage-CBakEI9a.js} +1 -1
- package/client/dist/assets/{MangaReadPage-Ce1VX7-0.js → MangaReadPage-DwAR3iPy.js} +1 -1
- package/client/dist/assets/{MangaResetProgressModal-P3oY4_14.js → MangaResetProgressModal-DGzl8vsO.js} +1 -1
- package/client/dist/assets/{Mature-D8EwGYQq.js → Mature-Pi0TxKuF.js} +1 -1
- package/client/dist/assets/{MediaCard-Dp8DjyXB.js → MediaCard--cuFxOCS.js} +1 -1
- package/client/dist/assets/{Music-DULtVsAM.js → Music-CQpyXTLH.js} +1 -1
- package/client/dist/assets/{OptionListMenu-fIHdE-nq.js → OptionListMenu-B3D39dGS.js} +1 -1
- package/client/dist/assets/{Player-B8XeOmso.js → Player-CsH4x_I_.js} +6 -6
- package/client/dist/assets/{PlayerSettings-BycNCiCs.js → PlayerSettings-DGxBsi3F.js} +1 -1
- package/client/dist/assets/{QueueOptionsButton-T1J37IZT.js → QueueOptionsButton-Djq4Cpex.js} +1 -1
- package/client/dist/assets/{QueueRail-BAwI-apz.js → QueueRail-DOrYgNVX.js} +1 -1
- package/client/dist/assets/{Radio-Bv9DyKtZ.js → Radio-DF6g6odd.js} +1 -1
- package/client/dist/assets/{ReadingList-Cl0CcVp3.js → ReadingList-DwYoBrNk.js} +1 -1
- package/client/dist/assets/{ResetProgressModal--N60WWCB.js → ResetProgressModal-CMF86mX6.js} +1 -1
- package/client/dist/assets/{Search-DvgVDlUR.js → Search-DFkhuk-x.js} +1 -1
- package/client/dist/assets/{Settings-dCz_-bJn.js → Settings-DBB2r0VQ.js} +1 -1
- package/client/dist/assets/{SkeletonGrid-BZHKk1I6.js → SkeletonGrid-DJelJgAv.js} +1 -1
- package/client/dist/assets/{Trackers-C1T5VcPu.js → Trackers-DGYXFhYZ.js} +1 -1
- package/client/dist/assets/{Tv-Dhv_cg4y.js → Tv-C5MDGD2Z.js} +4 -4
- package/client/dist/assets/{TvInfo-DgaLK2H6.js → TvInfo-DrKuK13u.js} +1 -1
- package/client/dist/assets/{TvPopup-DyX7f8kC.js → TvPopup-DtHilRDT.js} +1 -1
- package/client/dist/assets/{TvSearch-Bp0H6kue.js → TvSearch-CzNxdu_w.js} +1 -1
- package/client/dist/assets/{TvWatchlist-ohMtMeKa.js → TvWatchlist-D7p4br6S.js} +1 -1
- package/client/dist/assets/{Watchlist-BbQtzsER.js → Watchlist-DrOzswl2.js} +1 -1
- package/client/dist/assets/{hls-Bi1cjpLZ.js → hls-BGCX7mJy.js} +1 -1
- package/client/dist/assets/{index-BTnhzofk.js → index-CnfZwsds.js} +2 -2
- package/client/dist/assets/{useAnimeInfoData-Cvmso3IK.js → useAnimeInfoData-DYXWBPF-.js} +1 -1
- package/client/dist/assets/{useAsmr-CbzGCzmv.js → useAsmr-BbhQ59bk.js} +1 -1
- package/client/dist/assets/{useAsmrPopup-DaREZ9Ie.js → useAsmrPopup-SymV1J-b.js} +1 -1
- package/client/dist/assets/{useMangaLibrary-BVQRhsFh.js → useMangaLibrary-DuesWQaE.js} +1 -1
- package/client/dist/assets/{useMangaPopup-CzsCbndG.js → useMangaPopup-D57OVGUr.js} +1 -1
- package/client/dist/assets/{useProviders-UuUPzft-.js → useProviders-mpQb_dix.js} +1 -1
- package/client/dist/assets/{useTv-CSsbWKH9.js → useTv-DGflCsSI.js} +1 -1
- package/client/dist/assets/{useTvLibrary-a_Y0c2FS.js → useTvLibrary-BqeSmyc4.js} +1 -1
- package/client/dist/index.html +1 -1
- package/package.json +2 -2
- package/server/dist/app-hono.js +1 -1
- package/server/dist/hono/proxy.js +105 -227
- package/server/dist/hono/tv.js +33 -2
- package/server/dist/providers/remote-loader.js +12 -3
- package/server/dist/providers/remote-types.js +35 -0
- package/server/dist/server.js +3 -0
- package/server/package.json +1 -1
- package/client/dist/assets/AvSyncCalibrator-DmoH5eRA.js +0 -10
- package/server/dist/utils/megaplay.utils.js +0 -40
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as y,h as A,u as e,A as R,g as Pe,S,$ as tt,p as nt,T as j}from"./vendor-core-DfaOB3Rn.js";import{t as Ie,P as it,h as H,z as $}from"./index-BTnhzofk.js";import{I as f}from"./vendor-icons-DrybRNxP.js";import{r as p}from"./Radio.module-DGSZLpKM.js";import{a}from"./Asmr.module-CdWlioTY.js";import{b as ne,u as Ae,a as Ee}from"./vendor-query-BBT5_sHx.js";import{p as te}from"./page.module-C1MlZzf3.js";const pe=new Set,ue=new Map,qe=n=>`/api/image-proxy?url=${encodeURIComponent(n)}&strict=1`,ze=n=>/googleusercontent\.com/.test(n)?n.replace(/=w\d+-h\d+(?:-l\d+)?(?:-rj)?$/,"=w544-h544-l90-rj"):n,Ye=/^[A-Za-z0-9_-]{11}$/;function st(n,s){const l=[],b=n?ue.get(n):void 0;b&&!pe.has(b)&&l.push(b);for(const x of s??[]){if(!x?.url)continue;const w=qe(ze(x.url));pe.has(w)||l.includes(w)||l.push(w)}if(n&&Ye.test(n)){const x=qe(`https://i.ytimg.com/vi/${n}/hqdefault.jpg`);!pe.has(x)&&!l.includes(x)&&l.push(x)}return l}function at(n,s){const l=s?.[0]?.url;return l?ze(l):n&&Ye.test(n)?`https://i.ytimg.com/vi/${n}/hqdefault.jpg`:""}function rt(n,s){!n||pe.has(s)||(ue.set(n,s),ue.size>500&&ue.clear())}function ot(n){pe.add(n);for(const[s,l]of ue)l===n&&ue.delete(s)}function $e({id:n,thumbnails:s}){const[l,b]=y(0),[x,w]=y(!1);A(()=>{b(0),w(!1)},[n]);const _=st(n,s),E=_[l];return x||!E?e("span",{className:p.stationThumbPlaceholder,children:e(f,{name:"headphones"})}):e("img",{src:E,alt:"",className:p.stationThumb,loading:"lazy",decoding:"async",onLoad:()=>rt(n,E),onError:()=>{ot(E),l+1<_.length?b(l+1):w(!0)}})}function Ue(n){if(!Number.isFinite(n)||n<0)return"0:00";const s=Math.floor(n/60),l=Math.floor(n%60);return`${s}:${String(l).padStart(2,"0")}`}const ct=({track:n,shuffle:s,onToggleShuffle:l,onTrackStep:b,onTrackFailed:x,onClose:w,liked:_,likeVisible:E,likePending:de,onToggleLike:ie})=>{const O=R(null),me=R(!1),[T,se]=y(!1),[h,v]=y(!0),[V,B]=y(!1),[F,ae]=y(0),[Z,J]=y(0),[N,re]=y(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[z,oe]=y(()=>localStorage.getItem("musicAutoplay")!=="false"),L=R(N);L.current=N;const k=R(z);k.current=z;const W=R(0),D=R(0),Y=R(null),G=R("");G.current||(G.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const fe=`/api/music/audio?videoId=${encodeURIComponent(n.id)}`,q=Pe.useCallback(()=>{Y.current&&(window.clearTimeout(Y.current),Y.current=null)},[]),ce=Pe.useCallback(r=>{const c=O.current;if(!c)return;q(),v(!0),B(!1);const P=()=>{if(c.removeEventListener("loadedmetadata",P),r>5&&Number.isFinite(c.duration)&&r<c.duration-5)try{c.currentTime=r}catch{}};c.addEventListener("loadedmetadata",P),c.src=fe,c.load(),c.volume=L.current,c.play().catch(()=>{})},[fe,q]),ye=()=>{v(!1),B(!0),x?.(n),k.current&&b(1)},be=()=>{if(!Y.current){if(D.current>=3){ye();return}D.current+=1,Y.current=window.setTimeout(()=>{Y.current=null,ce(W.current)},5e3)}},Q=()=>{D.current=0,ce(W.current)};A(()=>{W.current=0,D.current=0,se(!1),ae(0),J(0);const r=O.current;return ce(W.current),()=>{q(),r&&r.removeAttribute("src")}},[ce,q]),A(()=>{const r=O.current;r&&(r.volume=N)},[N]),A(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const ve=at(n.id,n.thumbnails),K=Pe.useCallback(r=>{const c=O.current;Ie.discord.musicPresence.mutate({title:n.title,artistLabel:n.artists,isPlaying:r,thumbnail:ve||"",currentTime:c?.currentTime??0,duration:Number.isFinite(c?.duration??NaN)?c?.duration:0,sessionId:G.current}).catch(()=>{}),Ie.discord.heartbeat.mutate({sessionId:G.current}).catch(()=>{})},[n,ve]);A(()=>{K(T)},[K,T,n.id]),A(()=>{if(!T)return;const r=window.setInterval(()=>K(!0),15e3);return()=>window.clearInterval(r)},[T,K]),A(()=>{const r=G.current,c=()=>it(r),P=()=>c(),U=()=>{document.visibilityState==="hidden"&&c()};return window.addEventListener("pagehide",P),window.addEventListener("beforeunload",P),document.addEventListener("visibilitychange",U),()=>{window.removeEventListener("pagehide",P),window.removeEventListener("beforeunload",P),document.removeEventListener("visibilitychange",U),c()}},[]);const Se=()=>{const r=O.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},ke=`${n.title} — ${n.artists}`,Ne=e(S,{children:[e("div",{className:a.playerButtons,children:[e("button",{className:a.playerBtn,onClick:()=>b(-1),"aria-label":"Previous track",children:e(f,{name:"step-backward"})}),e("button",{className:`${a.playerBtn} ${a.playBtn}`,onClick:Se,"aria-label":T?"Pause":"Play",children:T?e(f,{name:"pause"}):e(f,{name:"play"})}),e("button",{className:a.playerBtn,onClick:()=>b(1),"aria-label":"Next track",children:e(f,{name:"step-forward"})}),V&&e("button",{className:a.playerBtn,onClick:Q,title:"Retry playback","aria-label":"Retry playback",children:e(f,{name:"redo"})})]}),e("div",{className:a.seekRow,children:[e("span",{className:a.timeLabel,children:Ue(F)}),e("input",{className:a.seekBar,type:"range",min:0,max:Z||0,step:.1,value:Math.min(F,Z||0),onChange:r=>{const c=O.current;!c||!Number.isFinite(c.duration)||(c.currentTime=parseFloat(r.target.value),ae(c.currentTime))},onPointerDown:()=>{me.current=!0},onPointerUp:()=>{me.current=!1},style:{"--played-percent":`${Z>0?F/Z*100:0}%`},"aria-label":"Seek"}),e("span",{className:a.timeLabel,children:Ue(Z)}),h&&!V&&e("span",{className:a.timeLabel,children:"loading…"})]})]}),xe=e(S,{children:[e($e,{id:n.id,thumbnails:n.thumbnails}),e("div",{className:a.playerInfo,children:[e("p",{className:a.playerTitle,title:ke,children:ke}),e("p",{className:a.playerTrack,children:n.artists})]}),e("div",{className:a.playerControls,children:Ne}),e("div",{className:a.playerRight,children:[N===0?e(f,{name:"volume-mute",className:a.volumeIcon}):N<.5?e(f,{name:"volume-down",className:a.volumeIcon}):e(f,{name:"volume-up",className:a.volumeIcon}),e("input",{className:a.volumeBar,type:"range",min:0,max:1,step:.01,value:N,onChange:r=>{const c=parseFloat(r.target.value);re(c),localStorage.setItem("musicVolume",String(c))},style:{"--volume-percent":`${N*100}%`},"aria-label":"Volume"})]}),e("div",{className:a.playerActions,children:[E&&ie&&e("button",{className:`${a.playerBtn} ${_?a.playerBtnActive:""}`,onClick:ie,disabled:de,title:_?"Remove from Liked Music":"Add to Liked Music","aria-label":_?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!_,children:e(f,{name:"heart"})}),e("button",{className:`${a.playerBtn} ${s?a.playerBtnActive:""}`,onClick:l,title:s?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":s,children:e(f,{name:"shuffle"})}),e("button",{className:`${a.playerBtn} ${z?a.playerBtnActive:""}`,onClick:()=>{oe(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:z?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":z,children:e(f,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(n.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:a.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(f,{name:"external-link-alt"})}),e("button",{className:a.playerBtn,onClick:w,"aria-label":"Close player",children:e(f,{name:"times"})})]})]});return tt(e(S,{children:[e("audio",{ref:O,preload:"none",onPlay:()=>{se(!0),v(!1),B(!1),D.current=0,q()},onPause:()=>se(!1),onWaiting:()=>{V||v(!0)},onPlaying:()=>{v(!1),D.current=0,q()},onTimeUpdate:r=>{const c=r.target.currentTime;W.current=c,q(),me.current||ae(c)},onStalled:()=>{be()},onLoadedMetadata:r=>{const c=r.target.duration;Number.isFinite(c)&&J(c)},onDurationChange:r=>{const c=r.target.duration;Number.isFinite(c)&&J(c)},onError:()=>{be()},onEnded:()=>{k.current&&b(1)}}),e("div",{className:a.playerBar,children:xe})]}),document.body)},lt=()=>e("div",{style:{marginTop:"0.9rem",paddingTop:"0.9rem",borderTop:"1px dashed var(--border-color)"},children:[e("h4",{style:{margin:"0 0 0.35rem",fontSize:"0.95rem"},children:"Where to get the cookie"}),e("p",{style:{margin:"0 0 0.6rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Google marks its login cookies unreadable to page scripts, so this has to come from DevTools — it takes about 20 seconds:"}),e("ol",{style:{margin:"0 0 0.75rem",paddingLeft:"1.25rem",fontSize:"0.85rem",color:"var(--text-secondary)",display:"grid",gap:"0.3rem"},children:[e("li",{children:["Open"," ",e("a",{href:"https://music.youtube.com/",target:"_blank",rel:"noopener noreferrer",children:"music.youtube.com"})," ","and make sure you are logged in."]}),e("li",{children:["Press ",e("kbd",{children:"F12"}),", go to the ",e("strong",{children:"Network"})," tab, and type ",e("kbd",{children:"browse"})," ","in the filter box."]}),e("li",{children:["Click any ",e("kbd",{children:"POST"})," browse entry, then scroll to Request Headers."]}),e("li",{children:[e("strong",{children:"Right-click"})," the ",e("kbd",{children:"Cookie"})," value and choose"," ",e("strong",{children:"Copy value"})," — right-click copies the full unwrapped value, selecting the text by hand truncates it."]}),e("li",{children:"Paste it into the sign-in box above and press Sign in."})]})]}),ge=300*1e3,ut=()=>{const n=H();return ne({...n.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:s=>s.state.data?.authenticated?!1:3e3,retry:1})},dt=()=>{const n=H(),s=Ae();return Ee(n.music.authStart.mutationOptions({onSuccess:(l,b)=>{localStorage.setItem("ytmusic_cookie",b.cookie??""),s.invalidateQueries(n.music.pathFilter())}}))},mt=()=>{const n=H(),s=Ae();return Ee(n.music.signOut.mutationOptions({onSuccess:()=>{s.invalidateQueries(n.music.pathFilter())}}))},ht=n=>{const s=H();return ne({...s.music.search.queryOptions({q:n}),enabled:n.trim().length>0,staleTime:ge,retry:1})},pt=n=>{const s=H();return ne({...s.music.library.queryOptions(),enabled:n,staleTime:ge,retry:1})},gt=n=>{const s=H();return ne({...s.music.track.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},ft=n=>{const s=H();return ne({...s.music.playlist.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},yt=n=>{const s=H();return ne({...s.music.upnext.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},bt=n=>{const s=H();return ne({...s.music.likes.queryOptions(),enabled:n,staleTime:120*1e3,retry:1})},vt=()=>{const n=H(),s=Ae();return Ee(n.music.like.mutationOptions({onSuccess:()=>{s.invalidateQueries(n.music.pathFilter())}}))},kt="_authRow_10tvv_1",Nt="_btn_10tvv_9",wt="_btnGhost_10tvv_42",St="_cookieForm_10tvv_74",xt="_cookieInput_10tvv_83",Tt="_link_10tvv_99",Lt="_contentLayout_10tvv_109",Mt="_mainCol_10tvv_116",_t="_upnextAside_10tvv_120",Ct="_upnextHeader_10tvv_131",Rt="_upnextTitle_10tvv_139",Pt="_upnextActions_10tvv_149",It="_nowPlayingLabel_10tvv_156",$t="_nowPlayingWrap_10tvv_168",At="_likeBtn_10tvv_172",Et="_likeActive_10tvv_196",g={authRow:kt,btn:Nt,btnGhost:wt,cookieForm:St,cookieInput:xt,link:Tt,contentLayout:Lt,mainCol:Mt,upnextAside:_t,upnextHeader:Ct,upnextTitle:Rt,upnextActions:Pt,nowPlayingLabel:It,nowPlayingWrap:$t,likeBtn:At,likeActive:Et};function He(n){const s=n.trim();if(!s)return null;const l=s.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??s.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return l||(/^[A-Za-z0-9_-]{11}$/.test(s)?s:null)}const Ot="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Yt=()=>{const[n,s]=nt(),l=He(n.get("v")??""),[b,x]=y(()=>n.get("q")??""),w=n.get("q")??"";A(()=>{x(w)},[w]);const[_,E]=y(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[de,ie]=y(!1),[O,me]=y(()=>localStorage.getItem("musicShuffle")==="true"),[T,se]=y(()=>localStorage.getItem("musicRadio")!=="false"),[h,v]=y(null),[V,B]=y([]),[F,ae]=y(null),[Z,J]=y({}),N=R([]);N.current=V;const re=R(null);re.current=h;const z=R(!1),oe=R(new Set),{data:L}=ut(),k=dt(),W=mt(),D=typeof navigator<"u"?navigator.userAgent:"",Y=/android/i.test(D),G=/firefox|fxios/i.test(D)&&!Y,fe=!G&&!Y&&/chrome|chromium|edg|brave/i.test(D),q=G||fe,ce=()=>{if(de)return;ie(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",o),ie(!1),$.error("Helper not detected — install the Dango Helper extension first.")},3e3),o=d=>{let m;try{m=JSON.parse(d.detail)}catch{return}if(!(!m||m.requestId!==t))if(window.clearTimeout(i),window.removeEventListener("dango:ytmusic-cookie",o),ie(!1),m?.ok&&m.cookie){const u=m.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(u.includes("…")||u.includes("...")){$.error(`Helper returned a truncated cookie (${u.length} chars) — reload music.youtube.com and Extract again.`);return}E(u),$.success("Cookie extracted from helper — signing in…"),k.mutate({cookie:u})}else m?.error==="NO_COOKIE"?$.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):$.error("Helper request failed — try again.")};window.addEventListener("dango:ytmusic-cookie",o),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:ye,isLoading:be}=ht(w),{data:Q,isLoading:ve,isFetching:K,error:Se,refetch:ke}=pt(L?.authenticated===!0),{data:Ne,isLoading:xe}=ft(F?.id??null),{data:Te,isLoading:r}=yt(h?.id??null),{data:c}=bt(L?.authenticated===!0),P=vt(),U=j(()=>ye?.tracks||[],[ye]),Le=j(()=>Q?.playlists||[],[Q]),I=j(()=>Q?.tracks||[],[Q]),X=j(()=>Ne?.tracks||[],[Ne]),M=j(()=>{const t=Te?.tracks||[];return h?t.filter(i=>i.id!==h.id):t},[Te,h]),Ge=j(()=>new Set(c?.likedIds||[]),[c]),Me=t=>Z[t.id]??(Ge.has(t.id)||t.liked===!0);A(()=>{L?.authenticated!==!0&&J({})},[L?.authenticated]);const Qe=j(()=>[...U,...X,...I,...M],[U,X,I,M]),Ve=l&&h?.id!==l&&!Qe.some(t=>t.id===l)?l:null,{data:Oe}=gt(Ve),_e=h?.id;A(()=>{document.title=h?`${h.title} - dango`:"Music - dango"},[h]),A(()=>{if(!l){_e&&v(null);return}if(_e===l)return;const t=d=>{const m=d.find(u=>u.id===l);return m?(v(m),B(u=>u.some(le=>le.id===l)?u:d.length>0?d:[m]),!0):!1};if(t(U)||t(X)||t(I))return;const i=M.find(d=>d.id===l);if(i){v(i),B(d=>d.some(m=>m.id===i.id)?d:[i]);return}const o=Oe?.track;o&&o.id===l&&(v(o),B(d=>d.some(m=>m.id===o.id)?d:[o]))},[l,_e,U,X,I,M,Oe]);const ee=t=>{s(i=>{const o=new URLSearchParams(i);return t?o.set("v",t):o.delete("v"),o})},Ce=(t,i)=>{oe.current.delete(t.id),v(t),B(i.length>0?i:[t]),ee(t.id)},We=t=>{oe.current.add(t.id),$.error(`Couldn't play “${t.title}” — skipped.`)},je=async()=>{if(z.current)return;const t=N.current,i=t[t.length-1]??re.current;if(i){z.current=!0;try{const o=await Ie.music.upnext.query({id:i.id}),d=new Set(t.map(u=>u.id)),m=(o.tracks||[]).filter(u=>!d.has(u.id)&&!oe.current.has(u.id));if(m.length===0){const u=N.current[0];u&&(v(u),ee(u.id));return}B([...N.current,...m]),v(m[0]),ee(m[0].id)}catch{const o=N.current[0];o&&(v(o),ee(o.id))}finally{z.current=!1}}},Ze=t=>{const i=N.current,o=re.current;if(!o||i.length===0)return;const d=i.findIndex(C=>C.id===o.id);if(t>0&&T&&(d<0||d===i.length-1)){je();return}const m=C=>oe.current.has(C.id),u=i.length;let le;if(O&&u>1){let C=Math.floor(Math.random()*u);for(let Re=0;Re<u&&(C===d||m(i[C]));Re++)C=Math.floor(Math.random()*u);le=i[C]}else{const C=t>0?1:-1;let we=(((d<0?C>0?-1:0:d)+C)%u+u)%u;for(let De=1;De<u&&m(i[we]);De++)we=((we+C)%u+u)%u;le=i[we]}v(le),ee(le.id)},Je=()=>{if(T){se(!1),localStorage.setItem("musicRadio","false");return}const t=re.current;if(!t)return;if(M.length===0){$.error("No radio suggestions for this song yet.");return}const i=new Set,o=[];for(const d of[t,...M])i.has(d.id)||(i.add(d.id),o.push(d));se(!0),localStorage.setItem("musicRadio","true"),B(o),$.success(`Radio started — ${M.length} songs queued.`)},Be=t=>{if(L?.authenticated!==!0){$.error("Sign in to like songs.");return}const i=!Me(t);J(o=>({...o,[t.id]:i})),P.mutate({id:t.id,like:i},{onError:()=>{J(o=>{const d={...o};return delete d[t.id],d}),$.error("Like action failed — try again.")}})},Ke=()=>{me(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Xe=t=>e("button",{className:p.stationRow,onClick:()=>ae(t),"aria-label":`Open ${t.title}`,children:[e($e,{id:t.id,thumbnails:t.thumbnails}),e("span",{className:p.stationMeta,children:[e("span",{className:p.stationName,children:t.title}),t.subtitle&&e("span",{className:p.stationSub,children:t.subtitle})]})]},t.id),he=(t,i,o)=>{const d=h?.id===t.id,m=Me(t),u=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${p.stationRow} ${d?p.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>o?o(t):Ce(t,i),className:p.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[e($e,{id:t.id,thumbnails:t.thumbnails}),e("span",{className:p.stationMeta,children:[e("span",{className:p.stationName,children:t.title}),e("span",{className:p.stationSub,children:[t.artists,u?` · ${u}`:""]})]})]}),L?.authenticated===!0&&e("button",{className:`${g.likeBtn} ${m?g.likeActive:""}`,onClick:()=>Be(t),disabled:P.isPending,title:m?"Remove from Liked Music":"Add to Liked Music","aria-label":m?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":m,children:e(f,{name:"heart"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(t.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":`Open ${t.title} in YouTube Music`,style:{padding:8,color:"inherit",opacity:.7,flexShrink:0},children:e(f,{name:"external-link-alt"})})]},t.id)},Fe=j(()=>{if(!h)return M;const t=new Set,i=[];for(const o of[h,...M])t.has(o.id)||(t.add(o.id),i.push(o));return i},[h,M]),et=t=>{Ce(t,Fe)};return e("div",{className:`${te.page} ${h?te.pageWithPlayer:""}`,children:[e("div",{className:te.header,children:[e("h1",{className:te.pageTitle,children:[e(f,{name:"headphones"})," Music"]}),e("form",{className:te.searchForm,onSubmit:t=>{t.preventDefault();const i=He(b);if(i)ee(i);else{const o=b.trim();s(d=>{const m=new URLSearchParams(d);return o?m.set("q",o):m.delete("q"),m})}},children:[e("input",{className:te.searchInput,value:b,onChange:t=>x(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:te.searchBtn,type:"submit","aria-label":"Search",children:e(f,{name:"search"})})]})]}),e("div",{className:g.authRow,children:[L?.authenticated?e(S,{children:[e("span",{className:a.statusMsg,children:["Signed in to YouTube Music",Q&&` — ${Q.tracks.length} songs, ${Q.playlists.length} playlists`]}),e("button",{className:g.btnGhost,onClick:()=>W.mutate(),disabled:W.isPending,children:"Sign out"})]}):e(S,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=_.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){$.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==_&&E(i),k.mutate({cookie:i})}},className:g.cookieForm,children:[e("input",{className:g.cookieInput,value:_,onChange:t=>E(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:g.btn,type:"submit",disabled:k.isPending||!_.trim(),children:k.isPending?"Checking…":"Sign in"}),q&&e("button",{className:g.btnGhost,type:"button",onClick:ce,disabled:de||k.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:de?"Extracting…":"Extract from helper"})]}),q&&e("p",{className:a.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:Ot,target:"_blank",rel:"noreferrer",className:g.link,children:"dango-extension.zip"})," ","then"," ",G?e(S,{children:[e("code",{children:"about:debugging"})," → ",e("strong",{children:"This Firefox"})," →"," ",e("strong",{children:"Load Temporary Add-on"})," →"," ",e("code",{children:"dango-extension/firefox/manifest.json"})]}):e(S,{children:[e("code",{children:"chrome://extensions"})," → ",e("strong",{children:"Developer mode"})," →"," ",e("strong",{children:"Load unpacked"})," → ",e("code",{children:"dango-extension/chrome"})]}),", log in on a music.youtube.com tab, and click Extract."]}),e(lt,{})]}),k.isSuccess&&e("p",{className:a.statusMsg,children:["Signed in — found ",k.data.tracks," songs and ",k.data.playlists," ","playlists."]}),k.isError&&e("p",{className:a.statusMsg,children:k.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!L?.authenticated&&!k.isError&&!k.isSuccess&&e("p",{className:a.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:h?g.contentLayout:void 0,children:[e("div",{className:g.mainCol,children:w?e(S,{children:[e("h2",{className:p.sectionTitle,children:["Results for “",w,"”"]}),be?e("p",{className:a.statusMsg,children:"Searching…"}):U.length===0?e("p",{className:a.statusMsg,children:"No tracks found."}):e("div",{className:p.stationList,children:U.map(t=>he(t,U))})]}):L?.authenticated?e(S,{children:[e("h2",{className:p.sectionTitle,children:"Your library"}),ve?e("p",{className:a.statusMsg,children:"Loading library…"}):Le.length===0&&I.length===0&&!F?e(S,{children:[e("p",{className:a.statusMsg,children:Se?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:g.btnGhost,onClick:()=>{ke()},disabled:K,"aria-label":"Retry loading library",children:K?"Retrying…":"Retry"})}),e("p",{className:a.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(S,{children:[Le.length>0&&!F&&e(S,{children:[e("h3",{className:p.sectionTitle,children:"Playlists"}),e("div",{className:p.stationList,children:Le.map(t=>Xe(t))})]}),I.length>0&&!F&&e(S,{children:[e("h3",{className:p.sectionTitle,children:["Liked songs (",I.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:g.btnGhost,onClick:()=>Ce(I[0],I),"aria-label":"Play all liked songs",children:[e(f,{name:"play"})," Play all"]})}),e("div",{className:p.stationList,children:I.map(t=>he(t,I))})]}),F?e(S,{children:[e("button",{className:g.btnGhost,onClick:()=>ae(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:p.sectionTitle,children:F.title}),xe?e("p",{className:a.statusMsg,children:"Loading playlist…"}):X.length===0?e("p",{className:a.statusMsg,children:"No tracks in this playlist."}):e("div",{className:p.stationList,children:X.map(t=>he(t,X))})]}):null]})]}):e("p",{className:a.statusMsg,children:"Search above, or sign in to see your library."})}),h&&e("aside",{className:g.upnextAside,"aria-label":"Up next",children:[e("div",{className:g.upnextHeader,children:e("span",{className:g.upnextTitle,children:[e(f,{name:"list-ul"})," Up Next"]})}),e("div",{className:g.nowPlayingWrap,children:[e("p",{className:g.nowPlayingLabel,children:"Now playing"}),he(h,V.length>0?V:[h])]}),e("div",{className:g.upnextActions,children:e("button",{className:g.btnGhost,onClick:Je,disabled:!T&&(r||M.length===0),"aria-pressed":T,title:T?"Stop the radio — the queue will loop instead of fetching more songs":"Queue these suggestions after the current song and keep the mix going",children:T?"Stop radio":"Start radio"})}),r?e("p",{className:a.statusMsg,children:"Loading suggestions…"}):M.length===0?e("p",{className:a.statusMsg,children:"No suggestions for this song."}):e("div",{className:p.stationList,children:M.map(t=>he(t,Fe,et))})]})]}),h&&e(ct,{track:h,queue:V,shuffle:O,onToggleShuffle:Ke,onTrackStep:Ze,onTrackFailed:We,onClose:()=>{v(null),ee(null)},liked:h?Me(h):!1,likeVisible:L?.authenticated===!0,likePending:P.isPending,onToggleLike:()=>Be(h)})]})};export{Yt as default};
|
|
1
|
+
import{d as y,h as A,u as e,A as R,g as Pe,S,$ as tt,p as nt,T as j}from"./vendor-core-DfaOB3Rn.js";import{t as Ie,P as it,h as H,z as $}from"./index-CnfZwsds.js";import{I as f}from"./vendor-icons-DrybRNxP.js";import{r as p}from"./Radio.module-DGSZLpKM.js";import{a}from"./Asmr.module-CdWlioTY.js";import{b as ne,u as Ae,a as Ee}from"./vendor-query-BBT5_sHx.js";import{p as te}from"./page.module-C1MlZzf3.js";const pe=new Set,ue=new Map,qe=n=>`/api/image-proxy?url=${encodeURIComponent(n)}&strict=1`,ze=n=>/googleusercontent\.com/.test(n)?n.replace(/=w\d+-h\d+(?:-l\d+)?(?:-rj)?$/,"=w544-h544-l90-rj"):n,Ye=/^[A-Za-z0-9_-]{11}$/;function st(n,s){const l=[],b=n?ue.get(n):void 0;b&&!pe.has(b)&&l.push(b);for(const x of s??[]){if(!x?.url)continue;const w=qe(ze(x.url));pe.has(w)||l.includes(w)||l.push(w)}if(n&&Ye.test(n)){const x=qe(`https://i.ytimg.com/vi/${n}/hqdefault.jpg`);!pe.has(x)&&!l.includes(x)&&l.push(x)}return l}function at(n,s){const l=s?.[0]?.url;return l?ze(l):n&&Ye.test(n)?`https://i.ytimg.com/vi/${n}/hqdefault.jpg`:""}function rt(n,s){!n||pe.has(s)||(ue.set(n,s),ue.size>500&&ue.clear())}function ot(n){pe.add(n);for(const[s,l]of ue)l===n&&ue.delete(s)}function $e({id:n,thumbnails:s}){const[l,b]=y(0),[x,w]=y(!1);A(()=>{b(0),w(!1)},[n]);const _=st(n,s),E=_[l];return x||!E?e("span",{className:p.stationThumbPlaceholder,children:e(f,{name:"headphones"})}):e("img",{src:E,alt:"",className:p.stationThumb,loading:"lazy",decoding:"async",onLoad:()=>rt(n,E),onError:()=>{ot(E),l+1<_.length?b(l+1):w(!0)}})}function Ue(n){if(!Number.isFinite(n)||n<0)return"0:00";const s=Math.floor(n/60),l=Math.floor(n%60);return`${s}:${String(l).padStart(2,"0")}`}const ct=({track:n,shuffle:s,onToggleShuffle:l,onTrackStep:b,onTrackFailed:x,onClose:w,liked:_,likeVisible:E,likePending:de,onToggleLike:ie})=>{const O=R(null),me=R(!1),[T,se]=y(!1),[h,v]=y(!0),[V,B]=y(!1),[F,ae]=y(0),[Z,J]=y(0),[N,re]=y(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[z,oe]=y(()=>localStorage.getItem("musicAutoplay")!=="false"),L=R(N);L.current=N;const k=R(z);k.current=z;const W=R(0),D=R(0),Y=R(null),G=R("");G.current||(G.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const fe=`/api/music/audio?videoId=${encodeURIComponent(n.id)}`,q=Pe.useCallback(()=>{Y.current&&(window.clearTimeout(Y.current),Y.current=null)},[]),ce=Pe.useCallback(r=>{const c=O.current;if(!c)return;q(),v(!0),B(!1);const P=()=>{if(c.removeEventListener("loadedmetadata",P),r>5&&Number.isFinite(c.duration)&&r<c.duration-5)try{c.currentTime=r}catch{}};c.addEventListener("loadedmetadata",P),c.src=fe,c.load(),c.volume=L.current,c.play().catch(()=>{})},[fe,q]),ye=()=>{v(!1),B(!0),x?.(n),k.current&&b(1)},be=()=>{if(!Y.current){if(D.current>=3){ye();return}D.current+=1,Y.current=window.setTimeout(()=>{Y.current=null,ce(W.current)},5e3)}},Q=()=>{D.current=0,ce(W.current)};A(()=>{W.current=0,D.current=0,se(!1),ae(0),J(0);const r=O.current;return ce(W.current),()=>{q(),r&&r.removeAttribute("src")}},[ce,q]),A(()=>{const r=O.current;r&&(r.volume=N)},[N]),A(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const ve=at(n.id,n.thumbnails),K=Pe.useCallback(r=>{const c=O.current;Ie.discord.musicPresence.mutate({title:n.title,artistLabel:n.artists,isPlaying:r,thumbnail:ve||"",currentTime:c?.currentTime??0,duration:Number.isFinite(c?.duration??NaN)?c?.duration:0,sessionId:G.current}).catch(()=>{}),Ie.discord.heartbeat.mutate({sessionId:G.current}).catch(()=>{})},[n,ve]);A(()=>{K(T)},[K,T,n.id]),A(()=>{if(!T)return;const r=window.setInterval(()=>K(!0),15e3);return()=>window.clearInterval(r)},[T,K]),A(()=>{const r=G.current,c=()=>it(r),P=()=>c(),U=()=>{document.visibilityState==="hidden"&&c()};return window.addEventListener("pagehide",P),window.addEventListener("beforeunload",P),document.addEventListener("visibilitychange",U),()=>{window.removeEventListener("pagehide",P),window.removeEventListener("beforeunload",P),document.removeEventListener("visibilitychange",U),c()}},[]);const Se=()=>{const r=O.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},ke=`${n.title} — ${n.artists}`,Ne=e(S,{children:[e("div",{className:a.playerButtons,children:[e("button",{className:a.playerBtn,onClick:()=>b(-1),"aria-label":"Previous track",children:e(f,{name:"step-backward"})}),e("button",{className:`${a.playerBtn} ${a.playBtn}`,onClick:Se,"aria-label":T?"Pause":"Play",children:T?e(f,{name:"pause"}):e(f,{name:"play"})}),e("button",{className:a.playerBtn,onClick:()=>b(1),"aria-label":"Next track",children:e(f,{name:"step-forward"})}),V&&e("button",{className:a.playerBtn,onClick:Q,title:"Retry playback","aria-label":"Retry playback",children:e(f,{name:"redo"})})]}),e("div",{className:a.seekRow,children:[e("span",{className:a.timeLabel,children:Ue(F)}),e("input",{className:a.seekBar,type:"range",min:0,max:Z||0,step:.1,value:Math.min(F,Z||0),onChange:r=>{const c=O.current;!c||!Number.isFinite(c.duration)||(c.currentTime=parseFloat(r.target.value),ae(c.currentTime))},onPointerDown:()=>{me.current=!0},onPointerUp:()=>{me.current=!1},style:{"--played-percent":`${Z>0?F/Z*100:0}%`},"aria-label":"Seek"}),e("span",{className:a.timeLabel,children:Ue(Z)}),h&&!V&&e("span",{className:a.timeLabel,children:"loading…"})]})]}),xe=e(S,{children:[e($e,{id:n.id,thumbnails:n.thumbnails}),e("div",{className:a.playerInfo,children:[e("p",{className:a.playerTitle,title:ke,children:ke}),e("p",{className:a.playerTrack,children:n.artists})]}),e("div",{className:a.playerControls,children:Ne}),e("div",{className:a.playerRight,children:[N===0?e(f,{name:"volume-mute",className:a.volumeIcon}):N<.5?e(f,{name:"volume-down",className:a.volumeIcon}):e(f,{name:"volume-up",className:a.volumeIcon}),e("input",{className:a.volumeBar,type:"range",min:0,max:1,step:.01,value:N,onChange:r=>{const c=parseFloat(r.target.value);re(c),localStorage.setItem("musicVolume",String(c))},style:{"--volume-percent":`${N*100}%`},"aria-label":"Volume"})]}),e("div",{className:a.playerActions,children:[E&&ie&&e("button",{className:`${a.playerBtn} ${_?a.playerBtnActive:""}`,onClick:ie,disabled:de,title:_?"Remove from Liked Music":"Add to Liked Music","aria-label":_?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!_,children:e(f,{name:"heart"})}),e("button",{className:`${a.playerBtn} ${s?a.playerBtnActive:""}`,onClick:l,title:s?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":s,children:e(f,{name:"shuffle"})}),e("button",{className:`${a.playerBtn} ${z?a.playerBtnActive:""}`,onClick:()=>{oe(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:z?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":z,children:e(f,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(n.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:a.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(f,{name:"external-link-alt"})}),e("button",{className:a.playerBtn,onClick:w,"aria-label":"Close player",children:e(f,{name:"times"})})]})]});return tt(e(S,{children:[e("audio",{ref:O,preload:"none",onPlay:()=>{se(!0),v(!1),B(!1),D.current=0,q()},onPause:()=>se(!1),onWaiting:()=>{V||v(!0)},onPlaying:()=>{v(!1),D.current=0,q()},onTimeUpdate:r=>{const c=r.target.currentTime;W.current=c,q(),me.current||ae(c)},onStalled:()=>{be()},onLoadedMetadata:r=>{const c=r.target.duration;Number.isFinite(c)&&J(c)},onDurationChange:r=>{const c=r.target.duration;Number.isFinite(c)&&J(c)},onError:()=>{be()},onEnded:()=>{k.current&&b(1)}}),e("div",{className:a.playerBar,children:xe})]}),document.body)},lt=()=>e("div",{style:{marginTop:"0.9rem",paddingTop:"0.9rem",borderTop:"1px dashed var(--border-color)"},children:[e("h4",{style:{margin:"0 0 0.35rem",fontSize:"0.95rem"},children:"Where to get the cookie"}),e("p",{style:{margin:"0 0 0.6rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Google marks its login cookies unreadable to page scripts, so this has to come from DevTools — it takes about 20 seconds:"}),e("ol",{style:{margin:"0 0 0.75rem",paddingLeft:"1.25rem",fontSize:"0.85rem",color:"var(--text-secondary)",display:"grid",gap:"0.3rem"},children:[e("li",{children:["Open"," ",e("a",{href:"https://music.youtube.com/",target:"_blank",rel:"noopener noreferrer",children:"music.youtube.com"})," ","and make sure you are logged in."]}),e("li",{children:["Press ",e("kbd",{children:"F12"}),", go to the ",e("strong",{children:"Network"})," tab, and type ",e("kbd",{children:"browse"})," ","in the filter box."]}),e("li",{children:["Click any ",e("kbd",{children:"POST"})," browse entry, then scroll to Request Headers."]}),e("li",{children:[e("strong",{children:"Right-click"})," the ",e("kbd",{children:"Cookie"})," value and choose"," ",e("strong",{children:"Copy value"})," — right-click copies the full unwrapped value, selecting the text by hand truncates it."]}),e("li",{children:"Paste it into the sign-in box above and press Sign in."})]})]}),ge=300*1e3,ut=()=>{const n=H();return ne({...n.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:s=>s.state.data?.authenticated?!1:3e3,retry:1})},dt=()=>{const n=H(),s=Ae();return Ee(n.music.authStart.mutationOptions({onSuccess:(l,b)=>{localStorage.setItem("ytmusic_cookie",b.cookie??""),s.invalidateQueries(n.music.pathFilter())}}))},mt=()=>{const n=H(),s=Ae();return Ee(n.music.signOut.mutationOptions({onSuccess:()=>{s.invalidateQueries(n.music.pathFilter())}}))},ht=n=>{const s=H();return ne({...s.music.search.queryOptions({q:n}),enabled:n.trim().length>0,staleTime:ge,retry:1})},pt=n=>{const s=H();return ne({...s.music.library.queryOptions(),enabled:n,staleTime:ge,retry:1})},gt=n=>{const s=H();return ne({...s.music.track.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},ft=n=>{const s=H();return ne({...s.music.playlist.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},yt=n=>{const s=H();return ne({...s.music.upnext.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},bt=n=>{const s=H();return ne({...s.music.likes.queryOptions(),enabled:n,staleTime:120*1e3,retry:1})},vt=()=>{const n=H(),s=Ae();return Ee(n.music.like.mutationOptions({onSuccess:()=>{s.invalidateQueries(n.music.pathFilter())}}))},kt="_authRow_10tvv_1",Nt="_btn_10tvv_9",wt="_btnGhost_10tvv_42",St="_cookieForm_10tvv_74",xt="_cookieInput_10tvv_83",Tt="_link_10tvv_99",Lt="_contentLayout_10tvv_109",Mt="_mainCol_10tvv_116",_t="_upnextAside_10tvv_120",Ct="_upnextHeader_10tvv_131",Rt="_upnextTitle_10tvv_139",Pt="_upnextActions_10tvv_149",It="_nowPlayingLabel_10tvv_156",$t="_nowPlayingWrap_10tvv_168",At="_likeBtn_10tvv_172",Et="_likeActive_10tvv_196",g={authRow:kt,btn:Nt,btnGhost:wt,cookieForm:St,cookieInput:xt,link:Tt,contentLayout:Lt,mainCol:Mt,upnextAside:_t,upnextHeader:Ct,upnextTitle:Rt,upnextActions:Pt,nowPlayingLabel:It,nowPlayingWrap:$t,likeBtn:At,likeActive:Et};function He(n){const s=n.trim();if(!s)return null;const l=s.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??s.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return l||(/^[A-Za-z0-9_-]{11}$/.test(s)?s:null)}const Ot="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Yt=()=>{const[n,s]=nt(),l=He(n.get("v")??""),[b,x]=y(()=>n.get("q")??""),w=n.get("q")??"";A(()=>{x(w)},[w]);const[_,E]=y(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[de,ie]=y(!1),[O,me]=y(()=>localStorage.getItem("musicShuffle")==="true"),[T,se]=y(()=>localStorage.getItem("musicRadio")!=="false"),[h,v]=y(null),[V,B]=y([]),[F,ae]=y(null),[Z,J]=y({}),N=R([]);N.current=V;const re=R(null);re.current=h;const z=R(!1),oe=R(new Set),{data:L}=ut(),k=dt(),W=mt(),D=typeof navigator<"u"?navigator.userAgent:"",Y=/android/i.test(D),G=/firefox|fxios/i.test(D)&&!Y,fe=!G&&!Y&&/chrome|chromium|edg|brave/i.test(D),q=G||fe,ce=()=>{if(de)return;ie(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",o),ie(!1),$.error("Helper not detected — install the Dango Helper extension first.")},3e3),o=d=>{let m;try{m=JSON.parse(d.detail)}catch{return}if(!(!m||m.requestId!==t))if(window.clearTimeout(i),window.removeEventListener("dango:ytmusic-cookie",o),ie(!1),m?.ok&&m.cookie){const u=m.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(u.includes("…")||u.includes("...")){$.error(`Helper returned a truncated cookie (${u.length} chars) — reload music.youtube.com and Extract again.`);return}E(u),$.success("Cookie extracted from helper — signing in…"),k.mutate({cookie:u})}else m?.error==="NO_COOKIE"?$.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):$.error("Helper request failed — try again.")};window.addEventListener("dango:ytmusic-cookie",o),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:ye,isLoading:be}=ht(w),{data:Q,isLoading:ve,isFetching:K,error:Se,refetch:ke}=pt(L?.authenticated===!0),{data:Ne,isLoading:xe}=ft(F?.id??null),{data:Te,isLoading:r}=yt(h?.id??null),{data:c}=bt(L?.authenticated===!0),P=vt(),U=j(()=>ye?.tracks||[],[ye]),Le=j(()=>Q?.playlists||[],[Q]),I=j(()=>Q?.tracks||[],[Q]),X=j(()=>Ne?.tracks||[],[Ne]),M=j(()=>{const t=Te?.tracks||[];return h?t.filter(i=>i.id!==h.id):t},[Te,h]),Ge=j(()=>new Set(c?.likedIds||[]),[c]),Me=t=>Z[t.id]??(Ge.has(t.id)||t.liked===!0);A(()=>{L?.authenticated!==!0&&J({})},[L?.authenticated]);const Qe=j(()=>[...U,...X,...I,...M],[U,X,I,M]),Ve=l&&h?.id!==l&&!Qe.some(t=>t.id===l)?l:null,{data:Oe}=gt(Ve),_e=h?.id;A(()=>{document.title=h?`${h.title} - dango`:"Music - dango"},[h]),A(()=>{if(!l){_e&&v(null);return}if(_e===l)return;const t=d=>{const m=d.find(u=>u.id===l);return m?(v(m),B(u=>u.some(le=>le.id===l)?u:d.length>0?d:[m]),!0):!1};if(t(U)||t(X)||t(I))return;const i=M.find(d=>d.id===l);if(i){v(i),B(d=>d.some(m=>m.id===i.id)?d:[i]);return}const o=Oe?.track;o&&o.id===l&&(v(o),B(d=>d.some(m=>m.id===o.id)?d:[o]))},[l,_e,U,X,I,M,Oe]);const ee=t=>{s(i=>{const o=new URLSearchParams(i);return t?o.set("v",t):o.delete("v"),o})},Ce=(t,i)=>{oe.current.delete(t.id),v(t),B(i.length>0?i:[t]),ee(t.id)},We=t=>{oe.current.add(t.id),$.error(`Couldn't play “${t.title}” — skipped.`)},je=async()=>{if(z.current)return;const t=N.current,i=t[t.length-1]??re.current;if(i){z.current=!0;try{const o=await Ie.music.upnext.query({id:i.id}),d=new Set(t.map(u=>u.id)),m=(o.tracks||[]).filter(u=>!d.has(u.id)&&!oe.current.has(u.id));if(m.length===0){const u=N.current[0];u&&(v(u),ee(u.id));return}B([...N.current,...m]),v(m[0]),ee(m[0].id)}catch{const o=N.current[0];o&&(v(o),ee(o.id))}finally{z.current=!1}}},Ze=t=>{const i=N.current,o=re.current;if(!o||i.length===0)return;const d=i.findIndex(C=>C.id===o.id);if(t>0&&T&&(d<0||d===i.length-1)){je();return}const m=C=>oe.current.has(C.id),u=i.length;let le;if(O&&u>1){let C=Math.floor(Math.random()*u);for(let Re=0;Re<u&&(C===d||m(i[C]));Re++)C=Math.floor(Math.random()*u);le=i[C]}else{const C=t>0?1:-1;let we=(((d<0?C>0?-1:0:d)+C)%u+u)%u;for(let De=1;De<u&&m(i[we]);De++)we=((we+C)%u+u)%u;le=i[we]}v(le),ee(le.id)},Je=()=>{if(T){se(!1),localStorage.setItem("musicRadio","false");return}const t=re.current;if(!t)return;if(M.length===0){$.error("No radio suggestions for this song yet.");return}const i=new Set,o=[];for(const d of[t,...M])i.has(d.id)||(i.add(d.id),o.push(d));se(!0),localStorage.setItem("musicRadio","true"),B(o),$.success(`Radio started — ${M.length} songs queued.`)},Be=t=>{if(L?.authenticated!==!0){$.error("Sign in to like songs.");return}const i=!Me(t);J(o=>({...o,[t.id]:i})),P.mutate({id:t.id,like:i},{onError:()=>{J(o=>{const d={...o};return delete d[t.id],d}),$.error("Like action failed — try again.")}})},Ke=()=>{me(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Xe=t=>e("button",{className:p.stationRow,onClick:()=>ae(t),"aria-label":`Open ${t.title}`,children:[e($e,{id:t.id,thumbnails:t.thumbnails}),e("span",{className:p.stationMeta,children:[e("span",{className:p.stationName,children:t.title}),t.subtitle&&e("span",{className:p.stationSub,children:t.subtitle})]})]},t.id),he=(t,i,o)=>{const d=h?.id===t.id,m=Me(t),u=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${p.stationRow} ${d?p.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>o?o(t):Ce(t,i),className:p.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[e($e,{id:t.id,thumbnails:t.thumbnails}),e("span",{className:p.stationMeta,children:[e("span",{className:p.stationName,children:t.title}),e("span",{className:p.stationSub,children:[t.artists,u?` · ${u}`:""]})]})]}),L?.authenticated===!0&&e("button",{className:`${g.likeBtn} ${m?g.likeActive:""}`,onClick:()=>Be(t),disabled:P.isPending,title:m?"Remove from Liked Music":"Add to Liked Music","aria-label":m?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":m,children:e(f,{name:"heart"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(t.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":`Open ${t.title} in YouTube Music`,style:{padding:8,color:"inherit",opacity:.7,flexShrink:0},children:e(f,{name:"external-link-alt"})})]},t.id)},Fe=j(()=>{if(!h)return M;const t=new Set,i=[];for(const o of[h,...M])t.has(o.id)||(t.add(o.id),i.push(o));return i},[h,M]),et=t=>{Ce(t,Fe)};return e("div",{className:`${te.page} ${h?te.pageWithPlayer:""}`,children:[e("div",{className:te.header,children:[e("h1",{className:te.pageTitle,children:[e(f,{name:"headphones"})," Music"]}),e("form",{className:te.searchForm,onSubmit:t=>{t.preventDefault();const i=He(b);if(i)ee(i);else{const o=b.trim();s(d=>{const m=new URLSearchParams(d);return o?m.set("q",o):m.delete("q"),m})}},children:[e("input",{className:te.searchInput,value:b,onChange:t=>x(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:te.searchBtn,type:"submit","aria-label":"Search",children:e(f,{name:"search"})})]})]}),e("div",{className:g.authRow,children:[L?.authenticated?e(S,{children:[e("span",{className:a.statusMsg,children:["Signed in to YouTube Music",Q&&` — ${Q.tracks.length} songs, ${Q.playlists.length} playlists`]}),e("button",{className:g.btnGhost,onClick:()=>W.mutate(),disabled:W.isPending,children:"Sign out"})]}):e(S,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=_.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){$.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==_&&E(i),k.mutate({cookie:i})}},className:g.cookieForm,children:[e("input",{className:g.cookieInput,value:_,onChange:t=>E(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:g.btn,type:"submit",disabled:k.isPending||!_.trim(),children:k.isPending?"Checking…":"Sign in"}),q&&e("button",{className:g.btnGhost,type:"button",onClick:ce,disabled:de||k.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:de?"Extracting…":"Extract from helper"})]}),q&&e("p",{className:a.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:Ot,target:"_blank",rel:"noreferrer",className:g.link,children:"dango-extension.zip"})," ","then"," ",G?e(S,{children:[e("code",{children:"about:debugging"})," → ",e("strong",{children:"This Firefox"})," →"," ",e("strong",{children:"Load Temporary Add-on"})," →"," ",e("code",{children:"dango-extension/firefox/manifest.json"})]}):e(S,{children:[e("code",{children:"chrome://extensions"})," → ",e("strong",{children:"Developer mode"})," →"," ",e("strong",{children:"Load unpacked"})," → ",e("code",{children:"dango-extension/chrome"})]}),", log in on a music.youtube.com tab, and click Extract."]}),e(lt,{})]}),k.isSuccess&&e("p",{className:a.statusMsg,children:["Signed in — found ",k.data.tracks," songs and ",k.data.playlists," ","playlists."]}),k.isError&&e("p",{className:a.statusMsg,children:k.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!L?.authenticated&&!k.isError&&!k.isSuccess&&e("p",{className:a.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:h?g.contentLayout:void 0,children:[e("div",{className:g.mainCol,children:w?e(S,{children:[e("h2",{className:p.sectionTitle,children:["Results for “",w,"”"]}),be?e("p",{className:a.statusMsg,children:"Searching…"}):U.length===0?e("p",{className:a.statusMsg,children:"No tracks found."}):e("div",{className:p.stationList,children:U.map(t=>he(t,U))})]}):L?.authenticated?e(S,{children:[e("h2",{className:p.sectionTitle,children:"Your library"}),ve?e("p",{className:a.statusMsg,children:"Loading library…"}):Le.length===0&&I.length===0&&!F?e(S,{children:[e("p",{className:a.statusMsg,children:Se?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:g.btnGhost,onClick:()=>{ke()},disabled:K,"aria-label":"Retry loading library",children:K?"Retrying…":"Retry"})}),e("p",{className:a.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(S,{children:[Le.length>0&&!F&&e(S,{children:[e("h3",{className:p.sectionTitle,children:"Playlists"}),e("div",{className:p.stationList,children:Le.map(t=>Xe(t))})]}),I.length>0&&!F&&e(S,{children:[e("h3",{className:p.sectionTitle,children:["Liked songs (",I.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:g.btnGhost,onClick:()=>Ce(I[0],I),"aria-label":"Play all liked songs",children:[e(f,{name:"play"})," Play all"]})}),e("div",{className:p.stationList,children:I.map(t=>he(t,I))})]}),F?e(S,{children:[e("button",{className:g.btnGhost,onClick:()=>ae(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:p.sectionTitle,children:F.title}),xe?e("p",{className:a.statusMsg,children:"Loading playlist…"}):X.length===0?e("p",{className:a.statusMsg,children:"No tracks in this playlist."}):e("div",{className:p.stationList,children:X.map(t=>he(t,X))})]}):null]})]}):e("p",{className:a.statusMsg,children:"Search above, or sign in to see your library."})}),h&&e("aside",{className:g.upnextAside,"aria-label":"Up next",children:[e("div",{className:g.upnextHeader,children:e("span",{className:g.upnextTitle,children:[e(f,{name:"list-ul"})," Up Next"]})}),e("div",{className:g.nowPlayingWrap,children:[e("p",{className:g.nowPlayingLabel,children:"Now playing"}),he(h,V.length>0?V:[h])]}),e("div",{className:g.upnextActions,children:e("button",{className:g.btnGhost,onClick:Je,disabled:!T&&(r||M.length===0),"aria-pressed":T,title:T?"Stop the radio — the queue will loop instead of fetching more songs":"Queue these suggestions after the current song and keep the mix going",children:T?"Stop radio":"Start radio"})}),r?e("p",{className:a.statusMsg,children:"Loading suggestions…"}):M.length===0?e("p",{className:a.statusMsg,children:"No suggestions for this song."}):e("div",{className:p.stationList,children:M.map(t=>he(t,Fe,et))})]})]}),h&&e(ct,{track:h,queue:V,shuffle:O,onToggleShuffle:Ke,onTrackStep:Ze,onTrackFailed:We,onClose:()=>{v(null),ee(null)},liked:h?Me(h):!1,likeVisible:L?.authenticated===!0,likePending:P.isPending,onToggleLike:()=>Be(h)})]})};export{Yt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e,S as s,d as y,h as g}from"./vendor-core-DfaOB3Rn.js";import{I as p}from"./vendor-icons-DrybRNxP.js";import{M as l,I as m,T as S,J as f,K as k,L as x,N}from"./AvSyncCalibrator-
|
|
1
|
+
import{u as e,S as s,d as y,h as g}from"./vendor-core-DfaOB3Rn.js";import{I as p}from"./vendor-icons-DrybRNxP.js";import{M as l,I as m,T as S,J as f,K as k,L as x,N}from"./AvSyncCalibrator-CQ2fjf2E.js";const C=({classes:o,title:t,titleTag:i="span",showBack:a=!0,onBack:n,panelRef:b,onPanelClick:r,children:c})=>{const d=i;return e("div",{ref:b,className:o.panel,onClick:r,"data-speed-boost-ignore":"true",children:[e("div",{className:o.header,children:[a&&e("button",{className:o.backBtn,onClick:n,children:e(p,{name:"chevron-left"})}),e(d,{className:o.title||void 0,children:t})]}),e("div",{className:o.content,children:c})]})},$=({classes:o,values:t,onChange:i})=>{const a=()=>{const n=x;i("fontSize",n.fontSize),i("position",n.position),i("bgOpacity",n.bgOpacity),i("bgColor",n.bgColor),i("textColor",n.textColor),i("edge",n.edge),i("bold",n.bold)};return e(s,{children:[e(l,{label:"Font Size",display:t.fontSize.toFixed(1),min:.5,max:10,step:.5,value:t.fontSize,percent:(t.fontSize-.5)/9.5*100,onChange:n=>{Number.isFinite(n)&&i("fontSize",n)}}),e(l,{label:"Vertical Position",display:`${t.position}`,min:0,max:100,step:1,value:t.position,percent:t.position,onChange:n=>{Number.isFinite(n)&&i("position",Math.round(n))}}),e(l,{label:"Background Opacity",display:`${Math.round(t.bgOpacity*100)}%`,min:0,max:1,step:.05,value:t.bgOpacity,percent:t.bgOpacity*100,onChange:n=>{Number.isFinite(n)&&i("bgOpacity",n)}}),e(m,{label:"Text Color",colors:S,value:t.textColor,onChange:n=>i("textColor",n)}),e(m,{label:"Background Color",colors:f,value:t.bgColor,onChange:n=>i("bgColor",n)}),e(k,{label:"Text Edge",options:["shadow","outline","none"],value:t.edge,onChange:n=>i("edge",n)}),e("button",{type:"button",className:`${o.item} ${t.bold?o.active:""}`,onClick:()=>i("bold",!t.bold),children:[e("span",{children:"Bold Text"}),t.bold&&e(p,{name:"check",size:12})]}),e("button",{type:"button",className:o.item,onClick:a,children:e("span",{children:"Reset to Defaults"})})]})},z=({classes:o,enabled:t,delayMs:i,onToggle:a,onDelayChange:n,onCalibrate:b})=>{const[r,c]=y(null),d=r??i;g(()=>{c(null)},[i]);const h=()=>{r!==null&&(n(r),c(null))};return e(s,{children:[e("button",{type:"button",className:`${o.item} ${t?o.active:""}`,onClick:()=>a(!t),children:[e("span",{children:"Video delay"}),t&&e(p,{name:"check",size:12})]}),e(l,{label:"Video delay",display:`${d}ms`,min:0,max:500,step:5,value:d,percent:d/500*100,onChange:u=>c(Math.round(u)),onCommit:h}),e("div",{className:o.note,children:"For Bluetooth headsets where audio arrives late. Video is held back via canvas; audio plays untouched."}),b&&e("button",{type:"button",className:o.item,onClick:b,children:e("span",{children:"Calibrate…"})})]})},E=({classes:o,values:t,onChange:i})=>e(s,{children:[e("button",{type:"button",className:`${o.item} ${t.enabled?o.active:""}`,onClick:()=>i({enabled:!t.enabled}),"aria-pressed":t.enabled,children:[e("span",{children:"Ambient light"}),e("span",{style:{display:"flex",alignItems:"center",gap:6},children:[t.enabled?"On":"Off",t.enabled&&e(p,{name:"check",size:12})]})]}),e(l,{label:"Blur",display:`${t.blur}px`,min:0,max:120,step:2,value:t.blur,percent:t.blur/120*100,onChange:a=>i({blur:Math.round(a)})}),e(l,{label:"Saturation",display:`${t.saturation}%`,min:0,max:200,step:5,value:t.saturation,percent:t.saturation/200*100,onChange:a=>i({saturation:Math.round(a)})}),e(l,{label:"Brightness",display:`${t.brightness}%`,min:20,max:120,step:5,value:t.brightness,percent:(t.brightness-20)/100*100,onChange:a=>i({brightness:Math.round(a)})}),e(l,{label:"Opacity",display:`${t.opacity}%`,min:10,max:100,step:5,value:t.opacity,percent:(t.opacity-10)/90*100,onChange:a=>i({opacity:Math.round(a)})}),e("div",{className:o.note,children:"Mirrors the video onto the backdrop behind the player. Turn off for pure black."}),e("button",{type:"button",className:o.item,onClick:()=>i({...N}),children:e("span",{children:"Reset to defaults"})})]}),B=({classes:o,options:t,onSelect:i})=>e(s,{children:t.map(a=>e("button",{type:"button",className:`${o.item} ${a.selected?o.active:""}`,onClick:()=>i(a.key),children:[e("span",{children:a.label}),a.selected&&e(p,{name:"check",size:12})]},a.key))});export{z as A,B as O,C as S,$ as a,E as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-
|
|
2
|
-
import{u as r,g as Ut,h as D,P as $r,z as Fr,d as ue,A as m,q as K,y as Or,T as Je,o as Wr,a as Ur,c as Vr,_ as qr,S as Wt}from"./vendor-core-DfaOB3Rn.js";import{_ as fr,S as _t,h as Qr,t as Ee,z as Oe,J as zr,K as yt,M as Be,e as Gr,l as Kr,m as Hr,n as jr,o as Yr,d as Xr,u as Jr,B as it,L as Zr,f as en}from"./index-BTnhzofk.js";import{u as vr,b as cr,a as Yt}from"./vendor-query-BBT5_sHx.js";import{S as tn,U as rn,p as Xt,s as nn,C as sn,a as on,b as an,c as at,l as ln,u as cn,d as un,e as dn,f as hn,i as pn,g as ur,h as mn,j as fn,k as dr,m as hr,n as vn,o as gn,q as bn,r as yn,t as xe,A as Sn,R as En,E as wn,v as kn,w as h,x as Tn,y as Cn,P as Rn,z as Mn,B as _n}from"./AvSyncCalibrator-DmoH5eRA.js";import{I as Z}from"./vendor-icons-DrybRNxP.js";import{l as Nn}from"./hls-Bi1cjpLZ.js";import{u as Pn}from"./useIsMobile-Dvx1uJ82.js";import{s as ze,Q as An}from"./QueueRail-BAwI-apz.js";import{u as xn,Q as Bn}from"./QueueOptionsButton-T1J37IZT.js";import{u as gr}from"./useProviders-UuUPzft-.js";import{A as Ln}from"./AnimeMetaDetails-BogOi_bM.js";import{S as In}from"./SynopsisText-B3Sa5pRv.js";import"./vendor-ui-3qrARCPr.js";const Dn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},$n={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Fn=["direct","cookie","embed"],On="_controlsOverlay_1h2da_1",Wn="_hidden_1h2da_21",Un="_topControls_1h2da_27",Vn="_backBtn_1h2da_47",qn="_videoTitleInfo_1h2da_67",Qn="_animeTitle_1h2da_73",zn="_episodeNumber_1h2da_83",Gn="_bottomControls_1h2da_91",Kn="_progressBarContainer_1h2da_110",Hn="_progressBar_1h2da_110",jn="_thumb_1h2da_129",Yn="_scrubbing_1h2da_144",Xn="_watchedBar_1h2da_148",Jn="_bufferedBar_1h2da_149",Zn="_timeBubble_1h2da_187",es="_skipSegment_1h2da_221",ts="_op_1h2da_231",rs="_ed_1h2da_234",ns="_recap_1h2da_237",ss="_bottomControlsRow_1h2da_241",os="_leftControls_1h2da_249",is="_rightControls_1h2da_250",as="_controlBtn_1h2da_257",ls="_theaterBtn_1h2da_298",cs="_nextEpisodeBtn_1h2da_302",us="_active_1h2da_323",ds="_timeDisplay_1h2da_327",hs="_skipControls_1h2da_335",ps="_skipBtn_1h2da_341",ms="_volumeContainer_1h2da_382",fs="_volumeSlider_1h2da_388",vs="_playerPageLayout_1h2da_446",gs="_videoPlayerWrapper_1h2da_450",bs="_playerInfoContainer_1h2da_455",ys="_visible_1h2da_572",Ss="_shortcuts_1h2da_590",C={controlsOverlay:On,hidden:Wn,topControls:Un,backBtn:Vn,videoTitleInfo:qn,animeTitle:Qn,episodeNumber:zn,bottomControls:Gn,progressBarContainer:Kn,progressBar:Hn,thumb:jn,scrubbing:Yn,watchedBar:Xn,bufferedBar:Jn,timeBubble:Zn,skipSegment:es,op:ts,ed:rs,recap:ns,bottomControlsRow:ss,leftControls:os,rightControls:is,controlBtn:as,theaterBtn:ls,nextEpisodeBtn:cs,active:us,timeDisplay:ds,skipControls:hs,skipBtn:ps,volumeContainer:ms,volumeSlider:fs,playerPageLayout:vs,videoPlayerWrapper:gs,playerInfoContainer:bs,visible:ys,shortcuts:Ss},Es=({player:n,handlers:i,visible:p,skipIntervals:B,showNextEpisodeButton:f,onNextEpisode:E,isTheaterMode:v,onTheaterModeToggle:L,settingsBtnRef:P,timeDisplayRef:F})=>{const{state:w,refs:e,actions:o}=n,{showSettings:J}=w,g=()=>w.isMuted||w.volume===0?r(Z,{name:"volume-mute"}):w.volume<.5?r(Z,{name:"volume-down"}):r(Z,{name:"volume-up"});return r("div",{className:`${C.controlsOverlay} ${p?"":C.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:C.bottomControls,"data-speed-boost-ignore":"true",onClick:A=>A.stopPropagation(),children:[r(tn,{classes:{container:C.progressBarContainer,scrubbing:C.scrubbing,timeBubble:C.timeBubble,bar:C.progressBar,buffered:C.bufferedBar,watched:C.watchedBar,thumb:C.thumb},videoRef:e.videoRef,duration:w.duration,formatTime:o.formatTime,isScrubbing:w.isScrubbing,onSeek:i.handleSeek,onScrubStart:i.handleScrubStart,onScrubMove:i.handleScrubMove,onScrubEnd:i.handleScrubEnd,timeLabelRef:F,children:[w.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${C.skipSegment} ${C[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/w.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/w.duration*100}% `}}),B.map(A=>{const de=A.start_time/w.duration*100,V=(A.end_time-A.start_time)/w.duration*100;return r("div",{className:`${C.skipSegment} ${C[A.skip_type]} `,style:{left:`${de}% `,width:`${V}% `},title:A.skip_type.toUpperCase()},A.skip_id)})]}),r("div",{className:C.bottomControlsRow,children:[r("div",{className:C.leftControls,children:[r("button",{className:C.controlBtn,onClick:o.togglePlay,"aria-label":w.isPlaying?"Pause":"Play",children:w.isPlaying?r(Z,{name:"pause"}):r(Z,{name:"play"})}),r(rn,{muted:w.isMuted,volume:w.volume,volumeIcon:g(),buttonClassName:C.controlBtn,onToggleMute:o.toggleMute,onVolumeChange:i.handleVolumeChange,onExpandedChange:A=>o.setShowVolumeSlider(A)}),r("span",{className:C.timeDisplay,ref:F,children:[o.formatTime(0)," / ",o.formatTime(w.duration)]}),w.currentSkipInterval&&!w.isAutoSkipEnabled&&r("button",{className:C.controlBtn,onClick:()=>{e.videoRef.current&&w.currentSkipInterval&&(e.videoRef.current.currentTime=w.currentSkipInterval.end_time,o.setCurrentSkipInterval(null))},children:["Skip ",w.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:C.rightControls,children:[r("div",{className:C.skipControls,children:f&&r("button",{className:C.nextEpisodeBtn,onClick:E,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${C.controlBtn} ${i.isSubtitleActive?C.active:""}`,onClick:i.handleCCToggle,title:i.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(Z,{name:"closed-captioning",size:22})}),r("button",{ref:P,className:`${C.controlBtn} ${J?C.active:""} `,onClick:()=>o.setShowSettings(!J),"aria-label":"Settings",children:r(Z,{name:"cog"})}),r("button",{className:`${C.controlBtn} ${C.theaterBtn} ${v?C.active:""} `,onClick:A=>{A.stopPropagation(),L()},title:v?"Exit Theater Mode":"Theater Mode","aria-label":v?"Exit Theater Mode":"Theater Mode",children:r(Z,{name:"tv"})}),r("button",{className:C.controlBtn,onClick:o.toggleFullscreen,"aria-label":w.isFullscreen?"Exit Fullscreen":"Fullscreen",children:w.isFullscreen?r(Z,{name:"compress"}):r(Z,{name:"expand"})})]})]})]})})};function ws(n){const{state:i,refs:p,actions:B}=n,f=o=>{p.videoRef.current&&(p.videoRef.current.volume=o,p.videoRef.current.muted=o===0)},E=o=>{!p.videoRef.current||isNaN(i.duration)||i.duration===0||(p.videoRef.current.currentTime=o*i.duration,B.sendProgressUpdate(!1,!0))},v=()=>{p.videoRef.current&&(B.setIsScrubbing(!0),B.wasPlayingBeforeScrub.current=!p.videoRef.current.paused,p.videoRef.current.pause())},L=o=>{!p.videoRef.current||!i.duration||(p.videoRef.current.currentTime=o*i.duration)},P=()=>{B.setIsScrubbing(!1),B.wasPlayingBeforeScrub.current&&p.videoRef.current?.play()},F=o=>{if(!p.videoRef.current)return;B.setActiveSubtitleTrack(o);try{if(o===null||o==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const g=i.availableSubtitles.find(A=>A.label===o||A.lang===o);g?localStorage.setItem("playerLastSubtitle",nn(g)):localStorage.setItem("playerLastSubtitle",o)}}catch{}let J=!1;Array.from(p.videoRef.current.textTracks).forEach(g=>{const de=o!==null&&o!=="off"&&(g.language===o||g.label===o)&&!J;g.mode=de?"showing":"hidden",de&&(J=!0)})},w=i.activeSubtitleTrack!==null&&i.activeSubtitleTrack!=="off";return{handleVolumeChange:f,handleSeek:E,handleScrubStart:v,handleScrubMove:L,handleScrubEnd:P,handleSubtitleSelection:F,isSubtitleActive:w,handleCCToggle:()=>{if(!p.videoRef.current)return;if(w){F("off");return}if(i.availableSubtitles.length===0)return;let o=null;try{o=localStorage.getItem("playerLastSubtitle")}catch{}const J=Xt(i.availableSubtitles,{lastKey:o,enabled:!0});if(J<0)return;const g=i.availableSubtitles[J];F(g.label||g.lang)}}}const ks=Fr(()=>fr(()=>import("./PlayerSettings-BycNCiCs.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Ts=({player:n,isAutoplayEnabled:i,onAutoplayChange:p,showNextEpisodeButton:B,onNextEpisode:f,videoSources:E,selectedSource:v,selectedLink:L,onSourceChange:P,loadingVideo:F,skipIntervals:w,animeTitle:e,episodeNumber:o,isTheaterMode:J,onTheaterModeToggle:g,anime4kEnabled:A,onAnime4kToggle:de,anime4kSupported:V,anime4kProfile:x,onAnime4kProfileChange:O,anime4kInitializing:Le,anime4kError:We,videoDelayEnabled:a,onVideoDelayToggle:d,videoDelayMs:k,onVideoDelayChange:ve,onCalibrateAvSync:Ie,fallbackChoice:_e,onFallbackChoiceChange:Ne,ambientSettings:Ue,onAmbientChange:oe,children:we,overlays:c,isInteractingExtra:b=!1,className:T,hideChrome:I=!1})=>{const{state:R,actions:q}=n,{showSettings:ye}=R,{setShowSettings:Y}=q,G=ws(n),ke=Ut.useRef(null),De=Ut.useRef(null),St=Ut.useRef(null);D(()=>{const $=W=>{ke.current&&!ke.current.contains(W.target)&&De.current&&!De.current.contains(W.target)&&ye&&Y(!1)};return ye&&document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[ye,Y]);const Ze=R.showControls||ye||R.isScrubbing,Et=r(an,{visible:Ze,title:e,episode:o?`Episode ${o}`:void 0,onBack:()=>window.history.back(),classes:{overlay:C.controlsOverlay,hidden:C.hidden,top:C.topControls,backBtn:C.backBtn,titleInfo:C.videoTitleInfo,title:C.animeTitle,episode:C.episodeNumber}}),H=!F&&!R.isBuffering&&R.duration>0?r(sn,{isPlaying:R.isPlaying,onTogglePlay:q.togglePlay,onSkipBack:()=>q.seek(-10),onSkipForward:()=>q.seek(10)}):null,Pe=r(Es,{player:n,handlers:G,visible:Ze,skipIntervals:w,showNextEpisodeButton:B,onNextEpisode:f,isTheaterMode:J,onTheaterModeToggle:g,settingsBtnRef:De,timeDisplayRef:St}),lt=r($r,{fallback:null,children:r(ks,{ref:ke,isOpen:ye,onClose:()=>Y(!1),videoSources:E,currentSource:v,currentLink:L,onSourceChange:P,subtitles:R.availableSubtitles,activeSubtitleTrack:R.activeSubtitleTrack,onSubtitleChange:G.handleSubtitleSelection,subtitleSettings:{fontSize:R.subtitleFontSize,position:R.subtitlePosition,bgOpacity:R.subtitleBgOpacity,bgColor:R.subtitleBgColor,textColor:R.subtitleTextColor,edge:R.subtitleEdge,bold:R.subtitleBold},onSubtitleSettingsChange:($,W)=>{const Te=(Ve,Ge)=>{try{localStorage.setItem(Ve,String(Ge))}catch{}};switch($){case"fontSize":q.setSubtitleFontSize(W),Te("subtitleFontSize",W);break;case"position":q.setSubtitlePosition(W),Te("subtitlePosition",W);break;case"bgOpacity":q.setSubtitleBgOpacity(W),Te("subtitleBgOpacity",W);break;case"bgColor":q.setSubtitleBgColor(W),Te("subtitleBgColor",W);break;case"textColor":q.setSubtitleTextColor(W),Te("subtitleTextColor",W);break;case"edge":q.setSubtitleEdge(W),Te("subtitleEdge",W);break;case"bold":q.setSubtitleBold(W),Te("subtitleBold",W);break}},useNativeControls:R.useNativeControls,onNativeControlsToggle:q.setUseNativeControls,anime4kEnabled:A,onAnime4kToggle:de,anime4kSupported:V,anime4kProfile:x,onAnime4kProfileChange:O,anime4kInitializing:Le,anime4kError:We,videoDelayEnabled:a,onVideoDelayToggle:d,videoDelayMs:k,onVideoDelayChange:ve,onCalibrateAvSync:Ie,isAutoSkipEnabled:R.isAutoSkipEnabled,onAutoSkipChange:$=>{q.setIsAutoSkipEnabled($);try{localStorage.setItem("autoSkipEnabled",$.toString())}catch{}},isAutoplayEnabled:i,onAutoplayChange:p,fallbackChoice:_e,onFallbackChoiceChange:Ne,isTheaterMode:J,ambientSettings:Ue,onAmbientChange:oe})}),_=ye?r("div",{"data-speed-boost-ignore":"true",onClick:$=>$.stopPropagation(),children:lt}):null;return r(on,{player:n,topBar:Et,centerControls:H,bottomBar:!F&&R.duration>0?Pe:null,settingsPanel:_,overlays:c,isInteracting:b,className:T,chromeDisabled:I,children:we})},Cs=({count:n=3})=>r("section",{className:ze.section,children:[r("div",{className:ze.header,children:r("button",{className:ze.headerToggle,disabled:!0,children:[r("span",{className:ze.title,children:r(_t,{width:"60px",height:"1.2rem",variant:"text"})}),r(Z,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:ze.list,children:Array.from({length:n}).map((i,p)=>r("div",{className:ze.item,style:{pointerEvents:"none"},children:[r("div",{className:ze.dragHandle,style:{opacity:.2},children:r(_t,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:ze.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(_t,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:ze.meta,children:[r(_t,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(_t,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},p))})]}),Rs=({selectedProvider:n,onProviderChange:i,isAdult:p,options:B})=>{const E=(B&&B.length>0?B:[]).filter(v=>v.mature===(p===!0));return r("div",{className:at.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:at.providerSelect,value:n,onChange:v=>i(v.target.value),children:Fn.map(v=>{const L=E.filter(P=>(P.tier??"direct")===v);return L.length===0?null:r("optgroup",{label:$n[v],children:L.map(P=>r("option",{value:P.value,children:P.sub?`${P.label} (${Dn[P.sub]})`:P.label},P.value))},v)})})]})},Ms=({videoSources:n,selectedSource:i,selectedLink:p,onSourceChange:B,onLinkChange:f})=>{const E=Array.isArray(n)?n:[];if(E.length===0)return null;const v=i?.type==="iframe"&&(i.links?.length??0)>1;return r("div",{className:at.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:at.sourceButtons,children:E.map((L,P)=>r("button",{className:`${at.sourceButton} ${i?.sourceName===L.sourceName?at.active:""} `,onClick:()=>B(L),children:L.sourceName},`${L.sourceName}-${P}`))}),v&&r("select",{className:at.sourceSelect,"aria-label":"Fallback embed quality",value:p?.link??i.links[0]?.link??"",onChange:L=>{const P=i.links.find(F=>F.link===L.target.value);P&&f(P)},children:i.links.map(L=>r("option",{value:L.link,children:L.resolutionStr},L.link))})]})},_s=Ut.memo(Ms,(n,i)=>n.selectedSource?.sourceName===i.selectedSource?.sourceName&&n.selectedLink?.link===i.selectedLink?.link&&n.videoSources===i.videoSources),Ns={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}},Ps={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},As=5,xs=15e3,Bs=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-DGxBsi3F.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-icons-DrybRNxP.js","assets/OptionListMenu-B3D39dGS.js","assets/AvSyncCalibrator-CQ2fjf2E.js","assets/index-CnfZwsds.js","assets/vendor-query-BBT5_sHx.js","assets/index-D0Haw_Zl.css","assets/AvSyncCalibrator-ZSpMgUid.css","assets/PlayerSettings-BXGe3F5k.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as r,g as Wt,h as D,P as $r,z as Fr,d as ue,A as m,q as K,y as Or,T as Je,o as Wr,a as Ur,c as Vr,_ as qr,S as Ot}from"./vendor-core-DfaOB3Rn.js";import{_ as mr,S as Mt,h as Qr,t as Ee,z as Oe,J as zr,K as bt,M as Be,e as Gr,l as Kr,m as Hr,n as jr,o as Yr,d as Xr,u as Jr,B as it,L as Zr,f as en}from"./index-CnfZwsds.js";import{u as fr,b as lr,a as jt}from"./vendor-query-BBT5_sHx.js";import{S as tn,U as rn,p as Yt,s as nn,C as sn,a as on,b as an,c as at,l as ln,u as cn,d as un,e as dn,f as pn,i as hn,g as cr,h as mn,j as fn,k as ur,m as dr,n as vn,o as gn,q as bn,r as yn,t as xe,A as Sn,R as En,E as wn,v as kn,w as p,x as Tn,y as Cn,P as Rn,z as Mn,B as _n}from"./AvSyncCalibrator-CQ2fjf2E.js";import{I as Z}from"./vendor-icons-DrybRNxP.js";import{l as Nn}from"./hls-BGCX7mJy.js";import{u as Pn}from"./useIsMobile-Dvx1uJ82.js";import{s as ze,Q as An}from"./QueueRail-DOrYgNVX.js";import{u as xn,Q as Bn}from"./QueueOptionsButton-Djq4Cpex.js";import{u as vr}from"./useProviders-mpQb_dix.js";import{A as Ln}from"./AnimeMetaDetails-BogOi_bM.js";import{S as In}from"./SynopsisText-B3Sa5pRv.js";import"./vendor-ui-3qrARCPr.js";const Dn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},$n={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Fn=["direct","cookie","embed"],On="_controlsOverlay_1h2da_1",Wn="_hidden_1h2da_21",Un="_topControls_1h2da_27",Vn="_backBtn_1h2da_47",qn="_videoTitleInfo_1h2da_67",Qn="_animeTitle_1h2da_73",zn="_episodeNumber_1h2da_83",Gn="_bottomControls_1h2da_91",Kn="_progressBarContainer_1h2da_110",Hn="_progressBar_1h2da_110",jn="_thumb_1h2da_129",Yn="_scrubbing_1h2da_144",Xn="_watchedBar_1h2da_148",Jn="_bufferedBar_1h2da_149",Zn="_timeBubble_1h2da_187",es="_skipSegment_1h2da_221",ts="_op_1h2da_231",rs="_ed_1h2da_234",ns="_recap_1h2da_237",ss="_bottomControlsRow_1h2da_241",os="_leftControls_1h2da_249",is="_rightControls_1h2da_250",as="_controlBtn_1h2da_257",ls="_theaterBtn_1h2da_298",cs="_nextEpisodeBtn_1h2da_302",us="_active_1h2da_323",ds="_timeDisplay_1h2da_327",ps="_skipControls_1h2da_335",hs="_skipBtn_1h2da_341",ms="_volumeContainer_1h2da_382",fs="_volumeSlider_1h2da_388",vs="_playerPageLayout_1h2da_446",gs="_videoPlayerWrapper_1h2da_450",bs="_playerInfoContainer_1h2da_455",ys="_visible_1h2da_572",Ss="_shortcuts_1h2da_590",C={controlsOverlay:On,hidden:Wn,topControls:Un,backBtn:Vn,videoTitleInfo:qn,animeTitle:Qn,episodeNumber:zn,bottomControls:Gn,progressBarContainer:Kn,progressBar:Hn,thumb:jn,scrubbing:Yn,watchedBar:Xn,bufferedBar:Jn,timeBubble:Zn,skipSegment:es,op:ts,ed:rs,recap:ns,bottomControlsRow:ss,leftControls:os,rightControls:is,controlBtn:as,theaterBtn:ls,nextEpisodeBtn:cs,active:us,timeDisplay:ds,skipControls:ps,skipBtn:hs,volumeContainer:ms,volumeSlider:fs,playerPageLayout:vs,videoPlayerWrapper:gs,playerInfoContainer:bs,visible:ys,shortcuts:Ss},Es=({player:n,handlers:i,visible:h,skipIntervals:B,showNextEpisodeButton:f,onNextEpisode:S,isTheaterMode:v,onTheaterModeToggle:L,settingsBtnRef:P,timeDisplayRef:F})=>{const{state:E,refs:e,actions:o}=n,{showSettings:J}=E,g=()=>E.isMuted||E.volume===0?r(Z,{name:"volume-mute"}):E.volume<.5?r(Z,{name:"volume-down"}):r(Z,{name:"volume-up"});return r("div",{className:`${C.controlsOverlay} ${h?"":C.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:C.bottomControls,"data-speed-boost-ignore":"true",onClick:A=>A.stopPropagation(),children:[r(tn,{classes:{container:C.progressBarContainer,scrubbing:C.scrubbing,timeBubble:C.timeBubble,bar:C.progressBar,buffered:C.bufferedBar,watched:C.watchedBar,thumb:C.thumb},videoRef:e.videoRef,duration:E.duration,formatTime:o.formatTime,isScrubbing:E.isScrubbing,onSeek:i.handleSeek,onScrubStart:i.handleScrubStart,onScrubMove:i.handleScrubMove,onScrubEnd:i.handleScrubEnd,timeLabelRef:F,children:[E.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${C.skipSegment} ${C[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/E.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/E.duration*100}% `}}),B.map(A=>{const de=A.start_time/E.duration*100,V=(A.end_time-A.start_time)/E.duration*100;return r("div",{className:`${C.skipSegment} ${C[A.skip_type]} `,style:{left:`${de}% `,width:`${V}% `},title:A.skip_type.toUpperCase()},A.skip_id)})]}),r("div",{className:C.bottomControlsRow,children:[r("div",{className:C.leftControls,children:[r("button",{className:C.controlBtn,onClick:o.togglePlay,"aria-label":E.isPlaying?"Pause":"Play",children:E.isPlaying?r(Z,{name:"pause"}):r(Z,{name:"play"})}),r(rn,{muted:E.isMuted,volume:E.volume,volumeIcon:g(),buttonClassName:C.controlBtn,onToggleMute:o.toggleMute,onVolumeChange:i.handleVolumeChange,onExpandedChange:A=>o.setShowVolumeSlider(A)}),r("span",{className:C.timeDisplay,ref:F,children:[o.formatTime(0)," / ",o.formatTime(E.duration)]}),E.currentSkipInterval&&!E.isAutoSkipEnabled&&r("button",{className:C.controlBtn,onClick:()=>{e.videoRef.current&&E.currentSkipInterval&&(e.videoRef.current.currentTime=E.currentSkipInterval.end_time,o.setCurrentSkipInterval(null))},children:["Skip ",E.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:C.rightControls,children:[r("div",{className:C.skipControls,children:f&&r("button",{className:C.nextEpisodeBtn,onClick:S,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${C.controlBtn} ${i.isSubtitleActive?C.active:""}`,onClick:i.handleCCToggle,title:i.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(Z,{name:"closed-captioning",size:22})}),r("button",{ref:P,className:`${C.controlBtn} ${J?C.active:""} `,onClick:()=>o.setShowSettings(!J),"aria-label":"Settings",children:r(Z,{name:"cog"})}),r("button",{className:`${C.controlBtn} ${C.theaterBtn} ${v?C.active:""} `,onClick:A=>{A.stopPropagation(),L()},title:v?"Exit Theater Mode":"Theater Mode","aria-label":v?"Exit Theater Mode":"Theater Mode",children:r(Z,{name:"tv"})}),r("button",{className:C.controlBtn,onClick:o.toggleFullscreen,"aria-label":E.isFullscreen?"Exit Fullscreen":"Fullscreen",children:E.isFullscreen?r(Z,{name:"compress"}):r(Z,{name:"expand"})})]})]})]})})};function ws(n){const{state:i,refs:h,actions:B}=n,f=o=>{h.videoRef.current&&(h.videoRef.current.volume=o,h.videoRef.current.muted=o===0)},S=o=>{!h.videoRef.current||isNaN(i.duration)||i.duration===0||(h.videoRef.current.currentTime=o*i.duration,B.sendProgressUpdate(!1,!0))},v=()=>{h.videoRef.current&&(B.setIsScrubbing(!0),B.wasPlayingBeforeScrub.current=!h.videoRef.current.paused,h.videoRef.current.pause())},L=o=>{!h.videoRef.current||!i.duration||(h.videoRef.current.currentTime=o*i.duration)},P=()=>{B.setIsScrubbing(!1),B.wasPlayingBeforeScrub.current&&h.videoRef.current?.play()},F=o=>{if(!h.videoRef.current)return;B.setActiveSubtitleTrack(o);try{if(o===null||o==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const g=i.availableSubtitles.find(A=>A.label===o||A.lang===o);g?localStorage.setItem("playerLastSubtitle",nn(g)):localStorage.setItem("playerLastSubtitle",o)}}catch{}let J=!1;Array.from(h.videoRef.current.textTracks).forEach(g=>{const de=o!==null&&o!=="off"&&(g.language===o||g.label===o)&&!J;g.mode=de?"showing":"hidden",de&&(J=!0)})},E=i.activeSubtitleTrack!==null&&i.activeSubtitleTrack!=="off";return{handleVolumeChange:f,handleSeek:S,handleScrubStart:v,handleScrubMove:L,handleScrubEnd:P,handleSubtitleSelection:F,isSubtitleActive:E,handleCCToggle:()=>{if(!h.videoRef.current)return;if(E){F("off");return}if(i.availableSubtitles.length===0)return;let o=null;try{o=localStorage.getItem("playerLastSubtitle")}catch{}const J=Yt(i.availableSubtitles,{lastKey:o,enabled:!0});if(J<0)return;const g=i.availableSubtitles[J];F(g.label||g.lang)}}}const ks=Fr(()=>mr(()=>import("./PlayerSettings-DGxBsi3F.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Ts=({player:n,isAutoplayEnabled:i,onAutoplayChange:h,showNextEpisodeButton:B,onNextEpisode:f,videoSources:S,selectedSource:v,selectedLink:L,onSourceChange:P,loadingVideo:F,skipIntervals:E,animeTitle:e,episodeNumber:o,isTheaterMode:J,onTheaterModeToggle:g,anime4kEnabled:A,onAnime4kToggle:de,anime4kSupported:V,anime4kProfile:x,onAnime4kProfileChange:O,anime4kInitializing:Le,anime4kError:We,videoDelayEnabled:a,onVideoDelayToggle:d,videoDelayMs:k,onVideoDelayChange:ve,onCalibrateAvSync:Ie,fallbackChoice:_e,onFallbackChoiceChange:Ne,ambientSettings:Ue,onAmbientChange:ie,children:we,overlays:c,isInteractingExtra:b=!1,className:T,hideChrome:I=!1})=>{const{state:R,actions:q}=n,{showSettings:ye}=R,{setShowSettings:Y}=q,G=ws(n),ke=Wt.useRef(null),De=Wt.useRef(null),yt=Wt.useRef(null);D(()=>{const $=W=>{ke.current&&!ke.current.contains(W.target)&&De.current&&!De.current.contains(W.target)&&ye&&Y(!1)};return ye&&document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[ye,Y]);const Ze=R.showControls||ye||R.isScrubbing,St=r(an,{visible:Ze,title:e,episode:o?`Episode ${o}`:void 0,onBack:()=>window.history.back(),classes:{overlay:C.controlsOverlay,hidden:C.hidden,top:C.topControls,backBtn:C.backBtn,titleInfo:C.videoTitleInfo,title:C.animeTitle,episode:C.episodeNumber}}),H=!F&&!R.isBuffering&&R.duration>0?r(sn,{isPlaying:R.isPlaying,onTogglePlay:q.togglePlay,onSkipBack:()=>q.seek(-10),onSkipForward:()=>q.seek(10)}):null,Pe=r(Es,{player:n,handlers:G,visible:Ze,skipIntervals:E,showNextEpisodeButton:B,onNextEpisode:f,isTheaterMode:J,onTheaterModeToggle:g,settingsBtnRef:De,timeDisplayRef:yt}),lt=r($r,{fallback:null,children:r(ks,{ref:ke,isOpen:ye,onClose:()=>Y(!1),videoSources:S,currentSource:v,currentLink:L,onSourceChange:P,subtitles:R.availableSubtitles,activeSubtitleTrack:R.activeSubtitleTrack,onSubtitleChange:G.handleSubtitleSelection,subtitleSettings:{fontSize:R.subtitleFontSize,position:R.subtitlePosition,bgOpacity:R.subtitleBgOpacity,bgColor:R.subtitleBgColor,textColor:R.subtitleTextColor,edge:R.subtitleEdge,bold:R.subtitleBold},onSubtitleSettingsChange:($,W)=>{const Te=(Ve,Ge)=>{try{localStorage.setItem(Ve,String(Ge))}catch{}};switch($){case"fontSize":q.setSubtitleFontSize(W),Te("subtitleFontSize",W);break;case"position":q.setSubtitlePosition(W),Te("subtitlePosition",W);break;case"bgOpacity":q.setSubtitleBgOpacity(W),Te("subtitleBgOpacity",W);break;case"bgColor":q.setSubtitleBgColor(W),Te("subtitleBgColor",W);break;case"textColor":q.setSubtitleTextColor(W),Te("subtitleTextColor",W);break;case"edge":q.setSubtitleEdge(W),Te("subtitleEdge",W);break;case"bold":q.setSubtitleBold(W),Te("subtitleBold",W);break}},useNativeControls:R.useNativeControls,onNativeControlsToggle:q.setUseNativeControls,anime4kEnabled:A,onAnime4kToggle:de,anime4kSupported:V,anime4kProfile:x,onAnime4kProfileChange:O,anime4kInitializing:Le,anime4kError:We,videoDelayEnabled:a,onVideoDelayToggle:d,videoDelayMs:k,onVideoDelayChange:ve,onCalibrateAvSync:Ie,isAutoSkipEnabled:R.isAutoSkipEnabled,onAutoSkipChange:$=>{q.setIsAutoSkipEnabled($);try{localStorage.setItem("autoSkipEnabled",$.toString())}catch{}},isAutoplayEnabled:i,onAutoplayChange:h,fallbackChoice:_e,onFallbackChoiceChange:Ne,isTheaterMode:J,ambientSettings:Ue,onAmbientChange:ie})}),_=ye?r("div",{"data-speed-boost-ignore":"true",onClick:$=>$.stopPropagation(),children:lt}):null;return r(on,{player:n,topBar:St,centerControls:H,bottomBar:!F&&R.duration>0?Pe:null,settingsPanel:_,overlays:c,isInteracting:b,className:T,chromeDisabled:I,children:we})},Cs=({count:n=3})=>r("section",{className:ze.section,children:[r("div",{className:ze.header,children:r("button",{className:ze.headerToggle,disabled:!0,children:[r("span",{className:ze.title,children:r(Mt,{width:"60px",height:"1.2rem",variant:"text"})}),r(Z,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:ze.list,children:Array.from({length:n}).map((i,h)=>r("div",{className:ze.item,style:{pointerEvents:"none"},children:[r("div",{className:ze.dragHandle,style:{opacity:.2},children:r(Mt,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:ze.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(Mt,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:ze.meta,children:[r(Mt,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(Mt,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},h))})]}),Rs=({selectedProvider:n,onProviderChange:i,isAdult:h,options:B})=>{const S=(B&&B.length>0?B:[]).filter(v=>v.mature===(h===!0));return r("div",{className:at.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:at.providerSelect,value:n,onChange:v=>i(v.target.value),children:Fn.map(v=>{const L=S.filter(P=>(P.tier??"direct")===v);return L.length===0?null:r("optgroup",{label:$n[v],children:L.map(P=>r("option",{value:P.value,children:P.sub?`${P.label} (${Dn[P.sub]})`:P.label},P.value))},v)})})]})},Ms=({videoSources:n,selectedSource:i,selectedLink:h,onSourceChange:B,onLinkChange:f})=>{const S=Array.isArray(n)?n:[];if(S.length===0)return null;const v=i?.type==="iframe"&&(i.links?.length??0)>1;return r("div",{className:at.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:at.sourceButtons,children:S.map((L,P)=>r("button",{className:`${at.sourceButton} ${i?.sourceName===L.sourceName?at.active:""} `,onClick:()=>B(L),children:L.sourceName},`${L.sourceName}-${P}`))}),v&&r("select",{className:at.sourceSelect,"aria-label":"Fallback embed quality",value:h?.link??i.links[0]?.link??"",onChange:L=>{const P=i.links.find(F=>F.link===L.target.value);P&&f(P)},children:i.links.map(L=>r("option",{value:L.link,children:L.resolutionStr},L.link))})]})},_s=Wt.memo(Ms,(n,i)=>n.selectedSource?.sourceName===i.selectedSource?.sourceName&&n.selectedLink?.link===i.selectedLink?.link&&n.videoSources===i.videoSources),Ns={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}},Ps={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},As=5,xs=15e3,Bs=`
|
|
3
3
|
@group(0) @binding(0) var extTex: texture_external;
|
|
4
4
|
@group(0) @binding(1) var extSamp: sampler;
|
|
5
5
|
struct VSOut {
|
|
@@ -25,7 +25,7 @@ import{u as r,g as Ut,h as D,P as $r,z as Fr,d as ue,A as m,q as K,y as Or,T as
|
|
|
25
25
|
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
26
26
|
return textureSampleBaseClampToEdge(extTex, extSamp, uv);
|
|
27
27
|
}
|
|
28
|
-
`;function Ls({videoRef:n,canvasRef:i,profile:
|
|
28
|
+
`;function Ls({videoRef:n,canvasRef:i,profile:h="balanced",delayMs:B=0}){const[f,S]=ue(!1),[v,L]=ue(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[P,F]=ue(!1),[E,e]=ue(null),[o,J]=ue(0),g=m(0),A=m(null),de=m(null),V=m(null),x=m(null),O=m(null),Le=m(null),We=m(null),a=m(null),d=m(null),k=m(!1),ve=m(-1),Ie=m(0),_e=m(B);_e.current=B;const Ne=m([]),Ue=m(!1),ie=m(!1),we=m(!1),c=m(null),b=m(-1),T=m(-1),I=m(!1),R=m(0);D(()=>{async function Y(){if(typeof navigator>"u"||!navigator.gpu){S(!1);return}try{const G=await navigator.gpu.requestAdapter();S(!!G)}catch{S(!1)}}Y()},[]),D(()=>{if(!v||!f)return;let Y=!1;const G=++g.current,ke=H=>{if(H)try{H.close()}catch{}},De=()=>{for(const H of Ne.current)ke(H.bitmap);Ne.current=[]},yt=H=>Math.max(8,Math.min(40,Math.ceil(H/16.7)+4));function Ze(){d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)}async function St(){let H=n.current;const Pe=i.current;if(!H||!Pe||g.current!==G)return;const lt=performance.now()+xs;for(;(!H||H.videoWidth===0)&&performance.now()<lt;){if(await new Promise(le=>requestAnimationFrame(le)),Y||g.current!==G)return;H=n.current}if(!H||H.videoWidth===0){!Y&&g.current===G&&(e("Timed out waiting for video metadata"),F(!1),L(!1));return}const _=H.videoWidth,$=H.videoHeight,W=Math.max(_,$),Te=window.innerWidth,Ve=window.innerHeight,Ge=Math.max(Te,Ve),ct=W<Ge?Ge/W:1,ut=Ns[h],dt=W<=480?ut.sd:W<=720?ut.hd:W<=1080?ut.fhd:1,pt=Math.min(dt,ct);Pe.width=Math.round(_*pt),Pe.height=Math.round($*pt),F(!0),e(null),Ie.current=0,ve.current=-1,b.current=-1,T.current=-1,I.current=!1,R.current=0,De(),k.current=!1;try{let le=function(){Y||g.current!==G||(Ze(),d.current=requestAnimationFrame(()=>{At()}))};const{ModeA:Ke,ModeB:He,ModeC:_t,ModeAA:Et}=await mr(async()=>{const{ModeA:U,ModeB:Q,ModeC:be,ModeAA:pe}=await import("./index-BOKlZEHq.js").then(y=>y.i);return{ModeA:U,ModeB:Q,ModeC:be,ModeAA:pe}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const je=await navigator.gpu.requestAdapter();if(!je)throw new Error("No GPU adapter found");const M=await je.requestDevice();if(!M)throw new Error("Failed to get GPU device");const $e=Pe.getContext("webgpu");if(!$e)throw new Error("Failed to get WebGPU context");const Fe=navigator.gpu.getPreferredCanvasFormat();$e.configure({device:M,format:Fe,alphaMode:"premultiplied"});const ee=M.createTexture({size:[_,$],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),Ye=Ps[h],et=Math.round(_*pt),ge=Math.round($*pt),ht=(()=>{switch(Ye){case"ModeB":return new He({device:M,inputTexture:ee,nativeDimensions:{width:_,height:$},targetDimensions:{width:et,height:ge}});case"ModeC":return new _t({device:M,inputTexture:ee,nativeDimensions:{width:_,height:$},targetDimensions:{width:et,height:ge}});case"ModeAA":return new Et({device:M,inputTexture:ee,nativeDimensions:{width:_,height:$},targetDimensions:{width:et,height:ge}});default:return new Ke({device:M,inputTexture:ee,nativeDimensions:{width:_,height:$},targetDimensions:{width:et,height:ge}})}})(),mt=ht.getOutputTexture(),qe=M.createSampler({magFilter:"linear",minFilter:"linear"}),wt=M.createShaderModule({code:`
|
|
29
29
|
@group(0) @binding(0) var tex: texture_2d<f32>;
|
|
30
30
|
@group(0) @binding(1) var samp: sampler;
|
|
31
31
|
struct VertexOutput {
|
|
@@ -51,6 +51,6 @@ import{u as r,g as Ut,h as D,P as $r,z as Fr,d as ue,A as m,q as K,y as Or,T as
|
|
|
51
51
|
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
52
52
|
return textureSample(tex, samp, uv);
|
|
53
53
|
}
|
|
54
|
-
`}),tt=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Pt=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[tt]}),vertex:{module:kt,entryPoint:"vs"},fragment:{module:kt,entryPoint:"fs",targets:[{format:Fe}]},primitive:{topology:"triangle-list"}}),rt=M.createBindGroup({layout:tt,entries:[{binding:0,resource:mt.createView()},{binding:1,resource:qe}]});try{const U=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Q=M.createShaderModule({code:Bs}),be=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[U]}),vertex:{module:Q,entryPoint:"vs"},fragment:{module:Q,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});c.current={pipeline:be,layout:U,inputView:ee.createView()}}catch{c.current=null}if(g.current!==G){ee.destroy(),M.destroy();return}A.current=M,de.current=$e,V.current=pt,x.current=ee,O.current=mt,Le.current=Pt,We.current=qe,a.current=tt,oe.current=!1,we.current=!1;async function At(){const U=c.current;if(!U||oe.current)return!1;const Q=n.current;if(!Q)return!1;const be=!we.current;be&&M.pushErrorScope("validation");try{const he=M.importExternalTexture({source:Q}),y=M.createBindGroup({layout:U.layout,entries:[{binding:0,resource:he},{binding:1,resource:qe}]}),Ce=M.createCommandEncoder(),pe=Ce.beginRenderPass({colorAttachments:[{view:U.inputView,loadOp:"load",storeOp:"store"}]});pe.setPipeline(U.pipeline),pe.setBindGroup(0,y),pe.draw(6),pe.end(),M.queue.submit([Ce.finish()])}catch{return oe.current=!0,c.current=null,!1}if(be){const he=await M.popErrorScope().catch(()=>null);if(he)return console.warn("[anime4k] blit probe failed:",he.message),oe.current=!0,c.current=null,!1;we.current=!0}return!0}F(!1);async function xt(){if(Y||g.current!==G)return;const U=n.current;if(!U||U.videoWidth===0){le();return}if(U!==H||U.videoWidth!==_||U.videoHeight!==$){J(y=>y+1);return}if(U.paused||U.ended||document.hidden||U.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){le();return}const Q=U.getVideoPlaybackQuality().totalVideoFrames;if(Q===T.current){le();return}if(k.current){le();return}const be=U.currentTime;(U.seeking||b.current>=0&&Math.abs(be-b.current)>.5)&&(De(),I.current=!1,R.current=0,T.current=-1),b.current=be;const he=Math.max(0,_e.current||0);he>R.current&&(I.current=!1),k.current=!0;try{const y=performance.now();let Ce=null,pe=!1;if(he<=0){Ne.current.length>0&&De(),I.current=!1,R.current=0;let Ae=!1;if(!Ue.current)try{M.queue.copyExternalImageToTexture({source:U},{texture:ee},[_,$]),T.current=Q,Ae=!0}catch(z){if(z instanceof TypeError)Ue.current=!0;else throw z}if(!Ae&&!oe.current&&c.current&&await At()&&(T.current=Q,Ae=!0),!Ae){const z=await createImageBitmap(U);T.current=Q,M.queue.copyExternalImageToTexture({source:z},{texture:ee},[_,$]),ke(z)}}else{const Ae=await createImageBitmap(U);T.current=Q;const z=Ne.current;z.push({bitmap:Ae,capture:y});const Tt=St(he);for(;z.length>Tt;)ke(z.shift()?.bitmap);let Ct=-1;for(let te=z.length-1;te>=0;te--)if(y-z[te].capture>=he){Ct=te;break}if(Ct!==-1){for(let vt=0;vt<Ct;vt++)ke(z.shift()?.bitmap);const te=z.shift();te?(Ce=te.bitmap,I.current=!0,R.current=he):(Ce=Ae,pe=!0)}else if(!I.current)Ce=Ae,pe=!0;else{const te=z.shift();Ce=te?te.bitmap:Ae,te||(pe=!0)}if(!Ce){k.current=!1,le();return}M.queue.copyExternalImageToTexture({source:Ce},{texture:ee},[_,$]),pe||ke(Ce)}const nt=M.createCommandEncoder();await pt.pass(nt);const ft=nt.beginRenderPass({colorAttachments:[{view:$e.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});ft.setPipeline(Pt),ft.setBindGroup(0,rt),ft.draw(6),ft.end(),M.queue.submit([nt.finish()]),ve.current=Q,Ie.current=0,M.queue.onSubmittedWorkDone().then(()=>{g.current===G&&(k.current=!1)})}catch(y){if(k.current=!1,Ie.current+=1,Ie.current>=As&&!Y&&g.current===G){console.error(y),e(y instanceof Error?y.message:"Render error"),L(!1);return}}le()}le()}catch(le){!Y&&g.current===G&&(e(le instanceof Error?le.message:"Failed to initialize upscaler"),F(!1),L(!1))}}return Et(),()=>{Y=!0,g.current+=1,Ze(),De(),x.current&&(x.current.destroy(),x.current=null),O.current&&(O.current.destroy(),O.current=null),A.current&&(A.current.destroy(),A.current=null),V.current=null,Le.current=null,We.current=null,a.current=null,c.current=null,de.current=null,k.current=!1}},[v,f,n,i,p,o]);const q=K(Y=>{L(Y);try{localStorage.setItem("anime4kEnabled",String(Y))}catch{}},[]),ye=K(()=>{L(Y=>{const G=!Y;try{localStorage.setItem("anime4kEnabled",String(G))}catch{}return G})},[]);return{isWebGPUSupported:f,isEnabled:v,isInitializing:P,error:w,toggle:ye,setEnabled:q}}const Is=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Ds=/^[a-z0-9-]+$/i,br=n=>n?"preferredProviderMature":"preferredProvider",yr=n=>{const i=localStorage.getItem(br(n));return i&&Ds.test(i)?i:null},pr=(n,i)=>{localStorage.setItem(br(i),n)},$s=()=>yr(!1)??"megaplay",Fs=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:Is(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:ln(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:$s(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Os(n,i){switch(i.type){case"SET_STATE":return{...n,...i.payload};case"SET_MODE":return{...n,currentMode:i.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...n,selectedProvider:i.payload};default:return n}}async function mr(n,i,p,B,f=!1){if(!n||!i)throw new Error("Missing params");try{const[E,v,L,P]=await Promise.all([Ee.data.video.query({showId:n,episodeNumber:i,mode:p.currentMode,provider:p.selectedProvider}).catch(x=>{const O=x.data?.cause;return x.message==="AUTH_REQUIRED"&&O?.provider==="mkissa"&&B({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:"mkissa"}}),null}),Ee.progress.getEpisode.query({showId:n,episodeNumber:i}).catch(()=>null),Ee.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),Ee.data.skipTimes.query({showId:n,episodeNumber:i}).catch(()=>[])]),F=L?.value,w=E?.filter(x=>{const O=x.sourceName.toLowerCase();return p.currentMode==="dub"?O.includes("eng")||O.includes("dub"):O.includes("jpn")||O.includes("sub")||!O.includes("eng")&&!O.includes("dub")})??[],e=w.length>0?w:E??[];let o=e.length>0?e[0]:null;if(F){const x=e.find(O=>O.sourceName===F);x&&(o=x)}const J=o&&o.links.length>0?o.links.sort((x,O)=>(parseInt(O.resolutionStr)||0)-(parseInt(x.resolutionStr)||0))[0]:null,g=v?.currentTime||0,A=v?.duration||0,V=(Array.isArray(P)?P:P?.results||[]).map(x=>({skip_id:x.skip_id||"",skip_type:x.skip_type||"",start_time:x.interval?.start_time??x.start_time??0,end_time:x.interval?.end_time??x.end_time??0})).filter(x=>x.end_time>0);return(!E||E.length===0)&&(f||Oe.error(`No video sources found for ${p.selectedProvider}`)),{videoSources:E,selectedSource:o,selectedLink:J,resumeTime:g,resumeDuration:A,showResumeModal:g>5&&o?.type!=="iframe",skipIntervals:V,fetchedEpisodeNumber:i}}catch(E){const v=E;if(v.message==="AUTH_REQUIRED")return B({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:v.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:i};throw E}}const Ws=(n,i,p,B)=>{const[f,E]=Or(Os,p,c=>({...Fs(),showMeta:c?.name?{name:c.name,thumbnail:c.thumbnail,nativeName:c.nativeName,englishName:c.englishName,names:{romaji:c.name||c.englishName,english:c.englishName||c.name,native:c.nativeName}}:{}})),v=vr(),L=Qr(),P=m(null),F=m(null),{options:w}=gr(),e=Je(()=>w.filter(c=>(c.kind??"anime")==="anime"),[w]),o=i||f.initialEpisode,J=m(o);D(()=>{J.current!==o&&(J.current=o,E({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[o,E]),D(()=>{n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)&&f.selectedProvider!=="animepahe"&&P.current!==n&&(P.current=n,E({type:"SET_PROVIDER",payload:"animepahe"}))},[n,f.selectedProvider]);const{data:g,isLoading:A,error:de}=xn(n),{data:V}=cr({queryKey:["player-data",n,f.currentMode,f.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const c=async()=>{try{const q=await Ee.data.episodes.query({showId:n,mode:f.currentMode,provider:f.selectedProvider}).catch(()=>null);if(q?.episodes?.length)return q}catch{}return null},[b,T,I]=await Promise.all([c(),Ee.watchlist.check.query({showId:n}).catch(()=>({inWatchlist:!1,status:null})),Ee.progress.getWatchedEpisodes.query({showId:n}).catch(()=>[])]),R=b?.episodes?b.episodes.sort((q,ye)=>parseFloat(q)-parseFloat(ye)):[];return{description:b?.description||"",episodes:R,inWatchlist:T.inWatchlist,watchlistStatus:T.status??null,watchedEpisodes:I}},enabled:!!n});D(()=>{!i&&V?.episodes&&V.episodes.length>0&&!i&&E({type:"SET_STATE",payload:{initialEpisode:V.episodes[0]}})},[V,i]),D(()=>{if(g?.isAdult===void 0||F.current===n)return;const c=g.isAdult===!0,b=e.filter(I=>I.mature===c);if(b.length===0||e.find(I=>I.value===f.selectedProvider)?.mature===c)return;const T=yr(c);F.current=n,E({type:"SET_PROVIDER",payload:b.find(I=>I.value===T)?.value??b[0].value})},[g?.isAdult,f.selectedProvider,n,e]),D(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||F.current===`temp:${n}`)return;const c=g?.provider;c&&(F.current=`temp:${n}`,c!==f.selectedProvider&&E({type:"SET_PROVIDER",payload:c}))},[n,g,f.selectedProvider]);const{data:x,isLoading:O,error:Le}=cr({queryKey:["video-sources",n,o,f.selectedProvider,f.currentMode],queryFn:()=>mr(n,o,f,E),enabled:!!n&&!!o&&!(f.showMeta?.isAdult===!0&&!B?.hasMatureConsent)}),{mutateAsync:We}=Yt({mutationFn:async({wasIn:c,showMeta:b})=>{if(!n)throw new Error("Missing showId");if(c)await Ee.watchlist.remove.mutate({id:n});else{const T=b.name||b.names?.romaji;if(!T)throw new Error("Missing show name");await Ee.watchlist.add.mutate({id:n,name:T,thumbnail:b.thumbnail,nativeName:b.names?.native,englishName:b.names?.english,type:b.type,isAdult:b.isAdult})}return!c},onSuccess:c=>{Oe.success(c?"Added to watchlist":"Removed from watchlist"),v.invalidateQueries({queryKey:["player-data",n]}),v.invalidateQueries({queryKey:["show-data",n]}),v.invalidateQueries({queryKey:["watchlist"]})},onError:c=>Oe.error(c instanceof Error?c.message:"Failed to update watchlist")}),a=K(async()=>{!n||!g||await We({wasIn:!!V?.inWatchlist,showMeta:g})},[n,g,V?.inWatchlist,We]),d=K(async c=>{try{await Ee.settings.set.mutate({key:"preferredSource",value:c})}catch(b){console.error(b)}},[]),{mutateAsync:k,isPending:ve}=Yt({mutationFn:async({status:c})=>{if(!n)throw new Error("Missing showId");return await Ee.watchlist.setStatus.mutate({id:n,status:c}),c},onSuccess:c=>{E({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:c}}),Oe.success(`Moved to ${c}`),v.invalidateQueries({queryKey:["show-data",n]}),v.invalidateQueries({queryKey:["watchlist"]}),v.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>Oe.error("Failed to update watchlist status")}),Ie=K(async()=>{await k({status:"Completed"})},[k]),{mutateAsync:_e}=Yt({mutationFn:async({episodeNumber:c,duration:b,showMeta:T,episodes:I})=>{await Ee.progress.updateProgress.mutate({showId:n,episodeNumber:c,currentTime:b,duration:b,showName:T.name,showThumbnail:T.thumbnail,nativeName:T.names?.native,englishName:T.names?.english,genres:T.genres?.map(R=>R.name),popularityScore:zr(T.score??T.stats?.averageScore),type:T.type,status:T.status,episodeCount:I.length,isAdult:T.isAdult})},onSuccess:(c,b)=>{Oe.success(`Episode ${b.episodeNumber} marked as watched`),v.invalidateQueries({queryKey:["player-data",n]}),v.invalidateQueries({queryKey:["show-meta",n]}),v.invalidateQueries({queryKey:["video-sources",n,b.episodeNumber]}),v.invalidateQueries({queryKey:["allContinueWatching"]}),v.invalidateQueries({queryKey:["thisWeekSchedule"]}),v.invalidateQueries(L.continueWatching.pathFilter())},onError:()=>Oe.error("Failed to mark episode as watched")}),Ne=K(async(c,b)=>{!n||!g||await _e({episodeNumber:c,duration:b,showMeta:g,episodes:V?.episodes||[]})},[n,g,V?.episodes,_e]),Ue=K(async()=>{E({type:"SET_STATE",payload:{showCombinedDetails:!f.showCombinedDetails}})},[f.showCombinedDetails]),oe=Je(()=>{const c=de||Le,b=c?c.message:null,T=b==="AUTH_REQUIRED"?null:b,I=x&&x.fetchedEpisodeNumber===o?x:null,R=!!x&&!I;return{...f,currentEpisode:o,showMeta:{...f.showMeta||{},...g||{}},episodes:V?.episodes||[],watchedEpisodes:V?.watchedEpisodes||[],inWatchlist:!!V?.inWatchlist,watchlistStatus:V?.watchlistStatus??f.watchlistStatus??null,videoSources:I?.videoSources||[],selectedSource:f.selectedSource||I?.selectedSource||null,selectedLink:f.selectedLink||I?.selectedLink||null,resumeTime:I?.resumeTime||0,resumeDuration:I?.resumeDuration||0,showResumeModal:f.showResumeModal&&(I?.showResumeModal??!1),skipIntervals:I?.skipIntervals||[],loadingShowData:A,loadingVideo:O||R,error:T,fetchedEpisodeNumber:I?.fetchedEpisodeNumber}},[f,g,V,x,A,O,de,Le,o]),we=K((c,b)=>{const T=b||n;if(!T||!c||T===n&&c===o)return;const R=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(T)&&f.selectedProvider!=="animepahe"?"animepahe":f.selectedProvider,q=["video-sources",T,c,R,f.currentMode];v.getQueryState(q)?.status!=="success"&&v.prefetchQuery({queryKey:q,queryFn:()=>mr(T,c,{selectedProvider:R,currentMode:f.currentMode},E,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,o,v,f,E]);return{state:oe,dispatch:E,toggleWatchlist:a,moveToCompleted:Ie,setPreferredSource:d,handleToggleDetails:Ue,markEpisodeWatched:Ne,prefetchEpisodeSources:we,isMarkingWatched:_e.isPending,isUpdatingWatchlistStatus:ve}},Us=({isOpen:n,onClose:i,onSuccess:p})=>{const B=()=>{p?.(),i()};return r(Be,{isOpen:n,onClose:i,title:"MKissa Browser Verification",children:r("div",{className:yt.container,children:[r("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."}),r("div",{className:yt.actions,children:r("a",{className:yt.link,href:"https://mkissa.to/anime",target:"_blank",rel:"noreferrer",children:"Open MKissa anime"})}),r("div",{className:yt.actions,children:[r("button",{className:yt.secondaryButton,onClick:i,children:"Cancel"}),r("button",{className:yt.button,onClick:B,children:"Refresh Dango"})]})]})})},Jt="fallbackChoice";function Vs(){try{const n=localStorage.getItem(Jt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function qs(n){try{n===null?localStorage.removeItem(Jt):localStorage.setItem(Jt,n)}catch{}}const ao=()=>{const{id:n,episodeNumber:i}=Wr(),p=Ur(),B=vr(),f=Vr(),{hasConsent:E,grant:v}=Gr(),{options:L}=gr(),P=Je(()=>L.filter(t=>(t.kind??"anime")==="anime"),[L]),F=Je(()=>P.map(t=>t.value),[P]),w=Je(()=>new Set(P.filter(t=>t.mature).map(t=>t.value)),[P]),{state:e,dispatch:o,toggleWatchlist:J,moveToCompleted:g,setPreferredSource:A,handleToggleDetails:de,markEpisodeWatched:V,prefetchEpisodeSources:x,isMarkingWatched:O,isUpdatingWatchlistStatus:Le}=Ws(n,i,f.state||null,{hasMatureConsent:E});D(()=>{if(n&&e.showMeta?.id&&e.showMeta.id!==n){const t=i?`/watch/${e.showMeta.id}/${i}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;p(t,{replace:!0})}},[n,e.showMeta?.id,i,p]);const We=Je(()=>{if(e.showMeta.name)return{name:e.showMeta.name,thumbnail:e.showMeta.thumbnail,names:e.showMeta.names,genres:e.showMeta.genres,score:e.showMeta.score,isAdult:e.showMeta.isAdult}},[e.showMeta.name,e.showMeta.thumbnail,e.showMeta.names,e.showMeta.genres,e.showMeta.score,e.showMeta.isAdult]),a=cn({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:We}),{refs:d,actions:k}=a,ve=m(null),Ie=Pn(),_e=m(null),Ne=m(null),Ue=m(null),oe=m(0),we=m(e.resumeTime),c=m(e.showResumeModal),[b,T]=ue(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),{videoDelayMs:I,videoDelayEnabled:R,setDelayEnabled:q,handleVideoDelayChange:ye,isCalibrating:Y,testClipActive:G,stopCalibration:ke,openAvSyncCalibrator:De,cancelAvSyncCalibrator:St,applyAvSyncCalibrator:Ze,toggleTestClip:Et,calibReturnRef:H,effectiveVideoDelayMs:Pe}=un(d.videoRef,()=>k.setShowSettings(!1)),lt=m(null),_=Ls({videoRef:d.videoRef,canvasRef:Ne,profile:b,delayMs:Pe}),$=_.isEnabled&&_.isWebGPUSupported,W=`${n??""}:${e.currentEpisode??""}`,Te=m(null),Ve=m(!1),Ge=m(!1),ct=m(_.setEnabled);ct.current=_.setEnabled,D(()=>{const t=Te.current;Te.current=W,!(t===null||t===W)&&(!_.isEnabled||!_.isWebGPUSupported||(Ve.current=!0,Ge.current=!1,ct.current(!1)))},[W,_.isEnabled,_.isWebGPUSupported]),D(()=>{if(!Ve.current)return;if(_.isEnabled){Ge.current&&(Ve.current=!1);return}if(Ge.current=!0,e.loadingVideo||!e.selectedLink)return;if(e.selectedSource?.type==="iframe"){Ve.current=!1,ct.current(!0);return}const t=d.videoRef.current;if(!t)return;let s,l=!1;const u=()=>{l||(l=!0,Ve.current=!1,ct.current(!0))};if(t.readyState>=2)return s=window.setTimeout(u,500),()=>window.clearTimeout(s);const N=()=>{window.setTimeout(u,500)};return t.addEventListener("canplay",N,{once:!0}),t.addEventListener("playing",N,{once:!0}),s=window.setTimeout(u,5e3),()=>{window.clearTimeout(s),t.removeEventListener("canplay",N),t.removeEventListener("playing",N)}},[_.isEnabled,e.loadingVideo,e.selectedLink,e.selectedSource?.type,d.videoRef]),dn({videoRef:d.videoRef,canvasRef:lt,delayMs:Pe,enabled:R&&!$});const ut=R&&!$,dt=$||ut;D(()=>{we.current=e.resumeTime,c.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[ht,le]=ue(!1),[Ke,He]=ue(!1),[Nt,wt]=ue(!1),je=m(!1),[M,$e]=ue(null),Fe=m(!1),ee=m([]),Ye=m(!1),[et,ge]=ue(null),[pt,mt]=ue(!1),[qe,kt]=ue(!1),[tt,Pt]=ue(()=>Vs()??"ask"),rt=K(t=>{Pt(t),qs(t==="ask"?null:t)},[]),At=m(tt);At.current=tt;const xt=m(e.videoSources);xt.current=e.videoSources;const U=m(()=>{}),[Q,be]=ue(null),he=m(i);D(()=>{he.current!==i&&(he.current=i,be(null),$e(null),je.current=!1,ke())},[i,ke]),D(()=>{Fe.current=!1,ee.current=[],Ye.current=!1,ge(null),mt(!1)},[n,e.currentEpisode]),D(()=>{Ke||(je.current=!1)},[Ke]);const{data:y=[],isLoading:Ce}=Kr(),pe=Hr(),nt=m(pe);nt.current=pe;const ft=jr(),Ae=Yr(),{isTheaterMode:z,toggleTheaterMode:Tt,handleLayoutClick:Ct}=hn();qr(()=>{if(a.state.isFullscreen||z)return;const t=d.playerContainerRef.current,s=_e.current;if(!t||!s)return;const l=()=>{const N=t.getBoundingClientRect().height;s.style.height=`${N}px`};l();const u=new ResizeObserver(l);return u.observe(t),()=>u.disconnect()},[a.state.isFullscreen,z,d.playerContainerRef]);const te=Je(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),vt=te>0?e.episodes[te-1]:null,Re=te>=0&&te<e.episodes.length-1?e.episodes[te+1]:null,Vt=te>-1&&te<e.episodes.length-1,qt=pn(e.resumeTime,e.resumeDuration)||Ke,Xe=qt&&ur(e.episodes,e.currentEpisode,e.showMeta.status),Qt=e.showResumeModal&&(Xe||!qt),Bt=qt&&!Xe&&y.length===0&&!Q&&(e.showResumeModal||Ke),st=Qt||Bt;mn(a,!!e.selectedLink&&!z&&!st),D(()=>{const t=d.videoRef.current;if(!t)return;let s=!1;for(ve.current&&(ve.current.destroy(),ve.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(G)return t.src="/av-sync-test.mp4",t.play().catch(()=>{k.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){oe.current=0;return}H.current!=null?(oe.current=H.current,H.current=null):we.current>5&&!c.current?oe.current=we.current:c.current&&(oe.current=0);let l=e.selectedLink.link;if(l.startsWith("/api/proxy")||(l=`/api/proxy?url=${encodeURIComponent(l)}`,e.selectedLink.headers?.Referer&&(l+=`&referer=${encodeURIComponent(e.selectedLink.headers.Referer)}`)),e.selectedSource.subtitles){const ce=localStorage.getItem("playerSubtitlesEnabled")!=="false";let Se=null;try{Se=localStorage.getItem("playerLastSubtitle")}catch{}const re=Xt(e.selectedSource.subtitles,{lastKey:Se,enabled:ce}),Me=re>=0?e.selectedSource.subtitles[re]:null;e.selectedSource.subtitles.forEach(fe=>{const ne=document.createElement("track");ne.kind="subtitles",ne.label=fe.label,ne.srclang=fe.lang;const S=fe.src??fe.url;if(S){let se=`/api/subtitle-proxy?url=${encodeURIComponent(S)}`;const ae=e.selectedLink?.headers?.Referer,gt=S.includes("anilight.live")?"https://anilight.live/":"",Ot=ae||gt;Ot&&(se+=`&referer=${encodeURIComponent(Ot)}`),ne.src=se}Me&&fe.label===Me.label&&fe.lang===Me.lang&&(ne.default=!0),t.appendChild(ne)}),ce||k.setActiveSubtitleTrack("off"),k.setAvailableSubtitles(e.selectedSource.subtitles)}const u=oe.current;oe.current=0;const N=()=>{u>0&&(t.currentTime=u)};t.addEventListener("loadedmetadata",N,{once:!0});const me=!(c.current&&we.current>5),X=()=>{me&&t.play().catch(()=>{k.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const ce=await Nn();if(s)return;if(!ce||!ce.isSupported()){t.src=l,X();return}const Se=document.body.classList.contains("low-end"),re=new ce({maxBufferLength:Se?15:30,maxMaxBufferLength:Se?30:60,maxBufferSize:Se?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});ve.current=re,re.on(ce.Events.ERROR,(ne,S)=>{S.fatal&&!Fe.current&&U.current()});const Me=(e.selectedSource?.subtitles?.length??0)>0,fe=()=>{try{Me&&typeof re.subtitleTrack=="number"&&re.subtitleTrack!==-1&&(re.subtitleTrack=-1)}catch{}};re.on(ce.Events.SUBTITLE_TRACK_SWITCH,(ne,S)=>{S?.id!==-1&&fe()}),fe(),re.loadSource(l),re.attachMedia(t),re.once(ce.Events.MANIFEST_PARSED,()=>{s||X()})})():(t.src=l,X());const j=localStorage.getItem("playerVolume"),ie=localStorage.getItem("playerMuted");return j!==null&&(t.volume=parseFloat(j)),ie!==null&&(t.muted=ie==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",N),ve.current&&(ve.current.destroy(),ve.current=null)}},[e.selectedSource,e.selectedLink,d.videoRef,H,k,e.loadingVideo,G]);const Lt=K(t=>{if(Fe.current)return;Fe.current=!0;const s=t.links[0];A(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),ge(null)},[o,A]),It=K(()=>{const s=xt.current.find(l=>l.type==="iframe");return s?.links?.length?s:null},[]),Dt=K(async()=>{const t=e.showMeta?.isAdult,s=F.filter(l=>{if(ee.current.includes(l))return!1;const u=w.has(l);return t===void 0?!0:u===t});mt(!0);try{for(const l of s){ee.current.push(l);let u=null;try{u=await Ee.data.video.query({showId:n,episodeNumber:e.currentEpisode,mode:e.currentMode,provider:l})}catch{continue}const N=(u??[]).filter(j=>{const ie=j.sourceName.toLowerCase();return e.currentMode==="dub"?ie.includes("eng")||ie.includes("dub"):ie.includes("jpn")||ie.includes("sub")||!ie.includes("eng")&&!ie.includes("dub")});if((N.length>0?N:u??[]).find(j=>j.type!=="iframe"&&j.links?.length)){ee.current=[e.selectedProvider],Ye.current=!1,o({type:"SET_STATE",payload:{selectedProvider:l,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),pr(l,e.showMeta?.isAdult===!0),ge(null),Oe.success(`Switched to ${l} (direct stream)`);return}}ge({retryFailed:!0}),Oe.error("No working direct stream found on other providers")}finally{mt(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,o,F,w]),Zt=K(()=>{if(Fe.current||Ye.current||e.selectedSource?.type!=="player")return;const t=It();if(!t)return;ee.current.includes(e.selectedProvider)||ee.current.push(e.selectedProvider);const s=At.current;if(s==="iframe"){Lt(t);return}if(s==="retry"){Dt();return}k.setShowControls(!0),ge({retryFailed:!1})},[e.selectedSource,e.selectedProvider,It,Lt,Dt,k]);U.current=Zt;const Sr=K(()=>{Ye.current=!0,ge(null),kt(!1)},[]),Er=K(()=>{qe&&rt("iframe");const t=It();t?Lt(t):ge(null)},[qe,rt,It,Lt]),wr=K(()=>{qe&&rt("retry"),Dt()},[qe,rt,Dt]),Rt=(t,s,l)=>t.showId===s||!!l&&t.showId===l,$t=K(()=>{k.onEnded();const t=y.find(l=>Rt(l,n,e.showMeta?.id)&&l.episodeNumber===e.currentEpisode);if(y.length>0){const l=y.findIndex(N=>Rt(N,n,e.showMeta?.id)&&N.episodeNumber===e.currentEpisode),u=l>=0?y[l+1]||null:y[0];be({nextItem:u,playedItem:t||null}),$e(2)}else t&&nt.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&y.length===0){const l=e.episodes.findIndex(u=>u===e.currentEpisode);if(l>-1&&l<e.episodes.length-1){const u=e.episodes[l+1];B.invalidateQueries({queryKey:["allContinueWatching"]}),p(`/watch/${n}/${u}`),s=!0}}!s&&y.length===0&&!Q&&!je.current&&ur(e.episodes,e.currentEpisode,e.showMeta.status)&&o({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,p,y,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,Q,o,B]),zt=K(()=>{if(y.length===0)return;k.onEnded();const t=y.find(u=>Rt(u,n,e.showMeta?.id)&&u.episodeNumber===e.currentEpisode),s=y.findIndex(u=>Rt(u,n,e.showMeta?.id)&&u.episodeNumber===e.currentEpisode),l=s>=0?y[s+1]||null:y[0];t&&pe.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),l?p(`/watch/${l.showId}/${l.episodeNumber}`):t&&o({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,p,y,pe,n,e.showMeta?.id,e.currentEpisode,o]),Mt=K(()=>{Re&&(B.invalidateQueries({queryKey:["allContinueWatching"]}),He(!1),p(`/watch/${n}/${Re}`)),o({type:"SET_STATE",payload:{showResumeModal:!1}})},[Re,p,n,o,B]),er=K(()=>{y.length>0?zt():Re?Mt():Oe.error("No next episode available")},[y.length,zt,Mt,Re]),kr=()=>{vt&&p(`/watch/${n}/${vt}`)};D(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>{G||$t()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[$t,d.videoRef,G]),D(()=>{const t=s=>{s.origin===window.location.origin&&e.selectedSource?.type==="iframe"&&s.data?.type==="ANI_WEB_MEDIA_ENDED"&&$t()};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[$t,e.selectedSource?.type]),D(()=>{if(!Q||M===null)return;if(M<=0){const{nextItem:s,playedItem:l}=Q;be(null),$e(null),l&&nt.current.mutate({showId:l.showId,episodeNumber:l.episodeNumber}),s?p(`/watch/${s.showId}/${s.episodeNumber}`):l&&o({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{$e(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[Q,M,p,o]),D(()=>{st&&a.state.isFullscreen&&a.actions.toggleFullscreen()},[st,a.state.isFullscreen,a.actions]),D(()=>{st&&d.videoRef.current&&d.videoRef.current.pause()},[st,d.videoRef]);const{titlePreference:Ft}=Xr(),{lowEndMode:tr}=Jr(),{settings:Gt,update:Tr}=fn(),Cr=z&&Gt.enabled&&!tr&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,ot=Je(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:t,names:s}=e.showMeta;return Ft==="name"?t||"Loading...":Ft==="nativeName"?s?.native||t||"Loading...":Ft==="englishName"?s?.english||t||"Loading...":t||"Loading..."},[e.showMeta,Ft,e.loadingShowData]);D(()=>{ot&&ot!=="Loading..."&&e.currentEpisode&&(document.title=`► ${ot} Episode ${e.currentEpisode} - dango`)},[ot,e.currentEpisode]),D(()=>{const t=s=>{s.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(s.key.toLowerCase())&&(k.setShowControls(!0),a.actions.inactivityTimer.current&&clearTimeout(a.actions.inactivityTimer.current),a.actions.inactivityTimer.current=window.setTimeout(()=>{k.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&er(),s.key.toLowerCase()==="t"&&Tt())};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[k,a.actions.inactivityTimer,er,Tt]);const{setAvailableSubtitles:rr,setActiveSubtitleTrack:Kt}=k;D(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>{const l=Array.from(t.textTracks).map(u=>({label:u.label,lang:u.language,src:void 0,mode:u.mode}));rr(l)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[d.videoRef,rr]),D(()=>{if(a.state.activeSubtitleTrack===null&&a.state.availableSubtitles.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let t=null;try{t=localStorage.getItem("playerLastSubtitle")}catch{}const s=Xt(a.state.availableSubtitles,{lastKey:t,enabled:!0});if(s<0){Kt("off");return}const l=a.state.availableSubtitles[s];Kt(l.lang||l.label)}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,Kt]),D(()=>{const t=d.videoRef.current;if(!t||a.state.availableSubtitles.length===0)return;const s=a.state.activeSubtitleTrack;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(t.textTracks).forEach(N=>{N.mode="hidden"});return}let u=!1;if(Array.from(t.textTracks).forEach(N=>{const X=(N.language===s||N.label===s)&&!u;N.mode=X?"showing":"hidden",X&&(u=!0)}),!u&&t.textTracks.length>0){const N=Array.from(t.textTracks).find(me=>me.language==="en"||me.label==="English")||t.textTracks[0];N&&(N.mode="showing")}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,d.videoRef]);const[nr,Rr]=ue(0);D(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>Rr(t.clientHeight||0);s();const l=new ResizeObserver(s);return l.observe(t),()=>l.disconnect()},[d.videoRef,e.selectedSource,e.selectedLink]),D(()=>{const t="dynamic-subtitle-styles";let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,document.head.appendChild(s));const l={fontSize:a.state.subtitleFontSize,position:a.state.subtitlePosition,bgOpacity:a.state.subtitleBgOpacity,bgColor:a.state.subtitleBgColor,textColor:a.state.subtitleTextColor,edge:a.state.subtitleEdge,bold:a.state.subtitleBold};s.textContent=dr(l);const u=d.videoRef.current;if(!u)return;const N=hr(a.state.subtitleFontSize,nr||u.clientHeight||720);s.textContent=dr({...l,fontSize:N});const me=()=>{const S=Number(a.state.subtitlePosition),se=isNaN(S)?0:Math.max(0,Math.min(100,S));return Math.max(0,Math.min(100,100-se))},X=(S,se)=>{try{const ae=S;ae.snapToLines=!1,ae.line=se}catch{}},j=()=>{const S=N*16,se=u.videoHeight||u.clientHeight||720,ae=u.videoWidth||u.clientWidth||1280;return{step:S*1.3/se*100,chars:Math.max(20,Math.floor(ae/(S*.55)))}},ie=S=>{const se=me(),ae=Array.from(S.activeCues??[]);if(ae.length<=1){ae.forEach(bt=>X(bt,se));return}const{step:gt,chars:Ot}=j();let ar=se;for(let bt=ae.length-1;bt>=0;bt--){const Lr=String(ae[bt].text??"").replace(/<[^>]*>/g,"").split(`
|
|
55
|
-
`).reduce((Ir,Dr)=>Ir+Math.max(1,Math.ceil(Dr.length/
|
|
56
|
-
bottom: calc(${Me}px + ${gt}em);`,ae.innerHTML=yn(se),s.appendChild(ae)})}const me=()=>N(),X=()=>N();return Array.from(t.textTracks).forEach(j=>{j.addEventListener("cuechange",me)}),t.addEventListener("timeupdate",X),N(),()=>{Array.from(t.textTracks).forEach(j=>{j.removeEventListener("cuechange",me)}),t.removeEventListener("timeupdate",X),s.innerHTML=""}},[_.isEnabled,_.isWebGPUSupported,a.state.subtitleFontSize,a.state.subtitlePosition,a.state.subtitleBgOpacity,a.state.subtitleBgColor,a.state.subtitleTextColor,a.state.subtitleEdge,a.state.subtitleBold,a.state.activeSubtitleTrack,d.videoRef,dt,Pe]),D(()=>{try{localStorage.setItem("anime4kProfile",b)}catch{}},[b]);const Mr=()=>{d.videoRef.current&&(d.videoRef.current.currentTime=e.resumeTime,d.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},_r=()=>{d.videoRef.current&&(d.videoRef.current.currentTime=0,d.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},Ht=K(()=>{Xe&&(je.current=!0),Bt&&He(!1),o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o,Xe,Bt]),Nr=K(()=>{if(He(!1),d.videoRef.current)try{d.videoRef.current.currentTime=0,d.videoRef.current.play().catch(()=>{})}catch{}o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o,d]),Pr=K(async()=>{try{await g(),o({type:"SET_STATE",payload:{showResumeModal:!1}}),p("/")}catch{}},[g,o,p]),sr=(t,s)=>r("div",{className:t,children:[r("button",{className:`${h.episodeNavBtn} ${h.secondary}`,onClick:kr,disabled:!vt,type:"button",children:[r(Z,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${h.episodeNavBtn} ${h.primary}`,onClick:Mt,disabled:!Re,type:"button",children:["Next EP",r(Z,{name:"chevron-right",size:12})]}),s==="mobile"&&Ie&&r("button",{className:`${h.episodeNavBtn} ${h.episodePickerBtn}`,onClick:()=>wt(!0),type:"button",children:[r(Z,{name:"list-ul",size:12}),"Episodes"]})]});D(()=>{Ke&&(e.showResumeModal||y.length>0||Q||je.current||Xe&&o({type:"SET_STATE",payload:{showResumeModal:!0}}))},[Ke,Xe,e.showResumeModal,y.length,Q,o]);const Ar=t=>{o({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),_n(t)},or=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),xr=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",jt=m(x);jt.current=x;const ir=m("");D(()=>{const t=d.videoRef.current;if(le(!1),He(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const l=t.duration,u=t.currentTime;if(!l||Number.isNaN(l)){le(!1),He(!1);return}const N=u/l;if(l-u<=60){const me=y.findIndex(ie=>Rt(ie,n,e.showMeta?.id)&&ie.episodeNumber===e.currentEpisode),X=y.length>0?me>=0?y[me+1]||null:y[0]:null,j=X?`${X.showId}:${X.episodeNumber}`:Vt?`${n}:${Re}`:"";j&&ir.current!==j&&(ir.current=j,X?jt.current(X.episodeNumber,X.showId):jt.current(Re))}le(Vt&&N>=.8),He(u>=Math.max(l*.98,l-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[d.videoRef,Vt,e.currentEpisode,e.selectedSource,Re,n,y,e.showMeta?.id]);const Br=K(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||O)return;const t=d.videoRef.current?.duration,s=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await V(e.currentEpisode,s)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,V,O,d.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return r("p",{className:"error-message",children:["Error: ",e.error]});const Qe=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!E?r("div",{className:xe.playerPageLayout,children:r(Be,{isOpen:!0,title:"Content Warning",onClose:()=>p("/home"),children:r("div",{style:{padding:"1rem",textAlign:"center"},children:[r("p",{children:"This title contains mature content intended for adult audiences."}),r("p",{children:["By proceeding, you confirm that you are ",r("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),r("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[r(it,{variant:"secondary",onClick:()=>p("/home"),children:"Go Back"}),r(it,{onClick:v,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${xe.playerPageLayout} ${z?xe.theaterMode:""}`,onClick:Ct,children:[z&&r(Sn,{videoRef:d.videoRef,active:Cr,settings:Gt}),r(Be,{isOpen:Qt&&Xe,onClose:Ht,title:"Show Completed!",width:"sm",children:[r(Be.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r(Be.Actions,{children:r(it,{onClick:Pr,disabled:Le,children:Le?"Saving...":"Move to Completed"})})]}),r(En,{isOpen:Qt&&!Xe,onClose:Ht,title:"Resume Playback?",message:r(Wt,{children:["You were watching at ",r("strong",{children:a.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:Mr,onRestart:_r}),r(Be,{isOpen:Bt,onClose:Ht,title:"Episode Completed",width:"sm",children:[r(Be.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",Re?" Would you like to watch the next episode?":""]})}),r(Be.Actions,{children:[r(it,{variant:"secondary",onClick:Nr,children:"Replay"}),Re&&r(it,{onClick:Mt,children:`Watch EP ${Re}`})]})]}),r(Be,{isOpen:!!et,onClose:Sr,title:"Direct stream failed",width:"sm",children:[r(Be.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),et?.retryFailed&&r("p",{children:"No working direct stream was found on the other providers either."}),r("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",r("strong",{children:"ads and pop-ups"}),"."]}),r("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[r("input",{type:"checkbox",checked:qe,onChange:t=>kt(t.target.checked)}),"Remember my choice"]})]}),r(Be.Actions,{children:[r(it,{variant:"secondary",onClick:Er,children:"Continue with iframe"}),r(it,{onClick:wr,disabled:pt,children:pt?"Searching…":"Try another provider"})]})]}),r(Zr,{isOpen:!!e.showCookieModal&&e.cookieProvider!=="mkissa",onClose:()=>o({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{B.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),r(Us,{isOpen:!!e.showCookieModal&&e.cookieProvider==="mkissa",onClose:()=>o({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{B.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!z&&r("aside",{ref:_e,className:xe.episodeSidebar,children:e.loadingShowData?r(wn,{variant:"sidebar"}):r(kn,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>p(`/watch/${n}/${t}`)})}),r("div",{className:xe.playerMain,children:[r("div",{className:`${h.videoContainer} ${a.state.isFullscreen?"":xe.videoPlayerWrapper} ${a.state.isFullscreen?h.fullscreenActive:""}`,style:{...st?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(Ts,{player:a,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Ar,fallbackChoice:tt,onFallbackChoiceChange:rt,ambientSettings:Gt,onAmbientChange:Tr,showNextEpisodeButton:!st&&ht&&y.length===0,onNextEpisode:Mt,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{d.videoRef.current&&!isNaN(d.videoRef.current.currentTime)&&(oe.current=d.videoRef.current.currentTime),A(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:Qe,skipIntervals:e.skipIntervals,animeTitle:ot,episodeNumber:e.currentEpisode,isTheaterMode:z,onTheaterModeToggle:Tt,anime4kEnabled:_.isEnabled,onAnime4kToggle:_.toggle,anime4kSupported:_.isWebGPUSupported,anime4kProfile:b,onAnime4kProfileChange:T,anime4kInitializing:_.isInitializing,anime4kError:_.error,videoDelayEnabled:R,onVideoDelayToggle:q,videoDelayMs:I,onVideoDelayChange:ye,onCalibrateAvSync:De,isInteractingExtra:Nt||Y,className:Tn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(Wt,{children:[a.state.isSpeedBoostActive&&r("div",{className:h.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(Z,{name:"forward",size:12})]}),M!==null&&Q?.nextItem&&r("div",{className:h.queueCountdown,children:["Queue next in ",M,"s"]})]}),children:[Qe&&r("div",{className:h.loadingOverlay,children:r("div",{className:h.loadingDots,children:[r("div",{className:h.dot}),r("div",{className:h.dot}),r("div",{className:h.dot})]})}),a.state.isBuffering&&!Qe&&e.selectedSource?.type!=="iframe"&&r("div",{className:h.bufferingOverlay,children:r("div",{className:h.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!Qe&&r("iframe",{src:e.selectedLink?.link,className:h.videoIframe,allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,sandbox:e.selectedSource.sandbox?`${e.selectedSource.sandbox} allow-fullscreen allow-popups allow-popups-to-escape-sandbox`:void 0}):r(Wt,{children:[!Qe&&e.videoSources.length===0&&r("div",{className:h.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:h.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:h.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Qe&&e.videoSources.length>0&&r("video",{ref:d.videoRef,controls:a.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:k.onPlay,onPause:k.onPause,onLoadedMetadata:k.onLoadedMetadata,onTimeUpdate:()=>{G||(k.onTimeUpdate(),Q&&d.videoRef.current&&d.videoRef.current.currentTime<d.videoRef.current.duration-1&&(be(null),$e(null)))},onProgress:k.onProgress,onVolumeChange:k.onVolumeChange,onWaiting:k.onWaiting,onPlaying:k.onPlaying,onCanPlay:k.onCanPlay,onError:Zt,onContextMenu:t=>t.preventDefault(),className:dt?h.videoElementHidden:""}),_.isWebGPUSupported&&!Qe&&e.videoSources.length>0&&r("canvas",{ref:Ne,className:`${h.upscalerCanvas} ${$?h.upscalerActive:""}`}),!$&&!Qe&&e.videoSources.length>0&&r("canvas",{ref:lt,className:`${h.upscalerCanvas} ${ut?h.upscalerActive:""}`}),_.isEnabled&&_.isWebGPUSupported&&_.isInitializing&&r("div",{className:h.upscalerStatusBadge,children:"Preparing upscaler…"}),dt&&r("div",{ref:Ue,className:h.subtitleOverlay}),r(Cn,{isOpen:Y,ms:I,onChange:ye,onApply:Ze,onClose:St,testClipActive:G,onTestClip:Et})]})]})}),!z&&r(Rn,{}),!z&&r(Wt,{children:[Ce&&y.length===0?r(Cs,{count:3}):r(An,{title:"Queue",items:y,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:zt,onRemove:t=>pe.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>ft.mutate(),showClearAll:!0,onReorder:t=>Ae.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:h.streamPanel,children:[r(Rs,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:P,onProviderChange:t=>{Fe.current=!1,ee.current=[],Ye.current=!1,ge(null),o({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),pr(t,e.showMeta?.isAdult===!0)}}),sr(`${h.episodeActions} ${h.desktopEpisodeActions}`,"desktop"),Qe?r("div",{className:h.sourceLoader,children:r("div",{className:h.spinner})}):r(_s,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{d.videoRef.current&&!isNaN(d.videoRef.current.currentTime)&&(oe.current=d.videoRef.current.currentTime);const l=(t.links||[]).sort((u,N)=>(parseInt(N.resolutionStr)||0)-(parseInt(u.resolutionStr)||0))[0]||null;A(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:l,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(A(e.selectedSource.sourceName),o({type:"SET_STATE",payload:{selectedLink:t}}))}})]}),r("div",{className:xe.playerInfoContainer,children:[r("div",{className:xe.playerInfoHeader,children:[r("div",{className:xe.playerAnimeCard,children:r("img",{src:en(e.showMeta.thumbnail||""),alt:ot,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:xe.videoTitleSection,children:[r("div",{className:h.titleContainer,children:[r("h1",{children:ot}),r("div",{className:h.scheduleInfo,children:[e.showMeta.status&&r("span",{className:h.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:h.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:h.controls,children:[r("button",{className:`${h.watchlistBtn} ${e.inWatchlist?h.inList:""}`,onClick:J,children:[e.inWatchlist?r(Z,{name:"check",size:14}):r(Z,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(Bn,{showId:n,showName:e.showMeta.name||e.showMeta.names?.romaji,showThumbnail:e.showMeta.thumbnail,nativeName:e.showMeta.names?.native,englishName:e.showMeta.names?.english,showType:e.showMeta.type,className:`${h.watchlistBtn} ${h.queueBtn}`,activeClassName:h.queueActive}),xr&&r("button",{className:`${h.watchlistBtn} ${h.markWatchedBtn} ${or?h.markWatchedDone:""}`,onClick:Br,disabled:O||!e.currentEpisode,children:[r(Z,{name:"check",size:14}),O?"Saving...":or?"Watched":"Mark Watched"]}),r("button",{className:`${h.watchlistBtn} ${h.modeToggleBtn} ${e.currentMode==="dub"?h.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";Fe.current=!1,ee.current=[],Ye.current=!1,ge(null),o({type:"SET_MODE",payload:t}),localStorage.setItem("preferredMode",t)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),tr&&r("button",{className:`${h.watchlistBtn} ${h.modeToggleBtn} ${a.state.useNativeControls?h.modeToggleActive:""}`,onClick:()=>{const t=!a.state.useNativeControls;a.actions.setUseNativeControls(t),localStorage.setItem("playerUseNativeControls",t.toString())},type:"button",children:a.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),sr(`${h.episodeActions} ${h.mobileEpisodeActions}`,"mobile"),r("div",{className:xe.infoColumns,children:[r("div",{className:`${h.descriptionSection} ${h.synopsisFlat}`,children:[r("h3",{children:"Synopsis"}),r(In,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."}),r("button",{className:h.detailsToggleBtn,onClick:de,children:[e.showCombinedDetails?r(Z,{name:"chevron-up"}):r(Z,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]})]}),e.showCombinedDetails&&r(Ln,{showMeta:e.showMeta,styles:h})]})]})]})]}),r(Mn,{isOpen:Nt,onClose:()=>wt(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{wt(!1),p(`/watch/${n}/${t}`)}})]})};export{ao as default};
|
|
54
|
+
`}),tt=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Nt=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[tt]}),vertex:{module:wt,entryPoint:"vs"},fragment:{module:wt,entryPoint:"fs",targets:[{format:Fe}]},primitive:{topology:"triangle-list"}}),rt=M.createBindGroup({layout:tt,entries:[{binding:0,resource:mt.createView()},{binding:1,resource:qe}]});try{const U=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Q=M.createShaderModule({code:Bs}),be=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[U]}),vertex:{module:Q,entryPoint:"vs"},fragment:{module:Q,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});c.current={pipeline:be,layout:U,inputView:ee.createView()}}catch{c.current=null}if(g.current!==G){ee.destroy(),M.destroy();return}A.current=M,de.current=$e,V.current=ht,x.current=ee,O.current=mt,Le.current=Nt,We.current=qe,a.current=tt,ie.current=!1,we.current=!1;async function Pt(){const U=c.current;if(!U||ie.current)return!1;const Q=n.current;if(!Q)return!1;const be=!we.current;be&&M.pushErrorScope("validation");try{const pe=M.importExternalTexture({source:Q}),y=M.createBindGroup({layout:U.layout,entries:[{binding:0,resource:pe},{binding:1,resource:qe}]}),Ce=M.createCommandEncoder(),he=Ce.beginRenderPass({colorAttachments:[{view:U.inputView,loadOp:"load",storeOp:"store"}]});he.setPipeline(U.pipeline),he.setBindGroup(0,y),he.draw(6),he.end(),M.queue.submit([Ce.finish()])}catch{return ie.current=!0,c.current=null,!1}if(be){const pe=await M.popErrorScope().catch(()=>null);if(pe)return console.warn("[anime4k] blit probe failed:",pe.message),ie.current=!0,c.current=null,!1;we.current=!0}return!0}F(!1);async function At(){if(Y||g.current!==G)return;const U=n.current;if(!U||U.videoWidth===0){le();return}if(U!==H||U.videoWidth!==_||U.videoHeight!==$){J(y=>y+1);return}if(U.paused||U.ended||document.hidden||U.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){le();return}const Q=U.getVideoPlaybackQuality().totalVideoFrames;if(Q===T.current){le();return}if(k.current){le();return}const be=U.currentTime;(U.seeking||b.current>=0&&Math.abs(be-b.current)>.5)&&(De(),I.current=!1,R.current=0,T.current=-1),b.current=be;const pe=Math.max(0,_e.current||0);pe>R.current&&(I.current=!1),k.current=!0;try{const y=performance.now();let Ce=null,he=!1;if(pe<=0){Ne.current.length>0&&De(),I.current=!1,R.current=0;let Ae=!1;if(!Ue.current)try{M.queue.copyExternalImageToTexture({source:U},{texture:ee},[_,$]),T.current=Q,Ae=!0}catch(z){if(z instanceof TypeError)Ue.current=!0;else throw z}if(!Ae&&!ie.current&&c.current&&await Pt()&&(T.current=Q,Ae=!0),!Ae){const z=await createImageBitmap(U);T.current=Q,M.queue.copyExternalImageToTexture({source:z},{texture:ee},[_,$]),ke(z)}}else{const Ae=await createImageBitmap(U);T.current=Q;const z=Ne.current;z.push({bitmap:Ae,capture:y});const kt=yt(pe);for(;z.length>kt;)ke(z.shift()?.bitmap);let Tt=-1;for(let te=z.length-1;te>=0;te--)if(y-z[te].capture>=pe){Tt=te;break}if(Tt!==-1){for(let vt=0;vt<Tt;vt++)ke(z.shift()?.bitmap);const te=z.shift();te?(Ce=te.bitmap,I.current=!0,R.current=pe):(Ce=Ae,he=!0)}else if(!I.current)Ce=Ae,he=!0;else{const te=z.shift();Ce=te?te.bitmap:Ae,te||(he=!0)}if(!Ce){k.current=!1,le();return}M.queue.copyExternalImageToTexture({source:Ce},{texture:ee},[_,$]),he||ke(Ce)}const nt=M.createCommandEncoder();await ht.pass(nt);const ft=nt.beginRenderPass({colorAttachments:[{view:$e.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});ft.setPipeline(Nt),ft.setBindGroup(0,rt),ft.draw(6),ft.end(),M.queue.submit([nt.finish()]),ve.current=Q,Ie.current=0,M.queue.onSubmittedWorkDone().then(()=>{g.current===G&&(k.current=!1)})}catch(y){if(k.current=!1,Ie.current+=1,Ie.current>=As&&!Y&&g.current===G){console.error(y),e(y instanceof Error?y.message:"Render error"),L(!1);return}}le()}le()}catch(le){!Y&&g.current===G&&(e(le instanceof Error?le.message:"Failed to initialize upscaler"),F(!1),L(!1))}}return St(),()=>{Y=!0,g.current+=1,Ze(),De(),x.current&&(x.current.destroy(),x.current=null),O.current&&(O.current.destroy(),O.current=null),A.current&&(A.current.destroy(),A.current=null),V.current=null,Le.current=null,We.current=null,a.current=null,c.current=null,de.current=null,k.current=!1}},[v,f,n,i,h,o]);const q=K(Y=>{L(Y);try{localStorage.setItem("anime4kEnabled",String(Y))}catch{}},[]),ye=K(()=>{L(Y=>{const G=!Y;try{localStorage.setItem("anime4kEnabled",String(G))}catch{}return G})},[]);return{isWebGPUSupported:f,isEnabled:v,isInitializing:P,error:E,toggle:ye,setEnabled:q}}const Is=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Ds=/^[a-z0-9-]+$/i,gr=n=>n?"preferredProviderMature":"preferredProvider",br=n=>{const i=localStorage.getItem(gr(n));return i&&Ds.test(i)?i:null},pr=(n,i)=>{localStorage.setItem(gr(i),n)},$s=()=>br(!1)??"megaplay",Fs=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:Is(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:ln(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:$s(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Os(n,i){switch(i.type){case"SET_STATE":return{...n,...i.payload};case"SET_MODE":return{...n,currentMode:i.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...n,selectedProvider:i.payload};default:return n}}async function hr(n,i,h,B,f=!1){if(!n||!i)throw new Error("Missing params");try{const[S,v,L,P]=await Promise.all([Ee.data.video.query({showId:n,episodeNumber:i,mode:h.currentMode,provider:h.selectedProvider}).catch(x=>{const O=x.data?.cause;return x.message==="AUTH_REQUIRED"&&O?.provider==="mkissa"&&B({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:"mkissa"}}),null}),Ee.progress.getEpisode.query({showId:n,episodeNumber:i}).catch(()=>null),Ee.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),Ee.data.skipTimes.query({showId:n,episodeNumber:i}).catch(()=>[])]),F=L?.value,E=S?.filter(x=>{const O=x.sourceName.toLowerCase();return h.currentMode==="dub"?O.includes("eng")||O.includes("dub"):O.includes("jpn")||O.includes("sub")||!O.includes("eng")&&!O.includes("dub")})??[],e=E.length>0?E:S??[];let o=e.length>0?e[0]:null;if(F){const x=e.find(O=>O.sourceName===F);x&&(o=x)}const J=o&&o.links.length>0?o.links.sort((x,O)=>(parseInt(O.resolutionStr)||0)-(parseInt(x.resolutionStr)||0))[0]:null,g=v?.currentTime||0,A=v?.duration||0,V=(Array.isArray(P)?P:P?.results||[]).map(x=>({skip_id:x.skip_id||"",skip_type:x.skip_type||"",start_time:x.interval?.start_time??x.start_time??0,end_time:x.interval?.end_time??x.end_time??0})).filter(x=>x.end_time>0);return(!S||S.length===0)&&(f||Oe.error(`No video sources found for ${h.selectedProvider}`)),{videoSources:S,selectedSource:o,selectedLink:J,resumeTime:g,resumeDuration:A,showResumeModal:g>5&&o?.type!=="iframe",skipIntervals:V,fetchedEpisodeNumber:i}}catch(S){const v=S;if(v.message==="AUTH_REQUIRED")return B({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:v.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:i};throw S}}const Ws=(n,i,h,B)=>{const[f,S]=Or(Os,h,c=>({...Fs(),showMeta:c?.name?{name:c.name,thumbnail:c.thumbnail,nativeName:c.nativeName,englishName:c.englishName,names:{romaji:c.name||c.englishName,english:c.englishName||c.name,native:c.nativeName}}:{}})),v=fr(),L=Qr(),P=m(null),F=m(null),{options:E}=vr(),e=Je(()=>E.filter(c=>(c.kind??"anime")==="anime"),[E]),o=i||f.initialEpisode,J=m(o);D(()=>{J.current!==o&&(J.current=o,S({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[o,S]),D(()=>{n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)&&f.selectedProvider!=="animepahe"&&P.current!==n&&(P.current=n,S({type:"SET_PROVIDER",payload:"animepahe"}))},[n,f.selectedProvider]);const{data:g,isLoading:A,error:de}=xn(n),{data:V}=lr({queryKey:["player-data",n,f.currentMode,f.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const c=async()=>{try{const q=await Ee.data.episodes.query({showId:n,mode:f.currentMode,provider:f.selectedProvider}).catch(()=>null);if(q?.episodes?.length)return q}catch{}return null},[b,T,I]=await Promise.all([c(),Ee.watchlist.check.query({showId:n}).catch(()=>({inWatchlist:!1,status:null})),Ee.progress.getWatchedEpisodes.query({showId:n}).catch(()=>[])]),R=b?.episodes?b.episodes.sort((q,ye)=>parseFloat(q)-parseFloat(ye)):[];return{description:b?.description||"",episodes:R,inWatchlist:T.inWatchlist,watchlistStatus:T.status??null,watchedEpisodes:I}},enabled:!!n});D(()=>{!i&&V?.episodes&&V.episodes.length>0&&!i&&S({type:"SET_STATE",payload:{initialEpisode:V.episodes[0]}})},[V,i]),D(()=>{if(g?.isAdult===void 0||F.current===n)return;const c=g.isAdult===!0,b=e.filter(I=>I.mature===c);if(b.length===0||e.find(I=>I.value===f.selectedProvider)?.mature===c)return;const T=br(c);F.current=n,S({type:"SET_PROVIDER",payload:b.find(I=>I.value===T)?.value??b[0].value})},[g?.isAdult,f.selectedProvider,n,e]),D(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||F.current===`temp:${n}`)return;const c=g?.provider;c&&(F.current=`temp:${n}`,c!==f.selectedProvider&&S({type:"SET_PROVIDER",payload:c}))},[n,g,f.selectedProvider]);const{data:x,isLoading:O,error:Le}=lr({queryKey:["video-sources",n,o,f.selectedProvider,f.currentMode],queryFn:()=>hr(n,o,f,S),enabled:!!n&&!!o&&!(f.showMeta?.isAdult===!0&&!B?.hasMatureConsent)}),{mutateAsync:We}=jt({mutationFn:async({wasIn:c,showMeta:b})=>{if(!n)throw new Error("Missing showId");if(c)await Ee.watchlist.remove.mutate({id:n});else{const T=b.name||b.names?.romaji;if(!T)throw new Error("Missing show name");await Ee.watchlist.add.mutate({id:n,name:T,thumbnail:b.thumbnail,nativeName:b.names?.native,englishName:b.names?.english,type:b.type,isAdult:b.isAdult})}return!c},onSuccess:c=>{Oe.success(c?"Added to watchlist":"Removed from watchlist"),v.invalidateQueries({queryKey:["player-data",n]}),v.invalidateQueries({queryKey:["show-data",n]}),v.invalidateQueries({queryKey:["watchlist"]})},onError:c=>Oe.error(c instanceof Error?c.message:"Failed to update watchlist")}),a=K(async()=>{!n||!g||await We({wasIn:!!V?.inWatchlist,showMeta:g})},[n,g,V?.inWatchlist,We]),d=K(async c=>{try{await Ee.settings.set.mutate({key:"preferredSource",value:c})}catch(b){console.error(b)}},[]),{mutateAsync:k,isPending:ve}=jt({mutationFn:async({status:c})=>{if(!n)throw new Error("Missing showId");return await Ee.watchlist.setStatus.mutate({id:n,status:c}),c},onSuccess:c=>{S({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:c}}),Oe.success(`Moved to ${c}`),v.invalidateQueries({queryKey:["show-data",n]}),v.invalidateQueries({queryKey:["watchlist"]}),v.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>Oe.error("Failed to update watchlist status")}),Ie=K(async()=>{await k({status:"Completed"})},[k]),{mutateAsync:_e}=jt({mutationFn:async({episodeNumber:c,duration:b,showMeta:T,episodes:I})=>{await Ee.progress.updateProgress.mutate({showId:n,episodeNumber:c,currentTime:b,duration:b,showName:T.name,showThumbnail:T.thumbnail,nativeName:T.names?.native,englishName:T.names?.english,genres:T.genres?.map(R=>R.name),popularityScore:zr(T.score??T.stats?.averageScore),type:T.type,status:T.status,episodeCount:I.length,isAdult:T.isAdult})},onSuccess:(c,b)=>{Oe.success(`Episode ${b.episodeNumber} marked as watched`),v.invalidateQueries({queryKey:["player-data",n]}),v.invalidateQueries({queryKey:["show-meta",n]}),v.invalidateQueries({queryKey:["video-sources",n,b.episodeNumber]}),v.invalidateQueries({queryKey:["allContinueWatching"]}),v.invalidateQueries({queryKey:["thisWeekSchedule"]}),v.invalidateQueries(L.continueWatching.pathFilter())},onError:()=>Oe.error("Failed to mark episode as watched")}),Ne=K(async(c,b)=>{!n||!g||await _e({episodeNumber:c,duration:b,showMeta:g,episodes:V?.episodes||[]})},[n,g,V?.episodes,_e]),Ue=K(async()=>{S({type:"SET_STATE",payload:{showCombinedDetails:!f.showCombinedDetails}})},[f.showCombinedDetails]),ie=Je(()=>{const c=de||Le,b=c?c.message:null,T=b==="AUTH_REQUIRED"?null:b,I=x&&x.fetchedEpisodeNumber===o?x:null,R=!!x&&!I;return{...f,currentEpisode:o,showMeta:{...f.showMeta||{},...g||{}},episodes:V?.episodes||[],watchedEpisodes:V?.watchedEpisodes||[],inWatchlist:!!V?.inWatchlist,watchlistStatus:V?.watchlistStatus??f.watchlistStatus??null,videoSources:I?.videoSources||[],selectedSource:f.selectedSource||I?.selectedSource||null,selectedLink:f.selectedLink||I?.selectedLink||null,resumeTime:I?.resumeTime||0,resumeDuration:I?.resumeDuration||0,showResumeModal:f.showResumeModal&&(I?.showResumeModal??!1),skipIntervals:I?.skipIntervals||[],loadingShowData:A,loadingVideo:O||R,error:T,fetchedEpisodeNumber:I?.fetchedEpisodeNumber}},[f,g,V,x,A,O,de,Le,o]),we=K((c,b)=>{const T=b||n;if(!T||!c||T===n&&c===o)return;const R=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(T)&&f.selectedProvider!=="animepahe"?"animepahe":f.selectedProvider,q=["video-sources",T,c,R,f.currentMode];v.getQueryState(q)?.status!=="success"&&v.prefetchQuery({queryKey:q,queryFn:()=>hr(T,c,{selectedProvider:R,currentMode:f.currentMode},S,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,o,v,f,S]);return{state:ie,dispatch:S,toggleWatchlist:a,moveToCompleted:Ie,setPreferredSource:d,handleToggleDetails:Ue,markEpisodeWatched:Ne,prefetchEpisodeSources:we,isMarkingWatched:_e.isPending,isUpdatingWatchlistStatus:ve}},Us=({isOpen:n,onClose:i,onSuccess:h})=>{const B=()=>{h?.(),i()};return r(Be,{isOpen:n,onClose:i,title:"MKissa Browser Verification",children:r("div",{className:bt.container,children:[r("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."}),r("div",{className:bt.actions,children:r("a",{className:bt.link,href:"https://mkissa.to/anime",target:"_blank",rel:"noreferrer",children:"Open MKissa anime"})}),r("div",{className:bt.actions,children:[r("button",{className:bt.secondaryButton,onClick:i,children:"Cancel"}),r("button",{className:bt.button,onClick:B,children:"Refresh Dango"})]})]})})},Xt="fallbackChoice";function Vs(){try{const n=localStorage.getItem(Xt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function qs(n){try{n===null?localStorage.removeItem(Xt):localStorage.setItem(Xt,n)}catch{}}const ao=()=>{const{id:n,episodeNumber:i}=Wr(),h=Ur(),B=fr(),f=Vr(),{hasConsent:S,grant:v}=Gr(),{options:L}=vr(),P=Je(()=>L.filter(t=>(t.kind??"anime")==="anime"),[L]),F=Je(()=>P.map(t=>t.value),[P]),E=Je(()=>new Set(P.filter(t=>t.mature).map(t=>t.value)),[P]),{state:e,dispatch:o,toggleWatchlist:J,moveToCompleted:g,setPreferredSource:A,handleToggleDetails:de,markEpisodeWatched:V,prefetchEpisodeSources:x,isMarkingWatched:O,isUpdatingWatchlistStatus:Le}=Ws(n,i,f.state||null,{hasMatureConsent:S});D(()=>{if(n&&e.showMeta?.id&&e.showMeta.id!==n){const t=i?`/watch/${e.showMeta.id}/${i}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;h(t,{replace:!0})}},[n,e.showMeta?.id,i,h]);const We=Je(()=>{if(e.showMeta.name)return{name:e.showMeta.name,thumbnail:e.showMeta.thumbnail,names:e.showMeta.names,genres:e.showMeta.genres,score:e.showMeta.score,isAdult:e.showMeta.isAdult}},[e.showMeta.name,e.showMeta.thumbnail,e.showMeta.names,e.showMeta.genres,e.showMeta.score,e.showMeta.isAdult]),a=cn({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:We}),{refs:d,actions:k}=a,ve=m(null),Ie=Pn(),_e=m(null),Ne=m(null),Ue=m(null),ie=m(0),we=m(e.resumeTime),c=m(e.showResumeModal),[b,T]=ue(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),{videoDelayMs:I,videoDelayEnabled:R,setDelayEnabled:q,handleVideoDelayChange:ye,isCalibrating:Y,testClipActive:G,stopCalibration:ke,openAvSyncCalibrator:De,cancelAvSyncCalibrator:yt,applyAvSyncCalibrator:Ze,toggleTestClip:St,calibReturnRef:H,effectiveVideoDelayMs:Pe}=un(d.videoRef,()=>k.setShowSettings(!1)),lt=m(null),_=Ls({videoRef:d.videoRef,canvasRef:Ne,profile:b,delayMs:Pe}),$=_.isEnabled&&_.isWebGPUSupported,W=`${n??""}:${e.currentEpisode??""}`,Te=m(null),Ve=m(!1),Ge=m(!1),ct=m(_.setEnabled);ct.current=_.setEnabled,D(()=>{const t=Te.current;Te.current=W,!(t===null||t===W)&&(!_.isEnabled||!_.isWebGPUSupported||(Ve.current=!0,Ge.current=!1,ct.current(!1)))},[W,_.isEnabled,_.isWebGPUSupported]),D(()=>{if(!Ve.current)return;if(_.isEnabled){Ge.current&&(Ve.current=!1);return}if(Ge.current=!0,e.loadingVideo||!e.selectedLink)return;if(e.selectedSource?.type==="iframe"){Ve.current=!1,ct.current(!0);return}const t=d.videoRef.current;if(!t)return;let s,l=!1;const u=()=>{l||(l=!0,Ve.current=!1,ct.current(!0))};if(t.readyState>=2)return s=window.setTimeout(u,500),()=>window.clearTimeout(s);const N=()=>{window.setTimeout(u,500)};return t.addEventListener("canplay",N,{once:!0}),t.addEventListener("playing",N,{once:!0}),s=window.setTimeout(u,5e3),()=>{window.clearTimeout(s),t.removeEventListener("canplay",N),t.removeEventListener("playing",N)}},[_.isEnabled,e.loadingVideo,e.selectedLink,e.selectedSource?.type,d.videoRef]),dn({videoRef:d.videoRef,canvasRef:lt,delayMs:Pe,enabled:R&&!$});const ut=R&&!$,dt=$||ut;D(()=>{we.current=e.resumeTime,c.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[pt,le]=ue(!1),[Ke,He]=ue(!1),[_t,Et]=ue(!1),je=m(!1),[M,$e]=ue(null),Fe=m(!1),ee=m([]),Ye=m(!1),[et,ge]=ue(null),[ht,mt]=ue(!1),[qe,wt]=ue(!1),[tt,Nt]=ue(()=>Vs()??"ask"),rt=K(t=>{Nt(t),qs(t==="ask"?null:t)},[]),Pt=m(tt);Pt.current=tt;const At=m(e.videoSources);At.current=e.videoSources;const U=m(()=>{}),[Q,be]=ue(null),pe=m(i);D(()=>{pe.current!==i&&(pe.current=i,be(null),$e(null),je.current=!1,ke())},[i,ke]),D(()=>{Fe.current=!1,ee.current=[],Ye.current=!1,ge(null),mt(!1)},[n,e.currentEpisode]),D(()=>{Ke||(je.current=!1)},[Ke]);const{data:y=[],isLoading:Ce}=Kr(),he=Hr(),nt=m(he);nt.current=he;const ft=jr(),Ae=Yr(),{isTheaterMode:z,toggleTheaterMode:kt,handleLayoutClick:Tt}=pn();qr(()=>{if(a.state.isFullscreen||z)return;const t=d.playerContainerRef.current,s=_e.current;if(!t||!s)return;const l=()=>{const N=t.getBoundingClientRect().height;s.style.height=`${N}px`};l();const u=new ResizeObserver(l);return u.observe(t),()=>u.disconnect()},[a.state.isFullscreen,z,d.playerContainerRef]);const te=Je(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),vt=te>0?e.episodes[te-1]:null,Re=te>=0&&te<e.episodes.length-1?e.episodes[te+1]:null,Ut=te>-1&&te<e.episodes.length-1,Vt=hn(e.resumeTime,e.resumeDuration)||Ke,Xe=Vt&&cr(e.episodes,e.currentEpisode,e.showMeta.status),qt=e.showResumeModal&&(Xe||!Vt),xt=Vt&&!Xe&&y.length===0&&!Q&&(e.showResumeModal||Ke),st=qt||xt;mn(a,!!e.selectedLink&&!z&&!st),D(()=>{const t=d.videoRef.current;if(!t)return;let s=!1;for(ve.current&&(ve.current.destroy(),ve.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(G)return t.src="/av-sync-test.mp4",t.play().catch(()=>{k.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){ie.current=0;return}H.current!=null?(ie.current=H.current,H.current=null):we.current>5&&!c.current?ie.current=we.current:c.current&&(ie.current=0);let l=e.selectedLink.link;if(l.startsWith("/api/proxy")||(l=`/api/proxy?url=${encodeURIComponent(l)}`,e.selectedLink.headers?.Referer&&(l+=`&referer=${encodeURIComponent(e.selectedLink.headers.Referer)}`)),e.selectedSource.subtitles){const ce=localStorage.getItem("playerSubtitlesEnabled")!=="false";let Se=null;try{Se=localStorage.getItem("playerLastSubtitle")}catch{}const re=Yt(e.selectedSource.subtitles,{lastKey:Se,enabled:ce}),Me=re>=0?e.selectedSource.subtitles[re]:null;e.selectedSource.subtitles.forEach(fe=>{const ne=document.createElement("track");ne.kind="subtitles",ne.label=fe.label,ne.srclang=fe.lang;const w=fe.src??fe.url;if(w){let se=`/api/subtitle-proxy?url=${encodeURIComponent(w)}`;const oe=e.selectedLink?.headers?.Referer;oe&&(se+=`&referer=${encodeURIComponent(oe)}`),ne.src=se}Me&&fe.label===Me.label&&fe.lang===Me.lang&&(ne.default=!0),t.appendChild(ne)}),ce||k.setActiveSubtitleTrack("off"),k.setAvailableSubtitles(e.selectedSource.subtitles)}const u=ie.current;ie.current=0;const N=()=>{u>0&&(t.currentTime=u)};t.addEventListener("loadedmetadata",N,{once:!0});const me=!(c.current&&we.current>5),X=()=>{me&&t.play().catch(()=>{k.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const ce=await Nn();if(s)return;if(!ce||!ce.isSupported()){t.src=l,X();return}const Se=document.body.classList.contains("low-end"),re=new ce({maxBufferLength:Se?15:30,maxMaxBufferLength:Se?30:60,maxBufferSize:Se?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});ve.current=re,re.on(ce.Events.ERROR,(ne,w)=>{w.fatal&&!Fe.current&&U.current()});const Me=(e.selectedSource?.subtitles?.length??0)>0,fe=()=>{try{Me&&typeof re.subtitleTrack=="number"&&re.subtitleTrack!==-1&&(re.subtitleTrack=-1)}catch{}};re.on(ce.Events.SUBTITLE_TRACK_SWITCH,(ne,w)=>{w?.id!==-1&&fe()}),fe(),re.loadSource(l),re.attachMedia(t),re.once(ce.Events.MANIFEST_PARSED,()=>{s||X()})})():(t.src=l,X());const j=localStorage.getItem("playerVolume"),ae=localStorage.getItem("playerMuted");return j!==null&&(t.volume=parseFloat(j)),ae!==null&&(t.muted=ae==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",N),ve.current&&(ve.current.destroy(),ve.current=null)}},[e.selectedSource,e.selectedLink,d.videoRef,H,k,e.loadingVideo,G]);const Bt=K(t=>{if(Fe.current)return;Fe.current=!0;const s=t.links[0];A(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),ge(null)},[o,A]),Lt=K(()=>{const s=At.current.find(l=>l.type==="iframe");return s?.links?.length?s:null},[]),It=K(async()=>{const t=e.showMeta?.isAdult,s=F.filter(l=>{if(ee.current.includes(l))return!1;const u=E.has(l);return t===void 0?!0:u===t});mt(!0);try{for(const l of s){ee.current.push(l);let u=null;try{u=await Ee.data.video.query({showId:n,episodeNumber:e.currentEpisode,mode:e.currentMode,provider:l})}catch{continue}const N=(u??[]).filter(j=>{const ae=j.sourceName.toLowerCase();return e.currentMode==="dub"?ae.includes("eng")||ae.includes("dub"):ae.includes("jpn")||ae.includes("sub")||!ae.includes("eng")&&!ae.includes("dub")});if((N.length>0?N:u??[]).find(j=>j.type!=="iframe"&&j.links?.length)){ee.current=[e.selectedProvider],Ye.current=!1,o({type:"SET_STATE",payload:{selectedProvider:l,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),pr(l,e.showMeta?.isAdult===!0),ge(null),Oe.success(`Switched to ${l} (direct stream)`);return}}ge({retryFailed:!0}),Oe.error("No working direct stream found on other providers")}finally{mt(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,o,F,E]),Jt=K(()=>{if(Fe.current||Ye.current||e.selectedSource?.type!=="player")return;const t=Lt();if(!t)return;ee.current.includes(e.selectedProvider)||ee.current.push(e.selectedProvider);const s=Pt.current;if(s==="iframe"){Bt(t);return}if(s==="retry"){It();return}k.setShowControls(!0),ge({retryFailed:!1})},[e.selectedSource,e.selectedProvider,Lt,Bt,It,k]);U.current=Jt;const yr=K(()=>{Ye.current=!0,ge(null),wt(!1)},[]),Sr=K(()=>{qe&&rt("iframe");const t=Lt();t?Bt(t):ge(null)},[qe,rt,Lt,Bt]),Er=K(()=>{qe&&rt("retry"),It()},[qe,rt,It]),Ct=(t,s,l)=>t.showId===s||!!l&&t.showId===l,Dt=K(()=>{k.onEnded();const t=y.find(l=>Ct(l,n,e.showMeta?.id)&&l.episodeNumber===e.currentEpisode);if(y.length>0){const l=y.findIndex(N=>Ct(N,n,e.showMeta?.id)&&N.episodeNumber===e.currentEpisode),u=l>=0?y[l+1]||null:y[0];be({nextItem:u,playedItem:t||null}),$e(2)}else t&&nt.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&y.length===0){const l=e.episodes.findIndex(u=>u===e.currentEpisode);if(l>-1&&l<e.episodes.length-1){const u=e.episodes[l+1];B.invalidateQueries({queryKey:["allContinueWatching"]}),h(`/watch/${n}/${u}`),s=!0}}!s&&y.length===0&&!Q&&!je.current&&cr(e.episodes,e.currentEpisode,e.showMeta.status)&&o({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,h,y,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,Q,o,B]),Qt=K(()=>{if(y.length===0)return;k.onEnded();const t=y.find(u=>Ct(u,n,e.showMeta?.id)&&u.episodeNumber===e.currentEpisode),s=y.findIndex(u=>Ct(u,n,e.showMeta?.id)&&u.episodeNumber===e.currentEpisode),l=s>=0?y[s+1]||null:y[0];t&&he.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),l?h(`/watch/${l.showId}/${l.episodeNumber}`):t&&o({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,h,y,he,n,e.showMeta?.id,e.currentEpisode,o]),Rt=K(()=>{Re&&(B.invalidateQueries({queryKey:["allContinueWatching"]}),He(!1),h(`/watch/${n}/${Re}`)),o({type:"SET_STATE",payload:{showResumeModal:!1}})},[Re,h,n,o,B]),Zt=K(()=>{y.length>0?Qt():Re?Rt():Oe.error("No next episode available")},[y.length,Qt,Rt,Re]),wr=()=>{vt&&h(`/watch/${n}/${vt}`)};D(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>{G||Dt()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[Dt,d.videoRef,G]),D(()=>{const t=s=>{s.origin===window.location.origin&&e.selectedSource?.type==="iframe"&&s.data?.type==="ANI_WEB_MEDIA_ENDED"&&Dt()};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[Dt,e.selectedSource?.type]),D(()=>{if(!Q||M===null)return;if(M<=0){const{nextItem:s,playedItem:l}=Q;be(null),$e(null),l&&nt.current.mutate({showId:l.showId,episodeNumber:l.episodeNumber}),s?h(`/watch/${s.showId}/${s.episodeNumber}`):l&&o({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{$e(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[Q,M,h,o]),D(()=>{st&&a.state.isFullscreen&&a.actions.toggleFullscreen()},[st,a.state.isFullscreen,a.actions]),D(()=>{st&&d.videoRef.current&&d.videoRef.current.pause()},[st,d.videoRef]);const{titlePreference:$t}=Xr(),{lowEndMode:er}=Jr(),{settings:zt,update:kr}=fn(),Tr=z&&zt.enabled&&!er&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,ot=Je(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:t,names:s}=e.showMeta;return $t==="name"?t||"Loading...":$t==="nativeName"?s?.native||t||"Loading...":$t==="englishName"?s?.english||t||"Loading...":t||"Loading..."},[e.showMeta,$t,e.loadingShowData]);D(()=>{ot&&ot!=="Loading..."&&e.currentEpisode&&(document.title=`► ${ot} Episode ${e.currentEpisode} - dango`)},[ot,e.currentEpisode]),D(()=>{const t=s=>{s.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(s.key.toLowerCase())&&(k.setShowControls(!0),a.actions.inactivityTimer.current&&clearTimeout(a.actions.inactivityTimer.current),a.actions.inactivityTimer.current=window.setTimeout(()=>{k.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&Zt(),s.key.toLowerCase()==="t"&&kt())};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[k,a.actions.inactivityTimer,Zt,kt]);const{setAvailableSubtitles:tr,setActiveSubtitleTrack:Gt}=k;D(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>{const l=Array.from(t.textTracks).map(u=>({label:u.label,lang:u.language,src:void 0,mode:u.mode}));tr(l)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[d.videoRef,tr]),D(()=>{if(a.state.activeSubtitleTrack===null&&a.state.availableSubtitles.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let t=null;try{t=localStorage.getItem("playerLastSubtitle")}catch{}const s=Yt(a.state.availableSubtitles,{lastKey:t,enabled:!0});if(s<0){Gt("off");return}const l=a.state.availableSubtitles[s];Gt(l.lang||l.label)}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,Gt]),D(()=>{const t=d.videoRef.current;if(!t||a.state.availableSubtitles.length===0)return;const s=a.state.activeSubtitleTrack;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(t.textTracks).forEach(N=>{N.mode="hidden"});return}let u=!1;if(Array.from(t.textTracks).forEach(N=>{const X=(N.language===s||N.label===s)&&!u;N.mode=X?"showing":"hidden",X&&(u=!0)}),!u&&t.textTracks.length>0){const N=Array.from(t.textTracks).find(me=>me.language==="en"||me.label==="English")||t.textTracks[0];N&&(N.mode="showing")}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,d.videoRef]);const[rr,Cr]=ue(0);D(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>Cr(t.clientHeight||0);s();const l=new ResizeObserver(s);return l.observe(t),()=>l.disconnect()},[d.videoRef,e.selectedSource,e.selectedLink]),D(()=>{const t="dynamic-subtitle-styles";let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,document.head.appendChild(s));const l={fontSize:a.state.subtitleFontSize,position:a.state.subtitlePosition,bgOpacity:a.state.subtitleBgOpacity,bgColor:a.state.subtitleBgColor,textColor:a.state.subtitleTextColor,edge:a.state.subtitleEdge,bold:a.state.subtitleBold};s.textContent=ur(l);const u=d.videoRef.current;if(!u)return;const N=dr(a.state.subtitleFontSize,rr||u.clientHeight||720);s.textContent=ur({...l,fontSize:N});const me=()=>{const w=Number(a.state.subtitlePosition),se=isNaN(w)?0:Math.max(0,Math.min(100,w));return Math.max(0,Math.min(100,100-se))},X=(w,se)=>{try{const oe=w;oe.snapToLines=!1,oe.line=se}catch{}},j=()=>{const w=N*16,se=u.videoHeight||u.clientHeight||720,oe=u.videoWidth||u.clientWidth||1280;return{step:w*1.3/se*100,chars:Math.max(20,Math.floor(oe/(w*.55)))}},ae=w=>{const se=me(),oe=Array.from(w.activeCues??[]);if(oe.length<=1){oe.forEach(gt=>X(gt,se));return}const{step:Ft,chars:Br}=j();let ir=se;for(let gt=oe.length-1;gt>=0;gt--){const Lr=String(oe[gt].text??"").replace(/<[^>]*>/g,"").split(`
|
|
55
|
+
`).reduce((Ir,Dr)=>Ir+Math.max(1,Math.ceil(Dr.length/Br)),0),ar=ir-Lr*Ft;X(oe[gt],Math.max(0,ar)),ir=ar-Ft*.4}},ce=w=>{if(!w.cues)return;const se=me();Array.from(w.cues).forEach(oe=>X(oe,se)),w.mode==="showing"&&ae(w)},Se=()=>{Array.from(u.textTracks).forEach(ce)};Se();const re=w=>{const se=w.target;se.mode==="showing"&&ae(se)};Array.from(u.textTracks).forEach(w=>{w.addEventListener("cuechange",re)});const Me=()=>{Array.from(u.textTracks).forEach(w=>{w.removeEventListener("cuechange",re),w.addEventListener("cuechange",re)}),Se()};u.textTracks.addEventListener("addtrack",Me),u.textTracks.addEventListener("removetrack",Me);const fe=Array.from(u.querySelectorAll("track")),ne=()=>{Se()};return fe.forEach(w=>{w.addEventListener("load",ne)}),()=>{Array.from(u.textTracks).forEach(w=>{w.removeEventListener("cuechange",re)}),u.textTracks.removeEventListener("addtrack",Me),u.textTracks.removeEventListener("removetrack",Me),fe.forEach(w=>{w.removeEventListener("load",ne)})}},[a.state.subtitleFontSize,a.state.subtitlePosition,a.state.subtitleBgOpacity,a.state.subtitleBgColor,a.state.subtitleTextColor,a.state.subtitleEdge,a.state.subtitleBold,a.state.activeSubtitleTrack,a.state.availableSubtitles,e.selectedSource,e.selectedLink,d.videoRef,rr]),D(()=>{if(!dt)return;const t=d.videoRef.current,s=Ue.current;if(!t||!s)return;const l=localStorage.getItem("playerSubtitlesEnabled")!=="false",u=a.state.activeSubtitleTrack;function N(){if(s.innerHTML="",!l||u==="off"||u===null)return;const j=Array.from(t.textTracks).find(ne=>ne.language===u||ne.label===u);if(!j||j.mode!=="showing")return;const ae=Pe/1e3;let ce;if(ae>0&&j.cues){const ne=t.currentTime-ae;ce=Array.from(j.cues).filter(w=>w.startTime<=ne&&ne<=w.endTime)}else ce=Array.from(j.activeCues??[]);if(ce.length===0)return;const Se={fontSize:dr(a.state.subtitleFontSize,t.clientHeight||0),position:a.state.subtitlePosition,bgOpacity:a.state.subtitleBgOpacity,bgColor:a.state.subtitleBgColor,textColor:a.state.subtitleTextColor,edge:a.state.subtitleEdge,bold:a.state.subtitleBold},re=vn(Se),Me=gn(t,Se.position),fe=Array.from(ce);fe.forEach((ne,w)=>{const se=String(ne.text??"");if(!bn(se).trim())return;const oe=document.createElement("div"),Ft=(fe.length-1-w)*1.7;oe.style.cssText=`${re}
|
|
56
|
+
bottom: calc(${Me}px + ${Ft}em);`,oe.innerHTML=yn(se),s.appendChild(oe)})}const me=()=>N(),X=()=>N();return Array.from(t.textTracks).forEach(j=>{j.addEventListener("cuechange",me)}),t.addEventListener("timeupdate",X),N(),()=>{Array.from(t.textTracks).forEach(j=>{j.removeEventListener("cuechange",me)}),t.removeEventListener("timeupdate",X),s.innerHTML=""}},[_.isEnabled,_.isWebGPUSupported,a.state.subtitleFontSize,a.state.subtitlePosition,a.state.subtitleBgOpacity,a.state.subtitleBgColor,a.state.subtitleTextColor,a.state.subtitleEdge,a.state.subtitleBold,a.state.activeSubtitleTrack,d.videoRef,dt,Pe]),D(()=>{try{localStorage.setItem("anime4kProfile",b)}catch{}},[b]);const Rr=()=>{d.videoRef.current&&(d.videoRef.current.currentTime=e.resumeTime,d.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},Mr=()=>{d.videoRef.current&&(d.videoRef.current.currentTime=0,d.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},Kt=K(()=>{Xe&&(je.current=!0),xt&&He(!1),o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o,Xe,xt]),_r=K(()=>{if(He(!1),d.videoRef.current)try{d.videoRef.current.currentTime=0,d.videoRef.current.play().catch(()=>{})}catch{}o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o,d]),Nr=K(async()=>{try{await g(),o({type:"SET_STATE",payload:{showResumeModal:!1}}),h("/")}catch{}},[g,o,h]),nr=(t,s)=>r("div",{className:t,children:[r("button",{className:`${p.episodeNavBtn} ${p.secondary}`,onClick:wr,disabled:!vt,type:"button",children:[r(Z,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${p.episodeNavBtn} ${p.primary}`,onClick:Rt,disabled:!Re,type:"button",children:["Next EP",r(Z,{name:"chevron-right",size:12})]}),s==="mobile"&&Ie&&r("button",{className:`${p.episodeNavBtn} ${p.episodePickerBtn}`,onClick:()=>Et(!0),type:"button",children:[r(Z,{name:"list-ul",size:12}),"Episodes"]})]});D(()=>{Ke&&(e.showResumeModal||y.length>0||Q||je.current||Xe&&o({type:"SET_STATE",payload:{showResumeModal:!0}}))},[Ke,Xe,e.showResumeModal,y.length,Q,o]);const Pr=t=>{o({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),_n(t)},sr=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),Ar=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",Ht=m(x);Ht.current=x;const or=m("");D(()=>{const t=d.videoRef.current;if(le(!1),He(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const l=t.duration,u=t.currentTime;if(!l||Number.isNaN(l)){le(!1),He(!1);return}const N=u/l;if(l-u<=60){const me=y.findIndex(ae=>Ct(ae,n,e.showMeta?.id)&&ae.episodeNumber===e.currentEpisode),X=y.length>0?me>=0?y[me+1]||null:y[0]:null,j=X?`${X.showId}:${X.episodeNumber}`:Ut?`${n}:${Re}`:"";j&&or.current!==j&&(or.current=j,X?Ht.current(X.episodeNumber,X.showId):Ht.current(Re))}le(Ut&&N>=.8),He(u>=Math.max(l*.98,l-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[d.videoRef,Ut,e.currentEpisode,e.selectedSource,Re,n,y,e.showMeta?.id]);const xr=K(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||O)return;const t=d.videoRef.current?.duration,s=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await V(e.currentEpisode,s)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,V,O,d.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return r("p",{className:"error-message",children:["Error: ",e.error]});const Qe=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!S?r("div",{className:xe.playerPageLayout,children:r(Be,{isOpen:!0,title:"Content Warning",onClose:()=>h("/home"),children:r("div",{style:{padding:"1rem",textAlign:"center"},children:[r("p",{children:"This title contains mature content intended for adult audiences."}),r("p",{children:["By proceeding, you confirm that you are ",r("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),r("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[r(it,{variant:"secondary",onClick:()=>h("/home"),children:"Go Back"}),r(it,{onClick:v,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${xe.playerPageLayout} ${z?xe.theaterMode:""}`,onClick:Tt,children:[z&&r(Sn,{videoRef:d.videoRef,active:Tr,settings:zt}),r(Be,{isOpen:qt&&Xe,onClose:Kt,title:"Show Completed!",width:"sm",children:[r(Be.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r(Be.Actions,{children:r(it,{onClick:Nr,disabled:Le,children:Le?"Saving...":"Move to Completed"})})]}),r(En,{isOpen:qt&&!Xe,onClose:Kt,title:"Resume Playback?",message:r(Ot,{children:["You were watching at ",r("strong",{children:a.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:Rr,onRestart:Mr}),r(Be,{isOpen:xt,onClose:Kt,title:"Episode Completed",width:"sm",children:[r(Be.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",Re?" Would you like to watch the next episode?":""]})}),r(Be.Actions,{children:[r(it,{variant:"secondary",onClick:_r,children:"Replay"}),Re&&r(it,{onClick:Rt,children:`Watch EP ${Re}`})]})]}),r(Be,{isOpen:!!et,onClose:yr,title:"Direct stream failed",width:"sm",children:[r(Be.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),et?.retryFailed&&r("p",{children:"No working direct stream was found on the other providers either."}),r("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",r("strong",{children:"ads and pop-ups"}),"."]}),r("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[r("input",{type:"checkbox",checked:qe,onChange:t=>wt(t.target.checked)}),"Remember my choice"]})]}),r(Be.Actions,{children:[r(it,{variant:"secondary",onClick:Sr,children:"Continue with iframe"}),r(it,{onClick:Er,disabled:ht,children:ht?"Searching…":"Try another provider"})]})]}),r(Zr,{isOpen:!!e.showCookieModal&&e.cookieProvider!=="mkissa",onClose:()=>o({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{B.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),r(Us,{isOpen:!!e.showCookieModal&&e.cookieProvider==="mkissa",onClose:()=>o({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{B.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!z&&r("aside",{ref:_e,className:xe.episodeSidebar,children:e.loadingShowData?r(wn,{variant:"sidebar"}):r(kn,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>h(`/watch/${n}/${t}`)})}),r("div",{className:xe.playerMain,children:[r("div",{className:`${p.videoContainer} ${a.state.isFullscreen?"":xe.videoPlayerWrapper} ${a.state.isFullscreen?p.fullscreenActive:""}`,style:{...st?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(Ts,{player:a,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Pr,fallbackChoice:tt,onFallbackChoiceChange:rt,ambientSettings:zt,onAmbientChange:kr,showNextEpisodeButton:!st&&pt&&y.length===0,onNextEpisode:Rt,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{d.videoRef.current&&!isNaN(d.videoRef.current.currentTime)&&(ie.current=d.videoRef.current.currentTime),A(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:Qe,skipIntervals:e.skipIntervals,animeTitle:ot,episodeNumber:e.currentEpisode,isTheaterMode:z,onTheaterModeToggle:kt,anime4kEnabled:_.isEnabled,onAnime4kToggle:_.toggle,anime4kSupported:_.isWebGPUSupported,anime4kProfile:b,onAnime4kProfileChange:T,anime4kInitializing:_.isInitializing,anime4kError:_.error,videoDelayEnabled:R,onVideoDelayToggle:q,videoDelayMs:I,onVideoDelayChange:ye,onCalibrateAvSync:De,isInteractingExtra:_t||Y,className:Tn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(Ot,{children:[a.state.isSpeedBoostActive&&r("div",{className:p.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(Z,{name:"forward",size:12})]}),M!==null&&Q?.nextItem&&r("div",{className:p.queueCountdown,children:["Queue next in ",M,"s"]})]}),children:[Qe&&r("div",{className:p.loadingOverlay,children:r("div",{className:p.loadingDots,children:[r("div",{className:p.dot}),r("div",{className:p.dot}),r("div",{className:p.dot})]})}),a.state.isBuffering&&!Qe&&e.selectedSource?.type!=="iframe"&&r("div",{className:p.bufferingOverlay,children:r("div",{className:p.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!Qe&&r("iframe",{src:e.selectedLink?.link,className:p.videoIframe,allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,sandbox:e.selectedSource.sandbox?`${e.selectedSource.sandbox} allow-fullscreen allow-popups allow-popups-to-escape-sandbox`:void 0}):r(Ot,{children:[!Qe&&e.videoSources.length===0&&r("div",{className:p.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:p.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:p.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Qe&&e.videoSources.length>0&&r("video",{ref:d.videoRef,controls:a.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:k.onPlay,onPause:k.onPause,onLoadedMetadata:k.onLoadedMetadata,onTimeUpdate:()=>{G||(k.onTimeUpdate(),Q&&d.videoRef.current&&d.videoRef.current.currentTime<d.videoRef.current.duration-1&&(be(null),$e(null)))},onProgress:k.onProgress,onVolumeChange:k.onVolumeChange,onWaiting:k.onWaiting,onPlaying:k.onPlaying,onCanPlay:k.onCanPlay,onError:Jt,onContextMenu:t=>t.preventDefault(),className:dt?p.videoElementHidden:""}),_.isWebGPUSupported&&!Qe&&e.videoSources.length>0&&r("canvas",{ref:Ne,className:`${p.upscalerCanvas} ${$?p.upscalerActive:""}`}),!$&&!Qe&&e.videoSources.length>0&&r("canvas",{ref:lt,className:`${p.upscalerCanvas} ${ut?p.upscalerActive:""}`}),_.isEnabled&&_.isWebGPUSupported&&_.isInitializing&&r("div",{className:p.upscalerStatusBadge,children:"Preparing upscaler…"}),dt&&r("div",{ref:Ue,className:p.subtitleOverlay}),r(Cn,{isOpen:Y,ms:I,onChange:ye,onApply:Ze,onClose:yt,testClipActive:G,onTestClip:St})]})]})}),!z&&r(Rn,{}),!z&&r(Ot,{children:[Ce&&y.length===0?r(Cs,{count:3}):r(An,{title:"Queue",items:y,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:Qt,onRemove:t=>he.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>ft.mutate(),showClearAll:!0,onReorder:t=>Ae.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:p.streamPanel,children:[r(Rs,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:P,onProviderChange:t=>{Fe.current=!1,ee.current=[],Ye.current=!1,ge(null),o({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),pr(t,e.showMeta?.isAdult===!0)}}),nr(`${p.episodeActions} ${p.desktopEpisodeActions}`,"desktop"),Qe?r("div",{className:p.sourceLoader,children:r("div",{className:p.spinner})}):r(_s,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{d.videoRef.current&&!isNaN(d.videoRef.current.currentTime)&&(ie.current=d.videoRef.current.currentTime);const l=(t.links||[]).sort((u,N)=>(parseInt(N.resolutionStr)||0)-(parseInt(u.resolutionStr)||0))[0]||null;A(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:l,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(A(e.selectedSource.sourceName),o({type:"SET_STATE",payload:{selectedLink:t}}))}})]}),r("div",{className:xe.playerInfoContainer,children:[r("div",{className:xe.playerInfoHeader,children:[r("div",{className:xe.playerAnimeCard,children:r("img",{src:en(e.showMeta.thumbnail||""),alt:ot,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:xe.videoTitleSection,children:[r("div",{className:p.titleContainer,children:[r("h1",{children:ot}),r("div",{className:p.scheduleInfo,children:[e.showMeta.status&&r("span",{className:p.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:p.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:p.controls,children:[r("button",{className:`${p.watchlistBtn} ${e.inWatchlist?p.inList:""}`,onClick:J,children:[e.inWatchlist?r(Z,{name:"check",size:14}):r(Z,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(Bn,{showId:n,showName:e.showMeta.name||e.showMeta.names?.romaji,showThumbnail:e.showMeta.thumbnail,nativeName:e.showMeta.names?.native,englishName:e.showMeta.names?.english,showType:e.showMeta.type,className:`${p.watchlistBtn} ${p.queueBtn}`,activeClassName:p.queueActive}),Ar&&r("button",{className:`${p.watchlistBtn} ${p.markWatchedBtn} ${sr?p.markWatchedDone:""}`,onClick:xr,disabled:O||!e.currentEpisode,children:[r(Z,{name:"check",size:14}),O?"Saving...":sr?"Watched":"Mark Watched"]}),r("button",{className:`${p.watchlistBtn} ${p.modeToggleBtn} ${e.currentMode==="dub"?p.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";Fe.current=!1,ee.current=[],Ye.current=!1,ge(null),o({type:"SET_MODE",payload:t}),localStorage.setItem("preferredMode",t)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),er&&r("button",{className:`${p.watchlistBtn} ${p.modeToggleBtn} ${a.state.useNativeControls?p.modeToggleActive:""}`,onClick:()=>{const t=!a.state.useNativeControls;a.actions.setUseNativeControls(t),localStorage.setItem("playerUseNativeControls",t.toString())},type:"button",children:a.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),nr(`${p.episodeActions} ${p.mobileEpisodeActions}`,"mobile"),r("div",{className:xe.infoColumns,children:[r("div",{className:`${p.descriptionSection} ${p.synopsisFlat}`,children:[r("h3",{children:"Synopsis"}),r(In,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."}),r("button",{className:p.detailsToggleBtn,onClick:de,children:[e.showCombinedDetails?r(Z,{name:"chevron-up"}):r(Z,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]})]}),e.showCombinedDetails&&r(Ln,{showMeta:e.showMeta,styles:p})]})]})]})]}),r(Mn,{isOpen:_t,onClose:()=>Et(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{Et(!1),h(`/watch/${n}/${t}`)}})]})};export{ao as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as w,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as ae,O as A,a as se,A as le,b as ie}from"./OptionListMenu-
|
|
1
|
+
import{g as w,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as ae,O as A,a as se,A as le,b as ie}from"./OptionListMenu-B3D39dGS.js";import{u as re}from"./index-CnfZwsds.js";import"./AvSyncCalibrator-CQ2fjf2E.js";import"./vendor-query-BBT5_sHx.js";const ce="_settingsPanel_1dymm_1",oe="_header_1dymm_33",me="_backBtn_1dymm_56",de="_contentWrapper_1dymm_76",ue="_menuContent_1dymm_82",he="_menuItem_1dymm_89",pe="_selected_1dymm_114",be="_currentValue_1dymm_134",ye="_menuNote_1dymm_141",ge="_menuError_1dymm_150",n={settingsPanel:ce,header:oe,backBtn:me,contentWrapper:de,menuContent:ue,menuItem:he,selected:pe,currentValue:be,menuNote:ye,menuError:ge},ve=($,P)=>{const{isOpen:y,onClose:ke,videoSources:Ce,currentSource:C,currentLink:N,onSourceChange:V,subtitles:O,activeSubtitleTrack:g,onSubtitleChange:E,subtitleSettings:z,onSubtitleSettingsChange:T,useNativeControls:v,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:f,anime4kProfile:r,onAnime4kProfileChange:h,anime4kInitializing:L,anime4kError:S,videoDelayEnabled:_,onVideoDelayToggle:M,videoDelayMs:I,onVideoDelayChange:D,onCalibrateAvSync:x,isAutoSkipEnabled:m,onAutoSkipChange:W,isAutoplayEnabled:d,onAutoplayChange:G,fallbackChoice:p,onFallbackChoiceChange:j,isTheaterMode:q,ambientSettings:b,onAmbientChange:k}=$,{lowEndMode:F}=re(),[a,i]=ne("main");w.useEffect(()=>{if(!y){const t=setTimeout(()=>i("main"),300);return()=>clearTimeout(t)}},[y]);const Q=()=>e("div",{className:n.menuContent,children:[e("button",{className:n.menuItem,onClick:()=>i("quality"),children:[e("span",{children:"Quality"}),e("span",{className:n.currentValue,children:N?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:g||"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitle-style"),children:e("span",{children:"Subtitle Style"})}),F&&e("button",{className:`${n.menuItem} ${v?n.selected:""}`,onClick:()=>{const t=!v;U(t),localStorage.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),v&&e(o,{name:"check",size:12})]}),f&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),f&&u&&e("button",{className:n.menuItem,onClick:()=>i("upscaler"),children:e("span",{children:"Upscaler Settings"})}),e("button",{className:n.menuItem,onClick:()=>i("av-sync"),children:[e("span",{children:"A/V Sync"}),e("span",{className:n.currentValue,children:_?`${I}ms`:"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("playback"),children:[e("span",{children:"Playback"}),e("span",{className:n.currentValue,children:[m?"Auto-skip On":null,d?"Autoplay On":null].filter(Boolean).join(" • ")||"Off"})]}),q&&b&&k&&e("button",{className:n.menuItem,onClick:()=>i("ambient"),children:[e("span",{children:"Ambient Light"}),e("span",{className:n.currentValue,children:b.enabled?"On":"Off"})]})]}),R=()=>{const t=C?.links.sort((s,c)=>(parseInt(c.resolutionStr)||0)-(parseInt(s.resolutionStr)||0))||[];return e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:t.map(s=>({key:s.resolutionStr,label:s.resolutionStr,selected:N?.resolutionStr===s.resolutionStr})),onSelect:s=>{const c=t.find(l=>l.resolutionStr===s);c&&V(C,c)}})})},H=()=>e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:g==="off"},...O.map(t=>({key:t.label||t.lang,label:t.label,selected:g===(t.label||t.lang)}))],onSelect:t=>E(t)})}),K=()=>e("div",{className:n.menuContent,children:e(se,{classes:{item:n.menuItem,active:n.selected},values:z,onChange:T})}),J=te(()=>{try{const s=navigator.userAgentData?.brands?.map(l=>l.brand.toLowerCase())??[];if(s.length>0)return s.some(l=>l.includes("chromium")||l.includes("chrome")||l.includes("edge")||l.includes("opera")||l.includes("brave")||l.includes("vivaldi"));const c=navigator.userAgent.toLowerCase();return c.includes("chrome")||c.includes("chromium")||c.includes("edg")}catch{return!0}},[]),X=()=>e("div",{className:n.menuContent,children:[L&&e("div",{className:n.menuNote,role:"status",children:"Preparing GPU, this can take a few seconds…"}),S&&e("div",{className:n.menuError,role:"alert",children:["Upscaler failed: ",S]}),!J&&e("div",{className:n.menuNote,children:"Upscaling performs best in Chrome-based browsers."}),e("button",{className:`${n.menuItem} ${r==="low"?n.selected:""}`,onClick:()=>h("low"),children:[e("div",{children:[e("div",{children:"Low"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Lightest, best for weaker GPUs"})]}),r==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="balanced"?n.selected:""}`,onClick:()=>h("balanced"),children:[e("div",{children:[e("div",{children:"Balanced"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Source + display aware"})]}),r==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="high"?n.selected:""}`,onClick:()=>h("high"),children:[e("div",{children:[e("div",{children:"High"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Aggressive, needs strong GPU"})]}),r==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="denoise"?n.selected:""}`,onClick:()=>h("denoise"),children:[e("div",{children:[e("div",{children:"Denoise"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Denoise + upscale noisy, compressed sources"})]}),r==="denoise"&&e(o,{name:"check",size:12})]})]}),Y=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${m?n.selected:""}`,onClick:()=>W(!m),"aria-pressed":m,children:[e("span",{children:"Auto-skip openings and endings"}),e("span",{className:n.currentValue,children:m?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically jump past opening, ending and recap segments when detected."}),e("button",{type:"button",className:`${n.menuItem} ${d?n.selected:""}`,onClick:()=>G(!d),"aria-pressed":d,children:[e("span",{children:"Autoplay next episode"}),e("span",{className:n.currentValue,children:d?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically start the next episode when this one ends."}),e("button",{type:"button",className:n.menuItem,onClick:()=>j(p==="ask"?"iframe":p==="iframe"?"retry":"ask"),children:[e("span",{children:"Failed direct stream"}),e("span",{className:n.currentValue,children:p==="iframe"?"Use iframe":p==="retry"?"Try provider":"Ask me"})]}),e("div",{className:n.menuNote,children:"When a direct stream fails: ask each time, go straight to the embedded player (may show ads), or automatically try another provider."})]}),Z=()=>e("div",{className:n.menuContent,children:e(le,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:_,delayMs:I,onToggle:M,onDelayChange:D,onCalibrate:x})}),ee=()=>b&&k?e("div",{className:n.menuContent,children:e(ie,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},values:b,onChange:k})}):null;return y?e(ae,{classes:{panel:n.settingsPanel,header:n.header,backBtn:n.backBtn,title:"",content:n.contentWrapper},title:a==="main"?"Settings":a==="ambient"?"Ambient Light":a.charAt(0).toUpperCase()+a.slice(1).replace("-"," "),titleTag:"h3",showBack:a!=="main",onBack:()=>i("main"),panelRef:P,onPanelClick:t=>t.stopPropagation(),children:[a==="main"&&Q(),a==="quality"&&R(),a==="subtitles"&&H(),a==="subtitle-style"&&K(),a==="upscaler"&&X(),a==="av-sync"&&Z(),a==="playback"&&Y(),a==="ambient"&&ee()]}):null},we=w.forwardRef(ve);export{we as default};
|