@knpkv/rly 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +90 -3
  2. package/dist/{Dialog-B9Ub_gMT.js → Dialog-CU66FqWD.js} +325 -257
  3. package/dist/Dialog-CU66FqWD.js.map +1 -0
  4. package/dist/{PortalProvider-CN_81Fy3.js → PortalProvider-op07u8na.js} +20 -18
  5. package/dist/PortalProvider-op07u8na.js.map +1 -0
  6. package/dist/components.css +2 -2
  7. package/dist/diff/bounded/index.js.map +1 -1
  8. package/dist/diff/index.js.map +1 -1
  9. package/dist/diff/patch/index.js.map +1 -1
  10. package/dist/dts/foundations/Icon.d.ts +1 -1
  11. package/dist/dts/foundations/Icon.d.ts.map +1 -1
  12. package/dist/dts/internal/composedFocus.d.ts +11 -0
  13. package/dist/dts/internal/composedFocus.d.ts.map +1 -0
  14. package/dist/dts/internal/relaySummon.d.ts +50 -0
  15. package/dist/dts/internal/relaySummon.d.ts.map +1 -0
  16. package/dist/dts/patterns/RelayComposer.d.ts +65 -0
  17. package/dist/dts/patterns/RelayComposer.d.ts.map +1 -0
  18. package/dist/dts/patterns/RelayDecision.d.ts +75 -0
  19. package/dist/dts/patterns/RelayDecision.d.ts.map +1 -0
  20. package/dist/dts/patterns/RelayDock.d.ts.map +1 -1
  21. package/dist/dts/patterns/RelayFindings.d.ts +83 -0
  22. package/dist/dts/patterns/RelayFindings.d.ts.map +1 -0
  23. package/dist/dts/patterns/RelayLauncher.d.ts +32 -1
  24. package/dist/dts/patterns/RelayLauncher.d.ts.map +1 -1
  25. package/dist/dts/patterns/RelayPanel.d.ts +91 -0
  26. package/dist/dts/patterns/RelayPanel.d.ts.map +1 -0
  27. package/dist/dts/patterns/RelaySetup.d.ts +58 -0
  28. package/dist/dts/patterns/RelaySetup.d.ts.map +1 -0
  29. package/dist/dts/patterns/RelayTranscript.d.ts +68 -0
  30. package/dist/dts/patterns/RelayTranscript.d.ts.map +1 -0
  31. package/dist/dts/patterns/index.d.ts +14 -2
  32. package/dist/dts/patterns/index.d.ts.map +1 -1
  33. package/dist/dts/tokens/fonts.d.ts +13 -0
  34. package/dist/dts/tokens/fonts.d.ts.map +1 -0
  35. package/dist/dts/tokens/index.d.ts +2 -0
  36. package/dist/dts/tokens/index.d.ts.map +1 -1
  37. package/dist/fonts.css +7 -2
  38. package/dist/foundations/index.js +1 -1
  39. package/dist/index.js +6 -6
  40. package/dist/patterns/index.js +2 -2
  41. package/dist/patterns-B3WbiVEp.js +4981 -0
  42. package/dist/patterns-B3WbiVEp.js.map +1 -0
  43. package/dist/primitives/index.js +3 -3
  44. package/dist/{primitives-Bd6WhE78.js → primitives-DgQybTyq.js} +254 -322
  45. package/dist/primitives-DgQybTyq.js.map +1 -0
  46. package/dist/tokens/index.js +2 -2
  47. package/dist/{tokens-B075JP3Z.js → tokens-Cf0jXIRg.js} +14 -8
  48. package/dist/tokens-Cf0jXIRg.js.map +1 -0
  49. package/dist/workbench-CHCnYW3G.js.map +1 -1
  50. package/package.json +1 -1
  51. package/registry/components.json +558 -1
  52. package/registry/search.json +162 -0
  53. package/dist/Dialog-B9Ub_gMT.js.map +0 -1
  54. package/dist/PortalProvider-CN_81Fy3.js.map +0 -1
  55. package/dist/patterns-ChmGSFqO.js +0 -3768
  56. package/dist/patterns-ChmGSFqO.js.map +0 -1
  57. package/dist/primitives-Bd6WhE78.js.map +0 -1
  58. package/dist/tokens-B075JP3Z.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["code","styles","GIT_DIFF_FILE_BREAK_REGEX","FILENAME_HEADER_REGEX","INDEX_LINE_METADATA","getHunkSideStartBoundary","start","count","getHunkSideEndBoundary","CACHE_KEY_VERSION","composeCacheKey","segments","scope","cleanLastNewline","end","contents","stringDetachEncoder","stringDetachDecoder","SURROGATE_CODE_UNIT_PATTERN","STRING_DETACH_INITIAL_BUFFER_SIZE","stringDetachBuffer","releaseStringDetachBuffer","detachString","value","requiredByteLength","written","filenameDecoder","NAMED_ESCAPES","parseQuotedDiffFileName","input","fileName","index","char","escaped","bytes","byte","readOctalByte","first","second","third","MAX_ALIGNMENT_COMPARISONS","MIN_IMPROVEMENT_PER_PAIR","realignChangeContentBySimilarity","hunk","diff","content","replacement","realignChangeBlock","pairCount","deletions","additions","surplus","strippedDeletions","line","stripWhitespace","deletionLineIndex","strippedAdditions","additionLineIndex","additionsAreLonger","bestOffset","bestScore","offset","score","pair","lineSimilarity","blocks","pushBlock","blockDeletions","blockAdditions","blockDeletionIndex","blockAdditionIndex","WHITESPACE","a","b","maxLength","minLength","prefix","suffix","GIT_DIFF_HEADER_FILENAMES","processFile","_processFile","fileDiffString","options","lastHunkEnd","hunks","splitAtLinePrefix","currentFile","isPartial","oldFile","newFile","lines","splitWithNewlines","firstLine","throwOnError","fileHeader","parseHunkHeader","additionLines","deletionLines","splitFileContents","maybeDetachOptionalString","cacheKey","filenameMatch","prevName","decodeDiffFileName","name","type","rawFileName","isGitDiff","detachedFileName","prevObjectId","newObjectId","mode","currentContent","lastLineType","deletionStart","additionStart","hunkData","parsedAdditionLines","parsedDeletionLines","lineIndex","rawLine","isFormatPatchVersionSeparator","firstChar","parseRawLineType","getParsedLineContent","createContentGroup","lastIndex","repairedAdditionStart","repairedDeletionStart","additionStartDelta","deletionStartDelta","lastHunk","totalFileLines","collapsedAfter","rawName","stripGitPrefix","startIndex","newlineIndex","isHunkBodyLine","deletionStartResult","readPositiveInteger","deletionCount","deletionCountResult","additionStartResult","additionCount","additionCountResult","hunkContext","contextStartIndex","trimLineEnd","parsedValue","digit","newlinePrefix","firstBoundaryIndex","findLinePrefixIndex","parts","nextBoundaryIndex","fromIndex","processedLine","Diff","callback","oldString","oldStr","newString","newStr","oldTokens","newTokens","done","newLen","oldLen","editLength","maxEditLength","maxExecutionTime","abortAfterTimestamp","bestPath","newPos","minDiagonalToConsider","maxDiagonalToConsider","execEditLength","diagonalPath","basePath","removePath","addPath","canAdd","addPathNewPos","canRemove","exec","ret","last","path","added","removed","oldPosInc","oldPos","commonCount","left","right","i","array","chars","changeObjects","components","nextComponent","lastComponent","componentLen","componentPos","component","oldValue","longestCommonPrefix","str1","str2","longestCommonSuffix","replacePrefix","string","oldPrefix","newPrefix","replaceSuffix","oldSuffix","newSuffix","removePrefix","removeSuffix","maximumOverlap","string2","overlapCount","string1","startA","endB","map","k","j","segment","segmentObj","segmenter","trailingWs","leadingAndTrailingWs","leadingWs","match","firstSeg","lastSeg","extendedWordChars","tokenizeIncludingWhitespace","tokens","prevPart","part","token","changes","lastKeep","insertion","deletion","change","dedupeWhitespaceInChangeObjects","oldWsPrefix","oldWsSuffix","newWsPrefix","newWsSuffix","startKeep","commonWsPrefix","endKeep","commonWsSuffix","ws","newWsFull","delWsStart","delWsEnd","newWsStart","newWsEnd","endKeepWsPrefix","overlap","regex","lineDiff","tokenize","diffLines","retLines","linesAndNewlines","isSentenceEndPunct","result","tokenStartI","v","undefinedReplacement","canonicalize","stringifyReplacer","replacer","key","obj","stack","replacementStack","canonicalizedObj","sortedKeys","needsQuoting","s","quoteFileNameIfNeeded","INCLUDE_HEADERS","structuredPatch","optionsObj","context","patch","diffLinesResultToPatch","contextLines","entry","oldRangeStart","newRangeStart","curRange","oldLine","newLine","current","splitLines","prev","contextSize","formatPatch","headerOptions","p","gitOldName","gitNewName","hasHunks","oldStart","newStart","createTwoFilesPatch","oldFileName","newFileName","oldHeader","newHeader","patchObj","hasTrailingNl","text","MISSING_FILE_NAME","parseDiffFromFile","resolvedOldFile","createMissingFile","resolvedNewFile","fileData","oldCacheKey","newCacheKey","language","cssClass","sheet","useNarrowerThan","narrow","setNarrow","useState","useCallback","element","measure","measured","width","view","observer","renderedDiffLine","root","container","sideContainer","location","contextLine","pierreLine","item","annotationNode","focusLine","DiffCodeAnnotation","annotationRef","useRef","restoreLineFocus","returnFocus","annotation","createElement","event","requireDiffCodeAnnotations","ids","annotations","BoundedDiffCodeView_module_default","boundedAnnotationLocation","contentAt","hunkLabel","parseItem","contextSplitRows","changeSplitRows","splitRows","unifiedRows","code","wrap","itemId","alternate","lineNumber","side","focusBoundedLine","annotationsAt","splitAnnotationRows","row","renderSplit","Fragment","unifiedAnnotationRows","renderUnified","BoundedDiffCodeView","rootRef","measureRef","attachRoot","shown","initialItems","empty","className"],"sources":["../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/constants.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/getHunkSideBoundaries.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/composeCacheKey.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/cleanLastNewline.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/detachString.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/parseQuotedDiffFileName.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/realignChangeContent.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/parsePatchFiles.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/base.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/character.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/util/string.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/word.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/line.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/sentence.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/css.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/json.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/array.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/patch/create.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/parseDiffFromFile.js","../../../src/internal/component.ts","../../../src/internal/useNarrowerThan.ts","../../../src/diff/rendered-line.ts","../../../src/diff/annotation.ts","../../../src/diff/bounded/BoundedDiffCodeView.module.css","../../../src/diff/bounded/BoundedDiffCodeView.tsx"],"sourcesContent":["//#region src/constants.ts\nconst DIFFS_TAG_NAME = \"diffs-container\";\nconst DIFFS_DEVELOPMENT_BUILD = (() => {\n\ttry {\n\t\treturn process.env.NODE_ENV === \"development\";\n\t} catch {\n\t\treturn false;\n\t}\n})();\nconst COMMIT_METADATA_SPLIT = /(?=^From [a-f0-9]+ .+$)/m;\nconst GIT_DIFF_FILE_BREAK_REGEX = /(?=^diff --git)/gm;\nconst UNIFIED_DIFF_FILE_BREAK_REGEX = /(?=^---\\s+\\S)/gm;\nconst FILE_CONTEXT_BLOB = /(?=^@@ )/gm;\nconst HUNK_HEADER = /^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(?: (.*))?/m;\nconst SPLIT_WITH_NEWLINES = /(?<=\\n)/;\nconst FILENAME_HEADER_REGEX = /^(---|\\+\\+\\+)\\s+([^\\t\\r\\n]+)/;\nconst INDEX_LINE_METADATA = /^index ([0-9a-f]+)\\.\\.([0-9a-f]+)(?: (\\d+))?$/i;\nconst MERGE_CONFLICT_START_MARKER_REGEX = /^<{7,}(?:\\s.*)?$/;\nconst MERGE_CONFLICT_BASE_MARKER_REGEX = /^\\|{7,}(?:\\s.*)?$/;\nconst MERGE_CONFLICT_SEPARATOR_MARKER_REGEX = /^={7,}$/;\nconst MERGE_CONFLICT_END_MARKER_REGEX = /^>{7,}(?:\\s.*)?$/;\nconst HEADER_PREFIX_SLOT_ID = \"header-prefix\";\nconst HEADER_FILENAME_SUFFIX_SLOT_ID = \"header-filename-suffix\";\nconst HEADER_METADATA_SLOT_ID = \"header-metadata\";\nconst CUSTOM_HEADER_SLOT_ID = \"header-custom\";\nconst DEFAULT_THEMES = {\n\tdark: \"pierre-dark\",\n\tlight: \"pierre-light\"\n};\nconst THEME_CSS_ATTRIBUTE = \"data-theme-css\";\nconst UNSAFE_CSS_ATTRIBUTE = \"data-unsafe-css\";\nconst CORE_CSS_ATTRIBUTE = \"data-core-css\";\nconst DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE = \"data-diffs-scrollbar-measure\";\nconst CODE_VIEW_HEADER_ATTRIBUTE = \"data-diffs-code-view-header\";\nconst CODE_VIEW_FOOTER_ATTRIBUTE = \"data-diffs-code-view-footer\";\nconst DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY = \"--diffs-scrollbar-gutter-measured\";\nconst DEFAULT_COLLAPSED_CONTEXT_THRESHOLD = 1;\nconst DEFAULT_TOKENIZE_MAX_LENGTH = 1e5;\nconst DEFAULT_VIRTUAL_FILE_METRICS = {\n\thunkLineCount: 50,\n\tlineHeight: 20,\n\tdiffHeaderHeight: 44,\n\tspacing: 8\n};\nconst DEFAULT_CODE_VIEW_FILE_METRICS = {\n\t...DEFAULT_VIRTUAL_FILE_METRICS,\n\thunkLineCount: 1\n};\nconst DEFAULT_CODE_VIEW_LAYOUT = {\n\tpaddingTop: 8,\n\tpaddingBottom: 8,\n\tgap: 8\n};\nconst DEFAULT_SMOOTH_SCROLL_SETTINGS = {\n\tomega: .015,\n\tpositionEpsilon: .5,\n\tvelocityEpsilon: .05\n};\nconst DEFAULT_EXPANDED_REGION = Object.freeze({\n\tfromStart: 0,\n\tfromEnd: 0\n});\nconst DEFAULT_RENDER_RANGE = {\n\tstartingLine: 0,\n\ttotalLines: Infinity,\n\tbufferBefore: 0,\n\tbufferAfter: 0\n};\nconst EMPTY_RENDER_RANGE = {\n\tstartingLine: 0,\n\ttotalLines: 0,\n\tbufferBefore: 0,\n\tbufferAfter: 0\n};\n//#endregion\nexport { CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE };\n\n//# sourceMappingURL=constants.js.map","//#region src/utils/getHunkSideBoundaries.ts\n/** Converts a unified hunk side's start/count into its consumed-file range. */\nfunction getHunkSideStartBoundary(start, count) {\n\treturn start - (count === 0 ? 0 : 1);\n}\nfunction getHunkSideEndBoundary(start, count) {\n\treturn getHunkSideStartBoundary(start, count) + count;\n}\n//#endregion\nexport { getHunkSideEndBoundary, getHunkSideStartBoundary };\n\n//# sourceMappingURL=getHunkSideBoundaries.js.map","//#region src/utils/composeCacheKey.ts\nconst CACHE_KEY_VERSION = 1;\n/** Encodes caller-controlled segments without delimiter ambiguity. */\nfunction composeCacheKey(scope, ...segments) {\n\treturn `ck${CACHE_KEY_VERSION}:${JSON.stringify([scope, ...segments])}`;\n}\n//#endregion\nexport { composeCacheKey };\n\n//# sourceMappingURL=composeCacheKey.js.map","//#region src/utils/cleanLastNewline.ts\nfunction cleanLastNewline(contents) {\n\tlet end = contents.length;\n\tif (contents.charCodeAt(end - 1) === 10) {\n\t\tend--;\n\t\tif (contents.charCodeAt(end - 1) === 13) end--;\n\t}\n\treturn contents.slice(0, end);\n}\n//#endregion\nexport { cleanLastNewline };\n\n//# sourceMappingURL=cleanLastNewline.js.map","//#region src/utils/detachString.ts\nconst stringDetachEncoder = new TextEncoder();\nconst stringDetachDecoder = new TextDecoder(\"utf-8\", { ignoreBOM: true });\nconst SURROGATE_CODE_UNIT_PATTERN = /[\\uD800-\\uDFFF]/;\nconst STRING_DETACH_INITIAL_BUFFER_SIZE = 1024;\nlet stringDetachBuffer = new Uint8Array(STRING_DETACH_INITIAL_BUFFER_SIZE);\nfunction releaseStringDetachBuffer() {\n\tif (stringDetachBuffer.length !== STRING_DETACH_INITIAL_BUFFER_SIZE) stringDetachBuffer = new Uint8Array(STRING_DETACH_INITIAL_BUFFER_SIZE);\n}\nfunction detachString(value) {\n\tif (value.length === 0) return value;\n\tif (SURROGATE_CODE_UNIT_PATTERN.test(value)) return JSON.parse(JSON.stringify(value));\n\tconst requiredByteLength = value.length * 3;\n\tif (stringDetachBuffer.length < requiredByteLength) stringDetachBuffer = new Uint8Array(requiredByteLength);\n\tconst { written } = stringDetachEncoder.encodeInto(value, stringDetachBuffer);\n\treturn stringDetachDecoder.decode(stringDetachBuffer.subarray(0, written));\n}\n//#endregion\nexport { detachString, releaseStringDetachBuffer };\n\n//# sourceMappingURL=detachString.js.map","//#region src/utils/parseQuotedDiffFileName.ts\nconst filenameDecoder = new TextDecoder(\"utf-8\", { ignoreBOM: true });\nconst NAMED_ESCAPES = {\n\t\"\\\"\": \"\\\"\",\n\t\"\\\\\": \"\\\\\",\n\ta: \"\\x07\",\n\tb: \"\\b\",\n\tt: \"\t\",\n\tn: \"\\n\",\n\tv: \"\\v\",\n\tf: \"\\f\",\n\tr: \"\\r\"\n};\nfunction parseQuotedDiffFileName(input) {\n\tif (input[0] !== \"\\\"\") return;\n\tlet fileName = \"\";\n\tlet index = 1;\n\twhile (index < input.length) {\n\t\tconst char = input[index];\n\t\tif (char === \"\\\"\") return {\n\t\t\tfileName,\n\t\t\trawLength: index + 1\n\t\t};\n\t\tif (char !== \"\\\\\") {\n\t\t\tfileName += char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tconst escaped = NAMED_ESCAPES[input[index + 1]];\n\t\tif (escaped != null) {\n\t\t\tfileName += escaped;\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tconst bytes = [];\n\t\tdo {\n\t\t\tconst byte = readOctalByte(input, index + 1);\n\t\t\tif (byte == null) return;\n\t\t\tbytes.push(byte);\n\t\t\tindex += 4;\n\t\t} while (input[index] === \"\\\\\" && input[index + 1] >= \"0\" && input[index + 1] <= \"7\");\n\t\tfileName += filenameDecoder.decode(new Uint8Array(bytes));\n\t}\n}\nfunction readOctalByte(input, index) {\n\tconst first = input.charCodeAt(index) - 48;\n\tconst second = input.charCodeAt(index + 1) - 48;\n\tconst third = input.charCodeAt(index + 2) - 48;\n\tif (first >= 0 && first <= 3 && second >= 0 && second <= 7 && third >= 0 && third <= 7) return first * 64 + second * 8 + third;\n}\n//#endregion\nexport { parseQuotedDiffFileName };\n\n//# sourceMappingURL=parseQuotedDiffFileName.js.map","//#region src/utils/realignChangeContent.ts\nconst MAX_ALIGNMENT_COMPARISONS = 4096;\nconst MIN_IMPROVEMENT_PER_PAIR = .5;\n/**\n* Re-split count-mismatched change blocks in every hunk so paired lines are\n* chosen by content similarity instead of position. Mutates `hunks` in place\n* without moving changes across context lines; rendered row counts are\n* unchanged (a split block covers the same split/unified rows as the original).\n*/\nfunction realignChangeContentBySimilarity(diff) {\n\tfor (const hunk of diff.hunks) for (let index = 0; index < hunk.hunkContent.length; index++) {\n\t\tconst content = hunk.hunkContent[index];\n\t\tif (content.type !== \"change\") continue;\n\t\tconst replacement = realignChangeBlock(diff, content);\n\t\tif (replacement != null) {\n\t\t\thunk.hunkContent.splice(index, 1, ...replacement);\n\t\t\tindex += replacement.length - 1;\n\t\t}\n\t}\n}\n/**\n* During editing, slide pure insert/delete blocks made entirely of blank lines\n* to the top of the blank run they sit in. Adding or removing a blank line next to\n* existing blanks is ambiguous, and the diff library reports the change at\n* the run's bottom — so pressing Enter at the end of a line marks a blank\n* *below* the caret as inserted while the caret's own new line renders as\n* context. Sliding up anchors the change to the content above it (the caret\n* line after an Enter) instead.\n*\n* `resolveSlide` receives each block that qualifies along with the full\n* distance to the run's top and returns how far to actually move it; 0 keeps\n* the parsed position. Without it, every qualifying block slides to the top.\n*\n* The slide only applies when the block comes to rest directly beneath\n* remaining in-hunk content. A slide that would consume the\n* hunk's entire leading context was stopped by the hunk's edge — a context\n* window cut, not the top of the blank run — and that landing spot is\n* arbitrary, so the block keeps the library's bottom-of-run anchor (which\n* sits against the content below the run). Non-blank blocks never slide, so\n* code that merely ends like its neighbor (an added function before an\n* identical `}`) keeps the library's canonical position.\n*/\nfunction slideBlankBoundaryBlocksUp(hunk, diff, resolveSlide) {\n\tconst { hunkContent } = hunk;\n\tfor (let index = 1; index < hunkContent.length; index++) {\n\t\tconst block = hunkContent[index];\n\t\tconst previous = hunkContent[index - 1];\n\t\tif (block.type !== \"change\" || block.additions > 0 && block.deletions > 0 || previous.type !== \"context\") continue;\n\t\tconst isInsert = block.additions > 0;\n\t\tconst lines = isInsert ? diff.additionLines : diff.deletionLines;\n\t\tconst blockStart = isInsert ? block.additionLineIndex : block.deletionLineIndex;\n\t\tconst blockLength = isInsert ? block.additions : block.deletions;\n\t\tconst unit = lines[blockStart] ?? \"\";\n\t\tif (unit.trim() !== \"\") continue;\n\t\tlet uniform = true;\n\t\tfor (let offset = 1; offset < blockLength; offset++) if (lines[blockStart + offset] !== unit) {\n\t\t\tuniform = false;\n\t\t\tbreak;\n\t\t}\n\t\tif (!uniform) continue;\n\t\tlet slide = 0;\n\t\twhile (slide < previous.lines && diff.additionLines[previous.additionLineIndex + previous.lines - 1 - slide] === unit) slide++;\n\t\tif (slide === 0) continue;\n\t\tif (index === 1 && slide === previous.lines) continue;\n\t\tif (resolveSlide != null) {\n\t\t\tslide = resolveSlide(block, slide);\n\t\t\tif (slide === 0) continue;\n\t\t}\n\t\tblock.additionLineIndex -= slide;\n\t\tblock.deletionLineIndex -= slide;\n\t\tconst blockAdditionEnd = block.additionLineIndex + block.additions;\n\t\tconst blockDeletionEnd = block.deletionLineIndex + block.deletions;\n\t\tconst next = hunkContent[index + 1];\n\t\tif (next?.type === \"context\") {\n\t\t\tnext.lines += slide;\n\t\t\tnext.additionLineIndex = blockAdditionEnd;\n\t\t\tnext.deletionLineIndex = blockDeletionEnd;\n\t\t} else hunkContent.splice(index + 1, 0, {\n\t\t\ttype: \"context\",\n\t\t\tlines: slide,\n\t\t\tadditionLineIndex: blockAdditionEnd,\n\t\t\tdeletionLineIndex: blockDeletionEnd\n\t\t});\n\t\tprevious.lines -= slide;\n\t\tif (previous.lines === 0) {\n\t\t\thunkContent.splice(index - 1, 1);\n\t\t\tindex--;\n\t\t}\n\t}\n}\nfunction realignChangeBlock(diff, content) {\n\tconst { deletions, additions, deletionLineIndex, additionLineIndex } = content;\n\tconst pairCount = Math.min(deletions, additions);\n\tconst surplus = Math.abs(additions - deletions);\n\tif (pairCount === 0 || surplus === 0 || pairCount * (surplus + 1) > MAX_ALIGNMENT_COMPARISONS) return null;\n\tconst strippedDeletions = [];\n\tfor (let line = 0; line < deletions; line++) strippedDeletions.push(stripWhitespace(diff.deletionLines[deletionLineIndex + line] ?? \"\"));\n\tconst strippedAdditions = [];\n\tfor (let line = 0; line < additions; line++) strippedAdditions.push(stripWhitespace(diff.additionLines[additionLineIndex + line] ?? \"\"));\n\tconst additionsAreLonger = additions > deletions;\n\tlet bestOffset = 0;\n\tlet bestScore = -1;\n\tfor (let offset = 0; offset <= surplus; offset++) {\n\t\tlet score = 0;\n\t\tfor (let pair = 0; pair < pairCount; pair++) score += lineSimilarity(strippedDeletions[pair + (additionsAreLonger ? 0 : offset)], strippedAdditions[pair + (additionsAreLonger ? offset : 0)]);\n\t\tif (offset === 0) bestScore = score + pairCount * MIN_IMPROVEMENT_PER_PAIR;\n\t\telse if (score > bestScore) {\n\t\t\tbestScore = score;\n\t\t\tbestOffset = offset;\n\t\t}\n\t}\n\tif (bestOffset === 0) return null;\n\tconst blocks = [];\n\tconst pushBlock = (blockDeletions, blockAdditions, blockDeletionIndex, blockAdditionIndex) => {\n\t\tif (blockDeletions > 0 || blockAdditions > 0) blocks.push({\n\t\t\ttype: \"change\",\n\t\t\tdeletions: blockDeletions,\n\t\t\tadditions: blockAdditions,\n\t\t\tdeletionLineIndex: blockDeletionIndex,\n\t\t\tadditionLineIndex: blockAdditionIndex\n\t\t});\n\t};\n\tif (additionsAreLonger) {\n\t\tpushBlock(0, bestOffset, deletionLineIndex, additionLineIndex);\n\t\tpushBlock(pairCount, pairCount, deletionLineIndex, additionLineIndex + bestOffset);\n\t\tpushBlock(0, additions - pairCount - bestOffset, deletionLineIndex + pairCount, additionLineIndex + bestOffset + pairCount);\n\t} else {\n\t\tpushBlock(bestOffset, 0, deletionLineIndex, additionLineIndex);\n\t\tpushBlock(pairCount, pairCount, deletionLineIndex + bestOffset, additionLineIndex);\n\t\tpushBlock(deletions - pairCount - bestOffset, 0, deletionLineIndex + bestOffset + pairCount, additionLineIndex + pairCount);\n\t}\n\treturn blocks;\n}\nconst WHITESPACE = /\\s+/g;\nfunction stripWhitespace(line) {\n\treturn line.replace(WHITESPACE, \"\");\n}\nfunction lineSimilarity(a, b) {\n\tif (a === b) return 1;\n\tconst maxLength = Math.max(a.length, b.length);\n\tconst minLength = Math.min(a.length, b.length);\n\tif (minLength === 0) return 0;\n\tlet prefix = 0;\n\twhile (prefix < minLength && a[prefix] === b[prefix]) prefix++;\n\tlet suffix = 0;\n\twhile (suffix < minLength - prefix && a[a.length - 1 - suffix] === b[b.length - 1 - suffix]) suffix++;\n\treturn (prefix + suffix) / maxLength;\n}\n//#endregion\nexport { realignChangeContentBySimilarity, slideBlankBoundaryBlocksUp };\n\n//# sourceMappingURL=realignChangeContent.js.map","import { COMMIT_METADATA_SPLIT, FILENAME_HEADER_REGEX, GIT_DIFF_FILE_BREAK_REGEX, INDEX_LINE_METADATA } from \"../constants.js\";\nimport { getHunkSideEndBoundary, getHunkSideStartBoundary } from \"./getHunkSideBoundaries.js\";\nimport { composeCacheKey } from \"./composeCacheKey.js\";\nimport { cleanLastNewline } from \"./cleanLastNewline.js\";\nimport { detachString, releaseStringDetachBuffer } from \"./detachString.js\";\nimport { parseQuotedDiffFileName } from \"./parseQuotedDiffFileName.js\";\nimport { realignChangeContentBySimilarity } from \"./realignChangeContent.js\";\n//#region src/utils/parsePatchFiles.ts\nconst GIT_DIFF_HEADER_FILENAMES = /^diff --git (\"a\\/(?:[^\"\\\\]|\\\\.)*\"|a\\/.+?) (\"b\\/(?:[^\"\\\\]|\\\\.)*\"|b\\/.+?)$/;\nfunction processPatch(data, cacheKeyPrefix, throwOnError) {\n\ttry {\n\t\treturn _processPatch(data, cacheKeyPrefix, throwOnError);\n\t} finally {\n\t\treleaseStringDetachBuffer();\n\t}\n}\nfunction _processPatch(data, cacheKeyPrefix, throwOnError = false, patchIndex) {\n\tconst isGitDiff = isGitDiffPatch(data);\n\tconst rawFiles = isGitDiff ? splitGitDiffFiles(data) : splitUnifiedDiffFiles(data);\n\tlet patchMetadata;\n\tconst files = [];\n\tfor (const fileOrPatchMetadata of rawFiles) {\n\t\tif (isGitDiff && !GIT_DIFF_FILE_BREAK_REGEX.test(fileOrPatchMetadata)) {\n\t\t\tif (patchMetadata == null) patchMetadata = detachString(fileOrPatchMetadata);\n\t\t\telse if (throwOnError) throw Error(\"parsePatchContent: unknown file blob\");\n\t\t\telse console.error(\"parsePatchContent: unknown file blob:\", fileOrPatchMetadata);\n\t\t\tcontinue;\n\t\t} else if (!isGitDiff && !startsWithUnifiedDiffFileHeader(fileOrPatchMetadata)) {\n\t\t\tif (patchMetadata == null) patchMetadata = detachString(fileOrPatchMetadata);\n\t\t\telse if (throwOnError) throw Error(\"parsePatchContent: unknown file blob\");\n\t\t\telse console.error(\"parsePatchContent: unknown file blob:\", fileOrPatchMetadata);\n\t\t\tcontinue;\n\t\t}\n\t\tconst currentFile = _processFile(fileOrPatchMetadata, {\n\t\t\tcacheKey: cacheKeyPrefix != null ? patchIndex == null ? composeCacheKey(\"patch-file\", cacheKeyPrefix, String(files.length)) : composeCacheKey(\"patch-file\", cacheKeyPrefix, String(patchIndex), String(files.length)) : void 0,\n\t\t\tisGitDiff,\n\t\t\tthrowOnError\n\t\t});\n\t\tif (currentFile != null) files.push(currentFile);\n\t}\n\treturn {\n\t\tpatchMetadata,\n\t\tfiles\n\t};\n}\nfunction processFile(fileDiffString, options) {\n\ttry {\n\t\treturn _processFile(fileDiffString, options);\n\t} finally {\n\t\treleaseStringDetachBuffer();\n\t}\n}\nfunction _processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(fileDiffString), oldFile, newFile, throwOnError = false } = {}) {\n\tlet lastHunkEnd = 0;\n\tconst hunks = splitAtLinePrefix(fileDiffString, \"@@ \");\n\tlet currentFile;\n\tconst isPartial = oldFile == null || newFile == null;\n\tlet deletionLineIndex = 0;\n\tlet additionLineIndex = 0;\n\tfor (const hunk of hunks) {\n\t\tconst lines = splitWithNewlines(hunk);\n\t\tconst firstLine = lines[0];\n\t\tif (firstLine == null) {\n\t\t\tif (throwOnError) throw Error(\"parsePatchContent: invalid hunk\");\n\t\t\telse console.error(\"parsePatchContent: invalid hunk\", hunk);\n\t\t\tcontinue;\n\t\t}\n\t\tconst fileHeader = parseHunkHeader(firstLine);\n\t\tlet additionLines = 0;\n\t\tlet deletionLines = 0;\n\t\tif (fileHeader == null || currentFile == null) {\n\t\t\tif (currentFile != null) {\n\t\t\t\tif (throwOnError) throw Error(\"parsePatchContent: Invalid hunk\");\n\t\t\t\telse console.error(\"parsePatchContent: Invalid hunk\", hunk);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcurrentFile = {\n\t\t\t\tname: \"\",\n\t\t\t\ttype: \"change\",\n\t\t\t\thunks: [],\n\t\t\t\tsplitLineCount: 0,\n\t\t\t\tunifiedLineCount: 0,\n\t\t\t\tisPartial,\n\t\t\t\tadditionLines: !isPartial && oldFile != null && newFile != null ? splitFileContents(newFile.contents) : [],\n\t\t\t\tdeletionLines: !isPartial && oldFile != null && newFile != null ? splitFileContents(oldFile.contents) : [],\n\t\t\t\tcacheKey: maybeDetachOptionalString(cacheKey)\n\t\t\t};\n\t\t\tif (currentFile.additionLines.length === 1 && newFile?.contents === \"\") currentFile.additionLines.length = 0;\n\t\t\tif (currentFile.deletionLines.length === 1 && oldFile?.contents === \"\") currentFile.deletionLines.length = 0;\n\t\t\tfor (const line of lines) {\n\t\t\t\tif (line.startsWith(\"diff --git\")) {\n\t\t\t\t\tconst filenameMatch = line.trim().match(GIT_DIFF_HEADER_FILENAMES);\n\t\t\t\t\tif (filenameMatch == null) {\n\t\t\t\t\t\tif (throwOnError) throw Error(\"parsePatchContent: invalid git diff header\");\n\t\t\t\t\t\telse console.error(\"parsePatchContent: invalid git diff header\", line);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst prevName = decodeDiffFileName(filenameMatch[1], true);\n\t\t\t\t\tconst name = decodeDiffFileName(filenameMatch[2], true);\n\t\t\t\t\tcurrentFile.name = detachString(name);\n\t\t\t\t\tif (prevName !== name) currentFile.prevName = detachString(prevName);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst filenameMatch = line.startsWith(\"---\") || line.startsWith(\"+++\") ? line.match(FILENAME_HEADER_REGEX) : null;\n\t\t\t\tif (filenameMatch != null) {\n\t\t\t\t\tconst [, type, rawFileName] = filenameMatch;\n\t\t\t\t\tconst fileName = decodeDiffFileName(rawFileName, isGitDiff);\n\t\t\t\t\tif (type === \"---\" && fileName !== \"/dev/null\") {\n\t\t\t\t\t\tconst detachedFileName = detachString(fileName);\n\t\t\t\t\t\tcurrentFile.prevName = detachedFileName;\n\t\t\t\t\t\tcurrentFile.name = detachedFileName;\n\t\t\t\t\t} else if (type === \"+++\" && fileName !== \"/dev/null\") currentFile.name = detachString(fileName);\n\t\t\t\t} else if (isGitDiff) {\n\t\t\t\t\tif (line.startsWith(\"new mode \")) currentFile.mode = detachString(line.slice(8).trim());\n\t\t\t\t\tif (line.startsWith(\"old mode \")) currentFile.prevMode = detachString(line.slice(8).trim());\n\t\t\t\t\tif (line.startsWith(\"new file mode\")) {\n\t\t\t\t\t\tcurrentFile.type = \"new\";\n\t\t\t\t\t\tcurrentFile.mode = detachString(line.slice(13).trim());\n\t\t\t\t\t}\n\t\t\t\t\tif (line.startsWith(\"deleted file mode\")) {\n\t\t\t\t\t\tcurrentFile.type = \"deleted\";\n\t\t\t\t\t\tcurrentFile.mode = detachString(line.slice(17).trim());\n\t\t\t\t\t}\n\t\t\t\t\tif (line.startsWith(\"similarity index\")) {\n\t\t\t\t\t\tif (line.startsWith(\"similarity index 100%\")) currentFile.type = \"rename-pure\";\n\t\t\t\t\t\telse currentFile.type = \"rename-changed\";\n\t\t\t\t\t}\n\t\t\t\t\tif (line.startsWith(\"index \")) {\n\t\t\t\t\t\tconst [, prevObjectId, newObjectId, mode] = line.trim().match(INDEX_LINE_METADATA) ?? [];\n\t\t\t\t\t\tif (prevObjectId != null) currentFile.prevObjectId = detachString(prevObjectId);\n\t\t\t\t\t\tif (newObjectId != null) currentFile.newObjectId = detachString(newObjectId);\n\t\t\t\t\t\tif (mode != null) currentFile.mode = detachString(mode);\n\t\t\t\t\t}\n\t\t\t\t\tif (line.startsWith(\"rename from \") || line.startsWith(\"copy from \")) currentFile.prevName = detachString(decodeDiffFileName(line.slice(line.startsWith(\"rename\") ? 12 : 10)));\n\t\t\t\t\tif (line.startsWith(\"rename to \") || line.startsWith(\"copy to \")) currentFile.name = detachString(decodeDiffFileName(line.slice(line.startsWith(\"rename\") ? 10 : 8)));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tlet currentContent;\n\t\tlet lastLineType;\n\t\twhile (lines.length > 0 && (lines[lines.length - 1] === \"\\n\" || lines[lines.length - 1] === \"\\r\" || lines[lines.length - 1] === \"\\r\\n\" || lines[lines.length - 1] === \"\")) lines.pop();\n\t\tconst { additionStart, deletionStart } = fileHeader;\n\t\tdeletionLineIndex = isPartial ? deletionLineIndex : deletionStart - 1;\n\t\tadditionLineIndex = isPartial ? additionLineIndex : additionStart - 1;\n\t\tconst hunkData = {\n\t\t\tcollapsedBefore: 0,\n\t\t\tsplitLineCount: 0,\n\t\t\tsplitLineStart: 0,\n\t\t\tunifiedLineCount: 0,\n\t\t\tunifiedLineStart: 0,\n\t\t\tadditionCount: fileHeader.additionCount,\n\t\t\tadditionStart,\n\t\t\tadditionLines,\n\t\t\tdeletionCount: fileHeader.deletionCount,\n\t\t\tdeletionStart,\n\t\t\tdeletionLines,\n\t\t\tdeletionLineIndex,\n\t\t\tadditionLineIndex,\n\t\t\thunkContent: [],\n\t\t\thunkContext: maybeDetachOptionalString(fileHeader.hunkContext),\n\t\t\thunkSpecs: detachString(firstLine),\n\t\t\tnoEOFCRAdditions: false,\n\t\t\tnoEOFCRDeletions: false\n\t\t};\n\t\tlet parsedAdditionLines = 0;\n\t\tlet parsedDeletionLines = 0;\n\t\tfor (let lineIndex = 1; lineIndex < lines.length; lineIndex++) {\n\t\t\tconst rawLine = lines[lineIndex];\n\t\t\tif (parsedAdditionLines >= hunkData.additionCount && parsedDeletionLines >= hunkData.deletionCount && !rawLine.startsWith(\"\\\\\")) {\n\t\t\t\tif (!(isHunkBodyLine(rawLine) && !isFormatPatchVersionSeparator(rawLine))) break;\n\t\t\t\tif (throwOnError) throw Error(\"parsePatchContent: hunk has more lines than expected\");\n\t\t\t}\n\t\t\tconst firstChar = rawLine[0];\n\t\t\tif (firstChar !== \"+\" && firstChar !== \"-\" && firstChar !== \" \" && firstChar !== \"\\\\\") {\n\t\t\t\tif (throwOnError) throw Error(\"parsePatchContent: invalid hunk line\");\n\t\t\t\tconsole.error(`parseLineType: Invalid firstChar: \"${firstChar}\", full line: \"${rawLine}\"`);\n\t\t\t\tconsole.error(\"processFile: invalid rawLine:\", rawLine);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst type = parseRawLineType(firstChar);\n\t\t\tif (type === \"addition\") {\n\t\t\t\tif (throwOnError && parsedAdditionLines >= hunkData.additionCount) throw Error(\"parsePatchContent: hunk has too many addition lines\");\n\t\t\t\tconst line = getParsedLineContent(rawLine);\n\t\t\t\tif (currentContent == null || currentContent.type !== \"change\") {\n\t\t\t\t\tcurrentContent = createContentGroup(\"change\", deletionLineIndex, additionLineIndex);\n\t\t\t\t\thunkData.hunkContent.push(currentContent);\n\t\t\t\t}\n\t\t\t\tadditionLineIndex++;\n\t\t\t\tparsedAdditionLines++;\n\t\t\t\tif (isPartial) currentFile.additionLines.push(line);\n\t\t\t\tcurrentContent.additions++;\n\t\t\t\tadditionLines++;\n\t\t\t\tlastLineType = \"addition\";\n\t\t\t} else if (type === \"deletion\") {\n\t\t\t\tif (throwOnError && parsedDeletionLines >= hunkData.deletionCount) throw Error(\"parsePatchContent: hunk has too many deletion lines\");\n\t\t\t\tconst line = getParsedLineContent(rawLine);\n\t\t\t\tif (currentContent == null || currentContent.type !== \"change\") {\n\t\t\t\t\tcurrentContent = createContentGroup(\"change\", deletionLineIndex, additionLineIndex);\n\t\t\t\t\thunkData.hunkContent.push(currentContent);\n\t\t\t\t}\n\t\t\t\tdeletionLineIndex++;\n\t\t\t\tparsedDeletionLines++;\n\t\t\t\tif (isPartial) currentFile.deletionLines.push(line);\n\t\t\t\tcurrentContent.deletions++;\n\t\t\t\tdeletionLines++;\n\t\t\t\tlastLineType = \"deletion\";\n\t\t\t} else if (type === \"context\") {\n\t\t\t\tif (throwOnError && (parsedDeletionLines >= hunkData.deletionCount || parsedAdditionLines >= hunkData.additionCount)) throw Error(\"parsePatchContent: hunk has too many context lines\");\n\t\t\t\tconst line = getParsedLineContent(rawLine);\n\t\t\t\tif (currentContent == null || currentContent.type !== \"context\") {\n\t\t\t\t\tcurrentContent = createContentGroup(\"context\", deletionLineIndex, additionLineIndex);\n\t\t\t\t\thunkData.hunkContent.push(currentContent);\n\t\t\t\t}\n\t\t\t\tadditionLineIndex++;\n\t\t\t\tdeletionLineIndex++;\n\t\t\t\tparsedAdditionLines++;\n\t\t\t\tparsedDeletionLines++;\n\t\t\t\tif (isPartial) {\n\t\t\t\t\tcurrentFile.deletionLines.push(line);\n\t\t\t\t\tcurrentFile.additionLines.push(line);\n\t\t\t\t}\n\t\t\t\tcurrentContent.lines++;\n\t\t\t\tlastLineType = \"context\";\n\t\t\t} else if (type === \"metadata\" && currentContent != null) {\n\t\t\t\tif (currentContent.type === \"context\") {\n\t\t\t\t\thunkData.noEOFCRAdditions = true;\n\t\t\t\t\thunkData.noEOFCRDeletions = true;\n\t\t\t\t} else if (lastLineType === \"deletion\") hunkData.noEOFCRDeletions = true;\n\t\t\t\telse if (lastLineType === \"addition\") hunkData.noEOFCRAdditions = true;\n\t\t\t\tif (isPartial && (lastLineType === \"addition\" || lastLineType === \"context\")) {\n\t\t\t\t\tconst lastIndex = currentFile.additionLines.length - 1;\n\t\t\t\t\tif (lastIndex >= 0) currentFile.additionLines[lastIndex] = cleanLastNewline(currentFile.additionLines[lastIndex]);\n\t\t\t\t}\n\t\t\t\tif (isPartial && (lastLineType === \"deletion\" || lastLineType === \"context\")) {\n\t\t\t\t\tconst lastIndex = currentFile.deletionLines.length - 1;\n\t\t\t\t\tif (lastIndex >= 0) currentFile.deletionLines[lastIndex] = cleanLastNewline(currentFile.deletionLines[lastIndex]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (parsedAdditionLines !== hunkData.additionCount || parsedDeletionLines !== hunkData.deletionCount) {\n\t\t\tif (throwOnError) throw Error(\"parsePatchContent: hunk line count mismatch\");\n\t\t\tconsole.error(`parsePatchContent: hunk line count mismatch: \"${firstLine.trimEnd()}\", declared old/new ${hunkData.deletionCount}/${hunkData.additionCount}, parsed old/new ${parsedDeletionLines}/${parsedAdditionLines}`);\n\t\t\tconst repairedAdditionStart = getHunkSideStartBoundary(hunkData.additionStart, hunkData.additionCount) + (parsedAdditionLines === 0 ? 0 : 1);\n\t\t\tconst repairedDeletionStart = getHunkSideStartBoundary(hunkData.deletionStart, hunkData.deletionCount) + (parsedDeletionLines === 0 ? 0 : 1);\n\t\t\tif (!isPartial) {\n\t\t\t\tconst additionStartDelta = repairedAdditionStart - hunkData.additionStart;\n\t\t\t\tconst deletionStartDelta = repairedDeletionStart - hunkData.deletionStart;\n\t\t\t\thunkData.additionLineIndex += additionStartDelta;\n\t\t\t\thunkData.deletionLineIndex += deletionStartDelta;\n\t\t\t\tfor (const content of hunkData.hunkContent) {\n\t\t\t\t\tcontent.additionLineIndex += additionStartDelta;\n\t\t\t\t\tcontent.deletionLineIndex += deletionStartDelta;\n\t\t\t\t}\n\t\t\t}\n\t\t\thunkData.additionStart = repairedAdditionStart;\n\t\t\thunkData.deletionStart = repairedDeletionStart;\n\t\t\thunkData.additionCount = parsedAdditionLines;\n\t\t\thunkData.deletionCount = parsedDeletionLines;\n\t\t}\n\t\thunkData.additionLines = additionLines;\n\t\thunkData.deletionLines = deletionLines;\n\t\thunkData.collapsedBefore = Math.max(getHunkSideStartBoundary(hunkData.additionStart, hunkData.additionCount) - lastHunkEnd, 0);\n\t\tcurrentFile.hunks.push(hunkData);\n\t\tlastHunkEnd = getHunkSideEndBoundary(hunkData.additionStart, hunkData.additionCount);\n\t\tfor (const content of hunkData.hunkContent) if (content.type === \"context\") {\n\t\t\thunkData.splitLineCount += content.lines;\n\t\t\thunkData.unifiedLineCount += content.lines;\n\t\t} else {\n\t\t\thunkData.splitLineCount += Math.max(content.additions, content.deletions);\n\t\t\thunkData.unifiedLineCount += content.deletions + content.additions;\n\t\t}\n\t\thunkData.splitLineStart = currentFile.splitLineCount + hunkData.collapsedBefore;\n\t\thunkData.unifiedLineStart = currentFile.unifiedLineCount + hunkData.collapsedBefore;\n\t\tcurrentFile.splitLineCount += hunkData.collapsedBefore + hunkData.splitLineCount;\n\t\tcurrentFile.unifiedLineCount += hunkData.collapsedBefore + hunkData.unifiedLineCount;\n\t}\n\tif (currentFile == null) return;\n\tif (throwOnError && isPartial && !isGitDiff && currentFile.hunks.length === 0) throw Error(\"parsePatchContent: unified file has no hunks\");\n\tif (currentFile.hunks.length > 0 && !isPartial && currentFile.additionLines.length > 0 && currentFile.deletionLines.length > 0) {\n\t\tconst lastHunk = currentFile.hunks[currentFile.hunks.length - 1];\n\t\tconst lastHunkEnd = getHunkSideEndBoundary(lastHunk.additionStart, lastHunk.additionCount);\n\t\tconst totalFileLines = currentFile.additionLines.length;\n\t\tconst collapsedAfter = Math.max(totalFileLines - lastHunkEnd, 0);\n\t\tcurrentFile.splitLineCount += collapsedAfter;\n\t\tcurrentFile.unifiedLineCount += collapsedAfter;\n\t}\n\tif (!isGitDiff) {\n\t\tif (currentFile.prevName != null && currentFile.name !== currentFile.prevName) {\n\t\t\tif (currentFile.hunks.length > 0) currentFile.type = \"rename-changed\";\n\t\t\telse currentFile.type = \"rename-pure\";\n\t\t} else if ((oldFile == null || oldFile.contents === \"\") && newFile != null && newFile.contents !== \"\") currentFile.type = \"new\";\n\t\telse if (oldFile != null && oldFile.contents !== \"\" && (newFile == null || newFile.contents === \"\")) currentFile.type = \"deleted\";\n\t}\n\tif (currentFile.type !== \"rename-pure\" && currentFile.type !== \"rename-changed\") currentFile.prevName = void 0;\n\trealignChangeContentBySimilarity(currentFile);\n\treturn currentFile;\n}\n/**\n* Parses a patch file string into an array of parsed patches.\n*\n* @param data - The raw patch file content (supports multi-commit patches)\n* @param cacheKeyPrefix - Optional prefix for collision-safe cache keys derived\n* from the prefix, patch index, and file index. This enables caching of\n* rendered diff results in the worker pool.\n* @param throwOnError - When true, invalid data throws. When false, invalid data\n* is reported with `console.error` and the parser attempts to recover when\n* possible. Recovery is best-effort and does not guarantee valid output.\n*/\nfunction parsePatchFiles(data, cacheKeyPrefix, throwOnError = false) {\n\tconst patches = [];\n\tconst rawPatches = hasCommitMetadataBoundary(data) ? data.split(COMMIT_METADATA_SPLIT) : [data];\n\tfor (const patch of rawPatches) try {\n\t\tpatches.push(_processPatch(patch, cacheKeyPrefix, throwOnError, cacheKeyPrefix != null ? patches.length : void 0));\n\t} catch (error) {\n\t\tif (throwOnError) throw error;\n\t\telse console.error(error);\n\t} finally {\n\t\treleaseStringDetachBuffer();\n\t}\n\treturn patches;\n}\nfunction decodeDiffFileName(value, stripGitPrefix = false) {\n\tconst rawName = value.trim();\n\tconst name = rawName.startsWith(\"\\\"\") ? parseQuotedDiffFileName(rawName)?.fileName ?? rawName : rawName;\n\treturn stripGitPrefix && (name.startsWith(\"a/\") || name.startsWith(\"b/\")) ? name.slice(2) : name;\n}\nfunction hasCommitMetadataBoundary(data) {\n\treturn data.startsWith(\"From \") || data.includes(\"\\nFrom \");\n}\nfunction splitFileContents(contents) {\n\tconst lines = splitWithNewlines(contents);\n\tfor (let index = 0; index < lines.length; index++) lines[index] = detachString(lines[index]);\n\treturn lines;\n}\nfunction splitWithNewlines(contents) {\n\tif (contents.length === 0) return [\"\"];\n\tconst lines = [];\n\tlet startIndex = 0;\n\tfor (;;) {\n\t\tconst newlineIndex = contents.indexOf(\"\\n\", startIndex);\n\t\tif (newlineIndex === -1) break;\n\t\tlines.push(contents.slice(startIndex, newlineIndex + 1));\n\t\tstartIndex = newlineIndex + 1;\n\t}\n\tif (startIndex < contents.length) lines.push(contents.slice(startIndex));\n\treturn lines;\n}\nfunction splitGitDiffFiles(contents) {\n\treturn splitAtLinePrefix(contents, \"diff --git\");\n}\nfunction splitUnifiedDiffFiles(contents) {\n\tif (contents.length === 0) return [\"\"];\n\tconst parts = [];\n\tlet partStartIndex = 0;\n\tlet lineStartIndex = 0;\n\tlet remainingDeletionLines = 0;\n\tlet remainingAdditionLines = 0;\n\tlet hasOpenedUnifiedFile = false;\n\twhile (lineStartIndex < contents.length) {\n\t\tconst nextLineStartIndex = getNextLineStartIndex(contents, lineStartIndex);\n\t\tif (remainingDeletionLines <= 0 && remainingAdditionLines <= 0) {\n\t\t\tif (isUnifiedDiffFileHeaderAt(contents, lineStartIndex)) {\n\t\t\t\tif (lineStartIndex > partStartIndex) parts.push(contents.slice(partStartIndex, lineStartIndex));\n\t\t\t\tpartStartIndex = lineStartIndex;\n\t\t\t\thasOpenedUnifiedFile = true;\n\t\t\t\tlineStartIndex = getNextLineStartIndex(contents, nextLineStartIndex);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (hasOpenedUnifiedFile && contents.startsWith(\"@@ -\", lineStartIndex)) {\n\t\t\t\tconst fileHeader = parseHunkHeader(contents.slice(lineStartIndex, nextLineStartIndex));\n\t\t\t\tif (fileHeader != null) {\n\t\t\t\t\tremainingDeletionLines = fileHeader.deletionCount;\n\t\t\t\t\tremainingAdditionLines = fileHeader.additionCount;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlineStartIndex = nextLineStartIndex;\n\t\t\tcontinue;\n\t\t}\n\t\tconst firstChar = contents[lineStartIndex];\n\t\tif (firstChar === \"\\\\\") {\n\t\t\tlineStartIndex = nextLineStartIndex;\n\t\t\tcontinue;\n\t\t}\n\t\tif (firstChar === \" \") {\n\t\t\tremainingDeletionLines = Math.max(remainingDeletionLines - 1, 0);\n\t\t\tremainingAdditionLines = Math.max(remainingAdditionLines - 1, 0);\n\t\t} else if (firstChar === \"-\") remainingDeletionLines = Math.max(remainingDeletionLines - 1, 0);\n\t\telse if (firstChar === \"+\") remainingAdditionLines = Math.max(remainingAdditionLines - 1, 0);\n\t\tlineStartIndex = nextLineStartIndex;\n\t}\n\tparts.push(contents.slice(partStartIndex));\n\treturn parts;\n}\nfunction startsWithUnifiedDiffFileHeader(contents) {\n\treturn isUnifiedDiffFileHeaderAt(contents, 0);\n}\nfunction isUnifiedDiffFileHeaderAt(contents, lineStartIndex) {\n\tconst nextLineStartIndex = getNextLineStartIndex(contents, lineStartIndex);\n\treturn isUnifiedDiffHeaderLineAt(contents, lineStartIndex, \"---\") && isUnifiedDiffHeaderLineAt(contents, nextLineStartIndex, \"+++\");\n}\nfunction isUnifiedDiffHeaderLineAt(contents, lineStartIndex, prefix) {\n\tif (!contents.startsWith(prefix, lineStartIndex)) return false;\n\tconst separator = contents[lineStartIndex + prefix.length];\n\tif (separator !== \" \" && separator !== \"\t\") return false;\n\tfor (let index = lineStartIndex + prefix.length + 1; index < contents.length; index++) {\n\t\tconst char = contents[index];\n\t\tif (char === \"\\n\" || char === \"\\r\") break;\n\t\tif (char !== \" \" && char !== \"\t\") return true;\n\t}\n\treturn false;\n}\nfunction getNextLineStartIndex(contents, lineStartIndex) {\n\tconst newlineIndex = contents.indexOf(\"\\n\", lineStartIndex);\n\treturn newlineIndex === -1 ? contents.length : newlineIndex + 1;\n}\nfunction isHunkBodyLine(line) {\n\tconst firstChar = line[0];\n\treturn firstChar === \"+\" || firstChar === \"-\" || firstChar === \" \";\n}\nfunction isFormatPatchVersionSeparator(line) {\n\tif (!line.startsWith(\"--\")) return false;\n\tfor (let index = 2; index < line.length; index++) {\n\t\tconst char = line[index];\n\t\tif (char !== \" \" && char !== \"\t\" && char !== \"\\n\" && char !== \"\\r\") return false;\n\t}\n\treturn true;\n}\nfunction parseHunkHeader(line) {\n\tif (!line.startsWith(\"@@ -\")) return;\n\tlet index = 4;\n\tconst deletionStartResult = readPositiveInteger(line, index);\n\tif (deletionStartResult == null) return;\n\tconst deletionStart = deletionStartResult.value;\n\tindex = deletionStartResult.endIndex;\n\tlet deletionCount = 1;\n\tif (line[index] === \",\") {\n\t\tconst deletionCountResult = readPositiveInteger(line, index + 1);\n\t\tif (deletionCountResult == null) return;\n\t\tdeletionCount = deletionCountResult.value;\n\t\tindex = deletionCountResult.endIndex;\n\t}\n\tif (line[index] !== \" \" || line[index + 1] !== \"+\") return;\n\tindex += 2;\n\tconst additionStartResult = readPositiveInteger(line, index);\n\tif (additionStartResult == null) return;\n\tconst additionStart = additionStartResult.value;\n\tindex = additionStartResult.endIndex;\n\tlet additionCount = 1;\n\tif (line[index] === \",\") {\n\t\tconst additionCountResult = readPositiveInteger(line, index + 1);\n\t\tif (additionCountResult == null) return;\n\t\tadditionCount = additionCountResult.value;\n\t\tindex = additionCountResult.endIndex;\n\t}\n\tif (line[index] !== \" \" || line[index + 1] !== \"@\" || line[index + 2] !== \"@\") return;\n\tlet hunkContext;\n\tconst contextStartIndex = index + 3;\n\tif (line[contextStartIndex] === \" \") hunkContext = trimLineEnd(line.slice(contextStartIndex + 1));\n\treturn {\n\t\tadditionCount,\n\t\tadditionStart,\n\t\tdeletionCount,\n\t\tdeletionStart,\n\t\thunkContext\n\t};\n}\nfunction readPositiveInteger(value, startIndex) {\n\tlet index = startIndex;\n\tlet parsedValue = 0;\n\tfor (; index < value.length; index++) {\n\t\tconst digit = value.charCodeAt(index) - 48;\n\t\tif (digit < 0 || digit > 9) break;\n\t\tparsedValue = parsedValue * 10 + digit;\n\t}\n\tif (index === startIndex) return;\n\treturn {\n\t\tvalue: parsedValue,\n\t\tendIndex: index\n\t};\n}\nfunction trimLineEnd(value) {\n\tif (value.endsWith(\"\\r\\n\")) return value.slice(0, -2);\n\tif (value.endsWith(\"\\n\")) return value.slice(0, -1);\n\treturn value;\n}\nfunction isGitDiffPatch(data) {\n\treturn data.startsWith(\"diff --git\") || data.includes(\"\\ndiff --git\");\n}\nfunction splitAtLinePrefix(contents, prefix) {\n\tif (contents.length === 0) return [\"\"];\n\tconst newlinePrefix = `\\n${prefix}`;\n\tconst firstBoundaryIndex = contents.startsWith(prefix) ? 0 : findLinePrefixIndex(contents, newlinePrefix, 0);\n\tif (firstBoundaryIndex === -1) return [contents];\n\tconst parts = [];\n\tif (firstBoundaryIndex > 0) parts.push(contents.slice(0, firstBoundaryIndex));\n\tlet startIndex = firstBoundaryIndex;\n\tfor (;;) {\n\t\tconst nextBoundaryIndex = findLinePrefixIndex(contents, newlinePrefix, startIndex + 1);\n\t\tif (nextBoundaryIndex === -1) break;\n\t\tparts.push(contents.slice(startIndex, nextBoundaryIndex));\n\t\tstartIndex = nextBoundaryIndex;\n\t}\n\tparts.push(contents.slice(startIndex));\n\treturn parts;\n}\nfunction findLinePrefixIndex(contents, newlinePrefix, fromIndex) {\n\tconst index = contents.indexOf(newlinePrefix, fromIndex);\n\treturn index === -1 ? -1 : index + 1;\n}\nfunction maybeDetachOptionalString(value) {\n\treturn value == null ? value : detachString(value);\n}\nfunction parseRawLineType(firstChar) {\n\treturn firstChar === \" \" ? \"context\" : firstChar === \"\\\\\" ? \"metadata\" : firstChar === \"+\" ? \"addition\" : \"deletion\";\n}\nfunction getParsedLineContent(rawLine) {\n\tconst processedLine = rawLine.slice(1);\n\treturn detachString(processedLine === \"\" ? \"\\n\" : processedLine);\n}\nfunction createContentGroup(type, deletionLineIndex, additionLineIndex) {\n\tif (type === \"change\") return {\n\t\ttype: \"change\",\n\t\tadditions: 0,\n\t\tdeletions: 0,\n\t\tadditionLineIndex,\n\t\tdeletionLineIndex\n\t};\n\treturn {\n\t\ttype: \"context\",\n\t\tlines: 0,\n\t\tadditionLineIndex,\n\t\tdeletionLineIndex\n\t};\n}\n//#endregion\nexport { parsePatchFiles, processFile, processPatch };\n\n//# sourceMappingURL=parsePatchFiles.js.map","export default class Diff {\n diff(oldStr, newStr, \n // Type below is not accurate/complete - see above for full possibilities - but it compiles\n options = {}) {\n let callback;\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n else if ('callback' in options) {\n callback = options.callback;\n }\n // Allow subclasses to massage the input prior to running\n const oldString = this.castInput(oldStr, options);\n const newString = this.castInput(newStr, options);\n const oldTokens = this.removeEmpty(this.tokenize(oldString, options));\n const newTokens = this.removeEmpty(this.tokenize(newString, options));\n return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);\n }\n diffWithOptionsObj(oldTokens, newTokens, options, callback) {\n var _a;\n const done = (value) => {\n value = this.postProcess(value, options);\n if (callback) {\n setTimeout(function () { callback(value); }, 0);\n return undefined;\n }\n else {\n return value;\n }\n };\n const newLen = newTokens.length, oldLen = oldTokens.length;\n let editLength = 1;\n let maxEditLength = newLen + oldLen;\n if (options.maxEditLength != null) {\n maxEditLength = Math.min(maxEditLength, options.maxEditLength);\n }\n const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;\n const abortAfterTimestamp = Date.now() + maxExecutionTime;\n const bestPath = [{ oldPos: -1, lastComponent: undefined }];\n // Seed editLength = 0, i.e. the content starts with the same values\n let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);\n if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {\n // Identity per the equality and tokenizer\n return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));\n }\n // Once we hit the right edge of the edit graph on some diagonal k, we can\n // definitely reach the end of the edit graph in no more than k edits, so\n // there's no point in considering any moves to diagonal k+1 any more (from\n // which we're guaranteed to need at least k+1 more edits).\n // Similarly, once we've reached the bottom of the edit graph, there's no\n // point considering moves to lower diagonals.\n // We record this fact by setting minDiagonalToConsider and\n // maxDiagonalToConsider to some finite value once we've hit the edge of\n // the edit graph.\n // This optimization is not faithful to the original algorithm presented in\n // Myers's paper, which instead pointlessly extends D-paths off the end of\n // the edit graph - see page 7 of Myers's paper which notes this point\n // explicitly and illustrates it with a diagram. This has major performance\n // implications for some common scenarios. For instance, to compute a diff\n // where the new text simply appends d characters on the end of the\n // original text of length n, the true Myers algorithm will take O(n+d^2)\n // time while this optimization needs only O(n+d) time.\n let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;\n // Main worker method. checks all permutations of a given edit length for acceptance.\n const execEditLength = () => {\n for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {\n let basePath;\n const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];\n if (removePath) {\n // No one else is going to attempt to use this value, clear it\n // @ts-expect-error - perf optimisation. This type-violating value will never be read.\n bestPath[diagonalPath - 1] = undefined;\n }\n let canAdd = false;\n if (addPath) {\n // what newPos will be after we do an insertion:\n const addPathNewPos = addPath.oldPos - diagonalPath;\n canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;\n }\n const canRemove = removePath && removePath.oldPos + 1 < oldLen;\n if (!canAdd && !canRemove) {\n // If this path is a terminal then prune\n // @ts-expect-error - perf optimisation. This type-violating value will never be read.\n bestPath[diagonalPath] = undefined;\n continue;\n }\n // Select the diagonal that we want to branch from. We select the prior\n // path whose position in the old string is the farthest from the origin\n // and does not pass the bounds of the diff graph\n if (!canRemove || (canAdd && removePath.oldPos < addPath.oldPos)) {\n basePath = this.addToPath(addPath, true, false, 0, options);\n }\n else {\n basePath = this.addToPath(removePath, false, true, 1, options);\n }\n newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);\n if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {\n // If we have hit the end of both strings, then we are done\n return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;\n }\n else {\n bestPath[diagonalPath] = basePath;\n if (basePath.oldPos + 1 >= oldLen) {\n maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);\n }\n if (newPos + 1 >= newLen) {\n minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);\n }\n }\n }\n editLength++;\n };\n // Performs the length of edit iteration. Is a bit fugly as this has to support the\n // sync and async mode which is never fun. Loops over execEditLength until a value\n // is produced, or until the edit length exceeds options.maxEditLength (if given),\n // in which case it will return undefined.\n if (callback) {\n (function exec() {\n setTimeout(function () {\n if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {\n return callback(undefined);\n }\n if (!execEditLength()) {\n exec();\n }\n }, 0);\n }());\n }\n else {\n while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {\n const ret = execEditLength();\n if (ret) {\n return ret;\n }\n }\n }\n }\n addToPath(path, added, removed, oldPosInc, options) {\n const last = path.lastComponent;\n if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {\n return {\n oldPos: path.oldPos + oldPosInc,\n lastComponent: { count: last.count + 1, added: added, removed: removed, previousComponent: last.previousComponent }\n };\n }\n else {\n return {\n oldPos: path.oldPos + oldPosInc,\n lastComponent: { count: 1, added: added, removed: removed, previousComponent: last }\n };\n }\n }\n extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {\n const newLen = newTokens.length, oldLen = oldTokens.length;\n let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;\n while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {\n newPos++;\n oldPos++;\n commonCount++;\n if (options.oneChangePerToken) {\n basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };\n }\n }\n if (commonCount && !options.oneChangePerToken) {\n basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };\n }\n basePath.oldPos = oldPos;\n return newPos;\n }\n equals(left, right, options) {\n if (options.comparator) {\n return options.comparator(left, right);\n }\n else {\n return left === right\n || (!!options.ignoreCase && left.toLowerCase() === right.toLowerCase());\n }\n }\n removeEmpty(array) {\n const ret = [];\n for (let i = 0; i < array.length; i++) {\n if (array[i]) {\n ret.push(array[i]);\n }\n }\n return ret;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n castInput(value, options) {\n return value;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n tokenize(value, options) {\n return Array.from(value);\n }\n join(chars) {\n // Assumes ValueT is string, which is the case for most subclasses.\n // When it's false, e.g. in diffArrays, this method needs to be overridden (e.g. with a no-op)\n // Yes, the casts are verbose and ugly, because this pattern - of having the base class SORT OF\n // assume tokens and values are strings, but not completely - is weird and janky.\n return chars.join('');\n }\n postProcess(changeObjects, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n options) {\n return changeObjects;\n }\n get useLongestToken() {\n return false;\n }\n buildValues(lastComponent, newTokens, oldTokens) {\n // First we convert our linked list of components in reverse order to an\n // array in the right order:\n const components = [];\n let nextComponent;\n while (lastComponent) {\n components.push(lastComponent);\n nextComponent = lastComponent.previousComponent;\n delete lastComponent.previousComponent;\n lastComponent = nextComponent;\n }\n components.reverse();\n const componentLen = components.length;\n let componentPos = 0, newPos = 0, oldPos = 0;\n for (; componentPos < componentLen; componentPos++) {\n const component = components[componentPos];\n if (!component.removed) {\n if (!component.added && this.useLongestToken) {\n let value = newTokens.slice(newPos, newPos + component.count);\n value = value.map(function (value, i) {\n const oldValue = oldTokens[oldPos + i];\n return oldValue.length > value.length ? oldValue : value;\n });\n component.value = this.join(value);\n }\n else {\n component.value = this.join(newTokens.slice(newPos, newPos + component.count));\n }\n newPos += component.count;\n // Common case\n if (!component.added) {\n oldPos += component.count;\n }\n }\n else {\n component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));\n oldPos += component.count;\n }\n }\n return components;\n }\n}\n","import Diff from './base.js';\nclass CharacterDiff extends Diff {\n}\nexport const characterDiff = new CharacterDiff();\nexport function diffChars(oldStr, newStr, options) {\n return characterDiff.diff(oldStr, newStr, options);\n}\n","export function longestCommonPrefix(str1, str2) {\n let i;\n for (i = 0; i < str1.length && i < str2.length; i++) {\n if (str1[i] != str2[i]) {\n return str1.slice(0, i);\n }\n }\n return str1.slice(0, i);\n}\nexport function longestCommonSuffix(str1, str2) {\n let i;\n // Unlike longestCommonPrefix, we need a special case to handle all scenarios\n // where we return the empty string since str1.slice(-0) will return the\n // entire string.\n if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {\n return '';\n }\n for (i = 0; i < str1.length && i < str2.length; i++) {\n if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {\n return str1.slice(-i);\n }\n }\n return str1.slice(-i);\n}\nexport function replacePrefix(string, oldPrefix, newPrefix) {\n if (string.slice(0, oldPrefix.length) != oldPrefix) {\n throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);\n }\n return newPrefix + string.slice(oldPrefix.length);\n}\nexport function replaceSuffix(string, oldSuffix, newSuffix) {\n if (!oldSuffix) {\n return string + newSuffix;\n }\n if (string.slice(-oldSuffix.length) != oldSuffix) {\n throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);\n }\n return string.slice(0, -oldSuffix.length) + newSuffix;\n}\nexport function removePrefix(string, oldPrefix) {\n return replacePrefix(string, oldPrefix, '');\n}\nexport function removeSuffix(string, oldSuffix) {\n return replaceSuffix(string, oldSuffix, '');\n}\nexport function maximumOverlap(string1, string2) {\n return string2.slice(0, overlapCount(string1, string2));\n}\n// Nicked from https://stackoverflow.com/a/60422853/1709587\nfunction overlapCount(a, b) {\n // Deal with cases where the strings differ in length\n let startA = 0;\n if (a.length > b.length) {\n startA = a.length - b.length;\n }\n let endB = b.length;\n if (a.length < b.length) {\n endB = a.length;\n }\n // Create a back-reference for each index\n // that should be followed in case of a mismatch.\n // We only need B to make these references:\n const map = Array(endB);\n let k = 0; // Index that lags behind j\n map[0] = 0;\n for (let j = 1; j < endB; j++) {\n if (b[j] == b[k]) {\n map[j] = map[k]; // skip over the same character (optional optimisation)\n }\n else {\n map[j] = k;\n }\n while (k > 0 && b[j] != b[k]) {\n k = map[k];\n }\n if (b[j] == b[k]) {\n k++;\n }\n }\n // Phase 2: use these references while iterating over A\n k = 0;\n for (let i = startA; i < a.length; i++) {\n while (k > 0 && a[i] != b[k]) {\n k = map[k];\n }\n if (a[i] == b[k]) {\n k++;\n }\n }\n return k;\n}\n/**\n * Returns true if the string consistently uses Windows line endings.\n */\nexport function hasOnlyWinLineEndings(string) {\n return string.includes('\\r\\n') && !string.startsWith('\\n') && !string.match(/[^\\r]\\n/);\n}\n/**\n * Returns true if the string consistently uses Unix line endings.\n */\nexport function hasOnlyUnixLineEndings(string) {\n return !string.includes('\\r\\n') && string.includes('\\n');\n}\n/**\n * Split a string into segments using a word segmenter, merging consecutive\n * segments if they are both whitespace segments. Whitespace segments can\n * appear adjacent to one another for two reasons:\n * - newlines always get their own segment\n * - where a diacritic is attached to a whitespace character in the text, the\n * segment ends after the diacritic, so e.g. \" \\u0300 \" becomes two segments.\n * This function therefore runs the segmenter's .segment() method and then\n * merges consecutive segments of whitespace into a single part.\n */\nexport function segment(string, segmenter) {\n const parts = [];\n for (const segmentObj of Array.from(segmenter.segment(string))) {\n const segment = segmentObj.segment;\n if (parts.length && (/\\s/).test(parts[parts.length - 1]) && (/\\s/).test(segment)) {\n parts[parts.length - 1] += segment;\n }\n else {\n parts.push(segment);\n }\n }\n return parts;\n}\n// The functions below take a `segmenter` argument so that, when called from\n// diffWords when it is using a segmenter, they can use a notion of what\n// constitutes \"whitespace\" that is consistent with the segmenter.\n//\n// USUALLY this will be identical to the result of the non-segmenter-based\n// logic, but it differs in at least one case: when whitespace characters are\n// modified by diacritics. A word segmenter considers these diacritics to be\n// part of the whitespace, whereas our non-segmenter-based logic does not.\n//\n// Because the segmenter-based approach necessarily requires segmenting the\n// entire string, we offer a leadingAndTrailingWs function to allow getting the\n// whitespace prefix AND whitespace suffix with a single call to the segmenter,\n// for efficiency's sake.\nexport function trailingWs(string, segmenter) {\n if (segmenter) {\n return leadingAndTrailingWs(string, segmenter)[1];\n }\n // Yes, this looks overcomplicated and dumb - why not replace the whole function with\n // return string.match(/\\s*$/)[0]\n // you ask? Because:\n // 1. the trap described at https://markamery.com/blog/quadratic-time-regexes/ would mean doing\n // this would cause this function to take O(n²) time in the worst case (specifically when\n // there is a massive run of NON-TRAILING whitespace in `string`), and\n // 2. the fix proposed in the same blog post, of using a negative lookbehind, is incompatible\n // with old Safari versions that we'd like to not break if possible (see\n // https://github.com/kpdecker/jsdiff/pull/550)\n // It feels absurd to do this with an explicit loop instead of a regex, but I really can't see a\n // better way that doesn't result in broken behaviour.\n let i;\n for (i = string.length - 1; i >= 0; i--) {\n if (!string[i].match(/\\s/)) {\n break;\n }\n }\n return string.substring(i + 1);\n}\nexport function leadingWs(string, segmenter) {\n if (segmenter) {\n return leadingAndTrailingWs(string, segmenter)[0];\n }\n // Thankfully the annoying considerations described in trailingWs don't apply here:\n const match = string.match(/^\\s*/);\n return match ? match[0] : '';\n}\nexport function leadingAndTrailingWs(string, segmenter) {\n if (!segmenter) {\n return [leadingWs(string), trailingWs(string)];\n }\n if (segmenter.resolvedOptions().granularity != 'word') {\n throw new Error('The segmenter passed must have a granularity of \"word\"');\n }\n const segments = segment(string, segmenter);\n const firstSeg = segments[0];\n const lastSeg = segments[segments.length - 1];\n const head = (/\\s/).test(firstSeg) ? firstSeg : '';\n const tail = (/\\s/).test(lastSeg) ? lastSeg : '';\n return [head, tail];\n}\n","import Diff from './base.js';\nimport { longestCommonPrefix, longestCommonSuffix, replacePrefix, replaceSuffix, removePrefix, removeSuffix, maximumOverlap, leadingWs, trailingWs, leadingAndTrailingWs, segment } from '../util/string.js';\n// Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode\n//\n// Chars/ranges counted as \"word\" characters by this regex are as follows:\n//\n// + U+00AD Soft hyphen\n// + 00C0–00FF (letters with diacritics from the Latin-1 Supplement), except:\n// - U+00D7 × Multiplication sign\n// - U+00F7 ÷ Division sign\n// + Latin Extended-A, 0100–017F\n// + Latin Extended-B, 0180–024F\n// + IPA Extensions, 0250–02AF\n// + Spacing Modifier Letters, 02B0–02FF, except:\n// - U+02C7 ˇ &#711; Caron\n// - U+02D8 ˘ &#728; Breve\n// - U+02D9 ˙ &#729; Dot Above\n// - U+02DA ˚ &#730; Ring Above\n// - U+02DB ˛ &#731; Ogonek\n// - U+02DC ˜ &#732; Small Tilde\n// - U+02DD ˝ &#733; Double Acute Accent\n// + Latin Extended Additional, 1E00–1EFF\nconst extendedWordChars = 'a-zA-Z0-9_\\\\u{AD}\\\\u{C0}-\\\\u{D6}\\\\u{D8}-\\\\u{F6}\\\\u{F8}-\\\\u{2C6}\\\\u{2C8}-\\\\u{2D7}\\\\u{2DE}-\\\\u{2FF}\\\\u{1E00}-\\\\u{1EFF}';\n// Each token is one of the following:\n// - A punctuation mark plus the surrounding whitespace\n// - A word plus the surrounding whitespace\n// - Pure whitespace (but only in the special case where the entire text\n// is just whitespace)\n//\n// We have to include surrounding whitespace in the tokens because the two\n// alternative approaches produce horribly broken results:\n// * If we just discard the whitespace, we can't fully reproduce the original\n// text from the sequence of tokens and any attempt to render the diff will\n// get the whitespace wrong.\n// * If we have separate tokens for whitespace, then in a typical text every\n// second token will be a single space character. But this often results in\n// the optimal diff between two texts being a perverse one that preserves\n// the spaces between words but deletes and reinserts actual common words.\n// See https://github.com/kpdecker/jsdiff/issues/160#issuecomment-1866099640\n// for an example.\n//\n// Keeping the surrounding whitespace of course has implications for .equals\n// and .join, not just .tokenize.\n// This regex does NOT fully implement the tokenization rules described above.\n// Instead, it gives runs of whitespace their own \"token\". The tokenize method\n// then handles stitching whitespace tokens onto adjacent word or punctuation\n// tokens.\nconst tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\\\s+|[^${extendedWordChars}]`, 'ug');\nclass WordDiff extends Diff {\n equals(left, right, options) {\n if (options.ignoreCase) {\n left = left.toLowerCase();\n right = right.toLowerCase();\n }\n return left.trim() === right.trim();\n }\n tokenize(value, options = {}) {\n let parts;\n if (options.intlSegmenter) {\n const segmenter = options.intlSegmenter;\n if (segmenter.resolvedOptions().granularity != 'word') {\n throw new Error('The segmenter passed must have a granularity of \"word\"');\n }\n // We want `parts` to be an array whose elements alternate between being\n // pure whitespace and being pure non-whitespace. This is ALMOST what the\n // segments returned by a word-based Intl.Segmenter already look like,\n // but not quite - see explanation in the docs of our custom segment()\n // function.\n parts = segment(value, segmenter);\n }\n else {\n parts = value.match(tokenizeIncludingWhitespace) || [];\n }\n const tokens = [];\n let prevPart = null;\n parts.forEach(part => {\n if ((/\\s/).test(part)) {\n if (prevPart == null) {\n tokens.push(part);\n }\n else {\n tokens.push(tokens.pop() + part);\n }\n }\n else if (prevPart != null && (/\\s/).test(prevPart)) {\n if (tokens[tokens.length - 1] == prevPart) {\n tokens.push(tokens.pop() + part);\n }\n else {\n tokens.push(prevPart + part);\n }\n }\n else {\n tokens.push(part);\n }\n prevPart = part;\n });\n return tokens;\n }\n join(tokens) {\n // Tokens being joined here will always have appeared consecutively in the\n // same text, so we can simply strip off the leading whitespace from all the\n // tokens except the first (and except any whitespace-only tokens - but such\n // a token will always be the first and only token anyway) and then join them\n // and the whitespace around words and punctuation will end up correct.\n return tokens.map((token, i) => {\n if (i == 0) {\n return token;\n }\n else {\n return token.replace((/^\\s+/), '');\n }\n }).join('');\n }\n postProcess(changes, options) {\n if (!changes || options.oneChangePerToken) {\n return changes;\n }\n let lastKeep = null;\n // Change objects representing any insertion or deletion since the last\n // \"keep\" change object. There can be at most one of each.\n let insertion = null;\n let deletion = null;\n changes.forEach(change => {\n if (change.added) {\n insertion = change;\n }\n else if (change.removed) {\n deletion = change;\n }\n else {\n if (insertion || deletion) { // May be false at start of text\n dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change, options.intlSegmenter);\n }\n lastKeep = change;\n insertion = null;\n deletion = null;\n }\n });\n if (insertion || deletion) {\n dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null, options.intlSegmenter);\n }\n return changes;\n }\n}\nexport const wordDiff = new WordDiff();\nexport function diffWords(oldStr, newStr, options) {\n // This option has never been documented and never will be (it's clearer to\n // just call `diffWordsWithSpace` directly if you need that behavior), but\n // has existed in jsdiff for a long time, so we retain support for it here\n // for the sake of backwards compatibility.\n if ((options === null || options === void 0 ? void 0 : options.ignoreWhitespace) != null && !options.ignoreWhitespace) {\n return diffWordsWithSpace(oldStr, newStr, options);\n }\n return wordDiff.diff(oldStr, newStr, options);\n}\nfunction dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep, segmenter) {\n // Before returning, we tidy up the leading and trailing whitespace of the\n // change objects to eliminate cases where trailing whitespace in one object\n // is repeated as leading whitespace in the next.\n // Below are examples of the outcomes we want here to explain the code.\n // I=insert, K=keep, D=delete\n // 1. diffing 'foo bar baz' vs 'foo baz'\n // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'\n // After cleanup, we want: K:'foo ' D:'bar ' K:'baz'\n //\n // 2. Diffing 'foo bar baz' vs 'foo qux baz'\n // Prior to cleanup, we have K:'foo ' D:' bar ' I:' qux ' K:' baz'\n // After cleanup, we want K:'foo ' D:'bar' I:'qux' K:' baz'\n //\n // 3. Diffing 'foo\\nbar baz' vs 'foo baz'\n // Prior to cleanup, we have K:'foo ' D:'\\nbar ' K:' baz'\n // After cleanup, we want K'foo' D:'\\nbar' K:' baz'\n //\n // 4. Diffing 'foo baz' vs 'foo\\nbar baz'\n // Prior to cleanup, we have K:'foo\\n' I:'\\nbar ' K:' baz'\n // After cleanup, we ideally want K'foo' I:'\\nbar' K:' baz'\n // but don't actually manage this currently (the pre-cleanup change\n // objects don't contain enough information to make it possible).\n //\n // 5. Diffing 'foo bar baz' vs 'foo baz'\n // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'\n // After cleanup, we want K:'foo ' D:' bar ' K:'baz'\n //\n // Our handling is unavoidably imperfect in the case where there's a single\n // indel between keeps and the whitespace has changed. For instance, consider\n // diffing 'foo\\tbar\\nbaz' vs 'foo baz'. Unless we create an extra change\n // object to represent the insertion of the space character (which isn't even\n // a token), we have no way to avoid losing information about the texts'\n // original whitespace in the result we return. Still, we do our best to\n // output something that will look sensible if we e.g. print it with\n // insertions in green and deletions in red.\n // Between two \"keep\" change objects (or before the first or after the last\n // change object), we can have either:\n // * A \"delete\" followed by an \"insert\"\n // * Just an \"insert\"\n // * Just a \"delete\"\n // We handle the three cases separately.\n if (deletion && insertion) {\n const [oldWsPrefix, oldWsSuffix] = leadingAndTrailingWs(deletion.value, segmenter);\n const [newWsPrefix, newWsSuffix] = leadingAndTrailingWs(insertion.value, segmenter);\n if (startKeep) {\n const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);\n startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);\n deletion.value = removePrefix(deletion.value, commonWsPrefix);\n insertion.value = removePrefix(insertion.value, commonWsPrefix);\n }\n if (endKeep) {\n const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);\n endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);\n deletion.value = removeSuffix(deletion.value, commonWsSuffix);\n insertion.value = removeSuffix(insertion.value, commonWsSuffix);\n }\n }\n else if (insertion) {\n // The whitespaces all reflect what was in the new text rather than\n // the old, so we essentially have no information about whitespace\n // insertion or deletion. We just want to dedupe the whitespace.\n // We do that by having each change object keep its trailing\n // whitespace and deleting duplicate leading whitespace where\n // present.\n if (startKeep) {\n const ws = leadingWs(insertion.value, segmenter);\n insertion.value = insertion.value.substring(ws.length);\n }\n if (endKeep) {\n const ws = leadingWs(endKeep.value, segmenter);\n endKeep.value = endKeep.value.substring(ws.length);\n }\n // otherwise we've got a deletion and no insertion\n }\n else if (startKeep && endKeep) {\n const newWsFull = leadingWs(endKeep.value, segmenter), [delWsStart, delWsEnd] = leadingAndTrailingWs(deletion.value, segmenter);\n // Any whitespace that comes straight after startKeep in both the old and\n // new texts, assign to startKeep and remove from the deletion.\n const newWsStart = longestCommonPrefix(newWsFull, delWsStart);\n deletion.value = removePrefix(deletion.value, newWsStart);\n // Any whitespace that comes straight before endKeep in both the old and\n // new texts, and hasn't already been assigned to startKeep, assign to\n // endKeep and remove from the deletion.\n const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);\n deletion.value = removeSuffix(deletion.value, newWsEnd);\n endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);\n // If there's any whitespace from the new text that HASN'T already been\n // assigned, assign it to the start:\n startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));\n }\n else if (endKeep) {\n // We are at the start of the text. Preserve all the whitespace on\n // endKeep, and just remove whitespace from the end of deletion to the\n // extent that it overlaps with the start of endKeep.\n const endKeepWsPrefix = leadingWs(endKeep.value, segmenter);\n const deletionWsSuffix = trailingWs(deletion.value, segmenter);\n const overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);\n deletion.value = removeSuffix(deletion.value, overlap);\n }\n else if (startKeep) {\n // We are at the END of the text. Preserve all the whitespace on\n // startKeep, and just remove whitespace from the start of deletion to\n // the extent that it overlaps with the end of startKeep.\n const startKeepWsSuffix = trailingWs(startKeep.value, segmenter);\n const deletionWsPrefix = leadingWs(deletion.value, segmenter);\n const overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);\n deletion.value = removePrefix(deletion.value, overlap);\n }\n}\nclass WordsWithSpaceDiff extends Diff {\n tokenize(value) {\n // Slightly different to the tokenizeIncludingWhitespace regex used above in\n // that this one treats each individual newline as a distinct token, rather\n // than merging them into other surrounding whitespace. This was requested\n // in https://github.com/kpdecker/jsdiff/issues/180 &\n // https://github.com/kpdecker/jsdiff/issues/211\n const regex = new RegExp(`(\\\\r?\\\\n)|[${extendedWordChars}]+|[^\\\\S\\\\n\\\\r]+|[^${extendedWordChars}]`, 'ug');\n return value.match(regex) || [];\n }\n}\nexport const wordsWithSpaceDiff = new WordsWithSpaceDiff();\nexport function diffWordsWithSpace(oldStr, newStr, options) {\n return wordsWithSpaceDiff.diff(oldStr, newStr, options);\n}\n","import Diff from './base.js';\nimport { generateOptions } from '../util/params.js';\nclass LineDiff extends Diff {\n constructor() {\n super(...arguments);\n this.tokenize = tokenize;\n }\n equals(left, right, options) {\n // If we're ignoring whitespace, we need to normalise lines by stripping\n // whitespace before checking equality. (This has an annoying interaction\n // with newlineIsToken that requires special handling: if newlines get their\n // own token, then we DON'T want to trim the *newline* tokens down to empty\n // strings, since this would cause us to treat whitespace-only line content\n // as equal to a separator between lines, which would be weird and\n // inconsistent with the documented behavior of the options.)\n if (options.ignoreWhitespace) {\n if (!options.newlineIsToken || !left.includes('\\n')) {\n left = left.trim();\n }\n if (!options.newlineIsToken || !right.includes('\\n')) {\n right = right.trim();\n }\n }\n else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {\n if (left.endsWith('\\n')) {\n left = left.slice(0, -1);\n }\n if (right.endsWith('\\n')) {\n right = right.slice(0, -1);\n }\n }\n return super.equals(left, right, options);\n }\n}\nexport const lineDiff = new LineDiff();\nexport function diffLines(oldStr, newStr, options) {\n return lineDiff.diff(oldStr, newStr, options);\n}\nexport function diffTrimmedLines(oldStr, newStr, options) {\n options = generateOptions(options, { ignoreWhitespace: true });\n return lineDiff.diff(oldStr, newStr, options);\n}\n// Exported standalone so it can be used from jsonDiff too.\nexport function tokenize(value, options) {\n if (options.stripTrailingCr) {\n // remove one \\r before \\n to match GNU diff's --strip-trailing-cr behavior\n value = value.replace(/\\r\\n/g, '\\n');\n }\n const retLines = [], linesAndNewlines = value.split(/(\\n|\\r\\n)/);\n // Ignore the final empty token that occurs if the string ends with a new line\n if (!linesAndNewlines[linesAndNewlines.length - 1]) {\n linesAndNewlines.pop();\n }\n // Merge the content and line separators into single tokens\n for (let i = 0; i < linesAndNewlines.length; i++) {\n const line = linesAndNewlines[i];\n if (i % 2 && !options.newlineIsToken) {\n retLines[retLines.length - 1] += line;\n }\n else {\n retLines.push(line);\n }\n }\n return retLines;\n}\n","import Diff from './base.js';\nfunction isSentenceEndPunct(char) {\n return char == '.' || char == '!' || char == '?';\n}\nclass SentenceDiff extends Diff {\n tokenize(value) {\n var _a;\n // If in future we drop support for environments that don't support lookbehinds, we can replace\n // this entire function with:\n // return value.split(/(?<=[.!?])(\\s+|$)/);\n // but until then, for similar reasons to the trailingWs function in string.ts, we are forced\n // to do this verbosely \"by hand\" instead of using a regex.\n const result = [];\n let tokenStartI = 0;\n for (let i = 0; i < value.length; i++) {\n if (i == value.length - 1) {\n result.push(value.slice(tokenStartI));\n break;\n }\n if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\\s/)) {\n // We've hit a sentence break - i.e. a punctuation mark followed by whitespace.\n // We now want to push TWO tokens to the result:\n // 1. the sentence\n result.push(value.slice(tokenStartI, i + 1));\n // 2. the whitespace\n i = tokenStartI = i + 1;\n while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\\s/)) {\n i++;\n }\n result.push(value.slice(tokenStartI, i + 1));\n // Then the next token (a sentence) starts on the character after the whitespace.\n // (It's okay if this is off the end of the string - then the outer loop will terminate\n // here anyway.)\n tokenStartI = i + 1;\n }\n }\n return result;\n }\n}\nexport const sentenceDiff = new SentenceDiff();\nexport function diffSentences(oldStr, newStr, options) {\n return sentenceDiff.diff(oldStr, newStr, options);\n}\n","import Diff from './base.js';\nclass CssDiff extends Diff {\n tokenize(value) {\n return value.split(/([{}:;,]|\\s+)/);\n }\n}\nexport const cssDiff = new CssDiff();\nexport function diffCss(oldStr, newStr, options) {\n return cssDiff.diff(oldStr, newStr, options);\n}\n","import Diff from './base.js';\nimport { tokenize } from './line.js';\nclass JsonDiff extends Diff {\n constructor() {\n super(...arguments);\n this.tokenize = tokenize;\n }\n get useLongestToken() {\n // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a\n // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:\n return true;\n }\n castInput(value, options) {\n const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === 'undefined' ? undefinedReplacement : v } = options;\n return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, ' ');\n }\n equals(left, right, options) {\n return super.equals(left.replace(/,([\\r\\n])/g, '$1'), right.replace(/,([\\r\\n])/g, '$1'), options);\n }\n}\nexport const jsonDiff = new JsonDiff();\nexport function diffJson(oldStr, newStr, options) {\n return jsonDiff.diff(oldStr, newStr, options);\n}\n// This function handles the presence of circular references by bailing out when encountering an\n// object that is already on the \"stack\" of items being processed. Accepts an optional replacer\nexport function canonicalize(obj, stack, replacementStack, replacer, key) {\n stack = stack || [];\n replacementStack = replacementStack || [];\n if (replacer) {\n obj = replacer(key === undefined ? '' : key, obj);\n }\n let i;\n for (i = 0; i < stack.length; i += 1) {\n if (stack[i] === obj) {\n return replacementStack[i];\n }\n }\n let canonicalizedObj;\n if ('[object Array]' === Object.prototype.toString.call(obj)) {\n stack.push(obj);\n canonicalizedObj = new Array(obj.length);\n replacementStack.push(canonicalizedObj);\n for (i = 0; i < obj.length; i += 1) {\n canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));\n }\n stack.pop();\n replacementStack.pop();\n return canonicalizedObj;\n }\n if (obj && obj.toJSON) {\n obj = obj.toJSON();\n }\n if (typeof obj === 'object' && obj !== null) {\n stack.push(obj);\n canonicalizedObj = {};\n replacementStack.push(canonicalizedObj);\n const sortedKeys = [];\n let key;\n for (key in obj) {\n /* istanbul ignore else */\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n sortedKeys.push(key);\n }\n }\n sortedKeys.sort();\n for (i = 0; i < sortedKeys.length; i += 1) {\n key = sortedKeys[i];\n canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key);\n }\n stack.pop();\n replacementStack.pop();\n }\n else {\n canonicalizedObj = obj;\n }\n return canonicalizedObj;\n}\n","import Diff from './base.js';\nclass ArrayDiff extends Diff {\n tokenize(value) {\n return value.slice();\n }\n join(value) {\n return value;\n }\n removeEmpty(value) {\n return value;\n }\n}\nexport const arrayDiff = new ArrayDiff();\nexport function diffArrays(oldArr, newArr, options) {\n return arrayDiff.diff(oldArr, newArr, options);\n}\n","import { diffLines } from '../diff/line.js';\n/**\n * Returns true if the filename contains characters that require C-style\n * quoting (as used by Git and GNU diffutils in diff output).\n */\nfunction needsQuoting(s) {\n for (let i = 0; i < s.length; i++) {\n if (s[i] < '\\x20' || s[i] > '\\x7e' || s[i] === '\"' || s[i] === '\\\\') {\n return true;\n }\n }\n return false;\n}\n/**\n * C-style quotes a filename, encoding special characters as escape sequences\n * and non-ASCII bytes as octal escapes. This is the inverse of\n * `parseQuotedFileName` in parse.ts.\n *\n * Non-ASCII bytes are encoded as UTF-8 before being emitted as octal escapes.\n * This matches the behaviour of both Git and GNU diffutils, which always emit\n * UTF-8 octal escapes regardless of the underlying filesystem encoding (e.g.\n * Git for Windows converts from NTFS's UTF-16 to UTF-8 internally).\n *\n * If the filename doesn't need quoting, returns it as-is.\n */\nfunction quoteFileNameIfNeeded(s) {\n if (!needsQuoting(s)) {\n return s;\n }\n let result = '\"';\n const bytes = new TextEncoder().encode(s);\n let i = 0;\n while (i < bytes.length) {\n const b = bytes[i];\n // See https://en.wikipedia.org/wiki/Escape_sequences_in_C#Escape_sequences\n if (b === 0x07) {\n result += '\\\\a';\n }\n else if (b === 0x08) {\n result += '\\\\b';\n }\n else if (b === 0x09) {\n result += '\\\\t';\n }\n else if (b === 0x0a) {\n result += '\\\\n';\n }\n else if (b === 0x0b) {\n result += '\\\\v';\n }\n else if (b === 0x0c) {\n result += '\\\\f';\n }\n else if (b === 0x0d) {\n result += '\\\\r';\n }\n else if (b === 0x22) {\n result += '\\\\\"';\n }\n else if (b === 0x5c) {\n result += '\\\\\\\\';\n }\n else if (b >= 0x20 && b <= 0x7e) {\n // Just a printable ASCII character that is neither a double quote nor a\n // backslash; no need to escape it.\n result += String.fromCharCode(b);\n }\n else {\n // Either part of a non-ASCII character or a control character without a\n // special escape sequence; needs escaping as a 3-digit octal escape\n result += '\\\\' + b.toString(8).padStart(3, '0');\n }\n i++;\n }\n result += '\"';\n return result;\n}\nexport const INCLUDE_HEADERS = {\n includeIndex: true,\n includeUnderline: true,\n includeFileHeaders: true\n};\nexport const FILE_HEADERS_ONLY = {\n includeIndex: false,\n includeUnderline: false,\n includeFileHeaders: true\n};\nexport const OMIT_HEADERS = {\n includeIndex: false,\n includeUnderline: false,\n includeFileHeaders: false\n};\nexport function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {\n let optionsObj;\n if (!options) {\n optionsObj = {};\n }\n else if (typeof options === 'function') {\n optionsObj = { callback: options };\n }\n else {\n optionsObj = options;\n }\n if (typeof optionsObj.context === 'undefined') {\n optionsObj.context = 4;\n }\n // We copy this into its own variable to placate TypeScript, which thinks\n // optionsObj.context might be undefined in the callbacks below.\n const context = optionsObj.context;\n // @ts-expect-error (runtime check for something that is correctly a static type error)\n if (optionsObj.newlineIsToken) {\n throw new Error('newlineIsToken may not be used with patch-generation functions, only with diffing functions');\n }\n if (!optionsObj.callback) {\n return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));\n }\n else {\n const { callback } = optionsObj;\n diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {\n const patch = diffLinesResultToPatch(diff);\n // TypeScript is unhappy without the cast because it does not understand that `patch` may\n // be undefined here only if `callback` is StructuredPatchCallbackAbortable:\n callback(patch);\n } }));\n }\n function diffLinesResultToPatch(diff) {\n // STEP 1: Build up the patch with no \"\\" lines and with the arrays\n // of lines containing trailing newline characters. We'll tidy up later...\n if (!diff) {\n return;\n }\n diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier\n function contextLines(lines) {\n return lines.map(function (entry) { return ' ' + entry; });\n }\n const hunks = [];\n let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;\n for (let i = 0; i < diff.length; i++) {\n const current = diff[i], lines = current.lines || splitLines(current.value);\n current.lines = lines;\n if (current.added || current.removed) {\n // If we have previous context, start with that\n if (!oldRangeStart) {\n const prev = diff[i - 1];\n oldRangeStart = oldLine;\n newRangeStart = newLine;\n if (prev) {\n curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];\n oldRangeStart -= curRange.length;\n newRangeStart -= curRange.length;\n }\n }\n // Output our changes\n for (const line of lines) {\n curRange.push((current.added ? '+' : '-') + line);\n }\n // Track the updated file position\n if (current.added) {\n newLine += lines.length;\n }\n else {\n oldLine += lines.length;\n }\n }\n else {\n // Identical context lines. Track line changes\n if (oldRangeStart) {\n // Close out any changes that have been output (or join overlapping)\n if (lines.length <= context * 2 && i < diff.length - 2) {\n // Overlapping\n for (const line of contextLines(lines)) {\n curRange.push(line);\n }\n }\n else {\n // end the range and output\n const contextSize = Math.min(lines.length, context);\n for (const line of contextLines(lines.slice(0, contextSize))) {\n curRange.push(line);\n }\n const hunk = {\n oldStart: oldRangeStart,\n oldLines: (oldLine - oldRangeStart + contextSize),\n newStart: newRangeStart,\n newLines: (newLine - newRangeStart + contextSize),\n lines: curRange\n };\n hunks.push(hunk);\n oldRangeStart = 0;\n newRangeStart = 0;\n curRange = [];\n }\n }\n oldLine += lines.length;\n newLine += lines.length;\n }\n }\n // Step 2: eliminate the trailing `\\n` from each line of each hunk, and, where needed, add\n // \"\\".\n for (const hunk of hunks) {\n for (let i = 0; i < hunk.lines.length; i++) {\n if (hunk.lines[i].endsWith('\\n')) {\n hunk.lines[i] = hunk.lines[i].slice(0, -1);\n }\n else {\n hunk.lines.splice(i + 1, 0, '\\\');\n i++; // Skip the line we just added, then continue iterating\n }\n }\n }\n return {\n oldFileName: oldFileName, newFileName: newFileName,\n oldHeader: oldHeader, newHeader: newHeader,\n hunks: hunks\n };\n }\n}\n/**\n * creates a unified diff patch.\n *\n * @param patch either a single structured patch object (as returned by `structuredPatch`) or an\n * array of them (as returned by `parsePatch`).\n * @param headerOptions behaves the same as the `headerOptions` option of `createTwoFilesPatch`.\n * Ignored for patches where `isGit` is `true`.\n *\n * When a patch has `isGit: true`, `formatPatch` output is changed to more closely match Git's\n * output: it emits a `diff --git` header, emits Git extended headers as appropriate based on\n * properties like `isRename`, `isCreate`, `newMode`, etc, and will omit `---`/`+++` file\n * headers for patches with no hunks (e.g. renames without content changes).\n */\nexport function formatPatch(patch, headerOptions) {\n var _a, _b, _c, _d, _e, _f;\n if (!headerOptions) {\n headerOptions = INCLUDE_HEADERS;\n }\n if (Array.isArray(patch)) {\n if (patch.length > 1 && !headerOptions.includeFileHeaders && !patch.every(p => p.isGit)) {\n throw new Error('Cannot omit file headers on a multi-file patch. '\n + '(The result would be unparseable; how would a tool trying to apply '\n + 'the patch know which changes are to which file?)');\n }\n return patch.map(p => formatPatch(p, headerOptions)).join('\\n');\n }\n const ret = [];\n // Git patches have a fixed header format (diff --git, extended headers,\n // and ---/+++ when hunks are present), so headerOptions is ignored.\n if (patch.isGit) {\n headerOptions = INCLUDE_HEADERS;\n // Emit Git-style diff --git header and extended headers.\n // Git never puts /dev/null in the \"diff --git\" line; for file\n // creations/deletions it uses the real filename on both sides.\n if (!patch.oldFileName) {\n throw new Error('oldFileName must be specified for Git patches');\n }\n if (!patch.newFileName) {\n throw new Error('newFileName must be specified for Git patches');\n }\n let gitOldName = patch.oldFileName;\n let gitNewName = patch.newFileName;\n if (patch.isCreate && gitOldName === '/dev/null') {\n gitOldName = gitNewName.replace(/^b\\//, 'a/');\n }\n else if (patch.isDelete && gitNewName === '/dev/null') {\n gitNewName = gitOldName.replace(/^a\\//, 'b/');\n }\n ret.push('diff --git ' + quoteFileNameIfNeeded(gitOldName) + ' ' + quoteFileNameIfNeeded(gitNewName));\n if (patch.isDelete) {\n ret.push('deleted file mode ' + ((_a = patch.oldMode) !== null && _a !== void 0 ? _a : '100644'));\n }\n if (patch.isCreate) {\n ret.push('new file mode ' + ((_b = patch.newMode) !== null && _b !== void 0 ? _b : '100644'));\n }\n if (patch.oldMode && patch.newMode && !patch.isDelete && !patch.isCreate) {\n ret.push('old mode ' + patch.oldMode);\n ret.push('new mode ' + patch.newMode);\n }\n if (patch.isRename) {\n ret.push('rename from ' + quoteFileNameIfNeeded(((_c = patch.oldFileName) !== null && _c !== void 0 ? _c : '').replace(/^a\\//, '')));\n ret.push('rename to ' + quoteFileNameIfNeeded(((_d = patch.newFileName) !== null && _d !== void 0 ? _d : '').replace(/^b\\//, '')));\n }\n if (patch.isCopy) {\n ret.push('copy from ' + quoteFileNameIfNeeded(((_e = patch.oldFileName) !== null && _e !== void 0 ? _e : '').replace(/^a\\//, '')));\n ret.push('copy to ' + quoteFileNameIfNeeded(((_f = patch.newFileName) !== null && _f !== void 0 ? _f : '').replace(/^b\\//, '')));\n }\n }\n else {\n if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName && patch.oldFileName !== undefined) {\n ret.push('Index: ' + patch.oldFileName);\n }\n if (headerOptions.includeUnderline) {\n ret.push('===================================================================');\n }\n }\n // Emit --- / +++ file headers. For Git patches with no hunks (e.g.\n // pure renames, mode-only changes), Git omits these, so we do too.\n const hasHunks = patch.hunks.length > 0;\n if (headerOptions.includeFileHeaders && patch.oldFileName !== undefined && patch.newFileName !== undefined\n && (!patch.isGit || hasHunks)) {\n ret.push('--- ' + quoteFileNameIfNeeded(patch.oldFileName) + (patch.oldHeader ? '\\t' + patch.oldHeader : ''));\n ret.push('+++ ' + quoteFileNameIfNeeded(patch.newFileName) + (patch.newHeader ? '\\t' + patch.newHeader : ''));\n }\n for (let i = 0; i < patch.hunks.length; i++) {\n const hunk = patch.hunks[i];\n // Unified Diff Format quirk: If the chunk size is 0,\n // the first number is one lower than one would expect.\n // https://www.artima.com/weblogs/viewpost.jsp?thread=164293\n const oldStart = hunk.oldLines === 0 ? hunk.oldStart - 1 : hunk.oldStart;\n const newStart = hunk.newLines === 0 ? hunk.newStart - 1 : hunk.newStart;\n ret.push('@@ -' + oldStart + ',' + hunk.oldLines\n + ' +' + newStart + ',' + hunk.newLines\n + ' @@');\n for (const line of hunk.lines) {\n ret.push(line);\n }\n }\n return ret.join('\\n') + '\\n';\n}\nexport function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {\n if (typeof options === 'function') {\n options = { callback: options };\n }\n if (!(options === null || options === void 0 ? void 0 : options.callback)) {\n const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);\n if (!patchObj) {\n return;\n }\n return formatPatch(patchObj, options === null || options === void 0 ? void 0 : options.headerOptions);\n }\n else {\n const { callback } = options;\n structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: patchObj => {\n if (!patchObj) {\n callback(undefined);\n }\n else {\n callback(formatPatch(patchObj, options.headerOptions));\n }\n } }));\n }\n}\nexport function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {\n return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);\n}\n/**\n * Split `text` into an array of lines, including the trailing newline character (where present)\n */\nfunction splitLines(text) {\n const hasTrailingNl = text.endsWith('\\n');\n const result = text.split('\\n').map(line => line + '\\n');\n if (hasTrailingNl) {\n result.pop();\n }\n else {\n result.push(result.pop().slice(0, -1));\n }\n return result;\n}\n","import { composeCacheKey } from \"./composeCacheKey.js\";\nimport { processFile } from \"./parsePatchFiles.js\";\nimport { createTwoFilesPatch } from \"diff\";\n//#region src/utils/parseDiffFromFile.ts\nconst MISSING_FILE_NAME = \"/dev/null\";\n/**\n* Parses a diff from two file contents objects.\n*\n* If both `oldFile` and `newFile` have a `cacheKey`, the resulting diff gets a\n* collision-safe key derived from both values.\n*/\nfunction parseDiffFromFile(oldFile, newFile, options, throwOnError = false) {\n\tif (oldFile === null && newFile === null) throw new Error(\"parseDiffFromFile: You must pass oldFile, newFile, or both\");\n\tconst resolvedOldFile = oldFile ?? createMissingFile();\n\tconst resolvedNewFile = newFile ?? createMissingFile();\n\tconst patch = createTwoFilesPatch(resolvedOldFile.name, resolvedNewFile.name, resolvedOldFile.contents, resolvedNewFile.contents, resolvedOldFile.header, resolvedNewFile.header, options);\n\tconst fileData = processFile(patch, {\n\t\tcacheKey: (() => {\n\t\t\tconst oldCacheKey = oldFile?.cacheKey;\n\t\t\tconst newCacheKey = newFile?.cacheKey;\n\t\t\treturn oldCacheKey != null && newCacheKey != null ? composeCacheKey(\"diff\", oldCacheKey, newCacheKey) : void 0;\n\t\t})(),\n\t\toldFile: resolvedOldFile,\n\t\tnewFile: resolvedNewFile,\n\t\tthrowOnError\n\t});\n\tif (fileData == null) throw new Error(\"parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?\");\n\tif (oldFile === null) {\n\t\tfileData.type = \"new\";\n\t\tfileData.prevName = void 0;\n\t} else if (newFile === null) {\n\t\tfileData.type = \"deleted\";\n\t\tfileData.prevName = void 0;\n\t}\n\tconst language = newFile?.lang ?? (newFile === null ? oldFile?.lang : void 0);\n\tif (language != null) fileData.lang = language;\n\treturn fileData;\n}\nfunction createMissingFile() {\n\treturn {\n\t\tname: MISSING_FILE_NAME,\n\t\tcontents: \"\"\n\t};\n}\n//#endregion\nexport { parseDiffFromFile };\n\n//# sourceMappingURL=parseDiffFromFile.js.map","import * as Predicate from \"./predicates.js\"\n/** Preserve literal variant keys without type assertions. */\nexport const defineVariants = <const Variants>(variants: Variants): Variants => variants\n\n/** Resolve a required generated CSS Module class and fail loudly on drift. */\nexport const cssClass = (sheet: Readonly<Record<string, string>>, name: string): string => {\n const value = sheet[name]\n if (value === undefined) throw new Error(`Missing CSS Module class: ${name}`)\n return value\n}\n\n/** Join owned component classes with an optional consumer class. */\nexport const classNames = (...values: ReadonlyArray<string | undefined | false>): string =>\n values.filter((value): value is string => Predicate.isString(value) && value.length > 0).join(\" \")\n\n/** Enforce runtime text invariants that TypeScript cannot express. */\nexport const requireText = (value: string, label: string): string => {\n if (value.trim().length === 0) throw new Error(`${label} must contain visible text`)\n return value\n}\n","import { type RefCallback, useCallback, useState } from \"react\"\n\n/** Below this container width a side-by-side diff leaves each code column too narrow to read. */\nexport const RLY_SPLIT_DIFF_MIN_WIDTH = 720\n\n/**\n * Whether the element is laid out narrower than `width`, kept current with a ResizeObserver from the\n * element's own window. It measures in the commit phase, before paint, so a layout chosen from it\n * never shifts. An element not laid out yet (width 0, or no layout engine) counts as wide.\n */\nexport const useNarrowerThan = <E extends Element>(width: number): readonly [boolean, RefCallback<E>] => {\n const [narrow, setNarrow] = useState(false)\n const ref = useCallback(\n (element: E | null) => {\n if (element === null) return\n const measure = (): void => {\n const measured = element.getBoundingClientRect().width\n setNarrow(measured > 0 && measured < width)\n }\n measure()\n const view = element.ownerDocument.defaultView\n if (view === null || !(\"ResizeObserver\" in view)) return\n const observer = new view.ResizeObserver(measure)\n observer.observe(element)\n return () => observer.disconnect()\n },\n [width]\n )\n return [narrow, ref]\n}\n","interface RenderedDiffLineLocation {\n readonly lineNumber: number\n readonly side: \"additions\" | \"deletions\"\n}\n\n/** Resolve one Pierre renderer line across split, stacked, and alternate-line presentations. */\nexport const renderedDiffLine = (\n container: Element,\n location: RenderedDiffLineLocation\n): HTMLElement | null => {\n const root = container.shadowRoot\n if (root === null) return null\n\n const sideContainer = location.side === \"additions\" ? \"data-additions\" : \"data-deletions\"\n const type = location.side === \"additions\" ? \"change-addition\" : \"change-deletion\"\n const contextLine = location.side === \"additions\" ? \"data-line\" : \"data-alt-line\"\n return (\n root.querySelector<HTMLElement>(`[${sideContainer}] [data-line=\"${location.lineNumber}\"]`) ??\n root.querySelector<HTMLElement>(`[data-line=\"${location.lineNumber}\"][data-line-type=\"${type}\"]`) ??\n root.querySelector<HTMLElement>(`[${contextLine}=\"${location.lineNumber}\"][data-line-type=\"context\"]`) ??\n root.querySelector<HTMLElement>(`[${contextLine}=\"${location.lineNumber}\"][data-line-type=\"context-expanded\"]`) ??\n root.querySelector<HTMLElement>(`[${sideContainer}] [data-alt-line=\"${location.lineNumber}\"]`) ??\n root.querySelector<HTMLElement>(`[${sideContainer}][data-line=\"${location.lineNumber}\"]`) ??\n root.querySelector<HTMLElement>(`[${sideContainer}][data-alt-line=\"${location.lineNumber}\"]`)\n )\n}\n","\"use client\"\n\nimport { createElement, type KeyboardEvent, type ReactElement, useRef } from \"react\"\nimport { renderedDiffLine } from \"./rendered-line.js\"\nimport type { RlyDiffCodeAnnotation, RlyDiffCodeAnnotationLocation } from \"./types.js\"\n\ninterface DiffCodeAnnotationProps {\n readonly annotation: RlyDiffCodeAnnotation\n readonly className: string\n readonly returnFocus?: () => void\n}\n\nconst pierreLine = (annotationNode: HTMLDivElement, location: RlyDiffCodeAnnotationLocation): HTMLElement | null => {\n const item = annotationNode.closest(\"diffs-container\")\n return item === null ? null : renderedDiffLine(item, location)\n}\n\nconst focusLine = (annotationNode: HTMLDivElement, location: RlyDiffCodeAnnotationLocation): void => {\n const line = pierreLine(annotationNode, location)\n if (line === null) return\n line.tabIndex = -1\n line.focus({ preventScroll: true })\n}\n\n/** Keyboard boundary shared by virtualized and bounded annotation presentations. */\nexport const DiffCodeAnnotation = ({\n annotation,\n className,\n returnFocus\n}: DiffCodeAnnotationProps): ReactElement => {\n const annotationRef = useRef<HTMLDivElement>(null)\n const restoreLineFocus = (): void => {\n if (returnFocus !== undefined) {\n returnFocus()\n return\n }\n if (annotationRef.current !== null) focusLine(annotationRef.current, annotation.location)\n }\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n if (event.key !== \"Escape\") return\n event.preventDefault()\n event.stopPropagation()\n restoreLineFocus()\n }\n\n return createElement(\n \"div\",\n {\n ref: annotationRef,\n \"aria-label\": annotation.accessibilityLabel,\n className,\n \"data-rly-diff-annotation\": annotation.id,\n \"data-rly-diff-annotation-item\": annotation.location.itemId,\n \"data-rly-diff-annotation-line\": annotation.location.lineNumber,\n \"data-rly-diff-annotation-side\": annotation.location.side,\n onKeyDown: handleKeyDown,\n role: \"group\",\n tabIndex: 0\n },\n annotation.render({\n annotationId: annotation.id,\n location: annotation.location,\n returnFocus: restoreLineFocus\n })\n )\n}\n\n/** Validate public annotations before either renderer crosses into implementation code. */\nexport const requireDiffCodeAnnotations = (annotations: ReadonlyArray<RlyDiffCodeAnnotation>): void => {\n const ids = new Set<string>()\n for (const annotation of annotations) {\n if (annotation.id.trim().length === 0 || annotation.accessibilityLabel.trim().length === 0) {\n throw new Error(\"Diff annotation id and accessibility label must not be blank\")\n }\n if (annotation.location.itemId.trim().length === 0) {\n throw new Error(`Diff annotation ${annotation.id} location item id must not be blank`)\n }\n if (!Number.isInteger(annotation.location.lineNumber) || annotation.location.lineNumber < 1) {\n throw new Error(`Diff annotation ${annotation.id} line number must be a positive integer`)\n }\n if (ids.has(annotation.id)) throw new Error(`Diff annotation id ${annotation.id} must be unique`)\n ids.add(annotation.id)\n }\n}\n",".root {\n overflow: hidden;\n border: 1px solid var(--rly-color-border-1);\n border-radius: var(--rly-radius-field);\n background: var(--rly-color-surface-1);\n color: var(--rly-color-text-1);\n}\n\n.file + .file {\n border-top: 1px solid var(--rly-color-border-1);\n}\n\n.noChanges {\n margin: 0;\n padding: var(--rly-space-16);\n color: var(--rly-color-text-2);\n font: var(--rly-type-body-weight) var(--rly-type-body-size) / var(--rly-type-body-line-height)\n var(--rly-type-body-font);\n}\n\n.fileName {\n margin: 0;\n padding: var(--rly-space-12) var(--rly-space-16);\n border-bottom: 1px solid var(--rly-color-border-1);\n font: var(--rly-type-label-weight) var(--rly-type-label-size) / var(--rly-type-label-line-height)\n var(--rly-type-label-font);\n}\n\n.scroller {\n max-height: min(70vh, 56rem);\n overflow: auto;\n}\n\n.table {\n width: 100%;\n border-spacing: 0;\n border-collapse: collapse;\n font-family: var(--rly-font-mono);\n font-size: 0.78rem;\n line-height: 1.55;\n}\n\n.table td {\n min-width: 0;\n padding: 0;\n vertical-align: top;\n}\n\n.hunk td {\n padding: var(--rly-space-4) var(--rly-space-12);\n border-block: 1px solid var(--rly-color-border-1);\n background: var(--rly-color-surface-2);\n color: var(--rly-color-text-2);\n}\n\n.lineNumber {\n width: 3.25rem;\n /* Room either side of the number, so the column rule reads as one rule, not a box per line. */\n padding-inline: var(--rly-space-8) var(--rly-space-6) !important;\n border-right: 1px solid var(--rly-color-border-1);\n color: var(--rly-color-text-3);\n text-align: right;\n user-select: none;\n}\n\n.marker {\n width: 1.5rem;\n color: var(--rly-color-text-3);\n text-align: center;\n user-select: none;\n}\n\n.code,\n.wrappedCode {\n display: block;\n min-height: 1.55em;\n padding-inline: var(--rly-space-12);\n white-space: pre;\n}\n\n.wrappedCode {\n white-space: pre-wrap;\n overflow-wrap: break-word;\n}\n\n/*\n * In an auto-sized table a long token would widen its column rather than wrap. Capping the wrapped\n * code cell at zero and letting it take the remaining width bounds it to the viewport, so\n * break-word can wrap a 200-character string; unwrapped views keep their horizontal scroll.\n */\n.table td:has(> .wrappedCode) {\n inline-size: 100%;\n max-inline-size: 0;\n}\n\n.deletion > td,\n.change .deletionCode {\n background: var(--rly-color-blocked-tint);\n}\n\n.addition > td,\n.change .additionCode {\n background: var(--rly-color-success-tint);\n}\n\n.deletion .lineNumber,\n.addition .lineNumber,\n.deletion .marker,\n.addition .marker {\n color: var(--rly-color-text-2);\n}\n\n.context > td {\n background: var(--rly-color-surface-1);\n}\n\n.deletionCode,\n.additionCode {\n width: 50%;\n border-right: 1px solid var(--rly-color-border-1);\n}\n\n.annotationRow > td {\n background: var(--rly-color-surface-2);\n border-block: 1px solid var(--rly-color-border-1);\n}\n\n.annotationRow > .annotationCell {\n padding: var(--rly-space-8);\n}\n\n.annotation {\n background: var(--rly-color-held-tint);\n border: 1px solid color-mix(in oklab, var(--rly-color-held-ink) 35%, transparent);\n border-radius: var(--rly-radius-tag);\n color: var(--rly-color-text-1);\n font: var(--rly-type-label-weight) var(--rly-type-label-size) / var(--rly-type-label-line-height)\n var(--rly-type-label-font);\n padding: var(--rly-space-8) var(--rly-space-12);\n}\n\n.annotation:focus-visible,\n[data-rly-diff-line]:focus-visible {\n outline: var(--rly-focus-ring-width) solid var(--rly-color-focus);\n outline-offset: var(--rly-focus-ring-offset);\n}\n\n@media (forced-colors: active) {\n .annotation,\n [data-rly-diff-line]:focus-visible {\n forced-color-adjust: auto;\n }\n}\n\n/*\n * Forced colours drop the add/remove tints. Split cells have no marker column, so a changed cell\n * gets its sign drawn before the code (hidden from assistive technology, which reads the column).\n */\n@media (forced-colors: active) {\n .change .deletionCode > :is(.code, .wrappedCode)::before {\n content: \"− \" / \"\";\n }\n .change .additionCode > :is(.code, .wrappedCode)::before {\n content: \"+ \" / \"\";\n }\n}\n\n:where([data-forced-colors=\"active\"], [data-rly-forced-colors=\"active\"])\n .change\n .deletionCode\n > :is(.code, .wrappedCode)::before {\n content: \"− \" / \"\";\n}\n:where([data-forced-colors=\"active\"], [data-rly-forced-colors=\"active\"])\n .change\n .additionCode\n > :is(.code, .wrappedCode)::before {\n content: \"+ \" / \"\";\n}\n","\"use client\"\n\nimport {\n type ChangeContent,\n type ContextContent,\n type FileDiffMetadata,\n type Hunk,\n parseDiffFromFile\n} from \"@pierre/diffs\"\nimport { Fragment, type ReactElement, type ReactNode, useCallback, useRef } from \"react\"\nimport { cssClass } from \"../../internal/component.js\"\nimport { RLY_SPLIT_DIFF_MIN_WIDTH, useNarrowerThan } from \"../../internal/useNarrowerThan.js\"\nimport { DiffCodeAnnotation, requireDiffCodeAnnotations } from \"../annotation.js\"\nimport type { RlyDiffCodeAnnotation, RlyDiffCodeItem } from \"../types.js\"\nimport styles from \"./BoundedDiffCodeView.module.css\"\n\nexport type {\n RlyDiffCodeAnnotation,\n RlyDiffCodeAnnotationLocation,\n RlyDiffCodeAnnotationRenderContext,\n RlyDiffCodeItem\n} from \"../types.js\"\n\ntype BoundedDiffMode = \"split\" | \"stacked\"\n\ninterface BoundedAnnotationLocation {\n readonly lineNumber: number\n readonly side: \"additions\" | \"deletions\"\n}\n\nconst boundedAnnotationLocation = (\n lineNumber: number,\n side: BoundedAnnotationLocation[\"side\"]\n): BoundedAnnotationLocation => ({ lineNumber, side })\n\ninterface DiffLine {\n readonly content: string\n readonly number: number\n}\n\ntype SplitRow =\n | {\n readonly addition?: DiffLine\n readonly deletion?: DiffLine\n readonly kind: \"change\" | \"context\"\n }\n | {\n readonly kind: \"hunk\"\n readonly label: string\n }\n\ntype UnifiedRow =\n | {\n readonly additionNumber?: number\n readonly content: string\n readonly deletionNumber?: number\n readonly kind: \"addition\" | \"context\" | \"deletion\"\n }\n | {\n readonly kind: \"hunk\"\n readonly label: string\n }\n\n/** Props for the strict-budget, main-thread line diff renderer. */\nexport interface BoundedDiffCodeViewProps {\n readonly annotations?: ReadonlyArray<RlyDiffCodeAnnotation>\n readonly className?: string\n readonly empty?: ReactNode\n readonly initialItems: ReadonlyArray<RlyDiffCodeItem>\n readonly mode?: BoundedDiffMode\n readonly wrap?: boolean\n}\n\nconst contentAt = (lines: ReadonlyArray<string>, index: number): string => lines[index]?.replace(/\\r?\\n$/, \"\") ?? \"\"\n\nconst hunkLabel = (hunk: Hunk): string =>\n hunk.hunkSpecs?.trim() ??\n `@@ -${hunk.deletionStart},${hunk.deletionCount} +${hunk.additionStart},${hunk.additionCount} @@`\n\nconst parseItem = (item: RlyDiffCodeItem): FileDiffMetadata | undefined => {\n if (item.before.contents === item.after.contents) return undefined\n return parseDiffFromFile(\n {\n ...(!(item.before.cacheKey === undefined) && { cacheKey: item.before.cacheKey }),\n contents: item.before.contents,\n name: item.before.name\n },\n {\n ...(!(item.after.cacheKey === undefined) && { cacheKey: item.after.cacheKey }),\n contents: item.after.contents,\n name: item.after.name\n },\n undefined,\n true\n )\n}\n\nconst contextSplitRows = (diff: FileDiffMetadata, content: ContextContent): ReadonlyArray<SplitRow> =>\n Array.from({ length: content.lines }, (_, offset) => ({\n addition: {\n content: contentAt(diff.additionLines, content.additionLineIndex + offset),\n number: content.additionLineIndex + offset + 1\n },\n deletion: {\n content: contentAt(diff.deletionLines, content.deletionLineIndex + offset),\n number: content.deletionLineIndex + offset + 1\n },\n kind: \"context\"\n }))\n\nconst changeSplitRows = (diff: FileDiffMetadata, content: ChangeContent): ReadonlyArray<SplitRow> =>\n Array.from({ length: Math.max(content.deletions, content.additions) }, (_, offset) => ({\n ...(offset < content.additions && {\n addition: {\n content: contentAt(diff.additionLines, content.additionLineIndex + offset),\n number: content.additionLineIndex + offset + 1\n }\n }),\n ...(offset < content.deletions && {\n deletion: {\n content: contentAt(diff.deletionLines, content.deletionLineIndex + offset),\n number: content.deletionLineIndex + offset + 1\n }\n }),\n kind: \"change\"\n }))\n\nconst splitRows = (diff: FileDiffMetadata): ReadonlyArray<SplitRow> =>\n diff.hunks.flatMap((hunk) => [\n { kind: \"hunk\", label: hunkLabel(hunk) },\n ...hunk.hunkContent.flatMap((content) =>\n content.type === \"context\" ? contextSplitRows(diff, content) : changeSplitRows(diff, content)\n )\n ])\n\nconst unifiedRows = (diff: FileDiffMetadata): ReadonlyArray<UnifiedRow> =>\n diff.hunks.flatMap((hunk) => [\n { kind: \"hunk\", label: hunkLabel(hunk) },\n ...hunk.hunkContent.flatMap((content): ReadonlyArray<UnifiedRow> => {\n if (content.type === \"context\") {\n return Array.from({ length: content.lines }, (_, offset) => ({\n additionNumber: content.additionLineIndex + offset + 1,\n content: contentAt(diff.additionLines, content.additionLineIndex + offset),\n deletionNumber: content.deletionLineIndex + offset + 1,\n kind: \"context\"\n }))\n }\n return [\n ...Array.from({ length: content.deletions }, (_, offset): UnifiedRow => ({\n content: contentAt(diff.deletionLines, content.deletionLineIndex + offset),\n deletionNumber: content.deletionLineIndex + offset + 1,\n kind: \"deletion\"\n })),\n ...Array.from({ length: content.additions }, (_, offset): UnifiedRow => ({\n additionNumber: content.additionLineIndex + offset + 1,\n content: contentAt(diff.additionLines, content.additionLineIndex + offset),\n kind: \"addition\"\n }))\n ]\n })\n ])\n\nconst code = (\n content: string,\n itemId: string,\n lineNumber: number,\n side: \"additions\" | \"deletions\",\n wrap: boolean,\n alternate?: { readonly lineNumber: number; readonly side: \"additions\" | \"deletions\" }\n): ReactElement => (\n <code\n className={wrap ? styles.wrappedCode : styles.code}\n data-rly-diff-item={itemId}\n {...(alternate === undefined\n ? {}\n : {\n \"data-rly-diff-line-alternate\": alternate.lineNumber,\n \"data-rly-diff-line-side-alternate\": alternate.side\n })}\n data-rly-diff-line={lineNumber}\n data-rly-diff-line-side={side}\n tabIndex={-1}\n >\n {content.length === 0 ? \" \" : content}\n </code>\n)\n\nconst focusBoundedLine = (\n root: HTMLDivElement | null,\n itemId: string,\n lineNumber: number,\n side: \"additions\" | \"deletions\"\n): void => {\n const item = `[data-rly-diff-item=\"${CSS.escape(itemId)}\"]`\n const line =\n root?.querySelector<HTMLElement>(\n `${item}[data-rly-diff-line=\"${lineNumber}\"][data-rly-diff-line-side=\"${side}\"]`\n ) ??\n root?.querySelector<HTMLElement>(\n `${item}[data-rly-diff-line-alternate=\"${lineNumber}\"][data-rly-diff-line-side-alternate=\"${side}\"]`\n )\n line?.focus({ preventScroll: true })\n}\n\nconst annotationsAt = (\n annotations: ReadonlyArray<RlyDiffCodeAnnotation>,\n itemId: string,\n lineNumber: number | undefined,\n side: \"additions\" | \"deletions\"\n): ReadonlyArray<RlyDiffCodeAnnotation> =>\n lineNumber === undefined\n ? []\n : annotations.filter(\n (annotation) =>\n annotation.location.itemId === itemId &&\n annotation.location.lineNumber === lineNumber &&\n annotation.location.side === side\n )\n\nconst splitAnnotationRows = (\n annotations: ReadonlyArray<RlyDiffCodeAnnotation>,\n itemId: string,\n row: Extract<SplitRow, { readonly kind: \"change\" | \"context\" }>,\n root: () => HTMLDivElement | null\n): ReadonlyArray<ReactElement> => [\n ...annotationsAt(annotations, itemId, row.deletion?.number, \"deletions\").map((annotation) => (\n <tr className={styles.annotationRow} key={annotation.id}>\n <td className={styles.annotationCell} colSpan={2}>\n <DiffCodeAnnotation\n annotation={annotation}\n className={cssClass(styles, \"annotation\")}\n returnFocus={() => focusBoundedLine(root(), itemId, annotation.location.lineNumber, annotation.location.side)}\n />\n </td>\n <td colSpan={2} />\n </tr>\n )),\n ...annotationsAt(annotations, itemId, row.addition?.number, \"additions\").map((annotation) => (\n <tr className={styles.annotationRow} key={annotation.id}>\n <td colSpan={2} />\n <td className={styles.annotationCell} colSpan={2}>\n <DiffCodeAnnotation\n annotation={annotation}\n className={cssClass(styles, \"annotation\")}\n returnFocus={() => focusBoundedLine(root(), itemId, annotation.location.lineNumber, annotation.location.side)}\n />\n </td>\n </tr>\n ))\n]\n\nconst renderSplit = (\n diff: FileDiffMetadata,\n itemId: string,\n annotations: ReadonlyArray<RlyDiffCodeAnnotation>,\n root: () => HTMLDivElement | null,\n wrap: boolean\n): ReactElement => (\n <table aria-label={`Changes in ${diff.name}`} className={styles.table}>\n <tbody>\n {splitRows(diff).map((row, index) =>\n row.kind === \"hunk\" ? (\n <tr className={styles.hunk} key={`${index}:${row.label}`}>\n <td colSpan={4}>{row.label}</td>\n </tr>\n ) : (\n <Fragment key={`${index}:${row.deletion?.number ?? \"\"}:${row.addition?.number ?? \"\"}`}>\n <tr className={styles[row.kind]}>\n <td className={styles.lineNumber}>{row.deletion?.number}</td>\n <td className={styles.deletionCode}>\n {row.deletion === undefined\n ? null\n : code(row.deletion.content, itemId, row.deletion.number, \"deletions\", wrap)}\n </td>\n <td className={styles.lineNumber}>{row.addition?.number}</td>\n <td className={styles.additionCode}>\n {row.addition === undefined\n ? null\n : code(row.addition.content, itemId, row.addition.number, \"additions\", wrap)}\n </td>\n </tr>\n {splitAnnotationRows(annotations, itemId, row, root)}\n </Fragment>\n )\n )}\n </tbody>\n </table>\n)\n\nconst unifiedAnnotationRows = (\n annotations: ReadonlyArray<RlyDiffCodeAnnotation>,\n itemId: string,\n row: Extract<UnifiedRow, { readonly kind: \"addition\" | \"context\" | \"deletion\" }>,\n root: () => HTMLDivElement | null\n): ReadonlyArray<ReactElement> => {\n const locations: ReadonlyArray<BoundedAnnotationLocation> = [\n ...(row.deletionNumber === undefined ? [] : [boundedAnnotationLocation(row.deletionNumber, \"deletions\")]),\n ...(row.additionNumber === undefined ? [] : [boundedAnnotationLocation(row.additionNumber, \"additions\")])\n ]\n return locations.flatMap(({ lineNumber, side }) =>\n annotationsAt(annotations, itemId, lineNumber, side).map((annotation) => (\n <tr className={styles.annotationRow} key={annotation.id}>\n <td className={styles.annotationCell} colSpan={4}>\n <DiffCodeAnnotation\n annotation={annotation}\n className={cssClass(styles, \"annotation\")}\n returnFocus={() => focusBoundedLine(root(), itemId, lineNumber, side)}\n />\n </td>\n </tr>\n ))\n )\n}\n\nconst renderUnified = (\n diff: FileDiffMetadata,\n itemId: string,\n annotations: ReadonlyArray<RlyDiffCodeAnnotation>,\n root: () => HTMLDivElement | null,\n wrap: boolean\n): ReactElement => (\n <table aria-label={`Changes in ${diff.name}`} className={styles.table}>\n <tbody>\n {unifiedRows(diff).map((row, index) =>\n row.kind === \"hunk\" ? (\n <tr className={styles.hunk} key={`${index}:${row.label}`}>\n <td colSpan={4}>{row.label}</td>\n </tr>\n ) : (\n <Fragment key={`${index}:${row.deletionNumber ?? \"\"}:${row.additionNumber ?? \"\"}`}>\n <tr className={styles[row.kind]}>\n <td className={styles.lineNumber}>{row.deletionNumber}</td>\n <td className={styles.lineNumber}>{row.additionNumber}</td>\n <td className={styles.marker}>{row.kind === \"addition\" ? \"+\" : row.kind === \"deletion\" ? \"−\" : \" \"}</td>\n <td>\n {code(\n row.content,\n itemId,\n row.kind === \"deletion\" ? (row.deletionNumber ?? 0) : (row.additionNumber ?? 0),\n row.kind === \"deletion\" ? \"deletions\" : \"additions\",\n wrap,\n row.kind === \"context\" && row.deletionNumber !== undefined\n ? { lineNumber: row.deletionNumber, side: \"deletions\" }\n : undefined\n )}\n </td>\n </tr>\n {unifiedAnnotationRows(annotations, itemId, row, root)}\n </Fragment>\n )\n )}\n </tbody>\n </table>\n)\n\n/**\n * Render complete line changes using Diffs' parser without syntax packs or a WASM worker.\n *\n * The public shape is deliberately small so syntax highlighting and virtualized rendering\n * can be added later without changing Control Center's diff data contract.\n */\nexport const BoundedDiffCodeView = ({\n annotations = [],\n className,\n empty = \"No renderable source changes.\",\n initialItems,\n mode = \"split\",\n wrap = false\n}: BoundedDiffCodeViewProps): ReactNode => {\n requireDiffCodeAnnotations(annotations)\n const rootRef = useRef<HTMLDivElement>(null)\n // A split view stacks in a narrow container, so neither side is clipped to a sliver.\n const [narrow, measureRef] = useNarrowerThan<HTMLDivElement>(RLY_SPLIT_DIFF_MIN_WIDTH)\n const attachRoot = useCallback(\n (element: HTMLDivElement | null) => {\n rootRef.current = element\n return measureRef(element)\n },\n [measureRef]\n )\n const shown: BoundedDiffMode = mode === \"split\" && narrow ? \"stacked\" : mode\n if (initialItems.length === 0) return <p className={className}>{empty}</p>\n\n return (\n <div\n ref={attachRoot}\n className={className === undefined ? cssClass(styles, \"root\") : `${cssClass(styles, \"root\")} ${className}`}\n data-rly-diff-code-view=\"\"\n data-rly-diff-mode={shown}\n >\n {initialItems.map((item) => {\n const diff = parseItem(item)\n if (diff === undefined) {\n return (\n <p className={styles.noChanges} key={item.id}>\n No textual changes in this file.\n </p>\n )\n }\n return (\n <section className={styles.file} key={item.id}>\n {initialItems.length > 1 ? <h3 className={styles.fileName}>{diff.name}</h3> : null}\n <div className={styles.scroller}>\n {shown === \"split\"\n ? renderSplit(diff, item.id, annotations, () => rootRef.current, wrap)\n : renderUnified(diff, item.id, annotations, () => rootRef.current, wrap)}\n </div>\n </section>\n )\n })}\n </div>\n )\n}\n"],"ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],"mappings":";;;OAEuC;CACtC,IAAI;EACH,OAAA,QAAA,IAAA,aAAgC;CACjC,QAAQ;EACP,OAAO;CACR;AACD,EAAA,CAAG;AAEH,IAAME,IAA4B,qBAK5BC,IAAwB,gCACxBC,IAAsB;AA0CI,OAAO,OAAO;CAC7C,WAAW;CACX,SAAS;AACV,CAAC;;;AC3DD,SAASC,EAAyB,GAAO,GAAO;CAC/C,OAAOC,KAASC,MAAU,IAAI,IAAI;AACnC;AACA,SAASC,EAAuB,GAAO,GAAO;CAC7C,OAAOH,EAAyBC,GAAOC,CAAK,IAAIA;AACjD;;;ACNA,IAAME,IAAoB;AAE1B,SAASC,EAAgB,GAAO,GAAGC,GAAU;CAC5C,OAAO,KAAKF,EAAkB,GAAG,KAAK,UAAU,CAACG,GAAO,GAAGD,CAAQ,CAAC;AACrE;;;ACJA,SAASE,EAAiB,GAAU;CACnC,IAAIC,IAAMC,EAAS;CAKnB,OAJIA,EAAS,WAAWD,IAAM,CAAC,MAAM,OACpC,KACIC,EAAS,WAAWD,IAAM,CAAC,MAAM,MAAI,MAEnCC,EAAS,MAAM,GAAGD,CAAG;AAC7B;;;ACPA,IAAME,IAAsB,IAAI,YAAY,GACtCC,IAAsB,IAAI,YAAY,SAAS,EAAE,WAAW,GAAK,CAAC,GAClEC,IAA8B,mBAC9BC,IAAoC,MACtCC,IAAqB,IAAI,WAAWD,CAAiC;AACzE,SAASE,IAA4B;CACpC,AAAID,EAAmB,WAAWD,MAAmC,IAAqB,IAAI,WAAWA,CAAiC;AAC3I;AACA,SAASG,EAAa,GAAO;CAC5B,IAAIC,EAAM,WAAW,GAAG,OAAOA;CAC/B,IAAIL,E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;EACE,KAAKH;EACL,WAAWI,MAAc,KAAA,IAAYhE,EAAS1U,GAAQ,MAAM,IAAI,GAAG0U,EAAS1U,GAAQ,MAAM,EAAE,GAAG0Y;EAC/F,2BAAwB;EACxB,sBAAoBH;EAEnB,UAAAC,EAAa,KAAK,MAAS;GAC1B,IAAM7V,IAAOqU,GAAUlB,CAAI;GAQ3B,OAPInT,MAAS,KAAA,IAET,kBAAC,KAAD;IAAG,WAAW3C,EAAO;IAAyB,UAAA;GAE3C,GAFkC8V,EAAK,EAEvC,IAIL,kBAAC,WAAD;IAAS,WAAW9V,EAAO;IAA3B,UAAA,CACGwY,EAAa,SAAS,IAAI,kBAAC,MAAD;KAAI,WAAWxY,EAAO;KAAW,UAAA2C,EAAK;IAAS,CAAA,IAAI,MAC9E,kBAAC,OAAD;KAAK,WAAW3C,EAAO;KACpB,UAAAuY,MAAU,UACPR,GAAYpV,GAAMmT,EAAK,IAAIa,SAAmByB,EAAQ,SAASd,CAAI,IACnEY,GAAcvV,GAAMmT,EAAK,IAAIa,SAAmByB,EAAQ,SAASd,CAAI;IACtE,CAAA,CACE;GAP6B,GAAAxB,EAAK,EAOlC;EAEb,CAAC;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"index.js","names":["code","styles","GIT_DIFF_FILE_BREAK_REGEX","FILENAME_HEADER_REGEX","INDEX_LINE_METADATA","getHunkSideStartBoundary","start","count","getHunkSideEndBoundary","CACHE_KEY_VERSION","composeCacheKey","segments","scope","cleanLastNewline","end","contents","stringDetachEncoder","stringDetachDecoder","SURROGATE_CODE_UNIT_PATTERN","STRING_DETACH_INITIAL_BUFFER_SIZE","stringDetachBuffer","releaseStringDetachBuffer","detachString","value","requiredByteLength","written","filenameDecoder","NAMED_ESCAPES","parseQuotedDiffFileName","input","fileName","index","char","escaped","bytes","byte","readOctalByte","first","second","third","MAX_ALIGNMENT_COMPARISONS","MIN_IMPROVEMENT_PER_PAIR","realignChangeContentBySimilarity","hunk","diff","content","replacement","realignChangeBlock","pairCount","deletions","additions","surplus","strippedDeletions","line","stripWhitespace","deletionLineIndex","strippedAdditions","additionLineIndex","additionsAreLonger","bestOffset","bestScore","offset","score","pair","lineSimilarity","blocks","pushBlock","blockDeletions","blockAdditions","blockDeletionIndex","blockAdditionIndex","WHITESPACE","a","b","maxLength","minLength","prefix","suffix","GIT_DIFF_HEADER_FILENAMES","processFile","_processFile","fileDiffString","options","lastHunkEnd","hunks","splitAtLinePrefix","currentFile","isPartial","oldFile","newFile","lines","splitWithNewlines","firstLine","throwOnError","fileHeader","parseHunkHeader","additionLines","deletionLines","splitFileContents","maybeDetachOptionalString","cacheKey","filenameMatch","prevName","decodeDiffFileName","name","type","rawFileName","isGitDiff","detachedFileName","prevObjectId","newObjectId","mode","currentContent","lastLineType","deletionStart","additionStart","hunkData","parsedAdditionLines","parsedDeletionLines","lineIndex","rawLine","isFormatPatchVersionSeparator","firstChar","parseRawLineType","getParsedLineContent","createContentGroup","lastIndex","repairedAdditionStart","repairedDeletionStart","additionStartDelta","deletionStartDelta","lastHunk","totalFileLines","collapsedAfter","rawName","stripGitPrefix","startIndex","newlineIndex","isHunkBodyLine","deletionStartResult","readPositiveInteger","deletionCount","deletionCountResult","additionStartResult","additionCount","additionCountResult","hunkContext","contextStartIndex","trimLineEnd","parsedValue","digit","newlinePrefix","firstBoundaryIndex","findLinePrefixIndex","parts","nextBoundaryIndex","fromIndex","processedLine","Diff","callback","oldString","oldStr","newString","newStr","oldTokens","newTokens","done","newLen","oldLen","editLength","maxEditLength","maxExecutionTime","abortAfterTimestamp","bestPath","newPos","minDiagonalToConsider","maxDiagonalToConsider","execEditLength","diagonalPath","basePath","removePath","addPath","canAdd","addPathNewPos","canRemove","exec","ret","last","path","added","removed","oldPosInc","oldPos","commonCount","left","right","i","array","chars","changeObjects","components","nextComponent","lastComponent","componentLen","componentPos","component","oldValue","longestCommonPrefix","str1","str2","longestCommonSuffix","replacePrefix","string","oldPrefix","newPrefix","replaceSuffix","oldSuffix","newSuffix","removePrefix","removeSuffix","maximumOverlap","string2","overlapCount","string1","startA","endB","map","k","j","segment","segmentObj","segmenter","trailingWs","leadingAndTrailingWs","leadingWs","match","firstSeg","lastSeg","extendedWordChars","tokenizeIncludingWhitespace","tokens","prevPart","part","token","changes","lastKeep","insertion","deletion","change","dedupeWhitespaceInChangeObjects","oldWsPrefix","oldWsSuffix","newWsPrefix","newWsSuffix","startKeep","commonWsPrefix","endKeep","commonWsSuffix","ws","newWsFull","delWsStart","delWsEnd","newWsStart","newWsEnd","endKeepWsPrefix","overlap","regex","lineDiff","tokenize","diffLines","retLines","linesAndNewlines","isSentenceEndPunct","result","tokenStartI","v","undefinedReplacement","canonicalize","stringifyReplacer","replacer","key","obj","stack","replacementStack","canonicalizedObj","sortedKeys","needsQuoting","s","quoteFileNameIfNeeded","INCLUDE_HEADERS","structuredPatch","optionsObj","context","patch","diffLinesResultToPatch","contextLines","entry","oldRangeStart","newRangeStart","curRange","oldLine","newLine","current","splitLines","prev","contextSize","formatPatch","headerOptions","p","gitOldName","gitNewName","hasHunks","oldStart","newStart","createTwoFilesPatch","oldFileName","newFileName","oldHeader","newHeader","patchObj","hasTrailingNl","text","MISSING_FILE_NAME","parseDiffFromFile","resolvedOldFile","createMissingFile","resolvedNewFile","fileData","oldCacheKey","newCacheKey","language","cssClass","sheet","useNarrowerThan","narrow","setNarrow","useState","useCallback","element","measure","measured","width","view","observer","renderedDiffLine","root","container","sideContainer","location","contextLine","pierreLine","item","annotationNode","focusLine","DiffCodeAnnotation","annotationRef","useRef","restoreLineFocus","returnFocus","annotation","createElement","event","requireDiffCodeAnnotations","ids","annotations","BoundedDiffCodeView_module_default","boundedAnnotationLocation","contentAt","hunkLabel","parseItem","contextSplitRows","changeSplitRows","splitRows","unifiedRows","code","wrap","itemId","alternate","lineNumber","side","focusBoundedLine","annotationsAt","splitAnnotationRows","row","renderSplit","Fragment","unifiedAnnotationRows","renderUnified","BoundedDiffCodeView","rootRef","measureRef","attachRoot","shown","initialItems","empty","className"],"sources":["../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/constants.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/getHunkSideBoundaries.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/composeCacheKey.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/cleanLastNewline.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/detachString.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/parseQuotedDiffFileName.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/realignChangeContent.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/parsePatchFiles.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/base.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/character.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/util/string.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/word.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/line.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/sentence.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/css.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/json.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/array.js","../../../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/patch/create.js","../../../../../node_modules/.pnpm/@pierre+diffs@1.5.1_patch_hash=ce17810cfea58efa02eb4e70947801afb36c9f8a08a8bb4c810297c2_63846ff899210db6647d73492b0c4e78/node_modules/@pierre/diffs/dist/utils/parseDiffFromFile.js","../../../src/internal/component.ts","../../../src/internal/useNarrowerThan.ts","../../../src/diff/rendered-line.ts","../../../src/diff/annotation.ts","../../../src/diff/bounded/BoundedDiffCodeView.module.css","../../../src/diff/bounded/BoundedDiffCodeView.tsx"],"sourcesContent":["//#region src/constants.ts\nconst DIFFS_TAG_NAME = \"diffs-container\";\nconst DIFFS_DEVELOPMENT_BUILD = (() => {\n\ttry {\n\t\treturn process.env.NODE_ENV === \"development\";\n\t} catch {\n\t\treturn false;\n\t}\n})();\nconst COMMIT_METADATA_SPLIT = /(?=^From [a-f0-9]+ .+$)/m;\nconst GIT_DIFF_FILE_BREAK_REGEX = /(?=^diff --git)/gm;\nconst UNIFIED_DIFF_FILE_BREAK_REGEX = /(?=^---\\s+\\S)/gm;\nconst FILE_CONTEXT_BLOB = /(?=^@@ )/gm;\nconst HUNK_HEADER = /^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(?: (.*))?/m;\nconst SPLIT_WITH_NEWLINES = /(?<=\\n)/;\nconst FILENAME_HEADER_REGEX = /^(---|\\+\\+\\+)\\s+([^\\t\\r\\n]+)/;\nconst INDEX_LINE_METADATA = /^index ([0-9a-f]+)\\.\\.([0-9a-f]+)(?: (\\d+))?$/i;\nconst MERGE_CONFLICT_START_MARKER_REGEX = /^<{7,}(?:\\s.*)?$/;\nconst MERGE_CONFLICT_BASE_MARKER_REGEX = /^\\|{7,}(?:\\s.*)?$/;\nconst MERGE_CONFLICT_SEPARATOR_MARKER_REGEX = /^={7,}$/;\nconst MERGE_CONFLICT_END_MARKER_REGEX = /^>{7,}(?:\\s.*)?$/;\nconst HEADER_PREFIX_SLOT_ID = \"header-prefix\";\nconst HEADER_FILENAME_SUFFIX_SLOT_ID = \"header-filename-suffix\";\nconst HEADER_METADATA_SLOT_ID = \"header-metadata\";\nconst CUSTOM_HEADER_SLOT_ID = \"header-custom\";\nconst DEFAULT_THEMES = {\n\tdark: \"pierre-dark\",\n\tlight: \"pierre-light\"\n};\nconst THEME_CSS_ATTRIBUTE = \"data-theme-css\";\nconst UNSAFE_CSS_ATTRIBUTE = \"data-unsafe-css\";\nconst CORE_CSS_ATTRIBUTE = \"data-core-css\";\nconst DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE = \"data-diffs-scrollbar-measure\";\nconst CODE_VIEW_HEADER_ATTRIBUTE = \"data-diffs-code-view-header\";\nconst CODE_VIEW_FOOTER_ATTRIBUTE = \"data-diffs-code-view-footer\";\nconst DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY = \"--diffs-scrollbar-gutter-measured\";\nconst DEFAULT_COLLAPSED_CONTEXT_THRESHOLD = 1;\nconst DEFAULT_TOKENIZE_MAX_LENGTH = 1e5;\nconst DEFAULT_VIRTUAL_FILE_METRICS = {\n\thunkLineCount: 50,\n\tlineHeight: 20,\n\tdiffHeaderHeight: 44,\n\tspacing: 8\n};\nconst DEFAULT_CODE_VIEW_FILE_METRICS = {\n\t...DEFAULT_VIRTUAL_FILE_METRICS,\n\thunkLineCount: 1\n};\nconst DEFAULT_CODE_VIEW_LAYOUT = {\n\tpaddingTop: 8,\n\tpaddingBottom: 8,\n\tgap: 8\n};\nconst DEFAULT_SMOOTH_SCROLL_SETTINGS = {\n\tomega: .015,\n\tpositionEpsilon: .5,\n\tvelocityEpsilon: .05\n};\nconst DEFAULT_EXPANDED_REGION = Object.freeze({\n\tfromStart: 0,\n\tfromEnd: 0\n});\nconst DEFAULT_RENDER_RANGE = {\n\tstartingLine: 0,\n\ttotalLines: Infinity,\n\tbufferBefore: 0,\n\tbufferAfter: 0\n};\nconst EMPTY_RENDER_RANGE = {\n\tstartingLine: 0,\n\ttotalLines: 0,\n\tbufferBefore: 0,\n\tbufferAfter: 0\n};\n//#endregion\nexport { CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE };\n\n//# sourceMappingURL=constants.js.map","//#region src/utils/getHunkSideBoundaries.ts\n/** Converts a unified hunk side's start/count into its consumed-file range. */\nfunction getHunkSideStartBoundary(start, count) {\n\treturn start - (count === 0 ? 0 : 1);\n}\nfunction getHunkSideEndBoundary(start, count) {\n\treturn getHunkSideStartBoundary(start, count) + count;\n}\n//#endregion\nexport { getHunkSideEndBoundary, getHunkSideStartBoundary };\n\n//# sourceMappingURL=getHunkSideBoundaries.js.map","//#region src/utils/composeCacheKey.ts\nconst CACHE_KEY_VERSION = 1;\n/** Encodes caller-controlled segments without delimiter ambiguity. */\nfunction composeCacheKey(scope, ...segments) {\n\treturn `ck${CACHE_KEY_VERSION}:${JSON.stringify([scope, ...segments])}`;\n}\n//#endregion\nexport { composeCacheKey };\n\n//# sourceMappingURL=composeCacheKey.js.map","//#region src/utils/cleanLastNewline.ts\nfunction cleanLastNewline(contents) {\n\tlet end = contents.length;\n\tif (contents.charCodeAt(end - 1) === 10) {\n\t\tend--;\n\t\tif (contents.charCodeAt(end - 1) === 13) end--;\n\t}\n\treturn contents.slice(0, end);\n}\n//#endregion\nexport { cleanLastNewline };\n\n//# sourceMappingURL=cleanLastNewline.js.map","//#region src/utils/detachString.ts\nconst stringDetachEncoder = new TextEncoder();\nconst stringDetachDecoder = new TextDecoder(\"utf-8\", { ignoreBOM: true });\nconst SURROGATE_CODE_UNIT_PATTERN = /[\\uD800-\\uDFFF]/;\nconst STRING_DETACH_INITIAL_BUFFER_SIZE = 1024;\nlet stringDetachBuffer = new Uint8Array(STRING_DETACH_INITIAL_BUFFER_SIZE);\nfunction releaseStringDetachBuffer() {\n\tif (stringDetachBuffer.length !== STRING_DETACH_INITIAL_BUFFER_SIZE) stringDetachBuffer = new Uint8Array(STRING_DETACH_INITIAL_BUFFER_SIZE);\n}\nfunction detachString(value) {\n\tif (value.length === 0) return value;\n\tif (SURROGATE_CODE_UNIT_PATTERN.test(value)) return JSON.parse(JSON.stringify(value));\n\tconst requiredByteLength = value.length * 3;\n\tif (stringDetachBuffer.length < requiredByteLength) stringDetachBuffer = new Uint8Array(requiredByteLength);\n\tconst { written } = stringDetachEncoder.encodeInto(value, stringDetachBuffer);\n\treturn stringDetachDecoder.decode(stringDetachBuffer.subarray(0, written));\n}\n//#endregion\nexport { detachString, releaseStringDetachBuffer };\n\n//# sourceMappingURL=detachString.js.map","//#region src/utils/parseQuotedDiffFileName.ts\nconst filenameDecoder = new TextDecoder(\"utf-8\", { ignoreBOM: true });\nconst NAMED_ESCAPES = {\n\t\"\\\"\": \"\\\"\",\n\t\"\\\\\": \"\\\\\",\n\ta: \"\\x07\",\n\tb: \"\\b\",\n\tt: \"\t\",\n\tn: \"\\n\",\n\tv: \"\\v\",\n\tf: \"\\f\",\n\tr: \"\\r\"\n};\nfunction parseQuotedDiffFileName(input) {\n\tif (input[0] !== \"\\\"\") return;\n\tlet fileName = \"\";\n\tlet index = 1;\n\twhile (index < input.length) {\n\t\tconst char = input[index];\n\t\tif (char === \"\\\"\") return {\n\t\t\tfileName,\n\t\t\trawLength: index + 1\n\t\t};\n\t\tif (char !== \"\\\\\") {\n\t\t\tfileName += char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tconst escaped = NAMED_ESCAPES[input[index + 1]];\n\t\tif (escaped != null) {\n\t\t\tfileName += escaped;\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tconst bytes = [];\n\t\tdo {\n\t\t\tconst byte = readOctalByte(input, index + 1);\n\t\t\tif (byte == null) return;\n\t\t\tbytes.push(byte);\n\t\t\tindex += 4;\n\t\t} while (input[index] === \"\\\\\" && input[index + 1] >= \"0\" && input[index + 1] <= \"7\");\n\t\tfileName += filenameDecoder.decode(new Uint8Array(bytes));\n\t}\n}\nfunction readOctalByte(input, index) {\n\tconst first = input.charCodeAt(index) - 48;\n\tconst second = input.charCodeAt(index + 1) - 48;\n\tconst third = input.charCodeAt(index + 2) - 48;\n\tif (first >= 0 && first <= 3 && second >= 0 && second <= 7 && third >= 0 && third <= 7) return first * 64 + second * 8 + third;\n}\n//#endregion\nexport { parseQuotedDiffFileName };\n\n//# sourceMappingURL=parseQuotedDiffFileName.js.map","//#region src/utils/realignChangeContent.ts\nconst MAX_ALIGNMENT_COMPARISONS = 4096;\nconst MIN_IMPROVEMENT_PER_PAIR = .5;\n/**\n* Re-split count-mismatched change blocks in every hunk so paired lines are\n* chosen by content similarity instead of position. Mutates `hunks` in place\n* without moving changes across context lines; rendered row counts are\n* unchanged (a split block covers the same split/unified rows as the original).\n*/\nfunction realignChangeContentBySimilarity(diff) {\n\tfor (const hunk of diff.hunks) for (let index = 0; index < hunk.hunkContent.length; index++) {\n\t\tconst content = hunk.hunkContent[index];\n\t\tif (content.type !== \"change\") continue;\n\t\tconst replacement = realignChangeBlock(diff, content);\n\t\tif (replacement != null) {\n\t\t\thunk.hunkContent.splice(index, 1, ...replacement);\n\t\t\tindex += replacement.length - 1;\n\t\t}\n\t}\n}\n/**\n* During editing, slide pure insert/delete blocks made entirely of blank lines\n* to the top of the blank run they sit in. Adding or removing a blank line next to\n* existing blanks is ambiguous, and the diff library reports the change at\n* the run's bottom — so pressing Enter at the end of a line marks a blank\n* *below* the caret as inserted while the caret's own new line renders as\n* context. Sliding up anchors the change to the content above it (the caret\n* line after an Enter) instead.\n*\n* `resolveSlide` receives each block that qualifies along with the full\n* distance to the run's top and returns how far to actually move it; 0 keeps\n* the parsed position. Without it, every qualifying block slides to the top.\n*\n* The slide only applies when the block comes to rest directly beneath\n* remaining in-hunk content. A slide that would consume the\n* hunk's entire leading context was stopped by the hunk's edge — a context\n* window cut, not the top of the blank run — and that landing spot is\n* arbitrary, so the block keeps the library's bottom-of-run anchor (which\n* sits against the content below the run). Non-blank blocks never slide, so\n* code that merely ends like its neighbor (an added function before an\n* identical `}`) keeps the library's canonical position.\n*/\nfunction slideBlankBoundaryBlocksUp(hunk, diff, resolveSlide) {\n\tconst { hunkContent } = hunk;\n\tfor (let index = 1; index < hunkContent.length; index++) {\n\t\tconst block = hunkContent[index];\n\t\tconst previous = hunkContent[index - 1];\n\t\tif (block.type !== \"change\" || block.additions > 0 && block.deletions > 0 || previous.type !== \"context\") continue;\n\t\tconst isInsert = block.additions > 0;\n\t\tconst lines = isInsert ? diff.additionLines : diff.deletionLines;\n\t\tconst blockStart = isInsert ? block.additionLineIndex : block.deletionLineIndex;\n\t\tconst blockLength = isInsert ? block.additions : block.deletions;\n\t\tconst unit = lines[blockStart] ?? \"\";\n\t\tif (unit.trim() !== \"\") continue;\n\t\tlet uniform = true;\n\t\tfor (let offset = 1; offset < blockLength; offset++) if (lines[blockStart + offset] !== unit) {\n\t\t\tuniform = false;\n\t\t\tbreak;\n\t\t}\n\t\tif (!uniform) continue;\n\t\tlet slide = 0;\n\t\twhile (slide < previous.lines && diff.additionLines[previous.additionLineIndex + previous.lines - 1 - slide] === unit) slide++;\n\t\tif (slide === 0) continue;\n\t\tif (index === 1 && slide === previous.lines) continue;\n\t\tif (resolveSlide != null) {\n\t\t\tslide = resolveSlide(block, slide);\n\t\t\tif (slide === 0) continue;\n\t\t}\n\t\tblock.additionLineIndex -= slide;\n\t\tblock.deletionLineIndex -= slide;\n\t\tconst blockAdditionEnd = block.additionLineIndex + block.additions;\n\t\tconst blockDeletionEnd = block.deletionLineIndex + block.deletions;\n\t\tconst next = hunkContent[index + 1];\n\t\tif (next?.type === \"context\") {\n\t\t\tnext.lines += slide;\n\t\t\tnext.additionLineIndex = blockAdditionEnd;\n\t\t\tnext.deletionLineIndex = blockDeletionEnd;\n\t\t} else hunkContent.splice(index + 1, 0, {\n\t\t\ttype: \"context\",\n\t\t\tlines: slide,\n\t\t\tadditionLineIndex: blockAdditionEnd,\n\t\t\tdeletionLineIndex: blockDeletionEnd\n\t\t});\n\t\tprevious.lines -= slide;\n\t\tif (previous.lines === 0) {\n\t\t\thunkContent.splice(index - 1, 1);\n\t\t\tindex--;\n\t\t}\n\t}\n}\nfunction realignChangeBlock(diff, content) {\n\tconst { deletions, additions, deletionLineIndex, additionLineIndex } = content;\n\tconst pairCount = Math.min(deletions, additions);\n\tconst surplus = Math.abs(additions - deletions);\n\tif (pairCount === 0 || surplus === 0 || pairCount * (surplus + 1) > MAX_ALIGNMENT_COMPARISONS) return null;\n\tconst strippedDeletions = [];\n\tfor (let line = 0; line < deletions; line++) strippedDeletions.push(stripWhitespace(diff.deletionLines[deletionLineIndex + line] ?? \"\"));\n\tconst strippedAdditions = [];\n\tfor (let line = 0; line < additions; line++) strippedAdditions.push(stripWhitespace(diff.additionLines[additionLineIndex + line] ?? \"\"));\n\tconst additionsAreLonger = additions > deletions;\n\tlet bestOffset = 0;\n\tlet bestScore = -1;\n\tfor (let offset = 0; offset <= surplus; offset++) {\n\t\tlet score = 0;\n\t\tfor (let pair = 0; pair < pairCount; pair++) score += lineSimilarity(strippedDeletions[pair + (additionsAreLonger ? 0 : offset)], strippedAdditions[pair + (additionsAreLonger ? offset : 0)]);\n\t\tif (offset === 0) bestScore = score + pairCount * MIN_IMPROVEMENT_PER_PAIR;\n\t\telse if (score > bestScore) {\n\t\t\tbestScore = score;\n\t\t\tbestOffset = offset;\n\t\t}\n\t}\n\tif (bestOffset === 0) return null;\n\tconst blocks = [];\n\tconst pushBlock = (blockDeletions, blockAdditions, blockDeletionIndex, blockAdditionIndex) => {\n\t\tif (blockDeletions > 0 || blockAdditions > 0) blocks.push({\n\t\t\ttype: \"change\",\n\t\t\tdeletions: blockDeletions,\n\t\t\tadditions: blockAdditions,\n\t\t\tdeletionLineIndex: blockDeletionIndex,\n\t\t\tadditionLineIndex: blockAdditionIndex\n\t\t});\n\t};\n\tif (additionsAreLonger) {\n\t\tpushBlock(0, bestOffset, deletionLineIndex, additionLineIndex);\n\t\tpushBlock(pairCount, pairCount, deletionLineIndex, additionLineIndex + bestOffset);\n\t\tpushBlock(0, additions - pairCount - bestOffset, deletionLineIndex + pairCount, additionLineIndex + bestOffset + pairCount);\n\t} else {\n\t\tpushBlock(bestOffset, 0, deletionLineIndex, additionLineIndex);\n\t\tpushBlock(pairCount, pairCount, deletionLineIndex + bestOffset, additionLineIndex);\n\t\tpushBlock(deletions - pairCount - bestOffset, 0, deletionLineIndex + bestOffset + pairCount, additionLineIndex + pairCount);\n\t}\n\treturn blocks;\n}\nconst WHITESPACE = /\\s+/g;\nfunction stripWhitespace(line) {\n\treturn line.replace(WHITESPACE, \"\");\n}\nfunction lineSimilarity(a, b) {\n\tif (a === b) return 1;\n\tconst maxLength = Math.max(a.length, b.length);\n\tconst minLength = Math.min(a.length, b.length);\n\tif (minLength === 0) return 0;\n\tlet prefix = 0;\n\twhile (prefix < minLength && a[prefix] === b[prefix]) prefix++;\n\tlet suffix = 0;\n\twhile (suffix < minLength - prefix && a[a.length - 1 - suffix] === b[b.length - 1 - suffix]) suffix++;\n\treturn (prefix + suffix) / maxLength;\n}\n//#endregion\nexport { realignChangeContentBySimilarity, slideBlankBoundaryBlocksUp };\n\n//# sourceMappingURL=realignChangeContent.js.map","import { COMMIT_METADATA_SPLIT, FILENAME_HEADER_REGEX, GIT_DIFF_FILE_BREAK_REGEX, INDEX_LINE_METADATA } from \"../constants.js\";\nimport { getHunkSideEndBoundary, getHunkSideStartBoundary } from \"./getHunkSideBoundaries.js\";\nimport { composeCacheKey } from \"./composeCacheKey.js\";\nimport { cleanLastNewline } from \"./cleanLastNewline.js\";\nimport { detachString, releaseStringDetachBuffer } from \"./detachString.js\";\nimport { parseQuotedDiffFileName } from \"./parseQuotedDiffFileName.js\";\nimport { realignChangeContentBySimilarity } from \"./realignChangeContent.js\";\n//#region src/utils/parsePatchFiles.ts\nconst GIT_DIFF_HEADER_FILENAMES = /^diff --git (\"a\\/(?:[^\"\\\\]|\\\\.)*\"|a\\/.+?) (\"b\\/(?:[^\"\\\\]|\\\\.)*\"|b\\/.+?)$/;\nfunction processPatch(data, cacheKeyPrefix, throwOnError) {\n\ttry {\n\t\treturn _processPatch(data, cacheKeyPrefix, throwOnError);\n\t} finally {\n\t\treleaseStringDetachBuffer();\n\t}\n}\nfunction _processPatch(data, cacheKeyPrefix, throwOnError = false, patchIndex) {\n\tconst isGitDiff = isGitDiffPatch(data);\n\tconst rawFiles = isGitDiff ? splitGitDiffFiles(data) : splitUnifiedDiffFiles(data);\n\tlet patchMetadata;\n\tconst files = [];\n\tfor (const fileOrPatchMetadata of rawFiles) {\n\t\tif (isGitDiff && !GIT_DIFF_FILE_BREAK_REGEX.test(fileOrPatchMetadata)) {\n\t\t\tif (patchMetadata == null) patchMetadata = detachString(fileOrPatchMetadata);\n\t\t\telse if (throwOnError) throw Error(\"parsePatchContent: unknown file blob\");\n\t\t\telse console.error(\"parsePatchContent: unknown file blob:\", fileOrPatchMetadata);\n\t\t\tcontinue;\n\t\t} else if (!isGitDiff && !startsWithUnifiedDiffFileHeader(fileOrPatchMetadata)) {\n\t\t\tif (patchMetadata == null) patchMetadata = detachString(fileOrPatchMetadata);\n\t\t\telse if (throwOnError) throw Error(\"parsePatchContent: unknown file blob\");\n\t\t\telse console.error(\"parsePatchContent: unknown file blob:\", fileOrPatchMetadata);\n\t\t\tcontinue;\n\t\t}\n\t\tconst currentFile = _processFile(fileOrPatchMetadata, {\n\t\t\tcacheKey: cacheKeyPrefix != null ? patchIndex == null ? composeCacheKey(\"patch-file\", cacheKeyPrefix, String(files.length)) : composeCacheKey(\"patch-file\", cacheKeyPrefix, String(patchIndex), String(files.length)) : void 0,\n\t\t\tisGitDiff,\n\t\t\tthrowOnError\n\t\t});\n\t\tif (currentFile != null) files.push(currentFile);\n\t}\n\treturn {\n\t\tpatchMetadata,\n\t\tfiles\n\t};\n}\nfunction processFile(fileDiffString, options) {\n\ttry {\n\t\treturn _processFile(fileDiffString, options);\n\t} finally {\n\t\treleaseStringDetachBuffer();\n\t}\n}\nfunction _processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(fileDiffString), oldFile, newFile, throwOnError = false } = {}) {\n\tlet lastHunkEnd = 0;\n\tconst hunks = splitAtLinePrefix(fileDiffString, \"@@ \");\n\tlet currentFile;\n\tconst isPartial = oldFile == null || newFile == null;\n\tlet deletionLineIndex = 0;\n\tlet additionLineIndex = 0;\n\tfor (const hunk of hunks) {\n\t\tconst lines = splitWithNewlines(hunk);\n\t\tconst firstLine = lines[0];\n\t\tif (firstLine == null) {\n\t\t\tif (throwOnError) throw Error(\"parsePatchContent: invalid hunk\");\n\t\t\telse console.error(\"parsePatchContent: invalid hunk\", hunk);\n\t\t\tcontinue;\n\t\t}\n\t\tconst fileHeader = parseHunkHeader(firstLine);\n\t\tlet additionLines = 0;\n\t\tlet deletionLines = 0;\n\t\tif (fileHeader == null || currentFile == null) {\n\t\t\tif (currentFile != null) {\n\t\t\t\tif (throwOnError) throw Error(\"parsePatchContent: Invalid hunk\");\n\t\t\t\telse console.error(\"parsePatchContent: Invalid hunk\", hunk);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcurrentFile = {\n\t\t\t\tname: \"\",\n\t\t\t\ttype: \"change\",\n\t\t\t\thunks: [],\n\t\t\t\tsplitLineCount: 0,\n\t\t\t\tunifiedLineCount: 0,\n\t\t\t\tisPartial,\n\t\t\t\tadditionLines: !isPartial && oldFile != null && newFile != null ? splitFileContents(newFile.contents) : [],\n\t\t\t\tdeletionLines: !isPartial && oldFile != null && newFile != null ? splitFileContents(oldFile.contents) : [],\n\t\t\t\tcacheKey: maybeDetachOptionalString(cacheKey)\n\t\t\t};\n\t\t\tif (currentFile.additionLines.length === 1 && newFile?.contents === \"\") currentFile.additionLines.length = 0;\n\t\t\tif (currentFile.deletionLines.length === 1 && oldFile?.contents === \"\") currentFile.deletionLines.length = 0;\n\t\t\tfor (const line of lines) {\n\t\t\t\tif (line.startsWith(\"diff --git\")) {\n\t\t\t\t\tconst filenameMatch = line.trim().match(GIT_DIFF_HEADER_FILENAMES);\n\t\t\t\t\tif (filenameMatch == null) {\n\t\t\t\t\t\tif (throwOnError) throw Error(\"parsePatchContent: invalid git diff header\");\n\t\t\t\t\t\telse console.error(\"parsePatchContent: invalid git diff header\", line);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst prevName = decodeDiffFileName(filenameMatch[1], true);\n\t\t\t\t\tconst name = decodeDiffFileName(filenameMatch[2], true);\n\t\t\t\t\tcurrentFile.name = detachString(name);\n\t\t\t\t\tif (prevName !== name) currentFile.prevName = detachString(prevName);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst filenameMatch = line.startsWith(\"---\") || line.startsWith(\"+++\") ? line.match(FILENAME_HEADER_REGEX) : null;\n\t\t\t\tif (filenameMatch != null) {\n\t\t\t\t\tconst [, type, rawFileName] = filenameMatch;\n\t\t\t\t\tconst fileName = decodeDiffFileName(rawFileName, isGitDiff);\n\t\t\t\t\tif (type === \"---\" && fileName !== \"/dev/null\") {\n\t\t\t\t\t\tconst detachedFileName = detachString(fileName);\n\t\t\t\t\t\tcurrentFile.prevName = detachedFileName;\n\t\t\t\t\t\tcurrentFile.name = detachedFileName;\n\t\t\t\t\t} else if (type === \"+++\" && fileName !== \"/dev/null\") currentFile.name = detachString(fileName);\n\t\t\t\t} else if (isGitDiff) {\n\t\t\t\t\tif (line.startsWith(\"new mode \")) currentFile.mode = detachString(line.slice(8).trim());\n\t\t\t\t\tif (line.startsWith(\"old mode \")) currentFile.prevMode = detachString(line.slice(8).trim());\n\t\t\t\t\tif (line.startsWith(\"new file mode\")) {\n\t\t\t\t\t\tcurrentFile.type = \"new\";\n\t\t\t\t\t\tcurrentFile.mode = detachString(line.slice(13).trim());\n\t\t\t\t\t}\n\t\t\t\t\tif (line.startsWith(\"deleted file mode\")) {\n\t\t\t\t\t\tcurrentFile.type = \"deleted\";\n\t\t\t\t\t\tcurrentFile.mode = detachString(line.slice(17).trim());\n\t\t\t\t\t}\n\t\t\t\t\tif (line.startsWith(\"similarity index\")) {\n\t\t\t\t\t\tif (line.startsWith(\"similarity index 100%\")) currentFile.type = \"rename-pure\";\n\t\t\t\t\t\telse currentFile.type = \"rename-changed\";\n\t\t\t\t\t}\n\t\t\t\t\tif (line.startsWith(\"index \")) {\n\t\t\t\t\t\tconst [, prevObjectId, newObjectId, mode] = line.trim().match(INDEX_LINE_METADATA) ?? [];\n\t\t\t\t\t\tif (prevObjectId != null) currentFile.prevObjectId = detachString(prevObjectId);\n\t\t\t\t\t\tif (newObjectId != null) currentFile.newObjectId = detachString(newObjectId);\n\t\t\t\t\t\tif (mode != null) currentFile.mode = detachString(mode);\n\t\t\t\t\t}\n\t\t\t\t\tif (line.startsWith(\"rename from \") || line.startsWith(\"copy from \")) currentFile.prevName = detachString(decodeDiffFileName(line.slice(line.startsWith(\"rename\") ? 12 : 10)));\n\t\t\t\t\tif (line.startsWith(\"rename to \") || line.startsWith(\"copy to \")) currentFile.name = detachString(decodeDiffFileName(line.slice(line.startsWith(\"rename\") ? 10 : 8)));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tlet currentContent;\n\t\tlet lastLineType;\n\t\twhile (lines.length > 0 && (lines[lines.length - 1] === \"\\n\" || lines[lines.length - 1] === \"\\r\" || lines[lines.length - 1] === \"\\r\\n\" || lines[lines.length - 1] === \"\")) lines.pop();\n\t\tconst { additionStart, deletionStart } = fileHeader;\n\t\tdeletionLineIndex = isPartial ? deletionLineIndex : deletionStart - 1;\n\t\tadditionLineIndex = isPartial ? additionLineIndex : additionStart - 1;\n\t\tconst hunkData = {\n\t\t\tcollapsedBefore: 0,\n\t\t\tsplitLineCount: 0,\n\t\t\tsplitLineStart: 0,\n\t\t\tunifiedLineCount: 0,\n\t\t\tunifiedLineStart: 0,\n\t\t\tadditionCount: fileHeader.additionCount,\n\t\t\tadditionStart,\n\t\t\tadditionLines,\n\t\t\tdeletionCount: fileHeader.deletionCount,\n\t\t\tdeletionStart,\n\t\t\tdeletionLines,\n\t\t\tdeletionLineIndex,\n\t\t\tadditionLineIndex,\n\t\t\thunkContent: [],\n\t\t\thunkContext: maybeDetachOptionalString(fileHeader.hunkContext),\n\t\t\thunkSpecs: detachString(firstLine),\n\t\t\tnoEOFCRAdditions: false,\n\t\t\tnoEOFCRDeletions: false\n\t\t};\n\t\tlet parsedAdditionLines = 0;\n\t\tlet parsedDeletionLines = 0;\n\t\tfor (let lineIndex = 1; lineIndex < lines.length; lineIndex++) {\n\t\t\tconst rawLine = lines[lineIndex];\n\t\t\tif (parsedAdditionLines >= hunkData.additionCount && parsedDeletionLines >= hunkData.deletionCount && !rawLine.startsWith(\"\\\\\")) {\n\t\t\t\tif (!(isHunkBodyLine(rawLine) && !isFormatPatchVersionSeparator(rawLine))) break;\n\t\t\t\tif (throwOnError) throw Error(\"parsePatchContent: hunk has more lines than expected\");\n\t\t\t}\n\t\t\tconst firstChar = rawLine[0];\n\t\t\tif (firstChar !== \"+\" && firstChar !== \"-\" && firstChar !== \" \" && firstChar !== \"\\\\\") {\n\t\t\t\tif (throwOnError) throw Error(\"parsePatchContent: invalid hunk line\");\n\t\t\t\tconsole.error(`parseLineType: Invalid firstChar: \"${firstChar}\", full line: \"${rawLine}\"`);\n\t\t\t\tconsole.error(\"processFile: invalid rawLine:\", rawLine);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst type = parseRawLineType(firstChar);\n\t\t\tif (type === \"addition\") {\n\t\t\t\tif (throwOnError && parsedAdditionLines >= hunkData.additionCount) throw Error(\"parsePatchContent: hunk has too many addition lines\");\n\t\t\t\tconst line = getParsedLineContent(rawLine);\n\t\t\t\tif (currentContent == null || currentContent.type !== \"change\") {\n\t\t\t\t\tcurrentContent = createContentGroup(\"change\", deletionLineIndex, additionLineIndex);\n\t\t\t\t\thunkData.hunkContent.push(currentContent);\n\t\t\t\t}\n\t\t\t\tadditionLineIndex++;\n\t\t\t\tparsedAdditionLines++;\n\t\t\t\tif (isPartial) currentFile.additionLines.push(line);\n\t\t\t\tcurrentContent.additions++;\n\t\t\t\tadditionLines++;\n\t\t\t\tlastLineType = \"addition\";\n\t\t\t} else if (type === \"deletion\") {\n\t\t\t\tif (throwOnError && parsedDeletionLines >= hunkData.deletionCount) throw Error(\"parsePatchContent: hunk has too many deletion lines\");\n\t\t\t\tconst line = getParsedLineContent(rawLine);\n\t\t\t\tif (currentContent == null || currentContent.type !== \"change\") {\n\t\t\t\t\tcurrentContent = createContentGroup(\"change\", deletionLineIndex, additionLineIndex);\n\t\t\t\t\thunkData.hunkContent.push(currentContent);\n\t\t\t\t}\n\t\t\t\tdeletionLineIndex++;\n\t\t\t\tparsedDeletionLines++;\n\t\t\t\tif (isPartial) currentFile.deletionLines.push(line);\n\t\t\t\tcurrentContent.deletions++;\n\t\t\t\tdeletionLines++;\n\t\t\t\tlastLineType = \"deletion\";\n\t\t\t} else if (type === \"context\") {\n\t\t\t\tif (throwOnError && (parsedDeletionLines >= hunkData.deletionCount || parsedAdditionLines >= hunkData.additionCount)) throw Error(\"parsePatchContent: hunk has too many context lines\");\n\t\t\t\tconst line = getParsedLineContent(rawLine);\n\t\t\t\tif (currentContent == null || currentContent.type !== \"context\") {\n\t\t\t\t\tcurrentContent = createContentGroup(\"context\", deletionLineIndex, additionLineIndex);\n\t\t\t\t\thunkData.hunkContent.push(currentContent);\n\t\t\t\t}\n\t\t\t\tadditionLineIndex++;\n\t\t\t\tdeletionLineIndex++;\n\t\t\t\tparsedAdditionLines++;\n\t\t\t\tparsedDeletionLines++;\n\t\t\t\tif (isPartial) {\n\t\t\t\t\tcurrentFile.deletionLines.push(line);\n\t\t\t\t\tcurrentFile.additionLines.push(line);\n\t\t\t\t}\n\t\t\t\tcurrentContent.lines++;\n\t\t\t\tlastLineType = \"context\";\n\t\t\t} else if (type === \"metadata\" && currentContent != null) {\n\t\t\t\tif (currentContent.type === \"context\") {\n\t\t\t\t\thunkData.noEOFCRAdditions = true;\n\t\t\t\t\thunkData.noEOFCRDeletions = true;\n\t\t\t\t} else if (lastLineType === \"deletion\") hunkData.noEOFCRDeletions = true;\n\t\t\t\telse if (lastLineType === \"addition\") hunkData.noEOFCRAdditions = true;\n\t\t\t\tif (isPartial && (lastLineType === \"addition\" || lastLineType === \"context\")) {\n\t\t\t\t\tconst lastIndex = currentFile.additionLines.length - 1;\n\t\t\t\t\tif (lastIndex >= 0) currentFile.additionLines[lastIndex] = cleanLastNewline(currentFile.additionLines[lastIndex]);\n\t\t\t\t}\n\t\t\t\tif (isPartial && (lastLineType === \"deletion\" || lastLineType === \"context\")) {\n\t\t\t\t\tconst lastIndex = currentFile.deletionLines.length - 1;\n\t\t\t\t\tif (lastIndex >= 0) currentFile.deletionLines[lastIndex] = cleanLastNewline(currentFile.deletionLines[lastIndex]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (parsedAdditionLines !== hunkData.additionCount || parsedDeletionLines !== hunkData.deletionCount) {\n\t\t\tif (throwOnError) throw Error(\"parsePatchContent: hunk line count mismatch\");\n\t\t\tconsole.error(`parsePatchContent: hunk line count mismatch: \"${firstLine.trimEnd()}\", declared old/new ${hunkData.deletionCount}/${hunkData.additionCount}, parsed old/new ${parsedDeletionLines}/${parsedAdditionLines}`);\n\t\t\tconst repairedAdditionStart = getHunkSideStartBoundary(hunkData.additionStart, hunkData.additionCount) + (parsedAdditionLines === 0 ? 0 : 1);\n\t\t\tconst repairedDeletionStart = getHunkSideStartBoundary(hunkData.deletionStart, hunkData.deletionCount) + (parsedDeletionLines === 0 ? 0 : 1);\n\t\t\tif (!isPartial) {\n\t\t\t\tconst additionStartDelta = repairedAdditionStart - hunkData.additionStart;\n\t\t\t\tconst deletionStartDelta = repairedDeletionStart - hunkData.deletionStart;\n\t\t\t\thunkData.additionLineIndex += additionStartDelta;\n\t\t\t\thunkData.deletionLineIndex += deletionStartDelta;\n\t\t\t\tfor (const content of hunkData.hunkContent) {\n\t\t\t\t\tcontent.additionLineIndex += additionStartDelta;\n\t\t\t\t\tcontent.deletionLineIndex += deletionStartDelta;\n\t\t\t\t}\n\t\t\t}\n\t\t\thunkData.additionStart = repairedAdditionStart;\n\t\t\thunkData.deletionStart = repairedDeletionStart;\n\t\t\thunkData.additionCount = parsedAdditionLines;\n\t\t\thunkData.deletionCount = parsedDeletionLines;\n\t\t}\n\t\thunkData.additionLines = additionLines;\n\t\thunkData.deletionLines = deletionLines;\n\t\thunkData.collapsedBefore = Math.max(getHunkSideStartBoundary(hunkData.additionStart, hunkData.additionCount) - lastHunkEnd, 0);\n\t\tcurrentFile.hunks.push(hunkData);\n\t\tlastHunkEnd = getHunkSideEndBoundary(hunkData.additionStart, hunkData.additionCount);\n\t\tfor (const content of hunkData.hunkContent) if (content.type === \"context\") {\n\t\t\thunkData.splitLineCount += content.lines;\n\t\t\thunkData.unifiedLineCount += content.lines;\n\t\t} else {\n\t\t\thunkData.splitLineCount += Math.max(content.additions, content.deletions);\n\t\t\thunkData.unifiedLineCount += content.deletions + content.additions;\n\t\t}\n\t\thunkData.splitLineStart = currentFile.splitLineCount + hunkData.collapsedBefore;\n\t\thunkData.unifiedLineStart = currentFile.unifiedLineCount + hunkData.collapsedBefore;\n\t\tcurrentFile.splitLineCount += hunkData.collapsedBefore + hunkData.splitLineCount;\n\t\tcurrentFile.unifiedLineCount += hunkData.collapsedBefore + hunkData.unifiedLineCount;\n\t}\n\tif (currentFile == null) return;\n\tif (throwOnError && isPartial && !isGitDiff && currentFile.hunks.length === 0) throw Error(\"parsePatchContent: unified file has no hunks\");\n\tif (currentFile.hunks.length > 0 && !isPartial && currentFile.additionLines.length > 0 && currentFile.deletionLines.length > 0) {\n\t\tconst lastHunk = currentFile.hunks[currentFile.hunks.length - 1];\n\t\tconst lastHunkEnd = getHunkSideEndBoundary(lastHunk.additionStart, lastHunk.additionCount);\n\t\tconst totalFileLines = currentFile.additionLines.length;\n\t\tconst collapsedAfter = Math.max(totalFileLines - lastHunkEnd, 0);\n\t\tcurrentFile.splitLineCount += collapsedAfter;\n\t\tcurrentFile.unifiedLineCount += collapsedAfter;\n\t}\n\tif (!isGitDiff) {\n\t\tif (currentFile.prevName != null && currentFile.name !== currentFile.prevName) {\n\t\t\tif (currentFile.hunks.length > 0) currentFile.type = \"rename-changed\";\n\t\t\telse currentFile.type = \"rename-pure\";\n\t\t} else if ((oldFile == null || oldFile.contents === \"\") && newFile != null && newFile.contents !== \"\") currentFile.type = \"new\";\n\t\telse if (oldFile != null && oldFile.contents !== \"\" && (newFile == null || newFile.contents === \"\")) currentFile.type = \"deleted\";\n\t}\n\tif (currentFile.type !== \"rename-pure\" && currentFile.type !== \"rename-changed\") currentFile.prevName = void 0;\n\trealignChangeContentBySimilarity(currentFile);\n\treturn currentFile;\n}\n/**\n* Parses a patch file string into an array of parsed patches.\n*\n* @param data - The raw patch file content (supports multi-commit patches)\n* @param cacheKeyPrefix - Optional prefix for collision-safe cache keys derived\n* from the prefix, patch index, and file index. This enables caching of\n* rendered diff results in the worker pool.\n* @param throwOnError - When true, invalid data throws. When false, invalid data\n* is reported with `console.error` and the parser attempts to recover when\n* possible. Recovery is best-effort and does not guarantee valid output.\n*/\nfunction parsePatchFiles(data, cacheKeyPrefix, throwOnError = false) {\n\tconst patches = [];\n\tconst rawPatches = hasCommitMetadataBoundary(data) ? data.split(COMMIT_METADATA_SPLIT) : [data];\n\tfor (const patch of rawPatches) try {\n\t\tpatches.push(_processPatch(patch, cacheKeyPrefix, throwOnError, cacheKeyPrefix != null ? patches.length : void 0));\n\t} catch (error) {\n\t\tif (throwOnError) throw error;\n\t\telse console.error(error);\n\t} finally {\n\t\treleaseStringDetachBuffer();\n\t}\n\treturn patches;\n}\nfunction decodeDiffFileName(value, stripGitPrefix = false) {\n\tconst rawName = value.trim();\n\tconst name = rawName.startsWith(\"\\\"\") ? parseQuotedDiffFileName(rawName)?.fileName ?? rawName : rawName;\n\treturn stripGitPrefix && (name.startsWith(\"a/\") || name.startsWith(\"b/\")) ? name.slice(2) : name;\n}\nfunction hasCommitMetadataBoundary(data) {\n\treturn data.startsWith(\"From \") || data.includes(\"\\nFrom \");\n}\nfunction splitFileContents(contents) {\n\tconst lines = splitWithNewlines(contents);\n\tfor (let index = 0; index < lines.length; index++) lines[index] = detachString(lines[index]);\n\treturn lines;\n}\nfunction splitWithNewlines(contents) {\n\tif (contents.length === 0) return [\"\"];\n\tconst lines = [];\n\tlet startIndex = 0;\n\tfor (;;) {\n\t\tconst newlineIndex = contents.indexOf(\"\\n\", startIndex);\n\t\tif (newlineIndex === -1) break;\n\t\tlines.push(contents.slice(startIndex, newlineIndex + 1));\n\t\tstartIndex = newlineIndex + 1;\n\t}\n\tif (startIndex < contents.length) lines.push(contents.slice(startIndex));\n\treturn lines;\n}\nfunction splitGitDiffFiles(contents) {\n\treturn splitAtLinePrefix(contents, \"diff --git\");\n}\nfunction splitUnifiedDiffFiles(contents) {\n\tif (contents.length === 0) return [\"\"];\n\tconst parts = [];\n\tlet partStartIndex = 0;\n\tlet lineStartIndex = 0;\n\tlet remainingDeletionLines = 0;\n\tlet remainingAdditionLines = 0;\n\tlet hasOpenedUnifiedFile = false;\n\twhile (lineStartIndex < contents.length) {\n\t\tconst nextLineStartIndex = getNextLineStartIndex(contents, lineStartIndex);\n\t\tif (remainingDeletionLines <= 0 && remainingAdditionLines <= 0) {\n\t\t\tif (isUnifiedDiffFileHeaderAt(contents, lineStartIndex)) {\n\t\t\t\tif (lineStartIndex > partStartIndex) parts.push(contents.slice(partStartIndex, lineStartIndex));\n\t\t\t\tpartStartIndex = lineStartIndex;\n\t\t\t\thasOpenedUnifiedFile = true;\n\t\t\t\tlineStartIndex = getNextLineStartIndex(contents, nextLineStartIndex);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (hasOpenedUnifiedFile && contents.startsWith(\"@@ -\", lineStartIndex)) {\n\t\t\t\tconst fileHeader = parseHunkHeader(contents.slice(lineStartIndex, nextLineStartIndex));\n\t\t\t\tif (fileHeader != null) {\n\t\t\t\t\tremainingDeletionLines = fileHeader.deletionCount;\n\t\t\t\t\tremainingAdditionLines = fileHeader.additionCount;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlineStartIndex = nextLineStartIndex;\n\t\t\tcontinue;\n\t\t}\n\t\tconst firstChar = contents[lineStartIndex];\n\t\tif (firstChar === \"\\\\\") {\n\t\t\tlineStartIndex = nextLineStartIndex;\n\t\t\tcontinue;\n\t\t}\n\t\tif (firstChar === \" \") {\n\t\t\tremainingDeletionLines = Math.max(remainingDeletionLines - 1, 0);\n\t\t\tremainingAdditionLines = Math.max(remainingAdditionLines - 1, 0);\n\t\t} else if (firstChar === \"-\") remainingDeletionLines = Math.max(remainingDeletionLines - 1, 0);\n\t\telse if (firstChar === \"+\") remainingAdditionLines = Math.max(remainingAdditionLines - 1, 0);\n\t\tlineStartIndex = nextLineStartIndex;\n\t}\n\tparts.push(contents.slice(partStartIndex));\n\treturn parts;\n}\nfunction startsWithUnifiedDiffFileHeader(contents) {\n\treturn isUnifiedDiffFileHeaderAt(contents, 0);\n}\nfunction isUnifiedDiffFileHeaderAt(contents, lineStartIndex) {\n\tconst nextLineStartIndex = getNextLineStartIndex(contents, lineStartIndex);\n\treturn isUnifiedDiffHeaderLineAt(contents, lineStartIndex, \"---\") && isUnifiedDiffHeaderLineAt(contents, nextLineStartIndex, \"+++\");\n}\nfunction isUnifiedDiffHeaderLineAt(contents, lineStartIndex, prefix) {\n\tif (!contents.startsWith(prefix, lineStartIndex)) return false;\n\tconst separator = contents[lineStartIndex + prefix.length];\n\tif (separator !== \" \" && separator !== \"\t\") return false;\n\tfor (let index = lineStartIndex + prefix.length + 1; index < contents.length; index++) {\n\t\tconst char = contents[index];\n\t\tif (char === \"\\n\" || char === \"\\r\") break;\n\t\tif (char !== \" \" && char !== \"\t\") return true;\n\t}\n\treturn false;\n}\nfunction getNextLineStartIndex(contents, lineStartIndex) {\n\tconst newlineIndex = contents.indexOf(\"\\n\", lineStartIndex);\n\treturn newlineIndex === -1 ? contents.length : newlineIndex + 1;\n}\nfunction isHunkBodyLine(line) {\n\tconst firstChar = line[0];\n\treturn firstChar === \"+\" || firstChar === \"-\" || firstChar === \" \";\n}\nfunction isFormatPatchVersionSeparator(line) {\n\tif (!line.startsWith(\"--\")) return false;\n\tfor (let index = 2; index < line.length; index++) {\n\t\tconst char = line[index];\n\t\tif (char !== \" \" && char !== \"\t\" && char !== \"\\n\" && char !== \"\\r\") return false;\n\t}\n\treturn true;\n}\nfunction parseHunkHeader(line) {\n\tif (!line.startsWith(\"@@ -\")) return;\n\tlet index = 4;\n\tconst deletionStartResult = readPositiveInteger(line, index);\n\tif (deletionStartResult == null) return;\n\tconst deletionStart = deletionStartResult.value;\n\tindex = deletionStartResult.endIndex;\n\tlet deletionCount = 1;\n\tif (line[index] === \",\") {\n\t\tconst deletionCountResult = readPositiveInteger(line, index + 1);\n\t\tif (deletionCountResult == null) return;\n\t\tdeletionCount = deletionCountResult.value;\n\t\tindex = deletionCountResult.endIndex;\n\t}\n\tif (line[index] !== \" \" || line[index + 1] !== \"+\") return;\n\tindex += 2;\n\tconst additionStartResult = readPositiveInteger(line, index);\n\tif (additionStartResult == null) return;\n\tconst additionStart = additionStartResult.value;\n\tindex = additionStartResult.endIndex;\n\tlet additionCount = 1;\n\tif (line[index] === \",\") {\n\t\tconst additionCountResult = readPositiveInteger(line, index + 1);\n\t\tif (additionCountResult == null) return;\n\t\tadditionCount = additionCountResult.value;\n\t\tindex = additionCountResult.endIndex;\n\t}\n\tif (line[index] !== \" \" || line[index + 1] !== \"@\" || line[index + 2] !== \"@\") return;\n\tlet hunkContext;\n\tconst contextStartIndex = index + 3;\n\tif (line[contextStartIndex] === \" \") hunkContext = trimLineEnd(line.slice(contextStartIndex + 1));\n\treturn {\n\t\tadditionCount,\n\t\tadditionStart,\n\t\tdeletionCount,\n\t\tdeletionStart,\n\t\thunkContext\n\t};\n}\nfunction readPositiveInteger(value, startIndex) {\n\tlet index = startIndex;\n\tlet parsedValue = 0;\n\tfor (; index < value.length; index++) {\n\t\tconst digit = value.charCodeAt(index) - 48;\n\t\tif (digit < 0 || digit > 9) break;\n\t\tparsedValue = parsedValue * 10 + digit;\n\t}\n\tif (index === startIndex) return;\n\treturn {\n\t\tvalue: parsedValue,\n\t\tendIndex: index\n\t};\n}\nfunction trimLineEnd(value) {\n\tif (value.endsWith(\"\\r\\n\")) return value.slice(0, -2);\n\tif (value.endsWith(\"\\n\")) return value.slice(0, -1);\n\treturn value;\n}\nfunction isGitDiffPatch(data) {\n\treturn data.startsWith(\"diff --git\") || data.includes(\"\\ndiff --git\");\n}\nfunction splitAtLinePrefix(contents, prefix) {\n\tif (contents.length === 0) return [\"\"];\n\tconst newlinePrefix = `\\n${prefix}`;\n\tconst firstBoundaryIndex = contents.startsWith(prefix) ? 0 : findLinePrefixIndex(contents, newlinePrefix, 0);\n\tif (firstBoundaryIndex === -1) return [contents];\n\tconst parts = [];\n\tif (firstBoundaryIndex > 0) parts.push(contents.slice(0, firstBoundaryIndex));\n\tlet startIndex = firstBoundaryIndex;\n\tfor (;;) {\n\t\tconst nextBoundaryIndex = findLinePrefixIndex(contents, newlinePrefix, startIndex + 1);\n\t\tif (nextBoundaryIndex === -1) break;\n\t\tparts.push(contents.slice(startIndex, nextBoundaryIndex));\n\t\tstartIndex = nextBoundaryIndex;\n\t}\n\tparts.push(contents.slice(startIndex));\n\treturn parts;\n}\nfunction findLinePrefixIndex(contents, newlinePrefix, fromIndex) {\n\tconst index = contents.indexOf(newlinePrefix, fromIndex);\n\treturn index === -1 ? -1 : index + 1;\n}\nfunction maybeDetachOptionalString(value) {\n\treturn value == null ? value : detachString(value);\n}\nfunction parseRawLineType(firstChar) {\n\treturn firstChar === \" \" ? \"context\" : firstChar === \"\\\\\" ? \"metadata\" : firstChar === \"+\" ? \"addition\" : \"deletion\";\n}\nfunction getParsedLineContent(rawLine) {\n\tconst processedLine = rawLine.slice(1);\n\treturn detachString(processedLine === \"\" ? \"\\n\" : processedLine);\n}\nfunction createContentGroup(type, deletionLineIndex, additionLineIndex) {\n\tif (type === \"change\") return {\n\t\ttype: \"change\",\n\t\tadditions: 0,\n\t\tdeletions: 0,\n\t\tadditionLineIndex,\n\t\tdeletionLineIndex\n\t};\n\treturn {\n\t\ttype: \"context\",\n\t\tlines: 0,\n\t\tadditionLineIndex,\n\t\tdeletionLineIndex\n\t};\n}\n//#endregion\nexport { parsePatchFiles, processFile, processPatch };\n\n//# sourceMappingURL=parsePatchFiles.js.map","export default class Diff {\n diff(oldStr, newStr, \n // Type below is not accurate/complete - see above for full possibilities - but it compiles\n options = {}) {\n let callback;\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n else if ('callback' in options) {\n callback = options.callback;\n }\n // Allow subclasses to massage the input prior to running\n const oldString = this.castInput(oldStr, options);\n const newString = this.castInput(newStr, options);\n const oldTokens = this.removeEmpty(this.tokenize(oldString, options));\n const newTokens = this.removeEmpty(this.tokenize(newString, options));\n return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);\n }\n diffWithOptionsObj(oldTokens, newTokens, options, callback) {\n var _a;\n const done = (value) => {\n value = this.postProcess(value, options);\n if (callback) {\n setTimeout(function () { callback(value); }, 0);\n return undefined;\n }\n else {\n return value;\n }\n };\n const newLen = newTokens.length, oldLen = oldTokens.length;\n let editLength = 1;\n let maxEditLength = newLen + oldLen;\n if (options.maxEditLength != null) {\n maxEditLength = Math.min(maxEditLength, options.maxEditLength);\n }\n const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;\n const abortAfterTimestamp = Date.now() + maxExecutionTime;\n const bestPath = [{ oldPos: -1, lastComponent: undefined }];\n // Seed editLength = 0, i.e. the content starts with the same values\n let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);\n if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {\n // Identity per the equality and tokenizer\n return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));\n }\n // Once we hit the right edge of the edit graph on some diagonal k, we can\n // definitely reach the end of the edit graph in no more than k edits, so\n // there's no point in considering any moves to diagonal k+1 any more (from\n // which we're guaranteed to need at least k+1 more edits).\n // Similarly, once we've reached the bottom of the edit graph, there's no\n // point considering moves to lower diagonals.\n // We record this fact by setting minDiagonalToConsider and\n // maxDiagonalToConsider to some finite value once we've hit the edge of\n // the edit graph.\n // This optimization is not faithful to the original algorithm presented in\n // Myers's paper, which instead pointlessly extends D-paths off the end of\n // the edit graph - see page 7 of Myers's paper which notes this point\n // explicitly and illustrates it with a diagram. This has major performance\n // implications for some common scenarios. For instance, to compute a diff\n // where the new text simply appends d characters on the end of the\n // original text of length n, the true Myers algorithm will take O(n+d^2)\n // time while this optimization needs only O(n+d) time.\n let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;\n // Main worker method. checks all permutations of a given edit length for acceptance.\n const execEditLength = () => {\n for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {\n let basePath;\n const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];\n if (removePath) {\n // No one else is going to attempt to use this value, clear it\n // @ts-expect-error - perf optimisation. This type-violating value will never be read.\n bestPath[diagonalPath - 1] = undefined;\n }\n let canAdd = false;\n if (addPath) {\n // what newPos will be after we do an insertion:\n const addPathNewPos = addPath.oldPos - diagonalPath;\n canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;\n }\n const canRemove = removePath && removePath.oldPos + 1 < oldLen;\n if (!canAdd && !canRemove) {\n // If this path is a terminal then prune\n // @ts-expect-error - perf optimisation. This type-violating value will never be read.\n bestPath[diagonalPath] = undefined;\n continue;\n }\n // Select the diagonal that we want to branch from. We select the prior\n // path whose position in the old string is the farthest from the origin\n // and does not pass the bounds of the diff graph\n if (!canRemove || (canAdd && removePath.oldPos < addPath.oldPos)) {\n basePath = this.addToPath(addPath, true, false, 0, options);\n }\n else {\n basePath = this.addToPath(removePath, false, true, 1, options);\n }\n newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);\n if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {\n // If we have hit the end of both strings, then we are done\n return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;\n }\n else {\n bestPath[diagonalPath] = basePath;\n if (basePath.oldPos + 1 >= oldLen) {\n maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);\n }\n if (newPos + 1 >= newLen) {\n minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);\n }\n }\n }\n editLength++;\n };\n // Performs the length of edit iteration. Is a bit fugly as this has to support the\n // sync and async mode which is never fun. Loops over execEditLength until a value\n // is produced, or until the edit length exceeds options.maxEditLength (if given),\n // in which case it will return undefined.\n if (callback) {\n (function exec() {\n setTimeout(function () {\n if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {\n return callback(undefined);\n }\n if (!execEditLength()) {\n exec();\n }\n }, 0);\n }());\n }\n else {\n while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {\n const ret = execEditLength();\n if (ret) {\n return ret;\n }\n }\n }\n }\n addToPath(path, added, removed, oldPosInc, options) {\n const last = path.lastComponent;\n if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {\n return {\n oldPos: path.oldPos + oldPosInc,\n lastComponent: { count: last.count + 1, added: added, removed: removed, previousComponent: last.previousComponent }\n };\n }\n else {\n return {\n oldPos: path.oldPos + oldPosInc,\n lastComponent: { count: 1, added: added, removed: removed, previousComponent: last }\n };\n }\n }\n extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {\n const newLen = newTokens.length, oldLen = oldTokens.length;\n let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;\n while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {\n newPos++;\n oldPos++;\n commonCount++;\n if (options.oneChangePerToken) {\n basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };\n }\n }\n if (commonCount && !options.oneChangePerToken) {\n basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };\n }\n basePath.oldPos = oldPos;\n return newPos;\n }\n equals(left, right, options) {\n if (options.comparator) {\n return options.comparator(left, right);\n }\n else {\n return left === right\n || (!!options.ignoreCase && left.toLowerCase() === right.toLowerCase());\n }\n }\n removeEmpty(array) {\n const ret = [];\n for (let i = 0; i < array.length; i++) {\n if (array[i]) {\n ret.push(array[i]);\n }\n }\n return ret;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n castInput(value, options) {\n return value;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n tokenize(value, options) {\n return Array.from(value);\n }\n join(chars) {\n // Assumes ValueT is string, which is the case for most subclasses.\n // When it's false, e.g. in diffArrays, this method needs to be overridden (e.g. with a no-op)\n // Yes, the casts are verbose and ugly, because this pattern - of having the base class SORT OF\n // assume tokens and values are strings, but not completely - is weird and janky.\n return chars.join('');\n }\n postProcess(changeObjects, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n options) {\n return changeObjects;\n }\n get useLongestToken() {\n return false;\n }\n buildValues(lastComponent, newTokens, oldTokens) {\n // First we convert our linked list of components in reverse order to an\n // array in the right order:\n const components = [];\n let nextComponent;\n while (lastComponent) {\n components.push(lastComponent);\n nextComponent = lastComponent.previousComponent;\n delete lastComponent.previousComponent;\n lastComponent = nextComponent;\n }\n components.reverse();\n const componentLen = components.length;\n let componentPos = 0, newPos = 0, oldPos = 0;\n for (; componentPos < componentLen; componentPos++) {\n const component = components[componentPos];\n if (!component.removed) {\n if (!component.added && this.useLongestToken) {\n let value = newTokens.slice(newPos, newPos + component.count);\n value = value.map(function (value, i) {\n const oldValue = oldTokens[oldPos + i];\n return oldValue.length > value.length ? oldValue : value;\n });\n component.value = this.join(value);\n }\n else {\n component.value = this.join(newTokens.slice(newPos, newPos + component.count));\n }\n newPos += component.count;\n // Common case\n if (!component.added) {\n oldPos += component.count;\n }\n }\n else {\n component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));\n oldPos += component.count;\n }\n }\n return components;\n }\n}\n","import Diff from './base.js';\nclass CharacterDiff extends Diff {\n}\nexport const characterDiff = new CharacterDiff();\nexport function diffChars(oldStr, newStr, options) {\n return characterDiff.diff(oldStr, newStr, options);\n}\n","export function longestCommonPrefix(str1, str2) {\n let i;\n for (i = 0; i < str1.length && i < str2.length; i++) {\n if (str1[i] != str2[i]) {\n return str1.slice(0, i);\n }\n }\n return str1.slice(0, i);\n}\nexport function longestCommonSuffix(str1, str2) {\n let i;\n // Unlike longestCommonPrefix, we need a special case to handle all scenarios\n // where we return the empty string since str1.slice(-0) will return the\n // entire string.\n if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {\n return '';\n }\n for (i = 0; i < str1.length && i < str2.length; i++) {\n if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {\n return str1.slice(-i);\n }\n }\n return str1.slice(-i);\n}\nexport function replacePrefix(string, oldPrefix, newPrefix) {\n if (string.slice(0, oldPrefix.length) != oldPrefix) {\n throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);\n }\n return newPrefix + string.slice(oldPrefix.length);\n}\nexport function replaceSuffix(string, oldSuffix, newSuffix) {\n if (!oldSuffix) {\n return string + newSuffix;\n }\n if (string.slice(-oldSuffix.length) != oldSuffix) {\n throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);\n }\n return string.slice(0, -oldSuffix.length) + newSuffix;\n}\nexport function removePrefix(string, oldPrefix) {\n return replacePrefix(string, oldPrefix, '');\n}\nexport function removeSuffix(string, oldSuffix) {\n return replaceSuffix(string, oldSuffix, '');\n}\nexport function maximumOverlap(string1, string2) {\n return string2.slice(0, overlapCount(string1, string2));\n}\n// Nicked from https://stackoverflow.com/a/60422853/1709587\nfunction overlapCount(a, b) {\n // Deal with cases where the strings differ in length\n let startA = 0;\n if (a.length > b.length) {\n startA = a.length - b.length;\n }\n let endB = b.length;\n if (a.length < b.length) {\n endB = a.length;\n }\n // Create a back-reference for each index\n // that should be followed in case of a mismatch.\n // We only need B to make these references:\n const map = Array(endB);\n let k = 0; // Index that lags behind j\n map[0] = 0;\n for (let j = 1; j < endB; j++) {\n if (b[j] == b[k]) {\n map[j] = map[k]; // skip over the same character (optional optimisation)\n }\n else {\n map[j] = k;\n }\n while (k > 0 && b[j] != b[k]) {\n k = map[k];\n }\n if (b[j] == b[k]) {\n k++;\n }\n }\n // Phase 2: use these references while iterating over A\n k = 0;\n for (let i = startA; i < a.length; i++) {\n while (k > 0 && a[i] != b[k]) {\n k = map[k];\n }\n if (a[i] == b[k]) {\n k++;\n }\n }\n return k;\n}\n/**\n * Returns true if the string consistently uses Windows line endings.\n */\nexport function hasOnlyWinLineEndings(string) {\n return string.includes('\\r\\n') && !string.startsWith('\\n') && !string.match(/[^\\r]\\n/);\n}\n/**\n * Returns true if the string consistently uses Unix line endings.\n */\nexport function hasOnlyUnixLineEndings(string) {\n return !string.includes('\\r\\n') && string.includes('\\n');\n}\n/**\n * Split a string into segments using a word segmenter, merging consecutive\n * segments if they are both whitespace segments. Whitespace segments can\n * appear adjacent to one another for two reasons:\n * - newlines always get their own segment\n * - where a diacritic is attached to a whitespace character in the text, the\n * segment ends after the diacritic, so e.g. \" \\u0300 \" becomes two segments.\n * This function therefore runs the segmenter's .segment() method and then\n * merges consecutive segments of whitespace into a single part.\n */\nexport function segment(string, segmenter) {\n const parts = [];\n for (const segmentObj of Array.from(segmenter.segment(string))) {\n const segment = segmentObj.segment;\n if (parts.length && (/\\s/).test(parts[parts.length - 1]) && (/\\s/).test(segment)) {\n parts[parts.length - 1] += segment;\n }\n else {\n parts.push(segment);\n }\n }\n return parts;\n}\n// The functions below take a `segmenter` argument so that, when called from\n// diffWords when it is using a segmenter, they can use a notion of what\n// constitutes \"whitespace\" that is consistent with the segmenter.\n//\n// USUALLY this will be identical to the result of the non-segmenter-based\n// logic, but it differs in at least one case: when whitespace characters are\n// modified by diacritics. A word segmenter considers these diacritics to be\n// part of the whitespace, whereas our non-segmenter-based logic does not.\n//\n// Because the segmenter-based approach necessarily requires segmenting the\n// entire string, we offer a leadingAndTrailingWs function to allow getting the\n// whitespace prefix AND whitespace suffix with a single call to the segmenter,\n// for efficiency's sake.\nexport function trailingWs(string, segmenter) {\n if (segmenter) {\n return leadingAndTrailingWs(string, segmenter)[1];\n }\n // Yes, this looks overcomplicated and dumb - why not replace the whole function with\n // return string.match(/\\s*$/)[0]\n // you ask? Because:\n // 1. the trap described at https://markamery.com/blog/quadratic-time-regexes/ would mean doing\n // this would cause this function to take O(n²) time in the worst case (specifically when\n // there is a massive run of NON-TRAILING whitespace in `string`), and\n // 2. the fix proposed in the same blog post, of using a negative lookbehind, is incompatible\n // with old Safari versions that we'd like to not break if possible (see\n // https://github.com/kpdecker/jsdiff/pull/550)\n // It feels absurd to do this with an explicit loop instead of a regex, but I really can't see a\n // better way that doesn't result in broken behaviour.\n let i;\n for (i = string.length - 1; i >= 0; i--) {\n if (!string[i].match(/\\s/)) {\n break;\n }\n }\n return string.substring(i + 1);\n}\nexport function leadingWs(string, segmenter) {\n if (segmenter) {\n return leadingAndTrailingWs(string, segmenter)[0];\n }\n // Thankfully the annoying considerations described in trailingWs don't apply here:\n const match = string.match(/^\\s*/);\n return match ? match[0] : '';\n}\nexport function leadingAndTrailingWs(string, segmenter) {\n if (!segmenter) {\n return [leadingWs(string), trailingWs(string)];\n }\n if (segmenter.resolvedOptions().granularity != 'word') {\n throw new Error('The segmenter passed must have a granularity of \"word\"');\n }\n const segments = segment(string, segmenter);\n const firstSeg = segments[0];\n const lastSeg = segments[segments.length - 1];\n const head = (/\\s/).test(firstSeg) ? firstSeg : '';\n const tail = (/\\s/).test(lastSeg) ? lastSeg : '';\n return [head, tail];\n}\n","import Diff from './base.js';\nimport { longestCommonPrefix, longestCommonSuffix, replacePrefix, replaceSuffix, removePrefix, removeSuffix, maximumOverlap, leadingWs, trailingWs, leadingAndTrailingWs, segment } from '../util/string.js';\n// Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode\n//\n// Chars/ranges counted as \"word\" characters by this regex are as follows:\n//\n// + U+00AD Soft hyphen\n// + 00C0–00FF (letters with diacritics from the Latin-1 Supplement), except:\n// - U+00D7 × Multiplication sign\n// - U+00F7 ÷ Division sign\n// + Latin Extended-A, 0100–017F\n// + Latin Extended-B, 0180–024F\n// + IPA Extensions, 0250–02AF\n// + Spacing Modifier Letters, 02B0–02FF, except:\n// - U+02C7 ˇ &#711; Caron\n// - U+02D8 ˘ &#728; Breve\n// - U+02D9 ˙ &#729; Dot Above\n// - U+02DA ˚ &#730; Ring Above\n// - U+02DB ˛ &#731; Ogonek\n// - U+02DC ˜ &#732; Small Tilde\n// - U+02DD ˝ &#733; Double Acute Accent\n// + Latin Extended Additional, 1E00–1EFF\nconst extendedWordChars = 'a-zA-Z0-9_\\\\u{AD}\\\\u{C0}-\\\\u{D6}\\\\u{D8}-\\\\u{F6}\\\\u{F8}-\\\\u{2C6}\\\\u{2C8}-\\\\u{2D7}\\\\u{2DE}-\\\\u{2FF}\\\\u{1E00}-\\\\u{1EFF}';\n// Each token is one of the following:\n// - A punctuation mark plus the surrounding whitespace\n// - A word plus the surrounding whitespace\n// - Pure whitespace (but only in the special case where the entire text\n// is just whitespace)\n//\n// We have to include surrounding whitespace in the tokens because the two\n// alternative approaches produce horribly broken results:\n// * If we just discard the whitespace, we can't fully reproduce the original\n// text from the sequence of tokens and any attempt to render the diff will\n// get the whitespace wrong.\n// * If we have separate tokens for whitespace, then in a typical text every\n// second token will be a single space character. But this often results in\n// the optimal diff between two texts being a perverse one that preserves\n// the spaces between words but deletes and reinserts actual common words.\n// See https://github.com/kpdecker/jsdiff/issues/160#issuecomment-1866099640\n// for an example.\n//\n// Keeping the surrounding whitespace of course has implications for .equals\n// and .join, not just .tokenize.\n// This regex does NOT fully implement the tokenization rules described above.\n// Instead, it gives runs of whitespace their own \"token\". The tokenize method\n// then handles stitching whitespace tokens onto adjacent word or punctuation\n// tokens.\nconst tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\\\s+|[^${extendedWordChars}]`, 'ug');\nclass WordDiff extends Diff {\n equals(left, right, options) {\n if (options.ignoreCase) {\n left = left.toLowerCase();\n right = right.toLowerCase();\n }\n return left.trim() === right.trim();\n }\n tokenize(value, options = {}) {\n let parts;\n if (options.intlSegmenter) {\n const segmenter = options.intlSegmenter;\n if (segmenter.resolvedOptions().granularity != 'word') {\n throw new Error('The segmenter passed must have a granularity of \"word\"');\n }\n // We want `parts` to be an array whose elements alternate between being\n // pure whitespace and being pure non-whitespace. This is ALMOST what the\n // segments returned by a word-based Intl.Segmenter already look like,\n // but not quite - see explanation in the docs of our custom segment()\n // function.\n parts = segment(value, segmenter);\n }\n else {\n parts = value.match(tokenizeIncludingWhitespace) || [];\n }\n const tokens = [];\n let prevPart = null;\n parts.forEach(part => {\n if ((/\\s/).test(part)) {\n if (prevPart == null) {\n tokens.push(part);\n }\n else {\n tokens.push(tokens.pop() + part);\n }\n }\n else if (prevPart != null && (/\\s/).test(prevPart)) {\n if (tokens[tokens.length - 1] == prevPart) {\n tokens.push(tokens.pop() + part);\n }\n else {\n tokens.push(prevPart + part);\n }\n }\n else {\n tokens.push(part);\n }\n prevPart = part;\n });\n return tokens;\n }\n join(tokens) {\n // Tokens being joined here will always have appeared consecutively in the\n // same text, so we can simply strip off the leading whitespace from all the\n // tokens except the first (and except any whitespace-only tokens - but such\n // a token will always be the first and only token anyway) and then join them\n // and the whitespace around words and punctuation will end up correct.\n return tokens.map((token, i) => {\n if (i == 0) {\n return token;\n }\n else {\n return token.replace((/^\\s+/), '');\n }\n }).join('');\n }\n postProcess(changes, options) {\n if (!changes || options.oneChangePerToken) {\n return changes;\n }\n let lastKeep = null;\n // Change objects representing any insertion or deletion since the last\n // \"keep\" change object. There can be at most one of each.\n let insertion = null;\n let deletion = null;\n changes.forEach(change => {\n if (change.added) {\n insertion = change;\n }\n else if (change.removed) {\n deletion = change;\n }\n else {\n if (insertion || deletion) { // May be false at start of text\n dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change, options.intlSegmenter);\n }\n lastKeep = change;\n insertion = null;\n deletion = null;\n }\n });\n if (insertion || deletion) {\n dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null, options.intlSegmenter);\n }\n return changes;\n }\n}\nexport const wordDiff = new WordDiff();\nexport function diffWords(oldStr, newStr, options) {\n // This option has never been documented and never will be (it's clearer to\n // just call `diffWordsWithSpace` directly if you need that behavior), but\n // has existed in jsdiff for a long time, so we retain support for it here\n // for the sake of backwards compatibility.\n if ((options === null || options === void 0 ? void 0 : options.ignoreWhitespace) != null && !options.ignoreWhitespace) {\n return diffWordsWithSpace(oldStr, newStr, options);\n }\n return wordDiff.diff(oldStr, newStr, options);\n}\nfunction dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep, segmenter) {\n // Before returning, we tidy up the leading and trailing whitespace of the\n // change objects to eliminate cases where trailing whitespace in one object\n // is repeated as leading whitespace in the next.\n // Below are examples of the outcomes we want here to explain the code.\n // I=insert, K=keep, D=delete\n // 1. diffing 'foo bar baz' vs 'foo baz'\n // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'\n // After cleanup, we want: K:'foo ' D:'bar ' K:'baz'\n //\n // 2. Diffing 'foo bar baz' vs 'foo qux baz'\n // Prior to cleanup, we have K:'foo ' D:' bar ' I:' qux ' K:' baz'\n // After cleanup, we want K:'foo ' D:'bar' I:'qux' K:' baz'\n //\n // 3. Diffing 'foo\\nbar baz' vs 'foo baz'\n // Prior to cleanup, we have K:'foo ' D:'\\nbar ' K:' baz'\n // After cleanup, we want K'foo' D:'\\nbar' K:' baz'\n //\n // 4. Diffing 'foo baz' vs 'foo\\nbar baz'\n // Prior to cleanup, we have K:'foo\\n' I:'\\nbar ' K:' baz'\n // After cleanup, we ideally want K'foo' I:'\\nbar' K:' baz'\n // but don't actually manage this currently (the pre-cleanup change\n // objects don't contain enough information to make it possible).\n //\n // 5. Diffing 'foo bar baz' vs 'foo baz'\n // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'\n // After cleanup, we want K:'foo ' D:' bar ' K:'baz'\n //\n // Our handling is unavoidably imperfect in the case where there's a single\n // indel between keeps and the whitespace has changed. For instance, consider\n // diffing 'foo\\tbar\\nbaz' vs 'foo baz'. Unless we create an extra change\n // object to represent the insertion of the space character (which isn't even\n // a token), we have no way to avoid losing information about the texts'\n // original whitespace in the result we return. Still, we do our best to\n // output something that will look sensible if we e.g. print it with\n // insertions in green and deletions in red.\n // Between two \"keep\" change objects (or before the first or after the last\n // change object), we can have either:\n // * A \"delete\" followed by an \"insert\"\n // * Just an \"insert\"\n // * Just a \"delete\"\n // We handle the three cases separately.\n if (deletion && insertion) {\n const [oldWsPrefix, oldWsSuffix] = leadingAndTrailingWs(deletion.value, segmenter);\n const [newWsPrefix, newWsSuffix] = leadingAndTrailingWs(insertion.value, segmenter);\n if (startKeep) {\n const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);\n startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);\n deletion.value = removePrefix(deletion.value, commonWsPrefix);\n insertion.value = removePrefix(insertion.value, commonWsPrefix);\n }\n if (endKeep) {\n const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);\n endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);\n deletion.value = removeSuffix(deletion.value, commonWsSuffix);\n insertion.value = removeSuffix(insertion.value, commonWsSuffix);\n }\n }\n else if (insertion) {\n // The whitespaces all reflect what was in the new text rather than\n // the old, so we essentially have no information about whitespace\n // insertion or deletion. We just want to dedupe the whitespace.\n // We do that by having each change object keep its trailing\n // whitespace and deleting duplicate leading whitespace where\n // present.\n if (startKeep) {\n const ws = leadingWs(insertion.value, segmenter);\n insertion.value = insertion.value.substring(ws.length);\n }\n if (endKeep) {\n const ws = leadingWs(endKeep.value, segmenter);\n endKeep.value = endKeep.value.substring(ws.length);\n }\n // otherwise we've got a deletion and no insertion\n }\n else if (startKeep && endKeep) {\n const newWsFull = leadingWs(endKeep.value, segmenter), [delWsStart, delWsEnd] = leadingAndTrailingWs(deletion.value, segmenter);\n // Any whitespace that comes straight after startKeep in both the old and\n // new texts, assign to startKeep and remove from the deletion.\n const newWsStart = longestCommonPrefix(newWsFull, delWsStart);\n deletion.value = removePrefix(deletion.value, newWsStart);\n // Any whitespace that comes straight before endKeep in both the old and\n // new texts, and hasn't already been assigned to startKeep, assign to\n // endKeep and remove from the deletion.\n const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);\n deletion.value = removeSuffix(deletion.value, newWsEnd);\n endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);\n // If there's any whitespace from the new text that HASN'T already been\n // assigned, assign it to the start:\n startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));\n }\n else if (endKeep) {\n // We are at the start of the text. Preserve all the whitespace on\n // endKeep, and just remove whitespace from the end of deletion to the\n // extent that it overlaps with the start of endKeep.\n const endKeepWsPrefix = leadingWs(endKeep.value, segmenter);\n const deletionWsSuffix = trailingWs(deletion.value, segmenter);\n const overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);\n deletion.value = removeSuffix(deletion.value, overlap);\n }\n else if (startKeep) {\n // We are at the END of the text. Preserve all the whitespace on\n // startKeep, and just remove whitespace from the start of deletion to\n // the extent that it overlaps with the end of startKeep.\n const startKeepWsSuffix = trailingWs(startKeep.value, segmenter);\n const deletionWsPrefix = leadingWs(deletion.value, segmenter);\n const overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);\n deletion.value = removePrefix(deletion.value, overlap);\n }\n}\nclass WordsWithSpaceDiff extends Diff {\n tokenize(value) {\n // Slightly different to the tokenizeIncludingWhitespace regex used above in\n // that this one treats each individual newline as a distinct token, rather\n // than merging them into other surrounding whitespace. This was requested\n // in https://github.com/kpdecker/jsdiff/issues/180 &\n // https://github.com/kpdecker/jsdiff/issues/211\n const regex = new RegExp(`(\\\\r?\\\\n)|[${extendedWordChars}]+|[^\\\\S\\\\n\\\\r]+|[^${extendedWordChars}]`, 'ug');\n return value.match(regex) || [];\n }\n}\nexport const wordsWithSpaceDiff = new WordsWithSpaceDiff();\nexport function diffWordsWithSpace(oldStr, newStr, options) {\n return wordsWithSpaceDiff.diff(oldStr, newStr, options);\n}\n","import Diff from './base.js';\nimport { generateOptions } from '../util/params.js';\nclass LineDiff extends Diff {\n constructor() {\n super(...arguments);\n this.tokenize = tokenize;\n }\n equals(left, right, options) {\n // If we're ignoring whitespace, we need to normalise lines by stripping\n // whitespace before checking equality. (This has an annoying interaction\n // with newlineIsToken that requires special handling: if newlines get their\n // own token, then we DON'T want to trim the *newline* tokens down to empty\n // strings, since this would cause us to treat whitespace-only line content\n // as equal to a separator between lines, which would be weird and\n // inconsistent with the documented behavior of the options.)\n if (options.ignoreWhitespace) {\n if (!options.newlineIsToken || !left.includes('\\n')) {\n left = left.trim();\n }\n if (!options.newlineIsToken || !right.includes('\\n')) {\n right = right.trim();\n }\n }\n else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {\n if (left.endsWith('\\n')) {\n left = left.slice(0, -1);\n }\n if (right.endsWith('\\n')) {\n right = right.slice(0, -1);\n }\n }\n return super.equals(left, right, options);\n }\n}\nexport const lineDiff = new LineDiff();\nexport function diffLines(oldStr, newStr, options) {\n return lineDiff.diff(oldStr, newStr, options);\n}\nexport function diffTrimmedLines(oldStr, newStr, options) {\n options = generateOptions(options, { ignoreWhitespace: true });\n return lineDiff.diff(oldStr, newStr, options);\n}\n// Exported standalone so it can be used from jsonDiff too.\nexport function tokenize(value, options) {\n if (options.stripTrailingCr) {\n // remove one \\r before \\n to match GNU diff's --strip-trailing-cr behavior\n value = value.replace(/\\r\\n/g, '\\n');\n }\n const retLines = [], linesAndNewlines = value.split(/(\\n|\\r\\n)/);\n // Ignore the final empty token that occurs if the string ends with a new line\n if (!linesAndNewlines[linesAndNewlines.length - 1]) {\n linesAndNewlines.pop();\n }\n // Merge the content and line separators into single tokens\n for (let i = 0; i < linesAndNewlines.length; i++) {\n const line = linesAndNewlines[i];\n if (i % 2 && !options.newlineIsToken) {\n retLines[retLines.length - 1] += line;\n }\n else {\n retLines.push(line);\n }\n }\n return retLines;\n}\n","import Diff from './base.js';\nfunction isSentenceEndPunct(char) {\n return char == '.' || char == '!' || char == '?';\n}\nclass SentenceDiff extends Diff {\n tokenize(value) {\n var _a;\n // If in future we drop support for environments that don't support lookbehinds, we can replace\n // this entire function with:\n // return value.split(/(?<=[.!?])(\\s+|$)/);\n // but until then, for similar reasons to the trailingWs function in string.ts, we are forced\n // to do this verbosely \"by hand\" instead of using a regex.\n const result = [];\n let tokenStartI = 0;\n for (let i = 0; i < value.length; i++) {\n if (i == value.length - 1) {\n result.push(value.slice(tokenStartI));\n break;\n }\n if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\\s/)) {\n // We've hit a sentence break - i.e. a punctuation mark followed by whitespace.\n // We now want to push TWO tokens to the result:\n // 1. the sentence\n result.push(value.slice(tokenStartI, i + 1));\n // 2. the whitespace\n i = tokenStartI = i + 1;\n while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\\s/)) {\n i++;\n }\n result.push(value.slice(tokenStartI, i + 1));\n // Then the next token (a sentence) starts on the character after the whitespace.\n // (It's okay if this is off the end of the string - then the outer loop will terminate\n // here anyway.)\n tokenStartI = i + 1;\n }\n }\n return result;\n }\n}\nexport const sentenceDiff = new SentenceDiff();\nexport function diffSentences(oldStr, newStr, options) {\n return sentenceDiff.diff(oldStr, newStr, options);\n}\n","import Diff from './base.js';\nclass CssDiff extends Diff {\n tokenize(value) {\n return value.split(/([{}:;,]|\\s+)/);\n }\n}\nexport const cssDiff = new CssDiff();\nexport function diffCss(oldStr, newStr, options) {\n return cssDiff.diff(oldStr, newStr, options);\n}\n","import Diff from './base.js';\nimport { tokenize } from './line.js';\nclass JsonDiff extends Diff {\n constructor() {\n super(...arguments);\n this.tokenize = tokenize;\n }\n get useLongestToken() {\n // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a\n // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:\n return true;\n }\n castInput(value, options) {\n const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === 'undefined' ? undefinedReplacement : v } = options;\n return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, ' ');\n }\n equals(left, right, options) {\n return super.equals(left.replace(/,([\\r\\n])/g, '$1'), right.replace(/,([\\r\\n])/g, '$1'), options);\n }\n}\nexport const jsonDiff = new JsonDiff();\nexport function diffJson(oldStr, newStr, options) {\n return jsonDiff.diff(oldStr, newStr, options);\n}\n// This function handles the presence of circular references by bailing out when encountering an\n// object that is already on the \"stack\" of items being processed. Accepts an optional replacer\nexport function canonicalize(obj, stack, replacementStack, replacer, key) {\n stack = stack || [];\n replacementStack = replacementStack || [];\n if (replacer) {\n obj = replacer(key === undefined ? '' : key, obj);\n }\n let i;\n for (i = 0; i < stack.length; i += 1) {\n if (stack[i] === obj) {\n return replacementStack[i];\n }\n }\n let canonicalizedObj;\n if ('[object Array]' === Object.prototype.toString.call(obj)) {\n stack.push(obj);\n canonicalizedObj = new Array(obj.length);\n replacementStack.push(canonicalizedObj);\n for (i = 0; i < obj.length; i += 1) {\n canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));\n }\n stack.pop();\n replacementStack.pop();\n return canonicalizedObj;\n }\n if (obj && obj.toJSON) {\n obj = obj.toJSON();\n }\n if (typeof obj === 'object' && obj !== null) {\n stack.push(obj);\n canonicalizedObj = {};\n replacementStack.push(canonicalizedObj);\n const sortedKeys = [];\n let key;\n for (key in obj) {\n /* istanbul ignore else */\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n sortedKeys.push(key);\n }\n }\n sortedKeys.sort();\n for (i = 0; i < sortedKeys.length; i += 1) {\n key = sortedKeys[i];\n canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key);\n }\n stack.pop();\n replacementStack.pop();\n }\n else {\n canonicalizedObj = obj;\n }\n return canonicalizedObj;\n}\n","import Diff from './base.js';\nclass ArrayDiff extends Diff {\n tokenize(value) {\n return value.slice();\n }\n join(value) {\n return value;\n }\n removeEmpty(value) {\n return value;\n }\n}\nexport const arrayDiff = new ArrayDiff();\nexport function diffArrays(oldArr, newArr, options) {\n return arrayDiff.diff(oldArr, newArr, options);\n}\n","import { diffLines } from '../diff/line.js';\n/**\n * Returns true if the filename contains characters that require C-style\n * quoting (as used by Git and GNU diffutils in diff output).\n */\nfunction needsQuoting(s) {\n for (let i = 0; i < s.length; i++) {\n if (s[i] < '\\x20' || s[i] > '\\x7e' || s[i] === '\"' || s[i] === '\\\\') {\n return true;\n }\n }\n return false;\n}\n/**\n * C-style quotes a filename, encoding special characters as escape sequences\n * and non-ASCII bytes as octal escapes. This is the inverse of\n * `parseQuotedFileName` in parse.ts.\n *\n * Non-ASCII bytes are encoded as UTF-8 before being emitted as octal escapes.\n * This matches the behaviour of both Git and GNU diffutils, which always emit\n * UTF-8 octal escapes regardless of the underlying filesystem encoding (e.g.\n * Git for Windows converts from NTFS's UTF-16 to UTF-8 internally).\n *\n * If the filename doesn't need quoting, returns it as-is.\n */\nfunction quoteFileNameIfNeeded(s) {\n if (!needsQuoting(s)) {\n return s;\n }\n let result = '\"';\n const bytes = new TextEncoder().encode(s);\n let i = 0;\n while (i < bytes.length) {\n const b = bytes[i];\n // See https://en.wikipedia.org/wiki/Escape_sequences_in_C#Escape_sequences\n if (b === 0x07) {\n result += '\\\\a';\n }\n else if (b === 0x08) {\n result += '\\\\b';\n }\n else if (b === 0x09) {\n result += '\\\\t';\n }\n else if (b === 0x0a) {\n result += '\\\\n';\n }\n else if (b === 0x0b) {\n result += '\\\\v';\n }\n else if (b === 0x0c) {\n result += '\\\\f';\n }\n else if (b === 0x0d) {\n result += '\\\\r';\n }\n else if (b === 0x22) {\n result += '\\\\\"';\n }\n else if (b === 0x5c) {\n result += '\\\\\\\\';\n }\n else if (b >= 0x20 && b <= 0x7e) {\n // Just a printable ASCII character that is neither a double quote nor a\n // backslash; no need to escape it.\n result += String.fromCharCode(b);\n }\n else {\n // Either part of a non-ASCII character or a control character without a\n // special escape sequence; needs escaping as a 3-digit octal escape\n result += '\\\\' + b.toString(8).padStart(3, '0');\n }\n i++;\n }\n result += '\"';\n return result;\n}\nexport const INCLUDE_HEADERS = {\n includeIndex: true,\n includeUnderline: true,\n includeFileHeaders: true\n};\nexport const FILE_HEADERS_ONLY = {\n includeIndex: false,\n includeUnderline: false,\n includeFileHeaders: true\n};\nexport const OMIT_HEADERS = {\n includeIndex: false,\n includeUnderline: false,\n includeFileHeaders: false\n};\nexport function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {\n let optionsObj;\n if (!options) {\n optionsObj = {};\n }\n else if (typeof options === 'function') {\n optionsObj = { callback: options };\n }\n else {\n optionsObj = options;\n }\n if (typeof optionsObj.context === 'undefined') {\n optionsObj.context = 4;\n }\n // We copy this into its own variable to placate TypeScript, which thinks\n // optionsObj.context might be undefined in the callbacks below.\n const context = optionsObj.context;\n // @ts-expect-error (runtime check for something that is correctly a static type error)\n if (optionsObj.newlineIsToken) {\n throw new Error('newlineIsToken may not be used with patch-generation functions, only with diffing functions');\n }\n if (!optionsObj.callback) {\n return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));\n }\n else {\n const { callback } = optionsObj;\n diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {\n const patch = diffLinesResultToPatch(diff);\n // TypeScript is unhappy without the cast because it does not understand that `patch` may\n // be undefined here only if `callback` is StructuredPatchCallbackAbortable:\n callback(patch);\n } }));\n }\n function diffLinesResultToPatch(diff) {\n // STEP 1: Build up the patch with no \"\\" lines and with the arrays\n // of lines containing trailing newline characters. We'll tidy up later...\n if (!diff) {\n return;\n }\n diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier\n function contextLines(lines) {\n return lines.map(function (entry) { return ' ' + entry; });\n }\n const hunks = [];\n let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;\n for (let i = 0; i < diff.length; i++) {\n const current = diff[i], lines = current.lines || splitLines(current.value);\n current.lines = lines;\n if (current.added || current.removed) {\n // If we have previous context, start with that\n if (!oldRangeStart) {\n const prev = diff[i - 1];\n oldRangeStart = oldLine;\n newRangeStart = newLine;\n if (prev) {\n curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];\n oldRangeStart -= curRange.length;\n newRangeStart -= curRange.length;\n }\n }\n // Output our changes\n for (const line of lines) {\n curRange.push((current.added ? '+' : '-') + line);\n }\n // Track the updated file position\n if (current.added) {\n newLine += lines.length;\n }\n else {\n oldLine += lines.length;\n }\n }\n else {\n // Identical context lines. Track line changes\n if (oldRangeStart) {\n // Close out any changes that have been output (or join overlapping)\n if (lines.length <= context * 2 && i < diff.length - 2) {\n // Overlapping\n for (const line of contextLines(lines)) {\n curRange.push(line);\n }\n }\n else {\n // end the range and output\n const contextSize = Math.min(lines.length, context);\n for (const line of contextLines(lines.slice(0, contextSize))) {\n curRange.push(line);\n }\n const hunk = {\n oldStart: oldRangeStart,\n oldLines: (oldLine - oldRangeStart + contextSize),\n newStart: newRangeStart,\n newLines: (newLine - newRangeStart + contextSize),\n lines: curRange\n };\n hunks.push(hunk);\n oldRangeStart = 0;\n newRangeStart = 0;\n curRange = [];\n }\n }\n oldLine += lines.length;\n newLine += lines.length;\n }\n }\n // Step 2: eliminate the trailing `\\n` from each line of each hunk, and, where needed, add\n // \"\\".\n for (const hunk of hunks) {\n for (let i = 0; i < hunk.lines.length; i++) {\n if (hunk.lines[i].endsWith('\\n')) {\n hunk.lines[i] = hunk.lines[i].slice(0, -1);\n }\n else {\n hunk.lines.splice(i + 1, 0, '\\\');\n i++; // Skip the line we just added, then continue iterating\n }\n }\n }\n return {\n oldFileName: oldFileName, newFileName: newFileName,\n oldHeader: oldHeader, newHeader: newHeader,\n hunks: hunks\n };\n }\n}\n/**\n * creates a unified diff patch.\n *\n * @param patch either a single structured patch object (as returned by `structuredPatch`) or an\n * array of them (as returned by `parsePatch`).\n * @param headerOptions behaves the same as the `headerOptions` option of `createTwoFilesPatch`.\n * Ignored for patches where `isGit` is `true`.\n *\n * When a patch has `isGit: true`, `formatPatch` output is changed to more closely match Git's\n * output: it emits a `diff --git` header, emits Git extended headers as appropriate based on\n * properties like `isRename`, `isCreate`, `newMode`, etc, and will omit `---`/`+++` file\n * headers for patches with no hunks (e.g. renames without content changes).\n */\nexport function formatPatch(patch, headerOptions) {\n var _a, _b, _c, _d, _e, _f;\n if (!headerOptions) {\n headerOptions = INCLUDE_HEADERS;\n }\n if (Array.isArray(patch)) {\n if (patch.length > 1 && !headerOptions.includeFileHeaders && !patch.every(p => p.isGit)) {\n throw new Error('Cannot omit file headers on a multi-file patch. '\n + '(The result would be unparseable; how would a tool trying to apply '\n + 'the patch know which changes are to which file?)');\n }\n return patch.map(p => formatPatch(p, headerOptions)).join('\\n');\n }\n const ret = [];\n // Git patches have a fixed header format (diff --git, extended headers,\n // and ---/+++ when hunks are present), so headerOptions is ignored.\n if (patch.isGit) {\n headerOptions = INCLUDE_HEADERS;\n // Emit Git-style diff --git header and extended headers.\n // Git never puts /dev/null in the \"diff --git\" line; for file\n // creations/deletions it uses the real filename on both sides.\n if (!patch.oldFileName) {\n throw new Error('oldFileName must be specified for Git patches');\n }\n if (!patch.newFileName) {\n throw new Error('newFileName must be specified for Git patches');\n }\n let gitOldName = patch.oldFileName;\n let gitNewName = patch.newFileName;\n if (patch.isCreate && gitOldName === '/dev/null') {\n gitOldName = gitNewName.replace(/^b\\//, 'a/');\n }\n else if (patch.isDelete && gitNewName === '/dev/null') {\n gitNewName = gitOldName.replace(/^a\\//, 'b/');\n }\n ret.push('diff --git ' + quoteFileNameIfNeeded(gitOldName) + ' ' + quoteFileNameIfNeeded(gitNewName));\n if (patch.isDelete) {\n ret.push('deleted file mode ' + ((_a = patch.oldMode) !== null && _a !== void 0 ? _a : '100644'));\n }\n if (patch.isCreate) {\n ret.push('new file mode ' + ((_b = patch.newMode) !== null && _b !== void 0 ? _b : '100644'));\n }\n if (patch.oldMode && patch.newMode && !patch.isDelete && !patch.isCreate) {\n ret.push('old mode ' + patch.oldMode);\n ret.push('new mode ' + patch.newMode);\n }\n if (patch.isRename) {\n ret.push('rename from ' + quoteFileNameIfNeeded(((_c = patch.oldFileName) !== null && _c !== void 0 ? _c : '').replace(/^a\\//, '')));\n ret.push('rename to ' + quoteFileNameIfNeeded(((_d = patch.newFileName) !== null && _d !== void 0 ? _d : '').replace(/^b\\//, '')));\n }\n if (patch.isCopy) {\n ret.push('copy from ' + quoteFileNameIfNeeded(((_e = patch.oldFileName) !== null && _e !== void 0 ? _e : '').replace(/^a\\//, '')));\n ret.push('copy to ' + quoteFileNameIfNeeded(((_f = patch.newFileName) !== null && _f !== void 0 ? _f : '').replace(/^b\\//, '')));\n }\n }\n else {\n if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName && patch.oldFileName !== undefined) {\n ret.push('Index: ' + patch.oldFileName);\n }\n if (headerOptions.includeUnderline) {\n ret.push('===================================================================');\n }\n }\n // Emit --- / +++ file headers. For Git patches with no hunks (e.g.\n // pure renames, mode-only changes), Git omits these, so we do too.\n const hasHunks = patch.hunks.length > 0;\n if (headerOptions.includeFileHeaders && patch.oldFileName !== undefined && patch.newFileName !== undefined\n && (!patch.isGit || hasHunks)) {\n ret.push('--- ' + quoteFileNameIfNeeded(patch.oldFileName) + (patch.oldHeader ? '\\t' + patch.oldHeader : ''));\n ret.push('+++ ' + quoteFileNameIfNeeded(patch.newFileName) + (patch.newHeader ? '\\t' + patch.newHeader : ''));\n }\n for (let i = 0; i < patch.hunks.length; i++) {\n const hunk = patch.hunks[i];\n // Unified Diff Format quirk: If the chunk size is 0,\n // the first number is one lower than one would expect.\n // https://www.artima.com/weblogs/viewpost.jsp?thread=164293\n const oldStart = hunk.oldLines === 0 ? hunk.oldStart - 1 : hunk.oldStart;\n const newStart = hunk.newLines === 0 ? hunk.newStart - 1 : hunk.newStart;\n ret.push('@@ -' + oldStart + ',' + hunk.oldLines\n + ' +' + newStart + ',' + hunk.newLines\n + ' @@');\n for (const line of hunk.lines) {\n ret.push(line);\n }\n }\n return ret.join('\\n') + '\\n';\n}\nexport function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {\n if (typeof options === 'function') {\n options = { callback: options };\n }\n if (!(options === null || options === void 0 ? void 0 : options.callback)) {\n const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);\n if (!patchObj) {\n return;\n }\n return formatPatch(patchObj, options === null || options === void 0 ? void 0 : options.headerOptions);\n }\n else {\n const { callback } = options;\n structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: patchObj => {\n if (!patchObj) {\n callback(undefined);\n }\n else {\n callback(formatPatch(patchObj, options.headerOptions));\n }\n } }));\n }\n}\nexport function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {\n return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);\n}\n/**\n * Split `text` into an array of lines, including the trailing newline character (where present)\n */\nfunction splitLines(text) {\n const hasTrailingNl = text.endsWith('\\n');\n const result = text.split('\\n').map(line => line + '\\n');\n if (hasTrailingNl) {\n result.pop();\n }\n else {\n result.push(result.pop().slice(0, -1));\n }\n return result;\n}\n","import { composeCacheKey } from \"./composeCacheKey.js\";\nimport { processFile } from \"./parsePatchFiles.js\";\nimport { createTwoFilesPatch } from \"diff\";\n//#region src/utils/parseDiffFromFile.ts\nconst MISSING_FILE_NAME = \"/dev/null\";\n/**\n* Parses a diff from two file contents objects.\n*\n* If both `oldFile` and `newFile` have a `cacheKey`, the resulting diff gets a\n* collision-safe key derived from both values.\n*/\nfunction parseDiffFromFile(oldFile, newFile, options, throwOnError = false) {\n\tif (oldFile === null && newFile === null) throw new Error(\"parseDiffFromFile: You must pass oldFile, newFile, or both\");\n\tconst resolvedOldFile = oldFile ?? createMissingFile();\n\tconst resolvedNewFile = newFile ?? createMissingFile();\n\tconst patch = createTwoFilesPatch(resolvedOldFile.name, resolvedNewFile.name, resolvedOldFile.contents, resolvedNewFile.contents, resolvedOldFile.header, resolvedNewFile.header, options);\n\tconst fileData = processFile(patch, {\n\t\tcacheKey: (() => {\n\t\t\tconst oldCacheKey = oldFile?.cacheKey;\n\t\t\tconst newCacheKey = newFile?.cacheKey;\n\t\t\treturn oldCacheKey != null && newCacheKey != null ? composeCacheKey(\"diff\", oldCacheKey, newCacheKey) : void 0;\n\t\t})(),\n\t\toldFile: resolvedOldFile,\n\t\tnewFile: resolvedNewFile,\n\t\tthrowOnError\n\t});\n\tif (fileData == null) throw new Error(\"parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?\");\n\tif (oldFile === null) {\n\t\tfileData.type = \"new\";\n\t\tfileData.prevName = void 0;\n\t} else if (newFile === null) {\n\t\tfileData.type = \"deleted\";\n\t\tfileData.prevName = void 0;\n\t}\n\tconst language = newFile?.lang ?? (newFile === null ? oldFile?.lang : void 0);\n\tif (language != null) fileData.lang = language;\n\treturn fileData;\n}\nfunction createMissingFile() {\n\treturn {\n\t\tname: MISSING_FILE_NAME,\n\t\tcontents: \"\"\n\t};\n}\n//#endregion\nexport { parseDiffFromFile };\n\n//# sourceMappingURL=parseDiffFromFile.js.map","import * as Predicate from \"./predicates.js\"\n/** Preserve literal variant keys without type assertions. */\nexport const defineVariants = <const Variants>(variants: Variants): Variants => variants\n\n/** Resolve a required generated CSS Module class and fail loudly on drift. */\nexport const cssClass = (sheet: Readonly<Record<string, string>>, name: string): string => {\n const value = sheet[name]\n if (value === undefined) throw new Error(`Missing CSS Module class: ${name}`)\n return value\n}\n\n/** Join owned component classes with an optional consumer class. */\nexport const classNames = (...values: ReadonlyArray<string | undefined | false>): string =>\n values.filter((value): value is string => Predicate.isString(value) && value.length > 0).join(\" \")\n\n/** Enforce runtime text invariants that TypeScript cannot express. */\nexport const requireText = (value: string, label: string): string => {\n if (value.trim().length === 0) throw new Error(`${label} must contain visible text`)\n return value\n}\n","import { type RefCallback, useCallback, useState } from \"react\"\n\n/** Below this container width a side-by-side diff leaves each code column too narrow to read. */\nexport const RLY_SPLIT_DIFF_MIN_WIDTH = 720\n\n/**\n * Whether the element is laid out narrower than `width`, kept current with a ResizeObserver from the\n * element's own window. It measures in the commit phase, before paint, so a layout chosen from it\n * never shifts. An element not laid out yet (width 0, or no layout engine) counts as wide.\n */\nexport const useNarrowerThan = <E extends Element>(width: number): readonly [boolean, RefCallback<E>] => {\n const [narrow, setNarrow] = useState(false)\n const ref = useCallback(\n (element: E | null) => {\n if (element === null) return\n const measure = (): void => {\n const measured = element.getBoundingClientRect().width\n setNarrow(measured > 0 && measured < width)\n }\n measure()\n const view = element.ownerDocument.defaultView\n if (view === null || !(\"ResizeObserver\" in view)) return\n const observer = new view.ResizeObserver(measure)\n observer.observe(element)\n return () => observer.disconnect()\n },\n [width]\n )\n return [narrow, ref]\n}\n","interface RenderedDiffLineLocation {\n readonly lineNumber: number\n readonly side: \"additions\" | \"deletions\"\n}\n\n/** Resolve one Pierre renderer line across split, stacked, and alternate-line presentations. */\nexport const renderedDiffLine = (\n container: Element,\n location: RenderedDiffLineLocation\n): HTMLElement | null => {\n const root = container.shadowRoot\n if (root === null) return null\n\n const sideContainer = location.side === \"additions\" ? \"data-additions\" : \"data-deletions\"\n const type = location.side === \"additions\" ? \"change-addition\" : \"change-deletion\"\n const contextLine = location.side === \"additions\" ? \"data-line\" : \"data-alt-line\"\n return (\n root.querySelector<HTMLElement>(`[${sideContainer}] [data-line=\"${location.lineNumber}\"]`) ??\n root.querySelector<HTMLElement>(`[data-line=\"${location.lineNumber}\"][data-line-type=\"${type}\"]`) ??\n root.querySelector<HTMLElement>(`[${contextLine}=\"${location.lineNumber}\"][data-line-type=\"context\"]`) ??\n root.querySelector<HTMLElement>(`[${contextLine}=\"${location.lineNumber}\"][data-line-type=\"context-expanded\"]`) ??\n root.querySelector<HTMLElement>(`[${sideContainer}] [data-alt-line=\"${location.lineNumber}\"]`) ??\n root.querySelector<HTMLElement>(`[${sideContainer}][data-line=\"${location.lineNumber}\"]`) ??\n root.querySelector<HTMLElement>(`[${sideContainer}][data-alt-line=\"${location.lineNumber}\"]`)\n )\n}\n","\"use client\"\n\nimport { createElement, type KeyboardEvent, type ReactElement, useRef } from \"react\"\nimport { renderedDiffLine } from \"./rendered-line.js\"\nimport type { RlyDiffCodeAnnotation, RlyDiffCodeAnnotationLocation } from \"./types.js\"\n\ninterface DiffCodeAnnotationProps {\n readonly annotation: RlyDiffCodeAnnotation\n readonly className: string\n readonly returnFocus?: () => void\n}\n\nconst pierreLine = (annotationNode: HTMLDivElement, location: RlyDiffCodeAnnotationLocation): HTMLElement | null => {\n const item = annotationNode.closest(\"diffs-container\")\n return item === null ? null : renderedDiffLine(item, location)\n}\n\nconst focusLine = (annotationNode: HTMLDivElement, location: RlyDiffCodeAnnotationLocation): void => {\n const line = pierreLine(annotationNode, location)\n if (line === null) return\n line.tabIndex = -1\n line.focus({ preventScroll: true })\n}\n\n/** Keyboard boundary shared by virtualized and bounded annotation presentations. */\nexport const DiffCodeAnnotation = ({\n annotation,\n className,\n returnFocus\n}: DiffCodeAnnotationProps): ReactElement => {\n const annotationRef = useRef<HTMLDivElement>(null)\n const restoreLineFocus = (): void => {\n if (returnFocus !== undefined) {\n returnFocus()\n return\n }\n if (annotationRef.current !== null) focusLine(annotationRef.current, annotation.location)\n }\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n if (event.key !== \"Escape\") return\n event.preventDefault()\n event.stopPropagation()\n restoreLineFocus()\n }\n\n return createElement(\n \"div\",\n {\n ref: annotationRef,\n \"aria-label\": annotation.accessibilityLabel,\n className,\n \"data-rly-diff-annotation\": annotation.id,\n \"data-rly-diff-annotation-item\": annotation.location.itemId,\n \"data-rly-diff-annotation-line\": annotation.location.lineNumber,\n \"data-rly-diff-annotation-side\": annotation.location.side,\n onKeyDown: handleKeyDown,\n role: \"group\",\n tabIndex: 0\n },\n annotation.render({\n annotationId: annotation.id,\n location: annotation.location,\n returnFocus: restoreLineFocus\n })\n )\n}\n\n/** Validate public annotations before either renderer crosses into implementation code. */\nexport const requireDiffCodeAnnotations = (annotations: ReadonlyArray<RlyDiffCodeAnnotation>): void => {\n const ids = new Set<string>()\n for (const annotation of annotations) {\n if (annotation.id.trim().length === 0 || annotation.accessibilityLabel.trim().length === 0) {\n throw new Error(\"Diff annotation id and accessibility label must not be blank\")\n }\n if (annotation.location.itemId.trim().length === 0) {\n throw new Error(`Diff annotation ${annotation.id} location item id must not be blank`)\n }\n if (!Number.isInteger(annotation.location.lineNumber) || annotation.location.lineNumber < 1) {\n throw new Error(`Diff annotation ${annotation.id} line number must be a positive integer`)\n }\n if (ids.has(annotation.id)) throw new Error(`Diff annotation id ${annotation.id} must be unique`)\n ids.add(annotation.id)\n }\n}\n","/* Code reads left to right whatever the page's direction; isolated so it never mirrors with an RTL host. */\n.root {\n direction: ltr;\n unicode-bidi: isolate;\n min-inline-size: 0;\n overflow: clip;\n border: 1px solid var(--rly-color-border-1);\n border-radius: var(--rly-radius-field);\n background: var(--rly-color-surface-1);\n color: var(--rly-color-text-1);\n}\n\n.file + .file {\n border-block-start: 1px solid var(--rly-color-border-1);\n}\n\n.noChanges {\n margin: 0;\n padding: var(--rly-space-16);\n color: var(--rly-color-text-2);\n font: var(--rly-type-body-weight) var(--rly-type-body-size) / var(--rly-type-body-line-height)\n var(--rly-type-body-font);\n}\n\n.fileName {\n margin: 0;\n padding: var(--rly-space-12) var(--rly-space-16);\n border-block-end: 1px solid var(--rly-color-border-1);\n font: var(--rly-type-label-weight) var(--rly-type-label-size) / var(--rly-type-label-line-height)\n var(--rly-type-label-font);\n}\n\n.scroller {\n max-height: min(70vh, 56rem);\n overflow: auto;\n}\n\n.table {\n width: 100%;\n border-spacing: 0;\n border-collapse: collapse;\n font-family: var(--rly-font-mono);\n font-size: 0.78rem;\n line-height: 1.55;\n}\n\n.table td {\n min-width: 0;\n padding: 0;\n vertical-align: top;\n}\n\n.hunk td {\n padding: var(--rly-space-4) var(--rly-space-12);\n border-block: 1px solid var(--rly-color-border-1);\n background: var(--rly-color-surface-2);\n color: var(--rly-color-text-2);\n}\n\n.lineNumber {\n width: 3.25rem;\n /* Room either side of the number, so the column rule reads as one rule, not a box per line. */\n padding-inline: var(--rly-space-8) var(--rly-space-6) !important;\n border-inline-end: 1px solid var(--rly-color-border-1);\n color: var(--rly-color-text-3);\n text-align: end;\n user-select: none;\n}\n\n.marker {\n width: 1.5rem;\n color: var(--rly-color-text-3);\n text-align: center;\n user-select: none;\n}\n\n.code,\n.wrappedCode {\n display: block;\n min-height: 1.55em;\n padding-inline: var(--rly-space-12);\n white-space: pre;\n}\n\n.wrappedCode {\n white-space: pre-wrap;\n overflow-wrap: break-word;\n}\n\n/*\n * In an auto-sized table a long token would widen its column rather than wrap. Capping the wrapped\n * code cell at zero and letting it take the remaining width bounds it to the viewport, so\n * break-word can wrap a 200-character string; unwrapped views keep their horizontal scroll.\n */\n.table td:has(> .wrappedCode) {\n inline-size: 100%;\n max-inline-size: 0;\n}\n\n.deletion > td,\n.change .deletionCode {\n background: var(--rly-color-blocked-tint);\n}\n\n.addition > td,\n.change .additionCode {\n background: var(--rly-color-success-tint);\n}\n\n.deletion .lineNumber,\n.addition .lineNumber,\n.deletion .marker,\n.addition .marker {\n color: var(--rly-color-text-2);\n}\n\n.context > td {\n background: var(--rly-color-surface-1);\n}\n\n.deletionCode,\n.additionCode {\n width: 50%;\n border-inline-end: 1px solid var(--rly-color-border-1);\n}\n\n.annotationRow > td {\n background: var(--rly-color-surface-2);\n border-block: 1px solid var(--rly-color-border-1);\n}\n\n.annotationRow > .annotationCell {\n padding: var(--rly-space-8);\n}\n\n.annotation {\n background: var(--rly-color-held-tint);\n border: 1px solid color-mix(in oklab, var(--rly-color-held-ink) 35%, transparent);\n border-radius: var(--rly-radius-tag);\n color: var(--rly-color-text-1);\n font: var(--rly-type-label-weight) var(--rly-type-label-size) / var(--rly-type-label-line-height)\n var(--rly-type-label-font);\n padding: var(--rly-space-8) var(--rly-space-12);\n}\n\n.annotation:focus-visible,\n[data-rly-diff-line]:focus-visible {\n outline: var(--rly-focus-ring-width) solid var(--rly-color-focus);\n outline-offset: var(--rly-focus-ring-offset);\n}\n\n@media (forced-colors: active) {\n .annotation,\n [data-rly-diff-line]:focus-visible {\n forced-color-adjust: auto;\n }\n}\n\n/*\n * Forced colours drop the add/remove tints. Split cells have no marker column, so a changed cell\n * gets its sign drawn before the code (hidden from assistive technology, which reads the column).\n */\n@media (forced-colors: active) {\n .change .deletionCode > :is(.code, .wrappedCode)::before {\n content: \"− \" / \"\";\n }\n .change .additionCode > :is(.code, .wrappedCode)::before {\n content: \"+ \" / \"\";\n }\n}\n\n:where([data-forced-colors=\"active\"], [data-rly-forced-colors=\"active\"])\n .change\n .deletionCode\n > :is(.code, .wrappedCode)::before {\n content: \"− \" / \"\";\n}\n:where([data-forced-colors=\"active\"], [data-rly-forced-colors=\"active\"])\n .change\n .additionCode\n > :is(.code, .wrappedCode)::before {\n content: \"+ \" / \"\";\n}\n","\"use client\"\n\nimport {\n type ChangeContent,\n type ContextContent,\n type FileDiffMetadata,\n type Hunk,\n parseDiffFromFile\n} from \"@pierre/diffs\"\nimport { Fragment, type ReactElement, type ReactNode, useCallback, useRef } from \"react\"\nimport { cssClass } from \"../../internal/component.js\"\nimport { RLY_SPLIT_DIFF_MIN_WIDTH, useNarrowerThan } from \"../../internal/useNarrowerThan.js\"\nimport { DiffCodeAnnotation, requireDiffCodeAnnotations } from \"../annotation.js\"\nimport type { RlyDiffCodeAnnotation, RlyDiffCodeItem } from \"../types.js\"\nimport styles from \"./BoundedDiffCodeView.module.css\"\n\nexport type {\n RlyDiffCodeAnnotation,\n RlyDiffCodeAnnotationLocation,\n RlyDiffCodeAnnotationRenderContext,\n RlyDiffCodeItem\n} from \"../types.js\"\n\ntype BoundedDiffMode = \"split\" | \"stacked\"\n\ninterface BoundedAnnotationLocation {\n readonly lineNumber: number\n readonly side: \"additions\" | \"deletions\"\n}\n\nconst boundedAnnotationLocation = (\n lineNumber: number,\n side: BoundedAnnotationLocation[\"side\"]\n): BoundedAnnotationLocation => ({ lineNumber, side })\n\ninterface DiffLine {\n readonly content: string\n readonly number: number\n}\n\ntype SplitRow =\n | {\n readonly addition?: DiffLine\n readonly deletion?: DiffLine\n readonly kind: \"change\" | \"context\"\n }\n | {\n readonly kind: \"hunk\"\n readonly label: string\n }\n\ntype UnifiedRow =\n | {\n readonly additionNumber?: number\n readonly content: string\n readonly deletionNumber?: number\n readonly kind: \"addition\" | \"context\" | \"deletion\"\n }\n | {\n readonly kind: \"hunk\"\n readonly label: string\n }\n\n/** Props for the strict-budget, main-thread line diff renderer. */\nexport interface BoundedDiffCodeViewProps {\n readonly annotations?: ReadonlyArray<RlyDiffCodeAnnotation>\n readonly className?: string\n readonly empty?: ReactNode\n readonly initialItems: ReadonlyArray<RlyDiffCodeItem>\n readonly mode?: BoundedDiffMode\n readonly wrap?: boolean\n}\n\nconst contentAt = (lines: ReadonlyArray<string>, index: number): string => lines[index]?.replace(/\\r?\\n$/, \"\") ?? \"\"\n\nconst hunkLabel = (hunk: Hunk): string =>\n hunk.hunkSpecs?.trim() ??\n `@@ -${hunk.deletionStart},${hunk.deletionCount} +${hunk.additionStart},${hunk.additionCount} @@`\n\nconst parseItem = (item: RlyDiffCodeItem): FileDiffMetadata | undefined => {\n if (item.before.contents === item.after.contents) return undefined\n return parseDiffFromFile(\n {\n ...(!(item.before.cacheKey === undefined) && { cacheKey: item.before.cacheKey }),\n contents: item.before.contents,\n name: item.before.name\n },\n {\n ...(!(item.after.cacheKey === undefined) && { cacheKey: item.after.cacheKey }),\n contents: item.after.contents,\n name: item.after.name\n },\n undefined,\n true\n )\n}\n\nconst contextSplitRows = (diff: FileDiffMetadata, content: ContextContent): ReadonlyArray<SplitRow> =>\n Array.from({ length: content.lines }, (_, offset) => ({\n addition: {\n content: contentAt(diff.additionLines, content.additionLineIndex + offset),\n number: content.additionLineIndex + offset + 1\n },\n deletion: {\n content: contentAt(diff.deletionLines, content.deletionLineIndex + offset),\n number: content.deletionLineIndex + offset + 1\n },\n kind: \"context\"\n }))\n\nconst changeSplitRows = (diff: FileDiffMetadata, content: ChangeContent): ReadonlyArray<SplitRow> =>\n Array.from({ length: Math.max(content.deletions, content.additions) }, (_, offset) => ({\n ...(offset < content.additions && {\n addition: {\n content: contentAt(diff.additionLines, content.additionLineIndex + offset),\n number: content.additionLineIndex + offset + 1\n }\n }),\n ...(offset < content.deletions && {\n deletion: {\n content: contentAt(diff.deletionLines, content.deletionLineIndex + offset),\n number: content.deletionLineIndex + offset + 1\n }\n }),\n kind: \"change\"\n }))\n\nconst splitRows = (diff: FileDiffMetadata): ReadonlyArray<SplitRow> =>\n diff.hunks.flatMap((hunk) => [\n { kind: \"hunk\", label: hunkLabel(hunk) },\n ...hunk.hunkContent.flatMap((content) =>\n content.type === \"context\" ? contextSplitRows(diff, content) : changeSplitRows(diff, content)\n )\n ])\n\nconst unifiedRows = (diff: FileDiffMetadata): ReadonlyArray<UnifiedRow> =>\n diff.hunks.flatMap((hunk) => [\n { kind: \"hunk\", label: hunkLabel(hunk) },\n ...hunk.hunkContent.flatMap((content): ReadonlyArray<UnifiedRow> => {\n if (content.type === \"context\") {\n return Array.from({ length: content.lines }, (_, offset) => ({\n additionNumber: content.additionLineIndex + offset + 1,\n content: contentAt(diff.additionLines, content.additionLineIndex + offset),\n deletionNumber: content.deletionLineIndex + offset + 1,\n kind: \"context\"\n }))\n }\n return [\n ...Array.from({ length: content.deletions }, (_, offset): UnifiedRow => ({\n content: contentAt(diff.deletionLines, content.deletionLineIndex + offset),\n deletionNumber: content.deletionLineIndex + offset + 1,\n kind: \"deletion\"\n })),\n ...Array.from({ length: content.additions }, (_, offset): UnifiedRow => ({\n additionNumber: content.additionLineIndex + offset + 1,\n content: contentAt(diff.additionLines, content.additionLineIndex + offset),\n kind: \"addition\"\n }))\n ]\n })\n ])\n\nconst code = (\n content: string,\n itemId: string,\n lineNumber: number,\n side: \"additions\" | \"deletions\",\n wrap: boolean,\n alternate?: { readonly lineNumber: number; readonly side: \"additions\" | \"deletions\" }\n): ReactElement => (\n <code\n className={wrap ? styles.wrappedCode : styles.code}\n data-rly-diff-item={itemId}\n {...(alternate === undefined\n ? {}\n : {\n \"data-rly-diff-line-alternate\": alternate.lineNumber,\n \"data-rly-diff-line-side-alternate\": alternate.side\n })}\n data-rly-diff-line={lineNumber}\n data-rly-diff-line-side={side}\n tabIndex={-1}\n >\n {content.length === 0 ? \" \" : content}\n </code>\n)\n\nconst focusBoundedLine = (\n root: HTMLDivElement | null,\n itemId: string,\n lineNumber: number,\n side: \"additions\" | \"deletions\"\n): void => {\n const item = `[data-rly-diff-item=\"${CSS.escape(itemId)}\"]`\n const line =\n root?.querySelector<HTMLElement>(\n `${item}[data-rly-diff-line=\"${lineNumber}\"][data-rly-diff-line-side=\"${side}\"]`\n ) ??\n root?.querySelector<HTMLElement>(\n `${item}[data-rly-diff-line-alternate=\"${lineNumber}\"][data-rly-diff-line-side-alternate=\"${side}\"]`\n )\n line?.focus({ preventScroll: true })\n}\n\nconst annotationsAt = (\n annotations: ReadonlyArray<RlyDiffCodeAnnotation>,\n itemId: string,\n lineNumber: number | undefined,\n side: \"additions\" | \"deletions\"\n): ReadonlyArray<RlyDiffCodeAnnotation> =>\n lineNumber === undefined\n ? []\n : annotations.filter(\n (annotation) =>\n annotation.location.itemId === itemId &&\n annotation.location.lineNumber === lineNumber &&\n annotation.location.side === side\n )\n\nconst splitAnnotationRows = (\n annotations: ReadonlyArray<RlyDiffCodeAnnotation>,\n itemId: string,\n row: Extract<SplitRow, { readonly kind: \"change\" | \"context\" }>,\n root: () => HTMLDivElement | null\n): ReadonlyArray<ReactElement> => [\n ...annotationsAt(annotations, itemId, row.deletion?.number, \"deletions\").map((annotation) => (\n <tr className={styles.annotationRow} key={annotation.id}>\n <td className={styles.annotationCell} colSpan={2}>\n <DiffCodeAnnotation\n annotation={annotation}\n className={cssClass(styles, \"annotation\")}\n returnFocus={() => focusBoundedLine(root(), itemId, annotation.location.lineNumber, annotation.location.side)}\n />\n </td>\n <td colSpan={2} />\n </tr>\n )),\n ...annotationsAt(annotations, itemId, row.addition?.number, \"additions\").map((annotation) => (\n <tr className={styles.annotationRow} key={annotation.id}>\n <td colSpan={2} />\n <td className={styles.annotationCell} colSpan={2}>\n <DiffCodeAnnotation\n annotation={annotation}\n className={cssClass(styles, \"annotation\")}\n returnFocus={() => focusBoundedLine(root(), itemId, annotation.location.lineNumber, annotation.location.side)}\n />\n </td>\n </tr>\n ))\n]\n\nconst renderSplit = (\n diff: FileDiffMetadata,\n itemId: string,\n annotations: ReadonlyArray<RlyDiffCodeAnnotation>,\n root: () => HTMLDivElement | null,\n wrap: boolean\n): ReactElement => (\n <table aria-label={`Changes in ${diff.name}`} className={styles.table}>\n <tbody>\n {splitRows(diff).map((row, index) =>\n row.kind === \"hunk\" ? (\n <tr className={styles.hunk} key={`${index}:${row.label}`}>\n <td colSpan={4}>{row.label}</td>\n </tr>\n ) : (\n <Fragment key={`${index}:${row.deletion?.number ?? \"\"}:${row.addition?.number ?? \"\"}`}>\n <tr className={styles[row.kind]}>\n <td className={styles.lineNumber}>{row.deletion?.number}</td>\n <td className={styles.deletionCode}>\n {row.deletion === undefined\n ? null\n : code(row.deletion.content, itemId, row.deletion.number, \"deletions\", wrap)}\n </td>\n <td className={styles.lineNumber}>{row.addition?.number}</td>\n <td className={styles.additionCode}>\n {row.addition === undefined\n ? null\n : code(row.addition.content, itemId, row.addition.number, \"additions\", wrap)}\n </td>\n </tr>\n {splitAnnotationRows(annotations, itemId, row, root)}\n </Fragment>\n )\n )}\n </tbody>\n </table>\n)\n\nconst unifiedAnnotationRows = (\n annotations: ReadonlyArray<RlyDiffCodeAnnotation>,\n itemId: string,\n row: Extract<UnifiedRow, { readonly kind: \"addition\" | \"context\" | \"deletion\" }>,\n root: () => HTMLDivElement | null\n): ReadonlyArray<ReactElement> => {\n const locations: ReadonlyArray<BoundedAnnotationLocation> = [\n ...(row.deletionNumber === undefined ? [] : [boundedAnnotationLocation(row.deletionNumber, \"deletions\")]),\n ...(row.additionNumber === undefined ? [] : [boundedAnnotationLocation(row.additionNumber, \"additions\")])\n ]\n return locations.flatMap(({ lineNumber, side }) =>\n annotationsAt(annotations, itemId, lineNumber, side).map((annotation) => (\n <tr className={styles.annotationRow} key={annotation.id}>\n <td className={styles.annotationCell} colSpan={4}>\n <DiffCodeAnnotation\n annotation={annotation}\n className={cssClass(styles, \"annotation\")}\n returnFocus={() => focusBoundedLine(root(), itemId, lineNumber, side)}\n />\n </td>\n </tr>\n ))\n )\n}\n\nconst renderUnified = (\n diff: FileDiffMetadata,\n itemId: string,\n annotations: ReadonlyArray<RlyDiffCodeAnnotation>,\n root: () => HTMLDivElement | null,\n wrap: boolean\n): ReactElement => (\n <table aria-label={`Changes in ${diff.name}`} className={styles.table}>\n <tbody>\n {unifiedRows(diff).map((row, index) =>\n row.kind === \"hunk\" ? (\n <tr className={styles.hunk} key={`${index}:${row.label}`}>\n <td colSpan={4}>{row.label}</td>\n </tr>\n ) : (\n <Fragment key={`${index}:${row.deletionNumber ?? \"\"}:${row.additionNumber ?? \"\"}`}>\n <tr className={styles[row.kind]}>\n <td className={styles.lineNumber}>{row.deletionNumber}</td>\n <td className={styles.lineNumber}>{row.additionNumber}</td>\n <td className={styles.marker}>{row.kind === \"addition\" ? \"+\" : row.kind === \"deletion\" ? \"−\" : \" \"}</td>\n <td>\n {code(\n row.content,\n itemId,\n row.kind === \"deletion\" ? (row.deletionNumber ?? 0) : (row.additionNumber ?? 0),\n row.kind === \"deletion\" ? \"deletions\" : \"additions\",\n wrap,\n row.kind === \"context\" && row.deletionNumber !== undefined\n ? { lineNumber: row.deletionNumber, side: \"deletions\" }\n : undefined\n )}\n </td>\n </tr>\n {unifiedAnnotationRows(annotations, itemId, row, root)}\n </Fragment>\n )\n )}\n </tbody>\n </table>\n)\n\n/**\n * Render complete line changes using Diffs' parser without syntax packs or a WASM worker.\n *\n * The public shape is deliberately small so syntax highlighting and virtualized rendering\n * can be added later without changing Control Center's diff data contract.\n */\nexport const BoundedDiffCodeView = ({\n annotations = [],\n className,\n empty = \"No renderable source changes.\",\n initialItems,\n mode = \"split\",\n wrap = false\n}: BoundedDiffCodeViewProps): ReactNode => {\n requireDiffCodeAnnotations(annotations)\n const rootRef = useRef<HTMLDivElement>(null)\n // A split view stacks in a narrow container, so neither side is clipped to a sliver.\n const [narrow, measureRef] = useNarrowerThan<HTMLDivElement>(RLY_SPLIT_DIFF_MIN_WIDTH)\n const attachRoot = useCallback(\n (element: HTMLDivElement | null) => {\n rootRef.current = element\n return measureRef(element)\n },\n [measureRef]\n )\n const shown: BoundedDiffMode = mode === \"split\" && narrow ? \"stacked\" : mode\n if (initialItems.length === 0) return <p className={className}>{empty}</p>\n\n return (\n <div\n ref={attachRoot}\n className={className === undefined ? cssClass(styles, \"root\") : `${cssClass(styles, \"root\")} ${className}`}\n data-rly-diff-code-view=\"\"\n data-rly-diff-mode={shown}\n >\n {initialItems.map((item) => {\n const diff = parseItem(item)\n if (diff === undefined) {\n return (\n <p className={styles.noChanges} key={item.id}>\n No textual changes in this file.\n </p>\n )\n }\n return (\n <section className={styles.file} key={item.id}>\n {initialItems.length > 1 ? <h3 className={styles.fileName}>{diff.name}</h3> : null}\n <div className={styles.scroller}>\n {shown === \"split\"\n ? renderSplit(diff, item.id, annotations, () => rootRef.current, wrap)\n : renderUnified(diff, item.id, annotations, () => rootRef.current, wrap)}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