text: define([
      '../Core/Check',
      '../Core/Credit',
      '../Core/defaultValue',
      '../Core/defined',
      '../Core/destroyObject'
  ], function(
      Check,
      Credit,
      defaultValue,
      defined,
      destroyObject) {
      'use strict';
  
      var mobileWidth = 576;
      var lightboxHeight = 100;
      var textColor = '#ffffff';
      var highlightColor = '#48b';
  
      function contains(credits, credit) {
          var len = credits.length;
          for (var i = 0; i < len; i++) {
              var existingCredit = credits[i];
              if (Credit.equals(existingCredit, credit)) {
                  return true;
              }
          }
          return false;
      }
  
      function displayTextCredits(creditDisplay, textCredits) {
          var i;
          var index;
          var credit;
          var displayedTextCredits = creditDisplay._displayedCredits.textCredits;
          var container = creditDisplay._textContainer;
          for (i = 0; i < textCredits.length; i++) {
              credit = textCredits[i];
              if (defined(credit)) {
                  index = displayedTextCredits.indexOf(credit);
                  if (index === -1) {
                      var element = credit.element;
                      if (container.hasChildNodes()) {
                          var del = document.createElement('span');
                          del.textContent = creditDisplay._delimiter;
                          del.className = 'cesium-credit-delimiter';
                          container.appendChild(del);
                      }
                      container.appendChild(element);
                  } else {
                      displayedTextCredits.splice(index, 1);
                  }
              }
          }
      }
  
      function displayImageCredits(creditDisplay, imageCredits) {
          var i;
          var index;
          var credit;
          var displayedImageCredits = creditDisplay._displayedCredits.imageCredits;
          var container = creditDisplay._imageContainer;
          for (i = 0; i < imageCredits.length; i++) {
              credit = imageCredits[i];
              if (defined(credit)) {
                  index = displayedImageCredits.indexOf(credit);
                  if (index === -1) {
                      container.appendChild(credit.element);
                  } else {
                      displayedImageCredits.splice(index, 1);
                  }
              }
          }
      }
  
      function displayLightboxCredits(creditDisplay, lighboxCredits) {
          var i;
          var index;
          var credit;
          var displayedCredits = creditDisplay._displayedCredits.lightboxCredits;
          var container = creditDisplay._creditList;
          for (i = 0; i < lighboxCredits.length; i++) {
              credit = lighboxCredits[i];
              if (defined(credit)) {
                  index = displayedCredits.indexOf(credit);
                  if (index === -1) {
                      var li = document.createElement('li');
                      var element = credit.element;
                      li.appendChild(element);
                      container.appendChild(li);
                  } else {
                      displayedCredits.splice(index, 1);
                  }
              }
          }
      }
  
      function removeCreditDomElement(credit) {
          var element = credit.element;
  
          var container = credit.showOnScreen ? element.parentNode : element.parentNode.parentNode;
  
          if (credit.hasImage() || !credit.showOnScreen) {
              if (credit.showOnScreen) {
                  container.removeChild(element);
              } else {
                  container.removeChild(element.parentNode);
              }
              return;
          }
  
          var delimiter = element.previousSibling;
          if (delimiter === null) {
              delimiter = element.nextSibling;
          }
          if (delimiter !== null) {
              container.removeChild(delimiter);
          }
          container.removeChild(element);
      }
  
      function removeUnusedCredits(creditDisplay) {
          var i;
          var credit;
          var displayedTextCredits = creditDisplay._displayedCredits.textCredits;
          for (i = 0; i < displayedTextCredits.length; i++) {
              credit = displayedTextCredits[i];
              if (defined(credit)) {
                  removeCreditDomElement(credit);
              }
          }
          var displayedImageCredits = creditDisplay._displayedCredits.imageCredits;
          for (i = 0; i < displayedImageCredits.length; i++) {
              credit = displayedImageCredits[i];
              if (defined(credit)) {
                  removeCreditDomElement(credit);
              }
          }
      }
  
      function removeUnusedLightboxCredits(creditDisplay) {
          var i;
          var credit;
          var displayedLightboxCredits = creditDisplay._displayedCredits.lightboxCredits;
          for (i = 0; i < displayedLightboxCredits.length; i++) {
              credit = displayedLightboxCredits[i];
              if (defined(credit)) {
                  removeCreditDomElement(credit);
              }
          }
      }
  
      function styleLightboxContainer(that) {
          var lightboxCredits = that._lightboxCredits;
          var width = that.viewport.clientWidth;
          var height = that.viewport.clientHeight;
          if (width !== that._lastViewportWidth) {
              if (width < mobileWidth) {
                  lightboxCredits.className = 'cesium-credit-lightbox cesium-credit-lightbox-mobile';
                  lightboxCredits.style.marginTop = '0';
              } else {
                  lightboxCredits.className = 'cesium-credit-lightbox cesium-credit-lightbox-expanded';
                  lightboxCredits.style.marginTop = Math.floor((height - lightboxCredits.clientHeight) * 0.5) + 'px';
              }
              that._lastViewportWidth = width;
          }
  
          if (width >= mobileWidth && height !== that._lastViewportHeight) {
              lightboxCredits.style.marginTop = Math.floor((height - lightboxCredits.clientHeight) * 0.5) + 'px';
              that._lastViewportHeight = height;
          }
      }
  
      function addStyle(selector, styles) {
          var style = selector + ' {';
          for (var attribute in styles) {
              if (styles.hasOwnProperty(attribute)) {
                  style += attribute + ': ' + styles[attribute] + '; ';
              }
          }
          style += ' }\n';
          return style;
      }
  
      function appendCss() {
          var head = document.head;
          var css = document.createElement('style');
          var style = '';
          style += addStyle('.cesium-credit-lightbox-overlay', {
              display : 'none',
              'z-index' : '1', //must be at least 1 to draw over top other Cesium widgets
              position : 'absolute',
              top : '0',
              left : '0',
              width : '100%',
              height : '100%',
              'background-color' : 'rgba(80, 80, 80, 0.8)'
          });
  
          style += addStyle('.cesium-credit-lightbox', {
              'background-color' : '#303336',
              color : textColor,
              position : 'relative',
              'min-height' : lightboxHeight + 'px',
              margin : 'auto'
          });
  
          style += addStyle('.cesium-credit-lightbox > ul > li > span > a, .cesium-credit-lightbox > ul > li > span > a:visited', {
              color: textColor
          });
  
          style += addStyle('.cesium-credit-lightbox > ul > li > span > a:hover', {
              color: highlightColor
          });
  
          style += addStyle('.cesium-credit-lightbox.cesium-credit-lightbox-expanded', {
              border : '1px solid #444',
              'border-radius' : '5px',
              'max-width' : '370px'
          });
  
          style += addStyle('.cesium-credit-lightbox.cesium-credit-lightbox-mobile', {
              height : '100%',
              width : '100%'
          });
  
          style += addStyle('.cesium-credit-lightbox-title', {
              padding : '20px 20px 0 20px'
          });
  
          style += addStyle('.cesium-credit-lightbox-close', {
              'font-size' : '18pt',
              cursor : 'pointer',
              position : 'absolute',
              top : '0',
              right : '6px',
              color : textColor
          });
  
          style += addStyle('.cesium-credit-lightbox-close:hover', {
              color : highlightColor
          });
  
          style += addStyle('.cesium-credit-lightbox > ul', {
              margin : '0',
              padding : '12px 20px 12px 40px',
              'font-size' : '13px'
          });
  
          style += addStyle('.cesium-credit-lightbox > ul > li', {
              'padding-bottom' : '6px'
          });
  
          style += addStyle('.cesium-credit-expand-link', {
              'padding-left' : '5px',
              cursor : 'pointer',
              'text-decoration' : 'underline',
              color: textColor
          });
          style += addStyle('.cesium-credit-expand-link:hover', {
              'color' : highlightColor
          });
  
          style += addStyle('.cesium-credit-text', {
              color: textColor
          });
  
          css.innerHTML = style;
  
          head.insertBefore(css, head.firstChild);
      }
  
      var cesiumCredit = new Credit({
          text: 'CesiumJS',
          imageUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHYAAAAeCAYAAAD5AOomAAAQWUlEQVR42u1beXxOxxpudrEktkbUkriI4lZpq5JbW6pJuFG0qrFeexVRak3TBm3RUgS1hFhrCdKgQWKLrUGQBiVBJMgiq0Qiuyxzn/fzTu74ZPnS9nfrj4zf8/ty5sw7M+c8824zx0svVa3oAfqAAWAIGAHGCoy43oDb6TGqywta9JgsIq4GUAswB+oDDRXU5/ragCm3N6gm+MUkVJ+1kAg1AyyA5oAN8BrQCXiTfzsArwLWgCVQF6jJBOtXk/tikWrMGkiEtgTeAOyBfsAQS0vL8YMHD/aws7ObiuthwAeAA/A20AZozAvCRNHe6vI3k2rCprUp8DoR1qVLF1c/P7+A5OTkhyUlJaKwuETkPSkRBUUlgkpmZmbW2bNnQyZOnLgA7Z2BzkALNtM1qsl9MTSVSLUCugADAwMDTxKZVI7cfCw8DiWK6fselMLtlwSxJyxDPM4vFsXFxSWRkZFRkBsOdAdaAw2qyf37ij77RDMm1a5evXojY2NjH5BW7ruaIab4xotPd8cJV/xO0cKkPXGae97n0kR6TpHIzs7O7d279xdsvoncemwJqn3u/1lbDTnqfYXN6JCUlJS03CfFwt0/4TkiK8IEEBydWiBIy21tbaejr24cWJlpBVT6ShpVFvS10iddZP6MbFkyqpw2Kor6K5P9M33onG1Iv0omsz3Q//79+7HpuUViDsys697KyZy89ynk9Wc/x4u7DwvE48ePs2mRcARtqUTLRjxmDa6rpYWanDqZKHmyzJ+lTFlyUrZGGbIm3GdF49VQcnMjZUwTJW83Ua4NtayQmlEYKW1NlOc11RrLoA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g7asyrxoG+RER4HoMorzj/SY64ijw18OIm4Xd2uTh4fq04f+OASEy7pyGUvrqYPXv2CvYfb/JEzbUOlA342lR5MDNFo+UZam1+MBPlgNuU69X25mXI1lIO6qVsTUXWrAK5GloH49qH3Ophf21l/mZlzL2G1gG9aTkfEJgoHwDU1LpvqIxZ0eG8TuTKM8VWbCKcoYGj1q1btwehegJtPVIuSVEmnd8iQDhtbW3tamxs/CGbs7a8OOooDr68z1QMlQdUH0b7kxX1sxbDSmBQzqcoBpXIGJQjo/1ZSmVzqaivyvozqOB96f+Z78b0lLPFumwabFgDe3K+NpDz0kH8rXEvNrttWUvr6/DRuJ6O+CMyf0a2Ku+pqn390Xt/6QduBopPNFe2zFrJaI2dfmv2XZbsz2op5qL6v3m8oF8vqv9/R/oB+Q1RPf41U3yT0R+x/9Xlryn/BY268qsf3smdAAAAAElFTkSuQmCC',
          link: 'https://cesiumjs.org/',
          showOnScreen: true
      });
  
      /**
       * The credit display is responsible for displaying credits on screen.
       *
       * @param {HTMLElement} container The HTML element where credits will be displayed
       * @param {String} [delimiter= ' • '] The string to separate text credits
       * @param {HTMLElement} [viewport=document.body] The HTML element that will contain the credits popup
       *
       * @alias CreditDisplay
       * @constructor
       *
       * @example
       * var creditDisplay = new Cesium.CreditDisplay(creditContainer);
       */
      function CreditDisplay(container, delimiter, viewport) {
          //>>includeStart('debug', pragmas.debug);
          Check.defined('container', container);
          //>>includeEnd('debug');
          var that = this;
  
          viewport = defaultValue(viewport, document.body);
  
          var lightbox = document.createElement('div');
          lightbox.className = 'cesium-credit-lightbox-overlay';
          viewport.appendChild(lightbox);
  
          var lightboxCredits = document.createElement('div');
          lightboxCredits.className = 'cesium-credit-lightbox';
          lightbox.appendChild(lightboxCredits);
  
          function hideLightbox(event) {
              if (lightboxCredits.contains(event.target)) {
                  return;
              }
              that.hideLightbox();
          }
          lightbox.addEventListener('click', hideLightbox, false);
  
          var title = document.createElement('div');
          title.className = 'cesium-credit-lightbox-title';
          title.textContent = 'Data provided by:';
          lightboxCredits.appendChild(title);
  
          var closeButton = document.createElement('a');
          closeButton.onclick = this.hideLightbox.bind(this);
          closeButton.innerHTML = '&times;';
          closeButton.className = 'cesium-credit-lightbox-close';
          lightboxCredits.appendChild(closeButton);
  
          var creditList = document.createElement('ul');
          lightboxCredits.appendChild(creditList);
  
          var imageContainer = document.createElement('span');
          imageContainer.className = 'cesium-credit-imageContainer';
          container.appendChild(imageContainer);
  
          var textContainer = document.createElement('span');
          textContainer.className = 'cesium-credit-textContainer';
          container.appendChild(textContainer);
  
          var expandLink = document.createElement('a');
          expandLink.className = 'cesium-credit-expand-link';
          expandLink.onclick = this.showLightbox.bind(this);
          expandLink.textContent = 'Data attribution';
          container.appendChild(expandLink);
  
          appendCss();
  
          this._delimiter = defaultValue(delimiter, ' • ');
          this._textContainer = textContainer;
          this._imageContainer = imageContainer;
          this._lastViewportHeight = undefined;
          this._lastViewportWidth = undefined;
          this._lightboxCredits = lightboxCredits;
          this._creditList = creditList;
          this._lightbox = lightbox;
          this._hideLightbox = hideLightbox;
          this._expandLink = expandLink;
          this._expanded = false;
          this._defaultImageCredits = [];
          this._defaultTextCredits = [];
  
          this._displayedCredits = {
              imageCredits : [],
              textCredits : [],
              lightboxCredits : []
          };
          this._currentFrameCredits = {
              imageCredits : [],
              textCredits : [],
              lightboxCredits : []
          };
  
          this.viewport = viewport;
  
          /**
           * The HTML element where credits will be displayed.
           * @type {HTMLElement}
           */
          this.container = container;
      }
  
      /**
       * Adds a credit to the list of current credits to be displayed in the credit container
       *
       * @param {Credit} credit The credit to display
       */
      CreditDisplay.prototype.addCredit = function(credit) {
          //>>includeStart('debug', pragmas.debug);
          Check.defined('credit', credit);
          //>>includeEnd('debug');
  
          var imageCredits = this._currentFrameCredits.imageCredits;
  
          if (credit.text === 'Cesium ion') {
              // We don't want to clutter the screen with the Cesium logo and the Cesium ion
              // logo at the same time. Since the ion logo is required, we just replace the
              // Cesium logo or add the logo if the Cesium one was removed.
              if (defined(imageCredits[cesiumCredit.id])) {
                  imageCredits[cesiumCredit.id] = credit;
              } else {
                  imageCredits[credit.id] = credit;
              }
          } else if (!credit.showOnScreen) {
              this._currentFrameCredits.lightboxCredits[credit.id] = credit;
          } else if (credit.hasImage()) {
              imageCredits[credit.id] = credit;
          } else {
              this._currentFrameCredits.textCredits[credit.id] = credit;
          }
      };
  
      /**
       * Adds credits that will persist until they are removed
       *
       * @param {Credit} credit The credit to added to defaults
       */
      CreditDisplay.prototype.addDefaultCredit = function(credit) {
          //>>includeStart('debug', pragmas.debug);
          Check.defined('credit', credit);
          //>>includeEnd('debug');
  
          if (credit.hasImage()) {
              var imageCredits = this._defaultImageCredits;
              if (!contains(imageCredits, credit)) {
                  imageCredits.push(credit);
              }
          } else {
              var textCredits = this._defaultTextCredits;
              if (!contains(textCredits, credit)) {
                  textCredits.push(credit);
              }
          }
      };
  
      /**
       * Removes a default credit
       *
       * @param {Credit} credit The credit to be removed from defaults
       */
      CreditDisplay.prototype.removeDefaultCredit = function(credit) {
          //>>includeStart('debug', pragmas.debug);
          Check.defined('credit', credit);
          //>>includeEnd('debug');
  
          var index;
          if (credit.hasImage()) {
              index = this._defaultImageCredits.indexOf(credit);
              if (index !== -1) {
                  this._defaultImageCredits.splice(index, 1);
              }
          } else {
              index = this._defaultTextCredits.indexOf(credit);
              if (index !== -1) {
                  this._defaultTextCredits.splice(index, 1);
              }
          }
      };
  
      CreditDisplay.prototype.showLightbox = function() {
          this._lightbox.style.display = 'block';
          this._expanded = true;
      };
  
      CreditDisplay.prototype.hideLightbox = function() {
          this._lightbox.style.display = 'none';
          this._expanded = false;
      };
  
      /**
       * Updates the credit display before a new frame is rendered.
       */
      CreditDisplay.prototype.update = function() {
          var displayedLightboxCredits = [];
  
          if (this._expanded && defined(this._creditsToUpdate)) {
              styleLightboxContainer(this);
              displayLightboxCredits(this, this._creditsToUpdate);
              displayedLightboxCredits = this._creditsToUpdate.slice();
          }
  
          removeUnusedLightboxCredits(this);
  
          this._displayedCredits.lightboxCredits = displayedLightboxCredits;
      };
  
      /**
       * Resets the credit display to a beginning of frame state, clearing out current credits.
       */
      CreditDisplay.prototype.beginFrame = function() {
          this._currentFrameCredits.imageCredits.length = 0;
          this._currentFrameCredits.textCredits.length = 0;
          this._currentFrameCredits.lightboxCredits.length = 0;
  
          var cesiumCredit = CreditDisplay.cesiumCredit;
          if (defined(cesiumCredit)) {
              this._currentFrameCredits.imageCredits[cesiumCredit.id] = cesiumCredit;
          }
      };
  
      /**
       * Sets the credit display to the end of frame state, displaying credits from the last frame in the credit container.
       */
      CreditDisplay.prototype.endFrame = function() {
          displayImageCredits(this, this._defaultImageCredits);
          displayTextCredits(this, this._defaultTextCredits);
  
          displayImageCredits(this, this._currentFrameCredits.imageCredits);
          displayTextCredits(this, this._currentFrameCredits.textCredits);
  
          var displayedTextCredits = this._defaultTextCredits.concat(this._currentFrameCredits.textCredits);
          var displayedImageCredits = this._defaultImageCredits.concat(this._currentFrameCredits.imageCredits);
  
          var showLightboxLink = this._currentFrameCredits.lightboxCredits.length > 0;
          this._expandLink.style.display = showLightboxLink ? 'inline' : 'none';
  
          removeUnusedCredits(this);
  
          this._displayedCredits.textCredits = displayedTextCredits;
          this._displayedCredits.imageCredits = displayedImageCredits;
  
          this._creditsToUpdate = this._currentFrameCredits.lightboxCredits.slice();
      };
  
      /**
       * Destroys the resources held by this object.  Destroying an object allows for deterministic
       * release of resources, instead of relying on the garbage collector to destroy this object.
       * <br /><br />
       * Once an object is destroyed, it should not be used; calling any function other than
       * <code>isDestroyed</code> will result in a {@link DeveloperError} exception.  Therefore,
       * assign the return value (<code>undefined</code>) to the object as done in the example.
       *
       * @returns {undefined}
       *
       * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
       */
      CreditDisplay.prototype.destroy = function() {
          this._lightbox.removeEventListener('click', this._hideLightbox, false);
  
          this.container.removeChild(this._textContainer);
          this.container.removeChild(this._imageContainer);
          this.container.removeChild(this._expandLink);
          this.viewport.removeChild(this._lightbox);
  
          return destroyObject(this);
      };
  
      /**
       * Returns true if this object was destroyed; otherwise, false.
       * <br /><br />
       *
       * @returns {Boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
       */
      CreditDisplay.prototype.isDestroyed = function() {
          return false;
      };
  
      /**
       * Gets or sets the Cesium logo credit.
       * @type {Credit}
       */
      CreditDisplay.cesiumCredit = cesiumCredit;
  
      return CreditDisplay;
  });
  