const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/v1/vendor-ant-cds-BSoK4Ds2.css","assets/v1/c6eedc03a-BjS1Z-Ak.css","assets/v1/c6a992d55-023Wc09a.css"])))=>i.map(i=>d[i]);
import{r as e,j as s,_ as a}from"./vendor-react-Dp9pL_Wn.js";import{au as n,X as i,av as t,h as r,Z as o,aw as d,ax as l,ay as c,az as u,aA as p,aB as m,aC as f,aD as x,aE as h}from"./c6eedc03a-CsEFTfjy.js";import{aK as g}from"./index-CBEPphRm.js";import{M as j}from"./vendor-intl-D2wGIp4M.js";import{u as _,T as b}from"./c41323917-D2qX4YRv.js";import{u as y}from"./vendor-query-BwvgHhJ1.js";function v({surface:a,isOpen:t,onClose:r,title:o,subtitle:d}){const{handleUpgradeClick:l,handleDismissed:c}=_(a,t),u=e.useRef(!1),p=e.useCallback(()=>{u.current||c(),u.current=!1,r()},[c,r]);return s.jsx(n,{isOpen:t,onClose:p,modalSize:"lg",hasCloseButton:!0,className:"sm:!px-8 sm:!pt-8 sm:!pb-8 !px-6 !pt-8 !pb-8 !min-h-0",title:s.jsx("div",{className:"font-xl-bold",children:o}),children:s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 w-full py-3 mt-4 px-4 border-0.5 border-border-300 rounded-xl text-left",children:[s.jsx(g,{className:"w-5 h-5 text-text-300 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("p",{className:"font-base-bold text-text-000 flex items-center gap-2",children:[s.jsx(j,{defaultMessage:"Share with your team",id:"SR0wOS9AQM"}),s.jsx(b,{})]}),s.jsx("p",{className:"font-base text-text-300",children:d})]})]}),s.jsx("div",{className:"mt-2 flex w-full items-center justify-end gap-2",children:s.jsx(i,{variant:"secondary",size:"default",onClick:()=>{u.current=!0,l()},children:s.jsx(j,{defaultMessage:"Upgrade to Team plan",id:"g5TMaIxuqQ"})})})]})})}const S="pending_shares";function T(e){const s=t(),{activeOrganization:a}=r(),n=a?.uuid;return o(`/api/organizations/${n}/projects/${e}/pending_shares`,{queryKey:[S,{orgUuid:n,projectUuid:e}],enabled:!!n&&!!e&&!s,meta:{noToast:!0}})}function z(e){const s=t(),{activeOrganization:a}=r(),n=a?.uuid;return o(`/api/organizations/${n}/skills/${e}/pending_shares`,{queryKey:[S,{orgUuid:n,skillId:e}],enabled:!!n&&!!e&&!s,meta:{noToast:!0}})}function C(e={}){const{activeOrganization:s}=r(),a=s?.uuid,n=y();return d(`/api/organizations/${a}/pending_shares`,"POST",{...e,enabled:!!a,async onSuccess(s,i,t){const r="skill"===i.resource_type?[S,{orgUuid:a,skillId:i.resource_id}]:[S,{orgUuid:a,projectUuid:i.resource_id}];"pending"===s.pending_share.status&&n.setQueryData(r,e=>[...e??[],s.pending_share]),await(e.onSuccess?.(s,i,t))}})}function N(e={}){const{activeOrganization:s}=r(),a=s?.uuid,n=y();return d(e=>`/api/organizations/${a}/pending_shares/${e.pendingShareId}`,"DELETE",{...e,enabled:!!a,async onSuccess(s,a,i){n.setQueriesData({queryKey:[S]},e=>e?.filter(e=>e.id!==a.pendingShareId)),await(e.onSuccess?.(s,a,i))}})}function O(){const e=l(),s=c(),{unclaimedSeatsByTier:a}=u(),{data:n}=p(),i=m(),{data:t}=f(),{tiers:r}=x({includeUnassigned:!1}),o=e?"enterprise_usage_based":t?.default_new_member_tier??r[0]??"unassigned",d=new Set(n?.tiers_with_unlimited_seats??[]);return{defaultSeatTier:o,stripePromise:i,seatsNeededFor:e=>{if(!s)return 0;let n=0;for(const s of r){if(d.has(s))return 0;n+=a[s]||0}return Math.max(0,e-n)}}}const w=e.lazy(()=>a(()=>import("./ccf5b4c65-5fl7yT8u.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.Elements}))),M=e.lazy(()=>a(()=>import("./cf8b75fc3-DuPIo9_B.js").then(e=>e.a),__vite__mapDeps([0,1,2])).then(e=>({default:e.InsufficientSeatsModal})));function k({isOpen:a,stripePromise:i,onClose:t,onCloseAddMemberModal:r,emails:o,role:d,seatTier:l,seatsNeeded:c,onSendInvites:u}){return s.jsx(e.Suspense,{fallback:s.jsx(n,{isOpen:a,onClose:r,modalSize:"md",children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(h,{size:"sm"})})}),children:s.jsx(w,{stripe:i,children:s.jsx(M,{isOpen:a,onClose:t,onCloseAddMemberModal:r,emails:o,role:d,seatTier:l,canChangeTier:!1,crossTierAssign:!0,seatsNeeded:c,inviteType:1===o.length?"individual":"bulk",onSendInvites:u})})})}export{k as L,v as T,C as a,N as b,O as c,T as d,z as u};
