{"version":3,"file":"pagination.es.mjs","names":[],"sources":["../src/pagination/decodeCursor.ts"],"sourcesContent":["import type { PaginationCursor } from '../types/pagination/PaginationCursor'\n\n/**\n * Decodes a base64 pagination cursor token into a PaginationCursor.\n *\n * Browser-oriented: uses `atob` (always defined in the host page / mobile\n * webview). Returns null for a missing token, malformed base64/JSON, or an\n * object lacking `id`/`createdAt`. Fails silently (the library never logs) so\n * callers handle the null however they like.\n * @param {string | null | undefined} base64Cursor - The encoded cursor token.\n * @returns {PaginationCursor | null} The decoded cursor, or null when invalid.\n */\nexport const decodeCursor = (\n  base64Cursor: string | null | undefined,\n): PaginationCursor | null => {\n  if (!base64Cursor) return null\n\n  try {\n    const cursor = JSON.parse(atob(base64Cursor)) as unknown\n    if (\n      typeof cursor === 'object' &&\n      cursor !== null &&\n      'createdAt' in cursor &&\n      'id' in cursor\n    ) {\n      return {\n        createdAt: String((cursor as PaginationCursor).createdAt),\n        id: String((cursor as PaginationCursor).id),\n      }\n    }\n  } catch {\n    // Malformed token: treat as no cursor.\n  }\n\n  return null\n}\n"],"mappings":";AAYA,IAAa,KACX,MAC4B;CAC5B,IAAI,CAAC,GAAc,OAAO;CAE1B,IAAI;EACF,IAAM,IAAS,KAAK,MAAM,KAAK,CAAY,CAAC;EAC5C,IACE,OAAO,KAAW,YAClB,KACA,eAAe,KACf,QAAQ,GAER,OAAO;GACL,WAAW,OAAQ,EAA4B,SAAS;GACxD,IAAI,OAAQ,EAA4B,EAAE;EAC5C;CAEJ,QAAQ,CAER;CAEA,OAAO;AACT"}