{"version":3,"file":"snapshot-selector-formatter.d.ts","sourceRoot":"","sources":["../../src/core/snapshot-selector-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAmC,KAAK,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE3G,MAAM,WAAW,qBAAqB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,kBAAkB,CAAC;CAC/B;AAED,MAAM,WAAW,yBAAyB;IACzC,gBAAgB,EAAE,qBAAqB,CAAC;IACxC,cAAc,EAAE,qBAAqB,CAAC;IACtC,mBAAmB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;CAC5C;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,SAAkC,GAAG,MAAM,CAE9G;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,SAAkC,GAAG,MAAM,CAEjH;AAED,wBAAgB,mCAAmC,CAAC,aAAa,SAAkC,GAAG,MAAM,CAE3G;AAED,wBAAgB,qCAAqC,CAAC,aAAa,SAAkC,GAAG,MAAM,EAAE,CAM/G;AAED,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,SAAS,qBAAqB,EAAE,EACxC,aAAa,SAAkC,GAC7C,MAAM,EAAE,CAwBV;AAED,wBAAgB,uCAAuC,CACtD,MAAM,EAAE,SAAS,qBAAqB,EAAE,EACxC,aAAa,SAAkC,GAC7C,MAAM,EAAE,CAcV;AAED,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,yBAAyB,EAClC,aAAa,SAAkC,GAC7C,MAAM,EAAE,CAYV;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,EAAE,CAUrF","sourcesContent":["import type { MemoryHistorySnapshot } from \"./memory.js\";\nimport { MEMORY_SNAPSHOT_SHORT_ID_LENGTH, type SnapshotResolution } from \"./snapshot-selector-resolver.js\";\n\nexport interface SnapshotSelectorIssue {\n\tlabel: string;\n\tresolution: SnapshotResolution;\n}\n\nexport interface SnapshotDiffHeaderContext {\n\tbaselineSnapshot: MemoryHistorySnapshot;\n\ttargetSnapshot: MemoryHistorySnapshot;\n\tgetRelativeAgeLabel: (date: Date) => string;\n}\n\nexport function formatSnapshotShortId(entryId: string, shortIdLength = MEMORY_SNAPSHOT_SHORT_ID_LENGTH): string {\n\treturn `[${entryId.slice(0, shortIdLength)}]`;\n}\n\nexport function formatResolvedSnapshotId(entryId: string, shortIdLength = MEMORY_SNAPSHOT_SHORT_ID_LENGTH): string {\n\treturn `${formatSnapshotShortId(entryId, shortIdLength)} ${entryId}`;\n}\n\nexport function formatSnapshotSelectorAcceptedForms(shortIdLength = MEMORY_SNAPSHOT_SHORT_ID_LENGTH): string {\n\treturn `Accepted forms: full entryId, short ID (${shortIdLength} chars), or strict unique prefix. Brackets are optional.`;\n}\n\nexport function formatSnapshotSelectorHistoryGuidance(shortIdLength = MEMORY_SNAPSHOT_SHORT_ID_LENGTH): string[] {\n\treturn [\n\t\t\"Use /memory diff <baselineId> <targetId> to compare any two snapshots.\",\n\t\t`IDs shown in brackets (${formatSnapshotShortId(\"x\".repeat(shortIdLength), shortIdLength)}) can be copied directly; brackets are optional.`,\n\t\t`Accepted: full entryId, ${shortIdLength}-char short ID, or strict unique prefix.`,\n\t];\n}\n\nexport function formatSnapshotSelectorIssues(\n\tissues: readonly SnapshotSelectorIssue[],\n\tshortIdLength = MEMORY_SNAPSHOT_SHORT_ID_LENGTH,\n): string[] {\n\tconst lines: string[] = [];\n\n\tfor (const issue of issues) {\n\t\tconst { label, resolution } = issue;\n\t\tif (resolution.error === \"empty\") {\n\t\t\tlines.push(`${label} selector is empty.`);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (resolution.error === \"not_found\") {\n\t\t\tlines.push(`${label} ID not found: ${resolution.matchedInput}`);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (resolution.error === \"ambiguous\") {\n\t\t\tlines.push(`${label} ID is ambiguous: ${resolution.matchedInput}`);\n\t\t\tfor (const candidate of resolution.candidates) {\n\t\t\t\tlines.push(`  ${formatResolvedSnapshotId(candidate, shortIdLength)}`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lines;\n}\n\nexport function formatSnapshotSelectorResolutionFailure(\n\tissues: readonly SnapshotSelectorIssue[],\n\tshortIdLength = MEMORY_SNAPSHOT_SHORT_ID_LENGTH,\n): string[] {\n\tconst detailLines = formatSnapshotSelectorIssues(issues, shortIdLength);\n\tif (detailLines.length === 0) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\t\"Snapshot resolution failed in current branch history.\",\n\t\t\"\",\n\t\t...detailLines,\n\t\t\"\",\n\t\t\"Run /memory history to see available snapshot IDs (shown in brackets after each age label).\",\n\t\tformatSnapshotSelectorAcceptedForms(shortIdLength),\n\t];\n}\n\nexport function formatExplicitDiffHeader(\n\tcontext: SnapshotDiffHeaderContext,\n\tshortIdLength = MEMORY_SNAPSHOT_SHORT_ID_LENGTH,\n): string[] {\n\tconst baselineDate = new Date(context.baselineSnapshot.recordedAt);\n\tconst targetDate = new Date(context.targetSnapshot.recordedAt);\n\n\treturn [\n\t\t`Baseline: ${context.getRelativeAgeLabel(baselineDate)} — ${baselineDate.toLocaleString()}`,\n\t\t`        ID: ${formatResolvedSnapshotId(context.baselineSnapshot.entryId, shortIdLength)}`,\n\t\t`Target:   ${context.getRelativeAgeLabel(targetDate)} — ${targetDate.toLocaleString()}`,\n\t\t`        ID: ${formatResolvedSnapshotId(context.targetSnapshot.entryId, shortIdLength)}`,\n\t\t\"(snapshot comparison · not an event log)\",\n\t\t\"\",\n\t];\n}\n\nexport function formatAdjacentDiffHeader(context: SnapshotDiffHeaderContext): string[] {\n\tconst baselineDate = new Date(context.baselineSnapshot.recordedAt);\n\tconst targetDate = new Date(context.targetSnapshot.recordedAt);\n\n\treturn [\n\t\t`Comparing: ${context.getRelativeAgeLabel(baselineDate)} → ${context.getRelativeAgeLabel(targetDate)}`,\n\t\t`${baselineDate.toLocaleString()} → ${targetDate.toLocaleString()}`,\n\t\t\"(snapshot comparison · not an event log)\",\n\t\t\"\",\n\t];\n}\n"]}