(window["anomalyDetectionDashboards_bundle_jsonpfunction"]=window["anomalyDetectionDashboards_bundle_jsonpfunction"]||[]).push([[22],{2806:function(module,exports,__webpack_require__){"use strict";var _interopRequireWildcard=__webpack_require__(9).default;var _interopRequireDefault=__webpack_require__(0).default;Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(__webpack_require__(3));var _eui=__webpack_require__(7);var _react=__webpack_require__(13);var _react2=_interopRequireWildcard(__webpack_require__(2));var _common=__webpack_require__(10);var _filter_bar=__webpack_require__(801);var _query=__webpack_require__(154);class ApplyFiltersPopoverContent extends _react2.Component{constructor(props){super(props);(0,_defineProperty2.default)(this,"isFilterSelected",i=>this.state.isFilterSelected[i]);(0,_defineProperty2.default)(this,"toggleFilterSelected",i=>{const isFilterSelected=[...this.state.isFilterSelected];isFilterSelected[i]=!isFilterSelected[i];this.setState({isFilterSelected:isFilterSelected})});(0,_defineProperty2.default)(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=(0,_common.getDisplayValueFromFilter)(filter,this.props.indexPatterns);return _react2.default.createElement(_filter_bar.FilterLabel,{filter:filter,valueLabel:valueLabel})}render(){if(this.props.filters.length===0){return""}const mappedFilters=(0,_query.mapAndFlattenFilters)(this.props.filters);const form=_react2.default.createElement(_eui.EuiForm,null,mappedFilters.map((filter,i)=>_react2.default.createElement(_eui.EuiCompressedFormRow,{key:i},_react2.default.createElement(_eui.EuiCompressedSwitch,{label:this.getLabel(filter),checked:this.isFilterSelected(i),onChange:()=>this.toggleFilterSelected(i)}))));return _react2.default.createElement(_react2.default.Fragment,null,_react2.default.createElement(_eui.EuiModalHeader,null,_react2.default.createElement(_eui.EuiModalHeaderTitle,null,_react2.default.createElement(_eui.EuiText,{size:"s"},_react2.default.createElement("h2",null,_react2.default.createElement(_react.FormattedMessage,{id:"data.filter.applyFilters.popupHeader",defaultMessage:"Select filters to apply"}))))),_react2.default.createElement(_eui.EuiModalBody,null,form),_react2.default.createElement(_eui.EuiModalFooter,null,_react2.default.createElement(_eui.EuiSmallButtonEmpty,{onClick:this.props.onCancel},_react2.default.createElement(_react.FormattedMessage,{id:"data.filter.applyFiltersPopup.cancelButtonLabel",defaultMessage:"Cancel"})),_react2.default.createElement(_eui.EuiSmallButton,{onClick:this.onSubmit,"data-test-subj":"applyFiltersPopoverButton",fill:true},_react2.default.createElement(_react.FormattedMessage,{id:"data.filter.applyFiltersPopup.saveButtonLabel",defaultMessage:"Apply"}))))}}exports.default=ApplyFiltersPopoverContent;(0,_defineProperty2.default)(ApplyFiltersPopoverContent,"defaultProps",{filters:[]});module.exports=exports.default}}]);