PageSourceSearch

https://initiocapital.com/assets/SettingsPage-D6jh0JhE.js

js initiocapital.com collected 2026-10-08 09:04:19 UTC 58,116 bytes, 6 lines download raw bytes

1import{c as ls,s as w,j as e,B as j,R as ie,T as Ee}from"./index-CWSYbuAR.js";import{O as ds}from"./OutreachSettingsTab-DyRlWvC5.js";import{u as Le,a as ee}from"./useQuery-Pk2LeOB6.js";import{u as I}from"./index-cLF8VOT_.js";import{C as L,a as R,b as M,c as $,d as W}from"./card-CDMLnNYQ.js";import{A as Re,h as De,a as qe,b as Oe,c as Te,d as Ue,e as Fe,f as Me,g as $e}from"./alert-dialog-Dfu_yzUV.js";import{u as G}from"./AuthContext-BEHTmcl5.js";import{D as ms}from"./download-_oVnDXzP.js";import{T as ye,ay as xs,D as Pe,Y as us,a as Ge,b as Be,c as We,e as Ye,az as P,aA as pe,d as hs,aB as ke,E as be,j as ps,S as F,X as gs}from"./AppShell-B8iMz4g3.js";import{B as q}from"./badge-gaYw3uxr.js";import{L as me,b as js,e as fs}from"./ScrollToTop-ByVCb_nq.js";import{r as y}from"./react-vendor-B8DbRJ_3.js";import{u as vs,b as ys,f as ce,C as Z}from"./useCredits-Dao1fOZX.js";import{u as bs,A as Se}from"./AppLayout-DIok04eD.js";import{C as Ns}from"./coins-BDWKFWpH.js";import{L as z}from"./loader-circle-DpVA9_ED.js";import{R as ws}from"./receipt-DolsLBUq.js";import{C as _s}from"./credit-card-C3Qkewqi.js";import{G as Cs}from"./GoogleReconnectBanner-CVLHMBbl.js";import{T as ks,a as Ss,b as oe,c as le}from"./tabs-CZPUIZp9.js";import{A as ge,a as je}from"./avatar-D_KBuEbR.js";import{S as Ke,a as Ve,b as He,c as Qe,d as Xe}from"./select-C1483cDL.js";import{u as Ne}from"./use-toast-CYrXNg79.js";import{u as re,a as Je,f as Ze}from"./useUnlockState-BXXgx8hv.js";import{u as As}from"./useCompanyPermissions-CLy76uBm.js";import{I as ne}from"./input-CFpZuH_Y.js";import{L as D}from"./label-BbGl7fcq.js";import{A as se,b as te}from"./alert-B8mQ6hWq.js";import{U as es}from"./user-plus--lSzhncL.js";import{M as B}from"./mail-DhExWD8O.js";import{C as we}from"./circle-alert-DucYfdPg.js";import{U as Ae}from"./users-BY9vtCxy.js";import{C as fe}from"./crown-YGW9TnzG.js";import{A as Is}from"./arrow-right-left-PhsDaUWo.js";import{X as Ie}from"./x-C79zfdNS.js";import{C as zs}from"./clock-DN3YV-LX.js";import{H as Es}from"./history-BW75q_k0.js";import{S as Ls}from"./shield-DE1rN69u.js";import{P as Rs}from"./pencil-Ds7wN_dw.js";import{f as ze}from"./format-ekxmF514.js";import{S as xe}from"./separator-BM-SxNC2.js";import{u as ss,c as Ds}from"./useUnipile-DuVsi9WO.js";import{L as _e}from"./linkedin-BGOfzX3k.js";import{M as ts}from"./message-circle-DOIzAqp6.js";import{C as qs}from"./circle-check-BzkasNJV.js";import{C as as,a as ns,b as is}from"./collapsible-DxDoF8OQ.js";import{G as ve}from"./google-logo-36WXA7lu.js";import{u as Os,l as Ts,C as Us}from"./useGmail-B2NMVDdD.js";import{I as rs}from"./info-CjCQIatx.js";import{C as Fs}from"./index-BEGMp0Xn.js";import{M as Ms}from"./mic-ZjwqsZyO.js";import{C as $s}from"./calendar-clock-BMDd6kdr.js";import{F as Ps}from"./FinancialConnectionCard-CEyqrcr_.js";import{a as Gs,f as Bs}from"./useMeetingIntelligence-DdVpV58t.js";import{S as Ws}from"./settings-2-CxDqIlKx.js";import{C as Ys}from"./dropdown-menu-prmhAJwR.js";import{S as Ks}from"./settings-yjppg44S.js";import"./useInstantly-CFEMxw15.js";import"./OutreachGuidelinesCard-B_9zAGbd.js";import"./textarea-UZKA8J6E.js";import"./checkbox-nRXLAs5Q.js";import"./bot-DTsbBM7C.js";import"./rotate-ccw-B9NkOjUF.js";import"./save-6P_brvi6.js";import"./message-square-BSfwnMjE.js";import"./list-checks-Bxadkirq.js";import"./sparkles--vTQE1TX.js";import"./target-vj4tjKN3.js";import"./progress-BNE_zhY7.js";import"./scroll-area-D3P2tj1u.js";import"./flame-DvOrLbwk.js";import"./send-9xKr1B3e.js";import"./index-BFkE4B95.js";import"./proxy-DhIE7uZ4.js";import"./trending-up-z_cpI6UV.js";import"./zap-DMvYvLlm.js";import"./calendar-C7IoxwHl.js";import"./index-CWAqz-SW.js";import"./handshake-CLSYb5uw.js";import"./briefcase-CgI7J5Bx.js";import"./search-TYnvlkQ7.js";import"./arrow-up-right-vJzLMDWh.js";import"./file-text-DWQiS9X_.js";import"./arrow-left-ZWtCe06B.js";import"./recordTouch-D5TxfSI6.js";import"./bookingLinks-DNod1y5u.js";import"./external-link-DN4BYQO0.js";import"./arrow-right-Oq-q6r5k.js";import"./plus-eLxLHAHn.js";import"./engagementDelivery-BmWFe_Vp.js";import"./InitioMark-B3n7wBK1.js";import"./partnerLogo-Bla-3p6a.js";import"./BugReportButton-C-J8FKaJ.js";import"./usePartnerAdminScope-MiVZwX-L.js";import"./fundingAccess-C8OeB085.js";import"./layout-dashboard-BSkwf7A5.js";import"./folder-open-D1zuArF8.js";import"./landmark-DkLN4glB.js";import"./wrench-C8zLKUmZ.js";import"./FundManagerSidebar-WnOcE8yU.js";import"./usePlatformBrandName-CGHsvJZG.js";import"./chart-pie-BoNljJ9V.js";import"./headphones-CAvjB13W.js";import"./PartnerSidebar-DV9q_OdW.js";import"./dollar-sign-CXQ_4WBJ.js";import"./book-open-CzkoJj3y.js";import"./bell-B09h55_L.js";import"./pin-CJ-bUOb6.js";import"./en-US-DL7Z7JHb.js";import"./constructFrom-rJN6zrQ_.js";import"./index-DX40Xcfv.js";import"./building-2-DNhw7jhW.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 Vs=ls("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);function Hs(){const{user:s}=G(),n=Le(),{data:l=[]}=ee({queryKey:["data-requests",s==null?void 0:s.id],enabled:!!s,queryFn:async()=>(await w.from("data_requests").select("*").eq("user_id",s.id).order("created_at",{ascending:!1}).limit(5)).data??[]}),i=d=>l.some(h=>h.kind===d&&h.status!=="done"&&h.status!=="rejected"),t=async d=>{const{error:h}=await w.from("data_requests").insert({user_id:s.id,kind:d});h?I.error("Couldn't send the request — please try again."):(I.success(d==="export"?"We'll email you a copy of your data.":"Deleti
6on requested — we'll confirm by email."),n.invalidateQueries({queryKey:["data-requests"]}))};return e.jsx(L,{children:e.jsxs(R,{className:"space-y-2 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your data"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(j,{size:"sm",variant:"outline",disabled:i("export"),onClick:()=>t("export"),children:[e.jsx(ms,{className:"mr-1 h-4 w-4"}),i("export")?"Export requested":"Request a copy of my data"]}),e.jsxs(Re,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(j,{size:"sm",variant:"outline",className:"text-destructive",disabled:i("delete"),children:[e.jsx(ye,{className:"mr-1 h-4 w-4"}),i("delete")?"Deletion requested":"Delete my account"]})}),e.jsxs(qe,{children:[e.jsxs(Oe,{children:[e.jsx(Te,{children:"Delete your account?"}),e.jsx(Ue,{children:"Our team will confirm by email, then permanently delete your account and company data."})]}),e.jsxs(Fe,{children:[e.jsx(Me,{children:"Cancel"}),e.jsx($e,{onClick:()=>t("delete"),children:"Request deletion"})]})]})]})]})]})})}const Qs={initio_os:"Initio OS"},Xs=s=>Qs[s]??s.replace(/_/g," ");function Js(){const{rows:s,loading:n}=xs(),l=s.some(i=>i.plan_key==="initio_os"&&i.status==="active");return e.jsxs("div",{className:"rounded-xl border border-border bg-card px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm font-semibold",children:"Your plan"}),e.jsx(me,{to:"/billing",className:"text-xs text-primary hover:underline",children:"Billing"})]}),n?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading…"}):s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No plan on this account yet."}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left font-medium py-1",children:"Plan"}),e.jsx("th",{className:"text-left font-medium",children:"Status"}),e.jsx("th",{className:"text-left font-medium",children:"Since"})]})}),e.jsx("tbody",{children:s.map(i=>e.jsxs("tr",{className:"border-t border-border",children:[e.jsx("td",{className:"py-1.5 capitalize",children:Xs(i.plan_key)}),e.jsx("td",{children:e.jsx(q,{variant:i.status==="active"?"default":"secondary",children:i.status})}),e.jsx("td",{children:i.granted_at?new Date(i.granted_at).toLocaleDateString():"—"})]},i.id))})]}),!n&&!l&&e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx("p",{className:"text-xs",children:"Initio OS — put in requests and agents build them, with monthly tokens."}),e.jsx(j,{size:"sm",asChild:!0,children:e.jsx(me,{to:"/pricing",children:"See plan"})})]})]})}const Zs={purchase:"Top-up purchase",tier_monthly_grant:"Monthly plan credits",tier_credits_expired:"Unused plan credits expired"},et=s=>Zs[s]??s.replace(/_/g," ").replace(/^\w/,n=>n.toUpperCase());function st(){const{user:s}=G(),{balance:n,isLow:l,tierKey:i}=vs(),{busy:t,buyTopup:d,buyTier:h}=bs(),p=y.useRef(null),v=ee({queryKey:["credit-ledger",s==null?void 0:s.id],enabled:!!(s!=null&&s.id),queryFn:async()=>(await w.from("credit_ledger").select("id, delta, balance_after, action, ref_id, created_at").eq("user_id",s.id).order("created_at",{ascending:!1}).limit(25)).data??[]});return y.useEffect(()=>{const c=new URLSearchParams(window.location.search);c.get("tab")==="billing"&&setTimeout(()=>{var f;return(f=p.current)==null?void 0:f.scrollIntoView({behavior:"smooth",block:"start"})},200),c.get("purchase")==="canceled"&&I.message("Checkout canceled — nothing was charged.")},[]),e.jsx("div",{ref:p,id:"credits",children:e.jsxs(L,{children:[e.jsxs(M,{className:"pb-2",children:[e.jsxs($,{className:"text-base flex items-center gap-2",children:[e.jsx(Ns,{className:"h-4 w-4 text-primary"})," Credits"]}),e.jsxs(W,{children:["Balance: ",e.jsx("span",{className:"font-semibold text-foreground",children:n.toLocaleString()})," credits",l&&e.jsx("span",{className:"ml-2 text-destructive",children:"Running low — top up to keep missions moving."})]})]}),e.jsxs(R,{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Monthly plans · credits refresh each month and don't roll over"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:ys.map(c=>{const f=i===c.key;return e.jsxs("div",{className:`rounded-lg border p-3 space-y-1 ${f?"border-primary":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-semibold",children:c.name}),f&&e.jsx(q,{variant:"secondary",children:"Your plan"})]}),e.jsxs("div",{className:"text-lg font-semibold",children:[ce(c.price_cents),e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"/mo"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[c.credits.toLocaleStr
6ing()," credits every month"]}),e.jsx(j,{size:"sm",variant:f?"outline":"default",className:"w-full",disabled:f||t===c.key,onClick:()=>h(c.key),children:t===c.key?e.jsx(z,{className:"h-3.5 w-3.5 animate-spin"}):f?"Current plan":`Choose ${c.name} · ${ce(c.price_cents)}/mo`})]},c.key)})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border p-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:"One-off top-up"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[Z.credits," credits for ",ce(Z.price_cents)," · top-up credits don't expire"]})]}),e.jsx(j,{size:"sm",variant:"outline",disabled:t===Z.key,onClick:d,children:t===Z.key?e.jsx(z,{className:"h-3.5 w-3.5 animate-spin"}):`${ce(Z.price_cents)} top-up · ${Z.credits} credits`})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"History"}),e.jsxs("div",{className:"divide-y divide-border rounded-lg border border-border text-xs",children:[(v.data??[]).length===0&&e.jsx("div",{className:"p-2 text-muted-foreground",children:"No activity yet."}),(v.data??[]).map(c=>e.jsxs("div",{className:"flex items-center justify-between p-2",children:[e.jsx("span",{children:et(c.action)}),e.jsxs("span",{className:"flex gap-3",children:[e.jsxs("span",{className:c.delta<0?"text-destructive":"text-primary",children:[c.delta>0?"+":"",c.delta]}),e.jsx("span",{className:"text-muted-foreground w-16 text-right",children:c.balance_after}),e.jsx("span",{className:"text-muted-foreground w-20 text-right",children:new Date(c.created_at).toLocaleDateString()})]})]},c.id))]})]})]})]})})}function tt(){const{user:s}=G(),l=ee({queryKey:["credit-receipts",s==null?void 0:s.id],enabled:!!(s!=null&&s.id),queryFn:async()=>(await w.from("credit_purchases").select("id,bundle_key,credits_granted,amount_paid_cents,currency,status,created_at").eq("user_id",s.id).order("created_at",{ascending:!1}).limit(25)).data??[]}).data??[];return e.jsxs(L,{children:[e.jsxs(M,{className:"pb-2",children:[e.jsxs($,{className:"text-base flex items-center gap-2",children:[e.jsx(ws,{size:16,className:"text-primary"})," Receipts"]}),e.jsx(W,{children:"Your purchases. Card details are managed securely at checkout."})]}),e.jsxs(R,{className:"space-y-1",children:[l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No purchases yet."}):l.map(i=>e.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 text-sm last:border-0",children:[e.jsxs("span",{children:[new Date(i.created_at).toLocaleDateString()," · ",i.credits_granted??0," credits"]}),e.jsxs("span",{className:"text-muted-foreground",children:[i.amount_paid_cents!=null?`${(i.amount_paid_cents/100).toFixed(2)} ${(i.currency??"usd").toUpperCase()}`:""," · ",i.status]})]},i.id)),e.jsxs("p",{className:"flex items-center gap-1.5 pt-2 text-xs text-muted-foreground",children:[e.jsx(_s,{size:12})," Payment methods: managed at checkout."]})]})]})}const cs=s=>{const[n,l]=y.useState([]),[i,t]=y.useState([]),[d,h]=y.useState(!0),{user:p,isAdmin:v,isAdvisor:c}=G(),{effectiveUserId:f,isImpersonating:_,realUserId:m}=re(),{toast:o}=Ne(),S=s||f,{company:x}=Je(S||void 0),u=y.useCallback(async()=>{if(!(x!=null&&x.id)){h(!1);return}try{const{data:b,error:g}=await w.from("company_members").select("*").eq("company_id",x.id);if(g)throw g;const k=await Promise.all((b||[]).map(async T=>{const{data:U}=await w.from("profiles").select("email, full_name").eq("user_id",T.user_id).single();return{...T,profile:U||void 0}}));l(k);const{data:A,error:O}=await w.from("company_invitations").select("*").eq("company_id",x.id).is("accepted_at",null);if(O)throw O;t(A||[])}catch(b){console.error("Error fetching company members:",b)}finally{h(!1)}},[x==null?void 0:x.id]);y.useEffect(()=>{l([]),t([]),h(!0),u()},[u]);const r=async(b,g="member")=>{if(!(x!=null&&x.id))return{error:new Error("No company found")};const k=m;if(!k)return{error:new Error("Not authorized")};try{const{data:A,error:O}=await w.from("company_invitations").insert({company_id:x.id,email:b.toLowerCase(),role:g,invited_by:k}).select().single();if(O)throw O.code==="23505"?new Error("An invitation has already been sent to this email"):O;const{data:T}=await w.from("profiles").select("full_name").eq("user_id",k).single();try{const{error:U}=await w.functions.invoke("send-team-invitation",{body:{invitationId:A.id,email:b.toLowerCase(),role:g,companyName:x.name,inviterName:(T==null?void 0:T.full_name)||void 0,token:A.token}});U&&console.error("Failed to send invitation email:",U)}catch(U){console.error("Error calling send-team-invitation:",U)}return o({title:"Invitation sent",description:`An invitation has been sent to ${b}`}),u(),{data:A,error:null}}catch(A){return o({title:"Error",description:A.message,variant:"destructive"}),{data:null,error:A}}},E=async b=>{if(!(x!=null&&x.id))return{error:new Error("No company found")};const g=m;if(!g)return{error:new Error("Not authorized")};try{const{data:k}=await w.from("profiles").select("full_name").eq("user_id",g).single(),{error:A}=await w.functions.invoke("send-team-invitation",{body:{invitationId:b.id,email:b.email,role:b.role,companyName:x.name,inviterName:(k==null?void 0:k.full_name)||void 0,token:b.token,resend:!0}});if(A)throw new Error("Failed to send email");return o({title:"Invitation resent",description:`A new invitation email has been sent to ${b.email}`}),{error:null}}catch(k){return o({title:"Error",description:k.message,variant:"destructive"}),{error:k}}},Y=async b=>{try{const{error:g}=await w.from("company_invitations").delete().eq("id",b);if(g)throw g;o({title:"Invitation cancelled"}),u()}catch(g){o({title:"Error",description:g.message,variant:"destructive"})}},K=async b=>{try{const{error:g}=await w.from("company_members").delete().eq("id",b);if(g)throw g;o({title:"Member removed"}),u()}catch(g){o({title:"Error",description:g.message,variant:"destructive"})}},ae=async b=>{if(!(p!=null&&p.id))return{error:new Error("Not logged in")};try{const{data:g,error:k}=await w.from("company_invitations").select("*").eq("token",b).is("accepted_at",null).single();if(k||!g)throw new Error("Invalid or expired invitation");if(new Date(g.expires_at)<new Date)throw new Error("This invitation has expired");const{error:A}=await w.from("company_members").insert({company_id:g.company_id,user_id:p.id,role:g.role,
6invited_by:g.invited_by});if(A)throw A.code==="23505"?new Error("You are already a member of this company"):A;return await w.from("company_invitations").update({accepted_at:new Date().toISOString()}).eq("id",g.id),o({title:"Welcome!",description:"You have joined the company successfully"}),{error:null}}catch(g){return o({title:"Error",description:g.message,variant:"destructive"}),{error:g}}},V=async(b,g)=>{const{error:k}=await w.from("company_members").update({role:g}).eq("id",b);return k?(o({title:"Couldn't change role",description:k.message,variant:"destructive"}),{error:k}):(o({title:"Role updated"}),u(),{error:null})},H=async b=>{if(!(x!=null&&x.id))return{error:new Error("No company found")};const{error:g}=await w.rpc("transfer_company_ownership",{_company_id:x.id,_new_owner:b});return g?(o({title:"Couldn't transfer ownership",description:g.message,variant:"destructive"}),{error:g}):(o({title:"Ownership transferred",description:"You are now an admin."}),u(),{error:null})},Q=y.useCallback(async()=>{if(!(x!=null&&x.id))return[];const{data:b}=await w.from("company_membership_audit").select("*").eq("company_id",x.id).order("created_at",{ascending:!1}).limit(25);return b??[]},[x==null?void 0:x.id]),{role:X,isOwner:N,isAdmin:a,canInvite:C}=As(s);return{members:n,invitations:i,isLoading:d,inviteMember:r,resendInvitation:E,cancelInvitation:Y,removeMember:K,acceptInvitation:ae,changeRole:V,transferOwnership:H,fetchAudit:Q,myRole:X,isOwner:N,isCompanyAdmin:a,canInvite:C,company:x,refetch:u}},os=({trigger:s})=>{const[n,l]=y.useState(!1),[i,t]=y.useState(""),[d,h]=y.useState("member"),[p,v]=y.useState(!1),{effectiveUserId:c,isImpersonating:f,impersonatedUser:_}=re(),{inviteMember:m,canInvite:o,isOwner:S}=cs(c||void 0),x=S?["admin","member","viewer"]:["member","viewer"],u=async r=>{if(r.preventDefault(),!i.trim())return;v(!0);const{error:E}=await m(i,d);v(!1),E||(t(""),h("member"),l(!1))};return o?e.jsxs(Pe,{open:n,onOpenChange:l,children:[e.jsx(us,{asChild:!0,children:s||e.jsxs(j,{variant:"outline",size:"sm",children:[e.jsx(es,{size:16,className:"mr-2"}),"Invite teammate"]})}),e.jsxs(Ge,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsxs(We,{className:"flex items-center gap-2",children:[e.jsx(B,{size:20}),"Invite teammate"]}),e.jsx(Ye,{children:"Choose what they can do. You can change it later."})]}),f&&_&&e.jsxs(se,{className:"bg-accent/40 border-accent",children:[e.jsx(we,{size:16}),e.jsxs(te,{className:"text-sm",children:["Inviting on behalf of ",e.jsx("strong",{children:_.full_name||_.email}),_.company_name&&e.jsxs(e.Fragment,{children:[" at ",e.jsx("strong",{children:_.company_name})]})]})]}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"email",children:"Email address"}),e.jsx(ne,{id:"email",type:"email",placeholder:"[email protected]",value:i,onChange:r=>t(r.target.value),required:!0,autoFocus:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"They'll get an email with a link to join. It expires in 7 days."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{children:"Role"}),e.jsxs(Ke,{value:d,onValueChange:r=>h(r),children:[e.jsx(Ve,{children:e.jsx(He,{})}),e.jsx(Qe,{children:x.map(r=>e.jsx(Xe,{value:r,children:P[r]},r))})]}),e.jsxs("p",{className:"text-xs text-muted-foreground p-3 rounded-lg bg-muted/50 border",children:[e.jsxs("strong",{className:"text-foreground",children:[P[d],":"]})," ",pe[d]]})]})]}),e.jsxs(hs,{className:"gap-2 sm:gap-0",children:[e.jsx(j,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(j,{type:"submit",disabled:p||!i.trim(),children:p?e.jsxs(e.Fragment,{children:[e.jsx(z,{size:16,className:"mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{size:16,className:"mr-2"}),"Send invitation"]})})]})]})]})]}):null},de=s=>s==="owner"?e.jsx(fe,{size:12}):s==="admin"?e.jsx(Ls,{size:12}):s==="member"?e.jsx(Rs,{size:12}):e.jsx(be,{size:12}),at={invite:"invited",accept:"joined",add:"added",role_change:"role changed",remove:"removed",revoke:"invite revoked",resend:"invite resent",transfer:"ownership transferred"},nt=()=>{const{effectiveUserId:s,isImpersonating:n,impersonatedUser:l}=re(),{members:i,invitations:t,isLoading:d,cancelInvitation:h,removeMember:p,resendInvitation:v,changeRole:c,transferOwnership:f,fetchAudit:_,myRole:m,isOwner:o,isCompanyAdmin:S,canInvite:x,company:u}=cs(s||void 0),{user:r}=G(),[E,Y]=y.useState(null),[K,ae]=y.useState([]);if(y.useEffect(()=>{S&&_().then(ae)},[S,_,i.length,t.length]),d)return e.jsx(L,{children:e.jsx(R,{className:"flex items-center justify-center py-8",children:e.jsx(z,{className:"w-6 h-6 animate-spin text-muted-foreground"})})});const V=(a,C)=>a?a.split(" ").map(b=>b[0]).join("").toUpperCase().slice(0,2):(C==null?void 0:C.substring(0,2).toUpperCase())||"??",H=i.some(a=>a.role==="owner"),Q=a=>a==="owner"?null:o?["admin","member","viewer"]:m==="admin"&&a!=="admin"?["member","viewer"]:null,X=(a,C)=>C!==(r==null?void 0:r.id)&&a!=="owner"&&(o||m==="admin"&&a!=="admin"),N=async(a,C)=>{Y(a),await C(),Y(null)};return e.jsxs(L,{children:[e.jsxs(M,{className:"flex flex-row items-center justify-between",children:[e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(Ae,{size:20}),"Team access"]}),x&&e.jsx(os,{})]}),e.jsxs(R,{className:"space-y-3",children:[n&&l&&e.jsxs(se,{className:"bg-accent/40 border-accent",children:[e.jsx(we,{size:16}),e.jsxs(te,{className:"text-sm",children:["Viewing team for ",e.jsx("strong",{children:l.full_name||l.email}),l.company_name&&e.jsxs(e.Fragment,{children:[" at ",e.jsx("strong",{children:l.company_name})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Your access: ",e.jsx("strong",{className:"text-foreground",children:P[m]})," — ",pe[m]]}),u&&!H&&e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ge,{className:"ring-2 ring-primary/20",children:e.jsx(je,{className:"bg-primary/10 text-primary",children:e.jsx(fe,{size:16})})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:u.user_id===(r==null?void 0:r.id)?"You":`${u.name} founder`}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Created the company"})]})]}),e.jsxs(q,{className:"gap-1",children:[e.jsx(fe,{size:12}),"Owner"]}
6)]}),i.map(a=>{var A,O,T,U,Ce;const C=ke(a.role),b=Q(C),g=E===a.id,k=((A=a.profile)==null?void 0:A.full_name)||((O=a.profile)==null?void 0:O.email)||"Unknown";return e.jsxs("div",{className:"flex items-center justify-between gap-2 p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ge,{children:e.jsx(je,{className:"bg-muted",children:V((T=a.profile)==null?void 0:T.full_name,(U=a.profile)==null?void 0:U.email)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium truncate",children:[k,a.user_id===(r==null?void 0:r.id)&&" (you)"]}),((Ce=a.profile)==null?void 0:Ce.email)&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:a.profile.email})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[b&&a.user_id!==(r==null?void 0:r.id)?e.jsxs(Ke,{value:C,onValueChange:J=>N(a.id,()=>c(a.id,J)),disabled:g,children:[e.jsx(Ve,{className:"w-[110px] h-8",children:g?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(He,{})}),e.jsx(Qe,{children:b.map(J=>e.jsx(Xe,{value:J,children:e.jsxs("span",{className:"flex items-center gap-2",children:[de(J),P[J]]})},J))})]}):e.jsxs(q,{variant:C==="owner"?"default":"secondary",className:"gap-1",children:[de(C),P[C]]}),o&&C!=="owner"&&a.user_id!==(r==null?void 0:r.id)&&e.jsx(j,{variant:"ghost",size:"icon",className:"h-8 w-8",title:"Transfer ownership",onClick:()=>{window.confirm(`Make ${k} the owner? You'll become an admin.`)&&N(a.id,()=>
6f(a.user_id))},children:e.jsx(Is,{size:15})}),X(C,a.user_id)&&e.jsx(j,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",title:"Remove",onClick:()=>{window.confirm(`Remove ${k} from the team?`)&&N(a.id,()=>p(a.id))},children:e.jsx(Ie,{size:16})})]})]},a.id)}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground pt-2",children:"Pending invitations"}),t.map(a=>{const C=ke(a.role);return e.jsxs("div",{className:"flex items-center justify-between gap-2 p-3 rounded-lg border border-dashed bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center",children:e.jsx(B,{size:16,className:"text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:a.email}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(zs,{size:10}),new Date(a.expires_at)<new Date?"Expired":`Expires ${ze(new Date(a.expires_at),"MMM d, yyyy")}`]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs(q,{variant:"outline",className:"gap-1",children:[de(C),P[C]]}),S&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"ghost",size:"icon",className:"h-8 w-8",title:"Resend invitation",disabled:E===a.id,onClick:()=>N(a.id,()=>v(a)),children:E===a.id?e.jsx(z,{size:16,className:"animate-spin"}):e.jsx(ie,{size:16})}),e.jsx(j,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",title:"Revoke invitation",onClick:()=>{window.confirm(`Revoke the invitation to ${a.email}?`)&&h(a.id)},children:e.jsx(Ie,{size:16})})]})]})]},a.id)})]}),i.length===0&&t.length===0&&e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(Ae,{className:"w-10 h-10 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No team members yet"}),x&&e.jsx("p",{className:"text-xs mt-1",children:"Invite teammates and choose what they can do"})]}),e.jsxs("div",{className:"pt-3 border-t space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Access levels"}),["owner","admin","member","viewer"].map(a=>e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[de(a),e.jsxs("strong",{className:"text-foreground",children:[P[a],":"]})," ",pe[a]]},a))]}),S&&K.length>0&&e.jsxs("div",{className:"pt-3 border-t space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[e.jsx(Es,{size:12}),"Recent team changes"]}),K.slice(0,8).map(a=>e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ze(new Date(a.created_at),"MMM d, h:mm a")," · ",a.target_email||"member"," ",at[a.action]||a.action,a.old_role&&a.new_role?` (${a.old_role} → ${a.new_role})`:a.new_role?` as ${a.new_role}`:""]},a.id))]})]})]})},ue=({account:s,onDisconnect:n})=>{const[l,i]=y.useState(!1),t=Ds(s),d=t==="linkedin",h=s.status==="connected",p=async()=>{i(!0);try{await n(s.unipile_account_id),I.success("Account disconnected")}catch(v){I.error((v==null?void 0:v.message)||"Failed to disconnect")}finally{i(!1)}};return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"p-2 rounded-full bg-primary/10 shrink-0",children:t==="whatsapp"?e.jsx(ts,{className:"h-4 w-4 text-emerald-600"}):d?e.jsx(_e,{className:"h-4 w-4 text-primary"}):e.jsx(B,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:s.display_name||s.account_email||s.provider}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.account_email||(t==="whatsapp"?`WhatsApp${s.display_name?` · ${s.display_name}`:""}`:d?"LinkedIn account":s.provider)})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(q,{variant:"outline",className:h?"bg-success/10 text-success border-success/20":"bg-destructive/10 text-destructive border-destructive/20",children:[h?e.jsx(qs,{className:"h-3 w-3 mr-1"}):e.jsx(we,{className:"h-3 w-3 mr-1"}),h?"Synced":"Needs attention"]}),e.jsx(j,{variant:"ghost",size:"icon",onClick:p,disabled:l,"aria-label":"Disconnect",children:e.jsx(ye,{className:"h-4 w-4"})})]})]})},it=()=>{const{accounts:s,emailAccounts:n,linkedinAccounts:l,whatsappAccounts:i,isLoading:t,isConnecting:d,isSyncing:h,error:p,isImpersonating:v,connect:c,disconnect:f,syncAccounts:_}=ss();return e.jsxs(L,{children:[e.jsx(M,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-5 w-5 text-primary"}),"Email, LinkedIn & WhatsApp"]}),e.jsx(W,{children:"Connect your mailbox, LinkedIn and WhatsApp to send and track outreach from the platform."})]}),e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>_().catch(m=>I.error((m==null?void 0:m.message)||"Sync failed")),disabled:h||s.length===0,children:[e.jsx(ie,{className:`h-4 w-4 mr-2 ${h?"animate-spin":""}`}),"Refresh"]})]})}),e.jsxs(R,{className:"space-y-4",children:[p&&e.jsx("p",{className:"text-sm text-destructive",children:p}),v&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connecting accounts is disabled 
6while viewing another user."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(B,{className:"h-4 w-4"})," Mailboxes"]}),e.jsx(j,{size:"sm",onClick:()=>c("email"),disabled:d!==null||v,children:d==="email"?"Opening…":"Connect mailbox"})]}),n.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:t?"Loading…":"No mailbox connected yet (Gmail, Outlook or IMAP)."}):n.map(m=>e.jsx(ue,{account:m,onDisconnect:f},m.id))]}),e.jsx(xe,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"})," LinkedIn"]}),e.jsx(j,{size:"sm",onClick:()=>c("linkedin"),disabled:d!==null||v,children:d==="linkedin"?"Opening…":"Connect LinkedIn"})]}),l.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:t?"Loading…":"No LinkedIn account connected yet."}):l.map(m=>e.jsx(ue,{account:m,onDisconnect:f},m.id))]}),e.jsx(xe,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ts,{className:"h-4 w-4"})," WhatsApp"]}),e.jsx(j,{size:"sm",onClick:()=>c("whatsapp"),disabled:d!==null||v,children:d==="whatsapp"?"Opening…":"Connect WhatsApp"})]}),i.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:t?"Loading…":"No WhatsApp connected yet. You'll scan a QR code with WhatsApp on your phone."}):i.map(m=>e.jsx(ue,{account:m,onDisconnect:f},m.id))]})]})]})};function rt(){const{toast:s}=Ne(),{impersonatedUser:n}=Ze(),{connections:l,threadsByMailbox:i,isLoading:t,isConnecting:d,isSyncing:h,error:p,isImpersonating:v,connect:c,disconnect:f,syncThreads:_}=Os(),m=y.useMemo(()=>`${window.location.origin}/settings?gmailConnected=1`,[]);return e.jsxs(L,{children:[e.jsxs(M,{children:[e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(B,{size:20}),"Gmail sync"]}),e.jsx(W,{children:"Connect one or more Google Workspace mailboxes to send outreach from your own email."})]}),e.jsxs(R,{className:"space-y-4",children:[v&&n&&e.jsxs(se,{className:"border-blue-200 bg-blue-50 dark:bg-blue-950/20 dark:border-blue-800",children:[e.jsx(be,{className:"h-4 w-4 text-blue-600"}),e.jsxs(te,{className:"text-sm text-blue-700 dark:text-blue-300",children:["Viewing ",e.jsx("strong",{children:n.full_name||n.email}),"'s Gmail connections. Changes are disabled while impersonating."]})]}),p?e.jsx("div",{className:"text-sm text-destructive",children:p}):null,e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(j,{onClick:()=>c({redirectUrl:m}),disabled:d||v,className:"gap-2",children:[d?e.jsx(z,{className:"h-4 w-4 animate-spin"}):e.jsx(ve,{}),"Connect Gmail"]}),e.jsxs(j,{variant:"outline",onClick:()=>{(async()=>{try{await Promise.all(l.map(o=>_(o.gmail_address)).slice(0,1)),s({title:"Inbox synced"})}catch(o){s({title:"Sync failed",description:o==null?void 0:o.message,variant:"destructive"})}})()},disabled:t||l.length===0,className:"gap-2",children:[e.jsx(ie,{size:16}),"Sync inbox"]})]}),e.jsx(xe,{}),t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(z,{className:"h-4 w-4 animate-spin"}),"Loading Gmail status…"]}):l.length===0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No Gmail accounts connected yet."}),e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(j,{variant:"ghost",size:"sm",className:"w-full gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(rs,{className:"w-4 h-4"}),"Using Google Workspace? Read this first"]})}),e.jsx(is,{className:"mt-3",children:e.jsxs(se,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:[e.jsx(Ee,{className:"h-4 w-4 text-amber-600"}),e.jsxs(te,{className:"text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-amber-800 dark:text-amber-200",children:"Google Worksp
6ace accounts require admin approval"}),e.jsx("p",{className:"text-amber-700 dark:text-amber-300",children:'If you see a "403: access_denied" error, your Workspace admin needs to:'}),e.jsxs("ol",{className:"list-decimal list-inside text-amber-700 dark:text-amber-300 space-y-1 ml-2",children:[e.jsxs("li",{children:["Go to ",e.jsx("strong",{children:"admin.google.com → Security → API controls"})]}),e.jsx("li",{children:'Under "App access control", add this app to the trusted list'}),e.jsx("li",{children:'Or enable "Allow users to access any third-party app"'})]}),e.jsx("p",{className:"text-amber-700 dark:text-amber-300 text-xs mt-2",children:"Personal Gmail accounts work immediately without admin approval."})]})]})})]})]}):e.jsx("div",{className:"space-y-4",children:l.map(o=>{var x,u;const S=i.get(o.gmail_address)??[];return e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"font-medium truncate",children:o.gmail_address}),e.jsx(q,{variant:"secondary",children:"Connected"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(x=o.scopes)!=null&&x.includes("https://www.googleapis.com/auth/gmail.send")?"Send enabled":"Send not enabled"," • ",(u=o.scopes)!=null&&u.includes("https://www.googleapis.com/auth/gmail.readonly")?"Read enabled":"Read not enabled"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(j,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>void(async()=>{try{await _(o.gmail_address),s({title:"Inbox synced"})}catch(r){s({title:"Sync failed",description:r==null?void 0:r.message,variant:"destructive"})}})(),disabled:h===o.gmail_address,children:[h===o.gmail_address?e.jsx(z,{className:"h-4 w-4 animate-spin"}):e.jsx(ie,{size:14}),"Sync"]}),e.jsxs(j,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>void(async()=>{try{await f(o.gmail_address),s({title:"Disconnected"})}catch(r){s({title:"Failed to disconnect",description:r==null?void 0:r.message,variant:"destructive"})}})(),children:[e.jsx(ye,{size:14}),"Disconnect"]})]})]}),S.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Recent threads"}),e.jsx("div",{className:"space-y-2",children:S.slice(0,5).map(r=>e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium truncate",children:r.subject||"(no subject)"}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[r.from_email||r.from_name||"Unknown sender",r.snippet?` • ${r.snippet}`:""]})]},r.id))})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No synced threads yet—click Sync."})]},o.id)})})]})]})}const ct=s=>s==="connected"?e.jsx(q,{variant:"outline",className:"border-success/30 bg-success/10 text-success",children:"Connected"}):s==="expired"?e.jsx(q,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:"Reconnect"}):e.jsx(q,{variant:"outline",className:"text-muted-foreground",children:"Not connected"});function ot({compact:s=!1}){const{effectiveUserId:n}=re(),l=ss(),{data:i}=ee({queryKey:["fireflies-ws",n],enabled:!!n,queryFn:async()=>{const{data:o}=await w.from("fireflies_workspaces").select("id, sync_enabled").eq("user_id",n).limit(1);return(o??[])[0]??null}}),{data:t}=ee({queryKey:["booking-links",n],enabled:!!n,queryFn:async()=>(await w.from("founder_booking_links").select("*").eq("user_id",n).maybeSingle()).data}),d=o=>o.some(S=>S.status==="connected")?"connected":o.length?"expired":"not_connected",h=d(l.emailAccounts),p=d(l.emailAccounts.filter(o=>/google|microsoft|outlook/i.test(o.provider??""))),v=d(l.linkedinAccounts),c=i?"connected":"not_connected",f=t&&(t.investor_call_url||t.partner_call_url||t.interview_call_url)?"connected":"not_connected",_=!!l.error&&/not configured/i.test(l.error),m=[{icon:e.jsx(B,{className:"h-4 w-4"}),label:"Email",hint:"Agents draft from your inbox; nothing sends without approval.",status:h,action:e.jsx(j,{size:"sm",variant:"outline",disabled:!!l.isConnecting||_,onClick:()=>l.connect("email"),children:l.isConnecting==="email"?e.jsx(z,{className:"h-3.5 w-3.5 animate-spin"}):h==="not_connected"?"Connect":"Reconnect"})},{icon:e.jsx(Fs,{className:"h-4 w-4"}),label:"Calendar",hint:"Comes with a Google or Microsoft email connection.",status:p,action:e.jsx(j,{size:"sm",variant:"outline",disabled:!!l.isConnecting||_,onClick:()=>l.connect("email"),children:p==="not_connected"?"Connect":"Reconnect"})},{icon:e.jsx(_e,{className:"h-4 w-4"}),label:"LinkedIn",hint:"Agents draft messages only — you send them.",status:v,action:e.jsx(j,{size:"sm",variant:"outline",disabled:!!l.isConnecting||_,onClick:()=>l.connect("linkedin"),children:l.isConnecting==="linkedin"?e.jsx(z,{className:"h-3.5 w-3.5 animate-spin"}):v==="not_connected"?"Connect":"Reconnect"})},{icon:e.jsx(Ms,{className:"h-4 w-4"}),label:"Fireflies",hint:"Meeting notes and transcripts.",status:c,action:e.jsx(j,{size:"sm",variant:"outline",asChild:!0,children:e.jsx(me,{to:"/meeting-intelligence",children:c==="connected"?"Manage":"Connect"})})},{icon:e.jsx($s,{className:"h-4 w-4"}),label:"Booking links (Calendly or any link)",hint:"Investor, partner and interview call links.",status:f,action:e.jsx(j,{size:"sm",variant:"outline",asChild:!0,children:e.jsx(me,{to:"/settings#booking-links",children:f==="connected"?"Edit":"Add"})})}];return e.jsxs(L,{id:"connect-accounts",children:[e.jsxs(M,{className:s?"p-3 pb-1":void 0,children:[e.jsxs($,{className:"text-base",children:["Connect your accounts ",e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(all optional)"})]}),e.jsx(W,{children:"Our agents use these to work for you. You can connect them any time in Settings."})]}),e.jsxs(R,{className:`space-y-1.5 ${s?"p-3 pt-1":""}`,children:[_&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email, calendar and LinkedIn connections are temporarily unavailable. Our team has been notified."}),m.map(o=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border p-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:o.icon}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:o.label}),!s&&e.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:o.hint})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[ct(o.status),o.action]})]},o.label))]})]})}const he=s=>{const n=s.trim();return n?/^https?:\/\//i.test(n)?n:`https://${n}`:null};function lt(){const{effectiveUserId:s,isImpersonating:n}=re(),l=Le(),{data:i}=ee({queryKey:["booking-links",s],enabled:!!s,queryFn:async()=>(await w.from("founder_booking_links").select("*").eq("user_id",s).maybeSingle()).data}),[t,d]=y.useState({investor:"",partner:"",interview:"",handle:!1,call:!1,auto:!1,minScore:"80"}),[h,p]=y.useState(!1);y.useEffect(()=>{i&&d({investor:i.investor_call_url??"",partner:i.partner_call_url??"",interview:i.interview_call_url??"",handle:i.agents_handle_scheduling,call:i.agents_may_call,auto:i.approval_mode==="auto_above_score",minScore:String(i.auto_approve_min_score??80)})},[i]);const v=async()=>
6{if(!s||n)return;const c=Math.min(100,Math.max(0,Math.round(Number(t.minScore)||80)));p(!0);const{error:f}=await w.from("founder_booking_links").upsert({user_id:s,investor_call_url:he(t.investor),partner_call_url:he(t.partner),interview_call_url:he(t.interview),agents_handle_scheduling:t.handle,agents_may_call:t.call,approval_mode:t.auto?"auto_above_score":"approve_each",auto_approve_min_score:t.auto?c:null,updated_at:new Date().toISOString()});p(!1),f?I.error(`Couldn't save: ${f.message}`):(I.success("Saved"),l.invalidateQueries({queryKey:["booking-links"]}))};return e.jsxs(L,{id:"booking-links",children:[e.jsxs(M,{children:[e.jsx($,{className:"text-base",children:"Booking links & agent permissions"}),e.jsx(W,{children:"Our agents add the right link to each message and only act within what you allow here."})]}),e.jsxs(R,{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(D,{htmlFor:"bl-inv",children:"Investor calls"}),e.jsx(ne,{id:"bl-inv",value:t.investor,onChange:c=>d({...t,investor:c.target.value}),placeholder:"calendly.com/you/investor-call"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(D,{htmlFor:"bl-par",children:"Founder / partner calls"}),e.jsx(ne,{id:"bl-par",value:t.partner,onChange:c=>d({...t,partner:c.target.value}),placeholder:"calendly.com/you/intro"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(D,{htmlFor:"bl-int",children:"Interview calls"}),e.jsx(ne,{id:"bl-int",value:t.interview,onChange:c=>d({...t,interview:c.target.value}),placeholder:"calendly.com/you/interview"})]}),e.jsxs("label",{className:"flex items-center justify-between gap-2 rounded-md border border-border p-2 text-sm",children:[e.jsxs("span",{children:["Let Initio agents handle scheduling",e.jsx("span",{className:"block text-[11px] text-muted-foreground",children:"Agents reply to booking requests and propose times. Off by default."})]}),e.jsx(F,{checked:t.handle,onCheckedChange:c=>d({...t,handle:c})})]}),e.jsxs("label",{className:"flex items-center justify-between gap-2 rounded-md border border-border p-2 text-sm",children:[e.jsxs("span",{children:["Agents may call contacts on my behalf",e.jsx("span",{className:"block text-[11px] text-muted-foreground",children:"For example, candidate screening calls. Every call opens with a consent line. Off by default."})]}),e.jsx(F,{checked:t.call,onCheckedChange:c=>d({...t,call:c})})]}),e.jsxs("div",{className:"space-y-1 rounded-md border border-border p-2 text-sm",children:[e.jsxs("label",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Approve automatically above a match score",e.jsx("span",{className:"block text-[11px] text-muted-foreground",children:"Off means you approve each message before it goes out."})]}),e.jsx(F,{checked:t.auto,onCheckedChange:c=>d({...t,auto:c})})]}),t.auto&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{htmlFor:"bl-min",className:"text-xs",children:"Minimum score"}),e.jsx(ne,{id:"bl-min",type:"number",min:0,max:100,className:"h-8 w-20",value:t.minScore,onChange:c=>d({...t,minScore:c.target.value})})]})]}),e.jsx(j,{size:"sm",onClick:v,disabled:h||n,children:h?"Saving…":"Save"})]})]})}const dt=()=>{const[s,n]=y.useState(!1),[l,i]=y.useState(!1),[t,d]=js(),{isImpersonating:h,impersonatedUser:p}=Ze(),{data:v,isLoading:c,refetch:f}=Gs(),_=Bs(),m=v==null?void 0:v.find(u=>u.status==="connected");y.useEffect(()=>{const u=t.get("calendarSuccess"),r=t.get("calendarError");u==="true"&&(I.success("Google Calendar connected successfully!"),f(),t.delete("calendarSuccess"),d(t,{replace:!0})),r&&(I.error(`Calendar connection failed: ${r}`),t.delete("calendarError"),d(t,{replace:!0}))},[t,d,f]);const o=async()=>{if(h){I.error("Cannot connect calendar while viewing another user's account");return}i(!0);try{const{data:{session:u}}=await w.auth.getSession();if(!(u!=null&&u.access_token)){I.error("Please sign in to connect your calendar");return}if(!await Ts()){window.location.assign(Us);return}const{data:r,error:E}=await w.functions.invoke("calendar-oauth-start",{body:{redirectUrl:window.location.href.split("?")[0]}});if(E)throw E;if(r!=null&&r.authUrl)window.location.href=r.authUrl;else throw new Error("No auth URL returned")}catch(u){console.error("Calendar OAuth error:",u),I.error("Failed to start calendar connection")}finally{i(!1)}},S=async(u,r)=>{try{await _.mutateAsync({id:u,notetaker_enabled:r}),I.success(r?"AI notetaker enabled":"AI notetaker disabled")}catch{I.error("Failed to update notetaker setting")}},x=async(u,r)=>{try{await _.mutateAsync({id:u,auto_record_investor_meetings:r}),I.success(r?"Auto-record enabled":"Auto-record disabled")}catch{I.error("Failed to update auto-record setting")}};return c?e.jsx(L,{children:e.jsx(R,{className:"py-8 flex items-center justify-center",children:e.jsx(z,{className:"w-6 h-6 animate-spin text-muted-foreground"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[e.jsx(M,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-white border",children:e.jsx(ve,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx($,{className:"text-lg",children:"Google Calendar"}),e.jsx(W,{children:"Auto-record investor meetings with AI notetaker"})]})]}),m&&e.jsx(j,{variant:"ghost",size:"icon",onClick:()=>n(!0),children:e.jsx(Ws,{className:"w-4 h-4"})})]})}),e.jsxs(R,{children:[h&&p&&e.jsxs(se,{className:"mb-4 border-blue-200 bg-blue-50 dark:bg-blue-950/20 dark:border-blue-800",children:[e.jsx(be,{className:"h-4 w-4 text-blue-600"}),e.jsxs(te,{className:"text-sm text-blue-700 dark:text-blue-300",children:["Viewing ",e.jsx("strong",{children:p.full_name||p.email}
6),"'s calendar connections. Changes are disabled while impersonating."]})]}),m?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-green-500 flex items-center justify-center",children:e.jsx(Ys,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Google Calendar"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m.calendar_email||"Connected"})]})]}),e.jsx(q,{variant:"secondary",className:"bg-green-500/10 text-green-600",children:"Connected"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(D,{htmlFor:"notetaker",className:"text-sm",children:"AI Notetaker enabled"}),e.jsx(F,{id:"notetaker",checked:m.notetaker_enabled??!1,onCheckedChange:u=>S(m.id,u)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(D,{htmlFor:"autorecord",className:"text-sm",children:"Auto-record investor meetings"}),e.jsx(F,{id:"autorecord",checked:m.auto_record_investor_meetings??!1,onCheckedChange:u=>x(m.id,u)})]})]}),m.last_sync_at&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ie,{className:"w-3 h-3"}),"Last synced:"," ",new Date(m.last_sync_at).toLocaleString()]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your Google Calendar to automatically detect and analyze investor meetings"}),e.jsxs(j,{onClick:o,disabled:l,className:"w-full gap-2",variant:"outline",children:[l?e.jsx(z,{className:"w-4 h-4 animate-spin"}):e.jsx(ve,{}),l?"Connecting...":"Connect Google Calendar"]}),e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(j,{variant:"ghost",size:"sm",className:"w-full gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(rs,{className:"w-4 h-4"}),"Using Google Workspace? Read this first"]})}),e.jsx(is,{className:"mt-3",children:e.jsxs(se,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:[e.jsx(Ee,{className:"h-4 w-4 text-amber-600"}),e.jsxs(te,{className:"text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-amber-800 dark:text-amber-200",children:"Google Workspace accounts require admin a
6pproval"}),e.jsx("p",{className:"text-amber-700 dark:text-amber-300",children:'If you see a "403: access_denied" error, your Workspace admin needs to:'}),e.jsxs("ol",{className:"list-decimal list-inside text-amber-700 dark:text-amber-300 space-y-1 ml-2",children:[e.jsxs("li",{children:["Go to ",e.jsx("strong",{children:"admin.google.com → Security → API controls"})]}),e.jsx("li",{children:'Under "App access control", add this app to the trusted list'}),e.jsx("li",{children:'Or enable "Allow users to access any third-party app"'})]}),e.jsx("p",{className:"text-amber-700 dark:text-amber-300 text-xs mt-2",children:"Personal Gmail accounts work immediately without admin approval."})]})]})})]})]})]})]}),e.jsx(Pe,{open:s,onOpenChange:n,children:e.jsxs(Ge,{children:[e.jsxs(Be,{children:[e.jsx(We,{children:"Calendar Settings"}),e.jsx(Ye,{children:"Configure how your calendar syncs with meeting intelligence"})]}),m&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(D,{children:"AI Notetaker"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically join and transcribe meetings"})]}),e.jsx(F,{checked:m.notetaker_enabled??!1,onCheckedChange:u=>S(m.id,u)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(D,{children:"Auto-detect investor meetings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Prioritize recording meetings with investors"})]}),e.jsx(F,{checked:m.auto_record_investor_meetings??!1,onCheckedChange:u=>x(m.id,u)})]})]})]})})]})},gn=()=>{var V,H,Q,X;const{isAdmin:s}=G(),{user:n,isAdmin:l,isLoading:i,signOut:t}=G(),{company:d,updateCompany:h}=Je(),{toast:p}=Ne(),v=fs();y.useState(!1),y.useState(!1);const[c,f]=y.useState(!1);y.useState("");const[_,m]=y.useState(!0),S=new URLSearchParams(window.location.search).get("tab")||"integrations",x=S==="credits"?"billing":["integrations","account","team","billing"].includes(S)?S:"integrations",[u,r]=y.useState(x);y.useEffect(()=>{d&&m(d.auto_invite_investors!==!1)},[d]),y.useEffect(()=>{const N=new URLSearchParams(window.location.search),a=N.get("gmailConnected"),C=N.get("gmailError");a&&(p({title:"Gmail connected"}),N.delete("gmailConnected"),window.history.replaceState({},"",`${window.location.pathname}?${N.toString()}`.replace(/\?$/,""))),C&&(p({title:"Gmail connection failed",description:C,variant:"destructive"}),N.delete("gmailError"),window.history.replaceState({},"",`${window.location.pathname}?${N.toString()}`.replace(/\?$/,"")))},[]);const E=(V=n==null?void 0:n.user_metadata)!=null&&V.full_name?n.user_metadata.full_name.split(" ").map(N=>N[0]).join("").toUpperCase():((H=n==null?void 0:n.email)==null?void 0:H.substring(0,2).toUpperCase())||"U",Y=((Q=n==null?void 0:n.user_metadata)==null?void 0:Q.full_name)||((X=n==null?void 0:n.email)==null?void 0:X.split("@")[0])||"User",K=async()=>{if(n!=null&&n.email){f(!0);try{const{error:N}=await w.auth.resetPasswordForEmail(n.email,{redirectTo:`${window.location.origin}/reset-password`});if(N)throw N;p({title:"Password reset email sent",description:"Check your inbox for a link to reset your password"})}catch(N){p({title:"Failed to send reset email",description:N.message,variant:"destructive"})}finally{f(!1)}}},ae=async()=>{await t(),v("/")};return i?e.jsx(Se,{children:e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(z,{className:"w-8 h-8 animate-spin text-primary"})})}):e.jsx(Se,{children:e.jsxs("div",{className:"p-4 lg:p-6 max-w-4xl mx-auto space-y-6",children:[e.jsx(Cs,{}),e.jsxs("header",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:e.jsx(Ks,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Account, team, connections and billing."})]})]}),e.jsxs(ks,{value:u,onValueChange:N=>{r(N);const a=new URLSearchParams(window.location.search);a.set("tab",N),window.history.replaceState({},"",`${window.location.pathname}?${a.toString()}`)},children:[e.jsxs(Ss,{className:"grid w-full grid-cols-4",children:[e.jsx(oe,{value:"account",children:"Account"}),e.jsx(oe,{value:"team",children:"Team"}),e.jsx(oe,{value:"integrations",children:"Connections"}),e.jsx(oe,{value:"billing",children:"Billing"})]}),e.jsxs(le,{value:"billing",className:"space-y-3",children:[e.jsx(Js,{}),e.jsx(st,{}),e.jsx(tt,{})]}),e.jsx(le,{value:"integrations",children:e.jsxs("section",{className:"space-y-3",children:[e.jsx(ot,{}),e.jsx(lt,{}),e.jsx(Ps,{}),e.jsxs("details",{className:"rounded-xl border border-border bg-card p-3",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-semibold",children:["More connection options ",e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"— extra mailboxes, WhatsApp and manual sync. Most founders don't need these."})]}),e.jsxs("div",{className:"space-y-3 pt-3",children:[e.jsx(it,{}),e.jsx(ds,{}),s&&e.jsx(rt,{}),s&&e.jsx(dt,{})]})]})]})}),e.jsx(le,{value:"team",children:e.jsxs("section",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(os,{trigger:e.jsxs(j,{size:"sm",className:"gap-1.5 h-8 text-xs",children:[e.jsx(es,{size:14})," Invite teammate"]})})}),e.jsx(nt,{})]})}),e.jsx(le,{value:"account",children:e.jsxs("section",{className:"space-y-3",children:[e.jsx(Hs,{}),e.jsx(L,{children:e.jsxs(R,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ge,{className:"h-9 w-9",children:e.jsx(je,{className:"text-xs bg-primary/10 text-primary font-semibold",children:E})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Y}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n==null?void 0:n.email})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[e.jsxs(j,{variant:"outline",size:"sm",onClick:K,disabled:c,
6className:"gap-1.5 min-h-11 sm:min-h-8 text-xs",children:[c?e.jsx(z,{size:12,className:"animate-spin"}):e.jsx(Vs,{size:12})," Reset password"]}),e.jsxs(Re,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(j,{variant:"ghost",size:"sm",className:"min-h-11 sm:h-8 text-xs gap-1.5 text-destructive hover:text-destructive",children:[e.jsx(gs,{size:12})," Sign out"]})}),e.jsxs(qe,{children:[e.jsxs(Oe,{children:[e.jsx(Te,{children:"Sign out?"}),e.jsx(Ue,{children:"You'll need to sign in again to access your dashboard."})]}),e.jsxs(Fe,{children:[e.jsx(Me,{children:"Cancel"}),e.jsx($e,{onClick:ae,className:"bg-destructive hover:bg-destructive/90",children:"Sign out"})]})]})]})]})]}),e.jsx(xe,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(D,{htmlFor:"auto-invite",className:"text-sm",children:"Email investors when I add them to my pipeline"}),e.jsx(F,{id:"auto-invite",checked:_,onCheckedChange:async N=>{m(N);try{await h({auto_invite_investors:N}),p({title:N?"Auto-invite enabled":"Auto-invite disabled"})}catch{m(!N),p({title:"Failed to update",variant:"destructive"})}}})]})]})})]})})]})]})})};export{gn 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.