{"version":3,"file":"discourse-presence.js","names":["define","_exports","_component","_tracking","_service","_truthHelpers","_userLink","_avatar","_helperFn","_discourseI18n","_component2","_templateFactory","Object","defineProperty","value","default","ComposerPresenceDisplay","static","dt7948","g","this","prototype","service","presence","i","composerPresenceManager","currentUser","siteSettings","tracked","replyChannel","whisperChannel","editChannel","setupReplyChannel","_","on","topic","args","model","isReply","name","id","getChannel","subscribe","cleanup","unsubscribe","setupWhisperChannel","whisperer","setupEditChannel","post","isEdit","notifyState","replyDirty","entity","state","leave","editingPost","whisper","replyingToTopic","n","cached","users","filter","u","slice","presence_max_users_shown","setComponentTemplate","createTemplateFactory","block","moduleName","scope","gt","i18n","isStrictMode","TopicPresenceDisplay","_runloop","_environment","ComposerPresenceManager","keepAlive","arguments","length","undefined","canHideProfile","allow_users_to_hide_profile","isHidingPresence","user_option","hide_presence","_name","_channel","enter","isTesting","_autoLeaveTimer","debounce","cancel"],"sources":["discourse/plugins/discourse-presence/discourse/components/composer-presence-display.js","discourse/plugins/discourse-presence/discourse/components/topic-presence-display.js","discourse/plugins/discourse-presence/discourse/services/composer-presence-manager.js","discourse/plugins/discourse-presence/discourse/templates/connectors/before-composer-controls/presence.js","discourse/plugins/discourse-presence/discourse/templates/connectors/topic-above-footer-buttons/presence.js"],"sourcesContent":["define(\"discourse/plugins/discourse-presence/discourse/components/composer-presence-display\", [\"exports\", \"@glimmer/component\", \"@glimmer/tracking\", \"@ember/service\", \"truth-helpers\", \"discourse/components/user-link\", \"discourse/helpers/avatar\", \"discourse/helpers/helper-fn\", \"discourse-i18n\", \"@ember/component\", \"@ember/template-factory\"], function (_exports, _component, _tracking, _service, _truthHelpers, _userLink, _avatar, _helperFn, _discourseI18n, _component2, _templateFactory) {\n \"use strict\";\n\n Object.defineProperty(_exports, \"__esModule\", {\n value: true\n });\n _exports.default = void 0;\n class ComposerPresenceDisplay extends _component.default {\n static #_ = (() => dt7948.g(this.prototype, \"presence\", [_service.service]))();\n #presence = (() => (dt7948.i(this, \"presence\"), void 0))();\n static #_2 = (() => dt7948.g(this.prototype, \"composerPresenceManager\", [_service.service]))();\n #composerPresenceManager = (() => (dt7948.i(this, \"composerPresenceManager\"), void 0))();\n static #_3 = (() => dt7948.g(this.prototype, \"currentUser\", [_service.service]))();\n #currentUser = (() => (dt7948.i(this, \"currentUser\"), void 0))();\n static #_4 = (() => dt7948.g(this.prototype, \"siteSettings\", [_service.service]))();\n #siteSettings = (() => (dt7948.i(this, \"siteSettings\"), void 0))();\n static #_5 = (() => dt7948.g(this.prototype, \"replyChannel\", [_tracking.tracked]))();\n #replyChannel = (() => (dt7948.i(this, \"replyChannel\"), void 0))();\n static #_6 = (() => dt7948.g(this.prototype, \"whisperChannel\", [_tracking.tracked]))();\n #whisperChannel = (() => (dt7948.i(this, \"whisperChannel\"), void 0))();\n static #_7 = (() => dt7948.g(this.prototype, \"editChannel\", [_tracking.tracked]))();\n #editChannel = (() => (dt7948.i(this, \"editChannel\"), void 0))();\n setupReplyChannel = (() => (0, _helperFn.default)((_, on) => {\n const {\n topic\n } = this.args.model;\n if (!topic || !this.isReply) {\n return;\n }\n const name = `/discourse-presence/reply/${topic.id}`;\n const replyChannel = this.presence.getChannel(name);\n this.replyChannel = replyChannel;\n replyChannel.subscribe();\n on.cleanup(() => replyChannel.unsubscribe());\n }))();\n setupWhisperChannel = (() => (0, _helperFn.default)((_, on) => {\n const {\n topic\n } = this.args.model;\n const {\n whisperer\n } = this.currentUser;\n if (!topic || !this.isReply || !whisperer) {\n return;\n }\n const name = `/discourse-presence/whisper/${topic.id}`;\n const whisperChannel = this.presence.getChannel(name);\n this.whisperChannel = whisperChannel;\n whisperChannel.subscribe();\n on.cleanup(() => whisperChannel.unsubscribe());\n }))();\n setupEditChannel = (() => (0, _helperFn.default)((_, on) => {\n const {\n post\n } = this.args.model;\n if (!post || !this.isEdit) {\n return;\n }\n const name = `/discourse-presence/edit/${post.id}`;\n const editChannel = this.presence.getChannel(name);\n this.editChannel = editChannel;\n editChannel.subscribe();\n on.cleanup(() => editChannel.unsubscribe());\n }))();\n notifyState = (() => (0, _helperFn.default)((_, on) => {\n const {\n topic,\n post,\n replyDirty\n } = this.args.model;\n const entity = this.isEdit ? post : topic;\n if (entity) {\n const name = `/discourse-presence/${this.state}/${entity.id}`;\n this.composerPresenceManager.notifyState(name, replyDirty);\n }\n on.cleanup(() => this.composerPresenceManager.leave());\n }))();\n get isReply() {\n return this.state === \"reply\" || this.state === \"whisper\";\n }\n get isEdit() {\n return this.state === \"edit\";\n }\n get state() {\n const {\n editingPost,\n whisper,\n replyingToTopic\n } = this.args.model;\n if (editingPost) {\n return \"edit\";\n } else if (whisper) {\n return \"whisper\";\n } else if (replyingToTopic) {\n return \"reply\";\n }\n }\n static #_8 = (() => dt7948.n(this.prototype, \"state\", [_tracking.cached]))();\n get users() {\n let users;\n if (this.isEdit) {\n users = this.editChannel?.users || [];\n } else {\n const replyUsers = this.replyChannel?.users || [];\n const whisperUsers = this.whisperChannel?.users || [];\n users = [...replyUsers, ...whisperUsers];\n }\n return users.filter(u => u.id !== this.currentUser.id).slice(0, this.siteSettings.presence_max_users_shown);\n }\n static #_9 = (() => dt7948.n(this.prototype, \"users\", [_tracking.cached]))();\n static #_10 = (() => (0, _component2.setComponentTemplate)((0, _templateFactory.createTemplateFactory)(\n /*\n \n {{#if this.currentUser}}\n {{this.setupReplyChannel}}\n {{this.setupWhisperChannel}}\n {{this.setupEditChannel}}\n {{this.notifyState}}\n \n {{#if (gt this.users.length 0)}}\n