import{i as e}from"./chunk-B3pr0VN8.js";import{n as t,t as n}from"./jsx-runtime-wTfS3W87.js";import{d as r,u as i}from"./chunk-6CSD65Y2-Dj7xjS5D.js";import{i as a,r as o}from"./authSession-CrP9lMPq.js";import{n as s,r as c,t as l}from"./norm-CeclA1Tu.js";import{n as u}from"./runtimeFeatures-C_7AZG1k.js";import{o as d}from"./cloudModel-CGo_el7I.js";import{n as f,t as p}from"./llmSettings-A1Pww_S_.js";import{t as m}from"./resumeAiConsent-Cb5Qq4UE.js";import{t as h}from"./exportDomPng-BDWMk3SC.js";import{t as g}from"./download-8udYNbpo.js";import{t as _}from"./PlatformTokenUsage-DOyFOKQg.js";import{n as v,t as y}from"./ToolConversationUI-SaFaLfJ7.js";import{t as b}from"./FallbackNoticeCard-B3WK5QL2.js";import{c as x,l as S,n as C,o as w,s as T,t as E,u as D}from"./toolRuntime-wpPmOqkC.js";import{d as O}from"./proxyOps-Bu_E5G0s.js";import{a as k,n as A,r as j,t as M}from"./llm-BJZzBJtf.js";import{t as N}from"./privacyMask-CsOBYv0S.js";import{t as P}from"./roleTaxonomy-CL03wfHw.js";import{n as F,t as I}from"./ToolSidebarNav-ydI_X_Ab.js";import{t as ee}from"./ThinkingPanel-DWgqEvqz.js";import{t as L}from"./MarkdownText-PFZ-Hr7C.js";import{t as R}from"./ToolLiveStreamPanel-NdoSsKvg.js";import{i as te,r as ne,t as z}from"./ToolConversationBilling-tfxRkJpq.js";import{t as re}from"./universityDictionary-fSLAxeXv.js";import"./aiInterviewCoach-CyZEJppP.js";import{n as ie}from"./aiResumeOptimize-DcvfFgqJ.js";import{n as ae}from"./aiResumeMatch-CPT2N070.js";import{t as B}from"./supportFileText-L4xSfqOJ.js";import{n as oe}from"./taskPointGuard-Cj3sjKf6.js";import{n as se}from"./toolSkillSummary-B3044xDN.js";import{n as V}from"./cloudWorkspaceClient-CMlIQBWi.js";import{t as ce}from"./resumeTranslate-DyTrlVNW.js";import{n as H,o as U,t as W}from"./ToolConversationExecution-Dzjh1RyP.js";import{n as G,t as K}from"./ComingSoonPanel-wdNeA4OD.js";import{n as le}from"./useToolRunState-lqkZz3ea.js";import{n as ue,r as de,t as fe}from"./ToolConversationHelpers-Bab8E63h.js";import{i as pe,r as me,t as he}from"./careerCoachSessionStore-BxJQJhCc.js";import{t as ge}from"./JdBuzzwordDetector-BRBwbLvV.js";var q=e(t(),1),J=(e,t=8)=>Array.from(new Set((Array.isArray(e)?e:[]).map(e=>c(e)).filter(Boolean))).slice(0,t),_e=`he_career_coach_professional_notice_v1`,ve=(e,t)=>({id:`career_job_${Date.now()}`,title:c(t.targetRole)||`目标岗位`,company:`目标公司`,salary:{min:0,max:0,currency:`CNY`},description:c(e),url:``,platform:`import`,tags:[],location:c(t.location),experience:c(t.yearsExperience),industry:c(t.targetIndustry)}),Y=(e,t=1200)=>{let n=c(e);return n?n.length<=t?n:`${n.slice(0,t).trimEnd()}…`:``},ye=()=>{try{let e=globalThis?.crypto;if(e?.randomUUID)return String(e.randomUUID())}catch{}return`career_${Date.now()}_${Math.random().toString(16).slice(2,10)}`},X=e=>Array.isArray(e)?e.slice(0,16).map(e=>({text:c(e?.text).slice(0,1600),thought:!!e?.thought,thoughtSignature:c(e?.thoughtSignature||e?.thought_signature).slice(0,240),functionCall:e?.functionCall&&typeof e.functionCall==`object`?{name:c(e.functionCall?.name).slice(0,120),args:typeof e.functionCall?.args==`string`?c(e.functionCall.args).slice(0,2400):e.functionCall?.args&&typeof e.functionCall.args==`object`?e.functionCall.args:null}:null,functionResponse:e?.functionResponse&&typeof e.functionResponse==`object`?{name:c(e.functionResponse?.name).slice(0,120),response:typeof e.functionResponse?.response==`string`?c(e.functionResponse.response).slice(0,2400):e.functionResponse?.response&&typeof e.functionResponse.response==`object`?e.functionResponse.response:null}:null})):[],be=e=>Array.isArray(e)?e.slice(0,8).map(e=>({id:c(e?.id).slice(0,160),type:c(e?.type).slice(0,40)||`function`,function:e?.function&&typeof e.function==`object`?{name:c(e.function?.name).slice(0,120),arguments:c(e.function?.arguments).slice(0,4e3)}:void 0,extra_content:e?.extra_content&&typeof e.extra_content==`object`?e.extra_content:void 0})):[],xe=e=>(Array.isArray(e)?e:[]).slice(-12).map(e=>({id:c(e.id).slice(0,120),role:e.role,content:c(e.content).slice(0,4e3),createdAt:Number(e.createdAt||0)||Date.now(),reasoningContent:c(e.reasoningContent).slice(0,2400),thoughtSignature:c(e.thoughtSignature).slice(0,240),rawParts:X(e.rawParts),toolCalls:be(e.toolCalls)})),Se=(e,t)=>J([c(e.targetRole),c(e.targetIndustry),c(e.currentRole),...Array.isArray(e.goals)?e.goals:[],...Array.isArray(e.constraints)?e.constraints:[],...String(t||``).split(/[\s\n、，,；。]/g)].flatMap(e=>{let t=c(e);return!t||t.length<=1?[]:t.length>24?[t.slice(0,24)]:[t]}),8),Ce=e=>J([c(e.currentRole),c(e.targetRole),c(e.yearsExperience),c(e.riskTolerance)],6),we=e=>{let t=c(String(e||``).split(`
`).map(e=>c(e)).filter(Boolean).slice(0,3).join(`；`)||String(e||``).slice(0,140));return t.length<=140?t:`${t.slice(0,140)}…`},Te=e=>{let t=String(e||``).replace(/\r/g,``);return t?Array.from(t.matchAll(/<thought>([\s\S]*?)<\/thought>/gi)).map(e=>c(e?.[1]||``)).filter(Boolean).join(`

`).trim():``},Ee=e=>{let t=String(e||``).replace(/\r/g,``);return t?t.replace(/<thought>[\s\S]*?<\/thought>/gi,``).trim():``},De=e=>{let t=Ee(String(e||``).replace(/\r/g,``));if(!t)return``;let n=t,r=t.match(/---JSON_STATE---/);if(r&&typeof r.index==`number`)n=t.slice(0,r.index);else{let e=t.match(/```json\n([\s\S]*)/);e&&typeof e.index==`number`&&(n=t.slice(0,e.index))}n=n.replace(/^<对话回复>[\s\n]*/i,``).replace(/<\/?对话回复>[\s\n]*/gi,``).trim();let i=n.split(`
`).map(e=>e.trimEnd()).filter(e=>!!String(e||``).trim()).join(`
`);return i.length<=16e3?i:`…\n${i.slice(-16e3)}`},Oe=e=>{let t=Te(e),n=[String(e||``).replace(/\r/g,``),t].filter(Boolean).join(`
`).replace(/```[\s\S]*?```/g,``).split(`
`).map(e=>e.trimEnd()),r=[],i=``;for(let e of n){let t=String(e||``).trim();t&&(/^\s*[\{\}\[\],]+\s*$/.test(t)||/output_schema|compact_json|response_format|max_tokens|prompt_tokens/i.test(t)||t!==i&&(i=t,r.push(t)))}let a=r.join(`
`);return a.length<=12e3?a:`…\n${a.slice(-12e3)}`},Z=e=>{let t=c((Array.isArray(e)?e:[]).find(e=>c(e?.function?.name)===`submit_career_coach_result`)?.function?.arguments);if(!t)return null;try{let e=JSON.parse(t);return e&&typeof e==`object`?e:null}catch{return null}},ke=e=>{let t=e&&typeof e==`object`?e:{};return{title:c(t.title)||`职业教练建议`,summary:c(t.summary),stage:c(t.stage),directionVerdict:c(t.directionVerdict||t.verdict),confidenceScore:Number.isFinite(Number(t.confidenceScore))?Math.max(0,Math.min(100,Math.round(Number(t.confidenceScore||0)))):void 0,primaryAction:c(t.primaryAction),nextQuestion:c(t.nextQuestion),profileSnapshot:t.profileSnapshot&&typeof t.profileSnapshot==`object`?t.profileSnapshot:void 0,recommendedTracks:(Array.isArray(t.recommendedTracks)?t.recommendedTracks:[]).slice(0,4).map(e=>({label:c(e?.label),fit:c(e?.fit),why:c(e?.why),risks:J(e?.risks,4),firstStep:c(e?.firstStep)})).filter(e=>e.label||e.why),strengths:J(t.strengths,8),blockers:J(t.blockers,8),opportunities:J(t.opportunities,8),marketSignals:J(t.marketSignals,8),actionPlan:(Array.isArray(t.actionPlan)?t.actionPlan:[]).slice(0,6).map(e=>({phase:c(e?.phase),title:c(e?.title),why:c(e?.why),steps:J(e?.steps,6),recommendedTool:c(e?.recommendedTool),toolPrompt:c(e?.toolPrompt)})).filter(e=>e.title||e.why||Array.isArray(e.steps)&&e.steps.length),resumeFocus:c(t.resumeFocus),interviewFocus:c(t.interviewFocus),compensationStrategy:c(t.compensationStrategy),diagnosis:t.diagnosis&&typeof t.diagnosis==`object`?{stage:c(t.diagnosis?.stage),painPoint:c(t.diagnosis?.painPoint),currentState:c(t.diagnosis?.currentState),urgency:c(t.diagnosis?.urgency)}:void 0,coachingInsights:J(t.coachingInsights,8),gapAnalysis:t.gapAnalysis&&typeof t.gapAnalysis==`object`?{skills:J(t.gapAnalysis?.skills,6),network:J(t.gapAnalysis?.network,6),positioning:J(t.gapAnalysis?.positioning,6),mindset:J(t.gapAnalysis?.mindset,6)}:void 0,roadmap:(Array.isArray(t.roadmap)?t.roadmap:[]).slice(0,4).map(e=>({timeframe:c(e?.timeframe),focus:c(e?.focus),actions:J(e?.actions,6)})).filter(e=>e.timeframe||e.focus||Array.isArray(e.actions)&&e.actions.length),toolRecommendations:(Array.isArray(t.toolRecommendations)?t.toolRecommendations:[]).slice(0,4).map(e=>({tool:c(e?.tool),route:c(e?.route),reason:c(e?.reason),urgency:c(e?.urgency),prefillHint:c(e?.prefillHint)})).filter(e=>e.tool||e.reason),toolExecutionPlan:(Array.isArray(t.toolExecutionPlan)?t.toolExecutionPlan:[]).slice(0,6).map(e=>({tool:c(e?.tool),title:c(e?.title),reason:c(e?.reason),prefillHint:c(e?.prefillHint),fallbackToModel:!!e?.fallbackToModel})).filter(e=>e.tool||e.reason||e.title),toolSchemaVersion:c(t.toolSchemaVersion),toolSchemaSummary:J(t.toolSchemaSummary,8),followUpQuestions:J(t.followUpQuestions,6),knowledgeRefs:(Array.isArray(t.knowledgeRefs)?t.knowledgeRefs:[]).slice(0,6).map(e=>({title:c(e?.title),sourceType:c(e?.sourceType),useFor:c(e?.useFor)})).filter(e=>e.title||e.useFor),caveats:J(t.caveats,8),evidence:J(t.evidence,8),executionLedger:(Array.isArray(t.executionLedger)?t.executionLedger:[]).slice(-12).map(e=>({id:c(e?.id),tool:c(e?.tool),title:c(e?.title),reason:c(e?.reason),status:c(e?.status),source:c(e?.source),startedAt:Number(e?.startedAt||0)||void 0,finishedAt:Number(e?.finishedAt||0)||void 0,requestCount:Number(e?.requestCount||0)||void 0,totalTokens:Number(e?.totalTokens||0)||void 0,estimatedPoints:Number(e?.estimatedPoints||0)||void 0,actualPoints:Number(e?.actualPoints||0)||void 0,pointsStatus:c(e?.pointsStatus)===`actual`||c(e?.pointsStatus)===`mixed`||c(e?.pointsStatus)===`estimated`?c(e?.pointsStatus):void 0,model:c(e?.model),note:c(e?.note)})).filter(e=>e.tool||e.status||e.title),workflowContext:t.workflowContext&&typeof t.workflowContext==`object`?{resumeText:c(t.workflowContext?.resumeText),jdText:c(t.workflowContext?.jdText)}:void 0}},Ae=e=>{let t=String(e||``).trim().toLowerCase();return t===`deep`?{id:`deep`,replyTimeoutMs:6e4,structuredTimeoutMs:3e4,useAgentWhenReady:!0}:t===`lite`?{id:`lite`,replyTimeoutMs:25e3,structuredTimeoutMs:18e3,useAgentWhenReady:!1}:{id:`standard`,replyTimeoutMs:4e4,structuredTimeoutMs:24e3,useAgentWhenReady:!0}},je=async e=>{try{e.onStatus?.(`正在整理外部上下文…`);let t=[],n=String(e.prompt||``),r=String(e.profile?.summary||``),i=P.buildRoleContextFromText([n,r,String(e.profile?.targetRole||``),String(e.profile?.targetIndustry||``),...Array.isArray(e.profile?.goals)?e.profile.goals:[]].join(`
`));i&&t.push(i);let a=/([^，。！？,!?\s]{2,10}(大学|学院|分校|Institute|University|College))/gi,o=new Set,s;for(;(s=a.exec(n))!==null;)o.add(s[1].trim());for(;(s=a.exec(r))!==null;)o.add(s[1].trim());if(o.size>0){e.onStatus?.(`正在查验高校背景字典…`);for(let e of Array.from(o).slice(0,3)){let n=await re.getSchoolSummaryContext(e);n&&t.push(n)}}return t}catch(e){console.warn(`CareerCoach: Failed to collect external context`,e)}return[]},Me=(e,t=[])=>{let n=Z(t);if(n&&typeof n==`object`)return n;let r=c(e);if(!r)return null;let i=r.match(/```json\n([\s\S]*?)```/)?.[1]?.trim()||k(r);try{let e=JSON.parse(i);return e&&typeof e==`object`?e:null}catch{return null}},Ne={title:`string`,summary:`string`,stage:`string`,directionVerdict:`string`,confidenceScore:`number(0-100)`,primaryAction:`string`,nextQuestion:`string`,strengths:[`string`],blockers:[`string`],opportunities:[`string`],actionPlan:[{phase:`string`,title:`string`,why:`string`,steps:[`string`],recommendedTool:`string`,toolPrompt:`string`}],resumeFocus:`string`,interviewFocus:`string`,compensationStrategy:`string`,followUpQuestions:[`string`],caveats:[`string`],evidence:[`string`]},Pe=`deepseek_pro`,Fe=`deepseek`,Ie=`deepseek-v4-pro`,Le=e=>e.reduce((e,t)=>e+c(t?.content).length+c(t?.preview).length+c(t?.name).length,0),Re=e=>e.reduce((e,t)=>e+c(t?.content).length,0),ze=e=>{try{return JSON.stringify(e||{}).length}catch{return c(e?.summary).length+c(e?.currentRole).length+c(e?.targetRole).length}},Be=e=>{let t=e.currentResult&&typeof e.currentResult==`object`?e.currentResult:null,n={profile:e.profile||{},userInput:e.userInput,assistantReply:c(e.assistantReply).slice(0,2200),currentResult:t?{title:c(t.title),summary:c(t.summary),directionVerdict:c(t.directionVerdict),primaryAction:c(t.primaryAction),nextQuestion:c(t.nextQuestion),strengths:Array.isArray(t.strengths)?t.strengths.slice(0,4):[],blockers:Array.isArray(t.blockers)?t.blockers.slice(0,4):[],opportunities:Array.isArray(t.opportunities)?t.opportunities.slice(0,4):[],actionPlan:Array.isArray(t.actionPlan)?t.actionPlan.slice(0,3).map(e=>({phase:c(e?.phase),title:c(e?.title),why:c(e?.why),steps:Array.isArray(e?.steps)?e.steps.slice(0,3):[]})):[]}:null,recentTurns:c(e.recentTurns).slice(0,1400),recentToolContext:c(e.recentToolContext).slice(0,600),knowledgeContext:Array.isArray(e.knowledgeContext)?e.knowledgeContext.slice(0,4).map(e=>({title:c(e?.title),sourceType:c(e?.sourceType),summary:c(e?.summary).slice(0,180)})):[],uploadedDocs:Array.isArray(e.uploadedDocs)?e.uploadedDocs.slice(0,4).map(e=>({name:c(e?.name),preview:c(e?.preview)})):[],resumeText:c(e.resumeText).slice(0,1200),jdText:c(e.jdText).slice(0,1200),pinnedContext:c(e.pinnedContext),progressSummary:c(e.progressSummary)},r=JSON.stringify(Ne,null,2),i=JSON.stringify(n,null,2);return{messages:[{role:`system`,content:e.retry?`你是资深中文职业教练。上一次输出未能被解析。本次必须只输出一个合法 JSON 对象，不要输出任何解释、Markdown、代码块或额外文字。`:`你是资深中文职业教练。请基于给定上下文生成结构化详细规划。必须只输出一个合法 JSON 对象，不要输出任何解释、Markdown、代码块或额外文字。`},{role:`user`,content:[`请基于以下上下文，输出职业教练详细规划。`,`要求：`,`1. 结论要具体、可执行，避免空泛表述。`,`2. actionPlan 输出 3-5 条，steps 每条 2-5 步。`,`3. strengths / blockers / opportunities / followUpQuestions / caveats / evidence 都尽量填写。`,`4. 如果信息不足，也要给出当前最稳妥的建议，并在 caveats 中说明缺口。`,`5. recommendedTool 只允许填写：resume_match、resume_optimize、jd_analysis、resume_translate、resume_html、market_signal_scan、job_search_strategy、interview_coach、salary_negotiation、none。`,``,`输出 JSON Schema：`,r,``,`上下文：`,i].join(`
`)}],temperature:e.retry?.1:.2,max_tokens:3600}};function Ve(e){let t=(0,q.useRef)(e);t.current=e;let n=(0,q.useCallback)(async()=>{let{sessionId:e,detailBusy:n,coachConsentAccepted:r,profile:i,result:a,setResult:s,setErr:l,dialogInput:u,setDialogInput:d,chatTurns:p,uploadedDocs:m,setStreamText:h,writeToolConversationRun:g,start:_,setProgress:v,appendChatTurn:y,updateChatTurn:b,abortRef:x,clearDetailCardTimers:S,setDetailBusy:C,setDetailStatus:w,setDetailCardTurnId:T,setDetailCardStage:D,setBusy:O,makeId:k,setSessionId:M,navigate:N,runSeqRef:F,pendingAttachments:I,setPendingAttachments:ee,resetBufferedConversationState:L,setStreamThinking:R,setStreamStage:z,setStreamActor:re,streamTextRawRef:ie,streamThinkingRawRef:ae,streamTextFlushTimerRef:B,streamThinkingFlushTimerRef:se,setModelChoiceState:V,syncProfileToCloud:ce,syncSessionToCloud:U,listLocalToolResultSummaries:W,listCareerCoachKnowledgeItems:K,analysisDepth:le,withTimeout:ue,done:de,failByMessage:fe,executionLedger:pe,derivedResumeText:me,derivedJdText:he,pinnedContext:ge,autoProgressSummary:q,beginDetailCardReveal:J,normalizeToolError:_e,sanitizeTurnRawParts:ve,buildPlainStreamPreview:Y}=t.current,ye=await o();if(!ye?.token){window.location.href=E();return}if(!r){l(`请先确认职业教练的专业模型与扣费提示，再开始使用。`);return}let X=c(u);if(!X&&!m.length&&!c(i.summary)&&!c(i.currentRole)&&!c(i.targetRole)){l(`请先输入你的问题、职业背景，或上传简历后再开始。`);return}try{let e=await oe({tool:`career_coach`,modelChoice:Pe,inputChars:X.length+ze(i)+c(ge).length+c(q).length,docsChars:Le(m),chatChars:Re(p),resumeChars:c(me).length,jdChars:c(he).length,outputChars:9e3});if(!e.ok){l(`${e.message} 请先充值后再开始。`);return}}catch(e){l(String(e?.message||`暂时无法校验积分余额，请稍后重试。`));return}if(n&&x.current)try{x.current.abort()}catch{}l(``),S(),C(!1),w(``),T(``),D(0),s(null),_(),v(10),O(!0);let be=c(e)||k();if(!c(e)){M(be);try{N(`/tools/career-coach?sid=${encodeURIComponent(be)}`,{replace:!0})}catch{}}let Ee=++F.current,De=new AbortController;x.current=De;let Z=De.signal,Ne=await te({pageSize:100,rangeDays:1}),Fe=I.slice(),Ie=X||Fe.length?{id:`turn_u_${Date.now()}_${Math.random().toString(16).slice(2,8)}`,role:`user`,content:X,attachments:Fe,createdAt:Date.now()}:null;(X||Fe.length)&&y(Ie);let Be=Ie?[...p,Ie].slice(-80):p.slice(-80);ee([]),d(``),L({setStreamText:h,setStreamThinking:R,setStreamStage:z,setStreamActor:re,streamTextRawRef:ie,streamThinkingRawRef:ae,streamTextFlushTimerRef:B,streamThinkingFlushTimerRef:se}),V(`deepseek_pro`),await ce(i);let Ve=!1,Q=Be,He=``;try{await U({status:`running`,sid:be,chatTurnsOverride:Be,uploadedDocsOverride:m,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}})}catch(e){console.warn(`Failed to sync session to cloud initially:`,e)}try{let e=(Ie?Be.slice(0,-1):Be).filter(e=>e.role===`user`||e.role===`assistant`),t=xe(e),n=e.slice(-12).map(e=>`${e.role===`assistant`?`AI`:`用户`}：${c(e.content).slice(0,700)}`).filter(Boolean).join(`
`),r=W({userId:c(ye?.user?.id)}).slice(0,6).map(e=>{let t=c(e?.insightSummary?.headline),n=c(e?.insightSummary?.primaryAction);return`${c(e.toolType)}｜${c(e.title)}${t?`｜${t}`:``}${n?`｜下一步：${n}`:``}`}).filter(Boolean).join(`
`),a=``;try{let e=await G(X,Z,e=>{z(e),w(e)});e.triggered&&e.contextText&&(a=e.contextText)}catch{}let o=[a,r].filter(Boolean).join(`

`),l=Ae(le),u=await K({query:[X,c(i.targetRole),c(i.targetIndustry),...Array.isArray(i.goals)?i.goals:[]].filter(Boolean).join(`；`),tags:Se(i,X),audienceTags:Ce(i),limit:6}).catch(()=>[]),d=(Array.isArray(u)?u:[]).slice(0,6).map(e=>({title:c(e.title),sourceType:c(e.sourceType),tags:Array.isArray(e.tags)?e.tags:[],audienceTags:Array.isArray(e.audienceTags)?e.audienceTags:[],summary:c(e.summary).slice(0,260),content:c(e.content).slice(0,900)})),p=await je({mode:l.id,prompt:X,profile:i,signal:Z,onStatus:w}).catch(()=>[]),_=[...p,...d].slice(0,6),S=m.slice(-6).map(e=>({name:e.name,preview:c(e.preview||we(e.content)),content:c(e.content).slice(0,6e3)})),T={},E=await f(),D=l.replyTimeoutMs,k=c(ge),M=c(q),N=P.buildRoleContextFromText([X,c(i.targetRole),c(i.targetIndustry),...Array.isArray(i.goals)?i.goals:[],he,me].join(`
`)),I=H({tool:`career_coach`,runSeq:Ee,runSeqRef:F,stage:`career_coach`,agentLabel:`Agent: career-coach`,skillLabel:`Skill: career_coach`,setStreamStage:z,setStreamActor:re,setStreamText:h,setStreamThinking:R,buildPlainStreamPreview:Y,sanitizeThinking:Oe,streamTextRawRef:ie,streamThinkingRawRef:ae,streamTextFlushTimerRef:B,streamThinkingFlushTimerRef:se,hideModelMeta:!0}),ee=c(me).length>100,te=c(he).length>50;if(ee&&te&&l.useAgentWhenReady){w(`正在分析...`);let e=await ue(j({proxyUrl:E.proxyUrl,gatewayApiKey:E.gatewayApiKey,clientId:E.clientId,tier:E.tier,data:{userInput:X,resume:me,jd:he,profile:i,pinnedContext:k,progressSummary:M,roleContext:N,historyTurns:t,runtimeMode:l.id,externalContext:p},signal:Z,onToolStart:(e,t,n)=>{w(t),I.onText(`\n\n*${t}*`)},onToolDone:(e,t)=>{w(`整理结果中...`)},onText:e=>{I.onText(e)}}),D,`职业教练 Agent`);w(``);let n=`turn_a_${Date.now()}_${Math.random().toString(16).slice(2,8)}`;He=n;let r={id:n,role:`assistant`,content:e,createdAt:Date.now()};y(r),Ve=!0,Q=[...Be,r];let a=Me(e),o=a?{...ke(a),...pe.length?{executionLedger:pe.slice(-24)}:{},workflowContext:{resumeText:me,jdText:he}}:null;o&&(s(o),J(n,o));let c=await ne({beforeIds:Ne,aggregateAllNew:!0,pageSize:100,rangeDays:1}),u=c&&{...c,model:``};u&&(b(n,{billing:u}),Q=Q.map(e=>e.id===n?{...e,billing:u}:e)),g(`career_coach`,{runState:`done`,progress:100,sessionId:be,profile:i,analysisDepth:le,result:o,chatTurns:Q,uploadedDocs:m.slice(-12)}),await U({status:`done`,sid:be,nextResult:o,chatTurnsOverride:Q,uploadedDocsOverride:m,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}}),L({setStreamText:h,setStreamThinking:R,setStreamStage:z,setStreamActor:re,streamTextRawRef:ie,streamThinkingRawRef:ae,streamTextFlushTimerRef:B,streamThinkingFlushTimerRef:se}),x.current=null,O(!1),de();return}let oe=e=>{let t=Te(e);t&&I.onThinking(t),I.onText(e)},V=await ue(A({proxyUrl:E.proxyUrl,gatewayApiKey:E.gatewayApiKey,clientId:E.clientId,tier:E.tier,preset:`career_coach`,provider:`deepseek`,model:`deepseek-v4-pro`,data:{lang:`zh-CN`,mode:l.id,outputMode:`reply_only`,profile:{...i,goals:Array.isArray(i.goals)?i.goals:[],constraints:Array.isArray(i.constraints)?i.constraints:[]},recentTurns:n,historyTurns:t,pinnedContext:k,progressSummary:M,roleContext:N,userInput:X,uploadedDocs:S,recentToolContext:o,knowledgeContext:_,externalContext:p},thinking:!0,signal:Z,onThinking:I.onThinking,onText:oe,onToolCalls:e=>{T.toolCalls=Array.isArray(e)?e:[]},onResponseMeta:e=>{I.onMeta({type:`start`,requestId:``,provider:e.provider,model:e.model}),T.provider=c(e.provider||T.provider),T.model=c(e.model||T.model),T.fallbackMeta=e.fallback&&typeof e.fallback==`object`?{fromProvider:c(e.fallback?.fromProvider),fromModel:c(e.fallback?.fromModel),provider:c(e.fallback?.provider),model:c(e.fallback?.model)}:T.fallbackMeta||null,T.reasoningContent=Oe(String(e.reasoningContent||T.reasoningContent||``)),T.thoughtSignature=c(e.thoughtSignature||T.thoughtSignature),T.thoughtsTokens=Math.max(0,Number(e.thoughtsTokens||T.thoughtsTokens||0)),T.rawParts=ve(e.rawParts),Array.isArray(e.toolCalls)&&(T.toolCalls=e.toolCalls)}}),D,`职业教练生成`);if(Ee!==F.current)return;I.flushPending(),c(T.reasoningContent)||(T.reasoningContent=Oe(Te(V)));let ce=Me(V,T.toolCalls||[]),fe=ce?{...ke(ce),...pe.length?{executionLedger:pe.slice(-24)}:{},workflowContext:{resumeText:me,jdText:he}}:null,_e=Y(V),De={id:`turn_a_${Date.now()}_${Math.random().toString(16).slice(2,8)}`,role:`assistant`,content:_e,createdAt:Date.now(),providerMeta:null,fallbackMeta:null};He=De.id,y(De),fe&&(s(fe),J(De.id,fe)),Q=[...Be,De].slice(-80),Ve=!0,L({setStreamText:h,setStreamThinking:R,setStreamStage:z,setStreamActor:re,streamTextRawRef:ie,streamThinkingRawRef:ae,streamTextFlushTimerRef:B,streamThinkingFlushTimerRef:se}),v(58),O(!1),C(!1),w(``),g(`career_coach`,{runState:`partial`,progress:58,sessionId:be,profile:i,analysisDepth:le,result:fe,chatTurns:Q,uploadedDocs:m.slice(-12),streamThinking:``,streamStage:``,streamActor:``});let Pe=await ne({beforeIds:Ne,aggregateAllNew:!0,pageSize:100,rangeDays:1}),Fe=Pe&&{...Pe,model:``,...Number(T.thoughtsTokens||0)>0?{thoughtsTokens:Math.max(0,Number(T.thoughtsTokens||0))}:{}},Le={...De,content:_e||De.content,billing:Fe,providerMeta:null,fallbackMeta:null,reasoningContent:Oe(String(T.reasoningContent||``)),thoughtSignature:c(T.thoughtSignature),rawParts:ve(T.rawParts),toolCalls:Array.isArray(T.toolCalls)?T.toolCalls:void 0};b(He,Le);let Re=Q.map(e=>e.id===He?Le:e).slice(-80);de(),v(100),C(!1),w(``),g(`career_coach`,{runState:`done`,progress:100,sessionId:be,profile:i,analysisDepth:le,result:fe,chatTurns:Re,uploadedDocs:m.slice(-12)}),await U({status:`done`,sid:be,nextResult:fe,chatTurnsOverride:Re,uploadedDocsOverride:m,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}})}catch(e){if(Ee!==F.current)return;let t=_e(e,`生成失败`);if(L({setStreamText:h,setStreamThinking:R,setStreamStage:z,setStreamActor:re,streamTextRawRef:ie,streamThinkingRawRef:ae,streamTextFlushTimerRef:B,streamThinkingFlushTimerRef:se}),C(!1),w(``),Ve){x.current=null,O(!1),de(),v(100),l(t===`已取消`?`已取消`:``),g(`career_coach`,{runState:`done`,progress:100,sessionId:be,profile:i,analysisDepth:le,result:a,chatTurns:Q,uploadedDocs:m.slice(-12)}),await U({status:`done`,sid:be,nextResult:a,chatTurnsOverride:Q,uploadedDocsOverride:m,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}});return}fe(t,l),O(!1),g(`career_coach`,{runState:t===`已取消`?`cancelled`:`failed`,err:t}),await U({status:`failed`,sid:be,error:t,chatTurnsOverride:Be,uploadedDocsOverride:m,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}})}},[]),r=(0,q.useCallback)(async e=>{let{sessionId:n,busy:r,detailBusy:i,coachConsentAccepted:a,profile:s,setResult:l,setErr:u,chatTurns:d,uploadedDocs:p,writeToolConversationRun:m,abortRef:h,clearDetailCardTimers:g,setDetailBusy:_,setDetailStatus:v,setDetailCardTurnId:y,setDetailCardStage:b,setStreamText:x,setStreamThinking:S,setStreamStage:C,setStreamActor:w,streamTextRawRef:T,streamThinkingRawRef:D,streamTextFlushTimerRef:O,streamThinkingFlushTimerRef:k,runSeqRef:j,buildPlainStreamPreview:N,resetBufferedConversationState:P,syncSessionToCloud:F,listLocalToolResultSummaries:I,listCareerCoachKnowledgeItems:ee,analysisDepth:L,withTimeout:R,executionLedger:te,derivedResumeText:ne,derivedJdText:z,pinnedContext:re,autoProgressSummary:ie,beginDetailCardReveal:ae,normalizeToolError:B,sanitizeTurnRawParts:se,sanitizeTurnToolCalls:V}=t.current;if(r||i)return;if(!a){u(`请先确认职业教练的专业模型与扣费提示，再开始使用。`);return}let ce=await o();if(!ce?.token){window.location.href=E();return}let U=c(e.id);if(!U)return;let W=d.findIndex(e=>c(e.id)===U),G=(W>=0?d.slice(0,W+1):d.slice()).filter(e=>e.role===`user`||e.role===`assistant`),K=c([...G].reverse().find(e=>e.role===`user`)?.content);if(!K){u(`请先完成一轮对话，再生成详细规划。`);return}try{let t=await oe({tool:`career_coach`,modelChoice:Pe,inputChars:K.length+c(e.content).length+ze(s)+c(re).length+c(ie).length,docsChars:Le(p),chatChars:Re(G),resumeChars:c(ne).length,jdChars:c(z).length,outputChars:7e3});if(!t.ok){u(`${t.message} 请先充值后再开始。`);return}}catch(e){u(String(e?.message||`暂时无法校验积分余额，请稍后重试。`));return}u(``),g(),_(!0),v(`正在生成详细规划…`),y(U),b(0),l(null),P?.({setStreamText:x,setStreamThinking:S,setStreamStage:C,setStreamActor:w,streamTextRawRef:T,streamThinkingRawRef:D,streamTextFlushTimerRef:O,streamThinkingFlushTimerRef:k});let le=j.current,ue=new AbortController;h.current=ue;let de=ue.signal,fe=G.slice(-12).map(e=>`${e.role===`assistant`?`AI`:`用户`}：${c(e.content).slice(0,700)}`).filter(Boolean).join(`
`),pe=I({userId:c(ce?.user?.id)}).slice(0,6).map(e=>{let t=c(e?.insightSummary?.headline),n=c(e?.insightSummary?.primaryAction);return`${c(e.toolType)}｜${c(e.title)}${t?`｜${t}`:``}${n?`｜下一步：${n}`:``}`}).filter(Boolean).join(`
`),me=Ae(L),he=await ee({query:[K,c(s.targetRole),c(s.targetIndustry),...Array.isArray(s.goals)?s.goals:[]].filter(Boolean).join(`；`),tags:Se(s,K),audienceTags:Ce(s),limit:6}).catch(()=>[]),ge=(Array.isArray(he)?he:[]).slice(0,6).map(e=>({title:c(e.title),sourceType:c(e.sourceType),tags:Array.isArray(e.tags)?e.tags:[],audienceTags:Array.isArray(e.audienceTags)?e.audienceTags:[],summary:c(e.summary).slice(0,260),content:c(e.content).slice(0,900)})),q=[...await je({mode:me.id,prompt:K,profile:s,signal:de,onStatus:v}).catch(()=>[]),...ge].slice(0,6),J=p.slice(-6).map(e=>({name:e.name,preview:c(e.preview||we(e.content)),content:c(e.content).slice(0,6e3)})),_e=c(re),ve=c(ie),Y={};try{let r=await f(),i=me.structuredTimeoutMs,a=Be({userInput:K,assistantReply:c(e.content),profile:s,currentResult:t.current.result,recentTurns:fe,recentToolContext:pe,knowledgeContext:q,uploadedDocs:J,resumeText:ne,jdText:z,pinnedContext:_e,progressSummary:ve}),o=H({tool:`career_coach`,runSeq:le,runSeqRef:j,stage:`详细规划生成中`,agentLabel:`Agent: career-coach`,skillLabel:`Skill: detailed_plan`,setStreamStage:C,setStreamActor:w,setStreamText:x,setStreamThinking:S,buildPlainStreamPreview:N,sanitizeThinking:Oe,streamTextRawRef:T,streamThinkingRawRef:D,streamTextFlushTimerRef:O,streamThinkingFlushTimerRef:k,hideModelMeta:!0}),u=await R(A({proxyUrl:r.proxyUrl,gatewayApiKey:r.gatewayApiKey,clientId:r.clientId,tier:r.tier,payload:a,provider:`deepseek`,model:`deepseek-v4-pro`,thinking:!0,signal:de,onMeta:o.onMeta,onText:o.onText,onThinking:o.onThinking,onResponseMeta:e=>{Y.provider=c(e.provider||Y.provider),Y.model=c(e.model||Y.model),Y.rawParts=se(e.rawParts),Array.isArray(e.toolCalls)&&(Y.toolCalls=V(e.toolCalls))},_forceDirectProxy:!0}),i,`职业教练详细规划生成`);o.flushPending();let h=Me(u,Y.toolCalls||[]),g=!!(h&&typeof h==`object`&&!Array.isArray(h)&&!Object.keys(h).length);if(!h||typeof h!=`object`||g){let n=Be({userInput:K,assistantReply:c(e.content),profile:s,currentResult:t.current.result,recentTurns:fe,recentToolContext:pe,knowledgeContext:q,uploadedDocs:J,resumeText:ne,jdText:z,pinnedContext:_e,progressSummary:ve,retry:!0});h=Me(await R(M({proxyUrl:r.proxyUrl,gatewayApiKey:r.gatewayApiKey,clientId:r.clientId,tier:r.tier,payload:n,provider:Fe,model:Ie,thinking:!0,onResponseMeta:e=>{Y.provider=c(e.provider||Y.provider),Y.model=c(e.model||Y.model),Y.rawParts=se(e.rawParts),Array.isArray(e.toolCalls)&&(Y.toolCalls=V(e.toolCalls))},signal:de,_forceDirectProxy:!0}),Math.min(i,9e4),`职业教练详细规划重试`),Y.toolCalls||[])}if(!h||typeof h!=`object`||!Object.keys(h).length)throw Error(`详细规划生成失败，请稍后再试`);let y={...ke(h),...te.length?{executionLedger:te.slice(-24)}:{},workflowContext:{resumeText:ne,jdText:z}};l(y),ae(U,y),v(``),_(!1),P?.({setStreamText:x,setStreamThinking:S,setStreamStage:C,setStreamActor:w,streamTextRawRef:T,streamThinkingRawRef:D,streamTextFlushTimerRef:O,streamThinkingFlushTimerRef:k}),m(`career_coach`,{runState:`done`,progress:100,sessionId:c(n),profile:s,analysisDepth:L,result:y,chatTurns:d,uploadedDocs:p.slice(-12)}),await F({status:`done`,nextResult:y,chatTurnsOverride:d,uploadedDocsOverride:p,runtimeState:{modelChoice:`deepseek_pro`,thinkingEnabled:!0}})}catch(e){_(!1),v(``),P?.({setStreamText:x,setStreamThinking:S,setStreamStage:C,setStreamActor:w,streamTextRawRef:T,streamThinkingRawRef:D,streamTextFlushTimerRef:O,streamThinkingFlushTimerRef:k}),u(B(e,`详细规划生成失败`))}},[]);return(0,q.useMemo)(()=>({submit:n,generateDetailedPlan:r}),[n,r])}var Q=async e=>{let t=await o();if(!t?.token)throw Error(`请先登录后再使用职业教练工作流。`);let n=await f(),r=c(n.proxyUrl),i=c(n.gatewayApiKey);if(!r||!i)throw Error(`代理配置缺失`);let a=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,apikey:i,Authorization:`Bearer ${i}`,"x-auth-token":t.token,"x-client-id":`career_workflow:${Date.now()}`},body:JSON.stringify(e||{})}),s=null;try{s=await a.json()}catch{}if(!a.ok)throw Error(c(s?.message)||c(s?.error)||`职业教练工作流执行失败`);return s},He=e=>({ok:!!e?.ok,sessionId:c(e?.sessionId)||void 0,completedCount:Number(e?.completedCount||0)||0,stoppedAt:c(e?.stoppedAt)||void 0,steps:Array.isArray(e?.steps)?e.steps.map(e=>({id:c(e?.id),tool:c(e?.tool),title:c(e?.title),reason:c(e?.reason),status:c(e?.status)===`failed`?`failed`:c(e?.status)===`skipped`?`skipped`:`completed`,requestId:c(e?.requestId)||void 0,requestCount:Number(e?.requestCount||0)||void 0,totalTokens:Number(e?.totalTokens||0)||void 0,estimatedPoints:Number(e?.estimatedPoints||0)||void 0,model:c(e?.model)||void 0,note:c(e?.note)||void 0,outputText:c(e?.outputText)||void 0,source:c(e?.source)||void 0})).filter(e=>e.id&&e.tool):[]}),Ue=async e=>He(await Q({op:`career_tool_execute`,sessionId:c(e.sessionId),profile:e.profile,resumeText:c(e.resumeText),jdText:c(e.jdText),steps:Array.isArray(e.steps)?e.steps:[]})),We=async e=>{try{let e=await o(),t=String(e?.user?.id||``).trim();if(t)return`u:${t}`.slice(0,120)}catch{}return String(e||`public`).slice(0,120)||`public`},Ge=async e=>{let t=await l();return t?e.map(e=>({...e,jd:N(String(e?.jd||``),t)})):e},Ke=e=>Array.isArray(e)?e.map(e=>String(e??``)).filter(Boolean).slice(0,30):[],qe=(e,t)=>{let n=String(e||``).trim();return n?n.length>t?`${n.slice(0,t)}…`:n:``},Je=(e,t,n)=>{let r=Math.min(Math.max(1,Number(n?.maxJobs||12)||12),e.length),i=Math.max(120,Math.min(8e3,Number(n?.excerptLen||4e3)||4e3));return e.slice(0,r).map(e=>{let n=String(e.description||``),r=t===`none`?``:t===`full`?n:qe(n,i);return{id:String(e.id||``),title:String(e.title||``),company:String(e.company||``),location:String(e.location||e.city_name||e.province_name||``),experience:String(e.experience||``),education:String(e.education||``),salary_text:String(e.salary?.text||``),salary_min:Number(e.salary?.min||0)||0,salary_max:Number(e.salary?.max||0)||0,platform:String(e.platform||``),jd:r}})},Ye=(e,t)=>{let n=e&&typeof e==`object`?e:{},r=e=>String(e??``).trim(),i=r(n.title)||(t.toLowerCase().startsWith(`zh`)?`JD 优化`:`JD Optimization`);return{lang:r(n.lang)||t,title:i,optimizedJd:r(n.optimizedJd),formatPatterns:Ke(n.formatPatterns||n.format||n.patterns).slice(0,20),keywords:Ke(n.keywords).slice(0,30),sellingPoints:Ke(n.sellingPoints||n.selling_points||n.highlights).slice(0,20),talentPersona:r(n.talentPersona||n.persona||n.talent_profile),changes:Ke(n.changes).slice(0,20),competencies:Ke(n.competencies).slice(0,20),risks:Ke(n.risks).slice(0,20),caveats:Ke(n.caveats).slice(0,10)}},Xe=async(e,t)=>{let n=await f();if(!n.enabled||!n.proxyUrl)throw Error(`AI 网关未启用或配置不完整`);let r=await We(n.clientId||`public`),i=s(),a=await p(),o=await d()===`glm5`,c=o&&a.jdMode===`full`?`excerpt`:a.jdMode,l=Array.isArray(e?.referenceJobs)?e.referenceJobs:[],u=e?.targetJob||null,m=String(e?.roleTitle||``).trim(),h=String(e?.requirementsIdea||``).trim(),g=Array.isArray(e?.clarifyQa)?e.clarifyQa:[],_=String(e?.extraContext||``).trim(),v=String(e?.style||`professional`).trim(),y=P.buildRoleContextFromText([m,h,_,...g.map(e=>`${String(e?.q||``)}\n${String(e?.a||``)}`)].join(`
`)),b=await re.buildUniversityContextFromText([m,h,_,...g.map(e=>`${String(e?.q||``)}\n${String(e?.a||``)}`)].join(`
`)).catch(()=>``),x=[_,y,b].filter(Boolean).join(`
`).slice(0,1200);if(!l.length&&!u&&!m&&!h)throw Error(i.toLowerCase().startsWith(`zh`)?`请至少选择岗位参考或输入岗位名称/岗位要求`:`Provide reference jobs or role info`);let S=await Ge(Je(l,c,{maxJobs:5,excerptLen:o?3e3:4e3})),C=u?(await Ge(Je([u],c,{maxJobs:1,excerptLen:o?3e3:4e3})))?.[0]||{}:null,w=await M({proxyUrl:n.proxyUrl,gatewayApiKey:n.gatewayApiKey,clientId:r,tier:n.tier,preset:`optimize_jd`,data:{lang:i,referenceJobs:S,targetJob:C,roleTitle:qe(m,120),requirementsIdea:qe(h,2200),clarifyQa:g.map(e=>({q:String(e?.q||``).trim(),a:String(e?.a||``).trim()})).filter(e=>e.q&&e.a).slice(0,8),extraContext:x,style:v.slice(0,40),roleContext:y,universityContext:b},signal:t?.signal}),T=null;try{T=JSON.parse(k(w))}catch{let e=String(w||``).slice(0,220).replace(/\s+/g,` `).trim();throw Error(e?`代理未返回可解析的 JSON：${e}`:`代理未返回可解析的 JSON`)}let E=Ye(T,i),D=E.caveats||[],O=i.toLowerCase().startsWith(`zh`)?`该JD优化由云端大模型生成，输出可能不准确`:`JD optimization generated by a cloud LLM; output may be inaccurate.`;return D.includes(O)||D.unshift(O),E.caveats=D.slice(0,10),E},Ze={resume_match:`简历匹配`,resume_optimize:`简历优化`,jd_analysis:`JD 分析`,resume_translate:`简历翻译`,resume_html:`HTML 简历`},Qe={...Ze,market_signal_scan:`市场信号扫描`,job_search_strategy:`求职推进策略`},$e=e=>{let t=c(e).toLowerCase();return t===`resume_match`?`resume_match`:t===`resume_optimize`?`resume_optimize`:t===`resume_translate`?`resume_translate`:t===`resume_html_generation`||t===`resume_html`?`resume_html`:t===`optimize_jd`||t===`jd_analysis`||t===`jd_clarify`?`jd_analysis`:``},et=e=>{let t=$e(e);if(t)return t;let n=c(e).toLowerCase();return n===`market_signal_scan`?`market_signal_scan`:n===`job_search_strategy`?`job_search_strategy`:``},tt=e=>Qe[e]||c(e)||`协同步骤`,nt=e=>({requiresResume:e===`resume_match`||e===`resume_optimize`||e===`resume_translate`||e===`resume_html`,requiresJd:e===`resume_match`||e===`resume_optimize`||e===`jd_analysis`}),rt=(e,t,n,r)=>({id:`${e}_${Math.random().toString(16).slice(2,8)}`,kind:e,title:c(r?.title)||Qe[e],reason:c(t)||`执行${Qe[e]}`,prefillHint:c(n)||void 0,source:r?.source||`heuristic`,fallbackToModel:!!r?.fallbackToModel,...nt(e)}),it=(e,t)=>t.map(t=>e.indexOf(t)).filter(e=>e>=0).sort((e,t)=>e-t)[0]??-1,at=e=>{let t=c(e.userInput).toLowerCase(),n=!!c(e.resumeText),r=!!c(e.jdText),i=[],a=(e,t,n,r)=>{i.some(t=>t.kind===e)||i.push(rt(e,t,n,r))};(Array.isArray(e.result?.toolExecutionPlan)&&e.result?.toolExecutionPlan||[]).forEach(e=>{let t=et(c(e?.tool));t&&a(t,c(e?.reason)||`根据职业教练编排执行${Qe[t]}`,c(e?.prefillHint),{title:c(e?.title),source:`tool_execution_plan`,fallbackToModel:!!e?.fallbackToModel})}),(Array.isArray(e.result?.toolRecommendations)&&e.result?.toolRecommendations||[]).forEach(e=>{let t=et(c(e?.tool));t&&a(t,c(e?.reason)||`根据职业教练建议执行${Qe[t]}`,c(e?.prefillHint),{source:`tool_recommendation`})}),(Array.isArray(e.result?.actionPlan)&&e.result?.actionPlan||[]).forEach(e=>{let t=et(c(e?.recommendedTool));t&&a(t,c(e?.toolPrompt)||c(e?.title)||`根据行动计划执行${Qe[t]}`,``,{source:`action_plan`})});let o=[],s=(e,n,r,i=!0)=>{if(!i)return;let a=it(t,n);a<0||o.push({kind:e,index:a,reason:r})};return s(`jd_analysis`,[`jd`,`岗位`,`职位`,`要求`,`职责`,`分析`],`按你当前提问，先拆解岗位关键词、风险点与目标画像`,r),s(`resume_match`,[`匹配`,`对比`,`适配`,`符合`],`按你当前提问，先判断简历与目标岗位的匹配度`,n&&r),s(`resume_optimize`,[`优化`,`改写`,`重写`,`润色`],`按你当前提问，直接进入简历优化与强化`,n&&r),s(`resume_translate`,[`英文`,`翻译`,`english`,`海外`],`按你当前提问，直接生成英文版简历`,n),s(`resume_html`,[`html`,`pdf`,`导出`,`排版`,`打印`],`按你当前提问，生成可导出版本`,n),o.sort((e,t)=>e.index-t.index).forEach(e=>a(e.kind,e.reason,``,{source:`heuristic`})),!i.length&&n&&r&&a(`resume_match`,`当前已具备简历与 JD，先做匹配判断更容易找到下一步重点`,``,{source:`heuristic`}),i.filter(e=>(!e.requiresResume||n)&&(!e.requiresJd||r)).slice(0,5)},ot=`deepseek_pro`,st=`deepseek`,ct=`deepseek-v4-pro`,lt=`deepseek`,ut=`deepseek-v4-flash`,dt=e=>e===`resume_match`?`resume_match`:e===`resume_optimize`?`resume_optimize`:e===`resume_translate`?`resume_translate`:`career_coach`,ft=e=>e===`resume_match`?lt:ot;function pt({sessionId:e,isAuthed:t,busy:n,detailBusy:r,coachConsentAccepted:i,profile:a,result:s,setResult:l,setErr:u,dialogInput:d,chatTurns:f,uploadedDocs:p,buildActionHref:m,jumpToRecommendedTool:h,appendChatTurn:g}){let[_,v]=(0,q.useState)(`resume_match`),[y,b]=(0,q.useState)(``),[x,C]=(0,q.useState)(``),[w,D]=(0,q.useState)(!1),[k,A]=(0,q.useState)(0),[j,M]=(0,q.useState)(``),[N,P]=(0,q.useState)(!1),[F,I]=(0,q.useState)(``),[ee,L]=(0,q.useState)([]),[R,z]=(0,q.useState)([]),[re,B]=(0,q.useState)(null),V=(e,t)=>{g({id:`turn_tool_${Date.now()}_${Math.random().toString(16).slice(2,8)}`,role:`assistant`,content:`**${e}**\n\n${t}`,createdAt:Date.now()})},H=e=>{z(t=>{let n=[...t,e].slice(-24);return l(e=>e&&{...e,executionLedger:n}),n})},U=(0,q.useMemo)(()=>c(y)?c(y):p.map(e=>c(e.content)).filter(Boolean).join(`

`).trim()||c(s?.workflowContext?.resumeText),[y,s,p]),W=(0,q.useMemo)(()=>{if(c(x))return c(x);let e=[...f].reverse().find(e=>e.role===`user`);return c(d)||c(e?.content)||c(s?.workflowContext?.jdText)},[f,d,x,s]),G=(0,q.useMemo)(()=>at({result:s,userInput:c(d)||c([...f].reverse().find(e=>e.role===`user`)?.content),resumeText:U,jdText:W}),[f,W,U,d,s]),K=(0,q.useMemo)(()=>{if(!G.length)return[];let e=new Map;R.forEach(t=>{let n=c(t.tool);n&&e.set(n,c(t.status))});let t=G.findIndex(t=>e.get(t.kind)!==`completed`);return t<0?[]:G.slice(t)},[R,G]);(0,q.useEffect)(()=>{if(N)return;let e=new Map;R.forEach(t=>{let n=c(t.tool);n&&e.set(n,c(t.status))}),L(G.map(t=>({id:t.id,kind:t.kind,title:t.title,reason:t.reason,status:e.get(t.kind)===`completed`?`completed`:e.get(t.kind)===`failed`?`failed`:`pending`}))),I(G.length?`职业教练已整理好多步执行建议。`:``)},[R,N,G]),(0,q.useEffect)(()=>{s&&z(Array.isArray(s?.executionLedger)&&s?.executionLedger||[])},[s]);let le=async(e,t)=>{try{let n=await oe({tool:dt(e),modelChoice:ft(e),resumeChars:c(t?.resumeText??U).length,jdChars:c(t?.jdText??W).length,inputChars:Math.max(0,Math.floor(Number(t?.extraChars||0))),chatChars:f.reduce((e,t)=>e+c(t?.content).length,0),docsChars:p.reduce((e,t)=>e+c(t?.content).length+c(t?.preview).length,0),outputChars:e===`resume_html`?9e3:e===`resume_optimize`?8e3:5e3});return n.ok?!0:(u(`${n.message} 请先充值后再开始。`),!1)}catch(e){return u(String(e?.message||`暂时无法校验积分余额，请稍后重试。`)),!1}},ue=async e=>{try{let t=e.map(e=>`${c(e.kind)} ${c(e.title)} ${c(e.reason)} ${c(e.prefillHint)}`).join(`
`),n=await oe({tool:`career_coach`,modelChoices:[ot],resumeChars:c(U).length,jdChars:c(W).length,inputChars:t.length+c(d).length+JSON.stringify(a||{}).length,chatChars:f.reduce((e,t)=>e+c(t?.content).length,0),docsChars:p.reduce((e,t)=>e+c(t?.content).length+c(t?.preview).length,0),outputChars:Math.max(5e3,e.length*4500)});return n.ok?!0:(u(`${n.message} 请先充值后再开始。`),!1)}catch(e){return u(String(e?.message||`暂时无法校验积分余额，请稍后重试。`)),!1}};return{embeddedToolKind:_,setEmbeddedToolKind:v,embeddedResumeDraft:y,setEmbeddedResumeDraft:b,embeddedJdDraft:x,setEmbeddedJdDraft:C,embeddedToolBusy:w,setEmbeddedToolBusy:D,embeddedToolProgress:k,setEmbeddedToolProgress:A,embeddedToolStatus:j,setEmbeddedToolStatus:M,workflowBusy:N,setWorkflowBusy:P,workflowStatus:F,setWorkflowStatus:I,workflowStepsState:ee,setWorkflowStepsState:L,executionLedger:R,setExecutionLedger:z,embeddedToolResult:re,setEmbeddedToolResult:B,derivedResumeText:U,derivedJdText:W,workflowPlan:G,resumableWorkflowPlan:K,pushEmbeddedToolTurn:V,appendExecutionLedgerEntry:H,runEmbeddedCoachTool:async(e,t)=>{if(n||r||w||N&&!t?.viaWorkflow)return!1;if(!i)return u(`请先确认职业教练的专业模型与扣费提示，再开始使用。`),!1;let s=await o();if(!s?.token)return window.location.href=E(),!1;let l=c(t?.prefillHint)||W,d=U,f=l;if((e===`resume_match`||e===`resume_optimize`||e===`resume_translate`||e===`resume_html`)&&!d)return u(`请先上传或粘贴你的简历内容，再让职业教练调用相关工具。`),!1;if((e===`resume_match`||e===`resume_optimize`||e===`jd_analysis`)&&!f)return u(`请先在对话里粘贴目标 JD，或在下方工作台补充 JD 内容。`),!1;if(!await le(e,{resumeText:d,jdText:f,extraChars:c(t?.prefillHint).length}))return!1;c(t?.prefillHint)&&C(c(t?.prefillHint)),v(e),D(!0),A(6),M(`正在执行${Ze[e]}…`),B(null);let p=`ledger_${e}_${Date.now()}_${Math.random().toString(16).slice(2,8)}`,h=Date.now(),g=await te({pageSize:100,rangeDays:1}),_=``,y=``,b=new AbortController;try{if(e===`resume_match`){let n=await ae([ve(f,a)],d,{provider:st,model:ut,thinking:!0,signal:b.signal,onProgress:A}),r=Array.isArray(n.items)?n.items[0]:null,i=[c(n.summary),...Array.isArray(r?.actions)?r.actions.slice(0,3):[]].filter(Boolean).join(`
`);B({kind:e,title:`简历匹配结果`,summary:`匹配度 ${Math.round(Number(n.overallScore||r?.score||0))} 分`,content:Y(i||`已生成简历匹配结果。`,1600)}),await S({id:`career_inline_${e}_${Date.now()}`,toolType:`resume_match`,title:`职业教练内嵌简历匹配`,score:Number.isFinite(Number(n.overallScore))?`${Math.round(Number(n.overallScore||0))}`:void 0,createdAt:Date.now(),deepLink:m(`resume_match`)||`/tools/career-coach`,userId:c(s.user?.id)||void 0,insightSummary:se(`resume_match`,n)},n),y=c(n?.meta?.model||n?.model),_=`匹配度 ${Math.round(Number(n.overallScore||r?.score||0))} 分`,V(t?.viaWorkflow?`工作流已完成简历匹配`:`已完成简历匹配`,i||`我已经在当前对话里完成了简历与目标 JD 的匹配分析。`)}else if(e===`resume_optimize`){let n=await ie([ve(f,a)],d,{provider:st,model:ct,thinking:!0,signal:b.signal,onProgress:A}),r=Array.isArray(n.items)?n.items[0]:null,i=c(r?.optimizedResume),o=[c(r?.fitSummary),...Array.isArray(r?.changes)?r.changes.slice(0,4):[]].filter(Boolean).join(`
`);B({kind:e,title:`简历优化结果`,summary:c(r?.fitSummary)||`已生成针对目标岗位的改写版简历`,content:Y(i||o||`已完成简历优化。`,2400)}),await S({id:`career_inline_${e}_${Date.now()}`,toolType:`resume_optimize`,title:`职业教练内嵌简历优化`,score:Number.isFinite(Number(r?.fitScore))?`${Math.round(Number(r?.fitScore||0))}`:void 0,createdAt:Date.now(),deepLink:m(`resume_optimize`)||`/tools/career-coach`,userId:c(s.user?.id)||void 0,insightSummary:se(`resume_optimize`,n)},n),y=c(n?.meta?.model||n?.model),_=c(r?.fitSummary)||`已生成改写版简历`,V(t?.viaWorkflow?`工作流已完成简历优化`:`已完成简历优化`,o||`我已经在当前对话里完成了简历优化，你可以直接继续追问。`)}else if(e===`jd_analysis`){let n=await Xe({requirementsIdea:f,roleTitle:c(a.targetRole)||void 0},{signal:b.signal}),r=[c(n.talentPersona)?`目标画像：${c(n.talentPersona)}`:``,Array.isArray(n.keywords)?`关键词：${n.keywords.slice(0,6).join(`、`)}`:``,Array.isArray(n.risks)?`风险点：${n.risks.slice(0,3).join(`；`)}`:``].filter(Boolean).join(`
`);B({kind:e,title:`JD 分析结果`,summary:`已提炼岗位关键词、目标画像与风险点`,content:Y(r||c(n.optimizedJd)||`已完成 JD 分析。`,1800)}),await S({id:`career_inline_${e}_${Date.now()}`,toolType:`jd_analysis`,title:`职业教练内嵌 JD 分析`,createdAt:Date.now(),deepLink:`/tools/career-coach`,userId:c(s.user?.id)||void 0,insightSummary:{title:`JD 分析`,headline:Y(r,72)||`已提炼岗位关键信号`,primaryAction:`根据 JD 结果继续优化简历`}},n),y=c(n?.meta?.model||n?.model),_=`已提炼岗位关键词与目标画像`,V(t?.viaWorkflow?`工作流已完成 JD 分析`:`已完成 JD 分析`,r||`我已经在当前对话里完成了 JD 分析。`)}else if(e===`resume_translate`){let n=await ce(d,{signal:b.signal,to:`en`,onProgress:A,onPartial:t=>B({kind:e,title:`英文简历译文`,summary:`正在生成英文版简历`,content:Y(c(t.en),2400)})});B({kind:e,title:`英文简历译文`,summary:n.piiFound?`已完成翻译，并自动做了隐私保护处理`:`已完成英文简历翻译`,content:Y(c(n.en),2400)}),await S({id:`career_inline_${e}_${Date.now()}`,toolType:`resume_translate`,title:`职业教练内嵌简历翻译`,createdAt:Date.now(),deepLink:`/tools/career-coach`,userId:c(s.user?.id)||void 0,insightSummary:{title:`简历翻译`,headline:n.piiFound?`已翻译并做隐私处理`:`已生成英文版简历`,primaryAction:`检查术语后再用于投递`}},n),y=c(n?.provider||n?.model),_=n.piiFound?`已生成带隐私处理的译文`:`已生成英文版简历`,V(t?.viaWorkflow?`工作流已完成简历翻译`:`已完成简历翻译`,`我已经在当前对话里生成了英文版简历，你可以继续让我润色或导出。`)}else if(e===`resume_html`){let n=await O({resumeText:d,signal:b.signal}),r=c(n?.html||``),i=new Blob([r],{type:`text/html;charset=utf-8`}),a=URL.createObjectURL(i);B({kind:e,title:`HTML 简历已生成`,summary:`可直接下载 HTML，再用浏览器打印另存为 PDF`,content:Y(r.replace(/<[^>]+>/g,` `),1600),downloadName:`career-coach-resume.html`,downloadUrl:a}),await S({id:`career_inline_${e}_${Date.now()}`,toolType:`resume_html`,title:`职业教练内嵌 HTML 简历`,createdAt:Date.now(),deepLink:`/tools/career-coach`,userId:c(s.user?.id)||void 0,insightSummary:{title:`HTML 简历`,headline:`已生成可下载 HTML 简历`,primaryAction:`下载后用浏览器打印为 PDF`}},n),y=c(n?.model||n?.provider),_=`已生成可下载的 HTML 简历`,V(t?.viaWorkflow?`工作流已完成 HTML 简历生成`:`已完成 HTML 简历生成`,`我已经在当前对话里生成了 HTML 简历，你可以直接下载并另存为 PDF。`)}A(100),M(`${Ze[e]}已完成`);let n=await ne({beforeIds:g,aggregateAllNew:!0,pageSize:100,rangeDays:1});return H({id:p,tool:e,title:Ze[e],reason:t?.viaWorkflow?`由职业教练编排方案自动触发`:`由职业教练当前对话直接触发`,status:`completed`,source:t?.viaWorkflow?`workflow`:`manual`,startedAt:h,finishedAt:Date.now(),requestCount:Number(n?.requests||0)||void 0,totalTokens:Number(n?.totalTokens||0)||void 0,estimatedPoints:Number(n?.estimatedPoints||0)||void 0,actualPoints:Number(n?.actualPoints||0)||void 0,pointsStatus:n?.pointsStatus===`actual`||n?.pointsStatus===`mixed`||n?.pointsStatus===`estimated`?n.pointsStatus:void 0,model:y||void 0,note:_||void 0}),!0}catch(n){let r=await ne({beforeIds:g,aggregateAllNew:!0,pageSize:100,rangeDays:1}).catch(()=>null);return H({id:p,tool:e,title:Ze[e],reason:t?.viaWorkflow?`由职业教练编排方案自动触发`:`由职业教练当前对话直接触发`,status:`failed`,source:t?.viaWorkflow?`workflow`:`manual`,startedAt:h,finishedAt:Date.now(),requestCount:Number(r?.requests||0)||void 0,totalTokens:Number(r?.totalTokens||0)||void 0,estimatedPoints:Number(r?.estimatedPoints||0)||void 0,actualPoints:Number(r?.actualPoints||0)||void 0,pointsStatus:r?.pointsStatus===`actual`||r?.pointsStatus===`mixed`||r?.pointsStatus===`estimated`?r.pointsStatus:void 0,model:y||void 0,note:T(n,`${Ze[e]}执行失败`)}),u(T(n,`${Ze[e]}执行失败`)),M(``),!1}finally{D(!1)}},runCareerCoachWorkflow:async t=>{let i=Array.isArray(t)&&t.length?t:G;if(!(!i.length||N||w||n||r)&&await ue(i)){u(``),P(!0),I(`职业教练正在通过后端执行器编排并执行多步方案…`),l(e=>e&&{...e,workflowContext:{resumeText:U,jdText:W}}),L(i.map(e=>({id:e.id,kind:e.kind,title:e.title,reason:e.reason,status:`pending`})));try{let t=await Ue({sessionId:c(e),profile:a,steps:i,resumeText:U,jdText:W}),n=new Map(t.steps.map(e=>[e.id,e.status===`failed`?`failed`:`completed`]));L(e=>e.map(e=>({...e,status:n.get(e.id)||e.status}))),t.steps.forEach(e=>{H({id:e.id,tool:e.tool,title:e.title||tt(e.tool),reason:e.reason,status:e.status,source:e.source||`backend_executor`,startedAt:Date.now(),finishedAt:Date.now(),requestCount:e.requestCount,totalTokens:e.totalTokens,estimatedPoints:e.estimatedPoints,model:e.model,note:e.note}),c(e.outputText)&&V(e.status===`failed`?`工作流在 ${e.title} 停止`:`后端执行器已完成${e.title}`,c(e.outputText)||c(e.note))}),t.stoppedAt?I(`已在 ${t.stoppedAt} 停止，可在补充材料后续跑未完成步骤。`):(I(`多步方案已完成，共执行 ${t.completedCount} 个动作。`),V(`多步编排执行完成`,`职业教练已通过后端执行器完成 ${t.completedCount} 个协同步骤。你可以继续追问，我会基于这些结果继续推进。`))}finally{P(!1)}}}}}var mt=(e,t=8,n=80)=>Array.from(new Set((Array.isArray(e)?e:[]).map(e=>c(e)).filter(Boolean))).slice(0,t).map(e=>e.length<=n?e:`${e.slice(0,Math.max(1,n-1)).trimEnd()}…`),ht=async e=>{let t=await V(e);if(!t.ok)throw Error(t.error||`${e.op}_failed`);return t.data},gt=async e=>{let t=await ht({op:`list_career_knowledge_items`,query:c(e?.query).slice(0,200),tags:mt(e?.tags,8,48),audienceTags:mt(e?.audienceTags,8,48),limit:Math.max(1,Math.min(12,Math.floor(Number(e?.limit||6)||6)))});return Array.isArray(t?.items)?t.items:[]},_t=`deepseek_pro`,vt=`DeepSeek V4 Pro`,yt=(e,t=4e3)=>{let n=String(e??``);return n.length<=t?n:n.slice(0,Math.max(0,t))},bt=(e,t=0)=>{if(e==null)return e;if(typeof e==`string`)return yt(e,t<=1?6e3:2e3);if(typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))return e.slice(0,t<=1?24:12).map(e=>bt(e,t+1));if(typeof e==`object`){if(t>=5)return;let n={};return Object.entries(e).slice(0,t===0?40:24).forEach(([e,r])=>{let i=bt(r,t+1);i!==void 0&&(n[e]=i)}),n}},xt=e=>({...e,providerMeta:void 0,fallbackMeta:void 0,billing:e?.billing?{...e.billing,model:``}:e?.billing}),St=e=>(Array.isArray(e)?e:[]).map(e=>xt(e)),Ct=e=>(Array.isArray(e)?e:[]).slice(-40).map(e=>({...xt(e),content:yt(e?.content,5e3),reasoningContent:yt(e?.reasoningContent,1200),rawParts:void 0,toolCalls:Array.isArray(e?.toolCalls)?e.toolCalls.slice(0,4).map(e=>bt(e,1)):void 0})),wt=e=>(Array.isArray(e)?e:[]).slice(-8).map(e=>({...e,content:yt(e?.content,4e3),preview:yt(e?.preview||e?.content,1200)})),Tt=e=>e&&typeof e==`object`?bt(e,0):null,Et={currentRole:``,yearsExperience:``,targetRole:``,targetIndustry:``,location:``,workMode:``,compensationGoal:``,urgency:``,riskTolerance:``,summary:``,goals:[],constraints:[]},Dt={resume_match:`/tools/resume-match`,resume_optimize:`/tools/resume-optimize`,interview_coach:`/tools/interview-coach`,salary_negotiation:`/tools/salary-negotiation`};function Ot(){let e=r(),t=i(),[n,s]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(``),[p,h]=(0,q.useState)(``),[g,_]=(0,q.useState)(0),[v,y]=(0,q.useState)(``),{start:b,setProgress:S,done:E,failByMessage:O}=le(),[k,A]=(0,q.useState)(``),[j,M]=(0,q.useState)(null),[N,P]=(0,q.useState)([]),[F,I]=(0,q.useState)([]),[ee,L]=(0,q.useState)([]),[R,te]=(0,q.useState)(``),[ne,z]=(0,q.useState)(``),[re,ie]=(0,q.useState)(``),[ae,oe]=(0,q.useState)(``),se=(0,q.useRef)(``),V=(0,q.useRef)(null),ce=(0,q.useRef)(``),H=(0,q.useRef)(null),W=(0,q.useRef)(null),G=(0,q.useRef)(null),K=(0,q.useRef)(0),de=(0,q.useRef)([]),fe=(0,q.useRef)(null),[ge,J]=(0,q.useState)(``),[ve,Y]=(0,q.useState)(()=>!!a()?.token),[xe,Se]=(0,q.useState)(()=>!!a()?.token),[Ce,Te]=(0,q.useState)(``),[Ee,Oe]=(0,q.useState)(`deep`),[Z,ke]=(0,q.useState)(Et),[Ae,je]=(0,q.useState)(``),[Me,Ne]=(0,q.useState)(_t),[Pe,Fe]=(0,q.useState)(!0),[Ie,Le]=(0,q.useState)(!0),Re=(0,q.useRef)(c(a()?.user?.id)),ze=(0,q.useMemo)(()=>new URLSearchParams(t.search).get(`sid`)||``,[t.search]),Be=(0,q.useCallback)(async()=>({modelChoice:_t,modelLabel:vt,thinkingEnabled:!0}),[]),Q=e=>{P(t=>[...t,e].slice(-80))},He=(e,t)=>{c(e)&&P(n=>n.map(n=>n.id===e?{...n,...t}:n).slice(-80))},Ue=He,We=ye,Ge=()=>{de.current.forEach(e=>window.clearTimeout(e)),de.current=[]},Ke=(e,t)=>{Ge(),h(c(e)),_(1);let n=Array.isArray(t.actionPlan)&&t.actionPlan.length>0,r=Array.isArray(t.roadmap)&&t.roadmap.length>0,i=Array.isArray(t.followUpQuestions)&&t.followUpQuestions.length>0,a=Ee===`quick`?260:Ee===`deep`?620:420,o=Ee===`quick`?560:Ee===`deep`?1180:860;(n||r||i)&&de.current.push(window.setTimeout(()=>_(2),a)),(r||i)&&de.current.push(window.setTimeout(()=>_(3),o))},qe=(0,q.useRef)({setExecutionLedger:null,setWorkflowStatus:null,setWorkflowStepsState:null}),Je=(0,q.useCallback)(()=>{Ge();try{G.current?.abort()}catch{}y(``),M(null),h(``),_(0),P([]),s(!1),u(!1),f(``),I([]),L([]),qe.current.setExecutionLedger?.([]),qe.current.setWorkflowStatus?.(``),qe.current.setWorkflowStepsState?.([]),A(``),Te(``),J(``),ke(Et),U({setStreamText:te,setStreamThinking:z,setStreamStage:ie,setStreamActor:oe,streamTextRawRef:se,streamThinkingRawRef:ce,streamTextFlushTimerRef:V,streamThinkingFlushTimerRef:H}),he()},[]);(0,q.useEffect)(()=>{if(ze)return;let e=me();if(!e||typeof e!=`object`)return;Array.isArray(e.chatTurns)&&P(St(e.chatTurns).slice(-80)),e.result&&typeof e.result==`object`&&M(e.result),Array.isArray(e.uploadedDocs)&&I(e.uploadedDocs.slice(-12)),e.profile&&typeof e.profile==`object`&&ke(t=>({...t,...e.profile})),c(e.pinnedContext)&&je(c(e.pinnedContext)),c(e.sessionId)&&Te(c(e.sessionId)),Oe(`deep`);let t=c(e.runState);t===`failed`?O(String(e.err||`生成失败`),y):t===`cancelled`&&O(`已取消`,y)},[]),(0,q.useEffect)(()=>(W.current&&window.clearTimeout(W.current),W.current=window.setTimeout(()=>{pe(`career_coach`,{sessionId:Ce,profile:bt(Z,0),chatTurns:Ct(N),uploadedDocs:wt(F),analysisDepth:Ee,result:Tt(j),pinnedContext:Ae}),W.current=null},240),()=>{W.current&&=(window.clearTimeout(W.current),null)}),[Ee,N,Ae,Z,j,Ce,F]),(0,q.useEffect)(()=>{let e=fe.current;if(e)try{e.scrollTop=e.scrollHeight}catch{}},[n,N.length,ge,R,ne]),(0,q.useEffect)(()=>()=>Ge(),[]),(0,q.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await o();if(!e)return;let n=c(t?.user?.id);Re.current&&n&&Re.current!==n?(Re.current=n,Je()):!Re.current&&n?Re.current=n:Re.current&&!n&&(Re.current=``),Y(!!t?.token),Se(!0)}catch{if(!e)return;Se(!0)}};t();let n=()=>{t()};return window.addEventListener(`AUTH_SESSION_UPDATED_WEB`,n),()=>{e=!1,window.removeEventListener(`AUTH_SESSION_UPDATED_WEB`,n)}},[Je]),(0,q.useEffect)(()=>{let e=c(ze);if(!e)return;let t=me();!t||c(t.sessionId)!==e||(Te(e),t.result&&typeof t.result==`object`&&M(t.result),t.profile&&typeof t.profile==`object`&&ke(e=>({...e,...t.profile})),Array.isArray(t.chatTurns)&&P(St(t.chatTurns).slice(-80)),Array.isArray(t.uploadedDocs)&&I(t.uploadedDocs.map(e=>({name:c(e?.name),content:c(e?.content||e?.preview),preview:c(e?.preview||e?.content)}))),Oe(`deep`),y(``))},[ze]);let Ye=(0,q.useMemo)(()=>c([...N].reverse().find(e=>e.role===`assistant`)?.id),[N]);(0,q.useEffect)(()=>{if(!l){if(!j||!Ye){h(``),_(0);return}p!==Ye&&(Ge(),h(Ye),_(3))}},[l,p,Ye,j]);let Xe=(0,q.useMemo)(()=>{let e=N.filter(e=>e.role===`user`||e.role===`assistant`).slice(0,-12);if(!e.length)return``;let t=e.filter(e=>e.role===`user`).slice(-4).map(e=>`用户：${c(e.content).replace(/\s+/g,` `).slice(0,90)}`).filter(Boolean),n=e.filter(e=>e.role===`assistant`).slice(-3).map(e=>`教练：${c(e.content).replace(/\s+/g,` `).slice(0,90)}`).filter(Boolean),r=[...t,...n].slice(-6);return r.length?r.join(`
`):``},[N]),Ze=e=>{let t=Dt[e];return t?C(t,`tool`,{source:`career_coach`,sid:c(Ce)}):``},Qe=(e,t)=>{let n=Ze(e),r=c(Ce);r&&x({sid:r,source:`career_coach`,tool:e,createdAt:Date.now(),resumeText:yt(Mt,12e3),jdText:yt(Nt,12e3),currentRole:c(Z.currentRole),targetRole:c(Z.targetRole),targetIndustry:c(Z.targetIndustry),summary:c(Z.summary)||Xe,primaryAction:c(j?.primaryAction),nextQuestion:c(j?.nextQuestion),prefillHint:c(t)}),n&&(window.location.href=n)},{embeddedToolKind:$e,setEmbeddedToolKind:et,embeddedResumeDraft:tt,setEmbeddedResumeDraft:nt,embeddedJdDraft:rt,setEmbeddedJdDraft:it,embeddedToolBusy:at,setEmbeddedToolBusy:ot,embeddedToolProgress:st,setEmbeddedToolProgress:ct,embeddedToolStatus:lt,setEmbeddedToolStatus:ut,workflowBusy:dt,setWorkflowBusy:ft,workflowStatus:mt,setWorkflowStatus:ht,workflowStepsState:xt,setWorkflowStepsState:Ot,executionLedger:$,setExecutionLedger:kt,embeddedToolResult:At,setEmbeddedToolResult:jt,derivedResumeText:Mt,derivedJdText:Nt,workflowPlan:Pt,resumableWorkflowPlan:Ft,pushEmbeddedToolTurn:It,appendExecutionLedgerEntry:Lt,runEmbeddedCoachTool:Rt,runCareerCoachWorkflow:zt}=pt({sessionId:Ce,isAuthed:ve,busy:n,detailBusy:l,coachConsentAccepted:Ie,profile:Z,result:j,setResult:M,setErr:y,dialogInput:k,chatTurns:N,uploadedDocs:F,buildActionHref:Ze,jumpToRecommendedTool:Qe,appendChatTurn:Q});qe.current={setExecutionLedger:kt,setWorkflowStatus:ht,setWorkflowStepsState:Ot};let Bt=async()=>{try{localStorage.setItem(_e,`1`)}catch{}Le(!0),Fe(!0)},Vt=async e=>{},Ht=async e=>{let t=c(e.sid||Ce);if(!t)return;let n=e.nextResult===void 0?j:e.nextResult,r=St(Array.isArray(e.chatTurnsOverride)?e.chatTurnsOverride:N),i=Array.isArray(e.uploadedDocsOverride)?e.uploadedDocsOverride:F;pe(`career_coach`,{sessionId:t,runState:e.status===`running`?`running`:e.status===`failed`?`failed`:`done`,err:c(e.error)||void 0,profile:bt(Z,0),result:Tt(n||null),chatTurns:Ct(r),uploadedDocs:wt(i),analysisDepth:Ee})},Ut=(0,q.useRef)(Ht);Ut.current=Ht,(0,q.useEffect)(()=>{if(!Ce||!j||!$.length||n||l||at||dt)return;let e=window.setTimeout(()=>{Ut.current({status:`done`,nextResult:{...j,executionLedger:$},runtimeState:{modelChoice:Me,thinkingEnabled:Pe}})},420);return()=>window.clearTimeout(e)},[n,l,at,$,Me,j,Ce,Pe,dt]);let Wt=async e=>{let t=Array.isArray(e)?e.slice(0,4):[];if(!t.length)return;if(!(await o())?.token)throw Error(`请先登录后上传文件`);if(!await m())throw Error(`未同意隐私条款，已取消文件解析`);let n=[],r=[];try{for(let e of t){let t=c(e?.name)||`附件`,i=t.toLowerCase(),a=``;if(J(`解析 ${t}…`),a=c(await B(e,{minLength:120,onStage:e=>J(`${t} · ${c(e)||`解析中`}`)}).catch(()=>i.endsWith(`.txt`)||i.endsWith(`.md`)||i.endsWith(`.markdown`)||i.endsWith(`.json`)||i.endsWith(`.csv`)?e.text().catch(()=>``):``)),!a)throw Error(`${t} 解析失败，请重试`);let o=we(a);n.push({name:t,content:a,preview:o}),r.push({name:t,preview:o})}}finally{J(``)}I(e=>[...e,...n].slice(-12)),L(e=>[...e,...r].slice(-12))},Gt=e=>{L(t=>t.filter((t,n)=>n!==e)),I(t=>t.filter((t,n)=>n!==e))},Kt=e=>ue(c(e),`center`),qt=async()=>{Je();try{e(`/tools/career-coach`,{replace:!0})}catch{}},{submit:Jt,generateDetailedPlan:Yt}=Ve({sessionId:Ce,busy:n,detailBusy:l,coachConsentAccepted:Ie,profile:Z,result:j,setResult:M,setErr:y,dialogInput:k,setDialogInput:A,chatTurns:N,uploadedDocs:F,setStreamText:te,writeToolConversationRun:pe,start:b,setProgress:S,appendChatTurn:Q,updateChatTurn:Ue,abortRef:G,clearDetailCardTimers:Ge,setDetailBusy:u,setDetailStatus:f,setDetailCardTurnId:h,setDetailCardStage:_,setBusy:s,makeId:We,setSessionId:Te,navigate:e,runSeqRef:K,pendingAttachments:ee,setPendingAttachments:L,resetBufferedConversationState:U,setStreamThinking:z,setStreamStage:ie,setStreamActor:oe,streamTextRawRef:se,streamThinkingRawRef:ce,streamTextFlushTimerRef:V,streamThinkingFlushTimerRef:H,setModelChoiceState:Ne,syncProfileToCloud:Vt,syncSessionToCloud:Ht,listLocalToolResultSummaries:w,listCareerCoachKnowledgeItems:gt,analysisDepth:Ee,withTimeout:D,done:E,failByMessage:O,executionLedger:$,derivedResumeText:Mt,derivedJdText:Nt,pinnedContext:Ae,autoProgressSummary:Xe,beginDetailCardReveal:Ke,normalizeToolError:T,sanitizeTurnRawParts:X,sanitizeTurnToolCalls:be,buildPlainStreamPreview:De});return{navigate:e,location:t,busy:n,setBusy:s,detailBusy:l,setDetailBusy:u,detailStatus:d,setDetailStatus:f,detailCardTurnId:p,setDetailCardTurnId:h,detailCardStage:g,setDetailCardStage:_,err:v,setErr:y,dialogInput:k,setDialogInput:A,result:j,setResult:M,chatTurns:N,setChatTurns:P,uploadedDocs:F,setUploadedDocs:I,pendingAttachments:ee,setPendingAttachments:L,streamText:R,setStreamText:te,streamThinking:ne,setStreamThinking:z,_streamStage:re,setStreamStage:ie,_streamActor:ae,setStreamActor:oe,streamTextRawRef:se,streamTextFlushTimerRef:V,streamThinkingRawRef:ce,streamThinkingFlushTimerRef:H,abortRef:G,runSeqRef:K,detailCardTimersRef:de,chatScrollRef:fe,parseStage:ge,setParseStage:J,isAuthed:ve,setIsAuthed:Y,sessionId:Ce,setSessionId:Te,analysisDepth:Ee,setAnalysisDepth:Oe,profile:Z,setProfile:ke,pinnedContext:Ae,setPinnedContext:je,autoProgressSummary:Xe,modelChoice:Me,thinkingEnabledState:Pe,setThinkingEnabledState:Fe,coachConsentAccepted:Ie,authResolved:xe,setCoachConsentAccepted:Le,embeddedToolKind:$e,setEmbeddedToolKind:et,embeddedResumeDraft:tt,setEmbeddedResumeDraft:nt,embeddedJdDraft:rt,setEmbeddedJdDraft:it,embeddedToolBusy:at,setEmbeddedToolBusy:ot,embeddedToolProgress:st,setEmbeddedToolProgress:ct,embeddedToolStatus:lt,setEmbeddedToolStatus:ut,workflowBusy:dt,setWorkflowBusy:ft,workflowStatus:mt,setWorkflowStatus:ht,workflowStepsState:xt,setWorkflowStepsState:Ot,executionLedger:$,setExecutionLedger:kt,embeddedToolResult:At,setEmbeddedToolResult:jt,authUserIdRef:Re,latestSessionQuery:ze,readLatestCloudRuntimeState:Be,appendChatTurn:Q,patchChatTurn:He,clearDetailCardTimers:Ge,beginDetailCardReveal:Ke,resetConversationStateForUserIsolation:Je,latestAssistantTurnId:Ye,showReplyPreview:!1,buildActionHref:Ze,derivedResumeText:Mt,derivedJdText:Nt,workflowPlan:Pt,resumableWorkflowPlan:Ft,persistCoachConsent:Bt,pushEmbeddedToolTurn:It,appendExecutionLedgerEntry:Lt,runEmbeddedCoachTool:Rt,runCareerCoachWorkflow:zt,jumpToRecommendedTool:Qe,syncProfileToCloud:Vt,syncSessionToCloud:Ht,ingestFilesToChat:Wt,removePendingAttachment:Gt,jumpToTurn:Kt,resetAll:qt,submit:Jt,generateDetailedPlan:Yt}}var $=n(),kt=`
@keyframes careerCoachStageFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes careerCoachStagePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.18);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}
.career-coach-stage-card {
  animation: careerCoachStageFadeIn 320ms ease both;
}
.career-coach-stage-card.active {
  animation: careerCoachStageFadeIn 320ms ease both, careerCoachStagePulse 1.4s ease-out 1;
}
`;function At({assistantTurnId:e,detailCardTurnId:t,detailCardStage:n,result:r,onAnswerQuestion:i,onOpenReport:a,onRunTool:o}){let s=(0,q.useRef)(null),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(`overview`),p=Array.isArray(r.actionPlan)?r.actionPlan.slice(0,3):[],m=Array.isArray(r.followUpQuestions)?r.followUpQuestions.slice(0,4):[],_=Array.isArray(r.roadmap)?r.roadmap.slice(0,3):[],v=Array.isArray(r.toolRecommendations)?r.toolRecommendations.slice(0,2):[],y=r.diagnosis,b=p.length>0,x=m.length>0,S=!!(y&&c(y.currentState)),C=_.length>0,w=t===e,T=w?n:3,E=S&&T>=1,D=b&&T>=2,O=C&&T>=(b?3:2),k=x&&T>=3,A=[{key:`diag`,label:`诊断摘要`,visible:S,reached:T>=1},{key:`plan`,label:`行动计划`,visible:b,reached:T>=2},{key:`roadmap`,label:`路线图`,visible:C||x,reached:T>=(b?3:2)}].filter(e=>e.visible),j=T<2&&b?`plan`:T<(b?3:2)&&(C||x)?`roadmap`:``,M=T<2&&b?`正在补充行动计划…`:T<(b?3:2)&&C?`正在补充阶段路线图…`:T<3&&x?`正在补充关键追问…`:``;if(!b&&!x&&!S&&!C&&!c(r.summary))return null;let N=async()=>{if(!(!s.current||l)){u(!0);try{await h({element:s.current,fileName:`career-coach-summary.png`,backgroundColor:`#F7F5F2`,pixelRatio:2})}finally{u(!1)}}};return(0,$.jsxs)(`div`,{style:{marginTop:22,display:`flex`,flexDirection:`column`,gap:14},children:[(0,$.jsx)(`style`,{children:kt}),(0,$.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},"data-export-ignore":`1`,children:[a?(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{padding:`0 12px`,height:30,fontSize:12},onClick:a,children:`查看完整报告`}):null,(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{padding:`0 12px`,height:30,fontSize:12},onClick:()=>void N(),disabled:l,children:(0,$.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,$.jsx)(g,{size:14}),l?`导出中`:`导出摘要`]})})]}),(0,$.jsxs)(`div`,{ref:s,style:{display:`grid`,gap:14,padding:16,borderRadius:18,border:`1px solid color-mix(in srgb, var(--accent) 18%, var(--border))`,background:`linear-gradient(180deg, color-mix(in srgb, var(--surface) 98%, transparent) 0%, color-mix(in srgb, var(--accent) 6%, var(--surface)) 100%)`},children:[(0,$.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`},children:[(0,$.jsxs)(`div`,{style:{maxWidth:620},children:[(0,$.jsx)(`div`,{style:{fontSize:11,fontWeight:700,letterSpacing:`0.18em`,textTransform:`uppercase`,color:`var(--accent)`},children:`职业教练摘要`}),(0,$.jsx)(`div`,{style:{marginTop:8,fontSize:24,fontWeight:800,lineHeight:1.32,color:`var(--text-1)`},children:c(r.directionVerdict)||c(r.title)||`你的下一步方向已经整理好了`}),(0,$.jsx)(`div`,{style:{marginTop:8,fontSize:13,lineHeight:1.75,color:`var(--text-2)`},children:c(r.summary)||c(r.primaryAction)||`你可以直接按下面的行动计划推进，也可以先回答关键追问让我继续细化。`})]}),(0,$.jsxs)(`div`,{style:{minWidth:176,borderRadius:18,border:`1px solid color-mix(in srgb, var(--accent) 16%, var(--border))`,background:`var(--surface)`,padding:`14px 16px`},children:[(0,$.jsx)(`div`,{style:{fontSize:12,color:`var(--text-3)`},children:`信心分`}),(0,$.jsx)(`div`,{style:{marginTop:8,fontSize:34,fontWeight:800,color:`var(--accent)`},children:Number.isFinite(Number(r.confidenceScore))?Number(r.confidenceScore):`--`}),(0,$.jsx)(`div`,{style:{fontSize:12,color:`var(--text-3)`},children:c(r.stage)||`职业判断`}),(0,$.jsx)(`div`,{style:{marginTop:6,fontSize:11,color:`var(--text-3)`,lineHeight:1.6},children:`基于你提供的信息完整度、目标明确度与上下文一致性估计。补充简历 / JD / Offer 可提升准确度。`})]})]}),(0,$.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[c(r.primaryAction)?(0,$.jsxs)(`span`,{style:{padding:`5px 12px`,borderRadius:999,border:`1px solid color-mix(in srgb, var(--accent) 18%, var(--border))`,background:`var(--surface)`,fontSize:11,fontWeight:600,color:`var(--accent)`},children:[`当前主动作：`,c(r.primaryAction)]}):null,c(r.nextQuestion)?(0,$.jsxs)(`span`,{style:{padding:`5px 12px`,borderRadius:999,border:`1px solid var(--border)`,background:`var(--surface)`,fontSize:11,fontWeight:600,color:`var(--text-2)`},children:[`下一问：`,c(r.nextQuestion)]}):null,v.map((e,t)=>(0,$.jsx)(`span`,{style:{padding:`5px 12px`,borderRadius:999,border:`1px solid var(--border)`,background:`var(--surface)`,fontSize:11,fontWeight:600,color:`var(--text-2)`},children:c(e.reason)||c(e.tool)},`${t}_${e.tool}`))]}),v.length||m.length?(0,$.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:16,padding:14,background:`var(--surface)`},"data-export-ignore":`1`,children:[(0,$.jsx)(`div`,{style:{fontSize:12,fontWeight:700,letterSpacing:`0.14em`,textTransform:`uppercase`,color:`var(--text-3)`},children:`下一步承接`}),(0,$.jsxs)(`div`,{style:{marginTop:10,display:`flex`,gap:10,flexWrap:`wrap`},children:[v.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,className:`ui-btn-primary`,onClick:()=>o?.(c(e.tool),c(e.prefillHint)),children:c(e.reason)||`继续执行 ${c(e.tool)}`},`${t}_${e.tool}`)),m[0]?(0,$.jsx)(`button`,{type:`button`,className:`ui-btn-outline`,onClick:()=>i(m[0]),children:`回答关键追问 →`}):null]})]}):null,(0,$.jsx)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},"data-export-ignore":`1`,children:[{key:`overview`,label:`概览`},{key:`diagnosis`,label:`诊断`},{key:`plan`,label:`行动计划`},{key:`roadmap`,label:`路线图`},{key:`tools`,label:`推荐工具`}].map(e=>(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{minHeight:30,padding:`0 12px`,borderColor:d===e.key?`var(--accent)`:void 0,color:d===e.key?`var(--accent)`:void 0},onClick:()=>f(e.key),children:e.label},e.key))}),A.length?(0,$.jsxs)(`div`,{className:j?`career-coach-stage-card active`:`career-coach-stage-card`,style:{display:`grid`,gap:10,padding:`12px 14px`,borderRadius:14,border:`1px solid var(--border)`,background:`color-mix(in srgb, var(--surface) 94%, transparent)`},children:[(0,$.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,flexWrap:`wrap`},children:A.map((e,t)=>{let n=e.reached&&j!==e.key,r=j===e.key;return(0,$.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,$.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:8},children:[(0,$.jsx)(`span`,{style:{width:22,height:22,borderRadius:999,display:`grid`,placeItems:`center`,fontSize:11,fontWeight:700,color:n||r?`#fff`:`var(--text-2)`,background:n?`var(--accent)`:r?`color-mix(in srgb, var(--accent) 86%, #fff)`:`var(--surface)`,border:n||r?`none`:`1px solid var(--border)`,transition:`all 220ms ease`,transform:r?`scale(1.06)`:`scale(1)`,boxShadow:r?`0 0 0 6px rgba(245,158,11,0.10)`:`none`},children:n?`完`:t+1}),(0,$.jsx)(`span`,{style:{fontSize:13,fontWeight:n||r?700:500,color:n||r?`var(--text-1)`:`var(--text-2)`,transition:`all 220ms ease`,transform:r?`translateY(-1px)`:`none`},children:e.label})]}),t<A.length-1?(0,$.jsx)(`span`,{style:{width:26,height:1,background:n?`color-mix(in srgb, var(--accent) 65%, var(--border))`:r?`color-mix(in srgb, var(--accent) 40%, var(--border))`:`var(--border)`,transition:`background 220ms ease`}}):null]},e.key)})}),(0,$.jsx)(`div`,{style:{fontSize:12,color:`var(--text-3)`},children:M||`详细内容已全部就绪`})]}):null,M?(0,$.jsx)(`div`,{className:`career-coach-stage-card active`,style:{padding:`10px 14px`,borderRadius:12,border:`1px solid var(--border)`,background:`color-mix(in srgb, var(--surface) 92%, transparent)`,color:`var(--text-2)`,fontSize:13},children:M}):null,E&&(d===`overview`||d===`diagnosis`)?(0,$.jsxs)(`div`,{className:`career-coach-stage-card${w&&T===1?` active`:``}`,style:{padding:16,background:`var(--bg2)`,borderRadius:12,border:`1px solid var(--border)`,boxShadow:w&&T===1?`0 14px 30px rgba(245,158,11,0.10)`:`0 8px 20px rgba(15,23,42,0.04)`,transition:`box-shadow 240ms ease, border-color 240ms ease`,borderColor:w&&T===1?`color-mix(in srgb, var(--accent) 42%, var(--border))`:`var(--border)`},children:[(0,$.jsx)(`div`,{style:{fontSize:14,fontWeight:700,color:`var(--text-1)`,marginBottom:12},children:`当前诊断与定位`}),(0,$.jsxs)(`div`,{style:{display:`grid`,gap:8,fontSize:13},children:[(0,$.jsxs)(`div`,{style:{display:`flex`,gap:12},children:[(0,$.jsx)(`span`,{style:{color:`var(--text-3)`,width:64,flexShrink:0},children:`当前阶段`}),(0,$.jsx)(`span`,{style:{color:`var(--text-1)`},children:c(y?.stage)})]}),(0,$.jsxs)(`div`,{style:{display:`flex`,gap:12},children:[(0,$.jsx)(`span`,{style:{color:`var(--text-3)`,width:64,flexShrink:0},children:`核心痛点`}),(0,$.jsx)(`span`,{style:{color:`var(--text-1)`},children:c(y?.painPoint)})]}),(0,$.jsxs)(`div`,{style:{display:`flex`,gap:12},children:[(0,$.jsx)(`span`,{style:{color:`var(--text-3)`,width:64,flexShrink:0},children:`现状评估`}),(0,$.jsx)(`span`,{style:{color:`var(--text-1)`,lineHeight:1.6},children:c(y?.currentState)})]})]})]}):null,D&&(d===`overview`||d===`plan`)?(0,$.jsxs)(`div`,{className:`career-coach-stage-card${w&&j===`plan`?` active`:``}`,style:{padding:16,background:`var(--bg2)`,borderRadius:12,border:`1px solid var(--border)`,boxShadow:w&&j===`plan`?`0 14px 30px rgba(245,158,11,0.10)`:`0 8px 20px rgba(15,23,42,0.04)`,transition:`box-shadow 240ms ease, border-color 240ms ease`,borderColor:w&&j===`plan`?`color-mix(in srgb, var(--accent) 42%, var(--border))`:`var(--border)`},children:[(0,$.jsx)(`div`,{style:{fontSize:14,fontWeight:700,color:`var(--text-1)`,marginBottom:16},children:`你的专属行动计划`}),(0,$.jsx)(`div`,{style:{display:`grid`,gap:16},children:p.map((e,t)=>(0,$.jsxs)(`div`,{style:{display:`flex`,gap:12,alignItems:`flex-start`},children:[(0,$.jsx)(`div`,{style:{width:24,height:24,borderRadius:`50%`,background:`var(--surface)`,border:`1px solid var(--border)`,display:`grid`,placeItems:`center`,fontSize:12,fontWeight:600,color:`var(--text-2)`,flexShrink:0,marginTop:2},children:t+1}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{style:{fontSize:14,fontWeight:600,color:`var(--text-1)`},children:c(e.title)||c(e.phase)}),(0,$.jsx)(`div`,{style:{fontSize:13,color:`var(--text-2)`,marginTop:4,lineHeight:1.6},children:c(e.why)})]})]},`${t}_${e.title||e.phase}`))})]}):null,O&&(d===`overview`||d===`roadmap`)?(0,$.jsxs)(`div`,{className:`career-coach-stage-card${w&&j===`roadmap`?` active`:``}`,style:{padding:16,background:`var(--bg2)`,borderRadius:12,border:`1px solid var(--border)`,boxShadow:w&&j===`roadmap`?`0 14px 30px rgba(245,158,11,0.10)`:`0 8px 20px rgba(15,23,42,0.04)`,transition:`box-shadow 240ms ease, border-color 240ms ease`,borderColor:w&&j===`roadmap`?`color-mix(in srgb, var(--accent) 42%, var(--border))`:`var(--border)`},children:[(0,$.jsx)(`div`,{style:{fontSize:14,fontWeight:700,color:`var(--text-1)`,marginBottom:16},children:`阶段路线图`}),(0,$.jsx)(`div`,{style:{display:`grid`,gap:16},children:_.map((e,t)=>(0,$.jsxs)(`div`,{style:{display:`flex`,gap:12,alignItems:`flex-start`},children:[(0,$.jsx)(`div`,{style:{width:6,height:6,borderRadius:`50%`,background:`var(--accent)`,marginTop:8,flexShrink:0}}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-1)`},children:[c(e.timeframe),` · `,c(e.focus)]}),(0,$.jsx)(`div`,{style:{fontSize:13,color:`var(--text-2)`,marginTop:6,display:`grid`,gap:6},children:(Array.isArray(e.actions)?e.actions:[]).slice(0,3).map((e,t)=>(0,$.jsxs)(`div`,{style:{lineHeight:1.5},children:[`- `,c(e)]},`${t}_${e}`))})]})]},`${t}_${e.timeframe||e.focus}`))})]}):null,(k||v.length)&&d===`tools`?(0,$.jsxs)(`div`,{className:`career-coach-stage-card`,style:{padding:16,background:`var(--bg2)`,borderRadius:12,border:`1px solid var(--border)`,boxShadow:`0 8px 20px rgba(15,23,42,0.04)`},"data-export-ignore":`1`,children:[v.length?(0,$.jsxs)(`div`,{style:{display:`grid`,gap:10,marginBottom:m.length?14:0},children:[(0,$.jsx)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-2)`},children:`推荐你继续使用这些工具：`}),v.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{textAlign:`left`,whiteSpace:`normal`,lineHeight:1.6,padding:`12px 16px`,justifyContent:`flex-start`},onClick:()=>o?.(c(e.tool),c(e.prefillHint)),children:c(e.reason)||`去使用 ${c(e.tool)}`},`${t}_${e.tool}`))]}):null,k?(0,$.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,$.jsx)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-2)`},children:`如果你愿意，可以直接回答这些关键问题：`}),m.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{textAlign:`left`,whiteSpace:`normal`,lineHeight:1.6,padding:`12px 16px`,justifyContent:`flex-start`,border:`1px solid var(--border)`,background:`var(--surface)`},onClick:()=>i(e),children:`回答：${e}`},`${t}_${e}`))]}):null]}):null,k&&d===`overview`?(0,$.jsxs)(`div`,{className:`career-coach-stage-card`,style:{padding:16,background:`var(--bg2)`,borderRadius:12,border:`1px solid var(--border)`,boxShadow:`0 8px 20px rgba(15,23,42,0.04)`},"data-export-ignore":`1`,children:[(0,$.jsx)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-2)`,marginBottom:12},children:`如果你愿意，可以直接回答这些关键问题：`}),(0,$.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:m.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{textAlign:`left`,whiteSpace:`normal`,lineHeight:1.6,padding:`12px 16px`,justifyContent:`flex-start`,border:`1px solid var(--border)`,background:`var(--surface)`},onClick:()=>i(e),children:`回答：${e}`},`${t}_${e}`))})]}):null]})]})}function jt({sticky:e=!0,busy:t,detailBusy:n,detailStatus:r,parseStage:i,needsUserInput:a,pendingAttachments:o,removePendingAttachment:s,dialogInput:l,setDialogInput:u,submit:d,ingestFilesToChat:f,isAuthed:p,chatTurns:m,result:h,sessionId:g,latestAssistantTurnId:_,jumpToTurn:v,runSeqRef:b,abortRef:x,setBusy:S,setDetailBusy:C,setDetailStatus:w,err:T,setErr:E}){return(0,$.jsx)(`div`,{style:{position:e?`sticky`:`relative`,bottom:e?0:void 0,padding:e?`20px 0 30px 0`:`12px 0 8px 0`,background:e?`linear-gradient(180deg, rgba(10,13,18,0) 0%, color-mix(in srgb, var(--bg) 88%, transparent) 18%, var(--bg) 48%)`:`transparent`,backdropFilter:e?`blur(10px)`:void 0,zIndex:10},children:(0,$.jsx)(`div`,{style:{maxWidth:860,margin:`0 auto`},children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(y,{busy:t,inputDisabled:!!i,fileDisabled:!!i||t||n,actionDisabled:t,pendingAttachments:o,onRemoveAttachment:s,value:l,onChange:u,onSubmit:()=>{d()},onFilesPicked:async e=>{try{await f(e)}catch(e){E(c(e?.message||`文件解析失败`))}},placeholder:m.length?``:`直接告诉我：你要面什么岗位，你目前的背景，JD重点，你担心的问题；也可以直接粘贴简历或岗位描述。`,helperText:``,parseStage:i,submitDisabled:!p,submitLabel:`发送`,simpleStyle:!0,minTextareaHeight:120,maxTextareaHeight:260,rightActions:(0,$.jsx)($.Fragment,{children:h&&c(g)?(0,$.jsx)(`a`,{href:`/report/career-coach?sid=${encodeURIComponent(c(g))}`,className:`btn-secondary`,style:{padding:`0 10px`,height:28,fontSize:12,lineHeight:`26px`,borderRadius:14,marginRight:8,background:`transparent`,border:`none`,color:`var(--text-2)`,textDecoration:`none`},children:`查看报告`}):null})}),a?(0,$.jsx)(`div`,{style:{marginTop:10,padding:`10px 12px`,borderRadius:14,border:`1px solid rgba(239,68,68,0.24)`,background:`rgba(239,68,68,0.07)`,fontSize:12,color:`var(--text-2)`},children:`我还差一点信息。你在这里补一句背景、目标或岗位细节，我就能接着往下推进。`}):null,n?(0,$.jsx)(`div`,{style:{marginTop:12,padding:`12px 14px`,borderRadius:16,border:`1px solid color-mix(in srgb, var(--border) 88%, transparent)`,background:`color-mix(in srgb, var(--surface) 85%, transparent)`,fontSize:13,color:`var(--text-2)`},children:r||`正在生成详细规划。你现在可以继续聊天，或等待完整规划生成完成。`}):null,(0,$.jsxs)(`div`,{className:`he-actions`,style:{marginTop:14,alignItems:`center`},children:[_?(0,$.jsx)(`button`,{type:`button`,className:`btn-secondary`,style:{padding:`0 12px`,height:28,fontSize:12},onClick:()=>v(_),children:`定位到最新回答`}):null,(0,$.jsx)(`div`,{style:{flex:1}}),t||n?(0,$.jsx)(`button`,{type:`button`,className:`btn-primary`,style:{padding:`0 14px`,height:34,fontSize:13},onClick:()=>W({tool:`career_coach`,runSeqRef:b,abortRef:x,setBusy:S,onCancelled:()=>{C(!1),w(``),E(n?`已停止继续整理详细建议，你可以继续输入下一条消息。`:`已取消`)}}),children:n?`停止补全`:`停止生成`}):null]}),T?(0,$.jsx)(`div`,{className:`he-card`,style:{marginTop:12,color:`var(--danger)`,padding:`10px 16px`,fontSize:13},children:T}):null]})})})}var Mt=[`我想从运营转产品，不知道差距在哪，请先帮我判断优势和短板。`,`我拿到两个 Offer，不确定怎么选，请先问清楚岗位和薪资再帮我判断。`,`我在当前公司停滞了 2 年，想重新规划，请帮我判断问题出在哪里。`,`我准备跳槽但不知道简历问题在哪，请先问我目标岗位和当前经历。`],Nt=e=>{let t=c(e).replace(/[？?]+$/g,``);return t?`关于"${t}"，我的回答是：`:``},Pt=e=>{let t=String(e||``).split(`
`).map(e=>c(e).replace(/^[-*#>\s]+/,``).replace(/\*\*/g,``)).filter(Boolean),n=t.find(e=>!/^(?:google\/|provider:|model:|thought|思考过程)/i.test(e))||t[0]||``;return n?n.length<=64?n:`${n.slice(0,64)}…`:`已完成思考，点击查看完整过程`},Ft=(e,t)=>{let n=String(e||``).trim();return n?t===`user`?(0,$.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:n}):(0,$.jsx)(L,{text:n}):null};function It(){return u(`/tools/career-coach`)?(0,$.jsx)(F,{title:`职业教练`,hideModelSelector:!0,hideThinkingToggle:!0,compactHero:!0,hideFootnote:!0,children:(0,$.jsx)(K,{title:`职业教练即将上线`,description:`职业教练即将上线，建议先使用简历匹配与简历优化。`})}):(0,$.jsx)(Lt,{})}function Lt(){let{copiedKey:e,copyText:t}=de(),{busy:n,setBusy:r,detailBusy:i,setDetailBusy:a,detailStatus:o,setDetailStatus:s,detailCardTurnId:l,detailCardStage:u,err:d,setErr:f,dialogInput:p,setDialogInput:m,result:h,chatTurns:g,pendingAttachments:y,streamThinking:x,streamText:S,_streamStage:C,_streamActor:w,abortRef:T,runSeqRef:D,chatScrollRef:O,parseStage:k,isAuthed:A,authResolved:j,sessionId:M,coachConsentAccepted:N,setEmbeddedJdDraft:P,workflowStepsState:L,latestAssistantTurnId:te,buildActionHref:ne,jumpToRecommendedTool:re,runEmbeddedCoachTool:ie,ingestFilesToChat:ae,removePendingAttachment:B,jumpToTurn:oe,resetAll:se,submit:V,generateDetailedPlan:ce,profile:H}=Ot(),U=(0,q.useMemo)(()=>({...Qe,orchestrator:`总编排`,interview_questions:`面试题库`,salary_research:`薪酬调研`,career_assessment:`职业评估`,session_note:`阶段总结`,cover_letter:`Cover Letter`,networking_message:`人脉破冰`,finalize:`收尾整合`}),[]),W=(0,q.useMemo)(()=>(Array.isArray(L)?L:[]).map(e=>({tool:String(e?.kind||e?.tool||``),status:String(e?.status||``).trim()===`completed`?`done`:`running`})).filter(e=>e.tool),[L]),G=!!(n||S||x||W.length||i),K=(0,q.useMemo)(()=>z(g),[g]);return(0,$.jsx)(F,{title:`职业教练`,hideModelSelector:!0,hideThinkingToggle:!0,compactHero:!0,hideFootnote:!0,hideEyebrow:!0,sidebar:(0,$.jsx)(I,{current:`/tools/career-coach`}),children:(0,$.jsxs)(`div`,{className:`he-tools-main`,style:{display:`flex`,flexDirection:`column`},children:[j&&!A?(0,$.jsxs)(`div`,{className:`he-card`,children:[(0,$.jsx)(`div`,{className:`he-label`,children:`需要登录`}),(0,$.jsx)(`div`,{className:`he-muted`,style:{marginTop:8},children:`职业教练需要登录后才能开始聊天。对话保存在你当前的浏览器里，下次打开能接着继续；换设备或清除浏览器数据后会丢失。`}),(0,$.jsx)(`div`,{className:`he-actions`,style:{marginTop:12},children:(0,$.jsx)(`a`,{href:E(),className:`btn-primary`,children:`去登录`})})]}):null,(0,$.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,$.jsxs)(`div`,{style:{width:`100%`,display:`flex`,flexDirection:`column`},children:[K?(0,$.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,padding:`0 2px 8px`},children:(0,$.jsx)(_,{billing:K,label:`本次会话累计`,style:{marginTop:0,fontSize:11,lineHeight:1.5}})}):null,(0,$.jsx)(v,{style:{overflowY:`visible`},turns:g,assistantLabel:`职业教练助手`,hideBillingModel:!0,emptyText:`直接开始你的第一句提问。`,emptyState:(0,$.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,padding:`26px 24px 18px`},children:[(0,$.jsxs)(`div`,{style:{borderBottom:`1px solid var(--border-soft)`,paddingBottom:16},children:[(0,$.jsx)(`div`,{className:`he-label`,children:`职业教练对话`}),(0,$.jsx)(`div`,{style:{marginTop:8,fontSize:22,fontWeight:800,color:`var(--text-1)`,letterSpacing:`-0.02em`},children:`职业教练不是另一个聊天框，而是你的职业判断中枢`}),(0,$.jsx)(`div`,{className:`he-muted`,style:{marginTop:8,fontSize:13,lineHeight:1.8,maxWidth:720},children:`从转岗、跳槽、Offer 选择到长期规划，我会先帮你一步步完成。`}),(0,$.jsxs)(`div`,{style:{marginTop:12,display:`flex`,alignItems:`flex-start`,gap:8,padding:`10px 12px`,borderRadius:12,border:`1px solid var(--border-soft)`,background:`var(--surface2)`,maxWidth:720},children:[(0,$.jsx)(`span`,{style:{fontSize:12,fontWeight:700,color:`var(--text-2)`,flexShrink:0,marginTop:1},children:`说明`}),(0,$.jsx)(`span`,{className:`he-muted`,style:{fontSize:12,lineHeight:1.7},children:`本工具的对话会保存在你当前的浏览器里，下次打开能接着上次继续。换设备、更换浏览器或清除浏览器数据后会丢失；点「重新开始」会清空当前对话。`})]})]}),(0,$.jsxs)(`div`,{style:{marginTop:16,padding:`16px 16px 12px`,borderRadius:18,border:`1px solid var(--border)`,background:`var(--surface)`},children:[(0,$.jsx)(`div`,{className:`he-label`,children:`建议这样开始`}),(0,$.jsx)(`div`,{style:{marginTop:12,display:`flex`,flexWrap:`wrap`,gap:10},children:Mt.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(e),style:{padding:`10px 14px`,borderRadius:999,border:`1px solid var(--border)`,background:`var(--surface2)`,cursor:`pointer`,textAlign:`left`,transition:`transform 0.15s, border-color 0.15s`},onMouseEnter:e=>{e.currentTarget.style.transform=`translateY(-1px)`,e.currentTarget.style.borderColor=`var(--accent)`},onMouseLeave:e=>{e.currentTarget.style.transform=``,e.currentTarget.style.borderColor=`var(--border)`},children:(0,$.jsx)(`span`,{style:{fontSize:12,fontWeight:600,color:`var(--text-1)`,lineHeight:1.5},children:e})},`scenario_${t}`))}),(0,$.jsx)(`div`,{className:`he-muted`,style:{marginTop:12,fontSize:12,lineHeight:1.7},children:`你也可以直接粘贴简历、JD、offer 邮件、追问记录，或上传附件开始对话。`})]}),c(H?.currentRole)||c(H?.targetRole)||c(H?.yearsExperience)?(0,$.jsxs)(`div`,{style:{marginTop:16,padding:`14px 16px`,borderRadius:14,border:`1px solid var(--border-soft)`,background:`var(--surface2)`,display:`flex`,flexWrap:`wrap`,gap:10,alignItems:`center`},children:[(0,$.jsx)(`span`,{className:`he-label`,style:{fontSize:11,marginRight:4},children:`我的档案`}),c(H?.currentRole)?(0,$.jsxs)(`span`,{className:`he-chip`,children:[`现在：`,H.currentRole]}):null,c(H?.targetRole)?(0,$.jsxs)(`span`,{className:`he-chip`,style:{borderColor:`var(--accent)`,color:`var(--accent)`,background:`color-mix(in srgb, var(--accent) 8%, transparent)`},children:[`目标：`,H.targetRole]}):null,c(H?.yearsExperience)?(0,$.jsxs)(`span`,{className:`he-chip`,children:[H.yearsExperience,` 年经验`]}):null]}):null]}),chatScrollRef:O,renderContent:e=>(0,$.jsxs)($.Fragment,{children:[e.role===`assistant`&&c(e.reasoningContent)?(0,$.jsx)(`div`,{style:{marginBottom:12},children:(0,$.jsx)(ee,{thinking:e.reasoningContent||``,title:`思考`,defaultCollapsed:!0,maxHeight:160,fontSize:11,lineHeight:1.45,embedded:!0,collapsedPreview:Pt(e.reasoningContent)})}):null,e.role===`assistant`&&e.fallbackMeta?(0,$.jsx)(b,{raw:e.fallbackMeta,variant:`notice`,style:{marginBottom:12,padding:`10px 14px`,borderRadius:14,background:`rgba(244, 136, 53, 0.08)`,border:`1px solid rgba(244, 136, 53, 0.18)`},textStyle:{color:`var(--text-1)`,fontSize:13,fontWeight:600}}):null,e.role===`assistant`&&e.fallbackMeta?(0,$.jsx)(b,{raw:e.fallbackMeta,variant:`hint`,style:{marginBottom:12,padding:`10px 14px`,borderRadius:14,background:`rgba(244, 136, 53, 0.07)`,border:`1px solid rgba(244, 136, 53, 0.16)`},textStyle:{color:`var(--text-2)`,fontSize:13,lineHeight:1.65}}):null,Ft(e.content,e.role)]}),streamPreview:G?(0,$.jsx)(R,{assistantLabel:`职业教练助手`,busy:n||i,streamText:S,streamThinking:x,streamStage:C,streamActor:w,agentMode:W.length>0,agentSteps:W,stepLabels:U,stageText:c(o)||`职业教练正在思考与规划下一步`,emptyText:`正在结合画像、上下文和工具执行台账生成下一步建议…`}):null,onCopyAssistantMessage:e=>t(`msg_${e.id}`,e.content),copiedAssistantTurnId:e.startsWith(`msg_`)?e.slice(4):``,getAssistantActions:e=>{let t=te===e.id,n=t&&h&&c(M),r=t&&h&&Array.isArray(h.toolRecommendations)&&h.toolRecommendations.length>0,a=[];return t&&a.push({key:h?`refresh_detail_plan`:`generate_detail_plan`,label:i&&l===e.id?`正在生成详细规划`:h?`重新生成详细规划`:`生成详细规划`,onClick:()=>{i&&l===e.id||ce(e)},primary:!1}),r&&h.toolRecommendations.slice(0,2).map((e,t)=>{let n=$e(c(e.tool)),r=ne(c(e.tool));n?a.push({key:`tool_inline_${t}`,label:`${c(e.reason)||`在对话里执行 ${Ze[n]}`}`,onClick:()=>{c(e.prefillHint)&&P(c(e.prefillHint)),ie(n)},primary:!1}):r&&a.push({key:`tool_${t}`,label:`${c(e.reason)||`去使用 ${c(e.tool)}`}`,onClick:()=>{re(c(e.tool),c(e.prefillHint))},primary:!1})}),fe({nextQuestion:t?c(h?.nextQuestion):``,onUseNextQuestion:t&&c(h?.nextQuestion)?()=>m(Nt(c(h?.nextQuestion))):void 0,nextQuestionLabel:`回答教练追问`,onShowDetail:n?()=>{window.location.href=`/report/career-coach?sid=${encodeURIComponent(c(M))}`}:void 0,customActions:a})},getAssistantCards:e=>te!==e.id||!h?null:(0,$.jsx)(At,{assistantTurnId:e.id,detailCardTurnId:l,detailCardStage:u,result:h,onAnswerQuestion:e=>m(Nt(e)),onOpenReport:c(M)?()=>{window.location.href=`/report/career-coach?sid=${encodeURIComponent(c(M))}`}:void 0,onRunTool:(e,t)=>{let n=$e(c(e));if(n){c(t)&&P(c(t)),ie(n);return}re(c(e),t)}})})]}),(0,$.jsx)(jt,{sticky:!0,busy:n,detailBusy:i,detailStatus:o,parseStage:k,coachConsentAccepted:N,needsUserInput:L.some(e=>String(e?.status||``).trim()===`failed`),pendingAttachments:y,removePendingAttachment:B,dialogInput:p,setDialogInput:m,submit:V,ingestFilesToChat:ae,isAuthed:A,resetAll:se,chatTurns:g,result:h,sessionId:M,latestAssistantTurnId:te,jumpToTurn:oe,runSeqRef:D,abortRef:T,setBusy:r,setDetailBusy:a,setDetailStatus:s,err:d,setErr:f})]}),(0,$.jsxs)(`details`,{style:{marginTop:12},children:[(0,$.jsx)(`summary`,{style:{cursor:`pointer`,fontSize:13,fontWeight:600,color:`var(--text-2)`},children:`检测岗位 JD 黑话（粘贴 JD，解读招聘套路与风险）`}),(0,$.jsx)(ge,{standalone:!0,sourceTool:`career_coach`,disabled:n})]})]})})}export{It as default};