import{d as C}from"./chunk-QM7X6D7F.mjs";import{a as k,b as $,c as w}from"./chunk-XEHBQAFR.mjs";var _={};$(_,{default:()=>I});var M,I,O=k(()=>{"use strict";M=function(){var e=[{defaultValue:null,kind:"LocalArgument",name:"input"}],t=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"ChatRoomArchivePayload",kind:"LinkedField",name:"chatRoomArchive",plural:!1,selections:[{alias:null,args:null,concreteType:"ChatRoom",kind:"LinkedField",name:"room",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"isArchived",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"ErrorType",kind:"LinkedField",name:"errors",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"field",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"messages",storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:e,kind:"Fragment",metadata:null,name:"ArchiveChatRoomMutation",selections:t,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:e,kind:"Operation",name:"ArchiveChatRoomMutation",selections:t},params:{cacheID:"a5ff92800175aa403361c077d4e49670",id:null,metadata:{},name:"ArchiveChatRoomMutation",operationKind:"mutation",text:`mutation ArchiveChatRoomMutation(
  $input: ChatRoomArchiveInput!
) {
  chatRoomArchive(input: $input) {
    room {
      id
      isArchived
    }
    errors {
      field
      messages
    }
  }
}
`}}}();M.hash="f6be713c58475ebea0ad623b11c629de";I=M});import{useCurrentProfile as N}from"@baseapp-frontend/authentication";import{useNotification as H}from"@baseapp-frontend/utils";import{ConnectionHandler as V,useMutation as Q}from"react-relay";function f(e){"@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(e)}var m;function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(c){return Object.getOwnPropertyDescriptor(e,c).enumerable})),r.push.apply(r,o)}return r}function P(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?j(Object(r),!0).forEach(function(o){T(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function T(e,t,r){return(t=E(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(e){var t=K(e,"string");return f(t)=="symbol"?t:t+""}function K(e,t){if(f(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(f(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function x(e,t){return q(e)||L(e,t)||D(e,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 D(e,t){if(e){if(typeof e=="string")return S(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(e,t):void 0}}function S(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function L(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,c,y,v,h=[],l=!0,b=!1;try{if(y=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(o=y.call(r)).done)&&(h.push(o.value),h.length!==t);l=!0);}catch(A){b=!0,c=A}finally{try{if(!l&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(b)throw c}}return h}}function q(e){if(Array.isArray(e))return e}var U=(m!==void 0||(m=(O(),w(_)),m.hash&&m.hash!=="f6be713c58475ebea0ad623b11c629de"&&console.error("The definition of 'ArchiveChatRoomMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data.")),m),X=function(){var t=H(),r=t.sendToast,o=Q(U),c=x(o,2),y=c[0],v=c[1],h=N(),l=h.currentProfile,b=function(i){return y(P(P({},i),{},{onCompleted:function(s,n){var d;n?.forEach(function(p){r(p.message,{type:"error"})}),i==null||(d=i.onCompleted)===null||d===void 0||d.call(i,s,n)},onError:function(s){var n;r(s.message,{type:"error"}),i==null||(n=i.onError)===null||n===void 0||n.call(i,s)},updater:function(s,n){var d,p;!(n!=null&&(d=n.chatRoomArchive)!==null&&d!==void 0&&d.errors)&&l!==null&&l!==void 0&&l.id&&C(s,l.id,function(g){var a,u=g.archived;return u===!(n!=null&&(a=n.chatRoomArchive)!==null&&a!==void 0&&(a=a.room)!==null&&a!==void 0&&a.isArchived)}).forEach(function(g){var a,u;n!=null&&(a=n.chatRoomArchive)!==null&&a!==void 0&&(a=a.room)!==null&&a!==void 0&&a.id&&V.deleteNode(g,n==null||(u=n.chatRoomArchive)===null||u===void 0||(u=u.room)===null||u===void 0?void 0:u.id)}),i==null||(p=i.updater)===null||p===void 0||p.call(i,s,n)}}))};return[b,v]};export{U as a,X as b};
//# sourceMappingURL=chunk-ENGOMVJ6.mjs.map