\n\t\n\n\n\n\n\n","/*!\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport axios from '@nextcloud/axios'\nimport { loadState } from '@nextcloud/initial-state'\nimport { generateOcsUrl } from '@nextcloud/router'\nimport { defineComponent } from 'vue'\n\nexport default defineComponent({\n\tprops: {\n\t\tresourceId: {\n\t\t\ttype: Number,\n\t\t\trequired: true,\n\t\t},\n\t\tresourceType: {\n\t\t\ttype: String,\n\t\t\tdefault: 'files',\n\t\t},\n\t},\n\tdata() {\n\t\treturn {\n\t\t\teditorData: {\n\t\t\t\tactorDisplayName: getCurrentUser()!.displayName as string,\n\t\t\t\tactorId: getCurrentUser()!.uid as string,\n\t\t\t\tkey: 'editor',\n\t\t\t},\n\t\t\tuserData: {},\n\t\t\tcurrentResourceId: this.resourceId,\n\t\t}\n\t},\n\tmethods: {\n\t\t/**\n\t\t * Autocomplete `@mentions`\n\t\t *\n\t\t * @param search the query\n\t\t * @param callback the callback to process the results with\n\t\t */\n\t\tasync autoComplete(search, callback) {\n\t\t\tconst { data } = await axios.get(generateOcsUrl('core/autocomplete/get'), {\n\t\t\t\tparams: {\n\t\t\t\t\tsearch,\n\t\t\t\t\titemType: this.resourceType,\n\t\t\t\t\titemId: this.currentResourceId,\n\t\t\t\t\tsorter: 'commenters|share-recipients',\n\t\t\t\t\tlimit: loadState('comments', 'maxAutoCompleteResults'),\n\t\t\t\t},\n\t\t\t})\n\t\t\t// Save user data so it can be used by the editor to replace mentions\n\t\t\tdata.ocs.data.forEach((user) => {\n\t\t\t\tthis.userData[user.id] = user\n\t\t\t})\n\t\t\treturn callback(Object.values(this.userData))\n\t\t},\n\n\t\t/**\n\t\t * Make sure we have all mentions as Array of objects\n\t\t *\n\t\t * @param mentions the mentions list\n\t\t */\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tgenMentionsData(mentions: any[]): Record {\n\t\t\tObject.values(mentions)\n\t\t\t\t.flat()\n\t\t\t\t.forEach((mention) => {\n\t\t\t\t\tthis.userData[mention.mentionId] = {\n\t\t\t\t\t\t// TODO: support groups\n\t\t\t\t\t\ticon: 'icon-user',\n\t\t\t\t\t\tid: mention.mentionId,\n\t\t\t\t\t\tlabel: mention.mentionDisplayName,\n\t\t\t\t\t\tsource: 'users',\n\t\t\t\t\t\tprimary: getCurrentUser()?.uid === mention.mentionId,\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\treturn this.userData\n\t\t},\n\t},\n})\n"],"file":"CommentView-BWs00COP.chunk.mjs"}