1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AdminFlagsModal-DbEUuOJ4.js","assets/main-DmDsGTCr.js","assets/main-Ddz38Tdj.css","assets/dialog-CHuX4MUN.js","assets/index-H3pqt8Mq.js","assets/index-BT86mV_3.js","assets/switch-C9fo2Gdy.js","assets/index-B2BwbHwT.js","assets/search-C4HAQwt1.js","assets/copy-Dpj_eCG9.js","assets/GroundingReviewersModal-giTryk6i.js","assets/mail-C39XquGB.js","assets/MembershipDevModal-BIfzBWVx.js","assets/useMutation-BXaTcy4a.js","assets/use-membership-Bx2DwdPj.js","assets/ftux-session-markers-yOSaBTTA.js","assets/send-DKb2GXmz.js","assets/clock-tr-BQZYQ.js","assets/product-events-DE71XA68.js","assets/payload-validation-C-pMPr5Y.js","assets/use-feature-flag-C9iVprKR.js"])))=>i.map(i=>d[i]); 2import{I as ge,T as Qr,j as n,U as Xr,N as be,V as We,W as Dt,r as s,n as De,X as $n,Y as Zr,Z as L,_ as P,$ as zn,a0 as ut,a1 as ae,a2 as Jr,a3 as W,a4 as Kn,a5 as ea,a6 as Lt,a7 as dt,a8 as ta,B as te,a9 as He,aa as qe,M as na,ab as ra,h as aa,ac as Ft,ad as Ut,ae as sa,af as oa,ag as U,ah as Ae,ai as me,aj as ia,ak as Xe,al as ca,am as Wn,an as la,ao as ue,ap as Hn,p as se,aq as qn,ar as ua,as as at,at as da,au as ma,av as fa,aw as pa,ax as ha,ay as Gn,az as xa,aA as ga,aB as ba,aC as ya,aD as _a,aE as mt,aF as ne,aG as Bt,aH as $t,aI as va,aJ as Oe,aK as ee,aL as wa,aM as Ea,aN as zt,F as ka,aO as Sa,aP as Kt,aQ as Ra,aR as ja,aS as Na,Q as Ge,aT as Ca,aU as Le,aV as ye,aW as Vn,aX as Yn,aY as Qn,aZ as Ta,a_ as Xn,a$ as Aa,b0 as Oa,b1 as Wt,b2 as xe,b3 as st,b4 as Ht,b5 as Ia,b6 as Fe,b7 as Pa,b8 as Ma,b9 as Zn,ba as qt,bb as Gt,bc as Vt,bd as Da,be as Jn,bf as ot,bg as it,bh as La,bi as de,bj as Fa,bk as Ua,bl as Ba,bm as $a,bn as za,bo as Ka,bp as Yt,bq as Wa,br as Ha,bs as ft,bt as qa,bu as pt,L as er,bv as Ga,bw as Va,bx as Ya,by as tr,e as Qt,bz as Xt,bA as Qa,bB as Xa,bC as Za,bD as Ja,bE as es,bF as Zt,bG as ts,bH as Ie,bI as ns,O as rs,bJ as as,bK as ss,bL as os,bM as is,bN as cs,bO as ls,bP as us,bQ as ds,bR as ms,bS as fs,bT as ps,bU as hs}from"./main-DmDsGTCr.js";import{u as xs}from"./useSuspenseQuery-DJyxosyP.js";import{u as Ue}from"./useMutation-BXaTcy4a.js";import{u as Be,e as ct,a as Jt}from"./use-feature-flag-C9iVprKR.js";import{u as gs,F as bs}from"./extension-presence-hEP74lNh.js";import{u as ys,P as _s}from"./paywall-context-FiGeElF6.js";import{u as ht,s as vs,g as en}from"./use-membership-Bx2DwdPj.js";import{D as tn}from"./DualArcSpinner-D4HRp4ig.js";import{D as nr,a as rr,b as ws,c as Es}from"./dialog-CHuX4MUN.js";import{M as ks,t as Ss,u as ar,m as Rs,F as nn,c as js,a as sr,b as Ns,d as rn,r as Cs,e as Ts,f as an}from"./ftux-session-markers-yOSaBTTA.js";import{C as As}from"./check-7NZig2Tr.js";import{t as C}from"./product-events-DE71XA68.js";import{r as Os,o as Is}from"./offer-interstitial-C7DkHAHD.js";import{P as or,a as Ps,b as ir,c as Ms}from"./popover-CU_Nu5OD.js";import{s as Ds}from"./profile-intake-DeOO991U.js";import{W as Ls,a as Fs}from"./WelcomeModal-D6jfSyjL.js";import{t as Us,a as sn,b as Bs}from"./track-upload-DlkJyEzl.js";import{h as $s}from"./major-seed-vbUJ9wZq.js";import{S as zs,a as Ks,b as Ws,c as Hs,d as qs,e as Gs}from"./sheet-D9lkfEB6.js";import{g as cr,S as lr,a as ur,b as dr,c as mr,d as fr,e as pr,f as hr,h as xr}from"./sidebar-CsuZ5YGq.js";import{B as xt,U as gr,F as Vs}from"./Footer-BiE8YMTq.js";import{f as gt}from"./flush-D2KamQOg.js";import{B as Ys}from"./bell-Ck4bn7d0.js";import{C as Qs}from"./circle-alert-B_UM7h_4.js";import{M as Xs}from"./mail-C39XquGB.js";import{H as Zs}from"./hammer-BvwU5x6b.js";import{B as Js}from"./building-2-Iybo88u-.js";import{S as eo}from"./search-C4HAQwt1.js";import{P as on}from"./PageHeader-BybPPbxT.js";import{h as to}from"./resume-content-_LE5NXxL.js";import{R as no,a as ro,u as br}from"./resume-import-context-DLBgXRZm.js";import{D as ao,a as so,b as oo,c as fe}from"./dropdown-menu-gvtbf2CI.js";import{N as yr}from"./operator-flags-BnPBIyfK.js";import{C as io}from"./clock-tr-BQZYQ.js";import{W as co}from"./wallet-CLVbttkT.js";import{u as lo}from"./use-focus-trap-fahQvZeG.js";import"./index-H3pqt8Mq.js";import"./index-BT86mV_3.js";import"./send-DKb2GXmz.js";import"./payload-validation-C-pMPr5Y.js";
2import"./StarLatticeLoader-LxbW-Ljv.js";import"./AgentStatus-u6-y9Vm-.js";import"./job-status-badge-9sg9VAMG.js";import"./ApplyActionButtons-5CTvJApx.js";import"./lock-CGVUhhnO.js";import"./CompanyTile-CuIY9V5A.js";import"./SignalList-NCDBd0cl.js";import"./triangle-alert-C4NPl7AO.js";import"./arrow-right-CjcMx_Uy.js";import"./file-up-BDbtwhRr.js";import"./index-DO-c3b5w.js";function $e(e){return e.type==="job_match"&&!!e.matched_companies&&e.matched_companies.length>0}function _r(e){const t=e.map(r=>r.name);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} & ${t[t.length-1]}`}const uo=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],mo=ge("credit-card",uo);const fo=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],po=ge("flag",fo);const ho=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],xo=ge("house",ho);const go=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],bo=ge("log-out",go);const yo=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],_o=ge("shield-check",yo);function vo(e){return!Number.isFinite(e)||e<0?"unknown":e<1e5?"0-100kb":e<5e5?"100kb-500kb":e<1e6?"500kb-1mb":e<5e6?"1mb-5mb":"5mb+"}const wo="checkout-island",Eo=`/${wo}/`;function ko(){const e=Be(Qr),t=gs();return e!=="on"||t!==bs?null:n.jsxs("div",{className:"rounded-lg border border-hairline bg-surface-white p-4 text-sm text-text",children:[n.jsx("p",{className:"font-medium",children:"Your Chegg extension is out of date."}),n.jsx("p",{className:"mt-1 text-text-muted",children:"Update it to keep tailoring resumes and autofilling applications."}),n.jsx("a",{className:"mt-2 inline-block font-medium underline",href:Xr,rel:"noreferrer",target:"_blank","data-amp-track-surface":"dashboard","data-amp-track-action":"extension_update_nudge_click",children:"Update the extension"})]})}const So="pricing_page";function Ro(){const e=be(),t=We({from:"/_app"}),{openPaywall:r,isEnforced:a}=ys(),{tier:o,isLoading:i}=ht(),c=t[Dt],l=Zr(c),d=s.useRef(!1);return s.useEffect(()=>{if(c===void 0){d.current=!1;return}if(d.current)return;const u=()=>{e({to:".",replace:!0,search:m=>({...m,[Dt]:void 0})})};if(!l){d.current=!0,u();return}i||De()||a&&(d.current=!0,o!==$n&&r(So,{startAt:"payment"}),u())},[c,l,i,a,o,r,e]),null}const K=128,cn=256,ln=/^\d{1,7}\.\d{2}$/,jo=/^[A-Za-z0-9._-]{1,48}$/,No=4,Co=/^[A-Za-z0-9_-]{1,32}$/,vr=L({apiKey:P().min(1).max(K),idToken:P(),accessToken:P(),cheggBaseUrl:Lt({protocol:/^https$/}).max(cn),cheggGraphQLUrl:Lt({protocol:/^https$/}).max(cn),useBFF:ut()}).strict(),To=L({subtotal:ae().nonnegative(),discount:ae().nullable(),tax:ae().nullable(),total:ae().nonnegative(),totalWithCurrencyFormat:P().max(K).nullable(),subtotalWithCurrencyFormat:P().max(K).nullable(),taxWithCurrencyFormat:P().max(K).nullable(),currencyName:W("USD"),taxDetails:L({tax:ae().nullable(),taxWithCurrencyFormat:P().max(K).nullable(),label:Jr()}).strict(),orderGiftCodeBalance:ae(),totalCoveredByScholarship:ut()}).strict(),Ao=L({catalogItemId:P().min(1).max(K),pricingId:W("USD"),quantity:W(1),productType:P().min(1).max(K),catalogItemSource:W("RECURLY")}).strict(),wr=L({orderSummary:To,items:zn(Ao).length(1),cartId:P().min(1).max(K),externalId:P().min(1).max(K),subtotalWithCurrencyFormat:P().min(1).max(K)}).strict();L({subtotal:P().regex(ln),total:P().regex(ln),currency:W("USD")}).strict();const Er=["PLACE_ORDER_ENABLED","PLACE_ORDER_DISABLED"];dt(Er);const Oo=dt([...Er,"PLACE_ORDER","ADD_ITEM","INITIALIZE","REAUTHORIZE","APP_MODE_CHANGED","UNKNOWN_COMMAND"]),Io=dt(["SUCCESS","ERROR","PENDING","INFO","EMPTY"]),Po=L({cartId:P().min(1).max(K).optional(),orderKey:P().min(1).max(K).optional(),codes:zn(P().regex(jo)
2).min(1).max(No).optional()}).strict(),Mo=L({kind:W("INIT"),authorization:vr,recurlyCart:wr,allowsZeroAmount:ut().optional()}).strict(),Do=L({kind:W("PLACE_ORDER")}).strict(),Lo=L({kind:W("REAUTHORIZE"),authorization:vr}).strict(),Fo=L({kind:W("READY")}).strict(),Uo=200,Bo=2400,$o=L({kind:W("RESIZE"),height:ae().int().min(Uo).max(Bo)}).strict(),zo=L({kind:W("STATUS"),command:Oo,status:Io,payload:Po}).strict(),Ko=L({kind:W("ORDER_PLACED"),orderKey:P().min(1).max(K)}).strict(),Wo=L({kind:W("PROMO"),code:P().regex(Co).nullable()}).strict(),Ho=Kn("kind",[Mo,Do,Lo]),kr=Kn("kind",[Fo,$o,zo,Ko,Wo]),qo=Ho.options.map(e=>e.shape.kind.value),Go=kr.options.map(e=>e.shape.kind.value);function Vo(e){if(typeof e!="object"||e===null)return;const t=e.kind;return typeof t=="string"?t:void 0}function Yo(e,t,r,a){const o=ea(e);if(!e.issues.some(l=>l.path[0]==="kind"))return o;const i=Vo(a),c=i!==void 0&&r.includes(i)?` ("${i}" is a message for the other direction)`:"";return`${o} 3 valid kinds: ${t.join(", ")}${c}`}function Qo(e){const t=kr.safeParse(e);return t.success?{ok:!0,message:t.data}:{ok:!1,error:Yo(t.error,Go,qo,e)}}const Xo=["pmt","RCLY-"],Zo=["DP-","PM-","ORD-"];function Jo(e){if(Xo.some(t=>e.startsWith(t)))return"declined";if(Zo.some(t=>e.startsWith(t)))return"server"}function ei(e){const{command:t,codes:r}=e;if(t==="INITIALIZE"||t==="REAUTHORIZE")return"auth";for(const a of r??[]){const o=Jo(a);if(o)return o}return t==="ADD_ITEM"||t==="UNKNOWN_COMMAND"?"server":"unknown"}function ti(e){return ta(Eo)}const le="[checkout]",un=15e3,dn=5e3,mn=2e4,fn=9e4,ni=["PLACE_ORDER","PLACE_ORDER_DISABLED"],ri=["PLACE_ORDER_ENABLED","PLACE_ORDER_DISABLED"],pn={idle:0,requested:1,purchasing:2};function Sr(e){return e?.inFlight===!0&&!e.charged}function ai(e){return e.cartReady&&!e.enablementClosed&&!e.charged&&!e.outcomeUnknown}const si=600,oi={ready:!1,cartReady:!1,enablementClosed:!1,placeOrderEnabled:!1,phase:"idle",inFlight:!1,charged:!1,placedOrderKey:null,outcomeUnknown:!1,unconfirmed:!1,failure:null,stall:null,promoCode:null};function ii(e,t,r){const a={reason:ei({command:e,codes:t})};return t&&(a.codes=t),r&&(a.cartId=r),a}function ci(e,t){if(e===t)return!0;if(e===null||t===null)return!1;const r=a=>a.codes===void 0?null:a.codes.join(" ");return e.reason===t.reason&&e.cartId===t.cartId&&e.kind===t.kind&&r(e)===r(t)}function li(e,t){return e.ready===t.ready&&e.cartReady===t.cartReady&&e.enablementClosed===t.enablementClosed&&e.placeOrderEnabled===t.placeOrderEnabled&&e.phase===t.phase&&e.inFlight===t.inFlight&&e.charged===t.charged&&e.placedOrderKey===t.placedOrderKey&&e.outcomeUnknown===t.outcomeUnknown&&e.unconfirmed===t.unconfirmed&&e.promoCode===t.promoCode&&e.stall===t.stall&&ci(e.failure,t.failure)}function X(e,t){const r={...e,...t},a={...r,placeOrderEnabled:ai(r),inFlight:r.phase!=="idle",unconfirmed:(r.charged||r.outcomeUnknown)&&r.placedOrderKey===null&&r.phase==="idle"};return li(e,a)?e:a}function hn(e,t,r){return e==="requested"?{ms:mn,why:`no PLACE_ORDER/PENDING within ${mn}ms, so no purchase call was made; dropping the overlay and reopening the place-order gate`,patch:{phase:"idle",enablementClosed:!1,stall:{kind:"place_order_never_started"}}}:e==="purchasing"&&!t?{ms:fn,why:`no terminal PLACE_ORDER status within ${fn}ms; a purchase call is outstanding, so the card may be charged and the gate stays shut`,patch:{phase:"idle",outcomeUnknown:!0}}:e==="purchasing"&&t&&r===null?{ms:dn,why:`the place order succeeded with no ORDER_PLACED within ${dn}ms; the card is charged and the order is unconfirmed`,patch:{phase:"idle"}}:null}function ui(e,t){if(t.kind==="READY")return X(e,{ready:!0});if(t.kind==="ORDER_PLACED")return e.placedOrderKey!==null?e:X(e,{placedOrderKey:t.orderKey,charged:!0,phase:"idle",outcomeUnknown:!1});if(t.kind==="RESIZE")return e;if(t.kind==="PROMO")return X(e,{promoCode:t.code});const{command:r,status:a,payload:o}=t,i={};r==="PLACE_ORDER_ENABLED"&&(i.enablementClosed=!1),r==="PLACE_ORDER_DISABLED"&&(i.enablementClosed=!0),r==="PLACE_ORDER"&&a==="ERROR"&&(i.enablementClosed=!1);const c=ni.includes(r);if(c&&a==="PENDING"&&!e.charged){const l=r==="PLACE_ORDER"?"purchasing":"requested";pn[l]>pn[e.phase]&&(i.phase=l)}return r==="PLACE_ORDER"&&a==="SUCCESS"?(i.charged=!0,i.phase=e.placedOrder
3Key===null?"purchasing":"idle",i.outcomeUnknown=!1):c&&(a==="SUCCESS"||a==="ERROR")&&(i.phase="idle",i.outcomeUnknown=!1),a==="ERROR"&&!ri.includes(r)&&(i.failure=ii(r,o.codes,o.cartId)),X(e,i)}function di({authorization:e,recurlyCart:t,allowsZeroAmount:r,placeOrderNonce:a,onStateChange:o,onOrderPlaced:i}){if(!wr.safeParse(t).success)throw new Error("CheckoutFrame requires a priced recurlyCart: previewPurchase must have resolved before the frame mounts");const c=s.useRef(null),[l,d]=s.useState(oi),[u,m]=s.useState(si),h=s.useRef(o),g=s.useRef(i),f=s.useRef({authorization:e,recurlyCart:t,allowsZeroAmount:r});s.useEffect(()=>{h.current=o,g.current=i,f.current={authorization:e,recurlyCart:t,allowsZeroAmount:r}},[o,i,e,t,r]);const p=s.useRef(!1),b=s.useRef(null),j=s.useRef(null),R=s.useRef(a),y=s.useRef(null),k=s.useCallback(_=>{const E=c.current?.contentWindow;E&&E.postMessage(_,window.location.origin)},[]);s.useEffect(()=>{h.current(l)},[l]),s.useEffect(()=>{const _=E=>{if(E.origin!==window.location.origin||E.source!==c.current?.contentWindow)return;const S=Qo(E.data);if(!S.ok){typeof E.data=="object"&&E.data!==null&&"kind"in E.data&&console.warn(`${le} dropped an island message that failed schema validation: 4${S.error}`);return}if(S.message.kind==="RESIZE"){m(S.message.height);return}if(d(I=>ui(I,S.message)),S.message.kind==="ORDER_PLACED"){const{orderKey:I}=S.message;if(y.current!==null){console.warn(`${le} ignored a repeat ORDER_PLACED; the order was already reported`);return}y.current=I,g.current(I)}};return window.addEventListener("message",_),()=>window.removeEventListener("message",_)},[]);const O=s.useCallback((_,E)=>{console.warn(`${le} ${_}`),d(S=>X(S,{failure:{reason:"server",kind:E}}))},[]),w=s.useCallback(()=>{if(p.current){console.warn(`${le} the island document loaded again; not re-posting INIT`);return}const{authorization:_,recurlyCart:E,allowsZeroAmount:S}=f.current;k({kind:"INIT",authorization:_,recurlyCart:E,...S?{allowsZeroAmount:!0}:{}}),p.current=!0,d(I=>({...I,cartReady:!0})),b.current=_},[k]),N=s.useRef(!1);return s.useEffect(()=>{const _=l.enablementClosed&&!N.current;if(N.current=l.enablementClosed,!_)return;const E=requestAnimationFrame(()=>{c.current?.scrollIntoView?.({block:"end",behavior:"smooth"})});return()=>cancelAnimationFrame(E)},[l.enablementClosed]),s.useEffect(()=>{const _=c.current;if(!_)return;const E=()=>O("the island document failed to load","island_load_failed");return _.addEventListener("error",E),()=>_.removeEventListener("error",E)},[O]),s.useEffect(()=>{if(l.ready||l.failure!==null)return;const _=setTimeout(()=>{O(`no READY from the island within ${un}ms; the payment form cannot be shown`,"island_not_ready")},un);return()=>clearTimeout(_)},[l.ready,l.failure,O]),s.useEffect(()=>{const _=hn(l.phase,l.charged,l.placedOrderKey);if(_===null)return;const E=setTimeout(()=>{console.warn(`${le} ${_.why}`),d(S=>hn(S.phase,S.charged,S.placedOrderKey)?.ms!==_.ms?S:X(S,_.patch))},_.ms);return()=>clearTimeout(E)},[l.phase,l.charged,l.placedOrderKey]),s.useEffect(()=>{if(!p.current)return;e!==b.current&&(j.current=e);const _=j.current;_!==null&&(l.inFlight||(j.current=null,b.current=_,k({kind:"REAUTHORIZE",authorization:_}),d(E=>E.failure?.reason==="auth"?X(E,{failure:null}):E)))},[e,l.inFlight,k]),s.useEffect(()=>{if(a===R.current)return;R.current=a;const _=(E,S)=>{console.warn(`${le} dropped a place-order attempt: ${S}`),d(I=>X(I,{stall:{kind:E}}))};if(!p.current){_("dropped_no_init","the island has not loaded, so INIT has not been posted");return}if(l.inFlight){_("dropped_in_flight","one is already in flight");return}if(!l.placeOrderEnabled){_("dropped_gate_closed",`cartReady=${l.cartReady} enablementClosed=${l.enablementClosed} charged=${l.charged}`);return}d(E=>X(E,{phase:"requested",failure:null})),k({kind:"PLACE_ORDER"})},[a,l.placeOrderEnabled,l.inFlight,l.cartReady,l.enablementClosed,l.charged,k]),n.jsxs("div",{className:"relative w-full",children:[n.jsx("iframe",{ref:c,title:"Secure payment",src:ti(),allow:"payment",onLoad:w,style:{height:u},className:"w-full border-0"}),l.ready||l.failure!==null?null:n.jsxs("div",{className:"absolute inset-0 grid place-items-center gap-2 bg-surface",children:[n.jsx(tn,{}),n.jsx("p",{className:"text-xs text-text-muted",children:"Loading secure paymentâ¦"})]}),l.inFlight?n.jsxs("output",{className:"absolute inset-0 grid place-items-center gap-2 bg-surface/90",children:[n.jsx(tn,{}),n.jsx("p",{className:"text-xs text-text-muted",children:"Completing your paymentâ¦"})]}):null]})}const Rr="membership_checkout";function mi({orderKey:e}){return n.jsxs("div",{"data-testid":"membership-activating",children:[n.jsx("p",{className:"text-sm leading-normal text-text-strong",children:"Payment received. Your membership is activating and your benefits will turn on shortly â you do not need to pay again or start over."}),e?n.jsxs("p",{className:"mt-3 text-sm leading-normal text-text-muted",children:["Your order number is"," ",n.jsx("span",{className:"font-bold text-text-strong","data-testid":"order-key",children:e}),". Keep it handy if you contact Chegg about this purchase."]}):null]})}function fi({reason:e,codes:t,onRetry:r,onReauthorize:a}){const o=t??[],i=s.useRef(a);return s.useEffect(()=>{i.current=a},[a]),s.useEffect(()=>{e==="auth"&&i.current()},[e]),e==="auth"?n.jsx("output",{className:"block px-8 py-4 text-center text-sm text-text-muted","data-amp-track-surface":"membership_checkout",children:"Reconnecting to checkoutâ¦"}):n.jsxs("div",{role:"alert",className:"rounded-md bg-danger-tint px-4 py-3","data-amp-track-surface":"membership_checkout",children:[n.jsx("p",{className:"text-sm font-semibold text-danger",children:pi(e)}),o.length>0?n.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:["Error c
4ode: ",o.join(", ")]}):null,r===null?null:n.jsx(te,{type:"button",variant:"orange",onClick:r,"data-amp-track-surface":"membership_checkout","data-amp-track-action":"retry_payment","data-amp-track-target":e,className:"mt-3 h-10 w-full rounded-md text-sm font-semibold",children:"Try again"})]})}function pi(e){return e==="declined"?"Your card was declined. Check the details, or use a different card.":e==="server"?"Something went wrong on our side. Please try again.":"Something went wrong while processing your payment. Please try again. If this keeps happening, try a different card."}class hi extends s.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,r){He(t,{context:Rr,componentStack:r.componentStack??""}),console.error("[checkout] payment frame crashed",t)}render(){return this.state.hasError?n.jsx("div",{"data-testid":"checkout-frame-fallback",role:"alert",className:"px-8 py-6 text-center text-sm text-text-muted",children:"We couldn't load the secure payment form. Close this window and try again."}):this.props.children}}function jr(e,t){const r=new Date(t.getTime());return r.setDate(r.getDate()+e),r}function xi(e,t){return new Intl.DateTimeFormat("en-US",{month:"long",day:"numeric",year:"numeric"}).format(jr(e,t))}const xn="h-auto w-full whitespace-normal px-5 py-3 text-center font-bold text-base leading-tight",Nr="w-16",Cr="w-28",Ze="pt-2 pb-1 font-bold text-xs uppercase tracking-label";function gn({on:e,column:t}){return n.jsxs(n.Fragment,{children:[e?n.jsx(As,{className:"size-4 text-purple",strokeWidth:2.25,"aria-hidden":!0}):n.jsx(qe,{className:"size-4 text-text-muted/50",strokeWidth:2,"aria-hidden":!0}),n.jsxs("span",{className:"sr-only",children:[t,": ",e?"included":"not included"]})]})}function gi(){return n.jsxs("figure",{className:"flex flex-col gap-1.5",children:[n.jsx("blockquote",{className:"text-pretty font-serif text-md text-text-strong italic leading-snug",children:`â${Ut.quote}â`}),n.jsxs("figcaption",{className:"text-sm text-text-muted",children:["- ",Ut.attribution]})]})}function bi(){const e=sa;return n.jsxs("div",{className:"grid grid-cols-[1fr_auto_auto] gap-x-3 text-sm",children:[n.jsx("span",{className:`${Ze} text-text-muted`,children:"Features"}),n.jsx("span",{className:`${Nr} ${Ze} text-center text-text-muted`,children:"Free"}),n.jsx("span",{className:`${Cr} ${Ze} rounded-t-lg border border-purple-24 border-b-0 bg-purple-surface px-2 text-center text-purple`,children:"Members"}),e.map((t,r)=>{const a=r===e.length-1;return n.jsx(yi,{row:t,last:a},t.label)})]})}function yi({row:e,last:t}){return n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"border-hairline border-t py-2.5 text-text",children:e.label}),n.jsx("span",{className:`flex ${Nr} items-center justify-center border-hairline border-t py-2.5`,children:n.jsx(gn,{on:e.free,column:"Free"})}),n.jsx("span",{className:`flex ${Cr} items-center justify-center border-purple-24 border-x bg-purple-surface py-2.5 ${t?"rounded-b-lg border-b":""}`,children:n.jsx(gn,{on:e.membership,column:"Members"})})]})}function _i({feature:e,offer:t,onContinue:r,onStartTrial:a}){const o=ra(t);return n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsx("p",{className:"text-center font-bold text-[14px] text-text-strong",children:`${aa.internshipsOnly}/mo. Cancel anytime.`}),r?n.jsxs(n.Fragment,{children:[n.jsx(te,{type:"button",variant:"orange",onClick:r,"data-amp-track-surface":"membership_modal","data-amp-track-action":"continue_checkout","data-amp-track-target":e,className:xn,children:Ft.monthly}),a?n.jsxs(n.Fragment,{children:[n.jsx(te,{type:"button",variant:"orange-outline",onClick:a,...Ss({surface:"membership_modal",target:e,source:"offer_step"}),className:xn,children:Ft[t]}),o?n.jsx("p",{className:"text-center text-sm text-text-muted",children:o}):null]}):null]}):n.jsx("p",{className:"text-center text-sm text-text-muted",children:"Membership isn't available just yet. Please check back soon."})]})}function vi({feature:e,offer:t,onContinue:r,onStartTrial:a}){return n.jsxs("div",{className:"relative flex min-w-0 flex-col gap-4 px-8 py-6 md:px-10 md:py-8",children:[n.jsxs("div",{className:"flex items-start justify-between gap-4",children:[n.jsx("span",{className:"font-bold text-text-muted text-xs uppercase tracking-label",children:"Career membership"}),n.jsx(nr,{"aria-label":"Close","data-amp-track-surface":"membership_modal","data-amp-track-action":"dismiss","data-amp-track-target":e,className:"-m-1 flex rounded-md p-1 text-text-muted outline-none transition-colors hover:bg-surface-raised hover:text-text-strong focus-visible:shadow-focus",children:n.jsx(qe,{className:"size-[18px]",strokeWidth:1.5})})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-x-10",children:[n.jsxs("div",{className:"flex flex-col gap-6",children:[n.jsx(rr,{className:"max-w-[22ch] text-pretty font-bold text-[24px] text-text-strong leading-tight tracking-display",children:na}),n.jsx(ks,{}),n.jsx(_i,{feature:e,offer:t,onContinue:r,onStartTrial:a})]}),n.jsxs("div",{className:"hidden md:flex md:flex-col md:gap-6",children:[n.jsx(gi,{}),n.jsx(bi,{})]})]})]})}function wi({open:e,onOpenChange:t,step:r,onContinue:a,onStartTrial:o,feature:i,offer:c,checkoutOpenedMs:l,checkout:d,entitlementLagged:u,orderKey:m,promoApplied:h}){const g=r==="payment"&&d.status==="ready"&&Sr(d.frameState);return n.jsx(ws,{open:e,onOpenChange:t,children:n.jsxs(Es,{showCloseButton:!1,onEscapeKeyDown:f=>{g&&f.preventDefault()},onInteractOutside:f=>{g&&f.preventDefault()},"aria-describedby":void 0,className:r==="offer"?"grid max-h-[88vh] w-full max-w-[860px] gap-0 overflow-y-auto rounded-[14px] p-0 shadow-modal":`grid max-h-[88vh] max-w-[520px] gap-0 overflow-hidden [@media(max-height:560px)]:overflow-y-auto rounded-xl p-0 shadow-modal ${r==="payment"&&d.status==="ready"?"grid-rows-[auto_minmax(12rem,1fr)_auto]":"grid-rows-[auto_minmax(0,1fr)_auto]"}`,"data-amp-track-surface":"membership_modal",children:[r==="offer"?n.jsx(vi,{feature:i,offer:c,onContinue:a,onStartTrial:o}
4):null,r==="payment"?n.jsx(Ei,{feature:i,checkout:d,dismissible:!g,offer:c,checkoutOpenedMs:l}):null,r==="success"?n.jsx(Si,{feature:i,checkout:d,onOpenChange:t,entitlementLagged:u,orderKey:m,offer:c,checkoutOpenedMs:l,promoApplied:h}):null]})})}function Tr({title:e,feature:t,dismissible:r=!0,align:a="start",eyebrow:o=!0}){return n.jsxs("div",{className:"flex flex-col gap-3 px-8 pt-6 pb-4",children:[n.jsxs("div",{className:U("flex items-start gap-4",o?"justify-between":"justify-end"),children:[o?n.jsx("span",{className:"font-bold text-text-muted text-xs uppercase tracking-label",children:"Career membership"}):null,n.jsx(nr,{"aria-label":"Close",disabled:!r,"data-amp-track-surface":"membership_modal","data-amp-track-action":"dismiss","data-amp-track-target":t,className:"-m-1 flex rounded-md p-1 text-text-muted outline-none transition-colors hover:bg-surface-raised hover:text-text-strong focus-visible:shadow-focus disabled:cursor-not-allowed disabled:text-text-muted/40 disabled:hover:bg-transparent",children:n.jsx(qe,{className:"size-[18px]",strokeWidth:1.5})})]}),n.jsx(rr,{className:U("text-pretty font-bold text-[24px] text-text-strong leading-tight tracking-display",a==="center"&&"text-center"),children:e}),n.jsx("div",{className:"h-px bg-hairline"})]})}function bt({children:e,scrollRef:t}){return n.jsx("div",{ref:t,"data-testid":"step-scroll",className:"overflow-y-auto [@media(max-height:560px)]:overflow-visible",children:e})}function Ar({children:e}){return n.jsx("div",{className:"border-t border-hairline bg-surface px-8 pb-6 pt-5",children:e})}function Ei({feature:e,checkout:t,dismissible:r,offer:a,checkoutOpenedMs:o}){const i=t.status==="ready"&&!t.frameState?.enablementClosed;return n.jsxs(n.Fragment,{children:[n.jsx(Tr,{title:oa(a),feature:e,dismissible:r,align:"center",eyebrow:!i}),t.status==="unavailable"?n.jsx(bt,{children:n.jsx(ji,{reason:t.reason,onRetry:t.onRetry})}):n.jsx(ki,{feature:e,checkout:t,offer:a,checkoutOpenedMs:o})]})}function ki({feature:e,checkout:t,offer:r,checkoutOpenedMs:a}){const{recurlyCart:o,frame:i,frameState:c,promoPreview:l,onPlaceOrder:d,onRetry:u,onReauthorize:m}=t,h=c?.failure??null,g=c?.unconfirmed??!1,f=h===null&&!g&&d!==null,p=(c?.placeOrderEnabled??!1)&&!c?.inFlight?u:null,b=s.useRef(null);s.useEffect(()=>{const y=b.current;if(!y)return;const k=requestAnimationFrame(()=>{y.scrollTop=0;const O=y.closest('[data-amp-track-surface="membership_modal"]');O&&(O.scrollTop=0)});return()=>cancelAnimationFrame(k)},[]);const j=s.useRef(null),R=s.useRef(null);return s.useEffect(()=>{if(!h&&!g)return;(j.current??R.current)?.scrollIntoView({block:"nearest"})},[h,g]),n.jsxs(n.Fragment,{children:[n.jsxs(bt,{scrollRef:b,children:[n.jsx("div",{className:"px-8 pt-5",children:n.jsx(hi,{children:i})}),h?n.jsx("div",{ref:j,className:"px-8 pt-4",children:n.jsx(fi,{reason:h.reason,codes:h.codes,onRetry:p,onReauthorize:m})}):null,g?n.jsx("div",{ref:R,className:"px-8 pt-4",children:n.jsx("p",{role:"alert",className:"rounded-md bg-danger-tint px-4 py-3 text-sm text-danger",children:"We could not confirm your order. Your card may have been charged, so please don't place it again. Check your email for a receipt, and contact Chegg support if one doesn't arrive."})}):null,n.jsx("div",{className:"h-5"})]}),c?.enablementClosed?null:n.jsxs(Ar,{children:[n.jsx(Or,{recurlyCart:o,testId:"rosca-disclosure",offer:r,checkoutOpenedMs:a,promoPreview:l}),f?n.jsx(te,{type:"button",variant:"orange",onClick:d,disabled:!c?.placeOrderEnabled||c.inFlight,"data-amp-track-surface":"membership_checkout","data-amp-track-action":"place_order","data-amp-track-target":e,className:"mt-4 h-12 w-full rounded-md text-base font-semibold",children:c?.inFlight?"Placing your orderâ¦":"Place order"}):null]})]})}function Si({feature:e,checkout:t,onOpenChange:r,entitlementLagged:a,orderKey:o,offer:i,checkoutOpenedMs:c,promoApplied:l}){return n.jsxs(n.Fragment,{children:[n.jsx(Tr,{title:a?"Payment received":"You're a member",feature:e}),n.jsx(bt,{children:n.jsxs("div",{className:"px-8 pb-5 pt-5",children:[a?n.jsx(mi,{orderKey:o}):n.jsx("p",{className:"text-sm leading-normal text-text-strong",children:"Your order is placed and a receipt is on its way to your email. Your benefits turn on once Chegg finishes setting up your membership, which usually takes a moment."}),t.recurlyCart?n.jsx("div",{className:"mt-4",children:n.jsx(Or,{recurlyCart:t.re
4curlyCart,testId:"success-terms",lead:"It renews at",offer:i,checkoutOpenedMs:c,promoApplied:l})}):null]})}),n.jsx(Ar,{children:n.jsx(te,{type:"button",variant:"orange",onClick:()=>r(!1),"data-amp-track-surface":"membership_checkout","data-amp-track-action":"dismiss","data-amp-track-target":e,className:"h-12 w-full rounded-md text-base font-semibold",children:"Done"})})]})}function Je(){return n.jsx("a",{...Wn({surface:"membership_checkout"}),className:"whitespace-nowrap underline hover:text-text-strong",children:"Cancel anytime"})}function Or({recurlyCart:e,testId:t,lead:r,offer:a,checkoutOpenedMs:o,promoPreview:i,promoApplied:c}){const l=Ci[ca.soldBillingPeriod],d=me[a];if(Ae(a))return n.jsxs("div",{"data-testid":t,className:"text-center text-xs leading-normal text-text-muted",children:[n.jsxs("p",{className:"text-md font-bold tracking-tight text-text-strong",children:[ia(a)," for the first ",d.introDays," days"]}),n.jsxs("p",{className:"mt-1.5",children:["Then your membership renews at ",Xe," ",l.per," ","starting"," ",xi(d.introDays,new Date(o)),", until you cancel. ",n.jsx(Je,{})]})]});if(i)return n.jsxs("div",{"data-testid":t,className:"text-center text-xs leading-normal text-text-muted",children:[n.jsxs("p",{className:"text-md font-bold tracking-tight text-text-strong",children:[Ti(i.total)," for your first month"]}),n.jsxs("p",{className:"mt-1.5",children:["Then ",Xe," ",l.per,", until you cancel."," ",n.jsx(Je,{})]})]});const u=c?Xe:Ai(e);return n.jsxs("div",{"data-testid":t,className:"text-center text-xs leading-normal text-text-muted",children:[n.jsxs("p",{className:"text-md font-bold tracking-tight text-text-strong",children:[r?`${r} `:"",u," ",l.per]}),n.jsxs("p",{className:"mt-1.5",children:["Your membership renews ",l.every," until you cancel."," ",n.jsx(Je,{})]})]})}const Ri={reconnect_failed:"restart_checkout",checkout_unreachable:"retry_preview",price_unavailable:"retry_preview",price_pending:"retry_preview",plan_missing:"retry_preview",plan_currency_unsupported:"retry_preview",plan_amount_unusable:"retry_preview",already_member:"retry_preview",missing_api_key:"retry_preview",missing_endpoints:"retry_preview",not_signed_in:"retry_preview",session_expired:"retry_preview"};function ji({reason:e,onRetry:t}){return n.jsxs("div",{"data-testid":"checkout-unavailable",role:"alert",className:"px-8 pb-6 pt-5 text-center text-sm leading-normal text-text-muted",children:[Ni[e],t?n.jsx("div",{className:"mt-4",children:n.jsx(te,{type:"button",variant:"orange",size:"lg",onClick:t,"data-amp-track-surface":"membership_checkout","data-amp-track-action":Ri[e],"data-amp-track-target":e,children:"Try again"})}):null]})}const Ni={not_signed_in:"Sign in to your Chegg account to finish joining.",session_expired:"Your session expired. Sign in again to finish joining.",missing_api_key:"Checkout isn't available right now. Please try again in a few minutes.",missing_endpoints:"Checkout isn't available right now. Please try again in a few minutes.",price_pending:"Loading secure checkoutâ¦",checkout_unreachable:"We're having trouble reaching checkout.",reconnect_failed:"We lost the connection to checkout.",already_member:"You're already a member. Your membership is active, so there's nothing to buy here.",price_unavailable:"We couldn't get today's price. Please try again in a moment.",plan_missing:"Checkout isn't available right now. Please try again in a few minutes.",plan_amount_unusable:"Checkout isn't available right now. Please try again in a few minutes.",plan_currency_unsupported:"Membership isn't available in your country yet."},Ci={monthly:{per:"per month",every:"every month"},annual:{per:"per year",every:"every year"}};function Ti(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(e)}function Ai(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:e.orderSummary.currencyName}).format(e.orderSummary.total)}const Oi=`mutation PreviewPurchase($previewPurchaseInput: PreviewPurchaseInput!) { 5 previewPurchase(previewPurchaseInput: $previewPurchaseInput) { 6 currency 7 price 8 subTotal 9 tax 10 taxInfo { rate region type } 11 totalAmount 12 totalDiscount 13 } 14}`;function Ii(e){return e.orderSummary.total<=0}const Pi="INTERNSHIPS";function et(e,t){return t!=="USD"||e===null?null:e===0?"0":`$${e.toFixed(2)}`}function Ir(e){const{preview:t,currency:r,planCode:a}=e,o=Number(t.subTotal),i=Number(t.totalAmount),{tax:c,totalDiscount:l}=t,d=et(c,r),u=et(o,r);return{orderSummary:{subtotal:o,discount:l,tax:c,total:i,totalWithCurrencyFormat:et(i,r),subtotalWithCurrencyFormat:u,taxWithCurrencyFormat:d,currencyName:r,taxDetails:{tax:c,taxWithCurrencyFormat:d,label:null},orderGiftCodeBalance:0,totalCoveredByScholarship:!1},items:[{catalogItemId:a,pricingId:r,quantity:1,productType:Pi,c
14atalogItemSource:"RECURLY"}],cartId:crypto.randomUUID(),externalId:a,subtotalWithCurrencyFormat:u}}function je(e){return e===null?null:typeof e=="number"&&Number.isFinite(e)?e:void 0}async function Pr(e){if(!e.idToken&&!e.accessToken)return{ok:!1,failure:{reason:"not_signed_in"}};const t={"content-type":"application/json","apollographql-client-name":e.clientName};e.idToken&&(t.id_token=e.idToken),e.accessToken&&(t.access_token=e.accessToken);let r;try{r=await(e.fetchImpl??fetch)(e.graphQLUrl,{method:"POST",headers:t,credentials:"omit",body:JSON.stringify({operationName:"PreviewPurchase",query:Oi,variables:{previewPurchaseInput:{currency:e.currency,planCode:e.planCode,...e.billingAddress?{billingAddress:e.billingAddress}:{},...e.promotionCode?{promotionCode:[e.promotionCode]}:{}}}})})}catch(h){return{ok:!1,failure:{reason:"network",detail:h instanceof Error?h.message:String(h)}}}let a;try{a=await r.json()}catch(h){return{ok:!1,failure:{reason:"malformed",detail:`HTTP ${r.status}, body was not JSON (${h instanceof Error?h.message:String(h)})`}}}const o=a,i=o?.errors;if(Array.isArray(i)&&i.length>0){const h=i.map(g=>`${String(g?.extensions?.code??"")} ${g?.message??""}`.trim()).join(" | ");return/already have a subscription/i.test(h)?{ok:!1,failure:{reason:"already_subscribed",detail:h}}:{ok:!1,failure:{reason:"rejected",detail:h}}}const c=o?.data?.previewPurchase;if(!c||typeof c!="object")return{ok:!1,failure:{reason:"malformed",detail:`HTTP ${r.status}, no previewPurchase in the response`}};const l=je(c.subTotal),d=je(c.totalAmount),u=je(c.tax),m=je(c.totalDiscount);return l==null||d===void 0||d===null||u===void 0||m===void 0?{ok:!1,failure:{reason:"malformed",detail:`previewPurchase amounts were not numbers: ${JSON.stringify(c)}`}}:{ok:!0,preview:{subTotal:l,totalAmount:d,tax:u,totalDiscount:m}}}const ze="USD",Mi=15e3,Mr="internships-web";function Di(e){const t=me[e].planPrice;return Ir({preview:{subTotal:t,totalAmount:t,tax:0,totalDiscount:0},currency:ze,planCode:me[e].planCode})}function Ne(e){e.current!==null&&(clearTimeout(e.current),e.current=null)}function Li(e){const{authorization:t,enabled:r,attempt:a=0,offer:o=ue}=e,[i,c]=s.useState({status:"idle"}),l=s.useRef(null),d=s.useRef(0),u=s.useRef(null),m=s.useRef(null);return s.useEffect(()=>{if(!r||!t||l.current===a)return;if(l.current=a,la){c({status:"ready",recurlyCart:Di(o)});return}const h=me[o].planCode;d.current+=1;const g=d.current;u.current=g,Ne(m),c({status:"loading"}),m.current=setTimeout(()=>{u.current===g&&(u.current=null,m.current=null,c({status:"failed",failure:{reason:"timeout"}}))},Mi),(e.fetchPreview??Pr)({graphQLUrl:t.cheggGraphQLUrl,clientName:Mr,idToken:t.idToken,accessToken:t.accessToken,planCode:h,currency:ze}).then(f=>{u.current===g&&(u.current=null,Ne(m),c(f.ok?{status:"ready",recurlyCart:Ir({preview:f.preview,currency:ze,planCode:h})}:{status:"failed",failure:f.failure}))})},[t,r,a,o,e.fetchPreview]),s.useEffect(()=>{r||(l.current=null,u.current=null,Ne(m),c({status:"idle"}))},[r]),s.useEffect(()=>()=>{u.current=null,Ne(m)},[]),i}function Fi(e=Hn){const{cheggBaseUrl:t,cheggGraphQLUrl:r,useBFF:a}=e;if(typeof t!="string"||t.trim()===""||typeof r!="string"||r.trim()===""||typeof a!="boolean")throw new Error(`Chegg commerce endpoints are not configured for stage "${e.stage}". Add cheggBaseUrl, cheggGraphQLUrl and useBFF to src/config/config.${e.stage}.ts, with values confirmed against chegg-web's config for that stage. Do not derive the prod pair from the nonprod one: the host differs and so does the GraphQL path.`);return{cheggBaseUrl:t,cheggGraphQLUrl:r,useBFF:a}}function Ui(e=Hn){const t=e.dipApiKey;if(typeof t!="string"||t.trim()==="")throw new Error(`DIP apiKey is not configured for stage "${e.stage}". Add dipApiKey to src/config/config.${e.stage}.ts once GCE issues a key for that stage. Do not substitute an empty string: checkout-sdk would send it as the Basic auth credential on every call.`);return t}const Dr=6e4,Bi=2147483647,$i=8e3;function Lr(e){return Number.isFinite(e)?Math.min(Math.max(e,0),Bi):0}function zi(e,t){if(t!==void 0&&!(t<=e))return Lr(t-Dr-e)}function Ki(){let e;try{e=Ui()}catch{return{status:"unavailable",reason:"missing_api_key"}}let t;try{t=Fi()}catch{return{status:"unavailable",reason:"missing_endpoints"}}const r=at(ma)??"",a=at(fa)??"";return r===""&&a===""?{status:"unavailable",reason:"not_signed_in"}:{status:"ready",authorization:{apiKey:e,idToken:r,accessToken:a,...t}}}const bn=5;function Ce(){return{session:Ki(),expiresAtMs:ua(at(da))}}function Wi(e,t){if(e.session.status!=="ready"||t.session.status!=="ready")return t;const r=e.session.authorization,a=t.session.authorization;return r.idToken!==a.idToken||r.accessToken!==a.accessToken?t:e.expiresAtMs===t.expiresAtMs?e:{session:e.session,expiresAtMs:t.expiresAtMs}}function Hi(e){const{enabled:t}=e,[r,a]=s.useState(Ce),[o,i]=s.useState(null),[c,l]=s.useState(t),d=s.useRef(null),u=s.useRef(null),m=s.useRef(null),h=s.useRef(0),g=s.useRef(!0);s.useEffect(()=>(g.current=!0,()=>{g.current=!1}),[]);const f=s.useRef(t);s.useEffect(()=>{f.current=t},[t]);const p=s.useCallback(()=>{a(w=>Wi(w,Ce()))},[]),b=s.useRef(()=>{}),j=s.useCallback(w=>{if(u.current===w)return{state:"joined",settled:m.current??Promise.resolve()};if(d.current===w||h.current>=bn)return{state:"spent"};h.current+=1,d.current=w,u.current=w;const N=(async()=>{try{await fetch(se("/api/auth/refresh"),{method:"POST",credentials:"include",signal:AbortSignal.timeout($i)}),qn()}catch{}u.current=null,m.current=null})();return m.current=N,{state:"started",settled:N}},[]);t!==c&&(l(t),t&&p());const R=r.session.status==="ready"?r.session.authorization.accessToken:null,y=R!==null&&o===R;s.useEffect(()=>{if(!t||De()||r.session.status!=="ready")return;if(y)return document.addEventListener("visibilitychange",p),window.addEventListener("focus",p),()=>{document.removeEventListener("visibilitychange",p),window.removeEventListener("focus",p)};const w=r.session.authorization.accessToken,N=r.expiresAtMs;let _,E=!1,S=!1;const I=()=>{g.current&&(f.current&&p(),!S&&(B(),A()))};b.current=I;const Y=()=>d.current===w||h.current>=bn,B=()=>
14{if(E||S)return;const F=Date.now(),q=N===void 0?void 0:N-Dr;if(!(w===""||q!==void 0&&F>=q))return;const Q=j(w);if(Q.state==="started"){Q.settled.then(I);return}Q.state!=="joined"&&N!==void 0&&F>=N&&(E=!0,i(w))},A=()=>{if(E||S||N===void 0||u.current===w)return;const F=Date.now(),q=Y()?Lr(N-F):zi(F,N)??0;_!==void 0&&clearTimeout(_),_=setTimeout(()=>{B(),A()},q)};B(),A();const $=w===""&&N===void 0?p:B;return document.addEventListener("visibilitychange",$),window.addEventListener("focus",$),()=>{S=!0,_!==void 0&&clearTimeout(_),document.removeEventListener("visibilitychange",$),window.removeEventListener("focus",$)}},[t,r,y,p,j]);const k=s.useCallback(async()=>{if(De())return!1;const w=Ce();if(w.session.status!=="ready")return!1;const N=w.session.authorization.accessToken,_=j(N);if(_.state==="spent")return!1;await _.settled,b.current();const E=Ce();if(E.session.status!=="ready")return!1;const S=E.session.authorization.accessToken;return S!==""&&S!==N},[j]),O=s.useMemo(()=>r.session.status==="ready"?{...r.session,refresh:k}:r.session,[r.session,k]);return y?{status:"unavailable",reason:"session_expired"}:O}function qi(e){const{authorization:t,offer:r,promoCode:a}=e,[o,i]=s.useState(null),c=s.useRef(null),l=s.useRef(t);return l.current=t,s.useEffect(()=>{c.current=a,i(null);const d=l.current;if(!a||!d)return;let u=!1;return Pr({graphQLUrl:d.cheggGraphQLUrl,clientName:Mr,idToken:d.idToken,accessToken:d.accessToken,planCode:me[r].planCode,currency:ze,promotionCode:a}).then(m=>{if(u||c.current!==a||!m.ok)return;const{totalAmount:h,totalDiscount:g}=m.preview;(g??0)<=0||i({code:a,total:h})}),()=>{u=!0}},[!!t,r,a]),o}const Gi=3e4,Vi=2e3;async function Yi(e){const t=e.windowMs??Gi,r=e.intervalMs??Vi;if(await yn(e),_n(e))return"entitled";let a=0;for(let o=0;o<t;o+=r)if(await e.wait(r),a+=1,(a&a-1)===0&&await yn(e),_n(e))return"entitled";return"lagged"}async function yn(e){try{await e.refreshAccessToken()}catch{}}function _n(e){try{return e.isEntitled()}catch{return!1}}const Qi=1e4;function Xi(){return{refreshAccessToken:()=>fetch(se("/api/auth/refresh"),{method:"POST",credentials:"include",signal:AbortSignal.timeout(Qi)}).finally(qn),isEntitled:()=>pa(ha()),wait:e=>new Promise(t=>{setTimeout(t,e)})}}const vn={[_a]:"monthly",[ya]:"trial3d",[ba]:"trial7dFree",[ga]:"trial14dFree",[xa]:"trial7d"};function Zi(e){if(!Object.hasOwn(vn,e.variant))return{offer:ue};const t=vn[e.variant];return e.hasEverTrialled&&Gn(t)?{offer:ue}:{offer:t}}const Ji="purchase_success";function ec(){return typeof window>"u"?!1:mt&&!ne()}function tc(){if(!ec())return;const e=window;e.dataLayer=e.dataLayer??[],e.dataLayer.push({event:Ji})}const nc=15e3,rc=1,ac=new Set(["already_member","session_expired","not_signed_in"]),sc=new Set(["network"]),oc=new Set(["price_unavailable","checkout_unreachable","already_member"]);class ic extends Error{constructor(t,r){super(`${t}: ${r}`),this.name=`${t}/${r}`}}const cc=1e4;function Te(e,t,r,a={}){const o={reason:t,offer:r.offer,feature:r.feature,fault:r.fault,give_up_cause:r.giveUpCause??"none",context:Rr,...a},i=r.fault?new ic(e,t):null;let c=!1;const l=()=>{c||(c=!0,Oe(e,o),i&&He(i,o))};va(l),!c&&setTimeout(l,cc)}function lc({children:e}){const[t,r]=s.useState(null),[a,o]=s.useState("offer"),[i,c]=s.useState(()=>Date.now()),[l,d]=s.useState(!1),u=De(),[m,h]=s.useState(null),[g,f]=s.useState(0),[p,b]=s.useState(null),[j,R]=s.useState("idle"),y=s.useRef(null),[k,O]=s.useState(null),w=s.useCallback(v=>{O(T=>T??v)},[]),N=s.useRef(null);s.useEffect(()=>{N.current=k},[k]);const _=s.useRef(0),E=s.useRef(0),S=Be(Bt)==="on",{isMember:I,isLoading:Y,tier:B}=ht(),A=ar(),$=s.useRef("unknown");!Y&&!A.isLoading&&($.current=Rs({tier:B,trialPhase:A.phase,trialKind:A.kind}));const{offer:F}=Zi({variant:Be($t),hasEverTrialled:A.hasEverTrialled||!A.hasEverTrialledKnown&&!A.hasEverTrialledErrored}),Z=!u&&!l?F:ue,[Q,H]=s.useState(null),x=Q??Z,J=u?Os():null,M=Hi({enabled:t!==null&&a==="payment"}),[G,oe]=s.useState(0),_e=s.useCallback(()=>oe(v=>v+1),[]),Et=qi({authorization:M.status==="ready"?M.authorization:null,offer:x,promoCode:m?.promoCode??null}),z=Li({authorization:M.status==="ready"?M.authorization:null,enabled:t!==null&&a==="payment",attempt:G,offer:x}),ve=s.useCallback(()=>{h(null),O(null),_.current=0,E.current+=1},[]),we=s.useCallback((v,T)=>{r(v);const D=T?.startAt==="payment",re=D?T?.beginWithOffer:void 0;o(T?.startAt??"offer"),d(D&&!re),H(re??null),c(Date.now()),ve(),b(null),R("idle"),ct(Bt),(!D||re)&&ct($t),T?.skipViewedEvent||C("membership_modal_viewed",{feature:v,membershipStatus:$.current}),D&&C("membership_checkout_started",{feature:v,offer:re??ue})},[ve]),Ee=s.useCallback(v=>!(u&&mt)&&S&&!I&&!A.isActive&&!Y,[u,S,I,Y,A.isActive]),kt=s.useCallback((v,T)=>{Ee(v)?we(v):T()},[Ee,we]),St=s.useCallback(v=>{if(t&&C("membership_checkout_started",{feature:t,offer:v}),u){J&&Is(J);return}H(v),o("payment")},[t,u,J]),Ve=s.useCallback(()=>{f(v=>v+1)},[]),Rt=s.useCallback(v=>{if(y.current===v)return;if(y.current=v,o("success"),b(v),t&&C("membership_checkout_completed",{feature:t,offer:x,promoApplied:!!m?.promoCode,membershipTier:$n}),Ae(x)){const D=jr(me[x].introDays,new Date(i)).toISOString();A.recordTrialEnd(D).then(({justRecorded:re})=>{re&&C("trial_started",{trialKind:"recurly",offer:x})},()=>{})}const T=t;Yi(Xi()).then(D=>{y.current===v&&(R(D),D==="lagged"&&T&&C("membership_entitlement_lag",{feature:T}))}),tc()},[t,x,i,A,m]),ke=M.status==="ready"?M.refresh:null,jt=s.useCallback(()=>
14{if(_.current+=1,_.current>rc||!ke){w(ke?"reconnect":"reissue_refused");return}const v=E.current;ke().then(T=>{T||v!==E.current||w("reissue_refused")})},[ke,w]),Nt=s.useRef(null);s.useEffect(()=>{M.status==="ready"&&(Nt.current=M.authorization)},[M]);const Ct=s.useRef(null);s.useEffect(()=>{z.status==="ready"&&(Ct.current=z.recurlyCart)},[z]);const Tt=m!==null&&(m.charged||m.inFlight||m.outcomeUnknown),V=m?.failure??null;s.useEffect(()=>{!V||!t||C("membership_checkout_failed",{feature:t,reason:V.reason})},[V,t]),s.useEffect(()=>{if(!V||!t)return;const v=V.reason!=="declined"&&V.reason!=="auth",T=V.kind??"dip_reported";Te("checkout_failed",V.reason,{offer:x,feature:t,fault:v,giveUpCause:N.current},{failure_kind:T})},[V,t,x]);const Se=m?.stall??null;s.useEffect(()=>{if(!Se||!t)return;const v=Se.kind!=="dropped_in_flight",T=Se.kind;Te("checkout_failed","stalled",{offer:x,feature:t,fault:v,giveUpCause:N.current},{failure_kind:T})},[Se,t,x]);const At=m?.unconfirmed??!1,Re=m?.charged??!1,Ot=m?.outcomeUnknown??!1,It=s.useRef(null);s.useEffect(()=>{if(!At||!t)return;const v=It.current;v?.nonce===g&&(v.charged||!Re)||(It.current={nonce:g,charged:Re},Te("checkout_failed","outcome_unknown",{offer:x,feature:t,fault:!0,giveUpCause:N.current},{failure_kind:"outcome_unknown",charged:Re,outcome_unknown:Ot}))},[At,Re,Ot,g,t,x]),s.useEffect(()=>{if(V?.reason!=="auth")return;const v=setTimeout(()=>w("reconnect"),nc);return()=>clearTimeout(v)},[V,w]);const pe=s.useMemo(()=>{const v=z.status==="ready"?z.recurlyCart:Ct.current??void 0,T=k!==null||M.status==="unavailable",D=M.status==="ready"?M.authorization:Nt.current;if(T&&!(Tt&&D!==null)){const ce=M.status==="unavailable"?M.reason:k==="reconnect"?"reconnect_failed":"session_expired";return{status:"unavailable",reason:ce,recurlyCart:v,onRetry:ce==="reconnect_failed"?ve:null}}if(z.status==="idle"||z.status==="loading")return{status:"unavailable",reason:"price_pending",recurlyCart:v};if(z.status==="failed"||!v){let ce="price_unavailable",Ye=!1;if(z.status==="failed"){const Qe=z.failure.reason;Qe==="already_subscribed"?ce="already_member":Qe==="timeout"?(ce="checkout_unreachable",Ye=!0):Qe==="network"&&(Ye=!0)}return{status:"unavailable",reason:ce,onRetry:Ye?_e:null}}return D===null?{status:"unavailable",reason:"session_expired",recurlyCart:v}:{status:"ready",recurlyCart:v,frame:n.jsx(di,{authorization:D,recurlyCart:v,allowsZeroAmount:Gn(x)||Ae(x)&&Ii(v),placeOrderNonce:g,onStateChange:h,onOrderPlaced:Rt}),frameState:m,promoPreview:Et,onPlaceOrder:T?null:Ve,onRetry:T?null:Ve,onReauthorize:jt}},[x,z,Et,_e,k,M,Tt,g,m,Rt,Ve,jt,ve]),ie=pe.status==="unavailable"?pe.reason:null,Pt=pe.status==="unavailable"&&pe.onRetry!=null,Mt=z.status==="failed"?z.failure.reason:null;s.useEffect(()=>{if(a!=="payment"||t===null||ie===null||ie==="price_pending")return;const v=oc.has(ie)?Mt??"none":"none",T=N.current,D=!ac.has(ie)&&!sc.has(v)||T==="reissue_refused";Te("checkout_unavailable",ie,{offer:x,feature:t,fault:D,giveUpCause:T},{preview_failure:v,retryable:Pt})},[a,t,x,ie,Pt,Mt]);const Yr=s.useMemo(()=>({openPaywall:we,requireMembership:kt,isPaywalled:Ee,isEnforced:S,offer:x}),[we,kt,Ee,S,x]);return n.jsxs(_s.Provider,{value:Yr,children:[e,n.jsx(wi,{open:t!==null,step:a,offer:x,checkoutOpenedMs:i,onOpenChange:v=>{!v&&a==="payment"&&Sr(m)||v||(r(null),d(!1),H(null))},onContinue:!u||J?(()=>St(ue)):null,onStartTrial:!u&&Ae(x)?()=>St(x):null,feature:t??void 0,checkout:pe,entitlementLagged:j==="lagged",orderKey:p??void 0,promoApplied:!!m?.promoCode})]})}function wn({id:e,label:t,value:r,onChange:a,placeholder:o,queryKey:i,fetchSuggestions:c}){const[l,d]=s.useState(!1),[u,m]=s.useState(-1),h=s.useId(),g=r.trim(),f=ee({queryKey:[i,g],queryFn:()=>c(g),staleTime:5*6e4,enabled:l}),p=f.data??[],b=f.isFetching,j=l&&(p.length>0||b),R=y=>{a(y.replace(/\s+/g," ").trim()),d(!1),m(-1)};return n.jsxs("label",{className:"ftux-rv-field",htmlFor:e,children:[n.jsx("span",{className:"ftux-rv-label",children:t}),n.jsxs(or,{open:j,onOpenChange:y=>!y&&d(!1),children:[n.jsx(Ps,{asChild:!0,children:n.jsx("input",{id:e,type:"text",role:"combobox","aria-expanded":j,"aria-controls":h,"aria-autocomplete":"list",autoComplete:"off",className:"ftux-rv-input",placeholder:o,value:r,onChange:y=>{a(y.target.value),d(!0),m(-1)},onFocus:()=>d(!0),onKeyDown:y=>{y.key==="ArrowDown"?(y.preventDefault(),d(!0),m(k=>Math.min(k+1,p.length-1))):y.key==="ArrowUp"?(y.preventDefault(),m(k=>Math.max(k-1,0))):y.key==="Enter"?u>=0&&p[u]&&(y.preventDefault(),R(p[u].label)):y.key==="Escape"&&(d(!1),m(-1))}})}
14),n.jsx(ir,{align:"start",sideOffset:6,onOpenAutoFocus:y=>y.preventDefault(),onCloseAutoFocus:y=>y.preventDefault(),className:"border-0 bg-transparent p-0 shadow-none",style:{width:"var(--radix-popover-trigger-width)"},children:n.jsxs("div",{id:h,role:"listbox",className:"max-h-64 overflow-y-auto rounded-xl border border-hairline bg-popover p-1 shadow-lg",children:[p.map((y,k)=>n.jsxs("button",{type:"button",role:"option","aria-selected":k===u,className:`flex w-full flex-col items-start gap-0.5 rounded-lg px-3 py-2 text-left ${k===u?"bg-surface-raised":""} hover:bg-surface-raised`,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>m(k),onClick:()=>R(y.label),children:[n.jsx("span",{className:"text-sm font-medium text-text-strong",children:y.label}),y.sublabel?n.jsx("span",{className:"text-xs text-text-muted",children:y.sublabel}):null]},y.label)),b&&p.length===0?n.jsx("div",{className:"px-3 py-2 text-xs text-text-muted",children:"Searchingâ¦"}):null]})})]})]})}function uc({onSubmit:e,onSkip:t,submitting:r=!1}){const a=s.useId(),o=s.useId(),[i,c]=s.useState(""),[l,d]=s.useState(""),u=i.trim().length>0&&l.trim().length>0&&!r,m=s.useCallback(f=>wa(f,8).map(p=>({label:p.label})),[]),h=s.useCallback(async f=>(await Ea({data:{query:f,limit:8}})).map(b=>({label:b.label,sublabel:[b.city,b.state].filter(Boolean).join(", ")||void 0})),[]),g=f=>{f.preventDefault(),u&&e({school:i.trim(),major:l.trim()})};return n.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-background text-foreground","aria-busy":r,children:n.jsx("div",{className:"mx-auto flex min-h-full w-full max-w-md flex-col justify-center px-6 py-12",children:n.jsxs("form",{onSubmit:g,"aria-label":"Tell us what you study",className:"flex flex-col gap-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"ftux-h1",children:"What do you study?"}),n.jsx("p",{className:"ftux-sub",children:"Tell us your university and major and we'll line up internships that fit â no filters, just a head start."})]}),n.jsx(wn,{id:o,label:"Major",value:l,onChange:d,placeholder:"e.g. Computer Science",queryKey:"major-suggestions",fetchSuggestions:m}),n.jsx(wn,{id:a,label:"University",value:i,onChange:c,placeholder:"e.g. UCLA",queryKey:"school-suggestions",fetchSuggestions:h}),n.jsxs("div",{className:"mt-1 flex flex-col gap-2",children:[n.jsx(te,{type:"submit",variant:"orange",size:"lg",disabled:!u,children:r?"Finding internshipsâ¦":"Show me internships"}),n.jsx(te,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:r,children:"Skip for now"})]})]})})})}async function dc({major:e,school:t}){await Ds({data:{major:e.trim()||void 0,school:t?.trim()||void 0}})}function mc({variantId:e,trackedEntryPoint:t}){C("ftux_manual_intake_started",{source:"welcome_modal",entry_point:e}),C("ftux_step_skipped",{step:"upload",source:"welcome_modal",reason:"manual_intake",entry_point:t})}const yt="embed_intake";function fc(){C("major_seed_prompt_shown",{source:yt})}function pc(){C("major_seed_prompt_submitted",{source:yt})}function hc(){C("major_seed_prompt_skipped",{source:yt})}const xc=1e3;function gc(){try{return window.sessionStorage}catch{return null}}function bc(){return{enabled:!0,storage:gc(),now:Date.now,resolveSendMessage:ka,announce:e=>Sa(document,window,e),report:({outcome:e,waitedMs:t})=>{C("extension_install_handoff",{outcome:e,waitedMs:t}),e==="gave_up"&&!mt&&console.warn("[chegg] install handoff gave up: the extension never answered. Check that this origin is in the extension's externally_connectable matches, and that localStorage['chegg:ext_id_override'] is set when testing an unpacked build.")}}}function yc(e){const t=s.useRef(e);t.current=e,s.useEffect(()=>{if(typeof window>"u")return;const r={...bc(),...t.current};if(!r.enabled)return;const a=r.storage;if(!a)return;let o=!1,i=null,c=!1,l=0,d=!1;const u=()=>{i!==null&&(window.clearInterval(i),i=null)},m=f=>{ja(a),u(),!c&&(c=!0,r.report({outcome:f,waitedMs:r.now()-l}))},h=()=>{if(o||d)return;if(!Kt(a,r.now())){m("gave_up");return}const f=r.resolveSendMessage();f&&(d=!0,Ra({sendMessage:f}).then(p=>{d=!1,!(o||!p)&&(p.version&&r.announce(p.version),p.claimed&&m("claimed"))}))},g=()=>{o||i!==null||Kt(a,r.now())&&(l=r.now(),c=!1,i=window.setInterval(h,xc))};return g(),window.addEventListener(zt,g),()=>{o=!0,u(),window.removeEventListener(zt,g)}},[])}function _c(){const e=s.useRef(!1);s.useEffect(()=>{e.current||(e.current=!0,Na())},[])}const Fr=s.createContext({resolve:()=>null});function vc({children:e}){const t=s.useRef(null),r=s.useCallback(a=>t.current?t.current.querySelector(`[data-anchor="${a}"]`):null,[]);return n.jsx(Fr.Provider,{value:{resolve:r},children:n.jsx("div",{ref:t,className:"contents",children:e})})}function wc(){return s.useContext(Fr)}function Ec(e){return/[\t\n\r]/.test(e)?!1:e.startsWith("/")&&!e.startsWith("//")&&!e.startsWith("/\\")}const Pe="chegg-jobs-embed";function tt(e,t){return e==="route-change"?{source:Pe,type:e,path:t?.path??""}:e==="height"?{source:Pe,type:e,height:t?.height??0}:{source:Pe,type:"ready"}}const kc=new Set(["www.chegg.com","trunk.live.test.cheggnet.com","local.live.test.cheggnet.com","localhost"]);
14function En(e,t){try{if(e){const r=new URL(e);if(r.origin===t||r.protocol==="https:"&&kc.has(r.hostname))return r.origin}}catch{}return t}const kn="embed:origin";function Ur(){if(typeof window>"u"||!window.location)return"";const e=window.location.origin;let t=null;try{t=new URLSearchParams(window.location.search).get("embedOrigin")}catch{t=null}if(t){const r=En(t,e);if(r!==e){try{window.sessionStorage.setItem(kn,r)}catch{}return r}}try{const r=window.sessionStorage.getItem(kn);if(r)return En(r,e)}catch{}return e}function Sc(e){if(typeof window>"u"||e.source!==window.parent)return null;const t=Ur();if(e.origin!==t)return null;const r=e.data;return!r||r.source!==Pe||r.type!=="navigate"?null:typeof r.to=="string"&&Ec(r.to)?r.to:null}function nt(e){typeof window>"u"||window.parent!==window&&window.parent.postMessage(e,Ur())}function Rc(){const e=Ge({select:r=>r.location.pathname}),t=be();return s.useEffect(()=>{nt(tt("ready"))},[]),s.useEffect(()=>{const r=a=>{const o=Sc(a);o&&t({to:o})};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[t]),s.useEffect(()=>{nt(tt("route-change",{path:e}))},[e]),s.useEffect(()=>{if(typeof ResizeObserver>"u")return;const r=()=>nt(tt("height",{height:document.documentElement.scrollHeight})),a=new ResizeObserver(r);return a.observe(document.documentElement),r(),()=>a.disconnect()},[]),null}const Sn=9;function jc({count:e}){return e<=0?null:n.jsx("span",{"aria-hidden":"true","data-testid":"nav-count-badge",className:"ml-auto flex min-w-5 shrink-0 items-center justify-center rounded-pill bg-orange px-1.5 text-xs font-bold text-text-on-brand tabular-nums",children:e>Sn?`${Sn}+`:e})}function Rn(e,t){return t<=0?e:`${e}, ${t} needing attention`}function Br(e){return/[\t\n\r]/.test(e)?!1:e.startsWith("/")&&!e.startsWith("//")&&!e.startsWith("/\\")}function Nc({company:e}){const{src:t,onError:r}=Ca(e.logoUrl,e.name);return t?n.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg border-2 border-white bg-white shadow-sm",children:n.jsx("img",{src:t,alt:e.name,referrerPolicy:"no-referrer",onError:r,className:"size-6 rounded object-contain"},t)}):n.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg border-2 border-white bg-orange-08 text-sm font-semibold text-orange shadow-sm",children:e.name.charAt(0).toUpperCase()})}function $r({companies:e}){return e.length===0?null:n.jsx("div",{className:"-space-x-2 flex shrink-0 items-center",children:e.map((t,r)=>n.jsx(Nc,{company:t},`${t.name}-${r}`))})}function Cc(e){switch(e){case"apply_action":case"apply_outcome":return"View application";case"connection_reply":return"View reply";case"document_ready":return"View document";case"mail_signal":return"View message";case"job_match":return"View internships";default:return"View"}}const Tc=Object.freeze([]);function _t(){const{data:e,isPending:t,isFetched:r}=ee(Le());return{isFetched:r,isPending:t,notifications:e?.notifications??Tc,unreadCount:e?.unreadCount??0,unreadApplyActionCount:e?.unreadApplyActionCount??0}}const jn=new Set;function rt(e){return e.link_url!==null&&Br(e.link_url)}const zr="notifications:banner-dismissed",Nn=16,Ac=3;function Me(){try{const e=sessionStorage.getItem(zr);return new Set(e?JSON.parse(e):[])}catch{return new Set}}function Oc(e){try{const t=Me();t.add(e),sessionStorage.setItem(zr,JSON.stringify([...t]))}catch{}}function Ic({avatarUrl:e}){const[t,r]=s.useState(!1);return e&&!t?n.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-lg bg-white shadow-sm",children:n.jsx("img",{src:e,alt:"",referrerPolicy:"no-referrer",onError:()=>r(!0),className:"size-7 rounded object-contain"})}):n.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-lg bg-white shadow-sm",children:n.jsx(xt,{className:"size-5 text-purple",strokeWidth:1.5})})}function Pc({subtitle:e}){const[t,...r]=e.split(" â ");return r.length===0?n.jsx("p",{"data-amp-mask":!0,className:"mt-0.5 text-sm text-text-muted",children:t}):n.jsxs("p",{"data-amp-mask":!0,className:"mt-0.5 text-sm text-text-muted",children:[n.jsx("span",{className:"font-semibold text-text",children:t})," â ",r.join(" â ")]})}function Mc(){const e=ye(),{notifications:t}=_t(),[r,a]=s.useState(Me);s.useEffect(()=>{a(Me())},[]);const o=Ue({mutationFn:f=>Vn({data:{id:f}}),onSuccess:()=>e.invalidateQueries({queryKey:Le().queryKey})}),i=t.filter(f=>f.read_at===null&&!r.has(f.id)),c=i.slice(0,Ac),l=c.length>
140?c[0]:null,d=l&&rt(l)?l.id:null,u=l?.type??null,m=c.length;if(s.useEffect(()=>{if(!(d===null||u===null)&&!jn.has(d)){jn.add(d);try{C("notification_banner_shown",{notificationType:u,stackSize:m})}catch{}}},[d,u,m]),i.length===0)return null;const h=f=>{Oc(f.id),a(Me()),o.mutate(f.id);try{C("notification_dismissed",{notificationType:f.type,source:"banner"})}catch{}},g=async(f,p)=>{try{C("notification_opened",{notificationType:f.type,wasUnread:f.read_at===null,source:"banner",position:p})}catch{}o.mutate(f.id),await gt(),rt(f)&&(window.location.href=Yn(f.link_url,Qn))};return n.jsx("div",{className:"mx-auto w-full max-w-5xl px-6 pt-3 lg:px-12 lg:pt-4",children:n.jsx("div",{className:"relative",style:{paddingBottom:`${(c.length-1)*Nn}px`},children:c.map((f,p)=>{const b=p===0;return n.jsx("div",{className:b?"relative origin-top":"absolute inset-x-0 top-0 origin-top",style:{transform:`translateY(${p*Nn}px) scale(${1-p*.025})`,zIndex:c.length-p,opacity:1},children:n.jsxs("div",{className:"flex items-center gap-4 rounded-xl border border-purple-16 bg-purple-surface px-4 py-3.5",children:[$e(f)?n.jsx($r,{companies:f.matched_companies}):n.jsx(Ic,{avatarUrl:f.avatar_url}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{"data-amp-mask":!0,className:"text-md font-bold text-text-strong",children:f.title}),$e(f)?n.jsx("p",{"data-amp-mask":!0,className:"mt-0.5 truncate text-sm text-text-muted",children:_r(f.matched_companies)}):f.subtitle&&n.jsx(Pc,{subtitle:f.subtitle})]}),b&&rt(f)&&n.jsx("button",{type:"button",onClick:()=>g(f,p),"data-amp-track-surface":"notifications","data-amp-track-action":"open","data-amp-track-target":"banner_cta",className:"shrink-0 rounded-md bg-purple px-5 py-2.5 text-base font-semibold text-white transition-colors hover:bg-purple-hover focus:outline-none focus-visible:shadow-focus",children:Cc(f.type)}),b&&n.jsx("button",{type:"button",onClick:()=>h(f),"aria-label":"Dismiss notification","data-amp-track-surface":"notifications","data-amp-track-action":"dismiss","data-amp-track-target":"banner",className:"shrink-0 text-text-disabled transition-colors hover:text-text-muted focus:outline-none focus-visible:shadow-focus",children:n.jsx(qe,{className:"size-4",strokeWidth:1.5})})]})},f.id)})})})}const Cn=5;function Dc(e){const t=Date.now(),r=new Date(e).getTime(),a=t-r,o=Math.floor(a/6e4);if(o<60)return o<=1?"Just now":`${o}m ago`;const i=Math.floor(o/60);if(i<24)return`${i}h ago`;const c=Math.floor(i/24);return c===1?"Yesterday":`${c}d ago`}function he({children:e,shade:t="bg-orange-12"}){return n.jsx("span",{className:U("flex size-9 shrink-0 items-center justify-center rounded-full text-orange",t),children:e})}function Lc({type:e}){return e==="connection_reply"?n.jsx(he,{children:n.jsx(gr,{className:"size-4",strokeWidth:1.5})}):e==="apply_action"?n.jsx(he,{children:n.jsx(xt,{className:"size-4",strokeWidth:1.5})}):e==="apply_outcome"?n.jsx(he,{children:n.jsx(Qs,{className:"size-4",strokeWidth:1.5})}):e==="mail_account"||e==="mail_signal"?n.jsx(he,{children:n.jsx(Xs,{className:"size-4",strokeWidth:1.5})}):n.jsx(he,{shade:"bg-orange-08",children:n.jsx(Xn,{className:"size-4",strokeWidth:1.5})})}function Fc({notification:e}){const[t,r]=s.useState(!1);if(e.avatar_url&&!t){const a=e.type==="connection_reply";return n.jsx("div",{className:`flex size-9 shrink-0 items-center justify-center bg-white shadow-sm ${a?"rounded-full":"rounded-lg"}`,children:n.jsx("img",{src:e.avatar_url,alt:"",referrerPolicy:"no-referrer",onError:()=>r(!0),className:`object-contain ${a?"size-9 rounded-full":"size-6 rounded"}`})})}return n.jsx(Lc,{type:e.type})}function Uc({notification:e,position:t,onRead:r}){const a=e.read_at===null,o=e.link_url!==null&&Br(e.link_url),i=async()=>{await gt(),o&&(window.location.href=Yn(e.link_url,Qn))},c=()=>{C("notification_opened",{notificationType:e.type,wasUnread:a,source:"bell",position:t})},l=async()=>{try{c()}catch{}a&&r(e.id),await i()};return n.jsxs("button",{type:"button",onClick:l,"data-amp-track-surface":"notifications","data-amp-track-action":"open","data-amp-track-target":"notification",className:U("flex w-full items-start gap-3 px-4 py-3 text-left transition-colors duration-fast hover:bg-surface-warm focus:outline-none focus-visible:bg-surface-warm",o?"cursor-pointer":"cursor-default"),children:[$e(e)?n.jsx($r,{companies:e.matched_companies}):n.jsx(Fc,{notification:e}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{"data-amp-mask":!0,className:U("text-sm leading-snug",a?"font-semibold text-text-strong":"text-text-strong"),children:e.title}),(()=>
14{const d=$e(e)?_r(e.matched_companies):e.subtitle;return d&&n.jsx("p",{"data-amp-mask":!0,className:"mt-0.5 line-clamp-1 text-text-muted text-xs",children:d})})(),n.jsx("p",{className:"mt-1 text-xs text-text-disabled",children:Dc(e.created_at)})]}),a&&n.jsx("span",{className:"mt-1.5 size-2 shrink-0 rounded-full bg-orange"})]})}function Tn(){const[e,t]=s.useState(!1),r=ye(),{notifications:a,unreadCount:o}=_t(),i=a.slice(0,Cn),c=Ue({mutationFn:u=>Vn({data:{id:u}}),onSuccess:()=>r.invalidateQueries({queryKey:Le().queryKey})}),l=Ue({mutationFn:()=>Ta(),onSuccess:()=>r.invalidateQueries({queryKey:Le().queryKey})}),d=()=>{o<=0||l.mutateAsync().then(({clearedCount:u})=>{u>0&&C("notifications_marked_all_read",{clearedCount:u})}).catch(()=>{})};return n.jsxs(or,{open:e,onOpenChange:t,children:[n.jsx(Ms,{asChild:!0,children:n.jsxs("button",{type:"button","aria-label":o>0?`${o} unread notification${o===1?"":"s"}`:"Notifications","data-amp-track-surface":"notifications","data-amp-track-action":"open","data-amp-track-target":"bell",className:"relative flex size-9 items-center justify-center rounded-md text-text-muted transition-colors duration-fast hover:bg-surface-warm-accent hover:text-text-strong focus:outline-none focus-visible:shadow-focus",children:[n.jsx(Ys,{className:"size-5",strokeWidth:1.5}),o>0&&n.jsx("span",{"data-testid":"notification-unread-dot",className:"absolute top-1 right-1 size-2 rounded-full bg-orange"})]})}),n.jsxs(ir,{align:"end",sideOffset:8,className:"w-[360px] p-0 shadow-lg",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-hairline px-4 py-3",children:[n.jsx("span",{className:"text-sm font-semibold text-text-strong",children:"Notifications"}),o>0&&n.jsx("button",{type:"button",onClick:d,"data-amp-track-surface":"notifications","data-amp-track-action":"mark_all_read",className:"text-xs font-medium text-orange hover:text-orange-hover focus:outline-none focus-visible:underline",children:"Mark all read"})]}),n.jsx("div",{className:"divide-y divide-hairline",children:i.length===0?n.jsx("div",{className:"px-4 py-8 text-center text-sm text-text-muted",children:"No notifications yet."}):i.map((u,m)=>n.jsx(Uc,{notification:u,position:m,onRead:h=>c.mutate(h)},u.id))}),a.length>Cn&&n.jsx("div",{className:"border-t border-hairline",children:n.jsx("button",{type:"button",onClick:()=>t(!1),className:"w-full py-3 text-center text-xs font-medium text-text-muted transition-colors hover:text-text-strong focus:outline-none focus-visible:text-text-strong",children:"View all notifications"})})]})]})}const vt={home:xo,search:eo,tracker:xt,connections:Oa,companies:Js,resume:Xn,"skill-builder":Zs,"interview-prep":Aa,profile:gr},Kr={home:"home",search:"search",tracker:"tracker",connections:"connections",companies:"companies",resume:"resume","skill-builder":"skill_builder","interview-prep":"interview_prep",profile:"profile"},Bc=["home","search","connections","companies","tracker","interview-prep","resume","skill-builder","profile"],$c={"interview-prep":"interviewPrepOn"};function zc(e){return Bc.filter(t=>{const r=$c[t];return r===void 0||e[r]})}const Kc=new Set(["profile"]);function Wc(e){return Kc.has(e)}function Wr(e){return zc(e).filter(t=>!Wc(t))}const lt=`${Ia}/`;function Hc(e){return e===Wt||e===`${Wt}/`?"home":e===xe||e===`${xe}/`?"tracker":e===st||e===`${st}/`?"connections":e===Ht||e===`${Ht}/`?"companies":e.startsWith(lt)?"connections":e===Fe||e===`${Fe}/`?"profile":Pa(e)?"skill-builder":Ma(e)?"interview-prep":Zn(e)?"resume":e===qt||e===`${qt}/`?"tracker":"search"}const qc={home:"Home",search:"Find internships",tracker:"Tracker",connections:"Build network",companies:"Companies",resume:"Resume","skill-builder":"Skill Builder","interview-prep":"Interview Prep",profile:"Profile"};function Hr(){return qc}function Gc(e){if(!e)return"";const t=e.replace(/-+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):""}async function Vc(e){const t=await fetch(se("/api/resume-scan"),{method:"POST",body:JSON.stringify({uploadId:e}),headers:{"content-type":"application/json"},credentials:"include"});if(!t.ok)throw new Error("Could not start resume scan.");return await t.json()}async function Yc(e){const t=await fetch(se(`/api/resume-scan/${e}`),{credentials:"include"});if(!t.ok)throw new Error("Could not read resume scan status.");return await t.json()}async function Qc(e,t){const r=t.intervalMs??2e3;for(;;){if(t.now()-t.startedAt>t.budgetMs)return{status:"failed",error:"parse timed out",reason:null};const{status:a,error:o,reason:i}=await t.getStatus(e);if(a==="done")return{status:"done",error:null,reason:i??null};if(a==="failed")return{status:"failed",error:o??null,reason:i??null};await t.sleep(r)}}function Xc(e){const t=e.scanReason??null;return e.status==="failed"?{action:"fail",errorKind:"parse_failed",reason:e.error??"unknown error",scanReason:t}:e.hasContent?{action:"commit"}:{action:"fail",errorKind:"parse_failed",reason:"We couldn't read any resume content from that file.",scanReason:t}}async function Zc(e){try{return{kind:"ok",resume:await e.fetchResume()}}catch(t){if(!e.isDeferrable(t))throw t;if(!await e.refreshSession().catch(()=>!1))return{kind:"auth_expired"};try{return{kind:"ok",resume:await e.fetchResume()}}catch(a){if(e.isDeferrable(a))return{kind:"auth_expired"};throw a}}}
14async function Jc(e){const{fileName:t,surface:r,errorKind:a,reason:o,scanReason:i,deps:c}=e;c.captureError(new Error(o),{context:"resume_upload",surface:r,upload_error_kind:a,...i?{scan_reason:i}:{}}),c.trackFailed({uploadType:"resume",surface:r,errorKind:a,scanReason:i}),c.setPending(null),c.toastError(a==="persist_failed"?`Couldn't upload ${t}. ${o} Your existing resume is unchanged â try again in a moment.`:`Couldn't read ${t}. Your existing resume is unchanged â try a different file.`,{id:"profile-resume-parse-failed"})}const el="chegg:resume-added";function tl(){try{window.dispatchEvent(new CustomEvent(el))}catch{}}function nl({children:e}){const t=ye(),[r,a]=s.useState(null),o=s.useCallback(async(c,l,d)=>{const u=Date.now(),m=d?.viaIntake??!1;a({fileName:c.name,startedAt:u,viaIntake:m});const h=async(p,b,j)=>{await Jc({fileName:c.name,surface:l,errorKind:p,reason:b,scanReason:j,deps:{captureError:(R,y)=>He(R instanceof Error?R:new Error(String(R)),y),trackFailed:sn,toastError:(R,y)=>ot.error(R,y),setPending:()=>a(null)}})},g=p=>{Oe("resume_upload_auth_deferred",{stage:p,via_intake:m,elapsed_ms:Date.now()-u}),sn({uploadType:"resume",surface:l,errorKind:"auth_expired"}),a(null)};let f;try{const p=new FormData;p.set("file",c);const b=await fetch(se("/api/resume-uploads"),{method:"POST",body:p,credentials:"include"});if(!b.ok){const j=await b.json().catch(()=>({}));throw new Error(j.error??"Could not save your resume â please try again.")}({uploadId:f}=await b.json())}catch(p){await h("persist_failed",p instanceof Error?p.message:"unknown error");return}try{const{scanId:p}=await Vc(f),b=await Qc(p,{getStatus:Yc,now:()=>Date.now(),sleep:k=>new Promise(O=>setTimeout(O,k)),startedAt:u,budgetMs:no});if(b.status==="failed"){b.error==="parse timed out"&&Oe("resume_upload_parse_timeout",{elapsed_ms:Date.now()-u,via_intake:m}),await h("parse_failed",b.error??"unknown error",b.reason??void 0);return}const j=await Zc({fetchResume:()=>t.fetchQuery({...Jn(),staleTime:0}),refreshSession:Da,isDeferrable:k=>Gt(k)||Vt(k)});if(j.kind==="auth_expired"){g("post_scan_readback");return}const R=Xc({status:b.status,error:b.error,hasContent:to(j.resume),scanReason:b.reason});if(R.action==="fail"){await h(R.errorKind,R.reason,R.scanReason??void 0);return}const y=Date.now()-u;Oe("resume_upload_committed",{elapsed_ms:y,via_intake:m}),tl(),a(null),m||ot.success("Resume scanned. Your profile is updated.",{id:"profile-resume-parsed"}),Us({uploadType:"resume",surface:l,fileSizeBucket:vo(c.size),durationMs:y}),await Promise.all([t.invalidateQueries({queryKey:it().queryKey}),t.invalidateQueries({queryKey:La().queryKey}),t.invalidateQueries({queryKey:de().queryKey})]).catch(()=>{})}catch(p){if(Gt(p)||Vt(p)){g("post_scan_readback");return}await h("parse_failed",p instanceof Error?p.message:"unknown error")}},[t]),i=s.useMemo(()=>({importResumeFile:o,pendingResumeUpload:r,setPendingResumeUpload:a}),[o,r]);return n.jsx(ro.Provider,{value:i,children:e})}function rl(e=Fa){const t=s.useCallback(a=>{const o=[Ua(a)];for(const i of e)o.push(Ba(i.key,a));return()=>{for(const i of o)i()}},[e]),r=s.useCallback(()=>{const a=$a();let o=0;for(const i of e){const c=za(i.key);Ka(i,c,a[i.key])!==i.defaultVariant&&(o+=1)}return o},[e]);return s.useSyncExternalStore(t,r,()=>0)}function al({isFreshAccount:e,dismissed:t,suppressed:r,entryPointsResolved:a,entryPoint:o}){const i=s.useRef(!1),c=s.useRef(t),l=s.useRef({isFreshAccount:e,entryPointsResolved:a,entryPoint:o,suppressed:r});s.useEffect(()=>{l.current={isFreshAccount:e,entryPointsResolved:a,entryPoint:o,suppressed:r}},[e,a,o,r]);const d=s.useRef(m=>{if(!i.current){if(typeof window<"u")try{if(window.sessionStorage.getItem(nn)==="1"){i.current=!0;return}window.sessionStorage.setItem(nn,"1")}catch{}i.current=!0,C("ftux_started",{source:"welcome_modal",...m?{entry_point:l.current.entryPoint}:{}})}}).current,u=s.useRef(e);s.useEffect(()=>{if(!i.current&&!r&&!c.current){if(!e){u.current&&d(a);return}u.current=!0;{d(!0);return}}},[e,t,r,a,d]),s.useEffect(()=>()=>{u.current&&(l.current.suppressed||c.current||d(l.current.entryPointsResolved))},[d])}const sl="Couldn't sign you out. Please try again.",ol="logout-error",il=8e3;function cl(e){return e.type==="opaqueredirect"||e.status===204}function ll(){return s.useCallback(()=>{Yt();const e=new AbortController,t=setTimeout(()=>e.abort(),il);fetch(se("/api/auth/logout"),{method:"POST",redirect:"manual",signal:e.signal}).then(r=>{if(!cl(r))throw new Error(`logout response not recognized: ${r.status}`);js(),Yt(),Wa(),Ha(),window.location.href=se("/")}
14).catch(r=>{He(r,{operation:"logout"}),ot.error(sl,{id:ol})}).finally(()=>clearTimeout(t))},[])}const qr="rounded-full bg-purple-08 px-2 py-0.5 text-xs font-medium text-purple-press",Gr=`ml-auto ${qr}`,Ke=ft||qa,An=Ke?s.lazy(()=>pt(()=>import("./AdminFlagsModal-DbEUuOJ4.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.AdminFlagsModal}))):null,On=ft?s.lazy(()=>pt(()=>import("./GroundingReviewersModal-giTryk6i.js"),__vite__mapDeps([10,1,2,3,4,5,11])).then(e=>({default:e.GroundingReviewersModal}))):null,In=Ke?s.lazy(()=>pt(()=>import("./MembershipDevModal-BIfzBWVx.js"),__vite__mapDeps([12,1,2,13,3,4,5,14,15,16,17,18,19,20])).then(e=>({default:e.MembershipDevModal}))):null;function Pn({user:e,active:t=!1,trial:r=null,isMember:a,variant:o="sidebar"}){const i=e?.name??e?.email??"User",c=(e?.given_name??e?.name??e?.email??"U").charAt(0).toUpperCase(),l=e?.school??null,d=ll(),[u,m]=s.useState(!1),[h,g]=s.useState(!1),[f,p]=s.useState(!1),b=o==="avatar",j=b?"mobile_header":"sidebar",R={"data-amp-track-surface":"navigation","data-amp-track-action":"toggle","data-amp-track-target":"profile_menu","data-amp-track-placement":j};return n.jsxs(n.Fragment,{children:[n.jsxs(ao,{children:[n.jsx(so,{asChild:!0,children:b?n.jsx("button",{type:"button","data-testid":"mobile-profile-trigger","aria-label":"Open profile menu",...R,"data-amp-mask":!0,"data-amp-mask-attributes":"alt",className:U("flex size-8 shrink-0 items-center justify-center rounded-full outline-none transition-colors duration-fast ease-out focus-visible:shadow-focus",t?"ring-1 ring-orange":"hover:bg-surface-warm-accent"),children:n.jsx(Mn,{user:e,name:i,initial:c,sizeClass:"size-8",testId:"mobile-profile-avatar",fallbackClassName:"bg-orange/10 text-orange",fallbackIcon:!0})}):n.jsxs("button",{type:"button","data-testid":"sidebar-profile-trigger",...R,"data-amp-mask":!0,"data-amp-mask-attributes":"alt","data-active":t||void 0,className:U("flex w-full items-center gap-2.5 rounded-md px-2.5 py-2.5 text-left outline-none transition-colors duration-fast ease-out focus-visible:shadow-focus",t?"bg-orange/10 text-orange":"hover:bg-orange/5"),children:[n.jsx(Mn,{user:e,name:i,initial:c,sizeClass:"size-8 shrink-0",testId:"sidebar-profile-avatar"}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{"data-testid":"sidebar-profile-name",className:U("block truncate text-xs font-semibold",t?"text-inherit":"text-text-strong"),children:i}),l&&n.jsx("span",{className:"block truncate text-xs text-text-muted",children:l}),r&&n.jsxs("span",{"data-testid":"sidebar-trial-badge",className:U("mt-1 inline-flex items-center gap-1",qr),children:[n.jsx(io,{className:"size-3",strokeWidth:2}),r.label]})]})]})}),n.jsxs(oo,{align:"end",side:b?"bottom":"top",className:"min-w-[11rem]",children:[n.jsx(ul,{active:t}),a&&n.jsx(dl,{placement:j}),Ke&&n.jsx(pl,{onSelect:()=>m(!0)}),ft&&n.jsx(ml,{onSelect:()=>g(!0)}),Ke&&n.jsx(fl,{onSelect:()=>p(!0)}),n.jsxs(fe,{"data-testid":"sidebar-logout-item",onSelect:d,children:[n.jsx(bo,{className:"size-4"}),"Log out"]})]})]}),An&&u&&n.jsx(s.Suspense,{fallback:null,children:n.jsx(An,{open:u,onClose:()=>m(!1),flags:yr})}),On&&h&&n.jsx(s.Suspense,{fallback:null,children:n.jsx(On,{open:h,onClose:()=>g(!1)})}),In&&f&&n.jsx(s.Suspense,{fallback:null,children:n.jsx(In,{open:f,onClose:()=>p(!1)})})]})}const Vr=vt.profile;function Mn({user:e,name:t,initial:r,sizeClass:a,testId:o,fallbackClassName:i="bg-amber text-terracotta",fallbackIcon:c=!1}){return e?.picture_url?n.jsx("img",{src:e.picture_url,alt:`${t} profile`,"data-testid":o,className:U(a,"rounded-full object-cover")}):n.jsx("span",{"data-testid":o,className:U(a,"flex items-center justify-center rounded-full",!c&&"text-xs font-bold",i),children:c?n.jsx(Vr,{className:"size-4",strokeWidth:1.5}):r})}function ul({active:e}){return n.jsx(fe,{asChild:!0,children:n.jsxs(er,{to:Fe,"data-testid":"sidebar-profile-item","aria-current":e?"page":void 0,"data-amp-track-surface":"navigation","data-amp-track-action":"open","data-amp-track-target":Kr.profile,children:[n.jsx(Vr,{className:"size-4"}),n.jsx("span",{children:"Profile"})]})})}function dl({placement:e}){return n.jsx(fe,{asChild:!0,children:n.jsxs("a",{"data-testid":"sidebar-manage-subscription-item",...Wn({surface:"navigation",placement:e}),children:[n.jsx(co,{className:"size-4"}),n.jsx("span",{children:Ga}),n.jsx(Va,{className:"ml-auto size-3.5 text-text-muted"})]})})}function ml({onSelect:e}){return n.jsxs(fe,{"data-testid":"sidebar-grounding-reviewers-item","data-amp-track-surface":"admin","data-amp-track-action":"open",onSelect:t=>{t.preventDefault(),e()},children:[n.jsx(_o,{className:"size-4"}),n.jsx("span",{children:"LLM grounding reviewers"})]})}function fl({onSelect:e}){const t=s.useSyncExternalStore(vs,en,en);return n.jsxs(fe,{"data-testid":"sidebar-membership-dev-item","data-amp-track-surface":"admin","data-amp-track-action":"open","data-amp-track-target":"membership_tier",onSelect:r=>{r.preventDefault(),e()},children:[n.jsx(mo,{className:"size-4"}),n.jsx("span",{children:"Membership tier"}),t!=null&&n.jsxs("span",{"data-testid":"sidebar-membership-dev-badge",className:Gr,children:["pinned: ",Ya[t]]})]})}function pl({onSelect:e}){const t=rl(yr);return n.jsxs(fe,{"data-testid":"sidebar-feature-flags-item","data-amp-track-surface":"admin","data-amp-track-action":"open",onSelect:r=>{r.preventDefault(),e()},children:[n.jsx(po,{className:"size-4"}),n.jsx("span",{children:"Feature flags"}),n.jsxs("span",{"data-testid":"sidebar-feature-flags-badge",className:Gr,children:[t," on"]})]})}const hl={review:"Review posting",strengthen:"Tailor resume",resume:"Review resume",apply:"Apply",contacts:"Contact alumni",outreach:"Contact alumni"};function xl(){const e=Ge({select:o=>o.location.pathname}),t=We({from:"/_app"}),{data:r=[]}=ee(tr()),a=gl(e,t,r);return n.jsx("header",{"data-testid":"app-topbar",className:"flex h-11 items-center gap-2 bg-background px-8 text-xs text-muted-foreground",children:a.map((o,i)=>{const c=i===a.length-1,l=c?"font-semibold text-text-strong":"";return n.jsxs("span",{className:"flex items-center gap-2",children:[i>0&&n.jsx("span",{className:"text-text-disabled",children:"/"}),!c&&o.href?n.jsx(er,{to:o.href,className:"cursor-pointer rounded-sm underline-offset-4 transition-colors hover:text-text-strong hover:underline focus:outline-none focus-visible:text-text-strong focus-visible:underline",children:o.label}):n.jsx("span",{className:l,children:o.label})]},`${i}-${o.label}`)})})}function gl(e,t,r){if(e.startsWith(lt)){const a=e.slice(lt.length).split("/")[0],o=Gc(a);return[{label:"Build network",href:st},{label:o}]}if(e.startsWith(xe)){const a=[{label:"Tracker",href:xe}];let o=!1;if(t.job!=null){const c=r.find(l=>l.job_id===t.job);c?.company_name&&(a.push({label:c.company_name}),o=!0)}const i=t.sub?hl[t.sub]:void 0;return i&&o&&a.push({label:i}),a}return e.startsWith(Fe)?[{label:"Profile"}]:Zn(e)?e.startsWith(`${Qt}/tailored/`)?[{label:"Resume",href:Qt},{label:"Tailored resume"}]:[{label:"Resume"}]:[{label:"Find internships"}]}function bl(e){const[t,r]=s.useState(!1);return s.useEffect(()=>{e==="desktop"&&r(!1)},[e]),[t,r]}const yl=64;function wt(){const[e,t]=s.useState(null);return s.useEffect(()=>{const r=window.matchMedia?.(`(min-width: ${yl}rem)`);if(!r)return;const a=()=>t(r.matches?"desktop":"mobile_web");return a(),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[]),e}const Dn=new Set;function _l(e,{mobileNavOpen:t}){const r=wt();s.useEffect(()=>{e<=0||ne()||r!==null&&(r==="mobile_web"&&!t||Dn.has(e)||(Dn.add(e),C("nav_notification_badge_shown",{count:e,viewport:r})))},[e,r,t])}let Ln=!1,Fn=!1,Un=!1;function vl(e,t){const r=wt();s.useEffect(()=>{!ne()&&r==="desktop"&&sr(e,t)!=null&&e.kind!=="none"&&!Ln&&(Ln=!0,C("trial_countdown_viewed",{remainingMs:e.msRemaining,viewport:r,trialKind:e.kind})),Ns(e,t)&&e.kind!=="none"&&!Fn&&(Fn=!0,C("trial_expired",{trialKind:e.kind})),e.hasEverTrialledErrored&&!Un&&(Un=!0,C("trial_status_load_failed",{armEnabled:e.enabled&&!t.isMember&&!ne()}))},[e,t,r])}const wl=8;function El({enabled:e,scrollerRef:t,headerRef:r}){const[a,o]=s.useState(!1),[i,c]=s.useState(0),l=s.useRef(0);return s.useEffect(()=>{const d=t.current,u=r.current;if(!e||!d||!u){o(!1);return}let m=!1,h=null;const g=()=>{m||(m=!0,h=window.requestAnimationFrame(()=>{m=!1,h=null;const p=d.scrollTop,b=u.offsetHeight;c(b);const j=p>=d.scrollHeight-d.clientHeight-1,R=p<l.current-wl;p<=0||R&&!j?o(!1):p>b&&p>l.current&&o(!0),l.current=p}))},f=()=>o(!1);return c(u.offsetHeight),d.addEventListener("scroll",g,{passive:!0}),u.addEventListener("focusin",f),()=>{d.removeEventListener("scroll",g),u.removeEventListener("focusin",f),h!=null&&window.cancelAnimationFrame(h)}},[e,t,r]),{collapsed:a,headerHeight:i}}function kl({anchorResolve:e,user:t,setMemoriesWrapped:r,getMemoryProfile:a,setMemoryProfile:o,importResumeFile:i,savedJobsRef:c,alumniByCompanyRef:l,j
14obMaterialsRef:d}){s.useEffect(()=>{const u={resolveAnchor:e,getUser:()=>t?{name:t.name,email:t.email}:null,setMemories:r,getMemoryProfile:a,setMemoryProfile:o,importResumeFile:i,getSavedJobs:()=>c.current.map(m=>({id:m.job_id,title:m.title??null,company_name:m.company_name??""})),getAlumniByCompany:()=>l.current,getJobStatus:m=>c.current.find(g=>g.job_id===m)?.status,getJobAppliedAt:m=>c.current.find(h=>h.job_id===m)?.applied_at,getTailoredCv:m=>d.current.get(m)?.tailoredCvMarkdown??void 0,getJobMaterials:m=>d.current.get(m)??void 0};return window.__app=u,()=>{delete window.__app}},[e,t,r,a,o,i,c,l,d])}function Sl(e){const t=ye(),r=de().queryKey,a=s.useRef(e?.memory_profile??Xt);a.current=e?.memory_profile??Xt;const o=s.useCallback((l,d)=>{d&&(a.current=d),t.setQueryData(r,u=>u&&{...u,memory_notes:l,memory_profile:d??u.memory_profile})},[t,r]),i=s.useCallback(l=>{const d=Qa(l);a.current=d,t.setQueryData(r,u=>u&&{...u,memory_profile:d})},[t,r]),c=s.useCallback(()=>a.current,[]);return{setMemories:o,setMemoryProfile:i,getMemoryProfile:c}}function Rl({isEmbedded:e,isFreshAccount:t,majorAlreadyProvided:r}){return e&&t&&!r||t&&r}function jl({onDemandUpload:e,pathname:t,surfaceRoute:r}){return e?t===r:!0}function Nl({isEmbedded:e,isFreshAccount:t,dismissed:r,majorAlreadyProvided:a,wasOnNoWelcomeStepPath:o,welcomeModalOpen:i}){const l=e&&t&&!a&&!r,d=t&&a;return{showMajorSeed:l,majorSeededRouting:d,freshAccountWelcomeOpen:t&&!r&&!d,welcomeStepEligible:t&&!r&&!l&&!d,ftuxStartedSuppressed:o&&!(i&&!l)}}function Bn({icon:e,label:t,badgeCount:r}){return n.jsxs(n.Fragment,{children:[n.jsx(e,{className:"size-5 shrink-0",strokeWidth:1.5}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t}),n.jsx(jc,{count:r})]})}function Cl(){_c();const{data:e}=xs(de()),t=ar(),r=ht(),a=sr(t,r);vl(t,r),yc({enabled:!ne()});const{data:o=[]}=ee(tr()),{data:i=new Map}=ee(Xa()),{data:c={}}=ee(Za()),l=be(),d=Ge({select:x=>x.location.pathname}),u=Hc(d),m=wt(),h=s.useRef(null),g=s.useRef(null),{collapsed:f,headerHeight:p}=El({enabled:ls(d)&&m==="mobile_web",scrollerRef:h,headerRef:g}),b=Be(Ja)==="on",j=Hr(),{unreadApplyActionCount:R,isFetched:y}=_t(),k=Wr({interviewPrepOn:b}).map(x=>({id:x,label:j[x],icon:vt[x],trackTarget:Kr[x],badgeCount:x==="tracker"?R:0,countState:x==="tracker"?y?"ready":"loading":void 0})),O=es(d),w=d!==xe,{importResumeFile:N}=br(),_=Sl(e),E=wc(),S=s.useRef(o);S.current=o;const I=s.useRef(c);I.current=c;const Y=s.useRef(i);Y.current=i,kl({anchorResolve:E.resolve,user:e,setMemoriesWrapped:_.setMemories,getMemoryProfile:_.getMemoryProfile,setMemoryProfile:_.setMemoryProfile,importResumeFile:N,savedJobsRef:S,alumniByCompanyRef:I,jobMaterialsRef:Y});const B=We({from:"/_app"}),A=s.useRef({}),$=s.useRef({});s.useEffect(()=>{u==="tracker"?A.current=Zt("tracker",B):u==="search"&&($.current=Zt("search",B))},[u,B]);const F=s.useCallback(x=>{const J=x==="tracker"?A.current:x==="search"?$.current:{};l({to:ts(x),search:()=>J})},[l]),[q,Z]=bl(m),Q=s.useCallback(x=>{Z(!1),F(x)},[F,Z]);_l(R,{mobileNavOpen:q});const H=ne();return n.jsxs("div",{className:"flex h-[100svh] overflow-hidden bg-surface-warm",children:[n.jsx("a",{href:`#${rn}`,className:"sr-only focus:not-sr-only focus:absolute focus:left-2 focus:top-2 focus:z-[100] focus:rounded-md focus:bg-accent focus:px-3 focus:py-2 focus:text-sm focus:font-semibold focus:text-white",children:"Skip to main content"}),n.jsxs(cr,{className:"flex h-[100svh] flex-1 overflow-hidden",children:[H&&n.jsx(Rc,{}),!H&&n.jsx(lr,{"data-testid":"app-sidebar",collapsible:"icon",className:"sticky top-0 hidden h-[100svh] border-r border-hairline lg:flex",children:n.jsxs(ur,{className:"px-3 pt-5 pb-3.5",children:[n.jsx("div",{className:"mb-5 px-2.5 pt-1.5",children:n.jsx(Ie,{className:"block h-9 w-auto shrink-0"})}),n.jsx(dr,{children:n.jsx(mr,{children:n.jsx(fr,{role:"tablist",children:k.map(x=>n.jsx(pr,{children:n.jsx(hr,{type:"button",role:"tab",isActive:u===x.id,"aria-selected":u===x.id,"data-count-state":x.countState,"aria-label":Rn(x.label,x.badgeCount),"data-amp-track-surface":"navigation","data-amp-track-action":"open","data-amp-track-target":x.trackTarget,"data-amp-track-placement":"sidebar",onClick:()=>
14F(x.id),children:n.jsx(Bn,{icon:x.icon,label:x.label,badgeCount:x.badgeCount})})},x.id))})})}),n.jsx("div",{className:"mt-auto border-t border-hairline pt-2",children:n.jsx(Pn,{user:e,active:u==="profile",trial:a,isMember:r.isMember})})]})}),n.jsxs(xr,{className:"flex min-w-0 min-h-0 flex-1 flex-col overflow-hidden bg-surface-warm",children:[!H&&O&&n.jsx(xl,{}),!H&&n.jsxs("header",{ref:g,"data-testid":"mobile-header","data-collapsed":f?"true":"false",style:f?{marginTop:-p}:void 0,className:"flex items-center gap-3 border-b border-hairline px-5 py-4 transition-[margin] duration-base ease-out lg:hidden",children:[n.jsxs(zs,{open:q,onOpenChange:Z,children:[n.jsx(Ks,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Open navigation menu","data-amp-track-surface":"navigation","data-amp-track-action":"open","data-amp-track-target":"nav_drawer",className:"-ml-1.5 flex size-8 shrink-0 items-center justify-center rounded-md text-text-strong outline-none transition-colors duration-fast ease-out hover:bg-orange/5 focus-visible:shadow-focus",children:n.jsx(ns,{className:"size-5",strokeWidth:1.75})})}),n.jsxs(Ws,{side:"left",className:"p-0",children:[n.jsxs(Hs,{className:"border-b border-hairline",children:[n.jsx(qs,{children:n.jsx(Ie,{className:"h-8 w-auto"})}),n.jsx(Gs,{className:"sr-only",children:"Jump to any section of the app."})]}),n.jsx("div",{role:"tablist","aria-label":"Primary",className:"flex-1 overflow-y-auto p-2",children:k.map(x=>n.jsx("button",{type:"button",role:"tab","aria-selected":u===x.id,"data-count-state":x.countState,"aria-label":Rn(x.label,x.badgeCount),"data-amp-track-surface":"navigation","data-amp-track-action":"open","data-amp-track-target":x.trackTarget,"data-amp-track-placement":"mobile_header",className:U("flex w-full items-center gap-3 rounded-md px-2.5 py-2 text-sm outline-none transition-colors duration-fast ease-out focus-visible:shadow-focus",u===x.id?"bg-orange/10 font-semibold text-orange":"font-medium text-text hover:bg-orange/5"),onClick:()=>Q(x.id),children:n.jsx(Bn,{icon:x.icon,label:x.label,badgeCount:x.badgeCount})},x.id))})]})]}),n.jsx(Ie,{className:"h-8 w-auto shrink-0"}),n.jsxs("div",{"data-testid":"mobile-header-actions",className:"ml-auto flex items-center gap-2",children:[w&&n.jsx(Tn,{}),n.jsx(Pn,{user:e,active:u==="profile",isMember:r.isMember,variant:"avatar"})]})]}),n.jsx("main",{ref:h,id:rn,tabIndex:-1,className:"flex min-w-0 min-h-0 flex-1 flex-col overflow-y-auto focus:outline-none",children:n.jsxs("div",{className:"flex min-h-full flex-col",children:[w&&n.jsx(Mc,{}),n.jsx("div",{className:U(on,"empty:hidden"),children:n.jsx(ko,{})}),n.jsxs("div",{className:"relative flex-1",children:[w&&n.jsx("div",{"data-testid":"desktop-notification-row",className:"pointer-events-none absolute inset-x-0 top-12 z-10 hidden lg:block",children:n.jsx("div",{className:U(on,"flex justify-end"),children:n.jsx("div",{className:"pointer-events-auto",children:n.jsx(Tn,{})})})}),n.jsx(rs,{})]}),!H&&n.jsx(Vs,{isMember:r.isMember})]})})]})]})]})}function Tl(){return n.jsx(nl,{children:n.jsx(vc,{children:n.jsxs(lc,{children:[n.jsx(Cl,{}),n.jsx(Al,{}),n.jsx(Ro,{})]})})})}function Al(){const{data:e}=ee(de()),{data:t}=ee(it()),{importResumeFile:r}=br(),a=ye(),o=be(),i=Ge({select:G=>G.location.pathname}),[c,l]=s.useState(Cs),[d,u]=s.useState(!1),m=!!e&&!e.profile_intake_confirmed_at&&t===!1,h=We({from:"/_app"}),g=s.useRef(null);g.current===null&&(g.current=$s(h.major));const f=s.useRef(!1);Rl({isEmbedded:ne(),isFreshAccount:m,majorAlreadyProvided:!!g.current})&&(f.current=!0);const p=d&&t===!1,{showMajorSeed:b,freshAccountWelcomeOpen:j,welcomeStepEligible:R,ftuxStartedSuppressed:y}=Nl({isEmbedded:ne(),isFreshAccount:m,dismissed:c,majorAlreadyProvided:!!g.current,wasOnNoWelcomeStepPath:f.current,welcomeModalOpen:p});s.useEffect(()=>{h.ftux===as&&(u(!0),o({to:".",search:G=>({...G,ftux:void 0}),replace:!0}))},[h.ftux,o]);const k=s.useRef(null);k.current===null&&m&&!c&&(k.current=i);const O=k.current??i,w=ss(O);m&&Ts(w.id);const N=w.dismissible,_=w.requireUpload,E=Jt(os,{when:R&&w.id==="search"}),S=Jt(is,{when:R})==="on",Y=w.id==="search"&&E==="on"?{...w.intro,welcome:cs}:w.intro;al({isFreshAccount:m,dismissed:c,suppressed:y,entryPointsResolved:!0,entryPoint:w.id});const B=w.id,A=s.useCallback(()=>{an(),l(!0)},[]),$=s.useCallback(()=>{u(!1),A()},[A]),F=Ue({mutationFn:dc,onSuccess:()=>a.invalidateQueries({queryKey:de().queryKey})}),q=s.useRef(!1);s.useEffect(()=>{b&&!q.current&&(q.current=!0,fc())},[b]);const Z=async({school:G,major:oe})=>{pc();try{await F.mutateAsync({major:oe,school:G})}catch{}an(),l(!0),await o({to:us,search:_e=>({..._e,major:oe,seed:"prompt"}),replace:!0})},Q=()=>{hc(),A()},H=w.id,x=jl({onDemandUpload:d,pathname:i,surfaceRoute:w.surfaceRoute}),J=async G=>{Bs({uploadType:"resume",surface:"ftux"}),await Promise.resolve(r(G,"ftux",{viaIntake:!0})),await Promise.all([a.invalidateQueries({queryKey:it().queryKey}),a.invalidateQueries({queryKey:Jn().queryKey}),a.invalidateQueries({queryKey:de().queryKey}),a.invalidateQueries({queryKey:ds().queryKey}),a.invalidateQueries({queryKey:ms().queryKey})]),x&&await o({to:w.surfaceRoute,search:oe=>({...oe,intake:1,onboarding:H}),replace:!0})},M=async()=>{mc({variantId:w.id,trackedEntryPoint:B}),$(),await o({to:w.surfaceRoute,search:G=>({...G,intake:1,onboarding:H}),replace:!0})};return b?n.jsx(uc,{onSubmit:Z,onSkip:Q,submitting:F.isPending}):n.jsx(Ls,{open:j||p,initialStep:d?"upload":void 0,intro:Y,steps:w.steps,companiesStepEnabled:S,dismissible:N||d,requireUpload:_,surfaceOwnsBuildingLoader:w.surfaceOwnsBuildingLoader??!1,onDismiss:$,onFileUpload:J,onManualIntake:M,entryPoint:B})}const Ol=Wr({interviewPrepOn:!1});function Il({activeTab:e="resume"}){const t=Hr();return n.jsx("div",{className:"pointer-events-none flex h-[100svh] overflow-hidden bg-surface-warm","aria-hidden":!0,
14children:n.jsxs(cr,{className:"flex h-[100svh] flex-1 overflow-hidden",children:[n.jsx(lr,{collapsible:"icon",className:"sticky top-0 hidden h-[100svh] border-r border-hairline lg:flex",children:n.jsxs(ur,{className:"px-3 pt-5 pb-3.5",children:[n.jsx("div",{className:"mb-5 px-2.5 pt-1.5",children:n.jsx(Ie,{alt:"",className:"block h-9 w-auto shrink-0"})}),n.jsx(dr,{children:n.jsx(mr,{children:n.jsx(fr,{children:Ol.map(r=>{const a=vt[r];return n.jsx(pr,{children:n.jsxs(hr,{type:"button",isActive:r===e,tabIndex:-1,children:[n.jsx(a,{className:"size-5 shrink-0",strokeWidth:1.5}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t[r]})]})},r)})})})}),n.jsx("div",{className:"mt-auto border-t border-hairline pt-2",children:n.jsxs("div",{className:"flex items-center gap-2 px-2 py-2",children:[n.jsx("div",{className:"size-8 shrink-0 rounded-full bg-hairline"}),n.jsx("div",{className:"h-3 min-w-0 flex-1 rounded bg-hairline"})]})})]})}),n.jsx(xr,{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-warm"})]})})}function Pl(e){if(typeof window>"u")return e.route;const t=new URLSearchParams(window.location.search);t.delete("_landing");const r=t.toString();return r?`${e.route}?${r}`:e.route}function Ml({surface:e,isPreview:t=!1,previewWithSession:r=!1}){const a=be(),o=s.useId(),i=s.useRef(null),c=fs(e.variantId);if(lo(i,c!=null),s.useEffect(()=>{if(c&&!t){C("public_landing_viewed",{surface_route:e.route,entry_point:e.variantId});for(const u of e.requiredFlags)ct(u)}},[e.route,e.variantId,e.requiredFlags,c,t]),!c)return null;const l=c.intro,d=()=>{const u=Pl(e);if(t){a({to:"/login",search:{redirect:u,screen_hint:"signup"}});return}C("public_landing_cta_clicked",{surface_route:e.route,entry_point:e.variantId});const m=ps({signup:!0,redirect:u});gt().finally(()=>{window.location.href=m})};return n.jsxs(n.Fragment,{children:[n.jsx(Il,{activeTab:e.activeTab}),n.jsx("div",{className:"ftux-scrim",style:{opacity:1},children:n.jsxs("div",{ref:i,role:"dialog","aria-modal":"true",tabIndex:-1,"aria-label":l.dialogLabel,className:"ftux-modal ftux-step-fade",children:[n.jsx(Fs,{headingId:o,copy:l.welcome,onContinue:d,trackSurface:"public_landing",trackStep:e.variantId}),r?n.jsxs("p",{className:"ftux-meta mt-3 text-center",children:["Previewing the logged-out landing."," ",n.jsx("button",{type:"button",className:"underline",onClick:()=>{a({to:e.route})},children:"Exit preview"})]}):null]})})]})}function Iu(){}function Pu(){const{publicLanding:e,surface:t,isPreview:r,previewWithSession:a}=hs.useRouteContext();return e&&t?n.jsx(Ml,{surface:t,isPreview:r,previewWithSession:a}):n.jsx(Tl,{})}export{Iu as __resetAccessClaimRepairForTests,Pu as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.