@react-querybuilder/datetime 8.20.2 → 8.21.0

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.
Files changed (118) hide show
  1. package/dist/cjs/{getDatetimeRuleProcessorTanStackDB-cmGqMT0Q.js → getDatetimeRuleProcessorTanStackDB-CDEB9coD.js} +22 -19
  2. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-CDEB9coD.js.map +1 -0
  3. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-X6tZv7yV.js +2 -0
  4. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-X6tZv7yV.js.map +1 -0
  5. package/dist/cjs/react-querybuilder_datetime.cjs.development.d.ts +122 -138
  6. package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.d.ts +49 -50
  7. package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.js +2 -2
  8. package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.d.ts +49 -50
  9. package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js +2 -2
  10. package/dist/cjs/react-querybuilder_datetime.cjs.development.js +3 -2
  11. package/dist/cjs/react-querybuilder_datetime.cjs.development.js.map +1 -1
  12. package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.d.ts +52 -53
  13. package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js +2 -2
  14. package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.d.ts +49 -50
  15. package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js +2 -2
  16. package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.d.ts +100 -114
  17. package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.js +5 -3
  18. package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.js.map +1 -1
  19. package/dist/cjs/react-querybuilder_datetime.cjs.production.d.ts +122 -138
  20. package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.d.ts +49 -50
  21. package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.js +1 -1
  22. package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.d.ts +49 -50
  23. package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.js +1 -1
  24. package/dist/cjs/react-querybuilder_datetime.cjs.production.js +1 -1
  25. package/dist/cjs/react-querybuilder_datetime.cjs.production.js.map +1 -1
  26. package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.d.ts +52 -53
  27. package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.js +1 -1
  28. package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.d.ts +49 -50
  29. package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.js +1 -1
  30. package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.d.ts +100 -114
  31. package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js +1 -1
  32. package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js.map +1 -1
  33. package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-ioz2B1zh.js → rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js} +2 -2
  34. package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-ioz2B1zh.js.map → rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js.map} +1 -1
  35. package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-BPEcMhhr.js → rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js} +2 -2
  36. package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-BPEcMhhr.js.map → rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js.map} +1 -1
  37. package/dist/cjs/{types-Di8kFIXV.d.ts → types-BKA1aoY6.d.ts} +82 -73
  38. package/dist/cjs/utils-DdBYGWHZ.js +2 -0
  39. package/dist/cjs/utils-DdBYGWHZ.js.map +1 -0
  40. package/dist/cjs/{utils-DUePrC--.js → utils-_X97pUtk.js} +13 -1
  41. package/dist/cjs/utils-_X97pUtk.js.map +1 -0
  42. package/dist/getDatetimeRuleProcessorTanStackDB-6K1DsuEV.mjs +2 -0
  43. package/dist/getDatetimeRuleProcessorTanStackDB-6K1DsuEV.mjs.map +1 -0
  44. package/dist/{getDatetimeRuleProcessorTanStackDB-BDFJlfJh.js → getDatetimeRuleProcessorTanStackDB-BrSD2e9G.js} +22 -19
  45. package/dist/getDatetimeRuleProcessorTanStackDB-BrSD2e9G.js.map +1 -0
  46. package/dist/{getDatetimeRuleProcessorTanStackDB-B93XaPdB.mjs → getDatetimeRuleProcessorTanStackDB-DR8aYrUa.mjs} +22 -19
  47. package/dist/getDatetimeRuleProcessorTanStackDB-DR8aYrUa.mjs.map +1 -0
  48. package/dist/{objectSpread2-73AKOozq.js → objectSpread2-MqoZ2hSz.js} +13 -7
  49. package/dist/objectSpread2-MqoZ2hSz.js.map +1 -0
  50. package/dist/react-querybuilder_datetime.d.mts +122 -138
  51. package/dist/react-querybuilder_datetime.date-fns.d.mts +49 -50
  52. package/dist/react-querybuilder_datetime.date-fns.mjs +2 -2
  53. package/dist/react-querybuilder_datetime.dayjs.d.mts +49 -50
  54. package/dist/react-querybuilder_datetime.dayjs.mjs +2 -2
  55. package/dist/react-querybuilder_datetime.jsdate.d.mts +52 -53
  56. package/dist/react-querybuilder_datetime.jsdate.mjs +2 -2
  57. package/dist/react-querybuilder_datetime.legacy-esm.d.ts +122 -138
  58. package/dist/react-querybuilder_datetime.legacy-esm.date-fns.d.ts +49 -50
  59. package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js +2 -2
  60. package/dist/react-querybuilder_datetime.legacy-esm.dayjs.d.ts +49 -50
  61. package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js +2 -2
  62. package/dist/react-querybuilder_datetime.legacy-esm.js +3 -2
  63. package/dist/react-querybuilder_datetime.legacy-esm.js.map +1 -1
  64. package/dist/react-querybuilder_datetime.legacy-esm.jsdate.d.ts +52 -53
  65. package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js +2 -2
  66. package/dist/react-querybuilder_datetime.legacy-esm.luxon.d.ts +49 -50
  67. package/dist/react-querybuilder_datetime.legacy-esm.luxon.js +2 -2
  68. package/dist/react-querybuilder_datetime.legacy-esm.ui.d.ts +100 -114
  69. package/dist/react-querybuilder_datetime.legacy-esm.ui.js +7 -5
  70. package/dist/react-querybuilder_datetime.legacy-esm.ui.js.map +1 -1
  71. package/dist/react-querybuilder_datetime.luxon.d.mts +49 -50
  72. package/dist/react-querybuilder_datetime.luxon.mjs +2 -2
  73. package/dist/react-querybuilder_datetime.mjs +3 -2
  74. package/dist/react-querybuilder_datetime.mjs.map +1 -1
  75. package/dist/react-querybuilder_datetime.production.d.mts +122 -138
  76. package/dist/react-querybuilder_datetime.production.date-fns.d.mts +49 -50
  77. package/dist/react-querybuilder_datetime.production.date-fns.mjs +1 -1
  78. package/dist/react-querybuilder_datetime.production.dayjs.d.mts +49 -50
  79. package/dist/react-querybuilder_datetime.production.dayjs.mjs +1 -1
  80. package/dist/react-querybuilder_datetime.production.jsdate.d.mts +52 -53
  81. package/dist/react-querybuilder_datetime.production.jsdate.mjs +1 -1
  82. package/dist/react-querybuilder_datetime.production.luxon.d.mts +49 -50
  83. package/dist/react-querybuilder_datetime.production.luxon.mjs +1 -1
  84. package/dist/react-querybuilder_datetime.production.mjs +1 -1
  85. package/dist/react-querybuilder_datetime.production.mjs.map +1 -1
  86. package/dist/react-querybuilder_datetime.production.ui.d.mts +100 -114
  87. package/dist/react-querybuilder_datetime.production.ui.mjs +1 -1
  88. package/dist/react-querybuilder_datetime.production.ui.mjs.map +1 -1
  89. package/dist/react-querybuilder_datetime.ui.d.mts +100 -114
  90. package/dist/react-querybuilder_datetime.ui.mjs +5 -3
  91. package/dist/react-querybuilder_datetime.ui.mjs.map +1 -1
  92. package/dist/{rqbDateTimeLibraryAPI.jsdate-CpGoQAje.js → rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js} +2 -2
  93. package/dist/{rqbDateTimeLibraryAPI.jsdate-CpGoQAje.js.map → rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js.map} +1 -1
  94. package/dist/{rqbDateTimeLibraryAPI.jsdate-CDOtydFq.mjs → rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs} +2 -2
  95. package/dist/{rqbDateTimeLibraryAPI.jsdate-CDOtydFq.mjs.map → rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs.map} +1 -1
  96. package/dist/{rqbDateTimeLibraryAPI.jsdate-D66yJ1hK.mjs → rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs} +2 -2
  97. package/dist/{rqbDateTimeLibraryAPI.jsdate-D66yJ1hK.mjs.map → rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs.map} +1 -1
  98. package/dist/{types-Di8kFIXV.d.mts → types-BKA1aoY6.d.mts} +82 -73
  99. package/dist/{types-Di8kFIXV.d.ts → types-BKA1aoY6.d.ts} +82 -73
  100. package/dist/{utils-BC2SALFm.mjs → utils-BAgUBdyf.mjs} +8 -2
  101. package/dist/utils-BAgUBdyf.mjs.map +1 -0
  102. package/dist/utils-DA8aluCt.mjs +2 -0
  103. package/dist/utils-DA8aluCt.mjs.map +1 -0
  104. package/package.json +16 -16
  105. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-BVNfYaIj.js +0 -2
  106. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-BVNfYaIj.js.map +0 -1
  107. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-cmGqMT0Q.js.map +0 -1
  108. package/dist/cjs/utils-DUePrC--.js.map +0 -1
  109. package/dist/cjs/utils-jkW5R1AA.js +0 -2
  110. package/dist/cjs/utils-jkW5R1AA.js.map +0 -1
  111. package/dist/getDatetimeRuleProcessorTanStackDB-B93XaPdB.mjs.map +0 -1
  112. package/dist/getDatetimeRuleProcessorTanStackDB-BDFJlfJh.js.map +0 -1
  113. package/dist/getDatetimeRuleProcessorTanStackDB-Czg9Fbb8.mjs +0 -2
  114. package/dist/getDatetimeRuleProcessorTanStackDB-Czg9Fbb8.mjs.map +0 -1
  115. package/dist/objectSpread2-73AKOozq.js.map +0 -1
  116. package/dist/utils-BC2SALFm.mjs.map +0 -1
  117. package/dist/utils-VKS8YY2D.mjs +0 -2
  118. package/dist/utils-VKS8YY2D.mjs.map +0 -1
@@ -1,6 +1,5 @@
1
1
  import { RQBJsonLogic, RuleProcessor } from "@react-querybuilder/core";
2
2
  import { RulesLogic } from "json-logic-js";
3
-
4
3
  //#region src/types.d.ts
5
4
  interface RQBJsonLogicDateBetween {
6
5
  dateBetween: [RQBJsonLogic, RQBJsonLogic, RQBJsonLogic];
@@ -36,35 +35,35 @@ interface RQBJsonLogicDateRelative {
36
35
  dateRelative: [RelativeDateTimeAnchor, number, RelativeDateTimeUnit, boolean];
37
36
  }
38
37
  /**
39
- * JsonLogic rule object with additional operators generated by
40
- * {@link @react-querybuilder/core!formatQuery formatQuery} and accepted by
41
- * {@link @react-querybuilder/core!parseJsonLogic parseJsonLogic}.
42
- */
38
+ * JsonLogic rule object with additional operators generated by
39
+ * {@link @react-querybuilder/core!formatQuery formatQuery} and accepted by
40
+ * {@link @react-querybuilder/core!parseJsonLogic parseJsonLogic}.
41
+ */
43
42
  type RQBDateTimeJsonLogic = RQBJsonLogic | RulesLogic<RQBJsonLogicDateAfter | RQBJsonLogicDateBefore | RQBJsonLogicDateBetween | RQBJsonLogicDateIn | RQBJsonLogicDateNotBetween | RQBJsonLogicDateNotIn | RQBJsonLogicDateNotOn | RQBJsonLogicDateOn | RQBJsonLogicDateOnOrAfter | RQBJsonLogicDateOnOrBefore | RQBJsonLogicDateRelative>;
44
43
  type DateOrString = string | Date;
45
44
  /**
46
- * Unit of measure for a relative date/time offset.
47
- */
45
+ * Unit of measure for a relative date/time offset.
46
+ */
48
47
  type RelativeDateTimeUnit = "minute" | "hour" | "day" | "week" | "month" | "year";
49
48
  /**
50
- * Unit of measure for truncating a date/time to the start or end of a period
51
- * (the subset of {@link RelativeDateTimeUnit} that represents a calendar period).
52
- */
49
+ * Unit of measure for truncating a date/time to the start or end of a period
50
+ * (the subset of {@link RelativeDateTimeUnit} that represents a calendar period).
51
+ */
53
52
  type RelativeDateTimeTruncationUnit = "day" | "week" | "month" | "year";
54
53
  /**
55
- * Reference point (zero-offset) for a {@link RelativeDateTimeValue}. `'now'` is the
56
- * current date/time; the `startOf*`/`endOf*` anchors truncate to the start or end
57
- * of the corresponding calendar period.
58
- */
54
+ * Reference point (zero-offset) for a {@link RelativeDateTimeValue}. `'now'` is the
55
+ * current date/time; the `startOf*`/`endOf*` anchors truncate to the start or end
56
+ * of the corresponding calendar period.
57
+ */
59
58
  type RelativeDateTimeAnchor = "now" | "startOfDay" | "endOfDay" | "startOfWeek" | "endOfWeek" | "startOfMonth" | "endOfMonth" | "startOfYear" | "endOfYear";
60
59
  /**
61
- * Structured representation of a relative date/time value, e.g. "three months ago"
62
- * or "the beginning of this year". Stored as the `value` of a rule (in place of the
63
- * usual ISO 8601 string) and recognized by the date/time rule processors.
64
- *
65
- * The final date/time is computed as: apply the `anchor` to the current date/time,
66
- * then add `offset` units of `unit`. When `offset` is `0`, `unit` is irrelevant.
67
- */
60
+ * Structured representation of a relative date/time value, e.g. "three months ago"
61
+ * or "the beginning of this year". Stored as the `value` of a rule (in place of the
62
+ * usual ISO 8601 string) and recognized by the date/time rule processors.
63
+ *
64
+ * The final date/time is computed as: apply the `anchor` to the current date/time,
65
+ * then add `offset` units of `unit`. When `offset` is `0`, `unit` is irrelevant.
66
+ */
68
67
  interface RelativeDateTimeValue {
69
68
  /** Discriminant identifying a relative (as opposed to absolute) value. */
70
69
  mode: "relative";
@@ -77,89 +76,99 @@ interface RelativeDateTimeValue {
77
76
  }
78
77
  interface RQBDateTimeLibraryAPI {
79
78
  /**
80
- * Formats a date as a string.
81
- */
79
+ * Formats a date as a string.
80
+ */
82
81
  format: (d: DateOrString, fmt: string) => string;
83
82
  /**
84
- * Formats a date as an ISO 8601 string, only including
85
- * the year, month, and day ('YYYY-MM-DD').
86
- */
83
+ * Formats a date as an ISO 8601 string, only including
84
+ * the year, month, and day ('YYYY-MM-DD').
85
+ */
87
86
  toISOStringDateOnly: (d: DateOrString) => string;
88
87
  /**
89
- * Determines whether the first date is after the second date.
90
- */
88
+ * Determines whether the first date is after the second date.
89
+ */
91
90
  isAfter: (a: DateOrString, b: DateOrString) => boolean;
92
91
  /**
93
- * Determines whether the first date is before the second date.
94
- */
92
+ * Determines whether the first date is before the second date.
93
+ */
95
94
  isBefore: (a: DateOrString, b: DateOrString) => boolean;
96
95
  /**
97
- * Determines whether the first date is the same as the second date.
98
- *
99
- * If either the first date or the second date is a string in the
100
- * format 'YYYY-MM-DD', then the dates will only be compared at
101
- * the date level (no time component). Otherwise, they will be
102
- * compared to the millisecond.
103
- */
96
+ * Determines whether the first date is the same as the second date.
97
+ *
98
+ * If either the first date or the second date is a string in the
99
+ * format 'YYYY-MM-DD', then the dates will only be compared at
100
+ * the date level (no time component). Otherwise, they will be
101
+ * compared to the millisecond.
102
+ */
104
103
  isSame: (a: DateOrString, b: DateOrString) => boolean;
105
104
  /**
106
- * Determines whether the date is either a valid `Date` object or an
107
- * ISO 8601-formatted string representing a valid date.
108
- */
105
+ * Determines whether the date is either a valid `Date` object or an
106
+ * ISO 8601-formatted string representing a valid date.
107
+ */
109
108
  isValid: (d: DateOrString) => boolean;
110
109
  /**
111
- * Converts a string to a `Date` object or returns a valid `Date` as is.
112
- */
110
+ * Converts a string to a `Date` object or returns a valid `Date` as is.
111
+ */
113
112
  toDate: (d: DateOrString) => Date;
114
113
  /**
115
- * Converts a `Date` or ISO 8601-formatted string into a full ISO 8601 UTC
116
- * string, in the format 'YYYY-MM-DDTHH:mm:ss.SSSZ' (the "T" and "Z" are
117
- * static; other parts represent standard time units, increasing in precision
118
- * from left to right).
119
- */
114
+ * Converts a `Date` or ISO 8601-formatted string into a full ISO 8601 UTC
115
+ * string, in the format 'YYYY-MM-DDTHH:mm:ss.SSSZ' (the "T" and "Z" are
116
+ * static; other parts represent standard time units, increasing in precision
117
+ * from left to right).
118
+ */
120
119
  toISOString: (d: DateOrString) => string;
121
120
  /**
122
- * Returns a new `Date` truncated to the start of the given period.
123
- *
124
- * Week start follows the date library's own default/locale (e.g. Luxon uses
125
- * Monday per ISO 8601; Day.js and date-fns default to Sunday).
126
- */
121
+ * Returns a new `Date` truncated to the start of the given period.
122
+ *
123
+ * Week start follows the date library's own default/locale (e.g. Luxon uses
124
+ * Monday per ISO 8601; Day.js and date-fns default to Sunday).
125
+ */
127
126
  startOf: (d: DateOrString, unit: RelativeDateTimeTruncationUnit) => Date;
128
127
  /**
129
- * Returns a new `Date` advanced to the end of the given period (the last
130
- * representable instant within it).
131
- *
132
- * Week start follows the date library's own default/locale (see {@link RQBDateTimeLibraryAPI.startOf}).
133
- */
128
+ * Returns a new `Date` advanced to the end of the given period (the last
129
+ * representable instant within it).
130
+ *
131
+ * Week start follows the date library's own default/locale (see {@link RQBDateTimeLibraryAPI.startOf}).
132
+ */
134
133
  endOf: (d: DateOrString, unit: RelativeDateTimeTruncationUnit) => Date;
135
134
  /**
136
- * Returns a new `Date` offset from the input by `amount` units of `unit`
137
- * (negative `amount` moves into the past).
138
- */
135
+ * Returns a new `Date` offset from the input by `amount` units of `unit`
136
+ * (negative `amount` moves into the past).
137
+ */
139
138
  add: (d: DateOrString, amount: number, unit: RelativeDateTimeUnit) => Date;
140
139
  }
141
140
  type FnDateDate = (a: DateOrString, b: DateOrString) => boolean;
142
141
  type FnDateArrayOfDates = (a: DateOrString, b: DateOrString[]) => boolean;
143
142
  type FnDateDateDate = (a: DateOrString, b: DateOrString, c: DateOrString) => boolean;
144
143
  type RQBJsonLogicDateTimeOperations = {
145
- /** Determines if the first date is after the second date. */dateAfter: FnDateDate; /** Determines if the first date is before the second date. */
146
- dateBefore: FnDateDate; /** Determines if the second date is between the first and third dates (inclusive). */
147
- dateBetween: FnDateDateDate; /** Determines if the first date is one of the values in the array of dates. */
148
- dateIn: FnDateArrayOfDates; /** Determines if the second date is not between the first and third dates. */
149
- dateNotBetween: FnDateDateDate; /** Determines if the first date is not one of the values in the array of dates. */
150
- dateNotIn: FnDateArrayOfDates; /** Determines if the first date is not the same as the second date. */
151
- dateNotOn: FnDateDate; /** Determines if the first date is the same as the second date (at the level of least precision between the two). */
152
- dateOn: FnDateDate; /** Determines if the first date is either the same as the second date or after it. */
153
- dateOnOrAfter: FnDateDate; /** Determines if the first date is either the same as the second date or before it. */
144
+ /** Determines if the first date is after the second date. */
145
+ dateAfter: FnDateDate;
146
+ /** Determines if the first date is before the second date. */
147
+ dateBefore: FnDateDate;
148
+ /** Determines if the second date is between the first and third dates (inclusive). */
149
+ dateBetween: FnDateDateDate;
150
+ /** Determines if the first date is one of the values in the array of dates. */
151
+ dateIn: FnDateArrayOfDates;
152
+ /** Determines if the second date is not between the first and third dates. */
153
+ dateNotBetween: FnDateDateDate;
154
+ /** Determines if the first date is not one of the values in the array of dates. */
155
+ dateNotIn: FnDateArrayOfDates;
156
+ /** Determines if the first date is not the same as the second date. */
157
+ dateNotOn: FnDateDate;
158
+ /** Determines if the first date is the same as the second date (at the level of least precision between the two). */
159
+ dateOn: FnDateDate;
160
+ /** Determines if the first date is either the same as the second date or after it. */
161
+ dateOnOrAfter: FnDateDate;
162
+ /** Determines if the first date is either the same as the second date or before it. */
154
163
  dateOnOrBefore: FnDateDate;
155
164
  /**
156
- * Resolves a relative date/time descriptor (anchor, offset, unit, and date-only
157
- * flag) to a concrete ISO 8601 string at evaluation time ("live" semantics).
158
- */
165
+ * Resolves a relative date/time descriptor (anchor, offset, unit, and date-only
166
+ * flag) to a concrete ISO 8601 string at evaluation time ("live" semantics).
167
+ */
159
168
  dateRelative: (anchor: RelativeDateTimeAnchor, offset: number, unit: RelativeDateTimeUnit, dateOnly: boolean) => string;
160
169
  };
161
170
  type IsDateFieldFunction = (...[rule, opts]: Parameters<RuleProcessor>) => boolean;
162
171
  type IsDateField = IsDateFieldFunction | Record<string, unknown> | Record<string, unknown>[] | boolean | undefined;
163
172
  //#endregion
164
173
  export { RelativeDateTimeAnchor as _, RQBJsonLogicDateAfter as a, RelativeDateTimeValue as b, RQBJsonLogicDateIn as c, RQBJsonLogicDateNotOn as d, RQBJsonLogicDateOn as f, RQBJsonLogicDateTimeOperations as g, RQBJsonLogicDateRelative as h, RQBDateTimeLibraryAPI as i, RQBJsonLogicDateNotBetween as l, RQBJsonLogicDateOnOrBefore as m, IsDateFieldFunction as n, RQBJsonLogicDateBefore as o, RQBJsonLogicDateOnOrAfter as p, RQBDateTimeJsonLogic as r, RQBJsonLogicDateBetween as s, IsDateField as t, RQBJsonLogicDateNotIn as u, RelativeDateTimeTruncationUnit as v, RelativeDateTimeUnit as y };
165
- //# sourceMappingURL=types-Di8kFIXV.d.ts.map
174
+ //# sourceMappingURL=types-BKA1aoY6.d.ts.map
@@ -1,6 +1,12 @@
1
1
  //#region src/utils.ts
2
2
  const isISOStringDateOnly = (date) => typeof date === "string" && /^\d{4}-\d{2}-\d{2}$/.test(date);
3
3
  /**
4
+ * Whether a rule's value source is one that datetime processors must NOT materialize as a
5
+ * date (`field` references another column; `parameter` is a named bind placeholder). Both
6
+ * are delegated to the core default processor, which serializes them per format.
7
+ */
8
+ const isNonDateValueSource = (valueSource) => valueSource === "field" || valueSource === "parameter";
9
+ /**
4
10
  * Type guard for {@link RelativeDateTimeValue}. Relative values are stored as objects
5
11
  * (distinguishing them from the ISO 8601 strings used for absolute date/time values).
6
12
  */
@@ -102,6 +108,6 @@ const processIsDateField = (isDateField, ...[rule, opts]) => {
102
108
  return defaultIsDateField(rule, opts);
103
109
  };
104
110
  //#endregion
105
- export { materializeRelativeValues as a, resolveRelativeDateTime as c, materializeForExport as i, isISOStringDateOnly as n, processIsDateField as o, isRelativeDateTimeValue as r, resolveDatetimeOperator as s, isDateOnlyDatatype as t };
111
+ export { materializeForExport as a, resolveDatetimeOperator as c, isRelativeDateTimeValue as i, resolveRelativeDateTime as l, isISOStringDateOnly as n, materializeRelativeValues as o, isNonDateValueSource as r, processIsDateField as s, isDateOnlyDatatype as t };
106
112
 
107
- //# sourceMappingURL=utils-BC2SALFm.mjs.map
113
+ //# sourceMappingURL=utils-BAgUBdyf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-BAgUBdyf.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { RuleProcessor, ValueSource } from '@react-querybuilder/core';\nimport type {\n IsDateField,\n IsDateFieldFunction,\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeValue,\n RQBDateTimeLibraryAPI,\n} from './types';\n\nexport const isISOStringDateOnly = (\n date: unknown\n): date is `${number}${number}${number}${number}-${number}${number}-${number}${number}` =>\n typeof date === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(date);\n\n/**\n * Whether a rule's value source is one that datetime processors must NOT materialize as a\n * date (`field` references another column; `parameter` is a named bind placeholder). Both\n * are delegated to the core default processor, which serializes them per format.\n */\nexport const isNonDateValueSource = (valueSource: ValueSource | undefined): boolean =>\n valueSource === 'field' || valueSource === 'parameter';\n\n/**\n * Type guard for {@link RelativeDateTimeValue}. Relative values are stored as objects\n * (distinguishing them from the ISO 8601 strings used for absolute date/time values).\n */\nexport const isRelativeDateTimeValue = (value: unknown): value is RelativeDateTimeValue =>\n typeof value === 'object' &&\n value !== null &&\n (value as { mode?: unknown }).mode === 'relative' &&\n typeof (value as RelativeDateTimeValue).anchor === 'string';\n\nconst anchorRegExp = /^(start|end)Of(Day|Week|Month|Year)$/;\n\n/**\n * Resolves a {@link RelativeDateTimeValue} into a concrete `Date` using the given\n * date library API. The anchor is applied relative to `base` (defaulting to now),\n * then the signed offset is added.\n */\nexport const resolveRelativeDateTime = (\n apiFns: RQBDateTimeLibraryAPI,\n value: RelativeDateTimeValue,\n base: Date = new Date()\n): Date => {\n let result: Date = base;\n\n if (value.anchor !== 'now') {\n const match = anchorRegExp.exec(value.anchor);\n // v8 ignore next -- guarded by the RelativeDateTimeAnchor type\n if (match) {\n const unit = match[2].toLowerCase() as RelativeDateTimeTruncationUnit;\n result = match[1] === 'start' ? apiFns.startOf(result, unit) : apiFns.endOf(result, unit);\n }\n }\n\n if (value.offset) {\n result = apiFns.add(result, value.offset, value.unit);\n }\n\n return result;\n};\n\n/**\n * Whether a `datatype` represents a date-only (no time component) type, e.g. `date`\n * but not `datetime`/`datetimeoffset`/`timestamp`. Used to choose the precision when\n * materializing a relative value to an ISO 8601 string.\n */\nexport const isDateOnlyDatatype = (datatype: unknown): boolean =>\n /^date\\b/i.test(datatype as string);\n\n/**\n * Replaces any {@link RelativeDateTimeValue} in `value` (or in each element, if `value`\n * is an array) with a concrete ISO 8601 string, resolved via\n * {@link resolveRelativeDateTime}. The \"now\" reference can be pinned with\n * `opts.context.relativeDateTimeBase` for deterministic output; precision (date-only vs\n * full) follows the field's `datatype`. Non-relative values pass through unchanged.\n */\nexport const materializeRelativeValues = (\n apiFns: RQBDateTimeLibraryAPI,\n value: unknown,\n opts: Parameters<RuleProcessor>[1]\n): unknown => {\n const base = opts?.context?.relativeDateTimeBase as Date | undefined;\n const dateOnly = isDateOnlyDatatype(opts?.fieldData?.datatype);\n const conv = (v: unknown): unknown => {\n if (!isRelativeDateTimeValue(v)) return v;\n const resolved = resolveRelativeDateTime(apiFns, v, base);\n return dateOnly ? apiFns.toISOStringDateOnly(resolved) : apiFns.toISOString(resolved);\n };\n return Array.isArray(value) ? value.map(conv) : conv(value);\n};\n\n/**\n * Resolves a rule's operator for export, applying any `context.relativeOperatorMap`\n * entry. Operator-driven mode controllers (see `createOperatorModeController`) use\n * dedicated operator names to signal relative mode; this maps those names to the real\n * comparison operator at format time. Operators absent from the map pass through unchanged.\n */\nexport const resolveDatetimeOperator = (...[rule, opts]: Parameters<RuleProcessor>): string =>\n (opts?.context?.relativeOperatorMap as Record<string, string> | undefined)?.[rule.operator] ??\n rule.operator;\n\n/**\n * Prepares a date/time rule for delegation to a non-symbolic default rule processor\n * (e.g. \"parameterized\", \"spel\", \"ldap\", \"gremlin\", \"prisma\", \"sequelize\", \"drizzle\",\n * \"tanstack_db\"). Relative values are materialized to concrete dates (these formats have\n * no symbolic relative form), and `between`/`notBetween` operands are ordered\n * chronologically (defaults can't reorder non-numeric date operands). When `asDate` is\n * set, each valid value is converted to a `Date` (for object-based formats); otherwise\n * the materialized ISO 8601 strings are passed through. The resolved `operator` (after\n * any `relativeOperatorMap` mapping) is returned alongside the prepared `value`.\n */\nexport const materializeForExport = (\n apiFns: RQBDateTimeLibraryAPI,\n rule: Parameters<RuleProcessor>[0],\n opts: Parameters<RuleProcessor>[1],\n asDate = false\n): { operator: string; value: unknown } => {\n const operator = resolveDatetimeOperator(rule, opts);\n const materialized = materializeRelativeValues(apiFns, rule.value, opts);\n\n let prepared = materialized;\n if (Array.isArray(materialized) && materialized.length >= 2) {\n const opLC = operator.toLowerCase();\n if (opLC === 'between' || opLC === 'notbetween') {\n const first = apiFns.toDate(materialized[0] as string | Date);\n const second = apiFns.toDate(materialized[1] as string | Date);\n if (apiFns.isValid(first) && apiFns.isValid(second) && !apiFns.isBefore(first, second)) {\n prepared = [materialized[1], materialized[0], ...materialized.slice(2)];\n }\n }\n }\n\n if (!asDate) return { operator, value: prepared };\n\n const toDateVal = (v: unknown) => {\n const d = apiFns.toDate(v as string | Date);\n return apiFns.isValid(d) ? d : v;\n };\n return {\n operator,\n value: Array.isArray(prepared) ? prepared.map(toDateVal) : toDateVal(prepared),\n };\n};\n\nexport const defaultIsDateField: IsDateFieldFunction = (\n ...[rule, opts]: Parameters<RuleProcessor>\n): boolean =>\n rule.operator !== 'contains' &&\n rule.operator !== 'beginsWith' &&\n rule.operator !== 'endsWith' &&\n rule.operator !== 'doesNotContain' &&\n rule.operator !== 'doesNotBeginWith' &&\n rule.operator !== 'doesNotEndWith' &&\n rule.operator !== 'null' &&\n rule.operator !== 'notNull' &&\n /^(?:date|datetime|datetimeoffset|timestamp)\\b/i.test(opts?.fieldData?.datatype as string);\n\nexport const processIsDateField = (\n isDateField: IsDateField,\n ...[rule, opts]: Parameters<RuleProcessor>\n): boolean => {\n if (typeof isDateField === 'boolean') {\n return isDateField;\n }\n\n if (typeof isDateField === 'function') {\n return isDateField(rule, opts);\n }\n\n if (Array.isArray(isDateField)) {\n return isDateField.some(condition =>\n Object.entries(condition).every(([key, value]) => opts?.fieldData?.[key] === value)\n );\n }\n\n if (typeof isDateField === 'object') {\n return Object.entries(isDateField).every(([key, value]) => opts?.fieldData?.[key] === value);\n }\n\n return defaultIsDateField(rule, opts);\n};\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ const e=e=>typeof e==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e),t=e=>e===`field`||e===`parameter`,n=e=>typeof e==`object`&&!!e&&e.mode===`relative`&&typeof e.anchor==`string`,r=/^(start|end)Of(Day|Week|Month|Year)$/,i=(e,t,n=new Date)=>{let i=n;if(t.anchor!==`now`){let n=r.exec(t.anchor);if(n){let t=n[2].toLowerCase();i=n[1]===`start`?e.startOf(i,t):e.endOf(i,t)}}return t.offset&&(i=e.add(i,t.offset,t.unit)),i},a=e=>/^date\b/i.test(e),o=(e,t,r)=>{let o=r?.context?.relativeDateTimeBase,s=a(r?.fieldData?.datatype),c=t=>{if(!n(t))return t;let r=i(e,t,o);return s?e.toISOStringDateOnly(r):e.toISOString(r)};return Array.isArray(t)?t.map(c):c(t)},s=(...[e,t])=>t?.context?.relativeOperatorMap?.[e.operator]??e.operator,c=(e,t,n,r=!1)=>{let i=s(t,n),a=o(e,t.value,n),c=a;if(Array.isArray(a)&&a.length>=2){let t=i.toLowerCase();if(t===`between`||t===`notbetween`){let t=e.toDate(a[0]),n=e.toDate(a[1]);e.isValid(t)&&e.isValid(n)&&!e.isBefore(t,n)&&(c=[a[1],a[0],...a.slice(2)])}}if(!r)return{operator:i,value:c};let l=t=>{let n=e.toDate(t);return e.isValid(n)?n:t};return{operator:i,value:Array.isArray(c)?c.map(l):l(c)}},l=(...[e,t])=>e.operator!==`contains`&&e.operator!==`beginsWith`&&e.operator!==`endsWith`&&e.operator!==`doesNotContain`&&e.operator!==`doesNotBeginWith`&&e.operator!==`doesNotEndWith`&&e.operator!==`null`&&e.operator!==`notNull`&&/^(?:date|datetime|datetimeoffset|timestamp)\b/i.test(t?.fieldData?.datatype),u=(e,...[t,n])=>typeof e==`boolean`?e:typeof e==`function`?e(t,n):Array.isArray(e)?e.some(e=>Object.entries(e).every(([e,t])=>n?.fieldData?.[e]===t)):typeof e==`object`?Object.entries(e).every(([e,t])=>n?.fieldData?.[e]===t):l(t,n);export{c as a,s as c,n as i,i as l,e as n,o,t as r,u as s,a as t};
2
+ //# sourceMappingURL=utils-DA8aluCt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-DA8aluCt.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { RuleProcessor, ValueSource } from '@react-querybuilder/core';\nimport type {\n IsDateField,\n IsDateFieldFunction,\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeValue,\n RQBDateTimeLibraryAPI,\n} from './types';\n\nexport const isISOStringDateOnly = (\n date: unknown\n): date is `${number}${number}${number}${number}-${number}${number}-${number}${number}` =>\n typeof date === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(date);\n\n/**\n * Whether a rule's value source is one that datetime processors must NOT materialize as a\n * date (`field` references another column; `parameter` is a named bind placeholder). Both\n * are delegated to the core default processor, which serializes them per format.\n */\nexport const isNonDateValueSource = (valueSource: ValueSource | undefined): boolean =>\n valueSource === 'field' || valueSource === 'parameter';\n\n/**\n * Type guard for {@link RelativeDateTimeValue}. Relative values are stored as objects\n * (distinguishing them from the ISO 8601 strings used for absolute date/time values).\n */\nexport const isRelativeDateTimeValue = (value: unknown): value is RelativeDateTimeValue =>\n typeof value === 'object' &&\n value !== null &&\n (value as { mode?: unknown }).mode === 'relative' &&\n typeof (value as RelativeDateTimeValue).anchor === 'string';\n\nconst anchorRegExp = /^(start|end)Of(Day|Week|Month|Year)$/;\n\n/**\n * Resolves a {@link RelativeDateTimeValue} into a concrete `Date` using the given\n * date library API. The anchor is applied relative to `base` (defaulting to now),\n * then the signed offset is added.\n */\nexport const resolveRelativeDateTime = (\n apiFns: RQBDateTimeLibraryAPI,\n value: RelativeDateTimeValue,\n base: Date = new Date()\n): Date => {\n let result: Date = base;\n\n if (value.anchor !== 'now') {\n const match = anchorRegExp.exec(value.anchor);\n // v8 ignore next -- guarded by the RelativeDateTimeAnchor type\n if (match) {\n const unit = match[2].toLowerCase() as RelativeDateTimeTruncationUnit;\n result = match[1] === 'start' ? apiFns.startOf(result, unit) : apiFns.endOf(result, unit);\n }\n }\n\n if (value.offset) {\n result = apiFns.add(result, value.offset, value.unit);\n }\n\n return result;\n};\n\n/**\n * Whether a `datatype` represents a date-only (no time component) type, e.g. `date`\n * but not `datetime`/`datetimeoffset`/`timestamp`. Used to choose the precision when\n * materializing a relative value to an ISO 8601 string.\n */\nexport const isDateOnlyDatatype = (datatype: unknown): boolean =>\n /^date\\b/i.test(datatype as string);\n\n/**\n * Replaces any {@link RelativeDateTimeValue} in `value` (or in each element, if `value`\n * is an array) with a concrete ISO 8601 string, resolved via\n * {@link resolveRelativeDateTime}. The \"now\" reference can be pinned with\n * `opts.context.relativeDateTimeBase` for deterministic output; precision (date-only vs\n * full) follows the field's `datatype`. Non-relative values pass through unchanged.\n */\nexport const materializeRelativeValues = (\n apiFns: RQBDateTimeLibraryAPI,\n value: unknown,\n opts: Parameters<RuleProcessor>[1]\n): unknown => {\n const base = opts?.context?.relativeDateTimeBase as Date | undefined;\n const dateOnly = isDateOnlyDatatype(opts?.fieldData?.datatype);\n const conv = (v: unknown): unknown => {\n if (!isRelativeDateTimeValue(v)) return v;\n const resolved = resolveRelativeDateTime(apiFns, v, base);\n return dateOnly ? apiFns.toISOStringDateOnly(resolved) : apiFns.toISOString(resolved);\n };\n return Array.isArray(value) ? value.map(conv) : conv(value);\n};\n\n/**\n * Resolves a rule's operator for export, applying any `context.relativeOperatorMap`\n * entry. Operator-driven mode controllers (see `createOperatorModeController`) use\n * dedicated operator names to signal relative mode; this maps those names to the real\n * comparison operator at format time. Operators absent from the map pass through unchanged.\n */\nexport const resolveDatetimeOperator = (...[rule, opts]: Parameters<RuleProcessor>): string =>\n (opts?.context?.relativeOperatorMap as Record<string, string> | undefined)?.[rule.operator] ??\n rule.operator;\n\n/**\n * Prepares a date/time rule for delegation to a non-symbolic default rule processor\n * (e.g. \"parameterized\", \"spel\", \"ldap\", \"gremlin\", \"prisma\", \"sequelize\", \"drizzle\",\n * \"tanstack_db\"). Relative values are materialized to concrete dates (these formats have\n * no symbolic relative form), and `between`/`notBetween` operands are ordered\n * chronologically (defaults can't reorder non-numeric date operands). When `asDate` is\n * set, each valid value is converted to a `Date` (for object-based formats); otherwise\n * the materialized ISO 8601 strings are passed through. The resolved `operator` (after\n * any `relativeOperatorMap` mapping) is returned alongside the prepared `value`.\n */\nexport const materializeForExport = (\n apiFns: RQBDateTimeLibraryAPI,\n rule: Parameters<RuleProcessor>[0],\n opts: Parameters<RuleProcessor>[1],\n asDate = false\n): { operator: string; value: unknown } => {\n const operator = resolveDatetimeOperator(rule, opts);\n const materialized = materializeRelativeValues(apiFns, rule.value, opts);\n\n let prepared = materialized;\n if (Array.isArray(materialized) && materialized.length >= 2) {\n const opLC = operator.toLowerCase();\n if (opLC === 'between' || opLC === 'notbetween') {\n const first = apiFns.toDate(materialized[0] as string | Date);\n const second = apiFns.toDate(materialized[1] as string | Date);\n if (apiFns.isValid(first) && apiFns.isValid(second) && !apiFns.isBefore(first, second)) {\n prepared = [materialized[1], materialized[0], ...materialized.slice(2)];\n }\n }\n }\n\n if (!asDate) return { operator, value: prepared };\n\n const toDateVal = (v: unknown) => {\n const d = apiFns.toDate(v as string | Date);\n return apiFns.isValid(d) ? d : v;\n };\n return {\n operator,\n value: Array.isArray(prepared) ? prepared.map(toDateVal) : toDateVal(prepared),\n };\n};\n\nexport const defaultIsDateField: IsDateFieldFunction = (\n ...[rule, opts]: Parameters<RuleProcessor>\n): boolean =>\n rule.operator !== 'contains' &&\n rule.operator !== 'beginsWith' &&\n rule.operator !== 'endsWith' &&\n rule.operator !== 'doesNotContain' &&\n rule.operator !== 'doesNotBeginWith' &&\n rule.operator !== 'doesNotEndWith' &&\n rule.operator !== 'null' &&\n rule.operator !== 'notNull' &&\n /^(?:date|datetime|datetimeoffset|timestamp)\\b/i.test(opts?.fieldData?.datatype as string);\n\nexport const processIsDateField = (\n isDateField: IsDateField,\n ...[rule, opts]: Parameters<RuleProcessor>\n): boolean => {\n if (typeof isDateField === 'boolean') {\n return isDateField;\n }\n\n if (typeof isDateField === 'function') {\n return isDateField(rule, opts);\n }\n\n if (Array.isArray(isDateField)) {\n return isDateField.some(condition =>\n Object.entries(condition).every(([key, value]) => opts?.fieldData?.[key] === value)\n );\n }\n\n if (typeof isDateField === 'object') {\n return Object.entries(isDateField).every(([key, value]) => opts?.fieldData?.[key] === value);\n }\n\n return defaultIsDateField(rule, opts);\n};\n"],"mappings":"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"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-querybuilder/datetime",
3
3
  "description": "Date/time features for react-querybuilder",
4
- "version": "8.20.2",
4
+ "version": "8.21.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -109,43 +109,43 @@
109
109
  "devDependencies": {
110
110
  "@electric-sql/pglite": "^0.5.3",
111
111
  "@grafeo-db/js": "^0.5.42",
112
- "@prisma/client": "^7.7.0",
113
- "@tanstack/db": "^0.6.9",
112
+ "@prisma/client": "^7.9.0",
113
+ "@tanstack/db": "^0.6.16",
114
114
  "@testing-library/dom": "^10.4.1",
115
115
  "@testing-library/react": "^16.3.2",
116
116
  "@testing-library/user-event": "14.6.1",
117
117
  "@types/luxon": "^3.7.1",
118
118
  "@types/react": "^19.2.17",
119
- "@vitejs/plugin-react": "^6.0.2",
119
+ "@vitejs/plugin-react": "^6.0.4",
120
120
  "date-fns": "^4.4.0",
121
121
  "dayjs": "^1.11.20",
122
122
  "drizzle-orm": "^0.45.2",
123
123
  "json-logic-js": "^2.0.5",
124
- "jsonata": "^2.2.0",
124
+ "jsonata": "^2.2.2",
125
125
  "luxon": "^3.7.2",
126
126
  "mongodb-memory-server-core": "^11.2.0",
127
- "mongoose": "^9.7.1",
127
+ "mongoose": "^9.8.0",
128
128
  "pglite-prisma-adapter": "^0.7.2",
129
- "prisma": "^7.7.0",
130
- "react": "^19.2.7",
131
- "react-dom": "^19.2.7",
132
- "react-querybuilder": "8.20.2",
129
+ "prisma": "^7.9.0",
130
+ "react": "^19.2.8",
131
+ "react-dom": "^19.2.8",
132
+ "react-querybuilder": "8.21.0",
133
133
  "rollup-plugin-visualizer": "^7.0.1",
134
- "sass": "^1.101.0",
134
+ "sass": "^1.101.7",
135
135
  "sequelize": "^6.37.8",
136
136
  "sqlite3": "^6.0.1",
137
- "typescript": "^6.0.2",
138
- "vite": "^8.0.16"
137
+ "typescript": "^7.0.2",
138
+ "vite": "^8.1.5"
139
139
  },
140
140
  "dependencies": {
141
- "@react-querybuilder/core": "8.20.2"
141
+ "@react-querybuilder/core": "8.21.0"
142
142
  },
143
143
  "peerDependencies": {
144
144
  "date-fns": ">=4.1.0",
145
145
  "dayjs": ">=1",
146
146
  "luxon": ">=3.5.0",
147
147
  "react": ">=18",
148
- "react-querybuilder": "8.20.2"
148
+ "react-querybuilder": "8.21.0"
149
149
  },
150
150
  "peerDependenciesMeta": {
151
151
  "date-fns": {
@@ -164,5 +164,5 @@
164
164
  "optional": true
165
165
  }
166
166
  },
167
- "gitHead": "57e2d2ae18513501fed44f206c122d20f361ab01"
167
+ "gitHead": "30316a24a5bb5a56e32eabc28cc3c3b4cfdfdaf8"
168
168
  }
@@ -1,2 +0,0 @@
1
- const e=require("./utils-jkW5R1AA.js");let t=require("@react-querybuilder/core");const n=t=>{let{isAfter:n,isBefore:r,isSame:i}=t;return{dateAfter:(e,t)=>n(e,t),dateBefore:(e,t)=>r(e,t),dateBetween:(e,t,a)=>i(t,e)||i(t,a)||n(t,e)&&r(t,a)||n(t,a)&&r(t,e),dateNotBetween:(e,t,a)=>!i(t,e)&&!i(t,a)&&(r(e,a)&&(r(t,e)||n(t,a))||n(e,a)&&(r(t,a)||n(t,e))),dateIn:(e,t)=>t.some(t=>i(e,t)),dateNotIn:(e,t)=>t.every(t=>!i(e,t)),dateNotOn:(e,t)=>!i(e,t),dateOn:(e,t)=>i(e,t),dateOnOrAfter:(e,t)=>n(e,t)||i(e,t),dateOnOrBefore:(e,t)=>r(e,t)||i(e,t),dateRelative:(n,r,i,a)=>{let o=e.c(t,{mode:`relative`,anchor:n,offset:r,unit:i});return a?t.toISOStringDateOnly(o):t.toISOString(o)}}},r=e=>/^(does)?not/i.test(e),i=n=>(i,a)=>{let o=a??{},{context:s={}}=o;if(i.valueSource===`field`||!e.o(s.isDateField,i,o))return(0,t.defaultRuleProcessorCEL)(i,o);let c=e=>`timestamp("${n.toISOString(e)}")`,l=e.a(n,i.value,o),u=(0,t.lc)(e.s(i,o).replace(/^=$/,`==`));switch(u){case`<`:case`<=`:case`==`:case`!=`:case`>`:case`>=`:return`${i.field} ${u} ${c(l)}`}let d=(0,t.toArray)(l,{retainEmptyStrings:!1}).map(e=>n.toDate(e)).filter(e=>n.isValid(e));switch(u){case`in`:case`notin`:{if(d.length===0)return``;let[e,t]=r(u)?[`!(`,`)`]:[``,``];return`${e}${i.field} in [${d.map(e=>c(e)).join(`, `)}]${t}`}case`between`:case`notbetween`:{if(d.length<2)return``;let[e,t]=d,[r,a]=n.isBefore(e,t)?[e,t]:[t,e];return u===`between`?`(${i.field} >= ${c(r)} && ${i.field} <= ${c(a)})`:`(${i.field} < ${c(r)} || ${i.field} > ${c(a)})`}}return(0,t.defaultRuleProcessorCEL)(i,o)},a=e=>/^(does)?not/i.test(e),o=(e,t)=>t?`date('${e}')`:`datetime('${e}')`,s=n=>(r,i)=>{let s=i??{},{context:c={}}=s;if(r.valueSource===`field`||!e.o(c.isDateField,r,s))return(0,t.defaultRuleProcessorCypher)(r,s);let{field:l}=r,u=(0,t.lc)(e.s(r,s));if(u===`olderthanduration`)return`datetime() - ${l} > duration('${r.value}')`;if(u===`withinduration`)return`datetime() - ${l} <= duration('${r.value}')`;let d=(0,t.toArray)(e.a(n,r.value,s),{retainEmptyStrings:!1}).map(e=>[e,n.toDate(e)]).filter(([,e])=>n.isValid(e)),f=t=>{let r=e.n(t);return o(r?n.toISOStringDateOnly(t):n.toISOString(t),r)};switch(u){case`in`:case`notin`:{if(d.length===0)return``;let e=d.map(([e])=>f(e));return`${a(u)?`NOT `:``}${l} IN [${e.join(`, `)}]`}case`between`:case`notbetween`:{if(d.length<2)return``;let[e,t]=d,[r,i]=n.isBefore(e[1],t[1])?[e,t]:[t,e],a=`${f(r[0])} <= ${l} AND ${l} <= ${f(i[0])}`;return u===`notbetween`?`NOT (${a})`:a}default:{if(d.length===0)return``;let[e]=d[0];return`${l} ${u===`<>`?`<>`:u} ${f(e)}`}}},c=n=>(r,i)=>{let a=i??{},{context:o={}}=a;if(r.valueSource===`field`||!e.o(o.isDateField,r,a))return(0,t.defaultRuleProcessorDrizzle)(r,a);let{operator:s,value:c}=e.i(n,r,a,!0);return(0,t.defaultRuleProcessorDrizzle)({...r,operator:s,value:c},a)},l=n=>(r,i)=>{let a=i??{},{context:o={}}=a;if(r.valueSource===`field`||!e.o(o.isDateField,r,a))return(0,t.defaultRuleProcessorElasticSearch)(r,a);let{operator:s,value:c}=e.i(n,r,a);return(0,t.defaultRuleProcessorElasticSearch)({...r,operator:s,value:c},a)},u=n=>(r,i)=>{let a=i??{},{context:o={}}=a;if(r.valueSource===`field`||!e.o(o.isDateField,r,a))return(0,t.defaultRuleProcessorGremlin)(r,a);let{operator:s,value:c}=e.i(n,r,a);return(0,t.defaultRuleProcessorGremlin)({...r,operator:s,value:c},a)},d=e=>/^(does)?not/i.test(e),f=(e,t)=>t?`$not(${e})`:`${e}`,p=n=>(r,i)=>{let a=i??{},{context:o={}}=a,{quoteFieldNamesWith:s=[``,``],fieldIdentifierSeparator:c=``}=a,{field:l,valueSource:u}=r,p=e.s(r,a);if(!e.o(o.isDateField,r,a))return(0,t.defaultRuleProcessorJSONata)(r,a);let m=u===`field`,h=m?r.value:e.a(n,r.value,a),g=e=>`$toMillis(${(0,t.getQuotedFieldName)(e,{quoteFieldNamesWith:s,fieldIdentifierSeparator:c})})`,_=e=>`$toMillis("${n.toISOString(e)}")`;switch(p){case`<`:case`<=`:case`=`:case`!=`:case`>`:case`>=`:return`${g(l)} ${p} ${m?g(h):_(h)}`}let v=(0,t.toArray)(h,{retainEmptyStrings:!1}),y=v.map(e=>n.toDate(e)).filter(e=>n.isValid(e));switch(p){case`in`:case`notIn`:return m?v.length===0?``:f(`${g(l)} in [${v.map(e=>g(e)).join(`, `)}]`,d(p)):y.length===0?``:f(`${g(l)} in [${y.map(e=>_(e)).join(`, `)}]`,d(p));case`between`:case`notBetween`:{if(v.length<2||(0,t.nullOrUndefinedOrEmpty)(v[0])||(0,t.nullOrUndefinedOrEmpty)(v[1])||!m&&y.length<2)return``;if(m){let[e,t]=v,n=`${g(l)} >= ${g(e)} and ${g(l)} <= ${g(t)}`;return p===`between`?`(${n})`:f(n,!0)}let[e,r]=y,[i,a]=n.isBefore(e,r)?[e,r]:[r,e],o=`${g(l)} >= ${_(i)} and ${g(l)} <= ${_(a)}`;return p===`between`?`(${o})`:f(o,!0)}}return(0,t.defaultRuleProcessorJSONata)(r,a)},m=n=>(r,i)=>{let a=i??{},{context:o={}}=a;if(r.valueSource===`field`||!e.o(o.isDateField,r,a))return(0,t.defaultRuleProcessorLDAP)(r,a);let{operator:s,value:c}=e.i(n,r,a);return(0,t.defaultRuleProcessorLDAP)({...r,operator:s,value:c},a)},h=n=>(r,i)=>{let a=i??{},{field:o,valueSource:s}=r,c=e.s(r,a);if(s===`field`||!e.o(a.context?.isDateField,r,a))return(0,t.defaultRuleProcessorMongoDBQuery)(r,a);let l=e.a(n,r.value,a);if(c===`=`)return{[o]:n.toDate(l)};switch(c){case`<`:case`<=`:case`!=`:case`>`:case`>=`:return{[o]:{[t.mongoOperators[c]]:n.toDate(l)}}}let u=(0,t.toArray)(l,{retainEmptyStrings:!1}).map(e=>n.toDate(e)).filter(e=>n.isValid(e));switch(c){case`in`:case`notIn`:return{[o]:{[t.mongoOperators[c]]:u}};case`between`:case`notBetween`:{if(u.length<2)return``;let[e,t]=u,r=n.isBefore(e,t)?[e,t]:[t,e];return c===`between`?{[o]:{$gte:r[0],$lte:r[1]}}:{$or:[{[o]:{$lt:r[0]}},{[o]:{$gt:r[1]}}]}}}return(0,t.defaultRuleProcessorMongoDBQuery)(r,a)},g=e=>{let t=h(e);return(e,n)=>{let r=t(e,n);return r?JSON.stringify(r):``}},_={"<":`is before`,">":`is after`,"<=":`is on or before`,">=":`is on or after`,in:[`is one of the dates`,`is the same as a date in`],notin:[`is not one of the dates`,`is not the same as any date in`],between:[`is between`,`is between the dates in`],notbetween:[`is not between`,`is not between the dates in`]},v=(t,n)=>e.n(n?.context?.originalValue)?new Intl.DateTimeFormat(n?.context?.locales,{dateStyle:`full`,...n?.context?.dateFormat}).format(t.value):new Intl.DateTimeFormat(n?.context?.locales,{dateStyle:`full`,timeStyle:`long`,...n?.context?.dateTimeFormat}).format(t.value),y=n=>(r,i)=>{let a=i??{},o=e.s(r,a),s=(0,t.lc)(o),c=``,{fieldData:l,quoteFieldNamesWith:u=[``,``],fieldIdentifierSeparator:d=``,operatorProcessor:f=t.defaultOperatorProcessorNL,wordOrder:p=`SVO`,context:m={},operatorMap:h=_}=a;if(!e.o(m.isDateField,r,a))return(0,t.defaultRuleProcessorNL)(r,a);if(r.valueSource===`field`)return(0,t.defaultRuleProcessorNL)(r,{...a,operatorMap:_});if((s===`in`||s===`notin`||s===`between`||s===`notbetween`)&&!r.value)return``;let g=(0,t.toArray)(e.a(n,r.value,a),{retainEmptyStrings:!1}).map(e=>[e,n.toDate(e)]).filter(e=>n.isValid(e[1]));switch(s){case`in`:case`notin`:if(g.length===0)return``;c=`(${g.map(e=>v({field:r.field,operator:`=`,value:e[1]},{...a,context:{...m,originalValue:e[0]}})).join(`, `)})`;break;case`between`:case`notbetween`:{if(g.length<2)return``;let[e,t]=g;c=(n.isBefore(e[1],t[1])?[e,t]:[t,e]).map(([e,t])=>v({field:r.field,operator:`=`,value:t},{...a,context:{...m,originalValue:e}})).join(` ${a.translations?.and??`and`} `)}break;default:{let[e,t]=g[0]??[``,``];c=e?v({field:r.field,operator:`=`,value:t},{...a,context:{...m,originalValue:e}}):``}}let y={S:(0,t.getQuotedFieldName)(l?.label??r.field,{quoteFieldNamesWith:u,fieldIdentifierSeparator:d}),V:f({...r,operator:o},{...a,operatorMap:{..._,...h}}),O:c};return(0,t.normalizeConstituentWordOrder)(p).map(e=>`${y[e]}`).join(` `).trim()},b=n=>(r,i,a)=>{let o=i??{},{context:s={}}=o;if(r.valueSource===`field`||!e.o(s.isDateField,r,o))return(0,t.defaultRuleProcessorParameterized)(r,o,a);let{operator:c,value:l}=e.i(n,r,o);return(0,t.defaultRuleProcessorParameterized)({...r,operator:c,value:l},o,a)},x=n=>(r,i)=>{let a=i??{},{context:o={}}=a;if(r.valueSource===`field`||!e.o(o.isDateField,r,a))return(0,t.defaultRuleProcessorPrisma)(r,a);let{operator:s,value:c}=e.i(n,r,a,!0);return(0,t.defaultRuleProcessorPrisma)({...r,operator:s,value:c},a)},S=n=>(r,i)=>{let a=i??{},{context:o={}}=a;if(r.valueSource===`field`||!e.o(o.isDateField,r,a))return(0,t.defaultRuleProcessorSequelize)(r,a);let{operator:s,value:c}=e.i(n,r,a,!0);return(0,t.defaultRuleProcessorSequelize)({...r,operator:s,value:c},a)},C=e=>/^(does)?not/i.test(e),w=(e,t)=>t?`"${e}"^^xsd:date`:`"${e}"^^xsd:dateTime`,T=n=>(r,i)=>{let a=i??{},{context:o={}}=a;if(r.valueSource===`field`||!e.o(o.isDateField,r,a))return(0,t.defaultRuleProcessorSPARQL)(r,a);let{field:s,value:c}=r,l=e.s(r,a),u=(0,t.sparqlVar)(s),d=(0,t.lc)(l);if(d===`olderthanduration`)return`NOW() - ${u} > "${c}"^^xsd:duration`;if(d===`withinduration`)return`NOW() - ${u} <= "${c}"^^xsd:duration`;let f=(0,t.toArray)(e.a(n,c,a),{retainEmptyStrings:!1}).map(e=>[e,n.toDate(e)]).filter(([,e])=>n.isValid(e)),p=t=>{let r=e.n(t);return w(r?n.toISOStringDateOnly(t):n.toISOString(t),r)};switch(d){case`in`:case`notin`:{if(f.length===0)return``;let e=f.map(([e])=>p(e));return`${u} ${C(d)?`NOT `:``}IN (${e.join(`, `)})`}case`between`:case`notbetween`:{if(f.length<2)return``;let[e,t]=f,[r,i]=n.isBefore(e[1],t[1])?[e,t]:[t,e];return d===`notbetween`?`(${u} < ${p(r[0])} || ${u} > ${p(i[0])})`:`${u} >= ${p(r[0])} && ${u} <= ${p(i[0])}`}default:{if(f.length===0)return``;let[e]=f[0];return`${u} ${d===`<>`?`!=`:d} ${p(e)}`}}},E=n=>(r,i)=>{let a=i??{},{context:o={}}=a;if(r.valueSource===`field`||!e.o(o.isDateField,r,a))return(0,t.defaultRuleProcessorSpEL)(r,a);let{operator:s,value:c}=e.i(n,r,a);return(0,t.defaultRuleProcessorSpEL)({...r,operator:s,value:c},a)},D=e=>{if(e===`now`)return{bound:`now`};let t=/^(start|end)Of(Day|Week|Month|Year)$/.exec(e);return{bound:t[1],unit:t[2].toLowerCase()}},O=e=>`${e}s`,k=(e,t)=>{let n=t?`current_date`:`current_timestamp`,{bound:r,unit:i}=D(e.anchor),a=n,o=!1;if(r===`start`&&i?(a=`date_trunc('${i}', ${n})`,o=!0):r===`end`&&i&&(a=`date_trunc('${i}', ${n}) + interval '1 ${i}' - ${t?`interval '1 day'`:`interval '1 microsecond'`}`,o=!0),e.offset){let t=e.offset<0?`-`:`+`;a=`${a} ${t} interval '${Math.abs(e.offset)} ${O(e.unit)}'`,o=!0}return t&&o?`cast(${a} as date)`:a},A=(e,t,n)=>{if(t===`start`)switch(n){case`day`:return`date(${e})`;case`week`:return`date_sub(date(${e}), interval dayofweek(${e}) - 1 day)`;case`month`:return`date_format(${e}, '%Y-%m-01')`;case`year`:return`date_format(${e}, '%Y-01-01')`}switch(n){case`day`:return`date(${e})`;case`week`:return`date_add(date(${e}), interval 7 - dayofweek(${e}) day)`;case`month`:return`last_day(${e})`}return`date_format(${e}, '%Y-12-31')`},j=(e,t)=>{let n=t?`curdate()`:`now()`,{bound:r,unit:i}=D(e.anchor),a=n;return r!==`now`&&i&&(a=A(n,r,i),r===`end`&&!t&&(a=`date_sub(date_add(${a}, interval 1 day), interval 1 microsecond)`)),e.offset&&(a=`${e.offset<0?`date_sub`:`date_add`}(${a}, interval ${Math.abs(e.offset)} ${e.unit})`),a},M=(e,t,n,r)=>{let i=`dateadd(${n}, datediff(${n}, 0, ${e}), 0)`;if(t===`start`)return i;let a=`dateadd(${n}, datediff(${n}, 0, ${e}) + 1, 0)`;return r?`dateadd(day, -1, ${a})`:`dateadd(nanosecond, -100, cast(${a} as datetime2))`},N=(e,t)=>{let n=t?`cast(getdate() as date)`:`getdate()`,{bound:r,unit:i}=D(e.anchor),a=n;return r!==`now`&&i&&(a=M(n,r,i,t)),e.offset&&(a=`dateadd(${e.unit}, ${e.offset}, ${a})`),a},P={day:`DDD`,week:`IW`,month:`MM`,year:`YYYY`},F=(e,t)=>{let n=t?`trunc(sysdate)`:`systimestamp`,{bound:r,unit:i}=D(e.anchor),a=n,o=!1;if(r!==`now`&&i){let e=`trunc(${n}, '${P[i]}')`;if(r===`start`)a=e;else{let n=i===`month`||i===`year`?`add_months(${e}, ${i===`month`?1:12})`:`${e} + interval '1' day${i===`week`?` * 7`:``}`;t?a=`${n} - interval '1' second`:(a=n,o=!0)}}if(e.offset)if(e.unit===`month`||e.unit===`year`)a=`add_months(${a}, ${e.offset*(e.unit===`year`?12:1)})`;else{let t={day:1,week:7}[e.unit];a=t?`${a} ${e.offset<0?`-`:`+`} ${Math.abs(e.offset)*t}`:`${a} + numtodsinterval(${e.offset}, '${e.unit.toUpperCase()}')`}return o&&(a=`cast(${a} as timestamp) - numtodsinterval(0.000001, 'second')`),a},I={day:`'start of day'`,week:`'weekday 0', '-7 days'`,month:`'start of month'`,year:`'start of year'`},L={ansi:k,mssql:N,mysql:j,oracle:F,postgresql:k,sqlite:(e,t)=>{let n=t?`date`:`datetime`,r=[`'now'`],{bound:i,unit:a}=D(e.anchor);if(i!==`now`&&a)if(i===`start`)r.push(I[a]);else switch(a){case`day`:r.push(`'start of day'`,`'+1 day'`,t?`'-1 day'`:`'-1 second'`);break;case`week`:r.push(`'weekday 0'`,t?`'-1 day'`:`'-1 second'`);break;case`month`:r.push(`'start of month'`,`'+1 month'`,t?`'-1 day'`:`'-1 second'`);break;case`year`:r.push(`'start of year'`,`'+1 year'`,t?`'-1 day'`:`'-1 second'`);break}if(e.offset){let t=e.offset<0?`-`:`+`;r.push(`'${t}${Math.abs(e.offset)} ${O(e.unit)}'`)}return`${n}(${r.join(`, `)})`}},R=(e,t)=>{let n=t;switch(e){case`mssql`:return!/^(?:small)?datetime/i.test(n);case`mysql`:return!/^(?:datetime|timestamp)/i.test(n);case`oracle`:case`postgresql`:return!/^timestamp/i.test(n);default:return!/^(?:datetime|timestamp)/i.test(n)}},z=(e,t,n)=>L[t](e,R(t,n)),B=({toISOStringDateOnly:n,toISOString:r})=>(i,a)=>e.n(a?.context?.originalValue)?(0,t.defaultValueProcessorByRule)({...i,value:n(i.value)},a):(0,t.defaultValueProcessorByRule)({...i,value:r(i.value)},a),V=({toISOStringDateOnly:e,toISOString:n})=>(r,i)=>{let a=/^(?:small)?datetime/i.test(i?.fieldData?.datatype)?`datetimeoffset`:`date`,o=a===`datetimeoffset`?n(r.value):e(r.value);return(0,t.defaultValueProcessorByRule)({...r,value:o},{...i,wrapValueWith:[`cast(`,` as ${a})`]})},H=({toISOStringDateOnly:e,toISOString:n})=>(r,i)=>{let a=/^(?:datetime|timestamp)/i.test(i?.fieldData?.datatype)?`datetime`:`date`,o=a===`datetime`?n(r.value):e(r.value);return(0,t.defaultValueProcessorByRule)({...r,value:o},{...i,wrapValueWith:[`cast(`,` as ${a})`]})},U=({toISOStringDateOnly:e,toISOString:n})=>(r,i)=>{let a=/^timestamp/i.test(i?.fieldData?.datatype)?`timestamp`:`date`,o=a===`timestamp`?n(r.value).replaceAll(`T`,` `).replace(`Z`,` UTC`):e(r.value);return(0,t.defaultValueProcessorByRule)({...r,value:o},{...i,wrapValueWith:[a,``]})},W=({toISOStringDateOnly:e,toISOString:n})=>(r,i)=>{let a=/^timestamp/i.test(i?.fieldData?.datatype)?`timestamp`:`date`,o=a===`timestamp`?n(r.value):e(r.value);return(0,t.defaultValueProcessorByRule)({...r,value:o},{...i,wrapValueWith:[a,``]})},G={ansi:B,mssql:V,mysql:H,oracle:U,postgresql:W,sqlite:B},K=n=>(r,i)=>{let a=i??{},o=(0,t.mapSQLOperator)(e.s(r,a)),s=(0,t.lc)(o),{quoteFieldNamesWith:c=[``,``],fieldIdentifierSeparator:l=``,context:u={}}=a,d=``;if(r.valueSource===`field`||!e.o(u.isDateField,r,a))return(0,t.defaultRuleProcessorSQL)(r,a);let f=G[a.preset](n),p=(0,t.getQuotedFieldName)(r.field,{quoteFieldNamesWith:c,fieldIdentifierSeparator:l}),m=u.materializeRelativeDateTime?e.a(n,r.value,a):r.value,h=Array.isArray(m)?m:[m];if(h.some(e.r)){let t=t=>{if(e.r(t))return z(t,a.preset,a.fieldData?.datatype);let i=n.toDate(t);if(n.isValid(i))return f({field:r.field,operator:`=`,value:i},{...a,context:{originalValue:t}})};switch(s){case`in`:case`not in`:{let e=h.map(t).filter(e=>e!==void 0);if(e.length===0)return``;d=`(${e.join(`, `)})`;break}case`between`:case`not between`:{let e=t(h[0]),n=t(h[1]);if(e===void 0||n===void 0)return``;d=`${e} and ${n}`;break}default:{let e=t(h[0]);if(e===void 0)return``;d=e}}return`${p} ${o} ${d}`.trim()}let g=(0,t.toArray)(m,{retainEmptyStrings:!1}).map(e=>[e,n.toDate(e)]).filter(e=>n.isValid(e[1]));switch(s){case`in`:case`not in`:if(g.length===0)return``;d=`(${g.map(e=>f({field:r.field,operator:`=`,value:e[1]},{...a,context:{originalValue:e[0]}})).join(`, `)})`;break;case`between`:case`not between`:{if(g.length<2)return``;let[e,t]=g;d=(n.isBefore(e[1],t[1])?[e,t]:[t,e]).map(([e,t])=>f({field:r.field,operator:`=`,value:t},{...a,context:{originalValue:e}})).join(` and `)}break;default:{let[e,t]=g[0]??[``,``];d=f({field:r.field,operator:`=`,value:t},{...a,context:{originalValue:e}})}}return`${p} ${o} ${d}`.trim()},q=n=>(r,i)=>{let a=i??{},{context:o={}}=a;if(r.valueSource===`field`||!e.o(o.isDateField,r,a))return(0,t.defaultRuleProcessorTanStackDB)(r,a);let{operator:s,value:c}=e.i(n,r,a,!0);return(0,t.defaultRuleProcessorTanStackDB)({...r,operator:s,value:c},a)};Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return p}});
2
- //# sourceMappingURL=getDatetimeRuleProcessorTanStackDB-BVNfYaIj.js.map