@serifpersia/dango 3.4.4 → 3.4.6
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-4CEz8Buu.js → AnimeCard-BVdH0EeW.js} +1 -1
- package/client/dist/assets/{AnimeInfo-DyX9qTwg.js → AnimeInfo-Dw2Nop6Q.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-Dvp_c8vK.js → AnimeInfoPage-Cw-Tq3YX.js} +2 -2
- package/client/dist/assets/{Asmr-qg3lMAJn.js → Asmr-BrjzzyOi.js} +1 -1
- package/client/dist/assets/{AsmrResetProgressModal-BpPlg_Vv.js → AsmrResetProgressModal-CYjpcYpb.js} +1 -1
- package/client/dist/assets/{AvSyncCalibrator-FJllOgOH.js → AvSyncCalibrator-BuHurVgo.js} +3 -3
- package/client/dist/assets/AvSyncCalibrator-D0FYSwiz.css +1 -0
- package/client/dist/assets/{Home-A7gCeEST.js → Home-KdnP7sNM.js} +1 -1
- package/client/dist/assets/{Insights-G9IXepHJ.js → Insights-DDWry-t1.js} +1 -1
- package/client/dist/assets/{LibraryListPage-Bh2qCJPh.js → LibraryListPage-CV8Z9JlO.js} +1 -1
- package/client/dist/assets/{ListeningList-Czv4cTRl.js → ListeningList-DSMbMZT7.js} +1 -1
- package/client/dist/assets/{Manga-qdAAS1z7.js → Manga-J6XoqEKq.js} +1 -1
- package/client/dist/assets/{MangaInfoPage-1rTgZzf2.js → MangaInfoPage-N7TxsN5u.js} +1 -1
- package/client/dist/assets/{MangaReadPage-CeyxPG6w.js → MangaReadPage-D_VzSNWq.js} +1 -1
- package/client/dist/assets/{MangaResetProgressModal-C_ppotmh.js → MangaResetProgressModal-DyhQYBDy.js} +1 -1
- package/client/dist/assets/{Mature-Bkhxnr3K.js → Mature-Db53R-LR.js} +1 -1
- package/client/dist/assets/{MediaCard-BQZsutEo.js → MediaCard-BcLjlpfR.js} +1 -1
- package/client/dist/assets/{Music-C0rGzSbi.js → Music-DjxQjJOl.js} +1 -1
- package/client/dist/assets/{OptionListMenu-CyfpCBEy.js → OptionListMenu-DngTgHxH.js} +1 -1
- package/client/dist/assets/Player-Be_7Ne5p.js +56 -0
- package/client/dist/assets/{PlayerSettings-icy4SfQa.js → PlayerSettings-D47ItGDR.js} +1 -1
- package/client/dist/assets/{QueueOptionsButton-5eloKF5J.js → QueueOptionsButton-ClVTpH8J.js} +1 -1
- package/client/dist/assets/{QueueRail-DaMjlKL4.js → QueueRail-DeJKVRs5.js} +1 -1
- package/client/dist/assets/{Radio-FxGqCxR4.js → Radio-DU0ma3GA.js} +1 -1
- package/client/dist/assets/{ReadingList-CCm3IAbt.js → ReadingList-qXW7Dk5z.js} +1 -1
- package/client/dist/assets/{ResetProgressModal-CeI4V3Y5.js → ResetProgressModal-C6ukct_c.js} +1 -1
- package/client/dist/assets/{Search-qpILaAiQ.js → Search-DjjKA_Wu.js} +1 -1
- package/client/dist/assets/{Settings-Bw9M3NGz.js → Settings-DQt_S5Qw.js} +1 -1
- package/client/dist/assets/{SkeletonGrid-0dY_xMq3.js → SkeletonGrid-nx2HEi4P.js} +1 -1
- package/client/dist/assets/{Trackers-Zy5GOs0P.js → Trackers-BcGzeqj2.js} +1 -1
- package/client/dist/assets/Tv-COvyHdeJ.js +4 -0
- package/client/dist/assets/{TvInfo-CHIsVzZ0.js → TvInfo-CUd1agFy.js} +1 -1
- package/client/dist/assets/{TvPopup-D_tVTyZ2.js → TvPopup-CJeu3tgc.js} +1 -1
- package/client/dist/assets/{TvSearch-BVxedBW-.js → TvSearch-BIypjbU3.js} +1 -1
- package/client/dist/assets/{TvWatchlist-BEIwq9R9.js → TvWatchlist-DZrBdiqZ.js} +1 -1
- package/client/dist/assets/{Watchlist-CSngjqlz.js → Watchlist-Dw8cPe0n.js} +1 -1
- package/client/dist/assets/{hls-D48GVTkk.js → hls-B3_1VuDP.js} +1 -1
- package/client/dist/assets/{index-CVB5dYhT.js → index-gMxawd-E.js} +2 -2
- package/client/dist/assets/{useAnimeInfoData-DxdOg_B7.js → useAnimeInfoData-_iOLEAa8.js} +1 -1
- package/client/dist/assets/{useAsmr-ClckxnPe.js → useAsmr-Blk4v41t.js} +1 -1
- package/client/dist/assets/{useAsmrPopup-Bbgxefy_.js → useAsmrPopup-D9SQIgZa.js} +1 -1
- package/client/dist/assets/{useMangaLibrary-B3_BUKVk.js → useMangaLibrary-B60at6ni.js} +1 -1
- package/client/dist/assets/{useMangaPopup-Celk4lzf.js → useMangaPopup-DEfGjWSu.js} +1 -1
- package/client/dist/assets/{useProviders-pwxPZPHh.js → useProviders-Ca0bZWt7.js} +1 -1
- package/client/dist/assets/{useTv-D9sQrDop.js → useTv-WJCDL5_5.js} +1 -1
- package/client/dist/assets/{useTvLibrary-UsQpgBTB.js → useTvLibrary-Fgn5i9rJ.js} +1 -1
- package/client/dist/index.html +1 -1
- package/package.json +4 -2
- package/server/dist/app-hono.js +2 -0
- package/server/dist/hono/asmr.js +10 -1
- package/server/dist/hono/music.js +122 -332
- package/server/dist/hono/proxy.js +105 -99
- package/server/dist/hono/tv.js +5 -58
- package/server/dist/hono/watchlist.js +2 -291
- package/server/dist/lib/anilist.js +0 -3
- package/server/dist/lib/mal.js +4 -41
- package/server/dist/lib/offline-db.js +0 -6
- package/server/dist/lib/potoken.js +135 -0
- package/server/dist/lib/tracker/manga-sync.service.js +3 -22
- package/server/dist/lib/tracker/sync-state.js +21 -0
- package/server/dist/lib/tracker/sync.service.js +3 -22
- package/server/dist/lib/ump.js +106 -0
- package/server/dist/providers/remote-loader.js +17 -27
- package/server/dist/providers/title-matching.js +5 -5
- package/server/dist/repositories/asmr.repository.js +4 -53
- package/server/dist/repositories/library.repository.js +46 -0
- package/server/dist/repositories/manga.repository.js +3 -53
- package/server/dist/repositories/settings.repository.js +8 -0
- package/server/dist/repositories/tv.repository.js +3 -46
- package/server/dist/repositories/watched-episodes.repository.js +0 -2
- package/server/dist/server.js +5 -1
- package/server/dist/sync.js +3 -5
- package/server/dist/trpc/routers/asmr-library.js +2 -12
- package/server/dist/trpc/routers/asmr-progress.js +10 -22
- package/server/dist/trpc/routers/data.js +17 -36
- package/server/dist/trpc/routers/discord.js +1 -8
- package/server/dist/trpc/routers/insights.js +15 -16
- package/server/dist/trpc/routers/manga-library.js +5 -22
- package/server/dist/trpc/routers/manga-progress.js +8 -20
- package/server/dist/trpc/routers/music.js +6 -11
- package/server/dist/trpc/routers/queue.js +1 -1
- package/server/dist/trpc/routers/tracker.js +1 -7
- package/server/dist/trpc/routers/tv-library.js +2 -12
- package/server/dist/trpc/routers/tv-progress.js +16 -28
- package/server/dist/trpc/routers/tv.js +5 -21
- package/server/dist/trpc/routers/watchlist.js +1 -8
- package/server/dist/trpc/validation.js +35 -0
- package/server/dist/utils/db-utils.js +8 -0
- package/server/dist/utils/http.utils.js +12 -0
- package/server/dist/utils/machine-id.js +1 -2
- package/server/dist/utils/megaplay.utils.js +1 -2
- package/server/package.json +4 -1
- package/client/dist/assets/AvSyncCalibrator-C2wu1ydI.css +0 -1
- package/client/dist/assets/Player-yhiTlpYU.js +0 -56
- package/client/dist/assets/Tv-DREwc7BX.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as t,a as we,p as ke,h as de,d as l,T as ue,S as me}from"./vendor-core-DfaOB3Rn.js";import{b as he}from"./vendor-query-BBT5_sHx.js";import{B as O,M as $e,h as qe,e as Fe,U as xe,t as x,z as Ue}from"./index-CVB5dYhT.js";import{I as ge}from"./vendor-icons-DrybRNxP.js";import{S as Ye,P as pe}from"./SkeletonGrid-0dY_xMq3.js";import{A as Ve}from"./AnimeCard-4CEz8Buu.js";import{E as We}from"./ErrorMessage-DAxegITP.js";import{u as je}from"./useProviders-pwxPZPHh.js";import{s as a}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-DxdOg_B7.js";import"./QueueOptionsButton-5eloKF5J.js";import"./vendor-ui-3qrARCPr.js";import"./MediaCard-BQZsutEo.js";import"./useIsMobile-Dvx1uJ82.js";const He=({isOpen:u,onClose:c,onGrant:s})=>t($e,{isOpen:u,title:"Content Warning",onClose:c,children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:"This title contains mature content intended for adult audiences."}),t("p",{children:["By proceeding, you confirm that you are ",t("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(O,{variant:"secondary",onClick:c,children:"Go Back"}),t(O,{onClick:s,children:"I'm 18+, Continue"})]})]})}),Ke="_shrinkSelect_130sm_1",Qe="_tightGrid_130sm_7",Q={shrinkSelect:Ke,tightGrid:Qe},ze=[{value:"anilist",label:"AniList"},{value:"mal",label:"MAL"}],Ze=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"FAVOURITES_DESC",label:"Favourites"}],Je=[{value:"",label:"All Status"},{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"}],Xe=[{value:"",label:"Relevance"},{value:"visits:desc",label:"Most Visited"},{value:"title:asc",label:"Title A-Z"}],et={recent:"Latest",popular:"Popular",views:"Most Viewed",rating:"Top Rated",random:"Random"},tt=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],ve=u=>u.split("-").map(c=>c&&c[0].toUpperCase()+c.slice(1)).join(" "),at=new Set(["page","limit","year","minScore","minEpisodes"]),rt=new Set(["provider","query","page","limit","type","status","season","year","country","genres","genre","excludeGenres","sortBy","order","studio","blacklist","minScore","minEpisodes"]);function st(u){const c=new URLSearchParams(u),s={};for(const[y,b]of c.entries())rt.has(y)&&(at.has(y)?s[y]=Number(b)||0:s[y]=b);return s}function bt(){const u=we(),c=qe(),[s,y]=ke(),{hasConsent:b,grant:fe}=Fe();de(()=>{document.title="Mature - dango"},[]);const[i,Se]=l(s.get("provider")||"anilist"),[C,z]=l(s.get("query")||""),[T,U]=l(s.get("query")||""),[I,g]=l(parseInt(s.get("page")||"1",10)||1),[_,Y]=l(()=>{const e=s.get("sortBy");return e||(i==="mal"?"SCORE_DESC":"POPULARITY_DESC")}),[M,Z]=l(s.get("sortBy")||""),[N,ye]=l(s.get("status")||""),[D,be]=l(s.get("season")||"ALL"),[G,Ce]=l(s.get("year")||"ALL"),[p,B]=l(s.get("genre")||s.get("genres")||""),[V,Ne]=l(s.get("order")||"recent"),[W,Ae]=l(s.get("studio")||""),[w,Ee]=l(s.get("studio")||""),[J,X]=l([]),[j,Pe]=l(!1),[Re,ee]=l(null),{options:te}=je(),ae=ue(()=>te.filter(e=>e.mature&&(e.kind??"anime")==="anime"),[te]),re=ue(()=>[...ze,...ae.map(e=>({value:e.value,label:e.label}))],[ae]),{data:k}=he({...c.data.matureFilters.queryOptions(),enabled:b,staleTime:1/0}),d=i==="anilist"||i==="mal",H=d?void 0:k?.providers?.[i],P=H?.browse,R=H?.genres??[],A=H?.orders??[],se=A.length>0&&!A.includes(V)?A[0]:V,$=!d&&(P?.genre===!0||R.length>0||J.length>0),v=!d&&(P?.order===!0||A.length>0),E=!d&&P?.studio===!0,ie=!d&&P?.sort===!0,q=d?14:P?.pageSize??14,f=e=>{const r=new URLSearchParams;if(e.provider!=="anilist"&&r.set("provider",e.provider),e.query.trim()&&r.set("query",e.query.trim()),e.page>1&&r.set("page",String(e.page)),e.provider==="anilist")e.sort!=="POPULARITY_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status),e.season!=="ALL"&&r.set("season",e.season),e.year!=="ALL"&&r.set("year",e.year);else if(e.provider==="mal")e.sort!=="SCORE_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status);else{const n=k?.providers?.[e.provider]?.browse,m=k?.providers?.[e.provider]?.orders??[],o=m.length>0&&!m.includes(e.remoteOrder)?m[0]:e.remoteOrder;(!n||n.sort)&&e.remoteSort&&r.set("sortBy",e.remoteSort),(!n||n.genre)&&e.genre&&r.set("genre",e.genre),(!n||n.order)&&o!==(m[0]??"recent")&&r.set("order",o),(!n||n.studio)&&e.studio.trim()&&r.set("studio",e.studio.trim())}y(r,{replace:!0})},S=(e={})=>({provider:i,query:T,page:I,sort:_,remoteSort:M,status:N,season:D,year:G,genre:p,remoteOrder:V,studio:w,...e}),Le=(()=>{const e=new URLSearchParams;return e.set("provider",i),T.trim()&&e.set("query",T.trim()),e.set("page",String(I)),e.set("limit",String(q)),i==="anilist"&&(e.set("sortBy",_),N&&e.set("status",N),D!=="ALL"&&e.set("season",D),G!=="ALL"&&e.set("year",G)),i==="mal"?(e.set("sortBy",_),N&&e.set("status",N)):d||($&&p&&e.set("genre",p),v&&e.set("order",se),ie&&M&&e.set("sortBy",M),E&&w.trim()&&e.set("studio",w.trim())),e.toString()})(),{data:h,isLoading:Oe,isError:Te,error:Ie}=he({...c.data.matureSearch.queryOptions(st(Le)),enabled:b});de(()=>{const e=h?.genres;!d&&R.length===0&&e&&e.length>0&&X(r=>{const n=new Set(r.map(o=>o.slug)),m=[...r];for(const o of e)o.slug&&!n.has(o.slug)&&(n.add(o.slug),m.push(o));return m.length===r.length?r:m})},[h,i,d,R.length]);const F=(h?.data||[]).map(e=>({...e,isAdult:!0})),le=h?.hasMore??!1,L=()=>{xe(),g(1);let e=p;!d&&!v&&C.trim()&&(e=""),B(e),E&&Ee(W),U(C),f(S({query:C,page:1,genre:e,studio:E?W:w}))},_e=e=>{Se(e),g(1),Z(""),B(""),X([]),e==="mal"?Y("SCORE_DESC"):e==="anilist"&&Y("POPULARITY_DESC"),U(C),f(S({provider:e,page:1,remoteSort:"",genre:"",query:C}))},Me=e=>{B(e),g(1),e&&(z(""),U("")),f(S({genre:e,page:1,query:e?"":T}))},ne=e=>{g(e),f(S({page:e})),window.scrollTo({top:0,behavior:"smooth"})},De=async(e,r)=>{const n=r.id||r._id;if(i!=="mal"&&!/^\d+$/.test(n)&&(e.preventDefault(),e.stopPropagation(),!Re)){ee(n);try{if(i!=="anilist"){let o=!1;try{o=(await x.data.anilistStatus.query())?.available===!0}catch{o=!1}if(o){const ce=await x.data.matureResolve.query({title:r.name});u(`/anime/${ce.id}`);return}const oe=await x.data.matureAllocate.mutate({provider:i,nativeId:n,title:r.name,thumbnail:r.thumbnail});if(!oe?.id)throw new Error("Allocate failed");u(`/anime/${oe.id}`);return}const m=await x.data.matureResolve.query({title:r.name});u(`/anime/${m.id}`)}catch{Ue.error("Could not match this title on AniList")}finally{ee(null)}}},K=new Date().getFullYear(),Ge=[{value:"ALL",label:"All Years"},...Array.from({length:K-1980+1},(e,r)=>({value:String(K-r),label:String(K-r)}))],Be=R.length>0?R.map(e=>({value:e,label:ve(e)})):J.map(e=>({value:e.slug,label:e.name}));return b?t("div",{className:"page-container",children:[t("div",{className:a.header,children:[t("h1",{className:a.pageTitle,children:"Mature"}),t("p",{className:a.pageSubtitle,children:"Browse 18+ titles across AniList and streaming providers"})]}),t("div",{className:a.filterContainer,children:[t("div",{className:a.searchBarWrapper,children:[t("div",{className:a.inputIconWrapper,children:[t(ge,{name:"search",className:a.searchIcon}),t("input",{type:"text",placeholder:`Search ${re.find(e=>e.value===i)?.label}...`,value:C,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]}),t("div",{className:a.searchActions,children:[t("select",{value:i,onChange:e=>_e(e.target.value),className:a.providerSelect,"aria-label":"Provider",children:re.map(e=>t("option",{value:e.value,children:e.label},e.value))}),t(O,{onClick:L,className:a.searchBtn,children:"Search"}),d&&t("button",{onClick:()=>Pe(!j),className:`${a.filterToggleBtn} ${j?a.active:""}`,children:[t(ge,{name:"filter"})," Filters"]}),ie&&t("select",{value:M,onChange:e=>{Z(e.target.value),g(1),f(S({remoteSort:e.target.value,page:1}))},className:a.providerSelect,"aria-label":"Sort",children:Xe.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),(i==="anilist"||i==="mal")&&t("div",{className:`${a.advancedFilters} ${j?a.show:""}`,children:[t("div",{className:a.filterDivider}),t("div",{className:a.filterGrid,children:[t("div",{className:a.filterItem,children:[t("label",{children:"Sort By"}),t("select",{value:_,onChange:e=>Y(e.currentTarget.value),children:Ze.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Status"}),t("select",{value:N,onChange:e=>ye(e.currentTarget.value),children:Je.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),i==="anilist"&&t(me,{children:[t("div",{className:a.filterItem,children:[t("label",{children:"Season"}),t("select",{value:D,onChange:e=>be(e.currentTarget.value),children:tt.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Year"}),t("select",{value:G,onChange:e=>Ce(e.currentTarget.value),children:Ge.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]})]}),t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]}),!d&&!!k&&($||v||E)&&t("div",{className:`${a.advancedFilters} ${a.show}`,children:[t("div",{className:a.filterDivider}),t("div",{className:`${a.filterGrid} ${Q.tightGrid}`,children:[v&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Order"}),t("select",{value:se,onChange:e=>{Ne(e.target.value),g(1),f(S({remoteOrder:e.target.value,page:1}))},children:(A.length>0?A:["recent"]).map(e=>t("option",{value:e,children:et[e]||e},e))})]}),$&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Genre"}),t("select",{value:p,onChange:e=>{v?(B(e.target.value),g(1),f(S({genre:e.target.value,page:1}))):Me(e.target.value)},children:[t("option",{value:"",children:"All Genres"}),Be.map(e=>t("option",{value:e.value,children:e.label},e.value))]})]}),E&&t("div",{className:a.filterItem,children:[t("label",{children:"Studio"}),t("input",{type:"text",placeholder:"Studio name...",value:W,onChange:e=>Ae(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]})]}),p&&$&&!v&&t("p",{className:a.pageSubtitle,children:["Browsing the ",ve(p)," genre — search text is ignored while a genre is selected."]}),(v||E)&&t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]})]}),Te&&t(We,{message:Ie?.message||"Search failed"}),Oe?t(Ye,{count:q}):F.length===0?t("div",{className:a.noResults,children:[t("h3",{children:"No results found"}),t("p",{children:"Try a different query, genre or provider"})]}):t(me,{children:[t("div",{className:a.resultsHeader,children:[t("h2",{className:a.resultsTitle,children:[h?.total??F.length," result",(h?.total??F.length)===1?"":"s"]}),t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})]}),t("div",{className:a.resultsGrid,children:F.map(e=>t("div",{onClickCapture:r=>De(r,e),children:t(Ve,{anime:e})},`${i}-${e._id}`))}),t("div",{className:a.bottomPagination,children:t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})})]})]}):t(He,{isOpen:!0,onClose:()=>u("/"),onGrant:fe})}export{bt as default};
|
|
1
|
+
import{u as t,a as we,p as ke,h as de,d as l,T as ue,S as me}from"./vendor-core-DfaOB3Rn.js";import{b as he}from"./vendor-query-BBT5_sHx.js";import{B as O,M as $e,h as qe,e as Fe,U as xe,t as x,z as Ue}from"./index-gMxawd-E.js";import{I as ge}from"./vendor-icons-DrybRNxP.js";import{S as Ye,P as pe}from"./SkeletonGrid-nx2HEi4P.js";import{A as Ve}from"./AnimeCard-BVdH0EeW.js";import{E as We}from"./ErrorMessage-DAxegITP.js";import{u as je}from"./useProviders-Ca0bZWt7.js";import{s as a}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-_iOLEAa8.js";import"./QueueOptionsButton-ClVTpH8J.js";import"./vendor-ui-3qrARCPr.js";import"./MediaCard-BcLjlpfR.js";import"./useIsMobile-Dvx1uJ82.js";const He=({isOpen:u,onClose:c,onGrant:s})=>t($e,{isOpen:u,title:"Content Warning",onClose:c,children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:"This title contains mature content intended for adult audiences."}),t("p",{children:["By proceeding, you confirm that you are ",t("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(O,{variant:"secondary",onClick:c,children:"Go Back"}),t(O,{onClick:s,children:"I'm 18+, Continue"})]})]})}),Ke="_shrinkSelect_130sm_1",Qe="_tightGrid_130sm_7",Q={shrinkSelect:Ke,tightGrid:Qe},ze=[{value:"anilist",label:"AniList"},{value:"mal",label:"MAL"}],Ze=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"FAVOURITES_DESC",label:"Favourites"}],Je=[{value:"",label:"All Status"},{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"}],Xe=[{value:"",label:"Relevance"},{value:"visits:desc",label:"Most Visited"},{value:"title:asc",label:"Title A-Z"}],et={recent:"Latest",popular:"Popular",views:"Most Viewed",rating:"Top Rated",random:"Random"},tt=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],ve=u=>u.split("-").map(c=>c&&c[0].toUpperCase()+c.slice(1)).join(" "),at=new Set(["page","limit","year","minScore","minEpisodes"]),rt=new Set(["provider","query","page","limit","type","status","season","year","country","genres","genre","excludeGenres","sortBy","order","studio","blacklist","minScore","minEpisodes"]);function st(u){const c=new URLSearchParams(u),s={};for(const[y,b]of c.entries())rt.has(y)&&(at.has(y)?s[y]=Number(b)||0:s[y]=b);return s}function bt(){const u=we(),c=qe(),[s,y]=ke(),{hasConsent:b,grant:fe}=Fe();de(()=>{document.title="Mature - dango"},[]);const[i,Se]=l(s.get("provider")||"anilist"),[C,z]=l(s.get("query")||""),[T,U]=l(s.get("query")||""),[I,g]=l(parseInt(s.get("page")||"1",10)||1),[_,Y]=l(()=>{const e=s.get("sortBy");return e||(i==="mal"?"SCORE_DESC":"POPULARITY_DESC")}),[M,Z]=l(s.get("sortBy")||""),[N,ye]=l(s.get("status")||""),[D,be]=l(s.get("season")||"ALL"),[G,Ce]=l(s.get("year")||"ALL"),[p,B]=l(s.get("genre")||s.get("genres")||""),[V,Ne]=l(s.get("order")||"recent"),[W,Ae]=l(s.get("studio")||""),[w,Ee]=l(s.get("studio")||""),[J,X]=l([]),[j,Pe]=l(!1),[Re,ee]=l(null),{options:te}=je(),ae=ue(()=>te.filter(e=>e.mature&&(e.kind??"anime")==="anime"),[te]),re=ue(()=>[...ze,...ae.map(e=>({value:e.value,label:e.label}))],[ae]),{data:k}=he({...c.data.matureFilters.queryOptions(),enabled:b,staleTime:1/0}),d=i==="anilist"||i==="mal",H=d?void 0:k?.providers?.[i],P=H?.browse,R=H?.genres??[],A=H?.orders??[],se=A.length>0&&!A.includes(V)?A[0]:V,$=!d&&(P?.genre===!0||R.length>0||J.length>0),v=!d&&(P?.order===!0||A.length>0),E=!d&&P?.studio===!0,ie=!d&&P?.sort===!0,q=d?14:P?.pageSize??14,f=e=>{const r=new URLSearchParams;if(e.provider!=="anilist"&&r.set("provider",e.provider),e.query.trim()&&r.set("query",e.query.trim()),e.page>1&&r.set("page",String(e.page)),e.provider==="anilist")e.sort!=="POPULARITY_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status),e.season!=="ALL"&&r.set("season",e.season),e.year!=="ALL"&&r.set("year",e.year);else if(e.provider==="mal")e.sort!=="SCORE_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status);else{const n=k?.providers?.[e.provider]?.browse,m=k?.providers?.[e.provider]?.orders??[],o=m.length>0&&!m.includes(e.remoteOrder)?m[0]:e.remoteOrder;(!n||n.sort)&&e.remoteSort&&r.set("sortBy",e.remoteSort),(!n||n.genre)&&e.genre&&r.set("genre",e.genre),(!n||n.order)&&o!==(m[0]??"recent")&&r.set("order",o),(!n||n.studio)&&e.studio.trim()&&r.set("studio",e.studio.trim())}y(r,{replace:!0})},S=(e={})=>({provider:i,query:T,page:I,sort:_,remoteSort:M,status:N,season:D,year:G,genre:p,remoteOrder:V,studio:w,...e}),Le=(()=>{const e=new URLSearchParams;return e.set("provider",i),T.trim()&&e.set("query",T.trim()),e.set("page",String(I)),e.set("limit",String(q)),i==="anilist"&&(e.set("sortBy",_),N&&e.set("status",N),D!=="ALL"&&e.set("season",D),G!=="ALL"&&e.set("year",G)),i==="mal"?(e.set("sortBy",_),N&&e.set("status",N)):d||($&&p&&e.set("genre",p),v&&e.set("order",se),ie&&M&&e.set("sortBy",M),E&&w.trim()&&e.set("studio",w.trim())),e.toString()})(),{data:h,isLoading:Oe,isError:Te,error:Ie}=he({...c.data.matureSearch.queryOptions(st(Le)),enabled:b});de(()=>{const e=h?.genres;!d&&R.length===0&&e&&e.length>0&&X(r=>{const n=new Set(r.map(o=>o.slug)),m=[...r];for(const o of e)o.slug&&!n.has(o.slug)&&(n.add(o.slug),m.push(o));return m.length===r.length?r:m})},[h,i,d,R.length]);const F=(h?.data||[]).map(e=>({...e,isAdult:!0})),le=h?.hasMore??!1,L=()=>{xe(),g(1);let e=p;!d&&!v&&C.trim()&&(e=""),B(e),E&&Ee(W),U(C),f(S({query:C,page:1,genre:e,studio:E?W:w}))},_e=e=>{Se(e),g(1),Z(""),B(""),X([]),e==="mal"?Y("SCORE_DESC"):e==="anilist"&&Y("POPULARITY_DESC"),U(C),f(S({provider:e,page:1,remoteSort:"",genre:"",query:C}))},Me=e=>{B(e),g(1),e&&(z(""),U("")),f(S({genre:e,page:1,query:e?"":T}))},ne=e=>{g(e),f(S({page:e})),window.scrollTo({top:0,behavior:"smooth"})},De=async(e,r)=>{const n=r.id||r._id;if(i!=="mal"&&!/^\d+$/.test(n)&&(e.preventDefault(),e.stopPropagation(),!Re)){ee(n);try{if(i!=="anilist"){let o=!1;try{o=(await x.data.anilistStatus.query())?.available===!0}catch{o=!1}if(o){const ce=await x.data.matureResolve.query({title:r.name});u(`/anime/${ce.id}`);return}const oe=await x.data.matureAllocate.mutate({provider:i,nativeId:n,title:r.name,thumbnail:r.thumbnail});if(!oe?.id)throw new Error("Allocate failed");u(`/anime/${oe.id}`);return}const m=await x.data.matureResolve.query({title:r.name});u(`/anime/${m.id}`)}catch{Ue.error("Could not match this title on AniList")}finally{ee(null)}}},K=new Date().getFullYear(),Ge=[{value:"ALL",label:"All Years"},...Array.from({length:K-1980+1},(e,r)=>({value:String(K-r),label:String(K-r)}))],Be=R.length>0?R.map(e=>({value:e,label:ve(e)})):J.map(e=>({value:e.slug,label:e.name}));return b?t("div",{className:"page-container",children:[t("div",{className:a.header,children:[t("h1",{className:a.pageTitle,children:"Mature"}),t("p",{className:a.pageSubtitle,children:"Browse 18+ titles across AniList and streaming providers"})]}),t("div",{className:a.filterContainer,children:[t("div",{className:a.searchBarWrapper,children:[t("div",{className:a.inputIconWrapper,children:[t(ge,{name:"search",className:a.searchIcon}),t("input",{type:"text",placeholder:`Search ${re.find(e=>e.value===i)?.label}...`,value:C,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]}),t("div",{className:a.searchActions,children:[t("select",{value:i,onChange:e=>_e(e.target.value),className:a.providerSelect,"aria-label":"Provider",children:re.map(e=>t("option",{value:e.value,children:e.label},e.value))}),t(O,{onClick:L,className:a.searchBtn,children:"Search"}),d&&t("button",{onClick:()=>Pe(!j),className:`${a.filterToggleBtn} ${j?a.active:""}`,children:[t(ge,{name:"filter"})," Filters"]}),ie&&t("select",{value:M,onChange:e=>{Z(e.target.value),g(1),f(S({remoteSort:e.target.value,page:1}))},className:a.providerSelect,"aria-label":"Sort",children:Xe.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),(i==="anilist"||i==="mal")&&t("div",{className:`${a.advancedFilters} ${j?a.show:""}`,children:[t("div",{className:a.filterDivider}),t("div",{className:a.filterGrid,children:[t("div",{className:a.filterItem,children:[t("label",{children:"Sort By"}),t("select",{value:_,onChange:e=>Y(e.currentTarget.value),children:Ze.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Status"}),t("select",{value:N,onChange:e=>ye(e.currentTarget.value),children:Je.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),i==="anilist"&&t(me,{children:[t("div",{className:a.filterItem,children:[t("label",{children:"Season"}),t("select",{value:D,onChange:e=>be(e.currentTarget.value),children:tt.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Year"}),t("select",{value:G,onChange:e=>Ce(e.currentTarget.value),children:Ge.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]})]}),t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]}),!d&&!!k&&($||v||E)&&t("div",{className:`${a.advancedFilters} ${a.show}`,children:[t("div",{className:a.filterDivider}),t("div",{className:`${a.filterGrid} ${Q.tightGrid}`,children:[v&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Order"}),t("select",{value:se,onChange:e=>{Ne(e.target.value),g(1),f(S({remoteOrder:e.target.value,page:1}))},children:(A.length>0?A:["recent"]).map(e=>t("option",{value:e,children:et[e]||e},e))})]}),$&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Genre"}),t("select",{value:p,onChange:e=>{v?(B(e.target.value),g(1),f(S({genre:e.target.value,page:1}))):Me(e.target.value)},children:[t("option",{value:"",children:"All Genres"}),Be.map(e=>t("option",{value:e.value,children:e.label},e.value))]})]}),E&&t("div",{className:a.filterItem,children:[t("label",{children:"Studio"}),t("input",{type:"text",placeholder:"Studio name...",value:W,onChange:e=>Ae(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]})]}),p&&$&&!v&&t("p",{className:a.pageSubtitle,children:["Browsing the ",ve(p)," genre — search text is ignored while a genre is selected."]}),(v||E)&&t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]})]}),Te&&t(We,{message:Ie?.message||"Search failed"}),Oe?t(Ye,{count:q}):F.length===0?t("div",{className:a.noResults,children:[t("h3",{children:"No results found"}),t("p",{children:"Try a different query, genre or provider"})]}):t(me,{children:[t("div",{className:a.resultsHeader,children:[t("h2",{className:a.resultsTitle,children:[h?.total??F.length," result",(h?.total??F.length)===1?"":"s"]}),t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})]}),t("div",{className:a.resultsGrid,children:F.map(e=>t("div",{onClickCapture:r=>De(r,e),children:t(Ve,{anime:e})},`${i}-${e._id}`))}),t("div",{className:a.bottomPagination,children:t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})})]})]}):t(He,{isOpen:!0,onClose:()=>u("/"),onGrant:fe})}export{bt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as y,g as T,u as e,S as ee,$ as Ne,h as K,A as x,q as d,N as Ee,a as Se,L as Ie}from"./vendor-core-DfaOB3Rn.js";import{a as Re,b as Ae,f as Le,s as $e}from"./vendor-ui-3qrARCPr.js";import{I as v}from"./vendor-icons-DrybRNxP.js";import{t as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-CVB5dYhT.js";import{u as Ge}from"./useIsMobile-Dvx1uJ82.js";const We="_popupPortal_7glox_1",Ye="_popupContent_7glox_6",je="_popupBackdrop_7glox_31",Fe="_mobile_7glox_38",Xe="_header_7glox_62",qe="_title_7glox_67",He="_body_7glox_87",Je="_metaRow_7glox_94",Ke="_metaItem_7glox_101",Qe="_scoreIcon_7glox_107",Ze="_synopsis_7glox_111",et="_details_7glox_121",tt="_detailItem_7glox_129",nt="_genres_7glox_133",ot="_genre_7glox_133",rt="_footer_7glox_148",st="_primaryAction_7glox_157",at="_watchBtn_7glox_161",lt="_secondaryActions_7glox_184",ct="_watchlistBtn_7glox_189",it="_detailsBtn_7glox_190",dt="_active_7glox_216",ut="_loading_7glox_227",_t="_spinner_7glox_237",R={popupPortal:We,popupContent:Ye,popupBackdrop:je,mobile:Fe,header:Xe,title:qe,body:He,metaRow:Je,metaItem:Ke,scoreIcon:Qe,synopsis:Ze,details:et,detailItem:tt,genres:nt,genre:ot,footer:rt,primaryAction:st,watchBtn:at,secondaryActions:lt,watchlistBtn:ct,detailsBtn:it,active:dt,loading:ut,spinner:_t},cn=({anchorRect:t,onMouseEnter:a,onMouseLeave:l,onRequestClose:c,children:u})=>{const[i]=y(()=>window.matchMedia("(pointer: coarse)").matches),r=T.useMemo(()=>({getBoundingClientRect:()=>t}),[t]),{refs:w,floatingStyles:b}=Re({placement:"right-start",middleware:[Le({fallbackAxisSideDirection:"start"}),$e({padding:20})],whileElementsMounted:Ae});T.useEffect(()=>{w.setPositionReference(r)},[w,r]),T.useEffect(()=>{if(!i)return;const C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C}},[i]);const _=e(ee,{children:[i&&e("div",{className:R.popupBackdrop,onClick:()=>c?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:l,children:e("div",{className:R.popupContent,children:u})})]});return Ne(_,document.body)},pt=t=>!t||t.trim()===""?!0:t.includes("placeholder");function gt(t,a){const[l,c]=y(a);return K(()=>{c(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke.data.showMeta.query({id:t}).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&c(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:l}}const mt="_cardWrapper_w7bu0_1",ft="_card_w7bu0_1",ht="_cardButton_w7bu0_35",bt="_hoverOverlay_w7bu0_60",Bt="_matureOverlay_w7bu0_81",wt="_posterContainer_w7bu0_91",vt="_horizontal_w7bu0_100",yt="_posterImg_w7bu0_104",Ct="_blurred_w7bu0_116",Mt="_flat_w7bu0_139",xt="_loaded_w7bu0_143",Tt="_posterGradient_w7bu0_147",Pt="_progressSection_w7bu0_167",Nt="_titleSection_w7bu0_174",Et="_title_w7bu0_174",St="_titleText_w7bu0_193",It="_badge_w7bu0_205",Rt="_typeBadge_w7bu0_216 _badge_w7bu0_205",At="_epBadge_w7bu0_225 _badge_w7bu0_205",Lt="_airTime_w7bu0_234",$t="_adultBadge_w7bu0_241 _badge_w7bu0_205",kt="_gated_w7bu0_254",Ot="_notAiredBadge_w7bu0_260 _badge_w7bu0_205",zt="_metaRow_w7bu0_275",Dt="_metaItem_w7bu0_286",Ut="_progressContainer_w7bu0_303",Vt="_progressBar_w7bu0_311",Gt="_timestamp_w7bu0_318",Wt="_removeBtn_w7bu0_323",Yt="_infoBtn_w7bu0_324",jt="_mobileBadges_w7bu0_375",Ft="_mobileBadgeBase_w7bu0_382",Xt="_mobileType_w7bu0_390 _mobileBadgeBase_w7bu0_382",qt="_mobileEp_w7bu0_397 _mobileBadgeBase_w7bu0_382",Ht="_vertical_w7bu0_489",Jt="_placeholder_w7bu0_504",Kt="_placeholderText_w7bu0_513",Qt="_lowEnd_w7bu0_520",n={cardWrapper:mt,card:ft,cardButton:ht,hoverOverlay:bt,matureOverlay:Bt,posterContainer:wt,horizontal:vt,posterImg:yt,blurred:Ct,flat:Mt,loaded:xt,posterGradient:Tt,progressSection:Pt,titleSection:Nt,title:Et,titleText:St,badge:It,typeBadge:Rt,epBadge:At,airTime:Lt,adultBadge:$t,gated:kt,notAiredBadge:Ot,metaRow:zt,metaItem:Dt,progressContainer:Ut,progressBar:Vt,timestamp:Gt,removeBtn:Wt,infoBtn:Yt,mobileBadges:jt,mobileBadgeBase:Ft,mobileType:Xt,mobileEp:qt,vertical:Ht,placeholder:Jt,placeholderText:Kt,lowEnd:Qt},Zt=500,Z=20,en=300;function tn(t){const a=x(null),l=x(null),c=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),w=d(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),b=d(s=>{a.current&&clearTimeout(a.current),a.current=setTimeout(s,en)},[]),_=d((s,p=!1)=>{c.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,c.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),l.current=setTimeout(()=>{l.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!l.current)return;const p=Math.abs(s.clientX-u.current.x),m=Math.abs(s.clientY-u.current.y);(p>Z||m>Z)&&r()},[r]),g=d(()=>{r(),i.current=null},[r]),P=d((s,p)=>{s.preventDefault(),s.stopPropagation(),i.current==="touch"?l.current&&(clearTimeout(l.current),l.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!c.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>c.current?(c.current=!1,!0):!1,[]);return{longPressFiredRef:c,cancelLongPress:r,clearPopupTimeout:w,schedulePopupClose:b,openViaHold:_,handlePointerDown:C,handlePointerMove:B,handlePointerUpOrCancel:g,handleContextMenu:P,consumeLongPressClick:A}}const z={elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!0}}},dn=Ee(({item:t,linkTo:a,hoverIcon:l,progress:c,showProgress:u=!1,metaRow:i,display:r,layout:w="vertical",onRemove:b,showRemoveButton:_,showInfoButton:C=!1,onOpenDetails:B,renderPopup:g,onPopupHoverIntent:P,rawThumbnail:A,enrichedId:s})=>{const p=Se(),m=Ge(),{titlePreference:te}=Oe(),{lowEndMode:M}=ze(),[ne,oe]=y(!1),[re,D]=y(!1),{thumbnail:U}=gt(s,t.thumbnail),[L,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},$=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose($)},[f,$]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},le=()=>{j()},ce=()=>{g&&k()},ie=o=>{f.handlePointerDown(o,h)},de=o=>{f.handlePointerMove(o)},F=()=>{f.handlePointerUpOrCancel()},ue=o=>{if(B){o.preventDefault(),o.stopPropagation(),B(o.currentTarget.getBoundingClientRect());return}if(g){f.handleContextMenu(o,h);return}f.handleContextMenu(o,h)},X={...r,elements:{...z.elements,...r?.elements||{},poster:{...z.elements?.poster,...r?.elements?.poster||{}},info:{...z.elements?.info,...r?.elements?.info||{}}}},O=t[te]||t.title,N=X.elements?.poster,E=X.elements?.info,_e=(N?.typeBadge??!0)&&!!t.typeBadge,pe=(N?.chapterBadge??!0)&&!!t.chapterBadge,ge=_??N?.removeButton??!!b,me=N?.adultBadge??!0,fe=E?.mobileBadges??!0,he=E?.progress??!0,be=E?.meta??!0,Be=u&&!!c&&c.percent>0,q=!!t.isAdult,[we,ve]=De("agreedToViewMature","false"),ye=we==="true",[H,S]=T.useState(!1),I=T.useRef(null),Ce=()=>{ve("true"),S(!1),I.current&&(p(I.current),I.current=null)},h=q&&!ye,Me=o=>{if(f.consumeLongPressClick()){o.preventDefault(),o.stopPropagation();return}h&&(o.preventDefault(),o.stopPropagation(),I.current=a,S(!0))},xe=l==="book"?e(v,{name:"book",size:28}):l==="play"?e(v,{name:"play",size:28}):l==="info"?e(v,{name:"info-circle",size:28}):e(v,{name:"info-circle",size:28}),Te=d(o=>{o.preventDefault(),o.stopPropagation(),b&&b(t.id)},[b,t.id]),Pe=A?U??t.thumbnail:Ue(U,M?100:150,M?150:200);return e("div",{className:`${n.cardWrapper} ${M?n.lowEnd:""}`,onMouseEnter:()=>{D(!0),P?.(!0),L&&j()},onMouseLeave:()=>{D(!1),P?.(!1),L&&k()},children:[e(Ie,{to:a,className:`${n.card} ${n[w]} ${h?n.cardButton:""}`,onClick:Me,onContextMenu:ue,onPointerDown:ie,onPointerMove:de,onPointerUp:F,onPointerCancel:F,children:[e("div",{className:n.posterContainer,children:[h&&e("div",{className:`${n.matureOverlay} ${M?n.flat:""}`}),e("img",{src:Pe,alt:O,className:`${n.posterImg} ${ne?n.loaded:""} ${h&&!M?n.blurred:""}`,loading:"lazy",decoding:"async",onLoad:()=>oe(!0)}),!m&&e(ee,{children:[_e&&e("div",{className:n.typeBadge,children:t.typeBadge}),pe&&e("div",{className:n.epBadge,children:[t.chapterBadge,t.airMeta&&e("span",{className:n.airTime,children:t.airMeta})]})]}),me&&q&&e("div",{className:`${n.adultBadge} ${h?n.gated:""}`,children:"18+"}),t.notAired&&e("div",{className:n.notAiredBadge,children:"NOT AIRED"}),!m&&re&&e("div",{className:n.hoverOverlay,children:xe})]}),he&&u&&Be&&c&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${c.percent}%`}})}),e("div",{className:n.timestamp,children:c.label})]}),e("div",{className:n.titleSection,children:[m&&fe&&e("div",{className:n.mobileBadges,children:[!!t.typeBadge&&e("span",{className:n.mobileType,children:t.typeBadge}),t.chapterBadge&&e("span",{className:n.mobileEp,children:t.chapterBadge})]}),E?.title!==!1&&e("div",{className:n.title,title:O,children:e("span",{className:n.titleText,children:O})}),be&&i&&e("div",{className:n.metaRow,children:i})]})]}),H&&e(Ve,{isOpen:H,title:"Content Warning",onClose:()=>S(!1),children:e("div",{style:{padding:"1rem",textAlign:"center"},children:[e("p",{children:"This title contains mature content intended for adult audiences."}),e("p",{children:["By proceeding, you confirm that you are ",e("strong",{children:"18 years of age or older"})," ","(or the age of majority in your jurisdiction) and wish to view this content."]}),e("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"1rem"},children:["You can reset this preference at any time in the ",e("strong",{children:"Settings"})," page."]}),e("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[e(Q,{variant:"secondary",onClick:()=>S(!1),children:"Go Back"}),e(Q,{onClick:Ce,children:"I'm 18+, Continue"})]})]})}),ge&&e("button",{className:n.removeBtn,onClick:Te,"aria-label":"Remove",children:e(v,{name:"times",size:10})}),C&&!m&&!h&&e("button",{className:n.infoBtn,onMouseEnter:se,onMouseLeave:ae,"aria-label":"Info",children:e(v,{name:"info",size:11})}),g&&L&&G?g(G,{close:$,onMouseEnter:le,onMouseLeave:ce}):null]})});export{dn as M,cn as a,n as m,R as p};
|
|
1
|
+
import{d as y,g as T,u as e,S as ee,$ as Ne,h as K,A as x,q as d,N as Ee,a as Se,L as Ie}from"./vendor-core-DfaOB3Rn.js";import{a as Re,b as Ae,f as Le,s as $e}from"./vendor-ui-3qrARCPr.js";import{I as v}from"./vendor-icons-DrybRNxP.js";import{t as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-gMxawd-E.js";import{u as Ge}from"./useIsMobile-Dvx1uJ82.js";const We="_popupPortal_7glox_1",Ye="_popupContent_7glox_6",je="_popupBackdrop_7glox_31",Fe="_mobile_7glox_38",Xe="_header_7glox_62",qe="_title_7glox_67",He="_body_7glox_87",Je="_metaRow_7glox_94",Ke="_metaItem_7glox_101",Qe="_scoreIcon_7glox_107",Ze="_synopsis_7glox_111",et="_details_7glox_121",tt="_detailItem_7glox_129",nt="_genres_7glox_133",ot="_genre_7glox_133",rt="_footer_7glox_148",st="_primaryAction_7glox_157",at="_watchBtn_7glox_161",lt="_secondaryActions_7glox_184",ct="_watchlistBtn_7glox_189",it="_detailsBtn_7glox_190",dt="_active_7glox_216",ut="_loading_7glox_227",_t="_spinner_7glox_237",R={popupPortal:We,popupContent:Ye,popupBackdrop:je,mobile:Fe,header:Xe,title:qe,body:He,metaRow:Je,metaItem:Ke,scoreIcon:Qe,synopsis:Ze,details:et,detailItem:tt,genres:nt,genre:ot,footer:rt,primaryAction:st,watchBtn:at,secondaryActions:lt,watchlistBtn:ct,detailsBtn:it,active:dt,loading:ut,spinner:_t},cn=({anchorRect:t,onMouseEnter:a,onMouseLeave:l,onRequestClose:c,children:u})=>{const[i]=y(()=>window.matchMedia("(pointer: coarse)").matches),r=T.useMemo(()=>({getBoundingClientRect:()=>t}),[t]),{refs:w,floatingStyles:b}=Re({placement:"right-start",middleware:[Le({fallbackAxisSideDirection:"start"}),$e({padding:20})],whileElementsMounted:Ae});T.useEffect(()=>{w.setPositionReference(r)},[w,r]),T.useEffect(()=>{if(!i)return;const C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C}},[i]);const _=e(ee,{children:[i&&e("div",{className:R.popupBackdrop,onClick:()=>c?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:l,children:e("div",{className:R.popupContent,children:u})})]});return Ne(_,document.body)},pt=t=>!t||t.trim()===""?!0:t.includes("placeholder");function gt(t,a){const[l,c]=y(a);return K(()=>{c(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke.data.showMeta.query({id:t}).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&c(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:l}}const mt="_cardWrapper_w7bu0_1",ft="_card_w7bu0_1",ht="_cardButton_w7bu0_35",bt="_hoverOverlay_w7bu0_60",Bt="_matureOverlay_w7bu0_81",wt="_posterContainer_w7bu0_91",vt="_horizontal_w7bu0_100",yt="_posterImg_w7bu0_104",Ct="_blurred_w7bu0_116",Mt="_flat_w7bu0_139",xt="_loaded_w7bu0_143",Tt="_posterGradient_w7bu0_147",Pt="_progressSection_w7bu0_167",Nt="_titleSection_w7bu0_174",Et="_title_w7bu0_174",St="_titleText_w7bu0_193",It="_badge_w7bu0_205",Rt="_typeBadge_w7bu0_216 _badge_w7bu0_205",At="_epBadge_w7bu0_225 _badge_w7bu0_205",Lt="_airTime_w7bu0_234",$t="_adultBadge_w7bu0_241 _badge_w7bu0_205",kt="_gated_w7bu0_254",Ot="_notAiredBadge_w7bu0_260 _badge_w7bu0_205",zt="_metaRow_w7bu0_275",Dt="_metaItem_w7bu0_286",Ut="_progressContainer_w7bu0_303",Vt="_progressBar_w7bu0_311",Gt="_timestamp_w7bu0_318",Wt="_removeBtn_w7bu0_323",Yt="_infoBtn_w7bu0_324",jt="_mobileBadges_w7bu0_375",Ft="_mobileBadgeBase_w7bu0_382",Xt="_mobileType_w7bu0_390 _mobileBadgeBase_w7bu0_382",qt="_mobileEp_w7bu0_397 _mobileBadgeBase_w7bu0_382",Ht="_vertical_w7bu0_489",Jt="_placeholder_w7bu0_504",Kt="_placeholderText_w7bu0_513",Qt="_lowEnd_w7bu0_520",n={cardWrapper:mt,card:ft,cardButton:ht,hoverOverlay:bt,matureOverlay:Bt,posterContainer:wt,horizontal:vt,posterImg:yt,blurred:Ct,flat:Mt,loaded:xt,posterGradient:Tt,progressSection:Pt,titleSection:Nt,title:Et,titleText:St,badge:It,typeBadge:Rt,epBadge:At,airTime:Lt,adultBadge:$t,gated:kt,notAiredBadge:Ot,metaRow:zt,metaItem:Dt,progressContainer:Ut,progressBar:Vt,timestamp:Gt,removeBtn:Wt,infoBtn:Yt,mobileBadges:jt,mobileBadgeBase:Ft,mobileType:Xt,mobileEp:qt,vertical:Ht,placeholder:Jt,placeholderText:Kt,lowEnd:Qt},Zt=500,Z=20,en=300;function tn(t){const a=x(null),l=x(null),c=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),w=d(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),b=d(s=>{a.current&&clearTimeout(a.current),a.current=setTimeout(s,en)},[]),_=d((s,p=!1)=>{c.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,c.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),l.current=setTimeout(()=>{l.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!l.current)return;const p=Math.abs(s.clientX-u.current.x),m=Math.abs(s.clientY-u.current.y);(p>Z||m>Z)&&r()},[r]),g=d(()=>{r(),i.current=null},[r]),P=d((s,p)=>{s.preventDefault(),s.stopPropagation(),i.current==="touch"?l.current&&(clearTimeout(l.current),l.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!c.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>c.current?(c.current=!1,!0):!1,[]);return{longPressFiredRef:c,cancelLongPress:r,clearPopupTimeout:w,schedulePopupClose:b,openViaHold:_,handlePointerDown:C,handlePointerMove:B,handlePointerUpOrCancel:g,handleContextMenu:P,consumeLongPressClick:A}}const z={elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!0}}},dn=Ee(({item:t,linkTo:a,hoverIcon:l,progress:c,showProgress:u=!1,metaRow:i,display:r,layout:w="vertical",onRemove:b,showRemoveButton:_,showInfoButton:C=!1,onOpenDetails:B,renderPopup:g,onPopupHoverIntent:P,rawThumbnail:A,enrichedId:s})=>{const p=Se(),m=Ge(),{titlePreference:te}=Oe(),{lowEndMode:M}=ze(),[ne,oe]=y(!1),[re,D]=y(!1),{thumbnail:U}=gt(s,t.thumbnail),[L,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},$=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose($)},[f,$]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},le=()=>{j()},ce=()=>{g&&k()},ie=o=>{f.handlePointerDown(o,h)},de=o=>{f.handlePointerMove(o)},F=()=>{f.handlePointerUpOrCancel()},ue=o=>{if(B){o.preventDefault(),o.stopPropagation(),B(o.currentTarget.getBoundingClientRect());return}if(g){f.handleContextMenu(o,h);return}f.handleContextMenu(o,h)},X={...r,elements:{...z.elements,...r?.elements||{},poster:{...z.elements?.poster,...r?.elements?.poster||{}},info:{...z.elements?.info,...r?.elements?.info||{}}}},O=t[te]||t.title,N=X.elements?.poster,E=X.elements?.info,_e=(N?.typeBadge??!0)&&!!t.typeBadge,pe=(N?.chapterBadge??!0)&&!!t.chapterBadge,ge=_??N?.removeButton??!!b,me=N?.adultBadge??!0,fe=E?.mobileBadges??!0,he=E?.progress??!0,be=E?.meta??!0,Be=u&&!!c&&c.percent>0,q=!!t.isAdult,[we,ve]=De("agreedToViewMature","false"),ye=we==="true",[H,S]=T.useState(!1),I=T.useRef(null),Ce=()=>{ve("true"),S(!1),I.current&&(p(I.current),I.current=null)},h=q&&!ye,Me=o=>{if(f.consumeLongPressClick()){o.preventDefault(),o.stopPropagation();return}h&&(o.preventDefault(),o.stopPropagation(),I.current=a,S(!0))},xe=l==="book"?e(v,{name:"book",size:28}):l==="play"?e(v,{name:"play",size:28}):l==="info"?e(v,{name:"info-circle",size:28}):e(v,{name:"info-circle",size:28}),Te=d(o=>{o.preventDefault(),o.stopPropagation(),b&&b(t.id)},[b,t.id]),Pe=A?U??t.thumbnail:Ue(U,M?100:150,M?150:200);return e("div",{className:`${n.cardWrapper} ${M?n.lowEnd:""}`,onMouseEnter:()=>{D(!0),P?.(!0),L&&j()},onMouseLeave:()=>{D(!1),P?.(!1),L&&k()},children:[e(Ie,{to:a,className:`${n.card} ${n[w]} ${h?n.cardButton:""}`,onClick:Me,onContextMenu:ue,onPointerDown:ie,onPointerMove:de,onPointerUp:F,onPointerCancel:F,children:[e("div",{className:n.posterContainer,children:[h&&e("div",{className:`${n.matureOverlay} ${M?n.flat:""}`}),e("img",{src:Pe,alt:O,className:`${n.posterImg} ${ne?n.loaded:""} ${h&&!M?n.blurred:""}`,loading:"lazy",decoding:"async",onLoad:()=>oe(!0)}),!m&&e(ee,{children:[_e&&e("div",{className:n.typeBadge,children:t.typeBadge}),pe&&e("div",{className:n.epBadge,children:[t.chapterBadge,t.airMeta&&e("span",{className:n.airTime,children:t.airMeta})]})]}),me&&q&&e("div",{className:`${n.adultBadge} ${h?n.gated:""}`,children:"18+"}),t.notAired&&e("div",{className:n.notAiredBadge,children:"NOT AIRED"}),!m&&re&&e("div",{className:n.hoverOverlay,children:xe})]}),he&&u&&Be&&c&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${c.percent}%`}})}),e("div",{className:n.timestamp,children:c.label})]}),e("div",{className:n.titleSection,children:[m&&fe&&e("div",{className:n.mobileBadges,children:[!!t.typeBadge&&e("span",{className:n.mobileType,children:t.typeBadge}),t.chapterBadge&&e("span",{className:n.mobileEp,children:t.chapterBadge})]}),E?.title!==!1&&e("div",{className:n.title,title:O,children:e("span",{className:n.titleText,children:O})}),be&&i&&e("div",{className:n.metaRow,children:i})]})]}),H&&e(Ve,{isOpen:H,title:"Content Warning",onClose:()=>S(!1),children:e("div",{style:{padding:"1rem",textAlign:"center"},children:[e("p",{children:"This title contains mature content intended for adult audiences."}),e("p",{children:["By proceeding, you confirm that you are ",e("strong",{children:"18 years of age or older"})," ","(or the age of majority in your jurisdiction) and wish to view this content."]}),e("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"1rem"},children:["You can reset this preference at any time in the ",e("strong",{children:"Settings"})," page."]}),e("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[e(Q,{variant:"secondary",onClick:()=>S(!1),children:"Go Back"}),e(Q,{onClick:Ce,children:"I'm 18+, Continue"})]})]})}),ge&&e("button",{className:n.removeBtn,onClick:Te,"aria-label":"Remove",children:e(v,{name:"times",size:10})}),C&&!m&&!h&&e("button",{className:n.infoBtn,onMouseEnter:se,onMouseLeave:ae,"aria-label":"Info",children:e(v,{name:"info",size:11})}),g&&L&&G?g(G,{close:$,onMouseEnter:le,onMouseLeave:ce}):null]})});export{dn as M,cn as a,n as m,R as p};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as L,d as b,g as _e,h as F,u as e,S as w,$ as Ve,p as Ze,T as G}from"./vendor-core-DfaOB3Rn.js";import{t as Ce,W as je,h as O,z as P}from"./index-CVB5dYhT.js";import{I as g}from"./vendor-icons-DrybRNxP.js";import{a as n}from"./Asmr.module-ChUXDZKx.js";import{r as h}from"./Radio.module-DGSZLpKM.js";import{b as J,u as Pe,a as Re}from"./vendor-query-BBT5_sHx.js";function Be(a){if(!Number.isFinite(a)||a<0)return"0:00";const s=Math.floor(a/60),f=Math.floor(a%60);return`${s}:${String(f).padStart(2,"0")}`}const Je=({track:a,shuffle:s,onToggleShuffle:f,onTrackStep:R,onTrackFailed:be,onClose:se,liked:W,likeVisible:K,likePending:re,onToggleLike:X})=>{const M=L(null),ee=L(!1),[H,I]=b(!1),[he,u]=b(!0),[k,U]=b(!1),[$,A]=b(0),[z,oe]=b(0),[T,Y]=b(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[E,le]=b(()=>localStorage.getItem("musicAutoplay")!=="false"),V=L(T);V.current=T;const N=L(E);N.current=E;const y=L(0),D=L(0),B=L(null),Q=L("");Q.current||(Q.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const te=`/api/music/audio?videoId=${encodeURIComponent(a.id)}`,q=_e.useCallback(()=>{B.current&&(window.clearTimeout(B.current),B.current=null)},[]),Z=_e.useCallback(r=>{const o=M.current;if(!o)return;q(),u(!0),U(!1);const v=()=>{if(o.removeEventListener("loadedmetadata",v),r>5&&Number.isFinite(o.duration)&&r<o.duration-5)try{o.currentTime=r}catch{}};o.addEventListener("loadedmetadata",v),o.src=te,o.load(),o.volume=V.current,o.play().catch(()=>{})},[te,q]),ve=()=>{u(!1),U(!0),be?.(a),N.current&&R(1)},ce=()=>{if(!B.current){if(D.current>=3){ve();return}D.current+=1,B.current=window.setTimeout(()=>{B.current=null,Z(y.current)},5e3)}},ke=()=>{D.current=0,Z(y.current)};F(()=>{y.current=0,D.current=0,I(!1),A(0),oe(0);const r=M.current;return Z(y.current),()=>{q(),r&&r.removeAttribute("src")}},[Z,q]),F(()=>{const r=M.current;r&&(r.volume=T)},[T]),F(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const _=a.thumbnails?.[a.thumbnails.length-1]?.url??null,ne=_e.useCallback(r=>{const o=M.current;Ce.discord.musicPresence.mutate({title:a.title,artistLabel:a.artists,isPlaying:r,thumbnail:_||"",currentTime:o?.currentTime??0,duration:Number.isFinite(o?.duration??NaN)?o?.duration:0,sessionId:Q.current}).catch(()=>{}),Ce.discord.heartbeat.mutate({sessionId:Q.current}).catch(()=>{})},[a,_]);F(()=>{ne(H)},[ne,H,a.id]),F(()=>{if(!H)return;const r=window.setInterval(()=>ne(!0),15e3);return()=>window.clearInterval(r)},[H,ne]),F(()=>{const r=Q.current,o=()=>je(r),v=()=>o(),ae=()=>{document.visibilityState==="hidden"&&o()};return window.addEventListener("pagehide",v),window.addEventListener("beforeunload",v),document.addEventListener("visibilitychange",ae),()=>{window.removeEventListener("pagehide",v),window.removeEventListener("beforeunload",v),document.removeEventListener("visibilitychange",ae),o()}},[]);const pe=()=>{const r=M.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},[Ne,ge]=b(!1);F(()=>{ge(!1)},[_]);const ue=`${a.title} — ${a.artists}`,we=e(w,{children:[e("div",{className:n.playerButtons,children:[e("button",{className:n.playerBtn,onClick:()=>R(-1),"aria-label":"Previous track",children:e(g,{name:"step-backward"})}),e("button",{className:`${n.playerBtn} ${n.playBtn}`,onClick:pe,"aria-label":H?"Pause":"Play",children:H?e(g,{name:"pause"}):e(g,{name:"play"})}),e("button",{className:n.playerBtn,onClick:()=>R(1),"aria-label":"Next track",children:e(g,{name:"step-forward"})}),k&&e("button",{className:n.playerBtn,onClick:ke,title:"Retry playback","aria-label":"Retry playback",children:e(g,{name:"redo"})})]}),e("div",{className:n.seekRow,children:[e("span",{className:n.timeLabel,children:Be($)}),e("input",{className:n.seekBar,type:"range",min:0,max:z||0,step:.1,value:Math.min($,z||0),onChange:r=>{const o=M.current;!o||!Number.isFinite(o.duration)||(o.currentTime=parseFloat(r.target.value),A(o.currentTime))},onPointerDown:()=>{ee.current=!0},onPointerUp:()=>{ee.current=!1},style:{"--played-percent":`${z>0?$/z*100:0}%`},"aria-label":"Seek"}),e("span",{className:n.timeLabel,children:Be(z)}),he&&!k&&e("span",{className:n.timeLabel,children:"loading…"})]})]}),fe=e(w,{children:[a.thumbnails?.[0]?.url&&!Ne&&e("img",{src:a.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async",onError:()=>ge(!0)}),e("div",{className:n.playerInfo,children:[e("p",{className:n.playerTitle,title:ue,children:ue}),e("p",{className:n.playerTrack,children:a.artists})]}),e("div",{className:n.playerControls,children:we}),e("div",{className:n.playerRight,children:[T===0?e(g,{name:"volume-mute",className:n.volumeIcon}):T<.5?e(g,{name:"volume-down",className:n.volumeIcon}):e(g,{name:"volume-up",className:n.volumeIcon}),e("input",{className:n.volumeBar,type:"range",min:0,max:1,step:.01,value:T,onChange:r=>{const o=parseFloat(r.target.value);Y(o),localStorage.setItem("musicVolume",String(o))},style:{"--volume-percent":`${T*100}%`},"aria-label":"Volume"})]}),e("div",{className:n.playerActions,children:[K&&X&&e("button",{className:`${n.playerBtn} ${W?n.playerBtnActive:""}`,onClick:X,disabled:re,title:W?"Remove from Liked Music":"Add to Liked Music","aria-label":W?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!W,children:e(g,{name:"heart"})}),e("button",{className:`${n.playerBtn} ${s?n.playerBtnActive:""}`,onClick:f,title:s?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":s,children:e(g,{name:"shuffle"})}),e("button",{className:`${n.playerBtn} ${E?n.playerBtnActive:""}`,onClick:()=>{le(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:E?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":E,children:e(g,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(a.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:n.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(g,{name:"external-link-alt"})}),e("button",{className:n.playerBtn,onClick:se,"aria-label":"Close player",children:e(g,{name:"times"})})]})]});return Ve(e(w,{children:[e("audio",{ref:M,preload:"none",onPlay:()=>{I(!0),u(!1),U(!1),D.current=0,q()},onPause:()=>I(!1),onWaiting:()=>{k||u(!0)},onPlaying:()=>{u(!1),D.current=0,q()},onTimeUpdate:r=>{const o=r.target.currentTime;y.current=o,q(),ee.current||A(o)},onStalled:()=>{ce()},onLoadedMetadata:r=>{const o=r.target.duration;Number.isFinite(o)&&oe(o)},onDurationChange:r=>{const o=r.target.duration;Number.isFinite(o)&&oe(o)},onError:()=>{ce()},onEnded:()=>{N.current&&R(1)}}),e("div",{className:n.playerBar,children:fe})]}),document.body)},Ke=()=>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."})]})]}),me=300*1e3,Xe=()=>{const a=O();return J({...a.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:s=>s.state.data?.authenticated?!1:3e3,retry:1})},et=()=>{const a=O(),s=Pe();return Re(a.music.authStart.mutationOptions({onSuccess:(f,R)=>{localStorage.setItem("ytmusic_cookie",R.cookie??""),s.invalidateQueries(a.music.pathFilter())}}))},tt=()=>{const a=O(),s=Pe();return Re(a.music.signOut.mutationOptions({onSuccess:()=>{s.invalidateQueries(a.music.pathFilter())}}))},nt=a=>{const s=O();return J({...s.music.search.queryOptions({q:a}),enabled:a.trim().length>0,staleTime:me,retry:1})},at=a=>{const s=O();return J({...s.music.library.queryOptions(),enabled:a,staleTime:me,retry:1})},it=a=>{const s=O();return J({...s.music.track.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},st=a=>{const s=O();return J({...s.music.playlist.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},rt=a=>{const s=O();return J({...s.music.upnext.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},ot=a=>{const s=O();return J({...s.music.likes.queryOptions(),enabled:a,staleTime:120*1e3,retry:1})},lt=()=>{const a=O(),s=Pe();return Re(a.music.like.mutationOptions({onSuccess:()=>{s.invalidateQueries(a.music.pathFilter())}}))},ct="_authRow_10tvv_1",ut="_btn_10tvv_9",dt="_btnGhost_10tvv_42",mt="_cookieForm_10tvv_74",ht="_cookieInput_10tvv_83",pt="_link_10tvv_99",gt="_contentLayout_10tvv_109",ft="_mainCol_10tvv_116",yt="_upnextAside_10tvv_120",bt="_upnextHeader_10tvv_131",vt="_upnextTitle_10tvv_139",kt="_upnextActions_10tvv_149",Nt="_nowPlayingLabel_10tvv_156",wt="_nowPlayingWrap_10tvv_168",St="_likeBtn_10tvv_172",Tt="_likeActive_10tvv_196",p={authRow:ct,btn:ut,btnGhost:dt,cookieForm:mt,cookieInput:ht,link:pt,contentLayout:gt,mainCol:ft,upnextAside:yt,upnextHeader:bt,upnextTitle:vt,upnextActions:kt,nowPlayingLabel:Nt,nowPlayingWrap:wt,likeBtn:St,likeActive:Tt};function Fe(a){const s=a.trim();if(!s)return null;const f=s.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??s.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return f||(/^[A-Za-z0-9_-]{11}$/.test(s)?s:null)}const xt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",It=()=>{const[a,s]=Ze(),f=Fe(a.get("v")??""),[R,be]=b(""),[se,W]=b(""),[K,re]=b(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[X,M]=b(!1),[ee,H]=b(()=>localStorage.getItem("musicShuffle")==="true"),[I,he]=b(()=>localStorage.getItem("musicRadio")!=="false"),[u,k]=b(null),[U,$]=b([]),[A,z]=b(null),[oe,T]=b({}),Y=L([]);Y.current=U;const E=L(null);E.current=u;const le=L(!1),V=L(new Set),{data:N}=Xe(),y=et(),D=tt(),B=typeof navigator<"u"?navigator.userAgent:"",Q=/android/i.test(B),te=/firefox|fxios/i.test(B)&&!Q,q=!te&&!Q&&/chrome|chromium|edg|brave/i.test(B),Z=te||q,ve=()=>{if(X)return;M(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",c),M(!1),P.error("Helper not detected — install the Dango Helper extension first.")},3e3),c=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",c),M(!1),m?.ok&&m.cookie){const l=m.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(l.includes("…")||l.includes("...")){P.error(`Helper returned a truncated cookie (${l.length} chars) — reload music.youtube.com and Extract again.`);return}re(l),P.success("Cookie extracted from helper — signing in…"),y.mutate({cookie:l})}else m?.error==="NO_COOKIE"?P.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):P.error("Helper request failed — try again.")};window.addEventListener("dango:ytmusic-cookie",c),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:ce,isLoading:ke}=nt(se),{data:_,isLoading:ne,isFetching:pe,error:Ne,refetch:ge}=at(N?.authenticated===!0),{data:ue,isLoading:we}=st(A?.id??null),{data:fe,isLoading:Se}=rt(u?.id??null),{data:r}=ot(N?.authenticated===!0),o=lt(),v=G(()=>ce?.tracks||[],[ce]),ae=G(()=>_?.playlists||[],[_]),C=G(()=>_?.tracks||[],[_]),j=G(()=>ue?.tracks||[],[ue]),S=G(()=>{const t=fe?.tracks||[];return u?t.filter(i=>i.id!==u.id):t},[fe,u]),Oe=G(()=>new Set(r?.likedIds||[]),[r]),Te=t=>oe[t.id]??(Oe.has(t.id)||t.liked===!0);F(()=>{N?.authenticated!==!0&&T({})},[N?.authenticated]);const De=G(()=>[...v,...j,...C,...S],[v,j,C,S]),qe=f&&u?.id!==f&&!De.some(t=>t.id===f)?f:null,{data:Ie}=it(qe),xe=u?.id;F(()=>{document.title=u?`${u.title} - dango`:"Music - dango"},[u]),F(()=>{if(!f){xe&&k(null);return}if(xe===f)return;const t=d=>{const m=d.find(l=>l.id===f);return m?(k(m),$(l=>l.some(ie=>ie.id===f)?l:d.length>0?d:[m]),!0):!1};if(t(v)||t(j)||t(C))return;const i=S.find(d=>d.id===f);if(i){k(i),$(d=>d.some(m=>m.id===i.id)?d:[i]);return}const c=Ie?.track;c&&c.id===f&&(k(c),$(d=>d.some(m=>m.id===c.id)?d:[c]))},[f,xe,v,j,C,S,Ie]);const Le=(t,i)=>{V.current.delete(t.id),k(t),$(i.length>0?i:[t]),s({v:t.id})},He=t=>{V.current.add(t.id),P.error(`Couldn't play “${t.title}” — skipped.`)},Ue=async()=>{if(le.current)return;const t=Y.current,i=t[t.length-1]??E.current;if(i){le.current=!0;try{const c=await Ce.music.upnext.query({id:i.id}),d=new Set(t.map(l=>l.id)),m=(c.tracks||[]).filter(l=>!d.has(l.id)&&!V.current.has(l.id));if(m.length===0){const l=Y.current[0];l&&(k(l),s({v:l.id}));return}$([...Y.current,...m]),k(m[0]),s({v:m[0].id})}catch{const c=Y.current[0];c&&(k(c),s({v:c.id}))}finally{le.current=!1}}},ze=t=>{const i=Y.current,c=E.current;if(!c||i.length===0)return;const d=i.findIndex(x=>x.id===c.id);if(t>0&&I&&(d<0||d===i.length-1)){Ue();return}const m=x=>V.current.has(x.id),l=i.length;let ie;if(ee&&l>1){let x=Math.floor(Math.random()*l);for(let Me=0;Me<l&&(x===d||m(i[x]));Me++)x=Math.floor(Math.random()*l);ie=i[x]}else{const x=t>0?1:-1;let ye=(((d<0?x>0?-1:0:d)+x)%l+l)%l;for(let Ee=1;Ee<l&&m(i[ye]);Ee++)ye=((ye+x)%l+l)%l;ie=i[ye]}k(ie),s({v:ie.id})},Ye=()=>{if(I){he(!1),localStorage.setItem("musicRadio","false");return}const t=E.current;if(!t)return;if(S.length===0){P.error("No radio suggestions for this song yet.");return}const i=new Set,c=[];for(const d of[t,...S])i.has(d.id)||(i.add(d.id),c.push(d));he(!0),localStorage.setItem("musicRadio","true"),$(c),P.success(`Radio started — ${S.length} songs queued.`)},$e=t=>{if(N?.authenticated!==!0){P.error("Sign in to like songs.");return}const i=!Te(t);T(c=>({...c,[t.id]:i})),o.mutate({id:t.id,like:i},{onError:()=>{T(c=>{const d={...c};return delete d[t.id],d}),P.error("Like action failed — try again.")}})},Qe=()=>{H(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Ge=t=>e("button",{className:h.stationRow,onClick:()=>z(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),t.subtitle&&e("span",{className:h.stationSub,children:t.subtitle})]})]},t.id),de=(t,i,c)=>{const d=u?.id===t.id,m=Te(t),l=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${h.stationRow} ${d?h.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>c?c(t):Le(t,i),className:h.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),e("span",{className:h.stationSub,children:[t.artists,l?` · ${l}`:""]})]})]}),N?.authenticated===!0&&e("button",{className:`${p.likeBtn} ${m?p.likeActive:""}`,onClick:()=>$e(t),disabled:o.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(g,{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(g,{name:"external-link-alt"})})]},t.id)},Ae=G(()=>{if(!u)return S;const t=new Set,i=[];for(const c of[u,...S])t.has(c.id)||(t.add(c.id),i.push(c));return i},[u,S]),We=t=>{Le(t,Ae)};return e("div",{className:`${n.page} ${u?n.pageWithPlayer:""}`,children:[e("div",{className:n.header,children:[e("h1",{className:n.pageTitle,children:[e(g,{name:"headphones"})," Music"]}),e("form",{className:n.searchForm,onSubmit:t=>{t.preventDefault();const i=Fe(R);i?(W(""),s({v:i})):W(R)},children:[e("input",{className:n.searchInput,value:R,onChange:t=>be(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:n.searchBtn,type:"submit","aria-label":"Search",children:e(g,{name:"search"})})]})]}),e("div",{className:p.authRow,children:[N?.authenticated?e(w,{children:[e("span",{className:n.statusMsg,children:["Signed in to YouTube Music",_&&` — ${_.tracks.length} songs, ${_.playlists.length} playlists`]}),e("button",{className:p.btnGhost,onClick:()=>D.mutate(),disabled:D.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=K.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){P.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==K&&re(i),y.mutate({cookie:i})}},className:p.cookieForm,children:[e("input",{className:p.cookieInput,value:K,onChange:t=>re(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:p.btn,type:"submit",disabled:y.isPending||!K.trim(),children:y.isPending?"Checking…":"Sign in"}),Z&&e("button",{className:p.btnGhost,type:"button",onClick:ve,disabled:X||y.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:X?"Extracting…":"Extract from helper"})]}),Z&&e("p",{className:n.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:xt,target:"_blank",rel:"noreferrer",className:p.link,children:"dango-extension.zip"})," ","then"," ",te?e(w,{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(w,{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(Ke,{})]}),y.isSuccess&&e("p",{className:n.statusMsg,children:["Signed in — found ",y.data.tracks," songs and ",y.data.playlists," ","playlists."]}),y.isError&&e("p",{className:n.statusMsg,children:y.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!N?.authenticated&&!y.isError&&!y.isSuccess&&e("p",{className:n.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:u?p.contentLayout:void 0,children:[e("div",{className:p.mainCol,children:se?e(w,{children:[e("h2",{className:h.sectionTitle,children:["Results for “",se,"”"]}),ke?e("p",{className:n.statusMsg,children:"Searching…"}):v.length===0?e("p",{className:n.statusMsg,children:"No tracks found."}):e("div",{className:h.stationList,children:v.map(t=>de(t,v))})]}):N?.authenticated?e(w,{children:[e("h2",{className:h.sectionTitle,children:"Your library"}),ne?e("p",{className:n.statusMsg,children:"Loading library…"}):ae.length===0&&C.length===0&&!A?e(w,{children:[e("p",{className:n.statusMsg,children:Ne?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>{ge()},disabled:pe,"aria-label":"Retry loading library",children:pe?"Retrying…":"Retry"})}),e("p",{className:n.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(w,{children:[ae.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:"Playlists"}),e("div",{className:h.stationList,children:ae.map(t=>Ge(t))})]}),C.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:["Liked songs (",C.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>Le(C[0],C),"aria-label":"Play all liked songs",children:[e(g,{name:"play"})," Play all"]})}),e("div",{className:h.stationList,children:C.map(t=>de(t,C))})]}),A?e(w,{children:[e("button",{className:p.btnGhost,onClick:()=>z(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:h.sectionTitle,children:A.title}),we?e("p",{className:n.statusMsg,children:"Loading playlist…"}):j.length===0?e("p",{className:n.statusMsg,children:"No tracks in this playlist."}):e("div",{className:h.stationList,children:j.map(t=>de(t,j))})]}):null]})]}):e("p",{className:n.statusMsg,children:"Search above, or sign in to see your library."})}),u&&e("aside",{className:p.upnextAside,"aria-label":"Up next",children:[e("div",{className:p.upnextHeader,children:e("span",{className:p.upnextTitle,children:[e(g,{name:"list-ul"})," Up Next"]})}),e("div",{className:p.nowPlayingWrap,children:[e("p",{className:p.nowPlayingLabel,children:"Now playing"}),de(u,U.length>0?U:[u])]}),e("div",{className:p.upnextActions,children:e("button",{className:p.btnGhost,onClick:Ye,disabled:!I&&(Se||S.length===0),"aria-pressed":I,title:I?"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:I?"Stop radio":"Start radio"})}),Se?e("p",{className:n.statusMsg,children:"Loading suggestions…"}):S.length===0?e("p",{className:n.statusMsg,children:"No suggestions for this song."}):e("div",{className:h.stationList,children:S.map(t=>de(t,Ae,We))})]})]}),u&&e(Je,{track:u,queue:U,shuffle:ee,onToggleShuffle:Qe,onTrackStep:ze,onTrackFailed:He,onClose:()=>{k(null),s({})},liked:u?Te(u):!1,likeVisible:N?.authenticated===!0,likePending:o.isPending,onToggleLike:()=>$e(u)})]})};export{It as default};
|
|
1
|
+
import{A as L,d as b,g as _e,h as F,u as e,S as w,$ as Ve,p as Ze,T as G}from"./vendor-core-DfaOB3Rn.js";import{t as Ce,W as je,h as O,z as P}from"./index-gMxawd-E.js";import{I as g}from"./vendor-icons-DrybRNxP.js";import{a as n}from"./Asmr.module-ChUXDZKx.js";import{r as h}from"./Radio.module-DGSZLpKM.js";import{b as J,u as Pe,a as Re}from"./vendor-query-BBT5_sHx.js";function Be(a){if(!Number.isFinite(a)||a<0)return"0:00";const s=Math.floor(a/60),f=Math.floor(a%60);return`${s}:${String(f).padStart(2,"0")}`}const Je=({track:a,shuffle:s,onToggleShuffle:f,onTrackStep:R,onTrackFailed:be,onClose:se,liked:W,likeVisible:K,likePending:re,onToggleLike:X})=>{const M=L(null),ee=L(!1),[H,I]=b(!1),[he,u]=b(!0),[k,U]=b(!1),[$,A]=b(0),[z,oe]=b(0),[T,Y]=b(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[E,le]=b(()=>localStorage.getItem("musicAutoplay")!=="false"),V=L(T);V.current=T;const N=L(E);N.current=E;const y=L(0),D=L(0),B=L(null),Q=L("");Q.current||(Q.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const te=`/api/music/audio?videoId=${encodeURIComponent(a.id)}`,q=_e.useCallback(()=>{B.current&&(window.clearTimeout(B.current),B.current=null)},[]),Z=_e.useCallback(r=>{const o=M.current;if(!o)return;q(),u(!0),U(!1);const v=()=>{if(o.removeEventListener("loadedmetadata",v),r>5&&Number.isFinite(o.duration)&&r<o.duration-5)try{o.currentTime=r}catch{}};o.addEventListener("loadedmetadata",v),o.src=te,o.load(),o.volume=V.current,o.play().catch(()=>{})},[te,q]),ve=()=>{u(!1),U(!0),be?.(a),N.current&&R(1)},ce=()=>{if(!B.current){if(D.current>=3){ve();return}D.current+=1,B.current=window.setTimeout(()=>{B.current=null,Z(y.current)},5e3)}},ke=()=>{D.current=0,Z(y.current)};F(()=>{y.current=0,D.current=0,I(!1),A(0),oe(0);const r=M.current;return Z(y.current),()=>{q(),r&&r.removeAttribute("src")}},[Z,q]),F(()=>{const r=M.current;r&&(r.volume=T)},[T]),F(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const _=a.thumbnails?.[a.thumbnails.length-1]?.url??null,ne=_e.useCallback(r=>{const o=M.current;Ce.discord.musicPresence.mutate({title:a.title,artistLabel:a.artists,isPlaying:r,thumbnail:_||"",currentTime:o?.currentTime??0,duration:Number.isFinite(o?.duration??NaN)?o?.duration:0,sessionId:Q.current}).catch(()=>{}),Ce.discord.heartbeat.mutate({sessionId:Q.current}).catch(()=>{})},[a,_]);F(()=>{ne(H)},[ne,H,a.id]),F(()=>{if(!H)return;const r=window.setInterval(()=>ne(!0),15e3);return()=>window.clearInterval(r)},[H,ne]),F(()=>{const r=Q.current,o=()=>je(r),v=()=>o(),ae=()=>{document.visibilityState==="hidden"&&o()};return window.addEventListener("pagehide",v),window.addEventListener("beforeunload",v),document.addEventListener("visibilitychange",ae),()=>{window.removeEventListener("pagehide",v),window.removeEventListener("beforeunload",v),document.removeEventListener("visibilitychange",ae),o()}},[]);const pe=()=>{const r=M.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},[Ne,ge]=b(!1);F(()=>{ge(!1)},[_]);const ue=`${a.title} — ${a.artists}`,we=e(w,{children:[e("div",{className:n.playerButtons,children:[e("button",{className:n.playerBtn,onClick:()=>R(-1),"aria-label":"Previous track",children:e(g,{name:"step-backward"})}),e("button",{className:`${n.playerBtn} ${n.playBtn}`,onClick:pe,"aria-label":H?"Pause":"Play",children:H?e(g,{name:"pause"}):e(g,{name:"play"})}),e("button",{className:n.playerBtn,onClick:()=>R(1),"aria-label":"Next track",children:e(g,{name:"step-forward"})}),k&&e("button",{className:n.playerBtn,onClick:ke,title:"Retry playback","aria-label":"Retry playback",children:e(g,{name:"redo"})})]}),e("div",{className:n.seekRow,children:[e("span",{className:n.timeLabel,children:Be($)}),e("input",{className:n.seekBar,type:"range",min:0,max:z||0,step:.1,value:Math.min($,z||0),onChange:r=>{const o=M.current;!o||!Number.isFinite(o.duration)||(o.currentTime=parseFloat(r.target.value),A(o.currentTime))},onPointerDown:()=>{ee.current=!0},onPointerUp:()=>{ee.current=!1},style:{"--played-percent":`${z>0?$/z*100:0}%`},"aria-label":"Seek"}),e("span",{className:n.timeLabel,children:Be(z)}),he&&!k&&e("span",{className:n.timeLabel,children:"loading…"})]})]}),fe=e(w,{children:[a.thumbnails?.[0]?.url&&!Ne&&e("img",{src:a.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async",onError:()=>ge(!0)}),e("div",{className:n.playerInfo,children:[e("p",{className:n.playerTitle,title:ue,children:ue}),e("p",{className:n.playerTrack,children:a.artists})]}),e("div",{className:n.playerControls,children:we}),e("div",{className:n.playerRight,children:[T===0?e(g,{name:"volume-mute",className:n.volumeIcon}):T<.5?e(g,{name:"volume-down",className:n.volumeIcon}):e(g,{name:"volume-up",className:n.volumeIcon}),e("input",{className:n.volumeBar,type:"range",min:0,max:1,step:.01,value:T,onChange:r=>{const o=parseFloat(r.target.value);Y(o),localStorage.setItem("musicVolume",String(o))},style:{"--volume-percent":`${T*100}%`},"aria-label":"Volume"})]}),e("div",{className:n.playerActions,children:[K&&X&&e("button",{className:`${n.playerBtn} ${W?n.playerBtnActive:""}`,onClick:X,disabled:re,title:W?"Remove from Liked Music":"Add to Liked Music","aria-label":W?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!W,children:e(g,{name:"heart"})}),e("button",{className:`${n.playerBtn} ${s?n.playerBtnActive:""}`,onClick:f,title:s?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":s,children:e(g,{name:"shuffle"})}),e("button",{className:`${n.playerBtn} ${E?n.playerBtnActive:""}`,onClick:()=>{le(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:E?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":E,children:e(g,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(a.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:n.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(g,{name:"external-link-alt"})}),e("button",{className:n.playerBtn,onClick:se,"aria-label":"Close player",children:e(g,{name:"times"})})]})]});return Ve(e(w,{children:[e("audio",{ref:M,preload:"none",onPlay:()=>{I(!0),u(!1),U(!1),D.current=0,q()},onPause:()=>I(!1),onWaiting:()=>{k||u(!0)},onPlaying:()=>{u(!1),D.current=0,q()},onTimeUpdate:r=>{const o=r.target.currentTime;y.current=o,q(),ee.current||A(o)},onStalled:()=>{ce()},onLoadedMetadata:r=>{const o=r.target.duration;Number.isFinite(o)&&oe(o)},onDurationChange:r=>{const o=r.target.duration;Number.isFinite(o)&&oe(o)},onError:()=>{ce()},onEnded:()=>{N.current&&R(1)}}),e("div",{className:n.playerBar,children:fe})]}),document.body)},Ke=()=>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."})]})]}),me=300*1e3,Xe=()=>{const a=O();return J({...a.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:s=>s.state.data?.authenticated?!1:3e3,retry:1})},et=()=>{const a=O(),s=Pe();return Re(a.music.authStart.mutationOptions({onSuccess:(f,R)=>{localStorage.setItem("ytmusic_cookie",R.cookie??""),s.invalidateQueries(a.music.pathFilter())}}))},tt=()=>{const a=O(),s=Pe();return Re(a.music.signOut.mutationOptions({onSuccess:()=>{s.invalidateQueries(a.music.pathFilter())}}))},nt=a=>{const s=O();return J({...s.music.search.queryOptions({q:a}),enabled:a.trim().length>0,staleTime:me,retry:1})},at=a=>{const s=O();return J({...s.music.library.queryOptions(),enabled:a,staleTime:me,retry:1})},it=a=>{const s=O();return J({...s.music.track.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},st=a=>{const s=O();return J({...s.music.playlist.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},rt=a=>{const s=O();return J({...s.music.upnext.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},ot=a=>{const s=O();return J({...s.music.likes.queryOptions(),enabled:a,staleTime:120*1e3,retry:1})},lt=()=>{const a=O(),s=Pe();return Re(a.music.like.mutationOptions({onSuccess:()=>{s.invalidateQueries(a.music.pathFilter())}}))},ct="_authRow_10tvv_1",ut="_btn_10tvv_9",dt="_btnGhost_10tvv_42",mt="_cookieForm_10tvv_74",ht="_cookieInput_10tvv_83",pt="_link_10tvv_99",gt="_contentLayout_10tvv_109",ft="_mainCol_10tvv_116",yt="_upnextAside_10tvv_120",bt="_upnextHeader_10tvv_131",vt="_upnextTitle_10tvv_139",kt="_upnextActions_10tvv_149",Nt="_nowPlayingLabel_10tvv_156",wt="_nowPlayingWrap_10tvv_168",St="_likeBtn_10tvv_172",Tt="_likeActive_10tvv_196",p={authRow:ct,btn:ut,btnGhost:dt,cookieForm:mt,cookieInput:ht,link:pt,contentLayout:gt,mainCol:ft,upnextAside:yt,upnextHeader:bt,upnextTitle:vt,upnextActions:kt,nowPlayingLabel:Nt,nowPlayingWrap:wt,likeBtn:St,likeActive:Tt};function Fe(a){const s=a.trim();if(!s)return null;const f=s.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??s.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return f||(/^[A-Za-z0-9_-]{11}$/.test(s)?s:null)}const xt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",It=()=>{const[a,s]=Ze(),f=Fe(a.get("v")??""),[R,be]=b(""),[se,W]=b(""),[K,re]=b(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[X,M]=b(!1),[ee,H]=b(()=>localStorage.getItem("musicShuffle")==="true"),[I,he]=b(()=>localStorage.getItem("musicRadio")!=="false"),[u,k]=b(null),[U,$]=b([]),[A,z]=b(null),[oe,T]=b({}),Y=L([]);Y.current=U;const E=L(null);E.current=u;const le=L(!1),V=L(new Set),{data:N}=Xe(),y=et(),D=tt(),B=typeof navigator<"u"?navigator.userAgent:"",Q=/android/i.test(B),te=/firefox|fxios/i.test(B)&&!Q,q=!te&&!Q&&/chrome|chromium|edg|brave/i.test(B),Z=te||q,ve=()=>{if(X)return;M(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",c),M(!1),P.error("Helper not detected — install the Dango Helper extension first.")},3e3),c=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",c),M(!1),m?.ok&&m.cookie){const l=m.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(l.includes("…")||l.includes("...")){P.error(`Helper returned a truncated cookie (${l.length} chars) — reload music.youtube.com and Extract again.`);return}re(l),P.success("Cookie extracted from helper — signing in…"),y.mutate({cookie:l})}else m?.error==="NO_COOKIE"?P.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):P.error("Helper request failed — try again.")};window.addEventListener("dango:ytmusic-cookie",c),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:ce,isLoading:ke}=nt(se),{data:_,isLoading:ne,isFetching:pe,error:Ne,refetch:ge}=at(N?.authenticated===!0),{data:ue,isLoading:we}=st(A?.id??null),{data:fe,isLoading:Se}=rt(u?.id??null),{data:r}=ot(N?.authenticated===!0),o=lt(),v=G(()=>ce?.tracks||[],[ce]),ae=G(()=>_?.playlists||[],[_]),C=G(()=>_?.tracks||[],[_]),j=G(()=>ue?.tracks||[],[ue]),S=G(()=>{const t=fe?.tracks||[];return u?t.filter(i=>i.id!==u.id):t},[fe,u]),Oe=G(()=>new Set(r?.likedIds||[]),[r]),Te=t=>oe[t.id]??(Oe.has(t.id)||t.liked===!0);F(()=>{N?.authenticated!==!0&&T({})},[N?.authenticated]);const De=G(()=>[...v,...j,...C,...S],[v,j,C,S]),qe=f&&u?.id!==f&&!De.some(t=>t.id===f)?f:null,{data:Ie}=it(qe),xe=u?.id;F(()=>{document.title=u?`${u.title} - dango`:"Music - dango"},[u]),F(()=>{if(!f){xe&&k(null);return}if(xe===f)return;const t=d=>{const m=d.find(l=>l.id===f);return m?(k(m),$(l=>l.some(ie=>ie.id===f)?l:d.length>0?d:[m]),!0):!1};if(t(v)||t(j)||t(C))return;const i=S.find(d=>d.id===f);if(i){k(i),$(d=>d.some(m=>m.id===i.id)?d:[i]);return}const c=Ie?.track;c&&c.id===f&&(k(c),$(d=>d.some(m=>m.id===c.id)?d:[c]))},[f,xe,v,j,C,S,Ie]);const Le=(t,i)=>{V.current.delete(t.id),k(t),$(i.length>0?i:[t]),s({v:t.id})},He=t=>{V.current.add(t.id),P.error(`Couldn't play “${t.title}” — skipped.`)},Ue=async()=>{if(le.current)return;const t=Y.current,i=t[t.length-1]??E.current;if(i){le.current=!0;try{const c=await Ce.music.upnext.query({id:i.id}),d=new Set(t.map(l=>l.id)),m=(c.tracks||[]).filter(l=>!d.has(l.id)&&!V.current.has(l.id));if(m.length===0){const l=Y.current[0];l&&(k(l),s({v:l.id}));return}$([...Y.current,...m]),k(m[0]),s({v:m[0].id})}catch{const c=Y.current[0];c&&(k(c),s({v:c.id}))}finally{le.current=!1}}},ze=t=>{const i=Y.current,c=E.current;if(!c||i.length===0)return;const d=i.findIndex(x=>x.id===c.id);if(t>0&&I&&(d<0||d===i.length-1)){Ue();return}const m=x=>V.current.has(x.id),l=i.length;let ie;if(ee&&l>1){let x=Math.floor(Math.random()*l);for(let Me=0;Me<l&&(x===d||m(i[x]));Me++)x=Math.floor(Math.random()*l);ie=i[x]}else{const x=t>0?1:-1;let ye=(((d<0?x>0?-1:0:d)+x)%l+l)%l;for(let Ee=1;Ee<l&&m(i[ye]);Ee++)ye=((ye+x)%l+l)%l;ie=i[ye]}k(ie),s({v:ie.id})},Ye=()=>{if(I){he(!1),localStorage.setItem("musicRadio","false");return}const t=E.current;if(!t)return;if(S.length===0){P.error("No radio suggestions for this song yet.");return}const i=new Set,c=[];for(const d of[t,...S])i.has(d.id)||(i.add(d.id),c.push(d));he(!0),localStorage.setItem("musicRadio","true"),$(c),P.success(`Radio started — ${S.length} songs queued.`)},$e=t=>{if(N?.authenticated!==!0){P.error("Sign in to like songs.");return}const i=!Te(t);T(c=>({...c,[t.id]:i})),o.mutate({id:t.id,like:i},{onError:()=>{T(c=>{const d={...c};return delete d[t.id],d}),P.error("Like action failed — try again.")}})},Qe=()=>{H(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Ge=t=>e("button",{className:h.stationRow,onClick:()=>z(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),t.subtitle&&e("span",{className:h.stationSub,children:t.subtitle})]})]},t.id),de=(t,i,c)=>{const d=u?.id===t.id,m=Te(t),l=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${h.stationRow} ${d?h.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>c?c(t):Le(t,i),className:h.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),e("span",{className:h.stationSub,children:[t.artists,l?` · ${l}`:""]})]})]}),N?.authenticated===!0&&e("button",{className:`${p.likeBtn} ${m?p.likeActive:""}`,onClick:()=>$e(t),disabled:o.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(g,{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(g,{name:"external-link-alt"})})]},t.id)},Ae=G(()=>{if(!u)return S;const t=new Set,i=[];for(const c of[u,...S])t.has(c.id)||(t.add(c.id),i.push(c));return i},[u,S]),We=t=>{Le(t,Ae)};return e("div",{className:`${n.page} ${u?n.pageWithPlayer:""}`,children:[e("div",{className:n.header,children:[e("h1",{className:n.pageTitle,children:[e(g,{name:"headphones"})," Music"]}),e("form",{className:n.searchForm,onSubmit:t=>{t.preventDefault();const i=Fe(R);i?(W(""),s({v:i})):W(R)},children:[e("input",{className:n.searchInput,value:R,onChange:t=>be(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:n.searchBtn,type:"submit","aria-label":"Search",children:e(g,{name:"search"})})]})]}),e("div",{className:p.authRow,children:[N?.authenticated?e(w,{children:[e("span",{className:n.statusMsg,children:["Signed in to YouTube Music",_&&` — ${_.tracks.length} songs, ${_.playlists.length} playlists`]}),e("button",{className:p.btnGhost,onClick:()=>D.mutate(),disabled:D.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=K.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){P.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==K&&re(i),y.mutate({cookie:i})}},className:p.cookieForm,children:[e("input",{className:p.cookieInput,value:K,onChange:t=>re(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:p.btn,type:"submit",disabled:y.isPending||!K.trim(),children:y.isPending?"Checking…":"Sign in"}),Z&&e("button",{className:p.btnGhost,type:"button",onClick:ve,disabled:X||y.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:X?"Extracting…":"Extract from helper"})]}),Z&&e("p",{className:n.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:xt,target:"_blank",rel:"noreferrer",className:p.link,children:"dango-extension.zip"})," ","then"," ",te?e(w,{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(w,{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(Ke,{})]}),y.isSuccess&&e("p",{className:n.statusMsg,children:["Signed in — found ",y.data.tracks," songs and ",y.data.playlists," ","playlists."]}),y.isError&&e("p",{className:n.statusMsg,children:y.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!N?.authenticated&&!y.isError&&!y.isSuccess&&e("p",{className:n.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:u?p.contentLayout:void 0,children:[e("div",{className:p.mainCol,children:se?e(w,{children:[e("h2",{className:h.sectionTitle,children:["Results for “",se,"”"]}),ke?e("p",{className:n.statusMsg,children:"Searching…"}):v.length===0?e("p",{className:n.statusMsg,children:"No tracks found."}):e("div",{className:h.stationList,children:v.map(t=>de(t,v))})]}):N?.authenticated?e(w,{children:[e("h2",{className:h.sectionTitle,children:"Your library"}),ne?e("p",{className:n.statusMsg,children:"Loading library…"}):ae.length===0&&C.length===0&&!A?e(w,{children:[e("p",{className:n.statusMsg,children:Ne?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>{ge()},disabled:pe,"aria-label":"Retry loading library",children:pe?"Retrying…":"Retry"})}),e("p",{className:n.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(w,{children:[ae.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:"Playlists"}),e("div",{className:h.stationList,children:ae.map(t=>Ge(t))})]}),C.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:["Liked songs (",C.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>Le(C[0],C),"aria-label":"Play all liked songs",children:[e(g,{name:"play"})," Play all"]})}),e("div",{className:h.stationList,children:C.map(t=>de(t,C))})]}),A?e(w,{children:[e("button",{className:p.btnGhost,onClick:()=>z(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:h.sectionTitle,children:A.title}),we?e("p",{className:n.statusMsg,children:"Loading playlist…"}):j.length===0?e("p",{className:n.statusMsg,children:"No tracks in this playlist."}):e("div",{className:h.stationList,children:j.map(t=>de(t,j))})]}):null]})]}):e("p",{className:n.statusMsg,children:"Search above, or sign in to see your library."})}),u&&e("aside",{className:p.upnextAside,"aria-label":"Up next",children:[e("div",{className:p.upnextHeader,children:e("span",{className:p.upnextTitle,children:[e(g,{name:"list-ul"})," Up Next"]})}),e("div",{className:p.nowPlayingWrap,children:[e("p",{className:p.nowPlayingLabel,children:"Now playing"}),de(u,U.length>0?U:[u])]}),e("div",{className:p.upnextActions,children:e("button",{className:p.btnGhost,onClick:Ye,disabled:!I&&(Se||S.length===0),"aria-pressed":I,title:I?"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:I?"Stop radio":"Start radio"})}),Se?e("p",{className:n.statusMsg,children:"Loading suggestions…"}):S.length===0?e("p",{className:n.statusMsg,children:"No suggestions for this song."}):e("div",{className:h.stationList,children:S.map(t=>de(t,Ae,We))})]})]}),u&&e(Je,{track:u,queue:U,shuffle:ee,onToggleShuffle:Qe,onTrackStep:ze,onTrackFailed:He,onClose:()=>{k(null),s({})},liked:u?Te(u):!1,likeVisible:N?.authenticated===!0,likePending:o.isPending,onToggleLike:()=>$e(u)})]})};export{It as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e,S as p,d as y,h as S}from"./vendor-core-DfaOB3Rn.js";import{I as m}from"./vendor-icons-DrybRNxP.js";import{M as s,
|
|
1
|
+
import{u as e,S as p,d as y,h as S}from"./vendor-core-DfaOB3Rn.js";import{I as m}from"./vendor-icons-DrybRNxP.js";import{M as s,z as b,T as g,B as f,D as k,F as C}from"./AvSyncCalibrator-BuHurVgo.js";const O=({classes:n,title:i,titleTag:o="span",showBack:l=!0,onBack:t,panelRef:d,onPanelClick:a,children:c})=>{const r=o;return e("div",{ref:d,className:n.panel,onClick:a,"data-speed-boost-ignore":"true",children:[e("div",{className:n.header,children:[l&&e("button",{className:n.backBtn,onClick:t,children:e(m,{name:"chevron-left"})}),e(r,{className:n.title||void 0,children:i})]}),e("div",{className:n.content,children:c})]})},z=({classes:n,values:i,onChange:o})=>{const l=()=>{const t=C;o("fontSize",t.fontSize),o("position",t.position),o("bgOpacity",t.bgOpacity),o("bgColor",t.bgColor),o("textColor",t.textColor),o("edge",t.edge),o("bold",t.bold)};return e(p,{children:[e(s,{label:"Font Size",display:i.fontSize.toFixed(1),min:.5,max:10,step:.5,value:i.fontSize,percent:(i.fontSize-.5)/9.5*100,onChange:t=>{Number.isFinite(t)&&o("fontSize",t)}}),e(s,{label:"Vertical Position",display:`${i.position}`,min:0,max:100,step:1,value:i.position,percent:i.position,onChange:t=>{Number.isFinite(t)&&o("position",Math.round(t))}}),e(s,{label:"Background Opacity",display:`${Math.round(i.bgOpacity*100)}%`,min:0,max:1,step:.05,value:i.bgOpacity,percent:i.bgOpacity*100,onChange:t=>{Number.isFinite(t)&&o("bgOpacity",t)}}),e(b,{label:"Text Color",colors:g,value:i.textColor,onChange:t=>o("textColor",t)}),e(b,{label:"Background Color",colors:f,value:i.bgColor,onChange:t=>o("bgColor",t)}),e(k,{label:"Text Edge",options:["shadow","outline","none"],value:i.edge,onChange:t=>o("edge",t)}),e("button",{type:"button",className:`${n.item} ${i.bold?n.active:""}`,onClick:()=>o("bold",!i.bold),children:[e("span",{children:"Bold Text"}),i.bold&&e(m,{name:"check",size:12})]}),e("button",{type:"button",className:n.item,onClick:l,children:e("span",{children:"Reset to Defaults"})})]})},M=({classes:n,enabled:i,delayMs:o,onToggle:l,onDelayChange:t,onCalibrate:d})=>{const[a,c]=y(null),r=a??o;S(()=>{c(null)},[o]);const u=()=>{a!==null&&(t(a),c(null))};return e(p,{children:[e("button",{type:"button",className:`${n.item} ${i?n.active:""}`,onClick:()=>l(!i),children:[e("span",{children:"Video delay"}),i&&e(m,{name:"check",size:12})]}),e(s,{label:"Video delay",display:`${r}ms`,min:0,max:500,step:5,value:r,percent:r/500*100,onChange:h=>c(Math.round(h)),onCommit:u}),e("div",{className:n.note,children:"For Bluetooth headsets where audio arrives late. Video is held back via canvas; audio plays untouched."}),d&&e("button",{type:"button",className:n.item,onClick:d,children:e("span",{children:"Calibrate…"})})]})},E=({classes:n,options:i,onSelect:o})=>e(p,{children:i.map(l=>e("button",{type:"button",className:`${n.item} ${l.selected?n.active:""}`,onClick:()=>o(l.key),children:[e("span",{children:l.label}),l.selected&&e(m,{name:"check",size:12})]},l.key))});export{M as A,E as O,O as S,z as a};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-D47ItGDR.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-icons-DrybRNxP.js","assets/OptionListMenu-DngTgHxH.js","assets/AvSyncCalibrator-BuHurVgo.js","assets/index-gMxawd-E.js","assets/vendor-query-BBT5_sHx.js","assets/index-Cc1Up_NI.css","assets/AvSyncCalibrator-D0FYSwiz.css","assets/PlayerSettings-Bj6SsmQ2.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{g as Ot,h as x,u as r,P as Lr,z as Ir,d as H,A as f,q as O,y as Dr,T as ot,o as $r,a as Fr,c as Wr,_ as Or,S as kt}from"./vendor-core-DfaOB3Rn.js";import{_ as fr,S as xt,h as Vr,t as Te,z as Ge,P as Ur,e as qr,l as Qr,m as zr,n as Gr,o as Kr,d as Hr,u as jr,M as Le,B as Ze,Q as Yr,f as Xr}from"./index-gMxawd-E.js";import{u as hr,b as cr,a as jt}from"./vendor-query-BBT5_sHx.js";import{C as Jr,S as Zr,U as en,a as tn,p as Yt,s as rn,l as nn,u as sn,b as on,i as an,c as ur,d as ln,e as dr,f as pr,g as cn,h as un,j as dn,r as pn,k as ze,E as mn,m as fn,n as d,o as hn,A as vn,P as gn,q as bn,t as yn}from"./AvSyncCalibrator-BuHurVgo.js";import{I as j}from"./vendor-icons-DrybRNxP.js";import{l as Sn}from"./hls-B3_1VuDP.js";import{u as En}from"./useIsMobile-Dvx1uJ82.js";import{s as et,Q as wn}from"./QueueRail-DeJKVRs5.js";import{u as Tn,Q as kn}from"./QueueOptionsButton-ClVTpH8J.js";import{u as vr}from"./useProviders-Ca0bZWt7.js";import{A as Cn}from"./AnimeMetaDetails-BogOi_bM.js";import{S as Mn}from"./SynopsisText-B3Sa5pRv.js";import"./vendor-ui-3qrARCPr.js";const Rn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},_n={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Nn=["direct","cookie","embed"],Pn="_controlsOverlay_1b7ea_1",xn="_hidden_1b7ea_21",An="_topControls_1b7ea_27",Bn="_backBtn_1b7ea_47",Ln="_videoTitleInfo_1b7ea_67",In="_animeTitle_1b7ea_73",Dn="_episodeNumber_1b7ea_81",$n="_bottomControls_1b7ea_89",Fn="_progressBarContainer_1b7ea_108",Wn="_progressBar_1b7ea_108",On="_thumb_1b7ea_127",Vn="_scrubbing_1b7ea_142",Un="_watchedBar_1b7ea_146",qn="_bufferedBar_1b7ea_147",Qn="_timeBubble_1b7ea_185",zn="_skipSegment_1b7ea_219",Gn="_op_1b7ea_229",Kn="_ed_1b7ea_232",Hn="_recap_1b7ea_235",jn="_bottomControlsRow_1b7ea_239",Yn="_leftControls_1b7ea_247",Xn="_rightControls_1b7ea_248",Jn="_controlBtn_1b7ea_255",Zn="_theaterBtn_1b7ea_296",es="_nextEpisodeBtn_1b7ea_300",ts="_active_1b7ea_317",rs="_timeDisplay_1b7ea_321",ns="_skipControls_1b7ea_329",ss="_skipBtn_1b7ea_335",os="_volumeContainer_1b7ea_376",as="_volumeSlider_1b7ea_382",is="_playerPageLayout_1b7ea_440",ls="_videoPlayerWrapper_1b7ea_444",cs="_playerInfoContainer_1b7ea_449",us="_visible_1b7ea_566",ds="_shortcuts_1b7ea_584",k={controlsOverlay:Pn,hidden:xn,topControls:An,backBtn:Bn,videoTitleInfo:Ln,animeTitle:In,episodeNumber:Dn,bottomControls:$n,progressBarContainer:Fn,progressBar:Wn,thumb:On,scrubbing:Vn,watchedBar:Un,bufferedBar:qn,timeBubble:Qn,skipSegment:zn,op:Gn,ed:Kn,recap:Hn,bottomControlsRow:jn,leftControls:Yn,rightControls:Xn,controlBtn:Jn,theaterBtn:Zn,nextEpisodeBtn:es,active:ts,timeDisplay:rs,skipControls:ns,skipBtn:ss,volumeContainer:os,volumeSlider:as,playerPageLayout:is,videoPlayerWrapper:ls,playerInfoContainer:cs,visible:us,shortcuts:ds},ps=Ir(()=>fr(()=>import("./PlayerSettings-D47ItGDR.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),ms=({player:n,isAutoplayEnabled:v,onAutoplayChange:C,showNextEpisodeButton:Y,onNextEpisode:g,videoSources:R,selectedSource:E,selectedLink:I,onSourceChange:L,loadingVideo:Q,skipIntervals:ke,animeTitle:e,episodeNumber:m,isTheaterMode:Ce,onTheaterModeToggle:N,anime4kEnabled:ie,onAnime4kToggle:We,anime4kSupported:V,anime4kProfile:B,onAnime4kProfileChange:$,anime4kInitializing:Oe,anime4kError:Ke,videoDelayEnabled:a,onVideoDelayToggle:u,videoDelayMs:w,onVideoDelayChange:ge,onCalibrateAvSync:Ve,fallbackChoice:Ie,onFallbackChoiceChange:De,children:He,overlays:ne,isInteractingExtra:Me=!1,className:c,hideChrome:y=!1})=>{const{state:o,refs:h,actions:b}=n,{showSettings:F}=o,{setShowSettings:ye,setShowVolumeSlider:Z}=b,U=Ot.useRef(null),le=Ot.useRef(null);x(()=>{const p=P=>{U.current&&!U.current.contains(P.target)&&le.current&&!le.current.contains(P.target)&&F&&ye(!1)};return F&&document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[F,ye]);const Se=Ot.useRef(null),tt=p=>{h.videoRef.current&&(h.videoRef.current.volume=p,h.videoRef.current.muted=p===0,localStorage.setItem("playerVolume",p.toString()))},je=p=>{!h.videoRef.current||isNaN(o.duration)||o.duration===0||(h.videoRef.current.currentTime=p*o.duration,b.sendProgressUpdate(!1,!0))},ht=()=>{h.videoRef.current&&(b.setIsScrubbing(!0),b.wasPlayingBeforeScrub.current=!h.videoRef.current.paused,h.videoRef.current.pause())},z=p=>{!h.videoRef.current||!o.duration||(h.videoRef.current.currentTime=p*o.duration)},rt=()=>{b.setIsScrubbing(!1),b.wasPlayingBeforeScrub.current&&h.videoRef.current?.play()},at=p=>{if(!h.videoRef.current)return;b.setActiveSubtitleTrack(p);try{if(p===null||p==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const M=o.availableSubtitles.find(qe=>qe.label===p||qe.lang===p);M?localStorage.setItem("playerLastSubtitle",rn(M)):localStorage.setItem("playerLastSubtitle",p)}}catch{}let P=!1;Array.from(h.videoRef.current.textTracks).forEach(M=>{const $e=p!==null&&p!=="off"&&(M.language===p||M.label===p)&&!P;M.mode=$e?"showing":"hidden",$e&&(P=!0)})},se=o.activeSubtitleTrack!==null&&o.activeSubtitleTrack!=="off",ue=()=>{if(!h.videoRef.current)return;if(se){at("off");return}if(o.availableSubtitles.length===0)return;let p=null;try{p=localStorage.getItem("playerLastSubtitle")}catch{}const P=Yt(o.availableSubtitles,{lastKey:p,enabled:!0});if(P<0)return;const M=o.availableSubtitles[P];at(M.label||M.lang)},Re=()=>o.isMuted||o.volume===0?r(j,{name:"volume-mute"}):o.volume<.5?r(j,{name:"volume-down"}):r(j,{name:"volume-up"}),vt=r("div",{className:`${k.controlsOverlay} ${!o.showControls&&!F&&!o.isScrubbing?k.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none"},children:r("div",{className:k.topControls,onClick:p=>p.stopPropagation(),children:[r("button",{className:k.backBtn,onClick:p=>{p.stopPropagation(),window.history.back()},title:"Back","aria-label":"Back",children:r(j,{name:"chevron-left"})}),r("div",{className:k.videoTitleInfo,children:[r("span",{className:k.animeTitle,children:e}),m&&r("span",{className:k.episodeNumber,children:["Episode ",m]})]})]})}),W=!Q&&!o.isBuffering&&o.duration>0?r(Jr,{isPlaying:o.isPlaying,onTogglePlay:b.togglePlay,onSkipBack:()=>b.seek(-10),onSkipForward:()=>b.seek(10)}):null,Ue=r("div",{className:`${k.controlsOverlay} ${!o.showControls&&!F&&!o.isScrubbing?k.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:k.bottomControls,"data-speed-boost-ignore":"true",onClick:p=>p.stopPropagation(),children:[r(Zr,{classes:{container:k.progressBarContainer,scrubbing:k.scrubbing,timeBubble:k.timeBubble,bar:k.progressBar,buffered:k.bufferedBar,watched:k.watchedBar,thumb:k.thumb},videoRef:h.videoRef,duration:o.duration,formatTime:b.formatTime,isScrubbing:o.isScrubbing,onSeek:je,onScrubStart:ht,onScrubMove:z,onScrubEnd:rt,timeLabelRef:Se,children:[o.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${k.skipSegment} ${k[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/o.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/o.duration*100}% `}}),ke.map(p=>{const P=p.start_time/o.duration*100,M=(p.end_time-p.start_time)/o.duration*100;return r("div",{className:`${k.skipSegment} ${k[p.skip_type]} `,style:{left:`${P}% `,width:`${M}% `},title:p.skip_type.toUpperCase()},p.skip_id)})]}),r("div",{className:k.bottomControlsRow,children:[r("div",{className:k.leftControls,children:[r("button",{className:k.controlBtn,onClick:b.togglePlay,"aria-label":o.isPlaying?"Pause":"Play",children:o.isPlaying?r(j,{name:"pause"}):r(j,{name:"play"})}),r(en,{muted:o.isMuted,volume:o.volume,volumeIcon:Re(),buttonClassName:k.controlBtn,onToggleMute:b.toggleMute,onVolumeChange:tt,onExpandedChange:p=>Z(p)}),r("span",{className:k.timeDisplay,ref:Se,children:[b.formatTime(0)," / ",b.formatTime(o.duration)]}),o.currentSkipInterval&&!o.isAutoSkipEnabled&&r("button",{className:k.controlBtn,onClick:()=>{h.videoRef.current&&o.currentSkipInterval&&(h.videoRef.current.currentTime=o.currentSkipInterval.end_time,b.setCurrentSkipInterval(null))},children:["Skip ",o.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:k.rightControls,children:[r("div",{className:k.skipControls,children:Y&&r("button",{className:k.nextEpisodeBtn,onClick:g,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${k.controlBtn} ${se?k.active:""}`,onClick:ue,title:se?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(j,{name:"closed-captioning",size:22})}),r("button",{ref:le,className:`${k.controlBtn} ${F?k.active:""} `,onClick:()=>ye(!F),"aria-label":"Settings",children:r(j,{name:"cog"})}),r("button",{className:`${k.controlBtn} ${k.theaterBtn} ${Ce?k.active:""} `,onClick:p=>{p.stopPropagation(),N()},title:Ce?"Exit Theater Mode":"Theater Mode","aria-label":Ce?"Exit Theater Mode":"Theater Mode",children:r(j,{name:"tv"})}),r("button",{className:k.controlBtn,onClick:b.toggleFullscreen,"aria-label":o.isFullscreen?"Exit Fullscreen":"Fullscreen",children:o.isFullscreen?r(j,{name:"compress"}):r(j,{name:"expand"})})]})]})]})}),it=r(Lr,{fallback:null,children:r(ps,{ref:U,isOpen:F,onClose:()=>ye(!1),videoSources:R,currentSource:E,currentLink:I,onSourceChange:L,subtitles:o.availableSubtitles,activeSubtitleTrack:o.activeSubtitleTrack,onSubtitleChange:at,subtitleSettings:{fontSize:o.subtitleFontSize,position:o.subtitlePosition,bgOpacity:o.subtitleBgOpacity,bgColor:o.subtitleBgColor,textColor:o.subtitleTextColor,edge:o.subtitleEdge,bold:o.subtitleBold},onSubtitleSettingsChange:(p,P)=>{const M=(qe,$e)=>{try{localStorage.setItem(qe,String($e))}catch{}};switch(p){case"fontSize":b.setSubtitleFontSize(P),M("subtitleFontSize",P);break;case"position":b.setSubtitlePosition(P),M("subtitlePosition",P);break;case"bgOpacity":b.setSubtitleBgOpacity(P),M("subtitleBgOpacity",P);break;case"bgColor":b.setSubtitleBgColor(P),M("subtitleBgColor",P);break;case"textColor":b.setSubtitleTextColor(P),M("subtitleTextColor",P);break;case"edge":b.setSubtitleEdge(P),M("subtitleEdge",P);break;case"bold":b.setSubtitleBold(P),M("subtitleBold",P);break}},useNativeControls:o.useNativeControls,onNativeControlsToggle:b.setUseNativeControls,anime4kEnabled:ie,onAnime4kToggle:We,anime4kSupported:V,anime4kProfile:B,onAnime4kProfileChange:$,anime4kInitializing:Oe,anime4kError:Ke,videoDelayEnabled:a,onVideoDelayToggle:u,videoDelayMs:w,onVideoDelayChange:ge,onCalibrateAvSync:Ve,isAutoSkipEnabled:o.isAutoSkipEnabled,onAutoSkipChange:p=>{b.setIsAutoSkipEnabled(p);try{localStorage.setItem("autoSkipEnabled",p.toString())}catch{}},isAutoplayEnabled:v,onAutoplayChange:C,fallbackChoice:Ie,onFallbackChoiceChange:De})}),nt=F?r("div",{"data-speed-boost-ignore":"true",onClick:p=>p.stopPropagation(),children:it}):null;return r(tn,{player:n,topBar:vt,centerControls:W,bottomBar:!Q&&o.duration>0?Ue:null,settingsPanel:nt,overlays:ne,isInteracting:Me,className:c,chromeDisabled:y,children:He})},fs=({count:n=3})=>r("section",{className:et.section,children:[r("div",{className:et.header,children:r("button",{className:et.headerToggle,disabled:!0,children:[r("span",{className:et.title,children:r(xt,{width:"60px",height:"1.2rem",variant:"text"})}),r(j,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:et.list,children:Array.from({length:n}).map((v,C)=>r("div",{className:et.item,style:{pointerEvents:"none"},children:[r("div",{className:et.dragHandle,style:{opacity:.2},children:r(xt,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:et.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(xt,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:et.meta,children:[r(xt,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(xt,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},C))})]}),hs="_sourceSelectionContainer_c5tub_76",vs="_providerSelectContainer_c5tub_89",gs="_providerSelect_c5tub_89",bs="_sourceSelect_c5tub_76",ys="_sourceButtons_c5tub_145",Ss="_sourceButton_c5tub_145",Es="_active_c5tub_170",ft={sourceSelectionContainer:hs,providerSelectContainer:vs,providerSelect:gs,sourceSelect:bs,sourceButtons:ys,sourceButton:Ss,active:Es},ws=({selectedProvider:n,onProviderChange:v,isAdult:C,options:Y})=>{const g=Y&&Y.length>0?Y:[],R=C===void 0?g:g.filter(E=>E.mature===C);return r("div",{className:ft.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:ft.providerSelect,value:n,onChange:E=>v(E.target.value),children:Nn.map(E=>{const I=R.filter(L=>(L.tier??"direct")===E);return I.length===0?null:r("optgroup",{label:_n[E],children:I.map(L=>r("option",{value:L.value,children:L.sub?`${L.label} (${Rn[L.sub]})`:L.label},L.value))},E)})})]})},Ts=({videoSources:n,selectedSource:v,selectedLink:C,onSourceChange:Y,onLinkChange:g})=>{const R=Array.isArray(n)?n:[];if(R.length===0)return null;const E=v?.type==="iframe"&&(v.links?.length??0)>1;return r("div",{className:ft.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:ft.sourceButtons,children:R.map((I,L)=>r("button",{className:`${ft.sourceButton} ${v?.sourceName===I.sourceName?ft.active:""} `,onClick:()=>Y(I),children:I.sourceName},`${I.sourceName}-${L}`))}),E&&r("select",{className:ft.sourceSelect,"aria-label":"Fallback embed quality",value:C?.link??v.links[0]?.link??"",onChange:I=>{const L=v.links.find(Q=>Q.link===I.target.value);L&&g(L)},children:v.links.map(I=>r("option",{value:I.link,children:I.resolutionStr},I.link))})]})},ks=Ot.memo(Ts,(n,v)=>n.selectedSource?.sourceName===v.selectedSource?.sourceName&&n.selectedLink?.link===v.selectedLink?.link&&n.videoSources===v.videoSources),Cs={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}},Ms={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Rs=5,_s=15e3,Ns=`
|
|
3
|
+
@group(0) @binding(0) var extTex: texture_external;
|
|
4
|
+
@group(0) @binding(1) var extSamp: sampler;
|
|
5
|
+
struct VSOut {
|
|
6
|
+
@builtin(position) pos: vec4f,
|
|
7
|
+
@location(0) uv: vec2f,
|
|
8
|
+
};
|
|
9
|
+
@vertex
|
|
10
|
+
fn vs(@builtin(vertex_index) idx: u32) -> VSOut {
|
|
11
|
+
var positions = array<vec2f, 6>(
|
|
12
|
+
vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
|
|
13
|
+
vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
|
|
14
|
+
);
|
|
15
|
+
var uvs = array<vec2f, 6>(
|
|
16
|
+
vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
|
|
17
|
+
vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
|
|
18
|
+
);
|
|
19
|
+
var out: VSOut;
|
|
20
|
+
out.pos = vec4f(positions[idx], 0.0, 1.0);
|
|
21
|
+
out.uv = uvs[idx];
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
@fragment
|
|
25
|
+
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
26
|
+
return textureSampleBaseClampToEdge(extTex, extSamp, uv);
|
|
27
|
+
}
|
|
28
|
+
`;function Ps({videoRef:n,canvasRef:v,profile:C="balanced",delayMs:Y=0}){const[g,R]=H(!1),[E,I]=H(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[L,Q]=H(!1),[ke,e]=H(null),[m,Ce]=H(0),N=f(0),ie=f(null),We=f(null),V=f(null),B=f(null),$=f(null),Oe=f(null),Ke=f(null),a=f(null),u=f(null),w=f(!1),ge=f(-1),Ve=f(0),Ie=f(Y);Ie.current=Y;const De=f([]),He=f(!1),ne=f(!1),Me=f(!1),c=f(null),y=f(-1),o=f(-1),h=f(!1),b=f(0);x(()=>{async function Z(){if(typeof navigator>"u"||!navigator.gpu){R(!1);return}try{const U=await navigator.gpu.requestAdapter();R(!!U)}catch{R(!1)}}Z()},[]),x(()=>{if(!E||!g)return;let Z=!1;const U=++N.current,le=z=>{if(z)try{z.close()}catch{}},Se=()=>{for(const z of De.current)le(z.bitmap);De.current=[]},tt=z=>Math.max(8,Math.min(40,Math.ceil(z/16.7)+4));function je(){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}async function ht(){let z=n.current;const rt=v.current;if(!z||!rt||N.current!==U)return;const at=performance.now()+_s;for(;(!z||z.videoWidth===0)&&performance.now()<at;){if(await new Promise(M=>requestAnimationFrame(M)),Z||N.current!==U)return;z=n.current}if(!z||z.videoWidth===0){!Z&&N.current===U&&(e("Timed out waiting for video metadata"),Q(!1),I(!1));return}const se=z.videoWidth,ue=z.videoHeight,Re=Math.max(se,ue),vt=window.innerWidth,W=window.innerHeight,Ue=Math.max(vt,W),it=Re<Ue?Ue/Re:1,nt=Cs[C],p=Re<=480?nt.sd:Re<=720?nt.hd:Re<=1080?nt.fhd:1,P=Math.min(p,it);rt.width=Math.round(se*P),rt.height=Math.round(ue*P),Q(!0),e(null),Ve.current=0,ge.current=-1,y.current=-1,o.current=-1,h.current=!1,b.current=0,Se(),w.current=!1;try{let M=function(){Z||N.current!==U||(je(),u.current=requestAnimationFrame(()=>{Mt()}))};const{ModeA:qe,ModeB:$e,ModeC:Vt,ModeAA:Ct}=await fr(async()=>{const{ModeA:D,ModeB:X,ModeC:xe,ModeAA:me}=await import("./index-BOKlZEHq.js").then(fe=>fe.i);return{ModeA:D,ModeB:X,ModeC:xe,ModeAA:me}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const Ye=await navigator.gpu.requestAdapter();if(!Ye)throw new Error("No GPU adapter found");const T=await Ye.requestDevice();if(!T)throw new Error("Failed to get GPU device");const lt=rt.getContext("webgpu");if(!lt)throw new Error("Failed to get WebGPU context");const gt=navigator.gpu.getPreferredCanvasFormat();lt.configure({device:T,format:gt,alphaMode:"premultiplied"});const de=T.createTexture({size:[se,ue],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),ct=Ms[C],Qe=Math.round(se*P),_e=Math.round(ue*P),Ne=(()=>{switch(ct){case"ModeB":return new $e({device:T,inputTexture:de,nativeDimensions:{width:se,height:ue},targetDimensions:{width:Qe,height:_e}});case"ModeC":return new Vt({device:T,inputTexture:de,nativeDimensions:{width:se,height:ue},targetDimensions:{width:Qe,height:_e}});case"ModeAA":return new Ct({device:T,inputTexture:de,nativeDimensions:{width:se,height:ue},targetDimensions:{width:Qe,height:_e}});default:return new qe({device:T,inputTexture:de,nativeDimensions:{width:se,height:ue},targetDimensions:{width:Qe,height:_e}})}})(),Xe=Ne.getOutputTexture(),bt=T.createSampler({magFilter:"linear",minFilter:"linear"}),Pe=T.createShaderModule({code:`
|
|
29
|
+
@group(0) @binding(0) var tex: texture_2d<f32>;
|
|
30
|
+
@group(0) @binding(1) var samp: sampler;
|
|
31
|
+
struct VertexOutput {
|
|
32
|
+
@builtin(position) pos: vec4f,
|
|
33
|
+
@location(0) uv: vec2f,
|
|
34
|
+
}
|
|
35
|
+
@vertex
|
|
36
|
+
fn vs(@builtin(vertex_index) idx: u32) -> VertexOutput {
|
|
37
|
+
var positions = array<vec2f, 6>(
|
|
38
|
+
vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
|
|
39
|
+
vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
|
|
40
|
+
);
|
|
41
|
+
var uvs = array<vec2f, 6>(
|
|
42
|
+
vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
|
|
43
|
+
vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
|
|
44
|
+
);
|
|
45
|
+
var out: VertexOutput;
|
|
46
|
+
out.pos = vec4f(positions[idx], 0.0, 1.0);
|
|
47
|
+
out.uv = uvs[idx];
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
@fragment
|
|
51
|
+
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
52
|
+
return textureSample(tex, samp, uv);
|
|
53
|
+
}
|
|
54
|
+
`}),yt=T.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),St=T.createRenderPipeline({layout:T.createPipelineLayout({bindGroupLayouts:[yt]}),vertex:{module:Pe,entryPoint:"vs"},fragment:{module:Pe,entryPoint:"fs",targets:[{format:gt}]},primitive:{topology:"triangle-list"}}),ut=T.createBindGroup({layout:yt,entries:[{binding:0,resource:Xe.createView()},{binding:1,resource:bt}]});try{const D=T.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),X=T.createShaderModule({code:Ns}),xe=T.createRenderPipeline({layout:T.createPipelineLayout({bindGroupLayouts:[D]}),vertex:{module:X,entryPoint:"vs"},fragment:{module:X,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});c.current={pipeline:xe,layout:D,inputView:de.createView()}}catch{c.current=null}if(N.current!==U){de.destroy(),T.destroy();return}ie.current=T,We.current=lt,V.current=Ne,B.current=de,$.current=Xe,Oe.current=St,Ke.current=bt,a.current=yt,ne.current=!1,Me.current=!1;async function At(){const D=c.current;if(!D||ne.current)return!1;const X=n.current;if(!X)return!1;const xe=!Me.current;xe&&T.pushErrorScope("validation");try{const me=T.importExternalTexture({source:X}),fe=T.createBindGroup({layout:D.layout,entries:[{binding:0,resource:me},{binding:1,resource:bt}]}),G=T.createCommandEncoder(),be=G.beginRenderPass({colorAttachments:[{view:D.inputView,loadOp:"load",storeOp:"store"}]});be.setPipeline(D.pipeline),be.setBindGroup(0,fe),be.draw(6),be.end(),T.queue.submit([G.finish()])}catch{return ne.current=!0,c.current=null,!1}if(xe){const me=await T.popErrorScope().catch(()=>null);if(me)return console.warn("[anime4k] blit probe failed:",me.message),ne.current=!0,c.current=null,!1;Me.current=!0}return!0}Q(!1);async function Mt(){if(Z||N.current!==U)return;const D=n.current;if(!D||D.videoWidth===0){M();return}if(D!==z||D.videoWidth!==se||D.videoHeight!==ue){Ce(fe=>fe+1);return}if(D.paused||D.ended||document.hidden||D.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){M();return}const X=D.getVideoPlaybackQuality().totalVideoFrames;if(X===o.current){M();return}if(w.current){M();return}const xe=D.currentTime;(D.seeking||y.current>=0&&Math.abs(xe-y.current)>.5)&&(Se(),h.current=!1,b.current=0,o.current=-1),y.current=xe;const me=Math.max(0,Ie.current||0);me>b.current&&(h.current=!1),w.current=!0;try{const fe=performance.now();let G=null,be=!1;if(me<=0){De.current.length>0&&Se(),h.current=!1,b.current=0;let Fe=!1;if(!He.current)try{T.queue.copyExternalImageToTexture({source:D},{texture:de},[se,ue]),o.current=X,Fe=!0}catch(J){if(J instanceof TypeError)He.current=!0;else throw J}if(!Fe&&!ne.current&&c.current&&await At()&&(o.current=X,Fe=!0),!Fe){const J=await createImageBitmap(D);o.current=X,T.queue.copyExternalImageToTexture({source:J},{texture:de},[se,ue]),le(J)}}else{const Fe=await createImageBitmap(D);o.current=X;const J=De.current;J.push({bitmap:Fe,capture:fe});const Rt=tt(me);for(;J.length>Rt;)le(J.shift()?.bitmap);let _t=-1;for(let Ee=J.length-1;Ee>=0;Ee--)if(fe-J[Ee].capture>=me){_t=Ee;break}if(_t!==-1){for(let ce=0;ce<_t;ce++)le(J.shift()?.bitmap);const Ee=J.shift();Ee?(G=Ee.bitmap,h.current=!0,b.current=me):(G=Fe,be=!0)}else if(!h.current)G=Fe,be=!0;else{const Ee=J.shift();G=Ee?Ee.bitmap:Fe,Ee||(be=!0)}if(!G){w.current=!1,M();return}T.queue.copyExternalImageToTexture({source:G},{texture:de},[se,ue]),be||le(G)}const Et=T.createCommandEncoder();await Ne.pass(Et);const A=Et.beginRenderPass({colorAttachments:[{view:lt.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});A.setPipeline(St),A.setBindGroup(0,ut),A.draw(6),A.end(),T.queue.submit([Et.finish()]),ge.current=X,Ve.current=0,T.queue.onSubmittedWorkDone().then(()=>{N.current===U&&(w.current=!1)})}catch(fe){if(w.current=!1,Ve.current+=1,Ve.current>=Rs&&!Z&&N.current===U){console.error(fe),e(fe instanceof Error?fe.message:"Render error"),I(!1);return}}M()}M()}catch(M){!Z&&N.current===U&&(e(M instanceof Error?M.message:"Failed to initialize upscaler"),Q(!1),I(!1))}}return ht(),()=>{Z=!0,N.current+=1,je(),Se(),B.current&&(B.current.destroy(),B.current=null),$.current&&($.current.destroy(),$.current=null),ie.current&&(ie.current.destroy(),ie.current=null),V.current=null,Oe.current=null,Ke.current=null,a.current=null,c.current=null,We.current=null,w.current=!1}},[E,g,n,v,C,m]);const F=O(Z=>{I(Z);try{localStorage.setItem("anime4kEnabled",String(Z))}catch{}},[]),ye=O(()=>{I(Z=>{const U=!Z;try{localStorage.setItem("anime4kEnabled",String(U))}catch{}return U})},[]);return{isWebGPUSupported:g,isEnabled:E,isInitializing:L,error:ke,toggle:ye,setEnabled:F}}const xs=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",As=()=>{const n=localStorage.getItem("preferredProvider");return n&&/^[a-z0-9-]+$/i.test(n)?n:"megaplay"},Bs=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:xs(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:nn(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:As(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Ls(n,v){switch(v.type){case"SET_STATE":return{...n,...v.payload};case"SET_MODE":return{...n,currentMode:v.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...n,selectedProvider:v.payload};default:return n}}async function mr(n,v,C,Y,g=!1){if(!n||!v)throw new Error("Missing params");try{const[R,E,I,L]=await Promise.all([Te.data.video.query({showId:n,episodeNumber:v,mode:C.currentMode,provider:C.selectedProvider}).catch(()=>null),Te.progress.getEpisode.query({showId:n,episodeNumber:v}).catch(()=>null),Te.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),Te.data.skipTimes.query({showId:n,episodeNumber:v}).catch(()=>[])]),Q=I?.value,ke=R?.filter(B=>{const $=B.sourceName.toLowerCase();return C.currentMode==="dub"?$.includes("eng")||$.includes("dub"):$.includes("jpn")||$.includes("sub")||!$.includes("eng")&&!$.includes("dub")})??[],e=ke.length>0?ke:R??[];let m=e.length>0?e[0]:null;if(Q){const B=e.find($=>$.sourceName===Q);B&&(m=B)}const Ce=m&&m.links.length>0?m.links.sort((B,$)=>(parseInt($.resolutionStr)||0)-(parseInt(B.resolutionStr)||0))[0]:null,N=E?.currentTime||0,ie=E?.duration||0,V=(Array.isArray(L)?L:L?.results||[]).map(B=>({skip_id:B.skip_id||"",skip_type:B.skip_type||"",start_time:B.interval?.start_time??B.start_time??0,end_time:B.interval?.end_time??B.end_time??0})).filter(B=>B.end_time>0);return(!R||R.length===0)&&(g||Ge.error(`No video sources found for ${C.selectedProvider}`)),{videoSources:R,selectedSource:m,selectedLink:Ce,resumeTime:N,resumeDuration:ie,showResumeModal:N>5&&m?.type!=="iframe",skipIntervals:V,fetchedEpisodeNumber:v}}catch(R){const E=R;if(E.message==="AUTH_REQUIRED")return Y({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:E.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:v};throw R}}const Is=(n,v,C,Y)=>{const[g,R]=Dr(Ls,C,c=>({...Bs(),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}}:{}})),E=hr(),I=Vr(),L=f(null),Q=f(null),{options:ke}=vr(),e=ot(()=>ke.filter(c=>(c.kind??"anime")==="anime"),[ke]),m=v||g.initialEpisode,Ce=f(m);x(()=>{Ce.current!==m&&(Ce.current=m,R({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[m,R]),x(()=>{n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)&&g.selectedProvider!=="animepahe"&&L.current!==n&&(L.current=n,R({type:"SET_PROVIDER",payload:"animepahe"}))},[n,g.selectedProvider]);const{data:N,isLoading:ie,error:We}=Tn(n),{data:V}=cr({queryKey:["player-data",n,g.currentMode,g.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const c=async()=>{try{const F=await Te.data.episodes.query({showId:n,mode:g.currentMode,provider:g.selectedProvider}).catch(()=>null);if(F?.episodes?.length)return F}catch{}return null},[y,o,h]=await Promise.all([c(),Te.watchlist.check.query({showId:n}).catch(()=>({inWatchlist:!1,status:null})),Te.progress.getWatchedEpisodes.query({showId:n}).catch(()=>[])]),b=y?.episodes?y.episodes.sort((F,ye)=>parseFloat(F)-parseFloat(ye)):[];return{description:y?.description||"",episodes:b,inWatchlist:o.inWatchlist,watchlistStatus:o.status??null,watchedEpisodes:h}},enabled:!!n});x(()=>{!v&&V?.episodes&&V.episodes.length>0&&!v&&R({type:"SET_STATE",payload:{initialEpisode:V.episodes[0]}})},[V,v]),x(()=>{if(N?.isAdult===void 0)return;const y=new Set(e.filter(o=>o.mature).map(o=>o.value)).has(g.selectedProvider);if(Q.current!==n){if(N.isAdult&&!y){const o=e.find(h=>h.mature);if(!o)return;Q.current=n,R({type:"SET_PROVIDER",payload:o.value}),localStorage.setItem("preferredProvider",o.value)}if(!N.isAdult&&y){const o=e.find(h=>!h.mature);if(!o)return;Q.current=n,R({type:"SET_PROVIDER",payload:o.value}),localStorage.setItem("preferredProvider",o.value)}}},[N?.isAdult,g.selectedProvider,n,e]),x(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||Q.current===`temp:${n}`)return;const c=N?.provider;c&&(Q.current=`temp:${n}`,c!==g.selectedProvider&&R({type:"SET_PROVIDER",payload:c}))},[n,N,g.selectedProvider]);const{data:B,isLoading:$,error:Oe}=cr({queryKey:["video-sources",n,m,g.selectedProvider,g.currentMode],queryFn:()=>mr(n,m,g,R),enabled:!!n&&!!m&&!(g.showMeta?.isAdult===!0&&!Y?.hasMatureConsent)}),{mutateAsync:Ke}=jt({mutationFn:async({wasIn:c,showMeta:y})=>{if(!n)throw new Error("Missing showId");if(c)await Te.watchlist.remove.mutate({id:n});else{const o=y.name||y.names?.romaji;if(!o)throw new Error("Missing show name");await Te.watchlist.add.mutate({id:n,name:o,thumbnail:y.thumbnail,nativeName:y.names?.native,englishName:y.names?.english,type:y.type,isAdult:y.isAdult})}return!c},onSuccess:c=>{Ge.success(c?"Added to watchlist":"Removed from watchlist"),E.invalidateQueries({queryKey:["player-data",n]}),E.invalidateQueries({queryKey:["show-data",n]}),E.invalidateQueries({queryKey:["watchlist"]})},onError:c=>Ge.error(c instanceof Error?c.message:"Failed to update watchlist")}),a=O(async()=>{!n||!N||await Ke({wasIn:!!V?.inWatchlist,showMeta:N})},[n,N,V?.inWatchlist,Ke]),u=O(async c=>{try{await Te.settings.set.mutate({key:"preferredSource",value:c})}catch(y){console.error(y)}},[]),{mutateAsync:w,isPending:ge}=jt({mutationFn:async({status:c})=>{if(!n)throw new Error("Missing showId");return await Te.watchlist.setStatus.mutate({id:n,status:c}),c},onSuccess:c=>{R({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:c}}),Ge.success(`Moved to ${c}`),E.invalidateQueries({queryKey:["show-data",n]}),E.invalidateQueries({queryKey:["watchlist"]}),E.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>Ge.error("Failed to update watchlist status")}),Ve=O(async()=>{await w({status:"Completed"})},[w]),{mutateAsync:Ie}=jt({mutationFn:async({episodeNumber:c,duration:y,showMeta:o,episodes:h})=>{await Te.progress.updateProgress.mutate({showId:n,episodeNumber:c,currentTime:y,duration:y,showName:o.name,showThumbnail:o.thumbnail,nativeName:o.names?.native,englishName:o.names?.english,genres:o.genres?.map(b=>b.name),popularityScore:Ur(o.score??o.stats?.averageScore),type:o.type,status:o.status,episodeCount:h.length,isAdult:o.isAdult})},onSuccess:(c,y)=>{Ge.success(`Episode ${y.episodeNumber} marked as watched`),E.invalidateQueries({queryKey:["player-data",n]}),E.invalidateQueries({queryKey:["show-meta",n]}),E.invalidateQueries({queryKey:["video-sources",n,y.episodeNumber]}),E.invalidateQueries({queryKey:["allContinueWatching"]}),E.invalidateQueries({queryKey:["thisWeekSchedule"]}),E.invalidateQueries(I.continueWatching.pathFilter())},onError:()=>Ge.error("Failed to mark episode as watched")}),De=O(async(c,y)=>{!n||!N||await Ie({episodeNumber:c,duration:y,showMeta:N,episodes:V?.episodes||[]})},[n,N,V?.episodes,Ie]),He=O(async()=>{R({type:"SET_STATE",payload:{showCombinedDetails:!g.showCombinedDetails}})},[g.showCombinedDetails]),ne=ot(()=>{const c=We||Oe,y=c?c.message:null,o=y==="AUTH_REQUIRED"?null:y,h=B&&B.fetchedEpisodeNumber===m?B:null,b=!!B&&!h;return{...g,currentEpisode:m,showMeta:{...g.showMeta||{},...N||{}},episodes:V?.episodes||[],watchedEpisodes:V?.watchedEpisodes||[],inWatchlist:!!V?.inWatchlist,watchlistStatus:V?.watchlistStatus??g.watchlistStatus??null,videoSources:h?.videoSources||[],selectedSource:g.selectedSource||h?.selectedSource||null,selectedLink:g.selectedLink||h?.selectedLink||null,resumeTime:h?.resumeTime||0,resumeDuration:h?.resumeDuration||0,showResumeModal:g.showResumeModal&&(h?.showResumeModal??!1),skipIntervals:h?.skipIntervals||[],loadingShowData:ie,loadingVideo:$||b,error:o,fetchedEpisodeNumber:h?.fetchedEpisodeNumber}},[g,N,V,B,ie,$,We,Oe,m]),Me=O((c,y)=>{const o=y||n;if(!o||!c||o===n&&c===m)return;const b=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(o)&&g.selectedProvider!=="animepahe"?"animepahe":g.selectedProvider,F=["video-sources",o,c,b,g.currentMode];E.getQueryState(F)?.status!=="success"&&E.prefetchQuery({queryKey:F,queryFn:()=>mr(o,c,{selectedProvider:b,currentMode:g.currentMode},R,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,m,E,g,R]);return{state:ne,dispatch:R,toggleWatchlist:a,moveToCompleted:Ve,setPreferredSource:u,handleToggleDetails:He,markEpisodeWatched:De,prefetchEpisodeSources:Me,isMarkingWatched:Ie.isPending,isUpdatingWatchlistStatus:ge}},Xt="fallbackChoice";function Ds(){try{const n=localStorage.getItem(Xt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function $s(n){try{n===null?localStorage.removeItem(Xt):localStorage.setItem(Xt,n)}catch{}}const to=()=>{const{id:n,episodeNumber:v}=$r(),C=Fr(),Y=hr(),g=Wr(),{hasConsent:R,grant:E}=qr(),{options:I}=vr(),L=ot(()=>I.filter(t=>(t.kind??"anime")==="anime"),[I]),Q=ot(()=>L.map(t=>t.value),[L]),ke=ot(()=>new Set(L.filter(t=>t.mature).map(t=>t.value)),[L]),{state:e,dispatch:m,toggleWatchlist:Ce,moveToCompleted:N,setPreferredSource:ie,handleToggleDetails:We,markEpisodeWatched:V,prefetchEpisodeSources:B,isMarkingWatched:$,isUpdatingWatchlistStatus:Oe}=Is(n,v,g.state||null,{hasMatureConsent:R});x(()=>{if(n&&e.showMeta?.id&&e.showMeta.id!==n){const t=v?`/watch/${e.showMeta.id}/${v}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;C(t,{replace:!0})}},[n,e.showMeta?.id,v,C]);const Ke=ot(()=>{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=sn({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:Ke}),{refs:u,actions:w}=a,ge=f(null),Ve=En(),Ie=f(null),De=f(null),He=f(null),ne=f(0),Me=f(e.resumeTime),c=f(e.showResumeModal),[y,o]=H(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),[h,b]=H(()=>{try{const t=Number(localStorage.getItem("playerVideoDelayMs"));if(Number.isFinite(t)&&t>=0&&t<=500)return Math.round(t)}catch{}return 180}),[F,ye]=H(()=>{try{return localStorage.getItem("playerVideoDelayEnabled")==="true"}catch{return!1}}),[Z,U]=H(!1),[le,Se]=H(!1),tt=f(null),je=f(null),ht=(t,s)=>{try{localStorage.setItem("playerVideoDelayMs",String(t)),localStorage.setItem("playerVideoDelayEnabled",String(s))}catch{}},z=t=>{const s=Math.max(0,Math.min(500,Math.round(t)));b(s);try{localStorage.setItem("playerVideoDelayMs",String(s))}catch{}},rt=()=>{tt.current={enabled:F,ms:h},ye(!0);try{localStorage.setItem("playerVideoDelayEnabled","true")}catch{}w.setShowSettings(!1),U(!0)},at=()=>{const t=tt.current;tt.current=null,t&&(b(t.ms),ye(t.enabled),ht(t.ms,t.enabled)),Se(!1),U(!1)},se=()=>{tt.current=null,ye(!0),ht(h,!0),Se(!1),U(!1)},ue=()=>{if(le){Se(!1);return}const t=u.videoRef.current;t&&!isNaN(t.currentTime)&&(je.current=t.currentTime),Se(!0)},Re=F?h:0,vt=f(null),W=Ps({videoRef:u.videoRef,canvasRef:De,profile:y,delayMs:Re}),Ue=W.isEnabled&&W.isWebGPUSupported,it=`${n??""}:${e.currentEpisode??""}`,nt=f(null),p=f(!1),P=f(!1),M=f(W.setEnabled);M.current=W.setEnabled,x(()=>{const t=nt.current;nt.current=it,!(t===null||t===it)&&(!W.isEnabled||!W.isWebGPUSupported||(p.current=!0,P.current=!1,M.current(!1)))},[it,W.isEnabled,W.isWebGPUSupported]),x(()=>{if(!p.current)return;if(W.isEnabled){P.current&&(p.current=!1);return}if(P.current=!0,e.loadingVideo||!e.selectedLink)return;if(e.selectedSource?.type==="iframe"){p.current=!1,M.current(!0);return}const t=u.videoRef.current;if(!t)return;let s,i=!1;const l=()=>{i||(i=!0,p.current=!1,M.current(!0))};if(t.readyState>=2)return s=window.setTimeout(l,500),()=>window.clearTimeout(s);const _=()=>{window.setTimeout(l,500)};return t.addEventListener("canplay",_,{once:!0}),t.addEventListener("playing",_,{once:!0}),s=window.setTimeout(l,5e3),()=>{window.clearTimeout(s),t.removeEventListener("canplay",_),t.removeEventListener("playing",_)}},[W.isEnabled,e.loadingVideo,e.selectedLink,e.selectedSource?.type,u.videoRef]),on({videoRef:u.videoRef,canvasRef:vt,delayMs:Re,enabled:F&&!Ue});const qe=F&&!Ue,$e=Ue||qe;x(()=>{Me.current=e.resumeTime,c.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[Vt,Ct]=H(!1),[Ye,T]=H(!1),[lt,gt]=H(!1),de=f(!1),[ct,Qe]=H(null),_e=f(!1),Ne=f([]),Xe=f(!1),[bt,Pe]=H(null),[yt,St]=H(!1),[ut,At]=H(!1),[Mt,D]=H(()=>Ds()??"ask"),X=O(t=>{D(t),$s(t==="ask"?null:t)},[]),xe=f(Mt);xe.current=Mt;const me=f(e.videoSources);me.current=e.videoSources;const fe=f(()=>{}),[G,be]=H(null),Et=f(v);x(()=>{Et.current!==v&&(Et.current=v,be(null),Qe(null),de.current=!1,Se(!1),U(!1))},[v]),x(()=>{_e.current=!1,Ne.current=[],Xe.current=!1,Pe(null),St(!1)},[n,e.currentEpisode]),x(()=>{Ye||(de.current=!1)},[Ye]);const{data:A=[],isLoading:Fe}=Qr(),J=zr(),Rt=f(J);Rt.current=J;const _t=Gr(),Ee=Kr(),[ce,Ut]=H(()=>{try{return localStorage.getItem("playerTheaterMode")==="true"}catch{return!1}});x(()=>{try{ce?document.body.classList.add("theater-mode"):document.body.classList.remove("theater-mode")}catch(t){console.error(t)}return()=>{try{document.body.classList.remove("theater-mode")}catch(t){console.error(t)}}},[ce]),Or(()=>{if(a.state.isFullscreen||ce)return;const t=u.playerContainerRef.current,s=Ie.current;if(!t||!s)return;const i=()=>{const _=t.getBoundingClientRect().height;s.style.height=`${_}px`};i();const l=new ResizeObserver(i);return l.observe(t),()=>l.disconnect()},[a.state.isFullscreen,ce,u.playerContainerRef]);const dt=ot(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),qt=dt>0?e.episodes[dt-1]:null,Ae=dt>=0&&dt<e.episodes.length-1?e.episodes[dt+1]:null,Qt=dt>-1&&dt<e.episodes.length-1,zt=an(e.resumeTime,e.resumeDuration)||Ye,st=zt&&ur(e.episodes,e.currentEpisode,e.showMeta.status),Jt=e.showResumeModal&&(st||!zt),Bt=zt&&!st&&A.length===0&&!G&&(e.showResumeModal||Ye),pt=Jt||Bt;ln(a,!!e.selectedLink&&!ce&&!pt),x(()=>{const t=u.videoRef.current;if(!t)return;let s=!1;for(ge.current&&(ge.current.destroy(),ge.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(le)return t.src="/av-sync-test.mp4",t.play().catch(()=>{w.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){ne.current=0;return}je.current!=null?(ne.current=je.current,je.current=null):Me.current>5&&!c.current?ne.current=Me.current:c.current&&(ne.current=0);let i=e.selectedLink.link;if(i.startsWith("/api/proxy")||(i=`/api/proxy?url=${encodeURIComponent(i)}`,e.selectedLink.headers?.Referer&&(i+=`&referer=${encodeURIComponent(e.selectedLink.headers.Referer)}`)),e.selectedSource.subtitles){const pe=localStorage.getItem("playerSubtitlesEnabled")!=="false";let we=null;try{we=localStorage.getItem("playerLastSubtitle")}catch{}const ee=Yt(e.selectedSource.subtitles,{lastKey:we,enabled:pe}),Be=ee>=0?e.selectedSource.subtitles[ee]:null;e.selectedSource.subtitles.forEach(ve=>{const te=document.createElement("track");te.kind="subtitles",te.label=ve.label,te.srclang=ve.lang;const S=ve.src??ve.url;if(S){let re=`/api/subtitle-proxy?url=${encodeURIComponent(S)}`;const ae=e.selectedLink?.headers?.Referer,wt=S.includes("anilight.live")?"https://anilight.live/":"",Wt=ae||wt;Wt&&(re+=`&referer=${encodeURIComponent(Wt)}`),te.src=re}Be&&ve.label===Be.label&&ve.lang===Be.lang&&(te.default=!0),t.appendChild(te)}),pe||w.setActiveSubtitleTrack("off"),w.setAvailableSubtitles(e.selectedSource.subtitles)}const l=ne.current;ne.current=0;const _=()=>{l>0&&(t.currentTime=l)};t.addEventListener("loadedmetadata",_,{once:!0});const he=!(c.current&&Me.current>5),K=()=>{he&&t.play().catch(()=>{w.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const pe=await Sn();if(s)return;if(!pe||!pe.isSupported()){t.src=i,K();return}const we=document.body.classList.contains("low-end"),ee=new pe({maxBufferLength:we?15:30,maxMaxBufferLength:we?30:60,maxBufferSize:we?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});ge.current=ee,ee.on(pe.Events.ERROR,(te,S)=>{S.fatal&&!_e.current&&fe.current()});const Be=(e.selectedSource?.subtitles?.length??0)>0,ve=()=>{try{Be&&typeof ee.subtitleTrack=="number"&&ee.subtitleTrack!==-1&&(ee.subtitleTrack=-1)}catch{}};ee.on(pe.Events.SUBTITLE_TRACK_SWITCH,(te,S)=>{S?.id!==-1&&ve()}),ve(),ee.loadSource(i),ee.attachMedia(t),ee.once(pe.Events.MANIFEST_PARSED,()=>{s||K()})})():(t.src=i,K());const q=localStorage.getItem("playerVolume"),oe=localStorage.getItem("playerMuted");return q!==null&&(t.volume=parseFloat(q)),oe!==null&&(t.muted=oe==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",_),ge.current&&(ge.current.destroy(),ge.current=null)}},[e.selectedSource,e.selectedLink,u.videoRef,w,e.loadingVideo,le]);const Lt=O(t=>{if(_e.current)return;_e.current=!0;const s=t.links[0];ie(t.sourceName),m({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),Pe(null)},[m,ie]),It=O(()=>{const s=me.current.find(i=>i.type==="iframe");return s?.links?.length?s:null},[]),Dt=O(async()=>{const t=e.showMeta?.isAdult,s=Q.filter(i=>{if(Ne.current.includes(i))return!1;const l=ke.has(i);return t===void 0?!0:l===t});St(!0);try{for(const i of s){Ne.current.push(i);let l=null;try{l=await Te.data.video.query({showId:n,episodeNumber:e.currentEpisode,mode:e.currentMode,provider:i})}catch{continue}const _=(l??[]).filter(q=>{const oe=q.sourceName.toLowerCase();return e.currentMode==="dub"?oe.includes("eng")||oe.includes("dub"):oe.includes("jpn")||oe.includes("sub")||!oe.includes("eng")&&!oe.includes("dub")});if((_.length>0?_:l??[]).find(q=>q.type!=="iframe"&&q.links?.length)){Ne.current=[e.selectedProvider],Xe.current=!1,m({type:"SET_STATE",payload:{selectedProvider:i,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",i),Pe(null),Ge.success(`Switched to ${i} (direct stream)`);return}}Pe({retryFailed:!0}),Ge.error("No working direct stream found on other providers")}finally{St(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,m,Q,ke]),Zt=O(()=>{if(_e.current||Xe.current||e.selectedSource?.type!=="player")return;const t=It();if(!t)return;Ne.current.includes(e.selectedProvider)||Ne.current.push(e.selectedProvider);const s=xe.current;if(s==="iframe"){Lt(t);return}if(s==="retry"){Dt();return}w.setShowControls(!0),Pe({retryFailed:!1})},[e.selectedSource,e.selectedProvider,It,Lt,Dt,w]);fe.current=Zt;const gr=O(()=>{Xe.current=!0,Pe(null),At(!1)},[]),br=O(()=>{ut&&X("iframe");const t=It();t?Lt(t):Pe(null)},[ut,X,It,Lt]),yr=O(()=>{ut&&X("retry"),Dt()},[ut,X,Dt]),Nt=(t,s,i)=>t.showId===s||!!i&&t.showId===i,$t=O(()=>{w.onEnded();const t=A.find(i=>Nt(i,n,e.showMeta?.id)&&i.episodeNumber===e.currentEpisode);if(A.length>0){const i=A.findIndex(_=>Nt(_,n,e.showMeta?.id)&&_.episodeNumber===e.currentEpisode),l=i>=0?A[i+1]||null:A[0];be({nextItem:l,playedItem:t||null}),Qe(2)}else t&&Rt.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&A.length===0){const i=e.episodes.findIndex(l=>l===e.currentEpisode);if(i>-1&&i<e.episodes.length-1){const l=e.episodes[i+1];Y.invalidateQueries({queryKey:["allContinueWatching"]}),C(`/watch/${n}/${l}`),s=!0}}!s&&A.length===0&&!G&&!de.current&&ur(e.episodes,e.currentEpisode,e.showMeta.status)&&m({type:"SET_STATE",payload:{showResumeModal:!0}})},[w,C,A,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,G,m,Y]),Gt=O(()=>{if(A.length===0)return;w.onEnded();const t=A.find(l=>Nt(l,n,e.showMeta?.id)&&l.episodeNumber===e.currentEpisode),s=A.findIndex(l=>Nt(l,n,e.showMeta?.id)&&l.episodeNumber===e.currentEpisode),i=s>=0?A[s+1]||null:A[0];t&&J.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),i?C(`/watch/${i.showId}/${i.episodeNumber}`):t&&m({type:"SET_STATE",payload:{showResumeModal:!0}})},[w,C,A,J,n,e.showMeta?.id,e.currentEpisode,m]),Pt=O(()=>{Ae&&(Y.invalidateQueries({queryKey:["allContinueWatching"]}),T(!1),C(`/watch/${n}/${Ae}`)),m({type:"SET_STATE",payload:{showResumeModal:!1}})},[Ae,C,n,m,Y]),er=O(()=>{A.length>0?Gt():Ae?Pt():Ge.error("No next episode available")},[A.length,Gt,Pt,Ae]),Sr=()=>{qt&&C(`/watch/${n}/${qt}`)};x(()=>{const t=u.videoRef.current;if(!t)return;const s=()=>{le||$t()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[$t,u.videoRef,le]),x(()=>{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]),x(()=>{if(!G||ct===null)return;if(ct<=0){const{nextItem:s,playedItem:i}=G;be(null),Qe(null),i&&Rt.current.mutate({showId:i.showId,episodeNumber:i.episodeNumber}),s?C(`/watch/${s.showId}/${s.episodeNumber}`):i&&m({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{Qe(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[G,ct,C,m]),x(()=>{pt&&a.state.isFullscreen&&a.actions.toggleFullscreen()},[pt,a.state.isFullscreen,a.actions]),x(()=>{pt&&u.videoRef.current&&u.videoRef.current.pause()},[pt,u.videoRef]);const{titlePreference:Ft}=Hr(),{lowEndMode:Er}=jr(),mt=ot(()=>{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]);x(()=>{mt&&mt!=="Loading..."&&e.currentEpisode&&(document.title=`► ${mt} Episode ${e.currentEpisode} - dango`)},[mt,e.currentEpisode]),x(()=>{const t=s=>{if(!s.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')&&(["arrowup","arrowdown","arrowleft","arrowright"].includes(s.key.toLowerCase())&&(w.setShowControls(!0),a.actions.inactivityTimer.current&&clearTimeout(a.actions.inactivityTimer.current),a.actions.inactivityTimer.current=window.setTimeout(()=>{w.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&er(),s.key.toLowerCase()==="t")){const l=!ce;Ut(l),localStorage.setItem("playerTheaterMode",l.toString())}};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[w,a.actions.inactivityTimer,er,ce]);const{setAvailableSubtitles:tr,setActiveSubtitleTrack:Kt}=w;x(()=>{const t=u.videoRef.current;if(!t)return;const s=()=>{const i=Array.from(t.textTracks).map(l=>({label:l.label,lang:l.language,src:void 0,mode:l.mode}));tr(i)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[u.videoRef,tr]),x(()=>{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){Kt("off");return}const i=a.state.availableSubtitles[s];Kt(i.lang||i.label)}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,Kt]),x(()=>{const t=u.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(_=>{_.mode="hidden"});return}let l=!1;if(Array.from(t.textTracks).forEach(_=>{const K=(_.language===s||_.label===s)&&!l;_.mode=K?"showing":"hidden",K&&(l=!0)}),!l&&t.textTracks.length>0){const _=Array.from(t.textTracks).find(he=>he.language==="en"||he.label==="English")||t.textTracks[0];_&&(_.mode="showing")}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,u.videoRef]);const[rr,wr]=H(0);x(()=>{const t=u.videoRef.current;if(!t)return;const s=()=>wr(t.clientHeight||0);s();const i=new ResizeObserver(s);return i.observe(t),()=>i.disconnect()},[u.videoRef,e.selectedSource,e.selectedLink]),x(()=>{const t="dynamic-subtitle-styles";let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,document.head.appendChild(s));const i={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(i);const l=u.videoRef.current;if(!l)return;const _=pr(a.state.subtitleFontSize,rr||l.clientHeight||720);s.textContent=dr({...i,fontSize:_});const he=()=>{const S=Number(a.state.subtitlePosition),re=isNaN(S)?0:Math.max(0,Math.min(100,S));return Math.max(0,Math.min(100,100-re))},K=(S,re)=>{try{const ae=S;ae.snapToLines=!1,ae.line=re}catch{}},q=()=>{const S=_*16,re=l.videoHeight||l.clientHeight||720,ae=l.videoWidth||l.clientWidth||1280;return{step:S*1.3/re*100,chars:Math.max(20,Math.floor(ae/(S*.55)))}},oe=S=>{const re=he(),ae=Array.from(S.activeCues??[]);if(ae.length<=1){ae.forEach(Tt=>K(Tt,re));return}const{step:wt,chars:Wt}=q();let ir=re;for(let Tt=ae.length-1;Tt>=0;Tt--){const xr=String(ae[Tt].text??"").replace(/<[^>]*>/g,"").split(`
|
|
55
|
+
`).reduce((Ar,Br)=>Ar+Math.max(1,Math.ceil(Br.length/Wt)),0),lr=ir-xr*wt;K(ae[Tt],Math.max(0,lr)),ir=lr-wt*.4}},pe=S=>{if(!S.cues)return;const re=he();Array.from(S.cues).forEach(ae=>K(ae,re)),S.mode==="showing"&&oe(S)},we=()=>{Array.from(l.textTracks).forEach(pe)};we();const ee=S=>{const re=S.target;re.mode==="showing"&&oe(re)};Array.from(l.textTracks).forEach(S=>{S.addEventListener("cuechange",ee)});const Be=()=>{Array.from(l.textTracks).forEach(S=>{S.removeEventListener("cuechange",ee),S.addEventListener("cuechange",ee)}),we()};l.textTracks.addEventListener("addtrack",Be),l.textTracks.addEventListener("removetrack",Be);const ve=Array.from(l.querySelectorAll("track")),te=()=>{we()};return ve.forEach(S=>{S.addEventListener("load",te)}),()=>{Array.from(l.textTracks).forEach(S=>{S.removeEventListener("cuechange",ee)}),l.textTracks.removeEventListener("addtrack",Be),l.textTracks.removeEventListener("removetrack",Be),ve.forEach(S=>{S.removeEventListener("load",te)})}},[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,u.videoRef,rr]),x(()=>{if(!$e)return;const t=u.videoRef.current,s=He.current;if(!t||!s)return;const i=localStorage.getItem("playerSubtitlesEnabled")!=="false",l=a.state.activeSubtitleTrack;function _(){if(s.innerHTML="",!i||l==="off"||l===null)return;const q=Array.from(t.textTracks).find(te=>te.language===l||te.label===l);if(!q||q.mode!=="showing")return;const oe=Re/1e3;let pe;if(oe>0&&q.cues){const te=t.currentTime-oe;pe=Array.from(q.cues).filter(S=>S.startTime<=te&&te<=S.endTime)}else pe=Array.from(q.activeCues??[]);if(pe.length===0)return;const we={fontSize:pr(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},ee=cn(we),Be=un(t,we.position),ve=Array.from(pe);ve.forEach((te,S)=>{const re=String(te.text??"");if(!dn(re).trim())return;const ae=document.createElement("div"),wt=(ve.length-1-S)*1.7;ae.style.cssText=`${ee}
|
|
56
|
+
bottom: calc(${Be}px + ${wt}em);`,ae.innerHTML=pn(re),s.appendChild(ae)})}const he=()=>_(),K=()=>_();return Array.from(t.textTracks).forEach(q=>{q.addEventListener("cuechange",he)}),t.addEventListener("timeupdate",K),_(),()=>{Array.from(t.textTracks).forEach(q=>{q.removeEventListener("cuechange",he)}),t.removeEventListener("timeupdate",K),s.innerHTML=""}},[W.isEnabled,W.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,u.videoRef,$e,Re]),x(()=>{try{localStorage.setItem("anime4kProfile",y)}catch{}},[y]);const Tr=()=>{u.videoRef.current&&(u.videoRef.current.currentTime=e.resumeTime,u.videoRef.current.play()),m({type:"SET_STATE",payload:{showResumeModal:!1}})},kr=()=>{u.videoRef.current&&(u.videoRef.current.currentTime=0,u.videoRef.current.play()),m({type:"SET_STATE",payload:{showResumeModal:!1}})},nr=O(()=>{st&&(de.current=!0),Bt&&T(!1),m({type:"SET_STATE",payload:{showResumeModal:!1}})},[m,st,Bt]),Cr=O(()=>{if(T(!1),u.videoRef.current)try{u.videoRef.current.currentTime=0,u.videoRef.current.play().catch(()=>{})}catch{}m({type:"SET_STATE",payload:{showResumeModal:!1}})},[m,u]),Mr=O(async()=>{try{await N(),m({type:"SET_STATE",payload:{showResumeModal:!1}}),C("/")}catch{}},[N,m,C]),sr=(t,s)=>r("div",{className:t,children:[r("button",{className:`${d.episodeNavBtn} ${d.secondary}`,onClick:Sr,disabled:!qt,type:"button",children:[r(j,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${d.episodeNavBtn} ${d.primary}`,onClick:Pt,disabled:!Ae,type:"button",children:["Next EP",r(j,{name:"chevron-right",size:12})]}),s==="mobile"&&Ve&&r("button",{className:`${d.episodeNavBtn} ${d.episodePickerBtn}`,onClick:()=>gt(!0),type:"button",children:[r(j,{name:"list-ul",size:12}),"Episodes"]})]});x(()=>{Ye&&(e.showResumeModal||A.length>0||G||de.current||st&&m({type:"SET_STATE",payload:{showResumeModal:!0}}))},[Ye,st,e.showResumeModal,A.length,G,m]);const Rr=t=>{m({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),yn(t)},or=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),_r=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",Ht=f(B);Ht.current=B;const ar=f("");x(()=>{const t=u.videoRef.current;if(Ct(!1),T(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const i=t.duration,l=t.currentTime;if(!i||Number.isNaN(i)){Ct(!1),T(!1);return}const _=l/i;if(i-l<=60){const he=A.findIndex(oe=>Nt(oe,n,e.showMeta?.id)&&oe.episodeNumber===e.currentEpisode),K=A.length>0?he>=0?A[he+1]||null:A[0]:null,q=K?`${K.showId}:${K.episodeNumber}`:Qt?`${n}:${Ae}`:"";q&&ar.current!==q&&(ar.current=q,K?Ht.current(K.episodeNumber,K.showId):Ht.current(Ae))}Ct(Qt&&_>=.8),T(l>=Math.max(i*.98,i-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[u.videoRef,Qt,e.currentEpisode,e.selectedSource,Ae,n,A,e.showMeta?.id]);const Nr=O(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||$)return;const t=u.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,$,u.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 Je=e.loadingShowData||e.loadingVideo,Pr=t=>{ce&&t.target===t.currentTarget&&(Ut(!1),localStorage.setItem("playerTheaterMode","false"))};return e.showMeta?.isAdult===!0&&!R?r("div",{className:ze.playerPageLayout,children:r(Le,{isOpen:!0,title:"Content Warning",onClose:()=>C("/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(Ze,{variant:"secondary",onClick:()=>C("/home"),children:"Go Back"}),r(Ze,{onClick:E,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${ze.playerPageLayout} ${ce?ze.theaterMode:""}`,onClick:Pr,children:[r(Le,{isOpen:Jt,onClose:nr,title:st?"Show Completed!":"Resume Playback?",width:"sm",children:st?r(kt,{children:[r(Le.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r(Le.Actions,{children:r(Ze,{onClick:Mr,disabled:Oe,children:Oe?"Saving...":"Move to Completed"})})]}):r(kt,{children:[r(Le.Body,{children:r("p",{children:["You were watching at ",r("strong",{children:a.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]})}),r(Le.Actions,{children:[r(Ze,{variant:"secondary",onClick:kr,children:"Start Over"}),r(Ze,{onClick:Tr,children:"Resume"})]})]})}),r(Le,{isOpen:Bt,onClose:nr,title:"Episode Completed",width:"sm",children:[r(Le.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",Ae?" Would you like to watch the next episode?":""]})}),r(Le.Actions,{children:[r(Ze,{variant:"secondary",onClick:Cr,children:"Replay"}),Ae&&r(Ze,{onClick:Pt,children:`Watch EP ${Ae}`})]})]}),r(Le,{isOpen:!!bt,onClose:gr,title:"Direct stream failed",width:"sm",children:[r(Le.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),bt?.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:ut,onChange:t=>At(t.target.checked)}),"Remember my choice"]})]}),r(Le.Actions,{children:[r(Ze,{variant:"secondary",onClick:br,children:"Continue with iframe"}),r(Ze,{onClick:yr,disabled:yt,children:yt?"Searching…":"Try another provider"})]})]}),r(Yr,{isOpen:!!e.showCookieModal,onClose:()=>m({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{Y.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!ce&&r("aside",{ref:Ie,className:ze.episodeSidebar,children:e.loadingShowData?r(mn,{variant:"sidebar"}):r(fn,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>C(`/watch/${n}/${t}`)})}),r("div",{className:ze.playerMain,children:[r("div",{className:`${d.videoContainer} ${a.state.isFullscreen?"":ze.videoPlayerWrapper} ${a.state.isFullscreen?d.fullscreenActive:""}`,style:{...pt?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(ms,{player:a,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Rr,fallbackChoice:Mt,onFallbackChoiceChange:X,showNextEpisodeButton:!pt&&Vt&&A.length===0,onNextEpisode:Pt,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{u.videoRef.current&&!isNaN(u.videoRef.current.currentTime)&&(ne.current=u.videoRef.current.currentTime),ie(t.sourceName),m({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:Je,skipIntervals:e.skipIntervals,animeTitle:mt,episodeNumber:e.currentEpisode,isTheaterMode:ce,onTheaterModeToggle:()=>{const t=!ce;Ut(t),localStorage.setItem("playerTheaterMode",t.toString())},anime4kEnabled:W.isEnabled,onAnime4kToggle:W.toggle,anime4kSupported:W.isWebGPUSupported,anime4kProfile:y,onAnime4kProfileChange:o,anime4kInitializing:W.isInitializing,anime4kError:W.error,videoDelayEnabled:F,onVideoDelayToggle:t=>{ye(t);try{localStorage.setItem("playerVideoDelayEnabled",String(t))}catch{}},videoDelayMs:h,onVideoDelayChange:z,onCalibrateAvSync:rt,isInteractingExtra:lt||Z,className:hn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(kt,{children:[a.state.isSpeedBoostActive&&r("div",{className:d.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(j,{name:"forward",size:12})]}),ct!==null&&G?.nextItem&&r("div",{className:d.queueCountdown,children:["Queue next in ",ct,"s"]})]}),children:[Je&&r("div",{className:d.loadingOverlay,children:r("div",{className:d.loadingDots,children:[r("div",{className:d.dot}),r("div",{className:d.dot}),r("div",{className:d.dot})]})}),a.state.isBuffering&&!Je&&e.selectedSource?.type!=="iframe"&&r("div",{className:d.bufferingOverlay,children:r("div",{className:d.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!Je&&r("iframe",{src:e.selectedLink?.link,className:d.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(kt,{children:[!Je&&e.videoSources.length===0&&r("div",{className:d.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:d.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:d.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Je&&e.videoSources.length>0&&r("video",{ref:u.videoRef,controls:a.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:w.onPlay,onPause:w.onPause,onLoadedMetadata:w.onLoadedMetadata,onTimeUpdate:()=>{le||(w.onTimeUpdate(),G&&u.videoRef.current&&u.videoRef.current.currentTime<u.videoRef.current.duration-1&&(be(null),Qe(null)))},onProgress:w.onProgress,onVolumeChange:w.onVolumeChange,onWaiting:w.onWaiting,onPlaying:w.onPlaying,onCanPlay:w.onCanPlay,onError:Zt,onContextMenu:t=>t.preventDefault(),className:$e?d.videoElementHidden:""}),W.isWebGPUSupported&&!Je&&e.videoSources.length>0&&r("canvas",{ref:De,className:`${d.upscalerCanvas} ${Ue?d.upscalerActive:""}`}),!Ue&&!Je&&e.videoSources.length>0&&r("canvas",{ref:vt,className:`${d.upscalerCanvas} ${qe?d.upscalerActive:""}`}),W.isEnabled&&W.isWebGPUSupported&&W.isInitializing&&r("div",{className:d.upscalerStatusBadge,children:"Preparing upscaler…"}),$e&&r("div",{ref:He,className:d.subtitleOverlay}),r(vn,{isOpen:Z,ms:h,onChange:z,onApply:se,onClose:at,testClipActive:le,onTestClip:ue})]})]})}),!ce&&r(gn,{}),!ce&&r(kt,{children:[Fe&&A.length===0?r(fs,{count:3}):r(wn,{title:"Queue",items:A,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:Gt,onRemove:t=>J.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>_t.mutate(),showClearAll:!0,onReorder:t=>Ee.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:d.providerAndEpisodeRow,children:[r(ws,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:L,onProviderChange:t=>{_e.current=!1,Ne.current=[],Xe.current=!1,Pe(null),m({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",t)}}),sr(`${d.episodeActions} ${d.desktopEpisodeActions}`,"desktop")]}),Je?r("div",{className:d.sourceLoader,children:r("div",{className:d.spinner})}):r(kt,{children:r(ks,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{u.videoRef.current&&!isNaN(u.videoRef.current.currentTime)&&(ne.current=u.videoRef.current.currentTime);const i=(t.links||[]).sort((l,_)=>(parseInt(_.resolutionStr)||0)-(parseInt(l.resolutionStr)||0))[0]||null;ie(t.sourceName),m({type:"SET_STATE",payload:{selectedSource:t,selectedLink:i,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(ie(e.selectedSource.sourceName),m({type:"SET_STATE",payload:{selectedLink:t}}))}})}),r("div",{className:ze.playerInfoContainer,children:[r("div",{className:ze.playerInfoHeader,children:[r("div",{className:ze.playerAnimeCard,children:r("img",{src:Xr(e.showMeta.thumbnail||""),alt:mt,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:ze.videoTitleSection,children:[r("div",{className:d.titleContainer,children:[r("h1",{children:mt}),r("div",{className:d.scheduleInfo,children:[e.showMeta.status&&r("span",{className:d.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:d.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:d.controls,children:[r("button",{className:`${d.watchlistBtn} ${e.inWatchlist?d.inList:""}`,onClick:Ce,children:[e.inWatchlist?r(j,{name:"check",size:14}):r(j,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(kn,{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:`${d.watchlistBtn} ${d.queueBtn}`,activeClassName:d.queueActive}),_r&&r("button",{className:`${d.watchlistBtn} ${d.markWatchedBtn} ${or?d.markWatchedDone:""}`,onClick:Nr,disabled:$||!e.currentEpisode,children:[r(j,{name:"check",size:14}),$?"Saving...":or?"Watched":"Mark Watched"]}),r("button",{className:`${d.watchlistBtn} ${d.modeToggleBtn} ${e.currentMode==="dub"?d.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";_e.current=!1,Ne.current=[],Xe.current=!1,Pe(null),m({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:`${d.watchlistBtn} ${d.modeToggleBtn} ${a.state.useNativeControls?d.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(`${d.episodeActions} ${d.mobileEpisodeActions}`,"mobile"),r("div",{className:d.descriptionSection,children:[r("h3",{children:"Synopsis"}),r(Mn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."})]}),r("button",{className:d.detailsToggleBtn,onClick:We,children:[e.showCombinedDetails?r(j,{name:"chevron-up"}):r(j,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]}),e.showCombinedDetails&&r(Cn,{showMeta:e.showMeta,styles:d})]})]})]}),r(bn,{isOpen:lt,onClose:()=>gt(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{gt(!1),C(`/watch/${n}/${t}`)}})]})};export{to as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as I,d as X,T as Y,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as Z,O as _,a as ee,A as ne}from"./OptionListMenu-
|
|
1
|
+
import{g as I,d as X,T as Y,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as Z,O as _,a as ee,A as ne}from"./OptionListMenu-DngTgHxH.js";import{u as te}from"./index-gMxawd-E.js";import"./AvSyncCalibrator-BuHurVgo.js";import"./vendor-query-BBT5_sHx.js";const ae="_settingsPanel_y6z3b_1",se="_header_y6z3b_33",le="_backBtn_y6z3b_56",ie="_contentWrapper_y6z3b_76",re="_menuContent_y6z3b_82",ce="_menuItem_y6z3b_89",oe="_selected_y6z3b_114",de="_currentValue_y6z3b_134",me="_menuNote_y6z3b_141",ue="_menuError_y6z3b_150",n={settingsPanel:ae,header:se,backBtn:le,contentWrapper:ie,menuContent:re,menuItem:ce,selected:oe,currentValue:de,menuNote:me,menuError:ue},he=(A,z)=>{const{isOpen:b,onClose:pe,videoSources:be,currentSource:v,currentLink:k,onSourceChange:w,subtitles:$,activeSubtitleTrack:y,onSubtitleChange:P,subtitleSettings:V,onSubtitleSettingsChange:O,useNativeControls:g,onNativeControlsToggle:E,anime4kEnabled:u,onAnime4kToggle:U,anime4kSupported:C,anime4kProfile:i,onAnime4kProfileChange:h,anime4kInitializing:B,anime4kError:f,videoDelayEnabled:N,onVideoDelayToggle:T,videoDelayMs:S,onVideoDelayChange:D,onCalibrateAvSync:M,isAutoSkipEnabled:d,onAutoSkipChange:x,isAutoplayEnabled:m,onAutoplayChange:L,fallbackChoice:p,onFallbackChoiceChange:W}=A,{lowEndMode:G}=te(),[a,r]=X("main");I.useEffect(()=>{if(!b){const t=setTimeout(()=>r("main"),300);return()=>clearTimeout(t)}},[b]);const j=()=>e("div",{className:n.menuContent,children:[e("button",{className:n.menuItem,onClick:()=>r("quality"),children:[e("span",{children:"Quality"}),e("span",{className:n.currentValue,children:k?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>r("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:y||"Off"})]}),e("button",{className:n.menuItem,onClick:()=>r("subtitle-style"),children:e("span",{children:"Subtitle Style"})}),G&&e("button",{className:`${n.menuItem} ${g?n.selected:""}`,onClick:()=>{const t=!g;E(t),localStorage.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),g&&e(o,{name:"check",size:12})]}),C&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{U(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),C&&u&&e("button",{className:n.menuItem,onClick:()=>r("upscaler"),children:e("span",{children:"Upscaler Settings"})}),e("button",{className:n.menuItem,onClick:()=>r("av-sync"),children:[e("span",{children:"A/V Sync"}),e("span",{className:n.currentValue,children:N?`${S}ms`:"Off"})]}),e("button",{className:n.menuItem,onClick:()=>r("playback"),children:[e("span",{children:"Playback"}),e("span",{className:n.currentValue,children:[d?"Auto-skip On":null,m?"Autoplay On":null].filter(Boolean).join(" • ")||"Off"})]})]}),q=()=>{const t=v?.links.sort((s,c)=>(parseInt(c.resolutionStr)||0)-(parseInt(s.resolutionStr)||0))||[];return e("div",{className:n.menuContent,children:e(_,{classes:{item:n.menuItem,active:n.selected},options:t.map(s=>({key:s.resolutionStr,label:s.resolutionStr,selected:k?.resolutionStr===s.resolutionStr})),onSelect:s=>{const c=t.find(l=>l.resolutionStr===s);c&&w(v,c)}})})},F=()=>e("div",{className:n.menuContent,children:e(_,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:y==="off"},...$.map(t=>({key:t.label||t.lang,label:t.label,selected:y===(t.label||t.lang)}))],onSelect:t=>P(t)})}),Q=()=>e("div",{className:n.menuContent,children:e(ee,{classes:{item:n.menuItem,active:n.selected},values:V,onChange:O})}),R=Y(()=>{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}},[]),H=()=>e("div",{className:n.menuContent,children:[B&&e("div",{className:n.menuNote,role:"status",children:"Preparing GPU, this can take a few seconds…"}),f&&e("div",{className:n.menuError,role:"alert",children:["Upscaler failed: ",f]}),!R&&e("div",{className:n.menuNote,children:"Upscaling performs best in Chrome-based browsers."}),e("button",{className:`${n.menuItem} ${i==="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"})]}),i==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="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"})]}),i==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="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"})]}),i==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="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"})]}),i==="denoise"&&e(o,{name:"check",size:12})]})]}),K=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${d?n.selected:""}`,onClick:()=>x(!d),"aria-pressed":d,children:[e("span",{children:"Auto-skip openings and endings"}),e("span",{className:n.currentValue,children:d?"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} ${m?n.selected:""}`,onClick:()=>L(!m),"aria-pressed":m,children:[e("span",{children:"Autoplay next episode"}),e("span",{className:n.currentValue,children:m?"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:()=>W(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."})]}),J=()=>e("div",{className:n.menuContent,children:e(ne,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:N,delayMs:S,onToggle:T,onDelayChange:D,onCalibrate:M})});return b?e(Z,{classes:{panel:n.settingsPanel,header:n.header,backBtn:n.backBtn,title:"",content:n.contentWrapper},title:a==="main"?"Settings":a.charAt(0).toUpperCase()+a.slice(1).replace("-"," "),titleTag:"h3",showBack:a!=="main",onBack:()=>r("main"),panelRef:z,onPanelClick:t=>t.stopPropagation(),children:[a==="main"&&j(),a==="quality"&&q(),a==="subtitles"&&F(),a==="subtitle-style"&&Q(),a==="upscaler"&&H(),a==="av-sync"&&J(),a==="playback"&&K()]}):null},Ne=I.forwardRef(he);export{Ne as default};
|
package/client/dist/assets/{QueueOptionsButton-5eloKF5J.js → QueueOptionsButton-ClVTpH8J.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as F}from"./vendor-query-BBT5_sHx.js";import{t as T,l as H,a3 as J,a4 as W,a5 as X}from"./index-
|
|
1
|
+
import{b as F}from"./vendor-query-BBT5_sHx.js";import{t as T,l as H,a3 as J,a4 as W,a5 as X}from"./index-gMxawd-E.js";import{d as Y,T as R,q as r,u as t,$ as Z,S as w}from"./vendor-core-DfaOB3Rn.js";import{a as ee,c as te,d as ne,b as se,o as ae,f as oe,s as ie}from"./vendor-ui-3qrARCPr.js";import{I as u}from"./vendor-icons-DrybRNxP.js";function Pe(n){return F({queryKey:["show-meta",n],queryFn:async()=>n?T.data.showMeta.query({id:n}):{},enabled:!!n,staleTime:3e4})}async function re(n){try{return await T.watchlist.queueSuggested.query({showId:n})}catch{throw new Error("Failed to resolve suggested episode")}}const ue="_trigger_1vova_6",le="_triggerBtn_1vova_11",me="_chevron_1vova_25",ce="_menu_1vova_34",de="_menuTitle_1vova_51",pe="_menuItem_1vova_60",ge="_removeItem_1vova_91",fe="_menuEmpty_1vova_99",o={trigger:ue,triggerBtn:le,chevron:me,menu:ce,menuTitle:de,menuItem:pe,removeItem:ge,menuEmpty:fe},ve=8,qe=({showId:n,showName:v,showThumbnail:h,nativeName:y,englishName:_,showType:b,className:z="",activeClassName:A="",align:D="right",onMenuOpenChange:p})=>{const{data:E=[]}=H(),P=J(),q=W(),[l,f]=Y(!1),{refs:Q,floatingStyles:M,context:S}=ee({open:l,onOpenChange:e=>{e||(f(!1),p?.(!1))},placement:D==="left"?"bottom-start":"bottom-end",middleware:[ae(ve),oe({padding:8}),ie({padding:8})],whileElementsMounted:se}),x=te(S,{outsidePress:!0,escapeKey:!0,referencePress:!1}),{getReferenceProps:C,getFloatingProps:I}=ne([x]),m=R(()=>E.filter(e=>e.showId===n),[E,n]),{data:K}=F({queryKey:["suggestedEpisode",n],queryFn:()=>re(n),enabled:!!n}),{data:$,isFetching:N}=X(n,l),s=R(()=>$?.episodes||[],[$]),k=r(()=>{f(!0),p?.(!0)},[p]),c=r(()=>{f(!1),p?.(!1)},[p]),d=m.length>0,a=s.length>0,g=K?.episodeNumber,i=r(e=>{!n||e.length===0||(P.mutate({showId:n,episodeNumbers:e,showName:v,showThumbnail:h,nativeName:y,englishName:_,type:b}),c())},[n,v,h,y,_,b,P,c]),L=r(()=>{!n||m.length===0||(q.mutate({showId:n,episodeNumbers:m.map(e=>e.episodeNumber)}),c())},[n,m,q,c]),O=r(()=>{a?i([s[0]]):g&&i([String(g)])},[a,s,g,i]),U=r(()=>{a&&i(s.slice(0,3))},[a,s,i]),G=r(()=>{a&&i([...s])},[a,s,i]),B=s[0],V=s[Math.min(2,s.length-1)],j=t("div",{className:o.trigger,ref:Q.setReference,children:t("span",{className:`${o.triggerBtn} ${z} ${d?A:""}`,role:"button",tabIndex:0,"aria-haspopup":"menu","aria-expanded":l,"aria-label":d?"Queued":"Queue",...C(),onClick:e=>{e.preventDefault(),e.stopPropagation(),l?c():k()},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),l?c():k())},children:[d?t(u,{name:"check",size:14}):t(u,{name:"plus",size:14}),d?"Queued":"Queue",t(u,{name:"chevron-down",size:10,className:o.chevron})]})});return t(w,{children:[j,l&&Z(t("div",{ref:Q.setFloating,className:o.menu,style:M,role:"menu",...I(),onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[t("div",{className:o.menuTitle,children:"Queue episodes"}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a&&!g,onClick:e=>{e.stopPropagation(),O()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+1 — EP ${B}`:`+1 — EP ${g||"?"}`})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),U()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+3 — EP ${B}${s.length>1?`-${V}`:""}`:"+3"})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),G()},children:[t(u,{name:"plus",size:11}),t("span",{children:["All Remaining",N?"":` (${Math.max(s.length,0)})`]})]}),!N&&s.length===0&&t("div",{className:o.menuEmpty,children:d?"All episodes are already queued":"No remaining unwatched episodes"}),d&&t("button",{className:`${o.menuItem} ${o.removeItem}`,role:"menuitem",type:"button",onClick:e=>{e.stopPropagation(),L()},children:[t(u,{name:"times",size:11}),t("span",{children:["Remove from Queue",m.length>0?` (${m.length})`:""]})]})]}),document.body)]})};export{qe as Q,Pe as u};
|