(function() {
  if ('require' in window) {
    require("discourse/lib/theme-settings-store").registerSettings(16, {"linked_pm_group":"bug-files","bug_categories_active":"10|28|29|30|31|52|72|171|184","feature_categories_active":"15","trust_level_to_use":2,"bug_wizard_url":"/w/bug-report","feature_wizard_url":"/w/bug-report"});
  }
})();
(function() {
  if ('Ember' in window) {
    Ember.TEMPLATES["javascripts/discourse/connectors/before-create-topic-button/go-to-wizard"] = Ember.HTMLBars.template({"id":null,"block":"{\"symbols\":[],\"statements\":[[4,\"if\",[[24,[\"canCreateTopic\"]]],null,{\"statements\":[[0,\"\\t\"],[1,[28,\"d-button\",null,[[\"class\",\"id\",\"action\",\"icon\",\"disabled\",\"translatedLabel\"],[\"btn-default\",\"go-to-wizard\",[28,\"action\",[[23,0,[]],\"clickWizardButton\"],null],\"magic\",[28,\"if\",[[24,[\"canUse\"]],false,true],null],[24,[\"buttonText\"]]]]],false],[0,\"\\n\"]],\"parameters\":[]},null]],\"hasEval\":false}","meta":{}});
  }
})();

if ('define' in window) {
define("discourse/theme-16/connectors/before-create-topic-button/go-to-wizard", ["exports", "discourse/lib/plugin-api"], function (_exports, _pluginApi) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;

  var settings = require("discourse/lib/theme-settings-store").getObjectForTheme(16);

  var themePrefix = function themePrefix(key) {
    return "theme_translations.16.".concat(key);
  };

  function getPathCategoryId() {
    var pathName = window.location.pathname;
    var match = pathName.match(/(?!(\/c\/[^\/]+\/))\d+/);

    if (match) {
      return match[0];
    }
  }

  function checkCurrentCategory(categoriesString) {
    var currentCategoryId = getPathCategoryId();
    var categories = categoriesString.split("|");
    return categories.some(function (id) {
      return id === currentCategoryId;
    });
  }

  var _default = {
    setupComponent: function setupComponent(attrs, component) {
      var _this = this;

      (0, _pluginApi.withPluginApi)("0.1", function (api) {
        var currentUser = api.getCurrentUser();

        if (currentUser) {
          var trustLevel = currentUser.trust_level;

          if (trustLevel && settings.trust_level_to_use) {
            var canUse = trustLevel >= settings.trust_level_to_use;
            component.set("canUse", canUse);
          }
        }

        var isBugCategory = checkCurrentCategory(settings.bug_categories_active);
        var isFeatureCategory = checkCurrentCategory(settings.feature_categories_active);

        if (isBugCategory) {
          _this.href = settings.bug_wizard_url;
          component.set("buttonText", I18n.t(themePrefix("custom_wizard_extra.report_bug")));
        } else if (isFeatureCategory) {
          _this.href = settings.feature_wizard_url;
          component.set("buttonText", I18n.t(themePrefix("custom_wizard_extra.request_feature")));
        }
      });
    },
    shouldRender: function shouldRender(args) {
      var isBugCategory = checkCurrentCategory(settings.bug_categories_active);
      var isFeatureCategory = checkCurrentCategory(settings.feature_categories_active);
      return args.canCreateTopic && (isBugCategory || isFeatureCategory);
    },
    actions: {
      clickWizardButton: function clickWizardButton() {
        if (this.href) {
          window.location.href = this.href;
        }
      }
    }
  };
  _exports.default = _default;
});
}

(function() {
  if ('Ember' in window) {
    Ember.TEMPLATES["javascripts/discourse/connectors/topic-title/linked-pm-container"] = Ember.HTMLBars.template({"id":null,"block":"{\"symbols\":[],\"statements\":[[4,\"if\",[[24,[\"userCanSee\"]]],null,{\"statements\":[[4,\"if\",[[24,[\"model\",\"private_message_associated\"]]],null,{\"statements\":[[0,\"\\t\\t\"],[7,\"a\",true],[10,\"class\",\"btn wizard-pm-link\"],[10,\"target\",\"_blank\"],[11,\"href\",[29,[\"/t/\",[24,[\"model\",\"private_message_associated\"]]]]],[8],[0,\"\\n\\t\\t\"],[1,[28,\"d-icon\",[\"file\"],null],false],[0,\"\\n\\t\\t\"],[1,[28,\"theme-i18n\",[16,\"custom_wizard_extra.bugfile_topic_id\"],null],false],[0,\"\\n\\t\\t\"],[9],[0,\"\\n\"]],\"parameters\":[]},{\"statements\":[[4,\"if\",[[24,[\"model\",\"private_message_associated_2\"]]],null,{\"statements\":[[0,\"\\t\\t\"],[7,\"a\",true],[10,\"class\",\"btn wizard-pm-link\"],[10,\"target\",\"_blank\"],[11,\"href\",[29,[\"/t/\",[24,[\"model\",\"private_message_associated_2\"]]]]],[8],[0,\"\\n\\t\\t\"],[1,[28,\"d-icon\",[\"file\"],null],false],[0,\"\\n\\t\\t\"],[1,[28,\"theme-i18n\",[16,\"custom_wizard_extra.bugfile_topic_id\"],null],false],[0,\"\\n\\t\\t\"],[9],[0,\"\\n\\t\"]],\"parameters\":[]},null]],\"parameters\":[]}]],\"parameters\":[]},null]],\"hasEval\":false}","meta":{}});
  }
})();

if ('define' in window) {
define("discourse/theme-16/connectors/topic-title/linked-pm-container", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;

  var settings = require("discourse/lib/theme-settings-store").getObjectForTheme(16);

  var themePrefix = function themePrefix(key) {
    return "theme_translations.16.".concat(key);
  };

  var _default = {
    setupComponent: function setupComponent(attrs, component) {
      var doShow = false;
      var user = component.get("currentUser");

      if (user) {
        var _attrs$model, _attrs$model$details, _attrs$model$details$;

        if (user.groups) {
          // Users in the linked_pm_group can see the link
          var inGroup = user.groups.some(function (g) {
            return g.name == settings.linked_pm_group;
          });

          if (inGroup) {
            doShow = true;
          }
        } // Admins can see the link


        if (user.admin) {
          doShow = true;
        } // The topic creator can see the link


        var creatorId = (_attrs$model = attrs.model) === null || _attrs$model === void 0 ? void 0 : (_attrs$model$details = _attrs$model.details) === null || _attrs$model$details === void 0 ? void 0 : (_attrs$model$details$ = _attrs$model$details.created_by) === null || _attrs$model$details$ === void 0 ? void 0 : _attrs$model$details$.id;

        if (creatorId === user.id) {
          doShow = true;
        }
      }

      component.set("userCanSee", doShow);
    }
  };
  _exports.default = _default;
});
}

