1import{il as es,im as ts,io as xt,ip as Yt,iq as as,ir as ss,aK as T,bi as Ge,hs as ze,hp as Ce,gr as ue,is as da,it as rs,c as me,a as pe,b as fe,aV as ce,bf as je,iu as ns,iv as is,r as c,bB as Te,by as ua,aU as os,bC as ls,fE as cs,iw as ds,j as e,Z as ma,_ as us,a1 as ms,ag as yt,dA as ps,B as S,ix as pa,cq as Ye,dJ as fs,eC as hs,a7 as De,$ as xs,e5 as fa,gD as ha,iy as ys,iz as gs,iA as vs,iB as js,U as Ht,iC as Vt,ho as bs,g7 as xa,aJ as Ee,cu as ws,cc as Ns,L as gt,fZ as Qe,be as lt,iD as ks,iE as _s,iF as Ss,iG as Es,iH as As,iI as ct,iJ as Cs}from"./main-DmDsGTCr.js";import{u as le}from"./useMutation-BXaTcy4a.js";import{u as He}from"./paywall-context-FiGeElF6.js";import{t as ya,s as Rs}from"./adapt-BCOCNVmC.js";import{l as kt,C as Ts,i as qe,D as Ve}from"./mutations-C3e5yzYL.js";import{a as Fs,b as Ls,e as Xt,r as Ps}from"./apply-materials-download-CqhoCjRT.js";import{t as ae}from"./product-events-DE71XA68.js";import{u as ga,a as va}from"./use-feature-flag-C9iVprKR.js";import{a as Os}from"./extension-presence-hEP74lNh.js";import{w as qs}from"./job-key-DMLilZWY.js";import{e as Is,f as Ms,g as Ds,a as ja,b as Ks,c as Us,p as $s,h as zs,d as Qs}from"./mutations-tailored-edits-CAoQUphQ.js";import{h as Bs,b as Ws,e as Gs}from"./resume-content-_LE5NXxL.js";import{g as ba,r as Ys,a as Hs}from"./student-endpoints-BEkq0l27.js";import{R as Vs,a as Xs}from"./resume-import-context-DLBgXRZm.js";import{C as Zs,L as Js,a as Fe}from"./LockedTeaser-DXr-aCpS.js";import{C as er,t as tr,a as ar,c as sr}
1from"./ConnectModal-rOGC_tRZ.js";import{B as wa}from"./BecomeMemberButton-BvNe_a0M.js";import{D as _t}from"./DualArcSpinner-D4HRp4ig.js";import{a as Xe,b as Ze,c as vt,d as Na,e as rr,I as jt,f as dt,g as nr,h as ka,D as Zt,i as Jt}from"./ApplyActionButtons-5CTvJApx.js";import{C as Le}from"./check-7NZig2Tr.js";import{D as We}from"./download-Dde7N_q0.js";import{L as _a}from"./lock-CGVUhhnO.js";import{u as ir}from"./use-focus-trap-fahQvZeG.js";import{t as or}from"./download-bytes-B2Oq-Kfk.js";import{A as lr}from"./AgentStatus-u6-y9Vm-.js";import{j as cr,S as dr}from"./tracker-wJyy_6Q9.js";import{C as ur}from"./CompanyTile-CuIY9V5A.js";import{J as mr,d as pr}from"./JobDescriptionParagraphs-ieu3-BUz.js";import{M as fr}from"./map-pin-B__cyDn6.js";import{c as Sa,u as hr,f as xr,b as yr}from"./useSaveStandardAnswer-CwHXXTeu.js";import{s as gr}from"./extension-grant-contract-BXIAzKIF.js";import{n as vr}from"./normalize-apply-url-DxBqEC_k.js";import{m as jr,p as br,a as wr,S as Nr}from"./StandardAnswersFields-DCxSOh0y.js";import{M as kr}from"./mail-C39XquGB.js";import{C as _r}from"./copy-Dpj_eCG9.js";import{c as ut,h as Sr,A as Er}from"./AssistedApplyForm-DZDFGMjr.js";import{p as Ar,R as St,t as Cr}from"./ResumeDoc-DL8nnXHV.js";import"./track-jobs-abkNLz1q.js";import"./payload-validation-C-pMPr5Y.js";import"./formatPostedDate-BIv3w0xj.js";import"./network-signals-DBWnfbiK.js";import"./contact-avatar-BEWrB8Ci.js";import"./contact-name-B6ClW-dU.js";import"./dialog-CHuX4MUN.js";import"./index-H3pqt8Mq.js";import"./index-BT86mV_3.js";import"./building-2-Iybo88u-.js";import"./ask-intents-ClDgwFgj.js";import"./relevance-reasons-CLXthtJX.js";import"./MailReplyModal-D3oZJ15u.js";import"./textarea-DJtBLUuE.js";import"./triangle-alert-C4NPl7AO.js";import"./send-DKb2GXmz.js";import"./PageHeader-BybPPbxT.js";import"./dropdown-menu-gvtbf2CI.js";import"./index-DO-c3b5w.js";import"./job-status-badge-9sg9VAMG.js";import"./sheet-D9lkfEB6.js";import"./chevron-up-H5KsCNn5.js";import"./index-B2BwbHwT.js";import"./list-BCcRu_TZ.js";import"./SkeletonBar-CHkUsZZ6.js";import"./use-track-component-viewed-YUSuVzA1.js";import"./anchors-CdYSl11c.js";import"./standard-questions-CVX3_8hm.js";import"./popover-CU_Nu5OD.js";import"./EditableText-VUXPj7sO.js";import"./refresh-cw-BR9kNEv1.js";const bt={ats:0,employer:1,unknown:2,aggregator:3,ats_api:4,invalid:5},Rr=new Set(["learn4good.com","appcast.io","joinhandshake.com","tiptopjob.com","diversityjobs.com","barefootstudent.com","internsg.com","ziprecruiter.com","careerbuilder.com","snagajob.com","lensa.com","talent.com","builtin.com","jobcase.com","jobs2careers.com","myjobhelper.com","recruit.net","upward.net","hiring.cafe","jobg8.com","resume-library.com","jobsora.com","jobtome.com","trabajo.org","jobright.ai","simplify.jobs","tealhq.com","bebee.com","intern-list.com"]),Tr=new Set(["indeed","glassdoor","adzuna","linkedin","jooble","neuvoo","jobrapido","whatjobs","careerjet","jobisjob","trovit"]),Fr=new Set(["simplyhired"]),Lr=new Set(["co.uk","org.uk","ac.uk","gov.uk","me.uk","net.uk","sch.uk","co.nz","ac.nz","govt.nz","org.nz","net.nz","co.za","org.za","ac.za","gov.za","co.in","net.in","org.in","ac.in","gov.in","edu.in","co.jp","or.jp","ne.jp","ac.jp","go.jp","co.kr","or.kr","ac.kr","go.kr","co.il","org.il","ac.il","gov.il","co.id","ac.id","or.id","go.id","com.au","net.au","org.au","edu.au","gov.au","asn.au","id.au","com.br","net.br","org.br","gov.br","edu.br","com.mx","org.mx","gob.mx","edu.mx","com.sg","edu.sg","gov.sg","org.sg","com.hk","edu.hk","gov.hk","org.hk","com.tr","edu.tr","gov.tr","org.tr","com.cn","net.cn","org.cn","edu.cn","gov.cn","com.ar","org.ar","gob.ar","edu.ar","com.co","edu.co","gov.co","com.pe","edu.pe","gob.pe","com.ph","edu.ph","gov.ph","com.my","edu.my","gov.my","org.my","com.vn","edu.vn","gov.vn","com.tw","edu.tw","gov.tw","org.tw","co.th","ac.th","go.th","in.th","com.ua","edu.ua","gov.ua","org.ua","co.ke","co.ug","co.tz","com.ng","edu.ng","gov.ng","com.pk","edu.pk","gov.pk","com.bd","com.sa","com.eg","com.pl","com.es","com.pt","com.gr","com.ro","com.uy","com.ec","com.bo","com.py","com.do","com.gt","com.sv","com.hn","com.ni","com.pa","com.ve","com.cy","com.mt"]),Pr=new Set(["gh_src","lever-source","lever-origin","fbclid","gclid","msclkid","mc_cid","mc_eid","trk","trkcampaign","refid","trackingid","originalsubdomain","ref","referrer","source","src","iis","iisn"]);function Et(t){let a=t.trim().toLowerCase();if(!a)return null;if(a.includes("/")||/^https?:/i.test(a)){const n=Or(a);if(n===null)return null;a=n}a=a.replace(/\.$/,"");
1const s=a.split(".").filter(Boolean);if(s.length<2)return null;const r=s.slice(-2).join(".");return Lr.has(r)?s.length<3?null:s.slice(-3).join("."):r}function Or(t){try{const a=/^https?:\/\//i.test(t)?t:`https://${t}`;return new URL(a).hostname.toLowerCase().replace(/\.$/,"")}catch{return null}}function qr(t){if(t.startsWith("//"))return`https:${t}`;const a=t.indexOf(":");return a>0&&/^[a-z][a-z0-9+.-]*$/i.test(t.slice(0,a))&&!t.slice(0,a).includes(".")?t:`https://${t}`}function Ir(t){if(!t)return null;const a=t.trim();if(!a)return null;let s;try{s=new URL(qr(a))}catch{return null}if(s.protocol!=="http:"&&s.protocol!=="https:"||s.username||s.password||!s.hostname||(s.hostname=s.hostname.toLowerCase().replace(/\.$/,""),Et(s.hostname)===null))return null;s.hash="";for(const r of[...s.searchParams.keys()]){const n=r.toLowerCase();(n.startsWith("utm_")||Pr.has(n))&&s.searchParams.delete(r)}return s.pathname.length>1&&(s.pathname=s.pathname.replace(/\/+$/,"")),s.toString()}const Mr=[{kind:"paycom",path:/^\/v\d+\/ats\//i}];function Dr(t,a,s){const r=t.pathname.toLowerCase();if(r.startsWith("/wday/cxs/"))return!0;if(!s)return!1;const n=t.hostname.split(".")[0]??"";return n==="api"||n.startsWith("api-")||n.endsWith("-api")?!0:a!==null&&Mr.some(o=>o.kind===a&&o.path.test(r))?!1:/^\/(v\d+|api)\//.test(r)}function Kr(t){let a;try{a=new URL(t)}catch{return null}const s=a.hostname.toLowerCase();if(s==="api.smartrecruiters.com"){const n=/^\/v1\/companies\/([^/]+)\/postings\/([^/?#]+)/i.exec(a.pathname);if(n)return{url:`https://jobs.smartrecruiters.com/${n[1]}/${n[2]}`,rule:"smartrecruiters-api"}}const r=/^\/wday\/cxs\/([^/]+)\/([^/]+)\/job\/(.+)$/i.exec(a.pathname);if(r){const n=s.split(".")[0]??"";return r[1].toLowerCase()===n.toLowerCase()?{url:`https://${s}/en-US/${r[2]}/job/${r[3]}`,rule:"workday-cxs"}:null}if(s==="boards-api.greenhouse.io"){const n=/^\/v1\/boards\/([^/]+)\/jobs\/([^/?#]+)/i.exec(a.pathname);if(n)return{url:`https://job-boards.greenhouse.io/${n[1]}/jobs/${n[2]}`,rule:"greenhouse-api"}}if(s==="api.lever.co"){const n=/^\/v0\/postings\/([^/]+)\/([^/?#]+)/i.exec(a.pathname);if(n)return{url:`https://jobs.lever.co/${n[1]}/${n[2]}`,rule:"lever-api"}}return null}function Ur(t){const a=new Set;if(!t)return a;for(const s of[t.domain,t.url,t.payloadDomain,t.payloadUrl]){if(!s)continue;const r=Et(s);r&&a.add(r)}return a}function $r(t,a){if(t==null)return null;const s=String(t),r=Ir(s);if(r===null)return s.trim()?{url:s,rawUrl:s,tier:"invalid",atsKind:null,applyMode:null,reason:"invalid:unusable",rewritten:!1}:null;const n=new URL(r),o=n.hostname,i=Et(o),l=xt(r),m=Yt(r),d=as(r),y=w=>({url:r,rawUrl:s,tier:"aggregator",atsKind:l,applyMode:m,reason:w,rewritten:!1});if(i&&Rr.has(i))return y(`aggregator:${i}`);const f=i?.split(".")[0]??"";if(f&&Tr.has(f))return y(`aggregator-label:${f}`);if(f&&i&&Fr.has(f)&&i!==`${f}.com`)return y(`aggregator-mirror:${i}`);if(Dr(n,l,l!==null||d!==null)){const w=Kr(r),g=w?xt(w.url):null;return w&&g!==null?{url:w.url,rawUrl:s,tier:"ats",atsKind:g,applyMode:Yt(w.url),reason:`rewrite:${w.rule}`,rewritten:!0}:{url:r,rawUrl:s,tier:"ats_api",atsKind:l,applyMode:m,reason:`ats_api:no-rewrite:${l??"unknown"}`,rewritten:!1}}return l!==null?{url:r,rawUrl:s,tier:"ats",atsKind:l,applyMode:m,reason:`ats:${l}`,rewritten:!1}:d?{url:r,rawUrl:s,tier:"employer",atsKind:null,applyMode:d.applyMode,reason:`employer-verified:${d.employer}`,rewritten:!1}:i&&Ur(a).has(i)?{url:r,rawUrl:s,tier:"employer",atsKind:null,applyMode:null,reason:`employer-domain:${i}`,rewritten:!1}:{url:r,rawUrl:s,tier:"unknown",atsKind:null,applyMode:null,reason:"unknown",rewritten:!1}}const Ea={active:0,inactive:2,deleted:3},Pe=t=>t===null?1:Ea[t.toLowerCase()]??1,Ae=t=>t===null?1:t.toLowerCase()==="ats"?0:2,zr=t=>t===null||t.toLowerCase()==="active";function Qr(t,a){return t===null?a:a===null||Pe(t)<=Pe(a)?t:a}function Br(t){const a=new URL(t),s=a.hostname.replace(/^www\./,""),r=[...a.searchParams.entries()].map(([n,o])=>`${n.toLowerCase()}=${o}`).sort().join("&");return`${s}|${a.pathname.toLowerCase()}|${r}`}const Wr=t=>(t.match(/[A-Z]/g)??[]).length;function Gr(t,a){const s=([o,i,l])=>[bt[o.tier],Number(o.rewritten),-Wr(o.url),Ae(i),l],r=s(t),n=s(a);for(let o=0;o<r.length;o++){const i=(r[o]??0)-(n[o]??0);if(i!==0)return i}return 0}function Yr(t,a={}){const s=a.eligibleAts??es,r=new Map;return t.forEach((n,o)=>{const i=$r(n.url,a.company);if(!i)return;const l=n.ordinal??o,m=n.source??null,d=n.status??null;let y;try{y=i.tier==="invalid"?i.rawUrl:Br(i.url)}catch{y=i.url}const f=r.get(y);if(!f){r.set(y,{c:i,source:m,status:d,ordinal:l});return}const w=Gr([i,m,l],[f.c,f.source,f.ordinal])<0;
1r.set(y,{c:w?i:f.c,source:Ae(m)<Ae(f.source)?m:f.source,status:Qr(d,f.status),ordinal:Math.min(l,f.ordinal)})}),[...r.values()].map(({c:n,source:o,status:i,ordinal:l})=>({...n,source:o,status:i,ordinal:l,applyForMeEligible:(n.tier==="ats"&&n.atsKind!==null&&s.has(n.atsKind)||n.tier==="employer"&&n.applyMode!==null&&ts(n.applyMode))&&zr(i)})).sort((n,o)=>ea(n)-ea(o)||Number(n.rewritten)-Number(o.rewritten)||Pe(n.status)-Pe(o.status)||Ae(n.source)-Ae(o.source)||n.ordinal-o.ordinal).map(({ordinal:n,...o})=>o)}function ea(t){return t.tier==="ats"&&t.atsKind!==null&&ss.has(t.atsKind)?bt.aggregator:bt[t.tier]}function Hr(t,a={}){const s=Yr(t,a);return s.length===0?null:a.allowNonAts?s.filter(n=>n.tier!=="invalid"&&(a.allowDeleted||Pe(n.status)<Ea.deleted))[0]??null:s.find(n=>n.applyForMeEligible)??null}function Vr(t,a){return Hr(t,{company:a})}function Xr(t){return t.trim().replace(/[^A-Za-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"Company"}function Zr(t){return t.trim().replace(/[^A-Za-z0-9-]+/g,"")||"Student"}function Jr(t){const a=(t??"").trim();if(a==="")return"Student";const s=a.split(/\s+/);return s[s.length-1]}function en(t){const a=t.getUTCFullYear(),s=String(t.getUTCMonth()+1).padStart(2,"0"),r=String(t.getUTCDate()).padStart(2,"0");return`${a}-${s}-${r}`}function mt({lastName:t,company:a,type:s,tailoredOn:r,ext:n="pdf"}){const o=Zr(t),i=Xr(a);return`${o}_${i}_${s}_${en(r)}.${n}`}function tn(t){return`grounding-report:${t}`}function an(t){return typeof t=="object"&&t!==null&&Array.isArray(t.entries)}function sn(t){if(typeof window>"u")return null;let a=null;try{a=window.localStorage.getItem(tn(t))}catch{return null}if(!a)return null;let s;try{s=JSON.parse(a)}catch{return null}return an(s)?s:null}const rn=-1;function Aa(t){const{isExtension:a,seq:s,hasLinkedFallback:r}=kt(t),n=T({...Ge(),enabled:!a}),o=T({...ze(t.job_id),enabled:!a}),i=o.data?.id??null,l=T({...Ce(i??0),enabled:!a&&i!==null}),m=T({...ue(s),enabled:a||r}),d=T({...da(s),enabled:a||r});function y(){const P=m.data,D=P?.resume_doc??null,N=P?.resume_edits??null,j=P?.resume_edits_status??null,O=D?Fs(D):null,E=N?Ls(N,rn):[],X=m.isPending||d.isPending;let A="idle",V=null;return X||(m.isError?A="error":O!==null?j==="pending"?A="tailoring":j==="failed"?(A="edits_failed",V="resume_edits_failed"):A="ready":d.data&&rs.has(d.data.status)?A="tailoring":d.data?.status==="failed"?(A="failed",V=d.data.failure_kind):A="none"),{resume:A==="error"?null:O,edits:A==="error"||A==="edits_failed"?[]:E,status:A,isPending:X,failureKind:V}}if(a)return y();const f=o.isPending||i!==null&&l.isPending,w=o.data?ya(o.data,{name:n.data?.name??null,email:n.data?.email??null}):null,g=l.data??[],H=f?"idle":w!==null?"ready":"none";if(w!==null||!r)return{resume:w,edits:g,status:H,isPending:f,failureKind:null};const I=y();return{...I,isPending:f||I.isPending}}const nn=me({method:"POST"}).middleware([pe]).handler(fe("28314a9d6f30c0272e96563b0476db5f3664d17156a3f96f18d7676a0311bed9")),on=me({method:"POST"}).middleware([pe]).handler(fe("b2a78adae6765a560c34ed40279dd9e0639de071dfeffd0c2bd7c00589fd2f60")),ln=me({method:"POST"}).middleware([pe]).handler(fe("8217e76e8762ab854b87d82302b0b0e355753b191337a5c7b258fee47c897cd7")),cn=me({method:"POST"}).middleware([pe]).handler(fe("c17109530b928cb8e768fa4f7ebb5562369484eae0e644c55dfbb632f95b37e8")),dn=me({method:"POST"}).middleware([pe]).handler(fe("94646f8c44a6eb070e2db7582802b4019dd814eb0baa79ce87553e230eec4d33")),Je="Couldn't save your decision. Please try again.",un="Couldn't finalize your resume. Please try again.",mn="Couldn't save your cover letter. Please try again.",pn=-1;function fn(t){const a=ce(),s=ue(t).queryKey;return le({mutationFn:r=>nn({data:{seq:t,...r}}),onError:()=>je.error(Je),onSettled:()=>{a.invalidateQueries({queryKey:s})}})}function Ca(t){const a=ce(),s=ue(t).queryKey;return le({mutationFn:()=>on({data:{seq:t}}),onError:()=>je.error(Je),onSettled:()=>{a.invalidateQueries({queryKey:s})}})}function hn(t){const a=ce(),s=ue(t).queryKey;return le({mutationFn:()=>ln({data:{seq:t}}),onError:()=>je.error(Je),onSettled:()=>{a.invalidateQueries({queryKey:s})}})}function xn(t){const a=ce(),s=ue(t).queryKey;return le({mutationFn:r=>cn({data:{seq:t,...r}}),onError:()=>je.error(Je),onSettled:()=>{a.invalidateQueries({queryKey:s})}})}function yn(t){const a=ce(),s=ue(t).queryKey;return le({mutationFn:r=>ns({data:{seq:t,text:r.text,finalize:r.finalize}}),onError:()=>je.error(mn),onSettled:()=>{a.invalidateQueries({queryKey:s})}})}function gn(t){const a=ce(),s=ue(t).queryKey,r=le({mutationFn:()=>dn({data:{seq:t}}),onError:()=>je.error(un),onSettled:()=>{a.invalidateQueries({queryKey:s})}});return{finalize:(o,i,l)=>{r.mutate(void 0,{onSuccess:m=>{"finalized"in m&&m.finalized&&ae("tracker_tailor_resume_finalized",qs({jobId:-t,tailoredResumeId:pn,source:"extension_review",acceptedEditCount:o,rejectedEditCount:i})),l?.onSuccess?.()}})},isPending:r.isPending}}function vn(t,a){return a==="accept"?t!=="rejected":t==="accepted"}function jn(){return{keywordOffered:0,keywordAccepted:0,keywordRejected:0,rewriteOffered:0,rewriteAccepted:0,rewriteRejected:0,addOffered:0,addAccepted:0,addRejected:0,removeOffered:0,removeAccepted:0,removeRejected:0}}function bn(t,a){const s=jn();let r=0,n=0;for(const o of t){const i=vn(o.status,a);i?r+=1:n+=1;const l=`${o.kind}Offered`;
1l in s&&(s[l]+=1,i?s[`${o.kind}Accepted`]+=1:s[`${o.kind}Rejected`]+=1)}return{acceptedEditCount:r,rejectedEditCount:n,byKind:s}}function wn(t){const{isExtension:a,seq:s,hasLinkedFallback:r}=kt(t),n=T({...Te(),enabled:!a}),o=T({...ue(s),enabled:a||r});if(a){const m=o.data;return{data:m?Xt(m):void 0,isPending:o.isPending,isFetched:o.isFetched,isFetching:o.isFetching}}const i=n.data?.get(t.job_id);if(i||!r)return{data:i,isPending:n.isPending,isFetched:n.isFetched,isFetching:n.isFetching};const l=o.data;return{data:l?Xt(l):void 0,isPending:n.isPending||o.isPending,isFetched:n.isFetched&&o.isFetched,isFetching:n.isFetching||o.isFetching}}function Nn(t){const{isExtension:a,seq:s,hasLinkedFallback:r}=kt(t),n=ce(),i=T({...is(s),enabled:a||r}).data?.etag,l=c.useRef(null);c.useEffect(()=>{if(!(a||r)||i===void 0)return;const m=l.current;m&&m.seq===s&&m.etag!==i&&n.invalidateQueries({queryKey:ue(s).queryKey}),l.current={seq:s,etag:i}},[a,r,s,i,n])}const kn=me({method:"POST"}).middleware([pe]).handler(fe("2f06985e8bb2115a9da8afdd614af49c5ff06265cd8ab2e3f27b48d0a0337298"));function wt(t,a={}){t.invalidateQueries({queryKey:ua().queryKey}),a.notifications&&t.invalidateQueries({queryKey:os().queryKey})}const Ra=new Set(["applied","interviewing","offer","rejected","withdrawn"]);function _n(t){return!!t&&Ra.has(t)}function Sn(t){return t?Ra.has(t)?"both-done":t==="preparing"?"cover-active":"resume-active":"resume-active"}function En(t){return t.jobTailorable?t.tailoredResumeId===null?t.autoCreateSuppressed?!1:!t.createErrored&&(!t.resumeFetched||t.resumeFetching||t.createPending||t.createIdle||t.createSucceeded):t.createPending&&!t.editsStale?!0:!t.editsErrored&&!t.editsReady:!1}function An(t){return!t.jobTailorable||t.locked||t.resumeStepDone||t.autoCreateSuppressed||t.reviewPending||t.rowReadInFlight?!1:!t.editsKnown}const Cn=3*6e4;function ta(t){if(Array.isArray(t.editsData))return!0;if(t.rowCreatedAt==null)return!1;const a=new Date(t.rowCreatedAt).getTime();return Number.isNaN(a)?!1:t.now-a>Cn}function Rn(t){return{id:t.job_id,title:t.title??"",company:t.company_name??"",companyLogoUrl:t.company_logo??null,location:t.location??"",remote:t.remote??!1,salary:t.salary??null,postedDate:t.posted_at??null,descriptionSnippet:t.description??null,applicationUrl:t.application_url??null,fullDescription:t.description??null,descriptionStructured:null,functions:[],benefits:[],seniority:t.seniority??null,extractedSkills:[],state:"ready",score:null,signals:[],match:null,tier:"top"}}function Tn({job:t}){const a=ce(),{data:s}=T(Ge()),r=s?.school??"",n=s?.major??null,o=t.company_name??"",{data:i}=T(ls()),l=o?i?.[o]:void 0,m=T(cs({school:r,major:n,roleInterest:t.title??null,companies:o?[o]:[],enabled:!l})),d=l?void 0:m.data?.[o];c.useEffect(()=>{d&&d.length>0&&ds(a,o,d)},[d,o,a]);const y=(l??d??[]).length,f=!l&&m.isLoading,w=c.useMemo(()=>Rn(t),[t]),[g,H]=c.useState(null);return!f&&y===0?null:e.jsxs("article",{className:"af-card","data-testid":"apply-connect-step",children:[e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Reach out"}),e.jsxs("h2",{className:"af-card-title",children:["Connect with someone at ",o,"."]}),e.jsx("p",{className:"mt-1 text-sm leading-body text-text-muted",children:"A warm intro to an alum can move your application to the top of the pile."}),f?e.jsxs("p",{className:"mt-4 text-sm text-text-muted","aria-live":"polite",children:["Finding people at ",o,"â¦"]}):e.jsx(Zs,{card:w,variant:"rows",surface:"apply_connect",skipSave:!0,className:"mt-4",onContactSelect:(I,P)=>H({card:I,contact:P})})]}),g&&e.jsx(er,{person:sr(g.contact),company:ar({name:g.card.company,logoUrl:g.card.companyLogoUrl}),profile:tr({studentName:s?.name,school:s?.school,major:s?.major}),jobId:g.card.id,persistDrafts:!0,onContactSent:()=>{},onClose:()=>H(null)})]})}ma({jobId:ms(),coverLetterMarkdown:us().min(1).refine(t=>t.trim().length>0,"coverLetterMarkdown must be non-whitespace")});const Fn=me({method:"POST"}).middleware([pe]).handler(fe("a1b57ce76f8c5ca662770c36fc173aff31cf334677e071b307373eee1080e04d"));function Re({className:t,...a}){return e.jsx(S,{type:"button",variant:"orange-link",className:t,...a})}const Ln=yt(ps({variant:"orange-link"}));function Pn({message:t="Drafting your cover letterâ¦"}){return e.jsxs("output",{"data-testid":"cover-letter-processing-loader","aria-live":"polite",className:"flex items-center gap-3 rounded-lg bg-purple-04 px-4 py-3 text-sm text-text-muted",children:[e.jsx(_t,{className:"size-5 shrink-0 text-purple"}),e.jsx("span",{children:t})]})}
1const On=/^(sincerely|best regards|kind regards|all the best|best|thanks|regards|cheers|warmly)[,.]?(?:\s+\S[\s\S]*)?$/i;function Ke(t){const a={greeting:"",paragraphs:[],signoff:""};if(!t||t.trim()==="")return a;const r=t.replace(/\r\n/g,` 2`).split(/\n{2,}/).map(l=>l.trim()).filter(l=>l.length>0);if(r.length===0)return a;let n="",o=r;r[0].startsWith("Dear ")&&(n=r[0],o=r.slice(1));let i="";return o.length>0&&On.test(o[o.length-1])&&(i=o[o.length-1],o=o.slice(0,-1)),{greeting:n,paragraphs:o,signoff:i}}const qn=["Tighten it to three short paragraphs.","More about my Ledger project.","Less enthusiastic, more matter-of-fact.","Sharper opening that gets to the point."];function aa({onClose:t,onRefine:a}){const[s,r]=c.useState(""),n=i=>{r(l=>l?`${l.trimEnd()} ${i}`:i)},o=()=>{const i=s.trim();i&&a(i)};return c.useEffect(()=>{const i=l=>{l.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),e.jsx("div",{className:"af-modal-backdrop",onClick:i=>{i.target===i.currentTarget&&t()},children:e.jsxs("div",{className:"af-modal af-modal-refine",role:"dialog","aria-modal":"true",children:[e.jsx("button",{className:"af-modal-close",type:"button",onClick:t,"aria-label":"Close","data-amp-track-surface":"tracker_apply","data-amp-track-action":"refine_cancel",children:e.jsx(Xe,{})}),e.jsxs("div",{className:"af-modal-head",children:[e.jsxs("div",{className:"af-modal-eyebrow purple",children:[e.jsx("span",{className:"af-sum-pulse","aria-hidden":"true"}),"Refine with Chegg"]}),e.jsx("h3",{className:"af-modal-title",children:"What should the next draft do differently?"}),e.jsx("p",{className:"af-modal-reason",children:"Tell Chegg what to change. The next draft will take that direction."})]}),e.jsxs("div",{className:"af-modal-body",children:[e.jsx("textarea",{className:"af-textarea af-refine-textarea",placeholder:'e.g. "Tighten to three short paragraphs." "Drop the Linode bullet â too long." "More about my Ledger project."',value:s,onChange:i=>r(i.target.value)}),e.jsxs("div",{className:"af-refine-presets",children:[e.jsx("div",{className:"af-refine-presets-label",children:"Quick prompts"}),e.jsx("div",{className:"af-refine-presets-row",children:qn.map(i=>e.jsx("button",{type:"button",className:"af-refine-preset",onClick:()=>n(i),"data-amp-track-surface":"tracker_apply","data-amp-track-action":"refine_preset_append",children:i},i))})]})]}),e.jsxs("div",{className:"af-modal-foot",children:[e.jsx("div",{className:"af-modal-foot-left"}),e.jsxs("div",{className:"af-modal-foot-right",children:[e.jsx(S,{variant:"ghost",type:"button",onClick:t,"data-amp-track-surface":"tracker_apply","data-amp-track-action":"refine_cancel",children:"Cancel"}),e.jsx(S,{variant:"orange",type:"button",onClick:o,disabled:!s.trim(),"data-amp-track-surface":"tracker_apply","data-amp-track-action":"refine_submit",children:"Update"})]})]})]})})}function we(t){return t.split(/\s+/).filter(Boolean).length}function pt(t){const a=[];t.greeting&&a.push(t.greeting);for(const s of t.paragraphs)a.push(s);return t.signoff&&a.push(t.signoff),a.join(` 3 4`).trim()}const In={greeting:"",paragraphs:[],signoff:""},sa="Couldn't save your cover letter. Please try again.";function Mn({state:t,job:a,jobId:s,summaryBullets:r=null,onSave:n,onDownload:o,onReDownload:i,locked:l=!1,materialsDownloaded:m=!1}){const[d,y]=c.useState(!1),[f,w]=c.useState(!1),[g,H]=c.useState(0),[I,P]=c.useState(!1),[D,N]=c.useState(!1),j=c.useId(),O=c.useId(),E=c.useId(),[X,A]=c.useState(null),[V,$]=c.useState(null),J=c.useRef(!1),se=c.useRef(null),F=s!==void 0&&qe(s),p=F?Ve(s):0,k=h=>{const U=se.current;if(!U)return h;const q=[];for(const xe of Array.from(U.children)){if(xe.classList.contains("af-cl-paper-overlay"))continue;const be=(xe.textContent??"").trim();be&&q.push(be)}return q.join(` 5 6`)},z=le({mutationFn:async h=>{const U=Date.now();return{out:await Ts({data:h}),durationMs:Date.now()-U}}}),re=ce(),Z=le({mutationFn:h=>Fn({data:h}),onSuccess:()=>{re.invalidateQueries({queryKey:Te().queryKey}),re.invalidateQueries({queryKey:pa(s??0).queryKey})}}),de=yn(p),K=z.isPending&&J.current,L=z.isPending&&!z.variables?.studentFeedback,C=T({...Te(),enabled:!F&&s!==void 0}),ee=T({...ue(p),enabled:F}),x=F?ee.data?.cover_letter_body??null:null,v=F?x:s!==void 0?C.data?.get(s)?.coverLetterMarkdown??null:null,M=z.mutate;c.useEffect(()=>{if(s!==void 0&&!F&&t==="active"&&!J.current&&C.isFetched){if(v?.trim()){J.current=!0,$(Ke(v)),H(h=>h+1);return}J.current=!0,M({jobId:s},{onSuccess:({out:h,durationMs:U})=>{const q=Ke(h.coverLetterMarkdown);$(q),H(xe=>xe+1),ae("cover_letter_generated",{jobId:s,kind:"initial",durationMs:U,wordCount:we(h.coverLetterMarkdown)})}})}},[t,s,F,M,C.isFetched,v]),c.useEffect(()=>{t!=="done"&&y(!1)},[t]);const _=c.useMemo(()=>
6{if(s!==void 0){if(V)return V;if(v?.trim())return Ke(v)}return In},[s,V,v]),{isPaywalled:G,openPaywall:Y}=He(),R=G("cover_letter"),oe=e.jsx("article",{className:"af-cl-paper","aria-label":"Cover letter preview",children:e.jsx(Js,{feature:"cover_letter",clear:e.jsxs(e.Fragment,{children:[_.greeting?e.jsx("div",{className:"af-cl-greeting",children:_.greeting}):null,_.paragraphs[0]?e.jsx("p",{children:_.paragraphs[0]}):null]}),blurred:_.paragraphs.length>1||_.signoff?e.jsxs(e.Fragment,{children:[_.paragraphs.slice(1).map(h=>e.jsx("p",{children:h},h.slice(0,32))),_.signoff?e.jsx("div",{className:"af-cl-signoff",children:_.signoff}):null]}):null})}),Q=h=>{if(P(!1),H(q=>q+1),w(!1),s===void 0){const q=h.length>80?`${h.slice(0,80)}â¦`:h;A(q),window.setTimeout(()=>A(null),6e3);return}const U=k(pt(_));z.mutate({jobId:s,previousDraft:U,studentFeedback:h},{onSuccess:({out:q,durationMs:xe})=>{const be=Ke(q.coverLetterMarkdown);$(be);const ne=h.length>80?`${h.slice(0,80)}â¦`:h;A(ne),window.setTimeout(()=>A(null),6e3),ae("cover_letter_generated",{jobId:s,kind:"refined",durationMs:xe,wordCount:we(q.coverLetterMarkdown),feedbackLength:h.trim().length})}})},he=()=>{if(s===void 0){n();return}const h=k(pt(_));if(!h){n();return}if(F){de.mutate({text:h,finalize:!0},{onSuccess:U=>{if(!U.updated){je.error(sa);return}ae("cover_letter_persisted",{jobId:s,wordCount:we(h)}),n()}});return}Z.mutate({jobId:s,coverLetterMarkdown:h},{onSuccess:()=>{ae("cover_letter_persisted",{jobId:s,wordCount:we(h)}),n()}})},ge=r&&r.length>0?r.map(h=>e.jsxs("li",{children:[e.jsx("span",{className:"glyph","aria-hidden":"true",children:"â"}),e.jsx("span",{children:h})]},h)):e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:[e.jsx("span",{className:"glyph","aria-hidden":"true",children:"â"}),e.jsxs("span",{children:["Opens with why ",a.company," fits the story your resume tells."]})]}),e.jsxs("li",{children:[e.jsx("span",{className:"glyph","aria-hidden":"true",children:"â"}),e.jsx("span",{children:"Connects your strongest experience to the role's responsibilities."})]}),e.jsxs("li",{children:[e.jsx("span",{className:"glyph","aria-hidden":"true",children:"â"}),e.jsx("span",{children:"Closes with a concrete next step."})]})]}),b=h=>{if(R)return oe;const U=q=>h();return e.jsxs(e.Fragment,{children:[X&&!K&&e.jsxs("output",{className:"af-cl-refined-note",children:[e.jsx("span",{className:"check",children:e.jsx(Ze,{size:12,sw:2.6})}),e.jsxs("span",{children:[e.jsx("b",{children:"Refined just now."})," Using your direction: â",X,"â"]})]}),e.jsxs("article",{ref:se,className:`af-cl-paper${K||L?" refining":""}`,"aria-label":"Cover letter draft",contentEditable:!K&&!L,suppressContentEditableWarning:!0,onInput:U,spellCheck:!0,children:[K&&e.jsxs("output",{className:"af-cl-paper-overlay","aria-live":"polite",children:[e.jsx(_t,{className:"size-5 shrink-0 text-purple"}),e.jsx("span",{children:"Re-drafting using your directionâ¦"})]}),e.jsx("div",{className:"af-cl-greeting",children:_.greeting}),_.paragraphs.map(q=>e.jsx("p",{children:q},q.slice(0,32))),e.jsx("div",{className:"af-cl-signoff",children:_.signoff})]},g)]})};if(t==="locked")return e.jsx("article",{className:"af-card opacity-60","aria-labelledby":j,children:e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 2 · Up next"}),e.jsx("h2",{id:j,className:"af-card-title",children:"Draft your cover letter"}),e.jsx("div",{className:"af-card-meta",children:e.jsx("span",{children:"Unlocks when Step 1 saves. Drafted from your tailored resume."})})]})});if(t==="done"){const h=()=>{w(!1),y(!0)},U=()=>{H(ne=>ne+1),w(!1),y(!1)},q=()=>{if(s!==void 0){const ne=k(pt(_));if(ne){if(F){de.mutate({text:ne},{onSuccess:et=>{if(!et.updated){je.error(sa);return}ae("cover_letter_persisted",{jobId:s,wordCount:we(ne)}),w(!1),y(!1)}});return}Z.mutate({jobId:s,coverLetterMarkdown:ne},{onSuccess:()=>{ae("cover_letter_persisted",{jobId:s,wordCount:we(ne)})}})}}w(!1),y(!1)},xe=()=>{s!==void 0&&ae("cover_letter_downloaded",{jobId:s}),o?.()},be=l?`Cover letter sent to ${a.company}`:"Cover letter drafted";return e.jsxs(e.Fragment,{children:[e.jsxs("article",{className:"af-card af-card--compact","aria-labelledby":O,children:[e.jsxs("div",{className:"af-card-body",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(Le,{"aria-hidden":!0,strokeWidth:2.5,className:"size-4 shrink-0 text-success"}),e.jsx("h2",{id:O,className:"af-card-title af-card-title-inline",children:be})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[R?e.jsx(wa,{feature:"cover_letter"}):m?e.jsxs("button",{type:"button",onClick:i,"aria-label":"Re-download","data-amp-track-surface":"tracker_apply","data-amp-track-action":"redownload_cover_letter",className:"group inline-flex cursor-pointer items-center gap-1.5 rounded-md border border-transparent bg-transparent px-3 py-1.5 font-semibold text-sm text-text-muted outline-none transition-colors duration-fast ease-
6out hover:text-text-strong focus-visible:text-text-strong focus-visible:shadow-focus",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 group-hover:hidden group-focus-visible:hidden",children:[e.jsx(Le,{className:"size-3.5",strokeWidth:2.4}),"Downloaded"]}),e.jsxs("span",{className:"hidden items-center gap-1.5 group-hover:inline-flex group-focus-visible:inline-flex",children:[e.jsx(We,{className:"size-3.5",strokeWidth:2}),"Re-download"]})]}):e.jsxs("button",{type:"button",onClick:xe,"data-amp-track-surface":"tracker_apply","data-amp-track-action":"download_cover_letter",className:"inline-flex items-center gap-1.5 rounded-md border border-transparent bg-transparent px-3 py-1.5 font-semibold text-sm text-text-strong outline-none transition-colors duration-fast ease-out hover:text-orange-hover focus-visible:shadow-focus",children:[e.jsx(We,{className:"size-3.5",strokeWidth:2}),"Download .pdf"]}),e.jsx("button",{type:"button",onClick:d?U:h,"aria-expanded":d,"aria-label":d?"Collapse":l?"View":"Edit","data-amp-track-surface":"tracker_apply","data-amp-track-action":"revise_cover_letter",className:"inline-flex items-center justify-center rounded-md p-1.5 text-text-muted outline-none transition-colors duration-fast ease-out hover:text-text-strong focus-visible:shadow-focus",children:e.jsx(Ye,{"aria-hidden":!0,strokeWidth:1.75,className:`size-5 transition-transform duration-[260ms] ease-out ${d?"":"-rotate-90"}`})})]})]}),e.jsx(Fe,{open:d,children:e.jsxs("section",{className:"af-card-section",children:[e.jsx("div",{className:"af-card-eyebrow",children:"Your draft"}),e.jsx("ul",{className:"af-card-list",children:ge}),e.jsx("div",{className:"af-card-section-action",children:e.jsx("button",{type:"button",className:"af-link-quiet",onClick:()=>N(ne=>!ne),"aria-expanded":D,children:D?"Hide cover letter":"Review cover letter â"})}),D&&e.jsx("div",{className:"af-card-inline-review",children:R?oe:l?e.jsxs("article",{className:"af-cl-paper","aria-label":"Cover letter (read-only)",children:[e.jsx("div",{className:"af-cl-greeting",children:_.greeting}),_.paragraphs.map(ne=>e.jsx("p",{children:ne},ne.slice(0,32))),e.jsx("div",{className:"af-cl-signoff",children:_.signoff})]}):b(()=>w(!0))})]})})]}),!l&&e.jsx(Fe,{open:d&&f,children:e.jsx("footer",{className:"af-card-footer",children:e.jsxs("div",{className:"af-card-footer-actions",children:[e.jsx(Re,{onClick:U,children:"Cancel"}),e.jsx(S,{type:"button",variant:"orange",onClick:q,disabled:!f,children:"Save changes"})]})})})]}),I&&e.jsx(aa,{onClose:()=>P(!1),onRefine:Q})]})}return L?e.jsx("article",{className:"af-card","aria-labelledby":E,children:e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 2"}),e.jsxs("h2",{id:E,className:"af-card-title",children:["Drafting your cover letter for ",a.company,"â¦"]}),e.jsxs("div",{className:"af-card-meta",children:[e.jsx("span",{className:"af-card-pulse","aria-hidden":"true"}),e.jsx("span",{children:"Writing your draft"})]}),e.jsx("section",{className:"af-card-section",children:e.jsx(Pn,{})})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("article",{className:"af-card","aria-labelledby":E,children:[e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 2"}),e.jsxs("h2",{id:E,className:"af-card-title",children:["Cover letter for ",a.company,"."]}),e.jsxs("div",{className:"af-card-meta",children:[e.jsx("span",{className:"af-card-pulse","aria-hidden":"true"}),e.jsxs("span",{children:["Draft 1 · ",K?"re-draftingâ¦":"just now"]})]}),e.jsxs("section",{className:"af-card-section",children:[e.jsx("div",{className:"af-card-eyebrow",children:"Your draft"}),e.jsx("ul",{className:"af-card-list",children:ge}),e.jsx("div",{className:"af-card-section-action",children:e.jsx("button",{type:"button",className:"af-link-quiet",onClick:()=>N(h=>!h),"aria-expanded":D,children:D?"Hide cover letter":"Review cover letter â"})}),D&&e.jsx("div",{className:"af-card-inline-review",children:b(()=>{})})]})]}),e.jsx("footer",{className:"af-card-footer",children:R?e.jsxs("div",{className:"af-card-footer-actions",children:[e.jsxs(S,{type:"button",variant:"orange",onClick:()=>Y("cover_letter"),"data-amp-track-surface":"membership_lock","data-amp-track-action":"unlock","data-amp-track-target":"cover_letter",children:[e.jsx(_a,{className:"size-3.5",strokeWidth:2,"aria-hidden":!0}),"Continue with drafted cover letter"]}),e.jsx(Re,{onClick:n,"data-amp-track-surface":"tracker_apply","data-amp-track-action":"write_own_cover_letter",children:"Write my own cover letter"})]}):e.jsx("div",{className:"af-card-footer-actions",children:e.jsx(S,{type:"button",variant:"orange",onClick:he,disabled:Z.isPending,"data-amp-track-surface":"tracker_apply","data-amp-track-action":"save_cover_letter",children:"Save and next"})})})]}),I&&e.jsx(aa,{onClose:()=>P(!1),onRefine:Q})]})}function Dn({company:t,onConfirm:a,onDismiss:s}){const r=c.useId(),n=c.useRef(null);return ir(n,!0),c.useEffect(()=>{const o=i=>{i.key==="Escape"&&s()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[s]),e.jsx("div",{className:"af-modal-backdrop",onClick:o=>{o.target===o.currentTarget&&s()},children:e.jsxs("div",{ref:n,className:"af-modal",role:"dialog","aria-modal":"true","aria-labelledby":r,children:[e.jsx("button",{className:"af-modal-close",type:"button",onClick:s,"aria-label":"Close",children:e.jsx(Xe,{})}),e.jsxs("div",{className:"af-modal-head",children:[e.jsxs("h3",{id:r,className:"af-modal-title",children:["Did you apply to ",t,"?"]}),e.jsx("p",{className:"af-modal-reason",children:"Tell us so we can keep your tracker honest."}),e.jsx("p",{className:"af-modal-reason",children:"Confirming will lock your tailored resume and cover letter for this job â you won't be able to edit them after."})]}),e.jsxs("div",{className:"af-modal-foot",children:[e.jsx("div",{className:"af-modal-foot-left"}),e.jsxs("div",{className:"af-modal-foot-right",children:[e.jsx(S,{variant:"ghost",type:"button",onClick:s,"data-amp-track-surface":"apply","data-amp-track-action":"dismiss",children:"Not yet"}),e.jsxs(S,{variant:"orange",type:"button",onClick:a,"data-amp-track-surface":"apply","data-amp-track-action":"confirm_applied",children:[e.jsx(Ze,{size:15,sw:2.4}),"Yes, I applied"]})]})]})]})})}const Kn={interviewing:"Got an interview",offer:"Got an offer",rejected:"Not moving forward",withdrawn:"Withdrew"},Oe=["interviewing","offer"],Be=["rejected","withdrawn"];function Ta(t,a){if(!a)return!1;const s=Oe.indexOf(t),r=Oe.indexOf(a);return r<0?!1:s<=r}function Un(t,a){if(Be.includes(t))return a===t?"applied":t;const s=t;if(Ta(s,a)){const n=Oe.indexOf(s);return n===0?"applied":Oe[n-1]}return s}function $n({company:t,status:a,onUpdateStatus:s}){const r=[...Oe,...Be],n=a&&Be.includes(a),o=i=>{if(Be.includes(i))return a===i?"current":n?"past":"none";const l=i;return n?"past":Ta(l,a)?a===i?"current":"past":"none"};return e.jsx("section",{className:"af-card","data-testid":"apply-status-row",children:e.jsxs("div",{className:"af-card-body",children:[e.jsxs("p",{className:"af-ready-sub",children:["Update ",t,"'s status as you hear back:"]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:r.map(i=>{const l=o(i),m=l==="current"?"var(--orange-12)":l==="past"?"var(--surface-raised)":void 0;return e.jsx(S,{type:"button","aria-pressed":l!=="none",variant:"outline",style:m?{background:m}:void 0,onClick:()=>s(Un(i,a)),"data-amp-track-surface":"apply","data-amp-track-action":"update_status","data-amp-track-state":i,children:Kn[i]??i},i)})})]})})}function Fa(t){return t===!0?"Remote":t===!1?"On-site":null}function zn(t){const a=[];if(t.location!==null){const s=Fa(t.remote),r={label:"Location",value:t.location};s!==null&&(r.meta=s),a.push(r)}return t.employment_type!==null&&a.push({label:"Term",value:t.employment_type}),t.salary!==null&&a.push({label:"Pay",value:t.salary}),a}const Qn=me({method:"GET"}).middleware([pe]).handler(fe("78292ff50b4a6779d338aaca224d9c3b5b4e0cea842a563e9e8350567a5ed333"));function Bn(t){return fs({queryKey:["job-insights",t??"disabled"],queryFn:()=>Qn({data:{jobId:t}}),enabled:typeof t=="number"&&t>0,staleTime:300*1e3})}function Wn(t){return T(Bn(t))}function ra({items:t,testId:a}){if(t.length===0)return null;const s=pr(t);return e.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-5 leading-relaxed text-text marker:text-purple","data-testid":a,children:t.map((r,n)=>e.jsx("li",{children:r},s[n]))})}function Gn({insights:t}){const[a,s]=c.useState(!0);return e.jsxs("div",{"data-testid":"chegg-read",className:"rounded-xl border border-purple-12 bg-purple-04 p-4 text-sm text-text",children:[e.jsxs("button",{type:"button","data-amp-track-surface":"apply","data-amp-track-action":a?"close_chegg_read":"open_chegg_read","aria-expanded":a,onClick:()=>s(r=>!r),className:"flex w-full items-center gap-2.5 text-left font-bold text-[10.5px] text-purple-press uppercase tracking-[0.1em]",children:[e.jsx("span",{"aria-hidden":!0,
6className:"flex h-[1lh] shrink-0 items-center",children:e.jsx(lr,{})}),"Chegg's take",e.jsx(Ye,{"aria-hidden":!0,className:`ml-auto size-4 shrink-0 text-text-muted transition-transform duration-slow ease-out ${a?"":"-rotate-90"}`})]}),e.jsx(Fe,{open:a,children:e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("section",{children:[e.jsx("h4",{className:"font-semibold text-text-strong",children:"What this role is really asking for"}),e.jsx(ra,{items:t.asking,testId:"insights-asking"})]}),t.profileFit.length>0&&e.jsxs("section",{children:[e.jsx("h4",{className:"font-semibold text-text-strong",children:"How your profile lines up"}),e.jsx(ra,{items:t.profileFit,testId:"insights-fit"})]})]})})]})}function Yn(){return e.jsxs("div",{"aria-busy":"true",className:"rounded-xl border border-purple-12 bg-purple-04 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5 font-bold text-[10.5px] text-purple-press uppercase tracking-[0.1em]",children:[e.jsx("span",{"aria-hidden":"true",className:"size-1.5 animate-carp-pulse rounded-pill bg-purple"}),"Chegg's take"]}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-surface-white"}),e.jsx("div",{className:"h-3 w-5/6 animate-pulse rounded bg-surface-white"}),e.jsx("div",{className:"h-3 w-3/4 animate-pulse rounded bg-surface-white"})]})]})}function Hn({job:t}){const a=Wn(qe(t.job_id)?null:t.job_id),s=a.data??null,r=zn(t);return e.jsxs("div",{"data-testid":"job-expanded",className:"space-y-5 border-hairline border-t px-8 py-5",children:[r.length>0&&e.jsx("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-3 lg:grid-cols-4",children:r.map(n=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("dt",{className:"font-bold text-text-muted text-xs uppercase tracking-label",children:n.label}),e.jsx("dd",{className:"mt-0.5 truncate font-semibold text-sm text-text-strong",children:n.value}),n.meta&&e.jsx("div",{className:"text-text-muted text-xs",children:n.meta})]},n.label))}),s?e.jsx(Gn,{insights:s}):a.isLoading?e.jsx(Yn,{}):null,(t.description_structured||t.description)&&e.jsxs("section",{children:[e.jsx("h3",{className:"font-bold text-text-muted text-xs uppercase tracking-label",children:"About the role"}),e.jsx(mr,{raw:t.description??"",structured:t.description_structured??null})]})]})}function Vn({job:t,defaultOpen:a=!1}){const[s,r]=c.useState(a),n=t.company_name??"This company",o=t.title??"this role",i=Fa(t.remote),l=cr(t);return e.jsxs("header",{className:"rounded-xl border border-hairline bg-surface-white",children:[e.jsxs("button",{type:"button",onClick:()=>r(m=>!m),"aria-expanded":s,"data-amp-track-surface":"apply","data-amp-track-action":"header_toggle","data-amp-track-state":s?"open":"closed",className:"flex w-full items-center gap-4 py-3.5 pr-8 pl-8 text-left",children:[e.jsx(ur,{company:n,logoUrl:t.company_logo}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h1",{className:"truncate font-bold text-md text-text-strong leading-snug tracking-tight",children:o}),e.jsxs("p",{className:"mt-0.5 flex flex-wrap items-baseline gap-x-2 text-sm text-text-muted",children:[e.jsx("span",{className:"font-semibold text-text",children:n}),t.location&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-disabled",children:"·"}),e.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[e.jsx(fr,{className:"size-3 translate-y-0.5",strokeWidth:1.75}),t.location]})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-disabled",children:"·"}),e.jsx("span",{children:i})]})]})]}),l!=null&&e.jsx(dr,{student:l,className:"shrink-0"}),e.jsx("span",{className:"inline-flex shrink-0 items-center justify-center rounded-md p-1.5 text-text-muted",children:e.jsx(Ye,{"aria-hidden":"true",strokeWidth:1.75,className:`size-5 transition-transform duration-slow ease-out ${s?"":"-rotate-90"}`})})]}),e.jsx(Fe,{open:s,children:e.jsx(Hn,{job:t})})]})}function Xn(){const t=ga(hs)==="on",a=ce(),[s,r]=c.useState(!1),{data:n}=T({...jr(),enabled:t}),o=le({mutationFn:br,onSuccess:()=>{a.invalidateQueries({queryKey:wr})}}),i=n?.accounts.find(f=>f.provider==="chegg"&&f.address)??null,l=n?.useForApplications!==!1,m=c.useRef(!1),d=t&&n!==void 0&&n.canProvision&&l&&i===null&&!o.isPending;if(c.useEffect(()=>{!d||m.current||(m.current=!0,o.mutate())},[d,o]),!t||!l||!i?.address)return null;const y=i.address;return e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2 rounded-lg border border-hairline bg-surface-raised px-3 py-2","data-testid":"apply-application-email",children:[e.jsx(kr,{className:"size-3.5 shrink-0 text-text-muted"}),e.jsx("span",{className:"min-w-0 truncate text-[12.5px] font-medium text-text-strong",children:y}),e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded border border-hairline px-2 py-0.5 text-[11.5px] text-text-muted hover:text-text-strong","data-testid":"apply-copy-application-email","data-amp-track-surface":"apply","data-amp-track-action":"copy","data-amp-track-target":"application_email",onClick:async()=>{try{await navigator.clipboard.writeText(y),r(!0),setTimeout(()=>r(!1),2e3)}catch{}},children:[s?e.jsx(Le,{className:"size-3"}):e.jsx(_r,{className:"size-3"}),s?"Copied":"Copy"]}),e.jsx("span",{className:"w-full text-[11.5px] leading-[1.4] text-text-muted sm:w-auto
6sm:flex-1",children:"We created this address for your applications. Use it as your email â replies come back to your tracker."})]})}function Zn({company:t,installUrl:a,onApplyYourself:s,onClose:r,onInstallClick:n}){const o=c.useId();return c.useEffect(()=>{const i=l=>{l.key==="Escape"&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[r]),e.jsx("div",{className:"af-modal-backdrop",onClick:i=>{i.target===i.currentTarget&&r()},children:e.jsxs("div",{className:"af-modal af-modal-refine",role:"dialog","aria-modal":"true","aria-labelledby":o,children:[e.jsx("button",{className:"af-modal-close",type:"button",onClick:r,"aria-label":"Close","data-amp-track-surface":"apply","data-amp-track-action":"apply_via_extension_blocked_dismiss",children:e.jsx(Xe,{})}),e.jsxs("div",{className:"af-modal-head",children:[e.jsxs("div",{className:"af-modal-eyebrow purple",children:[e.jsx("span",{className:"af-sum-pulse","aria-hidden":"true"}),"Apply using extension"]}),e.jsx("h2",{id:o,className:"af-modal-title",children:"Add the Chegg Chrome extension to auto-fill your info for every application"}),e.jsx("p",{className:"af-modal-reason",children:"The Chegg Chrome extension fills the application with your tailored resume and cover letter. Install it or continue applying manually."}),e.jsxs("span",{className:"sr-only",children:["Applying to ",t]})]}),e.jsxs("div",{className:"af-modal-foot af-modal-foot-stack",children:[e.jsx(S,{asChild:!0,variant:"orange",children:e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:()=>{n?.(),r()},"data-amp-track-surface":"apply","data-amp-track-action":"install_extension",children:["Install extension",e.jsx(vt,{size:14,sw:2})]})}),e.jsx(Na,{variant:"secondary",onClick:s})]})]})})}function Jn(t){const a=[];for(const s of t){const r=s.message?.trim();r&&(s.actor==="csr"&&s.eventType==="question"?a.push({id:s.id,author:"csr",message:r}):s.actor==="student"&&s.eventType==="answer"&&a.push({id:s.id,author:"student",message:r}))}return a}function ei({events:t}){const a=Jn(t),s=c.useRef(null);return c.useEffect(()=>{const r=s.current;r&&(r.scrollTop=r.scrollHeight)},[a.length]),a.length===0?null:e.jsx("ol",{ref:s,className:"aa-qa-thread","aria-label":"Questions and your answers",children:a.map(r=>e.jsxs("li",{className:`aa-qa-entry aa-qa-${r.author}`,children:[e.jsx("span",{className:"aa-qa-author",children:r.author==="csr"?"Chegg agent":"You"}),e.jsx("p",{className:"aa-qa-message",children:r.message})]},r.id))})}const La=["hispanic_or_latino","white","black_or_african_american","native_hawaiian_or_other_pacific_islander","asian","american_indian_or_alaska_native","two_or_more_races","prefer_not_to_say"],Pa=["male","female","non_binary","prefer_not_to_say"],Oa=["protected_veteran","not_a_protected_veteran","prefer_not_to_say"],qa=["yes","no","prefer_not_to_say"];ma({raceEthnicity:xs(De(La)).default([]),gender:De(Pa).nullable().default(null),veteranStatus:De(Oa).nullable().default(null),disabilityStatus:De(qa).nullable().default(null)});const ti={prefer_not_to_say:"Prefer not to answer",hispanic_or_latino:"Hispanic or Latino",white:"White",black_or_african_american:"Black or African American",native_hawaiian_or_other_pacific_islander:"Native Hawaiian or other Pacific Islander",asian:"Asian",american_indian_or_alaska_native:"American Indian or Alaska Native",two_or_more_races:"Two or more races",male:"Male",female:"Female",non_binary:"Non-binary",protected_veteran:"I am a protected veteran",not_a_protected_veteran:"I am not a protected veteran",yes:"Yes, I have a disability",no:"No, I don't have a disability"};function ai(t){return ti[t]??t}me({method:"GET"}).middleware([pe]).handler(fe("bce1fb7a46f7999e3442ab6b69656ba1a472b51098c9c126f7fa0db8ff22363a"));const si=me({method:"POST"}).middleware([pe]).handler(fe("f6fd2144a77de81bd04ab066c53c9bd785bef162e751d6436619c057414f65a0"));me({method:"POST"}).middleware([pe]).handler(fe("56590b79200b20f3bcf46aa7c3c4b8641894045017c113c957317b2b6dc23531"));const Se="prefer_not_to_say";function Ue({label:t,options:a,value:s,onChange:r}){const n=c.useId();return e.jsxs("div",{className:"af-modal-field",children:[e.jsx("label",{className:"af-modal-field-label",htmlFor:n,children:t}),e.jsx("select",{id:n,className:"af-select",value:s,onChange:o=>r(o.target.value),children:a.map(o=>e.jsx("option",{value:o,children:ai(o)},o))})]})}function ri({company:t,onConsented:a,onClose:s,extraFields:r}){const n=c.useId(),[o,i]=c.useState(Se),[l,m]=c.useState(Se),[d,y]=c.useState(Se),[f,w]=c.useState(Se),[g,H]=c.useState(!1),[I,P]=c.useState(null);c.useEffect(()=>{const N=j=>{j.key==="Escape"&&!g&&s()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[s,g]);async function D(){H(!0),P(null);const N={raceEthnicity:o===Se?["prefer_not_to_say"]:[o],gender:l,veteranStatus:d,disabilityStatus:f};try{await si({data:{eeo:N}}),a()}catch{P("Something went wrong saving your consent. Please try again."),H(!1)}}return e.jsx("div",{className:"af-modal-backdrop",onClick:N=>{N.target===N.currentTarget&&!g&&s()},children:e.jsxs("div",{className:"af-modal af-modal-refine af-modal-autoapply",role:"dialog","aria-modal":"true","aria-labelledby":n,children:[e.jsx("button",{className:"af-modal-close",type:"button",onClick:s,"aria-label":"Close",disabled:g,"data-amp-track-surface":"auto_apply","data-amp-track-action":"gate_dism
6iss",children:e.jsx(Xe,{})}),e.jsxs("div",{className:"af-modal-head",children:[e.jsxs("div",{className:"af-modal-eyebrow purple",children:[e.jsx(rr,{size:13}),"Apply for me"]}),e.jsxs("h2",{id:n,className:"af-modal-title",children:["Let Chegg apply to ",t?e.jsx("b",{children:t}):"this role"," for you?"]}),e.jsx("p",{className:"af-modal-reason",children:"Chegg will fill the application from your profile and resume, then show you everything to review before anything is submitted â you always click the final submit. These optional questions are asked by many employers; your answers stay private and are never used for anything else."})]}),e.jsxs("div",{className:"af-modal-body",children:[e.jsx(Ue,{label:"Race / ethnicity",options:La,value:o,onChange:i}),e.jsx(Ue,{label:"Gender",options:Pa,value:l,onChange:m}),e.jsx(Ue,{label:"Veteran status",options:Oa,value:d,onChange:y}),e.jsx(Ue,{label:"Disability status",options:qa,value:f,onChange:w}),r,I?e.jsx("p",{className:"af-modal-reason",role:"alert",children:I}):null]}),e.jsxs("div",{className:"af-modal-foot",children:[e.jsx("div",{className:"af-modal-foot-left",children:e.jsx(S,{type:"button",variant:"outline",onClick:s,disabled:g,"data-amp-track-surface":"auto_apply","data-amp-track-action":"gate_dismiss",children:"Not yet"})}),e.jsx("div",{className:"af-modal-foot-right",children:e.jsxs(S,{type:"button",variant:"orange",onClick:D,disabled:g,"data-amp-track-surface":"auto_apply","data-amp-track-action":"gate_confirm",children:[e.jsx(jt,{size:14,sw:2}),g?"Savingâ¦":"Apply on my behalf"]})})]})]})})}function ni(){const{data:t,isSuccess:a}=T(Sa()),s=hr("auto_apply_gate"),[r,n]=c.useState(null);return c.useEffect(()=>{a&&r===null&&n(xr(t??{}))},[a,t,r]),!r||r.length===0?null:e.jsxs("div",{className:"af-modal-field","data-testid":"gate-standard-answers",children:[e.jsx("div",{className:"af-modal-field-label",children:"A few questions most applications ask"}),e.jsx("p",{className:"mb-2 text-[11.5px] leading-[1.45] text-text-muted",children:"Answer once and Chegg fills these on every application. You can change them anytime in your profile."}),e.jsx(Nr,{keys:r,answers:t??{},onCommit:s})]})}const ii=420,oi=1e3;function li(t){return t==="NO_APPLY_URL"?"We couldn't find this posting's application link.":t==="NO_RESUME"?"Add a resume before applying â we need one to send with your application.":t==="ALREADY_REQUESTED"?"You've already asked us to apply to this job â check the tracker for where it stands.":"Something went wrong. Please try again."}function na(t){return t==="ALREADY_REQUESTED"?"You've already asked":"Something went wrong"}const ci=1e3;function ft(t){return{queryKey:["assisted-apply-request",t],queryFn:()=>ba({data:{jobId:t}})}}function di({jobId:t,company:a,applyUrl:s,onClose:r,onApplied:n}){const[o,i]=c.useState({kind:"starting"}),[l,m]=c.useState(!1),[d,y]=c.useState(""),[f,w]=c.useState(0),g=c.useRef(!1),[H,I]=c.useState(!1),P=c.useRef(null),D=c.useRef(Date.now()),N=c.useRef(null),j=c.useRef(!0);c.useEffect(()=>()=>{j.current=!1,P.current&&clearTimeout(P.current),N.current&&clearTimeout(N.current)},[]);function O(){H||(I(!0),P.current=setTimeout(r,ii))}const E=H?"af-modal-backdrop af-modal-closing":"af-modal-backdrop",{data:X,isSuccess:A,isError:V}=T(Sa()),{data:$,isSuccess:J}=T(yr()),{answered:se,total:F}=ut($,X),p=F-se,k=A&&J&&p===0&&!Sr($,X),z=new Date,re=x=>String(x).padStart(2,"0"),Z=`${re(z.getMonth()+1)}/${re(z.getDate())}/${z.getFullYear()}`,de=ce(),K=T({...ft(t),refetchInterval:fa(x=>{const v=x.state.data?.request?.status;return v&&!ha(v)?8e3:!1})});async function L(){m(!0);try{const x=await Ys({data:{jobId:t,applyUrl:s}});if(x.ok&&x.request){try{ae("assisted_apply_request_queued",{jobId:t,requestId:x.request.id,requestReused:x.requestReused??!1,ats:vs(x.request.applyUrl)})}catch{}n?.(),i({kind:"applied"})}else if(!x.ok&&x.error.code==="NEEDS_CONSENT")i({kind:"gate"});else{const v=x.ok?null:x.error.code;i({kind:"error",title:na(v),message:li(v)})}}catch{i({kind:"error",title:na(null),message:"We couldn't set up your application. Please try again."})}finally{m(!1)}}c.useEffect(()=>{if(g.current||!A&&!V||!J)return;g.current=!0;const x=async()=>{const M=ft(t).queryKey,_=()=>de.getQueryData(M);let G=_();if(!G?.request)try{G=await de.fetchQuery({...ft(t),staleTime:0})}catch{G=_()}if(!j.current)return;const Y=G?.request;if(Y){i({kind:"status",request:Y,events:G?.events??[]});return}const R=ut($,X);R.answered<R.total?i({kind:"collect"}):L()},v=oi-(Date.now()-D.current);v>0?N.current=setTimeout(()=>{x()},v):x()},[A,V,J]),c.useEffect(()=>{if(o.kind!=="applied")return;const x=setTimeout(()=>
6O(),ci);return()=>clearTimeout(x)},[o.kind]),c.useEffect(()=>{const x=K.data;if(!x?.request)return;const{request:v}=x;i(M=>M.kind==="status"?{kind:"status",request:v,events:x.events}:M)},[K.data]);function C(){K.refetch(),wt(de,{notifications:!0})}async function ee(x){if(!d.trim())return;m(!0);const v=await Hs({data:{requestId:x,answer:d.trim()}});m(!1),v.ok?(y(""),C(),O()):v.error.code==="WRONG_STATE"&&(C(),O())}if(o.kind==="collect")return e.jsx("div",{className:E,children:e.jsxs("div",{className:"af-modal af-modal-autoapply aaq-modal",role:"dialog","aria-modal":"true",children:[e.jsxs("div",{className:"af-modal-head",children:[e.jsxs("div",{className:"aaq-eyebrow",children:[e.jsx("span",{className:"aaq-eyebrow-dot","aria-hidden":!0}),e.jsx("span",{className:"aaq-eyebrow-label",children:"Apply for me"})]}),e.jsx("h2",{className:"af-modal-title",children:"A few quick questions first"}),e.jsx("p",{className:"af-modal-reason",children:"Answer these once and Chegg fills them in on every application. You can edit them anytime in your profile."}),e.jsxs("div",{className:"aaq-progress",children:[e.jsxs("div",{className:"aaq-progress-label",children:[se," of ",F," required answered"]}),e.jsx("div",{className:"aaq-progress-track",children:e.jsx("div",{className:"aaq-progress-fill",style:{width:`${Math.round(se/F*100)}%`}})})]})]}),e.jsx("div",{className:"af-modal-body",children:e.jsx(Er,{today:Z,submitAttempt:f})}),e.jsxs("div",{className:"af-modal-foot",children:[e.jsx("div",{className:"af-modal-foot-left",children:e.jsx(S,{type:"button",variant:"outline",onClick:()=>O(),"data-amp-track-surface":"assisted_apply","data-amp-track-action":"collect_dismiss",children:"Cancel"})}),e.jsxs("div",{className:"af-modal-foot-right",children:[k?null:e.jsxs("span",{className:"aaq-foot-left-count",children:[p," left"]}),e.jsx("button",{type:"button",className:k?"aaq-primary":"aaq-primary aaq-primary-incomplete",disabled:l,onClick:()=>{if(!k){w(x=>x+1);return}L()},...k?{"data-amp-track-surface":"assisted_apply","data-amp-track-action":"request"}:{},children:"Apply for me"})]})]})]})});if(o.kind==="applied")return e.jsx("div",{className:E,children:e.jsx("div",{className:"af-modal af-modal-refine af-modal-autoapply aa-applied",role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"af-modal-head aa-applied-head",children:[e.jsx("div",{className:"aa-applied-check","aria-hidden":!0,children:e.jsx(Ze,{size:22,sw:2.6})}),e.jsx("h2",{className:"af-modal-title",children:"Applied"}),e.jsx("p",{className:"af-modal-reason",children:a?e.jsxs(e.Fragment,{children:["We applied to ",e.jsx("b",{children:a})," for you."]}):"We applied for you."})]})})});if(o.kind==="gate")return e.jsx(ri,{company:a,onConsented:()=>{L()},onClose:r,extraFields:e.jsx(ni,{})});if(o.kind==="error")return e.jsx("div",{className:E,children:e.jsxs("div",{className:"af-modal af-modal-refine af-modal-autoapply",role:"dialog","aria-modal":"true",children:[e.jsxs("div",{className:"af-modal-head",children:[e.jsxs("div",{className:"af-modal-eyebrow purple",children:[e.jsx(jt,{size:13,sw:2}),"Apply for me"]}),e.jsx("h2",{className:"af-modal-title",children:o.title}),e.jsx("p",{className:"af-modal-reason",children:o.message})]}),e.jsx("div",{className:"af-modal-foot",children:e.jsx("div",{className:"af-modal-foot-right",children:e.jsx(S,{type:"button",variant:"orange",onClick:()=>O(),"data-amp-track-surface":"assisted_apply","data-amp-track-action":"dismiss",children:"Close"})})})]})});if(o.kind==="status"){const{request:x,events:v}=o,M=ys(x.status),_=x.status==="needs_info"&&v.some(Y=>Y.actor==="csr"&&Y.eventType==="question"&&!!Y.message?.trim()),G=gs(x.status);return e.jsx("div",{className:E,children:e.jsxs("div",{className:"af-modal af-modal-refine af-modal-autoapply",role:"dialog","aria-modal":"true",children:[e.jsxs("div",{className:"af-modal-head",children:[e.jsxs("div",{className:"af-modal-eyebrow purple",children:[e.jsx(jt,{size:13,sw:2}),"Apply for me"]}),e.jsxs("h2",{className:"af-modal-title",children:[a?e.jsx("b",{children:a}):"Your application",x.roleTitle?` â ${x.roleTitle}`:""]}),e.jsx("div",{className:"mt-2 mb-1.5",children:e.jsx("span",{className:`aa-status-chip aa-status-${M.tone}`,children:M.label})}),e.jsx("p",{className:"af-modal-reason",children:M.description})]}),e.jsxs("div",{className:"af-modal-body",children:[_?e.jsxs("div",{className:"af-modal-field",children:[e.jsx("div",{className:"af-modal-field-label",children:"Questions & answers"}),e.jsx(ei,{events:v}),e.jsx("textarea",{className:"af-textarea",rows:3,value:d,onChange:Y=>y(Y.target.value),placeholder:"Type your answerâ¦","aria-label":"Your answer"})]}
6):null,x.status==="cannot_complete"&&x.outcomeReason?e.jsxs("div",{className:"af-modal-field",children:[e.jsx("div",{className:"af-modal-field-label",children:"What happened"}),e.jsx("p",{className:"text-[12.5px] leading-[1.5] text-text",children:x.outcomeReason})]}):null]}),e.jsxs("div",{className:"af-modal-foot",children:[e.jsx("div",{className:"af-modal-foot-left",children:_||G?e.jsx(S,{type:"button",variant:"outline",disabled:l,onClick:()=>O(),"data-amp-track-surface":"assisted_apply","data-amp-track-action":"dismiss",children:_?"Cancel":"Not now"}):null}),e.jsx("div",{className:"af-modal-foot-right",children:_?e.jsx(S,{type:"button",variant:"orange",disabled:l||!d.trim(),onClick:()=>{ee(x.id)},"data-amp-track-surface":"assisted_apply","data-amp-track-action":"answer",children:"Send answer"}):G?e.jsx(S,{type:"button",variant:"orange",disabled:l,onClick:()=>{const Y=ut($,X);Y.answered<Y.total?i({kind:"collect"}):L()},"data-amp-track-surface":"assisted_apply","data-amp-track-action":"ask_again",children:"Ask again"}):e.jsx(S,{type:"button",variant:"orange",onClick:()=>O(),"data-amp-track-surface":"assisted_apply","data-amp-track-action":"dismiss",children:"Done"})})]})]})})}return e.jsx("div",{className:E,children:e.jsx("div",{className:"af-modal af-modal-refine af-modal-autoapply",role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"af-modal-head",children:[e.jsxs("div",{className:"af-modal-eyebrow purple",children:[e.jsx("span",{className:"af-sum-pulse","aria-hidden":"true"}),"Apply for me"]}),e.jsx("h2",{className:"af-modal-title",children:"Setting things upâ¦"})]})})})}const ia={company:"Stripe",role:"Software Engineer Intern â Payments Reliability",location:"South San Francisco, CA",arrangement:"On-site · Summer 2026",applyUrl:"stripe.com/jobs/listing/se-intern-pr",facts:[{label:"Location",value:"South San Francisco, CA",meta:"On-site"},{label:"Term",value:"Summer 2026",meta:"12 weeks · Jun â Aug"},{label:"Hours",value:"Full-time",meta:"~40 hrs/wk"},{label:"Pay",value:"$52â60/hr",meta:"+ housing stipend"},{label:"Deadline",value:"Rolling",meta:"Posted 6 days ago"},{label:"Visa",value:"Sponsored",meta:"OPT/CPT ok"}],insights:{asking:["Production systems work in Go: services, metrics, on-call rotation.","Ownership instincts â ship a feature in your first month, then keep it healthy.","Comfort with the reliability mindset: SLOs, error budgets, postmortems."],profileFit:["Your Linode internship and Ledger project map directly to the production-systems bullets.","Listing âsome Goâ on Skills will read as light; Chegg promoted it to Go in the tailored draft.","No prior payments-domain experience â fine for an intern, but the cover letter should acknowledge it."]},jd:{bullets:["Build and operate distributed systems that process millions of payment events per second.","Write production-grade Go and Ruby; contribute to services owned end-to-end by small teams.","Instrument services â metrics, logs, and traces â and drive SLO work that keeps payments reliable.","Own incident response during on-call; write postmortems that lead to durable fixes.","Collaborate across product, design, and risk; ship a real feature in your first month."]},description:{sections:[{heading:"About the role",paragraphs:["Stripe builds economic infrastructure for the internet. Our Payments Reliability team owns the services that route, retry, and settle every transaction Stripe processes â a stream that grew past a million events per second in 2025.","As a Software Engineering Intern on Payments Reliability, youâll embed with a small team and own real production work. You will write Go, instrument services, sit on-call alongside your mentor, and ship a feature that runs in customer-facing infrastructure before your internship ends."]},{heading:"What you'll do",bullets:["Build and operate distributed systems that process millions of payment events per second.","Write production-grade Go and Ruby; contribute to services owned end-to-end by small teams.","Instrument services â metrics, logs, and traces â and drive SLO work that keeps payments reliable.","Own incident response during on-call; write postmortems that lead to durable fixes.","Collaborate across product, design, and risk; ship a real feature in your first month."]},{heading:"What we're looking for",bullets:["Currently pursuing a B.S. or M.S. in Computer Science or related field; available full-time for Summer 2026.","Comfortable in at least one production-grade language (Go, Ruby, Rust, Java, or similar).","Curiosity about how distributed systems break â and how to make them fail less often.","Communicates clearly in writing; comfortable owning a small piece of a larger system."]},{heading:"Nice to have",bullets:["Prior internship or open-source experience with backend services.","Exposure to observability tooling â Prometheus, Grafana, distributed tracing.","Familiarity with the language of reliability: SLOs, error budgets, postmortems."]},{heading:"Logistics",paragraphs:["Summer 2026 cohort, 12 weeks, starting early June. Based on-site in South San Francisco with a corporate-housing stipend for relocating interns. Pay range $52â60/hr depending on year and program. Visa sponsorship available for OPT/CPT."]}]}},Ia="this employer";function ui(t){return t===Ia?"":t}function mi(t){return t?{...ia,company:t.company_name?.trim()||Ia,role:t.title??"",location:t.location??"",applyUrl:t.application_url??""}:ia}const pi={applied:"Applied",interviewing:"Interviewing",offer:"Offer received",rejected:"Heard back · not moving forward",withdrawn:"Withdrew"},fi="Add a resume before applying â Chegg sends your tailored resume with every application.",hi="Still reading your new resume â this unlocks as soon as it lands.",oa=new Set;function xi({live:t,job:a,jobId:s,coresignalJobId:r,applyViaExtensionEnabled:n,extensionPresent:o,linkStatus:i,locked:l=!1,status:m,studentLastName:d,studentEmail:y,onApplyOnSite:f,onApplyForMe:w,onSendEmail:g,onArmReturnWatcher:H,resetHandoffSignal:I=0,onApplied:P,needsInfo:D=!1,applyForMeSupported:N,resumeMissing:j=!1,resumeUploadPending:O=!1}){const E=i==="dead",X=E||j,A=E?`${a.company}'s apply page isn't loading right now.`:void 0,V=O?hi:j?fi:A,$=qe(r),{requireMembership:J,isPaywalled:se}=He(),F=se("apply_for_me"),p=se("resume_tailoring"),[k,z]=c.useState(null),[re,Z]=c.useState(!1),[de,K]=c.useState(!1),L=va(js,{when:t&&!l})==="on",ee=gr(a.applyUrl)!==null?"&grant=1":"",x=L||(N??Vr([{url:a.applyUrl}])!==null),v=!$&&x;c.useEffect(()=>{t||z(null)},[t]),c.useEffect(()=>{if(!t||l||k!==null)return;const b=`${s}:${j?"no_resume":"ok"}`;oa.has(b)||(oa.add(b),ae("apply_choice_shown",{jobId:s,applyForMeOffered:v&&!j,suppressedReason:$?"extension_job":x?j?"no_resume":"none":"unsupported_ats",ats:xt(a.applyUrl)??"unknown"}))},[s,t,l,k,$,x,v,j,a.applyUrl]),c.useEffect(()=>{I>0&&z(null)},[I]);const M=r??s,_=re?e.jsx(di,{jobId:M,company:a.company,applyUrl:a.applyUrl,onClose:()=>Z(!1),onApplied:P}):null;if(!t)return e.jsx("section",{className:"af-ready dormant",children:e.jsxs("div",{className:"af-ready-inner-dormant",children:[e.jsx("div",{className:"af-ready-dormant-row",children:e.jsxs("div",{children:[e.jsx("div",{className:"af-ready-dormant-title",children:"Once both
6steps are saved, you'll land here."}),e.jsxs("div",{className:"af-ready-dormant-sub",children:["You'll get your resume and cover letter as files, then one button to submit on ",a.company,"'s site."]})]})}),e.jsxs("ul",{className:"af-ready-dormant-checklist",children:[e.jsxs("li",{children:[e.jsx("span",{className:"box"}),e.jsx("span",{children:"Tailored resume.pdf"})]}),e.jsxs("li",{children:[e.jsx("span",{className:"box"}),e.jsx("span",{children:"Cover letter.pdf"})]})]})]})});if(l){const b=(m&&pi[m])??"Application submitted";return e.jsxs("section",{className:"af-ready live submitted",children:[e.jsxs("div",{className:"af-ready-inner-active",children:[e.jsxs("div",{className:`af-ready-eyebrow${m==="rejected"?" red":m==="withdrawn"?" yellow":""}`,children:[e.jsx("span",{className:"dot"}),b]}),e.jsxs("h2",{className:"af-ready-headline",children:["You applied to ",a.company,"."]}),e.jsx("p",{className:"af-ready-sub",children:p?"Your base resume is saved here. Use the cards above to see what you sent.":"Your tailored resume and cover letter are saved here. Use the cards above to view or download what you sent."}),D&&e.jsxs("div",{className:"af-ready-warning",children:[e.jsx(dt,{}),e.jsx("span",{children:e.jsx("b",{children:"We need one more answer to finish your application."})}),e.jsx(S,{type:"button",variant:"orange-outline",onClick:()=>Z(!0),"data-amp-track-surface":"assisted_apply","data-amp-track-action":"answer_reopen",children:"Answer"})]})]}),_]})}const G=new Date,Y=ui(a.company),R={resume:mt({lastName:d,company:Y,type:"Resume",tailoredOn:G}),cover:mt({lastName:d,company:Y,type:"Cover-Letter",tailoredOn:G}),bundle:mt({lastName:d,company:Y,type:"Application",tailoredOn:G,ext:"zip"})},oe=()=>{if(E)return;const b=vr(a.applyUrl);b&&(f({jobId:s,filenames:R}),window.open(b,"_blank","noopener,noreferrer"),ae("apply_handoff_opened",{jobId:s,linkStatus:i}),H?.(),z("submitted"))},Q=()=>{if(!E){if(!o){K(!0),ae("apply_via_extension_blocked",{jobId:r,reason:"no_extension"});return}if(r<=0){oe();return}window.open(`/apply-launch?job=${r}${ee}`,"_blank","noopener,noreferrer")}},he=()=>{J("apply_for_me",()=>Z(!0))},ge=()=>{f({jobId:s,filenames:R})};return k==="submitted"?e.jsx("section",{className:"af-ready live submitted",children:e.jsxs("div",{className:"af-ready-inner-active",children:[e.jsxs("div",{className:"af-ready-eyebrow",children:[e.jsx("span",{className:"dot"}),"Handed off"]}),e.jsx("h2",{className:"af-ready-headline",children:p?"Opened in a new tab.":$?"Opened in a new tab. Files downloaded.":"Opened in a new tab. Bundle downloaded."}),e.jsx("p",{className:"af-ready-sub",children:p?e.jsxs(e.Fragment,{children:["We opened ",a.company,"'s application page. Apply with your resume there, then come back here and mark this ",e.jsx("b",{children:"Applied"}),"."]}):$?e.jsxs(e.Fragment,{children:["We opened ",a.company,"'s application page and downloaded your tailored resume and cover letter as two separate PDF files. Upload them on ",a.company,"'s form when prompted, then come back here and mark this ",e.jsx("b",{children:"Applied"}),"."]}):e.jsxs(e.Fragment,{children:["We opened ",a.company,"'s application page and saved your tailored materials to your downloads as a zip. Unzip it, upload the two files on ",a.company,"'s form when prompted, then come back here and mark this ",e.jsx("b",{children:"Applied"}),"."]})}),!p&&e.jsx("div",{className:"af-submitted-card",children:e.jsxs("div",{className:"af-submitted-row",children:[e.jsx("span",{className:"af-submitted-step done",children:e.jsx(Ze,{size:13,sw:2.6})}),e.jsxs("div",{children:[e.jsx("div",{className:"af-submitted-title",children:$?R.resume:R.bundle}),e.jsx("div",{className:"af-submitted-sub",children:$?`+ ${R.cover}`:`Contains ${R.resume} · ${R.cover}`})]}),e.jsx(S,{variant:"ghost",size:"icon-sm",type:"button",onClick:ge,"aria-label":$?"Download resume and cover letter again":"Download application bundle again","data-amp-track-surface":"apply","data-amp-track-action":"download","data-amp-track-target":"application_bundle",children:e.jsx(nr,{size:14,sw:2})})]})}),e.jsxs("div",{className:"af-submitted-foot",children:[e.jsxs(S,{variant:"ghost",type:"button",onClick:()=>z(null),"data-amp-track-surface":"apply","data-amp-track-action":"back",children:[e.jsx(ka,{size:14}),"Back"]}),e.jsx("span",{className:"af-submitted-foot-spacer"}),e.jsx(Zt,{disabled:E,hint:A,children:e.jsxs(S,{variant:"orange-outline",type:"button",onClick:oe,disabled:E,title:A,"data-amp-track-surface":"apply","data-amp-track-action":"external_open","data-amp-track-target":"company_apply_page",children:["Open job posting again",e.jsx(vt,{size:14,sw:2})]})})]})]})}):e.jsxs("section",{className:"af-ready live",children:[e.jsxs("div",{className:"af-ready-inner-active",children:[e.jsx("h2",{className:"af-ready-headline",children:j?`Add a resume to apply to ${a.company}.`:`You're ready to apply to ${a.company}.`}),e.jsx("p",{className:"af-ready-sub",children:j?"Chegg sends your tailored resume with every application, so it needs a resume to send.":p?"You're applying with your base resume and no cover letter. How do you want to apply?":"Your tailored resume and cover letter are ready. How do you want to apply?"}),e.jsx(Xn,{}),j&&e.jsxs("div",{className:"af-ready-warning","data-testid":"apply-no-resume-warning",children:[e.jsx(dt,{}),e.jsxs("span",{children:[e.jsx("b",{children:"No resume on file."})," Add your resume and Chegg will tailor it for this role â then both apply options open up."]})]}),E&&e.jsxs("div",{className:"af-ready-warning",children:[e.jsx(dt,{}),e.jsxs("span",{children:[e.jsxs("b",{children:["Couldn't verify ",a.company,"'s application page."]})," ","Submitting on the site is unavailable right now â try again later."]})]}),e.jsx("div",{className:"af-submit-actions",children:n?e.jsxs(e.Fragment,{children:[e.jsx(Zt,{disabled:X,hint:V,children:e.jsxs(S,{type:"button",variant:"orange",onClick:Q,disabled:X,title:V,"data-amp-track-surface":"apply","data-amp-track-action":"apply_via_extension","data-amp-track-target":"browser_extension",children:["Apply manually",e.jsx(vt,{size:14,sw:2})]})}),v&&e.jsx(Jt,{onClick:he,jobId:s,disabled:j,title:j?V:void 0,locked:F})]}):e.jsxs(e.Fragment,{children:[e.jsx(Na,{onClick:oe,disabled:X,title:V}),v&&e.jsx(Jt,{onClick:he,jobId:s,disabled:j,title:j?V:void 0,locked:F})]})}),n&&!o&&e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[e.jsx("a",{href:Ht,target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-purple underline",onClick:()=>Vt(),"data-amp-track-surface":"apply","data-amp-track-action":"install_extension",children:"Install the Chegg extension"})," ","to auto-fill applications."]})]}),_,de&&e.jsx(Zn,{company:a.company,installUrl:Ht,onInstallClick:()=>Vt(),onApplyYourself:()=>{K(!1),oe()},onClose:()=>K(!1)})]})}const yi={add:"Added bullet",rewrite:"Reworded bullet",keyword:"Keyword"};function gi({report:t}){const[a,s]=c.useState(!0);if(!t||t.entries.length===0)return null;const{entries:r,keptAfterRegenCount:n,droppedAgainCount:o}=t;return e.jsxs("section",{"data-testid":"grounding-report-panel",className:"rounded-xl border border-hairline bg-surface p-3",children:[e.jsxs("button",{type:"button",onClick:()=>s(i=>!i),"aria-expanded":a,"data-amp-track-surface":"tracker","data-amp-track-action":"toggle","data-amp-track-target":"grounding_report",className:"flex w-full items-center justify-between text-left",children:[e.jsxs("span",{className:"text-sm font-semibold text-text-strong",children:["Bullets reworked for grounding (",r.length,")"]}),e.jsxs("span",{className:"text-xs text-text-muted",children:[e.jsxs("span",{className:"text-success",children:[n," kept"]})," · ",e.jsxs("span",{className:"text-warning",children:[o," removed again"]}),e.jsx("span",{className:"ml-2","aria-hidden":"true",children:a?"â¾":"â¸"})]})]}),a&&e.jsx("ul",{className:"mt-3 space-y-3",children:r.map((i,l)=>e.jsx(vi,{entry:i},`${i.targetBlockId}-${l}`))})]})}function vi({entry:t}){const a=t.verdict==="kept";return e.jsxs("li",{"data-testid":"grounding-report-row",className:`rounded-lg border p-2.5 ${a?"border-success-tint bg-success-tint":"border-warning bg-warning-tint"}`,children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-text-muted",children:yi[t.kind]}),e.jsx("span",{"data-testid":"grounding-report-verdict",className:`text-xs font-semibold ${a?"text-success":"text-warning"}`,children:a?"Kept after rewrite":"Removed again"})]}),e.jsxs("p",{className:"text-sm text-text-muted",children:[e.jsx("span",{className:"text-text-strong",children:"Originally removed:"})," ",e.jsx("span",{className:"line-through",children:t.originalText})]}),t.regeneratedText?e.jsxs("p",{className:"mt-1 text-sm text-text-strong",children:[e.jsx("span",{className:"text-text-muted",children:"Rewritten as:"})," ",t.regeneratedText]}):e.jsx("p",{className:"mt-1 text-sm italic text-text-muted",children:"Couldn't be rewritten without going beyond your resume â left out."})]})}function Ma({pending:t,accepted:a,rejected:s,onAcceptAll:r,disabled:n,failed:o=0,onRetryFailed:i}){const l=a+s,m=t>0,d=o>0;return e.jsxs("div",{"data-testid":"review-header-band",className:"flex flex-col gap-2 rounded-md border border-hairline bg-surface-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-sm text-text",children:m?e.jsxs(e.Fragment,{children:[e.jsx("b",{className:"font-semibold text-text-strong",children:t})," ",t===1?"change":"changes"," to review"]}):e.jsxs(e.Fragment,{children:["All ",e.jsx("b",{className:"font-semibold text-text-strong",children:l})," ","resolved â"," ",e.jsx("b",{className:"font-semibold text-text-strong",children:a})," ","accepted,"," ",e.jsx("b",{className:"font-semibold text-text-strong",children:s})," ","declined"]})}),e.jsx(S,{type:"button",variant:"agent",size:"sm","data-testid":"review-header-accept-all","data-amp-track-surface":"tracker","data-amp-track-action":"accept_all",disabled:!m||n,onClick:r,children:m?`Accept all ${t} ${t===1?"change":"changes"}`:"Accept all"})]}),d&&e.jsxs("div",{"data-testid":"review-header-failed",className:"flex items-center justify-between gap-3 rounded-md border border-destructive/30 bg-destructive/5 px-2.5 py-1.5",children:[e.jsxs("p",{className:"text-sm text-destructive",children:[e.jsx("b",{className:"font-semibold",children:o})," ",o===1?"change":"changes"," couldn't be saved"]}),e.jsx(S,{type:"button",variant:"outline",size:"sm","data-testid":"review-header-retry-failed","data-amp-track-surface":"tracker","data-amp-track-action":"retry",onClick:i,children:"Retry"})]})]})}function ji({tailoredResumeId:t,readOnly:a=!1}){const s=T(bs(t)),r=T(Ce(t)),n=Is("tailored_edit",{tailoredResumeId:t},{initialData:()=>r.data?.map(Cr)}),o=T(Ge()),i=T(xa()),l=ce(),m=Ms("tailored_edit"),d=Ds("tailored_edit"),y=ja(t),f=Ks(t),w=Us(t),[g]=c.useState(()=>sn(t)),[H,I]=c.useState(new Set),P=p=>I(k=>new Set(k).add(p)),D=p=>I(k=>{if(!k.has(p))return k;const z=new Set(k);return z.delete(p),z}),N=()=>l.invalidateQueries({queryKey:$s("tailored_edit")});if(n.isLoading||s.isLoading)return e.jsxs("div",{"data-testid":"inline-chip-review-skeleton",className:"animate-pulse space-y-2",children:[e.jsx("div",{className:"h-3 w-40 rounded bg-gray-200"}),e.jsx("div",{className:"h-24 rounded bg-gray-100"})]});if(n.isError&&!n.data)return e.jsxs("div",{"data-testid":"inline-chip-review-error",className:"flex items-center justify-between rounded-xl border border-hairline p-3",children:[e.jsx("p",{className:"text-sm text-text-strong",children:"Couldn't load the tailored changes for this resume."}),e.jsx("button",{type:"button","data-testid":"inline-chip-review-retry",onClick:()=>n.refetch(),className:"rounded-md bg-accent px-3 py-1.5 text-xs font-semibold text-white hover:bg-orange-hover",children:"Retry"})]});if(!s.data)return e.jsxs("div",{"data-testid":"inline-chip-review-skeleton",className:"animate-pulse space-y-2",children:[e.jsx("div",{className:"h-3 w-40 rounded bg-gray-200"}),e.jsx("div",{className:"h-24 rounded bg-gray-100"})]});const j=(n.data??[]).map(Ar),O=j.filter(p=>p.status==="pending").length,E=j.filter(p=>p.status==="accepted").length,X=j.filter(p=>p.status==="rejected").length,A=j.filter(p=>p.status==="pending"&&H.has(p.id)).map(p=>p.id),V=ya(s.data,{name:o.data?.name??null,email:o.data?.email??null}),$=(p,k)=>{const z=j.find(re=>re.id===p);z&&ae("tailored_edit_resolved",{tailoredResumeId:t,tailoredEditId:p,kind:z.kind,decision:k})},J=p=>{m.mutate(String(p),{onSuccess:()=>{$(p,"accepted"),D(p)},onError:()=>P(p)})},se=p=>{D(p),d.mutate(String(p),{onSuccess:()=>$(p,"rejected")})},F=()=>{for(const p of A)J(p)};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(gi,{report:g}),!a&&(j.length>0?e.jsx(Ma,{pending:O,accepted:E,rejected:X,failed:A.length,disabled:y.isPending,onAcceptAll:()=>y.mutate(void 0),onRetryFailed:F}):e.jsx("p",{"data-testid":"inline-chip-review-empty",className:"text-sm text-text-muted",children:"No changes to review â your tailored resume is ready as-is."})),e.jsx(St,{base:V,edits:j,readOnly:a,template:i.data??void 0,onAccept:J,onReject:se,onRephrase:p=>f.mutate({editId:p},{onSettled:N}),onSetEditText:(p,k)=>w.mutate({editId:p,text:k},{onSettled:N})})]})}const la=()=>{};function bi({job:t,resume:a,edits:s,readOnly:r,template:n}){const o=Ve(t.job_id),i=fn(o),l=xn(o);return e.jsx(St,{base:a,edits:s,readOnly:r,template:n,onAccept:r?la:m=>i.mutate({editId:m,status:"accepted"}),onReject:r?la:m=>i.mutate({editId:m,status:"rejected"}),onSetEditText:r?void 0:(m,d)=>l.mutate({editId:m,text:d})})}function Nt({message:t="Reviewing your resume for changesâ¦"}){return e.jsxs("output",{"data-testid":"resume-processing-loader","aria-live":"polite",className:"flex items-center gap-3 rounded-lg bg-purple-04 px-4 py-3 text-sm text-text-muted",children:[e.jsx(_t,{className:"size-5 shrink-0 text-purple"}),e.jsx("span",{children:t})]})}const ht=()=>{};function $e({tailoredResumeId:t,pending:a,baseResume:s,user:r,readOnly:n=!1,job:o}){const i=T(xa());return typeof t=="number"&&t>0?e.jsx(ji,{tailoredResumeId:t,readOnly:n}):o&&qe(o.job_id)?e.jsx(wi,{job:o,readOnly:n,pending:a,baseResume:s,user:r,template:i.data??void 0}):e.jsx(Da,{pending:a,baseResume:s,user:r,template:i.data??void 0})}function wi({job:t,readOnly:a,pending:s,baseResume:r,user:n,template:o}){const{resume:i,edits:l,status:m}=Aa(t),d=Ca(Ve(t.job_id));if(m==="ready"&&i){const y=l.filter(g=>g.status==="pending").length,f=l.filter(g=>g.status==="accepted").length,w=l.filter(g=>g.status==="rejected").length;return e.jsxs("div",{className:"space-y-3",children:[!a&&l.length>0&&e.jsx(Ma,{pending:y,accepted:f,rejected:w,disabled:d.isPending,onAcceptAll:()=>d.mutate(void 0)}),e.jsx(bi,{job:t,resume:i,edits:l,readOnly:a,template:o})]})}return e.jsx(Da,{pending:s||m==="tailoring"||m==="idle",baseResume:r,user:n,template:o})}function Da({pending:t,baseResume:a,user:s,template:r}){if(t||a===void 0)return e.jsx(Nt,{});if(a){const n=Rs(a,{name:s?.name??null,email:s?.email??null});if(n.sections.length>0)return e.jsx(St,{base:n,edits:[],readOnly:!0,template:r,onAccept:ht,onReject:ht,onRephrase:ht})}return e.jsx("p",{"data-testid":"apply-resume-empty",className:"text-sm text-text-muted",children:"Your resume isn't ready to preview yet. Upload your resume in y
6our profile to tailor it for this role."})}function Ni({state:t,job:a,trackerJob:s=null,tailoredResumeId:r,tailoredResumePending:n=!1,baseResume:o,user:i,tailoredEdits:l=null,onSave:m,onAcceptAll:d,onRejectAll:y,onDownload:f,onReDownload:w,locked:g=!1,materialsDownloaded:H=!1,resumeMissing:I=!1,onUploadResume:P,uploadInFlight:D=!1}){const[N,j]=c.useState(!1),[O,E]=c.useState(!1),X=c.useId(),A=c.useId(),V=c.useId(),$=c.useId(),J=c.useId(),se=c.useId(),[F,p]=c.useState("idle"),k=c.useRef(null);c.useEffect(()=>()=>{k.current!==null&&window.clearTimeout(k.current)},[]);const z=c.useRef(!1);c.useEffect(()=>{const b=z.current&&!D;if(z.current=D,!(!b||F!=="reading")){if(k.current!==null&&(window.clearTimeout(k.current),k.current=null),!I){p("idle");return}Ee("apply_resume_upload_failed",{surface:"apply_assembly",reason:"settled_without_content"}),p("error")}},[D,I,F]);const re=async b=>{if(P){p("reading"),k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{Ee("apply_resume_upload_failed",{surface:"apply_assembly",reason:"parse_budget_elapsed"}),p("error")},Vs);try{await P(b)}catch(h){k.current!==null&&(window.clearTimeout(k.current),k.current=null),Qe(h,{context:"apply-assembly-resume-upload"}),Ee("apply_resume_upload_failed",{surface:"apply_assembly",reason:"threw"}),p("error")}}},Z=F==="reading"||D;c.useEffect(()=>{t!=="done"&&E(!1)},[t]);const de=l!==null&&l.length===0,K=()=>{d?.(),m()},L=()=>{y?.(),m()},C=(l??[]).filter(b=>b.status!=="rejected"),ee=b=>C.filter(h=>h.kind===b).length,x=ee("rewrite"),v=ee("keyword"),M=ee("remove"),_=ee("add"),G=[];x>0&&G.push({key:"rewrite",node:e.jsxs(e.Fragment,{children:["Reworded ",e.jsx("span",{className:"num",children:x})," resume bullet",x===1?"":"s"," to lead with ownership and concrete numbers."]})}),v>0&&G.push({key:"keyword",node:e.jsxs(e.Fragment,{children:["Sharpened ",e.jsx("span",{className:"num",children:v})," detail",v===1?"":"s"," to match keywords from the job description."]})}),M>0&&G.push({key:"remove",node:e.jsxs(e.Fragment,{children:["Removed ",e.jsx("span",{className:"num",children:M})," bullet",M===1?"":"s"," that didn't fit this role."]})}),_>0&&G.push({key:"add",node:e.jsxs(e.Fragment,{children:["Added ",e.jsx("span",{className:"num",children:_})," skill",_===1?"":"s"," tied to the role."]})});const Y=G.length>0?G.map(b=>e.jsxs("li",{children:[e.jsx("span",{className:"glyph","aria-hidden":"true",children:"â"}),e.jsx("span",{children:b.node})]},b.key)):l===null?e.jsxs("li",{children:[e.jsx("span",{className:"glyph","aria-hidden":"true",children:"â"}),e.jsx("span",{children:"Couldn't load what changed for this role."})]}):e.jsxs("li",{children:[e.jsx("span",{className:"glyph","aria-hidden":"true",children:"â"}),e.jsx("span",{children:"You kept your resume as-is for this role."})]}),{isPaywalled:R,openPaywall:oe}=He(),Q=R("resume_tailoring"),he=Q&&C.length>0?e.jsxs("div",{className:"af-card-inline-review flex flex-col gap-3",children:[e.jsxs("div",{className:yt(Ns,"flex items-start gap-3 px-4 py-3.5"),children:[e.jsx(ws,{className:"mt-0.5 size-4 shrink-0 text-orange-press",strokeWidth:2,"aria-hidden":!0}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-bold text-sm text-text-strong",children:"This is a preview of your tailored resume"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Become a member for unlimited tailored resumes, one for every job you apply to."})]})]}),e.jsx($e,{tailoredResumeId:r,pending:n,baseResume:o,user:i,job:s}),e.jsx("p",{className:"text-sm text-text-muted",children:"Every change is marked on your resume above â open any to see why. Your finished, ready-to-download tailored resume is a member feature."})]}):null,ge=()=>E(b=>!b);if(I&&!g)return e.jsxs("article",{className:"af-card","aria-labelledby":J,children:[e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 1"}),e.jsx("h2",{id:J,className:"af-card-title",children:Z?`Reading your resume for ${a.company}.`:`Add a resume to apply to ${a.company}.`}),e.jsx("div",{className:"af-card-meta",children:e.jsx("span",{children:Z?"Reading your resume":"No resume on file"})}),e.jsxs("section",{className:"af-card-section",children:[e.jsx("div",{className:"mb-2 font-semibold text-base text-text-strong",children:"Chegg tailors your own resume for each role â so it needs one to start from."}),e.jsx("p",{className:"text-sm text-text-muted",children:Z?"Reading your resume. This takes a few seconds â you can stay right here.":F==="error"?"Couldn't read that file. PDF or Word exports work best â a scanned image or a locked PDF usually can't be read.":"Upload it here and Chegg will tailor it for this role â no need to leave this page."}),Z&&e.jsx("div",{className:"mt-3",children:e.jsx(Nt,{})}),F==="error"&&e.jsx("output",{className:"mt-3 block text-danger text-sm","data-testid":"apply-resume-upload-error",children:"Nothing was changed â your application is exactly as you left it. Try another file, or build a resume instead."})]})]}),e.jsx("footer",{className:"af-card-footer",children:e.jsx("div",{className:"af-card-footer-actions",children:P?e.jsxs(e.Fragment,{children:[e.jsx("input",{id:se,type:"file",accept:".pdf,.doc,.docx",className:"peer sr-only","data-testid":"apply-resume-upload-input",disabled:Z,onChange:b=>{const h=b.target.files?.[0];b.target.value="",h&&re(h)}}),e.jsx(S,{asChild:!0,variant:"orange",className:yt("peer-focus-visible:shadow-focus",Z&&"pointer-events-none opacity-60"),children:e.jsx("label",{htmlFor:se,"data-testid":"apply-resume-missing-cta","data-amp-track-surface":"apply","data-amp-track-action":"add_resume",onClick:()=>Ee("resume_upload_click",{surface:"apply_flow_blocker",source:"apply_resume_missing"}),children:F==="reading"?"Reading your resumeâ¦":F==="error"?"Try another file":"Upload your resume"})}),e.jsx(gt,{to:"/resume",className:Ln,"data-amp-track-surface":"apply","data-amp-track-action":"build_resume",children:"Or build one"})]}):e.jsx(S,{asChild:!0,variant:"orange",children:e.jsx(gt,{to:"/resume","data-testid":"apply-resume-missing-cta","data-amp-track-surface":"apply","data-amp-track-action":"add_resume",children:"Add your resume"})})})})]});if(n&&!g&&t!=="done")return e.jsx("article",{className:"af-card","aria-labelledby":$,children:e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 1"}),e.jsxs("h2",{id:$,className:"af-card-title",children:["Tailoring your resume for ",a.company,"â¦"]}),e.jsxs("div",{className:"af-card-meta",children:[e.jsx("span",{className:"af-card-pulse","aria-hidden":"true"}),e.jsx("span",{children:"Reviewing for changes"})]}),e.jsx("section",{className:"af-card-section",children:e.jsx(Nt,{})})]})});if(de&&!g&&t!=="done")return e.jsxs("article",{className:"af-card","aria-labelledby":X,children:[e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 1"}),e.jsxs("h2",{id:X,className:"af-card-title",children:["Resume reviewed for ",a.company,"."]}),e.jsxs("div",{className:"af-card-meta",children:[e.jsx("span",{className:"af-card-pulse","aria-hidden":"true"}),e.jsx("span",{children:"Draft 1 · just now"})]}),e.jsxs("section",{className:"af-card-section",children:[e.jsx("div",{className:"mb-2 font-semibold text-base text-text-strong",children:"Your resume reads well for this role â no rewrites needed."}),e.jsxs("ul",{className:"af-card-list",children:[e.jsxs("li",{children:[e.jsx("span",{className:"glyph","aria-hidden":"true",children:"â"}),e.jsx("span",{children:"Your most recent experience already speaks to this role's responsibilities."})]}),e.jsxs("li",{children:[e.jsx("span",{className:"glyph","aria-hidden":"true",children:"â"}),e.jsx("span",{children:"Your skills section covers the technologies the job description calls out."})]})]}),e.jsx("div",{className:"af-card-section-action",children:e.jsx("button",{type:"button",className:"af-link-quiet",onClick:()=>j(b=>!b),"aria-expanded":N,children:N?"Hide resume":"Review resume â"})}),N&&e.jsx("div",{className:"af-card-inline-review",children:e.jsx($e,{tailoredResumeId:r,pending:n,baseResume:o,user:i,readOnly:!0,job:s})})]})]}),e.jsx("footer",{className:"af-card-footer",children:e.jsxs("div",{className:"af-card-footer-actions",children:[e.jsx(S,{type:"button",variant:"orange",onClick:K,"data-amp-track-surface":"apply","data-amp-track-action":"review_save_next",children:"Save and next"}),e.jsx(Re,{onClick:()=>j(b=>!b),"aria-expanded":N,"data-amp-track-surface":"apply","data-amp-track-action":"review_edit",children:"Edit"})]})})]});if(t==="done"){const b=g?`Resume sent to ${a.company}`:"Resume reviewed";return e.jsx("article",{className:"af-card af-card--compact","aria-labelledby":A,children:e.jsxs("div",{className:"af-card-body",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(Le,{"aria-hidden":!0,strokeWidth:2.5,className:"size-4 shrink-0 text-success"}),e.jsx("h2",{id:A,className:"af-card-title af-card-title-inline",children:b})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[Q?e.jsx(wa,{feature:"resume_tailoring"}):H?e.jsxs("button",{type:"button",onClick:w,"aria-label":"Re-download","data-amp-track-surface":"apply","data-amp-track-action":"redownload",className:"group inline-flex cursor-pointer items-center gap-1.5 rounded-md border border-transparent bg-transparent px-3 py-1.5 font-semibold text-sm text-text-muted outline-none transition-colors duration-fast ease-
6out hover:text-text-strong focus-visible:text-text-strong focus-visible:shadow-focus",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 group-hover:hidden group-focus-visible:hidden",children:[e.jsx(Le,{className:"size-3.5",strokeWidth:2.4}),"Downloaded"]}),e.jsxs("span",{className:"hidden items-center gap-1.5 group-hover:inline-flex group-focus-visible:inline-flex",children:[e.jsx(We,{className:"size-3.5",strokeWidth:2}),"Re-download"]})]}):e.jsxs("button",{type:"button",onClick:f,"data-amp-track-surface":"apply","data-amp-track-action":"download",className:"inline-flex items-center gap-1.5 rounded-md border border-transparent bg-transparent px-3 py-1.5 font-semibold text-sm text-text-strong outline-none transition-colors duration-fast ease-out hover:text-orange-hover focus-visible:shadow-focus",children:[e.jsx(We,{className:"size-3.5",strokeWidth:2}),"Download .pdf"]}),e.jsx("button",{type:"button",onClick:ge,"aria-expanded":O,"aria-label":O?"Collapse":"Edit","data-amp-track-surface":"apply","data-amp-track-action":O?"collapse":"edit",className:"inline-flex items-center justify-center rounded-md p-1.5 text-text-muted outline-none transition-colors duration-fast ease-out hover:text-text-strong focus-visible:shadow-focus",children:e.jsx(Ye,{"aria-hidden":!0,strokeWidth:1.75,className:`size-5 transition-transform duration-slow ease-out ${O?"":"-rotate-90"}`})})]})]}),e.jsx(Fe,{open:O,testId:g?"resume-locked-body":void 0,children:e.jsxs("section",{className:"af-card-section",children:[!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"af-card-eyebrow",children:"What Chegg changed"}),e.jsx("ul",{className:"af-card-list",children:Y}),!Q&&e.jsx("div",{className:"af-card-section-action",children:e.jsx("button",{type:"button",className:"af-link-quiet",onClick:()=>j(h=>!h),"aria-expanded":N,children:N?"Hide resume":"Review resume â"})})]}),Q?he:(g||N)&&e.jsx("div",{className:"af-card-inline-review",children:e.jsx($e,{tailoredResumeId:r,pending:n,baseResume:o,user:i,readOnly:!0,job:s})})]})})]})})}return e.jsxs("article",{className:"af-card","aria-labelledby":V,children:[e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 1"}),e.jsxs("h2",{id:V,className:"af-card-title",children:["Resume tailored for ",a.company,"."]}),e.jsxs("div",{className:"af-card-meta",children:[e.jsx("span",{className:"af-card-pulse","aria-hidden":"true"}),e.jsx("span",{children:"Draft 1 · just now"})]}),e.jsxs("section",{className:"af-card-section",children:[e.jsx("div",{className:"af-card-eyebrow",children:"What Chegg changed"}),e.jsx("ul",{className:"af-card-list",children:Y}),!Q&&e.jsx("div",{className:"af-card-section-action",children:e.jsx("button",{type:"button",className:"af-link-quiet",onClick:()=>j(b=>!b),"aria-expanded":N,children:N?"Hide suggested changes":"Review suggested changes â"})}),Q?he:N&&e.jsx("div",{className:"af-card-inline-review",children:e.jsx($e,{tailoredResumeId:r,pending:n,baseResume:o,user:i,job:s})})]})]}),e.jsx("footer",{className:"af-card-footer",children:e.jsx("div",{className:"af-card-footer-actions",children:Q?e.jsxs(e.Fragment,{children:[e.jsxs(S,{type:"button",variant:"orange",onClick:()=>oe("resume_tailoring"),"data-amp-track-surface":"membership_lock","data-amp-track-action":"unlock","data-amp-track-target":"resume_tailoring",children:[e.jsx(_a,{className:"size-3.5",strokeWidth:2,"aria-hidden":!0}),"Continue with tailored resume"]}),e.jsx(Re,{onClick:L,"data-amp-track-surface":"apply","data-amp-track-action":"continue_base_resume",children:"Continue with base resume"})]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{type:"button",variant:"orange",onClick:K,"data-amp-track-surface":"apply","data-amp-track-action":"review_accept_all",children:"Accept tailored resume"}),e.jsx(Re,{onClick:L,"data-amp-track-surface":"apply","data-amp-track-action":"review_skip",children:"Keep as-is"})]})})})]})}function ki(){const[t,a]=c.useState(!1),s=c.useRef(!1),r=c.useRef(!1),n=c.useRef(!1),o=c.useCallback(()=>{s.current=!0,r.current=!1,n.current=!1,a(!1)},[]),i=c.useCallback(()=>{s.current=!1,a(!1)},[]);return c.useEffect(()=>{const l=()=>{!s.current||!r.current||n.current||(n.current=!0,s.current=!1,a(!0))},m=()=>{s.current&&(document.visibilityState==="visible"?l():r.current=!0)},d=()=>{s.current&&(r.current=!0)},y=()=>l();return document.addEventListener("visibilitychange",m),window.addEventListener("blur",d),window.addEventListener("focus",y),()=>{document.removeEventListener("visibilitychange",m),window.removeEventListener("blur",d),window.removeEventListener("focus",y)}},[]),{isOpen:t,arm:o,dismiss:i}}function _i(t){return Jr(t?.name)}const Si={no_resume:"Add a resume with your experience, education, and contact details.",experience_incomplete:"Add at least one experience with a role or company and a bullet point describing what you did.",no_education:"Add your education â the school you attend and, ideally, your degree.",missing_contact:"Add your name and email so employers can reach you."};function Ei({reasons:t}){return e.jsxs("div",{className:"af-card","data-testid":"tailoring-gate-blocked",children:[e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 1"}),e.jsx("h2",{className:"af-card-title",children:"Add a little more before you tailor your resume"}),e.jsx("p",{className:"af-card-meta",children:"Your resume needs a bit more so employers get a complete application:"}),e.jsx("ul",{className:"af-card-meta list-disc pl-5",children:t.map(a=>e.jsx("li",{"data-testid":`tailoring-gate-reason-${a}`,children:Si[a]},a))})]}),e.jsx("footer",{className:"af-card-footer",children:e.jsx("div",{className:"af-card-footer-actions",children:e.jsx(S,{asChild:!0,variant:"orange",children:e.jsx(gt,{to:"/resume","data-amp-track-surface":"apply","data-amp-track-action":"tailoring_gate_edit_resume",children:"Edit my resume"})})})})]})}function ca(t){switch(t){case"resume-active":case"resume-active-busy":return{resume:"active",cover:"locked"};case"cover-active":return{resume:"done",cover:"active"};case"both-done":return{resume:"done",cover:"done"}}}const Ai={saved_at:new Date(0).toISOString(),job_id:0};function Qo({chrome:t="standalone",job:a,onStatusChange:s,isExtensionOrigin:r=!1,focusStep:n,detailsOpen:o=!1}={}){const i=mi(a),l=_n(a?.status),{isPaywalled:m}=He(),d=qe(a?.job_id??0),y=a??Ai,f=d?Ve(a?.job_id??0):0,w=a?.job_id??0,g=T({queryKey:["assisted-apply-request",w],queryFn:()=>ba({data:{jobId:w}}),enabled:l&&w>0,refetchInterval:fa(u=>{const B=u.state.data?.request?.status;return B&&!ha(B)?15e3:!1})}),H=g.data?.request?.status==="needs_info",{data:I}=T(Ge()),{data:P}=T(lt()),D=P!==void 0,N=c.useContext(Xs),j=N?async u=>{await Promise.resolve(N.importResumeFile(u,"resume",{viaIntake:!0})),await R.invalidateQueries({queryKey:lt().queryKey})}:void 0,O=N?.pendingResumeUpload!=null,E=!d&&D&&!Bs(P),X=E&&O,A=Ws(P),V=_i(I??void 0),$=I?.email??"[email protected]",J=a?.id??0,se=ga(ks)==="on",F=ki(),p=!!a&&!!s&&!l,[k,z]=c.useState(0),[re,Z]=c.useState(!1),de=re||l,K=a?.job_id,L=T({...ze(K??0),enabled:!d&&typeof K=="number"&&K>0}),C=d?null:L.data?.id??null,ee=se&&!d&&D&&!E&&!O?Gs(P,{contact:{name:I?.name,email:I?.email}}):null,x=typeof C=="number"&&C>0,v=!l&&!x&&ee!==null&&!ee.sufficient,M=T({...Ce(C??0),enabled:!d&&typeof C=="number"&&C>0}),_=Array.isArray(M.data)?M.data.some(u=>u.status!=="pending"):C!==null,G=L.data?.createdAt,Y=!d&&!l&&!re&&!_&&A!==null&&G!=null&&new Date(G).getTime()<A,R=ce(),oe=g.data?.request?.status;c.useEffect(()=>
6{(oe==="cannot_complete"||oe==="cancelled")&&wt(R)},[oe,R]);const Q=le({mutationFn:u=>_s({data:{jobId:u}}),meta:{nrReported:!0},onSuccess:(u,B)=>{typeof u.generationDurationMs=="number"&&ae("tracker_tailor_resume_generated",{jobId:B,durationMs:u.generationDurationMs}),R.invalidateQueries({queryKey:Ce(u.tailoredResumeId).queryKey})},onError:(u,B)=>{Qe(u,{context:"apply-assembly-tailor-create"}),Ee("apply_tailor_create_failed",{surface:"apply_assembly",jobId:B})},onSettled:(u,B,te)=>{R.invalidateQueries({queryKey:ze(te).queryKey})}}),he=c.useRef(!1),ge=le({mutationFn:()=>Ss(),onSuccess:()=>{R.invalidateQueries({queryKey:lt().queryKey})},onError:u=>{Qe(u,{context:"apply-assembly-seed-education"})}}),b=v&&ee!==null&&ee.missing.length===1&&ee.missing[0]==="no_education"&&!!(I?.school??"").trim();c.useEffect(()=>{d||b&&(he.current||(he.current=!0,ge.mutate()))},[d,b,ge.mutate]);const h=c.useRef(null);c.useEffect(()=>{if(d||typeof K!="number"||K<=0||!L.isFetched||v||L.data!==null&&!Y)return;const u=Y?L.data:null,B=u?`${u.id}:${u.createdAt}`:null;if(B===null){if(!Q.isIdle)return}else{if(Q.isPending||h.current===B)return;h.current=B}!D||E||O||Q.mutate(K)},[d,K,L.isFetched,L.data,Q.isIdle,Q.isPending,Q.mutate,D,E,O,Y,v]);const U=Aa(y);Nn(y);const q=le({mutationFn:()=>Es({data:{seq:f}}),onSuccess:u=>{u&&"status"in u&&(R.setQueryData(da(f).queryKey,{status:u.status,failure_kind:null}),R.invalidateQueries({queryKey:ue(f).queryKey}))}});c.useEffect(()=>{d&&(U.isPending||U.status==="none"&&q.isIdle&&q.mutate())},[d,U.isPending,U.status,q.isIdle,q.mutate]);const xe=q.data&&"kind"in q.data?q.data.kind:null,ne=d&&(U.status==="failed"||U.status==="edits_failed"||xe!==null)&&!q.isPending,et=d&&U.status==="error",Ka=()=>{R.invalidateQueries({queryKey:ue(f).queryKey})},At=Date.now(),Ct=d?U.edits.length>0||U.status==="ready":ta({editsData:M.data,rowCreatedAt:L.data?.createdAt,now:At}),Ua=!d&&ta({editsData:null,rowCreatedAt:L.data?.createdAt,now:At}),ye=d?U.edits:Array.isArray(M.data)?M.data:Ct?[]:null,tt=!d&&typeof K=="number"&&K>0,at=E||O||v,Ie=d?U.status==="tailoring"||q.isPending:En({jobTailorable:tt,tailoredResumeId:C,createErrored:Q.isError,resumeFetched:L.isFetched,resumeFetching:L.isFetching,createPending:Q.isPending,createIdle:Q.isIdle,createSucceeded:Q.isSuccess,editsErrored:M.isError,editsReady:Ct,editsStale:Ua,autoCreateSuppressed:at}),st=T({...pa(a?.job_id??0),enabled:!d&&typeof a?.job_id=="number"&&a.job_id>0}),rt=T({...As(f),enabled:d&&f>0}),$a=d?rt.data?.bullets&&rt.data.bullets.length>0?rt.data.bullets:null:st.data?.bullets&&st.data.bullets.length>0?st.data.bullets:null,ve=T({...Te(),enabled:!d&&typeof a?.job_id=="number"&&a.job_id>0}),{data:ie=null,isFetched:Rt,isFetching:Tt}=wn(y),Ft=ja(C??0),Lt=zs(C??0),{finalize:Pt}=Qs(C??0,a?.job_id??null),za=Ca(f),Qa=hn(f),{finalize:Ba}=gn(f),[nt,Ot]=c.useState(null);c.useEffect(()=>{if(nt===null||typeof C!="number"||C<=0)return;const{kind:u,acceptedEditCount:B,rejectedEditCount:te,byKind:W}=nt,_e=()=>Pt("apply_assembly",B,te,{byKind:W,commitKind:u,paywalled:m("resume_tailoring")});(u==="accept"?Ft:Lt).mutate(void 0,{onSuccess:_e}),Ot(null)},[nt,C,Ft,Lt,Pt,m]);const it=c.useRef(!1),ot=(ee?.missing??[]).join(",");c.useEffect(()=>{if(!v){it.current=!1;return}b||it.current||(it.current=!0,ae("application_tailoring_gate_blocked",{jobId:a?.job_id??null,reasons:ot?ot.split(","):[]}))},[v,a?.job_id,ot,b]);const qt=u=>{const B=ye??[],{acceptedEditCount:te,rejectedEditCount:W,byKind:_e}=bn(B,u);if(d){(u==="accept"?za:Qa).mutate(void 0,{onSuccess:()=>Ba(te,W)});return}Ot({kind:u,acceptedEditCount:te,rejectedEditCount:W,byKind:_e})},Wa=le({mutationFn:u=>kn({data:{jobId:u}}),onSuccess:()=>{R.invalidateQueries({queryKey:Te().queryKey})}}),Ga=Os(),It=Sn(a?.status),Mt=It,[Ne,ke]=c.useState(()=>{const u=ca(It);return{resume:u.resume,cover:u.cover}});c.useEffect(()=>{const u=ca(l?"both-done":Mt);ke({resume:u.resume,cover:u.cover})},[Mt,l]),c.useEffect(()=>{typeof a?.job_id!="number"||a.job_id<=0||!ve.isFetched||ve.isFetching||ie?.materialsDownloadedAt&&Z(!0)},[a?.job_id,ve.isFetched,ve.isFetching,ie?.materialsDownloadedAt]);const Dt=c.useRef(!1);c.useEffect(()=>{if(Dt.current||l||typeof a?.job_id!="number"||a.job_id<=0||!ve.isFetched||ve.isFetching||!L.isFetched||L.isFetching||typeof C!="number"||C<=0||!M.isFetched||M.isFetching)return;Dt.current=!0;const u=ie?.materialsDownloadedAt!=null,B=u||ie?.tailoredAppliedAt!=null||ye!=null&&ye.length>0&&ye.every(W=>W.status!=="pending"),te=u||!!ie?.coverLetterMarkdown?.trim();ke({resume:B?"done":"active",cover:te?"done":B?"active":"locked"})},[l,a?.job_id,ve.isFetched,ve.isFetching,L.isFetched,L.isFetching,M.isFetched,M.isFetching,C,ye,ie?.coverLetterMarkdown,ie?.tailoredAppliedAt,ie?.materialsDownloadedAt]);const Kt=c.useRef(!1);c.useEffect(()=>{if(!d||Kt.current||l||!Rt||Tt)return;Kt.current=!0;const u=ie?.tailoredAppliedAt!=null,B=ie?.coverFinalizedAt!=null,te={resume:u?"done":"active",cover:B?"done":u?"active":"locked"};ke(W=>W.resume===te.resume&&W.cover===te.cover?W:te)},[d,l,Rt,Tt,ie?.tailoredAppliedAt,ie?.coverFinalizedAt]);const Ya=An({jobTailorable:tt,reviewPending:Ie,editsKnown:ye!==null,autoCreateSuppressed:at,locked:l,resumeStepDone:Ne.resume==="done",rowReadInFlight:L.isFetching}),Ut=tt&&!at&&ye===null,Ha=()=>{h.current=null;const u=ze(K??0).queryKey;typeof C=="number"&&C>0&&R.invalidateQueries({queryKey:Ce(C).queryKey}),R.invalidateQueries({queryKey:u}).then(()=>{R.getQueryData(u)==null&&Q.reset()})},$t=c.useRef(!1);c.useEffect(()=>{$t.current||typeof a?.job_id!="number"||a.job_id<=0||Ie||Ut||v||($t.current=!0,ae("tracker_tailor_phase_entered",{jobId:a.job_id,tailoredResumeId:C,phase:l?"read_only":"review_ai",missingSkillCount:0,pendingAiEditCount:(ye??[]).filter(u=>u.status==="pending").length}))}
6,[a?.job_id,l,C,Ie,Ut,ye,v]);const zt=c.useRef(null);c.useEffect(()=>{if(!n||zt.current===n)return;const u=document.getElementById(ct[n]);if(!u)return;zt.current=n;const B=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;u.scrollIntoView({behavior:B?"auto":"smooth",block:"start"})},[n]);const Qt=()=>{ke(u=>({resume:"done",cover:u.cover==="locked"?"active":u.cover}))},Va=()=>{ke(u=>({...u,cover:"done"}))},Bt=Ne.resume==="done"&&Ne.cover==="done",Xa=va(Cs,{when:Bt})==="on",Za=a==null||!a.application_url?"dead":"valid",Me=async u=>{if(m(u==="cover-letter"?"cover_letter":"resume_tailoring"))return!1;if(d){const W=[];if((u==="resume"||u==="bundle")&&ie?.resumePdfUrl&&W.push(ie.resumePdfUrl),(u==="cover-letter"||u==="bundle")&&ie?.coverLetterPdfUrl&&W.push(ie.coverLetterPdfUrl),W.length===0)return!1;for(const _e of W)window.open(_e,"_blank","noopener,noreferrer");return!0}const te=a?.job_id;if(typeof te!="number"||te<=0)return!1;try{const W=await Ps({data:{jobId:te,kind:u}});return or(W),!0}catch(W){return console.error(`Failed to download ${u}`,W),Qe(W,{context:"apply_material_download",material_kind:u}),!1}},Wt=()=>{Me("bundle")},Gt=async()=>{await Me("bundle")&&(Z(!0),!d&&typeof a?.job_id=="number"&&a.job_id>0&&Wa.mutate(a.job_id))};return e.jsxs("div",{"data-testid":"apply-assembly","data-extension-origin":r||void 0,className:`af-root${t==="embedded"?" af-root-embedded":""}`,children:[t==="standalone"&&e.jsxs("header",{className:"af-top",children:[e.jsxs("div",{className:"af-top-left",children:[e.jsxs("button",{className:"af-back",type:"button",children:[e.jsx(ka,{size:16}),"Back to ",i.company," role"]}),e.jsx("span",{className:"af-top-divider"}),e.jsxs("span",{style:{fontSize:13,color:"var(--text-muted)",letterSpacing:-.005,fontWeight:600},children:["Application assembly ·"," ",e.jsx("span",{style:{color:"var(--text-strong)",fontWeight:700},children:i.company})]})]}),e.jsx("div",{className:"af-top-right"})]}),e.jsxs("main",{className:"af-stage",children:[a&&e.jsx(Vn,{job:a,defaultOpen:o}),e.jsx("div",{id:ct.resume,children:et?e.jsxs("article",{className:"af-card","data-testid":"extension-materials-error",children:[e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 1"}),e.jsx("h2",{className:"af-card-title",children:"We couldn't load your tailored resume"}),e.jsx("p",{className:"af-card-meta",children:"Something went wrong loading your resume for this role. You can try again."})]}),e.jsx("footer",{className:"af-card-footer",children:e.jsx("div",{className:"af-card-footer-actions",children:e.jsx(S,{type:"button",variant:"orange","data-testid":"extension-materials-error-retry","data-amp-track-surface":"apply","data-amp-track-action":"materials_retry",onClick:Ka,children:"Retry"})})})]}):ne?e.jsxs("article",{className:"af-card","data-testid":"extension-tailor-failed",children:[e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 1"}),e.jsx("h2",{className:"af-card-title",children:"We couldn't tailor your resume"}),e.jsx("p",{className:"af-card-meta",children:"Something went wrong generating a tailored draft for this role. You can try again."})]}),e.jsx("footer",{className:"af-card-footer",children:e.jsx("div",{className:"af-card-footer-actions",children:e.jsx(S,{type:"button",variant:"orange","data-testid":"extension-tailor-retry","data-amp-track-surface":"apply","data-amp-track-action":"tailor_retry",disabled:q.isPending,onClick:()=>q.mutate(),children:"Try again"})})})]}):v?e.jsx(Ei,{reasons:ee?.missing??[]}):Ya?e.jsxs("article",{className:"af-card","data-testid":"web-tailor-unresolved",children:[e.jsxs("div",{className:"af-card-body",children:[e.jsx("div",{className:"af-card-step",children:"Step 1"}),e.jsx("h2",{className:"af-card-title",children:"We couldn't load your tailored resume"}),e.jsx("p",{className:"af-card-meta",children:"Something went wrong tailoring your resume for this role. You can try again, or keep going with the resume you already have."})]}),e.jsx("footer",{className:"af-card-footer",children:e.jsxs("div",{className:"af-card-footer-actions",children:[e.jsx(S,{type:"button",variant:"orange","data-testid":"web-tailor-retry","data-amp-track-surface":"apply","data-amp-track-action":"tailor_retry","data-amp-track-target":"web",disabled:Q.isPending||M.isFetching||L.isFetching,onClick:Ha,children:"Try again"}),e.jsx(S,{type:"button",variant:"outline","data-testid":"web-tailor-continue","data-amp-track-surface":"apply","data-amp-track-action":"tailor_continue_untailored",onClick:Qt,children:"Use my current resume"})]})})]}):e.jsx(Ni,{state:Ne.resume,job:i,trackerJob:a??null,tailoredResumeId:C,tailoredResumePending:Ie,baseResume:P,user:I??null,tailoredEdits:ye,onSave:Qt,onAcceptAll:()=>qt("accept"),onRejectAll:()=>qt("reject"),onDownload:()=>{Me("resume")},onReDownload:Wt,locked:l,materialsDownloaded:re,resumeMissing:E,onUploadResume:j,uploadInFlight:O})}),e.jsx("div",{id:ct.cover,children:e.jsx(Mn,{state:Ne.cover,job:i,jobId:a?.job_id,summaryBullets:$a,onSave:Va,onDownload:()=>{Me("cover-letter")},onReDownload:Wt,locked:l,materialsDownloaded:re})}),e.jsx(xi,{live:Bt,job:i,jobId:J,coresignalJobId:a?.job_id??0,applyViaExtensionEnabled:Xa,extensionPresent:Ga,linkStatus:Za,locked:l,status:a?.status,studentLastName:V,studentEmail:$,onApplyOnSite:()=>{Gt()},onApplyForMe:()=>{Gt()},onApplied:()=>{const u=ua().queryKey,B=new Date().toISOString();R.setQueryData(u,te=>te?.map(W=>W.job_id===a?.job_id?{...W,status:"applied",applied_at:W.applied_at??B}:W)),wt(R)},needsInfo:H,resumeMissing:E,resumeUploadPending:X,onSendEmail:async()=>{},onArmReturnWatcher:p?F.arm:void 0,resetHandoffSignal:k,applyForMeSupported:a?.apply_for_me_supported}),de&&a&&e.jsx(Tn,{job:a}),l&&a&&s&&e.jsx($n,{company:i.company,status:a.status,onUpdateStatus:u=>s(a.job_id,u,"manual")})]}),p&&a&&F.isOpen&&e.jsx(Dn,{company:i.company,onConfirm:()=>{ae("application_step_completed",{jobId:a.job_id,step:"apply",source:"manual"}),s?.(a.job_id,"applied","self-confirmed"),F.dismiss()},onDismiss:()=>{z(u=>u+1),F.dismiss()}})]})}export{Qo as ApplyAssemblyPage,_i as lastNameFrom};
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.