1import{j as e}from"./vendor-ui-core.DP8knyZn.js";import{r as t}from"./vendor-react.BBoGJFYM.js";import{d as i,s as r,S as n,J as a,D as o,K as d,o as l,q as s,r as c,t as g,C as p,E as h,F as x,G as b}from"./index.CdjOtu-m.js";import{A as u,a as m,b as v,c as j,d as f,e as y,f as B,g as w}from"./alert-dialog.DmbxRrbo.js";import{D as T,a as S,b as C,c as k}from"./dropdown-menu.D3yGzeFM.js";import{R as I,y as _,ak as R,x as E,aF as H,bC as D,b4 as z,bM as O,T as P,D as W,F as A}from"./vendor-icons.BjAWwE8z.js";import"./vendor-supabase.DS-aP8MZ.js";import"./vendor-ui-forms.CjLBxE3d.js";import"./vendor-utils.BlEnRQrd.js";import"./vendor-ui-display.BT2Z6Vpo.js";import"./vendor-query.CfjDb5WU.js";import"./vendor-media.DY6E_qVO.js";import"./vendor-charts.RWeJ_I16.js";import"./vendor-motion.DCvbjL6b.js";const $={dark:{cardBg:"rgba(255,255,255,0.04)",cardBorder:"rgba(16,185,129,0.14)",tableBg:"rgba(255,255,255,0.03)",tableBorder:"rgba(255,255,255,0.07)",tableHeadBg:"rgba(255,255,255,0.05)",tableRowHoverBg:"rgba(16,185,129,0.06)",tableRowBorder:"rgba(255,255,255,0.05)",titleText:"rgba(255,255,255,0.92)",subText:"rgba(255,255,255,0.40)",headText:"rgba(255,255,255,0.55)",cellText:"rgba(255,255,255,0.82)",mutedText:"rgba(255,255,255,0.38)",badgeAcceptedBg:"rgba(16,185,129,0.18)",badgeAcceptedText:"#10b981",badgeAcceptedBorder:"rgba(16,185,129,0.35)",badgeExpiredBg:"rgba(248,113,113,0.12)",badgeExpiredText:"#f87171",badgeExpiredBorder:"rgba(248,113,113,0.28)",badgePendingBg:"rgba(251,191,36,0.12)",badgePendingText:"#fbbf24",badgePendingBorder:"rgba(251,191,36,0.25)",badgeInvitedBg:"rgba(96,165,250,0.12)",badgeInvitedText:"#60a5fa",badgeInvitedBorder:"rgba(96,165,250,0.25)",selectBg:"rgba(255,255,255,0.06)",selectBorder:"rgba(16,185,129,0.20)",selectText:"rgba(255,255,255,0.80)",inputBg:"rgba(255,255,255,0.05)",inputBorder:"rgba(255,255,255,0.12)",inputText:"rgba(255,255,255,0.88)",btnPrimaryBg:"rgba(16,185,129,0.90)",btnPrimaryHoverBg:"#10b981",btnPrimaryText:"#fff",btnOutlineBg:"rgba(255,255,255,0.05)",btnOutlineBorder:"rgba(255,255,255,0.14)",btnOutlineText:"rgba(255,255,255,0.70)",btnOutlineHoverBg:"rgba(255,255,255,0.09)",btnOutlineHoverText:"rgba(255,255,255,0.92)",btnGhostText:"rgba(255,255,255,0.45)",btnGhostHoverBg:"rgba(255,255,255,0.07)",btnGhostHoverText:"rgba(255,255,255,0.82)",btnDangerText:"rgba(248,113,113,0.80)",btnDangerHoverBg:"rgba(248,113,113,0.10)",btnDangerHoverText:"#f87171",divider:"rgba(255,255,255,0.06)",emptyIconColor:"rgba(255,255,255,0.20)",paginationText:"rgba(255,255,255,0.38)",countBadgeBg:"rgba(16,185,129,0.14)",countBadgeText:"#10b981",shimmerBase:"rgba(255,255,255,0.04)",shimmerHighlight:"rgba(255,255,255,0.07)"},light:{cardBg:"rgba(16,185,129,0.06)",cardBorder:"rgba(16,185,129,0.22)",tableBg:"rgba(16,185,129,0.04)",tableBorder:"rgba(16,185,129,0.18)",tableHeadBg:"rgba(16,185,129,0.10)",tableRowHoverBg:"rgba(16,185,129,0.10)",tableRowBorder:"rgba(16,185,129,0.12)",titleText:"rgba(255,255,255,0.96)",subText:"rgba(255,255,255,0.55)",headText:"rgba(255,255,255,0.72)",cellText:"rgba(255,255,255,0.92)",mutedText:"rgba(255,255,255,0.55)",badgeAcceptedBg:"rgba(16,185,129,0.25)",badgeAcceptedText:"#10b981",badgeAcceptedBorder:"rgba(16,185,129,0.50)",badgeExpiredBg:"rgba(248,113,113,0.18)",badgeExpiredText:"#f87171",badgeExpiredBorder:"rgba(248,113,113,0.38)",badgePendingBg:"rgba(251,191,36,0.18)",badgePendingText:"#fbbf24",badgePendingBorder:"rgba(251,191,36,0.35)",badgeInvitedBg:"rgba(96,165,250,0.18)",badgeInvitedText:"#60a5fa",badgeInvitedBorder:"rgba(96,165,250,0.35)",selectBg:"rgba(16,185,129,0.12)",selectBorder:"rgba(16,185,129,0.35)",selectText:"rgba(255,255,255,0.90)",inputBg:"rgba(16,185,129,0.08)",inputBorder:"rgba(16,185,129,0.28)",inputText:"rgba(255,255,255,0.95)",btnPrimaryBg:"#10b981",btnPrimaryHoverBg:"#0ea572",btnPrimaryText:"#fff",btnOutlineBg:"rgba(16,185,129,0.10)",btnOutlineBorder:"rgba(16,185,129,0.28)",btnOutlineText:"rgba(255,255,255,0.75)",btnOutlineHoverBg:"rgba(16,185,129,0.18)",btnOutlineHoverText:"rgba(255,255,255,0.95)",btnGhostText:"rgba(255,255,255,0.55)",btnGhostHoverBg:"rgba(16,185,129,0.12)",btnGhostHoverText:"rgba(255,255,255,0.92)",btnDangerText:"rgba(248,113,113,0.85)",btnDangerHoverBg:"rgba(248,113,113,0.15)",btnDangerHoverText:"#f87171",divider:"rgba(16,185,129,0.18)",emptyIconColor:"rgba(255,255,255,0.30)",paginationText:"rgba(255,255,255,0.55)",countBadgeBg:"rgba(16,185,129,0.20)",countBadgeText:"#10b981",shimmerBase:"rgba(255,255,255,0.06)",shimmerHighlight:"rgba(255,255,255,0.10)"}},M="#10b981";const G=({value:t,onValueChange:i,p:r,placeholder:n,children:a,width:o=190})=>e.jsxs(p,{value:t,onValueChange:i,children:[e.jsx(h,{style:{width:o,background:r.selectBg,border:`1px solid ${r.selectBorder}`,color:r.selectText,borderRadius:9,fontSize:12,height:34,paddingLeft:10,paddingRight:8,boxShadow:"none"},children:e.jsx(x,{placeholder:n})}),e.jsx(b,{children:a})]}),F=({p:t,...i})=>e.jsx("input",{...i,style:{width:"100%",height:36,padding:"0 10px",borderRadius:8,background:t.inputBg,border:`1px solid ${t.inputBorder}`,color:t.inputText,fontSize:13,outline:"none",transition:"border-color 180ms",...i.style||{}},onFocus:e=>{e.currentTarget.style.borderColor=M},onBlur:e=>{e.currentTarget.style.borderColor=t.inputBorder}}),V=({p:t,...i})=>e.jsx("textarea",{...i,style:{width:"100%",padding:"8px 10px",borderRadius:8,background:t.inputBg,border:`1px solid ${t.inputBorder}`,color:t.inputText,fontSize:13,outline:"none",resize:"vertical",transition:"border-color 180ms",lineHeight:1.5,...i.style||{}},onFocus:e=>{e.currentTarget.style.borderColor=M},onBlur:e=>{e.currentTarget.style.borderColor=t.inputBorder}}),N=({onClick:i,children:r,variant:n="outline",p:a,disabled:o=!1,fullWidth:d=!1,style:l={}})=>{const[s,c]=t.useState(!1),g={display:"inline-flex",alignItems:"center",gap:5,height:32,padding:"0 12px",borderRadius:8,fontSize:12,fontWeight:600,cursor:o?"not-allowed":"pointer",opacity:o?.45:1,border:"1px solid transparent",transition:"background 160ms, color 160ms, border-color 160ms",outline:"none",flexShrink:0,width:d?"100%":void 0,justifyContent:d?"center":void 0},p={primary:{background:s?a.btnPrimaryHoverBg:a.btnPrimaryBg,color:a.btnPrimaryText,border:`1px solid ${M}`},outline:{background:s?a.btnOutlineHoverBg:a.btnOutlineBg,color:s?a.btnOutlineHoverText:a.btnOutlineText,border:`1px solid ${a.btnOutlineBorder}`},ghost:{background:s?a.btnGhostHoverBg:"transparent",color:s?a.btnGhostHoverText:a.btnGhostText,border:"1px solid transparent"},danger:{background:s?a.btnDangerHoverBg:"transparent",color:s?a.btnDangerHoverText:a.btnDangerText,border:"1px solid "+(s?"rgba(248,113,113,0.35)":"rgba(248,113,113,0.18)")}};return e.jsx("button",{onClick:o?void 0:i,disabled:o,style:{...g,...p[n],...l},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:r})},J=({children:t,p:i})=>e.jsx("p",{style:{fontSize:11.5,fontWeight:600,color:i.headText,marginBottom:5,marginTop:0},children:t}),L=({status:t,p:i})=>{const r=t??"pending",n={accepted:{bg:i.badgeAcceptedBg,text:i.badgeAcceptedText,border:i.badgeAcceptedBorder},expired:{bg:i.badgeExpiredBg,text:i.badgeExpiredText,border:i.badgeExpiredBorder},invited:{bg:i.badgeInvitedBg,text:i.badgeInvitedText,border:i.badgeInvitedBorder},pending:{bg:i.badgePendingBg,text:i.badgePendingText,border:i.badgePendingBorder}},a=n[r]??n.pending;return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",fontSize:9.5,fontWeight:700,padding:"2px 7px",borderRadius:6,background:a.bg,color:a.text,border:`1px solid ${a.border}`,textTransform:"capitalize",lineHeight:1.5},children:r})},q=({p:i,jobRoles:n,onClose:o,corporateId:d})=>{const[l,s]=t.useState(""),[c,p]=t.useState(""),[h,x]=t.useState(""),[b,u]=t.useState("7"),[m,v]=t.useState(!1);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14,marginTop:16},children:[e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Job Role *"}),e.jsx(G,{value:h,onValueChange:x,p:i,placeholder:"Select job role",width:"100%",children:n.map(t=>e.jsx(a,{value:t.id,children:t.title},t.id))})]}),e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Email *"}),e.jsx(F,{p:i,type:"email",placeholder:"[email protected]",value:l,onCh
1ange:e=>s(e.target.value)})]}),e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Full Name"}),e.jsx(F,{p:i,placeholder:"John Doe",value:c,onChange:e=>p(e.target.value)})]}),e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Expiry (days)"}),e.jsx(G,{value:b,onValueChange:u,p:i,width:"100%",children:[3,5,7,14,21,30].map(t=>e.jsxs(a,{value:String(t),children:[t," days"]},t))})]}),e.jsx(N,{variant:"primary",p:i,onClick:async()=>{var e,t,i,n;if(l&&h&&d){v(!0);try{const a=await r.functions.invoke("corporate-invite-candidates",{body:{corporate_id:d,job_role_id:h,candidates:[{email:l.trim(),full_name:c.trim()||null}],expiry_days:parseInt(b)||7}});if(a.error)throw a.error;const s=a.data;(null==(e=null==s?void 0:s.summary)?void 0:e.invited)>0?g({title:"Invitation sent!"}):(null==(t=null==s?void 0:s.summary)?void 0:t.skipped)>0?g({title:"Already invited",variant:"destructive"}):g({title:"Error",description:(null==(n=null==(i=null==s?void 0:s.results)?void 0:i[0])?void 0:n.error)||"Unknown error",variant:"destructive"}),o()}catch(a){g({title:"Error",description:a.message,variant:"destructive"})}v(!1)}else g({title:"Missing fields",variant:"destructive"})},disabled:m,fullWidth:!0,style:{height:38,fontSize:13},children:m?"Sendingâ¦":"Send Invitation"})]})},U=({p:i,jobRoles:n,onClose:o,corporateId:d})=>{const[l,s]=t.useState(""),[c,p]=t.useState(""),[h,x]=t.useState("7"),[b,u]=t.useState(!1),[m,v]=t.useState(!1);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14,marginTop:16},children:[e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Job Role *"}),e.jsx(G,{value:l,onValueChange:s,p:i,placeholder:"Select job role",width:"100%",children:n.map(t=>e.jsx(a,{value:t.id,children:t.title},t.id))})]}),e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Upload CSV / TXT File"}),e.jsx("input",{type:"file",accept:".csv,.txt",disabled:m,style:{fontSize:12,color:i.cellText,width:"100%"},onChange:async e=>{var t,i;const r=null==(t=e.target.files)?void 0:t[0];if(r){v(!0);try{const e=(await r.text()).trim().split("\n").filter(e=>e.trim()),t=(null==(i=e[0])?void 0:i.toLowerCase())||"",n=t.includes("email")&&t.includes("name")?e.slice(1):e,a=n.filter(e=>{var t;const i=e.split(",").map(e=>e.trim());return!(null==(t=i[0])?void 0:t.includes("@"))||!i[1]});n.length?a.length?g({title:"Invalid format",description:`${a.length} line(s) invalid. Need: email, name`,variant:"destructive"}):(p(e=>e?e+"\n"+n.join("\n"):n.join("\n")),g({title:"CSV loaded",description:`${n.length} candidate(s) imported`})):g({title:"Empty file",variant:"destructive"})}catch{g({title:"Failed to read file",variant:"destructive"})}v(!1),e.target.value=""}}}),e.jsx("p",{style:{fontSize:10.5,color:i.mutedText,marginTop:4},children:"Format: email, name (one per line)"})]}),e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Or paste candidates (CSV: email, name)"}),e.jsx(V,{p:i,rows:5,placeholder:"[email protected], John Doe\[email protected], Jane Smith",value:c,onChange:e=>p(e.target.value)})]}),e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Expiry (days)"}),e.jsx(G,{value:h,onValueChange:x,p:i,width:"100%",children:[3,5,7,14,21,30].map(t=>e.jsxs(a,{value:String(t),children:[t," days"]},t))})]}),e.jsx(N,{variant:"primary",p:i,onClick:async()=>{var e;if(l&&c.trim()&&d){u(!0);try{const t=c.trim().split("\n").filter(e=>e.trim()),i=(null==(e=t[0])?void 0:e.toLowerCase())||"",n=(i.includes("email")&&i.includes("name")?t.slice(1):t).map(e=>{const t=e.split(",").map(e=>e.trim());return{email:t[0],full_name:t[1]||null}}).filter(e=>{var t;return null==(t=e.email)?void 0:t.includes("@")}),a=await r.functions.invoke("corporate-invite-candidates",{body:{corporate_id:d,job_role_id:l,candidates:n,expiry_days:parseInt(h)||7}});if(a.error)throw a.error;const{summary:s}=a.data;g({title:"Bulk invite complete",description:`${s.invited} invited, ${s.skipped} skipped, ${s.errors} errors`}),o()}catch(t){g({title:"Error",description:t.message,variant:"destructive"})}u(!1)}else g({title:"Missing fields",variant:"destructive"})},disabled:b,fullWidth:!0,style:{height:38,fontSize:13},children:b?"Sendingâ¦":"Send All Invitations"})]})},X=({p:i,inv:n,jobRoles:o,onClose:d,onSaved:l})=>{const[s,c]=t.useState(n.email),[p,h]=t.useState(n.full_name||""),[x,b]=t.useState(n.job_role_id),[u,m]=t.useState("7"),[v,j]=t.useState(!1);t.useEffect(()=>{if(n.expires_at){const e=Math.max(1,Math.ceil((new Date(n.expires_at).getTime()-Date.now())/864e5)),t=[3,5,7,14,21,30].reduce((t,i)=>Math.abs(i-e)<Math.abs(t-e)?i:t);m(String(t))}},[n]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14,marginTop:16},children:[e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Job Role *"}),e.jsx(G,{value:x,onValueChange:b,p:i,placeholder:"Select job role",width:"100%",children:o.map(t=>e.jsx(a,{value:t.id,children:t.title},t.id))})]}),e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Email *"}),e.jsx(F,{p:i,type:"email",value:s,onChange:e=>c(e.target.value)})]}),e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Full Name"}),e.jsx(F,{p:i,value:p,onChange:e=>h(e.target.value)})]}),e.jsxs("div",{children:[e.jsx(J,{p:i,children:"Expiry (days from now)"}),e.jsx(G,{value:u,onValueChange:m,p:i,width:"100%",children:[3,5,7,14,21,30].map(t=>e.jsxs(a,{value:String(t),children:[t," days"]},t))})]}),e.jsx(N,{variant:"primary",p:i,onClick:async()=>
1{if(s&&x){j(!0);try{const{error:e}=await r.from("candidate_invitations").update({email:s.trim().toLowerCase(),full_name:p.trim()||null,job_role_id:x,expires_at:new Date(Date.now()+864e5*(parseInt(u)||7)).toISOString()}).eq("id",n.id);if(e)throw e;g({title:"Invitation updated"}),l(),d()}catch(e){g({title:"Error",description:e.message,variant:"destructive"})}j(!1)}},disabled:v,fullWidth:!0,style:{height:38,fontSize:13},children:v?"Savingâ¦":"Save Changes"})]})},K=()=>{const{corporateId:p}=i(),h=function(){const e=t.useCallback(()=>{var e;if("undefined"!=typeof document){const e=document.documentElement.getAttribute("data-theme")??document.documentElement.getAttribute("class")??"";if(e.includes("light"))return"light";if(e.includes("dark"))return"dark"}return"undefined"!=typeof window&&(null==(e=window.matchMedia)?void 0:e.call(window,"(prefers-color-scheme: light)").matches)?"light":"dark"},[]),[i,r]=t.useState(e);return t.useEffect(()=>{const t=new MutationObserver(()=>r(e()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}),()=>t.disconnect()},[e]),i}(),x=$[h],[b,F]=t.useState([]),[V,J]=t.useState([]),[K,Q]=t.useState(!0),[Y,Z]=t.useState(!1),[ee,te]=t.useState(!1),[ie,re]=t.useState(!1),[ne,ae]=t.useState(null),[oe,de]=t.useState(null),[le,se]=t.useState("all"),[ce,ge]=t.useState(1),[pe,he]=t.useState(null);t.useEffect(()=>{p&&xe()},[p]);const xe=async()=>{if(!p)return;Q(!0);const[e,t]=await Promise.all([r.from("job_roles").select("id, title").eq("corporate_id",p).eq("is_active",!0),r.from("candidate_invitations").select("*").eq("corporate_id",p).order("created_at",{ascending:!1})]);J(e.data||[]),F(t.data||[]),ge(1),Q(!1)},be=e=>e?new Date(e).toLocaleDateString():"â",ue="all"===le?b:b.filter(e=>e.job_role_id===le),me=Math.ceil(ue.length/20),ve=ue.slice(20*(ce-1),20*ce);return e.jsxs(e.Fragment,{children:[e.jsx(n,{title:"Candidates | Corporate Portal",description:"Invite and manage candidates."}),e.jsx("style",{children:"\n @keyframes cc-spin { from{transform:rotate(0)} to{transform:rotate(360deg)} }\n @keyframes jr-shimmer { 0%{opacity:.5} 50%{opacity:1} 100%{opacity:.5} }\n .cc-spin { animation: cc-spin 1s linear infinite; }\n .cc-shimmer { animation: jr-shimmer 1.5s ease-in-out infinite; }\n "}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,width:"100%"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-end",justifyContent:"space-between",flexWrap:"wrap",gap:12,marginBottom:18},children:[e.jsxs("div",{children:[e.jsxs("h1",{style:{fontSize:17,fontWeight:800,color:"rgba(255,255,255,0.92)",margin:0,letterSpacing:"-0.3px"},children:["Candidates"," ",e.jsx("span",{style:{color:M,fontWeight:700},children:" Management"})]}),e.jsx("p",{style:{fontSize:11.5,color:x.subText,marginTop:2,marginBottom:0},children:"Candidate addition & invitation management"})]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[V.length>0&&e.jsxs(G,{value:le,onValueChange:e=>{se(e),ge(1)},p:x,placeholder:"All Job Roles",width:190,children:[e.jsx(a,{value:"all",children:"All Job Roles"}),V.map(t=>e.jsx(a,{value:t.id,children:t.title},t.id))]}),e.jsxs(N,{variant:"outline",p:x,onClick:xe,disabled:K,children:[e.jsx(I,{style:{width:12,height:12,...K?{animation:"cc-spin 1s linear infinite"}:{}}}),"Refresh"]}),e.jsxs(o,{open:ie,onOpenChange:re,children:[e.jsx(d,{asChild:!0,children:e.jsxs("button",{style:{display:"inline-flex",alignItems:"center",gap:6,height:34,padding:"0 12px",borderRadius:9,fontSize:12,fontWeight:600,cursor:"pointer",background:x.btnOutlineBg,color:x.btnOutlineText,border:`1px solid ${x.btnOutlineBorder}`,outline:"none"},children:[e.jsx(_,{style:{width:13,height:13}})," Bulk Invite"]})}),e.jsxs(l,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(s,{children:e.jsx(c,{children:"Bulk Invite Candidates"})}),e.jsx(U,{p:x,jobRoles:V,corporateId:p,onClose:()=>{re(!1),xe()}})]})]}),e.jsxs(o,{open:ee,onOpenChange:te,children:[e.jsx(d,{asChild:!0,children:e.jsxs("button",{style:{display:"inline-flex",alignItems:"center",gap:6,height:34,padding:"0 14px",borderRadius:9,fontSize:12,fontWeight:700,cursor:"pointer",background:x.btnPrimaryBg,color:x.btnPrimaryText,border:`1px solid ${M}`,outline:"none",transition:"background 180ms"},children:[e.jsx(R,{style:{width:13,height:13}})," Invite Candidate"]})}),e.jsxs(l,{className:"max-w-md",children:[e.jsx(s,{children:e.jsx(c,{children:"Invite Candidate"})}),e.jsx(q,{p:x,jobRoles:V,corporateId:p,onClose:()=>{te(!1),xe()}})]})]})]})]}),e.jsx("div",{style:{height:1,background:x.divider,marginBottom:20}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx(E,{style:{width:15,height:15,color:x.countBadgeText}}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"rgba(255,255,255,0.80)"},children:"Invitations"}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",fontSize:10,fontWeight:700,padding:"1px 8px",borderRadius:20,background:x.countBadgeBg,color:x.countBadgeText},children:ue.length})]}),K?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[1,2,3,4,5].map(t=>e.jsx("div",{className:"cc-shimmer",style:{height:38,borderRadius:8,background:x.shimmerBase}},t))}):0===ue.length?e.jsxs("div",{style:{background:x.tableBg,border:`1px solid ${x.tableBorder}`,borderRadius:14,padding:"48px 24px",textAlign:"center"},children:[e.jsx(E,{style:{width:36,height:36,color:x.emptyIconColor,margin:"0 auto 12px"}}),e.jsx("p",{style:{fontSize:15,fontWeight:700,color:"rgba(255,255,255,0.70)",margin:0},children:"No invitations yet"}),e.jsx("p",{style:{fontSize:12.5,color:x.mutedText,marginTop:4},children:"Invite candidates to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto",background:x.tableBg,border:`1px solid ${x.tableBorder}`,borderRadius:14},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:640},children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:x.tableHeadBg},children:["Email","Name","Job Role","Status","Expires","Sent",""].map((t,i)=>e.jsx("th",{style:{textAlign:6===i?"right":"left",padding:"10px 12px",fontSize:10.5,fontWeight:700,color:x.headText,borderBottom:`1px solid ${x.tableRowBorder}`,whiteSpace:"nowrap"},children:t},i))})}),e.jsx("tbody",{children:ve.map(t=>{return e.jsxs("tr",{onMouseEnter:()=>he(t.id),onMouseLeave:()=>he(null),style:{background:pe===t.id?x.tableRowHoverBg:"transparent",borderBottom:`1px solid ${x.tableRowBorder}`,transition:"background 150ms"},children:[e.jsx("td",{style:{padding:"9px 12px",fontSize:12,color:x.cellText,maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.email}),e.jsx("td",{style:{padding:"9px 12px",fontSize:12,color:x.cellText},children:t.full_name||"â"}),e.jsx("td",{style:{padding:"9px 12px",fontSize:12,color:x.cellText,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(i=t.job_role_id,(null==(n=V.find(e=>e.id===i))?void 0:n.title)||"â")}),e.jsx("td",{style:{padding:"9px 12px"},children:e.jsx(L,{status:t.status,p:x})}),e.jsx("td",{style:{padding:"9px 12px",fontSize:11.5,color:x.mutedText,whiteSpace:"nowrap"},children:be(t.expires_at)}),e.jsx("td",{style:{padding:"9px 12px",fontSize:11.5,color:x.mutedText,whiteSpace:"nowrap"},children:be(t.created_at)}),e.jsx("td",{style:{padding:"9px 12px",textAlign:"right"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4},children:[t.token&&e.jsx(N,{variant:"ghost",p:x,onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/invite/${t.token}`),g({title:"Link copied!",description:"Share this link with the candidate."})},style:{width:28,height:28,padding:0,justifyContent:"center"},children:e.jsx(H,{style:{width:12,height:12}})}),e.jsxs(T,{children:[e.jsx(S,{asChild:!0,children:e.jsx("button",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:7,border:"none",background:"transparent",color:x.btnGhostText,cursor:"pointer",transition:"background 150ms"},onMouseEnter:e=>{e.currentTarget.style.background=x.btnGhostHoverBg,e.currentTarget.style.color=x.btnGhostHoverText},onMouseLeave:e=>{e.currentTarget.style.background="transparent",e.currentTarget.style.color=x.btnGhostText},children:e.jsx(D,{style:{width:14,height:14}})})}),e.jsxs(C,{align:"end",children:["pending"===t.status&&e.jsxs(k,{onClick:()=>ae(t),children:[e.jsx(z,{style:{width:13,height:13,marginRight:8}})," Edit"]}),e.jsxs(k,{onClick:()=>(async e=>{Z(!0);try{await r.from("candidate_invitations").update({expires_at:new Date(Date.now()+6048e5).toISOString(),status:"pending"}).eq("id",e.id),await r.functions.invoke("corporate-invite-candidates",{body:{corporate_id:p,job_role_id:e.job_role_id,candidates:[{email:e.email,full_name:e.full_name}],resend:!0}}),g({title:"Invitation resent",description:`Sent to ${e.email}`}),xe()}catch(t){g({title:"Error",description:t.message,variant:"destructive"})}Z(!1)})(t),disabled:Y,children:[e.jsx(O,{style:{width:13,height:13,marginRight:8}})," Resend Invite"]}),e.jsxs(k,{className:"text-destructive focus:text-destructive",onClick:()=>de(t.id),children:[e.jsx(P,{style:{width:13,height:13,marginRight:8}})," Delete"]})]})]})]})})]},t.id);var i,n})})]})}),me>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:12,flexWrap:"wrap",gap:8},children:[e.jsxs("span",{style:{fontSize:11.5,color:x.paginationText},children:["Page ",ce," of ",me," (",ue.length," total)"]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx(N,{variant:"outline",p:x,disabled:1===ce,onClick:()=>ge(e=>e-1),style:{width:32,height:32,padding:0,justifyContent:"center"},children:e.jsx(W,{style:{width:14,height:14}})}),e.jsx(N,{variant:"outline",p:x,disabled:ce===me,onClick:()=>ge(e=>e+1),style:{width:32,height:32,padding:0,justifyContent:"center"},children:e.jsx(A,{style:{width:14,height:14}})})]})]})]}),e.jsx("div",{style:{height:16}})]}),e.jsx(o,{open:!!ne,onOpenChange:e=>{e||ae(null)},children:e.jsxs(l,{className:"max-w-md",children:[e.jsx(s,{children:e.jsx(c,{children:"Edit Invitation"})}),ne&&e.jsx(X,{p:x,inv:ne,jobRoles:V,onClose:()=>ae(null),onSaved:xe})]})}),e.jsx(u,{open:!!oe,onOpenChange:e=>{e||de(null)},children:e.jsxs(m,{children:[e.jsxs(v,{children:[e.jsx(j,{children:"Delete Invitation"}),e.jsx(f,{children:"Are you sure? This action cannot be undone."})]}),e.jsxs(y,{children:[e.jsx(B,{onClick:()=>de(null),children:"Cancel"}),e.jsx(w,{onClick:async()=>
1{if(oe)try{const{error:e}=await r.from("candidate_invitations").delete().eq("id",oe);if(e)throw e;g({title:"Invitation deleted"}),de(null),xe()}catch(e){g({title:"Error",description:e.message,variant:"destructive"})}},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})};export{K 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.