(window["customImportMapDashboards_bundle_jsonpfunction"]=window["customImportMapDashboards_bundle_jsonpfunction"]||[]).push([[18],{1970:function(module,exports,__webpack_require__){"use strict";var _interopRequireDefault=__webpack_require__(0);Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(__webpack_require__(2));var _eui=__webpack_require__(6);var _react=__webpack_require__(13);var _react2=_interopRequireWildcard(__webpack_require__(3));var _common=__webpack_require__(8);var _filter_bar=__webpack_require__(507);var _query=__webpack_require__(208);function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap,t=new WeakMap;return(_getRequireWildcardCache=function(e){return e?t:r})(e)}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,t&&t.set(e,n),n}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}}]);