import{a as V}from"./chunk-3FC6O56G.mjs";import{a as H}from"./chunk-EV4I2B7B.mjs";import{a as Q}from"./chunk-FSFL2CDH.mjs";import{a as q}from"./chunk-K35JDPQ6.mjs";import{a as z}from"./chunk-IG534TUB.mjs";import{a as G,b as J}from"./chunk-JCTDF5UL.mjs";import{a as K}from"./chunk-TYSBACHV.mjs";import{b as W}from"./chunk-EXHBXGDG.mjs";import{a as F}from"./chunk-X332F2ZY.mjs";import{a as g}from"./chunk-66PCFZQY.mjs";import{a as M}from"./chunk-VAFUPSD5.mjs";import{a as L}from"./chunk-XZYL2FE5.mjs";import{useRef as We,useState as Z,useTransition as Fe}from"react";import{Typography as ee}from"@mui/material";import{useRefetchableFragment as Ke}from"react-relay";import{AvatarWithPlaceholder as He}from"@baseapp-frontend/design-system/components/web/avatars";import{jsx as m,jsxs as s}from"react/jsx-runtime";function y(e){"@babel/helpers - typeof";return y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(e)}var xe=["actions"];function X(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?X(Object(n),!0).forEach(function(r){Ae(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Ae(e,t,n){return(t=Ee(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ee(e){var t=Be(e,"string");return y(t)=="symbol"?t:t+""}function Be(e,t){if(y(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(y(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function $e(e,t){if(e==null)return{};var n,r,i=Ne(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ne(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function f(e,t){return Me(e)||Le(e,t)||Ue(e,t)||ke()}function ke(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ue(e,t){if(e){if(typeof e=="string")return Y(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Y(e,t):void 0}}function Y(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Le(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,p,u=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(u.push(r.value),u.length!==t);c=!0);}catch(C){l=!0,i=C}finally{try{if(!c&&n.return!=null&&(p=n.return(),Object(p)!==p))return}finally{if(l)throw i}}return u}}function Me(e){if(Array.isArray(e))return e}var te=function(t){var n,r,i,a,p=t.comment,u=t.currentThreadDepth,c=t.subscriptionsEnabled,l=t.onReplyClick,C=t.CommentUpdateProps,ne=t.CommentsRepliesProps,h=t.ActionOverlayProps,R=t.enableDelete,re=R===void 0?!1:R,O=t.Timestamp,oe=O===void 0?M:O,P=t.CommentUpdate,ie=P===void 0?K:P,_=t.CommentReplyButton,me=_===void 0?q:_,j=t.CommentPinnedBadge,ae=j===void 0?H:j,w=t.CommentReactionButton,le=w===void 0?Q:w,se=Ke(F,p),D=f(se,2),o=D[0],ue=D[1],ce=g(),pe=ce.setCommentReply,S=We(null),de=Z(!1),T=f(de,2),fe=T[0],I=T[1],ye=Z(!1),x=f(ye,2),A=x[0],ve=x[1],be=V({comment:o,onEdit:function(){return I(!0)}}),E=h??{},B=E.actions,Ce=B===void 0?be:B,he=$e(E,xe),ge=Fe(),$=f(ge,2),N=$[0],Re=$[1],Oe=g(),Pe=Oe.resetCommentReply,_e=W(),k=f(_e,2),je=k[0],we=k[1],De=function(){A||Re(function(){ue({isRepliesExpanded:!0},{fetchPolicy:"store-or-network",onComplete:function(U){U?console.error(U):ve(!0)}})})},Se=function(){var d;l?.(),pe({commentItemRef:S,inReplyToId:o.id,name:(d=o.user)===null||d===void 0?void 0:d.fullName}),De()},Te=function(){return fe?m(ie,b({comment:o,onCancel:function(){return I(!1)}},C)):m(ee,{variant:"body2",sx:{whiteSpace:"pre-wrap",wordBreak:"normal",overflowWrap:"anywhere"},children:o.body})};if(!o)return null;var Ie=function(){je({variables:{id:o.id}}),Pe()};return s("div",{children:[m(G,{currentThreadDepth:u,children:m(L,b(b({actions:Ce,showDeleteButton:re&&o.canDelete,handleDeleteItem:Ie,isDeletingItem:we,title:"Comment"},he),{},{ref:S,children:s(J,{children:[m(He,{width:40,height:40,alt:(n=(r=o.user)===null||r===void 0?void 0:r.fullName)!==null&&n!==void 0?n:"Comment's user avatar",src:(i=o.user)===null||i===void 0||(i=i.avatar)===null||i===void 0?void 0:i.url}),s("div",{className:"grid gap-3",children:[s("div",{className:"grid grid-cols-1 justify-start",children:[s("div",{className:"grid grid-cols-[repeat(2,max-content)] items-center gap-2",children:[m(ee,{variant:"subtitle2",children:(a=o.user)===null||a===void 0?void 0:a.fullName}),m(ae,{isPinned:o.isPinned})]}),Te()]}),s("div",{className:"flex justify-between",children:[s("div",{className:"grid grid-cols-[repeat(2,max-content)] gap-4",children:[m(le,{target:o}),m(me,{onReply:Se,isLoadingReplies:N,commentId:o.id,totalCommentsCount:o.commentsCount.total})]}),m(oe,{date:o.created})]})]})]})}))}),A&&!N&&m(z,b({target:o,currentThreadDepth:u+1,subscriptionsEnabled:c,onReplyClick:l,CommentItem:te},ne),"replies-of-".concat(o.id))]})},it=te;export{it as a};
//# sourceMappingURL=chunk-YME7SZLX.mjs.map