{"version":3,"sources":["../../../src/components/DatePicker/datePickerFormatting.ts"],"sourcesContent":["import { calendarFormatters } from '../Calendar/utils';\n\nconst MONTH_NAMES = [\n  'january',\n  'february',\n  'march',\n  'april',\n  'may',\n  'june',\n  'july',\n  'august',\n  'september',\n  'october',\n  'november',\n  'december',\n];\n\nconst ISO_DATE = /^(\\d{4})-(\\d{1,2})-(\\d{1,2})$/;\nconst NUMERIC_DATE = /^(\\d{1,2})\\/(\\d{1,2})\\/(\\d{4})$/;\nconst MONTH_NAME_DATE = /^([a-z]+)\\.?\\s+(\\d{1,2}),?\\s+(\\d{4})$/i;\n\n/**\n * Creates a local calendar date from explicit parts, or returns `null` when the parts do not round-trip.\n * February 30 must not normalize into March.\n */\nexport const createLocalDate = (year: number, monthIndex: number, day: number): Date | null => {\n  const date = new Date(year, monthIndex, day);\n  // Years 0-99 are otherwise mapped to 1900-1999.\n  date.setFullYear(year, monthIndex, day);\n\n  return date.getFullYear() === year && date.getMonth() === monthIndex && date.getDate() === day ? date : null;\n};\n\nconst getMonthIndex = (name: string): number => {\n  const normalizedName = name.toLowerCase();\n  // Accept full names and abbreviations of at least three letters, such as \"Aug\" or \"Sept\".\n  return normalizedName.length < 3 ? -1 : MONTH_NAMES.findIndex(monthName => monthName.startsWith(normalizedName));\n};\n\n/**\n * Formats a date as an English long date, such as \"August 12, 2026\".\n */\nexport const defaultFormatDate = (date: Date): string => calendarFormatters.dateTime({ date, format: 'monthDayYear' });\n\n/**\n * Parses the English date formats accepted by DatePicker: `YYYY-MM-DD`, a full or abbreviated month name followed by\n * the day and a four-digit year with an optional comma, and `M/D/YYYY`. Date-only ISO values are local calendar dates,\n * not UTC timestamps.\n *\n * @returns The parsed local date, or `null` when the text is not a real calendar date in a supported format.\n */\nexport const defaultParseDate = (text: string): Date | null => {\n  const value = text.trim();\n\n  let match = ISO_DATE.exec(value);\n  if (match) {\n    return createLocalDate(Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n  }\n\n  match = NUMERIC_DATE.exec(value);\n  if (match) {\n    return createLocalDate(Number(match[3]), Number(match[1]) - 1, Number(match[2]));\n  }\n\n  match = MONTH_NAME_DATE.exec(value);\n  if (match) {\n    const monthIndex = getMonthIndex(match[1]);\n    return monthIndex < 0 ? null : createLocalDate(Number(match[3]), monthIndex, Number(match[2]));\n  }\n\n  return null;\n};\n"],"names":["createLocalDate","defaultFormatDate","defaultParseDate","MONTH_NAMES","ISO_DATE","NUMERIC_DATE","MONTH_NAME_DATE","year","monthIndex","day","date","Date","setFullYear","getFullYear","getMonth","getDate","getMonthIndex","name","normalizedName","toLowerCase","length","findIndex","monthName","startsWith","calendarFormatters","dateTime","format","text","value","trim","match","exec","Number"],"mappings":";;;;;;;;;;;QAyBaA;eAAAA;;QAiBAC;eAAAA;;QASAC;eAAAA;;;uBAnDsB;AAEnC,MAAMC,cAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,WAAW;AACjB,MAAMC,eAAe;AACrB,MAAMC,kBAAkB;AAMjB,MAAMN,kBAAkB,CAACO,MAAcC,YAAoBC;IAChE,MAAMC,OAAO,IAAIC,KAAKJ,MAAMC,YAAYC;IACxC,gDAAgD;IAChDC,KAAKE,WAAW,CAACL,MAAMC,YAAYC;IAEnC,OAAOC,KAAKG,WAAW,OAAON,QAAQG,KAAKI,QAAQ,OAAON,cAAcE,KAAKK,OAAO,OAAON,MAAMC,OAAO;AAC1G;AAEA,MAAMM,gBAAgB,CAACC;IACrB,MAAMC,iBAAiBD,KAAKE,WAAW;IACvC,0FAA0F;IAC1F,OAAOD,eAAeE,MAAM,GAAG,IAAI,CAAC,IAAIjB,YAAYkB,SAAS,CAACC,CAAAA,YAAaA,UAAUC,UAAU,CAACL;AAClG;AAKO,MAAMjB,oBAAoB,CAACS,OAAuBc,yBAAkB,CAACC,QAAQ,CAAC;QAAEf;QAAMgB,QAAQ;IAAe;AAS7G,MAAMxB,mBAAmB,CAACyB;IAC/B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