{"version":3,"file":"push-notifications.mjs","names":[],"sources":["../../src/renderer/push-notifications/index.ts"],"sourcesContent":["/**\n * Renderer process API for pushNotifications module (macOS only)\n * Usage in renderer process:\n *\n * import * as pushNotifications from 'electron-main-bridge/renderer/pushNotifications';\n * const token = await pushNotifications.registerForAPNSNotifications();\n * pushNotifications.on('received-apns-notification', (userInfo) => {\n *   console.log('Received notification:', userInfo);\n * });\n */\n\nimport type {\n  ApnsUserInfo,\n  PushNotificationsEventCallbacks,\n} from \"@shared/push-notifications.types.js\";\n\n/**\n * Register for Apple Push Notification service (APNS) notifications\n * @returns The APNS device token\n */\nexport async function registerForAPNSNotifications(): Promise<string> {\n  return (await window.rpc.call(\"pushNotifications.registerForAPNSNotifications\")) as string;\n}\n\n/**\n * Unregister from APNS notifications\n */\nexport async function unregisterForAPNSNotifications(): Promise<void> {\n  await window.rpc.call(\"pushNotifications.unregisterForAPNSNotifications\");\n}\n\n/**\n * Event callbacks for pushNotifications module\n */\nexport interface PushNotificationsEventCallbacksExtended extends PushNotificationsEventCallbacks {\n  \"received-apns-notification\": (userInfo: ApnsUserInfo) => void;\n}\n\n/**\n * Register a callback for a pushNotifications event\n * @returns A function that removes the listener\n */\nexport function on<K extends keyof PushNotificationsEventCallbacksExtended>(\n  event: K,\n  callback: PushNotificationsEventCallbacksExtended[K],\n): () => void {\n  return window.rpc.on(`pushNotifications.${event}`, callback as (...args: unknown[]) => void);\n}\n\n/**\n * Register a one-time callback for a pushNotifications event\n */\nexport function once<K extends keyof PushNotificationsEventCallbacksExtended>(\n  event: K,\n  callback: PushNotificationsEventCallbacksExtended[K],\n): void {\n  window.rpc.once(`pushNotifications.${event}`, callback as (...args: unknown[]) => void);\n}\n\n/**\n * Remove a callback for a pushNotifications event\n */\nexport function off<K extends keyof PushNotificationsEventCallbacksExtended>(\n  event: K,\n  callback?: PushNotificationsEventCallbacksExtended[K],\n): void {\n  window.rpc.off(\n    `pushNotifications.${event}`,\n    callback as ((...args: unknown[]) => void) | undefined,\n  );\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,eAAsB,+BAAgD;AACpE,QAAQ,MAAM,OAAO,IAAI,KAAK,iDAAiD;;;;;AAMjF,eAAsB,iCAAgD;AACpE,OAAM,OAAO,IAAI,KAAK,mDAAmD;;;;;;AAc3E,SAAgB,GACd,OACA,UACY;AACZ,QAAO,OAAO,IAAI,GAAG,qBAAqB,SAAS,SAAyC;;;;;AAM9F,SAAgB,KACd,OACA,UACM;AACN,QAAO,IAAI,KAAK,qBAAqB,SAAS,SAAyC;;;;;AAMzF,SAAgB,IACd,OACA,UACM;AACN,QAAO,IAAI,IACT,qBAAqB,SACrB,SACD"}