(function () {
  //Inject code v5.1

  var highcharts = document.createElement('script');
  var injectVersion = 5;
  var cdn = 'https://code.highcharts.com/';
  var loaded = 0;  
  var encodedUrl = encodeURI('https://https://app.everviz.com//show/6u5iNc4x3');
  var chartCreated = false;
  var delayGen = 0;
  var scripts = [
    "highcharts.js",
    "modules/stock.js",
    "highcharts-more.js",
    "highcharts-3d.js",
    "modules/data.js",
    "modules/exporting.js",
    "modules/funnel.js",
    "modules/solid-gauge.js",
    "modules/export-data.js",
    "modules/accessibility.js"
  ];

  var elementClassName = 'highcharts-6u5iNc4x3';
  var externalCSS = [
    "https://app.everviz.com/resources/css/highcharts-small-screen-annotations.css",
    "https://app.everviz.com/static/fonts/gordita/style.css",
    "https://app.everviz.com/resources/css/highcharts-data-table.css"
  ];

  var extraScripts = [
  "https://code.highcharts.com/modules/annotations.js",
  "https://code.highcharts.com/modules/annotations-advanced.js",
  "https://app.everviz.com/resources/js/highcharts-small-screen-annotations.js",
  "https://app.everviz.com/resources/js/highcharts-scroll-animation.js",
  "https://app.everviz.com/resources/js/everviz-utils.js",
  "https://app.everviz.com/resources/js/highcharts-overrides.js"
  ];

  var options = {"title":{"style":{"fontFamily":"\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","color":"#333333","fontSize":"18px","fontWeight":"normal","fontStyle":"normal"},"text":"II-03d: Humanities Bachelor’s Degree Completions","margin":11,"y":22,"useHTML":true},"subtitle":{"style":{"fontFamily":"Lucida Sans Unicode","color":"#666666","fontSize":"14px","fontWeight":"normal","fontStyle":"normal"},"text":"By Discipline, 1987–2018","useHTML":true},"plotOptions":{"series":{"allowPointSelect":true,"states":{"hover":{"color":"#a4edba"},"select":{"color":"#EFFFEF","borderColor":"black","dashStyle":"dot"}},"label":{"enabled":false}},"line":{"marker":{"symbol":"circle","enabled":false},"lineWidth":3}},"credits":{"href":"humanitiesindicators.org","style":{"fontSize":"11px","cursor":"pointer","color":"#999999","fontFamily":"\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif"},"text":"Humanities Indicators, 2021 | American Academy of Arts & Sciences"},"colors":["#4b803e","#f47b2a","#46ad9b","#f5cb23","#b80d31","#482078","#d3556b","#1b5fab","#9ab92e","#ffa600","#793381","#a9a9a9","#183a7e","#16ba38","#0fe9e3","#d111b8"],"series":[{"data":[],"turboThreshold":0,"_colorIndex":0,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":1,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":2,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":3,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":4,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":5,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":6,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":7,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":8,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":9,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":10,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":11,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":12,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":13,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":14,"_symbolIndex":0,"type":"line"},{"data":[],"turboThreshold":0,"_colorIndex":15,"_symbolIndex":0,"type":"line"}],"stockTools":{"gui":{"enabled":false}},"navigation":{"bindingsClassName":"tools-container","events":{}},"pane":{"background":[]},"responsive":{"rules":[]},"chart":{"plotBorderWidth":1,"borderColor":"#ffffff","type":"line","height":620,"width":null},"yAxis":{"title":{"style":{"fontFamily":"Lucida Sans Unicode","color":"#000","fontSize":"12px","fontWeight":"bold","fontStyle":"normal"},"text":"Completions","useHTML":true},"index":0},"xAxis":{"title":{"style":{"fontFamily":"Lucida Sans Unicode","color":"#212121","fontSize":"12px","fontWeight":"bold","fontStyle":"normal"}},"index":0,"isX":true},"labels":{"items":[]},"annotations":[],"lang":{"shortMonths":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"months":["January","February","March","April","May","June","July","August","September","October","November","December"],"numericSymbols":["k","M","G","T","P","E"],"thousandsSep":","},"legend":{"itemStyle":{"fontFamily":"Default","color":"#333333","fontSize":"12px","fontWeight":"normal","fontStyle":"normal","cursor":"pointer","textOverflow":"ellipsis"},"layout":"horizontal","align":"center","verticalAlign":"bottom"},"exporting":{"url":"https://api.everviz.com/export"},"data":{"csv":"null;Archeology;Area Studies;Classical Studies;Communication (excl. Professional);Comparative Literature;Cultural, Ethnic, & Gender Studies;English Language & Literature;Folklore;General Humanities/Liberal Studies;History;Languages & Lit. Other than English;Linguistics;Philosophy;Religion;Selected Interdisciplinary Studies;Study of the Arts\n1987;67;2770;491;20431;620;524;35603;;23826;17035;10182;477;3534;2621;;2438\n1988;88;2985;524;21551;562;507;38006;;24413;18244;10000;484;3814;2309;;2516\n1989;65;3319;578;22581;701;594;41635;;26496;20136;10748;447;4146;2492;;2802\n1990;87;3755;580;24153;714;669;46286;;27901;22266;11325;531;4589;2460;;3035\n1991;92;3918;635;24666;782;860;51000;;30655;24593;12008;572;4953;2493;;3249\n1992;102;4029;719;27158;709;1193;54169;;32291;27023;12695;576;5178;2499;21;5636\n1993;95;3978;754;27333;851;1391;55223;;33501;27852;13211;553;5234;2690;25;5091\n1994;120;3931;765;26488;780;1508;53032;;33428;27607;13136;611;5085;2630;24;3960\n1995;123;3827;725;24883;744;1687;51040;;33387;26700;12615;564;4801;2697;34;5661\n1996;120;3754;743;25146;772;1887;49821;;34241;26085;12797;619;4878;2698;36;5567\n1997;136;3803;719;25703;710;1909;48525;;34825;25339;12556;577;4863;2986;38;5272\n1998;138;3716;821;26631;698;2219;48822;;35239;25830;13109;680;5143;3233;27;5523\n1999;137;3630;806;27908;746;2391;49717;;37148;24875;13675;724;5129;3421;34;5003\n2000;122;3731;852;31279;832;2485;49912;;38232;25392;13594;727;5174;3378;30;3818\n2001;141;3627;918;32380;868;2536;50367;;40233;25241;13704;757;5182;3565;40;4173\n2002;160;3774;1005;35458;807;2623;52113;;41272;26175;13728;861;5814;3688;30;4352\n2003;190;3829;1126;37855;773;2820;53387;;42077;27888;14351;893;6326;4039;32;5459\n2004;172;4009;1248;39845;819;3257;53610;;43630;29990;14904;1023;6800;4362;36;5569\n2005;175;4237;1265;40988;834;3453;54007;;44685;31555;15533;1020;7168;4413;50;5988\n2006;176;4422;1394;41028;802;3624;54715;;44305;33321;16384;1145;7464;4576;37;6342\n2007;188;4599;1477;41543;880;3712;54686;;45512;34617;16909;1290;7448;4618;41;6818\n2008;214;4784;1497;42300;801;3772;54568;;46241;34548;17526;1442;7603;4680;50;7137\n2009;226;4946;1551;43142;814;3908;54925;;46572;34740;17755;1392;7844;4634;46;7458\n2010;217;5109;1579;46003;709;3642;52627;;46749;35201;18007;1592;7854;4708;66;7667\n2011;232;5126;1526;47827;792;4047;52133;;46717;35122;17911;1714;7912;4918;86;7670\n2012;264;5251;1576;48349;731;4223;53080;5;46961;35235;17743;1950;7847;4799;73;7882\n2013;234;5027;1550;49314;920;4093;51732;9;46790;34310;17388;2007;7931;4867;50;7828\n2014;215;4581;1284;51173;788;4000;49782;17;45281;31222;16375;2086;7433;4579;57;8050\n2015;207;4246;1281;53330;728;3845;45127;17;43599;28137;15560;2111;6853;4244;56;7516\n2016;195;4047;1151;54343;681;4115;42089;13;43669;25698;14656;2127;6253;3920;47;7605\n2017;173;3723;1104;54706;683;4250;40644;16;43841;24161;13940;2089;6237;3503;56;7621\n2018;167;3581;1066;53269;671;4408;39345;10;44262;23470;13306;2075;6262;3370;34;7369","seriesMapping":[{"x":0,"y":1},{"x":0,"y":2},{"x":0,"y":3},{"x":0,"y":4},{"x":0,"y":5},{"x":0,"y":6},{"x":0,"y":7},{"x":0,"y":8},{"x":0,"y":9},{"x":0,"y":10},{"x":0,"y":11},{"x":0,"y":12},{"x":0,"y":13},{"x":0,"y":14},{"x":0,"y":15},{"x":0,"y":16}]}};
  var optionsStub;
  
  var templateDataSettings = {};

  var pluginCode = {};;

  function isScriptAlreadyIncluded(src){
    var scripts = document.getElementsByTagName("script");
    for (var i = 0; i < scripts.length; i++) {
      if (scripts[i].hasAttribute('src')) {
        const scriptTag = scripts[i].getAttribute('src') || '';
        if ((scriptTag.indexOf(src) >= 0) || 
            (scriptTag.indexOf('highcharts.src.js') > -1 && src === 'highcharts.js') ||
            ((scriptTag.indexOf('stock/highstock.js') > -1) && src === 'modules/highstock.js')) {
          return true;
        }
      }
    }
    return false;
  }

  function loadCSS() {
    var cssLength = externalCSS.length;
    for(var i=0; i < cssLength; i++) {
      var css = document.createElement('link');
      css.rel  = 'stylesheet';
      css.type = "text/css";
      css.href = externalCSS[i];
      document.body.appendChild(css);
    }
  }

  function allScriptsIncluded(){
    var allScripts = scripts.concat(extraScripts);
    var haveAllScriptsBeenIncluded = true;
    var scriptsToUse = document.getElementsByTagName("script");
    for(var n=0;n<allScripts.length;n++) {
      if (!isScriptAlreadyIncluded(allScripts[n], scriptsToUse)) {
        haveAllScriptsBeenIncluded = false;
        break;
      }
    }
    return haveAllScriptsBeenIncluded;
  }

  function modifyOptions(){
    if (options.data) {
      options.data.complete = function(options) {
        const keys = Object.keys(templateDataSettings || {});
        keys.forEach(function(key) {
          const serie = options.series[key];
          (serie.data || []).forEach(function(d, i) {
            if (templateDataSettings[key].data && templateDataSettings[key].data[i]) {
              window["everviz"].merge(d, templateDataSettings[key].data[i]);
            }
          })
        })  
        return options;
      }
    }
    
    optionsStub = window["everviz"].createStub(options);
    window["everviz"].merge(options, pluginCode);
    if ('Chart' === 'Map') window["everviz"].modifyMapType(options);
  }

  function createChart() {
    if(chartCreated) return;

    var hasProj4 = extraScripts.indexOf('https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.6/proj4.js') > -1;

    if (!allScriptsIncluded() || 
      (hasProj4 && !window.proj4) || 
      !window["everviz"].merge ||
      !window["everviz"].createStub) {
      setTimeout(createChart, 200);
      return;
    }  

    modifyOptions();

    if (hasProj4) delayGen = 100;

    if (typeof window['Highcharts'] !== 'undefined') {
      

    if (options.yAxis && options.yAxis.length === 1) options.yAxis = options.yAxis[0];
    if (options.xAxis && options.xAxis.length === 1) options.xAxis = options.xAxis[0];
    if (options.zAxis && options.zAxis.length === 1) options.zAxis = options.zAxis[0];

    /*
// Sample of extending options:
Highcharts.merge(true, options, {
    chart: {
        backgroundColor: "#bada55"
    },
    plotOptions: {
        series: {
            cursor: "pointer",
            events: {
                click: function(event) {
                    alert(this.name + " clicked\n" +
                          "Alt: " + event.altKey + "\n" +
                          "Control: " + event.ctrlKey + "\n" +
                          "Shift: " + event.shiftKey + "\n");
                }
            }
        }
    }
});
*//*
// Sample of extending options:
Highcharts.merge(true, options, {
    chart: {
        backgroundColor: "#bada55"
    },
    plotOptions: {
        series: {
            cursor: "pointer",
            events: {
                click: function(event) {
                    alert(this.name + " clicked\n" +
                          "Alt: " + event.altKey + "\n" +
                          "Control: " + event.ctrlKey + "\n" +
                          "Shift: " + event.shiftKey + "\n");
                }
            }
        }
    }
});
*/


      if (options && (options.lang || options.global)) {
        Highcharts.setOptions({
          global: options.global || {},
          lang: options.lang || {}
        });
      }

      if (Highcharts.Annotation) {
        Highcharts.Annotation.ControlPoint.prototype.redraw = function (animation) {
          this.graphic[animation ? 'animate' : 'attr'](
              this.options.positioner ? this.options.positioner.call(this, this.target) : null
          );
        };
      }

      if (window['everviz'] && window['everviz'].tooltipFormatter && 
          options.everviz && options.everviz.tooltip){
        if (!options.tooltip) options.tooltip = {};
        options.tooltip.formatter = window['everviz'].tooltipFormatter;
      }

      chartCreated = true;
      window.HighchartsCloud.hasLoaded = true; 
      setTimeout(function(){
          if (window["everviz"] && window["everviz"].pendingAnim) {
            //TODO: change to using classes instead.
            //Bit of work to do there due to backward compatibility
            const elements = document.querySelectorAll('#' + elementClassName);
            const elementsArray = Array.prototype.slice.call(elements);
            elementsArray.forEach(function(element, elementIndex) {

              window["everviz"].updateRenderTo(optionsStub, element);
              var chart = new Highcharts.Chart(optionsStub);

              window["everviz"].pendingAnim({
                id: elementClassName + '-' + elementIndex, 
                loaded: false,
                options: options,
                appear:function(){
                  chart.destroy();

                  window["everviz"].updateRenderTo(options, element);
                  chart = new Highcharts.Chart(options); 

                },
                element: element
              });
            });

          } else {
            new Highcharts.Chart(elementClassName, options);   
          }
      }, delayGen);
    }
  }

  function check(scripts, cb) {
    if (loaded === scripts.length) {
      if (cb) {
        cb();
      } else {


        //Create first project
        if (!window.HighchartsCloud.versions ||
           (window.HighchartsCloud.versions && window.HighchartsCloud.versions.length !== window.HighchartsCloud.ondone.length)) {
             
          for (var i = 0; i < window.HighchartsCloud.ondone.length; i++) {
            try {
              window.HighchartsCloud.ondone[i]();
            } catch(e) {
              console.error(e);
            }
          }
        } else {
          if (window.HighchartsCloud.stack.length) {
            window.HighchartsCloud.stack[0]();
            window.HighchartsCloud.stack.shift();
            const shouldRenderNextChart = window.HighchartsCloud.stack.length > 0;
            if (shouldRenderNextChart) {
              window.HighchartsCloud.stack[0](true);
            }
          }
        }
        
      }
    }
  }

  function loadScript(s, scripts, cb) {
    if (!s) next();
    
    function next() {
      ++loaded;
      if (loaded < scripts.length) {
        loadScript(scripts[loaded], scripts, cb);
      }
      check(scripts, cb);
    }

    if (isScriptAlreadyIncluded(s)) {
      return next();
    }

    var n = document.createElement('script');

    n.onload = function () {
      next();
    };

    if (s.indexOf('https') >= 0) {
      n.src = s;
    } else {
      n.src = cdn + s;
    }
    document.body.appendChild(n);
  }

  function loadExtraScripts(){
    if (extraScripts.length > 0) {
      loaded = 0;
      loadScript(extraScripts[0], extraScripts);
    } else {
      check(scripts);
    }
  }

  function loadExtraScriptsAndMakeChart(isUsingStack){
    loaded = 0;
    loadCSS();
    if (extraScripts.length > 0) {
      if (isUsingStack) {
        window.HighchartsCloud.stack[0] = createChart;
        loadScript(extraScripts[0], extraScripts);
      }
      else loadScript(extraScripts[0], extraScripts, createChart);
    } else {
      check(extraScripts);
    }
  }

  function getAllScripts(){
    var evervizScripts = [];
    var allScripts = scripts.map(function(script) {
      return 'highcharts/'+ script.replace('highcharts/highcharts.js', 'highcharts.js').replace('.js', '');
    }).concat(
      extraScripts.map(function(script) {
        if (script.indexOf('https://code.highcharts.com/') > -1) {
          return 'highcharts/'+ script.replace('https://code.highcharts.com/', '').replace('.js', '');
        } else if (script.indexOf('https://app.everviz.com/') > -1) {
          evervizScripts.push(script);
          return null;
        } else return script;
      }).filter(function(s) {
        return s !== null;
      })
    );

    allScripts.forEach(function(script) {
      if (window.HighchartsCloud.allScripts)
        window.HighchartsCloud.allScripts[script] = 1
    });

    return {
      allHighchartsScripts: allScripts,
      evervizScripts: evervizScripts
    }
  }

  function loadRequireJSScript(){
    require.config({
      packages: [{
        name: 'highcharts',
        main: 'highcharts'
      }],
      paths: {
        'highcharts': 'https://code.highcharts.com'
      }
    });

    const allScripts = getAllScripts();

    require(
      allScripts.allHighchartsScripts,
      function (Highcharts) {
        //Attach highcharts to the window for use in the everviz scripts
        window.Highcharts = Highcharts;
        if (allScripts && allScripts.evervizScripts.length) {
          require(allScripts.evervizScripts, function(){
            createChart();
            loadCSS();
          })
        } else {
          createChart();
          loadCSS();
        }
      }
    );
  }

  function loadInitialScript(){
    if (window['require'] && typeof require === "function" && typeof require.specified === "function") {
      loadRequireJSScript();
    } else {
      getAllScripts()
      loadScript(scripts[0], scripts, loadExtraScripts);
      loadCSS();
    }
  }

  if (typeof window['HighchartsCloud'] === 'undefined') {
    window.HighchartsCloud = {
      ondone: [createChart],
      stack: [createChart],
      hasWrapped: false,
      hasLoaded: false,
      externalCSS: externalCSS,
      versions: [injectVersion],
      types: ['chart'],
      allScripts: {},
      projectUUIDs: {'6u5iNc4x3': 1},
    };

    loadInitialScript();

  } else {
    if (window.HighchartsCloud.externalCSS) window.HighchartsCloud.externalCSS.push(externalCSS);
    if (!window.HighchartsCloud.hasLoaded) {
      if (!window.HighchartsCloud.projectUUIDs) window.HighchartsCloud.projectUUIDs = {};

      if (!window.HighchartsCloud.projectUUIDs['6u5iNc4x3']) {

        window.HighchartsCloud.projectUUIDs['6u5iNc4x3'] = 1;
        window.HighchartsCloud.ondone.push(loadExtraScriptsAndMakeChart);
        if (window.HighchartsCloud.stack) {
          window.HighchartsCloud.stack.push(loadExtraScriptsAndMakeChart);
          window.HighchartsCloud.versions.push(injectVersion);
          window.HighchartsCloud.types.push('chart');
        }

      }
      if (window['require'] && typeof require === "function" && typeof require.specified === "function") {
        getAllScripts()
        loadRequireJSScript();
      }
    }
    else {
      if (window['require'] && typeof require === "function" && typeof require.specified === "function") {
        loadRequireJSScript();
      } else {
        getAllScripts()
        loadExtraScriptsAndMakeChart();
      }
    }
  }

}());
