@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
8 lines (7 loc) • 27.2 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/post-revisions-preview/block-diff.js"],
"sourcesContent": ["/**\n * External dependencies\n */\nimport { diffArrays } from 'diff/lib/diff/array';\nimport { diffWords } from 'diff/lib/diff/word';\n\n/**\n * WordPress dependencies\n */\nimport { parse as grammarParse } from '@wordpress/block-serialization-default-parser';\nimport {\n\tprivateApis as blocksPrivateApis,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport {\n\tRichTextData,\n\tcreate,\n\tslice,\n\tconcat,\n\tapplyFormat,\n} from '@wordpress/rich-text';\nimport { __, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { parseRawBlock } = unlock( blocksPrivateApis );\n\n/**\n * Safely stringifies a value for display and comparison.\n *\n * @param {*} value The value to stringify.\n * @return {string} The stringified value.\n */\nfunction stringifyValue( value ) {\n\tif ( value === null || value === undefined ) {\n\t\treturn '';\n\t}\n\tif ( typeof value === 'object' ) {\n\t\treturn JSON.stringify( value, null, 2 );\n\t}\n\treturn String( value );\n}\n\n/**\n * Calculate text similarity using word diff (semantically meaningful).\n * Returns ratio of unchanged words to total words.\n *\n * @param {string} text1 First text to compare.\n * @param {string} text2 Second text to compare.\n * @return {number} Similarity score between 0 and 1.\n */\nfunction textSimilarity( text1, text2 ) {\n\tif ( ! text1 && ! text2 ) {\n\t\treturn 1;\n\t}\n\tif ( ! text1 || ! text2 ) {\n\t\treturn 0;\n\t}\n\n\tconst changes = diffWords( text1, text2 );\n\tconst unchanged = changes\n\t\t.filter( ( c ) => ! c.added && ! c.removed )\n\t\t.reduce( ( sum, c ) => sum + c.value.length, 0 );\n\tconst total = Math.max( text1.length, text2.length );\n\treturn total > 0 ? unchanged / total : 0;\n}\n\n/**\n * Post-process diff result to pair similar removed/added blocks as modifications.\n * This catches modifications that LCS missed due to content changes.\n *\n * @param {Array} blocks Raw blocks with diff status.\n * @return {Array} Blocks with similar pairs converted to modifications.\n */\nfunction pairSimilarBlocks( blocks ) {\n\tconst removed = [];\n\tconst added = [];\n\n\t// Separate blocks by status, tracking original indices.\n\tblocks.forEach( ( block, index ) => {\n\t\tconst status = block.__revisionDiffStatus?.status;\n\t\tif ( status === 'removed' ) {\n\t\t\tremoved.push( { block, index } );\n\t\t} else if ( status === 'added' ) {\n\t\t\tadded.push( { block, index } );\n\t\t}\n\t} );\n\n\t// If no removed or no added, nothing to pair.\n\tif ( removed.length === 0 || added.length === 0 ) {\n\t\treturn blocks;\n\t}\n\n\tconst pairedRemoved = new Set(); // Indices of removed blocks that were paired.\n\tconst modifications = new Map(); // Map from added block index to modified block.\n\tconst SIMILARITY_THRESHOLD = 0.3;\n\n\t// For each removed block, find best matching added block.\n\tfor ( const rem of removed ) {\n\t\tlet bestMatch = null;\n\t\tlet bestScore = 0;\n\n\t\tfor ( const add of added ) {\n\t\t\tif ( modifications.has( add.index ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( add.block.blockName !== rem.block.blockName ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst score = textSimilarity(\n\t\t\t\trem.block.innerHTML || '',\n\t\t\t\tadd.block.innerHTML || ''\n\t\t\t);\n\t\t\t// If content is identical (score=1), only pair if attrs differ.\n\t\t\t// Otherwise identical blocks are just position swaps, not modifications.\n\t\t\tconst attrsMatch =\n\t\t\t\tJSON.stringify( rem.block.attrs ) ===\n\t\t\t\tJSON.stringify( add.block.attrs );\n\t\t\tif (\n\t\t\t\tscore > bestScore &&\n\t\t\t\tscore > SIMILARITY_THRESHOLD &&\n\t\t\t\t( score < 1 || ! attrsMatch )\n\t\t\t) {\n\t\t\t\tbestScore = score;\n\t\t\t\tbestMatch = add;\n\t\t\t}\n\t\t}\n\n\t\tif ( bestMatch ) {\n\t\t\tpairedRemoved.add( rem.index );\n\n\t\t\t// Create modified block with previous content stored.\n\t\t\tmodifications.set( bestMatch.index, {\n\t\t\t\t...bestMatch.block,\n\t\t\t\t__revisionDiffStatus: { status: 'modified' },\n\t\t\t\t__previousRawBlock: rem.block,\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Rebuild result: filter out paired removed, replace paired added with modified.\n\treturn blocks\n\t\t.map( ( block, index ) => {\n\t\t\t// Skip paired removed blocks.\n\t\t\tif ( pairedRemoved.has( index ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// Replace paired added blocks with modified version.\n\t\t\tif ( modifications.has( index ) ) {\n\t\t\t\treturn modifications.get( index );\n\t\t\t}\n\t\t\treturn block;\n\t\t} )\n\t\t.filter( Boolean );\n}\n\n/**\n * Diff raw block arrays using LCS, recursively handling innerBlocks.\n * Detects modifications when exactly 1 block is removed and 1 is added\n * with the same blockName (1:1 replacement = modification).\n *\n * @param {Array} currentRaw Current revision's raw blocks.\n * @param {Array} previousRaw Previous revision's raw blocks.\n * @return {Array} Merged raw blocks with diff status injected.\n */\nfunction diffRawBlocks( currentRaw, previousRaw ) {\n\tconst createBlockSignature = ( rawBlock ) =>\n\t\tJSON.stringify( {\n\t\t\tname: rawBlock.blockName,\n\t\t\tattrs: rawBlock.attrs,\n\t\t\t// Use innerContent filtered to non-null and non-whitespace-only strings.\n\t\t\t// This excludes whitespace between inner blocks which changes based on count.\n\t\t\thtml: ( rawBlock.innerContent || [] ).filter(\n\t\t\t\t( c ) => c !== null && c.trim() !== ''\n\t\t\t),\n\t\t} );\n\tconst currentSigs = currentRaw.map( createBlockSignature );\n\tconst previousSigs = previousRaw.map( createBlockSignature );\n\n\tconst diff = diffArrays( previousSigs, currentSigs );\n\n\tconst result = [];\n\tlet currIdx = 0;\n\tlet prevIdx = 0;\n\n\tfor ( const part of diff ) {\n\t\tif ( part.added ) {\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\t...currentRaw[ currIdx++ ],\n\t\t\t\t\t__revisionDiffStatus: { status: 'added' },\n\t\t\t\t} );\n\t\t\t}\n\t\t} else if ( part.removed ) {\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\t...previousRaw[ prevIdx++ ],\n\t\t\t\t\t__revisionDiffStatus: { status: 'removed' },\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\t// Matched blocks - recursively diff their innerBlocks.\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tconst currBlock = currentRaw[ currIdx++ ];\n\t\t\t\tconst prevBlock = previousRaw[ prevIdx++ ];\n\n\t\t\t\t// Recursively diff inner blocks.\n\t\t\t\tconst diffedInnerBlocks = diffRawBlocks(\n\t\t\t\t\tcurrBlock.innerBlocks || [],\n\t\t\t\t\tprevBlock.innerBlocks || []\n\t\t\t\t);\n\n\t\t\t\tresult.push( {\n\t\t\t\t\t...currBlock,\n\t\t\t\t\tinnerBlocks: diffedInnerBlocks,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Post-process to pair similar removed/added blocks as modifications.\n\treturn pairSimilarBlocks( result );\n}\n\n/**\n * Check if formatting has changed at specific character indices.\n *\n * @param {Array} currentFormats Current formats array.\n * @param {Array} previousFormats Previous formats array.\n * @param {number} currentIndex Character index in current.\n * @param {number} previousIndex Character index in previous.\n * @return {boolean} True if formatting changed at these indices.\n */\nfunction hasFormatChangedAtIndex(\n\tcurrentFormats,\n\tpreviousFormats,\n\tcurrentIndex,\n\tpreviousIndex\n) {\n\tconst currFmts = currentFormats[ currentIndex ] || [];\n\tconst prevFmts = previousFormats[ previousIndex ] || [];\n\n\tif ( currFmts.length !== prevFmts.length ) {\n\t\treturn true;\n\t}\n\n\t// Check if each format in current exists in previous\n\tfor ( const fmt of currFmts ) {\n\t\tconst match = prevFmts.find(\n\t\t\t( pf ) =>\n\t\t\t\tpf.type === fmt.type &&\n\t\t\t\tJSON.stringify( pf.attributes ) ===\n\t\t\t\t\tJSON.stringify( fmt.attributes )\n\t\t);\n\t\tif ( ! match ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Analyze what formatting changed between two character positions.\n * Returns both the change type (for styling) and a description (for tooltip).\n *\n * @param {Array} currentFormats Current formats array.\n * @param {Array} previousFormats Previous formats array.\n * @param {number} currIdx Character index in current.\n * @param {number} prevIdx Character index in previous.\n * @return {{ type: 'added'|'removed'|'changed', description: string }} Change info.\n */\nfunction describeFormatChange(\n\tcurrentFormats,\n\tpreviousFormats,\n\tcurrIdx,\n\tprevIdx\n) {\n\tconst currFmts = currentFormats[ currIdx ] || [];\n\tconst prevFmts = previousFormats[ prevIdx ] || [];\n\n\tlet addedCount = 0;\n\tlet removedCount = 0;\n\tlet changedCount = 0;\n\n\t// Find added formats and attribute changes\n\tfor ( const fmt of currFmts ) {\n\t\tconst match = prevFmts.find( ( pf ) => pf.type === fmt.type );\n\t\tif ( ! match ) {\n\t\t\taddedCount++;\n\t\t} else if (\n\t\t\tJSON.stringify( fmt.attributes ) !==\n\t\t\tJSON.stringify( match.attributes )\n\t\t) {\n\t\t\tchangedCount++;\n\t\t}\n\t}\n\n\t// Find removed formats\n\tfor ( const fmt of prevFmts ) {\n\t\tconst match = currFmts.find( ( cf ) => cf.type === fmt.type );\n\t\tif ( ! match ) {\n\t\t\tremovedCount++;\n\t\t}\n\t}\n\n\t// Determine primary change type for styling\n\tif ( addedCount > 0 && removedCount === 0 && changedCount === 0 ) {\n\t\treturn {\n\t\t\ttype: 'added',\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %d: number of formats added */\n\t\t\t\t_n( '%d format added', '%d formats added', addedCount ),\n\t\t\t\taddedCount\n\t\t\t),\n\t\t};\n\t}\n\tif ( removedCount > 0 && addedCount === 0 && changedCount === 0 ) {\n\t\treturn {\n\t\t\ttype: 'removed',\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %d: number of formats removed */\n\t\t\t\t_n( '%d format removed', '%d formats removed', removedCount ),\n\t\t\t\tremovedCount\n\t\t\t),\n\t\t};\n\t}\n\n\t// Mixed or attribute-only changes\n\tconst parts = [];\n\tif ( addedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats added */\n\t\t\t\t_n( '%d format added', '%d formats added', addedCount ),\n\t\t\t\taddedCount\n\t\t\t)\n\t\t);\n\t}\n\tif ( removedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats removed */\n\t\t\t\t_n( '%d format removed', '%d formats removed', removedCount ),\n\t\t\t\tremovedCount\n\t\t\t)\n\t\t);\n\t}\n\tif ( changedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats changed */\n\t\t\t\t_n( '%d format changed', '%d formats changed', changedCount ),\n\t\t\t\tchangedCount\n\t\t\t)\n\t\t);\n\t}\n\treturn {\n\t\ttype: 'changed',\n\t\tdescription: parts.join( ', ' ) || __( 'Formatting changed' ),\n\t};\n}\n\n/**\n * Apply inline diff formatting comparing two RichTextData values.\n * - Text changes: apply revision/diff-removed and revision/diff-added formats\n * - Format-only changes (text unchanged): apply revision/diff-format-changed format\n *\n * @param {RichTextData} currentRichText Current revision's rich text.\n * @param {RichTextData} previousRichText Previous revision's rich text.\n * @return {RichTextData} New rich text with diff formatting applied.\n */\nfunction applyRichTextDiff( currentRichText, previousRichText ) {\n\tconst currentText = currentRichText.toPlainText();\n\tconst previousText = previousRichText.toPlainText();\n\n\t// Diff the plain text (words for cleaner output)\n\tconst textDiff = diffWords( previousText, currentText );\n\n\tlet result = create( { text: '' } );\n\tlet currentIdx = 0;\n\tlet previousIdx = 0;\n\n\tfor ( const part of textDiff ) {\n\t\tif ( part.removed ) {\n\t\t\t// Text deleted - slice from PREVIOUS, apply <del>\n\t\t\tconst removedSlice = slice(\n\t\t\t\tpreviousRichText,\n\t\t\t\tpreviousIdx,\n\t\t\t\tpreviousIdx + part.value.length\n\t\t\t);\n\t\t\tconst formatted = applyFormat(\n\t\t\t\tremovedSlice,\n\t\t\t\t{\n\t\t\t\t\ttype: 'revision/diff-removed',\n\t\t\t\t\tattributes: { title: __( 'Removed' ) },\n\t\t\t\t},\n\t\t\t\t0,\n\t\t\t\tpart.value.length\n\t\t\t);\n\t\t\tresult = concat( result, formatted );\n\t\t\tpreviousIdx += part.value.length;\n\t\t} else if ( part.added ) {\n\t\t\t// Text added - slice from CURRENT, apply <ins>\n\t\t\tconst addedSlice = slice(\n\t\t\t\tcurrentRichText,\n\t\t\t\tcurrentIdx,\n\t\t\t\tcurrentIdx + part.value.length\n\t\t\t);\n\t\t\tconst formatted = applyFormat(\n\t\t\t\taddedSlice,\n\t\t\t\t{\n\t\t\t\t\ttype: 'revision/diff-added',\n\t\t\t\t\tattributes: { title: __( 'Added' ) },\n\t\t\t\t},\n\t\t\t\t0,\n\t\t\t\tpart.value.length\n\t\t\t);\n\t\t\tresult = concat( result, formatted );\n\t\t\tcurrentIdx += part.value.length;\n\t\t} else {\n\t\t\t// Text unchanged - check formatting at each character position.\n\t\t\t// Only apply <mark> to specific ranges where formatting differs.\n\t\t\tconst currentFormats = currentRichText.formats || [];\n\t\t\tconst previousFormats = previousRichText.formats || [];\n\t\t\tconst len = part.value.length;\n\n\t\t\t// Helper to check format change at offset within this unchanged part.\n\t\t\tconst checkFormatChanged = ( offset ) =>\n\t\t\t\thasFormatChangedAtIndex(\n\t\t\t\t\tcurrentFormats,\n\t\t\t\t\tpreviousFormats,\n\t\t\t\t\tcurrentIdx + offset,\n\t\t\t\t\tpreviousIdx + offset\n\t\t\t\t);\n\n\t\t\t// Find ranges of characters grouped by whether format changed.\n\t\t\tlet rangeStart = 0;\n\t\t\tlet rangeFormatChanged = checkFormatChanged( 0 );\n\n\t\t\tfor ( let i = 1; i <= len; i++ ) {\n\t\t\t\tconst formatChanged = i < len && checkFormatChanged( i );\n\n\t\t\t\t// When format-changed status changes or we reach the end, emit range.\n\t\t\t\tif ( i === len || formatChanged !== rangeFormatChanged ) {\n\t\t\t\t\tconst rangeSlice = slice(\n\t\t\t\t\t\tcurrentRichText,\n\t\t\t\t\t\tcurrentIdx + rangeStart,\n\t\t\t\t\t\tcurrentIdx + i\n\t\t\t\t\t);\n\n\t\t\t\t\tif ( rangeFormatChanged ) {\n\t\t\t\t\t\t// Get type and description of what changed\n\t\t\t\t\t\tconst { type, description } = describeFormatChange(\n\t\t\t\t\t\t\tcurrentFormats,\n\t\t\t\t\t\t\tpreviousFormats,\n\t\t\t\t\t\t\tcurrentIdx + rangeStart,\n\t\t\t\t\t\t\tpreviousIdx + rangeStart\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Map change type to format type for styling\n\t\t\t\t\t\tconst formatType = {\n\t\t\t\t\t\t\tadded: 'revision/diff-format-added',\n\t\t\t\t\t\t\tremoved: 'revision/diff-format-removed',\n\t\t\t\t\t\t\tchanged: 'revision/diff-format-changed',\n\t\t\t\t\t\t}[ type ];\n\n\t\t\t\t\t\tconst marked = applyFormat(\n\t\t\t\t\t\t\trangeSlice,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: formatType,\n\t\t\t\t\t\t\t\tattributes: { title: description },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\ti - rangeStart\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult = concat( result, marked );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = concat( result, rangeSlice );\n\t\t\t\t\t}\n\n\t\t\t\t\trangeStart = i;\n\t\t\t\t\trangeFormatChanged = formatChanged;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcurrentIdx += part.value.length;\n\t\t\tpreviousIdx += part.value.length;\n\t\t}\n\t}\n\n\treturn new RichTextData( result );\n}\n\n/**\n * Apply diffs to a modified block's attributes.\n * - Rich-text attributes: applies inline diff formatting (ins/del marks).\n * - Other attributes: computes word-level diffs for the sidebar panel.\n *\n * @param {Object} currentBlock Current parsed block.\n * @param {Object} previousBlock Previous parsed block.\n * @param {Object} diffStatus The __revisionDiffStatus object to attach changedAttributes to.\n */\nfunction applyDiffToBlock( currentBlock, previousBlock, diffStatus ) {\n\tconst blockType = getBlockType( currentBlock.name );\n\tif ( ! blockType ) {\n\t\treturn;\n\t}\n\n\tconst changedAttributes = {};\n\n\tfor ( const [ attrName, attrDef ] of Object.entries(\n\t\tblockType.attributes\n\t) ) {\n\t\tif ( attrDef.source === 'rich-text' ) {\n\t\t\tconst currentRichText = currentBlock.attributes[ attrName ];\n\t\t\tconst previousRichText = previousBlock.attributes[ attrName ];\n\t\t\tif (\n\t\t\t\tcurrentRichText instanceof RichTextData &&\n\t\t\t\tpreviousRichText instanceof RichTextData\n\t\t\t) {\n\t\t\t\tcurrentBlock.attributes[ attrName ] = applyRichTextDiff(\n\t\t\t\t\tcurrentRichText,\n\t\t\t\t\tpreviousRichText\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst currStr = stringifyValue(\n\t\t\t\tcurrentBlock.attributes[ attrName ]\n\t\t\t);\n\t\t\tconst prevStr = stringifyValue(\n\t\t\t\tpreviousBlock.attributes[ attrName ]\n\t\t\t);\n\t\t\tif ( currStr !== prevStr ) {\n\t\t\t\tchangedAttributes[ attrName ] = diffWords( prevStr, currStr );\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( Object.keys( changedAttributes ).length > 0 ) {\n\t\tdiffStatus.changedAttributes = changedAttributes;\n\t}\n}\n\n/**\n * Recursively apply diff status and rich text diff to blocks in the tree.\n * Copies __revisionDiffStatus from raw blocks to parsed blocks and applies\n * rich text diffs to modified blocks.\n *\n * @param {Object} parsedBlock Parsed block (with inner blocks).\n * @param {Object} rawBlock Raw block (with __revisionDiffStatus and __previousRawBlock).\n */\nfunction applyDiffRecursively( parsedBlock, rawBlock ) {\n\t// Copy diff status from raw block to parsed block.\n\tif ( rawBlock.__revisionDiffStatus ) {\n\t\t// Apply diffs if this block is modified and has a previous raw block.\n\t\tif (\n\t\t\trawBlock.__revisionDiffStatus.status === 'modified' &&\n\t\t\trawBlock.__previousRawBlock\n\t\t) {\n\t\t\tconst previousParsed = parseRawBlock( rawBlock.__previousRawBlock );\n\t\t\tif ( previousParsed ) {\n\t\t\t\tapplyDiffToBlock(\n\t\t\t\t\tparsedBlock,\n\t\t\t\t\tpreviousParsed,\n\t\t\t\t\trawBlock.__revisionDiffStatus\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tparsedBlock.__revisionDiffStatus = rawBlock.__revisionDiffStatus;\n\t\t// Also store in attributes so it survives block-editor store normalization.\n\t\tparsedBlock.attributes.__revisionDiffStatus =\n\t\t\trawBlock.__revisionDiffStatus;\n\t}\n\n\t// Recursively process inner blocks.\n\tif ( parsedBlock.innerBlocks && rawBlock.innerBlocks ) {\n\t\tfor ( let i = 0; i < parsedBlock.innerBlocks.length; i++ ) {\n\t\t\tconst parsedInner = parsedBlock.innerBlocks[ i ];\n\t\t\tconst rawInner = rawBlock.innerBlocks[ i ];\n\t\t\tif ( parsedInner && rawInner ) {\n\t\t\t\tapplyDiffRecursively( parsedInner, rawInner );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Diff two revision contents at the grammar level.\n *\n * @param {string} currentContent Current revision's raw content.\n * @param {string} previousContent Previous revision's raw content.\n * @return {Array} Array of parsed blocks with diff status attributes.\n */\nexport function diffRevisionContent( currentContent, previousContent ) {\n\t// Grammar parse both contents.\n\tconst currentRaw = grammarParse( currentContent || '' );\n\tconst previousRaw = grammarParse( previousContent || '' );\n\n\t// Diff the raw block arrays.\n\tconst mergedRaw = diffRawBlocks( currentRaw, previousRaw );\n\n\t// Parse each raw block and apply diff status.\n\treturn mergedRaw\n\t\t.map( ( rawBlock ) => {\n\t\t\tconst parsed = parseRawBlock( rawBlock );\n\t\t\tif ( parsed ) {\n\t\t\t\tapplyDiffRecursively( parsed, rawBlock );\n\t\t\t}\n\t\t\treturn parsed;\n\t\t} )\n\t\t.filter( Bo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