{"version":3,"file":"_httpQueryReadBigint.mjs","names":[],"sources":["../../src/internal/_httpQueryReadBigint.ts"],"sourcesContent":["/**\n * Read one query value as a bigint.\n *\n * Blank text is absent, `null` is null and other text is converted when it\n * parses and kept as text otherwise.\n *\n * @evidence contracts/common.md#principled-implementation Blank or missing text is absent because `BigInt(\" \")` would read as zero, the text `null` is null and other text is converted with BigInt where it parses and kept as text otherwise.\n * @evidence contracts/common.md#clear-and-simple-design One conditional and a private converter.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The blank rule follows the cited issue.\n * @evidence contracts/common.md#meaningful-documentation A comment states the cases.\n */\nexport const _httpQueryReadBigint = (\n  str: string | null,\n): bigint | null | undefined =>\n  // Blank text is absent, as the empty string always was: `BigInt(\" \")` is 0n,\n  // which would read a whitespace value as a real zero (#2448).\n  typeof str === \"string\" && str.trim().length !== 0\n    ? str === \"null\"\n      ? null\n      : (toBigint(str) as any)\n    : undefined;\n\nconst toBigint = (str: string): bigint | string => {\n  try {\n    return BigInt(str);\n  } catch {\n    return str;\n  }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,wBACX,QAIA,OAAO,QAAQ,YAAY,IAAI,KAAK,CAAC,CAAC,WAAW,IAC7C,QAAQ,SACN,OACC,SAAS,GAAG,IACf,KAAA;AAEN,MAAM,YAAY,QAAiC;CACjD,IAAI;EACF,OAAO,OAAO,GAAG;CACnB,QAAQ;EACN,OAAO;CACT;AACF"}