1import{r as e,f as t,j as r}from"./react-vendor-DJDEZQgo.js";import{a as n,u as s,A as i}from"./index-CpSz5HRc.js";import"./yandexMetrika-m_4Niw9W.js";import{u as o,v as a,w as l,x as c}from"./api-CPiT7-aR.js";import{C as u,a as d,A as m}from"./commentNode-DND3aMFI.js";import{u as p}from"./index-dydxNKMt.js";import{B as f,I as x}from"./toastOptions-C9sKTk_P.js";import{H as b}from"./createLucideIcon-CsK1bMTG.js";function j(e,t){let r=!1;const n=e.map(e=>{if(String(e.id)===String(t.id))return r=!0,{...e,...t,replies:e.replies||t.replies||[]};const n=e.replies||[],s=j(n,t);return s!==n?(r=!0,{...e,replies:s}):e});if(r)return n;const s=null==t.parentId?null:String(t.parentId);if(null===s)return[...e,{...t,replies:t.replies||[]}];let i=!1;const o=e=>e.map(e=>{if(String(e.id)===s)return i=!0,{...e,replies:[...e.replies||[],{...t,replies:t.replies||[]}]};const r=e.replies||[],n=o(r);return n===r?e:{...e,replies:n}}),a=o(e);return i?a:e}const h=({stepId:h})=>{const{currentUser:g}=e.useContext(n),[w,S]=e.useState([]),[I,v]=e.useState(""),[y,C]=e.useState([]),R=s(),E=p(),U=t(),k=e.useMemo(()=>new URLSearchParams(U.search).get("notificationThread"),[U.search]),M=e.useRef(null),$=e.useRef(null),B=e.useRef(null),T=e.useRef({time:0,text:""});e.useEffect(()=>{o(h).then(S),E.emit("joinStep",h);const e=e=>{e.stepId===h&&S(t=>j(t,e))};E.on("comment:add",e);const t=({id:e})=>{S(function t(r){return r.filter(t=>t.id!==e).map(e=>({...e,replies:e.replies?t(e.replies):[]}))})};return E.on("comment:delete",t),()=>{E.off("comment:add",e),E.off("comment:delete",t)}},[h]),e.useEffect(()=>{const e=/^step:([^:]+):([^:]+)$/.exec(k||"");if(!e||String(e[1])!==String(h)||M.current===k)return;const t=e[2];if(!w.some(e=>String(e.id)===t))return;const r=window.setTimeout(()=>{const e=document.getElementById(`step-comment-${h}-${t}`);e&&(e.scrollIntoView({behavior:"smooth",block:"center"}),M.current=k)},80);return()=>window.clearTimeout(r)},[w,k,h]);const A=e.useCallback(async()=>{var e;if((null==(e=$.current)?void 0:e.stepId)===h)return $.current.members;const t=await a(h);return $.current={stepId:h,members:t},C(t),t},[h]);e.useEffect(()=>{C([]),A().catch(()=>{})},[A]);const D=async(e,t=null,r=[])=>{if(!e)return!1;const n=Date.now();if(n-T.current.time<5e3)return R({status:"warning",title:"ÐодождиÑе немного",description:"Ðожно оÑпÑавлÑÑÑ Ð½Ðµ ÑаÑе Ñем Ñаз в 5 Ñек",duration:3e3,isClosable:!0}),!1;if(e===T.current.text)return R({status:"warning",title:"ÐоÑ
оже на дÑблиÑование",description:"ÐÑ Ñже оÑпÑавлÑли Ñакое ÑообÑение",duration:3e3,isClosable:!0}),!1;try{const s=await c({stepId:h,parentId:t,text:e,mentionedUserIds:r});return S(e=>j(e,s)),T.current={time:n,text:e},!0}catch(s){return R({status:"error",title:"ÐÑибка",description:"Ðе ÑдалоÑÑ Ð¾ÑпÑавиÑÑ ÐºÐ¾Ð¼Ð¼ÐµÐ½ÑаÑий",duration:3e3,isClosable:!0}),!1}};return r.jsxs(f,{w:"100%",children:[w.map(e=>r.jsx(f,{id:`step-comment-${h}-${e.id}`,scrollMarginTop:"96px",children:r.jsx(u,{c:e,onReply:(t,r,n)=>D(t,r||e.id,n),onDelete:e=>(async e=>{try{await l(e),S(t=>t.filter(t=>t.id!==e))}catch(t){}})(e),loadMentionableUsers:A,mentionableUsers:y})},e.id)),r.jsxs(b,{w:"100%",pt:w.length>0?3:0,children:[g&&r.jsx(i,{size:"sm",src:null==g?void 0:g.avatarUrl,name:(null==g?void 0:g.name)||(null==g?void 0:g.email)}),r.jsx(d,{value:I,onChange:v,onSubmit:async(e,t)=>{const r=await D(e,null,t);return r&&v(""),r},submitRef:B,loadMembers:A,focusBorderColor:"#4F378A",borderRadius:"99px",fontSize:".825rem",fontWeight:"400",placeholder:"ÐомменÑиÑоваÑÑ⦠· @ â ÑпомÑнÑÑÑ"}),r.jsx(x,{border:"1px solid #E2E8F0",bg:"#EBEDF0",borderRadius:"99px",icon:r.jsx(m,{}),onClick:()=>{var e;return null==(e=B.current)?void 0:e.call(B)}})]})]})};export{h as C};
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.