<commit_before>/**
 * External dependencies
 */
import PropTypes from 'prop-types';

/**
 * WordPress dependencies
 */
import { getBlockType, createBlock } from '@wordpress/blocks';
import { BlockIcon } from '@wordpress/block-editor';
import { withDispatch, withSelect } from '@wordpress/data';
import { DropdownMenu } from '@wordpress/components';
import { compose, ifCondition } from '@wordpress/compose';
import { __, sprintf } from '@wordpress/i18n';
/**
 * Internal dependencies
 */
import { IMAGE_BACKGROUND_TYPE, VIDEO_BACKGROUND_TYPE } from '../../constants';

const MediaInserter = ( { insertBlock, updateBlock, canInsertBlockType, showInserter } ) => {
	const blocks = [
		'core/video',
		'core/image',
	];

	const dropDownOptions = [
		{
			title: __( 'Insert background image', 'amp' ),
			icon: 'format-image',
			onClick: () => mediaPicker( __( 'Select background image', 'amp' ), 'image', updateBlock ),
			disabled: ! showInserter,
		},
		{
			title: __( 'Insert background video', 'amp' ),
			icon: 'media-video',
			onClick: () => mediaPicker( __( 'Select background video', 'amp' ), 'video', updateBlock ),
			disabled: ! showInserter,
		},
	];

	blocks.map( ( block ) => {
		if ( ! canInsertBlockType( block ) ) {
			return null;
		}

		const blockType = getBlockType( block );
		const item = {
			title: sprintf( __( 'Insert %s', 'amp' ), blockType.title ),
			onClick: () => insertBlock( block ),
			disabled: ! showInserter,
			icon: <BlockIcon icon={ blockType.icon } />,
		};
		dropDownOptions.unshift( item );
		return null;
	} );

	return (
		<DropdownMenu
			icon="admin-media"
			label={ __( 'Select media', 'amp' ) }<commit_msg>Use for loop instead of Array.prototype.map<commit_after>/**
 * External dependencies
 */
import PropTypes from 'prop-types';

/**
 * WordPress dependencies
 */
import { getBlockType, createBlock } from '@wordpress/blocks';
import { BlockIcon } from '@wordpress/block-editor';
import { withDispatch, withSelect } from '@wordpress/data';
import { DropdownMenu } from '@wordpress/components';
import { compose, ifCondition } from '@wordpress/compose';
import { __, sprintf } from '@wordpress/i18n';
/**
 * Internal dependencies
 */
import { IMAGE_BACKGROUND_TYPE, VIDEO_BACKGROUND_TYPE } from '../../constants';

const MediaInserter = ( { insertBlock, updateBlock, canInsertBlockType, showInserter } ) => {
	const blocks = [
		'core/video',
		'core/image',
	];

	const dropDownOptions = [
		{
			title: __( 'Insert background image', 'amp' ),
			icon: 'format-image',
			onClick: () => mediaPicker( __( 'Select background image', 'amp' ), 'image', updateBlock ),
			disabled: ! showInserter,
		},
		{
			title: __( 'Insert background video', 'amp' ),
			icon: 'media-video',
			onClick: () => mediaPicker( __( 'Select background video', 'amp' ), 'video', updateBlock ),
			disabled: ! showInserter,
		},
	];

	for ( const block of blocks ) {
		if ( ! canInsertBlockType( block ) ) {
			continue;
		}

		const blockType = getBlockType( block );
		const item = {
			title: sprintf( __( 'Insert %s', 'amp' ), blockType.title ),
			onClick: () => insertBlock( block ),
			disabled: ! showInserter,
			icon: <BlockIcon icon={ blockType.icon } />,
		};

		dropDownOptions.unshift( item );
	}

	return (
		<DropdownMenu
			icon="admin-media"
			label={ __( 'Select media', 'amp' ) }
{'fraction_non_alphanumeric': 0.16061242870009007, 'fraction_numerical': 0.0012008405884118883, 'mean_word_length': 3.9289940828402368, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3433876', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1043, 'n_words': 261}