"use strict";

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

/* global LearnosityApp */
var promise;

function loadLearnositySdk() {
  if (!promise) {
    promise = new Promise(function (resolve, reject) {
      var learnosityURL = '//questions.learnosity.com/?v2';
      var addScript = document.createElement('script');
      addScript.setAttribute('src', learnosityURL);

      addScript.onload = function () {
        resolve(LearnosityApp);
      };

      document.body.appendChild(addScript);

      addScript.onerror = function (e) {
        reject(e);
      };
    });
  }

  return promise;
}