@serifpersia/dango 3.4.4 → 3.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-4CEz8Buu.js → AnimeCard-I3S6qw9d.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-DyX9qTwg.js → AnimeInfo-CLU2NSBR.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-Dvp_c8vK.js → AnimeInfoPage-4Mw9ArDy.js} +2 -2
  5. package/client/dist/assets/{Asmr-qg3lMAJn.js → Asmr-DN9XBc5Y.js} +1 -1
  6. package/client/dist/assets/{AsmrResetProgressModal-BpPlg_Vv.js → AsmrResetProgressModal-DyU1Z2Gw.js} +1 -1
  7. package/client/dist/assets/{AvSyncCalibrator-FJllOgOH.js → AvSyncCalibrator-DxL0mr_4.js} +1 -1
  8. package/client/dist/assets/{Home-A7gCeEST.js → Home-CeTeJ-gM.js} +1 -1
  9. package/client/dist/assets/{Insights-G9IXepHJ.js → Insights-i34-qV4C.js} +1 -1
  10. package/client/dist/assets/{LibraryListPage-Bh2qCJPh.js → LibraryListPage-DE-ASOX2.js} +1 -1
  11. package/client/dist/assets/{ListeningList-Czv4cTRl.js → ListeningList-DrNce5ll.js} +1 -1
  12. package/client/dist/assets/{Manga-qdAAS1z7.js → Manga-DOrf7Fk6.js} +1 -1
  13. package/client/dist/assets/{MangaInfoPage-1rTgZzf2.js → MangaInfoPage-CAZMLMGw.js} +1 -1
  14. package/client/dist/assets/{MangaReadPage-CeyxPG6w.js → MangaReadPage-DQVEo8_F.js} +1 -1
  15. package/client/dist/assets/{MangaResetProgressModal-C_ppotmh.js → MangaResetProgressModal-DOjpLAMp.js} +1 -1
  16. package/client/dist/assets/{Mature-Bkhxnr3K.js → Mature-D2xb9EGB.js} +1 -1
  17. package/client/dist/assets/{MediaCard-BQZsutEo.js → MediaCard-CKUEcFTd.js} +1 -1
  18. package/client/dist/assets/{Music-C0rGzSbi.js → Music-w_a34r7r.js} +1 -1
  19. package/client/dist/assets/{OptionListMenu-CyfpCBEy.js → OptionListMenu-DxZHBMIZ.js} +1 -1
  20. package/client/dist/assets/{Player-yhiTlpYU.js → Player-B8YHeATv.js} +2 -2
  21. package/client/dist/assets/{PlayerSettings-icy4SfQa.js → PlayerSettings-Ddlg-MvW.js} +1 -1
  22. package/client/dist/assets/{QueueOptionsButton-5eloKF5J.js → QueueOptionsButton-BMvAC6Ut.js} +1 -1
  23. package/client/dist/assets/{QueueRail-DaMjlKL4.js → QueueRail-CAoGJvHP.js} +1 -1
  24. package/client/dist/assets/{Radio-FxGqCxR4.js → Radio-6O7rAUv1.js} +1 -1
  25. package/client/dist/assets/{ReadingList-CCm3IAbt.js → ReadingList-k3g8oHvs.js} +1 -1
  26. package/client/dist/assets/{ResetProgressModal-CeI4V3Y5.js → ResetProgressModal-vFC6N-Qw.js} +1 -1
  27. package/client/dist/assets/{Search-qpILaAiQ.js → Search-Bh9Y6nIJ.js} +1 -1
  28. package/client/dist/assets/{Settings-Bw9M3NGz.js → Settings-DRumujfh.js} +1 -1
  29. package/client/dist/assets/{SkeletonGrid-0dY_xMq3.js → SkeletonGrid-BtzUnQE0.js} +1 -1
  30. package/client/dist/assets/{Trackers-Zy5GOs0P.js → Trackers-D0nqy8wu.js} +1 -1
  31. package/client/dist/assets/{Tv-DREwc7BX.js → Tv-DVebLMNS.js} +1 -1
  32. package/client/dist/assets/{TvInfo-CHIsVzZ0.js → TvInfo-BkECbOKN.js} +1 -1
  33. package/client/dist/assets/{TvPopup-D_tVTyZ2.js → TvPopup-D8WWY6o4.js} +1 -1
  34. package/client/dist/assets/{TvSearch-BVxedBW-.js → TvSearch-kWPep3gL.js} +1 -1
  35. package/client/dist/assets/{TvWatchlist-BEIwq9R9.js → TvWatchlist-dD4emIHx.js} +1 -1
  36. package/client/dist/assets/{Watchlist-CSngjqlz.js → Watchlist-cWxw38nU.js} +1 -1
  37. package/client/dist/assets/{hls-D48GVTkk.js → hls-uG_Y3i5s.js} +1 -1
  38. package/client/dist/assets/{index-CVB5dYhT.js → index-BWIWE3Qy.js} +2 -2
  39. package/client/dist/assets/{useAnimeInfoData-DxdOg_B7.js → useAnimeInfoData-DjPBg24u.js} +1 -1
  40. package/client/dist/assets/{useAsmr-ClckxnPe.js → useAsmr-DQyobNQX.js} +1 -1
  41. package/client/dist/assets/{useAsmrPopup-Bbgxefy_.js → useAsmrPopup-CDoroMBD.js} +1 -1
  42. package/client/dist/assets/{useMangaLibrary-B3_BUKVk.js → useMangaLibrary-C6L8mrnS.js} +1 -1
  43. package/client/dist/assets/{useMangaPopup-Celk4lzf.js → useMangaPopup-BSuMa_vA.js} +1 -1
  44. package/client/dist/assets/{useProviders-pwxPZPHh.js → useProviders-XIdvDof6.js} +1 -1
  45. package/client/dist/assets/{useTv-D9sQrDop.js → useTv-DzSYasru.js} +1 -1
  46. package/client/dist/assets/{useTvLibrary-UsQpgBTB.js → useTvLibrary-BnbHS-gg.js} +1 -1
  47. package/client/dist/index.html +1 -1
  48. package/package.json +4 -2
  49. package/server/dist/app-hono.js +2 -0
  50. package/server/dist/hono/asmr.js +10 -1
  51. package/server/dist/hono/music.js +122 -332
  52. package/server/dist/hono/proxy.js +3 -24
  53. package/server/dist/hono/tv.js +3 -56
  54. package/server/dist/lib/mal.js +4 -3
  55. package/server/dist/lib/potoken.js +135 -0
  56. package/server/dist/lib/tracker/manga-sync.service.js +3 -22
  57. package/server/dist/lib/tracker/sync-state.js +21 -0
  58. package/server/dist/lib/tracker/sync.service.js +3 -22
  59. package/server/dist/lib/ump.js +106 -0
  60. package/server/dist/providers/remote-loader.js +2 -1
  61. package/server/dist/repositories/asmr.repository.js +4 -53
  62. package/server/dist/repositories/library.repository.js +46 -0
  63. package/server/dist/repositories/manga.repository.js +3 -52
  64. package/server/dist/repositories/settings.repository.js +8 -0
  65. package/server/dist/repositories/tv.repository.js +3 -46
  66. package/server/dist/server.js +5 -1
  67. package/server/dist/sync.js +3 -5
  68. package/server/dist/trpc/routers/asmr-library.js +2 -12
  69. package/server/dist/trpc/routers/asmr-progress.js +10 -22
  70. package/server/dist/trpc/routers/data.js +17 -36
  71. package/server/dist/trpc/routers/discord.js +1 -8
  72. package/server/dist/trpc/routers/insights.js +15 -16
  73. package/server/dist/trpc/routers/manga-library.js +5 -22
  74. package/server/dist/trpc/routers/manga-progress.js +8 -20
  75. package/server/dist/trpc/routers/music.js +6 -11
  76. package/server/dist/trpc/routers/queue.js +1 -1
  77. package/server/dist/trpc/routers/tracker.js +1 -7
  78. package/server/dist/trpc/routers/tv-library.js +2 -12
  79. package/server/dist/trpc/routers/tv-progress.js +16 -28
  80. package/server/dist/trpc/routers/tv.js +5 -21
  81. package/server/dist/trpc/routers/watchlist.js +1 -8
  82. package/server/dist/trpc/validation.js +35 -0
  83. package/server/dist/utils/db-utils.js +8 -0
  84. package/server/dist/utils/http.utils.js +12 -0
  85. package/server/dist/utils/machine-id.js +1 -2
  86. package/server/package.json +4 -1
@@ -1 +1 @@
1
- import{a as ie,d as N,h as re,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as h}from"./vendor-icons-DrybRNxP.js";import{P as E,S as de}from"./SkeletonGrid-0dY_xMq3.js";import{E as oe}from"./ErrorMessage-DAxegITP.js";import{y as me,A as he,M as C,B as q}from"./index-CVB5dYhT.js";import{s as l}from"./Watchlist.module-XGtVQr1d.js";function fe({headerTitle:H,headerSubtitle:O,filters:U,filterBy:r,filterBasePath:V,continueFilter:W,statusOptions:$,entries:d,total:o,isLoading:S,error:A,page:M,pageSize:u,onPageChange:I,emptyTitle:Y,emptyFilteredText:j,emptyAllText:F,browseLabel:J,browseTarget:Q,removeListLabel:w,listNoun:f,skipConfirmKey:x,onBulkStatus:X,onBulkRemove:B,onStatusChange:Z,onRemoveItem:R,renderCard:_,modals:K}){const z=ie(),[g,P]=N(!1),[t,i]=N(new Set),[n,p]=N(null),[T,b]=N(!1),{data:y}=me(x),L=he();re(()=>{i(new Set),P(!1)},[r]);const m=r===W,G=String(y)==="true"||String(y)==="1",ee=()=>{P(a=>(a&&i(new Set),!a))},ae=a=>{i(s=>{const c=new Set(s);return c.has(a)?c.delete(a):c.add(a),c})},v=d.map(a=>a.libId),k=v.length>0&&v.every(a=>t.has(a)),le=()=>{i(a=>{const s=new Set(a);if(k)for(const c of v)s.delete(c);else for(const c of v)s.add(c);return s})},te=a=>{t.size!==0&&(X([...t],a),i(new Set))},se=()=>{t.size!==0&&(m||G?(B([...t]),i(new Set)):p({ids:[...t]}))},ne=a=>{m||G?R(a.libId):p({ids:[a.libId],title:a.title})},ce=()=>{n&&(T&&L.mutate({key:x,value:!0}),n.ids.length===1?R(n.ids[0]):B(n.ids),i(new Set),p(null),b(!1))},D=()=>{p(null),b(!1)};return e("div",{className:"page-container",children:[e("header",{className:l.header,children:[e("h2",{className:l.title,children:H}),e("p",{className:l.subtitle,children:O})]}),e("div",{className:l.controls,children:e("div",{className:l.filters,children:U.map(a=>e("button",{className:`${l.filterBtn} ${r===a?l.active:""}`,onClick:()=>z(`${V}/${a==="All"?"":a}`),children:a},a))})}),e("div",{className:l.resultsHeader,children:[e("h3",{className:l.resultsTitle,children:[r,e("span",{className:l.itemCount,children:["(",o," items)"]})]}),e("div",{className:l.headerActions,children:[e("button",{className:`${l.manageBtn} ${g?l.active:""}`,onClick:ee,children:[e(h,{name:"pencil-alt",size:13}),e("span",{children:"Bulk Manage"})]}),o>0&&e(E,{page:M,totalPages:Math.max(1,Math.ceil(o/u)),canGoNext:d.length>=u,onChange:I,isLoading:S})]})]}),g&&e("div",{className:l.manageBar,children:[e("button",{className:l.selectAllBtn,onClick:le,children:[e("span",{className:`${l.selectAllBox} ${k?l.selectAllBoxChecked:""}`,"aria-hidden":"true"}),e("span",{children:k?"Clear Page":"Select All"})]}),e("span",{className:l.manageCount,children:[t.size," selected"]}),e("div",{className:l.manageSpacer}),!m&&e("select",{className:l.manageStatusSelect,value:"",onChange:a=>{a.currentTarget.value&&te(a.currentTarget.value)},disabled:t.size===0,title:"Set status for selected items",children:[e("option",{value:"",children:"Set status…"}),$.map(a=>e("option",{value:a,children:a},a))]}),e("button",{className:l.manageRemoveBtn,onClick:se,disabled:t.size===0,children:[e(h,{name:"trash",size:13}),e("span",{children:m?"Reset Selected":"Remove Selected"})]})]}),S?e(de,{}):A?e(oe,{message:A.message}):d.length===0?e("div",{className:l.emptyState,children:[e("h3",{className:l.emptyTitle,children:Y}),e("p",{className:l.emptyText,children:r!=="All"?j:F}),e("button",{className:l.emptyBtn,onClick:()=>z(Q),children:[e(h,{name:"search",size:14}),e("span",{children:J})]})]}):e("div",{className:l.grid,children:d.map(a=>e("div",{className:`${l.itemWrapper} ${t.has(a.libId)?l.selected:""}`,children:[g&&e("div",{className:l.selectOverlay,onClick:()=>ae(a.libId),title:t.has(a.libId)?"Deselect":"Select",children:e("span",{className:l.selectBadge,children:t.has(a.libId)?e(h,{name:"check",size:12}):null})}),_(a),!m&&!g&&e("div",{className:l.cardActions,children:[e("select",{className:l.statusSelect,value:a.status,onChange:s=>Z(a.libId,s.currentTarget.value),children:$.map(s=>e("option",{value:s,children:s},s))}),e("button",{className:l.removeBtn,onClick:()=>ne(a),title:w,"aria-label":w,children:e(h,{name:"trash",size:12})})]})]},a.key))}),o>0&&e("div",{className:l.bottomPagination,children:e(E,{page:M,totalPages:Math.max(1,Math.ceil(o/u)),canGoNext:d.length>=u,onChange:I,isLoading:S,variant:"labeled"})}),K,e(C,{isOpen:!!n,onClose:D,title:`Remove from ${f}`,children:[e(C.Body,{children:[e("p",{children:n&&n.ids.length===1?`Are you sure you want to remove "${n.title}" from your ${f}?`:`Are you sure you want to remove ${n?.ids.length??0} selected items from your ${f}?`}),e("label",{children:[e("input",{type:"checkbox",checked:T,onChange:a=>b(a.target.checked)}),"Don't ask again"]})]}),e(C.Actions,{children:[e(q,{variant:"secondary",onClick:D,children:"No"}),e(q,{variant:"danger",onClick:ce,children:"Yes"})]})]})]})}export{fe as L};
1
+ import{a as ie,d as N,h as re,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as h}from"./vendor-icons-DrybRNxP.js";import{P as E,S as de}from"./SkeletonGrid-BtzUnQE0.js";import{E as oe}from"./ErrorMessage-DAxegITP.js";import{y as me,A as he,M as C,B as q}from"./index-BWIWE3Qy.js";import{s as l}from"./Watchlist.module-XGtVQr1d.js";function fe({headerTitle:H,headerSubtitle:O,filters:U,filterBy:r,filterBasePath:V,continueFilter:W,statusOptions:$,entries:d,total:o,isLoading:S,error:A,page:M,pageSize:u,onPageChange:I,emptyTitle:Y,emptyFilteredText:j,emptyAllText:F,browseLabel:J,browseTarget:Q,removeListLabel:w,listNoun:f,skipConfirmKey:x,onBulkStatus:X,onBulkRemove:B,onStatusChange:Z,onRemoveItem:R,renderCard:_,modals:K}){const z=ie(),[g,P]=N(!1),[t,i]=N(new Set),[n,p]=N(null),[T,b]=N(!1),{data:y}=me(x),L=he();re(()=>{i(new Set),P(!1)},[r]);const m=r===W,G=String(y)==="true"||String(y)==="1",ee=()=>{P(a=>(a&&i(new Set),!a))},ae=a=>{i(s=>{const c=new Set(s);return c.has(a)?c.delete(a):c.add(a),c})},v=d.map(a=>a.libId),k=v.length>0&&v.every(a=>t.has(a)),le=()=>{i(a=>{const s=new Set(a);if(k)for(const c of v)s.delete(c);else for(const c of v)s.add(c);return s})},te=a=>{t.size!==0&&(X([...t],a),i(new Set))},se=()=>{t.size!==0&&(m||G?(B([...t]),i(new Set)):p({ids:[...t]}))},ne=a=>{m||G?R(a.libId):p({ids:[a.libId],title:a.title})},ce=()=>{n&&(T&&L.mutate({key:x,value:!0}),n.ids.length===1?R(n.ids[0]):B(n.ids),i(new Set),p(null),b(!1))},D=()=>{p(null),b(!1)};return e("div",{className:"page-container",children:[e("header",{className:l.header,children:[e("h2",{className:l.title,children:H}),e("p",{className:l.subtitle,children:O})]}),e("div",{className:l.controls,children:e("div",{className:l.filters,children:U.map(a=>e("button",{className:`${l.filterBtn} ${r===a?l.active:""}`,onClick:()=>z(`${V}/${a==="All"?"":a}`),children:a},a))})}),e("div",{className:l.resultsHeader,children:[e("h3",{className:l.resultsTitle,children:[r,e("span",{className:l.itemCount,children:["(",o," items)"]})]}),e("div",{className:l.headerActions,children:[e("button",{className:`${l.manageBtn} ${g?l.active:""}`,onClick:ee,children:[e(h,{name:"pencil-alt",size:13}),e("span",{children:"Bulk Manage"})]}),o>0&&e(E,{page:M,totalPages:Math.max(1,Math.ceil(o/u)),canGoNext:d.length>=u,onChange:I,isLoading:S})]})]}),g&&e("div",{className:l.manageBar,children:[e("button",{className:l.selectAllBtn,onClick:le,children:[e("span",{className:`${l.selectAllBox} ${k?l.selectAllBoxChecked:""}`,"aria-hidden":"true"}),e("span",{children:k?"Clear Page":"Select All"})]}),e("span",{className:l.manageCount,children:[t.size," selected"]}),e("div",{className:l.manageSpacer}),!m&&e("select",{className:l.manageStatusSelect,value:"",onChange:a=>{a.currentTarget.value&&te(a.currentTarget.value)},disabled:t.size===0,title:"Set status for selected items",children:[e("option",{value:"",children:"Set status…"}),$.map(a=>e("option",{value:a,children:a},a))]}),e("button",{className:l.manageRemoveBtn,onClick:se,disabled:t.size===0,children:[e(h,{name:"trash",size:13}),e("span",{children:m?"Reset Selected":"Remove Selected"})]})]}),S?e(de,{}):A?e(oe,{message:A.message}):d.length===0?e("div",{className:l.emptyState,children:[e("h3",{className:l.emptyTitle,children:Y}),e("p",{className:l.emptyText,children:r!=="All"?j:F}),e("button",{className:l.emptyBtn,onClick:()=>z(Q),children:[e(h,{name:"search",size:14}),e("span",{children:J})]})]}):e("div",{className:l.grid,children:d.map(a=>e("div",{className:`${l.itemWrapper} ${t.has(a.libId)?l.selected:""}`,children:[g&&e("div",{className:l.selectOverlay,onClick:()=>ae(a.libId),title:t.has(a.libId)?"Deselect":"Select",children:e("span",{className:l.selectBadge,children:t.has(a.libId)?e(h,{name:"check",size:12}):null})}),_(a),!m&&!g&&e("div",{className:l.cardActions,children:[e("select",{className:l.statusSelect,value:a.status,onChange:s=>Z(a.libId,s.currentTarget.value),children:$.map(s=>e("option",{value:s,children:s},s))}),e("button",{className:l.removeBtn,onClick:()=>ne(a),title:w,"aria-label":w,children:e(h,{name:"trash",size:12})})]})]},a.key))}),o>0&&e("div",{className:l.bottomPagination,children:e(E,{page:M,totalPages:Math.max(1,Math.ceil(o/u)),canGoNext:d.length>=u,onChange:I,isLoading:S,variant:"labeled"})}),K,e(C,{isOpen:!!n,onClose:D,title:`Remove from ${f}`,children:[e(C.Body,{children:[e("p",{children:n&&n.ids.length===1?`Are you sure you want to remove "${n.title}" from your ${f}?`:`Are you sure you want to remove ${n?.ids.length??0} selected items from your ${f}?`}),e("label",{children:[e("input",{type:"checkbox",checked:T,onChange:a=>b(a.target.checked)}),"Don't ask again"]})]}),e(C.Actions,{children:[e(q,{variant:"secondary",onClick:D,children:"No"}),e(q,{variant:"danger",onClick:ce,children:"Yes"})]})]})]})}export{fe as L};
@@ -1 +1 @@
1
- import{o as U,d as k,h as L,T as E,u,S as y}from"./vendor-core-DfaOB3Rn.js";import{M as F}from"./MediaCard-BQZsutEo.js";import{L as N}from"./LibraryListPage-Bh2qCJPh.js";import{u as _,A as q}from"./useAsmrPopup-Bbgxefy_.js";import{A as z}from"./AsmrResetProgressModal-BpPlg_Vv.js";import{g as h}from"./index-CVB5dYhT.js";import{m as O,u as Q,n as Y,o as D,e as G,p as H,q as K,r as Z,A as T,k as J}from"./useAsmr-ClckxnPe.js";import"./vendor-ui-3qrARCPr.js";import"./vendor-icons-DrybRNxP.js";import"./useIsMobile-Dvx1uJ82.js";import"./SkeletonGrid-0dY_xMq3.js";import"./ErrorMessage-DAxegITP.js";import"./Watchlist.module-XGtVQr1d.js";import"./Asmr.module-ChUXDZKx.js";import"./ResetProgressModal-CeI4V3Y5.js";import"./vendor-query-BBT5_sHx.js";const V=["All","Continue Listening",...T],A=24;function W(a){const d=a.currentTime??0,i=a.duration??0,r=(a.trackIndex??0)+1;return i>0?`Track ${r} · ${h(d)} / ${h(i)}`:`Track ${r}`}function bt(){const{filter:a="All"}=U(),[d,i]=k(1),[r,m]=k(null);L(()=>{document.title="Listening List - dango"},[]),L(()=>{i(1)},[a]);const o=a==="Continue Listening",n=O(o?"All":a,d,A),l=Q(100),f=Y(),C=D(),{toggle:v,bookmarkedIds:R}=G(),{popup:s,openPopup:I,scheduleClose:c,cancelClose:p,closePopup:B}=_(),P=H(),S=K(),j=Z(),M=E(()=>o?(l.data?.data??[]).map(t=>{const e=t.currentTime??0,g=t.duration??0,b=t.rjCode||t.id;return{key:t.id,libId:t.id,rjCode:b,title:t.title,thumbnail:t.thumbnail||"",status:t.status,isAdult:!!t.isAdult,trackLabel:`Track ${(t.trackIndex??0)+1}`,progressPercent:g>0?Math.min(100,e/g*100):0,progressLabel:W(t),detailTarget:`/asmr/${encodeURIComponent(b)}`}}):(n.data?.data??[]).map(t=>{const e=t.rjCode||t.id;return{key:t.id,libId:t.id,rjCode:e,title:t.title,thumbnail:t.thumbnail||"",status:t.status,isAdult:!!t.isAdult,trackLabel:t.lastTrackIndex!==null&&t.lastTrackIndex!==void 0?`Track ${t.lastTrackIndex+1}`:void 0,progressPercent:void 0,progressLabel:void 0,detailTarget:`/asmr/${encodeURIComponent(e)}`}}),[o,l.data,n.data]),w=o?l.data?.total??0:n.data?.total??0,x=o?l.isLoading:n.isLoading,$=o?l.error:n.error;return u(N,{headerTitle:"My Listening List",headerSubtitle:"Track and manage your ASMR collection",filters:V,filterBy:a,filterBasePath:"/listening-list",continueFilter:"Continue Listening",statusOptions:[...T],entries:M,total:w,isLoading:x,error:$,page:d,pageSize:A,onPageChange:i,emptyTitle:"Your listening list is looking a bit lonely",emptyFilteredText:"No works match this filter.",emptyAllText:"Let's find something to listen to!",browseLabel:"Browse ASMR",browseTarget:"/asmr",removeListLabel:"Remove from Listening List",listNoun:"listening list",skipConfirmKey:"asmrSkipRemoveConfirmation",onBulkStatus:(t,e)=>P.mutate({ids:t,status:e}),onBulkRemove:t=>{o?j.mutate({ids:t}):S.mutate({ids:t})},onStatusChange:(t,e)=>C.mutate({id:t,status:e}),onRemoveItem:t=>f.mutate({id:t}),renderCard:t=>u(F,{item:{id:t.libId,title:t.title,thumbnail:t.thumbnail,typeBadge:t.rjCode||void 0,chapterBadge:t.trackLabel??null,isAdult:t.isAdult},linkTo:t.detailTarget,hoverIcon:"info",layout:"horizontal",showInfoButton:!o,progress:t.progressPercent!==void 0&&t.progressLabel?{percent:t.progressPercent,label:t.progressLabel}:void 0,showProgress:o,display:{elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:o?()=>m(t):void 0,onOpenDetails:o?void 0:e=>I(e,{rjCode:t.rjCode,title:t.title,thumbnail:t.thumbnail,isAdult:t.isAdult,listenTarget:t.detailTarget,progressLabel:t.progressLabel}),onPopupHoverIntent:e=>e?p():c(),rawThumbnail:!0}),modals:u(y,{children:[u(z,{workId:r?r.libId:null,title:r?.title,onClose:()=>m(null)}),s&&u(q,{data:s.data,anchorRect:s.rect,bookmarked:R.has(J(s.data.rjCode)),onToggleBookmark:()=>v({rjCode:s.data.rjCode,title:s.data.title,thumbnail:s.data.thumbnail||"",isAdult:s.data.isAdult}),onMouseEnter:p,onMouseLeave:c,onRequestClose:B})]})})}export{bt as default};
1
+ import{o as U,d as k,h as L,T as E,u,S as y}from"./vendor-core-DfaOB3Rn.js";import{M as F}from"./MediaCard-CKUEcFTd.js";import{L as N}from"./LibraryListPage-DE-ASOX2.js";import{u as _,A as q}from"./useAsmrPopup-CDoroMBD.js";import{A as z}from"./AsmrResetProgressModal-DyU1Z2Gw.js";import{g as h}from"./index-BWIWE3Qy.js";import{m as O,u as Q,n as Y,o as D,e as G,p as H,q as K,r as Z,A as T,k as J}from"./useAsmr-DQyobNQX.js";import"./vendor-ui-3qrARCPr.js";import"./vendor-icons-DrybRNxP.js";import"./useIsMobile-Dvx1uJ82.js";import"./SkeletonGrid-BtzUnQE0.js";import"./ErrorMessage-DAxegITP.js";import"./Watchlist.module-XGtVQr1d.js";import"./Asmr.module-ChUXDZKx.js";import"./ResetProgressModal-vFC6N-Qw.js";import"./vendor-query-BBT5_sHx.js";const V=["All","Continue Listening",...T],A=24;function W(a){const d=a.currentTime??0,i=a.duration??0,r=(a.trackIndex??0)+1;return i>0?`Track ${r} · ${h(d)} / ${h(i)}`:`Track ${r}`}function bt(){const{filter:a="All"}=U(),[d,i]=k(1),[r,m]=k(null);L(()=>{document.title="Listening List - dango"},[]),L(()=>{i(1)},[a]);const o=a==="Continue Listening",n=O(o?"All":a,d,A),l=Q(100),f=Y(),C=D(),{toggle:v,bookmarkedIds:R}=G(),{popup:s,openPopup:I,scheduleClose:c,cancelClose:p,closePopup:B}=_(),P=H(),S=K(),j=Z(),M=E(()=>o?(l.data?.data??[]).map(t=>{const e=t.currentTime??0,g=t.duration??0,b=t.rjCode||t.id;return{key:t.id,libId:t.id,rjCode:b,title:t.title,thumbnail:t.thumbnail||"",status:t.status,isAdult:!!t.isAdult,trackLabel:`Track ${(t.trackIndex??0)+1}`,progressPercent:g>0?Math.min(100,e/g*100):0,progressLabel:W(t),detailTarget:`/asmr/${encodeURIComponent(b)}`}}):(n.data?.data??[]).map(t=>{const e=t.rjCode||t.id;return{key:t.id,libId:t.id,rjCode:e,title:t.title,thumbnail:t.thumbnail||"",status:t.status,isAdult:!!t.isAdult,trackLabel:t.lastTrackIndex!==null&&t.lastTrackIndex!==void 0?`Track ${t.lastTrackIndex+1}`:void 0,progressPercent:void 0,progressLabel:void 0,detailTarget:`/asmr/${encodeURIComponent(e)}`}}),[o,l.data,n.data]),w=o?l.data?.total??0:n.data?.total??0,x=o?l.isLoading:n.isLoading,$=o?l.error:n.error;return u(N,{headerTitle:"My Listening List",headerSubtitle:"Track and manage your ASMR collection",filters:V,filterBy:a,filterBasePath:"/listening-list",continueFilter:"Continue Listening",statusOptions:[...T],entries:M,total:w,isLoading:x,error:$,page:d,pageSize:A,onPageChange:i,emptyTitle:"Your listening list is looking a bit lonely",emptyFilteredText:"No works match this filter.",emptyAllText:"Let's find something to listen to!",browseLabel:"Browse ASMR",browseTarget:"/asmr",removeListLabel:"Remove from Listening List",listNoun:"listening list",skipConfirmKey:"asmrSkipRemoveConfirmation",onBulkStatus:(t,e)=>P.mutate({ids:t,status:e}),onBulkRemove:t=>{o?j.mutate({ids:t}):S.mutate({ids:t})},onStatusChange:(t,e)=>C.mutate({id:t,status:e}),onRemoveItem:t=>f.mutate({id:t}),renderCard:t=>u(F,{item:{id:t.libId,title:t.title,thumbnail:t.thumbnail,typeBadge:t.rjCode||void 0,chapterBadge:t.trackLabel??null,isAdult:t.isAdult},linkTo:t.detailTarget,hoverIcon:"info",layout:"horizontal",showInfoButton:!o,progress:t.progressPercent!==void 0&&t.progressLabel?{percent:t.progressPercent,label:t.progressLabel}:void 0,showProgress:o,display:{elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:o?()=>m(t):void 0,onOpenDetails:o?void 0:e=>I(e,{rjCode:t.rjCode,title:t.title,thumbnail:t.thumbnail,isAdult:t.isAdult,listenTarget:t.detailTarget,progressLabel:t.progressLabel}),onPopupHoverIntent:e=>e?p():c(),rawThumbnail:!0}),modals:u(y,{children:[u(z,{workId:r?r.libId:null,title:r?.title,onClose:()=>m(null)}),s&&u(q,{data:s.data,anchorRect:s.rect,bookmarked:R.has(J(s.data.rjCode)),onToggleBookmark:()=>v({rjCode:s.data.rjCode,title:s.data.title,thumbnail:s.data.thumbnail||"",isAdult:s.data.isAdult}),onMouseEnter:p,onMouseLeave:c,onRequestClose:B})]})})}export{bt as default};
@@ -1 +1 @@
1
- import{p as te,d as N,T as le,h as C,u as a,m as ne,S as re}from"./vendor-core-DfaOB3Rn.js";import{I as T}from"./vendor-icons-DrybRNxP.js";import{T as se,M as oe,B as q,U as ie}from"./index-CVB5dYhT.js";import{E as ce}from"./ErrorMessage-DAxegITP.js";import{M as de}from"./MediaCard-BQZsutEo.js";import{u as ue,M as ge}from"./useMangaPopup-Celk4lzf.js";import{f as pe,u as he,m as D,i as ve,b as me,c as be}from"./useMangaLibrary-B3_BUKVk.js";import{u as fe}from"./useProviders-pwxPZPHh.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import"./vendor-query-BBT5_sHx.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";const Se=[{value:"popular",label:"Popular"},{value:"latest",label:"Latest"},{value:"rating",label:"Top Rated"},{value:"followed",label:"Most Followed"}],ye=[{value:"",label:"Any Status"},{value:"ongoing",label:"Ongoing"},{value:"completed",label:"Completed"},{value:"hiatus",label:"Hiatus"},{value:"cancelled",label:"Cancelled"}],Ne=[{value:"",label:"Any Status"},{value:"publishing",label:"Publishing"},{value:"finished",label:"Finished"},{value:"on hiatus",label:"On Hiatus"},{value:"discontinued",label:"Discontinued"}],Ce=[{value:"",label:"All Types"},{value:"manga",label:"Manga"},{value:"novel",label:"Novel"},{value:"one-shot",label:"One-Shot"},{value:"doujinshi",label:"Doujinshi"}],Te=[{value:"safe",label:"Safe"}],Me=[{value:"safe",label:"Safe"},{value:"suggestive",label:"Suggestive"},{value:"erotica",label:"Erotica"},{value:"pornographic",label:"Pornographic"}],M="agreedToViewMature";function Fe(){const[r,w]=te(),[v,I]=N(()=>localStorage.getItem(M)==="true"),[P,m]=N(!1),[k,L]=N(r.get("q")||""),{options:R,isLoading:$,refetch:z}=fe(),d=le(()=>R.filter(e=>e.kind==="manga").map(e=>({value:e.value,label:e.label})),[R]),b=r.get("provider")||"",i=d.some(e=>e.value===b)?b:d[0]?.value??b,f=r.get("q")||"",u=parseInt(r.get("page")||"1"),B=r.get("sort")||"popular",E=r.get("status")||"",x=r.get("type")||"",g=r.get("rating")||"safe",A=r.get("id")||"";C(()=>{document.title="Manga - dango"},[]),C(()=>{const e=()=>I(localStorage.getItem(M)==="true");return window.addEventListener("focus",e),window.addEventListener("storage",e),()=>{window.removeEventListener("focus",e),window.removeEventListener("storage",e)}},[]);const c=v,S=c?g:"safe",H=c?Me:Te,o=(e,l=!1)=>{const n=new URLSearchParams(r);for(const[h,j]of Object.entries(e))j?n.set(h,j):n.delete(h);l&&n.delete("page"),w(n)},p=pe({provider:i,query:f,page:u,sort:B,status:E,type:x,rating:S,mature:c}),y=p.data?.items??[],G=p.data?.hasNext??!1,{toggle:V,bookmarkedIds:Y}=he(),{popup:s,openPopup:K,scheduleClose:U,cancelClose:F,closePopup:W}=ue();if(C(()=>{L(f)},[f]),A){const e=new URLSearchParams;c&&g!=="safe"&&e.set("rating",g);const l=r.get("chapter")||"";l&&e.set("chapter",l);const n=e.toString()?`?${e.toString()}`:"",h=`/manga/${i}/${encodeURIComponent(A)}${l?`/read${n}`:n}`;return a(ne,{to:h,replace:!0})}const X=e=>{e.preventDefault(),ie(),o({q:k},!0)},Q=e=>{e.target.checked&&!v&&m(!0)},J=()=>{localStorage.setItem(M,"true"),I(!0),m(!1),o({},!0)},O=()=>{m(!1)},_=e=>{const l=new URLSearchParams;c&&g!=="safe"&&l.set("rating",g);const n=l.toString()?`?${l.toString()}`:"";return`/manga/${e.provider}/${encodeURIComponent(e.id)}${n}`},Z=i==="mangapill"?Ne:ye,ee=i==="mangapill",ae=i==="mangadex";return a("div",{className:t.page,children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:[a(T,{name:"book"})," Manga"]}),a("form",{className:t.searchForm,onSubmit:X,children:[a("input",{className:t.searchInput,value:k,onChange:e=>L(e.target.value),placeholder:"Search manga titles...","aria-label":"Search manga"}),a("button",{className:t.searchBtn,type:"submit","aria-label":"Search",children:a(T,{name:"search",size:14})})]}),a("select",{className:t.select,value:i,disabled:d.length===0,onChange:e=>{const l=new URLSearchParams(r);l.set("provider",e.target.value),l.delete("page"),l.delete("id"),l.delete("chapter"),l.delete("status"),l.delete("type"),w(l)},"aria-label":"Manga provider",children:d.length===0?a("option",{value:"",children:$?"Loading providers…":"No providers available"}):d.map(e=>a("option",{value:e.value,children:e.label},e.value))}),d.length===0&&!$&&a("button",{className:t.searchBtn,type:"button",onClick:()=>z(),"aria-label":"Retry loading providers",children:a(T,{name:"redo",size:14})})]}),a("div",{className:t.filterRow,children:[i==="mangadex"&&a("select",{className:t.select,value:B,onChange:e=>o({sort:e.target.value},!0),"aria-label":"Sort manga",children:Se.map(e=>a("option",{value:e.value,children:e.label},e.value))}),a("select",{className:t.select,value:E,onChange:e=>o({status:e.target.value},!0),"aria-label":"Filter by status",children:Z.map(e=>a("option",{value:e.value,children:e.label},e.label))}),ee&&a("select",{className:t.select,value:x,onChange:e=>o({type:e.target.value},!0),"aria-label":"Filter by type",children:Ce.filter(e=>e.value!=="doujinshi"||c).map(e=>a("option",{value:e.value,children:e.label},e.value))}),ae&&a("select",{className:t.select,value:S,onChange:e=>o({rating:e.target.value},!0),"aria-label":"Content rating",children:H.map(e=>a("option",{value:e.value,children:e.label},e.value))}),!v&&a("div",{className:t.matureToggleWrap,children:[a("label",{className:t.matureLabel,htmlFor:"manga-mature-toggle",children:"Mature"}),a(se,{id:"manga-mature-toggle",isChecked:!1,onChange:Q})]})]}),p.isError?a(ce,{message:"Failed to load manga. Please try again."}):p.isLoading&&y.length===0?a("div",{className:t.grid,"aria-hidden":!0,children:Array.from({length:12}).map((e,l)=>a("div",{className:t.skeletonCard,children:[a("div",{className:`${t.skeletonThumb} ${t.shimmer}`}),a("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"88%"}}),a("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"55%"}})]},l))}):y.length===0?a("p",{className:t.statusMsg,children:"No titles found. Try another search or provider."}):a(re,{children:[a("div",{className:`${t.grid} ${p.isFetching?t.fetching:""}`,children:y.map(e=>{const l=D(e.provider,e.id);return a(de,{item:{id:l,title:e.title,...be(e),thumbnail:me(e.provider,e.cover),typeBadge:e.type||void 0,chapterBadge:e.latestChapter?`Ch. ${e.latestChapter}`:null,isAdult:ve(e)},linkTo:_(e),hoverIcon:"info",display:{elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!1,meta:!1}}},onOpenDetails:n=>K(n,{provider:e.provider,mangaId:e.id,title:e.title,altTitle:e.altTitle,cover:e.cover,contentRating:e.contentRating,readTarget:_(e),rating:S,mature:c}),onPopupHoverIntent:n=>n?F():U(),rawThumbnail:!0},`${e.provider}-${e.id}`)})}),a("nav",{className:t.pagination,children:[a("button",{className:t.pageBtn,disabled:u<=1,onClick:()=>o({page:String(u-1)}),children:"Previous"}),a("span",{className:t.pageIndicator,children:["Page ",u]}),a("button",{className:t.pageBtn,disabled:!G,onClick:()=>o({page:String(u+1)}),children:"Next"})]})]}),s&&a(ge,{data:s.data,anchorRect:s.rect,bookmarked:Y.has(D(s.data.provider,s.data.mangaId)),onToggleBookmark:()=>V({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:F,onMouseLeave:U,onRequestClose:W}),P&&a(oe,{isOpen:P,title:"Content Warning",onClose:O,children:a("div",{style:{padding:"var(--space-4)",textAlign:"center"},children:[a("p",{children:"This section contains mature content intended for adult audiences."}),a("p",{children:["By proceeding, you confirm that you are ",a("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),a("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-secondary)",marginTop:"var(--space-4)"},children:["You can reset this preference at any time in the ",a("strong",{children:"Settings"})," page."]}),a("div",{style:{marginTop:"var(--space-4)",display:"flex",gap:"var(--space-2-5)",justifyContent:"center"},children:[a(q,{variant:"secondary",onClick:O,children:"Go Back"}),a(q,{onClick:J,children:"I'm 18+, Continue"})]})]})})]})}export{Fe as default};
1
+ import{p as te,d as N,T as le,h as C,u as a,m as ne,S as re}from"./vendor-core-DfaOB3Rn.js";import{I as T}from"./vendor-icons-DrybRNxP.js";import{T as se,M as oe,B as q,U as ie}from"./index-BWIWE3Qy.js";import{E as ce}from"./ErrorMessage-DAxegITP.js";import{M as de}from"./MediaCard-CKUEcFTd.js";import{u as ue,M as ge}from"./useMangaPopup-BSuMa_vA.js";import{f as pe,u as he,m as D,i as ve,b as me,c as be}from"./useMangaLibrary-C6L8mrnS.js";import{u as fe}from"./useProviders-XIdvDof6.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import"./vendor-query-BBT5_sHx.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";const Se=[{value:"popular",label:"Popular"},{value:"latest",label:"Latest"},{value:"rating",label:"Top Rated"},{value:"followed",label:"Most Followed"}],ye=[{value:"",label:"Any Status"},{value:"ongoing",label:"Ongoing"},{value:"completed",label:"Completed"},{value:"hiatus",label:"Hiatus"},{value:"cancelled",label:"Cancelled"}],Ne=[{value:"",label:"Any Status"},{value:"publishing",label:"Publishing"},{value:"finished",label:"Finished"},{value:"on hiatus",label:"On Hiatus"},{value:"discontinued",label:"Discontinued"}],Ce=[{value:"",label:"All Types"},{value:"manga",label:"Manga"},{value:"novel",label:"Novel"},{value:"one-shot",label:"One-Shot"},{value:"doujinshi",label:"Doujinshi"}],Te=[{value:"safe",label:"Safe"}],Me=[{value:"safe",label:"Safe"},{value:"suggestive",label:"Suggestive"},{value:"erotica",label:"Erotica"},{value:"pornographic",label:"Pornographic"}],M="agreedToViewMature";function Fe(){const[r,w]=te(),[v,I]=N(()=>localStorage.getItem(M)==="true"),[P,m]=N(!1),[k,L]=N(r.get("q")||""),{options:R,isLoading:$,refetch:z}=fe(),d=le(()=>R.filter(e=>e.kind==="manga").map(e=>({value:e.value,label:e.label})),[R]),b=r.get("provider")||"",i=d.some(e=>e.value===b)?b:d[0]?.value??b,f=r.get("q")||"",u=parseInt(r.get("page")||"1"),B=r.get("sort")||"popular",E=r.get("status")||"",x=r.get("type")||"",g=r.get("rating")||"safe",A=r.get("id")||"";C(()=>{document.title="Manga - dango"},[]),C(()=>{const e=()=>I(localStorage.getItem(M)==="true");return window.addEventListener("focus",e),window.addEventListener("storage",e),()=>{window.removeEventListener("focus",e),window.removeEventListener("storage",e)}},[]);const c=v,S=c?g:"safe",H=c?Me:Te,o=(e,l=!1)=>{const n=new URLSearchParams(r);for(const[h,j]of Object.entries(e))j?n.set(h,j):n.delete(h);l&&n.delete("page"),w(n)},p=pe({provider:i,query:f,page:u,sort:B,status:E,type:x,rating:S,mature:c}),y=p.data?.items??[],G=p.data?.hasNext??!1,{toggle:V,bookmarkedIds:Y}=he(),{popup:s,openPopup:K,scheduleClose:U,cancelClose:F,closePopup:W}=ue();if(C(()=>{L(f)},[f]),A){const e=new URLSearchParams;c&&g!=="safe"&&e.set("rating",g);const l=r.get("chapter")||"";l&&e.set("chapter",l);const n=e.toString()?`?${e.toString()}`:"",h=`/manga/${i}/${encodeURIComponent(A)}${l?`/read${n}`:n}`;return a(ne,{to:h,replace:!0})}const X=e=>{e.preventDefault(),ie(),o({q:k},!0)},Q=e=>{e.target.checked&&!v&&m(!0)},J=()=>{localStorage.setItem(M,"true"),I(!0),m(!1),o({},!0)},O=()=>{m(!1)},_=e=>{const l=new URLSearchParams;c&&g!=="safe"&&l.set("rating",g);const n=l.toString()?`?${l.toString()}`:"";return`/manga/${e.provider}/${encodeURIComponent(e.id)}${n}`},Z=i==="mangapill"?Ne:ye,ee=i==="mangapill",ae=i==="mangadex";return a("div",{className:t.page,children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:[a(T,{name:"book"})," Manga"]}),a("form",{className:t.searchForm,onSubmit:X,children:[a("input",{className:t.searchInput,value:k,onChange:e=>L(e.target.value),placeholder:"Search manga titles...","aria-label":"Search manga"}),a("button",{className:t.searchBtn,type:"submit","aria-label":"Search",children:a(T,{name:"search",size:14})})]}),a("select",{className:t.select,value:i,disabled:d.length===0,onChange:e=>{const l=new URLSearchParams(r);l.set("provider",e.target.value),l.delete("page"),l.delete("id"),l.delete("chapter"),l.delete("status"),l.delete("type"),w(l)},"aria-label":"Manga provider",children:d.length===0?a("option",{value:"",children:$?"Loading providers…":"No providers available"}):d.map(e=>a("option",{value:e.value,children:e.label},e.value))}),d.length===0&&!$&&a("button",{className:t.searchBtn,type:"button",onClick:()=>z(),"aria-label":"Retry loading providers",children:a(T,{name:"redo",size:14})})]}),a("div",{className:t.filterRow,children:[i==="mangadex"&&a("select",{className:t.select,value:B,onChange:e=>o({sort:e.target.value},!0),"aria-label":"Sort manga",children:Se.map(e=>a("option",{value:e.value,children:e.label},e.value))}),a("select",{className:t.select,value:E,onChange:e=>o({status:e.target.value},!0),"aria-label":"Filter by status",children:Z.map(e=>a("option",{value:e.value,children:e.label},e.label))}),ee&&a("select",{className:t.select,value:x,onChange:e=>o({type:e.target.value},!0),"aria-label":"Filter by type",children:Ce.filter(e=>e.value!=="doujinshi"||c).map(e=>a("option",{value:e.value,children:e.label},e.value))}),ae&&a("select",{className:t.select,value:S,onChange:e=>o({rating:e.target.value},!0),"aria-label":"Content rating",children:H.map(e=>a("option",{value:e.value,children:e.label},e.value))}),!v&&a("div",{className:t.matureToggleWrap,children:[a("label",{className:t.matureLabel,htmlFor:"manga-mature-toggle",children:"Mature"}),a(se,{id:"manga-mature-toggle",isChecked:!1,onChange:Q})]})]}),p.isError?a(ce,{message:"Failed to load manga. Please try again."}):p.isLoading&&y.length===0?a("div",{className:t.grid,"aria-hidden":!0,children:Array.from({length:12}).map((e,l)=>a("div",{className:t.skeletonCard,children:[a("div",{className:`${t.skeletonThumb} ${t.shimmer}`}),a("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"88%"}}),a("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"55%"}})]},l))}):y.length===0?a("p",{className:t.statusMsg,children:"No titles found. Try another search or provider."}):a(re,{children:[a("div",{className:`${t.grid} ${p.isFetching?t.fetching:""}`,children:y.map(e=>{const l=D(e.provider,e.id);return a(de,{item:{id:l,title:e.title,...be(e),thumbnail:me(e.provider,e.cover),typeBadge:e.type||void 0,chapterBadge:e.latestChapter?`Ch. ${e.latestChapter}`:null,isAdult:ve(e)},linkTo:_(e),hoverIcon:"info",display:{elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!1,meta:!1}}},onOpenDetails:n=>K(n,{provider:e.provider,mangaId:e.id,title:e.title,altTitle:e.altTitle,cover:e.cover,contentRating:e.contentRating,readTarget:_(e),rating:S,mature:c}),onPopupHoverIntent:n=>n?F():U(),rawThumbnail:!0},`${e.provider}-${e.id}`)})}),a("nav",{className:t.pagination,children:[a("button",{className:t.pageBtn,disabled:u<=1,onClick:()=>o({page:String(u-1)}),children:"Previous"}),a("span",{className:t.pageIndicator,children:["Page ",u]}),a("button",{className:t.pageBtn,disabled:!G,onClick:()=>o({page:String(u+1)}),children:"Next"})]})]}),s&&a(ge,{data:s.data,anchorRect:s.rect,bookmarked:Y.has(D(s.data.provider,s.data.mangaId)),onToggleBookmark:()=>V({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:F,onMouseLeave:U,onRequestClose:W}),P&&a(oe,{isOpen:P,title:"Content Warning",onClose:O,children:a("div",{style:{padding:"var(--space-4)",textAlign:"center"},children:[a("p",{children:"This section contains mature content intended for adult audiences."}),a("p",{children:["By proceeding, you confirm that you are ",a("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),a("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-secondary)",marginTop:"var(--space-4)"},children:["You can reset this preference at any time in the ",a("strong",{children:"Settings"})," page."]}),a("div",{style:{marginTop:"var(--space-4)",display:"flex",gap:"var(--space-2-5)",justifyContent:"center"},children:[a(q,{variant:"secondary",onClick:O,children:"Go Back"}),a(q,{onClick:J,children:"I'm 18+, Continue"})]})]})})]})}export{Fe as default};
@@ -1 +1 @@
1
- import{u as e,a as Q,d as z,S as E,o as O,p as G,T as $,h as Y}from"./vendor-core-DfaOB3Rn.js";import{I as x}from"./vendor-icons-DrybRNxP.js";import{B as M,e as H,d as J}from"./index-CVB5dYhT.js";import{E as K}from"./ErrorMessage-DAxegITP.js";import{b as D,g as V,f as U,h as j,j as X,m as A,k as Z,l as ee,n as te,r as ae,o as re,p as ne,q as se,s as ie,M as oe}from"./useMangaLibrary-B3_BUKVk.js";import{s as r}from"./Manga.module-BcfOdsNP.js";import"./vendor-query-BBT5_sHx.js";const le=({detail:a,altTitle:c,onBack:b,onOpenChapter:v,bookmarkButton:n,statusSelect:g,primaryAction:k,progressByChapter:d})=>{const h=[a.type,a.status,a.year?String(a.year):"",a.author?`by ${a.author}`:""].filter(Boolean);return e("div",{children:[e("button",{className:r.backBtn,onClick:b,children:[e(x,{name:"chevron-left",size:12})," Back to browse"]}),e("div",{className:r.detail,children:[a.cover&&e("img",{className:r.detailCover,src:D(a.provider,a.cover),alt:a.title,decoding:"async",draggable:!1}),e("div",{className:r.detailInfo,children:[e("h2",{className:r.detailTitle,children:a.title}),c&&e("p",{className:r.detailAltTitle,children:["Also known as: ",c]}),h.length>0&&e("div",{className:r.detailMeta,children:h.map(t=>e("span",{className:r.badge,children:t},t))}),a.genres&&a.genres.length>0&&e("div",{className:r.detailMeta,children:a.genres.map(t=>e("span",{className:r.badge,children:t},t))}),a.description&&e("p",{className:r.detailDesc,children:a.description}),(n||g||k)&&e("div",{className:r.detailActions,children:[k,n,g]})]})]}),e("h3",{className:r.detailTitle,style:{fontSize:"1rem"},children:["Chapters (",a.chapters.length,")"]}),a.chapters.length===0?e("p",{className:r.statusMsg,children:"No chapters found for this title on this provider."}):e("div",{className:r.chapterList,children:a.chapters.map(t=>{const o=d?.get(t.id),p=!!o&&o.pageCount>0&&o.page>=o.pageCount;return e("button",{className:`${r.chapterRow} ${p?r.chapterDone:""}`,onClick:()=>v(t),title:t.externalUrl?"External only — opens on source site":void 0,children:[e("span",{children:["Ch. ",t.number,t.title?` — ${t.title}`:""]}),e("span",{className:r.chapterMeta,children:[o&&o.pageCount>0?p?"read":`p. ${o.page}/${o.pageCount}`:"",t.group,t.externalUrl?"external":""].filter(Boolean).join(" · ")})]},t.id)})})]})},ce=({libId:a,anilistId:c})=>{const b=Q(),v=V(a),n=v.data?.item,[g,k]=z(null),[d,h]=z(null),t=g??n?.title??"",o=U({provider:"mangadex",query:t,page:1,sort:"",status:"",type:"",rating:"safe",mature:!1},!!t),p=U({provider:"mangapill",query:t,page:1,sort:"",status:"",type:"",rating:"safe",mature:!1},!!t),S=j(),y=X(),B=async s=>{const u=A(s.provider,s.id);h(u);try{await S.mutateAsync({provider:s.provider,mangaId:s.id,title:s.title,cover:s.cover,altTitle:s.altTitle,contentRating:s.contentRating,silent:!0}),await y.mutateAsync({id:u,anilistId:c}),b(`/manga/${s.provider}/${encodeURIComponent(s.id)}`)}catch{return}finally{h(null)}},C=(s,u,I)=>e("div",{style:{marginTop:"12px"},children:[e("div",{style:{fontWeight:600,textTransform:"capitalize",marginBottom:"6px"},children:s}),I?e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:"Searching…"}):!u||u.length===0?e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:"No matches."}):u.slice(0,6).map(l=>{const T=A(l.provider,l.id),N=d===T;return e("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"6px 0",borderTop:"1px solid var(--border, #223)"},children:[l.cover&&e("img",{src:D(l.provider,l.cover),alt:"",loading:"lazy",style:{width:"34px",height:"48px",objectFit:"cover",borderRadius:"4px"}}),e("div",{style:{flex:1,minWidth:0},children:[e("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.title}),l.latestChapter&&e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.75rem"},children:l.latestChapter})]}),e(M,{onClick:()=>B(l),disabled:N,children:[e(x,{name:"external-link-alt",size:12})," ",N?"Linking…":"Link"]})]},T)})]});return e("div",{children:[e("button",{onClick:()=>b("/manga"),style:{background:"none",border:"none",color:"var(--accent)",cursor:"pointer",marginBottom:"12px"},children:[e(x,{name:"chevron-left",size:12})," Back to browse"]}),v.isLoading?e("div",{style:{color:"var(--text-tertiary)"},children:"Loading library entry…"}):n?e(E,{children:[e("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[n.cover&&e("img",{src:n.cover,alt:"",style:{width:"64px",height:"90px",objectFit:"cover",borderRadius:"6px"}}),e("div",{children:[e("h2",{style:{margin:"0 0 4px"},children:n.title}),e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:["Tracked on AniList",n.lastChapterNumber?` · Ch. ${n.lastChapterNumber}`:"",n.status?` · ${n.status}`:""]})]})]}),e("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",marginTop:"12px"},children:"AniList doesn't host chapters. Search your providers below and link the matching manga — your AniList status and chapter progress will sync to it from now on."}),e("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:e("input",{type:"text",value:g??n.title,onChange:s=>k(s.target.value),placeholder:"Search providers…",style:{flex:1,padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border, #223)",background:"var(--bg-secondary, transparent)",color:"inherit"}})}),C("mangadex",o.data?.items,o.isLoading),C("mangapill",p.data?.items,p.isLoading)]}):e("div",{style:{color:"var(--text-tertiary)"},children:"This AniList entry is no longer in your library."})]})};function ye(){const{provider:a="",id:c=""}=O(),[b]=G(),v=Q(),{hasConsent:n}=H(),g=b.get("rating")||"safe",k=n?g:"safe",d=a&&c?A(a,c):void 0,h=Z(a||null,c||null,k,n),t=h.data,o=ee(d),p=te(d),{titlePreference:S}=J(),y=$(()=>t&&{...t,title:ae(t,S)},[t,S]),B=j(),C=re(),s=ne();Y(()=>{y&&(document.title=`${y.title} - dango`)},[y]);const u=$(()=>{const i=new Map;for(const m of p.data?.progress??[])i.set(m.chapterId,m);return i},[p.data]),I=a.toLowerCase()==="anilist"&&/^\d+$/.test(c)?parseInt(c,10):null,l=o.data?.inLibrary??!1,T=o.data?.status??"Reading",N=$(()=>(t?.chapters??[]).filter(i=>!i.externalUrl),[t]),f=$(()=>{if(!t)return null;const i=[...p.data?.progress??[]].sort((m,L)=>L.updatedAt-m.updatedAt);for(const m of i){const L=t.chapters.find(w=>w.id===m.chapterId);if(L&&!L.externalUrl)return L;const P=se(m.chapterId);if(P!=null){const w=ie(t.chapters,P);if(w&&!w.externalUrl)return w}}return N[0]??null},[t,p.data,N]),q=f?u.get(f.id):void 0,F=(p.data?.progress?.length??0)>0,W=f&&(q||F)?`Continue Ch. ${f?.number}`:"Start Reading",R=i=>{if(i.externalUrl){window.open(i.externalUrl,"_blank","noopener,noreferrer");return}const m=new URLSearchParams;m.set("chapter",i.id),n&&g!=="safe"&&m.set("rating",g),v(`/manga/${a}/${encodeURIComponent(c)}/read?${m.toString()}`)},_=()=>{!t||!d||(l?C.mutate(d):B.mutate({provider:a,mangaId:c,title:t.title,cover:t.cover,author:t.author,altTitle:t.altTitle,contentRating:t.contentRating}))};return e("div",{className:r.page,children:h.isLoading?e("div",{"aria-hidden":!0,children:[e("div",{className:`${r.skeletonThumb} ${r.shimmer}`,style:{maxWidth:"12rem"}}),e("div",{className:`${r.skeletonLine} ${r.shimmer}`,style:{width:"40%"}}),e("div",{className:`${r.skeletonLine} ${r.shimmer}`,style:{width:"70%"}})]}):h.isError||!t||!y?I!=null&&d?e(ce,{libId:d,anilistId:I}):e(E,{children:[e("button",{className:r.backBtn,onClick:()=>v("/manga"),children:[e(x,{name:"chevron-left",size:12})," Back to browse"]}),e(K,{message:"Failed to load this title. Please try again."})]}):e(le,{detail:y,altTitle:t.altTitle!==y.title?t.altTitle:void 0,onBack:()=>v("/manga"),onOpenChapter:R,progressByChapter:u,primaryAction:f?e(M,{onClick:()=>f&&R(f),children:[e(x,{name:"book",size:13})," ",W]}):void 0,bookmarkButton:e(M,{variant:l?"secondary":"primary",onClick:_,disabled:B.isPending||C.isPending,children:[e(x,{name:"bookmark",size:13})," ",l?"Bookmarked":"Bookmark"]}),statusSelect:l?e("select",{className:r.detailSelect,value:T,onChange:i=>d&&s.mutate({id:d,status:i.target.value}),"aria-label":"Reading status",children:oe.map(i=>e("option",{value:i,children:i},i))}):void 0})})}export{ye as default};
1
+ import{u as e,a as Q,d as z,S as E,o as O,p as G,T as $,h as Y}from"./vendor-core-DfaOB3Rn.js";import{I as x}from"./vendor-icons-DrybRNxP.js";import{B as M,e as H,d as J}from"./index-BWIWE3Qy.js";import{E as K}from"./ErrorMessage-DAxegITP.js";import{b as D,g as V,f as U,h as j,j as X,m as A,k as Z,l as ee,n as te,r as ae,o as re,p as ne,q as se,s as ie,M as oe}from"./useMangaLibrary-C6L8mrnS.js";import{s as r}from"./Manga.module-BcfOdsNP.js";import"./vendor-query-BBT5_sHx.js";const le=({detail:a,altTitle:c,onBack:b,onOpenChapter:v,bookmarkButton:n,statusSelect:g,primaryAction:k,progressByChapter:d})=>{const h=[a.type,a.status,a.year?String(a.year):"",a.author?`by ${a.author}`:""].filter(Boolean);return e("div",{children:[e("button",{className:r.backBtn,onClick:b,children:[e(x,{name:"chevron-left",size:12})," Back to browse"]}),e("div",{className:r.detail,children:[a.cover&&e("img",{className:r.detailCover,src:D(a.provider,a.cover),alt:a.title,decoding:"async",draggable:!1}),e("div",{className:r.detailInfo,children:[e("h2",{className:r.detailTitle,children:a.title}),c&&e("p",{className:r.detailAltTitle,children:["Also known as: ",c]}),h.length>0&&e("div",{className:r.detailMeta,children:h.map(t=>e("span",{className:r.badge,children:t},t))}),a.genres&&a.genres.length>0&&e("div",{className:r.detailMeta,children:a.genres.map(t=>e("span",{className:r.badge,children:t},t))}),a.description&&e("p",{className:r.detailDesc,children:a.description}),(n||g||k)&&e("div",{className:r.detailActions,children:[k,n,g]})]})]}),e("h3",{className:r.detailTitle,style:{fontSize:"1rem"},children:["Chapters (",a.chapters.length,")"]}),a.chapters.length===0?e("p",{className:r.statusMsg,children:"No chapters found for this title on this provider."}):e("div",{className:r.chapterList,children:a.chapters.map(t=>{const o=d?.get(t.id),p=!!o&&o.pageCount>0&&o.page>=o.pageCount;return e("button",{className:`${r.chapterRow} ${p?r.chapterDone:""}`,onClick:()=>v(t),title:t.externalUrl?"External only — opens on source site":void 0,children:[e("span",{children:["Ch. ",t.number,t.title?` — ${t.title}`:""]}),e("span",{className:r.chapterMeta,children:[o&&o.pageCount>0?p?"read":`p. ${o.page}/${o.pageCount}`:"",t.group,t.externalUrl?"external":""].filter(Boolean).join(" · ")})]},t.id)})})]})},ce=({libId:a,anilistId:c})=>{const b=Q(),v=V(a),n=v.data?.item,[g,k]=z(null),[d,h]=z(null),t=g??n?.title??"",o=U({provider:"mangadex",query:t,page:1,sort:"",status:"",type:"",rating:"safe",mature:!1},!!t),p=U({provider:"mangapill",query:t,page:1,sort:"",status:"",type:"",rating:"safe",mature:!1},!!t),S=j(),y=X(),B=async s=>{const u=A(s.provider,s.id);h(u);try{await S.mutateAsync({provider:s.provider,mangaId:s.id,title:s.title,cover:s.cover,altTitle:s.altTitle,contentRating:s.contentRating,silent:!0}),await y.mutateAsync({id:u,anilistId:c}),b(`/manga/${s.provider}/${encodeURIComponent(s.id)}`)}catch{return}finally{h(null)}},C=(s,u,I)=>e("div",{style:{marginTop:"12px"},children:[e("div",{style:{fontWeight:600,textTransform:"capitalize",marginBottom:"6px"},children:s}),I?e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:"Searching…"}):!u||u.length===0?e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:"No matches."}):u.slice(0,6).map(l=>{const T=A(l.provider,l.id),N=d===T;return e("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"6px 0",borderTop:"1px solid var(--border, #223)"},children:[l.cover&&e("img",{src:D(l.provider,l.cover),alt:"",loading:"lazy",style:{width:"34px",height:"48px",objectFit:"cover",borderRadius:"4px"}}),e("div",{style:{flex:1,minWidth:0},children:[e("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.title}),l.latestChapter&&e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.75rem"},children:l.latestChapter})]}),e(M,{onClick:()=>B(l),disabled:N,children:[e(x,{name:"external-link-alt",size:12})," ",N?"Linking…":"Link"]})]},T)})]});return e("div",{children:[e("button",{onClick:()=>b("/manga"),style:{background:"none",border:"none",color:"var(--accent)",cursor:"pointer",marginBottom:"12px"},children:[e(x,{name:"chevron-left",size:12})," Back to browse"]}),v.isLoading?e("div",{style:{color:"var(--text-tertiary)"},children:"Loading library entry…"}):n?e(E,{children:[e("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[n.cover&&e("img",{src:n.cover,alt:"",style:{width:"64px",height:"90px",objectFit:"cover",borderRadius:"6px"}}),e("div",{children:[e("h2",{style:{margin:"0 0 4px"},children:n.title}),e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:["Tracked on AniList",n.lastChapterNumber?` · Ch. ${n.lastChapterNumber}`:"",n.status?` · ${n.status}`:""]})]})]}),e("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",marginTop:"12px"},children:"AniList doesn't host chapters. Search your providers below and link the matching manga — your AniList status and chapter progress will sync to it from now on."}),e("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:e("input",{type:"text",value:g??n.title,onChange:s=>k(s.target.value),placeholder:"Search providers…",style:{flex:1,padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border, #223)",background:"var(--bg-secondary, transparent)",color:"inherit"}})}),C("mangadex",o.data?.items,o.isLoading),C("mangapill",p.data?.items,p.isLoading)]}):e("div",{style:{color:"var(--text-tertiary)"},children:"This AniList entry is no longer in your library."})]})};function ye(){const{provider:a="",id:c=""}=O(),[b]=G(),v=Q(),{hasConsent:n}=H(),g=b.get("rating")||"safe",k=n?g:"safe",d=a&&c?A(a,c):void 0,h=Z(a||null,c||null,k,n),t=h.data,o=ee(d),p=te(d),{titlePreference:S}=J(),y=$(()=>t&&{...t,title:ae(t,S)},[t,S]),B=j(),C=re(),s=ne();Y(()=>{y&&(document.title=`${y.title} - dango`)},[y]);const u=$(()=>{const i=new Map;for(const m of p.data?.progress??[])i.set(m.chapterId,m);return i},[p.data]),I=a.toLowerCase()==="anilist"&&/^\d+$/.test(c)?parseInt(c,10):null,l=o.data?.inLibrary??!1,T=o.data?.status??"Reading",N=$(()=>(t?.chapters??[]).filter(i=>!i.externalUrl),[t]),f=$(()=>{if(!t)return null;const i=[...p.data?.progress??[]].sort((m,L)=>L.updatedAt-m.updatedAt);for(const m of i){const L=t.chapters.find(w=>w.id===m.chapterId);if(L&&!L.externalUrl)return L;const P=se(m.chapterId);if(P!=null){const w=ie(t.chapters,P);if(w&&!w.externalUrl)return w}}return N[0]??null},[t,p.data,N]),q=f?u.get(f.id):void 0,F=(p.data?.progress?.length??0)>0,W=f&&(q||F)?`Continue Ch. ${f?.number}`:"Start Reading",R=i=>{if(i.externalUrl){window.open(i.externalUrl,"_blank","noopener,noreferrer");return}const m=new URLSearchParams;m.set("chapter",i.id),n&&g!=="safe"&&m.set("rating",g),v(`/manga/${a}/${encodeURIComponent(c)}/read?${m.toString()}`)},_=()=>{!t||!d||(l?C.mutate(d):B.mutate({provider:a,mangaId:c,title:t.title,cover:t.cover,author:t.author,altTitle:t.altTitle,contentRating:t.contentRating}))};return e("div",{className:r.page,children:h.isLoading?e("div",{"aria-hidden":!0,children:[e("div",{className:`${r.skeletonThumb} ${r.shimmer}`,style:{maxWidth:"12rem"}}),e("div",{className:`${r.skeletonLine} ${r.shimmer}`,style:{width:"40%"}}),e("div",{className:`${r.skeletonLine} ${r.shimmer}`,style:{width:"70%"}})]}):h.isError||!t||!y?I!=null&&d?e(ce,{libId:d,anilistId:I}):e(E,{children:[e("button",{className:r.backBtn,onClick:()=>v("/manga"),children:[e(x,{name:"chevron-left",size:12})," Back to browse"]}),e(K,{message:"Failed to load this title. Please try again."})]}):e(le,{detail:y,altTitle:t.altTitle!==y.title?t.altTitle:void 0,onBack:()=>v("/manga"),onOpenChapter:R,progressByChapter:u,primaryAction:f?e(M,{onClick:()=>f&&R(f),children:[e(x,{name:"book",size:13})," ",W]}):void 0,bookmarkButton:e(M,{variant:l?"secondary":"primary",onClick:_,disabled:B.isPending||C.isPending,children:[e(x,{name:"bookmark",size:13})," ",l?"Bookmarked":"Bookmark"]}),statusSelect:l?e("select",{className:r.detailSelect,value:T,onChange:i=>d&&s.mutate({id:d,status:i.target.value}),"aria-label":"Reading status",children:oe.map(i=>e("option",{value:i,children:i},i))}):void 0})})}export{ye as default};
@@ -1 +1 @@
1
- import{d as F,A as I,q as Z,h as u,u as e,S as J,o as ce,p as le,a as de,T as ue}from"./vendor-core-DfaOB3Rn.js";import{E as ge}from"./ErrorMessage-DAxegITP.js";import{I as x}from"./vendor-icons-DrybRNxP.js";import{u as he}from"./vendor-query-BBT5_sHx.js";import{t as me,v as pe,m as fe,k as ve,r as be,n as Ne,w as we,q as ye,s as Ce}from"./useMangaLibrary-B3_BUKVk.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import{e as Ie,d as Se,t as G}from"./index-CVB5dYhT.js";const ee="mangaReadMode",te="mangaFitMode";function $e(){try{return localStorage.getItem(ee)==="page"?"page":"strip"}catch{return"strip"}}function ke(){try{return localStorage.getItem(te)==="height"?"height":"width"}catch{return"width"}}const Pe=({provider:d,mangaTitle:h,chapter:p,chapters:b,onBack:N,onOpenChapter:v,initialPage:l=0,onProgress:D,savedPage:$=0})=>{const[c,U]=F($e),[i,_]=F(ke),[g,M]=F(0),[T,m]=F(new Set),[w,S]=F(0),E=I(null),B=I([]),z=he(),{data:V,isLoading:k,isError:L}=me(d,p.id),a=V?.pages??[],K=a.map(n=>pe(d,n)),y=I(0),Q=I(0),P=I(!1);Q.current=a.length;const s=b.findIndex(n=>n.id===p.id),o=s>0?[...b.slice(0,s)].reverse().find(n=>!n.externalUrl)??null:null,C=s>=0?b.slice(s+1).find(n=>!n.externalUrl)??null:null,R=Z(n=>{P.current=!0,M(r=>{const f=r+n;return f<0?(o&&v(o),0):f>=a.length?(C&&v(C),r):f})},[a.length,o,C,v]);u(()=>{P.current=!1,y.current=Math.max(0,l),M(Math.max(0,l)),m(new Set),B.current=[],l<=0&&window.scrollTo(0,0)},[p.id,l]);const H=I(D);H.current=D;const X=I("");u(()=>{y.current=g,a.length!==0&&H.current?.(Math.min(g+1,a.length),a.length)},[g,a.length]),u(()=>{l<=0||P.current||y.current===0&&(P.current=!1,y.current=l,M(l))},[l]),u(()=>{if(c!=="strip"||a.length===0||l<=0)return;const n=`${p.id}:${l}`;if(X.current===n)return;X.current=n;const r=window.setTimeout(()=>{B.current[Math.min(l,a.length-1)]?.scrollIntoView({block:"start"})},150);return()=>window.clearTimeout(r)},[c,a.length,l,p.id]),u(()=>{document.title=`${h} Ch. ${p.number} - dango`},[h,p.number]),u(()=>{try{localStorage.setItem(ee,c)}catch{}},[c]),u(()=>{try{localStorage.setItem(te,i)}catch{}},[i]),u(()=>{c==="page"&&window.scrollTo(0,0)},[c]),u(()=>{if(c!=="page"||a.length===0)return;const n=r=>{r.key==="ArrowRight"||r.key===" "?(r.preventDefault(),R(1)):r.key==="ArrowLeft"&&(r.preventDefault(),R(-1))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[c,a.length,R]),u(()=>{if(c!=="strip"||a.length===0)return;const n=new IntersectionObserver(r=>{for(const f of r)if(f.isIntersecting){const W=Number(f.target.dataset.pageIndex);Number.isNaN(W)||(W!==y.current&&(P.current=!0),M(W))}},{rootMargin:"-45% 0px -45% 0px",threshold:0});return B.current.forEach(r=>r&&n.observe(r)),()=>n.disconnect()},[c,a.length,V]);const ne=n=>{E.current=n.touches[0].clientX},ae=n=>{if(E.current===null)return;const r=n.changedTouches[0].clientX-E.current;E.current=null,!(Math.abs(r)<50)&&R(r<0?1:-1)},q=n=>{n&&v(n)},O=n=>m(r=>{if(r.has(n))return r;const f=new Set(r);return f.add(n),f}),re=n=>{m(r=>{const f=new Set(r);return f.delete(n),f}),S(r=>r+1)},se=()=>{m(new Set),S(n=>n+1),z.invalidateQueries({queryKey:["mangaPages",d,p.id]})},ie=a.length>0&&T.size>=a.length,Y=n=>w>0?`${n}&n=${w}`:n,j=n=>e("div",{className:t.deadPage,role:"alert",children:[e("span",{children:["Page ",n+1," failed to load"]}),e("button",{className:t.pageBtn,onClick:()=>re(n),children:[e(x,{name:"sync-alt",size:12})," Retry"]})]}),A=i==="height",oe=$>0?$-1:-1;return e("div",{className:t.readerShell,children:[e("div",{className:t.readerBar,children:[e("button",{className:t.readerIconBtn,onClick:N,"aria-label":"Back to chapters",children:e(x,{name:"chevron-left",size:14})}),e("span",{className:t.readerTitle,children:[h," — Ch. ",p.number,p.title?` ${p.title}`:""]}),a.length>0&&e("span",{className:t.readerCounter,children:[Math.min(g+1,a.length)," / ",a.length]}),e("div",{className:t.readerSegment,role:"group","aria-label":"Reading mode",children:[e("button",{type:"button","aria-pressed":c==="strip",className:c==="strip"?t.readerSegmentActive:"",onClick:()=>U("strip"),children:"Strip"}),e("button",{type:"button","aria-pressed":c==="page",className:c==="page"?t.readerSegmentActive:"",onClick:()=>U("page"),children:"Page"})]}),e("div",{className:t.readerSegment,role:"group","aria-label":"Fit mode",children:[e("button",{type:"button","aria-pressed":!A,className:A?"":t.readerSegmentActive,onClick:()=>_("width"),title:"Fit width — best for portrait / phones",children:"Wide"}),e("button",{type:"button","aria-pressed":A,className:A?t.readerSegmentActive:"",onClick:()=>_("height"),title:"Fit height — best for landscape / desktop",children:"Tall"})]}),e("button",{className:t.readerIconBtn,disabled:!o,onClick:()=>q(o),"aria-label":"Previous chapter",children:e(x,{name:"chevron-left",size:14})}),e("button",{className:t.readerIconBtn,disabled:!C,onClick:()=>q(C),"aria-label":"Next chapter",children:e(x,{name:"chevron-right",size:14})})]}),L?e("p",{className:t.statusMsg,children:"Failed to load pages. Please try again."}):k?e("div",{className:t.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((n,r)=>e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},r))}):a.length===0?e("p",{className:t.statusMsg,children:"No pages found for this chapter."}):ie?e("div",{className:t.failedBox,children:[e("p",{className:t.statusMsg,children:"Page images failed to load (expired or blocked links)."}),e("button",{className:t.pageBtn,onClick:se,children:[e(x,{name:"sync-alt",size:12})," Reload pages"]})]}):c==="strip"?e("div",{className:`${t.readerPages} ${A?t.readerPagesTall:""}`,children:K.map((n,r)=>e("div",{ref:f=>{B.current[r]=f},"data-page-index":r,className:t.readerPageWrap,children:[r===oe&&e("div",{className:t.saveMarker,role:"note","aria-label":"Saved reading position",children:[e(x,{name:"bookmark",size:12}),e("span",{children:["Saved · p. ",$]})]}),T.has(r)?j(r):e("img",{className:t.readerPage,src:Y(n),alt:`Page ${r+1}`,loading:r<3?"eager":"lazy",decoding:"async",draggable:!1,onError:()=>O(r)})]},`${r}-${a[r].slice(-32)}`))}):e(J,{children:[e("div",{className:`${t.pageView} ${A?t.pageViewTall:""}`,onTouchStart:ne,onTouchEnd:ae,children:[e("button",{className:`${t.tapZone} ${t.tapZoneLeft}`,onClick:()=>R(-1),"aria-label":"Previous page",children:e("span",{className:t.tapChevron,children:e(x,{name:"chevron-left",size:16})})}),T.has(g)?j(g):e("img",{className:t.pageImage,src:Y(K[g]),alt:`Page ${g+1} of ${a.length}`,decoding:"async",draggable:!1,onError:()=>O(g)},`${g}-${a[g].slice(-32)}`),e("button",{className:`${t.tapZone} ${t.tapZoneRight}`,onClick:()=>R(1),"aria-label":"Next page",children:e("span",{className:t.tapChevron,children:e(x,{name:"chevron-right",size:16})})})]}),e("nav",{className:t.pagination,"aria-label":"Page navigation",children:[e("button",{className:t.pageBtn,disabled:g<=0,onClick:()=>R(-1),children:"Previous page"}),e("span",{className:t.pageIndicator,children:[g+1," / ",a.length]}),e("button",{className:t.pageBtn,disabled:g>=a.length-1,onClick:()=>R(1),children:"Next page"})]})]}),(o||C)&&e("nav",{className:t.pagination,children:[e("button",{className:t.pageBtn,disabled:!o,onClick:()=>q(o),children:"Previous chapter"}),e("button",{className:t.pageBtn,disabled:!C,onClick:()=>q(C),children:"Next chapter"})]})]})},Re=800,xe=5e3;function ze(){const{provider:d="",id:h=""}=ce(),[p]=le(),b=de(),N=p.get("chapter")||"",v=p.get("rating")||"safe",{hasConsent:l}=Ie(),D=l?v:"safe",$=d&&h?fe(d,h):"",c=d.toLowerCase()==="anilist";u(()=>{c&&h&&b(`/manga/anilist/${encodeURIComponent(h)}`,{replace:!0})},[c,h,b]);const U=ve(!c&&d?d:null,!c&&h?h:null,D,l),i=U.data,{titlePreference:_}=Se(),g=i?be(i,_):"Manga",M=Ne($||void 0),T=we(),m=i&&N?i.chapters.find(s=>s.id===N)??null:null,w=ye(N),S=w!=null&&i?Ce(i.chapters,w):null;u(()=>{if(w!=null&&S&&S.id!==N){const s=new URLSearchParams;s.set("chapter",S.id),l&&v!=="safe"&&s.set("rating",v),b(`/manga/${d}/${encodeURIComponent(h)}/read?${s.toString()}`,{replace:!0})}},[w,S,N,l,v,d,h,b]);const E=w!=null&&!!i&&!!S,B=w!=null&&!!i&&!S,z=ue(()=>{const s=(M.data?.progress??[]).find(o=>o.chapterId===N);return s&&s.page>0?s.page:0},[M.data,N]),V=z>1?z-1:0,k=I(null),L=I(null),a=Z(()=>{k.current&&(clearTimeout(k.current),k.current=null);const s=L.current;L.current=null,s&&$&&T.mutate({mangaId:$,chapterId:s.chapterId,chapterNumber:s.chapterNumber,page:s.page,pageCount:s.pageCount,title:i?.title??null,cover:i?.cover??null,provider:d||null,altTitle:i?.altTitle??null,contentRating:i?.contentRating??null})},[$,T,i?.title,i?.cover,i?.altTitle,i?.contentRating,d]),K=Z((s,o)=>{m&&(L.current={chapterId:m.id,chapterNumber:m.number,page:s,pageCount:o},k.current&&clearTimeout(k.current),k.current=setTimeout(a,Re))},[m,a]);u(()=>{a()},[N,a]),u(()=>()=>a(),[a]),u(()=>{const s=window.setInterval(()=>{L.current&&a()},xe);return()=>window.clearInterval(s)},[a]),u(()=>{const s=()=>{document.visibilityState==="hidden"&&a()},o=()=>a();return document.addEventListener("visibilitychange",s),window.addEventListener("pagehide",o),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("pagehide",o)}},[a]);const y=I("");y.current||(y.current=`manga-${Date.now()}-${Math.random().toString(36).slice(2)}`),u(()=>{if(!i||!m)return;const s=i.contentRating==="erotica"||i.contentRating==="pornographic"||i.type==="doujinshi",o=()=>{G.discord.mangaPresence.mutate({title:i.title,chapterLabel:`Chapter ${m.number}`,isPlaying:!0,thumbnail:i.cover||"",thumbnails:[i.cover].filter(Boolean),isAdult:s,sessionId:y.current}).catch(()=>{}),G.discord.heartbeat.mutate({sessionId:y.current}).catch(()=>{})};o();const C=window.setInterval(o,6e4);return()=>window.clearInterval(C)},[i,m]);const Q=s=>{if(a(),s.externalUrl){window.open(s.externalUrl,"_blank","noopener,noreferrer");return}const o=new URLSearchParams;o.set("chapter",s.id),l&&v!=="safe"&&o.set("rating",v),b(`/manga/${d}/${encodeURIComponent(h)}/read?${o.toString()}`)},P=()=>{a();const s=new URLSearchParams;l&&v!=="safe"&&s.set("rating",v);const o=s.toString()?`?${s.toString()}`:"";b(`/manga/${d}/${encodeURIComponent(h)}${o}`)};return c?null:e("div",{className:t.page,children:U.isLoading||E?e("div",{className:t.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((s,o)=>e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},o))}):!i||!m?e(J,{children:[e("button",{className:t.backBtn,onClick:P,children:"Back to title"}),e(ge,{message:B?`Chapter ${w} isn't available from ${d} for this title.`:"Failed to load this chapter. Please try again."})]}):e(Pe,{provider:d,mangaTitle:g,chapter:m,chapters:i.chapters,onBack:P,onOpenChapter:Q,initialPage:V,onProgress:K,savedPage:z},m.id)})}export{ze as default};
1
+ import{d as F,A as I,q as Z,h as u,u as e,S as J,o as ce,p as le,a as de,T as ue}from"./vendor-core-DfaOB3Rn.js";import{E as ge}from"./ErrorMessage-DAxegITP.js";import{I as x}from"./vendor-icons-DrybRNxP.js";import{u as he}from"./vendor-query-BBT5_sHx.js";import{t as me,v as pe,m as fe,k as ve,r as be,n as Ne,w as we,q as ye,s as Ce}from"./useMangaLibrary-C6L8mrnS.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import{e as Ie,d as Se,t as G}from"./index-BWIWE3Qy.js";const ee="mangaReadMode",te="mangaFitMode";function $e(){try{return localStorage.getItem(ee)==="page"?"page":"strip"}catch{return"strip"}}function ke(){try{return localStorage.getItem(te)==="height"?"height":"width"}catch{return"width"}}const Pe=({provider:d,mangaTitle:h,chapter:p,chapters:b,onBack:N,onOpenChapter:v,initialPage:l=0,onProgress:D,savedPage:$=0})=>{const[c,U]=F($e),[i,_]=F(ke),[g,M]=F(0),[T,m]=F(new Set),[w,S]=F(0),E=I(null),B=I([]),z=he(),{data:V,isLoading:k,isError:L}=me(d,p.id),a=V?.pages??[],K=a.map(n=>pe(d,n)),y=I(0),Q=I(0),P=I(!1);Q.current=a.length;const s=b.findIndex(n=>n.id===p.id),o=s>0?[...b.slice(0,s)].reverse().find(n=>!n.externalUrl)??null:null,C=s>=0?b.slice(s+1).find(n=>!n.externalUrl)??null:null,R=Z(n=>{P.current=!0,M(r=>{const f=r+n;return f<0?(o&&v(o),0):f>=a.length?(C&&v(C),r):f})},[a.length,o,C,v]);u(()=>{P.current=!1,y.current=Math.max(0,l),M(Math.max(0,l)),m(new Set),B.current=[],l<=0&&window.scrollTo(0,0)},[p.id,l]);const H=I(D);H.current=D;const X=I("");u(()=>{y.current=g,a.length!==0&&H.current?.(Math.min(g+1,a.length),a.length)},[g,a.length]),u(()=>{l<=0||P.current||y.current===0&&(P.current=!1,y.current=l,M(l))},[l]),u(()=>{if(c!=="strip"||a.length===0||l<=0)return;const n=`${p.id}:${l}`;if(X.current===n)return;X.current=n;const r=window.setTimeout(()=>{B.current[Math.min(l,a.length-1)]?.scrollIntoView({block:"start"})},150);return()=>window.clearTimeout(r)},[c,a.length,l,p.id]),u(()=>{document.title=`${h} Ch. ${p.number} - dango`},[h,p.number]),u(()=>{try{localStorage.setItem(ee,c)}catch{}},[c]),u(()=>{try{localStorage.setItem(te,i)}catch{}},[i]),u(()=>{c==="page"&&window.scrollTo(0,0)},[c]),u(()=>{if(c!=="page"||a.length===0)return;const n=r=>{r.key==="ArrowRight"||r.key===" "?(r.preventDefault(),R(1)):r.key==="ArrowLeft"&&(r.preventDefault(),R(-1))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[c,a.length,R]),u(()=>{if(c!=="strip"||a.length===0)return;const n=new IntersectionObserver(r=>{for(const f of r)if(f.isIntersecting){const W=Number(f.target.dataset.pageIndex);Number.isNaN(W)||(W!==y.current&&(P.current=!0),M(W))}},{rootMargin:"-45% 0px -45% 0px",threshold:0});return B.current.forEach(r=>r&&n.observe(r)),()=>n.disconnect()},[c,a.length,V]);const ne=n=>{E.current=n.touches[0].clientX},ae=n=>{if(E.current===null)return;const r=n.changedTouches[0].clientX-E.current;E.current=null,!(Math.abs(r)<50)&&R(r<0?1:-1)},q=n=>{n&&v(n)},O=n=>m(r=>{if(r.has(n))return r;const f=new Set(r);return f.add(n),f}),re=n=>{m(r=>{const f=new Set(r);return f.delete(n),f}),S(r=>r+1)},se=()=>{m(new Set),S(n=>n+1),z.invalidateQueries({queryKey:["mangaPages",d,p.id]})},ie=a.length>0&&T.size>=a.length,Y=n=>w>0?`${n}&n=${w}`:n,j=n=>e("div",{className:t.deadPage,role:"alert",children:[e("span",{children:["Page ",n+1," failed to load"]}),e("button",{className:t.pageBtn,onClick:()=>re(n),children:[e(x,{name:"sync-alt",size:12})," Retry"]})]}),A=i==="height",oe=$>0?$-1:-1;return e("div",{className:t.readerShell,children:[e("div",{className:t.readerBar,children:[e("button",{className:t.readerIconBtn,onClick:N,"aria-label":"Back to chapters",children:e(x,{name:"chevron-left",size:14})}),e("span",{className:t.readerTitle,children:[h," — Ch. ",p.number,p.title?` ${p.title}`:""]}),a.length>0&&e("span",{className:t.readerCounter,children:[Math.min(g+1,a.length)," / ",a.length]}),e("div",{className:t.readerSegment,role:"group","aria-label":"Reading mode",children:[e("button",{type:"button","aria-pressed":c==="strip",className:c==="strip"?t.readerSegmentActive:"",onClick:()=>U("strip"),children:"Strip"}),e("button",{type:"button","aria-pressed":c==="page",className:c==="page"?t.readerSegmentActive:"",onClick:()=>U("page"),children:"Page"})]}),e("div",{className:t.readerSegment,role:"group","aria-label":"Fit mode",children:[e("button",{type:"button","aria-pressed":!A,className:A?"":t.readerSegmentActive,onClick:()=>_("width"),title:"Fit width — best for portrait / phones",children:"Wide"}),e("button",{type:"button","aria-pressed":A,className:A?t.readerSegmentActive:"",onClick:()=>_("height"),title:"Fit height — best for landscape / desktop",children:"Tall"})]}),e("button",{className:t.readerIconBtn,disabled:!o,onClick:()=>q(o),"aria-label":"Previous chapter",children:e(x,{name:"chevron-left",size:14})}),e("button",{className:t.readerIconBtn,disabled:!C,onClick:()=>q(C),"aria-label":"Next chapter",children:e(x,{name:"chevron-right",size:14})})]}),L?e("p",{className:t.statusMsg,children:"Failed to load pages. Please try again."}):k?e("div",{className:t.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((n,r)=>e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},r))}):a.length===0?e("p",{className:t.statusMsg,children:"No pages found for this chapter."}):ie?e("div",{className:t.failedBox,children:[e("p",{className:t.statusMsg,children:"Page images failed to load (expired or blocked links)."}),e("button",{className:t.pageBtn,onClick:se,children:[e(x,{name:"sync-alt",size:12})," Reload pages"]})]}):c==="strip"?e("div",{className:`${t.readerPages} ${A?t.readerPagesTall:""}`,children:K.map((n,r)=>e("div",{ref:f=>{B.current[r]=f},"data-page-index":r,className:t.readerPageWrap,children:[r===oe&&e("div",{className:t.saveMarker,role:"note","aria-label":"Saved reading position",children:[e(x,{name:"bookmark",size:12}),e("span",{children:["Saved · p. ",$]})]}),T.has(r)?j(r):e("img",{className:t.readerPage,src:Y(n),alt:`Page ${r+1}`,loading:r<3?"eager":"lazy",decoding:"async",draggable:!1,onError:()=>O(r)})]},`${r}-${a[r].slice(-32)}`))}):e(J,{children:[e("div",{className:`${t.pageView} ${A?t.pageViewTall:""}`,onTouchStart:ne,onTouchEnd:ae,children:[e("button",{className:`${t.tapZone} ${t.tapZoneLeft}`,onClick:()=>R(-1),"aria-label":"Previous page",children:e("span",{className:t.tapChevron,children:e(x,{name:"chevron-left",size:16})})}),T.has(g)?j(g):e("img",{className:t.pageImage,src:Y(K[g]),alt:`Page ${g+1} of ${a.length}`,decoding:"async",draggable:!1,onError:()=>O(g)},`${g}-${a[g].slice(-32)}`),e("button",{className:`${t.tapZone} ${t.tapZoneRight}`,onClick:()=>R(1),"aria-label":"Next page",children:e("span",{className:t.tapChevron,children:e(x,{name:"chevron-right",size:16})})})]}),e("nav",{className:t.pagination,"aria-label":"Page navigation",children:[e("button",{className:t.pageBtn,disabled:g<=0,onClick:()=>R(-1),children:"Previous page"}),e("span",{className:t.pageIndicator,children:[g+1," / ",a.length]}),e("button",{className:t.pageBtn,disabled:g>=a.length-1,onClick:()=>R(1),children:"Next page"})]})]}),(o||C)&&e("nav",{className:t.pagination,children:[e("button",{className:t.pageBtn,disabled:!o,onClick:()=>q(o),children:"Previous chapter"}),e("button",{className:t.pageBtn,disabled:!C,onClick:()=>q(C),children:"Next chapter"})]})]})},Re=800,xe=5e3;function ze(){const{provider:d="",id:h=""}=ce(),[p]=le(),b=de(),N=p.get("chapter")||"",v=p.get("rating")||"safe",{hasConsent:l}=Ie(),D=l?v:"safe",$=d&&h?fe(d,h):"",c=d.toLowerCase()==="anilist";u(()=>{c&&h&&b(`/manga/anilist/${encodeURIComponent(h)}`,{replace:!0})},[c,h,b]);const U=ve(!c&&d?d:null,!c&&h?h:null,D,l),i=U.data,{titlePreference:_}=Se(),g=i?be(i,_):"Manga",M=Ne($||void 0),T=we(),m=i&&N?i.chapters.find(s=>s.id===N)??null:null,w=ye(N),S=w!=null&&i?Ce(i.chapters,w):null;u(()=>{if(w!=null&&S&&S.id!==N){const s=new URLSearchParams;s.set("chapter",S.id),l&&v!=="safe"&&s.set("rating",v),b(`/manga/${d}/${encodeURIComponent(h)}/read?${s.toString()}`,{replace:!0})}},[w,S,N,l,v,d,h,b]);const E=w!=null&&!!i&&!!S,B=w!=null&&!!i&&!S,z=ue(()=>{const s=(M.data?.progress??[]).find(o=>o.chapterId===N);return s&&s.page>0?s.page:0},[M.data,N]),V=z>1?z-1:0,k=I(null),L=I(null),a=Z(()=>{k.current&&(clearTimeout(k.current),k.current=null);const s=L.current;L.current=null,s&&$&&T.mutate({mangaId:$,chapterId:s.chapterId,chapterNumber:s.chapterNumber,page:s.page,pageCount:s.pageCount,title:i?.title??null,cover:i?.cover??null,provider:d||null,altTitle:i?.altTitle??null,contentRating:i?.contentRating??null})},[$,T,i?.title,i?.cover,i?.altTitle,i?.contentRating,d]),K=Z((s,o)=>{m&&(L.current={chapterId:m.id,chapterNumber:m.number,page:s,pageCount:o},k.current&&clearTimeout(k.current),k.current=setTimeout(a,Re))},[m,a]);u(()=>{a()},[N,a]),u(()=>()=>a(),[a]),u(()=>{const s=window.setInterval(()=>{L.current&&a()},xe);return()=>window.clearInterval(s)},[a]),u(()=>{const s=()=>{document.visibilityState==="hidden"&&a()},o=()=>a();return document.addEventListener("visibilitychange",s),window.addEventListener("pagehide",o),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("pagehide",o)}},[a]);const y=I("");y.current||(y.current=`manga-${Date.now()}-${Math.random().toString(36).slice(2)}`),u(()=>{if(!i||!m)return;const s=i.contentRating==="erotica"||i.contentRating==="pornographic"||i.type==="doujinshi",o=()=>{G.discord.mangaPresence.mutate({title:i.title,chapterLabel:`Chapter ${m.number}`,isPlaying:!0,thumbnail:i.cover||"",thumbnails:[i.cover].filter(Boolean),isAdult:s,sessionId:y.current}).catch(()=>{}),G.discord.heartbeat.mutate({sessionId:y.current}).catch(()=>{})};o();const C=window.setInterval(o,6e4);return()=>window.clearInterval(C)},[i,m]);const Q=s=>{if(a(),s.externalUrl){window.open(s.externalUrl,"_blank","noopener,noreferrer");return}const o=new URLSearchParams;o.set("chapter",s.id),l&&v!=="safe"&&o.set("rating",v),b(`/manga/${d}/${encodeURIComponent(h)}/read?${o.toString()}`)},P=()=>{a();const s=new URLSearchParams;l&&v!=="safe"&&s.set("rating",v);const o=s.toString()?`?${s.toString()}`:"";b(`/manga/${d}/${encodeURIComponent(h)}${o}`)};return c?null:e("div",{className:t.page,children:U.isLoading||E?e("div",{className:t.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((s,o)=>e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},o))}):!i||!m?e(J,{children:[e("button",{className:t.backBtn,onClick:P,children:"Back to title"}),e(ge,{message:B?`Chapter ${w} isn't available from ${d} for this title.`:"Failed to load this chapter. Please try again."})]}):e(Pe,{provider:d,mangaTitle:g,chapter:m,chapters:i.chapters,onBack:P,onOpenChapter:Q,initialPage:V,onProgress:K,savedPage:z},m.id)})}export{ze as default};
@@ -1 +1 @@
1
- import{d as n,u as l}from"./vendor-core-DfaOB3Rn.js";import{R as i}from"./ResetProgressModal-CeI4V3Y5.js";import{B as f,o as R}from"./useMangaLibrary-B3_BUKVk.js";const p=({mangaId:e,title:a,onClose:s})=>{const[r,o]=n(!1),t=f(),m=R();return l(i,{isOpen:!!e,itemName:a,progressKind:"reading",listLabel:"my reading list",alsoRemove:r,onAlsoRemoveChange:o,onClose:()=>{o(!1),s()},onConfirm:()=>{e&&(t.mutate({mangaId:e}),r&&m.mutate(e),o(!1),s())}})};export{p as M};
1
+ import{d as n,u as l}from"./vendor-core-DfaOB3Rn.js";import{R as i}from"./ResetProgressModal-vFC6N-Qw.js";import{B as f,o as R}from"./useMangaLibrary-C6L8mrnS.js";const p=({mangaId:e,title:a,onClose:s})=>{const[r,o]=n(!1),t=f(),m=R();return l(i,{isOpen:!!e,itemName:a,progressKind:"reading",listLabel:"my reading list",alsoRemove:r,onAlsoRemoveChange:o,onClose:()=>{o(!1),s()},onConfirm:()=>{e&&(t.mutate({mangaId:e}),r&&m.mutate(e),o(!1),s())}})};export{p as M};
@@ -1 +1 @@
1
- import{u as t,a as we,p as ke,h as de,d as l,T as ue,S as me}from"./vendor-core-DfaOB3Rn.js";import{b as he}from"./vendor-query-BBT5_sHx.js";import{B as O,M as $e,h as qe,e as Fe,U as xe,t as x,z as Ue}from"./index-CVB5dYhT.js";import{I as ge}from"./vendor-icons-DrybRNxP.js";import{S as Ye,P as pe}from"./SkeletonGrid-0dY_xMq3.js";import{A as Ve}from"./AnimeCard-4CEz8Buu.js";import{E as We}from"./ErrorMessage-DAxegITP.js";import{u as je}from"./useProviders-pwxPZPHh.js";import{s as a}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-DxdOg_B7.js";import"./QueueOptionsButton-5eloKF5J.js";import"./vendor-ui-3qrARCPr.js";import"./MediaCard-BQZsutEo.js";import"./useIsMobile-Dvx1uJ82.js";const He=({isOpen:u,onClose:c,onGrant:s})=>t($e,{isOpen:u,title:"Content Warning",onClose:c,children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:"This title contains mature content intended for adult audiences."}),t("p",{children:["By proceeding, you confirm that you are ",t("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(O,{variant:"secondary",onClick:c,children:"Go Back"}),t(O,{onClick:s,children:"I'm 18+, Continue"})]})]})}),Ke="_shrinkSelect_130sm_1",Qe="_tightGrid_130sm_7",Q={shrinkSelect:Ke,tightGrid:Qe},ze=[{value:"anilist",label:"AniList"},{value:"mal",label:"MAL"}],Ze=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"FAVOURITES_DESC",label:"Favourites"}],Je=[{value:"",label:"All Status"},{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"}],Xe=[{value:"",label:"Relevance"},{value:"visits:desc",label:"Most Visited"},{value:"title:asc",label:"Title A-Z"}],et={recent:"Latest",popular:"Popular",views:"Most Viewed",rating:"Top Rated",random:"Random"},tt=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],ve=u=>u.split("-").map(c=>c&&c[0].toUpperCase()+c.slice(1)).join(" "),at=new Set(["page","limit","year","minScore","minEpisodes"]),rt=new Set(["provider","query","page","limit","type","status","season","year","country","genres","genre","excludeGenres","sortBy","order","studio","blacklist","minScore","minEpisodes"]);function st(u){const c=new URLSearchParams(u),s={};for(const[y,b]of c.entries())rt.has(y)&&(at.has(y)?s[y]=Number(b)||0:s[y]=b);return s}function bt(){const u=we(),c=qe(),[s,y]=ke(),{hasConsent:b,grant:fe}=Fe();de(()=>{document.title="Mature - dango"},[]);const[i,Se]=l(s.get("provider")||"anilist"),[C,z]=l(s.get("query")||""),[T,U]=l(s.get("query")||""),[I,g]=l(parseInt(s.get("page")||"1",10)||1),[_,Y]=l(()=>{const e=s.get("sortBy");return e||(i==="mal"?"SCORE_DESC":"POPULARITY_DESC")}),[M,Z]=l(s.get("sortBy")||""),[N,ye]=l(s.get("status")||""),[D,be]=l(s.get("season")||"ALL"),[G,Ce]=l(s.get("year")||"ALL"),[p,B]=l(s.get("genre")||s.get("genres")||""),[V,Ne]=l(s.get("order")||"recent"),[W,Ae]=l(s.get("studio")||""),[w,Ee]=l(s.get("studio")||""),[J,X]=l([]),[j,Pe]=l(!1),[Re,ee]=l(null),{options:te}=je(),ae=ue(()=>te.filter(e=>e.mature&&(e.kind??"anime")==="anime"),[te]),re=ue(()=>[...ze,...ae.map(e=>({value:e.value,label:e.label}))],[ae]),{data:k}=he({...c.data.matureFilters.queryOptions(),enabled:b,staleTime:1/0}),d=i==="anilist"||i==="mal",H=d?void 0:k?.providers?.[i],P=H?.browse,R=H?.genres??[],A=H?.orders??[],se=A.length>0&&!A.includes(V)?A[0]:V,$=!d&&(P?.genre===!0||R.length>0||J.length>0),v=!d&&(P?.order===!0||A.length>0),E=!d&&P?.studio===!0,ie=!d&&P?.sort===!0,q=d?14:P?.pageSize??14,f=e=>{const r=new URLSearchParams;if(e.provider!=="anilist"&&r.set("provider",e.provider),e.query.trim()&&r.set("query",e.query.trim()),e.page>1&&r.set("page",String(e.page)),e.provider==="anilist")e.sort!=="POPULARITY_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status),e.season!=="ALL"&&r.set("season",e.season),e.year!=="ALL"&&r.set("year",e.year);else if(e.provider==="mal")e.sort!=="SCORE_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status);else{const n=k?.providers?.[e.provider]?.browse,m=k?.providers?.[e.provider]?.orders??[],o=m.length>0&&!m.includes(e.remoteOrder)?m[0]:e.remoteOrder;(!n||n.sort)&&e.remoteSort&&r.set("sortBy",e.remoteSort),(!n||n.genre)&&e.genre&&r.set("genre",e.genre),(!n||n.order)&&o!==(m[0]??"recent")&&r.set("order",o),(!n||n.studio)&&e.studio.trim()&&r.set("studio",e.studio.trim())}y(r,{replace:!0})},S=(e={})=>({provider:i,query:T,page:I,sort:_,remoteSort:M,status:N,season:D,year:G,genre:p,remoteOrder:V,studio:w,...e}),Le=(()=>{const e=new URLSearchParams;return e.set("provider",i),T.trim()&&e.set("query",T.trim()),e.set("page",String(I)),e.set("limit",String(q)),i==="anilist"&&(e.set("sortBy",_),N&&e.set("status",N),D!=="ALL"&&e.set("season",D),G!=="ALL"&&e.set("year",G)),i==="mal"?(e.set("sortBy",_),N&&e.set("status",N)):d||($&&p&&e.set("genre",p),v&&e.set("order",se),ie&&M&&e.set("sortBy",M),E&&w.trim()&&e.set("studio",w.trim())),e.toString()})(),{data:h,isLoading:Oe,isError:Te,error:Ie}=he({...c.data.matureSearch.queryOptions(st(Le)),enabled:b});de(()=>{const e=h?.genres;!d&&R.length===0&&e&&e.length>0&&X(r=>{const n=new Set(r.map(o=>o.slug)),m=[...r];for(const o of e)o.slug&&!n.has(o.slug)&&(n.add(o.slug),m.push(o));return m.length===r.length?r:m})},[h,i,d,R.length]);const F=(h?.data||[]).map(e=>({...e,isAdult:!0})),le=h?.hasMore??!1,L=()=>{xe(),g(1);let e=p;!d&&!v&&C.trim()&&(e=""),B(e),E&&Ee(W),U(C),f(S({query:C,page:1,genre:e,studio:E?W:w}))},_e=e=>{Se(e),g(1),Z(""),B(""),X([]),e==="mal"?Y("SCORE_DESC"):e==="anilist"&&Y("POPULARITY_DESC"),U(C),f(S({provider:e,page:1,remoteSort:"",genre:"",query:C}))},Me=e=>{B(e),g(1),e&&(z(""),U("")),f(S({genre:e,page:1,query:e?"":T}))},ne=e=>{g(e),f(S({page:e})),window.scrollTo({top:0,behavior:"smooth"})},De=async(e,r)=>{const n=r.id||r._id;if(i!=="mal"&&!/^\d+$/.test(n)&&(e.preventDefault(),e.stopPropagation(),!Re)){ee(n);try{if(i!=="anilist"){let o=!1;try{o=(await x.data.anilistStatus.query())?.available===!0}catch{o=!1}if(o){const ce=await x.data.matureResolve.query({title:r.name});u(`/anime/${ce.id}`);return}const oe=await x.data.matureAllocate.mutate({provider:i,nativeId:n,title:r.name,thumbnail:r.thumbnail});if(!oe?.id)throw new Error("Allocate failed");u(`/anime/${oe.id}`);return}const m=await x.data.matureResolve.query({title:r.name});u(`/anime/${m.id}`)}catch{Ue.error("Could not match this title on AniList")}finally{ee(null)}}},K=new Date().getFullYear(),Ge=[{value:"ALL",label:"All Years"},...Array.from({length:K-1980+1},(e,r)=>({value:String(K-r),label:String(K-r)}))],Be=R.length>0?R.map(e=>({value:e,label:ve(e)})):J.map(e=>({value:e.slug,label:e.name}));return b?t("div",{className:"page-container",children:[t("div",{className:a.header,children:[t("h1",{className:a.pageTitle,children:"Mature"}),t("p",{className:a.pageSubtitle,children:"Browse 18+ titles across AniList and streaming providers"})]}),t("div",{className:a.filterContainer,children:[t("div",{className:a.searchBarWrapper,children:[t("div",{className:a.inputIconWrapper,children:[t(ge,{name:"search",className:a.searchIcon}),t("input",{type:"text",placeholder:`Search ${re.find(e=>e.value===i)?.label}...`,value:C,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]}),t("div",{className:a.searchActions,children:[t("select",{value:i,onChange:e=>_e(e.target.value),className:a.providerSelect,"aria-label":"Provider",children:re.map(e=>t("option",{value:e.value,children:e.label},e.value))}),t(O,{onClick:L,className:a.searchBtn,children:"Search"}),d&&t("button",{onClick:()=>Pe(!j),className:`${a.filterToggleBtn} ${j?a.active:""}`,children:[t(ge,{name:"filter"})," Filters"]}),ie&&t("select",{value:M,onChange:e=>{Z(e.target.value),g(1),f(S({remoteSort:e.target.value,page:1}))},className:a.providerSelect,"aria-label":"Sort",children:Xe.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),(i==="anilist"||i==="mal")&&t("div",{className:`${a.advancedFilters} ${j?a.show:""}`,children:[t("div",{className:a.filterDivider}),t("div",{className:a.filterGrid,children:[t("div",{className:a.filterItem,children:[t("label",{children:"Sort By"}),t("select",{value:_,onChange:e=>Y(e.currentTarget.value),children:Ze.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Status"}),t("select",{value:N,onChange:e=>ye(e.currentTarget.value),children:Je.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),i==="anilist"&&t(me,{children:[t("div",{className:a.filterItem,children:[t("label",{children:"Season"}),t("select",{value:D,onChange:e=>be(e.currentTarget.value),children:tt.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Year"}),t("select",{value:G,onChange:e=>Ce(e.currentTarget.value),children:Ge.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]})]}),t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]}),!d&&!!k&&($||v||E)&&t("div",{className:`${a.advancedFilters} ${a.show}`,children:[t("div",{className:a.filterDivider}),t("div",{className:`${a.filterGrid} ${Q.tightGrid}`,children:[v&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Order"}),t("select",{value:se,onChange:e=>{Ne(e.target.value),g(1),f(S({remoteOrder:e.target.value,page:1}))},children:(A.length>0?A:["recent"]).map(e=>t("option",{value:e,children:et[e]||e},e))})]}),$&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Genre"}),t("select",{value:p,onChange:e=>{v?(B(e.target.value),g(1),f(S({genre:e.target.value,page:1}))):Me(e.target.value)},children:[t("option",{value:"",children:"All Genres"}),Be.map(e=>t("option",{value:e.value,children:e.label},e.value))]})]}),E&&t("div",{className:a.filterItem,children:[t("label",{children:"Studio"}),t("input",{type:"text",placeholder:"Studio name...",value:W,onChange:e=>Ae(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]})]}),p&&$&&!v&&t("p",{className:a.pageSubtitle,children:["Browsing the ",ve(p)," genre — search text is ignored while a genre is selected."]}),(v||E)&&t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]})]}),Te&&t(We,{message:Ie?.message||"Search failed"}),Oe?t(Ye,{count:q}):F.length===0?t("div",{className:a.noResults,children:[t("h3",{children:"No results found"}),t("p",{children:"Try a different query, genre or provider"})]}):t(me,{children:[t("div",{className:a.resultsHeader,children:[t("h2",{className:a.resultsTitle,children:[h?.total??F.length," result",(h?.total??F.length)===1?"":"s"]}),t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})]}),t("div",{className:a.resultsGrid,children:F.map(e=>t("div",{onClickCapture:r=>De(r,e),children:t(Ve,{anime:e})},`${i}-${e._id}`))}),t("div",{className:a.bottomPagination,children:t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})})]})]}):t(He,{isOpen:!0,onClose:()=>u("/"),onGrant:fe})}export{bt as default};
1
+ import{u as t,a as we,p as ke,h as de,d as l,T as ue,S as me}from"./vendor-core-DfaOB3Rn.js";import{b as he}from"./vendor-query-BBT5_sHx.js";import{B as O,M as $e,h as qe,e as Fe,U as xe,t as x,z as Ue}from"./index-BWIWE3Qy.js";import{I as ge}from"./vendor-icons-DrybRNxP.js";import{S as Ye,P as pe}from"./SkeletonGrid-BtzUnQE0.js";import{A as Ve}from"./AnimeCard-I3S6qw9d.js";import{E as We}from"./ErrorMessage-DAxegITP.js";import{u as je}from"./useProviders-XIdvDof6.js";import{s as a}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-DjPBg24u.js";import"./QueueOptionsButton-BMvAC6Ut.js";import"./vendor-ui-3qrARCPr.js";import"./MediaCard-CKUEcFTd.js";import"./useIsMobile-Dvx1uJ82.js";const He=({isOpen:u,onClose:c,onGrant:s})=>t($e,{isOpen:u,title:"Content Warning",onClose:c,children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:"This title contains mature content intended for adult audiences."}),t("p",{children:["By proceeding, you confirm that you are ",t("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(O,{variant:"secondary",onClick:c,children:"Go Back"}),t(O,{onClick:s,children:"I'm 18+, Continue"})]})]})}),Ke="_shrinkSelect_130sm_1",Qe="_tightGrid_130sm_7",Q={shrinkSelect:Ke,tightGrid:Qe},ze=[{value:"anilist",label:"AniList"},{value:"mal",label:"MAL"}],Ze=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"FAVOURITES_DESC",label:"Favourites"}],Je=[{value:"",label:"All Status"},{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"}],Xe=[{value:"",label:"Relevance"},{value:"visits:desc",label:"Most Visited"},{value:"title:asc",label:"Title A-Z"}],et={recent:"Latest",popular:"Popular",views:"Most Viewed",rating:"Top Rated",random:"Random"},tt=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],ve=u=>u.split("-").map(c=>c&&c[0].toUpperCase()+c.slice(1)).join(" "),at=new Set(["page","limit","year","minScore","minEpisodes"]),rt=new Set(["provider","query","page","limit","type","status","season","year","country","genres","genre","excludeGenres","sortBy","order","studio","blacklist","minScore","minEpisodes"]);function st(u){const c=new URLSearchParams(u),s={};for(const[y,b]of c.entries())rt.has(y)&&(at.has(y)?s[y]=Number(b)||0:s[y]=b);return s}function bt(){const u=we(),c=qe(),[s,y]=ke(),{hasConsent:b,grant:fe}=Fe();de(()=>{document.title="Mature - dango"},[]);const[i,Se]=l(s.get("provider")||"anilist"),[C,z]=l(s.get("query")||""),[T,U]=l(s.get("query")||""),[I,g]=l(parseInt(s.get("page")||"1",10)||1),[_,Y]=l(()=>{const e=s.get("sortBy");return e||(i==="mal"?"SCORE_DESC":"POPULARITY_DESC")}),[M,Z]=l(s.get("sortBy")||""),[N,ye]=l(s.get("status")||""),[D,be]=l(s.get("season")||"ALL"),[G,Ce]=l(s.get("year")||"ALL"),[p,B]=l(s.get("genre")||s.get("genres")||""),[V,Ne]=l(s.get("order")||"recent"),[W,Ae]=l(s.get("studio")||""),[w,Ee]=l(s.get("studio")||""),[J,X]=l([]),[j,Pe]=l(!1),[Re,ee]=l(null),{options:te}=je(),ae=ue(()=>te.filter(e=>e.mature&&(e.kind??"anime")==="anime"),[te]),re=ue(()=>[...ze,...ae.map(e=>({value:e.value,label:e.label}))],[ae]),{data:k}=he({...c.data.matureFilters.queryOptions(),enabled:b,staleTime:1/0}),d=i==="anilist"||i==="mal",H=d?void 0:k?.providers?.[i],P=H?.browse,R=H?.genres??[],A=H?.orders??[],se=A.length>0&&!A.includes(V)?A[0]:V,$=!d&&(P?.genre===!0||R.length>0||J.length>0),v=!d&&(P?.order===!0||A.length>0),E=!d&&P?.studio===!0,ie=!d&&P?.sort===!0,q=d?14:P?.pageSize??14,f=e=>{const r=new URLSearchParams;if(e.provider!=="anilist"&&r.set("provider",e.provider),e.query.trim()&&r.set("query",e.query.trim()),e.page>1&&r.set("page",String(e.page)),e.provider==="anilist")e.sort!=="POPULARITY_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status),e.season!=="ALL"&&r.set("season",e.season),e.year!=="ALL"&&r.set("year",e.year);else if(e.provider==="mal")e.sort!=="SCORE_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status);else{const n=k?.providers?.[e.provider]?.browse,m=k?.providers?.[e.provider]?.orders??[],o=m.length>0&&!m.includes(e.remoteOrder)?m[0]:e.remoteOrder;(!n||n.sort)&&e.remoteSort&&r.set("sortBy",e.remoteSort),(!n||n.genre)&&e.genre&&r.set("genre",e.genre),(!n||n.order)&&o!==(m[0]??"recent")&&r.set("order",o),(!n||n.studio)&&e.studio.trim()&&r.set("studio",e.studio.trim())}y(r,{replace:!0})},S=(e={})=>({provider:i,query:T,page:I,sort:_,remoteSort:M,status:N,season:D,year:G,genre:p,remoteOrder:V,studio:w,...e}),Le=(()=>{const e=new URLSearchParams;return e.set("provider",i),T.trim()&&e.set("query",T.trim()),e.set("page",String(I)),e.set("limit",String(q)),i==="anilist"&&(e.set("sortBy",_),N&&e.set("status",N),D!=="ALL"&&e.set("season",D),G!=="ALL"&&e.set("year",G)),i==="mal"?(e.set("sortBy",_),N&&e.set("status",N)):d||($&&p&&e.set("genre",p),v&&e.set("order",se),ie&&M&&e.set("sortBy",M),E&&w.trim()&&e.set("studio",w.trim())),e.toString()})(),{data:h,isLoading:Oe,isError:Te,error:Ie}=he({...c.data.matureSearch.queryOptions(st(Le)),enabled:b});de(()=>{const e=h?.genres;!d&&R.length===0&&e&&e.length>0&&X(r=>{const n=new Set(r.map(o=>o.slug)),m=[...r];for(const o of e)o.slug&&!n.has(o.slug)&&(n.add(o.slug),m.push(o));return m.length===r.length?r:m})},[h,i,d,R.length]);const F=(h?.data||[]).map(e=>({...e,isAdult:!0})),le=h?.hasMore??!1,L=()=>{xe(),g(1);let e=p;!d&&!v&&C.trim()&&(e=""),B(e),E&&Ee(W),U(C),f(S({query:C,page:1,genre:e,studio:E?W:w}))},_e=e=>{Se(e),g(1),Z(""),B(""),X([]),e==="mal"?Y("SCORE_DESC"):e==="anilist"&&Y("POPULARITY_DESC"),U(C),f(S({provider:e,page:1,remoteSort:"",genre:"",query:C}))},Me=e=>{B(e),g(1),e&&(z(""),U("")),f(S({genre:e,page:1,query:e?"":T}))},ne=e=>{g(e),f(S({page:e})),window.scrollTo({top:0,behavior:"smooth"})},De=async(e,r)=>{const n=r.id||r._id;if(i!=="mal"&&!/^\d+$/.test(n)&&(e.preventDefault(),e.stopPropagation(),!Re)){ee(n);try{if(i!=="anilist"){let o=!1;try{o=(await x.data.anilistStatus.query())?.available===!0}catch{o=!1}if(o){const ce=await x.data.matureResolve.query({title:r.name});u(`/anime/${ce.id}`);return}const oe=await x.data.matureAllocate.mutate({provider:i,nativeId:n,title:r.name,thumbnail:r.thumbnail});if(!oe?.id)throw new Error("Allocate failed");u(`/anime/${oe.id}`);return}const m=await x.data.matureResolve.query({title:r.name});u(`/anime/${m.id}`)}catch{Ue.error("Could not match this title on AniList")}finally{ee(null)}}},K=new Date().getFullYear(),Ge=[{value:"ALL",label:"All Years"},...Array.from({length:K-1980+1},(e,r)=>({value:String(K-r),label:String(K-r)}))],Be=R.length>0?R.map(e=>({value:e,label:ve(e)})):J.map(e=>({value:e.slug,label:e.name}));return b?t("div",{className:"page-container",children:[t("div",{className:a.header,children:[t("h1",{className:a.pageTitle,children:"Mature"}),t("p",{className:a.pageSubtitle,children:"Browse 18+ titles across AniList and streaming providers"})]}),t("div",{className:a.filterContainer,children:[t("div",{className:a.searchBarWrapper,children:[t("div",{className:a.inputIconWrapper,children:[t(ge,{name:"search",className:a.searchIcon}),t("input",{type:"text",placeholder:`Search ${re.find(e=>e.value===i)?.label}...`,value:C,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]}),t("div",{className:a.searchActions,children:[t("select",{value:i,onChange:e=>_e(e.target.value),className:a.providerSelect,"aria-label":"Provider",children:re.map(e=>t("option",{value:e.value,children:e.label},e.value))}),t(O,{onClick:L,className:a.searchBtn,children:"Search"}),d&&t("button",{onClick:()=>Pe(!j),className:`${a.filterToggleBtn} ${j?a.active:""}`,children:[t(ge,{name:"filter"})," Filters"]}),ie&&t("select",{value:M,onChange:e=>{Z(e.target.value),g(1),f(S({remoteSort:e.target.value,page:1}))},className:a.providerSelect,"aria-label":"Sort",children:Xe.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),(i==="anilist"||i==="mal")&&t("div",{className:`${a.advancedFilters} ${j?a.show:""}`,children:[t("div",{className:a.filterDivider}),t("div",{className:a.filterGrid,children:[t("div",{className:a.filterItem,children:[t("label",{children:"Sort By"}),t("select",{value:_,onChange:e=>Y(e.currentTarget.value),children:Ze.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Status"}),t("select",{value:N,onChange:e=>ye(e.currentTarget.value),children:Je.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),i==="anilist"&&t(me,{children:[t("div",{className:a.filterItem,children:[t("label",{children:"Season"}),t("select",{value:D,onChange:e=>be(e.currentTarget.value),children:tt.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Year"}),t("select",{value:G,onChange:e=>Ce(e.currentTarget.value),children:Ge.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]})]}),t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]}),!d&&!!k&&($||v||E)&&t("div",{className:`${a.advancedFilters} ${a.show}`,children:[t("div",{className:a.filterDivider}),t("div",{className:`${a.filterGrid} ${Q.tightGrid}`,children:[v&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Order"}),t("select",{value:se,onChange:e=>{Ne(e.target.value),g(1),f(S({remoteOrder:e.target.value,page:1}))},children:(A.length>0?A:["recent"]).map(e=>t("option",{value:e,children:et[e]||e},e))})]}),$&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Genre"}),t("select",{value:p,onChange:e=>{v?(B(e.target.value),g(1),f(S({genre:e.target.value,page:1}))):Me(e.target.value)},children:[t("option",{value:"",children:"All Genres"}),Be.map(e=>t("option",{value:e.value,children:e.label},e.value))]})]}),E&&t("div",{className:a.filterItem,children:[t("label",{children:"Studio"}),t("input",{type:"text",placeholder:"Studio name...",value:W,onChange:e=>Ae(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]})]}),p&&$&&!v&&t("p",{className:a.pageSubtitle,children:["Browsing the ",ve(p)," genre — search text is ignored while a genre is selected."]}),(v||E)&&t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]})]}),Te&&t(We,{message:Ie?.message||"Search failed"}),Oe?t(Ye,{count:q}):F.length===0?t("div",{className:a.noResults,children:[t("h3",{children:"No results found"}),t("p",{children:"Try a different query, genre or provider"})]}):t(me,{children:[t("div",{className:a.resultsHeader,children:[t("h2",{className:a.resultsTitle,children:[h?.total??F.length," result",(h?.total??F.length)===1?"":"s"]}),t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})]}),t("div",{className:a.resultsGrid,children:F.map(e=>t("div",{onClickCapture:r=>De(r,e),children:t(Ve,{anime:e})},`${i}-${e._id}`))}),t("div",{className:a.bottomPagination,children:t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})})]})]}):t(He,{isOpen:!0,onClose:()=>u("/"),onGrant:fe})}export{bt as default};
@@ -1 +1 @@
1
- import{d as y,g as T,u as e,S as ee,$ as Ne,h as K,A as x,q as d,N as Ee,a as Se,L as Ie}from"./vendor-core-DfaOB3Rn.js";import{a as Re,b as Ae,f as Le,s as $e}from"./vendor-ui-3qrARCPr.js";import{I as v}from"./vendor-icons-DrybRNxP.js";import{t as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-CVB5dYhT.js";import{u as Ge}from"./useIsMobile-Dvx1uJ82.js";const We="_popupPortal_7glox_1",Ye="_popupContent_7glox_6",je="_popupBackdrop_7glox_31",Fe="_mobile_7glox_38",Xe="_header_7glox_62",qe="_title_7glox_67",He="_body_7glox_87",Je="_metaRow_7glox_94",Ke="_metaItem_7glox_101",Qe="_scoreIcon_7glox_107",Ze="_synopsis_7glox_111",et="_details_7glox_121",tt="_detailItem_7glox_129",nt="_genres_7glox_133",ot="_genre_7glox_133",rt="_footer_7glox_148",st="_primaryAction_7glox_157",at="_watchBtn_7glox_161",lt="_secondaryActions_7glox_184",ct="_watchlistBtn_7glox_189",it="_detailsBtn_7glox_190",dt="_active_7glox_216",ut="_loading_7glox_227",_t="_spinner_7glox_237",R={popupPortal:We,popupContent:Ye,popupBackdrop:je,mobile:Fe,header:Xe,title:qe,body:He,metaRow:Je,metaItem:Ke,scoreIcon:Qe,synopsis:Ze,details:et,detailItem:tt,genres:nt,genre:ot,footer:rt,primaryAction:st,watchBtn:at,secondaryActions:lt,watchlistBtn:ct,detailsBtn:it,active:dt,loading:ut,spinner:_t},cn=({anchorRect:t,onMouseEnter:a,onMouseLeave:l,onRequestClose:c,children:u})=>{const[i]=y(()=>window.matchMedia("(pointer: coarse)").matches),r=T.useMemo(()=>({getBoundingClientRect:()=>t}),[t]),{refs:w,floatingStyles:b}=Re({placement:"right-start",middleware:[Le({fallbackAxisSideDirection:"start"}),$e({padding:20})],whileElementsMounted:Ae});T.useEffect(()=>{w.setPositionReference(r)},[w,r]),T.useEffect(()=>{if(!i)return;const C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C}},[i]);const _=e(ee,{children:[i&&e("div",{className:R.popupBackdrop,onClick:()=>c?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:l,children:e("div",{className:R.popupContent,children:u})})]});return Ne(_,document.body)},pt=t=>!t||t.trim()===""?!0:t.includes("placeholder");function gt(t,a){const[l,c]=y(a);return K(()=>{c(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke.data.showMeta.query({id:t}).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&c(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:l}}const mt="_cardWrapper_w7bu0_1",ft="_card_w7bu0_1",ht="_cardButton_w7bu0_35",bt="_hoverOverlay_w7bu0_60",Bt="_matureOverlay_w7bu0_81",wt="_posterContainer_w7bu0_91",vt="_horizontal_w7bu0_100",yt="_posterImg_w7bu0_104",Ct="_blurred_w7bu0_116",Mt="_flat_w7bu0_139",xt="_loaded_w7bu0_143",Tt="_posterGradient_w7bu0_147",Pt="_progressSection_w7bu0_167",Nt="_titleSection_w7bu0_174",Et="_title_w7bu0_174",St="_titleText_w7bu0_193",It="_badge_w7bu0_205",Rt="_typeBadge_w7bu0_216 _badge_w7bu0_205",At="_epBadge_w7bu0_225 _badge_w7bu0_205",Lt="_airTime_w7bu0_234",$t="_adultBadge_w7bu0_241 _badge_w7bu0_205",kt="_gated_w7bu0_254",Ot="_notAiredBadge_w7bu0_260 _badge_w7bu0_205",zt="_metaRow_w7bu0_275",Dt="_metaItem_w7bu0_286",Ut="_progressContainer_w7bu0_303",Vt="_progressBar_w7bu0_311",Gt="_timestamp_w7bu0_318",Wt="_removeBtn_w7bu0_323",Yt="_infoBtn_w7bu0_324",jt="_mobileBadges_w7bu0_375",Ft="_mobileBadgeBase_w7bu0_382",Xt="_mobileType_w7bu0_390 _mobileBadgeBase_w7bu0_382",qt="_mobileEp_w7bu0_397 _mobileBadgeBase_w7bu0_382",Ht="_vertical_w7bu0_489",Jt="_placeholder_w7bu0_504",Kt="_placeholderText_w7bu0_513",Qt="_lowEnd_w7bu0_520",n={cardWrapper:mt,card:ft,cardButton:ht,hoverOverlay:bt,matureOverlay:Bt,posterContainer:wt,horizontal:vt,posterImg:yt,blurred:Ct,flat:Mt,loaded:xt,posterGradient:Tt,progressSection:Pt,titleSection:Nt,title:Et,titleText:St,badge:It,typeBadge:Rt,epBadge:At,airTime:Lt,adultBadge:$t,gated:kt,notAiredBadge:Ot,metaRow:zt,metaItem:Dt,progressContainer:Ut,progressBar:Vt,timestamp:Gt,removeBtn:Wt,infoBtn:Yt,mobileBadges:jt,mobileBadgeBase:Ft,mobileType:Xt,mobileEp:qt,vertical:Ht,placeholder:Jt,placeholderText:Kt,lowEnd:Qt},Zt=500,Z=20,en=300;function tn(t){const a=x(null),l=x(null),c=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),w=d(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),b=d(s=>{a.current&&clearTimeout(a.current),a.current=setTimeout(s,en)},[]),_=d((s,p=!1)=>{c.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,c.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),l.current=setTimeout(()=>{l.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!l.current)return;const p=Math.abs(s.clientX-u.current.x),m=Math.abs(s.clientY-u.current.y);(p>Z||m>Z)&&r()},[r]),g=d(()=>{r(),i.current=null},[r]),P=d((s,p)=>{s.preventDefault(),s.stopPropagation(),i.current==="touch"?l.current&&(clearTimeout(l.current),l.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!c.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>c.current?(c.current=!1,!0):!1,[]);return{longPressFiredRef:c,cancelLongPress:r,clearPopupTimeout:w,schedulePopupClose:b,openViaHold:_,handlePointerDown:C,handlePointerMove:B,handlePointerUpOrCancel:g,handleContextMenu:P,consumeLongPressClick:A}}const z={elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!0}}},dn=Ee(({item:t,linkTo:a,hoverIcon:l,progress:c,showProgress:u=!1,metaRow:i,display:r,layout:w="vertical",onRemove:b,showRemoveButton:_,showInfoButton:C=!1,onOpenDetails:B,renderPopup:g,onPopupHoverIntent:P,rawThumbnail:A,enrichedId:s})=>{const p=Se(),m=Ge(),{titlePreference:te}=Oe(),{lowEndMode:M}=ze(),[ne,oe]=y(!1),[re,D]=y(!1),{thumbnail:U}=gt(s,t.thumbnail),[L,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},$=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose($)},[f,$]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},le=()=>{j()},ce=()=>{g&&k()},ie=o=>{f.handlePointerDown(o,h)},de=o=>{f.handlePointerMove(o)},F=()=>{f.handlePointerUpOrCancel()},ue=o=>{if(B){o.preventDefault(),o.stopPropagation(),B(o.currentTarget.getBoundingClientRect());return}if(g){f.handleContextMenu(o,h);return}f.handleContextMenu(o,h)},X={...r,elements:{...z.elements,...r?.elements||{},poster:{...z.elements?.poster,...r?.elements?.poster||{}},info:{...z.elements?.info,...r?.elements?.info||{}}}},O=t[te]||t.title,N=X.elements?.poster,E=X.elements?.info,_e=(N?.typeBadge??!0)&&!!t.typeBadge,pe=(N?.chapterBadge??!0)&&!!t.chapterBadge,ge=_??N?.removeButton??!!b,me=N?.adultBadge??!0,fe=E?.mobileBadges??!0,he=E?.progress??!0,be=E?.meta??!0,Be=u&&!!c&&c.percent>0,q=!!t.isAdult,[we,ve]=De("agreedToViewMature","false"),ye=we==="true",[H,S]=T.useState(!1),I=T.useRef(null),Ce=()=>{ve("true"),S(!1),I.current&&(p(I.current),I.current=null)},h=q&&!ye,Me=o=>{if(f.consumeLongPressClick()){o.preventDefault(),o.stopPropagation();return}h&&(o.preventDefault(),o.stopPropagation(),I.current=a,S(!0))},xe=l==="book"?e(v,{name:"book",size:28}):l==="play"?e(v,{name:"play",size:28}):l==="info"?e(v,{name:"info-circle",size:28}):e(v,{name:"info-circle",size:28}),Te=d(o=>{o.preventDefault(),o.stopPropagation(),b&&b(t.id)},[b,t.id]),Pe=A?U??t.thumbnail:Ue(U,M?100:150,M?150:200);return e("div",{className:`${n.cardWrapper} ${M?n.lowEnd:""}`,onMouseEnter:()=>{D(!0),P?.(!0),L&&j()},onMouseLeave:()=>{D(!1),P?.(!1),L&&k()},children:[e(Ie,{to:a,className:`${n.card} ${n[w]} ${h?n.cardButton:""}`,onClick:Me,onContextMenu:ue,onPointerDown:ie,onPointerMove:de,onPointerUp:F,onPointerCancel:F,children:[e("div",{className:n.posterContainer,children:[h&&e("div",{className:`${n.matureOverlay} ${M?n.flat:""}`}),e("img",{src:Pe,alt:O,className:`${n.posterImg} ${ne?n.loaded:""} ${h&&!M?n.blurred:""}`,loading:"lazy",decoding:"async",onLoad:()=>oe(!0)}),!m&&e(ee,{children:[_e&&e("div",{className:n.typeBadge,children:t.typeBadge}),pe&&e("div",{className:n.epBadge,children:[t.chapterBadge,t.airMeta&&e("span",{className:n.airTime,children:t.airMeta})]})]}),me&&q&&e("div",{className:`${n.adultBadge} ${h?n.gated:""}`,children:"18+"}),t.notAired&&e("div",{className:n.notAiredBadge,children:"NOT AIRED"}),!m&&re&&e("div",{className:n.hoverOverlay,children:xe})]}),he&&u&&Be&&c&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${c.percent}%`}})}),e("div",{className:n.timestamp,children:c.label})]}),e("div",{className:n.titleSection,children:[m&&fe&&e("div",{className:n.mobileBadges,children:[!!t.typeBadge&&e("span",{className:n.mobileType,children:t.typeBadge}),t.chapterBadge&&e("span",{className:n.mobileEp,children:t.chapterBadge})]}),E?.title!==!1&&e("div",{className:n.title,title:O,children:e("span",{className:n.titleText,children:O})}),be&&i&&e("div",{className:n.metaRow,children:i})]})]}),H&&e(Ve,{isOpen:H,title:"Content Warning",onClose:()=>S(!1),children:e("div",{style:{padding:"1rem",textAlign:"center"},children:[e("p",{children:"This title contains mature content intended for adult audiences."}),e("p",{children:["By proceeding, you confirm that you are ",e("strong",{children:"18 years of age or older"})," ","(or the age of majority in your jurisdiction) and wish to view this content."]}),e("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"1rem"},children:["You can reset this preference at any time in the ",e("strong",{children:"Settings"})," page."]}),e("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[e(Q,{variant:"secondary",onClick:()=>S(!1),children:"Go Back"}),e(Q,{onClick:Ce,children:"I'm 18+, Continue"})]})]})}),ge&&e("button",{className:n.removeBtn,onClick:Te,"aria-label":"Remove",children:e(v,{name:"times",size:10})}),C&&!m&&!h&&e("button",{className:n.infoBtn,onMouseEnter:se,onMouseLeave:ae,"aria-label":"Info",children:e(v,{name:"info",size:11})}),g&&L&&G?g(G,{close:$,onMouseEnter:le,onMouseLeave:ce}):null]})});export{dn as M,cn as a,n as m,R as p};
1
+ import{d as y,g as T,u as e,S as ee,$ as Ne,h as K,A as x,q as d,N as Ee,a as Se,L as Ie}from"./vendor-core-DfaOB3Rn.js";import{a as Re,b as Ae,f as Le,s as $e}from"./vendor-ui-3qrARCPr.js";import{I as v}from"./vendor-icons-DrybRNxP.js";import{t as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-BWIWE3Qy.js";import{u as Ge}from"./useIsMobile-Dvx1uJ82.js";const We="_popupPortal_7glox_1",Ye="_popupContent_7glox_6",je="_popupBackdrop_7glox_31",Fe="_mobile_7glox_38",Xe="_header_7glox_62",qe="_title_7glox_67",He="_body_7glox_87",Je="_metaRow_7glox_94",Ke="_metaItem_7glox_101",Qe="_scoreIcon_7glox_107",Ze="_synopsis_7glox_111",et="_details_7glox_121",tt="_detailItem_7glox_129",nt="_genres_7glox_133",ot="_genre_7glox_133",rt="_footer_7glox_148",st="_primaryAction_7glox_157",at="_watchBtn_7glox_161",lt="_secondaryActions_7glox_184",ct="_watchlistBtn_7glox_189",it="_detailsBtn_7glox_190",dt="_active_7glox_216",ut="_loading_7glox_227",_t="_spinner_7glox_237",R={popupPortal:We,popupContent:Ye,popupBackdrop:je,mobile:Fe,header:Xe,title:qe,body:He,metaRow:Je,metaItem:Ke,scoreIcon:Qe,synopsis:Ze,details:et,detailItem:tt,genres:nt,genre:ot,footer:rt,primaryAction:st,watchBtn:at,secondaryActions:lt,watchlistBtn:ct,detailsBtn:it,active:dt,loading:ut,spinner:_t},cn=({anchorRect:t,onMouseEnter:a,onMouseLeave:l,onRequestClose:c,children:u})=>{const[i]=y(()=>window.matchMedia("(pointer: coarse)").matches),r=T.useMemo(()=>({getBoundingClientRect:()=>t}),[t]),{refs:w,floatingStyles:b}=Re({placement:"right-start",middleware:[Le({fallbackAxisSideDirection:"start"}),$e({padding:20})],whileElementsMounted:Ae});T.useEffect(()=>{w.setPositionReference(r)},[w,r]),T.useEffect(()=>{if(!i)return;const C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C}},[i]);const _=e(ee,{children:[i&&e("div",{className:R.popupBackdrop,onClick:()=>c?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:l,children:e("div",{className:R.popupContent,children:u})})]});return Ne(_,document.body)},pt=t=>!t||t.trim()===""?!0:t.includes("placeholder");function gt(t,a){const[l,c]=y(a);return K(()=>{c(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke.data.showMeta.query({id:t}).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&c(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:l}}const mt="_cardWrapper_w7bu0_1",ft="_card_w7bu0_1",ht="_cardButton_w7bu0_35",bt="_hoverOverlay_w7bu0_60",Bt="_matureOverlay_w7bu0_81",wt="_posterContainer_w7bu0_91",vt="_horizontal_w7bu0_100",yt="_posterImg_w7bu0_104",Ct="_blurred_w7bu0_116",Mt="_flat_w7bu0_139",xt="_loaded_w7bu0_143",Tt="_posterGradient_w7bu0_147",Pt="_progressSection_w7bu0_167",Nt="_titleSection_w7bu0_174",Et="_title_w7bu0_174",St="_titleText_w7bu0_193",It="_badge_w7bu0_205",Rt="_typeBadge_w7bu0_216 _badge_w7bu0_205",At="_epBadge_w7bu0_225 _badge_w7bu0_205",Lt="_airTime_w7bu0_234",$t="_adultBadge_w7bu0_241 _badge_w7bu0_205",kt="_gated_w7bu0_254",Ot="_notAiredBadge_w7bu0_260 _badge_w7bu0_205",zt="_metaRow_w7bu0_275",Dt="_metaItem_w7bu0_286",Ut="_progressContainer_w7bu0_303",Vt="_progressBar_w7bu0_311",Gt="_timestamp_w7bu0_318",Wt="_removeBtn_w7bu0_323",Yt="_infoBtn_w7bu0_324",jt="_mobileBadges_w7bu0_375",Ft="_mobileBadgeBase_w7bu0_382",Xt="_mobileType_w7bu0_390 _mobileBadgeBase_w7bu0_382",qt="_mobileEp_w7bu0_397 _mobileBadgeBase_w7bu0_382",Ht="_vertical_w7bu0_489",Jt="_placeholder_w7bu0_504",Kt="_placeholderText_w7bu0_513",Qt="_lowEnd_w7bu0_520",n={cardWrapper:mt,card:ft,cardButton:ht,hoverOverlay:bt,matureOverlay:Bt,posterContainer:wt,horizontal:vt,posterImg:yt,blurred:Ct,flat:Mt,loaded:xt,posterGradient:Tt,progressSection:Pt,titleSection:Nt,title:Et,titleText:St,badge:It,typeBadge:Rt,epBadge:At,airTime:Lt,adultBadge:$t,gated:kt,notAiredBadge:Ot,metaRow:zt,metaItem:Dt,progressContainer:Ut,progressBar:Vt,timestamp:Gt,removeBtn:Wt,infoBtn:Yt,mobileBadges:jt,mobileBadgeBase:Ft,mobileType:Xt,mobileEp:qt,vertical:Ht,placeholder:Jt,placeholderText:Kt,lowEnd:Qt},Zt=500,Z=20,en=300;function tn(t){const a=x(null),l=x(null),c=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),w=d(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),b=d(s=>{a.current&&clearTimeout(a.current),a.current=setTimeout(s,en)},[]),_=d((s,p=!1)=>{c.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,c.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),l.current=setTimeout(()=>{l.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!l.current)return;const p=Math.abs(s.clientX-u.current.x),m=Math.abs(s.clientY-u.current.y);(p>Z||m>Z)&&r()},[r]),g=d(()=>{r(),i.current=null},[r]),P=d((s,p)=>{s.preventDefault(),s.stopPropagation(),i.current==="touch"?l.current&&(clearTimeout(l.current),l.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!c.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>c.current?(c.current=!1,!0):!1,[]);return{longPressFiredRef:c,cancelLongPress:r,clearPopupTimeout:w,schedulePopupClose:b,openViaHold:_,handlePointerDown:C,handlePointerMove:B,handlePointerUpOrCancel:g,handleContextMenu:P,consumeLongPressClick:A}}const z={elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!0}}},dn=Ee(({item:t,linkTo:a,hoverIcon:l,progress:c,showProgress:u=!1,metaRow:i,display:r,layout:w="vertical",onRemove:b,showRemoveButton:_,showInfoButton:C=!1,onOpenDetails:B,renderPopup:g,onPopupHoverIntent:P,rawThumbnail:A,enrichedId:s})=>{const p=Se(),m=Ge(),{titlePreference:te}=Oe(),{lowEndMode:M}=ze(),[ne,oe]=y(!1),[re,D]=y(!1),{thumbnail:U}=gt(s,t.thumbnail),[L,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},$=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose($)},[f,$]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},le=()=>{j()},ce=()=>{g&&k()},ie=o=>{f.handlePointerDown(o,h)},de=o=>{f.handlePointerMove(o)},F=()=>{f.handlePointerUpOrCancel()},ue=o=>{if(B){o.preventDefault(),o.stopPropagation(),B(o.currentTarget.getBoundingClientRect());return}if(g){f.handleContextMenu(o,h);return}f.handleContextMenu(o,h)},X={...r,elements:{...z.elements,...r?.elements||{},poster:{...z.elements?.poster,...r?.elements?.poster||{}},info:{...z.elements?.info,...r?.elements?.info||{}}}},O=t[te]||t.title,N=X.elements?.poster,E=X.elements?.info,_e=(N?.typeBadge??!0)&&!!t.typeBadge,pe=(N?.chapterBadge??!0)&&!!t.chapterBadge,ge=_??N?.removeButton??!!b,me=N?.adultBadge??!0,fe=E?.mobileBadges??!0,he=E?.progress??!0,be=E?.meta??!0,Be=u&&!!c&&c.percent>0,q=!!t.isAdult,[we,ve]=De("agreedToViewMature","false"),ye=we==="true",[H,S]=T.useState(!1),I=T.useRef(null),Ce=()=>{ve("true"),S(!1),I.current&&(p(I.current),I.current=null)},h=q&&!ye,Me=o=>{if(f.consumeLongPressClick()){o.preventDefault(),o.stopPropagation();return}h&&(o.preventDefault(),o.stopPropagation(),I.current=a,S(!0))},xe=l==="book"?e(v,{name:"book",size:28}):l==="play"?e(v,{name:"play",size:28}):l==="info"?e(v,{name:"info-circle",size:28}):e(v,{name:"info-circle",size:28}),Te=d(o=>{o.preventDefault(),o.stopPropagation(),b&&b(t.id)},[b,t.id]),Pe=A?U??t.thumbnail:Ue(U,M?100:150,M?150:200);return e("div",{className:`${n.cardWrapper} ${M?n.lowEnd:""}`,onMouseEnter:()=>{D(!0),P?.(!0),L&&j()},onMouseLeave:()=>{D(!1),P?.(!1),L&&k()},children:[e(Ie,{to:a,className:`${n.card} ${n[w]} ${h?n.cardButton:""}`,onClick:Me,onContextMenu:ue,onPointerDown:ie,onPointerMove:de,onPointerUp:F,onPointerCancel:F,children:[e("div",{className:n.posterContainer,children:[h&&e("div",{className:`${n.matureOverlay} ${M?n.flat:""}`}),e("img",{src:Pe,alt:O,className:`${n.posterImg} ${ne?n.loaded:""} ${h&&!M?n.blurred:""}`,loading:"lazy",decoding:"async",onLoad:()=>oe(!0)}),!m&&e(ee,{children:[_e&&e("div",{className:n.typeBadge,children:t.typeBadge}),pe&&e("div",{className:n.epBadge,children:[t.chapterBadge,t.airMeta&&e("span",{className:n.airTime,children:t.airMeta})]})]}),me&&q&&e("div",{className:`${n.adultBadge} ${h?n.gated:""}`,children:"18+"}),t.notAired&&e("div",{className:n.notAiredBadge,children:"NOT AIRED"}),!m&&re&&e("div",{className:n.hoverOverlay,children:xe})]}),he&&u&&Be&&c&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${c.percent}%`}})}),e("div",{className:n.timestamp,children:c.label})]}),e("div",{className:n.titleSection,children:[m&&fe&&e("div",{className:n.mobileBadges,children:[!!t.typeBadge&&e("span",{className:n.mobileType,children:t.typeBadge}),t.chapterBadge&&e("span",{className:n.mobileEp,children:t.chapterBadge})]}),E?.title!==!1&&e("div",{className:n.title,title:O,children:e("span",{className:n.titleText,children:O})}),be&&i&&e("div",{className:n.metaRow,children:i})]})]}),H&&e(Ve,{isOpen:H,title:"Content Warning",onClose:()=>S(!1),children:e("div",{style:{padding:"1rem",textAlign:"center"},children:[e("p",{children:"This title contains mature content intended for adult audiences."}),e("p",{children:["By proceeding, you confirm that you are ",e("strong",{children:"18 years of age or older"})," ","(or the age of majority in your jurisdiction) and wish to view this content."]}),e("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"1rem"},children:["You can reset this preference at any time in the ",e("strong",{children:"Settings"})," page."]}),e("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[e(Q,{variant:"secondary",onClick:()=>S(!1),children:"Go Back"}),e(Q,{onClick:Ce,children:"I'm 18+, Continue"})]})]})}),ge&&e("button",{className:n.removeBtn,onClick:Te,"aria-label":"Remove",children:e(v,{name:"times",size:10})}),C&&!m&&!h&&e("button",{className:n.infoBtn,onMouseEnter:se,onMouseLeave:ae,"aria-label":"Info",children:e(v,{name:"info",size:11})}),g&&L&&G?g(G,{close:$,onMouseEnter:le,onMouseLeave:ce}):null]})});export{dn as M,cn as a,n as m,R as p};
@@ -1 +1 @@
1
- import{A as L,d as b,g as _e,h as F,u as e,S as w,$ as Ve,p as Ze,T as G}from"./vendor-core-DfaOB3Rn.js";import{t as Ce,W as je,h as O,z as P}from"./index-CVB5dYhT.js";import{I as g}from"./vendor-icons-DrybRNxP.js";import{a as n}from"./Asmr.module-ChUXDZKx.js";import{r as h}from"./Radio.module-DGSZLpKM.js";import{b as J,u as Pe,a as Re}from"./vendor-query-BBT5_sHx.js";function Be(a){if(!Number.isFinite(a)||a<0)return"0:00";const s=Math.floor(a/60),f=Math.floor(a%60);return`${s}:${String(f).padStart(2,"0")}`}const Je=({track:a,shuffle:s,onToggleShuffle:f,onTrackStep:R,onTrackFailed:be,onClose:se,liked:W,likeVisible:K,likePending:re,onToggleLike:X})=>{const M=L(null),ee=L(!1),[H,I]=b(!1),[he,u]=b(!0),[k,U]=b(!1),[$,A]=b(0),[z,oe]=b(0),[T,Y]=b(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[E,le]=b(()=>localStorage.getItem("musicAutoplay")!=="false"),V=L(T);V.current=T;const N=L(E);N.current=E;const y=L(0),D=L(0),B=L(null),Q=L("");Q.current||(Q.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const te=`/api/music/audio?videoId=${encodeURIComponent(a.id)}`,q=_e.useCallback(()=>{B.current&&(window.clearTimeout(B.current),B.current=null)},[]),Z=_e.useCallback(r=>{const o=M.current;if(!o)return;q(),u(!0),U(!1);const v=()=>{if(o.removeEventListener("loadedmetadata",v),r>5&&Number.isFinite(o.duration)&&r<o.duration-5)try{o.currentTime=r}catch{}};o.addEventListener("loadedmetadata",v),o.src=te,o.load(),o.volume=V.current,o.play().catch(()=>{})},[te,q]),ve=()=>{u(!1),U(!0),be?.(a),N.current&&R(1)},ce=()=>{if(!B.current){if(D.current>=3){ve();return}D.current+=1,B.current=window.setTimeout(()=>{B.current=null,Z(y.current)},5e3)}},ke=()=>{D.current=0,Z(y.current)};F(()=>{y.current=0,D.current=0,I(!1),A(0),oe(0);const r=M.current;return Z(y.current),()=>{q(),r&&r.removeAttribute("src")}},[Z,q]),F(()=>{const r=M.current;r&&(r.volume=T)},[T]),F(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const _=a.thumbnails?.[a.thumbnails.length-1]?.url??null,ne=_e.useCallback(r=>{const o=M.current;Ce.discord.musicPresence.mutate({title:a.title,artistLabel:a.artists,isPlaying:r,thumbnail:_||"",currentTime:o?.currentTime??0,duration:Number.isFinite(o?.duration??NaN)?o?.duration:0,sessionId:Q.current}).catch(()=>{}),Ce.discord.heartbeat.mutate({sessionId:Q.current}).catch(()=>{})},[a,_]);F(()=>{ne(H)},[ne,H,a.id]),F(()=>{if(!H)return;const r=window.setInterval(()=>ne(!0),15e3);return()=>window.clearInterval(r)},[H,ne]),F(()=>{const r=Q.current,o=()=>je(r),v=()=>o(),ae=()=>{document.visibilityState==="hidden"&&o()};return window.addEventListener("pagehide",v),window.addEventListener("beforeunload",v),document.addEventListener("visibilitychange",ae),()=>{window.removeEventListener("pagehide",v),window.removeEventListener("beforeunload",v),document.removeEventListener("visibilitychange",ae),o()}},[]);const pe=()=>{const r=M.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},[Ne,ge]=b(!1);F(()=>{ge(!1)},[_]);const ue=`${a.title} — ${a.artists}`,we=e(w,{children:[e("div",{className:n.playerButtons,children:[e("button",{className:n.playerBtn,onClick:()=>R(-1),"aria-label":"Previous track",children:e(g,{name:"step-backward"})}),e("button",{className:`${n.playerBtn} ${n.playBtn}`,onClick:pe,"aria-label":H?"Pause":"Play",children:H?e(g,{name:"pause"}):e(g,{name:"play"})}),e("button",{className:n.playerBtn,onClick:()=>R(1),"aria-label":"Next track",children:e(g,{name:"step-forward"})}),k&&e("button",{className:n.playerBtn,onClick:ke,title:"Retry playback","aria-label":"Retry playback",children:e(g,{name:"redo"})})]}),e("div",{className:n.seekRow,children:[e("span",{className:n.timeLabel,children:Be($)}),e("input",{className:n.seekBar,type:"range",min:0,max:z||0,step:.1,value:Math.min($,z||0),onChange:r=>{const o=M.current;!o||!Number.isFinite(o.duration)||(o.currentTime=parseFloat(r.target.value),A(o.currentTime))},onPointerDown:()=>{ee.current=!0},onPointerUp:()=>{ee.current=!1},style:{"--played-percent":`${z>0?$/z*100:0}%`},"aria-label":"Seek"}),e("span",{className:n.timeLabel,children:Be(z)}),he&&!k&&e("span",{className:n.timeLabel,children:"loading…"})]})]}),fe=e(w,{children:[a.thumbnails?.[0]?.url&&!Ne&&e("img",{src:a.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async",onError:()=>ge(!0)}),e("div",{className:n.playerInfo,children:[e("p",{className:n.playerTitle,title:ue,children:ue}),e("p",{className:n.playerTrack,children:a.artists})]}),e("div",{className:n.playerControls,children:we}),e("div",{className:n.playerRight,children:[T===0?e(g,{name:"volume-mute",className:n.volumeIcon}):T<.5?e(g,{name:"volume-down",className:n.volumeIcon}):e(g,{name:"volume-up",className:n.volumeIcon}),e("input",{className:n.volumeBar,type:"range",min:0,max:1,step:.01,value:T,onChange:r=>{const o=parseFloat(r.target.value);Y(o),localStorage.setItem("musicVolume",String(o))},style:{"--volume-percent":`${T*100}%`},"aria-label":"Volume"})]}),e("div",{className:n.playerActions,children:[K&&X&&e("button",{className:`${n.playerBtn} ${W?n.playerBtnActive:""}`,onClick:X,disabled:re,title:W?"Remove from Liked Music":"Add to Liked Music","aria-label":W?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!W,children:e(g,{name:"heart"})}),e("button",{className:`${n.playerBtn} ${s?n.playerBtnActive:""}`,onClick:f,title:s?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":s,children:e(g,{name:"shuffle"})}),e("button",{className:`${n.playerBtn} ${E?n.playerBtnActive:""}`,onClick:()=>{le(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:E?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":E,children:e(g,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(a.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:n.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(g,{name:"external-link-alt"})}),e("button",{className:n.playerBtn,onClick:se,"aria-label":"Close player",children:e(g,{name:"times"})})]})]});return Ve(e(w,{children:[e("audio",{ref:M,preload:"none",onPlay:()=>{I(!0),u(!1),U(!1),D.current=0,q()},onPause:()=>I(!1),onWaiting:()=>{k||u(!0)},onPlaying:()=>{u(!1),D.current=0,q()},onTimeUpdate:r=>{const o=r.target.currentTime;y.current=o,q(),ee.current||A(o)},onStalled:()=>{ce()},onLoadedMetadata:r=>{const o=r.target.duration;Number.isFinite(o)&&oe(o)},onDurationChange:r=>{const o=r.target.duration;Number.isFinite(o)&&oe(o)},onError:()=>{ce()},onEnded:()=>{N.current&&R(1)}}),e("div",{className:n.playerBar,children:fe})]}),document.body)},Ke=()=>e("div",{style:{marginTop:"0.9rem",paddingTop:"0.9rem",borderTop:"1px dashed var(--border-color)"},children:[e("h4",{style:{margin:"0 0 0.35rem",fontSize:"0.95rem"},children:"Where to get the cookie"}),e("p",{style:{margin:"0 0 0.6rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Google marks its login cookies unreadable to page scripts, so this has to come from DevTools — it takes about 20 seconds:"}),e("ol",{style:{margin:"0 0 0.75rem",paddingLeft:"1.25rem",fontSize:"0.85rem",color:"var(--text-secondary)",display:"grid",gap:"0.3rem"},children:[e("li",{children:["Open"," ",e("a",{href:"https://music.youtube.com/",target:"_blank",rel:"noopener noreferrer",children:"music.youtube.com"})," ","and make sure you are logged in."]}),e("li",{children:["Press ",e("kbd",{children:"F12"}),", go to the ",e("strong",{children:"Network"})," tab, and type ",e("kbd",{children:"browse"})," ","in the filter box."]}),e("li",{children:["Click any ",e("kbd",{children:"POST"})," browse entry, then scroll to Request Headers."]}),e("li",{children:[e("strong",{children:"Right-click"})," the ",e("kbd",{children:"Cookie"})," value and choose"," ",e("strong",{children:"Copy value"})," — right-click copies the full unwrapped value, selecting the text by hand truncates it."]}),e("li",{children:"Paste it into the sign-in box above and press Sign in."})]})]}),me=300*1e3,Xe=()=>{const a=O();return J({...a.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:s=>s.state.data?.authenticated?!1:3e3,retry:1})},et=()=>{const a=O(),s=Pe();return Re(a.music.authStart.mutationOptions({onSuccess:(f,R)=>{localStorage.setItem("ytmusic_cookie",R.cookie??""),s.invalidateQueries(a.music.pathFilter())}}))},tt=()=>{const a=O(),s=Pe();return Re(a.music.signOut.mutationOptions({onSuccess:()=>{s.invalidateQueries(a.music.pathFilter())}}))},nt=a=>{const s=O();return J({...s.music.search.queryOptions({q:a}),enabled:a.trim().length>0,staleTime:me,retry:1})},at=a=>{const s=O();return J({...s.music.library.queryOptions(),enabled:a,staleTime:me,retry:1})},it=a=>{const s=O();return J({...s.music.track.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},st=a=>{const s=O();return J({...s.music.playlist.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},rt=a=>{const s=O();return J({...s.music.upnext.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},ot=a=>{const s=O();return J({...s.music.likes.queryOptions(),enabled:a,staleTime:120*1e3,retry:1})},lt=()=>{const a=O(),s=Pe();return Re(a.music.like.mutationOptions({onSuccess:()=>{s.invalidateQueries(a.music.pathFilter())}}))},ct="_authRow_10tvv_1",ut="_btn_10tvv_9",dt="_btnGhost_10tvv_42",mt="_cookieForm_10tvv_74",ht="_cookieInput_10tvv_83",pt="_link_10tvv_99",gt="_contentLayout_10tvv_109",ft="_mainCol_10tvv_116",yt="_upnextAside_10tvv_120",bt="_upnextHeader_10tvv_131",vt="_upnextTitle_10tvv_139",kt="_upnextActions_10tvv_149",Nt="_nowPlayingLabel_10tvv_156",wt="_nowPlayingWrap_10tvv_168",St="_likeBtn_10tvv_172",Tt="_likeActive_10tvv_196",p={authRow:ct,btn:ut,btnGhost:dt,cookieForm:mt,cookieInput:ht,link:pt,contentLayout:gt,mainCol:ft,upnextAside:yt,upnextHeader:bt,upnextTitle:vt,upnextActions:kt,nowPlayingLabel:Nt,nowPlayingWrap:wt,likeBtn:St,likeActive:Tt};function Fe(a){const s=a.trim();if(!s)return null;const f=s.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??s.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return f||(/^[A-Za-z0-9_-]{11}$/.test(s)?s:null)}const xt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",It=()=>{const[a,s]=Ze(),f=Fe(a.get("v")??""),[R,be]=b(""),[se,W]=b(""),[K,re]=b(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[X,M]=b(!1),[ee,H]=b(()=>localStorage.getItem("musicShuffle")==="true"),[I,he]=b(()=>localStorage.getItem("musicRadio")!=="false"),[u,k]=b(null),[U,$]=b([]),[A,z]=b(null),[oe,T]=b({}),Y=L([]);Y.current=U;const E=L(null);E.current=u;const le=L(!1),V=L(new Set),{data:N}=Xe(),y=et(),D=tt(),B=typeof navigator<"u"?navigator.userAgent:"",Q=/android/i.test(B),te=/firefox|fxios/i.test(B)&&!Q,q=!te&&!Q&&/chrome|chromium|edg|brave/i.test(B),Z=te||q,ve=()=>{if(X)return;M(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",c),M(!1),P.error("Helper not detected — install the Dango Helper extension first.")},3e3),c=d=>{let m;try{m=JSON.parse(d.detail)}catch{return}if(!(!m||m.requestId!==t))if(window.clearTimeout(i),window.removeEventListener("dango:ytmusic-cookie",c),M(!1),m?.ok&&m.cookie){const l=m.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(l.includes("…")||l.includes("...")){P.error(`Helper returned a truncated cookie (${l.length} chars) — reload music.youtube.com and Extract again.`);return}re(l),P.success("Cookie extracted from helper — signing in…"),y.mutate({cookie:l})}else m?.error==="NO_COOKIE"?P.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):P.error("Helper request failed — try again.")};window.addEventListener("dango:ytmusic-cookie",c),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:ce,isLoading:ke}=nt(se),{data:_,isLoading:ne,isFetching:pe,error:Ne,refetch:ge}=at(N?.authenticated===!0),{data:ue,isLoading:we}=st(A?.id??null),{data:fe,isLoading:Se}=rt(u?.id??null),{data:r}=ot(N?.authenticated===!0),o=lt(),v=G(()=>ce?.tracks||[],[ce]),ae=G(()=>_?.playlists||[],[_]),C=G(()=>_?.tracks||[],[_]),j=G(()=>ue?.tracks||[],[ue]),S=G(()=>{const t=fe?.tracks||[];return u?t.filter(i=>i.id!==u.id):t},[fe,u]),Oe=G(()=>new Set(r?.likedIds||[]),[r]),Te=t=>oe[t.id]??(Oe.has(t.id)||t.liked===!0);F(()=>{N?.authenticated!==!0&&T({})},[N?.authenticated]);const De=G(()=>[...v,...j,...C,...S],[v,j,C,S]),qe=f&&u?.id!==f&&!De.some(t=>t.id===f)?f:null,{data:Ie}=it(qe),xe=u?.id;F(()=>{document.title=u?`${u.title} - dango`:"Music - dango"},[u]),F(()=>{if(!f){xe&&k(null);return}if(xe===f)return;const t=d=>{const m=d.find(l=>l.id===f);return m?(k(m),$(l=>l.some(ie=>ie.id===f)?l:d.length>0?d:[m]),!0):!1};if(t(v)||t(j)||t(C))return;const i=S.find(d=>d.id===f);if(i){k(i),$(d=>d.some(m=>m.id===i.id)?d:[i]);return}const c=Ie?.track;c&&c.id===f&&(k(c),$(d=>d.some(m=>m.id===c.id)?d:[c]))},[f,xe,v,j,C,S,Ie]);const Le=(t,i)=>{V.current.delete(t.id),k(t),$(i.length>0?i:[t]),s({v:t.id})},He=t=>{V.current.add(t.id),P.error(`Couldn't play “${t.title}” — skipped.`)},Ue=async()=>{if(le.current)return;const t=Y.current,i=t[t.length-1]??E.current;if(i){le.current=!0;try{const c=await Ce.music.upnext.query({id:i.id}),d=new Set(t.map(l=>l.id)),m=(c.tracks||[]).filter(l=>!d.has(l.id)&&!V.current.has(l.id));if(m.length===0){const l=Y.current[0];l&&(k(l),s({v:l.id}));return}$([...Y.current,...m]),k(m[0]),s({v:m[0].id})}catch{const c=Y.current[0];c&&(k(c),s({v:c.id}))}finally{le.current=!1}}},ze=t=>{const i=Y.current,c=E.current;if(!c||i.length===0)return;const d=i.findIndex(x=>x.id===c.id);if(t>0&&I&&(d<0||d===i.length-1)){Ue();return}const m=x=>V.current.has(x.id),l=i.length;let ie;if(ee&&l>1){let x=Math.floor(Math.random()*l);for(let Me=0;Me<l&&(x===d||m(i[x]));Me++)x=Math.floor(Math.random()*l);ie=i[x]}else{const x=t>0?1:-1;let ye=(((d<0?x>0?-1:0:d)+x)%l+l)%l;for(let Ee=1;Ee<l&&m(i[ye]);Ee++)ye=((ye+x)%l+l)%l;ie=i[ye]}k(ie),s({v:ie.id})},Ye=()=>{if(I){he(!1),localStorage.setItem("musicRadio","false");return}const t=E.current;if(!t)return;if(S.length===0){P.error("No radio suggestions for this song yet.");return}const i=new Set,c=[];for(const d of[t,...S])i.has(d.id)||(i.add(d.id),c.push(d));he(!0),localStorage.setItem("musicRadio","true"),$(c),P.success(`Radio started — ${S.length} songs queued.`)},$e=t=>{if(N?.authenticated!==!0){P.error("Sign in to like songs.");return}const i=!Te(t);T(c=>({...c,[t.id]:i})),o.mutate({id:t.id,like:i},{onError:()=>{T(c=>{const d={...c};return delete d[t.id],d}),P.error("Like action failed — try again.")}})},Qe=()=>{H(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Ge=t=>e("button",{className:h.stationRow,onClick:()=>z(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),t.subtitle&&e("span",{className:h.stationSub,children:t.subtitle})]})]},t.id),de=(t,i,c)=>{const d=u?.id===t.id,m=Te(t),l=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${h.stationRow} ${d?h.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>c?c(t):Le(t,i),className:h.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),e("span",{className:h.stationSub,children:[t.artists,l?` · ${l}`:""]})]})]}),N?.authenticated===!0&&e("button",{className:`${p.likeBtn} ${m?p.likeActive:""}`,onClick:()=>$e(t),disabled:o.isPending,title:m?"Remove from Liked Music":"Add to Liked Music","aria-label":m?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":m,children:e(g,{name:"heart"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(t.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":`Open ${t.title} in YouTube Music`,style:{padding:8,color:"inherit",opacity:.7,flexShrink:0},children:e(g,{name:"external-link-alt"})})]},t.id)},Ae=G(()=>{if(!u)return S;const t=new Set,i=[];for(const c of[u,...S])t.has(c.id)||(t.add(c.id),i.push(c));return i},[u,S]),We=t=>{Le(t,Ae)};return e("div",{className:`${n.page} ${u?n.pageWithPlayer:""}`,children:[e("div",{className:n.header,children:[e("h1",{className:n.pageTitle,children:[e(g,{name:"headphones"})," Music"]}),e("form",{className:n.searchForm,onSubmit:t=>{t.preventDefault();const i=Fe(R);i?(W(""),s({v:i})):W(R)},children:[e("input",{className:n.searchInput,value:R,onChange:t=>be(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:n.searchBtn,type:"submit","aria-label":"Search",children:e(g,{name:"search"})})]})]}),e("div",{className:p.authRow,children:[N?.authenticated?e(w,{children:[e("span",{className:n.statusMsg,children:["Signed in to YouTube Music",_&&` — ${_.tracks.length} songs, ${_.playlists.length} playlists`]}),e("button",{className:p.btnGhost,onClick:()=>D.mutate(),disabled:D.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=K.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){P.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==K&&re(i),y.mutate({cookie:i})}},className:p.cookieForm,children:[e("input",{className:p.cookieInput,value:K,onChange:t=>re(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:p.btn,type:"submit",disabled:y.isPending||!K.trim(),children:y.isPending?"Checking…":"Sign in"}),Z&&e("button",{className:p.btnGhost,type:"button",onClick:ve,disabled:X||y.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:X?"Extracting…":"Extract from helper"})]}),Z&&e("p",{className:n.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:xt,target:"_blank",rel:"noreferrer",className:p.link,children:"dango-extension.zip"})," ","then"," ",te?e(w,{children:[e("code",{children:"about:debugging"})," → ",e("strong",{children:"This Firefox"})," →"," ",e("strong",{children:"Load Temporary Add-on"})," →"," ",e("code",{children:"dango-extension/firefox/manifest.json"})]}):e(w,{children:[e("code",{children:"chrome://extensions"})," → ",e("strong",{children:"Developer mode"})," →"," ",e("strong",{children:"Load unpacked"})," → ",e("code",{children:"dango-extension/chrome"})]}),", log in on a music.youtube.com tab, and click Extract."]}),e(Ke,{})]}),y.isSuccess&&e("p",{className:n.statusMsg,children:["Signed in — found ",y.data.tracks," songs and ",y.data.playlists," ","playlists."]}),y.isError&&e("p",{className:n.statusMsg,children:y.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!N?.authenticated&&!y.isError&&!y.isSuccess&&e("p",{className:n.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:u?p.contentLayout:void 0,children:[e("div",{className:p.mainCol,children:se?e(w,{children:[e("h2",{className:h.sectionTitle,children:["Results for “",se,"”"]}),ke?e("p",{className:n.statusMsg,children:"Searching…"}):v.length===0?e("p",{className:n.statusMsg,children:"No tracks found."}):e("div",{className:h.stationList,children:v.map(t=>de(t,v))})]}):N?.authenticated?e(w,{children:[e("h2",{className:h.sectionTitle,children:"Your library"}),ne?e("p",{className:n.statusMsg,children:"Loading library…"}):ae.length===0&&C.length===0&&!A?e(w,{children:[e("p",{className:n.statusMsg,children:Ne?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>{ge()},disabled:pe,"aria-label":"Retry loading library",children:pe?"Retrying…":"Retry"})}),e("p",{className:n.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(w,{children:[ae.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:"Playlists"}),e("div",{className:h.stationList,children:ae.map(t=>Ge(t))})]}),C.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:["Liked songs (",C.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>Le(C[0],C),"aria-label":"Play all liked songs",children:[e(g,{name:"play"})," Play all"]})}),e("div",{className:h.stationList,children:C.map(t=>de(t,C))})]}),A?e(w,{children:[e("button",{className:p.btnGhost,onClick:()=>z(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:h.sectionTitle,children:A.title}),we?e("p",{className:n.statusMsg,children:"Loading playlist…"}):j.length===0?e("p",{className:n.statusMsg,children:"No tracks in this playlist."}):e("div",{className:h.stationList,children:j.map(t=>de(t,j))})]}):null]})]}):e("p",{className:n.statusMsg,children:"Search above, or sign in to see your library."})}),u&&e("aside",{className:p.upnextAside,"aria-label":"Up next",children:[e("div",{className:p.upnextHeader,children:e("span",{className:p.upnextTitle,children:[e(g,{name:"list-ul"})," Up Next"]})}),e("div",{className:p.nowPlayingWrap,children:[e("p",{className:p.nowPlayingLabel,children:"Now playing"}),de(u,U.length>0?U:[u])]}),e("div",{className:p.upnextActions,children:e("button",{className:p.btnGhost,onClick:Ye,disabled:!I&&(Se||S.length===0),"aria-pressed":I,title:I?"Stop the radio — the queue will loop instead of fetching more songs":"Queue these suggestions after the current song and keep the mix going",children:I?"Stop radio":"Start radio"})}),Se?e("p",{className:n.statusMsg,children:"Loading suggestions…"}):S.length===0?e("p",{className:n.statusMsg,children:"No suggestions for this song."}):e("div",{className:h.stationList,children:S.map(t=>de(t,Ae,We))})]})]}),u&&e(Je,{track:u,queue:U,shuffle:ee,onToggleShuffle:Qe,onTrackStep:ze,onTrackFailed:He,onClose:()=>{k(null),s({})},liked:u?Te(u):!1,likeVisible:N?.authenticated===!0,likePending:o.isPending,onToggleLike:()=>$e(u)})]})};export{It as default};
1
+ import{A as L,d as b,g as _e,h as F,u as e,S as w,$ as Ve,p as Ze,T as G}from"./vendor-core-DfaOB3Rn.js";import{t as Ce,W as je,h as O,z as P}from"./index-BWIWE3Qy.js";import{I as g}from"./vendor-icons-DrybRNxP.js";import{a as n}from"./Asmr.module-ChUXDZKx.js";import{r as h}from"./Radio.module-DGSZLpKM.js";import{b as J,u as Pe,a as Re}from"./vendor-query-BBT5_sHx.js";function Be(a){if(!Number.isFinite(a)||a<0)return"0:00";const s=Math.floor(a/60),f=Math.floor(a%60);return`${s}:${String(f).padStart(2,"0")}`}const Je=({track:a,shuffle:s,onToggleShuffle:f,onTrackStep:R,onTrackFailed:be,onClose:se,liked:W,likeVisible:K,likePending:re,onToggleLike:X})=>{const M=L(null),ee=L(!1),[H,I]=b(!1),[he,u]=b(!0),[k,U]=b(!1),[$,A]=b(0),[z,oe]=b(0),[T,Y]=b(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[E,le]=b(()=>localStorage.getItem("musicAutoplay")!=="false"),V=L(T);V.current=T;const N=L(E);N.current=E;const y=L(0),D=L(0),B=L(null),Q=L("");Q.current||(Q.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const te=`/api/music/audio?videoId=${encodeURIComponent(a.id)}`,q=_e.useCallback(()=>{B.current&&(window.clearTimeout(B.current),B.current=null)},[]),Z=_e.useCallback(r=>{const o=M.current;if(!o)return;q(),u(!0),U(!1);const v=()=>{if(o.removeEventListener("loadedmetadata",v),r>5&&Number.isFinite(o.duration)&&r<o.duration-5)try{o.currentTime=r}catch{}};o.addEventListener("loadedmetadata",v),o.src=te,o.load(),o.volume=V.current,o.play().catch(()=>{})},[te,q]),ve=()=>{u(!1),U(!0),be?.(a),N.current&&R(1)},ce=()=>{if(!B.current){if(D.current>=3){ve();return}D.current+=1,B.current=window.setTimeout(()=>{B.current=null,Z(y.current)},5e3)}},ke=()=>{D.current=0,Z(y.current)};F(()=>{y.current=0,D.current=0,I(!1),A(0),oe(0);const r=M.current;return Z(y.current),()=>{q(),r&&r.removeAttribute("src")}},[Z,q]),F(()=>{const r=M.current;r&&(r.volume=T)},[T]),F(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const _=a.thumbnails?.[a.thumbnails.length-1]?.url??null,ne=_e.useCallback(r=>{const o=M.current;Ce.discord.musicPresence.mutate({title:a.title,artistLabel:a.artists,isPlaying:r,thumbnail:_||"",currentTime:o?.currentTime??0,duration:Number.isFinite(o?.duration??NaN)?o?.duration:0,sessionId:Q.current}).catch(()=>{}),Ce.discord.heartbeat.mutate({sessionId:Q.current}).catch(()=>{})},[a,_]);F(()=>{ne(H)},[ne,H,a.id]),F(()=>{if(!H)return;const r=window.setInterval(()=>ne(!0),15e3);return()=>window.clearInterval(r)},[H,ne]),F(()=>{const r=Q.current,o=()=>je(r),v=()=>o(),ae=()=>{document.visibilityState==="hidden"&&o()};return window.addEventListener("pagehide",v),window.addEventListener("beforeunload",v),document.addEventListener("visibilitychange",ae),()=>{window.removeEventListener("pagehide",v),window.removeEventListener("beforeunload",v),document.removeEventListener("visibilitychange",ae),o()}},[]);const pe=()=>{const r=M.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},[Ne,ge]=b(!1);F(()=>{ge(!1)},[_]);const ue=`${a.title} — ${a.artists}`,we=e(w,{children:[e("div",{className:n.playerButtons,children:[e("button",{className:n.playerBtn,onClick:()=>R(-1),"aria-label":"Previous track",children:e(g,{name:"step-backward"})}),e("button",{className:`${n.playerBtn} ${n.playBtn}`,onClick:pe,"aria-label":H?"Pause":"Play",children:H?e(g,{name:"pause"}):e(g,{name:"play"})}),e("button",{className:n.playerBtn,onClick:()=>R(1),"aria-label":"Next track",children:e(g,{name:"step-forward"})}),k&&e("button",{className:n.playerBtn,onClick:ke,title:"Retry playback","aria-label":"Retry playback",children:e(g,{name:"redo"})})]}),e("div",{className:n.seekRow,children:[e("span",{className:n.timeLabel,children:Be($)}),e("input",{className:n.seekBar,type:"range",min:0,max:z||0,step:.1,value:Math.min($,z||0),onChange:r=>{const o=M.current;!o||!Number.isFinite(o.duration)||(o.currentTime=parseFloat(r.target.value),A(o.currentTime))},onPointerDown:()=>{ee.current=!0},onPointerUp:()=>{ee.current=!1},style:{"--played-percent":`${z>0?$/z*100:0}%`},"aria-label":"Seek"}),e("span",{className:n.timeLabel,children:Be(z)}),he&&!k&&e("span",{className:n.timeLabel,children:"loading…"})]})]}),fe=e(w,{children:[a.thumbnails?.[0]?.url&&!Ne&&e("img",{src:a.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async",onError:()=>ge(!0)}),e("div",{className:n.playerInfo,children:[e("p",{className:n.playerTitle,title:ue,children:ue}),e("p",{className:n.playerTrack,children:a.artists})]}),e("div",{className:n.playerControls,children:we}),e("div",{className:n.playerRight,children:[T===0?e(g,{name:"volume-mute",className:n.volumeIcon}):T<.5?e(g,{name:"volume-down",className:n.volumeIcon}):e(g,{name:"volume-up",className:n.volumeIcon}),e("input",{className:n.volumeBar,type:"range",min:0,max:1,step:.01,value:T,onChange:r=>{const o=parseFloat(r.target.value);Y(o),localStorage.setItem("musicVolume",String(o))},style:{"--volume-percent":`${T*100}%`},"aria-label":"Volume"})]}),e("div",{className:n.playerActions,children:[K&&X&&e("button",{className:`${n.playerBtn} ${W?n.playerBtnActive:""}`,onClick:X,disabled:re,title:W?"Remove from Liked Music":"Add to Liked Music","aria-label":W?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!W,children:e(g,{name:"heart"})}),e("button",{className:`${n.playerBtn} ${s?n.playerBtnActive:""}`,onClick:f,title:s?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":s,children:e(g,{name:"shuffle"})}),e("button",{className:`${n.playerBtn} ${E?n.playerBtnActive:""}`,onClick:()=>{le(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:E?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":E,children:e(g,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(a.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:n.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(g,{name:"external-link-alt"})}),e("button",{className:n.playerBtn,onClick:se,"aria-label":"Close player",children:e(g,{name:"times"})})]})]});return Ve(e(w,{children:[e("audio",{ref:M,preload:"none",onPlay:()=>{I(!0),u(!1),U(!1),D.current=0,q()},onPause:()=>I(!1),onWaiting:()=>{k||u(!0)},onPlaying:()=>{u(!1),D.current=0,q()},onTimeUpdate:r=>{const o=r.target.currentTime;y.current=o,q(),ee.current||A(o)},onStalled:()=>{ce()},onLoadedMetadata:r=>{const o=r.target.duration;Number.isFinite(o)&&oe(o)},onDurationChange:r=>{const o=r.target.duration;Number.isFinite(o)&&oe(o)},onError:()=>{ce()},onEnded:()=>{N.current&&R(1)}}),e("div",{className:n.playerBar,children:fe})]}),document.body)},Ke=()=>e("div",{style:{marginTop:"0.9rem",paddingTop:"0.9rem",borderTop:"1px dashed var(--border-color)"},children:[e("h4",{style:{margin:"0 0 0.35rem",fontSize:"0.95rem"},children:"Where to get the cookie"}),e("p",{style:{margin:"0 0 0.6rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Google marks its login cookies unreadable to page scripts, so this has to come from DevTools — it takes about 20 seconds:"}),e("ol",{style:{margin:"0 0 0.75rem",paddingLeft:"1.25rem",fontSize:"0.85rem",color:"var(--text-secondary)",display:"grid",gap:"0.3rem"},children:[e("li",{children:["Open"," ",e("a",{href:"https://music.youtube.com/",target:"_blank",rel:"noopener noreferrer",children:"music.youtube.com"})," ","and make sure you are logged in."]}),e("li",{children:["Press ",e("kbd",{children:"F12"}),", go to the ",e("strong",{children:"Network"})," tab, and type ",e("kbd",{children:"browse"})," ","in the filter box."]}),e("li",{children:["Click any ",e("kbd",{children:"POST"})," browse entry, then scroll to Request Headers."]}),e("li",{children:[e("strong",{children:"Right-click"})," the ",e("kbd",{children:"Cookie"})," value and choose"," ",e("strong",{children:"Copy value"})," — right-click copies the full unwrapped value, selecting the text by hand truncates it."]}),e("li",{children:"Paste it into the sign-in box above and press Sign in."})]})]}),me=300*1e3,Xe=()=>{const a=O();return J({...a.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:s=>s.state.data?.authenticated?!1:3e3,retry:1})},et=()=>{const a=O(),s=Pe();return Re(a.music.authStart.mutationOptions({onSuccess:(f,R)=>{localStorage.setItem("ytmusic_cookie",R.cookie??""),s.invalidateQueries(a.music.pathFilter())}}))},tt=()=>{const a=O(),s=Pe();return Re(a.music.signOut.mutationOptions({onSuccess:()=>{s.invalidateQueries(a.music.pathFilter())}}))},nt=a=>{const s=O();return J({...s.music.search.queryOptions({q:a}),enabled:a.trim().length>0,staleTime:me,retry:1})},at=a=>{const s=O();return J({...s.music.library.queryOptions(),enabled:a,staleTime:me,retry:1})},it=a=>{const s=O();return J({...s.music.track.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},st=a=>{const s=O();return J({...s.music.playlist.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},rt=a=>{const s=O();return J({...s.music.upnext.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},ot=a=>{const s=O();return J({...s.music.likes.queryOptions(),enabled:a,staleTime:120*1e3,retry:1})},lt=()=>{const a=O(),s=Pe();return Re(a.music.like.mutationOptions({onSuccess:()=>{s.invalidateQueries(a.music.pathFilter())}}))},ct="_authRow_10tvv_1",ut="_btn_10tvv_9",dt="_btnGhost_10tvv_42",mt="_cookieForm_10tvv_74",ht="_cookieInput_10tvv_83",pt="_link_10tvv_99",gt="_contentLayout_10tvv_109",ft="_mainCol_10tvv_116",yt="_upnextAside_10tvv_120",bt="_upnextHeader_10tvv_131",vt="_upnextTitle_10tvv_139",kt="_upnextActions_10tvv_149",Nt="_nowPlayingLabel_10tvv_156",wt="_nowPlayingWrap_10tvv_168",St="_likeBtn_10tvv_172",Tt="_likeActive_10tvv_196",p={authRow:ct,btn:ut,btnGhost:dt,cookieForm:mt,cookieInput:ht,link:pt,contentLayout:gt,mainCol:ft,upnextAside:yt,upnextHeader:bt,upnextTitle:vt,upnextActions:kt,nowPlayingLabel:Nt,nowPlayingWrap:wt,likeBtn:St,likeActive:Tt};function Fe(a){const s=a.trim();if(!s)return null;const f=s.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??s.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return f||(/^[A-Za-z0-9_-]{11}$/.test(s)?s:null)}const xt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",It=()=>{const[a,s]=Ze(),f=Fe(a.get("v")??""),[R,be]=b(""),[se,W]=b(""),[K,re]=b(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[X,M]=b(!1),[ee,H]=b(()=>localStorage.getItem("musicShuffle")==="true"),[I,he]=b(()=>localStorage.getItem("musicRadio")!=="false"),[u,k]=b(null),[U,$]=b([]),[A,z]=b(null),[oe,T]=b({}),Y=L([]);Y.current=U;const E=L(null);E.current=u;const le=L(!1),V=L(new Set),{data:N}=Xe(),y=et(),D=tt(),B=typeof navigator<"u"?navigator.userAgent:"",Q=/android/i.test(B),te=/firefox|fxios/i.test(B)&&!Q,q=!te&&!Q&&/chrome|chromium|edg|brave/i.test(B),Z=te||q,ve=()=>{if(X)return;M(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",c),M(!1),P.error("Helper not detected — install the Dango Helper extension first.")},3e3),c=d=>{let m;try{m=JSON.parse(d.detail)}catch{return}if(!(!m||m.requestId!==t))if(window.clearTimeout(i),window.removeEventListener("dango:ytmusic-cookie",c),M(!1),m?.ok&&m.cookie){const l=m.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(l.includes("…")||l.includes("...")){P.error(`Helper returned a truncated cookie (${l.length} chars) — reload music.youtube.com and Extract again.`);return}re(l),P.success("Cookie extracted from helper — signing in…"),y.mutate({cookie:l})}else m?.error==="NO_COOKIE"?P.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):P.error("Helper request failed — try again.")};window.addEventListener("dango:ytmusic-cookie",c),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:ce,isLoading:ke}=nt(se),{data:_,isLoading:ne,isFetching:pe,error:Ne,refetch:ge}=at(N?.authenticated===!0),{data:ue,isLoading:we}=st(A?.id??null),{data:fe,isLoading:Se}=rt(u?.id??null),{data:r}=ot(N?.authenticated===!0),o=lt(),v=G(()=>ce?.tracks||[],[ce]),ae=G(()=>_?.playlists||[],[_]),C=G(()=>_?.tracks||[],[_]),j=G(()=>ue?.tracks||[],[ue]),S=G(()=>{const t=fe?.tracks||[];return u?t.filter(i=>i.id!==u.id):t},[fe,u]),Oe=G(()=>new Set(r?.likedIds||[]),[r]),Te=t=>oe[t.id]??(Oe.has(t.id)||t.liked===!0);F(()=>{N?.authenticated!==!0&&T({})},[N?.authenticated]);const De=G(()=>[...v,...j,...C,...S],[v,j,C,S]),qe=f&&u?.id!==f&&!De.some(t=>t.id===f)?f:null,{data:Ie}=it(qe),xe=u?.id;F(()=>{document.title=u?`${u.title} - dango`:"Music - dango"},[u]),F(()=>{if(!f){xe&&k(null);return}if(xe===f)return;const t=d=>{const m=d.find(l=>l.id===f);return m?(k(m),$(l=>l.some(ie=>ie.id===f)?l:d.length>0?d:[m]),!0):!1};if(t(v)||t(j)||t(C))return;const i=S.find(d=>d.id===f);if(i){k(i),$(d=>d.some(m=>m.id===i.id)?d:[i]);return}const c=Ie?.track;c&&c.id===f&&(k(c),$(d=>d.some(m=>m.id===c.id)?d:[c]))},[f,xe,v,j,C,S,Ie]);const Le=(t,i)=>{V.current.delete(t.id),k(t),$(i.length>0?i:[t]),s({v:t.id})},He=t=>{V.current.add(t.id),P.error(`Couldn't play “${t.title}” — skipped.`)},Ue=async()=>{if(le.current)return;const t=Y.current,i=t[t.length-1]??E.current;if(i){le.current=!0;try{const c=await Ce.music.upnext.query({id:i.id}),d=new Set(t.map(l=>l.id)),m=(c.tracks||[]).filter(l=>!d.has(l.id)&&!V.current.has(l.id));if(m.length===0){const l=Y.current[0];l&&(k(l),s({v:l.id}));return}$([...Y.current,...m]),k(m[0]),s({v:m[0].id})}catch{const c=Y.current[0];c&&(k(c),s({v:c.id}))}finally{le.current=!1}}},ze=t=>{const i=Y.current,c=E.current;if(!c||i.length===0)return;const d=i.findIndex(x=>x.id===c.id);if(t>0&&I&&(d<0||d===i.length-1)){Ue();return}const m=x=>V.current.has(x.id),l=i.length;let ie;if(ee&&l>1){let x=Math.floor(Math.random()*l);for(let Me=0;Me<l&&(x===d||m(i[x]));Me++)x=Math.floor(Math.random()*l);ie=i[x]}else{const x=t>0?1:-1;let ye=(((d<0?x>0?-1:0:d)+x)%l+l)%l;for(let Ee=1;Ee<l&&m(i[ye]);Ee++)ye=((ye+x)%l+l)%l;ie=i[ye]}k(ie),s({v:ie.id})},Ye=()=>{if(I){he(!1),localStorage.setItem("musicRadio","false");return}const t=E.current;if(!t)return;if(S.length===0){P.error("No radio suggestions for this song yet.");return}const i=new Set,c=[];for(const d of[t,...S])i.has(d.id)||(i.add(d.id),c.push(d));he(!0),localStorage.setItem("musicRadio","true"),$(c),P.success(`Radio started — ${S.length} songs queued.`)},$e=t=>{if(N?.authenticated!==!0){P.error("Sign in to like songs.");return}const i=!Te(t);T(c=>({...c,[t.id]:i})),o.mutate({id:t.id,like:i},{onError:()=>{T(c=>{const d={...c};return delete d[t.id],d}),P.error("Like action failed — try again.")}})},Qe=()=>{H(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Ge=t=>e("button",{className:h.stationRow,onClick:()=>z(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),t.subtitle&&e("span",{className:h.stationSub,children:t.subtitle})]})]},t.id),de=(t,i,c)=>{const d=u?.id===t.id,m=Te(t),l=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${h.stationRow} ${d?h.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>c?c(t):Le(t,i),className:h.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),e("span",{className:h.stationSub,children:[t.artists,l?` · ${l}`:""]})]})]}),N?.authenticated===!0&&e("button",{className:`${p.likeBtn} ${m?p.likeActive:""}`,onClick:()=>$e(t),disabled:o.isPending,title:m?"Remove from Liked Music":"Add to Liked Music","aria-label":m?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":m,children:e(g,{name:"heart"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(t.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":`Open ${t.title} in YouTube Music`,style:{padding:8,color:"inherit",opacity:.7,flexShrink:0},children:e(g,{name:"external-link-alt"})})]},t.id)},Ae=G(()=>{if(!u)return S;const t=new Set,i=[];for(const c of[u,...S])t.has(c.id)||(t.add(c.id),i.push(c));return i},[u,S]),We=t=>{Le(t,Ae)};return e("div",{className:`${n.page} ${u?n.pageWithPlayer:""}`,children:[e("div",{className:n.header,children:[e("h1",{className:n.pageTitle,children:[e(g,{name:"headphones"})," Music"]}),e("form",{className:n.searchForm,onSubmit:t=>{t.preventDefault();const i=Fe(R);i?(W(""),s({v:i})):W(R)},children:[e("input",{className:n.searchInput,value:R,onChange:t=>be(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:n.searchBtn,type:"submit","aria-label":"Search",children:e(g,{name:"search"})})]})]}),e("div",{className:p.authRow,children:[N?.authenticated?e(w,{children:[e("span",{className:n.statusMsg,children:["Signed in to YouTube Music",_&&` — ${_.tracks.length} songs, ${_.playlists.length} playlists`]}),e("button",{className:p.btnGhost,onClick:()=>D.mutate(),disabled:D.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=K.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){P.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==K&&re(i),y.mutate({cookie:i})}},className:p.cookieForm,children:[e("input",{className:p.cookieInput,value:K,onChange:t=>re(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:p.btn,type:"submit",disabled:y.isPending||!K.trim(),children:y.isPending?"Checking…":"Sign in"}),Z&&e("button",{className:p.btnGhost,type:"button",onClick:ve,disabled:X||y.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:X?"Extracting…":"Extract from helper"})]}),Z&&e("p",{className:n.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:xt,target:"_blank",rel:"noreferrer",className:p.link,children:"dango-extension.zip"})," ","then"," ",te?e(w,{children:[e("code",{children:"about:debugging"})," → ",e("strong",{children:"This Firefox"})," →"," ",e("strong",{children:"Load Temporary Add-on"})," →"," ",e("code",{children:"dango-extension/firefox/manifest.json"})]}):e(w,{children:[e("code",{children:"chrome://extensions"})," → ",e("strong",{children:"Developer mode"})," →"," ",e("strong",{children:"Load unpacked"})," → ",e("code",{children:"dango-extension/chrome"})]}),", log in on a music.youtube.com tab, and click Extract."]}),e(Ke,{})]}),y.isSuccess&&e("p",{className:n.statusMsg,children:["Signed in — found ",y.data.tracks," songs and ",y.data.playlists," ","playlists."]}),y.isError&&e("p",{className:n.statusMsg,children:y.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!N?.authenticated&&!y.isError&&!y.isSuccess&&e("p",{className:n.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:u?p.contentLayout:void 0,children:[e("div",{className:p.mainCol,children:se?e(w,{children:[e("h2",{className:h.sectionTitle,children:["Results for “",se,"”"]}),ke?e("p",{className:n.statusMsg,children:"Searching…"}):v.length===0?e("p",{className:n.statusMsg,children:"No tracks found."}):e("div",{className:h.stationList,children:v.map(t=>de(t,v))})]}):N?.authenticated?e(w,{children:[e("h2",{className:h.sectionTitle,children:"Your library"}),ne?e("p",{className:n.statusMsg,children:"Loading library…"}):ae.length===0&&C.length===0&&!A?e(w,{children:[e("p",{className:n.statusMsg,children:Ne?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>{ge()},disabled:pe,"aria-label":"Retry loading library",children:pe?"Retrying…":"Retry"})}),e("p",{className:n.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(w,{children:[ae.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:"Playlists"}),e("div",{className:h.stationList,children:ae.map(t=>Ge(t))})]}),C.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:["Liked songs (",C.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>Le(C[0],C),"aria-label":"Play all liked songs",children:[e(g,{name:"play"})," Play all"]})}),e("div",{className:h.stationList,children:C.map(t=>de(t,C))})]}),A?e(w,{children:[e("button",{className:p.btnGhost,onClick:()=>z(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:h.sectionTitle,children:A.title}),we?e("p",{className:n.statusMsg,children:"Loading playlist…"}):j.length===0?e("p",{className:n.statusMsg,children:"No tracks in this playlist."}):e("div",{className:h.stationList,children:j.map(t=>de(t,j))})]}):null]})]}):e("p",{className:n.statusMsg,children:"Search above, or sign in to see your library."})}),u&&e("aside",{className:p.upnextAside,"aria-label":"Up next",children:[e("div",{className:p.upnextHeader,children:e("span",{className:p.upnextTitle,children:[e(g,{name:"list-ul"})," Up Next"]})}),e("div",{className:p.nowPlayingWrap,children:[e("p",{className:p.nowPlayingLabel,children:"Now playing"}),de(u,U.length>0?U:[u])]}),e("div",{className:p.upnextActions,children:e("button",{className:p.btnGhost,onClick:Ye,disabled:!I&&(Se||S.length===0),"aria-pressed":I,title:I?"Stop the radio — the queue will loop instead of fetching more songs":"Queue these suggestions after the current song and keep the mix going",children:I?"Stop radio":"Start radio"})}),Se?e("p",{className:n.statusMsg,children:"Loading suggestions…"}):S.length===0?e("p",{className:n.statusMsg,children:"No suggestions for this song."}):e("div",{className:h.stationList,children:S.map(t=>de(t,Ae,We))})]})]}),u&&e(Je,{track:u,queue:U,shuffle:ee,onToggleShuffle:Qe,onTrackStep:ze,onTrackFailed:He,onClose:()=>{k(null),s({})},liked:u?Te(u):!1,likeVisible:N?.authenticated===!0,likePending:o.isPending,onToggleLike:()=>$e(u)})]})};export{It as default};
@@ -1 +1 @@
1
- import{u as e,S as p,d as y,h as S}from"./vendor-core-DfaOB3Rn.js";import{I as m}from"./vendor-icons-DrybRNxP.js";import{M as s,y as b,T as g,B as f,z as k,D as C}from"./AvSyncCalibrator-FJllOgOH.js";const O=({classes:n,title:i,titleTag:o="span",showBack:l=!0,onBack:t,panelRef:d,onPanelClick:a,children:c})=>{const r=o;return e("div",{ref:d,className:n.panel,onClick:a,"data-speed-boost-ignore":"true",children:[e("div",{className:n.header,children:[l&&e("button",{className:n.backBtn,onClick:t,children:e(m,{name:"chevron-left"})}),e(r,{className:n.title||void 0,children:i})]}),e("div",{className:n.content,children:c})]})},z=({classes:n,values:i,onChange:o})=>{const l=()=>{const t=C;o("fontSize",t.fontSize),o("position",t.position),o("bgOpacity",t.bgOpacity),o("bgColor",t.bgColor),o("textColor",t.textColor),o("edge",t.edge),o("bold",t.bold)};return e(p,{children:[e(s,{label:"Font Size",display:i.fontSize.toFixed(1),min:.5,max:10,step:.5,value:i.fontSize,percent:(i.fontSize-.5)/9.5*100,onChange:t=>{Number.isFinite(t)&&o("fontSize",t)}}),e(s,{label:"Vertical Position",display:`${i.position}`,min:0,max:100,step:1,value:i.position,percent:i.position,onChange:t=>{Number.isFinite(t)&&o("position",Math.round(t))}}),e(s,{label:"Background Opacity",display:`${Math.round(i.bgOpacity*100)}%`,min:0,max:1,step:.05,value:i.bgOpacity,percent:i.bgOpacity*100,onChange:t=>{Number.isFinite(t)&&o("bgOpacity",t)}}),e(b,{label:"Text Color",colors:g,value:i.textColor,onChange:t=>o("textColor",t)}),e(b,{label:"Background Color",colors:f,value:i.bgColor,onChange:t=>o("bgColor",t)}),e(k,{label:"Text Edge",options:["shadow","outline","none"],value:i.edge,onChange:t=>o("edge",t)}),e("button",{type:"button",className:`${n.item} ${i.bold?n.active:""}`,onClick:()=>o("bold",!i.bold),children:[e("span",{children:"Bold Text"}),i.bold&&e(m,{name:"check",size:12})]}),e("button",{type:"button",className:n.item,onClick:l,children:e("span",{children:"Reset to Defaults"})})]})},M=({classes:n,enabled:i,delayMs:o,onToggle:l,onDelayChange:t,onCalibrate:d})=>{const[a,c]=y(null),r=a??o;S(()=>{c(null)},[o]);const u=()=>{a!==null&&(t(a),c(null))};return e(p,{children:[e("button",{type:"button",className:`${n.item} ${i?n.active:""}`,onClick:()=>l(!i),children:[e("span",{children:"Video delay"}),i&&e(m,{name:"check",size:12})]}),e(s,{label:"Video delay",display:`${r}ms`,min:0,max:500,step:5,value:r,percent:r/500*100,onChange:h=>c(Math.round(h)),onCommit:u}),e("div",{className:n.note,children:"For Bluetooth headsets where audio arrives late. Video is held back via canvas; audio plays untouched."}),d&&e("button",{type:"button",className:n.item,onClick:d,children:e("span",{children:"Calibrate…"})})]})},E=({classes:n,options:i,onSelect:o})=>e(p,{children:i.map(l=>e("button",{type:"button",className:`${n.item} ${l.selected?n.active:""}`,onClick:()=>o(l.key),children:[e("span",{children:l.label}),l.selected&&e(m,{name:"check",size:12})]},l.key))});export{M as A,E as O,O as S,z as a};
1
+ import{u as e,S as p,d as y,h as S}from"./vendor-core-DfaOB3Rn.js";import{I as m}from"./vendor-icons-DrybRNxP.js";import{M as s,y as b,T as g,B as f,z as k,D as C}from"./AvSyncCalibrator-DxL0mr_4.js";const O=({classes:n,title:i,titleTag:o="span",showBack:l=!0,onBack:t,panelRef:d,onPanelClick:a,children:c})=>{const r=o;return e("div",{ref:d,className:n.panel,onClick:a,"data-speed-boost-ignore":"true",children:[e("div",{className:n.header,children:[l&&e("button",{className:n.backBtn,onClick:t,children:e(m,{name:"chevron-left"})}),e(r,{className:n.title||void 0,children:i})]}),e("div",{className:n.content,children:c})]})},z=({classes:n,values:i,onChange:o})=>{const l=()=>{const t=C;o("fontSize",t.fontSize),o("position",t.position),o("bgOpacity",t.bgOpacity),o("bgColor",t.bgColor),o("textColor",t.textColor),o("edge",t.edge),o("bold",t.bold)};return e(p,{children:[e(s,{label:"Font Size",display:i.fontSize.toFixed(1),min:.5,max:10,step:.5,value:i.fontSize,percent:(i.fontSize-.5)/9.5*100,onChange:t=>{Number.isFinite(t)&&o("fontSize",t)}}),e(s,{label:"Vertical Position",display:`${i.position}`,min:0,max:100,step:1,value:i.position,percent:i.position,onChange:t=>{Number.isFinite(t)&&o("position",Math.round(t))}}),e(s,{label:"Background Opacity",display:`${Math.round(i.bgOpacity*100)}%`,min:0,max:1,step:.05,value:i.bgOpacity,percent:i.bgOpacity*100,onChange:t=>{Number.isFinite(t)&&o("bgOpacity",t)}}),e(b,{label:"Text Color",colors:g,value:i.textColor,onChange:t=>o("textColor",t)}),e(b,{label:"Background Color",colors:f,value:i.bgColor,onChange:t=>o("bgColor",t)}),e(k,{label:"Text Edge",options:["shadow","outline","none"],value:i.edge,onChange:t=>o("edge",t)}),e("button",{type:"button",className:`${n.item} ${i.bold?n.active:""}`,onClick:()=>o("bold",!i.bold),children:[e("span",{children:"Bold Text"}),i.bold&&e(m,{name:"check",size:12})]}),e("button",{type:"button",className:n.item,onClick:l,children:e("span",{children:"Reset to Defaults"})})]})},M=({classes:n,enabled:i,delayMs:o,onToggle:l,onDelayChange:t,onCalibrate:d})=>{const[a,c]=y(null),r=a??o;S(()=>{c(null)},[o]);const u=()=>{a!==null&&(t(a),c(null))};return e(p,{children:[e("button",{type:"button",className:`${n.item} ${i?n.active:""}`,onClick:()=>l(!i),children:[e("span",{children:"Video delay"}),i&&e(m,{name:"check",size:12})]}),e(s,{label:"Video delay",display:`${r}ms`,min:0,max:500,step:5,value:r,percent:r/500*100,onChange:h=>c(Math.round(h)),onCommit:u}),e("div",{className:n.note,children:"For Bluetooth headsets where audio arrives late. Video is held back via canvas; audio plays untouched."}),d&&e("button",{type:"button",className:n.item,onClick:d,children:e("span",{children:"Calibrate…"})})]})},E=({classes:n,options:i,onSelect:o})=>e(p,{children:i.map(l=>e("button",{type:"button",className:`${n.item} ${l.selected?n.active:""}`,onClick:()=>o(l.key),children:[e("span",{children:l.label}),l.selected&&e(m,{name:"check",size:12})]},l.key))});export{M as A,E as O,O as S,z as a};