@serifpersia/dango 3.7.3 → 3.7.5
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 +10 -6
- package/client/dist/assets/{AnimeCard-BVufFeLC.js → AnimeCard-BxhPLWBG.js} +1 -1
- package/client/dist/assets/{AnimeInfo-Dihook4h.js → AnimeInfo-DcpKPBLS.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-K0ErjilQ.js → AnimeInfoPage-jKNSPHbX.js} +2 -2
- package/client/dist/assets/{Asmr-CP7vVwsh.js → Asmr-DlKBykO-.js} +2 -2
- package/client/dist/assets/Asmr-Do89pEHG.css +1 -0
- package/client/dist/assets/{AsmrResetProgressModal-cYO4Sr2k.js → AsmrResetProgressModal-DPHPLqPo.js} +1 -1
- package/client/dist/assets/{Home-BYuAVKgx.js → Home-D7-FNOmo.js} +1 -1
- package/client/dist/assets/{Insights-Bx01GySp.js → Insights-C9HufjGJ.js} +1 -1
- package/client/dist/assets/{LibraryListPage-BnrEDG8j.js → LibraryListPage-BT_xDjEq.js} +1 -1
- package/client/dist/assets/{ListeningList-kRSLAo3B.js → ListeningList-DL1rdCRi.js} +1 -1
- package/client/dist/assets/{Manga-COhyMd3K.js → Manga-BfFRq7eK.js} +1 -1
- package/client/dist/assets/{MangaInfoPage-LTEvl_nL.js → MangaInfoPage-wBJjn2FL.js} +1 -1
- package/client/dist/assets/{MangaReadPage-sEwzyBQ7.js → MangaReadPage-BAgsRqxt.js} +1 -1
- package/client/dist/assets/{MangaResetProgressModal-CbMR36Zu.js → MangaResetProgressModal-Br5zqZ-U.js} +1 -1
- package/client/dist/assets/{Mature-CMvs_-gf.js → Mature-MO7ZwJVT.js} +1 -1
- package/client/dist/assets/{MatureConsentModal-BnB-RHYQ.js → MatureConsentModal-Beq4JL0b.js} +1 -1
- package/client/dist/assets/{MediaCard-B0PJStxp.css → MediaCard-CoyScn-7.css} +1 -1
- package/client/dist/assets/MediaCard-lz7FdOe_.js +1 -0
- package/client/dist/assets/{OptionListMenu-onM2KK2X.js → OptionListMenu-BSUcso28.js} +1 -1
- package/client/dist/assets/Player-CnLC-x2S.js +56 -0
- package/client/dist/assets/{PlayerSettings-BfSv-hut.js → PlayerSettings-kqYmlLDl.js} +1 -1
- package/client/dist/assets/{QueueOptionsButton-B4Re8F3V.js → QueueOptionsButton-B8xuoYlH.js} +1 -1
- package/client/dist/assets/{QueueRail-Dkx_M6ng.js → QueueRail-D1FmM-GR.js} +1 -1
- package/client/dist/assets/{ReadingList-C--ZvTe2.js → ReadingList-D8ZiOnWi.js} +1 -1
- package/client/dist/assets/{ResetProgressModal-BuESoxbY.js → ResetProgressModal-0PvvM2XJ.js} +1 -1
- package/client/dist/assets/{Search-CEErwr88.js → Search-D1T-PrGX.js} +1 -1
- package/client/dist/assets/Settings-DALBQcFc.js +21 -0
- package/client/dist/assets/Settings-DYjRBgpE.css +1 -0
- package/client/dist/assets/{SkeletonGrid-QWMGLCGp.js → SkeletonGrid-pA-dcLBM.js} +1 -1
- package/client/dist/assets/Trackers-CvO6aWVx.css +1 -0
- package/client/dist/assets/Trackers-D68sJf1y.js +2 -0
- package/client/dist/assets/{Tv-C6F9655r.js → Tv-DO-WeaMv.js} +1 -1
- package/client/dist/assets/{TvInfo-BajXP7JJ.js → TvInfo-CpPIymn8.js} +1 -1
- package/client/dist/assets/{TvPopup-DZtX79Ol.js → TvPopup-BwGJ1Tjg.js} +1 -1
- package/client/dist/assets/{TvSearch-DcWcxRb1.js → TvSearch-D9SrfJjK.js} +1 -1
- package/client/dist/assets/{TvWatchlist-Cf_25dKi.js → TvWatchlist-25tpA8ln.js} +1 -1
- package/client/dist/assets/{Watchlist-DBmU8PNR.js → Watchlist-mlZQTcqR.js} +1 -1
- package/client/dist/assets/{hls-Bi-DS5KL.js → hls-qvAoYTJt.js} +1 -1
- package/client/dist/assets/index-DlcgJVM6.js +178 -0
- package/client/dist/assets/{index-B7katXv0.css → index-ZssheiHa.css} +1 -1
- package/client/dist/assets/{libraryInvalidation-DI-v-DQ1.js → libraryInvalidation-DdnIPcOQ.js} +1 -1
- package/client/dist/assets/{useAnimeInfoData-DpUA78Mv.js → useAnimeInfoData-tcGkDs2b.js} +1 -1
- package/client/dist/assets/{useAsmr-BwyYDnlP.js → useAsmr-B-FYJW2L.js} +1 -1
- package/client/dist/assets/{useAsmrPopup-BrrEaBlV.js → useAsmrPopup-Ct9jC6X6.js} +1 -1
- package/client/dist/assets/{useMangaLibrary-BAUaug-u.js → useMangaLibrary-BacTdrw2.js} +1 -1
- package/client/dist/assets/{useMangaPopup-3Lx5tEub.js → useMangaPopup-B_wRaMyP.js} +1 -1
- package/client/dist/assets/usePlaybackEnd-DLFOYx3Q.css +1 -0
- package/client/dist/assets/{usePlaybackEnd-CuDnNZ8o.js → usePlaybackEnd-DuEfjKb8.js} +2 -2
- package/client/dist/assets/{useProviders-CKqOSX5-.js → useProviders-D0XOHCsj.js} +1 -1
- package/client/dist/assets/{useTv-CZB47zUF.js → useTv-IidbSQU4.js} +1 -1
- package/client/dist/assets/{useTvLibrary-BGz7Unv_.js → useTvLibrary-DiCSdUOj.js} +1 -1
- package/client/dist/index.html +2 -2
- package/package.json +2 -2
- package/server/dist/server.js +251 -246
- package/server/dist/shipped-defaults.js +1 -1
- package/server/package.json +1 -1
- package/client/dist/assets/Asmr-Dl1EZqaI.css +0 -1
- package/client/dist/assets/MediaCard-hWGCEHWx.js +0 -1
- package/client/dist/assets/Player-2YKevlG4.js +0 -56
- package/client/dist/assets/Settings-BEHII_8K.css +0 -1
- package/client/dist/assets/Settings-C-QEEujv.js +0 -21
- package/client/dist/assets/Trackers-1i4Hd5D3.js +0 -2
- package/client/dist/assets/Trackers-D5XBOCDp.css +0 -1
- package/client/dist/assets/index-DB81Su4I.js +0 -178
- package/client/dist/assets/usePlaybackEnd-BtUHM1mW.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as x,p as pe,a as fe,d as o,A as ge,g as Le,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as f}from"./vendor-icons-DrybRNxP.js";import{P as ae}from"./MediaCard-
|
|
1
|
+
import{h as x,p as pe,a as fe,d as o,A as ge,g as Le,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as f}from"./vendor-icons-DrybRNxP.js";import{P as ae}from"./MediaCard-lz7FdOe_.js";import{A as Ae}from"./AnimeCard-BxhPLWBG.js";import{S as Se}from"./SkeletonGrid-pA-dcLBM.js";import{t as ye,u as be,x as Ne,R as te,B as _,U as Te}from"./index-DlcgJVM6.js";import{E as Ce}from"./ErrorMessage-DAxegITP.js";import{A as Ee}from"./ActiveFilterChips-olGfwxle.js";import{s as t}from"./Search.module-C_qwCdHS.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-Beq4JL0b.js";import"./useAnimeInfoData-tcGkDs2b.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-B8xuoYlH.js";import"./playbackCompletion-IPHm9fp5.js";const Re=[{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"}],Ie=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],De=[{value:"ALL",label:"All Countries"},{value:"JP",label:"Japan"},{value:"CN",label:"China"}],Pe=[{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"}],Oe=[{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 We(){x(()=>{document.title="Search - dango"},[]);const[r,le]=pe(),se=fe(),[m,B]=o(r.get("query")||""),[v,G]=o(parseInt(r.get("page")||"1")),[d,g]=o(r.get("type")||"ALL"),[L,A]=o(r.get("season")||"ALL"),[S,y]=o(r.get("year")||"ALL"),[Y,R]=o(r.get("country")||"ALL"),[k,re]=o(r.get("provider")||"anilist"),[U,I]=o(r.get("sortBy")||"POPULARITY_DESC"),[$,D]=o(r.get("status")||""),[b,ne]=o(!1),[ie,F]=o(null);x(()=>{let e=!1;return ye.data.anilistStatus.query().then(s=>{e||F(s.available)}).catch(()=>{e||F(!0)}),()=>{e=!0}},[]);const{lowEndMode:oe}=be(),P=ge(null),{data:ce}=Ne(),M=ce?.genres||[],[N,T]=o(()=>{const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],n=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return s.forEach(l=>l&&(e[l]="include")),n.forEach(l=>l&&(e[l]="exclude")),e}),V=new URLSearchParams(r);V.delete("page");const j=V.toString(),{data:p=[],isLoading:C,isError:ue,error:de}=te(j,v,14),{data:q}=te(j,v+1,14),[O,he]=o(!1),E=Le.useMemo(()=>k==="anilist"&&d==="ADULT"||O?p:p.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[p,O,k,d]);x(()=>{B(r.get("query")||""),g(r.get("type")||"ALL"),A(r.get("season")||"ALL"),y(r.get("year")||"ALL"),R(r.get("country")||"ALL"),re(r.get("provider")||"anilist"),I(r.get("sortBy")||"POPULARITY_DESC"),D(r.get("status")||""),G(parseInt(r.get("page")||"1"));const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],n=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];s.forEach(l=>l&&(e[l]="include")),n.forEach(l=>l&&(e[l]="exclude")),T(e)},[r]);const c=(e=1,s={})=>{Te();const n=s.type??d,l=s.status??$,W=s.season??L,J=s.year??S,K=s.country??Y,Q=s.sort??U,X=s.genreState??N,ve=s.showMature??O,i=new URLSearchParams;m.trim()&&i.set("query",m.trim()),n!=="ALL"&&i.set("type",n),l&&i.set("status",l),W!=="ALL"&&i.set("season",W),J!=="ALL"&&i.set("year",J),K!=="ALL"&&i.set("country",K),Q!=="POPULARITY_DESC"&&i.set("sortBy",Q);const Z=Object.entries(X).filter(([,u])=>u==="include").map(([u])=>u),ee=Object.entries(X).filter(([,u])=>u==="exclude").map(([u])=>u);Z.length>0&&i.set("genres",Z.join(",")),ee.length>0&&i.set("excludeGenres",ee.join(",")),n!=="ADULT"&&!ve&&i.set("adult","false"),i.set("provider","anilist"),e>1&&i.set("page",e.toString()),le(i),e!==v&&G(e)},z=e=>{if(c(e),P.current){const s=P.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:s,behavior:"smooth"})}},w=new Date().getFullYear(),me=[{value:"ALL",label:"All Years"},...Array.from({length:w-1980+1},(e,s)=>({value:String(w-s),label:String(w-s)}))],H=p.length>=14&&q&&q.length>0,h=[];d!=="ALL"&&h.push({key:"type",label:`Type: ${d}`,onRemove:()=>{g("ALL"),c(1,{type:"ALL"})}}),L!=="ALL"&&h.push({key:"season",label:`Season: ${L}`,onRemove:()=>{A("ALL"),c(1,{season:"ALL"})}}),S!=="ALL"&&h.push({key:"year",label:`Year: ${S}`,onRemove:()=>{y("ALL"),c(1,{year:"ALL"})}});for(const[e,s]of Object.entries(N))h.push({key:e,label:s==="include"?`+ ${e}`:`-${e}`,tone:s==="include"?"primary":"danger",onRemove:()=>{const n={...N};delete n[e],T(n),c(1,{genreState:n})}});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(f,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search by title, character, or studio...",value:m,onInput:e=>B(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&c()})]}),a("div",{className:t.searchActions,children:[a(_,{onClick:()=>c(),className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${b?t.active:""}`,onClick:()=>ne(!b),children:[a(f,{name:"filter",size:14}),a("span",{children:"Filters"}),b?a(f,{name:"chevron-up",size:12}):a(f,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${b?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:d,onChange:e=>{if(e.currentTarget.value==="ADULT"){se("/mature?provider=mal");return}g(e.currentTarget.value)},children:Re.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:$,onChange:e=>D(e.currentTarget.value),children:[a("option",{value:"",children:"All Status"}),Oe.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:L,onChange:e=>A(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:"Year"}),a("select",{value:S,onChange:e=>y(e.currentTarget.value),children:me.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:["Country",ie===!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:Y,onChange:e=>R(e.currentTarget.value),children:De.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:U,onChange:e=>I(e.currentTarget.value),children:Pe.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[N[e]||""]}`,onClick:()=>{T(s=>{const n=s[e],l={...s};return n==="include"?l[e]="exclude":n==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(_,{variant:"secondary",onClick:()=>{T({}),g("ALL"),A("ALL"),y("ALL"),R("ALL"),I("POPULARITY_DESC"),D(""),he(!1),c(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(_,{onClick:()=>c(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),ue&&a(Ce,{message:de?.message||"Error"}),h.length>0&&a(Ee,{chips:h}),a("div",{className:t.resultsHeader,ref:P,children:[a("h2",{className:t.resultsTitle,children:m?`Search Results for "${m}"`:"Discover Anime"}),E.length>0&&a(ae,{page:v,canGoNext:H,onChange:z,isLoading:C})]}),a("div",{className:`${t.resultsGrid} ${oe?t.lowEnd:""}`,children:C?a(Se,{}):E.map(e=>a(Ae,{anime:e},e._id))}),!C&&E.length===0&&a("div",{className:t.noResults,children:[a(f,{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."})]}),E.length>0&&a("div",{className:t.bottomPagination,children:a(ae,{page:v,canGoNext:H,onChange:z,isLoading:C,variant:"labeled"})})]})}export{We as default};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{d as s,A as j,h as O,u as e,q as le,S as Ne,T as Te,p as Ie,g as ue,_ as Le}from"./vendor-core-DfaOB3Rn.js";import{d as Re,D as pe,t as b,B as T,M as q,k as fe,i as xe,A as he,H as V,q as $,I as ge,J as Pe,K as De,T as Ae,u as Oe,e as Ge,L as Me,C as ne,V as ze,N as Ue}from"./index-DlcgJVM6.js";import{u as ce}from"./vendor-query-BBT5_sHx.js";import{T as K}from"./ToggleSwitch-CN_ppEc9.js";import{I as X}from"./vendor-icons-DrybRNxP.js";const se={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},re=["name","nativeName","englishName"],ie={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},Ee=()=>{const{titlePreference:t,setTitlePreference:r,loading:o}=Re(),c=pe(),[l,y]=s(ie[t]),[v,m]=s(!1),a=j(null);O(()=>{o||y(ie[t])},[t,o]);const i=async()=>{if(v)return;m(!0);const p=(re.indexOf(t)+1)%re.length,d=re[p],I=ie[d];a.current&&(a.current.style.transform="translateX(-100%)",a.current.style.opacity="0"),setTimeout(async()=>{y(I),r(d),a.current&&(a.current.style.transition="none",a.current.style.transform="translateX(100%)",a.current.style.opacity="0",a.current.offsetWidth,a.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",a.current.style.transform="translateX(0)",a.current.style.opacity="1");try{await c.mutateAsync({key:"titlePreference",value:d})}catch(h){console.error("Error saving title preference:",h)}finally{m(!1)}},300)};return o?e("p",{children:"Loading title preference..."}):e("div",{className:se["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:i,className:se["toggle-button"],disabled:v,children:e("span",{ref:a,className:se["toggle-label"],children:l})})]})},qe="_settingsHeader_ik3bf_1",Fe="_pageTitle_ik3bf_6",Ke="_pageSubtitle_ik3bf_14",$e="_settingsLayout_ik3bf_20",He="_sidebar_ik3bf_27",We="_sidebarIndicator_ik3bf_35",Be="_sidebarItem_ik3bf_50",Ve="_active_ik3bf_72",je="_mainContent_ik3bf_80",Qe="_tabContent_ik3bf_85",Ye="_settingItem_ik3bf_103",Je="_controls_ik3bf_108",Xe="_status_ik3bf_114",S={settingsHeader:qe,pageTitle:Fe,pageSubtitle:Ke,settingsLayout:$e,sidebar:He,sidebarIndicator:We,sidebarItem:Be,active:Ve,mainContent:je,tabContent:Qe,settingItem:Ye,controls:Je,status:Xe},Ze="_title_tm30b_11",et="_signIn_tm30b_18",tt="_userInfo_tm30b_25",at="_warning_tm30b_47",nt="_formGroup_tm30b_54",st="_label_tm30b_58",rt="_inputWrapper_tm30b_68",it="_input_tm30b_68",ot="_select_tm30b_92",lt="_actions_tm30b_109",ct="_hr_tm30b_117",g={title:Ze,signIn:et,userInfo:tt,warning:at,formGroup:nt,label:st,inputWrapper:rt,input:it,select:ot,actions:lt,hr:ct},dt="_sectionCard_1axuo_1",ut="_dangerCard_1axuo_23",ht="_settingRow_1axuo_31",N={sectionCard:dt,dangerCard:ut,settingRow:ht},gt=()=>{const[t,r]=s(!0),[o,c]=s(!1),[l,y]=s(!1),[v,m]=s(null),[a,i]=s({status:"idle"}),[u,p]=s(!1),[d,I]=s(""),[h,k]=s(!1),L=j(null),[R,x]=s({show:!1,message:"",type:"info"}),A=()=>{L.current&&(window.clearInterval(L.current),L.current=null)},w=le(f=>{y(f.authenticated),m(f.user||f.device.user||null),i(f.device),p(!!f.hasCustomClientId)},[]),C=le(async()=>{const f=await b.auth.githubStatus.query();w(f)},[w]),G=async()=>{try{const f=await b.auth.githubPoll.query();i(f),f.status==="success"?(A(),await C(),x({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):f.status==="error"&&(A(),x({show:!0,message:f.error||"GitHub authentication failed.",type:"error"}))}catch{A(),x({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},z=(f=5)=>{A(),L.current=window.setInterval(G,Math.max(f,5)*1e3)};O(()=>(C().catch(()=>{x({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>r(!1)),A),[C]);const _=async()=>{c(!0);try{const f=await b.auth.githubStart.mutate();i(f),z(f.verification?.interval)}catch(f){x({show:!0,message:f instanceof Error?f.message:"Failed to start GitHub authentication.",type:"error"})}finally{c(!1)}},D=async()=>{try{await b.auth.githubLogout.mutate(),y(!1),m(null),i({status:"idle"}),x({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{x({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},U=async()=>{k(!0);try{await b.auth.saveGithubAuth.mutate({clientId:d}),I(""),await C(),x({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{x({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},W=async()=>{k(!0);try{await b.auth.saveGithubAuth.mutate({clientId:""}),I(""),await C(),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:N.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&&v?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:v.name||v.login})]}),e(T,{variant:"danger",onClick:D,children:"Sign Out"})]}):e("div",{className:g.signIn,children:e(T,{onClick:_,disabled:o||a.status==="pending",children:o||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(Ne,{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:d,onChange:f=>I(f.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:g.actions,children:[e(T,{onClick:U,disabled:h,children:"Save override"}),e(T,{variant:"secondary",onClick:W,disabled:h,children:"Use dango defaults"})]})]}),e(q,{isOpen:R.show,onClose:()=>x(f=>({...f,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:R.message})}),e(q.Actions,{children:e(T,{onClick:()=>x(f=>({...f,show:!1})),children:"OK"})})]})]})},mt=()=>{const[t,r]=s(!0),[o,c]=s(null),[l,y]=s(!1),[v,m]=s(!1),[a,i]=s(""),[u,p]=s(""),[d,I]=s(""),[h,k]=s(!1),[L,R]=s({show:!1,message:"",type:"info"}),x=async()=>{try{const D=await b.auth.user.query();c(D?.email?D:null)}catch{c(null)}},A=async()=>{try{const[_,D]=await Promise.all([b.auth.configStatus.query(),b.auth.googleAuth.query()]);y(!!_.hasConfig),m(!!(D.hasCustomWorkerUrl||D.hasCustomClientId||D.hasClientSecret))}catch(_){console.error("Failed to fetch config status",_)}};O(()=>{(async()=>{r(!0),await Promise.all([x(),A()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await x(),window.history.replaceState(null,"",window.location.pathname))}catch{}r(!1)})();const D=U=>{U.origin===window.location.origin&&typeof U.data=="object"&&U.data!==null&&U.data.type==="GOOGLE_AUTH_SUCCESS"&&(c(U.data.user),window.location.reload())};return window.addEventListener("message",D),()=>window.removeEventListener("message",D)},[]);const w=async()=>{try{const _=await b.auth.googleLogin.mutate();if(_.authenticated){window.location.reload();return}if(_.url){if(typeof window.DangoBridge<"u"){window.location.href=_.url;return}const U=600,W=700,f=window.innerWidth/2-U/2,Z=window.innerHeight/2-W/2;window.open(_.url,"GoogleAuth",`width=${U},height=${W},top=${Z},left=${f}`)}else throw new Error("Auth URL not available")}catch{R({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},C=async()=>{try{await b.auth.logout.mutate(),c(null),R({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(_){console.error("Sign out failed",_),R({show:!0,message:"Failed to sign out.",type:"error"})}},G=async()=>{k(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:a,clientId:u,clientSecret:d}),i(""),p(""),I(""),await A(),R({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{R({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},z=async()=>{k(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),i(""),p(""),I(""),await A(),R({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{R({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:N.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:C,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:w,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 ",v?"(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:_=>i(_.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:_=>p(_.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:d,onChange:_=>I(_.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:g.actions,children:[e(T,{onClick:G,disabled:h,children:"Save override"}),e(T,{variant:"secondary",onClick:z,disabled:h,children:"Use dango defaults"})]})]}),e(q,{isOpen:L.show,onClose:()=>R(_=>({..._,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:L.message})}),e(q.Actions,{children:e(T,{onClick:()=>R(_=>({..._,show:!1})),children:"OK"})})]})]})},pt="_settingItem_3qq0n_1",ft="_modalOverlay_3qq0n_6",yt="_modal_3qq0n_6",vt="_modalActions_3qq0n_41",bt="_modalSecondary_3qq0n_47",wt="_modalPrimary_3qq0n_57",H={settingItem:pt,modalOverlay:ft,modal:yt,modalActions:vt,modalSecondary:bt,modalPrimary:wt},kt={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"]]}},Ct=(t,r)=>{if(t==null)return r;const o=String(t);return o==="true"||o==="1"?!0:o==="false"||o==="0"?!1:r},me=(t,r,o)=>{const[c,l]=s(r),[y,v]=s(!1),m=ce();return O(()=>{(async()=>{try{const u=await b.settings.getByKey.query({key:t});l(Ct(u.value,r))}catch(u){console.error("Failed to fetch setting",u)}})()},[t,r]),{value:c,setValue:l,isUpdating:y,toggle:async()=>{if(y)return;v(!0);const i=!c;l(i);try{await b.settings.set.mutate({key:t,value:i});for(const u of o)m.invalidateQueries({queryKey:u})}catch(u){console.error("Error saving setting:",u),l(!i)}finally{v(!1)}}}},St=()=>{const{contentType:t}=fe(),r=kt[t],[o,c]=s(!1),[l,y]=s(!0),[v,m]=s(!1),a=me(r.ignoreKey,!0,r.invalidateKeys),i=me(r.listOnlyKey,!1,r.invalidateKeys),[u,p]=s(null),[d,I]=s(!1),h=ce(),k=xe();O(()=>{y(!0),(async()=>{try{const C=await b.settings.getByKey.query({key:r.skipKey});String(C.value)==="true"||String(C.value)==="1"?c(!0):c(!1)}catch(C){console.error("Failed to fetch setting",C)}finally{y(!1)}})()},[r.skipKey]);const L=async()=>{if(v)return;m(!0);const w=!o;c(w);try{await b.settings.set.mutate({key:r.skipKey,value:w})}catch(C){console.error("Error saving setting:",C),c(!w)}finally{m(!1)}},R=async()=>{if(!a.isUpdating){if(a.value)try{let w;if(t==="anime"?w=(await b.continueWatching.adultCount.query()).count:t==="manga"?w=(await b.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await b.asmrProgress.adultCount.query()).count:w=(await b.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){p(w);return}}catch(w){console.error("Failed to fetch adult count",w)}a.toggle()}},x=()=>{p(null),a.toggle()},A=async()=>{if(!d){I(!0);try{let w;t==="anime"?w=(await b.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await b.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await b.asmrProgress.purgeAdult.mutate()).removed:w=(await b.tvProgress.purgeAdult.mutate()).removed,he.success(r.purgeDoneText(w??0));for(const C of r.invalidateKeys)h.invalidateQueries({queryKey:C});t==="anime"&&h.invalidateQueries(k.continueWatching.pathFilter()),t==="manga"&&h.invalidateQueries(k.mangaProgress.pathFilter()),t==="asmr"&&h.invalidateQueries(k.asmrProgress.pathFilter()),t==="tv"&&h.invalidateQueries(k.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),he.error("Failed to remove adult entries")}finally{I(!1),p(null)}a.toggle()}};return l?e("div",{children:"Loading settings..."}):e("div",{className:N.sectionCard,children:[e("h3",{children:r.heading}),e("p",{children:r.blurb}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:r.skipLabel}),e(K,{isChecked:o,onChange:L,id:"skip-confirmation-toggle",disabled:v})]})}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:r.ignoreLabel}),e(K,{isChecked:a.value,onChange:R,id:"ignore-adult-toggle",disabled:a.isUpdating})]})}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:r.listOnlyLabel}),e(K,{isChecked:i.value,onChange:i.toggle,id:"cw-watchlist-only-toggle",disabled:i.isUpdating})]})}),u!==null&&e("div",{className:H.modalOverlay,onClick:()=>p(null),children:e("div",{className:H.modal,onClick:w=>w.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:H.modalActions,children:[e("button",{type:"button",className:H.modalSecondary,onClick:x,disabled:d,children:"Show them"}),e("button",{type:"button",className:H.modalPrimary,onClick:A,disabled:d,children:d?"Purging...":`Purge ${u}`})]})]})})]})},_t="_statsGrid_o4nf0_1",Nt="_statCard_o4nf0_8",Tt="_statLabel_o4nf0_18",It="_statValue_o4nf0_26",Lt="_statMeta_o4nf0_32",Rt="_statusBanner_o4nf0_38",xt="_statusSuccess_o4nf0_49",Pt="_statusUpdating_o4nf0_55",Dt="_statusError_o4nf0_61",At="_sha_o4nf0_67",Ot="_settingItem_o4nf0_74",Gt="_settingTitle_o4nf0_79",Mt="_settingSubtitle_o4nf0_85",zt="_actionsRow_o4nf0_92",P={statsGrid:_t,statCard:Nt,statLabel:Tt,statValue:It,statMeta:Lt,statusBanner:Rt,statusSuccess:xt,statusUpdating:Pt,statusError:Dt,sha:At,settingItem:Ot,settingTitle:Gt,settingSubtitle:Mt,actionsRow:zt},Ut=()=>{const[t,r]=s(null),[o,c]=s(!0),[l,y]=s(!1),[v,m]=s(!1),a=j(null),i=async()=>{try{const h=await b.settings.offlineDbInfo.query();return r(h),h}catch(h){console.error("Failed to fetch offline DB info:",h)}finally{c(!1)}return null};O(()=>(i(),()=>{a.current&&window.clearInterval(a.current)}),[]),O(()=>{t?.isRefreshing?a.current||(a.current=window.setInterval(async()=>{const h=await i();h&&!h.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 h=!t.autoUpdateEnabled;y(!0),r({...t,autoUpdateEnabled:h});try{await b.settings.setOfflineDbAutoUpdate.mutate({enabled:h})}catch(k){console.error("Failed to update auto update setting:",k),r({...t,autoUpdateEnabled:!h})}finally{y(!1)}},p=async()=>{if(!(t?.isRefreshing||v)){m(!0);try{await b.settings.triggerOfflineDbUpdate.mutate(),r(h=>h?{...h,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(h){console.error("Failed to trigger offline DB update:",h)}finally{m(!1)}}},d=h=>{if(!h)return"Never";try{return new Date(h).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return h}},I=t?.isRefreshing||v;return e("div",{className:N.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:P.statsGrid,children:[e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"MAL Mapped"}),e("span",{className:P.statValue,children:o?"-":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Release"}),e("span",{className:P.statMeta,children:o?"-":t?.releaseTag??"Never"})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Checked"}),e("span",{className:P.statMeta,children:o?"-":d(t?.lastCheckedAt??null)})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Updated"}),e("span",{className:P.statMeta,children:o?"-":d(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${P.statusBanner} ${t.lastStatus==="failed"?P.statusError:t.lastStatus==="updating"?P.statusUpdating:P.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:P.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:P.settingItem,children:e("div",{className:N.settingRow,children:[e("div",{children:[e("span",{className:P.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:P.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(K,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:u,disabled:o||l})]})}),e("div",{className:P.actionsRow,children:e(T,{onClick:p,disabled:o||I,children:I?"Updating Database...":"Update Offline Database Now"})})]})},Et="_status_1wbo0_1",qt="_warningText_1wbo0_7",Ft="_ackLabel_1wbo0_11",oe={status:Et,warningText:qt,ackLabel:Ft},Kt=()=>{const t=ce(),[r,o]=s(!1),[c,l]=s(!1),[y,v]=s(!1),[m,a]=s(""),i=()=>{l(!1),a(""),o(!0)},u=()=>{y||(o(!1),l(!1))},p=async()=>{if(!(!c||y)){v(!0),a("");try{const d=await V("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),I=await d.json();if(!d.ok)throw new Error(I.error||"Failed to clear database");const h=I.deleted,k=I.deletedManga,L=I.deletedTv,R=I.deletedAsmr,x=Object.values(h).reduce((G,z)=>G+(z||0),0)+Object.values(k??{}).reduce((G,z)=>G+(z||0),0)+Object.values(L??{}).reduce((G,z)=>G+(z||0),0)+Object.values(R??{}).reduce((G,z)=>G+(z||0),0),A=(k?.manga_library??0)+(k?.manga_progress??0),w=(L?.tv_library??0)+(L?.tv_progress??0),C=(R?.asmr_library??0)+(R?.asmr_progress??0);a(`Library cleared - ${h.watchlist??0} watchlist entries, ${A} manga rows, ${w} TV rows, ${C} ASMR rows and ${x} total rows removed.`),t.invalidateQueries({queryKey:[$.watchlist]}),t.invalidateQueries({queryKey:[$.continueWatching]}),t.invalidateQueries({queryKey:[$.mangaLibrary]}),t.invalidateQueries({queryKey:[$.mangaContinueReading]}),t.invalidateQueries({queryKey:[$.tvLibrary]}),t.invalidateQueries({queryKey:[$.tvContinueWatching]}),t.invalidateQueries({queryKey:[$.asmrLibrary]}),t.invalidateQueries({queryKey:[$.asmrContinueListening]}),o(!1)}catch(d){a(d.message)}finally{v(!1),l(!1)}}};return e("div",{className:`${N.sectionCard} ${N.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"}),m&&e("p",{className:oe.status,children:m}),e(q,{isOpen:r,onClose:u,title:"Clear library data?",width:"sm",children:[e(q.Body,{children:[e("p",{className:oe.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:oe.ackLabel,children:[e("input",{type:"checkbox",checked:c,onChange:d=>l(d.currentTarget.checked),disabled:y}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(q.Actions,{children:[e(T,{variant:"secondary",onClick:u,disabled:y,children:"Cancel"}),e(T,{variant:"danger",onClick:p,disabled:!c||y,children:y?"Clearing...":"Yes, delete everything"})]})]})]})},$t=()=>{const[t,r]=s(""),[o,c]=s([]),[l,y]=s(null),[v,m]=s(!0),[a,i]=s({show:!1,message:"",type:"info"}),u=async()=>{try{m(!0);const d=await b.auth.rcloneSettings.query();r(d.remote||""),c(d.availableRemotes||[]),y(d.activeRemote||null)}catch(d){console.error("Failed to fetch Rclone settings",d)}finally{m(!1)}};O(()=>{u()},[]);const p=async()=>{try{await b.auth.saveRclone.mutate({remote:t}),i({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),u()}catch{i({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return v?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:N.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:d=>r(d.currentTarget.value),children:[e("option",{value:"",children:"(Disabled / None)"}),o.map(d=>e("option",{value:d,children:d},d)),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(q,{isOpen:a.show,onClose:()=>i(d=>({...d,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:a.message})}),e(q.Actions,{children:e(T,{onClick:()=>i(d=>({...d,show:!1})),children:"OK"})})]})]})},Ht=()=>{const[t,r]=s(null),[o,c]=s(!0),l=async()=>{try{const a=await b.auth.syncSettings.query();r(a)}catch(a){console.error("Failed to fetch sync settings",a)}finally{c(!1)}};O(()=>{l()},[]);const y=async a=>{const i=a.currentTarget.value;try{const u=await b.auth.saveSyncProvider.mutate({provider:i});r(p=>p?{...p,activeProvider:u.activeProvider}:null),await l(),ge.success(`Sync provider updated to ${i==="default"?"Default Order":i}`)}catch{ge.error("Failed to update sync provider")}};if(o||!t)return null;const v=[{value:"default",label:"Default (Priority Based)"}];t.authenticatedProviders.github&&v.push({value:"github",label:"GitHub"}),t.authenticatedProviders.google&&v.push({value:"google",label:"Google Drive"}),t.authenticatedProviders.rclone&&v.push({value:"rclone",label:"Rclone"}),v.push({value:"none",label:"None (Local Only)"});const m=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:N.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:m(t.actualActiveProvider)})]}),e("div",{className:N.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:t.activeProvider,onChange:y,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:v.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function Wt(){return"javascript:"+encodeURIComponent(`(function(){
|
|
2
|
+
if(!/(^|\\.)discord\\.com$/.test(location.hostname)){alert('Dango: use this bookmarklet while on discord.com');return}
|
|
3
|
+
var t=null;
|
|
4
|
+
try{
|
|
5
|
+
window.webpackChunkdiscord_app.push([[Symbol()],{},function(req){
|
|
6
|
+
if(!req.c)return;
|
|
7
|
+
var ms=Object.values(req.c);
|
|
8
|
+
for(var i=0;i<ms.length;i++){var m=ms[i];
|
|
9
|
+
try{
|
|
10
|
+
if(!m.exports||m.exports===window)continue;
|
|
11
|
+
if(typeof m.exports.getToken==='function'){var x=m.exports.getToken();if(x){t=x;return}}
|
|
12
|
+
for(var k in m.exports){try{var ex=m.exports[k];if(ex&&typeof ex.getToken==='function'&&ex[Symbol.toStringTag]!=='IntlMessagesProxy'){var y=ex.getToken();if(y){t=y;return}}}catch(e1){}}
|
|
13
|
+
}catch(e2){}}
|
|
14
|
+
}]);
|
|
15
|
+
window.webpackChunkdiscord_app.pop();
|
|
16
|
+
}catch(e3){}
|
|
17
|
+
if(!t){alert('Dango: could not grab your token. Make sure you are logged in to Discord in this tab, then run the bookmarklet again.');return}
|
|
18
|
+
function copyFallback(){var a=document.createElement('textarea');a.value=t;a.style.position='fixed';a.style.opacity='0';document.body.appendChild(a);a.select();try{document.execCommand('copy')}catch(e4){}document.body.removeChild(a)}
|
|
19
|
+
var done=function(){window.close();setTimeout(function(){if(!window.closed){alert('Dango: token copied to clipboard! Could not close this tab, so just close it, go back to Dango Settings, paste the token and press Save.')}},250)};
|
|
20
|
+
if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(t).then(done,function(){copyFallback();done()})}else{copyFallback();done()}
|
|
21
|
+
})()`)}const Bt=()=>{const t=Te(Wt,[]);return e("div",{style:{marginTop:"0.9rem",paddingTop:"0.9rem",borderTop:"1px dashed var(--border-color)"},children:[e("h4",{style:{margin:"0 0 0.35rem",fontSize:"0.95rem"},children:"Grab the token automatically (bookmarklet)"}),e("p",{style:{margin:"0 0 0.6rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Set this up once and you never have to dig through DevTools: the bookmarklet copies your Discord token to the clipboard and closes the Discord tab - then you just paste it above and press Save."}),e("ol",{style:{margin:"0 0 0.75rem",paddingLeft:"1.25rem",fontSize:"0.85rem",color:"var(--text-secondary)",display:"grid",gap:"0.3rem"},children:[e("li",{children:["Drag the ",e("strong",{style:{color:"var(--text-primary)"},children:"Dango Token Grabber"})," ","button below onto your bookmarks bar (press ",e("kbd",{children:"Ctrl"}),"+",e("kbd",{children:"Shift"}),"+",e("kbd",{children:"B"})," ","first if the bar is hidden)."]}),e("li",{children:["Click ",e("strong",{style:{color:"var(--text-primary)"},children:"Open Discord"})," and log in (skip this if you are already logged in)."]}),e("li",{children:["On the Discord tab, click the"," ",e("strong",{style:{color:"var(--text-primary)"},children:"Dango Token Grabber"})," bookmark. The token lands in your clipboard and the tab closes on its own - come back here, paste it above and press ",e("strong",{children:"Save"}),"."]})]}),e("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",flexWrap:"wrap"},children:[e("a",{href:t,onClick:c=>{c.preventDefault(),alert("Drag this button onto your bookmarks bar instead of clicking it, then click it while you are on discord.com.")},title:"Drag me to your bookmarks bar",draggable:!0,style:{display:"inline-flex",alignItems:"center",padding:"0.4rem 0.8rem",borderRadius:"999px",border:"1px dashed var(--accent)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:"0.85rem",textDecoration:"none",cursor:"grab",userSelect:"none"},children:[e(X,{name:"bookmark",style:{marginRight:"0.45rem",color:"var(--accent)"}}),"Dango Token Grabber"]}),e("a",{className:"btn btn-secondary btn-sm",href:"https://discord.com/channels/@me",target:"_blank",rel:"noopener noreferrer",children:"Open Discord"}),e(T,{variant:"ghost",size:"sm",onClick:async()=>{try{await navigator.clipboard.writeText(t),alert('Bookmarklet code copied. Create a new bookmark on your bookmarks bar, name it "Dango Token" and paste the code as its URL.')}catch{alert(`Could not copy automatically. Right-click the "Dango Token Grabber" button and choose "Copy link address" instead, then paste that into a new bookmark's URL.`)}},children:"Copy code"})]}),e("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:`"Copy code" is a fallback for browsers that won't drag bookmarklets: create any bookmark, then paste the copied code as its URL.`})]})},Vt="_settingItem_68mz3_1",jt="_field_68mz3_6",Qt="_input_68mz3_19",Yt="_actions_68mz3_39",Jt="_status_68mz3_45",E={settingItem:Vt,field:jt,input:Qt,actions:Yt,status:Jt},Xt=()=>{const[t,r]=s(!1),[o,c]=s(""),[l,y]=s(""),[v,m]=s(!0),[a,i]=s(!1),[u,p]=s("");O(()=>{(async()=>{try{const R=await(await V("/api/auth/app-status")).json();r(R.hasPassword)}catch{console.error("Failed to fetch LAN auth status")}finally{m(!1)}})()},[]);const d=async()=>{if(p(""),o!==l){p("Passwords do not match");return}if(o.length<4){p("Password must be at least 4 characters");return}i(!0);try{const k=await V("/api/auth/app-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:o})}),L=await k.json();if(!k.ok){p(L.error||"Failed to update password");return}r(L.hasPassword),c(""),y(""),p(L.hasPassword?"Password set successfully":"Password removed")}catch{p("Network error")}finally{i(!1)}},I=async()=>{i(!0);try{const k=await V("/api/auth/app-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:""})}),L=await k.json();if(!k.ok){p(L.error||"Failed to remove password");return}r(!1),c(""),y(""),p("Password removed")}catch{p("Network error")}finally{i(!1)}},h=async()=>{i(!0);try{await V("/api/auth/app-logout",{method:"POST"}),p("Logged out"),window.location.reload()}catch{p("Logout failed")}finally{i(!1)}};return v?e("div",{className:N.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:N.sectionCard,children:[e("h3",{children:"LAN Lock"}),e("p",{children:"Require a password to access this instance from any device, including this one. Sessions persist across server restarts until logout or password change."}),e("div",{className:E.settingItem,children:[e("div",{className:E.field,children:[e("label",{htmlFor:"lan-password",children:"New Password"}),e("input",{id:"lan-password",type:"password",value:o,onChange:k=>c(k.currentTarget.value),placeholder:t?"Leave empty to keep current password":"Enter a password...",className:E.input})]}),e("div",{className:E.field,children:[e("label",{htmlFor:"lan-confirm-password",children:"Confirm Password"}),e("input",{id:"lan-confirm-password",type:"password",value:l,onChange:k=>y(k.currentTarget.value),placeholder:"Confirm password...",className:E.input})]}),e("div",{className:E.actions,children:[e(T,{variant:"primary",onClick:d,loading:a,disabled:a,children:t?"Update Password":"Set Password"}),t&&e(T,{variant:"danger",onClick:h,loading:a,disabled:a,children:"Logout"}),t&&e(T,{variant:"secondary",onClick:I,loading:a,disabled:a,children:"Remove Password"})]}),u&&e("p",{className:E.status,children:u})]})]})},Zt=()=>{const[t,r]=s(""),[o,c]=s(!0),[l,y]=s(!1),[v,m]=s("");O(()=>{Pe("/api/auth/app-status").then(i=>r(String(i.port??3e3))).catch(()=>m("Failed to load current port")).finally(()=>c(!1))},[]);const a=async()=>{const i=Number(t);if(!Number.isInteger(i)||i<1||i>65535){m("Enter a port between 1 and 65535");return}y(!0),m("");try{await b.auth.setServerPort.mutate({port:i}),m(`Saved. Restart dango, then open http://localhost:${i} - this overrides the PORT environment variable.`)}catch(u){m(u.message)}finally{y(!1)}};return o?e("div",{className:N.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:N.sectionCard,children:[e("h3",{children:"Server Port"}),e("p",{children:"Port the backend listens on. Takes effect after a restart. Google and AniList sign-in need the matching redirect URI registered with the provider."}),e("div",{className:E.settingItem,children:[e("div",{className:E.field,children:[e("label",{htmlFor:"server-port",children:"Port"}),e("input",{id:"server-port",type:"number",min:1,max:65535,value:t,onChange:i=>r(i.currentTarget.value),className:E.input})]}),e("div",{className:E.actions,children:e(T,{variant:"primary",onClick:a,loading:l,disabled:l,children:"Save Port"})}),v&&e("p",{className:E.status,children:v})]})]})},ea=()=>{const{theme:t,setTheme:r,loading:o}=De();return e("div",{children:[e("h4",{style:{margin:"0 0 0.25rem",fontSize:"1rem"},children:"Palette"}),e("p",{style:{margin:"0 0 0.75rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Taro is the default. Pick a palette that suits you."}),e("div",{role:"radiogroup","aria-label":"Palette",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"0.6rem"},children:Ae.map(c=>{const l=t===c.id;return e("button",{role:"radio","aria-checked":l,disabled:o,onClick:()=>r(c.id),style:{display:"flex",gap:"0.6rem",alignItems:"center",textAlign:"left",padding:"0.65rem 0.75rem",borderRadius:"10px",cursor:"pointer",background:l?"var(--accent-subtle)":"var(--bg-tertiary)",border:l?"1px solid var(--accent)":"1px solid var(--border-primary)",color:"var(--text-primary)"},children:[e("span",{"aria-hidden":!0,style:{width:26,height:26,borderRadius:"50%",flex:"none",background:c.swatch,border:"1px solid rgba(0,0,0,0.35)"}}),e("span",{style:{minWidth:0},children:[e("span",{style:{display:"block",fontSize:"0.85rem",fontWeight:700},children:c.label}),e("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.blurb})]})]},c.id)})})]})};function ta({variant:t="info",children:r,className:o=""}){return e("div",{className:`alert alert-${t} ${o}`,children:r})}const aa={anime:"Watchlist",manga:"Reading List",tv:"TV Watchlist",asmr:"Listening List"},la=()=>{const[t,r]=Ie(),{contentType:o}=fe(),c=t.get("tab"),[l,y]=s(c&&["general","sync","watchlist","database"].includes(c)?c:"general"),[v,m]=s(""),a=j(null),i=j(null),u=j(new Map),[p,d]=s({top:0,height:0,left:0,width:0}),{lowEndMode:I,setLowEndMode:h}=Oe(),{hasConsent:k,revoke:L}=Ge(),[R,x]=s(Me),[A,w]=s(!0),{data:C}=ne("discordRPCEnabled"),G=pe(),[z,_]=s(!0),{data:D}=ne("dangoGaze"),[U,W]=s(!0),{data:f}=ne("discordRPCHideMature"),[Z,ee]=s(""),[Q,ae]=s(null);O(()=>{b.discord.gatewayStatus.query().then(n=>{ae(n),n.masked&&n.masked!=="none"&&ee(n.masked)}).catch(()=>{})},[]),O(()=>{C!==void 0&&w(C==="true"||C===!0||C===null)},[C]),O(()=>{f!==void 0&&W(f==="true"||f===!0||f===null)},[f]);const ye=n=>{w(n),G.mutate({key:"discordRPCEnabled",value:String(n)})};O(()=>{D!==void 0&&_(D!=="false"&&D!==!1)},[D]);const ve=n=>{_(n),G.mutate({key:"dangoGaze",value:String(n)})},be=n=>{W(n),G.mutate({key:"discordRPCHideMature",value:String(n)})},we=n=>{x(n),localStorage.setItem(ze,String(n)),window.dispatchEvent(new CustomEvent(Ue))};ue.useEffect(()=>{document.title="Settings - dango"},[]),ue.useEffect(()=>{const n=t.get("tab");n&&["general","sync","watchlist","database"].includes(n)&&y(n)},[t]);const te=n=>{y(n),r(n==="general"?{}:{tab:n})},Y=le(()=>{const n=u.current.get(l),M=i.current;if(n&&M){const B=M.getBoundingClientRect(),F=n.getBoundingClientRect(),J=window.matchMedia("(max-width: 900px)").matches;d(J?{top:F.top-B.top,height:F.height,left:F.left-B.left,width:F.width}:{top:F.top-B.top,height:F.height,left:0,width:0})}},[l]);Le(()=>{Y()},[l,Y]),O(()=>{const n=()=>Y();window.addEventListener("resize",n);let M=!1;return document.fonts?.ready&&document.fonts.ready.then(()=>{M||Y()}),()=>{M=!0,window.removeEventListener("resize",n)}},[l,Y]);const ke=()=>{m("Exporting databases...");const n=window.DangoBridge;if(n?.downloadFile){n.downloadFile("/api/backup-db","dango-backup.json"),setTimeout(()=>{m("Databases exported successfully!")},1500);return}const M=document.createElement("a");M.href="/api/backup-db",M.download="dango-backup.json",document.body.appendChild(M),M.click(),M.remove(),setTimeout(()=>{m("Databases exported successfully!")},1500)},Ce=async n=>{const M=n.currentTarget.files?.[0];if(!M)return;m("Importing databases...");const B=new FormData;B.append("dbfile",M);try{const F=await V("/api/restore-db",{method:"POST",body:B}),J=await F.json();if(F.ok){const de=Array.isArray(J.restored)?J.restored.join(", "):null;m(de?`Databases imported successfully (${de})!`:"Database imported successfully!"),setTimeout(()=>window.location.reload(),2e3)}else m(`Import failed: ${J.error}`)}catch{m("Import failed: An unexpected error occurred.")}finally{n.currentTarget.value=""}},Se=()=>{a.current?.click()},_e=()=>{switch(l){case"general":return e("div",{className:S.tabContent,children:e("div",{className:N.sectionCard,children:[e("h3",{children:"Appearance & Preferences"}),e("p",{children:"Configure how titles are displayed and other general preferences."}),e("div",{className:S.settingItem,children:e(Ee,{})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e(ea,{})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Low End Mode"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Disables animations and heavy visual effects for better performance on older hardware."})]}),e(K,{isChecked:I,onChange:n=>h(n.currentTarget.checked),id:"low-end-mode"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Dango Animations"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Lets the dango logo look around, blink and react when you pet it. Always off in Low End Mode."})]}),e(K,{isChecked:z,onChange:n=>ve(n.currentTarget.checked),id:"dango-gaze"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Virtual Keyboard"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Shows an on-screen keyboard when text search fields are focused."})]}),e(K,{isChecked:R,onChange:n=>we(n.currentTarget.checked),id:"virtual-keyboard-enabled"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Discord Rich Presence"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Show your current anime and watch progress on your Discord profile status."})]}),e(K,{isChecked:A,onChange:n=>ye(n.currentTarget.checked),id:"discord-rpc-enabled"})]})}),e("div",{style:{marginTop:"2rem"},children:e(Xt,{})}),e("div",{style:{marginTop:"2rem"},children:e(Zt,{})}),A&&e("div",{className:S.settingItem,style:{marginTop:"1rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Hide Mature Content"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Hide mature content (18+) from Discord Rich Presence."})]}),e(K,{isChecked:U,onChange:n=>be(n.currentTarget.checked),id:"discord-hide-mature"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem",background:"var(--bg-tertiary)",padding:"1rem",borderRadius:"8px",border:"1px solid var(--border-color)"},children:[e("div",{className:N.settingRow,children:e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Discord Mobile Presence (Gateway)"}),e("p",{style:{margin:"0.25rem 0 0.75rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Paste your Discord authentication token to enable presence on mobile devices. If no token is saved, the default desktop Rich Presence is used. The token is stored locally in your configuration and never shared."})]})}),e(ta,{variant:"warning",style:{marginTop:"1.25rem",paddingTop:"1.25rem"},children:[e("strong",{children:"Use at your own risk."})," This feature uses the Discord Gateway API with your user token, which violates Discord's Terms of Service. Discord may detect this usage and take action against your account, including phone number locks, temporary suspensions, or permanent bans. While the risk is generally low, it is not zero. Only use this if you understand and accept the risks."]}),e("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem",alignItems:"center",flexWrap:"wrap"},children:[e("input",{type:"password",value:Z,onChange:n=>ee(n.currentTarget.value),placeholder:"Paste Discord token here...",style:{flex:"1 1 200px",padding:"0.5rem",borderRadius:"4px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)",fontFamily:"monospace",minWidth:0}}),e(T,{variant:"primary",size:"sm",onClick:async()=>{try{const n=await b.discord.gatewaySave.mutate({token:Z});ae({hasToken:!0,masked:n.masked,enabled:!0}),ee(n.masked)}catch(n){alert(n instanceof Error?n.message:"Failed to save token")}},children:"Save"}),e(T,{variant:"secondary",size:"sm",onClick:async()=>{await b.discord.gatewayRemove.mutate().catch(()=>{}),ee(""),ae({hasToken:!1,masked:null,enabled:!1})},children:"Remove"})]}),Q&&e("p",{style:{marginTop:"0.5rem",fontSize:"0.8rem",color:Q.hasToken?"green":"var(--text-secondary)"},children:["Status:"," ",Q.hasToken?`Token saved (${Q.masked})`:"No token saved",Q.enabled?" - Gateway active":""]}),e(Bt,{})]}),k&&e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Mature Content"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"You have previously agreed to view 18+ content. Toggle this off to re-enable the blur gate and filtering."})]}),e(K,{isChecked:!0,onChange:n=>{n.currentTarget.checked||(L(),window.location.reload())},id:"mature-content-enabled"})]})})]})});case"sync":return e("div",{className:S.tabContent,children:[e(Ht,{}),e(gt,{}),e(mt,{}),e($t,{})]});case"watchlist":return e("div",{className:S.tabContent,children:e(St,{})});case"database":return e("div",{className:S.tabContent,children:[e("div",{className:N.sectionCard,children:[e("h3",{children:"Database Management"}),e("p",{children:"Download a backup of all databases (anime, manga, TV and ASMR) or restore from a backup file. Legacy single-file anime (.db) backups can still be restored."}),e("div",{className:S.controls,children:[e(T,{onClick:ke,children:"Backup Database"}),e(T,{variant:"secondary",onClick:Se,children:"Restore Database"})]}),e("input",{type:"file",ref:a,onChange:Ce,style:{position:"absolute",width:1,height:1,opacity:0,overflow:"hidden"},accept:".json,.db,application/octet-stream"}),v&&e("p",{className:S.status,children:v})]}),e(Ut,{}),e(Kt,{})]});default:return null}};return e("div",{className:"page-container",children:[e("div",{className:S.settingsHeader,children:[e("h1",{className:S.pageTitle,children:"Settings"}),e("p",{className:S.pageSubtitle,children:"Manage your preferences and data synchronization"})]}),e("div",{className:S.settingsLayout,children:[e("aside",{className:S.sidebar,ref:i,children:[e("div",{className:S.sidebarIndicator,style:{top:p.top,height:p.height,left:p.left,...p.width?{width:p.width}:{}}}),e("button",{ref:n=>{n&&u.current.set("general",n)},className:`${S.sidebarItem} ${l==="general"?S.active:""}`,onClick:()=>te("general"),children:[e(X,{name:"cog"})," ",e("span",{children:"General"})]}),e("button",{ref:n=>{n&&u.current.set("sync",n)},className:`${S.sidebarItem} ${l==="sync"?S.active:""}`,onClick:()=>te("sync"),children:[e(X,{name:"cloud"})," ",e("span",{children:"Synchronization"})]}),e("button",{ref:n=>{n&&u.current.set("watchlist",n)},className:`${S.sidebarItem} ${l==="watchlist"?S.active:""}`,onClick:()=>te("watchlist"),children:[e(X,{name:"list"})," ",e("span",{children:aa[o]})]}),e("button",{ref:n=>{n&&u.current.set("database",n)},className:`${S.sidebarItem} ${l==="database"?S.active:""}`,onClick:()=>te("database"),children:[e(X,{name:"database"})," ",e("span",{children:"Database"})]})]}),e("main",{className:S.mainContent,children:e("div",{className:S.tabContent,children:_e()},l)})]})]})};export{la as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._title-preference-container_sdqgs_1{margin-bottom:var(--space-6);padding:var(--space-4);border:1px solid var(--border-primary);border-radius:var(--radius-md);background-color:var(--bg-tertiary)}._title-preference-container_sdqgs_1 h4{margin-top:0;margin-bottom:var(--space-4);color:var(--text-primary);font-size:var(--font-size-base);font-weight:var(--font-weight-semibold)}._error_sdqgs_17{color:var(--danger)}._toggle-button_sdqgs_21{position:relative;width:200px;height:40px;background:linear-gradient(135deg,var(--accent) 0%,var(--accent-dark) 100%);border:none;border-radius:20px;cursor:pointer;overflow:hidden;display:flex;align-items:center;justify-content:center;color:var(--accent-text);font-size:var(--font-size-base);font-weight:var(--font-weight-semibold);transition:var(--transition-base);box-shadow:var(--shadow-md)}._toggle-button_sdqgs_21:hover:not(:disabled){transform:translateY(-2px);box-shadow:var(--shadow-lg);filter:brightness(1.1)}._toggle-button_sdqgs_21:disabled{opacity:.7;cursor:not-allowed}._toggle-label_sdqgs_51{position:absolute;white-space:nowrap;transition:var(--transition-base)}._settingsHeader_ik3bf_1{margin-bottom:var(--space-8);animation:_fadeIn_ik3bf_1 .8s var(--ease-smooth)}._pageTitle_ik3bf_6{font-size:var(--font-size-xl);font-weight:800;color:var(--text-primary);margin:0 0 var(--space-2);letter-spacing:-.02em}._pageSubtitle_ik3bf_14{color:var(--text-tertiary);font-size:var(--font-size-sm);margin:0}._settingsLayout_ik3bf_20{display:flex;gap:var(--space-8);align-items:flex-start;animation:_slideUpIn_ik3bf_1 .8s var(--ease-smooth)}._sidebar_ik3bf_27{width:240px;display:flex;flex-direction:column;gap:var(--space-2);position:relative}._sidebarIndicator_ik3bf_35{position:absolute;left:0;right:0;border-radius:var(--radius-lg);background:var(--accent);transition:top .22s cubic-bezier(.2,1.2,.3,1),height .22s cubic-bezier(.2,1.2,.3,1),left .22s cubic-bezier(.2,1.2,.3,1),width .22s cubic-bezier(.2,1.2,.3,1);z-index:0;pointer-events:none}._sidebarItem_ik3bf_50{display:flex;align-items:center;gap:var(--space-3);padding:var(--space-4) var(--space-5);background:transparent;border:1px solid transparent;border-radius:var(--radius-lg);color:var(--text-tertiary);font-weight:600;font-size:var(--font-size-sm);cursor:pointer;transition:color .22s ease;text-align:left;position:relative;z-index:1}._sidebarItem_ik3bf_50:hover{color:var(--text-primary)}._sidebarItem_ik3bf_50._active_ik3bf_72{color:var(--accent-text)}._sidebarItem_ik3bf_50 svg{font-size:1.1rem}._mainContent_ik3bf_80{flex:1;min-width:0}._tabContent_ik3bf_85{display:flex;flex-direction:column;gap:var(--space-6);animation:_tabFadeIn_ik3bf_1 .3s ease}@keyframes _tabFadeIn_ik3bf_1{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}._settingItem_ik3bf_103{border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._controls_ik3bf_108{display:flex;gap:var(--space-4);flex-wrap:wrap}._status_ik3bf_114{margin-top:var(--space-4);padding:var(--space-3) var(--space-4);background:color-mix(in srgb,var(--accent) 10%,transparent);border-radius:var(--radius-md);color:var(--accent-light);font-size:var(--font-size-sm);font-weight:500}@keyframes _fadeIn_ik3bf_1{0%{opacity:0}to{opacity:1}}@keyframes _slideUpIn_ik3bf_1{0%{opacity:0;transform:translateY(30px)}to{opacity:1;transform:translateY(0)}}@media(max-width:900px){._settingsLayout_ik3bf_20{flex-direction:column}._sidebar_ik3bf_27{width:100%;flex-direction:row;overflow-x:auto;padding-bottom:var(--space-2)}._sidebarIndicator_ik3bf_35{right:auto;top:auto!important;bottom:0;height:3px!important}._sidebarItem_ik3bf_50{padding:var(--space-3) var(--space-4);white-space:nowrap;flex-shrink:0}._sidebarItem_ik3bf_50 span{display:block}}@media(max-width:480px){._sidebarItem_ik3bf_50 span{display:none}._sidebarItem_ik3bf_50{padding:var(--space-4);justify-content:center}}._sectionCard_tm30b_1{background:var(--glass-bg);backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);border:1px solid var(--glass-border);padding:var(--space-8);border-radius:var(--radius-xl);box-shadow:var(--glass-shadow)}._title_tm30b_11{margin:0 0 var(--space-2);font-size:var(--font-size-lg);font-weight:700;color:var(--text-primary)}._signIn_tm30b_18{color:var(--text-secondary);font-size:var(--font-size-sm);margin:0 0 var(--space-6);line-height:1.6}._userInfo_tm30b_25{padding:var(--space-4) var(--space-5);background:color-mix(in srgb,var(--color-success) 5%,transparent);border:1px solid color-mix(in srgb,var(--color-success) 20%,transparent);border-radius:var(--radius-lg);margin-bottom:var(--space-6);display:flex;align-items:center;justify-content:space-between;gap:var(--space-4)}._userInfo_tm30b_25 p{margin:0;color:var(--text-secondary);font-size:var(--font-size-sm)}._userInfo_tm30b_25 strong{color:var(--color-success)}._warning_tm30b_47{color:var(--color-warning);font-size:var(--font-size-xs);margin:var(--space-3) 0 0;font-weight:500}._formGroup_tm30b_54{margin-bottom:var(--space-5)}._label_tm30b_58{display:block;margin-bottom:var(--space-2);color:var(--text-tertiary);font-size:.7rem;font-weight:700;text-transform:uppercase;letter-spacing:.05em}._inputWrapper_tm30b_68{display:flex;gap:var(--space-2)}._input_tm30b_68{flex-grow:1;height:48px;padding:0 var(--space-4);background:var(--bg-tertiary);color:var(--text-primary);border:1px solid var(--border-primary);border-radius:var(--radius-lg);font-size:var(--font-size-base);transition:all var(--transition-fast)}._input_tm30b_68:focus{outline:none;border-color:var(--accent);background:var(--bg-elevated);box-shadow:0 0 0 4px var(--accent-glow)}._select_tm30b_92{flex-grow:1;height:48px;padding:0 var(--space-4);background:var(--bg-tertiary);color:var(--text-primary);border:1px solid var(--border-primary);border-radius:var(--radius-lg);font-size:var(--font-size-base);cursor:pointer;transition:all var(--transition-fast);appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2371717a' stroke-width='2' viewBox='0 0 12 12'%3E%3Cpolyline points='3 5 6 8 9 5'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 1rem center}._actions_tm30b_109{display:flex;gap:var(--space-3);margin-top:var(--space-6);border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._hr_tm30b_117{border:none;border-top:1px solid var(--border-primary);margin:var(--space-8) 0}@media(max-width:600px){._userInfo_tm30b_25{flex-direction:column;align-items:flex-start}._actions_tm30b_109{flex-direction:column}}._sectionCard_1axuo_1{background:var(--bg-tertiary);border:1px solid var(--border-secondary);border-radius:var(--radius-lg);padding:var(--space-5);margin-bottom:var(--space-4)}._sectionCard_1axuo_1 h3{margin:0 0 var(--space-3);font-size:var(--font-size-base);font-weight:700;color:var(--text-primary)}._sectionCard_1axuo_1 p{margin:0 0 var(--space-3);font-size:var(--font-size-sm);color:var(--text-secondary);line-height:1.5}._dangerCard_1axuo_23{border-color:color-mix(in srgb,var(--color-danger) 40%,transparent)}._dangerCard_1axuo_23 h3{color:var(--color-danger)}._settingRow_1axuo_31{display:flex;align-items:center;justify-content:space-between;gap:var(--space-4);padding:var(--space-3) 0;border-bottom:1px solid var(--border-secondary)}._settingRow_1axuo_31:last-child{border-bottom:none}._settingRow_1axuo_31 label{display:flex;flex-direction:column;gap:var(--space-1);font-size:var(--font-size-sm);color:var(--text-primary)}._settingItem_3qq0n_1{border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._modalOverlay_3qq0n_6{position:fixed;inset:0;background:#0009;display:flex;align-items:center;justify-content:center;z-index:1000;padding:var(--space-4)}._modal_3qq0n_6{background:var(--bg-secondary, #1a1a2e);border:1px solid var(--glass-border);border-radius:var(--radius-xl);padding:var(--space-8);max-width:420px;width:100%;box-shadow:var(--glass-shadow)}._modal_3qq0n_6 h4{margin:0 0 var(--space-2);font-size:var(--font-size-lg);font-weight:700;color:var(--text-primary)}._modal_3qq0n_6 p{color:var(--text-secondary);font-size:var(--font-size-sm);line-height:1.6;margin:0 0 var(--space-6)}._modalActions_3qq0n_41{display:flex;justify-content:flex-end;gap:var(--space-3)}._modalSecondary_3qq0n_47{background:transparent;border:1px solid var(--border-primary);color:var(--text-primary);border-radius:var(--radius-md);padding:var(--space-2) var(--space-4);cursor:pointer;font-size:var(--font-size-sm)}._modalPrimary_3qq0n_57{background:var(--accent, var(--color-danger));border:none;color:var(--accent-text, var(--color-danger-text));border-radius:var(--radius-md);padding:var(--space-2) var(--space-4);cursor:pointer;font-size:var(--font-size-sm);font-weight:600}._modalSecondary_3qq0n_47:disabled,._modalPrimary_3qq0n_57:disabled{opacity:.6;cursor:default}._statsGrid_o4nf0_1{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:var(--space-3);margin-bottom:var(--space-4)}._statCard_o4nf0_8{background:var(--bg-tertiary);border:1px solid var(--border-primary);border-radius:var(--radius-md);padding:var(--space-4);display:flex;flex-direction:column;gap:var(--space-1)}._statLabel_o4nf0_18{font-size:var(--font-size-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--text-tertiary);font-weight:600}._statValue_o4nf0_26{font-size:var(--font-size-xl);font-weight:700;color:var(--text-primary)}._statMeta_o4nf0_32{font-size:var(--font-size-sm);font-weight:500;color:var(--text-primary)}._statusBanner_o4nf0_38{display:flex;align-items:center;gap:var(--space-2);padding:var(--space-3) var(--space-4);border-radius:var(--radius-md);font-size:var(--font-size-sm);margin-bottom:var(--space-4);flex-wrap:wrap}._statusSuccess_o4nf0_49{background:color-mix(in srgb,var(--color-success, #22c55e) 10%,transparent);border:1px solid color-mix(in srgb,var(--color-success, #22c55e) 25%,transparent);color:var(--text-primary)}._statusUpdating_o4nf0_55{background:#6366f11a;border:1px solid rgba(99,102,241,.3);color:var(--text-primary)}._statusError_o4nf0_61{background:color-mix(in srgb,var(--color-danger) 10%,transparent);border:1px solid color-mix(in srgb,var(--color-danger) 20%,transparent);color:var(--text-primary)}._sha_o4nf0_67{margin-left:auto;font-family:monospace;font-size:var(--font-size-xs);color:var(--text-tertiary)}._settingItem_o4nf0_74{border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._settingTitle_o4nf0_79{font-weight:600;color:var(--text-primary);font-size:var(--font-size-sm)}._settingSubtitle_o4nf0_85{font-size:var(--font-size-sm);color:var(--text-secondary);margin-top:var(--space-1);line-height:1.5}._actionsRow_o4nf0_92{margin-top:var(--space-6);display:flex;gap:var(--space-3)}._status_1wbo0_1{margin-top:var(--space-4);font-size:var(--font-size-sm);color:var(--text-primary)}._warningText_1wbo0_7{margin:0 0 var(--space-4)!important}._ackLabel_1wbo0_11{display:flex;align-items:flex-start;gap:var(--space-2);font-size:var(--font-size-sm);color:var(--text-primary);cursor:pointer}._ackLabel_1wbo0_11 input{margin-top:2px}._settingItem_68mz3_1{border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._field_68mz3_6{display:flex;flex-direction:column;gap:.5rem;margin-bottom:var(--space-4)}._field_68mz3_6 label{font-size:.9rem;color:var(--text-secondary);font-weight:500}._input_68mz3_19{background:var(--bg-secondary);border:1px solid var(--border-primary);color:var(--text-primary);padding:.6rem;border-radius:4px;width:100%;max-width:400px}._input_68mz3_19:hover{border-color:var(--border-secondary)}._input_68mz3_19:focus{outline:none;border-color:var(--accent);box-shadow:var(--shadow-input-focus)}._actions_68mz3_39{display:flex;gap:var(--space-3);flex-wrap:wrap}._status_68mz3_45{margin-top:var(--space-4);padding:var(--space-3) var(--space-4);background:color-mix(in srgb,var(--accent) 10%,transparent);border-radius:var(--radius-md);color:var(--accent-light);font-size:var(--font-size-sm);font-weight:500}.alert{display:flex;align-items:flex-start;gap:var(--space-3);padding:var(--space-4);border-radius:var(--radius-md);font-size:var(--font-size-sm);border:1px solid transparent}.alert-info{background:color-mix(in srgb,var(--accent) 10%,transparent);border-color:var(--accent);color:var(--text-primary)}.alert-success{background:color-mix(in srgb,var(--color-success) 10%,transparent);border-color:var(--color-success);color:var(--color-success)}.alert-warning{background:color-mix(in srgb,var(--color-warning) 10%,transparent);border-color:var(--color-warning);color:var(--color-warning)}.alert-error{background:color-mix(in srgb,var(--color-danger) 10%,transparent);border-color:var(--color-danger);color:var(--color-danger)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as o,g as r}from"./vendor-core-DfaOB3Rn.js";import{u as l}from"./index-
|
|
1
|
+
import{u as o,g as r}from"./vendor-core-DfaOB3Rn.js";import{u as l}from"./index-DlcgJVM6.js";const a="_skeletonCard_qtypb_1",i="_poster_qtypb_11",d="_line_qtypb_20",c="_info_qtypb_38",_="_short_qtypb_54",m="_lowEnd_qtypb_69",e={skeletonCard:a,poster:i,line:d,"skeleton-wave":"_skeleton-wave_qtypb_1",info:c,short:_,lowEnd:m},p=({layout:n="vertical"})=>{const{lowEndMode:t}=l();return o("div",{className:`${e.skeletonCard} ${e[n]} ${t?e.lowEnd:""}`,children:[o("div",{className:e.poster}),o("div",{className:e.info,children:[o("div",{className:e.line}),o("div",{className:`${e.line} ${e.short}`})]})]})},v=({count:n=14,layout:t="vertical"})=>o("div",{className:"grid-container",children:Array.from({length:n}).map((k,s)=>o(p,{layout:t},s))}),w=r.memo(v);export{p as A,w as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._header_yx26o_1{margin-bottom:var(--space-8);animation:_fadeIn_yx26o_1 .8s var(--ease-smooth)}._pageTitle_yx26o_6{font-size:var(--font-size-xl);font-weight:800;color:var(--text-primary);margin:0 0 var(--space-2);letter-spacing:-.02em}._pageSubtitle_yx26o_14{color:var(--text-tertiary);font-size:var(--font-size-sm);margin:0}._importCard_yx26o_20{background:var(--glass-bg);backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);border:1px solid var(--glass-border);padding:var(--space-8);border-radius:var(--radius-xl);box-shadow:var(--glass-shadow);max-width:600px;margin:0 auto;animation:_slideUpIn_yx26o_1 .8s var(--ease-smooth)}._importCard_yx26o_20+._importCard_yx26o_20{margin-top:var(--space-6)}._cardHeader_yx26o_37{margin-bottom:var(--space-6)}._cardHeader_yx26o_37 h3{margin:0 0 var(--space-2);font-size:var(--font-size-lg);font-weight:700;color:var(--text-primary)}._cardHeader_yx26o_37 p{color:var(--text-secondary);font-size:var(--font-size-sm);margin:0;line-height:1.6}._uploadArea_yx26o_55{margin-bottom:var(--space-6)}._fileInputWrapper_yx26o_59{position:relative;display:flex;align-items:center;gap:var(--space-4);background:var(--bg-tertiary);border:1px dashed var(--border-secondary);border-radius:var(--radius-lg);padding:var(--space-4);transition:all var(--transition-fast)}._fileInputWrapper_yx26o_59:hover{border-color:var(--accent);background:var(--bg-elevated)}._fileInput_yx26o_59{position:absolute;top:0;left:0;width:100%;height:100%;opacity:0;cursor:pointer;z-index:2}._fileDisplay_yx26o_87{flex:1;display:flex;align-items:center;gap:var(--space-3);overflow:hidden}._fileIcon_yx26o_95{color:var(--text-tertiary);font-size:1.5rem}._fileName_yx26o_100{color:var(--text-primary);font-size:var(--font-size-sm);font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._browseButton_yx26o_109{background:#ffffff0d;border:1px solid var(--border-primary);color:var(--text-secondary);padding:var(--space-2) var(--space-4);border-radius:var(--radius-md);font-size:var(--font-size-sm);font-weight:600;pointer-events:none}._optionsArea_yx26o_120{margin-bottom:var(--space-6);padding:var(--space-4);background:color-mix(in srgb,var(--color-warning) 5%,transparent);border:1px solid color-mix(in srgb,var(--color-warning) 10%,transparent);border-radius:var(--radius-lg)}._checkboxLabel_yx26o_128{display:flex;align-items:flex-start;gap:var(--space-3);cursor:pointer;position:relative}._checkbox_yx26o_128{opacity:0;position:absolute}._checkboxCustom_yx26o_141{width:20px;height:20px;border:2px solid var(--border-secondary);border-radius:4px;display:flex;align-items:center;justify-content:center;flex-shrink:0;margin-top:2px;transition:all var(--transition-fast)}._checkbox_yx26o_128:checked+._checkboxCustom_yx26o_141{background:var(--color-warning);border-color:var(--color-warning)}._checkbox_yx26o_128:checked+._checkboxCustom_yx26o_141:after{content:"";width:5px;height:10px;border:solid var(--color-warning-text);border-width:0 2px 2px 0;transform:rotate(45deg);margin-bottom:2px}._optionText_yx26o_169{display:flex;flex-direction:column;gap:4px}._optionTitle_yx26o_175{color:var(--color-warning);font-weight:600;font-size:var(--font-size-sm)}._optionDesc_yx26o_181{color:var(--text-tertiary);font-size:.8rem;line-height:1.4}._actions_yx26o_187{display:flex;justify-content:flex-end;gap:var(--space-3);border-top:1px solid var(--border-primary);padding-top:var(--space-6)}._importBtn_yx26o_195{display:flex;align-items:center;gap:var(--space-2)}._cancelBtn_yx26o_201{display:flex;align-items:center;gap:var(--space-2);background:color-mix(in srgb,var(--color-danger) 15%,transparent);border-color:color-mix(in srgb,var(--color-danger) 30%,transparent);color:var(--color-danger)}._cancelBtn_yx26o_201:hover{background:color-mix(in srgb,var(--color-danger) 25%,transparent);border-color:color-mix(in srgb,var(--color-danger) 50%,transparent)}._statusMessage_yx26o_215{margin-top:var(--space-6);padding:var(--space-4);border-radius:var(--radius-md);font-size:var(--font-size-sm);font-weight:500;text-align:center;animation:_fadeIn_yx26o_1 .3s ease}._statusMessage_yx26o_215._success_yx26o_225{background:color-mix(in srgb,var(--color-success) 10%,transparent);color:var(--color-success);border:1px solid color-mix(in srgb,var(--color-success) 20%,transparent)}._statusMessage_yx26o_215._error_yx26o_231{background:color-mix(in srgb,var(--color-danger) 10%,transparent);color:var(--color-danger);border:1px solid color-mix(in srgb,var(--color-danger) 20%,transparent)}._progressSection_yx26o_237{margin-top:var(--space-6);animation:_fadeIn_yx26o_1 .3s ease}._progressBar_yx26o_242{height:6px;background:var(--bg-tertiary);border-radius:3px;overflow:hidden;margin-bottom:var(--space-3)}._progressFill_yx26o_250{height:100%;background:linear-gradient(90deg,#6366f1,#8b5cf6);border-radius:3px;transition:width .3s ease}._progressInfo_yx26o_257{display:flex;align-items:center;justify-content:space-between;gap:var(--space-3)}._progressCount_yx26o_264{font-size:var(--font-size-sm);color:var(--text-tertiary);font-weight:500;white-space:nowrap}._progressTitle_yx26o_271{display:flex;align-items:center;gap:var(--space-2);font-size:var(--font-size-sm);color:var(--text-primary);font-weight:500;text-align:right;overflow:hidden}._progressTitle_yx26o_271>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:300px}._sourceBadge_yx26o_289{display:inline-flex;align-items:center;padding:2px 8px;border-radius:10px;font-size:.7rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;flex-shrink:0}._sourceBadge_yx26o_289._anilist_yx26o_301{background:#6366f126;color:#818cf8;border:1px solid rgba(99,102,241,.3)}._sourceBadge_yx26o_289._kitsu_yx26o_307{background:#ec489926;color:#f472b6;border:1px solid rgba(236,72,153,.3)}._sourceBadge_yx26o_289._offline_yx26o_313{background:#22c55e26;color:#4ade80;border:1px solid rgba(34,197,94,.3)}._skipped_yx26o_319{color:var(--text-tertiary);font-style:italic}._cardTitleRow_yx26o_324{display:flex;align-items:center;gap:var(--space-3)}._cardTitleRow_yx26o_324 h3{margin:0}._anilistIcon_yx26o_334{font-size:1.5rem;color:#818cf8;flex-shrink:0}._malIcon_yx26o_340{font-size:1.5rem;color:#2e51a2;flex-shrink:0}._badgeOnline_yx26o_346{font-size:.7rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;padding:3px 10px;border-radius:var(--radius-full);background:color-mix(in srgb,var(--color-success) 12%,transparent);color:var(--color-success);border:1px solid color-mix(in srgb,var(--color-success) 25%,transparent)}._badgeOffline_yx26o_358{font-size:.7rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;padding:3px 10px;border-radius:var(--radius-full);background:var(--bg-tertiary);color:var(--text-tertiary);border:1px solid var(--border-primary)}._connectedProfile_yx26o_370{display:flex;align-items:center;gap:var(--space-4);padding:var(--space-4);background:var(--bg-tertiary);border-radius:var(--radius-lg)}._avatar_yx26o_379{width:48px;height:48px;border-radius:50%;flex-shrink:0}._connectedInfo_yx26o_386{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}._connectedName_yx26o_394{color:var(--text-primary);font-weight:700;font-size:var(--font-size-sm)}._connectedHint_yx26o_400{color:var(--color-success);font-size:.8rem}._loginPrompt_yx26o_405{display:flex;align-items:center;justify-content:space-between;gap:var(--space-4);flex-wrap:wrap}._loginSection_yx26o_413{display:flex;flex-direction:column;gap:var(--space-3)}._loginSection_yx26o_413>._primaryBtn_yx26o_419{align-self:flex-start}._fieldLabel_yx26o_423{font-size:var(--font-size-sm);font-weight:600;color:var(--text-primary)}._fieldLabel_yx26o_423 a{color:var(--accent);text-decoration:none;display:inline-flex;align-items:center;gap:4px;margin-left:6px}._fieldLabel_yx26o_423 a:hover{text-decoration:underline}._helpText_yx26o_442{margin:0;font-size:.8rem;color:var(--text-tertiary);line-height:1.6}._resetBtn_yx26o_449{align-self:flex-start;padding:0;border:0;background:none;color:var(--accent);font-size:var(--font-size-sm);cursor:pointer;text-decoration:underline}._resetBtn_yx26o_449:hover:not(:disabled){filter:brightness(1.1)}._resetBtn_yx26o_449:disabled{opacity:.5;cursor:not-allowed}._helpText_yx26o_442 code{background:var(--bg-tertiary);border:1px solid var(--border-primary);border-radius:4px;padding:1px 6px;font-size:.75rem;color:var(--text-secondary);word-break:break-all}._loginText_yx26o_479{color:var(--text-secondary);font-size:var(--font-size-sm);margin:0;line-height:1.6;flex:1;min-width:220px}._primaryBtn_yx26o_419,._secondaryBtn_yx26o_489,._syncBtn_yx26o_490{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-2);padding:var(--space-2-5) var(--space-4);border-radius:var(--radius-md);font-weight:600;font-size:var(--font-size-sm);cursor:pointer;border:1px solid transparent;transition:all var(--transition-fast);flex-shrink:0}._primaryBtn_yx26o_419{background:var(--accent);color:var(--accent-text)}._primaryBtn_yx26o_419:hover{filter:brightness(1.1)}._secondaryBtn_yx26o_489{background:#ffffff0d;border-color:var(--border-primary);color:var(--text-primary)}._secondaryBtn_yx26o_489:hover:not(:disabled){background:var(--bg-elevated);border-color:var(--border-secondary)}._syncBtn_yx26o_490{background:linear-gradient(135deg,#6366f1,#8b5cf6);color:#fff;padding:var(--space-3) var(--space-6)}._syncBtn_yx26o_490:hover:not(:disabled){filter:brightness(1.1)}._primaryBtn_yx26o_419:disabled,._secondaryBtn_yx26o_489:disabled,._syncBtn_yx26o_490:disabled{opacity:.5;cursor:not-allowed}._divider_yx26o_542{border:0;border-top:1px solid var(--border-primary);margin:var(--space-6) 0}._actionSection_yx26o_548 h4{margin:0 0 var(--space-1);color:var(--text-primary);font-size:var(--font-size-sm);font-weight:700}._actionSection_yx26o_548 p{color:var(--text-secondary);font-size:var(--font-size-sm);margin:0 0 var(--space-4);line-height:1.6}._inputGroup_yx26o_562{display:flex;gap:var(--space-2)}._credentialFields_yx26o_567{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--space-3)}._credentialField_yx26o_567{display:flex;flex-direction:column;justify-content:flex-end;gap:var(--space-2);min-width:0}._credentialField_yx26o_567 ._input_yx26o_562{flex:none;width:100%;box-sizing:border-box}._input_yx26o_562{flex:1;min-width:0;padding:var(--space-2-5) var(--space-3);border-radius:var(--radius-md);border:1px solid var(--border-primary);background:var(--bg-tertiary);color:var(--text-primary);font-size:var(--font-size-sm)}._input_yx26o_562:focus{outline:none;border-color:var(--accent)}._syncSummary_yx26o_603{margin-top:var(--space-3);font-size:.8rem;color:var(--text-tertiary)}._syncErrors_yx26o_609{color:var(--color-danger)}._spin_yx26o_613{animation:_spin_yx26o_613 1s linear infinite}@keyframes _spin_yx26o_613{to{transform:rotate(360deg)}}@keyframes _fadeIn_yx26o_1{0%{opacity:0}to{opacity:1}}@keyframes _slideUpIn_yx26o_1{0%{opacity:0;transform:translateY(30px)}to{opacity:1;transform:translateY(0)}}._radioGroup_yx26o_642{display:flex;gap:var(--space-4);margin-bottom:var(--space-4)}._radioLabel_yx26o_648{display:flex;align-items:center;gap:var(--space-2);font-size:var(--font-size-sm);color:var(--text-secondary);cursor:pointer;-webkit-user-select:none;user-select:none}._radioLabel_yx26o_648 input[type=radio]{appearance:none;-webkit-appearance:none;width:16px;height:16px;border:2px solid var(--border-secondary);border-radius:50%;background:transparent;cursor:pointer;position:relative;flex-shrink:0}._radioLabel_yx26o_648 input[type=radio]:checked{border-color:var(--accent)}._radioLabel_yx26o_648 input[type=radio]:checked:after{content:"";position:absolute;top:3px;left:3px;width:6px;height:6px;border-radius:50%;background:var(--accent)}._syncHint_yx26o_686{color:var(--text-secondary);font-size:var(--font-size-sm);margin:0 0 var(--space-4);line-height:1.6}._importLoading_yx26o_693{display:flex;align-items:center;gap:var(--space-2);font-size:var(--font-size-sm);color:var(--text-secondary);margin-top:var(--space-3)}@media(max-width:600px){._credentialFields_yx26o_567{grid-template-columns:1fr}._importCard_yx26o_20{padding:var(--space-6)}._fileInputWrapper_yx26o_59{flex-direction:column;align-items:stretch;text-align:center}._fileDisplay_yx26o_87{flex-direction:column}._browseButton_yx26o_109{text-align:center}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{h as j,d as i,A as ye,u as e,S as g,g as en,q as $e}from"./vendor-core-DfaOB3Rn.js";import{u as Z,b as Q,a as I}from"./vendor-query-BBT5_sHx.js";import{A as r,q as s,t as c,Z as nn,k as an,H as Ke,B as ge}from"./index-DlcgJVM6.js";import{I as m}from"./vendor-icons-DrybRNxP.js";function tn(){const N=Z();j(()=>{const x=new URLSearchParams(window.location.search),h=x.get("mal");if(!h)return;const t=x.get("user"),y=x.get("reason");window.history.replaceState(null,"",window.location.pathname),h==="success"?(r.success(t?`Connected to MyAnimeList as ${decodeURIComponent(t)}`:"Connected to MyAnimeList"),N.invalidateQueries({queryKey:[s.trackerStatus]})):r.error(y?decodeURIComponent(y):"MyAnimeList authentication failed")},[N])}function sn(){const N=Z(),[x,h]=i(!1);return j(()=>{const t=new URLSearchParams(window.location.search),y=t.get("anilist");if(y){const f=t.get("user"),u=t.get("reason");window.history.replaceState(null,"",window.location.pathname),y==="success"?(r.success(f?`Connected to AniList as ${decodeURIComponent(f)}`:"Connected to AniList"),N.invalidateQueries({queryKey:[s.trackerStatus]})):r.error(u?decodeURIComponent(u):"AniList authentication failed");return}const k=new URLSearchParams(window.location.hash.substring(1)),l=k.get("access_token"),S=t.get("code");if(!l&&!S){const f=k.get("error");f&&(r.error(`AniList error: ${f}`),window.history.replaceState(null,"",window.location.pathname));return}const d=window.location.origin+window.location.pathname;window.history.replaceState(null,"",window.location.pathname),h(!0),r("Connecting to AniList..."),c.tracker.anilistAuth.mutate(l?{token:l}:{code:S,redirectUri:d}).then(async f=>{const u=f.user;r.success(`Connected to AniList as ${u?.name??"AniList user"}`),N.invalidateQueries({queryKey:[s.trackerStatus]})}).catch(f=>{r.error(f instanceof Error?f.message:"Failed to authenticate with AniList")}).finally(()=>{h(!1)})},[N]),x}const rn="_header_yx26o_1",cn="_fadeIn_yx26o_1",on="_pageTitle_yx26o_6",ln="_pageSubtitle_yx26o_14",dn="_importCard_yx26o_20",mn="_slideUpIn_yx26o_1",un="_cardHeader_yx26o_37",pn="_uploadArea_yx26o_55",hn="_fileInputWrapper_yx26o_59",gn="_fileInput_yx26o_59",yn="_fileDisplay_yx26o_87",fn="_fileIcon_yx26o_95",bn="_fileName_yx26o_100",_n="_browseButton_yx26o_109",kn="_optionsArea_yx26o_120",vn="_checkboxLabel_yx26o_128",Nn="_checkbox_yx26o_128",wn="_checkboxCustom_yx26o_141",xn="_optionText_yx26o_169",Cn="_optionTitle_yx26o_175",In="_optionDesc_yx26o_181",Sn="_actions_yx26o_187",Ln="_importBtn_yx26o_195",Mn="_cancelBtn_yx26o_201",Tn="_statusMessage_yx26o_215",An="_success_yx26o_225",Pn="_error_yx26o_231",Bn="_progressSection_yx26o_237",En="_progressBar_yx26o_242",Fn="_progressFill_yx26o_250",Dn="_progressInfo_yx26o_257",qn="_progressCount_yx26o_264",$n="_progressTitle_yx26o_271",Kn="_sourceBadge_yx26o_289",Rn="_anilist_yx26o_301",Un="_kitsu_yx26o_307",Qn="_offline_yx26o_313",On="_skipped_yx26o_319",Hn="_cardTitleRow_yx26o_324",zn="_anilistIcon_yx26o_334",Gn="_malIcon_yx26o_340",Wn="_badgeOnline_yx26o_346",Xn="_badgeOffline_yx26o_358",Yn="_connectedProfile_yx26o_370",Jn="_avatar_yx26o_379",jn="_connectedInfo_yx26o_386",Zn="_connectedName_yx26o_394",Vn="_connectedHint_yx26o_400",ea="_loginPrompt_yx26o_405",na="_loginSection_yx26o_413",aa="_primaryBtn_yx26o_419",ta="_fieldLabel_yx26o_423",sa="_helpText_yx26o_442",ia="_resetBtn_yx26o_449",ra="_loginText_yx26o_479",ca="_secondaryBtn_yx26o_489",oa="_syncBtn_yx26o_490",la="_divider_yx26o_542",da="_actionSection_yx26o_548",ma="_inputGroup_yx26o_562",ua="_credentialFields_yx26o_567",pa="_credentialField_yx26o_567",ha="_input_yx26o_562",ga="_syncSummary_yx26o_603",ya="_syncErrors_yx26o_609",fa="_spin_yx26o_613",ba="_radioGroup_yx26o_642",_a="_radioLabel_yx26o_648",ka="_syncHint_yx26o_686",va="_importLoading_yx26o_693",n={header:rn,fadeIn:cn,pageTitle:on,pageSubtitle:ln,importCard:dn,slideUpIn:mn,cardHeader:un,uploadArea:pn,fileInputWrapper:hn,fileInput:gn,fileDisplay:yn,fileIcon:fn,fileName:bn,browseButton:_n,optionsArea:kn,checkboxLabel:vn,checkbox:Nn,checkboxCustom:wn,optionText:xn,optionTitle:Cn,optionDesc:In,actions:Sn,importBtn:Ln,cancelBtn:Mn,statusMessage:Tn,success:An,error:Pn,progressSection:Bn,progressBar:En,progressFill:Fn,progressInfo:Dn,progressCount:qn,progressTitle:$n,sourceBadge:Kn,anilist:Rn,kitsu:Un,offline:Qn,skipped:On,cardTitleRow:Hn,anilistIcon:zn,malIcon:Gn,badgeOnline:Wn,badgeOffline:Xn,connectedProfile:Yn,avatar:Jn,connectedInfo:jn,connectedName:Zn,connectedHint:Vn,loginPrompt:ea,loginSection:na,primaryBtn:aa,fieldLabel:ta,helpText:sa,resetBtn:ia,loginText:ra,secondaryBtn:ca,syncBtn:oa,divider:la,actionSection:da,inputGroup:ma,credentialFields:ua,credentialField:pa,input:ha,syncSummary:ga,syncErrors:ya,spin:fa,radioGroup:ba,radioLabel:_a,syncHint:ka,importLoading:va},ie="tracker_anilist_client_id",Qe="49887".trim(),re=!!Qe;function Re(){const N=Z(),[x,h]=i(""),t=ye(!1),y=sn(),{data:k}=Q({queryKey:[s.trackerStatus],queryFn:()=>c.tracker.status.query()}),{data:l}=Q({queryKey:[s.anilistClientId],queryFn:async()=>(await c.settings.getByKey.query({key:ie})).value||""});j(()=>{t.current||l===void 0||(l&&h(l),t.current=!0)},[l]);const S=I({mutationFn:()=>c.tracker.anilistDisconnect.mutate(),onSuccess:()=>{N.invalidateQueries({queryKey:[s.trackerStatus]}),r.success("Disconnected from AniList")},onError:_=>r.error(_.message)}),d=I({mutationFn:()=>c.settings.set.mutate({key:ie,value:""}),onSuccess:()=>{h(""),N.invalidateQueries({queryKey:[s.anilistClientId]}),r.success("Switched to dango's AniList app")},onError:_=>r.error(_.message)}),f=async()=>{const _=x.trim(),o=_||Qe;if(!o){r.error("Enter your AniList client ID first");return}const B=(l||"").trim();try{_?_!==l&&await c.settings.set.mutate({key:ie,value:_}):re&&B&&await c.settings.set.mutate({key:ie,value:""}),N.invalidateQueries({queryKey:[s.anilistClientId]})}catch(L){r.error(L.message);return}const p=encodeURIComponent(window.location.origin+window.location.pathname);window.location.href=`https://anilist.co/api/v2/oauth/authorize?client_id=${encodeURIComponent(o)}&response_type=token&state=${p}`},u=k?.anilist?.user??null;return k?.anilist?.connected&&u?e("div",{className:n.connectedProfile,children:[u.avatar&&e("img",{src:u.avatar,alt:"Avatar",className:n.avatar,loading:"lazy",decoding:"async"}),e("div",{className:n.connectedInfo,children:[e("span",{className:n.connectedName,children:u.name}),e("span",{className:n.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:n.secondaryBtn,onClick:()=>S.mutate(),disabled:S.isPending,children:[e(m,{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.",y&&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(m,{name:"external-link-alt",size:9})]})]}),e("div",{className:n.inputGroup,children:[e("input",{type:"text",placeholder:"Client ID",value:x,onChange:_=>h(_.currentTarget.value),className:n.input}),e("button",{className:n.primaryBtn,onClick:f,disabled:!(x.trim()||re),children:[e(m,{name:"external-link-alt"})," Connect"]})]}),re&&l&&e("button",{className:n.resetBtn,onClick:()=>d.mutate(),disabled:d.isPending,children:"Use dango's app instead"}),e("p",{className:n.helpText,children:re?e(g,{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(g,{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."]})})]})}function Ue({kind:N="anime",active:x=!0}){const h=Z(),[t,y]=i(""),[k,l]=i(""),[S,d]=i(""),[f,u]=i(""),_=ye(!1),{data:o}=Q({queryKey:[s.malClientConfig],queryFn:()=>c.tracker.malConfig.query()}),{data:B}=Q({queryKey:[s.trackerStatus],queryFn:()=>c.tracker.status.query(),refetchInterval:15e3});j(()=>{o&&!_.current&&(y(o.clientId),_.current=!0)},[o]);const p=I({mutationFn:async()=>{d(""),(k.trim()||t.trim()&&t.trim()!==o?.clientId)&&await c.tracker.malSaveConfig.mutate({clientId:t.trim(),clientSecret:k.trim()||void 0}),l("");const b=await c.tracker.malLogin.mutate({redirectUri:`${window.location.origin}/api/tracker/mal/callback`});window.location.assign(b.url)},onError:b=>d(b.message)}),L=I({mutationFn:()=>c.tracker.malDisconnect.mutate(),onSuccess:()=>{h.invalidateQueries({queryKey:[s.trackerStatus]}),u(""),d(""),r.success("Disconnected from MyAnimeList")},onError:b=>d(b.message)}),F=I({mutationFn:()=>c.tracker.malClearConfig.mutate(),onSuccess:()=>{y(""),l(""),u(""),d(""),h.invalidateQueries({queryKey:[s.trackerStatus]}),h.invalidateQueries({queryKey:[s.malClientConfig]}),r.success("Switched to dango's MyAnimeList app - reconnect to finish")},onError:b=>d(b.message)}),$=I({mutationFn:()=>N==="manga"?c.tracker.mangaMalSync.mutate():c.tracker.sync.mutate({provider:"mal"}),onSuccess:b=>{const T=b.summary;u(`Pushed: ${T.pushed} · Pulled: ${T.pulled} · Merged: ${T.merged} · Unchanged: ${T.unchanged}`+(T.errors.length>0?` · ${T.errors.length} error${T.errors.length>1?"s":""}`:""));for(const D of N==="manga"?[[s.trackerStatus],[s.mangaLibrary],[s.mangaContinueReading]]:[[s.trackerStatus],[s.watchlist],[s.continueWatching]])h.invalidateQueries({queryKey:D})},onError:b=>d(b.message)}),M=B?.mal;return e("div",{children:[M?.connected?e(g,{children:[e("div",{className:n.connectedProfile,children:[M.user?.avatar&&e("img",{src:M.user.avatar,alt:"Avatar",className:n.avatar,loading:"lazy",decoding:"async"}),e("div",{className:n.connectedInfo,children:[e("span",{className:n.connectedName,children:M.user?.name||"MyAnimeList user"}),e("span",{className:n.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:n.secondaryBtn,onClick:()=>L.mutate(),disabled:L.isPending,children:[e(m,{name:"sign-out-alt"})," Disconnect"]})]}),x?e(g,{children:[e("button",{className:n.syncBtn,onClick:()=>$.mutate(),disabled:$.isPending,children:[e(m,{name:"sync-alt",className:$.isPending?n.spin:""}),$.isPending?"Syncing...":"Start Sync"]}),f&&e("div",{className:n.syncSummary,children:f})]}):e("p",{className:n.connectedHint,style:{color:"var(--color-warning)"},children:"Not the active tracker - sync disabled."})]}):e("div",{className:n.loginSection,children:[e("p",{className:n.loginText,children:"Log in with MyAnimeList to enable bidirectional progress & status synchronization."}),e("div",{className:n.credentialFields,children:[e("label",{className:`${n.fieldLabel} ${n.credentialField}`,children:[e("span",{children:["Client ID"," ",e("a",{href:"https://myanimelist.net/apiconfig",target:"_blank",rel:"noopener noreferrer",children:["create your own app ",e(m,{name:"external-link-alt",size:9})]}),o?.mode==="worker"&&e("span",{className:n.helpText,children:" — defaults to dango's app"})]}),e("input",{className:n.input,placeholder:o?.mode==="worker"?"dango's app (leave empty)":"Client ID",value:t,onChange:b=>y(b.currentTarget.value),autoComplete:"off"})]}),e("label",{className:`${n.fieldLabel} ${n.credentialField}`,children:[e("span",{children:["Client secret"," ",o?.hasSecret&&!k&&e("span",{className:n.helpText,children:"— saved"})]}),e("input",{className:n.input,type:"password",value:k,onChange:b=>l(b.currentTarget.value),placeholder:o?.mode==="worker"?"dango's app (leave empty)":o?.hasSecret?"Saved — leave blank to keep":"Client secret",autoComplete:"new-password"})]})]}),o?.hasCustomId&&o?.hasWorker&&e("button",{className:n.resetBtn,onClick:()=>F.mutate(),disabled:F.isPending,children:"Use dango's app instead"}),e("p",{className:n.helpText,children:o?.mode==="worker"?e(g,{children:["By default uses dango's client. To use your own MyAnimeList app: create it at"," ",e("a",{href:"https://myanimelist.net/apiconfig",target:"_blank",rel:"noopener noreferrer",children:"myanimelist.net/apiconfig"}),", set its ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:[window.location.origin,"/api/tracker/mal/callback"]}),", then paste its"," ",e("strong",{children:"Client ID"})," and ",e("strong",{children:"Client secret"})," above (leave both empty to use dango's)."]}):e(g,{children:["No shipped client in this build - create your own app at"," ",e("a",{href:"https://myanimelist.net/apiconfig",target:"_blank",rel:"noopener noreferrer",children:"myanimelist.net/apiconfig"}),", set its ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:[window.location.origin,"/api/tracker/mal/callback"]}),", then paste the"," ",e("strong",{children:"Client ID"})," and ",e("strong",{children:"Client secret"})," above. MAL requires the secret even for PKCE apps; it stays on your dango server and is never returned to the browser."]})}),e("button",{className:n.primaryBtn,onClick:()=>p.mutate(),disabled:!(t.trim()&&k.trim()||o?.clientId&&t.trim()===o.clientId&&o.hasSecret||!t.trim()&&!k.trim()&&o?.mode==="worker")||p.isPending,children:p.isPending?"Connecting...":"Connect to MyAnimeList"})]}),S&&e("p",{className:`${n.helpText} ${n.syncErrors}`,role:"alert",children:S}),e("hr",{className:n.divider}),e("p",{className:n.syncHint,children:"You can also import a public list or XML file without connecting an account:"})]})}const Ia=()=>{const{setIsOpen:N}=nn(),{contentType:x}=an(),h=x==="manga",t=Z();en.useEffect(()=>{document.title="Trackers - dango"},[]);const[y,k]=i(""),[l,S]=i("username"),[d,f]=i(null),[u,_]=i(!1);tn();const{data:o,isLoading:B}=Q({queryKey:[s.trackerStatus],queryFn:async()=>await c.tracker.status.query()}),p=o?.anilist?.connected??!1,L=o?.mal?.connected??!1,{data:F}=Q({queryKey:["activeTrackerProvider"],queryFn:async()=>(await c.settings.getByKey.query({key:"active_tracker_provider"}))?.value||""}),$=I({mutationFn:async a=>(await c.settings.set.mutate({key:"active_tracker_provider",value:a}),a),onSuccess:a=>{t.invalidateQueries({queryKey:["activeTrackerProvider"]}),r.success(`Active tracker set to ${a==="mal"?"MyAnimeList":"AniList"}`)},onError:()=>r.error("Failed to update active tracker")}),M=F&&(F==="anilist"&&p||F==="mal"&&L)?F:p&&!L?"anilist":L&&!p?"mal":p?"anilist":"",b=p||L;j(()=>{p&&S("sync")},[p]);const T=I({mutationFn:async()=>(await c.tracker.sync.mutate({provider:"anilist"})).summary,onSuccess:a=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),f(a),r.success(`Sync complete - pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}`,{duration:6e3})},onError:a=>r.error(a.message)}),[D,fe]=i(""),[V,be]=i("sync"),[ce,_e]=i("two-way"),[w,Oe]=i(null),ee=I({mutationFn:async()=>(await c.tracker.mangaSync.mutate({direction:ce})).summary,onSuccess:a=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),Oe(a);const v=(a.warnings?.length??0)>0?`, ${a.warnings.length} warning(s)`:"";r.success(`Manga sync complete - pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}${v}`,{duration:6e3})},onError:a=>r.error(a.message)}),K=I({mutationFn:async()=>{if(!D.trim())throw new Error("Please enter a username");return(await c.tracker.mangaImport.mutate({username:D.trim(),erase:u})).count},onSuccess:a=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),r.success(`Imported ${a} manga entries from AniList`),fe("")},onError:a=>r.error(a.message)}),[O,ke]=i(""),[ne,ve]=i("username"),[oe,Ne]=i(null),[ae,we]=i(!1),[xe,le]=i(""),[Ce,He]=i(""),E=I({mutationFn:async()=>{if(!O.trim())throw new Error("Please enter a MAL username");const a=await c.tracker.mangaMalImport.mutate({username:O.trim(),erase:u});return{imported:a.imported??0,skipped:a.skipped??0}},onSuccess:({imported:a,skipped:v})=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),r.success(`Imported ${a} manga entries from MAL${v>0?`, skipped ${v}`:""}`),ke("")},onError:a=>r.error(a.message)}),ze=$e(async()=>{const a=document.getElementById("malMangaFile");if(!a.files||a.files.length===0){le("Please select a file first.");return}we(!0),le(""),Ne(null);try{const v=new FormData;v.append("xmlfile",a.files[0]),v.append("erase",String(u));const X=await Ke("/api/import/mal-xml-manga",{method:"POST",body:v}),C=await X.json().catch(()=>({}));if(!X.ok)throw new Error(C.error||"Import failed");Ne({imported:C.imported??0,skipped:C.skipped??0}),t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]})}catch(v){le(v.message)}finally{we(!1)}},[u,t]),R=I({mutationFn:async()=>{if(!y.trim())throw new Error("Please enter a username");return(await c.tracker.anilistImport.mutate({username:y.trim(),erase:q})).count},onSuccess:a=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),r.success(`Imported ${a} anime entries from AniList`),k("")},onError:a=>r.error(a.message)}),[H,Ie]=i(""),P=I({mutationFn:async a=>{if(!H.trim())throw new Error("Please enter a MAL username");return(await c.tracker.malImport.mutate({username:H.trim(),erase:a.erase,useOfflineDb:a.useOfflineDb,skipFallback:a.skipFallback})).count},onSuccess:a=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),r.success(`Imported ${a} anime entries from MAL`),Ie("")},onError:a=>r.error(a.message)}),[q,Se]=i(!1),[z,Ge]=i(!0),[G,We]=i(!1),[Le,Me]=i(""),[U,Te]=i(!1),[A,Ae]=i(null),[de,Pe]=i(null),[Be,te]=i(""),me=ye(null),Xe=a=>{a.currentTarget.files&&a.currentTarget.files.length>0?Me(a.currentTarget.files[0].name):Me("")},Ye=$e(async()=>{const a=document.getElementById("malFile");if(!a.files||a.files.length===0){te("Please select a file first.");return}const v=a.files[0];Te(!0),Ae(null),Pe(null),te("");const X=new AbortController;me.current=X;try{const C=new FormData;C.append("xmlfile",v),C.append("erase",String(q)),C.append("useOfflineDb",String(z)),C.append("skipFallback",String(G));const ue=await Ke("/api/import/mal-xml",{method:"POST",body:C,signal:X.signal});if(!ue.ok){const he=await ue.text();let Y="Failed to import";try{Y=JSON.parse(he).error||Y}catch{}throw new Error(Y)}const Fe=ue.body?.getReader();if(!Fe)throw new Error("No response stream");const Ze=new TextDecoder;let pe="",se="";for(;;){const{done:he,value:Y}=await Fe.read();if(he)break;pe+=Ze.decode(Y,{stream:!0});const De=pe.split(`
|
|
2
|
+
`);pe=De.pop()||"";for(const J of De)if(J.startsWith("event: "))se=J.slice(7).trim();else if(J.startsWith("data: ")){const Ve=J.slice(6);try{const qe=JSON.parse(Ve);se==="progress"?Ae(qe):se==="complete"&&Pe(qe)}catch{}}else J===""&&(se="")}t.invalidateQueries({queryKey:[s.watchlist]})}catch(C){C instanceof DOMException&&C.name==="AbortError"?te("Import cancelled."):te(C.message)}finally{Te(!1),me.current=null}},[q,z,G,t]),Je=()=>{me.current?.abort(),c.settings.malImportCancel.mutate().catch(()=>{})},je=A?Math.round(A.current/A.total*100):0,[W,Ee]=i("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 and MyAnimeList entries, and dango may not always handle anime/manga lists correctly - always keep a backup of your lists before syncing."}),b&&e("div",{style:{marginBottom:"16px",padding:"10px 14px",borderRadius:"8px",background:"rgba(255, 255, 255, 0.03)",border:"1px solid var(--glass-border)",display:"flex",alignItems:"center",gap:"12px",fontSize:"0.85rem"},children:[e("label",{htmlFor:"active-tracker-select",style:{fontWeight:600},children:"Active tracker:"}),e("select",{id:"active-tracker-select",value:M,onChange:a=>$.mutate(a.currentTarget.value),style:{padding:"0.4rem 0.6rem",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)",cursor:"pointer"},children:[p&&e("option",{value:"anilist",children:"AniList"}),L&&e("option",{value:"mal",children:"MyAnimeList"})]})]}),!h&&e(g,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(m,{name:"anilist",className:n.anilistIcon}),e("h3",{children:"AniList"}),B?null:p?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),e(Re,{}),p&&M!=="anilist"&&e("p",{style:{color:"var(--color-warning)",marginTop:"8px",fontSize:"0.85rem"},children:"Not the active tracker - sync disabled."}),p&&M==="anilist"&&e(g,{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:l==="username",onChange:()=>S("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"sync",checked:l==="sync",onChange:()=>S("sync")}),e("span",{children:"Two-way Sync"})]})]}),l==="username"?e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:y,onChange:a=>k(a.currentTarget.value),className:n.input,disabled:R.isPending,onKeyDown:a=>{a.key==="Enter"&&y.trim()&&R.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."}),l==="username"&&e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:q,onChange:a=>Se(a.currentTarget.checked),className:n.checkbox,disabled:R.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."})]})]})}),l==="username"?e("button",{className:n.syncBtn,onClick:()=>R.mutate(),disabled:!y.trim()||R.isPending,children:[e(m,{name:"download"}),R.isPending?"Importing...":"Start Import"]}):e(g,{children:[e("button",{className:n.syncBtn,onClick:()=>T.mutate(),disabled:T.isPending,children:[e(m,{name:"sync-alt",className:T.isPending?n.spin:""}),T.isPending?"Syncing...":"Start Sync"]}),d&&e("div",{className:n.syncSummary,children:["Pushed: ",d.pushed," · Pulled: ",d.pulled," · Merged:"," ",d.merged," · Unchanged: ",d.unchanged,d.errors.length>0&&e("span",{className:n.syncErrors,children:[" ","· ",d.errors.length," error",d.errors.length>1?"s":""]})]})]})]})]})}),h&&e(g,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(m,{name:"anilist",className:n.anilistIcon}),e("h3",{children:"AniList Manga"}),B?null:p?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),e(Re,{}),p&&M!=="anilist"&&e("p",{style:{color:"var(--color-warning)",marginTop:"8px",fontSize:"0.85rem"},children:"Not the active tracker - sync disabled."}),p&&M==="anilist"&&e(g,{children:[e("hr",{className:n.divider}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"username",checked:V==="username",onChange:()=>be("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"sync",checked:V==="sync",onChange:()=>be("sync")}),e("span",{children:"Two-way Sync"})]})]}),V==="username"?e(g,{children:[e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:D,onChange:a=>fe(a.currentTarget.value),className:n.input,disabled:K.isPending,onKeyDown:a=>{a.key==="Enter"&&D.trim()&&K.mutate()}})}),e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:u,onChange:a=>_(a.currentTarget.checked),className:n.checkbox,disabled:K.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(g,{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:ce==="two-way",onChange:()=>_e("two-way")}),e("span",{children:"Two-way"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaDirection",value:"pull-only",checked:ce==="pull-only",onChange:()=>_e("pull-only")}),e("span",{children:"Pull only (never writes to AniList)"})]})]})]}),V==="username"?e("button",{className:n.syncBtn,onClick:()=>K.mutate(),disabled:!D.trim()||K.isPending,children:[e(m,{name:"download"}),K.isPending?"Importing...":"Start Import"]}):e(g,{children:[e("button",{className:n.syncBtn,onClick:()=>ee.mutate(),disabled:ee.isPending,children:[e(m,{name:"sync-alt",className:ee.isPending?n.spin:""}),ee.isPending?"Syncing...":"Start Manga Sync"]}),w&&e(g,{children:[e("div",{className:n.syncSummary,children:["Pushed: ",w.pushed," · Pulled: ",w.pulled," · Merged: ",w.merged," · Unchanged:"," ",w.unchanged,(w.skipped??0)>0&&e("span",{children:[" · Skipped: ",w.skipped]}),w.errors.length>0&&e("span",{className:n.syncErrors,children:[" ","· ",w.errors.length," error",w.errors.length>1?"s":""]})]}),(w.warnings?.length??0)>0&&e("div",{className:n.syncErrors,style:{marginTop:"8px"},children:[(w.warnings??[]).slice(0,5).map((a,v)=>e("div",{children:["⚠ ",a]},v)),(w.warnings?.length??0)>5&&e("div",{children:["+",(w.warnings?.length??0)-5," more warning(s)"]})]})]})]})]})]})}),!h&&e(g,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(m,{name:"myanimelist",className:n.malIcon}),e("h3",{children:"MyAnimeList"}),B?null:L?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),e(Ue,{active:M==="mal"}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"username",checked:W==="username",onChange:()=>Ee("username")}),e("span",{children:"Username"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"xml",checked:W==="xml",onChange:()=>Ee("xml")}),e("span",{children:"XML File"})]})]}),W==="username"?e(g,{children:[e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:H,onChange:a=>Ie(a.currentTarget.value),className:n.input,disabled:P.isPending,onKeyDown:a=>{a.key==="Enter"&&H.trim()&&P.mutate({erase:q,useOfflineDb:z,skipFallback:G})}})}),P.isPending&&e("div",{className:n.importLoading,children:[e(m,{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:Xe,disabled:U}),e("div",{className:n.fileDisplay,children:[e(m,{name:"file-alt",className:n.fileIcon}),e("span",{className:n.fileName,children:Le||"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:q,onChange:a=>Se(a.currentTarget.checked),className:n.checkbox,disabled:U||P.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:z,onChange:a=>Ge(a.currentTarget.checked),className:n.checkbox,disabled:U||P.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:G,onChange:a=>We(a.currentTarget.checked),className:n.checkbox,disabled:U||P.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."})]})]})]}),W==="username"?e("button",{className:n.syncBtn,onClick:()=>P.mutate({erase:q,useOfflineDb:z,skipFallback:G}),disabled:!H.trim()||P.isPending,children:[e(m,{name:"download"}),P.isPending?"Importing...":"Start Import"]}):e("div",{className:n.actions,children:U?e(ge,{onClick:Je,className:n.cancelBtn,children:"Cancel Import"}):e(ge,{onClick:Ye,className:n.importBtn,disabled:!Le,children:[e(m,{name:"upload"})," Start Import"]})}),W==="username"&&P.isError&&e("div",{className:`${n.statusMessage} ${n.error}`,children:P.error.message}),U&&A&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressBar,children:e("div",{className:n.progressFill,style:{width:`${je}%`}})}),e("div",{className:n.progressInfo,children:[e("span",{className:n.progressCount,children:[A.current," / ",A.total]}),e("span",{className:n.progressTitle,children:A.found?e(g,{children:[A.matchedTitle,e("span",{className:`${n.sourceBadge} ${n[A.source||"anilist"]}`,children:A.source==="kitsu"?"Kitsu":A.source==="offline"?"Offline DB":"AniList"})]}):e("span",{className:n.skipped,children:["Skipped: ",A.title]})})]})]}),de&&e("div",{className:`${n.statusMessage} ${n.success}`,children:["Import complete! Imported: ",de.imported,", Skipped: ",de.skipped,"."]}),Be&&e("div",{className:`${n.statusMessage} ${n.error}`,children:Be})]})}),h&&e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(m,{name:"myanimelist",className:n.malIcon}),e("h3",{children:"MyAnimeList Manga"}),B?null:L?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),e(Ue,{kind:"manga",active:M==="mal"}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"username",checked:ne==="username",onChange:()=>ve("username")}),e("span",{children:"Username"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"xml",checked:ne==="xml",onChange:()=>ve("xml")}),e("span",{children:"XML File"})]})]}),ne==="username"?e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:O,onChange:a=>ke(a.currentTarget.value),className:n.input,disabled:E.isPending,onKeyDown:a=>{a.key==="Enter"&&O.trim()&&E.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.currentTarget.files?.[0]?.name??""),disabled:ae}),e("div",{className:n.fileDisplay,children:[e(m,{name:"file-alt",className:n.fileIcon}),e("span",{className:n.fileName,children:Ce||"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:u,onChange:a=>_(a.currentTarget.checked),className:n.checkbox,disabled:E.isPending||ae}),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."})]})]})}),ne==="username"?e("button",{className:n.syncBtn,onClick:()=>E.mutate(),disabled:!O.trim()||E.isPending,children:[e(m,{name:"download"}),E.isPending?"Importing...":"Start Import"]}):e("div",{className:n.actions,children:e(ge,{onClick:ze,className:n.importBtn,disabled:ae||!Ce,children:[e(m,{name:"upload"})," ",ae?"Importing...":"Start Import"]})}),E.isError&&e("div",{className:`${n.statusMessage} ${n.error}`,children:E.error.message}),xe&&e("div",{className:`${n.statusMessage} ${n.error}`,children:xe}),oe&&e("div",{className:`${n.statusMessage} ${n.success}`,children:["Import complete! Imported: ",oe.imported,", Skipped:"," ",oe.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{Ia as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as t,d as _,A as O,h as y,S as We,g as Vr,q as k,o as Fr,p as qr,a as Ur,T as Se}from"./vendor-core-DfaOB3Rn.js";import{u as Hr}from"./vendor-query-BBT5_sHx.js";import{g as en,t as dt,W as Wr,J as An,e as Kr,A as Zn,B as Xt}from"./index-DB81Su4I.js";import{I as K}from"./vendor-icons-DrybRNxP.js";import{S as Yr,U as jr,p as wn,M as Gr,z as sr,f as Pn,d as Qr,C as Xr,a as Jr,b as Zr,c as Jt,u as es,i as ts,j as ns,n as rs,k as ss,m as as,l as os,s as Bn,e as is,g as ls,h as cs,r as us,o as Ne,A as ds,t as ms,E as bs,x as hs,P as fs,v as de,y as gs,R as ps,q as vs}from"./usePlaybackEnd-CuDnNZ8o.js";import{S as ys,O as Ln,a as Ss,A as _s,b as Ts}from"./OptionListMenu-onM2KK2X.js";import{M as Cs}from"./MatureConsentModal-BnB-RHYQ.js";import{u as ks}from"./useProviders-CKqOSX5-.js";import{d as Es,g as Ns,h as Is,j as xs,f as As,e as Bs,k as Ls,l as Ms}from"./useTvLibrary-BGz7Unv_.js";import{l as ws,s as Ps,i as er,h as tr}from"./playbackCompletion-IPHm9fp5.js";import{l as Rs,c as zs}from"./hls-Bi-DS5KL.js";import{u as $s}from"./useIsMobile-Dvx1uJ82.js";import{S as Ds}from"./SynopsisText-B3Sa5pRv.js";import"./libraryInvalidation-DI-v-DQ1.js";const Os="_fullscreenFlat_10bzs_1",Vs="_timeDisplay_10bzs_12",Fs="_bottomControls_10bzs_16",qs="_leftControls_10bzs_20",Us="_rightControls_10bzs_21",Hs="_controlBtn_10bzs_25",Ws="_controlsOverlay_10bzs_32",Ks="_hidden_10bzs_52",Ys="_topControls_10bzs_58",js="_backBtn_10bzs_78",Gs="_videoTitleInfo_10bzs_98",Qs="_animeTitle_10bzs_104",Xs="_episodeLabel_10bzs_112",Js="_speedBoostBadge_10bzs_119",Zs="_progressBarContainer_10bzs_165",ea="_progressBar_10bzs_165",ta="_thumb_10bzs_184",na="_bufferedBar_10bzs_202",ra="_watchedBar_10bzs_212",sa="_scrubbing_10bzs_237",aa="_timeBubble_10bzs_241",oa="_bottomControlsRow_10bzs_255",ia="_nextEpisodeBtn_10bzs_278",la="_active_10bzs_340",ca="_settingsPanel_10bzs_352",ua="_settingsHeader_10bzs_371",da="_settingsBackBtn_10bzs_379",ma="_settingsTitle_10bzs_397",ba="_settingsContent_10bzs_408",ha="_currentValue_10bzs_417",fa="_menuItem_10bzs_423",ga="_menuNote_10bzs_456",pa="_loadingOverlay_10bzs_465",va="_loadingDots_10bzs_476",ya="_dot_10bzs_481",Sa="_bufferingOverlay_10bzs_510",_a="_bufferingSpinner_10bzs_519",o={fullscreenFlat:Os,timeDisplay:Vs,bottomControls:Fs,leftControls:qs,rightControls:Us,controlBtn:Hs,controlsOverlay:Ws,hidden:Ks,topControls:Ys,backBtn:js,videoTitleInfo:Gs,animeTitle:Qs,episodeLabel:Xs,speedBoostBadge:Js,progressBarContainer:Zs,progressBar:ea,thumb:ta,bufferedBar:na,watchedBar:ra,scrubbing:sa,timeBubble:aa,bottomControlsRow:oa,nextEpisodeBtn:ia,active:la,settingsPanel:ca,settingsHeader:ua,settingsBackBtn:da,settingsTitle:ma,settingsContent:ba,currentValue:ha,menuItem:fa,menuNote:ga,loadingOverlay:pa,loadingDots:va,dot:ya,bufferingOverlay:Sa,bufferingSpinner:_a},Ta=({player:s,visible:m,settingsOpen:D,onOpenSettings:L,onCloseSettings:w,hasSubtitles:E,isSubtitleActive:n,subtitles:S,onSubtitleChange:a,showNextEpisodeButton:T,onNextEpisode:U,isTheaterMode:P,onTheaterModeToggle:h,timeLabelRef:Y})=>{const{state:d,refs:Re,actions:$}=s,X=Re.videoRef,Ie=N=>{const ne=X.current;!ne||isNaN(d.duration)||d.duration===0||(ne.currentTime=N*d.duration)},xe=()=>{X.current&&($.setIsScrubbing(!0),$.wasPlayingBeforeScrub.current=!X.current.paused,X.current.pause())},ze=N=>{const ne=X.current;ne&&d.duration&&(ne.currentTime=N*d.duration)},$e=()=>{$.setIsScrubbing(!1),$.wasPlayingBeforeScrub.current&&X.current?.play().catch(()=>{})},Ke=N=>{const ne=X.current;ne&&(ne.volume=N,ne.muted=N===0)},ie=()=>{if(n){a(-1);return}let N=null;try{N=localStorage.getItem("tvLastSubtitle")}catch{}a(wn(S,{lastKey:N,enabled:!0}))},j=d.isMuted?t(K,{name:"volume-mute"}):d.volume<.5?t(K,{name:"volume-down"}):t(K,{name:"volume-up"});return t("div",{className:`${o.controlsOverlay} ${m?"":o.hidden}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:o.bottomControls,onClick:N=>N.stopPropagation(),children:[t(Yr,{classes:{container:o.progressBarContainer,scrubbing:o.scrubbing,timeBubble:o.timeBubble,bar:o.progressBar,buffered:o.bufferedBar,watched:o.watchedBar,thumb:o.thumb},videoRef:X,duration:d.duration,formatTime:en,isScrubbing:d.isScrubbing,buffered:"full",onSeek:Ie,onScrubStart:xe,onScrubMove:ze,onScrubEnd:$e,timeLabelRef:Y}),t("div",{className:o.bottomControlsRow,children:[t("div",{className:o.leftControls,children:[t("button",{className:o.controlBtn,onClick:$.togglePlay,"aria-label":d.isPlaying?"Pause":"Play",children:d.isPlaying?t(K,{name:"pause"}):t(K,{name:"play"})}),t(jr,{muted:d.isMuted,volume:d.volume,volumeIcon:j,buttonClassName:o.controlBtn,onToggleMute:$.toggleMute,onVolumeChange:Ke,onExpandedChange:N=>$.setShowVolumeSlider(N)}),t("span",{className:o.timeDisplay,ref:Y,children:[en(0)," / ",en(d.duration)]})]}),t("div",{className:o.rightControls,children:[T&&t("button",{className:o.nextEpisodeBtn,onClick:U,title:"Play next episode",children:"Next EP"}),E&&t("button",{className:`${o.controlBtn} ${n?o.active:""}`,onClick:ie,"aria-label":n?"Turn subtitles off":"Turn subtitles on",children:t(K,{name:"closed-captioning"})}),t("button",{className:`${o.controlBtn} ${D?o.active:""}`,onClick:()=>D?w():L(),"aria-label":"Settings",children:t(K,{name:"cog"})}),t("button",{className:`${o.controlBtn} ${P?o.active:""}`,onClick:N=>{N.stopPropagation(),h()},title:P?"Exit Theater Mode":"Theater Mode","aria-label":P?"Exit Theater Mode":"Theater Mode",children:t(K,{name:"tv"})}),t("button",{className:o.controlBtn,onClick:$.toggleFullscreen,"aria-label":d.isFullscreen?"Exit Fullscreen":"Fullscreen",children:d.isFullscreen?t(K,{name:"compress"}):t(K,{name:"expand"})})]})]})]})})},Zt=-6e4,Mn=6e4,nr=500,Ca=({classes:s,delayMs:m,onDelayChange:D})=>{const[L,w]=_(null),E=L??m,n=O(D);n.current=D;const S=O(m);S.current=m;const a=O(null);a.current=L,y(()=>{w(null)},[m]),y(()=>()=>{const P=a.current;P!==null&&P!==S.current&&n.current(P)},[]);const T=P=>{S.current=P,a.current=null,n.current(P),w(null)},U=P=>{const h=a.current??S.current,Y=Math.max(Zt,Math.min(Mn,h+P));T(Y)};return t(We,{children:[t("div",{style:{display:"flex",gap:6,padding:"0.5rem 0.75rem 0.25rem"},children:[t("button",{type:"button",className:s.item,onClick:()=>U(-nr),"aria-label":"Show subtitles 0.5 seconds earlier",style:{flex:1,justifyContent:"center"},children:t("span",{children:"-0.5s"})}),t("button",{type:"button",className:s.item,onClick:()=>U(nr),"aria-label":"Show subtitles 0.5 seconds later",style:{flex:1,justifyContent:"center"},children:t("span",{children:"+0.5s"})}),t("button",{type:"button",className:s.item,onClick:()=>T(0),disabled:E===0,"aria-label":"Reset subtitle timing",style:{flex:1,justifyContent:"center"},children:t("span",{children:"Reset"})})]}),t(Gr,{label:"Subtitle timing",display:sr(E),min:Zt,max:Mn,step:100,value:E,percent:(E-Zt)/(Mn-Zt)*100,onChange:P=>{const h=Math.round(P);a.current=h,w(h)},onCommit:()=>{const P=a.current;P!==null&&T(P)}}),t("div",{className:s.note,children:"Positive delays subtitles (show later). Negative shows them earlier. 0.0s is default."})]})},ka=({view:s,onSelectView:m,onClose:D,player:L,onSubtitleStyleChange:w,streams:E,resolutionIdx:n,onResolutionChange:S,hasSubtitles:a,subtitles:T,selectedSubtitle:U,isSubtitleActive:P,onSubtitleChange:h,audioTracks:Y,selectedAudioTrack:d,onAudioTrackChange:Re,videoDelayEnabled:$,onVideoDelayToggle:X,videoDelayMs:Ie,onVideoDelayChange:xe,onCalibrate:ze,subtitleDelayMs:$e,onSubtitleDelayChange:Ke,ambientSettings:ie,onAmbientChange:j})=>{const{state:N}=L,ne=()=>t(We,{children:[E.length>1&&t("button",{className:o.menuItem,onClick:()=>m("resolution"),children:[t("span",{children:"Resolution"}),t("span",{className:o.currentValue,children:E[n]?.quality||"Auto"})]}),a&&t("button",{className:o.menuItem,onClick:()=>m("subtitles"),children:[t("span",{children:"Subtitles"}),t("span",{className:o.currentValue,children:P?T[U]?.label||T[U]?.language:"Off"})]}),a&&t("button",{className:o.menuItem,onClick:()=>m("subtitle-style"),children:[t("span",{children:"Subtitle Style"}),t("span",{className:o.currentValue,children:[N.subtitleFontSize.toFixed(1),"x · ",N.subtitlePosition]})]}),a&&t("button",{className:o.menuItem,onClick:()=>m("subtitle-timing"),children:[t("span",{children:"Subtitle Timing"}),t("span",{className:o.currentValue,children:sr($e)})]}),Y.length>0&&t("button",{className:o.menuItem,onClick:()=>m("audio"),children:[t("span",{children:"Audio Track"}),t("span",{className:o.currentValue,children:Y[d]?.label||Y[d]?.language})]}),t("button",{className:o.menuItem,onClick:()=>m("av-sync"),children:[t("span",{children:"A/V Sync"}),t("span",{className:o.currentValue,children:$?`${Ie}ms`:"Off"})]}),ie&&j&&t("button",{className:o.menuItem,onClick:()=>m("ambient"),children:[t("span",{children:"Ambient Light"}),t("span",{className:o.currentValue,children:ie.enabled?"On":"Off"})]})]}),_e=()=>t(Ln,{classes:{item:o.menuItem,active:o.active},options:E.map((x,W)=>({key:String(W),label:x.quality,selected:W===n})),onSelect:x=>S(Number(x))}),G=()=>t(Ln,{classes:{item:o.menuItem,active:o.active},options:[{key:"off",label:"Off",selected:!P},...T.map((x,W)=>({key:String(W),label:x.label||x.language,selected:W===U}))],onSelect:x=>h(x==="off"?-1:Number(x))}),Te=()=>t(Ss,{classes:{item:o.menuItem,active:o.active},values:{fontSize:N.subtitleFontSize,position:N.subtitlePosition,bgOpacity:N.subtitleBgOpacity,bgColor:N.subtitleBgColor,textColor:N.subtitleTextColor,edge:N.subtitleEdge,bold:N.subtitleBold},onChange:w}),H=()=>t(Ca,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},delayMs:$e,onDelayChange:x=>Ke?.(x)}),Ae=()=>t(Ln,{classes:{item:o.menuItem,active:o.active},options:Y.map((x,W)=>({key:String(W),label:x.label||x.language,selected:W===d})),onSelect:x=>Re(Number(x))}),De=()=>t(_s,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},enabled:$,delayMs:Ie,onToggle:x=>X?.(x),onDelayChange:x=>xe?.(x),onCalibrate:ze}),ge=()=>ie&&j?t(Ts,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},values:ie,onChange:j}):null;return t("div",{"data-speed-boost-ignore":"true",onClick:x=>x.stopPropagation(),children:t(ys,{classes:{panel:o.settingsPanel,header:o.settingsHeader,backBtn:o.settingsBackBtn,title:o.settingsTitle,content:o.settingsContent},title:s==="main"?"Settings":s==="subtitle-style"?"Subtitle Style":s==="subtitle-timing"?"Subtitle Timing":s==="audio"?"Audio Track":s==="resolution"?"Resolution":s==="av-sync"?"A/V Sync":s==="ambient"?"Ambient Light":s.charAt(0).toUpperCase()+s.slice(1),onBack:()=>s==="main"?D():m("main"),children:[s==="main"&&ne(),s==="resolution"&&_e(),s==="subtitles"&&G(),s==="subtitle-style"&&Te(),s==="subtitle-timing"&&H(),s==="audio"&&Ae(),s==="av-sync"&&De(),s==="ambient"&&ge()]})})},Ea=({player:s,title:m,episodeLabel:D,audioTracks:L,selectedAudioTrack:w,onAudioTrackChange:E,subtitles:n,selectedSubtitle:S,onSubtitleChange:a,streams:T,resolutionIdx:U,onResolutionChange:P,onBack:h,children:Y,videoDelayEnabled:d=!1,onVideoDelayToggle:Re,videoDelayMs:$=0,onVideoDelayChange:X,onCalibrateAvSync:Ie,subtitleDelayMs:xe=0,onSubtitleDelayChange:ze,showNextEpisodeButton:$e=!1,onNextEpisode:Ke,isLoading:ie=!1,isTheaterMode:j,onTheaterModeToggle:N,ambientSettings:ne,onAmbientChange:_e})=>{const{state:G,refs:Te,actions:H}=s,Ae=Te.videoRef,{subtitleFontSize:De,subtitlePosition:ge,subtitleBgOpacity:x,subtitleBgColor:W,subtitleTextColor:Je,subtitleEdge:le,subtitleBold:Be}=G,[Ce,Le]=_(null),Ze=O(null),[It,mt]=_(0);y(()=>{const we=Ae.current;if(!we)return;const pe=()=>mt(we.clientHeight||0);pe();const J=new ResizeObserver(pe);return J.observe(we),()=>J.disconnect()},[Ae]);const Ye=H.setSubtitleStyle;y(()=>{const we="tv-player-subtitle-style";let pe=document.getElementById(we);pe||(pe=document.createElement("style"),pe.id=we,document.head.appendChild(pe));const J={fontSize:De,position:ge,bgOpacity:x,bgColor:W,textColor:Je,edge:le,bold:Be},ae=Ae.current,je=Pn(De,It||ae?.clientHeight||720);if(pe.textContent=Qr({...J,fontSize:je}),ae){const gt=()=>{const M=Number(ge);return isNaN(M)?0:Math.max(0,Math.min(100,M))},tt=(M,Z)=>{try{const re=M;re.snapToLines=!1,re.line=Z}catch{}},Bt=()=>{const M=je*16,Z=ae.videoHeight||ae.clientHeight||720,re=ae.videoWidth||ae.clientWidth||1280;return{step:M*1.3/Z*100,chars:Math.max(20,Math.floor(re/(M*.55)))}},nt=M=>{const Z=Math.max(0,Math.min(100,100-gt())),re=Array.from(M.activeCues??[]);if(re.length<=1){re.forEach(ee=>tt(ee,Z));return}const{step:Lt,chars:Mt}=Bt();let wt=Z;for(let ee=re.length-1;ee>=0;ee--){const rn=String(re[ee].text??"").replace(/<[^>]*>/g,"").split(`
|
|
1
|
+
import{u as t,d as _,A as O,h as y,S as We,g as Vr,q as k,o as Fr,p as qr,a as Ur,T as Se}from"./vendor-core-DfaOB3Rn.js";import{u as Hr}from"./vendor-query-BBT5_sHx.js";import{g as en,t as dt,W as Wr,J as An,e as Kr,A as Zn,B as Xt}from"./index-DlcgJVM6.js";import{I as K}from"./vendor-icons-DrybRNxP.js";import{S as Yr,U as jr,p as wn,M as Gr,z as sr,f as Pn,d as Qr,C as Xr,a as Jr,b as Zr,c as Jt,u as es,i as ts,j as ns,n as rs,k as ss,m as as,l as os,s as Bn,e as is,g as ls,h as cs,r as us,o as Ne,A as ds,t as ms,E as bs,x as hs,P as fs,v as de,y as gs,R as ps,q as vs}from"./usePlaybackEnd-DuEfjKb8.js";import{S as ys,O as Ln,a as Ss,A as _s,b as Ts}from"./OptionListMenu-BSUcso28.js";import{M as Cs}from"./MatureConsentModal-Beq4JL0b.js";import{u as ks}from"./useProviders-D0XOHCsj.js";import{d as Es,g as Ns,h as Is,j as xs,f as As,e as Bs,k as Ls,l as Ms}from"./useTvLibrary-DiCSdUOj.js";import{l as ws,s as Ps,i as er,h as tr}from"./playbackCompletion-IPHm9fp5.js";import{l as Rs,c as zs}from"./hls-qvAoYTJt.js";import{u as $s}from"./useIsMobile-Dvx1uJ82.js";import{S as Ds}from"./SynopsisText-B3Sa5pRv.js";import"./libraryInvalidation-DdnIPcOQ.js";const Os="_fullscreenFlat_10bzs_1",Vs="_timeDisplay_10bzs_12",Fs="_bottomControls_10bzs_16",qs="_leftControls_10bzs_20",Us="_rightControls_10bzs_21",Hs="_controlBtn_10bzs_25",Ws="_controlsOverlay_10bzs_32",Ks="_hidden_10bzs_52",Ys="_topControls_10bzs_58",js="_backBtn_10bzs_78",Gs="_videoTitleInfo_10bzs_98",Qs="_animeTitle_10bzs_104",Xs="_episodeLabel_10bzs_112",Js="_speedBoostBadge_10bzs_119",Zs="_progressBarContainer_10bzs_165",ea="_progressBar_10bzs_165",ta="_thumb_10bzs_184",na="_bufferedBar_10bzs_202",ra="_watchedBar_10bzs_212",sa="_scrubbing_10bzs_237",aa="_timeBubble_10bzs_241",oa="_bottomControlsRow_10bzs_255",ia="_nextEpisodeBtn_10bzs_278",la="_active_10bzs_340",ca="_settingsPanel_10bzs_352",ua="_settingsHeader_10bzs_371",da="_settingsBackBtn_10bzs_379",ma="_settingsTitle_10bzs_397",ba="_settingsContent_10bzs_408",ha="_currentValue_10bzs_417",fa="_menuItem_10bzs_423",ga="_menuNote_10bzs_456",pa="_loadingOverlay_10bzs_465",va="_loadingDots_10bzs_476",ya="_dot_10bzs_481",Sa="_bufferingOverlay_10bzs_510",_a="_bufferingSpinner_10bzs_519",o={fullscreenFlat:Os,timeDisplay:Vs,bottomControls:Fs,leftControls:qs,rightControls:Us,controlBtn:Hs,controlsOverlay:Ws,hidden:Ks,topControls:Ys,backBtn:js,videoTitleInfo:Gs,animeTitle:Qs,episodeLabel:Xs,speedBoostBadge:Js,progressBarContainer:Zs,progressBar:ea,thumb:ta,bufferedBar:na,watchedBar:ra,scrubbing:sa,timeBubble:aa,bottomControlsRow:oa,nextEpisodeBtn:ia,active:la,settingsPanel:ca,settingsHeader:ua,settingsBackBtn:da,settingsTitle:ma,settingsContent:ba,currentValue:ha,menuItem:fa,menuNote:ga,loadingOverlay:pa,loadingDots:va,dot:ya,bufferingOverlay:Sa,bufferingSpinner:_a},Ta=({player:s,visible:m,settingsOpen:D,onOpenSettings:L,onCloseSettings:w,hasSubtitles:E,isSubtitleActive:n,subtitles:S,onSubtitleChange:a,showNextEpisodeButton:T,onNextEpisode:U,isTheaterMode:P,onTheaterModeToggle:h,timeLabelRef:Y})=>{const{state:d,refs:Re,actions:$}=s,X=Re.videoRef,Ie=N=>{const ne=X.current;!ne||isNaN(d.duration)||d.duration===0||(ne.currentTime=N*d.duration)},xe=()=>{X.current&&($.setIsScrubbing(!0),$.wasPlayingBeforeScrub.current=!X.current.paused,X.current.pause())},ze=N=>{const ne=X.current;ne&&d.duration&&(ne.currentTime=N*d.duration)},$e=()=>{$.setIsScrubbing(!1),$.wasPlayingBeforeScrub.current&&X.current?.play().catch(()=>{})},Ke=N=>{const ne=X.current;ne&&(ne.volume=N,ne.muted=N===0)},ie=()=>{if(n){a(-1);return}let N=null;try{N=localStorage.getItem("tvLastSubtitle")}catch{}a(wn(S,{lastKey:N,enabled:!0}))},j=d.isMuted?t(K,{name:"volume-mute"}):d.volume<.5?t(K,{name:"volume-down"}):t(K,{name:"volume-up"});return t("div",{className:`${o.controlsOverlay} ${m?"":o.hidden}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:o.bottomControls,onClick:N=>N.stopPropagation(),children:[t(Yr,{classes:{container:o.progressBarContainer,scrubbing:o.scrubbing,timeBubble:o.timeBubble,bar:o.progressBar,buffered:o.bufferedBar,watched:o.watchedBar,thumb:o.thumb},videoRef:X,duration:d.duration,formatTime:en,isScrubbing:d.isScrubbing,buffered:"full",onSeek:Ie,onScrubStart:xe,onScrubMove:ze,onScrubEnd:$e,timeLabelRef:Y}),t("div",{className:o.bottomControlsRow,children:[t("div",{className:o.leftControls,children:[t("button",{className:o.controlBtn,onClick:$.togglePlay,"aria-label":d.isPlaying?"Pause":"Play",children:d.isPlaying?t(K,{name:"pause"}):t(K,{name:"play"})}),t(jr,{muted:d.isMuted,volume:d.volume,volumeIcon:j,buttonClassName:o.controlBtn,onToggleMute:$.toggleMute,onVolumeChange:Ke,onExpandedChange:N=>$.setShowVolumeSlider(N)}),t("span",{className:o.timeDisplay,ref:Y,children:[en(0)," / ",en(d.duration)]})]}),t("div",{className:o.rightControls,children:[T&&t("button",{className:o.nextEpisodeBtn,onClick:U,title:"Play next episode",children:"Next EP"}),E&&t("button",{className:`${o.controlBtn} ${n?o.active:""}`,onClick:ie,"aria-label":n?"Turn subtitles off":"Turn subtitles on",children:t(K,{name:"closed-captioning"})}),t("button",{className:`${o.controlBtn} ${D?o.active:""}`,onClick:()=>D?w():L(),"aria-label":"Settings",children:t(K,{name:"cog"})}),t("button",{className:`${o.controlBtn} ${P?o.active:""}`,onClick:N=>{N.stopPropagation(),h()},title:P?"Exit Theater Mode":"Theater Mode","aria-label":P?"Exit Theater Mode":"Theater Mode",children:t(K,{name:"tv"})}),t("button",{className:o.controlBtn,onClick:$.toggleFullscreen,"aria-label":d.isFullscreen?"Exit Fullscreen":"Fullscreen",children:d.isFullscreen?t(K,{name:"compress"}):t(K,{name:"expand"})})]})]})]})})},Zt=-6e4,Mn=6e4,nr=500,Ca=({classes:s,delayMs:m,onDelayChange:D})=>{const[L,w]=_(null),E=L??m,n=O(D);n.current=D;const S=O(m);S.current=m;const a=O(null);a.current=L,y(()=>{w(null)},[m]),y(()=>()=>{const P=a.current;P!==null&&P!==S.current&&n.current(P)},[]);const T=P=>{S.current=P,a.current=null,n.current(P),w(null)},U=P=>{const h=a.current??S.current,Y=Math.max(Zt,Math.min(Mn,h+P));T(Y)};return t(We,{children:[t("div",{style:{display:"flex",gap:6,padding:"0.5rem 0.75rem 0.25rem"},children:[t("button",{type:"button",className:s.item,onClick:()=>U(-nr),"aria-label":"Show subtitles 0.5 seconds earlier",style:{flex:1,justifyContent:"center"},children:t("span",{children:"-0.5s"})}),t("button",{type:"button",className:s.item,onClick:()=>U(nr),"aria-label":"Show subtitles 0.5 seconds later",style:{flex:1,justifyContent:"center"},children:t("span",{children:"+0.5s"})}),t("button",{type:"button",className:s.item,onClick:()=>T(0),disabled:E===0,"aria-label":"Reset subtitle timing",style:{flex:1,justifyContent:"center"},children:t("span",{children:"Reset"})})]}),t(Gr,{label:"Subtitle timing",display:sr(E),min:Zt,max:Mn,step:100,value:E,percent:(E-Zt)/(Mn-Zt)*100,onChange:P=>{const h=Math.round(P);a.current=h,w(h)},onCommit:()=>{const P=a.current;P!==null&&T(P)}}),t("div",{className:s.note,children:"Positive delays subtitles (show later). Negative shows them earlier. 0.0s is default."})]})},ka=({view:s,onSelectView:m,onClose:D,player:L,onSubtitleStyleChange:w,streams:E,resolutionIdx:n,onResolutionChange:S,hasSubtitles:a,subtitles:T,selectedSubtitle:U,isSubtitleActive:P,onSubtitleChange:h,audioTracks:Y,selectedAudioTrack:d,onAudioTrackChange:Re,videoDelayEnabled:$,onVideoDelayToggle:X,videoDelayMs:Ie,onVideoDelayChange:xe,onCalibrate:ze,subtitleDelayMs:$e,onSubtitleDelayChange:Ke,ambientSettings:ie,onAmbientChange:j})=>{const{state:N}=L,ne=()=>t(We,{children:[E.length>1&&t("button",{className:o.menuItem,onClick:()=>m("resolution"),children:[t("span",{children:"Resolution"}),t("span",{className:o.currentValue,children:E[n]?.quality||"Auto"})]}),a&&t("button",{className:o.menuItem,onClick:()=>m("subtitles"),children:[t("span",{children:"Subtitles"}),t("span",{className:o.currentValue,children:P?T[U]?.label||T[U]?.language:"Off"})]}),a&&t("button",{className:o.menuItem,onClick:()=>m("subtitle-style"),children:[t("span",{children:"Subtitle Style"}),t("span",{className:o.currentValue,children:[N.subtitleFontSize.toFixed(1),"x · ",N.subtitlePosition]})]}),a&&t("button",{className:o.menuItem,onClick:()=>m("subtitle-timing"),children:[t("span",{children:"Subtitle Timing"}),t("span",{className:o.currentValue,children:sr($e)})]}),Y.length>0&&t("button",{className:o.menuItem,onClick:()=>m("audio"),children:[t("span",{children:"Audio Track"}),t("span",{className:o.currentValue,children:Y[d]?.label||Y[d]?.language})]}),t("button",{className:o.menuItem,onClick:()=>m("av-sync"),children:[t("span",{children:"A/V Sync"}),t("span",{className:o.currentValue,children:$?`${Ie}ms`:"Off"})]}),ie&&j&&t("button",{className:o.menuItem,onClick:()=>m("ambient"),children:[t("span",{children:"Ambient Light"}),t("span",{className:o.currentValue,children:ie.enabled?"On":"Off"})]})]}),_e=()=>t(Ln,{classes:{item:o.menuItem,active:o.active},options:E.map((x,W)=>({key:String(W),label:x.quality,selected:W===n})),onSelect:x=>S(Number(x))}),G=()=>t(Ln,{classes:{item:o.menuItem,active:o.active},options:[{key:"off",label:"Off",selected:!P},...T.map((x,W)=>({key:String(W),label:x.label||x.language,selected:W===U}))],onSelect:x=>h(x==="off"?-1:Number(x))}),Te=()=>t(Ss,{classes:{item:o.menuItem,active:o.active},values:{fontSize:N.subtitleFontSize,position:N.subtitlePosition,bgOpacity:N.subtitleBgOpacity,bgColor:N.subtitleBgColor,textColor:N.subtitleTextColor,edge:N.subtitleEdge,bold:N.subtitleBold},onChange:w}),H=()=>t(Ca,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},delayMs:$e,onDelayChange:x=>Ke?.(x)}),Ae=()=>t(Ln,{classes:{item:o.menuItem,active:o.active},options:Y.map((x,W)=>({key:String(W),label:x.label||x.language,selected:W===d})),onSelect:x=>Re(Number(x))}),De=()=>t(_s,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},enabled:$,delayMs:Ie,onToggle:x=>X?.(x),onDelayChange:x=>xe?.(x),onCalibrate:ze}),ge=()=>ie&&j?t(Ts,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},values:ie,onChange:j}):null;return t("div",{"data-speed-boost-ignore":"true",onClick:x=>x.stopPropagation(),children:t(ys,{classes:{panel:o.settingsPanel,header:o.settingsHeader,backBtn:o.settingsBackBtn,title:o.settingsTitle,content:o.settingsContent},title:s==="main"?"Settings":s==="subtitle-style"?"Subtitle Style":s==="subtitle-timing"?"Subtitle Timing":s==="audio"?"Audio Track":s==="resolution"?"Resolution":s==="av-sync"?"A/V Sync":s==="ambient"?"Ambient Light":s.charAt(0).toUpperCase()+s.slice(1),onBack:()=>s==="main"?D():m("main"),children:[s==="main"&&ne(),s==="resolution"&&_e(),s==="subtitles"&&G(),s==="subtitle-style"&&Te(),s==="subtitle-timing"&&H(),s==="audio"&&Ae(),s==="av-sync"&&De(),s==="ambient"&&ge()]})})},Ea=({player:s,title:m,episodeLabel:D,audioTracks:L,selectedAudioTrack:w,onAudioTrackChange:E,subtitles:n,selectedSubtitle:S,onSubtitleChange:a,streams:T,resolutionIdx:U,onResolutionChange:P,onBack:h,children:Y,videoDelayEnabled:d=!1,onVideoDelayToggle:Re,videoDelayMs:$=0,onVideoDelayChange:X,onCalibrateAvSync:Ie,subtitleDelayMs:xe=0,onSubtitleDelayChange:ze,showNextEpisodeButton:$e=!1,onNextEpisode:Ke,isLoading:ie=!1,isTheaterMode:j,onTheaterModeToggle:N,ambientSettings:ne,onAmbientChange:_e})=>{const{state:G,refs:Te,actions:H}=s,Ae=Te.videoRef,{subtitleFontSize:De,subtitlePosition:ge,subtitleBgOpacity:x,subtitleBgColor:W,subtitleTextColor:Je,subtitleEdge:le,subtitleBold:Be}=G,[Ce,Le]=_(null),Ze=O(null),[It,mt]=_(0);y(()=>{const we=Ae.current;if(!we)return;const pe=()=>mt(we.clientHeight||0);pe();const J=new ResizeObserver(pe);return J.observe(we),()=>J.disconnect()},[Ae]);const Ye=H.setSubtitleStyle;y(()=>{const we="tv-player-subtitle-style";let pe=document.getElementById(we);pe||(pe=document.createElement("style"),pe.id=we,document.head.appendChild(pe));const J={fontSize:De,position:ge,bgOpacity:x,bgColor:W,textColor:Je,edge:le,bold:Be},ae=Ae.current,je=Pn(De,It||ae?.clientHeight||720);if(pe.textContent=Qr({...J,fontSize:je}),ae){const gt=()=>{const M=Number(ge);return isNaN(M)?0:Math.max(0,Math.min(100,M))},tt=(M,Z)=>{try{const re=M;re.snapToLines=!1,re.line=Z}catch{}},Bt=()=>{const M=je*16,Z=ae.videoHeight||ae.clientHeight||720,re=ae.videoWidth||ae.clientWidth||1280;return{step:M*1.3/Z*100,chars:Math.max(20,Math.floor(re/(M*.55)))}},nt=M=>{const Z=Math.max(0,Math.min(100,100-gt())),re=Array.from(M.activeCues??[]);if(re.length<=1){re.forEach(ee=>tt(ee,Z));return}const{step:Lt,chars:Mt}=Bt();let wt=Z;for(let ee=re.length-1;ee>=0;ee--){const rn=String(re[ee].text??"").replace(/<[^>]*>/g,"").split(`
|
|
2
2
|
`).reduce((sn,an)=>sn+Math.max(1,Math.ceil(an.length/Mt)),0),Pt=wt-rn*Lt;tt(re[ee],Math.max(0,Pt)),wt=Pt-Lt*.4}},f=()=>{const M=Math.max(0,Math.min(100,100-gt()));Array.from(ae.textTracks).forEach(Z=>{Z.cues&&(Array.from(Z.cues).forEach(re=>tt(re,M)),Z.mode==="showing"&&nt(Z))})};f();const c=M=>{const Z=M.target;Z.mode==="showing"&&nt(Z)},ce=()=>{Array.from(ae.textTracks).forEach(M=>{M.removeEventListener("cuechange",c),M.addEventListener("cuechange",c)}),f()};Array.from(ae.textTracks).forEach(M=>{M.addEventListener("cuechange",c)}),ae.textTracks.addEventListener("addtrack",ce);const ue=Array.from(ae.querySelectorAll("track")),pt=()=>f();return ue.forEach(M=>M.addEventListener("load",pt)),()=>{Array.from(ae.textTracks).forEach(M=>{M.removeEventListener("cuechange",c)}),ae.textTracks.removeEventListener("addtrack",ce),ue.forEach(M=>M.removeEventListener("load",pt))}}},[De,ge,x,W,Je,le,Be,S,n,Ae,It]);const me=n.length>0,bt=S>=0,ht=()=>{Le("main"),H.setShowControls(!0)},B=()=>{Le(null)},et=G.showControls||!!Ce,xt=t(Zr,{visible:et,title:m,episode:D,onBack:h,classes:{overlay:o.controlsOverlay,hidden:o.hidden,top:o.topControls,backBtn:o.backBtn,titleInfo:o.videoTitleInfo,title:o.animeTitle,episode:o.episodeLabel}}),Me=!ie&&!G.isBuffering&&G.duration>0?t(Xr,{isPlaying:G.isPlaying,onTogglePlay:H.togglePlay,onSkipBack:()=>H.seek(-10),onSkipForward:()=>H.seek(10)}):null,At=t(Ta,{player:s,visible:et,settingsOpen:!!Ce,onOpenSettings:ht,onCloseSettings:B,hasSubtitles:me,isSubtitleActive:bt,subtitles:n,onSubtitleChange:a,showNextEpisodeButton:$e,onNextEpisode:Ke,isTheaterMode:j,onTheaterModeToggle:N,timeLabelRef:Ze}),tn=Ce?t(ka,{view:Ce,onSelectView:Le,onClose:B,player:s,onSubtitleStyleChange:Ye,streams:T,resolutionIdx:U,onResolutionChange:P,hasSubtitles:me,subtitles:n,selectedSubtitle:S,isSubtitleActive:bt,onSubtitleChange:a,audioTracks:L,selectedAudioTrack:w,onAudioTrackChange:E,videoDelayEnabled:d,onVideoDelayToggle:Re,videoDelayMs:$,onVideoDelayChange:X,onCalibrate:()=>{Le(null),Ie?.()},subtitleDelayMs:xe,onSubtitleDelayChange:ze,ambientSettings:ne,onAmbientChange:_e}):null,ft=t(We,{children:[ie&&t("div",{className:o.loadingOverlay,"aria-hidden":"true",children:t("div",{className:o.loadingDots,children:[t("div",{className:o.dot}),t("div",{className:o.dot}),t("div",{className:o.dot})]})}),G.isBuffering&&!ie&&t("div",{className:o.bufferingOverlay,"aria-hidden":"true",children:t("div",{className:o.bufferingSpinner})}),G.isSpeedBoostActive&&t("div",{className:o.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(K,{name:"forward",size:12})]})]});return t(Jr,{player:s,topBar:xt,centerControls:Me,bottomBar:!ie&&G.duration>0?At:null,settingsPanel:tn,overlays:ft,isInteracting:!!Ce,onStageClick:B,className:G.isFullscreen?o.fullscreenFlat:"",children:Y})},Na=({servers:s,selectedServer:m,onServerSelect:D})=>s.length===0?null:t("div",{className:Jt.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:Jt.sourceButtons,children:s.map(L=>t("button",{className:`${Jt.sourceButton} ${m===L?Jt.active:""}`,onClick:()=>D(L),children:L},L))})]}),Ia=Vr.memo(Na);function xa({details:s,isMovie:m,season:D,episode:L,videoRef:w,active:E}){const n=O("");n.current||(n.current=`tv-${Date.now()}-${Math.random().toString(36).slice(2)}`);const S=k(()=>{if(!s)return;const a=w.current,T=m?"":`S${String(D).padStart(2,"0")}E${String(L).padStart(2,"0")}`;dt.discord.tvPresence.mutate({title:s.title,episodeLabel:T,isPlaying:a?!a.paused&&!a.ended:!0,thumbnail:s.poster,currentTime:a?a.currentTime:0,duration:a&&a.duration||0,isAdult:s.adult===!0,sessionId:n.current}).catch(()=>{}),dt.discord.heartbeat.mutate({sessionId:n.current}).catch(()=>{})},[s,m,D,L,w]);return y(()=>{if(!s)return;S();const a=window.setInterval(()=>{const T=w.current;(!T||!T.paused)&&S()},15e3);return()=>window.clearInterval(a)},[S,s,w]),y(()=>{if(!s||!E)return;const a=w.current;if(!a)return;const T=()=>S();return a.addEventListener("play",T),a.addEventListener("pause",T),a.addEventListener("seeked",T),()=>{a.removeEventListener("play",T),a.removeEventListener("pause",T),a.removeEventListener("seeked",T)}},[s,E,S,w]),y(()=>{const a=n.current,T=()=>Wr(a),U=()=>T();return window.addEventListener("pagehide",U),window.addEventListener("beforeunload",U),()=>{window.removeEventListener("pagehide",U),window.removeEventListener("beforeunload",U),T()}},[]),{sendPresence:S}}function Aa(s,m,D){const L=()=>{const E=Array.isArray(s.audioTracks)?s.audioTracks.length:0,n=D.getWant(),S=E>0?Math.min(Math.max(0,n),E-1):n;s.audioTrack=S,S!==n&&D.onResolve(S)},w=(E,n)=>{const S=D.getWant(),a=Array.isArray(s.audioTracks)?s.audioTracks.length:0;if(n.id!==S&&S>=0&&S<a){s.audioTrack!==S&&(s.audioTrack=S);return}D.onResolve(n.id)};return s.on(m.MANIFEST_PARSED,L),s.on(m.AUDIO_TRACK_SWITCHED,w),()=>{s.off(m.MANIFEST_PARSED,L),s.off(m.AUDIO_TRACK_SWITCHED,w)}}const Ba=/\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 La(){try{if(Ba.test(navigator.userAgent||""))return!0;const s=navigator.deviceMemory;if(typeof s=="number"&&s>0&&s<2)return!0}catch{}return!1}const Ma="_statusMsg_zqb8u_1",wa="_error_zqb8u_7",Pa="_spinner_zqb8u_11",Ra="_spin_zqb8u_11",za="_sourceLoader_zqb8u_16",$a="_ringSpinner_zqb8u_22",Da="_meta_zqb8u_40",Oa="_year_zqb8u_48",Va="_rating_zqb8u_53",Fa="_typeBadge_zqb8u_62",qa="_tv_zqb8u_70",Ua="_movie_zqb8u_75",Ha="_controlLabel_zqb8u_80",Wa="_select_zqb8u_90",Ka="_playerSection_zqb8u_102",Ya="_video_zqb8u_106",ja="_videoHidden_zqb8u_128",Ga="_delayCanvas_zqb8u_133",Qa="_delayCanvasActive_zqb8u_146",Xa="_subtitleOverlay_zqb8u_150",Ja="_videoIframe_zqb8u_169",Za="_retryButton_zqb8u_177",eo="_sidebarSeason_zqb8u_192",to="_mobileSeasonRow_zqb8u_208",no="_providerSelectWrap_zqb8u_222",ro="_genreRow_zqb8u_230",so="_genreChip_zqb8u_237",ao="_metaRow_zqb8u_247",oo="_detailGrid_zqb8u_256",io="_detailItem_zqb8u_264",lo="_imdbLink_zqb8u_286",g={statusMsg:Ma,error:wa,spinner:Pa,spin:Ra,sourceLoader:za,ringSpinner:$a,meta:Da,year:Oa,rating:Va,typeBadge:Fa,tv:qa,movie:Ua,controlLabel:Ha,select:Wa,playerSection:Ka,video:Ya,videoHidden:ja,delayCanvas:Ga,delayCanvasActive:Qa,subtitleOverlay:Xa,videoIframe:Ja,retryButton:Za,sidebarSeason:eo,mobileSeasonRow:to,providerSelectWrap:no,genreRow:ro,genreChip:so,metaRow:ao,detailGrid:oo,detailItem:io,imdbLink:lo},co=[],uo=[];function rr({error:s,onRetry:m}){return t("div",{className:`${g.statusMsg} ${g.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:s}),t("button",{className:g.retryButton,onClick:m,children:"Retry"})]})})}const No=()=>{const{id:s}=Fr(),[m]=qr(),D=O(m);D.current=m;const L=Ur(),w=Hr(),E=m.get("type"),[n,S]=_(null),[a,T]=_(()=>parseInt(m.get("s")||"1",10)||1),[U,P]=_([]),[h,Y]=_(()=>parseInt(m.get("e")||"1",10)||1),[d,Re]=_(()=>{try{return localStorage.getItem("tvProvider")||""}catch{return""}}),[$,X]=_([]),[Ie,xe]=_(""),{options:ze,isFallback:$e,isLoading:Ke}=ks(),ie=Se(()=>ze.filter(e=>(e.kind??"tv")==="tv").map(e=>({id:e.id,label:e.label,tier:e.tier==="embed"?"embed":"direct",servers:e.servers})),[ze]),j=$e||ie.length===0?co:ie,N=j.filter(e=>e.tier==="direct"),ne=j.filter(e=>e.tier==="embed"),[_e,G]=_(!1),[Te,H]=_(""),[Ae,De]=_([]),[ge,x]=_(0),[W,Je]=_([]),[le,Be]=_(-1),[Ce,Le]=_(0),[Ze,It]=_(""),[mt,Ye]=_(""),[me,bt]=_(()=>{try{return localStorage.getItem("tvServer")||""}catch{return""}}),ht=Se(()=>j.find(e=>e.id===d),[j,d]),B=ht?.tier==="embed",[et,xt]=_([]),[Me,At]=_(""),[tn,ft]=_(""),[we,pe]=_(!1),J=Se(()=>et.length>0?et:ht?.servers??[],[et,ht]),ae=Se(()=>Me?["Embed",...J]:J,[J,Me]),je=we&&!!Me,gt=je?tn||Me:"";y(()=>{if(!Me){ft("");return}let e=!1;return An(`/api/resolve?url=${encodeURIComponent(Me)}`).then(r=>{!e&&r.finalUrl&&ft(r.finalUrl)}).catch(()=>{}),()=>{e=!0}},[Me]);const tt=O([]);y(()=>{tt.current=$},[$]);const Bt=O(ge);y(()=>{Bt.current=ge},[ge]);const nt=O(le);y(()=>{nt.current=le},[le]);const f=es({skipIntervals:uo}),c=f.refs.videoRef,ce=O(null),ue=O([]),pt=O(null),M=O(null),{videoDelayMs:Z,videoDelayEnabled:re,setDelayEnabled:Lt,handleVideoDelayChange:Mt,isCalibrating:wt,testClipActive:ee,stopCalibration:nn,openAvSyncCalibrator:rn,cancelAvSyncCalibrator:Pt,applyAvSyncCalibrator:sn,toggleTestClip:an,calibReturnRef:Rt,effectiveVideoDelayMs:on}=ts(c),[rt,ar]=_(()=>{try{const e=Number(localStorage.getItem("tvSubtitleDelayMs"));if(Number.isFinite(e)&&e>=-6e4&&e<=6e4)return Math.round(e)}catch{}return 0}),ln=O(rt);ln.current=rt;const or=k(e=>{const r=Math.max(-6e4,Math.min(6e4,Math.round(e)));if(ln.current!==r){ln.current=r,ar(r);try{localStorage.setItem("tvSubtitleDelayMs",String(r))}catch{}}},[]);ns({videoRef:c,canvasRef:pt,delayMs:on,enabled:re});const cn=re,ve=cn||rt!==0,{settings:un,update:ir}=rs(),dn=O(ve);dn.current=ve;const mn=k(()=>{if(!dn.current)return;const e=c.current;e&&Array.from(e.textTracks).forEach(r=>{r.mode!=="hidden"&&(r.mode="hidden")})},[c]),{hasConsent:vt,grant:lr}=Kr(),p=E==="movie";xa({details:n,isMovie:p,season:a,episode:h,videoRef:c,active:!B&&!_e&&!Te&&$.length>0});const zt=s?Es(E||"tv",s):"",Q=zt,Rn=Ns(),$t=Is(),Dt=xs(),{toggle:zn,bookmarkedIds:cr,pending:ur}=As(),{data:$n}=Bs(n?zt:void 0),yt=$n?!!$n.inLibrary:zt?cr.has(zt):!1,dr=k(()=>{!n||!s||zn({tmdbId:Number(s),mediaType:E||"tv",title:n.title,poster:n.poster,year:n.year,adult:n.adult})},[n,s,E,zn]),{data:Ot,isFetched:Dn}=Ls(Q||void 0,a,h),Vt=Se(()=>U.map(e=>e.episode_number).sort((e,r)=>e-r),[U]),St=Vt.indexOf(h),bn=St>0?Vt[St-1]:null,V=St>=0&&St<Vt.length-1?Vt[St+1]:null,Ft=Se(()=>(n?.seasons??[]).map(e=>e.season_number).filter(e=>Number.isFinite(e)).sort((e,r)=>e-r),[n]),Oe=Se(()=>{if(p||V!=null)return null;const e=Ft.indexOf(a);return e>=0&&e<Ft.length-1?Ft[e+1]:(n?.number_of_seasons??0)>a?a+1:null},[p,V,Ft,a,n?.number_of_seasons]),mr=Ot?.currentTime??0,hn=O(null),[Ve,qt]=_(!1),[st,On]=_(0),[_t,Vn]=_(!1),[at,ot]=_(!1),[br,fn]=_(!1),[hr,fr]=_(""),[Ut,gr]=_(!1),[pr,gn]=_(!1),{isTheaterMode:Pe,toggleTheaterMode:pn,handleLayoutClick:vr}=ss();y(()=>{const e=r=>{r.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||r.key.toLowerCase()==="t"&&pn()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[pn]),as(f,($.length>0||mt!=="")&&!Pe&&!Ve&&!at);const yr=$s(),[it,Sr]=_(ws),_r=k(e=>{Sr(e),Ps(e)},[]),Fe=O(!1),Ge=O(null),vn=O(0),te=O(null),Tt=O(""),Tr=tr(mr),Ct=!Fe.current&&(Ve||at||Tr),lt=O(Ct);lt.current=Ct;const ct=O(!1);y(()=>{ct.current=_t},[_t]);const qe=k((e,r)=>{if(!Q||!r||r<30)return;const i=er(e,r);Math.abs(e-vn.current)<10&&!i||(vn.current=e,Rn.mutate({mediaId:Q,season:a,episode:h,currentTime:Math.floor(e),duration:Math.floor(r),completed:i,title:n?.title??null,poster:n?.poster??null,backdrop:n?.backdrop??null,year:n?.year??null,overview:n?.overview??null,tmdbId:n?.id??null,mediaType:E||"tv",adult:n?.adult?1:0}))},[Q,a,h,Rn,n,E]),ke=k((e,r)=>{nn();const i=new URLSearchParams(m);i.set("type",m.get("type")||"tv"),i.set("s",String(e)),i.set("e",String(r)),L(`${window.location.pathname}?${i.toString()}`)},[m,L,nn]),kt=k(()=>{const e=c.current;if(!e||p||V==null){fn(!1);return}const r=e.duration||0,i=e.currentTime||0;fn(r>0&&i/r>=.8)},[p,V,c]),Ht=k((e,r)=>["tv-sources",d,p?"movie":"tv",s,e,r,me],[d,p,s,me]),Wt=k(async(e,r)=>{if(!n||!s||!d)return{valid:!1,sources:[]};const i=p?"movie":"tv",u=await dt.tv.sources.query({provider:d,type:i,tmdbId:String(s),season:e,episode:r,title:n.title||"",year:n.year||"",totalSeasons:String(n.number_of_seasons||1),imdbId:n.imdb_id||"",...J.length>0&&me?{server:me}:{}});return{valid:"valid"in u?u.valid:!1,error:"error"in u?u.error:void 0,sources:u.sources,referer:"referer"in u?u.referer:void 0,audioTracks:u.audioTracks,subtitles:"subtitles"in u?u.subtitles:void 0,servers:"servers"in u?u.servers:void 0,embedUrl:"embedUrl"in u?u.embedUrl:void 0}},[n,s,d,p,J,me]),Fn=k(()=>{if(p||!n||!s||!d||B||V==null)return;const e=Ht(a,V);w.getQueryState(e)?.status!=="success"&&w.prefetchQuery({queryKey:e,queryFn:()=>Wt(a,V),staleTime:300*1e3,gcTime:1800*1e3})},[p,n,s,d,B,V,a,w,Ht,Wt]),Cr=k(()=>{if(ee)return;kt();const e=c.current;!e||e.paused||e.ended||(e.duration>0&&e.duration-e.currentTime<=60&&Fn(),Ge.current&&clearTimeout(Ge.current),Ge.current=setTimeout(()=>{qe(e.currentTime,e.duration||0)},5e3))},[qe,c,ee,kt,Fn]),kr=k(()=>{const e=c.current;if(!(!e||!n)){if(Ge.current&&clearTimeout(Ge.current),qe(e.currentTime,e.duration||0),V!=null){it&&(Y(V),ke(a,V));return}fr(p?n.title:`${n.title} - Season ${a}`),ot(!0),Fe.current=!0}},[p,n,a,V,it,qe,ke,c]),{checkEnd:Kt,logDuration:qn}=os({videoRef:c,sourceType:B?"iframe":void 0,resetKey:`${Q}:${a}:${h}`,onEnd:kr}),Er=k(()=>{f.actions.onPlay()},[f.actions]),Nr=k(()=>{f.actions.onPause();const e=c.current;e&&!e.ended&&qe(e.currentTime,e.duration||0)},[f.actions,qe,c]),Ir=k(()=>{f.actions.onLoadedMetadata();const e=c.current;if(e){try{const r=parseFloat(localStorage.getItem("playerVolume")||"");isNaN(r)||(e.volume=Math.max(0,Math.min(1,r))),e.muted=localStorage.getItem("playerMuted")==="true"}catch{}if(te.current!=null&&te.current>0){try{e.currentTime=te.current}catch{}te.current=null}kt()}},[f.actions,c,kt]),yn=k(()=>{const e=c.current;if(e&&te.current!=null&&te.current>0){try{e.currentTime=te.current}catch{}te.current=null}},[c]),xr=k(()=>{st>0&&(te.current=st);const e=c.current;if(e&&st>0){try{e.currentTime=st,te.current=null}catch{}e.play().catch(()=>{})}qt(!1),Fe.current=!0},[st,c]),Un=k(()=>{te.current=null;const e=c.current;e&&(e.currentTime=0,e.play().catch(()=>{})),qt(!1),Fe.current=!0},[c]),Ar=k(()=>{V!=null&&(Fe.current=!0,Y(V),ke(a,V))},[V,a,ke]),Br=k(()=>{Oe!=null&&(ot(!1),Fe.current=!0,T(Oe),Y(1),ke(Oe,1))},[Oe,ke]),Lr=k(async()=>{if(Q)try{yt?await $t.mutateAsync({id:Q,status:"Completed"}):n&&s&&(await Dt.mutateAsync({tmdbId:Number(s),mediaType:E||"tv",title:n.title,poster:n.poster,backdrop:n.backdrop,year:n.year,overview:n.overview,adult:n.adult,status:"Completed",silent:!0}),Zn.success("Moved to Completed")),ot(!1),L("/")}catch{}},[Q,yt,$t,Dt,n,s,E,L]);y(()=>{Fe.current=!1,hn.current=null,qt(!1),fn(!1),On(0),Vn(!1),ct.current=!1,te.current=null,Tt.current=`${Q}:${a}:${h}`,vn.current=0},[Q,a,h]),y(()=>{Dn&&(Vn(!0),ct.current=!0)},[Dn,Q,a,h]),y(()=>{if(!Ot||Fe.current)return;const e=`${Q}:${a}:${h}`;if(hn.current===e)return;hn.current=e;const i=Ot.currentTime??0;tr(i)&&(On(i),qt(!0))},[Ot,Q,a,h]),y(()=>{Ve&&c.current&&c.current.pause()},[Ve,c]),y(()=>{const e=c.current;return()=>{Ge.current&&clearTimeout(Ge.current),e&&!e.ended&&qe(e.currentTime,e.duration||0)}},[qe,c]);const Sn=k(e=>{let r=null,i=!0;try{r=localStorage.getItem("tvLastSubtitle"),i=localStorage.getItem("tvSubtitlesEnabled")!=="false"}catch{}return wn(e,{lastKey:r,enabled:i})},[]),_n=k(e=>{if(!(e<0))try{localStorage.setItem("tvSubtitlesEnabled","true"),localStorage.setItem("tvSelectedSubtitle",String(e))}catch{}},[]),Hn=k(e=>{if(e.length===0)return 0;let r=null;try{r=localStorage.getItem("tvLastAudio")}catch{}if(r){const i=e.findIndex(b=>Bn(b)===r);if(i>=0)return i;const u=r.indexOf("|||"),l=u>=0?r.slice(0,u):r,A=u>=0?r.slice(u+3):r,R=e.findIndex(b=>b.language===l||b.label===A);if(R>=0)return R}return wn(e,{lastKey:null,enabled:!0})},[]),{data:Wn}=Ms(Q||void 0),Kn=Se(()=>(Wn?.progress??[]).filter(r=>r.season===a&&(r.completed===1||r.completed===1||er(r.currentTime,r.duration))).map(r=>String(r.episode)),[Wn,a]),Yn=Se(()=>U.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})),[U]),jn=Se(()=>(n?.genres??[]).map(e=>e.name).slice(0,5),[n]),Tn=Se(()=>[n?.year,n?.status,n?.number_of_seasons?`${n.number_of_seasons} Season${n.number_of_seasons>1?"s":""}`:null,n?.number_of_episodes?`${n.number_of_episodes} Episodes`:null].filter(Boolean),[n]);y(()=>{if(j.length!==0&&!j.some(e=>e.id===d)){const e=j.find(r=>r.tier==="direct")?.id??j[0].id;Re(e);try{localStorage.setItem("tvProvider",e)}catch{}}},[j,d]),y(()=>{xt([]),At(""),ft(""),pe(!1)},[d]),y(()=>{if(J.length!==0&&!J.includes(me)){bt(J[0]);try{localStorage.setItem("tvServer",J[0])}catch{}}},[J,me]),y(()=>{if(!s){S(null),X([]),xe(""),H(""),Ye("");return}const e=Number(s),r=E||"tv";S(null),X([]),xe(""),H(""),Ye("");const i=parseInt(D.current.get("s")||"",10),u=parseInt(D.current.get("e")||"",10);T(isNaN(i)?1:i),Y(isNaN(u)?1:u),Le(0),dt.tv.details.query({type:r,id:String(e)}).then(l=>{const A={id:l.id,title:l.title||"",overview:l.overview||"",vote_average:l.vote_average,year:l.year,poster:l.poster,backdrop:l.backdrop,imdb_id:l.imdb_id||void 0,adult:l.adult,seasons:l.seasons,number_of_seasons:l.number_of_seasons};S(A),A.seasons&&A.seasons.length>0&&isNaN(i)&&T(A.seasons[0].season_number)}).catch(()=>{})},[s,E]),y(()=>{if(!n||!s)return;if(!(n.seasons!==void 0||n.number_of_seasons!==void 0)){P([]);return}const r=parseInt(m.get("e")||"",10);dt.tv.episodes.query({id:String(s),season:String(a)}).then(i=>{const u=(i.episodes||[]).map(l=>({episode_number:l.episode_number,name:l.name||"",vote_average:l.vote_average,overview:l.overview||"",still_path:l.still_path||""}));P(u),u.length!==0&&Y(l=>!isNaN(r)&&u.some(A=>A.episode_number===r)?r:u.some(A=>A.episode_number===l)?l:u[0].episode_number)}).catch(()=>{})},[n,s,a,m]),y(()=>{if(!B||!n||!s)return;An(`/api/tv/embed/${d}/${p?"movie":"tv"}/${s}?season=${a}&episode=${h}`).then(r=>{if(r.url)return Ye(r.url),An(`/api/resolve?url=${encodeURIComponent(r.url)}`).then(i=>{i.finalUrl&&Ye(i.finalUrl)})}).catch(()=>{})},[d,n,s,a,h,p,B]);const Yt=k(async()=>{if(!n||!s||!d||B||n.adult&&!vt)return;const e=`${Q}:${a}:${h}`;G(!0),H(""),tt.current.length===0&&(X([]),Le(0),De([]),Je([]));try{const r=await w.fetchQuery({queryKey:Ht(a,h),queryFn:()=>Wt(a,h),staleTime:3e5,gcTime:18e5});if(Tt.current!==e){G(!1);return}if(G(!1),!r.valid||!r.sources?.length){H(r.error?`${r.error}`:J.length>0?`No streams from ${me}. Try another server.`:"No streams available.");return}X(r.sources),xe(e),r.servers?.length&&xt(r.servers),r.embedUrl&&At(r.embedUrl),Le(0),r.referer&&It(r.referer);const i=r.audioTracks||[];De(i),x(i.length>0?Hn(i):0);const u=r.subtitles||[];if(Je(u),u.length>0){const R=Sn(u);Be(R),_n(R)}else Be(-1);const l=p?"movie":"tv",A=s;dt.tv.subtitles.query({type:l,tmdbId:String(A),season:String(a),episode:String(h)}).then(R=>{if(Tt.current!==e)return;const b=Array.isArray(R.subtitles)?R.subtitles:[];b.length!==0&&Je(se=>{const be=[...se,...b.filter(v=>!se.some(he=>he.url===v.url))];if(se.length===0){const v=Sn(be);Be(v),_n(v)}return be})}).catch(()=>{}),H("")}catch(r){if(Tt.current!==e)return;G(!1),H(r instanceof Error?r.message:"Failed to load streams.")}},[n,s,d,a,h,p,B,vt,J,me,Sn,_n,Hn,Q,w,Ht,Wt]),Cn=k(()=>{const e=c.current;e&&!isNaN(e.currentTime)&&(te.current=e.currentTime)},[c]),Mr=k(e=>{if(e==="Embed"){pe(!0);return}Cn(),pe(!1),bt(e);try{localStorage.setItem("tvServer",e)}catch{}H("")},[Cn]),wr=k(e=>{Re(e);try{localStorage.setItem("tvProvider",e)}catch{}},[]);y(()=>{d&&n&&!B&&Yt()},[d,n,Yt,B]),y(()=>{if(!c.current)return;if(ce.current&&(ce.current.destroy(),ce.current=null),B||je){const b=c.current;b&&(b.pause(),b.removeAttribute("src"),b.load());return}let e=!1;if(ee){const b=c.current;return b&&(b.pause(),b.removeAttribute("src"),b.load(),b.src="/av-sync-test.mp4",lt.current||b.play().catch(()=>{})),()=>{e=!0}}if(Rt.current!=null&&(te.current=Rt.current,Rt.current=null),Tt.current===`${Q}:${a}:${h}`&&te.current==null&&!lt.current)try{const b=c.current;b&&!b.ended&&b.currentTime>1&&(te.current=b.currentTime)}catch{}const i=te.current??0,u=!_e&&Ie===`${Q}:${a}:${h}`?je?"":$[Ce]?.url||"":"";if(!u){try{c.current?.pause(),c.current?.removeAttribute("src"),c.current?.load()}catch{}return}const l=c.current;l.pause(),l.removeAttribute("src"),l.load(),f.actions.resetMediaState();const A=`/api/tv/stream-proxy?url=${encodeURIComponent(u)}&referer=${encodeURIComponent(Ze)}&provider=${encodeURIComponent(d)}`;$[Ce]?.type==="hls"?(async()=>{const b=await Rs();if(!e)if(b&&b.isSupported()){const se=La()||document.body.classList.contains("low-end"),be=se?60:180,v=new b({enableWorker:!0,lowLatencyMode:!1,startPosition:i>0?i:-1,maxBufferLength:be,maxMaxBufferLength:be+(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}}}});ce.current=v,v.on(b.Events.ERROR,(z,I)=>{I.fatal&&(H(`Stream failed (${I.details}). Try another source or reload.`),G(!1),v.destroy(),ce.current=null)}),v.loadSource(A),v.attachMedia(l);const he=()=>{let z=!1,I=0;try{z=localStorage.getItem("tvSubtitlesEnabled")==="true";const C=parseInt(localStorage.getItem("tvSelectedSubtitle")||"0",10);!isNaN(C)&&C>=0&&(I=C)}catch{}return{enabled:z,index:I}},F=()=>{if(typeof v.subtitleTrack!="number")return;if(ue.current.length>0){v.subtitleTrack=-1;return}const z=Array.isArray(v.subtitleTracks)?v.subtitleTracks:[];if(z.length===0){v.subtitleTrack=-1;return}const I=he();if(I.enabled){const C=I.index<z.length?I.index:0;v.subtitleTrack=C,Be(C),mn()}else v.subtitleTrack=-1};Aa(v,b.Events,{getWant:()=>Bt.current,onResolve:z=>x(z)}),v.on(b.Events.MANIFEST_PARSED,()=>{F(),(i>0||!lt.current&&ct.current)&&l.play().catch(()=>f.actions.setShowControls(!0))}),v.on(b.Events.SUBTITLE_TRACKS_UPDATED,()=>{F()}),v.on(b.Events.SUBTITLE_TRACK_SWITCH,(z,I)=>{if(ue.current.length>0){if(I.id!==-1)try{v.subtitleTrack=-1}catch{}return}const C=Array.isArray(v.subtitleTracks)?v.subtitleTracks:[];if(C.length!==0){if(I.id===-1){const ye=he();if(ye.enabled){const oe=ye.index<C.length?ye.index:0;v.subtitleTrack=oe;return}}Be(I.id),mn()}})}else zs(l)&&(l.src=A,(i>0||!lt.current&&ct.current)&&l.play().catch(()=>{H("Failed to play stream. Try another source.")}))})():(l.src=A,(i>0||!lt.current&&ct.current)&&l.play().catch(()=>{H("Failed to play stream. Try another source.")}));const R=()=>{const be=l.error?.code===4?"Video source not supported or not found":"Failed to load video stream";H(`${be}. The source may be invalid or expired. Try switching source or reloading.`),G(!1)};return l.addEventListener("error",R),()=>{e=!0,l.removeEventListener("error",R)}},[$,Ie,_e,Ce,d,Ze,B,je,c,Rt,ee,Q,a,h,yn,mn,f.actions]),y(()=>{if(!_t||Ve||at||Ct||B||ee)return;const e=c.current;!e||!e.paused||e.ended||e.readyState<1||(yn(),e.play().catch(()=>{}))},[_t,Ve,at,Ct,B,ee,yn,c]),y(()=>{const e=ce.current;!e||typeof e.audioTrack!="number"||(e.audioTrack=ge)},[ge]),y(()=>{const e=ce.current;!e||typeof e.subtitleTrack!="number"||!Array.isArray(e.subtitleTracks)||e.subtitleTracks.length===0||ue.current.length>0||(le>=0?e.subtitleTrack=le:e.subtitleTrack=-1)},[le]),y(()=>{const e=c.current;if(!(!e||B)&&(e.querySelectorAll("track").forEach(r=>r.remove()),ue.current=[],W.length!==0&&(W.forEach(r=>{const i=document.createElement("track");i.kind="subtitles",i.label=r.label||r.language||"Unknown",i.srclang=r.language||r.label||"en";const u=`/api/subtitle-proxy?url=${encodeURIComponent(r.url)}&referer=${encodeURIComponent(Ze)}`;i.src=u,i.addEventListener("load",()=>{const l=ue.current.indexOf(i),A=i.track;if(A&&l>=0){const R=l===nt.current;A.mode=R&&!dn.current?"showing":"hidden"}}),e.appendChild(i),ue.current.push(i)}),W.length>0)))try{const r=ce.current;r&&typeof r.subtitleTrack=="number"&&r.subtitleTrack!==-1&&(r.subtitleTrack=-1)}catch{}},[W,Ze,B,d,c]),y(()=>{const e=c.current;if(!e||B)return;const r=ce.current;ue.current.length>0&&r&&typeof r.subtitleTrack=="number"&&Array.isArray(r.subtitleTracks)&&r.subtitleTracks.length>0&&(r.subtitleTrack=-1);const i=()=>{const A=Pn(f.state.subtitleFontSize,e.clientHeight||720),R=Math.max(0,Math.min(100,100-f.state.subtitlePosition)),b=()=>{const F=A*16,z=e.videoHeight||e.clientHeight||720,I=e.videoWidth||e.clientWidth||1280;return{step:F*1.3/z*100,chars:Math.max(20,Math.floor(I/(F*.55)))}},se=(F,z)=>{const I=F;I.snapToLines=!1,I.line=z},be=F=>{if(!F.cues)return;Array.from(F.cues).forEach(oe=>se(oe,R));const z=Array.from(F.activeCues??[]);if(z.length<=1){z.forEach(oe=>se(oe,R));return}const{step:I,chars:C}=b();let ye=R;for(let oe=z.length-1;oe>=0;oe--){const Ue=String(z[oe].text??"").replace(/<[^>]*>/g,"").split(`
|
|
3
3
|
`).reduce((Gt,Et)=>Gt+Math.max(1,Math.ceil(Et.length/C)),0);ye=Math.max(0,ye-Ue*I),se(z[oe],ye),ye-=I*.4}},v=ue.current;if(v.length>0){v.forEach((F,z)=>{const I=F.track;if(!I)return;const C=z===le;I.mode=C&&!ve?"showing":"hidden",C&&!ve&&be(I)});return}const he=Array.from(e.textTracks);he.length!==0&&he.forEach((F,z)=>{const I=z===le;F.mode=I&&!ve?"showing":"hidden",I&&!ve&&be(F)})};i();const u=()=>i();e.textTracks.addEventListener("addtrack",u),e.addEventListener("loadedmetadata",i,{once:!0});const l=window.setTimeout(i,600);return()=>{e.textTracks.removeEventListener("addtrack",u),e.removeEventListener("loadedmetadata",i),window.clearTimeout(l)}},[le,W,B,d,c,ve,f.state.subtitleFontSize,f.state.subtitlePosition]),y(()=>{if(!ve)return;const e=c.current,r=M.current;if(!e||!r)return;const i=rt/1e3,u=on/1e3,l=new Set;let A=[],R=-1,b=-1,se=-1,be=-1,v=0,he=0,F=!1;const z=()=>{const q=nt.current;if(q<0)return null;const He=ue.current;return He.length>0?He[q]?.track??null:Array.from(e.textTracks)[q]??null},I=(q,He)=>{const fe=q.cues;if(!fe||fe.length===0)return Array.from(q.activeCues??[]);let Qe=0,Xe=fe.length;for(;Qe<Xe;){const Ee=Qe+Xe>>>1;fe[Ee].endTime+i<He?Qe=Ee+1:Xe=Ee}const Nt=[];for(let Ee=Qe;Ee<fe.length;Ee++){const Qt=fe[Ee];if(Qt.startTime+i>He)break;Qt.endTime+i>=He&&Nt.push(Qt)}return Nt},C=()=>{const q=z(),He=e.currentTime-u,fe=q?I(q,He):[],Qe=e.clientWidth,Xe=e.clientHeight,Nt=e.videoWidth,Ee=e.videoHeight;if(fe.length===A.length&&fe.every((Nn,In)=>Nn===A[In])&&Qe===R&&Xe===b&&Nt===se&&Ee===be||(A=fe,R=Qe,b=Xe,se=Nt,be=Ee,r.textContent="",fe.length===0))return;const Xn={fontSize:Pn(f.state.subtitleFontSize,Xe),position:f.state.subtitlePosition,bgOpacity:f.state.subtitleBgOpacity,bgColor:f.state.subtitleBgColor,textColor:f.state.subtitleTextColor,edge:f.state.subtitleEdge,bold:f.state.subtitleBold},$r=is(Xn),Dr=ls(e,Xn.position);fe.forEach((Nn,In)=>{const Jn=String(Nn.text??"");if(!cs(Jn).trim())return;const xn=document.createElement("div"),Or=(fe.length-1-In)*1.7;xn.style.cssText=`${$r}
|
|
4
4
|
bottom: calc(${Dr}px + ${Or}em);`,xn.innerHTML=us(Jn),r.appendChild(xn)})},ye=()=>{Array.from(e.textTracks).forEach(q=>{l.has(q)||(l.add(q),q.addEventListener("cuechange",C))})},oe=()=>{ye(),C()},En=()=>{if(F||he)return;const q=()=>{he=0,!(F||e.paused||e.ended)&&(C(),En())};he=window.requestAnimationFrame(q)},Ue=e,Gt=()=>{v=0,C(),!F&&Ue.requestVideoFrameCallback&&(v=Ue.requestVideoFrameCallback(Gt))},Et=()=>{C(),Ue.requestVideoFrameCallback?v||(v=Ue.requestVideoFrameCallback(Gt)):En()};ye(),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",Et);const Gn=Array.from(e.querySelectorAll("track"));Gn.forEach(q=>q.addEventListener("load",C));const Qn=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>C());return Qn?.observe(e),C(),Et(),()=>{F=!0,l.forEach(q=>q.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",Et),Gn.forEach(q=>q.removeEventListener("load",C)),Qn?.disconnect(),he&&window.cancelAnimationFrame(he),v&&Ue.cancelVideoFrameCallback&&Ue.cancelVideoFrameCallback(v),r.textContent=""}},[ve,rt,le,W,on,c,f.state.subtitleFontSize,f.state.subtitlePosition,f.state.subtitleBgOpacity,f.state.subtitleBgColor,f.state.subtitleTextColor,f.state.subtitleEdge,f.state.subtitleBold]);const kn=()=>{S(null),X([]),Ye(""),L(-1)},Pr=k(e=>{T(e),Y(1),ke(e,1)},[ke]),jt=!p&&n?.seasons&&n.seasons.length>1?t("label",{className:g.sidebarSeason,children:[t("span",{children:"Season"}),t("select",{value:a,onChange:e=>Pr(parseInt(e.currentTarget.value,10)||1),className:g.select,children:n.seasons.map(e=>t("option",{value:e.season_number,children:["Season ",e.season_number," (",e.episode_count," ep)"]},e.season_number))})]}):null,ut=k(e=>{const r=parseInt(e,10);if(!isNaN(r)){try{c.current?.pause()}catch{}Y(r),ke(a,r)}gn(!1)},[a,ke,c]);y(()=>{if(p)return;const e=r=>{r.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||r.key.toLowerCase()==="n"&&(V!=null?ut(String(V)):Zn.error("No next episode available"))};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[p,V,ut]);const Rr=e=>{x(e);try{const i=Ae[e];i&&localStorage.setItem("tvLastAudio",Bn(i))}catch{}const r=ce.current;r&&r.audioTrack!==void 0&&(r.audioTrack=e)},zr=e=>{Be(e);try{if(e===-1)localStorage.setItem("tvSubtitlesEnabled","false");else{localStorage.setItem("tvSubtitlesEnabled","true"),localStorage.setItem("tvSelectedSubtitle",String(e));const l=W[e];l&&localStorage.setItem("tvLastSubtitle",Bn(l))}}catch{}const r=c.current,i=ce.current;if(i&&typeof i.subtitleTrack=="number"&&Array.isArray(i.subtitleTracks)&&i.subtitleTracks.length>0&&(i.subtitleTrack=ue.current.length>0||e<0?-1:e),!r)return;const u=ue.current;if(u.length>0){u.forEach((l,A)=>{const R=l.track;if(!R)return;const b=A===e;R.mode=b&&!ve?"showing":"hidden"});return}Array.from(r.textTracks).forEach((l,A)=>{const R=A===e;l.mode=R&&!ve?"showing":"hidden"})};return y(()=>{if(!n){document.title="TV & Movies - dango";return}document.title=p?`${n.title} - dango`:`${n.title} - Season ${a} Episode ${h} - dango`},[n,p,a,h]),y(()=>{if(!n||p)return;const e=new URLSearchParams(m),r=e.get("s"),i=e.get("e"),u=String(a),l=String(h);r===u&&i===l||(e.set("type",m.get("type")||"tv"),e.set("s",u),e.set("e",l),L(`${window.location.pathname}?${e.toString()}`,{replace:!0}))},[n,p,a,h,m,L]),t("div",{className:`${Ne.playerPageLayout} ${Pe?Ne.theaterMode:""} ${p?Ne.noSidebar:""}`,onClick:vr,children:[Pe&&t(ds,{videoRef:c,active:un.enabled&&!B&&$.length>0&&!Te&&!(n?.adult&&!vt),settings:un}),!Pe&&!p&&t("aside",{className:Ne.episodeSidebar,children:n?t(ms,{episodes:Yn,currentEpisode:String(h),watchedEpisodes:Kn,onEpisodeClick:ut,header:jt}):t(bs,{variant:"sidebar"})}),t("div",{className:Ne.playerMain,children:[n&&t("div",{className:g.playerSection,onContextMenu:e=>e.preventDefault(),style:n.adult&&!vt?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:B&&mt?t("iframe",{src:mt,className:g.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!B&>?t("iframe",{src:gt,className:g.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!B&&($.length>0||_e)?t(We,{children:[Te&&t(rr,{error:Te,onRetry:Yt}),t(Ea,{player:f,title:n.title,episodeLabel:p?void 0:`S${a} E${h}`,audioTracks:Ae,selectedAudioTrack:ge,onAudioTrackChange:Rr,subtitles:W,selectedSubtitle:le,onSubtitleChange:zr,streams:$,resolutionIdx:Ce,onResolutionChange:e=>{Cn(),Le(e)},onBack:kn,videoDelayEnabled:re,onVideoDelayToggle:Lt,videoDelayMs:Z,onVideoDelayChange:Mt,onCalibrateAvSync:rn,subtitleDelayMs:rt,onSubtitleDelayChange:or,showNextEpisodeButton:br&&!Ve&&!at,onNextEpisode:Ar,isLoading:_e,isTheaterMode:Pe,onTheaterModeToggle:pn,ambientSettings:un,onAmbientChange:ir,children:[t("video",{ref:c,autoPlay:_t&&!Ct,playsInline:!0,disablePictureInPicture:!0,className:`${g.video} ${cn?g.videoHidden:""}`,onTimeUpdate:()=>{ee||(Cr(),Kt())},onEnded:()=>{ee||Kt(!0)},onPlay:Er,onPause:Nr,onSeeked:()=>{ee||(kt(),Kt())},onLoadedMetadata:()=>{Ir(),qn(),Kt()},onDurationChange:()=>{f.actions.onDurationChange(),qn()},onVolumeChange:f.actions.onVolumeChange,onWaiting:f.actions.onWaiting,onPlaying:f.actions.onPlaying,onCanPlay:f.actions.onCanPlay,onContextMenu:e=>e.preventDefault(),onError:()=>{H("Video failed to load. Try another server or reload."),G(!1)}}),t("canvas",{ref:pt,className:`${g.delayCanvas} ${cn?g.delayCanvasActive:""}`}),ve&&t("div",{ref:M,className:g.subtitleOverlay}),t(hs,{isOpen:wt,ms:Z,onChange:Mt,onApply:sn,onClose:Pt,testClipActive:ee,onTestClip:an})]})]}):Te&&!B?t(rr,{error:Te,onRetry:Yt}):null}),!Pe&&n&&t(fs,{}),!Pe&&jt&&t("div",{className:g.mobileSeasonRow,children:jt}),!Pe&&n&&t("div",{className:de.streamPanel,children:[t("div",{className:g.providerSelectWrap,children:t("label",{className:g.controlLabel,children:["Provider",t("select",{value:d,onChange:e=>wr(e.currentTarget.value),className:g.select,disabled:j.length===0,children:Ke?t("option",{value:"",children:"Loading..."}):j.length===0?t("option",{value:"",children:"No providers available"}):t(We,{children:[N.length>0&&t("optgroup",{label:"Direct HLS",children:N.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))})]})})]})}),!B&&(_e?t("div",{className:g.sourceLoader,children:t("div",{className:g.ringSpinner})}):t(Ia,{servers:ae,selectedServer:we?"Embed":me,onServerSelect:Mr}))]}),!Pe&&n&&t("div",{className:Ne.playerInfoContainer,children:[t("div",{className:Ne.playerInfoHeader,children:[t("div",{className:Ne.playerAnimeCard,children:n.poster&&t("img",{src:`https://image.tmdb.org/t/p/w342${n.poster}`,alt:n.title,loading:"lazy",decoding:"async"})}),t("div",{className:Ne.videoTitleSection,children:[t("div",{className:de.titleContainer,children:[t("h1",{children:n.title}),t("div",{className:g.meta,children:[t("span",{className:g.year,children:n.year}),n.vote_average!=null&&n.vote_average>0&&t("span",{className:g.rating,children:[t(K,{name:"star",size:12}),Number(n.vote_average).toFixed(1)]}),t("span",{className:`${g.typeBadge} ${g[p?"movie":"tv"]}`,children:p?"Movie":"TV Show"})]}),jn.length>0&&t("div",{className:g.genreRow,children:jn.map(e=>t("span",{className:g.genreChip,children:e},e))}),Tn.length>0&&t("div",{className:g.metaRow,children:Tn.map((e,r)=>t("span",{children:[e,r<Tn.length-1?" · ":""]},`${e}-${r}`))})]}),t("div",{className:de.controls,children:[t("button",{className:`${de.watchlistBtn} ${yt?de.inList:""}`,onClick:dr,disabled:ur,type:"button",children:[yt?t(K,{name:"check",size:14}):t(K,{name:"plus",size:14}),yt?"In Watchlist":"Add to Watchlist"]}),!p&&t(We,{children:[t("button",{className:`${de.watchlistBtn}`,onClick:()=>bn!=null&&ut(String(bn)),disabled:bn==null,type:"button",children:[t(K,{name:"chevron-left",size:14}),"Prev EP"]}),t("button",{className:`${de.watchlistBtn}`,onClick:()=>V!=null&&ut(String(V)),disabled:V==null,type:"button",children:["Next EP",t(K,{name:"chevron-right",size:14})]}),!p&&t("button",{className:`${de.watchlistBtn} ${de.modeToggleBtn} ${it?de.modeToggleActive:""}`,onClick:()=>_r(!it),type:"button","aria-pressed":it,children:it?"AUTOPLAY: ON":"AUTOPLAY: OFF"}),yr&&t("button",{className:`${de.watchlistBtn}`,onClick:()=>gn(!0),type:"button",children:[t(K,{name:"list-ul",size:14}),"Episodes"]})]})]})]})]}),t("div",{className:Ne.infoColumns,children:[t("div",{className:`${de.descriptionSection} ${de.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t(Ds,{text:n.overview,emptyText:"No description available."}),t("button",{className:de.detailsToggleBtn,onClick:()=>gr(!Ut),type:"button",children:[Ut?t(K,{name:"chevron-up"}):t(K,{name:"chevron-down"}),Ut?"Hide Details":"Show Details"]})]}),Ut&&t("div",{className:g.detailGrid,children:[n.first_air_date&&t("div",{className:g.detailItem,children:[t("strong",{children:p?"Release Date":"First Air Date"}),t("span",{children:n.first_air_date})]}),n.last_air_date&&t("div",{className:g.detailItem,children:[t("strong",{children:"Last Air Date"}),t("span",{children:n.last_air_date})]}),n.networks&&n.networks.length>0&&t("div",{className:g.detailItem,children:[t("strong",{children:"Networks"}),t("span",{children:n.networks.map(e=>e.name).join(", ")})]}),n.created_by&&n.created_by.length>0&&t("div",{className:g.detailItem,children:[t("strong",{children:"Created By"}),t("span",{children:n.created_by.map(e=>e.name).join(", ")})]}),n.episode_run_time&&n.episode_run_time.length>0&&t("div",{className:g.detailItem,children:[t("strong",{children:"Episode Runtime"}),t("span",{children:[n.episode_run_time[0]," min"]})]}),n.imdb_id&&t("div",{className:g.detailItem,children:[t("strong",{children:"IMDb"}),t("a",{href:`https://www.imdb.com/title/${n.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:g.imdbLink,children:"View on IMDb"})]})]})]})]}),!p&&t(gs,{isOpen:pr,onClose:()=>gn(!1),episodes:Yn,currentEpisode:String(h),watchedEpisodes:Kn,onEpisodeClick:ut,header:jt}),n?.adult&&!vt&&t(Cs,{isOpen:!0,onClose:kn,onGrant:lr}),t(ps,{isOpen:Ve,onClose:Un,title:"Resume Watching",message:t(We,{children:["You were at ",t("strong",{children:en(st)})]}),restartLabel:"Start from Beginning",onResume:xr,onRestart:Un}),t(vs,{isOpen:at,onClose:()=>ot(!1),title:p?"Movie Completed!":Oe!=null?"Season Complete!":"Show Completed!",heading:hr,message:p?"You finished this movie!":Oe!=null?`You finished Season ${a}.`:"Congratulations! You finished all available episodes.",children:[t(Xt,{variant:"secondary",onClick:()=>ot(!1),children:"Close"}),Oe!=null?t(Xt,{onClick:Br,children:["Start Season ",Oe]}):t(We,{children:[t(Xt,{onClick:()=>{ot(!1),kn()},children:"Back to Details"}),t(Xt,{onClick:Lr,disabled:$t.isPending||Dt.isPending,children:$t.isPending||Dt.isPending?"Saving...":"Move to Completed"})]})]}),!n&&t("div",{className:g.statusMsg,children:[t(K,{name:"spinner",className:g.spinner})," Loading..."]})]})]})};export{No as default};
|