import{u as y,a as N,y as b,v as k,cU as p,p as d,j as e,cY as S,c2 as B,_ as $,aK as w,cZ as h,O as m,bX as I,bA as L,cN as E}from"./bundle.CHKSNOJF.js";import{U as A}from"./UserUnsubscribedTooltip-CmrNR5P-.js";import{C as R}from"./ClientActionButtons-q9eajqVG.js";function V(s){const[a]=y(),c=N(),x=b(),u=k(),f=p(),[l,r]=d.useState(),{resource:n,afterClientName:v}=s,j=i=>!!n?.invitations.find(t=>t.client_contact_id===i),C=d.useCallback(i=>n?.invitations?.some(t=>t.client_contact_id===i)||!1,[n?.invitations]),_=d.useCallback(i=>!n?.invitations||!l?.contacts?!1:n.invitations.find(t=>t.client_contact_id===i)?.can_sign||!1,[n?.invitations,l?.contacts]);return d.useEffect(()=>{n?.client?r(n.client):n?.client_id&&f.find(n.client_id).then(i=>r(i)).catch(()=>{})},[n?.client_id]),e.jsxs("div",{className:"flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex flex-col justify-between space-y-0.5",style:{color:c.$3},children:[s.textOnly?e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex space-x-10",children:[e.jsx("span",{className:"text-sm font-medium",style:{color:c.$22},children:a("client")}),e.jsx("span",{className:"text-sm font-medium",children:n?.client?.display_name})]}),v]}):e.jsx(S,{inputLabel:a("client"),onChange:i=>s.onChange(i.id),value:n?.client_id,readonly:s.readonly||!n,clearButton:!!n?.client_id,onClearButtonClick:()=>{r(void 0),s.onClearButtonClick()},initiallyVisible:!n?.client_id,errorMessage:s.errorMessage,disableWithSpinner:s.disableWithSpinner}),l&&e.jsx(R,{client:l}),!!n?.client_id&&e.jsx(e.Fragment,{children:!!l?.locations?.length&&s.onLocationChange&&e.jsx("div",{className:"pt-3",children:e.jsx(B,{leftSide:a("location"),noExternalPadding:!0,noVerticalPadding:!0,children:e.jsx($,{value:n?.location_id,onValueChange:i=>s.onLocationChange?.(i),customSelector:!0,children:l?.locations.map(i=>e.jsx("option",{value:i.id,children:i.name},i.id))})})})})]}),n?.client_id&&l&&l.contacts.length&&e.jsxs("div",{children:[!!(s.onLocationChange&&l?.locations?.length||location)&&e.jsx(w,{className:"mb-2.5",children:a("contacts")}),e.jsx("div",{className:m("divide-y divide-dashed",{"divide-[#09090B1A]":!x.dark_mode,"divide-[#1f2e41]":x.dark_mode}),children:l.contacts.filter(i=>!i.cc_only).map((i,o)=>e.jsxs("div",{className:m("flex justify-between items-center first:pt-0 pt-2",{"pb-1.5":!n.invitations[0]?.link}),children:[e.jsxs("div",{className:"flex flex-col w-full",children:[e.jsxs("div",{className:"flex space-x-2.5 w-full",children:[e.jsx(h,{id:i.id,value:i.id,checked:j(i.id),onChange:t=>s.onContactCheckboxChange(t.target.value,t.target.checked)}),e.jsxs("div",{className:m("flex truncate",{"flex-col":!n.invitations[0]?.link,"space-x-4":n.invitations[0]?.link}),children:[e.jsx("span",{className:"text-sm font-medium",style:{color:c.$3},children:i.first_name.length>=1?`${i.first_name} ${i.last_name}`:i.email||l.display_name}),i.first_name&&e.jsx("span",{className:"text-sm",style:{color:c.$22},children:i.email})]})]}),u?.enable_modules&&e.jsxs("div",{className:"flex space-x-2.5 w-full mt-2",children:[e.jsx(h,{id:`can-sign-${i.id}`,checked:_(i.id),disabled:!1,onChange:t=>{s.onContactCanSignCheckboxChange?.(i.id,t.target.checked)}}),e.jsx("div",{className:"flex truncate",children:e.jsx("span",{className:`text-sm font-medium ${C(i.id)?"":"opacity-50"}`,style:{color:c.$3},children:a("authorized_to_sign")})})]}),e.jsx("div",{className:"flex flex-col relative left-7",children:(()=>{const t=n.invitations?.find(g=>g.client_contact_id===i.id);return!!t?.link&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{className:"font-medium",to:`${t.link}?silent=true&client_hash=${l.client_hash}`,external:!0,children:a("view_in_portal")}),e.jsx(L,{width:"auto",placement:"bottom",message:a("copy_link"),withoutArrow:!0,children:e.jsx("div",{className:"mt-1.5",children:e.jsx(E,{text:t.link})})})]})})()})]}),i.is_locked&&e.jsx(A,{size:24})]},o))})]})]})}export{V as C};
