{"ast":null,"code":"'use strict';\n\nimport EmitterSubscription from \"./EmitterSubscription\";\nimport EventSubscriptionVendor from \"./EventSubscriptionVendor\";\nimport invariant from 'fbjs/lib/invariant';\n\nvar sparseFilterPredicate = function sparseFilterPredicate() {\n  return true;\n};\n\nvar EventEmitter = function () {\n  function EventEmitter(subscriber) {\n    this._subscriber = subscriber || new EventSubscriptionVendor();\n  }\n\n  var _proto = EventEmitter.prototype;\n\n  _proto.addListener = function addListener(eventType, listener, context) {\n    return this._subscriber.addSubscription(eventType, new EmitterSubscription(this, this._subscriber, listener, context));\n  };\n\n  _proto.once = function once(eventType, listener, context) {\n    var _this = this;\n\n    return this.addListener(eventType, function () {\n      _this.removeCurrentListener();\n\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n\n      listener.apply(context, args);\n    });\n  };\n\n  _proto.removeAllListeners = function removeAllListeners(eventType) {\n    this._subscriber.removeAllSubscriptions(eventType);\n  };\n\n  _proto.removeCurrentListener = function removeCurrentListener() {\n    invariant(!!this._currentSubscription, 'Not in an emitting cycle; there is no current subscription');\n    this.removeSubscription(this._currentSubscription);\n  };\n\n  _proto.removeSubscription = function removeSubscription(subscription) {\n    invariant(subscription.emitter === this, 'Subscription does not belong to this emitter.');\n\n    this._subscriber.removeSubscription(subscription);\n  };\n\n  _proto.listeners = function listeners(eventType) {\n    var subscriptions = this._subscriber.getSubscriptionsForType(eventType);\n\n    return subscriptions ? subscriptions.filter(sparseFilterPredicate).map(function (subscription) {\n      return subscription.listener;\n    }) : [];\n  };\n\n  _proto.emit = function emit(eventType) {\n    var subscriptions = this._subscriber.getSubscriptionsForType(eventType);\n\n    if (subscriptions) {\n      for (var i = 0, l = subscriptions.length; i < l; i++) {\n        var subscription = subscriptions[i];\n\n        if (subscription && subscription.listener) {\n          this._currentSubscription = subscription;\n          subscription.listener.apply(subscription.context, Array.prototype.slice.call(arguments, 1));\n        }\n      }\n\n      this._currentSubscription = null;\n    }\n  };\n\n  _proto.removeListener = function removeListener(eventType, listener) {\n    var subscriptions = this._subscriber.getSubscriptionsForType(eventType);\n\n    if (subscriptions) {\n      for (var i = 0, l = subscriptions.length; i < l; i++) {\n        var subscription = subscriptions[i];\n\n        if (subscription && subscription.listener === listener) {\n          subscription.remove();\n        }\n      }\n    }\n  };\n\n  return EventEmitter;\n}();\n\nexport default EventEmitter;","map":{"version":3,"sources":["/Users/nishan/Desktop/oss/responsive-breakpoints/example/node_modules/react-native-web/dist/vendor/react-native/emitter/EventEmitter.js"],"names":["EmitterSubscription","EventSubscriptionVendor","invariant","sparseFilterPredicate","EventEmitter","subscriber","_subscriber","_proto","prototype","addListener","eventType","listener","context","addSubscription","once","_this","removeCurrentListener","_len","arguments","length","args","Array","_key","apply","removeAllListeners","removeAllSubscriptions","_currentSubscription","removeSubscription","subscription","emitter","listeners","subscriptions","getSubscriptionsForType","filter","map","emit","i","l","slice","call","removeListener","remove"],"mappings":"AAUA;;AAEA,OAAOA,mBAAP;AACA,OAAOC,uBAAP;AACA,OAAOC,SAAP,MAAsB,oBAAtB;;AAEA,IAAIC,qBAAqB,GAAG,SAASA,qBAAT,GAAiC;AAC3D,SAAO,IAAP;AACD,CAFD;;AAkBA,IAAIC,YAAY,GAEhB,YAAY;AAOV,WAASA,YAAT,CAAsBC,UAAtB,EAAkC;AAChC,SAAKC,WAAL,GAAmBD,UAAU,IAAI,IAAIJ,uBAAJ,EAAjC;AACD;;AAiBD,MAAIM,MAAM,GAAGH,YAAY,CAACI,SAA1B;;AAEAD,EAAAA,MAAM,CAACE,WAAP,GAAqB,SAASA,WAAT,CAAqBC,SAArB,EAAgCC,QAAhC,EAA0CC,OAA1C,EAAmD;AACtE,WAAO,KAAKN,WAAL,CAAiBO,eAAjB,CAAiCH,SAAjC,EAA4C,IAAIV,mBAAJ,CAAwB,IAAxB,EAA8B,KAAKM,WAAnC,EAAgDK,QAAhD,EAA0DC,OAA1D,CAA5C,CAAP;AACD,GAFD;;A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AGN,aAAa,CAACZ,MAAlC,EAA0CiB,CAAC,GAAGC,CAA9C,EAAiDD,CAAC,EAAlD,EAAsD;AACpD,YAAIR,YAAY,GAAGG,aAAa,CAACK,CAAD,CAAhC;;AAGA,YAAIR,YAAY,IAAIA,YAAY,CAACjB,QAAb,KAA0BA,QAA9C,EAAwD;AACtDiB,UAAAA,YAAY,CAACa,MAAb;AACD;AACF;AACF;AACF,GAbD;;AAeA,SAAOrC,YAAP;AACD,CA7LD,EAFA;;AAiMA,eAAeA,YAAf","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @format\n * \n * @typecheck\n */\n'use strict';\n\nimport EmitterSubscription from './EmitterSubscription';\nimport EventSubscriptionVendor from './EventSubscriptionVendor';\nimport invariant from 'fbjs/lib/invariant';\n\nvar sparseFilterPredicate = function sparseFilterPredicate() {\n  return true;\n};\n/**\n * @class EventEmitter\n * @description\n * An EventEmitter is responsible for managing a set of listeners and publishing\n * events to them when it is told that such events happened. In addition to the\n * data for the given event it also sends a event control object which allows\n * the listeners/handlers to prevent the default behavior of the given event.\n *\n * The emitter is designed to be generic enough to support all the different\n * contexts in which one might want to emit events. It is a simple multicast\n * mechanism on top of which extra functionality can be composed. For example, a\n * more advanced emitter may use an EventHolder and EventFactory.\n */\n\n\nvar EventEmitter =\n/*#__PURE__*/\nfunction () {\n  /**\n   * @constructor\n   *\n   * @param {EventSubscriptionVendor} subscriber - Optional subscriber instance\n   *   to use. If omitted, a new subscriber will be created for the emitter.\n   */\n  function EventEmitter(subscriber) {\n    this._subscriber = subscriber || new EventSubscriptionVendor();\n  }\n  /**\n   * Adds a listener to be invoked when events of the specified type are\n   * emitted. An optional calling context may be provided. The data arguments\n   * emitted will be passed to the listener function.\n   *\n   * TODO: Annotate the listener arg's type. This is tricky because listeners\n   *       can be invoked with varargs.\n   *\n   * @param {string} eventType - Name of the event to listen to\n   * @param {function} listener - Function to invoke when the specified event is\n   *   emitted\n   * @param {*} context - Optional context object to use when invoking the\n   *   listener\n   */\n\n\n  var _proto = EventEmitter.prototype;\n\n  _proto.addListener = function addListener(eventType, listener, context) {\n    return this._subscriber.addSubscription(eventType, new EmitterSubscription(this, this._subscriber, listener, context));\n  }\n  /**\n   * Similar to addListener, except that the listener is removed after it is\n   * invoked once.\n   *\n   * @param {string} eventType - Name of the event to listen to\n   * @param {function} listener - Function to invoke only once when the\n   *   specified event is emitted\n   * @param {*} context - Optional context object to use when invoking the\n   *   listener\n   */\n  ;\n\n  _proto.once = function once(eventType, listener, context) {\n    var _this = this;\n\n    return this.addListener(eventType, function () {\n      _this.removeCurrentListener();\n\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n\n      listener.apply(context, args);\n    });\n  }\n  /**\n   * Removes all of the registered listeners, including those registered as\n   * listener maps.\n   *\n   * @param {?string} eventType - Optional name of the event whose registered\n   *   listeners to remove\n   */\n  ;\n\n  _proto.removeAllListeners = function removeAllListeners(eventType) {\n    this._subscriber.removeAllSubscriptions(eventType);\n  }\n  /**\n   * Provides an API that can be called during an eventing cycle to remove the\n   * last listener that was invoked. This allows a developer to provide an event\n   * object that can remove the listener (or listener map) during the\n   * invocation.\n   *\n   * If it is called when not inside of an emitting cycle it will throw.\n   *\n   * @throws {Error} When called not during an eventing cycle\n   *\n   * @example\n   *   var subscription = emitter.addListenerMap({\n   *     someEvent: function(data, event) {\n   *       console.log(data);\n   *       emitter.removeCurrentListener();\n   *     }\n   *   });\n   *\n   *   emitter.emit('someEvent', 'abc'); // logs 'abc'\n   *   emitter.emit('someEvent', 'def'); // does not log anything\n   */\n  ;\n\n  _proto.removeCurrentListener = function removeCurrentListener() {\n    invariant(!!this._currentSubscription, 'Not in an emitting cycle; there is no current subscription');\n    this.removeSubscription(this._currentSubscription);\n  }\n  /**\n   * Removes a specific subscription. Called by the `remove()` method of the\n   * subscription itself to ensure any necessary cleanup is performed.\n   */\n  ;\n\n  _proto.removeSubscription = function removeSubscription(subscription) {\n    invariant(subscription.emitter === this, 'Subscription does not belong to this emitter.');\n\n    this._subscriber.removeSubscription(subscription);\n  }\n  /**\n   * Returns an array of listeners that are currently registered for the given\n   * event.\n   *\n   * @param {string} eventType - Name of the event to query\n   * @returns {array}\n   */\n  ;\n\n  _proto.listeners = function listeners(eventType) {\n    var subscriptions = this._subscriber.getSubscriptionsForType(eventType);\n\n    return subscriptions ? subscriptions // We filter out missing entries because the array is sparse.\n    // \"callbackfn is called only for elements of the array which actually\n    // exist; it is not called for missing elements of the array.\"\n    // https://www.ecma-international.org/ecma-262/9.0/index.html#sec-array.prototype.filter\n    .filter(sparseFilterPredicate).map(function (subscription) {\n      return subscription.listener;\n    }) : [];\n  }\n  /**\n   * Emits an event of the given type with the given data. All handlers of that\n   * particular type will be notified.\n   *\n   * @param {string} eventType - Name of the event to emit\n   * @param {...*} Arbitrary arguments to be passed to each registered listener\n   *\n   * @example\n   *   emitter.addListener('someEvent', function(message) {\n   *     console.log(message);\n   *   });\n   *\n   *   emitter.emit('someEvent', 'abc'); // logs 'abc'\n   */\n  ;\n\n  _proto.emit = function emit(eventType) {\n    var subscriptions = this._subscriber.getSubscriptionsForType(eventType);\n\n    if (subscriptions) {\n      for (var i = 0, l = subscriptions.length; i < l; i++) {\n        var subscription = subscriptions[i]; // The subscription may have been removed during this event loop.\n\n        if (subscription && subscription.listener) {\n          this._currentSubscription = subscription;\n          subscription.listener.apply(subscription.context, Array.prototype.slice.call(arguments, 1));\n        }\n      }\n\n      this._currentSubscription = null;\n    }\n  }\n  /**\n   * Removes the given listener for event of specific type.\n   *\n   * @param {string} eventType - Name of the event to emit\n   * @param {function} listener - Function to invoke when the specified event is\n   *   emitted\n   *\n   * @example\n   *   emitter.removeListener('someEvent', function(message) {\n   *     console.log(message);\n   *   }); // removes the listener if already registered\n   *\n   */\n  ;\n\n  _proto.removeListener = function removeListener(eventType, listener) {\n    var subscriptions = this._subscriber.getSubscriptionsForType(eventType);\n\n    if (subscriptions) {\n      for (var i = 0, l = subscriptions.length; i < l; i++) {\n        var subscription = subscriptions[i]; // The subscription may have been removed during this event loop.\n        // its listener matches the listener in method parameters\n\n        if (subscription && subscription.listener === listener) {\n          subscription.remove();\n        }\n      }\n    }\n  };\n\n  return EventEmitter;\n}();\n\nexport default EventEmitter;"]},"metadata":{},"sourceType":"module"}