/*!
 * Copyright © 2018 Splunk Inc.
 * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
 * in part without a valid written license from Splunk Inc. is PROHIBITED.
 */(()=>{"use strict";var e={9172:function(e,t,o){var a=this&&this.__createBinding||(Object.create?function(e,t,o,a){void 0===a&&(a=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,a,i)}:function(e,t,o,a){void 0===a&&(a=o),e[a]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&a(t,e,o);return i(t,e),t},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.EDITOR_NAME=void 0;const l=n(o(9497)),s=r(o(23)),u=r(o(7446)),d=o(9033),c=o(6801),p=o(1385),f=o(1256),b=r(o(4008));t.EDITOR_NAME="columnMultiSelectionByFieldName-editor";const g=[],m=({name:e,value:o,label:a,labelPosition:i="top",labelWidth:n,isAdvanced:r=!1,isDisabled:s=!1,tooltip:c,dataSourceBindings:m,filterByTypes:v=g,onChange:h})=>{const _=(0,p.useDataSource)({dataSourceBindings:m,dataSourceKey:"primary"}),{hasError:y,isMissing:O,isLoading:M}=(0,l.useMemo)((()=>(0,d.getDataSourceStateInfo)(_)),[_]),j=(0,l.useMemo)((()=>O||y||s),[y,s,O]),{columns:x,fields:P}=(0,l.useMemo)((()=>(null==_?void 0:_.data)||{columns:[],fields:[]}),[_]),D=(0,l.useMemo)((()=>(0,f.getAvailableFieldsWithTypes)(x,P)),[x,P]),A=(0,l.useMemo)((()=>(0,f.sanitizeFieldNames)(o,D.map((e=>e.name)))),[o,D]),E=(0,l.useCallback)(((t,{values:o})=>{h(t,e,o)}),[h,e]);return l.default.createElement(b.default,{"data-test":`${t.EDITOR_NAME}-${e}`,label:a,labelPosition:i,labelWidth:n,tooltip:c,isAdvanced:r},l.default.createElement(u.default,{"data-test":`${t.EDITOR_NAME}-select-${e}`,onChange:E,values:A,disabled:j,isLoadingOptions:M,compact:!0,selectAllAppearance:"checkbox"},D.map((e=>l.default.createElement(u.default.Option,{"data-test":`${t.EDITOR_NAME}-option-${e.name}`,key:e.name,value:e.name,label:`${e.name} (${e.type})`,disabled:v.length>0&&!v.find((t=>t===e.type))})))))};m.propTypes=Object.assign(Object.assign({},c.BaseEditorPropTypes),{tooltip:s.default.bool,labelPosition:s.default.oneOf(["top","left"]),isAdvanced:s.default.bool,isDisabled:s.default.bool}),t.default=m},1385:function(e,t,o){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.useDataSource=void 0;const i=o(9497),n=a(o(4853)),r=o(4793);t.useDataSource=({dataSourceBindings:e,dataSourceKey:t})=>{const o=(0,i.useContext)(n.default),[a,l]=(0,i.useState)();return(0,i.useEffect)((()=>{if(!(0,r.get)(e,t))return l(null),()=>{};const a=(0,r.isFunction)(o.subscribe)&&o.subscribe(t,(e=>l(e)));return()=>{a&&a()}}),[e]),a}},6801:function(e,t,o){var a=this&&this.__createBinding||(Object.create?function(e,t,o,a){void 0===a&&(a=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,a,i)}:function(e,t,o,a){void 0===a&&(a=o),e[a]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&a(t,e,o);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.BaseEditorPropTypes=void 0;const r=n(o(23));t.BaseEditorPropTypes={name:r.string.isRequired,value:r.oneOfType([r.string,r.object,r.arrayOf(r.string)]),context:r.object,label:r.string,labelPosition:r.oneOf(["top","left"]),labelWidth:r.number,onChange:r.func,isAdvanced:r.bool,isDisabled:r.bool,dataSourceBindings:r.object,options:r.object,optionsSchema:r.object}},4008:function(e,t,o){var a=this&&this.__createBinding||(Object.create?function(e,t,o,a){void 0===a&&(a=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,a,i)}:function(e,t,o,a){void 0===a&&(a=o),e[a]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&a(t,e,o);return i(t,e),t},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AdvancedConfigButton=void 0;const l=n(o(9497)),s=n(o(23)),u=r(o(232)),d=o(6649),c=r(o(6643)),p=o(3563),f=r(o(6379)),b=r(o(7020)),g=r(o(9250)),m=(0,u.default)(g.default)`
    margin-top: 0;
    padding: 0;
    // adjust bottom margin according to theme
    margin-bottom: ${p.variables.spacingMedium};
    width: 100%;

    // remove top margin of the first component in control group
    &:first-child {
        margin-top: 0;
    }

    // remove bottom margin of the last component in control group
    &:last-child {
        margin-bottom: 0;
    }
    // remove top padding on label of the first control group
    [data-test='label']:first-of-type {
        padding-top: 0;
    }
`,v=(0,u.default)(f.default)`
    display: flex;
    > span {
        display: flex;
        width: 35px;
    }
`,h=(0,u.default)(b.default)`
    color: ${p.variables.contentColorActive} !important;
    &:hover {
        background-color: ${p.variables.interactiveColorOverlayDrag} !important;
    }
`;t.AdvancedConfigButton=({label:e="",onClick:t})=>l.default.createElement(v,{"data-test":`${e}-advanced-config-button-tooltip`,content:(0,d._)("Advanced configurations")},l.default.createElement(h,{"data-test":`${e}-advanced-config-button`,icon:l.default.createElement(c.default,{"data-test":`${e}-advanced-config-button-icon`}),appearance:"subtle",onClick:t}));const _=({"data-test":e,children:o,isAdvanced:a=!1,label:i,hideLabel:n,labelPosition:r,labelWidth:s,tooltip:u,help:d,style:c,error:p,controlsLayout:f,onClick:b,onAdvancedConfigButtonClick:g})=>l.default.createElement(m,{"data-test":null!=e?e:"control-group",label:i,hideLabel:n,labelPosition:r,labelWidth:s,tooltip:u,help:d,error:p,style:c,onClick:b,controlsLayout:f},a?l.Children.toArray(o).filter(Boolean).map((e=>(0,l.cloneElement)(e,{style:{flex:1}}))):o,a?l.default.createElement(t.AdvancedConfigButton,{label:i,onClick:g}):null);_.propTypes={style:s.object,isAdvanced:s.bool,onClick:s.func,onAdvancedConfigButtonClick:s.func},t.default=_},1256:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getPlaceholderMessage=t.sanitizeFieldNames=t.getFilteredFields=t.getAvailableFieldsWithTypes=void 0;const a=o(6649),i=o(2588);t.getAvailableFieldsWithTypes=(e,t)=>t.map(((t,o)=>{const{name:a}=t;return{name:a,type:(0,i.canInferTypeFromMeta)(t)?(0,i.getDataTypeForMeta)(t):(0,i.inferDataTypeFromData)(e[o])}}));t.getFilteredFields=(e,t)=>e.filter((e=>-1!==e.name.indexOf(t)));t.sanitizeFieldNames=(e,t)=>"string"==typeof e&&t.includes(e)?[e]:Array.isArray(e)?e.filter((e=>t.includes(e))):[];t.getPlaceholderMessage=({hasError:e,isLoading:t,isMissing:o,defaultMessage:i="Select a field from data source"})=>o?(0,a._)("Set up data source to select"):e?(0,a._)("Please set up valid data source to select"):t?(0,a._)("Loading data source..."):(0,a._)(i)},6643:e=>{e.exports=require("@splunk/react-icons/SlidersDoubleHorizontal")},7020:e=>{e.exports=require("@splunk/react-ui/Button")},9250:e=>{e.exports=require("@splunk/react-ui/ControlGroup")},7446:e=>{e.exports=require("@splunk/react-ui/Multiselect")},6379:e=>{e.exports=require("@splunk/react-ui/Tooltip")},3563:e=>{e.exports=require("@splunk/themes")},6649:e=>{e.exports=require("@splunk/ui-utils/i18n")},4853:e=>{e.exports=require("@splunk/visualization-context/DataSourceContext")},2588:e=>{e.exports=require("@splunk/visualization-encoding/utils/types")},9033:e=>{e.exports=require("@splunk/visualizations-shared/dataSourceUtils")},4793:e=>{e.exports=require("lodash")},23:e=>{e.exports=require("prop-types")},9497:e=>{e.exports=require("react")},232:e=>{e.exports=require("styled-components")}},t={};var o=function o(a){var i=t[a];if(void 0!==i)return i.exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,o),n.exports}(9172);module.exports=o})();
//# sourceMappingURL=ColumnMultiSelectionByFieldNameEditor.js.map