PageSourceSearch

https://xterns.ai/assets/XternProfile-C7CieAUy.js

js xterns.ai collected 2026-10-05 13:24:15 UTC 72,291 bytes, 16 lines download raw bytes

1import{c as be,r as P,ad as D,j as e,N as Oe,O as Re,Q as Ge,V as $e,I as Y,n as ge,J as O,B as V,f as je,s as I,g as q,u as Be,Y as hs,h as X,i as Z,k as J,m as Q,F as De,M as ve,aL as ze,aa as He,ab as Ke,ac as Ye,K as Ae,a5 as ee,x as ps,S as We,w as fs,a4 as gs,b as Xe,aj as ys,E as bs,Z as js,a7 as Qe,P as vs,t as Ns,a as ws,aK as ue,bt as he,bu as pe,aZ as Pe}from"./index-DLd_kDlx.js";import{L as G}from"./label-D4-ENrYn.js";import{T as ks}from"./textarea-C6X-I43k.js";import{u as _s}from"./useXternProfile-C3z298Ah.js";import{s as Ss}from"./dareyScoreProfileSync-Bj-bhG5E.js";import{u as Cs}from"./useEIScore-C48npH32.js";import{A as As,a as Ps}from"./alert-CyfKy7ls.js";import{B as Es}from"./brain-pqum15ho.js";import{S as ye}from"./star-BH1OFEcs.js";import{L as Ms}from"./loader-circle-D2miE2xB.js";import{P as Ts,D as Us}from"./ProfilePictureUpload-C75uCAIp.js";import{C as Ls}from"./ConnectGitHubButton-DLktnEM_.js";import{s as ce}from"./subDays-B5afKHU7.js";import{f as ae,a as Fs}from"./format-BTXglRCX.js";import{g as Is}from"./getDay-qh2J2e9D.js";import{p as de}from"./parseISO-B4sJZ6AV.js";import{G as Ne}from"./git-commit-horizontal-CQF5yVsh.js";import{G as Ze}from"./git-pull-request-__1fAqC3.js";import{T as Je}from"./trending-up-BU4cR3Ys.js";import{c as Vs,d as qs,V as Os,e as Rs,u as es,f as ss,M as Gs,b as $s,g as Bs,h as Ds,j as fe,r as zs,k as Hs,l as ts,n as rs,o as Ks,p as Ys,q as Ws,s as Xs,t as Qs,v as Zs,w as Js,x as et,S as st,H as tt,y as me,z as rt,A as at,B as nt,m as R}from"./proxy-D0Q57V63.js";import{E as it}from"./EmptyState-DNi4BV7D.js";import{A as lt}from"./index-Da4Am1jz.js";import{B as ot}from"./book-open-BSYsXyfC.js";import{A as ct}from"./award-MEJfpupD.js";import{M as dt}from"./message-square-CtxeCfRz.js";import{E as mt}from"./eye-CRDofLPH.js";import{i as xt}from"./isAfter-DDRF2ylA.js";import{f as ut}from"./formatDistanceToNow-57P64IbE.js";import{f as ht}from"./numberFormat-zOUS8IHU.js";import{R as pt}from"./generateCategoricalChart-ByDL-d9M.js";import{A as ft,a as gt}from"./AreaChart-DvsyYnZ8.js";import{T as Ee}from"./trophy-DBX-jNOC.js";import{M as as}from"./map-pin-ChCNbN_o.js";import{M as ns}from"./mail-BVn2o8AP.js";import{S as is}from"./square-pen-Ce4P3TUP.js";import{L as we}from"./linkedin-C3YpjTq8.js";import{G as ke}from"./globe-C057RQ73.js";import{P as yt}from"./phone-rtR4Bg4j.js";import{R as bt}from"./refresh-cw-CoPjtj5-.js";import{U as jt}from"./upload-CCEcMTV9.js";import{C as vt}from"./code-xml-BUecDWl6.js";import{B as ls}from"./badge-check-BG9dn4bq.js";import{P as xe}from"./plus-0WhrdjYO.js";import{E as Nt}from"./external-link-D0CFvOTk.js";import"./select-RSrodAEw.js";import"./index-BdQq_4o_.js";import"./index-Deh-4PO1.js";import"./chevron-down-DpJJsCer.js";import"./chevron-up-M4SAwIjf.js";import"./monitor-CcmP4yDI.js";import"./rotate-ccw-Bx1C64Ur.js";import"./camera-CjU4dBqw.js";import"./useGitHubIdentity-DDmb0Jwt.js";import"./en-US-9SRVm7yB.js";import"./differenceInCalendarMonths-BA0TPVs2.js";import"./endOfDay-DkR3ZXc8.js";import"./endOfMonth-CYn6pTOm.js";import"./findIndex-Cos7Fxsp.js";import"./tiny-invariant-CopsF_GD.js";import"./YAxis-BtEb5zMI.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const os=be("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const wt=be("ChartSpline",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16c.5-2 1.5-7 4-7 2 0 2 3 4 3 2.5 0 4.5-5 5-7",key:"lw07rv"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const kt=be("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]),_t=(t,s,a)=>{const n=s-t;return((a-t)%n+n)%n+t};function cs(t,s){return Vs(t)?t[_t(0,t.length,s)]:t}class St{constructor(s){this.stop=()=>
vendor: 6,466 bytes, line 16
16this.runAll("stop"),this.animations=s.filter(Boolean)}get finished(){return Promise.all(this.animations.map(s=>s.finished))}getAll(s){return this.animations[0][s]}setAll(s,a){for(let n=0;n<this.animations.length;n++)this.animations[n][s]=a}attachTimeline(s){const a=this.animations.map(n=>n.attachTimeline(s));return()=>{a.forEach((n,l)=>{n&&n(),this.animations[l].stop()})}}get time(){return this.getAll("time")}set time(s){this.setAll("time",s)}get speed(){return this.getAll("speed")}set speed(s){this.setAll("speed",s)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return Me(this.animations,"duration")}get iterationDuration(){return Me(this.animations,"iterationDuration")}runAll(s){this.animations.forEach(a=>a[s]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function Me(t,s){let a=0;for(let n=0;n<t.length;n++){const l=t[n][s];l!==null&&l>a&&(a=l)}return a}class Ct extends St{then(s,a){return this.finished.finally(s).then(()=>{})}}function At(...t){const s=!Array.isArray(t[0]),a=s?0:-1,n=t[0+a],l=t[1+a],u=t[2+a],r=t[3+a],o=qs(l,u,r);return s?o(n):o}function Pt(t,s){return t in s}class Et extends Os{constructor(){super(...arguments),this.type="object"}readValueFromInstance(s,a){if(Pt(a,s)){const n=s[a];if(typeof n=="string"||typeof n=="number")return n}}getBaseTargetFromProps(){}removeValueFromRenderState(s,a){delete a.output[s]}measureInstanceViewportBox(){return Rs()}build(s,a){Object.assign(s.output,a)}renderInstance(s,{output:a}){Object.assign(s,a)}sortInstanceNodePosition(){return 0}}function ds(t){const s=es(()=>ss(t)),{isStatic:a}=P.useContext(Gs);if(a){const[,n]=P.useState(t);P.useEffect(()=>s.on("change",n),[])}return s}function ms(t,s){const a=ds(s()),n=()=>a.set(s());return n(),$s(()=>{const l=()=>Ds.preRender(n,!1,!0),u=t.map(r=>r.on("change",l));return()=>{u.forEach(r=>r()),Bs(n)}}),a}function Mt(t){fe.current=[],t();const s=ms(fe.current,t);return fe.current=void 0,s}function Tt(t,s,a,n){if(typeof t=="function")return Mt(t);const u=typeof s=="function"?s:At(s,a,n),r=Array.isArray(t)?Te(t,u):Te([t],([d])=>u(d)),o=Array.isArray(t)?void 0:t.accelerate;return o&&!o.isTransformed&&typeof s!="function"&&Array.isArray(a)&&(n==null?void 0:n.clamp)!==!1&&(r.accelerate={...o,times:s,keyframes:a,isTransformed:!0}),r}function Te(t,s){const a=es(()=>[]);return ms(t,()=>{a.length=0;const n=t.length;for(let l=0;l<n;l++)a[l]=t[l].get();return s(a)})}function _e(t){return typeof t=="object"&&!Array.isArray(t)}function xs(t,s,a,n){return t==null?[]:typeof t=="string"&&_e(s)?zs(t,a,n):t instanceof NodeList?Array.from(t):Array.isArray(t)?t.filter(l=>l!=null):[t]}function Ut(t,s,a){return t*(s+1)}function Ue(t,s,a,n){return typeof s=="number"?s:s.startsWith("-")||s.startsWith("+")?Math.max(0,t+parseFloat(s)):s==="<"?a:s.startsWith("<")?Math.max(0,a+parseFloat(s.slice(1))):n.get(s)??t}function Lt(t,s,a){for(let n=0;n<t.length;n++){const l=t[n];l.at>s&&l.at<a&&(ts(t,l),n--)}}function Ft(t,s,a,n,l,u){Lt(t,l,u);for(let r=0;r<s.length;r++)t.push({value:s[r],at:Hs(l,u,n[r]),easing:cs(a,r)})}function It(t,s){for(let a=0;a<t.length;a++)t[a]=t[a]/(s+1)}function Vt(t,s){return t.at===s.at?t.value===null?1:s.value===null?-1:0:t.at-s.at}const qt="easeInOut";function Ot(t,{defaultTransition:s={},...a}={},n,l){const u=s.duration||.3,r=new Map,o=new Map,d={},x=new Map;let i=0,c=0,m=0;for(let S=0;S<t.length;S++){const j=t[S];if(typeof j=="string"){x.set(j,c);continue}else if(!Array.isArray(j)){x.set(j.name,Ue(c,j.at,i,x));continue}let[w,E,T={}]=j;T.at!==void 0&&(c=Ue(c,T.at,i,x));let k=0;const C=(f,y,b,v=0,L=0)=>{const U=Rt(f),{delay:$=0,times:g=Ks(U),type:A=s.type||"keyframes",repeat:N,repeatType:p,repeatDelay:h=0,...M}=y;let{ease:_=s.ease||"easeOut",duration:F}=y;const B=typeof $=="function"?$(v,L):$,z=U.length,H=Xs(A)?A:l==null?void 0:l[A||"keyframes"];if(z<=2&&H){let se=100;if(z===2&&Bt(U)){const te=U[1]-U[0];se=Math.abs(te)}const ie={...s,...M};F!==void 0&&(ie.duration=Qs(F));const le=Ys(ie,se,H);_=le.ease,F=le.duration}F??(F=u);const K=c+B;g.length===1&&g[0]===0&&(g[1]=1);const ne=g.length-U.length;if(ne>0&&Ws(g,ne),U.length===1&&U.unshift(null),N){F=Ut(F,N);const se=[...U],ie=[...g];_=Array.isArray(_)?[..._]:[_];const le=[..._];for(let te=0;te<N;te++){U.push(...se);for(let re=0;re<se.length;re++)g.push(ie[re]+(te+1)),_.push(re===0?"linear":cs(le,re-1))}It(g,N)}const Ce=K+F;Ft(b,U,_,g,K,Ce),k=Math.max(B+F,k),m=Math.max(Ce,m)};if(rs(w)){const f=Le(w,o);C(E,T,Fe("default",f))}else{const f=xs(w,E,n,d),y=f.length;for(let b=0;b<y;b++){E=E,T=T;const v=f[b],L=Le(v,o);for(const U in E)C(E[U],Gt(T,U),Fe(U,L),b,y)}}i=c,c+=k}return o.forEach((S,j)=>{for(const w in S){const E=S[w];E.sort(Vt);const T=[],k=[],C=[];for(let v=0;v<E.length;v++){const{at:L,value:U,easing:$}=E[v];T.push(U),k.push(Zs(0,m,L)),C.push($||"easeOut")}k[0]!==0&&(k.unshift(0),T.unshift(T[0]),C.unshift(qt)),k[k.length-1]!==1&&(k.push(1),T.push(null)),r.has(j)||r.set(j,{keyframes:{},transition:{}});const f=r.get(j);f.keyframes[w]=T;const{type:y,...b}=s;f.transition[w]={...b,duration:m,ease:C,times:k,...a}}}),r}function Le(t,s){return!s.has(t)&&s.set(t,{}),s.get(t)}function Fe(t,s){return s[t]||(s[t]=[]),s[t]}function Rt(t){return Array.isArray(t)?t:[t]}function Gt(t,s){return t&&t[s]?{...t,...t[s]}:{...t}}const $t=t=>typeof t=="number",Bt=t=>t.every($t);function Dt(t){const s={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},a=Js(t)&&!et(t)?new st(s):new tt(s);a.mount(t),me.set(t,a)}function zt(t){const s={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},a=new Et(s);a.mount(t),me.set(t,a)}function Ht(t,s){return rs(t)||typeof t=="number"||typeof t=="string"&&!_e(s)}function us(t,s,a,n){const l=[];if(Ht(t,s))l.push(rt(t,_e(s)&&s.default||s,a&&(a.default||a)));else{if(t==null)return l;const u=xs(t,s,n),r=u.length;for(let o=0;o<r;o++){const d=u[o],x=d instanceof Element?Dt:zt;me.has(d)||x(d);const i=me.get(d),c={...a};"delay"in c&&typeof c.delay=="function"&&(c.delay=c.delay(o,r)),l.push(...at(i,{...s,transition:c},{}))}}return l}function Kt(t,s,a){const n=[],l=t.map(r=>{if(Array.isArray(r)&&typeof r[0]=="function"){const o=r[0],d=ss(0);return d.on("change",o),r.length===1?[d,[0,1]]:r.length===2?[d,[0,1],r[1]]:[d,r[1],r[2]]}return r});return Ot(l,s,a,{spring:nt}
16).forEach(({keyframes:r,transition:o},d)=>{n.push(...us(d,r,o))}),n}function Yt(t){return Array.isArray(t)&&t.some(Array.isArray)}function Wt(t={}){const{scope:s,reduceMotion:a}=t;function n(l,u,r){let o=[],d;if(Yt(l)){const{onComplete:i,...c}=u||{};typeof i=="function"&&(d=i),o=Kt(l,a!==void 0?{reduceMotion:a,...c}:c,s)}else{const{onComplete:i,...c}=r||{};typeof i=="function"&&(d=i),o=us(l,u,a!==void 0?{reduceMotion:a,...c}:c,s)}const x=new Ct(o);return d&&x.finished.then(d),s&&(s.animations.push(x),x.finished.then(()=>{ts(s.animations,x)})),x}return n}const Xt=Wt(),Qt=({isOpen:t,onClose:s,onSave:a,initialData:n})=>{const[l,u]=P.useState({firstName:"",lastName:"",email:"",bio:"",location:"",phone:"",portfolio:"",github:"",linkedin:"",careerPaths:[]});P.useEffect(()=>{if(n){const i=new Set(D.map(w=>w.id)),c=Array.isArray(n.careerPaths)?Array.from(new Set(n.careerPaths)).filter(w=>i.has(w)).slice(0,2):[],m=(n.name||"").trim().replace(/\s+/g," "),[S,...j]=m.split(" ");u({firstName:n.firstName||S||"",lastName:n.lastName||j.join(" ")||"",email:n.email||"",bio:n.bio||"",location:n.location||"",phone:n.phone||"",portfolio:n.portfolio||"",github:n.github||"",linkedin:n.linkedin||"",careerPaths:c})}},[n]);const r=(i,c)=>{u(m=>({...m,[i]:c}))},o=(i,c)=>{u(m=>{const S=new Set(D.map(w=>w.id)),j=Array.from(new Set(m.careerPaths.filter(w=>S.has(w))));return c?!j.includes(i)&&j.length<2?{...m,careerPaths:[...j,i]}:{...m,careerPaths:j}:{...m,careerPaths:j.filter(w=>w!==i)}})},d=i=>{i.preventDefault(),a(l),s()},x=i=>i.map(c=>{var m;return(m=D.find(S=>S.id===c))==null?void 0:m.name}).filter(Boolean);return e.jsx(Oe,{open:t,onOpenChange:s,children:e.jsxs(Re,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ge,{children:e.jsx($e,{children:"Edit Profile"})}),e.jsxs("form",{onSubmit:d,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"firstName",children:"First Name"}),e.jsx(Y,{id:"firstName",value:l.firstName,onChange:i=>r("firstName",i.target.value),placeholder:"Enter your first name",required:!0})]}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Y,{id:"lastName",value:l.lastName,onChange:i=>r("lastName",i.target.value),placeholder:"Enter your last name",required:!0})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:e.jsxs("div",{children:[e.jsx(G,{htmlFor:"email",children:"Email"}),e.jsx(Y,{id:"email",type:"email",value:l.email,onChange:i=>r("email",i.target.value),placeholder:"Enter your email",disabled:!0})]})}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"bio",children:"Bio"}),e.jsx(ks,{id:"bio",value:l.bio,onChange:i=>r("bio",i.target.value),placeholder:"Tell us about yourself...",rows:3})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"location",children:"Location"}),e.jsx(Y,{id:"location",value:l.location,onChange:i=>r("location",i.target.value),placeholder:"City, Country"})]}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"phone",children:"Phone"}),e.jsx(Y,{id:"phone",value:l.phone,onChange:i=>r("phone",i.target.value),placeholder:"Your phone number"})]})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(G,{className:"text-base font-medium",children:"Professional Role"}),e.jsx("p",{className:"text-sm text-gray-600 mb-3",children:"Select up to 2 professional roles that align with your interests"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:D.map(i=>e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(ge,{id:i.id,checked:l.careerPaths.includes(i.id),onCheckedChange:c=>o(i.id,c===!0),disabled:!l.careerPaths.includes(i.id)&&l.careerPaths.length>=2}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:i.id,className:`cursor-pointer block font-medium text-sm ${!l.careerPaths.includes(i.id)&&l.careerPaths.length>=2?"text-gray-400":"text-gray-900"}`,children:i.name}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:i.description})]})]},i.id))}),l.careerPaths.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Selected Professional Roles:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:x(l.careerPaths).map((i,c)=>e.jsx(O,{variant:"secondary",children:i},c))})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(G,{className:"text-base font-medium",children:"Links & Portfolio"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"portfolio",children:"Portfolio URL"}),e.jsx(Y,{id:"portfolio",value:l.portfolio,onChange:i=>r("portfolio",i.target.value),placeholder:"https://your-portfolio.com"})]}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"github",children:"GitHub URL"}),e.jsx(Y,{id:"github",value:l.github,onChange:i=>r("github",i.target.value),placeholder:"https://github.com/username"})]}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"linkedin",children:"LinkedIn URL"}),e.jsx(Y,{id:"linkedin",value:l.linkedin,onChange:i=>r("linkedin",i.target.value),placeholder:"https://linkedin.com/in/username"})]})]})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Cancel"}),e.jsx(V,{type:"submit",children:"Save Changes"})]})]})]})})},Zt=()=>{const{user:t}=je(),[s,a]=P.useState(!1),[n,l]=P.useState(null);return{createOrUpdateProfile:async o=>{var d,x,i;try{a(!0),l(null);const{data:{user:c}}=await I.auth.getUser();if(!c)throw new Error("User not authenticated");const{data:m,error:S}=await I.from("xterns_profiles").select("id").eq("user_id",c.id).maybeSingle();if(S&&S.code!=="PGRST116")throw S;const j=Array.isArray(o.preferred_roles)?Array.from(new Set(o.preferred_roles)).slice(0,2):[],w=((t==null?void 0:t.email)||c.email||o.email||"").toLowerCase();if(!w)throw new Error("Unable to resolve your account email");const E=(o.first_name||((d=o.full_name)==null?void 0:d.split(/\s+/)[0])||"").trim(),T=(o.last_name||((x=o.full_name)==null?void 0:x.split(/\s+/).slice(1).join(" "))||"").trim(),k=(o.full_name||[E,T].filter(
16Boolean).join(" ")).trim(),C={user_id:c.id,first_name:E||null,last_name:T||null,full_name:k,email:w,bio:o.bio||null,location:o.location||null,country:o.country||o.location||null,phone:o.phone||null,portfolio_url:o.portfolio_url||null,github_url:o.github_url||null,linkedin_url:o.linkedin_url||null,skills:o.skills||[],role:o.role||null,availability_status:o.availability_status||"available",preferred_roles:j,avatar_url:o.avatar_url||null,updated_at:new Date().toISOString()};o.skill_proficiencies!==void 0&&(C.skill_proficiencies=o.skill_proficiencies);let f;if(m){const{data:b,error:v}=await I.from("xterns_profiles").update(C).eq("user_id",c.id).select().single();if(v)throw v;f=b}else{const{data:b,error:v}=await I.from("xterns_profiles").insert(C).select().single();if(v)throw v;f=b}await I.from("profiles").update({full_name:k,updated_at:new Date().toISOString()}).eq("id",c.id);try{await Ss(c.id,f)}catch(b){console.error("Failed to sync profile snapshot to Signal Score:",b)}q.success("Profile updated successfully!",{description:"Your profile information has been saved.",duration:3e3});try{const{error:b}=await I.functions.invoke("link-dareyscore-identity",{body:{user_id:c.id,force_refresh:!0}});b&&console.error("Failed to refresh Signal Score identity link:",b)}catch(b){console.error("Failed to refresh Signal Score identity link:",b)}if(!!(k&&w&&(o.bio||o.location||o.phone)&&o.skills&&o.skills.length>0))try{const b={event_id:crypto.randomUUID(),occurred_at:new Date().toISOString(),platform:"xterns",platform_user_id:c.id,email:w,event_type:"profile_completed",payload:{profile_fields_completed:Object.keys(C).filter(v=>C[v]),skills_count:((i=o.skills)==null?void 0:i.length)||0},rules_version:"xterns_v1.0"};await I.functions.invoke("send-dareyscore-event",{body:{events:[b]}}),console.log("✅ Profile completion tracked to Signal Score")}catch(b){console.error("Failed to track profile completion:",b)}return f}catch(c){console.error("Error saving profile:",c);const m=c instanceof Error?c.message:"Failed to save profile";throw l(m),q.error("Failed to update profile",{description:m,duration:5e3}),c}finally{a(!1)}},getProfile:async()=>{try{a(!0),l(null);const{data:{user:o}}=await I.auth.getUser();if(!o)throw new Error("User not authenticated");const{data:d,error:x}=await I.from("xterns_profiles").select("*").eq("user_id",o.id).maybeSingle();if(x)throw x;return d}catch(o){console.error("Error fetching profile:",o);const d=o instanceof Error?o.message:"Failed to fetch profile";throw l(d),o}finally{a(!1)}},isLoading:s,error:n}},Jt=({isOpen:t,onClose:s,currentProfile:a,onUpdate:n})=>{const{user:l}=je(),u=Be(),[r,o]=P.useState([]),[d,x]=P.useState([]),[i,c]=P.useState([]),[m,S]=P.useState(!1),[j,w]=P.useState([]),[E,T]=P.useState([]),[k,C]=P.useState(!1);P.useEffect(()=>{if(t&&a){const g=new Set(D.map(h=>h.id)),A=Array.isArray(a.careerPaths)?Array.from(new Set(a.careerPaths)).filter(h=>g.has(h)).slice(0,2):[];o(A);const p=(a.skills||[]).map(h=>({name:typeof h=="string"?h:h.name,proficiency:typeof h=="string"?0:h.proficiency||0}));x(p),c(p.map(h=>h.name))}},[t,a]);const f=(g,A)=>{const N=new Set(D.map(h=>h.id)),p=Array.from(new Set(r.filter(h=>N.has(h))));A?!p.includes(g)&&p.length<2&&o([...p,g]):(o(p.filter(h=>h!==g)),x([]),c([]))},y=async()=>{if(r.length===0){q.error("Please select at least one career path first");return}S(!0);try{const{data:g,error:A}=await I.functions.invoke("generate-assessment-tech-stacks",{body:{careerPaths:r}});if(A)throw A;if(g!=null&&g.techStacks&&Array.isArray(g.techStacks)){const N=g.techStacks.map(h=>({name:typeof h=="string"?h:h.name,proficiency:0})),p=[...d];N.forEach(h=>{p.findIndex(_=>_.name===h.name)===-1&&p.push(h)}),x(p),q.success(`Generated ${N.length} tech stacks based on your career paths`)}}catch(g){console.error("Error generating tech stacks:",g),q.error("Failed to generate tech stacks. Please try again.")}finally{S(!1)}},b=(g,A)=>{c(A?N=>[...N,g]:N=>N.filter(p=>p!==g))},v=(g,A)=>{x(N=>N.map(p=>p.name===g?{...p,targetProficiency:A}:p))},L=()=>{const g=a.skills||[],A=new Map(g.map(h=>[typeof h=="string"?h:h.name,typeof h=="string"?0:h.proficiency||0])),N=[],p=[];
16return i.forEach(h=>{var F;const M=Number(A.get(h)||0),_=Number(((F=d.find(B=>B.name===h))==null?void 0:F.targetProficiency)||0);M===0?N.push(h):_>M&&_>0&&p.push(h)}),w(N),T(p),{newStacks:N,upgradeStacks:p}},U=async()=>{const{newStacks:g,upgradeStacks:A}=L(),N=[...g,...A];if(N.length===0){q.info("No tech stacks require assessment");return}const p=N.map(h=>{var B,z;const M=d.find(H=>H.name===h),_=Number(((z=(B=a==null?void 0:a.tech_stacks)==null?void 0:B.find(H=>H.name===h))==null?void 0:z.proficiency)||0),F=Number((M==null?void 0:M.targetProficiency)||3);return{name:h,proficiency:Math.max(_,F)}});C(!0);try{const{data:h,error:M}=await I.from("xtern_assessments").insert({user_id:l==null?void 0:l.id,assessment_type:"skill_update",stage_1_completed:!0,stage_2_completed:!0,stage_3_completed:!0,assessment_completed:!1,tech_assessment_passed:!1}).select().single();if(M)throw M;const _=i.map(H=>{const K=d.find(ne=>ne.name===H);return K?{name:K.name,proficiency:K.proficiency,targetProficiency:K.targetProficiency||K.proficiency||3}:null}).filter(Boolean),{error:F}=await I.from("xtern_assessment_skills").insert({assessment_id:h.id,selected_career_paths:r,skill_proficiencies:_});if(F)throw F;const{data:B,error:z}=await I.from("xtern_tech_assessments").insert({user_id:l==null?void 0:l.id,assessment_id:h.id,assessment_type:"skill_update",selected_tech_stacks:p,status:"pending",current_attempt:0,max_attempts:999}).select().single();if(z)throw z;q.success("Assessment created successfully!"),s(),u(`/xtern/tech-assessment/${B.id}`)}catch(h){console.error("Error creating skill update assessment:",h),q.error("Failed to create assessment. Please try again.")}finally{C(!1)}},$=async()=>{const{newStacks:g,upgradeStacks:A}=L();if(g.length>0||A.length>0){U();return}try{const N=i.map(h=>{const M=d.find(_=>_.name===h);return M?{name:M.name,proficiency:M.targetProficiency||M.proficiency||0}:{name:h,proficiency:0}}),{error:p}=await I.from("xterns_profiles").update({skills:N,preferred_roles:r,updated_at:new Date().toISOString()}).eq("user_id",l==null?void 0:l.id);if(p)throw p;q.success("Skills updated successfully!"),n(),s()}catch(N){console.error("Error updating skills:",N),q.error("Failed to update skills. Please try again.")}};return P.useEffect(()=>{L()},[i,d]),e.jsx(Oe,{open:t,onOpenChange:s,children:e.jsxs(Re,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ge,{children:[e.jsx($e,{children:"Update Tech Stacks & Skills"}),e.jsx(hs,{children:"Select your career paths and tech stacks. New stacks will require assessment."})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(X,{children:[e.jsx(Z,{children:e.jsx(J,{className:"text-lg",children:"Career Path Selection"})}),e.jsxs(Q,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:D.map(g=>e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(ge,{id:g.id,checked:r.includes(g.id),onCheckedChange:A=>f(g.id,A===!0),disabled:!r.includes(g.id)&&r.length>=2}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:g.id,className:`cursor-pointer block font-medium ${!r.includes(g.id)&&r.length>=2?"text-muted-foreground":"text-foreground"}`,children:g.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:g.description})]})]},g.id))}),r.length>0&&e.jsx("div",{className:"mt-4 flex gap-2",children:e.jsxs(V,{onClick:y,disabled:m,children:[e.jsx(Es,{className:"w-4 h-4 mr-2"}),m?"Generating...":"Generate Tech Stacks"]})})]})]}),d.length>0&&e.jsxs(X,{children:[e.jsx(Z,{children:e.jsx(J,{className:"text-lg",children:"Tech Stack Selection"})}),e.jsx(Q,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:d.map(g=>{const A=i.includes(g.name),N=j.includes(g.name),p=E.includes(g.name),h=g.proficiency>0,M=g.targetProficiency||g.proficiency||0;return e.jsx("div",{className:`p-3 border rounded-lg ${A?N?"bg-blue-50 border-blue-200":p?"bg-orange-50 border-orange-200":"bg-green-50 border-green-200":"bg-gray-50 border-gray-200"}`,children:e.jsxs("div",{className:"flex space-x-3",children:[e.jsx(ge,{id:`tech-${g.name}`,checked:A,onCheckedChange:_=>b(g.name,_)}),e.jsxs("div",{className:"",children:[e.jsx("label",{htmlFor:`tech-${g.name}`,className:"cursor-pointer font-medium text-sm",children:g.name}),e.jsxs("div",{className:"flex flex-col gap-2 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:"Current:"}),Array.from({length:5},(_,F)=>e.jsx(ye,{className:`w-3 h-3 ${F<g.proficiency?"fill-yellow-400 text-yellow-400":"text-gray-300"}`},F))]}),A&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:"Target:"}),Array.from({length:5},(_,F)=>e.jsx(ye,{className:`w-3 h-3 cursor-pointer ${F<M?"fill-blue-400 text-blue-400":"text-gray-300 hover:text-blue-300"}`,onClick:()=>v(g.name,F+1)},`target-${F}`))]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[N&&e.jsx(O,{variant:"outline",className:"text-xs bg-blue-100 text-blue-800",children:"New - Assessment Required"}),p&&e.jsx(O,{variant:"outline",className:"text-xs bg-orange-100 text-orange-800",children:"Upgrade - Assessment Required"}),h&&!N&&!p&&e.jsx(O,{variant:"secondary",className:"text-xs bg-green-100 text-green-800",children:"No Change"})]})]})]})},g.name)}
16)})})]}),(j.length>0||E.length>0)&&e.jsxs(As,{children:[e.jsx(De,{className:"h-4 w-4"}),e.jsxs(Ps,{children:[e.jsx("strong",{children:"Assessment Required:"}),j.length>0&&e.jsxs("span",{children:[" You have ",j.length," new tech stack(s) (",j.join(", "),") that require assessment."]}),E.length>0&&e.jsxs("span",{children:[" You want to upgrade ",E.length," existing skill(s) (",E.join(", "),") which require assessment."]}),e.jsx("br",{}),"Don't worry - you can take the assessment as many times as needed, and if you don't pass, your current skills will remain unchanged."]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx(V,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(V,{onClick:$,disabled:k||i.length===0,children:[k&&e.jsx(Ms,{className:"w-4 h-4 mr-2 animate-spin"}),j.length>0||E.length>0?"Take Assessment":"Update Skills"]})]})]})]})})};function er(t){var T,k,C,f;const s=new Date,a=ce(s,365),n=new Date(s.getFullYear(),s.getMonth(),1);let l=0,u=0,r=0,o=0,d=0;const x=new Set,i=new Map,c=new Set;for(const y of t){if((y.actor_github_username||"").endsWith("[bot]"))continue;const b=new Date(y.created_at),v=ae(b,"yyyy-MM-dd");if(x.add(y.repo_full_name),y.event_type==="push"){if(!((T=y.event_data)!=null&&T.is_merge_push)){const L=((k=y.event_data)==null?void 0:k.commits_count)||1;l+=L,b>=n&&(u+=L),b>=a&&i.set(v,(i.get(v)||0)+L),c.add(v)}}else if(y.event_type==="pull_request"){const L=(C=y.event_data)==null?void 0:C.action;L==="closed"&&((f=y.event_data)!=null&&f.merged)?(o++,c.add(v)):L==="opened"&&(r++,c.add(v)),b>=a&&i.set(v,(i.get(v)||0)+1)}else y.event_type==="pull_request_review"&&(d++,c.add(v),b>=a&&i.set(v,(i.get(v)||0)+1))}let m=0;const S=Fs(s);for(let y=0;y<365;y++){const b=ae(ce(S,y),"yyyy-MM-dd");if(c.has(b))m++;else if(y>0)break}const j=[];for(let y=364;y>=0;y--){const b=ae(ce(S,y),"yyyy-MM-dd");j.push({date:b,count:i.get(b)||0})}const E=[...t].sort((y,b)=>new Date(b.created_at).getTime()-new Date(y.created_at).getTime()).slice(0,20).map(y=>{var v,L;let b="";if(y.event_type==="push"){const U=((v=y.event_data)==null?void 0:v.commits_count)||1;b=`Pushed ${U} commit${U>1?"s":""} to ${y.repo_full_name}`}else y.event_type==="pull_request"?b=`${(L=y.event_data)!=null&&L.merged?"Merged":"Opened"} a pull request in ${y.repo_full_name}`:y.event_type==="pull_request_review"&&(b=`Reviewed a pull request in ${y.repo_full_name}`);return{id:y.id,type:y.event_type,repo:y.repo_full_name,timestamp:y.created_at,summary:b}});return{totalCommits:l,commitsThisMonth:u,streakDays:m,pullRequests:r,pullRequestsMerged:o,codeReviews:d,contributedRepos:x.size,contributionsByDay:j,recentActivity:E}}function Se(t){return ve({queryKey:["user-github-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:a}=await I.from("github_events").select("id, event_type, event_data, repo_full_name, created_at").eq("actor_user_id",t).order("created_at",{ascending:!1});if(a)throw a;return er(s||[])},enabled:!!t})}const Ie=["bg-muted","bg-green-200","bg-green-400","bg-green-600","bg-green-800"];function sr(t,s){if(t===0)return 0;if(s<=0)return 1;const a=t/s;return a<=.25?1:a<=.5?2:a<=.75?3:4}const tr=({userId:t})=>{const{data:s,isLoading:a}=Se(t),{weeks:n,max:l}=P.useMemo(()=>{const u=(s==null?void 0:s.contributionsByDay)||[],r=Math.max(...u.map(x=>x.count),1),o=[];let d=[];for(const x of u)Is(de(x.date))===0&&d.length>0&&(o.push(d),d=[]),d.push(x);return d.length>0&&o.push(d),{weeks:o,max:r}},[s==null?void 0:s.contributionsByDay]);return a?e.jsxs(X,{children:[e.jsx(Z,{children:e.jsx(J,{className:"text-base",children:"Contribution Activity"})}),e.jsx(Q,{children:e.jsx("div",{className:"h-[120px] flex items-center justify-center text-sm text-muted-foreground",children:"Loading…"})})]}):!s||s.totalCommits===0?e.jsxs(X,{children:[e.jsx(Z,{children:e.jsx(J,{className:"text-base",children:"Contribution Activity"})}),e.jsx(Q,{children:e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No contribution data yet. Connect GitHub and start coding!"})})]}):e.jsxs(X,{children:[e.jsx(Z,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(J,{className:"text-base",children:"Contribution Activity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.totalCommits," total contributions"]})]})}),e.jsx(Q,{children:e.jsxs(ze,{delayDuration:100,children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsx("div",{className:"flex gap-[3px]",children:n.map((u,r)=>e.jsx("div",{className:"flex flex-col gap-[3px]",children:u.map(o=>e.jsxs(He,{children:[e.jsx(Ke,{asChild:!0,children:e.jsx("div",{className:`w-[11px] h-[11px] rounded-[2px] ${Ie[sr(o.count,l)]}`})}),e.jsxs(Ye,{side:"top",className:"text-xs",children:[e.jsxs("span",{className:"font-medium",children:[o.count," contribution",o.count!==1?"s":""]})," on ",ae(de(o.date),"MMM d, yyyy")]})]},o.date))},r))})}),e.jsxs("div",{className:"flex items-center gap-1 mt-3 text-xs text-muted-foreground justify-end",children:[e.jsx("span",{children:"Less"}),Ie.map((u,r)=>e.jsx("div",{className:`w-[11px] h-[11px] rounded-[2px] ${u}`},r)),e.jsx("span",{children:"More"})]})]})})]})};function oe({icon:t,label:s,value:a,hint:n,index:l,accent:u}){return e.jsxs(R.div,{initial:{opacity:0,y:8}
16,animate:{opacity:1,y:0},transition:{duration:.3,delay:l*.05,ease:"easeOut"},className:"rounded-2xl border border-gray-200 bg-white p-4 shadow-[0_1px_2px_rgba(17,24,39,0.04)] transition-all hover:-translate-y-0.5 hover:shadow-[0_10px_24px_rgba(17,24,39,0.08)]",children:[e.jsx("div",{className:`inline-flex h-8 w-8 items-center justify-center rounded-xl ${u}`,children:t}),e.jsx("p",{className:"mt-3 text-[11px] font-medium uppercase tracking-wide text-gray-500",children:s}),e.jsx("p",{className:"mt-0.5 font-['DM_Serif_Display'] text-2xl leading-none text-xterns-navy",children:a}),n&&e.jsx("p",{className:"mt-1 text-[11px] text-gray-400",children:n})]})}function rr({userId:t}){const{data:s}=Se(t),a=(s==null?void 0:s.streakDays)??0,n=(s==null?void 0:s.commitsThisMonth)??0,l=(s==null?void 0:s.pullRequests)??0,u=(s==null?void 0:s.codeReviews)??0;return e.jsxs("section",{className:"rounded-[18px] border border-gray-200 bg-white p-5 shadow-[0_1px_2px_rgba(17,24,39,0.04)]",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Contributions"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Your open source and project activity"})]}),s&&e.jsxs("span",{className:"text-xs text-gray-500",children:[s.totalCommits," total contributions"]})]}),e.jsxs("div",{className:"mb-5 grid grid-cols-2 gap-3 md:grid-cols-4",children:[e.jsx(oe,{index:0,icon:e.jsx(kt,{className:"h-4 w-4 text-xterns-gold"}),accent:"bg-xterns-gold/15",label:"Current streak",value:`${a}d`,hint:"Days in a row"}),e.jsx(oe,{index:1,icon:e.jsx(Ne,{className:"h-4 w-4 text-xterns-blue"}),accent:"bg-xterns-blue/10",label:"Monthly commits",value:n,hint:"This month"}),e.jsx(oe,{index:2,icon:e.jsx(Ze,{className:"h-4 w-4 text-xterns-teal"}),accent:"bg-xterns-teal/10",label:"Pull requests",value:l,hint:"Opened"}),e.jsx(oe,{index:3,icon:e.jsx(Je,{className:"h-4 w-4 text-xterns-navy"}),accent:"bg-xterns-navy/10",label:"Code reviews",value:u,hint:"Delivered"})]}),e.jsx("div",{className:"[&_.card]:border-0 [&_.card]:shadow-none [&_.card]:bg-transparent [&_.card>div:first-child]:hidden [&_.card>div:last-child]:p-0",children:e.jsx(tr,{userId:t})})]})}const ar={push:{icon:e.jsx(Ne,{className:"h-4 w-4"}),label:"Commit",accent:"bg-xterns-green/15 text-xterns-green",ring:"ring-xterns-green/30"},pull_request:{icon:e.jsx(Ze,{className:"h-4 w-4"}),label:"Pull request",accent:"bg-xterns-blue/10 text-xterns-blue",ring:"ring-xterns-blue/30"},pull_request_review:{icon:e.jsx(mt,{className:"h-4 w-4"}),label:"Review",accent:"bg-xterns-teal/10 text-xterns-teal",ring:"ring-xterns-teal/30"},issues:{icon:e.jsx(dt,{className:"h-4 w-4"}),label:"Issue",accent:"bg-xterns-gold/15 text-xterns-navy",ring:"ring-xterns-gold/30"},assessment:{icon:e.jsx(ct,{className:"h-4 w-4"}),label:"Assessment",accent:"bg-xterns-navy/10 text-xterns-navy",ring:"ring-xterns-navy/30"},course:{icon:e.jsx(ot,{className:"h-4 w-4"}),label:"Course",accent:"bg-xterns-teal/10 text-xterns-teal",ring:"ring-xterns-teal/30"}},Ve=[{key:"today",label:"Today",days:1},{key:"week",label:"Week",days:7},{key:"month",label:"Month",days:30},{key:"all",label:"All",days:365*5}];function nr({userId:t}){const{data:s,isLoading:a}=Se(t),[n,l]=P.useState("all"),[u,r]=P.useState(!1),o=(s==null?void 0:s.recentActivity)||[],d=P.useMemo(()=>{const i=Ve.find(m=>m.key===n),c=ce(new Date,i.days);return o.filter(m=>xt(de(m.timestamp),c))},[o,n]),x=u?d:d.slice(0,12);return e.jsxs("section",{className:"flex max-h-[620px] flex-col rounded-[18px] border border-gray-200 bg-white p-5 shadow-[0_1px_2px_rgba(17,24,39,0.04)]",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-xterns-blue/10 text-xterns-blue",children:e.jsx(Ae,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Recent activity"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Your latest work across GitHub and Xterns"})]})]}),e.jsx("div",{className:"flex items-center gap-1 rounded-full border border-gray-200 bg-gray-50 p-1",children:Ve.map(i=>e.jsx("button",{onClick:()=>{l(i.key),r(!1)},className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${n===i.key?"bg-white text-xterns-navy shadow-sm":"text-gray-500 hover:text-gray-800"}`,children:i.label},i.key))})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-2",children:a?e.jsx("div",{className:"space-y-3",children:Array.from({length:4}).map((i,c)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-9 w-9 shrink-0 animate-pulse rounded-xl bg-gray-100"}),e.jsxs("div",{className:"flex-1 space-y-2 py-1",children:[e.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-gray-100"}),e.jsx("div",{className:"h-2.5 w-1/3 animate-pulse rounded bg-gray-100"})]})]},c))}):d.length===0?e.jsx(it,{icon:e.jsx(Ae,{className:"h-5 w-5"}),title:"No activity in this window",description:"Try a wider time range or connect GitHub to start populating your timeline."}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute bottom-2 left-[18px] top-2 w-px bg-gray-100","aria-hidden":!0}),e.jsx("ul",{className:"space-y-4",children:e.jsx(lt,{initial:!1,children:x.map((i,c)=>{const m=ar[i.type]||{icon:e.jsx(Ne,{className:"h-4 w-4"}),label:"Activity",accent:"bg-gray-100 text-gray-600"};return e.jsxs(R.li,{initial:{opacity:0,x:-6}
16,animate:{opacity:1,x:0},exit:{opacity:0},transition:{duration:.25,delay:c*.025},className:"relative flex items-start gap-3",children:[e.jsx("div",{className:`relative z-10 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl ring-4 ring-white ${m.accent}`,children:m.icon}),e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-500",children:m.label}),i.repo&&e.jsx("span",{className:"rounded-md bg-gray-100 px-1.5 py-0.5 font-mono text-[10px] text-gray-600",children:i.repo})]}),e.jsx("p",{className:"mt-0.5 truncate text-sm text-gray-800",children:i.summary}),e.jsx("p",{className:"text-[11px] text-gray-400",children:ut(de(i.timestamp),{addSuffix:!0})})]})]},i.id)})})}),d.length>x.length&&e.jsxs(V,{variant:"ghost",size:"sm",className:"mt-4 w-full rounded-lg text-xterns-blue hover:bg-xterns-blue/10",onClick:()=>r(!0),children:["View all ",d.length," activities"]})]})})]})}const ir=({userId:t,showLabel:s=!1})=>{const{data:a}=ve({queryKey:["github-identity-badge",t],queryFn:async()=>{const{data:n,error:l}=await I.from("github_identities").select("github_username").eq("user_id",t).maybeSingle();return l?null:n},enabled:!!t,staleTime:3e5});return a?e.jsx(ze,{children:e.jsxs(He,{children:[e.jsx(Ke,{asChild:!0,children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-green-700 bg-green-50 border border-green-200 rounded-full px-2 py-0.5",children:[e.jsx(ee,{className:"h-3 w-3"}),e.jsx(ps,{className:"h-3 w-3"}),s&&e.jsx("span",{children:"Verified"})]})}),e.jsx(Ye,{children:e.jsxs("p",{children:["GitHub connected: @",a.github_username]})})]})}):null};function lr({value:t}){const s=ds(0),a=Tt(s,n=>ht(n));return fs.useEffect(()=>Xt(s,t,{duration:1.1,ease:"easeOut"}).stop,[t,s]),e.jsx(R.span,{children:a})}const or=[42,45,44,48,52,55,53,58,60,62,61,63];function cr({score:t,tier:s="Discoverable Talent",history:a,globalRank:n="—",trackRank:l="—",onViewAnalytics:u}){const r=a&&a.length>1?a.slice(-14).map((o,d)=>({i:d,v:o.score})):or.map((o,d)=>({i:d,v:o}));return e.jsxs(R.div,{initial:{opacity:0,y:10,scale:.98},animate:{opacity:1,y:0,scale:1},transition:{duration:.5,ease:"easeOut"},className:"relative overflow-hidden rounded-[20px] border border-white/60 bg-white/85 p-5 shadow-[0_20px_50px_-20px_rgba(13,27,42,0.35)] backdrop-blur-xl",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-xterns-blue/10 text-xterns-blue",children:e.jsx(We,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-gray-500",children:"Signal Score"}),e.jsx("p",{className:"text-[11px] text-gray-400",children:"Live"})]})]}),e.jsx(O,{className:"bg-xterns-teal/10 text-xterns-teal hover:bg-xterns-teal/15 border-0",children:s})]}),e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-['DM_Serif_Display'] text-5xl leading-none text-xterns-navy",children:e.jsx(lr,{value:t})}),e.jsxs("p",{className:"mt-1 flex items-center gap-1 text-xs text-xterns-teal",children:[e.jsx(Je,{className:"h-3 w-3"})," trending up"]})]}),e.jsx("div",{className:"h-14 w-28",children:e.jsx(pt,{width:"100%",height:"100%",children:e.jsxs(ft,{data:r,margin:{top:4,right:0,left:0,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"sparkFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--blue))",stopOpacity:.35}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--blue))",stopOpacity:0})]})}),e.jsx(gt,{type:"monotone",dataKey:"v",stroke:"hsl(var(--blue))",strokeWidth:2,fill:"url(#sparkFill)",isAnimationActive:!0})]})})})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded-xl bg-gray-50 p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-gray-500",children:"Global rank"}),e.jsxs("p",{className:"mt-0.5 flex items-center gap-1 text-sm font-semibold text-gray-900",children:[e.jsx(Ee,{className:"h-3.5 w-3.5 text-xterns-gold"})," #",n]})]}),e.jsxs("div",{className:"rounded-xl bg-gray-50 p-2.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-gray-500",children:"Track rank"}),e.jsxs("p",{className:"mt-0.5 flex items-center gap-1 text-sm font-semibold text-gray-900",children:[e.jsx(Ee,{className:"h-3.5 w-3.5 text-xterns-blue"})," #",l]})]})]}),e.jsxs(V,{onClick:u,variant:"outline",className:"mt-4 h-9 w-full rounded-xl border-gray-200 text-sm font-medium text-gray-700 hover:bg-gray-50",children:[e.jsx(wt,{className:"mr-2 h-4 w-4"})," View analytics"]})]})}function dr(t){const{userId:s,name:a,bio:n,location:l,email:u,githubUrl:r,linkedinUrl:o,portfolioUrl:d,careerPathNames:x,profilePicture:i,onImageUpdate:c,score:m,scoreHistory:S,onEdit:j,onShare:w,onPreviewPublic:E,onViewAnalytics:T}=t,k=[r&&{icon:ee,href:r,label:"GitHub"},o&&{icon:we,href:o,label:"LinkedIn"},d&&{icon:ke,href:d,label:"Portfolio"}
16].filter(Boolean);return e.jsxs(R.section,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.45,ease:"easeOut"},className:"relative overflow-hidden rounded-[20px] border border-gray-200 bg-white shadow-[0_1px_2px_rgba(17,24,39,0.04)]",children:[e.jsxs("div",{className:"pointer-events-none absolute inset-0",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-xterns-navy/[0.07] via-xterns-blue/[0.06] to-xterns-teal/[0.05]"}),e.jsx("div",{className:"absolute -right-16 -top-24 h-72 w-72 rounded-full bg-xterns-blue/15 blur-3xl"}),e.jsx("div",{className:"absolute -left-24 bottom-[-6rem] h-72 w-72 rounded-full bg-xterns-teal/10 blur-3xl"}),e.jsx("svg",{className:"absolute inset-x-0 bottom-0 h-24 w-full text-xterns-blue/10",viewBox:"0 0 1440 120",preserveAspectRatio:"none","aria-hidden":!0,children:e.jsx("path",{d:"M0,64 C240,120 480,0 720,48 C960,96 1200,32 1440,72 L1440,120 L0,120 Z",fill:"currentColor"})})]}),e.jsxs("div",{className:"relative grid gap-6 p-6 md:p-8 lg:grid-cols-[minmax(0,1fr)_320px]",children:[e.jsxs("div",{className:"flex flex-col gap-5 md:flex-row md:items-start",children:[e.jsx("div",{className:"relative",children:e.jsx(Ts,{currentImageUrl:i,onImageUpdate:c})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h1",{className:"font-['DM_Serif_Display'] text-3xl leading-tight text-xterns-navy md:text-4xl",children:a}),s&&e.jsx(ir,{userId:s,showLabel:!0})]}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:x.length>0?x.map(C=>e.jsx(O,{className:"border-0 bg-xterns-blue/10 text-xterns-blue hover:bg-xterns-blue/15",children:C},C)):e.jsx(O,{variant:"outline",className:"text-gray-500",children:"No career path selected"})}),n?e.jsx("p",{className:"mt-3 max-w-2xl text-sm leading-relaxed text-gray-600",children:n}):e.jsx("p",{className:"mt-3 text-sm italic text-gray-400",children:"No bio added yet. Click Edit Profile to add one."}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-gray-600",children:[l&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(as,{className:"h-3.5 w-3.5 text-gray-400"})," ",l]}),u&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(ns,{className:"h-3.5 w-3.5 text-gray-400"})," ",u]}),r&&e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 hover:text-xterns-blue",children:[e.jsx(ee,{className:"h-3.5 w-3.5 text-gray-400"}),r.replace(/^https?:\/\/(www\.)?github\.com\//,"@")]})]}),k.length>0&&e.jsx("div",{className:"mt-4 flex items-center gap-2",children:k.map(({icon:C,href:f,label:y})=>e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer","aria-label":y,className:"flex h-9 w-9 items-center justify-center rounded-xl border border-gray-200 bg-white text-gray-500 transition-all hover:-translate-y-0.5 hover:border-xterns-blue/40 hover:text-xterns-blue",children:e.jsx(C,{className:"h-4 w-4"})},y))}),e.jsx("div",{className:"mt-5 flex flex-wrap items-center gap-2",children:e.jsxs(V,{onClick:j,className:"h-9 rounded-xl bg-xterns-blue text-white hover:bg-xterns-blue/90",children:[e.jsx(is,{className:"mr-2 h-4 w-4"})," Edit profile"]})})]})]}),e.jsx("div",{className:"lg:pl-2",children:e.jsx(cr,{score:m,history:S,onViewAnalytics:T})})]})]})}const W=({icon:t,label:s,value:a,href:n})=>{const l=!!a,u=e.jsxs("div",{className:"flex items-start gap-3 rounded-xl px-2 py-2 transition-colors hover:bg-gray-50",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500",children:e.jsx(t,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-gray-500",children:s}),e.jsx("p",{className:`truncate text-sm ${l?"text-gray-900":"italic text-gray-400"}`,children:a||"Not added"})]})]});return n&&l?e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:u}):u};function mr(t){const{email:s,phone:a,location:n,timezone:l,linkedin:u,github:r,website:o,onEdit:d}=t;return e.jsxs(R.div,{initial:{opacity:0,y:8}
16,animate:{opacity:1,y:0},transition:{duration:.35,ease:"easeOut"},className:"rounded-[18px] border border-gray-200 bg-white p-5 shadow-[0_1px_2px_rgba(17,24,39,0.04)] transition-all hover:shadow-[0_10px_24px_rgba(17,24,39,0.06)]",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Contact information"}),e.jsxs(V,{variant:"ghost",size:"sm",onClick:d,className:"h-8 rounded-lg text-xs text-xterns-blue hover:bg-xterns-blue/10",children:[e.jsx(is,{className:"mr-1 h-3.5 w-3.5"})," Edit"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(W,{icon:ns,label:"Email",value:s,href:s?`mailto:${s}`:void 0}),e.jsx(W,{icon:yt,label:"Phone",value:a}),e.jsx(W,{icon:as,label:"Location",value:n}),e.jsx(W,{icon:gs,label:"Timezone",value:l}),e.jsx(W,{icon:we,label:"LinkedIn",value:u,href:u}),e.jsx(W,{icon:ee,label:"GitHub",value:r,href:r}),e.jsx(W,{icon:ke,label:"Website",value:o,href:o})]})]})}function xr({items:t,recommendations:s,estMinutes:a}){const n=t.filter(m=>m.done).length,l=t.length||1,u=Math.round(n/l*100),r=112,o=10,d=(r-o)/2,x=2*Math.PI*d,i=x-u/100*x,c=s&&s.length>0?s:t.filter(m=>!m.done).slice(0,3).map(m=>m.hint||`Complete ${m.label.toLowerCase()}`);return e.jsxs(R.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.35,ease:"easeOut"},className:"rounded-[18px] border border-gray-200 bg-white p-5 shadow-[0_1px_2px_rgba(17,24,39,0.04)] transition-all hover:shadow-[0_10px_24px_rgba(17,24,39,0.06)]",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Profile completion"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[n,"/",l," done"]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative",style:{width:r,height:r},children:[e.jsxs("svg",{width:r,height:r,className:"-rotate-90",children:[e.jsx("circle",{cx:r/2,cy:r/2,r:d,stroke:"hsl(var(--muted))",strokeWidth:o,fill:"transparent",opacity:.35}),e.jsx(R.circle,{cx:r/2,cy:r/2,r:d,stroke:"hsl(var(--blue))",strokeWidth:o,strokeLinecap:"round",fill:"transparent",strokeDasharray:x,initial:{strokeDashoffset:x},animate:{strokeDashoffset:i},transition:{duration:1.1,ease:"easeOut"}})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsxs("span",{className:"font-['DM_Serif_Display'] text-2xl text-xterns-navy",children:[u,"%"]}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-gray-500",children:"complete"})]})]}),e.jsx("ul",{className:"grid flex-1 grid-cols-1 gap-1.5",children:t.map(m=>e.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[m.done?e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-xterns-teal/15 text-xterns-teal",children:e.jsx(Xe,{className:"h-3 w-3"})}):e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full border border-dashed border-gray-300 text-gray-400",children:e.jsx(ys,{className:"h-2 w-2"})}),e.jsx("span",{className:m.done?"text-gray-700":"text-gray-500",children:m.label})]},m.key))})]}),c.length>0&&e.jsxs("div",{className:"mt-5 rounded-xl border border-xterns-blue/15 bg-xterns-blue/[0.04] p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-xs font-semibold text-xterns-blue",children:[e.jsx(We,{className:"h-3.5 w-3.5"})," Recommendations"]}),e.jsx("ul",{className:"space-y-1 text-xs text-gray-700",children:c.map(m=>e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:"mt-1 h-1 w-1 shrink-0 rounded-full bg-xterns-blue"}),m]},m))}),a!==void 0&&e.jsxs("p",{className:"mt-2 text-[11px] text-gray-500",children:["Estimated time remaining: ~",a," minutes"]})]})]})}const ur={idle:"",uploading:"Uploading CV...",extracting:"Extracting text...",analyzing:"Analyzing experience...",complete:"CV synced successfully!",error:"Something went wrong"},hr={idle:0,uploading:20,extracting:50,analyzing:80,complete:100,error:0},pr=({userId:t,onSyncComplete:s})=>{const[a,n]=P.useState("idle"),l=P.useRef(null),{toast:u}=bs(),r=js(),{data:o,refetch:d}=ve({queryKey:["current-cv",t],queryFn:async()=>{const{data:c,error:m}=await I.from("cv_files").select("id, filename, uploaded_at").eq("user_id",t).order("uploaded_at",{ascending:!1}).limit(1).maybeSingle();if(m)throw m;return c},enabled:!!t}),x=async c=>{var S,j;const m=(S=c.target.files)==null?void 0:S[0];if(m){if(m.type!=="application/pdf"){u({title:"Invalid file type",description:"Please upload a PDF file.",variant:"destructive"});return}if(m.size>10*1024*1024){u({title:"File too large",description:"Maximum file size is 10MB.",variant:"destructive"});return}try{n("uploading");const w=Date.now(),E=`${t}/${t}_${w}_${m.name}`,{error:T}=await I.storage.from("cv-files").upload(E,m,{contentType:m.type,upsert:!1});if(T)throw T;const{data:k,error:C}=await I.from("cv_files").insert({user_id:t,filename:m.name,file_path:E,content_type:m.type,file_size:m.size}).select("id").single();if(C)throw C;n("extracting");const{error:f}=await I.functions.invoke("extract-cv-text",{body:{cvFileId:k.id}});if(f)throw f;n("analyzing");const{data:y}=await I.from("cv_files").select("extracted_text").eq("id",k.id).single();if(y!=null&&y.extracted_text){const{data:b,error:v}=await I.functions.invoke("parse-work-experience",{body:{extractedText:y.extracted_text,cvFileId:k.id}});if(v)throw v;if(((j=b==null?void 0:b.workExperiences)==null?void 0:j.length)>0){const{data:L}=await I.from("xtern_assessments").select("id").eq("user_id",t).order("created_at",{ascending:!1}).limit(1).maybeSingle();L&&await I.from("xtern_assessment_experience").upsert({assessment_id:L.id,cv_file_id:k.id,work_experiences:b.workExperiences},{onConflict:"assessment_id"})}}n("complete"),await d(),r.invalidateQueries({queryKey:["xtern-cv-data"]}),s==null||s(),u({title:"CV updated!",description:"Your CV has been uploaded and synced with your dynamic profile."}),setTimeout(()=>n("idle"),3e3)}catch(w){console.error("CV upload error:",w),n("error"),u({title:"Upload failed",description:w.message||"Please try again.",variant:"destructive"}),setTimeout(()=>n("idle"),3e3)}finally{l.current&&(l.current.value="")}}},i=!["idle","complete","error"].includes(a);return e.jsxs(X,{children:[e.jsx(Z,{children:e.jsx(J,{className:"text-base",children:"CV Management"})}),e.jsxs(Q,{className:"space-y-4",children:[o&&e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-muted/50",children:[e.jsx(Qe,{className:"h-5 w-5 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.filename}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Uploaded ",ae(new Date(o.uploaded_at),"MMM d, yyyy")]})]})]}),a!=="idle"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[a==="complete"?e.jsx(Xe,{className:"h-4 w-4 text-green-600"}):a==="error"?e.jsx(De,{className:"h-4 w-4 text-destructive"}):e.jsx(bt,{className:"h-4 w-4 animate-spin text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:ur[a]})]}),e.jsx(vs,{value:hr[a],className:"h-2"})]}),e.jsx("input",{ref:l,type:"file",accept:".pdf",className:"hidden",onChange:x,disabled:i}),e.jsxs(V,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{var c;return(c=l.current)==null?void 0:c.click()},disabled:i,children:[e.jsx(jt,{className:"h-4 w-4 mr-2"}),o?"Upload New CV":"Upload CV"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"PDF only, max 10MB. This will replace your current CV."})]})]})};function fr({userId:t,onSyncComplete:s}){return e.jsxs(R.div,{initial:{opacity:0,y:8}
16,animate:{opacity:1,y:0},transition:{duration:.35,ease:"easeOut"},className:"rounded-[18px] border border-gray-200 bg-white p-5 shadow-[0_1px_2px_rgba(17,24,39,0.04)] transition-all hover:shadow-[0_10px_24px_rgba(17,24,39,0.06)]",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-xterns-teal/10 text-xterns-teal",children:e.jsx(Qe,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Resume"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Upload and manage your CV"})]})]}),e.jsx("div",{className:"[&_.card]:border-0 [&_.card]:shadow-none [&_.card]:p-0",children:e.jsx(pr,{userId:t,onSyncComplete:s})})]})}function gr({skill:t,index:s=0}){const{name:a,proficiency:n}=t,l=n>0,u=n>=5,r=l&&!u,o=Math.max(0,Math.min(100,n/5*100)),d=n*87;return e.jsxs(R.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3,delay:s*.04,ease:"easeOut"},whileHover:{y:-2},className:"group relative overflow-hidden rounded-2xl border border-gray-200 bg-white p-4 shadow-[0_1px_2px_rgba(17,24,39,0.04)] transition-shadow duration-200 hover:shadow-[0_12px_24px_rgba(17,24,39,0.08)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-xterns-blue/10 text-xterns-blue",children:e.jsx(vt,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:a}),l&&e.jsx(ls,{className:"h-3.5 w-3.5 shrink-0 text-xterns-teal"})]}),e.jsxs("p",{className:"text-[11px] text-gray-500",children:["Level ",n," of 5 · +",d," XP"]})]})]}),e.jsx("div",{className:"flex items-center gap-0.5",children:Array.from({length:5},(x,i)=>e.jsx(ye,{className:Ns("h-3 w-3",i<n?"fill-xterns-gold text-xterns-gold":"text-gray-300")},i))})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-gray-100",children:e.jsx(R.div,{initial:{width:0},animate:{width:`${o}%`},transition:{duration:.9,delay:.1+s*.03,ease:"easeOut"},className:"h-full rounded-full bg-gradient-to-r from-xterns-blue to-xterns-teal"})}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[l?e.jsx(O,{className:"border-0 bg-xterns-teal/10 text-xterns-teal hover:bg-xterns-teal/15",children:"Assessed"}):e.jsx(O,{variant:"outline",className:"text-gray-500",children:"Not assessed"}),r&&e.jsxs(O,{className:"border-0 bg-xterns-blue/10 text-xterns-blue hover:bg-xterns-blue/15",children:[e.jsx(os,{className:"mr-0.5 h-3 w-3"})," Upgradeable"]}),u&&e.jsx(O,{className:"border-0 bg-xterns-gold/15 text-xterns-navy hover:bg-xterns-gold/20",children:"Max level"})]})]})]})}const yr=["react","vue","angular","svelte","next","html","css","tailwind","typescript","javascript"],br=["node","express","django","flask","rails","spring","go","java","python","php","laravel",".net","sql","postgres","mysql","mongodb","graphql"],jr=["docker","kubernetes","aws","gcp","azure","terraform","ci","cd","linux","jenkins","github actions"],vr=["ai","ml","tensorflow","pytorch","llm","openai","langchain","nlp","data"],Nr=["communication","leadership","agile","scrum","product","management","design"],wr=t=>{const s=t.toLowerCase();return yr.some(a=>s.includes(a))?"Frontend":br.some(a=>s.includes(a))?"Backend":jr.some(a=>s.includes(a))?"DevOps":vr.some(a=>s.includes(a))?"AI":Nr.some(a=>s.includes(a))?"Professional":"Other"},kr=["All","Frontend","Backend","DevOps","AI","Professional"];function _r({skills:t,hasUpgradeable:s,onUpgrade:a,onAdd:n}){const[l,u]=P.useState("All"),r=P.useMemo(()=>(t||[]).map(x=>{const i=typeof x=="string",c=i?x:x.name,m=i?0:Number(x.proficiency||0);return{name:c,proficiency:m,category:wr(c)}}),[t]),o=P.useMemo(()=>{const x={All:r.length};for(const i of r)x[i.category]=(x[i.category]||0)+1;return x},[r]),d=l==="All"?r:r.filter(x=>x.category===l);return e.jsxs("section",{id:"tech-stacks-section",className:"rounded-[18px] border border-gray-200 bg-white p-5 shadow-[0_1px_2px_rgba(17,24,39,0.04)]",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Skills"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Your assessed tech stacks and proficiencies"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsxs(V,{variant:"outline",size:"sm",className:"rounded-lg",onClick:n,children:[e.jsx(xe,{className:"mr-1 h-4 w-4"})," Add"]}),s&&a&&e.jsxs(V,{id:"upgrade-skills-button",size:"sm",className:"rounded-lg bg-xterns-blue text-white hover:bg-xterns-blue/90",onClick:a,children:[e.jsx(os,{className:"mr-1 h-4 w-4"})," Upgrade"]})]})]}),r.length>0&&e.jsx("div",{className:"mb-4 flex flex-wrap gap-1.5",children:kr.map(x=>{const i=o[x]??0,c=l===x,m=x!=="All"&&i===0;return e.jsxs("button",{disabled:m,onClick:()=>u(x),className:`inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium transition-colors ${c?"border-xterns-blue bg-xterns-blue text-white":"border-gray-200 bg-white text-gray-600 hover:bg-gray-50"} ${m?"opacity-40 cursor-not-allowed":""}`,children:[x,e.jsx("span",{className:`rounded-full px-1.5 py-0.5 text-[10px] ${c?"bg-white/20 text-white":"bg-gray-100 text-gray-500"}`,children:i})]},x)})}),d.length>0?e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3",children:d.map((x,i)=>e.jsx(gr,{skill:x,index:i},x.name))}):r.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-200 p-8 text-center",children:[e.jsx("p",{className:"mb-3 text-sm italic text-gray-500",children:"No tech stacks added yet."}),n&&e.jsxs(V,{onClick:n,className:"rounded-lg bg-xterns-blue text-white hover:bg-xterns-blue/90",children:[e.jsx(xe,{className:"mr-2 h-4 w-4"})," Add tech stacks"]})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-gray-200 p-8 text-center text-sm text-gray-500",children:"No skills in this category yet."})]})}const qe=["from-xterns-blue/80 via-xterns-teal/70 to-xterns-navy","from-xterns-navy via-xterns-blue/80 to-xterns-teal/70","from-xterns-teal/70 via-xterns-blue/60 to-xterns-navy/80"];
16function Sr({item:t,index:s}){const a=t.kind==="github"?ee:t.kind==="linkedin"?we:ke;return e.jsxs(R.article,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.35,delay:s*.05,ease:"easeOut"},whileHover:{y:-3},className:"group flex flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-[0_1px_2px_rgba(17,24,39,0.04)] transition-shadow duration-200 hover:shadow-[0_14px_30px_rgba(17,24,39,0.1)]",children:[e.jsxs("div",{className:`relative h-32 bg-gradient-to-br ${qe[s%qe.length]}`,children:[t.cover?e.jsx("img",{src:t.cover,alt:"",className:"h-full w-full object-cover"}):e.jsx("div",{className:"flex h-full w-full items-center justify-center text-white/80",children:e.jsx(a,{className:"h-10 w-10"})}),t.verified&&e.jsxs(O,{className:"absolute right-3 top-3 border-0 bg-white/90 text-xterns-teal",children:[e.jsx(ls,{className:"mr-1 h-3.5 w-3.5"})," Verified"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900",children:t.title}),t.description&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-gray-600",children:t.description}),t.tech&&t.tech.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-1",children:t.tech.slice(0,4).map(n=>e.jsx("span",{className:"rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] font-medium text-gray-600",children:n},n))}),e.jsxs("div",{className:"mt-auto flex items-center gap-2 pt-4",children:[t.repoUrl&&e.jsxs("a",{href:t.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-lg border border-gray-200 px-2.5 py-1 text-xs text-gray-700 transition-colors hover:bg-gray-50",children:[e.jsx(ee,{className:"h-3.5 w-3.5"})," Repo"]}),t.liveUrl&&e.jsxs("a",{href:t.liveUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-lg bg-xterns-blue px-2.5 py-1 text-xs text-white transition-colors hover:bg-xterns-blue/90",children:[e.jsx(Nt,{className:"h-3.5 w-3.5"})," Live"]})]})]})]})}function Cr({items:t,onAdd:s}){return e.jsxs("section",{id:"links-section",className:"rounded-[18px] border border-gray-200 bg-white p-5 shadow-[0_1px_2px_rgba(17,24,39,0.04)]",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Portfolio"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Projects and links that showcase your work"})]}),s&&e.jsxs(V,{variant:"outline",size:"sm",className:"rounded-lg",onClick:s,children:[e.jsx(xe,{className:"mr-1 h-4 w-4"})," Add portfolio"]})]}),t.length>0?e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3",children:t.map((a,n)=>e.jsx(Sr,{item:a,index:n},a.id))}):e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 py-10 text-center",children:[e.jsx("div",{className:"mb-3 flex h-12 w-12 items-center justify-center rounded-2xl bg-xterns-blue/10 text-xterns-blue",children:e.jsx(ws,{className:"h-5 w-5"})}),e.jsx("p",{className:"text-sm font-medium text-gray-800",children:"No projects yet"}),e.jsx("p",{className:"mt-1 max-w-xs text-xs text-gray-500",children:"Add a portfolio site, GitHub repository, or LinkedIn to showcase your work."}),s&&e.jsxs(V,{onClick:s,className:"mt-4 rounded-lg bg-xterns-blue text-white hover:bg-xterns-blue/90",children:[e.jsx(xe,{className:"mr-2 h-4 w-4"})," Add portfolio"]})]})]})}const La=()=>{var g,A,N;const t=Be(),{user:s}=je(),[a,n]=P.useState(!1),[l,u]=P.useState(!1),{profile:r,profilePicture:o,isLoading:d,error:x,refreshProfile:i}=_s(),{currentScore:c,scoreHistory:m}=Cs(),{createOrUpdateProfile:S}=Zt();P.useEffect(()=>{if(s!=null&&s.id&&r&&!d){const p=localStorage.getItem(`xtern_onboarding_${s.id}`),h=!r.location&&!r.phone&&r.skills.length===0;!p&&h&&(n(!0),localStorage.setItem(`xtern_onboarding_${s.id}`,"true"))}},[s==null?void 0:s.id,d]),P.useEffect(()=>{const p=async h=>{var M,_;console.log("🔄 Skill update completed event received, refreshing profile..."),console.log("🔄 Updated tech stacks:",(M=h.detail)==null?void 0:M.techStacksPassed),((_=h.detail)==null?void 0:_.userId)===(s==null?void 0:s.id)&&(await i(),console.log("✅ Profile refreshed after skill update"))};return window.addEventListener("skill-update-completed",p),()=>{window.removeEventListener("skill-update-completed",p)}},[s==null?void 0:s.id,i]);const j=async p=>{try{const h=(s==null?void 0:s.email)||p.email||(r==null?void 0:r.email)||"",M=(p.firstName||"").trim(),_=(p.lastName||"").trim();
16await S({first_name:M,last_name:_,full_name:[M,_].filter(Boolean).join(" "),email:h,bio:p.bio,location:p.location,phone:p.phone,portfolio_url:p.portfolio,github_url:p.github,linkedin_url:p.linkedin,skills:p.skills,preferred_roles:p.careerPaths||[]}),await i()}catch(h){console.error("Failed to save profile:",h)}},w=async p=>{await i()},E=(g=r==null?void 0:r.skills)==null?void 0:g.some(p=>{const h=typeof p=="object"?p.proficiency:0;return h>0&&h<5});if(d||!r)return e.jsx(ue,{children:e.jsxs("div",{className:"min-h-screen flex w-full bg-gray-50",children:[e.jsx(he,{}),e.jsxs(pe,{className:"flex-1",children:[e.jsxs("header",{className:"sticky top-0 z-40 flex h-16 shrink-0 items-center gap-2 border-b bg-white px-4",children:[e.jsx(Pe,{className:"-ml-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Profile"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Manage your profile and settings"})]})]}),e.jsxs("div",{className:"flex-1 space-y-6 p-6",children:[e.jsx(X,{children:e.jsx(Q,{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-6",children:[e.jsx("div",{className:"h-24 w-24 rounded-full bg-muted animate-pulse"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"h-7 w-64 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 w-96 bg-muted/70 rounded animate-pulse"}),e.jsx("div",{className:"h-4 w-48 bg-muted/50 rounded animate-pulse"})]})]})})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 h-64 bg-muted/40 rounded animate-pulse"}),e.jsx("div",{className:"h-64 bg-muted/40 rounded animate-pulse"})]})]})]})]})});if(x)return e.jsx(ue,{children:e.jsxs("div",{className:"min-h-screen flex w-full bg-gray-50",children:[e.jsx(he,{}),e.jsx(pe,{className:"flex-1",children:e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-red-600 mb-4",children:["Error loading profile: ",x]}),e.jsx(V,{onClick:i,children:"Try Again"})]})})})]})});const T=p=>p.map(h=>{var M;return(M=D.find(_=>_.id===h))==null?void 0:M.name}).filter(Boolean),k=new Set(D.map(p=>p.id)),C=Array.isArray(r==null?void 0:r.preferred_roles)?Array.from(new Set(r.preferred_roles)).filter(p=>k.has(p)).slice(0,2):[],f={name:(r==null?void 0:r.full_name)||"Xtern",firstName:(r==null?void 0:r.first_name)||((A=r==null?void 0:r.full_name)==null?void 0:A.split(/\s+/)[0])||"",lastName:(r==null?void 0:r.last_name)||((N=r==null?void 0:r.full_name)==null?void 0:N.split(/\s+/).slice(1).join(" "))||"",email:(r==null?void 0:r.email)||(s==null?void 0:s.email)||"",bio:(r==null?void 0:r.bio)||"",location:(r==null?void 0:r.location)||"",phone:(r==null?void 0:r.phone)||"",portfolio:(r==null?void 0:r.portfolio_url)||"",github:(r==null?void 0:r.github_url)||"",linkedin:(r==null?void 0:r.linkedin_url)||"",skills:(r==null?void 0:r.skills)||[],careerPaths:C,eiScore:(c==null?void 0:c.score)||0,profilePicture:o||""},y=T(C),b=[{key:"bio",label:"Bio",done:!!f.bio,hint:"Add a short bio to introduce yourself"},{key:"email",label:"Email",done:!!f.email},{key:"phone",label:"Phone",done:!!f.phone,hint:"Add a phone number so recruiters can reach you"},{key:"location",label:"Location",done:!!f.location},{key:"skills",label:"Skills",done:f.skills.length>0,hint:"Add and assess at least one skill"},{key:"links",label:"Social links",done:!!(f.portfolio||f.github||f.linkedin),hint:"Connect LinkedIn, GitHub or a portfolio URL"}],v=b.filter(p=>!p.done).length,L=Math.max(1,v*2),U=[f.portfolio&&{id:"portfolio",title:"Portfolio site",description:f.portfolio.replace(/^https?:\/\//,""),liveUrl:f.portfolio,kind:"portfolio",verified:!0},f.github&&{id:"github",title:"GitHub",description:f.github.replace(/^https?:\/\/(www\.)?github\.com\//,"@"),repoUrl:f.github,liveUrl:f.github,kind:"github",verified:!0},f.linkedin&&{id:"linkedin",title:"LinkedIn",description:f.linkedin.replace(/^https?:\/\/(www\.)?linkedin\.com\//,""),liveUrl:f.linkedin,kind:"linkedin"}
16].filter(Boolean),$=async()=>{const p=`${window.location.origin}/xterns/profile/${(s==null?void 0:s.id)??""}`;try{await navigator.clipboard.writeText(p),q.success("Profile link copied")}catch{q.message(p)}};return e.jsxs(ue,{children:[e.jsxs("div",{className:"min-h-screen flex w-full bg-gray-50",children:[e.jsx(he,{}),e.jsxs(pe,{className:"flex-1",children:[e.jsxs("header",{className:"sticky top-0 z-40 flex h-16 shrink-0 items-center gap-2 border-b border-gray-200/70 bg-white/80 px-4 backdrop-blur-md",children:[e.jsx(Pe,{className:"-ml-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"font-['DM_Serif_Display'] text-xl text-xterns-navy",children:"Profile"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Your public identity across Xterns"})]})]}),e.jsxs("div",{className:"flex-1 space-y-6 p-4 md:p-6 lg:p-8",children:[e.jsx(dr,{userId:s==null?void 0:s.id,name:f.name,bio:f.bio,location:f.location,email:f.email,githubUrl:f.github,linkedinUrl:f.linkedin,portfolioUrl:f.portfolio,careerPathNames:y,profilePicture:f.profilePicture,onImageUpdate:w,score:f.eiScore,scoreHistory:m,onEdit:()=>n(!0),onShare:$,onPreviewPublic:()=>t(`/xterns/profile/${(s==null?void 0:s.id)??""}`),onViewAnalytics:()=>t("/xterns/dashboard")}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(_r,{skills:(r==null?void 0:r.skills)||[],hasUpgradeable:E,onUpgrade:()=>t("/xterns/skill-update-wizard"),onAdd:()=>u(!0)}),e.jsx(Cr,{items:U,onAdd:()=>n(!0)}),!f.github&&e.jsx("div",{className:"rounded-[18px] border border-gray-200 bg-white p-5 shadow-[0_1px_2px_rgba(17,24,39,0.04)]",children:e.jsx(Ls,{})}),e.jsx(rr,{userId:s==null?void 0:s.id})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(mr,{email:f.email||(s==null?void 0:s.email),phone:f.phone,location:f.location,linkedin:f.linkedin,github:f.github,website:f.portfolio,onEdit:()=>n(!0)}),e.jsx(xr,{items:b,estMinutes:L}
16),(s==null?void 0:s.id)&&e.jsx(fr,{userId:s.id,onSyncComplete:i}),e.jsx(Us,{})]})]}),e.jsx(nr,{userId:s==null?void 0:s.id})]})]})]}),e.jsx(Qt,{isOpen:a,onClose:()=>n(!1),onSave:j,initialData:f}),e.jsx(Jt,{isOpen:l,onClose:()=>u(!1),currentProfile:f,onUpdate:i})]})};export{La 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.