1import{r as l,j as e,A as P,m as U}from"./animation-CddyXVCz.js";import{P as S}from"./PageWrapper-C3-XQErc.js";import{D as re,m as le,F as ie,u as ne,p as de,cs as z,L as oe,h as i,S as H,B as y,af as O,r as I,q as ce,bm as W,bD as V,bl as J,bX as me,bp as xe,w as pe,a3 as Z}from"./index-DnWsV7cE.js";import{c as he}from"./clipboard-C0L7pyCw.js";import{d as $}from"./htmlEntities-97NJt3YN.js";import{g as ue}from"./scoreSeverity-CZDyLV63.js";import"./react-vendor-CbN3pvl2.js";import"./billingLimits-4ln6JCGI.js";import"./supabase-iKSPld20.js";import"./docgen-Bp8WKBAE.js";import"./query-DPqpbKNH.js";const q=24,k=5,G=c=>new Date(c).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),f=c=>c.tailored_match_score??c.original_match_score??0,Re=()=>{var B;const c=re(),{session:n}=le(),{usage:x}=ie(),{toast:p}=ne(),[h,w]=l.useState([]),[u,j]=l.useState(null),[X,_]=l.useState(!0),[C,A]=l.useState(!1),[L,R]=l.useState(!0),[v,Y]=l.useState("date"),[b,K]=l.useState("all"),[g,Q]=l.useState("all"),[M,T]=l.useState(null);de({title:"Resume Library | CareerDiary",description:"Browse all your tailored resumes in one place.",canonical:"https://careerdiary.io/app/resume-library"}),l.useEffect(()=>{var r;const a=(r=n==null?void 0:n.user)==null?void 0:r.id;if(!a){w([]),R(!1),_(!1);return}let s=!0;return _(!0),z(a,q,0).then(({resumes:o,hasMore:N})=>{s&&(w(o),R(N),j(te=>{var D;return te||((D=o[0])==null?void 0:D.id)||null}))}).catch(o=>{console.error("Failed to load tailored resumes:",o),s&&p.error("Resume library unavailable","Could not load your saved tailored resumes.")}).finally(()=>{s&&_(!1)}),()=>{s=!1}},[(B=n==null?void 0:n.user)==null?void 0:B.id,p]);const ee=async()=>{var s;const a=(s=n==null?void 0:n.user)==null?void 0:s.id;if(!(!a||!L||C)){A(!0);try{const{resumes:r,hasMore:o}=await z(a,q,h.length);w(N=>[...N,...r]),R(o)}catch(r){console.error("Failed to load more tailored resumes:",r),p.error("Resume library unavailable","Could not load more tailored resumes.")}finally{A(!1)}}},d=l.useMemo(()=>x.tier==="signed_in"?h.slice(0,k):h,[h,x.tier]),E=x.tier==="signed_in"&&h.length>=k,ae=l.useMemo(()=>Array.from(new Set(d.map(a=>a.company_name).filter(Boolean))).sort((a,s)=>a.localeCompare(s)),[d]),m=l.useMemo(()=>d.filter(s=>{const r=b==="all"||s.company_name===b,o=!!s.applied_job_id;return r&&(g==="all"||g==="applied"&&o||g==="unapplied"&&!o)}).sort((s,r)=>v==="company"?s.company_name.localeCompare(r.company_name)||r.created_at.localeCompare(s.created_at):v==="score"&&f(r)-f(s)||r.created_at.localeCompare(s.created_at)),[g,b,v,d]);l.useEffect(()=>{if(!m.length){j(null);return}m.some(s=>s.id===u)||j(m[0].id)},[m,u]);const t=m.find(a=>a.id===u)||d.find(a=>a.id===u)||null,se=d.filter(a=>!!a.applied_job_id).length,F=async a=>{try{await he(a.tailored_resume),T(a.id),p.success("Resume copied","The tailored resume text is on your clipboard."),window.setTimeout(()=>{T(s=>s===a.id?null:s)},2e3)}catch(s){console.error("Failed to copy resume:",s),p.error("Copy failed","Could not copy the tailored resume text.")}};return X?e.jsx(S,{title:"Resume Library",description:"Loading your tailored resumes...",maxWidth:"full",children:e.jsx("div",{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(oe,{})})}):d.length?e.jsxs(S,{title:"Resume Library",description:"All your tailored resumes in one place â saved or not.",maxWidth:"full",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsx(i,{variant:"glass",className:"bg-gradient-to-br from-sky-500/12 via-white to-white dark:from-sky-500/10 dark:via-slate-900 dark:to-slate-900",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.2em] text-sky-600 dark:text-sky-300",children:"Total Resumes"}),e.jsxs("p",{className:"mt-3 text-3xl font-bold text-[var(--text-primary)]",children:[d.length,x.tier==="signed_in"&&e.jsxs("span",{className:"text-base font-medium text-[var(--text-secondary)]",children:[" / ",k]}),x.tier==="paid"&&e.jsx("span",{className:"text-base font-medium text-[var(--text-secondary)]",children:" / â"})]})]}),e.jsx(O,{className:"h-8 w-8 text-sky-500"})]})}),e.jsx(i,{variant:"glass",className:"bg-gradient-to-br from-emerald-500/12 via-white to-w
1hite dark:from-emerald-500/10 dark:via-slate-900 dark:to-slate-900",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.2em] text-emerald-600 dark:text-emerald-300",children:"Linked Applications"}),e.jsx("p",{className:"mt-3 text-3xl font-bold text-[var(--text-primary)]",children:se})]}),e.jsx(I,{className:"h-8 w-8 text-emerald-500"})]})}),e.jsx(i,{variant:"glass",className:"bg-gradient-to-br from-amber-500/12 via-white to-white dark:from-amber-500/10 dark:via-slate-900 dark:to-slate-900",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.2em] text-amber-600 dark:text-amber-300",children:"Top Match Score"}),e.jsxs("p",{className:"mt-3 text-3xl font-bold text-[var(--text-primary)]",children:[Math.max(...d.map(a=>f(a))),"%"]})]}),e.jsx(ce,{className:"h-8 w-8 text-amber-500"})]})})]}),E&&e.jsx(i,{variant:"glass",className:"border border-emerald-200/70 bg-gradient-to-r from-emerald-500/10 via-white to-blue-500/10 dark:border-emerald-900/40 dark:from-emerald-900/20 dark:via-slate-900 dark:to-blue-900/20",children:e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-primary)]",children:"Free plan limit reached"}),e.jsxs("p",{className:"mt-1 text-sm text-[var(--text-secondary)]",children:["Free accounts see their ",k," most recent resumes here. Every tailor is still saved; upgrade to Pro to see them all."]})]}),e.jsx(y,{type:"button",variant:"primary",onClick:()=>c("/app/settings/billing"),children:"Upgrade to Pro"})]})}),e.jsx(i,{variant:"glass",className:"border border-[var(--border-default)]/70",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-primary)]",children:"Filter and sort"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--text-secondary)]",children:"Narrow the library by company, application status, or match strength."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm text-[var(--text-secondary)]",children:[e.jsx("span",{children:"Company"}),e.jsxs("select",{value:b,onChange:a=>K(a.target.value),className:"rounded-xl border border-[var(--border-default)] bg-[var(--bg-secondary)] px-3 py-2 text-[var(--text-primary)]",children:[e.jsx("option",{value:"all",children:"All companies"}),ae.map(a=>e.jsx("option",{value:a,children:a},a))]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm text-[var(--text-secondary)]",children:[e.jsx("span",{children:"Status"}),e.jsxs("select",{value:g,onChange:a=>Q(a.target.value),className:"rounded-xl border border-[var(--border-default)] bg-[var(--bg-secondary)] px-3 py-2 text-[var(--text-primary)]",children:[e.jsx("option",{value:"all",children:"All resumes"}),e.jsx("option",{value:"applied",children:"Linked to application"}),e.jsx("option",{value:"unapplied",children:"Not linked"})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm text-[var(--text-secondary)]",children:[e.jsx("span",{children:"Sort"}),e.jsxs("select",{value:v,onChange:a=>Y(a.target.value),className:"rounded-xl border border-[var(--border-default)] bg-[var(--bg-secondary)] px-3 py-2 text-[var(--text-primary)]",children:[e.jsx("option",{value:"date",children:"Newest first"}),e.jsx("option",{value:"company",children:"Company A-Z"}),e.jsx("option",{value:"score",children:"Highest match score"})]})]})]})]})}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[360px,minmax(0,1fr)]",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{initial:!1,children:m.map((a,s)=>{const r=a.id===u;return e.jsxs(U.button,{type:"button",layout:!0,initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2,delay:s*.03},onClick:()=>j(a.id),className:`w-full rounded-3xl border p-5 text-left transition-all ${r?"border-sky-400 bg-sky-500/10 shadow-lg shadow-sky-500/10":"border-[var(--border-default)] bg-[var(--bg-secondary)] hover:border-sky-300 hover:bg-sky-500/5"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:W($(V(a.job_title)))}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3 text-sm text-[var(--text-secondary)]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(me,{className:"h-4 w-4"}),J(a.company_name)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(xe,{className:"h-4 w-4"}),G(a.created_at)]})]})]}),e.jsxs("div",{className:`rounded-2xl px-3 py-2 text-right ${ue(f(a))}`,children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] opacity-70",children:"Match"}),e.jsxs("div",{className:"text-xl font-bold",children:[f(a),"%"]})]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[a.applied_job_id?e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full bg-emerald-500/12 px-3 py-1 text-xs font-semibold text-emerald-700 dark:text-emerald-300",children:[e.jsx(I,{className:"h-4 w-4"}),"Applied"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full bg-slate-500/12 px-3 py-1 text-xs font-semibold text-slate-600 dar
1k:text-slate-300",children:[e.jsx(pe,{className:"h-4 w-4"}),"Draft only"]}),e.jsxs("span",{className:"rounded-full bg-[var(--bg-tertiary)] px-3 py-1 text-xs font-medium text-[var(--text-secondary)]",children:[a.page_count," page",a.page_count===1?"":"s"]})]})]},a.id)})}),L&&!E&&e.jsx(y,{onClick:ee,disabled:C,variant:"secondary",size:"md",className:"w-full mt-4",children:C?"Loading more...":"Load more resumes"})]}),e.jsx(P,{mode:"wait",children:t?e.jsxs(U.div,{initial:{opacity:0,x:18},animate:{opacity:1,x:0},exit:{opacity:0,x:-18},transition:{duration:.22},className:"space-y-6",children:[e.jsx(i,{variant:"glass",className:"overflow-hidden border border-[var(--border-default)]/70 bg-gradient-to-br from-white via-sky-500/6 to-emerald-500/6 dark:from-slate-900 dark:via-sky-500/10 dark:to-emerald-500/10",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full bg-sky-500/10 px-3 py-1 text-xs font-semibold uppercase tracking-[0.18em] text-sky-700 dark:text-sky-300",children:[e.jsx(O,{className:"h-4 w-4"}),"Tailored Resume"]}),t.applied_job_id&&e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full bg-emerald-500/12 px-3 py-1 text-xs font-semibold text-emerald-700 dark:text-emerald-300",children:[e.jsx(I,{className:"h-4 w-4"}),"Linked to application"]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-[var(--text-primary)]",children:W($(V(t.job_title)))}),e.jsxs("p",{className:"mt-2 text-base text-[var(--text-secondary)]",children:[J(t.company_name)," on ",G(t.created_at)]})]})]}),e.jsx(y,{onClick:()=>F(t),variant:"primary",size:"md",leftIcon:e.jsx(Z,{className:"h-4 w-4"}),className:"h-auto rounded-2xl px-5 py-3",children:M===t.id?"Copied":"Copy Resume"})]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(i,{variant:"glass",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold uppercase tracking-[0.16em] text-[var(--text-secondary)]",children:"Score Comparison"}),e.jsx("h3",{className:"mt-2 text-xl font-semibold text-[var(--text-primary)]",children:"Before vs tailored"})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-500/10 px-3 py-2 text-sm font-semibold text-emerald-700 dark:text-emerald-300",children:["+",Math.max(0,(t.tailored_match_score??0)-(t.original_match_score??0))," pts"]})]}),e.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-2xl bg-[var(--bg-tertiary)] p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.18em] text-[var(--text-secondary)]",children:"Original"}),e.jsxs("p",{className:"mt-3 text-3xl font-bold text-[var(--text-primary)]",children:[t.original_match_score??0,"%"]})]}),e.jsxs("div",{className:"rounded-2xl bg-sky-500/10 p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.18em] text-sky-700 dark:text-sky-300",children:"Tailored"}),e.jsxs("p",{className:"mt-3 text-3xl font-bold text-[var(--text-primary)]",children:[t.tailored_match_score??0,"%"]})]})]}),t.match_justification&&e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--text-secondary)]",children:t.match_justification})]}),e.jsxs(i,{variant:"glass",children:[e.jsx("p",{className:"text-sm font-semibold uppercase tracking-[0.16em] text-[var(--text-secondary)]",children:"Change Summary"}),e.jsx("div",{className:"mt-4 rounded-2xl bg-[var(--bg-tertiary)] p-4",children:e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-6 text-[var(--text-primary)]",children:t.change_summary||"No change summary was captured for this resume."})})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(i,{variant:"glass",children:[e.jsx("p",{className:"text-sm font-semibold uppercase tracking-[0.16em] text-[var(--text-secondary)]",children:"Matching Skills"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:t.matching_skills.length?t.matching_skills.map(a=>e.jsx("span",{className:"rounded-full bg-emerald-500/12 px-3 py-2 text-sm font-medium text-emerald-700 dark:text-emerald-300",children:a},a)):e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No explicit matching skills were extracted for this resume."})})]}),e.jsxs(i,{variant:"glass",children:[e.jsx("p",{className:"text-sm font-semibold uppercase tracking-[0.16em] text-[var(--text-secondary)]",children:"Missing Skills"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:t.missing_skills.length?t.missing_skills.map(a=>e.jsx("span",{className:"rounded-full bg-amber-500/12 px-3 py-2 text-sm font-medium text-amber-700 dark:text-amber-300",children:a},a)):e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"This resume covered the extracted job skills with no obvious gaps."})})]})]}),e.jsxs(i,{variant:"glass",children:[e.jsx("p",{className:"text-sm font-semibold uppercase tracking-[0.16em] text-[var(--text-secondary)]",children:"Job Description"}),e.jsx("div",{className:"mt-4 max-h-[240px] overflow-auto rounded-2xl bg-[var(--bg-tertiary)] p-4",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm leading-6 text-[var(--text-primary)]",children:t.job_description})})]}),e.jsxs(i,{variant:"glass",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("p",{className:"text-sm font-semibold uppercase tracking-[0.16em] text-[var(--text-secondary)]",children:"Resume Text"}),e.jsx(y,{onClick:()=>F(t),variant:"secondary",size:"sm",leftIcon:e.jsx(Z,{className:"h-4 w-4"}),children:M===t.id?"Copied":"Copy Text"})]}),e.jsx("div",{className:"mt-4 max-h-[720px] overflow-auto rounded-2xl bg-[var(--bg-tertiary)] p-5",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm leading-6 text-[var(--text-primary)]",children:t.tailored_resume})})]})]},t.id):e.jsx(i,{variant:"glass",className:"flex min-h-[280px] items-center justify-center",children:e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No resumes match the current filters."})})})]})]}):e.jsx(S,{title:"Resume Library",description:"All your tailored resumes in one place â saved or not.",maxWidth:"4xl",children:e.jsx(i,{variant:"glass",className:"overflow-hidden bg-gradient-to-br from-sky-500/12 via-white to-emerald-500/8 dark:from-sky-500/10 dark:via-slate-900 dark:to-emerald-500/10",children:e.jsxs("div",{className:"flex flex-col items-start gap-6 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-white/80 px-3 py-1 text-xs font-semibold uppercase tracking-[0.24em] text-sky-700 dark:bg-slate-900/80 dark:text-sky-300",children:[e.jsx(H,{className:"h-4 w-4"}),"Auto-saved tailoring"]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-[var(--text-primary)]",children:"No tailored resumes yet"}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm text-[var(--text-secondary)]",children:"Tailor a resume once and it will appear here, even if you close the page before saving an application."})]})]}),e.jsx(y,{onClick:()=>c("/app/tailor"),variant:"primary",size:"lg",leftIcon:e.jsx(H,{className:"h-4 w-4"}),className:"h-auto rounded-2xl px-6 py-3",children:"Tailor A Resume"})]})})})};export{Re as ResumeLibraryPage};
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.