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