1import{b6 as M,dc as N,b5 as k,b4 as C,j as s}from"./vendor-data-eBPZki-Z.js";import{o as R,r,n as S}from"./vendor-react-BgtJhS2O.js";import{eY as F,eZ as O,e_ as E,dv as L}from"./vendor-zod-Bei2Z9MS.js";import{m as U,bw as _}from"./index-DTQGL8n8.js";import{u as P}from"./useTrackScreen-BLOOZkQ_.js";import{D as T,a as I,b as Q}from"./DmReplyWarningBanner-BK4vqg_I.js";import{u as W}from"./useUserSettingValue-BuB0sMd0.js";import"./StatusPill-D1LA3ydS.js";function V(){P("DMNew");const{username:x=""}=R(),e=M(x||null),t=e.data?.id??null,i=N(t),l=i.data,o=k(t),d=C(),[u,c]=r.useState(""),[g,f]=r.useState(!0),n=F(e.data?.isBanned,o.data&&!o.data.allowed?o.data.reason??O:null),p=W("dm_permission","following"),y=typeof p=="string"?p:"following",h=e.data?.displayName||e.data?.username||"This user",v=!n&&e.data?E(y,e.data.isFollowingYou??!1,h):null,j=r.useCallback(a=>{if(a.key==="Enter"&&!a.shiftKey){if(a.preventDefault(),n)return;a.currentTarget.form?.requestSubmit()}},[n]),w=r.useCallback(a=>{a.preventDefault();const m=u.trim();!m||!t||n||L(m)||(c(""),d.mutate({text:m,recipient_ulid:t}))},[u,t,n,d]),b=e.isLoading||!!t&&i.isLoading||!!t&&i.isFetching&&l==null,D=r.useMemo(()=>{const a=e.data;return a?{displayName:a.displayName,username:a.username,avatarUrl:a.avatarUrl,badges:a.badges,isBanned:a.isBanned===!0}:null},[e.data]);return e.isError?s.jsx("div",{className:"max-w-[600px] p-8 text-center text-text-secondary dark:text-text-secondary-dark",children:s.jsx("p",{children:"Couldn't find that user. They may not exist or have been removed."})}):l?s.jsx(S,{to:`/messages/${l}`,replace:!0}):s.jsxs("div",{className:"flex flex-col h-[calc(100dvh-3.5rem)] md:h-dvh max-w-[600px]",children:[s.jsx(T,{otherUser:D}),s.jsx("div",{className:"flex-1 overflow-y-auto","aria-live":"polite","aria-relevant":"additions",children:b?s.jsx("div",{className:"py-12 flex justify-center",children:s.jsx(U,{size:"md",label:"Loading"})}):s.jsxs("div",{className:"p-8 text-center text-text-secondary dark:text-text-secondary-dark",children:[s.jsx("p",{children:"No messages yet â say hi."}),o.data?.delivery==="message_request"&&s.jsx("p",{className:"text-xs mt-2",children:"This message will be sent as a request."})]})}),s.jsx(I,{warning:v}),s.jsx(Q,{input:u,onInputChange:c,onInputKeyDown:j,onSubmit:w,isPending:d.isPending||!t,disabledReason:n}),n&&e.data&&s.jsx(_,{open:g,onOpenChange:f,username:e.data.username,theyFollowYou:!!e.data.isFollowingYou,youFollowThem:!!e.data.isFollowing})]})}export{V 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.