text: /**
   * @license Angular v7.2.7
   * (c) 2010-2019 Google LLC. https://angular.io/
   * License: MIT
   */
  
  import { getDebugNode, RendererFactory2, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, InjectionToken, Injector, ɵresetCompiledComponents, ɵgetInjectableDef, NgZone, ɵRender3ComponentFactory, ɵRender3NgModuleRef, ApplicationInitStatus, ɵcompileNgModuleDefs, resolveForwardRef, ɵcompileComponent, ɵcompileDirective, ɵcompilePipe, ɵpatchComponentDefWithScope, Compiler, Injectable, ɵclearOverrides, ɵoverrideComponentView, ɵAPP_ROOT, ɵoverrideProvider, ɵivyEnabled, Optional, SkipSelf } from '@angular/core';
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /**
   * @license
   * Copyright Google Inc. All Rights Reserved.
   *
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://angular.io/license
   */
  /** @type {?} */
  const _global = (/** @type {?} */ ((typeof window === 'undefined' ? global : window)));
  /**
   * Wraps a test function in an asynchronous test zone. The test will automatically
   * complete when all asynchronous calls within this zone are done. Can be used
   * to wrap an {\@link inject} call.
   *
   * Example:
   *
   * ```
   * it('...', async(inject([AClass], (object) => {
   *   object.doSomething.then(() => {
   *     expect(...);
   *   })
   * });
   * ```
   *
   *
   * @param {?} fn
   * @return {?}
   */
  function asyncFallback(fn) {
      // If we're running using the Jasmine test framework, adapt to call the 'done'
      // function when asynchronous activity is finished.
      if (_global.jasmine) {
          // Not using an arrow function to preserve context passed from call site
          return function (done) {
              if (!done) {
                  // if we run beforeEach in @angular/core/testing/testing_internal then we get no done
                  // fake it here and assume sync.
                  done = function () { };
                  done.fail = function (e) { throw e; };
              }
              runInTestZone(fn, this, done, (err) => {
                  if (typeof err === 'string') {
                      return done.fail(new Error((/** @type {?} */ (err))));
                  }
                  else {
                      done.fail(err);
                  }
              });
          };
      }
      // Otherwise, return a promise which will resolve when asynchronous activity
      // is finished. This will be correctly consumed by the Mocha framework with
      // it('...', async(myFn)); or can be used in a custom framework.
      // Not using an arrow function to preserve context passed from call site
      return function () {
          return new Promise((finishCallback, failCallback) => {
              runInTestZone(fn, this, finishCallback, failCallback);
          });
      };
  }
  /**
   * @param {?} fn
   * @param {?} context
   * @param {?} finishCallback
   * @param {?} failCallback
   * @return {?}
   */
  function runInTestZone(fn, context, finishCallback, failCallback) {
      /** @type {?} */
      const currentZone = Zone.current;
      /** @type {?} */
      const AsyncTestZoneSpec = ((/** @type {?} */ (Zone)))['AsyncTestZoneSpec'];
      if (AsyncTestZoneSpec === undefined) {
          throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' +
              'Please make sure that your environment includes zone.js/dist/async-test.js');
      }
      /** @type {?} */
      const ProxyZoneSpec = (/** @type {?} */ (((/** @type {?} */ (Zone)))['ProxyZoneSpec']));
      if (ProxyZoneSpec === undefined) {
          throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' +
              'Please make sure that your environment includes zone.js/dist/proxy.js');
      }
      /** @type {?} */
      const proxyZoneSpec = ProxyZoneSpec.get();
      ProxyZoneSpec.assertPresent();
      // We need to create the AsyncTestZoneSpec outside the ProxyZone.
      // If we do it in ProxyZone then we will get to infinite recursion.
      /** @type {?} */
      const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec');
      /** @type {?} */
      const previousDelegate = proxyZoneSpec.getDelegate();
      proxyZone.parent.run(() => {
          /** @type {?} */
          const testZoneSpec = new AsyncTestZoneSpec(() => {
              // Need to restore the original zone.
              currentZone.run(() => {
                  if (proxyZoneSpec.getDelegate() == testZoneSpec) {
                      // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK.
                      proxyZoneSpec.setDelegate(previousDelegate);
                  }
                  finishCallback();
              });
          }, (error) => {
              // Need to restore the original zone.
              currentZone.run(() => {
                  if (proxyZoneSpec.getDelegate() == testZoneSpec) {
                      // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK.
                      proxyZoneSpec.setDelegate(previousDelegate);
                  }
                  failCallback(error);
              });
          }, 'test');
          proxyZoneSpec.setDelegate(testZoneSpec);
      });
      return Zone.current.runGuarded(fn, context);
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /**
   * Wraps a test function in an asynchronous test zone. The test will automatically
   * complete when all asynchronous calls within this zone are done. Can be used
   * to wrap an {\@link inject} call.
   *
   * Example:
   *
   * ```
   * it('...', async(inject([AClass], (object) => {
   *   object.doSomething.then(() => {
   *     expect(...);
   *   })
   * });
   * ```
   *
   * \@publicApi
   * @param {?} fn
   * @return {?}
   */
  function async(fn) {
      /** @type {?} */
      const _Zone = typeof Zone !== 'undefined' ? Zone : null;
      if (!_Zone) {
          return function () {
              return Promise.reject('Zone is needed for the async() test helper but could not be found. ' +
                  'Please make sure that your environment includes zone.js/dist/zone.js');
          };
      }
      /** @type {?} */
      const asyncTest = _Zone && _Zone[_Zone.__symbol__('asyncTest')];
      if (typeof asyncTest === 'function') {
          return asyncTest(fn);
      }
      // not using new version of zone.js
      // TODO @JiaLiPassion, remove this after all library updated to
      // newest version of zone.js(0.8.25)
      return asyncFallback(fn);
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /**
   * Fixture for debugging and testing a component.
   *
   * \@publicApi
   * @template T
   */
  class ComponentFixture {
      /**
       * @param {?} componentRef
       * @param {?} ngZone
       * @param {?} _autoDetect
       */
      constructor(componentRef, ngZone, _autoDetect) {
          this.componentRef = componentRef;
          this.ngZone = ngZone;
          this._autoDetect = _autoDetect;
          this._isStable = true;
          this._isDestroyed = false;
          this._resolve = null;
          this._promise = null;
          this._onUnstableSubscription = null;
          this._onStableSubscription = null;
          this._onMicrotaskEmptySubscription = null;
          this._onErrorSubscription = null;
          this.changeDetectorRef = componentRef.changeDetectorRef;
          this.elementRef = componentRef.location;
          this.debugElement = (/** @type {?} */ (getDebugNode(this.elementRef.nativeElement)));
          this.componentInstance = componentRef.instance;
          this.nativeElement = this.elementRef.nativeElement;
          this.componentRef = componentRef;
          this.ngZone = ngZone;
          if (ngZone) {
              // Create subscriptions outside the NgZone so that the callbacks run oustide
              // of NgZone.
              ngZone.runOutsideAngular(() => {
                  this._onUnstableSubscription =
                      ngZone.onUnstable.subscribe({ next: () => { this._isStable = false; } });
                  this._onMicrotaskEmptySubscription = ngZone.onMicrotaskEmpty.subscribe({
                      next: () => {
                          if (this._autoDetect) {
                              // Do a change detection run with checkNoChanges set to true to check
                              // there are no changes on the second run.
                              this.detectChanges(true);
                          }
                      }
                  });
                  this._onStableSubscription = ngZone.onStable.subscribe({
                      next: () => {
                          this._isStable = true;
                          // Check whether there is a pending whenStable() completer to resolve.
                          if (this._promise !== null) {
                              // If so check whether there are no pending macrotasks before resolving.
                              // Do this check in the next tick so that ngZone gets a chance to update the state of
                              // pending macrotasks.
                              scheduleMicroTask(() => {
                                  if (!ngZone.hasPendingMacrotasks) {
                                      if (this._promise !== null) {
                                          (/** @type {?} */ (this._resolve))(true);
                                          this._resolve = null;
                                          this._promise = null;
                                      }
                                  }
                              });
                          }
                      }
                  });
                  this._onErrorSubscription =
                      ngZone.onError.subscribe({ next: (error) => { throw error; } });
              });
          }
      }
      /**
       * @private
       * @param {?} checkNoChanges
       * @return {?}
       */
      _tick(checkNoChanges) {
          this.changeDetectorRef.detectChanges();
          if (checkNoChanges) {
              this.checkNoChanges();
          }
      }
      /**
       * Trigger a change detection cycle for the component.
       * @param {?=} checkNoChanges
       * @return {?}
       */
      detectChanges(checkNoChanges = true) {
          if (this.ngZone != null) {
              // Run the change detection inside the NgZone so that any async tasks as part of the change
              // detection are captured by the zone and can be waited for in isStable.
              this.ngZone.run(() => { this._tick(checkNoChanges); });
          }
          else {
              // Running without zone. Just do the change detection.
              this._tick(checkNoChanges);
          }
      }
      /**
       * Do a change detection run to make sure there were no changes.
       * @return {?}
       */
      checkNoChanges() { this.changeDetectorRef.checkNoChanges(); }
      /**
       * Set whether the fixture should autodetect changes.
       *
       * Also runs detectChanges once so that any existing change is detected.
       * @param {?=} autoDetect
       * @return {?}
       */
      autoDetectChanges(autoDetect = true) {
          if (this.ngZone == null) {
              throw new Error('Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set');
          }
          this._autoDetect = autoDetect;
          this.detectChanges();
      }
      /**
       * Return whether the fixture is currently stable or has async tasks that have not been completed
       * yet.
       * @return {?}
       */
      isStable() { return this._isStable && !(/** @type {?} */ (this.ngZone)).hasPendingMacrotasks; }
      /**
       * Get a promise that resolves when the fixture is stable.
       *
       * This can be used to resume testing after events have triggered asynchronous activity or
       * asynchronous change detection.
       * @return {?}
       */
      whenStable() {
          if (this.isStable()) {
              return Promise.resolve(false);
          }
          else if (this._promise !== null) {
              return this._promise;
          }
          else {
              this._promise = new Promise(res => { this._resolve = res; });
              return this._promise;
          }
      }
      /**
       * @private
       * @return {?}
       */
      _getRenderer() {
          if (this._renderer === undefined) {
              this._renderer = this.componentRef.injector.get(RendererFactory2, null);
          }
          return (/** @type {?} */ (this._renderer));
      }
      /**
       * Get a promise that resolves when the ui state is stable following animations.
       * @return {?}
       */
      whenRenderingDone() {
          /** @type {?} */
          const renderer = this._getRenderer();
          if (renderer && renderer.whenRenderingDone) {
              return renderer.whenRenderingDone();
          }
          return this.whenStable();
      }
      /**
       * Trigger component destruction.
       * @return {?}
       */
      destroy() {
          if (!this._isDestroyed) {
              this.componentRef.destroy();
              if (this._onUnstableSubscription != null) {
                  this._onUnstableSubscription.unsubscribe();
                  this._onUnstableSubscription = null;
              }
              if (this._onStableSubscription != null) {
                  this._onStableSubscription.unsubscribe();
                  this._onStableSubscription = null;
              }
              if (this._onMicrotaskEmptySubscription != null) {
                  this._onMicrotaskEmptySubscription.unsubscribe();
                  this._onMicrotaskEmptySubscription = null;
              }
              if (this._onErrorSubscription != null) {
                  this._onErrorSubscription.unsubscribe();
                  this._onErrorSubscription = null;
              }
              this._isDestroyed = true;
          }
      }
  }
  /**
   * @param {?} fn
   * @return {?}
   */
  function scheduleMicroTask(fn) {
      Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /**
   * @license
   * Copyright Google Inc. All Rights Reserved.
   *
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://angular.io/license
   */
  /**
   * fakeAsync has been moved to zone.js
   * this file is for fallback in case old version of zone.js is used
   * @type {?}
   */
  const _Zone = typeof Zone !== 'undefined' ? Zone : null;
  /** @type {?} */
  const FakeAsyncTestZoneSpec = _Zone && _Zone['FakeAsyncTestZoneSpec'];
  /** @type {?} */
  const ProxyZoneSpec = _Zone && _Zone['ProxyZoneSpec'];
  /** @type {?} */
  let _fakeAsyncTestZoneSpec = null;
  /**
   * Clears out the shared fake async zone for a test.
   * To be called in a global `beforeEach`.
   *
   * \@publicApi
   * @return {?}
   */
  function resetFakeAsyncZoneFallback() {
      _fakeAsyncTestZoneSpec = null;
      // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset.
      ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate();
  }
  /** @type {?} */
  let _inFakeAsyncCall = false;
  /**
   * Wraps a function to be executed in the fakeAsync zone:
   * - microtasks are manually executed by calling `flushMicrotasks()`,
   * - timers are synchronous, `tick()` simulates the asynchronous passage of time.
   *
   * If there are any pending timers at the end of the function, an exception will be thrown.
   *
   * Can be used to wrap inject() calls.
   *
   * \@usageNotes
   * ### Example
   *
   * {\@example core/testing/ts/fake_async.ts region='basic'}
   *
   * \@publicApi
   * @param {?} fn
   * @return {?} The function wrapped to be executed in the fakeAsync zone
   *
   */
  function fakeAsyncFallback(fn) {
      // Not using an arrow function to preserve context passed from call site
      return function (...args) {
          /** @type {?} */
          const proxyZoneSpec = ProxyZoneSpec.assertPresent();
          if (_inFakeAsyncCall) {
              throw new Error('fakeAsync() calls can not be nested');
          }
          _inFakeAsyncCall = true;
          try {
              if (!_fakeAsyncTestZoneSpec) {
                  if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) {
                      throw new Error('fakeAsync() calls can not be nested');
                  }
                  _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec();
              }
              /** @type {?} */
              let res;
              /** @type {?} */
              const lastProxyZoneSpec = proxyZoneSpec.getDelegate();
              proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec);
              try {
                  res = fn.apply(this, args);
                  flushMicrotasksFallback();
              }
              finally {
                  proxyZoneSpec.setDelegate(lastProxyZoneSpec);
              }
              if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) {
                  throw new Error(`${_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length} ` +
                      `periodic timer(s) still in the queue.`);
              }
              if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) {
                  throw new Error(`${_fakeAsyncTestZoneSpec.pendingTimers.length} timer(s) still in the queue.`);
              }
              return res;
          }
          finally {
              _inFakeAsyncCall = false;
              resetFakeAsyncZoneFallback();
          }
      };
  }
  /**
   * @return {?}
   */
  function _getFakeAsyncZoneSpec() {
      if (_fakeAsyncTestZoneSpec == null) {
          throw new Error('The code should be running in the fakeAsync zone to call this function');
      }
      return _fakeAsyncTestZoneSpec;
  }
  /**
   * Simulates the asynchronous passage of time for the timers in the fakeAsync zone.
   *
   * The microtasks queue is drained at the very start of this function and after any timer callback
   * has been executed.
   *
   * \@usageNotes
   * ### Example
   *
   * {\@example core/testing/ts/fake_async.ts region='basic'}
   *
   * \@publicApi
   * @param {?=} millis
   * @return {?}
   */
  function tickFallback(millis = 0) {
      _getFakeAsyncZoneSpec().tick(millis);
  }
  /**
   * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by
   * draining the macrotask queue until it is empty. The returned value is the milliseconds
   * of time that would have been elapsed.
   *
   * \@publicApi
   * @param {?=} maxTurns
   * @return {?} The simulated time elapsed, in millis.
   *
   */
  function flushFallback(maxTurns) {
      return _getFakeAsyncZoneSpec().flush(maxTurns);
  }
  /**
   * Discard all remaining periodic tasks.
   *
   * \@publicApi
   * @return {?}
   */
  function discardPeriodicTasksFallback() {
      /** @type {?} */
      const zoneSpec = _getFakeAsyncZoneSpec();
      zoneSpec.pendingPeriodicTimers.length = 0;
  }
  /**
   * Flush any pending microtasks.
   *
   * \@publicApi
   * @return {?}
   */
  function flushMicrotasksFallback() {
      _getFakeAsyncZoneSpec().flushMicrotasks();
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /** @type {?} */
  const _Zone$1 = typeof Zone !== 'undefined' ? Zone : null;
  /** @type {?} */
  const fakeAsyncTestModule = _Zone$1 && _Zone$1[_Zone$1.__symbol__('fakeAsyncTest')];
  /**
   * Clears out the shared fake async zone for a test.
   * To be called in a global `beforeEach`.
   *
   * \@publicApi
   * @return {?}
   */
  function resetFakeAsyncZone() {
      if (fakeAsyncTestModule) {
          return fakeAsyncTestModule.resetFakeAsyncZone();
      }
      else {
          return resetFakeAsyncZoneFallback();
      }
  }
  /**
   * Wraps a function to be executed in the fakeAsync zone:
   * - microtasks are manually executed by calling `flushMicrotasks()`,
   * - timers are synchronous, `tick()` simulates the asynchronous passage of time.
   *
   * If there are any pending timers at the end of the function, an exception will be thrown.
   *
   * Can be used to wrap inject() calls.
   *
   * \@usageNotes
   * ### Example
   *
   * {\@example core/testing/ts/fake_async.ts region='basic'}
   *
   * \@publicApi
   * @param {?} fn
   * @return {?} The function wrapped to be executed in the fakeAsync zone
   *
   */
  function fakeAsync(fn) {
      if (fakeAsyncTestModule) {
          return fakeAsyncTestModule.fakeAsync(fn);
      }
      else {
          return fakeAsyncFallback(fn);
      }
  }
  /**
   * Simulates the asynchronous passage of time for the timers in the fakeAsync zone.
   *
   * The microtasks queue is drained at the very start of this function and after any timer callback
   * has been executed.
   *
   * \@usageNotes
   * ### Example
   *
   * {\@example core/testing/ts/fake_async.ts region='basic'}
   *
   * \@publicApi
   * @param {?=} millis
   * @return {?}
   */
  function tick(millis = 0) {
      if (fakeAsyncTestModule) {
          return fakeAsyncTestModule.tick(millis);
      }
      else {
          return tickFallback(millis);
      }
  }
  /**
   * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by
   * draining the macrotask queue until it is empty. The returned value is the milliseconds
   * of time that would have been elapsed.
   *
   * \@publicApi
   * @param {?=} maxTurns
   * @return {?} The simulated time elapsed, in millis.
   *
   */
  function flush(maxTurns) {
      if (fakeAsyncTestModule) {
          return fakeAsyncTestModule.flush(maxTurns);
      }
      else {
          return flushFallback(maxTurns);
      }
  }
  /**
   * Discard all remaining periodic tasks.
   *
   * \@publicApi
   * @return {?}
   */
  function discardPeriodicTasks() {
      if (fakeAsyncTestModule) {
          return fakeAsyncTestModule.discardPeriodicTasks();
      }
      else {
          discardPeriodicTasksFallback();
      }
  }
  /**
   * Flush any pending microtasks.
   *
   * \@publicApi
   * @return {?}
   */
  function flushMicrotasks() {
      if (fakeAsyncTestModule) {
          return fakeAsyncTestModule.flushMicrotasks();
      }
      else {
          return flushMicrotasksFallback();
      }
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /**
   * @license
   * Copyright Google Inc. All Rights Reserved.
   *
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://angular.io/license
   */
  /**
   * Injectable completer that allows signaling completion of an asynchronous test. Used internally.
   */
  class AsyncTestCompleter {
      constructor() {
          this._promise = new Promise((res, rej) => {
              this._resolve = res;
              this._reject = rej;
          });
      }
      /**
       * @param {?=} value
       * @return {?}
       */
      done(value) { this._resolve(value); }
      /**
       * @param {?=} error
       * @param {?=} stackTrace
       * @return {?}
       */
      fail(error, stackTrace) { this._reject(error); }
      /**
       * @return {?}
       */
      get promise() { return this._promise; }
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /** @type {?} */
  let _nextReferenceId = 0;
  class MetadataOverrider {
      constructor() {
          this._references = new Map();
      }
      /**
       * Creates a new instance for the given metadata class
       * based on an old instance and overrides.
       * @template C, T
       * @param {?} metadataClass
       * @param {?} oldMetadata
       * @param {?} override
       * @return {?}
       */
      overrideMetadata(metadataClass, oldMetadata, override) {
          /** @type {?} */
          const props = {};
          if (oldMetadata) {
              _valueProps(oldMetadata).forEach((prop) => props[prop] = ((/** @type {?} */ (oldMetadata)))[prop]);
          }
          if (override.set) {
              if (override.remove || override.add) {
                  throw new Error(`Cannot set and add/remove ${ɵstringify(metadataClass)} at the same time!`);
              }
              setMetadata(props, override.set);
          }
          if (override.remove) {
              removeMetadata(props, override.remove, this._references);
          }
          if (override.add) {
              addMetadata(props, override.add);
          }
          return new metadataClass((/** @type {?} */ (props)));
      }
  }
  /**
   * @param {?} metadata
   * @param {?} remove
   * @param {?} references
   * @return {?}
   */
  function removeMetadata(metadata, remove, references) {
      /** @type {?} */
      const removeObjects = new Set();
      for (const prop in remove) {
          /** @type {?} */
          const removeValue = remove[prop];
          if (removeValue instanceof Array) {
              removeValue.forEach((value) => { removeObjects.add(_propHashKey(prop, value, references)); });
          }
          else {
              removeObjects.add(_propHashKey(prop, removeValue, references));
          }
      }
      for (const prop in metadata) {
          /** @type {?} */
          const propValue = metadata[prop];
          if (propValue instanceof Array) {
              metadata[prop] = propValue.filter((value) => !removeObjects.has(_propHashKey(prop, value, references)));
          }
          else {
              if (removeObjects.has(_propHashKey(prop, propValue, references))) {
                  metadata[prop] = undefined;
              }
          }
      }
  }
  /**
   * @param {?} metadata
   * @param {?} add
   * @return {?}
   */
  function addMetadata(metadata, add) {
      for (const prop in add) {
          /** @type {?} */
          const addValue = add[prop];
          /** @type {?} */
          const propValue = metadata[prop];
          if (propValue != null && propValue instanceof Array) {
              metadata[prop] = propValue.concat(addValue);
          }
          else {
              metadata[prop] = addValue;
          }
      }
  }
  /**
   * @param {?} metadata
   * @param {?} set
   * @return {?}
   */
  function setMetadata(metadata, set) {
      for (const prop in set) {
          metadata[prop] = set[prop];
      }
  }
  /**
   * @param {?} propName
   * @param {?} propValue
   * @param {?} references
   * @return {?}
   */
  function _propHashKey(propName, propValue, references) {
      /** @type {?} */
      const replacer = (key, value) => {
          if (typeof value === 'function') {
              value = _serializeReference(value, references);
          }
          return value;
      };
      return `${propName}:${JSON.stringify(propValue, replacer)}`;
  }
  /**
   * @param {?} ref
   * @param {?} references
   * @return {?}
   */
  function _serializeReference(ref, references) {
      /** @type {?} */
      let id = references.get(ref);
      if (!id) {
          id = `${ɵstringify(ref)}${_nextReferenceId++}`;
          references.set(ref, id);
      }
      return id;
  }
  /**
   * @param {?} obj
   * @return {?}
   */
  function _valueProps(obj) {
      /** @type {?} */
      const props = [];
      // regular public props
      Object.keys(obj).forEach((prop) => {
          if (!prop.startsWith('_')) {
              props.push(prop);
          }
      });
      // getters
      /** @type {?} */
      let proto = obj;
      while (proto = Object.getPrototypeOf(proto)) {
          Object.keys(proto).forEach((protoProp) => {
              /** @type {?} */
              const desc = Object.getOwnPropertyDescriptor(proto, protoProp);
              if (!protoProp.startsWith('_') && desc && 'get' in desc) {
                  props.push(protoProp);
              }
          });
      }
      return props;
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /** @type {?} */
  const reflection = new ɵReflectionCapabilities();
  /**
   * Allows to override ivy metadata for tests (via the `TestBed`).
   * @abstract
   * @template T
   */
  class OverrideResolver {
      constructor() {
          this.overrides = new Map();
          this.resolved = new Map();
      }
      /**
       * @param {?} overrides
       * @return {?}
       */
      setOverrides(overrides) {
          this.overrides.clear();
          overrides.forEach(([type, override]) => {
              /** @type {?} */
              const overrides = this.overrides.get(type) || [];
              overrides.push(override);
              this.overrides.set(type, overrides);
          });
      }
      /**
       * @param {?} type
       * @return {?}
       */
      getAnnotation(type) {
          return reflection.annotations(type).find(a => a instanceof this.type) || null;
      }
      /**
       * @param {?} type
       * @return {?}
       */
      resolve(type) {
          /** @type {?} */
          let resolved = this.resolved.get(type) || null;
          if (!resolved) {
              resolved = this.getAnnotation(type);
              if (resolved) {
                  /** @type {?} */
                  const overrides = this.overrides.get(type);
                  if (overrides) {
                      /** @type {?} */
                      const overrider = new MetadataOverrider();
                      overrides.forEach(override => {
                          resolved = overrider.overrideMetadata(this.type, (/** @type {?} */ (resolved)), override);
                      });
                  }
              }
              this.resolved.set(type, resolved);
          }
          return resolved;
      }
  }
  class DirectiveResolver extends OverrideResolver {
      /**
       * @return {?}
       */
      get type() { return Directive; }
  }
  class ComponentResolver extends OverrideResolver {
      /**
       * @return {?}
       */
      get type() { return Component; }
  }
  class PipeResolver extends OverrideResolver {
      /**
       * @return {?}
       */
      get type() { return Pipe; }
  }
  class NgModuleResolver extends OverrideResolver {
      /**
       * @return {?}
       */
      get type() { return NgModule; }
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /**
   * An abstract class for inserting the root test component element in a platform independent way.
   *
   * \@publicApi
   */
  class TestComponentRenderer {
      /**
       * @param {?} rootElementId
       * @return {?}
       */
      insertRootElement(rootElementId) { }
  }
  /**
   * \@publicApi
   * @type {?}
   */
  const ComponentFixtureAutoDetect = new InjectionToken('ComponentFixtureAutoDetect');
  /**
   * \@publicApi
   * @type {?}
   */
  const ComponentFixtureNoNgZone = new InjectionToken('ComponentFixtureNoNgZone');
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /** @type {?} */
  let _nextRootElementId = 0;
  /** @type {?} */
  const EMPTY_ARRAY = [];
  /**
   * \@description
   * Configures and initializes environment for unit testing and provides methods for
   * creating components and services in unit tests.
   *
   * TestBed is the primary api for writing unit tests for Angular applications and libraries.
   *
   * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
   * according to the compiler used.
   */
  class TestBedRender3 {
      constructor() {
          // Properties
          this.platform = (/** @type {?} */ (null));
          this.ngModule = (/** @type {?} */ (null));
          // metadata overrides
          this._moduleOverrides = [];
          this._componentOverrides = [];
          this._directiveOverrides = [];
          this._pipeOverrides = [];
          this._providerOverrides = [];
          this._rootProviderOverrides = [];
          this._providerOverridesByToken = new Map();
          this._templateOverrides = new Map();
          // test module configuration
          this._providers = [];
          this._declarations = [];
          this._imports = [];
          this._schemas = [];
          this._activeFixtures = [];
          this._moduleRef = (/** @type {?} */ (null));
          this._testModuleType = (/** @type {?} */ (null));
          this._instantiated = false;
      }
      /**
       * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
       * angular module. These are common to every test in the suite.
       *
       * This may only be called once, to set up the common providers for the current test
       * suite on the current platform. If you absolutely need to change the providers,
       * first use `resetTestEnvironment`.
       *
       * Test modules and platforms for individual platforms are available from
       * '\@angular/<platform_name>/testing'.
       *
       * \@publicApi
       * @param {?} ngModule
       * @param {?} platform
       * @param {?=} aotSummaries
       * @return {?}
       */
      static initTestEnvironment(ngModule, platform, aotSummaries) {
          /** @type {?} */
          const testBed = _getTestBedRender3();
          testBed.initTestEnvironment(ngModule, platform, aotSummaries);
          return testBed;
      }
      /**
       * Reset the providers for the test injector.
       *
       * \@publicApi
       * @return {?}
       */
      static resetTestEnvironment() { _getTestBedRender3().resetTestEnvironment(); }
      /**
       * @param {?} config
       * @return {?}
       */
      static configureCompiler(config) {
          _getTestBedRender3().configureCompiler(config);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedRender3))));
      }
      /**
       * Allows overriding default providers, directives, pipes, modules of the test injector,
       * which are defined in test_injector.js
       * @param {?} moduleDef
       * @return {?}
       */
      static configureTestingModule(moduleDef) {
          _getTestBedRender3().configureTestingModule(moduleDef);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedRender3))));
      }
      /**
       * Compile components with a `templateUrl` for the test's NgModule.
       * It is necessary to call this function
       * as fetching urls is asynchronous.
       * @return {?}
       */
      static compileComponents() { return _getTestBedRender3().compileComponents(); }
      /**
       * @param {?} ngModule
       * @param {?} override
       * @return {?}
       */
      static overrideModule(ngModule, override) {
          _getTestBedRender3().overrideModule(ngModule, override);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedRender3))));
      }
      /**
       * @param {?} component
       * @param {?} override
       * @return {?}
       */
      static overrideComponent(component, override) {
          _getTestBedRender3().overrideComponent(component, override);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedRender3))));
      }
      /**
       * @param {?} directive
       * @param {?} override
       * @return {?}
       */
      static overrideDirective(directive, override) {
          _getTestBedRender3().overrideDirective(directive, override);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedRender3))));
      }
      /**
       * @param {?} pipe
       * @param {?} override
       * @return {?}
       */
      static overridePipe(pipe, override) {
          _getTestBedRender3().overridePipe(pipe, override);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedRender3))));
      }
      /**
       * @param {?} component
       * @param {?} template
       * @return {?}
       */
      static overrideTemplate(component, template) {
          _getTestBedRender3().overrideComponent(component, { set: { template, templateUrl: (/** @type {?} */ (null)) } });
          return (/** @type {?} */ ((/** @type {?} */ (TestBedRender3))));
      }
      /**
       * Overrides the template of the given component, compiling the template
       * in the context of the TestingModule.
       *
       * Note: This works for JIT and AOTed components as well.
       * @param {?} component
       * @param {?} template
       * @return {?}
       */
      static overrideTemplateUsingTestingModule(component, template) {
          _getTestBedRender3().overrideTemplateUsingTestingModule(component, template);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedRender3))));
      }
      /**
       * @param {?} component
       * @param {?} template
       * @return {?}
       */
      overrideTemplateUsingTestingModule(component, template) {
          if (this._instantiated) {
              throw new Error('Cannot override template when the test module has already been instantiated');
          }
          this._templateOverrides.set(component, template);
      }
      /**
       * @param {?} token
       * @param {?} provider
       * @return {?}
       */
      static overrideProvider(token, provider) {
          _getTestBedRender3().overrideProvider(token, provider);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedRender3))));
      }
      /**
       * @param {?} token
       * @param {?} provider
       * @return {?}
       */
      static deprecatedOverrideProvider(token, provider) {
          throw new Error('Render3TestBed.deprecatedOverrideProvider is not implemented');
      }
      /**
       * @param {?} token
       * @param {?=} notFoundValue
       * @return {?}
       */
      static get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
          return _getTestBedRender3().get(token, notFoundValue);
      }
      /**
       * @template T
       * @param {?} component
       * @return {?}
       */
      static createComponent(component) {
          return _getTestBedRender3().createComponent(component);
      }
      /**
       * @return {?}
       */
      static resetTestingModule() {
          _getTestBedRender3().resetTestingModule();
          return (/** @type {?} */ ((/** @type {?} */ (TestBedRender3))));
      }
      /**
       * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
       * angular module. These are common to every test in the suite.
       *
       * This may only be called once, to set up the common providers for the current test
       * suite on the current platform. If you absolutely need to change the providers,
       * first use `resetTestEnvironment`.
       *
       * Test modules and platforms for individual platforms are available from
       * '\@angular/<platform_name>/testing'.
       *
       * \@publicApi
       * @param {?} ngModule
       * @param {?} platform
       * @param {?=} aotSummaries
       * @return {?}
       */
      initTestEnvironment(ngModule, platform, aotSummaries) {
          if (this.platform || this.ngModule) {
              throw new Error('Cannot set base providers because it has already been called');
          }
          this.platform = platform;
          this.ngModule = ngModule;
      }
      /**
       * Reset the providers for the test injector.
       *
       * \@publicApi
       * @return {?}
       */
      resetTestEnvironment() {
          this.resetTestingModule();
          this.platform = (/** @type {?} */ (null));
          this.ngModule = (/** @type {?} */ (null));
      }
      /**
       * @return {?}
       */
      resetTestingModule() {
          ɵresetCompiledComponents();
          // reset metadata overrides
          this._moduleOverrides = [];
          this._componentOverrides = [];
          this._directiveOverrides = [];
          this._pipeOverrides = [];
          this._providerOverrides = [];
          this._rootProviderOverrides = [];
          this._providerOverridesByToken.clear();
          this._templateOverrides.clear();
          // reset test module config
          this._providers = [];
          this._declarations = [];
          this._imports = [];
          this._schemas = [];
          this._moduleRef = (/** @type {?} */ (null));
          this._testModuleType = (/** @type {?} */ (null));
          this._instantiated = false;
          this._activeFixtures.forEach((fixture) => {
              try {
                  fixture.destroy();
              }
              catch (e) {
                  console.error('Error during cleanup of component', {
                      component: fixture.componentInstance,
                      stacktrace: e,
                  });
              }
          });
          this._activeFixtures = [];
      }
      /**
       * @param {?} config
       * @return {?}
       */
      configureCompiler(config) {
          if (config.useJit != null) {
              throw new Error('the Render3 compiler JiT mode is not configurable !');
          }
          if (config.providers) {
              this._providerOverrides.push(...config.providers);
          }
      }
      /**
       * @param {?} moduleDef
       * @return {?}
       */
      configureTestingModule(moduleDef) {
          this._assertNotInstantiated('R3TestBed.configureTestingModule', 'configure the test module');
          if (moduleDef.providers) {
              this._providers.push(...moduleDef.providers);
          }
          if (moduleDef.declarations) {
              this._declarations.push(...moduleDef.declarations);
          }
          if (moduleDef.imports) {
              this._imports.push(...moduleDef.imports);
          }
          if (moduleDef.schemas) {
              this._schemas.push(...moduleDef.schemas);
          }
      }
      /**
       * @return {?}
       */
      compileComponents() {
          // assume for now that components don't use templateUrl / stylesUrl to unblock further testing
          // TODO(pk): plug into the ivy's resource fetching pipeline
          return Promise.resolve();
      }
      /**
       * @param {?} token
       * @param {?=} notFoundValue
       * @return {?}
       */
      get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
          this._initIfNeeded();
          if (token === TestBedRender3) {
              return this;
          }
          return this._moduleRef.injector.get(token, notFoundValue);
      }
      /**
       * @param {?} tokens
       * @param {?} fn
       * @param {?=} context
       * @return {?}
       */
      execute(tokens, fn, context) {
          this._initIfNeeded();
          /** @type {?} */
          const params = tokens.map(t => this.get(t));
          return fn.apply(context, params);
      }
      /**
       * @param {?} ngModule
       * @param {?} override
       * @return {?}
       */
      overrideModule(ngModule, override) {
          this._assertNotInstantiated('overrideModule', 'override module metadata');
          this._moduleOverrides.push([ngModule, override]);
      }
      /**
       * @param {?} component
       * @param {?} override
       * @return {?}
       */
      overrideComponent(component, override) {
          this._assertNotInstantiated('overrideComponent', 'override component metadata');
          this._componentOverrides.push([component, override]);
      }
      /**
       * @param {?} directive
       * @param {?} override
       * @return {?}
       */
      overrideDirective(directive, override) {
          this._assertNotInstantiated('overrideDirective', 'override directive metadata');
          this._directiveOverrides.push([directive, override]);
      }
      /**
       * @param {?} pipe
       * @param {?} override
       * @return {?}
       */
      overridePipe(pipe, override) {
          this._assertNotInstantiated('overridePipe', 'override pipe metadata');
          this._pipeOverrides.push([pipe, override]);
      }
      /**
       * Overwrites all providers for the given token with the given provider definition.
       * @param {?} token
       * @param {?} provider
       * @return {?}
       */
      overrideProvider(token, provider) {
          /** @type {?} */
          const providerDef = provider.useFactory ?
              { provide: token, useFactory: provider.useFactory, deps: provider.deps || [] } :
              { provide: token, useValue: provider.useValue };
          /** @type {?} */
          let injectableDef;
          /** @type {?} */
          const isRoot = (typeof token !== 'string' && (injectableDef = ɵgetInjectableDef(token)) &&
              injectableDef.providedIn === 'root');
          /** @type {?} */
          const overridesBucket = isRoot ? this._rootProviderOverrides : this._providerOverrides;
          overridesBucket.push(providerDef);
          // keep all overrides grouped by token as well for fast lookups using token
          /** @type {?} */
          const overridesForToken = this._providerOverridesByToken.get(token) || [];
          overridesForToken.push(providerDef);
          this._providerOverridesByToken.set(token, overridesForToken);
      }
      /**
       * @param {?} token
       * @param {?} provider
       * @return {?}
       */
      deprecatedOverrideProvider(token, provider) {
          throw new Error('No implemented in IVY');
      }
      /**
       * @template T
       * @param {?} type
       * @return {?}
       */
      createComponent(type) {
          this._initIfNeeded();
          /** @type {?} */
          const testComponentRenderer = this.get(TestComponentRenderer);
          /** @type {?} */
          const rootElId = `root${_nextRootElementId++}`;
          testComponentRenderer.insertRootElement(rootElId);
          /** @nocollapse @type {?} */
          const componentDef = ((/** @type {?} */ (type))).ngComponentDef;
          if (!componentDef) {
              throw new Error(`It looks like '${ɵstringify(type)}' has not been IVY compiled - it has no 'ngComponentDef' field`);
          }
          /** @type {?} */
          const noNgZone = this.get(ComponentFixtureNoNgZone, false);
          /** @type {?} */
          const autoDetect = this.get(ComponentFixtureAutoDetect, false);
          /** @type {?} */
          const ngZone = noNgZone ? null : this.get(NgZone, null);
          /** @type {?} */
          const componentFactory = new ɵRender3ComponentFactory(componentDef);
          /** @type {?} */
          const initComponent = () => {
              /** @type {?} */
              const componentRef = componentFactory.create(Injector.NULL, [], `#${rootElId}`, this._moduleRef);
              return new ComponentFixture(componentRef, ngZone, autoDetect);
          };
          /** @type {?} */
          const fixture = ngZone ? ngZone.run(initComponent) : initComponent();
          this._activeFixtures.push(fixture);
          return fixture;
      }
      // internal methods
      /**
       * @private
       * @return {?}
       */
      _initIfNeeded() {
          if (this._instantiated) {
              return;
          }
          /** @type {?} */
          const resolvers = this._getResolvers();
          this._testModuleType = this._createTestModule();
          this._compileNgModule(this._testModuleType, resolvers);
          /** @type {?} */
          const parentInjector = this.platform.injector;
          this._moduleRef = new ɵRender3NgModuleRef(this._testModuleType, parentInjector);
          // ApplicationInitStatus.runInitializers() is marked @internal
          // to core. Cast it to any before accessing it.
          ((/** @type {?} */ (this._moduleRef.injector.get(ApplicationInitStatus)))).runInitializers();
          this._instantiated = true;
      }
      // get overrides for a specific provider (if any)
      /**
       * @private
       * @param {?} provider
       * @return {?}
       */
      _getProviderOverrides(provider) {
          /** @type {?} */
          const token = typeof provider === 'object' && provider.hasOwnProperty('provide') ?
              provider.provide :
              provider;
          return this._providerOverridesByToken.get(token) || [];
      }
      // creates resolvers taking overrides into account
      /**
       * @private
       * @return {?}
       */
      _getResolvers() {
          /** @type {?} */
          const module = new NgModuleResolver();
          module.setOverrides(this._moduleOverrides);
          /** @type {?} */
          const component = new ComponentResolver();
          component.setOverrides(this._componentOverrides);
          /** @type {?} */
          const directive = new DirectiveResolver();
          directive.setOverrides(this._directiveOverrides);
          /** @type {?} */
          const pipe = new PipeResolver();
          pipe.setOverrides(this._pipeOverrides);
          return { module, component, directive, pipe };
      }
      /**
       * @private
       * @param {?} methodName
       * @param {?} methodDescription
       * @return {?}
       */
      _assertNotInstantiated(methodName, methodDescription) {
          if (this._instantiated) {
              throw new Error(`Cannot ${methodDescription} when the test module has already been instantiated. ` +
                  `Make sure you are not using \`inject\` before \`${methodName}\`.`);
          }
      }
      /**
       * @private
       * @return {?}
       */
      _createTestModule() {
          /** @type {?} */
          const rootProviderOverrides = this._rootProviderOverrides;
          class RootScopeModule {
          }
          RootScopeModule.decorators = [
              { type: NgModule, args: [{
                          providers: [...rootProviderOverrides],
                          jit: true,
                      },] },
          ];
          /** @type {?} */
          const ngZone = new NgZone({ enableLongStackTrace: true });
          /** @type {?} */
          const providers = [{ provide: NgZone, useValue: ngZone }, ...this._providers, ...this._providerOverrides];
          /** @type {?} */
          const declarations = this._declarations;
          /** @type {?} */
          const imports = [RootScopeModule, this.ngModule, this._imports];
          /** @type {?} */
          const schemas = this._schemas;
          class DynamicTestModule {
          }
          DynamicTestModule.decorators = [
              { type: NgModule, args: [{ providers, declarations, imports, schemas, jit: true },] },
          ];
          return (/** @type {?} */ (DynamicTestModule));
      }
      /**
       * @private
       * @param {?} meta
       * @param {?=} type
       * @return {?}
       */
      _getMetaWithOverrides(meta, type) {
          /** @type {?} */
          const overrides = {};
          if (meta.providers && meta.providers.length) {
              /** @type {?} */
              const providerOverrides = flatten(meta.providers, (provider) => this._getProviderOverrides(provider));
              if (providerOverrides.length) {
                  overrides.providers = [...meta.providers, ...providerOverrides];
              }
          }
          /** @type {?} */
          const hasTemplateOverride = !!type && this._templateOverrides.has(type);
          if (hasTemplateOverride) {
              overrides.template = this._templateOverrides.get((/** @type {?} */ (type)));
          }
          return Object.keys(overrides).length ? Object.assign({}, meta, overrides) : meta;
      }
      /**
       * @private
       * @param {?} moduleType
       * @param {?} resolvers
       * @return {?}
       */
      _compileNgModule(moduleType, resolvers) {
          /** @type {?} */
          const ngModule = resolvers.module.resolve(moduleType);
          if (ngModule === null) {
              throw new Error(`${ɵstringify(moduleType)} has not @NgModule annotation`);
          }
          /** @type {?} */
          const metadata = this._getMetaWithOverrides(ngModule);
          ɵcompileNgModuleDefs(moduleType, metadata);
          /** @type {?} */
          const declarations = flatten(ngModule.declarations || EMPTY_ARRAY, resolveForwardRef);
          /** @type {?} */
          const compiledComponents = [];
          // Compile the components, directives and pipes declared by this module
          declarations.forEach(declaration => {
              /** @type {?} */
              const component = resolvers.component.resolve(declaration);
              if (component) {
                  /** @type {?} */
                  const metadata = this._getMetaWithOverrides(component, declaration);
                  ɵcompileComponent(declaration, metadata);
                  compiledComponents.push(declaration);
                  return;
              }
              /** @type {?} */
              const directive = resolvers.directive.resolve(declaration);
              if (directive) {
                  /** @type {?} */
                  const metadata = this._getMetaWithOverrides(directive);
                  ɵcompileDirective(declaration, metadata);
                  return;
              }
              /** @type {?} */
              const pipe = resolvers.pipe.resolve(declaration);
              if (pipe) {
                  ɵcompilePipe(declaration, pipe);
                  return;
              }
          });
          // Compile transitive modules, components, directives and pipes
          /** @type {?} */
          const transitiveScope = this._transitiveScopesFor(moduleType, resolvers);
          compiledComponents.forEach(cmp => {
              /** @type {?} */
              const scope = this._templateOverrides.has(cmp) ?
                  // if we have template override via `TestBed.overrideTemplateUsingTestingModule` -
                  // define Component scope as TestingModule scope, instead of the scope of NgModule
                  // where this Component was declared
                  this._transitiveScopesFor(this._testModuleType, resolvers) :
                  transitiveScope;
              ɵpatchComponentDefWithScope(((/** @type {?} */ (cmp))).ngComponentDef, scope);
          });
      }
      /**
       * Compute the pair of transitive scopes (compilation scope and exported scope) for a given
       * module.
       *
       * This operation is memoized and the result is cached on the module's definition. It can be
       * called on modules with components that have not fully compiled yet, but the result should not
       * be used until they have.
       * @private
       * @template T
       * @param {?} moduleType
       * @param {?} resolvers
       * @return {?}
       */
      _transitiveScopesFor(moduleType, resolvers) {
          if (!isNgModule(moduleType)) {
              throw new Error(`${moduleType.name} does not have an ngModuleDef`);
          }
          /** @nocollapse @type {?} */
          const def = moduleType.ngModuleDef;
          if (def.transitiveCompileScopes !== null) {
              return def.transitiveCompileScopes;
          }
          /** @type {?} */
          const scopes = {
              compilation: {
                  directives: new Set(),
                  pipes: new Set(),
              },
              exported: {
                  directives: new Set(),
                  pipes: new Set(),
              },
          };
          def.declarations.forEach(declared => {
              /** @type {?} */
              const declaredWithDefs = (/** @type {?} */ (declared));
              if (declaredWithDefs.ngPipeDef !== undefined) {
                  scopes.compilation.pipes.add(declared);
              }
              else {
                  scopes.compilation.directives.add(declared);
              }
          });
          def.imports.forEach((imported) => {
              /** @type {?} */
              const ngModule = resolvers.module.resolve(imported);
              if (ngModule === null) {
                  throw new Error(`Importing ${imported.name} which does not have an @ngModule`);
              }
              else {
                  this._compileNgModule(imported, resolvers);
              }
              // When this module imports another, the imported module's exported directives and pipes are
              // added to the compilation scope of this module.
              /** @type {?} */
              const importedScope = this._transitiveScopesFor(imported, resolvers);
              importedScope.exported.directives.forEach(entry => scopes.compilation.directives.add(entry));
              importedScope.exported.pipes.forEach(entry => scopes.compilation.pipes.add(entry));
          });
          def.exports.forEach((exported) => {
              /** @type {?} */
              const exportedTyped = (/** @type {?} */ (exported));
              // Either the type is a module, a pipe, or a component/directive (which may not have an
              // ngComponentDef as it might be compiled asynchronously).
              if (isNgModule(exportedTyped)) {
                  // When this module exports another, the exported module's exported directives and pipes are
                  // added to both the compilation and exported scopes of this module.
                  /** @type {?} */
                  const exportedScope = this._transitiveScopesFor(exportedTyped, resolvers);
                  exportedScope.exported.directives.forEach(entry => {
                      scopes.compilation.directives.add(entry);
                      scopes.exported.directives.add(entry);
                  });
                  exportedScope.exported.pipes.forEach(entry => {
                      scopes.compilation.pipes.add(entry);
                      scopes.exported.pipes.add(entry);
                  });
              }
              else if (exportedTyped.ngPipeDef !== undefined) {
                  scopes.exported.pipes.add(exportedTyped);
              }
              else {
                  scopes.exported.directives.add(exportedTyped);
              }
          });
          def.transitiveCompileScopes = scopes;
          return scopes;
      }
  }
  /** @type {?} */
  let testBed;
  /**
   * @return {?}
   */
  function _getTestBedRender3() {
      return testBed = testBed || new TestBedRender3();
  }
  /**
   * @template T
   * @param {?} values
   * @param {?=} mapFn
   * @return {?}
   */
  function flatten(values, mapFn) {
      /** @type {?} */
      const out = [];
      values.forEach(value => {
          if (Array.isArray(value)) {
              out.push(...flatten(value, mapFn));
          }
          else {
              out.push(mapFn ? mapFn(value) : value);
          }
      });
      return out;
  }
  /**
   * @template T
   * @param {?} value
   * @return {?}
   */
  function isNgModule(value) {
      return ((/** @type {?} */ (value))).ngModuleDef !== undefined;
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /**
   * @return {?}
   */
  function unimplemented() {
      throw Error('unimplemented');
  }
  /**
   * Special interface to the compiler only used by testing
   *
   * \@publicApi
   */
  class TestingCompiler extends Compiler {
      /**
       * @return {?}
       */
      get injector() { throw unimplemented(); }
      /**
       * @param {?} module
       * @param {?} overrides
       * @return {?}
       */
      overrideModule(module, overrides) {
          throw unimplemented();
      }
      /**
       * @param {?} directive
       * @param {?} overrides
       * @return {?}
       */
      overrideDirective(directive, overrides) {
          throw unimplemented();
      }
      /**
       * @param {?} component
       * @param {?} overrides
       * @return {?}
       */
      overrideComponent(component, overrides) {
          throw unimplemented();
      }
      /**
       * @param {?} directive
       * @param {?} overrides
       * @return {?}
       */
      overridePipe(directive, overrides) {
          throw unimplemented();
      }
      /**
       * Allows to pass the compile summary from AOT compilation to the JIT compiler,
       * so that it can use the code generated by AOT.
       * @param {?} summaries
       * @return {?}
       */
      loadAotSummaries(summaries) { throw unimplemented(); }
      /**
       * Gets the component factory for the given component.
       * This assumes that the component has been compiled before calling this call using
       * `compileModuleAndAllComponents*`.
       * @template T
       * @param {?} component
       * @return {?}
       */
      getComponentFactory(component) { throw unimplemented(); }
      /**
       * Returns the component type that is stored in the given error.
       * This can be used for errors created by compileModule...
       * @param {?} error
       * @return {?}
       */
      getComponentFromError(error) { throw unimplemented(); }
  }
  TestingCompiler.decorators = [
      { type: Injectable }
  ];
  /**
   * A factory for creating a Compiler
   *
   * \@publicApi
   * @abstract
   */
  class TestingCompilerFactory {
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /** @type {?} */
  const UNDEFINED = new Object();
  /** @type {?} */
  let _nextRootElementId$1 = 0;
  // WARNING: interface has both a type and a value, skipping emit
  /**
   * \@description
   * Configures and initializes environment for unit testing and provides methods for
   * creating components and services in unit tests.
   *
   * `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
   *
   * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
   * according to the compiler used.
   */
  class TestBedViewEngine {
      constructor() {
          this._instantiated = false;
          this._compiler = (/** @type {?} */ (null));
          this._moduleRef = (/** @type {?} */ (null));
          this._moduleFactory = (/** @type {?} */ (null));
          this._compilerOptions = [];
          this._moduleOverrides = [];
          this._componentOverrides = [];
          this._directiveOverrides = [];
          this._pipeOverrides = [];
          this._providers = [];
          this._declarations = [];
          this._imports = [];
          this._schemas = [];
          this._activeFixtures = [];
          this._testEnvAotSummaries = () => [];
          this._aotSummaries = [];
          this._templateOverrides = [];
          this._isRoot = true;
          this._rootProviderOverrides = [];
          this.platform = (/** @type {?} */ (null));
          this.ngModule = (/** @type {?} */ (null));
      }
      /**
       * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
       * angular module. These are common to every test in the suite.
       *
       * This may only be called once, to set up the common providers for the current test
       * suite on the current platform. If you absolutely need to change the providers,
       * first use `resetTestEnvironment`.
       *
       * Test modules and platforms for individual platforms are available from
       * '\@angular/<platform_name>/testing'.
       * @param {?} ngModule
       * @param {?} platform
       * @param {?=} aotSummaries
       * @return {?}
       */
      static initTestEnvironment(ngModule, platform, aotSummaries) {
          /** @type {?} */
          const testBed = _getTestBedViewEngine();
          testBed.initTestEnvironment(ngModule, platform, aotSummaries);
          return testBed;
      }
      /**
       * Reset the providers for the test injector.
       * @return {?}
       */
      static resetTestEnvironment() { _getTestBedViewEngine().resetTestEnvironment(); }
      /**
       * @return {?}
       */
      static resetTestingModule() {
          _getTestBedViewEngine().resetTestingModule();
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * Allows overriding default compiler providers and settings
       * which are defined in test_injector.js
       * @param {?} config
       * @return {?}
       */
      static configureCompiler(config) {
          _getTestBedViewEngine().configureCompiler(config);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * Allows overriding default providers, directives, pipes, modules of the test injector,
       * which are defined in test_injector.js
       * @param {?} moduleDef
       * @return {?}
       */
      static configureTestingModule(moduleDef) {
          _getTestBedViewEngine().configureTestingModule(moduleDef);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * Compile components with a `templateUrl` for the test's NgModule.
       * It is necessary to call this function
       * as fetching urls is asynchronous.
       * @return {?}
       */
      static compileComponents() { return getTestBed().compileComponents(); }
      /**
       * @param {?} ngModule
       * @param {?} override
       * @return {?}
       */
      static overrideModule(ngModule, override) {
          _getTestBedViewEngine().overrideModule(ngModule, override);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * @param {?} component
       * @param {?} override
       * @return {?}
       */
      static overrideComponent(component, override) {
          _getTestBedViewEngine().overrideComponent(component, override);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * @param {?} directive
       * @param {?} override
       * @return {?}
       */
      static overrideDirective(directive, override) {
          _getTestBedViewEngine().overrideDirective(directive, override);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * @param {?} pipe
       * @param {?} override
       * @return {?}
       */
      static overridePipe(pipe, override) {
          _getTestBedViewEngine().overridePipe(pipe, override);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * @param {?} component
       * @param {?} template
       * @return {?}
       */
      static overrideTemplate(component, template) {
          _getTestBedViewEngine().overrideComponent(component, { set: { template, templateUrl: (/** @type {?} */ (null)) } });
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * Overrides the template of the given component, compiling the template
       * in the context of the TestingModule.
       *
       * Note: This works for JIT and AOTed components as well.
       * @param {?} component
       * @param {?} template
       * @return {?}
       */
      static overrideTemplateUsingTestingModule(component, template) {
          _getTestBedViewEngine().overrideTemplateUsingTestingModule(component, template);
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * @param {?} token
       * @param {?} provider
       * @return {?}
       */
      static overrideProvider(token, provider) {
          _getTestBedViewEngine().overrideProvider(token, (/** @type {?} */ (provider)));
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * @param {?} token
       * @param {?} provider
       * @return {?}
       */
      static deprecatedOverrideProvider(token, provider) {
          _getTestBedViewEngine().deprecatedOverrideProvider(token, (/** @type {?} */ (provider)));
          return (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
      }
      /**
       * @param {?} token
       * @param {?=} notFoundValue
       * @return {?}
       */
      static get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
          return _getTestBedViewEngine().get(token, notFoundValue);
      }
      /**
       * @template T
       * @param {?} component
       * @return {?}
       */
      static createComponent(component) {
          return _getTestBedViewEngine().createComponent(component);
      }
      /**
       * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
       * angular module. These are common to every test in the suite.
       *
       * This may only be called once, to set up the common providers for the current test
       * suite on the current platform. If you absolutely need to change the providers,
       * first use `resetTestEnvironment`.
       *
       * Test modules and platforms for individual platforms are available from
       * '\@angular/<platform_name>/testing'.
       * @param {?} ngModule
       * @param {?} platform
       * @param {?=} aotSummaries
       * @return {?}
       */
      initTestEnvironment(ngModule, platform, aotSummaries) {
          if (this.platform || this.ngModule) {
              throw new Error('Cannot set base providers because it has already been called');
          }
          this.platform = platform;
          this.ngModule = ngModule;
          if (aotSummaries) {
              this._testEnvAotSummaries = aotSummaries;
          }
      }
      /**
       * Reset the providers for the test injector.
       * @return {?}
       */
      resetTestEnvironment() {
          this.resetTestingModule();
          this.platform = (/** @type {?} */ (null));
          this.ngModule = (/** @type {?} */ (null));
          this._testEnvAotSummaries = () => [];
      }
      /**
       * @return {?}
       */
      resetTestingModule() {
          ɵclearOverrides();
          this._aotSummaries = [];
          this._templateOverrides = [];
          this._compiler = (/** @type {?} */ (null));
          this._moduleOverrides = [];
          this._componentOverrides = [];
          this._directiveOverrides = [];
          this._pipeOverrides = [];
          this._isRoot = true;
          this._rootProviderOverrides = [];
          this._moduleRef = (/** @type {?} */ (null));
          this._moduleFactory = (/** @type {?} */ (null));
          this._compilerOptions = [];
          this._providers = [];
          this._declarations = [];
          this._imports = [];
          this._schemas = [];
          this._instantiated = false;
          this._activeFixtures.forEach((fixture) => {
              try {
                  fixture.destroy();
              }
              catch (e) {
                  console.error('Error during cleanup of component', {
                      component: fixture.componentInstance,
                      stacktrace: e,
                  });
              }
          });
          this._activeFixtures = [];
      }
      /**
       * @param {?} config
       * @return {?}
       */
      configureCompiler(config) {
          this._assertNotInstantiated('TestBed.configureCompiler', 'configure the compiler');
          this._compilerOptions.push(config);
      }
      /**
       * @param {?} moduleDef
       * @return {?}
       */
      configureTestingModule(moduleDef) {
          this._assertNotInstantiated('TestBed.configureTestingModule', 'configure the test module');
          if (moduleDef.providers) {
              this._providers.push(...moduleDef.providers);
          }
          if (moduleDef.declarations) {
              this._declarations.push(...moduleDef.declarations);
          }
          if (moduleDef.imports) {
              this._imports.push(...moduleDef.imports);
          }
          if (moduleDef.schemas) {
              this._schemas.push(...moduleDef.schemas);
          }
          if (moduleDef.aotSummaries) {
              this._aotSummaries.push(moduleDef.aotSummaries);
          }
      }
      /**
       * @return {?}
       */
      compileComponents() {
          if (this._moduleFactory || this._instantiated) {
              return Promise.resolve(null);
          }
          /** @type {?} */
          const moduleType = this._createCompilerAndModule();
          return this._compiler.compileModuleAndAllComponentsAsync(moduleType)
              .then((moduleAndComponentFactories) => {
              this._moduleFactory = moduleAndComponentFactories.ngModuleFactory;
          });
      }
      /**
       * @private
       * @return {?}
       */
      _initIfNeeded() {
          if (this._instantiated) {
              return;
          }
          if (!this._moduleFactory) {
              try {
                  /** @type {?} */
                  const moduleType = this._createCompilerAndModule();
                  this._moduleFactory =
                      this._compiler.compileModuleAndAllComponentsSync(moduleType).ngModuleFactory;
              }
              catch (e) {
                  /** @type {?} */
                  const errorCompType = this._compiler.getComponentFromError(e);
                  if (errorCompType) {
                      throw new Error(`This test module uses the component ${ɵstringify(errorCompType)} which is using a "templateUrl" or "styleUrls", but they were never compiled. ` +
                          `Please call "TestBed.compileComponents" before your test.`);
                  }
                  else {
                      throw e;
                  }
              }
          }
          for (const { component, templateOf } of this._templateOverrides) {
              /** @type {?} */
              const compFactory = this._compiler.getComponentFactory(templateOf);
              ɵoverrideComponentView(component, compFactory);
          }
          /** @type {?} */
          const ngZone = new NgZone({ enableLongStackTrace: true });
          /** @type {?} */
          const providers = [{ provide: NgZone, useValue: ngZone }];
          /** @type {?} */
          const ngZoneInjector = Injector.create({
              providers: providers,
              parent: this.platform.injector,
              name: this._moduleFactory.moduleType.name
          });
          this._moduleRef = this._moduleFactory.create(ngZoneInjector);
          // ApplicationInitStatus.runInitializers() is marked @internal to core. So casting to any
          // before accessing it.
          ((/** @type {?} */ (this._moduleRef.injector.get(ApplicationInitStatus)))).runInitializers();
          this._instantiated = true;
      }
      /**
       * @private
       * @return {?}
       */
      _createCompilerAndModule() {
          /** @type {?} */
          const providers = this._providers.concat([{ provide: TestBed, useValue: this }]);
          /** @type {?} */
          const declarations = [...this._declarations, ...this._templateOverrides.map(entry => entry.templateOf)];
          /** @type {?} */
          const rootScopeImports = [];
          /** @type {?} */
          const rootProviderOverrides = this._rootProviderOverrides;
          if (this._isRoot) {
              class RootScopeModule {
              }
              RootScopeModule.decorators = [
                  { type: NgModule, args: [{
                              providers: [
                                  ...rootProviderOverrides,
                              ],
                              jit: true,
                          },] },
              ];
              rootScopeImports.push(RootScopeModule);
          }
          providers.push({ provide: ɵAPP_ROOT, useValue: this._isRoot });
          /** @type {?} */
          const imports = [rootScopeImports, this.ngModule, this._imports];
          /** @type {?} */
          const schemas = this._schemas;
          class DynamicTestModule {
          }
          DynamicTestModule.decorators = [
              { type: NgModule, args: [{ providers, declarations, imports, schemas, jit: true },] },
          ];
          /** @type {?} */
          const compilerFactory = this.platform.injector.get(TestingCompilerFactory);
          this._compiler = compilerFactory.createTestingCompiler(this._compilerOptions);
          for (const summary of [this._testEnvAotSummaries, ...this._aotSummaries]) {
              this._compiler.loadAotSummaries(summary);
          }
          this._moduleOverrides.forEach((entry) => this._compiler.overrideModule(entry[0], entry[1]));
          this._componentOverrides.forEach((entry) => this._compiler.overrideComponent(entry[0], entry[1]));
          this._directiveOverrides.forEach((entry) => this._compiler.overrideDirective(entry[0], entry[1]));
          this._pipeOverrides.forEach((entry) => this._compiler.overridePipe(entry[0], entry[1]));
          return DynamicTestModule;
      }
      /**
       * @private
       * @param {?} methodName
       * @param {?} methodDescription
       * @return {?}
       */
      _assertNotInstantiated(methodName, methodDescription) {
          if (this._instantiated) {
              throw new Error(`Cannot ${methodDescription} when the test module has already been instantiated. ` +
                  `Make sure you are not using \`inject\` before \`${methodName}\`.`);
          }
      }
      /**
       * @param {?} token
       * @param {?=} notFoundValue
       * @return {?}
       */
      get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
          this._initIfNeeded();
          if (token === TestBed) {
              return this;
          }
          // Tests can inject things from the ng module and from the compiler,
          // but the ng module can't inject things from the compiler and vice versa.
          /** @type {?} */
          const result = this._moduleRef.injector.get(token, UNDEFINED);
          return result === UNDEFINED ? this._compiler.injector.get(token, notFoundValue) : result;
      }
      /**
       * @param {?} tokens
       * @param {?} fn
       * @param {?=} context
       * @return {?}
       */
      execute(tokens, fn, context) {
          this._initIfNeeded();
          /** @type {?} */
          const params = tokens.map(t => this.get(t));
          return fn.apply(context, params);
      }
      /**
       * @param {?} ngModule
       * @param {?} override
       * @return {?}
       */
      overrideModule(ngModule, override) {
          this._assertNotInstantiated('overrideModule', 'override module metadata');
          this._moduleOverrides.push([ngModule, override]);
      }
      /**
       * @param {?} component
       * @param {?} override
       * @return {?}
       */
      overrideComponent(component, override) {
          this._assertNotInstantiated('overrideComponent', 'override component metadata');
          this._componentOverrides.push([component, override]);
      }
      /**
       * @param {?} directive
       * @param {?} override
       * @return {?}
       */
      overrideDirective(directive, override) {
          this._assertNotInstantiated('overrideDirective', 'override directive metadata');
          this._directiveOverrides.push([directive, override]);
      }
      /**
       * @param {?} pipe
       * @param {?} override
       * @return {?}
       */
      overridePipe(pipe, override) {
          this._assertNotInstantiated('overridePipe', 'override pipe metadata');
          this._pipeOverrides.push([pipe, override]);
      }
      /**
       * @param {?} token
       * @param {?} provider
       * @return {?}
       */
      overrideProvider(token, provider) {
          this.overrideProviderImpl(token, provider);
      }
      /**
       * @param {?} token
       * @param {?} provider
       * @return {?}
       */
      deprecatedOverrideProvider(token, provider) {
          this.overrideProviderImpl(token, provider, /* deprecated */ true);
      }
      /**
       * @private
       * @param {?} token
       * @param {?} provider
       * @param {?=} deprecated
       * @return {?}
       */
      overrideProviderImpl(token, provider, deprecated = false) {
          /** @type {?} */
          let def = null;
          if (typeof token !== 'string' && (def = ɵgetInjectableDef(token)) && def.providedIn === 'root') {
              if (provider.useFactory) {
                  this._rootProviderOverrides.push({ provide: token, useFactory: provider.useFactory, deps: provider.deps || [] });
              }
              else {
                  this._rootProviderOverrides.push({ provide: token, useValue: provider.useValue });
              }
          }
          /** @type {?} */
          let flags = 0;
          /** @type {?} */
          let value;
          if (provider.useFactory) {
              flags |= 1024 /* TypeFactoryProvider */;
              value = provider.useFactory;
          }
          else {
              flags |= 256 /* TypeValueProvider */;
              value = provider.useValue;
          }
          /** @type {?} */
          const deps = (provider.deps || []).map((dep) => {
              /** @type {?} */
              let depFlags = 0 /* None */;
              /** @type {?} */
              let depToken;
              if (Array.isArray(dep)) {
                  dep.forEach((entry) => {
                      if (entry instanceof Optional) {
                          depFlags |= 2 /* Optional */;
                      }
                      else if (entry instanceof SkipSelf) {
                          depFlags |= 1 /* SkipSelf */;
                      }
                      else {
                          depToken = entry;
                      }
                  });
              }
              else {
                  depToken = dep;
              }
              return [depFlags, depToken];
          });
          ɵoverrideProvider({ token, flags, deps, value, deprecatedBehavior: deprecated });
      }
      /**
       * @param {?} component
       * @param {?} template
       * @return {?}
       */
      overrideTemplateUsingTestingModule(component, template) {
          this._assertNotInstantiated('overrideTemplateUsingTestingModule', 'override template');
          class OverrideComponent {
          }
          OverrideComponent.decorators = [
              { type: Component, args: [{ selector: 'empty', template, jit: true },] },
          ];
          this._templateOverrides.push({ component, templateOf: OverrideComponent });
      }
      /**
       * @template T
       * @param {?} component
       * @return {?}
       */
      createComponent(component) {
          this._initIfNeeded();
          /** @type {?} */
          const componentFactory = this._compiler.getComponentFactory(component);
          if (!componentFactory) {
              throw new Error(`Cannot create the component ${ɵstringify(component)} as it was not imported into the testing module!`);
          }
          /** @type {?} */
          const noNgZone = this.get(ComponentFixtureNoNgZone, false);
          /** @type {?} */
          const autoDetect = this.get(ComponentFixtureAutoDetect, false);
          /** @type {?} */
          const ngZone = noNgZone ? null : this.get(NgZone, null);
          /** @type {?} */
          const testComponentRenderer = this.get(TestComponentRenderer);
          /** @type {?} */
          const rootElId = `root${_nextRootElementId$1++}`;
          testComponentRenderer.insertRootElement(rootElId);
          /** @type {?} */
          const initComponent = () => {
              /** @type {?} */
              const componentRef = componentFactory.create(Injector.NULL, [], `#${rootElId}`, this._moduleRef);
              return new ComponentFixture(componentRef, ngZone, autoDetect);
          };
          /** @type {?} */
          const fixture = !ngZone ? initComponent() : ngZone.run(initComponent);
          this._activeFixtures.push(fixture);
          return fixture;
      }
  }
  /**
   * \@description
   * Configures and initializes environment for unit testing and provides methods for
   * creating components and services in unit tests.
   *
   * `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
   *
   * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
   * according to the compiler used.
   *
   * \@publicApi
   * @type {?}
   */
  const TestBed = ɵivyEnabled ? (/** @type {?} */ ((/** @type {?} */ (TestBedRender3)))) : (/** @type {?} */ ((/** @type {?} */ (TestBedViewEngine))));
  /**
   * Returns a singleton of the applicable `TestBed`.
   *
   * It will be either an instance of `TestBedViewEngine` or `TestBedRender3`.
   *
   * \@publicApi
   * @type {?}
   */
  const getTestBed = ɵivyEnabled ? _getTestBedRender3 : _getTestBedViewEngine;
  /** @type {?} */
  let testBed$1;
  /**
   * @return {?}
   */
  function _getTestBedViewEngine() {
      return testBed$1 = testBed$1 || new TestBedViewEngine();
  }
  /**
   * Allows injecting dependencies in `beforeEach()` and `it()`.
   *
   * Example:
   *
   * ```
   * beforeEach(inject([Dependency, AClass], (dep, object) => {
   *   // some code that uses `dep` and `object`
   *   // ...
   * }));
   *
   * it('...', inject([AClass], (object) => {
   *   object.doSomething();
   *   expect(...);
   * })
   * ```
   *
   * Notes:
   * - inject is currently a function because of some Traceur limitation the syntax should
   * eventually
   *   becomes `it('...', \@Inject (object: AClass, async: AsyncTestCompleter) => { ... });`
   *
   * \@publicApi
   * @param {?} tokens
   * @param {?} fn
   * @return {?}
   */
  function inject(tokens, fn) {
      /** @type {?} */
      const testBed = getTestBed();
      if (tokens.indexOf(AsyncTestCompleter) >= 0) {
          // Not using an arrow function to preserve context passed from call site
          return function () {
              // Return an async test method that returns a Promise if AsyncTestCompleter is one of
              // the injected tokens.
              return testBed.compileComponents().then(() => {
                  /** @type {?} */
                  const completer = testBed.get(AsyncTestCompleter);
                  testBed.execute(tokens, fn, this);
                  return completer.promise;
              });
          };
      }
      else {
          // Not using an arrow function to preserve context passed from call site
          return function () { return testBed.execute(tokens, fn, this); };
      }
  }
  /**
   * \@publicApi
   */
  class InjectSetupWrapper {
      /**
       * @param {?} _moduleDef
       */
      constructor(_moduleDef) {
          this._moduleDef = _moduleDef;
      }
      /**
       * @private
       * @return {?}
       */
      _addModule() {
          /** @type {?} */
          const moduleDef = this._moduleDef();
          if (moduleDef) {
              getTestBed().configureTestingModule(moduleDef);
          }
      }
      /**
       * @param {?} tokens
       * @param {?} fn
       * @return {?}
       */
      inject(tokens, fn) {
          /** @type {?} */
          const self = this;
          // Not using an arrow function to preserve context passed from call site
          return function () {
              self._addModule();
              return inject(tokens, fn).call(this);
          };
      }
  }
  /**
   * @param {?} moduleDef
   * @param {?=} fn
   * @return {?}
   */
  function withModule(moduleDef, fn) {
      if (fn) {
          // Not using an arrow function to preserve context passed from call site
          return function () {
              /** @type {?} */
              const testBed = getTestBed();
              if (moduleDef) {
                  testBed.configureTestingModule(moduleDef);
              }
              return fn.apply(this);
          };
      }
      return new InjectSetupWrapper(() => moduleDef);
  }
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /** @type {?} */
  const _global$1 = (/** @type {?} */ ((typeof window === 'undefined' ? global : window)));
  // Reset the test providers and the fake async zone before each test.
  if (_global$1.beforeEach) {
      _global$1.beforeEach(() => {
          TestBed.resetTestingModule();
          resetFakeAsyncZone();
      });
  }
  // TODO(juliemr): remove this, only used because we need to export something to have compilation
  // work.
  /** @type {?} */
  const __core_private_testing_placeholder__ = '';
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  /**
   * @license
   * Copyright Google Inc. All Rights Reserved.
   *
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://angular.io/license
   */
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  
  /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  
  /**
   * Generated bundle index. Do not edit.
   */
  
  export { TestBedRender3 as ɵangular_packages_core_testing_testing_b, _getTestBedRender3 as ɵangular_packages_core_testing_testing_c, TestBedViewEngine as ɵangular_packages_core_testing_testing_a, TestBed, getTestBed, inject, InjectSetupWrapper, withModule, MetadataOverrider as ɵMetadataOverrider, async, ComponentFixture, resetFakeAsyncZone, fakeAsync, tick, flush, discardPeriodicTasks, flushMicrotasks, TestComponentRenderer, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, __core_private_testing_placeholder__, TestingCompiler as ɵTestingCompiler, TestingCompilerFactory as ɵTestingCompilerFactory };
  //# sourceMappingURL=testing.js.map
  