1import{j as e,r as c,aL as Ua,aH as Fi,bG as Zr,aV as ud,aG as hd}from"./vendor-CkXPoFMb.js";import{C as sa}from"./CandidateLayout-Dw-nINaX.js";import{C as xd}from"./CandidateBreadcrumb-D9xZh8gN.js";import{L as As}from"./LoadingSpinner-BAckjbJh.js";import{bb as fd,y as Gs,c as ye,aY as le,aZ as ie,a_ as va,bz as gd,I as Wi,bA as pd,bB as Xl,bC as bd,bD as yd,B as ae,u as Ma,bc as Yi,bd as vd,be as $i,bf as qi,bg as Hi,bh as Vi,bi as _d,bj as Zl,g as _a,bk as jd,bl as Jl,a8 as ei,bo as ws,av as wd,aj as ra,bE as Nd,bF as si,bG as kd,bH as Rd,bI as Cd,bJ as ri,bK as Ki,bu as Ed,bL as Id,ak as Td,a5 as Sd,br as ta,aq as Nr,al as ti,aA as aa,ar as Ld,au as Dd,bM as ai,ap as pt,bN as na}from"./index-CR9aNikF.js";import{B as je}from"./badge-PyECTiJT.js";import{s as zi,g as kr,r as dr,i as ni,F as Bd,b as Pd,c as Ud,h as Md}from"./appliedStageStatus-Boo7bDtt.js";import{g as Od}from"./candidateApplicationsService-DWV7nKja.js";import{r as bt,a as Fd,c as Qe,s as Wd,f as li,H as ii,j as Yd,i as $d,b as qd}from"./displayApplicationJourney-DnuvhPgp.js";import{T as Hd,u as Vd,R as la}from"./useCandidateAttemptDetail-C92qnEog.js";import{A as Kd,a as zd,b as Ad,c as Gd}from"./accordion-C10swJ_f.js";import{J as Ai,f as Qd,a as ia,b as Xd,c as Zd,d as Jd,r as ec}from"./jobEntryDisplay-DoA8SaGn.js";import{J as ss,d as Gi,b as Oa,s as Fa,U as Ps,L as Jr,r as sc,g as as,aq as gs,a7 as Tr,Q as rc,aS as tc,ae as ac,j as Lt,aa as nc,A as Ns,a1 as Wa,az as at,ay as oa,ax as lc,f as ic,aT as oi,aU as Qi,X as Xi,aV as oc,av as dc,I as nt,k as Zi,i as cc,M as ja,aW as et,o as cr,aO as mc,aQ as Ji,ap as uc,aX as hc,e as Tt,B as St,S as xc,aP as fc,aY as gc,aR as pc,D as bc,ad as wa,aZ as yc,aM as vc,an as _c,a_ as jc,aE as di,a$ as wc,n as Nc,aA as kc}from"./vendor-icons-DPnl4cY3.js";import{C as Rc,a as Cc,b as Ec}from"./collapsible-BF0L_gNK.js";import{a as Ic,E as Tc,D as Sc,R as Lc,F as Dc,c as Bc,i as da}from"./EligibilityNotMatchedStep-Dv3QjlKx.js";import{g as Pc}from"./eligibilityQuestionHelpers-h8PMlUvc.js";import{f as Uc,g as Mc,n as Oc,s as Fc,a as Wc,r as eo,b as ca,c as ma,i as ci,p as mi,d as ui,F as Yc,e as $c,R as qc,h as Hc,j as Vc,k as hi,l as Kc,m as zc,I as Ac,o as Gc,q as Qc,t as xi,u as Xc}from"./conciergeInterviewService-eJo-BSGo.js";import{T as Zc,a as Jc,b as yt,c as vt}from"./tabs-Ce1cCIbb.js";import{w as em,W as Ce,x as so,y as ro,t as Ir,z as sm,C as Dt,A as rm,u as qr,B as Hr,D as Is,E as Vr,i as Bs,F as Kr,G as fi,H as zr,I as ua,J as Ar,K as tm,L as am,M as nm,N as lm,O as im,P as om,Q as dm,R as cm,S as gi,T as mm,s as pi,U as _t,V as um,X as hm,Y as zs,Z as xm,_ as Rr,$ as fm,a0 as gm,a1 as pm,c as bi,a2 as bm,a3 as ym,a4 as vm,a5 as yi,a6 as _m,a7 as vi,a8 as _i,a9 as jm,aa as wm,ab as Nm,ac as jt,ad as ji,ae as wi,m as km,af as Rm,n as Cm,e as Em,f as Im,o as Ni,ag as Tm,p as Sm,q as Lm,ah as Dm,ai as Bm}from"./conciergeDecisionUi-Cw4ZVUEo.js";import{a5 as Xr}from"./vendor-datefns-N8mCDnaz.js";import{A as Na,a as ka,b as Ra,c as Ca,d as Ea,e as Ia,f as Ta,g as Sa}from"./alert-dialog-dV3p_s--.js";import{d as La,g as Pm,a as ha}from"./candidateResumeService-Cbke0BdP.js";import{P as Um}from"./PrivacyConsentCard-WZXqEw4a.js";import{p as ki}from"./polling-CSvkUZa2.js";import{c as Mm,a as Om,b as xa,d as Fm,r as Wm}from"./signedReviewStateCopy-BoUNpDTa.js";import{g as Ym,a as to,s as Gr,b as $m,i as Ri,c as Ci}from"./conciergeBypassUi-C0m685yf.js";import{n as Bt,J as Cr,i as qm,a as Hm,b as Ei,c as Vm}from"./conciergeNextStep-DDwZOIar.js";import{c as Km,a as zm}from"./commercialInterviewStepLabel-CDbFu5rY.js";import{B as Am}from"./BitScoreBadge-CWGsVx6I.js";import{B as Gm}from"./BadgeImagePreview-DUIyLtbc.js";import{S as ao}from"./ShareModal-B7Ej6iZo.js";import{c as Qm,t as Xm,a as Zm,b as Jm,d as eu}from"./credentialShareMessage-DbEBJ2Uc.js";import{J as su}from"./JobEntryCompanyMark-Bk6RklSq.js";import{f as no,c as ru,r as Ii,i as tu,a as Er,b as wt}from"./behaviouralRehearsalResolve-5B06uLox.js";import{g as au,p as nu,l as lu}from"./rehearsalBroadcast-DBGnHAMW.js";import{r as iu,b as ou}from"./rehearsalDuration-BEa4GvJv.js";import{c as Nt,a as du}from"./jobRehearsalAttachment-D8_8IyD-.js";import{g as kt}from"./conciergeService-CLLAyg4v.js";import{R as cu}from"./RehearsalDecisionScreen-D8M7j4-5.js";import{r as mu}from"./rehearsalAudioController-BpLYoF2a.js";import"./vendor-quill-Bo48LKbP.js";import{i as uu,a as hu,b as xu,g as fu,J as gu,c as pu,r as bu}from"./jobLifecycle-DzFJw_s6.js";import{b as yu,i as vu,s as _u,r as ju,g as wu}from"./candidateJobAvailability-DQpKy8Uj.js";import{l as Nu}from"./linksService-BWyESNIE.js";import{h as ku,i as Ru,a as Cu}from"./behaviouralScenarioUi-Cb1TyJCD.js";import{J as Eu}from"./JobDeadlineDisplay-BipFZw4Z.js";import"./checkbox-Cpm-hLEQ.js";import"./GoogleSignupButton-Bksx481N.js";import"./oauthPostLogin-Bp_x4sgc.js";import"./passwordValidation-Dn1l2Lqa.js";import"./signupEmailValidation-CD3kGD9O.js";import"./emailValidationService-D4JrT6ch.js";import"./MfaSetupPage-BYbF_bzC.js";import"./MfaEnrollPanel-ChuKGc1p.js";
1import"./input-otp-B7lYn7RV.js";import"./recruiterOnboardingService-DY0IebLw.js";import"./bitstage-logo-full-BrydXt0F.js";import"./vendor-jspdf-D2r6YsBm.js";import"./vendor-fingerprint-f-b5Qes_.js";import"./vendor-sanitize-8YZbVxp6.js";import"./vendor-sentry-DuxUMs8C.js";import"./vendor-motion-DvZ9ooo_.js";import"./journeyStepVisual-CI9jhb2d.js";import"./SnakePipelineLayout-DmQHYVBb.js";import"./use-mobile-BTzsHyKr.js";import"./applicationWithdrawal-C6Uwj61w.js";import"./ResumePreviewModal-BkKhzYQn.js";import"./PracticeScoreCard-CnKtZlmH.js";import"./evidenceMediaSync-qFKfiRYw.js";import"./EligibilityBooleanAnswer-BBo0Wifb.js";import"./recordingAccessPolicy-wJ1m_cOw.js";import"./workStyleFeature-DqGC3fkn.js";import"./rehearsalStageStatus-D3OIMIVl.js";const Ti=".pdf,.docx,.txt,.rtf,.odt",Iu=10,Rt=Iu*1024*1024,Tu=new Set(["pdf","docx","txt","rtf","odt"]),Su=new Set(["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain","application/rtf","text/rtf","application/vnd.oasis.opendocument.text"]),Ct="Only PDF, DOCX, TXT, RTF, and ODT files are allowed.";function Si(r){var m;const a=r.name||"",t=a.includes(".")&&((m=a.split(".").pop())==null?void 0:m.toLowerCase())||"",o=(r.type||"").toLowerCase();return!(!Tu.has(t)||!o||!Su.has(o))}function Lu(r){return(r.resume_status||"").toUpperCase()==="SCORED"||r.next_step==="RESUME_SCORED_START_REHEARSAL"}function Du(r){return(r.resume_status||"").toUpperCase()==="REJECTED"}function Bu(r){return(r.resume_status||"").toUpperCase()==="SCORING"||r.next_step==="RESUME_SCORING"||r.next_step==="RESUME_UNDER_REVIEW"}function Pu(r){var m,g,u;const a=Math.max(1,((m=r.resume_attempt_policy)==null?void 0:m.max_attempts)??fd),t=Math.min(Math.max(((g=r.resume_attempt_policy)==null?void 0:g.attempts_used)??r.resume_upload_attempts_used??0,0),a),o=((u=r.resume_attempt_policy)==null?void 0:u.can_retry)??r.resume_can_retry??t<a;return{maxAttempts:a,attemptsUsed:t,canRetry:o}}function Uu(r){const a=(r||"").toLowerCase();return a==="pending"||a==="running"||a==="scoring"||a==="processing"}function Mu(r){return(r.resume_attempt_history??[]).filter(a=>!a.deleted&&Uu(a.score_status)).map(a=>a.resume_id).filter(a=>!!a)}async function Li(r,a=[]){const t=new Set;a.filter(o=>!!o).forEach(o=>t.add(o));try{const o=await Gs(r);Mu(o).forEach(m=>t.add(m))}catch{}await Promise.all([...t].map(o=>La(o)))}function lo({description:r,fadeFromClassName:a="from-card",className:t}){const[o,m]=c.useState(!1);return e.jsxs("div",{className:t,children:[e.jsxs("div",{className:ye("relative",!o&&"max-h-56 overflow-hidden"),children:[e.jsx(Ai,{text:r,className:"max-w-none",emptyText:"No description provided."}),o?null:e.jsx("div",{className:ye("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t to-transparent",a)})]}),e.jsxs("button",{type:"button",onClick:()=>m(g=>!g),className:"mt-3 inline-flex items-center gap-1 text-sm font-medium text-primary hover:underline",children:[o?"Show less":"Show more",o?e.jsx(Gi,{className:"h-4 w-4"}):e.jsx(Oa,{className:"h-4 w-4"})]})]})}function Ou({skills:r,className:a}){return r.length?e.jsxs("div",{className:ye("space-y-2",a),children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Skills"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(t=>e.jsx(je,{variant:"secondary",className:"rounded-full border border-[hsl(var(--brand-navy))]/15 bg-[hsl(var(--brand-cream))] font-normal text-[hsl(var(--brand-navy))]",children:t.name},t.id||t.key||t.name))})]}):null}function Fu({description:r,skills:a=null,className:t}){const o=(r||"").trim(),m=Array.isArray(a)?a.filter(g=>{var u;return(u=g==null?void 0:g.name)==null?void 0:u.trim()}):[];return!o&&m.length===0?null:e.jsx(Kd,{type:"single",collapsible:!0,className:ye("w-full",t),children:e.jsxs(zd,{value:"job-description",className:"rounded-xl border border-border/70 border-b-0 bg-card px-4 sm:px-5",children:[e.jsxs(Ad,{className:"group gap-3 py-4 hover:no-underline",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-start gap-3 text-left",children:[e.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(ss,{className:"h-4 w-4 text-primary","aria-hidden":!0})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-semibold text-foreground",children:"Job description"}),e.jsx("span",{className:"mt-0.5 block text-xs font-normal text-muted-foreground",children:"Responsibilities, requirements and role details"})]})]}),e.jsx("span",{className:"hidden shrink-0 text-sm font-medium text-primary group-data-[state=open]:hidden sm:inline",children:"View details"})]}),e.jsx(Gd,{children:e.jsxs("div",{className:"space-y-5 pt-1",children:[e.jsx(Ou,{skills:m}),o?e.jsxs("div",{className:"space-y-2",children:[m.length>0?e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"About the role"}):null,e.jsx(lo,{description:o,fadeFromClassName:"from-card"})]}):null]})})]})})}function Wu({description:r,alertKeyword:a}){const t=!!(r!=null&&r.trim());return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:"rounded-xl border border-border/70 bg-card p-5 shadow-sm sm:p-6",children:[e.jsxs("div",{className:"mb-4 flex items-start gap-3",children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-primary/10",children:e.jsx(ss,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-primary",children:"Application submitted"}),e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:"About this role"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Review the role description for the role you applied to."})]})]}),t?e.jsx(lo,{description:r.trim()}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No description provided for this role."})]}),e.jsxs("section",{className:"flex flex-col gap-3 rounded-xl border border-amber-200/70 bg-amber-50/80 p-5 shadow-sm sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-full bg-white shadow-sm",children:e.jsx(Fa,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Get role alerts"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"We'll notify you when similar roles are posted."})]})]}),e.jsx(Hd,{keyword:a,variant:"sidebar",authInitialMode:"signup"})]})]})}function io({className:r,waitingInQualifiedPool:a=!1,emailVerificationPending:t=!1,variant:o="default",resumeRetryHeld:m=!1,resumeAttemptsExhausted:g=!1}){const u=o==="resume"?[{icon:Ps,title:"We ensure a fair process",body:"Every application for this role is reviewed with the same criteria."},{icon:Jr,title:"Your privacy is protected",body:"Your resume is used only for this application."},{icon:ss,title:"Next after this",body:t?"Verify your email to see your resume results and whether youâre eligible for the next step.":g?"Both resume attempts are used. You stay reserved for this application and canât move to the next step unless the employer inv
1ites you.":m?"This is your last resume upload. If it meets this roleâs threshold, you can move to the next step.":"You'll see your resume result, then choose Yes or No for an optional short rehearsal."}]:[{icon:Ps,title:"We ensure a fair process",body:"Every application is reviewed with the same criteria for this role."},{icon:Jr,title:"Your privacy is protected",body:"Your answers and materials are used only for this application."},{icon:Fa,title:"We'll keep you updated",body:a?"We'll email you if you become eligible for a rehearsal.":"You'll get notified when you move to the next step."}];return e.jsx(le,{className:r??"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"space-y-5 p-5",children:[e.jsx("h3",{className:"text-base font-bold text-foreground",children:"What to expect"}),e.jsxs("ul",{className:"space-y-4",children:[u.map(l=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[hsl(var(--brand-cream))] border border-[hsl(var(--brand-navy))]/15",children:e.jsx(l.icon,{className:"h-4 w-4 text-[hsl(var(--brand-navy))]"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:l.title}),e.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:l.body})]})]},l.title)),e.jsxs("li",{className:"flex items-start gap-3 border-t border-border/60 pt-4",children:[e.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(sc,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Questions?"}),e.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Visit the"," ",e.jsx(Ua,{to:"/help",className:"font-medium text-[hsl(var(--brand-navy))] hover:underline",children:"Help Center"})," ","for more details."]})]})]})]})]})})}const oo=c.createContext(null);function Yu({counter:r,children:a}){return e.jsx(oo.Provider,{value:(r==null?void 0:r.trim())||null,children:a})}function $u(){return c.useContext(oo)}function os({counter:r,suffix:a,className:t}){const o=$u(),m=(r==null?void 0:r.trim())||o;if(!m)return null;const g=a==null?void 0:a.trim();return e.jsx("span",{className:ye("inline-flex w-fit items-center rounded-full border border-primary/20 bg-primary/10 px-2.5 py-1 text-xs font-semibold text-primary",t),children:g?`${m} · ${g}`:m})}function fa({answers:r,defaultOpen:a=!1}){const[t,o]=c.useState(a),[m,g]=c.useState(!1),u=c.useRef(null),l=c.useCallback(()=>{u.current!=null&&(clearTimeout(u.current),u.current=null)},[]),_=c.useCallback(()=>{l(),g(!1),u.current=setTimeout(()=>{g(!0),u.current=null},400)},[l]);c.useEffect(()=>(a&&_(),l),[a,_,l]);const b=k=>{o(k),k?_():(l(),g(!1))},S=r.length,v=t&&!m;return e.jsxs(Rc,{open:t,onOpenChange:b,className:"rounded-xl border border-border/70 bg-background/80",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-4 py-3",children:[e.jsx(Cc,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-3 rounded-lg text-left transition-colors hover:bg-muted/40 focu
1s-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30","aria-expanded":t,children:[e.jsx(Oa,{className:ye("mt-0.5 h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200",t&&"rotate-180")}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"What you've submitted"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S>0?`${S} eligibility question${S===1?"":"s"} - click to ${t?"hide":"view"} answers`:"Your eligibility answers for this role"})]})]})}),e.jsxs(je,{className:"gap-1 rounded-full border-primary/20 bg-primary/10 text-primary hover:bg-primary/10",children:[e.jsx(gs,{className:"h-3 w-3"}),"Submitted"]})]}),e.jsx(Ec,{children:e.jsx("div",{className:"border-t border-border/60",children:v?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 px-4 py-10 text-sm text-muted-foreground","aria-busy":"true","aria-live":"polite",children:[e.jsx(as,{className:"h-5 w-5 animate-spin text-primary"}),e.jsx("span",{children:"Loading your answersâ¦"})]}):r.length===0?e.jsx("p",{className:"px-4 py-4 text-sm text-muted-foreground",children:"Your eligibility for this role was recorded. Individual answers are not available to display."}):e.jsx("ul",{className:"divide-y divide-border/60 animate-in fade-in-0 duration-200",children:r.map((k,B)=>e.jsx("li",{className:"px-4 py-4 sm:px-5",children:(()=>{const E=Uc(k.answer,k.type),s=Mc(E);return e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Question ",B+1]}),e.jsxs("div",{className:"mt-2 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[e.jsx("p",{className:"min-w-0 flex-1 text-sm font-semibold leading-6 text-foreground",children:k.text}),e.jsx("div",{className:"shrink-0",children:e.jsx("span",{className:ye("inline-flex min-w-[96px] items-center justify-center rounded-full border px-3 py-1.5 text-sm font-semibold shadow-sm",s.className),children:s.label})})]})]})})()},k.question_id||`q-${B}`))})})})]})}function Qr({children:r}){return e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsx(ie,{className:"space-y-5 p-5 sm:p-6",children:r})})}function qu({jobId:r,stepCounter:a,slug:t,jobTitle:o,companyName:m,jobLocation:g,isCurrentStep:u,nextStepTitle:l,onEligibilityChanged:_,onAdvanceToResume:b,compactWhenPassed:S=!1}){const[v,k]=c.useState(!0),[B,E]=c.useState("pending"),[s,q]=c.useState([]),[R,L]=c.useState([]),[N,P]=c.useState(null),[K,xe]=c.useState(0),J=c.useCallback(()=>xe(W=>W+1),[]);c.useEffect(()=>{let W=!1;return(async()=>{k(!0),P(null);try{const V=await Pc(r);if(W)return;E(V.eligibility_screen_status||"pending");const be=new Map((V.questions??[]).map(ve=>[ve.id,ve])),G=(V.submitted_answers??[]).map(ve=>{const A=be.get(ve.question_id),_e=(ve.text||"").trim();return{...ve,text:(!_e||_e==="Eligibility question")&&(A!=null&&A.text)?A.text:ve.text||(A==null?void 0:A.text)||"Eligibility question",type:ve.type||(A==null?void 0:A.type)||"short_text"}});q(G),L(V.other_roles??[])}catch{W||P("Could not load eligibility details. Please try again.")}finally{W||k(!1)}})(),()=>{W=!0}},[r,K]);const re=c.useCallback(()=>{_==null||_(),J(),b==null||b()},[_,b,J]),F=c.useCallback(W=>{L(W),E("not_matched"),_==null||_(),J()},[_,J]);if(v)return e.jsx(Qr,{children:e.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[e.jsx(as,{className:"h-4 w-4 animate-spin"}),"Loading eligibilityâ¦"]})});if(N)return e.jsx(Qr,{children:e.jsx("p",{className:"text-sm text-destructive",children:N})});const U=u&&B!=="passed"&&B!=="not_matched",me=B==="not_matched";if(S&&B==="passed"&&!U)return e.jsxs("div",{className:"space-y-2","data-testid":"applied-eligibility-collapsed",children:[e.jsx("p",{className:"px-0.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Questions"}),e.jsx(fa,{answers:s,defaultOpen:!1})]});const D=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(os,{counter:(a==null?void 0:a.trim())||"Step 1",suffix:U?"Required":null}),!U&&u?e.jsx(je,{className:"rounded-full bg-primary/10 text-primary hover:bg-primary/10",children:"Current step"}):null]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:U?"Answer a few questions for this role":"Eligibility review"}),e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:U?"These questions are required. They help us check basic fit before you submit your resume. Usually under 2 minutes.":B==="not_matched"?"Based on your answers, this role may not be the best fit.":"We're verifying that you meet the basic requirements for this role. This helps ensure a good fit before moving forward."})]})]}),ne=U?null:e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted/40 px-3 py-2.5 text-xs text-muted-foreground",children:[e.jsx(Tr,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("p",{children:u?"We'll notify you when there's an update. No action is needed right now.":"This step is complete. Select another journey step to continue reviewing your application."})]}),X=!U&&B==="passed"&&l?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-xl border border-border/70 bg-background px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"What happens next"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"If eligible, your application continues to the next stage."})]}),e.jsxs(je,{variant:"secondary",className:"rounded-full",children:["Next: ",l]})]}):null,Z=U?e.jsxs(Qr,{children:[D,e.jsx(Tc,{jobId:r,slug:t,jobLocation:g,embedded:!0,onPassed:re,onNotMatched:F})]}):me?e.jsxs(Qr,{children:[D,e.jsx(fa,{answers:s,defaultOpen:!0}),ne]}):e.jsxs(Qr,{children:[D,e.jsx(fa,{answers:s}),X,ne]});return me?e.jsxs("div",{className:"grid grid-cols-1 items-start gap-5 xl:grid-cols-[minmax(0,1.15fr)_minmax(340px,0.85fr)] xl
1:gap-6",children:[e.jsx("div",{className:"min-w-0",children:Z}),e.jsx("div",{className:"min-w-0",children:e.jsx(Ic,{otherRoles:R,jobTitle:o,companyName:m})})]}):e.jsxs("div",{className:"grid grid-cols-1 items-start gap-5 lg:grid-cols-3 lg:gap-6",children:[e.jsx("div",{className:"lg:col-span-2",children:Z}),e.jsx(io,{className:"border-border/70 shadow-sm lg:sticky lg:top-6"})]})}const Hu=12;function Vu({attemptId:r,enabled:a=!0,hasThumbnail:t=null,thumbnailStatus:o=null,inventoryThumbnailUrl:m=null}){const[g,u]=c.useState(null),[l,_]=c.useState("idle"),[b,S]=c.useState(0),v=c.useRef(null),k=c.useRef(0),B=c.useCallback(()=>{S(s=>s+1)},[]),E=c.useCallback(s=>{var q;(q=v.current)!=null&&q.startsWith("blob:")&&v.current!==s&&URL.revokeObjectURL(v.current),v.current=s!=null&&s.startsWith("blob:")?s:null,u(s)},[]);return c.useEffect(()=>{const s=Oc(typeof o=="string"?o:null);if(!a||!r){k.current+=1,E(null),_("idle");return}const q=(m==null?void 0:m.trim())||null,R=Fc({hasThumbnail:t,thumbnailStatus:s});if(!R&&!q){k.current+=1,E(null),_(t===!1||s==="missing"||s==="failed"?"missing":"idle");return}const L=++k.current,N=new AbortController;let P=0,K=null;const xe=va.getAccessToken();_(s==="uploading"?"uploading":"loading");const J=U=>{if(L!==k.current){U.startsWith("blob:")&&URL.revokeObjectURL(U);return}E(U),_("ready")},re=async()=>{if(!q)return!1;const U=await eo(q,{token:xe,signal:N.signal});return U?(J(U),!0):!1},F=async()=>{K=null;try{if(await re())return;if(!R){L===k.current&&(E(null),_("missing"));return}const U=await Wc(r,{token:xe,signal:N.signal});if(L!==k.current){U.kind==="ready"&&U.displayUrl.startsWith("blob:")&&URL.revokeObjectURL(U.displayUrl);return}if(U.kind==="ready"){J(U.displayUrl);return}if(U.kind==="uploading"){if(P+=1,P<=Hu){_("uploading"),K=setTimeout(()=>{F()},Math.max(1e3,U.retryAfterSeconds*1e3));return}E(null),_("missing");return}if(U.kind==="missing"){E(null),_("missing");return}E(null),_("error")}catch(U){if(L!==k.current||U instanceof DOMException&&U.name==="AbortError")return;E(null),_("error")}};return F(),()=>{K&&clearTimeout(K),N.abort(),k.current+=1}},[r,a,t,o,m,b,E]),c.useEffect(()=>()=>{var s;(s=v.current)!=null&&s.startsWith("blob:")&&(URL.revokeObjectURL(v.current),v.current=null)},[]),{thumbnailUrl:g,status:l,retry:B}}function Ku(r,a){return gd(a)}function zu(r){return Wi([r])}function Au(r,a=!0){const t=r??"",o=!!(a&&t);return c.useSyncExternalStore(m=>o?Ku(t,m):()=>{},()=>o?zu(t):!1,()=>!1)}const Gu=3e3,Qu=15e3,Xu=8;function Zu(r){return r==="failed"||r==="missing"||r==="purged"}function Ju({attemptId:r,playbackUrl:a,enabled:t=!0,inventoryStatus:o=null,hasFinalMedia:m}){const g=Au(r,t&&!!r),[u,l]=c.useState(null),[_,b]=c.useState(null),[S,v]=c.useState(!1),[k,B]=c.useState(!1),[E,s]=c.useState(null),[q,R]=c.useState("idle"),[L,N]=c.useState(null),P=c.useRef(0),[K,xe]=c.useState(0),J=c.useCallback(()=>{xe(F=>F+1)},[]);return c.useEffect(()=>{if(!t||!r){P.current+=1,l(O=>(O!=null&&O.startsWith("blob:")&&URL.revokeObjectURL(O),null)),b(null),N(O=>(O!=null&&O.startsWith("blob:")&&URL.revokeObjectURL(O),null)),v(!1),s(null),B(!1),R("idle");return}if(g){B(!0),s(null),R("uploading");const O=window.setInterval(()=>{Wi([r])||xe(Ee=>Ee+1)},2e3);return()=>window.clearInterval(O)}const F=++P.current,U=`/api/attempts/review/${r}/final_media/`,me=`${pd}${U}`,D=Zu(o),ne=D||m===!1&&o!=="uploading"?1:Xu,X=g||o==="uploading"||!D&&m!==!1&&o==null,Z=g||o==="uploading"?Qu:Gu;B(!0),s(null),v(!1),o==="uploading"&&!a?R("uploading"):D&&!a?(R("missing"),s(o==="purged"?"Recording was purged by retention policy.":"No recording available"),B(!1)):R("loading");const W=va.getAccessToken(),V=new AbortController,be=setTimeout(()=>V.abort(),6e5);let G=0,ve=0,A=null,_e=!1;const Ue=async O=>{if(F===P.current){if(bd(O)){const Ee=await Xl(O,{token:W,signal:V.signal});if(F!==P.current)return;b(null),l(we=>(we!=null&&we.startsWith("blob:")&&URL.revokeObjectURL(we),Ee))}else{const Ee=yd(O);if(F!==P.current)return;Ee.startsWith("http://")||Ee.startsWith("https://")?b(Ee):b(null),l(we=>(we!=null&&we.startsWith("blob:")&&URL.revokeObjectURL(we),Ee))}_e=!0,s(null),R("ready"),B(!1)}},Me=()=>{b(null),l(O=>(O!=null&&O.startsWith("blob:")&&URL.revokeObjectURL(O),null))},Y=async O=>{const Ee=$c(r,O);if(!Ee)return;const we=await eo(Ee,{token:W,signal:V.signal});F!==P.current||!we||N(Ye=>(Ye!=null&&Ye.startsWith("blob:")&&URL.revokeObjectURL(Ye),we))},C=Promise.resolve(),Te=()=>{A=null,fetch(me,{headers:{...W?{Authorization:`Bearer ${W}`}:{},"ngrok-skip-browser-warning":"true"},signal:V.signal}).then(async O=>{if(O.status===202){let Ie=15;try{const ge=await O.json();Ie=ca(ge)}catch{}throw ma(Ie)}if(!O.ok){O.status;const Ie=new Error(O.status===404?"No recording available":O.status===403?"Recording unavailable (permission)":`Failed to load video (${O.status})`);throw Ie.status=O.status,Ie}const Ee=O.headers.get("Content-Type")??"",we=O.clone();if(Ee.includes("application/json")){const Ie=await O.json();if(ci(Ie))throw ma(ca(Ie));Y(Ie);const ge=mi(Ie);if(ge)return ge;throw new Error("No download_url returned from final_media endpoint")}try{const Ie=await O.json();if(ci(Ie))throw ma(ca(Ie));Y(Ie);const ge=mi(Ie);if(ge)return ge}catch(Ie){if(ui(Ie))throw Ie}const Ye=await we.blob();if(Ye.type&&!Ye.type.startsWith("video/"))throw new Error("Video failed to play. The file may be incomplete or in an unsupported format.");return URL.createObjectURL(Ye)}).then(async O=>{await Ue(O)}).catch(O=>{if(F!==P.current||O instanceof DOMException&&O.name==="AbortError")return;if(ui(O)){if(ve+=1,ve<=Yc){_e||(R("uploading"),s(null),B(!0));
1const Ye=Math.max(1e3,O.retryAfterSeconds*1e3);A=setTimeout(Te,Ye);return}if(_e){R("ready"),s(null);return}R("error"),s("Recording upload is taking longer than expected. Retry when your connection is stable."),Me();return}const Ee=O.status;if(Ee===403){R("forbidden"),s("Recording unavailable (permission)"),Me();return}if(Ee===404){if(G+=1,G<ne&&X){_e||(R("uploading"),s(null)),A=setTimeout(Te,Z);return}if(_e){R("ready"),s(null);return}R("missing"),s(o==="purged"?"Recording was purged by retention policy.":"No recording available"),Me();return}if(_e){R("ready"),s(null);return}const we=O instanceof Error?O.message:"Failed to load recording";R("error"),s(we),Me()}).finally(()=>{F===P.current&&!A&&B(!1)})};return C.finally(()=>{F===P.current&&Te()}),()=>{clearTimeout(be),A&&clearTimeout(A),V.abort(),P.current+=1}},[r,t,a,K,o,m,g]),{videoBlobUrl:u,videoRemoteUrl:_,videoTriedBlobFallback:S,videoLoading:k,videoError:E,videoStatus:q,thumbnailUrl:L,retryLoad:J,retryBlobFallback:async F=>{v(!0),B(!0),s(null),R("loading");try{const U=await Xl(F,{token:va.getAccessToken()});l(me=>(me!=null&&me.startsWith("blob:")&&URL.revokeObjectURL(me),U)),s(null),R("ready")}catch(U){s(U instanceof Error?U.message:"Video failed to play."),R("error"),l(me=>(me!=null&&me.startsWith("blob:")&&URL.revokeObjectURL(me),null))}finally{B(!1)}}}}function Di(r){if(!r)return"-";const a=new Date(r);return Number.isNaN(a.getTime())?"-":Xr(a,"MMM d, yyyy, h:mm a")}function eh(r){if(r.startedAt&&r.endedAt){const a=new Date(r.endedAt).getTime()-new Date(r.startedAt).getTime();if(a>0){const t=Math.floor(a/6e4),o=Math.floor(a%6e4/1e3);return`${t}m ${o}s`}}return null}function Et({label:r,value:a,tabular:t=!1}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:r}),e.jsx("span",{className:`font-medium text-foreground text-right${t?" tabular-nums":""}`,children:a})]})}function sh({entry:r,createdAt:a,attemptsMax:t,fallbackJobTitle:o,fallbackScenarioTitle:m,expanded:g,onToggle:u}){const[l,_]=c.useState("overview"),[b,S]=c.useState(null),v=c.useRef(null),{rehearsal:k,isLoading:B}=Vd({attemptId:r.attemptId,enabled:g,fallbackJobTitle:o,fallbackScenarioTitle:m}),{thumbnailUrl:E,status:s}=Vu({attemptId:r.attemptId,enabled:!0,hasThumbnail:r.hasThumbnail??null,thumbnailStatus:r.thumbnailStatus??null,inventoryThumbnailUrl:r.thumbnailUrl??null}),{videoBlobUrl:q,videoRemoteUrl:R,videoTriedBlobFallback:L,videoLoading:N,videoError:P,videoStatus:K,thumbnailUrl:xe,retryLoad:J,retryBlobFallback:re}=Ju({attemptId:r.attemptId,playbackUrl:null,enabled:g&&l==="overview",inventoryStatus:r.finalMediaStatus??null,hasFinalMedia:r.hasFinalMedia}),F=E||xe||null,U=r.finalMediaStatus==="playable"||r.hasFinalMedia===!0||K==="ready"||!!q,me=em(r,{mediaReady:U}),D=me.completed,ne=me.label,X=k.ended_at||k.created_at||a,Z=eh({startedAt:k.started_at,endedAt:k.ended_at}),W=[Di(X),Z].filter(Boolean).join(" ⢠"),V=()=>{R&&!L&&re(R)};return e.jsxs("div",{className:ye("rounded-xl border bg-background transition-colors",g?"border-primary/30 shadow-sm":"border-border/70"),children:[e.jsxs("div",{className:"flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"relative h-12 w-[4.5rem] shrink-0 overflow-hidden rounded-md border border-border/70 bg-muted/40",children:E?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:E,alt:"",className:"h-full w-full object-cover"}),e.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-black/25","aria-hidden":!0,children:e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-black/55 text-white",children:e.jsx(rc,{className:"h-3 w-3 fill-current"})})})]}):s==="loading"||s==="uploading"?e.jsxs("div",{className:"flex h-full w-full items-center justify-center text-muted-foreground",children:[e.jsx(as,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:"Loading thumbnail"})]}):e.jsx("div",{className:"flex h-full w-full items-center justify-center text-xs font-bold tabular-nums text-muted-foreground",children:r.attemptNumber})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-semibold text-foreground",children:["Attempt ",r.attemptNumber]}),D?e.jsxs(je,{className:"rounded-full border-primary/20 bg-primary/10 text-primary hover:bg-primary/10",children:[e.jsx(gs,{className:"mr-1 h-3 w-3"}),"Completed"]}):e.jsx(je,{variant:"secondary",className:"rounded-full",children:ne||"In progress"})]}),W?e.jsx("p",{className:"text-xs text-muted-foreground",children:W}):null]})]}),e.jsxs(ae,{variant:"outline",size:"sm",className:ye("h-9 gap-1.5 font-semibold shrink-0",g&&"bg-muted/60"),onClick:u,children:[g?"Hide this rehearsal":"Watch this rehearsal",g?e.jsx(Gi,{className:"h-3.5 w-3.5"}):e.jsx(Oa,{className:"h-3.5 w-3.5"})]})]}),g?e.jsx("div",{className:"border-t border-border/70 px-4 pb-4 pt-3",children:B?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[e.jsx(as,{className:"h-4 w-4 animate-spin"}),"Loading attempt detailsâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsxs(Zc,{value:l,onValueChange:be=>_(be),className:"w-full",children:[e.jsxs(Jc,{className:"mb-4 grid h-auto w-full grid-cols-2 gap-1 rounded-none border-b border-border/40 bg-transparent p-0 sm:grid-cols-4",children:[e.jsxs(yt,{value:"overview",className:"gap-1.5 rounded-none border-b-2 border-transparent px-2 py-2.5 text-sm font-medium text-muted-foreground data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-primary data-[state=active]:shadow-none",children:[e.jsx(tc,{
1className:"h-3.5 w-3.5"}),"Overview"]}),e.jsxs(yt,{value:"analysis",className:"gap-1.5 rounded-none border-b-2 border-transparent px-2 py-2.5 text-sm font-medium text-muted-foreground data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-primary data-[state=active]:shadow-none",children:[e.jsx(ac,{className:"h-3.5 w-3.5"}),"AI Analysis"]}),e.jsxs(yt,{value:"transcript",className:"gap-1.5 rounded-none border-b-2 border-transparent px-2 py-2.5 text-sm font-medium text-muted-foreground data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-primary data-[state=active]:shadow-none",children:[e.jsx(ss,{className:"h-3.5 w-3.5"}),"Transcript"]}),e.jsxs(yt,{value:"evidence",className:"gap-1.5 rounded-none border-b-2 border-transparent px-2 py-2.5 text-sm font-medium text-muted-foreground data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-primary data-[state=active]:shadow-none",children:[e.jsx(Lt,{className:"h-3.5 w-3.5"}),"Evidence"]})]}),e.jsx(vt,{value:"overview",className:"mt-0 space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[e.jsx("div",{className:"overflow-hidden rounded-xl border border-border/70 bg-black/5",children:K==="uploading"&&!F?e.jsx("div",{className:"relative flex aspect-video flex-col items-center justify-center gap-3 overflow-hidden px-6 text-center",children:e.jsxs("div",{className:"relative z-10 flex flex-col items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(as,{className:"h-4 w-4 animate-spin"}),"Recording still uploadingâ¦"]}),e.jsx(ae,{type:"button",variant:"outline",size:"sm",onClick:()=>J(),children:"Retry"})]})}):K==="forbidden"?e.jsx("div",{className:"flex aspect-video items-center justify-center px-6 text-center text-sm text-muted-foreground",children:"Recording unavailable (permission)"}):F||q||N?e.jsx(qc,{src:q,posterUrl:F,isSourceLoading:N||K==="loading"||K==="uploading"||!q&&K!=="missing"&&K!=="error",videoRef:v,"aria-label":"Play rehearsal recording",onError:V}):K==="missing"||P==="No recording available"||P!=null&&P.includes("purged")?e.jsxs("div",{className:"flex aspect-video flex-col items-center justify-center gap-2 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("p",{children:P!=null&&P.includes("purged")?P:"No recording available"}),P!=null&&P.includes("purged")?null:e.jsx("p",{className:"text-xs",children:"This rehearsal may not have finished uploading, or the recording was not saved."}),e.jsx(ae,{type:"button",variant:"outline",size:"sm",onClick:()=>J(),children:"Retry"})]}):P?e.jsxs("div",{className:"flex aspect-video flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("p",{children:P}),e.jsx(ae,{type:"button",variant:"outline",size:"sm",onClick:()=>J(),children:"Retry"})]}):e.jsx("div",{className:"flex aspect-video items-center justify-center px-6 text-center text-sm text-muted-foreground",children:"No recording available"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-border/70 p-4",children:[e.jsx("h4",{className:"mb-3 text-sm font-bold text-foreground",children:"Attempt Summary"}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(Et,{label:"Status",value:D?"Completed":ne||"In progress"}),e.jsx(Et,{label:"Duration",value:Z||"-"}),e.jsx(Et,{label:"Submitted",value:Di(X)}),e.jsx(Et,{label:"Attempt",value:`${r.attemptNumber} of ${t}`,tabular:!0})]})]}),e.jsxs("div",{className:"rounded-xl border border-border/70 p-4",children:[e.jsx("h4",{className:"mb-2 text-sm font-bold text-foreground",children:"Performance Feedback"}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(gs,{className:"mt-0.5 h-4 w-4 shrink-0 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:D?"Complete":ne||"In progress"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Review the evidence to see how you did."})]})]})]})]})]})}),e.jsx(vt,{value:"analysis",className:"mt-0",children:e.jsx(la,{rehearsal:k,onClose:()=>{},onTryAgain:()=>{},layout:"panel-only",panel:"analysis"})}),e.jsx(vt,{value:"transcript",className:"mt-0",children:e.jsx(la,{rehearsal:k,onClose:()=>{},onTryAgain:()=>{},layout:"panel-only",panel:"transcript",highlightedTranscriptIndex:b})}),e.jsx(vt,{value:"evidence",className:"mt-0",children:e.jsx(la,{rehearsal:k,onClose:()=>{},onTryAgain:()=>{},layout:"panel-only",panel:"evidence",onJumpToTranscript:be=>{S(be),_("transcript")}})})]}),e.jsxs("div",{className:"mt-4 flex items-start gap-2 rounded-xl border border-amber-200/80 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:[e.jsx(nc,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-500"}),e.jsx("p",{children:"This is your rehearsal feedback. Rehearsal scores stay private - your verified BitScore appears on the Final result step after recruiter review."})]})]})}):null]})}const Bi="Skip rehearsal";function rh({stageKey:r,title:a,description:t,jobTitle:o,isCurrentStep:m,isBehavioural:g=!1,attemptsMax:u,attempts:l,attemptCreatedAtById:_,continueLabel:b,continueDisabled:S,continuing:v,onContinue:k,scoresLoading:B,rehearsalTimeHours:E,onStartRehearsal:s,canStartRehearsal:q,startingRehearsal:R,onTryPractice:L,practiceSubmitting:N,rehearsalDurationSeconds:P,isSafetyRehearsal:K=!1,isSkipped:xe=!1,skipSubmitting:J=!1,onSkipRehearsal:re,undoEligible:F=!1,undoSubmitting:U=!1,onUndoSkip:me,stepCounter:D}){const[ne,X]=c.useState(null),Z=l.length>0?l[l.length-1]:null,W=g?a||Ce:a||"Rehearsal",V=E!=null&&Number.isFinite(E)&&E>0?Math.round(E):null;c.useEffect(()=>{X(null)},[r]);const be=m&&!g&&!xe&&l.length===0&&(q||!!L);if(xe)return e.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-3 lg:gap-6",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"p-6 space-y-5",children:[e.jsx(os,{counter:D}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("span",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground",children:e.jsx(Tr,{className:"h-6 w-6",strokeWidth:2.5})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:"Resume only · no BitScore"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground leading-relaxed",children:"You skipped the rehearsal. The hiring team can still review your resume and may still invite you to interview, but this application has no BitScore."})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-border bg-muted/40 px-4 py-3",children:[e.jsx(Tr,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:"A BitScore is only issued after a recorded rehearsal take. Without one, you move forward on resume alone."})]})]})})}),e.jsx("div",{className:"lg:sticky lg:top-6",children:e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"p-5 space-y-3",children:[e.jsx("p",{className:"text-sm font-bold text-foreground",children:"Change your mind?"}),F?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Add a rehearsal before the shortlist goes out and you can still earn a BitScore for this role."}),e.jsx(ae,{variant:"outline",className:"w-full gap-2 font-semibold",onClick:me,disabled:U,children:U?"Restoringâ¦":e.jsxs(e.Fragment,{children:[e.jsx(Ns,{className:"h-4 w-4"}),"Add a rehearsal"]})})]}):e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"The shortlist has gone out. You can no longer add a rehearsal for this application."})]})})})]});if(be){const G=R||N||J;return e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"space-y-8 p-6 sm:p-10",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(os,{counter:D}),e.jsx("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Rehearse. It is how you set yourself apart."}),e.jsxs("div",{className:"max-w-lg space-y-1.5 text-base leading-relaxed text-muted-foreground",children:[e.jsx("p",{children:"Recommended. This is how you earn a BitScore. A short recorded answer gives the recruiter more than a resume can."}),e.jsx("p",{children:"Your camera stays off unless you turn it on."}),e.jsx("p",{children:"Skip and you continue on resume only · no BitScore for this application."})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:gap-5",children:[q&&s?e.jsx(ae,{size:"lg",className:"h-12 gap-2 px-6 text-base font-semibold",onClick:s,disabled:G,children:R?"Startingâ¦":e.jsxs(e.Fragment,{children:[e.jsx(Wa,{className:"h-[18px] w-[18px]"}),"Start rehearsal",e.jsx(Ns,{className:"h-4 w-4"})]})}):null,e.jsxs("div",{className:"flex items-center gap-4",children:[L?e.jsx(ae,{variant:"link",className:"h-auto gap-1.5 p-0 font-semibold text-[hsl(var(--brand-navy))]",onClick:L,disabled:G,children:N?"Opening practiceâ¦":e.jsxs(e.Fragment,{children:["Practice first",e.jsx(Ns,{className:"h-4 w-4"})]})}
1):null,L&&re?e.jsx("span",{"aria-hidden":!0,className:"h-5 w-px bg-border"}):null,re?e.jsx(ae,{variant:"link",className:"h-auto p-0 font-medium text-muted-foreground no-underline hover:text-foreground",onClick:re,disabled:G,children:J?"Skippingâ¦":Bi}):null]})]}),K?e.jsx("p",{className:"text-sm text-muted-foreground",children:"This rehearsal covers a safety situation for this role, so it is a required part of your application and cannot be skipped."}):null,e.jsx("p",{className:"text-sm text-muted-foreground",children:"Practice rounds are not scored and are never shown to an employer."})]})})}return e.jsx("div",{className:"space-y-5",children:e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"space-y-5 p-5 sm:p-6",children:[e.jsx("div",{className:"flex flex-wrap items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx(os,{counter:D,className:"mb-2"}),e.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:W}),m?e.jsx(je,{variant:"outline",className:"rounded-full border-primary/30 text-primary",children:"Current step"}):null]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t||(g?`Complete your ${Ce} for this role.`:V?`You've been selected for a rehearsal! You have ${V} hours to complete it.`:"Complete a recorded rehearsal to showcase your fit for this role.")})]})}),(m||b)&&b&&k?e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsxs(ae,{className:"h-10 gap-2 font-semibold",disabled:S||v,onClick:k,children:[v?"Startingâ¦":b,v?null:e.jsx(Ns,{className:"h-4 w-4"})]})}):null,e.jsxs("div",{className:"space-y-3 border-t border-border/70 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:"Your rehearsals"}),B?e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Loading rehearsalsâ¦"}):null]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.length>0?`Attempt ${(Z==null?void 0:Z.attemptNumber)??l.length} of ${u}`:`0 of ${u} attempts`})]}),l.length>0?e.jsx("div",{className:"space-y-2",children:[...l].reverse().map(G=>e.jsx(sh,{entry:G,createdAt:_==null?void 0:_[G.attemptId],attemptsMax:u,fallbackJobTitle:o,fallbackScenarioTitle:G.scenarioTitle||W,expanded:ne===G.attemptId,onToggle:()=>X(ve=>ve===G.attemptId?null:G.attemptId)},G.attemptId))}):e.jsx("div",{className:ye("rounded-xl border border-dashed border-border/80 bg-muted/10 px-4 py-6 text-center text-sm text-muted-foreground"),children:m?"No rehearsals yet. Start when you're ready.":"No rehearsals were recorded for this stage."}),m&&!xe&&re?e.jsxs("div",{className:"space-y-1.5 border-t border-border/70 pt-3",children:[e.jsxs(ae,{variant:"ghost",size:"sm",className:"gap-1.5 text-muted-foreground hover:text-foreground",onClick:re,disabled:J||R,children:[J?"Skippingâ¦":Bi,J?null:e.jsx(Ns,{className:"h-3.5 w-3.5"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Skip continues on resume only · no BitScore."})]}):m&&!xe&&K?e.jsx("div",{className:"border-t border-border/70 pt-3",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"This rehearsal covers a safety situation for this role. It is required, so it cannot be skipped."})}):null]})]})})})}function th({open:r,onOpenChange:a,onConfirm:t,submitting:o=!1}){return e.jsx(Na,{open:r,onOpenChange:a,children:e.jsxs(ka,{className:"max-w-md",children:[e.jsxs(Ra,{children:[e.jsx(Ca,{className:"text-xl",children:"We recommend the rehearsal"}),e.jsx(Ea,{className:"text-base",children:"It is how you set yourself apart from every other resume. Skip it and you will have no BitScore. You stay visible to the hiring team on your resume alone, and they can still invite you to interview. You can add a rehearsal later, until the shortlist goes out."})]}),e.jsxs(Ia,{className:"sm:flex-row-reverse sm:justify-start sm:gap-2",children:[e.jsx(Ta,{disabled:o,className:"mt-0",children:"Do the rehearsal"}),e.jsx(Sa,{disabled:o,onClick:m=>{m.preventDefault(),t()},className:"bg-transparent text-muted-foreground shadow-none hover:bg-muted hover:text-foreground",children:o?"Skippingâ¦":"Skip anyway"})]})]})})}let st=null;const Da=new Set;
1function co(){Da.forEach(r=>r())}function ah(r){return Da.add(r),()=>{Da.delete(r)}}function Pi(){return st}function nh(r){const a=r||null;st!==a&&(st=a,co())}function Ui(r){!r||st!==r||(st=null,co())}function lh(){return c.useSyncExternalStore(ah,Pi,Pi)}const Mi=[{label:"Reading your resume",stage:"CHECKING_SKILLS"},{label:"Matching role requirements",stage:"EVALUATING_EXPERIENCE"},{label:"Preparing your result",stage:"ASSESSING_ROLE_FIT"}];function ih(r){return!Number.isFinite(r)||r<=0?"":r<1024?`${r} B`:r<1024*1024?`${Math.max(1,Math.round(r/1024))} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function ga({jobId:r,slug:a,jobTitle:t,companyName:o,status:m,stepCounter:g,onComplete:u,variant:l="auto",embedded:_=!1,onBack:b}){const{toast:S}=Ma(),v=c.useRef(null),k=c.useRef(null),B=c.useRef(null),E=c.useRef(null),s=c.useRef(null),q=c.useRef(null),R=c.useRef(!1),L=c.useRef(!1),[N,P]=c.useState("upload"),[K,xe]=c.useState([]),[J,re]=c.useState(null),[F,U]=c.useState(null),[me,D]=c.useState(!1),[ne,X]=c.useState(!1),[Z,W]=c.useState(null),[V,be]=c.useState(!1),[G,ve]=c.useState(null),[A,_e]=c.useState(0),[Ue,Me]=c.useState(0),[Y,C]=c.useState(!1),[Te,O]=c.useState(!1),[Ee,we]=c.useState(!1),[Ye,Ie]=c.useState(Sc),ge=m?Pu(m):null,Qs=((ge==null?void 0:ge.attemptsUsed)??0)+1,Us=(ge==null?void 0:ge.maxAttempts)??2,Pt=(ge==null?void 0:ge.attemptsRemaining)??Math.max(0,Us-((ge==null?void 0:ge.attemptsUsed)??0)),$e=l==="minimal"||l==="auto"&&((ge==null?void 0:ge.attemptsUsed)??0)>=1,mr=_&&$e,lt=$e&&!mr&&((ge==null?void 0:ge.attemptsUsed)??0)>0&&Pt>0,Xs=lt?so():null;c.useEffect(()=>{if($e)return;let w=!1;return Pm().then(T=>{!w&&T.length&&xe(T)}).catch(()=>{}),()=>{w=!0}},[$e]),c.useEffect(()=>{V||N==="analyzing"?nh(r):Ui(r)},[V,N,r]),c.useEffect(()=>()=>{var w,T;Ui(r),(w=B.current)==null||w.abort(),(T=q.current)==null||T.stop()},[r]);const rs=c.useCallback(()=>{var w;(w=q.current)==null||w.stop(),q.current=null},[]),Ms=c.useCallback(()=>{rs();const w=Bc(T=>{Me(T.percent),_e(T.completedChecks)});return q.current=w,w.reset(),w.start(),w},[rs]),ps=c.useCallback(w=>{(q.current??Ms()).applyBackend(w)},[Ms]),Ve=c.useCallback(w=>{if(w){if(W(null),!Si(w)){W(Ct),re(null),D(!1),v.current&&(v.current.value=""),S({title:"Invalid file type",description:Ct,variant:"destructive"});return}if(w.size>Rt){const T=`Your file is too large. The maximum size is ${Rt/1048576} MB.`;W(T),re(null),D(!1),v.current&&(v.current.value=""),S({title:"File too large",description:T,variant:"destructive"});return}re(w),U(null),window.setTimeout(()=>D(!0),800)}},[S]),Sr=w=>{if(w.kind==="file")return{id:null,filename:w.file.name,sizeBytes:w.file.size,uploadedAt:new Date().toISOString()};const T=K.find(p=>p.id===w.resumeId);return{id:w.resumeId,filename:(T==null?void 0:T.filename)||"Selected resume",sizeBytes:(T==null?void 0:T.file_size)??null,uploadedAt:(T==null?void 0:T.created_at)??new Date().toISOString()}},Zs=c.useCallback(async w=>{var T;w.signal.aborted||((T=q.current)==null||T.markComplete(),await new Promise(p=>{window.setTimeout(p,700)}),!w.signal.aborted&&(Me(100),_e(Mi.length),rs(),await u(),w.signal.aborted||P("upload")))},[u,rs]),Os=async w=>{var p,de;W(null),be(!0),_e(0),Me(0),Ms();const T=new AbortController;B.current=T;try{try{await jd(a)}catch{}if(T.signal.aborted)return;const Xe=m??await Gs(r);if(Xe!=null&&Xe.has_eligibility_questions&&Xe.eligibility_screen_status!=="passed"){const Be=Xe.eligibility_screen_status==="not_matched"?"Your answers do not match the requirements for this role.":"Please complete eligibility questions before uploading your resume.";W(Be),S({title:"Eligibility required",description:Be,variant:"destructive"});return}if(T.signal.aborted||(w.kind==="file"&&await Li(r),T.signal.aborted))return;const i=w.kind==="existing"?await Jl({hiring_link_slug:a,job_id:r,resume_id:w.resumeId,opt_in_client_other_roles:Ye.optInClientOtherRoles,opt_in_bitstage_other_roles:Ye.optInBitstageOtherRoles}):await Jl({hiring_link_slug:a,job_id:r,file:w.file,opt_in_client_other_roles:Ye.optInClientOtherRoles,opt_in_bitstage_other_roles:Ye.optInBitstageOtherRoles});if(T.signal.aborted)return;ve({...Sr(w),id:i.id}),P("analyzing"),E.current=i.job_id??r,s.current=i.id,q.current||Ms(),be(!1);const es=i.job_id??r;E.current=es;let ns=await Gs(es);if(T.signal.aborted)return;if(i.score_status==="done"||i.already_scored||Lu(ns)||Du(ns)){ps({score_status:"done"}),await Zs(T);return}const Ys=await ki(Be=>ha(i.id,es,{signal:Be}),{intervalMs:1500,maxDurationMs:ei,shouldStop:Be=>
1da(Be.score_status),onUpdate:Be=>ps(Be),signal:T.signal});if(T.signal.aborted)return;if((Ys.score_status||"").toLowerCase()==="failed"){const Be=Ys.rejection_message||Ys.last_error||"We could not score that resume. Please upload it again.";W(Be),P("upload"),rs(),S({title:Ys.rejection_message?"We could not read that file":"Resume scoring failed",description:Be,variant:"destructive"});return}if(ns=await Gs(es),T.signal.aborted)return;(p=q.current)==null||p.markComplete(),await Zs(T)}catch(Xe){if(T.signal.aborted)return;const es=(de=_a(Xe).responseBody)==null?void 0:de.rejection_message,ns=Zl(Xe,"Upload failed. Please try again.");W(es||ns),P("upload"),rs(),re(null),D(!1),U(null),v.current&&(v.current.value=""),k.current&&(k.current.value=""),S({title:es?"We could not read that file":"Resume upload failed",description:es||ns,variant:"destructive"})}finally{be(!1),B.current===T&&(B.current=null)}},Js=()=>{var w;(w=B.current)==null||w.abort(),B.current=null},ds=async w=>{if(N!=="analyzing")return;const T=s.current??(G==null?void 0:G.id)??null;if(!T)return;q.current||Ms();const p=new AbortController;B.current=p;try{const de=await ha(T,w);if(p.signal.aborted)return;if(ps(de),da(de.score_status)){if((de.score_status||"").toLowerCase()==="failed"){const i=de.rejection_message||de.last_error||"We could not score that resume. Please upload it again.";W(i),P("upload"),rs();return}await Zs(p);return}const Xe=await ki(i=>ha(T,w,{signal:i}),{intervalMs:1500,maxDurationMs:ei,shouldStop:i=>da(i.score_status),onUpdate:i=>ps(i),signal:p.signal});if(p.signal.aborted)return;if((Xe.score_status||"").toLowerCase()==="failed"){const i=Xe.rejection_message||Xe.last_error||"We could not score that resume. Please upload it again.";W(i),P("upload"),rs();return}await Zs(p)}catch(de){if(p.signal.aborted)return;const Xe=de instanceof Error&&de.message.includes("maximum duration")?"Scoring is taking longer than usual. You can close this page. We will email you when the result is ready.":de instanceof Error?de.message:"Scoring is taking longer than usual. You can close this page and check back later.";W(Xe),P("upload"),rs()}finally{B.current===p&&(B.current=null)}},Fs=()=>{Js(),rs(),E.current=null,s.current=null,P("upload"),ve(null),re(null),D(!1),U(null),_e(0),Me(0),v.current&&(v.current.value=""),k.current&&(k.current.value="")},Ke=w=>{if(O(w),!w&&!R.current&&N==="analyzing"){const T=E.current;T&&ds(T)}w||(R.current=!1)},Ws=w=>{if(we(w),!w&&!L.current&&N==="analyzing"){const T=E.current;T&&ds(T)}w||(L.current=!1)},Ut=async(w,T)=>{if(w){if(!Si(w)){W(Ct),S({title:"Invalid file type",description:Ct,variant:"destructive"}),T!=null&&T.current&&(T.current.value="");return}if(w.size>Rt){const p=`Your file is too large. The maximum size is ${Rt/1048576} MB.`;W(p),S({title:"File too large",description:p,variant:"destructive"}),T!=null&&T.current&&(T.current.value="");return}W(null),C(!0);try{const p=E.current??r,de=G==null?void 0:G.id;Fs(),p?await Li(p,de?[de]:[]):de&&await La(de),re(w),U(null),D(!0),await Os({kind:"file",file:w})}catch(p){const de=Zl(p,"Please try again.");W(de),S({title:"Could not replace resume",description:de,variant:"destructive"}),P("upload")}finally{C(!1),T!=null&&T.current&&(T.current.value="")}}},ur=async()=>{we(!1),C(!0);try{const w=G==null?void 0:G.id;Fs(),w&&await La(w),S({title:"Resume removed",description:"Upload a new resume when you are ready to continue."})}catch(w){const T=_a(w);S({title:"Could not delete resume",description:T.serverMessage||"Please try again.",variant:"destructive"})}finally{C(!1)}},Ts=!V&&(!!(J&&me)||!$e&&!!F),hr=()=>{if(F){Os({kind:"existing",resumeId:F});return}J&&Os({kind:"file",file:J})};if(N==="analyzing")return e.jsxs("div",{className:"space-y-4",children:[G?e.jsx(Lc,{snapshot:G,onChangeResume:()=>{Js(),O(!0)},onDeleteResume:()=>{Js(),we(!0)},changeDisabled:Y,deleteDisabled:Y,isReplacing:Y}):null,e.jsx(le,{className:"overflow-hidden border-border/80 shadow-sm",children:e.jsxs(ie,{className:"space-y-6 px-6 py-8",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(as,{className:"mx-auto h-10 w-10 animate-spin text-primary"}),e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Scoring your resume for this roleâ¦"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["We are scoring your resume for ",t,". This page updates on its own when your result is ready."]})]}),e.jsxs("div",{className:"mx-auto max-w-lg space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-medium text-muted-foreground",children:[e.jsx("span",{children:"Scoring progress"}),e.jsxs("span",{children:[Math.round(Ue),"%"]})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-primary transition-[width] duration-500 ease-out",style:{width:`${Math.min(100,Math.max(0,Ue))}%`}})}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:Mi.map((w,T)=>{const p=A>T,de=A===T;return e.jsxs("div",{className:`rounded-lg border p-3 text-left text-xs ${p?"border-[hsl(var(--brand-green)/0.35)] bg-[hsl(var(--brand-pale-green))]":de?"border-primary/30 bg-card":"border-border/80 bg-muted/30 text-muted-foreground"}`,children:[e.jsx("div",{className:"mb-2 flex h-7 w-7 items-center justify-center rounded-full border",children:p?e.jsx(gs,{className:"h-3.5 w-3.5 text-[hsl(var(--brand-navy))]"}):de?e.jsx(as,{className:"h-3.5 w-3.5 animate-spin text-primary"}):e.jsx(at,{className:"h-3.5 w-3.5"})}),w.label]},w.label)})})]})]})}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Wrong file?"," ",e.jsx("button",{type:"button",className:"font-medium text-primary underline-offset-4 hover:underline",onClick:()=>{Js(),O(!0)},disabled:Y,children:"Change resume"})]}),e.jsx("input",{ref:k,type:"file",accept:Ti,className:"hidden",onChange:w=>{var T;return void Ut((T=w.target.files)==null?void 0:T[0],k)}}),e.jsx(Na,{open:Te,onOpenChange:Ke,children:e.jsxs(ka,{className:"max-w-md",children:[e.jsxs(Ra,{children:[e.jsx(Ca,{children:"Replace your resume?"}),e.jsxs(Ea,{children:["Choose a new file and we will score it for"," ",e.jsx("span",{className:"font-medium text-foreground",children:t}),". Scoring of your current resume stops right away."]})]}),e.jsxs(Ia,{children:[e.jsx(Ta,{disabled:Y,children:"Cancel"}),e.jsx(Sa,{disabled:Y,onClick:()=>{var w;R.current=!0,O(!1),(w=k.current)==null||w.click()},children:"Choose new file"})]})]})}),e.jsx(Na,{open:Ee,onOpenChange:Ws,children:e.jsxs(ka,{className:"max-w-md",children:[e.jsxs(Ra,{children:[e.jsx(Ca,{children:"Delete uploaded resume?"}),e.jsxs(Ea,{children:["This removes"," ",e.jsx("span",{className:"font-medium text-foreground",children:(G==null?void 0:G.filename)||"your resume"})," ","and stops scoring. You go back to the upload screen and can start again."]})]}),e.jsxs(Ia,{children:[e.jsx(Ta,{disabled:Y,children:"Keep resume"}),e.jsx(Sa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:Y,onClick:()=>{L.current=!0,ur()},children:"Delete resume"})]})]})})]});const er=()=>{re(null),U(null),D(!1),v.current&&(v.current.value="")},bs=F?K.find(w=>w.id===F):null,xr=!!J||!!(F&&!$e),sr=!xr&&!V,Mt=$e?null:e.jsxs("div",{className:"grid gap-3 rounded-xl border border-sky-100 bg-sky-50/80 px-4 py-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-sky-950",children:[e.jsx(gs,{className:"mt-0.5 h-4 w-4 shrink-0 text-sky-700"}),e.jsx("span",{children:"Required for this application"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-sky-950",children:[e.jsx(Jr,{className:"mt-0.5 h-4 w-4 shrink-0 text-sky-700"}),e.jsx("span",{children:"Only used for hiring for this role"})]})]}),Ot=J?e.jsxs("div",{className:"flex flex-wrap items-center gap-3 rounded-xl border border-border bg-background p-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-[hsl(var(--brand-navy))]/10",children:e.jsx(ss,{className:"h-5 w-5 text-[hsl(var(--brand-navy))]"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-foreground",children:J.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:ih(J.size)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(ae,{type:"button",variant:"secondary",size:"sm",className:"rounded-full",onClick:()=>{var w;return(w=v.current)==null?void 0:w.click()},children:"Replace"}),e.jsx(ae,{type:"button",variant:"secondary",size:"sm",className:"rounded-full",onClick:er,children:"Remove"})]})]}):bs?e.jsxs("div",{className:"flex flex-wrap items-center gap-3 rounded-xl border border-border bg-background p-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-[hsl(var(--brand-navy))]/10",children:e.jsx(ss,{className:"h-5 w-5 text-[hsl(var(--brand-navy))]"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-foreground",children:bs.filename||"Selected resume"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:bs.job_title?`from ${bs.job_title}`:"Previously uploaded"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(ae,{type:"button",variant:"secondary",size:"sm",className:"rounded-full",onClick:()=>{var w;return(w=v.current)==null?void 0:w.click()},children:"Replace"}),e.jsx(ae,{type:"button",variant:"secondary",size:"sm",className:"rounded-full",onClick:er,children:"Remove"})]})]}):null,ys=e.jsxs("button",{type:"button",onClick:()=>{var w;return(w=v.current)==null?void 0:w.click()},onDrop:w=>{var T;w.preventDefault(),X(!1),Ve((T=w.dataTransfer.files)==null?void 0:T[0])},onDragOver:w=>{w.preventDefault(),X(!0)},onDragLeave:()=>X(!1),className:`w-full rounded-xl border-2 border-dashed p-8 text-center transition-all ${ne?"scale-[1.01] border-primary bg-primary/10":"border-border hover:border-primary/50 hover:bg-muted/30"}`,children:[e.jsx(lc,{className:`mx-auto mb-3 h-10 w-10 ${ne?"text-primary":"text-[hsl(var(--brand-navy))]"}`}),e.jsx("p",{className:"text-sm font-semibold text-[hsl(var(--brand-navy))]",children:ne?"Release to upload":"Tap to choose your resume, or drag a file here"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"PDF, DOCX, TXT, RTF, or ODT ⢠Max 10MB"})]}),ze=e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:`flex flex-col gap-3 sm:flex-row sm:items-center ${b?"sm:justify-between":"sm:justify-end"}`,children:[b?e.jsx(ae,{type:"button",variant:"secondary",className:"min-h-11",onClick:b,children:"Back"}):null,e.jsxs("div",{className:"flex flex-col items-stretch gap-2 sm:items-end",children:[e.jsx(ae,{variant:"default",size:"lg",className:"group min-h-11 w-full sm:min-w-[14rem]",disabled:!Ts,onClick:hr,children:V?e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"h-4 w-4 animate-spin"}),"Uploadingâ¦"]}):e.jsxs(e.Fragment,{children:["Upload and continue",e.jsx(Ns,{className:"h-4 w-4 transition-transform group-hover:translate-x-1"})]})}),sr?e.jsxs("p",{className:"flex items-center justify-center gap-1.5 text-xs text-muted-foreground sm:justify-end",children:[e.jsx(Tr,{className:"h-3.5 w-3.5 shrink-0"}),"Please upload a resume to continue."]}):null]})]})});return e.jsxs("div",{className:"space-y-4",children:[Z?e.jsx("p",{className:"rounded-lg bg-destructive/10 p-3 text-sm text-destructive",role:"alert",children:Z}):null,!$e&&K.length>0&&!J&&!F?e.jsxs("div",{className:"mb-2",children:[e.jsxs(Yi,{children:[e.jsx(vd,{asChild:!0,children:e.jsxs(ae,{variant:"outline",className:"flex h-12 w-full items-center justify-center gap-2 rounded-xl border-primary/30 text-primary hover:bg-primary/5 hover:text-primary",children:[e.jsx(ss,{className:"h-4 w-4"}),"Select a previously uploaded resume"]})}),e.jsxs($i,{className:"max-w-md w-full",children:[e.jsxs(qi,{children:[e.jsx(Hi,{children:"Select a previously uploaded resume"}),e.jsx(Vi,{children:"Pick a resume you uploaded before. We will score it for this role."})]}),e.jsx("div",{className:"mt-2 max-h-[400px] space-y-2 overflow-y-auto pr-1",children:K.map(w=>e.jsx(_d,{asChild:!0,children:e.jsx("button",{type:"button",className:"flex w-full items-center justify-between rounded-lg border border-border p-3 text-left transition-all outline-none hover:border-primary/50 hover:bg-primary/5 focus:ring-2 focus:ring-primary/30",onClick:()=>
1{U(w.id),re(null),D(!0)},children:e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10",children:e.jsx(ss,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:w.filename||"Unnamed resume"}),e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:w.job_title?`from ${w.job_title}`:"Not linked to a job"})]})]})})},w.id))})]})]}),e.jsxs("div",{className:"flex items-center gap-3 px-0 pb-2 pt-6",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-center text-[11px] font-medium uppercase tracking-widest text-muted-foreground",children:"or upload a new resume"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]})]}):null,(()=>{const w=e.jsxs("div",{className:mr?"space-y-5 border-t border-border/60 pt-5":"space-y-5",children:[$e?lt&&Xs?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{className:"inline-flex items-center rounded-full border border-amber-200 bg-amber-50 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-[0.12em] text-amber-900",children:"Reserved"}),e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[e.jsx(oa,{className:"h-3.5 w-3.5"}),"Attempt ",Qs," of ",Us]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-lg font-bold tracking-tight text-foreground sm:text-xl",children:Xs.title}),e.jsxs("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:[Xs.description," Upload an updated resume to try again."]})]})]}):e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-lg font-bold text-foreground",children:[e.jsx(ss,{className:"h-5 w-5 text-primary"}),"Upload a new resume"]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[e.jsx(oa,{className:"h-3.5 w-3.5"}),"Attempt ",Qs," of ",Us]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-[hsl(var(--brand-pale-green))]",children:e.jsx(ss,{className:"h-4 w-4 text-[hsl(var(--brand-green))]"})}),e.jsxs("span",{className:"inline-flex items-center rounded-full border border-primary/20 bg-primary/10 px-2.5 py-1 text-xs font-semibold text-primary",children:[(g==null?void 0:g.trim())||"Step 1"," · Required"]}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 text-sm font-medium text-muted-foreground",children:[e.jsx(oa,{className:"h-3.5 w-3.5"}),"Attempt ",Qs," of ",Us,Qs===Us&&(ge!=null&&ge.canRetry)?e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:" (last attempt)"}):null]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:"Submit your resume"}),e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:"We score your resume against this role and show you the result on the next screen. It usually takes under a minute."})]})]}),xr?Ot:ys,e.jsx("input",{ref:v,type:"file",accept:Ti,className:"hidden",onChange:T=>{var p;return Ve((p=T.target.files)==null?void 0:p[0])}}),Mt,$e?null:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Next: a short AI rehearsal. It is optional, and we recommend doing it."}),$e?null:e.jsx(Um,{includeEmployerSharing:!0}),$e?null:e.jsx(Dc,{value:Ye,onChange:Ie,employerName:o}),ze]});return mr?w:$e?e.jsx(le,{children:e.jsx(ie,{className:"pt-6",children:w})}):e.jsx(le,{className:"border-border/60 shadow-sm",children:e.jsx(ie,{className:"space-y-6 p-6",children:w})})})()]})}function pa(r){if(!r)return null;const a=new Date(r).getTime()-Date.now();return Number.isFinite(a)?Math.floor(a/36e5):null}function mo({expiresAt:r,className:a}
1){const[t,o]=c.useState(()=>pa(r));return c.useEffect(()=>{o(pa(r));const m=window.setInterval(()=>o(pa(r)),6e4);return()=>window.clearInterval(m)},[r]),r?t==null||t<=0?e.jsx("p",{className:a,children:"Your rehearsal invitation has expired."}):t<48?e.jsxs("p",{className:a,children:["Your invite expires when this role closes -"," ",e.jsxs("strong",{children:[t," hour",t===1?"":"s"," remaining"]}),"."]}):e.jsxs("p",{className:a,children:["Your invitation link is valid for ",e.jsxs("strong",{children:[t," hour",t===1?"":"s"]}),"."]}):e.jsx("p",{className:a,children:"Complete your rehearsal before your invite expires."})}function Ya(r){return Math.floor(r)}const ba=90,ya=70,oh="You're through to the rehearsal. Start when you're ready.";function uo(r){const a=(r==null?void 0:r.resume_score)??(r==null?void 0:r.resume_best_score);if(a==null)return null;const t=typeof a=="number"?a:Number(a);return Number.isFinite(t)?t:null}function dh(r,a){var o;const t=String((a==null?void 0:a.resume_status)??"").toUpperCase();return!!(["UPLOADED","SCORING","SCORED","PASSED","FAILED"].includes(t)||(((o=a==null?void 0:a.resume_attempt_history)==null?void 0:o.length)??0)>0||r.resume_file||r.resume||r.resume_url)}function ch(r){const a=r==null?void 0:r.resume_attempt_history;return!Array.isArray(a)||a.length===0?null:[...a].sort((t,o)=>Number(o.attempt_number||0)-Number(t.attempt_number||0))[0]}function mh(r){const{application:a,status:t,resumeStepCompleted:o,laterStageStarted:m}=r,g=String((t==null?void 0:t.next_step)??"").toUpperCase(),u=String((t==null?void 0:t.resume_status)??"").toUpperCase(),l=String((t==null?void 0:t.resume_score_band)??"").toLowerCase(),_=String((t==null?void 0:t.batching_application_status)??"").toLowerCase(),b=uo(t),S=dh(a,t);if((t==null?void 0:t.requires_verification)===!0||g==="EMAIL_VERIFICATION_REQUIRED"||(t==null?void 0:t.is_verified_email)===!1&&u==="SCORED")return"email_verification_pending";if(o&&m)return"completed_review";if(sm(t)){const E=String((t==null?void 0:t.fast_track_status)??"").trim().toLowerCase(),s=String((t==null?void 0:t.next_step)??"").trim().toUpperCase();if(E==="parked_below_75"||s==="RESUME_RETRY_AVAILABLE"||s==="RESUME_UPLOAD_REQUIRED"||s==="RESUME_REQUIRED"||!(E==="bypassed_by_client"||E==="auto_invited"||E==="fast_lane_invited"||E==="queued_for_slot"||E==="reserve_75_79"||s==="START_REHEARSAL"||s==="RESUME_SCORED_START_REHEARSAL"||s==="REHEARSAL_INVITED"||s==="QUEUED_FOR_SLOT"))return"completed_review"}if(!S||g==="UPLOAD_RESUME"||g==="RESUME_REQUIRED"||g==="RESUME_UPLOAD_REQUIRED")return"not_uploaded";const v=ws?Bd:ya,k=u==="SCORING"||g==="RESUME_SCORING"||g==="RESUME_UNDER_REVIEW",B=l==="below_threshold"||g==="RESUME_RETRY_AVAILABLE"||b!=null&&b<v&&u==="SCORED";if(k&&!B)return"under_review";if(ws){const E=Ir(t),s=dr(t??{});switch(s){case"fast_lane_invited":case"auto_invited":{const q=String((t==null?void 0:t.fast_track_status)??"").trim().toLowerCase();return q==="fast_lane_invited"||q==="auto_invited"||q==="bypassed_by_client"||!!(t!=null&&t.rehearsal_invited_at)||ni(t)?s==="fast_lane_invited"?"fast_lane_invited":"auto_invited":"auto_invite_pending"}case"auto_invite_pending":return"auto_invite_pending";case"invite_blocked_insufficient_window":return"invite_window_too_short";case"bypassed_by_client":return"bypassed";case"queued_for_slot":return"queued_for_slot";case"reserve_75_79":return"reserve_75_79";case"ghosted":return"ghosted";case"parked_below_75":return E?"below_threshold_retry":"parked_below_75";case"rehearsal_in_progress":case"rehearsal_completed":case"work_style_invited":case"work_style_completed":case"in_recruiter_pool":return"completed_review"}}return l==="fast_track"||g==="RESUME_SCORED_START_REHEARSAL"||g==="START_REHEARSAL"||_==="rehearsal_invited"||_==="fast_tracked"||l===""&&b!=null&&b>=ba?ws&&!(t!=null&&t.rehearsal_invited_at)&&!ni(t)?(b!=null&&b>=ba,"auto_invite_pending"):"rehearsal_ready":l==="qualified"||g==="RESUME_SCORED_WAITING_INVITE"||g==="IN_QUALIFIED_POOL"||_==="resume_qualified"||_==="batch_queued"||_==="qualified_awaiting_invite"||l===""&&b!=null&&b>=ya&&b<ba?ws?"auto_invite_pending":"qualified_pool":l==="below_threshold"||g==="NOT_MOVING_FORWARD"||g==="RESUME_RETRY_AVAILABLE"||_==="not_moving_forward"||_==="rejected"||u==="FAILED"||(t==null?void 0:t.resume_pass_fail)===!1||String((t==null?void 0:t.resume_pass_fail)??"").toLowerCase()==="fail"||l===""&&b!=null&&b<ya?Ir(t)?"below_threshold_retry":ws?"parked_below_75":"not_progressing":o?"completed_review":"under_review"}function uh({score:r,resumeName:a,uploadedAt:t,outcome:o="reviewed"}){const m=o==="below_threshold";return e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-5 sm:p-6 shadow-sm space-y-4",children:[e.jsx(os,{}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:ye("flex h-10 w-10 shrink-0 items-center justify-center rounded-lg",m?"bg-muted text-muted-foreground border border-border":"bg-primary/10 text-primary border border-primary/15"),children:e.jsx(ss,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:String(a)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t?`Uploaded ${t}`:"Submitted resume on file"})]}),e.jsx("span",{className:ye("ml-auto shrink-0 rounded-full px-2.5 py-1 text-[11px] font-semibold",m?"bg-muted text-muted-foreground border border-border":"bg-primary/10 text-primary border border-primary/20"),children:m?"Below the bar for this role":"Reviewed"})]}),r!=null?e.jsxs("div",{className:"rounded-xl border border-border/60 bg-muted/20 px-4 py-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Overall match"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:m?"Did not meet the bar for this role":"Requirements review complete"})]}),e.jsx("p",{className:"text-2xl font-semibold tabular-nums text-foreground",children:Ya(r)})]}):null]})}
1function hh({title:r,description:a,resumeName:t,uploadedAt:o,score:m=null,children:g}){return e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-5 sm:p-6 shadow-sm space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(os,{className:"mb-1"}),e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.14em] uppercase text-amber-900",children:"Reserved"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground border border-border",children:e.jsx(Xi,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h2",{className:"text-xl sm:text-2xl font-semibold tracking-tight text-foreground",children:r}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:a})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-border/60 bg-muted/20 p-4 flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground border border-border",children:e.jsx(ss,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o?`Uploaded ${o}`:"Submitted resume on file"})]}),e.jsx("span",{className:"ml-auto shrink-0 rounded-full px-2.5 py-1 text-[11px] font-semibold bg-amber-50 text-amber-900 border border-amber-200",children:"Reserved"})]}),m!=null?e.jsxs("div",{className:"rounded-xl border border-border/60 bg-muted/20 px-4 py-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Overall match"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Did not meet the qualify threshold for this role"})]}),e.jsx("p",{className:"text-2xl font-semibold tabular-nums text-foreground",children:Ya(m)})]}):null,g]})}function xh({isFastTrack:r,showStart:a,starting:t,onStart:o}){return e.jsxs("div",{className:"rounded-2xl border border-emerald-200/80 bg-emerald-50/70 p-5 sm:p-6 space-y-3",children:[e.jsxs("p",{className:"text-sm font-semibold text-emerald-950 flex items-center gap-2",children:[e.jsx(Qi,{className:"h-4 w-4 shrink-0"}),r?"Strong match - you're invited to rehearsal":"Invited to rehearsal"]}),e.jsx("p",{className:"text-sm text-emerald-900/90 leading-relaxed",children:r?oh:"You've been selected to continue. Start your rehearsal when you're ready."}),a&&o?e.jsx(ae,{type:"button",className:"h-11 w-full sm:w-auto bg-primary text-primary-foreground hover:bg-[hsl(var(--brand-green)/0.9)]",disabled:t,onClick:o,children:t?e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"mr-2 h-4 w-4 animate-spin"}),"Startingâ¦"]}):"Start rehearsal"}):e.jsx("p",{className:"text-xs text-emerald-900/75",children:"Your rehearsal invitation is ready - open the Rehearsal step in your journey if the start button is not available yet."})]})}function fs({title:r,description:a,tone:t="default",eyebrow:o="Status"}){const m=t==="warning";return e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-5 sm:p-6 shadow-sm space-y-2",children:[e.jsx(os,{className:"mb-1"}),e.jsx("p",{className:ye("text-[11px] font-semibold tracking-[0.14em] uppercase",o==="Reserved"?"text-amber-900":"text-muted-foreground"),children:o}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:ye("mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full",m?"bg-muted text-muted-foreground border border-border":"bg-primary text-primary-foreground"),children:m?e.jsx(Xi,{className:"h-4 w-4"}):e.jsx(gs,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h2",{className:"text-xl sm:text-2xl font-semibold tracking-tight text-foreground",children:r}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:a})]})]})]})}
1function fh({title:r,description:a,children:t}){return e.jsxs("div",{className:"rounded-2xl border-2 border-primary/50 bg-card p-5 sm:p-6 shadow-sm ring-1 ring-primary/10 space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(os,{className:"mb-2"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:r}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:a})]}),t]})}function gh(r){return e.jsx(Yu,{counter:r.stepCounter,children:e.jsx(ph,{...r})})}function ph({application:r={},stepCounter:a,status:t,resumeStepCompleted:o,laterStageStarted:m,jobId:g,slug:u,jobTitle:l="this role",companyName:_="this employer",onUploadComplete:b,onStartRehearsal:S,startingRehearsal:v=!1,canStartRehearsal:k,onBack:B}){var me;const E=Fi(),{toast:s}=Ma(),[q,R]=c.useState(!1),L=mh({application:r,status:t,resumeStepCompleted:o,laterStageStarted:m}),N=uo(t),P=ws?null:N,K=ch(t),xe=ro(t),J=(K==null?void 0:K.filename)||r.resume_filename||r.resume_file||"Resume",re=K!=null&&K.uploaded_at?new Date(K.uploaded_at).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null,F=k??(!!S&&zi(t)),U=c.useRef(b);if(U.current=b,c.useEffect(()=>{if(L!=="email_verification_pending")return;let D=!1;const ne=()=>{var W;D||(W=U.current)==null||W.call(U)},X=window.setInterval(ne,4e3),Z=()=>{document.visibilityState==="visible"&&ne()};return window.addEventListener("focus",ne),document.addEventListener("visibilitychange",Z),()=>{D=!0,window.clearInterval(X),window.removeEventListener("focus",ne),document.removeEventListener("visibilitychange",Z)}},[L]),L==="email_verification_pending"){const D=async()=>{R(!0);try{if(typeof window<"u"&&g)try{sessionStorage.setItem("bitstage_verify_email_return",`/applications/${g}`)}catch{}const X=(await wd()).message||"Check your inbox for the magic link.",Z=X.toLowerCase().includes("already verified");s({title:Z?"Email already verified":"Verification email sent",description:Z?"Updating your applicationâ¦":`${X} This page updates automatically once you verify.`}),Z&&await(b==null?void 0:b())}catch(ne){s({title:"Could not send email",description:ne instanceof Error?ne.message:"Please try again.",variant:"destructive"})}finally{R(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{title:"Verify your email to continue",description:`Verify your email to see your resume results for ${l} and whether youâre eligible for the next step.`}),e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-5 sm:p-6 shadow-sm space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-muted border border-border",children:e.jsx(ic,{className:"h-5 w-5 text-foreground"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Verify your email"}),e.jsxs("p",{className:"text-sm text-muted-foreground leading-relaxed",children:["Weâll send a magic link to your inbox. After you verify, this page updates automatically. You can also manage verification from"," ",e.jsx(Ua,{to:"/candidate/profile",className:"font-medium text-primary underline underline-offset-2 hover:text-primary/90",children:"your profile"}),"."]})]})]}),e.jsx(ae,{size:"lg",className:"w-full",disabled:q,onClick:()=>void D(),children:q?e.jsx(as,{className:"h-5 w-5 animate-spin"}):"Send verification email"})]})]})}if(L==="not_uploaded")return!!(t!=null&&t.has_eligibility_questions)&&(t==null?void 0:t.eligibility_screen_status)!=="passed"?e.jsx("div",{className:"space-y-4",children:e.jsx(fs,{title:"Resume upload locked",description:(t==null?void 0:t.eligibility_screen_status)==="not_matched"?"Resume upload is not available based on your eligibility answers.":"Answer the eligibility questions for this role before uploading your resume."})}):g&&u&&b?e.jsx(ga,{stepCounter:a,jobId:g,slug:u,jobTitle:l,companyName:_,status:t,onComplete:b,onBack:B}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{title:"Resume review",description:"Resume not uploaded yet. Upload your resume to continue."}),e.jsx(fh,{title:"Upload your resume to begin",description:"Upload your resume so we can review your experience and qualifications.",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Resume upload is not available for this application yet. Please refresh and try again."})})]});if(L==="under_review"||t&&Bu(t))return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{title:"Resume under review",description:(xe==null?void 0:xe.description)||"We're reviewing your resume against this role's requirements. We'll update this page when your result is ready."}),e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-muted/20 p-5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[e.jsx(ss,{className:"h-4 w-4 text-primary"}),String(J)]}),e.jsxs("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(as,{className:"h-4 w-4 animate-spin text-primary"}),"Usually takes a few minutes. Results will appear on this page."]})]})]});if(L==="below_threshold_retry"){const D=so();
1return e.jsx(hh,{title:D.title,description:D.description,resumeName:String(J),uploadedAt:re,score:P,children:g&&u&&b?e.jsx(ga,{stepCounter:a,jobId:g,slug:u,jobTitle:l,companyName:_,status:t,onComplete:b,variant:"minimal",embedded:!0}):null})}if(L==="not_progressing"||L==="parked_below_75"){const D=L==="parked_below_75"?kr("parked_below_75"):{title:"Both resume attempts are used",body:"Your resume did not meet this roleâs threshold after both uploads, so you canât move to the next step. Youâre reserved for this application. Browse other roles, or get support from our team."};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{eyebrow:"Reserved",title:D.title,description:D.body,tone:"warning"}),e.jsxs("div",{className:"rounded-2xl border border-sky-200 bg-sky-50/90 p-5 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-base font-semibold text-sky-950",children:"What's next?"}),e.jsx("p",{className:"text-sm text-sky-900/85 leading-relaxed",children:"You canât upload another resume for this role. Browse other open roles, or contact support if you need help."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(ae,{type:"button",variant:"outline",className:"h-11 border-sky-300 bg-white hover:bg-sky-50 text-sky-950",onClick:()=>E("/practice?tab=invited&jobs_status=open#open-jobs"),children:[e.jsx(Lt,{className:"h-4 w-4 mr-2"}),"Browse other roles"]}),e.jsxs(ae,{type:"button",variant:"outline",className:"h-11 border-sky-300 bg-white hover:bg-sky-50 text-sky-950",onClick:()=>E("/candidate/help"),children:[e.jsx(oi,{className:"h-4 w-4 mr-2"}),"Get support"]})]})]})]})}if(L==="qualified_pool")return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{title:"Resume review complete",description:"Requirements confirmed. Your resume meets the role requirements."}),e.jsxs("div",{className:"rounded-2xl border border-primary/25 bg-primary/5 p-5 sm:p-6 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[e.jsx(Ps,{className:"h-4 w-4 shrink-0 text-primary"}),"Waiting for your rehearsal invite"]}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Weâll email you when your rehearsal becomes available."})]})]});if(L==="rehearsal_ready"){const D=String((t==null?void 0:t.resume_score_band)??"").toLowerCase()==="fast_track"||N!=null&&N>=90;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{title:"Resume review complete",description:"Requirements confirmed. Your resume meets the role requirements."}),e.jsx(uh,{score:P,resumeName:String(J),uploadedAt:re}),e.jsx(xh,{isFastTrack:D,showStart:F,starting:v,onStart:S})]})}if(L==="fast_lane_invited"||L==="auto_invited"||L==="bypassed"){const ne=kr(L==="fast_lane_invited"?"fast_lane_invited":L==="auto_invited"?"auto_invited":"bypassed_by_client");return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{title:"Resume review complete",description:"Requirements confirmed. Your resume meets the role requirements."}),e.jsxs("div",{className:"rounded-2xl border border-emerald-200/80 bg-emerald-50/70 p-5 sm:p-6 space-y-3",children:[e.jsxs("p",{className:"text-sm font-semibold text-emerald-950 flex items-center gap-2",children:[e.jsx(Qi,{className:"h-4 w-4 shrink-0"}),ne.title]}),e.jsx("p",{className:"text-sm text-emerald-900/90 leading-relaxed",children:ne.body}),e.jsx(mo,{expiresAt:t==null?void 0:t.rehearsal_invite_expires_at,className:"text-xs text-emerald-900/75"}),F&&S?e.jsx(ae,{type:"button",className:"h-11 w-full sm:w-auto bg-primary text-primary-foreground hover:bg-[hsl(var(--brand-green)/0.9)]",disabled:v,onClick:S,"data-testid":"resume-panel-start-rehearsal",children:v?e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"mr-2 h-4 w-4 animate-spin"}),"Startingâ¦"]}):"Start rehearsal"}):e.jsx("p",{className:"text-xs text-emerald-900/75",children:"Your invitation is active. If Start Rehearsal is unavailable, refresh this page or open the Rehearsal step in your journey."})]})]})}if(L==="auto_invite_pending"){const D=kr("auto_invite_pending");return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{title:"Resume review complete",description:"Requirements confirmed. Your resume meets the role requirements."}),e.jsxs("div",{className:"rounded-2xl border border-sky-200/80 bg-sky-50/70 p-5 sm:p-6 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-sky-950",children:[e.jsx(Ps,{className:"h-4 w-4 shrink-0 text-sky-700"}),D.title]}),e.jsx("p",{className:"text-sm text-sky-900/85 leading-relaxed",children:D.body})]})]})}if(L==="invite_window_too_short"){const D=kr("invite_blocked_insufficient_window");return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{title:"Resume review complete",description:"Requirements confirmed. Your resume meets the role requirements."}),e.jsxs("div",{className:"rounded-2xl border border-amber-200/80 bg-amber-50/80 p-5 sm:p-6 space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-950",children:D.title}),e.jsx("p",{className:"text-sm text-amber-950/85 leading-relaxed",children:D.body})]})]})}if(L==="queued_for_slot"){const D=kr("queued_for_slot");return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{title:"Resume review complete",description:"Requirements confirmed. Your resume meets the role requirements."}),e.jsxs("div",{className:"rounded-2xl border border-primary/25 bg-primary/5 p-5 sm:p-6 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[e.jsx(Ps,{className:"h-4 w-4 shrink-0 text-primary"}),D.title]}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D.body})]})]})}if(L==="reserve_75_79")return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-5 sm:p-6 shadow-sm space-y-4",children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.14em] uppercase text-muted-foreground",children:"Status"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground",children:e.jsx(gs,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h2",{className:"text-xl sm:text-2xl font-semibold tracking-tight text-foreground",children:"Resume review complete"}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Your resume has been reviewed for this role."})]})]}),e.jsxs("div",{className:"rounded-xl border border-border/60 bg-muted/20 p-4 flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary border border-primary/15",children:e.jsx(ss,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:String(J)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:re?`Uploaded ${re}`:"Submitted resume on file"})]}),e.jsx("span",{className:"shrink-0 rounded-full px-2.5 py-1 text-[11px] font-semibold bg-primary/10 text-primary border border-primary/20",children:"Reviewed"})]})]}),e.jsxs("div",{className:"rounded-2xl border border-amber-200 bg-amber-50/60 p-5 sm:p-6 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{className:"h-4 w-4 text-amber-700 shrink-0"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"You're on the reserve list"})]}),e.jsx("p",{className:"text-sm text-amber-800 leading-relaxed",children:"Your resume meets the requirements for this role. You're currently in the reserve pool. If the employer needs more candidates, you'll receive a rehearsal inv
1ite by email."})]}),Ir(t)&&((t==null?void 0:t.resume_can_retry)===!0||((me=t==null?void 0:t.resume_attempt_policy)==null?void 0:me.can_retry)===!0)&&g&&u&&b?e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-5 sm:p-6 shadow-sm space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"You have one more resume upload"}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Rehearsal isnât open yet. Upload an updated resume to use your remaining attempt."})]}),e.jsx(ga,{stepCounter:a,jobId:g,slug:u,jobTitle:l,companyName:_,status:t,onComplete:b,variant:"minimal",embedded:!0})]}):null]});if(L==="ghosted"){const D=kr("ghosted");return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fs,{title:D.title,description:D.body,tone:"warning"}),e.jsx("div",{className:"rounded-2xl border border-amber-200 bg-amber-50/90 p-5 sm:p-6 space-y-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(ae,{type:"button",variant:"outline",className:"h-11 border-amber-300 bg-white hover:bg-amber-50 text-amber-950",onClick:()=>E("/practice?tab=invited&jobs_status=open#open-jobs"),children:[e.jsx(Lt,{className:"h-4 w-4 mr-2"}),"Browse other roles"]}),e.jsxs(ae,{type:"button",variant:"outline",className:"h-11 border-amber-300 bg-white hover:bg-amber-50 text-amber-950",onClick:()=>E("/candidate/help"),children:[e.jsx(oi,{className:"h-4 w-4 mr-2"}),"Get support"]})]})})]})}return e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-5 sm:p-6 shadow-sm space-y-4",children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.14em] uppercase text-muted-foreground",children:"Status"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground",children:e.jsx(gs,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h2",{className:"text-xl sm:text-2xl font-semibold tracking-tight text-foreground",children:"Resume review complete"}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:P!=null?"Your resume was submitted and reviewed for this role.":"Your resume was submitted for this role."})]})]}),e.jsxs("div",{className:"rounded-xl border border-border/60 bg-muted/20 p-4 flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary border border-primary/15",children:e.jsx(ss,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:String(J)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:re?`Uploaded ${re}`:"Submitted resume on file"})]}),P!=null?e.jsx("p",{className:"text-xl font-semibold tabular-nums text-foreground shrink-0",children:Ya(P)}):e.jsx("span",{className:"shrink-0 rounded-full px-2.5 py-1 text-[11px] font-semibold bg-primary/10 text-primary border border-primary/20",children:"Reviewed"})]})]})}function bh(r){return r==="reserve_75_79_post_ws"||r==="parked_below_75_post_ws"||r==="queued_for_recruiter_slot"||r==="auto_recruiter_pending"?"work_style":"rehearsal"}function yh(r){switch(r){case"success":return"border-emerald-200/80 bg-emerald-50/70 text-emerald-950";case"info":return"border-sky-200/80 bg-sky-50/70 text-sky-950";case"warning":return"border-amber-200/80 bg-amber-50/70 text-amber-950";default:return"border-border/70 bg-muted/20 text-foreground"}}function vh({gateKey:r}){return r.includes("queued")?e.jsx(oc,{className:"h-4 w-4 shrink-0"}):r.includes("pending")?e.jsx(at,{className:"h-4 w-4 shrink-0"}):r.includes("parked")?e.jsx(dc,{className:"h-4 w-4 shrink-0"}):r.includes("reserve")?e.jsx(Ps,{className:"h-4 w-4 shrink-0"}):e.jsx(nt,{className:"h-4 w-4 shrink-0"})}function _h({gateKey:r,stepCounter:a,status:t,stage:o}){const m=r,g=o??bh(r),u=Pd(m,g),l=g==="rehearsal"&&(m==="fast_lane_ws_invited"||m==="auto_ws_invited"||m==="work_style_invited");return e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:ye("rounded-2xl border p-5 sm:p-6 space-y-2",yh(u.tone)),children:[e.jsx(os,{counter:a,className:"mb-1"}),e.jsxs("p",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(vh,{gateKey:r}),u.title]}),e.jsx("p",{className:"text-sm leading-relaxed opacity-90",children:u.body}),l?e.jsx(mo,{expiresAt:t==null?void 0:t.work_style_invite_expires_at,className:"text-xs opacity-80"}):null]})})}function jh({title:r,stepCounter:a,description:t,completed:o=!1,shortlistPublished:m,productType:g=null,rehearsalState:u="recorded",hasEligibilityQuestions:l=!1,credentialIssued:_=!1,interviewAdvanced:b=!1,instantScreeningOffer:S=!1,undoEligible:v=!1,undoSubmitting:k=!1,onUndoSkip:B}){const E=(g||"").toLowerCase()==="concierge",s=u==="recorded",q=u==="skipped_by_candidate",R=l?"your resume and answers":"your resume",L=S&&!_,N=E?"concierge":"crew",P=E?"Interview":"Screening call",K=L?Mm(N):s?"A BitStage recruiter is watching your rehearsal and reading your application.":"A BitStage recruiter is reading your application.",xe=l?"Reading your resume and answers":"Reading your resume",J=L?Om(N):s?["Watching your rehearsal",xe,"Judging fit for this role"]:[xe,"Judging fit for this role"],re=q?"You skipped the rehearsal, so this":"The hiring team moved your application ahead without a rehearsal, so it",U=Wm({hasIssuedBitScore:_,shortlistPublished:m??o}),me=U==="both_done"||U==="shortlist_only",D=U==="bitscore_only";if(me||D){const V=(t==null?void 0:t.trim())||"",be=/issued after that interview/i.test(V)||/comes after that interview/i.test(V)||/on the Final result step/i.test(V),G=/reviewing completed candidates/i.test(V)||/A BitStage recruiter is reviewing/i.test(V)||/\bis reviewing (your|this) application\b/i.test(V)||/under recruiter review/i.test(V),ve=b&&/interview comes next if you (are|get) selected/i.test(V),A=/^Recruiter review is complete( for this application)?\.?$/i.test(V),_e=D||!V||be||G||ve||U==="shortlist_only"&&!_||A&&!_?xa(U,{isConcierge:E,workStyleOn:ra,interviewAdvanced:b,instantScreeningOffer:S,rehearsalState:u}):V;return e.jsx("div",{className:"space-y-4",children:e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"space-y-4 p-5 sm:p-6",children:[e.jsx(os,{counter:a}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:(r==null?void 0:r.trim())||"Recruiter review"}),e.jsx(je,{className:D?"rounded-full border-amber-200 bg-amber-100 text-amber-800 hover:bg-amber-100":"rounded-full border-emerald-200 bg-emerald-100 text-emerald-800 hover:bg-emerald-100",children:D?"BitScore ready":"Complete"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:_e})]})]})})})}const ne=L?xa("review_open",{isConcierge:E,workStyleOn:ra,instantScreeningOffer:!0,interviewAdvanced:!0}):s?xa("review_open",{isConcierge:E,workStyleOn:ra}
1):[`The recruiter will review ${R}`,E?", then may schedule an interview.":".",q?" You can still add a rehearsal until the shortlist goes out.":""].join(""),X=L?Fm(N):s?t!=null&&t.trim()&&!/verified BitScore credential is ready/i.test(t)&&!/^Recruiter review is complete/i.test(t.trim())?t.trim():"Your rehearsal and application are being evaluated by our recruiter. You'll be notified once a decision has been made.":`${re} application is reviewed on ${R} alone and carries no BitScore. You'll be notified once a decision has been made.`,Z=L?`Open the ${P} step to pick a time. You do not need to wait for your verified BitScore first.`:"You don't need to take any action right now. We'll notify you here and via email once there's an update.",W=q&&!!B;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"space-y-5 p-5 sm:p-6",children:[e.jsx(os,{counter:a}),e.jsx("div",{children:e.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:(r==null?void 0:r.trim())||"Recruiter review"}),e.jsx(je,{className:"rounded-full border-amber-200 bg-amber-100 text-amber-800 hover:bg-amber-100",children:L?"Scores pending":"In review"})]})}),e.jsxs("div",{className:"flex flex-col gap-4 overflow-hidden rounded-xl border border-amber-200/70 bg-amber-50/70 p-4 sm:flex-row sm:items-center sm:justify-between sm:p-5",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-full bg-amber-500 text-white shadow-sm",children:e.jsx(Zi,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h3",{className:"text-base font-bold text-foreground",children:K}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:X})]})]}),e.jsxs("div",{className:"relative mx-auto flex h-24 w-28 shrink-0 items-center justify-center sm:mx-0","aria-hidden":!0,children:[e.jsxs("div",{className:"absolute inset-y-2 left-2 right-8 rounded-lg border border-amber-200/80 bg-white shadow-sm",children:[e.jsx("div",{className:"m-2 h-6 w-6 rounded-full bg-amber-100"}),e.jsxs("div",{className:"mx-2 mt-1 space-y-1.5",children:[e.jsx("div",{className:"h-1.5 w-16 rounded bg-amber-100"}),e.jsx("div",{className:"h-1.5 w-12 rounded bg-amber-100/80"}),e.jsx("div",{className:"h-1.5 w-14 rounded bg-amber-100/70"})]})]}),e.jsx("div",{className:"absolute bottom-1 right-0 flex h-12 w-12 items-center justify-center rounded-full border-2 border-amber-300 bg-white shadow-md",children:e.jsx(Lt,{className:"h-5 w-5 text-amber-600"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4 sm:p-5",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:"What happens next?"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:ne}),e.jsx("ul",{className:"mt-4 space-y-2.5",children:J.map(V=>e.jsxs("li",{className:"flex items-center gap-2.5 text-sm text-foreground",children:[L?e.jsx(cc,{className:"h-4 w-4 shrink-0 text-amber-600"}):e.jsx(gs,{className:"h-4 w-4 shrink-0 text-primary"}),e.jsx("span",{children:V})]},V))})]}),e.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4 sm:p-5",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:"What you can do"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:Z}),e.jsxs("ul",{className:"mt-4 space-y-2.5",children:[L?e.jsxs("li",{className:"flex items-center gap-2.5 text-sm text-foreground",children:[e.jsx(ja,{className:"h-4 w-4 shrink-0 text-primary"}),e.jsxs("span",{children:["Open ",P," and confirm a time"]})]}):e.jsxs("li",{className:"flex items-center gap-2.5 text-sm text-foreground",children:[e.jsx(ja,{className:"h-4 w-4 shrink-0 text-primary"}),e.jsx("span",{children:"Check your email for updates"})]}),e.jsxs("li",{className:"flex items-center gap-2.5 text-sm text-foreground",children:[e.jsx(Fa,{className:"h-4 w-4 shrink-0 text-primary"}),e.jsx("span",{children:"You'll get a notification in BitStage"})]})]})]})]})]})}),W?e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"space-y-3 p-5",children:[e.jsx("p",{className:"text-sm font-bold text-foreground",children:"Change your mind?"}),v?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Add a rehearsal before the shortlist goes out and you can still earn a BitScore for this role."}),e.jsx(ae,{variant:"outline",className:"w-full gap-2 font-semibold",onClick:B,disabled:k,children:k?"Restoringâ¦":e.jsxs(e.Fragment,{children:[e.jsx(Ns,{className:"h-4 w-4"}),"Add a rehearsal"]})})]}):e.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"The shortlist has gone out â you can no longer add a rehearsal for this application."})]})}):null]})}const wh="The hiring team is scheduling your Google Meet interview. You will receive the meeting time and link here once it is confirmed.";function Nh(r){const a=(r==null?void 0:r.trim())??"";return!(!a||/interview has been requested/i.test(a)||/check your email/i.test(a)||/scheduling your google meet/i.test(a))}function kh(r){var t;if(!((t=r==null?void 0:r.description)!=null&&t.trim()))return null;const a=r.description.match(/The hiring team advanced you past ([^.]+)\./i);return a?`The hiring team advanced you past ${a[1]}
1.`:/moving to recruiter interview/i.test(r.title)?null:r.description.trim()}function ho({title:r,description:a,status:t,className:o}){const m=Ym(t),g=Nh(a)?a.trim():wh,u=kh(m);return e.jsx(le,{className:ye("border-primary/25 bg-primary/5 shadow-sm",o),children:e.jsxs(ie,{className:"flex gap-4 p-5 sm:p-6",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(et,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:(r==null?void 0:r.trim())||"Recruiter Interview"}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:g}),u?e.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground/90",children:u}):null]})]})})}function xo({title:r,scheduledStartAt:a,timezone:t="America/Denver",durationMinutes:o=30,meetUrl:m,googleCalendarHtmlLink:g,managedExternally:u=!1,companyName:l,jobTitle:_,className:b}){const S=(t==null?void 0:t.trim())||"America/Denver",v=Nd(),k=a?{primary:si(a,v),secondary:S!==v?`Recruiter's time: ${si(a,S)}`:null}:null,B=m==null?void 0:m.trim(),E=g==null?void 0:g.trim(),s=l!=null&&l.trim()&&(_!=null&&_.trim())?`${l.trim()} · ${_.trim()}`:(l==null?void 0:l.trim())||(_==null?void 0:_.trim())||null,q=async()=>{if(B)try{await navigator.clipboard.writeText(B),Zr.success("Meet link copied")}catch{Zr.error("Could not copy link")}};return e.jsx(le,{className:ye("min-w-0 overflow-hidden border-[hsl(var(--brand-green)/0.35)] bg-white shadow-sm",b),children:e.jsx(ie,{className:"min-w-0 space-y-4 p-4 sm:p-5",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between sm:gap-6",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-[hsl(var(--brand-pale-green))] text-[hsl(var(--brand-navy))]",children:e.jsx(et,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-base font-bold tracking-tight text-foreground [overflow-wrap:anywhere] sm:text-lg",children:(r==null?void 0:r.trim())||"Recruiter Interview"}),e.jsx("span",{className:"inline-flex rounded-full bg-[hsl(var(--brand-pale-green))] px-2.5 py-0.5 text-[11px] font-semibold text-[hsl(var(--brand-navy))] ring-1 ring-[hsl(var(--brand-green)/0.35)]",children:"Scheduled"})]}),s?e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground [overflow-wrap:anywhere]",children:s}):null]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg bg-muted/30 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"When"}),e.jsxs("p",{className:"mt-1 flex items-start gap-1.5 text-sm font-medium text-foreground",children:[e.jsx(cr,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 leading-snug [overflow-wrap:anywhere]",children:(k==null?void 0:k.primary)??"Details coming soon"})]}),k!=null&&k.secondary?e.jsx("p",{className:"mt-0.5 pl-5 text-xs text-muted-foreground [overflow-wrap:anywhere]",children:k.secondary}):null]}),e.jsxs("div",{className:"rounded-lg bg-muted/30 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Duration"}),e.jsxs("p",{className:"mt-1 flex items-center gap-1.5 text-sm font-medium text-foreground",children:[e.jsx(at,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),o," minutes"]})]})]}),B?e.jsxs("div",{className:"flex flex-wrap items-center gap-3 rounded-lg border border-border/70 bg-muted/20 px-3 py-2.5",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-[hsl(var(--brand-pale-green))] text-[hsl(var(--brand-navy))]",children:e.jsx(Wa,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1 leading-tight",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Google Meet"}),e.jsx("p",{className:"mt-0.5 truncate text-sm font-medium text-foreground",children:B.replace(/^https?:\/\//,"")})]}),e.jsx("button",{type:"button","aria-label":"Copy meet link",onClick:()=>void q(),className:"shrink-0 rounded-md border border-border p-2 text-muted-foreground hover:bg-muted hover:text-foreground",children:e.jsx(mc,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"rounded-lg border border-dashed border-border bg-muted/10 px-3 py-2.5 text-sm text-muted-foreground",children:"Your meeting link will appear here before the interview."}),e.jsxs("p",{className:"flex items-start gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ja,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:["A Google Calendar invite was sent to your email.",u?" Your hiring team may also send a separate calendar invitation.":""]})]})]}),e.jsxs("div",{className:"flex shrink-0 flex-row flex-wrap gap-2 sm:w-40 sm:flex-col",children:[B?e.jsx(ae,{size:"sm",className:"w-full !bg-[hsl(var(--brand-green))] text-[hsl(var(--brand-navy))] hover:!bg-[hsl(var(--brand-green))] hover:brightness-95 hover:text-[hsl(var(--brand-navy))]",asChild:!0,children:e.jsxs("a",{href:B,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Ji,{className:"mr-1.5 h-4 w-4"})," Join meeting"]})}):null,E?e.jsx(ae,{size:"sm",variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:E,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(et,{className:"mr-1.5 h-4 w-4"})," Open calendar"]})}):null]})]})})})}function Rh(r,a){if(r!=null&&r.label||r!=null&&r.message)return{title:r.label??"Interview update",description:r.message??"The hiring team is reviewing your interview. We will notify you when there is an update.",tone
1:r.phase==="selected"?"success":"neutral"};switch(a){case"not_conducted":return{title:"Interview was not conducted",description:"The scheduled interview did not take place. The hiring team will decide on next steps and may contact you if a new time is set.",tone:"neutral"};case"selected":return{title:"Moving forward",description:"The hiring team has selected you to move forward. Check your email for next steps.",tone:"success"};case"not_selected":return{title:"Interview complete",description:"Thank you for completing your interview. The hiring team has finished their review for this role.",tone:"neutral"};case"awaiting_decision":return{title:"Your interview is complete",description:"The hiring team is reviewing your interview. We'll notify you when there's an update.",tone:"neutral"};default:return{title:"Your interview is complete",description:"The hiring team is reviewing your interview. We will be in touch soon.",tone:"neutral"}}}function fo({outcome:r,phase:a="completed",className:t}){const o=Rh(r,a),m=o.tone==="success"?gs:at;return e.jsx(le,{className:ye("shadow-sm",o.tone==="success"?"border-[hsl(var(--brand-green)/0.40)] bg-[hsl(var(--brand-pale-green))]":"border-primary/25 bg-primary/5",t),children:e.jsxs(ie,{className:"flex items-start gap-3 p-6",children:[e.jsx("div",{className:ye("mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-full",o.tone==="success"?"bg-[hsl(var(--brand-pale-green))] text-[hsl(var(--brand-navy))]":"bg-primary/10 text-primary"),children:e.jsx(m,{className:"h-5 w-5","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h3",{className:"text-base font-bold text-foreground",children:o.title}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:o.description})]})]})})}function Ba({title:r="Your application is with the hiring team.",description:a="The hiring team is reviewing your application. We'll be in touch within 5 business days."}={}){return e.jsx(le,{className:"border-l-4 border-l-[hsl(var(--brand-navy))] shadow-sm",children:e.jsxs(ie,{className:"p-6 flex gap-4",children:[e.jsx("div",{className:"h-10 w-10 shrink-0 rounded-lg bg-[hsl(var(--brand-cream))] flex items-center justify-center border border-[hsl(var(--brand-navy))]/15",children:e.jsx(Ps,{className:"h-5 w-5 text-[hsl(var(--brand-navy))]"})}),e.jsxs("div",{className:"space-y-1.5 min-w-0",children:[e.jsx("h3",{className:"text-lg font-bold text-foreground",children:r}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:a})]})]})})}function Ch(r,a){return Id(r.starts_at,a)}function Eh(r,a){return Ki(r.starts_at,{tz:a,style:"time"})}const $a=7;function rt(r,a){const[t,o,m]=r.split("-").map(Number);return new Date(Date.UTC(t,o-1,m+a)).toISOString().slice(0,10)}function tt(r,a){const[t,o,m]=r.split("-").map(Number),g=new Date(Date.UTC(t,o-1,m,12));return{weekday:new Intl.DateTimeFormat("en-US",{weekday:"short",timeZone:"UTC"}).format(g),longWeekday:new Intl.DateTimeFormat("en-US",{weekday:"long",timeZone:"UTC"}).format(g),dayNum:new Intl.DateTimeFormat("en-US",{day:"numeric",timeZone:"UTC"}).format(g),month:new Intl.DateTimeFormat("en-US",{month:"short",timeZone:"UTC"}).format(g)}}function Ih(r,a){const t=rt(r,$a-1),o=tt(r),m=tt(t);return o.month===m.month?`${o.month} ${o.dayNum} â ${m.dayNum}`:`${o.month} ${o.dayNum} â ${m.month} ${m.dayNum}`}function Th(r,a,t){const o=rt(r,$a-1),m=a.filter(l=>l>=r&&l<=o).sort();if(m.length===0)return Ih(r);const g=tt(m[0]),u=tt(m[m.length-1]);return m[0]===m[m.length-1]?`${g.month} ${g.dayNum}`:g.month===u.month?`${g.month} ${g.dayNum} â ${u.dayNum}`:`${g.month} ${g.dayNum} â ${u.month} ${u.dayNum}`}function Sh(r,a){const[t,o]=r.split("-").map(Number),m=new Date(Date.UTC(t,o-1,1,12));return new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(m)}function Lh(r){const[a,t]=r.split("-").map(Number),m=new Date(Date.UTC(a,t-1,1,12)).getUTCDay(),g=m===0?-6:1-m,u=rt(`${a}-${String(t).padStart(2,"0")}-01`,g);return Array.from({length:42},(l,_)=>rt(u,_))}function Dh(r,a){const t=tt(r);return`${t.longWeekday}, ${t.month} ${t.dayNum}`}function Bh({companyName:r,jobTitle:a,durationMinutes:t=30,slots:o,selecting:m=!1,onSelect:g,onDeclineNoneWork:u,declining:l=!1,className:_,note:b,provisionalScoreLabel:S,expiresAt:v,unitLabel:k="interview"}){var Me;const B=c.useMemo(()=>kd(o),[o]),[E,s]=c.useState(null),[q,R]=c.useState(!1),[L,N]=c.useState(null),P=c.useMemo(()=>Rd(),[]),K=((Me=B[0])==null?void 0:Me.timezone)||"",[xe,J]=c.useState(!1),re=!!K&&Cd(K,P),F=xe&&re?K:P,U=c.useMemo(()=>{const Y=(v||"").trim();if(!Y)return null;const C=new Date(Y).getTime();if(Number.isNaN(C))return null;try{return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(C))}catch{return null}},[v]),me=c.useMemo(()=>{const Y=new Map;for(const C of B){const Te=Ch(C,F);if(!Te)continue;const O=Y.get(Te)??[];O.push(C),Y.set(Te,O)}for(const C of Y.values())C.sort((Te,O)=>Te.starts_at.localeCompare(O.starts_at));return Y},[B,F]),D=c.useMemo(()=>Array.from(me.keys()).sort(),[me]),X=D[0]??null,Z=X?rt(X,$a-1):null,W=X?X.slice(0,7):null,V=c.useMemo(()=>!X||!Z?[]:D.filter(Y=>Y>=X&&Y<=Z),[D,X,Z]);c.useEffect(()=>{if(!V.length){N(null);return}N(Y=>Y&&V.includes(Y)?Y:V[0])},[V]);const be=c.useMemo(()=>W?Lh(W):[],[W]),G=Y=>V.includes(Y),ve=c.useMemo(()=>L?me.get(L)??[]:[],[L,me]),A=B.find(Y=>Y.id===E)??null,_e=Y=>{G(Y)&&(N(Y),s(null))},Ue=async()=>{E&&(await g(E),R(!1))};return B.length?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:ye("border-primary/25 bg-primary/5 shadow-sm",_),children:e.jsxs(ie,{className:"space-y-5 p-6",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(et,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-primary",children:"Next step"}),e.jsx("h3",{className:"text-lg font-bold leading-snug text-foreground",children:S?"You are through. Pick a time.":`Choose your ${k} time`}),S?e.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:[S," A BitStage recruiter would like ",t," minutes with you",a?` about ${a}
1`:"",". Choose a day, then a time. Booking confirms straight away."]}):e.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:[r?`${r} has`:"The hiring team has"," offered times for your"," ",t,"-minute recruiter ",k,a?` for ${a}`:"",". Pick a day, then a time to confirm."]}),b!=null&&b.trim()?e.jsx("div",{className:"mt-2 rounded-md border border-border/60 bg-background/80 px-3 py-2 text-sm text-foreground",children:b.trim()}):null,U?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["These times stay open until"," ",e.jsx("span",{className:"font-medium text-foreground",children:U}),"."]}):null,e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Wa,{className:"h-3.5 w-3.5"}),"Video ",k," · online · ",t," min"]}),S?e.jsx("p",{className:"text-xs italic text-muted-foreground",children:"Your score is reviewed by a recruiter before anything is shared with the employer."}):null]})]}),e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border/70 bg-background",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border/60 px-4 py-3",children:[e.jsxs("p",{className:"text-sm font-semibold text-foreground",children:["Select ",/^[aeiou]/i.test(k)?"an":"a"," ",k," time"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{"data-testid":"slot-picker-zone",children:[F===P?"Your time: ":"Recruiter's time: ",ri(F)]}),re?e.jsx("button",{type:"button",className:"font-medium text-primary underline-offset-2 hover:underline",onClick:()=>J(Y=>!Y),children:xe?"Show in my time":"Show in recruiter's time"}):null]})]}),e.jsxs("div",{className:"grid gap-0 md:grid-cols-[minmax(17rem,20rem)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"border-b border-border/60 p-4 sm:p-5 md:border-b-0 md:border-r",children:[e.jsxs("div",{className:"mb-3 text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:W?Sh(W):""}),e.jsx("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:X?Th(X,V):""})]}),e.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 text-center text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:["M","T","W","T","F","S","S"].map((Y,C)=>e.jsx("span",{children:Y},`${Y}-${C}`))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",role:"listbox","aria-label":"Days with open interview times",children:be.map(Y=>{const C=W?Y.startsWith(W):!1,Te=G(Y),O=L===Y,Ee=Number(Y.slice(8,10));return e.jsx("button",{type:"button",role:"option","aria-selected":O,disabled:!Te,onClick:()=>_e(Y),className:ye("mx-auto flex h-9 w-9 items-center justify-center rounded-full text-sm tabular-nums transition-colors",!C&&"text-muted-foreground/30",C&&!Te&&"cursor-default text-muted-foreground/45",Te&&!O&&"bg-[#EDF6E1] font-semibold text-[#002242] hover:bg-[#d9efc0]",O&&"bg-[#64BD28] font-semibold text-white shadow-sm"),children:Ee},Y)})}),e.jsx("p",{className:"mt-3 text-[11px] leading-snug text-muted-foreground",children:"Green days have open times. Tap a day to see slots."})]}),e.jsx("div",{className:"flex flex-col p-4 sm:p-5",children:L&&G(L)?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mb-2.5 text-sm font-semibold text-foreground",children:[Dh(L),e.jsxs("span",{className:"ml-1.5 font-normal text-muted-foreground",children:["· ",ve.length," open"]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5 sm:grid-cols-4",role:"radiogroup","aria-label":"Interview time options",children:ve.map(Y=>{const C=E===Y.id;return e.jsx("button",{type:"button",role:"radio","aria-checked":C,onClick:()=>s(Y.id),className:ye("rounded-md border px-1.5 py-1.5 text-center text-[11px] font-medium tabular-nums transition-colors sm:text-xs",C?"border-[#64BD28] bg-[#64BD28] text-white":"border-border bg-background text-foreground hover:border-[#64BD28]/60 hover:bg-[#EDF6E1]"),children:Eh(Y,F)},Y.id)})})]}):e.jsx("p",{className:"m-auto py-8 text-sm text-muted-foreground",children:"Select a green day on the calendar."})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[u?e.jsx(ae,{type:"button",variant:"ghost",className:"h-11 px-2 text-muted-foreground",disabled:m||l,onClick:()=>void u(),children:l?"Sendingâ¦":"None of these times work"}):e.jsx("span",{}),e.jsx(ae,{className:"h-11 px-6 font-semibold",disabled:!E||m||l,onClick:()=>R(!0),children:m?e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirmingâ¦"]}):`Confirm ${k} time`})]})]})}),e.jsx(Yi,{open:q,onOpenChange:R,children:e.jsxs($i,{children:[e.jsxs(qi,{children:[e.jsxs(Hi,{children:["Confirm ",k," time"]}),e.jsxs(Vi,{children:["Book this slot for your ",t,"-minute video ",k,"?"]})]}),A&&e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-muted/30 px-4 py-3",children:[e.jsx(gs,{className:"h-5 w-5 shrink-0 text-primary"}),e.jsxs("p",{className:"font-semibold text-foreground",children:[Ki(A.starts_at,{tz:F}),e.jsxs("span",{className:"ml-1 font-normal text-muted-foreground",children:["(",ri(F),")"]})]})]}),e.jsxs(Ed,{children:[e.jsx(ae,{variant:"outline",onClick:()=>R(!1),disabled:m,children:"Cancel"}),e.jsx(ae,{onClick:()=>void Ue(),disabled:!E||m,children:m?"Confirmingâ¦":"Confirm"})]})]})})]}):e.jsx(le,{className:ye("border-primary/25 bg-primary/5 shadow-sm",_),children:e.jsxs(ie,{className:"flex gap-4 p-6",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(cr,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsxs("h3",{className:"text-lg font-bold text-foreground",children:["Recruiter ",k]}),e.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["The hiring team is preparing ",k," times for you. Check back soon."]})]})]})})}function pe(r){return(r??"").trim()}function go(r,a){var m,g,u,l,_,b,S,v;if(qa(r)==="not_conducted"||((g=(m=r==null?void 0:r.concierge)==null?void 0:m.interview_scheduling)==null?void 0:g.is_not_conducted)===!0||pe((l=(u=r==null?void 0:r.concierge)==null?void 0:u.interview_scheduling)==null?void 0:l.scheduling_status).toLowerCase()==="not_conducted"||(a==null?void 0:a.is_not_conducted)===!0||pe(a==null?void 0:a.status).toLowerCase()==="not_conducted")return null;const t=(_=r==null?void 0:r.concierge)==null?void 0:_.interview_scheduling,o=pe(t==null?void 0:t.google_meet_url)||pe(t==null?void 0:t.meeting_url)||null;return o||pe(a==null?void 0:a.google_meet_url)||pe((b=a==null?void 0:a.interview)==null?void 0:b.google_meet_url)||pe((S=a==null?void 0:a.interview)==null?void 0:S.meet_url)||pe((v=a==null?void 0:a.interview)==null?void 0:v.external_meet_url)||null}function Ph(r,a){var u,l,_,b,S,v;const t=(u=r==null?void 0:r.concierge)==null?void 0:u.interview_scheduling,o=pe(a==null?void 0:a.scheduled_start_at)||pe((l=a==null?void 0:a.selected_slot)==null?void 0:l.starts_at)||pe((_=a==null?void 0:a.interview)==null?void 0:_.sc
1heduled_start_at)||pe((b=a==null?void 0:a.interview)==null?void 0:b.scheduled_starts_at)||pe(t==null?void 0:t.scheduled_start_at)||null,m=pe((S=a==null?void 0:a.selected_slot)==null?void 0:S.timezone)||pe(a==null?void 0:a.timezone)||pe((v=a==null?void 0:a.interview)==null?void 0:v.timezone)||pe(t==null?void 0:t.timezone)||null,g=(a==null?void 0:a.duration_minutes)??(t==null?void 0:t.duration_minutes)??30;return{scheduledStartAt:o,timezone:m,durationMinutes:g}}function qa(r,a){var S,v,k,B,E,s;const t=Bt(a??(r==null?void 0:r.next_step)),o=pe((S=r==null?void 0:r.concierge)==null?void 0:S.stage_status).toLowerCase(),m=pe((k=(v=r==null?void 0:r.concierge)==null?void 0:v.interview_outcome)==null?void 0:k.phase).toLowerCase(),g=pe((E=(B=r==null?void 0:r.concierge)==null?void 0:B.interview_outcome)==null?void 0:E.label).toLowerCase(),u=(s=r==null?void 0:r.concierge)==null?void 0:s.interview_scheduling,l=pe(u==null?void 0:u.scheduling_status).toLowerCase(),_=pe(u==null?void 0:u.outcome).toUpperCase();return m==="not_conducted"||o==="interview_not_conducted"||g.includes("not conducted")||l==="not_conducted"||(u==null?void 0:u.is_not_conducted)===!0||_==="NOT_CONDUCTED"||t==="INTERVIEW_NOT_CONDUCTED"?"not_conducted":t===Cr.NOT_SELECTED||o==="not_selected"?"not_selected":t===Cr.OFFER_RECEIVED||t===Cr.HIRED||o==="hired"||o==="offer_pending"||m==="selected"?"selected":t===Cr.AWAITING_HIRING_DECISION||o==="awaiting_client_decision"||m==="awaiting_hiring_decision"?"awaiting_decision":t===Cr.INTERVIEW_COMPLETED||t===Cr.INTERVIEW_COMPLETE||o==="interview_completed"||l==="completed"?"completed":null}function Pa(r){if(!r||(Array.isArray(r.offered_slots)?r.offered_slots.length:0)>0)return!1;if(pe(r.status).toLowerCase()==="awaiting_times"||pe(r.next_step).toUpperCase()==="AWAITING_INTERVIEW_TIMES")return!0;const t=pe(r.flow).toLowerCase();return t==="recruiter_slot_offer"||t==="instant_screening"}function po(r){return`You're approved for an interview. ${pe(r)||"Your BitStage recruiter"} will send you times to choose from soon. We'll email you when they're ready.`}function Uh(r,a,t){var v,k,B,E,s;if(qa(r,t))return"outcome";const m=pe(t??(r==null?void 0:r.next_step)),g=pe((v=r==null?void 0:r.concierge)==null?void 0:v.stage_status).toLowerCase(),u=pe((B=(k=r==null?void 0:r.concierge)==null?void 0:k.interview_scheduling)==null?void 0:B.scheduling_status).toLowerCase(),l=pe(a==null?void 0:a.status).toLowerCase();if(u==="not_conducted"||l==="not_conducted"||((s=(E=r==null?void 0:r.concierge)==null?void 0:E.interview_scheduling)==null?void 0:s.is_not_conducted)===!0||(a==null?void 0:a.is_not_conducted)===!0)return"outcome";const _=go(r,a);if(m==="INTERVIEW_SCHEDULED"||g==="interview_scheduled"||u==="scheduled"||l==="scheduled"||_)return"scheduled";const b=Array.isArray(a==null?void 0:a.offered_slots)?a.offered_slots.length:0,S=pe(a==null?void 0:a.flow).toLowerCase();return b===0&&Pa(a)?"pending":b>0||S==="instant_screening"||S==="recruiter_slot_offer"||l==="offered"||g==="instant_screening_offered"||g==="interview_slot_offered"||m==="INSTANT_SCREENING_PICK_SLOT"||m==="PICK_INTERVIEW_SLOT"?"pick_slot":m==="INTERVIEW_PENDING"||m==="AWAITING_INTERVIEW_TIMES"||m==="INTERVIEW_ACTION_REQUIRED"||g==="interview_eligible"||g==="interview_slot_offered"||l==="pending"||u==="pending"||u==="needs_slots"||u==="slots_offered"?"pending":"hidden"}function Mh(r,a,t=0,o){return o==="not_conducted"?null:r==="outcome"?6e4:r==="pending"||r==="pick_slot"?3e4:r==="scheduled"&&!a?t>=12e4?3e4:1e4:null}function Oh({title:r,stepCounter:a,description:t,mode:o,loading:m=!1,scheduledStartAt:g,timezone:u,durationMinutes:l,meetUrl:_,googleCalendarHtmlLink:b,managedExternally:S,companyName:v,jobTitle:k,outcome:B,outcomePhase:E,status:s,withHiringTeam:q=!1,offeredSlots:R=[],inviteNote:L,provisionalScoreLabel:N,expiresAt:P,selectingSlot:K=!1,onSelectSlot:xe,decliningSlots:J=!1,onDeclineSlots:re,productType:F=null,awaitingTimes:U=!1,recruiterName:me=null}){const D=(r==null?void 0:r.trim())||Km(F),ne=zm(F),X=String(F??"").trim().toLowerCase()==="crew",Z=o==="scheduled",W=o==="pending",V=o==="pick_slot",be=o==="outcome"||o==="completed";return V?m?e.jsx(le,{className:"border-primary/25 bg-primary/5 shadow-sm",children:e.jsxs(ie,{className:"flex items-center justify-center gap-3 p-6",children:[e.jsx(As,{}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading interview timesâ¦"})]})}):e.jsx(Bh,{companyName:v,jobTitle:k,durationMinutes:l??(X?15:30),unitLabel:X?"screening call":"interview",slots:R,selecting:K,declining:J,note:L,provisionalScoreLabel:N,expiresAt:P,onSelect:xe??(
1async()=>{}),onDeclineNoneWork:re}):W&&!Z?m?e.jsx(le,{className:"border-primary/25 bg-primary/5 shadow-sm",children:e.jsxs(ie,{className:"flex items-center justify-center gap-3 p-6",children:[e.jsx(As,{}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading interview statusâ¦"})]})}):e.jsx(ho,{title:r,description:U?po(me):t,status:s}):Z?m?e.jsx(le,{className:"border-[hsl(var(--brand-green)/0.40)] bg-[hsl(var(--brand-pale-green))] shadow-sm",children:e.jsxs(ie,{className:"flex items-center justify-center gap-3 p-6",children:[e.jsx(As,{}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading interview detailsâ¦"})]})}):e.jsx(xo,{title:r,scheduledStartAt:g,timezone:u,durationMinutes:l,meetUrl:_,googleCalendarHtmlLink:b,managedExternally:S,companyName:v,jobTitle:k}):be?e.jsxs("div",{className:"space-y-4",children:[e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"space-y-1 p-5 sm:p-6",children:[e.jsx(os,{counter:a,className:"mb-2"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(et,{className:"h-5 w-5 text-primary"})}),e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:D})]})]})}),e.jsx(fo,{outcome:B,phase:E??"completed"})]}):m?e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"flex items-center justify-center gap-3 p-6",children:[e.jsx(As,{}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading interview statusâ¦"})]})}):q?e.jsx(Ba,{title:`You're advancing to ${ne==="Screening call"?"a screening call":"interview"}.`,description:ne==="Screening call"?"You've been shortlisted. Open the Screening call step to pick a time from the recruiter's available slots â once you pick, the screening call is scheduled.":"You've been shortlisted. Open the Interview step to pick a time from the recruiter's available slots â once you pick, the interview is scheduled."}):e.jsx(Ba,{title:D,description:ne==="Screening call"?"Screening call details will appear here once the hiring team invites you.":"Interview details will appear here once the hiring team invites you."})}const Fh=["linkedin","twitter","facebook","whatsapp","email","copy"];function Wh(r,a,t){const o=typeof window<"u"?window.location.origin:"https://bitstage.ai";return r?`${o}/practice`:o}function Yh({badgeImageUrl:r,downloadFilename:a="bitstage-badge.png",shareText:t,shareUrl:o,scoreType:m,score:g,publicBadgeImageUrl:u,title:l="Share your win",description:_="Show your network you're rehearsing real role moments - recruiters take notice.",open:b,onOpenChange:S,trigger:v}){const[k,B]=c.useState(null),E=o??Wh(m),s=t??(m?"I rehearsed a real role moment on BitStage instead of guessing my way through an interview. #BitStage":"Check out BitStage - practicing real role moments instead of guessing my way through interviews. #BitStage"),q=c.useMemo(()=>({title:l,description:_,url:E,text:s,shortText:s,subject:l,downloadFilename:a}),[l,_,E,s,a]);return e.jsx(ao,{open:b,onOpenChange:S,payload:q,channels:Fh,resolvedDownloadUrl:k,trigger:v,preview:e.jsx("div",{className:"relative",children:e.jsx(Gm,{imageUrl:b===!1?null:r??null,fallbackLabel:l.replace(/^Share your\s+/i,"")||"BitStage badge",alt:"Badge preview",emptyTitle:"No badge yet",errorTitle:"Badge unavailable",loadingTitle:"Loading badge",className:"relative w-[200px] shadow-[0_8px_28px_-12px_hsl(220_40%_15%/0.18)]",onResolvedUrlChange:B})})})}function is({icon:r,label:a,value:t,valueClassName:o}){return e.jsxs("div",{className:"flex items-start gap-2.5 min-w-0",children:[e.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border/60 bg-muted/30",children:e.jsx(r,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:a}),e.jsx("p",{className:ye("text-sm font-semibold text-foreground truncate",o),children:t})]})]})}function Oi({title:r,stepCounter:a,description:t,candidateName:o,candidateAvatarUrl:m,roleTitle:g,employmentType:u,organizationName:l,issuedCredential:_=null,verifiedByLabel:b="Recruiter verified by BitStage",hired:S=null,jobDescription:v=null,rejected:k=null}){var ne;const[B,E]=c.useState(!1),[s,q]=c.useState(!1),[R,L]=c.useState(!1),N=((_==null?void 0:_.verification_id)||"").trim(),P=!!N&&_!=null,K=c.useMemo(()=>
1{if(!P||(_==null?void 0:_.final_score)==null)return null;const X=Number(_.final_score);return Number.isNaN(X)?null:Math.round(X)},[P,_==null?void 0:_.final_score]),xe=P&&(_!=null&&_.issued_at)?Xr(new Date(_.issued_at),"MMM d, yyyy"):"-",J=((_==null?void 0:_.role_title_snapshot)||g||"").trim()||"Role",re=c.useMemo(()=>{var Z;if(!N)return null;const X=((Z=_==null?void 0:_.badge_image_url)==null?void 0:Z.trim())||Qm(N);return Xm(X)},[N,_==null?void 0:_.badge_image_url]),F=c.useMemo(()=>N?Zm(N):"",[N]),U=c.useMemo(()=>F?Jm({candidateDisplayName:o,roleTitle:g,finalScore:K,publicUrl:F}):null,[F,o,g,K]),me=c.useCallback(async()=>{if(!N){Zr.error("Badge is not ready yet");return}L(!0);try{await eu(N),Zr.success("Badge downloaded")}catch{Zr.error("Could not download badge")}finally{L(!1)}},[N]),D=(o||"You").split(" ").filter(Boolean).slice(0,2).map(X=>{var Z;return((Z=X[0])==null?void 0:Z.toUpperCase())||""}).join("");if(S){const X=(S.role_title_snapshot||g||"").trim()||"this role",Z=(S.company_name_snapshot||l||"").trim(),W=/@/.test(Z)?"":Z,V=S.hire_start_date?Xr(new Date(S.hire_start_date),"MMM d, yyyy"):null,be=S.hired_at?Xr(new Date(S.hired_at),"MMM d, yyyy"):null,G=!!(v!=null&&v.trim());return e.jsx("div",{id:"final-result",className:"space-y-4 scroll-mt-24",children:e.jsxs(le,{className:"overflow-hidden border-primary/40 shadow-sm",children:[e.jsx("div",{className:"bg-accent px-5 py-6 sm:px-8 sm:py-8",children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-sm",children:e.jsx(uc,{className:"h-6 w-6","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-primary",children:(r==null?void 0:r.trim())||"Final result"}),e.jsx("h2",{className:"mt-0.5 text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"You're hired"}),e.jsx("p",{className:"mt-1 max-w-xl text-sm leading-relaxed text-foreground/80",children:(t==null?void 0:t.trim())||`Congratulations - the hiring team has selected you for ${X}${W?` at ${W}`:""}.`})]})]}),e.jsxs(je,{className:"shrink-0 gap-1.5 rounded-full bg-primary px-3 py-1 text-xs font-bold uppercase tracking-wide text-primary-foreground hover:bg-primary",children:[e.jsx(hc,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Hired"]})]})}),e.jsxs(ie,{className:"space-y-5 p-5 sm:p-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-3.5 sm:grid-cols-2",children:[e.jsx(is,{icon:Tt,label:"Role",value:X}),e.jsx(is,{icon:St,label:"Company",value:W||"Confidential employer",valueClassName:W?void 0:"text-muted-foreground"}),e.jsx(is,{icon:cr,label:"Hire date",value:be||"-"}),e.jsx(is,{icon:cr,label:"Start date",value:V||"To be confirmed",valueClassName:V?void 0:"text-muted-foreground"})]}),G?e.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4 sm:p-5",children:[e.jsx("p",{className:"mb-3 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Role details"}),e.jsx(Ai,{text:v})]}):null,e.jsx("div",{className:"rounded-xl border border-primary/30 bg-accent/50 p-4 sm:p-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(xc,{className:"mt-0.5 h-5 w-5 shrink-0 text-primary"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-bold text-foreground",children:"What happens next"}),e.jsx("p",{className:"text-sm leading-relaxed text-foreground/80",children:"The hiring team will reach out by email to confirm your start date and share onboarding details. If you have questions in the meantime, reply to any prior message from the recruiter."})]})]})})]})]})})}if(k){const X=(k.role_title_snapshot||g||"").trim()||"this role",Z=(k.company_name_snapshot||l||"").trim(),W=/@/.test(Z)?"":Z,V=k.rejected_at?Xr(new Date(k.rejected_at),"MMM d, yyyy"):null,be=((ne=k.reason_public)==null?void 0:ne.trim())||null;return e.jsx("div",{id:"final-result",className:"space-y-4 scroll-mt-24",children:e.jsxs(le,{className:"overflow-hidden border-slate-200 shadow-sm",children:[e.jsx("div",{className:"bg-gradient-to-r from-slate-100 via-slate-50 to-white px-5 py-6 sm:px-8 sm:py-8",children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-slate-500 text-white shadow-sm",children:e.jsx(Tr,{className:"h-6 w-6","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-slate-500",children:(r==null?void 0:r.trim())||"Final result"}),e.jsx("h2",{className:"mt-0.5 text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:Dt.title}),e.jsx("p",{className:"mt-1 max-w-xl text-sm leading-relaxed text-foreground
1/80",children:(t==null?void 0:t.trim())||Dt.description})]})]}),e.jsx(je,{className:"shrink-0 gap-1.5 rounded-full bg-slate-500 px-3 py-1 text-xs font-bold uppercase tracking-wide text-white hover:bg-slate-500",children:"Not selected"})]})}),e.jsxs(ie,{className:"space-y-5 p-5 sm:p-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-3.5 sm:grid-cols-2",children:[e.jsx(is,{icon:Tt,label:"Role",value:X}),e.jsx(is,{icon:St,label:"Company",value:W||"Confidential employer",valueClassName:W?void 0:"text-muted-foreground"}),e.jsx(is,{icon:cr,label:"Decision date",value:V||"-"})]}),be?e.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4 sm:p-5",children:[e.jsx("p",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Message from the hiring team"}),e.jsx("p",{className:"whitespace-pre-line text-sm leading-relaxed text-foreground/90",children:be})]}):null,e.jsx("div",{className:"rounded-xl border border-slate-200 bg-slate-50 p-4 sm:p-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Tr,{className:"mt-0.5 h-5 w-5 shrink-0 text-slate-500"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-bold text-foreground",children:"What's next"}),e.jsx("p",{className:"text-sm leading-relaxed text-foreground/80",children:"A decision on one role never limits your other applications. Keep applying - your rehearsal work and BitScore travel with you."})]})]})})]})]})})}return P?e.jsxs("div",{id:"final-result",className:"space-y-4 scroll-mt-24",children:[e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"space-y-5 p-5 sm:p-6",children:[e.jsx(os,{counter:a}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:(r==null?void 0:r.trim())||"Final result"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(t==null?void 0:t.trim())||"You've successfully completed all steps. Here is your verified BitScore."})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-border/70 bg-muted/15 p-5 sm:p-6",children:[e.jsx(Am,{score:K,role:J,size:"lg",variant:"bitscore",badgeImageUrl:re,hideDownload:!0}),e.jsxs("div",{className:"mt-4 space-y-1 text-center",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-primary",children:"Verified BitScore"}),e.jsx("p",{className:"text-2xl font-bold tabular-nums text-foreground",children:K??"-"})]})]}),e.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4 sm:p-5",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 border-b border-border/50 pb-4",children:[m?e.jsx("img",{src:m,alt:"",className:"h-12 w-12 rounded-full object-cover"}):e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-primary/10 text-sm font-bold text-primary",children:D||"BS"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-base font-bold text-foreground",children:(o==null?void 0:o.trim())||"Candidate"}),e.jsxs("p",{className:"inline-flex items-center gap-1 text-xs font-semibold text-primary",children:["Verified BitScore Holder",e.jsx(fc,{className:"h-3.5 w-3.5"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3.5 sm:grid-cols-2",children:[e.jsx(is,{icon:Zi,label:"Role",value:J}),e.jsx(is,{icon:gc,label:"Final BitScore",value:K!=null?`${K}`:"-",valueClassName:"tabular-nums"}),e.jsx(is,{icon:Tt,label:"Employment type",value:(u==null?void 0:u.trim())||"-"}),e.jsx(is,{icon:St,label:"Organization",value:(l==null?void 0:l.trim())||"-"}),e.jsx(is,{icon:cr,label:"Issued date",value:xe}),e.jsx(is,{icon:Ps,label:"Verified by",value:b||"Recruiter verified by BitStage",valueClassName:"text-primary"})]}),e.jsxs("div",{className:"mt-5 space-y-2",children:[e.jsx(ae,{className:"h-10 w-full gap-2 font-semibold",asChild:!0,children:e.jsxs("a",{href:`/credentials/${encodeURIComponent(N)}`,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Ji,{className:"h-4 w-4"}),"View / share credential"]})}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsxs(ae,{variant:"outline",className:"h-10 gap-2 font-semibold",disabled:!U,onClick:()=>q(!0),children:[e.jsx(pc,{className:"h-4 w-4"}),"Share credential"]}),e.jsxs(ae,{variant:"outline",className:"h-10 gap-2 font-semibold",onClick:()=>void me(),disabled:R,children:[e.jsx(bc,{className:"h-4 w-4"}),R?"Downloadingâ¦":"Download badge"]})]}),e.jsx(ae,{variant:"ghost",className:"h-9 w-full text-xs text-muted-foreground",onClick:()=>E(!0),children:"Open share card"})]})]})]})]})}),e.jsx(Yh,{open:B,onOpenChange:E,badgeImageUrl:re,downloadFilename:`bitscore-badge-${K??"score"}.png`,scoreType:"bitscore",score:K,title:"Share your BitScore"}),e.jsx(ao,{open:s,onOpenChange:q,payload:U})]}):e.jsx("div",{id:"final-result",className:"space-y-4 scroll-mt-24",children:e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsxs(ie,{className:"space-y-5 p-5 sm:p-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-foreground sm:text-2xl",children:(r==null?void 0:r.trim())||"Final result"}),e.jsx(je,{variant:"outline",className:"rounded-full border-border text-muted-foreground",children:"Pending verification"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(t==null?void 0:t.trim())||"Your verified BitScore will appear here after recruiter review."})]}),e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed border-border/80 bg-muted/20 px-6 py-12 text-center",children:[e.jsx("div",{className:"mb-3 flex h-12 w-12 items-center justify-center rounded-full border border-border/70 bg-background",children:e.jsx(Jr,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Verified credential not issued yet"}),e.jsx("p",{className:"mt-1 max-w-sm text-sm text-muted-foreground",children:"Once a recruiter confirms your Final BitScore, your shareable badge will unlock here."})]})]})})})}function $h({job:r,onTryPractice:a,practiceSubmitting:t=!1,disabled:o=!1}){const m=r.selected_rehearsal||no(r.enabled_rehearsals);return!r.allow_practice||!m?null:e.jsx(le,{className:"border-blue-200/60 bg-blue-50/60 shadow-none",children:e.jsxs(ie,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-11 h-11 rounded-full bg-white flex items-center justify-center shrink-0 shadow-sm",children:e.jsx(wa,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-foreground leading-tight",children:"Practice first"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Build confidence with a short, private practice before you apply."})]})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 border border-white px-4 py-3",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:m.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[Qd(m.target_interaction_seconds||60)," ⢠Private practice"]})]}),e.jsxs(ae,{variant:"outline",className:"w-full border-primary/40 text-primary hover:bg-primary hover:text-primary-foreground bg-white",onClick:a,disabled:t||o,children:[t?"Startingâ¦":"Try a private practice run",!t&&e.jsx(Ns,{className:"h-4 w-4 ml-1"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1.5",children:[e.jsx(Jr,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsxs("span",{children:["Not part of your application.",e.jsx("br",{}),"Not shared with the employer."]})]})]})})}function qh(r,a){return a&&(r==null?void 0:r.runtime_minutes)!=null?`~${r.runtime_minutes}-minute assessment`:"~3-minute assessment"}function Hh({nextRehearsal:r,assignedScenario:a,isRetry:t=!1}
1){const o=a??(r==null?void 0:r.assigned_scenario)??null,m=!!o,g=m?(o==null?void 0:o.title)??(r==null?void 0:r.title)??Ce:(r==null?void 0:r.title)??Ce,u=m?(o==null?void 0:o.description)??(o==null?void 0:o.brief)??(r==null?void 0:r.brief):r==null?void 0:r.brief;return!g&&!u?null:e.jsx(le,{className:"border-primary/30 bg-primary/5 shadow-sm",children:e.jsxs(ie,{className:"p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-primary",children:t?`Retry ${Ce}`:`Your ${Ce}`}),e.jsx("h3",{className:"text-lg font-bold text-foreground mt-1",children:g}),u&&e.jsx("p",{className:"text-sm text-muted-foreground mt-2 leading-relaxed",children:u})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(je,{variant:"outline",className:"gap-1 text-xs",children:[e.jsx(at,{className:"h-3 w-3"}),qh(o,m)]}),(o==null?void 0:o.scenario_type)&&e.jsxs(je,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(yc,{className:"h-3 w-3"}),Hc(o.scenario_type)]}),(o==null?void 0:o.difficulty_level)!=null&&e.jsxs(je,{variant:"outline",className:"gap-1 text-xs",children:[e.jsx(vc,{className:"h-3 w-3"}),Vc(o.difficulty_level)]})]})]})})}function Vh(){return e.jsx(le,{className:"border-[hsl(var(--brand-navy))]/25 bg-gradient-to-br from-[hsl(var(--brand-cream))] to-background shadow-sm",children:e.jsxs(ie,{className:"p-6 text-center space-y-4",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"h-12 w-12 rounded-full bg-[hsl(var(--brand-cream))] flex items-center justify-center border border-[hsl(var(--brand-navy))]/15",children:e.jsx(nt,{className:"h-6 w-6 text-[hsl(var(--brand-navy))]"})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{variant:"secondary",className:"bg-[hsl(var(--brand-cream))] text-[hsl(var(--brand-navy))] border-[hsl(var(--brand-navy))]/20 gap-1",children:[e.jsx(as,{className:"h-3 w-3 animate-spin"}),"Preparing"]}),e.jsxs("h3",{className:"text-lg font-bold text-foreground",children:["You've advanced to ",Ce]}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed max-w-md mx-auto",children:"We're tailoring your Work Style scenario to this role. This usually takes about a minute - you'll be able to start as soon as it's ready."})]})]})})}function Kh(){return e.jsx(le,{className:"border-[hsl(var(--brand-navy))]/25 bg-gradient-to-br from-[hsl(var(--brand-cream))] to-background shadow-sm",children:e.jsxs(ie,{className:"p-6 text-center space-y-4",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"h-12 w-12 rounded-full bg-[hsl(var(--brand-cream))] flex items-center justify-center border border-[hsl(var(--brand-navy))]/15",children:e.jsx(nt,{className:"h-6 w-6 text-[hsl(var(--brand-navy))] animate-pulse"})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{variant:"secondary",className:"bg-[hsl(var(--brand-cream))] text-[hsl(var(--brand-navy))] border-[hsl(var(--brand-navy))]/20",children:"Preparing"}),e.jsxs("h3",{className:"text-lg font-bold text-foreground",children:["You've advanced to ",Ce]}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed max-w-md mx-auto",children:"Your hiring team is finalizing your Work Style scenario. You'll be notified when it's ready to begin."})]})]})})}function zh({status:r,reason:a,className:t}){const o=r==="hired",m=o?"Youâve been selected":Dt.title,g=o?"The hiring team has marked you as hired for this role. Check your email for next steps.":Dt.description,u=(a??"").trim();return e.jsx(le,{className:ye("shadow-sm",o?"border-[hsl(var(--brand-green)/0.40)] bg-[hsl(var(--brand-pale-green))]":"border-border bg-muted/20",t),children:e.jsxs(ie,{className:"space-y-4 p-6",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:ye("mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-full",o?"bg-[hsl(var(--brand-pale-green))] text-[hsl(var(--brand-navy))]":"bg-muted text-muted-foreground"),children:e.jsx(gs,{className:"h-5 w-5","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h3",{className:"text-base font-bold text-foreground",children:m}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:g})]})]}),u?e.jsxs("div",{className:"rounded-lg border border-border bg-background/80 px-3 py-2.5",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[e.jsx(_c,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Message from the hiring team"]}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-foreground whitespace-pre-wrap",children:u})]}):null]})})}function Ah({nextStep:r}){const a=rm(r);if(!a)return null;const t=Bt(r)==="NOT_SELECTED";return e.jsx(le,{className:t?"border-l-4 border-l-muted-foreground
1/50 bg-muted/20 shadow-sm":"border-l-4 border-l-primary",children:e.jsxs(ie,{className:"p-4",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:a.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 leading-relaxed",children:a.description})]})})}function Gh({status:r,journey:a}){const t=to(r,a);return t?e.jsx(le,{className:"border-l-4 border-l-[hsl(var(--brand-green))] bg-[hsl(var(--brand-pale-green))] shadow-sm",children:e.jsxs(ie,{className:"p-4 flex items-start gap-3",children:[e.jsx("div",{className:"h-9 w-9 shrink-0 rounded-lg bg-[hsl(var(--brand-pale-green))] flex items-center justify-center border border-[hsl(var(--brand-green)/0.4)]",children:e.jsx(nt,{className:"h-4 w-4 text-[hsl(var(--brand-navy))]"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:t.description})]})]})}):null}function Qh({block:r,className:a,jobTitle:t}){return e.jsx(le,{className:ye("border-border/80 bg-muted/20 shadow-sm",a),children:e.jsxs(ie,{className:"flex flex-col gap-5 p-6 sm:p-8",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-muted",children:e.jsx(jc,{className:"h-6 w-6 text-muted-foreground","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Applications closed"}),e.jsx("h2",{className:"text-xl font-bold text-foreground leading-snug",children:r.title}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium text-foreground",children:t})," is no longer accepting new applications or rehearsals."]}):r.message}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Thank you for your interest. You can return to My Applications to view your other roles."})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 sm:pl-16",children:e.jsx(ae,{asChild:!0,variant:"default",size:"sm",children:e.jsx(Ua,{to:"/applications",children:"Back to my applications"})})})]})})}function Xh(r,a){return!1}function Zh(r){if(!r)return!1;if(ws){const a=dr(r);return a==="queued_for_slot"||a==="auto_invite_pending"||a==="reserve_75_79"}return(r.resume_band??"")==="qualified"||(r.resume_band??"")==="fast_track"?!0:(r.next_step??"").trim().toUpperCase()==="IN_QUALIFIED_POOL"}const Jh={invited:"Invited",resume_uploaded:"Resume Uploaded",rehearsal_selected:"Rehearsal Selected",in_progress:"In Progress",submitted:"Submitted",expired:"Expired",quota_full:"Role closed",not_eligible:"Not Eligible"},ex=new Set(["resume_uploaded","rehearsal_selected","in_progress"]),It=r=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test((r==null?void 0:r.trim())??""),Nf=()=>{var Nn,kn,Rn,Cn,En,In,Tn,Sn,Ln,Dn,Bn,Pn,Un,Mn,On,Fn,Wn,Yn,$n,qn,Hn,Vn,Kn,zn,An,Gn,Qn,Xn,Zn,Jn,el,sl,rl,tl,al,nl,ll,il,ol,dl,cl,ml,ul,hl,xl,fl,gl,pl,bl,yl,vl,_l,jl,wl,Nl,kl,Rl,Cl,El,Il,Tl,Sl,Ll,Dl,Bl,Pl,Ul,Ml,Ol,Fl,Wl,Yl,$l,ql,Hl,Vl,Kl,zl,Al;const{appId:r}=ud(),a=Fi(),t=hd(),{setActiveInvite:o,updateInvite:m,candidateAvatarUrl:g}=Td(),{toast:u}=Ma(),[l,_]=c.useState(null),[b,S]=c.useState(null),[v,k]=c.useState(null),[B,E]=c.useState(null),[s,q]=c.useState(null),[R,L]=c.useState(null),[N,P]=c.useState(null),[K,xe]=c.useState({}),[J,re]=c.useState(!1),[F,U]=c.useState(!1),[me,D]=c.useState(!1),[ne,X]=c.useState(!0),[Z,W]=c.useState(!1),[V,be]=c.useState(null),[G,ve]=c.useState(null),[A,_e]=c.useState(null),Ue=c.useRef(null),[Me,Y]=c.useState("rehearsal_1"),[C,Te]=c.useState(null),[O,Ee]=c.useState(!1),we=c.useRef(0),[Ye,Ie]=c.useState(!1),[ge,Qs]=c.useState(!1),[Us,Pt]=c.useState(!1),[$e,mr]=c.useState(!1),[lt,Xs]=c.useState(!1),[rs,Ms]=c.useState(!1),ps=c.useRef(null),Ve=c.useRef(!0),Sr=c.useRef(!1),Zs=c.useRef(!!((Nn=t.state)!=null&&Nn.startWorkStyle)),Os=c.useRef(null),Js=c.useRef(async()=>{}),ds=((r==null?void 0:r.trim())??"")||"",Fs=!!ds&&!It(ds);c.useEffect(()=>()=>{Ve.current=!1,ps.current&&ps.current.abort()},[]),c.useEffect(()=>{if(!(r!=null&&r.trim())){X(!1),W(!0);return}
1ps.current&&ps.current.abort(),ps.current=new AbortController;const n=ps.current.signal;X(!0),W(!1),(async()=>{var y,f,I,H,$;try{const z=Fs?aa.getJobBySlug(ds,{sendAuth:!0,signal:n}).catch(()=>null):null,[M,se]=await Promise.all([Od(),z]);if(n.aborted||!Ve.current)return;const Ne=r.trim(),ce=M.find(Q=>Q.job_id&&Q.job_id.trim()===Ne||Q.id&&Q.id.trim()===Ne||Q.application_id&&Q.application_id.trim()===Ne||Q.primary_link_slug&&Q.primary_link_slug.trim()===Ne);if(_(ce??null),ce&&new Set(["position_closed_by_employer","paused_by_employer","employer_inactive"]).has(ce.status)){!n.aborted&&Ve.current&&a("/applications",{replace:!0});return}let oe=se;if(ce){const Q=((y=ce.primary_link_slug)==null?void 0:y.trim())||((f=ce.job_id)==null?void 0:f.trim())||"";if(Q&&!It(Q))if(se&&Q===ds)S(se),oe=se;else try{const Re=await aa.getJobBySlug(Q,{sendAuth:!0,signal:n});!n.aborted&&Ve.current&&(S(Re),oe=Re)}catch{!n.aborted&&Ve.current&&(S(null),oe=null)}}else if(Fs&&se)k(se),oe=se;else if(Fs)try{const Q=await aa.getJobBySlug(ds,{sendAuth:!0,signal:n});!n.aborted&&Ve.current&&(k(Q),oe=Q)}catch{!n.aborted&&Ve.current&&(k(null),oe=null)}const ke=((I=ce==null?void 0:ce.primary_link_slug)==null?void 0:I.trim())||(Fs?ds:"")||((H=oe==null?void 0:oe.primary_link_slug)==null?void 0:H.trim())||"";if(ke&&!n.aborted)try{const Q=await Nu(ke);!n.aborted&&Ve.current&&Q.ok&&E({closes_at:Q.data.deadline??null,job_status:Q.data.job_status??null})}catch{!n.aborted&&Ve.current&&E(null)}const Fe=(ce==null?void 0:ce.job_id)||(oe==null?void 0:oe.id),te=oe;if(Fe&&!n.aborted&&Ve.current)try{const Q=await Gs(Fe);if(!n.aborted&&Ve.current){q(Q);const Re=await Kr(Fe,Q,{applicationUpdatedAt:ce==null?void 0:ce.updated_at,hasPassedResume:!Is(Q),rehearsalCount:($=te==null?void 0:te.enabled_rehearsals)==null?void 0:$.length,enabledRehearsals:te==null?void 0:te.enabled_rehearsals,signal:n});!n.aborted&&Ve.current&&L(Re)}}catch{}}catch{!n.aborted&&Ve.current&&_(null)}finally{!n.aborted&&Ve.current&&(X(!1),W(!0))}})()},[r,Fs,ds]),c.useEffect(()=>{const n=s==null?void 0:s.rehearsal_attempts_history;if(!(n!=null&&n.length)){xe({}),re(!1);return}let d=!1;return re(!0),(async()=>{const y={};await Promise.all(n.map(async f=>{const I=f.attempt_id,H=(f.status||"").toLowerCase();if(!(f.processing_stage==="failed"||H==="failed"||!["scored","replay_ready","completed"].includes(H)))try{const se=(await Sd(I)).overall_score;y[I]=typeof se=="number"&&!Number.isNaN(se)?se:f.score??null}catch{y[I]=f.score??null}})),d||(xe(y),re(!1))})(),()=>{d=!0}},[s]),c.useEffect(()=>{Sr.current=!1,L(null),P(null),ve(null),_e(null)},[r]),c.useEffect(()=>{const n=(l==null?void 0:l.job_id)||(b==null?void 0:b.id)||(v==null?void 0:v.id);if(!n){P(null);return}let d=!1;return ta(n).then(y=>{d||P(y)}).catch(()=>{d||P(null)}),()=>{d=!0}},[l==null?void 0:l.job_id,b==null?void 0:b.id,v==null?void 0:v.id,l==null?void 0:l.updated_at]),c.useEffect(()=>{var M;const n=N?qr(N,s,{product_type:l==null?void 0:l.product_type}):null,y=bt(n,{productTypeHint:(l==null?void 0:l.product_type)??null,isVerifiedEmail:s==null?void 0:s.is_verified_email,requiresVerification:s==null?void 0:s.requires_verification,nextStep:s==null?void 0:s.next_step,interviewActive:Gr(s),resumeScore:(s==null?void 0:s.resume_score)??null}).steps;if(!y.length){Ue.current=null,_e(null);return}const f=((M=Hr(y))==null?void 0:M.key)??null,I=Ue.current;Ue.current=f;const H=!Is(s),$=Ir(s),z=!!(s!=null&&s.has_eligibility_questions)&&(s==null?void 0:s.eligibility_screen_status)!=="passed";_e(se=>Fd({steps:y,selectedKey:se,previousCurrentKey:I,eligibilityPending:z,resumeRetryRequired:$||Vr(s),resumeComplete:H}))},[N,s,l==null?void 0:l.product_type]),c.useEffect(()=>{A&&Bs(A)?(Y(A),ve(A)):A&&ve(A)},[A]),c.useEffect(()=>{var f;const n=(l==null?void 0:l.job_id)||(b==null?void 0:b.id)||(v==null?void 0:v.id),d=b??v;if(!n||!s||!((f=d==null?void 0:d.enabled_rehearsals)!=null&&f.length))return;let y=!1;return(async()=>{var H;const I=await Kr(n,s,{applicationUpdatedAt:l==null?void 0:l.updated_at,hasPassedResume:!Is(s),rehearsalCount:(H=d.enabled_rehearsals)==null?void 0:H.length,enabledRehearsals:d.enabled_rehearsals});y||L(I)})(),()=>{y=!0}},[l==null?void 0:l.job_id,l==null?void 0:l.updated_at,s,b,v]);const Ke=(l==null?void 0:l.job_id)||(b==null?void 0:b.id)||(v==null?void 0:v.id),Ws=Bt((R==null?void 0:R.next_step)??(s==null?void 0:s.next_step)),Ut=(()=>{var d;if(!A)return!1;const n=(d=R==null?void 0:R.steps)==null?void 0:d.find(y=>y.key===A);return Qe(A,n==null?void 0:n.type)==="interview"}
1)(),ur=!!Ke&&(Gr(s,Ws)||Ut),Ts=c.useMemo(()=>Uh(s,C,Ws),[s,C,Ws]),hr=c.useMemo(()=>qa(s,Ws),[s,Ws]),er=c.useMemo(()=>go(s,C),[s,C]),bs=c.useMemo(()=>Ph(s,C),[s,C]),xr=c.useMemo(()=>ur?Mh(Ts,!!er,0,hr):null,[ur,Ts,er,hr]),sr=c.useCallback(async n=>{const d=await hi(n);Te(d)},[]),Mt=c.useCallback(async n=>{if(Ke){Ie(!0);try{const d=await Kc(Ke,n);Te(d)}catch(d){if(zc(d)){u({title:"Pick another time",description:Ac}),sr(Ke).catch(()=>{});return}if(Gc(d)){u({title:"Could not book that time",description:Qc}),sr(Ke).catch(()=>{});return}u({title:"Could not book that time",description:xi(d),variant:"destructive"})}finally{Ie(!1)}}},[Ke,sr,u]),Ot=c.useCallback(async()=>{if(Ke){Qs(!0);try{const n=await Xc(Ke);Te(n),u({title:"Got it",description:(n==null?void 0:n.message)||"Thanks â your recruiter will send new times."})}catch(n){u({title:"Could not decline times",description:xi(n),variant:"destructive"})}finally{Qs(!1)}}},[Ke,u]);c.useEffect(()=>{if(!ur||!Ke){Te(null);return}const n=++we.current,d=()=>we.current===n;return Ee(!0),hi(Ke).then(y=>{d()&&Te(y)}).catch(()=>{d()&&Te(null)}).finally(()=>{d()&&Ee(!1)}),()=>{d()&&(we.current+=1)}},[ur,Ke,(kn=s==null?void 0:s.concierge)==null?void 0:kn.stage_status,(Cn=(Rn=s==null?void 0:s.concierge)==null?void 0:Rn.interview_scheduling)==null?void 0:Cn.scheduling_status,(In=(En=s==null?void 0:s.concierge)==null?void 0:En.interview_scheduling)==null?void 0:In.google_meet_url,(Sn=(Tn=s==null?void 0:s.concierge)==null?void 0:Tn.interview_scheduling)==null?void 0:Sn.meeting_url,Ws]),c.useEffect(()=>{if(!Ke||!xr)return;const n=window.setInterval(()=>{sr(Ke).catch(()=>{})},xr);return()=>window.clearInterval(n)},[Ke,xr,sr]);const ys=Xh();c.useEffect(()=>{const n=fi(s,R);n.length&&!n.includes(Me)&&Y(n[0])},[s,R,Me]),c.useEffect(()=>{var I,H,$,z;if(G){Bs(G)&&Y(G);const M=(I=R==null?void 0:R.steps)==null?void 0:I.find(Ne=>Ne.key===G),se=Hr((R==null?void 0:R.steps)??[]);if(M&&se&&M.key!==se.key&&(M.status==="completed"||M.key==="resume_screen"))return}const n=(H=R==null?void 0:R.concierge)==null?void 0:H.current_rehearsal_key;if(n&&Bs(n)){Y(n);return}const d=($=R==null?void 0:R.steps)==null?void 0:$.find(M=>M.type==="rehearsal"&&zr(M.status));if(d!=null&&d.key&&Bs(d.key)){Y(d.key);return}if((z=R==null?void 0:R.steps)==null?void 0:z.find(M=>M.type==="behavioural"&&zr(M.status))){Y("behavioural");return}const f=ua(s);if(f!=null&&f.waitingForClientScenario){Y("behavioural");return}if(f!=null&&f.r2IsCurrent,f&&!f.r1Passed){Y("rehearsal_1");return}if(!Is(s)){const M=V??((f==null?void 0:f.defaultFocusStage)==="Resume rehearsal"?f.r2IsCurrent&&ys?"Rehearsal 2":"Rehearsal 1":f!=null&&f.r2IsCurrent&&!ys?"Work-Style Conversation":(f==null?void 0:f.defaultFocusStage)??null);M&&Y(Ar(M))}},[s,V,R,G,ys]),c.useEffect(()=>{if(Is(s)||tm(s)){be(null);return}const n=ua(s);if(!(n!=null&&n.defaultFocusStage)||Sr.current)return;const d=n.defaultFocusStage==="Resume rehearsal"?n.r2IsCurrent&&ys?"Rehearsal 2":"Rehearsal 1":n.r2IsCurrent&&!ys&&!n.defaultFocusStage?"Work-Style Conversation":n.defaultFocusStage;be(d),Sr.current=!0},[s,ys]);const ze=((Ln=l==null?void 0:l.primary_link_slug)==null?void 0:Ln.trim())||((Dn=l==null?void 0:l.job_id)==null?void 0:Dn.trim())||"",w=It(ze),T=!!ze&&!w,p=l?{id:l.job_id,slug:ze||l.job_id,company:b!=null&&b.is_confidential||l.is_confidential?"Hiring via BitStage":(b==null?void 0:b.org_name)??l.company_name,jobTitle:(b==null?void 0:b.title)??l.job_title,status:["invited","resume_uploaded","rehearsal_selected","in_progress","submitted","expired","quota_full","not_eligible"].includes(l.status)?l.status:"invited",deadline:l.deadline,submittedAt:l.submitted_at??void 0,bitScore:l.bit_score??void 0,rehearsalName:l.rehearsal_name??void 0,jobType:(b==null?void 0:b.employment_type)||void 0,location:(b==null?void 0:b.location)||"On-site",description:(b==null?void 0:b.description)||""}:v?{id:v.id,slug:ds,company:v.is_confidential?"Hiring via BitStage":v.org_name??"",jobTitle:v.title??"",status:"invited",deadline:v.closes_at??null,submittedAt:void 0,bitScore:void 0,rehearsalName:void 0,jobType:v.employment_type||void 0,location:v.location||"On-site",description:v.description||""}:null,de=p?l?ze:ds:"",Xe=!!de&&!It(de),i=b??v,es=no(i==null?void 0:i.enabled_rehearsals),ns=Nr
1((Bn=i==null?void 0:i.selected_rehearsal)==null?void 0:Bn.id,(Pn=s==null?void 0:s.selected_rehearsal)==null?void 0:Pn.id,es==null?void 0:es.id);c.useEffect(()=>{if(t.hash!=="#final-result")return;let n=0;const d=()=>{const y=document.getElementById("final-result");if(y){y.scrollIntoView({behavior:"smooth",block:"start"});return}n++<40&&requestAnimationFrame(d)};requestAnimationFrame(d)},[t.hash,Z,ne]);const Ys=!!(i!=null&&i.is_confidential||l!=null&&l.is_confidential||v!=null&&v.is_confidential),Be=Ys?"Hiring via BitStage":(p==null?void 0:p.company)??"",bo=(i==null?void 0:i.application_closes_at)??(l==null?void 0:l.deadline)??(i==null?void 0:i.closes_at)??(p==null?void 0:p.deadline)??null,Ha=ia((p==null?void 0:p.jobType)||(i==null?void 0:i.employment_type)),Ft=Xd(i==null?void 0:i.work_mode),Va=Zd(i==null?void 0:i.experience_range),Ka=Jd({currency:i==null?void 0:i.salary_currency,min:i==null?void 0:i.salary_min,max:i==null?void 0:i.salary_max}),yo=Array.isArray(i==null?void 0:i.skills)?i.skills:[],vo=((Un=p==null?void 0:p.location)==null?void 0:Un.trim())||Ft||"On-site",Wt={jobSource:i,linkMeta:B,application:l,applicationStatus:s},za=yu(Wt),_o=bu(za),jo=uu(za),Lr=(l==null?void 0:l.job_id)||(b==null?void 0:b.id)||(v==null?void 0:v.id)||(p==null?void 0:p.id)||null,Aa=c.useMemo(()=>{if(!ws||!s)return!1;const n=dr(s);return n==="queued_for_slot"||n==="auto_invite_pending"},[s]);c.useEffect(()=>{var $;if(!Aa||!Lr)return;const n=3e4;let d=!1;const y=($=b??v)==null?void 0:$.enabled_rehearsals,f=async()=>{if(!(d||document.visibilityState==="hidden"))try{const z=await Gs(Lr);if(d)return;q(z);const M=await Kr(Lr,z,{applicationUpdatedAt:l==null?void 0:l.updated_at,hasPassedResume:!Is(z),rehearsalCount:y==null?void 0:y.length,enabledRehearsals:y});if(d)return;L(M);const se=await ta(Lr).catch(()=>null);d||P(se)}catch{}},I=window.setInterval(()=>{f()},n),H=()=>{document.visibilityState==="visible"&&f()};return document.addEventListener("visibilitychange",H),()=>{d=!0,window.clearInterval(I),document.removeEventListener("visibilitychange",H)}},[Aa,Lr,l==null?void 0:l.updated_at,b,v]),c.useEffect(()=>{Zs.current&&(!Z||ne||F||s&&(Zs.current=!1,a(t.pathname+t.search,{replace:!0,state:{}}),Y("behavioural"),be("Work-Style Conversation"),ve("behavioural"),queueMicrotask(()=>{var n;(n=Os.current)==null||n.call(Os)})))},[Z,ne,s,F,a,t.pathname,t.search]);const Ga=am(s),Qa=(p==null?void 0:p.id)||(l==null?void 0:l.job_id)||null;c.useEffect(()=>{if(!Qa||!Ga)return;let n=!1,d=0;const y=40,f=4e3,I=async()=>{n||d>=y||(d+=1,await Js.current())},H=window.setInterval(()=>{I()},f);return I(),()=>{n=!0,window.clearInterval(H)}},[Qa,Ga]);const Xa=lh();if(!Z||ne)return e.jsx(sa,{layout:"job-entry",children:e.jsx(As,{message:"Loading applicationâ¦"})});if(!r||!p)return e.jsx(sa,{layout:"job-entry",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("h1",{className:"font-display text-xl font-bold text-foreground mb-2",children:"Application not found"}),e.jsx(ae,{variant:"outline",onClick:()=>a("/applications"),children:"Back to applications"})]})});const Za=(N==null?void 0:N.hired)!=null||((Mn=s==null?void 0:s.client_decision)==null?void 0:Mn.status)==="hired",Ja=(N==null?void 0:N.rejected)!=null||((On=s==null?void 0:s.client_decision)==null?void 0:On.status)==="rejected",wo=!(Za||Ja)&&["invited","resume_uploaded","rehearsal_selected","in_progress","submitted","expired","quota_full","not_eligible"].includes(p.status),en=vu(Wt)||jo,No=_u({jobClosed:en,hasApplication:!0}),ko=ju(Wt)??_o,Yt=(s==null?void 0:s.rehearsal_attempts_history)||[],Ro=(()=>{var y;const n=(y=s==null?void 0:s.concierge)==null?void 0:y.pending_decision;if(n&&typeof n=="object"&&n.score!=null)return Math.round(Number(n.score));const d=Yt[Yt.length-1];return typeof(d==null?void 0:d.score)=="number"?Math.round(d.score):0})(),$t=(l==null?void 0:l.job_id)||(b==null?void 0:b.id)||(v==null?void 0:v.id),j=(()=>{var d,y,f,I;let n=null;return(d=R==null?void 0:R.steps)!=null&&d.length?n=R:(f=(y=s==null?void 0:s.journey)==null?void 0:y.steps)!=null&&f.length?n=s.journey:$t&&s&&(n=nm($t,s,{applicationUpdatedAt:l==null?void 0:l.updated_at,hasPassedResume:!Is(s),rehearsalCount:(I=i==null?void 0:i.enabled_rehearsals)==null?void 0:I.length,enabledRehearsals:i==null?void 0:i.enabled_rehearsals})),n?qr(n,s,{product_type:l==null?void 0:l.product_type,job_product_type:(i==null?void 0:i.product_type)??(l==null?void 0:l.product_type)}):null}
1)(),Dr=fi(s,j),fr=lm(s,Dr,j,{enabledRehearsalCount:(Fn=i==null?void 0:i.enabled_rehearsals)==null?void 0:Fn.length}),h=im(j),cs=om(h),We=ua(s),fe=dm(s,i)||String((l==null?void 0:l.product_type)||"").toLowerCase()==="concierge"||String((N==null?void 0:N.product_type)||(N==null?void 0:N.plan_type)||"").toLowerCase()==="concierge",Ss=Is(s),Co=(()=>{const n=s==null?void 0:s.rehearsal_invite_expires_at;if(!n)return!1;const d=new Date(n).getTime();return Number.isFinite(d)&&d>Date.now()})(),Eo=(()=>{var d;const n=(d=h==null?void 0:h.cta)==null?void 0:d.type;return n==="start_rehearsal"||n==="retry_rehearsal"})(),sn=Co||Eo||["REHEARSAL_INVITED","START_REHEARSAL","RESUME_SCORED_START_REHEARSAL"].includes(String((s==null?void 0:s.next_step)??"").trim().toUpperCase())||(s==null?void 0:s.can_start_new_rehearsal)===!0,rn=((Wn=Hr((j==null?void 0:j.steps)??[]))==null?void 0:Wn.key)??null,it=!!(G&&G!==rn&&((($n=(Yn=j==null?void 0:j.steps)==null?void 0:Yn.find(n=>n.key===G))==null?void 0:$n.status)==="completed"||G==="resume_screen")),Ze=!fe&&!Ss?cm(s,i,{rehearsalTimeHours:i==null?void 0:i.rehearsal_time_hours}):null,Io=fe?gi(s,j):s?mm(s):null,ks=Bt((j==null?void 0:j.next_step)??(s==null?void 0:s.next_step)),ot=pi(s,j==null?void 0:j.next_step),vs=_t(s),gr=um(s,j==null?void 0:j.next_step),Rs=hm(s,(j==null?void 0:j.next_step)??(s==null?void 0:s.next_step)),dt=ot&&fe&&!Rs&&!vs,_s=s==null?void 0:s.client_decision,To=(_s==null?void 0:_s.status)==="hired"||(_s==null?void 0:_s.status)==="rejected",Br=ku({concierge:s==null?void 0:s.concierge,journey:j}),So=(((Hn=(qn=s==null?void 0:s.concierge)==null?void 0:qn.behavioural_assignment)==null?void 0:Hn.assignment_generation)??1)>=2&&(((Vn=s==null?void 0:s.concierge)==null?void 0:Vn.behavioural_attempts)??0)===0&&((zn=(Kn=s==null?void 0:s.concierge)==null?void 0:Kn.behavioural_assignment)==null?void 0:zn.assignment_source)==="employer_override",pr=!!(N!=null&&N.issued_credential||(An=N==null?void 0:N.steps)!=null&&An.some(n=>{const d=String(n.key||"").toLowerCase();return(d==="recruiter_review"||d==="under_recruiter_review"||d==="shortlisted")&&String(n.substate||"").toLowerCase()==="credential_issued"})),$s=!Rs&&!pr&&!it&&!Br&&(Ru(s,j)||qm(ks)),ct=G?(Gn=j==null?void 0:j.steps)==null?void 0:Gn.find(n=>n.key===G):null,tn=!!(ct&&zr(ct.status)&&Qe(ct.key,ct.type)==="behavioural"),rr=!Rs&&!pr&&!it&&!$s&&!Br&&!((Zn=(Xn=(Qn=s==null?void 0:s.concierge)==null?void 0:Qn.behavioural_assignment)==null?void 0:Xn.assigned_sce
1nario)!=null&&Zn.id)&&(Cu(s,j)||Hm(ks)&&!Br||tn),qs=!Rs&&Ts==="scheduled",Pr=!Rs&&Ts==="outcome",Lo=Zh(s)&&dr(s)!=="auto_invite_pending",an=!(!fe&&zs(s,{product_type:l==null?void 0:l.product_type}))&&(Lo||xm(s)),Do=ws&&!!s&&dr(s)==="ghosted",Bo=ws&&!!s&&dr(s)==="invite_blocked_insufficient_window",mt=Pr||an||Do||Bo||Ud(s)||Vr(s),br=!Rs&&(Ts==="pending"||Ts==="pick_slot"),Po=!Rs&&!br&&!qs&&!Pr&&$m(s).length>0,Uo=!Rs&&!Po&&!!to(s,j),Mo=ks==="OFFER_RECEIVED",qt=(()=>{if(gr)return null;if(Rs)return"NOT_SELECTED";const n=ks;return n==="ON_HOLD"||n==="CONCIERGE_ON_HOLD"?"ON_HOLD":n==="NOT_SELECTED"||n==="CONCIERGE_NOT_SELECTED"?"NOT_SELECTED":qs||Pr?null:Mo?"OFFER_RECEIVED":null})(),Oo=fe||!Ss||sn,ms=Ss?null:V??((We==null?void 0:We.defaultFocusStage)==="Resume rehearsal"?We.r2IsCurrent&&ys?"Rehearsal 2":"Rehearsal 1":We!=null&&We.r2IsCurrent&&!ys?"Work-Style Conversation":(We==null?void 0:We.defaultFocusStage)??null),nn=Ar(ms),ln=Rr(fr,nn);Rr(fr,Dr.includes(Me)?Me:Dr[0]??"rehearsal_1");const Fo=ln.quotaReached,Ae=We&&fe&&!Ss?fm(We,ms,s):null,Se=gm(s),Hs=(s==null?void 0:s.next_step)==="ELIGIBILITY_NOT_MATCHED",Ht=!!(s!=null&&s.has_eligibility_questions),Pe=!Se&&Ss?ro(s):null,he=(Jn=s==null?void 0:s.concierge)==null?void 0:Jn.next_rehearsal,ut=!!(!pr&&!it&&!qs&&!br&&!Pr&&!rr&&!$s&&!dt&&!gr&&(Br||ks==="START_BEHAVIOURAL"||ks==="RETRY_BEHAVIOURAL"||(sl=(el=s==null?void 0:s.concierge)==null?void 0:el.behavioural_assignment)!=null&&sl.assigned_sce
1nario||!(he!=null&&he.waiting_for_scenario)&&(he!=null&&he.assigned_scenario)||!(he!=null&&he.waiting_for_scenario)&&(he!=null&&he.id)&&((rl=he.stage)!=null&&rl.includes("behavioural"))||tn&&(Br||(al=(tl=s==null?void 0:s.concierge)==null?void 0:tl.behavioural_assignment)!=null&&al.assigned_scenario||he!=null&&he.assigned_scenario||he!=null&&he.id))),Vt=ks==="RETRY_BEHAVIOURAL",yr=()=>{var n,d,y,f;return Ii({nextRehearsal:he,primaryActionStep:(h==null?void 0:h.type)==="behavioural"||(h==null?void 0:h.key)==="behavioural"?h:(n=j==null?void 0:j.steps)==null?void 0:n.find(I=>I.type==="behavioural"||I.key==="behavioural"),journeySteps:j==null?void 0:j.steps,enabledRehearsals:i==null?void 0:i.enabled_rehearsals,behaviouralAssignment:(d=s==null?void 0:s.concierge)==null?void 0:d.behavioural_assignment,extraRoleIds:[(y=s==null?void 0:s.selected_rehearsal)==null?void 0:y.id,(f=i==null?void 0:i.selected_rehearsal)==null?void 0:f.id]})},on=ru({enabledRehearsals:i==null?void 0:i.enabled_rehearsals,journeySteps:j==null?void 0:j.steps,extraRoleIds:[(nl=s==null?void 0:s.selected_rehearsal)==null?void 0:nl.id,(ll=i==null?void 0:i.selected_rehearsal)==null?void 0:ll.id]}),tr=pm(s,{enabledRehearsals:i==null?void 0:i.enabled_rehearsals,journeySteps:j==null?void 0:j.steps,extraRoleIds:[(il=s==null?void 0:s.selected_rehearsal)==null?void 0:il.id,(ol=i==null?void 0:i.selected_rehearsal)==null?void 0:ol.id]}),ht=()=>{const{reason:n,code:d}=tr,y=d==="work_style_invite_required"?"Invite pending":d==="behavioural_assignment_missing"?`${Ce} not ready`:`${Ce} locked`;u({title:y,description:n??"Work-Style Conversation is not available yet. Please refresh in a moment.",variant:"destructive"})},vr=(n,d)=>{var I;if(n==="work_style")return"behavioural";if(d&&Bs(d)&&d!=="behavioural")return d;if(d&&wt(d))return"rehearsal_1";const y=(I=j==null?void 0:j.concierge)==null?void 0:I.current_rehearsal_key;if(y&&Bs(y)&&y!=="behavioural")return y;const f=Bm(s);return f==="behavioural"?"rehearsal_1":f},_r=(()=>{var d;if(h!=null&&h.key&&Bs(h.key))return h.key;const n=(d=j==null?void 0:j.concierge)==null?void 0:d.current_rehearsal_key;return n&&Bs(n)?n:Dr.includes(Me)?Me:nn})(),Ls=Rr(fr,_r),Kt=hu(s!=null&&s.rehearsal_start_blocker&&typeof s.rehearsal_start_blocker=="object"?s.rehearsal_start_blocker.message:null),Wo=bi(s,j==null?void 0:j.next_step,{firstRehearsalId:ns}),dn=bm(((dl=s==null?void 0:s.concierge)==null?void 0:dl.stage_status)??((cl=j==null?void 0:j.concierge)==null?void 0:cl.stage_status)),zt=((ml=h==null?void 0:h.cta)==null?void 0:ml.type)==="retry_rehearsal"||zr(h==null?void 0:h.status)&&(h==null?void 0:h.action_required)&&dn!=null&&dn===h.key,ar=(()=>{var d,y;if(Ls.max>0&&Ls.quotaReached)return!0;const n=(d=h==null?void 0:h.cta)==null?void 0:d.type;if(n==="retry_rehearsal"||n==="start_rehearsal"||zt){if(n==="retry_rehearsal"||zt){const f=(h==null?void 0:h.attempts_remaining)??Ls.remaining;return Ls.max===0&&Wo?!1:f<=0}return Ls.quotaReached}if(n==="continue_retry_decision"){const f=(y=s==null?void 0:s.concierge)==null?void 0:y.pending_decision,I=Number((f==null?void 0:f.attempts_remaining)??((f==null?void 0:f.attempts_max)!=null&&(f==null?void 0:f.attempts_used)!=null?f.attempts_max-f.attempts_used:NaN));return Number.isFinite(I)&&I>0?!1:Ls.quotaReached}return ot?!1:fe?Ls.quotaReached:Fo})(),Yo=ym(s,Dr,K),$o=p.status==="expired"||xu((i==null?void 0:i.application_closes_at)??(i==null?void 0:i.closes_at)??p.deadline),qo=(s==null?void 0:s.next_step)==="APPLY_REQUIRED"&&Yt.length===0,nr=!Kt&&(qo||bi(s,j==null?void 0:j.next_step,{firstRehearsalId:ns})),Ho=vm(j,fe,s),xt=s==null?void 0:s.rehearsal_start_blocker,lr=xt&&typeof xt=="object"&&((ul=xt.message)==null?void 0:ul.trim())||"",At=wu(xt),Vo=Kt?pu:"Rehearsal unavailable",cn=Kt?gu:lr||"You cannot start a new rehearsal for this application right now.",ft=((hl=h==null?void 0:h.cta)==null?void 0:hl.type)==="retry_rehearsal"||zt,Gt=Md(s),Qt=(s==null?void 0:s.can_start_new_rehearsal)===!1&&!Gt,Ko=Qt&&!!lr&&!mt&&!vs,zo=!!Ze&&!zs(s,{product_type:l==null?void 0:l.product_type}),mn=_r!=="behavioural"&&yi(s,{stageKey:_r,journeyNextStep:j==null?void 0:j.next_step}),Ur=ar||!!(Se!=null&&Se.buttonDisabled)||!!(Pe!=null&&Pe.buttonDisabled)||Qt&&!Pe&&!Se&&!vs&&!mn&&!zs(s,{product_type:l==null?void 0:l.product_type})||!nr&&!ft&&!Pe&&!Se&&!vs&&!mn&&!zs(s,{product_type:l==null?void 0:l.product_type}),Ao=A?["eligibility","resume"].includes(Qe(A)):!1,Go=!it&&!Rs&&!ot&&!qt&&!gr&&!rr&&!$s&&
1!ut&&!br&&!qs&&!Ao&&!Ei(ks)&&!Vm(ks)&&!Ho&&(!!Se||!!Pe||!!cs||!!Ze&&!Ss||!!(Ae!=null&&Ae.buttonLabel)&&nr||_m(h)&&nr),Qo=ar?[lr,At].filter(Boolean).join(" ")||`Maximum attempts reached. You have used all ${Ls.max} allowed attempts for ${vi(_r,h==null?void 0:h.title)}.`:Pe!=null&&Pe.buttonDisabled||nr?"":cn;(xl=i==null?void 0:i.enabled_rehearsals)!=null&&xl.length||i!=null&&i.selected_rehearsal;const jr=!Ss;ln.used>0;const ts=async(n,d,y,f)=>{var ce,Le,oe,ke,Fe;const I=f.kind==="work_style",H=I?"behavioural":f.stageKey==="behavioural"?"rehearsal_1":f.stageKey,$=I?`Could not start ${Ce}`:"Could not start rehearsal";let z=Nr(d),M=y;if(I){const te=yr();if(!te.rehearsalId||tu(te.rehearsalId,on)){u({title:`${Ce} not ready`,description:"Work-Style is not linked to a separate rehearsal yet. Please refresh or ask the hiring team to re-assign the scenario.",variant:"destructive"});return}z=te.rehearsalId,M=te.rehearsalTitle||y}else{const te=((ce=j==null?void 0:j.steps)==null?void 0:ce.find(Re=>Re.key===A))??null,Q=Er({selectedStep:te,primaryActionStep:(h==null?void 0:h.type)==="behavioural"||(h==null?void 0:h.key)==="behavioural"?null:h,nextRehearsal:he,enabledRehearsals:i==null?void 0:i.enabled_rehearsals,selectedRehearsalId:(Le=s==null?void 0:s.selected_rehearsal)==null?void 0:Le.id,overrideRehearsalId:z,fallbackRehearsalId:ns||((oe=i==null?void 0:i.selected_rehearsal)==null?void 0:oe.id)});Q.rehearsalId&&(z=Q.rehearsalId,M=Q.rehearsalTitle||y)}if(!z){u({title:$,description:"A valid rehearsal could not be resolved. Please refresh and try again.",variant:"destructive"});return}if(I&&on.has(z)){u({title:`${Ce} not ready`,description:"Work-Style is not linked to a separate rehearsal yet. Please refresh or ask the hiring team to re-assign the scenario.",variant:"destructive"});return}if(!I){const te=yr().rehearsalId;if(te&&te===z){u({title:"Could not start rehearsal",description:"This step is not linked to a role rehearsal. Use Work-Style Conversation if it is unlocked.",variant:"destructive"});return}}const se=Rr(fr,H);if(se.max>0&&se.used>=se.max){u({title:"No attempts remaining",description:`You have used all ${se.max} attempts for this stage.`,variant:"destructive"});return}if(I&&!tr.allowed){ht();return}if(!I){const te=Rr(fr,H),Q=te.max>0&&te.remaining<=0;if(jt(s)||ji(s)&&Q){u({title:"Rehearsal unavailable",description:"Role rehearsal attempts are complete. Use Work-Style Conversation if your hiring team has unlocked it.",variant:"destructive"});return}}try{mu.primeFromGesture()}catch{}U(!0);const Ne=au();try{const te=await Ld({hiring_link_slug:n,rehearsal_id:z,is_practice:!1},async()=>!(await nu(Ne)).active),Q=te.attempt_id!=null?String(te.attempt_id):te.id!=null?String(te.id):"";if(!Q){u({title:$,description:"No attempt was returned. Please try again.",variant:"destructive"});return}const Re=(Fe=(ke=i==null?void 0:i.enabled_rehearsals)==null?void 0:ke.find(hs=>String(hs.id)===z))==null?void 0:Fe.target_interaction_seconds,De=iu({status:s,targetInteractionSeconds:Re,explicitSeconds:I?ou(s):null});m({attempt_id:Q,selected_rehearsal_id:z}),a(lu(H),{state:{fromInvite:!0,fromRealApi:!0,attemptId:Q,inviteSlug:n,rehearsalId:z,rehearsalTitle:M,rehearsalDurationSeconds:De,jobId:$t??(l==null?void 0:l.job_id),rehearsalStageKey:H}})}catch(te){const Q=Dd(te),Re=I&&/rehearsal/i.test(Q.title)?Q.title.replace(/rehearsal/gi,Ce):Q.title;u({title:Re,description:Q.description,variant:"destructive"});const De=_a(te).responseBody;(De&&typeof De=="object"?String(De.code??""):"")==="max_stage_attempts_reached"&&(p!=null&&p.id)&&Gs(p.id).then(js=>{var xs;q(js),Kr(p.id,js,{applicationUpdatedAt:l==null?void 0:l.updated_at,hasPassedResume:!Is(js),rehearsalCount:(xs=i==null?void 0:i.enabled_rehearsals)==null?void 0:xs.length,enabledRehearsals:i==null?void 0:i.enabled_rehearsals}).then(L)})}finally{U(!1)}};Os.current=()=>{if(!tr.allowed){ht();return}const n=de||ze,{rehearsalId:d,rehearsalTitle:y}=yr();if(!n||!d){u({title:`${Ce} not ready`,description:"Your assigned scenario is not linked to this application yet. Please refresh in a moment or ask the hiring team to re-assign.",variant:"destructive"});return}ts(n,d,y,{kind:"work_style",stageKey:"behavioural"})};const un=()=>{Pt(!0),a("/practice")},qe=bt(N?qr(N,s,{product_type:l==null?void 0:l.product_type,job_product_type:(i==null?void 0:i.product_type)??(l==null?void 0:l.product_type)}):null,{productTypeHint:(l==null?void 0:l.product_type)??(fe?"concierge":null),isVerifiedEmail:s==null?void 0:s.is_verified_email,requiresVerification:s==null?void 0:s.requires_verification,nextStep:s==null?void 0:s.next_step,interviewActive:Gr(s),resumeScore:(s==null?void 0:s.resume_score)??null}),{candidateSteps:Mr,hiringSteps:gt}=Wd(qe),ir=li(Mr,A)??li(gt,A),x=qe.steps.find(n=>n.key===A)??null,ee=Qe(A,x==null?void 0:x.type);(gl=(fl=[...Mr,...gt].find(n=>n.key===A))==null?void 0:fl.title)!=null&&gl.trim();const Cs=!!(x&&(_i(x.status)||A===(((pl=Hr(qe.steps))==null?void 0:pl.key)??rn))),hn=n=>{$d(n.status,n.skipReason)&&_e(n.key)},Xt=ee==="resume",Xo=(s==null?void 0:s.eligibility_screen_status)==="passed"||qe.steps.some(n=>Qe(n.key,n.type)==="eligibility"&&n.status==="completed"),Zo=Xt||ee==="eligibility"&&Xo||!!(p!=null&&p.id&&Xa&&Xa===p.id),Or=qe.steps.find(n=>Qe(n.key,n.type)==="resume"),Jo=(Or==null?void 0:Or.status)==="completed",xn=Or?qe.steps.findIndex(n=>n.key===Or.key):-1,ed=xn>=0&&qe.steps.slice(xn+1).some(n=>_i(n.status)||n.status==="completed"||n.status==="not_selected"),Ds=(()=>
1{if(ee==="behavioural")return"behavioural";const n=A||"";return Bs(n)?n:n==="rehearsal"?"rehearsal_1":Me})(),Oe=Rr(fr,Ds),fn=yi(s,{stageKey:Ds,journeyNextStep:j==null?void 0:j.next_step}),gn=Yo[Ds]??[],sd=fe?gi(s,j,Ds):null,Fr=fe?Oe.remaining:(x==null?void 0:x.attempts_remaining)??(x==null?void 0:x.remaining)??Oe.remaining,rd=!fe&&ee==="rehearsal"&&(x==null?void 0:x.status)==="completed"&&jm(s,qe,{product_type:l==null?void 0:l.product_type})&&Fr>0,Vs=wm(s,qe,{product_type:l==null?void 0:l.product_type})||Nm(s),Wr=(bl=j==null?void 0:j.concierge)==null?void 0:bl.bypass,Yr=ee==="rehearsal"&&(x==null?void 0:x.status)==="skipped"&&(x==null?void 0:x.skip_reason)==="candidate_skip"||Ri(Wr)||Ri((yl=s==null?void 0:s.concierge)==null?void 0:yl.bypass),us=((j==null?void 0:j.steps)??[]).find(n=>String((n==null?void 0:n.key)||"").startsWith("rehearsal")),pn=Yr||String((us==null?void 0:us.status)||"")==="skipped"?Yr||(us==null?void 0:us.skip_reason)==="candidate_skip"?"skipped_by_candidate":"advanced_without_rehearsal":"recorded",td=!!(s!=null&&s.has_eligibility_questions)||((j==null?void 0:j.steps)??[]).some(n=>String((n==null?void 0:n.key)||"").startsWith("eligibility")),bn=Ci(Wr)||Ci((vl=s==null?void 0:s.concierge)==null?void 0:vl.bypass)||(us==null?void 0:us.skip_reason)==="candidate_skip"&&String((us==null?void 0:us.status)||"").toLowerCase()==="skipped"&&(Wr==null?void 0:Wr.do_over_eligible)!==!1&&((jl=(_l=s==null?void 0:s.concierge)==null?void 0:_l.bypass)==null?void 0:jl.do_over_eligible)!==!1,Zt=fe&&ee==="rehearsal"&&Cs&&Oe.used===0&&Oe.remaining>0&&!jt(s)&&!Oe.quotaReached&&!dt,yn=fe&&ee==="rehearsal"&&!Cs&&(x==null?void 0:x.status)==="completed"&&Fr>0&&nr,$r=!Cs&&!Vs&&(x==null?void 0:x.status)==="completed"&&Fr>0&&(yn||(s==null?void 0:s.can_start_new_rehearsal)!==!1&&(((wl=x==null?void 0:x.cta)==null?void 0:wl.type)==="retry_rehearsal"||rd))&&!!((Nl=x.cta)!=null&&Nl.rehearsal_id||x.rehearsal_id||(kl=s==null?void 0:s.selected_rehearsal)!=null&&kl.id||Oe.remaining>0),ad=$r?yn?"Start rehearsal":Fr===1?"Run another rehearsal (1 left)":`Run another rehearsal (${Fr} left)`:null,vn={};for(const n of(s==null?void 0:s.rehearsal_attempts_history)??[])vn[n.attempt_id]=n.created_at;const nd=()=>{var d;const n=((d=qe.steps.find(y=>Qe(y.key,y.type)==="resume"))==null?void 0:d.key)??"resume_under_review";_e(n)},ld=(n,d,y)=>{var Q,Re,De,hs,js,xs,Ks;const f=y??s,I=n?qr(n,f,{product_type:(l==null?void 0:l.product_type)??(fe?"concierge":null)}):null,H=bt(I??n,{productTypeHint:(l==null?void 0:l.product_type)??(fe?"concierge":null),isVerifiedEmail:f==null?void 0:f.is_verified_email,requiresVerification:f==null?void 0:f.requires_verification,nextStep:f==null?void 0:f.next_step,interviewActive:Gr(f),resumeScore:(f==null?void 0:f.resume_score)??null}),$=String(((Q=f==null?void 0:f.concierge)==null?void 0:Q.stage_status)??"").toLowerCase(),z=String(((Re=I??n)==null?void 0:Re.current_step)??"").toLowerCase();if(Vr(f)){const ue=((De=H.steps.find(Je=>String(Je.key||"").toLowerCase().includes("resume")||Qe(Je.key,Je.type)==="resume"))==null?void 0:De.key)??null;if(ue)return Ue.current=ue,ue}const M=H.steps.find(ue=>Qe(ue.key,ue.type)==="interview"||ue.type==="interview"||String(ue.key).includes("interview")),se=!!(M!=null&&M.locked)||String((M==null?void 0:M.status)??"").toLowerCase()==="locked",Ne=jt(f),ce=String((M==null?void 0:M.stage_status)??"").trim().toLowerCase()==="instant_screening_offered"||String(((hs=M==null?void 0:M.cta)==null?void 0:hs.type)??"").toLowerCase()==="pick_interview_slot"||z.includes("interview"),Le=H.steps.find(ue=>ue.key==="recruiter_review"||ue.key==="review_next_steps"||Qe(ue.key,ue.type)==="recruiter_review"),oe=String((Le==null?void 0:Le.status)??"").trim().toLowerCase()==="completed",ke=!oe&&!ce&&(z.includes("recruiter_review")||z==="review_next_steps"||!Ne&&($==="with_hiring_team"||$.includes("recruiter_review")||$==="exhausted_attempts_review"));if(ce&&M&&!se)return Ue.current=M.key,M.key;if(oe&&M&&!se){const ue=String(M.status??"").trim().toLowerCase();if(ue==="current"||ue==="not_started"||ue==="in_progress"||ue==="under_review"||z.includes("interview"))return Ue.current=M.key,M.key}if(($.includes("interview")||$==="offer_received")&&!ke&&!se){const ue=(M==null?void 0:M.key)??null;if(ue)return Ue.current=ue,ue}if(ke){const ue=(Le==null?void 0:Le.key)??null;if(ue)return Ue.current=ue,ue}if($.startsWith("behavioural")||$.includes("work_style")){const ue=((js=H.steps.find(Je=>Je.type==="behavioural"||Je.key==="behavioural"||Je.key==="behavioural_assessment"))==null?void 0:js.key)??null;if(ue)return Ue.current=ue,ue}if($.startsWith("rehearsal_")||z==="rehearsal"||z.startsWith("rehearsal")){const ue=((xs=H.steps.find(Je=>Qe(Je.key,Je.type)==="rehearsal"||Je.type==="rehearsal"||Je.key==="rehearsal"||String(Je.key).startsWith("rehearsal_")))==null?void 0:xs.key)??null;if(ue)return Ue.current=ue,ue}const Fe=((Ks=Hr(H.steps))==null?void 0:Ks.key)??null,te=Ue.current;return Ue.current=Fe,qd(H.steps,d,te)},ls=async()=>{var n;if(p!=null&&p.id)try{const d=await Gs(p.id);q(d);const y=await Kr(p.id,d,{applicationUpdatedAt:l==null?void 0:l.updated_at,hasPassedResume:!Is(d),rehearsalCount:(n=i==null?void 0:i.enabled_rehearsals)==null?void 0:n.length,enabledRehearsals:i==null?void 0:i.enabled_rehearsals});L(y);const f=await ta(p.id).catch(()=>null);P(f),_e(I=>{var z,M,se,Ne,ce,Le;if(Vr(d))return((M=(z=f==null?void 0:f.steps)==null?void 0:z.find(ke=>String(ke.key||"").toLowerCase().includes("resume")))==null?void 0:M.key)??((Ne=(se
1=y==null?void 0:y.steps)==null?void 0:se.find(ke=>String(ke.key||"").toLowerCase().includes("resume")))==null?void 0:Ne.key)??"resume_under_review";const H=ws?dr(d):null;if((["RESUME_SCORED_START_REHEARSAL","START_REHEARSAL","REHEARSAL_INVITED"].includes(d.next_step||"")||["rehearsal_invited","rehearsal_in_progress","fast_tracked"].includes(String(d.batching_application_status||"").toLowerCase())||String(d.resume_score_band||"").toLowerCase()==="fast_track"||H==="fast_lane_invited"||H==="auto_invited"||H==="bypassed_by_client")&&f){const oe=qr(f,d,{product_type:(l==null?void 0:l.product_type)??(fe?"concierge":null)}),ke=bt(oe,{productTypeHint:(l==null?void 0:l.product_type)??(fe?"concierge":null),isVerifiedEmail:d==null?void 0:d.is_verified_email,requiresVerification:d==null?void 0:d.requires_verification,nextStep:d==null?void 0:d.next_step,interviewActive:Gr(d),resumeScore:(d==null?void 0:d.resume_score)??null}),Fe=((ce=ke.steps.find(te=>zr(te.status)&&Qe(te.key,te.type)==="rehearsal"))==null?void 0:ce.key)??((Le=ke.steps.find(te=>Qe(te.key,te.type)==="rehearsal"))==null?void 0:Le.key);if(Fe)return Fe}return ld(f,I,d)})}catch{}};Js.current=ls;const id=async()=>{var n,d,y,f;if(p!=null&&p.id){if(Tm(s)){u({title:"Not moving forward",description:"You've used all attempts for this stage. You're not moving forward from this score."}),await ls();return}if(!Sm(s)){await ls(),u({title:"Application updated",description:"Your status was refreshed. Use the next step shown on this page."});return}D(!0);try{const I=await pt(p.id,"continue");if(I.concierge&&s&&q({...s,concierge:{...s.concierge,...I.concierge,stage_status:I.concierge.stage_status??I.stage_status??((n=s.concierge)==null?void 0:n.stage_status),next_rehearsal:I.concierge.next_rehearsal??((d=s.concierge)==null?void 0:d.next_rehearsal),pending_decision:I.concierge.pending_decision??null}}),(f=(y=I.concierge)==null?void 0:y.next_rehearsal)!=null&&f.id&&Lm(I.concierge)){const H=de||ze;if(H){const $=I.concierge.next_rehearsal,z=wt($.stage)?"work_style":"role_rehearsal";await ts(H,Nr($.rehearsal_id,$.id),$.title??"Next rehearsal",{kind:z,stageKey:vr(z,$.stage)})}return}await ls();return}catch(I){if(Ni(I)){await ls(),u({title:"Already updated",description:"This decision was already processed. Your page has been refreshed - use the next step shown."});return}u({title:"Could not continue",description:kt(I),variant:"destructive"})}finally{D(!1)}}},Jt=n=>{var I,H,$,z,M,se,Ne;const d=((I=j==null?void 0:j.steps)==null?void 0:I.find(ce=>ce.key===A))??x??null;if(ee==="behavioural"||(d==null?void 0:d.type)==="behavioural"||(d==null?void 0:d.key)==="behavioural")return Ii({nextRehearsal:(n==null?void 0:n.nextRehearsal)??he,primaryActionStep:(h==null?void 0:h.type)==="behavioural"||(h==null?void 0:h.key)==="behavioural"?h:(H=j==null?void 0:j.steps)==null?void 0:H.find(ce=>ce.type==="behavioural"||ce.key==="behavioural"),journeySteps:j==null?void 0:j.steps,enabledRehearsals:i==null?void 0:i.enabled_rehearsals,behaviouralAssignment:($=s==null?void 0:s.concierge)==null?void 0:$.behavioural_assignment,extraRoleIds:[(z=s==null?void 0:s.selected_rehearsal)==null?void 0:z.id,(M=i==null?void 0:i.selected_rehearsal)==null?void 0:M.id]});const f=(h==null?void 0:h.type)==="behavioural"||(h==null?void 0:h.key)==="behavioural"?null:h;return Er({selectedStep:d,primaryActionStep:f,nextRehearsal:(n==null?void 0:n.nextRehearsal)??he,enabledRehearsals:i==null?void 0:i.enabled_rehearsals,selectedRehearsalId:((se=s==null?void 0:s.selected_rehearsal)==null?void 0:se.id)??((Ne=i==null?void 0:i.selected_rehearsal)==null?void 0:Ne.id),overrideRehearsalId:n==null?void 0:n.overrideRehearsalId,fallbackRehearsalId:ns})},Es=async(n,d)=>{var ce,Le,oe,ke,Fe,te,Q;if(!(p!=null&&p.id))return;const y=de||ze,f=Jt({overrideRehearsalId:n});let I=f.rehearsalId;const H=d??f.rehearsalTitle,$=ee==="behavioural"||(x==null?void 0:x.type)==="behavioural"||(x==null?void 0:x.key)==="behavioural"||wt((Le=(ce=s==null?void 0:s.concierge)==null?void 0:ce.pending_decision)==null?void 0:Le.stage)||wt(he==null?void 0:he.stage),z={kind:$?"work_style":"role_rehearsal",stageKey:vr($?"work_style":"role_rehearsal",(x==null?void 0:x.key)??((ke=(oe=s==null?void 0:s.concierge)==null?void 0:oe.pending_decision)==null?void 0:ke.stage)??(he==null?void 0:he.stage)??_r)};if(!y||!I){u({title:"Could not start rehearsal",description:"Rehearsal configuration is missing. Please refresh and try again.",variant:"destructive"});return}const M=km(s),se=(x==null?void 0:x.attempts_remaining)??(x==null?void 0:x.remaining)??null,Ne=(x==null?void 0:x.status)==="completed"&&(((Fe=x==null?void 0:x.cta)==null?void 0:Fe.type)==="retry_rehearsal"||fe&&se!=null&&se>0||!fe&&Rm(s,{product_type:l==null?void 0:l.product_type}))&&(se==null||se>0);if(!M){if(!fe&&zs(s,{product_type:l==null?void 0:l.product_type})){await ts(y,I,H,z);return}if(Ne||Cm(s,j==null?void 0:j.next_step)){await ts(y,I,H,z);return}await ls();const Re=Em(s),De=Im(s),hs=s==null?void 0:s.rehearsal_invite_expires_at,js=hs?new Date(hs).getTime()<=Date.now():!1,xs=s==null?void 0:s.rehearsal_start_blocker,Ks=xs&&typeof xs=="object"?((te=xs.message)==null?void 0:te.trim())??"":"";Re>=De&&De>0?u({title:"No attempts remaining",description:`You have used all ${De} attempts for this stage.`,variant:"destructive"}
1):u(js?{title:"Invite expired",description:"Your rehearsal invite window has closed. Contact the hiring team to request a new one.",variant:"destructive"}:Ks?{title:"Rehearsal unavailable",description:Ks,variant:"destructive"}:{title:"Application updated",description:"Your status was refreshed. Use the next step shown on this page."});return}D(!0);try{const Re=await pt(p.id,"retry"),De=Jt({nextRehearsal:((Q=Re.concierge)==null?void 0:Q.next_rehearsal)??he,overrideRehearsalId:n});if(na(De.rehearsalId)&&(I=De.rehearsalId),D(!1),!na(I)){await ls(),u({title:"Could not start rehearsal",description:"Rehearsal configuration is missing. Please refresh and try again.",variant:"destructive"});return}await ts(y,I,H,z)}catch(Re){if(Ni(Re)){await ls();const De=Jt({overrideRehearsalId:n});na(De.rehearsalId)&&await ts(y,De.rehearsalId,De.rehearsalTitle,z);return}u({title:"Could not retry",description:kt(Re),variant:"destructive"})}finally{D(!1)}},od=()=>{var d;if(Ze&&zs(s,{product_type:l==null?void 0:l.product_type})){Es();return}if(fe&&_t(s)){Es();return}const n=h==null?void 0:h.cta;if((n==null?void 0:n.type)==="retry_rehearsal"){Es(n.rehearsal_id??void 0,(h==null?void 0:h.rehearsal_title)??(h==null?void 0:h.title));return}if(fe&&pi(s,j==null?void 0:j.next_step)&&!_t(s)){u({title:"Decision required",description:"Choose Continue or Retry before starting another rehearsal."});return}if((n==null?void 0:n.type)==="start_rehearsal"){if(fe&&(h==null?void 0:h.type)!=="behavioural"&&!Dm(s==null?void 0:s.concierge)&&!n.rehearsal_id){u({title:"Rehearsal not ready",description:"Complete your Continue or Retry decision first, then try again."});return}const y=de||ze;if((h==null?void 0:h.type)==="behavioural"||(h==null?void 0:h.key)==="behavioural"){const{rehearsalId:z,rehearsalTitle:M}=yr();y&&z?ts(y,z,M,{kind:"work_style",stageKey:"behavioural"}):y&&!z&&u({title:`${Ce} not ready`,description:"Your assigned scenario is not linked to this application yet. Please refresh in a moment or ask the hiring team to re-assign.",variant:"destructive"});return}const{rehearsalId:I,rehearsalTitle:H}=Er({selectedStep:h,primaryActionStep:h,nextRehearsal:he,enabledRehearsals:i==null?void 0:i.enabled_rehearsals,selectedRehearsalId:(d=s==null?void 0:s.selected_rehearsal)==null?void 0:d.id}),$=Nr(n.rehearsal_id,h==null?void 0:h.rehearsal_id,I)||I;y&&$&&ts(y,$,(h==null?void 0:h.rehearsal_title)??(h==null?void 0:h.title)??H??"Rehearsal",{kind:"role_rehearsal",stageKey:vr("role_rehearsal",(h==null?void 0:h.key)??_r)});return}or()},or=()=>{var $,z,M,se,Ne,ce,Le,oe,ke,Fe,te,Q,Re,De,hs,js,xs,Ks,ue,Je,ea,Gl;const n=de||ze;if(!Xe&&!T||!n)return;if(ar||Oe.quotaReached||Oe.remaining<=0){u({title:"No attempts remaining",description:`You have used all ${Oe.max||Ls.max||3} attempts for this stage.`,variant:"destructive"});return}if(fe&&_t(s)){Es();return}if(!fe&&zs(s,{product_type:l==null?void 0:l.product_type})){const He=Nt(i==null?void 0:i.enabled_rehearsals,(i==null?void 0:i.selected_rehearsal)??null),{rehearsalId:Ge,rehearsalTitle:wr}=Er({selectedStep:x,primaryActionStep:h,nextRehearsal:($=s==null?void 0:s.concierge)==null?void 0:$.next_rehearsal,enabledRehearsals:He,selectedRehearsalId:(z=s==null?void 0:s.selected_rehearsal)==null?void 0:z.id,fallbackRehearsalId:((M=i==null?void 0:i.selected_rehearsal)==null?void 0:M.id)??((se=He[0])==null?void 0:se.id)});if(!Ge){u({title:"Could not start rehearsal",description:"Rehearsal configuration is missing. Please refresh and try again.",variant:"destructive"});return}o({invite_code:n,slug:n,job_id:p.id,company:p.company,jobTitle:p.jobTitle,location:p.location,resume_uploaded:!0,resume_score:null,resume_passed:!0,rehearsal_required_count:1,enabled_rehearsals:He,rehearsal_optional_visible:!1,rehearsal_completed:!1,submission_status:null,selected_rehearsal_id:Ge}),ts(n,Ge,wr,{kind:"role_rehearsal",stageKey:vr("role_rehearsal",(x==null?void 0:x.key)??Ds)});return}if(((Ne=h==null?void 0:h.cta)==null?void 0:Ne.type)==="retry_rehearsal"||((ce=x==null?void 0:x.cta)==null?void 0:ce.type)==="retry_rehearsal"){Es(((Le=x==null?void 0:x.cta)==null?void 0:Le.rehearsal_id)??((oe=h==null?void 0:h.cta)==null?void 0:oe.rehearsal_id)??void 0,(x==null?void 0:x.rehearsal_title)??(x==null?void 0:x.title)??(h==null?void 0:h.rehearsal_title)??(h==null?void 0:h.title));return}if(fe&&(We!=null&&We.r1RetryAvailable)&&We.r1AttemptsRemaining>0&&(Ae==null?void 0:Ae.buttonLabel)==="Retry rehearsal"){Es();return}const d=(ke=s==null?void 0:s.concierge)==null?void 0:ke.next_rehearsal,y=!!(s!=null&&s.has_in_flight_rehearsal_attempt);if(!Ss&&fe&&y&&!(We!=null&&We.r2IsCurrent)&&ms==="Rehearsal 1"){const He=(d==null?void 0:d.stage)==="rehearsal_1"&&d.id?d.id:ns,Ge=(d==null?void 0:d.stage)==="rehearsal_1"&&d.title?d.title:(es==null?void 0:es.title)??((Fe=i==null?void 0:i.selected_rehearsal)==null?void 0:Fe.title)??"Rehearsal 1";
1if(!He){a(`/apply/${n}/choose-rehearsal`);return}o({invite_code:n,slug:n,job_id:p.id,company:p.company,jobTitle:p.jobTitle,location:p.location,resume_uploaded:!0,resume_score:null,resume_passed:!0,rehearsal_required_count:2,enabled_rehearsals:(i==null?void 0:i.enabled_rehearsals)||[],rehearsal_optional_visible:!1,rehearsal_completed:!1,submission_status:null,selected_rehearsal_id:ai(He)}),ts(n,ai(He),Ge,{kind:"role_rehearsal",stageKey:"rehearsal_1"});return}if(o({invite_code:n,slug:n,job_id:p.id,company:p.company,jobTitle:p.jobTitle,location:p.location,resume_uploaded:jr,resume_score:null,resume_passed:jr?!0:null,rehearsal_required_count:1,enabled_rehearsals:Nt(i==null?void 0:i.enabled_rehearsals,(i==null?void 0:i.selected_rehearsal)??null),rehearsal_optional_visible:!1,rehearsal_completed:!1,submission_status:null,selected_rehearsal_id:((te=i==null?void 0:i.selected_rehearsal)==null?void 0:te.id)??null}),jr&&new Set(["RESUME_SCORED_START_REHEARSAL","START_REHEARSAL","REHEARSAL_INVITED","SCORED","REHEARSAL_IN_PROGRESS","VERIFYING","UPLOAD_FINAL_MEDIA"]).has((s==null?void 0:s.next_step)||"")){if(!du(i)&&!((Q=s==null?void 0:s.selected_rehearsal)!=null&&Q.id)&&!Nr((Re=x==null?void 0:x.cta)==null?void 0:Re.rehearsal_id,x==null?void 0:x.rehearsal_id,(h==null?void 0:h.type)!=="behavioural"?(De=h==null?void 0:h.cta)==null?void 0:De.rehearsal_id:null,(h==null?void 0:h.type)!=="behavioural"?h==null?void 0:h.rehearsal_id:null)){u({title:"Rehearsal not assigned",description:"This role does not have an assigned rehearsal yet. Please try again later or contact support.",variant:"destructive"});return}const He=Nt(i==null?void 0:i.enabled_rehearsals,(i==null?void 0:i.selected_rehearsal)??null),{rehearsalId:Ge,rehearsalTitle:wr}=Er({selectedStep:x,primaryActionStep:h,nextRehearsal:(hs=s==null?void 0:s.concierge)==null?void 0:hs.next_rehearsal,enabledRehearsals:He,selectedRehearsalId:(js=s==null?void 0:s.selected_rehearsal)==null?void 0:js.id,fallbackRehearsalId:((xs=i==null?void 0:i.selected_rehearsal)==null?void 0:xs.id)??(He.length===1?(Ks=He[0])==null?void 0:Ks.id:null)});if(Ge){ts(n,Ge,wr,{kind:"role_rehearsal",stageKey:vr("role_rehearsal",(x==null?void 0:x.key)??Ds)});return}a(`/apply/${n}/choose-rehearsal`);return}{const He=Nt(i==null?void 0:i.enabled_rehearsals,(i==null?void 0:i.selected_rehearsal)??null),{rehearsalId:Ge,rehearsalTitle:wr}=Er({selectedStep:x,primaryActionStep:h,nextRehearsal:(ue=s==null?void 0:s.concierge)==null?void 0:ue.next_rehearsal,enabledRehearsals:He,selectedRehearsalId:(Je=s==null?void 0:s.selected_rehearsal)==null?void 0:Je.id,fallbackRehearsalId:((ea=i==null?void 0:i.selected_rehearsal)==null?void 0:ea.id)??((Gl=He[0])==null?void 0:Gl.id)});if(jr&&!Ge&&Zt){u({title:"Rehearsal being set up",description:"Your rehearsal is being configured. Please refresh in a moment and try again."});return}if(jr&&Ge){const Ql=Math.max(Oe.used,Number((s==null?void 0:s.rehearsal_attempts_used)??0),((s==null?void 0:s.rehearsal_attempts_history)??[]).length);if(fe&&Ql>0){Es(Ge,wr);return}o({invite_code:n,slug:n,job_id:p.id,company:p.company,jobTitle:p.jobTitle,location:p.location,resume_uploaded:!0,resume_score:null,resume_passed:!0,rehearsal_required_count:fe?2:1,enabled_rehearsals:He,rehearsal_optional_visible:!1,rehearsal_completed:!1,submission_status:null,selected_rehearsal_id:Ge}),ts(n,Ge,wr,{kind:"role_rehearsal",stageKey:vr("role_rehearsal",(x==null?void 0:x.key)??Ds)});return}
1if(jr){a(`/apply/${n}/choose-rehearsal`);return}}{const He=((s==null?void 0:s.next_step)??"").trim(),Ge=Ht&&He==="ELIGIBILITY_REQUIRED"?{initialStep:"eligibility"}:Ht&&He==="ELIGIBILITY_NOT_MATCHED"?{initialStep:"eligibility_not_matched"}:void 0;a(`/apply/${n}`,Ge?{state:Ge}:void 0)}},dd=()=>{!(p!=null&&p.id)||$e||Xs(!0)},cd=async()=>{if(!(!(p!=null&&p.id)||$e)){mr(!0);try{await pt(p.id,"skip_rehearsal"),Xs(!1),await ls()}catch(n){u({title:"Could not skip rehearsal",description:kt(n),variant:"destructive"})}finally{mr(!1)}}},_n=async()=>{if(!(!(p!=null&&p.id)||rs)){Ms(!0);try{await pt(p.id,"undo_skip_rehearsal"),await ls()}catch(n){u({title:"Could not restore rehearsal",description:kt(n),variant:"destructive"})}finally{Ms(!1)}}},jn=!Vs&&(sn||!Ur&&!!(de||ze)||$r||vs||fn),wn=(i==null?void 0:i.safety_rehearsal_locked)===!0,md=ee==="rehearsal"&&!Vs&&!wn&&!Yr&&(x==null?void 0:x.status)!=="locked"&&(jn||gn.length>0)?dd:void 0;return e.jsxs(sa,{layout:"job-entry",children:[e.jsx(xd,{items:[{label:"My Profile",to:"/candidate/profile"},{label:"Applications",to:"/applications"},{label:p.jobTitle}]}),e.jsxs("div",{className:"space-y-6",children:[No?e.jsx(Qh,{block:fu(ko),jobTitle:p.jobTitle}):null,e.jsxs("section",{className:"space-y-4 rounded-xl border border-border/70 bg-card p-5 shadow-sm",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-3",children:Za?e.jsxs(je,{className:"w-fit gap-1.5 rounded-full bg-[hsl(var(--brand-navy))] font-semibold text-[hsl(var(--brand-cream))] hover:bg-[hsl(var(--brand-navy))]",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[hsl(var(--brand-cream))]"}),"Hired"]}):Ja?e.jsxs(je,{className:"w-fit gap-1.5 rounded-full bg-slate-600 font-semibold text-white hover:bg-slate-600",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-white"}),"Not selected"]}):(()=>{const n=String((R==null?void 0:R.funnel_stage_label)??(N==null?void 0:N.funnel_stage_label)??"").trim(),d=qe.compactSteps.find($=>$.title==="Applied"||$.key==="eligibility_screen"||$.key==="eligibility"||$.key==="resume_screen"||$.key==="resume"),y=/^applied$/i.test(n)&&(d!=null&&d.statusLabel)?String(d.statusLabel).trim():null,f=qe.compactSteps.find($=>/rehearsal/i.test($.key)||$.type==="rehearsal"||$.title==="Rehearsed"),I=/^rehearsed$/i.test(n)&&((f==null?void 0:f.status)==="skipped"||/skip/i.test(String((f==null?void 0:f.statusLabel)??"")))?"Skipped":/^rehearsed$/i.test(n)&&(f!=null&&f.statusLabel)?String(f.statusLabel).trim():null,H=y||I||n;return H?e.jsxs(je,{variant:"secondary",className:"w-fit gap-1.5 rounded-full border-[hsl(var(--brand-navy))]/20 bg-[hsl(var(--brand-cream))] font-medium text-[hsl(var(--brand-navy))]",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[hsl(var(--brand-navy))]"}),H]}):ex.has(p.status)?null:e.jsxs(je,{variant:"secondary",className:"w-fit gap-1.5 rounded-full border-[hsl(var(--brand-navy))]/20 bg-[hsl(var(--brand-cream))] font-medium text-[hsl(var(--brand-navy))]",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[hsl(var(--brand-navy))]"}),Jh[p.status]??p.status]})})()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:e.jsx("h1",{className:"font-display text-3xl font-bold leading-tight tracking-tight text-foreground sm:text-4xl",children:p.jobTitle})}),e.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-2 font-semibold text-foreground",children:[e.jsx(su,{isConfidential:Ys,companyLogoUrl:Ys?null:i==null?void 0:i.company_logo_url,companyName:Be}),Be]}),e.jsx("span",{"aria-hidden":!0,children:"â¢"}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(di,{className:"h-3.5 w-3.5"}),vo]})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Ha?e.jsxs(je,{variant:"secondary",className:"gap-1.5 rounded-full border border-[hsl(var(--brand-navy))]/15 bg-[hsl(var(--brand-cream))] font-medium text-[hsl(var(--brand-navy))]",children:[e.jsx(Tt,{className:"h-3.5 w-3.5"}),Ha]}):null,Ft?e.jsxs(je,{variant:"secondary",className:"gap-1.5 rounded-full border border-[hsl(var(--brand-navy))]/15 bg-[hsl(var(--brand-cream))] font-medium text-[hsl(var(--brand-navy))]",children:[e.jsx(di,{className:"h-3.5 w-3.5"}),Ft]}):null,Va?e.jsxs(je,{variant:"secondary",className:"gap-1.5 rounded-full border border-[hsl(var(--brand-navy))]/15 bg-[hsl(var(--brand-cream))] font-medium text-[hsl(var(--brand-navy))]",children:[e.jsx(wa,{className:"h-3.5 w-3.5"}),Va]}):null,Ka?e.jsxs(je,{variant:"secondary",className:"gap-1.5 rounded-full border border-[hsl(var(--brand-navy))]/15 bg-[hsl(var(--brand-cream))] font-medium text-[hsl(var(--brand-navy))]",children:[e.jsx(wc,{className:"h-3.5 w-3.5"}),Ka]}):null,i!=null&&i.department?e.jsxs(je,{variant:"secondary",className:"gap-1.5 rounded-full border border-[hsl(var(--brand-navy))]/15 bg-[hsl(var(--brand-cream))] font-medium text-[hsl(var(--brand-navy))]",children:[e.jsx(St,{className:"h-3.5 w-3.5"}),i.department]}):null]}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground sm:shrink-0",children:[e.jsx(cr,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide",children:"Applications close"}),e.jsx("span",{className:"font-semibold text-foreground",children:en?"Closed":e.jsx(Eu,{deadlineStr:bo,expired:$o})})]})]}),e.jsx(Fu,{description:p.description||(i==null?void 0:i.description)||null,skills:yo}),qe.stepperSteps.length>0?e.jsx("div",{className:"space-y-4 overflow-hidden rounded-xl border border-border/50 bg-muted/15 px-3 py-4 sm:px-4",children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-stretch md:gap-5",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-foreground",children:"Your application progress"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Complete these ",Mr.length," ",Mr.length===1?"step":"steps"," to move forward."]})]}),e.jsx(ii,{steps:Mr,dense:!1,selectedKey:A,onStepClick:hn})]}),gt.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-px w-full shrink-0 bg-border md:h-auto md:w-px","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-2 md:w-[36%] md:max-w-[300px]",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-foreground",children:"Hiring process"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These steps happen after you complete your steps."})]}),e.jsx(ii,{steps:gt,dense:!1,selectedKey:A,onStepClick:hn})]})]}):null]})}):null]}),e.jsxs("div",{className:"space-y-6",children:[ee==="application"?e.jsxs(e.Fragment,{children:[e.jsx(Wu,{description:p.description,alertKeyword:ec({title:p.jobTitle,role_title:i==null?void 0:i.role_title})}),i?e.jsx($h,{job:i,onTryPractice:un,practiceSubmitting:Us}):null]}):null,(()=>{var M,se,Ne,ce,Le;if(!(ee==="eligibility"||ee==="resume")||!p.id)return null;const d=qe.steps.find(oe=>Qe(oe.key,oe.type)==="eligibility"),y=!!Ht||!!d,f=(s==null?void 0:s.eligibility_screen_status)==="passed"||(d==null?void 0:d.status)==="completed",I=Hs||(s==null?void 0:s.eligibility_screen_status)==="not_matched"||(d==null?void 0:d.status)==="not_selected",H=y&&!f&&!I,$=!y||f,z=ee==="eligibility"||H&&Cs;return e.jsxs("div",{className:"space-y-5","data-testid":"applied-journey-panel",children:[y?e.jsx(qu,{stepCounter:ir,jobId:p.id,slug:de||ze,jobTitle:p.jobTitle,companyName:Be,jobLocation:p.location,isCurrentStep:z||H,compactWhenPassed:$&&f,nextStepTitle:$?null:((M=qe.steps.find(oe=>oe.key!=="eligibility_screen"&&oe.key!=="eligibility"&&Qe(oe.key,oe.type)==="resume"))==null?void 0:M.title)??null,onEligibilityChanged:()=>{ls()},onAdvanceToResume:()=>{nd(),ls()}}):null,$&&Zo?e.jsxs("div",{className:"grid grid-cols-1 items-start gap-5 lg:grid-cols-3 lg:gap-6",style:Xt||f||!y?void 0:{display:"none"},"aria-hidden":Xt||f||!y?void 0:!0,"data-testid":"journey-resume-panel-wrapper",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsx(gh,{stepCounter:ir,application:{resume_filename:((Ne=(se=s==null?void 0:s.resume_attempt_history)==null?void 0:se[0])==null?void 0:Ne.filename)??null},status:s,resumeStepCompleted:!!Jo,laterStageStarted:ed,jobId:p.id,slug:de||ze||void 0,jobTitle:p.jobTitle,companyName:Be,onUploadComplete:ls,onStartRehearsal:or,startingRehearsal:F,canStartRehearsal:!!(de||ze)&&!Ur&&zi(s),onBack:y?void 0:()=>{var ke;const oe=((ke=qe.steps.find(Fe=>Qe(Fe.key,Fe.type)==="eligibility"))==null?void 0:ke.key)??null;oe&&_e(oe)}})}),e.jsx(io,{className:"border-border/70 shadow-sm lg:sticky lg:top-6",waitingInQualifiedPool:an,emailVerificationPending:Vr(s),resumeRetryHeld:(((ce=s==null?void 0:s.resume_attempt_policy)==null?void 0:ce.attempts_used)??(s==null?void 0:s.resume_upload_attempts_used)??0)>0&&Ir(s),resumeAttemptsExhausted:(((Le=s==null?void 0:s.resume_attempt_policy)==null?void 0:Le.attempts_used)??(s==null?void 0:s.resume_upload_attempts_used)??0)>0&&!Ir(s),variant:"resume"})]}):null]})})(),(ee==="rehearsal"||ee==="behavioural")&&Oo?e.jsxs(e.Fragment,{children:[e.jsx(rh,{stepCounter:ir,stageKey:Ds,title:(x==null?void 0:x.title)||vi(Ds,x==null?void 0:x.title),description:Oe.quotaReached?"You have used all attempts for this rehearsal stage.":x==null?void 0:x.description,jobTitle:p.jobTitle,companyName:Be,isCurrentStep:Cs,isBehavioural:ee==="behavioural",attemptsUsed:Oe.used,attemptsMax:Oe.max,attemptsRemaining:Oe.remaining,passThreshold:sd,attempts:gn,attemptCreatedAtById:vn,scoresLoading:J,rehearsalTimeHours:i==null?void 0:i.rehearsal_time_hours,onStartRehearsal:or,practiceSubmitting:Us,rehearsalDurationSeconds:(typeof(i==null?void 0:i.selected_rehearsal)=="object"&&i.selected_rehearsal!==null?i.selected_rehearsal.target_interaction_seconds:null)??((Cl=(Rl=i==null?void 0:i.enabled_rehearsals)==null?void 0:Rl[0])==null?void 0:Cl.target_interaction_seconds)??null,canStartRehearsal:jn,startingRehearsal:F,onTryPractice:un,isSafetyRehearsal:wn,isSkipped:Yr,ski
1pSubmitting:$e,onSkipRehearsal:md,undoEligible:bn,undoSubmitting:rs,onUndoSkip:Yr?_n:void 0,continueLabel:jt(s)||ee==="rehearsal"&&ji(s)&&Oe.max>0&&Oe.remaining<=0||Oe.quotaReached||Oe.remaining<=0||ar||dt||Vs||Qt&&!vs&&!$r&&!fn&&!zs(s,{product_type:l==null?void 0:l.product_type})&&!Zt?null:ad||(ee==="behavioural"&&Cs&&!rr&&!$s&&!ut&&Oe.remaining>0?Vt?`Retry ${Ce}`:`Start ${Ce}`:null)||(vs&&Cs&&ee!=="behavioural"?Oe.used>0?"Run another rehearsal":"Start rehearsal":null)||(Cs&&ee!=="behavioural"?(cs==null?void 0:cs.buttonLabel)||(Ze==null?void 0:Ze.buttonLabel)||(Ae==null?void 0:Ae.buttonLabel)||(ft?"Run another rehearsal":null)||(nr||vs||Zt?"Start rehearsal":null):null),continueDisabled:ee==="behavioural"?!!($s||rr||ar||!tr.allowed):$r||vs?!1:Ur||Vs||!!($s||rr),continuing:F,onContinue:$r?()=>{var n,d,y;Es(Nr((n=x==null?void 0:x.cta)==null?void 0:n.rehearsal_id,x==null?void 0:x.rehearsal_id,(d=s==null?void 0:s.selected_rehearsal)==null?void 0:d.id,(y=i==null?void 0:i.selected_rehearsal)==null?void 0:y.id,ns)||void 0,(x==null?void 0:x.title)??void 0)}:vs&&ee!=="behavioural"?()=>{Es()}:ee==="behavioural"?()=>{if(!tr.allowed){ht();return}const n=de||ze,{rehearsalId:d,rehearsalTitle:y}=yr();if(n){if(!d){u({title:`${Ce} not ready`,description:"Your assigned scenario is not linked to this application yet. Please refresh in a moment or ask the hiring team to re-assign.",variant:"destructive"});return}ts(n,d,y,{kind:"work_style",stageKey:"behavioural"})}}:or}),(s==null?void 0:s.can_start_new_rehearsal)===!1&&!Gt&&lr&&!mt&&!vs&&!Vs&&Cs?e.jsxs("div",{className:"space-y-1.5 rounded-lg border border-amber-200/80 bg-amber-50/70 px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium leading-snug text-amber-900",children:lr}),At?e.jsx("p",{className:"text-sm leading-snug text-amber-900/90",children:At}):null]}):null,zo&&!((s==null?void 0:s.can_start_new_rehearsal)===!1&&!Gt&&lr&&!mt)?e.jsx("div",{className:"space-y-1 rounded-lg border border-amber-200/80 bg-amber-50/70 px-3 py-2.5",children:e.jsx("p",{className:"text-sm font-medium leading-snug text-amber-900",children:lr||"Rehearsal temporarily unavailable â please refresh."})}):null]}):null,ee==="recruiter_review"?e.jsxs(e.Fragment,{children:[e.jsx(jh,{stepCounter:ir,title:x==null?void 0:x.title,description:x==null?void 0:x.description,shortlistPublished:(x==null?void 0:x.status)==="completed",completed:(x==null?void 0:x.status)==="completed",credentialIssued:pr,instantScreeningOffer:!!(Yd(qe.steps)&&!pr),interviewAdvanced:!!qe.steps.some(n=>{var $;if(Qe(n.key,n.type)!=="interview"&&n.type!=="interview")return!1;const y=String(n.status??"").trim().toLowerCase(),f=String(n.stage_status??"").trim().toLowerCase(),I=String((($=n.cta)==null?void 0:$.type)??"").trim().toLowerCase(),H=String(n.status_label??"").trim().toLowerCase();return f==="instant_screening_offered"||f==="interview_slot_offered"||f==="interview_action_required"||f==="interview_scheduled"||I==="pick_interview_slot"||/choose a time|pick a time|scheduling/i.test(H)?y!=="locked"&&y!=="skipped":y==="locked"||y==="not_started"||n.locked===!0&&y!=="current"&&y!=="completed"?!1:y==="current"||y==="completed"||y==="under_review"||y==="action_required"||y==="invited"||y==="scheduled"||n.locked===!1}),rehearsalState:pn,hasEligibilityQuestions:td,undoEligible:bn,undoSubmitting:rs,onUndoSkip:pn==="skipped_by_candidate"?_n:void 0,productType:(N==null?void 0:N.product_type)??(l==null?void 0:l.product_type)??(fe?"concierge":"crew")}),pr?e.jsx(Oi,{stepCounter:null,title:"Verified BitScore",description:"Your recruiter-verified BitScore credential is ready to view and share.",candidateName:((El=ti.get("user_profile"))==null?void 0:El.display_name)||null,candidateAvatarUrl:g,roleTitle:p.jobTitle,employmentType:ia(i==null?void 0:i.employment_type)??void 0,organizationName:Be,issuedCredential:(N==null?void 0:N.issued_credential)??null,verifiedByLabel:"Recruiter verified by BitStage",hired:null,rejected:null,jobDescription:i!=null&&i.is_confidential?null:p.description}):null]}):null,ee==="interview"?e.jsx(Oh,{stepCounter:ir,title:x==null?void 0:x.title,productType:(l==null?void 0:l.product_type)??(N==null?void 0:N.product_type)??(fe?"concierge":"crew"),description:x==null?void 0:x.description,mode:Ts,loading:O,scheduledStartAt:bs.scheduledStartAt,timezone:bs.timezone,durationMinutes:bs.durationMinutes,meetUrl:er,googleCalendarHtmlLink:(C==null?void 0:C.google_calendar_html_link)??((Il=C==null?void 0:C.interview)==null?void 0:Il.google_calendar_html_link),managedExternally:((Tl=C==null?void 0:C.interview)==null?void 0:Tl.managed_externally)??((Sl=C==null?void 0:C.interview)==null?void 0:Sl.skip_recall_bot),companyName:Be,jobTitle:(C==null?void 0:C.job_title)??(i==null?void 0:i.title),outcome:(Ll=s==null?void 0:s.concierge)==null?void 0:Ll.interview_outcome,outcomePhase:hr,status:s,withHiringTeam:gr,offeredSlots:(C==null?void 0:C.offered_slots)??[],inv
1iteNote:C==null?void 0:C.note,expiresAt:(C==null?void 0:C.expires_at)??null,provisionalScoreLabel:((Dl=C==null?void 0:C.provisional_score)==null?void 0:Dl.rehearsal)!=null?`You scored ${Math.round(Number(C.provisional_score.rehearsal))} (provisional).`:null,selectingSlot:Ye,onSelectSlot:Mt,decliningSlots:ge,onDeclineSlots:Ot,awaitingTimes:Pa(C),recruiterName:C==null?void 0:C.recruiter_name}):null,ee==="outcome"?e.jsx(Oi,{stepCounter:ir,title:x==null?void 0:x.title,description:x==null?void 0:x.description,candidateName:((Bl=ti.get("user_profile"))==null?void 0:Bl.display_name)||null,candidateAvatarUrl:g,roleTitle:p.jobTitle,employmentType:ia(i==null?void 0:i.employment_type)??void 0,organizationName:Be,issuedCredential:(N==null?void 0:N.issued_credential)??null,verifiedByLabel:"Recruiter verified by BitStage",hired:(N==null?void 0:N.hired)??null,rejected:(N==null?void 0:N.rejected)??null,jobDescription:i!=null&&i.is_confidential?null:p.description}):null,wi(A)?e.jsx(_h,{stepCounter:ir,gateKey:A,status:s}):null,ee==="generic"&&x&&!wi(A)?e.jsx(le,{className:"border-border/70 shadow-sm",children:e.jsx(ie,{className:"space-y-2 p-5",children:e.jsx("h2",{className:"text-xl font-bold text-foreground",children:x.title})})}):null,Cs&&wo&&ee!=="outcome"&&e.jsxs("div",{className:"space-y-3",children:[Ei(ks)&&ee!=="recruiter_review"&&ee!=="interview"&&!((Pl=j==null?void 0:j.steps)!=null&&Pl.some(n=>{const d=String(n.key??"").toLowerCase();if(!(d==="recruiter_review"||d==="review_next_steps"||n.type==="review"))return!1;const f=String(n.status??"").toLowerCase();return f==="under_review"||f==="current"||f==="in_progress"||f==="completed"}))&&e.jsx(le,{className:"border-border shadow-sm",children:e.jsxs(ie,{className:"flex items-center justify-center gap-3 p-6",children:[e.jsx(As,{}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Advancing to your next stepâ¦"})]})}),gr&&ee!=="recruiter_review"&&ee!=="interview"&&!br&&!qs&&e.jsx(Ba,{}),qt&&e.jsx(Ah,{nextStep:qt}),Uo&&e.jsx(Gh,{status:s,journey:j}),$s&&e.jsx(Vh,{}),rr&&e.jsx(Kh,{}),br&&!qs&&ee!=="interview"&&ee!=="recruiter_review"&&(O&&!C?e.jsx(le,{className:"border-[hsl(var(--brand-navy))]/25 bg-[hsl(var(--brand-cream))] shadow-sm",children:e.jsxs(ie,{className:"p-6 flex items-center justify-center gap-3",children:[e.jsx(As,{}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading interview statusâ¦"})]})}):e.jsx(ho,{title:(x==null?void 0:x.title)??"Recruiter Interview",description:Pa(C)?po(C==null?void 0:C.recruiter_name):x==null?void 0:x.description,status:s})),qs&&ee!=="interview"&&ee!=="recruiter_review"&&(O&&!C?e.jsx(le,{className:"border-[hsl(var(--brand-navy))]/25 bg-[hsl(var(--brand-cream))] shadow-sm",children:e.jsxs(ie,{className:"p-6 flex items-center justify-center gap-3",children:[e.jsx(As,{}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading interview detailsâ¦"})]})}):e.jsx(xo,{title:(x==null?void 0:x.title)??"Recruiter Interview",scheduledStartAt:bs.scheduledStartAt,timezone:bs.timezone,durationMinutes:bs.durationMinutes,meetUrl:er,googleCalendarHtmlLink:(C==null?void 0:C.google_calendar_html_link)??((Ul=C==null?void 0:C.interview)==null?void 0:Ul.google_calendar_html_link),managedExternally:((Ml=C==null?void 0:C.interview)==null?void 0:Ml.managed_externally)??((Ol=C==null?void 0:C.interview)==null?void 0:Ol.skip_recall_bot),companyName:Be,jobTitle:(C==null?void 0:C.job_title)??(i==null?void 0:i.title)})),To&&(_s!=null&&_s.status)?e.jsx(zh,{status:_s.status,reason:_s.reason}):null,Pr&&ee!=="interview"&&ee!=="recruiter_review"&&e.jsx(fo,{outcome:(Fl=s==null?void 0:s.concierge)==null?void 0:Fl.interview_outcome,phase:hr??"completed"}),ut&&e.jsxs("div",{className:"space-y-3",children:[So&&e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-200 bg-amber-50 dark:border-amber-800/60 dark:bg-amber-950/30 px-4 py-3",children:[e.jsx("span",{className:"text-amber-500 mt-0.5 shrink-0","aria-hidden":!0,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-800 dark:text-amber-300",children:"Your hiring team has updated your scenario"}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400 mt-0.5 leading-relaxed",children:((Wl=s==null?void 0:s.concierge)==null?void 0:Wl.max_attempts_per_stage)!=null?e.jsxs(e.Fragment,{children:["A new scenario has been assigned. You now have"," ",e.jsxs("strong",{className:"tabular-nums",children:[s.concierge.max_attempts_per_stage," fresh attempts"]})," ","for this rehearsal."]}):e.jsx(e.Fragment,{children:"A new scenario has been assigned. Your attempts have been reset for this rehearsal."})})]})]}),e.jsx(Hh,{nextRehearsal:he,assignedScenario:(($l=(Yl=s==null?void 0:s.concierge)==null?void 0:Yl.behavioural_assignment)==null?void 0:$l.assigned_sce
1nario)??(he==null?void 0:he.assigned_scenario)??((Hl=(ql=j==null?void 0:j.steps)==null?void 0:ql.find(n=>n.type==="behavioural"))==null?void 0:Hl.assigned_scenario)??null,isRetry:Vt}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(ae,{className:"h-11 gap-2 px-6 font-semibold",onClick:()=>{if(!tr.allowed){ht();return}const n=de||ze,{rehearsalId:d,rehearsalTitle:y}=yr();if(n){if(!d){u({title:`${Ce} not ready`,description:"Your assigned scenario is not linked to this application yet. Please refresh in a moment or ask the hiring team to re-assign.",variant:"destructive"});return}ts(n,d,y,{kind:"work_style",stageKey:"behavioural"})}},disabled:F||ar||!tr.allowed,"data-testid":"work-style-start-button",children:[F?"Startingâ¦":Vt?`Retry ${Ce}`:`Start ${Ce}`,e.jsx(Ns,{className:"h-4 w-4"})]})})]}),dt&&e.jsx(cu,{finalScore:Ro,concierge:s==null?void 0:s.concierge,applicationStatus:s,nextStep:(s==null?void 0:s.next_step)??(j==null?void 0:j.next_step),starting:F,submittingDecision:me,onContinue:id,onRetry:Es}),e.jsx(th,{open:lt,onOpenChange:Xs,onConfirm:()=>{cd()},submitting:$e}),Go&&!Vs&&ee!=="eligibility"&&ee!=="resume"&&ee!=="rehearsal"&&ee!=="behavioural"&&ee!=="recruiter_review"&&e.jsx(le,{className:Hs?"border-border/70 bg-card shadow-sm":"bg-[hsl(var(--brand-cream))] border-[hsl(var(--brand-navy))]/25 shadow-sm ring-1 ring-[hsl(var(--brand-navy))]/10",children:e.jsx(ie,{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:Hs?"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted":"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-[hsl(var(--brand-cream))] border border-[hsl(var(--brand-navy))]/15",children:Hs?e.jsx(wa,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Nc,{className:"h-5 w-5 text-[hsl(var(--brand-navy))]"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:Hs?"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground":"text-[11px] font-semibold uppercase tracking-wider text-[hsl(var(--brand-navy))]",children:Hs?"Role fit":"Next step"}),e.jsx("h3",{className:"text-lg font-bold text-foreground leading-snug",children:Se?Se.title:Pe?Pe.title:cs?cs.title:Ze?Ze.title:Ae?Ae.title:h!=null&&h.title?h.title:Ar(ms)==="behavioural"?`Start your ${Ce}`:ms==="Rehearsal 2"?"Start Rehearsal Round 2":ms==="Rehearsal 1"?"Start your rehearsal":"Upload your resume to begin"}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:Se?Se.description:Pe?Pe.description:cs?cs.description:Ze?Ze.description:Ae?Ae.description:h!=null&&h.description?h.description:Ar(ms)==="behavioural"?"Review the briefing above, then start when you're ready.":ms==="Rehearsal 2"?"You've completed your rehearsal. Begin your second rehearsal to strengthen your application.":ms==="Rehearsal 1"?"Record your first role rehearsal to showcase your skills for this position.":"We'll review your resume for eligibility, then unlock your rehearsal."}),Io!=null&&(ft||((Vl=h==null?void 0:h.cta)==null?void 0:Vl.type)==="start_rehearsal"||((Kl=h==null?void 0:h.cta)==null?void 0:Kl.type)==="retry_rehearsal"||Ze)?e.jsx("p",{className:"text-sm text-foreground/90",children:"Complete your rehearsal to continue this application. Scores stay private until a verified BitScore is issued."}):null]}),e.jsxs(e.Fragment,{children:[Hs?null:e.jsxs("p",{className:"text-sm text-muted-foreground leading-relaxed",children:["You are applying through BitStage for this employer'
1s role process. Your application, resume, rehearsal results, and related evaluation data may be shared with the relevant employer for this role. Please review BitStage's"," ",e.jsx("a",{href:"/terms",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-[hsl(var(--brand-navy))] hover:underline",children:"Terms of Service"}),","," ",e.jsx("a",{href:"/privacy",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-[hsl(var(--brand-navy))] hover:underline",children:"Privacy Policy"}),", and"," ",e.jsx("a",{href:"/trust-center",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-[hsl(var(--brand-navy))] hover:underline",children:"Trust Center"})," ","before continuing."]}),!(Se!=null&&Se.hideButton)&&!(Pe!=null&&Pe.hideButton)&&e.jsx("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row sm:justify-end",children:Hs?e.jsxs(e.Fragment,{children:[e.jsxs(ae,{variant:"outline",className:"h-11 w-full gap-2 px-6 text-sm font-semibold sm:w-auto",onClick:()=>a("/practice"),children:[e.jsx(nt,{className:"h-4 w-4"}),"Continue practicing"]}),e.jsxs(ae,{className:"h-11 w-full gap-2 px-6 text-sm font-semibold shadow-sm sm:w-auto",onClick:()=>a("/practice?tab=invited&jobs_status=open#open-jobs"),children:[(Se==null?void 0:Se.buttonLabel)||"View similar roles",e.jsx(Ns,{className:"h-4 w-4"})]})]}):e.jsxs(ae,{className:"h-11 w-full gap-2 px-6 text-sm font-semibold shadow-sm disabled:cursor-not-allowed disabled:opacity-60 sm:w-auto",onClick:Se||Pe?or:ft||((zl=h==null?void 0:h.cta)==null?void 0:zl.type)==="start_rehearsal"||((Al=h==null?void 0:h.cta)==null?void 0:Al.type)==="retry_rehearsal"||Ze?od:or,disabled:Ur||F,title:Ur?Qo:void 0,children:[F?"Startingâ¦":Se!=null&&Se.buttonLabel?Se.buttonLabel:Pe!=null&&Pe.buttonLabel?Pe.buttonLabel:cs!=null&&cs.buttonLabel?cs.buttonLabel:Ze!=null&&Ze.buttonLabel?Ze.buttonLabel:Ae!=null&&Ae.buttonLabel?Ae.buttonLabel:Ar(ms)==="behavioural"?`Start ${Ce}`:ms==="Rehearsal 2"?"Start Rehearsal Round 2":ms==="Rehearsal 1"?"Start your rehearsal":"Agree & Start Application",e.jsx(Ns,{className:"h-4 w-4"})]})})]})]})]})})}),!ar&&!nr&&!ot&&!Ss&&!rr&&!$s&&!ut&&!gr&&!br&&!qs&&!mt&&!Vs&&!Ko&&ee!=="recruiter_review"&&e.jsx("div",{className:"rounded-xl border border-amber-200/80 bg-amber-50/70 px-4 py-3 text-sm text-amber-900 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(kc,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-semibold leading-none",children:Vo}),e.jsx("p",{className:"leading-snug text-amber-900/90",children:cn})]})]})})]})]})]}),e.jsx("div",{className:"h-8"})]})};export{Nf as default};
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.