{
  "version": 3,
  "sources": ["../../../src/api/raw-handling/heading-transformer.ts"],
  "sourcesContent": ["/**\n * Transforms paragraphs with heading semantics into proper heading tags.\n *\n * This handles cases where content (like from Microsoft Word Online) comes in as\n * <p> tags with role=\"heading\" and aria-level attributes, and converts them to\n * proper <h1>, <h2>, etc. tags.\n *\n * @param node The node to check and potentially transform.\n */\nexport default function headingTransformer( node: Node ): void {\n\tif ( node.nodeType !== node.ELEMENT_NODE ) {\n\t\treturn;\n\t}\n\n\t// Check if this is a paragraph with heading semantics.\n\tconst element = node as HTMLElement;\n\tif (\n\t\telement.tagName === 'P' &&\n\t\telement.getAttribute( 'role' ) === 'heading' &&\n\t\telement.hasAttribute( 'aria-level' )\n\t) {\n\t\tconst level = parseInt( element.getAttribute( 'aria-level' )!, 10 );\n\n\t\t// To ensure valid heading level (1-6).\n\t\tif ( level >= 1 && level <= 6 ) {\n\t\t\tconst headingTag = `H${ level }`;\n\t\t\tconst newHeading =\n\t\t\t\telement.ownerDocument.createElement( headingTag );\n\n\t\t\t// Copying all attributes except role and aria-level.\n\t\t\tArray.from( element.attributes ).forEach( ( attr ) => {\n\t\t\t\tif ( attr.name !== 'role' && attr.name !== 'aria-level' ) {\n\t\t\t\t\tnewHeading.setAttribute( attr.name, attr.value );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\twhile ( element.firstChild ) {\n\t\t\t\tnewHeading.appendChild( element.firstChild );\n\t\t\t}\n\n\t\t\t// Replacing the paragraph with the heading.\n\t\t\telement.parentNode!.replaceChild( newHeading, element );\n\t\t}\n\t}\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASe,SAAR,mBAAqC,MAAmB;AAC9D,MAAK,KAAK,aAAa,KAAK,cAAe;AAC1C;AAAA,EACD;AAGA,QAAM,UAAU;AAChB,MACC,QAAQ,YAAY,OACpB,QAAQ,aAAc,MAAO,MAAM,aACnC,QAAQ,aAAc,YAAa,GAClC;AACD,UAAM,QAAQ,SAAU,QAAQ,aAAc,YAAa,GAAI,EAAG;AAGlE,QAAK,SAAS,KAAK,SAAS,GAAI;AAC/B,YAAM,aAAa,IAAK,KAAM;AAC9B,YAAM,aACL,QAAQ,cAAc,cAAe,UAAW;AAGjD,YAAM,KAAM,QAAQ,UAAW,EAAE,QAAS,CAAE,SAAU;AACrD,YAAK,KAAK,SAAS,UAAU,KAAK,SAAS,cAAe;AACzD,qBAAW,aAAc,KAAK,MAAM,KAAK,KAAM;AAAA,QAChD;AAAA,MACD,CAAE;AAEF,aAAQ,QAAQ,YAAa;AAC5B,mBAAW,YAAa,QAAQ,UAAW;AAAA,MAC5C;AAGA,cAAQ,WAAY,aAAc,YAAY,OAAQ;AAAA,IACvD;AAAA,EACD;AACD;",
  "names": []
}
