@serifpersia/dango 3.9.5 → 3.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/client/dist/assets/{AnimeCard-Bxo3dYi6.js → AnimeCard-BMhqfrkR.js} +1 -1
- package/client/dist/assets/{AnimeInfo-BVfj052Q.js → AnimeInfo-Dpvt4Bfs.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-V0Kmrgoa.js → AnimeInfoPage-CE1CxT-q.js} +2 -2
- package/client/dist/assets/{Asmr-C_uiD3nU.js → Asmr-Doj5jfXK.js} +1 -1
- package/client/dist/assets/{AsmrPopup-BqQpgR1K.js → AsmrPopup-Dj-Fzc8U.js} +1 -1
- package/client/dist/assets/{AsmrResetProgressModal-Csv4GiEL.js → AsmrResetProgressModal-DgFLBUSO.js} +1 -1
- package/client/dist/assets/{ErrorMessage-DAxegITP.js → ErrorMessage-hMt90aG4.js} +1 -1
- package/client/dist/assets/{Home-BVuZXbYG.js → Home-D163aa5L.js} +1 -1
- package/client/dist/assets/{Insights-CzqiUsSq.js → Insights-C1P7cKeY.js} +1 -1
- package/client/dist/assets/{LibraryListPage-CIqBrHf2.js → LibraryListPage-D-SFU6Ob.js} +1 -1
- package/client/dist/assets/{ListeningList-DBEOg6Pf.js → ListeningList-oyVVadHX.js} +1 -1
- package/client/dist/assets/{Manga-CMsgHNRo.js → Manga-B3jtSBx5.js} +1 -1
- package/client/dist/assets/{MangaInfoPage-BtoWZDAH.js → MangaInfoPage-DRVn2mAe.js} +1 -1
- package/client/dist/assets/{MangaReadPage-C5s5sOKl.js → MangaReadPage-BnlHoZaL.js} +1 -1
- package/client/dist/assets/{MangaResetProgressModal-BBIVaAVA.js → MangaResetProgressModal-BUz2MLDA.js} +1 -1
- package/client/dist/assets/{Mature-C5nVO-pD.js → Mature-C_6AL77P.js} +1 -1
- package/client/dist/assets/{MatureConsentModal-GDXcsFKz.js → MatureConsentModal-CC0bqpsd.js} +1 -1
- package/client/dist/assets/{MediaCard-DMGlm3fW.js → MediaCard-CeCsiCpy.js} +1 -1
- package/client/dist/assets/{OptionListMenu-DpPePCh7.js → OptionListMenu-BRI8vna9.js} +1 -1
- package/client/dist/assets/{Player-CGfFv0_G.js → Player-CWw0u5o2.js} +2 -2
- package/client/dist/assets/{PlayerProvider-zJDJ7w2h.js → PlayerProvider-9AfeIQ6B.js} +1 -1
- package/client/dist/assets/{PlayerSettings-B7FQWSSv.js → PlayerSettings-C9Tk-5ye.js} +1 -1
- package/client/dist/assets/{QueueOptionsButton-C40FPjKy.js → QueueOptionsButton-COnNd8B1.js} +1 -1
- package/client/dist/assets/{QueueRail-CCI5UE3V.js → QueueRail-C3V7Dxkj.js} +1 -1
- package/client/dist/assets/{ReadingList-CwbpzTqQ.js → ReadingList-CHjjXLoX.js} +1 -1
- package/client/dist/assets/{ResetProgressModal-CRmjBIiM.js → ResetProgressModal-2EZzznJV.js} +1 -1
- package/client/dist/assets/{Search-DqXagx5u.js → Search-3BVWhbFk.js} +1 -1
- package/client/dist/assets/Settings-BTFQ9byk.js +21 -0
- package/client/dist/assets/{SkeletonGrid-DSalPIgd.js → SkeletonGrid-B3ip19ry.js} +1 -1
- package/client/dist/assets/{Trackers-DPwyOrMr.js → Trackers-DQRyjPAR.js} +1 -1
- package/client/dist/assets/{Tv-DkMAx_ki.js → Tv-BTz52FUb.js} +1 -1
- package/client/dist/assets/{TvInfo-C9qnEHLF.js → TvInfo-BKOS8AmG.js} +1 -1
- package/client/dist/assets/{TvPopup-DmQw1air.js → TvPopup-DRGj0Mk8.js} +1 -1
- package/client/dist/assets/{TvSearch-Di-AdNgM.js → TvSearch-BjA0C3q7.js} +1 -1
- package/client/dist/assets/{TvWatchlist-CmW1Mevf.js → TvWatchlist-DG1RbmE4.js} +1 -1
- package/client/dist/assets/{VirtualKeyboard-CTTIG7Wy.js → VirtualKeyboard-BIXYg3GQ.js} +1 -1
- package/client/dist/assets/{WatchAlong-6Zw0uSo2.js → WatchAlong-XefYySuV.js} +1 -1
- package/client/dist/assets/{WatchAlongPanel-CBk19tnW.js → WatchAlongPanel-C2JcUz-e.js} +1 -1
- package/client/dist/assets/{Watchlist-DLNTPzcr.js → Watchlist-D7u_6_Rx.js} +1 -1
- package/client/dist/assets/index-BVkDKnzf.js +178 -0
- package/client/dist/assets/{index-TGvIXMUj.css → index-COFMCQUU.css} +1 -1
- package/client/dist/assets/{libraryInvalidation-CXA8qvJE.js → libraryInvalidation-ar7SX0CJ.js} +1 -1
- package/client/dist/assets/{playbackCompletion-Dz5SRhiZ.js → playbackCompletion-Bgy18e-S.js} +1 -1
- package/client/dist/assets/{useAnimeInfoData-B3zX9ouO.js → useAnimeInfoData-Bf5W2JqV.js} +1 -1
- package/client/dist/assets/{useMangaLibrary-BN6UWIDi.js → useMangaLibrary-CD_MzvM_.js} +1 -1
- package/client/dist/assets/{useMangaPopup-iiJ4p_Bv.js → useMangaPopup-C1YDuijt.js} +1 -1
- package/client/dist/assets/{useProviders-D0h-Ecgo.js → useProviders-CrYpQhz2.js} +1 -1
- package/client/dist/assets/{useTv-CjT0wz2W.js → useTv-ChpwVixu.js} +1 -1
- package/client/dist/assets/{useTvLibrary-C5s5jt9x.js → useTvLibrary-DqLFBTa7.js} +1 -1
- package/client/dist/assets/{useWatchAlongPlayer-C1iSTWOt.js → useWatchAlongPlayer-BTSgNMqR.js} +1 -1
- package/client/dist/assets/{vendor-icons-DrybRNxP.js → vendor-icons-C1Pj_eSX.js} +1 -1
- package/client/dist/index.html +3 -3
- package/package.json +2 -2
- package/server/dist/server.js +129 -129
- package/server/package.json +1 -1
- package/client/dist/assets/Settings-DBZG18um.js +0 -21
- package/client/dist/assets/index-CuAIqL2m.js +0 -178
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as Y,d as i,A as ye,u as e,S as g,g as ea,q as De}from"./vendor-core-DfaOB3Rn.js";import{u as V,b as R,a as S}from"./vendor-query-BBT5_sHx.js";import{J as r,q as s,t as c,ap as aa,v as na,X as qe,B as ge}from"./index-CuAIqL2m.js";import{I as m}from"./vendor-icons-DrybRNxP.js";function ta(){const N=V();Y(()=>{const C=new URLSearchParams(window.location.search),h=C.get("mal");if(!h)return;const t=C.get("user"),y=C.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 sa(){const N=V(),[C,h]=i(!1);return Y(()=>{const t=new URLSearchParams(window.location.search),y=t.get("anilist");if(y){const k=t.get("user"),u=t.get("reason");window.history.replaceState(null,"",window.location.pathname),y==="success"?(r.success(k?`Connected to AniList as ${decodeURIComponent(k)}`:"Connected to AniList"),N.invalidateQueries({queryKey:[s.trackerStatus]})):r.error(u?decodeURIComponent(u):"AniList authentication failed");return}const b=new URLSearchParams(window.location.hash.substring(1)),l=b.get("access_token"),L=t.get("code");if(!l&&!L){const k=b.get("error");k&&(r.error(`AniList error: ${k}`),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:L,redirectUri:d}).then(async k=>{const u=k.user;r.success(`Connected to AniList as ${u?.name??"AniList user"}`),N.invalidateQueries({queryKey:[s.trackerStatus]})}).catch(k=>{r.error(k instanceof Error?k.message:"Failed to authenticate with AniList")}).finally(()=>{h(!1)})},[N]),C}const ia="_header_azjok_1",ra="_fadeIn_azjok_1",ca="_pageTitle_azjok_6",oa="_pageSubtitle_azjok_14",la="_importCard_azjok_20",da="_cardHeader_azjok_31",ma="_uploadArea_azjok_49",ua="_fileInputWrapper_azjok_53",pa="_fileInput_azjok_53",ha="_fileDisplay_azjok_71",ga="_fileIcon_azjok_79",ya="_fileName_azjok_84",ka="_browseButton_azjok_93",fa="_optionsArea_azjok_104",_a="_checkboxLabel_azjok_112",ba="_checkbox_azjok_112",va="_checkboxCustom_azjok_125",Na="_optionText_azjok_153",wa="_optionTitle_azjok_159",Ca="_optionDesc_azjok_165",Ia="_actions_azjok_171",Sa="_importBtn_azjok_179",La="_cancelBtn_azjok_185",Ma="_statusMessage_azjok_199",xa="_success_azjok_209",Ta="_error_azjok_215",Aa="_progressSection_azjok_221",za="_progressBar_azjok_226",Pa="_progressFill_azjok_234",ja="_progressInfo_azjok_241",Ba="_progressCount_azjok_248",Ea="_progressTitle_azjok_255",Fa="_sourceBadge_azjok_273",Da="_anilist_azjok_285",qa="_kitsu_azjok_291",$a="_offline_azjok_297",Ka="_skipped_azjok_303",Ra="_cardTitleRow_azjok_308",Ua="_anilistIcon_azjok_318",Qa="_malIcon_azjok_324",Oa="_badgeOnline_azjok_330",Ha="_badgeOffline_azjok_342",Ga="_connectedProfile_azjok_354",Wa="_avatar_azjok_361",Xa="_connectedInfo_azjok_368",Ja="_connectedName_azjok_376",Ya="_connectedHint_azjok_382",Va="_loginPrompt_azjok_387",Za="_loginSection_azjok_395",en="_primaryBtn_azjok_401",an="_fieldLabel_azjok_405",nn="_helpText_azjok_424",tn="_resetBtn_azjok_431",sn="_loginText_azjok_461",rn="_secondaryBtn_azjok_471",cn="_syncBtn_azjok_472",on="_divider_azjok_525",ln="_actionSection_azjok_531",dn="_inputGroup_azjok_545",mn="_credentialFields_azjok_551",un="_credentialField_azjok_551",pn="_input_azjok_545",hn="_syncSummary_azjok_587",gn="_syncErrors_azjok_593",yn="_spin_azjok_597",kn="_radioGroup_azjok_616",fn="_radioLabel_azjok_623",_n="_syncHint_azjok_661",bn="_importLoading_azjok_668",a={header:ia,fadeIn:ra,pageTitle:ca,pageSubtitle:oa,importCard:la,cardHeader:da,uploadArea:ma,fileInputWrapper:ua,fileInput:pa,fileDisplay:ha,fileIcon:ga,fileName:ya,browseButton:ka,optionsArea:fa,checkboxLabel:_a,checkbox:ba,checkboxCustom:va,optionText:Na,optionTitle:wa,optionDesc:Ca,actions:Ia,importBtn:Sa,cancelBtn:La,statusMessage:Ma,success:xa,error:Ta,progressSection:Aa,progressBar:za,progressFill:Pa,progressInfo:ja,progressCount:Ba,progressTitle:Ea,sourceBadge:Fa,anilist:Da,kitsu:qa,offline:$a,skipped:Ka,cardTitleRow:Ra,anilistIcon:Ua,malIcon:Qa,badgeOnline:Oa,badgeOffline:Ha,connectedProfile:Ga,avatar:Wa,connectedInfo:Xa,connectedName:Ja,connectedHint:Ya,loginPrompt:Va,loginSection:Za,primaryBtn:en,fieldLabel:an,helpText:nn,resetBtn:tn,loginText:sn,secondaryBtn:rn,syncBtn:cn,divider:on,actionSection:ln,inputGroup:dn,credentialFields:mn,credentialField:un,input:pn,syncSummary:hn,syncErrors:gn,spin:yn,radioGroup:kn,radioLabel:fn,syncHint:_n,importLoading:bn},ie="tracker_anilist_client_id",Re="49887".trim(),re=!!Re;function $e(){const N=V(),[C,h]=i(""),t=ye(!1),y=sa(),{data:b}=R({queryKey:[s.trackerStatus],queryFn:()=>c.tracker.status.query()}),{data:l}=R({queryKey:[s.anilistClientId],queryFn:async()=>(await c.settings.getByKey.query({key:ie})).value||""});Y(()=>{t.current||l===void 0||(l&&h(l),t.current=!0)},[l]);const L=S({mutationFn:()=>c.tracker.anilistDisconnect.mutate(),onSuccess:()=>{N.invalidateQueries({queryKey:[s.trackerStatus]}),r.success("Disconnected from AniList")},onError:_=>r.error(_.message)}),d=S({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)}),k=async()=>{const _=C.trim(),o=_||Re;if(!o){r.error("Enter your AniList client ID first");return}const P=(l||"").trim();try{_?_!==l&&await c.settings.set.mutate({key:ie,value:_}):re&&P&&await c.settings.set.mutate({key:ie,value:""}),N.invalidateQueries({queryKey:[s.anilistClientId]})}catch(M){r.error(M.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=b?.anilist?.user??null;return b?.anilist?.connected&&u?e("div",{className:a.connectedProfile,children:[u.avatar&&e("img",{src:u.avatar,alt:"Avatar",className:a.avatar,loading:"lazy",decoding:"async"}),e("div",{className:a.connectedInfo,children:[e("span",{className:a.connectedName,children:u.name}),e("span",{className:a.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:a.secondaryBtn,onClick:()=>L.mutate(),disabled:L.isPending,children:[e(m,{name:"sign-out-alt"})," Disconnect"]})]}):e("div",{className:a.loginSection,children:[e("p",{className:a.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:a.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:a.inputGroup,children:[e("input",{type:"text",placeholder:"Client ID",value:C,onChange:_=>h(_.currentTarget.value),className:a.input}),e("button",{className:a.primaryBtn,onClick:k,disabled:!(C.trim()||re),children:[e(m,{name:"external-link-alt"})," Connect"]})]}),re&&l&&e("button",{className:a.resetBtn,onClick:()=>d.mutate(),disabled:d.isPending,children:"Use dango's app instead"}),e("p",{className:a.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 Ke({kind:N="anime",active:C=!0}){const h=V(),[t,y]=i(""),[b,l]=i(""),[L,d]=i(""),[k,u]=i(""),_=ye(!1),{data:o}=R({queryKey:[s.malClientConfig],queryFn:()=>c.tracker.malConfig.query()}),{data:P}=R({queryKey:[s.trackerStatus],queryFn:()=>c.tracker.status.query(),refetchInterval:15e3});Y(()=>{o&&!_.current&&(y(o.clientId),_.current=!0)},[o]);const p=S({mutationFn:async()=>{d(""),(b.trim()||t.trim()&&t.trim()!==o?.clientId)&&await c.tracker.malSaveConfig.mutate({clientId:t.trim(),clientSecret:b.trim()||void 0}),l("");const f=await c.tracker.malLogin.mutate({redirectUri:`${window.location.origin}/api/tracker/mal/callback`});window.location.assign(f.url)},onError:f=>d(f.message)}),M=S({mutationFn:()=>c.tracker.malDisconnect.mutate(),onSuccess:()=>{h.invalidateQueries({queryKey:[s.trackerStatus]}),u(""),d(""),r.success("Disconnected from MyAnimeList")},onError:f=>d(f.message)}),B=S({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:f=>d(f.message)}),D=S({mutationFn:()=>N==="manga"?c.tracker.mangaMalSync.mutate():c.tracker.sync.mutate({provider:"mal"}),onSuccess:f=>{const T=f.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 E of N==="manga"?[[s.trackerStatus],[s.mangaLibrary],[s.mangaContinueReading]]:[[s.trackerStatus],[s.watchlist],[s.continueWatching]])h.invalidateQueries({queryKey:E})},onError:f=>d(f.message)}),x=P?.mal;return e("div",{children:[x?.connected?e(g,{children:[e("div",{className:a.connectedProfile,children:[x.user?.avatar&&e("img",{src:x.user.avatar,alt:"Avatar",className:a.avatar,loading:"lazy",decoding:"async"}),e("div",{className:a.connectedInfo,children:[e("span",{className:a.connectedName,children:x.user?.name||"MyAnimeList user"}),e("span",{className:a.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:a.secondaryBtn,onClick:()=>M.mutate(),disabled:M.isPending,children:[e(m,{name:"sign-out-alt"})," Disconnect"]})]}),C?e(g,{children:[e("button",{className:a.syncBtn,onClick:()=>D.mutate(),disabled:D.isPending,children:[e(m,{name:"sync-alt",className:D.isPending?a.spin:""}),D.isPending?"Syncing...":"Start Sync"]}),k&&e("div",{className:a.syncSummary,children:k})]}):e("p",{className:a.connectedHint,style:{color:"var(--color-warning)"},children:"Not the active tracker - sync disabled."})]}):e("div",{className:a.loginSection,children:[e("p",{className:a.loginText,children:"Log in with MyAnimeList to enable bidirectional progress & status synchronization."}),e("div",{className:a.credentialFields,children:[e("label",{className:`${a.fieldLabel} ${a.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:a.helpText,children:" — defaults to dango's app"})]}),e("input",{className:a.input,placeholder:o?.mode==="worker"?"dango's app (leave empty)":"Client ID",value:t,onChange:f=>y(f.currentTarget.value),autoComplete:"off"})]}),e("label",{className:`${a.fieldLabel} ${a.credentialField}`,children:[e("span",{children:["Client secret"," ",o?.hasSecret&&!b&&e("span",{className:a.helpText,children:"— saved"})]}),e("input",{className:a.input,type:"password",value:b,onChange:f=>l(f.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:a.resetBtn,onClick:()=>B.mutate(),disabled:B.isPending,children:"Use dango's app instead"}),e("p",{className:a.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:a.primaryBtn,onClick:()=>p.mutate(),disabled:!(t.trim()&&b.trim()||o?.clientId&&t.trim()===o.clientId&&o.hasSecret||!t.trim()&&!b.trim()&&o?.mode==="worker")||p.isPending,children:p.isPending?"Connecting...":"Connect to MyAnimeList"})]}),L&&e("p",{className:`${a.helpText} ${a.syncErrors}`,role:"alert",children:L}),e("hr",{className:a.divider}),e("p",{className:a.syncHint,children:"You can also import a public list or XML file without connecting an account:"})]})}const In=()=>{const{setIsOpen:N}=aa(),{contentType:C}=na(),h=C==="manga",t=V();ea.useEffect(()=>{document.title="Trackers - dango"},[]);const[y,b]=i(""),[l,L]=i("username"),[d,k]=i(null),[u,_]=i(!1);ta();const{data:o,isLoading:P}=R({queryKey:[s.trackerStatus],queryFn:async()=>await c.tracker.status.query()}),p=o?.anilist?.connected??!1,M=o?.mal?.connected??!1,{data:B}=R({queryKey:["activeTrackerProvider"],queryFn:async()=>(await c.settings.getByKey.query({key:"active_tracker_provider"}))?.value||""}),D=S({mutationFn:async n=>(await c.settings.set.mutate({key:"active_tracker_provider",value:n}),n),onSuccess:n=>{t.invalidateQueries({queryKey:["activeTrackerProvider"]}),r.success(`Active tracker set to ${n==="mal"?"MyAnimeList":"AniList"}`)},onError:()=>r.error("Failed to update active tracker")}),x=B&&(B==="anilist"&&p||B==="mal"&&M)?B:p&&!M?"anilist":M&&!p?"mal":p?"anilist":"",f=p||M;Y(()=>{p&&L("sync")},[p]);const T=S({mutationFn:async()=>(await c.tracker.sync.mutate({provider:"anilist"})).summary,onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),k(n),r.success(`Sync complete - pushed ${n.pushed}, pulled ${n.pulled}, merged ${n.merged}, unchanged ${n.unchanged}`,{duration:6e3})},onError:n=>r.error(n.message)}),[E,ke]=i(""),[Z,fe]=i("sync"),[ce,_e]=i("two-way"),[w,Ue]=i(null),ee=S({mutationFn:async()=>(await c.tracker.mangaSync.mutate({direction:ce})).summary,onSuccess:n=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),Ue(n);const v=(n.warnings?.length??0)>0?`, ${n.warnings.length} warning(s)`:"";r.success(`Manga sync complete - pushed ${n.pushed}, pulled ${n.pulled}, merged ${n.merged}, unchanged ${n.unchanged}${v}`,{duration:6e3})},onError:n=>r.error(n.message)}),q=S({mutationFn:async()=>{if(!E.trim())throw new Error("Please enter a username");return(await c.tracker.mangaImport.mutate({username:E.trim(),erase:u})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),r.success(`Imported ${n} manga entries from AniList`),ke("")},onError:n=>r.error(n.message)}),[U,be]=i(""),[ae,ve]=i("username"),[oe,Ne]=i(null),[ne,we]=i(!1),[Ce,le]=i(""),[Ie,Qe]=i(""),j=S({mutationFn:async()=>{if(!U.trim())throw new Error("Please enter a MAL username");const n=await c.tracker.mangaMalImport.mutate({username:U.trim(),erase:u});return{imported:n.imported??0,skipped:n.skipped??0}},onSuccess:({imported:n,skipped:v})=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),r.success(`Imported ${n} manga entries from MAL${v>0?`, skipped ${v}`:""}`),be("")},onError:n=>r.error(n.message)}),Oe=De(async()=>{const n=document.getElementById("malMangaFile");if(!n.files||n.files.length===0){le("Please select a file first.");return}we(!0),le(""),Ne(null);try{const v=new FormData;v.append("xmlfile",n.files[0]),v.append("erase",String(u));const W=await qe("/api/import/mal-xml-manga",{method:"POST",body:v}),I=await W.json().catch(()=>({}));if(!W.ok)throw new Error(I.error||"Import failed");Ne({imported:I.imported??0,skipped:I.skipped??0}),t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]})}catch(v){le(v.message)}finally{we(!1)}},[u,t]),$=S({mutationFn:async()=>{if(!y.trim())throw new Error("Please enter a username");return(await c.tracker.anilistImport.mutate({username:y.trim(),erase:F})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),r.success(`Imported ${n} anime entries from AniList`),b("")},onError:n=>r.error(n.message)}),[Q,Se]=i(""),z=S({mutationFn:async n=>{if(!Q.trim())throw new Error("Please enter a MAL username");return(await c.tracker.malImport.mutate({username:Q.trim(),erase:n.erase,useOfflineDb:n.useOfflineDb,skipFallback:n.skipFallback})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),r.success(`Imported ${n} anime entries from MAL`),Se("")},onError:n=>r.error(n.message)}),[F,Le]=i(!1),[O,He]=i(!0),[H,Ge]=i(!1),[Me,xe]=i(""),[K,Te]=i(!1),[A,Ae]=i(null),[de,ze]=i(null),[Pe,te]=i(""),me=ye(null),We=n=>{n.currentTarget.files&&n.currentTarget.files.length>0?xe(n.currentTarget.files[0].name):xe("")},Xe=De(async()=>{const n=document.getElementById("malFile");if(!n.files||n.files.length===0){te("Please select a file first.");return}const v=n.files[0];Te(!0),Ae(null),ze(null),te("");const W=new AbortController;me.current=W;try{const I=new FormData;I.append("xmlfile",v),I.append("erase",String(F)),I.append("useOfflineDb",String(O)),I.append("skipFallback",String(H));const ue=await qe("/api/import/mal-xml",{method:"POST",body:I,signal:W.signal});if(!ue.ok){const he=await ue.text();let X="Failed to import";try{X=JSON.parse(he).error||X}catch{}throw new Error(X)}const Be=ue.body?.getReader();if(!Be)throw new Error("No response stream");const Ve=new TextDecoder;let pe="",se="";for(;;){const{done:he,value:X}=await Be.read();if(he)break;pe+=Ve.decode(X,{stream:!0});const Ee=pe.split(`
|
|
1
|
+
import{h as Y,d as i,A as ye,u as e,S as g,g as ea,q as De}from"./vendor-core-DfaOB3Rn.js";import{u as V,b as R,a as S}from"./vendor-query-BBT5_sHx.js";import{J as r,q as s,t as c,ap as aa,v as na,X as qe,B as ge}from"./index-BVkDKnzf.js";import{I as m}from"./vendor-icons-C1Pj_eSX.js";function ta(){const N=V();Y(()=>{const C=new URLSearchParams(window.location.search),h=C.get("mal");if(!h)return;const t=C.get("user"),y=C.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 sa(){const N=V(),[C,h]=i(!1);return Y(()=>{const t=new URLSearchParams(window.location.search),y=t.get("anilist");if(y){const k=t.get("user"),u=t.get("reason");window.history.replaceState(null,"",window.location.pathname),y==="success"?(r.success(k?`Connected to AniList as ${decodeURIComponent(k)}`:"Connected to AniList"),N.invalidateQueries({queryKey:[s.trackerStatus]})):r.error(u?decodeURIComponent(u):"AniList authentication failed");return}const b=new URLSearchParams(window.location.hash.substring(1)),l=b.get("access_token"),L=t.get("code");if(!l&&!L){const k=b.get("error");k&&(r.error(`AniList error: ${k}`),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:L,redirectUri:d}).then(async k=>{const u=k.user;r.success(`Connected to AniList as ${u?.name??"AniList user"}`),N.invalidateQueries({queryKey:[s.trackerStatus]})}).catch(k=>{r.error(k instanceof Error?k.message:"Failed to authenticate with AniList")}).finally(()=>{h(!1)})},[N]),C}const ia="_header_azjok_1",ra="_fadeIn_azjok_1",ca="_pageTitle_azjok_6",oa="_pageSubtitle_azjok_14",la="_importCard_azjok_20",da="_cardHeader_azjok_31",ma="_uploadArea_azjok_49",ua="_fileInputWrapper_azjok_53",pa="_fileInput_azjok_53",ha="_fileDisplay_azjok_71",ga="_fileIcon_azjok_79",ya="_fileName_azjok_84",ka="_browseButton_azjok_93",fa="_optionsArea_azjok_104",_a="_checkboxLabel_azjok_112",ba="_checkbox_azjok_112",va="_checkboxCustom_azjok_125",Na="_optionText_azjok_153",wa="_optionTitle_azjok_159",Ca="_optionDesc_azjok_165",Ia="_actions_azjok_171",Sa="_importBtn_azjok_179",La="_cancelBtn_azjok_185",Ma="_statusMessage_azjok_199",xa="_success_azjok_209",Ta="_error_azjok_215",Aa="_progressSection_azjok_221",za="_progressBar_azjok_226",Pa="_progressFill_azjok_234",ja="_progressInfo_azjok_241",Ba="_progressCount_azjok_248",Ea="_progressTitle_azjok_255",Fa="_sourceBadge_azjok_273",Da="_anilist_azjok_285",qa="_kitsu_azjok_291",$a="_offline_azjok_297",Ka="_skipped_azjok_303",Ra="_cardTitleRow_azjok_308",Ua="_anilistIcon_azjok_318",Qa="_malIcon_azjok_324",Oa="_badgeOnline_azjok_330",Ha="_badgeOffline_azjok_342",Ga="_connectedProfile_azjok_354",Wa="_avatar_azjok_361",Xa="_connectedInfo_azjok_368",Ja="_connectedName_azjok_376",Ya="_connectedHint_azjok_382",Va="_loginPrompt_azjok_387",Za="_loginSection_azjok_395",en="_primaryBtn_azjok_401",an="_fieldLabel_azjok_405",nn="_helpText_azjok_424",tn="_resetBtn_azjok_431",sn="_loginText_azjok_461",rn="_secondaryBtn_azjok_471",cn="_syncBtn_azjok_472",on="_divider_azjok_525",ln="_actionSection_azjok_531",dn="_inputGroup_azjok_545",mn="_credentialFields_azjok_551",un="_credentialField_azjok_551",pn="_input_azjok_545",hn="_syncSummary_azjok_587",gn="_syncErrors_azjok_593",yn="_spin_azjok_597",kn="_radioGroup_azjok_616",fn="_radioLabel_azjok_623",_n="_syncHint_azjok_661",bn="_importLoading_azjok_668",a={header:ia,fadeIn:ra,pageTitle:ca,pageSubtitle:oa,importCard:la,cardHeader:da,uploadArea:ma,fileInputWrapper:ua,fileInput:pa,fileDisplay:ha,fileIcon:ga,fileName:ya,browseButton:ka,optionsArea:fa,checkboxLabel:_a,checkbox:ba,checkboxCustom:va,optionText:Na,optionTitle:wa,optionDesc:Ca,actions:Ia,importBtn:Sa,cancelBtn:La,statusMessage:Ma,success:xa,error:Ta,progressSection:Aa,progressBar:za,progressFill:Pa,progressInfo:ja,progressCount:Ba,progressTitle:Ea,sourceBadge:Fa,anilist:Da,kitsu:qa,offline:$a,skipped:Ka,cardTitleRow:Ra,anilistIcon:Ua,malIcon:Qa,badgeOnline:Oa,badgeOffline:Ha,connectedProfile:Ga,avatar:Wa,connectedInfo:Xa,connectedName:Ja,connectedHint:Ya,loginPrompt:Va,loginSection:Za,primaryBtn:en,fieldLabel:an,helpText:nn,resetBtn:tn,loginText:sn,secondaryBtn:rn,syncBtn:cn,divider:on,actionSection:ln,inputGroup:dn,credentialFields:mn,credentialField:un,input:pn,syncSummary:hn,syncErrors:gn,spin:yn,radioGroup:kn,radioLabel:fn,syncHint:_n,importLoading:bn},ie="tracker_anilist_client_id",Re="49887".trim(),re=!!Re;function $e(){const N=V(),[C,h]=i(""),t=ye(!1),y=sa(),{data:b}=R({queryKey:[s.trackerStatus],queryFn:()=>c.tracker.status.query()}),{data:l}=R({queryKey:[s.anilistClientId],queryFn:async()=>(await c.settings.getByKey.query({key:ie})).value||""});Y(()=>{t.current||l===void 0||(l&&h(l),t.current=!0)},[l]);const L=S({mutationFn:()=>c.tracker.anilistDisconnect.mutate(),onSuccess:()=>{N.invalidateQueries({queryKey:[s.trackerStatus]}),r.success("Disconnected from AniList")},onError:_=>r.error(_.message)}),d=S({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)}),k=async()=>{const _=C.trim(),o=_||Re;if(!o){r.error("Enter your AniList client ID first");return}const P=(l||"").trim();try{_?_!==l&&await c.settings.set.mutate({key:ie,value:_}):re&&P&&await c.settings.set.mutate({key:ie,value:""}),N.invalidateQueries({queryKey:[s.anilistClientId]})}catch(M){r.error(M.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=b?.anilist?.user??null;return b?.anilist?.connected&&u?e("div",{className:a.connectedProfile,children:[u.avatar&&e("img",{src:u.avatar,alt:"Avatar",className:a.avatar,loading:"lazy",decoding:"async"}),e("div",{className:a.connectedInfo,children:[e("span",{className:a.connectedName,children:u.name}),e("span",{className:a.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:a.secondaryBtn,onClick:()=>L.mutate(),disabled:L.isPending,children:[e(m,{name:"sign-out-alt"})," Disconnect"]})]}):e("div",{className:a.loginSection,children:[e("p",{className:a.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:a.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:a.inputGroup,children:[e("input",{type:"text",placeholder:"Client ID",value:C,onChange:_=>h(_.currentTarget.value),className:a.input}),e("button",{className:a.primaryBtn,onClick:k,disabled:!(C.trim()||re),children:[e(m,{name:"external-link-alt"})," Connect"]})]}),re&&l&&e("button",{className:a.resetBtn,onClick:()=>d.mutate(),disabled:d.isPending,children:"Use dango's app instead"}),e("p",{className:a.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 Ke({kind:N="anime",active:C=!0}){const h=V(),[t,y]=i(""),[b,l]=i(""),[L,d]=i(""),[k,u]=i(""),_=ye(!1),{data:o}=R({queryKey:[s.malClientConfig],queryFn:()=>c.tracker.malConfig.query()}),{data:P}=R({queryKey:[s.trackerStatus],queryFn:()=>c.tracker.status.query(),refetchInterval:15e3});Y(()=>{o&&!_.current&&(y(o.clientId),_.current=!0)},[o]);const p=S({mutationFn:async()=>{d(""),(b.trim()||t.trim()&&t.trim()!==o?.clientId)&&await c.tracker.malSaveConfig.mutate({clientId:t.trim(),clientSecret:b.trim()||void 0}),l("");const f=await c.tracker.malLogin.mutate({redirectUri:`${window.location.origin}/api/tracker/mal/callback`});window.location.assign(f.url)},onError:f=>d(f.message)}),M=S({mutationFn:()=>c.tracker.malDisconnect.mutate(),onSuccess:()=>{h.invalidateQueries({queryKey:[s.trackerStatus]}),u(""),d(""),r.success("Disconnected from MyAnimeList")},onError:f=>d(f.message)}),B=S({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:f=>d(f.message)}),D=S({mutationFn:()=>N==="manga"?c.tracker.mangaMalSync.mutate():c.tracker.sync.mutate({provider:"mal"}),onSuccess:f=>{const T=f.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 E of N==="manga"?[[s.trackerStatus],[s.mangaLibrary],[s.mangaContinueReading]]:[[s.trackerStatus],[s.watchlist],[s.continueWatching]])h.invalidateQueries({queryKey:E})},onError:f=>d(f.message)}),x=P?.mal;return e("div",{children:[x?.connected?e(g,{children:[e("div",{className:a.connectedProfile,children:[x.user?.avatar&&e("img",{src:x.user.avatar,alt:"Avatar",className:a.avatar,loading:"lazy",decoding:"async"}),e("div",{className:a.connectedInfo,children:[e("span",{className:a.connectedName,children:x.user?.name||"MyAnimeList user"}),e("span",{className:a.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:a.secondaryBtn,onClick:()=>M.mutate(),disabled:M.isPending,children:[e(m,{name:"sign-out-alt"})," Disconnect"]})]}),C?e(g,{children:[e("button",{className:a.syncBtn,onClick:()=>D.mutate(),disabled:D.isPending,children:[e(m,{name:"sync-alt",className:D.isPending?a.spin:""}),D.isPending?"Syncing...":"Start Sync"]}),k&&e("div",{className:a.syncSummary,children:k})]}):e("p",{className:a.connectedHint,style:{color:"var(--color-warning)"},children:"Not the active tracker - sync disabled."})]}):e("div",{className:a.loginSection,children:[e("p",{className:a.loginText,children:"Log in with MyAnimeList to enable bidirectional progress & status synchronization."}),e("div",{className:a.credentialFields,children:[e("label",{className:`${a.fieldLabel} ${a.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:a.helpText,children:" — defaults to dango's app"})]}),e("input",{className:a.input,placeholder:o?.mode==="worker"?"dango's app (leave empty)":"Client ID",value:t,onChange:f=>y(f.currentTarget.value),autoComplete:"off"})]}),e("label",{className:`${a.fieldLabel} ${a.credentialField}`,children:[e("span",{children:["Client secret"," ",o?.hasSecret&&!b&&e("span",{className:a.helpText,children:"— saved"})]}),e("input",{className:a.input,type:"password",value:b,onChange:f=>l(f.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:a.resetBtn,onClick:()=>B.mutate(),disabled:B.isPending,children:"Use dango's app instead"}),e("p",{className:a.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:a.primaryBtn,onClick:()=>p.mutate(),disabled:!(t.trim()&&b.trim()||o?.clientId&&t.trim()===o.clientId&&o.hasSecret||!t.trim()&&!b.trim()&&o?.mode==="worker")||p.isPending,children:p.isPending?"Connecting...":"Connect to MyAnimeList"})]}),L&&e("p",{className:`${a.helpText} ${a.syncErrors}`,role:"alert",children:L}),e("hr",{className:a.divider}),e("p",{className:a.syncHint,children:"You can also import a public list or XML file without connecting an account:"})]})}const In=()=>{const{setIsOpen:N}=aa(),{contentType:C}=na(),h=C==="manga",t=V();ea.useEffect(()=>{document.title="Trackers - dango"},[]);const[y,b]=i(""),[l,L]=i("username"),[d,k]=i(null),[u,_]=i(!1);ta();const{data:o,isLoading:P}=R({queryKey:[s.trackerStatus],queryFn:async()=>await c.tracker.status.query()}),p=o?.anilist?.connected??!1,M=o?.mal?.connected??!1,{data:B}=R({queryKey:["activeTrackerProvider"],queryFn:async()=>(await c.settings.getByKey.query({key:"active_tracker_provider"}))?.value||""}),D=S({mutationFn:async n=>(await c.settings.set.mutate({key:"active_tracker_provider",value:n}),n),onSuccess:n=>{t.invalidateQueries({queryKey:["activeTrackerProvider"]}),r.success(`Active tracker set to ${n==="mal"?"MyAnimeList":"AniList"}`)},onError:()=>r.error("Failed to update active tracker")}),x=B&&(B==="anilist"&&p||B==="mal"&&M)?B:p&&!M?"anilist":M&&!p?"mal":p?"anilist":"",f=p||M;Y(()=>{p&&L("sync")},[p]);const T=S({mutationFn:async()=>(await c.tracker.sync.mutate({provider:"anilist"})).summary,onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),k(n),r.success(`Sync complete - pushed ${n.pushed}, pulled ${n.pulled}, merged ${n.merged}, unchanged ${n.unchanged}`,{duration:6e3})},onError:n=>r.error(n.message)}),[E,ke]=i(""),[Z,fe]=i("sync"),[ce,_e]=i("two-way"),[w,Ue]=i(null),ee=S({mutationFn:async()=>(await c.tracker.mangaSync.mutate({direction:ce})).summary,onSuccess:n=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),Ue(n);const v=(n.warnings?.length??0)>0?`, ${n.warnings.length} warning(s)`:"";r.success(`Manga sync complete - pushed ${n.pushed}, pulled ${n.pulled}, merged ${n.merged}, unchanged ${n.unchanged}${v}`,{duration:6e3})},onError:n=>r.error(n.message)}),q=S({mutationFn:async()=>{if(!E.trim())throw new Error("Please enter a username");return(await c.tracker.mangaImport.mutate({username:E.trim(),erase:u})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),r.success(`Imported ${n} manga entries from AniList`),ke("")},onError:n=>r.error(n.message)}),[U,be]=i(""),[ae,ve]=i("username"),[oe,Ne]=i(null),[ne,we]=i(!1),[Ce,le]=i(""),[Ie,Qe]=i(""),j=S({mutationFn:async()=>{if(!U.trim())throw new Error("Please enter a MAL username");const n=await c.tracker.mangaMalImport.mutate({username:U.trim(),erase:u});return{imported:n.imported??0,skipped:n.skipped??0}},onSuccess:({imported:n,skipped:v})=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),r.success(`Imported ${n} manga entries from MAL${v>0?`, skipped ${v}`:""}`),be("")},onError:n=>r.error(n.message)}),Oe=De(async()=>{const n=document.getElementById("malMangaFile");if(!n.files||n.files.length===0){le("Please select a file first.");return}we(!0),le(""),Ne(null);try{const v=new FormData;v.append("xmlfile",n.files[0]),v.append("erase",String(u));const W=await qe("/api/import/mal-xml-manga",{method:"POST",body:v}),I=await W.json().catch(()=>({}));if(!W.ok)throw new Error(I.error||"Import failed");Ne({imported:I.imported??0,skipped:I.skipped??0}),t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]})}catch(v){le(v.message)}finally{we(!1)}},[u,t]),$=S({mutationFn:async()=>{if(!y.trim())throw new Error("Please enter a username");return(await c.tracker.anilistImport.mutate({username:y.trim(),erase:F})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),r.success(`Imported ${n} anime entries from AniList`),b("")},onError:n=>r.error(n.message)}),[Q,Se]=i(""),z=S({mutationFn:async n=>{if(!Q.trim())throw new Error("Please enter a MAL username");return(await c.tracker.malImport.mutate({username:Q.trim(),erase:n.erase,useOfflineDb:n.useOfflineDb,skipFallback:n.skipFallback})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),r.success(`Imported ${n} anime entries from MAL`),Se("")},onError:n=>r.error(n.message)}),[F,Le]=i(!1),[O,He]=i(!0),[H,Ge]=i(!1),[Me,xe]=i(""),[K,Te]=i(!1),[A,Ae]=i(null),[de,ze]=i(null),[Pe,te]=i(""),me=ye(null),We=n=>{n.currentTarget.files&&n.currentTarget.files.length>0?xe(n.currentTarget.files[0].name):xe("")},Xe=De(async()=>{const n=document.getElementById("malFile");if(!n.files||n.files.length===0){te("Please select a file first.");return}const v=n.files[0];Te(!0),Ae(null),ze(null),te("");const W=new AbortController;me.current=W;try{const I=new FormData;I.append("xmlfile",v),I.append("erase",String(F)),I.append("useOfflineDb",String(O)),I.append("skipFallback",String(H));const ue=await qe("/api/import/mal-xml",{method:"POST",body:I,signal:W.signal});if(!ue.ok){const he=await ue.text();let X="Failed to import";try{X=JSON.parse(he).error||X}catch{}throw new Error(X)}const Be=ue.body?.getReader();if(!Be)throw new Error("No response stream");const Ve=new TextDecoder;let pe="",se="";for(;;){const{done:he,value:X}=await Be.read();if(he)break;pe+=Ve.decode(X,{stream:!0});const Ee=pe.split(`
|
|
2
2
|
`);pe=Ee.pop()||"";for(const J of Ee)if(J.startsWith("event: "))se=J.slice(7).trim();else if(J.startsWith("data: ")){const Ze=J.slice(6);try{const Fe=JSON.parse(Ze);se==="progress"?Ae(Fe):se==="complete"&&ze(Fe)}catch{}}else J===""&&(se="")}t.invalidateQueries({queryKey:[s.watchlist]})}catch(I){I instanceof DOMException&&I.name==="AbortError"?te("Import cancelled."):te(I.message)}finally{Te(!1),me.current=null}},[F,O,H,t]),Je=()=>{me.current?.abort(),c.settings.malImportCancel.mutate().catch(()=>{})},Ye=A?Math.round(A.current/A.total*100):0,[G,je]=i("username");return e("div",{className:"page-container",children:[e("div",{className:a.header,children:[e("h1",{className:a.pageTitle,children:"Trackers"}),e("p",{className:a.pageSubtitle,children:"Import & sync your anime watchlists and manga reading lists with tracking services"})]}),e("div",{style:{marginBottom:"16px",fontSize:"0.8rem",color:"var(--color-warning)",borderBottom:"1px solid var(--border-primary)",paddingBottom:"12px"},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."}),f&&e("div",{style:{marginBottom:"16px",display:"flex",alignItems:"center",gap:"10px",fontSize:"0.85rem"},children:[e("label",{htmlFor:"active-tracker-select",style:{fontWeight:600,color:"var(--text-secondary)"},children:"Active tracker:"}),e("select",{id:"active-tracker-select",value:x,onChange:n=>D.mutate(n.currentTarget.value),style:{padding:"0.3rem 0.5rem",borderRadius:"var(--radius-md)",background:"var(--bg-tertiary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",fontSize:"var(--font-size-sm)",cursor:"pointer"},children:[p&&e("option",{value:"anilist",children:"AniList"}),M&&e("option",{value:"mal",children:"MyAnimeList"})]})]}),!h&&e(g,{children:e("div",{className:a.importCard,children:[e("div",{className:a.cardHeader,children:e("div",{className:a.cardTitleRow,children:[e(m,{name:"anilist",className:a.anilistIcon}),e("h3",{children:"AniList"}),P?null:p?e("span",{className:a.badgeOnline,children:"Connected"}):e("span",{className:a.badgeOffline,children:"Not connected"})]})}),e($e,{}),p&&x!=="anilist"&&e("p",{style:{color:"var(--color-warning)",marginTop:"8px",fontSize:"0.85rem"},children:"Not the active tracker - sync disabled."}),p&&x==="anilist"&&e(g,{children:[e("hr",{className:a.divider}),e("div",{className:a.radioGroup,children:[e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"username",checked:l==="username",onChange:()=>L("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"sync",checked:l==="sync",onChange:()=>L("sync")}),e("span",{children:"Two-way Sync"})]})]}),l==="username"?e("div",{className:a.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:y,onChange:n=>b(n.currentTarget.value),className:a.input,disabled:$.isPending,onKeyDown:n=>{n.key==="Enter"&&y.trim()&&$.mutate()}})}):e("p",{className:a.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:a.optionsArea,children:e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:F,onChange:n=>Le(n.currentTarget.checked),className:a.checkbox,disabled:$.isPending}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Erase current watchlist"}),e("span",{className:a.optionDesc,children:"Delete existing watchlist before importing."})]})]})}),l==="username"?e("button",{className:a.syncBtn,onClick:()=>$.mutate(),disabled:!y.trim()||$.isPending,children:[e(m,{name:"download"}),$.isPending?"Importing...":"Start Import"]}):e(g,{children:[e("button",{className:a.syncBtn,onClick:()=>T.mutate(),disabled:T.isPending,children:[e(m,{name:"sync-alt",className:T.isPending?a.spin:""}),T.isPending?"Syncing...":"Start Sync"]}),d&&e("div",{className:a.syncSummary,children:["Pushed: ",d.pushed," · Pulled: ",d.pulled," · Merged:"," ",d.merged," · Unchanged: ",d.unchanged,d.errors.length>0&&e("span",{className:a.syncErrors,children:[" ","· ",d.errors.length," error",d.errors.length>1?"s":""]})]})]})]})]})}),h&&e(g,{children:e("div",{className:a.importCard,children:[e("div",{className:a.cardHeader,children:e("div",{className:a.cardTitleRow,children:[e(m,{name:"anilist",className:a.anilistIcon}),e("h3",{children:"AniList Manga"}),P?null:p?e("span",{className:a.badgeOnline,children:"Connected"}):e("span",{className:a.badgeOffline,children:"Not connected"})]})}),e($e,{}),p&&x!=="anilist"&&e("p",{style:{color:"var(--color-warning)",marginTop:"8px",fontSize:"0.85rem"},children:"Not the active tracker - sync disabled."}),p&&x==="anilist"&&e(g,{children:[e("hr",{className:a.divider}),e("div",{className:a.radioGroup,children:[e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"username",checked:Z==="username",onChange:()=>fe("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"sync",checked:Z==="sync",onChange:()=>fe("sync")}),e("span",{children:"Two-way Sync"})]})]}),Z==="username"?e(g,{children:[e("div",{className:a.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:E,onChange:n=>ke(n.currentTarget.value),className:a.input,disabled:q.isPending,onKeyDown:n=>{n.key==="Enter"&&E.trim()&&q.mutate()}})}),e("div",{className:a.optionsArea,children:e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:u,onChange:n=>_(n.currentTarget.checked),className:a.checkbox,disabled:q.isPending}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Replace AniList-linked manga"}),e("span",{className:a.optionDesc,children:"Clears previously imported (anilist:) entries before importing. Your provider bookmarks are never touched."})]})]})})]}):e(g,{children:[e("p",{className:a.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:a.radioGroup,children:[e("label",{className:a.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:a.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)"})]})]})]}),Z==="username"?e("button",{className:a.syncBtn,onClick:()=>q.mutate(),disabled:!E.trim()||q.isPending,children:[e(m,{name:"download"}),q.isPending?"Importing...":"Start Import"]}):e(g,{children:[e("button",{className:a.syncBtn,onClick:()=>ee.mutate(),disabled:ee.isPending,children:[e(m,{name:"sync-alt",className:ee.isPending?a.spin:""}),ee.isPending?"Syncing...":"Start Manga Sync"]}),w&&e(g,{children:[e("div",{className:a.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:a.syncErrors,children:[" ","· ",w.errors.length," error",w.errors.length>1?"s":""]})]}),(w.warnings?.length??0)>0&&e("div",{className:a.syncErrors,style:{marginTop:"8px"},children:[(w.warnings??[]).slice(0,5).map((n,v)=>e("div",{children:["⚠ ",n]},v)),(w.warnings?.length??0)>5&&e("div",{children:["+",(w.warnings?.length??0)-5," more warning(s)"]})]})]})]})]})]})}),!h&&e(g,{children:e("div",{className:a.importCard,children:[e("div",{className:a.cardHeader,children:e("div",{className:a.cardTitleRow,children:[e(m,{name:"myanimelist",className:a.malIcon}),e("h3",{children:"MyAnimeList"}),P?null:M?e("span",{className:a.badgeOnline,children:"Connected"}):e("span",{className:a.badgeOffline,children:"Not connected"})]})}),e(Ke,{active:x==="mal"}),e("div",{className:a.radioGroup,children:[e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"username",checked:G==="username",onChange:()=>je("username")}),e("span",{children:"Username"})]}),e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"xml",checked:G==="xml",onChange:()=>je("xml")}),e("span",{children:"XML File"})]})]}),G==="username"?e(g,{children:[e("div",{className:a.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:Q,onChange:n=>Se(n.currentTarget.value),className:a.input,disabled:z.isPending,onKeyDown:n=>{n.key==="Enter"&&Q.trim()&&z.mutate({erase:F,useOfflineDb:O,skipFallback:H})}})}),z.isPending&&e("div",{className:a.importLoading,children:[e(m,{name:"sync-alt",className:a.spin}),e("span",{children:"Importing from MAL..."})]})]}):e("div",{className:a.uploadArea,children:e("div",{className:a.fileInputWrapper,children:[e("input",{type:"file",id:"malFile",accept:".xml,application/xml",className:a.fileInput,onChange:We,disabled:K}),e("div",{className:a.fileDisplay,children:[e(m,{name:"file-alt",className:a.fileIcon}),e("span",{className:a.fileName,children:Me||"Choose XML file..."})]}),e("label",{htmlFor:"malFile",className:a.browseButton,children:"Browse"})]})}),e("div",{className:a.optionsArea,children:[e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:F,onChange:n=>Le(n.currentTarget.checked),className:a.checkbox,disabled:K||z.isPending}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Erase current watchlist"}),e("span",{className:a.optionDesc,children:"Delete existing watchlist before importing."})]})]}),e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:O,onChange:n=>He(n.currentTarget.checked),className:a.checkbox,disabled:K||z.isPending}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Use offline database (fast)"}),e("span",{className:a.optionDesc,children:"Match by MAL ID locally first - instant and avoids AniList rate limits."})]})]}),e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:H,onChange:n=>Ge(n.currentTarget.checked),className:a.checkbox,disabled:K||z.isPending}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Skip online fallback"}),e("span",{className:a.optionDesc,children:"Only import offline matches. Unmatched titles are skipped without API calls."})]})]})]}),G==="username"?e("button",{className:a.syncBtn,onClick:()=>z.mutate({erase:F,useOfflineDb:O,skipFallback:H}),disabled:!Q.trim()||z.isPending,children:[e(m,{name:"download"}),z.isPending?"Importing...":"Start Import"]}):e("div",{className:a.actions,children:K?e(ge,{onClick:Je,className:a.cancelBtn,children:"Cancel Import"}):e(ge,{onClick:Xe,className:a.importBtn,disabled:!Me,children:[e(m,{name:"upload"})," Start Import"]})}),G==="username"&&z.isError&&e("div",{className:`${a.statusMessage} ${a.error}`,children:z.error.message}),K&&A&&e("div",{className:a.progressSection,children:[e("div",{className:a.progressBar,children:e("div",{className:a.progressFill,style:{width:`${Ye}%`}})}),e("div",{className:a.progressInfo,children:[e("span",{className:a.progressCount,children:[A.current," / ",A.total]}),e("span",{className:a.progressTitle,children:A.found?e(g,{children:[A.matchedTitle,e("span",{className:`${a.sourceBadge} ${a[A.source||"anilist"]}`,children:A.source==="kitsu"?"Kitsu":A.source==="offline"?"Offline DB":"AniList"})]}):e("span",{className:a.skipped,children:["Skipped: ",A.title]})})]})]}),de&&e("div",{className:`${a.statusMessage} ${a.success}`,children:["Import complete! Imported: ",de.imported,", Skipped: ",de.skipped,"."]}),Pe&&e("div",{className:`${a.statusMessage} ${a.error}`,children:Pe})]})}),h&&e("div",{className:a.importCard,children:[e("div",{className:a.cardHeader,children:e("div",{className:a.cardTitleRow,children:[e(m,{name:"myanimelist",className:a.malIcon}),e("h3",{children:"MyAnimeList Manga"}),P?null:M?e("span",{className:a.badgeOnline,children:"Connected"}):e("span",{className:a.badgeOffline,children:"Not connected"})]})}),e(Ke,{kind:"manga",active:x==="mal"}),e("div",{className:a.radioGroup,children:[e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"username",checked:ae==="username",onChange:()=>ve("username")}),e("span",{children:"Username"})]}),e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"xml",checked:ae==="xml",onChange:()=>ve("xml")}),e("span",{children:"XML File"})]})]}),ae==="username"?e("div",{className:a.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:U,onChange:n=>be(n.currentTarget.value),className:a.input,disabled:j.isPending,onKeyDown:n=>{n.key==="Enter"&&U.trim()&&j.mutate()}})}):e("div",{className:a.uploadArea,children:e("div",{className:a.fileInputWrapper,children:[e("input",{type:"file",id:"malMangaFile",accept:".xml,application/xml",className:a.fileInput,onChange:n=>Qe(n.currentTarget.files?.[0]?.name??""),disabled:ne}),e("div",{className:a.fileDisplay,children:[e(m,{name:"file-alt",className:a.fileIcon}),e("span",{className:a.fileName,children:Ie||"Choose XML file..."})]}),e("label",{htmlFor:"malMangaFile",className:a.browseButton,children:"Browse"})]})}),e("div",{className:a.optionsArea,children:e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:u,onChange:n=>_(n.currentTarget.checked),className:a.checkbox,disabled:j.isPending||ne}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Replace AniList-linked manga"}),e("span",{className:a.optionDesc,children:"Clears previously imported (anilist:) entries before importing. Your provider bookmarks are never touched."})]})]})}),ae==="username"?e("button",{className:a.syncBtn,onClick:()=>j.mutate(),disabled:!U.trim()||j.isPending,children:[e(m,{name:"download"}),j.isPending?"Importing...":"Start Import"]}):e("div",{className:a.actions,children:e(ge,{onClick:Oe,className:a.importBtn,disabled:ne||!Ie,children:[e(m,{name:"upload"})," ",ne?"Importing...":"Start Import"]})}),j.isError&&e("div",{className:`${a.statusMessage} ${a.error}`,children:j.error.message}),Ce&&e("div",{className:`${a.statusMessage} ${a.error}`,children:Ce}),oe&&e("div",{className:`${a.statusMessage} ${a.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{In as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as t,d as g,A as U,h as b,S as tt,g as Ns,q as _,o as ws,p as As,a as Is,T as Ce}from"./vendor-core-DfaOB3Rn.js";import{h as jt,p as $,t as kt,ac as Ps,a6 as xs,S as tr,e as Rs,ak as Ls,J as Br,B as fe,a8 as Bs}from"./index-CuAIqL2m.js";import{P as Ms,a as $s,b as Ds,F as Os,f as zs,c as Fs}from"./PlayerProvider-zJDJ7w2h.js";import{u as Vs}from"./vendor-query-BBT5_sHx.js";import{I as ie}from"./vendor-icons-DrybRNxP.js";import{p as or,M as Us,z as zr,f as ar,c as Ws,C as Hs,a as qs,P as Ks,b as _n,u as Ys,i as Qs,j as js,n as Gs,h as Xs,k as Js,m as Zs,l as eo,s as nr,d as to,e as no,g as ro,r as so,o as Re,A as oo,t as ao,E as io,w as lo,x as co,v as Z,y as uo,R as mo,q as Mr}from"./useWatchAlongPlayer-C1iSTWOt.js";import{S as ho,O as rr,a as vo,A as po,b as fo}from"./OptionListMenu-DpPePCh7.js";import{M as bo}from"./MatureConsentModal-GDXcsFKz.js";import{u as go}from"./useProviders-D0h-Ecgo.js";import{e as yo,b as So,f as _o,g as Co,d as To,c as ko,h as Eo,i as No}from"./useTvLibrary-C5s5jt9x.js";import{b as wo,i as Qt,l as Ao,a as Io,c as Po,h as $r}from"./playbackCompletion-Dz5SRhiZ.js";import{u as xo}from"./useIsMobile-Dvx1uJ82.js";import{S as Ro}from"./SynopsisText-B3Sa5pRv.js";import{W as Lo}from"./WatchAlongPanel-CBk19tnW.js";import"./libraryInvalidation-CXA8qvJE.js";const Bo="_fullscreenFlat_n2elb_1",Mo="_timeDisplay_n2elb_12",$o="_bottomControls_n2elb_16",Do="_leftControls_n2elb_20",Oo="_rightControls_n2elb_21",zo="_controlBtn_n2elb_25",Fo="_controlsOverlay_n2elb_32",Vo="_hidden_n2elb_52",Uo="_topControls_n2elb_58",Wo="_backBtn_n2elb_78",Ho="_videoTitleInfo_n2elb_98",qo="_animeTitle_n2elb_104",Ko="_episodeLabel_n2elb_112",Yo="_speedBoostBadge_n2elb_119",Qo="_progressBarContainer_n2elb_165",jo="_progressBar_n2elb_165",Go="_thumb_n2elb_184",Xo="_bufferedBar_n2elb_202",Jo="_watchedBar_n2elb_212",Zo="_scrubbing_n2elb_237",ea="_timeBubble_n2elb_241",ta="_bottomControlsRow_n2elb_255",na="_nextEpisodeBtn_n2elb_278",ra="_active_n2elb_340",sa="_settingsPanel_n2elb_352",oa="_settingsHeader_n2elb_371",aa="_settingsBackBtn_n2elb_379",ia="_settingsTitle_n2elb_397",la="_settingsContent_n2elb_408",ca="_currentValue_n2elb_417",da="_menuItem_n2elb_423",ua="_menuNote_n2elb_456",ma="_loadingOverlay_n2elb_465",ha="_loadingDots_n2elb_476",va="_dot_n2elb_481",pa="_bufferingOverlay_n2elb_510",fa="_bufferingSpinner_n2elb_519",o={fullscreenFlat:Bo,timeDisplay:Mo,bottomControls:$o,leftControls:Do,rightControls:Oo,controlBtn:zo,controlsOverlay:Fo,hidden:Vo,topControls:Uo,backBtn:Wo,videoTitleInfo:Ho,animeTitle:qo,episodeLabel:Ko,speedBoostBadge:Yo,progressBarContainer:Qo,progressBar:jo,thumb:Go,bufferedBar:Xo,watchedBar:Jo,scrubbing:Zo,timeBubble:ea,bottomControlsRow:ta,nextEpisodeBtn:na,active:ra,settingsPanel:sa,settingsHeader:oa,settingsBackBtn:aa,settingsTitle:ia,settingsContent:la,currentValue:ca,menuItem:da,menuNote:ua,loadingOverlay:ma,loadingDots:ha,dot:va,bufferingOverlay:pa,bufferingSpinner:fa},ba=({player:s,visible:f,settingsOpen:z,onOpenSettings:x,onCloseSettings:M,hasSubtitles:k,isSubtitleActive:w,subtitles:d,onSubtitleChange:c,showNextEpisodeButton:C,onNextEpisode:r,isTheaterMode:R,onTheaterModeToggle:be,timeLabelRef:te})=>{const{state:u,actions:Ne}=s,Le=()=>{if(w){c(-1);return}let ge=null;try{ge=$.getItem("tvLastSubtitle")}catch{}c(or(d,{lastKey:ge,enabled:!0}))};return t("div",{className:`${o.controlsOverlay} ${f?"":o.hidden}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:o.bottomControls,onClick:ge=>ge.stopPropagation(),children:[t(Ms,{classes:{container:o.progressBarContainer,scrubbing:o.scrubbing,timeBubble:o.timeBubble,bar:o.progressBar,buffered:o.bufferedBar,watched:o.watchedBar,thumb:o.thumb},timeLabelRef:te}),t("div",{className:o.bottomControlsRow,children:[t("div",{className:o.leftControls,children:[t($s,{className:o.controlBtn}),t(Ds,{buttonClassName:o.controlBtn,onExpandedChange:Ne.setShowVolumeSlider}),t("span",{className:o.timeDisplay,ref:te,children:[jt(0)," / ",jt(u.duration)]})]}),t("div",{className:o.rightControls,children:[C&&t("button",{className:o.nextEpisodeBtn,onClick:r,title:"Play next episode",children:"Next EP"}),k&&t("button",{className:`${o.controlBtn} ${w?o.active:""}`,onClick:Le,"aria-label":w?"Turn subtitles off":"Turn subtitles on",children:t(ie,{name:"closed-captioning"})}),t("button",{className:`${o.controlBtn} ${z?o.active:""}`,onClick:()=>z?M():x(),"aria-label":"Settings",children:t(ie,{name:"cog"})}),t("button",{className:`${o.controlBtn} ${R?o.active:""}`,onClick:ge=>{ge.stopPropagation(),be()},title:R?"Exit Theater Mode":"Theater Mode","aria-label":R?"Exit Theater Mode":"Theater Mode",children:t(ie,{name:"tv"})}),t(Os,{className:o.controlBtn})]})]})]})})},Cn=-6e4,sr=6e4,Dr=500,ga=({classes:s,delayMs:f,onDelayChange:z})=>{const[x,M]=g(null),k=x??f,w=U(z);w.current=z;const d=U(f);d.current=f;const c=U(null);c.current=x,b(()=>{M(null)},[f]),b(()=>()=>{const R=c.current;R!==null&&R!==d.current&&w.current(R)},[]);const C=R=>{d.current=R,c.current=null,w.current(R),M(null)},r=R=>{const be=c.current??d.current,te=Math.max(Cn,Math.min(sr,be+R));C(te)};return t(tt,{children:[t("div",{style:{display:"flex",gap:6,padding:"0.5rem 0.75rem 0.25rem"},children:[t("button",{type:"button",className:s.item,onClick:()=>r(-Dr),"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:()=>r(Dr),"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:()=>C(0),disabled:k===0,"aria-label":"Reset subtitle timing",style:{flex:1,justifyContent:"center"},children:t("span",{children:"Reset"})})]}),t(Us,{label:"Subtitle timing",display:zr(k),min:Cn,max:sr,step:100,value:k,percent:(k-Cn)/(sr-Cn)*100,onChange:R=>{const be=Math.round(R);c.current=be,M(be)},onCommit:()=>{const R=c.current;R!==null&&C(R)}}),t("div",{className:s.note,children:"Positive delays subtitles (show later). Negative shows them earlier. 0.0s is default."})]})},ya=({view:s,onSelectView:f,onClose:z,player:x,onSubtitleStyleChange:M,streams:k,resolutionIdx:w,onResolutionChange:d,hasSubtitles:c,subtitles:C,selectedSubtitle:r,isSubtitleActive:R,onSubtitleChange:be,audioTracks:te,selectedAudioTrack:u,onAudioTrackChange:Ne,videoDelayEnabled:Le,onVideoDelayToggle:ge,videoDelayMs:ye,onVideoDelayChange:S,onCalibrate:Et,subtitleDelayMs:nt,onSubtitleDelayChange:E,ambientSettings:W,onAmbientChange:Y})=>{const{state:de}=x,Nt=()=>t(tt,{children:[k.length>1&&t("button",{className:o.menuItem,onClick:()=>f("resolution"),children:[t("span",{children:"Resolution"}),t("span",{className:o.currentValue,children:k[w]?.quality||"Auto"})]}),c&&t("button",{className:o.menuItem,onClick:()=>f("subtitles"),children:[t("span",{children:"Subtitles"}),t("span",{className:o.currentValue,children:R?C[r]?.label||C[r]?.language:"Off"})]}),c&&t("button",{className:o.menuItem,onClick:()=>f("subtitle-style"),children:[t("span",{children:"Subtitle Style"}),t("span",{className:o.currentValue,children:[de.subtitleFontSize.toFixed(1),"x · ",de.subtitlePosition]})]}),c&&t("button",{className:o.menuItem,onClick:()=>f("subtitle-timing"),children:[t("span",{children:"Subtitle Timing"}),t("span",{className:o.currentValue,children:zr(nt)})]}),te.length>0&&t("button",{className:o.menuItem,onClick:()=>f("audio"),children:[t("span",{children:"Audio Track"}),t("span",{className:o.currentValue,children:te[u]?.label||te[u]?.language})]}),t("button",{className:o.menuItem,onClick:()=>f("av-sync"),children:[t("span",{children:"A/V Sync"}),t("span",{className:o.currentValue,children:Le?`${ye}ms`:"Off"})]}),W&&Y&&t("button",{className:o.menuItem,onClick:()=>f("ambient"),children:[t("span",{children:"Ambient Light"}),t("span",{className:o.currentValue,children:W.enabled?"On":"Off"})]})]}),Be=()=>t(rr,{classes:{item:o.menuItem,active:o.active},options:k.map((A,re)=>({key:String(re),label:A.quality,selected:re===w})),onSelect:A=>d(Number(A))}),rt=()=>t(rr,{classes:{item:o.menuItem,active:o.active},options:[{key:"off",label:"Off",selected:!R},...C.map((A,re)=>({key:String(re),label:A.label||A.language,selected:re===r}))],onSelect:A=>be(A==="off"?-1:Number(A))}),pt=()=>t(vo,{classes:{item:o.menuItem,active:o.active},values:{fontSize:de.subtitleFontSize,position:de.subtitlePosition,bgOpacity:de.subtitleBgOpacity,bgColor:de.subtitleBgColor,textColor:de.subtitleTextColor,edge:de.subtitleEdge,bold:de.subtitleBold},onChange:M}),le=()=>t(ga,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},delayMs:nt,onDelayChange:A=>E?.(A)}),wt=()=>t(rr,{classes:{item:o.menuItem,active:o.active},options:te.map((A,re)=>({key:String(re),label:A.label||A.language,selected:re===u})),onSelect:A=>Ne(Number(A))}),st=()=>t(po,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},enabled:Le,delayMs:ye,onToggle:A=>ge?.(A),onDelayChange:A=>S?.(A),onCalibrate:Et}),Q=()=>W&&Y?t(fo,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},values:W,onChange:Y}):null;return t("div",{"data-speed-boost-ignore":"true",onClick:A=>A.stopPropagation(),children:t(ho,{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"?z():f("main"),children:[s==="main"&&Nt(),s==="resolution"&&Be(),s==="subtitles"&&rt(),s==="subtitle-style"&&pt(),s==="subtitle-timing"&&le(),s==="audio"&&wt(),s==="av-sync"&&st(),s==="ambient"&&Q()]})})},Sa=({player:s,title:f,episodeLabel:z,server:x,audioTracks:M,selectedAudioTrack:k,onAudioTrackChange:w,subtitles:d,selectedSubtitle:c,onSubtitleChange:C,streams:r,resolutionIdx:R,onResolutionChange:be,onBack:te,children:u,videoDelayEnabled:Ne=!1,onVideoDelayToggle:Le,videoDelayMs:ge=0,onVideoDelayChange:ye,onCalibrateAvSync:S,subtitleDelayMs:Et=0,onSubtitleDelayChange:nt,showNextEpisodeButton:E=!1,onNextEpisode:W,isLoading:Y=!1,isTheaterMode:de,onTheaterModeToggle:Nt,ambientSettings:Be,onAmbientChange:rt,hideChrome:pt=!1})=>{const{state:le,refs:wt,actions:st}=s,Q=wt.videoRef,{subtitleFontSize:A,subtitlePosition:re,subtitleBgOpacity:ue,subtitleBgColor:Me,subtitleTextColor:$e,subtitleEdge:se,subtitleBold:At}=le,[Ue,Te]=g(null),It=U(null),[ke,Pt]=g(0);b(()=>{const he=Q.current;if(!he)return;const ne=()=>Pt(he.clientHeight||0);ne();const at=new ResizeObserver(ne);return at.observe(he),()=>at.disconnect()},[Q]);const me=st.setSubtitleStyle;b(()=>{const he="tv-player-subtitle-style";let ne=document.getElementById(he);ne||(ne=document.createElement("style"),ne.id=he,document.head.appendChild(ne));const at={fontSize:A,position:re,bgOpacity:ue,bgColor:Me,textColor:$e,edge:se,bold:At},oe=Q.current,gt=ar(A,ke||oe?.clientHeight||720);if(ne.textContent=Ws({...at,fontSize:gt}),oe){const Lt=()=>{const i=Number(re);return isNaN(i)?0:Math.max(0,Math.min(100,i))},it=(i,l)=>{try{const F=i;F.snapToLines=!1,F.line=l}catch{}},Se=()=>{const i=gt*16,l=oe.videoHeight||oe.clientHeight||720,F=oe.videoWidth||oe.clientWidth||1280;return{step:i*1.3/l*100,chars:Math.max(20,Math.floor(F/(i*.55)))}},Jt=i=>{const l=Math.max(0,Math.min(100,100-Lt())),F=Array.from(i.activeCues??[]);if(F.length<=1){F.forEach(Oe=>it(Oe,l));return}const{step:ce,chars:Zt}=Se();let $t=l;for(let Oe=F.length-1;Oe>=0;Oe--){const Tn=String(F[Oe].text??"").replace(/<[^>]*>/g,"").split(`
|
|
1
|
+
import{u as t,d as g,A as U,h as b,S as tt,g as Ns,q as _,o as ws,p as As,a as Is,T as Ce}from"./vendor-core-DfaOB3Rn.js";import{h as jt,p as $,t as kt,ac as Ps,a6 as xs,S as tr,e as Rs,ak as Ls,J as Br,B as fe,a8 as Bs}from"./index-BVkDKnzf.js";import{P as Ms,a as $s,b as Ds,F as Os,f as zs,c as Fs}from"./PlayerProvider-9AfeIQ6B.js";import{u as Vs}from"./vendor-query-BBT5_sHx.js";import{I as ie}from"./vendor-icons-C1Pj_eSX.js";import{p as or,M as Us,z as zr,f as ar,c as Ws,C as Hs,a as qs,P as Ks,b as _n,u as Ys,i as Qs,j as js,n as Gs,h as Xs,k as Js,m as Zs,l as eo,s as nr,d as to,e as no,g as ro,r as so,o as Re,A as oo,t as ao,E as io,w as lo,x as co,v as Z,y as uo,R as mo,q as Mr}from"./useWatchAlongPlayer-BTSgNMqR.js";import{S as ho,O as rr,a as vo,A as po,b as fo}from"./OptionListMenu-BRI8vna9.js";import{M as bo}from"./MatureConsentModal-CC0bqpsd.js";import{u as go}from"./useProviders-CrYpQhz2.js";import{e as yo,b as So,f as _o,g as Co,d as To,c as ko,h as Eo,i as No}from"./useTvLibrary-DqLFBTa7.js";import{b as wo,i as Qt,l as Ao,a as Io,c as Po,h as $r}from"./playbackCompletion-Bgy18e-S.js";import{u as xo}from"./useIsMobile-Dvx1uJ82.js";import{S as Ro}from"./SynopsisText-B3Sa5pRv.js";import{W as Lo}from"./WatchAlongPanel-C2JcUz-e.js";import"./libraryInvalidation-ar7SX0CJ.js";const Bo="_fullscreenFlat_n2elb_1",Mo="_timeDisplay_n2elb_12",$o="_bottomControls_n2elb_16",Do="_leftControls_n2elb_20",Oo="_rightControls_n2elb_21",zo="_controlBtn_n2elb_25",Fo="_controlsOverlay_n2elb_32",Vo="_hidden_n2elb_52",Uo="_topControls_n2elb_58",Wo="_backBtn_n2elb_78",Ho="_videoTitleInfo_n2elb_98",qo="_animeTitle_n2elb_104",Ko="_episodeLabel_n2elb_112",Yo="_speedBoostBadge_n2elb_119",Qo="_progressBarContainer_n2elb_165",jo="_progressBar_n2elb_165",Go="_thumb_n2elb_184",Xo="_bufferedBar_n2elb_202",Jo="_watchedBar_n2elb_212",Zo="_scrubbing_n2elb_237",ea="_timeBubble_n2elb_241",ta="_bottomControlsRow_n2elb_255",na="_nextEpisodeBtn_n2elb_278",ra="_active_n2elb_340",sa="_settingsPanel_n2elb_352",oa="_settingsHeader_n2elb_371",aa="_settingsBackBtn_n2elb_379",ia="_settingsTitle_n2elb_397",la="_settingsContent_n2elb_408",ca="_currentValue_n2elb_417",da="_menuItem_n2elb_423",ua="_menuNote_n2elb_456",ma="_loadingOverlay_n2elb_465",ha="_loadingDots_n2elb_476",va="_dot_n2elb_481",pa="_bufferingOverlay_n2elb_510",fa="_bufferingSpinner_n2elb_519",o={fullscreenFlat:Bo,timeDisplay:Mo,bottomControls:$o,leftControls:Do,rightControls:Oo,controlBtn:zo,controlsOverlay:Fo,hidden:Vo,topControls:Uo,backBtn:Wo,videoTitleInfo:Ho,animeTitle:qo,episodeLabel:Ko,speedBoostBadge:Yo,progressBarContainer:Qo,progressBar:jo,thumb:Go,bufferedBar:Xo,watchedBar:Jo,scrubbing:Zo,timeBubble:ea,bottomControlsRow:ta,nextEpisodeBtn:na,active:ra,settingsPanel:sa,settingsHeader:oa,settingsBackBtn:aa,settingsTitle:ia,settingsContent:la,currentValue:ca,menuItem:da,menuNote:ua,loadingOverlay:ma,loadingDots:ha,dot:va,bufferingOverlay:pa,bufferingSpinner:fa},ba=({player:s,visible:f,settingsOpen:z,onOpenSettings:x,onCloseSettings:M,hasSubtitles:k,isSubtitleActive:w,subtitles:d,onSubtitleChange:c,showNextEpisodeButton:C,onNextEpisode:r,isTheaterMode:R,onTheaterModeToggle:be,timeLabelRef:te})=>{const{state:u,actions:Ne}=s,Le=()=>{if(w){c(-1);return}let ge=null;try{ge=$.getItem("tvLastSubtitle")}catch{}c(or(d,{lastKey:ge,enabled:!0}))};return t("div",{className:`${o.controlsOverlay} ${f?"":o.hidden}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:o.bottomControls,onClick:ge=>ge.stopPropagation(),children:[t(Ms,{classes:{container:o.progressBarContainer,scrubbing:o.scrubbing,timeBubble:o.timeBubble,bar:o.progressBar,buffered:o.bufferedBar,watched:o.watchedBar,thumb:o.thumb},timeLabelRef:te}),t("div",{className:o.bottomControlsRow,children:[t("div",{className:o.leftControls,children:[t($s,{className:o.controlBtn}),t(Ds,{buttonClassName:o.controlBtn,onExpandedChange:Ne.setShowVolumeSlider}),t("span",{className:o.timeDisplay,ref:te,children:[jt(0)," / ",jt(u.duration)]})]}),t("div",{className:o.rightControls,children:[C&&t("button",{className:o.nextEpisodeBtn,onClick:r,title:"Play next episode",children:"Next EP"}),k&&t("button",{className:`${o.controlBtn} ${w?o.active:""}`,onClick:Le,"aria-label":w?"Turn subtitles off":"Turn subtitles on",children:t(ie,{name:"closed-captioning"})}),t("button",{className:`${o.controlBtn} ${z?o.active:""}`,onClick:()=>z?M():x(),"aria-label":"Settings",children:t(ie,{name:"cog"})}),t("button",{className:`${o.controlBtn} ${R?o.active:""}`,onClick:ge=>{ge.stopPropagation(),be()},title:R?"Exit Theater Mode":"Theater Mode","aria-label":R?"Exit Theater Mode":"Theater Mode",children:t(ie,{name:"tv"})}),t(Os,{className:o.controlBtn})]})]})]})})},Cn=-6e4,sr=6e4,Dr=500,ga=({classes:s,delayMs:f,onDelayChange:z})=>{const[x,M]=g(null),k=x??f,w=U(z);w.current=z;const d=U(f);d.current=f;const c=U(null);c.current=x,b(()=>{M(null)},[f]),b(()=>()=>{const R=c.current;R!==null&&R!==d.current&&w.current(R)},[]);const C=R=>{d.current=R,c.current=null,w.current(R),M(null)},r=R=>{const be=c.current??d.current,te=Math.max(Cn,Math.min(sr,be+R));C(te)};return t(tt,{children:[t("div",{style:{display:"flex",gap:6,padding:"0.5rem 0.75rem 0.25rem"},children:[t("button",{type:"button",className:s.item,onClick:()=>r(-Dr),"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:()=>r(Dr),"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:()=>C(0),disabled:k===0,"aria-label":"Reset subtitle timing",style:{flex:1,justifyContent:"center"},children:t("span",{children:"Reset"})})]}),t(Us,{label:"Subtitle timing",display:zr(k),min:Cn,max:sr,step:100,value:k,percent:(k-Cn)/(sr-Cn)*100,onChange:R=>{const be=Math.round(R);c.current=be,M(be)},onCommit:()=>{const R=c.current;R!==null&&C(R)}}),t("div",{className:s.note,children:"Positive delays subtitles (show later). Negative shows them earlier. 0.0s is default."})]})},ya=({view:s,onSelectView:f,onClose:z,player:x,onSubtitleStyleChange:M,streams:k,resolutionIdx:w,onResolutionChange:d,hasSubtitles:c,subtitles:C,selectedSubtitle:r,isSubtitleActive:R,onSubtitleChange:be,audioTracks:te,selectedAudioTrack:u,onAudioTrackChange:Ne,videoDelayEnabled:Le,onVideoDelayToggle:ge,videoDelayMs:ye,onVideoDelayChange:S,onCalibrate:Et,subtitleDelayMs:nt,onSubtitleDelayChange:E,ambientSettings:W,onAmbientChange:Y})=>{const{state:de}=x,Nt=()=>t(tt,{children:[k.length>1&&t("button",{className:o.menuItem,onClick:()=>f("resolution"),children:[t("span",{children:"Resolution"}),t("span",{className:o.currentValue,children:k[w]?.quality||"Auto"})]}),c&&t("button",{className:o.menuItem,onClick:()=>f("subtitles"),children:[t("span",{children:"Subtitles"}),t("span",{className:o.currentValue,children:R?C[r]?.label||C[r]?.language:"Off"})]}),c&&t("button",{className:o.menuItem,onClick:()=>f("subtitle-style"),children:[t("span",{children:"Subtitle Style"}),t("span",{className:o.currentValue,children:[de.subtitleFontSize.toFixed(1),"x · ",de.subtitlePosition]})]}),c&&t("button",{className:o.menuItem,onClick:()=>f("subtitle-timing"),children:[t("span",{children:"Subtitle Timing"}),t("span",{className:o.currentValue,children:zr(nt)})]}),te.length>0&&t("button",{className:o.menuItem,onClick:()=>f("audio"),children:[t("span",{children:"Audio Track"}),t("span",{className:o.currentValue,children:te[u]?.label||te[u]?.language})]}),t("button",{className:o.menuItem,onClick:()=>f("av-sync"),children:[t("span",{children:"A/V Sync"}),t("span",{className:o.currentValue,children:Le?`${ye}ms`:"Off"})]}),W&&Y&&t("button",{className:o.menuItem,onClick:()=>f("ambient"),children:[t("span",{children:"Ambient Light"}),t("span",{className:o.currentValue,children:W.enabled?"On":"Off"})]})]}),Be=()=>t(rr,{classes:{item:o.menuItem,active:o.active},options:k.map((A,re)=>({key:String(re),label:A.quality,selected:re===w})),onSelect:A=>d(Number(A))}),rt=()=>t(rr,{classes:{item:o.menuItem,active:o.active},options:[{key:"off",label:"Off",selected:!R},...C.map((A,re)=>({key:String(re),label:A.label||A.language,selected:re===r}))],onSelect:A=>be(A==="off"?-1:Number(A))}),pt=()=>t(vo,{classes:{item:o.menuItem,active:o.active},values:{fontSize:de.subtitleFontSize,position:de.subtitlePosition,bgOpacity:de.subtitleBgOpacity,bgColor:de.subtitleBgColor,textColor:de.subtitleTextColor,edge:de.subtitleEdge,bold:de.subtitleBold},onChange:M}),le=()=>t(ga,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},delayMs:nt,onDelayChange:A=>E?.(A)}),wt=()=>t(rr,{classes:{item:o.menuItem,active:o.active},options:te.map((A,re)=>({key:String(re),label:A.label||A.language,selected:re===u})),onSelect:A=>Ne(Number(A))}),st=()=>t(po,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},enabled:Le,delayMs:ye,onToggle:A=>ge?.(A),onDelayChange:A=>S?.(A),onCalibrate:Et}),Q=()=>W&&Y?t(fo,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},values:W,onChange:Y}):null;return t("div",{"data-speed-boost-ignore":"true",onClick:A=>A.stopPropagation(),children:t(ho,{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"?z():f("main"),children:[s==="main"&&Nt(),s==="resolution"&&Be(),s==="subtitles"&&rt(),s==="subtitle-style"&&pt(),s==="subtitle-timing"&&le(),s==="audio"&&wt(),s==="av-sync"&&st(),s==="ambient"&&Q()]})})},Sa=({player:s,title:f,episodeLabel:z,server:x,audioTracks:M,selectedAudioTrack:k,onAudioTrackChange:w,subtitles:d,selectedSubtitle:c,onSubtitleChange:C,streams:r,resolutionIdx:R,onResolutionChange:be,onBack:te,children:u,videoDelayEnabled:Ne=!1,onVideoDelayToggle:Le,videoDelayMs:ge=0,onVideoDelayChange:ye,onCalibrateAvSync:S,subtitleDelayMs:Et=0,onSubtitleDelayChange:nt,showNextEpisodeButton:E=!1,onNextEpisode:W,isLoading:Y=!1,isTheaterMode:de,onTheaterModeToggle:Nt,ambientSettings:Be,onAmbientChange:rt,hideChrome:pt=!1})=>{const{state:le,refs:wt,actions:st}=s,Q=wt.videoRef,{subtitleFontSize:A,subtitlePosition:re,subtitleBgOpacity:ue,subtitleBgColor:Me,subtitleTextColor:$e,subtitleEdge:se,subtitleBold:At}=le,[Ue,Te]=g(null),It=U(null),[ke,Pt]=g(0);b(()=>{const he=Q.current;if(!he)return;const ne=()=>Pt(he.clientHeight||0);ne();const at=new ResizeObserver(ne);return at.observe(he),()=>at.disconnect()},[Q]);const me=st.setSubtitleStyle;b(()=>{const he="tv-player-subtitle-style";let ne=document.getElementById(he);ne||(ne=document.createElement("style"),ne.id=he,document.head.appendChild(ne));const at={fontSize:A,position:re,bgOpacity:ue,bgColor:Me,textColor:$e,edge:se,bold:At},oe=Q.current,gt=ar(A,ke||oe?.clientHeight||720);if(ne.textContent=Ws({...at,fontSize:gt}),oe){const Lt=()=>{const i=Number(re);return isNaN(i)?0:Math.max(0,Math.min(100,i))},it=(i,l)=>{try{const F=i;F.snapToLines=!1,F.line=l}catch{}},Se=()=>{const i=gt*16,l=oe.videoHeight||oe.clientHeight||720,F=oe.videoWidth||oe.clientWidth||1280;return{step:i*1.3/l*100,chars:Math.max(20,Math.floor(F/(i*.55)))}},Jt=i=>{const l=Math.max(0,Math.min(100,100-Lt())),F=Array.from(i.activeCues??[]);if(F.length<=1){F.forEach(Oe=>it(Oe,l));return}const{step:ce,chars:Zt}=Se();let $t=l;for(let Oe=F.length-1;Oe>=0;Oe--){const Tn=String(F[Oe].text??"").replace(/<[^>]*>/g,"").split(`
|
|
2
2
|
`).reduce((kn,ve)=>kn+Math.max(1,Math.ceil(ve.length/Zt)),0),Dt=$t-Tn*ce;it(F[Oe],Math.max(0,Dt)),$t=Dt-ce*.4}},Ae=()=>{const i=Math.max(0,Math.min(100,100-Lt()));Array.from(oe.textTracks).forEach(l=>{l.cues&&(Array.from(l.cues).forEach(F=>it(F,i)),l.mode==="showing"&&Jt(l))})};Ae();const lt=i=>{const l=i.target;l.mode==="showing"&&Jt(l)},Bt=()=>{Array.from(oe.textTracks).forEach(i=>{i.removeEventListener("cuechange",lt),i.addEventListener("cuechange",lt)}),Ae()};Array.from(oe.textTracks).forEach(i=>{i.addEventListener("cuechange",lt)}),oe.textTracks.addEventListener("addtrack",Bt);const Mt=Array.from(oe.querySelectorAll("track")),yt=()=>Ae();return Mt.forEach(i=>i.addEventListener("load",yt)),()=>{Array.from(oe.textTracks).forEach(i=>{i.removeEventListener("cuechange",lt)}),oe.textTracks.removeEventListener("addtrack",Bt),Mt.forEach(i=>i.removeEventListener("load",yt))}}},[A,re,ue,Me,$e,se,At,c,d,Q,ke]);const De=d.length>0,we=c>=0,ft=()=>{Te("main"),st.setShowControls(!0)},We=()=>{Te(null)},Gt=le.showControls||!!Ue,ot=zs(s.engine),He=ot.audioTracks.find(he=>he.id===ot.activeAudioTrack)??M[k],Xt=c>=0?d[c]??ot.subtitleTracks.find(he=>he.id===c):void 0,xt=t(Hs,{visible:Gt,title:f,episode:z,server:Y?void 0:x,audio:Y?void 0:He?.label||He?.language,subtitles:Y?void 0:Xt?.label||Xt?.language,onBack:te,classes:{overlay:o.controlsOverlay,hidden:o.hidden,top:o.topControls,backBtn:o.backBtn,titleInfo:o.videoTitleInfo,title:o.animeTitle,episode:o.episodeLabel}}),K=!Y&&!le.isBuffering&&le.duration>0?t(qs,{}):null,bt=t(ba,{player:s,visible:Gt,settingsOpen:!!Ue,onOpenSettings:ft,onCloseSettings:We,hasSubtitles:De,isSubtitleActive:we,subtitles:d,onSubtitleChange:C,showNextEpisodeButton:E,onNextEpisode:W,isTheaterMode:de,onTheaterModeToggle:Nt,timeLabelRef:It}),I=Ue?t(ya,{view:Ue,onSelectView:Te,onClose:We,player:s,onSubtitleStyleChange:me,streams:r,resolutionIdx:R,onResolutionChange:be,hasSubtitles:De,subtitles:d,selectedSubtitle:c,isSubtitleActive:we,onSubtitleChange:C,audioTracks:M,selectedAudioTrack:k,onAudioTrackChange:w,videoDelayEnabled:Ne,onVideoDelayToggle:Le,videoDelayMs:ge,onVideoDelayChange:ye,onCalibrate:()=>{Te(null),S?.()},subtitleDelayMs:Et,onSubtitleDelayChange:nt,ambientSettings:Be,onAmbientChange:rt}):null,Rt=t(tt,{children:[Y&&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})]})}),le.isBuffering&&!Y&&t("div",{className:o.bufferingOverlay,"aria-hidden":"true",children:t("div",{className:o.bufferingSpinner})}),le.isSpeedBoostActive&&t("div",{className:o.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(ie,{name:"forward",size:12})]})]});return t(Ks,{engine:s.engine,topBar:xt,centerControls:K,bottomBar:!Y&&le.duration>0?bt:null,settingsPanel:I,overlays:Rt,isInteracting:!!Ue||le.showVolumeSlider,nativeControls:le.useNativeControls,onStageClick:We,className:le.isFullscreen?o.fullscreenFlat:"",chromeDisabled:pt,children:u})},_a=({servers:s,selectedServer:f,onServerSelect:z})=>s.length===0?null:t("div",{className:_n.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:_n.sourceButtons,children:s.map(x=>t("button",{className:`${_n.sourceButton} ${f===x?_n.active:""}`,onClick:()=>z(x),children:x},x))})]}),Ca=Ns.memo(_a);function Ta({details:s,isMovie:f,season:z,episode:x,videoRef:M,active:k}){const w=U("");w.current||(w.current=`tv-${Date.now()}-${Math.random().toString(36).slice(2)}`);const d=_(()=>{if(!s)return;const c=M.current,C=f?"":`S${String(z).padStart(2,"0")}E${String(x).padStart(2,"0")}`;kt.discord.tvPresence.mutate({title:s.title,episodeLabel:C,isPlaying:c?!c.paused&&!c.ended:!0,thumbnail:s.poster,currentTime:c?c.currentTime:0,duration:c&&c.duration||0,isAdult:s.adult===!0,sessionId:w.current}).catch(()=>{}),kt.discord.heartbeat.mutate({sessionId:w.current}).catch(()=>{})},[s,f,z,x,M]);return b(()=>{if(!s)return;d();const c=window.setInterval(()=>{const C=M.current;(!C||!C.paused)&&d()},15e3);return()=>window.clearInterval(c)},[d,s,M]),b(()=>{if(!s||!k)return;const c=M.current;if(!c)return;const C=()=>d();return c.addEventListener("play",C),c.addEventListener("pause",C),c.addEventListener("seeked",C),()=>{c.removeEventListener("play",C),c.removeEventListener("pause",C),c.removeEventListener("seeked",C)}},[s,k,d,M]),b(()=>{const c=w.current,C=()=>Ps(c),r=()=>C();return window.addEventListener("pagehide",r),window.addEventListener("beforeunload",r),()=>{window.removeEventListener("pagehide",r),window.removeEventListener("beforeunload",r),C()}},[]),{sendPresence:d}}function ka(s,f,z){const x=()=>{const k=Array.isArray(s.audioTracks)?s.audioTracks.length:0,w=z.getWant(),d=k>0?Math.min(Math.max(0,w),k-1):w;s.audioTrack=d,d!==w&&z.onResolve(d)},M=(k,w)=>{const d=z.getWant(),c=Array.isArray(s.audioTracks)?s.audioTracks.length:0;if(w.id!==d&&d>=0&&d<c){s.audioTrack!==d&&(s.audioTrack=d);return}z.onResolve(w.id)};return s.on(f.MANIFEST_PARSED,x),s.on(f.AUDIO_TRACK_SWITCHED,M),()=>{s.off(f.MANIFEST_PARSED,x),s.off(f.AUDIO_TRACK_SWITCHED,M)}}const Ea=/\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 Na(){try{if(Ea.test(navigator.userAgent||""))return!0;const s=navigator.deviceMemory;if(typeof s=="number"&&s>0&&s<2)return!0}catch{}return!1}const wa="_statusMsg_vmhzm_1",Aa="_error_vmhzm_7",Ia="_spinner_vmhzm_11",Pa="_spin_vmhzm_11",xa="_sourceLoader_vmhzm_16",Ra="_ringSpinner_vmhzm_22",La="_meta_vmhzm_40",Ba="_year_vmhzm_48",Ma="_rating_vmhzm_53",$a="_typeBadge_vmhzm_62",Da="_tv_vmhzm_70",Oa="_movie_vmhzm_75",za="_controlLabel_vmhzm_80",Fa="_select_vmhzm_90",Va="_playerSection_vmhzm_102",Ua="_video_vmhzm_106",Wa="_videoHidden_vmhzm_128",Ha="_delayCanvas_vmhzm_133",qa="_delayCanvasActive_vmhzm_146",Ka="_subtitleOverlay_vmhzm_150",Ya="_videoIframe_vmhzm_169",Qa="_retryButton_vmhzm_177",ja="_sidebarSeason_vmhzm_192",Ga="_mobileSeasonRow_vmhzm_208",Xa="_providerActions_vmhzm_221",Ja="_providerRow_vmhzm_228",Za="_autoplayActive_vmhzm_247",ei="_genreRow_vmhzm_258",ti="_genreChip_vmhzm_265",ni="_metaRow_vmhzm_275",ri="_detailGrid_vmhzm_284",si="_detailItem_vmhzm_292",oi="_imdbLink_vmhzm_314",ai="_watchedOverlay_vmhzm_324",ii="_watchedTitle_vmhzm_346",li="_watchedSubtext_vmhzm_352",ci="_watchedActions_vmhzm_358",di="_watchedActionsCentered_vmhzm_376",p={statusMsg:wa,error:Aa,spinner:Ia,spin:Pa,sourceLoader:xa,ringSpinner:Ra,meta:La,year:Ba,rating:Ma,typeBadge:$a,tv:Da,movie:Oa,controlLabel:za,select:Fa,playerSection:Va,video:Ua,videoHidden:Wa,delayCanvas:Ha,delayCanvasActive:qa,subtitleOverlay:Ka,videoIframe:Ya,retryButton:Qa,sidebarSeason:ja,mobileSeasonRow:Ga,providerActions:Xa,providerRow:Ja,autoplayActive:Za,genreRow:ei,genreChip:ti,metaRow:ni,detailGrid:ri,detailItem:si,imdbLink:oi,watchedOverlay:ai,watchedTitle:ii,watchedSubtext:li,watchedActions:ci,watchedActionsCentered:di},ui=[],mi=[];function Or({error:s,onRetry:f}){return t("div",{className:`${p.statusMsg} ${p.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:p.retryButton,onClick:f,children:"Retry"})]})})}const Ai=()=>{const{id:s}=ws(),[f]=As(),z=U(f);z.current=f;const x=Is(),M=Vs(),k=f.get("type"),w=xs(),d=!!w.session,c=d&&!w.session?.host,C=c&&["tv","movie"].includes(w.room?.selection.kind||"")?w.room?.selection:null,[r,R]=g(null),[be,te]=g(()=>parseInt(f.get("s")||"1",10)||1),u=C?.season??be,[Ne,Le]=g([]),[ge,ye]=g(()=>parseInt(f.get("e")||"1",10)||1),S=C?Number(C.episode):ge,[Et,nt]=g(()=>{try{return $.getItem("tvProvider")||""}catch{return""}}),E=C?.provider??Et,[W,Y]=g([]),[de,Nt]=g(""),[Be,rt]=g(""),{options:pt,isFallback:le,isLoading:wt}=go(),st=Ce(()=>pt.filter(e=>(e.kind??"tv")==="tv").map(e=>({id:e.id,label:e.label,tier:e.tier==="embed"?"embed":"direct",servers:e.servers})),[pt]),Q=le||st.length===0?ui:st,A=Q.filter(e=>e.tier==="direct"),re=Q.filter(e=>e.tier==="embed"),[ue,Me]=g(!1),[$e,se]=g(""),[At,Ue]=g([]),[Te,It]=g(0),[ke,Pt]=g([]),[me,De]=g(-1),[we,ft]=g(0),[We,Gt]=g(""),[ot,He]=g(""),[Xt,xt]=g(()=>{try{return $.getItem("tvServer")||""}catch{return""}}),K=C?.source??Xt,bt=Ce(()=>Q.find(e=>e.id===E),[Q,E]),I=bt?.tier==="embed",[Rt,he]=g([]),[ne,at]=g(""),[oe,gt]=g(""),[Lt,it]=g(!1),Se=Ce(()=>Rt.length>0?Rt:bt?.servers??[],[Rt,bt]),Jt=Ce(()=>ne&&!d?["Embed",...Se]:Se,[Se,ne,d]),Ae=Lt&&!!ne,lt=Ae?oe||ne:"";b(()=>{if(!ne){gt("");return}let e=!1;return tr(`/api/resolve?url=${encodeURIComponent(ne)}`).then(n=>{!e&&n.finalUrl&>(n.finalUrl)}).catch(()=>{}),()=>{e=!0}},[ne]);const Bt=U([]);b(()=>{Bt.current=W},[W]);const Mt=U(Te);b(()=>{Mt.current=Te},[Te]);const yt=U(me);b(()=>{yt.current=me},[me]);const i=Ys({skipIntervals:mi}),l=i.refs.videoRef,F=U(null),ce=U([]),Zt=U(null),$t=U(null),{videoDelayMs:Oe,videoDelayEnabled:en,setDelayEnabled:Tn,handleVideoDelayChange:Dt,isCalibrating:kn,testClipActive:ve,stopCalibration:En,openAvSyncCalibrator:Fr,cancelAvSyncCalibrator:Vr,applyAvSyncCalibrator:Ur,toggleTestClip:Wr,calibReturnRef:tn,effectiveVideoDelayMs:Nn}=Qs(l),[St,Hr]=g(()=>{try{const e=Number($.getItem("tvSubtitleDelayMs"));if(Number.isFinite(e)&&e>=-6e4&&e<=6e4)return Math.round(e)}catch{}return 0}),wn=U(St);wn.current=St;const qr=_(e=>{const n=Math.max(-6e4,Math.min(6e4,Math.round(e)));if(wn.current!==n){wn.current=n,Hr(n);try{$.setItem("tvSubtitleDelayMs",String(n))}catch{}}},[]);js({videoRef:l,canvasRef:Zt,delayMs:Nn,enabled:en});const An=en,_e=An||St!==0,{settings:In,update:Kr}=Gs(),Pn=U(_e);Pn.current=_e;const xn=_(()=>{if(!Pn.current)return;const e=l.current;e&&Array.from(e.textTracks).forEach(n=>{n.mode!=="hidden"&&(n.mode="hidden")})},[l]),{hasConsent:Ot,grant:Yr}=Rs(),v=k==="movie";Ta({details:r,isMovie:v,season:u,episode:S,videoRef:l,active:!I&&!ue&&!$e&&W.length>0});const nn=s?Ls(k||"tv",s):"",j=nn,ze=`${j}:${u}:${S}:${E}:${K}`,rn=Ce(()=>!s||!r||I||Ae||ue||Be!==ze||W[we]?.type!=="hls"?null:{kind:v?"movie":"tv",...v?{}:{season:u},showId:s,episode:String(v?1:S),provider:E,source:K,mode:"sub",title:r.title},[s,r,I,Ae,ue,Be,ze,W,we,v,u,S,E,K]),ir=Xs(i.engine,rn,ue||!r),lr=yo(),Rn=So(),qe=_o(),Ke=Co(),{toggle:cr,bookmarkedIds:Qr,pending:jr}=To(),{data:dr}=ko(r?nn:void 0),zt=dr?!!dr.inLibrary:nn?Qr.has(nn):!1,Gr=_(()=>{!r||!s||cr({tmdbId:Number(s),mediaType:k||"tv",title:r.title,poster:r.poster,year:r.year,adult:r.adult})},[r,s,k,cr]),{data:Ye,isFetched:Ft,isFetching:Ln}=Eo(j||void 0,u,S),sn=Ce(()=>Ne.map(e=>e.episode_number).sort((e,n)=>e-n),[Ne]),Vt=sn.indexOf(S),Bn=Vt>0?sn[Vt-1]:null,P=Vt>=0&&Vt<sn.length-1?sn[Vt+1]:null,on=Ce(()=>(r?.seasons??[]).map(e=>e.season_number).filter(e=>Number.isFinite(e)).sort((e,n)=>e-n),[r]),G=Ce(()=>{if(v||P!=null)return null;const e=on.indexOf(u);return e>=0&&e<on.length-1?on[e+1]:(r?.number_of_seasons??0)>u?u+1:null},[v,P,on,u,r?.number_of_seasons]),Mn=wo(r?.status),ct=v||P==null&&G==null&&Mn,ur=P==null&&G==null&&!ct,Ie=Ye?.currentTime??0,an=U(null),[Qe,ln]=g(!1),[_t,mr]=g(0),[Ut,hr]=g(!1),[dt,ut]=g(!1),[Xr,$n]=g(!1),[Jr,Zr]=g(""),[cn,es]=g(!1),[ts,Dn]=g(!1),[On,zn]=g(!1),{isTheaterMode:Fe,toggleTheaterMode:Fn,handleLayoutClick:ns}=Js(),vr=Ye?.duration??0,pr=Ye?.completed===1,Wt=`${j}:${u}:${S}`,[fr,rs]=g(null);b(()=>{Ft&&rs(e=>e?.key===Wt?e:{key:Wt,watched:pr||Qt(Ie,vr)})},[Ft,Wt,pr,Ie,vr]);const ss=Ft&&fr?.key===Wt&&fr.watched,[dn]=g(Ao),[os,br]=g(!1);b(()=>{br(!1)},[Wt]);const gr=!d&&!ve&&ss&&!On,je=gr&&dn,mt=gr&&!dn&&!os,Ge=dt&&dn,as=dt&&!dn,yr=_(()=>{zn(!0),ut(!1)},[]);b(()=>{const e=n=>{n.defaultPrevented||n.ctrlKey||n.metaKey||n.altKey||n.repeat||n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="t"&&Fn()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[Fn]),Zs(i,(W.length>0||ot!=="")&&!Fe&&!Qe&&!dt&&!je&&!mt);const is=xo(),[Ct,ls]=g(Io),cs=_(e=>{ls(e),Po(e)},[]),ds=e=>t("div",{className:e,children:[t("button",{className:`${Z.episodeNavBtn} ${Z.secondary} ${Ct?p.autoplayActive:""}`,onClick:()=>cs(!Ct),type:"button","aria-pressed":Ct,children:Ct?"AUTOPLAY: ON":"AUTOPLAY: OFF"}),t("button",{className:`${Z.episodeNavBtn} ${Z.secondary}`,onClick:()=>Rn.mutate({mediaId:j??"",season:u,episode:S}),disabled:Rn.isPending,type:"button",children:[t(ie,{name:"undo",size:14}),Rn.isPending?"Resetting...":"Reset Progress"]}),t("button",{className:`${Z.episodeNavBtn} ${Z.secondary}`,onClick:()=>Bn!=null&&Tt(String(Bn)),disabled:c||Bn==null,type:"button",children:[t(ie,{name:"chevron-left",size:12}),"Prev EP"]}),t("button",{className:`${Z.episodeNavBtn} ${Z.primary}`,onClick:()=>P!=null&&Tt(String(P)),disabled:c||P==null,type:"button",children:["Next EP",t(ie,{name:"chevron-right",size:12})]}),is&&t("button",{className:`${Z.episodeNavBtn} ${Z.episodePickerBtn}`,onClick:()=>Dn(!0),type:"button",children:[t(ie,{name:"list-ul",size:12}),"Episodes"]})]}),Xe=U(!1),Ve=U(null),Vn=U(0),X=U(null),Sr=_(()=>{X.current=Ie,zn(!0),ut(!1)},[Ie]),un=U(""),us=$r(Ie),Ht=!d&&!Xe.current&&!On&&(Qe||dt||us||je||mt),mn=U(Ht);mn.current=Ht;const hn=U(!1);b(()=>{hn.current=Ut},[Ut]);const Je=_((e,n)=>{if(!j||!n||n<30)return;const a=Qt(e,n);Math.abs(e-Vn.current)<10&&!a||(Vn.current=e,lr.mutate({mediaId:j,season:u,episode:S,currentTime:Math.floor(e),duration:Math.floor(n),completed:a,title:r?.title??null,poster:r?.poster??null,backdrop:r?.backdrop??null,year:r?.year??null,overview:r?.overview??null,tmdbId:r?.id??null,mediaType:k||"tv",adult:r?.adult?1:0}))},[j,u,S,lr,r,k]),Pe=_((e,n)=>{En();const a=new URLSearchParams(f);a.set("type",f.get("type")||"tv"),a.set("s",String(e)),a.set("e",String(n)),x(`${window.location.pathname}?${a.toString()}`)},[f,x,En]),qt=_(()=>{const e=l.current;if(!e||v||P==null){$n(!1);return}const n=e.duration||0,a=e.currentTime||0;$n(n>0&&a/n>=.8)},[v,P,l]),vn=_((e,n)=>["tv-sources",E,v?"movie":"tv",s,e,n,K],[E,v,s,K]),pn=_(async(e,n)=>{if(!r||!s||!E)return{valid:!1,sources:[]};const a=v?"movie":"tv",m=await kt.tv.sources.query({provider:E,type:a,tmdbId:String(s),season:e,episode:n,title:r.title||"",year:r.year||"",totalSeasons:String(r.number_of_seasons||1),imdbId:r.imdb_id||"",...K?{server:K}:{}});return{valid:"valid"in m?m.valid:!1,error:"error"in m?m.error:void 0,sources:m.sources,referer:"referer"in m?m.referer:void 0,audioTracks:m.audioTracks,subtitles:"subtitles"in m?m.subtitles:void 0,servers:"servers"in m?m.servers:void 0,server:"server"in m?m.server:void 0,embedUrl:"embedUrl"in m?m.embedUrl:void 0}},[r,s,E,v,K]),_r=_(()=>{if(v||!r||!s||!E||I||P==null)return;const e=vn(u,P);M.getQueryState(e)?.status!=="success"&&M.prefetchQuery({queryKey:e,queryFn:()=>pn(u,P),staleTime:300*1e3,gcTime:1800*1e3})},[v,r,s,E,I,P,u,M,vn,pn]),ms=_(()=>{if(ve)return;qt();const e=l.current;!e||e.paused||e.ended||(e.duration>0&&e.duration-e.currentTime<=60&&_r(),!Ve.current&&(Ve.current=setTimeout(()=>{Ve.current=null,Je(e.currentTime,e.duration||0)},5e3)))},[Je,l,ve,qt,_r]),hs=_(()=>{const e=l.current;if(!(!e||!r)&&(Ve.current&&clearTimeout(Ve.current),Ve.current=null,Je(e.currentTime,e.duration||0),!c)){if(P!=null){Ct&&(ye(P),Pe(u,P));return}!v&&G==null&&!Mn||(Zr(v?r.title:`${r.title} - Season ${u}`),ut(!0),Xe.current=!0)}},[v,r,u,P,G,Mn,Ct,Je,Pe,l,c]),{checkEnd:fn,logDuration:Cr}=eo({videoRef:l,sourceType:I?"iframe":void 0,resetKey:`${j}:${u}:${S}:${On}`,onEnd:hs}),vs=_(()=>{i.actions.onPlay()},[i.actions]),ps=_(()=>{i.actions.onPause();const e=l.current;e&&!e.ended&&Je(e.currentTime,e.duration||0)},[i.actions,Je,l]),fs=_(()=>{const e=l.current;if(e){try{const n=parseFloat($.getItem("playerVolume")||"");isNaN(n)||(e.volume=Math.max(0,Math.min(1,n))),e.muted=$.getItem("playerMuted")==="true"}catch{}if(X.current!=null&&X.current>0){try{e.currentTime=X.current}catch{}X.current=null}qt()}},[l,qt]),Un=_(()=>{const e=l.current;if(e&&X.current!=null&&X.current>0){try{e.currentTime=X.current}catch{}X.current=null}},[l]),bs=_(()=>{_t>0&&(X.current=_t);const e=l.current;if(e&&_t>0){try{e.currentTime=_t,X.current=null}catch{}e.play().catch(()=>{})}ln(!1),Xe.current=!0},[_t,l]),Tr=_(()=>{X.current=null;const e=l.current;e&&(e.currentTime=0,e.play().catch(()=>{})),ln(!1),Xe.current=!0},[l]),Wn=_(()=>{P!=null&&(Xe.current=!0,ye(P),Pe(u,P))},[P,u,Pe]),Hn=_(()=>{G!=null&&(ut(!1),Xe.current=!0,te(G),ye(1),Pe(G,1))},[G,Pe]),qn=_(async()=>{if(j)try{zt?await qe.mutateAsync({id:j,status:"Completed"}):r&&s&&(await Ke.mutateAsync({tmdbId:Number(s),mediaType:k||"tv",title:r.title,poster:r.poster,backdrop:r.backdrop,year:r.year,overview:r.overview,adult:r.adult,status:"Completed",silent:!0}),Br.success("Moved to Completed")),ut(!1),x("/")}catch{}},[j,zt,qe,Ke,r,s,k,x]);b(()=>{Xe.current=!1,an.current=null,ln(!1),$n(!1),mr(0),hr(!1),zn(!1),hn.current=!1,X.current=null,Vn.current=0},[j,u,S]),b(()=>{un.current=ze},[ze]),b(()=>{Ft&&(hr(!0),hn.current=!0)},[Ft,j,u,S]),b(()=>{if(d||Ln||!Ye||Xe.current)return;const e=`${j}:${u}:${S}`;if(an.current===e)return;an.current=e;const n=Ye,a=n.currentTime??0;$r(a)&&n.completed!==1&&!Qt(a,n.duration??0)&&(mr(a),ln(!0))},[Ye,Ln,j,u,S,d]),b(()=>{!d&&Qe&&l.current&&l.current.pause()},[Qe,l,d]),b(()=>{!d&&mt&&l.current&&l.current.pause()},[mt,l,d]),b(()=>{(je||mt||Ge)&&i.state.isFullscreen&&i.actions.toggleFullscreen()},[je,mt,Ge,i.state.isFullscreen,i.actions]),b(()=>{const e=l.current;return()=>{Ve.current&&clearTimeout(Ve.current),Ve.current=null,!e?.ended&&i.engine.getState().duration>0&&Je(i.engine.getTimeline().currentTime,i.engine.getState().duration)}},[i.engine,Je,l]);const Kn=_(e=>{let n=null,a=!0;try{n=$.getItem("tvLastSubtitle"),a=$.getItem("tvSubtitlesEnabled")!=="false"}catch{}return or(e,{lastKey:n,enabled:a})},[]),Yn=_(e=>{if(!(e<0))try{$.setItem("tvSubtitlesEnabled","true"),$.setItem("tvSelectedSubtitle",String(e))}catch{}},[]),kr=_(e=>{if(e.length===0)return 0;let n=null;try{n=$.getItem("tvLastAudio")}catch{}if(n){const a=e.findIndex(L=>nr(L)===n);if(a>=0)return a;const m=n.indexOf("|||"),h=m>=0?n.slice(0,m):n,T=m>=0?n.slice(m+3):n,D=e.findIndex(L=>L.language===h||L.label===T);if(D>=0)return D}return or(e,{lastKey:null,enabled:!0})},[]),Er=_(e=>{let n=null;try{n=$.getItem("tvLastQuality")}catch{}if(!n||e.length===0)return 0;const a=e.findIndex(L=>(L.quality||"")===n);if(a>=0)return a;const m=L=>{const ee=/(\d{3,4})/.exec(L||"");return ee?parseInt(ee[1],10):0},h=m(n);if(!h)return 0;let T=0,D=1/0;return e.forEach((L,ee)=>{const y=m(L.quality),H=Math.abs(y-h);y>0&&H<D&&(D=H,T=ee)}),T},[]),{data:Nr}=No(j||void 0),wr=Ce(()=>(Nr?.progress??[]).filter(n=>n.season===u&&(n.completed===1||Qt(n.currentTime,n.duration))).map(n=>String(n.episode)),[Nr,u]),Ar=Ce(()=>Ne.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})),[Ne]),Ir=Ce(()=>(r?.genres??[]).map(e=>e.name).slice(0,5),[r]),Qn=Ce(()=>[r?.year,r?.status,r?.number_of_seasons?`${r.number_of_seasons} Season${r.number_of_seasons>1?"s":""}`:null,r?.number_of_episodes?`${r.number_of_episodes} Episodes`:null].filter(Boolean),[r]);b(()=>{if(!c&&Q.length!==0&&!Q.some(e=>e.id===E)){const e=Q.find(n=>n.tier==="direct")?.id??Q[0].id;nt(e);try{$.setItem("tvProvider",e)}catch{}}},[Q,E,c]),b(()=>{he([]),at(""),gt(""),it(!1)},[E]),b(()=>{if(!c&&Se.length!==0&&!Se.includes(K)){xt(Se[0]);try{$.setItem("tvServer",Se[0])}catch{}}},[Se,K,c]),b(()=>{if(!s){R(null),Y([]),rt(""),se(""),He("");return}const e=Number(s),n=k||"tv";R(null),Y([]),rt(""),se(""),He("");const a=parseInt(z.current.get("s")||"",10),m=parseInt(z.current.get("e")||"",10);te(isNaN(a)?1:a),ye(isNaN(m)?1:m),ft(0),kt.tv.details.query({type:n,id:String(e)}).then(h=>{const T={id:h.id,title:h.title||"",overview:h.overview||"",vote_average:h.vote_average,year:h.year,poster:h.poster,backdrop:h.backdrop,imdb_id:h.imdb_id||void 0,adult:h.adult,status:h.status,seasons:h.seasons,number_of_seasons:h.number_of_seasons};R(T),T.seasons&&T.seasons.length>0&&isNaN(a)&&te(T.seasons[0].season_number)}).catch(()=>{})},[s,k]),b(()=>{if(!r||!s)return;if(!(r.seasons!==void 0||r.number_of_seasons!==void 0)){Le([]);return}const n=parseInt(f.get("e")||"",10);kt.tv.episodes.query({id:String(s),season:String(u)}).then(a=>{const m=(a.episodes||[]).map(h=>({episode_number:h.episode_number,name:h.name||"",vote_average:h.vote_average,overview:h.overview||"",still_path:h.still_path||""}));Le(m),m.length!==0&&ye(h=>!isNaN(n)&&m.some(T=>T.episode_number===n)?n:m.some(T=>T.episode_number===h)?h:m[0].episode_number)}).catch(()=>{})},[r,s,u,f]),b(()=>{if(!I||!r||!s)return;tr(`/api/tv/embed/${E}/${v?"movie":"tv"}/${s}?season=${u}&episode=${S}`).then(n=>{if(n.url)return He(n.url),tr(`/api/resolve?url=${encodeURIComponent(n.url)}`).then(a=>{a.finalUrl&&He(a.finalUrl)})}).catch(()=>{})},[E,r,s,u,S,v,I]);const bn=_(async()=>{if(!r||!s||!E||I||r.adult&&!Ot)return;const e=ze;Me(!0),se(""),Bt.current.length===0&&(Y([]),ft(0),Ue([]),Pt([]));try{const n=await M.fetchQuery({queryKey:vn(u,S),queryFn:()=>pn(u,S),staleTime:3e5,gcTime:18e5});if(un.current!==e)return;if(Me(!1),!n.valid||!n.sources?.length){se(n.error?`${n.error}`:Se.length>0?`No streams from ${K}. Try another server.`:"No streams available.");return}if(d&&K&&n.server&&n.server!==K){Y([]),se("The host's selected server is unavailable. Automatic source switching is disabled in watch-along rooms.");return}!c&&!K&&n.server&&xt(n.server);const a=d?n.sources.filter(L=>L.type==="hls"):n.sources;if(d&&a.length===0){Y([]),se("The room requires a direct HLS source. No compatible stream is available here.");return}Y(a),Nt(n.server||K),rt(e),n.servers?.length&&he(n.servers),n.embedUrl&&at(n.embedUrl),ft(Er(a)),n.referer&&Gt(n.referer);const m=n.audioTracks||[];Ue(m),It(m.length>0?kr(m):0);const h=n.subtitles||[];if(Pt(h),h.length>0){const L=Kn(h);De(L),Yn(L)}else De(-1);const T=v?"movie":"tv",D=s;kt.tv.subtitles.query({type:T,tmdbId:String(D),season:String(u),episode:String(S)}).then(L=>{if(un.current!==e)return;const ee=Array.isArray(L.subtitles)?L.subtitles:[];ee.length!==0&&Pt(y=>{const H=[...y,...ee.filter(J=>!y.some(V=>V.url===J.url))];if(y.length===0){const J=Kn(H);De(J),Yn(J)}return H})}).catch(()=>{}),se("")}catch(n){if(un.current!==e)return;Me(!1),se(n instanceof Error?n.message:"Failed to load streams.")}},[r,s,E,u,S,v,I,Ot,Se,K,Kn,Yn,kr,Er,M,vn,pn,ze,d,c]),jn=_(()=>{const e=l.current;e&&!isNaN(e.currentTime)&&(X.current=e.currentTime)},[l]),gs=_(e=>{if(!(c||d&&e==="Embed")){if(e==="Embed"){it(!0);return}jn(),it(!1),xt(e);try{$.setItem("tvServer",e)}catch{}se("")}},[jn,c,d]),ys=_(e=>{nt(e);try{$.setItem("tvProvider",e)}catch{}},[]);b(()=>{E&&r&&!I&&bn()},[E,r,bn,I]),b(()=>{if(je){i.engine.unload();return}if(!l.current)return;if(F.current=null,I||Ae||d&&W[we]?.type!=="hls"){i.engine.unload();return}if(ve&&!d)return i.engine.loadSource({url:"/av-sync-test.mp4"},{autoPlay:!mn.current});if(tn.current!=null&&(X.current=tn.current,tn.current=null),Be===ze&&X.current==null&&!mn.current)try{const y=l.current;y&&!y.ended&&y.currentTime>1&&(X.current=y.currentTime)}catch{}const n=X.current??0,a=!ue&&Be===ze?Ae?"":W[we]?.url||"":"";if(!a){try{l.current?.pause(),l.current?.removeAttribute("src"),l.current?.load()}catch{}return}const m=l.current;m.pause(),m.removeAttribute("src"),m.load(),i.actions.resetMediaState();const h=`/api/tv/stream-proxy?url=${encodeURIComponent(a)}&referer=${encodeURIComponent(We)}&provider=${encodeURIComponent(E)}`,T=Na()||document.body.classList.contains("low-end"),D=T?60:180,L=i.engine.loadSource({url:h,hls:W[we]?.type==="hls"},{hlsConfig:{enableWorker:!0,lowLatencyMode:!1,startPosition:n>0?n:-1,maxBufferLength:D,maxMaxBufferLength:D+(T?30:60),backBufferLength:T?30:60,maxBufferSize:(T?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}}}},onHls:(y,H)=>{F.current=y;const J=()=>{let O=!1,B=0;try{O=$.getItem("tvSubtitlesEnabled")==="true";const N=parseInt($.getItem("tvSelectedSubtitle")||"0",10);!isNaN(N)&&N>=0&&(B=N)}catch{}return{enabled:O,index:B}},V=()=>{if(typeof y.subtitleTrack!="number")return;if(ce.current.length>0){y.subtitleTrack=-1;return}const O=Array.isArray(y.subtitleTracks)?y.subtitleTracks:[];if(O.length===0){y.subtitleTrack=-1;return}const B=J();if(B.enabled){const N=B.index<O.length?B.index:0;y.subtitleTrack=N,De(N),xn()}else y.subtitleTrack=-1};ka(y,H.Events,{getWant:()=>Mt.current,onResolve:O=>It(O)}),y.on(H.Events.MANIFEST_PARSED,V),y.on(H.Events.SUBTITLE_TRACKS_UPDATED,()=>{V()}),y.on(H.Events.SUBTITLE_TRACK_SWITCH,(O,B)=>{if(ce.current.length>0){if(B.id!==-1)try{y.subtitleTrack=-1}catch{}return}const N=Array.isArray(y.subtitleTracks)?y.subtitleTracks:[];if(N.length!==0){if(B.id===-1){const Ee=J();if(Ee.enabled){const ae=Ee.index<N.length?Ee.index:0;y.subtitleTrack=ae;return}}De(B.id),xn()}})},onReady:()=>{(n>0||!mn.current&&hn.current)&&i.engine.play()},onError:y=>{se(y.message),Me(!1),F.current=null}}),ee=()=>{const J=m.error?.code===4?"Video source not supported or not found":"Failed to load video stream";se(`${J}. The source may be invalid or expired. Try switching source or reloading.`),Me(!1)};return m.addEventListener("error",ee),()=>{L(),F.current=null,m.removeEventListener("error",ee)}},[W,Be,ue,we,E,We,I,Ae,l,tn,ve,j,u,S,Un,xn,i.actions,i.engine,ze,d,je]),b(()=>{if(c||!Ut||Qe||dt||Ht||I||ve)return;const e=l.current;!e||!e.paused||e.ended||e.readyState<1||(Un(),i.engine.play())},[Ut,Qe,dt,Ht,I,ve,Un,l,c,i.engine]),b(()=>{const e=F.current;!e||typeof e.audioTrack!="number"||(e.audioTrack=Te)},[Te]),b(()=>{const e=F.current;!e||typeof e.subtitleTrack!="number"||!Array.isArray(e.subtitleTracks)||e.subtitleTracks.length===0||ce.current.length>0||(me>=0?e.subtitleTrack=me:e.subtitleTrack=-1)},[me]),b(()=>{const e=l.current;if(!(!e||I)&&(e.querySelectorAll("track").forEach(n=>n.remove()),ce.current=[],ke.length!==0&&(ke.forEach(n=>{const a=document.createElement("track");a.kind="subtitles",a.label=n.label||n.language||"Unknown",a.srclang=n.language||n.label||"en";const m=`/api/subtitle-proxy?url=${encodeURIComponent(n.url)}&referer=${encodeURIComponent(We)}`;a.src=m,a.addEventListener("load",()=>{const h=ce.current.indexOf(a),T=a.track;if(T&&h>=0){const D=h===yt.current;T.mode=D&&!Pn.current?"showing":"hidden"}}),e.appendChild(a),ce.current.push(a)}),ke.length>0)))try{const n=F.current;n&&typeof n.subtitleTrack=="number"&&n.subtitleTrack!==-1&&(n.subtitleTrack=-1)}catch{}},[ke,We,I,E,K,l]),b(()=>{const e=l.current;if(!e||I)return;const n=F.current;ce.current.length>0&&n&&typeof n.subtitleTrack=="number"&&Array.isArray(n.subtitleTracks)&&n.subtitleTracks.length>0&&(n.subtitleTrack=-1);const a=()=>{const T=ar(i.state.subtitleFontSize,e.clientHeight||720),D=Math.max(0,Math.min(100,100-i.state.subtitlePosition)),L=()=>{const V=T*16,O=e.videoHeight||e.clientHeight||720,B=e.videoWidth||e.clientWidth||1280;return{step:V*1.3/O*100,chars:Math.max(20,Math.floor(B/(V*.55)))}},ee=(V,O)=>{const B=V;B.snapToLines=!1,B.line=O},y=V=>{if(!V.cues)return;Array.from(V.cues).forEach(ae=>ee(ae,D));const O=Array.from(V.activeCues??[]);if(O.length<=1){O.forEach(ae=>ee(ae,D));return}const{step:B,chars:N}=L();let Ee=D;for(let ae=O.length-1;ae>=0;ae--){const Ze=String(O[ae].text??"").replace(/<[^>]*>/g,"").split(`
|
|
3
3
|
`).reduce((yn,Kt)=>yn+Math.max(1,Math.ceil(Kt.length/N)),0);Ee=Math.max(0,Ee-Ze*B),ee(O[ae],Ee),Ee-=B*.4}},H=ce.current;if(H.length>0){H.forEach((V,O)=>{const B=V.track;if(!B)return;const N=O===me;B.mode=N&&!_e?"showing":"hidden",N&&!_e&&y(B)});return}const J=Array.from(e.textTracks);J.length!==0&&J.forEach((V,O)=>{const B=O===me;V.mode=B&&!_e?"showing":"hidden",B&&!_e&&y(V)})};a();const m=()=>a();e.textTracks.addEventListener("addtrack",m),e.addEventListener("loadedmetadata",a,{once:!0});const h=window.setTimeout(a,600);return()=>{e.textTracks.removeEventListener("addtrack",m),e.removeEventListener("loadedmetadata",a),window.clearTimeout(h)}},[me,ke,I,E,l,_e,i.state.subtitleFontSize,i.state.subtitlePosition]),b(()=>{if(!_e)return;const e=l.current,n=$t.current;if(!e||!n)return;const a=St/1e3,m=Nn/1e3,h=new Set;let T=[],D=-1,L=-1,ee=-1,y=-1,H=0,J=0,V=!1;const O=()=>{const q=yt.current;if(q<0)return null;const et=ce.current;return et.length>0?et[q]?.track??null:Array.from(e.textTracks)[q]??null},B=(q,et)=>{const pe=q.cues;if(!pe||pe.length===0)return Array.from(q.activeCues??[]);let ht=0,vt=pe.length;for(;ht<vt;){const xe=ht+vt>>>1;pe[xe].endTime+a<et?ht=xe+1:vt=xe}const Yt=[];for(let xe=ht;xe<pe.length;xe++){const Sn=pe[xe];if(Sn.startTime+a>et)break;Sn.endTime+a>=et&&Yt.push(Sn)}return Yt},N=()=>{const q=O(),et=e.currentTime-m,pe=q?B(q,et):[],ht=e.clientWidth,vt=e.clientHeight,Yt=e.videoWidth,xe=e.videoHeight;if(pe.length===T.length&&pe.every((Jn,Zn)=>Jn===T[Zn])&&ht===D&&vt===L&&Yt===ee&&xe===y||(T=pe,D=ht,L=vt,ee=Yt,y=xe,n.textContent="",pe.length===0))return;const Rr={fontSize:ar(i.state.subtitleFontSize,vt),position:i.state.subtitlePosition,bgOpacity:i.state.subtitleBgOpacity,bgColor:i.state.subtitleBgColor,textColor:i.state.subtitleTextColor,edge:i.state.subtitleEdge,bold:i.state.subtitleBold},Ts=to(Rr),ks=no(e,Rr.position);pe.forEach((Jn,Zn)=>{const Lr=String(Jn.text??"");if(!ro(Lr).trim())return;const er=document.createElement("div"),Es=(pe.length-1-Zn)*1.7;er.style.cssText=`${Ts}
|
|
4
4
|
bottom: calc(${ks}px + ${Es}em);`,er.innerHTML=so(Lr),n.appendChild(er)})},Ee=()=>{Array.from(e.textTracks).forEach(q=>{h.has(q)||(h.add(q),q.addEventListener("cuechange",N))})},ae=()=>{Ee(),N()},Xn=()=>{if(V||J)return;const q=()=>{J=0,!(V||e.paused||e.ended)&&(N(),Xn())};J=window.requestAnimationFrame(q)},Ze=e,yn=()=>{H=0,N(),!V&&Ze.requestVideoFrameCallback&&(H=Ze.requestVideoFrameCallback(yn))},Kt=()=>{N(),Ze.requestVideoFrameCallback?H||(H=Ze.requestVideoFrameCallback(yn)):Xn()};Ee(),e.textTracks.addEventListener("addtrack",ae),e.textTracks.addEventListener("removetrack",ae),e.addEventListener("timeupdate",N),e.addEventListener("seeked",N),e.addEventListener("loadedmetadata",N),e.addEventListener("play",Kt);const Pr=Array.from(e.querySelectorAll("track"));Pr.forEach(q=>q.addEventListener("load",N));const xr=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>N());return xr?.observe(e),N(),Kt(),()=>{V=!0,h.forEach(q=>q.removeEventListener("cuechange",N)),e.textTracks.removeEventListener("addtrack",ae),e.textTracks.removeEventListener("removetrack",ae),e.removeEventListener("timeupdate",N),e.removeEventListener("seeked",N),e.removeEventListener("loadedmetadata",N),e.removeEventListener("play",Kt),Pr.forEach(q=>q.removeEventListener("load",N)),xr?.disconnect(),J&&window.cancelAnimationFrame(J),H&&Ze.cancelVideoFrameCallback&&Ze.cancelVideoFrameCallback(H),n.textContent=""}},[_e,St,me,ke,Nn,l,i.state.subtitleFontSize,i.state.subtitlePosition,i.state.subtitleBgOpacity,i.state.subtitleBgColor,i.state.subtitleTextColor,i.state.subtitleEdge,i.state.subtitleBold]);const Gn=()=>{R(null),Y([]),He(""),x(-1)},Ss=_(e=>{c||(te(e),ye(1),Pe(e,1))},[Pe,c]),gn=!v&&r?.seasons&&r.seasons.length>1?t("label",{className:p.sidebarSeason,children:[t("span",{children:"Season"}),t("select",{disabled:c,value:u,onChange:e=>Ss(parseInt(e.currentTarget.value,10)||1),className:p.select,children:r.seasons.map(e=>t("option",{value:e.season_number,children:["Season ",e.season_number," (",e.episode_count," ep)"]},e.season_number))})]}):null,Tt=_(e=>{if(c)return;const n=parseInt(e,10);if(!isNaN(n)){try{l.current?.pause()}catch{}ye(n),Pe(u,n)}Dn(!1)},[u,Pe,l,c]);b(()=>{if(v)return;const e=n=>{n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="n"&&(P!=null?Tt(String(P)):Br.error("No next episode available"))};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[v,P,Tt]);const _s=e=>{It(e);try{const a=At[e];a&&$.setItem("tvLastAudio",nr(a))}catch{}const n=F.current;n&&n.audioTrack!==void 0&&(n.audioTrack=e)},Cs=e=>{De(e);try{if(e===-1)$.setItem("tvSubtitlesEnabled","false");else{$.setItem("tvSubtitlesEnabled","true"),$.setItem("tvSelectedSubtitle",String(e));const h=ke[e];h&&$.setItem("tvLastSubtitle",nr(h))}}catch{}const n=l.current,a=F.current;if(a&&typeof a.subtitleTrack=="number"&&Array.isArray(a.subtitleTracks)&&a.subtitleTracks.length>0&&(a.subtitleTrack=ce.current.length>0||e<0?-1:e),!n)return;const m=ce.current;if(m.length>0){m.forEach((h,T)=>{const D=h.track;if(!D)return;const L=T===e;D.mode=L&&!_e?"showing":"hidden"});return}Array.from(n.textTracks).forEach((h,T)=>{const D=T===e;h.mode=D&&!_e?"showing":"hidden"})};return b(()=>{if(!r){document.title="TV & Movies - dango";return}document.title=v?`${r.title} - dango`:`${r.title} - Season ${u} Episode ${S} - dango`},[r,v,u,S]),b(()=>{if(!r||v)return;const e=new URLSearchParams(f),n=e.get("s"),a=e.get("e"),m=String(u),h=String(S);n===m&&a===h||(e.set("type",f.get("type")||"tv"),e.set("s",m),e.set("e",h),x(`${window.location.pathname}?${e.toString()}`,{replace:!0}))},[r,v,u,S,f,x]),t("div",{className:`${Re.playerPageLayout} ${Fe?Re.theaterMode:""} ${v?Re.noSidebar:""}`,onClick:ns,children:[Fe&&t(oo,{videoRef:l,active:In.enabled&&!I&&W.length>0&&!$e&&!(r?.adult&&!Ot),settings:In}),!Fe&&!v&&t("aside",{className:Re.episodeSidebar,children:r?t(ao,{episodes:Ar,currentEpisode:String(S),watchedEpisodes:wr,onEpisodeClick:Tt,header:gn}):t(io,{variant:"sidebar"})}),t("div",{className:Re.playerMain,children:[r&&t("div",{className:p.playerSection,onContextMenu:e=>e.preventDefault(),style:r.adult&&!Ot?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:I&&ot&&!d?t("iframe",{src:ot,className:p.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!I&<&&!d?t("iframe",{src:lt,className:p.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!I&&(W.length>0||ue)?t(tt,{children:[$e&&t(Or,{error:$e,onRetry:bn}),t(Sa,{player:i,title:r.title,episodeLabel:v?void 0:`S${u} E${S}`,server:de||bt?.label||E,audioTracks:At,selectedAudioTrack:Te,onAudioTrackChange:_s,subtitles:ke,selectedSubtitle:me,onSubtitleChange:Cs,streams:W,resolutionIdx:we,onResolutionChange:e=>{jn(),ft(e);try{const n=W[e]?.quality;n&&$.setItem("tvLastQuality",n)}catch{}},onBack:Gn,videoDelayEnabled:en,onVideoDelayToggle:Tn,videoDelayMs:Oe,onVideoDelayChange:Dt,onCalibrateAvSync:d?void 0:Fr,subtitleDelayMs:St,onSubtitleDelayChange:qr,showNextEpisodeButton:!c&&Xr&&!Qe&&!dt,onNextEpisode:Wn,isLoading:ue,isTheaterMode:Fe,onTheaterModeToggle:Fn,ambientSettings:In,onAmbientChange:Kr,hideChrome:je||Ge,children:t(tt,{children:[t(Fs,{autoPlay:!d&&Ut&&!Ht,playsInline:!0,disablePictureInPicture:!0,className:`${p.video} ${An?p.videoHidden:""}`,onTimeUpdate:()=>{ve||(ms(),fn())},onEnded:()=>{ve||fn(!0)},onPlay:vs,onPause:ps,onSeeked:()=>{ve||(qt(),fn())},onLoadedMetadata:()=>{fs(),Cr(),fn()},onDurationChange:()=>{Cr()},onContextMenu:e=>e.preventDefault(),onError:()=>{se("Video failed to load. Try another server or reload."),Me(!1)}}),t("canvas",{ref:Zt,className:`${p.delayCanvas} ${An?p.delayCanvasActive:""}`}),_e&&t("div",{ref:$t,className:p.subtitleOverlay}),t(lo,{isOpen:kn,ms:Oe,onChange:Dt,onApply:Ur,onClose:Vr,testClipActive:ve,onTestClip:Wr}),(je||Ge)&&t("div",{className:p.watchedOverlay,children:[t(ie,{name:"check-circle",size:48,style:{color:"var(--accent-lighter)"}}),t("p",{className:p.watchedTitle,children:Ge||ct?G!=null?"Season Complete!":v?"Movie Completed!":"Show Completed!":v?"Movie watched":`S${u} E${S} watched`}),t("p",{className:p.watchedSubtext,children:Ge||ct?G!=null?`You finished Season ${u}.`:v?"You finished this movie!":"Congratulations! You finished all available episodes.":"Resume where you left off, replay from the beginning, or continue with the next episode."}),t("div",{className:`${p.watchedActions} ${Ge?p.watchedActionsCentered:""}`,children:[t("div",{children:Ie>5&&!Ge&&t(fe,{variant:ur?void 0:"secondary",onClick:Sr,children:`Resume ${jt(Ie)}`})}),t("div",{children:P!=null?t(fe,{onClick:Wn,children:`Watch EP ${P}`}):G!=null?t(fe,{onClick:Hn,children:`Start Season ${G}`}):null}),t("div",{children:[t(fe,{variant:"secondary",onClick:yr,children:"Replay"}),ct&&t(fe,{onClick:qn,disabled:qe.isPending||Ke.isPending,children:qe.isPending||Ke.isPending?"Saving...":"Move to Completed"})]})]})]})]})})]}):$e&&!I?t(Or,{error:$e,onRetry:bn}):null}),t(Lo,{playback:rn?{selection:rn,position:l.current?.currentTime||0,playing:!1,rate:i.engine.getState().playbackRate}:null,onCreate:()=>{En(),i.engine.pause()},needsPlayback:ir.needsPlayback,onEnablePlayback:ir.enablePlayback}),d&&!ue&&r&&!rn&&t("p",{role:"alert",children:"The host's direct HLS source is unavailable here. Retry or leave the room to use another source."}),!Fe&&r&&t(co,{}),!Fe&&gn&&t("div",{className:p.mobileSeasonRow,children:gn}),!Fe&&r&&t("div",{className:Z.streamPanel,children:[t("div",{className:p.providerRow,children:[t("label",{className:p.controlLabel,children:["Provider",t("select",{value:E,onChange:e=>ys(e.currentTarget.value),className:p.select,disabled:c||Q.length===0,children:wt?t("option",{value:"",children:"Loading..."}):Q.length===0?t("option",{value:"",children:"No providers available"}):t(tt,{children:[A.length>0&&t("optgroup",{label:"Direct HLS",children:A.map(e=>t("option",{value:e.id,children:e.label},e.id))}),re.length>0&&t("optgroup",{label:"Embeds",children:re.map(e=>t("option",{value:e.id,children:e.label},e.id))})]})})]}),!v&&ds(p.providerActions)]}),!c&&!I&&(ue?t("div",{className:p.sourceLoader,children:t("div",{className:p.ringSpinner})}):t(Ca,{servers:Jt,selectedServer:Lt?"Embed":K,onServerSelect:gs}))]}),!Fe&&r&&t("div",{className:Re.playerInfoContainer,children:[t("div",{className:Re.playerInfoHeader,children:[t("div",{className:Re.playerAnimeCard,children:r.poster&&t(Bs,{src:`https://image.tmdb.org/t/p/w342${r.poster}`,alt:r.title,loading:"lazy",decoding:"async"})}),t("div",{className:Re.videoTitleSection,children:[t("div",{className:Z.titleContainer,children:[t("h1",{children:r.title}),t("div",{className:p.meta,children:[t("span",{className:p.year,children:r.year}),r.vote_average!=null&&r.vote_average>0&&t("span",{className:p.rating,children:[t(ie,{name:"star",size:12}),Number(r.vote_average).toFixed(1)]}),t("span",{className:`${p.typeBadge} ${p[v?"movie":"tv"]}`,children:v?"Movie":"TV Show"})]}),Ir.length>0&&t("div",{className:p.genreRow,children:Ir.map(e=>t("span",{className:p.genreChip,children:e},e))}),Qn.length>0&&t("div",{className:p.metaRow,children:Qn.map((e,n)=>t("span",{children:[e,n<Qn.length-1?" · ":""]},`${e}-${n}`))})]}),t("div",{className:Z.controls,children:t("button",{className:`${Z.watchlistBtn} ${zt?Z.inList:""}`,onClick:Gr,disabled:jr,type:"button",children:[zt?t(ie,{name:"check",size:14}):t(ie,{name:"plus",size:14}),zt?"In Watchlist":"Add to Watchlist"]})})]})]}),t("div",{className:Re.infoColumns,children:[t("div",{className:`${Z.descriptionSection} ${Z.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t(Ro,{text:r.overview,emptyText:"No description available."}),t("button",{className:Z.detailsToggleBtn,onClick:()=>es(!cn),type:"button",children:[cn?t(ie,{name:"chevron-up"}):t(ie,{name:"chevron-down"}),cn?"Hide Details":"Show Details"]})]}),cn&&t("div",{className:p.detailGrid,children:[r.first_air_date&&t("div",{className:p.detailItem,children:[t("strong",{children:v?"Release Date":"First Air Date"}),t("span",{children:r.first_air_date})]}),r.last_air_date&&t("div",{className:p.detailItem,children:[t("strong",{children:"Last Air Date"}),t("span",{children:r.last_air_date})]}),r.networks&&r.networks.length>0&&t("div",{className:p.detailItem,children:[t("strong",{children:"Networks"}),t("span",{children:r.networks.map(e=>e.name).join(", ")})]}),r.created_by&&r.created_by.length>0&&t("div",{className:p.detailItem,children:[t("strong",{children:"Created By"}),t("span",{children:r.created_by.map(e=>e.name).join(", ")})]}),r.episode_run_time&&r.episode_run_time.length>0&&t("div",{className:p.detailItem,children:[t("strong",{children:"Episode Runtime"}),t("span",{children:[r.episode_run_time[0]," min"]})]}),r.imdb_id&&t("div",{className:p.detailItem,children:[t("strong",{children:"IMDb"}),t("a",{href:`https://www.imdb.com/title/${r.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:p.imdbLink,children:"View on IMDb"})]})]})]})]}),!v&&t(uo,{isOpen:ts,onClose:()=>Dn(!1),episodes:Ar,currentEpisode:String(S),watchedEpisodes:wr,onEpisodeClick:Tt,header:gn}),r?.adult&&!Ot&&t(bo,{isOpen:!0,onClose:Gn,onGrant:Yr}),t(mo,{isOpen:!d&&Qe&&!Ln&&an.current===`${j}:${u}:${S}`&&Ye?.completed!==1&&!Qt(Ie,Ye?.duration??0),onClose:Tr,title:"Resume Watching",message:t(tt,{children:["You were at ",t("strong",{children:jt(_t)})]}),restartLabel:"Start from Beginning",onResume:bs,onRestart:Tr}),t(Mr,{isOpen:mt,onClose:()=>br(!0),title:ct?v?"Movie Completed!":"Show Completed!":"Episode Completed",heading:v?r?.title??"Movie":`S${u} E${S}`,message:ct?v?"You finished this movie!":"Congratulations! You finished all available episodes.":v?"You've already watched this movie. Resume where you left off or replay it.":"You've already watched this episode. Resume where you left off, replay it, or continue with the next episode.",children:[Ie>5&&t(fe,{variant:ur?void 0:"secondary",onClick:Sr,children:`Resume ${jt(Ie)}`}),t(fe,{variant:"secondary",onClick:yr,children:"Replay"}),P!=null?t(fe,{onClick:Wn,children:["Watch EP ",P]}):G!=null?t(fe,{onClick:Hn,children:["Start Season ",G]}):ct?t(fe,{onClick:qn,disabled:qe.isPending||Ke.isPending,children:qe.isPending||Ke.isPending?"Saving...":"Move to Completed"}):null]}),t(Mr,{isOpen:as,onClose:()=>ut(!1),title:v?"Movie Completed!":G!=null?"Season Complete!":"Show Completed!",heading:Jr,message:v?"You finished this movie!":G!=null?`You finished Season ${u}.`:"Congratulations! You finished all available episodes.",children:G!=null?t(fe,{onClick:Hn,children:["Start Season ",G]}):t(tt,{children:[t(fe,{onClick:()=>{ut(!1),Gn()},children:"Back to Details"}),t(fe,{onClick:qn,disabled:qe.isPending||Ke.isPending,children:qe.isPending||Ke.isPending?"Saving...":"Move to Completed"})]})}),!r&&t("div",{className:p.statusMsg,children:[t(ie,{name:"spinner",className:p.spinner})," Loading..."]})]})]})};export{Ai as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as R,a as q,p as E,d as l,h as C,T,u as e,g as F}from"./vendor-core-DfaOB3Rn.js";import{I as a}from"./vendor-icons-
|
|
1
|
+
import{o as R,a as q,p as E,d as l,h as C,T,u as e,g as F}from"./vendor-core-DfaOB3Rn.js";import{I as a}from"./vendor-icons-C1Pj_eSX.js";import{aj as j,e as U,ak as H,t as J,B as w,a8 as K,i as I}from"./index-BVkDKnzf.js";import{c as Q,d as X}from"./useTvLibrary-DqLFBTa7.js";import"./vendor-query-BBT5_sHx.js";import"./libraryInvalidation-ar7SX0CJ.js";const Y="_container_198yg_1",Z="_heroSection_198yg_11",ee="_bannerContainer_198yg_17",ne="_banner_198yg_17",te="_bannerOverlay_198yg_37",se="_heroContent_198yg_49",ae="_posterContainer_198yg_62",oe="_poster_198yg_62",ie="_infoGlass_198yg_86",re="_title_198yg_100",le="_quickMeta_198yg_110",ce="_metaItem_198yg_118",de="_iconStar_198yg_126",me="_iconTv_198yg_130",_e="_iconType_198yg_134",he="_genres_198yg_139",ge="_genre_198yg_139",ve="_metaRow_198yg_156",pe="_metaValue_198yg_164",ue="_metaDivider_198yg_168",ye="_synopsisSection_198yg_173",ke="_sectionTitleSmall_198yg_179",be="_synopsis_198yg_173",Ne="_actions_198yg_196",Se="_watchBtn_198yg_202",fe="_watchlistBtn_198yg_226",Ce="_active_198yg_250",Te="_seasonPickerLabel_198yg_256",we="_seasonSelect_198yg_267",Ie="_detailsToggleBtn_198yg_286",Be="_expandedContent_198yg_304",De="_detailGrid_198yg_309",Me="_detailItem_198yg_315",Le="_imdbLink_198yg_333",Pe="_heroSkeleton_198yg_343",$e="_skeletonBanner_198yg_347",Ge="_skeletonContent_198yg_354",xe="_skeletonPoster_198yg_365",Oe="_skeletonInfo_198yg_373",Ae="_skeletonTitle_198yg_380",Ve="_skeletonMeta_198yg_388",We="_skeletonDesc_198yg_396",ze="_skeletonActions_198yg_404",Re="_errorState_198yg_413",qe="_matureOverlay_198yg_434",Ee="_matureContent_198yg_444",n={container:Y,heroSection:Z,bannerContainer:ee,banner:ne,bannerOverlay:te,heroContent:se,posterContainer:ae,poster:oe,infoGlass:ie,title:re,quickMeta:le,metaItem:ce,iconStar:de,iconTv:me,iconType:_e,genres:he,genre:ge,metaRow:ve,metaValue:pe,metaDivider:ue,synopsisSection:ye,sectionTitleSmall:ke,synopsis:be,actions:Ne,watchBtn:Se,watchlistBtn:fe,active:Ce,seasonPickerLabel:Te,seasonSelect:we,detailsToggleBtn:Ie,expandedContent:Be,detailGrid:De,detailItem:Me,imdbLink:Le,heroSkeleton:Pe,skeletonBanner:$e,skeletonContent:Ge,skeletonPoster:xe,skeletonInfo:Oe,skeletonTitle:Ae,skeletonMeta:Ve,skeletonDesc:We,skeletonActions:ze,errorState:Re,matureOverlay:qe,matureContent:Ee};function Qe(){const{id:o}=R(),c=q(),[B]=E(),i=j(B.get("type")),{hasConsent:D}=U(),[t,M]=l(null),[L,_]=l(!0),[u,y]=l(""),[d,P]=l(!1),[h,$]=l(1),G=H(i,o??""),x=Number(o),{data:O}=Q(t?G:void 0),g=!!O?.inLibrary,{toggle:A}=X();C(()=>{o&&(_(!0),y(""),J.tv.details.query({type:i,id:String(o)}).then(s=>{const m={id:s.id,title:s.title||"",overview:s.overview||"",vote_average:s.vote_average,year:s.year,poster:s.poster,backdrop:s.backdrop,imdb_id:s.imdb_id||void 0,adult:s.adult,seasons:s.seasons?.map(z=>({...z,name:""})),number_of_seasons:s.number_of_seasons};M(m),_(!1)}).catch(s=>{y(s.message),_(!1)}))},[o,i]),C(()=>{document.title=t?.title?`${t.title} - dango`:"TV & Movies - dango"},[t?.title]);const V=()=>{!o||!t||c(r?I(i,o):I(i,o,h,1))},W=()=>{t&&A({tmdbId:x,mediaType:i,title:t.title,poster:t.poster,year:t.year,adult:t.adult})},r=i==="movie",v=!r,k=t?.backdrop?`https://image.tmdb.org/t/p/w1280${t.backdrop}`:"",b=t?.poster?`https://image.tmdb.org/t/p/w500${t.poster}`:"",N=T(()=>t?.genres?t.genres.map(s=>s.name).slice(0,5):[],[t?.genres]),S=T(()=>t?.seasons?t.seasons.filter(s=>s.season_number>0):[],[t?.seasons]),p=[t?.year,t?.status,v&&t?.number_of_seasons?`${t.number_of_seasons} Season${t.number_of_seasons>1?"s":""}`:null,v&&t?.number_of_episodes?`${t.number_of_episodes} Episodes`:null].filter(Boolean);if(L)return e("div",{className:n.container,children:e("div",{className:n.heroSkeleton,children:[e("div",{className:n.skeletonBanner}),e("div",{className:n.skeletonContent,children:[e("div",{className:n.skeletonPoster}),e("div",{className:n.skeletonInfo,children:[e("div",{className:n.skeletonTitle}),e("div",{className:n.skeletonMeta}),e("div",{className:n.skeletonDesc}),e("div",{className:n.skeletonActions})]})]})]})});if(u||!t)return e("div",{className:n.container,children:e("div",{className:n.errorState,children:[e(a,{name:"exclamation-triangle",size:48}),e("h2",{children:"Failed to load details"}),e("p",{children:u||"Something went wrong"}),e(w,{onClick:()=>c(-1),children:"Go Back"})]})});const f=t.adult&&!D;return e("div",{className:n.container,style:f?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:[e("div",{className:n.heroSection,children:[e("div",{className:n.bannerContainer,children:[k&&e("div",{className:n.banner,style:{backgroundImage:`url(${k})`}}),e("div",{className:n.bannerOverlay})]}),e("div",{className:n.heroContent,children:[e("div",{className:n.posterContainer,children:b&&e(K,{src:b,alt:t.title,className:n.poster,decoding:"async"})}),e("div",{className:n.infoGlass,children:[e("div",{children:[e("h1",{className:n.title,children:t.title}),e("div",{className:n.quickMeta,children:[t.vote_average!=null&&t.vote_average>0&&e("div",{className:n.metaItem,children:[e(a,{name:"star",className:n.iconStar}),e("span",{children:Number(t.vote_average).toFixed(1)})]}),e("div",{className:n.metaItem,children:[e(a,{name:"tv",className:n.iconTv}),e("span",{children:r?"Movie":"TV Show"})]}),t.vote_count!=null&&e("div",{className:n.metaItem,children:[e(a,{name:"users",className:n.iconType}),e("span",{children:[t.vote_count.toLocaleString()," votes"]})]})]}),N.length>0&&e("div",{className:n.genres,children:N.map(s=>e("span",{className:n.genre,children:s},s))})]}),p.length>0&&e("div",{className:n.metaRow,children:p.map((s,m)=>e(F.Fragment,{children:[e("span",{className:n.metaValue,children:s}),m<p.length-1&&e("span",{className:n.metaDivider,children:"·"})]},m))}),t.overview&&e("div",{className:n.synopsisSection,children:[e("h2",{className:n.sectionTitleSmall,children:"Synopsis"}),e("p",{className:n.synopsis,children:t.overview})]}),e("div",{className:n.actions,children:[e("button",{className:n.watchBtn,onClick:V,children:[e(a,{name:"play",size:14}),r?"Watch Now":`Start S${h}`]}),e("button",{className:`${n.watchlistBtn} ${g?n.active:""}`,onClick:W,children:[g?e(a,{name:"check",size:14}):e(a,{name:"plus",size:14}),g?"In Watchlist":"Add to Watchlist"]})]}),v&&S.length>1&&e("label",{className:n.seasonPickerLabel,children:[e("span",{children:"Season"}),e("select",{value:h,onChange:s=>$(parseInt(s.currentTarget.value,10)||1),className:n.seasonSelect,children:S.map(s=>e("option",{value:s.season_number,children:["Season ",s.season_number," (",s.episode_count," Episodes)"]},s.season_number))})]}),e("button",{className:n.detailsToggleBtn,onClick:()=>P(!d),children:[d?e(a,{name:"chevron-up"}):e(a,{name:"chevron-down"}),d?"Hide Details":"Show Details"]}),d&&e("div",{className:n.expandedContent,children:e("div",{className:n.detailGrid,children:[t.first_air_date&&e("div",{className:n.detailItem,children:[e("strong",{children:r?"Release Date":"First Air Date"}),e("span",{children:t.first_air_date})]}),t.last_air_date&&e("div",{className:n.detailItem,children:[e("strong",{children:"Last Air Date"}),e("span",{children:t.last_air_date})]}),t.networks&&t.networks.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Networks"}),e("span",{children:t.networks.map(s=>s.name).join(", ")})]}),t.created_by&&t.created_by.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Created By"}),e("span",{children:t.created_by.map(s=>s.name).join(", ")})]}),t.episode_run_time&&t.episode_run_time.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Episode Runtime"}),e("span",{children:[t.episode_run_time[0]," min"]})]}),t.imdb_id&&e("div",{className:n.detailItem,children:[e("strong",{children:"IMDb"}),e("a",{href:`https://www.imdb.com/title/${t.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:n.imdbLink,children:"View on IMDb"})]})]})})]})]})]}),f&&e("div",{className:n.matureOverlay,children:e("div",{className:n.matureContent,children:[e(a,{name:"exclamation-triangle",size:48}),e("h2",{children:"Content Warning"}),e("p",{children:"This content may contain mature themes."}),e(w,{onClick:()=>c("/"),children:"Go Back"})]})})]})}export{Qe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as n,h as b,T as k,u as T}from"./vendor-core-DfaOB3Rn.js";import{ak as _,t as m,k as w,i as I,l as P}from"./index-
|
|
1
|
+
import{d as n,h as b,T as k,u as T}from"./vendor-core-DfaOB3Rn.js";import{ak as _,t as m,k as w,i as I,l as P}from"./index-BVkDKnzf.js";import{d as D}from"./useTvLibrary-DqLFBTa7.js";import{a as W}from"./MediaCard-CeCsiCpy.js";const S=({item:e,anchorRect:l,onMouseEnter:i,onMouseLeave:c,onRequestClose:p})=>{const[a,u]=n(null),[d,r]=n(!0),{toggle:v,bookmarkedIds:g}=D(),y=_(e.type,e.id),f=g.has(y);b(()=>{let o=!1;return r(!0),m.tv.details.query({type:e.type,id:String(e.id)}).then(s=>{o||(u({overview:s.overview,vote_average:s.vote_average,number_of_seasons:s.number_of_seasons}),r(!1))}).catch(()=>{o||r(!1)}),()=>{o=!0}},[e.id,e.type]);const h=k(()=>a?.genres?a.genres.slice(0,4).map(o=>o.name):[],[a?.genres]),t=[];return a?.vote_average!=null&&a.vote_average>0&&t.push({icon:"star",label:Number(a.vote_average).toFixed(1),accent:!0}),t.push({icon:"tv",label:e.type==="tv"?"TV Show":"Movie"}),e.year&&t.push({label:e.year}),a?.status&&t.push({label:a.status}),T(W,{anchorRect:l,title:e.title,loading:d,meta:t,genres:h,synopsis:P(a?.overview,200),primaryAction:{to:I(e.type,e.id),label:"Watch now",icon:"play"},secondaryAction:{to:w(e.type,e.id),label:"Details",icon:"info-circle"},bookmarked:f,onToggleBookmark:()=>v({tmdbId:e.id,mediaType:e.type,title:e.title,poster:e.image,year:e.year}),onMouseEnter:i,onMouseLeave:c,onRequestClose:p})};export{S as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as I,p as ae,A as re,d as o,T as Y,q as M,u as t}from"./vendor-core-DfaOB3Rn.js";import{I as h}from"./vendor-icons-
|
|
1
|
+
import{h as I,p as ae,A as re,d as o,T as Y,q as M,u as t}from"./vendor-core-DfaOB3Rn.js";import{I as h}from"./vendor-icons-C1Pj_eSX.js";import{P as D}from"./MediaCard-CeCsiCpy.js";import{a as ne,T as se}from"./useTv-ChpwVixu.js";import{S as le}from"./SkeletonGrid-B3ip19ry.js";import{u as ie,T as W,M as Q,aa as oe,B as x}from"./index-BVkDKnzf.js";import{E as ce}from"./ErrorMessage-hMt90aG4.js";import{s as r}from"./Search.module-C_qwCdHS.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-CC0bqpsd.js";import"./TvPopup-DRGj0Mk8.js";import"./useTvLibrary-DqLFBTa7.js";import"./vendor-query-BBT5_sHx.js";import"./libraryInvalidation-ar7SX0CJ.js";const de=[{value:"multi",label:"All"},{value:"tv",label:"TV Shows"},{value:"movie",label:"Movies"}],ue=[{value:"popularity.desc",label:"Popularity"},{value:"vote_average.desc",label:"Top Rated"},{value:"primary_release_date.desc",label:"Newest"},{value:"primary_release_date.asc",label:"Oldest"},{value:"vote_count.desc",label:"Most Voted"}],O=new Date().getFullYear(),me=[{value:"ALL",label:"All Years"},...Array.from({length:O-1980+1},(l,m)=>({value:String(O-m),label:String(O-m)}))];function _e(){I(()=>{document.title="Search TV & Movies - dango"},[]);const[l,m]=ae(),{lowEndMode:K}=ie(),C=re(null),[g,H]=o(l.get("q")||""),[p,U]=o(l.get("q")||""),[u,v]=o(parseInt(l.get("page")||"1",10)||1),[i,J]=o(l.get("type")||"multi"),[$,k]=o(l.get("genre")||""),[y,B]=o(l.get("year")||"ALL"),[f,E]=o(l.get("sort_by")||"popularity.desc"),[b,X]=o(!1),[c,N]=o(()=>{const e={},a=l.get("genre")||"";return a&&(e[a]="include"),e}),P=Y(()=>{if(i==="tv")return Object.entries(W).map(([a,n])=>({id:a,name:n}));if(i==="movie")return Object.entries(Q).map(([a,n])=>({id:a,name:n}));const e=new Map;for(const[a,n]of Object.entries(W))e.set(a,n);for(const[a,n]of Object.entries(Q))e.set(a,n);return Array.from(e.entries()).map(([a,n])=>({id:a,name:n}))},[i]),S=Y(()=>Object.entries(c).filter(([,a])=>a==="include").map(([a])=>a).join(","),[c]),{data:L,isLoading:w,isError:Z,error:ee}=ne({query:p,type:i,genre:S,year:y,sort_by:f,page:u}),T=L?.results||[],_=L?.total_pages||0,j=L?.total_results||0,R=u<Math.min(_,500),d=M((e={})=>{const a=new URLSearchParams,n=e.q!==void 0?e.q:p,s=e.type!==void 0?e.type:i,G=e.year!==void 0?e.year:y,V=e.sort!==void 0?e.sort:f,F=e.page!==void 0?e.page:String(u),z=e.genre!==void 0?e.genre:S;n.trim()&&a.set("q",n.trim()),s!=="multi"&&a.set("type",s),z&&a.set("genre",z),G!=="ALL"&&a.set("year",G),V!=="popularity.desc"&&a.set("sort_by",V),F!=="1"&&a.set("page",F),m(a,{replace:!0})},[p,i,y,f,u,S,m]),A=M(()=>{oe(),v(1),U(g),d({q:g,page:"1"}),window.scrollTo({top:0,behavior:"smooth"})},[g,d]),q=M(e=>{if(v(e),d({page:String(e)}),C.current){const a=C.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:a,behavior:"smooth"})}},[d]),te=M(e=>{N(a=>{const n=a[e],s={...a};return n==="include"?s[e]="exclude":n==="exclude"?delete s[e]:s[e]="include",s}),v(1)},[]);return I(()=>{const a=Object.entries(c).filter(([,n])=>n==="include").map(([n])=>n).join(",");a!==$&&(k(a),d({genre:a,page:"1"}))},[c,$,k,d]),t("div",{className:"page-container",children:[t("div",{className:r.header,children:[t("h1",{className:r.pageTitle,children:"Search TV & Movies"}),t("p",{className:r.pageSubtitle,children:"Discover trending shows, movies, and more powered by TMDB"})]}),t("div",{className:r.filterContainer,children:[t("div",{className:r.searchBarWrapper,children:[t("div",{className:r.inputIconWrapper,children:[t(h,{name:"search",className:r.searchIcon}),t("input",{type:"text","data-virtual-keyboard":"true",className:r.searchInput,placeholder:"Search titles...",value:g,onInput:e=>H(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&A()})]}),t("div",{className:r.searchActions,children:[t("select",{value:i,onChange:e=>{J(e.currentTarget.value),N({})},className:r.providerSelect,"aria-label":"Media type",children:de.map(e=>t("option",{value:e.value,children:e.label},e.value))}),t(x,{onClick:A,className:r.searchBtn,children:"Search"}),t("button",{className:`${r.filterToggleBtn} ${b?r.active:""}`,onClick:()=>X(!b),children:[t(h,{name:"filter",size:14}),t("span",{children:"Filters"}),b?t(h,{name:"chevron-up",size:12}):t(h,{name:"chevron-down",size:12})]})]})]}),t("div",{className:`${r.advancedFilters} ${b?r.show:""}`,children:[t("div",{className:r.filterDivider}),t("div",{className:r.filterGrid,children:[t("div",{className:r.filterItem,children:[t("label",{children:"Sort By"}),t("select",{value:f,onChange:e=>E(e.currentTarget.value),children:ue.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:r.filterItem,children:[t("label",{children:"Year"}),t("select",{value:y,onChange:e=>B(e.currentTarget.value),children:me.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),P.length>0&&t("div",{className:r.genreSection,children:[t("label",{className:r.genreLabel,children:"Genres"}),t("div",{className:r.genreContainer,children:P.map(e=>t("button",{className:`${r.genreButton} ${r[c[e.id]||""]}`,onClick:()=>te(e.id),children:e.name},e.id))})]}),t("div",{className:r.filterActions,children:[t(x,{variant:"secondary",onClick:()=>{N({}),B("ALL"),E("popularity.desc"),v(1),d({genre:"",year:"ALL",sort:"popularity.desc",page:"1"})},children:"Reset All"}),t(x,{onClick:A,className:r.searchBtn,children:"Apply Filters"})]})]})]}),Z&&t(ce,{message:ee?.message||"Search failed"}),Object.keys(c).length>0&&t("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"1.5rem"},children:[t("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontWeight:600},children:"Active Filters:"}),Object.entries(c).map(([e,a])=>{const n=P.find(s=>s.id===e)?.name||e;return t("span",{className:`badge ${a==="include"?"badge-primary":"badge-danger"}`,style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[a==="include"?`+ ${n}`:`- ${n}`,t("button",{onClick:()=>{const s={...c};delete s[e],N(s)},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]},e)})]}),t("div",{className:r.resultsHeader,ref:C,children:[t("h2",{className:r.resultsTitle,children:[p?`Results for "${p}"`:S?"Browsing genres":i==="tv"?"Popular TV Shows":i==="movie"?"Popular Movies":"Trending",j>0&&t("span",{style:{fontWeight:400,color:"var(--text-tertiary)",fontSize:"0.85em",marginLeft:"0.5em"},children:["(",j.toLocaleString(),")"]})]}),T.length>0&&t(D,{page:u,totalPages:Math.max(1,Math.min(_,500)),canGoNext:R,onChange:q,isLoading:w})]}),t("div",{className:`${r.resultsGrid} ${K?r.lowEnd:""}`,children:w?t(le,{}):T.map(e=>t(se,{item:{id:e.id,title:e.title,year:e.year,type:e.type,image:e.image,vote_average:e.vote_average,adult:e.adult}},`${e.type}-${e.id}`))}),!w&&T.length===0&&t("div",{className:r.noResults,children:[t(h,{name:"search",size:48,className:r.noResultsIcon}),t("h3",{children:"No results found"}),t("p",{children:"Try adjusting your search or filters to find what you're looking for."})]}),T.length>0&&t("div",{className:r.bottomPagination,children:t(D,{page:u,totalPages:Math.max(1,Math.min(_,500)),canGoNext:R,onChange:q,isLoading:w,variant:"labeled"})})]})}export{_e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as $,d as f,h as L,T as U,u as d}from"./vendor-core-DfaOB3Rn.js";import{M as x}from"./MediaCard-
|
|
1
|
+
import{o as $,d as f,h as L,T as U,u as d}from"./vendor-core-DfaOB3Rn.js";import{M as x}from"./MediaCard-CeCsiCpy.js";import{L as F}from"./LibraryListPage-D-SFU6Ob.js";import{R as N}from"./ResetProgressModal-2EZzznJV.js";import{T as _}from"./TvPopup-DRGj0Mk8.js";import{i as y,h as u,j as R}from"./index-BVkDKnzf.js";import{j,u as K,a as O,b as Q,f as Y,k as q,l as z,m as G,T as I}from"./useTvLibrary-DqLFBTa7.js";import"./vendor-icons-C1Pj_eSX.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-CC0bqpsd.js";import"./SkeletonGrid-B3ip19ry.js";import"./ErrorMessage-hMt90aG4.js";import"./LibraryListPage.module-r6k9nyT9.js";import"./vendor-query-BBT5_sHx.js";import"./libraryInvalidation-ar7SX0CJ.js";const Z=["All","Continue Watching",...I],S=24;function ct(){const{filter:l="All"}=$(),[c,m]=f(1),[s,v]=f(null);L(()=>{document.title="TV Watchlist - dango"},[]),L(()=>{m(1)},[l]);const o=l==="Continue Watching",r=j(o?"All":l,c,S),i=K(100),T=O(),P=Q(),k=Y(),w=q(),C=z(),B=G(),M=U(()=>o?(i.data?.data??[]).map(t=>{const a=t.currentTime??0,e=t.duration??0,g=t.season??1,h=t.episode??1,n=t.mediaType==="movie",p=n?"Movie":`S${g} E${h}`,b=t.completed===1||e>0&&a>=e*.8;return{key:t.id,libId:t.id,tmdbId:t.tmdbId??0,mediaType:t.mediaType,title:t.title||"",poster:t.poster||"",year:t.year,adult:R({adult:t.adult===1}),status:t.watchlistStatus??"",badge:p,progressPercent:b?100:e>0?a/e*100:0,progressLabel:e>0?b?"Watched":n?`${u(a)} / ${u(e)}`:`${p} · ${u(a)} / ${u(e)}`:p,watchTarget:y(t.mediaType,t.tmdbId??0,n?void 0:g,n?void 0:h)}}):(r.data?.data??[]).map(t=>({key:t.id,libId:t.id,tmdbId:t.tmdbId,mediaType:t.mediaType,title:t.title,poster:t.poster||"",year:t.year,adult:R({adult:t.adult===1}),status:t.status,badge:t.lastSeason&&t.lastEpisode?`S${t.lastSeason} E${t.lastEpisode}`:void 0,progressPercent:void 0,progressLabel:void 0,watchTarget:y(t.mediaType,t.tmdbId,t.lastSeason??void 0,t.lastEpisode??void 0)})),[o,i.data,r.data]),W=o?i.data?.total??0:r.data?.total??0,E=o?i.isLoading:r.isLoading,A=o?i.error:r.error,V=t=>{s&&(P.mutate({mediaId:s.libId}),t&&T.mutate(s.libId))};return d(F,{headerTitle:"My TV Watchlist",headerSubtitle:"Track and manage your movies and shows",filters:Z,filterBy:l,filterBasePath:"/tv-watchlist",continueFilter:"Continue Watching",statusOptions:[...I],entries:M,total:W,isLoading:E,error:A,page:c,pageSize:S,onPageChange:m,emptyTitle:"Your TV watchlist is looking a bit empty",emptyFilteredText:"No titles match this filter.",emptyAllText:"Let's find something to watch!",browseLabel:"Browse TV & Movies",browseTarget:"/tv",removeListLabel:"Remove from TV Watchlist",listNoun:"TV watchlist",skipConfirmKey:"tvSkipRemoveConfirmation",onBulkStatus:(t,a)=>w.mutate({ids:t,status:a}),onBulkRemove:t=>{o?B.mutate(t):C.mutate(t)},onStatusChange:(t,a)=>k.mutate({id:t,status:a}),onRemoveItem:t=>T.mutate(t),renderCard:t=>d(x,{item:{id:t.libId,title:t.title,thumbnail:t.poster,typeBadge:t.mediaType==="movie"?"Movie":"TV",chapterBadge:t.badge??null,isAdult:t.adult},linkTo:t.watchTarget,hoverIcon:"play",progress:t.progressPercent!==void 0&&t.progressLabel?{percent:t.progressPercent,label:t.progressLabel}:void 0,showProgress:o,metaRow:t.year?d("span",{style:{opacity:.75},children:t.year}):void 0,onRemove:o?()=>v(t):void 0,renderPopup:(a,e)=>d(_,{item:{id:t.tmdbId??0,title:t.title||"",year:t.year||"",type:t.mediaType||"tv",image:t.poster||""},anchorRect:a,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,onRequestClose:e.close})}),modals:d(N,{isOpen:!!s,itemName:s?.title,progressKind:"watch",listLabel:"my TV watchlist",onClose:()=>{v(null)},onConfirm:V})})}export{ct as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as w,A as E,h as v,q as N,$ as D,u as o}from"./vendor-core-DfaOB3Rn.js";import{p as x}from"./index-
|
|
1
|
+
import{d as w,A as E,h as v,q as N,$ as D,u as o}from"./vendor-core-DfaOB3Rn.js";import{p as x}from"./index-BVkDKnzf.js";import"./vendor-query-BBT5_sHx.js";import"./vendor-icons-C1Pj_eSX.js";const O="_keyboard_1l8yf_1",R="_small_1l8yf_18",T="_medium_1l8yf_25",q="_large_1l8yf_32",U="_topBar_1l8yf_39",V="_dragHandle_1l8yf_48",W="_grip_1l8yf_59",X="_topButton_1l8yf_67",Y="_key_1l8yf_1",j="_closeButton_1l8yf_98",A="_keys_1l8yf_104",F="_row_1l8yf_111",J="_wideKey_1l8yf_132",P="_spaceKey_1l8yf_136",G="_spaceIcon_1l8yf_144",Q="_activeKey_1l8yf_153",t={keyboard:O,small:R,medium:T,large:q,topBar:U,dragHandle:V,grip:W,topButton:X,key:Y,closeButton:j,keys:A,row:F,wideKey:J,spaceKey:P,spaceIcon:G,activeKey:Q},$="virtual-keyboard-state",b=["small","medium","large"],Z=["1","2","3","4","5","6","7","8","9","0"],ee=["!","@","#","$","%","^","&","*","(",")"],te=[["q","w","e","r","t","y","u","i","o","p"],["a","s","d","f","g","h","j","k","l"],["z","x","c","v","b","n","m"]],ne=()=>{const i={position:{x:Math.max(12,window.innerWidth-690),y:Math.max(90,window.innerHeight-330)},size:"medium"};try{const c=x.getItem($);if(!c)return i;const s=JSON.parse(c);return{position:s.position&&Number.isFinite(s.position.x)&&Number.isFinite(s.position.y)?s.position:i.position,size:s.size&&b.includes(s.size)?s.size:i.size}}catch{return i}},K=(i,c)=>{const s=c?.offsetWidth??650,r=c?.offsetHeight??270;return{x:Math.min(Math.max(8,i.x),Math.max(8,window.innerWidth-s-8)),y:Math.min(Math.max(8,i.y),Math.max(8,window.innerHeight-r-8))}};function re({activeInputRef:i,isVisible:c,onClose:s}){const[{position:r,size:l},h]=w(ne),[k,z]=w(!1),[g,S]=w(!1),f=E(null),u=E(null);v(()=>{x.setItem($,JSON.stringify({position:r,size:l}))},[r,l]),v(()=>{const e=()=>{h(n=>({...n,position:K(n.position,f.current)}))};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const _=()=>i.current&&document.contains(i.current)?i.current:document.activeElement instanceof HTMLInputElement?document.activeElement:null,d=e=>{const n=_();if(!n)return;const a=n.selectionStart??n.value.length,p=n.selectionEnd??n.value.length;n.setRangeText(e,a,p,"end"),n.dispatchEvent(new Event("input",{bubbles:!0})),n.focus()},M=()=>{const e=_();if(!e)return;const n=e.selectionStart??e.value.length,a=e.selectionEnd??e.value.length;n===a&&n===0||(e.setRangeText("",n===a?n-1:n,a,"end"),e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus())},B=()=>{const e=_();if(!e){s();return}const n=e.form;n?n.requestSubmit():e.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0})),s()},C=e=>{e.preventDefault()},y=N(e=>{if(!u.current)return;const n={x:e.clientX-u.current.x,y:e.clientY-u.current.y};h(a=>({...a,position:K(n,f.current)}))},[]),m=N(()=>{u.current=null,window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",m)},[y]),L=e=>{e.preventDefault(),u.current={x:e.clientX-r.x,y:e.clientY-r.y},window.addEventListener("mousemove",y),window.addEventListener("mouseup",m)};if(v(()=>()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",m)},[y,m]),!c)return null;const H=g?ee:Z,I=()=>{h(e=>{const n=b[(b.indexOf(e.size)+1)%b.length];return{...e,size:n}})};return D(o("div",{ref:f,className:`${t.keyboard} ${t[l]}`,style:{left:r.x,top:r.y},onMouseDown:C,"data-virtual-keyboard-root":!0,children:[o("div",{className:t.topBar,children:[o("div",{className:t.dragHandle,onMouseDown:L,"aria-label":"Move virtual keyboard",children:[o("span",{className:t.grip,"aria-hidden":"true"}),o("span",{children:"Virtual Keyboard"})]}),o("button",{type:"button",className:t.topButton,onClick:I,children:["Size: ",l[0].toUpperCase()+l.slice(1)]}),o("button",{type:"button",className:`${t.topButton} ${t.closeButton}`,onClick:s,children:"X"})]}),o("div",{className:t.keys,children:[o("div",{className:t.row,children:[H.map(e=>o("button",{type:"button",className:t.key,onClick:()=>d(e),children:e},e)),o("button",{type:"button",className:`${t.key} ${t.wideKey}`,onClick:M,"aria-label":"Backspace",children:"⟵"})]}),te.map((e,n)=>o("div",{className:t.row,children:[e.map(a=>{const p=k?a.toUpperCase():a;return o("button",{type:"button",className:t.key,onClick:()=>d(p),children:p},a)}),n===1&&o("button",{type:"button",className:`${t.key} ${t.wideKey}`,onClick:B,children:"Enter"})]},e.join(""))),o("div",{className:t.row,children:[o("button",{type:"button",className:`${t.key} ${t.wideKey} ${g?t.activeKey:""}`,onClick:()=>S(e=>!e),children:"Ctrl"}),o("button",{type:"button",className:`${t.key} ${t.wideKey} ${k?t.activeKey:""}`,onClick:()=>z(e=>!e),children:"Shift"}),o("button",{type:"button",className:`${t.key} ${t.spaceKey}`,onClick:()=>d(" "),"aria-label":"Space",children:o("span",{className:t.spaceIcon})}),o("button",{type:"button",className:t.key,onClick:()=>d("."),children:"."}),o("button",{type:"button",className:t.key,onClick:()=>d("-"),children:"-"})]})]})]}),document.body)}export{re as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as h,d as s,u as e}from"./vendor-core-DfaOB3Rn.js";import{a6 as d,B as m}from"./index-
|
|
1
|
+
import{c as h,d as s,u as e}from"./vendor-core-DfaOB3Rn.js";import{a6 as d,B as m}from"./index-BVkDKnzf.js";import{W as u,s as p,a as g}from"./WatchAlongPanel-C2JcUz-e.js";import"./vendor-query-BBT5_sHx.js";import"./vendor-icons-C1Pj_eSX.js";function b(){const o=d(),c=h(),[t,l]=s(c.hash.slice(1)),[n,a]=s("");return e("div",{style:{maxWidth:640,margin:"2rem auto",padding:"0 1rem"},children:[e("h1",{children:"Watch along"}),e("p",{children:"Watch with friends across the internet. The host chooses the episode, provider, and source, and controls playback. Your dango streams your own video."}),o.session&&e(u,{}),!o.session&&e("form",{className:p.panel,onSubmit:r=>{r.preventDefault();try{o.join(t),a("")}catch(i){a(i instanceof Error?i.message:"Could not join room")}},children:[e(g,{}),e("label",{htmlFor:"watch-invite",children:"Invite link or room code"}),e("input",{id:"watch-invite",value:t,onChange:r=>l(r.currentTarget.value),required:!0,autoComplete:"off"}),e("p",{children:"Joining shares your connection and playback readiness with the room service. Start a room from an episode using a direct HLS source."}),e(m,{type:"submit",disabled:!o.workerUrl,style:{marginTop:"1rem"},children:"Join room"}),!o.workerUrl&&e("p",{children:"Watch along is unavailable. The server needs a watch-along service URL."}),n&&e("p",{role:"alert",children:n})]})]})}export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as h,A as _,h as z,u as s,L as C}from"./vendor-core-DfaOB3Rn.js";import{a6 as g,B as r}from"./index-
|
|
1
|
+
import{d as h,A as _,h as z,u as s,L as C}from"./vendor-core-DfaOB3Rn.js";import{a6 as g,B as r}from"./index-BVkDKnzf.js";const N="_panel_ntzz0_1",b="_summary_ntzz0_10",k="_heading_ntzz0_20",x="_actions_ntzz0_21",T="_members_ntzz0_22",A="_name_ntzz0_29",o={panel:N,summary:b,heading:k,actions:x,members:T,name:A};function L(){const t=g();return s("label",{className:o.name,children:["Display name",s("input",{value:t.displayName,onChange:a=>t.setDisplayName(a.currentTarget.value),maxLength:32,placeholder:"Your name (optional)",autoComplete:"nickname"}),s("small",{children:"Remembered for this profile on this browser."})]})}function D({playback:t,onCreate:a,needsPlayback:l,onEnablePlayback:p}){const e=g(),[y,m]=h(!1),[d,i]=h(""),[v,f]=h(!1),c=_(null);z(()=>{c.current&&(e.session||l)&&(c.current.open=!0)},[e.session,l]);const u=e.session?`${e.workerUrl}/join#${e.session.id}.${e.session.guestToken}`:"";return s("details",{ref:c,className:o.panel,"aria-label":"Watch along",children:[s("summary",{className:o.summary,children:["Watch along",e.session?e.session.host?" · You are hosting":" · Following host":""]}),s("div",{className:o.heading,children:e.session?s("div",{className:o.actions,children:[s(r,{size:"sm",variant:"secondary",onClick:async()=>{f(!0);try{await navigator.clipboard.writeText(u),i("Invite copied")}catch{i("Copy the invite below")}},children:"Copy invite"}),s(r,{size:"sm",variant:"ghost",onClick:e.leave,children:e.session.host?"End room":"Leave room"})]}):s("div",{className:o.actions,children:[a&&s(r,{size:"sm",loading:y,disabled:!t||!e.workerUrl,onClick:async()=>{if(t){m(!0),i("");try{a(),await e.create({...t,playing:!1})}catch(n){i(n instanceof Error?n.message:"Could not create room")}finally{m(!1)}}},children:"Create room"}),s(C,{to:"/watch-along",children:"Join a room"})]})}),s(L,{}),!e.session&&s("p",{children:"Direct HLS only. Each viewer needs their own dango. Room controls use the shared watch-along service."}),e.session&&s("p",{children:[e.connected?e.room?.hostOnline?"Connected":"Host disconnected. Room closes after 60 seconds unless they reconnect":"Connecting…"," ","· Provider and source follow the host. Volume and subtitles stay yours."]}),e.room&&s("p",{children:[e.session?.host&&"End the room when you are finished watching. ","Rooms automatically close six hours after creation. This room expires at"," ",s("time",{dateTime:new Date(e.room.expiresAt).toISOString(),children:new Date(e.room.expiresAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),", even if playback is still active."]}),e.room&&s("ul",{className:o.members,children:e.room.members.map((n,w)=>s("li",{children:[n.name||(n.host?"Host":`Guest ${w+1}`),n.name&&n.host?" (host)":"",n.id===e.selfId?" (you)":"",": ",n.status]},n.id))}),l&&s(r,{size:"sm",onClick:p,children:"Enable playback"}),v&&e.session&&s("input",{"aria-label":"Room invite",readOnly:!0,value:u,onFocus:n=>n.currentTarget.select()}),(e.error||d)&&s("p",{role:"status",children:e.error||d})]})}export{D as W,L as a,o as s};
|