1import{r as n,ag as oe,K as le,j as e,I as h,s as i,a8 as ce,ac as Z,al as de}from"./index-PvriC7IB.js";import{D as F,U as me,T as ue,c as he,r as pe}from"./AppRoutes-_SQgw96o.js";import{I as m}from"./input-BGOmFG7B.js";import{L as o}from"./label-BOKjk9ds.js";import{T as G}from"./textarea-CrOzCqRr.js";import{S as f}from"./separator-mDU-aZ1J.js";import{S as W}from"./switch-C8Zgm8f0.js";import{T as xe}from"./TelegramZenConnectCard-BRBLFmvy.js";import{S as w}from"./save-CnL2r0OQ.js";import{D as z}from"./download-BaDpvSFB.js";import{E as ge}from"./eye-BTj2glRP.js";import"./index-DPA5sS5d.js";import"./circle-x-Bup88Avl.js";import"./refresh-cw-DnWtp8PJ.js";const Re=({role:p})=>{const[t,u]=n.useState({full_name:"",email:"",phone:"",headline:"",bio:"",linkedin_url:"",website_url:"",address:"",availability:"open_to_offers"}),[v,N]=n.useState(""),[x,k]=n.useState(""),[S,C]=n.useState(""),[g,H]=n.useState(!1),[l,P]=n.useState({analytics_consent:!1,marketing_consent:!1,ai_processing_consent:!0,recruiter_visibility:!1,cross_border_processing_ack:!1}),[K,b]=n.useState(!0),[Y,D]=n.useState(!1),[_,q]=n.useState("export"),[R,y]=n.useState(""),[I,E]=n.useState(!1),[U,A]=n.useState(!1),[L,O]=n.useState(!1),[T,J]=n.useState(!1),[$,Q]=n.useState(!0),{toast:c}=oe(),B=le(),M=p==="candidate"?he:pe;n.useEffect(()=>{(async()=>{const{data:{user:r}}=await i.auth.getUser();if(!r){B("/login");return}const{data:a}=await i.from("profiles").select("*").eq("id",r.id).maybeSingle(),{data:d}=await i.from("privacy_preferences").select("*").eq("user_id",r.id).maybeSingle();a&&(u({full_name:a.full_name||"",email:a.email||r.email||"",phone:a.phone||"",headline:a.headline||"",bio:a.bio||"",linkedin_url:a.linkedin_url||"",website_url:a.website_url||"",address:a.address||"",availability:a.availability||"open_to_offers"}),b(a.daily_job_alerts!==!1)),d&&P({analytics_consent:!!d.analytics_consent,marketing_consent:!!d.marketing_consent,ai_processing_consent:!!d.ai_processing_consent,recruiter_visibility:!!d.recruiter_visibility,cross_border_processing_ack:!!d.cross_border_processing_ack}),Q(!1)})()},[B]);const X=async()=>{E(!0);try{const{data:{user:s}}=await i.auth.getUser();if(!s)return;const{error:r}=await i.from("profiles").update({full_name:t.full_name,phone:t.phone,headline:t.headline,bio:t.bio,linkedin_url:t.linkedin_url,website_url:t.website_url,address:t.address,availability:t.availability}).eq("id",s.id);if(r)throw r;c({title:"Profile updated"})}catch(s){c({title:"Error",description:s.message,variant:"destructive"})}finally{E(!1)}},ee=async()=>{A(!0);try{const{data:{user:s}}=await i.auth.getUser();if(!s)return;const r={user_id:s.id,...l,consent_version:"2026-04"},{error:a}=await i.from("privacy_preferences").upsert(r,{onConflict:"user_id"});if(a)throw a;const d=[{user_id:s.id,consent_key:"analytics",consent_version:"2026-04",granted:l.analytics_consent,withdrawn_at:l.analytics_consent?null:new Date().toISOString()},{user_id:s.id,consent_key:"marketing",consent_version:"2026-04",granted:l.marketing_consent,withdrawn_at:l.marketing_consent?null:new Date().toISOString()},{user_id:s.id,consent_key:"ai_processing",consent_version:"2026-04",granted:l.ai_processing_consent,withdrawn_at:l.ai_processing_consent?null:new Date().toISOString()},{user_id:s.id,consent_key:"cross_border_processing",consent_version:"2026-04",granted:l.cross_border_processing_ack,withdrawn_at:l.cross_border_processing_ack?null:new Date().toISOString()}];await i.from("privacy_consents").upsert(d,{onConflict:"user_id,consent_key,consent_version"}),await i.rpc("log_audit_event",{_action:"privacy_preferences_updated",_entity_type:"privacy_preferences",_entity_id:s.id,_metadata:l}),c({title:"Privacy preferences saved"})}catch(s){c({title:"Error",description:s.message,variant:"destructive"})}finally{A(!1)}},se=async()=>{const{data:{user:s}}=await i.auth.getUser();if(!s)return;const[r,a,d,re]=await Promise.all([i.from("profiles").select("*").eq("id",s.id).maybeSingle(),i.from("resumes").select("*").eq("user_id",s.id),i.from("privacy_preferences").select("*").eq("user_id",s.id).maybeSingle(),i.from("data_subject_requests").select("*").eq("user_id",s.id).order("created_at",{ascending:!1})]),ie={exported_at:new Date().toISOString(),account:{id:s.id,email:s.email},profile:r.data,cvs:a.data||[],privacy_preferences:d.data,data_requests:re.data||[]},ne=new Blob([JSON.stringify(ie,null,2)],{type:"application/json"}),V=URL.createObjectURL(ne),j=document.createElement("a");j.href=V,j.download=`cvzen-data-export-${new Date().toISOString().slice(0,10)}.json`,j.click(),URL.revokeObjectURL(V),await i.rpc("log_audit_event",{_action:"data_export_downloaded",_entity_type:"profile",_entity_id:s.id,_metadata:{}})},ae=async()=>{O(!0);try{const{data:{user:s}}=await i.auth.getUser();if(!s)return;const{error:r}=await i.from("data_subject_requests").insert({user_id:s.id,request_type:_,details:R.trim()||null});if(r)throw r;await i.rpc("log_audit_event",{_action:"data_subject_request_submitted",_entity_type:"data_subject_request",_entity_id:s.id,_metadata:{request_type:_}}
1),y(""),c({title:"Request submitted",description:"Our privacy team will review it according to the published timeline."})}catch(s){c({title:"Error",description:s.message,variant:"destructive"})}finally{O(!1)}},te=async()=>{if(x!==S){c({title:"Passwords don't match",variant:"destructive"});return}if(x.length<6){c({title:"Password must be at least 6 characters",variant:"destructive"});return}J(!0);try{const{data:{user:s}}=await i.auth.getUser();if(!(s!=null&&s.email))throw new Error("No email found");const{error:r}=await i.auth.signInWithPassword({email:s.email,password:v});if(r)throw new Error("Current password is incorrect");const{error:a}=await i.auth.updateUser({password:x});if(a)throw a;c({title:"Password changed successfully"}),N(""),k(""),C("")}catch(s){c({title:"Error",description:s.message,variant:"destructive"})}finally{J(!1)}};return $?e.jsx(F,{navItems:M,role:p,children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):e.jsx(F,{navItems:M,role:p,children:e.jsxs("div",{className:"max-w-2xl space-y-8",children:[e.jsx(xe,{role:p}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(me,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Profile Information"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Update your personal details"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Full name"}),e.jsx(m,{value:t.full_name,onChange:s=>u({...t,full_name:s.target.value}),className:"h-10 bg-background enterprise-border"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Email"}),e.jsx(m,{value:t.email,disabled:!0,className:"h-10 bg-muted enterprise-border"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Phone"}),e.jsx(m,{value:t.phone,onChange:s=>u({...t,phone:s.target.value}),placeholder:"+1 234 567 890",className:"h-10 bg-background enterprise-border"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Headline"}),e.jsx(m,{value:t.headline,onChange:s=>u({...t,headline:s.target.value}),placeholder:"Senior Developer",className:"h-10 bg-background enterprise-border"})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Bio"}),e.jsx(G,{value:t.bio,onChange:s=>u({...t,bio:s.target.value}),placeholder:"A short bio about yourself",rows:3,className:"bg-background enterprise-border"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"LinkedIn URL"}),e.jsx(m,{value:t.linkedin_url,onChange:s=>u({...t,linkedin_url:s.target.value}),placeholder:"https://linkedin.com/in/...",className:"h-10 bg-background enterprise-border"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Website"}),e.jsx(m,{value:t.website_url,onChange:s=>u({...t,website_url:s.target.value}),placeholder:"https://...",className:"h-10 bg-background enterprise-border"})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Address"}),e.jsx(m,{value:t.address,onChange:s=>u({...t,address:s.target.value}),placeholder:"City, Country",className:"h-10 bg-background enterprise-border"})]})]}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsxs(h,{variant:"hero",onClick:X,disabled:I,className:"h-10",children:[e.jsx(w,{className:"h-4 w-4 mr-2"})," ",I?"Saving...":"Save changes"]})})]}),e.jsx(f,{}),p==="candidate"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(w,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Job Alerts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Daily emails with roles matched to your CV"})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 roun
1ded-lg border border-border bg-background/60 p-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-sm font-medium",children:"Daily job recommendations"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Get up to 5 fresh roles each morning, picked semantically from internal postings and live job feeds. You can turn this off any time."})]}),e.jsx(W,{checked:K,disabled:Y,onCheckedChange:async s=>{b(s),D(!0);try{const{data:{user:r}}=await i.auth.getUser();if(!r)return;const{error:a}=await i.from("profiles").update({daily_job_alerts:s}).eq("id",r.id);if(a)throw a;c({title:s?"Daily alerts enabled":"Daily alerts paused"})}catch(r){b(!s),c({title:"Could not save",description:r.message,variant:"destructive"})}finally{D(!1)}}})]})]}),e.jsx(f,{})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(ce,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Privacy & Consent"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage DPDP/GDPR-style choices for your account"})]})]}),e.jsx("div",{className:"space-y-4",children:[["analytics_consent","Analytics","Allow product analytics to improve cvZen."],["marketing_consent","Marketing communication","Receive product updates and offers."],["ai_processing_consent","AI processing","Allow AI features to process your CV and profile content."],["recruiter_visibility","Recruiter visibility","Allow relevant recruiters to discover your digital CV."],["cross_border_processing_ack","Cross-border processing acknowledgement","I understand my data may be processed or stored outside India."]].map(([s,r,a])=>e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-border bg-background/60 p-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-sm font-medium",children:r}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:a})]}),e.jsx(W,{checked:l[s],onCheckedChange:d=>P({...l,[s]:d})})]},s))}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsxs(h,{variant:"hero",onClick:ee,disabled:U,className:"h-10",children:[e.jsx(w,{className:"h-4 w-4 mr-2"})," ",U?"Saving...":"Save privacy choices"]})})]}),e.jsx(f,{}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(z,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Data Rights"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Export your data or submit privacy requests"})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-[1fr_auto]",children:[e.jsxs(h,{variant:"outline",onClick:se,className:"h-10 justify-start",children:[e.jsx(z,{className:"h-4 w-4 mr-2"})," Download my account data"]}),e.jsxs(h,{variant:"destructive",onClick:()=>{q("deletion"),y("Please delete my cvZen account and legally deletable personal data.")},className:"h-10",children:[e.jsx(ue,{className:"h-4 w-4 mr-2"}
1)," Prepare deletion request"]})]}),e.jsxs("div",{className:"mt-5 grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Request type"}),e.jsxs("select",{value:_,onChange:s=>q(s.target.value),className:"h-10 w-full rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"export",children:"Data export"}),e.jsx("option",{value:"correction",children:"Correction"}),e.jsx("option",{value:"deletion",children:"Deletion"}),e.jsx("option",{value:"consent_withdrawal",children:"Consent withdrawal"}),e.jsx("option",{value:"objection",children:"Objection / grievance"})]})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Details"}),e.jsx(G,{value:R,onChange:s=>y(s.target.value),rows:3,maxLength:1e3,placeholder:"Describe what you want us to review or change",className:"bg-background enterprise-border"})]})]}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx(h,{variant:"hero",onClick:ae,disabled:L,className:"h-10",children:L?"Submitting...":"Submit privacy request"})})]}),e.jsx(f,{}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Z,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Change Password"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Update your account password"})]})]}),e.jsxs("div",{className:"space-y-4 max-w-sm",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Current password"}),e.jsxs("div",{className:"relative",children:[e.jsx(m,{type:g?"text":"password",value:v,onChange:s=>N(s.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",className:"h-10 bg-background enterprise-border pr-10"}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>H(!g),children:g?e.jsx(de,{className:"h-4 w-4"}):e.jsx(ge,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"New password"}),e.jsx(m,{type:g?"text":"password",value:x,onChange:s=>k(s.target.value),placeholder:"Min 6 characters",className:"h-10 bg-background enterprise-border"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-medium",children:"Confirm new password"}),e.jsx(m,{type:g?"text":"password",value:S,onChange:s=>C(s.target.value),placeholder:"Repeat new password",className:"h-10 bg-background enterprise-border"})]})]}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsxs(h,{variant:"hero",onClick:te,disabled:T||!v||!x,className:"h-10",children:[e.jsx(Z,{className:"h-4 w-4 mr-2"})," ",T?"Changing...":"Change password"]})})]})]})})};export{Re 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.