(function (global) {
  // Add array index of for old browsers (IE<9).
  if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(obj, start) {
      var i, j;
      i = start || 0;
      j = this.length;
      while (i < j) {
        if (this[i] === obj) {
          return i;
        }
        i++;
      }
      return -1;
    };
  }

  // Make a global object to store stuff in.
  if (!global.KIWidgets) { global.KIWidgets = {}; };
  var KIWidgets = global.KIWidgets;

  // To keep track of which embeds we have already processed.
  if (!KIWidgets.processedScripts) { KIWidgets.processedScripts = []; };
  var processedScripts = KIWidgets.processedScripts;

  if (!KIWidgets.styleTags) { KIWidgets.styleTags = []; };
  var styleTags = KIWidgets.styleTags;

  var scriptTags = document.getElementsByTagName('script');
  var thisRequestUrl = 'https://nyheter.ki.se/widget/view/news?type=news&au=&ty=all&a%5B2274%5D=2274&aa=0&ae=0&ar=0&m=0&d=widget_compact&n=2&l=0&lang=sv&id=e756895d-25c5-438a-831c-2dfabcac1d5d';

  for (var i = 0; i < scriptTags.length; i++) {
    var scriptTag = scriptTags[i];

    // src matches the url of this request, and not processed it yet.
    if (scriptTag.src == thisRequestUrl && processedScripts.indexOf(scriptTag) < 0) {
      processedScripts.push(scriptTag);

      // Add the style tag into the head (once only).
      if (styleTags.length == 0) {
        // Add a style tag to the head.
        var styleTag = document.createElement("link");
        styleTag.rel = "stylesheet";
        styleTag.type = "text/css";
        styleTag.href =  "https://nyheter.ki.se/modules/custom/ki_widget_builder/css/dist/widgets_v1.css";
        styleTag.media = "all";
        document.getElementsByTagName('head')[0].appendChild(styleTag);
        styleTags.push(styleTag);
      }

      // Create a div
      var div = document.createElement('div');
      div.id = 'ki-embed-e756895d-25c5-438a-831c-2dfabcac1d5d';
      div.className = '';

      scriptTag.parentNode.insertBefore(div, scriptTag);
      div.innerHTML = '  <div class=\"news-listing-results\">    <div class=\"inner\">      <div class=\"item-listing item-listing__compact item-listing__news\"><div class=\"inside--listing\"><div><h3><a href=\"https://nyheter.ki.se/ki-i-medierna-8-14-september\" target=\"_parent\"><span>KI i medierna 8–14 september</span></a></h3><p class=\"date\">2025-09-18&nbsp;09:48</p></div></div></div><div class=\"item-listing item-listing__compact item-listing__news\"><div class=\"inside--listing\"><div><h3><a href=\"https://nyheter.ki.se/ki-i-medierna-31-augusti-7-september\" target=\"_parent\"><span>KI i medierna 31 augusti-7 september</span></a></h3><p class=\"date\">2025-09-11&nbsp;16:54</p></div></div></div>            <a href=\"https://nyheter.ki.se/widget/rss/news?au=&amp;ty=all&amp;a%5B2274%5D=2274&amp;aa=0&amp;ae=0&amp;ar=0&amp;m=0&amp;n=2&amp;lang=sv\" target=\"_blank\" class=\"read-more__rss\">RSS</a>    </div>  </div>';

      scriptTag.parentNode.querySelector('#ki-embed-loading-e756895d-25c5-438a-831c-2dfabcac1d5d').classList.remove('ki-embed-loading');
    }
  }
})(this);