1import{j as e,dJ as z,dK as Y,dL as B,dM as V,dN as $,dO as H,dP as Q,dQ as G,n as v,a as d,cr as Fe,O as je,S as C,dc as A,$ as se,bx as _,cy as te,aF as We,aG as ze,dR as Ye,aH as Be,aJ as ce,c$ as W,L as de,bR as Ve,d7 as $e,dS as He,bH as me,cV as ve,dT as ne,dD as he,db as Qe,dU as Ge,dV as qe,Z as Ke,q as Je,t as Xe,bh as Ze,dW as es,d8 as ss,dG as y}from"./try-on-links-D-kskELd.js";import{T as ue}from"./TeamsPageShell-DGWL4ikU.js";import{T as xe}from"./TeamPageIntro-DnJG8RKL.js";import{T as U}from"./TeamStatsCard-CHIueUx4.js";import{T as as}from"./TeamHubStates-B86o3aQw.js";import{d as q,k as pe,l as ts,c as ns,g as rs,e as Ne}from"./teamsUi-BUjcl69Q.js";import{I as is,g as ls,h as os,i as cs}from"./studioProjectCopy-6yl--Oly.js";import{L as ds}from"./LazyBillingPlans-C7jKMM-g.js";import{O as ye,a as ms,u as hs,I as us}from"./useInviteUser-CnOmNn4Z.js";import{M as xs}from"./ProjectSettingsDialog-Bd392vHg.js";import{o as M,g as ps,i as ae,b as ge,n as fe,d as gs,O as fs,e as bs}from"./orgRoleUtils-8kBHS7c_.js";import{g as ws,O as js}from"./orgRoleCapabilities-B0mWCB6A.js";import{T as vs,a as Ns,b as be,c as we}from"./tabs-BLT7ss3V.js";import{u as ys}from"./useAuthRedirect-BdmZE0z3.js";import{f as Cs}from"./teamProjectsApi-B-7FzwOl.js";import{b as Ss,c as ks,d as Ts,f as Es,g as Is,h as Rs,j as As}from"./studioKitProjectApi-8qbP3n4a.js";import{u as Os}from"./useWorkspaceRole-8LNE5xgt.js";import{g as F}from"./apiErrorMessage-DRUtEO3w.js";import{h as Ls,s as Ps}from"./index-YaSf-vmi.js";import"./WorkspaceSwitcher-D-NH3jCP.js";import"./useProjectManagement-vC3GKsKr.js";import"./onboardingProjectApi-DuDvgb1S.js";import"./projectFolderTree-BDpb2aHe.js";import"./TeamsProjectDialogs-n-4bs8Wp.js";import"./ImportAddEmptyState-MoLpM6y0.js";import"./googlePicker-BcWy3Tqz.js";import"./ingestDrag-D0-x4mdv.js";import"./ingestJourneyTheme-B55h8ZcE.js";import"./useBatchPolling-jWbNMHk5.js";import"./errorHandling-W_QQBFll.js";import"./SharedProjectChip-Hiw4_8e2.js";function _s({open:a,memberName:l,currentRole:h,nextRole:p,onConfirm:u,onCancel:w,isLoading:m=!1}){return e.jsx(z,{open:a,onOpenChange:r=>!r&&w(),children:e.jsxs(Y,{className:"theme-sheet max-h-[90vh] overflow-y-auto border-brand-border sm:max-w-lg",children:[e.jsxs(B,{children:[e.jsx(V,{children:"Change workspace role?"}),e.jsxs($,{className:"theme-caption",children:[e.jsx("span",{className:"theme-ink font-medium",children:l})," will move from"," ",e.jsx("span",{className:"theme-ink",children:M(h)})," to"," ",e.jsx("span",{className:"theme-ink",children:M(p)}),". Review what changes:"]})]}),e.jsx(ye,{role:p,variant:"compact"}
1),e.jsxs(H,{children:[e.jsx(Q,{onClick:w,disabled:m,className:"theme-segment-off",children:"Cancel"}),e.jsx(G,{onClick:r=>{r.preventDefault(),u()},disabled:m,className:v("rounded-xl",q),children:m?"Savingâ¦":`Set as ${M(p)}`})]})]})})}const Ms={backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 0.75rem center",backgroundSize:"12px 12px"};function Ds({members:a,searchTerm:l,onSearchChange:h,onInviteClick:p,onUpdateRole:u,onRemoveMember:w,currentUserId:m,canManageMembers:r=!0,showInviteButton:j=!0,updatingMemberId:S=null,removingMemberId:N=null,actorOrgRole:b=null,canInviteAsOwner:g=!1}){const k=ps(b,g),[o,x]=d.useState(null),[i,n]=d.useState(null),f=a.filter(s=>s.user.email.toLowerCase().includes(l.toLowerCase())||s.user.fullName&&s.user.fullName.toLowerCase().includes(l.toLowerCase())),c=a.filter(s=>ae(s.role)).length;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-white sm:text-xl",children:"Teammates"}),e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:w-auto sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1 sm:w-64",children:[e.jsx(Fe,{className:"pointer-events-none absolute left-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(je,{placeholder:"Search members...",value:l,onChange:s=>h(s.target.value),className:"w-full rounded-xl border-white/20 bg-white/[0.06] pl-10 text-white placeholder:text-gray-400 focus:border-white/30 focus:bg-white/[0.08]"})]}),r&&j?e.jsxs(C,{onClick:p,className:v("rounded-xl",pe),children:[e.jsx(A,{className:"mr-2 h-4 w-4"}),"Invite teammate"]}):null]})]}),r?e.jsx("p",{className:"mb-4 text-xs leading-relaxed text-gray-500",children:"One workspace role per teammate â Member and Viewer include Studio access (edit vs view-only). Owners and Managers always have full access."}):null,e.jsx("div",{className:"space-y-3",children:f.length===0?e.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] py-12 text-center sm:py-16",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white/[0.05]",children:e.jsx(se,{className:"h-8 w-8 text-gray-400"})}),e.jsx("h3",{className:"mb-2 text-lg font-semibold text-white",children:"No members found"}),e.jsx("p",{className:"mb-6 text-sm text-gray-400",children:r?"Invite someone to join your team workspace.":"Your team roster will appear here once members are added."}),r&&j?e.jsxs(C,{onClick:p,className:v("rounded-xl",pe),children:[e.jsx(A,{className:"mr-2 h-4 w-4"}),"Invite teammate"]}):r?e.jsx("p",{className:"text-sm text-gray-500",children:"Use Invite teammate above to add someone to your workspace."}):null]}):f.map(s=>{const R=new Date(s.joinedAt).toLocaleDateString(),E=s.user.fullName||s.user.email,I=m===s.user.id,O=ae(s.role),P=O&&c<=1,K=r&&!I&&!P&&ge(b,s.role);return e.jsxs("div",{className:v(ns,"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between"),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-4",children:[e.jsx(xs,{name:s.user.fullName,email:s.user.email,avatarUrl:s.user.avatarUrl}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"truncate text-base font-semibold text-white sm:text-lg",children:E}),I?e.jsx(_,{variant:"outline",className:"border-blue-500/40 bg-blue-500/10 text-blue-200",children:"You"}):null,O?e.jsxs(_,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 text-amber-200",children:[e.jsx(te,{className:"mr-1 h-3 w-3"}),"Owner"]}):null]}),e.jsx("p",{className:"truncate text-sm text-gray-400",children:s.user.email}),e.jsxs("p",{className:"mt-0.5 text-xs text-gray-500",children:["Joined ",R]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[r&&ge(b,s.role)?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-600",children:"Worksp
1ace role"}),e.jsx("select",{value:s.role,disabled:S===s.id||P,onChange:L=>{const D=fe(L.target.value);D!==fe(s.role)&&n({member:s,nextRole:D})},className:ts,style:Ms,"aria-label":`Workspace role for ${E}`,children:k.map(L=>e.jsx("option",{value:L.value,className:"bg-gray-900 text-white",children:L.label},L.value))})]}):e.jsx(_,{variant:"outline",className:"border-white/20 text-gray-300",children:M(s.role)}),e.jsx(_,{variant:"outline",className:s.isActive?"theme-accent-soft theme-accent-text":"theme-chip-idle",children:s.isActive?"Active":"Inactive"}),r?e.jsxs(We,{children:[e.jsx(ze,{asChild:!0,children:e.jsx(C,{type:"button",variant:"outline",size:"sm","aria-label":`Actions for ${E}`,className:"theme-icon-btn h-9 w-9 rounded-xl p-0",children:e.jsx(Ye,{className:"h-4 w-4"})})}),e.jsx(Be,{align:"end",className:"border-white/15 bg-zinc-950 text-white",children:K?e.jsx(ce,{className:"cursor-pointer text-red-300 focus:bg-red-500/15 focus:text-red-200",disabled:N===s.id,onClick:()=>x(s),children:N===s.id?"Removingâ¦":"Remove from team"}):e.jsx(ce,{disabled:!0,className:"text-gray-500",children:I?"You can't remove yourself":"Last owner cannot be removed"})})]}):null]})]},s.id)})})]}),e.jsx(_s,{open:!!i,memberName:i?.member.user.fullName||i?.member.user.email||"Teammate",currentRole:i?.member.role??"org_member",nextRole:i?.nextRole??"org_member",isLoading:!!i&&S===i.member.id,onCancel:()=>n(null),onConfirm:()=>{if(!i)return;const{member:s,nextRole:R}=i;n(null),u(s.id,R)}}),e.jsx(z,{open:!!o,onOpenChange:s=>!s&&x(null),children:e.jsxs(Y,{className:"border-white/15 bg-zinc-950 text-white",children:[e.jsxs(B,{children:[e.jsx(V,{children:"Remove teammate?"}),e.jsx($,{className:"text-gray-400",children:o?`${o.user.fullName||o.user.email} will lose access to shared projects and the brand library.`:null})]}
1),e.jsxs(H,{children:[e.jsx(Q,{className:"border-white/15 bg-transparent text-white hover:bg-white/10",children:"Cancel"}),e.jsx(G,{className:"bg-red-600 text-white hover:bg-red-500",onClick:()=>{o&&(w(o.id),x(null))},children:"Remove"})]})]})})]})}function Ce(a){return a.status!=="pending"?!1:new Date(a.expiresAt)<new Date}function Us(a){return a.status==="accepted"?{label:"Accepted",className:"theme-accent-soft theme-accent-text border-brand-border",icon:e.jsx($e,{className:"mr-1 h-3 w-3"})}:a.status==="declined"?{label:"Declined",className:"border-red-500/40 bg-red-500/10 text-red-200",icon:e.jsx(He,{className:"mr-1 h-3 w-3"})}:Ce(a)?{label:"Expired",className:"theme-chip-idle",icon:e.jsx(me,{className:"mr-1 h-3 w-3"})}:{label:"Pending",className:"theme-chip-idle",icon:e.jsx(me,{className:"mr-1 h-3 w-3"})}}function Fs(a){return a.status==="declined"||Ce(a)}function Ws({invites:a,pastInvites:l=[],searchTerm:h,onInviteClick:p,onCancelInvite:u,onResendInvite:w,hideInviteActions:m=!1,cancellingInviteId:r=null,resendingInviteId:j=null,actorOrgRole:S=null}){const[N,b]=d.useState(null),[g,k]=d.useState("pending"),x=(g==="pending"?a:l).filter(n=>n.email.toLowerCase().includes(h.toLowerCase())),i=(n,f)=>{const c=new Date(n.createdAt).toLocaleDateString(),s=M(n.role??"org_member"),R=ws(n.role??"org_member").tagline,E=Us(n),I=gs(S,n.role??"org_member");return e.jsxs("div",{className:"theme-row flex flex-col gap-4 roun
1ded-xl px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"theme-accent-soft flex h-11 w-11 shrink-0 items-center justify-center rounded-xl sm:h-12 sm:w-12",children:e.jsx(W,{className:"theme-accent-text h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"break-words text-base font-semibold sm:text-lg",children:n.email}),e.jsxs("p",{className:"theme-caption text-sm",children:["Invited by ",n.invitedBy?.fullName||n.invitedBy?.email||"Unknown"]}),e.jsxs("p",{className:"theme-caption mt-0.5 text-xs",children:["Sent ",c]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[e.jsx(_,{variant:"outline",className:"theme-chip-idle",children:s}),e.jsx("span",{className:"theme-caption hidden max-w-[12rem] break-words text-xs lg:inline",title:R,children:R}),e.jsxs(_,{variant:"outline",className:E.className,children:[E.icon,E.label]}),f==="pending"&&I?e.jsx(C,{onClick:()=>b(n),disabled:r===n.id,variant:"outline",size:"sm",className:"theme-segment-off rounded-xl",children:r===n.id?e.jsx(de,{size:"sm",variant:"onLight"}):"Cancel invite"}):I&&Fs(n)&&w?e.jsx(C,{onClick:()=>w(n.id),disabled:j===n.id,variant:"outline",size:"sm",className:"theme-segment-off rounded-xl",children:j===n.id?e.jsx(de,{size:"sm",variant:"onLight"}):e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"mr-1.5 h-3.5 w-3.5"}),"Resend"]})}):null]})]},n.id)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold sm:text-xl",children:g==="pending"?"Pending invitations":"Past invitations"}),e.jsx("p",{className:"theme-caption mt-0.5 text-xs",children:g==="pending"?"Invites waiting for a response.":"Accepted, declined, or expired invites."})]}),m?null:e.jsxs(C,{onClick:p,className:"theme-cta rounded-xl",children:[e.jsx(A,{className:"mr-2 h-4 w-4"}),"Send invite"]})]}),e.jsxs("div",{className:"theme-segment-track mb-4",children:[e.jsxs("button",{type:"button",className:v("rounded-lg px-3 py-1.5 text-[13px] font-medium transition-colors",g==="pending"?"theme-segment-on":"theme-segment-off"),onClick:()=>k("pending"),children:["Pending (",a.length,")"]}),e.jsxs("button",{type:"button",className:v("rounded-lg px-3 py-1.5 text-[13px] font-medium transition-colors",g==="past"?"theme-segment-on":"theme-segment-off"),onClick:()=>k("past"),children:["Past (",l.length,")"]})]}),e.jsx("div",{className:"space-y-3",children:x.length===0?e.jsxs("div",{className:"rounded-xl border border-brand-border bg-brand-wash py-12 text-center sm:py-16",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-brand-card",children:e.jsx(W,{className:"theme-muted h-8 w-8"})}),e.jsx("h3",{className:"mb-2 text-lg font-semibold",children:g==="pending"?"No pending invitations":"No past invitations"}),e.jsx("p",{className:"theme-caption mb-6 text-sm",children:g==="pending"?is:"Past invites will appear here after they are accepted, declined, or expire."}),g==="pending"&&!m?e.jsxs(C,{onClick:p,className:"theme-cta rounded-xl",children:[e.jsx(A,{className:"mr-2 h-4 w-4"}),"Send invite"]}):g==="pending"&&m?e.jsx("p",{className:"theme-caption text-sm",children:"Use Invite teammate above to send a new invitation."}):null]}):x.map(n=>i(n,g))})]}),e.jsx(z,{open:!!N,onOpenChange:n=>!n&&b(null),children:e.jsxs(Y,{className:"theme-sheet border-brand-border shadow-2xl sm:rounded-2xl",children:[e.jsxs(B,{children:[e.jsx(V,{children:"Cancel invitation?"}),e.jsx($,{className:"theme-caption",children:N?`The invite to ${N.email} will be withdrawn. You can send a new one anytime.`:null})]}
1),e.jsxs(H,{className:"gap-2 sm:gap-0",children:[e.jsx(Q,{className:"theme-segment-off rounded-xl",children:"Keep invite"}),e.jsx(G,{className:"rounded-xl bg-red-600 text-white hover:bg-red-500 focus:ring-red-500",onClick:()=>{N&&(u(N.id),b(null))},children:"Cancel invite"})]})]})})]})}const zs=[{icon:ne,label:"Name your team workspace"},{icon:ve,label:"Create a shared project"},{icon:A,label:"Invite your first teammate"}],Ys=[{icon:A,label:"Send an email invitation"},{icon:ve,label:"They join your shared projects"},{icon:ne,label:"Collaborate in Studio together"}];function Bs({onSetup:a,profileComplete:l=!1,className:h}){const p=l?Ys:zs,u=l?"Invite your team":ls,w=l?"Your workspace is ready. Send one invitation to get collaboration started.":os,m=l?"Invite teammate":cs;return e.jsxs("div",{className:v(rs,"mx-auto max-w-lg p-8 sm:p-9",h),children:[e.jsxs("div",{className:"text-center sm:text-left",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-gray-500",children:l?"Next step":"Get started"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-tight text-white/95 sm:text-[1.35rem]",children:u}),e.jsx("p",{className:"mt-2 text-[15px] leading-relaxed text-gray-400",children:w})]}),e.jsx("ul",{className:"mt-6 space-y-2",children:p.map(({icon:r,label:j})=>e.jsxs("li",{className:"flex items-center gap-3 rounded-xl px-3 py-2.5 text-sm text-gray-300",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-white/[0.05]",children:e.jsx(r,{className:"h-4 w-4 text-blue-300/90","aria-hidden":!0})}),j]},j))}),e.jsxs(C,{className:v("mt-7 h-11 w-full rounded-xl text-[15px] font-semibold",q),onClick:a,children:[e.jsx(A,{className:"mr-2 h-4 w-4","aria-hidden":!0}),m]})]})}function Vs(a){return!a||a==="free"?"Free":a.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase())}function $s({organizationName:a,teamBilling:l,members:h,currentUserId:p,onRenameWorkspace:u,onTransferOwnership:w,onManageBilling:m,isRenaming:r=!1,isTransferring:j=!1}){const[S,N]=d.useState(a??""),[b,g]=d.useState(""),[k,o]=d.useState(!1);d.useEffect(()=>{N(a??"")},[a]);const x=d.useMemo(()=>h.filter(c=>c.isActive&&c.user.id!==p&&c.role!=="org_owner"),[h,p]),i=x.find(c=>c.user.id===b),n=async c=>{c.preventDefault();const s=S.trim();!s||s===(a??"").trim()||await u(s)},f=async()=>{b&&(await w(b),o(!1),g(""))};return e.jsxs("div",{className:"theme-group mb-6 rounded-2xl p-5 sm:p-6",children:[e.jsxs("div",{className:"mb-5 flex items-start gap-3",children:[e.jsx("div",{className:"theme-accent-soft flex h-11 w-11 shrink-0 items-center justify-center rounded-xl",children:e.jsx(te,{className:"theme-accent-text h-5 w-5","aria-hidden":!0})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Workspace settings"}),e.jsx("p",{className:"theme-caption mt-1 text-sm",children:"Owner-only controls for billing, naming, and ownership."})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs("form",{onSubmit:n,className:"space-y-3 rounded-2xl border border-brand-border bg-brand-wash p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ne,{className:"theme-muted h-4 w-4","aria-hidden":!0}),"Workspace name"]}),e.jsx(he,{htmlFor:"workspace-name",className:"sr-only",children:"Workspace name"}),e.jsx(je,{id:"workspace-name",value:S,onChange:c=>N(c.target.value),className:"theme-field",placeholder:"Your team name"}),e.jsx(C,{type:"submit",size:"sm",disabled:r||!S.trim()||S.trim()===(a??"").trim(),className:v("rounded-xl",q),children:r?"Savingâ¦":"Save name"})]}),e.jsxs("div",{className:"space-y-3 rounded-2xl border border-brand-border bg-brand-wash p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Qe,{className:"theme-muted h-4 w-4","aria-hidden":!0}),"Team plan"]}),e.jsxs("p",{className:"text-sm",children:[Vs(l?.subscription_plan),l?.subscription_status?e.jsxs("span",{className:"theme-muted",children:[" · ",l.subscription_status]}):null]}),l?.canInviteAsOwner?null:e.jsx("p",{className:"theme-accent-text text-xs",children:"Teams (Enterprise) plan is required to invite additional owners."}),m?e.jsx(C,{type:"button",variant:"outline",size:"sm",className:"theme-segment-off rounded-xl",onClick:m,children:"Manage billing"}):null]}),e.jsxs("div",{className:"space-y-3 rounded-2xl border border-brand-border bg-brand-wash p-4 lg:col-span-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ge,{className:"h-4 w-4 text-red-500","aria-hidden":!0}),"Transfer ownership"]}),e.jsx("p",{className:"theme-caption text-sm",children:"Promote a teammate to owner. You will become a manager and keep access to the workspace."}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(he,{htmlFor:"transfer-target",className:"theme-caption mb-2 block text-xs",children:"New owner"}),e.jsxs("select",{id:"transfer-target",value:b,onChange:c=>g(c.target.value),className:"theme-field w-full",disabled:x.length===0||j,children:[e.jsx("option",{value:"",className:"bg-brand-card text-brand-ink",children:"Select a teammate"}),x.map(c=>e.jsx("option",{value:c.user.id,className:"bg-brand-card text-brand-ink",children:c.user.fullName||c.user.email}
1,c.id))]})]}),e.jsx(C,{type:"button",variant:"outline",size:"sm",className:"rounded-xl border-red-500/40 text-red-600 hover:bg-red-500/10",disabled:!b||j,onClick:()=>o(!0),children:"Transfer ownership"})]})]})]}),e.jsx(z,{open:k,onOpenChange:o,children:e.jsxs(Y,{className:"theme-sheet border-brand-border",children:[e.jsxs(B,{children:[e.jsx(V,{children:"Transfer workspace ownership?"}),e.jsx($,{className:"theme-caption",children:i?`${i.user.fullName||i.user.email} will become the workspace owner. You will be demoted to Manager. This cannot be undone from this screen without the new ownerâs help.`:"Choose a teammate to promote to owner."})]}),e.jsxs(H,{children:[e.jsx(Q,{className:"theme-segment-off",children:"Cancel"}),e.jsx(G,{className:"bg-red-600 text-white hover:bg-red-500",disabled:!b||j,onClick:c=>{c.preventDefault(),f()},children:j?"Transferringâ¦":"Confirm transfer"})]})]})})]})}function Hs({defaultExpanded:a=!0,className:l}){const[h,p]=d.useState(a),[u,w]=d.useState("org_member"),m=fs.filter(r=>js.includes(r.value));return e.jsxs("div",{className:v(Ne,"overflow-hidden",l),children:[e.jsxs("button",{type:"button",onClick:()=>p(r=>!r),className:"flex w-full items-start gap-3 p-4 text-left transition-colors hover:bg-white/[0.02] sm:p-5","aria-expanded":h,children:[e.jsx("span",{className:"theme-accent-fill mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl",children:e.jsx(qe,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"theme-ink block text-base font-semibold",children:"Roles"}),e.jsx("span",{className:"theme-caption mt-1 block",children:"What each person can do."})]}),e.jsx(Ke,{className:v("mt-1 h-5 w-5 shrink-0 text-gray-500 transition-transform",h&&"rotate-180"),"aria-hidden":!0})]}),h?e.jsxs("div",{className:"border-t border-white/10 px-4 pb-5 pt-4 sm:px-5",children:[e.jsx("p",{className:"theme-caption mb-4",children:"One role each. Member can edit. Viewer can look. Owners and managers can do everything."}),e.jsx(ms,{value:u,onChange:w,roles:m,className:"mb-4"}),e.jsx(ye,{role:u,showHeader:!1})]}):null]})}const Ca=()=>{Je();const{user:a,isLoading:l,refetch:h}=Xe(),[p,u]=d.useState(!1),[w,m]=d.useState(!1),[r,j]=d.useState(""),[S,N]=d.useState("members"),[b,g]=d.useState({email:"",role:"org_member"}),{workspaceRole:k,organization:o,members:x,orgQuery:i,membersQuery:n,canManageMembers:f,isOwnerOnly:c,teamBilling:s}=Os(),R=Ze({queryKey:["/api/projects","team-people",a?.id],queryFn:Cs,enabled:!!a?.id,staleTime:3e4}),E=!!o&&i.isSuccess,I=Ss(E&&f),O=I.data??[],P=d.useMemo(()=>O.filter(t=>t.status==="pending"&&new Date(t.expiresAt)>=new Date),[O]),K=d.useMemo(()=>O.filter(t=>t.status==="accepted"||t.status==="declined"||t.status==="pending"&&new Date(t.expiresAt)<new Date),[O]),L=d.useMemo(()=>x.filter(t=>ae(t.role)).length,[x]),D=d.useMemo(()=>x.filter(t=>bs(t.role)).length,[x]),re=s?.canInviteAsOwner??!1,J=ks(),X=Ts(),Z=Es(),ee=Is(),ie=Rs(),le=As(),{inviteUser:Se,isLoading:ke}=hs({onSuccess:()=>{u(!1),g({email:"",role:"org_member"}),N("invites")}});ys(),d.useEffect(()=>{i.isSuccess&&!o&&(h(),i.refetch())},[i.isSuccess,o,i,h]);const Te=t=>{if(!t.email){y({title:"Error",description:"Email is required",variant:"destructive"});return}Se({email:t.email,role:t.role})},Ee=()=>Ps({returnTo:ss,user:a,hasProjects:(R.data?.projects?.length??0)>0}),oe=Ls(a),Ie=async t=>{try{await Z.mutateAsync(t),y({title:"Success",description:"Invitation cancelled"})}catch(T){y({title:"Error",description:F(T,"Failed to cancel invitation"),variant:"destructive"})}},Re=async t=>{try{await ee.mutateAsync(t),y({title:"Invite resent",description:"A fresh invitation email was sent."})}catch(T){y({title:"Error",description:F(T,"Failed to resend invitation"),variant:"destructive"})}},Ae=async(t,T)=>{try{await J.mutateAsync({memberId:t,role:T}),y({title:"Success",description:"Member role updated"})}catch(Ue){y({title:"Error",description:F(Ue,"Failed to update member role"),variant:"destructive"})}},Oe=async t=>{try{await X.mutateAsync(t),y({title:"Success",description:"Member removed from team"})}catch(T){y({title:"Error",description:F(T,"Failed to remove member"),variant:"destructive"})}},Le=async t=>{try{await ie.mutateAsync(t),await h(),await i.refetch(),y({title:"Workspace updated",description:"Your team name has been saved."})}catch{y({title:"Error",description:"Failed to rename workspace",variant:"destructive"})}},Pe=async t=>{try{await le.mutateAsync(t),await h(),await i.refetch(),await n.refetch(),y({title:"Ownership transferred",description:"You are now a manager in this workspace."})}catch{y({title:"Error",description:"Failed to transfer ownership",variant:"destructive"})}},_e=!!a?.id,Me=l||_e&&(i.isLoading||o&&(n.isLoading||f&&I.isLoading)),De=f?e.jsxs(C,{size:"sm",className:v("rounded-xl",q),onClick:()=>u(!0),children:[e.jsx(A,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),"Invite teammate"]}):null;if(l||Me)return e.jsx(as,{currentPage:"people",orgName:o?.name});if(i.isSuccess&&!o){const t=i.data?.message,T=i.data?.membershipStatus==="inactive";return e.jsxs(ue,{orgName:a?.company_name??null,currentPage:"people",children:[e.jsx(xe,{title:"People",description:T?"You no longer have access to your previous team.":oe?"Your workspace is ready â invite colleagues to collaborate.":"Set up your team workspace, then invite colleagues to collaborate."}),T&&t?e.jsx("div",{className:"mb-4 rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-amber-100",children:t}):null,e.jsx(Bs,{onSetup:Ee,profileComplete:oe})]})}return e.jsxs(ue,{orgName:o?.name,currentPage:"people",children:[e.jsx(xe,{title:"People",description:o?.name?f?`People in ${o.name}.`:`View teammates in ${o.name}.`:f?"Manage teammates and invitations for your workspace.":"View teammates in your workspace.",trailing:De}),e.jsxs("div",{className:v("mb-6 grid gap-3",f?"grid-cols-2 lg:grid-cols-4":"grid-cols-2 lg:grid-cols-3"),children:[e.jsx(U,{label:"Total members",value:x.length,icon:e.jsx(se,{className:"h-5 w-5","aria-hidden":!0})}),f?e.jsx(U,{label:"Pending invites",value:P.length,icon:e.jsx(W,{className:"h-5 w-5","aria-hidden":!0})}):null,e.jsx(U,{label:"Owners",value:L,icon:e.jsx(te,{className:"h-5 w-5","aria-hidden":!0})}),e.jsx(U,{label:"Managers",value:D,icon:e.jsx(es,{className:"h-5 w-5","aria-hidden":!0})})]}),e.jsx(Hs,{defaultExpanded:f,className:"mb-6"}),c?e.jsx($s,{organizationName:o?.name,teamBilling:s,members:x,currentUserId:a?.id,onRenameWorkspace:Le,onTransferOwnership:Pe,onManageBilling:()=>m(!0),isRenaming:ie.isPending,isTransferring:le.isPending}):null,e.jsx("div",{className:v(Ne,"overflow-hidden"),children:e.jsxs(vs,{value:S,onValueChange:t=>N(t),className:"w-full",children:[e.jsx("div",{className:"border-b border-white/10 px-4 py-4 sm:px-6",children:e.jsxs(Ns,{className:v("grid h-auto w-full rounded-xl border border-white/10 bg-white/[0.04] p-1",f?"grid-cols-2":"grid-cols-1"),children:[e.jsxs(be,{value:"members",className:"rounded-lg text-gray-400 data-[state=active]:bg-white/10 data-[state=active]:text-white",children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Members (",x.length,")"]}),f?e.jsxs(be,{value:"invites",className:"rounded-lg text-gray-400 data-[state=active]:bg-white/10 data-[state=active]:text-white",children:[e.jsx(W,{className:"mr-2 h-4 w-4"}),"Invitations (",P.length,")"]}):null]})}),e.jsx(we,{value:"members",className:"mt-0",children:e.jsx(Ds,{members:x,searchTerm:r,onSearchChange:j,onInviteClick:()=>u(!0),onUpdateRole:Ae,onRemoveMember:Oe,currentUserId:a?.id,canManageMembers:f,showInviteButton:!1,updatingMemberId:J.isPending?J.variables?.memberId:null,removingMemberId:X.isPending?X.variables:null,actorOrgRole:k,canInviteAsOwner:re})}),e.jsx(we,{value:"invites",className:"mt-0",children:e.jsx(Ws,{invites:P,pastInvites:K,searchTerm:r,onInviteClick:()=>u(!0),onCancelInvite:Ie,onResendInvite:Re,hideInviteActions:!0,cancellingInviteId:Z.isPending?Z.variables:null,resendingInviteId:ee.isPending?ee.variables:null,actorOrgRole:k})})]})}),e.jsx(us,{open:p,onClose:()=>u(!1),onInvite:Te,organizationName:o?.name,onViewPlans:()=>{u(!1),m(!0)},isLoading:ke,inviteData:b,onInviteDataChange:g,actorOrgRole:k,canInviteAsOwner:re}),e.jsx(ds,{isOpen:w,onClose:()=>m(!1)})]})};export{Ca 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.