chronolizer 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -256,12 +256,12 @@ const parseRelativeMonth = (input) => {
256
256
  return Option.none();
257
257
  };
258
258
  const parseRelativeUnit = (input) => {
259
- const articlePeriod = String$1.match(/^the (day|week|month|quarter|year)$/u)(input);
259
+ const articlePeriod = String$1.match(/^the ([^ ]+)$/u)(input);
260
260
  if (Option.isSome(articlePeriod)) {
261
261
  const entry = units.find((unit) => unit[0] === textAt(articlePeriod.value, 1));
262
262
  if (entry !== void 0) return Option.some(relativePeriod(entry[1], 0, currentPeriod(entry[0])));
263
263
  }
264
- const outerRelative = String$1.match(/^(?:the )?(day|week|month|quarter|year) (before last|after next)$/u)(input);
264
+ const outerRelative = String$1.match(/^(?:the )?([^ ]+) (before last|after next)$/u)(input);
265
265
  if (Option.isSome(outerRelative)) {
266
266
  const entry = units.find((unit) => unit[0] === textAt(outerRelative.value, 1));
267
267
  if (entry !== void 0) {
@@ -310,7 +310,7 @@ const parsePeriodEdge = (input) => {
310
310
  return Option.some(name === "end" ? periodEndDay(period.value, canonical) : periodStartDay(period.value, canonical));
311
311
  };
312
312
  const parsePeriod = (input) => {
313
- const shifted = String$1.match(/^(.+) ([1-9]\d*) (day|days|week|weeks|month|months|quarter|quarters|year|years) (ago|prior|from now)$/u)(input);
313
+ const shifted = String$1.match(/^(.+) ([1-9]\d*) ([^ ]+) (ago|prior|from now)$/u)(input);
314
314
  if (Option.isSome(shifted)) {
315
315
  const amount = parseTrailingCount(textAt(shifted.value, 2));
316
316
  const unitText = textAt(shifted.value, 3);
@@ -326,7 +326,7 @@ const parsePeriod = (input) => {
326
326
  }
327
327
  }
328
328
  }
329
- const relativeShift = String$1.match(/^([1-9]\d*) (day|days|week|weeks|month|months|quarter|quarters|year|years) (before|after) (.+)$/u)(input);
329
+ const relativeShift = String$1.match(/^([1-9]\d*) ([^ ]+) (before|after) (.+)$/u)(input);
330
330
  if (Option.isSome(relativeShift)) {
331
331
  const amount = parseTrailingCount(textAt(relativeShift.value, 1));
332
332
  const unitText = textAt(relativeShift.value, 2);
@@ -389,7 +389,7 @@ const boundaryCandidate = (input) => openBoundaryCandidate(input, [
389
389
  ], parsePeriod);
390
390
  const countedUnit = (value, amount) => units.find((entry) => value === (amount === 1 ? entry[0] : entry[2]));
391
391
  const parseCalendarOffset = (input) => {
392
- const singular = String$1.match(/^(?:(?:a|one) (day|week|month|quarter|year) (ago|prior|from now)|in (?:a|one) (day|week|month|quarter|year))$/u)(input);
392
+ const singular = String$1.match(/^(?:(?:a|one) ([^ ]+) (ago|prior|from now)|in (?:a|one) ([^ ]+))$/u)(input);
393
393
  if (Option.isSome(singular)) {
394
394
  const unitText = textAt(singular.value, 1) || textAt(singular.value, 3);
395
395
  const entry = units.find((unit) => unit[0] === unitText);
@@ -401,9 +401,9 @@ const parseCalendarOffset = (input) => {
401
401
  return Option.some(relativePeriod(entry[1], direction, canonical));
402
402
  }
403
403
  }
404
- const past = String$1.match(/^([1-9]\d*) (day|days|week|weeks|month|months|quarter|quarters|year|years) (?:ago|prior)$/u)(input);
405
- const futureIn = String$1.match(/^in ([1-9]\d*) (day|days|week|weeks|month|months|quarter|quarters|year|years)$/u)(input);
406
- const futureFromNow = String$1.match(/^([1-9]\d*) (day|days|week|weeks|month|months|quarter|quarters|year|years) from now$/u)(input);
404
+ const past = String$1.match(/^([1-9]\d*) ([^ ]+) (?:ago|prior)$/u)(input);
405
+ const futureIn = String$1.match(/^in ([1-9]\d*) ([^ ]+)$/u)(input);
406
+ const futureFromNow = String$1.match(/^([1-9]\d*) ([^ ]+) from now$/u)(input);
407
407
  const match = Option.firstSomeOf([
408
408
  past,
409
409
  futureIn,
@@ -420,10 +420,10 @@ const parseCalendarOffset = (input) => {
420
420
  return Option.some(relativePeriod(entry[1], direction, canonical));
421
421
  };
422
422
  const parseRollingPeriod = (input) => {
423
- const past = String$1.match(/^(?:(?:last|previous|past) |(?:in|over) the (?:last|previous|past) )?([1-9]\d*) (day|days|week|weeks|month|months|quarter|quarters|year|years)$/u)(input);
424
- const singularPast = String$1.match(/^(?:past|the past|in the past|over the past|this past) (day|week|month|quarter|year)$/u)(input);
425
- const future = String$1.match(/^(?:(?:next|coming|within) |(?:in|over|within) the (?:next|coming) )([1-9]\d*) (day|days|week|weeks|month|months|quarter|quarters|year|years)$/u)(input);
426
- const singularFuture = String$1.match(/^(?:in|over|within) the (?:next|coming) (day|week|month|quarter|year)$/u)(input);
423
+ const past = String$1.match(/^(?:(?:last|previous|past) |(?:in|over) the (?:last|previous|past) )?([1-9]\d*) ([^ ]+)$/u)(input);
424
+ const singularPast = String$1.match(/^(?:past|the past|in the past|over the past|this past) ([^ ]+)$/u)(input);
425
+ const future = String$1.match(/^(?:(?:next|coming|within) |(?:in|over|within) the (?:next|coming) )([1-9]\d*) ([^ ]+)$/u)(input);
426
+ const singularFuture = String$1.match(/^(?:in|over|within) the (?:next|coming) ([^ ]+)$/u)(input);
427
427
  const match = Option.firstSomeOf([
428
428
  past,
429
429
  singularPast,
@@ -639,7 +639,7 @@ const renderEnglish = (range) => {
639
639
  ...currentYearDatePeriods(range, currentDateLabel),
640
640
  ...periodsFromPhrases([...datedPeriods(range, months), ...datedQuarterPeriods(range)], parsePeriod)
641
641
  ];
642
- return renderPeriodRange(range, [...units.map((entry) => candidate(periodToDateRange(entry[1]), `${entry[0]} to date`)), ...units.map((entry) => candidate(remainingPeriodRange(entry[1]), `rest of the ${entry[0]}`))], periods, (period) => `since ${period}`, (period) => `before ${period}`, (period) => `through ${period}`, (period) => `after ${period}`, (lower, upper) => `from ${lower} to ${upper}`, (period) => `from ${period} to now`, (period) => `from now to ${period}`, () => "until now", () => "from now");
642
+ return renderPeriodRange(range, [...units.map((entry) => candidate(periodToDateRange(entry[1]), `${entry[0]} to date`)), ...units.map((entry) => candidate(remainingPeriodRange(entry[1]), `rest of the ${entry[0]}`))], [...periods, ...periods.map((period) => periodPreviousDay(period, `the day before ${period.canonical}`))], (period) => `since ${period}`, (period) => `before ${period}`, (period) => `through ${period}`, (period) => `after ${period}`, (lower, upper) => `from ${lower} to ${upper}`, (period) => `from ${period} to now`, (period) => `from now to ${period}`, () => "until now", () => "from now");
643
643
  };
644
644
  const EnglishContribution = new BaseLanguageContribution({
645
645
  locale: "en",
@@ -1,10 +1,9 @@
1
- import { isIsoDate } from "../ast/schemas.mjs";
2
1
  import { BaseLanguageContribution } from "../language/model.mjs";
3
2
  import { normalizeNaturalText } from "../natural/text.mjs";
4
3
  import { defineLanguagePlugin, languagePluginsLayer } from "../language/registry.mjs";
5
4
  import { correctWhitespaceSeparatedText } from "../natural/correction.mjs";
6
5
  import { completeNaturalPhrases, fixedCalendarPeriodPhrases, naturalCount, prefixNaturalPhrases } from "../natural/suggestion.mjs";
7
- import { absoluteDatePeriod, calendarPeriodOffset, candidate, compileCountAliasNormalizer, compoundCountAliases, countAliasVocabulary, currentYearDatePeriods, datedPeriods, datedQuarterPeriods, decimalTens, decomposeShiftedPeriodRange, fixedDatePeriod, fixedMonthPeriod, fixedQuarterPeriod, fixedYearPeriod, fromNowRange, futurePeriod, futureRange, isoDate, joinedNowCandidate, joinedPeriodCandidate, monthOfRelativeYear, namedCurrentYearDatePeriod, namedDatePeriod, openBoundaryCandidate, parseTrailingCount, periodBoundaryCandidate, periodDay, periodEndDay, periodRange, periodStartDay, periodToDateRange, periodsFromPhrases, quarterOfRelativeYear, relativePeriod, relativeWeekday, relativeWeekend, remainingPeriodRange, renderPeriodRange, sequentialCountAliases, shiftPeriod, textAt, trailingPeriod, trailingRange, untilNowRange, validYear } from "./shared.mjs";
6
+ import { absoluteDatePeriod, calendarPeriodOffset, candidate, compileCountAliasNormalizer, compoundCountAliases, countAliasVocabulary, currentYearDatePeriods, datedPeriods, datedQuarterPeriods, decimalTens, decomposeShiftedPeriodRange, fixedMonthPeriod, fixedQuarterPeriod, fixedYearPeriod, fromNowRange, futurePeriod, futureRange, joinedNowCandidate, joinedPeriodCandidate, monthOfRelativeYear, namedCurrentYearDatePeriod, namedDatePeriod, openBoundaryCandidate, parseTrailingCount, periodBoundaryCandidate, periodDay, periodEndDay, periodRange, periodStartDay, periodToDateRange, periodsFromPhrases, quarterOfRelativeYear, relativePeriod, relativeWeekday, relativeWeekend, remainingPeriodRange, renderPeriodRange, sequentialCountAliases, shiftPeriod, textAt, trailingPeriod, trailingRange, untilNowRange, validYear } from "./shared.mjs";
8
7
  import { Effect, Option, String as String$1 } from "effect";
9
8
  //#region src/locales/es.ts
10
9
  const months = [
@@ -560,15 +559,7 @@ const parseNamedDate = (input) => {
560
559
  const named = String$1.match(/^(?:el (?:día )?)?([0-3]?\d)(?: de)? ([a-záéíóúñ]+\.?)(?:(?: de| del)? (\d{4}))$/u)(input);
561
560
  if (Option.isSome(named)) return namedDatePeriod(textAt(named.value, 3), textAt(named.value, 2), textAt(named.value, 1), monthNumber, (day, month, year) => `${day} de ${textAt(months, month - 1)} de ${year}`);
562
561
  const numeric = String$1.match(/^([0-3]?\d)[./-]([01]?\d)[./-](\d{4})$/u)(input);
563
- if (Option.isSome(numeric)) {
564
- const year = validYear(textAt(numeric.value, 3));
565
- const month = Number(textAt(numeric.value, 2));
566
- const day = Number(textAt(numeric.value, 1));
567
- if (year !== void 0 && month >= 1 && month <= 12) {
568
- const value = isoDate(year, month, day);
569
- if (isIsoDate(value) && value !== "9999-12-31") return Option.some(fixedDatePeriod(value, `${day} de ${textAt(months, month - 1)} de ${year}`));
570
- }
571
- }
562
+ if (Option.isSome(numeric)) return namedDatePeriod(textAt(numeric.value, 3), textAt(numeric.value, 2), textAt(numeric.value, 1), Number, (day, month, year) => `${day} de ${textAt(months, month - 1)} de ${year}`);
572
563
  const current = String$1.match(/^(?:el (?:día )?)?([0-3]?\d)(?: de)? ([a-záéíóúñ]+\.?)$/u)(input);
573
564
  if (Option.isSome(current)) return namedCurrentYearDatePeriod(textAt(current.value, 2), textAt(current.value, 1), monthNumber, currentDateLabel);
574
565
  const relative = String$1.match(/^(?:el (?:día )?)?([0-3]?\d) (de .+|del .+)$/u)(input);
@@ -729,7 +720,7 @@ const agreesWithSingularModifier = (entry, modifier, future) => {
729
720
  return modifier === expected || modifier === withoutAcute(expected);
730
721
  };
731
722
  const parseCalendarOffset = (input) => {
732
- const match = String$1.match(/^(hace|dentro de|en) ([1-9]\d*|un|una) (día|dia|días|dias|semana|semanas|mes|meses|trimestre|trimestres|año|años|ano|anos)$/u)(input);
723
+ const match = String$1.match(/^(hace|dentro de|en) ([1-9]\d*|un|una) ([^ ]+)$/u)(input);
733
724
  if (Option.isNone(match)) return Option.none();
734
725
  const amount = writtenAmount(textAt(match.value, 2));
735
726
  if (Option.isNone(amount)) return Option.none();
@@ -750,7 +741,7 @@ const rollingCanonical = (entry, amount, future) => {
750
741
  };
751
742
  const rollingCandidate = (entry, amount, future) => candidate(future ? futureRange(amount, entry.unit) : trailingRange(amount, entry.unit), rollingCanonical(entry, amount, future));
752
743
  const parseRollingSince = (input) => {
753
- const since = String$1.match(/^desde hace ([1-9]\d*|un|una) (día|dia|días|dias|semana|semanas|mes|meses|trimestre|trimestres|año|años|ano|anos)$/u)(input);
744
+ const since = String$1.match(/^desde hace ([1-9]\d*|un|una) ([^ ]+)$/u)(input);
754
745
  if (Option.isSome(since)) {
755
746
  const amount = writtenAmount(textAt(since.value, 1));
756
747
  if (Option.isSome(amount)) {
@@ -762,18 +753,18 @@ const parseRollingSince = (input) => {
762
753
  return Option.none();
763
754
  };
764
755
  const parseSingularRolling = (input) => {
765
- const futureSingular = String$1.match(/^desde ahora durante (un|una) (día|dia|semana|mes|trimestre|año|ano)$/u)(input);
756
+ const futureSingular = String$1.match(/^desde ahora durante (un|una) ([^ ]+)$/u)(input);
766
757
  if (Option.isSome(futureSingular)) {
767
758
  const entry = countedUnit(textAt(futureSingular.value, 2), 1);
768
759
  if (entry !== void 0 && agreesWithIndefiniteArticle(entry, textAt(futureSingular.value, 1))) return Option.some(rollingCandidate(entry, 1, true));
769
760
  }
770
- const lastSingular = String$1.match(/^(?:(?:durante|en) )?(?:este )?(?:(el|la) )?(último|ultimo|última|ultima) (día|dia|semana|mes|trimestre|año|ano)$/u)(input);
761
+ const lastSingular = String$1.match(/^(?:(?:durante|en) )?(?:este )?(?:(el|la) )?([uú]ltim[oa]) ([^ ]+)$/u)(input);
771
762
  if (Option.isSome(lastSingular)) {
772
763
  const entry = countedUnit(textAt(lastSingular.value, 3), 1);
773
764
  const modifier = textAt(lastSingular.value, 2);
774
765
  if (entry !== void 0 && agreesWithArticle(entry, textAt(lastSingular.value, 1)) && agreesWithSingularModifier(entry, modifier, false)) return Option.some(rollingCandidate(entry, 1, false));
775
766
  }
776
- const nextSingular = String$1.match(/^durante (el|la) (próximo|proximo|próxima|proxima|siguiente) (día|dia|semana|mes|trimestre|año|ano)$/u)(input);
767
+ const nextSingular = String$1.match(/^durante (el|la) (pr[oó]xim[oa]|siguiente) ([^ ]+)$/u)(input);
777
768
  if (Option.isSome(nextSingular)) {
778
769
  const entry = countedUnit(textAt(nextSingular.value, 3), 1);
779
770
  const modifier = textAt(nextSingular.value, 2);
@@ -782,17 +773,17 @@ const parseSingularRolling = (input) => {
782
773
  return Option.none();
783
774
  };
784
775
  const parseCountedRolling = (input) => {
785
- const counted = String$1.match(/^(?:(?:durante|en) )?(?:(los|las) )?(últimos|ultimos|últimas|ultimas|pasados|pasadas|anteriores|próximos|proximos|próximas|proximas|siguientes) ([1-9]\d*) (día|dia|días|dias|semana|semanas|mes|meses|trimestre|trimestres|año|años|ano|anos)$/u)(input);
776
+ const counted = String$1.match(/^(?:(?:durante|en) )?(?:(los|las) )?([uú]ltim(?:os|as)|pasad(?:os|as)|anteriores|pr[oó]xim(?:os|as)|siguientes) ([1-9]\d*) ([^ ]+)$/u)(input);
786
777
  if (Option.isSome(counted)) {
787
778
  const amount = parseTrailingCount(textAt(counted.value, 3));
788
779
  if (Option.isSome(amount) && amount.value > 1) {
789
780
  const entry = countedUnit(textAt(counted.value, 4), amount.value);
790
781
  const modifier = textAt(counted.value, 2);
791
- const future = modifier.startsWith("próxim") || modifier.startsWith("proxim") || modifier === "siguientes";
782
+ const future = modifier.includes("xim") || modifier === "siguientes";
792
783
  if (entry !== void 0 && agreesWithArticle(entry, textAt(counted.value, 1), true) && agreesWithRollingModifier(entry, modifier, future)) return Option.some(rollingCandidate(entry, amount.value, future));
793
784
  }
794
785
  }
795
- const bare = String$1.match(/^([1-9]\d*) (día|dia|días|dias|semana|semanas|mes|meses|trimestre|trimestres|año|años|ano|anos)$/u)(input);
786
+ const bare = String$1.match(/^([1-9]\d*) ([^ ]+)$/u)(input);
796
787
  if (Option.isNone(bare)) return Option.none();
797
788
  const amount = parseTrailingCount(textAt(bare.value, 1));
798
789
  if (Option.isNone(amount)) return Option.none();
@@ -1,10 +1,9 @@
1
- import { isIsoDate } from "../ast/schemas.mjs";
2
1
  import { BaseLanguageContribution } from "../language/model.mjs";
3
2
  import { normalizeNaturalText } from "../natural/text.mjs";
4
3
  import { defineLanguagePlugin, languagePluginsLayer } from "../language/registry.mjs";
5
4
  import { correctWhitespaceSeparatedText } from "../natural/correction.mjs";
6
5
  import { completeNaturalPhrases, fixedCalendarPeriodPhrases, naturalCount, prefixNaturalPhrases } from "../natural/suggestion.mjs";
7
- import { absoluteDatePeriod, calendarPeriodOffset, candidate, compileCountAliasNormalizer, countAliasVocabulary, currentYearDatePeriods, datedPeriods, datedQuarterPeriods, decomposeShiftedPeriodRange, fixedDatePeriod, fixedMonthPeriod, fixedQuarterPeriod, fixedYearPeriod, fromNowRange, futurePeriod, futureRange, isoDate, joinedNowCandidate, joinedPeriodCandidate, monthOfRelativeYear, namedCurrentYearDatePeriod, namedDatePeriod, openBoundaryCandidate, parseTrailingCount, periodBoundaryCandidate, periodDay, periodEndDay, periodRange, periodStartDay, periodToDateRange, periodsFromPhrases, quarterOfRelativeYear, relativePeriod, relativeWeekday, relativeWeekend, remainingPeriodRange, renderPeriodRange, sequentialCountAliases, shiftPeriod, textAt, trailingPeriod, trailingRange, untilNowRange, validYear } from "./shared.mjs";
6
+ import { absoluteDatePeriod, calendarPeriodOffset, candidate, compileCountAliasNormalizer, countAliasVocabulary, currentYearDatePeriods, datedPeriods, datedQuarterPeriods, decomposeShiftedPeriodRange, fixedMonthPeriod, fixedQuarterPeriod, fixedYearPeriod, fromNowRange, futurePeriod, futureRange, joinedNowCandidate, joinedPeriodCandidate, monthOfRelativeYear, namedCurrentYearDatePeriod, namedDatePeriod, openBoundaryCandidate, parseTrailingCount, periodBoundaryCandidate, periodDay, periodEndDay, periodRange, periodStartDay, periodToDateRange, periodsFromPhrases, quarterOfRelativeYear, relativePeriod, relativeWeekday, relativeWeekend, remainingPeriodRange, renderPeriodRange, sequentialCountAliases, shiftPeriod, textAt, trailingPeriod, trailingRange, untilNowRange, validYear } from "./shared.mjs";
8
7
  import { Effect, Option, String as String$1 } from "effect";
9
8
  //#region src/locales/fr.ts
10
9
  const months = [
@@ -91,7 +90,8 @@ const frenchCompoundCountAliases = () => {
91
90
  "soixante"
92
91
  ][tens];
93
92
  if (tensWord === void 0) continue;
94
- phrase = remainder === 1 ? `${tensWord} et un` : `${tensWord}-${words[remainder] ?? ""}`;
93
+ if (remainder === 0) phrase = tensWord;
94
+ else phrase = remainder === 1 ? `${tensWord} et un` : `${tensWord}-${words[remainder] ?? ""}`;
95
95
  } else if (tens === 7) phrase = remainder === 1 ? "soixante et onze" : `soixante-${words[10 + remainder] ?? ""}`;
96
96
  else if (tens === 8) phrase = remainder === 0 ? "quatre-vingts" : `quatre-vingt-${words[remainder] ?? ""}`;
97
97
  else phrase = `quatre-vingt-${words[10 + remainder] ?? ""}`;
@@ -499,15 +499,7 @@ const parseNamedDate = (input) => {
499
499
  const named = String$1.match(/^(?:le )?(1er|[0-3]?\d)(?: de)? ([a-zàâçéèêëîïôûùüÿœ]+\.?),?(?: de)? (\d{4})$/u)(input);
500
500
  if (Option.isSome(named)) return namedDatePeriod(textAt(named.value, 3), textAt(named.value, 2), textAt(named.value, 1).replace(/er$/u, ""), monthNumber, dateLabel);
501
501
  const numeric = String$1.match(/^([0-3]?\d)[./-]([01]?\d)[./-](\d{4})$/u)(input);
502
- if (Option.isSome(numeric)) {
503
- const year = validYear(textAt(numeric.value, 3));
504
- const month = Number(textAt(numeric.value, 2));
505
- const day = Number(textAt(numeric.value, 1));
506
- if (year !== void 0 && month >= 1 && month <= 12) {
507
- const value = isoDate(year, month, day);
508
- if (isIsoDate(value) && value !== "9999-12-31") return Option.some(fixedDatePeriod(value, dateLabel(day, month, year)));
509
- }
510
- }
502
+ if (Option.isSome(numeric)) return namedDatePeriod(textAt(numeric.value, 3), textAt(numeric.value, 2), textAt(numeric.value, 1), Number, dateLabel);
511
503
  const current = String$1.match(/^(?:le )?(1er|[0-3]?\d)(?: de)? ([a-zàâçéèêëîïôûùüÿœ]+\.?)$/u)(input);
512
504
  if (Option.isSome(current)) return namedCurrentYearDatePeriod(textAt(current.value, 2), textAt(current.value, 1).replace(/er$/u, ""), monthNumber, currentDateLabel);
513
505
  const relative = String$1.match(/^(?:le )?(1er|[0-3]?\d) (de .+|du .+)$/u)(input);
@@ -654,36 +646,29 @@ const countedUnit = (value, amount) => {
654
646
  const unit = unitAliases.find((entry) => entry[0] === value)?.[1];
655
647
  return unit === void 0 ? void 0 : units.find((entry) => entry.unit === unit);
656
648
  };
649
+ const rollingPastModifierPattern = "derni(?:ers|ères|eres)|pass(?:és|ées|es)|pr[eé]c[eé]dent(?:s|es)";
650
+ const rollingFutureModifierPattern = "prochain(?:s|es)|suivant(?:s|es)";
651
+ const rollingModifierMatchPattern = new RegExp(`(?:^| )(${`${rollingPastModifierPattern}|${rollingFutureModifierPattern}`})(?: |$)`, "u");
657
652
  const modifierAgreesWithNoun = (input, noun) => {
658
- const match = String$1.match(/(?:^| )(derniers|dernières|dernieres|passés|passées|passes|précédents|précédentes|precedents|precedentes|prochains|prochaines|suivants|suivantes)(?: |$)/u)(input);
653
+ const match = String$1.match(rollingModifierMatchPattern)(input);
659
654
  if (Option.isNone(match)) return true;
660
655
  const modifier = textAt(match.value, 1);
661
- return (noun.startsWith("semaine") || noun.startsWith("année") || noun.startsWith("annee")) === [
662
- "dernières",
663
- "dernieres",
664
- "passées",
665
- "passes",
666
- "précédentes",
667
- "precedentes",
668
- "prochaines",
669
- "suivantes"
670
- ].includes(modifier);
656
+ return (noun.startsWith("semaine") || noun.startsWith("année") || noun.startsWith("annee")) === modifier.endsWith("es");
671
657
  };
672
- const countedUnitPattern = "jour|jours|semaine|semaines|mois|trimestre|trimestres|an|ans|année|annee|années|annees";
673
- const compileCountedPattern = (source) => new RegExp(source.replace("UNIT", countedUnitPattern), "u");
674
- const calendarPastPattern = compileCountedPattern("^il y a ([1-9]\\d*) (UNIT)$");
675
- const calendarFuturePattern = compileCountedPattern("^dans ([1-9]\\d*) (UNIT)$");
676
- const rollingSincePattern = compileCountedPattern("^depuis ([1-9]\\d*) (UNIT)$");
677
- const rollingBarePattern = compileCountedPattern("^([1-9]\\d*) (UNIT)$");
658
+ const compilePattern = (source) => new RegExp(source, "u");
659
+ const calendarPastPattern = /^il y a ([1-9]\d*) ([^ ]+)$/u;
660
+ const calendarFuturePattern = /^dans ([1-9]\d*) ([^ ]+)$/u;
661
+ const rollingSincePattern = /^depuis ([1-9]\d*) ([^ ]+)$/u;
662
+ const rollingBarePattern = /^([1-9]\d*) ([^ ]+)$/u;
678
663
  const rollingPastPatterns = [
679
- compileCountedPattern("^(?:(?:les|la) )?(?:derniers|dernières|dernieres|passés|passées|passes|précédents|précédentes|precedents|precedentes) ([1-9]\\d*) (UNIT)$"),
680
- compileCountedPattern("^(?:(?:les|la|au cours des|pendant les) )?([1-9]\\d*) (?:derniers|dernières|dernieres|passés|passées|passes|précédents|précédentes|precedents|precedentes) (UNIT)$"),
681
- compileCountedPattern("^([1-9]\\d*) (UNIT) (?:derniers|dernières|dernieres|passés|passées|passes|précédents|précédentes|precedents|precedentes)$")
664
+ compilePattern(`^(?:(?:les|la) )?(?:${rollingPastModifierPattern}) ([1-9]\\d*) ([^ ]+)$`),
665
+ compilePattern(`^(?:(?:les|la|au cours des|pendant les) )?([1-9]\\d*) (?:${rollingPastModifierPattern}) ([^ ]+)$`),
666
+ compilePattern(`^([1-9]\\d*) ([^ ]+) (?:${rollingPastModifierPattern})$`)
682
667
  ];
683
668
  const rollingFuturePatterns = [
684
- compileCountedPattern("^(?:(?:les|la) )?(?:prochains|prochaines|suivants|suivantes) ([1-9]\\d*) (UNIT)$"),
685
- compileCountedPattern("^(?:(?:les|la|au cours des|pendant les) )?([1-9]\\d*) (?:prochains|prochaines|suivants|suivantes) (UNIT)$"),
686
- compileCountedPattern("^([1-9]\\d*) (UNIT) (?:prochains|prochaines|suivants|suivantes|à venir)$")
669
+ compilePattern(`^(?:(?:les|la) )?(?:${rollingFutureModifierPattern}) ([1-9]\\d*) ([^ ]+)$`),
670
+ compilePattern(`^(?:(?:les|la|au cours des|pendant les) )?([1-9]\\d*) (?:${rollingFutureModifierPattern}) ([^ ]+)$`),
671
+ compilePattern(`^([1-9]\\d*) ([^ ]+) (?:${rollingFutureModifierPattern}|à venir)$`)
687
672
  ];
688
673
  const firstPatternMatch = (input, patterns) => Option.firstSomeOf(patterns.map((pattern) => String$1.match(pattern)(input)));
689
674
  const relativeCountPhrase = (amount, entry, future) => {
@@ -1,10 +1,9 @@
1
- import { isIsoDate } from "../ast/schemas.mjs";
2
1
  import { BaseLanguageContribution } from "../language/model.mjs";
3
2
  import { normalizeNaturalText } from "../natural/text.mjs";
4
3
  import { defineLanguagePlugin, languagePluginsLayer } from "../language/registry.mjs";
5
4
  import { correctWhitespaceSeparatedText } from "../natural/correction.mjs";
6
5
  import { completeNaturalPhrases, fixedCalendarPeriodPhrases, naturalCount, prefixNaturalPhrases } from "../natural/suggestion.mjs";
7
- import { absoluteDatePeriod, calendarPeriodOffset, candidate, compileCountAliasNormalizer, compoundCountAliases, countAliasVocabulary, currentYearDatePeriods, datedPeriods, datedQuarterPeriods, decimalTens, decomposeShiftedPeriodRange, fixedDatePeriod, fixedMonthPeriod, fixedQuarterPeriod, fixedYearPeriod, fromNowRange, futurePeriod, futureRange, isoDate, joinedNowCandidate, joinedPeriodCandidate, monthOfRelativeYear, namedCurrentYearDatePeriod, namedDatePeriod, openBoundaryCandidate, parseTrailingCount, periodDay, periodEndDay, periodRange, periodStartDay, periodToDateRange, periodsFromPhrases, quarterOfRelativeYear, relativePeriod, relativeWeekday, relativeWeekend, remainingPeriodRange, renderPeriodRange, sequentialCountAliases, shiftPeriod, textAt, trailingPeriod, trailingRange, untilNowRange, validYear } from "./shared.mjs";
6
+ import { absoluteDatePeriod, calendarPeriodOffset, candidate, compileCountAliasNormalizer, compoundCountAliases, countAliasVocabulary, currentYearDatePeriods, datedPeriods, datedQuarterPeriods, decimalTens, decomposeShiftedPeriodRange, fixedMonthPeriod, fixedQuarterPeriod, fixedYearPeriod, fromNowRange, futurePeriod, futureRange, joinedNowCandidate, joinedPeriodCandidate, monthOfRelativeYear, namedCurrentYearDatePeriod, namedDatePeriod, openBoundaryCandidate, parseTrailingCount, periodDay, periodEndDay, periodRange, periodStartDay, periodToDateRange, periodsFromPhrases, quarterOfRelativeYear, relativePeriod, relativeWeekday, relativeWeekend, remainingPeriodRange, renderPeriodRange, sequentialCountAliases, shiftPeriod, textAt, trailingPeriod, trailingRange, untilNowRange, validYear } from "./shared.mjs";
8
7
  import { Effect, Option, String as String$1 } from "effect";
9
8
  //#region src/locales/nl.ts
10
9
  const months = [
@@ -398,15 +397,7 @@ const parseNamedDate = (input) => {
398
397
  const named = String$1.match(/^(?:de )?([0-3]?\d)(?:e|ste|de)?(?: van)? ([a-z]+\.?)(?: van)? (\d{4})$/u)(input);
399
398
  if (Option.isSome(named)) return namedDatePeriod(textAt(named.value, 3), textAt(named.value, 2), textAt(named.value, 1), monthNumber, dateLabel);
400
399
  const numeric = String$1.match(/^([0-3]?\d)[./-]([01]?\d)[./-](\d{4})$/u)(input);
401
- if (Option.isSome(numeric)) {
402
- const year = validYear(textAt(numeric.value, 3));
403
- const month = Number(textAt(numeric.value, 2));
404
- const day = Number(textAt(numeric.value, 1));
405
- if (year !== void 0 && month >= 1 && month <= 12) {
406
- const value = isoDate(year, month, day);
407
- if (isIsoDate(value) && value !== "9999-12-31") return Option.some(fixedDatePeriod(value, dateLabel(day, month, year)));
408
- }
409
- }
400
+ if (Option.isSome(numeric)) return namedDatePeriod(textAt(numeric.value, 3), textAt(numeric.value, 2), textAt(numeric.value, 1), Number, dateLabel);
410
401
  const current = String$1.match(/^(?:de )?([0-3]?\d)(?:e|ste|de)?(?: van)? ([a-z]+\.?)$/u)(input);
411
402
  if (Option.isSome(current)) return namedCurrentYearDatePeriod(textAt(current.value, 2), textAt(current.value, 1), monthNumber, currentDateLabel);
412
403
  const relative = String$1.match(/^(?:de )?([0-3]?\d)(?:e|ste|de)? van (.+)$/u)(input);
@@ -555,14 +546,12 @@ const countedUnit = (value, amount) => {
555
546
  const alias = unitAliases.find((entry) => entry[0] === value && (entry[2] === expected || entry[2] === "both"));
556
547
  return alias === void 0 ? void 0 : units.find((entry) => entry.unit === alias[1]);
557
548
  };
558
- const countedUnitPattern = "dag|dagen|week|weken|maand|maanden|kwartaal|kwartalen|jaar|jaren";
559
- const countedPattern = (source) => new RegExp(source.replace("UNIT", countedUnitPattern), "u");
560
- const calendarPastPattern = countedPattern("^([1-9]\\d*) (UNIT) geleden$");
561
- const calendarFuturePatterns = [countedPattern("^(?:over|binnen) ([1-9]\\d*) (UNIT)$"), countedPattern("^([1-9]\\d*) (UNIT) later$")];
562
- const rollingPastPatterns = [countedPattern("^(?:(?:de|in de) )?(?:afgelopen|laatste|vorige) ([1-9]\\d*) (UNIT)$"), countedPattern("^([1-9]\\d*) (?:afgelopen|laatste|vorige) (UNIT)$")];
563
- const rollingFuturePatterns = [countedPattern("^(?:(?:de|in de|binnen de) )?(?:komende|volgende|aankomende) ([1-9]\\d*) (UNIT)$"), countedPattern("^([1-9]\\d*) (?:komende|volgende|aankomende) (UNIT)$")];
564
- const rollingSincePattern = countedPattern("^(?:sinds|gedurende) ([1-9]\\d*) (UNIT)$");
565
- const rollingBarePattern = countedPattern("^([1-9]\\d*) (UNIT)$");
549
+ const calendarPastPattern = /^([1-9]\d*) ([^ ]+) geleden$/u;
550
+ const calendarFuturePatterns = [/^(?:over|binnen) ([1-9]\d*) ([^ ]+)$/u, /^([1-9]\d*) ([^ ]+) later$/u];
551
+ const rollingPastPatterns = [/^(?:(?:de|in de) )?(?:afgelopen|laatste|vorige) ([1-9]\d*) ([^ ]+)$/u, /^([1-9]\d*) (?:afgelopen|laatste|vorige) ([^ ]+)$/u];
552
+ const rollingFuturePatterns = [/^(?:(?:de|in de|binnen de) )?(?:komende|volgende|aankomende) ([1-9]\d*) ([^ ]+)$/u, /^([1-9]\d*) (?:komende|volgende|aankomende) ([^ ]+)$/u];
553
+ const rollingSincePattern = /^(?:sinds|gedurende) ([1-9]\d*) ([^ ]+)$/u;
554
+ const rollingBarePattern = /^([1-9]\d*) ([^ ]+)$/u;
566
555
  const firstPatternMatch = (input, patterns) => Option.firstSomeOf(patterns.map((pattern) => String$1.match(pattern)(input)));
567
556
  const singularRollingCanonical = (entry, future) => future ? `vanaf nu gedurende een ${entry.singular}` : `sinds een ${entry.singular}`;
568
557
  const singularRollingPhrases = units.flatMap((entry) => [
@@ -1,10 +1,9 @@
1
- import { isIsoDate } from "../ast/schemas.mjs";
2
1
  import { BaseLanguageContribution } from "../language/model.mjs";
3
2
  import { normalizeNaturalText } from "../natural/text.mjs";
4
3
  import { defineLanguagePlugin, languagePluginsLayer } from "../language/registry.mjs";
5
4
  import { correctWhitespaceSeparatedText } from "../natural/correction.mjs";
6
5
  import { completeNaturalPhrases, fixedCalendarPeriodPhrases, naturalCount } from "../natural/suggestion.mjs";
7
- import { absoluteDatePeriod, calendarPeriodOffset, candidate, compileCountAliasNormalizer, compoundCountAliases, countAliasVocabulary, currentYearDatePeriods, datedPeriods, datedQuarterPeriods, decimalTens, decomposeShiftedPeriodRange, fixedDatePeriod, fixedMonthPeriod, fixedQuarterPeriod, fixedYearPeriod, fromNowRange, futurePeriod, futureRange, isoDate, joinedNowCandidate, joinedPeriodCandidate, monthOfRelativeYear, namedCurrentYearDatePeriod, namedDatePeriod, parseTrailingCount, periodBoundaryCandidate, periodEndDay, periodRange, periodStartDay, periodToDateRange, periodsFromPhrases, quarterOfRelativeYear, relativePeriod, relativeWeekday, relativeWeekend, remainingPeriodRange, renderPeriodRange, sequentialCountAliases, shiftPeriod, textAt, trailingPeriod, trailingRange, untilNowRange, validYear } from "./shared.mjs";
6
+ import { absoluteDatePeriod, calendarPeriodOffset, candidate, compileCountAliasNormalizer, compoundCountAliases, countAliasVocabulary, currentYearDatePeriods, datedPeriods, datedQuarterPeriods, decimalTens, decomposeShiftedPeriodRange, fixedMonthPeriod, fixedQuarterPeriod, fixedYearPeriod, fromNowRange, futurePeriod, futureRange, joinedNowCandidate, joinedPeriodCandidate, monthOfRelativeYear, namedCurrentYearDatePeriod, namedDatePeriod, parseTrailingCount, periodBoundaryCandidate, periodEndDay, periodRange, periodStartDay, periodToDateRange, periodsFromPhrases, quarterOfRelativeYear, relativePeriod, relativeWeekday, relativeWeekend, remainingPeriodRange, renderPeriodRange, sequentialCountAliases, shiftPeriod, textAt, trailingPeriod, trailingRange, untilNowRange, validYear } from "./shared.mjs";
8
7
  import { Effect, Option, String as String$1 } from "effect";
9
8
  //#region src/locales/pl.ts
10
9
  const months = [
@@ -536,15 +535,7 @@ const parseNamedDate = (input) => {
536
535
  const named = String$1.match(/^([0-3]?\d)\.?(?: )([a-ząćęłńóśźż]+\.?) (\d{4})$/u)(input);
537
536
  if (Option.isSome(named)) return namedDatePeriod(textAt(named.value, 3), textAt(named.value, 2), textAt(named.value, 1), monthNumber, dateLabel);
538
537
  const numeric = String$1.match(/^([0-3]?\d)(?:\. ?|[/-])([01]?\d)(?:\. ?|[/-])(\d{4})$/u)(input);
539
- if (Option.isSome(numeric)) {
540
- const year = validYear(textAt(numeric.value, 3));
541
- const month = Number(textAt(numeric.value, 2));
542
- const day = Number(textAt(numeric.value, 1));
543
- if (year !== void 0 && month >= 1 && month <= 12) {
544
- const value = isoDate(year, month, day);
545
- if (isIsoDate(value) && value !== "9999-12-31") return Option.some(fixedDatePeriod(value, dateLabel(day, month, year)));
546
- }
547
- }
538
+ if (Option.isSome(numeric)) return namedDatePeriod(textAt(numeric.value, 3), textAt(numeric.value, 2), textAt(numeric.value, 1), Number, dateLabel);
548
539
  const current = String$1.match(/^([0-3]?\d)\.? ([a-ząćęłńóśźż]+\.?)$/u)(input);
549
540
  return Option.isSome(current) ? namedCurrentYearDatePeriod(textAt(current.value, 2), textAt(current.value, 1), monthNumber, currentDateLabel) : Option.none();
550
541
  };
@@ -667,13 +658,11 @@ const parsePeriod = (input) => {
667
658
  return Option.isSome(base) ? base : parseCalendarOffset(input);
668
659
  };
669
660
  const countedUnit = (value) => unitAliases.find((entry) => entry[0] === value)?.[1];
670
- const countedUnitPattern = "dzień|dni|tydzień|tygodnie|tygodni|miesiąc|miesiące|miesięcy|kwartał|kwartały|kwartałów|rok|lata|lat";
671
- const countedPattern = (source) => new RegExp(source.replace("UNIT", countedUnitPattern), "u");
672
- const calendarPastPattern = countedPattern("^(?:dokładnie )?(?:([1-9]\\d*) )?(UNIT) temu$");
673
- const calendarFuturePattern = countedPattern("^za (?:([1-9]\\d*) )?(UNIT)$");
674
- const rollingPastPatterns = [countedPattern("^(?:ostatni|ostatnie|ostatnich|miniony|minione|minionych) ([1-9]\\d*) (UNIT)$"), countedPattern("^w ciągu (?:ostatniego|ostatnich|minionego|minionych) ([1-9]\\d*) (UNIT)$")];
675
- const rollingFuturePatterns = [countedPattern("^(?:następny|następne|następnych|kolejny|kolejne|kolejnych) ([1-9]\\d*) (UNIT)$"), countedPattern("^w ciągu (?:najbliższego|najbliższych) ([1-9]\\d*) (UNIT)$")];
676
- const rollingBarePattern = countedPattern("^([1-9]\\d*) (UNIT)$");
661
+ const calendarPastPattern = /^(?:dokładnie )?(?:([1-9]\d*) )?([^ ]+) temu$/u;
662
+ const calendarFuturePattern = /^za (?:([1-9]\d*) )?([^ ]+)$/u;
663
+ const rollingPastPatterns = [/^(?:ostatni|ostatnie|ostatnich|miniony|minione|minionych) ([1-9]\d*) ([^ ]+)$/u, /^w ciągu (?:ostatniego|ostatnich|minionego|minionych) ([1-9]\d*) ([^ ]+)$/u];
664
+ const rollingFuturePatterns = [/^(?:następny|następne|następnych|kolejny|kolejne|kolejnych) ([1-9]\d*) ([^ ]+)$/u, /^w ciągu (?:najbliższego|najbliższych) ([1-9]\d*) ([^ ]+)$/u];
665
+ const rollingBarePattern = /^([1-9]\d*) ([^ ]+)$/u;
677
666
  const firstPatternMatch = (input, patterns) => Option.firstSomeOf(patterns.map((pattern) => String$1.match(pattern)(input)));
678
667
  const countNoun = (amount, entry) => {
679
668
  if (amount === 1) return entry.singular;
@@ -803,7 +792,7 @@ const parsePolish = (input) => {
803
792
  "teraz do "
804
793
  ], parsePeriod, (period) => `od ${period} do dziś`, (period) => `od dziś do ${period}`);
805
794
  if (Option.isSome(nowBounded)) return nowBounded;
806
- const bounded = joinedPeriodCandidate(input, [
795
+ const bounded = joinedPeriodCandidate(input.replace(/ włącznie$/u, ""), [
807
796
  ["od ", " do "],
808
797
  ["między ", " a "],
809
798
  ["pomiędzy ", " a "],
@@ -8,10 +8,10 @@ import { Match, Option, RegExp as RegExp$1, Schema, String as String$1 } from "e
8
8
  const textAt = (values, index) => values[index] ?? "";
9
9
  const sequentialCountAliases = (words, start) => words.flatMap((aliases, index) => aliases.map((phrase) => [phrase, start + index]));
10
10
  const decimalTens = (words) => words.map((word, index) => [20 + index * 10, word]);
11
- const compoundCountAliases = (tens, ones, join) => tens.flatMap(([tensAmount, tensWord]) => ones.flatMap(([oneAmount, oneWord]) => {
11
+ const compoundCountAliases = (tens, ones, join) => tens.flatMap(([tensAmount, tensWord]) => [[tensWord, tensAmount], ...ones.flatMap(([oneAmount, oneWord]) => {
12
12
  const amount = tensAmount + oneAmount;
13
13
  return join(tensWord, oneWord, amount).map((phrase) => [phrase, amount]);
14
- }));
14
+ })]);
15
15
  const countAliasVocabulary = (aliases) => [...new Set(aliases.flatMap(([phrase]) => phrase.split(" ")))];
16
16
  const compileCountAliasNormalizer = (aliases) => {
17
17
  const distinct = /* @__PURE__ */ new Map();
@@ -93,7 +93,7 @@ const periodDay = (period, day, canonical) => {
93
93
  const start = day === 1 ? period.start : shift(period.start, day - 1, "day");
94
94
  return Option.some(Period.make({
95
95
  start,
96
- end: shift(start, 1, "day"),
96
+ end: shift(period.start, day, "day"),
97
97
  canonical
98
98
  }));
99
99
  };
@@ -108,7 +108,7 @@ const relativeWeekday = (day, direction, canonical) => {
108
108
  const start = day === 0 ? weekStart : shift(weekStart, day, "day");
109
109
  return Period.make({
110
110
  start,
111
- end: shift(start, 1, "day"),
111
+ end: shift(weekStart, day + 1, "day"),
112
112
  canonical
113
113
  });
114
114
  };
@@ -118,7 +118,7 @@ const relativeWeekend = (direction, canonical) => {
118
118
  const start = shift(weekStart, 5, "day");
119
119
  return Period.make({
120
120
  start,
121
- end: shift(start, 2, "day"),
121
+ end: shift(weekStart, 7, "day"),
122
122
  canonical
123
123
  });
124
124
  };
@@ -254,7 +254,7 @@ const currentYearDatePeriod = (month, day, canonical) => {
254
254
  const start = day === 1 ? monthStart : shift(monthStart, day - 1, "day");
255
255
  return Period.make({
256
256
  start,
257
- end: shift(start, 1, "day"),
257
+ end: shift(monthStart, day, "day"),
258
258
  canonical
259
259
  });
260
260
  };
@@ -332,7 +332,7 @@ const monthOfRelativeYear = (month, direction, canonical) => {
332
332
  const start = month === 1 ? yearStart : shift(yearStart, month - 1, "month");
333
333
  return Period.make({
334
334
  start,
335
- end: shift(start, 1, "month"),
335
+ end: shift(yearStart, month, "month"),
336
336
  canonical
337
337
  });
338
338
  };
@@ -1,10 +1,9 @@
1
- import { isIsoDate } from "../ast/schemas.mjs";
2
1
  import { BaseLanguageContribution } from "../language/model.mjs";
3
2
  import { normalizeNaturalText } from "../natural/text.mjs";
4
3
  import { defineLanguagePlugin, languagePluginsLayer } from "../language/registry.mjs";
5
4
  import { correctWhitespaceSeparatedText } from "../natural/correction.mjs";
6
5
  import { completeNaturalPhrases, fixedCalendarPeriodPhrases, naturalCount, prefixNaturalPhrases } from "../natural/suggestion.mjs";
7
- import { absoluteDatePeriod, calendarPeriodOffset, candidate, compileCountAliasNormalizer, compoundCountAliases, countAliasVocabulary, currentYearDatePeriods, datedPeriods, datedQuarterPeriods, decimalTens, decomposeShiftedPeriodRange, fixedDatePeriod, fixedMonthPeriod, fixedQuarterPeriod, fixedYearPeriod, fromNowRange, futurePeriod, futureRange, isoDate, joinedNowCandidate, joinedPeriodCandidate, monthOfRelativeYear, namedCurrentYearDatePeriod, namedDatePeriod, openBoundaryCandidate, parseTrailingCount, periodBoundaryCandidate, periodEndDay, periodRange, periodStartDay, periodToDateRange, periodsFromPhrases, quarterOfRelativeYear, relativePeriod, relativeWeekday, relativeWeekend, remainingPeriodRange, renderPeriodRange, sequentialCountAliases, shiftPeriod, textAt, trailingPeriod, trailingRange, untilNowRange, validYear } from "./shared.mjs";
6
+ import { absoluteDatePeriod, calendarPeriodOffset, candidate, compileCountAliasNormalizer, compoundCountAliases, countAliasVocabulary, currentYearDatePeriods, datedPeriods, datedQuarterPeriods, decimalTens, decomposeShiftedPeriodRange, fixedMonthPeriod, fixedQuarterPeriod, fixedYearPeriod, fromNowRange, futurePeriod, futureRange, joinedNowCandidate, joinedPeriodCandidate, monthOfRelativeYear, namedCurrentYearDatePeriod, namedDatePeriod, openBoundaryCandidate, parseTrailingCount, periodBoundaryCandidate, periodEndDay, periodRange, periodStartDay, periodToDateRange, periodsFromPhrases, quarterOfRelativeYear, relativePeriod, relativeWeekday, relativeWeekend, remainingPeriodRange, renderPeriodRange, sequentialCountAliases, shiftPeriod, textAt, trailingPeriod, trailingRange, untilNowRange, validYear } from "./shared.mjs";
8
7
  import { Effect, Option, String as String$1 } from "effect";
9
8
  //#region src/locales/tr.ts
10
9
  const months = [
@@ -358,15 +357,7 @@ const parseNamedDate = (input) => {
358
357
  const named = String$1.match(/^([0-3]?\d)(?:\.)? ([a-zçğıöşü]+\.?)(?:,)? (\d{4})$/u)(input);
359
358
  if (Option.isSome(named)) return namedDatePeriod(textAt(named.value, 3), textAt(named.value, 2), textAt(named.value, 1), monthNumber, dateLabel);
360
359
  const numeric = String$1.match(/^([0-3]?\d)[./-]([01]?\d)[./-](\d{4})$/u)(input);
361
- if (Option.isSome(numeric)) {
362
- const year = validYear(textAt(numeric.value, 3));
363
- const month = Number(textAt(numeric.value, 2));
364
- const day = Number(textAt(numeric.value, 1));
365
- if (year !== void 0 && month >= 1 && month <= 12) {
366
- const value = isoDate(year, month, day);
367
- if (isIsoDate(value) && value !== "9999-12-31") return Option.some(fixedDatePeriod(value, dateLabel(day, month, year)));
368
- }
369
- }
360
+ if (Option.isSome(numeric)) return namedDatePeriod(textAt(numeric.value, 3), textAt(numeric.value, 2), textAt(numeric.value, 1), Number, dateLabel);
370
361
  const current = String$1.match(/^([0-3]?\d)(?:\.)? ([a-zçğıöşü]+\.?)$/u)(input);
371
362
  return Option.isSome(current) ? namedCurrentYearDatePeriod(textAt(current.value, 2), textAt(current.value, 1), monthNumber, currentDateLabel) : Option.none();
372
363
  };
@@ -460,8 +451,7 @@ const parsePeriodEdge = (input) => {
460
451
  const period = Option.isSome(basePeriod) || implicit === void 0 ? basePeriod : Option.some(relativePeriod(implicit.unit, 0, implicit.current));
461
452
  if (Option.isNone(period)) return Option.none();
462
453
  const isEnd = textAt(edge.value, 2) === "sonu";
463
- const canonical = `${period.value.canonical} ${isEnd ? "sonu" : "başı"}`;
464
- return Option.some(isEnd ? periodEndDay(period.value, canonical) : periodStartDay(period.value, canonical));
454
+ return Option.some(isEnd ? periodEndDay(period.value, input) : periodStartDay(period.value, input));
465
455
  };
466
456
  const parsePeriod = (input) => {
467
457
  const prefix = String$1.match(/^([1-9]\d*) (gün|gun|hafta|ay|çeyrek|ceyrek|yıl|yil|sene) (önce|sonra) (.+)$/u)(input);
@@ -493,14 +483,12 @@ const parsePeriod = (input) => {
493
483
  ]);
494
484
  };
495
485
  const countedUnit = (value) => unitAliases.find((entry) => entry[0] === value)?.[1];
496
- const countedUnitPattern = "gün|gun|hafta|ay|çeyrek|ceyrek|yıl|yil|sene";
497
- const countedPattern = (source) => new RegExp(source.replace("UNIT", countedUnitPattern), "u");
498
- const calendarPastPattern = countedPattern("^([1-9]\\d*) (UNIT) önce$");
499
- const calendarFuturePatterns = [countedPattern("^([1-9]\\d*) (UNIT) sonra$"), countedPattern("^([1-9]\\d*) (UNIT) içinde$")];
500
- const rollingPastPatterns = [countedPattern("^(?:son|geçen|önceki|geçtiğimiz) ([1-9]\\d*) (UNIT)$"), countedPattern("^([1-9]\\d*) (?:son|geçen|önceki) (UNIT)$")];
501
- const rollingFuturePatterns = [countedPattern("^(?:gelecek|önümüzdeki|sonraki) ([1-9]\\d*) (UNIT)$"), countedPattern("^([1-9]\\d*) (?:gelecek|sonraki) (UNIT)$")];
502
- const rollingSincePattern = countedPattern("^([1-9]\\d*) (UNIT) boyunca$");
503
- const rollingBarePattern = countedPattern("^([1-9]\\d*) (UNIT)$");
486
+ const calendarPastPattern = /^([1-9]\d*) ([^ ]+) önce$/u;
487
+ const calendarFuturePatterns = [/^([1-9]\d*) ([^ ]+) sonra$/u, /^([1-9]\d*) ([^ ]+) içinde$/u];
488
+ const rollingPastPatterns = [/^(?:son|geçen|önceki|geçtiğimiz) ([1-9]\d*) ([^ ]+)$/u, /^([1-9]\d*) (?:son|geçen|önceki) ([^ ]+)$/u];
489
+ const rollingFuturePatterns = [/^(?:gelecek|önümüzdeki|sonraki) ([1-9]\d*) ([^ ]+)$/u, /^([1-9]\d*) (?:gelecek|sonraki) ([^ ]+)$/u];
490
+ const rollingSincePattern = /^([1-9]\d*) ([^ ]+) boyunca$/u;
491
+ const rollingBarePattern = /^([1-9]\d*) ([^ ]+)$/u;
504
492
  const firstPatternMatch = (input, patterns) => Option.firstSomeOf(patterns.map((pattern) => String$1.match(pattern)(input)));
505
493
  const singularRollingCanonical = (entry, future) => future ? `önümüzdeki bir ${entry.singular}` : `son bir ${entry.singular}`;
506
494
  const singularRollingPhrases = units.flatMap((entry) => [