{
  "version": 3,
  "sources": ["../../../src/api/raw-handling/phrasing-content-reducer.ts"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { wrap, replaceTag } from '@wordpress/dom';\n\nexport default function phrasingContentReducer(\n\tnode: Node,\n\tdoc: Document\n): void {\n\t// In jsdom-jscore, 'node.style' can be null.\n\t// TODO: Explore fixing this by patching jsdom-jscore.\n\tif ( node.nodeName === 'SPAN' && ( node as HTMLElement ).style ) {\n\t\tconst {\n\t\t\tfontWeight,\n\t\t\tfontStyle,\n\t\t\ttextDecorationLine,\n\t\t\ttextDecoration,\n\t\t\tverticalAlign,\n\t\t} = ( node as HTMLElement ).style;\n\n\t\tconst element = node as Element;\n\n\t\tif ( fontWeight === 'bold' || fontWeight === '700' ) {\n\t\t\twrap( doc.createElement( 'strong' ), element );\n\t\t}\n\n\t\tif ( fontStyle === 'italic' ) {\n\t\t\twrap( doc.createElement( 'em' ), element );\n\t\t}\n\n\t\t// Some DOM implementations (Safari, JSDom) don't support\n\t\t// style.textDecorationLine, so we check style.textDecoration as a\n\t\t// fallback.\n\t\tif (\n\t\t\ttextDecorationLine === 'line-through' ||\n\t\t\ttextDecoration.includes( 'line-through' )\n\t\t) {\n\t\t\twrap( doc.createElement( 's' ), element );\n\t\t}\n\n\t\tif ( verticalAlign === 'super' ) {\n\t\t\twrap( doc.createElement( 'sup' ), element );\n\t\t} else if ( verticalAlign === 'sub' ) {\n\t\t\twrap( doc.createElement( 'sub' ), element );\n\t\t}\n\t} else if ( node.nodeName === 'B' ) {\n\t\treplaceTag( node as Element, 'strong' );\n\t} else if ( node.nodeName === 'I' ) {\n\t\treplaceTag( node as Element, 'em' );\n\t} else if ( node.nodeName === 'A' ) {\n\t\tconst anchor = node as HTMLAnchorElement;\n\t\t// In jsdom-jscore, 'node.target' can be null.\n\t\t// TODO: Explore fixing this by patching jsdom-jscore.\n\t\tif ( anchor.target && anchor.target.toLowerCase() === '_blank' ) {\n\t\t\tanchor.rel = 'noreferrer noopener';\n\t\t} else {\n\t\t\tanchor.removeAttribute( 'target' );\n\t\t\tanchor.removeAttribute( 'rel' );\n\t\t}\n\n\t\t// Saves anchor elements name attribute as id\n\t\tif ( anchor.name && ! anchor.id ) {\n\t\t\tanchor.id = anchor.name;\n\t\t}\n\n\t\t// Keeps id only if there is an internal link pointing to it\n\t\tif (\n\t\t\tanchor.id &&\n\t\t\t! anchor.ownerDocument.querySelector( `[href=\"#${ anchor.id }\"]` )\n\t\t) {\n\t\t\tanchor.removeAttribute( 'id' );\n\t\t}\n\t}\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAiC;AAElB,SAAR,uBACN,MACA,KACO;AAGP,MAAK,KAAK,aAAa,UAAY,KAAsB,OAAQ;AAChE,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAM,KAAsB;AAE5B,UAAM,UAAU;AAEhB,QAAK,eAAe,UAAU,eAAe,OAAQ;AACpD,2BAAM,IAAI,cAAe,QAAS,GAAG,OAAQ;AAAA,IAC9C;AAEA,QAAK,cAAc,UAAW;AAC7B,2BAAM,IAAI,cAAe,IAAK,GAAG,OAAQ;AAAA,IAC1C;AAKA,QACC,uBAAuB,kBACvB,eAAe,SAAU,cAAe,GACvC;AACD,2BAAM,IAAI,cAAe,GAAI,GAAG,OAAQ;AAAA,IACzC;AAEA,QAAK,kBAAkB,SAAU;AAChC,2BAAM,IAAI,cAAe,KAAM,GAAG,OAAQ;AAAA,IAC3C,WAAY,kBAAkB,OAAQ;AACrC,2BAAM,IAAI,cAAe,KAAM,GAAG,OAAQ;AAAA,IAC3C;AAAA,EACD,WAAY,KAAK,aAAa,KAAM;AACnC,+BAAY,MAAiB,QAAS;AAAA,EACvC,WAAY,KAAK,aAAa,KAAM;AACnC,+BAAY,MAAiB,IAAK;AAAA,EACnC,WAAY,KAAK,aAAa,KAAM;AACnC,UAAM,SAAS;AAG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