@serifpersia/dango 3.8.6 → 3.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-DWKuN1cB.js → AnimeCard-G3oigO8B.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-BvNA7-QZ.js → AnimeInfo-CR4XFD0Q.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-BGg76ExO.js → AnimeInfoPage-DbT2RS0J.js} +2 -2
  5. package/client/dist/assets/{Asmr-C8pvBHUO.js → Asmr-BaXYabXN.js} +1 -1
  6. package/client/dist/assets/{AsmrPopup-BV5rbWXg.js → AsmrPopup-6ky2U3uz.js} +1 -1
  7. package/client/dist/assets/{AsmrResetProgressModal-Cs5wzgRU.js → AsmrResetProgressModal-DXwHSqwf.js} +1 -1
  8. package/client/dist/assets/Home-ZHM84CD8.js +1 -0
  9. package/client/dist/assets/{Home-grKghNM9.css → Home-ujV6ObHi.css} +1 -1
  10. package/client/dist/assets/{Insights-RSd-4osN.js → Insights-C6rMfz5x.js} +1 -1
  11. package/client/dist/assets/{LibraryListPage-CHHjw4Jz.js → LibraryListPage-XHeMv9aN.js} +1 -1
  12. package/client/dist/assets/{ListeningList-DkgZaFkg.js → ListeningList-Dm_owBjG.js} +1 -1
  13. package/client/dist/assets/{Manga-BAI78oiq.js → Manga-BmHoV3yQ.js} +1 -1
  14. package/client/dist/assets/{MangaInfoPage-CPYfuLAg.js → MangaInfoPage-Blz86W7a.js} +1 -1
  15. package/client/dist/assets/{MangaReadPage-DvznQu_2.js → MangaReadPage-DzEhRrLW.js} +1 -1
  16. package/client/dist/assets/{MangaResetProgressModal-BPci6zSM.js → MangaResetProgressModal-DdnI3zEg.js} +1 -1
  17. package/client/dist/assets/{Mature-Cob1Zmtu.js → Mature-DGDC_8w6.js} +1 -1
  18. package/client/dist/assets/{MatureConsentModal-BrKd4CBZ.js → MatureConsentModal-BXFvhDf0.js} +1 -1
  19. package/client/dist/assets/{MediaCard-CXZJ8wr7.js → MediaCard-DW8QbvWe.js} +1 -1
  20. package/client/dist/assets/{OptionListMenu-ClUReC8J.js → OptionListMenu-Dxx8rcuO.js} +1 -1
  21. package/client/dist/assets/Player-CQy7jQbB.js +56 -0
  22. package/client/dist/assets/{PlayerProvider-DzaMVhFX.js → PlayerProvider-BoJyuLEn.js} +1 -1
  23. package/client/dist/assets/{PlayerSettings-DnFjoot8.js → PlayerSettings-DSq0bKT6.js} +1 -1
  24. package/client/dist/assets/{QueueOptionsButton-BdAz_Gn-.js → QueueOptionsButton-B2p9VIz2.js} +1 -1
  25. package/client/dist/assets/{QueueRail-BMLyoeAe.js → QueueRail-BWcF0bqm.js} +1 -1
  26. package/client/dist/assets/{ReadingList-B62vvh4_.js → ReadingList-CKJ1Lt3H.js} +1 -1
  27. package/client/dist/assets/{ResetProgressModal-CXDZfCap.js → ResetProgressModal-BpNG6BGY.js} +1 -1
  28. package/client/dist/assets/{Search-CfNUqNi0.js → Search-D5OkKFDj.js} +1 -1
  29. package/client/dist/assets/Settings-_URnBHKL.js +21 -0
  30. package/client/dist/assets/{SkeletonGrid-CmHR4_Fc.js → SkeletonGrid-BVWffnlT.js} +1 -1
  31. package/client/dist/assets/{Trackers-BnvqfI9T.js → Trackers-D4BC2YOO.js} +1 -1
  32. package/client/dist/assets/Tv-B0-XYYdF.js +4 -0
  33. package/client/dist/assets/{Tv-D3vXCsSC.css → Tv-DT3m2nZs.css} +1 -1
  34. package/client/dist/assets/{TvInfo-6fZeQsh1.js → TvInfo-FWR5_kso.js} +1 -1
  35. package/client/dist/assets/{TvPopup-CIMgMYf0.js → TvPopup-JKZPbL5t.js} +1 -1
  36. package/client/dist/assets/{TvSearch-DGG4xRiv.js → TvSearch-Gddgkz5g.js} +1 -1
  37. package/client/dist/assets/{TvWatchlist-B6DLkxqi.js → TvWatchlist-BTTqu23j.js} +1 -1
  38. package/client/dist/assets/{VirtualKeyboard-D8TvygKk.js → VirtualKeyboard-BD5VOYcJ.js} +1 -1
  39. package/client/dist/assets/{WatchAlong-ivfsMGhR.js → WatchAlong-Czm3Pr1E.js} +1 -1
  40. package/client/dist/assets/{WatchAlongPanel-CvUFCFll.js → WatchAlongPanel-Dsmcqrjh.js} +1 -1
  41. package/client/dist/assets/{Watchlist-dsmIAzsH.js → Watchlist-BMRAdzMF.js} +1 -1
  42. package/client/dist/assets/index-Bi-DGtzC.js +178 -0
  43. package/client/dist/assets/index-RwPVmyxh.css +1 -0
  44. package/client/dist/assets/{libraryInvalidation-CHlEJU7b.js → libraryInvalidation-B5vX-vJv.js} +1 -1
  45. package/client/dist/assets/{playbackCompletion-DB_c1lex.js → playbackCompletion-Dz3OK72-.js} +1 -1
  46. package/client/dist/assets/{useAnimeInfoData-DrWgr6PK.js → useAnimeInfoData-CQTVAjpz.js} +1 -1
  47. package/client/dist/assets/{useMangaLibrary-sGh96sdT.js → useMangaLibrary-i1RAEkNy.js} +1 -1
  48. package/client/dist/assets/{useMangaPopup-CWDMFbSD.js → useMangaPopup-BMXrc7pH.js} +1 -1
  49. package/client/dist/assets/{useProviders-DphwZjpZ.js → useProviders-DbKN3TWq.js} +1 -1
  50. package/client/dist/assets/{useTv-DatZ0tof.js → useTv-4SqDfx-O.js} +1 -1
  51. package/client/dist/assets/{useTvLibrary-efdd6TIy.js → useTvLibrary-yhqRv3U7.js} +1 -1
  52. package/client/dist/assets/{useWatchAlongPlayer-CRf0zHFj.js → useWatchAlongPlayer-BvcoBlQi.js} +3 -3
  53. package/client/dist/assets/useWatchAlongPlayer-CkSxIqXL.css +1 -0
  54. package/client/dist/index.html +2 -2
  55. package/package.json +2 -2
  56. package/server/dist/config.js +1 -1
  57. package/server/dist/server.js +146 -146
  58. package/server/package.json +1 -1
  59. package/client/dist/assets/Home-C3k84yqn.js +0 -1
  60. package/client/dist/assets/Player-7iroOb7T.js +0 -56
  61. package/client/dist/assets/Settings-CxC4k-nB.js +0 -21
  62. package/client/dist/assets/Tv-Dht8h84V.js +0 -4
  63. package/client/dist/assets/index-Ej7BS74s.css +0 -1
  64. package/client/dist/assets/index-npJ4Ahxa.js +0 -178
  65. package/client/dist/assets/useWatchAlongPlayer-CzQyysyL.css +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dango-server",
3
3
  "private": true,
4
- "version": "3.8.6",
4
+ "version": "3.8.8",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=22.12.0"
@@ -1 +0,0 @@
1
- import{d as B,A as F,h as P,q as x,g as U,u as e,L as We,T as Q,S as oe,a as ee,_ as et}from"./vendor-core-DfaOB3Rn.js";import{u as ke,a as ie,b as tt,c as at,q as Oe,t as nt,d as Ve,s as rt,f as Ne,B as Fe,e as ot,g as st,m as Ce,p as ne,h as re,i as lt,j as it,k as ct,l as Ie,M as dt,T as ut,n as ht,o as pt,r as Me,v as mt,w as gt,x as vt,y as _t,z as yt,A as bt,C as ft,D as Tt,E as Nt,F as wt}from"./index-npJ4Ahxa.js";import{b as St,u as kt,a as Ct}from"./vendor-query-BBT5_sHx.js";import{M as ge,P as It}from"./MediaCard-CXZJ8wr7.js";import{A as ce}from"./AnimeCard-DWKuN1cB.js";import{S as ze,A as je}from"./SkeletonGrid-CmHR4_Fc.js";import{I as W}from"./vendor-icons-DrybRNxP.js";import{u as At}from"./vendor-ui-3qrARCPr.js";import{E as Ae}from"./ErrorMessage-DAxegITP.js";import{R as Ge}from"./ResetProgressModal-CXDZfCap.js";import{Q as Rt}from"./QueueRail-BMLyoeAe.js";import{u as Ue,M as Qe}from"./useMangaPopup-CWDMFbSD.js";import{M as Lt}from"./MangaResetProgressModal-BPci6zSM.js";import{u as Ye,m as Se,i as He,a as Xe,b as $t}from"./useMangaLibrary-sGh96sdT.js";import{u as Mt}from"./useProviders-DphwZjpZ.js";import{u as Ke,a as Be,T as Bt}from"./useTv-DatZ0tof.js";import{T as Pt}from"./TvPopup-CIMgMYf0.js";import{u as xt,a as Et,b as Dt}from"./useTvLibrary-efdd6TIy.js";import{A as qt}from"./AsmrResetProgressModal-Cs5wzgRU.js";import{u as Wt,a as Ot,A as Vt,b as Ft,c as zt}from"./AsmrPopup-BV5rbWXg.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-BrKd4CBZ.js";import"./useAnimeInfoData-DrWgr6PK.js";import"./QueueOptionsButton-BdAz_Gn-.js";import"./playbackCompletion-DB_c1lex.js";import"./usePopup-DS9jMzp6.js";import"./libraryInvalidation-CHlEJU7b.js";const jt="_sectionWrapper_10ckl_9",Gt="_sectionTitleNoMargin_10ckl_13",Ut="_carousel_10ckl_189",M={"section-header":"_section-header_10ckl_1",sectionWrapper:jt,sectionTitleNoMargin:Gt,"title-wrapper":"_title-wrapper_10ckl_17","header-controls":"_header-controls_10ckl_24","header-select":"_header-select_10ckl_31","collapse-button":"_collapse-button_10ckl_80","title-link":"_title-link_10ckl_100","continue-watching":"_continue-watching_10ckl_119","nav-arrows":"_nav-arrows_10ckl_141","nav-button":"_nav-button_10ckl_147","carousel-container":"_carousel-container_10ckl_189",carousel:Ut,"carousel-inner":"_carousel-inner_10ckl_198","carousel-card":"_carousel-card_10ckl_203"};function ve({align:n="start",containScroll:l="trimSnaps",scrollFraction:h=.8,threshold:t=.6,onReachThreshold:o,slideCount:i=0}={}){const[g,s]=At({align:n,containScroll:l,dragFree:!0}),[k,y]=B(!1),[N,p]=B(!1),c=F({scrollFraction:h,threshold:t,onReachThreshold:o}),r=F(!1);P(()=>{c.current={scrollFraction:h,threshold:t,onReachThreshold:o}});const w=x(m=>{y(m.canScrollPrev()),p(m.canScrollNext())},[]);P(()=>{if(!s)return;const m=()=>{const u=s.scrollProgress();u>=c.current.threshold&&!r.current?(r.current=!0,c.current.onReachThreshold?.()):u<c.current.threshold&&(r.current=!1),w(s)};return s.on("init",m),s.on("reInit",m),s.on("scroll",m),s.on("resize",m),()=>{s.off("init",m),s.off("reInit",m),s.off("scroll",m),s.off("resize",m)}},[s,w]),P(()=>{s?.reInit()},[s,i]);const C=x(m=>{const u=m.containerNode().firstElementChild;if(!u)return 1;const b=m.rootNode().getBoundingClientRect().width,A=u.getBoundingClientRect().width;return A?Math.max(1,Math.round(b/A)):1},[]),S=x((m,u=!1)=>{if(!s)return;const b=Math.max(1,Math.round(C(s)*c.current.scrollFraction)),A=s.selectedScrollSnap()+(m==="left"?-b:b);s.scrollTo(A,u)},[s,C]),d=x((m=!1)=>{s?.scrollTo(0,m)},[s]);return{emblaRef:g,api:s,canScrollPrev:k,canScrollNext:N,stepBy:S,scrollToStart:d}}const Z=({title:n,eyebrow:l,titleLink:h,loading:t,emptyState:o,carousel:i,layout:g,collapsible:s,defaultExpanded:k=!0,onReachThreshold:y,scrollThreshold:N,isFetchingNextPage:p,resetScrollOnShrink:c,itemCount:r=0,highlight:w,headerActions:C,loadingSkeleton:S,skeletonCount:d=7,children:m})=>{const{lowEndMode:u}=ke(),{emblaRef:b,stepBy:A,scrollToStart:O,canScrollPrev:R,canScrollNext:E}=ve({onReachThreshold:y,threshold:N,slideCount:r}),[L,V]=U.useState(k);U.useEffect(()=>{V(k)},[k]);const z=U.useRef(0);return U.useEffect(()=>{c&&r>0&&L&&(r<=z.current||z.current===0)&&O(),r>0&&(z.current=r)},[r,c,L,O]),!t&&r===0&&!o&&!s?null:e("section",{className:`${M.sectionWrapper} ${w?M["continue-watching"]:""}`,children:[e("div",{className:M["section-header"],children:[e("div",{className:M["title-wrapper"],children:e("div",{className:"title-stack",children:[l&&e("div",{className:"section-eyebrow",children:l}),h?e(We,{to:h,className:M["title-link"],children:e("div",{className:`section-title ${M.sectionTitleNoMargin}`,children:n})}):e("div",{className:`section-title ${M.sectionTitleNoMargin}`,children:n})]})}),e("div",{className:M["header-controls"],children:[C,i&&r>0&&L&&(R||E)&&e("div",{className:M["nav-arrows"],children:[R&&e("button",{className:M["nav-button"],type:"button","aria-label":"Scroll left",onClick:I=>{I.preventDefault(),A("left",u)},children:e(W,{name:"chevron-left"})}),E&&e("button",{className:M["nav-button"],type:"button","aria-label":"Scroll right",onClick:I=>{I.preventDefault(),A("right",u)},children:e(W,{name:"chevron-right"})})]}),s&&e("button",{className:M["collapse-button"],type:"button",onClick:()=>V(I=>!I),"aria-expanded":L,"aria-label":L?`Collapse ${n}`:`Expand ${n}`,children:L?e(W,{name:"chevron-up"}):e(W,{name:"chevron-down"})})]})]}),L&&(i?!t&&r===0&&o?e("div",{children:o}):e("div",{className:M["carousel-container"],children:e("div",{className:M.carousel,ref:b,children:e("div",{className:M["carousel-inner"],children:[t&&r===0?Array.from({length:d}).map((I,G)=>e("div",{className:M["carousel-card"],children:S},G)):U.Children.map(m,(I,G)=>e("div",{className:M["carousel-card"],children:I},U.isValidElement(I)&&I.key!=null?I.key:`slide-${G}`)),p&&S&&e("div",{className:M["carousel-card"],children:S})]})})}):e("div",{className:"grid-container",children:t&&r===0?e(ze,{count:6,layout:g}):r>0?m:t?null:e("div",{style:{gridColumn:"1 / -1"},children:o})}))]})},Qt=({title:n,eyebrow:l,animeList:h,continueWatching:t,titleLink:o,onRemove:i,loading:g,emptyState:s,carousel:k,cardConfig:y,layout:N,onReachThreshold:p,scrollThreshold:c,isFetchingNextPage:r,collapsible:w,defaultExpanded:C=!0})=>{const S=N||"vertical";return e(Z,{title:n,eyebrow:l,titleLink:o,loading:g,emptyState:s,carousel:k,layout:S,collapsible:w,defaultExpanded:C,onReachThreshold:p,scrollThreshold:c,isFetchingNextPage:r,resetScrollOnShrink:t,highlight:t,itemCount:h.length,loadingSkeleton:e(je,{layout:S}),skeletonCount:7,children:h.map(d=>e(ce,{anime:d,continueWatching:t,onRemove:i,config:y,layout:S},d._id))})},Pe=U.memo(Qt),Yt="_wrapper_j52nn_1",Ht="_arrow_j52nn_6",Xt="_select_j52nn_15",we={wrapper:Yt,arrow:Ht,select:Xt},J=({value:n,options:l,onChange:h,ariaLabel:t,width:o})=>e("span",{className:we.wrapper,children:[e("select",{className:we.select,style:o!==void 0?{width:o}:void 0,value:n,"aria-label":t,onChange:i=>h(i.currentTarget.value),children:l.map(i=>e("option",{value:i.value,children:i.label},i.value))}),e(W,{name:"chevron-down",size:12,className:we.arrow})]}),Kt="_sectionWrapper_1dwd0_2",Zt="_sectionTitleNoMargin_1dwd0_6",Jt="_carouselContainer_1dwd0_94",ea="_carousel_1dwd0_94",ta="_carouselInner_1dwd0_105",aa="_carouselItem_1dwd0_110",na="_rankCard_1dwd0_147",ra="_rankPill_1dwd0_151",oa="_rankGold_1dwd0_162",sa="_rankSilver_1dwd0_166",la="_rankBronze_1dwd0_170",ia="_skeletonPoster_1dwd0_181",ca="_skeletonText_1dwd0_182",v={sectionWrapper:Kt,sectionTitleNoMargin:Zt,"section-header":"_section-header_1dwd0_11","title-wrapper":"_title-wrapper_1dwd0_19","header-actions":"_header-actions_1dwd0_39","nav-arrows":"_nav-arrows_1dwd0_45","nav-button":"_nav-button_1dwd0_51",carouselContainer:Jt,carousel:ea,carouselInner:ta,carouselItem:aa,rankCard:na,rankPill:ra,rankGold:oa,rankSilver:sa,rankBronze:la,skeletonPoster:ia,skeletonText:ca},xe="TRENDING_DESC",da="POPULARITY_DESC",ua=10;function ha({title:n,eyebrow:l}){const{lowEndMode:h}=ke(),[t,o]=ie("trending_sort",xe),i=[{value:xe,label:"Trending"},{value:da,label:"All Time"}],{data:g,fetchNextPage:s,hasNextPage:k,isFetchingNextPage:y,isLoading:N,isError:p,error:c}=tt(t,ua),r=Q(()=>g?.pages.flatMap(u=>u)||[],[g]),w=x(()=>{k&&!y&&!N&&s()},[k,y,N,s]),{emblaRef:C,stepBy:S,canScrollPrev:d,canScrollNext:m}=ve({onReachThreshold:w,slideCount:r.length});return e("section",{className:v.sectionWrapper,children:[e("div",{className:v["section-header"],children:[e("div",{className:v["title-wrapper"],children:e("div",{className:"title-stack",children:[l&&e("div",{className:"section-eyebrow",children:l}),e("div",{className:`section-title ${v.sectionTitleNoMargin}`,children:n})]})}),e("div",{className:v["header-actions"],children:[e(J,{ariaLabel:"Trending sort",width:120,value:t,options:i,onChange:o}),(d||m)&&e("div",{className:v["nav-arrows"],children:[d&&e("button",{className:v["nav-button"],type:"button",onClick:u=>{u.preventDefault(),S("left",h)},"aria-label":"Scroll left",children:e(W,{name:"chevron-left"})}),m&&e("button",{className:v["nav-button"],type:"button",onClick:u=>{u.preventDefault(),S("right",h)},"aria-label":"Scroll right",children:e(W,{name:"chevron-right"})})]})]})]}),N?e("div",{className:v.carouselContainer,children:e("div",{className:v.carousel,children:e("div",{className:v.carouselInner,children:Array.from({length:7}).map((u,b)=>e("div",{className:v.carouselItem,children:[e("div",{className:v.skeletonPoster}),e("div",{className:v.skeletonText})]},b))})})}):p?e(Ae,{message:c instanceof Error?c.message:"An unknown error occurred"}):e("div",{className:v.carouselContainer,children:e("div",{className:v.carousel,ref:C,children:e("div",{className:v.carouselInner,children:[r.map((u,b)=>e("div",{className:v.carouselItem,children:[e("div",{className:v.rankCard,children:e(ce,{anime:u})}),e("div",{className:`${v.rankPill} ${b===0?v.rankGold:b===1?v.rankSilver:b===2?v.rankBronze:""}`,children:b+1})]},u._id)),y&&e("div",{className:v.carouselItem,style:{minWidth:"150px",display:"flex",alignItems:"center",justifyContent:"center"},children:e("div",{className:v.skeletonPoster})})]})})})]})}const pa=[{value:"TV",label:"TV"},{value:"ONA",label:"ONA"},{value:"OVA",label:"OVA"},{value:"MOVIE",label:"Movie"},{value:"ALL",label:"All"},{value:"ADULT",label:"Mature"}],ma=10;function ga({eyebrow:n}){const{lowEndMode:l}=ke(),[h,t]=ie("latest_releases_format","TV"),{data:o,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:s,isLoading:k,isError:y,error:N}=at(h,ma),p=Q(()=>o?.pages.flatMap(d=>d)||[],[o]),c=x(()=>{g&&!s&&!k&&i()},[g,s,k,i]),{emblaRef:r,stepBy:w,canScrollPrev:C,canScrollNext:S}=ve({onReachThreshold:c,slideCount:p.length});return e("section",{className:v.sectionWrapper,children:[e("div",{className:v["section-header"],children:[e("div",{className:v["title-wrapper"],children:e("div",{className:"title-stack",children:[n&&e("div",{className:"section-eyebrow",children:n}),e("div",{className:`section-title ${v.sectionTitleNoMargin}`,children:"Latest Releases"})]})}),e("div",{className:v["header-actions"],children:[e(J,{ariaLabel:"Latest releases format",width:120,value:h,options:pa,onChange:t}),(C||S)&&e("div",{className:v["nav-arrows"],children:[C&&e("button",{className:v["nav-button"],type:"button",onClick:d=>{d.preventDefault(),w("left",l)},"aria-label":"Scroll left",children:e(W,{name:"chevron-left"})}),S&&e("button",{className:v["nav-button"],type:"button",onClick:d=>{d.preventDefault(),w("right",l)},"aria-label":"Scroll right",children:e(W,{name:"chevron-right"})})]})]})]}),k?e("div",{className:v.carouselContainer,children:e("div",{className:v.carousel,children:e("div",{className:v.carouselInner,children:Array.from({length:7}).map((d,m)=>e("div",{className:v.carouselItem,children:[e("div",{className:v.skeletonPoster}),e("div",{className:v.skeletonText})]},m))})})}):y?e(Ae,{message:N instanceof Error?N.message:"An unknown error occurred"}):e("div",{className:v.carouselContainer,children:e("div",{className:v.carousel,ref:r,children:e("div",{className:v.carouselInner,children:[p.map(d=>e("div",{className:v.carouselItem,children:e(ce,{anime:d})},d._id)),s&&e("div",{className:v.carouselItem,style:{minWidth:"150px",display:"flex",alignItems:"center",justifyContent:"center"},children:e("div",{className:v.skeletonPoster})})]})})})]})}const va="_scheduleSection_1o82r_1",_a="_sectionTitleRow_1o82r_5",ya="_sectionTitleNoMargin_1o82r_11",ba="_sectionHeader_1o82r_15",fa="_headerActions_1o82r_25",Ta="_daySelectorContainer_1o82r_33",Na="_daySelector_1o82r_33",wa="_daySelectorInner_1o82r_50",Sa="_dayBtn_1o82r_61",ka="_active_1o82r_84",Ca="_dayMonth_1o82r_92",Ia="_dayNum_1o82r_100",Aa="_dayName_1o82r_106",Ra="_navArrows_1o82r_119",La="_navButton_1o82r_125",$a="_carouselContainer_1o82r_168",Ma="_carousel_1o82r_168",Ba="_carouselInner_1o82r_180",Pa="_carouselCard_1o82r_185",$={scheduleSection:va,sectionTitleRow:_a,sectionTitleNoMargin:ya,sectionHeader:ba,headerActions:fa,daySelectorContainer:Ta,daySelector:Na,daySelectorInner:wa,dayBtn:Sa,active:ka,dayMonth:Ca,dayNum:Ia,dayName:Aa,navArrows:Ra,navButton:La,carouselContainer:$a,carousel:Ma,carouselInner:Ba,carouselCard:Pa},de=n=>{const l=n.getFullYear(),h=String(n.getMonth()+1).padStart(2,"0"),t=String(n.getDate()).padStart(2,"0");return`${l}-${h}-${t}`},xa=async(n,l)=>await nt.data.schedule.query({date:n,format:l}),Ea=({eyebrow:n})=>{const[l,h]=B(()=>de(new Date)),[t,o]=ie("schedule_format","TV"),i=F(null),g=F(!0),{data:s=[],isLoading:k,error:y}=St({queryKey:[Oe.schedule,l,t],queryFn:()=>xa(l,t),staleTime:1e3*60*5}),{emblaRef:N,canScrollPrev:p,canScrollNext:c,stepBy:r,scrollToStart:w}=ve({slideCount:s.length}),C=Q(()=>{const d=[],m=new Date,u=de(m),b=new Date(m);b.setDate(m.getDate()-1);const A=de(b),O=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let R=-6;R<=6;R++){const E=new Date(m);E.setDate(m.getDate()+R),d.push(E)}return d.map(R=>{const E=de(R),z=E===u?"Today":E===A?"Yest":O[R.getDay()],I=R.getDate(),G=new Intl.DateTimeFormat("en-US",{month:"short"}).format(R);return{dateString:E,dayLabel:z,dayNum:I,monthName:G}})},[]);P(()=>{const d=i.current,m=d?.querySelector(`[data-date="${l}"]`);if(!d||!m)return;const u=d.getBoundingClientRect(),b=m.getBoundingClientRect(),A=d.scrollLeft+(b.left-u.left)-(u.width-b.width)/2;d.scrollTo({left:Math.max(0,A),behavior:g.current?"auto":"smooth"}),g.current=!1},[l]),P(()=>{w(!0)},[l,w]);const S=[{value:"TV",label:"TV"},{value:"ONA",label:"ONA"},{value:"OVA",label:"OVA"},{value:"MOVIE",label:"Movie"},{value:"ALL",label:"All"},{value:"ADULT",label:"Mature"}];return e("div",{className:$.scheduleSection,children:[e("div",{className:$.sectionHeader,children:[e("div",{className:$.sectionTitleRow,children:e("div",{className:"title-stack",children:[n&&e("div",{className:"section-eyebrow",children:n}),e("h2",{className:`section-title ${$.sectionTitleNoMargin}`,children:"Episode Schedule"})]})}),e("div",{className:$.headerActions,children:[e(J,{ariaLabel:"Schedule format",width:120,value:t,options:S,onChange:o}),s.length>0&&(p||c)&&e("div",{className:$.navArrows,children:[p&&e("button",{className:$.navButton,onClick:()=>r("left"),"aria-label":"Scroll left",children:e(W,{name:"chevron-left"})}),c&&e("button",{className:$.navButton,onClick:()=>r("right"),"aria-label":"Scroll right",children:e(W,{name:"chevron-right"})})]})]})]}),e("div",{className:$.daySelectorContainer,children:e("div",{className:$.daySelector,ref:i,children:e("div",{className:$.daySelectorInner,children:C.map(d=>e("button",{type:"button","data-date":d.dateString,"aria-pressed":l===d.dateString,className:`${$.dayBtn} ${l===d.dateString?$.active:""}`,onClick:()=>h(d.dateString),children:[e("span",{className:$.dayMonth,children:d.monthName}),e("span",{className:$.dayNum,children:d.dayNum}),e("span",{className:$.dayName,children:d.dayLabel})]},d.dateString))})})}),e("div",{className:$.carouselContainer,children:e("div",{className:$.carousel,ref:N,children:e("div",{className:$.carouselInner,children:k?Array.from({length:7}).map((d,m)=>e("div",{className:$.carouselCard,children:e(je,{layout:"vertical"})},m)):y?e("div",{style:{width:"100%"},children:e(Ae,{message:y instanceof Error?y.message:"An unknown error occurred"})}):s.length===0?e("p",{style:{textAlign:"center",marginTop:"1rem",width:"100%"},children:"No episodes scheduled for this day."}):s.map(d=>e("div",{className:$.carouselCard,children:e(ce,{anime:d,continueWatching:!1,layout:"vertical"},d._id)},d._id))})})})]})},Da="_bannerContainer_1oqya_1",qa="_hero_1oqya_28",Wa="_ambient_1oqya_37",Oa="_ambientShow_1oqya_49",Va="_scrim_1oqya_53",Fa="_progressLine_1oqya_70",za="_paused_1oqya_90",ja="_dots_1oqya_104",Ga="_dot_1oqya_104",Ua="_dotActive_1oqya_127",Qa="_viewport_1oqya_138",Ya="_track_1oqya_145",Ha="_slide_1oqya_151",Xa="_slideInner_1oqya_159",Ka="_poster_1oqya_169",Za="_posterLandscape_1oqya_180",Ja="_info_1oqya_204",en="_kicker_1oqya_209",tn="_featureLabel_1oqya_216",an="_scoreChip_1oqya_228",nn="_rise_1oqya_246",rn="_active_1oqya_250",on="_metaRow_1oqya_306",sn="_metaItem_1oqya_317",ln="_metaDivider_1oqya_323",cn="_title_1oqya_330",dn="_genres_1oqya_346",un="_genreTag_1oqya_354",hn="_summary_1oqya_365",pn="_actions_1oqya_377",mn="_watchBtn_1oqya_384",gn="_detailsBtn_1oqya_413",vn="_navArrow_1oqya_434",_n="_prevArrow_1oqya_467",yn="_nextArrow_1oqya_471",_={bannerContainer:Da,hero:qa,ambient:Wa,ambientShow:Oa,scrim:Va,progressLine:Fa,paused:za,dots:ja,dot:Ga,dotActive:Ua,viewport:Qa,track:Ya,slide:Ha,slideInner:Xa,poster:Ka,posterLandscape:Za,info:Ja,kicker:en,featureLabel:tn,scoreChip:an,rise:nn,active:rn,metaRow:on,metaItem:sn,metaDivider:ln,title:cn,genres:dn,genreTag:un,summary:hn,actions:pn,watchBtn:mn,detailsBtn:gn,navArrow:vn,prevArrow:_n,nextArrow:yn},bn=8e3,ue=()=>e("div",{className:"skeleton",style:{width:"100vw",maxWidth:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",height:"clamp(480px, 72vh, 660px)",marginTop:"calc(-1 * var(--header-height))",marginBottom:"2.5rem"}}),_e=({slides:n,posterAspect:l="portrait",eyebrow:h="Spotlight"})=>{const[t,o]=B(0),[i,g]=B(0),[s,k]=B(!1),[y,N]=B(null),[p,c]=B(0),[r,w]=B({front:"",back:"",flip:!1}),C=F(0),S=F(0),d=F(new Set),m=F(null),u=F(0),b=x(a=>a.bannerSrc,[]),A=x(()=>{g(a=>a+1)},[]),O=x(a=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null),N(null),A();const f=b(n[a]);w(T=>T.flip?{front:f,back:T.back,flip:!1}:{front:T.front,back:f,flip:!0}),o(a)},[A,n,b]),R=x(a=>{if(n.length===0)return;const f=(a%n.length+n.length)%n.length;d.current.has(b(n[f]))?O(f):N(f)},[n,b,O]);P(()=>{let a=!1;return n.forEach(f=>{const T=b(f);if(!T||d.current.has(T))return;const D=new Image;D.src=T;const X=()=>{a||d.current.has(T)||(d.current.add(T),c(j=>j+1))};D.onload=X,D.onerror=X}),()=>{a=!0}},[n,b]),P(()=>{if(n.length!==0&&!r.front){const a=b(n[0]);w({front:a,back:"",flip:!1})}},[n,r.front,b]),P(()=>{if(y!==null){if(y<0||y>=n.length){N(null);return}d.current.has(b(n[y]))&&O(y)}},[y,p,n,b,O]),P(()=>{if(y===null)return;m.current!==null&&window.clearTimeout(m.current);const a=y;return m.current=window.setTimeout(()=>{m.current=null,O(a)},2500),()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)}},[y,O]);const E=x(a=>{R(a)},[R]),L=x(()=>{R(u.current+1)},[R]),V=x(()=>{R(u.current-1)},[R]),z=F(null);if(P(()=>{const a=z.current;if(!a)return;const f=T=>{if(Math.abs(T.deltaY)>Math.abs(T.deltaX)&&Math.abs(T.deltaY)>5){T.preventDefault(),T.stopPropagation();const D=Date.now();if(D-C.current<300)return;C.current=D,A(),T.deltaY>0?L():V()}};return a.addEventListener("wheel",f,{passive:!1}),()=>a.removeEventListener("wheel",f)},[n.length,L,V,A]),P(()=>{if(n.length===0||s)return;const a=setTimeout(L,bn);return()=>clearTimeout(a)},[t,L,n.length,i,s]),P(()=>{const a=f=>{const T=f.target;T&&(T.tagName==="INPUT"||T.tagName==="TEXTAREA"||T.tagName==="SELECT"||T.isContentEditable)||(f.key==="ArrowRight"?(f.preventDefault(),L()):f.key==="ArrowLeft"&&(f.preventDefault(),V()))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[L,V]),P(()=>{t>=n.length&&o(0)},[n.length,t]),n.length===0)return null;const I=t>=n.length?0:t;u.current=I;const G=a=>{S.current=a.touches[0].clientX},H=a=>{const T=a.changedTouches[0].clientX-S.current;Math.abs(T)>50&&(A(),T>0?V():L())};return e("div",{className:_.bannerContainer,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),children:e("div",{className:`${_.hero} ${s?_.paused:""}`,onTouchStart:G,onTouchEnd:H,children:[r.front&&e("img",{src:r.front,alt:"","aria-hidden":"true",className:`${_.ambient} ${r.flip?"":_.ambientShow}`}),r.back&&e("img",{src:r.back,alt:"","aria-hidden":"true",className:`${_.ambient} ${r.flip?_.ambientShow:""}`}),e("div",{className:_.scrim,"aria-hidden":"true"}),n.length>1&&e("div",{className:_.progressLine,"aria-hidden":"true"},`progress-${i}-${I}`),n.length>1&&e("div",{className:_.dots,ref:z,role:"tablist","aria-label":"Spotlight slides",children:n.map((a,f)=>e("button",{role:"tab","aria-selected":f===I,"aria-label":`Go to slide ${f+1}: ${a.title}`,className:`${_.dot} ${f===I?_.dotActive:""}`,onClick:()=>E(f),tabIndex:f===I?0:-1},a.key))}),e("div",{className:_.viewport,children:e("div",{className:_.track,style:{transform:`translateX(-${I*100}%)`},children:n.map((a,f)=>e("div",{className:`${_.slide} ${f===I?_.active:""}`,"aria-hidden":f!==I,children:e("div",{className:_.slideInner,children:[e("img",{src:a.posterSrc,alt:a.posterAlt,className:l==="landscape"?_.posterLandscape:_.poster,decoding:"async"}),e("div",{className:_.info,children:[e("div",{className:`${_.kicker} ${_.rise}`,children:[e("span",{className:_.featureLabel,children:h}),a.score!==void 0&&a.score!==null&&a.score!==""&&e("span",{className:_.scoreChip,children:[e(W,{name:"star",size:12}),e("span",{children:a.score})]})]}),e(We,{to:a.detailTo,className:`${_.title} ${_.rise}`,"aria-label":`View details for ${a.title}`,tabIndex:f===I?0:-1,children:a.title}),a.metaItems.length>0&&e("div",{className:`${_.metaRow} ${_.rise}`,children:a.metaItems.map((T,D)=>e(U.Fragment,{children:[e("span",{className:_.metaItem,children:T}),D<a.metaItems.length-1&&e("div",{className:_.metaDivider})]},D))}),a.tags.length>0&&e("div",{className:`${_.genres} ${_.rise}`,children:a.tags.slice(0,3).map(T=>e("span",{className:_.genreTag,children:T},T))}),a.synopsis&&e("p",{className:`${_.summary} ${_.rise}`,children:a.synopsis}),e("div",{className:`${_.actions} ${_.rise}`,children:[e("button",{className:_.watchBtn,onClick:a.onPrimary,tabIndex:f===I?0:-1,children:[e(W,{name:a.primaryIcon,size:14}),e("span",{children:a.primaryLabel})]}),e("button",{className:_.detailsBtn,onClick:a.onDetails,tabIndex:f===I?0:-1,children:[e(W,{name:"info-circle",size:15}),e("span",{children:"Details"})]})]})]})]})},a.key))})}),n.length>1&&e(oe,{children:[e("button",{className:`${_.navArrow} ${_.prevArrow}`,onClick:()=>{A(),V()},"aria-label":"Previous slide",children:e(W,{name:"chevron-left",size:20})}),e("button",{className:`${_.navArrow} ${_.nextArrow}`,onClick:()=>{A(),L()},"aria-label":"Next slide",children:e(W,{name:"chevron-right",size:20})})]})]})})},fn=({animeList:n})=>{const{titlePreference:l}=Ve(),h=ee(),t=Q(()=>n.slice(0,6).map(o=>{const i=l==="nativeName"?o.nativeName||o.name:l==="englishName"&&o.englishName||o.name;return{key:o._id,bannerSrc:o.bannerImage?Ne(o.bannerImage,1280,560):Ne(o.thumbnail,1280,450),posterSrc:Ne(o.thumbnail,460,650),posterAlt:i,title:i,detailTo:`/anime/${o._id}`,score:o.score,metaItems:[o.type||"Anime",o.status,o.episodeCount?`${o.episodeCount} Episodes`:void 0,o.rating].filter(g=>!!g),tags:(o.genres??[]).slice(0,3).map(g=>typeof g=="string"?g:g?.name).filter(g=>!!g),synopsis:rt(o.description??""),primaryLabel:"Watch Now",primaryIcon:"play",onPrimary:()=>h(`/watch/${o._id}`),onDetails:()=>h(`/anime/${o._id}`)}}),[n,l,h]);return e(_e,{slides:t})},Tn="_emptyState_19tmt_1",Nn="_emptyStateIcon_19tmt_16",wn="_emptyStateTitle_19tmt_23",Sn="_emptyStateText_19tmt_30",he={emptyState:Tn,emptyStateIcon:Nn,emptyStateTitle:wn,emptyStateText:Sn},ye=({icon:n,text:l,actionLabel:h,onAction:t,title:o="Nothing is here..."})=>e("div",{className:he.emptyState,children:[e(W,{name:n,size:48,className:he.emptyStateIcon}),e("div",{children:[e("h3",{className:he.emptyStateTitle,children:o}),e("p",{className:he.emptyStateText,children:l})]}),e(Fe,{variant:"primary",size:"sm",onClick:t,style:{marginTop:"1rem"},children:h})]}),kn="_tabBar_1mv4x_1",Cn="_tabIndicator_1mv4x_24",In="_tabButton_1mv4x_38",An="_tabActive_1mv4x_53",pe={tabBar:kn,tabIndicator:Cn,tabButton:In,tabActive:An};function Rn({options:n,value:l,onChange:h,ariaLabel:t},o){const i=F(null),g=F(new Map),s=F(null),[k,y]=B({left:0,width:0}),N=x((p,c)=>{const r=g.current.get(p),w=i.current;if(r&&w){const C=w.getBoundingClientRect(),S=r.getBoundingClientRect();y({left:S.left-C.left+w.scrollLeft,width:S.width}),c&&r.scrollIntoView({block:"nearest",inline:"nearest"})}},[]);return et(()=>{const p=s.current!==null&&s.current!==l;s.current=l,N(l,p)},[l,n.length,N]),P(()=>{if(N(l,!1),typeof ResizeObserver>"u")return;let p=0;const c=i.current;if(!c)return;const r=new ResizeObserver(()=>{cancelAnimationFrame(p),p=requestAnimationFrame(()=>N(l,!1))});r.observe(c);let w=!1;return document.fonts?.ready&&document.fonts.ready.then(()=>{w||N(l,!1)}),()=>{w=!0,cancelAnimationFrame(p),r.disconnect()}},[l,n.length,N]),e("div",{className:pe.tabBar,ref:p=>{i.current=p,typeof o=="function"?o(p):o&&(o.current=p)},"aria-label":t,children:[e("div",{className:pe.tabIndicator,style:{left:k.left,width:k.width}}),n.map(p=>e(Fe,{ref:c=>{c&&g.current.set(p.value,c)},variant:"secondary",size:"sm",className:`${pe.tabButton} ${l===p.value?pe.tabActive:""}`,onClick:()=>h(p.value),children:p.label},p.value))]})}const me=U.forwardRef(Rn),Ln=[{value:"popular",label:"Popular"},{value:"followed",label:"Most Followed"},{value:"rating",label:"Top Rated"}],Ee=({title:n,eyebrow:l,sort:h,mature:t,headerActions:o})=>{const{toggle:i,bookmarkedIds:g}=Ye(),{popup:s,openPopup:k,scheduleClose:y,cancelClose:N,closePopup:p}=Ue(),{data:c,isLoading:r,fetchNextPage:w,hasNextPage:C,isFetchingNextPage:S}=st({provider:"",query:"",sort:h,status:"",type:"",rating:t?"safe,suggestive,erotica,pornographic":"safe",mature:t}),d=Q(()=>c?.pages.flatMap(u=>u.items)??[],[c]),m=x(()=>{C&&!S&&!r&&w()},[C,S,r,w]);return e(oe,{children:[e(Z,{title:n,eyebrow:l,loading:r,carousel:!0,itemCount:d.length,headerActions:o,onReachThreshold:m,isFetchingNextPage:S,loadingSkeleton:e("div",{className:"skeleton",style:{aspectRatio:"3 / 4"}}),skeletonCount:7,children:d.map(u=>{const b=Se(u.provider,u.id);return e(ge,{item:{id:b,title:u.title,...Xe(u),thumbnail:Ce(u.provider,u.cover),typeBadge:u.type||void 0,chapterBadge:u.latestChapter?`Ch. ${u.latestChapter}`:null,isAdult:He(u)},linkTo:`/manga/${u.provider}/${encodeURIComponent(u.id)}`,hoverIcon:"info",showInfoButton:!0,display:{elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!1,meta:!1}}},onOpenDetails:A=>k(A,{provider:u.provider,mangaId:u.id,title:u.title,altTitle:u.altTitle,cover:u.cover,contentRating:u.contentRating,readTarget:`/manga/${u.provider}/${encodeURIComponent(u.id)}`,mature:t}),onPopupHoverIntent:A=>A?N():y(),rawThumbnail:!0},`${u.provider}-${u.id}`)})}),s&&e(Qe,{data:s.data,anchorRect:s.rect,bookmarked:g.has(Se(s.data.provider,s.data.mangaId)),onToggleBookmark:()=>i({id:s.data.mangaId,provider:s.data.provider,title:s.data.title,cover:s.data.cover,altTitle:s.data.altTitle??void 0,contentRating:s.data.contentRating}),onMouseEnter:N,onMouseLeave:y,onRequestClose:p})]})},$n=()=>{const{options:n}=Mt(),l=Q(()=>n.some(s=>s.kind==="manga"),[n]),{hasConsent:h}=ot(),[t,o]=ie("manga_discover_tab","latest"),[i,g]=ie("manga_trending_sort","popular");return l?e(oe,{children:[e(me,{ariaLabel:"Discover manga",options:[{value:"latest",label:"Latest Releases"},{value:"trending",label:"Trending"}],value:t,onChange:o}),t==="latest"?e(Ee,{title:"Latest Releases",eyebrow:"Fresh chapters",sort:"latest",mature:h}):e(Ee,{title:"Trending",eyebrow:"Discover",sort:i,mature:h,headerActions:e("select",{className:M["header-select"],value:i,onChange:s=>g(s.currentTarget.value),"aria-label":"Trending sort",children:Ln.map(s=>e("option",{value:s.value,children:s.label},s.value))})})]}):null},Mn=()=>{const n=ee(),{data:l,isLoading:h}=$t(24),[t,o]=B(null),{popup:i,openPopup:g,scheduleClose:s,cancelClose:k,closePopup:y}=Ue(),{toggle:N,bookmarkedIds:p}=Ye(),c=l?.data??[];return e("div",{style:{paddingBottom:"2rem"},children:[e(Z,{title:"Continue Reading",eyebrow:"Pick up where you left off",titleLink:"/reading-list/Continue Reading",loading:h,carousel:!0,collapsible:!0,defaultExpanded:c.length>0,highlight:!0,itemCount:c.length,loadingSkeleton:e("div",{className:"skeleton",style:{aspectRatio:"3 / 4"}}),skeletonCount:7,emptyState:e(ye,{icon:"book",text:"You haven't read anything yet. Browse manga and open a chapter to start tracking.",actionLabel:"Browse Manga",onAction:()=>n("/manga")}),children:c.map(r=>{const w=r.page??0,C=r.pageCount??0,S=r.chapterId&&r.provider?`/manga/${r.provider}/${encodeURIComponent(r.mangaId)}/read?chapter=${encodeURIComponent(r.chapterId)}`:r.provider?`/manga/${r.provider}/${encodeURIComponent(r.mangaId)}`:"#";return e(ge,{item:{id:r.id,title:r.title||"",...Xe({title:r.title||"",altTitle:r.altTitle}),thumbnail:r.provider?Ce(r.provider,r.cover||""):r.cover||"",chapterBadge:r.chapterNumber?`Ch. ${r.chapterNumber}`:null,isAdult:He(r)},linkTo:S,hoverIcon:"book",progress:C>0?{percent:w/C*100,label:`Ch. ${r.chapterNumber} · p. ${w}/${C}`}:void 0,showProgress:!0,display:{elements:{poster:{typeBadge:!1,chapterBadge:!0,adultBadge:!0,removeButton:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:()=>o({libId:r.id,title:r.title||""}),onOpenDetails:d=>g(d,{provider:r.provider||"",mangaId:r.mangaId||"",title:r.title||"",altTitle:r.altTitle,cover:r.cover||"",contentRating:r.contentRating||void 0,readTarget:S}),onPopupHoverIntent:d=>d?k():s(),rawThumbnail:!0},r.id)})}),e(Lt,{mangaId:t?t.libId:null,title:t?.title,onClose:()=>o(null)}),i&&i.data.provider&&e(Qe,{data:i.data,anchorRect:i.rect,bookmarked:p.has(Se(i.data.provider,i.data.mangaId)),onToggleBookmark:()=>N({id:i.data.mangaId,provider:i.data.provider,title:i.data.title,cover:i.data.cover,altTitle:i.data.altTitle??void 0,contentRating:i.data.contentRating}),onMouseEnter:k,onMouseLeave:s,onRequestClose:y}),e($n,{})]})},Bn="_emptyState_bpz5x_1",De={emptyState:Bn},Pn=[{value:"latest",label:"Latest Releases"},{value:"trending",label:"Trending"}],xn=[{value:"trending_week",label:"Trending Now"},{value:"trending_day",label:"Trending Today"},{value:"popular",label:"Popular All Time"},{value:"top_rated",label:"Top Rated"}],En=()=>{const n=ee(),{data:l,isLoading:h}=xt(24),t=Et(),o=Dt(),[i,g]=B(null),[s,k]=B(()=>ne.getItem("tv_home_activeTab")||"latest"),[y,N]=B("tv"),[p,c]=B("trending_week"),[r,w]=B("multi"),C=l?.data??[];U.useEffect(()=>{ne.setItem("tv_home_activeTab",s)},[s]);const S=p.startsWith("trending_"),d=p==="trending_day"?"day":"week",m={popular:"popularity.desc",top_rated:"vote_average.desc"},{data:u,isLoading:b}=Ke(r==="multi"?"all":r,d,1,S&&s==="trending"),{data:A,isLoading:O}=Be({type:r,sort_by:m[p]||"popularity.desc",page:1}),R=S?u?.results||[]:A?.results||[],E=S?b:O,{data:L,isLoading:V}=Be({type:y,sort_by:"primary_release_date.desc",page:1}),z=L?.results||[],I=a=>{i&&(o.mutate({mediaId:i.libId}),a&&t.mutate(i.libId))},G=x(a=>e(Bt,{item:{id:a.id,title:a.title,year:a.year,type:a.type,image:a.image,vote_average:a.vote_average,adult:a.adult}},`${a.type}-${a.id}`),[]),H=()=>{switch(s){case"latest":return e(Z,{title:"Latest Releases",eyebrow:"Fresh picks",loading:V,carousel:!0,itemCount:z.length,headerActions:e(J,{ariaLabel:"Latest type",value:y,onChange:a=>N(a),options:[{value:"tv",label:"TV Shows"},{value:"movie",label:"Movies"}]}),loadingSkeleton:e("div",{className:"skeleton",style:{aspectRatio:"3 / 4",borderRadius:"var(--radius-lg)"}}),emptyState:e("div",{className:De.emptyState,children:e("p",{children:"No latest releases available right now."})}),children:z.map(G)});case"trending":return e(Z,{title:"Trending",eyebrow:"Discover",loading:E,carousel:!0,itemCount:R.length,headerActions:e(oe,{children:[e(J,{ariaLabel:"Trending sort",value:p,onChange:c,options:xn.map(a=>({value:a.value,label:a.label}))}),e(J,{ariaLabel:"Trending type",value:r,onChange:a=>w(a),options:[{value:"multi",label:"All"},{value:"tv",label:"TV Shows"},{value:"movie",label:"Movies"}]})]}),loadingSkeleton:e("div",{className:"skeleton",style:{aspectRatio:"3 / 4",borderRadius:"var(--radius-lg)"}}),emptyState:e("div",{className:De.emptyState,children:e("p",{children:"No trending content available right now."})}),children:R.map(G)})}};return e("div",{style:{paddingBottom:"2rem"},children:[e(Z,{title:"Continue Watching",eyebrow:"Pick up where you left off",titleLink:"/tv-watchlist/Continue Watching",loading:h,carousel:!0,collapsible:!0,defaultExpanded:C.length>0,highlight:!0,itemCount:C.length,loadingSkeleton:e("div",{className:"skeleton",style:{aspectRatio:"3 / 4"}}),skeletonCount:7,emptyState:e(ye,{icon:"tv",text:"You haven't watched anything yet. Search TV & Movies and start watching to track progress.",actionLabel:"Browse TV & Movies",onAction:()=>n("/tv-search")}),children:C.map(a=>{const f=a.currentTime??0,T=a.duration??0,D=a.season??1,X=a.episode??1,j=a.mediaType==="movie",K=j?"Movie":`S${D} E${X}`,te=a.completed===1||T>0&&f>=T*.8,ae=te?100:T>0&&f>0?f/T*100:0,be=te?"Watched":T>0?j?`${re(f)} / ${re(T)}`:`${K} · ${re(f)} / ${re(T)}`:K;return e(ge,{item:{id:a.id,title:a.title||"",thumbnail:a.poster||"",typeBadge:j?"Movie":"TV",chapterBadge:K,isAdult:it({adult:a.adult===1})},linkTo:lt(a.mediaType,a.tmdbId??0,j?void 0:D,j?void 0:X),hoverIcon:"play",progress:(T>0||te)&&ae>0?{percent:ae,label:be}:void 0,showProgress:!0,metaRow:a.year?e("span",{style:{opacity:.75},children:a.year}):void 0,onRemove:()=>g({libId:a.id,title:a.title||""}),renderPopup:(fe,se)=>e(Pt,{item:{id:a.tmdbId??0,title:a.title||"",year:a.year||"",type:a.mediaType||"tv",image:a.poster||""},anchorRect:fe,onMouseEnter:se.onMouseEnter,onMouseLeave:se.onMouseLeave,onRequestClose:se.close})},a.id)})}),e(me,{ariaLabel:"Browse TV",options:Pn,value:s,onChange:k}),e("div",{children:H()}),e(Ge,{isOpen:!!i,itemName:i?.title,progressKind:"watch",listLabel:"my TV watchlist",onClose:()=>{g(null)},onConfirm:I})]})};function qe(n){const l=n.currentTime??0,h=n.duration??0,t=(n.trackIndex??0)+1;return h>0?`Track ${t} · ${re(l)} / ${re(h)}`:n.trackLabel?`Track ${t} · ${n.trackLabel}`:`Track ${t}`}const Dn=({title:n="Continue Listening",limit:l=24,titleLink:h,showEmptyState:t=!0})=>{const o=ee(),{data:i,isLoading:g}=Wt(l),{toggle:s,bookmarkedIds:k}=Ot(),[y,N]=B(null),p=i?.data??[];return e(oe,{children:[e(Z,{title:n,eyebrow:"Pick up where you left off",titleLink:h??"/listening-list/Continue Listening",loading:g,carousel:!0,collapsible:!0,defaultExpanded:p.length>0,highlight:!0,itemCount:p.length,loadingSkeleton:e("div",{className:"skeleton",style:{aspectRatio:"16 / 9"}}),skeletonCount:7,emptyState:t?e(ye,{icon:"headphones",text:"You haven't listened to anything yet. Browse ASMR and play a track to start tracking.",actionLabel:"Browse ASMR",onAction:()=>o("/asmr")}):void 0,children:p.map(c=>{const r=c.currentTime??0,w=c.duration??0,C=c.rjCode||c.id;return e(ge,{item:{id:c.id,title:c.title||"",thumbnail:c.thumbnail||"",chapterBadge:`Track ${(c.trackIndex??0)+1}`,isAdult:!!c.isAdult},linkTo:`/asmr/${encodeURIComponent(C)}`,hoverIcon:"play",layout:"horizontal",progress:w>0?{percent:Math.min(100,r/w*100),label:qe(c)??""}:void 0,showProgress:!0,display:{elements:{poster:{typeBadge:!1,chapterBadge:!0,adultBadge:!0,removeButton:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:()=>N({workId:c.id,title:c.title||""}),renderPopup:(S,d)=>e(Vt,{data:{rjCode:c.rjCode||c.id,title:c.title||"",thumbnail:c.thumbnail||"",isAdult:!!c.isAdult,listenTarget:`/asmr/${encodeURIComponent(c.rjCode||c.id)}`,progressLabel:qe(c)},anchorRect:S,bookmarked:k.has(Ft(c.rjCode||c.id)),onToggleBookmark:()=>s({rjCode:c.rjCode||c.id,title:c.title||"",thumbnail:c.thumbnail||"",isAdult:!!c.isAdult}),onMouseEnter:d.onMouseEnter,onMouseLeave:d.onMouseLeave,onRequestClose:d.close}),rawThumbnail:!0},c.id)})}),e(qt,{workId:y?y.workId:null,title:y?.title,onClose:()=>N(null)})]})},qn=()=>e("div",{style:{paddingBottom:"2rem"},children:e(Dn,{})}),Wn=({items:n})=>{const l=ee(),h=Q(()=>n.slice(0,6).map(t=>{const o=ct(t.type,t.id);return{key:String(t.id),bannerSrc:t.backdrop?t.backdrop:t.image,posterSrc:t.image,posterAlt:t.title,title:t.title,detailTo:o,score:t.vote_average>0?Number(t.vote_average).toFixed(1):null,metaItems:[t.type==="tv"?"TV Show":"Movie",t.year].filter(Boolean),tags:t.genre_ids.slice(0,3).map(i=>dt[i]??ut[i]).filter(Boolean),synopsis:Ie(t.overview,200),primaryLabel:"Watch Now",primaryIcon:"play",onPrimary:()=>l(o),onDetails:()=>l(o)}}),[n,l]);return e(_e,{slides:h,eyebrow:"TV Spotlight"})},On=({mangaList:n})=>{const l=ee(),h=Q(()=>n.slice(0,6).map(t=>{const o=`/manga/${t.provider||"mangadex"}/${t.id}`,i=Ce(t.provider||"mangadex",t.cover||"");return{key:`${t.provider}-${t.id}`,bannerSrc:i,posterSrc:i,posterAlt:t.title,title:t.title,detailTo:o,metaItems:[t.year?String(t.year):void 0,t.status??void 0].filter(g=>!!g),tags:t.tags.slice(0,3),synopsis:Ie(t.description,200,""),primaryLabel:"Read Now",primaryIcon:"book",onPrimary:()=>l(o),onDetails:()=>l(o)}}),[n,l]);return e(_e,{slides:h,eyebrow:"Manga Spotlight"})};function Vn(n){const l=n.availableEpisodes?.sub;if(typeof l=="number"&&l>0)return l;const h=n.availableEpisodesDetail?.sub,t=n.availableEpisodesDetail?.dub,o=(Array.isArray(h)?h.length:0)+(Array.isArray(t)?t.length:0);return o>0?o:null}const Fn=({works:n})=>{const l=ee(),h=Q(()=>n.slice(0,6).map((t,o)=>{const i=ht(t),g=`/asmr/${encodeURIComponent(i)}`,s=Vn(t);return{key:i||t._id||String(o),bannerSrc:t.thumbnail||"",posterSrc:t.thumbnail||"",posterAlt:t.name,title:t.name,detailTo:g,metaItems:[t.rating?t.rating.toUpperCase():void 0,s?`${s} track${s===1?"":"s"}`:void 0].filter(k=>!!k),tags:[],synopsis:Ie(t.description,160,""),primaryLabel:"Listen Now",primaryIcon:"play",onPrimary:()=>l(g),onDetails:()=>l(g)}}),[n,l]);return e(_e,{slides:h,eyebrow:"ASMR Spotlight",posterAspect:"landscape"})},zn="_seasonGrid_168jc_34",le={"section-header":"_section-header_168jc_1","content-type-nav":"_content-type-nav_168jc_8","title-wrapper":"_title-wrapper_168jc_18","pagination-controls":"_pagination-controls_168jc_24",seasonGrid:zn},jn=[{value:"anime",label:"Anime"},{value:"manga",label:"Manga"},{value:"tv",label:"TV & Movies"},{value:"asmr",label:"ASMR"}],yr=()=>{const n=kt(),l=pt(),[h,t]=U.useState(1),[o,i]=B(()=>ne.getItem("home_activeTab")||"latest"),[g,s]=B(()=>ne.getItem("season_format")||"TV"),k=F(null),{data:y}=Me(h+1,g,o==="season"),{titlePreference:N}=Ve(),{contentType:p,setContentType:c}=mt(),[r,w]=U.useState(null),C=gt(),{data:S=[]}=vt(),d=_t(),m=yt(),u=bt();P(()=>{document.title="Home - dango"},[]);const{data:b,isLoading:A}=ft();P(()=>{ne.setItem("home_activeTab",o)},[o]),P(()=>{ne.setItem("season_format",g),t(1)},[g]),P(()=>{b!==void 0&&b.length===0&&o==="week"&&i("latest")},[b,o]);const{data:O,isLoading:R,fetchNextPage:E,hasNextPage:L,isFetchingNextPage:V}=Tt(),z=x(()=>{L&&!V&&!R&&E()},[L,V,R,E]),{data:I,isLoading:G}=Nt(),{data:H,isLoading:a}=Ke("all","week",1,p==="tv"),{data:f,isLoading:T}=zt(p==="asmr"),{data:D,isLoading:X}=wt(),j=Q(()=>O?.pages||[],[O]),{data:K,isLoading:te}=Me(h,g,o==="season"),ae=14,be=K&&K.length>=ae&&y&&y.length>0,fe=Ct(l.continueWatching.remove.mutationOptions({onSuccess:async()=>{n.invalidateQueries(l.continueWatching.pathFilter()),await n.invalidateQueries({queryKey:[Oe.continueWatching]}),L&&j.length-1<14&&E()}})),se=x(q=>{const Y=j?.find(Te=>String(Te.id)===String(q));if(Y){const Te=Y[N]||Y.name;w({id:q,name:Te})}},[j,N]),Re=[{key:"latest",label:"Latest Releases"},{key:"season",label:"Current Season"},{key:"popular",label:"Trending"}],Le=b!==void 0&&b.length>0,Ze=Le?[{key:"week",label:"This Week"},...Re]:Re,$e=o==="week"&&!Le?"latest":o,Je=()=>{switch($e){case"latest":return e(ga,{eyebrow:"Fresh episodes"});case"season":return e("section",{style:{marginBottom:"2.5rem"},children:[e("div",{className:le["section-header"],ref:k,children:[e("div",{className:le["title-wrapper"],children:e("div",{className:"title-stack",children:[e("div",{className:"section-eyebrow",children:"This season"}),e("div",{className:"section-title",style:{marginBottom:0},children:"Current Season"})]})}),e("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e(J,{ariaLabel:"Season format",width:90,value:g,onChange:s,options:[{value:"TV",label:"TV"},{value:"ONA",label:"ONA"},{value:"OVA",label:"OVA"},{value:"MOVIE",label:"Movie"},{value:"ALL",label:"All"},{value:"ADULT",label:"Mature"}]}),e("div",{className:le["pagination-controls"],children:e(It,{page:h,canGoNext:be,onChange:q=>{if(t(q),k.current){const Y=k.current.getBoundingClientRect().top+window.scrollY-120;window.scrollTo({top:Y,behavior:"smooth"})}},isLoading:te})})]})]}),e("div",{className:`grid-container ${le.seasonGrid}`,style:{minHeight:"300px",alignContent:"start"},children:te?e(ze,{count:ae}):K?.slice(0,ae).map(q=>e(ce,{anime:q},q._id))})]});case"popular":return e(ha,{title:"Trending",eyebrow:"Discover"});case"week":return e(Pe,{title:"This Week",eyebrow:"Aired this week",animeList:b||[],continueWatching:!1,carousel:!0,loading:A});default:return null}};return e("div",{style:{paddingBottom:"2rem"},children:[p==="anime"&&(G&&!I?.length?e(ue,{}):I&&I.length>0&&e(fn,{animeList:I})),p==="tv"&&(a&&!H?.results?.length?e(ue,{}):H?.results&&H.results.length>0&&e(Wn,{items:H.results})),p==="manga"&&(X&&!D?.length?e(ue,{}):D&&D.length>0&&e(On,{mangaList:D})),p==="asmr"&&(T&&!f?.length?e(ue,{}):f&&f.length>0&&e(Fn,{works:f})),e("div",{className:le["content-type-nav"],children:e(me,{ariaLabel:"Content type",options:jn,value:p,onChange:c})}),p==="manga"?e(Mn,{}):p==="tv"?e(En,{}):p==="asmr"?e(qn,{}):e(oe,{children:[e(Pe,{title:"Continue Watching",eyebrow:"Pick up where you left off",titleLink:"/watchlist/Continue Watching",animeList:j,continueWatching:!0,carousel:!0,collapsible:!0,defaultExpanded:j.length>0,onRemove:se,loading:R,onReachThreshold:z,scrollThreshold:.7,isFetchingNextPage:V,emptyState:e(ye,{icon:"history",text:"You haven't watched anything yet. Start exploring and watch something first!",actionLabel:"Explore Trending",onAction:()=>i("popular")})}),e(Rt,{title:"Queue",eyebrow:"Up next",items:S,onRemove:q=>d.mutate({showId:q.showId,episodeNumber:q.episodeNumber}),showClearAll:!0,onClear:()=>m.mutate(),onReorder:q=>u.mutate(q.map(Y=>({id:Y.id,showId:Y.showId,episodeNumber:Y.episodeNumber})))}),e(me,{ariaLabel:"Browse anime",options:Ze.map(q=>({value:q.key,label:q.label})),value:$e,onChange:i}),e("div",{children:Je()}),e(Ea,{eyebrow:"Never miss an episode"}),e(Ge,{isOpen:!!r,itemName:r?.name,progressKind:"watch",listLabel:"my watchlist",onClose:()=>{w(null)},onConfirm:q=>{r&&(fe.mutate({showId:r.id}),q&&C.mutate({id:r.id}))}})]})]})};export{yr as default};
@@ -1,56 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-DnFjoot8.js","assets/vendor-core-DfaOB3Rn.js","assets/index-npJ4Ahxa.js","assets/vendor-query-BBT5_sHx.js","assets/vendor-icons-DrybRNxP.js","assets/index-Ej7BS74s.css","assets/OptionListMenu-ClUReC8J.js","assets/useWatchAlongPlayer-CRf0zHFj.js","assets/PlayerProvider-DzaMVhFX.js","assets/PlayerProvider-ZeplRma-.css","assets/playbackCompletion-DB_c1lex.js","assets/useWatchAlongPlayer-CzQyysyL.css","assets/PlayerSettings-CbGkvNJq.css"])))=>i.map(i=>d[i]);
2
- import{u as t,g as ct,h as U,P as er,z as tr,d as ie,A as R,q,y as rr,T as Ce,o as nr,a as sr,c as or,_ as ar,S as it}from"./vendor-core-DfaOB3Rn.js";import{p as J,a2 as Bt,a3 as Ze,o as ir,q as ae,t as me,J as Pe,a4 as lr,a5 as ze,Q as ut,a6 as cr,e as ur,x as dr,y as mr,z as pr,A as fr,d as hr,u as vr,B as lt,a7 as gr,a8 as br,f as yr}from"./index-npJ4Ahxa.js";import{P as Sr,a as kr,b as Er,F as wr,s as Tr,c as Cr}from"./PlayerProvider-DzaMVhFX.js";import{u as Dt,b as At,a as kt}from"./vendor-query-BBT5_sHx.js";import{p as wt,s as Mr,C as Rr,a as Nr,P as Pr,b as Fe,c as xt,f as $t,d as _r,e as Ar,g as xr,r as Lr,u as Br,h as Dr,i as $r,j as Ir,k as Fr,l as Or,m as Wr,n as Ur,o as Te,A as Vr,q as Qr,R as Kr,E as qr,t as Gr,v as S,w as zr,x as Hr,y as jr}from"./useWatchAlongPlayer-CRf0zHFj.js";import{I as be}from"./vendor-icons-DrybRNxP.js";import{l as Yr,i as dt,s as Xr}from"./playbackCompletion-DB_c1lex.js";import{M as Jr}from"./MatureConsentModal-BrKd4CBZ.js";import{u as Zr}from"./useIsMobile-Dvx1uJ82.js";import{s as Ne,Q as en}from"./QueueRail-BMLyoeAe.js";import{u as tn,Q as rn}from"./QueueOptionsButton-BdAz_Gn-.js";import{u as It}from"./useProviders-DphwZjpZ.js";import{A as nn}from"./AnimeMetaDetails-B3-A7O5H.js";import{S as sn}from"./SynopsisText-B3Sa5pRv.js";import{W as on}from"./WatchAlongPanel-CvUFCFll.js";import"./vendor-ui-3qrARCPr.js";const an="_controlsOverlay_6uapd_1",ln="_hidden_6uapd_21",cn="_topControls_6uapd_27",un="_backBtn_6uapd_47",dn="_videoTitleInfo_6uapd_67",mn="_animeTitle_6uapd_73",pn="_episodeNumber_6uapd_83",fn="_bottomControls_6uapd_91",hn="_progressBarContainer_6uapd_110",vn="_progressBar_6uapd_110",gn="_thumb_6uapd_129",bn="_scrubbing_6uapd_144",yn="_watchedBar_6uapd_148",Sn="_bufferedBar_6uapd_149",kn="_timeBubble_6uapd_191",En="_skipSegment_6uapd_225",wn="_op_6uapd_235",Tn="_mixed_op_6uapd_236",Cn="_ed_6uapd_240",Mn="_mixed_ed_6uapd_241",Rn="_recap_6uapd_245",Nn="_mixed_recap_6uapd_246",Pn="_bottomControlsRow_6uapd_250",_n="_leftControls_6uapd_258",An="_rightControls_6uapd_259",xn="_controlBtn_6uapd_266",Ln="_theaterBtn_6uapd_307",Bn="_nextEpisodeBtn_6uapd_311",Dn="_active_6uapd_332",$n="_timeDisplay_6uapd_336",In="_skipControls_6uapd_344",L={controlsOverlay:an,hidden:ln,topControls:cn,backBtn:un,videoTitleInfo:dn,animeTitle:mn,episodeNumber:pn,bottomControls:fn,progressBarContainer:hn,progressBar:vn,thumb:gn,scrubbing:bn,watchedBar:yn,bufferedBar:Sn,timeBubble:kn,skipSegment:En,op:wn,mixed_op:Tn,ed:Cn,mixed_ed:Mn,recap:Rn,mixed_recap:Nn,bottomControlsRow:Pn,leftControls:_n,rightControls:An,controlBtn:xn,theaterBtn:Ln,nextEpisodeBtn:Bn,active:Dn,timeDisplay:$n,skipControls:In},Fn=({player:r,handlers:o,visible:c,skipIntervals:m,showNextEpisodeButton:T,onNextEpisode:a,isTheaterMode:s,onTheaterModeToggle:n,settingsBtnRef:i,timeDisplayRef:p})=>{const{state:y,actions:f}=r,{showSettings:E}=y;return t("div",{className:`${L.controlsOverlay} ${c?"":L.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:L.bottomControls,"data-speed-boost-ignore":"true",onClick:w=>w.stopPropagation(),children:[t(Sr,{classes:{container:L.progressBarContainer,scrubbing:L.scrubbing,timeBubble:L.timeBubble,bar:L.progressBar,buffered:L.bufferedBar,watched:L.watchedBar,thumb:L.thumb},timeLabelRef:p,children:[y.duration>0&&r.state.currentSkipInterval&&t("div",{className:`${L.skipSegment} ${L[r.state.currentSkipInterval.skip_type]} `,style:{left:`${r.state.currentSkipInterval.start_time/y.duration*100}% `,width:`${(r.state.currentSkipInterval.end_time-r.state.currentSkipInterval.start_time)/y.duration*100}% `}}),m.map(w=>{const e=w.start_time/y.duration*100,v=(w.end_time-w.start_time)/y.duration*100;return t("div",{className:`${L.skipSegment} ${L[w.skip_type]} `,style:{left:`${e}% `,width:`${v}% `},title:w.skip_type.toUpperCase()},w.skip_id)})]}),t("div",{className:L.bottomControlsRow,children:[t("div",{className:L.leftControls,children:[t(kr,{className:L.controlBtn}),t(Er,{buttonClassName:L.controlBtn,onExpandedChange:f.setShowVolumeSlider}),t("span",{className:L.timeDisplay,ref:p,children:[f.formatTime(0)," / ",f.formatTime(y.duration)]}),y.currentSkipInterval&&!y.isAutoSkipEnabled&&!y.playbackLocked&&t("button",{className:L.controlBtn,onClick:()=>{y.currentSkipInterval&&(r.engine.seek(y.currentSkipInterval.end_time),f.setCurrentSkipInterval(null))},children:["Skip ",y.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),t("div",{className:L.rightControls,children:[t("div",{className:L.skipControls,children:T&&t("button",{className:L.nextEpisodeBtn,onClick:a,title:"Play next episode",children:"Next EP"})}),t("button",{className:`${L.controlBtn} ${o.isSubtitleActive?L.active:""}`,onClick:o.handleCCToggle,title:o.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:t(be,{name:"closed-captioning",size:22})}),t("button",{ref:i,className:`${L.controlBtn} ${E?L.active:""} `,onClick:()=>f.setShowSettings(!E),"aria-label":"Settings",children:t(be,{name:"cog"})}),t("button",{className:`${L.controlBtn} ${L.theaterBtn} ${s?L.active:""} `,onClick:w=>{w.stopPropagation(),n()},title:s?"Exit Theater Mode":"Theater Mode","aria-label":s?"Exit Theater Mode":"Theater Mode",children:t(be,{name:"tv"})}),t(wr,{className:L.controlBtn})]})]})]})})};function On(r){const{state:o,refs:c,actions:m}=r,T=n=>{if(!c.videoRef.current)return;m.setActiveSubtitleTrack(n);try{if(n===null||n==="off")J.setItem("playerSubtitlesEnabled","false");else{J.setItem("playerSubtitlesEnabled","true");const p=o.availableSubtitles.find(y=>y.label===n||y.lang===n);p?J.setItem("playerLastSubtitle",Mr(p)):J.setItem("playerLastSubtitle",n)}}catch{}let i=!1;Array.from(c.videoRef.current.textTracks).forEach(p=>{const f=n!==null&&n!=="off"&&(p.language===n||p.label===n)&&!i;p.mode=f?"showing":"hidden",f&&(i=!0)})},a=o.activeSubtitleTrack!==null&&o.activeSubtitleTrack!=="off";return{handleSubtitleSelection:T,isSubtitleActive:a,handleCCToggle:()=>{if(!c.videoRef.current)return;if(a){T("off");return}if(o.availableSubtitles.length===0)return;let n=null;try{n=J.getItem("playerLastSubtitle")}catch{}const i=wt(o.availableSubtitles,{lastKey:n,enabled:!0});if(i<0)return;const p=o.availableSubtitles[i];T(p.label||p.lang)}}}const Wn=tr(()=>Bt(()=>import("./PlayerSettings-DnFjoot8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),Un=({player:r,isAutoplayEnabled:o,onAutoplayChange:c,showNextEpisodeButton:m,onNextEpisode:T,videoSources:a,selectedSource:s,selectedLink:n,onSourceChange:i,loadingVideo:p,skipIntervals:y,animeTitle:f,episodeNumber:E,mode:w,isTheaterMode:e,onTheaterModeToggle:v,anime4kEnabled:N,onAnime4kToggle:_,anime4kSupported:x,anime4kProfile:g,onAnime4kProfileChange:d,anime4kInitializing:P,anime4kError:A,videoDelayEnabled:F,onVideoDelayToggle:V,videoDelayMs:b,onVideoDelayChange:h,onCalibrateAvSync:O,fallbackChoice:z,onFallbackChoiceChange:D,ambientSettings:B,onAmbientChange:H,children:j,overlays:pe,isInteractingExtra:$=!1,className:Q,hideChrome:ee=!1})=>{const{state:l,actions:M}=r,{showSettings:k}=l,{setShowSettings:C}=M,W=On(r),Y=ct.useRef(null),Me=ct.useRef(null),_e=ct.useRef(null);U(()=>{const le=xe=>{Y.current&&!Y.current.contains(xe.target)&&Me.current&&!Me.current.contains(xe.target)&&k&&C(!1)};return k&&document.addEventListener("mousedown",le),()=>{document.removeEventListener("mousedown",le)}},[k,C]);const ne=l.showControls||k||l.isScrubbing,X=l.activeSubtitleTrack!=="off"?l.availableSubtitles.find(le=>le.lang===l.activeSubtitleTrack||le.label===l.activeSubtitleTrack):void 0,Ae=t(Rr,{visible:ne,title:f,episode:E?`Episode ${E}`:void 0,mode:w,server:p?void 0:s?.sourceName,subtitles:p?void 0:X?.label||X?.lang,onBack:()=>window.history.back(),classes:{overlay:L.controlsOverlay,hidden:L.hidden,top:L.topControls,backBtn:L.backBtn,titleInfo:L.videoTitleInfo,title:L.animeTitle,episode:L.episodeNumber}}),De=!p&&!l.isBuffering&&l.duration>0?t(Nr,{}):null,se=t(Fn,{player:r,handlers:W,visible:ne,skipIntervals:y,showNextEpisodeButton:m,onNextEpisode:T,isTheaterMode:e,onTheaterModeToggle:v,settingsBtnRef:Me,timeDisplayRef:_e}),K=t(er,{fallback:null,children:t(Wn,{ref:Y,isOpen:k,onClose:()=>C(!1),videoSources:a,currentSource:s,currentLink:n,onSourceChange:i,subtitles:l.availableSubtitles,activeSubtitleTrack:l.activeSubtitleTrack,onSubtitleChange:W.handleSubtitleSelection,subtitleSettings:{fontSize:l.subtitleFontSize,position:l.subtitlePosition,bgOpacity:l.subtitleBgOpacity,bgColor:l.subtitleBgColor,textColor:l.subtitleTextColor,edge:l.subtitleEdge,bold:l.subtitleBold},onSubtitleSettingsChange:M.setSubtitleStyle,useNativeControls:!l.playbackLocked&&l.useNativeControls,onNativeControlsToggle:M.setUseNativeControls,anime4kEnabled:N,onAnime4kToggle:_,anime4kSupported:x,anime4kProfile:g,onAnime4kProfileChange:d,anime4kInitializing:P,anime4kError:A,videoDelayEnabled:F,onVideoDelayToggle:V,videoDelayMs:b,onVideoDelayChange:h,onCalibrateAvSync:O,isAutoSkipEnabled:l.isAutoSkipEnabled,onAutoSkipChange:le=>{M.setIsAutoSkipEnabled(le);try{J.setItem("autoSkipEnabled",le.toString())}catch{}},isAutoplayEnabled:o,onAutoplayChange:c,fallbackChoice:z,onFallbackChoiceChange:D,isTheaterMode:e,ambientSettings:B,onAmbientChange:H})}),fe=k?t("div",{"data-speed-boost-ignore":"true",onClick:le=>le.stopPropagation(),children:K}):null;return t(Pr,{engine:r.engine,topBar:Ae,centerControls:De,bottomBar:!p&&l.duration>0?se:null,settingsPanel:fe,overlays:pe,isInteracting:$||l.showSettings||l.showVolumeSlider,nativeControls:!l.playbackLocked&&l.useNativeControls,className:Q,chromeDisabled:ee,children:j})},Vn=({count:r=3})=>t("section",{className:Ne.section,children:[t("div",{className:Ne.header,children:t("button",{className:Ne.headerToggle,disabled:!0,children:[t("span",{className:Ne.title,children:t(Ze,{width:"60px",height:"1.2rem",variant:"text"})}),t(be,{name:"chevron-down",style:{opacity:.3}})]})}),t("div",{className:Ne.list,children:Array.from({length:r}).map((o,c)=>t("div",{className:Ne.item,style:{pointerEvents:"none"},children:[t("div",{className:Ne.dragHandle,style:{opacity:.2},children:t(Ze,{width:"16px",height:"16px",variant:"rectangular"})}),t("div",{className:Ne.thumbnail,style:{overflow:"hidden",background:"transparent"},children:t(Ze,{width:"100%",height:"100%",variant:"rectangular"})}),t("div",{className:Ne.meta,children:[t(Ze,{width:"80%",height:"1.2rem",variant:"text",className:Ne.metaGap}),t(Ze,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},c))})]}),Qn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Kn={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},qn=["direct","cookie","embed"],Gn=({selectedProvider:r,onProviderChange:o,isAdult:c,options:m})=>{const a=(m&&m.length>0?m:[]).filter(s=>s.mature===(c===!0));return t("div",{className:Fe.providerSelectContainer,children:[t("h4",{children:"Provider"}),t("select",{className:Fe.providerSelect,value:r,onChange:s=>o(s.currentTarget.value),children:qn.map(s=>{const n=a.filter(i=>(i.tier??"direct")===s);return n.length===0?null:t("optgroup",{label:Kn[s],children:n.map(i=>t("option",{value:i.id,children:i.sub?`${i.label} (${Qn[i.sub]})`:i.label},i.id))},s)})})]})},zn=({videoSources:r,selectedSource:o,selectedLink:c,onSourceChange:m,onLinkChange:T})=>{const a=Array.isArray(r)?r:[];if(a.length===0)return null;const s=o?.type==="iframe"&&(o.links?.length??0)>1;return t("div",{className:Fe.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:Fe.sourceButtons,children:a.map((n,i)=>t("button",{className:`${Fe.sourceButton} ${o?.sourceName===n.sourceName?Fe.active:""} `,onClick:()=>m(n),children:n.sourceName},`${n.sourceName}-${i}`))}),s&&t("select",{className:Fe.sourceSelect,"aria-label":"Fallback embed quality",value:c?.link??o.links[0]?.link??"",onChange:n=>{const i=o.links.find(p=>p.link===n.currentTarget.value);i&&T(i)},children:o.links.map(n=>t("option",{value:n.link,children:n.resolutionStr},n.link))})]})},Hn=ct.memo(zn,(r,o)=>r.selectedSource?.sourceName===o.selectedSource?.sourceName&&r.selectedLink?.link===o.selectedLink?.link&&r.videoSources===o.videoSources),jn={low:{sd:1.5,hd:1.3,fhd:1.25},balanced:{sd:2,hd:1.5,fhd:1.25},high:{sd:2.5,hd:2,fhd:1.5},denoise:{sd:1.5,hd:1.5,fhd:1.5}},Yn={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Xn=5,Jn=15e3,Zn=`
3
- @group(0) @binding(0) var extTex: texture_external;
4
- @group(0) @binding(1) var extSamp: sampler;
5
- struct VSOut {
6
- @builtin(position) pos: vec4f,
7
- @location(0) uv: vec2f,
8
- };
9
- @vertex
10
- fn vs(@builtin(vertex_index) idx: u32) -> VSOut {
11
- var positions = array<vec2f, 6>(
12
- vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
13
- vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
14
- );
15
- var uvs = array<vec2f, 6>(
16
- vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
17
- vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
18
- );
19
- var out: VSOut;
20
- out.pos = vec4f(positions[idx], 0.0, 1.0);
21
- out.uv = uvs[idx];
22
- return out;
23
- }
24
- @fragment
25
- fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
26
- return textureSampleBaseClampToEdge(extTex, extSamp, uv);
27
- }
28
- `;function es({videoRef:r,canvasRef:o,profile:c="balanced",delayMs:m=0}){const[T,a]=ie(!1),[s,n]=ie(()=>{try{return J.getItem("anime4kEnabled")==="true"}catch{return!1}}),[i,p]=ie(!1),[y,f]=ie(null),[E,w]=ie(0),e=R(0),v=R(null),N=R(null),_=R(null),x=R(null),g=R(null),d=R(null),P=R(null),A=R(null),F=R(null),V=R(!1),b=R(-1),h=R(0),O=R(m);O.current=m;const z=R([]),D=R(!1),B=R(!1),H=R(!1),j=R(null),pe=R(-1),$=R(-1),Q=R(!1),ee=R(0);U(()=>{async function k(){if(typeof navigator>"u"||!navigator.gpu){a(!1);return}try{const C=await navigator.gpu.requestAdapter();a(!!C)}catch{a(!1)}}k()},[]),U(()=>{if(!s||!T)return;let k=!1;const C=++e.current,W=X=>{if(X)try{X.close()}catch{}},Y=()=>{for(const X of z.current)W(X.bitmap);z.current=[]},Me=X=>Math.max(8,Math.min(40,Math.ceil(X/16.7)+4));function _e(){F.current!==null&&(cancelAnimationFrame(F.current),F.current=null)}async function ne(){let X=r.current;const Ae=o.current;if(!X||!Ae||e.current!==C)return;const De=performance.now()+Jn;for(;(!X||X.videoWidth===0)&&performance.now()<De;){if(await new Promise(de=>requestAnimationFrame(de)),k||e.current!==C)return;X=r.current}if(!X||X.videoWidth===0){!k&&e.current===C&&(f("Timed out waiting for video metadata"),p(!1),n(!1));return}const se=X.videoWidth,K=X.videoHeight,fe=Math.max(se,K),le=window.innerWidth,xe=window.innerHeight,He=Math.max(le,xe),je=fe<He?He/fe:1,Oe=jn[c],mt=fe<=480?Oe.sd:fe<=720?Oe.hd:fe<=1080?Oe.fhd:1,Re=Math.min(mt,je);Ae.width=Math.round(se*Re),Ae.height=Math.round(K*Re),p(!0),f(null),h.current=0,b.current=-1,pe.current=-1,$.current=-1,Q.current=!1,ee.current=0,Y(),V.current=!1;try{let de=function(){k||e.current!==C||(_e(),F.current=requestAnimationFrame(()=>{gt()}))};const{ModeA:tt,ModeB:pt,ModeC:ft,ModeAA:ye}=await Bt(async()=>{const{ModeA:G,ModeB:te,ModeC:Se,ModeAA:ce}=await import("./index-BOKlZEHq.js").then(ue=>ue.i);return{ModeA:G,ModeB:te,ModeC:Se,ModeAA:ce}},[]);if(k||e.current!==C)return;if(!navigator.gpu)throw new Error("WebGPU not available");const Ye=await navigator.gpu.requestAdapter();if(k||e.current!==C)return;if(!Ye)throw new Error("No GPU adapter found");const I=await Ye.requestDevice();if(!I)throw new Error("Failed to get GPU device");if(k||e.current!==C){I.destroy();return}v.current=I;const he=Ae.getContext("webgpu");if(!he)throw new Error("Failed to get WebGPU context");N.current=he;const Xe=navigator.gpu.getPreferredCanvasFormat();he.configure({device:I,format:Xe,alphaMode:"premultiplied"});const ve=I.createTexture({size:[se,K],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),ht=Yn[c],We=Math.round(se*Re),$e=Math.round(K*Re),Ue=(()=>{switch(ht){case"ModeB":return new pt({device:I,inputTexture:ve,nativeDimensions:{width:se,height:K},targetDimensions:{width:We,height:$e}});case"ModeC":return new ft({device:I,inputTexture:ve,nativeDimensions:{width:se,height:K},targetDimensions:{width:We,height:$e}});case"ModeAA":return new ye({device:I,inputTexture:ve,nativeDimensions:{width:se,height:K},targetDimensions:{width:We,height:$e}});default:return new tt({device:I,inputTexture:ve,nativeDimensions:{width:se,height:K},targetDimensions:{width:We,height:$e}})}})(),rt=Ue.getOutputTexture(),Ve=I.createSampler({magFilter:"linear",minFilter:"linear"}),nt=I.createShaderModule({code:`
29
- @group(0) @binding(0) var tex: texture_2d<f32>;
30
- @group(0) @binding(1) var samp: sampler;
31
- struct VertexOutput {
32
- @builtin(position) pos: vec4f,
33
- @location(0) uv: vec2f,
34
- }
35
- @vertex
36
- fn vs(@builtin(vertex_index) idx: u32) -> VertexOutput {
37
- var positions = array<vec2f, 6>(
38
- vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
39
- vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
40
- );
41
- var uvs = array<vec2f, 6>(
42
- vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
43
- vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
44
- );
45
- var out: VertexOutput;
46
- out.pos = vec4f(positions[idx], 0.0, 1.0);
47
- out.uv = uvs[idx];
48
- return out;
49
- }
50
- @fragment
51
- fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
52
- return textureSample(tex, samp, uv);
53
- }
54
- `}),Qe=I.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),st=I.createRenderPipeline({layout:I.createPipelineLayout({bindGroupLayouts:[Qe]}),vertex:{module:nt,entryPoint:"vs"},fragment:{module:nt,entryPoint:"fs",targets:[{format:Xe}]},primitive:{topology:"triangle-list"}}),Ke=I.createBindGroup({layout:Qe,entries:[{binding:0,resource:rt.createView()},{binding:1,resource:Ve}]});try{const G=I.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),te=I.createShaderModule({code:Zn}),Se=I.createRenderPipeline({layout:I.createPipelineLayout({bindGroupLayouts:[G]}),vertex:{module:te,entryPoint:"vs"},fragment:{module:te,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});j.current={pipeline:Se,layout:G,inputView:ve.createView()}}catch{j.current=null}_.current=Ue,x.current=ve,g.current=rt,d.current=st,P.current=Ve,A.current=Qe,B.current=!1,H.current=!1;async function vt(){const G=j.current;if(!G||B.current)return!1;const te=r.current;if(!te)return!1;const Se=!H.current;Se&&I.pushErrorScope("validation");try{const ce=I.importExternalTexture({source:te}),ue=I.createBindGroup({layout:G.layout,entries:[{binding:0,resource:ce},{binding:1,resource:Ve}]}),re=I.createCommandEncoder(),ke=re.beginRenderPass({colorAttachments:[{view:G.inputView,loadOp:"load",storeOp:"store"}]});ke.setPipeline(G.pipeline),ke.setBindGroup(0,ue),ke.draw(6),ke.end(),I.queue.submit([re.finish()])}catch{return B.current=!0,j.current=null,!1}if(Se){const ce=await I.popErrorScope().catch(()=>null);if(ce)return console.warn("[anime4k] blit probe failed:",ce.message),B.current=!0,j.current=null,!1;H.current=!0}return!0}p(!1);async function gt(){if(k||e.current!==C||!he)return;const G=r.current;if(!G||G.videoWidth===0){de();return}if(G!==X||G.videoWidth!==se||G.videoHeight!==K){w(ue=>ue+1);return}if(G.paused||G.ended||document.hidden||G.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){de();return}const te=G.getVideoPlaybackQuality().totalVideoFrames;if(te===$.current){de();return}if(V.current){de();return}const Se=G.currentTime;(G.seeking||pe.current>=0&&Math.abs(Se-pe.current)>.5)&&(Y(),Q.current=!1,ee.current=0,$.current=-1),pe.current=Se;const ce=Math.max(0,O.current||0);ce>ee.current&&(Q.current=!1),V.current=!0;try{const ue=performance.now();let re=null,ke=!1;if(ce<=0){z.current.length>0&&Y(),Q.current=!1,ee.current=0;let Ee=!1;if(!D.current)try{I.queue.copyExternalImageToTexture({source:G},{texture:ve},[se,K]),$.current=te,Ee=!0}catch(oe){if(oe instanceof TypeError)D.current=!0;else throw oe}if(!Ee&&!B.current&&j.current&&await vt()&&($.current=te,Ee=!0),!Ee){const oe=await createImageBitmap(G);$.current=te,I.queue.copyExternalImageToTexture({source:oe},{texture:ve},[se,K]),W(oe)}}else{const Ee=await createImageBitmap(G);$.current=te;const oe=z.current;oe.push({bitmap:Ee,capture:ue});const bt=Me(ce);for(;oe.length>bt;)W(oe.shift()?.bitmap);let Je=-1;for(let ge=oe.length-1;ge>=0;ge--)if(ue-oe[ge].capture>=ce){Je=ge;break}if(Je!==-1){for(let ot=0;ot<Je;ot++)W(oe.shift()?.bitmap);const ge=oe.shift();ge?(re=ge.bitmap,Q.current=!0,ee.current=ce):(re=Ee,ke=!0)}else if(!Q.current)re=Ee,ke=!0;else{const ge=oe.shift();re=ge?ge.bitmap:Ee,ge||(ke=!0)}if(!re){V.current=!1,de();return}I.queue.copyExternalImageToTexture({source:re},{texture:ve},[se,K]),ke||W(re)}const qe=I.createCommandEncoder();await Ue.pass(qe);const Ge=qe.beginRenderPass({colorAttachments:[{view:he.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});Ge.setPipeline(st),Ge.setBindGroup(0,Ke),Ge.draw(6),Ge.end(),I.queue.submit([qe.finish()]),b.current=te,h.current=0,I.queue.onSubmittedWorkDone().then(()=>{e.current===C&&(V.current=!1)})}catch(ue){if(V.current=!1,h.current+=1,h.current>=Xn&&!k&&e.current===C){console.error(ue),f(ue instanceof Error?ue.message:"Render error"),n(!1);return}}de()}de()}catch(de){!k&&e.current===C&&(N.current?.unconfigure(),v.current?.destroy(),v.current=null,N.current=null,f(de instanceof Error?de.message:"Failed to initialize upscaler"),p(!1),n(!1))}}return ne(),()=>{k=!0,e.current+=1,_e(),Y(),N.current?.unconfigure(),x.current&&(x.current.destroy(),x.current=null),g.current&&(g.current.destroy(),g.current=null),v.current&&(v.current.destroy(),v.current=null),_.current=null,d.current=null,P.current=null,A.current=null,j.current=null,N.current=null,V.current=!1}},[s,T,r,o,c,E]);const l=q(k=>{n(k);try{J.setItem("anime4kEnabled",String(k))}catch{}},[]),M=q(()=>{n(k=>{const C=!k;try{J.setItem("anime4kEnabled",String(C))}catch{}return C})},[]);return{isWebGPUSupported:T,isEnabled:s,isInitializing:i,error:y,toggle:M,setEnabled:l}}function ts({videoRef:r,episodeKey:o,isEnabled:c,isSupported:m,mediaReady:T,isIframeSource:a,setEnabled:s}){const n=R(null),i=R(!1),p=R(!1),y=R(s);y.current=s,U(()=>{const f=n.current;n.current=o,!(f===null||f===o)&&(!c||!m||(i.current=!0,p.current=!1,y.current(!1)))},[o,c,m]),U(()=>{if(!i.current)return;if(c){p.current&&(i.current=!1);return}if(p.current=!0,!T)return;if(a){i.current=!1,y.current(!0);return}const f=r.current;if(!f)return;let E,w=!1;const e=()=>{w||(w=!0,i.current=!1,y.current(!0))};if(f.readyState>=2)return E=window.setTimeout(e,500),()=>window.clearTimeout(E);const v=()=>{window.setTimeout(e,500)};return f.addEventListener("canplay",v,{once:!0}),f.addEventListener("playing",v,{once:!0}),E=window.setTimeout(e,5e3),()=>{window.clearTimeout(E),f.removeEventListener("canplay",v),f.removeEventListener("playing",v)}},[c,T,a,r])}const rs=()=>J.getItem("preferredMode")==="dub"?"dub":"sub",ns=/^[a-z0-9-]+$/i,Ft=r=>r?"preferredProviderMature":"preferredProvider",Ot=r=>{const o=J.getItem(Ft(r));return o&&ns.test(o)?o:null},Wt=(r,o)=>{J.setItem(Ft(o),r)},ss=()=>Ot(!1)??"megaplay",os=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:rs(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:Yr(),showResumeModal:!0,resumeProgressPending:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:ss(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function as(r,o){switch(o.type){case"SET_STATE":return{...r,...o.payload};case"SET_MODE":return{...r,currentMode:o.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...r,selectedProvider:o.payload};default:return r}}async function Lt(r,o,c,m,T=!1){if(!r||!o)throw new Error("Missing params");try{const[a,s,n,i]=await Promise.all([me.data.video.query({showId:r,episodeNumber:o,mode:c.currentMode,provider:c.selectedProvider}).catch(g=>{const d=g.data?.cause;return g.message==="AUTH_REQUIRED"&&d?.provider==="mkissa"&&m({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:"mkissa"}}),null}),me.progress.getEpisode.query({showId:r,episodeNumber:o}).catch(()=>null),me.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),me.data.skipTimes.query({showId:r,episodeNumber:o}).catch(()=>[])]),p=n?.value,y=a?.filter(g=>{const d=g.sourceName.toLowerCase();return c.currentMode==="dub"?d.includes("eng")||d.includes("dub"):d.includes("jpn")||d.includes("sub")||!d.includes("eng")&&!d.includes("dub")})??[],f=y.length>0?y:a??[];let E=f.length>0?f[0]:null;if(p){const g=f.find(d=>d.sourceName===p);g&&(E=g)}const w=E&&E.links.length>0?E.links.sort((g,d)=>(parseInt(d.resolutionStr)||0)-(parseInt(g.resolutionStr)||0))[0]:null,e=s?.currentTime||0,v=s?.duration||0,N=e,x=(Array.isArray(i)?i:i?.results||[]).map(g=>({skip_id:g.skip_id||"",skip_type:g.skip_type||"",start_time:g.interval?.start_time??g.start_time??0,end_time:g.interval?.end_time??g.end_time??0})).filter(g=>g.end_time>0);return(!a||a.length===0)&&(T||Pe.error(`No video sources found for ${c.selectedProvider}`)),{videoSources:a,selectedSource:E,selectedLink:w,resumeTime:N,resumeDuration:v,showResumeModal:N>5&&!dt(N,v)&&E?.type!=="iframe",skipIntervals:x,fetchedEpisodeNumber:o}}catch(a){const s=a;if(s.message==="AUTH_REQUIRED")return m({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:s.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:o};throw a}}const is=(r,o,c,m)=>{const[T,a]=rr(as,c,l=>({...os(),showMeta:l?.name?{name:l.name,thumbnail:l.thumbnail,nativeName:l.nativeName,englishName:l.englishName,names:{romaji:l.name||l.englishName,english:l.englishName||l.name,native:l.nativeName}}:{}})),s=m?.watchSelection,n=Ce(()=>s?{...T,selectedProvider:s.provider,currentMode:s.mode}:T,[T,s]),i=Dt(),p=ir(),y=R(null),f=R(null),{options:E}=It(),w=Ce(()=>E.filter(l=>(l.kind??"anime")==="anime"),[E]),e=o||n.initialEpisode,v=`${r}:${e}`,N=R(v);U(()=>{N.current!==v&&(N.current=v,a({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[v,a]),U(()=>{!s&&r&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)&&n.selectedProvider!=="animepahe"&&y.current!==r&&(y.current=r,a({type:"SET_PROVIDER",payload:"animepahe"}))},[r,n.selectedProvider,s]);const{data:_,isLoading:x,error:g}=tn(r),{data:d}=At({queryKey:[ae.playerData,r,n.currentMode,n.selectedProvider],queryFn:async()=>{if(!r)throw new Error("No showId");const l=async()=>{try{const Y=await me.data.episodes.query({showId:r,mode:n.currentMode,provider:n.selectedProvider}).catch(()=>null);if(Y?.episodes?.length)return Y}catch{}return null},[M,k,C]=await Promise.all([l(),me.watchlist.check.query({showId:r}).catch(()=>({inWatchlist:!1,status:null})),me.progress.getWatchedEpisodes.query({showId:r}).catch(()=>[])]),W=M?.episodes?M.episodes.sort((Y,Me)=>parseFloat(Y)-parseFloat(Me)):[];return{description:M?.description||"",episodes:W,inWatchlist:k.inWatchlist,watchlistStatus:k.status??null,watchedEpisodes:C}},enabled:!!r});U(()=>{!o&&d?.episodes&&d.episodes.length>0&&!o&&a({type:"SET_STATE",payload:{initialEpisode:d.episodes[0]}})},[d,o]),U(()=>{if(s||_?.isAdult===void 0||f.current===r)return;const l=_.isAdult===!0,M=w.filter(C=>C.mature===l);if(M.length===0||w.find(C=>C.id===n.selectedProvider)?.mature===l)return;const k=Ot(l);f.current=r??null,a({type:"SET_PROVIDER",payload:M.find(C=>C.id===k)?.id??M[0].id})},[_?.isAdult,n.selectedProvider,r,w,s]),U(()=>{if(s||!r||!/^dango-mt-\d+$/.test(r)||f.current===`temp:${r}`)return;const l=_?.provider;l&&(f.current=`temp:${r}`,l!==n.selectedProvider&&a({type:"SET_PROVIDER",payload:l}))},[r,_,n.selectedProvider,s]);const{data:P,isLoading:A,isFetching:F,error:V}=At({queryKey:[ae.videoSources,r,e,n.selectedProvider,n.currentMode],queryFn:()=>Lt(r,e,n,a),enabled:!!r&&!!e&&!(n.showMeta?.isAdult===!0&&!m?.hasMatureConsent)}),{mutateAsync:b}=kt({mutationFn:async({wasIn:l,showMeta:M})=>{if(!r)throw new Error("Missing showId");if(l)await me.watchlist.remove.mutate({id:r});else{const k=M.name||M.names?.romaji;if(!k)throw new Error("Missing show name");await me.watchlist.add.mutate({id:r,name:k,thumbnail:M.thumbnail,nativeName:M.names?.native,englishName:M.names?.english,type:M.type,isAdult:M.isAdult})}return!l},onSuccess:l=>{Pe.success(l?"Added to watchlist":"Removed from watchlist"),i.invalidateQueries({queryKey:[ae.playerData,r]}),i.invalidateQueries({queryKey:[ae.showData,r]}),i.invalidateQueries({queryKey:[ae.watchlist]})},onError:l=>Pe.error(l instanceof Error?l.message:"Failed to update watchlist")}),h=q(async()=>{!r||!_||await b({wasIn:!!d?.inWatchlist,showMeta:_})},[r,_,d?.inWatchlist,b]),O=q(async l=>{try{await me.settings.set.mutate({key:"preferredSource",value:l})}catch(M){console.error(M)}},[]),{mutateAsync:z,isPending:D}=kt({mutationFn:async({status:l})=>{if(!r)throw new Error("Missing showId");if(d?.inWatchlist)return await me.watchlist.setStatus.mutate({id:r,status:l}),l;const M=_,k=M?.name||M?.names?.romaji;if(!M||!k)throw new Error("Missing show name");return await me.watchlist.add.mutate({id:r,name:k,thumbnail:M.thumbnail,nativeName:M.names?.native,englishName:M.names?.english,type:M.type,isAdult:M.isAdult,status:l}),l},onSuccess:l=>{a({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:l}}),Pe.success(`Moved to ${l}`),i.invalidateQueries({queryKey:[ae.showData,r]}),i.invalidateQueries({queryKey:[ae.watchlist]}),i.invalidateQueries({queryKey:[ae.continueWatching]})},onError:()=>Pe.error("Failed to update watchlist status")}),B=q(async()=>{await z({status:"Completed"})},[z]),{mutateAsync:H,isPending:j}=kt({mutationFn:async({episodeNumber:l,duration:M,showMeta:k,episodes:C})=>{await me.progress.updateProgress.mutate({showId:r??"",episodeNumber:l,currentTime:M,duration:M,showName:k.name,showThumbnail:k.thumbnail,nativeName:k.names?.native,englishName:k.names?.english,genres:k.genres?.map(W=>W.name),popularityScore:lr(k.score)??void 0,type:k.type,status:k.status,episodeCount:C.length,isAdult:k.isAdult})},onSuccess:(l,M)=>{Pe.success(`Episode ${M.episodeNumber} marked as watched`),i.invalidateQueries({queryKey:[ae.playerData,r]}),i.invalidateQueries({queryKey:[ae.showMeta,r]}),i.invalidateQueries({queryKey:[ae.videoSources,r,M.episodeNumber]}),i.invalidateQueries({queryKey:[ae.continueWatching]}),i.invalidateQueries({queryKey:[ae.thisWeekSchedule]}),i.invalidateQueries(p.continueWatching.pathFilter())},onError:()=>Pe.error("Failed to mark episode as watched")}),pe=q(async(l,M)=>{!r||!_||await H({episodeNumber:l,duration:M,showMeta:_,episodes:d?.episodes||[]})},[r,_,d?.episodes,H]),$=q(async()=>{a({type:"SET_STATE",payload:{showCombinedDetails:!n.showCombinedDetails}})},[n.showCombinedDetails]),Q=Ce(()=>{const l=g||V,M=l?l.message:null,k=M==="AUTH_REQUIRED"?null:M,C=P&&P.fetchedEpisodeNumber===e?P:null,W=!!P&&!C,Y=s?C?.videoSources?.find(ne=>ne.sourceName===s.source&&ne.type!=="iframe"&&ne.links.some(X=>X.hls))??null:null,_e=(n.selectedSource?.sourceName===Y?.sourceName?Y?.links.find(ne=>ne.hls&&ne.link===n.selectedLink?.link):null)??Y?.links.filter(ne=>ne.hls).slice().sort((ne,X)=>(parseInt(X.resolutionStr)||0)-(parseInt(ne.resolutionStr)||0))[0]??null;return{...n,currentEpisode:e,showMeta:{...n.showMeta||{},..._||{}},episodes:d?.episodes||[],watchedEpisodes:d?.watchedEpisodes||[],inWatchlist:!!d?.inWatchlist,watchlistStatus:d?.watchlistStatus??n.watchlistStatus??null,videoSources:C?.videoSources||[],selectedSource:s?Y:n.selectedSource||C?.selectedSource||null,selectedLink:s?_e:n.selectedLink||C?.selectedLink||null,resumeTime:s?0:C?.resumeTime||0,resumeDuration:C?.resumeDuration||0,resumeProgressPending:F,showResumeModal:!s&&n.showResumeModal&&(C?.showResumeModal??!1),skipIntervals:C?.skipIntervals||[],loadingShowData:x,loadingVideo:A||W,error:k,fetchedEpisodeNumber:C?.fetchedEpisodeNumber}},[n,_,d,P,x,A,F,g,V,e,s]),ee=q((l,M)=>{const k=M||r;if(!k||!l||k===r&&l===e)return;const W=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(k)&&n.selectedProvider!=="animepahe"?"animepahe":n.selectedProvider,Y=["video-sources",k,l,W,n.currentMode];i.getQueryState(Y)?.status!=="success"&&i.prefetchQuery({queryKey:Y,queryFn:()=>Lt(k,l,{selectedProvider:W,currentMode:n.currentMode},a,!0),staleTime:300*1e3,gcTime:1800*1e3})},[r,e,i,n,a]);return{state:Q,dispatch:a,toggleWatchlist:h,moveToCompleted:B,setPreferredSource:O,handleToggleDetails:$,markEpisodeWatched:pe,prefetchEpisodeSources:ee,isMarkingWatched:j,isUpdatingWatchlistStatus:D}};function ls({onPrevious:r,onNext:o,onToggleTheater:c,flashControls:m}){U(()=>{const T=a=>{a.defaultPrevented||a.ctrlKey||a.metaKey||a.altKey||a.repeat||a.target.closest('input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(a.key.toLowerCase())&&m(),a.key.toLowerCase()==="n"&&o(),a.key.toLowerCase()==="p"&&r(),a.key.toLowerCase()==="t"&&c())};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[m,o,r,c])}const et=(r,o,c)=>r.showId===o||!!c&&r.showId===c;function cs({testClipActive:r,selectedSourceType:o,onEnded:c,queue:m,removeFromQueue:T,showId:a,showMetaId:s,currentEpisode:n,isAutoplayEnabled:i,nextEpisode:p,previousEpisode:y,navigate:f,invalidateContinueWatching:E,dispatch:w}){const[e,v]=ie(!1),[N,_]=ie(null),[x,g]=ie(null),d=R(T);d.current=T;const P=R(!1);U(()=>{P.current=!1,v(!1)},[a,n]);const A=q(()=>{if(r||P.current)return;P.current=!0,c();const D=m.find(B=>et(B,a,s)&&B.episodeNumber===n);if(m.length>0){const B=m.findIndex(j=>et(j,a,s)&&j.episodeNumber===n),H=B>=0?m[B+1]||null:m[0];g({nextItem:H,playedItem:D||null}),_(2);return}if(D&&d.current({showId:D.showId,episodeNumber:D.episodeNumber}),i&&p){E(),f(`/watch/${a}/${p}`);return}p||v(!0)},[c,f,m,a,s,n,p,i,E,r]),F=q(()=>{if(m.length===0)return;c();const D=m.find(j=>et(j,a,s)&&j.episodeNumber===n),B=m.findIndex(j=>et(j,a,s)&&j.episodeNumber===n),H=B>=0?m[B+1]||null:m[0];D&&T({showId:D.showId,episodeNumber:D.episodeNumber}),H?f(`/watch/${H.showId}/${H.episodeNumber}`):p||v(!0)},[c,f,m,T,a,s,n,p]),V=q(()=>{p&&(E(),f(`/watch/${a}/${p}`)),v(!1),w({type:"SET_STATE",payload:{showResumeModal:!1}})},[p,f,a,w,E]),b=q(()=>{m.length>0?F():p?V():Pe.error("No next episode available")},[m.length,F,V,p]),h=q(()=>v(!1),[]),O=q(()=>{g(null),_(null)},[]),z=q(()=>{y&&f(`/watch/${a}/${y}`)},[y,f,a]);return U(()=>{const D=B=>{B.origin===window.location.origin&&o==="iframe"&&B.data?.type==="ANI_WEB_MEDIA_ENDED"&&A()};return window.addEventListener("message",D),()=>window.removeEventListener("message",D)},[A,o]),U(()=>{if(!x||N===null)return;if(N<=0){const{nextItem:B,playedItem:H}=x;g(null),_(null),H&&d.current({showId:H.showId,episodeNumber:H.episodeNumber}),B?f(`/watch/${B.showId}/${B.episodeNumber}`):p||v(!0);return}const D=window.setTimeout(()=>{_(B=>B===null?null:B-1)},1e3);return()=>window.clearTimeout(D)},[x,N,f,p]),{showCompleteModal:e,queueCountdown:N,pendingQueueTransition:x,handleQueueTransition:F,handleNextEpisode:V,handleNShortcut:b,handlePreviousEpisode:z,handlePlaybackFinished:A,closeCompleteModal:h,cancelQueueTransition:O}}function us({videoRef:r,queue:o,showId:c,showMetaId:m,currentEpisode:T,selectedSource:a,hasNextEpisode:s,nextEpisode:n,prefetchEpisodeSources:i,matchesQueueItem:p}){const[y,f]=ie(!1),E=R(i);E.current=i;const w=R("");U(()=>{f(!1)},[T]);const e=q(()=>{const v=r.current;if(!v||a?.type==="iframe")return;const N=v.duration,_=v.currentTime;if(!N||Number.isNaN(N)){f(!1);return}if(N-_<=60){const x=o.findIndex(P=>p(P,c,m)&&P.episodeNumber===T),g=o.length>0?x>=0?o[x+1]||null:o[0]:null,d=g?`${g.showId}:${g.episodeNumber}`:s?`${c}:${n}`:"";d&&w.current!==d&&(w.current=d,g?E.current(g.episodeNumber,g.showId):E.current(n??""))}f(s&&dt(_,N))},[r,a,o,c,m,T,s,n,p]);return{showNextEpisodePrompt:y,handleThresholds:e}}const Et="fallbackChoice";function ds(){try{const r=J.getItem(Et);return r==="iframe"||r==="retry"?r:null}catch{return null}}function ms(r){try{r===null?J.removeItem(Et):J.setItem(Et,r)}catch{}}function ps({showId:r,episodeNumber:o,currentMode:c,selectedProvider:m,selectedSourceType:T,videoSources:a,isAdult:s,providerOrder:n,matureProviders:i,setPreferredSource:p,dispatch:y,showControls:f}){const E=R(!1),w=R([]),e=R(!1),[v,N]=ie(null),[_,x]=ie(!1),[g,d]=ie(!1),[P,A]=ie(()=>ds()??"ask"),F=q($=>{A($),ms($==="ask"?null:$)},[]),V=R(P);U(()=>{V.current=P},[P]);const b=R(a);b.current=a;const h=q(()=>{E.current=!1,w.current=[],e.current=!1,N(null),x(!1)},[]);U(()=>{h()},[h,r,o]);const O=q($=>{if(E.current)return;E.current=!0;const Q=$.links[0];p($.sourceName),y({type:"SET_STATE",payload:{selectedSource:$,selectedLink:Q}}),N(null)},[y,p]),z=q(()=>{const Q=b.current.find(ee=>ee.type==="iframe");return Q?.links?.length?Q:null},[]),D=q(async()=>{const $=n.filter(Q=>{if(w.current.includes(Q))return!1;const ee=i.has(Q);return s===void 0?!0:ee===s});x(!0);try{for(const Q of $){w.current.push(Q);let ee=null;try{ee=await me.data.video.query({showId:r,episodeNumber:o,mode:c,provider:Q})}catch{continue}const l=(ee??[]).filter(C=>{const W=C.sourceName.toLowerCase();return c==="dub"?W.includes("eng")||W.includes("dub"):W.includes("jpn")||W.includes("sub")||!W.includes("eng")&&!W.includes("dub")});if((l.length>0?l:ee??[]).find(C=>C.type!=="iframe"&&C.links?.length)){w.current=[m],e.current=!1,y({type:"SET_STATE",payload:{selectedProvider:Q,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Wt(Q,s===!0),N(null),Pe.success(`Switched to ${Q} (direct stream)`);return}}N({retryFailed:!0}),Pe.error("No working direct stream found on other providers")}finally{x(!1)}},[r,o,c,s,m,y,n,i]),B=q(()=>{if(E.current||e.current||T!=="player")return;const $=z();if(!$)return;w.current.includes(m)||w.current.push(m);const Q=V.current;if(Q==="iframe"){O($);return}if(Q==="retry"){D();return}f(!0),N({retryFailed:!1})},[T,m,z,O,D,f]),H=q(()=>{e.current=!0,N(null),d(!1)},[]),j=q(()=>{g&&F("iframe");const $=z();$?O($):N(null)},[g,F,z,O]),pe=q(()=>{g&&F("retry"),D()},[g,F,D]);return{fallbackPrompt:v,isRetryingProvider:_,rememberFallbackChoice:g,setRememberFallbackChoice:d,fallbackChoice:P,updateFallbackChoice:F,dismissFallbackPrompt:H,chooseIframeFallback:j,chooseProviderRetry:pe,handleVideoSourceError:B,resetFallback:h}}function fs({engine:r,videoRef:o,selectedSource:c,selectedLink:m,loadingVideo:T,testClipActive:a,resumeTime:s,resumeDuration:n=0,showResumeModal:i,calibReturnRef:p,setAvailableSubtitles:y,setActiveSubtitleTrack:f,onFatalError:E}){const w=R(null),e=R(s),v=R(n),N=R(i),_=R(E);return _.current=E,U(()=>{e.current=s,v.current=n,N.current=i},[s,n,i]),U(()=>{const x=o.current;if(!x)return;for(;x.firstChild;)x.removeChild(x.firstChild);if(a)return r.loadSource({url:"/av-sync-test.mp4"},{autoPlay:!0});if(T||!c||!m||c.type==="iframe"){r.unload();return}p.current!=null?(w.current=p.current,p.current=null):w.current===null&&e.current>5&&!N.current&&!dt(e.current,v.current)?w.current=e.current:w.current===null&&N.current&&(w.current=0);let g=m.link;if(g.startsWith("/api/proxy")||(g=`/api/proxy?url=${encodeURIComponent(g)}`,m.headers?.Referer&&(g+=`&referer=${encodeURIComponent(m.headers.Referer)}`)),c.subtitles){const A=J.getItem("playerSubtitlesEnabled")!=="false";let F=null;try{F=J.getItem("playerLastSubtitle")}catch{}const V=wt(c.subtitles,{lastKey:F,enabled:A}),b=V>=0?c.subtitles[V]:null;c.subtitles.forEach(h=>{const O=document.createElement("track");O.kind="subtitles",O.label=h.label,O.srclang=h.lang;const z=h.src??h.url;if(z){let D=`/api/subtitle-proxy?url=${encodeURIComponent(z)}`;const B=m.headers?.Referer;B&&(D+=`&referer=${encodeURIComponent(B)}`),O.src=D}b&&h.label===b.label&&h.lang===b.lang&&(O.default=!0),x.appendChild(O)}),A||f("off"),y(c.subtitles)}const d=w.current??0;w.current=null;const P=document.body.classList.contains("low-end");return r.loadSource({url:g,hls:m.hls},{initialTime:d,autoPlay:!(N.current&&e.current>5)&&!dt(e.current,v.current),hlsConfig:{maxBufferLength:P?15:30,maxMaxBufferLength:P?30:60,maxBufferSize:(P?25:60)*1e3*1e3,startLevel:-1},onHls:(A,F)=>{if(!c.subtitles?.length)return;const V=()=>{A.subtitleTrack!==-1&&(A.subtitleTrack=-1)};A.on(F.Events.SUBTITLE_TRACK_SWITCH,V),V()},onError:()=>_.current()})},[r,c,m,o,p,T,a,f,y]),{seekToTimeRef:w}}function hs({videoRef:r,availableSubtitles:o,activeSubtitleTrack:c,setAvailableSubtitles:m,setActiveSubtitleTrack:T}){U(()=>{const a=r.current;if(!a)return;const s=()=>{const n=Array.from(a.textTracks).map(i=>({label:i.label,lang:i.language,src:void 0,mode:i.mode}));m(n)};return a.textTracks.addEventListener("addtrack",s),a.textTracks.addEventListener("removetrack",s),s(),()=>{a.textTracks.removeEventListener("addtrack",s),a.textTracks.removeEventListener("removetrack",s)}},[r,m]),U(()=>{if(c===null&&o.length>0&&J.getItem("playerSubtitlesEnabled")!=="false"){let a=null;try{a=J.getItem("playerLastSubtitle")}catch{}const s=wt(o,{lastKey:a,enabled:!0});if(s<0){T("off");return}const n=o[s];T(n.lang||n.label)}},[c,o,T]),U(()=>{const a=r.current;if(!a||o.length===0)return;const s=c;if(!(J.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(a.textTracks).forEach(p=>{p.mode="hidden"});return}let i=!1;if(Array.from(a.textTracks).forEach(p=>{const f=(p.language===s||p.label===s)&&!i;p.mode=f?"showing":"hidden",f&&(i=!0)}),!i&&a.textTracks.length>0){const p=Array.from(a.textTracks).find(y=>y.language==="en"||y.label==="English")||a.textTracks[0];p&&(p.mode="showing")}},[c,o,r])}function vs({videoRef:r,videoBoxH:o,style:c,sourceKey:m,activeSubtitleTrack:T,availableSubtitles:a}){U(()=>{const s="dynamic-subtitle-styles";let n=document.getElementById(s);n||(n=document.createElement("style"),n.id=s,document.head.appendChild(n)),n.textContent=xt(c);const i=r.current;if(!i)return;const p=$t(c.fontSize,o||i.clientHeight||720);n.textContent=xt({...c,fontSize:p});const y=()=>{const d=Number(c.position),P=isNaN(d)?0:Math.max(0,Math.min(100,d));return Math.max(0,Math.min(100,100-P))},f=(d,P)=>{try{const A=d;A.snapToLines=!1,A.line=P}catch{}},E=()=>{const d=p*16,P=i.videoHeight||i.clientHeight||720,A=i.videoWidth||i.clientWidth||1280;return{step:d*1.3/P*100,chars:Math.max(20,Math.floor(A/(d*.55)))}},w=d=>{const P=y(),A=Array.from(d.activeCues??[]);if(A.length<=1){A.forEach(h=>f(h,P));return}const{step:F,chars:V}=E();let b=P;for(let h=A.length-1;h>=0;h--){const z=String(A[h].text??"").replace(/<[^>]*>/g,"").split(`
55
- `).reduce((B,H)=>B+Math.max(1,Math.ceil(H.length/V)),0),D=b-z*F;f(A[h],Math.max(0,D)),b=D-F*.4}},e=d=>{if(!d.cues)return;const P=y();Array.from(d.cues).forEach(A=>f(A,P)),d.mode==="showing"&&w(d)},v=()=>{Array.from(i.textTracks).forEach(e)};v();const N=d=>{const P=d.target;P.mode==="showing"&&w(P)};Array.from(i.textTracks).forEach(d=>{d.addEventListener("cuechange",N)});const _=()=>{Array.from(i.textTracks).forEach(d=>{d.removeEventListener("cuechange",N),d.addEventListener("cuechange",N)}),v()};i.textTracks.addEventListener("addtrack",_),i.textTracks.addEventListener("removetrack",_);const x=Array.from(i.querySelectorAll("track")),g=()=>{v()};return x.forEach(d=>{d.addEventListener("load",g)}),()=>{Array.from(i.textTracks).forEach(d=>{d.removeEventListener("cuechange",N)}),i.textTracks.removeEventListener("addtrack",_),i.textTracks.removeEventListener("removetrack",_),x.forEach(d=>{d.removeEventListener("load",g)})}},[c,o,r,m,T,a])}function gs({videoRef:r,overlayRef:o,style:c,activeSubtitleTrack:m,delayMs:T,enabled:a}){U(()=>{if(!a)return;const s=r.current,n=o.current;if(!s||!n)return;const i=J.getItem("playerSubtitlesEnabled")!=="false",p=()=>{if(n.innerHTML="",!i||m==="off"||m===null)return;const E=Array.from(s.textTracks).find(g=>g.language===m||g.label===m);if(!E||E.mode!=="showing")return;const w=T/1e3;let e;if(w>0&&E.cues){const g=s.currentTime-w;e=Array.from(E.cues).filter(d=>d.startTime<=g&&g<=d.endTime)}else e=Array.from(E.activeCues??[]);if(e.length===0)return;const v={...c,fontSize:$t(c.fontSize,s.clientHeight||0)},N=_r(v),_=Ar(s,v.position),x=Array.from(e);x.forEach((g,d)=>{const P=String(g.text??"");if(!xr(P).trim())return;const A=document.createElement("div"),F=(x.length-1-d)*1.7;A.style.cssText=`${N}
56
- bottom: calc(${_}px + ${F}em);`,A.innerHTML=Lr(P),n.appendChild(A)})},y=()=>p(),f=()=>p();return Array.from(s.textTracks).forEach(E=>{E.addEventListener("cuechange",y)}),s.addEventListener("timeupdate",f),p(),()=>{Array.from(s.textTracks).forEach(E=>{E.removeEventListener("cuechange",y)}),s.removeEventListener("timeupdate",f),n.innerHTML=""}},[m,T,a,o,c,r])}const bs=({isOpen:r,onClose:o,onSuccess:c})=>{const m=()=>{c?.(),o()};return t(ut,{isOpen:r,onClose:o,title:"MKissa Browser Verification",children:t("div",{className:ze.container,children:[t("p",{children:"Open MKissa in this browser, play an anime episode, and complete any Cloudflare verification it shows. Once playback works there, return to Dango and click Refresh."}),t("div",{className:ze.actions,children:t("a",{className:ze.link,href:"https://mkissa.to/anime",target:"_blank",rel:"noreferrer",children:"Open MKissa anime"})}),t("div",{className:ze.actions,children:[t("button",{className:ze.secondaryButton,onClick:o,children:"Cancel"}),t("button",{className:ze.button,onClick:m,children:"Refresh Dango"})]})]})})},$s=()=>{const{id:r,episodeNumber:o}=nr(),c=sr(),m=Dt(),T=or(),a=cr(),s=!!a.session,n=s&&!a.session?.host,{hasConsent:i,grant:p}=ur(),{options:y}=It(),f=Ce(()=>y.filter(u=>(u.kind??"anime")==="anime"),[y]),E=Ce(()=>f.map(u=>u.id),[f]),w=Ce(()=>new Set(f.filter(u=>u.mature).map(u=>u.id)),[f]),{state:e,dispatch:v,toggleWatchlist:N,moveToCompleted:_,setPreferredSource:x,handleToggleDetails:g,markEpisodeWatched:d,prefetchEpisodeSources:P,isMarkingWatched:A,isUpdatingWatchlistStatus:F}=is(r,o,T.state||null,{hasMatureConsent:i,watchSelection:n?a.room?.selection:null});U(()=>{if(r&&e.showMeta?.id&&e.showMeta.id!==r){const u=o?`/watch/${e.showMeta.id}/${o}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;c(u,{replace:!0})}},[r,e.showMeta?.id,o,c]);const V=Ce(()=>{if(e.showMeta.name)return{name:e.showMeta.name,thumbnail:e.showMeta.thumbnail,names:e.showMeta.names,genres:e.showMeta.genres,score:e.showMeta.score,isAdult:e.showMeta.isAdult}},[e.showMeta.name,e.showMeta.thumbnail,e.showMeta.names,e.showMeta.genres,e.showMeta.score,e.showMeta.isAdult]),b=Br({skipIntervals:e.skipIntervals,showId:r,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:V}),{refs:h,actions:O}=b,z=Ce(()=>!r||r.startsWith("dango-mt-")||!e.currentEpisode||e.selectedSource?.type==="iframe"||!e.selectedLink?.hls||!e.selectedSource?null:{showId:r,episode:e.currentEpisode,provider:e.selectedProvider,mode:e.currentMode,source:e.selectedSource.sourceName,title:e.showMeta.name||r},[r,e.currentEpisode,e.selectedProvider,e.currentMode,e.selectedSource,e.selectedLink,e.showMeta.name]),D=Dr(b.engine,z,e.loadingVideo||e.loadingShowData),B=Zr(),H=R(null),j=R(null),pe=R(null),[$,Q]=ie(()=>{try{const u=J.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(u)?u:"balanced"}catch{return"balanced"}}),{videoDelayMs:ee,videoDelayEnabled:l,setDelayEnabled:M,handleVideoDelayChange:k,isCalibrating:C,testClipActive:W,stopCalibration:Y,openAvSyncCalibrator:Me,cancelAvSyncCalibrator:_e,applyAvSyncCalibrator:ne,toggleTestClip:X,calibReturnRef:Ae,effectiveVideoDelayMs:De}=$r(h.videoRef,()=>O.setShowSettings(!1)),se=R(null),K=es({videoRef:h.videoRef,canvasRef:j,profile:$,delayMs:De}),fe=K.isEnabled&&K.isWebGPUSupported;ts({videoRef:h.videoRef,episodeKey:`${r??""}:${e.currentEpisode??""}`,isEnabled:K.isEnabled,isSupported:K.isWebGPUSupported,mediaReady:!e.loadingVideo&&!!e.selectedLink,isIframeSource:e.selectedSource?.type==="iframe",setEnabled:K.setEnabled}),Ir({videoRef:h.videoRef,canvasRef:se,delayMs:De,enabled:l&&!fe});const le=l&&!fe,xe=fe||le,[He,je]=ie(!1),Oe=R(o);U(()=>{Oe.current!==o&&(Oe.current=o,Y())},[o,Y]);const mt=q(()=>{m.invalidateQueries({queryKey:[ae.continueWatching]})},[m]),{data:Re=[],isLoading:de}=dr(),tt=mr(),pt=pr(),ft=fr(),{isTheaterMode:ye,toggleTheaterMode:Ye,handleLayoutClick:I}=Fr();ar(()=>{if(b.state.isFullscreen||ye)return;const u=h.playerContainerRef.current,Z=H.current;if(!u||!Z)return;const Ie=()=>{const St=u.getBoundingClientRect().height;Z.style.height=`${St}px`};Ie();const Be=new ResizeObserver(Ie);return Be.observe(u),()=>Be.disconnect()},[b.state.isFullscreen,ye,h.playerContainerRef]);const he=Ce(()=>e.episodes.findIndex(u=>u===e.currentEpisode),[e.episodes,e.currentEpisode]),Xe=he>0?e.episodes[he-1]:null,ve=he>=0&&he<e.episodes.length-1?e.episodes[he+1]:null,ht=he>-1&&he<e.episodes.length-1,{showCompleteModal:We,queueCountdown:$e,pendingQueueTransition:Ue,handleQueueTransition:rt,handleNextEpisode:Ve,handleNShortcut:nt,handlePreviousEpisode:Qe,handlePlaybackFinished:st,closeCompleteModal:Ke,cancelQueueTransition:vt}=cs({testClipActive:W,selectedSourceType:e.selectedSource?.type,onEnded:O.onEnded,queue:Re,removeFromQueue:tt.mutate,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,isAutoplayEnabled:!n&&e.isAutoplayEnabled,nextEpisode:ve,previousEpisode:Xe,navigate:c,invalidateContinueWatching:mt,dispatch:v}),{showNextEpisodePrompt:gt,handleThresholds:G}=us({videoRef:h.videoRef,queue:Re,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,selectedSource:e.selectedSource,hasNextEpisode:ht,nextEpisode:ve,prefetchEpisodeSources:P,matchesQueueItem:et}),{checkEnd:te,logDuration:Se}=Or({videoRef:h.videoRef,sourceType:e.selectedSource?.type,resetKey:`${r}:${e.currentEpisode}`,onEnd:n?O.onEnded:st}),ce=!s&&e.showResumeModal&&!e.resumeProgressPending,ue=We,re=ce||ue;Wr(b,!!e.selectedLink&&!ye&&!re);const{fallbackPrompt:ke,isRetryingProvider:qe,rememberFallbackChoice:Ge,setRememberFallbackChoice:Ee,fallbackChoice:oe,updateFallbackChoice:bt,dismissFallbackPrompt:Je,chooseIframeFallback:ge,chooseProviderRetry:ot,handleVideoSourceError:Tt,resetFallback:Ct}=ps({showId:r,episodeNumber:e.currentEpisode??void 0,currentMode:e.currentMode,selectedProvider:e.selectedProvider,selectedSourceType:e.selectedSource?.type,videoSources:e.videoSources,isAdult:e.showMeta?.isAdult,providerOrder:E,matureProviders:w,setPreferredSource:x,showControls:O.setShowControls,dispatch:v}),{seekToTimeRef:Mt}=fs({engine:b.engine,videoRef:h.videoRef,selectedSource:e.selectedSource,selectedLink:e.selectedLink,loadingVideo:e.loadingVideo,testClipActive:!s&&W,resumeTime:s?0:e.resumeTime,resumeDuration:e.resumeDuration,showResumeModal:!s&&e.showResumeModal,calibReturnRef:Ae,setAvailableSubtitles:O.setAvailableSubtitles,setActiveSubtitleTrack:O.setActiveSubtitleTrack,onFatalError:s?()=>{}:Tt});U(()=>{re&&b.state.isFullscreen&&b.actions.toggleFullscreen()},[re,b.state.isFullscreen,b.actions]),U(()=>{re&&h.videoRef.current&&h.videoRef.current.pause()},[re,h.videoRef]);const{titlePreference:at}=hr(),{lowEndMode:Rt}=vr(),{settings:yt,update:Ut}=Ur(),Vt=ye&&yt.enabled&&!Rt&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,Le=Ce(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:u,names:Z}=e.showMeta;return at==="name"?u||"Loading...":at==="nativeName"?Z?.native||u||"Loading...":at==="englishName"?Z?.english||u||"Loading...":u||"Loading..."},[e.showMeta,at,e.loadingShowData]);U(()=>{Le&&Le!=="Loading..."&&e.currentEpisode&&(document.title=`► ${Le} Episode ${e.currentEpisode} - dango`)},[Le,e.currentEpisode]),ls({onPrevious:n?()=>{}:Qe,onNext:n?()=>{}:nt,onToggleTheater:Ye,flashControls:b.actions.flashControls});const{setAvailableSubtitles:Qt,setActiveSubtitleTrack:Kt}=O,Nt=Ce(()=>({fontSize:b.state.subtitleFontSize,position:b.state.subtitlePosition,bgOpacity:b.state.subtitleBgOpacity,bgColor:b.state.subtitleBgColor,textColor:b.state.subtitleTextColor,edge:b.state.subtitleEdge,bold:b.state.subtitleBold}),[b.state.subtitleFontSize,b.state.subtitlePosition,b.state.subtitleBgOpacity,b.state.subtitleBgColor,b.state.subtitleTextColor,b.state.subtitleEdge,b.state.subtitleBold]);hs({videoRef:h.videoRef,availableSubtitles:b.state.availableSubtitles,activeSubtitleTrack:b.state.activeSubtitleTrack,setAvailableSubtitles:Qt,setActiveSubtitleTrack:Kt});const[qt,Gt]=ie(0);U(()=>{const u=h.videoRef.current;if(!u)return;const Z=()=>Gt(u.clientHeight||0);Z();const Ie=new ResizeObserver(Z);return Ie.observe(u),()=>Ie.disconnect()},[h.videoRef,e.selectedSource,e.selectedLink]),vs({videoRef:h.videoRef,videoBoxH:qt,style:Nt,sourceKey:`${e.selectedSource?.sourceName??""}:${e.selectedLink?.link??""}`,activeSubtitleTrack:b.state.activeSubtitleTrack,availableSubtitles:b.state.availableSubtitles}),gs({videoRef:h.videoRef,overlayRef:pe,style:Nt,activeSubtitleTrack:b.state.activeSubtitleTrack,delayMs:De,enabled:xe}),U(()=>{try{J.setItem("anime4kProfile",$)}catch{}},[$]);const zt=()=>{h.videoRef.current&&(h.videoRef.current.currentTime=e.resumeTime,h.videoRef.current.play()),v({type:"SET_STATE",payload:{showResumeModal:!1}})},Ht=()=>{h.videoRef.current&&(h.videoRef.current.currentTime=0,h.videoRef.current.play()),v({type:"SET_STATE",payload:{showResumeModal:!1}})},jt=q(()=>{v({type:"SET_STATE",payload:{showResumeModal:!1}})},[v]),Yt=q(async()=>{try{await _(),Ke(),v({type:"SET_STATE",payload:{showResumeModal:!1}}),c("/")}catch{}},[_,Ke,v,c]),Pt=(u,Z)=>t("div",{className:u,children:[t("button",{className:`${S.episodeNavBtn} ${S.secondary}`,onClick:Qe,disabled:n||!Xe,type:"button",children:[t(be,{name:"chevron-left",size:12}),"Prev EP"]}),t("button",{className:`${S.episodeNavBtn} ${S.primary}`,onClick:Ve,disabled:n||!ve,type:"button",children:["Next EP",t(be,{name:"chevron-right",size:12})]}),Z==="mobile"&&B&&t("button",{className:`${S.episodeNavBtn} ${S.episodePickerBtn}`,onClick:()=>je(!0),type:"button",children:[t(be,{name:"list-ul",size:12}),"Episodes"]})]}),Xt=u=>{v({type:"SET_STATE",payload:{isAutoplayEnabled:u}}),Xr(u)},_t=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),Jt=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",Zt=q(async()=>{if(!r||!e.currentEpisode||!e.showMeta.name||A)return;const u=h.videoRef.current?.duration,Z=Math.max(u||0,e.resumeDuration||0,Number(e.showMeta.episodeDuration||0)*60,1);await d(e.currentEpisode,Z)},[r,e.currentEpisode,e.showMeta,e.resumeDuration,d,A,h.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return t("p",{className:"error-message",children:["Error: ",e.error]});const we=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!i?t("div",{className:Te.playerPageLayout,children:t(Jr,{isOpen:!0,onClose:()=>c("/home"),onGrant:p})}):t("div",{className:`${Te.playerPageLayout} ${ye?Te.theaterMode:""}`,onClick:I,children:[ye&&t(Vr,{videoRef:h.videoRef,active:Vt,settings:yt}),t(Qr,{isOpen:ue,onClose:Ke,title:"Show Completed!",heading:Le,message:"Congratulations! You finished all available episodes.",children:[t(lt,{variant:"secondary",onClick:Ke,children:"Close"}),t(lt,{onClick:Yt,disabled:F,children:F?"Saving...":"Move to Completed"})]}),t(Kr,{isOpen:ce,onClose:jt,title:"Resume Playback?",message:t(it,{children:["You were watching at ",t("strong",{children:b.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:zt,onRestart:Ht}),t(ut,{isOpen:!!ke,onClose:Je,title:"Direct stream failed",width:"sm",children:[t(ut.Body,{children:[t("p",{children:[t("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),ke?.retryFailed&&t("p",{children:"No working direct stream was found on the other providers either."}),t("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",t("strong",{children:"ads and pop-ups"}),"."]}),t("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[t("input",{type:"checkbox",checked:Ge,onChange:u=>Ee(u.currentTarget.checked)}),"Remember my choice"]})]}),t(ut.Actions,{children:[t(lt,{variant:"secondary",onClick:ge,children:"Continue with iframe"}),t(lt,{onClick:ot,disabled:qe,children:qe?"Searching…":"Try another provider"})]})]}),t(gr,{isOpen:!!e.showCookieModal&&e.cookieProvider!=="mkissa",onClose:()=>v({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{m.invalidateQueries({queryKey:[ae.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),t(bs,{isOpen:!!e.showCookieModal&&e.cookieProvider==="mkissa",onClose:()=>v({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{m.invalidateQueries({queryKey:[ae.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!ye&&t("aside",{ref:H,className:Te.episodeSidebar,children:e.loadingShowData?t(qr,{variant:"sidebar"}):t(Gr,{episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:u=>{n||c(`/watch/${r}/${u}`)}})}),t("div",{className:Te.playerMain,children:[t("div",{className:`${S.videoContainer} ${b.state.isFullscreen?"":Te.videoPlayerWrapper} ${b.state.isFullscreen?S.fullscreenActive:""}`,style:{...re?{visibility:"hidden"}:{}},onContextMenu:u=>u.preventDefault(),children:t(Un,{player:b,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Xt,fallbackChoice:oe,onFallbackChoiceChange:bt,ambientSettings:yt,onAmbientChange:Ut,showNextEpisodeButton:!n&&!re&&gt&&Re.length===0,onNextEpisode:Ve,videoSources:n?[]:s?e.videoSources.filter(u=>u.type!=="iframe"&&u.links.some(Z=>Z.hls)):e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(u,Z)=>{n&&u.sourceName!==a.room?.selection.source||s&&(u.type==="iframe"||!Z.hls)||(h.videoRef.current&&!isNaN(h.videoRef.current.currentTime)&&(Mt.current=h.videoRef.current.currentTime),x(u.sourceName),v({type:"SET_STATE",payload:{selectedSource:u,selectedLink:Z,showResumeModal:e.showResumeModal&&u.type!=="iframe"}}))},loadingVideo:we,skipIntervals:e.skipIntervals,animeTitle:Le,episodeNumber:e.currentEpisode??void 0,mode:e.currentMode,isTheaterMode:ye,onTheaterModeToggle:Ye,anime4kEnabled:K.isEnabled,onAnime4kToggle:K.toggle,anime4kSupported:K.isWebGPUSupported,anime4kProfile:$,onAnime4kProfileChange:Q,anime4kInitializing:K.isInitializing,anime4kError:K.error,videoDelayEnabled:l,onVideoDelayToggle:M,videoDelayMs:ee,onVideoDelayChange:k,onCalibrateAvSync:s?()=>{}:Me,isInteractingExtra:He||C,className:Tr.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:t(it,{children:[b.state.isSpeedBoostActive&&t("div",{className:S.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(be,{name:"forward",size:12})]}),$e!==null&&Ue?.nextItem&&t("div",{className:S.queueCountdown,children:["Queue next in ",$e,"s"]})]}),children:[we&&t("div",{className:S.loadingOverlay,children:t("div",{className:S.loadingDots,children:[t("div",{className:S.dot}),t("div",{className:S.dot}),t("div",{className:S.dot})]})}),b.state.isBuffering&&!we&&e.selectedSource?.type!=="iframe"&&t("div",{className:S.bufferingOverlay,children:t("div",{className:S.bufferingSpinner})}),e.selectedSource?.type==="iframe"&&!s?!we&&t("iframe",{src:e.selectedLink?.link,className:S.videoIframe,allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,sandbox:e.selectedSource.sandbox?`${e.selectedSource.sandbox} allow-fullscreen allow-popups allow-popups-to-escape-sandbox`:void 0}):t(it,{children:[!we&&e.videoSources.length===0&&t("div",{className:S.errorOverlay,children:[t("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),t("p",{className:S.errorSubtext,children:"Please try selecting a different provider below."}),t("button",{className:S.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!we&&e.videoSources.length>0&&t(Cr,{controls:!b.state.playbackLocked&&b.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:O.onPlay,onPause:O.onPause,onEnded:()=>{W||te(!0)},onDurationChange:()=>{Se()},onSeeked:()=>{W||(G(),te())},onLoadedMetadata:()=>{G(),Se(),W||te()},onTimeUpdate:()=>{W||(O.onTimeUpdate(),G(),te(),Ue&&h.videoRef.current&&h.videoRef.current.currentTime<h.videoRef.current.duration-1&&vt())},onError:s?void 0:Tt,onContextMenu:u=>u.preventDefault(),className:xe?S.videoElementHidden:""}),K.isWebGPUSupported&&!we&&e.videoSources.length>0&&t("canvas",{ref:j,className:`${S.upscalerCanvas} ${fe?S.upscalerActive:""}`}),!fe&&!we&&e.videoSources.length>0&&t("canvas",{ref:se,className:`${S.upscalerCanvas} ${le?S.upscalerActive:""}`}),K.isEnabled&&K.isWebGPUSupported&&K.isInitializing&&t("div",{className:S.upscalerStatusBadge,children:"Preparing upscaler…"}),xe&&t("div",{ref:pe,className:S.subtitleOverlay}),t(zr,{isOpen:C,ms:ee,onChange:k,onApply:ne,onClose:_e,testClipActive:W,onTestClip:X})]})]})}),t(on,{playback:z&&!we?{selection:z,position:h.videoRef.current?.currentTime||0,playing:!1,rate:b.engine.getState().playbackRate}:null,onCreate:()=>{Y(),b.engine.pause()},needsPlayback:D.needsPlayback,onEnablePlayback:D.enablePlayback}),s&&!we&&!z&&t("p",{role:"alert",children:"This room requires the host's direct HLS source. It is unavailable here. Retry the episode or leave the room to use another source."}),!ye&&t(Hr,{}),!ye&&t(it,{children:[de&&Re.length===0?t(Vn,{count:3}):t(en,{title:"Queue",items:Re,currentShowId:r,currentEpisode:e.currentEpisode??void 0,onNextQueue:n?()=>{}:rt,onRemove:u=>tt.mutate({showId:u.showId,episodeNumber:u.episodeNumber}),onClear:()=>pt.mutate(),showClearAll:!0,onReorder:u=>ft.mutate(u.map(Z=>({id:Z.id,showId:Z.showId,episodeNumber:Z.episodeNumber})))}),t("div",{className:S.streamPanel,children:[!n&&t(Gn,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:f,onProviderChange:u=>{Ct(),v({type:"SET_STATE",payload:{selectedProvider:u,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Wt(u,e.showMeta?.isAdult===!0)}}),Pt(`${S.episodeActions} ${S.desktopEpisodeActions}`,"desktop"),we?t("div",{className:S.sourceLoader,children:t("div",{className:S.spinner})}):n?t("p",{children:["Provider: ",e.selectedProvider," · Source: ",a.room?.selection.source," ·"," ",e.currentMode]}):t(Hn,{videoSources:s?e.videoSources.filter(u=>u.type!=="iframe"&&u.links.some(Z=>Z.hls)):e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:u=>{if(s&&(u.type==="iframe"||!u.links.some(Be=>Be.hls)))return;h.videoRef.current&&!isNaN(h.videoRef.current.currentTime)&&(Mt.current=h.videoRef.current.currentTime);const Ie=(s?u.links.filter(Be=>Be.hls):u.links||[]).sort((Be,St)=>(parseInt(St.resolutionStr)||0)-(parseInt(Be.resolutionStr)||0))[0]||null;x(u.sourceName),v({type:"SET_STATE",payload:{selectedSource:u,selectedLink:Ie,showResumeModal:e.showResumeModal&&u.type!=="iframe"}})},onLinkChange:u=>{e.selectedSource&&(x(e.selectedSource.sourceName),v({type:"SET_STATE",payload:{selectedLink:u}}))}})]}),t("div",{className:Te.playerInfoContainer,children:[t("div",{className:Te.playerInfoHeader,children:[t("div",{className:Te.playerAnimeCard,children:t(br,{src:yr(e.showMeta.thumbnail||""),alt:Le,loading:"lazy",decoding:"async",onError:u=>{u.target.src="/placeholder.svg"}})}),t("div",{className:Te.videoTitleSection,children:[t("div",{className:S.titleContainer,children:[t("h1",{children:Le}),t("div",{className:S.scheduleInfo,children:[e.showMeta.status&&t("span",{className:S.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&t("span",{className:S.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),t("div",{className:S.controls,children:[t("button",{className:`${S.watchlistBtn} ${e.inWatchlist?S.inList:""}`,onClick:N,children:[e.inWatchlist?t(be,{name:"check",size:14}):t(be,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),t(rn,{showId:r,showName:e.showMeta.name||e.showMeta.names?.romaji,showThumbnail:e.showMeta.thumbnail,nativeName:e.showMeta.names?.native,englishName:e.showMeta.names?.english,showType:e.showMeta.type,className:`${S.watchlistBtn} ${S.queueBtn}`,activeClassName:S.queueActive}),Jt&&t("button",{className:`${S.watchlistBtn} ${S.markWatchedBtn} ${_t?S.markWatchedDone:""}`,onClick:Zt,disabled:A||!e.currentEpisode,children:[t(be,{name:"check",size:14}),A?"Saving...":_t?"Watched":"Mark Watched"]}),t("button",{className:`${S.watchlistBtn} ${S.modeToggleBtn} ${e.currentMode==="dub"?S.modeToggleActive:""}`,disabled:n,onClick:()=>{const u=e.currentMode==="dub"?"sub":"dub";Ct(),v({type:"SET_MODE",payload:u}),J.setItem("preferredMode",u)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),Rt&&t("button",{disabled:n,className:`${S.watchlistBtn} ${S.modeToggleBtn} ${b.state.useNativeControls?S.modeToggleActive:""}`,onClick:()=>{const u=!b.state.useNativeControls;b.actions.setUseNativeControls(u),J.setItem("playerUseNativeControls",u.toString())},type:"button",children:b.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),Pt(`${S.episodeActions} ${S.mobileEpisodeActions}`,"mobile"),t("div",{className:Te.infoColumns,children:[t("div",{className:`${S.descriptionSection} ${S.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t(sn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."}),t("button",{className:S.detailsToggleBtn,onClick:g,children:[e.showCombinedDetails?t(be,{name:"chevron-up"}):t(be,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]})]}),e.showCombinedDetails&&t(nn,{showMeta:e.showMeta,styles:S})]})]})]})]}),t(jr,{isOpen:He,onClose:()=>je(!1),episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:u=>{je(!1),c(`/watch/${r}/${u}`)}})]})};export{$s as default};
@@ -1,21 +0,0 @@
1
- import{d as s,u as e,S as ge,A as Z,h as G,q as me,T as Me,p as qe,g as we,_ as ze}from"./vendor-core-DfaOB3Rn.js";import{b as pe,u as te}from"./vendor-query-BBT5_sHx.js";import{R as ee,S as J,U as K,V as be,B as S,W as Ke,Q as U,d as Ue,L as _e,t as C,v as Te,o as Ee,J as Ce,X,q as W,Y as ke,Z as Fe,_ as $e,u as We,e as He,$ as Be,K as le,p as je,a0 as Qe,a1 as Ve}from"./index-npJ4Ahxa.js";import{I as B}from"./vendor-icons-DrybRNxP.js";import{T as $}from"./ToggleSwitch-CN_ppEc9.js";import{M as Ye}from"./MatureConsentModal-BrKd4CBZ.js";const Je="_sectionCard_1vuib_1",Xe="_dangerCard_1vuib_20",Ze="_settingRow_1vuib_31",L={sectionCard:Je,dangerCard:Xe,settingRow:Ze};function et(){const{data:t}=pe(ee),{data:o}=pe({queryKey:["profiles"],queryFn:()=>J("/api/profiles/status"),enabled:!!t?.owner}),c=te(),[g,p]=s(null),[h,k]=s(""),[y,i]=s(""),[r,m]=s(""),[f,d]=s(""),[P,l]=s(""),[v,_]=s(!1),[T,O]=s(null),I=async a=>{_(!0),l("");try{await J("/api/profiles/update",{method:"POST",body:JSON.stringify(a)}),await c.invalidateQueries({queryKey:ee.queryKey}),k(""),i(""),l("Profile saved")}catch(N){l(N.message)}finally{_(!1)}};return t?e("section",{className:L.sectionCard,children:[e("h3",{children:"Your profile"}),e("p",{children:"Keep using this profile, rename it, or add another person with their own library and connections."}),e("div",{className:K.avatarRow,children:[e(be,{image:t.image,name:t.name}),e("label",{className:K.uploadButton,children:[e(B,{name:"upload"}),e("span",{children:"Upload image"}),e("input",{className:K.fileInput,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",disabled:v,onChange:async a=>{const N=a.currentTarget.files?.[0];if(a.currentTarget.value="",!N)return;if(N.size>2*1024*1024){l("Image must be smaller than 2 MB");return}const R=new FileReader;R.onerror=()=>l("Could not read image"),R.onload=()=>{I({avatar:R.result})},R.readAsDataURL(N)}})]}),t.avatar&&e(S,{variant:"secondary",disabled:v,onClick:()=>I({avatar:null}),children:"Clear uploaded image"})]}),e("p",{children:"Your uploaded image takes priority, followed by your active cloud account image, then the default user icon."}),e("form",{className:K.form,onSubmit:a=>{a.preventDefault(),I({name:g??t.name})},children:[e("label",{className:K.field,children:["Profile name",e("input",{value:g??t.name,maxLength:60,required:!0,onChange:a=>p(a.currentTarget.value)})]}),e(S,{type:"submit",disabled:v,children:"Save name"})]}),e("form",{className:K.form,onSubmit:a=>{a.preventDefault(),I({password:h,currentPassword:y})},children:[t.protected&&e("label",{className:K.field,children:["Current password",e("input",{type:"password",autoComplete:"current-password",value:y,required:!0,maxLength:256,onChange:a=>i(a.currentTarget.value)})]}),e("label",{className:K.field,children:[t.protected?"New password (empty removes protection)":"Protect this profile",e("input",{type:"password",autoComplete:"new-password",value:h,minLength:8,maxLength:256,onChange:a=>k(a.currentTarget.value)})]}),e(S,{type:"submit",disabled:v,children:"Save password"})]}),e(S,{variant:"secondary",disabled:v,onClick:async()=>{_(!0);try{await J("/api/profiles/logout",{method:"POST"}),Ke()}catch(a){l(a.message),_(!1)}},children:"Switch profile / sign out"}),t.owner&&e("form",{className:K.form,onSubmit:async a=>{a.preventDefault(),_(!0),l("");try{await J("/api/profiles/create",{method:"POST",body:JSON.stringify({name:r,password:f})}),m(""),d(""),await c.invalidateQueries({queryKey:["profiles"]}),l("Profile created. Sign out to switch to it.")}catch(N){l(N.message)}finally{_(!1)}},children:[e("h3",{children:"Add another profile"}),e("p",{children:"Protect your owner profile first. New profiles start empty and do not inherit your accounts. A profile without a password is accessible to anyone who passes the LAN lock."}),e("label",{className:K.field,children:["Name",e("input",{required:!0,maxLength:60,value:r,onChange:a=>m(a.currentTarget.value)})]}),e("label",{className:K.field,children:["Password (optional)",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,value:f,onChange:a=>d(a.currentTarget.value)})]}),e(S,{type:"submit",disabled:v||!t.protected,children:"Create profile"})]}),t.owner&&o?.profiles.some(a=>!a.owner)&&e(ge,{children:[e("h3",{children:"Other profiles"}),e("ul",{className:K.profileList,children:o.profiles.filter(a=>!a.owner).map(a=>e("li",{children:[e("span",{className:K.smallAvatar,children:e(be,{image:a.avatar??a.cloudAvatar,name:a.name})}),e("span",{className:K.profileName,children:a.name}),e(S,{variant:"danger",size:"sm",disabled:v,onClick:()=>{l(""),O(a)},children:"Delete"})]},a.id))})]}),e(U,{isOpen:!!T,onClose:v?void 0:()=>O(null),title:"Delete profile?",width:"sm",footer:e(ge,{children:[e(S,{variant:"secondary",disabled:v,onClick:()=>O(null),children:"Cancel"}),e(S,{variant:"danger",loading:v,onClick:async()=>{if(T){_(!0);try{await J("/api/profiles/delete",{method:"POST",body:JSON.stringify({id:T.id,confirm:!0})}),await c.invalidateQueries({queryKey:["profiles"]}),O(null),l("Profile deleted. Local files will be removed when Dango restarts.")}catch(a){l(a.message),O(null)}finally{_(!1)}}},children:"Delete profile"})]}),children:[e("p",{children:["Delete ",e("strong",{children:T?.name}),"? This signs them out immediately. Their local libraries, settings and connections will be removed when Dango next restarts."]}),e("p",{children:"Cloud backups and tracker lists will stay intact. Export any library you want to keep before deleting."})]}),P&&e("p",{role:"status",children:P})]}):null}const ce={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},de=["name","nativeName","englishName"],ue={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},tt=()=>{const{titlePreference:t,setTitlePreference:o,loading:c}=Ue(),g=_e(),[p,h]=s(ue[t]),[k,y]=s(!1),i=Z(null);G(()=>{c||h(ue[t])},[t,c]);const r=async()=>{if(k)return;y(!0);const f=(de.indexOf(t)+1)%de.length,d=de[f],P=ue[d];i.current&&(i.current.style.transform="translateX(-100%)",i.current.style.opacity="0"),setTimeout(async()=>{h(P),o(d),i.current&&(i.current.style.transition="none",i.current.style.transform="translateX(100%)",i.current.style.opacity="0",i.current.offsetWidth,i.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",i.current.style.transform="translateX(0)",i.current.style.opacity="1");try{await g.mutateAsync({key:"titlePreference",value:d})}catch(l){console.error("Error saving title preference:",l)}finally{y(!1)}},300)};return c?e("p",{children:"Loading title preference..."}):e("div",{className:ce["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:r,className:ce["toggle-button"],disabled:k,children:e("span",{ref:i,className:ce["toggle-label"],children:p})})]})},at="_settingsHeader_gfwoa_1",nt="_pageTitle_gfwoa_6",rt="_pageSubtitle_gfwoa_14",st="_settingsLayout_gfwoa_20",it="_sidebar_gfwoa_27",ot="_sidebarIndicator_gfwoa_35",lt="_sidebarItem_gfwoa_50",ct="_active_gfwoa_72",dt="_mainContent_gfwoa_80",ut="_tabContent_gfwoa_85",ht="_settingItem_gfwoa_103",gt="_shortcutContainer_gfwoa_108",mt="_shortcutGroup_gfwoa_115",pt="_shortcutGroupTitle_gfwoa_121",ft="_shortcutGrid_gfwoa_130",yt="_shortcutCard_gfwoa_136",vt="_controls_gfwoa_170",wt="_status_gfwoa_176",u={settingsHeader:at,pageTitle:nt,pageSubtitle:rt,settingsLayout:st,sidebar:it,sidebarIndicator:ot,sidebarItem:lt,active:ct,mainContent:dt,tabContent:ut,settingItem:ht,shortcutContainer:gt,shortcutGroup:mt,shortcutGroupTitle:pt,shortcutGrid:ft,shortcutCard:yt,controls:vt,status:wt},bt="_title_tm30b_11",Ct="_signIn_tm30b_18",kt="_userInfo_tm30b_25",St="_warning_tm30b_47",Nt="_formGroup_tm30b_54",_t="_label_tm30b_58",Tt="_inputWrapper_tm30b_68",Lt="_input_tm30b_68",Pt="_select_tm30b_92",It="_actions_tm30b_109",xt="_hr_tm30b_117",w={title:bt,signIn:Ct,userInfo:kt,warning:St,formGroup:Nt,label:_t,inputWrapper:Tt,input:Lt,select:Pt,actions:It,hr:xt},Rt=()=>{const t=te(),[o,c]=s(!0),[g,p]=s(!1),[h,k]=s(!1),[y,i]=s(null),[r,m]=s({status:"idle"}),[f,d]=s(!1),[P,l]=s(""),[v,_]=s(!1),T=Z(null),[O,I]=s({show:!1,message:"",type:"info"}),a=()=>{T.current&&(window.clearInterval(T.current),T.current=null)},N=me(b=>{k(b.authenticated),i(b.user||b.device.user||null),m(b.device),d(!!b.hasCustomClientId)},[]),R=me(async()=>{const b=await C.auth.githubStatus.query();N(b)},[N]),q=async()=>{try{const b=await C.auth.githubPoll.query();m(b),b.status==="success"?(a(),await t.invalidateQueries({queryKey:ee.queryKey}),await R(),I({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):b.status==="error"&&(a(),I({show:!0,message:b.error||"GitHub authentication failed.",type:"error"}))}catch{a(),I({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},x=(b=5)=>{a(),T.current=window.setInterval(q,Math.max(b,5)*1e3)};G(()=>(R().catch(()=>{I({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>c(!1)),a),[R]);const A=async()=>{p(!0);try{const b=await C.auth.githubStart.mutate();m(b),x(b.verification?.interval)}catch(b){I({show:!0,message:b instanceof Error?b.message:"Failed to start GitHub authentication.",type:"error"})}finally{p(!1)}},M=async()=>{try{await C.auth.githubLogout.mutate(),await t.invalidateQueries({queryKey:ee.queryKey}),k(!1),i(null),m({status:"idle"}),I({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{I({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},j=async()=>{_(!0);try{await C.auth.saveGithubAuth.mutate({clientId:P}),l(""),await R(),I({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{I({show:!0,message:"Failed to save override.",type:"error"})}finally{_(!1)}},Q=async()=>{_(!0);try{await C.auth.saveGithubAuth.mutate({clientId:""}),l(""),await R(),I({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{I({show:!0,message:"Failed to clear override.",type:"error"})}finally{_(!1)}};return o?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:L.sectionCard,children:[e("h3",{className:w.title,children:"GitHub Cloud Sync"}),e("p",{className:w.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),h&&y?e("div",{className:w.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:y.name||y.login})]}),e(S,{variant:"danger",onClick:M,children:"Sign Out"})]}):e("div",{className:w.signIn,children:e(S,{onClick:A,disabled:g||r.status==="pending",children:g||r.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),r.status==="pending"&&r.verification&&e(ge,{children:[e("hr",{className:w.hr}),e("div",{className:w.formGroup,children:[e("label",{className:w.label,children:"Verification URL"}),e("div",{className:w.inputWrapper,children:[e("input",{className:w.input,value:r.verification.verification_uri,readOnly:!0}),e(S,{onClick:()=>{const b=r.verification?.verification_uri;b&&/^https?:\/\//i.test(b)&&window.open(b,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:w.formGroup,children:[e("label",{className:w.label,children:"Device Code"}),e("input",{className:w.input,value:r.verification.user_code,readOnly:!0})]})]}),r.status==="error"&&e("p",{className:w.warning,children:r.error}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",f?"(override active)":""]}),e("div",{className:w.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:w.label,children:"Client ID (optional)"}),e("input",{className:w.input,value:P,onChange:b=>l(b.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:w.actions,children:[e(S,{onClick:j,disabled:v,children:"Save override"}),e(S,{variant:"secondary",onClick:Q,disabled:v,children:"Use dango defaults"})]})]}),e(U,{isOpen:O.show,onClose:()=>I(b=>({...b,show:!1})),width:"sm",children:[e(U.Body,{children:e("p",{children:O.message})}),e(U.Actions,{children:e(S,{onClick:()=>I(b=>({...b,show:!1})),children:"OK"})})]})]})},Dt=()=>{const[t,o]=s(!0),[c,g]=s(null),[p,h]=s(!1),[k,y]=s(!1),[i,r]=s(""),[m,f]=s(""),[d,P]=s(""),[l,v]=s(!1),[_,T]=s({show:!1,message:"",type:"info"}),O=async()=>{try{const A=await C.auth.user.query();g(A?.email?A:null)}catch{g(null)}},I=async()=>{try{const[x,A]=await Promise.all([C.auth.configStatus.query(),C.auth.googleAuth.query()]);h(!!x.hasConfig),y(!!(A.hasCustomWorkerUrl||A.hasCustomClientId||A.hasClientSecret))}catch(x){console.error("Failed to fetch config status",x)}};G(()=>{(async()=>{o(!0),await Promise.all([O(),I()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await O(),window.history.replaceState(null,"",window.location.pathname))}catch{}o(!1)})();const A=M=>{M.origin===window.location.origin&&typeof M.data=="object"&&M.data!==null&&M.data.type==="GOOGLE_AUTH_SUCCESS"&&(g(M.data.user),window.location.reload())};return window.addEventListener("message",A),()=>window.removeEventListener("message",A)},[]);const a=async()=>{try{const x=await C.auth.googleLogin.mutate();if(x.authenticated){window.location.reload();return}if(x.url){if(typeof window.DangoBridge<"u"){window.location.href=x.url;return}const M=600,j=700,Q=window.innerWidth/2-M/2,b=window.innerHeight/2-j/2;window.open(x.url,"GoogleAuth",`width=${M},height=${j},top=${b},left=${Q}`)}else throw new Error("Auth URL not available")}catch{T({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},N=async()=>{try{await C.auth.logout.mutate(),g(null),T({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(x){console.error("Sign out failed",x),T({show:!0,message:"Failed to sign out.",type:"error"})}},R=async()=>{v(!0);try{await C.auth.saveGoogleAuth.mutate({workerUrl:i,clientId:m,clientSecret:d}),r(""),f(""),P(""),await I(),T({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{T({show:!0,message:"Failed to save override.",type:"error"})}finally{v(!1)}},q=async()=>{v(!0);try{await C.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),r(""),f(""),P(""),await I(),T({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{T({show:!0,message:"Failed to clear override.",type:"error"})}finally{v(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:L.sectionCard,children:[e("h3",{className:w.title,children:"Google Drive Sync"}),c?e("div",{className:w.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:c.name})," (",c.email,")"]}),e(S,{variant:"danger",onClick:N,children:"Sign Out"})]}):e("div",{className:w.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(S,{onClick:a,disabled:!p,children:"Sign in with Google"}),!p&&e("p",{className:w.warning,children:"Google sync is not configured on the server."})]}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",k?"(override active)":""]}),e("div",{className:w.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:w.label,children:"Worker URL (optional)"}),e("input",{className:w.input,value:i,onChange:x=>r(x.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:w.formGroup,children:[e("label",{className:w.label,children:"Client ID (optional)"}),e("input",{className:w.input,value:m,onChange:x=>f(x.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:w.formGroup,children:[e("label",{className:w.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:w.input,value:d,onChange:x=>P(x.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:w.actions,children:[e(S,{onClick:R,disabled:l,children:"Save override"}),e(S,{variant:"secondary",onClick:q,disabled:l,children:"Use dango defaults"})]})]}),e(U,{isOpen:_.show,onClose:()=>T(x=>({...x,show:!1})),width:"sm",children:[e(U.Body,{children:e("p",{children:_.message})}),e(U.Actions,{children:e(S,{onClick:()=>T(x=>({...x,show:!1})),children:"OK"})})]})]})},At="_settingItem_3qq0n_1",Ot="_modalOverlay_3qq0n_6",Gt="_modal_3qq0n_6",Mt="_modalActions_3qq0n_41",qt="_modalSecondary_3qq0n_47",zt="_modalPrimary_3qq0n_57",H={settingItem:At,modalOverlay:Ot,modal:Gt,modalActions:Mt,modalSecondary:qt,modalPrimary:zt},Kt={anime:{heading:"Watchlist Preferences",blurb:"Customize your experience when managing your watchlist and series entries.",skipKey:"skipRemoveConfirmation",ignoreKey:"ignoreAdultContent",listOnlyKey:"cwWatchlistOnly",skipLabel:"Skip confirmation when removing from watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in watchlist",listNoun:"watchlist",continueNoun:"continue watching",adultCountUrl:"/api/continue-watching/adult-count",purgeUrl:"/api/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["allContinueWatching"]]},manga:{heading:"Reading List Preferences",blurb:"Customize your experience when managing your reading list and manga entries.",skipKey:"mangaSkipRemoveConfirmation",ignoreKey:"mangaIgnoreAdultContent",listOnlyKey:"mangaCwWatchlistOnly",skipLabel:"Skip confirmation when removing from reading list",ignoreLabel:"Hide adult content from continue reading",listOnlyLabel:"Only show continue reading for manga in reading list",listNoun:"reading list",continueNoun:"continue reading",adultCountUrl:"/api/manga/continue-reading/adult-count",purgeUrl:"/api/manga/continue-reading/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue reading`,invalidateKeys:[["manga-continue-reading"]]},tv:{heading:"TV Watchlist Preferences",blurb:"Customize your experience when managing your TV watchlist and series entries.",skipKey:"tvSkipRemoveConfirmation",ignoreKey:"tvIgnoreAdultContent",listOnlyKey:"tvCwWatchlistOnly",skipLabel:"Skip confirmation when removing from TV watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in TV watchlist",listNoun:"TV watchlist",continueNoun:"continue watching",adultCountUrl:"/api/tv/continue-watching/adult-count",purgeUrl:"/api/tv/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["tv-continue-watching"]]},asmr:{heading:"Listening List Preferences",blurb:"Customize your experience when managing your listening list and work entries.",skipKey:"asmrSkipRemoveConfirmation",ignoreKey:"asmrIgnoreAdultContent",listOnlyKey:"asmrCwWatchlistOnly",skipLabel:"Skip confirmation when removing from listening list",ignoreLabel:"Hide adult content from continue listening",listOnlyLabel:"Only show continue listening for works in listening list",listNoun:"listening list",continueNoun:"continue listening",adultCountUrl:"/api/asmr/continue-listening/adult-count",purgeUrl:"/api/asmr/continue-listening/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue listening`,invalidateKeys:[["asmr-continue-listening"]]}},Ut=(t,o)=>{if(t==null)return o;const c=String(t);return c==="true"||c==="1"?!0:c==="false"||c==="0"?!1:o},Se=(t,o,c)=>{const[g,p]=s(o),[h,k]=s(!1),y=te();return G(()=>{(async()=>{try{const m=await C.settings.getByKey.query({key:t});p(Ut(m.value,o))}catch(m){console.error("Failed to fetch setting",m)}})()},[t,o]),{value:g,setValue:p,isUpdating:h,toggle:async()=>{if(h)return;k(!0);const r=!g;p(r);try{await C.settings.set.mutate({key:t,value:r});for(const m of c)y.invalidateQueries({queryKey:m})}catch(m){console.error("Error saving setting:",m),p(!r)}finally{k(!1)}}}},Et=()=>{const{contentType:t}=Te(),o=Kt[t],[c,g]=s(!1),[p,h]=s(!0),[k,y]=s(!1),i=Se(o.ignoreKey,!0,o.invalidateKeys),r=Se(o.listOnlyKey,!1,o.invalidateKeys),[m,f]=s(null),[d,P]=s(!1),l=te(),v=Ee();G(()=>{h(!0),(async()=>{try{const N=await C.settings.getByKey.query({key:o.skipKey});String(N.value)==="true"||String(N.value)==="1"?g(!0):g(!1)}catch(N){console.error("Failed to fetch setting",N)}finally{h(!1)}})()},[o.skipKey]);const _=async()=>{if(k)return;y(!0);const a=!c;g(a);try{await C.settings.set.mutate({key:o.skipKey,value:a})}catch(N){console.error("Error saving setting:",N),g(!a)}finally{y(!1)}},T=async()=>{if(!i.isUpdating){if(i.value)try{let a;if(t==="anime"?a=(await C.continueWatching.adultCount.query()).count:t==="manga"?a=(await C.mangaProgress.adultCount.query()).count:t==="asmr"?a=(await C.asmrProgress.adultCount.query()).count:a=(await C.tvProgress.adultCount.query()).count,typeof a=="number"&&a>0){f(a);return}}catch(a){console.error("Failed to fetch adult count",a)}i.toggle()}},O=()=>{f(null),i.toggle()},I=async()=>{if(!d){P(!0);try{let a;t==="anime"?a=(await C.continueWatching.purgeAdult.mutate()).removed:t==="manga"?a=(await C.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?a=(await C.asmrProgress.purgeAdult.mutate()).removed:a=(await C.tvProgress.purgeAdult.mutate()).removed,Ce.success(o.purgeDoneText(a??0));for(const N of o.invalidateKeys)l.invalidateQueries({queryKey:N});t==="anime"&&l.invalidateQueries(v.continueWatching.pathFilter()),t==="manga"&&l.invalidateQueries(v.mangaProgress.pathFilter()),t==="asmr"&&l.invalidateQueries(v.asmrProgress.pathFilter()),t==="tv"&&l.invalidateQueries(v.tvProgress.pathFilter())}catch(a){console.error("Failed to purge adult entries",a),Ce.error("Failed to remove adult entries")}finally{P(!1),f(null)}i.toggle()}};return p?e("div",{children:"Loading settings..."}):e("div",{className:L.sectionCard,children:[e("h3",{children:o.heading}),e("p",{children:o.blurb}),e("div",{className:H.settingItem,children:e("div",{className:L.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:o.skipLabel}),e($,{isChecked:c,onChange:_,id:"skip-confirmation-toggle",disabled:k})]})}),e("div",{className:H.settingItem,children:e("div",{className:L.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:o.ignoreLabel}),e($,{isChecked:i.value,onChange:T,id:"ignore-adult-toggle",disabled:i.isUpdating})]})}),e("div",{className:H.settingItem,children:e("div",{className:L.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:o.listOnlyLabel}),e($,{isChecked:r.value,onChange:r.toggle,id:"cw-watchlist-only-toggle",disabled:r.isUpdating})]})}),m!==null&&e("div",{className:H.modalOverlay,onClick:()=>f(null),children:e("div",{className:H.modal,onClick:a=>a.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[m," adult ",m===1?"entry":"entries"," not in your"," ",o.listNoun," ",m===1?"is":"are"," currently hidden from"," ",o.continueNoun,". You can purge ",m===1?"it":"them"," from the database instead of showing ",m===1?"it":"them","."]}),e("div",{className:H.modalActions,children:[e("button",{type:"button",className:H.modalSecondary,onClick:O,disabled:d,children:"Show them"}),e("button",{type:"button",className:H.modalPrimary,onClick:I,disabled:d,children:d?"Purging...":`Purge ${m}`})]})]})})]})},Ft="_statsGrid_o4nf0_1",$t="_statCard_o4nf0_8",Wt="_statLabel_o4nf0_18",Ht="_statValue_o4nf0_26",Bt="_statMeta_o4nf0_32",jt="_statusBanner_o4nf0_38",Qt="_statusSuccess_o4nf0_49",Vt="_statusUpdating_o4nf0_55",Yt="_statusError_o4nf0_61",Jt="_sha_o4nf0_67",Xt="_settingItem_o4nf0_74",Zt="_settingTitle_o4nf0_79",ea="_settingSubtitle_o4nf0_85",ta="_actionsRow_o4nf0_92",D={statsGrid:Ft,statCard:$t,statLabel:Wt,statValue:Ht,statMeta:Bt,statusBanner:jt,statusSuccess:Qt,statusUpdating:Vt,statusError:Yt,sha:Jt,settingItem:Xt,settingTitle:Zt,settingSubtitle:ea,actionsRow:ta},aa=()=>{const[t,o]=s(null),[c,g]=s(!0),[p,h]=s(!1),[k,y]=s(!1),i=Z(null),r=async()=>{try{const l=await C.settings.offlineDbInfo.query();return o(l),l}catch(l){console.error("Failed to fetch offline DB info:",l)}finally{g(!1)}return null};G(()=>(r(),()=>{i.current&&window.clearInterval(i.current)}),[]),G(()=>{t?.isRefreshing?i.current||(i.current=window.setInterval(async()=>{const l=await r();l&&!l.isRefreshing&&i.current&&(window.clearInterval(i.current),i.current=null)},2e3)):i.current&&(window.clearInterval(i.current),i.current=null)},[t?.isRefreshing]);const m=async()=>{if(!t||p)return;const l=!t.autoUpdateEnabled;h(!0),o({...t,autoUpdateEnabled:l});try{await C.settings.setOfflineDbAutoUpdate.mutate({enabled:l})}catch(v){console.error("Failed to update auto update setting:",v),o({...t,autoUpdateEnabled:!l})}finally{h(!1)}},f=async()=>{if(!(t?.isRefreshing||k)){y(!0);try{await C.settings.triggerOfflineDbUpdate.mutate(),o(l=>l?{...l,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(l){console.error("Failed to trigger offline DB update:",l)}finally{y(!1)}}},d=l=>{if(!l)return"Never";try{return new Date(l).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return l}},P=t?.isRefreshing||k;return e("div",{className:L.sectionCard,children:[e("h3",{children:"Offline Metadata Database"}),e("p",{children:"Local MAL to AniList ID map used for instant imports and metadata enrichment without hitting rate-limited APIs. Updates automatically every Saturday in the background."}),e("div",{className:D.statsGrid,children:[e("div",{className:D.statCard,children:[e("span",{className:D.statLabel,children:"MAL Mapped"}),e("span",{className:D.statValue,children:c?"-":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:D.statCard,children:[e("span",{className:D.statLabel,children:"Release"}),e("span",{className:D.statMeta,children:c?"-":t?.releaseTag??"Never"})]}),e("div",{className:D.statCard,children:[e("span",{className:D.statLabel,children:"Last Checked"}),e("span",{className:D.statMeta,children:c?"-":d(t?.lastCheckedAt??null)})]}),e("div",{className:D.statCard,children:[e("span",{className:D.statLabel,children:"Last Updated"}),e("span",{className:D.statMeta,children:c?"-":d(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${D.statusBanner} ${t.lastStatus==="failed"?D.statusError:t.lastStatus==="updating"?D.statusUpdating:D.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:D.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:D.settingItem,children:e("div",{className:L.settingRow,children:[e("div",{children:[e("span",{className:D.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:D.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e($,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:m,disabled:c||p})]})}),e("div",{className:D.actionsRow,children:e(S,{onClick:f,disabled:c||P,children:P?"Updating Database...":"Update Offline Database Now"})})]})},na="_status_1wbo0_1",ra="_warningText_1wbo0_7",sa="_ackLabel_1wbo0_11",he={status:na,warningText:ra,ackLabel:sa},ia=()=>{const t=te(),[o,c]=s(!1),[g,p]=s(!1),[h,k]=s(!1),[y,i]=s(""),r=()=>{p(!1),i(""),c(!0)},m=()=>{h||(c(!1),p(!1))},f=async()=>{if(!(!g||h)){k(!0),i("");try{const d=await X("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),P=await d.json();if(!d.ok)throw new Error(P.error||"Failed to clear database");const l=P.deleted,v=P.deletedManga,_=P.deletedTv,T=P.deletedAsmr,O=Object.values(l).reduce((R,q)=>R+(q||0),0)+Object.values(v??{}).reduce((R,q)=>R+(q||0),0)+Object.values(_??{}).reduce((R,q)=>R+(q||0),0)+Object.values(T??{}).reduce((R,q)=>R+(q||0),0),I=(v?.manga_library??0)+(v?.manga_progress??0),a=(_?.tv_library??0)+(_?.tv_progress??0),N=(T?.asmr_library??0)+(T?.asmr_progress??0);i(`Library cleared - ${l.watchlist??0} watchlist entries, ${I} manga rows, ${a} TV rows, ${N} ASMR rows and ${O} total rows removed.`),t.invalidateQueries({queryKey:[W.watchlist]}),t.invalidateQueries({queryKey:[W.continueWatching]}),t.invalidateQueries({queryKey:[W.mangaLibrary]}),t.invalidateQueries({queryKey:[W.mangaContinueReading]}),t.invalidateQueries({queryKey:[W.tvLibrary]}),t.invalidateQueries({queryKey:[W.tvContinueWatching]}),t.invalidateQueries({queryKey:[W.asmrLibrary]}),t.invalidateQueries({queryKey:[W.asmrContinueListening]}),c(!1)}catch(d){i(d.message)}finally{k(!1),p(!1)}}};return e("div",{className:`${L.sectionCard} ${L.dangerCard}`,children:[e("h3",{children:"Danger Zone"}),e("p",{children:"Permanently delete your library (watchlist, watched episodes, queue, cached show metadata, manga reading list and reading progress, TV watchlist and watch progress, ASMR listening list and listening progress) to start fresh. Your settings, sync state and the offline metadata cache are preserved."}),e(S,{variant:"danger",onClick:r,children:"Clear Library Data"}),y&&e("p",{className:he.status,children:y}),e(U,{isOpen:o,onClose:m,title:"Clear library data?",width:"sm",children:[e(U.Body,{children:[e("p",{className:he.warningText,children:"This permanently deletes everything in your library. It acts on the active database (dev or prod, per server config) and cannot be undone. Settings, sync state and the offline metadata cache are kept."}),e("label",{className:he.ackLabel,children:[e("input",{type:"checkbox",checked:g,onChange:d=>p(d.currentTarget.checked),disabled:h}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(U.Actions,{children:[e(S,{variant:"secondary",onClick:m,disabled:h,children:"Cancel"}),e(S,{variant:"danger",onClick:f,disabled:!g||h,children:h?"Clearing...":"Yes, delete everything"})]})]})]})},oa=()=>{const[t,o]=s(""),[c,g]=s([]),[p,h]=s(null),[k,y]=s(!0),[i,r]=s({show:!1,message:"",type:"info"}),m=async()=>{try{y(!0);const d=await C.auth.rcloneSettings.query();o(d.remote||""),g(d.availableRemotes||[]),h(d.activeRemote||null)}catch(d){console.error("Failed to fetch Rclone settings",d)}finally{y(!1)}};G(()=>{m()},[]);const f=async()=>{try{await C.auth.saveRclone.mutate({remote:t}),r({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),m()}catch{r({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return k?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:L.sectionCard,children:[e("h3",{className:w.title,children:"Rclone Cloud Sync"}),e("p",{className:w.signIn,children:"Configure which Rclone remote to use for database synchronization."}),p?e("div",{className:w.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:p})]})}):e("p",{className:w.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:w.formGroup,children:[e("label",{className:w.label,children:"Remote Name"}),e("div",{className:w.inputWrapper,children:e("select",{className:w.select,value:t,onChange:d=>o(d.currentTarget.value),children:[e("option",{value:"",children:"(Disabled / None)"}),c.map(d=>e("option",{value:d,children:d},d)),t&&!c.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:w.warning,style:{marginTop:"12px"},children:[e("strong",{children:"Note:"})," You can choose which provider is active using the selector at the top of the page."]})]}),e("div",{className:w.actions,children:e(S,{onClick:f,children:"Save Rclone Settings"})}),e(U,{isOpen:i.show,onClose:()=>r(d=>({...d,show:!1})),width:"sm",children:[e(U.Body,{children:e("p",{children:i.message})}),e(U.Actions,{children:e(S,{onClick:()=>r(d=>({...d,show:!1})),children:"OK"})})]})]})},la=()=>{const t=te(),[o,c]=s(null),[g,p]=s(!0),h=async()=>{try{const r=await C.auth.syncSettings.query();c(r)}catch(r){console.error("Failed to fetch sync settings",r)}finally{p(!1)}};G(()=>{h()},[]);const k=async r=>{const m=r.currentTarget.value;try{const f=await C.auth.saveSyncProvider.mutate({provider:m});c(d=>d?{...d,activeProvider:f.activeProvider}:null),await h(),await t.invalidateQueries({queryKey:ee.queryKey}),ke.success(`Sync provider updated to ${m==="default"?"Default Order":m}`)}catch{ke.error("Failed to update sync provider")}};if(g||!o)return null;const y=[{value:"default",label:"Default (Priority Based)"}];o.authenticatedProviders.github&&y.push({value:"github",label:"GitHub"}),o.authenticatedProviders.google&&y.push({value:"google",label:"Google Drive"}),o.authenticatedProviders.rclone&&y.push({value:"rclone",label:"Rclone"}),y.push({value:"none",label:"None (Local Only)"});const i=r=>r==="none"?"Local Only (No Sync)":r==="google"?"Google Drive":r==="github"?"GitHub":r==="rclone"?"Rclone":r;return e("div",{className:L.sectionCard,children:[e("h3",{children:"Active Sync Provider"}),e("p",{children:'Choose which provider to use for synchronization. "Default" uses the first available provider you are logged into.'}),e("div",{style:{marginBottom:"1.5rem",padding:"0.75rem",background:"rgba(255, 255, 255, 0.03)",borderRadius:"var(--radius-md)",borderLeft:"4px solid var(--accent)",fontSize:"var(--font-size-sm)"},children:["Current Status:"," ",e("strong",{style:{color:"var(--accent-light)",textTransform:"capitalize"},children:i(o.actualActiveProvider)})]}),e("div",{className:L.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:o.activeProvider,onChange:k,style:{padding:"0.5rem",borderRadius:"var(--radius-md)",background:"rgba(255, 255, 255, 0.05)",color:"var(--text-primary)",border:"1px solid var(--glass-border)",fontSize:"var(--font-size-sm)",minWidth:"220px",outline:"none",cursor:"pointer"},children:y.map(r=>e("option",{value:r.value,children:r.label},r.value))})]})]})};function ca(){return"javascript:"+encodeURIComponent(`(function(){
2
- if(!/(^|\\.)discord\\.com$/.test(location.hostname)){alert('Dango: use this bookmarklet while on discord.com');return}
3
- var t=null;
4
- try{
5
- window.webpackChunkdiscord_app.push([[Symbol()],{},function(req){
6
- if(!req.c)return;
7
- var ms=Object.values(req.c);
8
- for(var i=0;i<ms.length;i++){var m=ms[i];
9
- try{
10
- if(!m.exports||m.exports===window)continue;
11
- if(typeof m.exports.getToken==='function'){var x=m.exports.getToken();if(x){t=x;return}}
12
- for(var k in m.exports){try{var ex=m.exports[k];if(ex&&typeof ex.getToken==='function'&&ex[Symbol.toStringTag]!=='IntlMessagesProxy'){var y=ex.getToken();if(y){t=y;return}}}catch(e1){}}
13
- }catch(e2){}}
14
- }]);
15
- window.webpackChunkdiscord_app.pop();
16
- }catch(e3){}
17
- if(!t){alert('Dango: could not grab your token. Make sure you are logged in to Discord in this tab, then run the bookmarklet again.');return}
18
- function copyFallback(){var a=document.createElement('textarea');a.value=t;a.style.position='fixed';a.style.opacity='0';document.body.appendChild(a);a.select();try{document.execCommand('copy')}catch(e4){}document.body.removeChild(a)}
19
- var done=function(){window.close();setTimeout(function(){if(!window.closed){alert('Dango: token copied to clipboard! Could not close this tab, so just close it, go back to Dango Settings, paste the token and press Save.')}},250)};
20
- if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(t).then(done,function(){copyFallback();done()})}else{copyFallback();done()}
21
- })()`)}const da=()=>{const t=Me(ca,[]);return e("div",{style:{marginTop:"0.9rem",paddingTop:"0.9rem",borderTop:"1px dashed var(--border-color)"},children:[e("h4",{style:{margin:"0 0 0.35rem",fontSize:"0.95rem"},children:"Grab the token automatically (bookmarklet)"}),e("p",{style:{margin:"0 0 0.6rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Set this up once and you never have to dig through DevTools: the bookmarklet copies your Discord token to the clipboard and closes the Discord tab - then you just paste it above and press Save."}),e("ol",{style:{margin:"0 0 0.75rem",paddingLeft:"1.25rem",fontSize:"0.85rem",color:"var(--text-secondary)",display:"grid",gap:"0.3rem"},children:[e("li",{children:["Drag the ",e("strong",{style:{color:"var(--text-primary)"},children:"Dango Token Grabber"})," ","button below onto your bookmarks bar (press ",e("kbd",{children:"Ctrl"}),"+",e("kbd",{children:"Shift"}),"+",e("kbd",{children:"B"})," ","first if the bar is hidden)."]}),e("li",{children:["Click ",e("strong",{style:{color:"var(--text-primary)"},children:"Open Discord"})," and log in (skip this if you are already logged in)."]}),e("li",{children:["On the Discord tab, click the"," ",e("strong",{style:{color:"var(--text-primary)"},children:"Dango Token Grabber"})," bookmark. The token lands in your clipboard and the tab closes on its own - come back here, paste it above and press ",e("strong",{children:"Save"}),"."]})]}),e("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",flexWrap:"wrap"},children:[e("a",{href:t,onClick:g=>{g.preventDefault(),alert("Drag this button onto your bookmarks bar instead of clicking it, then click it while you are on discord.com.")},title:"Drag me to your bookmarks bar",draggable:!0,style:{display:"inline-flex",alignItems:"center",padding:"0.4rem 0.8rem",borderRadius:"999px",border:"1px dashed var(--accent)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:"0.85rem",textDecoration:"none",cursor:"grab",userSelect:"none"},children:[e(B,{name:"bookmark",style:{marginRight:"0.45rem",color:"var(--accent)"}}),"Dango Token Grabber"]}),e("a",{className:"btn btn-secondary btn-sm",href:"https://discord.com/channels/@me",target:"_blank",rel:"noopener noreferrer",children:"Open Discord"}),e(S,{variant:"ghost",size:"sm",onClick:async()=>{try{await navigator.clipboard.writeText(t),alert('Bookmarklet code copied. Create a new bookmark on your bookmarks bar, name it "Dango Token" and paste the code as its URL.')}catch{alert(`Could not copy automatically. Right-click the "Dango Token Grabber" button and choose "Copy link address" instead, then paste that into a new bookmark's URL.`)}},children:"Copy code"})]}),e("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:`"Copy code" is a fallback for browsers that won't drag bookmarklets: create any bookmark, then paste the copied code as its URL.`})]})},ua="_settingItem_68mz3_1",ha="_field_68mz3_6",ga="_input_68mz3_19",ma="_actions_68mz3_39",pa="_status_68mz3_45",E={settingItem:ua,field:ha,input:ga,actions:ma,status:pa},fa=()=>{const[t,o]=s(!1),[c,g]=s(""),[p,h]=s(""),[k,y]=s(!0),[i,r]=s(!1),[m,f]=s("");G(()=>{(async()=>{try{const T=await(await X("/api/auth/app-status")).json();o(T.hasPassword)}catch{console.error("Failed to fetch LAN auth status")}finally{y(!1)}})()},[]);const d=async()=>{if(f(""),c!==p){f("Passwords do not match");return}if(c.length<4){f("Password must be at least 4 characters");return}r(!0);try{const v=await X("/api/auth/app-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:c})}),_=await v.json();if(!v.ok){f(_.error||"Failed to update password");return}o(_.hasPassword),g(""),h(""),f(_.hasPassword?"Password set successfully":"Password removed")}catch{f("Network error")}finally{r(!1)}},P=async()=>{r(!0);try{const v=await X("/api/auth/app-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:""})}),_=await v.json();if(!v.ok){f(_.error||"Failed to remove password");return}o(!1),g(""),h(""),f("Password removed")}catch{f("Network error")}finally{r(!1)}},l=async()=>{r(!0);try{await X("/api/auth/app-logout",{method:"POST"}),f("Logged out"),window.location.reload()}catch{f("Logout failed")}finally{r(!1)}};return k?e("div",{className:L.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:L.sectionCard,children:[e("h3",{children:"LAN Lock"}),e("p",{children:"Require a password to access this instance from any device, including this one. Sessions persist across server restarts until logout or password change."}),e("div",{className:E.settingItem,children:[e("div",{className:E.field,children:[e("label",{htmlFor:"lan-password",children:"New Password"}),e("input",{id:"lan-password",type:"password",value:c,onChange:v=>g(v.currentTarget.value),placeholder:t?"Leave empty to keep current password":"Enter a password...",className:E.input})]}),e("div",{className:E.field,children:[e("label",{htmlFor:"lan-confirm-password",children:"Confirm Password"}),e("input",{id:"lan-confirm-password",type:"password",value:p,onChange:v=>h(v.currentTarget.value),placeholder:"Confirm password...",className:E.input})]}),e("div",{className:E.actions,children:[e(S,{variant:"primary",onClick:d,loading:i,disabled:i,children:t?"Update Password":"Set Password"}),t&&e(S,{variant:"danger",onClick:l,loading:i,disabled:i,children:"Logout"}),t&&e(S,{variant:"secondary",onClick:P,loading:i,disabled:i,children:"Remove Password"})]}),m&&e("p",{className:E.status,children:m})]})]})},ya=()=>{const[t,o]=s(""),[c,g]=s(!0),[p,h]=s(!1),[k,y]=s("");G(()=>{J("/api/auth/app-status").then(r=>o(String(r.port??3e3))).catch(()=>y("Failed to load current port")).finally(()=>g(!1))},[]);const i=async()=>{const r=Number(t);if(!Number.isInteger(r)||r<1||r>65535){y("Enter a port between 1 and 65535");return}h(!0),y("");try{await C.auth.setServerPort.mutate({port:r}),y(`Saved. Restart dango, then open http://localhost:${r} - this overrides the PORT environment variable.`)}catch(m){y(m.message)}finally{h(!1)}};return c?e("div",{className:L.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:L.sectionCard,children:[e("h3",{children:"Server Port"}),e("p",{children:"Port the backend listens on. Takes effect after a restart. Google and AniList sign-in need the matching redirect URI registered with the provider."}),e("div",{className:E.settingItem,children:[e("div",{className:E.field,children:[e("label",{htmlFor:"server-port",children:"Port"}),e("input",{id:"server-port",type:"number",min:1,max:65535,value:t,onChange:r=>o(r.currentTarget.value),className:E.input})]}),e("div",{className:E.actions,children:e(S,{variant:"primary",onClick:i,loading:p,disabled:p,children:"Save Port"})}),k&&e("p",{className:E.status,children:k})]})]})},va=()=>{const{theme:t,setTheme:o,loading:c}=Fe();return e("div",{children:[e("h4",{style:{margin:"0 0 0.25rem",fontSize:"1rem"},children:"Palette"}),e("p",{style:{margin:"0 0 0.75rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Taro is the default. Pick a palette that suits you."}),e("div",{role:"radiogroup","aria-label":"Palette",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"0.6rem"},children:$e.map(g=>{const p=t===g.id;return e("button",{role:"radio","aria-checked":p,disabled:c,onClick:()=>o(g.id),style:{display:"flex",gap:"0.6rem",alignItems:"center",textAlign:"left",padding:"0.65rem 0.75rem",borderRadius:"10px",cursor:"pointer",background:p?"var(--accent-subtle)":"var(--bg-tertiary)",border:p?"1px solid var(--accent)":"1px solid var(--border-primary)",color:"var(--text-primary)"},children:[e("span",{"aria-hidden":!0,style:{width:26,height:26,borderRadius:"50%",flex:"none",background:g.swatch,border:"1px solid rgba(0,0,0,0.35)"}}),e("span",{style:{minWidth:0},children:[e("span",{style:{display:"block",fontSize:"0.85rem",fontWeight:700},children:g.label}),e("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g.blurb})]})]},g.id)})})]})};function wa({variant:t="info",children:o,className:c=""}){return e("div",{className:`alert alert-${t} ${c}`,children:o})}const ba={anime:"Watchlist",manga:"Reading List",tv:"TV Watchlist",asmr:"Listening List"},Ne=["general","presence","server","sync","watchlist","database"],La=()=>{const{data:t}=pe(ee),[o,c]=qe(),{contentType:g}=Te(),p=o.get("tab"),[h,k]=s(p&&Ne.includes(p)?p:"general"),[y,i]=s(""),r=Z(null),m=Z(null),f=Z(new Map),[d,P]=s({top:0,height:0,left:0,width:0}),{lowEndMode:l,setLowEndMode:v}=We(),{hasConsent:_,grant:T,revoke:O}=He(),[I,a]=s(!1),[N,R]=s(Be),[q,x]=s(!0),{data:A}=le("discordRPCEnabled"),M=_e(),[j,Q]=s(!0),{data:b}=le("dangoGaze"),[Le,fe]=s(!0),{data:ae}=le("discordRPCHideMature"),[ye,ie]=s(""),[ne,oe]=s(null);G(()=>{t?.owner&&C.discord.gatewayStatus.query().then(n=>{oe(n),n.masked&&n.masked!=="none"&&ie(n.masked)}).catch(()=>{})},[t?.owner]),G(()=>{A!==void 0&&x(A==="true"||A===!0||A===null)},[A]),G(()=>{ae!==void 0&&fe(ae==="true"||ae===!0||ae===null)},[ae]);const Pe=n=>{x(n),M.mutate({key:"discordRPCEnabled",value:String(n)})};G(()=>{b!==void 0&&Q(b!=="false"&&b!==!1)},[b]);const Ie=n=>{Q(n),M.mutate({key:"dangoGaze",value:String(n)})},xe=n=>{fe(n),M.mutate({key:"discordRPCHideMature",value:String(n)})},Re=n=>{R(n),je.setItem(Qe,String(n)),window.dispatchEvent(new CustomEvent(Ve))};we.useEffect(()=>{document.title="Settings - dango"},[]),we.useEffect(()=>{const n=o.get("tab");n&&Ne.includes(n)&&k(n)},[o]);const V=n=>{k(n),c(n==="general"?{}:{tab:n})},re=me(()=>{const n=f.current.get(h),z=m.current;if(n&&z){const Y=z.getBoundingClientRect(),F=n.getBoundingClientRect(),se=window.matchMedia("(max-width: 900px)").matches;P(se?{top:F.top-Y.top,height:F.height,left:F.left-Y.left,width:F.width}:{top:F.top-Y.top,height:F.height,left:0,width:0})}},[h]);ze(()=>{re()},[h,re]),G(()=>{const n=()=>re();window.addEventListener("resize",n);let z=!1;return document.fonts?.ready&&document.fonts.ready.then(()=>{z||re()}),()=>{z=!0,window.removeEventListener("resize",n)}},[h,re]);const De=()=>{i("Exporting databases...");const n=window.DangoBridge;if(n?.downloadFile){n.downloadFile("/api/backup-db","dango-backup.json"),setTimeout(()=>{i("Databases exported successfully!")},1500);return}const z=document.createElement("a");z.href="/api/backup-db",z.download="dango-backup.json",document.body.appendChild(z),z.click(),z.remove(),setTimeout(()=>{i("Databases exported successfully!")},1500)},Ae=async n=>{const z=n.currentTarget.files?.[0];if(!z)return;i("Importing databases...");const Y=new FormData;Y.append("dbfile",z);try{const F=await X("/api/restore-db",{method:"POST",body:Y}),se=await F.json();if(F.ok){const ve=Array.isArray(se.restored)?se.restored.join(", "):null;i(ve?`Databases imported successfully (${ve})!`:"Database imported successfully!"),setTimeout(()=>window.location.reload(),2e3)}else i(`Import failed: ${se.error}`)}catch{i("Import failed: An unexpected error occurred.")}finally{n.currentTarget.value=""}},Oe=()=>{r.current?.click()},Ge=()=>{switch(h){case"general":return e("div",{className:u.tabContent,children:[e(et,{}),e("div",{className:L.sectionCard,children:[e("h3",{children:"Appearance & Preferences"}),e("p",{children:"Configure how titles are displayed and other general preferences."}),e("div",{className:u.settingItem,children:e(tt,{})}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e(va,{})}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:L.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Low End Mode"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Disables animations and heavy visual effects for better performance on older hardware."})]}),e($,{isChecked:l,onChange:n=>v(n.currentTarget.checked),id:"low-end-mode"})]})}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:L.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Dango Animations"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Lets the dango logo look around, blink and react when you pet it. Always off in Low End Mode."})]}),e($,{isChecked:j,onChange:n=>Ie(n.currentTarget.checked),id:"dango-gaze"})]})}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:L.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Virtual Keyboard"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Shows an on-screen keyboard when text search fields are focused."})]}),e($,{isChecked:N,onChange:n=>Re(n.currentTarget.checked),id:"virtual-keyboard-enabled"})]})})]}),e("section",{className:L.sectionCard,children:[e("h3",{children:"Keyboard Shortcuts"}),e("p",{children:"Use S or Ctrl+K to focus search anywhere, or use player keys while watching."}),e("div",{className:u.shortcutContainer,children:[e("div",{className:u.shortcutGroup,children:[e("h4",{className:u.shortcutGroupTitle,children:"Search"}),e("div",{className:u.shortcutGrid,children:[e("div",{className:u.shortcutCard,children:[e("kbd",{children:"S"}),e("span",{children:"Focus search"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"Ctrl + K / ⌘ + K"}),e("span",{children:"Focus search"})]})]})]}),e("div",{className:u.shortcutGroup,children:[e("h4",{className:u.shortcutGroupTitle,children:"Player"}),e("div",{className:u.shortcutGrid,children:[e("div",{className:u.shortcutCard,children:[e("kbd",{children:"Space / K"}),e("span",{children:"Play / pause"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"J / L · ← / →"}),e("span",{children:"Seek back / fwd"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"↑ / ↓"}),e("span",{children:"Adjust volume"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"M / F"}),e("span",{children:"Mute / fullscreen"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"N / P"}),e("span",{children:"Next / prev episode"})]}),e("div",{className:u.shortcutCard,children:[e("kbd",{children:"T"}),e("span",{children:"Theater mode"})]})]})]})]})]})]});case"presence":return e("div",{className:u.tabContent,children:e("div",{className:L.sectionCard,children:[e("h3",{children:"Presence & Content"}),e("p",{children:"Control what Dango shares on Discord and your mature-content preference."}),t?.owner&&e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:L.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Discord Rich Presence"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Show your current anime and watch progress on your Discord profile status."})]}),e($,{isChecked:q,onChange:n=>Pe(n.currentTarget.checked),id:"discord-rpc-enabled"})]})}),t?.owner&&q&&e("div",{className:u.settingItem,style:{marginTop:"1rem"},children:e("div",{className:L.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Hide Mature Content"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Hide mature content (18+) from Discord Rich Presence."})]}),e($,{isChecked:Le,onChange:n=>xe(n.currentTarget.checked),id:"discord-hide-mature"})]})}),t?.owner&&e("div",{className:u.settingItem,style:{marginTop:"1.5rem",background:"var(--bg-tertiary)",padding:"1rem",borderRadius:"8px",border:"1px solid var(--border-color)"},children:[e("div",{className:L.settingRow,children:e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Discord Mobile Presence (Gateway)"}),e("p",{style:{margin:"0.25rem 0 0.75rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Paste your Discord authentication token to enable presence on mobile devices. If no token is saved, the default desktop Rich Presence is used. The token is stored locally in your configuration and never shared."})]})}),e(wa,{variant:"warning",style:{marginTop:"1.25rem",paddingTop:"1.25rem"},children:[e("strong",{children:"Use at your own risk."})," This feature uses the Discord Gateway API with your user token, which violates Discord's Terms of Service. Discord may detect this usage and take action against your account, including phone number locks, temporary suspensions, or permanent bans. While the risk is generally low, it is not zero. Only use this if you understand and accept the risks."]}),e("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem",alignItems:"center",flexWrap:"wrap"},children:[e("input",{type:"password",value:ye,onChange:n=>ie(n.currentTarget.value),placeholder:"Paste Discord token here...",style:{flex:"1 1 200px",padding:"0.5rem",borderRadius:"4px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)",fontFamily:"monospace",minWidth:0}}),e(S,{variant:"primary",size:"sm",onClick:async()=>{try{const n=await C.discord.gatewaySave.mutate({token:ye});oe({hasToken:!0,masked:n.masked,enabled:!0}),ie(n.masked)}catch(n){alert(n instanceof Error?n.message:"Failed to save token")}},children:"Save"}),e(S,{variant:"secondary",size:"sm",onClick:async()=>{await C.discord.gatewayRemove.mutate().catch(()=>{}),ie(""),oe({hasToken:!1,masked:null,enabled:!1})},children:"Remove"})]}),ne&&e("p",{style:{marginTop:"0.5rem",fontSize:"0.8rem",color:ne.hasToken?"green":"var(--text-secondary)"},children:["Status:"," ",ne.hasToken?`Token saved (${ne.masked})`:"No token saved",ne.enabled?" - Gateway active":""]}),t?.owner&&e(da,{})]}),e("div",{className:u.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:L.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Mature Content"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Allow mature content intended for adults 18 and older. Turning this off restores filtering and blur gates."})]}),e($,{isChecked:_,onChange:n=>{n.currentTarget.checked?a(!0):(O(),window.location.reload())},id:"mature-content-enabled"})]})})]})});case"server":return e("div",{className:u.tabContent,children:[t?.owner&&e(fa,{}),t?.owner&&e(ya,{})]});case"sync":return e("div",{className:u.tabContent,children:[e(la,{}),e(Rt,{}),e(Dt,{}),t?.owner&&e(oa,{})]});case"watchlist":return e("div",{className:u.tabContent,children:e(Et,{})});case"database":return e("div",{className:u.tabContent,children:[e("div",{className:L.sectionCard,children:[e("h3",{children:"Database Management"}),e("p",{children:"Download a backup of all databases (anime, manga, TV and ASMR) or restore from a backup file. Legacy single-file anime (.db) backups can still be restored."}),e("div",{className:u.controls,children:[e(S,{onClick:De,children:"Backup Database"}),e(S,{variant:"secondary",onClick:Oe,children:"Restore Database"})]}),e("input",{type:"file",ref:r,onChange:Ae,style:{position:"absolute",width:1,height:1,opacity:0,overflow:"hidden"},accept:".json,.db,application/octet-stream"}),y&&e("p",{className:u.status,children:y})]}),t?.owner&&e(aa,{}),e(ia,{})]});default:return null}};return e("div",{className:"page-container",children:[e("div",{className:u.settingsHeader,children:[e("h1",{className:u.pageTitle,children:"Settings"}),e("p",{className:u.pageSubtitle,children:"Manage your preferences and data synchronization"})]}),e("div",{className:u.settingsLayout,children:[e("aside",{className:u.sidebar,ref:m,children:[e("div",{className:u.sidebarIndicator,style:{top:d.top,height:d.height,left:d.left,...d.width?{width:d.width}:{}}}),e("button",{ref:n=>{n&&f.current.set("general",n)},className:`${u.sidebarItem} ${h==="general"?u.active:""}`,onClick:()=>V("general"),children:[e(B,{name:"cog"})," ",e("span",{children:"General"})]}),e("button",{ref:n=>{n&&f.current.set("presence",n)},className:`${u.sidebarItem} ${h==="presence"?u.active:""}`,onClick:()=>V("presence"),children:[e(B,{name:"discord"})," ",e("span",{children:"Presence"})]}),e("button",{ref:n=>{n&&f.current.set("server",n)},className:`${u.sidebarItem} ${h==="server"?u.active:""}`,onClick:()=>V("server"),children:[e(B,{name:"server"})," ",e("span",{children:"Server"})]}),e("button",{ref:n=>{n&&f.current.set("sync",n)},className:`${u.sidebarItem} ${h==="sync"?u.active:""}`,onClick:()=>V("sync"),children:[e(B,{name:"cloud"})," ",e("span",{children:"Synchronization"})]}),e("button",{ref:n=>{n&&f.current.set("watchlist",n)},className:`${u.sidebarItem} ${h==="watchlist"?u.active:""}`,onClick:()=>V("watchlist"),children:[e(B,{name:"list"})," ",e("span",{children:ba[g]})]}),e("button",{ref:n=>{n&&f.current.set("database",n)},className:`${u.sidebarItem} ${h==="database"?u.active:""}`,onClick:()=>V("database"),children:[e(B,{name:"database"})," ",e("span",{children:"Database"})]})]}),e("main",{className:u.mainContent,children:e("div",{className:u.tabContent,children:Ge()},h)})]}),e(Ye,{isOpen:I,onClose:()=>a(!1),onGrant:()=>{T(),a(!1)},scope:"section"})]})};export{La as default};