text: import { InjectionToken, NgZone, PLATFORM_ID, Injectable, Inject, Optional } from '@angular/core';
  import { of, from } from 'rxjs';
  import { AngularFirestoreDocument } from './document/document';
  import { AngularFirestoreCollection } from './collection/collection';
  import { FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';
  import { isPlatformBrowser } from '@angular/common';
  export var EnablePersistenceToken = new InjectionToken('angularfire2.enableFirestorePersistence');
  export var FirestoreSettingsToken = new InjectionToken('angularfire2.firestore.settings');
  export var DefaultFirestoreSettings = { timestampsInSnapshots: true };
  export function associateQuery(collectionRef, queryFn) {
      if (queryFn === void 0) { queryFn = function (ref) { return ref; }; }
      var query = queryFn(collectionRef);
      var ref = collectionRef;
      return { query: query, ref: ref };
  }
  var AngularFirestore = (function () {
      function AngularFirestore(options, nameOrConfig, shouldEnablePersistence, settings, platformId, zone) {
          var _this = this;
          this.scheduler = new FirebaseZoneScheduler(zone, platformId);
          this.firestore = zone.runOutsideAngular(function () {
              var app = _firebaseAppFactory(options, nameOrConfig);
              var firestore = app.firestore();
              firestore.settings(settings || DefaultFirestoreSettings);
              return firestore;
          });
          if (shouldEnablePersistence && isPlatformBrowser(platformId)) {
              var enablePersistence = function () {
                  try {
                      return from(_this.firestore.enablePersistence().then(function () { return true; }, function () { return false; }));
                  }
                  catch (e) {
                      return of(false);
                  }
              };
              this.persistenceEnabled$ = zone.runOutsideAngular(enablePersistence);
          }
          else {
              this.persistenceEnabled$ = of(false);
          }
      }
      AngularFirestore.prototype.collection = function (pathOrRef, queryFn) {
          var collectionRef;
          if (typeof pathOrRef === 'string') {
              collectionRef = this.firestore.collection(pathOrRef);
          }
          else {
              collectionRef = pathOrRef;
          }
          var _a = associateQuery(collectionRef, queryFn), ref = _a.ref, query = _a.query;
          return new AngularFirestoreCollection(ref, query, this);
      };
      AngularFirestore.prototype.doc = function (pathOrRef) {
          var ref;
          if (typeof pathOrRef === 'string') {
              ref = this.firestore.doc(pathOrRef);
          }
          else {
              ref = pathOrRef;
          }
          return new AngularFirestoreDocument(ref, this);
      };
      AngularFirestore.prototype.createId = function () {
          return this.firestore.collection('_').doc().id;
      };
      AngularFirestore.decorators = [
          { type: Injectable },
      ];
      AngularFirestore.ctorParameters = function () { return [
          { type: undefined, decorators: [{ type: Inject, args: [FirebaseOptionsToken,] }] },
          { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FirebaseNameOrConfigToken,] }] },
          { type: Boolean, decorators: [{ type: Optional }, { type: Inject, args: [EnablePersistenceToken,] }] },
          { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FirestoreSettingsToken,] }] },
          { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] },
          { type: NgZone }
      ]; };
      return AngularFirestore;
  }());
  export { AngularFirestore };
  //# sourceMappingURL=firestore.js.map