{
  "version": 3,
  "sources": ["../../core-impl/src/plugins/push/pushchannel.ts", "../../core-impl/src/plugins/push/getW3CDeviceDetails.ts", "../../core-impl/src/plugins/push/pushactivation.ts", "../../core-impl/src/common/lib/types/errorinfo.ts", "../../core-impl/src/plugins/react-native-push/getReactNativePushDeviceDetails.ts", "../../core-impl/src/plugins/react-native-push/index.ts"],
  "sourcesContent": ["import type BaseClient from 'common/lib/client/baseclient';\nimport type RealtimeChannel from 'common/lib/client/realtimechannel';\nimport type HttpChannel from 'common/lib/client/httpchannel';\n\nclass PushChannel {\n  client: BaseClient;\n  channel: HttpChannel | RealtimeChannel;\n\n  constructor(channel: HttpChannel | RealtimeChannel) {\n    this.channel = channel;\n    this.client = channel.client;\n  }\n\n  async subscribeDevice() {\n    const client = this.client;\n    const device = await client.getDevice();\n    const format = client.options.useBinaryProtocol ? client.Utils.Format.msgpack : client.Utils.Format.json,\n      body = { deviceId: device.id, channel: this.channel.name },\n      headers = client.Defaults.defaultPostHeaders(client.options);\n\n    if (client.options.headers) client.Utils.mixin(headers, client.options.headers);\n\n    client.Utils.mixin(headers, this._getPushAuthHeaders(device));\n\n    const requestBody = client.Utils.encodeBody(body, client._MsgPack, format);\n    await client.http.Resource.post(client, '/push/channelSubscriptions', requestBody, headers, {}, format, true);\n  }\n\n  async unsubscribeDevice() {\n    const client = this.client;\n    const device = await client.getDevice();\n    const format = client.options.useBinaryProtocol ? client.Utils.Format.msgpack : client.Utils.Format.json,\n      headers = client.Defaults.defaultPostHeaders(client.options);\n\n    if (client.options.headers) client.Utils.mixin(headers, client.options.headers);\n\n    client.Utils.mixin(headers, this._getPushAuthHeaders(device));\n\n    await client.http.Resource.delete(\n      client,\n      '/push/channelSubscriptions',\n      headers,\n      { deviceId: device.id, channel: this.channel.name },\n      format,\n      true,\n    );\n  }\n\n  async subscribeClient() {\n    const client = this.client;\n    const clientId = this.client.auth.clientId;\n    if (!clientId) {\n      throw new this.client.ErrorInfo({\n        message: 'Cannot subscribe from client without client ID',\n        code: 50000,\n        statusCode: 500,\n        remediation:\n          'Set ClientOptions.clientId before calling pushChannel.subscribeClient(). On a realtime client, a clientId carried in the token also satisfies this once the connection has connected. On a REST client, only ClientOptions.clientId works.',\n      });\n    }\n    const format = client.options.useBinaryProtocol ? client.Utils.Format.msgpack : client.Utils.Format.json,\n      body = { clientId: clientId, channel: this.channel.name },\n      headers = client.Defaults.defaultPostHeaders(client.options);\n\n    if (client.options.headers) client.Utils.mixin(headers, client.options.headers);\n\n    const requestBody = client.Utils.encodeBody(body, client._MsgPack, format);\n    await client.http.Resource.post(client, '/push/channelSubscriptions', requestBody, headers, {}, format, true);\n  }\n\n  async unsubscribeClient() {\n    const client = this.client;\n\n    const clientId = this.client.auth.clientId;\n    if (!clientId) {\n      throw new this.client.ErrorInfo({\n        message: 'Cannot unsubscribe from client without client ID',\n        code: 50000,\n        statusCode: 500,\n        remediation:\n          'Set ClientOptions.clientId before calling pushChannel.unsubscribeClient(). On a realtime client, a clientId carried in the token also satisfies this once the connection has connected. On a REST client, only ClientOptions.clientId works.',\n      });\n    }\n    const format = client.options.useBinaryProtocol ? client.Utils.Format.msgpack : client.Utils.Format.json,\n      headers = client.Defaults.defaultPostHeaders(client.options);\n\n    if (client.options.headers) client.Utils.mixin(headers, client.options.headers);\n\n    await client.http.Resource.delete(\n      client,\n      '/push/channelSubscriptions',\n      headers,\n      { clientId: clientId, channel: this.channel.name },\n      format,\n      true,\n    );\n  }\n\n  async listSubscriptions(params?: Record<string, string>) {\n    this.client.Logger.logAction(\n      this.client.logger,\n      this.client.Logger.LOG_MICRO,\n      'PushChannel.listSubscriptions()',\n      'channel = ' + this.channel.name,\n    );\n\n    return this.client.push.admin.channelSubscriptions.list({\n      ...params,\n      channel: this.channel.name,\n      concatFilters: true,\n    });\n  }\n\n  private _getDeviceIdentityToken(device: Awaited<ReturnType<BaseClient['getDevice']>>) {\n    const deviceIdentityToken = device.deviceIdentityToken;\n    if (deviceIdentityToken) {\n      return deviceIdentityToken;\n    } else {\n      throw new this.client.ErrorInfo({\n        message: 'Cannot subscribe or unsubscribe this device without a deviceIdentityToken',\n        code: 50000,\n        statusCode: 500,\n        remediation: 'Activate this device first by awaiting client.push.activate().',\n      });\n    }\n  }\n\n  private _getPushAuthHeaders(device: Awaited<ReturnType<BaseClient['getDevice']>>) {\n    const deviceIdentityToken = this._getDeviceIdentityToken(device);\n    return { 'X-Ably-DeviceToken': deviceIdentityToken };\n  }\n}\n\nexport default PushChannel;\n", "import { ActivationStateMachine } from 'plugins/push/pushactivation';\n\nfunction toBase64Url(arrayBuffer: ArrayBuffer) {\n  const buffer = new Uint8Array(arrayBuffer.slice(0, arrayBuffer.byteLength));\n  return btoa(String.fromCharCode.apply(null, Array.from(buffer)));\n}\n\nfunction urlBase64ToBase64(base64String: string) {\n  const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n  const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/');\n  return base64;\n}\n\nfunction base64ToUint8Array(base64String: string) {\n  const rawData = window.atob(base64String);\n  const rawDataChars = [];\n  for (let i = 0; i < rawData.length; i++) {\n    rawDataChars.push(rawData[i].charCodeAt(0));\n  }\n  return Uint8Array.from(rawDataChars);\n}\n\nexport async function getW3CPushDeviceDetails(machine: ActivationStateMachine) {\n  const GettingPushDeviceDetailsFailed = machine.GettingPushDeviceDetailsFailed;\n  const GotPushDeviceDetails = machine.GotPushDeviceDetails;\n  const { ErrorInfo, Defaults } = machine.client;\n\n  const permission = await Notification.requestPermission();\n\n  if (permission !== 'granted') {\n    const err =\n      permission === 'denied'\n        ? new ErrorInfo({\n            message: 'User denied permission to send notifications: browser notification permission is \"denied\"',\n            code: 40000,\n            statusCode: 400,\n            remediation:\n              'Tell the user to re-enable notifications for this site in their browser settings, then call push.activate() again to retry registration. A re-request will not prompt while the permission stays \"denied\".',\n          })\n        : new ErrorInfo({\n            message:\n              'Notification permission prompt was dismissed without a choice: browser notification permission is \"default\"',\n            code: 40000,\n            statusCode: 400,\n            remediation:\n              'Surface UI explaining the value of notifications, then call push.activate() again to retry registration. The browser will show the permission prompt again.',\n          });\n    machine.handleEvent(new GettingPushDeviceDetailsFailed(err));\n    return;\n  }\n\n  const swUrl = machine.client.options.pushServiceWorkerUrl;\n  if (!swUrl) {\n    const err = new ErrorInfo({\n      message: 'Missing ClientOptions.pushServiceWorkerUrl',\n      code: 40000,\n      statusCode: 400,\n      remediation:\n        'Set ClientOptions.pushServiceWorkerUrl to the path of your service worker (e.g. \"/ably-push-sw.js\") so the SDK can register it for web push.',\n    });\n    machine.handleEvent(new GettingPushDeviceDetailsFailed(err));\n    return;\n  }\n\n  try {\n    const worker = await navigator.serviceWorker.register(swUrl);\n\n    machine._pushManager = worker.pushManager;\n\n    const headers = Defaults.defaultGetHeaders(machine.client.options, { format: 'text' });\n    const appServerKey = (\n      await machine.client.http.Resource.get(machine.client, '/push/publicVapidKey', headers, {}, null, true)\n    ).body as string;\n\n    if (!worker.active) {\n      await navigator.serviceWorker.ready;\n    }\n\n    const subscription = await worker.pushManager.subscribe({\n      userVisibleOnly: true,\n      applicationServerKey: base64ToUint8Array(urlBase64ToBase64(appServerKey)),\n    });\n\n    const endpoint = subscription.endpoint;\n\n    const [p256dh, auth] = [subscription.getKey('p256dh'), subscription.getKey('auth')];\n\n    if (!p256dh || !auth) {\n      throw new ErrorInfo('Public key not found', 50000, 500);\n    }\n\n    const device = await machine.client.getDevice();\n    device.push.recipient = {\n      transportType: 'web',\n      targetUrl: btoa(endpoint),\n      publicVapidKey: appServerKey,\n      encryptionKey: {\n        p256dh: toBase64Url(p256dh),\n        auth: toBase64Url(auth),\n      },\n    };\n    device.persist();\n\n    machine.handleEvent(new GotPushDeviceDetails());\n  } catch (err) {\n    machine.handleEvent(\n      new GettingPushDeviceDetailsFailed(\n        new ErrorInfo('Failed to register service worker: ' + (err as Error).message, 50000, 500),\n      ),\n    );\n  }\n}\n", "import * as API from '@ably/pubsub-core/api';\nimport { IPlatformPushConfig } from 'common/types/IPlatformConfig';\nimport { ulid } from 'ulid';\nimport type { ErrCallback, StandardCallback } from 'common/types/utils';\nimport type ErrorInfo from 'common/lib/types/errorinfo';\nimport DeviceDetails, { DevicePlatform, DevicePushDetails } from 'common/lib/types/devicedetails';\nimport type PushChannelSubscription from 'common/lib/types/pushchannelsubscription';\nimport { getW3CPushDeviceDetails } from './getW3CDeviceDetails';\nimport type BaseClient from 'common/lib/client/baseclient';\nimport type { PaginatedResult } from 'common/lib/client/paginatedresource';\n\n// Keep this byte-identical to the copy in src/common/lib/client/push.ts. This plugin only\n// type-imports from common client modules, so a value import from there is not viable for the build.\nconst PUSH_ACTIVATION_NOT_AVAILABLE_HINT =\n  'Run push.activate() in a browser environment with service worker support, or in React Native using the ably/react-native-push plugin. From a server, use client.push.admin instead. Call client.push.admin.publish(recipient, payload) to send to a device or clientId. Call client.push.admin.deviceRegistrations.save(device) to register a device record.';\n\nconst persistKeys = {\n  deviceId: 'ably.push.deviceId',\n  deviceSecret: 'ably.push.deviceSecret',\n  deviceIdentityToken: 'ably.push.deviceIdentityToken',\n  pushRecipient: 'ably.push.pushRecipient',\n  activationState: 'ably.push.activationState',\n};\n\ntype DeviceRegistration = Required<{\n  [K in keyof DeviceDetails]: K extends 'deviceIdentityToken' ? API.TokenDetails : DeviceDetails[K];\n}>;\n\nexport type RegisterCallback = (device: DeviceDetails, callback: StandardCallback<DeviceRegistration>) => void;\nexport type DeregisterCallback = (device: DeviceDetails, callback: StandardCallback<string>) => void;\n\nexport interface LocalDeviceAuthDetails {\n  headers: Record<string, string>;\n  params: Record<string, unknown>;\n}\n\nexport type LocalDeviceFactory = ReturnType<typeof localDeviceFactory>;\nexport type LocalDevice = ReturnType<LocalDeviceFactory['load']>;\n\n/**\n * Push storage writes may be asynchronous (e.g. React Native's AsyncStorage). Several write sites\n * sit inside synchronous state-machine code and cannot await the result, so a logging rejection\n * handler is pre-attached: ignoring the returned promise never causes an unhandled rejection. The\n * returned promise itself still rejects, so asynchronous callers that await persistence observe\n * the failure.\n */\nfunction loggedStorageWrites(client: BaseClient, op: string, writes: (void | Promise<void>)[]): void | Promise<void> {\n  const promises = writes.filter((result): result is Promise<void> => !!result && typeof result.then === 'function');\n  if (promises.length === 0) {\n    return;\n  }\n  const allWritten = Promise.all(promises).then(() => {});\n  allWritten.catch((err) => {\n    client.Logger.logAction(\n      client.logger,\n      client.Logger.LOG_ERROR,\n      'Push.' + op,\n      'failed to persist push state to storage: ' + client.Utils.inspectError(err),\n    );\n  });\n  return allWritten;\n}\n\n/**\n * LocalDevice extends DeviceDetails, but DeviceDetails is part of core ably-js and LocalDevice is part of the Push plugin\n * In order to avoid bundling the DeviceDetails class in both core ably-js and the plugin, the LocalDevice is exported as\n * a factory, and the DeviceDetails constructor is used to create the class declaration for LocalDevice when the plugin is\n * loaded.\n */\nexport function localDeviceFactory(deviceDetails: typeof DeviceDetails) {\n  return class LocalDevice extends deviceDetails {\n    // guaranteed to be set in the .loadPersisted() method\n    declare id: string;\n    declare deviceSecret: string;\n\n    http: BaseClient;\n    push: DevicePushDetails;\n\n    private constructor(http: BaseClient) {\n      super();\n      this.push = {};\n      this.http = http;\n    }\n\n    static load(http: BaseClient) {\n      const device = new LocalDevice(http);\n      device.loadPersisted();\n      return device;\n    }\n\n    static async loadAsync(http: BaseClient) {\n      const device = new LocalDevice(http);\n      await device.loadPersistedAsync();\n      return device;\n    }\n\n    async listSubscriptions(): Promise<PaginatedResult<PushChannelSubscription>> {\n      if (!this.http.pushConfig) {\n        throw new this.http.ErrorInfo({\n          message:\n            'Push activation is not available on this platform: it requires a browser environment with service worker support, or a React Native environment with the ably/react-native-push plugin',\n          code: 40000,\n          statusCode: 400,\n          remediation: PUSH_ACTIVATION_NOT_AVAILABLE_HINT,\n        });\n      }\n\n      if (!this.id) {\n        throw new this.http.ErrorInfo({\n          message: 'Device not activated',\n          code: 40000,\n          statusCode: 400,\n          remediation: 'Call client.push.activate() and await its completion before listing subscriptions.',\n        });\n      }\n\n      if (!this.deviceIdentityToken) {\n        throw new this.http.ErrorInfo('Cannot list device subscriptions without deviceIdentityToken', 50000, 500);\n      }\n\n      const client = this.http,\n        format = client.options.useBinaryProtocol ? client.Utils.Format.msgpack : client.Utils.Format.json,\n        envelope = client.httpRequester.supportsLinkHeaders ? undefined : format,\n        headers = client.Defaults.defaultGetHeaders(client.options);\n\n      client.Utils.mixin(headers, client.options.headers, { 'X-Ably-DeviceToken': this.deviceIdentityToken });\n\n      return new client.http.PaginatedResource(client, '/push/channelSubscriptions', headers, envelope, async function (\n        body,\n        headers,\n        unpacked,\n      ) {\n        return client.http.PushChannelSubscription.fromResponseBody(\n          body as Record<string, unknown>[],\n          client._MsgPack,\n          unpacked ? undefined : format,\n        );\n      }).get({ deviceId: this.id });\n    }\n\n    // keep in sync with loadPersistedAsync()\n    loadPersisted() {\n      const pushConfig = this.http.pushConfig;\n      if (!pushConfig) {\n        throw new this.http.ErrorInfo({\n          message:\n            'Push activation is not available on this platform: it requires a browser environment with service worker support, or a React Native environment with the ably/react-native-push plugin',\n          code: 40000,\n          statusCode: 400,\n          remediation: PUSH_ACTIVATION_NOT_AVAILABLE_HINT,\n        });\n      }\n      if (pushConfig.storageIsAsync) {\n        throw new this.http.ErrorInfo({\n          message: 'The local device cannot be loaded synchronously: push storage on this platform is asynchronous',\n          code: 40000,\n          statusCode: 400,\n          remediation: 'Use await client.getDevice(), which loads the local device from asynchronous storage.',\n        });\n      }\n      this.platform = pushConfig.platform;\n      this.clientId = this.http.auth.clientId ?? undefined;\n      this.formFactor = pushConfig.formFactor;\n      // this path is only reachable with synchronous storage (async storage implies storageIsAsync,\n      // which routes callers to getDevice() and the async load path), so the reads are cast to string\n      this.id = pushConfig.storage.get(persistKeys.deviceId) as string;\n\n      if (this.id) {\n        this.deviceSecret = pushConfig.storage.get(persistKeys.deviceSecret) as string;\n        this.deviceIdentityToken = JSON.parse(\n          (pushConfig.storage.get(persistKeys.deviceIdentityToken) as string) || 'null',\n        );\n        this.push.recipient = JSON.parse((pushConfig.storage.get(persistKeys.pushRecipient) as string) || 'null');\n      } else {\n        this.resetId();\n      }\n    }\n\n    // keep in sync with loadPersisted(); awaiting a non-promise is a no-op, so this single\n    // implementation serves both synchronous (web) and asynchronous (React Native) storage\n    async loadPersistedAsync() {\n      const pushConfig = this.http.pushConfig;\n      if (!pushConfig) {\n        throw new this.http.ErrorInfo({\n          message:\n            'Push activation is not available on this platform: it requires a browser environment with service worker support, or a React Native environment with the ably/react-native-push plugin',\n          code: 40000,\n          statusCode: 400,\n          remediation: PUSH_ACTIVATION_NOT_AVAILABLE_HINT,\n        });\n      }\n      this.platform = pushConfig.platform;\n      this.clientId = this.http.auth.clientId ?? undefined;\n      this.formFactor = pushConfig.formFactor;\n      this.id = ((await pushConfig.storage.get(persistKeys.deviceId)) ?? undefined) as string;\n\n      if (this.id) {\n        this.deviceSecret = ((await pushConfig.storage.get(persistKeys.deviceSecret)) ?? undefined) as string;\n        this.deviceIdentityToken = JSON.parse(\n          (await pushConfig.storage.get(persistKeys.deviceIdentityToken)) || 'null',\n        );\n        this.push.recipient = JSON.parse((await pushConfig.storage.get(persistKeys.pushRecipient)) || 'null');\n      } else {\n        await this.resetId();\n      }\n    }\n\n    persist(): void | Promise<void> {\n      const pushConfig = this.http.pushConfig;\n      if (!pushConfig) {\n        throw new this.http.ErrorInfo({\n          message:\n            'Push activation is not available on this platform: it requires a browser environment with service worker support, or a React Native environment with the ably/react-native-push plugin',\n          code: 40000,\n          statusCode: 400,\n          remediation: PUSH_ACTIVATION_NOT_AVAILABLE_HINT,\n        });\n      }\n      const writes: (void | Promise<void>)[] = [];\n      if (this.id) {\n        writes.push(pushConfig.storage.set(persistKeys.deviceId, this.id));\n      }\n      if (this.deviceSecret) {\n        writes.push(pushConfig.storage.set(persistKeys.deviceSecret, this.deviceSecret));\n      }\n      if (this.deviceIdentityToken) {\n        writes.push(pushConfig.storage.set(persistKeys.deviceIdentityToken, JSON.stringify(this.deviceIdentityToken)));\n      }\n      if (this.push.recipient) {\n        writes.push(pushConfig.storage.set(persistKeys.pushRecipient, JSON.stringify(this.push.recipient)));\n      }\n      return loggedStorageWrites(this.http, 'LocalDevice.persist()', writes);\n    }\n\n    resetId(): void | Promise<void> {\n      this.id = ulid();\n      this.deviceSecret = ulid();\n      return this.persist();\n    }\n\n    getAuthDetails(\n      http: BaseClient,\n      headers: Record<string, string>,\n      params: Record<string, unknown>,\n    ): LocalDeviceAuthDetails {\n      if (!this.deviceIdentityToken) {\n        throw new this.http.ErrorInfo('Unable to update device registration; no deviceIdentityToken', 50000, 500);\n      }\n      if (this.http.httpRequester.supportsAuthHeaders) {\n        return {\n          headers: http.Utils.mixin(\n            { authorization: 'Bearer ' + http.Utils.toBase64(this.deviceIdentityToken) },\n            headers,\n          ) as Record<string, string>,\n          params,\n        };\n      } else {\n        return { headers, params: http.Utils.mixin({ access_token: this.deviceIdentityToken }, params) };\n      }\n    }\n  };\n}\n\nexport class ActivationStateMachine {\n  client: BaseClient;\n  // set in the constructor with synchronous storage, or by ensureInitialized() with asynchronous storage\n  current!: ActivationState;\n  private _initPromise?: Promise<void>;\n  // serializes asynchronous activation-state writes; see persist()\n  private _activationStateWrite: Promise<void> = Promise.resolve();\n  pendingEvents: ActivationEvent[];\n  handling: boolean;\n  deactivatedCallback?: ErrCallback;\n  activatedCallback?: ErrCallback;\n  _pushConfig?: IPlatformPushConfig;\n  registerCallback?: RegisterCallback;\n  deregisterCallback?: DeregisterCallback;\n  updateFailedCallback?: ErrCallback;\n\n  // Used for testing\n  _pushManager?: PushManager;\n\n  // exported for testing\n  GettingPushDeviceDetailsFailed = GettingPushDeviceDetailsFailed;\n  GotPushDeviceDetails = GotPushDeviceDetails;\n\n  constructor(http: BaseClient) {\n    this.client = http;\n    this._pushConfig = http.pushConfig;\n    if (!this._pushConfig?.storageIsAsync) {\n      // synchronous storage: resolve the persisted activation state immediately. With\n      // asynchronous storage the state is resolved by ensureInitialized() instead.\n      this.current = new ActivationStates[\n        (this.pushConfig.storage.get(persistKeys.activationState) as string as ActivationStateName) || 'NotActivated'\n      ](null);\n    }\n    this.pendingEvents = [];\n    this.handling = false;\n  }\n\n  /**\n   * Resolves the persisted activation state when storage is asynchronous. Must be awaited\n   * before the first handleEvent() call; a no-op with synchronous storage, where the\n   * constructor has already resolved the state.\n   */\n  async ensureInitialized(): Promise<void> {\n    if (this.current) {\n      return;\n    }\n    this._initPromise ??= (async () => {\n      try {\n        const persistedName = (await this.pushConfig.storage.get(persistKeys.activationState)) as string | null;\n        this.current = new ActivationStates[(persistedName as ActivationStateName) || 'NotActivated'](null);\n      } catch (err) {\n        // drop the failed read so a later activation attempt can retry after a transient storage failure\n        this._initPromise = undefined;\n        throw err;\n      }\n    })();\n    return this._initPromise;\n  }\n\n  get pushConfig() {\n    if (!this._pushConfig) {\n      throw new this.client.ErrorInfo({\n        message:\n          'This platform is not supported as a target of push notifications: push activation requires a browser environment with service worker support, or a React Native environment with the ably/react-native-push plugin',\n        code: 40000,\n        statusCode: 400,\n        remediation: PUSH_ACTIVATION_NOT_AVAILABLE_HINT,\n      });\n    }\n    return this._pushConfig;\n  }\n\n  persist() {\n    if (!(this.current && isPersistentState(this.current))) {\n      return;\n    }\n    const name = this.current.name;\n    if (this.pushConfig.storageIsAsync) {\n      // chain asynchronous writes so an earlier slow write cannot complete after a later\n      // transition and restore stale activation state. Failures are logged by\n      // loggedStorageWrites; the queue swallows them so subsequent writes still run.\n      this._activationStateWrite = this._activationStateWrite\n        .then(() =>\n          loggedStorageWrites(this.client, 'ActivationStateMachine.persist()', [\n            this.pushConfig.storage.set(persistKeys.activationState, name),\n          ]),\n        )\n        .catch(() => {});\n    } else {\n      loggedStorageWrites(this.client, 'ActivationStateMachine.persist()', [\n        this.pushConfig.storage.set(persistKeys.activationState, name),\n      ]);\n    }\n  }\n\n  callUpdateRegistrationFailedCallback(reason: ErrorInfo) {\n    if (this.updateFailedCallback) {\n      this.updateFailedCallback(reason);\n    } else {\n      this.client.Logger.logAction(\n        this.client.logger,\n        this.client.Logger.LOG_ERROR,\n        'UpdateRegistrationFailed',\n        'Failed updating device push registration: ' + this.client.Utils.inspectError(reason),\n      );\n    }\n  }\n\n  callCustomRegisterer(device: LocalDevice, isNew: boolean) {\n    this.registerCallback?.(device, (error: ErrorInfo, deviceRegistration?: DeviceRegistration) => {\n      if (error) {\n        if (isNew) {\n          this.handleEvent(new GettingDeviceRegistrationFailed(error));\n        } else {\n          this.handleEvent(new SyncRegistrationFailed(error));\n        }\n        return;\n      }\n\n      if (!deviceRegistration) {\n        const err = new this.client.ErrorInfo({\n          message: 'registerCallback did not return deviceRegistration',\n          code: 40000,\n          statusCode: 400,\n          remediation: 'Your registerCallback must invoke its callback with (null, deviceRegistration).',\n        });\n        this.handleEvent(new GettingDeviceRegistrationFailed(err));\n        return;\n      }\n\n      if (isNew) {\n        this.handleEvent(new GotDeviceRegistration(deviceRegistration as any));\n      } else {\n        this.handleEvent(new RegistrationSynced());\n      }\n    });\n  }\n\n  callCustomDeregisterer(device: LocalDevice) {\n    this.deregisterCallback?.(device, (err: ErrorInfo) => {\n      if (err) {\n        this.handleEvent(new DeregistrationFailed(err));\n        return;\n      }\n      this.handleEvent(new Deregistered());\n    });\n  }\n\n  async updateRegistration() {\n    const localDevice = await this.client.getDevice();\n    if (this.registerCallback) {\n      this.callCustomRegisterer(localDevice, false);\n    } else {\n      const client = this.client;\n      const format = client.options.useBinaryProtocol\n          ? this.client.Utils.Format.msgpack\n          : this.client.Utils.Format.json,\n        body = { push: { recipient: localDevice.push.recipient } },\n        headers = this.client.Defaults.defaultPostHeaders(this.client.options, { format }),\n        params = {};\n\n      if (client.options.headers) {\n        this.client.Utils.mixin(headers, client.options.headers);\n      }\n\n      if (client.options.pushFullWait) {\n        this.client.Utils.mixin(params, { fullWait: 'true' });\n      }\n\n      const requestBody = this.client.Utils.encodeBody(body, client._MsgPack, format);\n      const authDetails = localDevice.getAuthDetails(client, headers, params);\n      try {\n        await this.client.http.Resource.patch(\n          client,\n          '/push/deviceRegistrations/' + encodeURIComponent(localDevice.id),\n          requestBody,\n          authDetails.headers,\n          authDetails.params,\n          format,\n          true,\n        );\n        this.handleEvent(new RegistrationSynced());\n      } catch (err) {\n        this.handleEvent(new SyncRegistrationFailed(err as ErrorInfo));\n      }\n    }\n  }\n\n  async deregister() {\n    const device = await this.client.getDevice();\n    if (this.deregisterCallback) {\n      this.callCustomDeregisterer(device);\n    } else {\n      const http = this.client;\n      const format = http.options.useBinaryProtocol ? this.client.Utils.Format.msgpack : this.client.Utils.Format.json,\n        headers = this.client.Defaults.defaultPostHeaders(http.options),\n        params = { deviceId: device.id };\n\n      if (http.options.headers) this.client.Utils.mixin(headers, http.options.headers);\n\n      const authDetails = device.getAuthDetails(this.client, headers, params);\n\n      if (http.options.pushFullWait) this.client.Utils.mixin(params, { fullWait: 'true' });\n\n      try {\n        await this.client.http.Resource.delete(\n          http,\n          '/push/deviceRegistrations',\n          authDetails.headers,\n          authDetails.params,\n          format,\n          true,\n        );\n        this.handleEvent(new Deregistered());\n      } catch (err) {\n        this.handleEvent(new DeregistrationFailed(err as ErrorInfo));\n      }\n    }\n  }\n\n  callActivatedCallback(err: ErrorInfo | null) {\n    this.activatedCallback?.(err);\n    delete this.activatedCallback;\n  }\n\n  callDeactivatedCallback(err: ErrorInfo | null) {\n    this.deactivatedCallback?.(err);\n    delete this.deactivatedCallback;\n  }\n\n  handleEvent(event: ActivationEvent) {\n    if (this.handling) {\n      this.client.Platform.Config.nextTick(() => {\n        this.handleEvent(event);\n      });\n      return;\n    }\n\n    this.handling = true;\n    this.client.Logger.logAction(\n      this.client.logger,\n      this.client.Logger.LOG_MAJOR,\n      'Push.ActivationStateMachine.handleEvent()',\n      'handling event ' + event.name + ' from ' + this.current.name,\n    );\n\n    let maybeNext = this.current.processEvent(this, event);\n    if (!maybeNext) {\n      this.client.Logger.logAction(\n        this.client.logger,\n        this.client.Logger.LOG_MAJOR,\n        'Push.ActivationStateMachine.handleEvent()',\n        'enqueing event: ' + event.name,\n      );\n      this.pendingEvents.push(event);\n      this.handling = false;\n      return;\n    }\n\n    this.client.Logger.logAction(\n      this.client.logger,\n      this.client.Logger.LOG_MAJOR,\n      'Push.ActivationStateMachine.handleEvent()',\n      'transition: ' + this.current.name + ' -(' + event.name + ')-> ' + maybeNext.name,\n    );\n    this.current = maybeNext;\n\n    while (this.pendingEvents.length > 0) {\n      const pending = this.pendingEvents[0];\n\n      this.client.Logger.logAction(\n        this.client.logger,\n        this.client.Logger.LOG_MAJOR,\n        'Push.ActivationStateMachine.handleEvent()',\n        'attempting to consume pending event: ' + pending.name,\n      );\n\n      maybeNext = this.current.processEvent(this, pending);\n      if (!maybeNext) {\n        break;\n      }\n      this.pendingEvents.splice(0, 1);\n\n      this.client.Logger.logAction(\n        this.client.logger,\n        this.client.Logger.LOG_MAJOR,\n        'Push.ActivationStateMachine.handleEvent()',\n        'transition: ' + this.current.name + ' -(' + pending.name + ')-> ' + maybeNext.name,\n      );\n      this.current = maybeNext;\n    }\n\n    this.persist();\n    this.handling = false;\n  }\n}\n\n// Events\nexport class CalledActivate {\n  name = 'CalledActivate';\n\n  constructor(machine: ActivationStateMachine, registerCallback?: RegisterCallback) {\n    if (registerCallback) {\n      machine.registerCallback = registerCallback;\n    }\n    machine.persist();\n  }\n}\n\nexport class CalledDeactivate {\n  name = 'CalledDeactivate';\n\n  constructor(machine: ActivationStateMachine, deregisterCallback?: DeregisterCallback) {\n    machine.deregisterCallback = deregisterCallback;\n    machine.persist();\n  }\n}\n\nexport class GotPushDeviceDetails {\n  name = 'GotPushDeviceDetails';\n}\n\nexport class GettingPushDeviceDetailsFailed {\n  name = 'GettingPushDeviceDetailsFailed';\n  reason: ErrorInfo;\n\n  constructor(reason: ErrorInfo) {\n    this.reason = reason;\n  }\n}\n\nclass GotDeviceRegistration {\n  name = 'GotDeviceRegistration';\n  tokenDetails: API.TokenDetails;\n\n  constructor(deviceRegistration: DeviceRegistration) {\n    this.tokenDetails = deviceRegistration.deviceIdentityToken;\n  }\n}\n\nclass GettingDeviceRegistrationFailed {\n  name = 'GettingDeviceRegistrationFailed';\n  reason: ErrorInfo;\n  constructor(reason: ErrorInfo) {\n    this.reason = reason;\n  }\n}\n\nclass RegistrationSynced {\n  name = 'RegistrationSynced';\n}\n\nclass SyncRegistrationFailed {\n  name = 'SyncRegistrationFailed';\n  reason: ErrorInfo;\n\n  constructor(reason: ErrorInfo) {\n    this.reason = reason;\n  }\n}\n\nclass Deregistered {\n  name = 'Deregistered';\n}\n\nclass DeregistrationFailed {\n  name = 'DeregistrationFailed';\n  reason: ErrorInfo;\n  constructor(reason: ErrorInfo) {\n    this.reason = reason;\n  }\n}\n\ntype ActivationEvent =\n  | CalledActivate\n  | CalledDeactivate\n  | GotPushDeviceDetails\n  | GettingPushDeviceDetailsFailed\n  | GotDeviceRegistration\n  | GettingDeviceRegistrationFailed\n  | RegistrationSynced\n  | SyncRegistrationFailed\n  | Deregistered\n  | DeregistrationFailed;\n\n// States\n//\n// Invariant: processEvent() implementations are synchronous and read the local device via the\n// synchronous machine.client.deviceSync(). This relies on Push.activate()/deactivate() pre-hydrating\n// the device (await client.getDevice()) and the machine state (await ensureInitialized()) before\n// dispatching any event. Never add a device() call reachable before that hydration has happened.\nabstract class ActivationState {\n  name: ActivationStateName;\n\n  constructor(name: ActivationStateName) {\n    this.name = name;\n  }\n\n  abstract processEvent(machine: ActivationStateMachine, event: ActivationEvent): ActivationState | null;\n}\n\nclass NotActivated extends ActivationState {\n  constructor() {\n    super('NotActivated');\n  }\n\n  processEvent(machine: ActivationStateMachine, event: ActivationEvent): ActivationState | null {\n    if (event instanceof CalledDeactivate) {\n      machine.callDeactivatedCallback(null);\n      return new NotActivated();\n    } else if (event instanceof CalledActivate) {\n      const device = machine.client.deviceSync();\n\n      if (device.deviceIdentityToken != null) {\n        if (device.clientId && device.clientId !== machine.client.auth.clientId) {\n          machine.handleEvent(\n            new SyncRegistrationFailed(\n              new machine.client.ErrorInfo('clientId not compatible with local device clientId', 61002, 400),\n            ),\n          );\n          return null;\n        }\n        // Already registered.\n        machine.pendingEvents.push(event);\n        return new WaitingForNewPushDeviceDetails();\n      }\n\n      if (device.push.recipient) {\n        machine.pendingEvents.push(new GotPushDeviceDetails());\n      } else if (machine.pushConfig.getPushDeviceDetails) {\n        machine.pushConfig.getPushDeviceDetails?.(machine);\n      } else if (machine.pushConfig.platform === DevicePlatform.Browser) {\n        getW3CPushDeviceDetails(machine);\n      } else {\n        machine.handleEvent(\n          new GettingPushDeviceDetailsFailed(\n            new machine.client.ErrorInfo('No available implementation to get push device details', 50000, 500),\n          ),\n        );\n      }\n\n      return new WaitingForPushDeviceDetails();\n    } else if (event instanceof GotPushDeviceDetails) {\n      return new NotActivated();\n    }\n    return null;\n  }\n}\n\nclass WaitingForPushDeviceDetails extends ActivationState {\n  constructor() {\n    super('WaitingForPushDeviceDetails');\n  }\n\n  processEvent(machine: ActivationStateMachine, event: ActivationEvent) {\n    if (event instanceof CalledActivate) {\n      return new WaitingForPushDeviceDetails();\n    } else if (event instanceof CalledDeactivate) {\n      machine.callDeactivatedCallback(null);\n      return new NotActivated();\n    } else if (event instanceof GotPushDeviceDetails) {\n      const client = machine.client;\n      const device = client.deviceSync();\n\n      if (machine.registerCallback) {\n        machine.callCustomRegisterer(device, true);\n      } else {\n        const format = client.options.useBinaryProtocol\n            ? machine.client.Utils.Format.msgpack\n            : machine.client.Utils.Format.json,\n          body = client.http.DeviceDetails.fromLocalDevice(device),\n          headers = machine.client.Defaults.defaultPostHeaders(client.options, { format }),\n          params = {};\n\n        if (client.options.headers) machine.client.Utils.mixin(headers, client.options.headers);\n\n        if (client.options.pushFullWait) machine.client.Utils.mixin(params, { fullWait: 'true' });\n\n        const requestBody = machine.client.Utils.encodeBody(body, client._MsgPack, format);\n\n        machine.client.http.Resource.post(client, '/push/deviceRegistrations', requestBody, headers, params, null, true)\n          .then((response) => {\n            const deviceDetails = response.unpacked\n              ? response.body\n              : client.http.DeviceDetails.fromResponseBody(response.body as any, client._MsgPack, format);\n            machine.handleEvent(new GotDeviceRegistration(deviceDetails as DeviceRegistration));\n          })\n          .catch((err) => {\n            machine.handleEvent(new GettingDeviceRegistrationFailed(err as ErrorInfo));\n          });\n      }\n\n      return new WaitingForDeviceRegistration();\n    } else if (event instanceof GettingPushDeviceDetailsFailed) {\n      machine.callActivatedCallback(event.reason);\n      return new NotActivated();\n    }\n    return null;\n  }\n}\n\nclass WaitingForDeviceRegistration extends ActivationState {\n  constructor() {\n    super('WaitingForDeviceRegistration');\n  }\n\n  processEvent(machine: ActivationStateMachine, event: ActivationEvent) {\n    if (event instanceof CalledActivate) {\n      return new WaitingForDeviceRegistration();\n    } else if (event instanceof GotDeviceRegistration) {\n      const device = machine.client.deviceSync();\n      device.deviceIdentityToken = event.tokenDetails.token;\n      device.persist();\n      machine.callActivatedCallback(null);\n      return new WaitingForNewPushDeviceDetails();\n    } else if (event instanceof GettingDeviceRegistrationFailed) {\n      machine.callActivatedCallback(event.reason);\n      return new NotActivated();\n    }\n    return null;\n  }\n}\n\nclass WaitingForNewPushDeviceDetails extends ActivationState {\n  constructor() {\n    super('WaitingForNewPushDeviceDetails');\n  }\n\n  processEvent(machine: ActivationStateMachine, event: ActivationEvent) {\n    if (event instanceof CalledActivate) {\n      machine.callActivatedCallback(null);\n      return new WaitingForNewPushDeviceDetails();\n    } else if (event instanceof CalledDeactivate) {\n      machine.deregister();\n      return new WaitingForDeregistration(this);\n    } else if (event instanceof GotPushDeviceDetails) {\n      machine.updateRegistration();\n      return new WaitingForRegistrationSync();\n    }\n    return null;\n  }\n}\n\nclass WaitingForRegistrationSync extends ActivationState {\n  triggeredByCalledActivate: boolean | null;\n\n  constructor(triggeredByCalledActivate: boolean | null = false) {\n    super('WaitingForRegistrationSync');\n    this.triggeredByCalledActivate = triggeredByCalledActivate;\n  }\n\n  processEvent(machine: ActivationStateMachine, event: ActivationEvent) {\n    if (event instanceof CalledActivate && !this.triggeredByCalledActivate) {\n      machine.callActivatedCallback(null);\n      return new WaitingForRegistrationSync(true);\n    } else if (event instanceof RegistrationSynced) {\n      return new WaitingForNewPushDeviceDetails();\n    } else if (event instanceof SyncRegistrationFailed) {\n      machine.callUpdateRegistrationFailedCallback(event.reason);\n      return new AfterRegistrationSyncFailed();\n    }\n    return null;\n  }\n}\n\nclass AfterRegistrationSyncFailed extends ActivationState {\n  constructor() {\n    super('AfterRegistrationSyncFailed');\n  }\n\n  processEvent(machine: ActivationStateMachine, event: ActivationEvent) {\n    if (event instanceof CalledActivate || event instanceof GotPushDeviceDetails) {\n      machine.updateRegistration();\n      return new WaitingForRegistrationSync(event instanceof CalledActivate);\n    } else if (event instanceof CalledDeactivate) {\n      machine.deregister();\n      return new WaitingForDeregistration(this);\n    }\n    return null;\n  }\n}\n\nclass WaitingForDeregistration extends ActivationState {\n  previousState: ActivationState | null;\n\n  constructor(previousState: ActivationState | null) {\n    super('WaitingForDeregistration');\n    this.previousState = previousState;\n  }\n\n  processEvent(machine: ActivationStateMachine, event: ActivationEvent): ActivationState | null {\n    if (event instanceof CalledDeactivate) {\n      return new WaitingForDeregistration(this.previousState);\n    } else if (event instanceof Deregistered) {\n      const device = machine.client.deviceSync();\n      delete device.deviceIdentityToken;\n      delete device.push.recipient;\n      loggedStorageWrites(machine.client, 'WaitingForDeregistration.processEvent()', [\n        machine.pushConfig.storage.remove(persistKeys.deviceIdentityToken),\n        machine.pushConfig.storage.remove(persistKeys.pushRecipient),\n      ]);\n      device.resetId();\n      machine.callDeactivatedCallback(null);\n      return new NotActivated();\n    } else if (event instanceof DeregistrationFailed) {\n      machine.callDeactivatedCallback(event.reason);\n      return this.previousState;\n    }\n    return null;\n  }\n}\n\ntype ActivationStateName =\n  | 'NotActivated'\n  | 'WaitingForPushDeviceDetails'\n  | 'WaitingForDeviceRegistration'\n  | 'WaitingForNewPushDeviceDetails'\n  | 'WaitingForRegistrationSync'\n  | 'AfterRegistrationSyncFailed'\n  | 'WaitingForDeregistration';\n\nexport const ActivationStates = {\n  NotActivated,\n  WaitingForPushDeviceDetails,\n  WaitingForDeviceRegistration,\n  WaitingForNewPushDeviceDetails,\n  WaitingForRegistrationSync,\n  AfterRegistrationSyncFailed,\n  WaitingForDeregistration,\n};\n\nfunction isPersistentState(state: ActivationState) {\n  return state.name == 'NotActivated' || state.name == 'WaitingForNewPushDeviceDetails';\n}\n", "// ErrorInfo and PartialErrorInfo live in the core's runtime (packages/core/src/errorinfo.ts), so that\n// there is one copy of each shared with the SDKs layered on Pub/Sub. Re-exported here so the\n// implementation keeps one import path.\nexport { ErrorInfo as default, PartialErrorInfo } from '@ably/pubsub-core';\nexport type {\n  IPartialErrorInfo,\n  IConvertibleToErrorInfo,\n  IConvertibleToPartialErrorInfo,\n  ErrorInfoValues,\n  PartialErrorInfoValues,\n} from '@ably/pubsub-core';\n", "import type { ActivationStateMachine } from '../push/pushactivation';\nimport type { ReactNativePushToken } from './index';\n\n/**\n * React Native equivalent of getW3CPushDeviceDetails: obtains a push token via the user-supplied\n * requestToken callback, records it as the device's push recipient and hands control back to the\n * activation state machine. Invoked by the state machine through the push config's\n * getPushDeviceDetails hook.\n */\nexport async function getReactNativePushDeviceDetails(\n  machine: ActivationStateMachine,\n  requestToken: () => Promise<ReactNativePushToken>,\n): Promise<void> {\n  const { ErrorInfo } = machine.client;\n  try {\n    const result = await requestToken();\n    if (\n      !result ||\n      (result.transportType !== 'fcm' && result.transportType !== 'apns') ||\n      typeof result.token !== 'string' ||\n      result.token.length === 0\n    ) {\n      throw new TypeError(\n        \"requestToken must return { transportType: 'fcm' | 'apns', token } with a non-empty token string\",\n      );\n    }\n    const { transportType, token } = result;\n    const device = await machine.client.getDevice();\n    device.push.recipient =\n      transportType === 'apns'\n        ? { transportType: 'apns', deviceToken: token }\n        : { transportType: 'fcm', registrationToken: token };\n    await device.persist();\n    machine.handleEvent(new machine.GotPushDeviceDetails());\n  } catch (err) {\n    machine.handleEvent(\n      new machine.GettingPushDeviceDetailsFailed(\n        new ErrorInfo('Failed to get react-native push device details: ' + (err as Error).message, 50000, 500),\n      ),\n    );\n  }\n}\n", "import PushChannel from '../push/pushchannel';\nimport { getW3CPushDeviceDetails } from '../push/getW3CDeviceDetails';\nimport { ActivationStateMachine, CalledActivate, CalledDeactivate, localDeviceFactory } from '../push/pushactivation';\nimport { DeviceFormFactor, DevicePlatform } from 'common/lib/types/devicedetails';\nimport type { IPlatformPushConfig } from 'common/types/IPlatformConfig';\nimport { getReactNativePushDeviceDetails } from './getReactNativePushDeviceDetails';\n\n/**\n * Asynchronous key-value storage used to persist push activation state. Matches the interface of\n * `@react-native-async-storage/async-storage`, so its default export can be passed directly.\n */\nexport interface ReactNativePushStorage {\n  getItem(key: string): Promise<string | null>;\n  setItem(key: string, value: string): Promise<void>;\n  removeItem(key: string): Promise<void>;\n}\n\n/**\n * A push token obtained by the application, along with the transport it belongs to. Return\n * `transportType: 'fcm'` for a Firebase Cloud Messaging registration token (what\n * `messaging().getToken()` from `@react-native-firebase/messaging` returns, on both Android and\n * iOS), or `transportType: 'apns'` for a raw APNs device token (e.g. from\n * `messaging().getAPNSToken()`).\n */\nexport interface ReactNativePushToken {\n  transportType: 'fcm' | 'apns';\n  token: string;\n}\n\nexport interface ReactNativePushOptions {\n  /** Persistent storage for activation state, e.g. `@react-native-async-storage/async-storage`. */\n  storage: ReactNativePushStorage;\n  /**\n   * Called by the plugin whenever it needs a push token. Requesting notification permissions\n   * beforehand is the application's responsibility.\n   */\n  requestToken: () => Promise<ReactNativePushToken>;\n}\n\nfunction resolvePlatform(): DevicePlatform {\n  // 'react-native' is a peer dependency, marked external in the plugin bundle. The UMD wrapper\n  // requires all externals at module load, so the bundle only loads where react-native is\n  // resolvable (a React Native runtime, or a test environment that mocks it).\n  // Installing @types/react-native would allow a typed import but conflicts with @types/node,\n  // see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15960\n  // eslint-disable-next-line @typescript-eslint/no-var-requires\n  const os = require('react-native').Platform.OS;\n  return os === 'ios' ? DevicePlatform.IOS : DevicePlatform.Android;\n}\n\nexport function create(options: ReactNativePushOptions) {\n  if (\n    !options ||\n    typeof options.storage?.getItem !== 'function' ||\n    typeof options.storage?.setItem !== 'function' ||\n    typeof options.storage?.removeItem !== 'function' ||\n    typeof options.requestToken !== 'function'\n  ) {\n    throw new TypeError(\n      'ReactNativePush.create() requires an options object with a storage implementing getItem/setItem/removeItem (e.g. @react-native-async-storage/async-storage) and a requestToken callback returning a { transportType, token } object.',\n    );\n  }\n\n  const pushConfig: IPlatformPushConfig = {\n    platform: resolvePlatform(),\n    formFactor: DeviceFormFactor.Phone,\n    storageIsAsync: true,\n    storage: {\n      get: (name: string) => options.storage.getItem(name),\n      set: (name: string, value: string) => options.storage.setItem(name, value),\n      remove: (name: string) => options.storage.removeItem(name),\n    },\n    getPushDeviceDetails: (machine: ActivationStateMachine) => {\n      // fire-and-forget, like the W3C hook: failures are reported to the state machine as\n      // GettingPushDeviceDetailsFailed events rather than propagated to this caller\n      void getReactNativePushDeviceDetails(machine, options.requestToken);\n    },\n  };\n\n  // the same shape as the default export of plugins/push, plus a pushConfig which the client\n  // reads per instance (client.pushConfig), so this object registers under\n  // ClientOptions.plugins.Push unchanged and clients never share storage or callbacks\n  return {\n    ActivationStateMachine,\n    localDeviceFactory,\n    CalledActivate,\n    CalledDeactivate,\n    PushChannel,\n    getW3CPushDeviceDetails,\n    pushConfig,\n  };\n}\n\nexport default { create };\n"],
  "mappings": ";;;;;;;;;;;;;;;AAIA,IAAM,cAAN,MAAkB;AAAA,EAIhB,YAAY,SAAwC;AAClD,SAAK,UAAU;AACf,SAAK,SAAS,QAAQ;AAAA,EACxB;AAAA,EAEA,MAAM,kBAAkB;AACtB,UAAM,SAAS,KAAK;AACpB,UAAM,SAAS,MAAM,OAAO,UAAU;AACtC,UAAM,SAAS,OAAO,QAAQ,oBAAoB,OAAO,MAAM,OAAO,UAAU,OAAO,MAAM,OAAO,MAClG,OAAO,EAAE,UAAU,OAAO,IAAI,SAAS,KAAK,QAAQ,KAAK,GACzD,UAAU,OAAO,SAA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