{"version":3,"file":"_httpFormDataReadNumber.mjs","names":[],"sources":["../../src/internal/_httpFormDataReadNumber.ts"],"sourcesContent":["/**\n * Read one form field as a number.\n *\n * A file passes through, blank text is absent, `null` is null and other text is\n * converted when it is a number and kept as text otherwise.\n *\n * @evidence contracts/common.md#principled-implementation A file is passed through, blank text is absent because `Number(\" \")` would read as zero, `null` is null, and other text is converted when it is a number and kept as text when it is NaN so the assertion rejects it.\n * @evidence contracts/common.md#clear-and-simple-design One conditional chain and a private converter.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The blank-text rule follows the cited issue and is general.\n * @evidence contracts/common.md#meaningful-documentation A comment states the cases.\n */\nexport const _httpFormDataReadNumber = (\n  input: string | File | null,\n): number | null | undefined =>\n  input instanceof File\n    ? (input as any)\n    : // Blank text is absent, as the empty string always was: `Number(\" \")`\n      // is 0, which would read a whitespace value as a real zero (#2448).\n      typeof input === \"string\" && input.trim().length !== 0\n      ? input === \"null\"\n        ? null\n        : (toNumber(input) as any)\n      : undefined;\n\nconst toNumber = (str: string): number | string => {\n  const value: number = Number(str);\n  return isNaN(value) ? str : value;\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,2BACX,UAEA,iBAAiB,OACZ,QAGD,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,WAAW,IACnD,UAAU,SACR,OACC,SAAS,KAAK,IACjB,KAAA;AAER,MAAM,YAAY,QAAiC;CACjD,MAAM,QAAgB,OAAO,GAAG;CAChC,OAAO,MAAM,KAAK,IAAI,MAAM;AAC9B"}