PageSourceSearch

https://1000paths.ai/path-app-v2/assets/simulator-BRH_jkPN.js

js 1000paths.ai collected 2026-10-05 11:46:57 UTC 13,982 bytes, 1 lines download raw bytes

1import{d as ee,as as B,r as d,at as U,j as e,E as S,o as F}from"./index-CEBZ7Z96.js";const te=12,se=6,ae=250;function le({embedded:u=!1}={}){const{data:s,isLoading:r,error:o}=ee(),{data:c,isLoading:h,error:f}=B({queryKey:["/api/archetypes"],queryFn:()=>U("/archetypes"),staleTime:5*6e4}),{data:i,isLoading:C}=B({queryKey:["/api/users/me/profile"],queryFn:()=>U("/users/me/profile"),staleTime:6e4}),p=d.useMemo(()=>{if(!s||!c)return null;if(s.archetypeId!==null){const t=c.find(a=>a.id===s.archetypeId);if(t)return t}if(s.archetypeName){const t=c.find(l=>l.name===s.archetypeName);if(t)return t;const a=l=>l.toLowerCase().replace(/[^a-z0-9]+/g," ").trim(),n=a(s.archetypeName),m=c.find(l=>a(l.name)===n);if(m)return m}return null},[s,c]),[b,E]=d.useState(null);d.useEffect(()=>{b===null&&p&&E(p.id)},[b,p]);const w=d.useMemo(()=>!c||b===null?null:c.find(t=>t.id===b)??null,[c,b]),y=d.useMemo(()=>new Set((i?.skills??[]).map(t=>t.toLowerCase())),[i?.skills]),j=d.useMemo(()=>new Set((i?.credentials??[]).map(t=>t.toLowerCase())),[i?.credentials]),M=d.useMemo(()=>{const t=(w?.skillFrequencies??[]).slice(0,te).map(l=>l.skill),a=i?.skills??[],n=new Set,m=[];return[...t,...a].forEach(l=>{const g=l.toLowerCase();n.has(g)||(n.add(g),m.push(l))}),m},[w,i?.skills]),L=d.useMemo(()=>{const t=(w?.credentialFrequencies??[]).slice(0,se).map(l=>l.credential),a=i?.credentials??[],n=new Set,m=[];return[...t,...a].forEach(l=>{const g=l.toLowerCase();n.has(g)||(n.add(g),m.push(l))}),m},[w,i?.credentials]),[_,P]=d.useState(new Map),[R,T]=d.useState(new Map);d.useEffect(()=>{P(t=>{const a=new Map;return M.forEach(n=>{t.has(n)?a.set(n,t.get(n)):a.set(n,y.has(n.toLowerCase()))}),a})},[M,y]),d.useEffect(()=>{T(t=>{const a=new Map;return L.forEach(n=>{t.has(n)?a.set(n,t.get(n)):a.set(n,j.has(n.toLowerCase()))}),a})},[L,j]);const{addSkills:I,removeSkills:D,addCredentials:$}=d.useMemo(()=>{const t=[],a=[];_.forEach((m,l)=>{const g=y.has(l.toLowerCase());m&&!g?t.push(l):!m&&g&&a.push(l)});const n=[];return R.forEach((m,l)=>{const g=j.has(l.toLowerCase());m&&!g&&n.push(l)}),{addSkills:t,removeSkills:a,addCredentials:n}},[_,R,y,j]),[x,H]=d.useState(null),[J,A]=d.useState(!1),[O,z]=d.useState(null),N=d.useRef(null),q=d.useRef(null),k=d.useRef(0);d.useEffect(()=>{if(!(!p||b===null))return N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{q.current&&q.current.abort();const t=new AbortController;q.current=t;const a=++k.current;A(!0),z(null),U("/score/simulate",{method:"POST",signal:t.signal,body:JSON.stringify({archetypeId:b,addSkills:I,addCredentials:$,removeSkills:D})}).then(n=>{a===k.current&&H(n)}).catch(n=>{t.signal.aborted||a===k.current&&z(n?.message??"Simulation failed")}).finally(()=>{a===k.current&&A(!1)})},ae),()=>{N.current&&clearTimeout(N.current)}},[p,b,I,$,D]);const Q=t=>P(a=>{const n=new Map(a);return n.set(t,!a.get(t)),n}),V=t=>T(a=>{const n=new Map(a);return n.set(t,!a.get(t)),n}),K=p!==null&&b!==p.id,v=I.length+D.length+$.length,X=K||v>0,Z=()=>{p&&E(p.id),P(t=>{const a=new Map;return t.forEach((n,m)=>a.set(m,y.has(m.toLowerCase()))),a}),T(t=>{const a=new Map;return t.forEach((n,m)=>a.set(m,j.has(m.toLowerCase()))),a})};return r||h||C?e.jsx("div",{className:"py-16 text-center label-mono opacity-60",children:"Loading simulator…"}):o||!s?e.jsx(S,{tag:"Simulator",headline:"Simulator unavailable.",helper:"We couldn't load your composite score. Set a destination from your Map to open the simulator.",variant:"error",cta:{label:"Pick a destination",onClick:F},testId:"sim-no-score"}):f||!c||c.length===0?e.jsx(S,{tag:"Simulator",headline:"Destinations unavailable.",helper:"We couldn't load the destination catalog. Refresh in a moment.",variant:"error",cta:{label:"Refresh",onClick:()=>window.location.reload()},testId:"sim-no-archetypes"}):s.archetypeId===null?e.jsx(S,{tag:"Simulator",headline:"Set a destination first.",helper:"The simulator compares your current path to a candidate path — choose a destination from your Compass and try again.",variant:"notice",cta:{label:"Pick a destination",onClick:F},testId:"sim-no-destination"}):p?e.jsxs("div",{className:u?"space-y-6":"space-y-10",children:[!u&&e.jsxs("header",{children:[e.jsx("p",{className:"label-mono opacity-60 mb-2",children:"§ Simulator"}),e.jsx("h1",{className:"font-serif text-3xl sm:text-4xl mb-3",children:"Model what changes do."}),e.jsx("p",{className:"text-ink-700 max-w-2xl",children:"Toggle skills and credentials on or off, or switch the destination you're simulating against. Every number below is recomputed by the same engine that powers your Compass — there are no scenarios baked in."})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.1fr)] gap-8",children:[e.jsxs("section",{className:"space-y-8",children:[e.jsxs("div",{className:"border border-rule p-5 sm:p-6 bg-paper",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-3",children:[e.jsx("h2",{className:"label-mono",children:"Destination"}),K&&e.jsx("span",{className:"label-mono text-[10px] tracking-wider opacity-70",children:"Switched"})]}),e.jsx("select",{className:"w-full border border-rule bg-paper px-3 py-2 touch:min-h-11 font-serif text-lg",value:b??"",onChange:t=>E(Number(t.target.value)),children:c.map(t=>e.jsxs("option",{value:t.id,children:[t.name,t.id===p.id?"  ·  current":""]},t.id))}),e.jsxs("p",{className:"text-sm text-ink-700 mt-3",children:["Current destination is ",e.jsx("strong",{children:p.name}),". Switching here doesn't change your saved goal — it only re-scores you against a different path so you can compare."]})]}),e.jsx(W,{title:"Skills",items:M,ownedLower:y,enabled:_,onToggle:Q}),e.jsx(W,{title:"Credentials",items:L,ownedLower:j,enabled:R,onToggle:V}
1),v>0&&e.jsx("p",{className:"label-mono text-[10px] opacity-60 pt-2 leading-relaxed",children:"Projected estimate — added skills haven't been validated against your resume yet. Real composite is reconciled when those skills show up in your work history."}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-2",children:[e.jsx("span",{className:"label-mono text-[11px] opacity-60",children:v===0?"No changes simulated":`${v} change${v===1?"":"s"} simulated`}),e.jsx("button",{type:"button",disabled:!X,onClick:Z,className:"label-mono opacity-70 hover:opacity-100 disabled:opacity-30 disabled:hover:opacity-30",children:"← Reset to your saved path"})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-3",children:[e.jsx("h2",{className:"label-mono",children:"Side-by-side"}),e.jsx("span",{className:"label-mono text-[10px] tracking-wider opacity-60",children:J?"recomputing…":O?"error":x?"live":"—"})]}),O&&e.jsx("div",{className:"border border-rule bg-paper p-4 text-sm text-ink-700 mb-4",children:O}),e.jsxs("div",{className:"grid grid-cols-2 gap-px bg-rule border border-rule",children:[e.jsx(G,{kind:"current",meta:x?.currentPath??null,composite:x?.current??null,fallbackComposite:s.composite}),e.jsx(G,{kind:"simulated",meta:x?.simulatedPath??null,composite:x?.simulated??null,delta:x?.delta??null,fallbackComposite:s.composite})]}),x&&e.jsx(re,{dimensions:x.dimensions}),x?.roi&&x.roi.items.length>0&&e.jsx(ne,{items:x.roi.items}),e.jsx("p",{className:"text-sm text-ink-700 mt-6",children:"Composite scores are out of 100. The 2-year and median-time figures are pulled from the cohort buckets your Pivot Playbook uses, so what you see here matches what you'd see if you set this destination as your goal."})]})]})]}):e.jsx(S,{tag:"Simulator",headline:"Destination not found.",helper:"Your saved destination doesn't match any archetype in our catalog. Pick a new destination from your Compass.",variant:"notice",cta:{label:"Pick a destination",onClick:F},testId:"sim-destination-missing"})}function W({title:u,items:s,ownedLower:r,enabled:o,onToggle:c}){const h=s.filter(i=>r.has(i.toLowerCase())),f=s.filter(i=>!r.has(i.toLowerCase()));return e.jsxs("div",{className:"border border-rule p-5 sm:p-6 bg-paper",children:[e.jsx("h2",{className:"label-mono mb-3",children:u}),s.length===0?e.jsxs("p",{className:"text-sm text-ink-700",children:["No ",u.toLowerCase()," signal recorded for this destination."]}):e.jsxs("div",{className:"space-y-3",children:[h.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"label-mono text-[10px] opacity-60 mb-1.5",children:["You have (",h.length,") — toggle off to simulate dropping"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(i=>e.jsx(Y,{label:i,on:o.get(i)??!0,onClick:()=>c(i),style:"owned"},i))})]}),f.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"label-mono text-[10px] opacity-60 mb-1.5",children:["Candidates (",f.length,") — toggle on to simulate adding"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(i=>e.jsx(Y,{label:i,on:o.get(i)??!1,onClick:()=>c(i),style:"candidate"},i))})]})]})]})}function Y({label:u,on:s,onClick:r,style:o}){let c="px-3 py-1.5 touch:min-h-11 inline-flex items-center border text-sm transition-colors ";o==="owned"?c+=s?"bg-ink-900 text-paper border-ink-900":"bg-paper text-ink-700 border-rule line-through opacity-70 hover:opacity-100":c+=s?"bg-ink-900 text-paper border-ink-900":"bg-paper text-ink-900 border-rule hover:border-ink-900";const h=o==="owned"?s?"✓ ":"× ":s?"+ ":"  ";return e.jsxs("button",{type:"button",onClick:r,className:c,children:[h,u]})}function G({kind:u,meta:s,composite:r,delta:o,fallbackComposite:c}){const h=u==="simulated",f=r!==null?r:h?null:c,i=h&&typeof o=="number"&&Math.abs(o)>=1,C=(o??0)>0?"+":"";return e.jsxs("div",{className:"bg-paper p-5 sm:p-6",children:[e.jsx("div",{className:"label-mono opacity-60 mb-2",children:h?"Simulated path":"Current path"}),e.jsx("div",{className:"font-serif text-xl mb-1",children:s?.archetypeName??(h?"—":"")}),e.jsxs("div",{className:"text-sm text-ink-700 mb-4",children:[s?.targetRole??"",s?.sampleSize!=null?` · n = ${s.sampleSize.toLocaleStr
1ing()}`:""]}),e.jsxs("div",{className:"flex items-baseline gap-3 mb-4",children:[e.jsx("div",{className:"font-serif text-5xl tabular-nums",children:f!==null?Math.round(f):"—"}),i&&e.jsxs("div",{className:"label-mono text-sm "+((o??0)>0?"text-olive-700":"text-crimson-500"),children:[C,Math.round(o??0)]})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsx("dt",{className:"opacity-60",children:"% in 2 years"}),e.jsx("dd",{className:"tabular-nums",children:s?.pct2yr!==null&&s?.pct2yr!==void 0?`${s.pct2yr}%`:"—"}),e.jsx("dt",{className:"opacity-60",children:"Median months"}),e.jsx("dd",{className:"tabular-nums",children:s?.medianMonths??"—"})]}),s?.pathSteps&&s.pathSteps.length>0&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-rule",children:[e.jsx("div",{className:"label-mono text-[10px] opacity-60 mb-1",children:"Path shape"}),e.jsx("div",{className:"text-sm text-ink-700 leading-relaxed",children:s.pathSteps.join(" → ")})]})]})}function ne({items:u}){const s=r=>r>=1e3?`$${(r/1e3).toFixed(r>=1e4?0:1)}k`:`$${r}`;return e.jsxs("div",{className:"mt-8 border border-rule","data-testid":"sim-roi-block",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 px-4 py-3 bg-paper border-b border-rule",children:[e.jsx("h3",{className:"label-mono",children:"§ ROI · Payback estimates"}),e.jsx("a",{href:"/methodology#compensation",className:"label-mono text-[10px] tracking-wider opacity-60 hover:opacity-100",children:"How we compute these →"})]}),e.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto_auto_auto] gap-4 px-4 py-2 bg-paper border-b border-rule label-mono text-[11px] opacity-60",children:[e.jsx("div",{children:"Kind"}),e.jsx("div",{children:"Move"}),e.jsx("div",{className:"text-right",children:"Est. cost"}),e.jsx("div",{className:"text-right",children:"Annual lift"}),e.jsx("div",{className:"text-right",children:"Payback"})]}),u.map(r=>e.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto_auto_auto] gap-4 px-4 py-2 bg-paper border-b border-rule last:border-b-0 text-sm items-baseline",children:[e.jsx("div",{className:"label-mono opacity-60 text-[10px] uppercase",children:r.kind}),e.jsx("div",{className:"truncate",children:r.name}),e.jsxs("div",{className:"text-right tabular-nums",children:[s(r.costUsd),!r.isReference&&e.jsx("span",{className:"label-mono text-[10px] opacity-50 ml-1",children:"est"})]}),e.jsx("div",{className:"text-right tabular-nums",children:s(r.annualCompDeltaUsd)}),e.jsx("div",{className:"text-right tabular-nums text-ink-900 font-medium",children:r.paybackText})]},`${r.kind}:${r.name}`)),e.jsx("p",{className:"text-xs text-ink-500 px-4 py-3 leading-relaxed",children:"Cost figures are mid-market US estimates (tuition + fees); annual lift is a typical comp delta at the next waypoint. Payback adds a 12-month realisation lag so the figure reflects when you start seeing the lift, not when you finish the credential."})]})}function re({dimensions:u}){const s=Object.entries(u??{});return s.length===0?null:e.jsxs("div",{className:"mt-6 border border-rule",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-2 bg-paper border-b border-rule label-mono text-[11px] opacity-60",children:[e.jsx("div",{children:"Dimension"}),e.jsx("div",{className:"text-right",children:"Current"}),e.jsx("div",{className:"text-right",children:"Simulated"}),e.jsx("div",{className:"text-right",children:"Δ"})]}),s.map(([r,o])=>e.jsxs("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-2 bg-paper border-b border-rule last:border-b-0 text-sm",children:[e.jsx("div",{children:o.label}),e.jsx("div",{className:"text-right tabular-nums",children:Math.round(o.current)}),e.jsx("div",{className:"text-right tabular-nums",children:Math.round(o.simulated)}),e.jsxs("div",{className:"text-right tabular-nums "+(o.delta>0?"text-olive-700":o.delta<0?"text-crimson-500":"opacity-50"),children:[o.delta>0?"+":"",Math.round(o.delta)]})]},r))]})}export{le as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.