{"version":3,"file":"discourse-voting.js","names":["define","_exports","Object","defineProperty","value","default","resource","path","map","this","route","resetNamespace","_I18n","_pluginApi","_navItem","name","initialize","withPluginApi","api","container","lookup","voting_enabled","sortOrders","pushObject","t","id","term","addNavigationBarItem","before","customFilter","category","can_vote","customHref","args","pathFor","forceActive","router","queryParams","currentRoute","keys","length","getCurrentUser","addSearchSuggestion","addPostClassesCallback","post","post_number","includePostAttributes","addTagsHtmlCallback","topic","buffer","title","user_voted","userVotedClass","push","url","vote_count","count","join","priority","addCategorySortCriteria","_userTopicList","_userAction","extend","userActionType","TYPES","topics","model","store","findFiltered","filter","modelFor","get","then","set","emptyState","user","isCurrentUser","username","body","_deprecationsHelper","_templateFactory","createTemplateFactory","block","moduleName","scope","isStrictMode","_widget","_iconLibrary","createWidget","tagName","buildClasses","html","iconNode","click","sendWidgetAction","_ajax","_rawHtml","_ajaxError","buildKey","siteSettings","voting_show_who_voted","defaultState","allowClick","initialVote","attrs","state","contents","attach","votesAlert","currentUser","hideVotesAlert","scheduleRerender","clickOutside","addVote","ajax","type","data","topic_id","result","setProperties","votes_exceeded","votes_left","alert","who_voted","catch","popupAjaxError","removeVote","_virtualDom","buttonClass","closed","buildButtonTitle","h","attributes","className","$","cookie","window","location","href","parentWidget","toggleClass","addClass","_getUrl","whoVotedUsers","voteCount","toString","whoVoted","users","addSelf","liked","listClassName","getWhoVoted","toggle","hide","whoVotedAvatars","template","avatar_template","post_url","toLowerCase"],"sources":["discourse/plugins/discourse-topic-voting/discourse/feature-voting-route-map.js","discourse/plugins/discourse-topic-voting/discourse/initializers/discourse-topic-voting.js","discourse/plugins/discourse-topic-voting/discourse/pre-initializers/extend-category-for-voting.js","discourse/plugins/discourse-topic-voting/discourse/routes/user-activity-votes.js","discourse/plugins/discourse-topic-voting/discourse/templates/connectors/category-custom-settings/feature-voting-settings.js","discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting.js","discourse/plugins/discourse-topic-voting/discourse/templates/connectors/user-activity-bottom/user-voted-topics.js","discourse/plugins/discourse-topic-voting/discourse/widgets/remove-vote.js","discourse/plugins/discourse-topic-voting/discourse/widgets/vote-box.js","discourse/plugins/discourse-topic-voting/discourse/widgets/vote-button.js","discourse/plugins/discourse-topic-voting/discourse/widgets/vote-count.js","discourse/plugins/discourse-topic-voting/discourse/widgets/vote-options.js"],"sourcesContent":["define(\"discourse/plugins/discourse-topic-voting/discourse/feature-voting-route-map\", [\"exports\"], function (_exports) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = {\n    resource: \"user\",\n    path: \"users/:username\",\n    map() {\n      this.route(\"userActivity\", {\n        path: \"activity\",\n        resetNamespace: true\n      }, function () {\n        this.route(\"votes\");\n      });\n    }\n  };\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/initializers/discourse-topic-voting\", [\"exports\", \"I18n\", \"discourse/lib/plugin-api\", \"discourse/models/nav-item\"], function (_exports, _I18n, _pluginApi, _navItem) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = {\n    name: \"discourse-topic-voting\",\n    initialize() {\n      (0, _pluginApi.withPluginApi)(\"0.8.32\", api => {\n        const siteSettings = api.container.lookup(\"site-settings:main\");\n        if (siteSettings.voting_enabled) {\n          const pageSearchController = api.container.lookup(\"controller:full-page-search\");\n          pageSearchController.sortOrders.pushObject({\n            name: _I18n.default.t(\"search.most_votes\"),\n            id: 5,\n            term: \"order:votes\"\n          });\n          api.addNavigationBarItem({\n            name: \"votes\",\n            before: \"top\",\n            customFilter: category => {\n              return category && category.can_vote;\n            },\n            customHref: (category, args) => {\n              const path = _navItem.default.pathFor(\"latest\", args);\n              return `${path}?order=votes`;\n            },\n            forceActive: (category, args, router) => {\n              const queryParams = router.currentRoute.queryParams;\n              return queryParams && Object.keys(queryParams).length === 1 && queryParams[\"order\"] === \"votes\";\n            }\n          });\n          api.addNavigationBarItem({\n            name: \"my_votes\",\n            before: \"top\",\n            customFilter: category => {\n              return category && category.can_vote && api.getCurrentUser();\n            },\n            customHref: (category, args) => {\n              const path = _navItem.default.pathFor(\"latest\", args);\n              return `${path}?state=my_votes`;\n            },\n            forceActive: (category, args, router) => {\n              const queryParams = router.currentRoute.queryParams;\n              return queryParams && Object.keys(queryParams).length === 1 && queryParams[\"state\"] === \"my_votes\";\n            }\n          });\n        }\n      });\n      (0, _pluginApi.withPluginApi)(\"0.11.7\", api => {\n        const siteSettings = api.container.lookup(\"site-settings:main\");\n        if (siteSettings.voting_enabled) {\n          api.addSearchSuggestion(\"order:votes\");\n        }\n      });\n    }\n  };\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/pre-initializers/extend-category-for-voting\", [\"exports\", \"I18n\", \"discourse/lib/plugin-api\"], function (_exports, _I18n, _pluginApi) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  function initialize(api) {\n    api.addPostClassesCallback(post => {\n      if (post.post_number === 1 && post.can_vote) {\n        return [\"voting-post\"];\n      }\n    });\n    api.includePostAttributes(\"can_vote\");\n    api.addTagsHtmlCallback(topic => {\n      if (!topic.can_vote) {\n        return;\n      }\n      let buffer = [];\n      let title = \"\";\n      if (topic.user_voted) {\n        title = ` title='${_I18n.default.t(\"topic_voting.voted\")}'`;\n      }\n      let userVotedClass = topic.user_voted ? \" voted\" : \"\";\n      buffer.push(`<a href='${topic.url}' class='list-vote-count vote-count-${topic.vote_count} discourse-tag simple${userVotedClass}'${title}>`);\n      buffer.push(_I18n.default.t(\"topic_voting.votes\", {\n        count: topic.vote_count\n      }));\n      buffer.push(\"</a>\");\n      if (buffer.length > 0) {\n        return buffer.join(\"\");\n      }\n    }, {\n      priority: -100\n    });\n  }\n  var _default = _exports.default = {\n    name: \"extend-category-for-voting\",\n    before: \"inject-discourse-objects\",\n    initialize() {\n      (0, _pluginApi.withPluginApi)(\"0.8.4\", api => initialize(api));\n      (0, _pluginApi.withPluginApi)(\"0.8.30\", api => api.addCategorySortCriteria(\"votes\"));\n    }\n  };\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/routes/user-activity-votes\", [\"exports\", \"discourse/routes/user-topic-list\", \"discourse/models/user-action\", \"I18n\"], function (_exports, _userTopicList, _userAction, _I18n) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = _userTopicList.default.extend({\n    userActionType: _userAction.default.TYPES.topics,\n    model() {\n      return this.store.findFiltered(\"topicList\", {\n        filter: \"topics/voted-by/\" + this.modelFor(\"user\").get(\"username_lower\")\n      }).then(model => {\n        model.set(\"emptyState\", this.emptyState());\n        return model;\n      });\n    },\n    emptyState() {\n      const user = this.modelFor(\"user\");\n      const title = this.isCurrentUser(user) ? _I18n.default.t(\"topic_voting.no_votes_title_self\") : _I18n.default.t(\"topic_voting.no_votes_title_others\", {\n        username: user.username\n      });\n      return {\n        title,\n        body: \"\"\n      };\n    }\n  });\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/category-custom-settings/feature-voting-settings\", [\"exports\", \"ember-this-fallback/deprecations-helper\", \"@ember/template-factory\"], function (_exports, _deprecationsHelper, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    <h3>{{i18n \"topic_voting.title\"}}</h3>\n  <section class=\"field\">\n    <div class=\"enable-topic-voting\">\n      <label class=\"checkbox-label\">\n        <Input\n          @type=\"checkbox\"\n          @checked={{category.custom_fields.enable_topic_voting}}\n        />\n        {{i18n \"topic_voting.allow_topic_voting\"}}\n      </label>\n    </div>\n  </section>\n  */\n  {\n    \"id\": \"MzfT2eth\",\n    \"block\": \"[[[10,\\\"h3\\\"],[12],[1,[28,[35,0],[\\\"topic_voting.title\\\"],null]],[13],[1,\\\"\\\\n\\\"],[10,\\\"section\\\"],[14,0,\\\"field\\\"],[12],[1,\\\"\\\\n  \\\"],[10,0],[14,0,\\\"enable-topic-voting\\\"],[12],[1,\\\"\\\\n    \\\"],[10,\\\"label\\\"],[14,0,\\\"checkbox-label\\\"],[12],[1,\\\"\\\\n      \\\"],[8,[39,1],null,[[\\\"@type\\\",\\\"@checked\\\"],[\\\"checkbox\\\",[30,0,[\\\"category\\\",\\\"custom_fields\\\",\\\"enable_topic_voting\\\"]]]],null],[1,\\\"\\\\n      \\\"],[1,[28,[35,0],[\\\"topic_voting.allow_topic_voting\\\"],null]],[1,\\\"\\\\n    \\\"],[13],[1,\\\"\\\\n  \\\"],[13],[1,\\\"\\\\n\\\"],[13],[1,[28,[32,0],[\\\"[[\\\\\\\"The `category` property path was used in the `discourse/plugins/discourse-topic-voting/discourse/templates/connectors/category-custom-settings/feature-voting-settings.hbs` template without using `this`. This fallback behavior has been deprecated, all properties must be looked up on `this` when used in the template: {{this.category}}\\\\\\\",false,{\\\\\\\"id\\\\\\\":\\\\\\\"ember-this-fallback.this-property-fallback\\\\\\\",\\\\\\\"until\\\\\\\":\\\\\\\"n/a\\\\\\\",\\\\\\\"for\\\\\\\":\\\\\\\"ember-this-fallback\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://deprecations.emberjs.com/v3.x#toc_this-property-fallback\\\\\\\",\\\\\\\"since\\\\\\\":{\\\\\\\"available\\\\\\\":\\\\\\\"0.2.0\\\\\\\"}}]]\\\"],null]]],[],false,[\\\"i18n\\\",\\\"input\\\"]]\",\n    \"moduleName\": \"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/category-custom-settings/feature-voting-settings.hbs\",\n    \"scope\": () => [_deprecationsHelper.default],\n    \"isStrictMode\": false\n  });\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting\", [\"exports\", \"ember-this-fallback/deprecations-helper\", \"@ember/template-factory\"], function (_exports, _deprecationsHelper, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    {{#if model.can_vote}}\n    {{#if model.postStream.loaded}}\n      {{#if model.postStream.firstPostPresent}}\n        <div class=\"voting title-voting\">\n          {{! template-lint-disable no-capital-arguments }}\n          <MountWidget\n            @widget=\"vote-box\"\n            @args={{model}}\n            @showLogin={{route-action \"showLogin\"}}\n          />\n        </div>\n      {{/if}}\n    {{/if}}\n  {{/if}}\n  */\n  {\n    \"id\": \"MnzpRITs\",\n    \"block\": \"[[[41,[30,0,[\\\"model\\\",\\\"can_vote\\\"]],[[[41,[30,0,[\\\"model\\\",\\\"postStream\\\",\\\"loaded\\\"]],[[[41,[30,0,[\\\"model\\\",\\\"postStream\\\",\\\"firstPostPresent\\\"]],[[[1,\\\"      \\\"],[10,0],[14,0,\\\"voting title-voting\\\"],[12],[1,\\\"\\\\n\\\"],[1,\\\"        \\\"],[8,[39,1],null,[[\\\"@widget\\\",\\\"@args\\\",\\\"@showLogin\\\"],[\\\"vote-box\\\",[30,0,[\\\"model\\\"]],[28,[37,2],[\\\"showLogin\\\"],null]]],null],[1,\\\"\\\\n      \\\"],[13],[1,\\\"\\\\n\\\"]],[]],null]],[]],null]],[]],null],[1,[28,[32,0],[\\\"[[\\\\\\\"The `model` property path was used in the `discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting.hbs` template without using `this`. This fallback behavior has been deprecated, all properties must be looked up on `this` when used in the template: {{this.model}}\\\\\\\",false,{\\\\\\\"id\\\\\\\":\\\\\\\"ember-this-fallback.this-property-fallback\\\\\\\",\\\\\\\"until\\\\\\\":\\\\\\\"n/a\\\\\\\",\\\\\\\"for\\\\\\\":\\\\\\\"ember-this-fallback\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://deprecations.emberjs.com/v3.x#toc_this-property-fallback\\\\\\\",\\\\\\\"since\\\\\\\":{\\\\\\\"available\\\\\\\":\\\\\\\"0.2.0\\\\\\\"}}],[\\\\\\\"The `model` property path was used in the `discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting.hbs` template without using `this`. This fallback behavior has been deprecated, all properties must be looked up on `this` when used in the template: {{this.model}}\\\\\\\",false,{\\\\\\\"id\\\\\\\":\\\\\\\"ember-this-fallback.this-property-fallback\\\\\\\",\\\\\\\"until\\\\\\\":\\\\\\\"n/a\\\\\\\",\\\\\\\"for\\\\\\\":\\\\\\\"ember-this-fallback\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://deprecations.emberjs.com/v3.x#toc_this-property-fallback\\\\\\\",\\\\\\\"since\\\\\\\":{\\\\\\\"available\\\\\\\":\\\\\\\"0.2.0\\\\\\\"}}],[\\\\\\\"The `model` property path was used in the `discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting.hbs` template without using `this`. This fallback behavior has been deprecated, all properties must be looked up on `this` when used in the template: {{this.model}}\\\\\\\",false,{\\\\\\\"id\\\\\\\":\\\\\\\"ember-this-fallback.this-property-fallback\\\\\\\",\\\\\\\"until\\\\\\\":\\\\\\\"n/a\\\\\\\",\\\\\\\"for\\\\\\\":\\\\\\\"ember-this-fallback\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://deprecations.emberjs.com/v3.x#toc_this-property-fallback\\\\\\\",\\\\\\\"since\\\\\\\":{\\\\\\\"available\\\\\\\":\\\\\\\"0.2.0\\\\\\\"}}],[\\\\\\\"The `model` property path was used in the `discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting.hbs` template without using `this`. This fallback behavior has been deprecated, all properties must be looked up on `this` when used in the template: {{this.model}}\\\\\\\",false,{\\\\\\\"id\\\\\\\":\\\\\\\"ember-this-fallback.this-property-fallback\\\\\\\",\\\\\\\"until\\\\\\\":\\\\\\\"n/a\\\\\\\",\\\\\\\"for\\\\\\\":\\\\\\\"ember-this-fallback\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://deprecations.emberjs.com/v3.x#toc_this-property-fallback\\\\\\\",\\\\\\\"since\\\\\\\":{\\\\\\\"available\\\\\\\":\\\\\\\"0.2.0\\\\\\\"}}]]\\\"],null]]],[],false,[\\\"if\\\",\\\"mount-widget\\\",\\\"route-action\\\"]]\",\n    \"moduleName\": \"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting.hbs\",\n    \"scope\": () => [_deprecationsHelper.default],\n    \"isStrictMode\": false\n  });\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/user-activity-bottom/user-voted-topics\", [\"exports\", \"ember-this-fallback/deprecations-helper\", \"@ember/template-factory\"], function (_exports, _deprecationsHelper, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    {{#if siteSettings.voting_show_votes_on_profile}}\n    <LinkTo @route=\"userActivity.votes\">\n      {{d-icon \"heart\"}}\n      {{i18n \"topic_voting.vote_title_plural\"}}\n    </LinkTo>\n  {{/if}}\n  */\n  {\n    \"id\": \"ToK3NLBN\",\n    \"block\": \"[[[41,[30,0,[\\\"siteSettings\\\",\\\"voting_show_votes_on_profile\\\"]],[[[1,\\\"  \\\"],[8,[39,1],null,[[\\\"@route\\\"],[\\\"userActivity.votes\\\"]],[[\\\"default\\\"],[[[[1,\\\"\\\\n    \\\"],[1,[28,[35,2],[\\\"heart\\\"],null]],[1,\\\"\\\\n    \\\"],[1,[28,[35,3],[\\\"topic_voting.vote_title_plural\\\"],null]],[1,\\\"\\\\n  \\\"]],[]]]]],[1,\\\"\\\\n\\\"]],[]],null],[1,[28,[32,0],[\\\"[[\\\\\\\"The `siteSettings` property path was used in the `discourse/plugins/discourse-topic-voting/discourse/templates/connectors/user-activity-bottom/user-voted-topics.hbs` template without using `this`. This fallback behavior has been deprecated, all properties must be looked up on `this` when used in the template: {{this.siteSettings}}\\\\\\\",false,{\\\\\\\"id\\\\\\\":\\\\\\\"ember-this-fallback.this-property-fallback\\\\\\\",\\\\\\\"until\\\\\\\":\\\\\\\"n/a\\\\\\\",\\\\\\\"for\\\\\\\":\\\\\\\"ember-this-fallback\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://deprecations.emberjs.com/v3.x#toc_this-property-fallback\\\\\\\",\\\\\\\"since\\\\\\\":{\\\\\\\"available\\\\\\\":\\\\\\\"0.2.0\\\\\\\"}}]]\\\"],null]]],[],false,[\\\"if\\\",\\\"link-to\\\",\\\"d-icon\\\",\\\"i18n\\\"]]\",\n    \"moduleName\": \"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/user-activity-bottom/user-voted-topics.hbs\",\n    \"scope\": () => [_deprecationsHelper.default],\n    \"isStrictMode\": false\n  });\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/remove-vote\", [\"exports\", \"I18n\", \"discourse/widgets/widget\", \"discourse-common/lib/icon-library\"], function (_exports, _I18n, _widget, _iconLibrary) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _widget.createWidget)(\"remove-vote\", {\n    tagName: \"div.remove-vote\",\n    buildClasses() {\n      return \"vote-option\";\n    },\n    html() {\n      return [(0, _iconLibrary.iconNode)(\"times\"), _I18n.default.t(\"topic_voting.remove_vote\")];\n    },\n    click() {\n      this.sendWidgetAction(\"removeVote\");\n    }\n  });\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-box\", [\"exports\", \"I18n\", \"discourse/widgets/widget\", \"discourse/lib/ajax\", \"discourse/widgets/raw-html\", \"discourse/lib/ajax-error\"], function (_exports, _I18n, _widget, _ajax, _rawHtml, _ajaxError) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _widget.createWidget)(\"vote-box\", {\n    tagName: \"div.voting-wrapper\",\n    buildKey: () => \"vote-box\",\n    buildClasses() {\n      if (this.siteSettings.voting_show_who_voted) {\n        return \"show-pointer\";\n      }\n    },\n    defaultState() {\n      return {\n        allowClick: true,\n        initialVote: false\n      };\n    },\n    html(attrs, state) {\n      let voteCount = this.attach(\"vote-count\", attrs);\n      let voteButton = this.attach(\"vote-button\", attrs);\n      let voteOptions = this.attach(\"vote-options\", attrs);\n      let contents = [voteCount, voteButton, voteOptions];\n      if (state.votesAlert > 0) {\n        const html = \"<div class='voting-popup-menu vote-options popup-menu'>\" + _I18n.default.t(\"topic_voting.votes_left\", {\n          count: state.votesAlert,\n          path: this.currentUser.get(\"path\") + \"/activity/votes\"\n        }) + \"</div>\";\n        contents.push(new _rawHtml.default({\n          html\n        }));\n      }\n      return contents;\n    },\n    hideVotesAlert() {\n      if (this.state.votesAlert) {\n        this.state.votesAlert = null;\n        this.scheduleRerender();\n      }\n    },\n    click() {\n      this.hideVotesAlert();\n    },\n    clickOutside() {\n      this.hideVotesAlert();\n    },\n    addVote() {\n      let topic = this.attrs;\n      let state = this.state;\n      return (0, _ajax.ajax)(\"/voting/vote\", {\n        type: \"POST\",\n        data: {\n          topic_id: topic.id\n        }\n      }).then(result => {\n        topic.set(\"vote_count\", result.vote_count);\n        topic.set(\"user_voted\", true);\n        this.currentUser.setProperties({\n          votes_exceeded: !result.can_vote,\n          votes_left: result.votes_left\n        });\n        if (result.alert) {\n          state.votesAlert = result.votes_left;\n        }\n        topic.set(\"who_voted\", result.who_voted);\n        state.allowClick = true;\n        this.scheduleRerender();\n      }).catch(_ajaxError.popupAjaxError);\n    },\n    removeVote() {\n      let topic = this.attrs;\n      let state = this.state;\n      return (0, _ajax.ajax)(\"/voting/unvote\", {\n        type: \"POST\",\n        data: {\n          topic_id: topic.id\n        }\n      }).then(result => {\n        topic.set(\"vote_count\", result.vote_count);\n        topic.set(\"user_voted\", false);\n        this.currentUser.setProperties({\n          votes_exceeded: !result.can_vote,\n          votes_left: result.votes_left\n        });\n        topic.set(\"who_voted\", result.who_voted);\n        state.allowClick = true;\n        this.scheduleRerender();\n      }).catch(_ajaxError.popupAjaxError);\n    }\n  });\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-button\", [\"exports\", \"I18n\", \"discourse/widgets/widget\", \"virtual-dom\"], function (_exports, _I18n, _widget, _virtualDom) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _widget.createWidget)(\"vote-button\", {\n    tagName: \"div\",\n    buildClasses(attrs) {\n      let buttonClass = \"\";\n      if (attrs.closed) {\n        buttonClass = \"voting-closed\";\n      } else {\n        if (!attrs.user_voted) {\n          buttonClass = \"nonvote\";\n        } else {\n          if (this.currentUser && this.currentUser.votes_exceeded) {\n            buttonClass = \"vote-limited nonvote\";\n          } else {\n            buttonClass = \"vote\";\n          }\n        }\n      }\n      if (this.siteSettings.voting_show_who_voted) {\n        buttonClass += \" show-pointer\";\n      }\n      return buttonClass;\n    },\n    buildButtonTitle(attrs) {\n      if (this.currentUser) {\n        if (attrs.closed) {\n          return _I18n.default.t(\"topic_voting.voting_closed_title\");\n        }\n        if (attrs.user_voted) {\n          return _I18n.default.t(\"topic_voting.voted_title\");\n        }\n        if (this.currentUser.votes_exceeded) {\n          return _I18n.default.t(\"topic_voting.voting_limit\");\n        }\n        return _I18n.default.t(\"topic_voting.vote_title\");\n      }\n      if (attrs.vote_count) {\n        return _I18n.default.t(\"topic_voting.anonymous_button\", {\n          count: attrs.vote_count\n        });\n      }\n      return _I18n.default.t(\"topic_voting.anonymous_button\", {\n        count: 1\n      });\n    },\n    html(attrs) {\n      return (0, _virtualDom.h)(\"button\", {\n        attributes: {\n          title: this.currentUser ? _I18n.default.t(\"topic_voting.votes_left_button_title\", {\n            count: this.currentUser.votes_left\n          }) : \"\"\n        },\n        className: \"btn btn-primary vote-button\"\n      }, this.buildButtonTitle(attrs));\n    },\n    click() {\n      if (!this.currentUser) {\n        this.sendWidgetAction(\"showLogin\");\n        $.cookie(\"destination_url\", window.location.href);\n        return;\n      }\n      if (!this.attrs.closed && this.parentWidget.state.allowClick && !this.attrs.user_voted && !this.currentUser.votes_exceeded) {\n        this.parentWidget.state.allowClick = false;\n        this.parentWidget.state.initialVote = true;\n        this.sendWidgetAction(\"addVote\");\n      }\n      if (this.attrs.user_voted || this.currentUser.votes_exceeded) {\n        $(\".vote-options\").toggleClass(\"hidden\");\n      }\n    },\n    clickOutside() {\n      $(\".vote-options\").addClass(\"hidden\");\n      this.parentWidget.state.initialVote = false;\n    }\n  });\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-count\", [\"exports\", \"discourse/widgets/widget\", \"discourse-common/lib/get-url\", \"virtual-dom\", \"discourse/lib/ajax\"], function (_exports, _widget, _getUrl, _virtualDom, _ajax) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _widget.createWidget)(\"vote-count\", {\n    tagName: \"div.vote-count-wrapper\",\n    buildKey: () => \"vote-count\",\n    buildClasses() {\n      if (this.attrs.vote_count === 0) {\n        return \"no-votes\";\n      }\n    },\n    defaultState() {\n      return {\n        whoVotedUsers: null\n      };\n    },\n    html(attrs) {\n      let voteCount = (0, _virtualDom.h)(\"div.vote-count\", attrs.vote_count.toString());\n      let whoVoted = null;\n      if (this.siteSettings.voting_show_who_voted && this.state.whoVotedUsers && this.state.whoVotedUsers.length > 0) {\n        whoVoted = this.attach(\"small-user-list\", {\n          users: this.state.whoVotedUsers,\n          addSelf: attrs.liked,\n          listClassName: \"regular-votes\"\n        });\n      }\n      let buffer = [voteCount];\n      if (whoVoted) {\n        buffer.push((0, _virtualDom.h)(\"div.who-voted.popup-menu.voting-popup-menu\", [whoVoted]));\n      }\n      return buffer;\n    },\n    click() {\n      if (!this.currentUser) {\n        this.sendWidgetAction(\"showLogin\");\n        $.cookie(\"destination_url\", window.location.href);\n        return;\n      }\n      if (this.siteSettings.voting_show_who_voted && this.attrs.vote_count > 0) {\n        if (this.state.whoVotedUsers === null) {\n          return this.getWhoVoted();\n        } else {\n          $(\".who-voted\").toggle();\n        }\n      }\n    },\n    clickOutside() {\n      $(\".who-voted\").hide();\n    },\n    getWhoVoted() {\n      return (0, _ajax.ajax)(\"/voting/who\", {\n        type: \"GET\",\n        data: {\n          topic_id: this.attrs.id\n        }\n      }).then(users => {\n        this.state.whoVotedUsers = users.map(whoVotedAvatars);\n      });\n    }\n  });\n  function whoVotedAvatars(user) {\n    return {\n      template: user.avatar_template,\n      username: user.username,\n      post_url: user.post_url,\n      url: (0, _getUrl.default)(\"/u/\") + user.username.toLowerCase()\n    };\n  }\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-options\", [\"exports\", \"I18n\", \"discourse/widgets/widget\", \"virtual-dom\"], function (_exports, _I18n, _widget, _virtualDom) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _widget.createWidget)(\"vote-options\", {\n    tagName: \"div.vote-options\",\n    buildClasses() {\n      return \"voting-popup-menu popup-menu hidden\";\n    },\n    html(attrs) {\n      let contents = [];\n      if (attrs.user_voted) {\n        contents.push(this.attach(\"remove-vote\", attrs));\n      } else if (this.currentUser && this.currentUser.votes_exceeded && !attrs.user_voted) {\n        contents.push([(0, _virtualDom.h)(\"div\", _I18n.default.t(\"topic_voting.reached_limit\")), (0, _virtualDom.h)(\"p\", (0, _virtualDom.h)(\"a\", {\n          href: this.currentUser.get(\"path\") + \"/activity/votes\"\n        }, _I18n.default.t(\"topic_voting.list_votes\")))]);\n      }\n      return contents;\n    }\n  });\n});"],"mappings":"A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