"use strict";Object.defineProperty(exports, "__esModule", {value: true});

var _chunkUYBEH4KAjs = require('./chunk-UYBEH4KA.js');




var _chunk4CV4JOE5js = require('./chunk-4CV4JOE5.js');

// __generated__/ArchiveChatRoomMutation.graphql.ts
var ArchiveChatRoomMutation_graphql_exports = {};
_chunk4CV4JOE5js.__export.call(void 0, ArchiveChatRoomMutation_graphql_exports, {
  default: () => ArchiveChatRoomMutation_graphql_default
});
var node, ArchiveChatRoomMutation_graphql_default;
var init_ArchiveChatRoomMutation_graphql = _chunk4CV4JOE5js.__esm.call(void 0, {
  "__generated__/ArchiveChatRoomMutation.graphql.ts"() {
    "use strict";
    node = /* @__PURE__ */ function() {
      var v0 = [
        {
          "defaultValue": null,
          "kind": "LocalArgument",
          "name": "input"
        }
      ], v1 = [
        {
          "alias": null,
          "args": [
            {
              "kind": "Variable",
              "name": "input",
              "variableName": "input"
            }
          ],
          "concreteType": "ChatRoomArchivePayload",
          "kind": "LinkedField",
          "name": "chatRoomArchive",
          "plural": false,
          "selections": [
            {
              "alias": null,
              "args": null,
              "concreteType": "ChatRoom",
              "kind": "LinkedField",
              "name": "room",
              "plural": false,
              "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": true,
              "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": v0,
          "kind": "Fragment",
          "metadata": null,
          "name": "ArchiveChatRoomMutation",
          "selections": v1,
          "type": "Mutation",
          "abstractKey": null
        },
        "kind": "Request",
        "operation": {
          "argumentDefinitions": v0,
          "kind": "Operation",
          "name": "ArchiveChatRoomMutation",
          "selections": v1
        },
        "params": {
          "cacheID": "a5ff92800175aa403361c077d4e49670",
          "id": null,
          "metadata": {},
          "name": "ArchiveChatRoomMutation",
          "operationKind": "mutation",
          "text": "mutation ArchiveChatRoomMutation(\n  $input: ChatRoomArchiveInput!\n) {\n  chatRoomArchive(input: $input) {\n    room {\n      id\n      isArchived\n    }\n    errors {\n      field\n      messages\n    }\n  }\n}\n"
        }
      };
    }();
    node.hash = "f6be713c58475ebea0ad623b11c629de";
    ArchiveChatRoomMutation_graphql_default = node;
  }
});

// tmp-babel/messages/common/graphql/mutations/ArchiveChatRoom.js
var _authentication = require('@baseapp-frontend/authentication');
var _utils = require('@baseapp-frontend/utils');
var _reactrelay = require('react-relay');
function _typeof(o) {
  "@babel/helpers - typeof";
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
    return typeof o2;
  } : function(o2) {
    return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
  }, _typeof(o);
}
var _ArchiveChatRoomMutation;
function ownKeys(e, r) {
  var t = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var o = Object.getOwnPropertySymbols(e);
    r && (o = o.filter(function(r2) {
      return Object.getOwnPropertyDescriptor(e, r2).enumerable;
    })), t.push.apply(t, o);
  }
  return t;
}
function _objectSpread(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = null != arguments[r] ? arguments[r] : {};
    r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
      _defineProperty(e, r2, t[r2]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
      Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
    });
  }
  return e;
}
function _defineProperty(e, r, t) {
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
}
function _toPropertyKey(t) {
  var i = _toPrimitive(t, "string");
  return "symbol" == _typeof(i) ? i : i + "";
}
function _toPrimitive(t, r) {
  if ("object" != _typeof(t) || !t) return t;
  var e = t[Symbol.toPrimitive];
  if (void 0 !== e) {
    var i = e.call(t, r || "default");
    if ("object" != _typeof(i)) return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return ("string" === r ? String : Number)(t);
}
function _slicedToArray(r, e) {
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _nonIterableRest() {
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray(r, a) {
  if (r) {
    if ("string" == typeof r) return _arrayLikeToArray(r, a);
    var t = {}.toString.call(r).slice(8, -1);
    return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
  }
}
function _arrayLikeToArray(r, a) {
  (null == a || a > r.length) && (a = r.length);
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  return n;
}
function _iterableToArrayLimit(r, l) {
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  if (null != t) {
    var e, n, i, u, a = [], f = true, o = false;
    try {
      if (i = (t = t.call(r)).next, 0 === l) {
        if (Object(t) !== t) return;
        f = false;
      } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
    } catch (r2) {
      o = true, n = r2;
    } finally {
      try {
        if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
      } finally {
        if (o) throw n;
      }
    }
    return a;
  }
}
function _arrayWithHoles(r) {
  if (Array.isArray(r)) return r;
}
var ArchiveChatRoomMutationQuery = _ArchiveChatRoomMutation !== void 0 ? _ArchiveChatRoomMutation : (_ArchiveChatRoomMutation = (init_ArchiveChatRoomMutation_graphql(), _chunk4CV4JOE5js.__toCommonJS.call(void 0, ArchiveChatRoomMutation_graphql_exports)), _ArchiveChatRoomMutation.hash && _ArchiveChatRoomMutation.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."), _ArchiveChatRoomMutation);
var useArchiveChatRoomMutation = function useArchiveChatRoomMutation2() {
  var _useNotification = _utils.useNotification.call(void 0, ), sendToast = _useNotification.sendToast;
  var _useMutation = _reactrelay.useMutation.call(void 0, ArchiveChatRoomMutationQuery), _useMutation2 = _slicedToArray(_useMutation, 2), commitMutation = _useMutation2[0], isMutationInFlight = _useMutation2[1];
  var _useCurrentProfile = _authentication.useCurrentProfile.call(void 0, ), currentProfile = _useCurrentProfile.currentProfile;
  var commit = function commit2(config) {
    return commitMutation(_objectSpread(_objectSpread({}, config), {}, {
      onCompleted: function onCompleted(response, errors) {
        var _config$onCompleted;
        errors === null || errors === void 0 || errors.forEach(function(error) {
          sendToast(error.message, {
            type: "error"
          });
        });
        config === null || config === void 0 || (_config$onCompleted = config.onCompleted) === null || _config$onCompleted === void 0 || _config$onCompleted.call(config, response, errors);
      },
      onError: function onError(error) {
        var _config$onError;
        sendToast(error.message, {
          type: "error"
        });
        config === null || config === void 0 || (_config$onError = config.onError) === null || _config$onError === void 0 || _config$onError.call(config, error);
      },
      updater: function updater(store, data) {
        var _data$chatRoomArchive, _config$updater;
        if (!(data !== null && data !== void 0 && (_data$chatRoomArchive = data.chatRoomArchive) !== null && _data$chatRoomArchive !== void 0 && _data$chatRoomArchive.errors) && currentProfile !== null && currentProfile !== void 0 && currentProfile.id) {
          _chunkUYBEH4KAjs.getChatRoomConnections.call(void 0, store, currentProfile.id, function(_ref) {
            var _data$chatRoomArchive2;
            var archived = _ref.archived;
            return archived === !(data !== null && data !== void 0 && (_data$chatRoomArchive2 = data.chatRoomArchive) !== null && _data$chatRoomArchive2 !== void 0 && (_data$chatRoomArchive2 = _data$chatRoomArchive2.room) !== null && _data$chatRoomArchive2 !== void 0 && _data$chatRoomArchive2.isArchived);
          }).forEach(function(connectionRecord) {
            var _data$chatRoomArchive3, _data$chatRoomArchive4;
            if (data !== null && data !== void 0 && (_data$chatRoomArchive3 = data.chatRoomArchive) !== null && _data$chatRoomArchive3 !== void 0 && (_data$chatRoomArchive3 = _data$chatRoomArchive3.room) !== null && _data$chatRoomArchive3 !== void 0 && _data$chatRoomArchive3.id) _reactrelay.ConnectionHandler.deleteNode(connectionRecord, data === null || data === void 0 || (_data$chatRoomArchive4 = data.chatRoomArchive) === null || _data$chatRoomArchive4 === void 0 || (_data$chatRoomArchive4 = _data$chatRoomArchive4.room) === null || _data$chatRoomArchive4 === void 0 ? void 0 : _data$chatRoomArchive4.id);
          });
        }
        config === null || config === void 0 || (_config$updater = config.updater) === null || _config$updater === void 0 || _config$updater.call(config, store, data);
      }
    }));
  };
  return [commit, isMutationInFlight];
};




exports.ArchiveChatRoomMutationQuery = ArchiveChatRoomMutationQuery; exports.useArchiveChatRoomMutation = useArchiveChatRoomMutation;
//# sourceMappingURL=chunk-VPKGCVB7.js.map