PageSourceSearch

https://app.jungleai.com/assets/MasteryChallengeModal-DLZfkCYQ.js

js jungleai.com collected 2026-10-01 15:36:12 UTC 11,847 bytes, 2 lines download raw bytes

1import{ap as ge,j as s,aA as he,r,aB as xe,aC as ye,T as ne,B as P,a3 as Se}from"./MarketingSiteLoadingFallback-DfYAzeIM.js";import{a1 as Ae,aI as $,u as q,a as be,p as oe,t as ve,aO as Ce,aP as _e,aQ as Me,h as m,aR as ke,B as D}from"./renderJungleWebApp-DZgne_TB.js";import{F as H}from"./landingHandoffUploadClaim-B2LBwAI7.js";import{u as Ee,g as Te}from"./microphoneErrorKind-1vTdXBk9.js";import"./sounds-6VEiAGrS.js";import{ao as Re,ap as je,aq as we}from"./VoiceEndedLine-BgqrWdm3.js";import{M as Ie,s as Oe}from"./MicPermissionDeniedModal-C4CDPTvI.js";import{G as Pe,f as De,R as B}from"./voiceChallengeShared-B_DkTPaz.js";import{f as Be}from"./monkey-fire-DTsdg-LK.js";import{M as Ue}from"./MicrophoneAccessErrorContent-Bawky_DI.js";import{d as Le}from"./client-environment-BMTHOZAb.js";import{U as ze,a as Ne}from"./upsellCopyConstants-BLJE5m9g.js";import{c as ae}from"./hub-D89kKFfg.js";import"./frontend-release-BHg_hj9G.js";import"./index-rQLcFmgX.js";import"./track-error-DEre5AXz.js";import"./legacy-referrer-id-43tytWzp.js";import"./main-YoYAMf6n.js";import"./stripe-price-details-DClgIPIw.js";import"./document-upload-sentry-Dl2_Y04U.js";import"./sentry-init-BRm8Bcin.js";import"./liveKitConversationSession-CCgChqOE.js";import"./microphone-access-Bai3iDRY.js";import"./MarkdownWithMath-CLxXCppZ.js";import"./remark-gfm-for-older-webkit-QGdm8VJ7.js";import"./step-B98a7oi-.js";import"./close-CKCy2mmL.js";import"./plus-BEyzA85c.js";import"./icon-button-BKnGN1H6.js";import"./ChevronRight-b1cVxF27.js";import"./IconChat-CYBOpyVh.js";import"./IconCopy-B8-hvn3S.js";const Q={};async function We(o){var A;let f=null;try{f=await((A=Ae.currentUser)==null?void 0:A.getIdToken(!1))??null}catch{f=null}if(!f)return{status:"error",message:"not_authenticated"};const x=(Q==null?void 0:Q.VITE_MASTERY_JUDGE_URL)||ge;let p;try{p=await fetch(`${x}/voice-mastery-challenge`,{method:"POST",headers:{Authorization:`Bearer ${f}`,"Content-Type":"application/json"},body:JSON.stringify({conversationId:o.conversationId,challengeId:o.challengeId,voiceSessionId:o.voiceSessionId,concept:o.concept,deckId:o.deckId,deckName:o.deckName,messages:o.messages})})}catch{return{status:"retriable_error"}}let i={};try{i=await p.json()}catch{i={}}if(p.status===403&&(i==null?void 0:i.error)==="attempts_exhausted")return{status:"attempts_exhausted"};if(p.status===503||(i==null?void 0:i.retriable)===!0)return{status:"retriable_error"};if(!p.ok||(i==null?void 0:i.status)!=="ok")return{status:"error",message:(i==null?void 0:i.error)||`status_${p.status}`};const g=typeof i.attemptsRemaining=="number"?i.attemptsRemaining:0;return i.passed===!0&&typeof i.expiresAtMs=="number"?{status:"pass",expiresAtMs:i.expiresAtMs,attemptsRemaining:g,alreadyGranted:i.alreadyGranted===!0}:{status:"fail",attemptsRemaining:g}}const R=120,Ge=45;function vt(){const o=$(g=>g.masteryChallenge),f=$(g=>g.closeMasteryChallenge),x=$(g=>g.openQuestionQualityUpsellModal),p=q(g=>g.currentUser);return o!=null?s.jsx(Ve,{concept:o.concept,deckId:o.deckId,deckName:o.deckName,language:o.language||"English",isHealthStudent:he(p==null?void 0:p.student_type),onClose:f,onClaim:()=>{f(),x("voice_free_limit_blocked_pre_call")},onBackToOffer:()=>{f(),x("voice_free_limit_blocked_pre_call")}},`${o.deckId??"no-deck"}:${o.concept}`):null}function Ve({concept:o,deckId:f,deckName:x,language:p,isHealthStudent:i,onClose:g,onClaim:A,onBackToOffer:ie}){const{t:l}=be(),u=ze.masteryChallenge,d=Ne.masteryChallenge,[C]=r.useState(xe),[a,h]=r.useState("live"),[J,U]=r.useState(R),[L,ce]=r.useState(null),[le,ue]=r.useState(""),[z,Y]=r.useState(null),[j,X]=r.useState(null),de=oe(t=>t.iosVersionPublished),pe=oe(t=>t.androidVersionPublished),N=r.useRef(new Map),_=r.useRef(null),M=r.useRef(!1),w=r.useRef(!1),b=r.useRef(null),W=r.useRef(0),I=r.useRef(!0),G=r.useMemo(()=>Le(),[]),me=r.useMemo(()=>({challengeMode:!0,challengeType:"mastery",challengeConcept:o,challengeDocumentName:x,deckId:f,languageToGenerateIn:p}),[o,f,x,p]),n=Ee({mode:"voice-conversation",surface:"mastery-challenge",challengeId:C,language:p,context:me}),S=r.useCallback((t,e={})=>{const c=n.getSessionId();ve(t,{concept:o,challenge_id:C,session_type:"mastery_challenge",surface:"mastery-challenge",...c?{session_id:c}:{},...e},void 0,null)},[C,o,n]),O=r.useRef(!1),k=r.useCallback(()=>{!O.current&&!(a==="pass"||a==="fail"||a==="exhausted")&&(O.current=!0,S("mastery challenge abandoned")),g()},[g,a,S]);r.useEffect(()=>n.onTranscript(t=>{t.text.trim()&&N.current.set(t.segmentId,{role:t.role,text:t.text})}),[n]);const V=r.useCallback(()=>{w.current||b.current||(w.current=!0,W.current+=1,h("live"),n.start().catch(()=>{}).finally(()=>{w.current=!1}))},[n]),Z=r.useRef(!1);r.useEffect(()=>{Z.current||(Z.current=!0,S("mastery challenge shown"),V(),S("mastery challenge started"))},[]);const ee=r.useCallback(()=>
1{if(w.current||b.current)return;N.current.clear(),_.current=null,M.current=!1,U(R),X(null);const t=n.getSessionId();V(),S("mastery challenge connection retried",{...t?{previous_session_id:t}:{}})},[V,S,n]),y=n.state.kind;r.useEffect(()=>{(y==="listening"||y==="thinking"||y==="speaking")&&_.current===null&&(_.current=Date.now())},[y]);const te=r.useCallback(()=>{const t=[];for(const e of N.current.values()){const c=e.text.trim();c&&t.push({text_message:c,is_message_from_user:e.role==="user"})}return t},[]),re=r.useCallback(async()=>{h("judging");const t=n.getConversationId();if(!t){h("error");return}let e;try{e=await We({conversationId:t,challengeId:C,voiceSessionId:n.getSessionId()??void 0,concept:o,deckId:f,deckName:x,messages:te()})}catch{e={status:"error",message:"network"}}if(e.status==="pass"){ce(e.expiresAtMs),Y(e.attemptsRemaining);const c=q.getState().currentUser;c&&q.getState().setCurrentUser({...c,voice_mastery_challenge:{...c.voice_mastery_challenge??{},attempts_used:ye-e.attemptsRemaining,discount:{granted_at:Date.now()/1e3,expires_at:e.expiresAtMs/1e3,consumed:!1}}}),h("pass")}else e.status==="fail"?(Y(e.attemptsRemaining),h("fail")):e.status==="attempts_exhausted"?h("exhausted"):h("error")},[n,C,o,f,x,te]),E=r.useCallback((t="challenge_completed")=>{M.current||(M.current=!0,n.stop(t),re())},[n,re]);r.useEffect(()=>{if(a!=="live")return;const t=()=>{const c=_.current;if(c===null){U(R);return}const T=(Date.now()-c)/1e3,v=R-T;U(v),v<=0&&E()};t();const e=window.setInterval(t,500);return()=>window.clearInterval(e)},[a,E]),r.useEffect(()=>{var t;if(!(a!=="live"||y!=="error"))if(_.current===null){if(b.current)return;M.current=!0;const e=n.lastError,c=Te(e==null?void 0:e.kind);if(e&&e.kind!=="mic-permission-denied"&&e.kind!=="user-cancelled-connect")try{ae(e,{level:c&&c!=="mic-access-failed"?"warning":"error",tags:{feature:"voice",surface:"mastery-challenge",error_kind:e.kind,...e.startupDiagnostics?{failure_stage:e.startupDiagnostics.failureStage,browser_error_name:e.startupDiagnostics.browserErrorName}:{},connection_attempt:String(W.current)},extra:{voiceStartup:e.startupDiagnostics}})}catch{}const T=(e==null?void 0:e.kind)==="user-cancelled-connect"?"user":"error",v=n.stop(T).then(()=>{b.current=null,I.current&&(c?(X(c),h("microphone-error")):h("error"))},K=>{if(b.current=null,!!I.current){try{ae(K,{tags:{feature:"voice",surface:"mastery-challenge",error_kind:"connection-cleanup-failed",connection_attempt:String(W.current)}})}catch{}h("error")}});b.current=v}else((t=n.lastError)==null?void 0:t.kind)==="agent-audio-timeout"?(M.current=!0,h("error")):E("error")},[a,y,E,n]),r.useEffect(()=>{if(a!=="pass"||L==null)return;const t=()=>{const c=Math.max(0,L-Date.now()),T=Math.floor(c/36e5),v=Math.floor(c%36e5/6e4),K=Math.floor(c%6e4/1e3);ue(`${T}:${v.toString().padStart(2,"0")}:${K.toString().padStart(2,"0")}`)};t();const e=window.setInterval(t,1e3);return()=>window.clearInterval(e)},[a,L]),r.useEffect(()=>(I.current=!0,()=>{I.current=!1,n.stop("unmount")}),[]);const fe=y==="idle"||y==="requesting-mic"||y==="connecting",se=n.artifacts.filter(t=>t.kind==="question"),F=se[se.length-1];return s.jsxs(Ce,{isOpen:!0,onClose:()=>{a==="live"?(O.current||(O.current=!0,S("mastery challenge abandoned")),n.stop("user"),ie()):k()},isCentered:!0,closeOnOverlayClick:a!=="judging",closeOnEsc:a!=="live"&&a!=="judging",size:{base:"full",md:"lg"},children:[s.jsx(_e,{bg:"rgba(0,0,0,0.55)"}),s.jsx(Me,{borderRadius:{base:"0",md:"20px"},overflow:"hidden",bg:m.surface.offWhite,maxW:{base:"100%",md:"560px"},children:s.jsx(ke,{p:0,children:s.jsxs(H,{direction:"column",align:"center",px:"24px",py:"28px",gap:"14px",children:[a==="live"||a==="judging"?s.jsxs(s.Fragment,{children:[s.jsx(Pe,{label:a==="judging"?l(u.timerFinished,d.timerFinished):l(u.timerToProve,d.timerToProve,{time:De(J)}),voiceStateKind:n.state.kind,isMuted:n.isMuted,getMicAnalyser:n.getMicAnalyser,getAgentAnalyser:n.getAgentAnalyser}),s.jsxs(ne,{fontSize:"15px",fontWeight:600,color:m.text.header,textAlign:"center",maxW:"420px",children:[l(u.introPrefix,d.introPrefix)," ",s.jsx(P,{as:"span",color:m.primaryAction.default,children:o})]}),s.jsx(Re,{voiceStateKind:n.state.kind,isMuted:n.isMuted,isConnecting:fe,getMicAnalyser:n.getMicAnalyser,getAgentAnalyser:n.getAgentAnalyser,isHealthStudent:i,avatarSrc:Be,avatarBg:"transparent",avatarSizePx:200,disableGlow:!0,avatarContain:!0}),s.jsx(P,{w:"100%",maxW:"440px",minH:"64px",children:F&&s.jsx(je,{artifact:F,opacity:1},F.id)}),a==="judging"?s.jsxs(H,{align:"center",gap:"8px",color:m.text.label,children:[s.jsx(Se,{size:"sm"}),s.jsx(ne,{fontSize:"14px",children:l(u.judging,d.judging)})]}):R-J>=Ge?s.jsxs(H,{as:"button",type:"button",onClick:()=>E(),align:"center",gap:"8px",mt:"2px",px:"18px",py:"10px",borderRadius:"999px",bg:m.accentColors.errorStrong,color:m.surface.white,fontSize:"14px",fontWeight:700,_hover:{opacity:.92},children:[s.jsx(we,{size:16,color:m.surface.white}),l(u.finishCta,d.finishCta)]}):null]}):null,a==="pass"?s.jsxs(B,{emoji:"🎉",title:l(u.passTitle,d.passTitle),body:l(u.passBody,d.passBody,{concept:o}),accent:m.primaryAction.default,children:[s.jsxs(P,{px:"14px",py:"6px",borderRadius:"999px",bg:m.surface.secondary,fontSize:"13px",fontWeight:700,color:m.text.header,children:[l(u.offerExpiresIn,d.offerExpiresIn)," ",le||"24:00:00"]}),s.jsx(D,{title:l(u.claimDiscountCta,d.claimDiscountCta),onClick:A,buttonPrimaryOrSecondaryType:"primary",size:"medium",shouldAllowTitleToWrap:!0})]}):null,a==="fail"?s.jsxs(B,{emoji:"🤔",title:l(u.failTitle,d.failTitle),body:z&&z>0?l(u.failBodyWithAttempts,d.failBodyWithAttempts,{count:z}):l(u.failBodyLastAttempt,d.failBodyLastAttempt),accent:m.text.header,children:[s.jsx(D,{title:l(u.seeUpgradeOptions,d.seeUpgradeOptions),onClick:A,buttonPrimaryOrSecondaryType:"primary",size:"medium",shouldAllowTitleToWrap:!0}),s.jsx(P,{as:"button",type:"button",onClick:k,fontSize:"14px",color:m.text.label,_hover:{textDecoration:"underline"},children:l(u.maybeLater,d.maybeLater)})]}):null,a==="exhausted"?s.jsx(B,{emoji:"✋",title:l(u.exhaustedTitle,d.exhaustedTitle),body:l(u.exhaustedBody,d.exhaustedBody),accent:m.text.header,children:s.jsx(D,{title:l(u.seeUpgradeOptions,d.seeUpgradeOptions),onClick:A,buttonPrimaryOrSecondaryType:"primary",size:"medium",shouldAllowTitleToWrap:!0})}):null,a==="microphone-error"&&j==="mic-permission-denied"?s.jsx(Ie,{onDismiss:k,onPermissionGranted:ee,clientEnv
1ironment:G,supportsOpeningAppSettings:Oe(G,de,pe),presentation:"embedded"}):null,a==="microphone-error"&&j&&j!=="mic-permission-denied"?s.jsx(Ue,{errorKind:j,onDismiss:k,onRetry:ee,clientEnvironment:G,presentation:"embedded"}):null,a==="error"?s.jsx(B,{emoji:"⚠️",title:l(u.errorTitle,d.errorTitle),body:l(u.errorBody,d.errorBody),accent:m.text.header,children:s.jsx(D,{title:l(u.close,d.close),onClick:k,buttonPrimaryOrSecondaryType:"primary",size:"medium",shouldAllowTitleToWrap:!0})}):null]})})})]})}export{vt as default};
2//# sourceMappingURL=MasteryChallengeModal-DLZfkCYQ.js.map

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.