: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Array of icon colors containing a color to be used if the icon color
* was not explicitly set but the icon background color was.
const ICON_COLORS = ['#191e23', '#f8f9f9'];
* Determines whether the block's attributes are equal to the default attributes
* which means the block is unmodified.
* @param {WPBlock} block Block Object
* @return {boolean} Whether the block is an unmodified block.
function isUnmodifiedBlock(block) {
var _getBlockType$attribu;
return Object.entries((_getBlockType$attribu = getBlockType(block.name)?.attributes) !== null && _getBlockType$attribu !== void 0 ? _getBlockType$attribu : {}).every(([key, definition]) => {
const value = block.attributes[key];
// Every attribute that has a default must match the default.
if (definition.hasOwnProperty('default')) {
return value === definition.default;
// The rich text type is a bit different from the rest because it
// has an implicit default value of an empty RichTextData instance,
// so check the length of the value.
if (definition.type === 'rich-text') {
// Every attribute that doesn't have a default should be undefined.
return value === undefined;
* Determines whether the block is a default block and its attributes are equal
* to the default attributes which means the block is unmodified.
* @param {WPBlock} block Block Object
* @return {boolean} Whether the block is an unmodified default block.
function isUnmodifiedDefaultBlock(block) {
return block.name === getDefaultBlockName() && isUnmodifiedBlock(block);
* Function that checks if the parameter is a valid icon.
* @param {*} icon Parameter to be checked.
* @return {boolean} True if the parameter is a valid icon and false otherwise.
function isValidIcon(icon) {
return !!icon && (typeof icon === 'string' || (0,external_wp_element_namespaceObject.isValidElement)(icon) || typeof icon === 'function' || icon instanceof external_wp_element_namespaceObject.Component);
* Function that receives an icon as set by the blocks during the registration
* and returns a new icon object that is normalized so we can rely on just on possible icon structure
* @param {WPBlockTypeIconRender} icon Render behavior of a block type icon;
* one of a Dashicon slug, an element, or a
* @return {WPBlockTypeIconDescriptor} Object describing the icon.
function normalizeIconObject(icon) {
icon = icon || BLOCK_ICON_DEFAULT;
if ('background' in icon) {
const colordBgColor = w(icon.background);
const getColorContrast = iconColor => colordBgColor.contrast(iconColor);
const maxContrast = Math.max(...ICON_COLORS.map(getColorContrast));
foreground: icon.foreground ? icon.foreground : ICON_COLORS.find(iconColor => getColorContrast(iconColor) === maxContrast),
shadowColor: colordBgColor.alpha(0.3).toRgbString()
* Normalizes block type passed as param. When string is passed then
* it converts it to the matching block type object.
* It passes the original object otherwise.
* @param {string|Object} blockTypeOrName Block type or name.
* @return {?Object} Block type.
function normalizeBlockType(blockTypeOrName) {
if (typeof blockTypeOrName === 'string') {
return getBlockType(blockTypeOrName);
* Get the label for the block, usually this is either the block title,
* or the value of the block's `label` function when that's specified.
* @param {Object} blockType The block type.
* @param {Object} attributes The values of the block's attributes.
* @param {Object} context The intended use for the label.
* @return {string} The block label.
function getBlockLabel(blockType, attributes, context = 'visual') {
__experimentalLabel: getLabel,
const label = getLabel && getLabel(attributes, {
return label.toPlainText();
// Strip any HTML (i.e. RichText formatting) before returning.
return (0,external_wp_dom_namespaceObject.__unstableStripHTML)(label);
* Get a label for the block for use by screenreaders, this is more descriptive
* than the visual label and includes the block title and the value of the
* `getLabel` function if it's specified.
* @param {?Object} blockType The block type.
* @param {Object} attributes The values of the block's attributes.
* @param {?number} position The position of the block in the block list.
* @param {string} [direction='vertical'] The direction of the block layout.
* @return {string} The block label.
function getAccessibleBlockLabel(blockType, attributes, position, direction = 'vertical') {
// `title` is already localized, `label` is a user-supplied value.
const title = blockType?.title;
const label = blockType ? getBlockLabel(blockType, attributes, 'accessibility') : '';
const hasPosition = position !== undefined;
// getBlockLabel returns the block title as a fallback when there's no label,
// if it did return the title, this function needs to avoid adding the
// title twice within the accessible label. Use this `hasLabel` boolean to
const hasLabel = label && label !== title;
if (hasPosition && direction === 'vertical') {
return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */
(0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d. %3$s'), title, position, label);
return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block row number. */
(0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d'), title, position);
} else if (hasPosition && direction === 'horizontal') {
return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */
(0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d. %3$s'), title, position, label);
return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block column number. */
(0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d'), title, position);
return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. %1: The block title. %2: The block label. */
(0,external_wp_i18n_namespaceObject.__)('%1$s Block. %2$s'), title, label);
return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. %s: The block title. */
(0,external_wp_i18n_namespaceObject.__)('%s Block'), title);
function getDefault(attributeSchema) {
if (attributeSchema.default !== undefined) {
return attributeSchema.default;
if (attributeSchema.type === 'rich-text') {
return new external_wp_richText_namespaceObject.RichTextData();
* Ensure attributes contains only values defined by block type, and merge
* default values for missing attributes.
* @param {string} name The block's name.
* @param {Object} attributes The block's attributes.
* @return {Object} The sanitized attributes.
function __experimentalSanitizeBlockAttributes(name, attributes) {
// Get the type definition associated with a registered block.
const blockType = getBlockType(name);
if (undefined === blockType) {
throw new Error(`Block type '${name}' is not registered.`);
return Object.entries(blockType.attributes).reduce((accumulator, [key, schema]) => {
const value = attributes[key];
if (undefined !== value) {
if (schema.type === 'rich-text') {
if (value instanceof external_wp_richText_namespaceObject.RichTextData) {
accumulator[key] = value;
} else if (typeof value === 'string') {
accumulator[key] = external_wp_richText_namespaceObject.RichTextData.fromHTMLString(value);
} else if (schema.type === 'string' && value instanceof external_wp_richText_namespaceObject.RichTextData) {
accumulator[key] = value.toHTMLString();
accumulator[key] = value;
const _default = getDefault(schema);
if (undefined !== _default) {
accumulator[key] = _default;
if (['node', 'children'].indexOf(schema.source) !== -1) {
// Ensure value passed is always an array, which we're expecting in
// the RichText component to handle the deprecated value.
if (typeof accumulator[key] === 'string') {
accumulator[key] = [accumulator[key]];
} else if (!Array.isArray(accumulator[key])) {
* Filter block attributes by `role` and return their names.
* @param {string} name Block attribute's name.
* @param {string} role The role of a block attribute.
* @return {string[]} The attribute names that have the provided role.
function __experimentalGetBlockAttributesNamesByRole(name, role) {
const attributes = getBlockType(name)?.attributes;
const attributesNames = Object.keys(attributes);
return attributesNames.filter(attributeName => attributes[attributeName]?.__experimentalRole === role);
* Return a new object with the specified keys omitted.
* @param {Object} object Original object.
* @param {Array} keys Keys to be omitted.
* @return {Object} Object with omitted keys.
function omit(object, keys) {
return Object.fromEntries(Object.entries(object).filter(([key]) => !keys.includes(key)));
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js
* @typedef {Object} WPBlockCategory
* @property {string} slug Unique category slug.
* @property {string} title Category label, for display in user interface.
* Default set of categories.
* @type {WPBlockCategory[]}
const DEFAULT_CATEGORIES = [{
title: (0,external_wp_i18n_namespaceObject.__)('Text')
title: (0,external_wp_i18n_namespaceObject.__)('Media')
title: (0,external_wp_i18n_namespaceObject.__)('Design')
title: (0,external_wp_i18n_namespaceObject.__)('Widgets')
title: (0,external_wp_i18n_namespaceObject.__)('Theme')
title: (0,external_wp_i18n_namespaceObject.__)('Embeds')
title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
// Key block types by their name.
function keyBlockTypesByName(types) {
return types.reduce((newBlockTypes, block) => ({
// Filter items to ensure they're unique by their name.
function getUniqueItemsByName(items) {
return items.reduce((acc, currentItem) => {
if (!acc.some(item => item.name === currentItem.name)) {
function bootstrappedBlockTypes(state = {}, action) {
case 'ADD_BOOTSTRAPPED_BLOCK_TYPE':
const serverDefinition = state[name];
// Don't overwrite if already set. It covers the case when metadata
// was initialized from the server.
// The `blockHooks` prop is not yet included in the server provided
// definitions and needs to be polyfilled. This can be removed when the
// minimum supported WordPress is >= 6.4.
if (serverDefinition.blockHooks === undefined && blockType.blockHooks) {
blockHooks: blockType.blockHooks
// The `allowedBlocks` prop is not yet included in the server provided
// definitions and needs to be polyfilled. This can be removed when the
// minimum supported WordPress is >= 6.5.
if (serverDefinition.allowedBlocks === undefined && blockType.allowedBlocks) {
allowedBlocks: blockType.allowedBlocks
newDefinition = Object.fromEntries(Object.entries(blockType).filter(([, value]) => value !== null && value !== undefined).map(([key, value]) => [camelCase(key), value]));
newDefinition.name = name;
case 'REMOVE_BLOCK_TYPES':
return omit(state, action.names);
* Reducer managing the unprocessed block types in a form passed when registering the by block.
* It's for internal use only. It allows recomputing the processed block types on-demand after block type filters
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
* @return {Object} Updated state.
function unprocessedBlockTypes(state = {}, action) {
case 'ADD_UNPROCESSED_BLOCK_TYPE':
[action.name]: action.blockType
case 'REMOVE_BLOCK_TYPES':
return omit(state, action.names);
* Reducer managing the processed block types with all filters applied.
* The state is derived from the `unprocessedBlockTypes` reducer.
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
* @return {Object} Updated state.
function blockTypes(state = {}, action) {
...keyBlockTypesByName(action.blockTypes)
case 'REMOVE_BLOCK_TYPES':
return omit(state, action.names);
* Reducer managing the block styles.
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
* @return {Object} Updated state.
function blockStyles(state = {}, action) {
var _state$action$blockNa;
...Object.fromEntries(Object.entries(keyBlockTypesByName(action.blockTypes)).map(([name, blockType]) => {
var _blockType$styles, _state$blockType$name;
return [name, getUniqueItemsByName([...((_blockType$styles = blockType.styles) !== null && _blockType$styles !== void 0 ? _blockType$styles : []).map(style => ({
})), ...((_state$blockType$name = state[blockType.name]) !== null && _state$blockType$name !== void 0 ? _state$blockType$name : []).filter(({
}) => 'block' !== source)])];
const updatedStyles = {};
action.blockNames.forEach(blockName => {
updatedStyles[blockName] = getUniqueItemsByName([...((_state$blockName = state[blockName]) !== null && _state$blockName !== void 0 ? _state$blockName : []), ...action.styles]);
case 'REMOVE_BLOCK_STYLES':
[action.blockName]: ((_state$action$blockNa = state[action.blockName]) !== null && _state$action$blockNa !== void 0 ? _state$action$blockNa : []).filter(style => action.styleNames.indexOf(style.name) === -1)
* Reducer managing the block variations.
* @param {Object} state Current state.