{
  "version": 3,
  "sources": ["../../../src/api/raw-handling/ms-list-converter.js"],
  "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { deepFilterHTML } from './utils';\nimport msListIgnore from './ms-list-ignore';\n\nfunction isList( node ) {\n\treturn node.nodeName === 'OL' || node.nodeName === 'UL';\n}\n\nexport default function msListConverter( node, doc ) {\n\tif ( node.nodeName !== 'P' ) {\n\t\treturn;\n\t}\n\n\tconst style = node.getAttribute( 'style' );\n\n\tif ( ! style || ! style.includes( 'mso-list' ) ) {\n\t\treturn;\n\t}\n\n\tconst prevNode = node.previousElementSibling;\n\n\t// Add new list if no previous.\n\tif ( ! prevNode || ! isList( prevNode ) ) {\n\t\t// See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type.\n\t\tconst type = node.textContent.trim().slice( 0, 1 );\n\t\tconst isNumeric = /[1iIaA]/.test( type );\n\t\tconst newListNode = doc.createElement( isNumeric ? 'ol' : 'ul' );\n\n\t\tif ( isNumeric ) {\n\t\t\tnewListNode.setAttribute( 'type', type );\n\t\t}\n\n\t\tnode.parentNode.insertBefore( newListNode, node );\n\t}\n\n\tconst listNode = node.previousElementSibling;\n\tconst listType = listNode.nodeName;\n\tconst listItem = doc.createElement( 'li' );\n\n\tlet receivingNode = listNode;\n\n\t// Add content.\n\tlistItem.innerHTML = deepFilterHTML( node.innerHTML, [ msListIgnore ] );\n\n\tconst matches = /mso-list\\s*:[^;]+level([0-9]+)/i.exec( style );\n\tlet level = matches ? parseInt( matches[ 1 ], 10 ) - 1 || 0 : 0;\n\n\t// Change pointer depending on indentation level.\n\twhile ( level-- ) {\n\t\treceivingNode = receivingNode.lastChild || receivingNode;\n\n\t\t// If it's a list, move pointer to the last item.\n\t\tif ( isList( receivingNode ) ) {\n\t\t\treceivingNode = receivingNode.lastChild || receivingNode;\n\t\t}\n\t}\n\n\t// Make sure we append to a list.\n\tif ( ! isList( receivingNode ) ) {\n\t\treceivingNode = receivingNode.appendChild(\n\t\t\tdoc.createElement( listType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