{
  "version": 3,
  "sources": ["../../../src/api/parser/fix-global-attribute.ts"],
  "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { hasBlockSupport } from '../registration';\nimport { parseWithAttributeSchema } from './get-block-attributes';\nimport type { BlockAttribute, BlockType } from '../../types';\n\n/**\n * Given an HTML string and an attribute schema, returns the specified attribute\n * value from the root element in the markup.\n *\n * @param innerHTML       Markup string from which to extract the attribute.\n * @param dataAttribute   The data attribute name to use as wrapper.\n * @param attributeSchema The attribute schema configuration.\n *\n * @return The attribute value assigned to the root element.\n */\nexport function getHTMLRootElement(\n\tinnerHTML: string,\n\tdataAttribute: string,\n\tattributeSchema: BlockAttribute\n): unknown {\n\tconst parsed = parseWithAttributeSchema(\n\t\t`<div ${ dataAttribute }>${ innerHTML }</div>`,\n\t\tattributeSchema\n\t);\n\treturn parsed;\n}\n\n/**\n * Given a parsed set of block attributes, if the block supports the specified attribute\n * and the attribute is found in the HTML, the attribute is assigned to the block attributes.\n *\n * @param blockAttributes Original block attributes.\n * @param blockType       Block type settings.\n * @param innerHTML       Original block markup.\n * @param supportKey      The block support key to check and attribute key to set.\n * @param dataAttribute   The data attribute name to use as wrapper.\n * @param attributeSchema The attribute schema configuration.\n *\n * @return Filtered block attributes.\n */\nexport function fixGlobalAttribute(\n\tblockAttributes: Record< string, unknown >,\n\tblockType: BlockType,\n\tinnerHTML: string,\n\tsupportKey: string,\n\tdataAttribute: string,\n\tattributeSchema: BlockAttribute\n): Record< string, unknown > {\n\tif ( ! hasBlockSupport( blockType, supportKey, false ) ) {\n\t\treturn blockAttributes;\n\t}\n\tconst modifiedBlockAttributes = { ...blockAttributes };\n\tconst attributeValue = getHTMLRootElement(\n\t\tinnerHTML,\n\t\tdataAttribute,\n\t\tattributeSchema\n\t);\n\tif ( attributeValue ) {\n\t\tmodifiedBlockAttributes[ supportKey ] = attributeValue;\n\t}\n\treturn modifiedBlockAttributes;\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAgC;AAChC,kCAAyC;AAalC,SAAS,mBACf,WACA,eACA,iBACU;AACV,QAAM,aAAS;AAAA,IACd,QAAS,aAAc,IAAK,SAAU;AAAA,IACtC;AAAA,EACD;AACA,SAAO;AACR;AAeO,SAAS,mBACf,iBACA,WACA,WACA,YACA,eACA,iBAC4B;AAC5B,MAAK,KAAE,qCAAiB,WAAW,YAAY,KAAM,GAAI;AACxD,WAAO;AAAA,EACR;AACA,QAAM,0BAA0B,EAAE,GAAG,gBAAgB;AACrD,QAAM,iBAAiB;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,MAAK,gBAAiB;AACrB,4BAAyB,UAAW,IAAI;AAAA,EACzC;AACA,SAAO;AACR;",
  "names": []
}
