PageSourceSearch

https://replikatie.com/assets/team-BC-5Wi5U.js

js replikatie.com collected 2026-10-02 01:41:37 UTC 27,454 bytes, 1 lines download raw bytes

1import{r as l,a as qe,j as e,c as Te,u as vt,b as jt,B as p,L as yt,s as v,t as c}from"./index-BRvF9KL5.js";import{u as _t,P as $e,g as bt,h as kt,i as wt,j as Nt,A as Ct,D as oe,k as ce,l as de,m as me,n as ue,S as F,a as V,b as U,c as H,d as A,C as St,p as he,q as At,r as Ee,o as Lt,f as W,t as X,v as It,w as Rt}from"./app-shell-C4kAfi3A.js";import{C as O}from"./card-DvO89iRO.js";import{I as j,L as xe}from"./label-DUNkUgV8.js";import{B as G}from"./badge-Da5XUyfp.js";import{X as Me,g as ze}from"./stripe-CsEycnAu.js";import{U as Tt}from"./katie-avatar.png.asset-gupalrgQ.js";import{P as J,T as Pe}from"./trash-2-CzqILa9H.js";import{c as fe}from"./createLucideIcon-DEyJk1z8.js";import{M as Et}from"./mail-Cj--3EnX.js";import"./useServerFn-CkqOwPA1.js";import"./activity-log-CTKx31u4.js";import"./check-_HCx1sfW.js";import"./auth-middleware-4JOqsKeD.js";import"./use-subscription-BF_qmTm6.js";import"./logo-Djfh2_9Z.js";import"./shield-check-B8qWVIDb.js";import"./log-out-DWZBRHkw.js";const Mt=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],zt=fe("bot",Mt);const Pt=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ot=fe("copy",Pt);const Bt=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],qt=fe("pencil",Bt);var Y="Switch",[$t]=Nt(Y),[Dt,Ft]=$t(Y),De=l.forwardRef((i,u)=>{const{__scopeSwitch:o,name:k,checked:_,defaultChecked:g,required:T,disabled:N,value:f="on",onCheckedChange:B,form:n,...h}=i,[E,M]=l.useState(null),w=qe(u,$=>M($)),Z=l.useRef(!1),b=E?n||!!E.closest("form"):!0,[q,Q]=_t({prop:_,defaultProp:g??!1,onChange:B,caller:Y});return e.jsxs(Dt,{scope:o,checked:q,disabled:N,children:[e.jsx($e.button,{type:"button",role:"switch","aria-checked":q,"aria-required":T,"data-state":He(q),"data-disabled":N?"":void 0,disabled:N,value:f,...h,ref:w,onClick:bt(i.onClick,$=>{Q(ee=>!ee),b&&(Z.current=$.isPropagationStopped(),Z.current||$.stopPropagation())})}),b&&e.jsx(Ue,{control:E,bubbles:!Z.current,name:k,value:f,checked:q,required:T,disabled:N,form:n,style:{transform:"translateX(-100%)"}})]})});De.displayName=Y;var Fe="SwitchThumb",Ve=l.forwardRef((i,u)=>{const{__scopeSwitch:o,...k}=i,_=Ft(Fe,o);return e.jsx($e.span,{"data-state":He(_.checked),"data-disabled":_.disabled?"":void 0,...k,ref:u})});Ve.displayName=Fe;var Vt="SwitchBubbleInput",Ue=l.forwardRef(({__scopeSwitch:i,control:u,checked:o,bubbles:k=!0,..._},g)=>{const T=l.useRef(null),N=qe(T,g),f=kt(o),B=wt(u);return l.useEffect(()=>{const n=T.current;if(!n)return;const h=window.HTMLInputElement.prototype,M=Object.getOwnPropertyDescriptor(h,"checked").set;if(f!==o&&M){const w=new Event("click",{bubbles:k});M.call(n,o),n.dispatchEvent(w)}},[f,o,k]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o,..._,tabIndex:-1,ref:N,style:{..._.style,...B,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Ue.displayName=Vt;function He(i){return i?"checked":"unchecked"}var We=De,Ut=Ve;const pe=l.forwardRef(({className:i,...u},o)=>e.jsx(We,{className:Te("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",i),...u,ref:o,children:e.jsx(Ut,{className:Te("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));pe.displayName=We.displayName;const ge=[{key:"ceo",title:"CEO"},{key:"regional",title:"Regional Manager"},{key:"associate",title:"Associate Supervisor"},{key:"rep",title:"Sales Rep"}];function Ht(i){if(Array.isArray(i)){const u=i.filter(o=>
1o&&typeof o=="object"&&"key"in o&&"title"in o);if(u.length>0)return u}else if(i&&typeof i=="object"){const u=i,o=["ceo","regional","associate","rep"],k=o.filter(g=>g in u).map(g=>({key:g,title:u[g]})),_=Object.keys(u).filter(g=>!o.includes(g)).map(g=>({key:g,title:u[g]}));return[...k,..._].length>0?[...k,..._]:ge}return ge}const Oe=/^[A-Za-z]+(?:[ '-][A-Za-z]+)*$/,Wt=/^[A-Za-z][A-Za-z ]*$/,Zt=Lt({first_name:W().trim().min(1).max(50).regex(Oe,"Letters only"),last_name:W().trim().min(1).max(50).regex(Oe,"Letters only"),gender:Rt(["male","female","prefer not to say"]),age:X().int().min(14).max(100),archetype_id:W().uuid().nullable(),works_weekends:It(),work_start:W().regex(/^\d{2}:\d{2}$/),work_end:W().regex(/^\d{2}:\d{2}$/),lunch_minutes:X().int().min(0).max(240),break1_minutes:X().int().min(0).max(120),break2_minutes:X().int().min(0).max(120),role_title:W().trim().min(1).max(50).regex(Wt,"Letters only").nullable()}).refine(i=>{const[u,o]=i.work_start.split(":").map(Number),[k,_]=i.work_end.split(":").map(Number),g=k*60+_-(u*60+o);return g>0&&g<=480},{message:"Workday must be greater than 0 and at most 8 hours",path:["work_end"]}),Be={first_name:"",last_name:"",gender:"prefer not to say",age:30,archetype_id:null,works_weekends:!1,work_start:"09:00",work_end:"17:00",lunch_minutes:30,break1_minutes:15,break2_minutes:15,role_title:null,company_id:null,user_id:"",level:null,manager_id:null};function us(){const{user:i}=vt(),u=jt(),[o,k]=l.useState([]),[_,g]=l.useState([]),[T,N]=l.useState(!1),[f,B]=l.useState(null),[n,h]=l.useState(Be),[E,M]=l.useState(!1),[w,Z]=l.useState(!1),[b,q]=l.useState(null),[Q,$]=l.useState(!1),[ee,Ze]=l.useState(!1),[te,Ke]=l.useState([]),[Xe,se]=l.useState(!1),[ve,je]=l.useState(""),[ye,_e]=l.useState(""),[be,ke]=l.useState(!1),[ae,Ge]=l.useState([]),[Je,Ye]=l.useState(null),[d,R]=l.useState(ge),[Qe,z]=l.useState(!1),[we,Ne]=l.useState(!1),[et,ne]=l.useState(!1),[x,P]=l.useState({first_name:"",last_name:"",email:"",level:"rep",role_title:"",manager_id:""}),[Ce,Se]=l.useState(!1),[tt,Ae]=l.useState([]),[st,re]=l.useState(null);async function L(){let t=null;if(i){const{data:y}=await v.from("user_roles").select("role, company_id").eq("user_id",i.id).maybeSingle();if(Z(y?.role==="employer"),Ze(y?.role==="employee"),q(y?.company_id??null),t=y?.company_id??null,$(!0),y?.role==="employee"){u({to:"/dashboard",replace:!0});return}if(y?.company_id){const{data:S}=await v.from("companies").select("level_titles").eq("id",y.company_id).maybeSingle();S?.level_titles&&R(Ht(S.level_titles))}}const[s,a]=await Promise.all([v.from("team_members").select("*").order("first_name"),v.from("archetypes").select("id,name").order("name")]);k(s.data??[]);const r=["sloth","average","workaholic"],I=(a.data??[]).slice().sort((y,S)=>{const ie=r.indexOf(y.name.toLowerCase()),le=r.indexOf(S.name.toLowerCase());return ie!==-1||le!==-1?(ie===-1?999:ie)-(le===-1?999:le):y.name.localeCompare(S.name)});g(I);const{data:C}=await v.from("ai_accounts").select("*").order("created_at",{ascending:!1});if(Ke(C??[]),i){const y=(s.data??[]).find(S=>S.user_id===i.id);Ye(y?.level??null)}const{data:D}=await v.from("team_invites").select("*").is("accepted_at",null).order("created_at",{ascending:!1});if(Ge(D??[]),t){const{data:y}=await v.from("user_roles").select("user_id, role, billing_paused").eq("company_id",t);Ae(y??[])}else Ae([])}if(l.useEffect(()=>{i&&L()},[i]),!Q||ee)return null;function at(){B(null),h(Be),N(!0)}function nt(t){B(t),h({first_name:t.first_name,last_name:t.last_name,gender:t.gender,age:t.age,archetype_id:t.archetype_id,works_weekends:t.works_weekends,work_start:t.work_start.slice(0,5),work_end:t.work_end.slice(0,5),lunch_minutes:t.lunch_minutes,break1_minutes:t.break1_minutes,break2_minutes:t.break2_minutes,role_title:t.role_title,company_id:t.company_id,user_id:t.user_id,level:t.level??null,manager_id:t.manager_id??null}),N(!0)}async function rt(){if(!i)return;const t=Zt.safeParse({...n,role_title:n.role_title??null});if(!t.success){c.error(t.error.issues[0].message);return}M(!0);let s;if(f){const a=w||!f.role_title,r={...t.data,level:n.level??null,manager_id:n.manager_id??null},I=a?r:(()=>{const{role_title:C,...D}=r;return D})();({error:s}=await v.from("team_members").update(I).eq("id",f.id))}else{const a={...t.data,user_id:i.id,company_id:b,level:n.level??null,manager_id:n.manager_id??null};({error:s}=await v.from("team_members").insert(a))}if(M(!1),s){c.error(s.message);return}c.success(f?"Updated":"Team member added"),N(!1),await L()}async function it(t){if(!confirm("Remove this sub-account? Their historical sends and reports will be kept. They will lose access immediately and their seat will stop being billed."))return;const s=o.find(r=>r.id===t),{error:a}=await v.from("team_members").delete().eq("id",t);if(a){c.error(a.message);return}if(s?.user_id&&b&&s.user_id!==i?.id){await v.from("user_roles").delete().eq("user_id",s.user_id
1).eq("company_id",b).eq("role","employee");try{await Ee({data:{environment:ze()}})}catch{}}c.success("Removed"),await L()}async function lt(t,s){if(!b||!t.user_id)return;re(t.id);const{error:a}=await v.from("user_roles").update({billing_paused:s}).eq("user_id",t.user_id).eq("company_id",b).eq("role","employee");if(a){re(null),c.error(a.message);return}try{const r=await Ee({data:{environment:ze()}});if(r&&typeof r=="object"&&"error"in r)throw new Error(r.error);c.success(s?"Billing paused for this sub-account":"Billing resumed for this sub-account")}catch(r){c.error(`Updated locally, but billing sync failed: ${r.message}`)}re(null),await L()}async function ot(){if(!i||!b)return;const t=ve.trim(),s=ye.trim().toLowerCase();if(t.length<1||t.length>80){c.error("Name is required");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)){c.error("Enter a valid sending email");return}ke(!0);const{error:a}=await v.from("ai_accounts").insert({display_name:t,sending_email:s,company_id:b,owner_id:i.id,is_active:!0});if(ke(!1),a){c.error(a.message);return}c.success("Outreach Agent added"),je(""),_e(""),se(!1),await L()}async function ct(t){const{error:s}=await v.from("ai_accounts").update({is_active:!t.is_active}).eq("id",t.id);if(s){c.error(s.message);return}await L()}async function dt(t){if(!confirm("Remove this Outreach Agent? Past sends remain in reports."))return;const{error:s}=await v.from("ai_accounts").delete().eq("id",t);if(s){c.error(s.message);return}c.success("Removed"),await L()}const Le=t=>t&&d.find(s=>s.key===t)?.title||t||"Unassigned",mt=d[0]?.key??"ceo",ut=w?mt:Je??d[d.length-1]?.key??"rep",K=d.findIndex(t=>t.key===ut),ht=w||K>=0&&K<d.length-1;function Ie(){return w?d:K>=0?d.slice(K+1):d}function Re(t){return`${window.location.origin}/signup?invite=${t}`}async function xt(){if(!b)return;const t=d.map(r=>({key:r.key.trim().toLowerCase().replace(/[^a-z0-9_]/g,"_"),title:r.title.trim().slice(0,40)})).filter(r=>r.key&&r.title);if(t.length===0){c.error("Need at least one level");return}const s=new Set;for(const r of t){if(s.has(r.key)){c.error(`Duplicate level key: ${r.key}`);return}s.add(r.key)}Ne(!0);const{error:a}=await v.from("companies").update({level_titles:t}).eq("id",b);if(Ne(!1),a){c.error(a.message);return}R(t),c.success("Hierarchy saved"),z(!1)}async function pt(){if(!i||!b)return;const t=x.first_name.trim(),s=x.last_name.trim(),a=x.email.trim().toLowerCase();if(!t||!s){c.error("Name is required");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)){c.error("Valid email required");return}if(!Ie().some(S=>S.key===x.level)){c.error("Pick a level below yours");return}Se(!0);const r=o.find(S=>S.user_id===i.id),I=x.manager_id||r?.id||null,{data:C,error:D}=await v.from("team_invites").insert({company_id:b,inviter_user_id:i.id,manager_id:I,email:a,first_name:t,last_name:s,level:x.level,role_title:x.role_title.trim()||null}).select().single();if(Se(!1),D){c.error(D.message);return}const y=Re(C.token);try{await navigator.clipboard.writeText(y),c.success("Invite created — link copied to clipboard")}catch{c.success("Invite created")}P({first_name:"",last_name:"",email:"",level:"rep",role_title:"",manager_id:""}),ne(!1),await L()}async function gt(t){if(!confirm("Revoke this invite?"))return;const{error:s}=await v.from("team_invites").delete().eq("id",t);if(s){c.error(s.message);return}c.success("Invite revoked"),await L()}async function ft(t){const s=Re(t);try{await navigator.clipboard.writeText(s),c.success("Invite link copied")}catch{c.error("Could not copy")}}return e.jsxs(Ct,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6 gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Tt,{className:"h-6 w-6 text-primary mt-1"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Your Team"}),e.jsx(G,{variant:"secondary",children:o.length})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Sales Reps and Their Archetypes"})]})]}),e.jsxs(oe,{open:T,onOpenChange:N,children:[e.jsx(ce,{asChild:!0,children:e.jsxs(p,{onClick:at,className:"gap-2",children:[e.jsx(J,{className:"h-4 w-4"}),"Add Team Member"]})}),e.jsxs(de,{className:"max-w-2xl",children:[e.jsx(me,{children:e.jsx(ue,{children:f?"Edit Team Member":"Add Team Member"})}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4 py-2",children:[e.jsx(m,{label:"First name",children:e.jsx(j,{value:n.first_name,onChange:t=>h({...n,first_name:t.target.value}),maxLength:50})}),e.jsx(m,{label:"Last name",children:e.jsx(j,{value:n.last_name,onChange:t=>h({...n,last_name:t.target.value}),maxLength:50})}),e.jsx(m,{label:"Gender",children:e.jsxs(F,{value:n.gender,onValueChange:t=>h({...n,gender:t}),children:[e.jsx(V,{children:e.jsx(U,{})}
1),e.jsxs(H,{children:[e.jsx(A,{value:"male",children:"Male"}),e.jsx(A,{value:"female",children:"Female"}),e.jsx(A,{value:"prefer not to say",children:"Prefer not to say"})]})]})}),e.jsx(m,{label:"Age",children:e.jsx(j,{type:"number",min:14,max:100,value:n.age,onChange:t=>h({...n,age:parseInt(t.target.value||"0",10)})})}),e.jsx(m,{label:`Role in company${f&&f.role_title&&!w?" (locked — boss only)":" (letters only)"}`,children:e.jsx(j,{value:n.role_title??"",onChange:t=>h({...n,role_title:t.target.value.replace(/[^A-Za-z ]/g,"")||null}),maxLength:50,placeholder:"e.g. Sales Rep",disabled:!!f&&!!f.role_title&&!w})}),e.jsx(m,{label:"Archetype",children:e.jsxs(F,{value:n.archetype_id??"",onValueChange:t=>h({...n,archetype_id:t||null}),children:[e.jsx(V,{children:e.jsx(U,{placeholder:"Select archetype"})}),e.jsx(H,{children:_.map(t=>e.jsx(A,{value:t.id,children:t.name},t.id))})]})}),e.jsx(m,{label:"Hierarchy level",children:e.jsxs(F,{value:n.level??"none",onValueChange:t=>h({...n,level:t==="none"?null:t}),children:[e.jsx(V,{children:e.jsx(U,{})}
1),e.jsxs(H,{children:[e.jsx(A,{value:"none",children:"Unassigned"}),d.map(t=>e.jsx(A,{value:t.key,children:t.title},t.key))]})]})}),e.jsx(m,{label:"Reports to",children:e.jsxs(F,{value:n.manager_id??"none",onValueChange:t=>h({...n,manager_id:t==="none"?null:t}),children:[e.jsx(V,{children:e.jsx(U,{placeholder:"No manager"})}),e.jsxs(H,{children:[e.jsx(A,{value:"none",children:"No manager (top)"}),o.filter(t=>!f||t.id!==f.id).map(t=>e.jsxs(A,{value:t.id,children:[t.first_name," ",t.last_name,t.level?` · ${Le(t.level)}`:""]},t.id))]})]})}),e.jsx(m,{label:"Works weekends",children:e.jsxs("div",{className:"flex items-center h-10",children:[e.jsx(St,{checked:n.works_weekends,onCheckedChange:t=>h({...n,works_weekends:!!t})}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Check if yes"})]})}),e.jsx(m,{label:"Work start",children:e.jsx(j,{type:"time",value:n.work_start,onChange:t=>h({...n,work_start:t.target.value})})}),e.jsx(m,{label:"Work end",children:e.jsx(j,{type:"time",value:n.work_end,onChange:t=>h({...n,work_end:t.target.value})})}),e.jsx(m,{label:"Lunch (minutes)",children:e.jsx(j,{type:"number",min:0,max:240,value:n.lunch_minutes,onChange:t=>h({...n,lunch_minutes:parseInt(t.target.value||"0",10)})})}),e.jsx(m,{label:"Break 1 (minutes)",children:e.jsx(j,{type:"number",min:0,max:120,value:n.break1_minutes,onChange:t=>h({...n,break1_minutes:parseInt(t.target.value||"0",10)})})}),e.jsx(m,{label:"Break 2 (minutes)",children:e.jsx(j,{type:"number",min:0,max:120,value:n.break2_minutes,onChange:t=>h({...n,break2_minutes:parseInt(t.target.value||"0",10)})})})]}),e.jsxs(he,{children:[e.jsx(p,{variant:"ghost",onClick:()=>N(!1),children:"Cancel"}),e.jsx(p,{onClick:rt,disabled:E,children:E?"Saving…":f?"Save changes":"Add member"})]})]})]})]}),o.length===0?e.jsxs(O,{className:"p-10 text-center text-muted-foreground",children:["No team members yet. Click ",e.jsx("span",{className:"font-medium",children:"Add Team Member"})," to create your first sales rep."]}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:o.map(t=>{const s=_.find(C=>C.id===t.archetype_id),a=tt.find(C=>C.user_id===t.user_id&&C.role==="employee"),r=w&&!!a&&t.user_id!==i?.id,I=!!a?.billing_paused;return e.jsxs(O,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold",children:[t.first_name," ",t.last_name]}),t.role_title&&e.jsx("div",{className:"text-xs font-medium text-primary mt-0.5",children:t.role_title}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[s?.name??"No archetype"," · age ",t.age," · ",t.gender]}),r&&I&&e.jsx(G,{variant:"secondary",className:"mt-2",children:"Billing paused"})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>nt(t),children:e.jsx(qt,{className:"h-4 w-4"})}),e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>it(t.id),children:e.jsx(Pe,{className:"h-4 w-4 text-destructive"})})]})]}),e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground space-y-1",children:[e.jsxs("div",{children:["Hours: ",t.work_start.slice(0,5),"–",t.work_end.slice(0,5),t.works_weekends?" · weekends":""]}),e.jsxs("div",{children:["Lunch ",t.lunch_minutes,"m · Breaks ",t.break1_minutes,"m / ",t.break2_minutes,"m"]})]}),r&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-border flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium",children:"Billing for this sub-account"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:I?"Not counted in your seat total.":"Counted in your seat total."})]}),e.jsx(pe,{checked:!I,disabled:st===t.id,onCheckedChange:C=>lt(t,!C),"aria-label":"Toggle billing for this sub-account"})]}),e.jsxs("div",{className:"mt-4 pt-3 border-t border-border",children:[e.jsx(yt,{to:"/reports",search:{empId:t.id},children:e.jsxs(p,{size:"sm",variant:"outline",className:"w-full gap-2",children:[e.jsx(At,{className:"h-4 w-4"})," Report"]})}),e.jsxs("p",{className:"mt-1.5 text-[10px] text-muted-foreground text-center",children:["Visible to you & ",t.first_name," only"]})]})]},t.id)})}),w&&e.jsxs("section",{className:"mt-12",children:[e.jsx("div",{className:"border-t border-dotted border-border mb-8"}),e.jsxs("div",{className:"flex items-center justify-between mb-4 gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(zt,{className:"h-6 w-6 text-primary"}),e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Outreach Agents"}),e.jsx(G,{variant:"secondary",children:te.length})]}),e.jsxs(oe,{open:Xe,onOpenChange:se,children:[e.jsx(ce,{asChild:!0,children:e.jsxs(p,{variant:"outline",className:"gap-2",children:[e.jsx(J,{className:"h-4 w-4"}),"Add Outreach Agent"]})}),e.jsxs(de,{children:[e.jsx(me,{children:e.jsx(ue,{children:"Add Outreach Agent"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsx(m,{label:"Display name",children:e.jsx(j,{value:ve,onChange:t=>je(t.target.value),maxLength:80,placeholder:"e.g. Shirley Timple"})}),e.jsx(m,{label:"Sending email",children:e.jsx(j,{type:"email",value:ye,onChange:t=>_e(t.target.value),placeholder:"[email protected]"})}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"The email address this Outreach Agent sends from. No login is created — only you can send through it."})]}),e.jsxs(he,{children:[e.jsx(p,{variant:"ghost",onClick:()=>se(!1),children:"Cancel"}),e.jsx(p,{onClick:ot,disabled:be,children:be?"Adding…":"Add"})]})]})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4 -mt-2",children:"Outreach Agents are digital representatives that operate from a dedicated email account and perform outreach activities on behalf of your organization."}),te.length===0?e.jsx(O,{className:"p-10 text-center text-muted-foreground",children:"No Outreach Agents yet. Add one to send through a dedicated mailbox."}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:te.map(t=>e.jsxs(O,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold truncate",children:t.display_name}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:t.sending_email})]}),e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>dt(t.id),children:e.jsx(Pe,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"mt-4 pt-3 border-t border-border flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:t.is_active?"Active":"Paused"}),e.jsx(pe,{checked:t.is_active,onCheckedChange:()=>ct(t)})]})]},t.id))})]}),ht&&e.jsxs("section",{className:"mt-12",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Et,{className:"h-6 w-6 text-primary"}),e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Invite by email"}),e.jsxs(G,{variant:"secondary",children:[ae.length," pending"]})]}),e.jsxs(oe,{open:et,onOpenChange:ne,children:[e.jsx(ce,{asChild:!0,children:e.jsxs(p,{className:"gap-2",children:[e.jsx(J,{className:"h-4 w-4"}),"Invite teammate"]})}),e.jsxs(de,{children:[e.jsx(me,{children:e.jsx(ue,{children:"Invite a teammate by email"})}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4 py-2",children:[e.jsx(m,{label:"First name",children:e.jsx(j,{value:x.first_name,onChange:t=>P({...x,first_name:t.target.value}),maxLength:50})}),e.jsx(m,{label:"Last name",children:e.jsx(j,{value:x.last_name,onChange:t=>P({...x,last_name:t.target.value}),maxLength:50})}),e.jsx(m,{label:"Email",children:e.jsx(j,{type:"email",value:x.email,onChange:t=>P({...x,email:t.target.value}),placeholder:"[email protected]"})}),e.jsx(m,{label:"Level",children:e.jsxs(F,{value:x.level,onValueChange:t=>P({...x,level:t}),children:[e.jsx(V,{children:e.jsx(U,{})}),e.jsx(H,{children:Ie().map(t=>e.jsx(A,{value:t.key,children:t.title},t.key))})]})}),e.jsx(m,{label:"Job title (optional)",children:e.jsx(j,{value:x.role_title,onChange:t=>P({...x,role_title:t.target.value.replace(/[^A-Za-z ]/g,"")}),maxLength:50,placeholder:"e.g. Outbound Rep"})}),e.jsx(m,{label:"Direct manager (optional)",children:e.jsxs(F,{value:x.manager_id||"self",onValueChange:t=>P({...x,manager_id:t==="self"?"":t}),children:[e.jsx(V,{children:e.jsx(U,{})}
1),e.jsxs(H,{children:[e.jsx(A,{value:"self",children:"Me"}),o.filter(t=>{if(!t.level)return!1;const s=d.findIndex(r=>r.key===t.level),a=d.findIndex(r=>r.key===x.level);return s>=0&&a>=0&&s<a}).map(t=>e.jsxs(A,{value:t.id,children:[t.first_name," ",t.last_name]},t.id))]})]})})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"We'll create the invite and copy a personalized signup link to your clipboard. Paste it into an email to your teammate — they finish setup, then land in the right level under the right manager."}),e.jsxs(he,{children:[e.jsx(p,{variant:"ghost",onClick:()=>ne(!1),children:"Cancel"}),e.jsx(p,{onClick:pt,disabled:Ce,children:Ce?"Creating…":"Create invite & copy link"})]})]})]})]}),ae.length===0?e.jsx(O,{className:"p-6 text-sm text-muted-foreground text-center",children:"No pending invites."}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-3",children:ae.map(t=>e.jsxs(O,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-medium truncate",children:[t.first_name," ",t.last_name]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:t.email}),e.jsxs("div",{className:"text-[11px] mt-1",children:[e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5",children:Le(t.level)}),t.role_title&&e.jsxs("span",{className:"ml-1 text-muted-foreground",children:["· ",t.role_title]})]})]}),e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>gt(t.id),title:"Revoke",children:e.jsx(Me,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs(p,{variant:"outline",size:"sm",className:"mt-3 w-full gap-2",onClick:()=>ft(t.token),children:[e.jsx(Ot,{className:"h-3.5 w-3.5"})," Copy invite link"]})]},t.id))})]}),w&&e.jsxs("section",{className:"mt-12",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight mb-2",children:"Company structure"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add, rename, or reorder the levels in your org. Top is the most senior. Members keep their existing level keys; only display titles and ordering change."}),e.jsxs(O,{className:"p-5 space-y-3",children:[d.map((t,s)=>e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(xe,{className:"text-[11px] text-muted-foreground",children:"Title"}),e.jsx(j,{value:t.title,onChange:a=>{const r=[...d];r[s]={...t,title:a.target.value.slice(0,40)},R(r),z(!0)},maxLength:40})]}),e.jsxs("div",{className:"w-32",children:[e.jsx(xe,{className:"text-[11px] text-muted-foreground",children:"Key"}),e.jsx(j,{value:t.key,onChange:a=>{const r=[...d];r[s]={...t,key:a.target.value.toLowerCase().replace(/[^a-z0-9_]/g,"_").slice(0,20)},R(r),z(!0)},maxLength:20})]}),e.jsx(p,{variant:"ghost",size:"icon",disabled:s===0,onClick:()=>{const a=[...d];[a[s-1],a[s]]=[a[s],a[s-1]],R(a),z(!0)},title:"Move up",children:"↑"}),e.jsx(p,{variant:"ghost",size:"icon",disabled:s===d.length-1,onClick:()=>{const a=[...d];[a[s+1],a[s]]=[a[s],a[s+1]],R(a),z(!0)},title:"Move down",children:"↓"}),e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>{R(d.filter((a,r)=>r!==s)),z(!0)},title:"Remove",children:e.jsx(Me,{className:"h-4 w-4 text-destructive"})})]},s)),e.jsxs("div",{className:"flex justify-between pt-2",children:[e.jsxs(p,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{R([...d,{key:`level_${d.length+1}`,title:"New Level"}]),z(!0)},children:[e.jsx(J,{className:"h-4 w-4"})," Add level"]}),e.jsx(p,{onClick:xt,disabled:!Qe||we,children:we?"Saving…":"Save hierarchy"})]})]})]})]})}function m({label:i,children:u}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs",children:i}),u]})}export{us as component};

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.