{
  "version": 3,
  "sources": ["../../../src/api/raw-handling/html-to-blocks.js"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { createBlock, findTransform } from '../factory';\nimport parse from '../parser';\nimport { getBlockAttributes } from '../parser/get-block-attributes';\nimport { getRawTransforms } from './get-raw-transforms';\n\n/**\n * Converts HTML directly to blocks. Looks for a matching transform for each\n * top-level tag. The HTML should be filtered to not have any text between\n * top-level tags and formatted in a way that blocks can handle the HTML.\n *\n * @param {string}   html    HTML to convert.\n * @param {Function} handler The handler calling htmlToBlocks: either rawHandler\n *                           or pasteHandler.\n *\n * @return {Array} An array of blocks.\n */\nexport function htmlToBlocks( html, handler ) {\n\tconst doc = document.implementation.createHTMLDocument( '' );\n\n\tdoc.body.innerHTML = html;\n\n\treturn Array.from( doc.body.children ).flatMap( ( node ) => {\n\t\tconst rawTransform = findTransform(\n\t\t\tgetRawTransforms(),\n\t\t\t( { isMatch } ) => isMatch( node )\n\t\t);\n\n\t\tif ( ! rawTransform ) {\n\t\t\t// Until the HTML block is supported in the native version, we'll parse it\n\t\t\t// instead of creating the block to generate it as an unsupported block.\n\t\t\tif ( Platform.isNative ) {\n\t\t\t\treturn parse(\n\t\t\t\t\t`<!-- wp:html -->${ node.outerHTML }<!-- /wp:html -->`\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn createBlock(\n\t\t\t\t// Should not be hardcoded.\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockAttributes( 'core/html', node.outerHTML )\n\t\t\t);\n\t\t}\n\n\t\tconst { transform, blockName } = rawTransform;\n\n\t\tif ( transform ) {\n\t\t\tconst block = transform( node, handler );\n\t\t\tif ( node.hasAttribute( 'class' ) ) {\n\t\t\t\tblock.attributes.className = node.getAttribute( 'class' );\n\t\t\t}\n\t\t\treturn block;\n\t\t}\n\n\t\treturn createBlock(\n\t\t\tblockName,\n\t\t\tgetBlockAttributes( blockName, node.outerHTML )\n\t\t);\n\t} );\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAyB;AAKzB,qBAA2C;AAC3C,oBAAkB;AAClB,kCAAmC;AACnC,gCAAiC;AAa1B,SAAS,aAAc,MAAM,SAAU;AAC7C,QAAM,MAAM,SAAS,eAAe,mBAAoB,EAAG;AAE3D,MAAI,KAAK,YAAY;AAErB,SAAO,MAAM,KAAM,IAAI,KAAK,QAAS,EAAE,QAAS,CAAE,SAAU;AAC3D,UAAM,mBAAe;AAAA,UACpB,4CAAiB;AAAA,MACjB,CAAE,EAAE,QAAQ,MAAO,QAAS,IAAK;AAAA,IAClC;AAEA,QAAK,CAAE,cAAe;AAGrB,UAAK,wBAAS,UAAW;AACxB,mBAAO,cAAAA;AAAA,UACN,mBAAoB,KAAK,SAAU;AAAA,QACpC;AAAA,MACD;AACA,iBAAO;AAAA;AAAA,QAEN;AAAA,YACA,gDAAoB,aAAa,KAAK,SAAU;AAAA,MACjD;AAAA,IACD;AAEA,UAAM,EAAE,WAAW,UAAU,IAAI;AAEjC,QAAK,WAAY;AAChB,YAAM,QAAQ,UAAW,MAAM,OAAQ;AACvC,UAAK,KAAK,aAAc,OAAQ,GAAI;AACnC,cAAM,WAAW,YAAY,KAAK,aAAc,OAAQ;AAAA,MACzD;AACA,aAAO;AAAA,IACR;AAEA,eAAO;AAAA,MACN;AAAA,UACA,gDAAoB,WAAW,KAAK,SAAU;AAAA,IAC/C;AAAA,EACD,CAAE;AACH;",
  "names": ["parse"]
}
