@dev-blinq/bvt-playwright-js 1.0.0-dev.3 → 1.0.0-dev.4
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.
- package/index.d.mts +182 -14
- package/index.mjs +2939 -137
- package/index.mjs.map +1 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6265,9 +6265,12 @@ const ProjectBrowserLaunchConfigurationSchema = object({
|
|
|
6265
6265
|
height: 900
|
|
6266
6266
|
} })
|
|
6267
6267
|
}).strict();
|
|
6268
|
+
const ProjectGitCodegenFormats = ["playwright", "gherkin"];
|
|
6269
|
+
const ProjectGitCodegenFormatSchema = _enum(ProjectGitCodegenFormats).default("playwright");
|
|
6268
6270
|
const ProjectSettingsSchema = object({
|
|
6269
6271
|
_id: EntityIdSchema,
|
|
6270
6272
|
projectId: EntityIdSchema,
|
|
6273
|
+
gitCodegenFormat: ProjectGitCodegenFormatSchema,
|
|
6271
6274
|
browerLaunchConfiguration: ProjectBrowserLaunchConfigurationSchema.default({
|
|
6272
6275
|
browser: {},
|
|
6273
6276
|
browserContext: { viewport: {
|
|
@@ -12157,11 +12160,11 @@ function attachDownloadInterceptor(page, options) {
|
|
|
12157
12160
|
//#endregion
|
|
12158
12161
|
//#region ../../core/bvt-agent/src/agent/recovery/types.ts
|
|
12159
12162
|
const RECOVERY_USER_FACING_MESSAGES = {
|
|
12160
|
-
analyzing: "
|
|
12161
|
-
trying_fix: "
|
|
12162
|
-
checking_fix: "
|
|
12163
|
-
fixed: "
|
|
12164
|
-
failed: "
|
|
12163
|
+
analyzing: "AI Test Engineer is analyzing the failure",
|
|
12164
|
+
trying_fix: "AI Test Engineer is trying a fix",
|
|
12165
|
+
checking_fix: "AI Test Engineer is checking the fix",
|
|
12166
|
+
fixed: "AI Test Engineer fixed this automatically",
|
|
12167
|
+
failed: "AI Test Engineer could not fix this automatically"
|
|
12165
12168
|
};
|
|
12166
12169
|
|
|
12167
12170
|
//#endregion
|
|
@@ -13642,10 +13645,10 @@ function nextLineBreak(code, from, end) {
|
|
|
13642
13645
|
var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
|
|
13643
13646
|
var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
|
|
13644
13647
|
var ref = Object.prototype;
|
|
13645
|
-
var hasOwnProperty = ref.hasOwnProperty;
|
|
13648
|
+
var hasOwnProperty$1 = ref.hasOwnProperty;
|
|
13646
13649
|
var toString = ref.toString;
|
|
13647
13650
|
var hasOwn = Object.hasOwn || (function(obj, propName) {
|
|
13648
|
-
return hasOwnProperty.call(obj, propName);
|
|
13651
|
+
return hasOwnProperty$1.call(obj, propName);
|
|
13649
13652
|
});
|
|
13650
13653
|
var isArray = Array.isArray || (function(obj) {
|
|
13651
13654
|
return toString.call(obj) === "[object Array]";
|
|
@@ -20614,6 +20617,213 @@ async function executePlaywrightCode({ page, code, context, timeoutMs = PLAYWRIG
|
|
|
20614
20617
|
}
|
|
20615
20618
|
}
|
|
20616
20619
|
|
|
20620
|
+
//#endregion
|
|
20621
|
+
//#region ../../shared/observability/src/logger.ts
|
|
20622
|
+
function extractEventName(metadata) {
|
|
20623
|
+
if (!metadata) return {};
|
|
20624
|
+
const rawEventName = metadata.eventName;
|
|
20625
|
+
if (typeof rawEventName !== "string" || rawEventName.trim().length === 0) return { sanitizedMetadata: metadata };
|
|
20626
|
+
const { eventName: _eventName, ...restMetadata } = metadata;
|
|
20627
|
+
return {
|
|
20628
|
+
eventName: rawEventName,
|
|
20629
|
+
sanitizedMetadata: Object.keys(restMetadata).length > 0 ? restMetadata : void 0
|
|
20630
|
+
};
|
|
20631
|
+
}
|
|
20632
|
+
var Logger = class Logger {
|
|
20633
|
+
constructor(transports, defaultContext = { system: true }) {
|
|
20634
|
+
this.transports = transports;
|
|
20635
|
+
this.defaultContext = defaultContext;
|
|
20636
|
+
}
|
|
20637
|
+
debug(message, metadata, context) {
|
|
20638
|
+
this.emit("debug", message, metadata, context);
|
|
20639
|
+
}
|
|
20640
|
+
info(message, metadata, context) {
|
|
20641
|
+
this.emit("info", message, metadata, context);
|
|
20642
|
+
}
|
|
20643
|
+
warn(message, metadata, context) {
|
|
20644
|
+
this.emit("warn", message, metadata, context);
|
|
20645
|
+
}
|
|
20646
|
+
error(message, metadata, context) {
|
|
20647
|
+
this.emit("error", message, metadata, context);
|
|
20648
|
+
}
|
|
20649
|
+
/** Returns a new Logger instance bound to the given context. */
|
|
20650
|
+
withContext(context) {
|
|
20651
|
+
return new Logger(this.transports, context);
|
|
20652
|
+
}
|
|
20653
|
+
emit(level, message, metadata, context) {
|
|
20654
|
+
const { eventName, sanitizedMetadata } = extractEventName(metadata);
|
|
20655
|
+
const entry = {
|
|
20656
|
+
level,
|
|
20657
|
+
message,
|
|
20658
|
+
...eventName ? { eventName } : {},
|
|
20659
|
+
context: context ?? this.defaultContext,
|
|
20660
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
20661
|
+
metadata: sanitizedMetadata
|
|
20662
|
+
};
|
|
20663
|
+
for (const transport of this.transports) try {
|
|
20664
|
+
const result = transport.log?.(entry);
|
|
20665
|
+
if (result instanceof Promise) result.catch((err) => {
|
|
20666
|
+
console.error(`[observability] Transport "${transport.name}" log() failed:`, err);
|
|
20667
|
+
});
|
|
20668
|
+
} catch (err) {
|
|
20669
|
+
console.error(`[observability] Transport "${transport.name}" log() threw:`, err);
|
|
20670
|
+
}
|
|
20671
|
+
}
|
|
20672
|
+
};
|
|
20673
|
+
|
|
20674
|
+
//#endregion
|
|
20675
|
+
//#region ../../shared/observability/src/error-serialization.ts
|
|
20676
|
+
const DEFAULT_MAX_DEPTH = 8;
|
|
20677
|
+
const DEFAULT_MAX_ARRAY_LENGTH = 100;
|
|
20678
|
+
const DEFAULT_MAX_OBJECT_KEYS = 100;
|
|
20679
|
+
const DEFAULT_MAX_STRING_LENGTH = Number.MAX_SAFE_INTEGER;
|
|
20680
|
+
const ERROR_FIELD_NAMES = [
|
|
20681
|
+
"name",
|
|
20682
|
+
"message",
|
|
20683
|
+
"code",
|
|
20684
|
+
"status",
|
|
20685
|
+
"statusCode",
|
|
20686
|
+
"stack"
|
|
20687
|
+
];
|
|
20688
|
+
const ERROR_RESERVED_FIELDS = new Set([
|
|
20689
|
+
...ERROR_FIELD_NAMES,
|
|
20690
|
+
"cause",
|
|
20691
|
+
"errors",
|
|
20692
|
+
"details"
|
|
20693
|
+
]);
|
|
20694
|
+
function safeString(value) {
|
|
20695
|
+
try {
|
|
20696
|
+
return String(value);
|
|
20697
|
+
} catch {
|
|
20698
|
+
return "[Unstringifiable]";
|
|
20699
|
+
}
|
|
20700
|
+
}
|
|
20701
|
+
function createSerializationState(options = {}) {
|
|
20702
|
+
return {
|
|
20703
|
+
seen: /* @__PURE__ */ new WeakSet(),
|
|
20704
|
+
maxDepth: options.maxDepth ?? DEFAULT_MAX_DEPTH,
|
|
20705
|
+
maxArrayLength: options.maxArrayLength ?? DEFAULT_MAX_ARRAY_LENGTH,
|
|
20706
|
+
maxObjectKeys: options.maxObjectKeys ?? DEFAULT_MAX_OBJECT_KEYS,
|
|
20707
|
+
maxStringLength: options.maxStringLength ?? DEFAULT_MAX_STRING_LENGTH
|
|
20708
|
+
};
|
|
20709
|
+
}
|
|
20710
|
+
function truncateString(value, state) {
|
|
20711
|
+
if (value.length <= state.maxStringLength) return value;
|
|
20712
|
+
return `${value.slice(0, state.maxStringLength)}...[truncated ${value.length - state.maxStringLength} chars]`;
|
|
20713
|
+
}
|
|
20714
|
+
function readProperty(record, key) {
|
|
20715
|
+
try {
|
|
20716
|
+
return record[key];
|
|
20717
|
+
} catch (error) {
|
|
20718
|
+
return `[Unreadable property: ${error instanceof Error ? error.message : safeString(error)}]`;
|
|
20719
|
+
}
|
|
20720
|
+
}
|
|
20721
|
+
function hasOwnProperty(value, key) {
|
|
20722
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
20723
|
+
}
|
|
20724
|
+
function tryCustomToString(value) {
|
|
20725
|
+
const toStringMethod = value.toString;
|
|
20726
|
+
if (typeof toStringMethod !== "function" || toStringMethod === Object.prototype.toString || toStringMethod === Error.prototype.toString) return;
|
|
20727
|
+
try {
|
|
20728
|
+
const result = toStringMethod.call(value);
|
|
20729
|
+
return typeof result === "string" ? result : void 0;
|
|
20730
|
+
} catch {
|
|
20731
|
+
return;
|
|
20732
|
+
}
|
|
20733
|
+
}
|
|
20734
|
+
function toSafeValue(value, state, depth = 0) {
|
|
20735
|
+
if (value === null || value === void 0) return value;
|
|
20736
|
+
if (typeof value === "string") return truncateString(value, state);
|
|
20737
|
+
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
20738
|
+
if (typeof value === "bigint") return value.toString();
|
|
20739
|
+
if (typeof value === "symbol") return value.toString();
|
|
20740
|
+
if (typeof value === "function") return `[Function ${value.name || "anonymous"}]`;
|
|
20741
|
+
if (value instanceof Date) return Number.isNaN(value.getTime()) ? value.toString() : value.toISOString();
|
|
20742
|
+
if (value instanceof Error) return serializeErrorInternal(value, state, depth);
|
|
20743
|
+
if (typeof value !== "object") return safeString(value);
|
|
20744
|
+
if (state.seen.has(value)) return "[Circular]";
|
|
20745
|
+
if (depth >= state.maxDepth) return "[MaxDepth]";
|
|
20746
|
+
state.seen.add(value);
|
|
20747
|
+
try {
|
|
20748
|
+
if (Array.isArray(value)) {
|
|
20749
|
+
const items = value.slice(0, state.maxArrayLength).map((item) => toSafeValue(item, state, depth + 1));
|
|
20750
|
+
if (value.length > state.maxArrayLength) items.push(`[Truncated ${value.length - state.maxArrayLength} items]`);
|
|
20751
|
+
return items;
|
|
20752
|
+
}
|
|
20753
|
+
if (value instanceof Map) return {
|
|
20754
|
+
type: "Map",
|
|
20755
|
+
entries: toSafeValue(Array.from(value.entries()), state, depth + 1)
|
|
20756
|
+
};
|
|
20757
|
+
if (value instanceof Set) return {
|
|
20758
|
+
type: "Set",
|
|
20759
|
+
values: toSafeValue(Array.from(value.values()), state, depth + 1)
|
|
20760
|
+
};
|
|
20761
|
+
const record = value;
|
|
20762
|
+
const output = {};
|
|
20763
|
+
const customToString = tryCustomToString(value);
|
|
20764
|
+
if (customToString) output.stringValue = truncateString(customToString, state);
|
|
20765
|
+
const keys = Object.keys(record);
|
|
20766
|
+
for (const key of keys.slice(0, state.maxObjectKeys)) output[key] = toSafeValue(readProperty(record, key), state, depth + 1);
|
|
20767
|
+
if (keys.length > state.maxObjectKeys) output.__truncatedKeys = keys.length - state.maxObjectKeys;
|
|
20768
|
+
return output;
|
|
20769
|
+
} finally {
|
|
20770
|
+
state.seen.delete(value);
|
|
20771
|
+
}
|
|
20772
|
+
}
|
|
20773
|
+
function copyErrorField(output, input, fieldName, state, depth) {
|
|
20774
|
+
if (!hasOwnProperty(input, fieldName)) return;
|
|
20775
|
+
const value = readProperty(input, fieldName);
|
|
20776
|
+
if (value !== void 0) output[fieldName] = toSafeValue(value, state, depth + 1);
|
|
20777
|
+
}
|
|
20778
|
+
function serializeErrorInternal(error, state, depth = 0) {
|
|
20779
|
+
if (error === null || error === void 0) return { message: safeString(error) };
|
|
20780
|
+
if (typeof error !== "object") return { message: safeString(error) };
|
|
20781
|
+
if (state.seen.has(error)) return { message: "[Circular]" };
|
|
20782
|
+
state.seen.add(error);
|
|
20783
|
+
try {
|
|
20784
|
+
const record = error;
|
|
20785
|
+
const output = {};
|
|
20786
|
+
if (error instanceof Error) {
|
|
20787
|
+
output.name = error.name;
|
|
20788
|
+
output.message = error.message;
|
|
20789
|
+
if (error.stack) output.stack = truncateString(error.stack, state);
|
|
20790
|
+
}
|
|
20791
|
+
for (const fieldName of ERROR_FIELD_NAMES) copyErrorField(output, record, fieldName, state, depth);
|
|
20792
|
+
const customToString = tryCustomToString(error);
|
|
20793
|
+
if (customToString) output.stringValue = truncateString(customToString, state);
|
|
20794
|
+
if (hasOwnProperty(record, "details")) output.details = toSafeValue(readProperty(record, "details"), state, depth + 1);
|
|
20795
|
+
if (hasOwnProperty(record, "cause")) output.cause = serializeErrorInternal(readProperty(record, "cause"), state, depth + 1);
|
|
20796
|
+
if (hasOwnProperty(record, "errors")) output.errors = toSafeValue(readProperty(record, "errors"), state, depth + 1);
|
|
20797
|
+
for (const key of Object.keys(record).slice(0, state.maxObjectKeys)) {
|
|
20798
|
+
if (ERROR_RESERVED_FIELDS.has(key) || key in output) continue;
|
|
20799
|
+
output[key] = toSafeValue(readProperty(record, key), state, depth + 1);
|
|
20800
|
+
}
|
|
20801
|
+
if (Object.keys(output).length === 0) return {
|
|
20802
|
+
message: safeString(error),
|
|
20803
|
+
value: toSafeValue(error, state, depth + 1)
|
|
20804
|
+
};
|
|
20805
|
+
return output;
|
|
20806
|
+
} finally {
|
|
20807
|
+
state.seen.delete(error);
|
|
20808
|
+
}
|
|
20809
|
+
}
|
|
20810
|
+
function serializeErrorLike(error, options = {}) {
|
|
20811
|
+
return serializeErrorInternal(error, createSerializationState(options));
|
|
20812
|
+
}
|
|
20813
|
+
function toJsonSafeValue(value, options = {}) {
|
|
20814
|
+
return toSafeValue(value, createSerializationState(options));
|
|
20815
|
+
}
|
|
20816
|
+
function safeJsonStringify(value, space) {
|
|
20817
|
+
try {
|
|
20818
|
+
return JSON.stringify(toJsonSafeValue(value), null, space) ?? "undefined";
|
|
20819
|
+
} catch (error) {
|
|
20820
|
+
return JSON.stringify({
|
|
20821
|
+
serializationError: error instanceof Error ? error.message : safeString(error),
|
|
20822
|
+
fallback: safeString(value)
|
|
20823
|
+
});
|
|
20824
|
+
}
|
|
20825
|
+
}
|
|
20826
|
+
|
|
20617
20827
|
//#endregion
|
|
20618
20828
|
//#region ../../core/bvt-agent/src/agent/utils.ts
|
|
20619
20829
|
const hasUnresolvedTokens = (obj) => {
|
|
@@ -20632,6 +20842,25 @@ const formatForLog = (value) => {
|
|
|
20632
20842
|
return String(value);
|
|
20633
20843
|
}
|
|
20634
20844
|
};
|
|
20845
|
+
const OBJECT_OBJECT_TOKEN = "[object Object]";
|
|
20846
|
+
const stripObjectObject = (message) => {
|
|
20847
|
+
const trimmed = message.trim();
|
|
20848
|
+
if (!trimmed.includes(OBJECT_OBJECT_TOKEN)) return trimmed;
|
|
20849
|
+
return trimmed.split(OBJECT_OBJECT_TOKEN).join("").replace(/[A-Za-z$_][\w$]*:\s*$/, "").replace(/[\s:]+$/, "").trim();
|
|
20850
|
+
};
|
|
20851
|
+
const getErrorMessage = (error, fallback = "Unknown error") => {
|
|
20852
|
+
const serialized = serializeErrorLike(error);
|
|
20853
|
+
const message = typeof serialized.message === "string" ? stripObjectObject(serialized.message) : "";
|
|
20854
|
+
if (message) return message;
|
|
20855
|
+
if (error !== null && typeof error === "object" && !(error instanceof Error)) {
|
|
20856
|
+
const json = stripObjectObject(safeJsonStringify(error));
|
|
20857
|
+
if (json && json !== "{}") return json;
|
|
20858
|
+
}
|
|
20859
|
+
return fallback;
|
|
20860
|
+
};
|
|
20861
|
+
const toExecutionError = (error, fallback = "Unknown error") => {
|
|
20862
|
+
return error instanceof Error ? error : new Error(getErrorMessage(error, fallback));
|
|
20863
|
+
};
|
|
20635
20864
|
const getValueFromStringOrRegex = (input) => {
|
|
20636
20865
|
switch (input.type) {
|
|
20637
20866
|
case "string": return input.value;
|
|
@@ -20928,7 +21157,7 @@ var Tester = class {
|
|
|
20928
21157
|
return this.pageList[this.pageList.length - 1] ?? null;
|
|
20929
21158
|
}
|
|
20930
21159
|
toExecutionError(error) {
|
|
20931
|
-
return
|
|
21160
|
+
return toExecutionError(error);
|
|
20932
21161
|
}
|
|
20933
21162
|
toFailureResult(error) {
|
|
20934
21163
|
const executionError = this.toExecutionError(error);
|
|
@@ -20943,7 +21172,7 @@ var Tester = class {
|
|
|
20943
21172
|
name: error.name,
|
|
20944
21173
|
message: error.message
|
|
20945
21174
|
};
|
|
20946
|
-
return { message:
|
|
21175
|
+
return { message: getErrorMessage(error) };
|
|
20947
21176
|
}
|
|
20948
21177
|
summarizeSessionForExecutionLog(session) {
|
|
20949
21178
|
if (!session) return { type: "none" };
|
|
@@ -22135,7 +22364,7 @@ var Tester = class {
|
|
|
22135
22364
|
return;
|
|
22136
22365
|
} catch (error) {
|
|
22137
22366
|
this.obs.logger.warn(`Action "${data.type}" failed on selector "${JSON.stringify(selectorInfo, null, 2)}". Trying next selector if available...`, error);
|
|
22138
|
-
errors.push(
|
|
22367
|
+
errors.push(this.toExecutionError(error));
|
|
22139
22368
|
}
|
|
22140
22369
|
for (let i = 0; i < target.uniqueSelectors.length; i++) {
|
|
22141
22370
|
if (i === chosenSelectorIndex) continue;
|
|
@@ -22156,7 +22385,7 @@ var Tester = class {
|
|
|
22156
22385
|
return;
|
|
22157
22386
|
} catch (error) {
|
|
22158
22387
|
this.obs.logger.warn(`Action "${data.type}" failed on fallback selector "${JSON.stringify(selectorInfo, null, 2)}". Trying next selector if available...`, error);
|
|
22159
|
-
errors.push(
|
|
22388
|
+
errors.push(this.toExecutionError(error));
|
|
22160
22389
|
}
|
|
22161
22390
|
}
|
|
22162
22391
|
throw new Error(`All selectors failed for element action "${data.type}". Errors: ${errors.map((e) => e.message).join("; ")}`);
|
|
@@ -22186,7 +22415,7 @@ var Tester = class {
|
|
|
22186
22415
|
return;
|
|
22187
22416
|
} catch (error) {
|
|
22188
22417
|
this.obs.logger.warn(`Assertion "${data.type}" failed on selector "${JSON.stringify(selectorInfo, null, 2)}". Trying next selector if available...`, error);
|
|
22189
|
-
errors.push(
|
|
22418
|
+
errors.push(this.toExecutionError(error));
|
|
22190
22419
|
}
|
|
22191
22420
|
for (let i = 0; i < target.uniqueSelectors.length; i++) {
|
|
22192
22421
|
if (i === chosenSelectorIndex) continue;
|
|
@@ -22206,7 +22435,7 @@ var Tester = class {
|
|
|
22206
22435
|
return;
|
|
22207
22436
|
} catch (error) {
|
|
22208
22437
|
this.obs.logger.warn(`Assertion "${data.type}" failed on fallback selector "${JSON.stringify(selectorInfo, null, 2)}". Trying next selector if available...`, error);
|
|
22209
|
-
errors.push(
|
|
22438
|
+
errors.push(this.toExecutionError(error));
|
|
22210
22439
|
}
|
|
22211
22440
|
}
|
|
22212
22441
|
throw new Error(`All selectors failed for element assertion "${data.type}". Errors: ${errors.map((e) => e.message).join("; ")}`);
|
|
@@ -22232,7 +22461,7 @@ var Tester = class {
|
|
|
22232
22461
|
return;
|
|
22233
22462
|
} catch (error) {
|
|
22234
22463
|
this.obs.logger.warn(`Extraction "${extract.type}" failed on selector "${JSON.stringify(selectorInfo, null, 2)}". Trying next selector if available...`, error);
|
|
22235
|
-
errors.push(
|
|
22464
|
+
errors.push(this.toExecutionError(error));
|
|
22236
22465
|
}
|
|
22237
22466
|
for (let i = 0; i < target.uniqueSelectors.length; i++) {
|
|
22238
22467
|
if (i === chosenSelectorIndex) continue;
|
|
@@ -22245,7 +22474,7 @@ var Tester = class {
|
|
|
22245
22474
|
return;
|
|
22246
22475
|
} catch (error) {
|
|
22247
22476
|
this.obs.logger.warn(`Extraction "${extract.type}" failed on fallback selector "${JSON.stringify(fallbackSelectorInfo, null, 2)}". Trying next selector if available...`, error);
|
|
22248
|
-
errors.push(
|
|
22477
|
+
errors.push(this.toExecutionError(error));
|
|
22249
22478
|
}
|
|
22250
22479
|
}
|
|
22251
22480
|
throw new Error(`All selectors failed for element extraction "${extract.type}". Errors: ${errors.map((e) => e.message).join("; ")}`);
|
|
@@ -22528,101 +22757,6 @@ function createStepParameterPreprocessor() {
|
|
|
22528
22757
|
};
|
|
22529
22758
|
}
|
|
22530
22759
|
|
|
22531
|
-
//#endregion
|
|
22532
|
-
//#region ../../core/bvt-agent/src/agent/data-resolver.preprocessor.ts
|
|
22533
|
-
function createDataResolverPreprocessor(resolver) {
|
|
22534
|
-
return async (command, context) => {
|
|
22535
|
-
if (!context.resolutionContext) return command;
|
|
22536
|
-
if (command.type === "custom" && typeof command.code === "string" && !command.code.includes("{{")) {
|
|
22537
|
-
const { code, ...rest } = command;
|
|
22538
|
-
return {
|
|
22539
|
-
...await resolver.resolveObject(rest, context.resolutionContext),
|
|
22540
|
-
code
|
|
22541
|
-
};
|
|
22542
|
-
}
|
|
22543
|
-
if (command.type === "custom.code" && typeof command.code === "string") {
|
|
22544
|
-
const { code, ...rest } = command;
|
|
22545
|
-
return {
|
|
22546
|
-
...await resolver.resolveObject(rest, context.resolutionContext),
|
|
22547
|
-
code
|
|
22548
|
-
};
|
|
22549
|
-
}
|
|
22550
|
-
return resolver.resolveObject(command, context.resolutionContext);
|
|
22551
|
-
};
|
|
22552
|
-
}
|
|
22553
|
-
|
|
22554
|
-
//#endregion
|
|
22555
|
-
//#region ../../shared/observability/src/logger.ts
|
|
22556
|
-
function extractEventName(metadata) {
|
|
22557
|
-
if (!metadata) return {};
|
|
22558
|
-
const rawEventName = metadata.eventName;
|
|
22559
|
-
if (typeof rawEventName !== "string" || rawEventName.trim().length === 0) return { sanitizedMetadata: metadata };
|
|
22560
|
-
const { eventName: _eventName, ...restMetadata } = metadata;
|
|
22561
|
-
return {
|
|
22562
|
-
eventName: rawEventName,
|
|
22563
|
-
sanitizedMetadata: Object.keys(restMetadata).length > 0 ? restMetadata : void 0
|
|
22564
|
-
};
|
|
22565
|
-
}
|
|
22566
|
-
var Logger = class Logger {
|
|
22567
|
-
constructor(transports, defaultContext = { system: true }) {
|
|
22568
|
-
this.transports = transports;
|
|
22569
|
-
this.defaultContext = defaultContext;
|
|
22570
|
-
}
|
|
22571
|
-
debug(message, metadata, context) {
|
|
22572
|
-
this.emit("debug", message, metadata, context);
|
|
22573
|
-
}
|
|
22574
|
-
info(message, metadata, context) {
|
|
22575
|
-
this.emit("info", message, metadata, context);
|
|
22576
|
-
}
|
|
22577
|
-
warn(message, metadata, context) {
|
|
22578
|
-
this.emit("warn", message, metadata, context);
|
|
22579
|
-
}
|
|
22580
|
-
error(message, metadata, context) {
|
|
22581
|
-
this.emit("error", message, metadata, context);
|
|
22582
|
-
}
|
|
22583
|
-
/** Returns a new Logger instance bound to the given context. */
|
|
22584
|
-
withContext(context) {
|
|
22585
|
-
return new Logger(this.transports, context);
|
|
22586
|
-
}
|
|
22587
|
-
emit(level, message, metadata, context) {
|
|
22588
|
-
const { eventName, sanitizedMetadata } = extractEventName(metadata);
|
|
22589
|
-
const entry = {
|
|
22590
|
-
level,
|
|
22591
|
-
message,
|
|
22592
|
-
...eventName ? { eventName } : {},
|
|
22593
|
-
context: context ?? this.defaultContext,
|
|
22594
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
22595
|
-
metadata: sanitizedMetadata
|
|
22596
|
-
};
|
|
22597
|
-
for (const transport of this.transports) try {
|
|
22598
|
-
const result = transport.log?.(entry);
|
|
22599
|
-
if (result instanceof Promise) result.catch((err) => {
|
|
22600
|
-
console.error(`[observability] Transport "${transport.name}" log() failed:`, err);
|
|
22601
|
-
});
|
|
22602
|
-
} catch (err) {
|
|
22603
|
-
console.error(`[observability] Transport "${transport.name}" log() threw:`, err);
|
|
22604
|
-
}
|
|
22605
|
-
}
|
|
22606
|
-
};
|
|
22607
|
-
|
|
22608
|
-
//#endregion
|
|
22609
|
-
//#region ../../shared/observability/src/error-serialization.ts
|
|
22610
|
-
const DEFAULT_MAX_STRING_LENGTH = Number.MAX_SAFE_INTEGER;
|
|
22611
|
-
const ERROR_FIELD_NAMES = [
|
|
22612
|
-
"name",
|
|
22613
|
-
"message",
|
|
22614
|
-
"code",
|
|
22615
|
-
"status",
|
|
22616
|
-
"statusCode",
|
|
22617
|
-
"stack"
|
|
22618
|
-
];
|
|
22619
|
-
const ERROR_RESERVED_FIELDS = new Set([
|
|
22620
|
-
...ERROR_FIELD_NAMES,
|
|
22621
|
-
"cause",
|
|
22622
|
-
"errors",
|
|
22623
|
-
"details"
|
|
22624
|
-
]);
|
|
22625
|
-
|
|
22626
22760
|
//#endregion
|
|
22627
22761
|
//#region ../../core/data-resolver/src/types.ts
|
|
22628
22762
|
var CircularDependencyError = class extends Error {
|
|
@@ -23074,6 +23208,7 @@ var DataResolver = class {
|
|
|
23074
23208
|
encryptionKey;
|
|
23075
23209
|
decryptSecret;
|
|
23076
23210
|
decryptTotpSeed;
|
|
23211
|
+
skipJSNormalization;
|
|
23077
23212
|
constructor(scopeManager, evaluatorRegistry, options) {
|
|
23078
23213
|
this.scopeManager = scopeManager;
|
|
23079
23214
|
this.registry = evaluatorRegistry;
|
|
@@ -23081,6 +23216,7 @@ var DataResolver = class {
|
|
|
23081
23216
|
this.encryptionKey = options?.encryptionKey;
|
|
23082
23217
|
this.decryptSecret = options?.decryptSecret;
|
|
23083
23218
|
this.decryptTotpSeed = options?.decryptTotpSeed;
|
|
23219
|
+
this.skipJSNormalization = options?.skipJSNormalization ?? false;
|
|
23084
23220
|
this.logger = options?.logger ?? silentLogger;
|
|
23085
23221
|
if (!this.registry.has("literal")) this.registry.register(new LiteralEvaluator());
|
|
23086
23222
|
}
|
|
@@ -23127,7 +23263,12 @@ var DataResolver = class {
|
|
|
23127
23263
|
return this.resolveValue(input, new ResolutionStack(), [], [], log, context);
|
|
23128
23264
|
}
|
|
23129
23265
|
async resolveString(input, stack, warnings, usedKeys, log, context) {
|
|
23130
|
-
const normalized = normalizeJSTokens(input);
|
|
23266
|
+
const normalized = this.skipJSNormalization ? input : normalizeJSTokens(input);
|
|
23267
|
+
if (normalized !== input && !this.skipJSNormalization) log.warn("[DataResolver] ${...} shorthand is deprecated — use {{js:...}} instead", {
|
|
23268
|
+
input,
|
|
23269
|
+
normalized,
|
|
23270
|
+
projectId: context?.projectId
|
|
23271
|
+
});
|
|
23131
23272
|
if (!hasTokens(normalized)) return input;
|
|
23132
23273
|
if (stack.depth >= this.maxRecursionDepth) {
|
|
23133
23274
|
const message = `Maximum recursion depth (${this.maxRecursionDepth}) reached`;
|
|
@@ -25034,35 +25175,2614 @@ var JSEvaluator = class {
|
|
|
25034
25175
|
};
|
|
25035
25176
|
|
|
25036
25177
|
//#endregion
|
|
25037
|
-
//#region ../../
|
|
25038
|
-
|
|
25039
|
-
|
|
25040
|
-
|
|
25041
|
-
|
|
25042
|
-
|
|
25043
|
-
|
|
25044
|
-
|
|
25045
|
-
|
|
25046
|
-
|
|
25047
|
-
|
|
25048
|
-
|
|
25049
|
-
|
|
25178
|
+
//#region ../../node_modules/chrono-node/dist/esm/types.js
|
|
25179
|
+
var Meridiem;
|
|
25180
|
+
(function(Meridiem) {
|
|
25181
|
+
Meridiem[Meridiem["AM"] = 0] = "AM";
|
|
25182
|
+
Meridiem[Meridiem["PM"] = 1] = "PM";
|
|
25183
|
+
})(Meridiem || (Meridiem = {}));
|
|
25184
|
+
var Weekday;
|
|
25185
|
+
(function(Weekday) {
|
|
25186
|
+
Weekday[Weekday["SUNDAY"] = 0] = "SUNDAY";
|
|
25187
|
+
Weekday[Weekday["MONDAY"] = 1] = "MONDAY";
|
|
25188
|
+
Weekday[Weekday["TUESDAY"] = 2] = "TUESDAY";
|
|
25189
|
+
Weekday[Weekday["WEDNESDAY"] = 3] = "WEDNESDAY";
|
|
25190
|
+
Weekday[Weekday["THURSDAY"] = 4] = "THURSDAY";
|
|
25191
|
+
Weekday[Weekday["FRIDAY"] = 5] = "FRIDAY";
|
|
25192
|
+
Weekday[Weekday["SATURDAY"] = 6] = "SATURDAY";
|
|
25193
|
+
})(Weekday || (Weekday = {}));
|
|
25194
|
+
var Month;
|
|
25195
|
+
(function(Month) {
|
|
25196
|
+
Month[Month["JANUARY"] = 1] = "JANUARY";
|
|
25197
|
+
Month[Month["FEBRUARY"] = 2] = "FEBRUARY";
|
|
25198
|
+
Month[Month["MARCH"] = 3] = "MARCH";
|
|
25199
|
+
Month[Month["APRIL"] = 4] = "APRIL";
|
|
25200
|
+
Month[Month["MAY"] = 5] = "MAY";
|
|
25201
|
+
Month[Month["JUNE"] = 6] = "JUNE";
|
|
25202
|
+
Month[Month["JULY"] = 7] = "JULY";
|
|
25203
|
+
Month[Month["AUGUST"] = 8] = "AUGUST";
|
|
25204
|
+
Month[Month["SEPTEMBER"] = 9] = "SEPTEMBER";
|
|
25205
|
+
Month[Month["OCTOBER"] = 10] = "OCTOBER";
|
|
25206
|
+
Month[Month["NOVEMBER"] = 11] = "NOVEMBER";
|
|
25207
|
+
Month[Month["DECEMBER"] = 12] = "DECEMBER";
|
|
25208
|
+
})(Month || (Month = {}));
|
|
25050
25209
|
|
|
25051
25210
|
//#endregion
|
|
25052
|
-
//#region ../../
|
|
25053
|
-
|
|
25054
|
-
|
|
25055
|
-
|
|
25056
|
-
|
|
25057
|
-
|
|
25211
|
+
//#region ../../node_modules/chrono-node/dist/esm/utils/dates.js
|
|
25212
|
+
function assignSimilarDate(component, target) {
|
|
25213
|
+
component.assign("day", target.getDate());
|
|
25214
|
+
component.assign("month", target.getMonth() + 1);
|
|
25215
|
+
component.assign("year", target.getFullYear());
|
|
25216
|
+
}
|
|
25217
|
+
function assignSimilarTime(component, target) {
|
|
25218
|
+
component.assign("hour", target.getHours());
|
|
25219
|
+
component.assign("minute", target.getMinutes());
|
|
25220
|
+
component.assign("second", target.getSeconds());
|
|
25221
|
+
component.assign("millisecond", target.getMilliseconds());
|
|
25222
|
+
component.assign("meridiem", target.getHours() < 12 ? Meridiem.AM : Meridiem.PM);
|
|
25223
|
+
}
|
|
25224
|
+
function implySimilarDate(component, target) {
|
|
25225
|
+
component.imply("day", target.getDate());
|
|
25226
|
+
component.imply("month", target.getMonth() + 1);
|
|
25227
|
+
component.imply("year", target.getFullYear());
|
|
25228
|
+
}
|
|
25229
|
+
function implySimilarTime(component, target) {
|
|
25230
|
+
component.imply("hour", target.getHours());
|
|
25231
|
+
component.imply("minute", target.getMinutes());
|
|
25232
|
+
component.imply("second", target.getSeconds());
|
|
25233
|
+
component.imply("millisecond", target.getMilliseconds());
|
|
25234
|
+
component.imply("meridiem", target.getHours() < 12 ? Meridiem.AM : Meridiem.PM);
|
|
25235
|
+
}
|
|
25236
|
+
|
|
25237
|
+
//#endregion
|
|
25238
|
+
//#region ../../node_modules/chrono-node/dist/esm/timezone.js
|
|
25239
|
+
const TIMEZONE_ABBR_MAP = {
|
|
25240
|
+
ACDT: 630,
|
|
25241
|
+
ACST: 570,
|
|
25242
|
+
ADT: -180,
|
|
25243
|
+
AEDT: 660,
|
|
25244
|
+
AEST: 600,
|
|
25245
|
+
AFT: 270,
|
|
25246
|
+
AKDT: -480,
|
|
25247
|
+
AKST: -540,
|
|
25248
|
+
ALMT: 360,
|
|
25249
|
+
AMST: -180,
|
|
25250
|
+
AMT: -240,
|
|
25251
|
+
ANAST: 720,
|
|
25252
|
+
ANAT: 720,
|
|
25253
|
+
AQTT: 300,
|
|
25254
|
+
ART: -180,
|
|
25255
|
+
AST: -240,
|
|
25256
|
+
AWDT: 540,
|
|
25257
|
+
AWST: 480,
|
|
25258
|
+
AZOST: 0,
|
|
25259
|
+
AZOT: -60,
|
|
25260
|
+
AZST: 300,
|
|
25261
|
+
AZT: 240,
|
|
25262
|
+
BNT: 480,
|
|
25263
|
+
BOT: -240,
|
|
25264
|
+
BRST: -120,
|
|
25265
|
+
BRT: -180,
|
|
25266
|
+
BST: 60,
|
|
25267
|
+
BTT: 360,
|
|
25268
|
+
CAST: 480,
|
|
25269
|
+
CAT: 120,
|
|
25270
|
+
CCT: 390,
|
|
25271
|
+
CDT: -300,
|
|
25272
|
+
CEST: 120,
|
|
25273
|
+
CET: {
|
|
25274
|
+
timezoneOffsetDuringDst: 120,
|
|
25275
|
+
timezoneOffsetNonDst: 60,
|
|
25276
|
+
dstStart: (year) => getLastWeekdayOfMonth(year, Month.MARCH, Weekday.SUNDAY, 2),
|
|
25277
|
+
dstEnd: (year) => getLastWeekdayOfMonth(year, Month.OCTOBER, Weekday.SUNDAY, 3)
|
|
25278
|
+
},
|
|
25279
|
+
CHADT: 825,
|
|
25280
|
+
CHAST: 765,
|
|
25281
|
+
CKT: -600,
|
|
25282
|
+
CLST: -180,
|
|
25283
|
+
CLT: -240,
|
|
25284
|
+
COT: -300,
|
|
25285
|
+
CST: -360,
|
|
25286
|
+
CT: {
|
|
25287
|
+
timezoneOffsetDuringDst: -300,
|
|
25288
|
+
timezoneOffsetNonDst: -360,
|
|
25289
|
+
dstStart: (year) => getNthWeekdayOfMonth(year, Month.MARCH, Weekday.SUNDAY, 2, 2),
|
|
25290
|
+
dstEnd: (year) => getNthWeekdayOfMonth(year, Month.NOVEMBER, Weekday.SUNDAY, 1, 2)
|
|
25291
|
+
},
|
|
25292
|
+
CVT: -60,
|
|
25293
|
+
CXT: 420,
|
|
25294
|
+
ChST: 600,
|
|
25295
|
+
DAVT: 420,
|
|
25296
|
+
EASST: -300,
|
|
25297
|
+
EAST: -360,
|
|
25298
|
+
EAT: 180,
|
|
25299
|
+
ECT: -300,
|
|
25300
|
+
EDT: -240,
|
|
25301
|
+
EEST: 180,
|
|
25302
|
+
EET: 120,
|
|
25303
|
+
EGST: 0,
|
|
25304
|
+
EGT: -60,
|
|
25305
|
+
EST: -300,
|
|
25306
|
+
ET: {
|
|
25307
|
+
timezoneOffsetDuringDst: -240,
|
|
25308
|
+
timezoneOffsetNonDst: -300,
|
|
25309
|
+
dstStart: (year) => getNthWeekdayOfMonth(year, Month.MARCH, Weekday.SUNDAY, 2, 2),
|
|
25310
|
+
dstEnd: (year) => getNthWeekdayOfMonth(year, Month.NOVEMBER, Weekday.SUNDAY, 1, 2)
|
|
25311
|
+
},
|
|
25312
|
+
FJST: 780,
|
|
25313
|
+
FJT: 720,
|
|
25314
|
+
FKST: -180,
|
|
25315
|
+
FKT: -240,
|
|
25316
|
+
FNT: -120,
|
|
25317
|
+
GALT: -360,
|
|
25318
|
+
GAMT: -540,
|
|
25319
|
+
GET: 240,
|
|
25320
|
+
GFT: -180,
|
|
25321
|
+
GILT: 720,
|
|
25322
|
+
GMT: 0,
|
|
25323
|
+
GST: 240,
|
|
25324
|
+
GYT: -240,
|
|
25325
|
+
HAA: -180,
|
|
25326
|
+
HAC: -300,
|
|
25327
|
+
HADT: -540,
|
|
25328
|
+
HAE: -240,
|
|
25329
|
+
HAP: -420,
|
|
25330
|
+
HAR: -360,
|
|
25331
|
+
HAST: -600,
|
|
25332
|
+
HAT: -90,
|
|
25333
|
+
HAY: -480,
|
|
25334
|
+
HKT: 480,
|
|
25335
|
+
HLV: -210,
|
|
25336
|
+
HNA: -240,
|
|
25337
|
+
HNC: -360,
|
|
25338
|
+
HNE: -300,
|
|
25339
|
+
HNP: -480,
|
|
25340
|
+
HNR: -420,
|
|
25341
|
+
HNT: -150,
|
|
25342
|
+
HNY: -540,
|
|
25343
|
+
HOVT: 420,
|
|
25344
|
+
ICT: 420,
|
|
25345
|
+
IDT: 180,
|
|
25346
|
+
IOT: 360,
|
|
25347
|
+
IRDT: 270,
|
|
25348
|
+
IRKST: 540,
|
|
25349
|
+
IRKT: 540,
|
|
25350
|
+
IRST: 210,
|
|
25351
|
+
IST: 330,
|
|
25352
|
+
JST: 540,
|
|
25353
|
+
KGT: 360,
|
|
25354
|
+
KRAST: 480,
|
|
25355
|
+
KRAT: 480,
|
|
25356
|
+
KST: 540,
|
|
25357
|
+
KUYT: 240,
|
|
25358
|
+
LHDT: 660,
|
|
25359
|
+
LHST: 630,
|
|
25360
|
+
LINT: 840,
|
|
25361
|
+
MAGST: 720,
|
|
25362
|
+
MAGT: 720,
|
|
25363
|
+
MART: -510,
|
|
25364
|
+
MAWT: 300,
|
|
25365
|
+
MDT: -360,
|
|
25366
|
+
MESZ: 120,
|
|
25367
|
+
MEZ: 60,
|
|
25368
|
+
MHT: 720,
|
|
25369
|
+
MMT: 390,
|
|
25370
|
+
MSD: 240,
|
|
25371
|
+
MSK: 180,
|
|
25372
|
+
MST: -420,
|
|
25373
|
+
MT: {
|
|
25374
|
+
timezoneOffsetDuringDst: -360,
|
|
25375
|
+
timezoneOffsetNonDst: -420,
|
|
25376
|
+
dstStart: (year) => getNthWeekdayOfMonth(year, Month.MARCH, Weekday.SUNDAY, 2, 2),
|
|
25377
|
+
dstEnd: (year) => getNthWeekdayOfMonth(year, Month.NOVEMBER, Weekday.SUNDAY, 1, 2)
|
|
25378
|
+
},
|
|
25379
|
+
MUT: 240,
|
|
25380
|
+
MVT: 300,
|
|
25381
|
+
MYT: 480,
|
|
25382
|
+
NCT: 660,
|
|
25383
|
+
NDT: -90,
|
|
25384
|
+
NFT: 690,
|
|
25385
|
+
NOVST: 420,
|
|
25386
|
+
NOVT: 360,
|
|
25387
|
+
NPT: 345,
|
|
25388
|
+
NST: -150,
|
|
25389
|
+
NUT: -660,
|
|
25390
|
+
NZDT: 780,
|
|
25391
|
+
NZST: 720,
|
|
25392
|
+
OMSST: 420,
|
|
25393
|
+
OMST: 420,
|
|
25394
|
+
PDT: -420,
|
|
25395
|
+
PET: -300,
|
|
25396
|
+
PETST: 720,
|
|
25397
|
+
PETT: 720,
|
|
25398
|
+
PGT: 600,
|
|
25399
|
+
PHOT: 780,
|
|
25400
|
+
PHT: 480,
|
|
25401
|
+
PKT: 300,
|
|
25402
|
+
PMDT: -120,
|
|
25403
|
+
PMST: -180,
|
|
25404
|
+
PONT: 660,
|
|
25405
|
+
PST: -480,
|
|
25406
|
+
PT: {
|
|
25407
|
+
timezoneOffsetDuringDst: -420,
|
|
25408
|
+
timezoneOffsetNonDst: -480,
|
|
25409
|
+
dstStart: (year) => getNthWeekdayOfMonth(year, Month.MARCH, Weekday.SUNDAY, 2, 2),
|
|
25410
|
+
dstEnd: (year) => getNthWeekdayOfMonth(year, Month.NOVEMBER, Weekday.SUNDAY, 1, 2)
|
|
25411
|
+
},
|
|
25412
|
+
PWT: 540,
|
|
25413
|
+
PYST: -180,
|
|
25414
|
+
PYT: -240,
|
|
25415
|
+
RET: 240,
|
|
25416
|
+
SAMT: 240,
|
|
25417
|
+
SAST: 120,
|
|
25418
|
+
SBT: 660,
|
|
25419
|
+
SCT: 240,
|
|
25420
|
+
SGT: 480,
|
|
25421
|
+
SRT: -180,
|
|
25422
|
+
SST: -660,
|
|
25423
|
+
TAHT: -600,
|
|
25424
|
+
TFT: 300,
|
|
25425
|
+
TJT: 300,
|
|
25426
|
+
TKT: 780,
|
|
25427
|
+
TLT: 540,
|
|
25428
|
+
TMT: 300,
|
|
25429
|
+
TVT: 720,
|
|
25430
|
+
ULAT: 480,
|
|
25431
|
+
UTC: 0,
|
|
25432
|
+
UYST: -120,
|
|
25433
|
+
UYT: -180,
|
|
25434
|
+
UZT: 300,
|
|
25435
|
+
VET: -210,
|
|
25436
|
+
VLAST: 660,
|
|
25437
|
+
VLAT: 660,
|
|
25438
|
+
VUT: 660,
|
|
25439
|
+
WAST: 120,
|
|
25440
|
+
WAT: 60,
|
|
25441
|
+
WEST: 60,
|
|
25442
|
+
WESZ: 60,
|
|
25443
|
+
WET: 0,
|
|
25444
|
+
WEZ: 0,
|
|
25445
|
+
WFT: 720,
|
|
25446
|
+
WGST: -120,
|
|
25447
|
+
WGT: -180,
|
|
25448
|
+
WIB: 420,
|
|
25449
|
+
WIT: 540,
|
|
25450
|
+
WITA: 480,
|
|
25451
|
+
WST: 780,
|
|
25452
|
+
WT: 0,
|
|
25453
|
+
YAKST: 600,
|
|
25454
|
+
YAKT: 600,
|
|
25455
|
+
YAPT: 600,
|
|
25456
|
+
YEKST: 360,
|
|
25457
|
+
YEKT: 360
|
|
25458
|
+
};
|
|
25459
|
+
function getNthWeekdayOfMonth(year, month, weekday, n, hour = 0) {
|
|
25460
|
+
let dayOfMonth = 0;
|
|
25461
|
+
let i = 0;
|
|
25462
|
+
while (i < n) {
|
|
25463
|
+
dayOfMonth++;
|
|
25464
|
+
if (new Date(year, month - 1, dayOfMonth).getDay() === weekday) i++;
|
|
25465
|
+
}
|
|
25466
|
+
return new Date(year, month - 1, dayOfMonth, hour);
|
|
25467
|
+
}
|
|
25468
|
+
function getLastWeekdayOfMonth(year, month, weekday, hour = 0) {
|
|
25469
|
+
const oneIndexedWeekday = weekday === 0 ? 7 : weekday;
|
|
25470
|
+
const date = new Date(year, month - 1 + 1, 1, 12);
|
|
25471
|
+
const firstWeekdayNextMonth = date.getDay() === 0 ? 7 : date.getDay();
|
|
25472
|
+
let dayDiff;
|
|
25473
|
+
if (firstWeekdayNextMonth === oneIndexedWeekday) dayDiff = 7;
|
|
25474
|
+
else if (firstWeekdayNextMonth < oneIndexedWeekday) dayDiff = 7 + firstWeekdayNextMonth - oneIndexedWeekday;
|
|
25475
|
+
else dayDiff = firstWeekdayNextMonth - oneIndexedWeekday;
|
|
25476
|
+
date.setDate(date.getDate() - dayDiff);
|
|
25477
|
+
return new Date(year, month - 1, date.getDate(), hour);
|
|
25478
|
+
}
|
|
25479
|
+
function toTimezoneOffset(timezoneInput, date, timezoneOverrides = {}) {
|
|
25480
|
+
if (timezoneInput == null) return null;
|
|
25481
|
+
if (typeof timezoneInput === "number") return timezoneInput;
|
|
25482
|
+
const matchedTimezone = timezoneOverrides[timezoneInput] ?? TIMEZONE_ABBR_MAP[timezoneInput];
|
|
25483
|
+
if (matchedTimezone == null) return null;
|
|
25484
|
+
if (typeof matchedTimezone == "number") return matchedTimezone;
|
|
25485
|
+
if (date == null) return null;
|
|
25486
|
+
if (date > matchedTimezone.dstStart(date.getFullYear()) && !(date > matchedTimezone.dstEnd(date.getFullYear()))) return matchedTimezone.timezoneOffsetDuringDst;
|
|
25487
|
+
return matchedTimezone.timezoneOffsetNonDst;
|
|
25488
|
+
}
|
|
25489
|
+
|
|
25490
|
+
//#endregion
|
|
25491
|
+
//#region ../../node_modules/chrono-node/dist/esm/calculation/duration.js
|
|
25492
|
+
const EmptyDuration = {
|
|
25493
|
+
day: 0,
|
|
25494
|
+
second: 0,
|
|
25495
|
+
millisecond: 0
|
|
25496
|
+
};
|
|
25497
|
+
function addDuration(ref, duration) {
|
|
25498
|
+
let date = new Date(ref);
|
|
25499
|
+
if (duration["y"]) {
|
|
25500
|
+
duration["year"] = duration["y"];
|
|
25501
|
+
delete duration["y"];
|
|
25502
|
+
}
|
|
25503
|
+
if (duration["mo"]) {
|
|
25504
|
+
duration["month"] = duration["mo"];
|
|
25505
|
+
delete duration["mo"];
|
|
25506
|
+
}
|
|
25507
|
+
if (duration["M"]) {
|
|
25508
|
+
duration["month"] = duration["M"];
|
|
25509
|
+
delete duration["M"];
|
|
25510
|
+
}
|
|
25511
|
+
if (duration["w"]) {
|
|
25512
|
+
duration["week"] = duration["w"];
|
|
25513
|
+
delete duration["w"];
|
|
25514
|
+
}
|
|
25515
|
+
if (duration["d"]) {
|
|
25516
|
+
duration["day"] = duration["d"];
|
|
25517
|
+
delete duration["d"];
|
|
25518
|
+
}
|
|
25519
|
+
if (duration["h"]) {
|
|
25520
|
+
duration["hour"] = duration["h"];
|
|
25521
|
+
delete duration["h"];
|
|
25522
|
+
}
|
|
25523
|
+
if (duration["m"]) {
|
|
25524
|
+
duration["minute"] = duration["m"];
|
|
25525
|
+
delete duration["m"];
|
|
25526
|
+
}
|
|
25527
|
+
if (duration["s"]) {
|
|
25528
|
+
duration["second"] = duration["s"];
|
|
25529
|
+
delete duration["s"];
|
|
25530
|
+
}
|
|
25531
|
+
if (duration["ms"]) {
|
|
25532
|
+
duration["millisecond"] = duration["ms"];
|
|
25533
|
+
delete duration["ms"];
|
|
25534
|
+
}
|
|
25535
|
+
if ("year" in duration) {
|
|
25536
|
+
const floor = Math.floor(duration["year"]);
|
|
25537
|
+
date.setFullYear(date.getFullYear() + floor);
|
|
25538
|
+
const remainingFraction = duration["year"] - floor;
|
|
25539
|
+
if (remainingFraction > 0) {
|
|
25540
|
+
duration.month = duration?.month ?? 0;
|
|
25541
|
+
duration.month += remainingFraction * 12;
|
|
25542
|
+
}
|
|
25543
|
+
}
|
|
25544
|
+
if ("quarter" in duration) {
|
|
25545
|
+
const floor = Math.floor(duration["quarter"]);
|
|
25546
|
+
date.setMonth(date.getMonth() + floor * 3);
|
|
25547
|
+
}
|
|
25548
|
+
if ("month" in duration) {
|
|
25549
|
+
const floor = Math.floor(duration["month"]);
|
|
25550
|
+
date.setMonth(date.getMonth() + floor);
|
|
25551
|
+
const remainingFraction = duration["month"] - floor;
|
|
25552
|
+
if (remainingFraction > 0) {
|
|
25553
|
+
duration.week = duration?.week ?? 0;
|
|
25554
|
+
duration.week += remainingFraction * 4;
|
|
25555
|
+
}
|
|
25556
|
+
}
|
|
25557
|
+
if ("week" in duration) {
|
|
25558
|
+
const floor = Math.floor(duration["week"]);
|
|
25559
|
+
date.setDate(date.getDate() + floor * 7);
|
|
25560
|
+
const remainingFraction = duration["week"] - floor;
|
|
25561
|
+
if (remainingFraction > 0) {
|
|
25562
|
+
duration.day = duration?.day ?? 0;
|
|
25563
|
+
duration.day += Math.round(remainingFraction * 7);
|
|
25564
|
+
}
|
|
25565
|
+
}
|
|
25566
|
+
if ("day" in duration) {
|
|
25567
|
+
const floor = Math.floor(duration["day"]);
|
|
25568
|
+
date.setDate(date.getDate() + floor);
|
|
25569
|
+
const remainingFraction = duration["day"] - floor;
|
|
25570
|
+
if (remainingFraction > 0) {
|
|
25571
|
+
duration.hour = duration?.hour ?? 0;
|
|
25572
|
+
duration.hour += Math.round(remainingFraction * 24);
|
|
25573
|
+
}
|
|
25574
|
+
}
|
|
25575
|
+
if ("hour" in duration) {
|
|
25576
|
+
const floor = Math.floor(duration["hour"]);
|
|
25577
|
+
date.setHours(date.getHours() + floor);
|
|
25578
|
+
const remainingFraction = duration["hour"] - floor;
|
|
25579
|
+
if (remainingFraction > 0) {
|
|
25580
|
+
duration.minute = duration?.minute ?? 0;
|
|
25581
|
+
duration.minute += Math.round(remainingFraction * 60);
|
|
25582
|
+
}
|
|
25583
|
+
}
|
|
25584
|
+
if ("minute" in duration) {
|
|
25585
|
+
const floor = Math.floor(duration["minute"]);
|
|
25586
|
+
date.setMinutes(date.getMinutes() + floor);
|
|
25587
|
+
const remainingFraction = duration["minute"] - floor;
|
|
25588
|
+
if (remainingFraction > 0) {
|
|
25589
|
+
duration.second = duration?.second ?? 0;
|
|
25590
|
+
duration.second += Math.round(remainingFraction * 60);
|
|
25591
|
+
}
|
|
25592
|
+
}
|
|
25593
|
+
if ("second" in duration) {
|
|
25594
|
+
const floor = Math.floor(duration["second"]);
|
|
25595
|
+
date.setSeconds(date.getSeconds() + floor);
|
|
25596
|
+
const remainingFraction = duration["second"] - floor;
|
|
25597
|
+
if (remainingFraction > 0) {
|
|
25598
|
+
duration.millisecond = duration?.millisecond ?? 0;
|
|
25599
|
+
duration.millisecond += Math.round(remainingFraction * 1e3);
|
|
25600
|
+
}
|
|
25601
|
+
}
|
|
25602
|
+
if ("millisecond" in duration) {
|
|
25603
|
+
const floor = Math.floor(duration["millisecond"]);
|
|
25604
|
+
date.setMilliseconds(date.getMilliseconds() + floor);
|
|
25605
|
+
}
|
|
25606
|
+
return date;
|
|
25607
|
+
}
|
|
25608
|
+
function reverseDuration(duration) {
|
|
25609
|
+
const reversed = {};
|
|
25610
|
+
for (const key in duration) reversed[key] = -duration[key];
|
|
25611
|
+
return reversed;
|
|
25612
|
+
}
|
|
25613
|
+
|
|
25614
|
+
//#endregion
|
|
25615
|
+
//#region ../../node_modules/chrono-node/dist/esm/results.js
|
|
25616
|
+
var ReferenceWithTimezone = class ReferenceWithTimezone {
|
|
25617
|
+
instant;
|
|
25618
|
+
timezoneOffset;
|
|
25619
|
+
constructor(instant, timezoneOffset) {
|
|
25620
|
+
this.instant = instant ?? /* @__PURE__ */ new Date();
|
|
25621
|
+
this.timezoneOffset = timezoneOffset ?? null;
|
|
25622
|
+
}
|
|
25623
|
+
static fromDate(date) {
|
|
25624
|
+
return new ReferenceWithTimezone(date);
|
|
25625
|
+
}
|
|
25626
|
+
static fromInput(input, timezoneOverrides) {
|
|
25627
|
+
if (input instanceof Date) return ReferenceWithTimezone.fromDate(input);
|
|
25628
|
+
const instant = input?.instant ?? /* @__PURE__ */ new Date();
|
|
25629
|
+
return new ReferenceWithTimezone(instant, toTimezoneOffset(input?.timezone, instant, timezoneOverrides));
|
|
25630
|
+
}
|
|
25631
|
+
getDateWithAdjustedTimezone() {
|
|
25632
|
+
const date = new Date(this.instant);
|
|
25633
|
+
if (this.timezoneOffset !== null) date.setMinutes(date.getMinutes() - this.getSystemTimezoneAdjustmentMinute(this.instant));
|
|
25634
|
+
return date;
|
|
25635
|
+
}
|
|
25636
|
+
getSystemTimezoneAdjustmentMinute(date, overrideTimezoneOffset) {
|
|
25637
|
+
if (!date || date.getTime() < 0) date = /* @__PURE__ */ new Date();
|
|
25638
|
+
const currentTimezoneOffset = -date.getTimezoneOffset();
|
|
25639
|
+
return currentTimezoneOffset - (overrideTimezoneOffset ?? this.timezoneOffset ?? currentTimezoneOffset);
|
|
25640
|
+
}
|
|
25641
|
+
getTimezoneOffset() {
|
|
25642
|
+
return this.timezoneOffset ?? -this.instant.getTimezoneOffset();
|
|
25643
|
+
}
|
|
25644
|
+
};
|
|
25645
|
+
var ParsingComponents = class ParsingComponents {
|
|
25646
|
+
knownValues;
|
|
25647
|
+
impliedValues;
|
|
25648
|
+
reference;
|
|
25649
|
+
_tags = /* @__PURE__ */ new Set();
|
|
25650
|
+
constructor(reference, knownComponents) {
|
|
25651
|
+
this.reference = reference;
|
|
25652
|
+
this.knownValues = {};
|
|
25653
|
+
this.impliedValues = {};
|
|
25654
|
+
if (knownComponents) for (const key in knownComponents) this.knownValues[key] = knownComponents[key];
|
|
25655
|
+
const date = reference.getDateWithAdjustedTimezone();
|
|
25656
|
+
this.imply("day", date.getDate());
|
|
25657
|
+
this.imply("month", date.getMonth() + 1);
|
|
25658
|
+
this.imply("year", date.getFullYear());
|
|
25659
|
+
this.imply("hour", 12);
|
|
25660
|
+
this.imply("minute", 0);
|
|
25661
|
+
this.imply("second", 0);
|
|
25662
|
+
this.imply("millisecond", 0);
|
|
25663
|
+
}
|
|
25664
|
+
static createRelativeFromReference(reference, duration = EmptyDuration) {
|
|
25665
|
+
let date = addDuration(reference.getDateWithAdjustedTimezone(), duration);
|
|
25666
|
+
const components = new ParsingComponents(reference);
|
|
25667
|
+
components.addTag("result/relativeDate");
|
|
25668
|
+
if ("hour" in duration || "minute" in duration || "second" in duration || "millisecond" in duration) {
|
|
25669
|
+
components.addTag("result/relativeDateAndTime");
|
|
25670
|
+
assignSimilarTime(components, date);
|
|
25671
|
+
assignSimilarDate(components, date);
|
|
25672
|
+
components.assign("timezoneOffset", reference.getTimezoneOffset());
|
|
25673
|
+
} else {
|
|
25674
|
+
implySimilarTime(components, date);
|
|
25675
|
+
components.imply("timezoneOffset", reference.getTimezoneOffset());
|
|
25676
|
+
if ("day" in duration) {
|
|
25677
|
+
components.assign("day", date.getDate());
|
|
25678
|
+
components.assign("month", date.getMonth() + 1);
|
|
25679
|
+
components.assign("year", date.getFullYear());
|
|
25680
|
+
components.assign("weekday", date.getDay());
|
|
25681
|
+
} else if ("week" in duration) {
|
|
25682
|
+
components.assign("day", date.getDate());
|
|
25683
|
+
components.assign("month", date.getMonth() + 1);
|
|
25684
|
+
components.assign("year", date.getFullYear());
|
|
25685
|
+
components.imply("weekday", date.getDay());
|
|
25686
|
+
} else {
|
|
25687
|
+
components.imply("day", date.getDate());
|
|
25688
|
+
if ("month" in duration) {
|
|
25689
|
+
components.assign("month", date.getMonth() + 1);
|
|
25690
|
+
components.assign("year", date.getFullYear());
|
|
25691
|
+
} else {
|
|
25692
|
+
components.imply("month", date.getMonth() + 1);
|
|
25693
|
+
if ("year" in duration) components.assign("year", date.getFullYear());
|
|
25694
|
+
else components.imply("year", date.getFullYear());
|
|
25695
|
+
}
|
|
25696
|
+
}
|
|
25697
|
+
}
|
|
25698
|
+
return components;
|
|
25058
25699
|
}
|
|
25059
|
-
|
|
25060
|
-
|
|
25700
|
+
get(component) {
|
|
25701
|
+
if (component in this.knownValues) return this.knownValues[component];
|
|
25702
|
+
if (component in this.impliedValues) return this.impliedValues[component];
|
|
25703
|
+
return null;
|
|
25061
25704
|
}
|
|
25062
|
-
|
|
25063
|
-
|
|
25064
|
-
|
|
25065
|
-
|
|
25705
|
+
isCertain(component) {
|
|
25706
|
+
return component in this.knownValues;
|
|
25707
|
+
}
|
|
25708
|
+
getCertainComponents() {
|
|
25709
|
+
return Object.keys(this.knownValues);
|
|
25710
|
+
}
|
|
25711
|
+
imply(component, value) {
|
|
25712
|
+
if (component in this.knownValues) return this;
|
|
25713
|
+
this.impliedValues[component] = value;
|
|
25714
|
+
return this;
|
|
25715
|
+
}
|
|
25716
|
+
assign(component, value) {
|
|
25717
|
+
this.knownValues[component] = value;
|
|
25718
|
+
delete this.impliedValues[component];
|
|
25719
|
+
return this;
|
|
25720
|
+
}
|
|
25721
|
+
addDurationAsImplied(duration) {
|
|
25722
|
+
const date = addDuration(this.dateWithoutTimezoneAdjustment(), duration);
|
|
25723
|
+
if ("day" in duration || "week" in duration || "month" in duration || "year" in duration) {
|
|
25724
|
+
this.delete([
|
|
25725
|
+
"day",
|
|
25726
|
+
"weekday",
|
|
25727
|
+
"month",
|
|
25728
|
+
"year"
|
|
25729
|
+
]);
|
|
25730
|
+
this.imply("day", date.getDate());
|
|
25731
|
+
this.imply("weekday", date.getDay());
|
|
25732
|
+
this.imply("month", date.getMonth() + 1);
|
|
25733
|
+
this.imply("year", date.getFullYear());
|
|
25734
|
+
}
|
|
25735
|
+
if ("second" in duration || "minute" in duration || "hour" in duration) {
|
|
25736
|
+
this.delete([
|
|
25737
|
+
"second",
|
|
25738
|
+
"minute",
|
|
25739
|
+
"hour"
|
|
25740
|
+
]);
|
|
25741
|
+
this.imply("second", date.getSeconds());
|
|
25742
|
+
this.imply("minute", date.getMinutes());
|
|
25743
|
+
this.imply("hour", date.getHours());
|
|
25744
|
+
}
|
|
25745
|
+
return this;
|
|
25746
|
+
}
|
|
25747
|
+
delete(components) {
|
|
25748
|
+
if (typeof components === "string") components = [components];
|
|
25749
|
+
for (const component of components) {
|
|
25750
|
+
delete this.knownValues[component];
|
|
25751
|
+
delete this.impliedValues[component];
|
|
25752
|
+
}
|
|
25753
|
+
}
|
|
25754
|
+
clone() {
|
|
25755
|
+
const component = new ParsingComponents(this.reference);
|
|
25756
|
+
component.knownValues = {};
|
|
25757
|
+
component.impliedValues = {};
|
|
25758
|
+
for (const key in this.knownValues) component.knownValues[key] = this.knownValues[key];
|
|
25759
|
+
for (const key in this.impliedValues) component.impliedValues[key] = this.impliedValues[key];
|
|
25760
|
+
return component;
|
|
25761
|
+
}
|
|
25762
|
+
isOnlyDate() {
|
|
25763
|
+
return !this.isCertain("hour") && !this.isCertain("minute") && !this.isCertain("second");
|
|
25764
|
+
}
|
|
25765
|
+
isOnlyTime() {
|
|
25766
|
+
return !this.isCertain("weekday") && !this.isCertain("day") && !this.isCertain("month") && !this.isCertain("year");
|
|
25767
|
+
}
|
|
25768
|
+
isOnlyWeekdayComponent() {
|
|
25769
|
+
return this.isCertain("weekday") && !this.isCertain("day") && !this.isCertain("month");
|
|
25770
|
+
}
|
|
25771
|
+
isDateWithUnknownYear() {
|
|
25772
|
+
return this.isCertain("month") && !this.isCertain("year");
|
|
25773
|
+
}
|
|
25774
|
+
isValidDate() {
|
|
25775
|
+
const date = this.dateWithoutTimezoneAdjustment();
|
|
25776
|
+
if (date.getFullYear() !== this.get("year")) return false;
|
|
25777
|
+
if (date.getMonth() !== this.get("month") - 1) return false;
|
|
25778
|
+
if (date.getDate() !== this.get("day")) return false;
|
|
25779
|
+
if (this.get("hour") != null && date.getHours() != this.get("hour")) return false;
|
|
25780
|
+
if (this.get("minute") != null && date.getMinutes() != this.get("minute")) return false;
|
|
25781
|
+
return true;
|
|
25782
|
+
}
|
|
25783
|
+
toString() {
|
|
25784
|
+
return `[ParsingComponents {
|
|
25785
|
+
tags: ${JSON.stringify(Array.from(this._tags).sort())},
|
|
25786
|
+
knownValues: ${JSON.stringify(this.knownValues)},
|
|
25787
|
+
impliedValues: ${JSON.stringify(this.impliedValues)}},
|
|
25788
|
+
reference: ${JSON.stringify(this.reference)}]`;
|
|
25789
|
+
}
|
|
25790
|
+
date() {
|
|
25791
|
+
const date = this.dateWithoutTimezoneAdjustment();
|
|
25792
|
+
const timezoneAdjustment = this.reference.getSystemTimezoneAdjustmentMinute(date, this.get("timezoneOffset"));
|
|
25793
|
+
return new Date(date.getTime() + timezoneAdjustment * 6e4);
|
|
25794
|
+
}
|
|
25795
|
+
addTag(tag) {
|
|
25796
|
+
this._tags.add(tag);
|
|
25797
|
+
return this;
|
|
25798
|
+
}
|
|
25799
|
+
addTags(tags) {
|
|
25800
|
+
for (const tag of tags) this._tags.add(tag);
|
|
25801
|
+
return this;
|
|
25802
|
+
}
|
|
25803
|
+
tags() {
|
|
25804
|
+
return new Set(this._tags);
|
|
25805
|
+
}
|
|
25806
|
+
dateWithoutTimezoneAdjustment() {
|
|
25807
|
+
const date = new Date(this.get("year"), this.get("month") - 1, this.get("day"), this.get("hour"), this.get("minute"), this.get("second"), this.get("millisecond"));
|
|
25808
|
+
date.setFullYear(this.get("year"));
|
|
25809
|
+
return date;
|
|
25810
|
+
}
|
|
25811
|
+
};
|
|
25812
|
+
var ParsingResult = class ParsingResult {
|
|
25813
|
+
refDate;
|
|
25814
|
+
index;
|
|
25815
|
+
text;
|
|
25816
|
+
reference;
|
|
25817
|
+
start;
|
|
25818
|
+
end;
|
|
25819
|
+
constructor(reference, index, text, start, end) {
|
|
25820
|
+
this.reference = reference;
|
|
25821
|
+
this.refDate = reference.instant;
|
|
25822
|
+
this.index = index;
|
|
25823
|
+
this.text = text;
|
|
25824
|
+
this.start = start || new ParsingComponents(reference);
|
|
25825
|
+
this.end = end;
|
|
25826
|
+
}
|
|
25827
|
+
clone() {
|
|
25828
|
+
const result = new ParsingResult(this.reference, this.index, this.text);
|
|
25829
|
+
result.start = this.start ? this.start.clone() : null;
|
|
25830
|
+
result.end = this.end ? this.end.clone() : null;
|
|
25831
|
+
return result;
|
|
25832
|
+
}
|
|
25833
|
+
date() {
|
|
25834
|
+
return this.start.date();
|
|
25835
|
+
}
|
|
25836
|
+
addTag(tag) {
|
|
25837
|
+
this.start.addTag(tag);
|
|
25838
|
+
if (this.end) this.end.addTag(tag);
|
|
25839
|
+
return this;
|
|
25840
|
+
}
|
|
25841
|
+
addTags(tags) {
|
|
25842
|
+
this.start.addTags(tags);
|
|
25843
|
+
if (this.end) this.end.addTags(tags);
|
|
25844
|
+
return this;
|
|
25845
|
+
}
|
|
25846
|
+
tags() {
|
|
25847
|
+
const combinedTags = new Set(this.start.tags());
|
|
25848
|
+
if (this.end) for (const tag of this.end.tags()) combinedTags.add(tag);
|
|
25849
|
+
return combinedTags;
|
|
25850
|
+
}
|
|
25851
|
+
toString() {
|
|
25852
|
+
const tags = Array.from(this.tags()).sort();
|
|
25853
|
+
return `[ParsingResult {index: ${this.index}, text: '${this.text}', tags: ${JSON.stringify(tags)} ...}]`;
|
|
25854
|
+
}
|
|
25855
|
+
};
|
|
25856
|
+
|
|
25857
|
+
//#endregion
|
|
25858
|
+
//#region ../../node_modules/chrono-node/dist/esm/utils/pattern.js
|
|
25859
|
+
function repeatedTimeunitPattern(prefix, singleTimeunitPattern, connectorPattern = "\\s{0,5},?\\s{0,5}") {
|
|
25860
|
+
const singleTimeunitPatternNoCapture = singleTimeunitPattern.replace(/\((?!\?)/g, "(?:");
|
|
25861
|
+
return `${prefix}${singleTimeunitPatternNoCapture}(?:${connectorPattern}${singleTimeunitPatternNoCapture}){0,10}`;
|
|
25862
|
+
}
|
|
25863
|
+
function extractTerms(dictionary) {
|
|
25864
|
+
let keys;
|
|
25865
|
+
if (dictionary instanceof Array) keys = [...dictionary];
|
|
25866
|
+
else if (dictionary instanceof Map) keys = Array.from(dictionary.keys());
|
|
25867
|
+
else keys = Object.keys(dictionary);
|
|
25868
|
+
return keys;
|
|
25869
|
+
}
|
|
25870
|
+
function matchAnyPattern(dictionary) {
|
|
25871
|
+
return `(?:${extractTerms(dictionary).sort((a, b) => b.length - a.length).join("|").replace(/\./g, "\\.")})`;
|
|
25872
|
+
}
|
|
25873
|
+
|
|
25874
|
+
//#endregion
|
|
25875
|
+
//#region ../../node_modules/chrono-node/dist/esm/calculation/years.js
|
|
25876
|
+
function findMostLikelyADYear(yearNumber) {
|
|
25877
|
+
if (yearNumber < 100) if (yearNumber > 50) yearNumber = yearNumber + 1900;
|
|
25878
|
+
else yearNumber = yearNumber + 2e3;
|
|
25879
|
+
return yearNumber;
|
|
25880
|
+
}
|
|
25881
|
+
function findYearClosestToRef(refDate, day, month) {
|
|
25882
|
+
let date = new Date(refDate);
|
|
25883
|
+
date.setMonth(month - 1);
|
|
25884
|
+
date.setDate(day);
|
|
25885
|
+
const nextYear = addDuration(date, { "year": 1 });
|
|
25886
|
+
const lastYear = addDuration(date, { "year": -1 });
|
|
25887
|
+
if (Math.abs(nextYear.getTime() - refDate.getTime()) < Math.abs(date.getTime() - refDate.getTime())) date = nextYear;
|
|
25888
|
+
else if (Math.abs(lastYear.getTime() - refDate.getTime()) < Math.abs(date.getTime() - refDate.getTime())) date = lastYear;
|
|
25889
|
+
return date.getFullYear();
|
|
25890
|
+
}
|
|
25891
|
+
|
|
25892
|
+
//#endregion
|
|
25893
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/constants.js
|
|
25894
|
+
const WEEKDAY_DICTIONARY = {
|
|
25895
|
+
sunday: 0,
|
|
25896
|
+
sun: 0,
|
|
25897
|
+
"sun.": 0,
|
|
25898
|
+
monday: 1,
|
|
25899
|
+
mon: 1,
|
|
25900
|
+
"mon.": 1,
|
|
25901
|
+
tuesday: 2,
|
|
25902
|
+
tue: 2,
|
|
25903
|
+
"tue.": 2,
|
|
25904
|
+
wednesday: 3,
|
|
25905
|
+
wed: 3,
|
|
25906
|
+
"wed.": 3,
|
|
25907
|
+
thursday: 4,
|
|
25908
|
+
thurs: 4,
|
|
25909
|
+
"thurs.": 4,
|
|
25910
|
+
thur: 4,
|
|
25911
|
+
"thur.": 4,
|
|
25912
|
+
thu: 4,
|
|
25913
|
+
"thu.": 4,
|
|
25914
|
+
friday: 5,
|
|
25915
|
+
fri: 5,
|
|
25916
|
+
"fri.": 5,
|
|
25917
|
+
saturday: 6,
|
|
25918
|
+
sat: 6,
|
|
25919
|
+
"sat.": 6
|
|
25920
|
+
};
|
|
25921
|
+
const FULL_MONTH_NAME_DICTIONARY = {
|
|
25922
|
+
january: 1,
|
|
25923
|
+
february: 2,
|
|
25924
|
+
march: 3,
|
|
25925
|
+
april: 4,
|
|
25926
|
+
may: 5,
|
|
25927
|
+
june: 6,
|
|
25928
|
+
july: 7,
|
|
25929
|
+
august: 8,
|
|
25930
|
+
september: 9,
|
|
25931
|
+
october: 10,
|
|
25932
|
+
november: 11,
|
|
25933
|
+
december: 12
|
|
25934
|
+
};
|
|
25935
|
+
const MONTH_DICTIONARY = {
|
|
25936
|
+
...FULL_MONTH_NAME_DICTIONARY,
|
|
25937
|
+
jan: 1,
|
|
25938
|
+
"jan.": 1,
|
|
25939
|
+
feb: 2,
|
|
25940
|
+
"feb.": 2,
|
|
25941
|
+
mar: 3,
|
|
25942
|
+
"mar.": 3,
|
|
25943
|
+
apr: 4,
|
|
25944
|
+
"apr.": 4,
|
|
25945
|
+
jun: 6,
|
|
25946
|
+
"jun.": 6,
|
|
25947
|
+
jul: 7,
|
|
25948
|
+
"jul.": 7,
|
|
25949
|
+
aug: 8,
|
|
25950
|
+
"aug.": 8,
|
|
25951
|
+
sep: 9,
|
|
25952
|
+
"sep.": 9,
|
|
25953
|
+
sept: 9,
|
|
25954
|
+
"sept.": 9,
|
|
25955
|
+
oct: 10,
|
|
25956
|
+
"oct.": 10,
|
|
25957
|
+
nov: 11,
|
|
25958
|
+
"nov.": 11,
|
|
25959
|
+
dec: 12,
|
|
25960
|
+
"dec.": 12
|
|
25961
|
+
};
|
|
25962
|
+
const INTEGER_WORD_DICTIONARY = {
|
|
25963
|
+
one: 1,
|
|
25964
|
+
two: 2,
|
|
25965
|
+
three: 3,
|
|
25966
|
+
four: 4,
|
|
25967
|
+
five: 5,
|
|
25968
|
+
six: 6,
|
|
25969
|
+
seven: 7,
|
|
25970
|
+
eight: 8,
|
|
25971
|
+
nine: 9,
|
|
25972
|
+
ten: 10,
|
|
25973
|
+
eleven: 11,
|
|
25974
|
+
twelve: 12
|
|
25975
|
+
};
|
|
25976
|
+
const ORDINAL_WORD_DICTIONARY = {
|
|
25977
|
+
first: 1,
|
|
25978
|
+
second: 2,
|
|
25979
|
+
third: 3,
|
|
25980
|
+
fourth: 4,
|
|
25981
|
+
fifth: 5,
|
|
25982
|
+
sixth: 6,
|
|
25983
|
+
seventh: 7,
|
|
25984
|
+
eighth: 8,
|
|
25985
|
+
ninth: 9,
|
|
25986
|
+
tenth: 10,
|
|
25987
|
+
eleventh: 11,
|
|
25988
|
+
twelfth: 12,
|
|
25989
|
+
thirteenth: 13,
|
|
25990
|
+
fourteenth: 14,
|
|
25991
|
+
fifteenth: 15,
|
|
25992
|
+
sixteenth: 16,
|
|
25993
|
+
seventeenth: 17,
|
|
25994
|
+
eighteenth: 18,
|
|
25995
|
+
nineteenth: 19,
|
|
25996
|
+
twentieth: 20,
|
|
25997
|
+
"twenty first": 21,
|
|
25998
|
+
"twenty-first": 21,
|
|
25999
|
+
"twenty second": 22,
|
|
26000
|
+
"twenty-second": 22,
|
|
26001
|
+
"twenty third": 23,
|
|
26002
|
+
"twenty-third": 23,
|
|
26003
|
+
"twenty fourth": 24,
|
|
26004
|
+
"twenty-fourth": 24,
|
|
26005
|
+
"twenty fifth": 25,
|
|
26006
|
+
"twenty-fifth": 25,
|
|
26007
|
+
"twenty sixth": 26,
|
|
26008
|
+
"twenty-sixth": 26,
|
|
26009
|
+
"twenty seventh": 27,
|
|
26010
|
+
"twenty-seventh": 27,
|
|
26011
|
+
"twenty eighth": 28,
|
|
26012
|
+
"twenty-eighth": 28,
|
|
26013
|
+
"twenty ninth": 29,
|
|
26014
|
+
"twenty-ninth": 29,
|
|
26015
|
+
"thirtieth": 30,
|
|
26016
|
+
"thirty first": 31,
|
|
26017
|
+
"thirty-first": 31
|
|
26018
|
+
};
|
|
26019
|
+
const TIME_UNIT_DICTIONARY_NO_ABBR = {
|
|
26020
|
+
second: "second",
|
|
26021
|
+
seconds: "second",
|
|
26022
|
+
minute: "minute",
|
|
26023
|
+
minutes: "minute",
|
|
26024
|
+
hour: "hour",
|
|
26025
|
+
hours: "hour",
|
|
26026
|
+
day: "day",
|
|
26027
|
+
days: "day",
|
|
26028
|
+
week: "week",
|
|
26029
|
+
weeks: "week",
|
|
26030
|
+
month: "month",
|
|
26031
|
+
months: "month",
|
|
26032
|
+
quarter: "quarter",
|
|
26033
|
+
quarters: "quarter",
|
|
26034
|
+
year: "year",
|
|
26035
|
+
years: "year"
|
|
26036
|
+
};
|
|
26037
|
+
const TIME_UNIT_DICTIONARY = {
|
|
26038
|
+
s: "second",
|
|
26039
|
+
sec: "second",
|
|
26040
|
+
second: "second",
|
|
26041
|
+
seconds: "second",
|
|
26042
|
+
m: "minute",
|
|
26043
|
+
min: "minute",
|
|
26044
|
+
mins: "minute",
|
|
26045
|
+
minute: "minute",
|
|
26046
|
+
minutes: "minute",
|
|
26047
|
+
h: "hour",
|
|
26048
|
+
hr: "hour",
|
|
26049
|
+
hrs: "hour",
|
|
26050
|
+
hour: "hour",
|
|
26051
|
+
hours: "hour",
|
|
26052
|
+
d: "day",
|
|
26053
|
+
day: "day",
|
|
26054
|
+
days: "day",
|
|
26055
|
+
w: "week",
|
|
26056
|
+
week: "week",
|
|
26057
|
+
weeks: "week",
|
|
26058
|
+
mo: "month",
|
|
26059
|
+
mon: "month",
|
|
26060
|
+
mos: "month",
|
|
26061
|
+
month: "month",
|
|
26062
|
+
months: "month",
|
|
26063
|
+
qtr: "quarter",
|
|
26064
|
+
quarter: "quarter",
|
|
26065
|
+
quarters: "quarter",
|
|
26066
|
+
y: "year",
|
|
26067
|
+
yr: "year",
|
|
26068
|
+
year: "year",
|
|
26069
|
+
years: "year",
|
|
26070
|
+
...TIME_UNIT_DICTIONARY_NO_ABBR
|
|
26071
|
+
};
|
|
26072
|
+
const NUMBER_PATTERN = `(?:${matchAnyPattern(INTEGER_WORD_DICTIONARY)}|[0-9]+|[0-9]+\\.[0-9]+|half(?:\\s{0,2}an?)?|an?\\b(?:\\s{0,2}few)?|few|several|the|a?\\s{0,2}couple\\s{0,2}(?:of)?)`;
|
|
26073
|
+
function parseNumberPattern(match) {
|
|
26074
|
+
const num = match.toLowerCase();
|
|
26075
|
+
if (INTEGER_WORD_DICTIONARY[num] !== void 0) return INTEGER_WORD_DICTIONARY[num];
|
|
26076
|
+
else if (num === "a" || num === "an" || num == "the") return 1;
|
|
26077
|
+
else if (num.match(/few/)) return 3;
|
|
26078
|
+
else if (num.match(/half/)) return .5;
|
|
26079
|
+
else if (num.match(/couple/)) return 2;
|
|
26080
|
+
else if (num.match(/several/)) return 7;
|
|
26081
|
+
return parseFloat(num);
|
|
26082
|
+
}
|
|
26083
|
+
const ORDINAL_NUMBER_PATTERN = `(?:${matchAnyPattern(ORDINAL_WORD_DICTIONARY)}|[0-9]{1,2}(?:st|nd|rd|th)?)`;
|
|
26084
|
+
function parseOrdinalNumberPattern(match) {
|
|
26085
|
+
let num = match.toLowerCase();
|
|
26086
|
+
if (ORDINAL_WORD_DICTIONARY[num] !== void 0) return ORDINAL_WORD_DICTIONARY[num];
|
|
26087
|
+
num = num.replace(/(?:st|nd|rd|th)$/i, "");
|
|
26088
|
+
return parseInt(num);
|
|
26089
|
+
}
|
|
26090
|
+
const YEAR_PATTERN = `(?:[1-9][0-9]{0,3}\\s{0,2}(?:BE|AD|BC|BCE|CE)|[1-2][0-9]{3}|[5-9][0-9]|2[0-5])`;
|
|
26091
|
+
function parseYear(match) {
|
|
26092
|
+
if (/BE/i.test(match)) {
|
|
26093
|
+
match = match.replace(/BE/i, "");
|
|
26094
|
+
return parseInt(match) - 543;
|
|
26095
|
+
}
|
|
26096
|
+
if (/BCE?/i.test(match)) {
|
|
26097
|
+
match = match.replace(/BCE?/i, "");
|
|
26098
|
+
return -parseInt(match);
|
|
26099
|
+
}
|
|
26100
|
+
if (/(AD|CE)/i.test(match)) {
|
|
26101
|
+
match = match.replace(/(AD|CE)/i, "");
|
|
26102
|
+
return parseInt(match);
|
|
26103
|
+
}
|
|
26104
|
+
return findMostLikelyADYear(parseInt(match));
|
|
26105
|
+
}
|
|
26106
|
+
const SINGLE_TIME_UNIT_PATTERN = `(${NUMBER_PATTERN})\\s{0,3}(${matchAnyPattern(TIME_UNIT_DICTIONARY)})`;
|
|
26107
|
+
const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
|
26108
|
+
const SINGLE_TIME_UNIT_NO_ABBR_PATTERN = `(${NUMBER_PATTERN})\\s{0,3}(${matchAnyPattern(TIME_UNIT_DICTIONARY_NO_ABBR)})`;
|
|
26109
|
+
const TIME_UNIT_CONNECTOR_PATTERN = `\\s{0,5},?(?:\\s*and)?\\s{0,5}`;
|
|
26110
|
+
const TIME_UNITS_PATTERN = repeatedTimeunitPattern(`(?:(?:about|around)\\s{0,3})?`, SINGLE_TIME_UNIT_PATTERN, TIME_UNIT_CONNECTOR_PATTERN);
|
|
26111
|
+
const TIME_UNITS_NO_ABBR_PATTERN = repeatedTimeunitPattern(`(?:(?:about|around)\\s{0,3})?`, SINGLE_TIME_UNIT_NO_ABBR_PATTERN, TIME_UNIT_CONNECTOR_PATTERN);
|
|
26112
|
+
function parseDuration(timeunitText) {
|
|
26113
|
+
const fragments = {};
|
|
26114
|
+
let remainingText = timeunitText;
|
|
26115
|
+
let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
26116
|
+
while (match) {
|
|
26117
|
+
collectDateTimeFragment(fragments, match);
|
|
26118
|
+
remainingText = remainingText.substring(match[0].length).trim();
|
|
26119
|
+
match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
|
26120
|
+
}
|
|
26121
|
+
if (Object.keys(fragments).length == 0) return null;
|
|
26122
|
+
return fragments;
|
|
26123
|
+
}
|
|
26124
|
+
function collectDateTimeFragment(fragments, match) {
|
|
26125
|
+
if (match[0].match(/^[a-zA-Z]+$/)) return;
|
|
26126
|
+
const num = parseNumberPattern(match[1]);
|
|
26127
|
+
const unit = TIME_UNIT_DICTIONARY[match[2].toLowerCase()];
|
|
26128
|
+
fragments[unit] = num;
|
|
26129
|
+
}
|
|
26130
|
+
|
|
26131
|
+
//#endregion
|
|
26132
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/parsers/AbstractParserWithWordBoundary.js
|
|
26133
|
+
var AbstractParserWithWordBoundaryChecking = class {
|
|
26134
|
+
innerPatternHasChange(context, currentInnerPattern) {
|
|
26135
|
+
return this.innerPattern(context) !== currentInnerPattern;
|
|
26136
|
+
}
|
|
26137
|
+
patternLeftBoundary() {
|
|
26138
|
+
return `(\\W|^)`;
|
|
26139
|
+
}
|
|
26140
|
+
cachedInnerPattern = null;
|
|
26141
|
+
cachedPattern = null;
|
|
26142
|
+
pattern(context) {
|
|
26143
|
+
if (this.cachedInnerPattern) {
|
|
26144
|
+
if (!this.innerPatternHasChange(context, this.cachedInnerPattern)) return this.cachedPattern;
|
|
26145
|
+
}
|
|
26146
|
+
this.cachedInnerPattern = this.innerPattern(context);
|
|
26147
|
+
this.cachedPattern = new RegExp(`${this.patternLeftBoundary()}${this.cachedInnerPattern.source}`, this.cachedInnerPattern.flags);
|
|
26148
|
+
return this.cachedPattern;
|
|
26149
|
+
}
|
|
26150
|
+
extract(context, match) {
|
|
26151
|
+
const header = match[1] ?? "";
|
|
26152
|
+
match.index = match.index + header.length;
|
|
26153
|
+
match[0] = match[0].substring(header.length);
|
|
26154
|
+
for (let i = 2; i < match.length; i++) match[i - 1] = match[i];
|
|
26155
|
+
return this.innerExtract(context, match);
|
|
26156
|
+
}
|
|
26157
|
+
};
|
|
26158
|
+
|
|
26159
|
+
//#endregion
|
|
26160
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENTimeUnitWithinFormatParser.js
|
|
26161
|
+
const PATTERN_WITH_OPTIONAL_PREFIX = new RegExp(`(?:(?:within|in|for)\\s*)?(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
|
|
26162
|
+
const PATTERN_WITH_PREFIX = new RegExp(`(?:within|in|for)\\s*(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
|
|
26163
|
+
const PATTERN_WITH_PREFIX_STRICT = new RegExp(`(?:within|in|for)\\s*(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${TIME_UNITS_NO_ABBR_PATTERN})(?=\\W|$)`, "i");
|
|
26164
|
+
var ENTimeUnitWithinFormatParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
26165
|
+
strictMode;
|
|
26166
|
+
constructor(strictMode) {
|
|
26167
|
+
super();
|
|
26168
|
+
this.strictMode = strictMode;
|
|
26169
|
+
}
|
|
26170
|
+
innerPattern(context) {
|
|
26171
|
+
if (this.strictMode) return PATTERN_WITH_PREFIX_STRICT;
|
|
26172
|
+
return context.option.forwardDate ? PATTERN_WITH_OPTIONAL_PREFIX : PATTERN_WITH_PREFIX;
|
|
26173
|
+
}
|
|
26174
|
+
innerExtract(context, match) {
|
|
26175
|
+
if (match[0].match(/^for\s*the\s*\w+/)) return null;
|
|
26176
|
+
const timeUnits = parseDuration(match[1]);
|
|
26177
|
+
if (!timeUnits) return null;
|
|
26178
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
26179
|
+
}
|
|
26180
|
+
};
|
|
26181
|
+
|
|
26182
|
+
//#endregion
|
|
26183
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENMonthNameLittleEndianParser.js
|
|
26184
|
+
const PATTERN$13 = new RegExp(`(?:on\\s{0,3})?(${ORDINAL_NUMBER_PATTERN})(?:\\s{0,3}(?:to|\\-|\\–|until|through|till)?\\s{0,3}(${ORDINAL_NUMBER_PATTERN}))?(?:-|/|\\s{0,3}(?:of)?\\s{0,3})(${matchAnyPattern(MONTH_DICTIONARY)})(?:(?:-|/|,?\\s{0,3})(${YEAR_PATTERN}(?!\\w)))?(?=\\W|\$)`, "i");
|
|
26185
|
+
const DATE_GROUP$1 = 1;
|
|
26186
|
+
const DATE_TO_GROUP$1 = 2;
|
|
26187
|
+
const MONTH_NAME_GROUP$3 = 3;
|
|
26188
|
+
const YEAR_GROUP$5 = 4;
|
|
26189
|
+
var ENMonthNameLittleEndianParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
26190
|
+
innerPattern() {
|
|
26191
|
+
return PATTERN$13;
|
|
26192
|
+
}
|
|
26193
|
+
innerExtract(context, match) {
|
|
26194
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
26195
|
+
const month = MONTH_DICTIONARY[match[MONTH_NAME_GROUP$3].toLowerCase()];
|
|
26196
|
+
const day = parseOrdinalNumberPattern(match[DATE_GROUP$1]);
|
|
26197
|
+
if (day > 31) {
|
|
26198
|
+
match.index = match.index + match[DATE_GROUP$1].length;
|
|
26199
|
+
return null;
|
|
26200
|
+
}
|
|
26201
|
+
result.start.assign("month", month);
|
|
26202
|
+
result.start.assign("day", day);
|
|
26203
|
+
if (match[YEAR_GROUP$5]) {
|
|
26204
|
+
const yearNumber = parseYear(match[YEAR_GROUP$5]);
|
|
26205
|
+
result.start.assign("year", yearNumber);
|
|
26206
|
+
} else {
|
|
26207
|
+
const year = findYearClosestToRef(context.refDate, day, month);
|
|
26208
|
+
result.start.imply("year", year);
|
|
26209
|
+
}
|
|
26210
|
+
if (match[DATE_TO_GROUP$1]) {
|
|
26211
|
+
const endDate = parseOrdinalNumberPattern(match[DATE_TO_GROUP$1]);
|
|
26212
|
+
result.end = result.start.clone();
|
|
26213
|
+
result.end.assign("day", endDate);
|
|
26214
|
+
}
|
|
26215
|
+
return result;
|
|
26216
|
+
}
|
|
26217
|
+
};
|
|
26218
|
+
|
|
26219
|
+
//#endregion
|
|
26220
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENMonthNameMiddleEndianParser.js
|
|
26221
|
+
const PATTERN$12 = new RegExp(`(${matchAnyPattern(MONTH_DICTIONARY)})(?:-|/|\\s*,?\\s*)(${ORDINAL_NUMBER_PATTERN})(?!\\s*(?:am|pm))\\s*(?:(?:to|\\-)\\s*(${ORDINAL_NUMBER_PATTERN})\\s*)?(?:(?:-|/|\\s*,\\s*|\\s+)(${YEAR_PATTERN}))?(?=\\W|\$)(?!\\:\\d)`, "i");
|
|
26222
|
+
const MONTH_NAME_GROUP$2 = 1;
|
|
26223
|
+
const DATE_GROUP = 2;
|
|
26224
|
+
const DATE_TO_GROUP = 3;
|
|
26225
|
+
const YEAR_GROUP$4 = 4;
|
|
26226
|
+
var ENMonthNameMiddleEndianParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
26227
|
+
shouldSkipYearLikeDate;
|
|
26228
|
+
constructor(shouldSkipYearLikeDate) {
|
|
26229
|
+
super();
|
|
26230
|
+
this.shouldSkipYearLikeDate = shouldSkipYearLikeDate;
|
|
26231
|
+
}
|
|
26232
|
+
innerPattern() {
|
|
26233
|
+
return PATTERN$12;
|
|
26234
|
+
}
|
|
26235
|
+
innerExtract(context, match) {
|
|
26236
|
+
const month = MONTH_DICTIONARY[match[MONTH_NAME_GROUP$2].toLowerCase()];
|
|
26237
|
+
const day = parseOrdinalNumberPattern(match[DATE_GROUP]);
|
|
26238
|
+
if (day > 31) return null;
|
|
26239
|
+
if (this.shouldSkipYearLikeDate) {
|
|
26240
|
+
if (!match[DATE_TO_GROUP] && !match[YEAR_GROUP$4] && match[DATE_GROUP].match(/^2[0-5]$/)) return null;
|
|
26241
|
+
}
|
|
26242
|
+
const components = context.createParsingComponents({
|
|
26243
|
+
day,
|
|
26244
|
+
month
|
|
26245
|
+
}).addTag("parser/ENMonthNameMiddleEndianParser");
|
|
26246
|
+
if (match[YEAR_GROUP$4]) {
|
|
26247
|
+
const year = parseYear(match[YEAR_GROUP$4]);
|
|
26248
|
+
components.assign("year", year);
|
|
26249
|
+
} else {
|
|
26250
|
+
const year = findYearClosestToRef(context.refDate, day, month);
|
|
26251
|
+
components.imply("year", year);
|
|
26252
|
+
}
|
|
26253
|
+
if (!match[DATE_TO_GROUP]) return components;
|
|
26254
|
+
const endDate = parseOrdinalNumberPattern(match[DATE_TO_GROUP]);
|
|
26255
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
26256
|
+
result.start = components;
|
|
26257
|
+
result.end = components.clone();
|
|
26258
|
+
result.end.assign("day", endDate);
|
|
26259
|
+
return result;
|
|
26260
|
+
}
|
|
26261
|
+
};
|
|
26262
|
+
|
|
26263
|
+
//#endregion
|
|
26264
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENMonthNameParser.js
|
|
26265
|
+
const PATTERN$11 = new RegExp(`((?:in)\\s*)?(${matchAnyPattern(MONTH_DICTIONARY)})\\s*(?:(?:,|-|of)?\\s*(${YEAR_PATTERN})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+\$|\$)`, "i");
|
|
26266
|
+
const PREFIX_GROUP$1 = 1;
|
|
26267
|
+
const MONTH_NAME_GROUP$1 = 2;
|
|
26268
|
+
const YEAR_GROUP$3 = 3;
|
|
26269
|
+
var ENMonthNameParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
26270
|
+
innerPattern() {
|
|
26271
|
+
return PATTERN$11;
|
|
26272
|
+
}
|
|
26273
|
+
innerExtract(context, match) {
|
|
26274
|
+
const monthName = match[MONTH_NAME_GROUP$1].toLowerCase();
|
|
26275
|
+
if (match[0].length <= 3 && !FULL_MONTH_NAME_DICTIONARY[monthName]) return null;
|
|
26276
|
+
const result = context.createParsingResult(match.index + (match[PREFIX_GROUP$1] || "").length, match.index + match[0].length);
|
|
26277
|
+
result.start.imply("day", 1);
|
|
26278
|
+
result.start.addTag("parser/ENMonthNameParser");
|
|
26279
|
+
const month = MONTH_DICTIONARY[monthName];
|
|
26280
|
+
result.start.assign("month", month);
|
|
26281
|
+
if (match[YEAR_GROUP$3]) {
|
|
26282
|
+
const year = parseYear(match[YEAR_GROUP$3]);
|
|
26283
|
+
result.start.assign("year", year);
|
|
26284
|
+
} else {
|
|
26285
|
+
const year = findYearClosestToRef(context.refDate, 1, month);
|
|
26286
|
+
result.start.imply("year", year);
|
|
26287
|
+
}
|
|
26288
|
+
return result;
|
|
26289
|
+
}
|
|
26290
|
+
};
|
|
26291
|
+
|
|
26292
|
+
//#endregion
|
|
26293
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENYearMonthDayParser.js
|
|
26294
|
+
const PATTERN$10 = new RegExp(`([0-9]{4})[-\\.\\/\\s](?:(${matchAnyPattern(MONTH_DICTIONARY)})|([0-9]{1,2}))[-\\.\\/\\s]([0-9]{1,2})(?=\\W|\$)`, "i");
|
|
26295
|
+
const YEAR_NUMBER_GROUP$1 = 1;
|
|
26296
|
+
const MONTH_NAME_GROUP = 2;
|
|
26297
|
+
const MONTH_NUMBER_GROUP$1 = 3;
|
|
26298
|
+
const DATE_NUMBER_GROUP$1 = 4;
|
|
26299
|
+
var ENYearMonthDayParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
26300
|
+
strictMonthDateOrder;
|
|
26301
|
+
constructor(strictMonthDateOrder) {
|
|
26302
|
+
super();
|
|
26303
|
+
this.strictMonthDateOrder = strictMonthDateOrder;
|
|
26304
|
+
}
|
|
26305
|
+
innerPattern() {
|
|
26306
|
+
return PATTERN$10;
|
|
26307
|
+
}
|
|
26308
|
+
innerExtract(context, match) {
|
|
26309
|
+
const year = parseInt(match[YEAR_NUMBER_GROUP$1]);
|
|
26310
|
+
let day = parseInt(match[DATE_NUMBER_GROUP$1]);
|
|
26311
|
+
let month = match[MONTH_NUMBER_GROUP$1] ? parseInt(match[MONTH_NUMBER_GROUP$1]) : MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
|
26312
|
+
if (month < 1 || month > 12) {
|
|
26313
|
+
if (this.strictMonthDateOrder) return null;
|
|
26314
|
+
if (day >= 1 && day <= 12) [month, day] = [day, month];
|
|
26315
|
+
}
|
|
26316
|
+
if (day < 1 || day > 31) return null;
|
|
26317
|
+
return {
|
|
26318
|
+
day,
|
|
26319
|
+
month,
|
|
26320
|
+
year
|
|
26321
|
+
};
|
|
26322
|
+
}
|
|
26323
|
+
};
|
|
26324
|
+
|
|
26325
|
+
//#endregion
|
|
26326
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENSlashMonthFormatParser.js
|
|
26327
|
+
const PATTERN$9 = new RegExp("([0-9]|0[1-9]|1[012])/([0-9]{4})", "i");
|
|
26328
|
+
const MONTH_GROUP = 1;
|
|
26329
|
+
const YEAR_GROUP$2 = 2;
|
|
26330
|
+
var ENSlashMonthFormatParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
26331
|
+
innerPattern() {
|
|
26332
|
+
return PATTERN$9;
|
|
26333
|
+
}
|
|
26334
|
+
innerExtract(context, match) {
|
|
26335
|
+
const year = parseInt(match[YEAR_GROUP$2]);
|
|
26336
|
+
const month = parseInt(match[MONTH_GROUP]);
|
|
26337
|
+
return context.createParsingComponents().imply("day", 1).assign("month", month).assign("year", year);
|
|
26338
|
+
}
|
|
26339
|
+
};
|
|
26340
|
+
|
|
26341
|
+
//#endregion
|
|
26342
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/parsers/AbstractTimeExpressionParser.js
|
|
26343
|
+
function primaryTimePattern(leftBoundary, primaryPrefix, primarySuffix, flags) {
|
|
26344
|
+
return new RegExp(`${leftBoundary}${primaryPrefix}(\\d{1,4})(?:(?:\\.|:|:)(\\d{1,2})(?:(?::|:)(\\d{2})(?:\\.(\\d{1,6}))?)?)?(?:\\s*(a\\.m\\.|p\\.m\\.|am?|pm?))?${primarySuffix}`, flags);
|
|
26345
|
+
}
|
|
26346
|
+
function followingTimePatten(followingPhase, followingSuffix) {
|
|
26347
|
+
return new RegExp(`^(${followingPhase})(\\d{1,4})(?:(?:\\.|\\:|\\:)(\\d{1,2})(?:(?:\\.|\\:|\\:)(\\d{1,2})(?:\\.(\\d{1,6}))?)?)?(?:\\s*(a\\.m\\.|p\\.m\\.|am?|pm?))?${followingSuffix}`, "i");
|
|
26348
|
+
}
|
|
26349
|
+
const HOUR_GROUP = 2;
|
|
26350
|
+
const MINUTE_GROUP = 3;
|
|
26351
|
+
const SECOND_GROUP = 4;
|
|
26352
|
+
const MILLI_SECOND_GROUP = 5;
|
|
26353
|
+
const AM_PM_HOUR_GROUP = 6;
|
|
26354
|
+
var AbstractTimeExpressionParser = class {
|
|
26355
|
+
strictMode;
|
|
26356
|
+
constructor(strictMode = false) {
|
|
26357
|
+
this.strictMode = strictMode;
|
|
26358
|
+
}
|
|
26359
|
+
patternFlags() {
|
|
26360
|
+
return "i";
|
|
26361
|
+
}
|
|
26362
|
+
primaryPatternLeftBoundary() {
|
|
26363
|
+
return `(^|\\s|T|\\b)`;
|
|
26364
|
+
}
|
|
26365
|
+
primarySuffix() {
|
|
26366
|
+
return `(?!/)(?=\\W|$)`;
|
|
26367
|
+
}
|
|
26368
|
+
followingSuffix() {
|
|
26369
|
+
return `(?!/)(?=\\W|$)`;
|
|
26370
|
+
}
|
|
26371
|
+
pattern(context) {
|
|
26372
|
+
return this.getPrimaryTimePatternThroughCache();
|
|
26373
|
+
}
|
|
26374
|
+
extract(context, match) {
|
|
26375
|
+
const startComponents = this.extractPrimaryTimeComponents(context, match);
|
|
26376
|
+
if (!startComponents) {
|
|
26377
|
+
if (match[0].match(/^\d{4}/)) {
|
|
26378
|
+
match.index += 4;
|
|
26379
|
+
return null;
|
|
26380
|
+
}
|
|
26381
|
+
match.index += match[0].length;
|
|
26382
|
+
return null;
|
|
26383
|
+
}
|
|
26384
|
+
const index = match.index + match[1].length;
|
|
26385
|
+
const text = match[0].substring(match[1].length);
|
|
26386
|
+
const result = context.createParsingResult(index, text, startComponents);
|
|
26387
|
+
match.index += match[0].length;
|
|
26388
|
+
const remainingText = context.text.substring(match.index);
|
|
26389
|
+
const followingMatch = this.getFollowingTimePatternThroughCache().exec(remainingText);
|
|
26390
|
+
if (text.match(/^\d{3,4}/) && followingMatch) {
|
|
26391
|
+
if (followingMatch[0].match(/^\s*([+-])\s*\d{2,4}$/)) return null;
|
|
26392
|
+
if (followingMatch[0].match(/^\s*([+-])\s*\d{2}\W\d{2}/)) return null;
|
|
26393
|
+
}
|
|
26394
|
+
if (!followingMatch || followingMatch[0].match(/^\s*([+-])\s*\d{3,4}$/)) return this.checkAndReturnWithoutFollowingPattern(result);
|
|
26395
|
+
result.end = this.extractFollowingTimeComponents(context, followingMatch, result);
|
|
26396
|
+
if (result.end) result.text += followingMatch[0];
|
|
26397
|
+
return this.checkAndReturnWithFollowingPattern(result);
|
|
26398
|
+
}
|
|
26399
|
+
extractPrimaryTimeComponents(context, match, strict = false) {
|
|
26400
|
+
const components = context.createParsingComponents();
|
|
26401
|
+
let minute = 0;
|
|
26402
|
+
let meridiem = null;
|
|
26403
|
+
let hour = parseInt(match[HOUR_GROUP]);
|
|
26404
|
+
if (hour > 100) {
|
|
26405
|
+
if (match[HOUR_GROUP].length == 4 && match[MINUTE_GROUP] == null && !match[AM_PM_HOUR_GROUP]) return null;
|
|
26406
|
+
if (this.strictMode || match[MINUTE_GROUP] != null) return null;
|
|
26407
|
+
minute = hour % 100;
|
|
26408
|
+
hour = Math.floor(hour / 100);
|
|
26409
|
+
}
|
|
26410
|
+
if (hour > 24) return null;
|
|
26411
|
+
if (match[MINUTE_GROUP] != null) {
|
|
26412
|
+
if (match[MINUTE_GROUP].length == 1 && !match[AM_PM_HOUR_GROUP]) return null;
|
|
26413
|
+
minute = parseInt(match[MINUTE_GROUP]);
|
|
26414
|
+
}
|
|
26415
|
+
if (minute >= 60) return null;
|
|
26416
|
+
if (hour > 12) meridiem = Meridiem.PM;
|
|
26417
|
+
if (match[AM_PM_HOUR_GROUP] != null) {
|
|
26418
|
+
if (hour > 12) return null;
|
|
26419
|
+
const ampm = match[AM_PM_HOUR_GROUP][0].toLowerCase();
|
|
26420
|
+
if (ampm == "a") {
|
|
26421
|
+
meridiem = Meridiem.AM;
|
|
26422
|
+
if (hour == 12) hour = 0;
|
|
26423
|
+
}
|
|
26424
|
+
if (ampm == "p") {
|
|
26425
|
+
meridiem = Meridiem.PM;
|
|
26426
|
+
if (hour != 12) hour += 12;
|
|
26427
|
+
}
|
|
26428
|
+
}
|
|
26429
|
+
components.assign("hour", hour);
|
|
26430
|
+
components.assign("minute", minute);
|
|
26431
|
+
if (meridiem !== null) components.assign("meridiem", meridiem);
|
|
26432
|
+
else if (hour < 12) components.imply("meridiem", Meridiem.AM);
|
|
26433
|
+
else components.imply("meridiem", Meridiem.PM);
|
|
26434
|
+
if (match[MILLI_SECOND_GROUP] != null) {
|
|
26435
|
+
const millisecond = parseInt(match[MILLI_SECOND_GROUP].substring(0, 3));
|
|
26436
|
+
if (millisecond >= 1e3) return null;
|
|
26437
|
+
components.assign("millisecond", millisecond);
|
|
26438
|
+
}
|
|
26439
|
+
if (match[SECOND_GROUP] != null) {
|
|
26440
|
+
const second = parseInt(match[SECOND_GROUP]);
|
|
26441
|
+
if (second >= 60) return null;
|
|
26442
|
+
components.assign("second", second);
|
|
26443
|
+
}
|
|
26444
|
+
return components;
|
|
26445
|
+
}
|
|
26446
|
+
extractFollowingTimeComponents(context, match, result) {
|
|
26447
|
+
const components = context.createParsingComponents();
|
|
26448
|
+
if (match[MILLI_SECOND_GROUP] != null) {
|
|
26449
|
+
const millisecond = parseInt(match[MILLI_SECOND_GROUP].substring(0, 3));
|
|
26450
|
+
if (millisecond >= 1e3) return null;
|
|
26451
|
+
components.assign("millisecond", millisecond);
|
|
26452
|
+
}
|
|
26453
|
+
if (match[SECOND_GROUP] != null) {
|
|
26454
|
+
const second = parseInt(match[SECOND_GROUP]);
|
|
26455
|
+
if (second >= 60) return null;
|
|
26456
|
+
components.assign("second", second);
|
|
26457
|
+
}
|
|
26458
|
+
let hour = parseInt(match[HOUR_GROUP]);
|
|
26459
|
+
let minute = 0;
|
|
26460
|
+
let meridiem = -1;
|
|
26461
|
+
if (match[MINUTE_GROUP] != null) minute = parseInt(match[MINUTE_GROUP]);
|
|
26462
|
+
else if (hour > 100) {
|
|
26463
|
+
minute = hour % 100;
|
|
26464
|
+
hour = Math.floor(hour / 100);
|
|
26465
|
+
}
|
|
26466
|
+
if (minute >= 60 || hour > 24) return null;
|
|
26467
|
+
if (hour >= 12) meridiem = Meridiem.PM;
|
|
26468
|
+
if (match[AM_PM_HOUR_GROUP] != null) {
|
|
26469
|
+
if (hour > 12) return null;
|
|
26470
|
+
const ampm = match[AM_PM_HOUR_GROUP][0].toLowerCase();
|
|
26471
|
+
if (ampm == "a") {
|
|
26472
|
+
meridiem = Meridiem.AM;
|
|
26473
|
+
if (hour == 12) {
|
|
26474
|
+
hour = 0;
|
|
26475
|
+
if (!components.isCertain("day")) components.imply("day", components.get("day") + 1);
|
|
26476
|
+
}
|
|
26477
|
+
}
|
|
26478
|
+
if (ampm == "p") {
|
|
26479
|
+
meridiem = Meridiem.PM;
|
|
26480
|
+
if (hour != 12) hour += 12;
|
|
26481
|
+
}
|
|
26482
|
+
if (!result.start.isCertain("meridiem")) if (meridiem == Meridiem.AM) {
|
|
26483
|
+
result.start.imply("meridiem", Meridiem.AM);
|
|
26484
|
+
if (result.start.get("hour") == 12) result.start.assign("hour", 0);
|
|
26485
|
+
} else {
|
|
26486
|
+
result.start.imply("meridiem", Meridiem.PM);
|
|
26487
|
+
if (result.start.get("hour") != 12) result.start.assign("hour", result.start.get("hour") + 12);
|
|
26488
|
+
}
|
|
26489
|
+
}
|
|
26490
|
+
components.assign("hour", hour);
|
|
26491
|
+
components.assign("minute", minute);
|
|
26492
|
+
if (meridiem >= 0) components.assign("meridiem", meridiem);
|
|
26493
|
+
else if (result.start.isCertain("meridiem") && result.start.get("hour") > 12) {
|
|
26494
|
+
if (result.start.get("hour") - 12 > hour) components.imply("meridiem", Meridiem.AM);
|
|
26495
|
+
else if (hour <= 12) {
|
|
26496
|
+
components.assign("hour", hour + 12);
|
|
26497
|
+
components.assign("meridiem", Meridiem.PM);
|
|
26498
|
+
}
|
|
26499
|
+
} else if (hour > 12) components.imply("meridiem", Meridiem.PM);
|
|
26500
|
+
else if (hour <= 12) components.imply("meridiem", Meridiem.AM);
|
|
26501
|
+
if (components.date().getTime() < result.start.date().getTime()) components.imply("day", components.get("day") + 1);
|
|
26502
|
+
return components;
|
|
26503
|
+
}
|
|
26504
|
+
checkAndReturnWithoutFollowingPattern(result) {
|
|
26505
|
+
if (result.text.match(/^\d$/)) return null;
|
|
26506
|
+
if (result.text.match(/^\d\d\d+$/)) return null;
|
|
26507
|
+
if (result.text.match(/\d[apAP]$/)) return null;
|
|
26508
|
+
const endingWithNumbers = result.text.match(/[^\d:.](\d[\d.]+)$/);
|
|
26509
|
+
if (endingWithNumbers) {
|
|
26510
|
+
const endingNumbers = endingWithNumbers[1];
|
|
26511
|
+
if (this.strictMode) return null;
|
|
26512
|
+
if (endingNumbers.includes(".") && !endingNumbers.match(/\d(\.\d{2})+$/)) return null;
|
|
26513
|
+
if (parseInt(endingNumbers) > 24) return null;
|
|
26514
|
+
}
|
|
26515
|
+
return result;
|
|
26516
|
+
}
|
|
26517
|
+
checkAndReturnWithFollowingPattern(result) {
|
|
26518
|
+
if (result.text.match(/^\d+-\d+$/)) return null;
|
|
26519
|
+
const endingWithNumbers = result.text.match(/[^\d:.](\d[\d.]+)\s*-\s*(\d[\d.]+)$/);
|
|
26520
|
+
if (endingWithNumbers) {
|
|
26521
|
+
if (this.strictMode) return null;
|
|
26522
|
+
const startingNumbers = endingWithNumbers[1];
|
|
26523
|
+
const endingNumbers = endingWithNumbers[2];
|
|
26524
|
+
if (endingNumbers.includes(".") && !endingNumbers.match(/\d(\.\d{2})+$/)) return null;
|
|
26525
|
+
if (parseInt(endingNumbers) > 24 || parseInt(startingNumbers) > 24) return null;
|
|
26526
|
+
}
|
|
26527
|
+
return result;
|
|
26528
|
+
}
|
|
26529
|
+
cachedPrimaryPrefix = null;
|
|
26530
|
+
cachedPrimarySuffix = null;
|
|
26531
|
+
cachedPrimaryTimePattern = null;
|
|
26532
|
+
getPrimaryTimePatternThroughCache() {
|
|
26533
|
+
const primaryPrefix = this.primaryPrefix();
|
|
26534
|
+
const primarySuffix = this.primarySuffix();
|
|
26535
|
+
if (this.cachedPrimaryPrefix === primaryPrefix && this.cachedPrimarySuffix === primarySuffix) return this.cachedPrimaryTimePattern;
|
|
26536
|
+
this.cachedPrimaryTimePattern = primaryTimePattern(this.primaryPatternLeftBoundary(), primaryPrefix, primarySuffix, this.patternFlags());
|
|
26537
|
+
this.cachedPrimaryPrefix = primaryPrefix;
|
|
26538
|
+
this.cachedPrimarySuffix = primarySuffix;
|
|
26539
|
+
return this.cachedPrimaryTimePattern;
|
|
26540
|
+
}
|
|
26541
|
+
cachedFollowingPhase = null;
|
|
26542
|
+
cachedFollowingSuffix = null;
|
|
26543
|
+
cachedFollowingTimePatten = null;
|
|
26544
|
+
getFollowingTimePatternThroughCache() {
|
|
26545
|
+
const followingPhase = this.followingPhase();
|
|
26546
|
+
const followingSuffix = this.followingSuffix();
|
|
26547
|
+
if (this.cachedFollowingPhase === followingPhase && this.cachedFollowingSuffix === followingSuffix) return this.cachedFollowingTimePatten;
|
|
26548
|
+
this.cachedFollowingTimePatten = followingTimePatten(followingPhase, followingSuffix);
|
|
26549
|
+
this.cachedFollowingPhase = followingPhase;
|
|
26550
|
+
this.cachedFollowingSuffix = followingSuffix;
|
|
26551
|
+
return this.cachedFollowingTimePatten;
|
|
26552
|
+
}
|
|
26553
|
+
};
|
|
26554
|
+
|
|
26555
|
+
//#endregion
|
|
26556
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENTimeExpressionParser.js
|
|
26557
|
+
var ENTimeExpressionParser = class extends AbstractTimeExpressionParser {
|
|
26558
|
+
constructor(strictMode) {
|
|
26559
|
+
super(strictMode);
|
|
26560
|
+
}
|
|
26561
|
+
followingPhase() {
|
|
26562
|
+
return "\\s*(?:\\-|\\–|\\~|\\〜|to|until|through|till|\\?)\\s*";
|
|
26563
|
+
}
|
|
26564
|
+
primaryPrefix() {
|
|
26565
|
+
return "(?:(?:at|from)\\s*)??";
|
|
26566
|
+
}
|
|
26567
|
+
primarySuffix() {
|
|
26568
|
+
return "(?:\\s*(?:o\\W*clock|at\\s*night|in\\s*the\\s*(?:morning|afternoon)))?(?!/)(?=\\W|$)";
|
|
26569
|
+
}
|
|
26570
|
+
extractPrimaryTimeComponents(context, match) {
|
|
26571
|
+
const components = super.extractPrimaryTimeComponents(context, match);
|
|
26572
|
+
if (!components) return components;
|
|
26573
|
+
if (match[0].endsWith("night")) {
|
|
26574
|
+
const hour = components.get("hour");
|
|
26575
|
+
if (hour >= 6 && hour < 12) {
|
|
26576
|
+
components.assign("hour", components.get("hour") + 12);
|
|
26577
|
+
components.assign("meridiem", Meridiem.PM);
|
|
26578
|
+
} else if (hour < 6) components.assign("meridiem", Meridiem.AM);
|
|
26579
|
+
}
|
|
26580
|
+
if (match[0].endsWith("afternoon")) {
|
|
26581
|
+
components.assign("meridiem", Meridiem.PM);
|
|
26582
|
+
const hour = components.get("hour");
|
|
26583
|
+
if (hour >= 0 && hour <= 6) components.assign("hour", components.get("hour") + 12);
|
|
26584
|
+
}
|
|
26585
|
+
if (match[0].endsWith("morning")) {
|
|
26586
|
+
components.assign("meridiem", Meridiem.AM);
|
|
26587
|
+
if (components.get("hour") < 12) components.assign("hour", components.get("hour"));
|
|
26588
|
+
}
|
|
26589
|
+
return components.addTag("parser/ENTimeExpressionParser");
|
|
26590
|
+
}
|
|
26591
|
+
extractFollowingTimeComponents(context, match, result) {
|
|
26592
|
+
const followingComponents = super.extractFollowingTimeComponents(context, match, result);
|
|
26593
|
+
if (followingComponents) followingComponents.addTag("parser/ENTimeExpressionParser");
|
|
26594
|
+
return followingComponents;
|
|
26595
|
+
}
|
|
26596
|
+
};
|
|
26597
|
+
|
|
26598
|
+
//#endregion
|
|
26599
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENTimeUnitAgoFormatParser.js
|
|
26600
|
+
const PATTERN$8 = new RegExp(`(${TIME_UNITS_PATTERN})\\s{0,5}(?:ago|before|earlier)(?=\\W|$)`, "i");
|
|
26601
|
+
const STRICT_PATTERN$1 = new RegExp(`(${TIME_UNITS_NO_ABBR_PATTERN})\\s{0,5}(?:ago|before|earlier)(?=\\W|$)`, "i");
|
|
26602
|
+
var ENTimeUnitAgoFormatParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
26603
|
+
strictMode;
|
|
26604
|
+
constructor(strictMode) {
|
|
26605
|
+
super();
|
|
26606
|
+
this.strictMode = strictMode;
|
|
26607
|
+
}
|
|
26608
|
+
innerPattern() {
|
|
26609
|
+
return this.strictMode ? STRICT_PATTERN$1 : PATTERN$8;
|
|
26610
|
+
}
|
|
26611
|
+
innerExtract(context, match) {
|
|
26612
|
+
const duration = parseDuration(match[1]);
|
|
26613
|
+
if (!duration) return null;
|
|
26614
|
+
return ParsingComponents.createRelativeFromReference(context.reference, reverseDuration(duration));
|
|
26615
|
+
}
|
|
26616
|
+
};
|
|
26617
|
+
|
|
26618
|
+
//#endregion
|
|
26619
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENTimeUnitLaterFormatParser.js
|
|
26620
|
+
const PATTERN$7 = new RegExp(`(${TIME_UNITS_PATTERN})\\s{0,5}(?:later|after|from now|henceforth|forward|out)(?=(?:\\W|\$))`, "i");
|
|
26621
|
+
const STRICT_PATTERN = new RegExp(`(${TIME_UNITS_NO_ABBR_PATTERN})\\s{0,5}(later|after|from now)(?=\\W|$)`, "i");
|
|
26622
|
+
const GROUP_NUM_TIMEUNITS = 1;
|
|
26623
|
+
var ENTimeUnitLaterFormatParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
26624
|
+
strictMode;
|
|
26625
|
+
constructor(strictMode) {
|
|
26626
|
+
super();
|
|
26627
|
+
this.strictMode = strictMode;
|
|
26628
|
+
}
|
|
26629
|
+
innerPattern() {
|
|
26630
|
+
return this.strictMode ? STRICT_PATTERN : PATTERN$7;
|
|
26631
|
+
}
|
|
26632
|
+
innerExtract(context, match) {
|
|
26633
|
+
const timeUnits = parseDuration(match[GROUP_NUM_TIMEUNITS]);
|
|
26634
|
+
if (!timeUnits) return null;
|
|
26635
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
26636
|
+
}
|
|
26637
|
+
};
|
|
26638
|
+
|
|
26639
|
+
//#endregion
|
|
26640
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/abstractRefiners.js
|
|
26641
|
+
var Filter = class {
|
|
26642
|
+
refine(context, results) {
|
|
26643
|
+
return results.filter((r) => this.isValid(context, r));
|
|
26644
|
+
}
|
|
26645
|
+
};
|
|
26646
|
+
var MergingRefiner = class {
|
|
26647
|
+
refine(context, results) {
|
|
26648
|
+
if (results.length < 2) return results;
|
|
26649
|
+
const mergedResults = [];
|
|
26650
|
+
let curResult = results[0];
|
|
26651
|
+
let nextResult = null;
|
|
26652
|
+
for (let i = 1; i < results.length; i++) {
|
|
26653
|
+
nextResult = results[i];
|
|
26654
|
+
const textBetween = context.text.substring(curResult.index + curResult.text.length, nextResult.index);
|
|
26655
|
+
if (!this.shouldMergeResults(textBetween, curResult, nextResult, context)) {
|
|
26656
|
+
mergedResults.push(curResult);
|
|
26657
|
+
curResult = nextResult;
|
|
26658
|
+
} else {
|
|
26659
|
+
const left = curResult;
|
|
26660
|
+
const right = nextResult;
|
|
26661
|
+
const mergedResult = this.mergeResults(textBetween, left, right, context);
|
|
26662
|
+
context.debug(() => {
|
|
26663
|
+
console.log(`${this.constructor.name} merged ${left} and ${right} into ${mergedResult}`);
|
|
26664
|
+
});
|
|
26665
|
+
curResult = mergedResult;
|
|
26666
|
+
}
|
|
26667
|
+
}
|
|
26668
|
+
if (curResult != null) mergedResults.push(curResult);
|
|
26669
|
+
return mergedResults;
|
|
26670
|
+
}
|
|
26671
|
+
};
|
|
26672
|
+
|
|
26673
|
+
//#endregion
|
|
26674
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/refiners/AbstractMergeDateRangeRefiner.js
|
|
26675
|
+
var AbstractMergeDateRangeRefiner = class extends MergingRefiner {
|
|
26676
|
+
shouldMergeResults(textBetween, currentResult, nextResult) {
|
|
26677
|
+
return !currentResult.end && !nextResult.end && textBetween.match(this.patternBetween()) != null;
|
|
26678
|
+
}
|
|
26679
|
+
mergeResults(textBetween, fromResult, toResult) {
|
|
26680
|
+
if (!fromResult.start.isOnlyWeekdayComponent() && !toResult.start.isOnlyWeekdayComponent()) {
|
|
26681
|
+
toResult.start.getCertainComponents().forEach((key) => {
|
|
26682
|
+
if (!fromResult.start.isCertain(key)) fromResult.start.imply(key, toResult.start.get(key));
|
|
26683
|
+
});
|
|
26684
|
+
fromResult.start.getCertainComponents().forEach((key) => {
|
|
26685
|
+
if (!toResult.start.isCertain(key)) toResult.start.imply(key, fromResult.start.get(key));
|
|
26686
|
+
});
|
|
26687
|
+
}
|
|
26688
|
+
if (fromResult.start.date() > toResult.start.date()) {
|
|
26689
|
+
let fromDate = fromResult.start.date();
|
|
26690
|
+
let toDate = toResult.start.date();
|
|
26691
|
+
if (toResult.start.isOnlyWeekdayComponent() && addDuration(toDate, { day: 7 }) > fromDate) {
|
|
26692
|
+
toDate = addDuration(toDate, { day: 7 });
|
|
26693
|
+
toResult.start.imply("day", toDate.getDate());
|
|
26694
|
+
toResult.start.imply("month", toDate.getMonth() + 1);
|
|
26695
|
+
toResult.start.imply("year", toDate.getFullYear());
|
|
26696
|
+
} else if (fromResult.start.isOnlyWeekdayComponent() && addDuration(fromDate, { day: -7 }) < toDate) {
|
|
26697
|
+
fromDate = addDuration(fromDate, { day: -7 });
|
|
26698
|
+
fromResult.start.imply("day", fromDate.getDate());
|
|
26699
|
+
fromResult.start.imply("month", fromDate.getMonth() + 1);
|
|
26700
|
+
fromResult.start.imply("year", fromDate.getFullYear());
|
|
26701
|
+
} else if (toResult.start.isDateWithUnknownYear() && addDuration(toDate, { year: 1 }) > fromDate) {
|
|
26702
|
+
toDate = addDuration(toDate, { year: 1 });
|
|
26703
|
+
toResult.start.imply("year", toDate.getFullYear());
|
|
26704
|
+
} else if (fromResult.start.isDateWithUnknownYear() && addDuration(fromDate, { year: -1 }) < toDate) {
|
|
26705
|
+
fromDate = addDuration(fromDate, { year: -1 });
|
|
26706
|
+
fromResult.start.imply("year", fromDate.getFullYear());
|
|
26707
|
+
} else [toResult, fromResult] = [fromResult, toResult];
|
|
26708
|
+
}
|
|
26709
|
+
const result = fromResult.clone();
|
|
26710
|
+
result.start = fromResult.start;
|
|
26711
|
+
result.end = toResult.start;
|
|
26712
|
+
result.index = Math.min(fromResult.index, toResult.index);
|
|
26713
|
+
if (fromResult.index < toResult.index) result.text = fromResult.text + textBetween + toResult.text;
|
|
26714
|
+
else result.text = toResult.text + textBetween + fromResult.text;
|
|
26715
|
+
return result;
|
|
26716
|
+
}
|
|
26717
|
+
};
|
|
26718
|
+
|
|
26719
|
+
//#endregion
|
|
26720
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/refiners/ENMergeDateRangeRefiner.js
|
|
26721
|
+
var ENMergeDateRangeRefiner = class extends AbstractMergeDateRangeRefiner {
|
|
26722
|
+
patternBetween() {
|
|
26723
|
+
return /^\s*(to|-|–|until|through|till)\s*$/i;
|
|
26724
|
+
}
|
|
26725
|
+
};
|
|
26726
|
+
|
|
26727
|
+
//#endregion
|
|
26728
|
+
//#region ../../node_modules/chrono-node/dist/esm/calculation/mergingCalculation.js
|
|
26729
|
+
function mergeDateTimeResult(dateResult, timeResult) {
|
|
26730
|
+
const result = dateResult.clone();
|
|
26731
|
+
const beginDate = dateResult.start;
|
|
26732
|
+
const beginTime = timeResult.start;
|
|
26733
|
+
result.start = mergeDateTimeComponent(beginDate, beginTime);
|
|
26734
|
+
if (dateResult.end != null || timeResult.end != null) {
|
|
26735
|
+
const endDateTime = mergeDateTimeComponent(dateResult.end == null ? dateResult.start : dateResult.end, timeResult.end == null ? timeResult.start : timeResult.end);
|
|
26736
|
+
if (dateResult.end == null && endDateTime.date().getTime() < result.start.date().getTime()) {
|
|
26737
|
+
const nextDay = new Date(endDateTime.date().getTime());
|
|
26738
|
+
nextDay.setDate(nextDay.getDate() + 1);
|
|
26739
|
+
if (endDateTime.isCertain("day")) assignSimilarDate(endDateTime, nextDay);
|
|
26740
|
+
else implySimilarDate(endDateTime, nextDay);
|
|
26741
|
+
}
|
|
26742
|
+
result.end = endDateTime;
|
|
26743
|
+
}
|
|
26744
|
+
return result;
|
|
26745
|
+
}
|
|
26746
|
+
function mergeDateTimeComponent(dateComponent, timeComponent) {
|
|
26747
|
+
const dateTimeComponent = dateComponent.clone();
|
|
26748
|
+
if (timeComponent.isCertain("hour")) {
|
|
26749
|
+
dateTimeComponent.assign("hour", timeComponent.get("hour"));
|
|
26750
|
+
dateTimeComponent.assign("minute", timeComponent.get("minute"));
|
|
26751
|
+
if (timeComponent.isCertain("second")) {
|
|
26752
|
+
dateTimeComponent.assign("second", timeComponent.get("second"));
|
|
26753
|
+
if (timeComponent.isCertain("millisecond")) dateTimeComponent.assign("millisecond", timeComponent.get("millisecond"));
|
|
26754
|
+
else dateTimeComponent.imply("millisecond", timeComponent.get("millisecond"));
|
|
26755
|
+
} else {
|
|
26756
|
+
dateTimeComponent.imply("second", timeComponent.get("second"));
|
|
26757
|
+
dateTimeComponent.imply("millisecond", timeComponent.get("millisecond"));
|
|
26758
|
+
}
|
|
26759
|
+
} else {
|
|
26760
|
+
dateTimeComponent.imply("hour", timeComponent.get("hour"));
|
|
26761
|
+
dateTimeComponent.imply("minute", timeComponent.get("minute"));
|
|
26762
|
+
dateTimeComponent.imply("second", timeComponent.get("second"));
|
|
26763
|
+
dateTimeComponent.imply("millisecond", timeComponent.get("millisecond"));
|
|
26764
|
+
}
|
|
26765
|
+
if (timeComponent.isCertain("timezoneOffset")) dateTimeComponent.assign("timezoneOffset", timeComponent.get("timezoneOffset"));
|
|
26766
|
+
if (timeComponent.isCertain("meridiem")) dateTimeComponent.assign("meridiem", timeComponent.get("meridiem"));
|
|
26767
|
+
else if (timeComponent.get("meridiem") != null && dateTimeComponent.get("meridiem") == null) dateTimeComponent.imply("meridiem", timeComponent.get("meridiem"));
|
|
26768
|
+
if (dateTimeComponent.get("meridiem") == Meridiem.PM && dateTimeComponent.get("hour") < 12) if (timeComponent.isCertain("hour")) dateTimeComponent.assign("hour", dateTimeComponent.get("hour") + 12);
|
|
26769
|
+
else dateTimeComponent.imply("hour", dateTimeComponent.get("hour") + 12);
|
|
26770
|
+
dateTimeComponent.addTags(dateComponent.tags());
|
|
26771
|
+
dateTimeComponent.addTags(timeComponent.tags());
|
|
26772
|
+
return dateTimeComponent;
|
|
26773
|
+
}
|
|
26774
|
+
|
|
26775
|
+
//#endregion
|
|
26776
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/refiners/AbstractMergeDateTimeRefiner.js
|
|
26777
|
+
var AbstractMergeDateTimeRefiner = class extends MergingRefiner {
|
|
26778
|
+
shouldMergeResults(textBetween, currentResult, nextResult) {
|
|
26779
|
+
return (currentResult.start.isOnlyDate() && nextResult.start.isOnlyTime() || nextResult.start.isOnlyDate() && currentResult.start.isOnlyTime()) && textBetween.match(this.patternBetween()) != null;
|
|
26780
|
+
}
|
|
26781
|
+
mergeResults(textBetween, currentResult, nextResult) {
|
|
26782
|
+
const result = currentResult.start.isOnlyDate() ? mergeDateTimeResult(currentResult, nextResult) : mergeDateTimeResult(nextResult, currentResult);
|
|
26783
|
+
result.index = currentResult.index;
|
|
26784
|
+
result.text = currentResult.text + textBetween + nextResult.text;
|
|
26785
|
+
return result;
|
|
26786
|
+
}
|
|
26787
|
+
};
|
|
26788
|
+
|
|
26789
|
+
//#endregion
|
|
26790
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/refiners/ENMergeDateTimeRefiner.js
|
|
26791
|
+
var ENMergeDateTimeRefiner = class extends AbstractMergeDateTimeRefiner {
|
|
26792
|
+
patternBetween() {
|
|
26793
|
+
return /* @__PURE__ */ new RegExp("^\\s*(T|at|after|before|on|of|,|-|\\.|∙|:)?\\s*$");
|
|
26794
|
+
}
|
|
26795
|
+
};
|
|
26796
|
+
|
|
26797
|
+
//#endregion
|
|
26798
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/refiners/ExtractTimezoneAbbrRefiner.js
|
|
26799
|
+
const TIMEZONE_NAME_PATTERN = /* @__PURE__ */ new RegExp("^\\s*,?\\s*\\(?([A-Z]{2,4})\\)?(?=\\W|$)", "i");
|
|
26800
|
+
var ExtractTimezoneAbbrRefiner = class {
|
|
26801
|
+
timezoneOverrides;
|
|
26802
|
+
constructor(timezoneOverrides) {
|
|
26803
|
+
this.timezoneOverrides = timezoneOverrides;
|
|
26804
|
+
}
|
|
26805
|
+
refine(context, results) {
|
|
26806
|
+
const timezoneOverrides = context.option.timezones ?? {};
|
|
26807
|
+
results.forEach((result) => {
|
|
26808
|
+
const suffix = context.text.substring(result.index + result.text.length);
|
|
26809
|
+
const match = TIMEZONE_NAME_PATTERN.exec(suffix);
|
|
26810
|
+
if (!match) return;
|
|
26811
|
+
const timezoneAbbr = match[1].toUpperCase();
|
|
26812
|
+
const extractedTimezoneOffset = toTimezoneOffset(timezoneAbbr, result.start.date() ?? result.refDate ?? /* @__PURE__ */ new Date(), {
|
|
26813
|
+
...this.timezoneOverrides,
|
|
26814
|
+
...timezoneOverrides
|
|
26815
|
+
});
|
|
26816
|
+
if (extractedTimezoneOffset == null) return;
|
|
26817
|
+
context.debug(() => {
|
|
26818
|
+
console.log(`Extracting timezone: '${timezoneAbbr}' into: ${extractedTimezoneOffset} for: ${result.start}`);
|
|
26819
|
+
});
|
|
26820
|
+
const currentTimezoneOffset = result.start.get("timezoneOffset");
|
|
26821
|
+
if (currentTimezoneOffset !== null && extractedTimezoneOffset != currentTimezoneOffset) {
|
|
26822
|
+
if (result.start.isCertain("timezoneOffset")) return;
|
|
26823
|
+
if (timezoneAbbr != match[1]) return;
|
|
26824
|
+
}
|
|
26825
|
+
if (result.start.isOnlyDate()) {
|
|
26826
|
+
if (timezoneAbbr != match[1]) return;
|
|
26827
|
+
}
|
|
26828
|
+
result.text += match[0];
|
|
26829
|
+
if (!result.start.isCertain("timezoneOffset")) result.start.assign("timezoneOffset", extractedTimezoneOffset);
|
|
26830
|
+
if (result.end != null && !result.end.isCertain("timezoneOffset")) result.end.assign("timezoneOffset", extractedTimezoneOffset);
|
|
26831
|
+
});
|
|
26832
|
+
return results;
|
|
26833
|
+
}
|
|
26834
|
+
};
|
|
26835
|
+
|
|
26836
|
+
//#endregion
|
|
26837
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/refiners/ExtractTimezoneOffsetRefiner.js
|
|
26838
|
+
const TIMEZONE_OFFSET_PATTERN = /* @__PURE__ */ new RegExp("^\\s*(?:\\(?(?:GMT|UTC)\\s?)?([+-])(\\d{1,2})(?::?(\\d{2}))?\\)?", "i");
|
|
26839
|
+
const TIMEZONE_OFFSET_SIGN_GROUP = 1;
|
|
26840
|
+
const TIMEZONE_OFFSET_HOUR_OFFSET_GROUP = 2;
|
|
26841
|
+
const TIMEZONE_OFFSET_MINUTE_OFFSET_GROUP = 3;
|
|
26842
|
+
var ExtractTimezoneOffsetRefiner = class {
|
|
26843
|
+
refine(context, results) {
|
|
26844
|
+
results.forEach(function(result) {
|
|
26845
|
+
if (result.start.isCertain("timezoneOffset")) return;
|
|
26846
|
+
const suffix = context.text.substring(result.index + result.text.length);
|
|
26847
|
+
const match = TIMEZONE_OFFSET_PATTERN.exec(suffix);
|
|
26848
|
+
if (!match) return;
|
|
26849
|
+
context.debug(() => {
|
|
26850
|
+
console.log(`Extracting timezone: '${match[0]}' into : ${result}`);
|
|
26851
|
+
});
|
|
26852
|
+
const hourOffset = parseInt(match[TIMEZONE_OFFSET_HOUR_OFFSET_GROUP]);
|
|
26853
|
+
const minuteOffset = parseInt(match[TIMEZONE_OFFSET_MINUTE_OFFSET_GROUP] || "0");
|
|
26854
|
+
let timezoneOffset = hourOffset * 60 + minuteOffset;
|
|
26855
|
+
if (timezoneOffset > 840) return;
|
|
26856
|
+
if (match[TIMEZONE_OFFSET_SIGN_GROUP] === "-") timezoneOffset = -timezoneOffset;
|
|
26857
|
+
if (result.end != null) result.end.assign("timezoneOffset", timezoneOffset);
|
|
26858
|
+
result.start.assign("timezoneOffset", timezoneOffset);
|
|
26859
|
+
result.text += match[0];
|
|
26860
|
+
});
|
|
26861
|
+
return results;
|
|
26862
|
+
}
|
|
26863
|
+
};
|
|
26864
|
+
|
|
26865
|
+
//#endregion
|
|
26866
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/refiners/OverlapRemovalRefiner.js
|
|
26867
|
+
var OverlapRemovalRefiner = class {
|
|
26868
|
+
refine(context, results) {
|
|
26869
|
+
if (results.length < 2) return results;
|
|
26870
|
+
const filteredResults = [];
|
|
26871
|
+
let prevResult = results[0];
|
|
26872
|
+
for (let i = 1; i < results.length; i++) {
|
|
26873
|
+
const result = results[i];
|
|
26874
|
+
if (result.index >= prevResult.index + prevResult.text.length) {
|
|
26875
|
+
filteredResults.push(prevResult);
|
|
26876
|
+
prevResult = result;
|
|
26877
|
+
continue;
|
|
26878
|
+
}
|
|
26879
|
+
let kept = null;
|
|
26880
|
+
let removed = null;
|
|
26881
|
+
if (result.text.length > prevResult.text.length) {
|
|
26882
|
+
kept = result;
|
|
26883
|
+
removed = prevResult;
|
|
26884
|
+
} else {
|
|
26885
|
+
kept = prevResult;
|
|
26886
|
+
removed = result;
|
|
26887
|
+
}
|
|
26888
|
+
context.debug(() => {
|
|
26889
|
+
console.log(`${this.constructor.name} remove ${removed} by ${kept}`);
|
|
26890
|
+
});
|
|
26891
|
+
prevResult = kept;
|
|
26892
|
+
}
|
|
26893
|
+
if (prevResult != null) filteredResults.push(prevResult);
|
|
26894
|
+
return filteredResults;
|
|
26895
|
+
}
|
|
26896
|
+
};
|
|
26897
|
+
|
|
26898
|
+
//#endregion
|
|
26899
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/refiners/ForwardDateRefiner.js
|
|
26900
|
+
var ForwardDateRefiner = class {
|
|
26901
|
+
refine(context, results) {
|
|
26902
|
+
if (!context.option.forwardDate) return results;
|
|
26903
|
+
results.forEach((result) => {
|
|
26904
|
+
let refDate = context.reference.getDateWithAdjustedTimezone();
|
|
26905
|
+
if (result.start.isOnlyTime() && context.reference.instant > result.start.date()) {
|
|
26906
|
+
const refDate = context.reference.getDateWithAdjustedTimezone();
|
|
26907
|
+
const refFollowingDay = new Date(refDate);
|
|
26908
|
+
refFollowingDay.setDate(refFollowingDay.getDate() + 1);
|
|
26909
|
+
implySimilarDate(result.start, refFollowingDay);
|
|
26910
|
+
context.debug(() => {
|
|
26911
|
+
console.log(`${this.constructor.name} adjusted ${result} time from the ref date (${refDate}) to the following day (${refFollowingDay})`);
|
|
26912
|
+
});
|
|
26913
|
+
if (result.end && result.end.isOnlyTime()) {
|
|
26914
|
+
implySimilarDate(result.end, refFollowingDay);
|
|
26915
|
+
if (result.start.date() > result.end.date()) {
|
|
26916
|
+
refFollowingDay.setDate(refFollowingDay.getDate() + 1);
|
|
26917
|
+
implySimilarDate(result.end, refFollowingDay);
|
|
26918
|
+
}
|
|
26919
|
+
}
|
|
26920
|
+
}
|
|
26921
|
+
if (result.start.isOnlyWeekdayComponent() && refDate > result.start.date()) {
|
|
26922
|
+
let daysToAdd = result.start.get("weekday") - refDate.getDay();
|
|
26923
|
+
if (daysToAdd <= 0) daysToAdd += 7;
|
|
26924
|
+
refDate = addDuration(refDate, { day: daysToAdd });
|
|
26925
|
+
implySimilarDate(result.start, refDate);
|
|
26926
|
+
context.debug(() => {
|
|
26927
|
+
console.log(`${this.constructor.name} adjusted ${result} weekday (${result.start})`);
|
|
26928
|
+
});
|
|
26929
|
+
if (result.end && result.end.isOnlyWeekdayComponent()) {
|
|
26930
|
+
let daysToAdd = result.end.get("weekday") - refDate.getDay();
|
|
26931
|
+
if (daysToAdd <= 0) daysToAdd += 7;
|
|
26932
|
+
refDate = addDuration(refDate, { day: daysToAdd });
|
|
26933
|
+
implySimilarDate(result.end, refDate);
|
|
26934
|
+
context.debug(() => {
|
|
26935
|
+
console.log(`${this.constructor.name} adjusted ${result} weekday (${result.end})`);
|
|
26936
|
+
});
|
|
26937
|
+
}
|
|
26938
|
+
}
|
|
26939
|
+
if (result.start.isDateWithUnknownYear() && refDate > result.start.date()) for (let i = 0; i < 3 && refDate > result.start.date(); i++) {
|
|
26940
|
+
result.start.imply("year", result.start.get("year") + 1);
|
|
26941
|
+
context.debug(() => {
|
|
26942
|
+
console.log(`${this.constructor.name} adjusted ${result} year (${result.start})`);
|
|
26943
|
+
});
|
|
26944
|
+
if (result.end && !result.end.isCertain("year")) {
|
|
26945
|
+
result.end.imply("year", result.end.get("year") + 1);
|
|
26946
|
+
context.debug(() => {
|
|
26947
|
+
console.log(`${this.constructor.name} adjusted ${result} month (${result.start})`);
|
|
26948
|
+
});
|
|
26949
|
+
}
|
|
26950
|
+
}
|
|
26951
|
+
});
|
|
26952
|
+
return results;
|
|
26953
|
+
}
|
|
26954
|
+
};
|
|
26955
|
+
|
|
26956
|
+
//#endregion
|
|
26957
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/refiners/UnlikelyFormatFilter.js
|
|
26958
|
+
var UnlikelyFormatFilter = class extends Filter {
|
|
26959
|
+
strictMode;
|
|
26960
|
+
constructor(strictMode) {
|
|
26961
|
+
super();
|
|
26962
|
+
this.strictMode = strictMode;
|
|
26963
|
+
}
|
|
26964
|
+
isValid(context, result) {
|
|
26965
|
+
if (result.text.replace(" ", "").match(/^\d*(\.\d*)?$/)) {
|
|
26966
|
+
context.debug(() => {
|
|
26967
|
+
console.log(`Removing unlikely result '${result.text}'`);
|
|
26968
|
+
});
|
|
26969
|
+
return false;
|
|
26970
|
+
}
|
|
26971
|
+
if (!result.start.isValidDate()) {
|
|
26972
|
+
context.debug(() => {
|
|
26973
|
+
console.log(`Removing invalid result: ${result} (${result.start})`);
|
|
26974
|
+
});
|
|
26975
|
+
return false;
|
|
26976
|
+
}
|
|
26977
|
+
if (result.end && !result.end.isValidDate()) {
|
|
26978
|
+
context.debug(() => {
|
|
26979
|
+
console.log(`Removing invalid result: ${result} (${result.end})`);
|
|
26980
|
+
});
|
|
26981
|
+
return false;
|
|
26982
|
+
}
|
|
26983
|
+
if (this.strictMode) return this.isStrictModeValid(context, result);
|
|
26984
|
+
return true;
|
|
26985
|
+
}
|
|
26986
|
+
isStrictModeValid(context, result) {
|
|
26987
|
+
if (result.start.isOnlyWeekdayComponent()) {
|
|
26988
|
+
context.debug(() => {
|
|
26989
|
+
console.log(`(Strict) Removing weekday only component: ${result} (${result.end})`);
|
|
26990
|
+
});
|
|
26991
|
+
return false;
|
|
26992
|
+
}
|
|
26993
|
+
return true;
|
|
26994
|
+
}
|
|
26995
|
+
};
|
|
26996
|
+
|
|
26997
|
+
//#endregion
|
|
26998
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/parsers/ISOFormatParser.js
|
|
26999
|
+
const PATTERN$6 = new RegExp("([0-9]{4})\\-([0-9]{1,2})\\-([0-9]{1,2})(?:T([0-9]{1,2}):([0-9]{1,2})(?::([0-9]{1,2})(?:\\.(\\d{1,4}))?)?(Z|([+-]\\d{2}):?(\\d{2})?)?)?(?=\\W|$)", "i");
|
|
27000
|
+
const YEAR_NUMBER_GROUP = 1;
|
|
27001
|
+
const MONTH_NUMBER_GROUP = 2;
|
|
27002
|
+
const DATE_NUMBER_GROUP = 3;
|
|
27003
|
+
const HOUR_NUMBER_GROUP = 4;
|
|
27004
|
+
const MINUTE_NUMBER_GROUP = 5;
|
|
27005
|
+
const SECOND_NUMBER_GROUP = 6;
|
|
27006
|
+
const MILLISECOND_NUMBER_GROUP = 7;
|
|
27007
|
+
const TZD_GROUP = 8;
|
|
27008
|
+
const TZD_HOUR_OFFSET_GROUP = 9;
|
|
27009
|
+
const TZD_MINUTE_OFFSET_GROUP = 10;
|
|
27010
|
+
var ISOFormatParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
27011
|
+
innerPattern() {
|
|
27012
|
+
return PATTERN$6;
|
|
27013
|
+
}
|
|
27014
|
+
innerExtract(context, match) {
|
|
27015
|
+
const components = context.createParsingComponents({
|
|
27016
|
+
"year": parseInt(match[YEAR_NUMBER_GROUP]),
|
|
27017
|
+
"month": parseInt(match[MONTH_NUMBER_GROUP]),
|
|
27018
|
+
"day": parseInt(match[DATE_NUMBER_GROUP])
|
|
27019
|
+
});
|
|
27020
|
+
if (match[HOUR_NUMBER_GROUP] != null) {
|
|
27021
|
+
components.assign("hour", parseInt(match[HOUR_NUMBER_GROUP]));
|
|
27022
|
+
components.assign("minute", parseInt(match[MINUTE_NUMBER_GROUP]));
|
|
27023
|
+
if (match[SECOND_NUMBER_GROUP] != null) components.assign("second", parseInt(match[SECOND_NUMBER_GROUP]));
|
|
27024
|
+
if (match[MILLISECOND_NUMBER_GROUP] != null) components.assign("millisecond", parseInt(match[MILLISECOND_NUMBER_GROUP]));
|
|
27025
|
+
if (match[TZD_GROUP] != null) {
|
|
27026
|
+
let offset = 0;
|
|
27027
|
+
if (match[TZD_HOUR_OFFSET_GROUP]) {
|
|
27028
|
+
const hourOffset = parseInt(match[TZD_HOUR_OFFSET_GROUP]);
|
|
27029
|
+
let minuteOffset = 0;
|
|
27030
|
+
if (match[TZD_MINUTE_OFFSET_GROUP] != null) minuteOffset = parseInt(match[TZD_MINUTE_OFFSET_GROUP]);
|
|
27031
|
+
offset = hourOffset * 60;
|
|
27032
|
+
if (offset < 0) offset -= minuteOffset;
|
|
27033
|
+
else offset += minuteOffset;
|
|
27034
|
+
}
|
|
27035
|
+
components.assign("timezoneOffset", offset);
|
|
27036
|
+
}
|
|
27037
|
+
}
|
|
27038
|
+
return components.addTag("parser/ISOFormatParser");
|
|
27039
|
+
}
|
|
27040
|
+
};
|
|
27041
|
+
|
|
27042
|
+
//#endregion
|
|
27043
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/refiners/MergeWeekdayComponentRefiner.js
|
|
27044
|
+
var MergeWeekdayComponentRefiner = class extends MergingRefiner {
|
|
27045
|
+
mergeResults(textBetween, currentResult, nextResult) {
|
|
27046
|
+
const newResult = nextResult.clone();
|
|
27047
|
+
newResult.index = currentResult.index;
|
|
27048
|
+
newResult.text = currentResult.text + textBetween + newResult.text;
|
|
27049
|
+
newResult.start.assign("weekday", currentResult.start.get("weekday"));
|
|
27050
|
+
if (newResult.end) newResult.end.assign("weekday", currentResult.start.get("weekday"));
|
|
27051
|
+
return newResult;
|
|
27052
|
+
}
|
|
27053
|
+
shouldMergeResults(textBetween, currentResult, nextResult) {
|
|
27054
|
+
return currentResult.start.isOnlyWeekdayComponent() && !currentResult.start.isCertain("hour") && nextResult.start.isCertain("day") && textBetween.match(/^,?\s*$/) != null;
|
|
27055
|
+
}
|
|
27056
|
+
};
|
|
27057
|
+
|
|
27058
|
+
//#endregion
|
|
27059
|
+
//#region ../../node_modules/chrono-node/dist/esm/configurations.js
|
|
27060
|
+
function includeCommonConfiguration(configuration, strictMode = false) {
|
|
27061
|
+
configuration.parsers.unshift(new ISOFormatParser());
|
|
27062
|
+
configuration.refiners.unshift(new MergeWeekdayComponentRefiner());
|
|
27063
|
+
configuration.refiners.unshift(new ExtractTimezoneOffsetRefiner());
|
|
27064
|
+
configuration.refiners.unshift(new OverlapRemovalRefiner());
|
|
27065
|
+
configuration.refiners.push(new ExtractTimezoneAbbrRefiner());
|
|
27066
|
+
configuration.refiners.push(new OverlapRemovalRefiner());
|
|
27067
|
+
configuration.refiners.push(new ForwardDateRefiner());
|
|
27068
|
+
configuration.refiners.push(new UnlikelyFormatFilter(strictMode));
|
|
27069
|
+
return configuration;
|
|
27070
|
+
}
|
|
27071
|
+
|
|
27072
|
+
//#endregion
|
|
27073
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/casualReferences.js
|
|
27074
|
+
function now(reference) {
|
|
27075
|
+
const targetDate = reference.getDateWithAdjustedTimezone();
|
|
27076
|
+
const component = new ParsingComponents(reference, {});
|
|
27077
|
+
assignSimilarDate(component, targetDate);
|
|
27078
|
+
assignSimilarTime(component, targetDate);
|
|
27079
|
+
component.assign("timezoneOffset", reference.getTimezoneOffset());
|
|
27080
|
+
component.addTag("casualReference/now");
|
|
27081
|
+
return component;
|
|
27082
|
+
}
|
|
27083
|
+
function today(reference) {
|
|
27084
|
+
const targetDate = reference.getDateWithAdjustedTimezone();
|
|
27085
|
+
const component = new ParsingComponents(reference, {});
|
|
27086
|
+
assignSimilarDate(component, targetDate);
|
|
27087
|
+
implySimilarTime(component, targetDate);
|
|
27088
|
+
component.delete("meridiem");
|
|
27089
|
+
component.addTag("casualReference/today");
|
|
27090
|
+
return component;
|
|
27091
|
+
}
|
|
27092
|
+
function yesterday(reference) {
|
|
27093
|
+
return theDayBefore(reference, 1).addTag("casualReference/yesterday");
|
|
27094
|
+
}
|
|
27095
|
+
function tomorrow(reference) {
|
|
27096
|
+
return theDayAfter(reference, 1).addTag("casualReference/tomorrow");
|
|
27097
|
+
}
|
|
27098
|
+
function theDayBefore(reference, numDay) {
|
|
27099
|
+
return theDayAfter(reference, -numDay);
|
|
27100
|
+
}
|
|
27101
|
+
function theDayAfter(reference, nDays) {
|
|
27102
|
+
const targetDate = reference.getDateWithAdjustedTimezone();
|
|
27103
|
+
const component = new ParsingComponents(reference, {});
|
|
27104
|
+
const newDate = new Date(targetDate.getTime());
|
|
27105
|
+
newDate.setDate(newDate.getDate() + nDays);
|
|
27106
|
+
assignSimilarDate(component, newDate);
|
|
27107
|
+
implySimilarTime(component, newDate);
|
|
27108
|
+
component.delete("meridiem");
|
|
27109
|
+
return component;
|
|
27110
|
+
}
|
|
27111
|
+
function tonight(reference, implyHour = 22) {
|
|
27112
|
+
const targetDate = reference.getDateWithAdjustedTimezone();
|
|
27113
|
+
const component = new ParsingComponents(reference, {});
|
|
27114
|
+
assignSimilarDate(component, targetDate);
|
|
27115
|
+
component.imply("hour", implyHour);
|
|
27116
|
+
component.imply("meridiem", Meridiem.PM);
|
|
27117
|
+
component.addTag("casualReference/tonight");
|
|
27118
|
+
return component;
|
|
27119
|
+
}
|
|
27120
|
+
function evening(reference, implyHour = 20) {
|
|
27121
|
+
const component = new ParsingComponents(reference, {});
|
|
27122
|
+
component.imply("meridiem", Meridiem.PM);
|
|
27123
|
+
component.imply("hour", implyHour);
|
|
27124
|
+
component.addTag("casualReference/evening");
|
|
27125
|
+
return component;
|
|
27126
|
+
}
|
|
27127
|
+
function midnight(reference) {
|
|
27128
|
+
const component = new ParsingComponents(reference, {});
|
|
27129
|
+
if (reference.getDateWithAdjustedTimezone().getHours() > 2) component.addDurationAsImplied({ day: 1 });
|
|
27130
|
+
component.assign("hour", 0);
|
|
27131
|
+
component.imply("minute", 0);
|
|
27132
|
+
component.imply("second", 0);
|
|
27133
|
+
component.imply("millisecond", 0);
|
|
27134
|
+
component.addTag("casualReference/midnight");
|
|
27135
|
+
return component;
|
|
27136
|
+
}
|
|
27137
|
+
function morning(reference, implyHour = 6) {
|
|
27138
|
+
const component = new ParsingComponents(reference, {});
|
|
27139
|
+
component.imply("meridiem", Meridiem.AM);
|
|
27140
|
+
component.imply("hour", implyHour);
|
|
27141
|
+
component.imply("minute", 0);
|
|
27142
|
+
component.imply("second", 0);
|
|
27143
|
+
component.imply("millisecond", 0);
|
|
27144
|
+
component.addTag("casualReference/morning");
|
|
27145
|
+
return component;
|
|
27146
|
+
}
|
|
27147
|
+
function afternoon(reference, implyHour = 15) {
|
|
27148
|
+
const component = new ParsingComponents(reference, {});
|
|
27149
|
+
component.imply("meridiem", Meridiem.PM);
|
|
27150
|
+
component.imply("hour", implyHour);
|
|
27151
|
+
component.imply("minute", 0);
|
|
27152
|
+
component.imply("second", 0);
|
|
27153
|
+
component.imply("millisecond", 0);
|
|
27154
|
+
component.addTag("casualReference/afternoon");
|
|
27155
|
+
return component;
|
|
27156
|
+
}
|
|
27157
|
+
function noon(reference) {
|
|
27158
|
+
const component = new ParsingComponents(reference, {});
|
|
27159
|
+
component.imply("meridiem", Meridiem.AM);
|
|
27160
|
+
component.assign("hour", 12);
|
|
27161
|
+
component.imply("minute", 0);
|
|
27162
|
+
component.imply("second", 0);
|
|
27163
|
+
component.imply("millisecond", 0);
|
|
27164
|
+
component.addTag("casualReference/noon");
|
|
27165
|
+
return component;
|
|
27166
|
+
}
|
|
27167
|
+
|
|
27168
|
+
//#endregion
|
|
27169
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENCasualDateParser.js
|
|
27170
|
+
const PATTERN$5 = /(now|today|tonight|tomorrow|overmorrow|tmr|tmrw|yesterday|last\s*night)(?=\W|$)/i;
|
|
27171
|
+
var ENCasualDateParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
27172
|
+
innerPattern(context) {
|
|
27173
|
+
return PATTERN$5;
|
|
27174
|
+
}
|
|
27175
|
+
innerExtract(context, match) {
|
|
27176
|
+
let targetDate = context.refDate;
|
|
27177
|
+
const lowerText = match[0].toLowerCase();
|
|
27178
|
+
let component = context.createParsingComponents();
|
|
27179
|
+
switch (lowerText) {
|
|
27180
|
+
case "now":
|
|
27181
|
+
component = now(context.reference);
|
|
27182
|
+
break;
|
|
27183
|
+
case "today":
|
|
27184
|
+
component = today(context.reference);
|
|
27185
|
+
break;
|
|
27186
|
+
case "yesterday":
|
|
27187
|
+
component = yesterday(context.reference);
|
|
27188
|
+
break;
|
|
27189
|
+
case "tomorrow":
|
|
27190
|
+
case "tmr":
|
|
27191
|
+
case "tmrw":
|
|
27192
|
+
component = tomorrow(context.reference);
|
|
27193
|
+
break;
|
|
27194
|
+
case "tonight":
|
|
27195
|
+
component = tonight(context.reference);
|
|
27196
|
+
break;
|
|
27197
|
+
case "overmorrow":
|
|
27198
|
+
component = theDayAfter(context.reference, 2);
|
|
27199
|
+
break;
|
|
27200
|
+
default:
|
|
27201
|
+
if (lowerText.match(/last\s*night/)) {
|
|
27202
|
+
if (targetDate.getHours() > 6) {
|
|
27203
|
+
const previousDay = new Date(targetDate.getTime());
|
|
27204
|
+
previousDay.setDate(previousDay.getDate() - 1);
|
|
27205
|
+
targetDate = previousDay;
|
|
27206
|
+
}
|
|
27207
|
+
assignSimilarDate(component, targetDate);
|
|
27208
|
+
component.imply("hour", 0);
|
|
27209
|
+
}
|
|
27210
|
+
break;
|
|
27211
|
+
}
|
|
27212
|
+
component.addTag("parser/ENCasualDateParser");
|
|
27213
|
+
return component;
|
|
27214
|
+
}
|
|
27215
|
+
};
|
|
27216
|
+
|
|
27217
|
+
//#endregion
|
|
27218
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENCasualTimeParser.js
|
|
27219
|
+
const PATTERN$4 = /(?:this)?\s{0,3}(morning|afternoon|evening|night|midnight|midday|noon)(?=\W|$)/i;
|
|
27220
|
+
var ENCasualTimeParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
27221
|
+
innerPattern() {
|
|
27222
|
+
return PATTERN$4;
|
|
27223
|
+
}
|
|
27224
|
+
innerExtract(context, match) {
|
|
27225
|
+
let component = null;
|
|
27226
|
+
switch (match[1].toLowerCase()) {
|
|
27227
|
+
case "afternoon":
|
|
27228
|
+
component = afternoon(context.reference);
|
|
27229
|
+
break;
|
|
27230
|
+
case "evening":
|
|
27231
|
+
case "night":
|
|
27232
|
+
component = evening(context.reference);
|
|
27233
|
+
break;
|
|
27234
|
+
case "midnight":
|
|
27235
|
+
component = midnight(context.reference);
|
|
27236
|
+
break;
|
|
27237
|
+
case "morning":
|
|
27238
|
+
component = morning(context.reference);
|
|
27239
|
+
break;
|
|
27240
|
+
case "noon":
|
|
27241
|
+
case "midday":
|
|
27242
|
+
component = noon(context.reference);
|
|
27243
|
+
break;
|
|
27244
|
+
}
|
|
27245
|
+
if (component) component.addTag("parser/ENCasualTimeParser");
|
|
27246
|
+
return component;
|
|
27247
|
+
}
|
|
27248
|
+
};
|
|
27249
|
+
|
|
27250
|
+
//#endregion
|
|
27251
|
+
//#region ../../node_modules/chrono-node/dist/esm/calculation/weekdays.js
|
|
27252
|
+
function createParsingComponentsAtWeekday(reference, weekday, modifier) {
|
|
27253
|
+
const daysToWeekday = getDaysToWeekday(reference.getDateWithAdjustedTimezone(), weekday, modifier);
|
|
27254
|
+
let components = new ParsingComponents(reference);
|
|
27255
|
+
components = components.addDurationAsImplied({ day: daysToWeekday });
|
|
27256
|
+
components.assign("weekday", weekday);
|
|
27257
|
+
return components;
|
|
27258
|
+
}
|
|
27259
|
+
function getDaysToWeekday(refDate, weekday, modifier) {
|
|
27260
|
+
const refWeekday = refDate.getDay();
|
|
27261
|
+
switch (modifier) {
|
|
27262
|
+
case "this": return getDaysForwardToWeekday(refDate, weekday);
|
|
27263
|
+
case "last": return getBackwardDaysToWeekday(refDate, weekday);
|
|
27264
|
+
case "next":
|
|
27265
|
+
if (refWeekday == Weekday.SUNDAY) return weekday == Weekday.SUNDAY ? 7 : weekday;
|
|
27266
|
+
if (refWeekday == Weekday.SATURDAY) {
|
|
27267
|
+
if (weekday == Weekday.SATURDAY) return 7;
|
|
27268
|
+
if (weekday == Weekday.SUNDAY) return 8;
|
|
27269
|
+
return 1 + weekday;
|
|
27270
|
+
}
|
|
27271
|
+
if (weekday < refWeekday && weekday != Weekday.SUNDAY) return getDaysForwardToWeekday(refDate, weekday);
|
|
27272
|
+
else return getDaysForwardToWeekday(refDate, weekday) + 7;
|
|
27273
|
+
}
|
|
27274
|
+
return getDaysToWeekdayClosest(refDate, weekday);
|
|
27275
|
+
}
|
|
27276
|
+
function getDaysToWeekdayClosest(refDate, weekday) {
|
|
27277
|
+
const backward = getBackwardDaysToWeekday(refDate, weekday);
|
|
27278
|
+
const forward = getDaysForwardToWeekday(refDate, weekday);
|
|
27279
|
+
return forward < -backward ? forward : backward;
|
|
27280
|
+
}
|
|
27281
|
+
function getDaysForwardToWeekday(refDate, weekday) {
|
|
27282
|
+
let forwardCount = weekday - refDate.getDay();
|
|
27283
|
+
if (forwardCount < 0) forwardCount += 7;
|
|
27284
|
+
return forwardCount;
|
|
27285
|
+
}
|
|
27286
|
+
function getBackwardDaysToWeekday(refDate, weekday) {
|
|
27287
|
+
let backwardCount = weekday - refDate.getDay();
|
|
27288
|
+
if (backwardCount >= 0) backwardCount -= 7;
|
|
27289
|
+
return backwardCount;
|
|
27290
|
+
}
|
|
27291
|
+
|
|
27292
|
+
//#endregion
|
|
27293
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENWeekdayParser.js
|
|
27294
|
+
const PATTERN$3 = new RegExp(`(?:(?:\\,|\\(|\\()\\s*)?(?:on\\s*?)?(?:(this|last|past|next)\\s*)?(${matchAnyPattern(WEEKDAY_DICTIONARY)}|weekend|weekday)(?:\\s*(?:\\,|\\)|\\)))?(?:\\s*(this|last|past|next)\\s*week)?(?=\\W|\$)`, "i");
|
|
27295
|
+
const PREFIX_GROUP = 1;
|
|
27296
|
+
const WEEKDAY_GROUP = 2;
|
|
27297
|
+
const POSTFIX_GROUP = 3;
|
|
27298
|
+
var ENWeekdayParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
27299
|
+
innerPattern() {
|
|
27300
|
+
return PATTERN$3;
|
|
27301
|
+
}
|
|
27302
|
+
innerExtract(context, match) {
|
|
27303
|
+
const prefix = match[PREFIX_GROUP];
|
|
27304
|
+
const postfix = match[POSTFIX_GROUP];
|
|
27305
|
+
let modifierWord = prefix || postfix;
|
|
27306
|
+
modifierWord = modifierWord || "";
|
|
27307
|
+
modifierWord = modifierWord.toLowerCase();
|
|
27308
|
+
let modifier = null;
|
|
27309
|
+
if (modifierWord == "last" || modifierWord == "past") modifier = "last";
|
|
27310
|
+
else if (modifierWord == "next") modifier = "next";
|
|
27311
|
+
else if (modifierWord == "this") modifier = "this";
|
|
27312
|
+
const weekday_word = match[WEEKDAY_GROUP].toLowerCase();
|
|
27313
|
+
let weekday;
|
|
27314
|
+
if (WEEKDAY_DICTIONARY[weekday_word] !== void 0) weekday = WEEKDAY_DICTIONARY[weekday_word];
|
|
27315
|
+
else if (weekday_word == "weekend") weekday = modifier == "last" ? Weekday.SUNDAY : Weekday.SATURDAY;
|
|
27316
|
+
else if (weekday_word == "weekday") {
|
|
27317
|
+
const refWeekday = context.reference.getDateWithAdjustedTimezone().getDay();
|
|
27318
|
+
if (refWeekday == Weekday.SUNDAY || refWeekday == Weekday.SATURDAY) weekday = modifier == "last" ? Weekday.FRIDAY : Weekday.MONDAY;
|
|
27319
|
+
else {
|
|
27320
|
+
weekday = refWeekday - 1;
|
|
27321
|
+
weekday = modifier == "last" ? weekday - 1 : weekday + 1;
|
|
27322
|
+
weekday = weekday % 5 + 1;
|
|
27323
|
+
}
|
|
27324
|
+
} else return null;
|
|
27325
|
+
return createParsingComponentsAtWeekday(context.reference, weekday, modifier);
|
|
27326
|
+
}
|
|
27327
|
+
};
|
|
27328
|
+
|
|
27329
|
+
//#endregion
|
|
27330
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENRelativeDateFormatParser.js
|
|
27331
|
+
const PATTERN$2 = new RegExp(`(this|last|past|next|after\\s*this)\\s*(${matchAnyPattern(TIME_UNIT_DICTIONARY)})(?=\\s*)(?=\\W|\$)`, "i");
|
|
27332
|
+
const MODIFIER_WORD_GROUP = 1;
|
|
27333
|
+
const RELATIVE_WORD_GROUP = 2;
|
|
27334
|
+
var ENRelativeDateFormatParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
27335
|
+
innerPattern() {
|
|
27336
|
+
return PATTERN$2;
|
|
27337
|
+
}
|
|
27338
|
+
innerExtract(context, match) {
|
|
27339
|
+
const modifier = match[MODIFIER_WORD_GROUP].toLowerCase();
|
|
27340
|
+
const unitWord = match[RELATIVE_WORD_GROUP].toLowerCase();
|
|
27341
|
+
const timeunit = TIME_UNIT_DICTIONARY[unitWord];
|
|
27342
|
+
if (modifier == "next" || modifier.startsWith("after")) {
|
|
27343
|
+
const timeUnits = {};
|
|
27344
|
+
timeUnits[timeunit] = 1;
|
|
27345
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
27346
|
+
}
|
|
27347
|
+
if (modifier == "last" || modifier == "past") {
|
|
27348
|
+
const timeUnits = {};
|
|
27349
|
+
timeUnits[timeunit] = -1;
|
|
27350
|
+
return ParsingComponents.createRelativeFromReference(context.reference, timeUnits);
|
|
27351
|
+
}
|
|
27352
|
+
const components = context.createParsingComponents();
|
|
27353
|
+
let date = new Date(context.reference.instant.getTime());
|
|
27354
|
+
if (unitWord.match(/week/i)) {
|
|
27355
|
+
date.setDate(date.getDate() - date.getDay());
|
|
27356
|
+
components.imply("day", date.getDate());
|
|
27357
|
+
components.imply("month", date.getMonth() + 1);
|
|
27358
|
+
components.imply("year", date.getFullYear());
|
|
27359
|
+
} else if (unitWord.match(/month/i)) {
|
|
27360
|
+
date.setDate(1);
|
|
27361
|
+
components.imply("day", date.getDate());
|
|
27362
|
+
components.assign("year", date.getFullYear());
|
|
27363
|
+
components.assign("month", date.getMonth() + 1);
|
|
27364
|
+
} else if (unitWord.match(/year/i)) {
|
|
27365
|
+
date.setDate(1);
|
|
27366
|
+
date.setMonth(0);
|
|
27367
|
+
components.imply("day", date.getDate());
|
|
27368
|
+
components.imply("month", date.getMonth() + 1);
|
|
27369
|
+
components.assign("year", date.getFullYear());
|
|
27370
|
+
}
|
|
27371
|
+
return components;
|
|
27372
|
+
}
|
|
27373
|
+
};
|
|
27374
|
+
|
|
27375
|
+
//#endregion
|
|
27376
|
+
//#region ../../node_modules/chrono-node/dist/esm/common/parsers/SlashDateFormatParser.js
|
|
27377
|
+
const PATTERN$1 = new RegExp("([^\\d]|^)([0-3]{0,1}[0-9]{1})[\\/\\.\\-]([0-3]{0,1}[0-9]{1})(?:[\\/\\.\\-]([0-9]{4}|[0-9]{2}))?(\\W|$)", "i");
|
|
27378
|
+
const OPENING_GROUP = 1;
|
|
27379
|
+
const ENDING_GROUP = 5;
|
|
27380
|
+
const FIRST_NUMBERS_GROUP = 2;
|
|
27381
|
+
const SECOND_NUMBERS_GROUP = 3;
|
|
27382
|
+
const YEAR_GROUP$1 = 4;
|
|
27383
|
+
var SlashDateFormatParser = class {
|
|
27384
|
+
groupNumberMonth;
|
|
27385
|
+
groupNumberDay;
|
|
27386
|
+
constructor(littleEndian) {
|
|
27387
|
+
this.groupNumberMonth = littleEndian ? SECOND_NUMBERS_GROUP : FIRST_NUMBERS_GROUP;
|
|
27388
|
+
this.groupNumberDay = littleEndian ? FIRST_NUMBERS_GROUP : SECOND_NUMBERS_GROUP;
|
|
27389
|
+
}
|
|
27390
|
+
pattern() {
|
|
27391
|
+
return PATTERN$1;
|
|
27392
|
+
}
|
|
27393
|
+
extract(context, match) {
|
|
27394
|
+
const index = match.index + match[OPENING_GROUP].length;
|
|
27395
|
+
const indexEnd = match.index + match[0].length - match[ENDING_GROUP].length;
|
|
27396
|
+
if (index > 0) {
|
|
27397
|
+
if (context.text.substring(0, index).match("\\d/?$")) return;
|
|
27398
|
+
}
|
|
27399
|
+
if (indexEnd < context.text.length) {
|
|
27400
|
+
if (context.text.substring(indexEnd).match("^/?\\d")) return;
|
|
27401
|
+
}
|
|
27402
|
+
const text = context.text.substring(index, indexEnd);
|
|
27403
|
+
if (text.match(/^\d\.\d$/) || text.match(/^\d\.\d{1,2}\.\d{1,2}\s*$/)) return;
|
|
27404
|
+
if (!match[YEAR_GROUP$1] && text.indexOf("/") < 0) return;
|
|
27405
|
+
const result = context.createParsingResult(index, text);
|
|
27406
|
+
let month = parseInt(match[this.groupNumberMonth]);
|
|
27407
|
+
let day = parseInt(match[this.groupNumberDay]);
|
|
27408
|
+
if (month < 1 || month > 12) {
|
|
27409
|
+
if (month > 12) if (day >= 1 && day <= 12 && month <= 31) [day, month] = [month, day];
|
|
27410
|
+
else return null;
|
|
27411
|
+
}
|
|
27412
|
+
if (day < 1 || day > 31) return null;
|
|
27413
|
+
result.start.assign("day", day);
|
|
27414
|
+
result.start.assign("month", month);
|
|
27415
|
+
if (match[YEAR_GROUP$1]) {
|
|
27416
|
+
const year = findMostLikelyADYear(parseInt(match[YEAR_GROUP$1]));
|
|
27417
|
+
result.start.assign("year", year);
|
|
27418
|
+
} else {
|
|
27419
|
+
const year = findYearClosestToRef(context.refDate, day, month);
|
|
27420
|
+
result.start.imply("year", year);
|
|
27421
|
+
}
|
|
27422
|
+
return result.addTag("parser/SlashDateFormatParser");
|
|
27423
|
+
}
|
|
27424
|
+
};
|
|
27425
|
+
|
|
27426
|
+
//#endregion
|
|
27427
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js
|
|
27428
|
+
const PATTERN = new RegExp(`(this|last|past|next|after|\\+|-)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
|
|
27429
|
+
const PATTERN_NO_ABBR = new RegExp(`(this|last|past|next|after|\\+|-)\\s*(${TIME_UNITS_NO_ABBR_PATTERN})(?=\\W|$)`, "i");
|
|
27430
|
+
var ENTimeUnitCasualRelativeFormatParser = class extends AbstractParserWithWordBoundaryChecking {
|
|
27431
|
+
allowAbbreviations;
|
|
27432
|
+
constructor(allowAbbreviations = true) {
|
|
27433
|
+
super();
|
|
27434
|
+
this.allowAbbreviations = allowAbbreviations;
|
|
27435
|
+
}
|
|
27436
|
+
innerPattern() {
|
|
27437
|
+
return this.allowAbbreviations ? PATTERN : PATTERN_NO_ABBR;
|
|
27438
|
+
}
|
|
27439
|
+
innerExtract(context, match) {
|
|
27440
|
+
const prefix = match[1].toLowerCase();
|
|
27441
|
+
let duration = parseDuration(match[2]);
|
|
27442
|
+
if (!duration) return null;
|
|
27443
|
+
switch (prefix) {
|
|
27444
|
+
case "last":
|
|
27445
|
+
case "past":
|
|
27446
|
+
case "-":
|
|
27447
|
+
duration = reverseDuration(duration);
|
|
27448
|
+
break;
|
|
27449
|
+
}
|
|
27450
|
+
return ParsingComponents.createRelativeFromReference(context.reference, duration);
|
|
27451
|
+
}
|
|
27452
|
+
};
|
|
27453
|
+
|
|
27454
|
+
//#endregion
|
|
27455
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/refiners/ENMergeRelativeAfterDateRefiner.js
|
|
27456
|
+
function IsPositiveFollowingReference(result) {
|
|
27457
|
+
return result.text.match(/^[+-]/i) != null;
|
|
27458
|
+
}
|
|
27459
|
+
function IsNegativeFollowingReference(result) {
|
|
27460
|
+
return result.text.match(/^-/i) != null;
|
|
27461
|
+
}
|
|
27462
|
+
var ENMergeRelativeAfterDateRefiner = class extends MergingRefiner {
|
|
27463
|
+
shouldMergeResults(textBetween, currentResult, nextResult) {
|
|
27464
|
+
if (!textBetween.match(/^\s*$/i)) return false;
|
|
27465
|
+
return IsPositiveFollowingReference(nextResult) || IsNegativeFollowingReference(nextResult);
|
|
27466
|
+
}
|
|
27467
|
+
mergeResults(textBetween, currentResult, nextResult, context) {
|
|
27468
|
+
let timeUnits = parseDuration(nextResult.text);
|
|
27469
|
+
if (IsNegativeFollowingReference(nextResult)) timeUnits = reverseDuration(timeUnits);
|
|
27470
|
+
const components = ParsingComponents.createRelativeFromReference(ReferenceWithTimezone.fromDate(currentResult.start.date()), timeUnits);
|
|
27471
|
+
return new ParsingResult(currentResult.reference, currentResult.index, `${currentResult.text}${textBetween}${nextResult.text}`, components);
|
|
27472
|
+
}
|
|
27473
|
+
};
|
|
27474
|
+
|
|
27475
|
+
//#endregion
|
|
27476
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/refiners/ENMergeRelativeFollowByDateRefiner.js
|
|
27477
|
+
function hasImpliedEarlierReferenceDate(result) {
|
|
27478
|
+
return result.text.match(/\s+(before|from)$/i) != null;
|
|
27479
|
+
}
|
|
27480
|
+
function hasImpliedLaterReferenceDate(result) {
|
|
27481
|
+
return result.text.match(/\s+(after|since)$/i) != null;
|
|
27482
|
+
}
|
|
27483
|
+
var ENMergeRelativeFollowByDateRefiner = class extends MergingRefiner {
|
|
27484
|
+
patternBetween() {
|
|
27485
|
+
return /^\s*$/i;
|
|
27486
|
+
}
|
|
27487
|
+
shouldMergeResults(textBetween, currentResult, nextResult) {
|
|
27488
|
+
if (!textBetween.match(this.patternBetween())) return false;
|
|
27489
|
+
if (!hasImpliedEarlierReferenceDate(currentResult) && !hasImpliedLaterReferenceDate(currentResult)) return false;
|
|
27490
|
+
return !!nextResult.start.get("day") && !!nextResult.start.get("month") && !!nextResult.start.get("year");
|
|
27491
|
+
}
|
|
27492
|
+
mergeResults(textBetween, currentResult, nextResult) {
|
|
27493
|
+
let duration = parseDuration(currentResult.text);
|
|
27494
|
+
if (hasImpliedEarlierReferenceDate(currentResult)) duration = reverseDuration(duration);
|
|
27495
|
+
const components = ParsingComponents.createRelativeFromReference(ReferenceWithTimezone.fromDate(nextResult.start.date()), duration);
|
|
27496
|
+
return new ParsingResult(nextResult.reference, currentResult.index, `${currentResult.text}${textBetween}${nextResult.text}`, components);
|
|
27497
|
+
}
|
|
27498
|
+
};
|
|
27499
|
+
|
|
27500
|
+
//#endregion
|
|
27501
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/refiners/ENExtractYearSuffixRefiner.js
|
|
27502
|
+
const YEAR_SUFFIX_PATTERN = new RegExp(`^\\s*(${YEAR_PATTERN})`, "i");
|
|
27503
|
+
const YEAR_GROUP = 1;
|
|
27504
|
+
var ENExtractYearSuffixRefiner = class {
|
|
27505
|
+
refine(context, results) {
|
|
27506
|
+
results.forEach(function(result) {
|
|
27507
|
+
if (!result.start.isDateWithUnknownYear()) return;
|
|
27508
|
+
const suffix = context.text.substring(result.index + result.text.length);
|
|
27509
|
+
const match = YEAR_SUFFIX_PATTERN.exec(suffix);
|
|
27510
|
+
if (!match) return;
|
|
27511
|
+
if (match[0].trim().length <= 3) return;
|
|
27512
|
+
context.debug(() => {
|
|
27513
|
+
console.log(`Extracting year: '${match[0]}' into : ${result}`);
|
|
27514
|
+
});
|
|
27515
|
+
const year = parseYear(match[YEAR_GROUP]);
|
|
27516
|
+
if (result.end != null) result.end.assign("year", year);
|
|
27517
|
+
result.start.assign("year", year);
|
|
27518
|
+
result.text += match[0];
|
|
27519
|
+
});
|
|
27520
|
+
return results;
|
|
27521
|
+
}
|
|
27522
|
+
};
|
|
27523
|
+
|
|
27524
|
+
//#endregion
|
|
27525
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/refiners/ENUnlikelyFormatFilter.js
|
|
27526
|
+
var ENUnlikelyFormatFilter = class extends Filter {
|
|
27527
|
+
constructor() {
|
|
27528
|
+
super();
|
|
27529
|
+
}
|
|
27530
|
+
isValid(context, result) {
|
|
27531
|
+
const text = result.text.trim();
|
|
27532
|
+
if (text === context.text.trim()) return true;
|
|
27533
|
+
if (text.toLowerCase() === "may") {
|
|
27534
|
+
if (!context.text.substring(0, result.index).trim().match(/\b(in)$/i)) {
|
|
27535
|
+
context.debug(() => {
|
|
27536
|
+
console.log(`Removing unlikely result: ${result}`);
|
|
27537
|
+
});
|
|
27538
|
+
return false;
|
|
27539
|
+
}
|
|
27540
|
+
}
|
|
27541
|
+
if (text.toLowerCase().endsWith("the second")) {
|
|
27542
|
+
if (context.text.substring(result.index + result.text.length).trim().length > 0) context.debug(() => {
|
|
27543
|
+
console.log(`Removing unlikely result: ${result}`);
|
|
27544
|
+
});
|
|
27545
|
+
return false;
|
|
27546
|
+
}
|
|
27547
|
+
return true;
|
|
27548
|
+
}
|
|
27549
|
+
};
|
|
27550
|
+
|
|
27551
|
+
//#endregion
|
|
27552
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/configuration.js
|
|
27553
|
+
var ENDefaultConfiguration = class {
|
|
27554
|
+
createCasualConfiguration(littleEndian = false) {
|
|
27555
|
+
const option = this.createConfiguration(false, littleEndian);
|
|
27556
|
+
option.parsers.push(new ENCasualDateParser());
|
|
27557
|
+
option.parsers.push(new ENCasualTimeParser());
|
|
27558
|
+
option.parsers.push(new ENMonthNameParser());
|
|
27559
|
+
option.parsers.push(new ENRelativeDateFormatParser());
|
|
27560
|
+
option.parsers.push(new ENTimeUnitCasualRelativeFormatParser());
|
|
27561
|
+
option.refiners.push(new ENUnlikelyFormatFilter());
|
|
27562
|
+
return option;
|
|
27563
|
+
}
|
|
27564
|
+
createConfiguration(strictMode = true, littleEndian = false) {
|
|
27565
|
+
const options = includeCommonConfiguration({
|
|
27566
|
+
parsers: [
|
|
27567
|
+
new SlashDateFormatParser(littleEndian),
|
|
27568
|
+
new ENTimeUnitWithinFormatParser(strictMode),
|
|
27569
|
+
new ENMonthNameLittleEndianParser(),
|
|
27570
|
+
new ENMonthNameMiddleEndianParser(littleEndian),
|
|
27571
|
+
new ENWeekdayParser(),
|
|
27572
|
+
new ENSlashMonthFormatParser(),
|
|
27573
|
+
new ENTimeExpressionParser(strictMode),
|
|
27574
|
+
new ENTimeUnitAgoFormatParser(strictMode),
|
|
27575
|
+
new ENTimeUnitLaterFormatParser(strictMode)
|
|
27576
|
+
],
|
|
27577
|
+
refiners: [new ENMergeDateTimeRefiner()]
|
|
27578
|
+
}, strictMode);
|
|
27579
|
+
options.parsers.unshift(new ENYearMonthDayParser(strictMode));
|
|
27580
|
+
options.refiners.unshift(new ENMergeRelativeFollowByDateRefiner());
|
|
27581
|
+
options.refiners.unshift(new ENMergeRelativeAfterDateRefiner());
|
|
27582
|
+
options.refiners.unshift(new OverlapRemovalRefiner());
|
|
27583
|
+
options.refiners.push(new ENMergeDateTimeRefiner());
|
|
27584
|
+
options.refiners.push(new ENExtractYearSuffixRefiner());
|
|
27585
|
+
options.refiners.push(new ENMergeDateRangeRefiner());
|
|
27586
|
+
return options;
|
|
27587
|
+
}
|
|
27588
|
+
};
|
|
27589
|
+
|
|
27590
|
+
//#endregion
|
|
27591
|
+
//#region ../../node_modules/chrono-node/dist/esm/chrono.js
|
|
27592
|
+
var Chrono = class Chrono {
|
|
27593
|
+
parsers;
|
|
27594
|
+
refiners;
|
|
27595
|
+
defaultConfig = new ENDefaultConfiguration();
|
|
27596
|
+
constructor(configuration) {
|
|
27597
|
+
configuration = configuration || this.defaultConfig.createCasualConfiguration();
|
|
27598
|
+
this.parsers = [...configuration.parsers];
|
|
27599
|
+
this.refiners = [...configuration.refiners];
|
|
27600
|
+
}
|
|
27601
|
+
clone() {
|
|
27602
|
+
return new Chrono({
|
|
27603
|
+
parsers: [...this.parsers],
|
|
27604
|
+
refiners: [...this.refiners]
|
|
27605
|
+
});
|
|
27606
|
+
}
|
|
27607
|
+
parseDate(text, referenceDate, option) {
|
|
27608
|
+
const results = this.parse(text, referenceDate, option);
|
|
27609
|
+
return results.length > 0 ? results[0].start.date() : null;
|
|
27610
|
+
}
|
|
27611
|
+
parse(text, referenceDate, option) {
|
|
27612
|
+
const context = new ParsingContext(text, referenceDate, option);
|
|
27613
|
+
let results = [];
|
|
27614
|
+
this.parsers.forEach((parser) => {
|
|
27615
|
+
const parsedResults = Chrono.executeParser(context, parser);
|
|
27616
|
+
results = results.concat(parsedResults);
|
|
27617
|
+
});
|
|
27618
|
+
results.sort((a, b) => {
|
|
27619
|
+
return a.index - b.index;
|
|
27620
|
+
});
|
|
27621
|
+
this.refiners.forEach(function(refiner) {
|
|
27622
|
+
results = refiner.refine(context, results);
|
|
27623
|
+
});
|
|
27624
|
+
return results;
|
|
27625
|
+
}
|
|
27626
|
+
static executeParser(context, parser) {
|
|
27627
|
+
const results = [];
|
|
27628
|
+
const pattern = parser.pattern(context);
|
|
27629
|
+
const originalText = context.text;
|
|
27630
|
+
let remainingText = context.text;
|
|
27631
|
+
let match = pattern.exec(remainingText);
|
|
27632
|
+
while (match) {
|
|
27633
|
+
const index = match.index + originalText.length - remainingText.length;
|
|
27634
|
+
match.index = index;
|
|
27635
|
+
const result = parser.extract(context, match);
|
|
27636
|
+
if (!result) {
|
|
27637
|
+
remainingText = originalText.substring(match.index + 1);
|
|
27638
|
+
match = pattern.exec(remainingText);
|
|
27639
|
+
continue;
|
|
27640
|
+
}
|
|
27641
|
+
let parsedResult = null;
|
|
27642
|
+
if (result instanceof ParsingResult) parsedResult = result;
|
|
27643
|
+
else if (result instanceof ParsingComponents) {
|
|
27644
|
+
parsedResult = context.createParsingResult(match.index, match[0]);
|
|
27645
|
+
parsedResult.start = result;
|
|
27646
|
+
} else parsedResult = context.createParsingResult(match.index, match[0], result);
|
|
27647
|
+
const parsedIndex = parsedResult.index;
|
|
27648
|
+
const parsedText = parsedResult.text;
|
|
27649
|
+
context.debug(() => console.log(`${parser.constructor.name} extracted (at index=${parsedIndex}) '${parsedText}'`));
|
|
27650
|
+
results.push(parsedResult);
|
|
27651
|
+
remainingText = originalText.substring(parsedIndex + parsedText.length);
|
|
27652
|
+
match = pattern.exec(remainingText);
|
|
27653
|
+
}
|
|
27654
|
+
return results;
|
|
27655
|
+
}
|
|
27656
|
+
};
|
|
27657
|
+
var ParsingContext = class {
|
|
27658
|
+
text;
|
|
27659
|
+
option;
|
|
27660
|
+
reference;
|
|
27661
|
+
refDate;
|
|
27662
|
+
constructor(text, refDate, option) {
|
|
27663
|
+
this.text = text;
|
|
27664
|
+
this.option = option ?? {};
|
|
27665
|
+
this.reference = ReferenceWithTimezone.fromInput(refDate, this.option.timezones);
|
|
27666
|
+
this.refDate = this.reference.instant;
|
|
27667
|
+
}
|
|
27668
|
+
createParsingComponents(components) {
|
|
27669
|
+
if (components instanceof ParsingComponents) return components;
|
|
27670
|
+
return new ParsingComponents(this.reference, components);
|
|
27671
|
+
}
|
|
27672
|
+
createParsingResult(index, textOrEndIndex, startComponents, endComponents) {
|
|
27673
|
+
const text = typeof textOrEndIndex === "string" ? textOrEndIndex : this.text.substring(index, textOrEndIndex);
|
|
27674
|
+
const start = startComponents ? this.createParsingComponents(startComponents) : null;
|
|
27675
|
+
const end = endComponents ? this.createParsingComponents(endComponents) : null;
|
|
27676
|
+
return new ParsingResult(this.reference, index, text, start, end);
|
|
27677
|
+
}
|
|
27678
|
+
debug(block) {
|
|
27679
|
+
if (this.option.debug) if (this.option.debug instanceof Function) this.option.debug(block);
|
|
27680
|
+
else this.option.debug.debug(block);
|
|
27681
|
+
}
|
|
27682
|
+
};
|
|
27683
|
+
|
|
27684
|
+
//#endregion
|
|
27685
|
+
//#region ../../node_modules/chrono-node/dist/esm/locales/en/index.js
|
|
27686
|
+
const configuration = new ENDefaultConfiguration();
|
|
27687
|
+
const casual$1 = new Chrono(configuration.createCasualConfiguration(false));
|
|
27688
|
+
const strict$1 = new Chrono(configuration.createConfiguration(true, false));
|
|
27689
|
+
const GB = new Chrono(configuration.createCasualConfiguration(true));
|
|
27690
|
+
|
|
27691
|
+
//#endregion
|
|
27692
|
+
//#region ../../node_modules/chrono-node/dist/esm/index.js
|
|
27693
|
+
const strict = strict$1;
|
|
27694
|
+
const casual = casual$1;
|
|
27695
|
+
function parseDate(text, ref, option) {
|
|
27696
|
+
return casual.parseDate(text, ref, option);
|
|
27697
|
+
}
|
|
27698
|
+
|
|
27699
|
+
//#endregion
|
|
27700
|
+
//#region ../../core/data-resolver/src/evaluators/date-evaluator.ts
|
|
27701
|
+
/**
|
|
27702
|
+
* DateEvaluator: Parses and formats dates using chrono-node.
|
|
27703
|
+
*
|
|
27704
|
+
* Syntax:
|
|
27705
|
+
* {{date:tomorrow|iso}}
|
|
27706
|
+
* {{date: next friday >> dd-mm-yyyy}}
|
|
27707
|
+
* {{date: random 3 months >> yyyy-MM-ddT09:30:00}}
|
|
27708
|
+
* {{date: random}} — random date in next 30 days, ISO output
|
|
27709
|
+
*
|
|
27710
|
+
* Format tokens: yyyy/YYYY, MM (month), dd/DD. Non-token chars are literal.
|
|
27711
|
+
* "iso" format → full ISO 8601 string.
|
|
27712
|
+
*/
|
|
27713
|
+
var DateEvaluator = class {
|
|
27714
|
+
prefix = "date";
|
|
27715
|
+
async evaluate(expression, _scopeValues) {
|
|
27716
|
+
const separatorMatch = expression.match(/^(.*?)\s*(?:>>|\|)\s*(.+)$/);
|
|
27717
|
+
let dateExpr;
|
|
27718
|
+
let format;
|
|
27719
|
+
if (separatorMatch) {
|
|
27720
|
+
dateExpr = separatorMatch[1].trim();
|
|
27721
|
+
format = separatorMatch[2].trim();
|
|
27722
|
+
} else {
|
|
27723
|
+
dateExpr = expression.trim();
|
|
27724
|
+
format = "iso";
|
|
27725
|
+
}
|
|
27726
|
+
const date = this.parseDate(dateExpr);
|
|
27727
|
+
if (!date) throw new Error(`DateEvaluator: could not parse date expression "${dateExpr}"`);
|
|
27728
|
+
return this.formatDate(date, format);
|
|
27729
|
+
}
|
|
27730
|
+
parseDate(expr) {
|
|
27731
|
+
const now = /* @__PURE__ */ new Date();
|
|
27732
|
+
if (expr.toLowerCase().startsWith("random")) {
|
|
27733
|
+
const rest = expr.slice(6).trim();
|
|
27734
|
+
const upperBound = rest ? parseDate(`in ${rest}`, now, { forwardDate: true }) ?? new Date(now.getTime() + 720 * 60 * 60 * 1e3) : new Date(now.getTime() + 720 * 60 * 60 * 1e3);
|
|
27735
|
+
return new Date(now.getTime() + Math.random() * (upperBound.getTime() - now.getTime()));
|
|
27736
|
+
}
|
|
27737
|
+
return parseDate(expr, now, { forwardDate: true });
|
|
27738
|
+
}
|
|
27739
|
+
formatDate(date, format) {
|
|
27740
|
+
if (format === "iso") return date.toISOString();
|
|
27741
|
+
const yyyy = date.getFullYear().toString();
|
|
27742
|
+
const MM = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
27743
|
+
const dd = date.getDate().toString().padStart(2, "0");
|
|
27744
|
+
return format.replace(/yyyy/gi, yyyy).replace(/MM/gi, MM).replace(/dd/gi, dd);
|
|
27745
|
+
}
|
|
27746
|
+
};
|
|
27747
|
+
|
|
27748
|
+
//#endregion
|
|
27749
|
+
//#region ../../core/bvt-agent/src/agent/data-resolver.preprocessor.ts
|
|
27750
|
+
function createDataResolverPreprocessor(resolver) {
|
|
27751
|
+
return async (command, context) => {
|
|
27752
|
+
if (!context.resolutionContext) return command;
|
|
27753
|
+
if (command.type === "custom" && typeof command.code === "string" && !command.code.includes("{{")) {
|
|
27754
|
+
const { code, ...rest } = command;
|
|
27755
|
+
return {
|
|
27756
|
+
...await resolver.resolveObject(rest, context.resolutionContext),
|
|
27757
|
+
code
|
|
27758
|
+
};
|
|
27759
|
+
}
|
|
27760
|
+
if (command.type === "custom.code" && typeof command.code === "string") {
|
|
27761
|
+
const { code, ...rest } = command;
|
|
27762
|
+
return {
|
|
27763
|
+
...await resolver.resolveObject(rest, context.resolutionContext),
|
|
27764
|
+
code
|
|
27765
|
+
};
|
|
27766
|
+
}
|
|
27767
|
+
return resolver.resolveObject(command, context.resolutionContext);
|
|
27768
|
+
};
|
|
27769
|
+
}
|
|
27770
|
+
|
|
27771
|
+
//#endregion
|
|
27772
|
+
//#region ../../core/bvt-agent/src/agent/ai-chat-code-token.preprocessor.ts
|
|
27773
|
+
var UnknownKeyError = class extends Error {
|
|
27774
|
+
constructor(key) {
|
|
27775
|
+
super(`Unknown test-data key in ai-chat generated code: ${key}`);
|
|
27776
|
+
this.key = key;
|
|
27777
|
+
this.name = "UnknownKeyError";
|
|
27778
|
+
}
|
|
27779
|
+
toString() {
|
|
27780
|
+
return `${this.name}: ${this.message}`;
|
|
27781
|
+
}
|
|
27782
|
+
};
|
|
27783
|
+
function scanJsContext(source) {
|
|
27784
|
+
const stateAt = Array.from({ length: source.length });
|
|
27785
|
+
const stringLiterals = [];
|
|
25066
27786
|
const commentRanges = [];
|
|
25067
27787
|
const stack = [];
|
|
25068
27788
|
let i = 0;
|
|
@@ -25535,6 +28255,63 @@ function toMatcherValue(value) {
|
|
|
25535
28255
|
default: throw new Error(`Invalid matcher value: unknown type "${value.type}"`);
|
|
25536
28256
|
}
|
|
25537
28257
|
}
|
|
28258
|
+
var BlinqApiRuntime = class {
|
|
28259
|
+
last;
|
|
28260
|
+
constructor(testDataApi) {
|
|
28261
|
+
this.testDataApi = testDataApi;
|
|
28262
|
+
}
|
|
28263
|
+
get lastResponse() {
|
|
28264
|
+
return this.last;
|
|
28265
|
+
}
|
|
28266
|
+
async request(request) {
|
|
28267
|
+
const response = await executeApiRequest(request);
|
|
28268
|
+
this.last = response;
|
|
28269
|
+
if (request.saveAs) await this.testDataApi.setRuntime(request.saveAs, serializeApiResponseForRuntime(response), { dataType: "string" });
|
|
28270
|
+
return response;
|
|
28271
|
+
}
|
|
28272
|
+
async assert(assertion) {
|
|
28273
|
+
if (!this.last) throw new Error("API assertion requires a previous API request command in the same step.");
|
|
28274
|
+
assertApiResponse(this.last, assertion);
|
|
28275
|
+
}
|
|
28276
|
+
};
|
|
28277
|
+
const AI_CHAT_COMMAND_DELAY_MS = 1e3;
|
|
28278
|
+
/**
|
|
28279
|
+
* Build the AI-chat command globals. Mirrors the recorder sandbox:
|
|
28280
|
+
* `onCommandStart` waits the watch-delay then records the command boundary,
|
|
28281
|
+
* `onCommandPass` waits the (overridable) watch-delay, and `checkpoint`
|
|
28282
|
+
* records a labelled marker. In a standalone Playwright run the sandbox's
|
|
28283
|
+
* live-timeline bridge is replaced by Playwright test annotations (via the
|
|
28284
|
+
* injected `annotate` callback).
|
|
28285
|
+
*/
|
|
28286
|
+
function createAiChatGlobals(input) {
|
|
28287
|
+
const { testDataApi, parameters, annotate } = input;
|
|
28288
|
+
return {
|
|
28289
|
+
context: {
|
|
28290
|
+
testData: testDataApi,
|
|
28291
|
+
...parameters.projectId ? { projectId: parameters.projectId } : {},
|
|
28292
|
+
...parameters.environmentId ? { environmentId: parameters.environmentId } : {},
|
|
28293
|
+
...parameters.featureId ? { featureId: parameters.featureId } : {},
|
|
28294
|
+
...parameters.scenarioId ? { scenarioId: parameters.scenarioId } : {},
|
|
28295
|
+
...parameters.executionId ? { executionId: parameters.executionId } : {}
|
|
28296
|
+
},
|
|
28297
|
+
checkpoint(label, data) {
|
|
28298
|
+
annotate({
|
|
28299
|
+
type: "blinq:checkpoint",
|
|
28300
|
+
description: data === void 0 ? label : `${label} ${JSON.stringify(data)}`
|
|
28301
|
+
});
|
|
28302
|
+
},
|
|
28303
|
+
async onCommandStart(label) {
|
|
28304
|
+
await sleep(AI_CHAT_COMMAND_DELAY_MS);
|
|
28305
|
+
annotate({
|
|
28306
|
+
type: "blinq:command-start",
|
|
28307
|
+
description: label
|
|
28308
|
+
});
|
|
28309
|
+
},
|
|
28310
|
+
async onCommandPass(opts) {
|
|
28311
|
+
await sleep(opts && typeof opts.delayMs === "number" && opts.delayMs >= 0 ? opts.delayMs : AI_CHAT_COMMAND_DELAY_MS);
|
|
28312
|
+
}
|
|
28313
|
+
};
|
|
28314
|
+
}
|
|
25538
28315
|
const DEFAULT_PROJECT_ID = "01K00000000000000000000000";
|
|
25539
28316
|
const BLINQ_ENVIRONMENT_ENV_VAR = "BLINQ_ENVIRONMENT";
|
|
25540
28317
|
function toFilePath(target) {
|
|
@@ -25690,6 +28467,7 @@ var PlaywrightRunner = class {
|
|
|
25690
28467
|
scopeManager;
|
|
25691
28468
|
preprocessors;
|
|
25692
28469
|
resolutionContext;
|
|
28470
|
+
apiRuntime;
|
|
25693
28471
|
constructor(options = {}, dependencies = {}) {
|
|
25694
28472
|
this.parameters = options.parameters ?? {};
|
|
25695
28473
|
this.resolutionContext = createResolutionContext(this.parameters);
|
|
@@ -25731,6 +28509,20 @@ var PlaywrightRunner = class {
|
|
|
25731
28509
|
detach() {
|
|
25732
28510
|
this.activePage = null;
|
|
25733
28511
|
}
|
|
28512
|
+
/**
|
|
28513
|
+
* Stateful API helper for `api.action` / `api.assertion` steps. Lazily built
|
|
28514
|
+
* and held for the runner's lifetime so a request and its following assertion
|
|
28515
|
+
* share `lastResponse`. Throws if no test-data provider/context is available
|
|
28516
|
+
* (the `saveAs` path needs it).
|
|
28517
|
+
*/
|
|
28518
|
+
get api() {
|
|
28519
|
+
if (!this.apiRuntime) {
|
|
28520
|
+
const testDataApi = this.tester.testDataApi;
|
|
28521
|
+
if (!testDataApi) throw new Error("bvt.api is unavailable: the runner has no test-data provider/context. API steps require a configured test-data layer.");
|
|
28522
|
+
this.apiRuntime = new BlinqApiRuntime(testDataApi);
|
|
28523
|
+
}
|
|
28524
|
+
return this.apiRuntime;
|
|
28525
|
+
}
|
|
25734
28526
|
async executeCommand(command, parameters = {}) {
|
|
25735
28527
|
if (!this.activePage) throw new Error("PlaywrightRunner has no active page. Call attach(page) before executeCommand.");
|
|
25736
28528
|
this.runtimeContext = {
|
|
@@ -25881,11 +28673,21 @@ function createBlinqTest(options = {}) {
|
|
|
25881
28673
|
runner.attach(page);
|
|
25882
28674
|
const testDataApi = runner.tester.testDataApi;
|
|
25883
28675
|
if (!testDataApi) throw new Error("bvt.testDataApi is unavailable: the runner has no test-data provider/context. Extract steps require a configured test-data layer.");
|
|
28676
|
+
const aiChat = createAiChatGlobals({
|
|
28677
|
+
testDataApi,
|
|
28678
|
+
parameters: runner.parameters,
|
|
28679
|
+
annotate: (annotation) => testInfo.annotations.push(annotation)
|
|
28680
|
+
});
|
|
25884
28681
|
try {
|
|
25885
28682
|
await use({
|
|
25886
28683
|
page,
|
|
25887
28684
|
parameters: runner.parameters,
|
|
25888
28685
|
testDataApi,
|
|
28686
|
+
api: runner.api,
|
|
28687
|
+
aiChatContext: aiChat.context,
|
|
28688
|
+
checkpoint: aiChat.checkpoint,
|
|
28689
|
+
onCommandStart: aiChat.onCommandStart,
|
|
28690
|
+
onCommandPass: aiChat.onCommandPass,
|
|
25889
28691
|
executeCommand: (command, stepParameters) => runner.executeCommand(command, stepParameters),
|
|
25890
28692
|
resolveCommand: (command, stepParameters) => runner.resolveCommand(command, stepParameters),
|
|
25891
28693
|
find: (command) => runner.find(command),
|
|
@@ -25903,5 +28705,5 @@ function createBlinqTest(options = {}) {
|
|
|
25903
28705
|
}
|
|
25904
28706
|
|
|
25905
28707
|
//#endregion
|
|
25906
|
-
export { PlaywrightRunner, TempFileTestDataProvider, createBlinqTest, createBlinqTest as default, toMatcherValue };
|
|
28708
|
+
export { PlaywrightRunner, TempFileTestDataProvider, createAiChatGlobals, createBlinqTest, createBlinqTest as default, toMatcherValue };
|
|
25907
28709
|
//# sourceMappingURL=index.mjs.map
|