PageSourceSearch

https://readingtk.net/assets/dashboard-DY4hagRx.js

js readingtk.net collected 2026-10-02 02:02:23 UTC 37,530 bytes, 1 lines download raw bytes

1import{r as x,j as e}from"./vendor-react-BBy2ZWQs.js";import{c as we,u as le,s as i,e as oe,t as ie,i as xe,L as Se,j as J}from"./index-Bj7licZY.js";import{i as ke,R as je,n as Ce,o as qe,e as Ne,p as Ee,q as Ke,r as Te,s as fe,u as ne,X as ue,v as me,t as T,E as De,m as ge}from"./vendor-ui-BxcOQNql.js";import{s as ye}from"./localAgent-DkOIJXWq.js";import"./vendor-misc-UQ56Iyoi.js";import"./vendor-supabase-B4HII3_u.js";const Fe=["all","manga","manhua","manhwa","novel","autre"],Qe=["all","ongoing","paused","dropped","completed"];function Me({col:a,sortBy:c,sortDir:o}){return c!==a?e.jsx(Ee,{className:"inline ml-1 h-3 w-3 opacity-40"}):o==="asc"?e.jsx(Ke,{className:"inline ml-1 h-3 w-3"}):e.jsx(Te,{className:"inline ml-1 h-3 w-3"})}function He(){const a=we(),{t:c,lang:o}=le(),[r,j]=x.useState(""),[w,Q]=x.useState("all"),[q,D]=x.useState("all"),[f,F]=x.useState(null),[C,X]=x.useState(()=>localStorage.getItem("dash-sort-col")??null),[M,Z]=x.useState(()=>localStorage.getItem("dash-sort-dir")??"asc"),[N,U]=x.useState(!1),[E,B]=x.useState(new Set),[L,P]=x.useState(!1);function H(){U(s=>(s||F(null),!s)),B(new Set)}function $(s){B(l=>{const u=new Set(l);return u.has(s)?u.delete(s):u.add(s),u})}async function I(s){const l=[...E].filter(u=>u!==s);if(l.length)try{const u=(_??[]).find(p=>p.id===s),S=(_??[]).filter(p=>l.includes(p.id)).flatMap(p=>[p.name,...p.aliases??[]]),d=[...new Set([...u.aliases??[],...S])].filter(p=>p!==u.name);await i.from("titles").update({aliases:d}).eq("id",s);for(const p of l){const{data:V}=await i.from("title_sources").select("site_id").eq("title_id",s),z=new Set((V??[]).map(K=>K.site_id)),{data:G}=await i.from("title_sources").select("id, site_id").eq("title_id",p);for(const K of G??[])z.has(K.site_id)||(await i.from("title_sources").update({title_id:s}).eq("id",K.id),z.add(K.site_id));const{data:Y}=await i.from("reading_progress").select("last_chapter_read").eq("title_id",p).maybeSingle();if(Y?.last_chapter_read){const{data:K}=await i.from("reading_progress").select("last_chapter_read").eq("title_id",s).maybeSingle(),se=parseFloat(Y.last_chapter_read),re=parseFloat(K?.last_chapter_read??"");!isNaN(se)&&(isNaN(re)||se>re)&&await i.from("reading_progress").upsert({title_id:s,last_chapter_read:Y.last_chapter_read,last_read_at:new Date().toISOString()},{onConflict:"title_id"})}await i.from("chapters").update({title_id:s}).eq("title_id",p),await i.from("title_sources").delete().eq("title_id",p),await i.from("reading_progress").delete().eq("title_id",p),await i.from("notifications").delete().eq("title_id",p),await i.from("titles").delete().eq("id",p)}T.success(c("dash.merged")),a.invalidateQueries({queryKey:["titles"]}),U(!1),B(new Set),P(!1)}catch(u){T.error(u.message)}}x.useEffect(()=>{const s=i.channel("rtk-dashboard-live").on("postgres_changes",{event:"*",schema:"public",table:"title_sources"},()=>{a.invalidateQueries({queryKey:["titles"]})}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"titles"},()=>{a.invalidateQueries({queryKey:["titles"]})}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"user_settings"},()=>{a.invalidateQueries({queryKey:["last-check"]})}).subscribe();return()=>{i.removeChannel(s)}},[a]);const{data:ee}=oe({queryKey:["last-check"],queryFn:async()=>{const{data:s}=await i.from("user_settings").select("last_global_check_at").maybeSingle();return s?.last_global_check_at??null},refetchInterval:6e4}),{data:_,isLoading:W}=oe({queryKey:["titles"],queryFn:async()=>{const{data:s,error:l}=await i.from("titles").select("id, name, type, status, aliases, cover_url, reading_progress(last_chapter_read), title_sources(last_seen_chapter)").order("created_at",{ascending:!1});if(l)throw l;return s??[]}});x.useEffect(()=>{if(!_)return;const s=_.filter(l=>l.cover_url&&!l.cover_url.includes("supabase.co/storage"));s.length&&(async()=>{for(const l of s)try{await i.functions.invoke("cache-cover",{body:{imageUrl:l.cover_url,titleId:l.id}})}catch{}s.length>0&&a.invalidateQueries({queryKey:["titles"]})})()},[_?.map(s=>`${s.id}:${s.cover_url?.includes("supabase.co/storage")?"":s.cover_url??""}`).join("|")]);const R=s=>{const l=(s.title_sources||[]).map(u=>parseFloat(u.last_seen_chapter??"")).filter(u=>!isNaN(u));return l.length?String(Math.max(...l)):null},A=(_??[]).filter(s=>{if(r){const l=r.toLowerCase(),u=s.name.toLowerCase().includes(l),k=(s.aliases??[]).some(S=>S.toLowerCase().includes(l));if(!u&&!k)return!1}return!(w!=="all"&&s.type!==w||q!=="all"&&s.status!==q)}),O=C?[...A].sort((s,l)=>{let u=0;if(C==="name")u=s.name.localeCompare(l.name,void 0,{sensitivity:"base"});else if(C==="type")u=(s.type??"").localeCompare(l.type??"",void 0,{sensitivity:"base"});else if(C==="status")u=(s.status??"").localeCompare(l.status??"",void 0,{sensitivity:"base"});else if(C==="lu"){const k=parseFloat(s.reading_progress?.last_chapter_read??""),S=parseFloat(l.reading_progress?.last_chapter_read??"");u=(isNaN(k)?-1:k)-(isNaN(S)?-1:S)}else if(C==="detected"){const k=(()=>{const d=R(s),p=s.reading_progress?.last_chapter_read;return d!=null&&(!p||parseFloat(d)>parseFloat(p||"0"))})(),S=(()=>{const d=R(l),p=l.reading_progress?.last_chapter_read;return d!=null&&(!p||parseFloat(d)>parseFloat(p||"0"))})();k!==S?u=k?-1:1:u=s.name.localeCompare(l.name,void 0,{sensitivity:"base"})}return M==="asc"?u:-u}):A;function te(s){if(C===s){const l=M==="asc"?"desc":"asc";Z(l),localStorage.setItem("dash-sort-dir",l)}else X(s),Z("asc"),localStorage.setItem("dash-sort-col",s),localStorage.setItem("dash-sort-dir","asc")}return e.jsxs("div",{className:"p-6 pr-[600px]",onClick:()=>{f&&!N&&F(null)},children:[e.jsx("div",{className:"mb-6 flex items-center gap-3",children:e.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-md border border-input bg-card/60 px-3 py-2",children:[e.jsx(ke,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("input",{value:r,onChange:s=>j(s.target.value),placeholder:c("dash.search"),className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]})}),e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3 text-xs",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx(ve,{label:c("filter.type"),value:w,options:Fe,onChange:Q,labelFn:s=>ie(c,s)}),e.jsx(ve,{label:c("filter.status"),value:q,options:Qe,onChange:D,labelFn:s=>xe(c,s)}
1),e.jsx("span",{className:"text-muted-foreground/60",children:c("dash.titleCount",{n:A.length,total:(_??[]).length})})]}),N?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:c("dash.selected",{n:E.size})}),E.size>=2&&e.jsx("button",{onClick:()=>P(!0),className:"rounded-full bg-accent px-3 py-1.5 font-medium text-accent-foreground transition",children:c("dash.mergeN",{n:E.size})}),e.jsx("button",{onClick:H,className:"rounded-full bg-secondary/40 px-3 py-1.5 text-muted-foreground hover:bg-secondary transition",children:c("common.cancel")})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[ee&&e.jsx("span",{className:"text-muted-foreground/60",children:c("dash.lastScraping",{date:new Date(ee).toLocaleString(o==="fr"?"fr-FR":"en-US",{dateStyle:"short",timeStyle:"short"})})}),e.jsxs("button",{onClick:()=>a.invalidateQueries({queryKey:["titles"]}),className:"flex items-center gap-1.5 rounded-full bg-secondary/40 px-3 py-1.5 text-muted-foreground hover:bg-secondary hover:text-foreground transition",children:[e.jsx(je,{className:"h-3 w-3"})," ",c("dash.refresh")]}),e.jsxs("button",{onClick:H,className:"flex items-center gap-1.5 rounded-full bg-secondary/40 px-3 py-1.5 text-muted-foreground hover:bg-secondary hover:text-foreground transition",children:[e.jsx(Ce,{className:"h-3 w-3"})," ",c("dash.merge")]})]})]}),W?e.jsx("div",{className:"rounded-xl border border-border/60 bg-card/40 p-10 text-center text-sm text-muted-foreground",children:c("common.loading")}):A.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-card/40 p-16 text-center",children:[e.jsx(qe,{className:"mx-auto h-8 w-8 text-accent"}),e.jsx("h2",{className:"mt-3 text-lg font-semibold",children:c("dash.emptyTitle")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:c("dash.emptyDesc")}),e.jsxs(Se,{to:"/titles/add",className:"mt-4 inline-flex items-center gap-2 rounded-md px-4 py-2 text-sm font-medium text-primary-foreground",style:{background:"var(--gradient-primary)"},children:[e.jsx(Ne,{className:"h-4 w-4"})," ",c("nav.addTitle")]})]}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border/60 bg-card/40",style:{boxShadow:"var(--shadow-card)"},children:e.jsxs("table",{className:"w-full table-fixed text-sm",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"w-24"}),e.jsx("col",{className:"w-full"}),e.jsx("col",{className:"w-24"}),e.jsx("col",{className:"w-12"}),e.jsx("col",{className:"w-24"})]}),e.jsx("thead",{className:"bg-secondary/40 text-xs uppercase tracking-wide text-muted-foreground",children:e.jsx("tr",{children:["type","name","status","lu","detected"].map((s,l)=>e.jsx("th",{className:`${l===0?"px-3":"px-2"} py-2 text-left`,children:e.jsxs("button",{onClick:u=>{u.stopPropagation(),te(s)},title:c("common.sortColumn"),className:"flex items-center hover:text-foreground transition-colors",children:[c(s==="name"?"dash.colTitle":s==="type"?"filter.type":s==="status"?"filter.status":s==="lu"?"dash.colRead":"dash.colDetected"),e.jsx(Me,{col:s,sortBy:C,sortDir:M})]})},s))})}),e.jsx("tbody",{children:O.map(s=>{const l=s.reading_progress?.last_chapter_read??null,u=R(s),k=u&&(!l||parseFloat(u)>parseFloat(l||"0")),S=E.has(s.id);return e.jsxs("tr",{onClick:d=>{d.stopPropagation(),N?$(s.id):F(s.id)},className:`cursor-pointer border-t border-border/40 transition-colors hover:bg-secondary/30 ${!N&&f===s.id||N&&S?"bg-secondary/40":""}`,children:[e.jsx("td",{className:"px-3 py-2",children:e.jsx(Le,{type:s.type})}),e.jsx("td",{className:"px-2 py-1",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.cover_url?e.jsx("img",{src:s.cover_url,alt:"",loading:"lazy",className:"h-9 w-6 shrink-0 rounded object-cover object-top"}):e.jsx("div",{className:"h-9 w-6 shrink-0 rounded bg-secondary/60"}),e.jsxs("span",{className:"truncate font-medium",children:[N&&e.jsx("input",{type:"checkbox",checked:S,onChange:()=>{},className:"mr-2 pointer-events-none"}),s.name,(s.aliases??[]).length>0&&e.jsx("span",{className:"ml-1.5 text-xs font-normal text-muted-foreground
1/60",children:c((s.aliases??[]).length>1?"dash.variantsMany":"dash.variantsOne",{n:(s.aliases??[]).length})})]})]})}),e.jsx("td",{className:"px-2 py-2 text-xs",children:e.jsx("span",{className:"rounded-full bg-secondary/60 px-2 py-0.5 text-muted-foreground",children:s.status?xe(c,s.status):"—"})}),e.jsx("td",{className:"px-2 py-2 text-xs",children:l??"—"}),e.jsxs("td",{className:"px-2 py-2 text-xs whitespace-nowrap",children:[u??"—",k&&e.jsx("span",{className:"ml-1 rounded-full bg-accent px-1.5 py-0.5 text-[10px] font-semibold text-accent-foreground",children:"NEW"})]})]},s.id)})})]})}),!N&&f&&e.jsx($e,{titleId:f,onClose:()=>F(null)}),L&&e.jsx(Ue,{selectedTitles:(_??[]).filter(s=>E.has(s.id)),onConfirm:I,onClose:()=>P(!1)})]})}function Ue({selectedTitles:a,onConfirm:c,onClose:o}){const{t:r}=le(),[j,w]=x.useState(a[0]?.id??""),[Q,q]=x.useState(!1),D=a.filter(f=>f.id!==j);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:o,children:e.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-xl",onClick:f=>f.stopPropagation(),children:[e.jsx("h2",{className:"text-lg font-bold",children:r("merge.title")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r("merge.desc")}),e.jsx("div",{className:"mt-4 space-y-2",children:a.map(f=>e.jsxs("label",{className:`flex cursor-pointer items-center gap-3 rounded-md border p-3 transition ${j===f.id?"border-accent bg-accent/10":"border-border/60 hover:bg-secondary/30"}`,children:[e.jsx("input",{type:"radio",name:"primary",checked:j===f.id,onChange:()=>w(f.id),className:"accent-accent"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:f.name}),(f.aliases??[]).length>0&&e.jsx("div",{className:"text-xs text-muted-foreground",children:r("merge.variants",{list:(f.aliases??[]).join(", ")})})]})]},f.id))}),D.length>0&&e.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[r("merge.willKeep",{list:""}),e.jsx("span",{className:"text-foreground/70",children:D.map(f=>`"${f.name}"`).join(", ")})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx("button",{onClick:o,className:"rounded-md px-4 py-2 text-sm text-muted-foreground hover:bg-secondary/40 transition",children:r("common.cancel")}),e.jsx("button",{onClick:async()=>{q(!0),await c(j),q(!1)},disabled:Q,className:"rounded-md px-4 py-2 text-sm font-semibold text-primary-foreground disabled:opacity-60",style:{background:"var(--gradient-primary)"},children:Q?"...":r("dash.merge")})]})]})})}const be={manga:"bg-accent/15 text-accent border border-accent/30",manhua:"bg-cyan-500/15 text-cyan-400 border border-cyan-500/30",manhwa:"bg-orange-500/15 text-orange-400 border border-orange-500/30",novel:"bg-amber-500/15 text-amber-400 border border-amber-500/30",autre:"bg-secondary/60 text-muted-foreground border border-border/60"};function Le({type:a}){const{t:c}=le(),o=be[a??""]??be.autre;return e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-semibold tracking-wide ${o}`,children:a?ie(c,a):"—"})}function ve({label:a,value:c,options:o,onChange:r,labelFn:j}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-muted-foreground",children:[a,":"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.map(w=>e.jsx("button",{onClick:()=>r(w),className:`rounded-full px-2.5 py-1 text-xs transition ${c===w?"bg-accent text-accent-foreground":"bg-secondary/40 text-muted-foreground hover:bg-secondary"}`,children:j?j(w):w},w))})]})}async function Pe(a,c){try{const o=await fetch("http://127.0.0.1:7842/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title_id:a,auto_discover:c}),signal:AbortSignal.timeout(9e4)});if(o.status===401)return{status:"unavailable"};const r=await o.json().catch(()=>null);return r?r.status==="done"?{status:"done",detected:r.detected??0,errors:r.errors??0}:r.status==="error"?{status:"error",message:r.error||"?"}:{status:"unavailable"}:{status:"unavailable"}}catch{return{status:"unavailable"}}}function $e({titleId:a,onClose:c}){const o=we(),{t:r}
1=le(),[j,w]=x.useState(!1),[Q,q]=x.useState(null),[D,f]=x.useState(null),[F,C]=x.useState(""),[X,M]=x.useState(""),[Z,N]=x.useState(!1),[U,E]=x.useState(""),[B,L]=x.useState(!1),[P,H]=x.useState(""),[$,I]=x.useState(!1),[ee,_]=x.useState(!1),[W,R]=x.useState(""),[A,O]=x.useState(!1),[te,s]=x.useState(""),{data:l}=oe({queryKey:["sites"],queryFn:async()=>(await i.from("sites").select("id,base_url,name")).data??[]});async function u(){const t=te.trim();if(!t)return;const{data:n}=await i.auth.getUser(),h=n.user.id;let g=null;try{const y=new URL(t),m=y.hostname,b=(l??[]).find(v=>{try{return new URL(v.base_url).hostname===m}catch{return!1}});if(b)g=b.id;else{const v=m.replace(/^www\./,"").split(".")[0],ae=v.charAt(0).toUpperCase()+v.slice(1),{data:de}=await i.from("sites").insert({user_id:h,name:ae,base_url:`${y.protocol}//${m}`,priority:0,enabled:!0}).select("id").single();g=de?.id??null}}catch{}await i.from("title_sources").insert({title_id:a,site_id:g,url:t,is_primary:!1}),o.invalidateQueries({queryKey:["title-detail",a]}),o.invalidateQueries({queryKey:["titles"]}),O(!1),s("")}x.useEffect(()=>{let t=!1;const n=Math.random().toString(36).slice(2),h=setTimeout(()=>window.removeEventListener("message",g),3e3);function g(y){y.source===window&&y.data?.source==="readingtk-extension"&&y.data?.requestId===n&&(clearTimeout(h),window.removeEventListener("message",g),!t&&y.data.response&&I(y.data.response.auto_discover===!0))}return window.addEventListener("message",g),window.postMessage({source:"readingtk-web",requestId:n,payload:{type:"GET_STATUS"}},"*"),()=>{t=!0,clearTimeout(h),window.removeEventListener("message",g)}},[]);function k(t){f(t.id),C(t.url??""),M(t.last_seen_chapter??"")}async function S(){D&&(await i.from("title_sources").update({url:F.trim()||null,last_seen_chapter:X.trim()||null,last_error:null}).eq("id",D),f(null),o.invalidateQueries({queryKey:["title-detail",a]}),o.invalidateQueries({queryKey:["titles"]}))}x.useEffect(()=>{const t=i.channel(`rtk-drawer-${a}`).on("postgres_changes",{event:"*",schema:"public",table:"title_sources"},()=>{o.invalidateQueries({queryKey:["title-detail",a]})}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"titles"},()=>{o.invalidateQueries({queryKey:["title-detail",a]})}).subscribe();return()=>{i.removeChannel(t)}},[a,o]);const{data:d}=oe({queryKey:["title-detail",a],queryFn:async()=>{const[t,n,h,g]=await Promise.all([i.from("titles").select("*").eq("id",a).maybeSingle(),i.from("reading_progress").select("*").eq("title_id",a).maybeSingle(),i.from("title_sources").select("*, sites(name, base_url, priority)").eq("title_id",a),i.from("chapters").select("*, sites(name)").eq("title_id",a).order("detected_at",{ascending:!1}).limit(20)]);return{title:t.data,progress:n.data,sources:h.data??[],chapters:g.data??[]}}}),[p,V]=x.useState(""),z=d?.progress?.last_chapter_read??"";x.useEffect(()=>{z&&V(z)},[z]);const G=J({mutationFn:async t=>{const{error:n}=await i.from("reading_progress").upsert({title_id:a,last_chapter_read:t,last_read_at:new Date().toISOString()},{onConflict:"title_id"});if(n)throw n},onSuccess:()=>{T.success(r("drawer.progressSaved")),o.invalidateQueries({queryKey:["title-detail",a]}),o.invalidateQueries({queryKey:["titles"]})}}),Y=J({mutationFn:async t=>{const{error:n}=await i.from("titles").update({status:t}).eq("id",a);if(n)throw n},onSuccess:()=>{o.invalidateQueries({queryKey:["titles"]}),o.invalidateQueries({queryKey:["title-detail",a]})}}),K=J({mutationFn:async t=>{const n=d?.title?.type,h=d?.title?.type_locked,g=!(n===t&&h),{error:y}=await i.from("titles").update({type:t,type_locked:g}).eq("id",a);if(y)throw y},onSuccess:()=>{o.invalidateQueries({queryKey:["titles"]}),o.invalidateQueries({queryKey:["title-detail",a]})}}),se=J({mutationFn:async t=>{const{error:n}=await i.from("titles").update({name:t}).eq("id",a);if(n)throw n},onSuccess:()=>{o.invalidateQueries({queryKey:["titles"]}),o.invalidateQueries({queryKey:["title-detail",a]}),L(!1)},onError:()=>T.error(r("drawer.renameFail"))});function re(t){H(t),L(!0)}function ce(){const t=P.trim();t&&t!==d?.title?.name?se.mutate(t):L(!1)}async function pe(t){const n=t.trim()||null;if(!n)await i.from("titles").update({cover_url:null}).eq("id",a);else if(n.includes("supabase.co/storage"))await i.from("titles").update({cover_url:n}).eq("id",a);else{const{error:h}=await i.functions.invoke("cache-cover",{body:{imageUrl:n,titleId:a}});h&&await i.from("titles").update({cover_url:n}).eq("id",a)}o.invalidateQueries({queryKey:["title-detail",a]}),o.invalidateQueries({queryKey:["titles"]}),_(!1)}const _e=J({mutationFn:async()=>{const{error:t}=await i.from("titles").delete().eq("id",a);if(t)throw t},onSuccess:()=>{T.success(r("drawer.titleDeleted")),o.invalidateQueries({queryKey:["titles"]}),c()}});if(!d?.title)return null;const he=d.title.aliases??[];return e.jsx("div",{className:"pointer-events-none fixed inset-0 z-40 flex justify-end",children:e.jsxs("div",{className:"pointer-events-auto h-full w-full max-w-xl overflow-y-auto border-l border-border/60 bg-card p-6",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 min-w-0",children:[e.jsxs("div",{className:"shrink-0 flex flex-col gap-1.5",children:[e.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{R(d.title.cover_url??""),_(t=>!t)},title:r("drawer.editCover"),children:[d.title.cover_url?e.jsx("img",{src:d.title.cover_url,alt:"",className:"h-28 w-20 rounded-lg object-cover object-top shadow-md"}):e.jsx("div",{className:"h-28 w-20 rounded-lg bg-secondary/60 flex items-center justify-center",children:e.jsx(fe,{className:"h-6 w-6 text-muted-foreground
1/40"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-lg bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(fe,{className:"h-5 w-5 text-white"})})]}),ee&&e.jsxs("div",{className:"flex flex-col gap-1",onClick:t=>t.stopPropagation(),children:[e.jsx("input",{autoFocus:!0,type:"url",value:W,onChange:t=>R(t.target.value),onKeyDown:t=>{t.key==="Enter"&&pe(W),t.key==="Escape"&&_(!1)},placeholder:"https://...",className:"w-20 rounded border border-input bg-input/50 px-1.5 py-1 text-[10px] outline-none focus:border-accent"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>pe(W),title:r("drawer.saveCover"),className:"flex-1 rounded bg-accent/20 px-1 py-0.5 text-[10px] text-accent hover:bg-accent/30 transition",children:e.jsx(ne,{className:"mx-auto h-3 w-3"})}),e.jsx("button",{onClick:()=>_(!1),title:r("common.cancel"),className:"flex-1 rounded bg-secondary/60 px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-secondary transition",children:e.jsx(ue,{className:"mx-auto h-3 w-3"})})]})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:d.title.type?ie(r,d.title.type):r("drawer.titleFallback")}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[B?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{autoFocus:!0,value:P,onChange:t=>H(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ce(),t.key==="Escape"&&L(!1)},onBlur:ce,className:"rounded-md border border-accent bg-background px-2 py-1 text-xl font-bold outline-none"}),e.jsx("button",{onClick:ce,title:r("drawer.confirmRename"),className:"rounded p-1 text-accent hover:bg-accent/10",children:e.jsx(ne,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("h2",{className:"text-2xl font-bold leading-tight",children:d.title.name}),e.jsx("button",{onClick:()=>re(d.title.name),title:r("drawer.renameTitle"),className:"shrink-0 rounded-md p-1.5 text-muted-foreground hover:bg-accent/10 hover:text-accent transition",children:e.jsx(me,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{title:r(j?Q==="windows"?"drawer.scrapingWindows":"drawer.scrapingExtension":"drawer.scrapeNow"),disabled:j,onClick:async t=>{t.stopPropagation(),w(!0),q("windows");try{const n=await Pe(a,$);if(n.status==="done")T.success(r("drawer.scrapeDone")),o.invalidateQueries({queryKey:["title-detail",a]}),o.invalidateQueries({queryKey:["titles"]});else if(n.status==="error")T.error(r("drawer.scrapeError",{message:n.message}));else{q("extension");const h=await ye({type:"CHECK_TITLE_NOW",titleId:a,autoDiscover:$});h?.error?T.error(h.error==="Extension non disponible"?r("drawer.extUnavailable"):String(h.error)):(T.success(r("drawer.scrapeDone")),o.invalidateQueries({queryKey:["title-detail",a]}),o.invalidateQueries({queryKey:["titles"]}))}}finally{w(!1),q(null)}},className:"shrink-0 rounded-md p-1.5 text-muted-foreground hover:bg-accent/10 hover:text-accent transition disabled:opacity-40",children:e.jsx(je,{className:`h-4 w-4 ${j?"animate-spin":""}`})}),e.jsx("button",{type:"button",title:r("drawer.autoDiscover"),onClick:async()=>{const t=!$;I(t),await ye({type:"SET_AUTO_DISCOVER",enabled:t})},className:`shrink-0 rounded-md px-1.5 py-0.5 text-[10px] font-medium transition border ${$?"border-accent bg-accent/20 text-accent":"border-border text-muted-foreground hover:border-accent/60 hover:text-foreground"}`,children:r("drawer.autoDiscover")})]})]}),he.length>0&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:he.map((t,n)=>e.jsx("span",{className:"rounded-full bg-secondary/60 px-2 py-0.5 text-xs text-muted-foreground",children:t},n))})]})]}),e.jsx("button",{onClick:c,title:r("common.close"),className:"shrink-0 rounded-md p-1 hover:bg-accent/10",children:e.jsx(ue,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:r("drawer.lastRead")}
1),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("button",{onClick:()=>{const t=parseFloat(p)||0,n=String(Math.max(0,parseFloat((t-1).toFixed(2))));V(n),G.mutate(n)},className:"rounded-md border border-input bg-secondary/60 px-3 text-sm font-semibold text-muted-foreground hover:bg-secondary hover:text-foreground transition",children:"−1"}),e.jsx("input",{value:p,onChange:t=>V(t.target.value),className:"w-0 flex-1 rounded-md border border-input bg-input/50 px-3 py-2 text-center text-sm"}),e.jsx("button",{onClick:()=>{const t=parseFloat(p)||0,n=String(parseFloat((t+1).toFixed(2)));V(n),G.mutate(n)},className:"rounded-md border border-input bg-secondary/60 px-3 text-sm font-semibold text-muted-foreground hover:bg-secondary hover:text-foreground transition",children:"+1"}),e.jsx("button",{onClick:()=>G.mutate(p),className:"rounded-md px-4 text-sm font-medium text-primary-foreground",style:{background:"var(--gradient-primary)"},children:r("common.save")})]})]}),e.jsxs("div",{className:"mt-6 flex gap-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:[r("filter.type"),d.title?.type_locked&&e.jsx("span",{className:"ml-1.5 text-[10px] text-muted-foreground/60",children:r("drawer.typeLocked")})]}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:["manga","manhua","manhwa","novel","autre"].map(t=>e.jsx("button",{onClick:()=>K.mutate(t),title:d.title?.type===t&&d.title?.type_locked?r("drawer.typeUnlock"):void 0,className:`rounded-full px-3 py-1 text-xs ${d.title?.type===t?"bg-accent text-accent-foreground":"bg-secondary/60 text-muted-foreground hover:bg-secondary"}`,children:ie(r,t)},t))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:r("filter.status")}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:["ongoing","paused","dropped","completed"].map(t=>e.jsx("button",{onClick:()=>Y.mutate(t),className:`rounded-full px-3 py-1 text-xs ${d.title?.status===t?"bg-accent text-accent-foreground":"bg-secondary/60 text-muted-foreground hover:bg-secondary"}`,children:xe(r,t)},t))})]})]}),e.jsx("div",{className:"mt-8",children:(()=>{const t=d.sources.filter(m=>m.last_seen_chapter).map(m=>({source:m,num:parseFloat(m.last_seen_chapter)})).filter(m=>!isNaN(m.num));if(t.length===0)return e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:r("drawer.detectedTitle")}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:r("drawer.detectedNone")})]});const n=Math.max(...t.map(m=>m.num)),h=String(n),g=new RegExp(`(?:chapter|chap|ch|episode|ep)[-_/]?${n}(?:[^0-9]|$)`,"i"),y=d.sources.map(m=>{const b=d.chapters.find(v=>v.site_id===m.site_id&&(v.chapter_label===h||g.test(v.chapter_url??"")));return b?.chapter_url?{chapId:b.id,sourceId:m.id,siteName:m.sites?.name??"Source",url:b.chapter_url}:null}).filter(m=>m!==null);return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:Z?e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-sm font-semibold shrink-0",children:r("drawer.detectedPrefix")}),e.jsx("input",{type:"number",className:"w-24 rounded border border-border bg-background px-2 py-0.5 text-sm text-accent",value:U,onChange:m=>E(m.target.value),onKeyDown:async m=>{if(m.key==="Enter"){const b=U.trim()||null;await i.from("title_sources").update({last_seen_chapter:b}).in("id",t.map(v=>v.source.id).filter(v=>{const ae=t.find(de=>de.source.id===v);return ae&&ae.num===n})),N(!1),o.invalidateQueries({queryKey:["title-detail",a]}),o.invalidateQueries({queryKey:["titles"]})}m.key==="Escape"&&N(!1)},autoFocus:!0}),e.jsx("button",{onClick:async()=>{const m=U.trim()||null;await i.from("title_sources").update({last_seen_chapter:m}).in("id",t.filter(b=>b.num===n).map(b=>b.source.id)),N(!1),o.invalidateQueries({queryKey:["title-detail",a]}),o.invalidateQueries({queryKey:["titles"]})},title:r("drawer.confirmDetected"),className:"rounded p-1 text-xs text-accent hover:bg-secondary/60 transition font-semibold",children:"✓"}),e.jsx("button",{onClick:()=>N(!1),title:r("common.cancel"),className:"rounded p-1 text-xs text-muted-foreground hover:bg-secondary/60 transition",children:"✕"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"text-sm font-semibold",children:[r("drawer.detectedPrefix"),e.jsx("span",{className:"text-accent",children:h})]}),e.jsx("button",{onClick:()=>{E(h),N(!0)},title:r("drawer.editDetected"),className:"rounded p-1 text-muted-foreground hover:bg-secondary/60 hover:text-foreground transition",children:e.jsx(me,{className:"h-3 w-3"})}),e.jsx("a",{href:`https://www.google.com/search?q=${encodeURIComponent(d.title.name+" "+h)}`,target:"_blank",rel:"noreferrer",title:r("drawer.googleSearchChap"),className:"rounded p-1 text-muted-foreground hover:bg-secondary/60 hover:text-foreground transition",children:e.jsx("svg",{viewBox:"0 0 24 24",className:"h-3.5 w-3.5",fill:"currentColor",children:e.jsx("path",{d:"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4
1-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"})})})]})}),e.jsx("div",{className:"mt-2 space-y-1",children:y.map(m=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("a",{href:m.url,target:"_blank",rel:"noopener noreferrer",className:"flex min-w-0 flex-1 items-center gap-1.5 text-xs text-accent hover:underline break-all",children:[e.jsx(De,{className:"shrink-0",style:{width:11,height:11}}),e.jsxs("span",{children:[m.siteName," — ",m.url]})]}),e.jsx("button",{title:r("drawer.deleteChapter"),onClick:async b=>{b.preventDefault(),await i.from("chapters").delete().eq("id",m.chapId),await i.from("title_sources").update({last_seen_chapter:null}).eq("id",m.sourceId).eq("last_seen_chapter",h),o.invalidateQueries({queryKey:["title-detail",a]}),o.invalidateQueries({queryKey:["titles"]})},className:"shrink-0 rounded p-1 text-destructive/50 hover:text-destructive hover:bg-destructive/10 transition",children:e.jsx(ge,{className:"h-3 w-3"})})]},m.chapId))})]})})()}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:r("drawer.sources",{n:d.sources.length})}),e.jsx("button",{onClick:()=>{O(t=>!t),s("")},title:r("drawer.addSource"),className:"rounded p-1 text-muted-foreground hover:bg-accent/10 hover:text-accent transition",children:e.jsx(Ne,{className:"h-3.5 w-3.5"})}),e.jsx("a",{href:`https://www.google.com/search?q=${encodeURIComponent(d.title.name+" scan")}`,target:"_blank",rel:"noreferrer",title:r("drawer.googleSearch"),className:"rounded p-1 text-muted-foreground hover:bg-secondary/60 hover:text-foreground transition",children:e.jsx("svg",{viewBox:"0 0 24 24",className:"h-3.5 w-3.5",fill:"currentColor",children:e.jsx("path",{d:"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"})})})]}),A&&e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("input",{autoFocus:!0,t
1ype:"url",value:te,onChange:t=>s(t.target.value),onKeyDown:t=>{t.key==="Enter"&&u(),t.key==="Escape"&&O(!1)},placeholder:"https://...",className:"min-w-0 flex-1 rounded-md border border-input bg-input/50 px-3 py-1.5 font-mono text-xs outline-none focus:border-accent"}),e.jsx("button",{onClick:u,title:r("drawer.confirmSource"),className:"rounded-md bg-accent/20 px-2 py-1.5 text-accent hover:bg-accent/30 transition",children:e.jsx(ne,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>O(!1),title:r("common.cancel"),className:"rounded-md bg-secondary/60 px-2 py-1.5 text-muted-foreground hover:bg-secondary transition",children:e.jsx(ue,{className:"h-3.5 w-3.5"})})]}),e.jsxs("ul",{className:"mt-2 space-y-2",children:[[...d.sources].sort((t,n)=>{const h=t.sites?.priority??0;return(n.sites?.priority??0)-h}).map(t=>{const n=t.last_error,h=t.sites?.priority??0,g=n==="404",y=n==="redirect",m=g||y,b=t.sites?.name??"Source";return D===t.id?e.jsxs("li",{className:"rounded-md border border-accent/40 bg-accent/5 p-3 text-xs space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-accent",children:b}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-semibold ${h>0?"bg-accent/20 text-accent":"bg-secondary/60 text-muted-foreground"}`,children:r("drawer.priority",{n:h})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-muted-foreground",children:r("drawer.link")}),e.jsx("input",{value:F,onChange:v=>C(v.target.value),className:"mt-1 w-full rounded border border-input bg-input/50 px-2 py-1 text-xs font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-muted-foreground",children:r("drawer.lastDetected")}),e.jsx("input",{value:X,onChange:v=>M(v.target.value),placeholder:r("drawer.lastDetectedPh"),className:"mt-1 w-full rounded border border-input bg-input/50 px-2 py-1 text-xs"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:()=>f(null),className:"rounded px-3 py-1 text-muted-foreground hover:bg-secondary/60 transition",children:r("common.cancel")}),e.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 rounded px-3 py-1 font-medium text-primary-foreground transition",style:{background:"var(--gradient-primary)"},children:[e.jsx(ne,{className:"h-3 w-3"})," ",r("common.save")]})]})]},t.id):e.jsxs("li",{className:`rounded-md border p-3 text-xs ${g?"border-destructive/40 bg-destructive/5":y?"border-orange-500/30 bg-
1orange-500/5":"border-border/60 bg-secondary/30"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-medium",children:b}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-semibold ${h>0?"bg-accent/20 text-accent":"bg-secondary/60 text-muted-foreground"}`,children:r("drawer.priority",{n:h})}),g&&e.jsxs("span",{className:"rounded-full bg-destructive/20 px-2 py-0.5 text-[10px] font-semibold text-destructive",children:["⬤ ",r("drawer.down")]}),y&&e.jsxs("span",{className:"rounded-full bg-orange-500/20 px-2 py-0.5 text-[10px] font-semibold text-orange-400",children:["↪ ",r("drawer.redirected")]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx("button",{title:r("drawer.editSource"),onClick:()=>k(t),className:"rounded p-1 text-muted-foreground/50 hover:text-foreground hover:bg-secondary/60 transition",children:e.jsx(me,{className:"h-3.5 w-3.5"})}),e.jsx("button",{title:r("drawer.deleteSource"),onClick:async()=>{confirm(r("drawer.confirmDeleteSource"))&&(await i.from("title_sources").delete().eq("id",t.id),o.invalidateQueries({queryKey:["title-detail",a]}),o.invalidateQueries({queryKey:["titles"]}))},className:"rounded p-1 text-destructive/50 hover:text-destructive hover:bg-destructive/10 transition",children:e.jsx(ge,{className:"h-3.5 w-3.5"})})]})]}),e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"mt-1 block truncate text-accent hover:underline",children:t.url}),t.last_seen_chapter&&!m&&e.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-muted-foreground",children:[e.jsx("span",{children:r("drawer.lastDetectedColon",{n:t.last_seen_chapter})}),e.jsx("a",{href:`https://www.google.com/search?q=${encodeURIComponent(d.title.name+" "+t.last_seen_chapter)}`,target:"_blank",rel:"noreferrer",title:r("drawer.googleSearchChap"),className:"rounded p-0.5 hover:bg-secondary/60 hover:text-foreground transition",children:e.jsx("svg",{viewBox:"0 0 24 24",className:"h-3 w-3",fill:"currentColor",children:e.jsx("path",{d:"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"})})})]})]},t.id)}),d.sources.length===0&&e.jsx("li",{className:"text-xs text-muted-foreground",children:r("drawer.noSources")})]})]}),e.jsx("div",{className:"mt-10 border-t border-border/40 pt-4",children:e.jsx("button",{onClick:()=>{confirm(r("drawer.confirmDeleteTitle"))&&_e.mutate()},className:"text-xs text-destructive hover:underline",children:r("drawer.deleteTitleBtn")})})]})})}export{He as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.