{
  "version": 3,
  "sources": ["../../src/store/private-selectors.ts"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { getBlockType } from './selectors';\nimport { getValueFromObjectPath } from './utils';\nimport { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY } from '../api/constants';\nimport type { BlockStoreState } from './types';\nimport type { BlockAttribute, BlockBindingsSource, BlockType } from '../types';\n\nconst ROOT_BLOCK_SUPPORTS: string[] = [\n\t'background',\n\t'backgroundColor',\n\t'color',\n\t'linkColor',\n\t'captionColor',\n\t'buttonColor',\n\t'headingColor',\n\t'fontFamily',\n\t'fontSize',\n\t'fontStyle',\n\t'fontWeight',\n\t'lineHeight',\n\t'padding',\n\t'contentSize',\n\t'wideSize',\n\t'blockGap',\n\t'textAlign',\n\t'textDecoration',\n\t'textIndent',\n\t'textTransform',\n\t'letterSpacing',\n];\n\n/**\n * Filters the list of supported styles for a given element.\n *\n * @param blockSupports list of supported styles.\n * @param name          block name.\n * @param element       element name.\n *\n * @return filtered list of supported styles.\n */\nfunction filterElementBlockSupports(\n\tblockSupports: string[],\n\tname: string | undefined,\n\telement: string | undefined\n): string[] {\n\treturn blockSupports.filter( ( support ) => {\n\t\tif ( support === 'fontSize' && element === 'heading' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// This is only available for links\n\t\tif ( support === 'textDecoration' && ! name && element !== 'link' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// This is only available for heading, button, caption and text\n\t\tif (\n\t\t\tsupport === 'textTransform' &&\n\t\t\t! name &&\n\t\t\t! (\n\t\t\t\t[ 'heading', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ].includes(\n\t\t\t\t\telement as string\n\t\t\t\t) ||\n\t\t\t\telement === 'button' ||\n\t\t\t\telement === 'caption' ||\n\t\t\t\telement === 'text'\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// This is only available for heading, button, caption and text\n\t\tif (\n\t\t\tsupport === 'letterSpacing' &&\n\t\t\t! name &&\n\t\t\t! (\n\t\t\t\t[ 'heading', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ].includes(\n\t\t\t\t\telement as string\n\t\t\t\t) ||\n\t\t\t\telement === 'button' ||\n\t\t\t\telement === 'caption' ||\n\t\t\t\telement === 'text'\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Text indent is only available for blocks, not elements\n\t\tif ( support === 'textIndent' && ! name ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Text columns is only available for blocks.\n\t\tif ( support === 'textColumns' && ! name ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} );\n}\n\n/**\n * Returns the list of supported styles for a given block name and element.\n */\nexport const getSupportedStyles = createSelector(\n\t(\n\t\tstate: BlockStoreState,\n\t\tname: string | undefined,\n\t\telement: string | undefined\n\t): string[] => {\n\t\tif ( ! name ) {\n\t\t\treturn filterElementBlockSupports(\n\t\t\t\tROOT_BLOCK_SUPPORTS,\n\t\t\t\tname,\n\t\t\t\telement\n\t\t\t);\n\t\t}\n\n\t\tconst blockType = getBlockType( state, name );\n\n\t\tif ( ! blockType ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst supportKeys: string[] = [];\n\n\t\t// Check for blockGap support.\n\t\t// Block spacing support doesn't map directly to a single style property, so needs to be handled separately.\n\t\tconst supports = blockType?.supports as\n\t\t\t| Record< string, unknown >\n\t\t\t| undefined;\n\t\tif (\n\t\t\t( supports?.spacing as Record< string, unknown > | undefined )\n\t\t\t\t?.blockGap\n\t\t) {\n\t\t\tsupportKeys.push( 'blockGap' );\n\t\t}\n\n\t\t// check for shadow support\n\t\tif ( supports?.shadow ) {\n\t\t\tsupportKeys.push( 'shadow' );\n\t\t}\n\n\t\tconst stylePropertyMap = STYLE_PROPERTY as Record<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tsupport?: string[];\n\t\t\t\trequiresOptOut?: boolean;\n\t\t\t\tvalue?: string[];\n\t\t\t}\n\t\t>;\n\n\t\tObject.keys( stylePropertyMap ).forEach( ( styleName ) => {\n\t\t\tif ( ! stylePropertyMap[ styleName ].support ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Opting out means that, for certain support keys like background color,\n\t\t\t// blocks have to explicitly set the support value false. If the key is\n\t\t\t// unset, we still enable it.\n\t\t\tif ( stylePropertyMap[ styleName ].requiresOptOut ) {\n\t\t\t\tif (\n\t\t\t\t\tsupports &&\n\t\t\t\t\tstylePropertyMap[ styleName ].support![ 0 ] in supports &&\n\t\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\t\tsupports,\n\t\t\t\t\t\tstylePropertyMap[ styleName ].support!\n\t\t\t\t\t) !== false\n\t\t\t\t) {\n\t\t\t\t\tsupportKeys.push( styleName );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tsupports &&\n\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\tsupports,\n\t\t\t\t\tstylePropertyMap[ styleName ].support!,\n\t\t\t\t\tfalse\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tsupportKeys.push( styleName );\n\t\t\t}\n\t\t} );\n\n\t\treturn filterElementBlockSupports( supportKeys, name, element );\n\t},\n\t( state: BlockStoreState, name: string | undefined ) => [\n\t\tstate.blockTypes[ name as string ],\n\t]\n);\n\n/**\n * Returns the bootstrapped block type metadata for a give block name.\n *\n * @param state Data state.\n * @param name  Block name.\n *\n * @return Bootstrapped block type metadata for a block.\n */\nexport function getBootstrappedBlockType(\n\tstate: BlockStoreState,\n\tname: string\n): Partial< BlockType > | undefined {\n\treturn state.bootstrappedBlockTypes[ name ];\n}\n\n/**\n * Returns all the unprocessed (before applying the `registerBlockType` filter)\n * block type settings as passed during block registration.\n *\n * @param state Data state.\n *\n * @return Unprocessed block type settings for all blocks.\n */\nexport function getUnprocessedBlockTypes(\n\tstate: BlockStoreState\n): Record< string, Partial< BlockType > > {\n\treturn state.unprocessedBlockTypes;\n}\n\n/**\n * Returns all the block bindings sources registered.\n *\n * @param state Data state.\n *\n * @return All the registered sources and their properties.\n */\nexport function getAllBlockBindingsSources(\n\tstate: BlockStoreState\n): Record< string, Omit< BlockBindingsSource, 'name' > > {\n\treturn state.blockBindingsSources;\n}\n\n/**\n * Returns a specific block bindings source.\n *\n * @param state      Data state.\n * @param sourceName Name of the source to get.\n *\n * @return The specific block binding source and its properties.\n */\nexport function getBlockBindingsSource(\n\tstate: BlockStoreState,\n\tsourceName: string\n): Omit< BlockBindingsSource, 'name' > | undefined {\n\treturn state.blockBindingsSources[ sourceName ];\n}\n\n/**\n * Compute the fields list for a specific block bindings source.\n *\n * @param state        Data state.\n * @param source       Block bindings source.\n * @param blockContext Block context.\n *\n * @return List of fields for the specific source.\n */\nexport const getBlockBindingsSourceFieldsList = createRegistrySelector(\n\t( select: unknown ) =>\n\t\tcreateSelector(\n\t\t\t(\n\t\t\t\tstate: BlockStoreState,\n\t\t\t\tsource: BlockBindingsSource,\n\t\t\t\tblockContext: Record< string, unknown >\n\t\t\t): unknown[] => {\n\t\t\t\tif ( ! source.getFieldsList ) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\n\t\t\t\tconst context: Record< string, unknown > = {};\n\t\t\t\tif ( source?.usesContext?.length ) {\n\t\t\t\t\tfor ( const key of source.usesContext ) {\n\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn source.getFieldsList( { select, context } ) as unknown[];\n\t\t\t},\n\t\t\t(\n\t\t\t\tstate: BlockStoreState,\n\t\t\t\tsource: BlockBindingsSource,\n\t\t\t\tblockContext: Record< string, unknown >\n\t\t\t) => [ source.getFieldsList, source.usesContext, blockContext ]\n\t\t)\n);\n\n/**\n * Determines if any of the block type's attributes have\n * the content role attribute.\n *\n * @param state         Data state.\n * @param blockTypeName Block type name.\n * @return Whether block type has content role attribute.\n */\nexport const hasContentRoleAttribute = (\n\tstate: BlockStoreState,\n\tblockTypeName: string\n): boolean => {\n\tconst blockType = getBlockType( state, blockTypeName );\n\tif ( ! blockType ) {\n\t\treturn false;\n\t}\n\n\treturn Object.values( blockType.attributes ).some(\n\t\t( { role, __experimentalRole }: BlockAttribute ) => {\n\t\t\tif ( role === 'content' ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( __experimentalRole === 'content' ) {\n\t\t\t\tdeprecated( '__experimentalRole attribute', {\n\t\t\t\t\tsince: '6.7',\n\t\t\t\t\tversion: '6.8',\n\t\t\t\t\talternative: 'role attribute',\n\t\t\t\t\thint: `Check the block.json of the ${ blockTypeName } block.`,\n\t\t\t\t} );\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t);\n};\n"],
  "mappings": ";AAGA,SAAS,gBAAgB,8BAA8B;AACvD,OAAO,gBAAgB;AAKvB,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B;AACvC,SAAS,iCAAiC,sBAAsB;AAIhE,IAAM,sBAAgC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAWA,SAAS,2BACR,eACA,MACA,SACW;AACX,SAAO,cAAc,OAAQ,CAAE,YAAa;AAC3C,QAAK,YAAY,cAAc,YAAY,WAAY;AACtD,aAAO;AAAA,IACR;AAGA,QAAK,YAAY,oBAAoB,CAAE,QAAQ,YAAY,QAAS;AACnE,aAAO;AAAA,IACR;AAGA,QACC,YAAY,mBACZ,CAAE,QACF,EACC,CAAE,WAAW,MAAM,MAAM,MAAM,MAAM,MAAM,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