import type { Applog, ApplogValue, DatalogQueryPattern, DatalogQueryResultEntry, ResultContext, SearchContext, ValueOrMatcher } from './datom-types.ts'; export declare const isoDateStrCompare: (strA: string, strB: string, dir?: "asc" | "desc") => number; export declare const objEqualByKeys: (keys: string[], objA: object, objB: object) => boolean; /** * Deep equality for an `ApplogValue`. `vl` can now hold JSON objects/arrays, so a bare * `===` would treat structurally-identical objects as different. `isEqual` short-circuits * on referential identity internally, so primitives stay on the cheap path. */ export declare const valueEq: (a: ApplogValue, b: ApplogValue) => boolean; /** Canonical, hashable Map key for an `ApplogValue` (see {@link valueKey}). */ export type ValueKey = string | number | boolean | null; /** * Canonical key for using an `ApplogValue` as a Map key. Primitives pass through unchanged * (so primitive-keyed lookups are identity-stable); objects/arrays are stably stringified * (key-sorted) behind a `\0obj:` sentinel so an object value can't collide with a string * value that happens to equal its serialization. */ export declare const valueKey: (vl: ApplogValue) => ValueKey; /** Transitive total-order comparator over (ts, cid). Safe for `Array.sort`. */ export declare const compareApplogsByTs: (logA: Applog, logB: Applog, dir?: "asc" | "desc") => number; export declare const compareApplogsByEnAt: (objA: object, objB: object) => boolean; /** * Pairwise: is `a` strictly later than `b` per (ts, pv-chain, cid)? * * NOT TRANSITIVE. Use only for two-log decisions (e.g. lastWriteWins replacement * check). Do NOT pass to `Array.sort` — it can produce cycles at 3+ chain links * and break the engine's sort. */ export declare function isLaterByTsAndPv(a: Applog, b: Applog): boolean; /** * Sort applogs in chain-aware order (modifies array, also returns for chaining). * * Two-phase: * 1. Transitive `(ts, cid)` `Array.sort` — fast, total-order, common case. * 2. For each contiguous same-ts cluster (rare), chain-stabilize via `pv` * so chain-tail logs land last (asc) / first (desc) within their (en, at) * sub-group. Cross-group order within a cluster stays cid-lex. * * No-tie inputs pay only one linear scan past `Array.sort`. */ export declare function sortApplogsByTs(appLogArray: Applog[], dir?: 'asc' | 'desc'): Applog[]; export declare const isTsBefore: (log: Applog, logToCompare: Applog) => boolean; export declare const uniqueEnFromAppLogs: (appLogArray: Applog[]) => string[]; export declare const areApplogsEqual: (logA: Applog, logB: Applog) => boolean; export type RemoveDuplicateAppLogsMode = 'safety' | 'cleanup'; /** * Deduplicate applogs by CID. * - safety: fast duplicate check; returns original array if no duplicates found. * - cleanup: optimized for merged arrays with likely duplicates. */ export declare const removeDuplicateAppLogs: (appLogArray: Applog[], mode?: RemoveDuplicateAppLogsMode) => Applog[]; export declare const getHashID: (stringifiable: any, lngth?: number) => string; export declare function isVariable(x: any): x is string; export declare function variableNameWithoutQuestionmark(str: string): string; export declare function isStaticPattern(x: any): x is ApplogValue; export declare function resolveOrRemoveVariables(pattern: DatalogQueryPattern, candidate: SearchContext): readonly [Partial>, Partial<{ cid: string; pv: string; ts: import("./datom-types.ts").Timestamp; ag: string; en: import("./datom-types.ts").EntityID; at: import("./datom-types.ts").Attribute; vl: string; }>]; export declare function matchPartStatic(field: keyof Applog, patternPart: ValueOrMatcher, atomPart: ApplogValue): boolean; export declare function matchPart(patternPart: ValueOrMatcher, atomPart: ApplogValue, context: SearchContext): ResultContext; /** * Check if pattern matches triple with context substitutions */ export declare function matchPattern(pattern: DatalogQueryPattern, applog: Applog, context: SearchContext): ResultContext; export declare function actualize; export declare const arrStats: { max: (array: number[]) => number; min: (array: number[]) => number; range: (array: number[]) => number; midrange: (array: number[]) => number; sum: (array: number[]) => number; mean: (array: number[]) => number; average: (array: number[]) => number; median: (array: number[]) => number; modes: (array: number[]) => any[]; variance: (array: number[]) => number; standardDeviation: (array: number[]) => number; meanAbsoluteDeviation: (array: number[]) => number; zScores: (array: number[]) => number[]; }; export declare const tsNearlySame: (timeA: string, timeB: string) => boolean; export declare const cyrb53hash: (str: string, seed: number, strLength: number) => string; export declare function arraysContainSameElements(arr1: any, arr2: any): boolean; export declare function dateNowIso(): string; //# sourceMappingURL=applog-utils.d.ts.map