@serifpersia/dango 3.3.6 → 3.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/client/dist/assets/{AnimeCard-OKU7LaSN.js → AnimeCard-D4qo4289.js} +1 -1
- package/client/dist/assets/{AnimeInfo-BCyLw0yz.js → AnimeInfo-BdRRm4So.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-BZWl-TJY.js → AnimeInfoPage-DeJNAKMR.js} +2 -2
- package/client/dist/assets/{Asmr-4S6uoevp.js → Asmr-D0EGRYsv.js} +1 -1
- package/client/dist/assets/{AsmrResetProgressModal-C8i6weqW.js → AsmrResetProgressModal-Gs0GmVaT.js} +1 -1
- package/client/dist/assets/{AvSyncCalibrator-oK6LlG61.js → AvSyncCalibrator-D8hqarVB.js} +1 -1
- package/client/dist/assets/Home-BnBzjFkW.js +1 -0
- package/client/dist/assets/Insights-Dc8xLmsr.css +1 -0
- package/client/dist/assets/Insights-i9QgY3nE.js +1 -0
- package/client/dist/assets/LibraryListPage-D3hTqTRU.js +1 -0
- package/client/dist/assets/{ListeningList-Dxkhy6E2.js → ListeningList-BgWsfu40.js} +1 -1
- package/client/dist/assets/{Manga-pJEpcUpo.js → Manga-Dn-CYins.js} +1 -1
- package/client/dist/assets/MangaInfoPage-EmQoK7Bv.js +1 -0
- package/client/dist/assets/MangaReadPage-xJB8K2YU.js +1 -0
- package/client/dist/assets/{MangaResetProgressModal-WjKH_G_f.js → MangaResetProgressModal-Dian37PQ.js} +1 -1
- package/client/dist/assets/Mature-DQtXKOXc.js +1 -0
- package/client/dist/assets/{MediaCard-DszKDA4s.js → MediaCard-DpKoY-1j.js} +1 -1
- package/client/dist/assets/{Music-CU6TBHF5.js → Music-BP43Zqmq.js} +1 -1
- package/client/dist/assets/{OptionListMenu-CkK2BvEz.js → OptionListMenu-Bj9ebsW3.js} +1 -1
- package/client/dist/assets/Player-O2Cy2GF1.js +56 -0
- package/client/dist/assets/PlayerSettings-DYZ272Yp.js +1 -0
- package/client/dist/assets/{QueueOptionsButton-DKWi-9kd.js → QueueOptionsButton-lv26-6jp.js} +1 -1
- package/client/dist/assets/{QueueRail-DAcIex5B.js → QueueRail-B7DeSFoA.js} +1 -1
- package/client/dist/assets/{Radio-BhTsgGGd.js → Radio-qQBYnVfY.js} +1 -1
- package/client/dist/assets/{ReadingList-BLnkwB--.js → ReadingList-BT8kUjCB.js} +1 -1
- package/client/dist/assets/{ResetProgressModal-8mcLXaAb.js → ResetProgressModal-DWeiO-hs.js} +1 -1
- package/client/dist/assets/Search-BkvPYN33.js +1 -0
- package/client/dist/assets/{Settings-bSA7BG7h.js → Settings-CyZEBF6S.js} +1 -1
- package/client/dist/assets/SkeletonGrid-B5loz7ii.js +1 -0
- package/client/dist/assets/SkeletonGrid-Bge3aRl2.css +1 -0
- package/client/dist/assets/Trackers-JK-aXBYC.js +2 -0
- package/client/dist/assets/{Tv-DJTbg4VW.js → Tv-BwXWJxMy.js} +1 -1
- package/client/dist/assets/{TvInfo-Z0c1Wh3i.js → TvInfo-Dzyq6ucH.js} +1 -1
- package/client/dist/assets/{TvPopup-CP41CncZ.js → TvPopup-PlCU30FO.js} +1 -1
- package/client/dist/assets/TvSearch-BYwCf5kO.js +1 -0
- package/client/dist/assets/{TvWatchlist-COCWPkgh.js → TvWatchlist-BiJU6pKT.js} +1 -1
- package/client/dist/assets/Watchlist-BOEeGXH9.js +1 -0
- package/client/dist/assets/{hls-B_yo8-yR.js → hls-C11FOWHj.js} +1 -1
- package/client/dist/assets/index-CtoKRNLc.js +178 -0
- package/client/dist/assets/{useAnimeInfoData-CbNnHRj8.js → useAnimeInfoData-kr3WOIWH.js} +1 -1
- package/client/dist/assets/{useAsmr-BEcgHwxg.js → useAsmr-CB9THf0m.js} +1 -1
- package/client/dist/assets/{useAsmrPopup-BXD3y2m1.js → useAsmrPopup-cT_Uu41e.js} +1 -1
- package/client/dist/assets/useMangaLibrary-rM6z3_0E.js +1 -0
- package/client/dist/assets/{useMangaPopup-BvgtZ53s.js → useMangaPopup-PnmSctHu.js} +1 -1
- package/client/dist/assets/{useProviders-xlftutIo.js → useProviders-B3VB7A9M.js} +1 -1
- package/client/dist/assets/{useTv-DTqrJEWp.js → useTv-BTUKMH7Q.js} +1 -1
- package/client/dist/assets/{useTvLibrary-BHeWSd1F.js → useTvLibrary-C0sX-ilZ.js} +1 -1
- package/client/dist/index.html +1 -1
- package/package.json +2 -2
- package/server/dist/controllers/data.controller.js +1 -0
- package/server/dist/controllers/insights.controller.js +8 -3
- package/server/dist/controllers/manga-library.controller.js +54 -0
- package/server/dist/controllers/proxy.controller.js +94 -23
- package/server/dist/controllers/watchlist.controller.js +55 -1
- package/server/dist/lib/anilist.js +36 -3
- package/server/dist/lib/discord-roles-sync.service.js +237 -2
- package/server/dist/lib/mal.js +69 -0
- package/server/dist/lib/tracker/anilist-tracker.js +66 -0
- package/server/dist/lib/tracker/manga-sync.service.js +792 -0
- package/server/dist/repositories/insights.repository.js +10 -0
- package/server/dist/repositories/manga.repository.js +17 -2
- package/server/dist/repositories/shows-meta.repository.js +4 -1
- package/server/dist/repositories/watchlist.repository.js +1 -0
- package/server/dist/routes/insights.routes.js +1 -0
- package/server/dist/routes/manga-library.routes.js +2 -0
- package/server/dist/routes/tracker.routes.js +123 -0
- package/server/dist/sync.js +8 -1
- package/server/package.json +1 -1
- package/client/dist/assets/Home-CQ4Ikeja.js +0 -1
- package/client/dist/assets/Insights-DKtoVe6L.css +0 -1
- package/client/dist/assets/Insights-DiAo0UAc.js +0 -1
- package/client/dist/assets/LibraryListPage-B0MDTnEc.js +0 -1
- package/client/dist/assets/MangaInfoPage-BEQsjTHH.js +0 -1
- package/client/dist/assets/MangaReadPage-C0WAtK-1.js +0 -1
- package/client/dist/assets/Mature-Ckx99wFj.js +0 -1
- package/client/dist/assets/Player-C3yWQkXb.js +0 -56
- package/client/dist/assets/PlayerSettings-CBdTzo0E.js +0 -1
- package/client/dist/assets/Search-DxX021dj.js +0 -1
- package/client/dist/assets/SkeletonGrid-DhPYefXr.css +0 -1
- package/client/dist/assets/SkeletonGrid-Du10CNfq.js +0 -1
- package/client/dist/assets/Trackers-BXSONaRD.js +0 -2
- package/client/dist/assets/TvSearch-BlqTQYJa.js +0 -1
- package/client/dist/assets/Watchlist-BHLshSPX.js +0 -1
- package/client/dist/assets/index-lo-bz7f2.js +0 -178
- package/client/dist/assets/useMangaLibrary-BXhgN-dl.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as F,A as C,q as W,h as g,u as e,S as Y,n as oe,o as ce,a as le,T as de}from"./vendor-core-8R2fFbyN.js";import{E as ge}from"./ErrorMessage-z4f4WGgP.js";import{I as x}from"./vendor-icons-CDMuNDeL.js";import{u as ue}from"./vendor-query-BXRECSI6.js";import{t as he,v as me,m as pe,k as fe,r as ve,n as be,w as Ne,q as ye,s as we}from"./useMangaLibrary-rM6z3_0E.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import{d as Se}from"./index-CtoKRNLc.js";const G="mangaReadMode",ee="mangaFitMode";function Ce(){try{return localStorage.getItem(G)==="page"?"page":"strip"}catch{return"strip"}}function Ie(){try{return localStorage.getItem(ee)==="height"?"height":"width"}catch{return"width"}}const $e=({provider:d,mangaTitle:h,chapter:p,chapters:b,onBack:N,onOpenChapter:v,initialPage:l=0,onProgress:D,savedPage:$=0})=>{const[c,U]=F(Ce),[i,_]=F(Ie),[u,T]=F(0),[M,m]=F(new Set),[y,I]=F(0),E=C(null),B=C([]),z=ue(),{data:V,isLoading:k,isError:L}=he(d,p.id),a=V?.pages??[],O=a.map(n=>me(d,n)),w=C(0),q=C(0),P=C(!1);q.current=a.length;const s=b.findIndex(n=>n.id===p.id),o=s>0?[...b.slice(0,s)].reverse().find(n=>!n.externalUrl)??null:null,S=s>=0?b.slice(s+1).find(n=>!n.externalUrl)??null:null,R=W(n=>{P.current=!0,T(r=>{const f=r+n;return f<0?(o&&v(o),0):f>=a.length?(S&&v(S),r):f})},[a.length,o,S,v]);g(()=>{P.current=!1,w.current=Math.max(0,l),T(Math.max(0,l)),m(new Set),B.current=[],l<=0&&window.scrollTo(0,0)},[p.id,l]);const Z=C(D);Z.current=D;const j=C("");g(()=>{w.current=u,a.length!==0&&Z.current?.(Math.min(u+1,a.length),a.length)},[u,a.length]),g(()=>{l<=0||P.current||w.current===0&&(P.current=!1,w.current=l,T(l))},[l]),g(()=>{if(c!=="strip"||a.length===0||l<=0)return;const n=`${p.id}:${l}`;if(j.current===n)return;j.current=n;const r=window.setTimeout(()=>{B.current[Math.min(l,a.length-1)]?.scrollIntoView({block:"start"})},150);return()=>window.clearTimeout(r)},[c,a.length,l,p.id]),g(()=>{document.title=`${h} Ch. ${p.number} - dango`},[h,p.number]),g(()=>{try{localStorage.setItem(G,c)}catch{}},[c]),g(()=>{try{localStorage.setItem(ee,i)}catch{}},[i]),g(()=>{c==="page"&&window.scrollTo(0,0)},[c]),g(()=>{if(c!=="page"||a.length===0)return;const n=r=>{r.key==="ArrowRight"||r.key===" "?(r.preventDefault(),R(1)):r.key==="ArrowLeft"&&(r.preventDefault(),R(-1))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[c,a.length,R]),g(()=>{if(c!=="strip"||a.length===0)return;const n=new IntersectionObserver(r=>{for(const f of r)if(f.isIntersecting){const Q=Number(f.target.dataset.pageIndex);Number.isNaN(Q)||(Q!==w.current&&(P.current=!0),T(Q))}},{rootMargin:"-45% 0px -45% 0px",threshold:0});return B.current.forEach(r=>r&&n.observe(r)),()=>n.disconnect()},[c,a.length,V]);const te=n=>{E.current=n.touches[0].clientX},ne=n=>{if(E.current===null)return;const r=n.changedTouches[0].clientX-E.current;E.current=null,!(Math.abs(r)<50)&&R(r<0?1:-1)},K=n=>{n&&v(n)},H=n=>m(r=>{if(r.has(n))return r;const f=new Set(r);return f.add(n),f}),ae=n=>{m(r=>{const f=new Set(r);return f.delete(n),f}),I(r=>r+1)},re=()=>{m(new Set),I(n=>n+1),z.invalidateQueries({queryKey:["mangaPages",d,p.id]})},se=a.length>0&&M.size>=a.length,X=n=>y>0?`${n}&n=${y}`:n,J=n=>e("div",{className:t.deadPage,role:"alert",children:[e("span",{children:["Page ",n+1," failed to load"]}),e("button",{className:t.pageBtn,onClick:()=>ae(n),children:[e(x,{name:"sync-alt",size:12})," Retry"]})]}),A=i==="height",ie=$>0?$-1:-1;return e("div",{className:t.readerShell,children:[e("div",{className:t.readerBar,children:[e("button",{className:t.readerIconBtn,onClick:N,"aria-label":"Back to chapters",children:e(x,{name:"chevron-left",size:14})}),e("span",{className:t.readerTitle,children:[h," — Ch. ",p.number,p.title?` ${p.title}`:""]}),a.length>0&&e("span",{className:t.readerCounter,children:[Math.min(u+1,a.length)," / ",a.length]}),e("div",{className:t.readerSegment,role:"group","aria-label":"Reading mode",children:[e("button",{type:"button","aria-pressed":c==="strip",className:c==="strip"?t.readerSegmentActive:"",onClick:()=>U("strip"),children:"Strip"}),e("button",{type:"button","aria-pressed":c==="page",className:c==="page"?t.readerSegmentActive:"",onClick:()=>U("page"),children:"Page"})]}),e("div",{className:t.readerSegment,role:"group","aria-label":"Fit mode",children:[e("button",{type:"button","aria-pressed":!A,className:A?"":t.readerSegmentActive,onClick:()=>_("width"),title:"Fit width — best for portrait / phones",children:"Wide"}),e("button",{type:"button","aria-pressed":A,className:A?t.readerSegmentActive:"",onClick:()=>_("height"),title:"Fit height — best for landscape / desktop",children:"Tall"})]}),e("button",{className:t.readerIconBtn,disabled:!o,onClick:()=>K(o),"aria-label":"Previous chapter",children:e(x,{name:"chevron-left",size:14})}),e("button",{className:t.readerIconBtn,disabled:!S,onClick:()=>K(S),"aria-label":"Next chapter",children:e(x,{name:"chevron-right",size:14})})]}),L?e("p",{className:t.statusMsg,children:"Failed to load pages. Please try again."}):k?e("div",{className:t.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((n,r)=>e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},r))}):a.length===0?e("p",{className:t.statusMsg,children:"No pages found for this chapter."}):se?e("div",{className:t.failedBox,children:[e("p",{className:t.statusMsg,children:"Page images failed to load (expired or blocked links)."}),e("button",{className:t.pageBtn,onClick:re,children:[e(x,{name:"sync-alt",size:12})," Reload pages"]})]}):c==="strip"?e("div",{className:`${t.readerPages} ${A?t.readerPagesTall:""}`,children:O.map((n,r)=>e("div",{ref:f=>{B.current[r]=f},"data-page-index":r,className:t.readerPageWrap,children:[r===ie&&e("div",{className:t.saveMarker,role:"note","aria-label":"Saved reading position",children:[e(x,{name:"bookmark",size:12}),e("span",{children:["Saved · p. ",$]})]}),M.has(r)?J(r):e("img",{className:t.readerPage,src:X(n),alt:`Page ${r+1}`,loading:r<3?"eager":"lazy",decoding:"async",draggable:!1,onError:()=>H(r)})]},`${r}-${a[r].slice(-32)}`))}):e(Y,{children:[e("div",{className:`${t.pageView} ${A?t.pageViewTall:""}`,onTouchStart:te,onTouchEnd:ne,children:[e("button",{className:`${t.tapZone} ${t.tapZoneLeft}`,onClick:()=>R(-1),"aria-label":"Previous page",children:e("span",{className:t.tapChevron,children:e(x,{name:"chevron-left",size:16})})}),M.has(u)?J(u):e("img",{className:t.pageImage,src:X(O[u]),alt:`Page ${u+1} of ${a.length}`,decoding:"async",draggable:!1,onError:()=>H(u)},`${u}-${a[u].slice(-32)}`),e("button",{className:`${t.tapZone} ${t.tapZoneRight}`,onClick:()=>R(1),"aria-label":"Next page",children:e("span",{className:t.tapChevron,children:e(x,{name:"chevron-right",size:16})})})]}),e("nav",{className:t.pagination,"aria-label":"Page navigation",children:[e("button",{className:t.pageBtn,disabled:u<=0,onClick:()=>R(-1),children:"Previous page"}),e("span",{className:t.pageIndicator,children:[u+1," / ",a.length]}),e("button",{className:t.pageBtn,disabled:u>=a.length-1,onClick:()=>R(1),children:"Next page"})]})]}),(o||S)&&e("nav",{className:t.pagination,children:[e("button",{className:t.pageBtn,disabled:!o,onClick:()=>K(o),children:"Previous chapter"}),e("button",{className:t.pageBtn,disabled:!S,onClick:()=>K(S),children:"Next chapter"})]})]})},ke=800,Pe=5e3;function Ae(){const{provider:d="",id:h=""}=oe(),[p]=ce(),b=le(),N=p.get("chapter")||"",v=p.get("rating")||"safe",l=typeof localStorage<"u"&&localStorage.getItem("agreedToViewMature")==="true",D=l?v:"safe",$=d&&h?pe(d,h):"",c=d.toLowerCase()==="anilist";g(()=>{c&&h&&b(`/manga/anilist/${encodeURIComponent(h)}`,{replace:!0})},[c,h,b]);const U=fe(!c&&d?d:null,!c&&h?h:null,D,l),i=U.data,{titlePreference:_}=Se(),u=i?ve(i,_):"Manga",T=be($||void 0),M=Ne(),m=i&&N?i.chapters.find(s=>s.id===N)??null:null,y=ye(N),I=y!=null&&i?we(i.chapters,y):null;g(()=>{if(y!=null&&I&&I.id!==N){const s=new URLSearchParams;s.set("chapter",I.id),l&&v!=="safe"&&s.set("rating",v),b(`/manga/${d}/${encodeURIComponent(h)}/read?${s.toString()}`,{replace:!0})}},[y,I,N,l,v,d,h,b]);const E=y!=null&&!!i&&!!I,B=y!=null&&!!i&&!I,z=de(()=>{const s=(T.data?.progress??[]).find(o=>o.chapterId===N);return s&&s.page>0?s.page:0},[T.data,N]),V=z>1?z-1:0,k=C(null),L=C(null),a=W(()=>{k.current&&(clearTimeout(k.current),k.current=null);const s=L.current;L.current=null,s&&$&&M.mutate({mangaId:$,chapterId:s.chapterId,chapterNumber:s.chapterNumber,page:s.page,pageCount:s.pageCount,title:i?.title??null,cover:i?.cover??null,provider:d||null,altTitle:i?.altTitle??null,contentRating:i?.contentRating??null})},[$,M,i?.title,i?.cover,i?.altTitle,i?.contentRating,d]),O=W((s,o)=>{m&&(L.current={chapterId:m.id,chapterNumber:m.number,page:s,pageCount:o},k.current&&clearTimeout(k.current),k.current=setTimeout(a,ke))},[m,a]);g(()=>{a()},[N,a]),g(()=>()=>a(),[a]),g(()=>{const s=window.setInterval(()=>{L.current&&a()},Pe);return()=>window.clearInterval(s)},[a]),g(()=>{const s=()=>{document.visibilityState==="hidden"&&a()},o=()=>a();return document.addEventListener("visibilitychange",s),window.addEventListener("pagehide",o),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("pagehide",o)}},[a]);const w=C("");w.current||(w.current=`manga-${Date.now()}-${Math.random().toString(36).slice(2)}`),g(()=>{if(!i||!m)return;const s=i.contentRating==="erotica"||i.contentRating==="pornographic"||i.type==="doujinshi",o=()=>{fetch("/api/discord/manga",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:i.title,chapterLabel:`Chapter ${m.number}`,isPlaying:!0,thumbnail:i.cover||"",thumbnails:[i.cover].filter(Boolean),isAdult:s,sessionId:w.current})}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:w.current})}).catch(()=>{})};o();const S=window.setInterval(o,6e4);return()=>window.clearInterval(S)},[i,m]);const q=s=>{if(a(),s.externalUrl){window.open(s.externalUrl,"_blank","noopener,noreferrer");return}const o=new URLSearchParams;o.set("chapter",s.id),l&&v!=="safe"&&o.set("rating",v),b(`/manga/${d}/${encodeURIComponent(h)}/read?${o.toString()}`)},P=()=>{a();const s=new URLSearchParams;l&&v!=="safe"&&s.set("rating",v);const o=s.toString()?`?${s.toString()}`:"";b(`/manga/${d}/${encodeURIComponent(h)}${o}`)};return c?null:e("div",{className:t.page,children:U.isLoading||E?e("div",{className:t.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((s,o)=>e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},o))}):!i||!m?e(Y,{children:[e("button",{className:t.backBtn,onClick:P,children:"Back to title"}),e(ge,{message:B?`Chapter ${y} isn't available from ${d} for this title.`:"Failed to load this chapter. Please try again."})]}):e($e,{provider:d,mangaTitle:u,chapter:m,chapters:i.chapters,onBack:P,onOpenChapter:q,initialPage:V,onProgress:O,savedPage:z},m.id)})}export{Ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as n,u as l}from"./vendor-core-8R2fFbyN.js";import{R as i}from"./ResetProgressModal-
|
|
1
|
+
import{d as n,u as l}from"./vendor-core-8R2fFbyN.js";import{R as i}from"./ResetProgressModal-DWeiO-hs.js";import{B as f,o as R}from"./useMangaLibrary-rM6z3_0E.js";const p=({mangaId:e,title:a,onClose:s})=>{const[r,o]=n(!1),t=f(),m=R();return l(i,{isOpen:!!e,itemName:a,progressKind:"reading",listLabel:"my reading list",alsoRemove:r,onAlsoRemoveChange:o,onClose:()=>{o(!1),s()},onConfirm:()=>{e&&(t.mutate({mangaId:e}),r&&m.mutate(e),o(!1),s())}})};export{p as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as t,a as Me,o as ke,h as ue,d as s,T as me,S as he}from"./vendor-core-8R2fFbyN.js";import{b as ge}from"./vendor-query-BXRECSI6.js";import{B as O,M as we,q as E,Q as Fe,z as qe}from"./index-CtoKRNLc.js";import{I as pe}from"./vendor-icons-CDMuNDeL.js";import{S as xe,P as ve}from"./SkeletonGrid-B5loz7ii.js";import{A as Ue}from"./AnimeCard-D4qo4289.js";import{E as Ye}from"./ErrorMessage-z4f4WGgP.js";import{u as je}from"./useMatureConsent-CT7-KfzG.js";import{u as Ke}from"./useProviders-B3VB7A9M.js";import{s as a}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-kr3WOIWH.js";import"./QueueOptionsButton-lv26-6jp.js";import"./vendor-ui-CUDCvRS_.js";import"./MediaCard-DpKoY-1j.js";import"./useIsMobile-Dm_b6Ob3.js";const Qe=({isOpen:u,onClose:i,onGrant:F})=>t(we,{isOpen:u,title:"Content Warning",onClose:i,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:i,children:"Go Back"}),t(O,{onClick:F,children:"I'm 18+, Continue"})]})]})}),Ve="_shrinkSelect_130sm_1",We="_tightGrid_130sm_7",W={shrinkSelect:Ve,tightGrid:We},ze=[{value:"anilist",label:"AniList"},{value:"mal",label:"MAL"}],He=[{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"}],Ze=[{value:"",label:"Relevance"},{value:"visits:desc",label:"Most Visited"},{value:"title:asc",label:"Title A-Z"}],Xe={recent:"Latest",popular:"Popular",views:"Most Viewed",rating:"Top Rated",random:"Random"},et=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],fe=u=>u.split("-").map(i=>i&&i[0].toUpperCase()+i.slice(1)).join(" ");function ft(){const u=Me(),[i,F]=ke(),{hasConsent:q,grant:Se}=je();ue(()=>{document.title="Mature - dango"},[]);const[l,ye]=s(i.get("provider")||"anilist"),[S,z]=s(i.get("query")||""),[I,x]=s(i.get("query")||""),[L,h]=s(parseInt(i.get("page")||"1",10)||1),[T,U]=s(()=>{const e=i.get("sortBy");return e||(l==="mal"?"SCORE_DESC":"POPULARITY_DESC")}),[R,H]=s(i.get("sortBy")||""),[y,be]=s(i.get("status")||""),[_,Ce]=s(i.get("season")||"ALL"),[D,Ne]=s(i.get("year")||"ALL"),[g,G]=s(i.get("genre")||i.get("genres")||""),[Y,Ae]=s(i.get("order")||"recent"),[j,Pe]=s(i.get("studio")||""),[$,Ee]=s(i.get("studio")||""),[J,Z]=s([]),[K,Oe]=s(!1),[Ie,X]=s(null),{options:ee}=Ke(),te=me(()=>ee.filter(e=>e.mature&&(e.kind??"anime")==="anime"),[ee]),ae=me(()=>[...ze,...te.map(e=>({value:e.value,label:e.label}))],[te]),{data:B}=ge({queryKey:["mature-filters"],queryFn:()=>E("/api/mature/filters"),enabled:q,staleTime:1/0}),c=l==="anilist"||l==="mal",Q=c?void 0:B?.providers?.[l],N=Q?.browse,A=Q?.genres??[],b=Q?.orders??[],re=b.length>0&&!b.includes(Y)?b[0]:Y,M=!c&&(N?.genre===!0||A.length>0||J.length>0),p=!c&&(N?.order===!0||b.length>0),C=!c&&N?.studio===!0,ie=!c&&N?.sort===!0,k=c?14:N?.pageSize??14,v=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=B?.providers?.[e.provider]?.browse,d=B?.providers?.[e.provider]?.orders??[],o=d.length>0&&!d.includes(e.remoteOrder)?d[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!==(d[0]??"recent")&&r.set("order",o),(!n||n.studio)&&e.studio.trim()&&r.set("studio",e.studio.trim())}F(r,{replace:!0})},f=(e={})=>({provider:l,query:I,page:L,sort:T,remoteSort:R,status:y,season:_,year:D,genre:g,remoteOrder:Y,studio:$,...e}),le=(()=>{const e=new URLSearchParams;return e.set("provider",l),I.trim()&&e.set("query",I.trim()),e.set("page",String(L)),e.set("limit",String(k)),l==="anilist"&&(e.set("sortBy",T),y&&e.set("status",y),_!=="ALL"&&e.set("season",_),D!=="ALL"&&e.set("year",D)),l==="mal"?(e.set("sortBy",T),y&&e.set("status",y)):c||(M&&g&&e.set("genre",g),p&&e.set("order",re),ie&&R&&e.set("sortBy",R),C&&$.trim()&&e.set("studio",$.trim())),e.toString()})(),{data:m,isLoading:Le,isError:Te,error:Re}=ge({queryKey:["mature-search",le],queryFn:()=>E(`/api/mature/search?${le}`),enabled:q});ue(()=>{const e=m?.genres;!c&&A.length===0&&e&&e.length>0&&Z(r=>{const n=new Set(r.map(o=>o.slug)),d=[...r];for(const o of e)o.slug&&!n.has(o.slug)&&(n.add(o.slug),d.push(o));return d.length===r.length?r:d})},[m,l,c,A.length]);const w=(m?.data||[]).map(e=>({...e,isAdult:!0})),se=m?.hasMore??!1,P=()=>{Fe(),h(1);let e=g;!c&&!p&&S.trim()&&(e=""),G(e),C&&Ee(j),x(S),v(f({query:S,page:1,genre:e,studio:C?j:$}))},_e=e=>{ye(e),h(1),H(""),G(""),Z([]),e==="mal"?U("SCORE_DESC"):e==="anilist"&&U("POPULARITY_DESC"),x(S),v(f({provider:e,page:1,remoteSort:"",genre:"",query:S}))},De=e=>{G(e),h(1),e&&(z(""),x("")),v(f({genre:e,page:1,query:e?"":I}))},ne=e=>{h(e),v(f({page:e})),window.scrollTo({top:0,behavior:"smooth"})},Ge=async(e,r)=>{const n=r.id||r._id;if(l!=="mal"&&!/^\d+$/.test(n)&&(e.preventDefault(),e.stopPropagation(),!Ie)){X(n);try{if(l!=="anilist"){let o=!1;try{o=(await E("/api/anilist-status"))?.available===!0}catch{o=!1}if(o){const de=await E(`/api/mature/resolve?title=${encodeURIComponent(r.name)}`);u(`/anime/${de.id}`);return}const oe=await fetch("/api/mature/allocate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:l,nativeId:n,title:r.name,thumbnail:r.thumbnail})}),ce=await oe.json().catch(()=>null);if(!oe.ok||!ce?.id)throw new Error("Allocate failed");u(`/anime/${ce.id}`);return}const d=await E(`/api/mature/resolve?title=${encodeURIComponent(r.name)}`);u(`/anime/${d.id}`)}catch{qe.error("Could not match this title on AniList")}finally{X(null)}}},V=new Date().getFullYear(),$e=[{value:"ALL",label:"All Years"},...Array.from({length:V-1980+1},(e,r)=>({value:String(V-r),label:String(V-r)}))],Be=A.length>0?A.map(e=>({value:e,label:fe(e)})):J.map(e=>({value:e.slug,label:e.name}));return q?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(pe,{name:"search",className:a.searchIcon}),t("input",{type:"text",placeholder:`Search ${ae.find(e=>e.value===l)?.label}...`,value:S,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key==="Enter"&&P()},className:a.searchInput})]}),t("div",{className:a.searchActions,children:[t("select",{value:l,onChange:e=>_e(e.target.value),className:a.providerSelect,"aria-label":"Provider",children:ae.map(e=>t("option",{value:e.value,children:e.label},e.value))}),t(O,{onClick:P,className:a.searchBtn,children:"Search"}),c&&t("button",{onClick:()=>Oe(!K),className:`${a.filterToggleBtn} ${K?a.active:""}`,children:[t(pe,{name:"filter"})," Filters"]}),ie&&t("select",{value:R,onChange:e=>{H(e.target.value),h(1),v(f({remoteSort:e.target.value,page:1}))},className:a.providerSelect,"aria-label":"Sort",children:Ze.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),(l==="anilist"||l==="mal")&&t("div",{className:`${a.advancedFilters} ${K?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:T,onChange:e=>U(e.currentTarget.value),children:He.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:y,onChange:e=>be(e.currentTarget.value),children:Je.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),l==="anilist"&&t(he,{children:[t("div",{className:a.filterItem,children:[t("label",{children:"Season"}),t("select",{value:_,onChange:e=>Ce(e.currentTarget.value),children:et.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:D,onChange:e=>Ne(e.currentTarget.value),children:$e.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]})]}),t("div",{className:a.filterActions,children:t(O,{onClick:P,className:a.searchBtn,children:"Apply Filters"})})]}),!c&&!!B&&(M||p||C)&&t("div",{className:`${a.advancedFilters} ${a.show}`,children:[t("div",{className:a.filterDivider}),t("div",{className:`${a.filterGrid} ${W.tightGrid}`,children:[p&&t("div",{className:`${a.filterItem} ${W.shrinkSelect}`,children:[t("label",{children:"Order"}),t("select",{value:re,onChange:e=>{Ae(e.target.value),h(1),v(f({remoteOrder:e.target.value,page:1}))},children:(b.length>0?b:["recent"]).map(e=>t("option",{value:e,children:Xe[e]||e},e))})]}),M&&t("div",{className:`${a.filterItem} ${W.shrinkSelect}`,children:[t("label",{children:"Genre"}),t("select",{value:g,onChange:e=>{p?(G(e.target.value),h(1),v(f({genre:e.target.value,page:1}))):De(e.target.value)},children:[t("option",{value:"",children:"All Genres"}),Be.map(e=>t("option",{value:e.value,children:e.label},e.value))]})]}),C&&t("div",{className:a.filterItem,children:[t("label",{children:"Studio"}),t("input",{type:"text",placeholder:"Studio name...",value:j,onChange:e=>Pe(e.target.value),onKeyDown:e=>{e.key==="Enter"&&P()},className:a.searchInput})]})]}),g&&M&&!p&&t("p",{className:a.pageSubtitle,children:["Browsing the ",fe(g)," genre — search text is ignored while a genre is selected."]}),(p||C)&&t("div",{className:a.filterActions,children:t(O,{onClick:P,className:a.searchBtn,children:"Apply Filters"})})]})]}),Te&&t(Ye,{message:Re?.message||"Search failed"}),Le?t(xe,{count:k}):w.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(he,{children:[t("div",{className:a.resultsHeader,children:[t("h2",{className:a.resultsTitle,children:[m?.total??w.length," result",(m?.total??w.length)===1?"":"s"]}),t("div",{className:a.pagination,children:t(ve,{page:L,totalPages:Math.max(1,Math.ceil((m?.total??0)/k)),canGoNext:se,onChange:ne,variant:"labeled"})})]}),t("div",{className:a.resultsGrid,children:w.map(e=>t("div",{onClickCapture:r=>Ge(r,e),children:t(Ue,{anime:e})},`${l}-${e._id}`))}),t("div",{className:a.bottomPagination,children:t("div",{className:a.pagination,children:t(ve,{page:L,totalPages:Math.max(1,Math.ceil((m?.total??0)/k)),canGoNext:se,onChange:ne,variant:"labeled"})})})]})]}):t(Qe,{isOpen:!0,onClose:()=>u("/"),onGrant:Se})}export{ft 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-8R2fFbyN.js";import{a as Re,b as Ae,f as $e,s as Le}from"./vendor-ui-CUDCvRS_.js";import{I as v}from"./vendor-icons-CDMuNDeL.js";import{q as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-lo-bz7f2.js";import{u as Ge}from"./useIsMobile-Dm_b6Ob3.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",ct="_secondaryActions_7glox_184",lt="_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:ct,watchlistBtn:lt,detailsBtn:it,active:dt,loading:ut,spinner:_t},ln=({anchorRect:t,onMouseEnter:a,onMouseLeave:c,onRequestClose:l,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:[$e({fallbackAxisSideDirection:"start"}),Le({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:()=>l?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:c,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[c,l]=y(a);return K(()=>{l(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke(`/api/show-meta/${t}`).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&l(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:c}}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",$t="_airTime_w7bu0_234",Lt="_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:$t,adultBadge:Lt,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),c=x(null),l=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{c.current&&(clearTimeout(c.current),c.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)=>{l.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,l.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),c.current=setTimeout(()=>{c.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!c.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"?c.current&&(clearTimeout(c.current),c.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!l.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>l.current?(l.current=!1,!0):!1,[]);return{longPressFiredRef:l,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:c,progress:l,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),[$,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},L=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose(L)},[f,L]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},ce=()=>{j()},le=()=>{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&&!!l&&l.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=c==="book"?e(v,{name:"book",size:28}):c==="play"?e(v,{name:"play",size:28}):c==="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),$&&j()},onMouseLeave:()=>{D(!1),P?.(!1),$&&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&&l&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${l.percent}%`}})}),e("div",{className:n.timestamp,children:l.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&&$&&G?g(G,{close:L,onMouseEnter:ce,onMouseLeave:le}):null]})});export{dn as M,ln 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-8R2fFbyN.js";import{a as Re,b as Ae,f as $e,s as Le}from"./vendor-ui-CUDCvRS_.js";import{I as v}from"./vendor-icons-CDMuNDeL.js";import{q as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-CtoKRNLc.js";import{u as Ge}from"./useIsMobile-Dm_b6Ob3.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",ct="_secondaryActions_7glox_184",lt="_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:ct,watchlistBtn:lt,detailsBtn:it,active:dt,loading:ut,spinner:_t},ln=({anchorRect:t,onMouseEnter:a,onMouseLeave:c,onRequestClose:l,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:[$e({fallbackAxisSideDirection:"start"}),Le({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:()=>l?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:c,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[c,l]=y(a);return K(()=>{l(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke(`/api/show-meta/${t}`).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&l(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:c}}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",$t="_airTime_w7bu0_234",Lt="_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:$t,adultBadge:Lt,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),c=x(null),l=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{c.current&&(clearTimeout(c.current),c.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)=>{l.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,l.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),c.current=setTimeout(()=>{c.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!c.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"?c.current&&(clearTimeout(c.current),c.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!l.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>l.current?(l.current=!1,!0):!1,[]);return{longPressFiredRef:l,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:c,progress:l,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),[$,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},L=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose(L)},[f,L]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},ce=()=>{j()},le=()=>{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&&!!l&&l.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=c==="book"?e(v,{name:"book",size:28}):c==="play"?e(v,{name:"play",size:28}):c==="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),$&&j()},onMouseLeave:()=>{D(!1),P?.(!1),$&&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&&l&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${l.percent}%`}})}),e("div",{className:n.timestamp,children:l.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&&$&&G?g(G,{close:L,onMouseEnter:ce,onMouseLeave:le}):null]})});export{dn as M,ln as a,n as m,R as p};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as L,d as b,h as F,g as Ke,u as e,S as w,$ as Qe,o as ze,T as z}from"./vendor-core-8R2fFbyN.js";import{q as P,z as C}from"./index-lo-bz7f2.js";import{I as p}from"./vendor-icons-CDMuNDeL.js";import{a as i}from"./Asmr.module-ChUXDZKx.js";import{r as m}from"./Radio.module-DGSZLpKM.js";import{b as J,u as Ce,a as Le}from"./vendor-query-BXRECSI6.js";function Ie(n){if(!Number.isFinite(n)||n<0)return"0:00";const h=Math.floor(n/60),g=Math.floor(n%60);return`${h}:${String(g).padStart(2,"0")}`}const Ye=({track:n,shuffle:h,onToggleShuffle:g,onTrackStep:O,onTrackFailed:be,onClose:ie,liked:Y,likeVisible:W,likePending:ae,onToggleLike:V})=>{const M=L(null),Z=L(!1),[q,R]=b(!1),[he,l]=b(!0),[N,D]=b(!1),[I,B]=b(0),[U,se]=b(0),[T,H]=b(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[$,re]=b(()=>localStorage.getItem("musicAutoplay")!=="false"),j=L(T);j.current=T;const S=L($);S.current=$;const f=L(0),E=L(0),A=L(null),K=L("");K.current||(K.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const X=`/api/music/audio?videoId=${encodeURIComponent(n.id)}`,G=()=>{A.current&&(window.clearTimeout(A.current),A.current=null)},ee=r=>{const a=M.current;if(!a)return;G(),l(!0),D(!1);const k=()=>{if(a.removeEventListener("loadedmetadata",k),r>5&&Number.isFinite(a.duration)&&r<a.duration-5)try{a.currentTime=r}catch{}};a.addEventListener("loadedmetadata",k),a.src=X,a.load(),a.volume=j.current,a.play().catch(()=>{})},ve=()=>{l(!1),D(!0),be?.(n),S.current&&O(1)},oe=()=>{if(!A.current){if(E.current>=3){ve();return}E.current+=1,A.current=window.setTimeout(()=>{A.current=null,ee(f.current)},5e3)}},ke=()=>{E.current=0,ee(f.current)};F(()=>{f.current=0,E.current=0,R(!1),B(0),se(0);const r=M.current;return ee(f.current),()=>{G(),r&&r.removeAttribute("src")}},[X]),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 _=n.thumbnails?.[n.thumbnails.length-1]?.url??null,te=Ke.useCallback(r=>{const a=M.current;fetch("/api/discord/music",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n.title,artistLabel:n.artists,isPlaying:r,thumbnail:_||"",currentTime:a?.currentTime??0,duration:Number.isFinite(a?.duration??NaN)?a?.duration:0,sessionId:K.current})}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:K.current})}).catch(()=>{})},[n,_]);F(()=>{te(q)},[te,q,n.id]),F(()=>{if(!q)return;const r=window.setInterval(()=>te(!0),15e3);return()=>window.clearInterval(r)},[q,te]),F(()=>{const r=K.current,a=()=>{if(!r)return;const ye=JSON.stringify({sessionId:r});navigator.sendBeacon?(navigator.sendBeacon("/api/discord/clear",new Blob([ye],{type:"application/json"})),navigator.sendBeacon("/api/discord/heartbeat",new Blob([JSON.stringify({sessionId:r,bye:!0})],{type:"application/json"}))):(fetch("/api/discord/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:ye,keepalive:!0}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r,bye:!0}),keepalive:!0}).catch(()=>{}))},k=()=>a(),v=()=>{document.visibilityState==="hidden"&&a()};return window.addEventListener("pagehide",k),window.addEventListener("beforeunload",k),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("pagehide",k),window.removeEventListener("beforeunload",k),document.removeEventListener("visibilitychange",v),a()}},[]);const pe=()=>{const r=M.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},[Ne,le]=b(!1);F(()=>{le(!1)},[_]);const ce=`${n.title} — ${n.artists}`,ge=e(w,{children:[e("div",{className:i.playerButtons,children:[e("button",{className:i.playerBtn,onClick:()=>O(-1),"aria-label":"Previous track",children:e(p,{name:"step-backward"})}),e("button",{className:`${i.playerBtn} ${i.playBtn}`,onClick:pe,"aria-label":q?"Pause":"Play",children:q?e(p,{name:"pause"}):e(p,{name:"play"})}),e("button",{className:i.playerBtn,onClick:()=>O(1),"aria-label":"Next track",children:e(p,{name:"step-forward"})}),N&&e("button",{className:i.playerBtn,onClick:ke,title:"Retry playback","aria-label":"Retry playback",children:e(p,{name:"redo"})})]}),e("div",{className:i.seekRow,children:[e("span",{className:i.timeLabel,children:Ie(I)}),e("input",{className:i.seekBar,type:"range",min:0,max:U||0,step:.1,value:Math.min(I,U||0),onChange:r=>{const a=M.current;!a||!Number.isFinite(a.duration)||(a.currentTime=parseFloat(r.target.value),B(a.currentTime))},onPointerDown:()=>{Z.current=!0},onPointerUp:()=>{Z.current=!1},style:{"--played-percent":`${U>0?I/U*100:0}%`},"aria-label":"Seek"}),e("span",{className:i.timeLabel,children:Ie(U)}),he&&!N&&e("span",{className:i.timeLabel,children:"loading…"})]})]}),ue=e(w,{children:[n.thumbnails?.[0]?.url&&!Ne&&e("img",{src:n.thumbnails[0].url,alt:"",className:m.stationThumb,loading:"lazy",decoding:"async",onError:()=>le(!0)}),e("div",{className:i.playerInfo,children:[e("p",{className:i.playerTitle,title:ce,children:ce}),e("p",{className:i.playerTrack,children:n.artists})]}),e("div",{className:i.playerControls,children:ge}),e("div",{className:i.playerRight,children:[T===0?e(p,{name:"volume-mute",className:i.volumeIcon}):T<.5?e(p,{name:"volume-down",className:i.volumeIcon}):e(p,{name:"volume-up",className:i.volumeIcon}),e("input",{className:i.volumeBar,type:"range",min:0,max:1,step:.01,value:T,onChange:r=>{const a=parseFloat(r.target.value);H(a),localStorage.setItem("musicVolume",String(a))},style:{"--volume-percent":`${T*100}%`},"aria-label":"Volume"})]}),e("div",{className:i.playerActions,children:[W&&V&&e("button",{className:`${i.playerBtn} ${Y?i.playerBtnActive:""}`,onClick:V,disabled:ae,title:Y?"Remove from Liked Music":"Add to Liked Music","aria-label":Y?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!Y,children:e(p,{name:"heart"})}),e("button",{className:`${i.playerBtn} ${h?i.playerBtnActive:""}`,onClick:g,title:h?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":h,children:e(p,{name:"shuffle"})}),e("button",{className:`${i.playerBtn} ${$?i.playerBtnActive:""}`,onClick:()=>{re(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:$?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":$,children:e(p,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(n.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:i.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(p,{name:"external-link-alt"})}),e("button",{className:i.playerBtn,onClick:ie,"aria-label":"Close player",children:e(p,{name:"times"})})]})]});return Qe(e(w,{children:[e("audio",{ref:M,preload:"none",onPlay:()=>{R(!0),l(!1),D(!1),E.current=0,G()},onPause:()=>R(!1),onWaiting:()=>{N||l(!0)},onPlaying:()=>{l(!1),E.current=0,G()},onTimeUpdate:r=>{const a=r.target.currentTime;f.current=a,G(),Z.current||B(a)},onStalled:()=>{oe()},onLoadedMetadata:r=>{const a=r.target.duration;Number.isFinite(a)&&se(a)},onDurationChange:r=>{const a=r.target.duration;Number.isFinite(a)&&se(a)},onError:()=>{oe()},onEnded:()=>{S.current&&O(1)}}),e("div",{className:i.playerBar,children:ue})]}),document.body)},je=()=>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,Ge=()=>J({queryKey:["music-auth"],queryFn:()=>P("/api/music/auth/status"),staleTime:30*1e3,refetchInterval:n=>n.state.data?.authenticated?!1:3e3,retry:1}),Je=()=>{const n=Ce();return Le({mutationFn:h=>P("/api/music/auth/start",{method:"POST",body:JSON.stringify({cookie:h})}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-auth"]}),n.invalidateQueries({queryKey:["music-library"]})}})},We=()=>{const n=Ce();return Le({mutationFn:()=>P("/api/music/auth/signout",{method:"POST"}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-auth"]}),n.invalidateQueries({queryKey:["music-library"]})}})},Ve=n=>J({queryKey:["music-search",n],queryFn:()=>P(`/api/music/search?q=${encodeURIComponent(n)}`),enabled:n.trim().length>0,staleTime:me,retry:1}),Ze=n=>J({queryKey:["music-library"],queryFn:()=>P("/api/music/library"),enabled:n,staleTime:me,retry:1}),Xe=n=>J({queryKey:["music-track",n],queryFn:()=>P(`/api/music/track?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),et=n=>J({queryKey:["music-playlist",n],queryFn:()=>P(`/api/music/playlist?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),tt=n=>J({queryKey:["music-upnext",n],queryFn:()=>P(`/api/music/upnext?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),nt=n=>J({queryKey:["music-likes"],queryFn:()=>P("/api/music/likes"),enabled:n,staleTime:120*1e3,retry:1}),it=()=>{const n=Ce();return Le({mutationFn:({id:h,like:g})=>P("/api/music/like",{method:"POST",body:JSON.stringify({id:h,like:g})}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-likes"]}),n.invalidateQueries({queryKey:["music-library"]}),n.invalidateQueries({queryKey:["music-upnext"]})}})},at="_authRow_10tvv_1",st="_btn_10tvv_9",rt="_btnGhost_10tvv_42",ot="_cookieForm_10tvv_74",lt="_cookieInput_10tvv_83",ct="_link_10tvv_99",ut="_contentLayout_10tvv_109",dt="_mainCol_10tvv_116",mt="_upnextAside_10tvv_120",ht="_upnextHeader_10tvv_131",pt="_upnextTitle_10tvv_139",gt="_upnextActions_10tvv_149",yt="_nowPlayingLabel_10tvv_156",ft="_nowPlayingWrap_10tvv_168",bt="_likeBtn_10tvv_172",vt="_likeActive_10tvv_196",y={authRow:at,btn:st,btnGhost:rt,cookieForm:ot,cookieInput:lt,link:ct,contentLayout:ut,mainCol:dt,upnextAside:mt,upnextHeader:ht,upnextTitle:pt,upnextActions:gt,nowPlayingLabel:yt,nowPlayingWrap:ft,likeBtn:bt,likeActive:vt};function $e(n){const h=n.trim();if(!h)return null;const g=h.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??h.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return g||(/^[A-Za-z0-9_-]{11}$/.test(h)?h:null)}const kt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Lt=()=>{const[n,h]=ze(),g=$e(n.get("v")??""),[O,be]=b(""),[ie,Y]=b(""),[W,ae]=b(""),[V,M]=b(!1),[Z,q]=b(()=>localStorage.getItem("musicShuffle")==="true"),[R,he]=b(()=>localStorage.getItem("musicRadio")!=="false"),[l,N]=b(null),[D,I]=b([]),[B,U]=b(null),[se,T]=b({}),H=L([]);H.current=D;const $=L(null);$.current=l;const re=L(!1),j=L(new Set),{data:S}=Ge(),f=Je(),E=We(),A=typeof navigator<"u"?navigator.userAgent:"",K=/android/i.test(A),X=/firefox|fxios/i.test(A)&&!K,G=!X&&!K&&/chrome|chromium|edg|brave/i.test(A),ee=X||G,ve=()=>{if(V)return;M(!0);const t=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",s),M(!1),C.error("Helper not detected — install the Dango Helper extension first.")},3e3),s=c=>{window.clearTimeout(t),window.removeEventListener("dango:ytmusic-cookie",s),M(!1);try{const o=JSON.parse(c.detail);if(o?.ok&&o.cookie){const d=o.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(d.includes("…")||d.includes("...")){C.error(`Helper returned a truncated cookie (${d.length} chars) — reload music.youtube.com and Extract again.`);return}ae(d),C.success("Cookie extracted from helper — signing in…"),f.mutate(d)}else o?.error==="NO_COOKIE"?C.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):C.error("Helper request failed — try again.")}catch{C.error("Helper request failed — try again.")}};window.addEventListener("dango:ytmusic-cookie",s),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie"))},{data:oe,isLoading:ke}=Ve(ie),{data:_,isLoading:te}=Ze(S?.authenticated===!0),{data:pe,isLoading:Ne}=et(B?.id??null),{data:le,isLoading:ce}=tt(l?.id??null),{data:ge}=nt(S?.authenticated===!0),ue=it(),Q=z(()=>oe?.tracks||[],[oe]),r=z(()=>_?.playlists||[],[_]),a=z(()=>_?.tracks||[],[_]),k=z(()=>pe?.tracks||[],[pe]),v=z(()=>{const t=le?.tracks||[];return l?t.filter(s=>s.id!==l.id):t},[le,l]),ye=z(()=>new Set(ge?.likedIds||[]),[ge]),Se=t=>se[t.id]??(ye.has(t.id)||t.liked===!0);F(()=>{S?.authenticated!==!0&&T({})},[S?.authenticated]);const Ae=z(()=>[...Q,...k,...a,...v],[Q,k,a,v]),Fe=g&&l?.id!==g&&!Ae.some(t=>t.id===g)?g:null,{data:Me}=Xe(Fe),we=l?.id;F(()=>{document.title=l?`${l.title} - dango`:"Music - dango"},[l]),F(()=>{if(!g){we&&N(null);return}if(we===g)return;const t=o=>{const d=o.find(u=>u.id===g);return d?(N(d),I(u=>u.some(ne=>ne.id===g)?u:o.length>0?o:[d]),!0):!1};if(t(Q)||t(k)||t(a))return;const s=v.find(o=>o.id===g);if(s){N(s),I(o=>o.some(d=>d.id===s.id)?o:[s]);return}const c=Me?.track;c&&c.id===g&&(N(c),I(o=>o.some(d=>d.id===c.id)?o:[c]))},[g,we,Q,k,a,v,Me]);const Te=(t,s)=>{j.current.delete(t.id),N(t),I(s.length>0?s:[t]),h({v:t.id})},Be=t=>{j.current.add(t.id),C.error(`Couldn't play “${t.title}” — skipped.`)},Ee=async()=>{if(re.current)return;const t=H.current,s=t[t.length-1]??$.current;if(s){re.current=!0;try{const c=await P(`/api/music/upnext?id=${encodeURIComponent(s.id)}`),o=new Set(t.map(u=>u.id)),d=(c.tracks||[]).filter(u=>!o.has(u.id)&&!j.current.has(u.id));if(d.length===0){const u=H.current[0];u&&(N(u),h({v:u.id}));return}I([...H.current,...d]),N(d[0]),h({v:d[0].id})}catch{const c=H.current[0];c&&(N(c),h({v:c.id}))}finally{re.current=!1}}},Oe=t=>{const s=H.current,c=$.current;if(!c||s.length===0)return;const o=s.findIndex(x=>x.id===c.id);if(t>0&&R&&(o<0||o===s.length-1)){Ee();return}const d=x=>j.current.has(x.id),u=s.length;let ne;if(Z&&u>1){let x=Math.floor(Math.random()*u);for(let xe=0;xe<u&&(x===o||d(s[x]));xe++)x=Math.floor(Math.random()*u);ne=s[x]}else{const x=t>0?1:-1;let fe=(((o<0?x>0?-1:0:o)+x)%u+u)%u;for(let Re=1;Re<u&&d(s[fe]);Re++)fe=((fe+x)%u+u)%u;ne=s[fe]}N(ne),h({v:ne.id})},qe=()=>{if(R){he(!1),localStorage.setItem("musicRadio","false");return}const t=$.current;if(!t)return;if(v.length===0){C.error("No radio suggestions for this song yet.");return}const s=new Set,c=[];for(const o of[t,...v])s.has(o.id)||(s.add(o.id),c.push(o));he(!0),localStorage.setItem("musicRadio","true"),I(c),C.success(`Radio started — ${v.length} songs queued.`)},_e=t=>{if(S?.authenticated!==!0){C.error("Sign in to like songs.");return}const s=!Se(t);T(c=>({...c,[t.id]:s})),ue.mutate({id:t.id,like:s},{onError:()=>{T(c=>{const o={...c};return delete o[t.id],o}),C.error("Like action failed — try again.")}})},De=()=>{q(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Ue=t=>e("button",{className:m.stationRow,onClick:()=>U(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:m.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:m.stationThumbPlaceholder,children:e(p,{name:"headphones"})}),e("span",{className:m.stationMeta,children:[e("span",{className:m.stationName,children:t.title}),t.subtitle&&e("span",{className:m.stationSub,children:t.subtitle})]})]},t.id),de=(t,s,c)=>{const o=l?.id===t.id,d=Se(t),u=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${m.stationRow} ${o?m.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>c?c(t):Te(t,s),className:m.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:m.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:m.stationThumbPlaceholder,children:e(p,{name:"headphones"})}),e("span",{className:m.stationMeta,children:[e("span",{className:m.stationName,children:t.title}),e("span",{className:m.stationSub,children:[t.artists,u?` · ${u}`:""]})]})]}),S?.authenticated===!0&&e("button",{className:`${y.likeBtn} ${d?y.likeActive:""}`,onClick:()=>_e(t),disabled:ue.isPending,title:d?"Remove from Liked Music":"Add to Liked Music","aria-label":d?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":d,children:e(p,{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(p,{name:"external-link-alt"})})]},t.id)},Pe=z(()=>{if(!l)return v;const t=new Set,s=[];for(const c of[l,...v])t.has(c.id)||(t.add(c.id),s.push(c));return s},[l,v]),He=t=>{Te(t,Pe)};return e("div",{className:`${i.page} ${l?i.pageWithPlayer:""}`,children:[e("div",{className:i.header,children:[e("h1",{className:i.pageTitle,children:[e(p,{name:"headphones"})," Music"]}),e("form",{className:i.searchForm,onSubmit:t=>{t.preventDefault();const s=$e(O);s?(Y(""),h({v:s})):Y(O)},children:[e("input",{className:i.searchInput,value:O,onChange:t=>be(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:i.searchBtn,type:"submit","aria-label":"Search",children:e(p,{name:"search"})})]})]}),e("div",{className:y.authRow,children:[S?.authenticated?e(w,{children:[e("span",{className:i.statusMsg,children:["Signed in to YouTube Music",_&&` — ${_.tracks.length} songs, ${_.playlists.length} playlists`]}),e("button",{className:y.btnGhost,onClick:()=>E.mutate(),disabled:E.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const s=W.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(s){if(s.includes("…")||s.includes("...")){C.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}s!==W&&ae(s),f.mutate(s)}},className:y.cookieForm,children:[e("input",{className:y.cookieInput,value:W,onChange:t=>ae(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:y.btn,type:"submit",disabled:f.isPending||!W.trim(),children:f.isPending?"Checking…":"Sign in"}),ee&&e("button",{className:y.btnGhost,type:"button",onClick:ve,disabled:V||f.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:V?"Extracting…":"Extract from helper"})]}),ee&&e("p",{className:i.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:kt,target:"_blank",rel:"noreferrer",className:y.link,children:"dango-extension.zip"})," ","then"," ",X?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(je,{})]}),f.isSuccess&&e("p",{className:i.statusMsg,children:["Signed in — found ",f.data.tracks," songs and ",f.data.playlists," ","playlists."]}),f.isError&&e("p",{className:i.statusMsg,children:f.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!S?.authenticated&&!f.isError&&!f.isSuccess&&e("p",{className:i.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:l?y.contentLayout:void 0,children:[e("div",{className:y.mainCol,children:ie?e(w,{children:[e("h2",{className:m.sectionTitle,children:["Results for “",ie,"”"]}),ke?e("p",{className:i.statusMsg,children:"Searching…"}):Q.length===0?e("p",{className:i.statusMsg,children:"No tracks found."}):e("div",{className:m.stationList,children:Q.map(t=>de(t,Q))})]}):S?.authenticated?e(w,{children:[e("h2",{className:m.sectionTitle,children:"Your library"}),te?e("p",{className:i.statusMsg,children:"Loading library…"}):e(w,{children:[r.length>0&&!B&&e(w,{children:[e("h3",{className:m.sectionTitle,children:"Playlists"}),e("div",{className:m.stationList,children:r.map(t=>Ue(t))})]}),a.length>0&&!B&&e(w,{children:[e("h3",{className:m.sectionTitle,children:["Liked songs (",a.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:y.btnGhost,onClick:()=>Te(a[0],a),"aria-label":"Play all liked songs",children:[e(p,{name:"play"})," Play all"]})}),e("div",{className:m.stationList,children:a.map(t=>de(t,a))})]}),B?e(w,{children:[e("button",{className:y.btnGhost,onClick:()=>U(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:m.sectionTitle,children:B.title}),Ne?e("p",{className:i.statusMsg,children:"Loading playlist…"}):k.length===0?e("p",{className:i.statusMsg,children:"No tracks in this playlist."}):e("div",{className:m.stationList,children:k.map(t=>de(t,k))})]}):null]})]}):e("p",{className:i.statusMsg,children:"Search above, or sign in to see your library."})}),l&&e("aside",{className:y.upnextAside,"aria-label":"Up next",children:[e("div",{className:y.upnextHeader,children:e("span",{className:y.upnextTitle,children:[e(p,{name:"list-ul"})," Up Next"]})}),e("div",{className:y.nowPlayingWrap,children:[e("p",{className:y.nowPlayingLabel,children:"Now playing"}),de(l,D.length>0?D:[l])]}),e("div",{className:y.upnextActions,children:e("button",{className:y.btnGhost,onClick:qe,disabled:!R&&(ce||v.length===0),"aria-pressed":R,title:R?"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:R?"Stop radio":"Start radio"})}),ce?e("p",{className:i.statusMsg,children:"Loading suggestions…"}):v.length===0?e("p",{className:i.statusMsg,children:"No suggestions for this song."}):e("div",{className:m.stationList,children:v.map(t=>de(t,Pe,He))})]})]}),l&&e(Ye,{track:l,queue:D,shuffle:Z,onToggleShuffle:De,onTrackStep:Oe,onTrackFailed:Be,onClose:()=>{N(null),h({})},liked:l?Se(l):!1,likeVisible:S?.authenticated===!0,likePending:ue.isPending,onToggleLike:()=>_e(l)})]})};export{Lt as default};
|
|
1
|
+
import{A as L,d as b,h as F,g as Ke,u as e,S as w,$ as Qe,o as ze,T as z}from"./vendor-core-8R2fFbyN.js";import{q as P,z as C}from"./index-CtoKRNLc.js";import{I as p}from"./vendor-icons-CDMuNDeL.js";import{a as i}from"./Asmr.module-ChUXDZKx.js";import{r as m}from"./Radio.module-DGSZLpKM.js";import{b as J,u as Ce,a as Le}from"./vendor-query-BXRECSI6.js";function Ie(n){if(!Number.isFinite(n)||n<0)return"0:00";const h=Math.floor(n/60),g=Math.floor(n%60);return`${h}:${String(g).padStart(2,"0")}`}const Ye=({track:n,shuffle:h,onToggleShuffle:g,onTrackStep:O,onTrackFailed:be,onClose:ie,liked:Y,likeVisible:W,likePending:ae,onToggleLike:V})=>{const M=L(null),Z=L(!1),[q,R]=b(!1),[he,l]=b(!0),[N,D]=b(!1),[I,B]=b(0),[U,se]=b(0),[T,H]=b(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[$,re]=b(()=>localStorage.getItem("musicAutoplay")!=="false"),j=L(T);j.current=T;const S=L($);S.current=$;const f=L(0),E=L(0),A=L(null),K=L("");K.current||(K.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const X=`/api/music/audio?videoId=${encodeURIComponent(n.id)}`,G=()=>{A.current&&(window.clearTimeout(A.current),A.current=null)},ee=r=>{const a=M.current;if(!a)return;G(),l(!0),D(!1);const k=()=>{if(a.removeEventListener("loadedmetadata",k),r>5&&Number.isFinite(a.duration)&&r<a.duration-5)try{a.currentTime=r}catch{}};a.addEventListener("loadedmetadata",k),a.src=X,a.load(),a.volume=j.current,a.play().catch(()=>{})},ve=()=>{l(!1),D(!0),be?.(n),S.current&&O(1)},oe=()=>{if(!A.current){if(E.current>=3){ve();return}E.current+=1,A.current=window.setTimeout(()=>{A.current=null,ee(f.current)},5e3)}},ke=()=>{E.current=0,ee(f.current)};F(()=>{f.current=0,E.current=0,R(!1),B(0),se(0);const r=M.current;return ee(f.current),()=>{G(),r&&r.removeAttribute("src")}},[X]),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 _=n.thumbnails?.[n.thumbnails.length-1]?.url??null,te=Ke.useCallback(r=>{const a=M.current;fetch("/api/discord/music",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n.title,artistLabel:n.artists,isPlaying:r,thumbnail:_||"",currentTime:a?.currentTime??0,duration:Number.isFinite(a?.duration??NaN)?a?.duration:0,sessionId:K.current})}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:K.current})}).catch(()=>{})},[n,_]);F(()=>{te(q)},[te,q,n.id]),F(()=>{if(!q)return;const r=window.setInterval(()=>te(!0),15e3);return()=>window.clearInterval(r)},[q,te]),F(()=>{const r=K.current,a=()=>{if(!r)return;const ye=JSON.stringify({sessionId:r});navigator.sendBeacon?(navigator.sendBeacon("/api/discord/clear",new Blob([ye],{type:"application/json"})),navigator.sendBeacon("/api/discord/heartbeat",new Blob([JSON.stringify({sessionId:r,bye:!0})],{type:"application/json"}))):(fetch("/api/discord/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:ye,keepalive:!0}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r,bye:!0}),keepalive:!0}).catch(()=>{}))},k=()=>a(),v=()=>{document.visibilityState==="hidden"&&a()};return window.addEventListener("pagehide",k),window.addEventListener("beforeunload",k),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("pagehide",k),window.removeEventListener("beforeunload",k),document.removeEventListener("visibilitychange",v),a()}},[]);const pe=()=>{const r=M.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},[Ne,le]=b(!1);F(()=>{le(!1)},[_]);const ce=`${n.title} — ${n.artists}`,ge=e(w,{children:[e("div",{className:i.playerButtons,children:[e("button",{className:i.playerBtn,onClick:()=>O(-1),"aria-label":"Previous track",children:e(p,{name:"step-backward"})}),e("button",{className:`${i.playerBtn} ${i.playBtn}`,onClick:pe,"aria-label":q?"Pause":"Play",children:q?e(p,{name:"pause"}):e(p,{name:"play"})}),e("button",{className:i.playerBtn,onClick:()=>O(1),"aria-label":"Next track",children:e(p,{name:"step-forward"})}),N&&e("button",{className:i.playerBtn,onClick:ke,title:"Retry playback","aria-label":"Retry playback",children:e(p,{name:"redo"})})]}),e("div",{className:i.seekRow,children:[e("span",{className:i.timeLabel,children:Ie(I)}),e("input",{className:i.seekBar,type:"range",min:0,max:U||0,step:.1,value:Math.min(I,U||0),onChange:r=>{const a=M.current;!a||!Number.isFinite(a.duration)||(a.currentTime=parseFloat(r.target.value),B(a.currentTime))},onPointerDown:()=>{Z.current=!0},onPointerUp:()=>{Z.current=!1},style:{"--played-percent":`${U>0?I/U*100:0}%`},"aria-label":"Seek"}),e("span",{className:i.timeLabel,children:Ie(U)}),he&&!N&&e("span",{className:i.timeLabel,children:"loading…"})]})]}),ue=e(w,{children:[n.thumbnails?.[0]?.url&&!Ne&&e("img",{src:n.thumbnails[0].url,alt:"",className:m.stationThumb,loading:"lazy",decoding:"async",onError:()=>le(!0)}),e("div",{className:i.playerInfo,children:[e("p",{className:i.playerTitle,title:ce,children:ce}),e("p",{className:i.playerTrack,children:n.artists})]}),e("div",{className:i.playerControls,children:ge}),e("div",{className:i.playerRight,children:[T===0?e(p,{name:"volume-mute",className:i.volumeIcon}):T<.5?e(p,{name:"volume-down",className:i.volumeIcon}):e(p,{name:"volume-up",className:i.volumeIcon}),e("input",{className:i.volumeBar,type:"range",min:0,max:1,step:.01,value:T,onChange:r=>{const a=parseFloat(r.target.value);H(a),localStorage.setItem("musicVolume",String(a))},style:{"--volume-percent":`${T*100}%`},"aria-label":"Volume"})]}),e("div",{className:i.playerActions,children:[W&&V&&e("button",{className:`${i.playerBtn} ${Y?i.playerBtnActive:""}`,onClick:V,disabled:ae,title:Y?"Remove from Liked Music":"Add to Liked Music","aria-label":Y?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!Y,children:e(p,{name:"heart"})}),e("button",{className:`${i.playerBtn} ${h?i.playerBtnActive:""}`,onClick:g,title:h?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":h,children:e(p,{name:"shuffle"})}),e("button",{className:`${i.playerBtn} ${$?i.playerBtnActive:""}`,onClick:()=>{re(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:$?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":$,children:e(p,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(n.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:i.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(p,{name:"external-link-alt"})}),e("button",{className:i.playerBtn,onClick:ie,"aria-label":"Close player",children:e(p,{name:"times"})})]})]});return Qe(e(w,{children:[e("audio",{ref:M,preload:"none",onPlay:()=>{R(!0),l(!1),D(!1),E.current=0,G()},onPause:()=>R(!1),onWaiting:()=>{N||l(!0)},onPlaying:()=>{l(!1),E.current=0,G()},onTimeUpdate:r=>{const a=r.target.currentTime;f.current=a,G(),Z.current||B(a)},onStalled:()=>{oe()},onLoadedMetadata:r=>{const a=r.target.duration;Number.isFinite(a)&&se(a)},onDurationChange:r=>{const a=r.target.duration;Number.isFinite(a)&&se(a)},onError:()=>{oe()},onEnded:()=>{S.current&&O(1)}}),e("div",{className:i.playerBar,children:ue})]}),document.body)},je=()=>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,Ge=()=>J({queryKey:["music-auth"],queryFn:()=>P("/api/music/auth/status"),staleTime:30*1e3,refetchInterval:n=>n.state.data?.authenticated?!1:3e3,retry:1}),Je=()=>{const n=Ce();return Le({mutationFn:h=>P("/api/music/auth/start",{method:"POST",body:JSON.stringify({cookie:h})}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-auth"]}),n.invalidateQueries({queryKey:["music-library"]})}})},We=()=>{const n=Ce();return Le({mutationFn:()=>P("/api/music/auth/signout",{method:"POST"}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-auth"]}),n.invalidateQueries({queryKey:["music-library"]})}})},Ve=n=>J({queryKey:["music-search",n],queryFn:()=>P(`/api/music/search?q=${encodeURIComponent(n)}`),enabled:n.trim().length>0,staleTime:me,retry:1}),Ze=n=>J({queryKey:["music-library"],queryFn:()=>P("/api/music/library"),enabled:n,staleTime:me,retry:1}),Xe=n=>J({queryKey:["music-track",n],queryFn:()=>P(`/api/music/track?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),et=n=>J({queryKey:["music-playlist",n],queryFn:()=>P(`/api/music/playlist?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),tt=n=>J({queryKey:["music-upnext",n],queryFn:()=>P(`/api/music/upnext?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),nt=n=>J({queryKey:["music-likes"],queryFn:()=>P("/api/music/likes"),enabled:n,staleTime:120*1e3,retry:1}),it=()=>{const n=Ce();return Le({mutationFn:({id:h,like:g})=>P("/api/music/like",{method:"POST",body:JSON.stringify({id:h,like:g})}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-likes"]}),n.invalidateQueries({queryKey:["music-library"]}),n.invalidateQueries({queryKey:["music-upnext"]})}})},at="_authRow_10tvv_1",st="_btn_10tvv_9",rt="_btnGhost_10tvv_42",ot="_cookieForm_10tvv_74",lt="_cookieInput_10tvv_83",ct="_link_10tvv_99",ut="_contentLayout_10tvv_109",dt="_mainCol_10tvv_116",mt="_upnextAside_10tvv_120",ht="_upnextHeader_10tvv_131",pt="_upnextTitle_10tvv_139",gt="_upnextActions_10tvv_149",yt="_nowPlayingLabel_10tvv_156",ft="_nowPlayingWrap_10tvv_168",bt="_likeBtn_10tvv_172",vt="_likeActive_10tvv_196",y={authRow:at,btn:st,btnGhost:rt,cookieForm:ot,cookieInput:lt,link:ct,contentLayout:ut,mainCol:dt,upnextAside:mt,upnextHeader:ht,upnextTitle:pt,upnextActions:gt,nowPlayingLabel:yt,nowPlayingWrap:ft,likeBtn:bt,likeActive:vt};function $e(n){const h=n.trim();if(!h)return null;const g=h.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??h.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return g||(/^[A-Za-z0-9_-]{11}$/.test(h)?h:null)}const kt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Lt=()=>{const[n,h]=ze(),g=$e(n.get("v")??""),[O,be]=b(""),[ie,Y]=b(""),[W,ae]=b(""),[V,M]=b(!1),[Z,q]=b(()=>localStorage.getItem("musicShuffle")==="true"),[R,he]=b(()=>localStorage.getItem("musicRadio")!=="false"),[l,N]=b(null),[D,I]=b([]),[B,U]=b(null),[se,T]=b({}),H=L([]);H.current=D;const $=L(null);$.current=l;const re=L(!1),j=L(new Set),{data:S}=Ge(),f=Je(),E=We(),A=typeof navigator<"u"?navigator.userAgent:"",K=/android/i.test(A),X=/firefox|fxios/i.test(A)&&!K,G=!X&&!K&&/chrome|chromium|edg|brave/i.test(A),ee=X||G,ve=()=>{if(V)return;M(!0);const t=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",s),M(!1),C.error("Helper not detected — install the Dango Helper extension first.")},3e3),s=c=>{window.clearTimeout(t),window.removeEventListener("dango:ytmusic-cookie",s),M(!1);try{const o=JSON.parse(c.detail);if(o?.ok&&o.cookie){const d=o.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(d.includes("…")||d.includes("...")){C.error(`Helper returned a truncated cookie (${d.length} chars) — reload music.youtube.com and Extract again.`);return}ae(d),C.success("Cookie extracted from helper — signing in…"),f.mutate(d)}else o?.error==="NO_COOKIE"?C.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):C.error("Helper request failed — try again.")}catch{C.error("Helper request failed — try again.")}};window.addEventListener("dango:ytmusic-cookie",s),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie"))},{data:oe,isLoading:ke}=Ve(ie),{data:_,isLoading:te}=Ze(S?.authenticated===!0),{data:pe,isLoading:Ne}=et(B?.id??null),{data:le,isLoading:ce}=tt(l?.id??null),{data:ge}=nt(S?.authenticated===!0),ue=it(),Q=z(()=>oe?.tracks||[],[oe]),r=z(()=>_?.playlists||[],[_]),a=z(()=>_?.tracks||[],[_]),k=z(()=>pe?.tracks||[],[pe]),v=z(()=>{const t=le?.tracks||[];return l?t.filter(s=>s.id!==l.id):t},[le,l]),ye=z(()=>new Set(ge?.likedIds||[]),[ge]),Se=t=>se[t.id]??(ye.has(t.id)||t.liked===!0);F(()=>{S?.authenticated!==!0&&T({})},[S?.authenticated]);const Ae=z(()=>[...Q,...k,...a,...v],[Q,k,a,v]),Fe=g&&l?.id!==g&&!Ae.some(t=>t.id===g)?g:null,{data:Me}=Xe(Fe),we=l?.id;F(()=>{document.title=l?`${l.title} - dango`:"Music - dango"},[l]),F(()=>{if(!g){we&&N(null);return}if(we===g)return;const t=o=>{const d=o.find(u=>u.id===g);return d?(N(d),I(u=>u.some(ne=>ne.id===g)?u:o.length>0?o:[d]),!0):!1};if(t(Q)||t(k)||t(a))return;const s=v.find(o=>o.id===g);if(s){N(s),I(o=>o.some(d=>d.id===s.id)?o:[s]);return}const c=Me?.track;c&&c.id===g&&(N(c),I(o=>o.some(d=>d.id===c.id)?o:[c]))},[g,we,Q,k,a,v,Me]);const Te=(t,s)=>{j.current.delete(t.id),N(t),I(s.length>0?s:[t]),h({v:t.id})},Be=t=>{j.current.add(t.id),C.error(`Couldn't play “${t.title}” — skipped.`)},Ee=async()=>{if(re.current)return;const t=H.current,s=t[t.length-1]??$.current;if(s){re.current=!0;try{const c=await P(`/api/music/upnext?id=${encodeURIComponent(s.id)}`),o=new Set(t.map(u=>u.id)),d=(c.tracks||[]).filter(u=>!o.has(u.id)&&!j.current.has(u.id));if(d.length===0){const u=H.current[0];u&&(N(u),h({v:u.id}));return}I([...H.current,...d]),N(d[0]),h({v:d[0].id})}catch{const c=H.current[0];c&&(N(c),h({v:c.id}))}finally{re.current=!1}}},Oe=t=>{const s=H.current,c=$.current;if(!c||s.length===0)return;const o=s.findIndex(x=>x.id===c.id);if(t>0&&R&&(o<0||o===s.length-1)){Ee();return}const d=x=>j.current.has(x.id),u=s.length;let ne;if(Z&&u>1){let x=Math.floor(Math.random()*u);for(let xe=0;xe<u&&(x===o||d(s[x]));xe++)x=Math.floor(Math.random()*u);ne=s[x]}else{const x=t>0?1:-1;let fe=(((o<0?x>0?-1:0:o)+x)%u+u)%u;for(let Re=1;Re<u&&d(s[fe]);Re++)fe=((fe+x)%u+u)%u;ne=s[fe]}N(ne),h({v:ne.id})},qe=()=>{if(R){he(!1),localStorage.setItem("musicRadio","false");return}const t=$.current;if(!t)return;if(v.length===0){C.error("No radio suggestions for this song yet.");return}const s=new Set,c=[];for(const o of[t,...v])s.has(o.id)||(s.add(o.id),c.push(o));he(!0),localStorage.setItem("musicRadio","true"),I(c),C.success(`Radio started — ${v.length} songs queued.`)},_e=t=>{if(S?.authenticated!==!0){C.error("Sign in to like songs.");return}const s=!Se(t);T(c=>({...c,[t.id]:s})),ue.mutate({id:t.id,like:s},{onError:()=>{T(c=>{const o={...c};return delete o[t.id],o}),C.error("Like action failed — try again.")}})},De=()=>{q(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Ue=t=>e("button",{className:m.stationRow,onClick:()=>U(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:m.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:m.stationThumbPlaceholder,children:e(p,{name:"headphones"})}),e("span",{className:m.stationMeta,children:[e("span",{className:m.stationName,children:t.title}),t.subtitle&&e("span",{className:m.stationSub,children:t.subtitle})]})]},t.id),de=(t,s,c)=>{const o=l?.id===t.id,d=Se(t),u=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${m.stationRow} ${o?m.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>c?c(t):Te(t,s),className:m.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:m.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:m.stationThumbPlaceholder,children:e(p,{name:"headphones"})}),e("span",{className:m.stationMeta,children:[e("span",{className:m.stationName,children:t.title}),e("span",{className:m.stationSub,children:[t.artists,u?` · ${u}`:""]})]})]}),S?.authenticated===!0&&e("button",{className:`${y.likeBtn} ${d?y.likeActive:""}`,onClick:()=>_e(t),disabled:ue.isPending,title:d?"Remove from Liked Music":"Add to Liked Music","aria-label":d?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":d,children:e(p,{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(p,{name:"external-link-alt"})})]},t.id)},Pe=z(()=>{if(!l)return v;const t=new Set,s=[];for(const c of[l,...v])t.has(c.id)||(t.add(c.id),s.push(c));return s},[l,v]),He=t=>{Te(t,Pe)};return e("div",{className:`${i.page} ${l?i.pageWithPlayer:""}`,children:[e("div",{className:i.header,children:[e("h1",{className:i.pageTitle,children:[e(p,{name:"headphones"})," Music"]}),e("form",{className:i.searchForm,onSubmit:t=>{t.preventDefault();const s=$e(O);s?(Y(""),h({v:s})):Y(O)},children:[e("input",{className:i.searchInput,value:O,onChange:t=>be(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:i.searchBtn,type:"submit","aria-label":"Search",children:e(p,{name:"search"})})]})]}),e("div",{className:y.authRow,children:[S?.authenticated?e(w,{children:[e("span",{className:i.statusMsg,children:["Signed in to YouTube Music",_&&` — ${_.tracks.length} songs, ${_.playlists.length} playlists`]}),e("button",{className:y.btnGhost,onClick:()=>E.mutate(),disabled:E.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const s=W.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(s){if(s.includes("…")||s.includes("...")){C.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}s!==W&&ae(s),f.mutate(s)}},className:y.cookieForm,children:[e("input",{className:y.cookieInput,value:W,onChange:t=>ae(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:y.btn,type:"submit",disabled:f.isPending||!W.trim(),children:f.isPending?"Checking…":"Sign in"}),ee&&e("button",{className:y.btnGhost,type:"button",onClick:ve,disabled:V||f.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:V?"Extracting…":"Extract from helper"})]}),ee&&e("p",{className:i.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:kt,target:"_blank",rel:"noreferrer",className:y.link,children:"dango-extension.zip"})," ","then"," ",X?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(je,{})]}),f.isSuccess&&e("p",{className:i.statusMsg,children:["Signed in — found ",f.data.tracks," songs and ",f.data.playlists," ","playlists."]}),f.isError&&e("p",{className:i.statusMsg,children:f.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!S?.authenticated&&!f.isError&&!f.isSuccess&&e("p",{className:i.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:l?y.contentLayout:void 0,children:[e("div",{className:y.mainCol,children:ie?e(w,{children:[e("h2",{className:m.sectionTitle,children:["Results for “",ie,"”"]}),ke?e("p",{className:i.statusMsg,children:"Searching…"}):Q.length===0?e("p",{className:i.statusMsg,children:"No tracks found."}):e("div",{className:m.stationList,children:Q.map(t=>de(t,Q))})]}):S?.authenticated?e(w,{children:[e("h2",{className:m.sectionTitle,children:"Your library"}),te?e("p",{className:i.statusMsg,children:"Loading library…"}):e(w,{children:[r.length>0&&!B&&e(w,{children:[e("h3",{className:m.sectionTitle,children:"Playlists"}),e("div",{className:m.stationList,children:r.map(t=>Ue(t))})]}),a.length>0&&!B&&e(w,{children:[e("h3",{className:m.sectionTitle,children:["Liked songs (",a.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:y.btnGhost,onClick:()=>Te(a[0],a),"aria-label":"Play all liked songs",children:[e(p,{name:"play"})," Play all"]})}),e("div",{className:m.stationList,children:a.map(t=>de(t,a))})]}),B?e(w,{children:[e("button",{className:y.btnGhost,onClick:()=>U(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:m.sectionTitle,children:B.title}),Ne?e("p",{className:i.statusMsg,children:"Loading playlist…"}):k.length===0?e("p",{className:i.statusMsg,children:"No tracks in this playlist."}):e("div",{className:m.stationList,children:k.map(t=>de(t,k))})]}):null]})]}):e("p",{className:i.statusMsg,children:"Search above, or sign in to see your library."})}),l&&e("aside",{className:y.upnextAside,"aria-label":"Up next",children:[e("div",{className:y.upnextHeader,children:e("span",{className:y.upnextTitle,children:[e(p,{name:"list-ul"})," Up Next"]})}),e("div",{className:y.nowPlayingWrap,children:[e("p",{className:y.nowPlayingLabel,children:"Now playing"}),de(l,D.length>0?D:[l])]}),e("div",{className:y.upnextActions,children:e("button",{className:y.btnGhost,onClick:qe,disabled:!R&&(ce||v.length===0),"aria-pressed":R,title:R?"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:R?"Stop radio":"Start radio"})}),ce?e("p",{className:i.statusMsg,children:"Loading suggestions…"}):v.length===0?e("p",{className:i.statusMsg,children:"No suggestions for this song."}):e("div",{className:m.stationList,children:v.map(t=>de(t,Pe,He))})]})]}),l&&e(Ye,{track:l,queue:D,shuffle:Z,onToggleShuffle:De,onTrackStep:Oe,onTrackFailed:Be,onClose:()=>{N(null),h({})},liked:l?Se(l):!1,likeVisible:S?.authenticated===!0,likePending:ue.isPending,onToggleLike:()=>_e(l)})]})};export{Lt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e,S as p,d as y,h as S}from"./vendor-core-8R2fFbyN.js";import{I as m}from"./vendor-icons-CDMuNDeL.js";import{M as s,y as b,T as f,B as g,z as k,D as C}from"./AvSyncCalibrator-
|
|
1
|
+
import{u as e,S as p,d as y,h as S}from"./vendor-core-8R2fFbyN.js";import{I as m}from"./vendor-icons-CDMuNDeL.js";import{M as s,y as b,T as f,B as g,z as k,D as C}from"./AvSyncCalibrator-D8hqarVB.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,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:f,value:i.textColor,onChange:t=>o("textColor",t)}),e(b,{label:"Background Color",colors:g,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-DYZ272Yp.js","assets/vendor-core-8R2fFbyN.js","assets/vendor-icons-CDMuNDeL.js","assets/OptionListMenu-Bj9ebsW3.js","assets/AvSyncCalibrator-D8hqarVB.js","assets/index-CtoKRNLc.js","assets/vendor-query-BXRECSI6.js","assets/index-CUm1meqr.css","assets/AvSyncCalibrator-BPa6KaGC.css","assets/PlayerSettings-Bj6SsmQ2.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{g as Dt,h as x,u as r,P as Ir,z as Lr,d as q,A as f,q as O,y as $r,T as ct,n as Dr,a as Fr,c as Or,_ as Wr,S as Et}from"./vendor-core-8R2fFbyN.js";import{_ as ur,S as Nt,q as $e,z as Qe,N as Vr,j as Ur,k as Qr,l as qr,m as zr,d as Gr,u as Hr,M as Ae,B as Ze,O as Kr,f as jr}from"./index-CtoKRNLc.js";import{u as dr,b as ar,a as Gt}from"./vendor-query-BXRECSI6.js";import{C as Yr,S as Jr,U as Xr,a as Zr,p as Ht,s as en,l as tn,u as rn,b as nn,i as on,c as sn,d as ir,f as lr,e as an,g as ln,h as cn,r as un,j as Ue,E as dn,k as pn,m as u,n as mn,A as hn,P as fn,o as vn,q as gn}from"./AvSyncCalibrator-D8hqarVB.js";import{I as W}from"./vendor-icons-CDMuNDeL.js";import{l as bn}from"./hls-C11FOWHj.js";import{u as yn}from"./useMatureConsent-CT7-KfzG.js";import{u as Sn}from"./useIsMobile-Dm_b6Ob3.js";import{s as et,Q as En}from"./QueueRail-B7DeSFoA.js";import{u as wn,Q as kn}from"./QueueOptionsButton-lv26-6jp.js";import{u as pr}from"./useProviders-B3VB7A9M.js";import{A as Tn}from"./AnimeMetaDetails-BPvv5xIl.js";import{S as Cn}from"./SynopsisText-BcpwT5iw.js";import"./vendor-ui-CUDCvRS_.js";const Mn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Rn={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},_n=["direct","cookie","embed"],Nn="_controlsOverlay_1b7ea_1",xn="_hidden_1b7ea_21",Pn="_topControls_1b7ea_27",An="_backBtn_1b7ea_47",Bn="_videoTitleInfo_1b7ea_67",In="_animeTitle_1b7ea_73",Ln="_episodeNumber_1b7ea_81",$n="_bottomControls_1b7ea_89",Dn="_progressBarContainer_1b7ea_108",Fn="_progressBar_1b7ea_108",On="_thumb_1b7ea_127",Wn="_scrubbing_1b7ea_142",Vn="_watchedBar_1b7ea_146",Un="_bufferedBar_1b7ea_147",Qn="_timeBubble_1b7ea_185",qn="_skipSegment_1b7ea_219",zn="_op_1b7ea_229",Gn="_ed_1b7ea_232",Hn="_recap_1b7ea_235",Kn="_bottomControlsRow_1b7ea_239",jn="_leftControls_1b7ea_247",Yn="_rightControls_1b7ea_248",Jn="_controlBtn_1b7ea_255",Xn="_theaterBtn_1b7ea_296",Zn="_nextEpisodeBtn_1b7ea_300",eo="_active_1b7ea_317",to="_timeDisplay_1b7ea_321",ro="_skipControls_1b7ea_329",no="_skipBtn_1b7ea_335",oo="_volumeContainer_1b7ea_376",so="_volumeSlider_1b7ea_382",ao="_playerPageLayout_1b7ea_440",io="_videoPlayerWrapper_1b7ea_444",lo="_playerInfoContainer_1b7ea_449",co="_visible_1b7ea_566",uo="_shortcuts_1b7ea_584",E={controlsOverlay:Nn,hidden:xn,topControls:Pn,backBtn:An,videoTitleInfo:Bn,animeTitle:In,episodeNumber:Ln,bottomControls:$n,progressBarContainer:Dn,progressBar:Fn,thumb:On,scrubbing:Wn,watchedBar:Vn,bufferedBar:Un,timeBubble:Qn,skipSegment:qn,op:zn,ed:Gn,recap:Hn,bottomControlsRow:Kn,leftControls:jn,rightControls:Yn,controlBtn:Jn,theaterBtn:Xn,nextEpisodeBtn:Zn,active:eo,timeDisplay:to,skipControls:ro,skipBtn:no,volumeContainer:oo,volumeSlider:so,playerPageLayout:ao,videoPlayerWrapper:io,playerInfoContainer:lo,visible:co,shortcuts:uo},po=Lr(()=>ur(()=>import("./PlayerSettings-DYZ272Yp.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),mo=({player:n,isAutoplayEnabled:v,onAutoplayChange:w,showNextEpisodeButton:j,onNextEpisode:b,videoSources:C,selectedSource:S,selectedLink:P,onSourceChange:R,skipIntervals:ie,animeTitle:ye,episodeNumber:e,isTheaterMode:g,onTheaterModeToggle:V,anime4kEnabled:U,onAnime4kToggle:le,anime4kSupported:z,anime4kProfile:ve,onAnime4kProfileChange:A,anime4kInitializing:$,anime4kError:De,videoDelayEnabled:qe,onVideoDelayToggle:a,videoDelayMs:m,onVideoDelayChange:k,onCalibrateAvSync:Se,fallbackChoice:Fe,onFallbackChoiceChange:Be,children:Ie,overlays:ze,isInteractingExtra:te=!1,className:Re,hideChrome:l=!1})=>{const{state:s,refs:d,actions:p}=n,{showSettings:B}=s,{setShowSettings:Q,setShowVolumeSlider:Y}=p,G=Dt.useRef(null),Ee=Dt.useRef(null);x(()=>{const h=_=>{G.current&&!G.current.contains(_.target)&&Ee.current&&!Ee.current.contains(_.target)&&B&&Q(!1)};return B&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[B,Q]);const we=Dt.useRef(null),Ge=h=>{d.videoRef.current&&(d.videoRef.current.volume=h,d.videoRef.current.muted=h===0,localStorage.setItem("playerVolume",h.toString()))},He=h=>{!d.videoRef.current||isNaN(s.duration)||s.duration===0||(d.videoRef.current.currentTime=h*s.duration,p.sendProgressUpdate(!1,!0))},tt=()=>{d.videoRef.current&&(p.setIsScrubbing(!0),p.wasPlayingBeforeScrub.current=!d.videoRef.current.paused,d.videoRef.current.pause())},H=h=>{!d.videoRef.current||!s.duration||(d.videoRef.current.currentTime=h*s.duration)},Ke=()=>{p.setIsScrubbing(!1),p.wasPlayingBeforeScrub.current&&d.videoRef.current?.play()},ut=h=>{if(!d.videoRef.current)return;p.setActiveSubtitleTrack(h);try{if(h===null||h==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const I=s.availableSubtitles.find(J=>J.label===h||J.lang===h);I?localStorage.setItem("playerLastSubtitle",en(I)):localStorage.setItem("playerLastSubtitle",h)}}catch{}let _=!1;Array.from(d.videoRef.current.textTracks).forEach(I=>{const nt=h!==null&&h!=="off"&&(I.language===h||I.label===h)&&!_;I.mode=nt?"showing":"hidden",nt&&(_=!0)})},re=s.activeSubtitleTrack!==null&&s.activeSubtitleTrack!=="off",pe=()=>{if(!d.videoRef.current)return;if(re){ut("off");return}if(s.availableSubtitles.length===0)return;let h=null;try{h=localStorage.getItem("playerLastSubtitle")}catch{}const _=Ht(s.availableSubtitles,{lastKey:h,enabled:!0});if(_<0)return;const I=s.availableSubtitles[_];ut(I.label||I.lang)},je=()=>s.isMuted||s.volume===0?r(W,{name:"volume-mute"}):s.volume<.5?r(W,{name:"volume-down"}):r(W,{name:"volume-up"}),rt=r("div",{className:`${E.controlsOverlay} ${!s.showControls&&!B&&!s.isScrubbing?E.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none"},children:r("div",{className:E.topControls,onClick:h=>h.stopPropagation(),children:[r("button",{className:E.backBtn,onClick:h=>{h.stopPropagation(),window.history.back()},title:"Back","aria-label":"Back",children:r(W,{name:"chevron-left"})}),r("div",{className:E.videoTitleInfo,children:[r("span",{className:E.animeTitle,children:ye}),e&&r("span",{className:E.episodeNumber,children:["Episode ",e]})]})]})}),ft=r(Yr,{isPlaying:s.isPlaying,onTogglePlay:p.togglePlay,onSkipBack:()=>p.seek(-10),onSkipForward:()=>p.seek(10)}),ne=r("div",{className:`${E.controlsOverlay} ${!s.showControls&&!B&&!s.isScrubbing?E.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:E.bottomControls,"data-speed-boost-ignore":"true",onClick:h=>h.stopPropagation(),children:[r(Jr,{classes:{container:E.progressBarContainer,scrubbing:E.scrubbing,timeBubble:E.timeBubble,bar:E.progressBar,buffered:E.bufferedBar,watched:E.watchedBar,thumb:E.thumb},videoRef:d.videoRef,duration:s.duration,formatTime:p.formatTime,isScrubbing:s.isScrubbing,onSeek:He,onScrubStart:tt,onScrubMove:H,onScrubEnd:Ke,timeLabelRef:we,children:[s.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${E.skipSegment} ${E[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/s.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/s.duration*100}% `}}),ie.map(h=>{const _=h.start_time/s.duration*100,I=(h.end_time-h.start_time)/s.duration*100;return r("div",{className:`${E.skipSegment} ${E[h.skip_type]} `,style:{left:`${_}% `,width:`${I}% `},title:h.skip_type.toUpperCase()},h.skip_id)})]}),r("div",{className:E.bottomControlsRow,children:[r("div",{className:E.leftControls,children:[r("button",{className:E.controlBtn,onClick:p.togglePlay,"aria-label":s.isPlaying?"Pause":"Play",children:s.isPlaying?r(W,{name:"pause"}):r(W,{name:"play"})}),r(Xr,{muted:s.isMuted,volume:s.volume,volumeIcon:je(),buttonClassName:E.controlBtn,onToggleMute:p.toggleMute,onVolumeChange:Ge,onExpandedChange:h=>Y(h)}),r("span",{className:E.timeDisplay,ref:we,children:[p.formatTime(0)," / ",p.formatTime(s.duration)]}),s.currentSkipInterval&&!s.isAutoSkipEnabled&&r("button",{className:E.controlBtn,onClick:()=>{d.videoRef.current&&s.currentSkipInterval&&(d.videoRef.current.currentTime=s.currentSkipInterval.end_time,p.setCurrentSkipInterval(null))},children:["Skip ",s.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:E.rightControls,children:[r("div",{className:E.skipControls,children:j&&r("button",{className:E.nextEpisodeBtn,onClick:b,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${E.controlBtn} ${re?E.active:""}`,onClick:pe,title:re?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(W,{name:"closed-captioning",size:22})}),r("button",{ref:Ee,className:`${E.controlBtn} ${B?E.active:""} `,onClick:()=>Q(!B),"aria-label":"Settings",children:r(W,{name:"cog"})}),r("button",{className:`${E.controlBtn} ${E.theaterBtn} ${g?E.active:""} `,onClick:h=>{h.stopPropagation(),V()},title:g?"Exit Theater Mode":"Theater Mode","aria-label":g?"Exit Theater Mode":"Theater Mode",children:r(W,{name:"tv"})}),r("button",{className:E.controlBtn,onClick:p.toggleFullscreen,"aria-label":s.isFullscreen?"Exit Fullscreen":"Fullscreen",children:s.isFullscreen?r(W,{name:"compress"}):r(W,{name:"expand"})})]})]})]})}),Ye=r(Ir,{fallback:null,children:r(po,{ref:G,isOpen:B,onClose:()=>Q(!1),videoSources:C,currentSource:S,currentLink:P,onSourceChange:R,subtitles:s.availableSubtitles,activeSubtitleTrack:s.activeSubtitleTrack,onSubtitleChange:ut,subtitleSettings:{fontSize:s.subtitleFontSize,position:s.subtitlePosition,bgOpacity:s.subtitleBgOpacity,bgColor:s.subtitleBgColor,textColor:s.subtitleTextColor,edge:s.subtitleEdge,bold:s.subtitleBold},onSubtitleSettingsChange:(h,_)=>{const I=(J,nt)=>{try{localStorage.setItem(J,String(nt))}catch{}};switch(h){case"fontSize":p.setSubtitleFontSize(_),I("subtitleFontSize",_);break;case"position":p.setSubtitlePosition(_),I("subtitlePosition",_);break;case"bgOpacity":p.setSubtitleBgOpacity(_),I("subtitleBgOpacity",_);break;case"bgColor":p.setSubtitleBgColor(_),I("subtitleBgColor",_);break;case"textColor":p.setSubtitleTextColor(_),I("subtitleTextColor",_);break;case"edge":p.setSubtitleEdge(_),I("subtitleEdge",_);break;case"bold":p.setSubtitleBold(_),I("subtitleBold",_);break}},useNativeControls:s.useNativeControls,onNativeControlsToggle:p.setUseNativeControls,anime4kEnabled:U,onAnime4kToggle:le,anime4kSupported:z,anime4kProfile:ve,onAnime4kProfileChange:A,anime4kInitializing:$,anime4kError:De,videoDelayEnabled:qe,onVideoDelayToggle:a,videoDelayMs:m,onVideoDelayChange:k,onCalibrateAvSync:Se,isAutoSkipEnabled:s.isAutoSkipEnabled,onAutoSkipChange:h=>{p.setIsAutoSkipEnabled(h);try{localStorage.setItem("autoSkipEnabled",h.toString())}catch{}},isAutoplayEnabled:v,onAutoplayChange:w,fallbackChoice:Fe,onFallbackChoiceChange:Be})});return r(Zr,{player:n,topBar:rt,centerControls:ft,bottomBar:ne,settingsPanel:Ye,overlays:ze,isInteracting:te,className:Re,chromeDisabled:l,children:Ie})},ho=({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(Nt,{width:"60px",height:"1.2rem",variant:"text"})}),r(W,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:et.list,children:Array.from({length:n}).map((v,w)=>r("div",{className:et.item,style:{pointerEvents:"none"},children:[r("div",{className:et.dragHandle,style:{opacity:.2},children:r(Nt,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:et.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(Nt,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:et.meta,children:[r(Nt,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(Nt,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},w))})]}),fo="_sourceSelectionContainer_c5tub_76",vo="_providerSelectContainer_c5tub_89",go="_providerSelect_c5tub_89",bo="_sourceSelect_c5tub_76",yo="_sourceButtons_c5tub_145",So="_sourceButton_c5tub_145",Eo="_active_c5tub_170",ht={sourceSelectionContainer:fo,providerSelectContainer:vo,providerSelect:go,sourceSelect:bo,sourceButtons:yo,sourceButton:So,active:Eo},wo=({selectedProvider:n,onProviderChange:v,isAdult:w,options:j})=>{const b=j&&j.length>0?j:[],C=w===void 0?b:b.filter(S=>S.mature===w);return r("div",{className:ht.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:ht.providerSelect,value:n,onChange:S=>v(S.target.value),children:_n.map(S=>{const P=C.filter(R=>(R.tier??"direct")===S);return P.length===0?null:r("optgroup",{label:Rn[S],children:P.map(R=>r("option",{value:R.value,children:R.sub?`${R.label} (${Mn[R.sub]})`:R.label},R.value))},S)})})]})},ko=({videoSources:n,selectedSource:v,selectedLink:w,onSourceChange:j,onLinkChange:b})=>{const C=Array.isArray(n)?n:[];if(C.length===0)return null;const S=v?.type==="iframe"&&(v.links?.length??0)>1;return r("div",{className:ht.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:ht.sourceButtons,children:C.map((P,R)=>r("button",{className:`${ht.sourceButton} ${v?.sourceName===P.sourceName?ht.active:""} `,onClick:()=>j(P),children:P.sourceName},`${P.sourceName}-${R}`))}),S&&r("select",{className:ht.sourceSelect,"aria-label":"Fallback embed quality",value:w?.link??v.links[0]?.link??"",onChange:P=>{const R=v.links.find(ie=>ie.link===P.target.value);R&&b(R)},children:v.links.map(P=>r("option",{value:P.link,children:P.resolutionStr},P.link))})]})},To=Dt.memo(ko,(n,v)=>n.selectedSource?.sourceName===v.selectedSource?.sourceName&&n.selectedLink?.link===v.selectedLink?.link&&n.videoSources===v.videoSources),Co={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}},Mo={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Ro=5,_o=15e3,No=`
|
|
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 xo({videoRef:n,canvasRef:v,profile:w="balanced",delayMs:j=0}){const[b,C]=q(!1),[S,P]=q(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[R,ie]=q(!1),[ye,e]=q(null),[g,V]=q(0),U=f(0),le=f(null),z=f(null),ve=f(null),A=f(null),$=f(null),De=f(null),qe=f(null),a=f(null),m=f(null),k=f(!1),Se=f(-1),Fe=f(0),Be=f(j);Be.current=j;const Ie=f([]),ze=f(!1),te=f(!1),Re=f(!1),l=f(null),s=f(-1),d=f(-1),p=f(!1),B=f(0);x(()=>{async function Y(){if(typeof navigator>"u"||!navigator.gpu){C(!1);return}try{const G=await navigator.gpu.requestAdapter();C(!!G)}catch{C(!1)}}Y()},[]),x(()=>{if(!S||!b)return;let Y=!1;const G=++U.current,Ee=H=>{if(H)try{H.close()}catch{}},we=()=>{for(const H of Ie.current)Ee(H.bitmap);Ie.current=[]},Ge=H=>Math.max(8,Math.min(40,Math.ceil(H/16.7)+4));function He(){m.current!==null&&(cancelAnimationFrame(m.current),m.current=null)}async function tt(){let H=n.current;const Ke=v.current;if(!H||!Ke||U.current!==G)return;const ut=performance.now()+_o;for(;(!H||H.videoWidth===0)&&performance.now()<ut;){if(await new Promise(J=>requestAnimationFrame(J)),Y||U.current!==G)return;H=n.current}if(!H||H.videoWidth===0){!Y&&U.current===G&&(e("Timed out waiting for video metadata"),ie(!1),P(!1));return}const re=H.videoWidth,pe=H.videoHeight,je=Math.max(re,pe),rt=window.innerWidth,ft=window.innerHeight,ne=Math.max(rt,ft),Ye=je<ne?ne/je:1,h=Co[w],_=je<=480?h.sd:je<=720?h.hd:je<=1080?h.fhd:1,I=Math.min(_,Ye);Ke.width=Math.round(re*I),Ke.height=Math.round(pe*I),ie(!0),e(null),Fe.current=0,Se.current=-1,k.current=!1;try{let J=function(){Y||U.current!==G||(He(),m.current=requestAnimationFrame(()=>{dt()}))};const{ModeA:nt,ModeB:wt,ModeC:ot,ModeAA:st}=await ur(async()=>{const{ModeA:L,ModeB:ce,ModeC:Ne,ModeAA:D}=await import("./index-BOKlZEHq.js").then(ue=>ue.i);return{ModeA:L,ModeB:ce,ModeC:Ne,ModeAA:D}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const kt=await navigator.gpu.requestAdapter();if(!kt)throw new Error("No GPU adapter found");const M=await kt.requestDevice();if(!M)throw new Error("Failed to get GPU device");const Oe=Ke.getContext("webgpu");if(!Oe)throw new Error("Failed to get WebGPU context");const at=navigator.gpu.getPreferredCanvasFormat();Oe.configure({device:M,format:at,alphaMode:"premultiplied"});const me=M.createTexture({size:[re,pe],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),Je=Mo[w],ke=Math.round(re*I),Le=Math.round(pe*I),vt=(()=>{switch(Je){case"ModeB":return new wt({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}});case"ModeC":return new ot({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}});case"ModeAA":return new st({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}});default:return new nt({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}})}})(),_e=vt.getOutputTexture(),gt=M.createSampler({magFilter:"linear",minFilter:"linear"}),bt=M.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
|
+
`}),Xe=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Tt=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[Xe]}),vertex:{module:bt,entryPoint:"vs"},fragment:{module:bt,entryPoint:"fs",targets:[{format:at}]},primitive:{topology:"triangle-list"}}),Ct=M.createBindGroup({layout:Xe,entries:[{binding:0,resource:_e.createView()},{binding:1,resource:gt}]});try{const L=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),ce=M.createShaderModule({code:No}),Ne=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[L]}),vertex:{module:ce,entryPoint:"vs"},fragment:{module:ce,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});l.current={pipeline:Ne,layout:L,inputView:me.createView()}}catch{l.current=null}if(U.current!==G){me.destroy(),M.destroy();return}le.current=M,z.current=Oe,ve.current=vt,A.current=me,$.current=_e,De.current=Tt,qe.current=gt,a.current=Xe,te.current=!1,Re.current=!1;async function Ft(){const L=l.current;if(!L||te.current)return!1;const ce=n.current;if(!ce)return!1;const Ne=!Re.current;Ne&&M.pushErrorScope("validation");try{const D=M.importExternalTexture({source:ce}),ue=M.createBindGroup({layout:L.layout,entries:[{binding:0,resource:D},{binding:1,resource:gt}]}),Te=M.createCommandEncoder(),T=Te.beginRenderPass({colorAttachments:[{view:L.inputView,loadOp:"load",storeOp:"store"}]});T.setPipeline(L.pipeline),T.setBindGroup(0,ue),T.draw(6),T.end(),M.queue.submit([Te.finish()])}catch{return te.current=!0,l.current=null,!1}if(Ne){const D=await M.popErrorScope().catch(()=>null);if(D)return console.warn("[anime4k] blit probe failed:",D.message),te.current=!0,l.current=null,!1;Re.current=!0}return!0}ie(!1);async function dt(){if(Y||U.current!==G)return;const L=n.current;if(!L||L.videoWidth===0){J();return}if(L!==H||L.videoWidth!==re||L.videoHeight!==pe){V(ue=>ue+1);return}if(L.paused||L.ended||document.hidden||L.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){J();return}const ce=L.getVideoPlaybackQuality().totalVideoFrames;if(ce===d.current){J();return}if(k.current){J();return}const Ne=L.currentTime;(L.seeking||s.current>=0&&Math.abs(Ne-s.current)>.5)&&(we(),p.current=!1,B.current=0,d.current=-1),s.current=Ne;const D=Math.max(0,Be.current||0);D>B.current&&(p.current=!1),k.current=!0;try{const ue=performance.now();let Te=null,T=!1;if(D<=0){Ie.current.length>0&&we(),p.current=!1,B.current=0;let Ce=!1;if(!ze.current)try{M.queue.copyExternalImageToTexture({source:L},{texture:me},[re,pe]),d.current=ce,Ce=!0}catch(he){if(he instanceof TypeError)ze.current=!0;else throw he}if(!Ce&&!te.current&&l.current&&await Ft()&&(d.current=ce,Ce=!0),!Ce){const he=await createImageBitmap(L);d.current=ce,M.queue.copyExternalImageToTexture({source:he},{texture:me},[re,pe]),Ee(he)}}else{const Ce=await createImageBitmap(L);d.current=ce;const he=Ie.current;he.push({bitmap:Ce,capture:ue});const Ot=Ge(D);for(;he.length>Ot;)Ee(he.shift()?.bitmap);let oe=-1;for(let ge=he.length-1;ge>=0;ge--)if(ue-he[ge].capture>=D){oe=ge;break}if(oe!==-1){for(let Ve=0;Ve<oe;Ve++)Ee(he.shift()?.bitmap);const ge=he.shift();ge?(Te=ge.bitmap,p.current=!0,B.current=D):(Te=Ce,T=!0)}else if(!p.current)Te=Ce,T=!0;else{const ge=he.shift();Te=ge?ge.bitmap:Ce,ge||(T=!0)}if(!Te){k.current=!1,J();return}M.queue.copyExternalImageToTexture({source:Te},{texture:me},[re,pe]),T||Ee(Te)}const Mt=M.createCommandEncoder();await vt.pass(Mt);const We=Mt.beginRenderPass({colorAttachments:[{view:Oe.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});We.setPipeline(Tt),We.setBindGroup(0,Ct),We.draw(6),We.end(),M.queue.submit([Mt.finish()]),Se.current=ce,Fe.current=0,M.queue.onSubmittedWorkDone().then(()=>{U.current===G&&(k.current=!1)})}catch(ue){if(k.current=!1,Fe.current+=1,Fe.current>=Ro&&!Y&&U.current===G){console.error(ue),e(ue instanceof Error?ue.message:"Render error"),P(!1);return}}J()}J()}catch(J){!Y&&U.current===G&&(e(J instanceof Error?J.message:"Failed to initialize upscaler"),ie(!1),P(!1))}}return tt(),()=>{Y=!0,U.current+=1,He(),we(),A.current&&(A.current.destroy(),A.current=null),$.current&&($.current.destroy(),$.current=null),le.current&&(le.current.destroy(),le.current=null),ve.current=null,De.current=null,qe.current=null,a.current=null,l.current=null,z.current=null,k.current=!1}},[S,b,n,v,w,g]);const Q=O(()=>{P(Y=>{const G=!Y;try{localStorage.setItem("anime4kEnabled",String(G))}catch{}return G})},[]);return{isWebGPUSupported:b,isEnabled:S,isInitializing:R,error:ye,toggle:Q}}const Po=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Ao=()=>{const n=localStorage.getItem("preferredProvider");return n&&/^[a-z0-9-]+$/i.test(n)?n:"megaplay"},mr=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:Po(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,forceNativePlayer:localStorage.getItem("forceNativePlayer")==="true",isAutoplayEnabled:tn(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Ao(),loadingShowData:!0,loadingVideo:!1,loadingDetails:!1,error:null,detailsError:null,showCookieModal:!1,cookieProvider:null});mr();function Bo(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};case"SET_OVERRIDE_SOURCE":return{...n,selectedSource:v.payload?.source??null,selectedLink:v.payload?.link??null};default:return n}}async function cr(n,v,w,j,b=!1){if(!n||!v)throw new Error("Missing params");try{const[C,S,P,R]=await Promise.all([$e(`/api/video?showId=${n}&episodeNumber=${v}&mode=${w.currentMode}&provider=${w.selectedProvider}`).catch(()=>null),$e(`/api/episode-progress/${n}/${v}`).catch(()=>null),$e("/api/settings?key=preferredSource").catch(()=>null),$e(`/api/skip-times/${n}/${v}`).catch(()=>[])]),ie=P?.value,ye=C?.filter(A=>{const $=A.sourceName.toLowerCase();return w.currentMode==="dub"?$.includes("eng")||$.includes("dub"):$.includes("jpn")||$.includes("sub")||!$.includes("eng")&&!$.includes("dub")})??[],e=ye.length>0?ye:C??[];let g=e.length>0?e[0]:null;if(ie){const A=e.find($=>$.sourceName===ie);A&&(g=A)}const V=g&&g.links.length>0?g.links.sort((A,$)=>(parseInt($.resolutionStr)||0)-(parseInt(A.resolutionStr)||0))[0]:null,U=S?.currentTime||0,le=S?.duration||0,ve=(Array.isArray(R)?R:R?.results||[]).map(A=>({skip_id:A.skip_id||"",skip_type:A.skip_type||"",start_time:A.interval?.start_time??A.start_time??0,end_time:A.interval?.end_time??A.end_time??0})).filter(A=>A.end_time>0);return(!C||C.length===0)&&(b||Qe.error(`No video sources found for ${w.selectedProvider}`)),{videoSources:C,selectedSource:g,selectedLink:V,resumeTime:U,resumeDuration:le,showResumeModal:U>5&&g?.type!=="iframe",skipIntervals:ve,fetchedEpisodeNumber:v}}catch(C){const S=C;if(S.message==="AUTH_REQUIRED")return j({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:S.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:v};throw C}}const Io=(n,v,w,j)=>{const[b,C]=$r(Bo,w,l=>({...mr(),showMeta:l?.name?{name:l.name,thumbnail:l.thumbnail,nativeName:l.nativeName,englishName:l.englishName,names:{romaji:l.name||l.englishName,english:l.englishName||l.name,native:l.nativeName}}:{}})),S=dr(),P=f(null),R=f(null),{options:ie}=pr(),ye=ct(()=>ie.filter(l=>(l.kind??"anime")==="anime"),[ie]),e=v||b.initialEpisode,g=f(e);x(()=>{g.current!==e&&(g.current=e,C({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[e,C]),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)&&b.selectedProvider!=="animepahe"&&P.current!==n&&(P.current=n,C({type:"SET_PROVIDER",payload:"animepahe"}))},[n,b.selectedProvider]);const{data:V,isLoading:U,error:le}=wn(n),{data:z}=ar({queryKey:["player-data",n,b.currentMode,b.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const l=async()=>{try{const Q=await $e(`/api/episodes?showId=${n}&mode=${b.currentMode}&provider=${b.selectedProvider}`);if(Q?.episodes?.length)return Q}catch{}return null},[s,d,p]=await Promise.all([l(),$e(`/api/watchlist/check/${n}`).catch(()=>({inWatchlist:!1})),$e(`/api/watched-episodes/${n}`).catch(()=>[])]),B=s?.episodes?s.episodes.sort((Q,Y)=>parseFloat(Q)-parseFloat(Y)):[];return{description:s?.description||"",episodes:B,inWatchlist:d.inWatchlist,watchlistStatus:d.status??null,watchedEpisodes:p}},enabled:!!n});x(()=>{!v&&z?.episodes&&z.episodes.length>0&&!v&&C({type:"SET_STATE",payload:{initialEpisode:z.episodes[0]}})},[z,v]),x(()=>{if(V?.isAdult===void 0)return;const s=new Set(ye.filter(d=>d.mature).map(d=>d.value)).has(b.selectedProvider);if(R.current!==n){if(V.isAdult&&!s){R.current=n;const d=ye.find(p=>p.mature);if(!d)return;C({type:"SET_PROVIDER",payload:d.value}),localStorage.setItem("preferredProvider",d.value)}if(!V.isAdult&&s){R.current=n;const d=ye.find(p=>!p.mature);if(!d)return;C({type:"SET_PROVIDER",payload:d.value}),localStorage.setItem("preferredProvider",d.value)}}},[V?.isAdult,b.selectedProvider,n,ye]),x(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||R.current===`temp:${n}`)return;const l=V?.provider;l&&(R.current=`temp:${n}`,l!==b.selectedProvider&&C({type:"SET_PROVIDER",payload:l}))},[n,V,b.selectedProvider]);const{data:ve,isLoading:A,error:$}=ar({queryKey:["video-sources",n,e,b.selectedProvider,b.currentMode],queryFn:()=>cr(n,e,b,C),enabled:!!n&&!!e&&!(b.showMeta?.isAdult===!0&&!j?.hasMatureConsent)}),De=!1,{mutateAsync:qe}=Gt({mutationFn:async({wasIn:l,showMeta:s})=>{const d=l?"/api/watchlist/remove":"/api/watchlist/add",p={id:n,name:s.name||s.names?.romaji,thumbnail:s.thumbnail,nativeName:s.names?.native,englishName:s.names?.english,type:s.type,isAdult:s.isAdult},B=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!B.ok){const Q=await B.json().catch(()=>null);throw new Error(Q?.error||"Failed to update watchlist")}return!l},onSuccess:l=>{Qe.success(l?"Added to watchlist":"Removed from watchlist"),S.invalidateQueries({queryKey:["player-data",n]}),S.invalidateQueries({queryKey:["show-data",n]}),S.invalidateQueries({queryKey:["watchlist"]})},onError:l=>Qe.error(l instanceof Error?l.message:"Failed to update watchlist")}),a=O(async()=>{!n||!V||await qe({wasIn:!!z?.inWatchlist,showMeta:V})},[n,V,z?.inWatchlist,qe]),m=O(async l=>{try{await $e("/api/settings",{method:"POST",body:JSON.stringify({key:"preferredSource",value:l})})}catch(s){console.error(s)}},[]),{mutateAsync:k,isPending:Se}=Gt({mutationFn:async({status:l})=>{if(!n)throw new Error("Missing showId");return await $e("/api/watchlist/status",{method:"POST",body:JSON.stringify({id:n,status:l})}),l},onSuccess:l=>{C({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:l}}),Qe.success(`Moved to ${l}`),S.invalidateQueries({queryKey:["show-data",n]}),S.invalidateQueries({queryKey:["watchlist"]}),S.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>Qe.error("Failed to update watchlist status")}),Fe=O(async()=>{await k({status:"Completed"})},[k]),{mutateAsync:Be}=Gt({mutationFn:async({episodeNumber:l,duration:s,showMeta:d,episodes:p})=>{await $e("/api/update-progress",{method:"POST",body:JSON.stringify({showId:n,episodeNumber:l,currentTime:s,duration:s,showName:d.name,showThumbnail:d.thumbnail,nativeName:d.names?.native,englishName:d.names?.english,genres:d.genres?.map(B=>B.name),popularityScore:Vr(d.score??d.stats?.averageScore),type:d.type,status:d.status,episodeCount:p.length,isAdult:d.isAdult}),keepalive:!0})},onSuccess:(l,s)=>{Qe.success(`Episode ${s.episodeNumber} marked as watched`),S.invalidateQueries({queryKey:["player-data",n]}),S.invalidateQueries({queryKey:["show-meta",n]}),S.invalidateQueries({queryKey:["video-sources",n,s.episodeNumber]}),S.invalidateQueries({queryKey:["allContinueWatching"]}),S.invalidateQueries({queryKey:["thisWeekSchedule"]})},onError:()=>Qe.error("Failed to mark episode as watched")}),Ie=O(async(l,s)=>{!n||!V||await Be({episodeNumber:l,duration:s,showMeta:V,episodes:z?.episodes||[]})},[n,V,z?.episodes,Be]),ze=O(async()=>{C({type:"SET_STATE",payload:{showCombinedDetails:!b.showCombinedDetails}})},[b.showCombinedDetails]),te=ct(()=>{const l=le||$,s=l?l.message:null,d=s==="AUTH_REQUIRED"?null:s,p=ve&&ve.fetchedEpisodeNumber===e?ve:null,B=!!ve&&!p;return{...b,currentEpisode:e,showMeta:{...b.showMeta||{},...V||{}},episodes:z?.episodes||[],watchedEpisodes:z?.watchedEpisodes||[],inWatchlist:!!z?.inWatchlist,watchlistStatus:z?.watchlistStatus??b.watchlistStatus??null,videoSources:p?.videoSources||[],selectedSource:b.selectedSource||p?.selectedSource||null,selectedLink:b.selectedLink||p?.selectedLink||null,resumeTime:p?.resumeTime||0,resumeDuration:p?.resumeDuration||0,showResumeModal:b.showResumeModal&&(p?.showResumeModal??!1),skipIntervals:p?.skipIntervals||[],loadingShowData:U,loadingVideo:A||B,loadingDetails:De,error:d,fetchedEpisodeNumber:p?.fetchedEpisodeNumber}},[b,V,z,ve,U,A,De,le,$,e]),Re=O((l,s)=>{const d=s||n;if(!d||!l||d===n&&l===e)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(d)&&b.selectedProvider!=="animepahe"?"animepahe":b.selectedProvider,Q=["video-sources",d,l,B,b.currentMode];S.getQueryState(Q)?.status!=="success"&&S.prefetchQuery({queryKey:Q,queryFn:()=>cr(d,l,{selectedProvider:B,currentMode:b.currentMode},C,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,e,S,b,C]);return{state:te,dispatch:C,toggleWatchlist:a,moveToCompleted:Fe,setPreferredSource:m,handleToggleDetails:ze,markEpisodeWatched:Ie,prefetchEpisodeSources:Re,isMarkingWatched:Be.isPending,isUpdatingWatchlistStatus:Se}},Kt="fallbackChoice";function Lo(){try{const n=localStorage.getItem(Kt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function $o(n){try{n===null?localStorage.removeItem(Kt):localStorage.setItem(Kt,n)}catch{}}const ts=()=>{const{id:n,episodeNumber:v}=Dr(),w=Fr(),j=dr(),b=Or(),{hasConsent:C,grant:S}=yn(),{options:P}=pr(),R=ct(()=>P.filter(t=>(t.kind??"anime")==="anime"),[P]),ie=ct(()=>R.map(t=>t.value),[R]),ye=ct(()=>new Set(R.filter(t=>t.mature).map(t=>t.value)),[R]),{state:e,dispatch:g,toggleWatchlist:V,moveToCompleted:U,setPreferredSource:le,handleToggleDetails:z,markEpisodeWatched:ve,prefetchEpisodeSources:A,isMarkingWatched:$,isUpdatingWatchlistStatus:De}=Io(n,v,b.state||null,{hasMatureConsent:C});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}`;w(t,{replace:!0})}},[n,e.showMeta?.id,v,w]);const qe=ct(()=>{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=rn({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:qe}),{refs:m,actions:k}=a,Se=f(null),Fe=Sn(),Be=f(null),Ie=f(null),ze=f(null),te=f(0),Re=f(e.resumeTime),l=f(e.showResumeModal),[s,d]=q(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),[p,B]=q(()=>{try{const t=Number(localStorage.getItem("playerVideoDelayMs"));if(Number.isFinite(t)&&t>=0&&t<=500)return Math.round(t)}catch{}return 180}),[Q,Y]=q(()=>{try{return localStorage.getItem("playerVideoDelayEnabled")==="true"}catch{return!1}}),[G,Ee]=q(!1),[we,Ge]=q(!1),He=f(null),tt=f(null),H=(t,o)=>{try{localStorage.setItem("playerVideoDelayMs",String(t)),localStorage.setItem("playerVideoDelayEnabled",String(o))}catch{}},Ke=t=>{const o=Math.max(0,Math.min(500,Math.round(t)));B(o);try{localStorage.setItem("playerVideoDelayMs",String(o))}catch{}},ut=()=>{He.current={enabled:Q,ms:p},Y(!0);try{localStorage.setItem("playerVideoDelayEnabled","true")}catch{}k.setShowSettings(!1),Ee(!0)},re=()=>{const t=He.current;He.current=null,t&&(B(t.ms),Y(t.enabled),H(t.ms,t.enabled)),Ge(!1),Ee(!1)},pe=()=>{He.current=null,Y(!0),H(p,!0),Ge(!1),Ee(!1)},je=()=>{if(we){Ge(!1);return}const t=m.videoRef.current;t&&!isNaN(t.currentTime)&&(tt.current=t.currentTime),Ge(!0)},rt=Q?p:0,ft=f(null),ne=xo({videoRef:m.videoRef,canvasRef:Ie,profile:s,delayMs:rt}),Ye=ne.isEnabled&&ne.isWebGPUSupported;nn({videoRef:m.videoRef,canvasRef:ft,delayMs:rt,enabled:Q&&!Ye});const h=Q&&!Ye,_=Ye||h;x(()=>{Re.current=e.resumeTime,l.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[I,J]=q(null),[nt,wt]=q(!1),[ot,st]=q(!1),[kt,M]=q(!1),Oe=f(!1),[at,me]=q(null),Je=f(!1),ke=f([]),Le=f(!1),[vt,_e]=q(null),[gt,bt]=q(!1),[Xe,Tt]=q(!1),[Ct,Ft]=q(()=>Lo()??"ask"),dt=O(t=>{Ft(t),$o(t==="ask"?null:t)},[]),L=f(Ct);L.current=Ct;const ce=f(e.videoSources);ce.current=e.videoSources;const Ne=f(()=>{}),[D,ue]=q(null),Te=f(v);x(()=>{Te.current!==v&&(Te.current=v,ue(null),me(null),Oe.current=!1,Ge(!1),Ee(!1))},[v]),x(()=>{Je.current=!1,ke.current=[],Le.current=!1,_e(null),bt(!1)},[n,e.currentEpisode]),x(()=>{ot||(Oe.current=!1)},[ot]);const{data:T=[],isLoading:Mt}=Ur(),We=Qr(),Ce=f(We);Ce.current=We;const he=qr(),Ot=zr(),[oe,ge]=q(()=>{try{return localStorage.getItem("playerTheaterMode")==="true"}catch{return!1}});x(()=>{try{oe?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)}}},[oe]),Wr(()=>{if(a.state.isFullscreen||oe)return;const t=m.playerContainerRef.current,o=Be.current;if(!t||!o)return;const i=()=>{const N=t.getBoundingClientRect().height;o.style.height=`${N}px`};i();const c=new ResizeObserver(i);return c.observe(t),()=>c.disconnect()},[a.state.isFullscreen,oe,m.playerContainerRef]);const Ve=ct(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),Wt=Ve>0?e.episodes[Ve-1]:null,xe=Ve>=0&&Ve<e.episodes.length-1?e.episodes[Ve+1]:null,Vt=Ve>-1&&Ve<e.episodes.length-1,hr=e.episodes.length>0&&!!e.currentEpisode&&e.episodes[e.episodes.length-1]===e.currentEpisode,fr=String(e.showMeta.status||"").trim().toLowerCase(),vr=["finished","completed","complete","ended"].some(t=>fr.includes(t)),Ut=on(e.resumeTime,e.resumeDuration)||ot,it=hr&&vr&&Ut,jt=e.showResumeModal&&(it||!Ut),xt=Ut&&!it&&T.length===0&&!D&&(e.showResumeModal||ot),pt=jt||xt;sn(a,!!e.selectedLink&&!oe&&!pt),x(()=>{const t=m.videoRef.current;if(!t)return;let o=!1;for(Se.current&&(Se.current.destroy(),Se.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(we)return t.src="/av-sync-test.mp4",t.play().catch(()=>{k.setShowControls(!0)}),()=>{o=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){te.current=0;return}tt.current!=null?(te.current=tt.current,tt.current=null):Re.current>5&&!l.current?te.current=Re.current:l.current&&(te.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 fe=localStorage.getItem("playerSubtitlesEnabled")!=="false";let Me=null;try{Me=localStorage.getItem("playerLastSubtitle")}catch{}const X=Ht(e.selectedSource.subtitles,{lastKey:Me,enabled:fe}),Pe=X>=0?e.selectedSource.subtitles[X]:null;e.selectedSource.subtitles.forEach(be=>{const Z=document.createElement("track");Z.kind="subtitles",Z.label=be.label,Z.srclang=be.lang;const y=be.src??be.url;if(y){let ee=`/api/subtitle-proxy?url=${encodeURIComponent(y)}`;const ae=e.selectedLink?.headers?.Referer,yt=y.includes("anilight.live")?"https://anilight.live/":"",$t=ae||yt;$t&&(ee+=`&referer=${encodeURIComponent($t)}`),Z.src=ee}Pe&&be.label===Pe.label&&be.lang===Pe.lang&&(Z.default=!0),t.appendChild(Z)}),fe||k.setActiveSubtitleTrack("off"),k.setAvailableSubtitles(e.selectedSource.subtitles)}const c=te.current;te.current=0;const N=()=>{c>0&&(t.currentTime=c)};t.addEventListener("loadedmetadata",N,{once:!0});const de=!(l.current&&Re.current>5),K=()=>{de&&t.play().catch(()=>{k.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const fe=await bn();if(o)return;if(!fe||!fe.isSupported()){t.src=i,K();return}const Me=document.body.classList.contains("low-end"),X=new fe({maxBufferLength:Me?15:30,maxMaxBufferLength:Me?30:60,maxBufferSize:Me?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});Se.current=X,X.on(fe.Events.ERROR,(Z,y)=>{y.fatal&&!Je.current&&Ne.current()});const Pe=(e.selectedSource?.subtitles?.length??0)>0,be=()=>{try{Pe&&typeof X.subtitleTrack=="number"&&X.subtitleTrack!==-1&&(X.subtitleTrack=-1)}catch{}};X.on(fe.Events.SUBTITLE_TRACK_SWITCH,(Z,y)=>{y?.id!==-1&&be()}),be(),X.loadSource(i),X.attachMedia(t),X.once(fe.Events.MANIFEST_PARSED,()=>{o||K()})})():(t.src=i,K());const F=localStorage.getItem("playerVolume"),se=localStorage.getItem("playerMuted");return F!==null&&(t.volume=parseFloat(F)),se!==null&&(t.muted=se==="true"),()=>{o=!0,t.removeEventListener("loadedmetadata",N),Se.current&&(Se.current.destroy(),Se.current=null)}},[e.selectedSource,e.selectedLink,m.videoRef,k,e.loadingVideo,we]);const Pt=O(t=>{if(Je.current)return;Je.current=!0;const o=t.links[0];le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:o}}),_e(null)},[g,le]),At=O(()=>{const o=ce.current.find(i=>i.type==="iframe");return o?.links?.length?o:null},[]),Bt=O(async()=>{const t=e.showMeta?.isAdult,o=ie.filter(i=>{if(ke.current.includes(i))return!1;const c=ye.has(i);return t===void 0?!0:c===t});bt(!0);try{for(const i of o){ke.current.push(i);let c=null;try{c=await $e(`/api/video?showId=${n}&episodeNumber=${e.currentEpisode}&mode=${e.currentMode}&provider=${i}`)}catch{continue}const N=(c??[]).filter(F=>{const se=F.sourceName.toLowerCase();return e.currentMode==="dub"?se.includes("eng")||se.includes("dub"):se.includes("jpn")||se.includes("sub")||!se.includes("eng")&&!se.includes("dub")});if((N.length>0?N:c??[]).find(F=>F.type!=="iframe"&&F.links?.length)){ke.current=[e.selectedProvider],Le.current=!1,g({type:"SET_STATE",payload:{selectedProvider:i,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",i),_e(null),Qe.success(`Switched to ${i} (direct stream)`);return}}_e({retryFailed:!0}),Qe.error("No working direct stream found on other providers")}finally{bt(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,g,ie,ye]),Yt=O(()=>{if(Je.current||Le.current||e.selectedSource?.type!=="player")return;const t=At();if(!t)return;ke.current.includes(e.selectedProvider)||ke.current.push(e.selectedProvider);const o=L.current;if(o==="iframe"){Pt(t);return}if(o==="retry"){Bt();return}k.setShowControls(!0),_e({retryFailed:!1})},[e.selectedSource,e.selectedProvider,At,Pt,Bt,k]);Ne.current=Yt;const gr=O(()=>{Le.current=!0,_e(null),Tt(!1)},[]),br=O(()=>{Xe&&dt("iframe");const t=At();t?Pt(t):_e(null)},[Xe,dt,At,Pt]),yr=O(()=>{Xe&&dt("retry"),Bt()},[Xe,dt,Bt]),Rt=(t,o,i)=>t.showId===o||!!i&&t.showId===i,It=O(()=>{k.onEnded();const t=T.find(i=>Rt(i,n,e.showMeta?.id)&&i.episodeNumber===e.currentEpisode);if(T.length>0){const i=T.findIndex(N=>Rt(N,n,e.showMeta?.id)&&N.episodeNumber===e.currentEpisode),c=i>=0?T[i+1]||null:T[0];ue({nextItem:c,playedItem:t||null}),me(2)}else t&&Ce.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let o=!1;if(e.isAutoplayEnabled&&T.length===0){const i=e.episodes.findIndex(c=>c===e.currentEpisode);if(i>-1&&i<e.episodes.length-1){const c=e.episodes[i+1];j.invalidateQueries({queryKey:["allContinueWatching"]}),w(`/watch/${n}/${c}`),o=!0}}if(!o&&T.length===0&&!D&&!Oe.current){const i=e.episodes.length>0&&!!e.currentEpisode&&e.episodes[e.episodes.length-1]===e.currentEpisode,c=String(e.showMeta.status||"").trim().toLowerCase(),N=["finished","completed","complete","ended"].some(de=>c.includes(de));i&&N&&g({type:"SET_STATE",payload:{showResumeModal:!0}})}},[k,w,T,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,D,g,j]),Qt=O(()=>{if(T.length===0)return;k.onEnded();const t=T.find(c=>Rt(c,n,e.showMeta?.id)&&c.episodeNumber===e.currentEpisode),o=T.findIndex(c=>Rt(c,n,e.showMeta?.id)&&c.episodeNumber===e.currentEpisode),i=o>=0?T[o+1]||null:T[0];t&&We.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),i?w(`/watch/${i.showId}/${i.episodeNumber}`):t&&g({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,w,T,We,n,e.showMeta?.id,e.currentEpisode,g]),_t=O(()=>{xe&&(j.invalidateQueries({queryKey:["allContinueWatching"]}),st(!1),w(`/watch/${n}/${xe}`)),g({type:"SET_STATE",payload:{showResumeModal:!1}})},[xe,w,n,g,j]),Jt=O(()=>{T.length>0?Qt():xe?_t():Qe.error("No next episode available")},[T.length,Qt,_t,xe]),Sr=()=>{Wt&&w(`/watch/${n}/${Wt}`)};x(()=>{const t=m.videoRef.current;if(!t)return;const o=()=>{we||It()};return t.addEventListener("ended",o),()=>{t&&t.removeEventListener("ended",o)}},[It,m.videoRef,we]),x(()=>{const t=o=>{o.origin===window.location.origin&&e.selectedSource?.type==="iframe"&&o.data?.type==="ANI_WEB_MEDIA_ENDED"&&It()};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[It,e.selectedSource?.type]),x(()=>{if(!D||at===null)return;if(at<=0){const{nextItem:o,playedItem:i}=D;ue(null),me(null),i&&Ce.current.mutate({showId:i.showId,episodeNumber:i.episodeNumber}),o?w(`/watch/${o.showId}/${o.episodeNumber}`):i&&g({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{me(o=>o===null?null:o-1)},1e3);return()=>window.clearTimeout(t)},[D,at,w,g]),x(()=>{pt&&a.state.isFullscreen&&a.actions.toggleFullscreen()},[pt,a.state.isFullscreen,a.actions]),x(()=>{pt&&m.videoRef.current&&m.videoRef.current.pause()},[pt,m.videoRef]);const{titlePreference:Lt}=Gr(),{lowEndMode:Er}=Hr(),mt=ct(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:t,names:o}=e.showMeta;return Lt==="name"?t||"Loading...":Lt==="nativeName"?o?.native||t||"Loading...":Lt==="englishName"?o?.english||t||"Loading...":t||"Loading..."},[e.showMeta,Lt,e.loadingShowData]);x(()=>{mt&&mt!=="Loading..."&&e.currentEpisode&&(document.title=`► ${mt} Episode ${e.currentEpisode} - dango`)},[mt,e.currentEpisode]),x(()=>{const t=o=>{if(!o.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')&&(["arrowup","arrowdown","arrowleft","arrowright"].includes(o.key.toLowerCase())&&(k.setShowControls(!0),a.actions.inactivityTimer.current&&clearTimeout(a.actions.inactivityTimer.current),a.actions.inactivityTimer.current=window.setTimeout(()=>{k.setShowControls(!1)},1e3)),o.key.toLowerCase()==="n"&&Jt(),o.key.toLowerCase()==="t")){const c=!oe;ge(c),localStorage.setItem("playerTheaterMode",c.toString())}};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[k,a.actions.inactivityTimer,Jt,oe]);const{setAvailableSubtitles:Xt,setActiveSubtitleTrack:qt}=k;x(()=>{const t=m.videoRef.current;if(!t)return;const o=()=>{const i=Array.from(t.textTracks).map(c=>({label:c.label,lang:c.language,src:void 0,mode:c.mode}));Xt(i)};return t.textTracks.addEventListener("addtrack",o),t.textTracks.addEventListener("removetrack",o),o(),()=>{t&&(t.textTracks.removeEventListener("addtrack",o),t.textTracks.removeEventListener("removetrack",o))}},[m.videoRef,Xt]),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 o=Ht(a.state.availableSubtitles,{lastKey:t,enabled:!0});if(o<0){qt("off");return}const i=a.state.availableSubtitles[o];qt(i.lang||i.label)}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,qt]),x(()=>{const t=m.videoRef.current;if(!t||a.state.availableSubtitles.length===0)return;const o=a.state.activeSubtitleTrack;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||o==="off"||o===null){Array.from(t.textTracks).forEach(N=>{N.mode="hidden"});return}let c=!1;if(Array.from(t.textTracks).forEach(N=>{const K=(N.language===o||N.label===o)&&!c;N.mode=K?"showing":"hidden",K&&(c=!0)}),!c&&t.textTracks.length>0){const N=Array.from(t.textTracks).find(de=>de.language==="en"||de.label==="English")||t.textTracks[0];N&&(N.mode="showing")}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,m.videoRef]);const[Zt,wr]=q(0);x(()=>{const t=m.videoRef.current;if(!t)return;const o=()=>wr(t.clientHeight||0);o();const i=new ResizeObserver(o);return i.observe(t),()=>i.disconnect()},[m.videoRef,e.selectedSource,e.selectedLink]),x(()=>{const t="dynamic-subtitle-styles";let o=document.getElementById(t);o||(o=document.createElement("style"),o.id=t,document.head.appendChild(o));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};o.textContent=ir(i);const c=m.videoRef.current;if(!c)return;const N=lr(a.state.subtitleFontSize,Zt||c.clientHeight||720);o.textContent=ir({...i,fontSize:N});const de=()=>{const y=Number(a.state.subtitlePosition),ee=isNaN(y)?0:Math.max(0,Math.min(100,y));return Math.max(0,Math.min(100,100-ee))},K=(y,ee)=>{try{const ae=y;ae.snapToLines=!1,ae.line=ee}catch{}},F=()=>{const y=N*16,ee=c.videoHeight||c.clientHeight||720,ae=c.videoWidth||c.clientWidth||1280;return{step:y*1.3/ee*100,chars:Math.max(20,Math.floor(ae/(y*.55)))}},se=y=>{const ee=de(),ae=Array.from(y.activeCues??[]);if(ae.length<=1){ae.forEach(St=>K(St,ee));return}const{step:yt,chars:$t}=F();let or=ee;for(let St=ae.length-1;St>=0;St--){const Pr=String(ae[St].text??"").replace(/<[^>]*>/g,"").split(`
|
|
55
|
+
`).reduce((Ar,Br)=>Ar+Math.max(1,Math.ceil(Br.length/$t)),0),sr=or-Pr*yt;K(ae[St],Math.max(0,sr)),or=sr-yt*.4}},fe=y=>{if(!y.cues)return;const ee=de();Array.from(y.cues).forEach(ae=>K(ae,ee)),y.mode==="showing"&&se(y)},Me=()=>{Array.from(c.textTracks).forEach(fe)};Me();const X=y=>{const ee=y.target;ee.mode==="showing"&&se(ee)};Array.from(c.textTracks).forEach(y=>{y.addEventListener("cuechange",X)});const Pe=()=>{Array.from(c.textTracks).forEach(y=>{y.removeEventListener("cuechange",X),y.addEventListener("cuechange",X)}),Me()};c.textTracks.addEventListener("addtrack",Pe),c.textTracks.addEventListener("removetrack",Pe);const be=Array.from(c.querySelectorAll("track")),Z=()=>{Me()};return be.forEach(y=>{y.addEventListener("load",Z)}),()=>{Array.from(c.textTracks).forEach(y=>{y.removeEventListener("cuechange",X)}),c.textTracks.removeEventListener("addtrack",Pe),c.textTracks.removeEventListener("removetrack",Pe),be.forEach(y=>{y.removeEventListener("load",Z)})}},[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,m.videoRef,Zt]),x(()=>{if(!_)return;const t=m.videoRef.current,o=ze.current;if(!t||!o)return;const i=localStorage.getItem("playerSubtitlesEnabled")!=="false",c=a.state.activeSubtitleTrack;function N(){if(o.innerHTML="",!i||c==="off"||c===null)return;const F=Array.from(t.textTracks).find(Z=>Z.language===c||Z.label===c);if(!F||F.mode!=="showing")return;const se=rt/1e3;let fe;if(se>0&&F.cues){const Z=t.currentTime-se;fe=Array.from(F.cues).filter(y=>y.startTime<=Z&&Z<=y.endTime)}else fe=Array.from(F.activeCues??[]);if(fe.length===0)return;const Me={fontSize:lr(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},X=an(Me),Pe=ln(t,Me.position),be=Array.from(fe);be.forEach((Z,y)=>{const ee=String(Z.text??"");if(!cn(ee).trim())return;const ae=document.createElement("div"),yt=(be.length-1-y)*1.7;ae.style.cssText=`${X}
|
|
56
|
+
bottom: calc(${Pe}px + ${yt}em);`,ae.innerHTML=un(ee),o.appendChild(ae)})}const de=()=>N(),K=()=>N();return Array.from(t.textTracks).forEach(F=>{F.addEventListener("cuechange",de)}),t.addEventListener("timeupdate",K),N(),()=>{Array.from(t.textTracks).forEach(F=>{F.removeEventListener("cuechange",de)}),t.removeEventListener("timeupdate",K),o.innerHTML=""}},[ne.isEnabled,ne.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,m.videoRef,_,rt]),x(()=>{try{localStorage.setItem("anime4kProfile",s)}catch{}},[s]);const kr=()=>{m.videoRef.current&&(m.videoRef.current.currentTime=e.resumeTime,m.videoRef.current.play()),g({type:"SET_STATE",payload:{showResumeModal:!1}})},Tr=()=>{m.videoRef.current&&(m.videoRef.current.currentTime=0,m.videoRef.current.play()),g({type:"SET_STATE",payload:{showResumeModal:!1}})},er=O(()=>{it&&(Oe.current=!0),xt&&st(!1),g({type:"SET_STATE",payload:{showResumeModal:!1}})},[g,it,xt]),Cr=O(()=>{if(st(!1),m.videoRef.current)try{m.videoRef.current.currentTime=0,m.videoRef.current.play().catch(()=>{})}catch{}g({type:"SET_STATE",payload:{showResumeModal:!1}})},[g,m]),Mr=O(async()=>{try{await U(),g({type:"SET_STATE",payload:{showResumeModal:!1}}),w("/")}catch{}},[U,g,w]),tr=(t,o)=>r("div",{className:t,children:[r("button",{className:`${u.episodeNavBtn} ${u.secondary}`,onClick:Sr,disabled:!Wt,type:"button",children:[r(W,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${u.episodeNavBtn} ${u.primary}`,onClick:_t,disabled:!xe,type:"button",children:["Next EP",r(W,{name:"chevron-right",size:12})]}),o==="mobile"&&Fe&&r("button",{className:`${u.episodeNavBtn} ${u.episodePickerBtn}`,onClick:()=>M(!0),type:"button",children:[r(W,{name:"list-ul",size:12}),"Episodes"]})]});x(()=>{ot&&(e.showResumeModal||T.length>0||D||Oe.current||it&&g({type:"SET_STATE",payload:{showResumeModal:!0}}))},[ot,it,e.showResumeModal,T.length,D,g]);const Rr=t=>{g({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),gn(t)},rr=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),_r=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",zt=f(A);zt.current=A;const nr=f("");x(()=>{const t=m.videoRef.current;if(wt(!1),st(!1),!t||e.selectedSource?.type==="iframe")return;const o=()=>{const i=t.duration,c=t.currentTime;if(!i||Number.isNaN(i)){wt(!1),st(!1);return}const N=c/i;if(i-c<=60){const de=T.findIndex(se=>Rt(se,n,e.showMeta?.id)&&se.episodeNumber===e.currentEpisode),K=T.length>0?de>=0?T[de+1]||null:T[0]:null,F=K?`${K.showId}:${K.episodeNumber}`:Vt?`${n}:${xe}`:"";F&&nr.current!==F&&(nr.current=F,K?zt.current(K.episodeNumber,K.showId):zt.current(xe))}wt(Vt&&N>=.8),st(c>=Math.max(i*.98,i-10))};return o(),t.addEventListener("timeupdate",o),t.addEventListener("loadedmetadata",o),()=>{t.removeEventListener("timeupdate",o),t.removeEventListener("loadedmetadata",o)}},[m.videoRef,Vt,e.currentEpisode,e.selectedSource,xe,n,T,e.showMeta?.id]);const Nr=O(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||$)return;const t=m.videoRef.current?.duration,o=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await ve(e.currentEpisode,o)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,ve,$,m.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 lt=e.loadingShowData||e.loadingVideo,xr=t=>{oe&&t.target===t.currentTarget&&(ge(!1),localStorage.setItem("playerTheaterMode","false"))};return e.showMeta?.isAdult===!0&&!C?r("div",{className:Ue.playerPageLayout,children:r(Ae,{isOpen:!0,title:"Content Warning",onClose:()=>w("/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:()=>w("/home"),children:"Go Back"}),r(Ze,{onClick:S,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${Ue.playerPageLayout} ${oe?Ue.theaterMode:""}`,onClick:xr,children:[r(Ae,{isOpen:jt,onClose:er,title:it?"Show Completed!":"Resume Playback?",width:"sm",children:it?r(Et,{children:[r(Ae.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r(Ae.Actions,{children:r(Ze,{onClick:Mr,disabled:De,children:De?"Saving...":"Move to Completed"})})]}):r(Et,{children:[r(Ae.Body,{children:r("p",{children:["You were watching at ",r("strong",{children:a.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]})}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:Tr,children:"Start Over"}),r(Ze,{onClick:kr,children:"Resume"})]})]})}),r(Ae,{isOpen:xt,onClose:er,title:"Episode Completed",width:"sm",children:[r(Ae.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",xe?" Would you like to watch the next episode?":""]})}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:Cr,children:"Replay"}),xe&&r(Ze,{onClick:_t,children:`Watch EP ${xe}`})]})]}),r(Ae,{isOpen:!!vt,onClose:gr,title:"Direct stream failed",width:"sm",children:[r(Ae.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),vt?.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:Xe,onChange:t=>Tt(t.target.checked)}),"Remember my choice"]})]}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:br,children:"Continue with iframe"}),r(Ze,{onClick:yr,disabled:gt,children:gt?"Searching…":"Try another provider"})]})]}),r(Kr,{isOpen:!!e.showCookieModal,onClose:()=>g({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{j.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!oe&&r("aside",{ref:Be,className:Ue.episodeSidebar,children:e.loadingShowData?r(dn,{variant:"sidebar"}):r(pn,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>w(`/watch/${n}/${t}`)})}),r("div",{className:Ue.playerMain,children:[r("div",{className:`${u.videoContainer} ${a.state.isFullscreen?"":Ue.videoPlayerWrapper} ${a.state.isFullscreen?u.fullscreenActive:""}`,style:{...pt?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(mo,{player:a,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Rr,fallbackChoice:Ct,onFallbackChoiceChange:dt,showNextEpisodeButton:!pt&&nt&&T.length===0,onNextEpisode:_t,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,o)=>{m.videoRef.current&&!isNaN(m.videoRef.current.currentTime)&&(te.current=m.videoRef.current.currentTime),le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:o,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:e.loadingVideo,skipIntervals:e.skipIntervals,animeTitle:mt,episodeNumber:e.currentEpisode,isTheaterMode:oe,onTheaterModeToggle:()=>{const t=!oe;ge(t),localStorage.setItem("playerTheaterMode",t.toString())},anime4kEnabled:ne.isEnabled,onAnime4kToggle:ne.toggle,anime4kSupported:ne.isWebGPUSupported,anime4kProfile:s,onAnime4kProfileChange:d,anime4kInitializing:ne.isInitializing,anime4kError:ne.error,videoDelayEnabled:Q,onVideoDelayToggle:t=>{Y(t);try{localStorage.setItem("playerVideoDelayEnabled",String(t))}catch{}},videoDelayMs:p,onVideoDelayChange:Ke,onCalibrateAvSync:ut,isInteractingExtra:kt||G,className:mn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(Et,{children:[a.state.isSpeedBoostActive&&r("div",{className:u.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(W,{name:"forward",size:12})]}),at!==null&&D?.nextItem&&r("div",{className:u.queueCountdown,children:["Queue next in ",at,"s"]})]}),children:[I&&r("div",{className:`${u.skipIndicatorContainer} ${I.side==="left"?u.leftSkip:u.rightSkip} `,children:r("div",{className:u.skipBubble,children:[r("div",{className:u.skipIcon,children:I.side==="left"?r(W,{name:"backward"}):r(W,{name:"forward"})}),r("div",{className:u.skipText,children:"15s"})]})}),lt&&r("div",{className:u.loadingOverlay,children:r("div",{className:u.loadingDots,children:[r("div",{className:u.dot}),r("div",{className:u.dot}),r("div",{className:u.dot})]})}),a.state.isBuffering&&!lt&&e.selectedSource?.type!=="iframe"&&r("div",{className:u.bufferingOverlay,children:r("div",{className:u.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!lt&&r("iframe",{src:e.selectedLink?.link,className:u.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(Et,{children:[!lt&&e.videoSources.length===0&&r("div",{className:u.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:u.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:u.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!lt&&e.videoSources.length>0&&r("video",{ref:m.videoRef,controls:a.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:k.onPlay,onPause:k.onPause,onLoadedMetadata:k.onLoadedMetadata,onTimeUpdate:()=>{we||(k.onTimeUpdate(),D&&m.videoRef.current&&m.videoRef.current.currentTime<m.videoRef.current.duration-1&&(ue(null),me(null)))},onProgress:k.onProgress,onVolumeChange:k.onVolumeChange,onWaiting:k.onWaiting,onPlaying:k.onPlaying,onError:Yt,onContextMenu:t=>t.preventDefault(),className:_?u.videoElementHidden:""}),ne.isWebGPUSupported&&!lt&&e.videoSources.length>0&&r("canvas",{ref:Ie,className:`${u.upscalerCanvas} ${Ye?u.upscalerActive:""}`}),!Ye&&!lt&&e.videoSources.length>0&&r("canvas",{ref:ft,className:`${u.upscalerCanvas} ${h?u.upscalerActive:""}`}),ne.isEnabled&&ne.isWebGPUSupported&&ne.isInitializing&&r("div",{className:u.upscalerStatusBadge,children:"Preparing upscaler…"}),_&&r("div",{ref:ze,className:u.subtitleOverlay}),r(hn,{isOpen:G,ms:p,onChange:Ke,onApply:pe,onClose:re,testClipActive:we,onTestClip:je})]})]})}),!oe&&r(fn,{}),!oe&&r(Et,{children:[Mt&&T.length===0?r(ho,{count:3}):r(En,{title:"Queue",items:T,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:Qt,onRemove:t=>We.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>he.mutate(),showClearAll:!0,onReorder:t=>Ot.mutate(t.map(o=>({id:o.id,showId:o.showId,episodeNumber:o.episodeNumber})))}),r("div",{className:u.providerAndEpisodeRow,children:[r(wo,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:R,onProviderChange:t=>{Je.current=!1,ke.current=[],Le.current=!1,_e(null),g({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",t)}}),tr(`${u.episodeActions} ${u.desktopEpisodeActions}`,"desktop")]}),lt?r("div",{className:u.sourceLoader,children:r("div",{className:u.spinner})}):r(Et,{children:r(To,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{m.videoRef.current&&!isNaN(m.videoRef.current.currentTime)&&(te.current=m.videoRef.current.currentTime);const i=(t.links||[]).sort((c,N)=>(parseInt(N.resolutionStr)||0)-(parseInt(c.resolutionStr)||0))[0]||null;le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:i,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(le(e.selectedSource.sourceName),g({type:"SET_STATE",payload:{selectedLink:t}}))}})}),r("div",{className:Ue.playerInfoContainer,children:[r("div",{className:Ue.playerInfoHeader,children:[r("div",{className:Ue.playerAnimeCard,children:r("img",{src:jr(e.showMeta.thumbnail||""),alt:mt,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:Ue.videoTitleSection,children:[r("div",{className:u.titleContainer,children:[r("h1",{children:mt}),r("div",{className:u.scheduleInfo,children:[e.showMeta.status&&r("span",{className:u.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:u.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:u.controls,children:[r("button",{className:`${u.watchlistBtn} ${e.inWatchlist?u.inList:""}`,onClick:V,children:[e.inWatchlist?r(W,{name:"check",size:14}):r(W,{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:`${u.watchlistBtn} ${u.queueBtn}`,activeClassName:u.queueActive}),_r&&r("button",{className:`${u.watchlistBtn} ${u.markWatchedBtn} ${rr?u.markWatchedDone:""}`,onClick:Nr,disabled:$||!e.currentEpisode,children:[r(W,{name:"check",size:14}),$?"Saving...":rr?"Watched":"Mark Watched"]}),r("button",{className:`${u.watchlistBtn} ${u.modeToggleBtn} ${e.currentMode==="dub"?u.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";Je.current=!1,ke.current=[],Le.current=!1,_e(null),g({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:`${u.watchlistBtn} ${u.modeToggleBtn} ${a.state.useNativeControls?u.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"})]})]})]}),tr(`${u.episodeActions} ${u.mobileEpisodeActions}`,"mobile"),r("div",{className:u.descriptionSection,children:[r("h3",{children:"Synopsis"}),r(Cn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."})]}),r("button",{className:u.detailsToggleBtn,onClick:z,children:[e.showCombinedDetails?r(W,{name:"chevron-up"}):r(W,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]}),e.showCombinedDetails&&r(Tn,{showMeta:e.showMeta,styles:u})]})]})]}),r(vn,{isOpen:kt,onClose:()=>M(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{M(!1),w(`/watch/${n}/${t}`)}})]})};export{ts as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as I,d as X,T as Y,u as e}from"./vendor-core-8R2fFbyN.js";import{I as o}from"./vendor-icons-CDMuNDeL.js";import{S as Z,O as _,a as ee,A as ne}from"./OptionListMenu-Bj9ebsW3.js";import{u as te}from"./index-CtoKRNLc.js";import"./AvSyncCalibrator-D8hqarVB.js";import"./vendor-query-BXRECSI6.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-DKWi-9kd.js → QueueOptionsButton-lv26-6jp.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as A}from"./vendor-query-BXRECSI6.js";import{q as V,j as Z,Z as H,$ as J,a0 as W}from"./index-
|
|
1
|
+
import{b as A}from"./vendor-query-BXRECSI6.js";import{q as V,j as Z,Z as H,$ as J,a0 as W}from"./index-CtoKRNLc.js";import{d as X,T as R,q as r,u as t,$ as Y,S as w}from"./vendor-core-8R2fFbyN.js";import{a as ee,c as te,d as ne,b as se,o as oe,f as ae,s as ie}from"./vendor-ui-CUDCvRS_.js";import{I as u}from"./vendor-icons-CDMuNDeL.js";function Pe(n){return A({queryKey:["show-meta",n],queryFn:async()=>n?V(`/api/show-meta/${n}`):{},enabled:!!n,staleTime:3e4})}async function re(n){const d=await fetch(`/api/queue/suggested/${n}`);if(!d.ok)throw new Error("Failed to resolve suggested episode");return d.json()}const ue="_trigger_1vova_6",me="_triggerBtn_1vova_11",le="_chevron_1vova_25",ce="_menu_1vova_34",pe="_menuTitle_1vova_51",de="_menuItem_1vova_60",ge="_removeItem_1vova_91",fe="_menuEmpty_1vova_99",a={trigger:ue,triggerBtn:me,chevron:le,menu:ce,menuTitle:pe,menuItem:de,removeItem:ge,menuEmpty:fe},ve=8,$e=({showId:n,showName:d,showThumbnail:h,nativeName:y,englishName:_,showType:b,className:F="",activeClassName:T="",align:z="right",onMenuOpenChange:g})=>{const{data:E=[]}=Z(),P=H(),$=J(),[m,v]=X(!1),{refs:q,floatingStyles:D,context:x}=ee({open:m,onOpenChange:e=>{e||(v(!1),g?.(!1))},placement:z==="left"?"bottom-start":"bottom-end",middleware:[oe(ve),ae({padding:8}),ie({padding:8})],whileElementsMounted:se}),I=te(x,{outsidePress:!0,escapeKey:!0,referencePress:!1}),{getReferenceProps:M,getFloatingProps:S}=ne([I]),l=R(()=>E.filter(e=>e.showId===n),[E,n]),{data:C}=A({queryKey:["suggestedEpisode",n],queryFn:()=>re(n),enabled:!!n}),{data:Q,isFetching:N}=W(n,m),s=R(()=>Q?.episodes||[],[Q]),k=r(()=>{v(!0),g?.(!0)},[g]),c=r(()=>{v(!1),g?.(!1)},[g]),p=l.length>0,o=s.length>0,f=C?.episodeNumber,i=r(e=>{!n||e.length===0||(P.mutate({showId:n,episodeNumbers:e,showName:d,showThumbnail:h,nativeName:y,englishName:_,type:b}),c())},[n,d,h,y,_,b,P,c]),K=r(()=>{!n||l.length===0||($.mutate({showId:n,episodeNumbers:l.map(e=>e.episodeNumber)}),c())},[n,l,$,c]),j=r(()=>{o?i([s[0]]):f&&i([String(f)])},[o,s,f,i]),L=r(()=>{o&&i(s.slice(0,3))},[o,s,i]),O=r(()=>{o&&i([...s])},[o,s,i]),B=s[0],U=s[Math.min(2,s.length-1)],G=t("div",{className:a.trigger,ref:q.setReference,children:t("span",{className:`${a.triggerBtn} ${F} ${p?T:""}`,role:"button",tabIndex:0,"aria-haspopup":"menu","aria-expanded":m,"aria-label":p?"Queued":"Queue",...M(),onClick:e=>{e.preventDefault(),e.stopPropagation(),m?c():k()},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),m?c():k())},children:[p?t(u,{name:"check",size:14}):t(u,{name:"plus",size:14}),p?"Queued":"Queue",t(u,{name:"chevron-down",size:10,className:a.chevron})]})});return t(w,{children:[G,m&&Y(t("div",{ref:q.setFloating,className:a.menu,style:D,role:"menu",...S(),onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[t("div",{className:a.menuTitle,children:"Queue episodes"}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o&&!f,onClick:e=>{e.stopPropagation(),j()},children:[t(u,{name:"plus",size:11}),t("span",{children:o?`+1 — EP ${B}`:`+1 — EP ${f||"?"}`})]}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o,onClick:e=>{e.stopPropagation(),L()},children:[t(u,{name:"plus",size:11}),t("span",{children:o?`+3 — EP ${B}${s.length>1?`-${U}`:""}`:"+3"})]}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o,onClick:e=>{e.stopPropagation(),O()},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:a.menuEmpty,children:p?"All episodes are already queued":"No remaining unwatched episodes"}),p&&t("button",{className:`${a.menuItem} ${a.removeItem}`,role:"menuitem",type:"button",onClick:e=>{e.stopPropagation(),K()},children:[t(u,{name:"times",size:11}),t("span",{children:["Remove from Queue",l.length>0?` (${l.length})`:""]})]})]}),document.body)]})};export{$e as Q,Pe as u};
|