import{a as j}from"./chunk-X2VVDCO6.mjs";import{a as O,c as C}from"./chunk-256IQ3QR.mjs";import{a as P}from"./chunk-66PCFZQY.mjs";import{b as _}from"./chunk-JVKFJ2DY.mjs";import{forwardRef as W}from"react";import{useCurrentProfile as q}from"@baseapp-frontend/authentication";import{setFormRelayErrors as B}from"@baseapp-frontend/utils";import{zodResolver as G}from"@hookform/resolvers/zod";import{useForm as J}from"react-hook-form";import{ConnectionHandler as Q}from"react-relay";import{jsx as X}from"react/jsx-runtime";function m(t){"@babel/helpers - typeof";return m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(t)}function h(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,o)}return r}function x(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?h(Object(r),!0).forEach(function(o){U(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}function U(t,e,r){return(e=V(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function V(t){var e=k(t,"string");return m(e)=="symbol"?e:e+""}function k(t,e){if(m(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var o=r.call(t,e||"default");if(m(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function H(t,e){return z(t)||K(t,e)||$(t,e)||N()}function N(){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 $(t,e){if(t){if(typeof t=="string")return R(t,e);var r={}.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?R(t,e):void 0}}function R(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,o=Array(e);r<e;r++)o[r]=t[r];return o}function K(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var o,i,f,u,c=[],a=!0,l=!1;try{if(f=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;a=!1}else for(;!(a=(o=f.call(r)).done)&&(c.push(o.value),c.length!==e);a=!0);}catch(n){l=!0,i=n}finally{try{if(!a&&r.return!=null&&(u=r.return(),Object(u)!==u))return}finally{if(l)throw i}}return c}}function z(t){if(Array.isArray(t))return t}var A=0,Y=W(function(t,e){var r=t.targetObjectId,o=t.autoFocusInput,i=t.SocialInput,f=i===void 0?j:i,u=t.SocialInputProps,c=u===void 0?{}:u,a=q(),l=a.currentProfile,n=P(),w=!!n.inReplyToId,p=J({defaultValues:O,resolver:G(C)}),T=_(),I=H(T,2),E=I[0],S=I[1],M=function(L){var y;if(!S){A+=1;var D=A.toString(),F=Q.getConnectionID((y=n.inReplyToId)!==null&&y!==void 0?y:r,"CommentsList_comments");E({variables:{input:{body:L.body,targetObjectId:r,inReplyToId:n.inReplyToId,profileId:l?.id,clientMutationId:D},connections:[F]},onCompleted:function(b,g){var d;if(g){console.error(g);return}var s=b==null||(d=b.commentCreate)===null||d===void 0?void 0:d.errors;if(B(p,s),!(s!=null&&s.length)){var v;n.resetCommentReply(),p.reset(),(v=n.commentItemRef)!==null&&v!==void 0&&v.current&&n.commentItemRef.current.scrollIntoView({block:"nearest",inline:"start",behavior:"smooth"})}},onError:console.error})}};return X(f,x({ref:e,placeholder:"Comment...",autoFocusInput:o,form:p,formId:"comment-create",submit:M,isLoading:S,isReply:w,replyTargetName:n.name,onCancelReply:n.resetCommentReply,SubmitActionsProps:{ariaLabel:"create comment"}},c))}),ft=Y;export{ft as a};
//# sourceMappingURL=chunk-5YKVNO5F.mjs.map