import {
  __esm,
  __export,
  __toCommonJS
} from "./chunk-NFEGQTCC.mjs";

// __generated__/CommentUpdateMutation.graphql.ts
var CommentUpdateMutation_graphql_exports = {};
__export(CommentUpdateMutation_graphql_exports, {
  default: () => CommentUpdateMutation_graphql_default
});
var node, CommentUpdateMutation_graphql_default;
var init_CommentUpdateMutation_graphql = __esm({
  "__generated__/CommentUpdateMutation.graphql.ts"() {
    "use strict";
    node = /* @__PURE__ */ function() {
      var v0 = [
        {
          "defaultValue": null,
          "kind": "LocalArgument",
          "name": "input"
        }
      ], v1 = [
        {
          "kind": "Variable",
          "name": "input",
          "variableName": "input"
        }
      ], v2 = {
        "alias": null,
        "args": null,
        "kind": "ScalarField",
        "name": "id",
        "storageKey": null
      }, v3 = {
        "alias": null,
        "args": null,
        "kind": "ScalarField",
        "name": "body",
        "storageKey": null
      }, v4 = {
        "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
      }, v5 = [
        {
          "alias": null,
          "args": null,
          "kind": "ScalarField",
          "name": "total",
          "storageKey": null
        }
      ], v6 = {
        "alias": null,
        "args": null,
        "concreteType": "CommentsCount",
        "kind": "LinkedField",
        "name": "commentsCount",
        "plural": false,
        "selections": v5,
        "storageKey": null
      }, v7 = [
        {
          "kind": "Literal",
          "name": "first",
          "value": 5
        },
        {
          "kind": "Literal",
          "name": "orderBy",
          "value": "-is_pinned,-created"
        }
      ], v8 = {
        "alias": null,
        "args": null,
        "kind": "ScalarField",
        "name": "pk",
        "storageKey": null
      };
      return {
        "fragment": {
          "argumentDefinitions": v0,
          "kind": "Fragment",
          "metadata": null,
          "name": "CommentUpdateMutation",
          "selections": [
            {
              "alias": null,
              "args": v1,
              "concreteType": "CommentUpdatePayload",
              "kind": "LinkedField",
              "name": "commentUpdate",
              "plural": false,
              "selections": [
                {
                  "alias": null,
                  "args": null,
                  "concreteType": "Comment",
                  "kind": "LinkedField",
                  "name": "comment",
                  "plural": false,
                  "selections": [
                    v2,
                    v3,
                    {
                      "args": null,
                      "kind": "FragmentSpread",
                      "name": "CommentsList_comments"
                    }
                  ],
                  "storageKey": null
                },
                v4
              ],
              "storageKey": null
            }
          ],
          "type": "Mutation",
          "abstractKey": null
        },
        "kind": "Request",
        "operation": {
          "argumentDefinitions": v0,
          "kind": "Operation",
          "name": "CommentUpdateMutation",
          "selections": [
            {
              "alias": null,
              "args": v1,
              "concreteType": "CommentUpdatePayload",
              "kind": "LinkedField",
              "name": "commentUpdate",
              "plural": false,
              "selections": [
                {
                  "alias": null,
                  "args": null,
                  "concreteType": "Comment",
                  "kind": "LinkedField",
                  "name": "comment",
                  "plural": false,
                  "selections": [
                    v2,
                    v3,
                    {
                      "kind": "InlineFragment",
                      "selections": [
                        v6,
                        {
                          "alias": null,
                          "args": v7,
                          "concreteType": "CommentConnection",
                          "kind": "LinkedField",
                          "name": "comments",
                          "plural": false,
                          "selections": [
                            {
                              "alias": null,
                              "args": null,
                              "concreteType": "PageInfo",
                              "kind": "LinkedField",
                              "name": "pageInfo",
                              "plural": false,
                              "selections": [
                                {
                                  "alias": null,
                                  "args": null,
                                  "kind": "ScalarField",
                                  "name": "endCursor",
                                  "storageKey": null
                                },
                                {
                                  "alias": null,
                                  "args": null,
                                  "kind": "ScalarField",
                                  "name": "hasNextPage",
                                  "storageKey": null
                                }
                              ],
                              "storageKey": null
                            },
                            {
                              "alias": null,
                              "args": null,
                              "concreteType": "CommentEdge",
                              "kind": "LinkedField",
                              "name": "edges",
                              "plural": true,
                              "selections": [
                                {
                                  "alias": null,
                                  "args": null,
                                  "concreteType": "Comment",
                                  "kind": "LinkedField",
                                  "name": "node",
                                  "plural": false,
                                  "selections": [
                                    v2,
                                    {
                                      "alias": null,
                                      "args": null,
                                      "kind": "ScalarField",
                                      "name": "isPinned",
                                      "storageKey": null
                                    },
                                    v8,
                                    v3,
                                    {
                                      "alias": null,
                                      "args": null,
                                      "concreteType": "User",
                                      "kind": "LinkedField",
                                      "name": "user",
                                      "plural": false,
                                      "selections": [
                                        v2,
                                        v8,
                                        {
                                          "alias": null,
                                          "args": null,
                                          "kind": "ScalarField",
                                          "name": "fullName",
                                          "storageKey": null
                                        },
                                        {
                                          "alias": null,
                                          "args": [
                                            {
                                              "kind": "Literal",
                                              "name": "height",
                                              "value": 50
                                            },
                                            {
                                              "kind": "Literal",
                                              "name": "width",
                                              "value": 50
                                            }
                                          ],
                                          "concreteType": "File",
                                          "kind": "LinkedField",
                                          "name": "avatar",
                                          "plural": false,
                                          "selections": [
                                            {
                                              "alias": null,
                                              "args": null,
                                              "kind": "ScalarField",
                                              "name": "url",
                                              "storageKey": null
                                            }
                                          ],
                                          "storageKey": "avatar(height:50,width:50)"
                                        }
                                      ],
                                      "storageKey": null
                                    },
                                    {
                                      "alias": null,
                                      "args": null,
                                      "kind": "ScalarField",
                                      "name": "created",
                                      "storageKey": null
                                    },
                                    v6,
                                    {
                                      "alias": "canChange",
                                      "args": [
                                        {
                                          "kind": "Literal",
                                          "name": "perm",
                                          "value": "change"
                                        }
                                      ],
                                      "kind": "ScalarField",
                                      "name": "hasPerm",
                                      "storageKey": 'hasPerm(perm:"change")'
                                    },
                                    {
                                      "alias": "canDelete",
                                      "args": [
                                        {
                                          "kind": "Literal",
                                          "name": "perm",
                                          "value": "delete"
                                        }
                                      ],
                                      "kind": "ScalarField",
                                      "name": "hasPerm",
                                      "storageKey": 'hasPerm(perm:"delete")'
                                    },
                                    {
                                      "alias": "canReport",
                                      "args": [
                                        {
                                          "kind": "Literal",
                                          "name": "perm",
                                          "value": "report"
                                        }
                                      ],
                                      "kind": "ScalarField",
                                      "name": "hasPerm",
                                      "storageKey": 'hasPerm(perm:"report")'
                                    },
                                    {
                                      "alias": "canPin",
                                      "args": [
                                        {
                                          "kind": "Literal",
                                          "name": "perm",
                                          "value": "pin"
                                        }
                                      ],
                                      "kind": "ScalarField",
                                      "name": "hasPerm",
                                      "storageKey": 'hasPerm(perm:"pin")'
                                    },
                                    {
                                      "alias": null,
                                      "args": null,
                                      "kind": "ScalarField",
                                      "name": "__typename",
                                      "storageKey": null
                                    },
                                    {
                                      "kind": "InlineFragment",
                                      "selections": [
                                        {
                                          "alias": null,
                                          "args": null,
                                          "concreteType": "ReactionsCount",
                                          "kind": "LinkedField",
                                          "name": "reactionsCount",
                                          "plural": false,
                                          "selections": v5,
                                          "storageKey": null
                                        },
                                        {
                                          "alias": null,
                                          "args": null,
                                          "concreteType": "Reaction",
                                          "kind": "LinkedField",
                                          "name": "myReaction",
                                          "plural": false,
                                          "selections": [
                                            v2,
                                            {
                                              "alias": null,
                                              "args": null,
                                              "kind": "ScalarField",
                                              "name": "reactionType",
                                              "storageKey": null
                                            }
                                          ],
                                          "storageKey": null
                                        }
                                      ],
                                      "type": "ReactionsInterface",
                                      "abstractKey": "__isReactionsInterface"
                                    },
                                    {
                                      "kind": "TypeDiscriminator",
                                      "abstractKey": "__isCommentsInterface"
                                    }
                                  ],
                                  "storageKey": null
                                },
                                {
                                  "alias": null,
                                  "args": null,
                                  "kind": "ScalarField",
                                  "name": "cursor",
                                  "storageKey": null
                                }
                              ],
                              "storageKey": null
                            }
                          ],
                          "storageKey": 'comments(first:5,orderBy:"-is_pinned,-created")'
                        },
                        {
                          "alias": null,
                          "args": v7,
                          "filters": [],
                          "handle": "connection",
                          "key": "CommentsList_comments",
                          "kind": "LinkedHandle",
                          "name": "comments"
                        }
                      ],
                      "type": "CommentsInterface",
                      "abstractKey": "__isCommentsInterface"
                    }
                  ],
                  "storageKey": null
                },
                v4
              ],
              "storageKey": null
            }
          ]
        },
        "params": {
          "cacheID": "516cc6fe05cec2d5539841a5d9b94dad",
          "id": null,
          "metadata": {},
          "name": "CommentUpdateMutation",
          "operationKind": "mutation",
          "text": 'mutation CommentUpdateMutation(\n  $input: CommentUpdateInput!\n) {\n  commentUpdate(input: $input) {\n    comment {\n      id\n      body\n      ...CommentsList_comments\n    }\n    errors {\n      field\n      messages\n    }\n  }\n}\n\nfragment CommentItem_comment on Comment {\n  id\n  pk\n  body\n  isPinned\n  user {\n    id\n    pk\n    fullName\n    avatar(width: 50, height: 50) {\n      url\n    }\n  }\n  created\n  commentsCount {\n    total\n  }\n  canChange: hasPerm(perm: "change")\n  canDelete: hasPerm(perm: "delete")\n  canReport: hasPerm(perm: "report")\n  canPin: hasPerm(perm: "pin")\n  ...ReactionButton_target\n  ...CommentItem_target\n}\n\nfragment CommentItem_target on CommentsInterface {\n  __isCommentsInterface: __typename\n  id\n}\n\nfragment CommentsList_comments on CommentsInterface {\n  __isCommentsInterface: __typename\n  id\n  commentsCount {\n    total\n  }\n  comments(first: 5, orderBy: "-is_pinned,-created") {\n    pageInfo {\n      endCursor\n      hasNextPage\n    }\n    edges {\n      node {\n        id\n        isPinned\n        ...CommentItem_comment\n        __typename\n      }\n      cursor\n    }\n  }\n  ...CommentItem_target\n}\n\nfragment ReactionButton_target on ReactionsInterface {\n  __isReactionsInterface: __typename\n  id\n  reactionsCount {\n    total\n  }\n  myReaction {\n    id\n    reactionType\n  }\n}\n'
        }
      };
    }();
    node.hash = "a65012ae50ff01b71fc9c930881f0c1a";
    CommentUpdateMutation_graphql_default = node;
  }
});

// tmp-babel/comments/common/graphql/mutations/CommentUpdate.js
import { useNotification } from "@baseapp-frontend/utils";
import { graphql, useMutation } from "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 _CommentUpdateMutation;
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 CommentUpdateMutationQuery = _CommentUpdateMutation !== void 0 ? _CommentUpdateMutation : (_CommentUpdateMutation = (init_CommentUpdateMutation_graphql(), __toCommonJS(CommentUpdateMutation_graphql_exports)), _CommentUpdateMutation.hash && _CommentUpdateMutation.hash !== "a65012ae50ff01b71fc9c930881f0c1a" && console.error("The definition of 'CommentUpdateMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CommentUpdateMutation);
var useCommentUpdateMutation = function useCommentUpdateMutation2() {
  var _useNotification = useNotification(), sendToast = _useNotification.sendToast;
  var _useMutation = useMutation(CommentUpdateMutationQuery), _useMutation2 = _slicedToArray(_useMutation, 2), commitMutation = _useMutation2[0], isMutationInFlight = _useMutation2[1];
  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);
      }
    }));
  };
  return [commit, isMutationInFlight];
};

export {
  CommentUpdateMutationQuery,
  useCommentUpdateMutation
};
//# sourceMappingURL=chunk-JFHCPOD7.mjs.map