@serifpersia/dango 3.6.1 → 3.6.3
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-DbrG4Bo-.js → AnimeCard-Cwc6Z9rO.js} +1 -1
- package/client/dist/assets/{AnimeInfo-CgSQGjef.js → AnimeInfo-ad7aMRq5.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-DSybdvf_.js → AnimeInfoPage-B795AIlr.js} +2 -2
- package/client/dist/assets/{Asmr-DFFV-7y4.js → Asmr-jqhD7q69.js} +2 -2
- package/client/dist/assets/{AsmrResetProgressModal-Brdfu_22.js → AsmrResetProgressModal-Bey2zoeh.js} +1 -1
- package/client/dist/assets/{AvSyncCalibrator-DBBUzoHn.js → AvSyncCalibrator-B2fQmjbo.js} +1 -1
- package/client/dist/assets/{Home-DjGl-3os.js → Home-rRTAnTfL.js} +1 -1
- package/client/dist/assets/{Insights-4O52Z1t2.js → Insights-CN2bm8wf.js} +1 -1
- package/client/dist/assets/{LibraryListPage-Z0w_rmHP.js → LibraryListPage-BlNQWLrf.js} +1 -1
- package/client/dist/assets/{ListeningList-DjbzDs1E.js → ListeningList-Pi1Baxgd.js} +1 -1
- package/client/dist/assets/{Manga-BRIDluzF.js → Manga-7Jt2tJyE.js} +1 -1
- package/client/dist/assets/{MangaInfoPage-Q4CjEGJH.js → MangaInfoPage-45jPSjxB.js} +1 -1
- package/client/dist/assets/{MangaReadPage-BbJK5FY6.js → MangaReadPage-BWgX9bSn.js} +1 -1
- package/client/dist/assets/{MangaResetProgressModal-BCFPXDF6.js → MangaResetProgressModal-DLgJrIVT.js} +1 -1
- package/client/dist/assets/{Mature-DjQzs66p.js → Mature-2I4mvoWk.js} +1 -1
- package/client/dist/assets/{MediaCard-DedwE5DX.js → MediaCard-cSWL_NlR.js} +1 -1
- package/client/dist/assets/{Music-z2RkiMDf.js → Music-bUuge7On.js} +1 -1
- package/client/dist/assets/{OptionListMenu-CetjZizt.js → OptionListMenu-D4ejupic.js} +1 -1
- package/client/dist/assets/Player-Fm7-Iaym.js +56 -0
- package/client/dist/assets/{PlayerSettings-ne_DQSTl.js → PlayerSettings-e_PohoiO.js} +1 -1
- package/client/dist/assets/{QueueOptionsButton-CIKT4YcD.js → QueueOptionsButton-BMl804vN.js} +1 -1
- package/client/dist/assets/{QueueRail-DPclldS0.js → QueueRail-BfNg-4sG.js} +1 -1
- package/client/dist/assets/{Radio-aeqPTMht.js → Radio-BbkMYqMU.js} +1 -1
- package/client/dist/assets/{ReadingList-p6G7NHtC.js → ReadingList-BN03nBXY.js} +1 -1
- package/client/dist/assets/{ResetProgressModal-B7UuuL3X.js → ResetProgressModal-CuoM4S_P.js} +1 -1
- package/client/dist/assets/{Search-BzyHVByR.js → Search-DnBPEHjw.js} +1 -1
- package/client/dist/assets/{Settings-DMmtLUsL.js → Settings-CqiYnqx7.js} +1 -1
- package/client/dist/assets/{SkeletonGrid-B5JXhZO4.js → SkeletonGrid-CYZ3cstC.js} +1 -1
- package/client/dist/assets/{Trackers-tLL1afjB.js → Trackers-DlkQl9Qs.js} +1 -1
- package/client/dist/assets/Tv-Ac8wPuCw.js +4 -0
- package/client/dist/assets/{TvInfo-DmrBLjgK.js → TvInfo-Dhv0lmCc.js} +1 -1
- package/client/dist/assets/{TvPopup-D1mSlOZt.js → TvPopup-5lwvCCOQ.js} +1 -1
- package/client/dist/assets/{TvSearch-BGQRUq9E.js → TvSearch-B3_Vf8Dk.js} +1 -1
- package/client/dist/assets/{TvWatchlist-DdLkpeQT.js → TvWatchlist-B_jtSOjL.js} +1 -1
- package/client/dist/assets/{Watchlist-BObmM6QB.js → Watchlist-BtFidAWI.js} +1 -1
- package/client/dist/assets/{hls-qCuNYJym.js → hls-CEWF8efn.js} +1 -1
- package/client/dist/assets/{index-B4AdKbhW.js → index-C93G341i.js} +2 -2
- package/client/dist/assets/{useAnimeInfoData-CSnwUBuU.js → useAnimeInfoData-gz0XXrYm.js} +1 -1
- package/client/dist/assets/{useAsmr-BKAaWEXn.js → useAsmr-BrRbA9AW.js} +1 -1
- package/client/dist/assets/{useAsmrPopup-DDLRBLzz.js → useAsmrPopup-C4gKdZId.js} +1 -1
- package/client/dist/assets/{useMangaLibrary-C6XEMuSr.js → useMangaLibrary-DkGSBFSX.js} +1 -1
- package/client/dist/assets/{useMangaPopup-wfCJubPD.js → useMangaPopup-DwKm2HYt.js} +1 -1
- package/client/dist/assets/{useProviders-C7jrBgxf.js → useProviders-C3E0fPpP.js} +1 -1
- package/client/dist/assets/{useTv-DM5KtzEc.js → useTv-BQ3K3Xdh.js} +1 -1
- package/client/dist/assets/{useTvLibrary-73NkS_5R.js → useTvLibrary-DizEfaXg.js} +1 -1
- package/client/dist/index.html +1 -1
- package/package.json +2 -2
- package/server/dist/lib/anilist.js +32 -4
- package/server/dist/providers/title-matching.js +2 -0
- package/server/dist/trpc/routers/data.js +1 -1
- package/server/package.json +1 -1
- package/client/dist/assets/Player-DD-9SgWU.js +0 -56
- package/client/dist/assets/Tv-CluLN4KA.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as R,p as me,a as ge,d as o,A as ve,g as fe,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as L}from"./vendor-icons-DrybRNxP.js";import{P as ee,S as Le}from"./SkeletonGrid-B5JXhZO4.js";import{A as Ae}from"./AnimeCard-DbrG4Bo-.js";import{t as be,u as ye,v as Se,L as ae,B as w,N as Ne}from"./index-B4AdKbhW.js";import{E as Ce}from"./ErrorMessage-DAxegITP.js";import{s as t}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-CSnwUBuU.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-CIKT4YcD.js";import"./vendor-ui-3qrARCPr.js";import"./MediaCard-DedwE5DX.js";import"./useIsMobile-Dvx1uJ82.js";const Te=[{value:"ALL",label:"All Types"},{value:"TV",label:"TV Series"},{value:"Movie",label:"Movie"},{value:"OVA",label:"OVA"},{value:"ONA",label:"ONA"},{value:"TV_SHORT",label:"TV Short"},{value:"SPECIAL",label:"Special"},{value:"ADULT",label:"Mature"}],Ee=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],Ie=[{value:"ALL",label:"All Countries"},{value:"JP",label:"Japan"},{value:"CN",label:"China"}],De=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"START_DATE_ASC",label:"Oldest"},{value:"EPISODES_DESC",label:"Most Episodes"},{value:"FAVOURITES_DESC",label:"Favourites"}],Pe=[{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"},{value:"CANCELLED",label:"Cancelled"},{value:"HIATUS",label:"Hiatus"}];function Ve(){R(()=>{document.title="Search - dango"},[]);const[r,te]=me(),le=ge(),[h,k]=o(r.get("query")||""),[p,_]=o(parseInt(r.get("page")||"1")),[u,A]=o(r.get("type")||"ALL"),[m,b]=o(r.get("season")||"ALL"),[g,y]=o(r.get("year")||"ALL"),[B,E]=o(r.get("country")||"ALL"),[G,ne]=o(r.get("provider")||"anilist"),[Y,I]=o(r.get("sortBy")||"POPULARITY_DESC"),[U,D]=o(r.get("status")||""),[S,re]=o(!1),[se,F]=o(null);R(()=>{let e=!1;return be.data.anilistStatus.query().then(n=>{e||F(n.available)}).catch(()=>{e||F(!0)}),()=>{e=!0}},[]);const{lowEndMode:ie}=ye(),P=ve(null),{data:oe}=Se(),M=oe?.genres||[],[v,N]=o(()=>{const e={},n=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],s=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return n.forEach(l=>l&&(e[l]="include")),s.forEach(l=>l&&(e[l]="exclude")),e}),$=new URLSearchParams(r);$.delete("page");const V=$.toString(),{data:f=[],isLoading:C,isError:ce,error:ue}=ae(V,p,14),{data:j}=ae(V,p+1,14),[x,de]=o(!1),T=fe.useMemo(()=>G==="anilist"&&u==="ADULT"||x?f:f.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[f,x,G,u]);R(()=>{k(r.get("query")||""),A(r.get("type")||"ALL"),b(r.get("season")||"ALL"),y(r.get("year")||"ALL"),E(r.get("country")||"ALL"),ne(r.get("provider")||"anilist"),I(r.get("sortBy")||"POPULARITY_DESC"),D(r.get("status")||""),_(parseInt(r.get("page")||"1"));const e={},n=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],s=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];n.forEach(l=>l&&(e[l]="include")),s.forEach(l=>l&&(e[l]="exclude")),N(e)},[r]);const c=(e=1,n={})=>{Ne();const s=n.type??u,l=n.status??U,q=n.season??m,H=n.year??g,J=n.country??B,K=n.sort??Y,Q=n.genreState??v,pe=n.showMature??x,i=new URLSearchParams;h.trim()&&i.set("query",h.trim()),s!=="ALL"&&i.set("type",s),l&&i.set("status",l),q!=="ALL"&&i.set("season",q),H!=="ALL"&&i.set("year",H),J!=="ALL"&&i.set("country",J),K!=="POPULARITY_DESC"&&i.set("sortBy",K);const X=Object.entries(Q).filter(([,d])=>d==="include").map(([d])=>d),Z=Object.entries(Q).filter(([,d])=>d==="exclude").map(([d])=>d);X.length>0&&i.set("genres",X.join(",")),Z.length>0&&i.set("excludeGenres",Z.join(",")),s!=="ADULT"&&!pe&&i.set("adult","false"),i.set("provider","anilist"),e>1&&i.set("page",e.toString()),te(i),e!==p&&_(e)},W=e=>{if(c(e),P.current){const n=P.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:n,behavior:"smooth"})}},O=new Date().getFullYear(),he=[{value:"ALL",label:"All Years"},...Array.from({length:O-1980+1},(e,n)=>({value:String(O-n),label:String(O-n)}))],z=f.length>=14&&j&&j.length>0;return a("div",{className:"page-container",children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:"Search Anime"}),a("p",{className:t.pageSubtitle,children:"Search through thousands of titles and discover your next favorite"})]}),a("div",{className:t.filterContainer,children:[a("div",{className:t.searchBarWrapper,children:[a("div",{className:t.inputIconWrapper,children:[a(L,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search by title, character, or studio...",value:h,onInput:e=>k(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&c()})]}),a("div",{className:t.searchActions,children:[a(w,{onClick:()=>c(),className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${S?t.active:""}`,onClick:()=>re(!S),children:[a(L,{name:"filter",size:14}),a("span",{children:"Filters"}),S?a(L,{name:"chevron-up",size:12}):a(L,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${S?t.show:""}`,children:[a("div",{className:t.filterDivider}),a("div",{className:t.filterGrid,children:[a("div",{className:t.filterItem,children:[a("label",{children:"Type"}),a("select",{value:u,onChange:e=>{if(e.currentTarget.value==="ADULT"){le("/mature?provider=mal");return}A(e.currentTarget.value)},children:Te.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Status"}),a("select",{value:U,onChange:e=>D(e.currentTarget.value),children:[a("option",{value:"",children:"All Status"}),Pe.map(e=>a("option",{value:e.value,children:e.label},e.value))]})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Season"}),a("select",{value:m,onChange:e=>b(e.currentTarget.value),children:Ee.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Year"}),a("select",{value:g,onChange:e=>y(e.currentTarget.value),children:he.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:["Country",se===!1&&a("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:400},children:"AniList only — ignored by fallback providers"})]}),a("select",{value:B,onChange:e=>E(e.currentTarget.value),children:Ie.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Sort By"}),a("select",{value:Y,onChange:e=>I(e.currentTarget.value),children:De.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),M.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:M.map(e=>a("button",{className:`${t.genreButton} ${t[v[e]||""]}`,onClick:()=>{N(n=>{const s=n[e],l={...n};return s==="include"?l[e]="exclude":s==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(w,{variant:"secondary",onClick:()=>{N({}),A("ALL"),b("ALL"),y("ALL"),E("ALL"),I("POPULARITY_DESC"),D(""),de(!1),c(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(w,{onClick:()=>c(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),ce&&a(Ce,{message:ue?.message||"Error"}),(u!=="ALL"||m!=="ALL"||g!=="ALL"||Object.keys(v).length>0)&&a("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",marginBottom:"1.5rem"},children:[a("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontWeight:600},children:"Active Filters:"}),u!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Type: ",u,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),A("ALL"),c(1,{type:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),m!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Season: ",m,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),b("ALL"),c(1,{season:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),g!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Year: ",g,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),y("ALL"),c(1,{year:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),Object.entries(v).map(([e,n])=>a("span",{className:`badge ${n==="include"?"badge-primary":"badge-danger"}`,style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[n==="include"?`+ ${e}`:`- ${e}`,a("button",{onClick:s=>{s.stopPropagation(),s.preventDefault();const l={...v};delete l[e],N(l),c(1,{genreState:l})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]},e))]}),a("div",{className:t.resultsHeader,ref:P,children:[a("h2",{className:t.resultsTitle,children:h?`Search Results for "${h}"`:"Discover Anime"}),T.length>0&&a(ee,{page:p,canGoNext:z,onChange:W,isLoading:C})]}),a("div",{className:`${t.resultsGrid} ${ie?t.lowEnd:""}`,children:C?a(Le,{}):T.map(e=>a(Ae,{anime:e},e._id))}),!C&&T.length===0&&a("div",{className:t.noResults,children:[a(L,{name:"search",size:48,className:t.noResultsIcon}),a("h3",{children:"No results found"}),a("p",{children:"Try adjusting your search or filters to find what you're looking for."})]}),T.length>0&&a("div",{className:t.bottomPagination,children:a(ee,{page:p,canGoNext:z,onChange:W,isLoading:C,variant:"labeled"})})]})}export{Ve as default};
|
|
1
|
+
import{h as R,p as me,a as ge,d as o,A as ve,g as fe,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as L}from"./vendor-icons-DrybRNxP.js";import{P as ee,S as Le}from"./SkeletonGrid-CYZ3cstC.js";import{A as Ae}from"./AnimeCard-Cwc6Z9rO.js";import{t as be,u as ye,v as Se,N as ae,B as w,O as Ne}from"./index-C93G341i.js";import{E as Ce}from"./ErrorMessage-DAxegITP.js";import{s as t}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-gz0XXrYm.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-BMl804vN.js";import"./vendor-ui-3qrARCPr.js";import"./MediaCard-cSWL_NlR.js";import"./useIsMobile-Dvx1uJ82.js";const Te=[{value:"ALL",label:"All Types"},{value:"TV",label:"TV Series"},{value:"Movie",label:"Movie"},{value:"OVA",label:"OVA"},{value:"ONA",label:"ONA"},{value:"TV_SHORT",label:"TV Short"},{value:"SPECIAL",label:"Special"},{value:"ADULT",label:"Mature"}],Ee=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],Ie=[{value:"ALL",label:"All Countries"},{value:"JP",label:"Japan"},{value:"CN",label:"China"}],De=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"START_DATE_ASC",label:"Oldest"},{value:"EPISODES_DESC",label:"Most Episodes"},{value:"FAVOURITES_DESC",label:"Favourites"}],Pe=[{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"},{value:"CANCELLED",label:"Cancelled"},{value:"HIATUS",label:"Hiatus"}];function Ve(){R(()=>{document.title="Search - dango"},[]);const[r,te]=me(),le=ge(),[h,k]=o(r.get("query")||""),[p,_]=o(parseInt(r.get("page")||"1")),[u,A]=o(r.get("type")||"ALL"),[m,b]=o(r.get("season")||"ALL"),[g,y]=o(r.get("year")||"ALL"),[B,E]=o(r.get("country")||"ALL"),[G,ne]=o(r.get("provider")||"anilist"),[Y,I]=o(r.get("sortBy")||"POPULARITY_DESC"),[U,D]=o(r.get("status")||""),[S,re]=o(!1),[se,F]=o(null);R(()=>{let e=!1;return be.data.anilistStatus.query().then(n=>{e||F(n.available)}).catch(()=>{e||F(!0)}),()=>{e=!0}},[]);const{lowEndMode:ie}=ye(),P=ve(null),{data:oe}=Se(),M=oe?.genres||[],[v,N]=o(()=>{const e={},n=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],s=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return n.forEach(l=>l&&(e[l]="include")),s.forEach(l=>l&&(e[l]="exclude")),e}),$=new URLSearchParams(r);$.delete("page");const V=$.toString(),{data:f=[],isLoading:C,isError:ce,error:ue}=ae(V,p,14),{data:j}=ae(V,p+1,14),[x,de]=o(!1),T=fe.useMemo(()=>G==="anilist"&&u==="ADULT"||x?f:f.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[f,x,G,u]);R(()=>{k(r.get("query")||""),A(r.get("type")||"ALL"),b(r.get("season")||"ALL"),y(r.get("year")||"ALL"),E(r.get("country")||"ALL"),ne(r.get("provider")||"anilist"),I(r.get("sortBy")||"POPULARITY_DESC"),D(r.get("status")||""),_(parseInt(r.get("page")||"1"));const e={},n=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],s=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];n.forEach(l=>l&&(e[l]="include")),s.forEach(l=>l&&(e[l]="exclude")),N(e)},[r]);const c=(e=1,n={})=>{Ne();const s=n.type??u,l=n.status??U,q=n.season??m,H=n.year??g,J=n.country??B,K=n.sort??Y,Q=n.genreState??v,pe=n.showMature??x,i=new URLSearchParams;h.trim()&&i.set("query",h.trim()),s!=="ALL"&&i.set("type",s),l&&i.set("status",l),q!=="ALL"&&i.set("season",q),H!=="ALL"&&i.set("year",H),J!=="ALL"&&i.set("country",J),K!=="POPULARITY_DESC"&&i.set("sortBy",K);const X=Object.entries(Q).filter(([,d])=>d==="include").map(([d])=>d),Z=Object.entries(Q).filter(([,d])=>d==="exclude").map(([d])=>d);X.length>0&&i.set("genres",X.join(",")),Z.length>0&&i.set("excludeGenres",Z.join(",")),s!=="ADULT"&&!pe&&i.set("adult","false"),i.set("provider","anilist"),e>1&&i.set("page",e.toString()),te(i),e!==p&&_(e)},W=e=>{if(c(e),P.current){const n=P.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:n,behavior:"smooth"})}},O=new Date().getFullYear(),he=[{value:"ALL",label:"All Years"},...Array.from({length:O-1980+1},(e,n)=>({value:String(O-n),label:String(O-n)}))],z=f.length>=14&&j&&j.length>0;return a("div",{className:"page-container",children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:"Search Anime"}),a("p",{className:t.pageSubtitle,children:"Search through thousands of titles and discover your next favorite"})]}),a("div",{className:t.filterContainer,children:[a("div",{className:t.searchBarWrapper,children:[a("div",{className:t.inputIconWrapper,children:[a(L,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search by title, character, or studio...",value:h,onInput:e=>k(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&c()})]}),a("div",{className:t.searchActions,children:[a(w,{onClick:()=>c(),className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${S?t.active:""}`,onClick:()=>re(!S),children:[a(L,{name:"filter",size:14}),a("span",{children:"Filters"}),S?a(L,{name:"chevron-up",size:12}):a(L,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${S?t.show:""}`,children:[a("div",{className:t.filterDivider}),a("div",{className:t.filterGrid,children:[a("div",{className:t.filterItem,children:[a("label",{children:"Type"}),a("select",{value:u,onChange:e=>{if(e.currentTarget.value==="ADULT"){le("/mature?provider=mal");return}A(e.currentTarget.value)},children:Te.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Status"}),a("select",{value:U,onChange:e=>D(e.currentTarget.value),children:[a("option",{value:"",children:"All Status"}),Pe.map(e=>a("option",{value:e.value,children:e.label},e.value))]})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Season"}),a("select",{value:m,onChange:e=>b(e.currentTarget.value),children:Ee.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Year"}),a("select",{value:g,onChange:e=>y(e.currentTarget.value),children:he.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:["Country",se===!1&&a("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:400},children:"AniList only — ignored by fallback providers"})]}),a("select",{value:B,onChange:e=>E(e.currentTarget.value),children:Ie.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Sort By"}),a("select",{value:Y,onChange:e=>I(e.currentTarget.value),children:De.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),M.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:M.map(e=>a("button",{className:`${t.genreButton} ${t[v[e]||""]}`,onClick:()=>{N(n=>{const s=n[e],l={...n};return s==="include"?l[e]="exclude":s==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(w,{variant:"secondary",onClick:()=>{N({}),A("ALL"),b("ALL"),y("ALL"),E("ALL"),I("POPULARITY_DESC"),D(""),de(!1),c(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(w,{onClick:()=>c(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),ce&&a(Ce,{message:ue?.message||"Error"}),(u!=="ALL"||m!=="ALL"||g!=="ALL"||Object.keys(v).length>0)&&a("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",marginBottom:"1.5rem"},children:[a("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontWeight:600},children:"Active Filters:"}),u!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Type: ",u,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),A("ALL"),c(1,{type:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),m!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Season: ",m,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),b("ALL"),c(1,{season:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),g!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Year: ",g,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),y("ALL"),c(1,{year:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),Object.entries(v).map(([e,n])=>a("span",{className:`badge ${n==="include"?"badge-primary":"badge-danger"}`,style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[n==="include"?`+ ${e}`:`- ${e}`,a("button",{onClick:s=>{s.stopPropagation(),s.preventDefault();const l={...v};delete l[e],N(l),c(1,{genreState:l})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]},e))]}),a("div",{className:t.resultsHeader,ref:P,children:[a("h2",{className:t.resultsTitle,children:h?`Search Results for "${h}"`:"Discover Anime"}),T.length>0&&a(ee,{page:p,canGoNext:z,onChange:W,isLoading:C})]}),a("div",{className:`${t.resultsGrid} ${ie?t.lowEnd:""}`,children:C?a(Le,{}):T.map(e=>a(Ae,{anime:e},e._id))}),!C&&T.length===0&&a("div",{className:t.noResults,children:[a(L,{name:"search",size:48,className:t.noResultsIcon}),a("h3",{children:"No results found"}),a("p",{children:"Try adjusting your search or filters to find what you're looking for."})]}),T.length>0&&a("div",{className:t.bottomPagination,children:a(ee,{page:p,canGoNext:z,onChange:W,isLoading:C,variant:"labeled"})})]})}export{Ve as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as s,A as H,h as A,u as e,q as ie,S as ke,T as Ce,p as Se,g as ce,_ as _e}from"./vendor-core-DfaOB3Rn.js";import{d as Ne,t as C,B as T,M as $,j as he,h as Te,z as de,F as te,G as Ie,T as Re,u as xe,e as Le,H as Pe,y as ae,A as De,V as Ae,I as Oe}from"./index-B4AdKbhW.js";import{u as oe}from"./vendor-query-BBT5_sHx.js";import{T as q}from"./ToggleSwitch-CN_ppEc9.js";import{I as Y}from"./vendor-icons-DrybRNxP.js";const ne={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},se=["name","nativeName","englishName"],re={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},Ge=()=>{const{titlePreference:t,setTitlePreference:r,loading:o}=Ne(),[d,l]=s(re[t]),[v,w]=s(!1),c=H(null);A(()=>{o||l(re[t])},[t,o]);const a=async()=>{if(v)return;w(!0);const u=(se.indexOf(t)+1)%se.length,p=se[u],h=re[p];c.current&&(c.current.style.transform="translateX(-100%)",c.current.style.opacity="0"),setTimeout(async()=>{l(h),r(p),c.current&&(c.current.style.transition="none",c.current.style.transform="translateX(100%)",c.current.style.opacity="0",c.current.offsetWidth,c.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",c.current.style.transform="translateX(0)",c.current.style.opacity="1");try{await C.settings.set.mutate({key:"titlePreference",value:p})}catch(_){console.error("Error saving title preference:",_)}finally{w(!1)}},300)};return o?e("p",{children:"Loading title preference..."}):e("div",{className:ne["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:a,className:ne["toggle-button"],disabled:v,children:e("span",{ref:c,className:ne["toggle-label"],children:d})})]})},Me="_settingsHeader_14a5d_1",Ue="_pageTitle_14a5d_6",Ee="_pageSubtitle_14a5d_14",ze="_settingsLayout_14a5d_20",$e="_sidebar_14a5d_27",Fe="_sidebarIndicator_14a5d_35",qe="_sidebarItem_14a5d_50",Ke="_active_14a5d_72",je="_mainContent_14a5d_80",He="_tabContent_14a5d_85",We="_sectionCard_14a5d_103",Be="_settingItem_14a5d_127",Ve="_settingRow_14a5d_132",Qe="_controls_14a5d_145",Ye="_status_14a5d_151",m={settingsHeader:Me,pageTitle:Ue,pageSubtitle:Ee,settingsLayout:ze,sidebar:$e,sidebarIndicator:Fe,sidebarItem:qe,active:Ke,mainContent:je,tabContent:He,sectionCard:We,settingItem:Be,settingRow:Ve,controls:Qe,status:Ye},Je="_sectionCard_wt900_12",Xe="_title_wt900_22",Ze="_signIn_wt900_29",et="_userInfo_wt900_36",tt="_warning_wt900_58",at="_formGroup_wt900_65",nt="_label_wt900_69",st="_inputWrapper_wt900_79",rt="_input_wt900_79",it="_select_wt900_103",ot="_actions_wt900_140",lt="_hr_wt900_148",g={sectionCard:Je,title:Xe,signIn:Ze,userInfo:et,warning:tt,formGroup:at,label:nt,inputWrapper:st,input:rt,select:it,actions:ot,hr:lt},ct=()=>{const[t,r]=s(!0),[o,d]=s(!1),[l,v]=s(!1),[w,c]=s(null),[a,i]=s({status:"idle"}),[u,p]=s(!1),[h,_]=s(""),[y,k]=s(!1),R=H(null),[x,L]=s({show:!1,message:"",type:"info"}),P=()=>{R.current&&(window.clearInterval(R.current),R.current=null)},b=ie(f=>{v(f.authenticated),c(f.user||f.device.user||null),i(f.device),p(!!f.hasCustomClientId)},[]),S=ie(async()=>{const f=await C.auth.githubStatus.query();b(f)},[b]),O=async()=>{try{const f=await C.auth.githubPoll.query();i(f),f.status==="success"?(P(),await S(),L({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):f.status==="error"&&(P(),L({show:!0,message:f.error||"GitHub authentication failed.",type:"error"}))}catch{P(),L({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},U=(f=5)=>{P(),R.current=window.setInterval(O,Math.max(f,5)*1e3)};A(()=>(S().catch(()=>{L({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>r(!1)),P),[S]);const N=async()=>{d(!0);try{const f=await C.auth.githubStart.mutate();i(f),U(f.verification?.interval)}catch(f){L({show:!0,message:f instanceof Error?f.message:"Failed to start GitHub authentication.",type:"error"})}finally{d(!1)}},G=async()=>{try{await C.auth.githubLogout.mutate(),v(!1),c(null),i({status:"idle"}),L({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{L({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},E=async()=>{k(!0);try{await C.auth.saveGithubAuth.mutate({clientId:h}),_(""),await S(),L({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{L({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},K=async()=>{k(!0);try{await C.auth.saveGithubAuth.mutate({clientId:""}),_(""),await S(),L({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{L({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:g.sectionCard,children:[e("h3",{className:g.title,children:"GitHub Cloud Sync"}),e("p",{className:g.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),l&&w?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:w.name||w.login})]}),e(T,{variant:"danger",onClick:G,children:"Sign Out"})]}):e("div",{className:g.signIn,children:e(T,{onClick:N,disabled:o||a.status==="pending",children:o||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(ke,{children:[e("hr",{className:g.hr}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Verification URL"}),e("div",{className:g.inputWrapper,children:[e("input",{className:g.input,value:a.verification.verification_uri,readOnly:!0}),e(T,{onClick:()=>{const f=a.verification?.verification_uri;f&&/^https?:\/\//i.test(f)&&window.open(f,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Device Code"}),e("input",{className:g.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:g.warning,children:a.error}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",u?"(override active)":""]}),e("div",{className:g.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:g.label,children:"Client ID (optional)"}),e("input",{className:g.input,value:h,onChange:f=>_(f.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:g.actions,children:[e(T,{onClick:E,disabled:y,children:"Save override"}),e(T,{variant:"secondary",onClick:K,disabled:y,children:"Use dango defaults"})]})]}),e($,{isOpen:x.show,onClose:()=>L(f=>({...f,show:!1})),width:"sm",children:[e($.Body,{children:e("p",{children:x.message})}),e($.Actions,{children:e(T,{onClick:()=>L(f=>({...f,show:!1})),children:"OK"})})]})]})},dt=()=>{const[t,r]=s(!0),[o,d]=s(null),[l,v]=s(!1),[w,c]=s(!1),[a,i]=s(""),[u,p]=s(""),[h,_]=s(""),[y,k]=s(!1),[R,x]=s({show:!1,message:"",type:"info"}),L=async()=>{try{const N=await C.auth.user.query();d(N?.email?N:null)}catch{d(null)}},P=async()=>{try{const[N,G]=await Promise.all([C.auth.configStatus.query(),C.auth.googleAuth.query()]);v(!!N.hasConfig),c(!!(G.hasCustomWorkerUrl||G.hasCustomClientId||G.hasClientSecret))}catch(N){console.error("Failed to fetch config status",N)}};A(()=>{(async()=>{r(!0),await Promise.all([L(),P()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await L(),window.history.replaceState(null,"",window.location.pathname))}catch{}r(!1)})();const G=E=>{E.origin===window.location.origin&&typeof E.data=="object"&&E.data!==null&&E.data.type==="GOOGLE_AUTH_SUCCESS"&&(d(E.data.user),window.location.reload())};return window.addEventListener("message",G),()=>window.removeEventListener("message",G)},[]);const b=async()=>{try{const N=await C.auth.googleLogin.mutate();if(N.authenticated){window.location.reload();return}if(N.url){if(typeof window.DangoBridge<"u"){window.location.href=N.url;return}const E=600,K=700,f=window.innerWidth/2-E/2,J=window.innerHeight/2-K/2;window.open(N.url,"GoogleAuth",`width=${E},height=${K},top=${J},left=${f}`)}else throw new Error("Auth URL not available")}catch{x({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},S=async()=>{try{await C.auth.logout.mutate(),d(null),x({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(N){console.error("Sign out failed",N),x({show:!0,message:"Failed to sign out.",type:"error"})}},O=async()=>{k(!0);try{await C.auth.saveGoogleAuth.mutate({workerUrl:a,clientId:u,clientSecret:h}),i(""),p(""),_(""),await P(),x({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{x({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},U=async()=>{k(!0);try{await C.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),i(""),p(""),_(""),await P(),x({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{x({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:g.sectionCard,children:[e("h3",{className:g.title,children:"Google Drive Sync"}),o?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:o.name})," (",o.email,")"]}),e(T,{variant:"danger",onClick:S,children:"Sign Out"})]}):e("div",{className:g.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(T,{onClick:b,disabled:!l,children:"Sign in with Google"}),!l&&e("p",{className:g.warning,children:"Google sync is not configured on the server."})]}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",w?"(override active)":""]}),e("div",{className:g.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:g.label,children:"Worker URL (optional)"}),e("input",{className:g.input,value:a,onChange:N=>i(N.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Client ID (optional)"}),e("input",{className:g.input,value:u,onChange:N=>p(N.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:g.input,value:h,onChange:N=>_(N.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:g.actions,children:[e(T,{onClick:O,disabled:y,children:"Save override"}),e(T,{variant:"secondary",onClick:U,disabled:y,children:"Use dango defaults"})]})]}),e($,{isOpen:R.show,onClose:()=>x(N=>({...N,show:!1})),width:"sm",children:[e($.Body,{children:e("p",{children:R.message})}),e($.Actions,{children:e(T,{onClick:()=>x(N=>({...N,show:!1})),children:"OK"})})]})]})},ut="_sectionCard_1pqo4_1",ht="_settingItem_1pqo4_26",gt="_settingRow_1pqo4_31",mt="_modalOverlay_1pqo4_38",pt="_modal_1pqo4_38",yt="_modalActions_1pqo4_73",ft="_modalSecondary_1pqo4_79",vt="_modalPrimary_1pqo4_89",z={sectionCard:ut,settingItem:ht,settingRow:gt,modalOverlay:mt,modal:pt,modalActions:yt,modalSecondary:ft,modalPrimary:vt},wt={anime:{heading:"Watchlist Preferences",blurb:"Customize your experience when managing your watchlist and series entries.",skipKey:"skipRemoveConfirmation",ignoreKey:"ignoreAdultContent",listOnlyKey:"cwWatchlistOnly",skipLabel:"Skip confirmation when removing from watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in watchlist",listNoun:"watchlist",continueNoun:"continue watching",adultCountUrl:"/api/continue-watching/adult-count",purgeUrl:"/api/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["allContinueWatching"]]},manga:{heading:"Reading List Preferences",blurb:"Customize your experience when managing your reading list and manga entries.",skipKey:"mangaSkipRemoveConfirmation",ignoreKey:"mangaIgnoreAdultContent",listOnlyKey:"mangaCwWatchlistOnly",skipLabel:"Skip confirmation when removing from reading list",ignoreLabel:"Hide adult content from continue reading",listOnlyLabel:"Only show continue reading for manga in reading list",listNoun:"reading list",continueNoun:"continue reading",adultCountUrl:"/api/manga/continue-reading/adult-count",purgeUrl:"/api/manga/continue-reading/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue reading`,invalidateKeys:[["manga-continue-reading"]]},tv:{heading:"TV Watchlist Preferences",blurb:"Customize your experience when managing your TV watchlist and series entries.",skipKey:"tvSkipRemoveConfirmation",ignoreKey:"tvIgnoreAdultContent",listOnlyKey:"tvCwWatchlistOnly",skipLabel:"Skip confirmation when removing from TV watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in TV watchlist",listNoun:"TV watchlist",continueNoun:"continue watching",adultCountUrl:"/api/tv/continue-watching/adult-count",purgeUrl:"/api/tv/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["tv-continue-watching"]]},asmr:{heading:"Listening List Preferences",blurb:"Customize your experience when managing your listening list and work entries.",skipKey:"asmrSkipRemoveConfirmation",ignoreKey:"asmrIgnoreAdultContent",listOnlyKey:"asmrCwWatchlistOnly",skipLabel:"Skip confirmation when removing from listening list",ignoreLabel:"Hide adult content from continue listening",listOnlyLabel:"Only show continue listening for works in listening list",listNoun:"listening list",continueNoun:"continue listening",adultCountUrl:"/api/asmr/continue-listening/adult-count",purgeUrl:"/api/asmr/continue-listening/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue listening`,invalidateKeys:[["asmr-continue-listening"]]}},bt=(t,r)=>{if(t==null)return r;const o=String(t);return o==="true"||o==="1"?!0:o==="false"||o==="0"?!1:r},ue=(t,r,o)=>{const[d,l]=s(r),[v,w]=s(!1),c=oe();return A(()=>{(async()=>{try{const u=await C.settings.getByKey.query({key:t});l(bt(u.value,r))}catch(u){console.error("Failed to fetch setting",u)}})()},[t,r]),{value:d,setValue:l,isUpdating:v,toggle:async()=>{if(v)return;w(!0);const i=!d;l(i);try{await C.settings.set.mutate({key:t,value:i});for(const u of o)c.invalidateQueries({queryKey:u})}catch(u){console.error("Error saving setting:",u),l(!i)}finally{w(!1)}}}},kt=()=>{const{contentType:t}=he(),r=wt[t],[o,d]=s(!1),[l,v]=s(!0),[w,c]=s(!1),a=ue(r.ignoreKey,!0,r.invalidateKeys),i=ue(r.listOnlyKey,!1,r.invalidateKeys),[u,p]=s(null),[h,_]=s(!1),y=oe(),k=Te();A(()=>{v(!0),(async()=>{try{const S=await C.settings.getByKey.query({key:r.skipKey});String(S.value)==="true"||String(S.value)==="1"?d(!0):d(!1)}catch(S){console.error("Failed to fetch setting",S)}finally{v(!1)}})()},[r.skipKey]);const R=async()=>{if(w)return;c(!0);const b=!o;d(b);try{await C.settings.set.mutate({key:r.skipKey,value:b})}catch(S){console.error("Error saving setting:",S),d(!b)}finally{c(!1)}},x=async()=>{if(!a.isUpdating){if(a.value)try{let b;if(t==="anime"?b=(await C.continueWatching.adultCount.query()).count:t==="manga"?b=(await C.mangaProgress.adultCount.query()).count:t==="asmr"?b=(await C.asmrProgress.adultCount.query()).count:b=(await C.tvProgress.adultCount.query()).count,typeof b=="number"&&b>0){p(b);return}}catch(b){console.error("Failed to fetch adult count",b)}a.toggle()}},L=()=>{p(null),a.toggle()},P=async()=>{if(!h){_(!0);try{let b;t==="anime"?b=(await C.continueWatching.purgeAdult.mutate()).removed:t==="manga"?b=(await C.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?b=(await C.asmrProgress.purgeAdult.mutate()).removed:b=(await C.tvProgress.purgeAdult.mutate()).removed,de.success(r.purgeDoneText(b??0));for(const S of r.invalidateKeys)y.invalidateQueries({queryKey:S});t==="anime"&&y.invalidateQueries(k.continueWatching.pathFilter()),t==="manga"&&y.invalidateQueries(k.mangaProgress.pathFilter()),t==="asmr"&&y.invalidateQueries(k.asmrProgress.pathFilter()),t==="tv"&&y.invalidateQueries(k.tvProgress.pathFilter())}catch(b){console.error("Failed to purge adult entries",b),de.error("Failed to remove adult entries")}finally{_(!1),p(null)}a.toggle()}};return l?e("div",{children:"Loading settings..."}):e("div",{className:z.sectionCard,children:[e("h3",{children:r.heading}),e("p",{children:r.blurb}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:r.skipLabel}),e(q,{isChecked:o,onChange:R,id:"skip-confirmation-toggle",disabled:w})]})}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:r.ignoreLabel}),e(q,{isChecked:a.value,onChange:x,id:"ignore-adult-toggle",disabled:a.isUpdating})]})}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:r.listOnlyLabel}),e(q,{isChecked:i.value,onChange:i.toggle,id:"cw-watchlist-only-toggle",disabled:i.isUpdating})]})}),u!==null&&e("div",{className:z.modalOverlay,onClick:()=>p(null),children:e("div",{className:z.modal,onClick:b=>b.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[u," adult ",u===1?"entry":"entries"," not in your"," ",r.listNoun," ",u===1?"is":"are"," currently hidden from"," ",r.continueNoun,". You can purge ",u===1?"it":"them"," from the database instead of showing ",u===1?"it":"them","."]}),e("div",{className:z.modalActions,children:[e("button",{type:"button",className:z.modalSecondary,onClick:L,disabled:h,children:"Show them"}),e("button",{type:"button",className:z.modalPrimary,onClick:P,disabled:h,children:h?"Purging...":`Purge ${u}`})]})]})})]})},Ct="_sectionCard_jkggs_1",St="_statsGrid_jkggs_26",_t="_statCard_jkggs_33",Nt="_statLabel_jkggs_43",Tt="_statValue_jkggs_51",It="_statMeta_jkggs_57",Rt="_statusBanner_jkggs_63",xt="_statusSuccess_jkggs_74",Lt="_statusUpdating_jkggs_80",Pt="_statusError_jkggs_86",Dt="_sha_jkggs_92",At="_settingItem_jkggs_99",Ot="_settingRow_jkggs_104",Gt="_settingTitle_jkggs_111",Mt="_settingSubtitle_jkggs_117",Ut="_actionsRow_jkggs_124",I={sectionCard:Ct,statsGrid:St,statCard:_t,statLabel:Nt,statValue:Tt,statMeta:It,statusBanner:Rt,statusSuccess:xt,statusUpdating:Lt,statusError:Pt,sha:Dt,settingItem:At,settingRow:Ot,settingTitle:Gt,settingSubtitle:Mt,actionsRow:Ut},Et=()=>{const[t,r]=s(null),[o,d]=s(!0),[l,v]=s(!1),[w,c]=s(!1),a=H(null),i=async()=>{try{const y=await C.settings.offlineDbInfo.query();return r(y),y}catch(y){console.error("Failed to fetch offline DB info:",y)}finally{d(!1)}return null};A(()=>(i(),()=>{a.current&&window.clearInterval(a.current)}),[]),A(()=>{t?.isRefreshing?a.current||(a.current=window.setInterval(async()=>{const y=await i();y&&!y.isRefreshing&&a.current&&(window.clearInterval(a.current),a.current=null)},2e3)):a.current&&(window.clearInterval(a.current),a.current=null)},[t?.isRefreshing]);const u=async()=>{if(!t||l)return;const y=!t.autoUpdateEnabled;v(!0),r({...t,autoUpdateEnabled:y});try{await C.settings.setOfflineDbAutoUpdate.mutate({enabled:y})}catch(k){console.error("Failed to update auto update setting:",k),r({...t,autoUpdateEnabled:!y})}finally{v(!1)}},p=async()=>{if(!(t?.isRefreshing||w)){c(!0);try{await C.settings.triggerOfflineDbUpdate.mutate(),r(y=>y?{...y,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(y){console.error("Failed to trigger offline DB update:",y)}finally{c(!1)}}},h=y=>{if(!y)return"Never";try{return new Date(y).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return y}},_=t?.isRefreshing||w;return e("div",{className:I.sectionCard,children:[e("h3",{children:"Offline Metadata Database"}),e("p",{children:"Local MAL to AniList ID map used for instant imports and metadata enrichment without hitting rate-limited APIs. Updates automatically every Saturday in the background."}),e("div",{className:I.statsGrid,children:[e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"MAL Mapped"}),e("span",{className:I.statValue,children:o?"—":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Release"}),e("span",{className:I.statMeta,children:o?"—":t?.releaseTag??"Never"})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Last Checked"}),e("span",{className:I.statMeta,children:o?"—":h(t?.lastCheckedAt??null)})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Last Updated"}),e("span",{className:I.statMeta,children:o?"—":h(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${I.statusBanner} ${t.lastStatus==="failed"?I.statusError:t.lastStatus==="updating"?I.statusUpdating:I.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:I.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:I.settingItem,children:e("div",{className:I.settingRow,children:[e("div",{children:[e("span",{className:I.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:I.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(q,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:u,disabled:o||l})]})}),e("div",{className:I.actionsRow,children:e(T,{onClick:p,disabled:o||_,children:_?"Updating Database...":"Update Offline Database Now"})})]})},zt="_sectionCard_1g4qx_1",$t="_dangerCard_1g4qx_26",Ft="_status_1g4qx_34",qt="_warningText_1g4qx_40",Kt="_ackLabel_1g4qx_44",Q={sectionCard:zt,dangerCard:$t,status:Ft,warningText:qt,ackLabel:Kt},jt=()=>{const t=oe(),[r,o]=s(!1),[d,l]=s(!1),[v,w]=s(!1),[c,a]=s(""),i=()=>{l(!1),a(""),o(!0)},u=()=>{v||(o(!1),l(!1))},p=async()=>{if(!(!d||v)){w(!0),a("");try{const h=await fetch("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),_=await h.json();if(!h.ok)throw new Error(_.error||"Failed to clear database");const y=_.deleted,k=_.deletedManga,R=_.deletedTv,x=_.deletedAsmr,L=Object.values(y).reduce((O,U)=>O+(U||0),0)+Object.values(k??{}).reduce((O,U)=>O+(U||0),0)+Object.values(R??{}).reduce((O,U)=>O+(U||0),0)+Object.values(x??{}).reduce((O,U)=>O+(U||0),0),P=(k?.manga_library??0)+(k?.manga_progress??0),b=(R?.tv_library??0)+(R?.tv_progress??0),S=(x?.asmr_library??0)+(x?.asmr_progress??0);a(`Library cleared — ${y.watchlist??0} watchlist entries, ${P} manga rows, ${b} TV rows, ${S} ASMR rows and ${L} total rows removed.`),t.invalidateQueries({queryKey:["watchlist"]}),t.invalidateQueries({queryKey:["allContinueWatching"]}),t.invalidateQueries({queryKey:["manga-library"]}),t.invalidateQueries({queryKey:["manga-continue-reading"]}),t.invalidateQueries({queryKey:["tv-library"]}),t.invalidateQueries({queryKey:["tv-continue-watching"]}),t.invalidateQueries({queryKey:["asmr-library"]}),t.invalidateQueries({queryKey:["asmr-continue-listening"]}),o(!1)}catch(h){a(h.message)}finally{w(!1),l(!1)}}};return e("div",{className:`${Q.sectionCard} ${Q.dangerCard}`,children:[e("h3",{children:"Danger Zone"}),e("p",{children:"Permanently delete your library (watchlist, watched episodes, queue, cached show metadata, manga reading list and reading progress, TV watchlist and watch progress, ASMR listening list and listening progress) to start fresh. Your settings, sync state and the offline metadata cache are preserved."}),e(T,{variant:"danger",onClick:i,children:"Clear Library Data"}),c&&e("p",{className:Q.status,children:c}),e($,{isOpen:r,onClose:u,title:"Clear library data?",width:"sm",children:[e($.Body,{children:[e("p",{className:Q.warningText,children:"This permanently deletes everything in your library. It acts on the active database (dev or prod, per server config) and cannot be undone. Settings, sync state and the offline metadata cache are kept."}),e("label",{className:Q.ackLabel,children:[e("input",{type:"checkbox",checked:d,onChange:h=>l(h.target.checked),disabled:v}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e($.Actions,{children:[e(T,{variant:"secondary",onClick:u,disabled:v,children:"Cancel"}),e(T,{variant:"danger",onClick:p,disabled:!d||v,children:v?"Clearing...":"Yes, delete everything"})]})]})]})},Ht=()=>{const[t,r]=s(""),[o,d]=s([]),[l,v]=s(null),[w,c]=s(!0),[a,i]=s({show:!1,message:"",type:"info"}),u=async()=>{try{c(!0);const _=await(await fetch("/api/auth/settings/rclone")).json();r(_.remote||""),d(_.availableRemotes||[]),v(_.activeRemote||null)}catch(h){console.error("Failed to fetch Rclone settings",h)}finally{c(!1)}};A(()=>{u()},[]);const p=async()=>{try{if((await fetch("/api/auth/settings/rclone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:t})})).ok)i({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),u();else throw new Error("Failed to save")}catch{i({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return w?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:g.sectionCard,children:[e("h3",{className:g.title,children:"Rclone Cloud Sync"}),e("p",{className:g.signIn,children:"Configure which Rclone remote to use for database synchronization."}),l?e("div",{className:g.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:l})]})}):e("p",{className:g.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Remote Name"}),e("div",{className:g.inputWrapper,children:e("select",{className:g.select,value:t,onChange:h=>r(h.target.value),children:[e("option",{value:"",children:"(Disabled / None)"}),o.map(h=>e("option",{value:h,children:h},h)),t&&!o.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:g.warning,style:{marginTop:"12px"},children:[e("strong",{children:"Note:"})," You can choose which provider is active using the selector at the top of the page."]})]}),e("div",{className:g.actions,children:e(T,{onClick:p,children:"Save Rclone Settings"})}),e($,{isOpen:a.show,onClose:()=>i(h=>({...h,show:!1})),width:"sm",children:[e($.Body,{children:e("p",{children:a.message})}),e($.Actions,{children:e(T,{onClick:()=>i(h=>({...h,show:!1})),children:"OK"})})]})]})},Wt=()=>{const[t,r]=s(null),[o,d]=s(!0),l=async()=>{try{const i=await(await fetch("/api/auth/settings/sync")).json();r(i)}catch(a){console.error("Failed to fetch sync settings",a)}finally{d(!1)}};A(()=>{l()},[]);const v=async a=>{const i=a.target.value;try{const u=await fetch("/api/auth/settings/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i})});if(u.ok){const p=await u.json();r(h=>h?{...h,activeProvider:p.activeProvider}:null),await l(),te.success(`Sync provider updated to ${i==="default"?"Default Order":i}`)}else te.error("Failed to update sync provider")}catch{te.error("Error updating sync provider")}};if(o||!t)return null;const w=[{value:"default",label:"Default (Priority Based)"}];t.authenticatedProviders.github&&w.push({value:"github",label:"GitHub"}),t.authenticatedProviders.google&&w.push({value:"google",label:"Google Drive"}),t.authenticatedProviders.rclone&&w.push({value:"rclone",label:"Rclone"}),w.push({value:"none",label:"None (Local Only)"});const c=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:m.sectionCard,children:[e("h3",{children:"Active Sync Provider"}),e("p",{children:'Choose which provider to use for synchronization. "Default" uses the first available provider you are logged into.'}),e("div",{style:{marginBottom:"1.5rem",padding:"0.75rem",background:"rgba(255, 255, 255, 0.03)",borderRadius:"var(--radius-md)",borderLeft:"4px solid var(--accent)",fontSize:"var(--font-size-sm)"},children:["Current Status:"," ",e("strong",{style:{color:"var(--accent-light)",textTransform:"capitalize"},children:c(t.actualActiveProvider)})]}),e("div",{className:m.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:t.activeProvider,onChange:v,style:{padding:"0.5rem",borderRadius:"var(--radius-md)",background:"rgba(255, 255, 255, 0.05)",color:"var(--text-primary)",border:"1px solid var(--glass-border)",fontSize:"var(--font-size-sm)",minWidth:"220px",outline:"none",cursor:"pointer"},children:w.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function Bt(){return"javascript:"+encodeURIComponent(`(function(){
|
|
1
|
+
import{d as s,A as H,h as A,u as e,q as ie,S as ke,T as Ce,p as Se,g as ce,_ as _e}from"./vendor-core-DfaOB3Rn.js";import{d as Ne,t as C,B as T,M as $,j as he,h as Te,z as de,F as te,G as Ie,T as Re,u as xe,e as Le,H as Pe,y as ae,A as De,V as Ae,I as Oe}from"./index-C93G341i.js";import{u as oe}from"./vendor-query-BBT5_sHx.js";import{T as q}from"./ToggleSwitch-CN_ppEc9.js";import{I as Y}from"./vendor-icons-DrybRNxP.js";const ne={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},se=["name","nativeName","englishName"],re={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},Ge=()=>{const{titlePreference:t,setTitlePreference:r,loading:o}=Ne(),[d,l]=s(re[t]),[v,w]=s(!1),c=H(null);A(()=>{o||l(re[t])},[t,o]);const a=async()=>{if(v)return;w(!0);const u=(se.indexOf(t)+1)%se.length,p=se[u],h=re[p];c.current&&(c.current.style.transform="translateX(-100%)",c.current.style.opacity="0"),setTimeout(async()=>{l(h),r(p),c.current&&(c.current.style.transition="none",c.current.style.transform="translateX(100%)",c.current.style.opacity="0",c.current.offsetWidth,c.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",c.current.style.transform="translateX(0)",c.current.style.opacity="1");try{await C.settings.set.mutate({key:"titlePreference",value:p})}catch(_){console.error("Error saving title preference:",_)}finally{w(!1)}},300)};return o?e("p",{children:"Loading title preference..."}):e("div",{className:ne["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:a,className:ne["toggle-button"],disabled:v,children:e("span",{ref:c,className:ne["toggle-label"],children:d})})]})},Me="_settingsHeader_14a5d_1",Ue="_pageTitle_14a5d_6",Ee="_pageSubtitle_14a5d_14",ze="_settingsLayout_14a5d_20",$e="_sidebar_14a5d_27",Fe="_sidebarIndicator_14a5d_35",qe="_sidebarItem_14a5d_50",Ke="_active_14a5d_72",je="_mainContent_14a5d_80",He="_tabContent_14a5d_85",We="_sectionCard_14a5d_103",Be="_settingItem_14a5d_127",Ve="_settingRow_14a5d_132",Qe="_controls_14a5d_145",Ye="_status_14a5d_151",m={settingsHeader:Me,pageTitle:Ue,pageSubtitle:Ee,settingsLayout:ze,sidebar:$e,sidebarIndicator:Fe,sidebarItem:qe,active:Ke,mainContent:je,tabContent:He,sectionCard:We,settingItem:Be,settingRow:Ve,controls:Qe,status:Ye},Je="_sectionCard_wt900_12",Xe="_title_wt900_22",Ze="_signIn_wt900_29",et="_userInfo_wt900_36",tt="_warning_wt900_58",at="_formGroup_wt900_65",nt="_label_wt900_69",st="_inputWrapper_wt900_79",rt="_input_wt900_79",it="_select_wt900_103",ot="_actions_wt900_140",lt="_hr_wt900_148",g={sectionCard:Je,title:Xe,signIn:Ze,userInfo:et,warning:tt,formGroup:at,label:nt,inputWrapper:st,input:rt,select:it,actions:ot,hr:lt},ct=()=>{const[t,r]=s(!0),[o,d]=s(!1),[l,v]=s(!1),[w,c]=s(null),[a,i]=s({status:"idle"}),[u,p]=s(!1),[h,_]=s(""),[y,k]=s(!1),R=H(null),[x,L]=s({show:!1,message:"",type:"info"}),P=()=>{R.current&&(window.clearInterval(R.current),R.current=null)},b=ie(f=>{v(f.authenticated),c(f.user||f.device.user||null),i(f.device),p(!!f.hasCustomClientId)},[]),S=ie(async()=>{const f=await C.auth.githubStatus.query();b(f)},[b]),O=async()=>{try{const f=await C.auth.githubPoll.query();i(f),f.status==="success"?(P(),await S(),L({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):f.status==="error"&&(P(),L({show:!0,message:f.error||"GitHub authentication failed.",type:"error"}))}catch{P(),L({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},U=(f=5)=>{P(),R.current=window.setInterval(O,Math.max(f,5)*1e3)};A(()=>(S().catch(()=>{L({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>r(!1)),P),[S]);const N=async()=>{d(!0);try{const f=await C.auth.githubStart.mutate();i(f),U(f.verification?.interval)}catch(f){L({show:!0,message:f instanceof Error?f.message:"Failed to start GitHub authentication.",type:"error"})}finally{d(!1)}},G=async()=>{try{await C.auth.githubLogout.mutate(),v(!1),c(null),i({status:"idle"}),L({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{L({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},E=async()=>{k(!0);try{await C.auth.saveGithubAuth.mutate({clientId:h}),_(""),await S(),L({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{L({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},K=async()=>{k(!0);try{await C.auth.saveGithubAuth.mutate({clientId:""}),_(""),await S(),L({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{L({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:g.sectionCard,children:[e("h3",{className:g.title,children:"GitHub Cloud Sync"}),e("p",{className:g.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),l&&w?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:w.name||w.login})]}),e(T,{variant:"danger",onClick:G,children:"Sign Out"})]}):e("div",{className:g.signIn,children:e(T,{onClick:N,disabled:o||a.status==="pending",children:o||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(ke,{children:[e("hr",{className:g.hr}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Verification URL"}),e("div",{className:g.inputWrapper,children:[e("input",{className:g.input,value:a.verification.verification_uri,readOnly:!0}),e(T,{onClick:()=>{const f=a.verification?.verification_uri;f&&/^https?:\/\//i.test(f)&&window.open(f,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Device Code"}),e("input",{className:g.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:g.warning,children:a.error}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",u?"(override active)":""]}),e("div",{className:g.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:g.label,children:"Client ID (optional)"}),e("input",{className:g.input,value:h,onChange:f=>_(f.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:g.actions,children:[e(T,{onClick:E,disabled:y,children:"Save override"}),e(T,{variant:"secondary",onClick:K,disabled:y,children:"Use dango defaults"})]})]}),e($,{isOpen:x.show,onClose:()=>L(f=>({...f,show:!1})),width:"sm",children:[e($.Body,{children:e("p",{children:x.message})}),e($.Actions,{children:e(T,{onClick:()=>L(f=>({...f,show:!1})),children:"OK"})})]})]})},dt=()=>{const[t,r]=s(!0),[o,d]=s(null),[l,v]=s(!1),[w,c]=s(!1),[a,i]=s(""),[u,p]=s(""),[h,_]=s(""),[y,k]=s(!1),[R,x]=s({show:!1,message:"",type:"info"}),L=async()=>{try{const N=await C.auth.user.query();d(N?.email?N:null)}catch{d(null)}},P=async()=>{try{const[N,G]=await Promise.all([C.auth.configStatus.query(),C.auth.googleAuth.query()]);v(!!N.hasConfig),c(!!(G.hasCustomWorkerUrl||G.hasCustomClientId||G.hasClientSecret))}catch(N){console.error("Failed to fetch config status",N)}};A(()=>{(async()=>{r(!0),await Promise.all([L(),P()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await L(),window.history.replaceState(null,"",window.location.pathname))}catch{}r(!1)})();const G=E=>{E.origin===window.location.origin&&typeof E.data=="object"&&E.data!==null&&E.data.type==="GOOGLE_AUTH_SUCCESS"&&(d(E.data.user),window.location.reload())};return window.addEventListener("message",G),()=>window.removeEventListener("message",G)},[]);const b=async()=>{try{const N=await C.auth.googleLogin.mutate();if(N.authenticated){window.location.reload();return}if(N.url){if(typeof window.DangoBridge<"u"){window.location.href=N.url;return}const E=600,K=700,f=window.innerWidth/2-E/2,J=window.innerHeight/2-K/2;window.open(N.url,"GoogleAuth",`width=${E},height=${K},top=${J},left=${f}`)}else throw new Error("Auth URL not available")}catch{x({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},S=async()=>{try{await C.auth.logout.mutate(),d(null),x({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(N){console.error("Sign out failed",N),x({show:!0,message:"Failed to sign out.",type:"error"})}},O=async()=>{k(!0);try{await C.auth.saveGoogleAuth.mutate({workerUrl:a,clientId:u,clientSecret:h}),i(""),p(""),_(""),await P(),x({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{x({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},U=async()=>{k(!0);try{await C.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),i(""),p(""),_(""),await P(),x({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{x({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:g.sectionCard,children:[e("h3",{className:g.title,children:"Google Drive Sync"}),o?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:o.name})," (",o.email,")"]}),e(T,{variant:"danger",onClick:S,children:"Sign Out"})]}):e("div",{className:g.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(T,{onClick:b,disabled:!l,children:"Sign in with Google"}),!l&&e("p",{className:g.warning,children:"Google sync is not configured on the server."})]}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",w?"(override active)":""]}),e("div",{className:g.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:g.label,children:"Worker URL (optional)"}),e("input",{className:g.input,value:a,onChange:N=>i(N.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Client ID (optional)"}),e("input",{className:g.input,value:u,onChange:N=>p(N.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:g.input,value:h,onChange:N=>_(N.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:g.actions,children:[e(T,{onClick:O,disabled:y,children:"Save override"}),e(T,{variant:"secondary",onClick:U,disabled:y,children:"Use dango defaults"})]})]}),e($,{isOpen:R.show,onClose:()=>x(N=>({...N,show:!1})),width:"sm",children:[e($.Body,{children:e("p",{children:R.message})}),e($.Actions,{children:e(T,{onClick:()=>x(N=>({...N,show:!1})),children:"OK"})})]})]})},ut="_sectionCard_1pqo4_1",ht="_settingItem_1pqo4_26",gt="_settingRow_1pqo4_31",mt="_modalOverlay_1pqo4_38",pt="_modal_1pqo4_38",yt="_modalActions_1pqo4_73",ft="_modalSecondary_1pqo4_79",vt="_modalPrimary_1pqo4_89",z={sectionCard:ut,settingItem:ht,settingRow:gt,modalOverlay:mt,modal:pt,modalActions:yt,modalSecondary:ft,modalPrimary:vt},wt={anime:{heading:"Watchlist Preferences",blurb:"Customize your experience when managing your watchlist and series entries.",skipKey:"skipRemoveConfirmation",ignoreKey:"ignoreAdultContent",listOnlyKey:"cwWatchlistOnly",skipLabel:"Skip confirmation when removing from watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in watchlist",listNoun:"watchlist",continueNoun:"continue watching",adultCountUrl:"/api/continue-watching/adult-count",purgeUrl:"/api/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["allContinueWatching"]]},manga:{heading:"Reading List Preferences",blurb:"Customize your experience when managing your reading list and manga entries.",skipKey:"mangaSkipRemoveConfirmation",ignoreKey:"mangaIgnoreAdultContent",listOnlyKey:"mangaCwWatchlistOnly",skipLabel:"Skip confirmation when removing from reading list",ignoreLabel:"Hide adult content from continue reading",listOnlyLabel:"Only show continue reading for manga in reading list",listNoun:"reading list",continueNoun:"continue reading",adultCountUrl:"/api/manga/continue-reading/adult-count",purgeUrl:"/api/manga/continue-reading/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue reading`,invalidateKeys:[["manga-continue-reading"]]},tv:{heading:"TV Watchlist Preferences",blurb:"Customize your experience when managing your TV watchlist and series entries.",skipKey:"tvSkipRemoveConfirmation",ignoreKey:"tvIgnoreAdultContent",listOnlyKey:"tvCwWatchlistOnly",skipLabel:"Skip confirmation when removing from TV watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in TV watchlist",listNoun:"TV watchlist",continueNoun:"continue watching",adultCountUrl:"/api/tv/continue-watching/adult-count",purgeUrl:"/api/tv/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["tv-continue-watching"]]},asmr:{heading:"Listening List Preferences",blurb:"Customize your experience when managing your listening list and work entries.",skipKey:"asmrSkipRemoveConfirmation",ignoreKey:"asmrIgnoreAdultContent",listOnlyKey:"asmrCwWatchlistOnly",skipLabel:"Skip confirmation when removing from listening list",ignoreLabel:"Hide adult content from continue listening",listOnlyLabel:"Only show continue listening for works in listening list",listNoun:"listening list",continueNoun:"continue listening",adultCountUrl:"/api/asmr/continue-listening/adult-count",purgeUrl:"/api/asmr/continue-listening/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue listening`,invalidateKeys:[["asmr-continue-listening"]]}},bt=(t,r)=>{if(t==null)return r;const o=String(t);return o==="true"||o==="1"?!0:o==="false"||o==="0"?!1:r},ue=(t,r,o)=>{const[d,l]=s(r),[v,w]=s(!1),c=oe();return A(()=>{(async()=>{try{const u=await C.settings.getByKey.query({key:t});l(bt(u.value,r))}catch(u){console.error("Failed to fetch setting",u)}})()},[t,r]),{value:d,setValue:l,isUpdating:v,toggle:async()=>{if(v)return;w(!0);const i=!d;l(i);try{await C.settings.set.mutate({key:t,value:i});for(const u of o)c.invalidateQueries({queryKey:u})}catch(u){console.error("Error saving setting:",u),l(!i)}finally{w(!1)}}}},kt=()=>{const{contentType:t}=he(),r=wt[t],[o,d]=s(!1),[l,v]=s(!0),[w,c]=s(!1),a=ue(r.ignoreKey,!0,r.invalidateKeys),i=ue(r.listOnlyKey,!1,r.invalidateKeys),[u,p]=s(null),[h,_]=s(!1),y=oe(),k=Te();A(()=>{v(!0),(async()=>{try{const S=await C.settings.getByKey.query({key:r.skipKey});String(S.value)==="true"||String(S.value)==="1"?d(!0):d(!1)}catch(S){console.error("Failed to fetch setting",S)}finally{v(!1)}})()},[r.skipKey]);const R=async()=>{if(w)return;c(!0);const b=!o;d(b);try{await C.settings.set.mutate({key:r.skipKey,value:b})}catch(S){console.error("Error saving setting:",S),d(!b)}finally{c(!1)}},x=async()=>{if(!a.isUpdating){if(a.value)try{let b;if(t==="anime"?b=(await C.continueWatching.adultCount.query()).count:t==="manga"?b=(await C.mangaProgress.adultCount.query()).count:t==="asmr"?b=(await C.asmrProgress.adultCount.query()).count:b=(await C.tvProgress.adultCount.query()).count,typeof b=="number"&&b>0){p(b);return}}catch(b){console.error("Failed to fetch adult count",b)}a.toggle()}},L=()=>{p(null),a.toggle()},P=async()=>{if(!h){_(!0);try{let b;t==="anime"?b=(await C.continueWatching.purgeAdult.mutate()).removed:t==="manga"?b=(await C.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?b=(await C.asmrProgress.purgeAdult.mutate()).removed:b=(await C.tvProgress.purgeAdult.mutate()).removed,de.success(r.purgeDoneText(b??0));for(const S of r.invalidateKeys)y.invalidateQueries({queryKey:S});t==="anime"&&y.invalidateQueries(k.continueWatching.pathFilter()),t==="manga"&&y.invalidateQueries(k.mangaProgress.pathFilter()),t==="asmr"&&y.invalidateQueries(k.asmrProgress.pathFilter()),t==="tv"&&y.invalidateQueries(k.tvProgress.pathFilter())}catch(b){console.error("Failed to purge adult entries",b),de.error("Failed to remove adult entries")}finally{_(!1),p(null)}a.toggle()}};return l?e("div",{children:"Loading settings..."}):e("div",{className:z.sectionCard,children:[e("h3",{children:r.heading}),e("p",{children:r.blurb}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:r.skipLabel}),e(q,{isChecked:o,onChange:R,id:"skip-confirmation-toggle",disabled:w})]})}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:r.ignoreLabel}),e(q,{isChecked:a.value,onChange:x,id:"ignore-adult-toggle",disabled:a.isUpdating})]})}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:r.listOnlyLabel}),e(q,{isChecked:i.value,onChange:i.toggle,id:"cw-watchlist-only-toggle",disabled:i.isUpdating})]})}),u!==null&&e("div",{className:z.modalOverlay,onClick:()=>p(null),children:e("div",{className:z.modal,onClick:b=>b.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[u," adult ",u===1?"entry":"entries"," not in your"," ",r.listNoun," ",u===1?"is":"are"," currently hidden from"," ",r.continueNoun,". You can purge ",u===1?"it":"them"," from the database instead of showing ",u===1?"it":"them","."]}),e("div",{className:z.modalActions,children:[e("button",{type:"button",className:z.modalSecondary,onClick:L,disabled:h,children:"Show them"}),e("button",{type:"button",className:z.modalPrimary,onClick:P,disabled:h,children:h?"Purging...":`Purge ${u}`})]})]})})]})},Ct="_sectionCard_jkggs_1",St="_statsGrid_jkggs_26",_t="_statCard_jkggs_33",Nt="_statLabel_jkggs_43",Tt="_statValue_jkggs_51",It="_statMeta_jkggs_57",Rt="_statusBanner_jkggs_63",xt="_statusSuccess_jkggs_74",Lt="_statusUpdating_jkggs_80",Pt="_statusError_jkggs_86",Dt="_sha_jkggs_92",At="_settingItem_jkggs_99",Ot="_settingRow_jkggs_104",Gt="_settingTitle_jkggs_111",Mt="_settingSubtitle_jkggs_117",Ut="_actionsRow_jkggs_124",I={sectionCard:Ct,statsGrid:St,statCard:_t,statLabel:Nt,statValue:Tt,statMeta:It,statusBanner:Rt,statusSuccess:xt,statusUpdating:Lt,statusError:Pt,sha:Dt,settingItem:At,settingRow:Ot,settingTitle:Gt,settingSubtitle:Mt,actionsRow:Ut},Et=()=>{const[t,r]=s(null),[o,d]=s(!0),[l,v]=s(!1),[w,c]=s(!1),a=H(null),i=async()=>{try{const y=await C.settings.offlineDbInfo.query();return r(y),y}catch(y){console.error("Failed to fetch offline DB info:",y)}finally{d(!1)}return null};A(()=>(i(),()=>{a.current&&window.clearInterval(a.current)}),[]),A(()=>{t?.isRefreshing?a.current||(a.current=window.setInterval(async()=>{const y=await i();y&&!y.isRefreshing&&a.current&&(window.clearInterval(a.current),a.current=null)},2e3)):a.current&&(window.clearInterval(a.current),a.current=null)},[t?.isRefreshing]);const u=async()=>{if(!t||l)return;const y=!t.autoUpdateEnabled;v(!0),r({...t,autoUpdateEnabled:y});try{await C.settings.setOfflineDbAutoUpdate.mutate({enabled:y})}catch(k){console.error("Failed to update auto update setting:",k),r({...t,autoUpdateEnabled:!y})}finally{v(!1)}},p=async()=>{if(!(t?.isRefreshing||w)){c(!0);try{await C.settings.triggerOfflineDbUpdate.mutate(),r(y=>y?{...y,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(y){console.error("Failed to trigger offline DB update:",y)}finally{c(!1)}}},h=y=>{if(!y)return"Never";try{return new Date(y).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return y}},_=t?.isRefreshing||w;return e("div",{className:I.sectionCard,children:[e("h3",{children:"Offline Metadata Database"}),e("p",{children:"Local MAL to AniList ID map used for instant imports and metadata enrichment without hitting rate-limited APIs. Updates automatically every Saturday in the background."}),e("div",{className:I.statsGrid,children:[e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"MAL Mapped"}),e("span",{className:I.statValue,children:o?"—":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Release"}),e("span",{className:I.statMeta,children:o?"—":t?.releaseTag??"Never"})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Last Checked"}),e("span",{className:I.statMeta,children:o?"—":h(t?.lastCheckedAt??null)})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Last Updated"}),e("span",{className:I.statMeta,children:o?"—":h(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${I.statusBanner} ${t.lastStatus==="failed"?I.statusError:t.lastStatus==="updating"?I.statusUpdating:I.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:I.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:I.settingItem,children:e("div",{className:I.settingRow,children:[e("div",{children:[e("span",{className:I.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:I.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(q,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:u,disabled:o||l})]})}),e("div",{className:I.actionsRow,children:e(T,{onClick:p,disabled:o||_,children:_?"Updating Database...":"Update Offline Database Now"})})]})},zt="_sectionCard_1g4qx_1",$t="_dangerCard_1g4qx_26",Ft="_status_1g4qx_34",qt="_warningText_1g4qx_40",Kt="_ackLabel_1g4qx_44",Q={sectionCard:zt,dangerCard:$t,status:Ft,warningText:qt,ackLabel:Kt},jt=()=>{const t=oe(),[r,o]=s(!1),[d,l]=s(!1),[v,w]=s(!1),[c,a]=s(""),i=()=>{l(!1),a(""),o(!0)},u=()=>{v||(o(!1),l(!1))},p=async()=>{if(!(!d||v)){w(!0),a("");try{const h=await fetch("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),_=await h.json();if(!h.ok)throw new Error(_.error||"Failed to clear database");const y=_.deleted,k=_.deletedManga,R=_.deletedTv,x=_.deletedAsmr,L=Object.values(y).reduce((O,U)=>O+(U||0),0)+Object.values(k??{}).reduce((O,U)=>O+(U||0),0)+Object.values(R??{}).reduce((O,U)=>O+(U||0),0)+Object.values(x??{}).reduce((O,U)=>O+(U||0),0),P=(k?.manga_library??0)+(k?.manga_progress??0),b=(R?.tv_library??0)+(R?.tv_progress??0),S=(x?.asmr_library??0)+(x?.asmr_progress??0);a(`Library cleared — ${y.watchlist??0} watchlist entries, ${P} manga rows, ${b} TV rows, ${S} ASMR rows and ${L} total rows removed.`),t.invalidateQueries({queryKey:["watchlist"]}),t.invalidateQueries({queryKey:["allContinueWatching"]}),t.invalidateQueries({queryKey:["manga-library"]}),t.invalidateQueries({queryKey:["manga-continue-reading"]}),t.invalidateQueries({queryKey:["tv-library"]}),t.invalidateQueries({queryKey:["tv-continue-watching"]}),t.invalidateQueries({queryKey:["asmr-library"]}),t.invalidateQueries({queryKey:["asmr-continue-listening"]}),o(!1)}catch(h){a(h.message)}finally{w(!1),l(!1)}}};return e("div",{className:`${Q.sectionCard} ${Q.dangerCard}`,children:[e("h3",{children:"Danger Zone"}),e("p",{children:"Permanently delete your library (watchlist, watched episodes, queue, cached show metadata, manga reading list and reading progress, TV watchlist and watch progress, ASMR listening list and listening progress) to start fresh. Your settings, sync state and the offline metadata cache are preserved."}),e(T,{variant:"danger",onClick:i,children:"Clear Library Data"}),c&&e("p",{className:Q.status,children:c}),e($,{isOpen:r,onClose:u,title:"Clear library data?",width:"sm",children:[e($.Body,{children:[e("p",{className:Q.warningText,children:"This permanently deletes everything in your library. It acts on the active database (dev or prod, per server config) and cannot be undone. Settings, sync state and the offline metadata cache are kept."}),e("label",{className:Q.ackLabel,children:[e("input",{type:"checkbox",checked:d,onChange:h=>l(h.target.checked),disabled:v}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e($.Actions,{children:[e(T,{variant:"secondary",onClick:u,disabled:v,children:"Cancel"}),e(T,{variant:"danger",onClick:p,disabled:!d||v,children:v?"Clearing...":"Yes, delete everything"})]})]})]})},Ht=()=>{const[t,r]=s(""),[o,d]=s([]),[l,v]=s(null),[w,c]=s(!0),[a,i]=s({show:!1,message:"",type:"info"}),u=async()=>{try{c(!0);const _=await(await fetch("/api/auth/settings/rclone")).json();r(_.remote||""),d(_.availableRemotes||[]),v(_.activeRemote||null)}catch(h){console.error("Failed to fetch Rclone settings",h)}finally{c(!1)}};A(()=>{u()},[]);const p=async()=>{try{if((await fetch("/api/auth/settings/rclone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:t})})).ok)i({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),u();else throw new Error("Failed to save")}catch{i({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return w?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:g.sectionCard,children:[e("h3",{className:g.title,children:"Rclone Cloud Sync"}),e("p",{className:g.signIn,children:"Configure which Rclone remote to use for database synchronization."}),l?e("div",{className:g.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:l})]})}):e("p",{className:g.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Remote Name"}),e("div",{className:g.inputWrapper,children:e("select",{className:g.select,value:t,onChange:h=>r(h.target.value),children:[e("option",{value:"",children:"(Disabled / None)"}),o.map(h=>e("option",{value:h,children:h},h)),t&&!o.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:g.warning,style:{marginTop:"12px"},children:[e("strong",{children:"Note:"})," You can choose which provider is active using the selector at the top of the page."]})]}),e("div",{className:g.actions,children:e(T,{onClick:p,children:"Save Rclone Settings"})}),e($,{isOpen:a.show,onClose:()=>i(h=>({...h,show:!1})),width:"sm",children:[e($.Body,{children:e("p",{children:a.message})}),e($.Actions,{children:e(T,{onClick:()=>i(h=>({...h,show:!1})),children:"OK"})})]})]})},Wt=()=>{const[t,r]=s(null),[o,d]=s(!0),l=async()=>{try{const i=await(await fetch("/api/auth/settings/sync")).json();r(i)}catch(a){console.error("Failed to fetch sync settings",a)}finally{d(!1)}};A(()=>{l()},[]);const v=async a=>{const i=a.target.value;try{const u=await fetch("/api/auth/settings/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i})});if(u.ok){const p=await u.json();r(h=>h?{...h,activeProvider:p.activeProvider}:null),await l(),te.success(`Sync provider updated to ${i==="default"?"Default Order":i}`)}else te.error("Failed to update sync provider")}catch{te.error("Error updating sync provider")}};if(o||!t)return null;const w=[{value:"default",label:"Default (Priority Based)"}];t.authenticatedProviders.github&&w.push({value:"github",label:"GitHub"}),t.authenticatedProviders.google&&w.push({value:"google",label:"Google Drive"}),t.authenticatedProviders.rclone&&w.push({value:"rclone",label:"Rclone"}),w.push({value:"none",label:"None (Local Only)"});const c=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:m.sectionCard,children:[e("h3",{children:"Active Sync Provider"}),e("p",{children:'Choose which provider to use for synchronization. "Default" uses the first available provider you are logged into.'}),e("div",{style:{marginBottom:"1.5rem",padding:"0.75rem",background:"rgba(255, 255, 255, 0.03)",borderRadius:"var(--radius-md)",borderLeft:"4px solid var(--accent)",fontSize:"var(--font-size-sm)"},children:["Current Status:"," ",e("strong",{style:{color:"var(--accent-light)",textTransform:"capitalize"},children:c(t.actualActiveProvider)})]}),e("div",{className:m.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:t.activeProvider,onChange:v,style:{padding:"0.5rem",borderRadius:"var(--radius-md)",background:"rgba(255, 255, 255, 0.05)",color:"var(--text-primary)",border:"1px solid var(--glass-border)",fontSize:"var(--font-size-sm)",minWidth:"220px",outline:"none",cursor:"pointer"},children:w.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function Bt(){return"javascript:"+encodeURIComponent(`(function(){
|
|
2
2
|
if(!/(^|\\.)discord\\.com$/.test(location.hostname)){alert('Dango: use this bookmarklet while on discord.com');return}
|
|
3
3
|
var t=null;
|
|
4
4
|
try{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as _,A as v,h as E,T as R,u as e,g as A}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{u as L}from"./index-
|
|
1
|
+
import{d as _,A as v,h as E,T as R,u as e,g as A}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{u as L}from"./index-C93G341i.js";const x="_pagination_zelsc_1",M="_pageBtn_zelsc_7",S="_pageInfo_zelsc_38",G="_pagePicker_zelsc_48",F="_dropdown_zelsc_52",K="_flipDown_zelsc_68",T="_jumpRow_zelsc_73",W="_jumpInput_zelsc_79",q="_jumpGo_zelsc_90",J="_optionList_zelsc_105",O="_optionBtn_zelsc_113",H="_current_zelsc_132",s={pagination:x,pageBtn:M,pageInfo:S,pagePicker:G,dropdown:F,flipDown:K,jumpRow:T,jumpInput:W,jumpGo:q,optionList:J,optionBtn:O,current:H},cn=({page:t,totalPages:d,canGoNext:m,onChange:p,isLoading:f=!1,variant:g="compact"})=>{const[l,u]=_(!1),[b,h]=_(""),[k,N]=_(0),[$,z]=_(!1),w=v(null),y=v(null),j=v(null);E(()=>{if(!l)return;const n=o=>{w.current&&!w.current.contains(o.target)&&u(!1)},r=o=>{o.key==="Escape"&&u(!1)};return document.addEventListener("pointerdown",n),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",n),document.removeEventListener("keydown",r)}},[l]),E(()=>{if(!l)return;N(0),z(!1);const n=requestAnimationFrame(()=>{const r=j.current?.getBoundingClientRect(),o=y.current?.getBoundingClientRect();if(!r)return;let c=0;r.right>window.innerWidth-8?c=window.innerWidth-8-r.right:r.left<8&&(c=8-r.left),N(Math.round(c)),o&&o.top<r.height+24&&z(!0)});return()=>cancelAnimationFrame(n)},[l]);const i=d,C=R(()=>{if(i!==void 0){if(i<=100)return Array.from({length:i},(o,c)=>c+1);const r=new Set([1,i]);for(let o=t-10;o<=t+10;o++)o>=1&&o<=i&&r.add(o);return[...r].sort((o,c)=>o-c)}const n=m?t+1:t;return Array.from({length:n},(r,o)=>o+1)},[i,t,m]),B=n=>{const r=i!==void 0?Math.min(Math.max(1,n),i):Math.max(1,n);u(!1),h(""),r!==t&&p(r)},D=()=>{const n=parseInt(b,10);Number.isNaN(n)||B(n)},I=f||(i!==void 0?t>=i:!m);return e("div",{className:s.pagination,ref:w,children:[e("button",{className:s.pageBtn,onClick:()=>p(t-1),disabled:t<=1||f,"aria-label":"Previous page",children:[e(P,{name:"chevron-left",size:14}),g==="labeled"&&e("span",{children:"Previous"})]}),e("div",{className:s.pagePicker,ref:y,children:[e("button",{className:s.pageBtn,onClick:()=>{h(""),u(n=>!n)},disabled:f,"aria-label":"Jump to page","aria-expanded":l,children:e("span",{className:s.pageInfo,children:["Page ",e("strong",{children:t}),i!==void 0&&` of ${i}`]})}),l&&e("div",{ref:j,className:`${s.dropdown} ${$?s.flipDown:""}`,style:k!==0?{marginLeft:k}:void 0,children:[e("div",{className:s.jumpRow,children:[e("input",{className:s.jumpInput,type:"number",inputMode:"numeric",min:1,max:i,value:b,placeholder:"Page #",onChange:n=>h(n.currentTarget.value),onKeyDown:n=>{n.key==="Enter"&&D()}}),e("button",{className:s.jumpGo,onClick:D,children:"Go"})]}),e("div",{className:s.optionList,children:C.map(n=>e("button",{className:`${s.optionBtn} ${n===t?s.current:""}`,onClick:()=>B(n),disabled:n===t,children:n},n))})]})]}),e("button",{className:s.pageBtn,onClick:()=>p(t+1),disabled:I,"aria-label":"Next page",children:[g==="labeled"&&e("span",{children:"Next"}),e(P,{name:"chevron-right",size:14})]})]})},Q="_skeletonCard_1b0hr_1",U="_poster_1b0hr_11",V="_line_1b0hr_20",X="_info_1b0hr_38",Y="_short_1b0hr_54",Z="_horizontal_1b0hr_60",nn="_vertical_1b0hr_78",en="_lowEnd_1b0hr_97",a={skeletonCard:Q,poster:U,line:V,"skeleton-wave":"_skeleton-wave_1b0hr_1",info:X,short:Y,horizontal:Z,vertical:nn,lowEnd:en},tn=({layout:t="vertical"})=>{const{lowEndMode:d}=L();return e("div",{className:`${a.skeletonCard} ${a[t]} ${d?a.lowEnd:""}`,children:[e("div",{className:a.poster}),e("div",{className:a.info,children:[e("div",{className:a.line}),e("div",{className:`${a.line} ${a.short}`})]})]})},on=({count:t=14,layout:d="vertical"})=>e("div",{className:"grid-container",children:Array.from({length:t}).map((m,p)=>e(tn,{layout:d},p))}),ln=A.memo(on);export{tn as A,cn as P,ln as S};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as t,h as Re,g as Be,A as De,q as Fe,u as e,S as d}from"./vendor-core-DfaOB3Rn.js";import{u as qe,b as $e,a as I}from"./vendor-query-BBT5_sHx.js";import{z as i,t as h,W as nn,j as an,B as le}from"./index-
|
|
1
|
+
import{d as t,h as Re,g as Be,A as De,q as Fe,u as e,S as d}from"./vendor-core-DfaOB3Rn.js";import{u as qe,b as $e,a as I}from"./vendor-query-BBT5_sHx.js";import{z as i,t as h,W as nn,j as an,B as le}from"./index-C93G341i.js";import{I as l}from"./vendor-icons-DrybRNxP.js";function tn(){const K=qe(),[Y,k]=t(!1);return Re(()=>{const s=new URLSearchParams(window.location.search),b=s.get("anilist");if(b){const m=s.get("user"),_=s.get("reason");window.history.replaceState(null,"",window.location.pathname),b==="success"?(i.success(m?`Connected to AniList as ${decodeURIComponent(m)}`:"Connected to AniList"),K.invalidateQueries({queryKey:["trackerStatus"]})):i.error(_?decodeURIComponent(_):"AniList authentication failed");return}const j=new URLSearchParams(window.location.hash.substring(1)),y=j.get("access_token"),x=s.get("code");if(!y&&!x){const m=j.get("error");m&&(i.error(`AniList error: ${m}`),window.history.replaceState(null,"",window.location.pathname));return}const g=window.location.origin+window.location.pathname;window.history.replaceState(null,"",window.location.pathname),k(!0),i("Connecting to AniList..."),h.tracker.anilistAuth.mutate(y?{token:y}:{code:x,redirectUri:g}).then(async m=>{const _=m.user;i.success(`Connected to AniList as ${_?.name??"AniList user"}`),K.invalidateQueries({queryKey:["trackerStatus"]})}).catch(m=>{i.error(m instanceof Error?m.message:"Failed to authenticate with AniList")}).finally(()=>{k(!1)})},[K]),Y}const sn="_header_j1lbh_1",rn="_fadeIn_j1lbh_1",ln="_pageTitle_j1lbh_6",cn="_pageSubtitle_j1lbh_14",on="_importCard_j1lbh_20",dn="_slideUpIn_j1lbh_1",mn="_cardHeader_j1lbh_37",pn="_uploadArea_j1lbh_55",hn="_fileInputWrapper_j1lbh_59",un="_fileInput_j1lbh_59",gn="_fileDisplay_j1lbh_87",yn="_fileIcon_j1lbh_95",bn="_fileName_j1lbh_100",_n="_browseButton_j1lbh_109",fn="_optionsArea_j1lbh_120",Nn="_checkboxLabel_j1lbh_128",kn="_checkbox_j1lbh_128",vn="_checkboxCustom_j1lbh_141",wn="_optionText_j1lbh_169",In="_optionTitle_j1lbh_175",xn="_optionDesc_j1lbh_181",Mn="_actions_j1lbh_187",Cn="_importBtn_j1lbh_195",Ln="_cancelBtn_j1lbh_201",Sn="_statusMessage_j1lbh_215",Tn="_success_j1lbh_225",An="_error_j1lbh_231",jn="_progressSection_j1lbh_237",Pn="_progressBar_j1lbh_242",En="_progressFill_j1lbh_250",Bn="_progressInfo_j1lbh_257",Dn="_progressCount_j1lbh_264",Fn="_progressTitle_j1lbh_271",$n="_sourceBadge_j1lbh_289",Un="_anilist_j1lbh_301",Rn="_kitsu_j1lbh_307",qn="_offline_j1lbh_313",Kn="_skipped_j1lbh_319",On="_cardTitleRow_j1lbh_324",Qn="_anilistIcon_j1lbh_334",Gn="_malIcon_j1lbh_340",Hn="_badgeOnline_j1lbh_346",Wn="_badgeOffline_j1lbh_358",zn="_connectedProfile_j1lbh_370",Xn="_avatar_j1lbh_379",Jn="_connectedInfo_j1lbh_386",Yn="_connectedName_j1lbh_394",Vn="_connectedHint_j1lbh_400",Zn="_loginPrompt_j1lbh_405",ea="_loginSection_j1lbh_413",na="_fieldLabel_j1lbh_419",aa="_helpText_j1lbh_438",ta="_loginText_j1lbh_455",sa="_primaryBtn_j1lbh_464",ia="_secondaryBtn_j1lbh_465",ra="_syncBtn_j1lbh_466",la="_divider_j1lbh_518",ca="_actionSection_j1lbh_524",oa="_inputGroup_j1lbh_538",da="_input_j1lbh_538",ma="_syncSummary_j1lbh_559",pa="_syncErrors_j1lbh_565",ha="_spin_j1lbh_569",ua="_radioGroup_j1lbh_598",ga="_radioLabel_j1lbh_604",ya="_syncHint_j1lbh_642",ba="_importLoading_j1lbh_649",n={header:sn,fadeIn:rn,pageTitle:ln,pageSubtitle:cn,importCard:on,slideUpIn:dn,cardHeader:mn,uploadArea:pn,fileInputWrapper:hn,fileInput:un,fileDisplay:gn,fileIcon:yn,fileName:bn,browseButton:_n,optionsArea:fn,checkboxLabel:Nn,checkbox:kn,checkboxCustom:vn,optionText:wn,optionTitle:In,optionDesc:xn,actions:Mn,importBtn:Cn,cancelBtn:Ln,statusMessage:Sn,success:Tn,error:An,progressSection:jn,progressBar:Pn,progressFill:En,progressInfo:Bn,progressCount:Dn,progressTitle:Fn,sourceBadge:$n,anilist:Un,kitsu:Rn,offline:qn,skipped:Kn,cardTitleRow:On,anilistIcon:Qn,malIcon:Gn,badgeOnline:Hn,badgeOffline:Wn,connectedProfile:zn,avatar:Xn,connectedInfo:Jn,connectedName:Yn,connectedHint:Vn,loginPrompt:Zn,loginSection:ea,fieldLabel:na,helpText:aa,loginText:ta,primaryBtn:sa,secondaryBtn:ia,syncBtn:ra,divider:la,actionSection:ca,inputGroup:oa,input:da,syncSummary:ma,syncErrors:pa,spin:ha,radioGroup:ua,radioLabel:ga,syncHint:ya,importLoading:ba},ce="tracker_anilist_client_id",Ue="49887".trim(),va=()=>{const{setIsOpen:K}=nn(),{contentType:Y}=an(),k=Y==="manga",s=qe();Be.useEffect(()=>{document.title="Trackers - dango"},[]);const[b,j]=t(""),[y,x]=t("username"),[g,m]=t(null),[_,oe]=t(""),[M,de]=t(!1),Ke=tn(),{data:me,isLoading:pe}=$e({queryKey:["trackerStatus"],queryFn:async()=>await h.tracker.status.query()}),{data:C}=$e({queryKey:["anilistClientId"],queryFn:async()=>(await h.settings.getByKey.query({key:ce})).value||""}),he=De(!1);Be.useEffect(()=>{he.current||C!==void 0&&(C&&oe(C),he.current=!0)},[C]);const v=me?.anilist?.connected??!1;Re(()=>{v&&x("sync")},[v]);const O=me?.anilist?.user??null,V=!!Ue,Oe=(C||"").trim(),Qe=async()=>{const a=_.trim(),r=a||Ue;if(!r){i.error("Enter your AniList client ID first");return}const N=async(A,se)=>{await h.settings.set.mutate({key:A,value:se})};try{a?a!==C&&await N(ce,a):V&&Oe&&await N(ce,""),s.invalidateQueries({queryKey:["anilistClientId"]})}catch(A){i.error(A.message);return}const c=window.location.origin+window.location.pathname,U=encodeURIComponent(c);window.location.href=`https://anilist.co/api/v2/oauth/authorize?client_id=${encodeURIComponent(r)}&response_type=token&state=${U}`},ue=I({mutationFn:async()=>h.tracker.anilistDisconnect.mutate(),onSuccess:()=>{s.invalidateQueries({queryKey:["trackerStatus"]}),i.success("Disconnected from AniList")},onError:a=>i.error(a.message)}),Q=I({mutationFn:async()=>(await h.tracker.sync.mutate({provider:"anilist"})).summary,onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),m(a),i.success(`Sync complete — pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}`,{duration:6e3})},onError:a=>i.error(a.message)}),[P,ge]=t(""),[G,ye]=t("sync"),[Z,be]=t("two-way"),[o,Ge]=t(null),H=I({mutationFn:async()=>(await h.tracker.mangaSync.mutate({direction:Z})).summary,onSuccess:a=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),Ge(a);const r=(a.warnings?.length??0)>0?`, ${a.warnings.length} warning(s)`:"";i.success(`Manga sync complete — pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}${r}`,{duration:6e3})},onError:a=>i.error(a.message)}),L=I({mutationFn:async()=>{if(!P.trim())throw new Error("Please enter a username");return(await h.tracker.mangaImport.mutate({username:P.trim(),erase:M})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),i.success(`Imported ${a} manga entries from AniList`),ge("")},onError:a=>i.error(a.message)}),[E,_e]=t(""),[W,fe]=t("username"),[ee,Ne]=t(null),[z,ke]=t(!1),[ve,ne]=t(""),[we,He]=t(""),f=I({mutationFn:async()=>{if(!E.trim())throw new Error("Please enter a MAL username");const a=await h.tracker.mangaMalImport.mutate({username:E.trim(),erase:M});return{imported:a.imported??0,skipped:a.skipped??0}},onSuccess:({imported:a,skipped:r})=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),i.success(`Imported ${a} manga entries from MAL${r>0?`, skipped ${r}`:""}`),_e("")},onError:a=>i.error(a.message)}),We=Fe(async()=>{const a=document.getElementById("malMangaFile");if(!a.files||a.files.length===0){ne("Please select a file first.");return}ke(!0),ne(""),Ne(null);try{const r=new FormData;r.append("xmlfile",a.files[0]),r.append("erase",String(M));const N=await fetch("/api/import/mal-xml-manga",{method:"POST",body:r}),c=await N.json().catch(()=>({}));if(!N.ok)throw new Error(c.error||"Import failed");Ne({imported:c.imported??0,skipped:c.skipped??0}),s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]})}catch(r){ne(r.message)}finally{ke(!1)}},[M,s]),S=I({mutationFn:async()=>{if(!b.trim())throw new Error("Please enter a username");return(await h.tracker.anilistImport.mutate({username:b.trim(),erase:w})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),i.success(`Imported ${a} anime entries from AniList`),j("")},onError:a=>i.error(a.message)}),[B,Ie]=t(""),u=I({mutationFn:async a=>{if(!B.trim())throw new Error("Please enter a MAL username");return(await h.tracker.malImport.mutate({username:B.trim(),erase:a.erase,useOfflineDb:a.useOfflineDb,skipFallback:a.skipFallback})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),i.success(`Imported ${a} anime entries from MAL`),Ie("")},onError:a=>i.error(a.message)}),[w,xe]=t(!1),[D,ze]=t(!0),[F,Xe]=t(!1),[Me,Ce]=t(""),[T,Le]=t(!1),[p,Se]=t(null),[ae,Te]=t(null),[Ae,X]=t(""),te=De(null),Je=a=>{a.target.files&&a.target.files.length>0?Ce(a.target.files[0].name):Ce("")},Ye=Fe(async()=>{const a=document.getElementById("malFile");if(!a.files||a.files.length===0){X("Please select a file first.");return}const r=a.files[0];Le(!0),Se(null),Te(null),X("");const N=new AbortController;te.current=N;try{const c=new FormData;c.append("xmlfile",r),c.append("erase",String(w)),c.append("useOfflineDb",String(D)),c.append("skipFallback",String(F));const U=await fetch("/api/import/mal-xml",{method:"POST",body:c,signal:N.signal});if(!U.ok){const re=await U.text();let R="Failed to import";try{R=JSON.parse(re).error||R}catch{}throw new Error(R)}const A=U.body?.getReader();if(!A)throw new Error("No response stream");const se=new TextDecoder;let ie="",J="";for(;;){const{done:re,value:R}=await A.read();if(re)break;ie+=se.decode(R,{stream:!0});const Pe=ie.split(`
|
|
2
2
|
`);ie=Pe.pop()||"";for(const q of Pe)if(q.startsWith("event: "))J=q.slice(7).trim();else if(q.startsWith("data: ")){const en=q.slice(6);try{const Ee=JSON.parse(en);J==="progress"?Se(Ee):J==="complete"&&Te(Ee)}catch{}}else q===""&&(J="")}s.invalidateQueries({queryKey:["watchlist"]})}catch(c){c instanceof DOMException&&c.name==="AbortError"?X("Import cancelled."):X(c.message)}finally{Le(!1),te.current=null}},[w,D,F,s]),Ve=()=>{te.current?.abort(),h.settings.malImportCancel.mutate().catch(()=>{})},Ze=p?Math.round(p.current/p.total*100):0,[$,je]=t("username");return e("div",{className:"page-container",children:[e("div",{className:n.header,children:[e("h1",{className:n.pageTitle,children:"Trackers"}),e("p",{className:n.pageSubtitle,children:"Import & sync your anime watchlists and manga reading lists with tracking services"})]}),e("div",{style:{marginBottom:"16px",padding:"10px 14px",borderRadius:"8px",fontSize:"0.85rem",background:"color-mix(in srgb, var(--color-warning) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--color-warning) 25%, transparent)",color:"var(--text-secondary)"},children:"⚠ Syncing writes directly to your AniList entries, and dango may not always handle anime/manga lists correctly — always keep a backup of your lists before syncing."}),!k&&e(d,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"anilist",className:n.anilistIcon}),e("h3",{children:"AniList"}),pe?null:v?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),v&&O?e("div",{className:n.connectedProfile,children:[O.avatar&&e("img",{src:O.avatar,alt:"Avatar",className:n.avatar,loading:"lazy",decoding:"async"}),e("div",{className:n.connectedInfo,children:[e("span",{className:n.connectedName,children:O.name}),e("span",{className:n.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:n.secondaryBtn,onClick:()=>ue.mutate(),disabled:ue.isPending,children:[e(l,{name:"sign-out-alt"})," Disconnect"]})]}):e("div",{className:n.loginSection,children:[e("p",{className:n.loginText,children:["Log in with AniList to enable bidirectional progress & status synchronization.",Ke&&e("span",{style:{marginLeft:8,color:"var(--accent)"},children:"Finishing login…"})]}),e("div",{className:n.fieldLabel,children:["AniList client ID — defaults to Dango's app"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:["create your own app ",e(l,{name:"external-link-alt",size:9})]})]}),e("div",{className:n.inputGroup,children:[e("input",{type:"text",placeholder:"Client ID",value:_,onChange:a=>oe(a.target.value),className:n.input}),e("button",{className:n.primaryBtn,onClick:Qe,disabled:!(_.trim()||V),children:[e(l,{name:"external-link-alt"})," Connect"]})]}),e("p",{className:n.helpText,children:V?e(d,{children:["By default uses Dango's client. To use your own AniList app: create it at"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:"anilist.co/settings/developer"}),", set its ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:`${window.location.origin}/api/tracker/anilist/callback`}),", then paste only the ",e("strong",{children:"Client ID"})," above (leave empty to use Dango's)."]}):e(d,{children:["No shipped client in this build — create your own app at"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:"anilist.co/settings/developer"}),", set ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:`${window.location.origin}/api/tracker/anilist/callback`}),", then paste the ",e("strong",{children:"Client ID"})," above."]})})]}),v&&e(d,{children:[e("hr",{className:n.divider}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"username",checked:y==="username",onChange:()=>x("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"sync",checked:y==="sync",onChange:()=>x("sync")}),e("span",{children:"Two-way Sync"})]})]}),y==="username"?e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:b,onChange:a=>j(a.target.value),className:n.input,disabled:S.isPending,onKeyDown:a=>{a.key==="Enter"&&b.trim()&&S.mutate()}})}):e("p",{className:n.syncHint,children:"Merges progress non-destructively: pushes shows and episodes you watched on dango to AniList, and pulls anything you updated on AniList into dango."}),y==="username"&&e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:w,onChange:a=>xe(a.target.checked),className:n.checkbox,disabled:S.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Erase current watchlist"}),e("span",{className:n.optionDesc,children:"Delete existing watchlist before importing."})]})]})}),y==="username"?e("button",{className:n.syncBtn,onClick:()=>S.mutate(),disabled:!b.trim()||S.isPending,children:[e(l,{name:"download"}),S.isPending?"Importing...":"Start Import"]}):e(d,{children:[e("button",{className:n.syncBtn,onClick:()=>Q.mutate(),disabled:Q.isPending,children:[e(l,{name:"sync-alt",className:Q.isPending?n.spin:""}),Q.isPending?"Syncing...":"Start Sync"]}),g&&e("div",{className:n.syncSummary,children:["Pushed: ",g.pushed," · Pulled: ",g.pulled," · Merged:"," ",g.merged," · Unchanged: ",g.unchanged,g.errors.length>0&&e("span",{className:n.syncErrors,children:[" ","· ",g.errors.length," error",g.errors.length>1?"s":""]})]})]}),e("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"8px"},children:["AniList ",e("code",{children:"Rewatching (REPEATING)"})," is not tracked — entries with this status are ignored."]})]})]})}),k&&e(d,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"anilist",className:n.anilistIcon}),e("h3",{children:"AniList Manga"}),pe?null:v?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),v?e(d,{children:[e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"username",checked:G==="username",onChange:()=>ye("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"sync",checked:G==="sync",onChange:()=>ye("sync")}),e("span",{children:"Two-way Sync"})]})]}),G==="username"?e(d,{children:[e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:P,onChange:a=>ge(a.target.value),className:n.input,disabled:L.isPending,onKeyDown:a=>{a.key==="Enter"&&P.trim()&&L.mutate()}})}),e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:M,onChange:a=>de(a.target.checked),className:n.checkbox,disabled:L.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Replace AniList-linked manga"}),e("span",{className:n.optionDesc,children:"Clears previously imported (anilist:) entries before importing. Your provider bookmarks are never touched."})]})]})})]}):e(d,{children:[e("p",{className:n.syncHint,children:"Merges chapter progress non-destructively: pushes manga and chapters you read on dango to AniList, and pulls anything you updated on AniList into dango. Local titles are linked only on exact title matches, and bookmarks with no chapters read are never pushed."}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaDirection",value:"two-way",checked:Z==="two-way",onChange:()=>be("two-way")}),e("span",{children:"Two-way"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaDirection",value:"pull-only",checked:Z==="pull-only",onChange:()=>be("pull-only")}),e("span",{children:"Pull only (never writes to AniList)"})]})]})]}),G==="username"?e("button",{className:n.syncBtn,onClick:()=>L.mutate(),disabled:!P.trim()||L.isPending,children:[e(l,{name:"download"}),L.isPending?"Importing...":"Start Import"]}):e(d,{children:[e("button",{className:n.syncBtn,onClick:()=>H.mutate(),disabled:H.isPending,children:[e(l,{name:"sync-alt",className:H.isPending?n.spin:""}),H.isPending?"Syncing...":"Start Manga Sync"]}),o&&e(d,{children:[e("div",{className:n.syncSummary,children:["Pushed: ",o.pushed," · Pulled: ",o.pulled," · Merged: ",o.merged," · Unchanged:"," ",o.unchanged,(o.skipped??0)>0&&e("span",{children:[" · Skipped: ",o.skipped]}),o.errors.length>0&&e("span",{className:n.syncErrors,children:[" ","· ",o.errors.length," error",o.errors.length>1?"s":""]})]}),(o.warnings?.length??0)>0&&e("div",{className:n.syncErrors,style:{marginTop:"8px"},children:[(o.warnings??[]).slice(0,5).map((a,r)=>e("div",{children:["⚠ ",a]},r)),(o.warnings?.length??0)>5&&e("div",{children:["+",(o.warnings?.length??0)-5," more warning(s)"]})]})]})]}),e("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"8px"},children:["AniList ",e("code",{children:"Rereading (REPEATING)"})," is not tracked — entries with this status are ignored."]})]}):e("p",{className:n.loginText,children:"Connect your AniList account above to sync your manga reading list."})]})}),!k&&e(d,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"myanimelist",className:n.malIcon}),e("h3",{children:"MyAnimeList"})]})}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"username",checked:$==="username",onChange:()=>je("username")}),e("span",{children:"Username"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"xml",checked:$==="xml",onChange:()=>je("xml")}),e("span",{children:"XML File"})]})]}),$==="username"?e(d,{children:[e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:B,onChange:a=>Ie(a.target.value),className:n.input,disabled:u.isPending,onKeyDown:a=>{a.key==="Enter"&&B.trim()&&u.mutate({erase:w,useOfflineDb:D,skipFallback:F})}})}),u.isPending&&e("div",{className:n.importLoading,children:[e(l,{name:"sync-alt",className:n.spin}),e("span",{children:"Importing from MAL..."})]})]}):e("div",{className:n.uploadArea,children:e("div",{className:n.fileInputWrapper,children:[e("input",{type:"file",id:"malFile",accept:".xml,application/xml",className:n.fileInput,onChange:Je,disabled:T}),e("div",{className:n.fileDisplay,children:[e(l,{name:"file-alt",className:n.fileIcon}),e("span",{className:n.fileName,children:Me||"Choose XML file..."})]}),e("label",{htmlFor:"malFile",className:n.browseButton,children:"Browse"})]})}),e("div",{className:n.optionsArea,children:[e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:w,onChange:a=>xe(a.target.checked),className:n.checkbox,disabled:T||u.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Erase current watchlist"}),e("span",{className:n.optionDesc,children:"Delete existing watchlist before importing."})]})]}),e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:D,onChange:a=>ze(a.target.checked),className:n.checkbox,disabled:T||u.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Use offline database (fast)"}),e("span",{className:n.optionDesc,children:"Match by MAL ID locally first — instant and avoids AniList rate limits."})]})]}),e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:F,onChange:a=>Xe(a.target.checked),className:n.checkbox,disabled:T||u.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Skip online fallback"}),e("span",{className:n.optionDesc,children:"Only import offline matches. Unmatched titles are skipped without API calls."})]})]})]}),$==="username"?e("button",{className:n.syncBtn,onClick:()=>u.mutate({erase:w,useOfflineDb:D,skipFallback:F}),disabled:!B.trim()||u.isPending,children:[e(l,{name:"download"}),u.isPending?"Importing...":"Start Import"]}):e("div",{className:n.actions,children:T?e(le,{onClick:Ve,className:n.cancelBtn,children:"Cancel Import"}):e(le,{onClick:Ye,className:n.importBtn,disabled:!Me,children:[e(l,{name:"upload"})," Start Import"]})}),$==="username"&&u.isError&&e("div",{className:`${n.statusMessage} ${n.error}`,children:u.error.message}),T&&p&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressBar,children:e("div",{className:n.progressFill,style:{width:`${Ze}%`}})}),e("div",{className:n.progressInfo,children:[e("span",{className:n.progressCount,children:[p.current," / ",p.total]}),e("span",{className:n.progressTitle,children:p.found?e(d,{children:[p.matchedTitle,e("span",{className:`${n.sourceBadge} ${n[p.source||"anilist"]}`,children:p.source==="kitsu"?"Kitsu":p.source==="offline"?"Offline DB":"AniList"})]}):e("span",{className:n.skipped,children:["Skipped: ",p.title]})})]})]}),ae&&e("div",{className:`${n.statusMessage} ${n.success}`,children:["Import complete! Imported: ",ae.imported,", Skipped: ",ae.skipped,"."]}),Ae&&e("div",{className:`${n.statusMessage} ${n.error}`,children:Ae})]})}),k&&e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"myanimelist",className:n.malIcon}),e("h3",{children:"MyAnimeList Manga"})]})}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"username",checked:W==="username",onChange:()=>fe("username")}),e("span",{children:"Username"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"xml",checked:W==="xml",onChange:()=>fe("xml")}),e("span",{children:"XML File"})]})]}),W==="username"?e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:E,onChange:a=>_e(a.target.value),className:n.input,disabled:f.isPending,onKeyDown:a=>{a.key==="Enter"&&E.trim()&&f.mutate()}})}):e("div",{className:n.uploadArea,children:e("div",{className:n.fileInputWrapper,children:[e("input",{type:"file",id:"malMangaFile",accept:".xml,application/xml",className:n.fileInput,onChange:a=>He(a.target.files?.[0]?.name??""),disabled:z}),e("div",{className:n.fileDisplay,children:[e(l,{name:"file-alt",className:n.fileIcon}),e("span",{className:n.fileName,children:we||"Choose XML file..."})]}),e("label",{htmlFor:"malMangaFile",className:n.browseButton,children:"Browse"})]})}),e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:M,onChange:a=>de(a.target.checked),className:n.checkbox,disabled:f.isPending||z}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Replace AniList-linked manga"}),e("span",{className:n.optionDesc,children:"Clears previously imported (anilist:) entries before importing. Your provider bookmarks are never touched."})]})]})}),W==="username"?e("button",{className:n.syncBtn,onClick:()=>f.mutate(),disabled:!E.trim()||f.isPending,children:[e(l,{name:"download"}),f.isPending?"Importing...":"Start Import"]}):e("div",{className:n.actions,children:e(le,{onClick:We,className:n.importBtn,disabled:z||!we,children:[e(l,{name:"upload"})," ",z?"Importing...":"Start Import"]})}),f.isError&&e("div",{className:`${n.statusMessage} ${n.error}`,children:f.error.message}),ve&&e("div",{className:`${n.statusMessage} ${n.error}`,children:ve}),ee&&e("div",{className:`${n.statusMessage} ${n.success}`,children:["Import complete! Imported: ",ee.imported,", Skipped:"," ",ee.skipped,"."]}),e("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"8px"},children:"MAL manga is matched to AniList by MAL ID with a title fallback. Unmatched titles are skipped. Imports land as AniList-linked entries alongside your provider bookmarks."})]})]})};export{va as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{u as t,d as S,A,h as y,S as Me,g as Gr,o as Qr,p as Xr,a as Zr,T as Ee,q as T}from"./vendor-core-DfaOB3Rn.js";import{u as Jr}from"./vendor-query-BBT5_sHx.js";import{g as on,e as es,t as yt,z as ts,P as ns,M as Mn,B as Ue}from"./index-C93G341i.js";import{I as U}from"./vendor-icons-DrybRNxP.js";import{S as rs,U as ss,p as Dn,M as os,D as gr,m as On,k as as,C as is,a as ls,b as cs,c as rn,u as ds,d as us,e as ms,j as hs,f as fs,h as gs,l as ps,B as bs,i as Pn,F as vs,G as ys,H as mr,s as Rn,n as _s,o as Ss,q as Ts,r as Cs,t as Le,A as ks,v as Es,E as ws,y as Ns,P as xs,w as ue,z as Is,R as Bs}from"./AvSyncCalibrator-B2fQmjbo.js";import{S as As,O as $n,a as Ls,A as Ms,b as Ps}from"./OptionListMenu-D4ejupic.js";import{u as Rs}from"./useProviders-C3E0fPpP.js";import{d as $s,g as zs,h as Ds,f as Os,e as Fs,j as Vs,k as js}from"./useTvLibrary-DizEfaXg.js";import{l as Us,c as Ws}from"./hls-CEWF8efn.js";import{u as Hs}from"./useIsMobile-Dvx1uJ82.js";import{S as Ks}from"./SynopsisText-B3Sa5pRv.js";const qs="_fullscreenFlat_1d0oj_1",Ys="_timeDisplay_1d0oj_15",Gs="_bottomControls_1d0oj_19",Qs="_leftControls_1d0oj_23",Xs="_rightControls_1d0oj_24",Zs="_controlBtn_1d0oj_28",Js="_controlsOverlay_1d0oj_47",eo="_hidden_1d0oj_67",to="_topControls_1d0oj_73",no="_backBtn_1d0oj_93",ro="_videoTitleInfo_1d0oj_113",so="_animeTitle_1d0oj_119",oo="_episodeLabel_1d0oj_127",ao="_speedBoostBadge_1d0oj_134",io="_progressBarContainer_1d0oj_180",lo="_progressBar_1d0oj_180",co="_thumb_1d0oj_199",uo="_bufferedBar_1d0oj_217",mo="_watchedBar_1d0oj_227",ho="_scrubbing_1d0oj_252",fo="_timeBubble_1d0oj_256",go="_bottomControlsRow_1d0oj_270",po="_nextEpisodeBtn_1d0oj_293",bo="_active_1d0oj_355",vo="_settingsPanel_1d0oj_430",yo="_settingsHeader_1d0oj_449",_o="_settingsBackBtn_1d0oj_457",So="_settingsTitle_1d0oj_475",To="_settingsContent_1d0oj_486",Co="_currentValue_1d0oj_495",ko="_menuItem_1d0oj_510",Eo="_menuNote_1d0oj_543",wo="_loadingOverlay_1d0oj_556",No="_loadingDots_1d0oj_567",xo="_dot_1d0oj_572",Io="_bufferingOverlay_1d0oj_601",Bo="_bufferingSpinner_1d0oj_610",a={fullscreenFlat:qs,timeDisplay:Ys,bottomControls:Gs,leftControls:Qs,rightControls:Xs,controlBtn:Zs,controlsOverlay:Js,hidden:eo,topControls:to,backBtn:no,videoTitleInfo:ro,animeTitle:so,episodeLabel:oo,speedBoostBadge:ao,progressBarContainer:io,progressBar:lo,thumb:co,bufferedBar:uo,watchedBar:mo,scrubbing:ho,timeBubble:fo,bottomControlsRow:go,nextEpisodeBtn:po,active:bo,settingsPanel:vo,settingsHeader:yo,settingsBackBtn:_o,settingsTitle:So,settingsContent:To,currentValue:Co,menuItem:ko,menuNote:Eo,loadingOverlay:wo,loadingDots:No,dot:xo,bufferingOverlay:Io,bufferingSpinner:Bo},Ao=({player:o,visible:p,settingsOpen:W,onOpenSettings:O,onCloseSettings:G,hasSubtitles:P,isSubtitleActive:r,subtitles:I,onSubtitleChange:i,showNextEpisodeButton:te,onNextEpisode:Q,isTheaterMode:R,onTheaterModeToggle:h,timeLabelRef:K})=>{const{state:m,refs:We,actions:$}=o,X=We.videoRef,Pe=k=>{const ne=X.current;!ne||isNaN(m.duration)||m.duration===0||(ne.currentTime=k*m.duration)},Re=()=>{X.current&&($.setIsScrubbing(!0),$.wasPlayingBeforeScrub.current=!X.current.paused,X.current.pause())},He=k=>{const ne=X.current;ne&&m.duration&&(ne.currentTime=k*m.duration)},Ke=()=>{$.setIsScrubbing(!1),$.wasPlayingBeforeScrub.current&&X.current?.play().catch(()=>{})},Ze=k=>{const ne=X.current;ne&&(ne.volume=k,ne.muted=k===0)},ae=()=>{if(r){i(-1);return}let k=null;try{k=localStorage.getItem("tvLastSubtitle")}catch{}i(Dn(I,{lastKey:k,enabled:!0}))},q=m.isMuted?t(U,{name:"volume-mute"}):m.volume<.5?t(U,{name:"volume-down"}):t(U,{name:"volume-up"});return t("div",{className:`${a.controlsOverlay} ${p?"":a.hidden}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:a.bottomControls,onClick:k=>k.stopPropagation(),children:[t(rs,{classes:{container:a.progressBarContainer,scrubbing:a.scrubbing,timeBubble:a.timeBubble,bar:a.progressBar,buffered:a.bufferedBar,watched:a.watchedBar,thumb:a.thumb},videoRef:X,duration:m.duration,formatTime:on,isScrubbing:m.isScrubbing,buffered:"full",onSeek:Pe,onScrubStart:Re,onScrubMove:He,onScrubEnd:Ke,timeLabelRef:K}),t("div",{className:a.bottomControlsRow,children:[t("div",{className:a.leftControls,children:[t("button",{className:a.controlBtn,onClick:$.togglePlay,"aria-label":m.isPlaying?"Pause":"Play",children:m.isPlaying?t(U,{name:"pause"}):t(U,{name:"play"})}),t(ss,{muted:m.isMuted,volume:m.volume,volumeIcon:q,buttonClassName:a.controlBtn,onToggleMute:$.toggleMute,onVolumeChange:Ze,onExpandedChange:k=>$.setShowVolumeSlider(k)}),t("span",{className:a.timeDisplay,ref:K,children:[on(0)," / ",on(m.duration)]})]}),t("div",{className:a.rightControls,children:[te&&t("button",{className:a.nextEpisodeBtn,onClick:Q,title:"Play next episode",children:"Next EP"}),P&&t("button",{className:`${a.controlBtn} ${r?a.active:""}`,onClick:ae,"aria-label":r?"Turn subtitles off":"Turn subtitles on",children:t(U,{name:"closed-captioning"})}),t("button",{className:`${a.controlBtn} ${W?a.active:""}`,onClick:()=>W?G():O(),"aria-label":"Settings",children:t(U,{name:"cog"})}),t("button",{className:`${a.controlBtn} ${R?a.active:""}`,onClick:k=>{k.stopPropagation(),h()},title:R?"Exit Theater Mode":"Theater Mode","aria-label":R?"Exit Theater Mode":"Theater Mode",children:t(U,{name:"tv"})}),t("button",{className:a.controlBtn,onClick:$.toggleFullscreen,"aria-label":m.isFullscreen?"Exit Fullscreen":"Fullscreen",children:m.isFullscreen?t(U,{name:"compress"}):t(U,{name:"expand"})})]})]})]})})},sn=-6e4,zn=6e4,hr=500,Lo=({classes:o,delayMs:p,onDelayChange:W})=>{const[O,G]=S(null),P=O??p,r=A(W);r.current=W;const I=A(p);I.current=p;const i=A(null);i.current=O,y(()=>{G(null)},[p]),y(()=>()=>{const R=i.current;R!==null&&R!==I.current&&r.current(R)},[]);const te=R=>{I.current=R,i.current=null,r.current(R),G(null)},Q=R=>{const h=i.current??I.current,K=Math.max(sn,Math.min(zn,h+R));te(K)};return t(Me,{children:[t("div",{style:{display:"flex",gap:6,padding:"0.5rem 0.75rem 0.25rem"},children:[t("button",{type:"button",className:o.item,onClick:()=>Q(-hr),"aria-label":"Show subtitles 0.5 seconds earlier",style:{flex:1,justifyContent:"center"},children:t("span",{children:"-0.5s"})}),t("button",{type:"button",className:o.item,onClick:()=>Q(hr),"aria-label":"Show subtitles 0.5 seconds later",style:{flex:1,justifyContent:"center"},children:t("span",{children:"+0.5s"})}),t("button",{type:"button",className:o.item,onClick:()=>te(0),disabled:P===0,"aria-label":"Reset subtitle timing",style:{flex:1,justifyContent:"center"},children:t("span",{children:"Reset"})})]}),t(os,{label:"Subtitle timing",display:gr(P),min:sn,max:zn,step:100,value:P,percent:(P-sn)/(zn-sn)*100,onChange:R=>{const h=Math.round(R);i.current=h,G(h)},onCommit:()=>{const R=i.current;R!==null&&te(R)}}),t("div",{className:o.note,children:"Positive delays subtitles (show later). Negative shows them earlier. 0.0s is default."})]})},Mo=({view:o,onSelectView:p,onClose:W,player:O,onSubtitleStyleChange:G,streams:P,resolutionIdx:r,onResolutionChange:I,hasSubtitles:i,subtitles:te,selectedSubtitle:Q,isSubtitleActive:R,onSubtitleChange:h,audioTracks:K,selectedAudioTrack:m,onAudioTrackChange:We,videoDelayEnabled:$,onVideoDelayToggle:X,videoDelayMs:Pe,onVideoDelayChange:Re,onCalibrate:He,subtitleDelayMs:Ke,onSubtitleDelayChange:Ze,ambientSettings:ae,onAmbientChange:q})=>{const{state:k}=O,ne=()=>t(Me,{children:[P.length>1&&t("button",{className:a.menuItem,onClick:()=>p("resolution"),children:[t("span",{children:"Resolution"}),t("span",{className:a.currentValue,children:P[r]?.quality||"Auto"})]}),i&&t("button",{className:a.menuItem,onClick:()=>p("subtitles"),children:[t("span",{children:"Subtitles"}),t("span",{className:a.currentValue,children:R?te[Q]?.label||te[Q]?.language:"Off"})]}),i&&t("button",{className:a.menuItem,onClick:()=>p("subtitle-style"),children:[t("span",{children:"Subtitle Style"}),t("span",{className:a.currentValue,children:[k.subtitleFontSize.toFixed(1),"x · ",k.subtitlePosition]})]}),i&&t("button",{className:a.menuItem,onClick:()=>p("subtitle-timing"),children:[t("span",{children:"Subtitle Timing"}),t("span",{className:a.currentValue,children:gr(Ke)})]}),K.length>0&&t("button",{className:a.menuItem,onClick:()=>p("audio"),children:[t("span",{children:"Audio Track"}),t("span",{className:a.currentValue,children:K[m]?.label||K[m]?.language})]}),t("button",{className:a.menuItem,onClick:()=>p("av-sync"),children:[t("span",{children:"A/V Sync"}),t("span",{className:a.currentValue,children:$?`${Pe}ms`:"Off"})]}),ae&&q&&t("button",{className:a.menuItem,onClick:()=>p("ambient"),children:[t("span",{children:"Ambient Light"}),t("span",{className:a.currentValue,children:ae.enabled?"On":"Off"})]})]}),Se=()=>t($n,{classes:{item:a.menuItem,active:a.active},options:P.map((w,H)=>({key:String(H),label:w.quality,selected:H===r})),onSelect:w=>I(Number(w))}),Y=()=>t($n,{classes:{item:a.menuItem,active:a.active},options:[{key:"off",label:"Off",selected:!R},...te.map((w,H)=>({key:String(H),label:w.label||w.language,selected:H===Q}))],onSelect:w=>h(w==="off"?-1:Number(w))}),Te=()=>t(Ls,{classes:{item:a.menuItem,active:a.active},values:{fontSize:k.subtitleFontSize,position:k.subtitlePosition,bgOpacity:k.subtitleBgOpacity,bgColor:k.subtitleBgColor,textColor:k.subtitleTextColor,edge:k.subtitleEdge,bold:k.subtitleBold},onChange:G}),L=()=>t(Lo,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},delayMs:Ke,onDelayChange:w=>Ze?.(w)}),$e=()=>t($n,{classes:{item:a.menuItem,active:a.active},options:K.map((w,H)=>({key:String(H),label:w.label||w.language,selected:H===m})),onSelect:w=>We(Number(w))}),qe=()=>t(Ms,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},enabled:$,delayMs:Pe,onToggle:w=>X?.(w),onDelayChange:w=>Re?.(w),onCalibrate:He}),be=()=>ae&&q?t(Ps,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},values:ae,onChange:q}):null;return t("div",{"data-speed-boost-ignore":"true",onClick:w=>w.stopPropagation(),children:t(As,{classes:{panel:a.settingsPanel,header:a.settingsHeader,backBtn:a.settingsBackBtn,title:a.settingsTitle,content:a.settingsContent},title:o==="main"?"Settings":o==="subtitle-style"?"Subtitle Style":o==="subtitle-timing"?"Subtitle Timing":o==="audio"?"Audio Track":o==="resolution"?"Resolution":o==="av-sync"?"A/V Sync":o==="ambient"?"Ambient Light":o.charAt(0).toUpperCase()+o.slice(1),onBack:()=>o==="main"?W():p("main"),children:[o==="main"&&ne(),o==="resolution"&&Se(),o==="subtitles"&&Y(),o==="subtitle-style"&&Te(),o==="subtitle-timing"&&L(),o==="audio"&&$e(),o==="av-sync"&&qe(),o==="ambient"&&be()]})})},Po=({player:o,title:p,episodeLabel:W,audioTracks:O,selectedAudioTrack:G,onAudioTrackChange:P,subtitles:r,selectedSubtitle:I,onSubtitleChange:i,streams:te,resolutionIdx:Q,onResolutionChange:R,onBack:h,children:K,videoDelayEnabled:m=!1,onVideoDelayToggle:We,videoDelayMs:$=0,onVideoDelayChange:X,onCalibrateAvSync:Pe,subtitleDelayMs:Re=0,onSubtitleDelayChange:He,showNextEpisodeButton:Ke=!1,onNextEpisode:Ze,isLoading:ae=!1,isTheaterMode:q,onTheaterModeToggle:k,ambientSettings:ne,onAmbientChange:Se})=>{const{state:Y,refs:Te,actions:L}=o,$e=Te.videoRef,{subtitleFontSize:qe,subtitlePosition:be,subtitleBgOpacity:w,subtitleBgColor:H,subtitleTextColor:at,subtitleEdge:ie,subtitleBold:ze}=Y,[we,De]=S(null),it=A(null),[Ot,_t]=S(0);y(()=>{const le=$e.current;if(!le)return;const u=()=>_t(le.clientHeight||0);u();const dt=new ResizeObserver(u);return dt.observe(le),()=>dt.disconnect()},[$e]);const me=(le,u)=>{try{localStorage.setItem(le,String(u))}catch{}},ve=(le,u)=>{switch(le){case"fontSize":typeof u=="number"&&(L.setSubtitleFontSize(u),me("subtitleFontSize",u));break;case"position":typeof u=="number"&&(L.setSubtitlePosition(u),me("subtitlePosition",u));break;case"bgOpacity":typeof u=="number"&&(L.setSubtitleBgOpacity(u),me("subtitleBgOpacity",u));break;case"bgColor":typeof u=="string"&&(L.setSubtitleBgColor(u),me("subtitleBgColor",u));break;case"textColor":typeof u=="string"&&(L.setSubtitleTextColor(u),me("subtitleTextColor",u));break;case"edge":(u==="shadow"||u==="outline"||u==="none")&&(L.setSubtitleEdge(u),me("subtitleEdge",u));break;case"bold":typeof u=="boolean"&&(L.setSubtitleBold(u),me("subtitleBold",u));break}};y(()=>{const le="tv-player-subtitle-style";let u=document.getElementById(le);u||(u=document.createElement("style"),u.id=le,document.head.appendChild(u));const dt={fontSize:qe,position:be,bgOpacity:w,bgColor:H,textColor:at,edge:ie,bold:ze},Z=$e.current,kt=On(qe,Ot||Z?.clientHeight||720);if(u.textContent=as({...dt,fontSize:kt}),Z){const Et=()=>{const B=Number(be);return isNaN(B)?0:Math.max(0,Math.min(100,B))},ut=(B,J)=>{try{const de=B;de.snapToLines=!1,de.line=J}catch{}},wt=()=>{const B=kt*16,J=Z.videoHeight||Z.clientHeight||720,de=Z.videoWidth||Z.clientWidth||1280;return{step:B*1.3/J*100,chars:Math.max(20,Math.floor(de/(B*.55)))}},b=B=>{const J=Math.max(0,Math.min(100,100-Et())),de=Array.from(B.activeCues??[]);if(de.length<=1){de.forEach(Fe=>ut(Fe,J));return}const{step:It,chars:ln}=wt();let Ce=J;for(let Fe=de.length-1;Fe>=0;Fe--){const cn=String(de[Fe].text??"").replace(/<[^>]*>/g,"").split(`
|
|
2
|
+
`).reduce((dn,mt)=>dn+Math.max(1,Math.ceil(mt.length/ln)),0),jt=Ce-cn*It;ut(de[Fe],Math.max(0,jt)),Ce=jt-It*.4}},l=()=>{const B=Math.max(0,Math.min(100,100-Et()));Array.from(Z.textTracks).forEach(J=>{J.cues&&(Array.from(J.cues).forEach(de=>ut(de,B)),J.mode==="showing"&&b(J))})};l();const re=B=>{const J=B.target;J.mode==="showing"&&b(J)},ce=()=>{Array.from(Z.textTracks).forEach(B=>{B.removeEventListener("cuechange",re),B.addEventListener("cuechange",re)}),l()};Array.from(Z.textTracks).forEach(B=>{B.addEventListener("cuechange",re)}),Z.textTracks.addEventListener("addtrack",ce);const Nt=Array.from(Z.querySelectorAll("track")),xt=()=>l();return Nt.forEach(B=>B.addEventListener("load",xt)),()=>{Array.from(Z.textTracks).forEach(B=>{B.removeEventListener("cuechange",re)}),Z.textTracks.removeEventListener("addtrack",ce),Nt.forEach(B=>B.removeEventListener("load",xt))}}},[qe,be,w,H,at,ie,ze,I,r,$e,Ot]);const St=r.length>0,lt=I>=0,M=()=>{De("main"),L.setShowControls(!0)},ct=()=>{De(null)},Tt=Y.showControls||!!we,Oe=t(cs,{visible:Tt,title:p,episode:W,onBack:h,classes:{overlay:a.controlsOverlay,hidden:a.hidden,top:a.topControls,backBtn:a.backBtn,titleInfo:a.videoTitleInfo,title:a.animeTitle,episode:a.episodeLabel}}),Ft=!ae&&!Y.isBuffering&&Y.duration>0?t(is,{isPlaying:Y.isPlaying,onTogglePlay:L.togglePlay,onSkipBack:()=>L.seek(-10),onSkipForward:()=>L.seek(10)}):null,an=t(Ao,{player:o,visible:Tt,settingsOpen:!!we,onOpenSettings:M,onCloseSettings:ct,hasSubtitles:St,isSubtitleActive:lt,subtitles:r,onSubtitleChange:i,showNextEpisodeButton:Ke,onNextEpisode:Ze,isTheaterMode:q,onTheaterModeToggle:k,timeLabelRef:it}),Ct=we?t(Mo,{view:we,onSelectView:De,onClose:ct,player:o,onSubtitleStyleChange:ve,streams:te,resolutionIdx:Q,onResolutionChange:R,hasSubtitles:St,subtitles:r,selectedSubtitle:I,isSubtitleActive:lt,onSubtitleChange:i,audioTracks:O,selectedAudioTrack:G,onAudioTrackChange:P,videoDelayEnabled:m,onVideoDelayToggle:We,videoDelayMs:$,onVideoDelayChange:X,onCalibrate:()=>{De(null),Pe?.()},subtitleDelayMs:Re,onSubtitleDelayChange:He,ambientSettings:ne,onAmbientChange:Se}):null,Vt=t(Me,{children:[ae&&t("div",{className:a.loadingOverlay,"aria-hidden":"true",children:t("div",{className:a.loadingDots,children:[t("div",{className:a.dot}),t("div",{className:a.dot}),t("div",{className:a.dot})]})}),Y.isBuffering&&!ae&&t("div",{className:a.bufferingOverlay,"aria-hidden":"true",children:t("div",{className:a.bufferingSpinner})}),Y.isSpeedBoostActive&&t("div",{className:a.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(U,{name:"forward",size:12})]})]});return t(ls,{player:o,topBar:Oe,centerControls:Ft,bottomBar:!ae&&Y.duration>0?an:null,settingsPanel:Ct,overlays:Vt,isInteracting:!!we,className:Y.isFullscreen?a.fullscreenFlat:"",children:K})},Ro=({servers:o,selectedServer:p,onServerSelect:W})=>o.length===0?null:t("div",{className:rn.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:rn.sourceButtons,children:o.map(O=>t("button",{className:`${rn.sourceButton} ${p===O?rn.active:""}`,onClick:()=>W(O),children:O},O))})]}),$o=Gr.memo(Ro);function zo(o,p,W){const O=()=>{const P=Array.isArray(o.audioTracks)?o.audioTracks.length:0,r=W.getWant(),I=P>0?Math.min(Math.max(0,r),P-1):r;o.audioTrack=I,I!==r&&W.onResolve(I)},G=(P,r)=>{const I=W.getWant(),i=Array.isArray(o.audioTracks)?o.audioTracks.length:0;if(r.id!==I&&I>=0&&I<i){o.audioTrack!==I&&(o.audioTrack=I);return}W.onResolve(r.id)};return o.on(p.MANIFEST_PARSED,O),o.on(p.AUDIO_TRACK_SWITCHED,G),()=>{o.off(p.MANIFEST_PARSED,O),o.off(p.AUDIO_TRACK_SWITCHED,G)}}const Do=/\b(SmartTV|SMART-TV|Tizen|Web0S|webOS|NetCast|HbbTV|AppleTV|CrKey|BRAVIA|AFT[A-Za-z]|Fire\s?TV|GoogleTV|Roku|VIDAA|DTV|PlayStation|Xbox|Opera TV|POV_TV)\b/i;function Oo(){try{if(Do.test(navigator.userAgent||""))return!0;const o=navigator.deviceMemory;if(typeof o=="number"&&o>0&&o<2)return!0}catch{}return!1}const Fo="_page_f7wlz_1",Vo="_header_f7wlz_7",jo="_pageTitle_f7wlz_11",Uo="_searchForm_f7wlz_21",Wo="_searchInput_f7wlz_27",Ho="_searchBtn_f7wlz_42",Ko="_suggestions_f7wlz_58",qo="_suggestionPill_f7wlz_65",Yo="_statusMsg_f7wlz_81",Go="_error_f7wlz_87",Qo="_textOnly_f7wlz_91",Xo="_spinner_f7wlz_96",Zo="_spin_f7wlz_96",Jo="_sourceLoader_f7wlz_101",ea="_ringSpinner_f7wlz_107",ta="_grid_f7wlz_125",na="_skeletonCard_f7wlz_131",ra="_skeletonThumb_f7wlz_136",sa="_skeletonLine_f7wlz_142",oa="_shimmer_f7wlz_149",aa="_backBtn_f7wlz_169",ia="_meta_f7wlz_187",la="_headerActions_f7wlz_195",ca="_watchlistBtn_f7wlz_202",da="_active_f7wlz_220",ua="_year_f7wlz_230",ma="_rating_f7wlz_235",ha="_typeBadge_f7wlz_244",fa="_tv_f7wlz_252",ga="_movie_f7wlz_257",pa="_tvSeries_f7wlz_262",ba="_tvMiniSeries_f7wlz_267",va="_overview_f7wlz_272",ya="_controls_f7wlz_279",_a="_controlLabel_f7wlz_287",Sa="_select_f7wlz_297",Ta="_playerSection_f7wlz_309",Ca="_video_f7wlz_313",ka="_videoHidden_f7wlz_335",Ea="_delayCanvas_f7wlz_340",wa="_delayCanvasActive_f7wlz_353",Na="_subtitleOverlay_f7wlz_357",xa="_videoIframe_f7wlz_376",Ia="_retryButton_f7wlz_384",Ba="_sidebarSeason_f7wlz_399",Aa="_mobileSeasonRow_f7wlz_415",La="_providerSelectWrap_f7wlz_429",Ma="_genreRow_f7wlz_441",Pa="_genreChip_f7wlz_448",Ra="_metaRow_f7wlz_458",$a="_detailGrid_f7wlz_467",za="_detailItem_f7wlz_475",Da="_imdbLink_f7wlz_497",v={page:Fo,header:Vo,pageTitle:jo,searchForm:Uo,searchInput:Wo,searchBtn:Ho,suggestions:Ko,suggestionPill:qo,statusMsg:Yo,error:Go,textOnly:Qo,spinner:Xo,spin:Zo,sourceLoader:Jo,ringSpinner:ea,grid:ta,skeletonCard:na,skeletonThumb:ra,skeletonLine:sa,shimmer:oa,backBtn:aa,meta:ia,headerActions:la,watchlistBtn:ca,active:da,year:ua,rating:ma,typeBadge:ha,tv:fa,movie:ga,tvSeries:pa,tvMiniSeries:ba,overview:va,controls:ya,controlLabel:_a,select:Sa,playerSection:Ta,video:Ca,videoHidden:ka,delayCanvas:Ea,delayCanvasActive:wa,subtitleOverlay:Na,videoIframe:xa,retryButton:Ia,sidebarSeason:Ba,mobileSeasonRow:Aa,providerSelectWrap:La,genreRow:Ma,genreChip:Pa,metaRow:Ra,detailGrid:$a,detailItem:za,imdbLink:Da},Oa=[],Fa=[];function fr({error:o,onRetry:p}){return t("div",{className:`${v.statusMsg} ${v.error}`,style:{flexDirection:"column",alignItems:"stretch",gap:8},children:t("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t("span",{style:{flex:1},children:o}),t("button",{className:v.retryButton,onClick:p,children:"Retry"})]})})}const Ja=()=>{const{id:o}=Qr(),[p]=Xr(),W=A(p);W.current=p;const O=Zr(),G=Jr(),P=p.get("type"),[r,I]=S(null),[i,te]=S(()=>parseInt(p.get("s")||"1",10)||1),[Q,R]=S([]),[h,K]=S(()=>parseInt(p.get("e")||"1",10)||1),[m,We]=S(()=>{try{return localStorage.getItem("tvProvider")||""}catch{return""}}),[$,X]=S([]),[Pe,Re]=S(""),{options:He,isFallback:Ke,isLoading:Ze}=Rs(),ae=Ee(()=>He.filter(e=>(e.kind??"tv")==="tv").map(e=>({id:e.value,label:e.label,tier:e.tier==="embed"?"embed":"direct",servers:e.servers})),[He]),q=Ke||ae.length===0?Oa:ae,k=q.filter(e=>e.tier==="direct"),ne=q.filter(e=>e.tier==="embed"),[Se,Y]=S(!1),[Te,L]=S(""),[$e,qe]=S([]),[be,w]=S(0),[H,at]=S([]),[ie,ze]=S(-1),[we,De]=S(0),[it,Ot]=S(""),[_t,me]=S(""),[ve,St]=S(()=>{try{return localStorage.getItem("tvServer")||""}catch{return""}}),lt=Ee(()=>q.find(e=>e.id===m),[q,m]),M=lt?.tier==="embed",[ct,Tt]=S([]),[Oe,Ft]=S(""),[an,Ct]=S(""),[Vt,le]=S(!1),u=Ee(()=>ct.length>0?ct:lt?.servers??[],[ct,lt]),dt=Ee(()=>Oe?["Embed",...u]:u,[u,Oe]),Z=Vt&&!!Oe,kt=Z?an||Oe:"";y(()=>{if(!Oe){Ct("");return}let e=!1;return fetch(`/api/resolve?url=${encodeURIComponent(Oe)}`).then(n=>n.json()).then(n=>{!e&&n.finalUrl&&Ct(n.finalUrl)}).catch(()=>{}),()=>{e=!0}},[Oe]);const Et=A([]);y(()=>{Et.current=$},[$]);const ut=A(be);y(()=>{ut.current=be},[be]);const wt=A(ie);y(()=>{wt.current=ie},[ie]);const b=ds({skipIntervals:Fa}),l=b.refs.videoRef,re=A(null),ce=A([]),Nt=A(null),xt=A(null),{videoDelayMs:B,videoDelayEnabled:J,setDelayEnabled:de,handleVideoDelayChange:It,isCalibrating:ln,testClipActive:Ce,stopCalibration:Fe,openAvSyncCalibrator:Fn,cancelAvSyncCalibrator:cn,applyAvSyncCalibrator:jt,toggleTestClip:dn,calibReturnRef:mt,effectiveVideoDelayMs:un}=us(l),[ht,pr]=S(()=>{try{const e=Number(localStorage.getItem("tvSubtitleDelayMs"));if(Number.isFinite(e)&&e>=-6e4&&e<=6e4)return Math.round(e)}catch{}return 0}),mn=A(ht);mn.current=ht;const br=T(e=>{const n=Math.max(-6e4,Math.min(6e4,Math.round(e)));if(mn.current!==n){mn.current=n,pr(n);try{localStorage.setItem("tvSubtitleDelayMs",String(n))}catch{}}},[]);ms({videoRef:l,canvasRef:Nt,delayMs:un,enabled:J});const hn=J,ye=hn||ht!==0,{settings:fn,update:vr}=hs(),gn=A(ye);gn.current=ye;const pn=T(()=>{if(!gn.current)return;const e=l.current;e&&Array.from(e.textTracks).forEach(n=>{n.mode!=="hidden"&&(n.mode="hidden")})},[l]),{hasConsent:Bt,grant:yr}=es(),At=A("");At.current||(At.current=`tv-${Date.now()}-${Math.random().toString(36).slice(2)}`);const f=P==="movie",Ut=o?$s(P||"tv",o):"",F=Ut,Vn=zs(),Wt=Ds(),{toggle:jn,bookmarkedIds:_r,pending:Sr}=Os(),{data:Un}=Fs(r?Ut:void 0),Ht=Un?!!Un.inLibrary:Ut?_r.has(Ut):!1,Tr=T(()=>{!r||!o||jn({tmdbId:Number(o),mediaType:P||"tv",title:r.title,poster:r.poster,year:r.year,adult:r.adult})},[r,o,P,jn]),{data:Je,isFetched:Wn,isPending:Hn}=Vs(F||void 0,i,h),Kt=Ee(()=>Q.map(e=>e.episode_number).sort((e,n)=>e-n),[Q]),et=Kt.indexOf(h),bn=et>0?Kt[et-1]:null,x=et>=0&&et<Kt.length-1?Kt[et+1]:null,qt=Ee(()=>(r?.seasons??[]).map(e=>e.season_number).filter(e=>Number.isFinite(e)).sort((e,n)=>e-n),[r]),_e=Ee(()=>{if(f||x!=null)return null;const e=qt.indexOf(i);return e>=0&&e<qt.length-1?qt[e+1]:(r?.number_of_seasons??0)>i?i+1:null},[f,x,qt,i,r?.number_of_seasons]),Kn=Je?.currentTime??0,qn=Je?.duration??0,vn=Je?.completed===!0||Je?.completed===1||Pn(Kn,qn),[Ne,Ve]=S(!1),xe=A(!1),yn=A(null),Lt=A(null);y(()=>{xe.current=!1,Lt.current=null,Ve(!1)},[F,i,h]);const[Ie,Yt]=S(!1),[ft,Yn]=S(0),[tt,Gn]=S(!1),[Ye,nt]=S(!1),[Cr,_n]=S(!1),[kr,Qn]=S(""),[Gt,Er]=S(!1),[wr,Sn]=S(!1),{isTheaterMode:je,toggleTheaterMode:Tn,handleLayoutClick:Nr}=fs();y(()=>{const e=n=>{n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="t"&&Tn()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[Tn]),gs(b,($.length>0||_t!=="")&&!je&&!Ie&&!Ne&&!Ye);const xr=Hs(),[gt,Ir]=S(ps),Br=T(e=>{Ir(e),bs(e)},[]),he=A(!1),rt=A(null),Cn=A(0),Xn=A(!1),Zn=A(0),ee=A(null),Mt=A(""),Ar=mr(Kn,qn),Pt=!he.current&&!xe.current&&(Ie||Ne||Ye||vn||Ar),pt=A(Pt);pt.current=Pt;const bt=A(!1);y(()=>{bt.current=tt},[tt]);const Ge=T((e,n)=>{if(!F||!n||n<30)return;const s=Pn(e,n),d=s?n:e;Math.abs(d-Cn.current)<10&&!s||(Cn.current=d,Vn.mutate({mediaId:F,season:i,episode:h,currentTime:Math.floor(d),duration:Math.floor(n),completed:s,title:r?.title??null,poster:r?.poster??null,backdrop:r?.backdrop??null,year:r?.year??null,overview:r?.overview??null,tmdbId:r?.id??null,mediaType:P||"tv",adult:r?.adult?1:0}))},[F,i,h,Vn,r,P]),Be=T((e,n)=>{Fe();const s=new URLSearchParams(p);s.set("type",p.get("type")||"tv"),s.set("s",String(e)),s.set("e",String(n)),O(`${window.location.pathname}?${s.toString()}`)},[p,O,Fe]),Rt=T(()=>{const e=l.current;if(!e||f||x==null){_n(!1);return}const n=e.duration||0,s=e.currentTime||0;_n(n>0&&s/n>=.8)},[f,x,l]),Qt=T((e,n)=>["tv-sources",m,f?"movie":"tv",o,e,n,ve],[m,f,o,ve]),Xt=T(async(e,n)=>{if(!r||!o||!m)return{valid:!1,sources:[]};const s=f?"movie":"tv",d=await yt.tv.sources.query({provider:m,type:s,tmdbId:String(o),season:e,episode:n,title:r.title||"",year:r.year||"",totalSeasons:String(r.number_of_seasons||1),imdbId:r.imdb_id||"",...u.length>0&&ve?{server:ve}:{}});return{valid:"valid"in d?d.valid:!1,error:"error"in d?d.error:void 0,sources:d.sources,referer:"referer"in d?d.referer:void 0,audioTracks:d.audioTracks,subtitles:"subtitles"in d?d.subtitles:void 0,servers:"servers"in d?d.servers:void 0,embedUrl:"embedUrl"in d?d.embedUrl:void 0}},[r,o,m,f,u,ve]),Jn=T(()=>{if(f||!r||!o||!m||M||x==null)return;const e=Qt(i,x);G.getQueryState(e)?.status!=="success"&&G.prefetchQuery({queryKey:e,queryFn:()=>Xt(i,x),staleTime:300*1e3,gcTime:1800*1e3})},[f,r,o,m,M,x,i,G,Qt,Xt]),Lr=T(()=>{if(Ce)return;Rt();const e=l.current;!e||e.paused||e.ended||(e.duration>0&&e.duration-e.currentTime<=60&&Jn(),rt.current&&clearTimeout(rt.current),rt.current=setTimeout(()=>{Ge(e.currentTime,e.duration||0)},5e3))},[Ge,l,Ce,Rt,Jn]),Mr=T(()=>{const e=l.current;if(!e||!r)return;rt.current&&clearTimeout(rt.current),Ge(e.currentTime,e.duration||0),Xn.current=!0;const n=vs({seekInduced:Date.now()-Zn.current<ys,autoplayEnabled:gt,hasNext:!f&&x!=null,isFinal:f||x==null});n==="advance"&&x!=null?(K(x),Be(i,x)):n==="prompt-next"?(xe.current=!1,he.current=!0,Ve(!0)):n==="prompt-complete"&&(Qn(f?r.title:`${r.title} — Season ${i}`),nt(!0),xe.current=!0,he.current=!0)},[f,r,i,x,gt,Ge,Be,l]),Pr=T(()=>{Xn.current=!1,b.actions.onPlay()},[b.actions]),Rr=T(()=>{b.actions.onPause();const e=l.current;e&&!e.ended&&Ge(e.currentTime,e.duration||0)},[b.actions,Ge,l]),$r=T(()=>{b.actions.onLoadedMetadata();const e=l.current;if(e){try{const n=parseFloat(localStorage.getItem("playerVolume")||"");isNaN(n)||(e.volume=Math.max(0,Math.min(1,n))),e.muted=localStorage.getItem("playerMuted")==="true"}catch{}if(ee.current!=null&&ee.current>0){try{e.currentTime=ee.current}catch{}ee.current=null}Rt()}},[b.actions,l,Rt]),kn=T(()=>{const e=l.current;if(e&&ee.current!=null&&ee.current>0){try{e.currentTime=ee.current}catch{}ee.current=null}},[l]),zr=T(()=>{ft>0&&(ee.current=ft);const e=l.current;if(e&&ft>0){try{e.currentTime=ft,ee.current=null}catch{}e.play().catch(()=>{})}Yt(!1),he.current=!0},[ft,l]),er=T(()=>{ee.current=null;const e=l.current;e&&(e.currentTime=0,e.play().catch(()=>{})),Yt(!1),he.current=!0},[l]),Dr=T(()=>{xe.current=!0,Ve(!1),he.current=!0},[]),Or=T(()=>{xe.current=!0,Ve(!1),he.current=!0,ee.current=null;const e=l.current;if(e){try{e.currentTime=0}catch{}e.play().catch(()=>{})}},[l]),tr=T(()=>{x!=null&&(xe.current=!0,Ve(!1),he.current=!0,K(x),Be(i,x))},[x,i,Be]),nr=T(()=>{_e!=null&&(xe.current=!0,Ve(!1),nt(!1),he.current=!0,te(_e),K(1),Be(_e,1))},[_e,Be]),Fr=T(async()=>{if(F)try{await Wt.mutateAsync({id:F,status:"Completed"}),nt(!1),Ve(!1),O("/")}catch{}},[F,Wt,O]);y(()=>{he.current=!1,yn.current=null,Yt(!1),_n(!1),Yn(0),Gn(!1),bt.current=!1,ee.current=null,Mt.current=`${F}:${i}:${h}`,Cn.current=0},[F,i,h]),y(()=>{Wn&&(Gn(!0),bt.current=!0)},[Wn,F,i,h]),y(()=>{if(!Je||he.current)return;const e=`${F}:${i}:${h}`;if(yn.current===e)return;yn.current=e;const n=Je,s=n.currentTime??0,d=n.duration??0;mr(s,d)&&(Yn(s),Yt(!0))},[Je,F,i,h]),y(()=>{if(!tt||he.current||xe.current||Ie||Ye||Ne)return;const e=`${F}:${i}:${h}`;if(Lt.current!==e){if(!vn){Hn||(Lt.current=e);return}if(f){Lt.current=e,Ve(!0);return}if(!(!r||et<0||Q.length===0)){if(Lt.current=e,x==null&&_e==null){r&&Q.length>0&&(Qn(`${r.title} — Season ${i}`),nt(!0),xe.current=!0,he.current=!0);return}Ve(!0)}}},[tt,vn,Hn,Ie,Ye,Ne,f,x,_e,r,et,Q.length,F,i,h]),y(()=>{(Ie||Ne)&&l.current&&l.current.pause()},[Ie,Ne,l]),y(()=>{const e=l.current;return()=>{rt.current&&clearTimeout(rt.current),e&&!e.ended&&Ge(e.currentTime,e.duration||0)}},[Ge,l]);const En=T(e=>{let n=null,s=!0;try{n=localStorage.getItem("tvLastSubtitle"),s=localStorage.getItem("tvSubtitlesEnabled")!=="false"}catch{}return Dn(e,{lastKey:n,enabled:s})},[]),wn=T(e=>{if(!(e<0))try{localStorage.setItem("tvSubtitlesEnabled","true"),localStorage.setItem("tvSelectedSubtitle",String(e))}catch{}},[]),rr=T(e=>{if(e.length===0)return 0;let n=null;try{n=localStorage.getItem("tvLastAudio")}catch{}if(n){const s=e.findIndex(g=>Rn(g)===n);if(s>=0)return s;const d=n.indexOf("|||"),c=d>=0?n.slice(0,d):n,N=d>=0?n.slice(d+3):n,z=e.findIndex(g=>g.language===c||g.label===N);if(z>=0)return z}return Dn(e,{lastKey:null,enabled:!0})},[]),{data:sr}=js(F||void 0),or=Ee(()=>(sr?.progress??[]).filter(n=>n.season===i&&(n.completed===!0||n.completed===1||Pn(n.currentTime,n.duration))).map(n=>String(n.episode)),[sr,i]),ar=Ee(()=>Q.map(e=>({id:String(e.episode_number),label:`Episode ${e.episode_number}`,sublabel:e.name||void 0,thumbnail:e.still_path?`https://image.tmdb.org/t/p/w185${e.still_path}`:void 0})),[Q]),ir=Ee(()=>(r?.genres??[]).map(e=>e.name).slice(0,5),[r]),Nn=Ee(()=>[r?.year,r?.status,r?.number_of_seasons?`${r.number_of_seasons} Season${r.number_of_seasons>1?"s":""}`:null,r?.number_of_episodes?`${r.number_of_episodes} Episodes`:null].filter(Boolean),[r]);y(()=>{if(q.length!==0&&!q.some(e=>e.id===m)){const e=q.find(n=>n.tier==="direct")?.id??q[0].id;We(e);try{localStorage.setItem("tvProvider",e)}catch{}}},[q,m]),y(()=>{Tt([]),Ft(""),Ct(""),le(!1)},[m]),y(()=>{if(u.length!==0&&!u.includes(ve)){St(u[0]);try{localStorage.setItem("tvServer",u[0])}catch{}}},[u,ve]),y(()=>{if(!o){I(null),X([]),Re(""),L(""),me("");return}const e=Number(o),n=P||"tv";I(null),X([]),Re(""),L(""),me("");const s=parseInt(W.current.get("s")||"",10),d=parseInt(W.current.get("e")||"",10);te(isNaN(s)?1:s),K(isNaN(d)?1:d),De(0),yt.tv.details.query({type:n,id:String(e)}).then(c=>{const N={id:c.id,title:c.title||"",overview:c.overview||"",vote_average:c.vote_average,year:c.year,poster:c.poster,backdrop:c.backdrop,imdb_id:c.imdb_id||void 0,adult:c.adult,seasons:c.seasons,number_of_seasons:c.number_of_seasons};I(N),N.seasons&&N.seasons.length>0&&isNaN(s)&&te(N.seasons[0].season_number)}).catch(()=>{})},[o,P]),y(()=>{if(!r||!o)return;if(!(r.seasons!==void 0||r.number_of_seasons!==void 0)){R([]);return}const n=parseInt(p.get("e")||"",10);yt.tv.episodes.query({id:String(o),season:String(i)}).then(s=>{const d=(s.episodes||[]).map(c=>({episode_number:c.episode_number,name:c.name||"",vote_average:c.vote_average,overview:c.overview||"",still_path:c.still_path||""}));R(d),d.length!==0&&K(c=>!isNaN(n)&&d.some(N=>N.episode_number===n)?n:d.some(N=>N.episode_number===c)?c:d[0].episode_number)}).catch(()=>{})},[r,o,i,p]),y(()=>{if(!M||!r||!o)return;fetch(`/api/tv/embed/${m}/${f?"movie":"tv"}/${o}?season=${i}&episode=${h}`).then(n=>n.json()).then(n=>{if(n.url)return me(n.url),fetch(`/api/resolve?url=${encodeURIComponent(n.url)}`).then(s=>s.json()).then(s=>{s.finalUrl&&me(s.finalUrl)})}).catch(()=>{})},[m,r,o,i,h,f,M]);const Zt=T(async()=>{if(!r||!o||!m||M||r.adult&&!Bt)return;const e=`${F}:${i}:${h}`;Y(!0),L(""),Et.current.length===0&&(X([]),De(0),qe([]),at([]));try{const n=await G.fetchQuery({queryKey:Qt(i,h),queryFn:()=>Xt(i,h),staleTime:3e5,gcTime:18e5});if(Mt.current!==e){Y(!1);return}if(Y(!1),!n.valid||!n.sources?.length){L(n.error?`${n.error}`:u.length>0?`No streams from ${ve}. Try another server.`:"No streams available.");return}X(n.sources),Re(e),n.servers?.length&&Tt(n.servers),n.embedUrl&&Ft(n.embedUrl),De(0),n.referer&&Ot(n.referer);const s=n.audioTracks||[];qe(s),w(s.length>0?rr(s):0);const d=n.subtitles||[];if(at(d),d.length>0){const z=En(d);ze(z),wn(z)}else ze(-1);const c=f?"movie":"tv",N=o;yt.tv.subtitles.query({type:c,tmdbId:String(N),season:String(i),episode:String(h)}).then(z=>{if(Mt.current!==e)return;const g=Array.isArray(z.subtitles)?z.subtitles:[];g.length!==0&&at(se=>{const fe=[...se,...g.filter(_=>!se.some(ge=>ge.url===_.url))];if(se.length===0){const _=En(fe);ze(_),wn(_)}return fe})}).catch(()=>{}),L("")}catch{if(Mt.current!==e)return;Y(!1),L("Failed to load streams.")}},[r,o,m,i,h,f,M,Bt,u,ve,En,wn,rr,F,G,Qt,Xt]),xn=T(()=>{const e=l.current;e&&!isNaN(e.currentTime)&&(ee.current=e.currentTime)},[l]),Vr=T(e=>{if(e==="Embed"){le(!0);return}xn(),le(!1),St(e);try{localStorage.setItem("tvServer",e)}catch{}L("")},[xn]),jr=T(e=>{We(e);try{localStorage.setItem("tvProvider",e)}catch{}},[]);y(()=>{m&&r&&!M&&Zt()},[m,r,Zt,M]),y(()=>{if(!l.current)return;if(re.current&&(re.current.destroy(),re.current=null),M||Z){const g=l.current;g&&(g.pause(),g.removeAttribute("src"),g.load());return}let e=!1;if(Ce){const g=l.current;return g&&(g.pause(),g.removeAttribute("src"),g.load(),g.src="/av-sync-test.mp4",pt.current||g.play().catch(()=>{})),()=>{e=!0}}if(mt.current!=null&&(ee.current=mt.current,mt.current=null),Mt.current===`${F}:${i}:${h}`&&ee.current==null&&!pt.current)try{const g=l.current;g&&!g.ended&&g.currentTime>1&&(ee.current=g.currentTime)}catch{}const s=ee.current??0,d=!Se&&Pe===`${F}:${i}:${h}`?Z?"":$[we]?.url||"":"";if(!d){try{l.current?.pause(),l.current?.removeAttribute("src"),l.current?.load()}catch{}return}const c=l.current;c.pause(),c.removeAttribute("src"),c.load(),b.actions.resetMediaState();const N=`/api/tv/stream-proxy?url=${encodeURIComponent(d)}&referer=${encodeURIComponent(it)}`;$[we]?.type==="hls"?(async()=>{const g=await Us();if(!e)if(g&&g.isSupported()){const se=Oo()||document.body.classList.contains("low-end"),fe=se?60:180,_=new g({enableWorker:!0,lowLatencyMode:!1,startPosition:s>0?s:-1,maxBufferLength:fe,maxMaxBufferLength:fe+(se?30:60),backBufferLength:se?30:60,maxBufferSize:(se?120:360)*1e3*1e3,fragLoadPolicy:{default:{maxTimeToFirstByteMs:15e3,maxLoadTimeMs:45e3,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:3,retryDelayMs:800,maxRetryDelayMs:6e3}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:25e3,timeoutRetry:{maxNumRetry:1,retryDelayMs:500,maxRetryDelayMs:2e3},errorRetry:{maxNumRetry:2,retryDelayMs:800,maxRetryDelayMs:4e3}}}});re.current=_,_.on(g.Events.ERROR,(D,E)=>{E.fatal&&(L(`Stream failed (${E.details}). Try another source or reload.`),Y(!1),_.destroy(),re.current=null)}),_.loadSource(N),_.attachMedia(c);const ge=()=>{let D=!1,E=0;try{D=localStorage.getItem("tvSubtitlesEnabled")==="true";const C=parseInt(localStorage.getItem("tvSelectedSubtitle")||"0",10);!isNaN(C)&&C>=0&&(E=C)}catch{}return{enabled:D,index:E}},V=()=>{if(typeof _.subtitleTrack!="number")return;if(ce.current.length>0){_.subtitleTrack=-1;return}const D=Array.isArray(_.subtitleTracks)?_.subtitleTracks:[];if(D.length===0){_.subtitleTrack=-1;return}const E=ge();if(E.enabled){const C=E.index<D.length?E.index:0;_.subtitleTrack=C,ze(C),pn()}else _.subtitleTrack=-1};zo(_,g.Events,{getWant:()=>ut.current,onResolve:D=>w(D)}),_.on(g.Events.MANIFEST_PARSED,()=>{V(),(s>0||!pt.current&&bt.current)&&c.play().catch(()=>b.actions.setShowControls(!0))}),_.on(g.Events.SUBTITLE_TRACKS_UPDATED,()=>{V()}),_.on(g.Events.SUBTITLE_TRACK_SWITCH,(D,E)=>{if(ce.current.length>0){if(E.id!==-1)try{_.subtitleTrack=-1}catch{}return}const C=Array.isArray(_.subtitleTracks)?_.subtitleTracks:[];if(C.length!==0){if(E.id===-1){const ke=ge();if(ke.enabled){const oe=ke.index<C.length?ke.index:0;_.subtitleTrack=oe;return}}ze(E.id),pn()}})}else Ws(c)&&(c.src=N,(s>0||!pt.current&&bt.current)&&c.play().catch(()=>{L("Failed to play stream. Try another source.")}))})():(c.src=N,(s>0||!pt.current&&bt.current)&&c.play().catch(()=>{L("Failed to play stream. Try another source.")}));const z=()=>{const fe=c.error?.code===4?"Video source not supported or not found":"Failed to load video stream";L(`${fe}. The source may be invalid or expired. Try switching source or reloading.`),Y(!1)};return c.addEventListener("error",z),()=>{e=!0,c.removeEventListener("error",z)}},[$,Pe,Se,we,m,it,M,Z,l,mt,Ce,F,i,h,kn,pn,b.actions]),y(()=>{if(!tt||Ie||Ne||Ye||Pt||M||Ce)return;const e=l.current;!e||!e.paused||e.ended||e.readyState<1||(kn(),e.play().catch(()=>{}))},[tt,Ie,Ne,Ye,Pt,M,Ce,kn,l]),y(()=>{const e=re.current;!e||typeof e.audioTrack!="number"||(e.audioTrack=be)},[be]),y(()=>{const e=re.current;!e||typeof e.subtitleTrack!="number"||!Array.isArray(e.subtitleTracks)||e.subtitleTracks.length===0||ce.current.length>0||(ie>=0?e.subtitleTrack=ie:e.subtitleTrack=-1)},[ie]),y(()=>{const e=l.current;if(!(!e||M)&&(e.querySelectorAll("track").forEach(n=>n.remove()),ce.current=[],H.length!==0&&(H.forEach(n=>{const s=document.createElement("track");s.kind="subtitles",s.label=n.label||n.language||"Unknown",s.srclang=n.language||n.label||"en";const d=`/api/subtitle-proxy?url=${encodeURIComponent(n.url)}&referer=${encodeURIComponent(it)}`;s.src=d,s.addEventListener("load",()=>{const c=ce.current.indexOf(s),N=s.track;if(N&&c>=0){const z=c===wt.current;N.mode=z&&!gn.current?"showing":"hidden"}}),e.appendChild(s),ce.current.push(s)}),H.length>0)))try{const n=re.current;n&&typeof n.subtitleTrack=="number"&&n.subtitleTrack!==-1&&(n.subtitleTrack=-1)}catch{}},[H,it,M,m,l]),y(()=>{const e=l.current;if(!e||M)return;const n=re.current;ce.current.length>0&&n&&typeof n.subtitleTrack=="number"&&Array.isArray(n.subtitleTracks)&&n.subtitleTracks.length>0&&(n.subtitleTrack=-1);const s=()=>{const N=On(b.state.subtitleFontSize,e.clientHeight||720),z=Math.max(0,Math.min(100,100-b.state.subtitlePosition)),g=()=>{const V=N*16,D=e.videoHeight||e.clientHeight||720,E=e.videoWidth||e.clientWidth||1280;return{step:V*1.3/D*100,chars:Math.max(20,Math.floor(E/(V*.55)))}},se=(V,D)=>{const E=V;E.snapToLines=!1,E.line=D},fe=V=>{if(!V.cues)return;Array.from(V.cues).forEach(oe=>se(oe,z));const D=Array.from(V.activeCues??[]);if(D.length<=1){D.forEach(oe=>se(oe,z));return}const{step:E,chars:C}=g();let ke=z;for(let oe=D.length-1;oe>=0;oe--){const Qe=String(D[oe].text??"").replace(/<[^>]*>/g,"").split(`
|
|
3
|
+
`).reduce((tn,zt)=>tn+Math.max(1,Math.ceil(zt.length/C)),0);ke=Math.max(0,ke-Qe*E),se(D[oe],ke),ke-=E*.4}},_=ce.current;if(_.length>0){_.forEach((V,D)=>{const E=V.track;if(!E)return;const C=D===ie;E.mode=C&&!ye?"showing":"hidden",C&&!ye&&fe(E)});return}const ge=Array.from(e.textTracks);ge.length!==0&&ge.forEach((V,D)=>{const E=D===ie;V.mode=E&&!ye?"showing":"hidden",E&&!ye&&fe(V)})};s();const d=()=>s();e.textTracks.addEventListener("addtrack",d),e.addEventListener("loadedmetadata",s,{once:!0});const c=window.setTimeout(s,600);return()=>{e.textTracks.removeEventListener("addtrack",d),e.removeEventListener("loadedmetadata",s),window.clearTimeout(c)}},[ie,H,M,m,l,ye,b.state.subtitleFontSize,b.state.subtitlePosition]),y(()=>{if(!ye)return;const e=l.current,n=xt.current;if(!e||!n)return;const s=ht/1e3,d=un/1e3,c=new Set;let N=[],z=-1,g=-1,se=-1,fe=-1,_=0,ge=0,V=!1;const D=()=>{const j=wt.current;if(j<0)return null;const Xe=ce.current;return Xe.length>0?Xe[j]?.track??null:Array.from(e.textTracks)[j]??null},E=(j,Xe)=>{const pe=j.cues;if(!pe||pe.length===0)return Array.from(j.activeCues??[]);let st=0,ot=pe.length;for(;st<ot;){const Ae=st+ot>>>1;pe[Ae].endTime+s<Xe?st=Ae+1:ot=Ae}const Dt=[];for(let Ae=st;Ae<pe.length;Ae++){const nn=pe[Ae];if(nn.startTime+s>Xe)break;nn.endTime+s>=Xe&&Dt.push(nn)}return Dt},C=()=>{const j=D(),Xe=e.currentTime-d,pe=j?E(j,Xe):[],st=e.clientWidth,ot=e.clientHeight,Dt=e.videoWidth,Ae=e.videoHeight;if(pe.length===N.length&&pe.every((Bn,An)=>Bn===N[An])&&st===z&&ot===g&&Dt===se&&Ae===fe||(N=pe,z=st,g=ot,se=Dt,fe=Ae,n.textContent="",pe.length===0))return;const dr={fontSize:On(b.state.subtitleFontSize,ot),position:b.state.subtitlePosition,bgOpacity:b.state.subtitleBgOpacity,bgColor:b.state.subtitleBgColor,textColor:b.state.subtitleTextColor,edge:b.state.subtitleEdge,bold:b.state.subtitleBold},Kr=_s(dr),qr=Ss(e,dr.position);pe.forEach((Bn,An)=>{const ur=String(Bn.text??"");if(!Ts(ur).trim())return;const Ln=document.createElement("div"),Yr=(pe.length-1-An)*1.7;Ln.style.cssText=`${Kr}
|
|
4
|
+
bottom: calc(${qr}px + ${Yr}em);`,Ln.innerHTML=Cs(ur),n.appendChild(Ln)})},ke=()=>{Array.from(e.textTracks).forEach(j=>{c.has(j)||(c.add(j),j.addEventListener("cuechange",C))})},oe=()=>{ke(),C()},In=()=>{if(V||ge)return;const j=()=>{ge=0,!(V||e.paused||e.ended)&&(C(),In())};ge=window.requestAnimationFrame(j)},Qe=e,tn=()=>{_=0,C(),!V&&Qe.requestVideoFrameCallback&&(_=Qe.requestVideoFrameCallback(tn))},zt=()=>{C(),Qe.requestVideoFrameCallback?_||(_=Qe.requestVideoFrameCallback(tn)):In()};ke(),e.textTracks.addEventListener("addtrack",oe),e.textTracks.addEventListener("removetrack",oe),e.addEventListener("timeupdate",C),e.addEventListener("seeked",C),e.addEventListener("loadedmetadata",C),e.addEventListener("play",zt);const lr=Array.from(e.querySelectorAll("track"));lr.forEach(j=>j.addEventListener("load",C));const cr=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>C());return cr?.observe(e),C(),zt(),()=>{V=!0,c.forEach(j=>j.removeEventListener("cuechange",C)),e.textTracks.removeEventListener("addtrack",oe),e.textTracks.removeEventListener("removetrack",oe),e.removeEventListener("timeupdate",C),e.removeEventListener("seeked",C),e.removeEventListener("loadedmetadata",C),e.removeEventListener("play",zt),lr.forEach(j=>j.removeEventListener("load",C)),cr?.disconnect(),ge&&window.cancelAnimationFrame(ge),_&&Qe.cancelVideoFrameCallback&&Qe.cancelVideoFrameCallback(_),n.textContent=""}},[ye,ht,ie,H,un,l,b.state.subtitleFontSize,b.state.subtitlePosition,b.state.subtitleBgOpacity,b.state.subtitleBgColor,b.state.subtitleTextColor,b.state.subtitleEdge,b.state.subtitleBold]);const Jt=()=>{I(null),X([]),me(""),O(-1)},Ur=T(e=>{te(e),K(1),Be(e,1)},[Be]),en=!f&&r?.seasons&&r.seasons.length>1?t("label",{className:v.sidebarSeason,children:[t("span",{children:"Season"}),t("select",{value:i,onChange:e=>Ur(parseInt(e.target.value,10)||1),className:v.select,children:r.seasons.map(e=>t("option",{value:e.season_number,children:["Season ",e.season_number," (",e.episode_count," ep)"]},e.season_number))})]}):null,vt=T(e=>{const n=parseInt(e,10);if(!isNaN(n)){try{l.current?.pause()}catch{}K(n),Be(i,n)}Sn(!1)},[i,Be,l]);y(()=>{if(f)return;const e=n=>{n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="n"&&(x!=null?vt(String(x)):ts.error("No next episode available"))};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[f,x,vt]);const Wr=e=>{w(e);try{const s=$e[e];s&&localStorage.setItem("tvLastAudio",Rn(s))}catch{}const n=re.current;n&&n.audioTrack!==void 0&&(n.audioTrack=e)},Hr=e=>{ze(e);try{if(e===-1)localStorage.setItem("tvSubtitlesEnabled","false");else{localStorage.setItem("tvSubtitlesEnabled","true"),localStorage.setItem("tvSelectedSubtitle",String(e));const c=H[e];c&&localStorage.setItem("tvLastSubtitle",Rn(c))}}catch{}const n=l.current,s=re.current;if(s&&typeof s.subtitleTrack=="number"&&Array.isArray(s.subtitleTracks)&&s.subtitleTracks.length>0&&(s.subtitleTrack=ce.current.length>0||e<0?-1:e),!n)return;const d=ce.current;if(d.length>0){d.forEach((c,N)=>{const z=c.track;if(!z)return;const g=N===e;z.mode=g&&!ye?"showing":"hidden"});return}Array.from(n.textTracks).forEach((c,N)=>{const z=N===e;c.mode=z&&!ye?"showing":"hidden"})},$t=T(()=>{if(!r)return;const e=l.current,n=f?"":`S${String(i).padStart(2,"0")}E${String(h).padStart(2,"0")}`;yt.discord.tvPresence.mutate({title:r.title,episodeLabel:n,isPlaying:e?!e.paused&&!e.ended:!0,thumbnail:r.poster,currentTime:e?e.currentTime:0,duration:e&&e.duration||0,isAdult:r.adult===!0,sessionId:At.current}).catch(()=>{}),yt.discord.heartbeat.mutate({sessionId:At.current}).catch(()=>{})},[r,f,i,h,l]);return y(()=>{if(!r)return;$t();const e=window.setInterval(()=>{const n=l.current;(!n||!n.paused)&&$t()},15e3);return()=>window.clearInterval(e)},[$t,r,l]),y(()=>{if(!r||M||Se||Te||$.length===0)return;const e=l.current;if(!e)return;const n=()=>$t();return e.addEventListener("play",n),e.addEventListener("pause",n),e.addEventListener("seeked",n),()=>{e.removeEventListener("play",n),e.removeEventListener("pause",n),e.removeEventListener("seeked",n)}},[r,M,Se,Te,$,$t,l]),y(()=>{const e=At.current,n=()=>ns(e),s=()=>n();return window.addEventListener("pagehide",s),window.addEventListener("beforeunload",s),()=>{window.removeEventListener("pagehide",s),window.removeEventListener("beforeunload",s),n()}},[]),y(()=>{if(!r){document.title="TV & Movies - dango";return}document.title=f?`${r.title} - dango`:`${r.title} - Season ${i} Episode ${h} - dango`},[r,f,i,h]),y(()=>{if(!r||f)return;const e=new URLSearchParams(p),n=e.get("s"),s=e.get("e"),d=String(i),c=String(h);n===d&&s===c||(e.set("type",p.get("type")||"tv"),e.set("s",d),e.set("e",c),O(`${window.location.pathname}?${e.toString()}`,{replace:!0}))},[r,f,i,h,p,O]),t("div",{className:`${Le.playerPageLayout} ${je?Le.theaterMode:""} ${f?Le.noSidebar:""}`,onClick:Nr,children:[je&&t(ks,{videoRef:l,active:fn.enabled&&!M&&$.length>0&&!Te&&!(r?.adult&&!Bt),settings:fn}),!je&&!f&&t("aside",{className:Le.episodeSidebar,children:r?t(Es,{episodes:ar,currentEpisode:String(h),watchedEpisodes:or,onEpisodeClick:vt,header:en}):t(ws,{variant:"sidebar"})}),t("div",{className:Le.playerMain,children:[r&&t("div",{className:v.playerSection,onContextMenu:e=>e.preventDefault(),style:r.adult&&!Bt?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:M&&_t?t("iframe",{src:_t,className:v.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!M&&kt?t("iframe",{src:kt,className:v.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!M&&($.length>0||Se)?t(Me,{children:[Te&&t(fr,{error:Te,onRetry:Zt}),t(Po,{player:b,title:r.title,episodeLabel:f?void 0:`S${i} E${h}`,audioTracks:$e,selectedAudioTrack:be,onAudioTrackChange:Wr,subtitles:H,selectedSubtitle:ie,onSubtitleChange:Hr,streams:$,resolutionIdx:we,onResolutionChange:e=>{xn(),De(e)},onBack:Jt,videoDelayEnabled:J,onVideoDelayToggle:de,videoDelayMs:B,onVideoDelayChange:It,onCalibrateAvSync:Fn,subtitleDelayMs:ht,onSubtitleDelayChange:br,showNextEpisodeButton:Cr&&!Ie&&!Ne&&!Ye,onNextEpisode:tr,isLoading:Se,isTheaterMode:je,onTheaterModeToggle:Tn,ambientSettings:fn,onAmbientChange:vr,children:[t("video",{ref:l,autoPlay:tt&&!Pt,playsInline:!0,disablePictureInPicture:!0,className:`${v.video} ${hn?v.videoHidden:""}`,onTimeUpdate:Lr,onEnded:()=>{Ce||Mr()},onPlay:Pr,onPause:Rr,onSeeked:()=>{Zn.current=Date.now(),Rt()},onLoadedMetadata:$r,onVolumeChange:b.actions.onVolumeChange,onWaiting:b.actions.onWaiting,onPlaying:b.actions.onPlaying,onCanPlay:b.actions.onCanPlay,onContextMenu:e=>e.preventDefault(),onError:()=>{L("Video failed to load. Try another server or reload."),Y(!1)}}),t("canvas",{ref:Nt,className:`${v.delayCanvas} ${hn?v.delayCanvasActive:""}`}),ye&&t("div",{ref:xt,className:v.subtitleOverlay}),t(Ns,{isOpen:ln,ms:B,onChange:It,onApply:jt,onClose:cn,testClipActive:Ce,onTestClip:dn})]})]}):Te&&!M?t(fr,{error:Te,onRetry:Zt}):null}),!je&&r&&t(xs,{}),!je&&en&&t("div",{className:v.mobileSeasonRow,children:en}),!je&&r&&t("div",{className:ue.streamPanel,children:[t("div",{className:v.providerSelectWrap,children:t("label",{className:v.controlLabel,children:["Provider",t("select",{value:m,onChange:e=>jr(e.target.value),className:v.select,disabled:q.length===0,children:Ze?t("option",{value:"",children:"Loading..."}):q.length===0?t("option",{value:"",children:"No providers available"}):t(Me,{children:[k.length>0&&t("optgroup",{label:"Direct HLS",children:k.map(e=>t("option",{value:e.id,children:e.label},e.id))}),ne.length>0&&t("optgroup",{label:"Embeds",children:ne.map(e=>t("option",{value:e.id,children:e.label},e.id))})]})})]})}),!M&&(Se?t("div",{className:v.sourceLoader,children:t("div",{className:v.ringSpinner})}):t($o,{servers:dt,selectedServer:Vt?"Embed":ve,onServerSelect:Vr}))]}),!je&&r&&t("div",{className:Le.playerInfoContainer,children:[t("div",{className:Le.playerInfoHeader,children:[t("div",{className:Le.playerAnimeCard,children:r.poster&&t("img",{src:`https://image.tmdb.org/t/p/w342${r.poster}`,alt:r.title,loading:"lazy",decoding:"async"})}),t("div",{className:Le.videoTitleSection,children:[t("div",{className:ue.titleContainer,children:[t("h1",{children:r.title}),t("div",{className:v.meta,children:[t("span",{className:v.year,children:r.year}),r.vote_average!=null&&r.vote_average>0&&t("span",{className:v.rating,children:[t(U,{name:"star",size:12}),Number(r.vote_average).toFixed(1)]}),t("span",{className:`${v.typeBadge} ${v[f?"movie":"tv"]}`,children:f?"Movie":"TV Show"})]}),ir.length>0&&t("div",{className:v.genreRow,children:ir.map(e=>t("span",{className:v.genreChip,children:e},e))}),Nn.length>0&&t("div",{className:v.metaRow,children:Nn.map((e,n)=>t("span",{children:[e,n<Nn.length-1?" · ":""]},`${e}-${n}`))})]}),t("div",{className:ue.controls,children:[t("button",{className:`${ue.watchlistBtn} ${Ht?ue.inList:""}`,onClick:Tr,disabled:Sr,type:"button",children:[Ht?t(U,{name:"check",size:14}):t(U,{name:"plus",size:14}),Ht?"In Watchlist":"Add to Watchlist"]}),!f&&t(Me,{children:[t("button",{className:`${ue.watchlistBtn}`,onClick:()=>bn!=null&&vt(String(bn)),disabled:bn==null,type:"button",children:[t(U,{name:"chevron-left",size:14}),"Prev EP"]}),t("button",{className:`${ue.watchlistBtn}`,onClick:()=>x!=null&&vt(String(x)),disabled:x==null,type:"button",children:["Next EP",t(U,{name:"chevron-right",size:14})]}),!f&&t("button",{className:`${ue.watchlistBtn} ${ue.modeToggleBtn} ${gt?ue.modeToggleActive:""}`,onClick:()=>Br(!gt),type:"button","aria-pressed":gt,children:gt?"AUTOPLAY: ON":"AUTOPLAY: OFF"}),xr&&t("button",{className:`${ue.watchlistBtn}`,onClick:()=>Sn(!0),type:"button",children:[t(U,{name:"list-ul",size:14}),"Episodes"]})]})]})]})]}),t("div",{className:Le.infoColumns,children:[t("div",{className:`${ue.descriptionSection} ${ue.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t(Ks,{text:r.overview,emptyText:"No description available."}),t("button",{className:ue.detailsToggleBtn,onClick:()=>Er(!Gt),type:"button",children:[Gt?t(U,{name:"chevron-up"}):t(U,{name:"chevron-down"}),Gt?"Hide Details":"Show Details"]})]}),Gt&&t("div",{className:v.detailGrid,children:[r.first_air_date&&t("div",{className:v.detailItem,children:[t("strong",{children:f?"Release Date":"First Air Date"}),t("span",{children:r.first_air_date})]}),r.last_air_date&&t("div",{className:v.detailItem,children:[t("strong",{children:"Last Air Date"}),t("span",{children:r.last_air_date})]}),r.networks&&r.networks.length>0&&t("div",{className:v.detailItem,children:[t("strong",{children:"Networks"}),t("span",{children:r.networks.map(e=>e.name).join(", ")})]}),r.created_by&&r.created_by.length>0&&t("div",{className:v.detailItem,children:[t("strong",{children:"Created By"}),t("span",{children:r.created_by.map(e=>e.name).join(", ")})]}),r.episode_run_time&&r.episode_run_time.length>0&&t("div",{className:v.detailItem,children:[t("strong",{children:"Episode Runtime"}),t("span",{children:[r.episode_run_time[0]," min"]})]}),r.imdb_id&&t("div",{className:v.detailItem,children:[t("strong",{children:"IMDb"}),t("a",{href:`https://www.imdb.com/title/${r.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:v.imdbLink,children:"View on IMDb"})]})]})]})]}),!f&&t(Is,{isOpen:wr,onClose:()=>Sn(!1),episodes:ar,currentEpisode:String(h),watchedEpisodes:or,onEpisodeClick:vt,header:en}),r?.adult&&!Bt&&t(Mn,{isOpen:!0,title:"Content Warning",onClose:Jt,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(Ue,{variant:"secondary",onClick:Jt,children:"Go Back"}),t(Ue,{onClick:yr,children:"I'm 18+, Continue"})]})]})}),t(Bs,{isOpen:Ie,onClose:er,title:"Resume Watching",message:t(Me,{children:["You were at ",t("strong",{children:on(ft)})]}),restartLabel:"Start from Beginning",onResume:zr,onRestart:er}),t(Mn,{isOpen:Ne,onClose:Dr,title:f?"Movie Completed":"Episode Completed",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:f?t(Me,{children:"You've already watched this movie."}):t(Me,{children:["You've already watched"," ",t("strong",{children:["Season ",i," Episode ",h]}),". Would you like to continue?"]})}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center",flexWrap:"wrap"},children:[t(Ue,{variant:"secondary",onClick:Or,children:"Replay"}),x!=null?t(Ue,{onClick:tr,children:["Watch EP ",x]}):_e!=null?t(Ue,{onClick:nr,children:["Start Season ",_e]}):null]})]})}),t(Mn,{isOpen:Ye,onClose:()=>nt(!1),title:f?"Movie Completed!":_e!=null?"Season Complete!":"Show Completed!",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t(U,{name:"check-circle",size:48,style:{color:"var(--accent-lighter)",marginBottom:"0.5rem"}}),t("p",{style:{fontSize:"1.1rem",fontWeight:600},children:kr}),t("p",{style:{color:"var(--text-secondary)"},children:f?"You finished this movie!":_e!=null?`You finished Season ${i}.`:"Congratulations! You finished all available episodes."}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center",flexWrap:"wrap"},children:[t(Ue,{variant:"secondary",onClick:()=>nt(!1),children:"Close"}),_e!=null?t(Ue,{onClick:nr,children:["Start Season ",_e]}):t(Me,{children:[t(Ue,{onClick:()=>{nt(!1),Jt()},children:"Back to Details"}),Ht&&t(Ue,{onClick:Fr,disabled:Wt.isPending,children:Wt.isPending?"Saving...":"Move to Completed"})]})]})]})}),!r&&t("div",{className:v.statusMsg,children:[t(U,{name:"spinner",className:v.spinner})," Loading..."]})]})]})};export{Ja as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as R,a as q,p as E,d as l,h as C,T,u as e,g as F}from"./vendor-core-DfaOB3Rn.js";import{I as a}from"./vendor-icons-DrybRNxP.js";import{e as j,t as U,B as w}from"./index-
|
|
1
|
+
import{o as R,a as q,p as E,d as l,h as C,T,u as e,g as F}from"./vendor-core-DfaOB3Rn.js";import{I as a}from"./vendor-icons-DrybRNxP.js";import{e as j,t as U,B as w}from"./index-C93G341i.js";import{n as H,d as J,e as K,f as Q,t as I}from"./useTvLibrary-DizEfaXg.js";import"./vendor-query-BBT5_sHx.js";const X="_container_198yg_1",Y="_heroSection_198yg_11",Z="_bannerContainer_198yg_17",ee="_banner_198yg_17",ne="_bannerOverlay_198yg_37",te="_heroContent_198yg_49",se="_posterContainer_198yg_62",ae="_poster_198yg_62",oe="_infoGlass_198yg_86",ie="_title_198yg_100",re="_quickMeta_198yg_110",le="_metaItem_198yg_118",ce="_iconStar_198yg_126",de="_iconTv_198yg_130",me="_iconType_198yg_134",_e="_genres_198yg_139",he="_genre_198yg_139",ge="_metaRow_198yg_156",ve="_metaValue_198yg_164",pe="_metaDivider_198yg_168",ye="_synopsisSection_198yg_173",ue="_sectionTitleSmall_198yg_179",ke="_synopsis_198yg_173",be="_actions_198yg_196",Ne="_watchBtn_198yg_202",Se="_watchlistBtn_198yg_226",fe="_active_198yg_250",Ce="_seasonPickerLabel_198yg_256",Te="_seasonSelect_198yg_267",we="_detailsToggleBtn_198yg_286",Ie="_expandedContent_198yg_304",Be="_detailGrid_198yg_309",De="_detailItem_198yg_315",Me="_imdbLink_198yg_333",Le="_heroSkeleton_198yg_343",Pe="_skeletonBanner_198yg_347",$e="_skeletonContent_198yg_354",Ge="_skeletonPoster_198yg_365",xe="_skeletonInfo_198yg_373",Oe="_skeletonTitle_198yg_380",Ae="_skeletonMeta_198yg_388",Ve="_skeletonDesc_198yg_396",We="_skeletonActions_198yg_404",ze="_errorState_198yg_413",Re="_matureOverlay_198yg_434",qe="_matureContent_198yg_444",n={container:X,heroSection:Y,bannerContainer:Z,banner:ee,bannerOverlay:ne,heroContent:te,posterContainer:se,poster:ae,infoGlass:oe,title:ie,quickMeta:re,metaItem:le,iconStar:ce,iconTv:de,iconType:me,genres:_e,genre:he,metaRow:ge,metaValue:ve,metaDivider:pe,synopsisSection:ye,sectionTitleSmall:ue,synopsis:ke,actions:be,watchBtn:Ne,watchlistBtn:Se,active:fe,seasonPickerLabel:Ce,seasonSelect:Te,detailsToggleBtn:we,expandedContent:Ie,detailGrid:Be,detailItem:De,imdbLink:Me,heroSkeleton:Le,skeletonBanner:Pe,skeletonContent:$e,skeletonPoster:Ge,skeletonInfo:xe,skeletonTitle:Oe,skeletonMeta:Ae,skeletonDesc:Ve,skeletonActions:We,errorState:ze,matureOverlay:Re,matureContent:qe};function Je(){const{id:o}=R(),c=q(),[B]=E(),i=H(B.get("type")),{hasConsent:D}=j(),[t,M]=l(null),[L,_]=l(!0),[y,u]=l(""),[d,P]=l(!1),[h,$]=l(1),G=J(i,o),x=Number(o),{data:O}=K(t?G:void 0),g=!!O?.inLibrary,{toggle:A}=Q();C(()=>{o&&(_(!0),u(""),U.tv.details.query({type:i,id:String(o)}).then(s=>{const m={id:s.id,title:s.title||"",overview:s.overview||"",vote_average:s.vote_average,year:s.year,poster:s.poster,backdrop:s.backdrop,imdb_id:s.imdb_id||void 0,adult:s.adult,seasons:s.seasons?.map(z=>({...z,name:""})),number_of_seasons:s.number_of_seasons};M(m),_(!1)}).catch(s=>{u(s.message),_(!1)}))},[o,i]),C(()=>{document.title=t?.title?`${t.title} - dango`:"TV & Movies - dango"},[t?.title]);const V=()=>{!o||!t||c(r?I(i,o):I(i,o,h,1))},W=()=>{t&&A({tmdbId:x,mediaType:i,title:t.title,poster:t.poster,year:t.year,adult:t.adult})},r=i==="movie",v=!r,k=t?.backdrop?`https://image.tmdb.org/t/p/w1280${t.backdrop}`:"",b=t?.poster?`https://image.tmdb.org/t/p/w500${t.poster}`:"",N=T(()=>t?.genres?t.genres.map(s=>s.name).slice(0,5):[],[t?.genres]),S=T(()=>t?.seasons?t.seasons.filter(s=>s.season_number>0):[],[t?.seasons]),p=[t?.year,t?.status,v&&t?.number_of_seasons?`${t.number_of_seasons} Season${t.number_of_seasons>1?"s":""}`:null,v&&t?.number_of_episodes?`${t.number_of_episodes} Episodes`:null].filter(Boolean);if(L)return e("div",{className:n.container,children:e("div",{className:n.heroSkeleton,children:[e("div",{className:n.skeletonBanner}),e("div",{className:n.skeletonContent,children:[e("div",{className:n.skeletonPoster}),e("div",{className:n.skeletonInfo,children:[e("div",{className:n.skeletonTitle}),e("div",{className:n.skeletonMeta}),e("div",{className:n.skeletonDesc}),e("div",{className:n.skeletonActions})]})]})]})});if(y||!t)return e("div",{className:n.container,children:e("div",{className:n.errorState,children:[e(a,{name:"exclamation-triangle",size:48}),e("h2",{children:"Failed to load details"}),e("p",{children:y||"Something went wrong"}),e(w,{onClick:()=>c(-1),children:"Go Back"})]})});const f=t.adult&&!D;return e("div",{className:n.container,style:f?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:[e("div",{className:n.heroSection,children:[e("div",{className:n.bannerContainer,children:[k&&e("div",{className:n.banner,style:{backgroundImage:`url(${k})`}}),e("div",{className:n.bannerOverlay})]}),e("div",{className:n.heroContent,children:[e("div",{className:n.posterContainer,children:b&&e("img",{src:b,alt:t.title,className:n.poster,decoding:"async"})}),e("div",{className:n.infoGlass,children:[e("div",{className:n.topInfo,children:[e("h1",{className:n.title,children:t.title}),e("div",{className:n.quickMeta,children:[t.vote_average!=null&&t.vote_average>0&&e("div",{className:n.metaItem,children:[e(a,{name:"star",className:n.iconStar}),e("span",{children:Number(t.vote_average).toFixed(1)})]}),e("div",{className:n.metaItem,children:[e(a,{name:"tv",className:n.iconTv}),e("span",{children:r?"Movie":"TV Show"})]}),t.vote_count!=null&&e("div",{className:n.metaItem,children:[e(a,{name:"users",className:n.iconType}),e("span",{children:[t.vote_count.toLocaleString()," votes"]})]})]}),N.length>0&&e("div",{className:n.genres,children:N.map(s=>e("span",{className:n.genre,children:s},s))})]}),p.length>0&&e("div",{className:n.metaRow,children:p.map((s,m)=>e(F.Fragment,{children:[e("span",{className:n.metaValue,children:s}),m<p.length-1&&e("span",{className:n.metaDivider,children:"·"})]},m))}),t.overview&&e("div",{className:n.synopsisSection,children:[e("h2",{className:n.sectionTitleSmall,children:"Synopsis"}),e("p",{className:n.synopsis,children:t.overview})]}),e("div",{className:n.actions,children:[e("button",{className:n.watchBtn,onClick:V,children:[e(a,{name:"play",size:14}),r?"Watch Now":`Start S${h}`]}),e("button",{className:`${n.watchlistBtn} ${g?n.active:""}`,onClick:W,children:[g?e(a,{name:"check",size:14}):e(a,{name:"plus",size:14}),g?"In Watchlist":"Add to Watchlist"]})]}),v&&S.length>1&&e("label",{className:n.seasonPickerLabel,children:[e("span",{children:"Season"}),e("select",{value:h,onChange:s=>$(parseInt(s.target.value,10)||1),className:n.seasonSelect,children:S.map(s=>e("option",{value:s.season_number,children:["Season ",s.season_number," (",s.episode_count," Episodes)"]},s.season_number))})]}),e("button",{className:n.detailsToggleBtn,onClick:()=>P(!d),children:[d?e(a,{name:"chevron-up"}):e(a,{name:"chevron-down"}),d?"Hide Details":"Show Details"]}),d&&e("div",{className:n.expandedContent,children:e("div",{className:n.detailGrid,children:[t.first_air_date&&e("div",{className:n.detailItem,children:[e("strong",{children:r?"Release Date":"First Air Date"}),e("span",{children:t.first_air_date})]}),t.last_air_date&&e("div",{className:n.detailItem,children:[e("strong",{children:"Last Air Date"}),e("span",{children:t.last_air_date})]}),t.networks&&t.networks.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Networks"}),e("span",{children:t.networks.map(s=>s.name).join(", ")})]}),t.created_by&&t.created_by.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Created By"}),e("span",{children:t.created_by.map(s=>s.name).join(", ")})]}),t.episode_run_time&&t.episode_run_time.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Episode Runtime"}),e("span",{children:[t.episode_run_time[0]," min"]})]}),t.imdb_id&&e("div",{className:n.detailItem,children:[e("strong",{children:"IMDb"}),e("a",{href:`https://www.imdb.com/title/${t.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:n.imdbLink,children:"View on IMDb"})]})]})})]})]})]}),f&&e("div",{className:n.matureOverlay,children:e("div",{className:n.matureContent,children:[e(a,{name:"exclamation-triangle",size:48}),e("h2",{children:"Content Warning"}),e("p",{children:"This content may contain mature themes."}),e(w,{onClick:()=>c("/"),children:"Go Back"})]})})]})}export{Je as default};
|