define(["exports", "core/l10n", "core/LinterRule"], function (exports, _l10n, _LinterRule) {
  "use strict";

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.rule = undefined;

  var _LinterRule2 = _interopRequireDefault(_LinterRule);

  function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
      default: obj
    };
  }

  var _extends = Object.assign || function (target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i];

      for (var key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
          target[key] = source[key];
        }
      }
    }

    return target;
  };

  var name = "no-http-props";

  var meta = {
    en: {
      description: "Insecure URLs are not allowed in `respecConfig`.",
      howToFix: "Please change the following properties to 'https://': "
    }
  };

  // Fall back to english, if language is missing
  var lang = _l10n.lang in meta ? _l10n.lang : "en";

  /**
   * Runs linter rule.
   *
   * @param {Object} config The ReSpec config.
   * @param  {Document} doc The document to be checked.
   */
  function lintingFunction(conf, doc) {
    // We can only really perform this check over http/https
    if (!doc.location.href.startsWith("http")) {
      return;
    }
    var offendingMembers = Object.getOwnPropertyNames(conf
    // this check is cheap, "prevED" is w3c exception.
    ).filter(function (key) {
      return key.endsWith("URI") || key === "prevED";
    }
    // this check is expensive, so seperate step
    ).filter(function (key) {
      return new URL(conf[key], doc.location.href).href.startsWith("http://");
    }).reduce(function (collector, key) {
      return collector.concat(key);
    }, []);
    if (!offendingMembers.length) {
      return [];
    }
    var result = _extends({
      name: name,
      occurances: offendingMembers.length
    }, meta[lang]);
    result.howToFix += offendingMembers.map(function (item) {
      return "`" + item + "`";
    }).join(", ") + ".";
    return result;
  }

  var rule = exports.rule = new _LinterRule2.default(name, lintingFunction);
});
//# sourceMappingURL=no-http-props.js.map