{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _regeneratorRuntime from \"@babel/runtime/regenerator\";\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nimport { CodedError, RCTDeviceEventEmitter, UnavailabilityError } from '@unimodules/core';\nimport Constants from 'expo-constants';\nimport { EventEmitter } from 'fbemitter';\nimport invariant from 'invariant';\nimport Platform from \"react-native-web/dist/exports/Platform\";\nimport ExponentNotifications from \"./ExponentNotifications\";\nimport Storage from \"./Storage\";\n\nvar _emitter;\n\nvar _initialNotification;\n\nfunction _getEventEmitter() {\n  if (!_emitter) {\n    _emitter = new EventEmitter();\n    RCTDeviceEventEmitter.addListener('Exponent.notification', emitNotification);\n  }\n\n  return _emitter;\n}\n\nexport function emitNotification(notification) {\n  if (typeof notification === 'string') {\n    notification = JSON.parse(notification);\n  }\n\n  notification = _objectSpread({}, notification);\n\n  if (typeof notification.data === 'string') {\n    try {\n      notification.data = JSON.parse(notification.data);\n    } catch (e) {}\n  }\n\n  var emitter = _getEventEmitter();\n\n  emitter.emit('notification', notification);\n}\n\nfunction _processNotification(notification) {\n  notification = _extends({}, notification);\n\n  if (!notification.data) {\n    notification.data = {};\n  }\n\n  if (notification.hasOwnProperty('count')) {\n    delete notification.count;\n  }\n\n  if (Platform.OS === 'ios') {\n    if (notification.android) {\n      delete notification.android;\n    }\n\n    if (notification.ios) {\n      notification = _extends(notification, notification.ios);\n      notification.data._displayInForeground = notification.ios._displayInForeground;\n      delete notification.ios;\n    }\n  }\n\n  if (Platform.OS === 'android') {\n    if (notification.ios) {\n      delete notification.ios;\n    }\n\n    if (notification.android) {\n      notification = _extends(notification, notification.android);\n      delete notification.android;\n    }\n  }\n\n  return notification;\n}\n\nfunction _validateNotification(notification) {\n  if (Platform.OS === 'ios') {\n    invariant(!!notification.title && !!notification.body, 'Local notifications on iOS require both a title and a body');\n  } else if (Platform.OS === 'android') {\n    invariant(!!notification.title, 'Local notifications on Android require a title');\n  }\n}\n\nvar ASYNC_STORAGE_PREFIX = '__expo_internal_channel_';\nvar IS_USING_NEW_BINARY = ExponentNotifications && typeof ExponentNotifications.createChannel === 'function';\n\nfunction _legacyReadChannel(id) {\n  var channelString;\n  return _regeneratorRuntime.async(function _legacyReadChannel$(_context) {\n    while (1) {\n      switch (_context.prev = _context.next) {\n        case 0:\n          _context.prev = 0;\n          _context.next = 3;\n          return _regeneratorRuntime.awrap(Storage.getItem(\"\" + ASYNC_STORAGE_PREFIX + id));\n\n        case 3:\n          channelString = _context.sent;\n\n          if (!channelString) {\n            _context.next = 6;\n            break;\n          }\n\n          return _context.abrupt(\"return\", JSON.parse(channelString));\n\n        case 6:\n          _context.next = 10;\n          break;\n\n        case 8:\n          _context.prev = 8;\n          _context.t0 = _context[\"catch\"](0);\n\n        case 10:\n          return _context.abrupt(\"return\", null);\n\n        case 11:\n        case \"end\":\n          return _context.stop();\n      }\n    }\n  }, null, null, [[0, 8]], Promise);\n}\n\nfunction _legacyDeleteChannel(id) {\n  return Storage.removeItem(\"\" + ASYNC_STORAGE_PREFIX + id);\n}\n\nif (Platform.OS === 'android') {\n  Storage.clear = function _callee(callback) {\n    var keys, filteredKeys;\n    return _regeneratorRuntime.async(function _callee$(_context2) {\n      while (1) {\n        switch (_context2.prev = _context2.next) {\n          case 0:\n            _context2.prev = 0;\n            _context2.next = 3;\n            return _regeneratorRuntime.awrap(Storage.getAllKeys());\n\n          case 3:\n            keys = _context2.sent;\n\n            if (!(keys && keys.length)) {\n              _context2.next = 8;\n              break;\n            }\n\n            filteredKeys = keys.filter(function (key) {\n              return !key.startsWith(ASYNC_STORAGE_PREFIX);\n            });\n            _context2.next = 8;\n            return _regeneratorRuntime.awrap(Storage.multiRemove(filteredKeys));\n\n          case 8:\n            callback && callback();\n            _context2.next = 15;\n            break;\n\n          case 11:\n            _context2.prev = 11;\n            _context2.t0 = _context2[\"catch\"](0);\n            callback && callback(_context2.t0);\n            throw _context2.t0;\n\n          case 15:\n          case \"end\":\n            return _context2.stop();\n        }\n      }\n    }, null, null, [[0, 11]], Promise);\n  };\n}\n\nfunction _legacySaveChannel(id, channel) {\n  return Storage.setItem(\"\" + ASYNC_STORAGE_PREFIX + id, JSON.stringify(channel));\n}\n\nexport default {\n  _setInitialNotification: function _setInitialNotification(notification) {\n    _initialNotification = notification;\n  },\n  createCategoryAsync: function createCategoryAsync(categoryId, actions, previewPlaceholder) {\n    return Platform.OS === 'ios' ? ExponentNotifications.createCategoryAsync(categoryId, actions, previewPlaceholder) : ExponentNotifications.createCategoryAsync(categoryId, actions);\n  },\n  deleteCategoryAsync: function deleteCategoryAsync(categoryId) {\n    return ExponentNotifications.deleteCategoryAsync(categoryId);\n  },\n  getExpoPushTokenAsync: function getExpoPushTokenAsync() {\n    if (!ExponentNotifications.getExponentPushTokenAsync) {\n      throw new UnavailabilityError('Expo.Notifications', 'getExpoPushTokenAsync');\n    }\n\n    if (!Constants.isDevice) {\n      throw new Error(\"Must be on a physical device to get an Expo Push Token\");\n    }\n\n    return ExponentNotifications.getExponentPushTokenAsync();\n  },\n  getDevicePushTokenAsync: function getDevicePushTokenAsync(config) {\n    if (!ExponentNotifications.getDevicePushTokenAsync) {\n      throw new UnavailabilityError('Expo.Notifications', 'getDevicePushTokenAsync');\n    }\n\n    return ExponentNotifications.getDevicePushTokenAsync(config || {});\n  },\n  createChannelAndroidAsync: function createChannelAndroidAsync(id, channel) {\n    if (Platform.OS !== 'android') {\n      console.warn(\"createChannelAndroidAsync(...) has no effect on \" + Platform.OS);\n      return Promise.resolve();\n    }\n\n    if (!IS_USING_NEW_BINARY) {\n      return _legacySaveChannel(id, channel);\n    }\n\n    return ExponentNotifications.createChannel(id, channel);\n  },\n  deleteChannelAndroidAsync: function deleteChannelAndroidAsync(id) {\n    if (Platform.OS !== 'android') {\n      console.warn(\"deleteChannelAndroidAsync(...) has no effect on \" + Platform.OS);\n      return Promise.resolve();\n    }\n\n    if (!IS_USING_NEW_BINARY) {\n      return Promise.resolve();\n    }\n\n    return ExponentNotifications.deleteChannel(id);\n  },\n  presentLocalNotificationAsync: function presentLocalNotificationAsync(notification) {\n    var nativeNotification, _channel;\n\n    return _regeneratorRuntime.async(function presentLocalNotificationAsync$(_context3) {\n      while (1) {\n        switch (_context3.prev = _context3.next) {\n          case 0:\n            _validateNotification(notification);\n\n            nativeNotification = _processNotification(notification);\n\n            if (!(Platform.OS !== 'android')) {\n              _context3.next = 8;\n              break;\n            }\n\n            _context3.next = 5;\n            return _regeneratorRuntime.awrap(ExponentNotifications.presentLocalNotification(nativeNotification));\n\n          case 5:\n            return _context3.abrupt(\"return\", _context3.sent);\n\n          case 8:\n            if (!nativeNotification.channelId) {\n              _context3.next = 12;\n              break;\n            }\n\n            _context3.next = 11;\n            return _regeneratorRuntime.awrap(_legacyReadChannel(nativeNotification.channelId));\n\n          case 11:\n            _channel = _context3.sent;\n\n          case 12:\n            if (!IS_USING_NEW_BINARY) {\n              _context3.next = 17;\n              break;\n            }\n\n            _legacyDeleteChannel(nativeNotification.channelId);\n\n            return _context3.abrupt(\"return\", ExponentNotifications.presentLocalNotificationWithChannel(nativeNotification, _channel));\n\n          case 17:\n            if (_channel) {\n              nativeNotification.sound = _channel.sound;\n              nativeNotification.priority = _channel.priority;\n              nativeNotification.vibrate = _channel.vibrate;\n            }\n\n            return _context3.abrupt(\"return\", ExponentNotifications.presentLocalNotification(nativeNotification));\n\n          case 19:\n          case \"end\":\n            return _context3.stop();\n        }\n      }\n    }, null, null, null, Promise);\n  },\n  scheduleLocalNotificationAsync: function scheduleLocalNotificationAsync(notification) {\n    var options,\n        now,\n        nativeNotification,\n        timeAsDateObj,\n        validOptions,\n        _channel,\n        _args4 = arguments;\n\n    return _regeneratorRuntime.async(function scheduleLocalNotificationAsync$(_context4) {\n      while (1) {\n        switch (_context4.prev = _context4.next) {\n          case 0:\n            options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};\n            now = Date.now();\n\n            _validateNotification(notification);\n\n            nativeNotification = _processNotification(notification);\n\n            if (!options.time) {\n              _context4.next = 11;\n              break;\n            }\n\n            timeAsDateObj = null;\n\n            if (options.time && typeof options.time === 'number') {\n              timeAsDateObj = new Date(options.time);\n\n              if (timeAsDateObj.toString() === 'Invalid Date') {\n                timeAsDateObj = null;\n              }\n            } else if (options.time && options.time instanceof Date) {\n              timeAsDateObj = options.time;\n            }\n\n            if (timeAsDateObj) {\n              _context4.next = 9;\n              break;\n            }\n\n            throw new Error(\"Provided value for \\\"time\\\" is invalid. Please verify that it's either a number representing Unix Epoch time in milliseconds, or a valid date object.\");\n\n          case 9:\n            if (timeAsDateObj.getTime() < now) {\n              console.warn(\"Provided value for \\\"time\\\" is before the current date. Did you possibly pass number of seconds since Unix Epoch instead of number of milliseconds?\");\n            }\n\n            options = _objectSpread(_objectSpread({}, options), {}, {\n              time: timeAsDateObj.getTime()\n            });\n\n          case 11:\n            if (!(options.intervalMs != null && options.repeat != null)) {\n              _context4.next = 13;\n              break;\n            }\n\n            throw new Error(\"Pass either the \\\"repeat\\\" option or \\\"intervalMs\\\" option, not both\");\n\n          case 13:\n            if (!(options.repeat != null)) {\n              _context4.next = 17;\n              break;\n            }\n\n            validOptions = new Set(['minute', 'hour', 'day', 'week', 'month', 'year']);\n\n            if (validOptions.has(options.repeat)) {\n              _context4.next = 17;\n              break;\n            }\n\n            throw new Error(\"Pass one of ['minute', 'hour', 'day', 'week', 'month', 'year'] as the value for the \\\"repeat\\\" option\");\n\n          case 17:\n            if (!(options.intervalMs != null)) {\n              _context4.next = 22;\n              break;\n            }\n\n            if (!(Platform.OS === 'ios')) {\n              _context4.next = 20;\n              break;\n            }\n\n            throw new Error(\"The \\\"intervalMs\\\" option is not supported on iOS\");\n\n          case 20:\n            if (!(options.intervalMs <= 0 || !Number.isInteger(options.intervalMs))) {\n              _context4.next = 22;\n              break;\n            }\n\n            throw new Error(\"Pass an integer greater than zero as the value for the \\\"intervalMs\\\" option\");\n\n          case 22:\n            if (!(Platform.OS !== 'android')) {\n              _context4.next = 29;\n              break;\n            }\n\n            if (!options.repeat) {\n              _context4.next = 26;\n              break;\n            }\n\n            console.warn('Ability to schedule an automatically repeated notification is deprecated on iOS and will be removed in the next SDK release.');\n            return _context4.abrupt(\"return\", ExponentNotifications.legacyScheduleLocalRepeatingNotification(nativeNotification, options));\n\n          case 26:\n            return _context4.abrupt(\"return\", ExponentNotifications.scheduleLocalNotification(nativeNotification, options));\n\n          case 29:\n            if (!nativeNotification.channelId) {\n              _context4.next = 33;\n              break;\n            }\n\n            _context4.next = 32;\n            return _regeneratorRuntime.awrap(_legacyReadChannel(nativeNotification.channelId));\n\n          case 32:\n            _channel = _context4.sent;\n\n          case 33:\n            if (!IS_USING_NEW_BINARY) {\n              _context4.next = 38;\n              break;\n            }\n\n            _legacyDeleteChannel(nativeNotification.channelId);\n\n            return _context4.abrupt(\"return\", ExponentNotifications.scheduleLocalNotificationWithChannel(nativeNotification, options, _channel));\n\n          case 38:\n            if (_channel) {\n              nativeNotification.sound = _channel.sound;\n              nativeNotification.priority = _channel.priority;\n              nativeNotification.vibrate = _channel.vibrate;\n            }\n\n            return _context4.abrupt(\"return\", ExponentNotifications.scheduleLocalNotification(nativeNotification, options));\n\n          case 40:\n          case \"end\":\n            return _context4.stop();\n        }\n      }\n    }, null, null, null, Promise);\n  },\n  dismissNotificationAsync: function dismissNotificationAsync(notificationId) {\n    return _regeneratorRuntime.async(function dismissNotificationAsync$(_context5) {\n      while (1) {\n        switch (_context5.prev = _context5.next) {\n          case 0:\n            if (ExponentNotifications.dismissNotification) {\n              _context5.next = 2;\n              break;\n            }\n\n            throw new UnavailabilityError('Expo.Notifications', 'dismissNotification');\n\n          case 2:\n            _context5.next = 4;\n            return _regeneratorRuntime.awrap(ExponentNotifications.dismissNotification(notificationId));\n\n          case 4:\n            return _context5.abrupt(\"return\", _context5.sent);\n\n          case 5:\n          case \"end\":\n            return _context5.stop();\n        }\n      }\n    }, null, null, null, Promise);\n  },\n  dismissAllNotificationsAsync: function dismissAllNotificationsAsync() {\n    return _regeneratorRuntime.async(function dismissAllNotificationsAsync$(_context6) {\n      while (1) {\n        switch (_context6.prev = _context6.next) {\n          case 0:\n            if (ExponentNotifications.dismissAllNotifications) {\n              _context6.next = 2;\n              break;\n            }\n\n            throw new UnavailabilityError('Expo.Notifications', 'dismissAllNotifications');\n\n          case 2:\n            _context6.next = 4;\n            return _regeneratorRuntime.awrap(ExponentNotifications.dismissAllNotifications());\n\n          case 4:\n            return _context6.abrupt(\"return\", _context6.sent);\n\n          case 5:\n          case \"end\":\n            return _context6.stop();\n        }\n      }\n    }, null, null, null, Promise);\n  },\n  cancelScheduledNotificationAsync: function cancelScheduledNotificationAsync(notificationId) {\n    if (Platform.OS === 'android' && typeof notificationId === 'string') {\n      return ExponentNotifications.cancelScheduledNotificationWithStringIdAsync(notificationId);\n    }\n\n    return ExponentNotifications.cancelScheduledNotificationAsync(notificationId);\n  },\n  cancelAllScheduledNotificationsAsync: function cancelAllScheduledNotificationsAsync() {\n    return ExponentNotifications.cancelAllScheduledNotificationsAsync();\n  },\n  addListener: function addListener(listener) {\n    var emitter = _getEventEmitter();\n\n    if (_initialNotification) {\n      var initialNotification = _initialNotification;\n      _initialNotification = null;\n      setTimeout(function () {\n        emitNotification(initialNotification);\n      }, 0);\n    }\n\n    return emitter.addListener('notification', listener);\n  },\n  getBadgeNumberAsync: function getBadgeNumberAsync() {\n    return _regeneratorRuntime.async(function getBadgeNumberAsync$(_context7) {\n      while (1) {\n        switch (_context7.prev = _context7.next) {\n          case 0:\n            if (ExponentNotifications.getBadgeNumberAsync) {\n              _context7.next = 2;\n              break;\n            }\n\n            return _context7.abrupt(\"return\", 0);\n\n          case 2:\n            return _context7.abrupt(\"return\", ExponentNotifications.getBadgeNumberAsync());\n\n          case 3:\n          case \"end\":\n            return _context7.stop();\n        }\n      }\n    }, null, null, null, Promise);\n  },\n  setBadgeNumberAsync: function setBadgeNumberAsync(number) {\n    return _regeneratorRuntime.async(function setBadgeNumberAsync$(_context8) {\n      while (1) {\n        switch (_context8.prev = _context8.next) {\n          case 0:\n            if (ExponentNotifications.setBadgeNumberAsync) {\n              _context8.next = 2;\n              break;\n            }\n\n            throw new UnavailabilityError('Expo.Notifications', 'setBadgeNumberAsync');\n\n          case 2:\n            return _context8.abrupt(\"return\", ExponentNotifications.setBadgeNumberAsync(number));\n\n          case 3:\n          case \"end\":\n            return _context8.stop();\n        }\n      }\n    }, null, null, null, Promise);\n  },\n  scheduleNotificationWithCalendarAsync: function scheduleNotificationWithCalendarAsync(notification) {\n    var options,\n        areOptionsValid,\n        nativeNotification,\n        _args9 = arguments;\n    return _regeneratorRuntime.async(function scheduleNotificationWithCalendarAsync$(_context9) {\n      while (1) {\n        switch (_context9.prev = _context9.next) {\n          case 0:\n            options = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : {};\n            areOptionsValid = (options.month == null || isInRangeInclusive(options.month, 1, 12)) && (options.day == null || isInRangeInclusive(options.day, 1, 31)) && (options.hour == null || isInRangeInclusive(options.hour, 0, 23)) && (options.minute == null || isInRangeInclusive(options.minute, 0, 59)) && (options.second == null || isInRangeInclusive(options.second, 0, 59)) && (options.weekDay == null || isInRangeInclusive(options.weekDay, 1, 7)) && (options.weekDay == null || options.day == null);\n\n            if (areOptionsValid) {\n              _context9.next = 4;\n              break;\n            }\n\n            throw new CodedError('WRONG_OPTIONS', 'Options in scheduleNotificationWithCalendarAsync call were incorrect!');\n\n          case 4:\n            _validateNotification(notification);\n\n            nativeNotification = _processNotification(notification);\n            return _context9.abrupt(\"return\", ExponentNotifications.scheduleNotificationWithCalendar(nativeNotification, options));\n\n          case 7:\n          case \"end\":\n            return _context9.stop();\n        }\n      }\n    }, null, null, null, Promise);\n  },\n  scheduleNotificationWithTimerAsync: function scheduleNotificationWithTimerAsync(notification, options) {\n    var nativeNotification;\n    return _regeneratorRuntime.async(function scheduleNotificationWithTimerAsync$(_context10) {\n      while (1) {\n        switch (_context10.prev = _context10.next) {\n          case 0:\n            if (!(options.interval < 1)) {\n              _context10.next = 2;\n              break;\n            }\n\n            throw new CodedError('WRONG_OPTIONS', 'Interval must be not less then 1');\n\n          case 2:\n            _validateNotification(notification);\n\n            nativeNotification = _processNotification(notification);\n            return _context10.abrupt(\"return\", ExponentNotifications.scheduleNotificationWithTimer(nativeNotification, options));\n\n          case 5:\n          case \"end\":\n            return _context10.stop();\n        }\n      }\n    }, null, null, null, Promise);\n  }\n};\n\nfunction isInRangeInclusive(variable, min, max) {\n  return variable >= min && variable <= max;\n}","map":{"version":3,"sources":["../../src/Notifications/Notifications.ts"],"names":[],"mappings":";;;;;;;;AAAA,SAAS,UAAT,EAAqB,qBAArB,EAA4C,mBAA5C,QAAuE,kBAAvE;AACA,OAAO,SAAP,MAAsB,gBAAtB;AACA,SAAS,YAAT,QAAgD,WAAhD;AACA,OAAO,SAAP,MAAsB,WAAtB;;AAGA,OAAO,qBAAP;AAQA,OAAO,OAAP;;AAEA,IAAI,QAAJ;;AACA,IAAI,oBAAJ;;AAEA,SAAS,gBAAT,GAAyB;AACvB,MAAI,CAAC,QAAL,EAAe;AACb,IAAA,QAAQ,GAAG,IAAI,YAAJ,EAAX;AACA,IAAA,qBAAqB,CAAC,WAAtB,CAAkC,uBAAlC,EAA2D,gBAA3D;AACD;;AAED,SA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,GAA3D,EAAsE;AACpE,SAAO,QAAQ,IAAI,GAAZ,IAAmB,QAAQ,IAAI,GAAtC;AACD","sourcesContent":["import { CodedError, RCTDeviceEventEmitter, UnavailabilityError } from '@unimodules/core';\nimport Constants from 'expo-constants';\nimport { EventEmitter, EventSubscription } from 'fbemitter';\nimport invariant from 'invariant';\nimport { Platform } from 'react-native';\n\nimport ExponentNotifications from './ExponentNotifications';\nimport {\n  Notification,\n  LocalNotification,\n  Channel,\n  ActionType,\n  LocalNotificationId,\n} from './Notifications.types';\nimport Storage from './Storage';\n\nlet _emitter;\nlet _initialNotification;\n\nfunction _getEventEmitter() {\n  if (!_emitter) {\n    _emitter = new EventEmitter();\n    RCTDeviceEventEmitter.addListener('Exponent.notification', emitNotification);\n  }\n\n  return _emitter;\n}\n\nexport function emitNotification(notification) {\n  if (typeof notification === 'string') {\n    notification = JSON.parse(notification);\n  }\n\n  /* Don't mutate the original notification */\n  notification = { ...notification };\n\n  if (typeof notification.data === 'string') {\n    try {\n      notification.data = JSON.parse(notification.data);\n    } catch (e) {\n      // It's actually just a string, that's fine\n    }\n  }\n\n  const emitter = _getEventEmitter();\n\n  emitter.emit('notification', notification);\n}\n\nfunction _processNotification(notification) {\n  notification = Object.assign({}, notification);\n\n  if (!notification.data) {\n    notification.data = {};\n  }\n\n  if (notification.hasOwnProperty('count')) {\n    delete notification.count;\n  }\n\n  // Delete any Android properties on iOS and merge the iOS properties on root notification object\n  if (Platform.OS === 'ios') {\n    if (notification.android) {\n      delete notification.android;\n    }\n\n    if (notification.ios) {\n      notification = Object.assign(notification, notification.ios);\n      notification.data._displayInForeground = notification.ios._displayInForeground;\n      delete notification.ios;\n    }\n  }\n\n  // Delete any iOS properties on Android and merge the Android properties on root notification\n  // object\n  if (Platform.OS === 'android') {\n    if (notification.ios) {\n      delete notification.ios;\n    }\n\n    if (notification.android) {\n      notification = Object.assign(notification, notification.android);\n      delete notification.android;\n    }\n  }\n\n  return notification;\n}\n\nfunction _validateNotification(notification) {\n  if (Platform.OS === 'ios') {\n    invariant(\n      !!notification.title && !!notification.body,\n      'Local notifications on iOS require both a title and a body'\n    );\n  } else if (Platform.OS === 'android') {\n    invariant(!!notification.title, 'Local notifications on Android require a title');\n  }\n}\n\nconst ASYNC_STORAGE_PREFIX = '__expo_internal_channel_';\n// TODO: remove this before releasing\n// this will always be `true` for SDK 28+\nconst IS_USING_NEW_BINARY =\n  ExponentNotifications && typeof ExponentNotifications.createChannel === 'function';\n\nasync function _legacyReadChannel(id: string): Promise<Channel | null> {\n  try {\n    const channelString = await Storage.getItem(`${ASYNC_STORAGE_PREFIX}${id}`);\n    if (channelString) {\n      return JSON.parse(channelString);\n    }\n  } catch (e) {}\n  return null;\n}\n\nfunction _legacyDeleteChannel(id: string): Promise<void> {\n  return Storage.removeItem(`${ASYNC_STORAGE_PREFIX}${id}`);\n}\n\nif (Platform.OS === 'android') {\n  Storage.clear = async function(callback?: (error?: Error) => void): Promise<void> {\n    try {\n      const keys = await Storage.getAllKeys();\n      if (keys && keys.length) {\n        const filteredKeys = keys.filter(key => !key.startsWith(ASYNC_STORAGE_PREFIX));\n        await Storage.multiRemove(filteredKeys);\n      }\n      callback && callback();\n    } catch (e) {\n      callback && callback(e);\n      throw e;\n    }\n  };\n}\n\n// This codepath will never be triggered in SDK 28 and above\n// TODO: remove before releasing\nfunction _legacySaveChannel(id: string, channel: Channel): Promise<void> {\n  return Storage.setItem(`${ASYNC_STORAGE_PREFIX}${id}`, JSON.stringify(channel));\n}\n\nexport default {\n  /* Only used internally to initialize the notification from top level props */\n  _setInitialNotification(notification: Notification) {\n    _initialNotification = notification;\n  },\n\n  // User passes set of actions titles.\n  createCategoryAsync(\n    categoryId: string,\n    actions: ActionType[],\n    previewPlaceholder?: string\n  ): Promise<void> {\n    return Platform.OS === 'ios'\n      ? ExponentNotifications.createCategoryAsync(categoryId, actions, previewPlaceholder)\n      : ExponentNotifications.createCategoryAsync(categoryId, actions);\n  },\n\n  deleteCategoryAsync(categoryId: string): Promise<void> {\n    return ExponentNotifications.deleteCategoryAsync(categoryId);\n  },\n\n  /* Re-export */\n  getExpoPushTokenAsync(): Promise<string> {\n    if (!ExponentNotifications.getExponentPushTokenAsync) {\n      throw new UnavailabilityError('Expo.Notifications', 'getExpoPushTokenAsync');\n    }\n    if (!Constants.isDevice) {\n      throw new Error(`Must be on a physical device to get an Expo Push Token`);\n    }\n    return ExponentNotifications.getExponentPushTokenAsync();\n  },\n\n  getDevicePushTokenAsync: (config: {\n    gcmSenderId?: string;\n  }): Promise<{ type: string; data: string }> => {\n    if (!ExponentNotifications.getDevicePushTokenAsync) {\n      throw new UnavailabilityError('Expo.Notifications', 'getDevicePushTokenAsync');\n    }\n    return ExponentNotifications.getDevicePushTokenAsync(config || {});\n  },\n\n  createChannelAndroidAsync(id: string, channel: Channel): Promise<void> {\n    if (Platform.OS !== 'android') {\n      console.warn(`createChannelAndroidAsync(...) has no effect on ${Platform.OS}`);\n      return Promise.resolve();\n    }\n    // This codepath will never be triggered in SDK 28 and above\n    // TODO: remove before releasing\n    if (!IS_USING_NEW_BINARY) {\n      return _legacySaveChannel(id, channel);\n    }\n    return ExponentNotifications.createChannel(id, channel);\n  },\n\n  deleteChannelAndroidAsync(id: string): Promise<void> {\n    if (Platform.OS !== 'android') {\n      console.warn(`deleteChannelAndroidAsync(...) has no effect on ${Platform.OS}`);\n      return Promise.resolve();\n    }\n    // This codepath will never be triggered in SDK 28 and above\n    // TODO: remove before releasing\n    if (!IS_USING_NEW_BINARY) {\n      return Promise.resolve();\n    }\n    return ExponentNotifications.deleteChannel(id);\n  },\n\n  /* Shows a notification instantly */\n  async presentLocalNotificationAsync(\n    notification: LocalNotification\n  ): Promise<LocalNotificationId> {\n    _validateNotification(notification);\n    const nativeNotification = _processNotification(notification);\n\n    if (Platform.OS !== 'android') {\n      return await ExponentNotifications.presentLocalNotification(nativeNotification);\n    } else {\n      let _channel;\n      if (nativeNotification.channelId) {\n        _channel = await _legacyReadChannel(nativeNotification.channelId);\n      }\n\n      if (IS_USING_NEW_BINARY) {\n        // delete the legacy channel from AsyncStorage so this codepath isn't triggered anymore\n        _legacyDeleteChannel(nativeNotification.channelId);\n        return ExponentNotifications.presentLocalNotificationWithChannel(\n          nativeNotification,\n          _channel\n        );\n      } else {\n        // TODO: remove this codepath before releasing, it will never be triggered on SDK 28+\n        // channel does not actually exist, so add its settings to the individual notification\n        if (_channel) {\n          nativeNotification.sound = _channel.sound;\n          nativeNotification.priority = _channel.priority;\n          nativeNotification.vibrate = _channel.vibrate;\n        }\n        return ExponentNotifications.presentLocalNotification(nativeNotification);\n      }\n    }\n  },\n\n  /* Schedule a notification at a later date */\n  async scheduleLocalNotificationAsync(\n    notification: LocalNotification,\n    options: {\n      time?: Date | number;\n      repeat?: 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';\n      intervalMs?: number;\n    } = {}\n  ): Promise<LocalNotificationId> {\n    // set now at the beginning of the method, to prevent potential weird warnings when we validate\n    // options.time later on\n    const now = Date.now();\n\n    // Validate and process the notification data\n    _validateNotification(notification);\n    const nativeNotification = _processNotification(notification);\n\n    // Validate `options.time`\n    if (options.time) {\n      let timeAsDateObj: Date | null = null;\n      if (options.time && typeof options.time === 'number') {\n        timeAsDateObj = new Date(options.time);\n        if (timeAsDateObj.toString() === 'Invalid Date') {\n          timeAsDateObj = null;\n        }\n      } else if (options.time && options.time instanceof Date) {\n        timeAsDateObj = options.time;\n      }\n\n      // If we couldn't convert properly, throw an error\n      if (!timeAsDateObj) {\n        throw new Error(\n          `Provided value for \"time\" is invalid. Please verify that it's either a number representing Unix Epoch time in milliseconds, or a valid date object.`\n        );\n      }\n\n      // If someone passes in a value that is too small, say, by an order of 1000 (it's common to\n      // accidently pass seconds instead of ms), display a warning.\n      if (timeAsDateObj.getTime() < now) {\n        console.warn(\n          `Provided value for \"time\" is before the current date. Did you possibly pass number of seconds since Unix Epoch instead of number of milliseconds?`\n        );\n      }\n\n      options = {\n        ...options,\n        time: timeAsDateObj.getTime(),\n      };\n    }\n\n    if (options.intervalMs != null && options.repeat != null) {\n      throw new Error(`Pass either the \"repeat\" option or \"intervalMs\" option, not both`);\n    }\n\n    // Validate options.repeat\n    if (options.repeat != null) {\n      const validOptions = new Set(['minute', 'hour', 'day', 'week', 'month', 'year']);\n      if (!validOptions.has(options.repeat)) {\n        throw new Error(\n          `Pass one of ['minute', 'hour', 'day', 'week', 'month', 'year'] as the value for the \"repeat\" option`\n        );\n      }\n    }\n\n    if (options.intervalMs != null) {\n      if (Platform.OS === 'ios') {\n        throw new Error(`The \"intervalMs\" option is not supported on iOS`);\n      }\n\n      if (options.intervalMs <= 0 || !Number.isInteger(options.intervalMs)) {\n        throw new Error(\n          `Pass an integer greater than zero as the value for the \"intervalMs\" option`\n        );\n      }\n    }\n\n    if (Platform.OS !== 'android') {\n      if (options.repeat) {\n        console.warn(\n          'Ability to schedule an automatically repeated notification is deprecated on iOS and will be removed in the next SDK release.'\n        );\n        return ExponentNotifications.legacyScheduleLocalRepeatingNotification(\n          nativeNotification,\n          options\n        );\n      }\n\n      return ExponentNotifications.scheduleLocalNotification(nativeNotification, options);\n    } else {\n      let _channel;\n      if (nativeNotification.channelId) {\n        _channel = await _legacyReadChannel(nativeNotification.channelId);\n      }\n\n      if (IS_USING_NEW_BINARY) {\n        // delete the legacy channel from AsyncStorage so this codepath isn't triggered anymore\n        _legacyDeleteChannel(nativeNotification.channelId);\n        return ExponentNotifications.scheduleLocalNotificationWithChannel(\n          nativeNotification,\n          options,\n          _channel\n        );\n      } else {\n        // TODO: remove this codepath before releasing, it will never be triggered on SDK 28+\n        // channel does not actually exist, so add its settings to the individual notification\n        if (_channel) {\n          nativeNotification.sound = _channel.sound;\n          nativeNotification.priority = _channel.priority;\n          nativeNotification.vibrate = _channel.vibrate;\n        }\n        return ExponentNotifications.scheduleLocalNotification(nativeNotification, options);\n      }\n    }\n  },\n\n  /* Dismiss currently shown notification with ID (Android only) */\n  async dismissNotificationAsync(notificationId: LocalNotificationId): Promise<void> {\n    if (!ExponentNotifications.dismissNotification) {\n      throw new UnavailabilityError('Expo.Notifications', 'dismissNotification');\n    }\n    return await ExponentNotifications.dismissNotification(notificationId);\n  },\n\n  /* Dismiss all currently shown notifications (Android only) */\n  async dismissAllNotificationsAsync(): Promise<void> {\n    if (!ExponentNotifications.dismissAllNotifications) {\n      throw new UnavailabilityError('Expo.Notifications', 'dismissAllNotifications');\n    }\n    return await ExponentNotifications.dismissAllNotifications();\n  },\n\n  /* Cancel scheduled notification notification with ID */\n  cancelScheduledNotificationAsync(notificationId: LocalNotificationId): Promise<void> {\n    if (Platform.OS === 'android' && typeof notificationId === 'string') {\n      return ExponentNotifications.cancelScheduledNotificationWithStringIdAsync(notificationId);\n    }\n    return ExponentNotifications.cancelScheduledNotificationAsync(notificationId);\n  },\n\n  /* Cancel all scheduled notifications */\n  cancelAllScheduledNotificationsAsync(): Promise<void> {\n    return ExponentNotifications.cancelAllScheduledNotificationsAsync();\n  },\n\n  /* Primary public api */\n  addListener(listener: (notification: Notification) => unknown): EventSubscription {\n    const emitter = _getEventEmitter();\n\n    if (_initialNotification) {\n      const initialNotification = _initialNotification;\n      _initialNotification = null;\n      setTimeout(() => {\n        emitNotification(initialNotification);\n      }, 0);\n    }\n\n    return emitter.addListener('notification', listener);\n  },\n\n  async getBadgeNumberAsync(): Promise<number> {\n    if (!ExponentNotifications.getBadgeNumberAsync) {\n      return 0;\n    }\n    return ExponentNotifications.getBadgeNumberAsync();\n  },\n\n  async setBadgeNumberAsync(number: number): Promise<void> {\n    if (!ExponentNotifications.setBadgeNumberAsync) {\n      throw new UnavailabilityError('Expo.Notifications', 'setBadgeNumberAsync');\n    }\n    return ExponentNotifications.setBadgeNumberAsync(number);\n  },\n\n  async scheduleNotificationWithCalendarAsync(\n    notification: LocalNotification,\n    options: {\n      year?: number;\n      month?: number;\n      hour?: number;\n      day?: number;\n      minute?: number;\n      second?: number;\n      weekDay?: number;\n      repeat?: boolean;\n    } = {}\n  ): Promise<string> {\n    const areOptionsValid: boolean =\n      (options.month == null || isInRangeInclusive(options.month, 1, 12)) &&\n      (options.day == null || isInRangeInclusive(options.day, 1, 31)) &&\n      (options.hour == null || isInRangeInclusive(options.hour, 0, 23)) &&\n      (options.minute == null || isInRangeInclusive(options.minute, 0, 59)) &&\n      (options.second == null || isInRangeInclusive(options.second, 0, 59)) &&\n      (options.weekDay == null || isInRangeInclusive(options.weekDay, 1, 7)) &&\n      (options.weekDay == null || options.day == null);\n\n    if (!areOptionsValid) {\n      throw new CodedError(\n        'WRONG_OPTIONS',\n        'Options in scheduleNotificationWithCalendarAsync call were incorrect!'\n      );\n    }\n\n    _validateNotification(notification);\n    const nativeNotification = _processNotification(notification);\n\n    return ExponentNotifications.scheduleNotificationWithCalendar(nativeNotification, options);\n  },\n\n  async scheduleNotificationWithTimerAsync(\n    notification: LocalNotification,\n    options: {\n      interval: number;\n      repeat?: boolean;\n    }\n  ): Promise<string> {\n    if (options.interval < 1) {\n      throw new CodedError('WRONG_OPTIONS', 'Interval must be not less then 1');\n    }\n\n    _validateNotification(notification);\n    const nativeNotification = _processNotification(notification);\n\n    return ExponentNotifications.scheduleNotificationWithTimer(nativeNotification, options);\n  },\n};\n\nfunction isInRangeInclusive(variable: number, min: number, max: number): boolean {\n  return variable >= min && variable <= max;\n}\n"],"sourceRoot":""},"metadata":{},"sourceType":"module"}