define("view/modal/setting-tabs/service/mail", ["require", "exports", "module", "configs/settings", "lang/index", "utils/server", "utils/analytics", "view/modal/setting-tabs/service/row"],
function(e, t) {
  var i = e("configs/settings"),
  n = e("lang/index"),
  s = e("utils/server"),
  a = e("utils/analytics"),
  r = e("view/modal/setting-tabs/service/row").View;
  t.View = r.extend({
    events: {
      "click input": "selectInput"
    },
    initialize: function() {
      this.initText(),
      this.render(),
      this.initDom(),
      this.getMailCode(),
      this.events = _.extend({},
      r.prototype.events, this.events)
    },
    initText: function() {
      this.textTitle = n.get("settings_mail_service_title"),
      this.textDesc = n.get("settings_mail_service_desc").replace("%s1", i.productName).replace(/%s2/g, i.domain),
      this.textEnable = n.get("settings_mail_service_enable"),
      this.textClose = n.get("settings_mail_service_close"),
      this.textReset = n.get("reset_mail"),
      this.textHolder = "",
      this.textInfo = n.get("settings_mail_service_info").replace("%s1", i.productName)
    },
    initDom: function() {
      this.$result = this.$(".action-result"),
      this.$action = this.$(".action-btn"),
      this.$input = this.$("input"),
      this.$info = this.$(".text-info-title")
    },
    getMailCode: function() {
      var e = this;
      s.getMailCode(function(t) {
        e.renderMailCode(t),
        e.renderEnabled()
      })
    },
    renderMailCode: function(e) {
      var t = "todo+" + e + "@mail." + i.domain;
      this.$input.val(t).attr("readonly", "true")
    },
    renderEnabled: function() {
      this.$action.text(this.textReset),
      this.$result.removeClass("hide"),
      this.$info.removeClass("hide")
    },
    selectInput: function() {
      this.$input.select()
    },
    resetCode: function() {
      var e = this;
      s.resetMailCode(function(t) {
        e.renderMailCode(t)
      }),
      a.set_mail("reset")
    },
    actionFn: function() {
      this.resetCode()
    }
  })
})