(window["observabilityDashboards_bundle_jsonpfunction"]=window["observabilityDashboards_bundle_jsonpfunction"]||[]).push([[12],{2317:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,"default",(function(){return ApplyFiltersPopoverContent}));var _elastic_eui__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(2);var _elastic_eui__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_elastic_eui__WEBPACK_IMPORTED_MODULE_0__);var _osd_i18n_react__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(8);var _osd_i18n_react__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_osd_i18n_react__WEBPACK_IMPORTED_MODULE_1__);var react__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(0);var react__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);var _common__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4);var _filter_bar__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(249);var _query__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(33);function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}class ApplyFiltersPopoverContent extends react__WEBPACK_IMPORTED_MODULE_2__["Component"]{constructor(props){super(props);_defineProperty(this,"isFilterSelected",i=>this.state.isFilterSelected[i]);_defineProperty(this,"toggleFilterSelected",i=>{const isFilterSelected=[...this.state.isFilterSelected];isFilterSelected[i]=!isFilterSelected[i];this.setState({isFilterSelected:isFilterSelected})});_defineProperty(this,"onSubmit",()=>{const selectedFilters=this.props.filters.filter((filter,i)=>this.state.isFilterSelected[i]);this.props.onSubmit(selectedFilters)});this.state={isFilterSelected:props.filters.map(()=>true)}}getLabel(filter){const valueLabel=Object(_common__WEBPACK_IMPORTED_MODULE_3__["K"])(filter,this.props.indexPatterns);return react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_filter_bar__WEBPACK_IMPORTED_MODULE_4__["a"],{filter:filter,valueLabel:valueLabel})}render(){if(this.props.filters.length===0){return""}const mappedFilters=Object(_query__WEBPACK_IMPORTED_MODULE_5__["i"])(this.props.filters);const form=react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_elastic_eui__WEBPACK_IMPORTED_MODULE_0__["EuiForm"],null,mappedFilters.map((filter,i)=>react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_elastic_eui__WEBPACK_IMPORTED_MODULE_0__["EuiFormRow"],{key:i},react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_elastic_eui__WEBPACK_IMPORTED_MODULE_0__["EuiSwitch"],{label:this.getLabel(filter),checked:this.isFilterSelected(i),onChange:()=>this.toggleFilterSelected(i)}))));return react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_2___default.a.Fragment,null,react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_elastic_eui__WEBPACK_IMPORTED_MODULE_0__["EuiModalHeader"],null,react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_elastic_eui__WEBPACK_IMPORTED_MODULE_0__["EuiModalHeaderTitle"],null,react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_osd_i18n_react__WEBPACK_IMPORTED_MODULE_1__["FormattedMessage"],{id:"data.filter.applyFilters.popupHeader",defaultMessage:"Select filters to apply"}))),react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_elastic_eui__WEBPACK_IMPORTED_MODULE_0__["EuiModalBody"],null,form),react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_elastic_eui__WEBPACK_IMPORTED_MODULE_0__["EuiModalFooter"],null,react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_elastic_eui__WEBPACK_IMPORTED_MODULE_0__["EuiButtonEmpty"],{onClick:this.props.onCancel},react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_osd_i18n_react__WEBPACK_IMPORTED_MODULE_1__["FormattedMessage"],{id:"data.filter.applyFiltersPopup.cancelButtonLabel",defaultMessage:"Cancel"})),react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_elastic_eui__WEBPACK_IMPORTED_MODULE_0__["EuiButton"],{onClick:this.onSubmit,"data-test-subj":"applyFiltersPopoverButton",fill:true},react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_osd_i18n_react__WEBPACK_IMPORTED_MODULE_1__["FormattedMessage"],{id:"data.filter.applyFiltersPopup.saveButtonLabel",defaultMessage:"Apply"}))))}}_defineProperty(ApplyFiltersPopoverContent,"defaultProps",{filters:[]})}}]);