text: import { __extends, __spread, __values } from 'tslib';
  import { Injectable, EventEmitter, Inject, InjectionToken, ChangeDetectorRef, Directive, ElementRef, Input, Pipe, NgModule } from '@angular/core';
  import { of, concat, merge, Observable } from 'rxjs';
  import { map, share, switchMap, take, toArray } from 'rxjs/operators';
  
  var TranslateLoader = /** @class */ (function () {
      function TranslateLoader() {
      }
      return TranslateLoader;
  }());
  var TranslateFakeLoader = /** @class */ (function (_super) {
      __extends(TranslateFakeLoader, _super);
      function TranslateFakeLoader() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      TranslateFakeLoader.prototype.getTranslation = function (lang) {
          return of({});
      };
      return TranslateFakeLoader;
  }(TranslateLoader));
  TranslateFakeLoader.decorators = [
      { type: Injectable },
  ];
  TranslateFakeLoader.ctorParameters = function () { return []; };
  var MissingTranslationHandler = /** @class */ (function () {
      function MissingTranslationHandler() {
      }
      return MissingTranslationHandler;
  }());
  var FakeMissingTranslationHandler = /** @class */ (function () {
      function FakeMissingTranslationHandler() {
      }
      FakeMissingTranslationHandler.prototype.handle = function (params) {
          return params.key;
      };
      return FakeMissingTranslationHandler;
  }());
  FakeMissingTranslationHandler.decorators = [
      { type: Injectable },
  ];
  FakeMissingTranslationHandler.ctorParameters = function () { return []; };
  var TranslateCompiler = /** @class */ (function () {
      function TranslateCompiler() {
      }
      return TranslateCompiler;
  }());
  var TranslateFakeCompiler = /** @class */ (function (_super) {
      __extends(TranslateFakeCompiler, _super);
      function TranslateFakeCompiler() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      TranslateFakeCompiler.prototype.compile = function (value, lang) {
          return value;
      };
      TranslateFakeCompiler.prototype.compileTranslations = function (translations, lang) {
          return translations;
      };
      return TranslateFakeCompiler;
  }(TranslateCompiler));
  TranslateFakeCompiler.decorators = [
      { type: Injectable },
  ];
  TranslateFakeCompiler.ctorParameters = function () { return []; };
  function equals(o1, o2) {
      if (o1 === o2)
          return true;
      if (o1 === null || o2 === null)
          return false;
      if (o1 !== o1 && o2 !== o2)
          return true;
      var t1 = typeof o1, t2 = typeof o2, length, key, keySet;
      if (t1 == t2 && t1 == 'object') {
          if (Array.isArray(o1)) {
              if (!Array.isArray(o2))
                  return false;
              if ((length = o1.length) == o2.length) {
                  for (key = 0; key < length; key++) {
                      if (!equals(o1[key], o2[key]))
                          return false;
                  }
                  return true;
              }
          }
          else {
              if (Array.isArray(o2)) {
                  return false;
              }
              keySet = Object.create(null);
              for (key in o1) {
                  if (!equals(o1[key], o2[key])) {
                      return false;
                  }
                  keySet[key] = true;
              }
              for (key in o2) {
                  if (!(key in keySet) && typeof o2[key] !== 'undefined') {
                      return false;
                  }
              }
              return true;
          }
      }
      return false;
  }
  function isDefined(value) {
      return typeof value !== 'undefined' && value !== null;
  }
  function isObject(item) {
      return (item && typeof item === 'object' && !Array.isArray(item));
  }
  function mergeDeep(target, source) {
      var output = Object.assign({}, target);
      if (isObject(target) && isObject(source)) {
          Object.keys(source).forEach(function (key) {
              if (isObject(source[key])) {
                  if (!(key in target)) {
                      Object.assign(output, (_a = {}, _a[key] = source[key], _a));
                  }
                  else {
                      output[key] = mergeDeep(target[key], source[key]);
                  }
              }
              else {
                  Object.assign(output, (_b = {}, _b[key] = source[key], _b));
              }
              var _a, _b;
          });
      }
      return output;
  }
  var TranslateParser = /** @class */ (function () {
      function TranslateParser() {
      }
      return TranslateParser;
  }());
  var TranslateDefaultParser = /** @class */ (function (_super) {
      __extends(TranslateDefaultParser, _super);
      function TranslateDefaultParser() {
          var _this = _super.apply(this, __spread(arguments)) || this;
          _this.templateMatcher = /{{\s?([^{}\s]*)\s?}}/g;
          return _this;
      }
      TranslateDefaultParser.prototype.interpolate = function (expr, params) {
          var result;
          if (typeof expr === 'string') {
              result = this.interpolateString(expr, params);
          }
          else if (typeof expr === 'function') {
              result = this.interpolateFunction(expr, params);
          }
          else {
              result = (expr);
          }
          return result;
      };
      TranslateDefaultParser.prototype.getValue = function (target, key) {
          var keys = key.split('.');
          key = '';
          do {
              key += keys.shift();
              if (isDefined(target) && isDefined(target[key]) && (typeof target[key] === 'object' || !keys.length)) {
                  target = target[key];
                  key = '';
              }
              else if (!keys.length) {
                  target = undefined;
              }
              else {
                  key += '.';
              }
          } while (keys.length);
          return target;
      };
      TranslateDefaultParser.prototype.interpolateFunction = function (fn, params) {
          return fn(params);
      };
      TranslateDefaultParser.prototype.interpolateString = function (expr, params) {
          var _this = this;
          if (!params) {
              return expr;
          }
          return expr.replace(this.templateMatcher, function (substring, b) {
              var r = _this.getValue(params, b);
              return isDefined(r) ? r : substring;
          });
      };
      return TranslateDefaultParser;
  }(TranslateParser));
  TranslateDefaultParser.decorators = [
      { type: Injectable },
  ];
  TranslateDefaultParser.ctorParameters = function () { return []; };
  var TranslateStore = /** @class */ (function () {
      function TranslateStore() {
          this.currentLang = this.defaultLang;
          this.translations = {};
          this.langs = [];
          this.onTranslationChange = new EventEmitter();
          this.onLangChange = new EventEmitter();
          this.onDefaultLangChange = new EventEmitter();
      }
      return TranslateStore;
  }());
  var USE_STORE = new InjectionToken('USE_STORE');
  var USE_DEFAULT_LANG = new InjectionToken('USE_DEFAULT_LANG');
  var TranslateService = /** @class */ (function () {
      function TranslateService(store, currentLoader, compiler, parser, missingTranslationHandler, useDefaultLang, isolate) {
          if (useDefaultLang === void 0) { useDefaultLang = true; }
          if (isolate === void 0) { isolate = false; }
          this.store = store;
          this.currentLoader = currentLoader;
          this.compiler = compiler;
          this.parser = parser;
          this.missingTranslationHandler = missingTranslationHandler;
          this.useDefaultLang = useDefaultLang;
          this.isolate = isolate;
          this.pending = false;
          this._onTranslationChange = new EventEmitter();
          this._onLangChange = new EventEmitter();
          this._onDefaultLangChange = new EventEmitter();
          this._langs = [];
          this._translations = {};
          this._translationRequests = {};
      }
      Object.defineProperty(TranslateService.prototype, "onTranslationChange", {
          get: function () {
              return this.isolate ? this._onTranslationChange : this.store.onTranslationChange;
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(TranslateService.prototype, "onLangChange", {
          get: function () {
              return this.isolate ? this._onLangChange : this.store.onLangChange;
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(TranslateService.prototype, "onDefaultLangChange", {
          get: function () {
              return this.isolate ? this._onDefaultLangChange : this.store.onDefaultLangChange;
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(TranslateService.prototype, "defaultLang", {
          get: function () {
              return this.isolate ? this._defaultLang : this.store.defaultLang;
          },
          set: function (defaultLang) {
              if (this.isolate) {
                  this._defaultLang = defaultLang;
              }
              else {
                  this.store.defaultLang = defaultLang;
              }
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(TranslateService.prototype, "currentLang", {
          get: function () {
              return this.isolate ? this._currentLang : this.store.currentLang;
          },
          set: function (currentLang) {
              if (this.isolate) {
                  this._currentLang = currentLang;
              }
              else {
                  this.store.currentLang = currentLang;
              }
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(TranslateService.prototype, "langs", {
          get: function () {
              return this.isolate ? this._langs : this.store.langs;
          },
          set: function (langs) {
              if (this.isolate) {
                  this._langs = langs;
              }
              else {
                  this.store.langs = langs;
              }
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(TranslateService.prototype, "translations", {
          get: function () {
              return this.isolate ? this._translations : this.store.translations;
          },
          set: function (translations) {
              if (this.isolate) {
                  this._translations = translations;
              }
              else {
                  this.store.translations = translations;
              }
          },
          enumerable: true,
          configurable: true
      });
      TranslateService.prototype.setDefaultLang = function (lang) {
          var _this = this;
          if (lang === this.defaultLang) {
              return;
          }
          var pending = this.retrieveTranslations(lang);
          if (typeof pending !== "undefined") {
              if (!this.defaultLang) {
                  this.defaultLang = lang;
              }
              pending.pipe(take(1))
                  .subscribe(function (res) {
                  _this.changeDefaultLang(lang);
              });
          }
          else {
              this.changeDefaultLang(lang);
          }
      };
      TranslateService.prototype.getDefaultLang = function () {
          return this.defaultLang;
      };
      TranslateService.prototype.use = function (lang) {
          var _this = this;
          if (lang === this.currentLang) {
              return of(this.translations[lang]);
          }
          var pending = this.retrieveTranslations(lang);
          if (typeof pending !== "undefined") {
              if (!this.currentLang) {
                  this.currentLang = lang;
              }
              pending.pipe(take(1))
                  .subscribe(function (res) {
                  _this.changeLang(lang);
              });
              return pending;
          }
          else {
              this.changeLang(lang);
              return of(this.translations[lang]);
          }
      };
      TranslateService.prototype.retrieveTranslations = function (lang) {
          var pending;
          if (typeof this.translations[lang] === "undefined") {
              this._translationRequests[lang] = this._translationRequests[lang] || this.getTranslation(lang);
              pending = this._translationRequests[lang];
          }
          return pending;
      };
      TranslateService.prototype.getTranslation = function (lang) {
          var _this = this;
          this.pending = true;
          this.loadingTranslations = this.currentLoader.getTranslation(lang).pipe(share());
          this.loadingTranslations.pipe(take(1))
              .subscribe(function (res) {
              _this.translations[lang] = _this.compiler.compileTranslations(res, lang);
              _this.updateLangs();
              _this.pending = false;
          }, function (err) {
              _this.pending = false;
          });
          return this.loadingTranslations;
      };
      TranslateService.prototype.setTranslation = function (lang, translations, shouldMerge) {
          if (shouldMerge === void 0) { shouldMerge = false; }
          translations = this.compiler.compileTranslations(translations, lang);
          if (shouldMerge && this.translations[lang]) {
              this.translations[lang] = mergeDeep(this.translations[lang], translations);
          }
          else {
              this.translations[lang] = translations;
          }
          this.updateLangs();
          this.onTranslationChange.emit({ lang: lang, translations: this.translations[lang] });
      };
      TranslateService.prototype.getLangs = function () {
          return this.langs;
      };
      TranslateService.prototype.addLangs = function (langs) {
          var _this = this;
          langs.forEach(function (lang) {
              if (_this.langs.indexOf(lang) === -1) {
                  _this.langs.push(lang);
              }
          });
      };
      TranslateService.prototype.updateLangs = function () {
          this.addLangs(Object.keys(this.translations));
      };
      TranslateService.prototype.getParsedResult = function (translations, key, interpolateParams) {
          var res;
          if (key instanceof Array) {
              var result = {}, observables = false;
              try {
                  for (var key_1 = __values(key), key_1_1 = key_1.next(); !key_1_1.done; key_1_1 = key_1.next()) {
                      var k = key_1_1.value;
                      result[k] = this.getParsedResult(translations, k, interpolateParams);
                      if (typeof result[k].subscribe === "function") {
                          observables = true;
                      }
                  }
              }
              catch (e_1_1) { e_1 = { error: e_1_1 }; }
              finally {
                  try {
                      if (key_1_1 && !key_1_1.done && (_a = key_1.return)) _a.call(key_1);
                  }
                  finally { if (e_1) throw e_1.error; }
              }
              if (observables) {
                  var mergedObs = void 0;
                  try {
                      for (var key_2 = __values(key), key_2_1 = key_2.next(); !key_2_1.done; key_2_1 = key_2.next()) {
                          var k = key_2_1.value;
                          var obs = typeof result[k].subscribe === "function" ? result[k] : of((result[k]));
                          if (typeof mergedObs === "undefined") {
                              mergedObs = obs;
                          }
                          else {
                              mergedObs = merge(mergedObs, obs);
                          }
                      }
                  }
                  catch (e_2_1) { e_2 = { error: e_2_1 }; }
                  finally {
                      try {
                          if (key_2_1 && !key_2_1.done && (_b = key_2.return)) _b.call(key_2);
                      }
                      finally { if (e_2) throw e_2.error; }
                  }
                  return mergedObs.pipe(toArray(), map(function (arr) {
                      var obj = {};
                      arr.forEach(function (value, index) {
                          obj[key[index]] = value;
                      });
                      return obj;
                  }));
              }
              return result;
          }
          if (translations) {
              res = this.parser.interpolate(this.parser.getValue(translations, key), interpolateParams);
          }
          if (typeof res === "undefined" && this.defaultLang && this.defaultLang !== this.currentLang && this.useDefaultLang) {
              res = this.parser.interpolate(this.parser.getValue(this.translations[this.defaultLang], key), interpolateParams);
          }
          if (typeof res === "undefined") {
              var params = { key: key, translateService: this };
              if (typeof interpolateParams !== 'undefined') {
                  params.interpolateParams = interpolateParams;
              }
              res = this.missingTranslationHandler.handle(params);
          }
          return typeof res !== "undefined" ? res : key;
          var e_1, _a, e_2, _b;
      };
      TranslateService.prototype.get = function (key, interpolateParams) {
          var _this = this;
          if (!isDefined(key) || !key.length) {
              throw new Error("Parameter \"key\" required");
          }
          if (this.pending) {
              return Observable.create(function (observer) {
                  var onComplete = function (res) {
                      observer.next(res);
                      observer.complete();
                  };
                  var onError = function (err) {
                      observer.error(err);
                  };
                  _this.loadingTranslations.subscribe(function (res) {
                      res = _this.getParsedResult(_this.compiler.compileTranslations(res, _this.currentLang), key, interpolateParams);
                      if (typeof res.subscribe === "function") {
                          res.subscribe(onComplete, onError);
                      }
                      else {
                          onComplete(res);
                      }
                  }, onError);
              });
          }
          else {
              var res = this.getParsedResult(this.translations[this.currentLang], key, interpolateParams);
              if (typeof res.subscribe === "function") {
                  return res;
              }
              else {
                  return of(res);
              }
          }
      };
      TranslateService.prototype.stream = function (key, interpolateParams) {
          var _this = this;
          if (!isDefined(key) || !key.length) {
              throw new Error("Parameter \"key\" required");
          }
          return concat(this.get(key, interpolateParams), this.onLangChange.pipe(switchMap(function (event) {
              var res = _this.getParsedResult(event.translations, key, interpolateParams);
              if (typeof res.subscribe === "function") {
                  return res;
              }
              else {
                  return of(res);
              }
          })));
      };
      TranslateService.prototype.instant = function (key, interpolateParams) {
          if (!isDefined(key) || !key.length) {
              throw new Error("Parameter \"key\" required");
          }
          var res = this.getParsedResult(this.translations[this.currentLang], key, interpolateParams);
          if (typeof res.subscribe !== "undefined") {
              if (key instanceof Array) {
                  var obj_1 = {};
                  key.forEach(function (value, index) {
                      obj_1[key[index]] = key[index];
                  });
                  return obj_1;
              }
              return key;
          }
          else {
              return res;
          }
      };
      TranslateService.prototype.set = function (key, value, lang) {
          if (lang === void 0) { lang = this.currentLang; }
          this.translations[lang][key] = this.compiler.compile(value, lang);
          this.updateLangs();
          this.onTranslationChange.emit({ lang: lang, translations: this.translations[lang] });
      };
      TranslateService.prototype.changeLang = function (lang) {
          this.currentLang = lang;
          this.onLangChange.emit({ lang: lang, translations: this.translations[lang] });
          if (!this.defaultLang) {
              this.changeDefaultLang(lang);
          }
      };
      TranslateService.prototype.changeDefaultLang = function (lang) {
          this.defaultLang = lang;
          this.onDefaultLangChange.emit({ lang: lang, translations: this.translations[lang] });
      };
      TranslateService.prototype.reloadLang = function (lang) {
          this.resetLang(lang);
          return this.getTranslation(lang);
      };
      TranslateService.prototype.resetLang = function (lang) {
          this._translationRequests[lang] = undefined;
          this.translations[lang] = undefined;
      };
      TranslateService.prototype.getBrowserLang = function () {
          if (typeof window === 'undefined' || typeof window.navigator === 'undefined') {
              return undefined;
          }
          var browserLang = window.navigator.languages ? window.navigator.languages[0] : null;
          browserLang = browserLang || window.navigator.language || window.navigator.browserLanguage || window.navigator.userLanguage;
          if (browserLang.indexOf('-') !== -1) {
              browserLang = browserLang.split('-')[0];
          }
          if (browserLang.indexOf('_') !== -1) {
              browserLang = browserLang.split('_')[0];
          }
          return browserLang;
      };
      TranslateService.prototype.getBrowserCultureLang = function () {
          if (typeof window === 'undefined' || typeof window.navigator === 'undefined') {
              return undefined;
          }
          var browserCultureLang = window.navigator.languages ? window.navigator.languages[0] : null;
          browserCultureLang = browserCultureLang || window.navigator.language || window.navigator.browserLanguage || window.navigator.userLanguage;
          return browserCultureLang;
      };
      return TranslateService;
  }());
  TranslateService.decorators = [
      { type: Injectable },
  ];
  TranslateService.ctorParameters = function () { return [
      { type: TranslateStore, },
      { type: TranslateLoader, },
      { type: TranslateCompiler, },
      { type: TranslateParser, },
      { type: MissingTranslationHandler, },
      { type: undefined, decorators: [{ type: Inject, args: [USE_DEFAULT_LANG,] },] },
      { type: undefined, decorators: [{ type: Inject, args: [USE_STORE,] },] },
  ]; };
  var TranslateDirective = /** @class */ (function () {
      function TranslateDirective(translateService, element, _ref) {
          var _this = this;
          this.translateService = translateService;
          this.element = element;
          this._ref = _ref;
          if (!this.onTranslationChangeSub) {
              this.onTranslationChangeSub = this.translateService.onTranslationChange.subscribe(function (event) {
                  if (event.lang === _this.translateService.currentLang) {
                      _this.checkNodes(true, event.translations);
                  }
              });
          }
          if (!this.onLangChangeSub) {
              this.onLangChangeSub = this.translateService.onLangChange.subscribe(function (event) {
                  _this.checkNodes(true, event.translations);
              });
          }
          if (!this.onDefaultLangChangeSub) {
              this.onDefaultLangChangeSub = this.translateService.onDefaultLangChange.subscribe(function (event) {
                  _this.checkNodes(true);
              });
          }
      }
      Object.defineProperty(TranslateDirective.prototype, "translate", {
          set: function (key) {
              if (key) {
                  this.key = key;
                  this.checkNodes();
              }
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(TranslateDirective.prototype, "translateParams", {
          set: function (params) {
              if (!equals(this.currentParams, params)) {
                  this.currentParams = params;
                  this.checkNodes(true);
              }
          },
          enumerable: true,
          configurable: true
      });
      TranslateDirective.prototype.ngAfterViewChecked = function () {
          this.checkNodes();
      };
      TranslateDirective.prototype.checkNodes = function (forceUpdate, translations) {
          if (forceUpdate === void 0) { forceUpdate = false; }
          var nodes = this.element.nativeElement.childNodes;
          if (!nodes.length) {
              this.setContent(this.element.nativeElement, this.key);
              nodes = this.element.nativeElement.childNodes;
          }
          for (var i = 0; i < nodes.length; ++i) {
              var node = nodes[i];
              if (node.nodeType === 3) {
                  var key = void 0;
                  if (this.key) {
                      key = this.key;
                      if (forceUpdate) {
                          node.lastKey = null;
                      }
                  }
                  else {
                      var content = this.getContent(node);
                      var trimmedContent = content.trim();
                      if (trimmedContent.length) {
                          if (content !== node.currentValue) {
                              key = trimmedContent;
                              node.originalContent = this.getContent(node);
                          }
                          else if (node.originalContent && forceUpdate) {
                              node.lastKey = null;
                              key = node.originalContent.trim();
                          }
                      }
                  }
                  this.updateValue(key, node, translations);
              }
          }
      };
      TranslateDirective.prototype.updateValue = function (key, node, translations) {
          var _this = this;
          if (key) {
              if (node.lastKey === key && this.lastParams === this.currentParams) {
                  return;
              }
              this.lastParams = this.currentParams;
              var onTranslation = function (res) {
                  if (res !== key) {
                      node.lastKey = key;
                  }
                  if (!node.originalContent) {
                      node.originalContent = _this.getContent(node);
                  }
                  node.currentValue = isDefined(res) ? res : (node.originalContent || key);
                  _this.setContent(node, _this.key ? node.currentValue : node.originalContent.replace(key, node.currentValue));
                  _this._ref.markForCheck();
              };
              if (isDefined(translations)) {
                  var res = this.translateService.getParsedResult(translations, key, this.currentParams);
                  if (typeof res.subscribe === "function") {
                      res.subscribe(onTranslation);
                  }
                  else {
                      onTranslation(res);
                  }
              }
              else {
                  this.translateService.get(key, this.currentParams).subscribe(onTranslation);
              }
          }
      };
      TranslateDirective.prototype.getContent = function (node) {
          return isDefined(node.textContent) ? node.textContent : node.data;
      };
      TranslateDirective.prototype.setContent = function (node, content) {
          if (isDefined(node.textContent)) {
              node.textContent = content;
          }
          else {
              node.data = content;
          }
      };
      TranslateDirective.prototype.ngOnDestroy = function () {
          if (this.onLangChangeSub) {
              this.onLangChangeSub.unsubscribe();
          }
          if (this.onDefaultLangChangeSub) {
              this.onDefaultLangChangeSub.unsubscribe();
          }
          if (this.onTranslationChangeSub) {
              this.onTranslationChangeSub.unsubscribe();
          }
      };
      return TranslateDirective;
  }());
  TranslateDirective.decorators = [
      { type: Directive, args: [{
                  selector: '[translate],[ngx-translate]'
              },] },
  ];
  TranslateDirective.ctorParameters = function () { return [
      { type: TranslateService, },
      { type: ElementRef, },
      { type: ChangeDetectorRef, },
  ]; };
  TranslateDirective.propDecorators = {
      "translate": [{ type: Input },],
      "translateParams": [{ type: Input },],
  };
  var TranslatePipe = /** @class */ (function () {
      function TranslatePipe(translate, _ref) {
          this.translate = translate;
          this._ref = _ref;
          this.value = '';
      }
      TranslatePipe.prototype.updateValue = function (key, interpolateParams, translations) {
          var _this = this;
          var onTranslation = function (res) {
              _this.value = res !== undefined ? res : key;
              _this.lastKey = key;
              _this._ref.markForCheck();
          };
          if (translations) {
              var res = this.translate.getParsedResult(translations, key, interpolateParams);
              if (typeof res.subscribe === 'function') {
                  res.subscribe(onTranslation);
              }
              else {
                  onTranslation(res);
              }
          }
          this.translate.get(key, interpolateParams).subscribe(onTranslation);
      };
      TranslatePipe.prototype.transform = function (query) {
          var _this = this;
          var args = [];
          for (var _i = 1; _i < arguments.length; _i++) {
              args[_i - 1] = arguments[_i];
          }
          if (!query || query.length === 0) {
              return query;
          }
          if (equals(query, this.lastKey) && equals(args, this.lastParams)) {
              return this.value;
          }
          var interpolateParams;
          if (isDefined(args[0]) && args.length) {
              if (typeof args[0] === 'string' && args[0].length) {
                  var validArgs = args[0]
                      .replace(/(\')?([a-zA-Z0-9_]+)(\')?(\s)?:/g, '"$2":')
                      .replace(/:(\s)?(\')(.*?)(\')/g, ':"$3"');
                  try {
                      interpolateParams = JSON.parse(validArgs);
                  }
                  catch (e) {
                      throw new SyntaxError("Wrong parameter in TranslatePipe. Expected a valid Object, received: " + args[0]);
                  }
              }
              else if (typeof args[0] === 'object' && !Array.isArray(args[0])) {
                  interpolateParams = args[0];
              }
          }
          this.lastKey = query;
          this.lastParams = args;
          this.updateValue(query, interpolateParams);
          this._dispose();
          if (!this.onTranslationChange) {
              this.onTranslationChange = this.translate.onTranslationChange.subscribe(function (event) {
                  if (_this.lastKey && event.lang === _this.translate.currentLang) {
                      _this.lastKey = null;
                      _this.updateValue(query, interpolateParams, event.translations);
                  }
              });
          }
          if (!this.onLangChange) {
              this.onLangChange = this.translate.onLangChange.subscribe(function (event) {
                  if (_this.lastKey) {
                      _this.lastKey = null;
                      _this.updateValue(query, interpolateParams, event.translations);
                  }
              });
          }
          if (!this.onDefaultLangChange) {
              this.onDefaultLangChange = this.translate.onDefaultLangChange.subscribe(function () {
                  if (_this.lastKey) {
                      _this.lastKey = null;
                      _this.updateValue(query, interpolateParams);
                  }
              });
          }
          return this.value;
      };
      TranslatePipe.prototype._dispose = function () {
          if (typeof this.onTranslationChange !== 'undefined') {
              this.onTranslationChange.unsubscribe();
              this.onTranslationChange = undefined;
          }
          if (typeof this.onLangChange !== 'undefined') {
              this.onLangChange.unsubscribe();
              this.onLangChange = undefined;
          }
          if (typeof this.onDefaultLangChange !== 'undefined') {
              this.onDefaultLangChange.unsubscribe();
              this.onDefaultLangChange = undefined;
          }
      };
      TranslatePipe.prototype.ngOnDestroy = function () {
          this._dispose();
      };
      return TranslatePipe;
  }());
  TranslatePipe.decorators = [
      { type: Injectable },
      { type: Pipe, args: [{
                  name: 'translate',
                  pure: false
              },] },
  ];
  TranslatePipe.ctorParameters = function () { return [
      { type: TranslateService, },
      { type: ChangeDetectorRef, },
  ]; };
  var TranslateModule = /** @class */ (function () {
      function TranslateModule() {
      }
      TranslateModule.forRoot = function (config) {
          if (config === void 0) { config = {}; }
          return {
              ngModule: TranslateModule,
              providers: [
                  config.loader || { provide: TranslateLoader, useClass: TranslateFakeLoader },
                  config.compiler || { provide: TranslateCompiler, useClass: TranslateFakeCompiler },
                  config.parser || { provide: TranslateParser, useClass: TranslateDefaultParser },
                  config.missingTranslationHandler || { provide: MissingTranslationHandler, useClass: FakeMissingTranslationHandler },
                  TranslateStore,
                  { provide: USE_STORE, useValue: config.isolate },
                  { provide: USE_DEFAULT_LANG, useValue: config.useDefaultLang },
                  TranslateService
              ]
          };
      };
      TranslateModule.forChild = function (config) {
          if (config === void 0) { config = {}; }
          return {
              ngModule: TranslateModule,
              providers: [
                  config.loader || { provide: TranslateLoader, useClass: TranslateFakeLoader },
                  config.compiler || { provide: TranslateCompiler, useClass: TranslateFakeCompiler },
                  config.parser || { provide: TranslateParser, useClass: TranslateDefaultParser },
                  config.missingTranslationHandler || { provide: MissingTranslationHandler, useClass: FakeMissingTranslationHandler },
                  { provide: USE_STORE, useValue: config.isolate },
                  { provide: USE_DEFAULT_LANG, useValue: config.useDefaultLang },
                  TranslateService
              ]
          };
      };
      return TranslateModule;
  }());
  TranslateModule.decorators = [
      { type: NgModule, args: [{
                  declarations: [
                      TranslatePipe,
                      TranslateDirective
                  ],
                  exports: [
                      TranslatePipe,
                      TranslateDirective
                  ]
              },] },
  ];
  TranslateModule.ctorParameters = function () { return []; };
  
  export { TranslateModule, TranslateLoader, TranslateFakeLoader, USE_STORE, USE_DEFAULT_LANG, TranslateService, MissingTranslationHandler, FakeMissingTranslationHandler, TranslateParser, TranslateDefaultParser, TranslateCompiler, TranslateFakeCompiler, TranslateDirective, TranslatePipe, TranslateStore as ɵa };
  //# sourceMappingURL=ngx-translate-core.js.map
  