!function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t){function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){a=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(a)throw o}}return r}(e,t)||a(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||a(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach(function(t){u(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var c=wp.hooks.addFilter,s=wp.compose.createHigherOrderComponent,p=wp.blockEditor.InspectorControls,f=wp.components,g=f.PanelBody,d=f.SelectControl,b=wp.i18n.__,y=[{label:b("All"),value:"all"}],m=s(function(e){var t=[];return t.push({label:y[0].label,value:y[0].value}),t.push.apply(t,n(Object.entries(wpml_active_and_selected_languages.active_languages).map(function(e){var t=r(e,2),n=(t[0],t[1]);return{label:n.native_name,value:n.code}}))),function(r){var n=r.attributes.wpml_language;return void 0!==r.attributes.__internalWidgetId&&"core/legacy-widget"===r.name&&(y[0].value=wpml_active_and_selected_languages.legacy_widgets_languages[r.attributes.__internalWidgetId]),React.createElement(React.Fragment,null,React.createElement(e,r),React.createElement(p,null,React.createElement(g,{title:b("Display on language","sitepress-multilingual-cms"),initialOpen:!0},React.createElement(d,{value:n||y[0].value,options:t,onChange:function(e){if(r.setAttributes({wpml_language:e}),void 0!==r.attributes.__internalWidgetId&&"core/legacy-widget"===r.name){var n=t.find(function(t){return t.value===e});void 0!==n&&v(r.attributes.__internalWidgetId,n)}}}))))}},"languageControls"),v=function(e,t){var r=new FormData;r.append("action","wpml_change_selected_language_for_legacy_widget"),r.append("id",e),r.append("selected_language_value",t.value),fetch(ajaxurl,{method:"POST",body:r}).then(function(e){if(!e.ok)throw new Error("Changing selected language for legacy widgets action has failed!.")})};c("blocks.registerBlockType","sitepress-multilingual-cms/attribute/wpml_language",function(e){return e.attributes=l(l({},e.attributes),{},{wpml_language:{type:"string"}}),e}),c("editor.BlockEdit","sitepress-multilingual-cms/language-controls",m)},function(e,t,r){"use strict";r.r(t);r(0)},function(e,t,r){e.exports=r(1)}]);