text: /**
   * angular2-google-maps - Angular 2 components for Google Maps
   * @version v0.12.0
   * @link https://github.com/SebastianM/angular2-google-maps#readme
   * @license MIT
   */
  "use strict";
  var __extends = (this && this.__extends) || function (d, b) {
      for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
      function __() { this.constructor = d; }
      d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
      var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
      if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
      else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
      return c > 3 && r && Object.defineProperty(target, key, r), r;
  };
  var __metadata = (this && this.__metadata) || function (k, v) {
      if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  };
  var __param = (this && this.__param) || function (paramIndex, decorator) {
      return function (target, key) { decorator(target, key, paramIndex); }
  };
  var core_1 = require('@angular/core');
  var browser_globals_1 = require('../../utils/browser-globals');
  var maps_api_loader_1 = require('./maps-api-loader');
  (function (GoogleMapsScriptProtocol) {
      GoogleMapsScriptProtocol[GoogleMapsScriptProtocol["HTTP"] = 0] = "HTTP";
      GoogleMapsScriptProtocol[GoogleMapsScriptProtocol["HTTPS"] = 1] = "HTTPS";
      GoogleMapsScriptProtocol[GoogleMapsScriptProtocol["AUTO"] = 2] = "AUTO";
  })(exports.GoogleMapsScriptProtocol || (exports.GoogleMapsScriptProtocol = {}));
  var GoogleMapsScriptProtocol = exports.GoogleMapsScriptProtocol;
  /**
   * Configuration for {@link LazyMapsAPILoader}.
   * See {@link LazyMapsAPILoaderConfig} for instance attribute descriptions.
   */
  var LazyMapsAPILoaderConfig = (function () {
      function LazyMapsAPILoaderConfig() {
          this.apiKey = null;
          this.clientId = null;
          this.channel = null;
          this.apiVersion = '3';
          this.hostAndPath = 'maps.googleapis.com/maps/api/js';
          this.protocol = GoogleMapsScriptProtocol.HTTPS;
          this.libraries = [];
          this.region = null;
          this.language = null;
      }
      return LazyMapsAPILoaderConfig;
  }());
  exports.LazyMapsAPILoaderConfig = LazyMapsAPILoaderConfig;
  var DEFAULT_CONFIGURATION = new LazyMapsAPILoaderConfig();
  var LazyMapsAPILoader = (function (_super) {
      __extends(LazyMapsAPILoader, _super);
      function LazyMapsAPILoader(config, w, d) {
          _super.call(this);
          this._config = config || DEFAULT_CONFIGURATION;
          this._window = w;
          this._document = d;
      }
      LazyMapsAPILoader.prototype.load = function () {
          var _this = this;
          if (this._scriptLoadingPromise) {
              return this._scriptLoadingPromise;
          }
          var script = this._document.createElement('script');
          script.type = 'text/javascript';
          script.async = true;
          script.defer = true;
          var callbackName = "angular2GoogleMapsLazyMapsAPILoader";
          script.src = this._getScriptSrc(callbackName);
          this._scriptLoadingPromise = new Promise(function (resolve, reject) {
              _this._window[callbackName] = function () { resolve(); };
              script.onerror = function (error) { reject(error); };
          });
          this._document.body.appendChild(script);
          return this._scriptLoadingPromise;
      };
      LazyMapsAPILoader.prototype._getScriptSrc = function (callbackName) {
          var protocolType = (this._config && this._config.protocol) || DEFAULT_CONFIGURATION.protocol;
          var protocol;
          switch (protocolType) {
              case GoogleMapsScriptProtocol.AUTO:
                  protocol = '';
                  break;
              case GoogleMapsScriptProtocol.HTTP:
                  protocol = 'http:';
                  break;
              case GoogleMapsScriptProtocol.HTTPS:
                  protocol = 'https:';
                  break;
          }
          var hostAndPath = this._config.hostAndPath || DEFAULT_CONFIGURATION.hostAndPath;
          var queryParams = {
              v: this._config.apiVersion || DEFAULT_CONFIGURATION.apiVersion,
              callback: callbackName,
              key: this._config.apiKey,
              client: this._config.clientId,
              channel: this._config.channel,
              libraries: this._config.libraries,
              region: this._config.region,
              language: this._config.language
          };
          var params = Object.keys(queryParams)
              .filter(function (k) { return queryParams[k] != null; })
              .filter(function (k) {
              // remove empty arrays
              return !Array.isArray(queryParams[k]) ||
                  (Array.isArray(queryParams[k]) && queryParams[k].length > 0);
          })
              .map(function (k) {
              // join arrays as comma seperated strings
              var i = queryParams[k];
              if (Array.isArray(i)) {
                  return { key: k, value: i.join(',') };
              }
              return { key: k, value: queryParams[k] };
          })
              .map(function (entry) { return entry.key + "=" + entry.value; })
              .join('&');
          return protocol + "//" + hostAndPath + "?" + params;
      };
      LazyMapsAPILoader = __decorate([
          core_1.Injectable(),
          __param(0, core_1.Optional()),
          __param(1, core_1.Inject(browser_globals_1.WINDOW_GLOBAL)),
          __param(2, core_1.Inject(browser_globals_1.DOCUMENT_GLOBAL)), 
          __metadata('design:paramtypes', [LazyMapsAPILoaderConfig, Window, Document])
      ], LazyMapsAPILoader);
      return LazyMapsAPILoader;
  }(maps_api_loader_1.MapsAPILoader));
  exports.LazyMapsAPILoader = LazyMapsAPILoader;
  /**
   * Creates a provider for a {@link LazyMapsAPILoaderConfig})
   */
  function provideLazyMapsAPILoaderConfig(confLiteral) {
      return core_1.provide(LazyMapsAPILoaderConfig, {
          useFactory: function () {
              var config = new LazyMapsAPILoaderConfig();
              // todo(sebastian): deprecate LazyMapsAPILoader class
              config.apiKey = confLiteral.apiKey || DEFAULT_CONFIGURATION.apiKey;
              config.apiVersion = confLiteral.apiVersion || DEFAULT_CONFIGURATION.apiVersion;
              config.channel = confLiteral.channel || DEFAULT_CONFIGURATION.channel;
              config.clientId = confLiteral.clientId || DEFAULT_CONFIGURATION.clientId;
              config.hostAndPath = confLiteral.hostAndPath || DEFAULT_CONFIGURATION.hostAndPath;
              config.language = confLiteral.language || DEFAULT_CONFIGURATION.language;
              config.libraries = confLiteral.libraries || DEFAULT_CONFIGURATION.libraries;
              config.protocol = config.protocol || DEFAULT_CONFIGURATION.protocol;
              config.region = config.region || DEFAULT_CONFIGURATION.region;
              return config;
          }
      });
  }
  exports.provideLazyMapsAPILoaderConfig = provideLazyMapsAPILoaderConfig;
  
  //# sourceMappingURL=lazy-maps-api-loader.js.map
  