1import{r as l,j as e}from"./vendor-react-Bq0AAjM7.js";import{m as V}from"./mergeTypedPeople-ClUOriov.js";import{u as z,O as B}from"./useOrganisationTermsConsent-BTnUSwjK.js";import{ca as $,cb as q,bu as H,b2 as U,a as G,z as J,al as K,dm as X,aA as p,cf as Y,aM as Q,cM as W,ar as T,d_ as Z,G as A,H as R,c1 as ee,c2 as te,U as ae,J as v,I as se,d$ as ie,e0 as re,bJ as ne,ac as le}from"./main-D49UUfSD.js";import{o as oe}from"./vendor-misc-DMccS2Mw.js";import{T as de}from"./ThreadPeopleInput-Bh84OSPb.js";import{c as ce}from"./copyText-0_NNZNe-.js";import{u as me}from"./useHidePlainChat-CgB1uSRE.js";import{u as ue}from"./useRecommendedInvites-BUPLbio5.js";import{u as pe}from"./useReferralLink-Bbxw9kHy.js";import{F as fe}from"./trials-8KUt_9DV.js";import{f as xe,C as ge}from"./currency-BvZtfEGc.js";import{S as he,a as be,b as ye,c as ve,d as je}from"./select-4sRtrU5h.js";import{u as Ie}from"./useOrganisationActions-BVWeZ-8E.js";import"./vendor-runtime-DG-GlVKR.js";import"./isEnterpriseOrganisation-Fjb8mzJZ.js";import"./index-Dl4pFCyo.js";import"./vendor-icons-DePtd98t.js";import"./vendor-ui-HM9MEgw-.js";import"./vendor-analytics-DaFEZfd9.js";import"./vendor-sentry-BBJkNfRx.js";import"./popover-4HcJ00FV.js";import"./avatarStyle-Bfvt7XCu.js";import"./dropdownClassNames-Dga6WU27.js";import"./resolveAriaLabelledBy-B6xExwUN.js";try{let t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new t.Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="7faff190-6c7c-4291-871b-837ae2c5e9e9",t._sentryDebugIdIdentifier="sentry-dbid-7faff190-6c7c-4291-871b-837ae2c5e9e9")}catch{}const S=[{label:"Super Admin",value:p.SUPER_ADMIN},{label:"Member",value:p.MEMBER}],u=10,Ee=({markSeen:t})=>{$(q.ADD_TEAM),me();const{user:r}=H(),{subscription:f}=U(),[n,j]=l.useState(!1),[c,I]=l.useState([]),[x,E]=l.useState({}),[m,P]=l.useState(""),[_,g]=l.useState(),h=pe(),{sendInvites:w}=Ie(),{logButtonPress:F,logFormSubmit:C}=G(),o=z(),L=J(),d=ue({enabled:!0,location:"team_invite_page"}),{data:b,isLoading:M}=oe({queryKey:["programData",r.slug],queryFn:L.referral.program.get,enabled:!!r.slug,refetchOnWindowFocus:!1}),y=f==null?void 0:f.data(),D=c.length>0||m.trim()!=="";l.useEffect(()=>{Array.isArray(d.data)&&d.data.length>0&&I(d.data.filter(K).slice(0,u).map(a=>({email:X(a)})))},[d.data]);const O=async()=>{await ce({text:h??"",copied:{title:"Invite link copied"}})&&F(le.INVITE_LINK_COPIED,{location:"teamInvitePage"})},k=()=>b?(y==null?void 0:y.status)===ne.ACTIVE?`Get ${xe({value:b.creditAmount/100,currency:ge.USD})} credit`:`Extend your trial by ${b.extraDays} days`:`Extend your trial by ${fe} days`,N=l.useCallback(async()=>{const a=V({people:c,typed:m});if("error"in a){g(a.error);return}if(a.people.length>u){g(`You can invite up to ${u} people at a time.`);return}const s=a.people.map(i=>({email:i.email,role:x[i.email]??p.MEMBER}));if(s.length>0&&!n)try{j(!0),await w(s,{referrer:r.slug,...o.inviteOptions}),C(Y.SEND_INVITES,{count:s.length}),Q.success({title:s.length===1?"Invite sent":`${s.length} invites sent`})}catch(i){console.error("Error sending invites:",i),W({action:"send invites",error:i,onRetry:()=>void N()})}j(!1),t==null||t()},[c,m,x,n,t,w,r.slug,o.inviteOptions,C]);return d.isLoading||M?e.jsxs("div",{role:"status","aria-busy":"true",className:"flex h-full min-h-80 flex-col items-center justify-center bg-rb-parchment-light p-4 text-center",children:[e.jsx(T,{"aria-hidden":!0,className:"size-8 text-rb-darkbtn"}),e.jsx("p",{className:"mt-4 text-body font-medium text-rb-secondary-dark",children:"Preparing invitationsâ¦"})]}):e.jsx("div",{className:"min-h-full bg-rb-parchment-light px-4 py-6 sm:px-6 sm:py-10",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[640px] flex-col gap-6",children:[t?e.jsx("div",{className:"flex justify-end",children:e.jsx(Z,{icon:"X",label:"Close",size:"md",onClick:t})}):null,e.jsxs("header",{className:"text-center",children:[e.jsx("h1",{className:"text-title-lg font-medium text-balance text-rb-darkbtn sm:text-display",children:"Invite your team"}),e.jsxs("p",{className:"mx-auto mt-2 max-w-xl text-body text-pretty text-rb-secondary-dark",children:[e.jsx("strong",{className:"font-medium text-rb-darkbtn",children:k()})," for each teammate you invite to Fyxer AI using the link or form below."]})]}),e.jsx(A,{children:e.jsx(R,{className:"flex flex-col gap-4",children:e.jsxs(ee,{children:[e.jsx(te,{htmlFor:"team-referral-link",children:"Invite with link"}),e.jsxs("div",{className:"flex min-w-0 gap-2",children:[e.jsx(ae,{id:"team-referral-link",value:h??"",readOnly:!0,className:"min-w-0 flex-1 bg-rb-parchment-light"}),e.jsxs(v,{size:"md",onClick:()=>void O(),disabled:!h,children:[e.jsx(se,{name:"Copy",color:"current","data-icon":"inl
1ine-start"}),"Copy"]})]})]})})}),e.jsx(A,{children:e.jsx(R,{children:e.jsxs(ie,{children:[e.jsx(re,{variant:"label",children:"Invite with email"}),e.jsx(de,{ariaLabel:"People to invite",people:c,onPeopleChange:a=>{I(a),E(s=>Object.fromEntries(a.flatMap(i=>s[i.email]?[[i.email,s[i.email]]]:[])))},inputValue:m,onInputValueChange:a=>{P(a),g(void 0)},errorMessage:_,max:u,placeholder:"Add emails, or paste a list",layout:"rows",renderRowTrailing:a=>e.jsx("div",{className:"w-full sm:w-40",children:e.jsxs(he,{items:S,value:x[a.email]??p.MEMBER,onValueChange:s=>{s!==null&&E(i=>({...i,[a.email]:s}))},children:[e.jsx(be,{"aria-label":`Role for ${a.email}`,className:"w-full",children:e.jsx(ye,{placeholder:"Selectâ¦"})}),e.jsx(ve,{align:"start",children:S.map(s=>e.jsx(je,{value:s.value,children:s.label},s.value))})]})})})]})})}),e.jsxs("div",{className:"flex flex-col items-center gap-2 pb-6",children:[o.isRequired?e.jsx(B,{hasAccepted:o.hasAccepted,onAcceptedChange:o.setHasAccepted,disabled:n,className:"mb-2 w-full sm:max-w-md"}):null,e.jsx(v,{variant:"brand",size:"lg","aria-busy":n,"aria-label":n?"Sending invitations":void 0,onClick:()=>void N(),disabled:n||D&&!o.canSendInvites,className:"w-full sm:max-w-md",children:n?e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"size-5 text-rb-disabled","aria-hidden":!0}),"Sending invitations"]}):"Invite your team"}),t?e.jsx(v,{variant:"ghost",size:"md",onClick:t,children:"Remind me later"}):null]})]})})},Xe=()=>e.jsx(Ee,{markSeen:void 0});export{Xe as InviteTeamPage};
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.