!function(e){function t(t){for(var i,n,a=t[0],r=t[1],o=0,l=[];o","|"],o=r.concat(" ");function d(e){const t={},i=function(e){return r.reduce(((t,i)=>(e.includes(i)&&t.push(i),t)),[])}(e);return i.length&&(t[n]=i),function(e){return e.includes(" ")}(e)&&(t[a]=!0),t}},function(e,t,i){"use strict";i.d(t,"c",(function(){return DuplicateDataViewError})),i.d(t,"b",(function(){return DataViewSavedObjectConflictError})),i.d(t,"a",(function(){return DataViewInsufficientAccessError}));class DuplicateDataViewError extends Error{constructor(e){super(e),this.name="DuplicateDataViewError"}}class DataViewSavedObjectConflictError extends Error{constructor(e){super(`Conflict loading DataView saved object, id: ${e}`),this.name="DataViewSavedObjectConflictError"}}class DataViewInsufficientAccessError extends Error{constructor(e){super(`Operation failed due to insufficient access, id: ${e}`),this.name="DataViewInsufficientAccessError"}}},function(e,t,i){"use strict";i.d(t,"b",(function(){return c})),i.d(t,"d",(function(){return l})),i.d(t,"c",(function(){return u})),i.d(t,"a",(function(){return r}));var s=i(0),n=i.n(s);let a,r;!function(e){e._ID="_id",e._INDEX="_index",e._SOURCE="_source",e._TYPE="_type",e.STRING="string",e.TEXT="text",e.MATCH_ONLY_TEXT="match_only_text",e.KEYWORD="keyword",e.VERSION="version",e.BOOLEAN="boolean",e.OBJECT="object",e.DATE="date",e.DATE_NANOS="date_nanos",e.DATE_RANGE="date_range",e.GEO_POINT="geo_point",e.GEO_SHAPE="geo_shape",e.FLOAT="float",e.HALF_FLOAT="half_float",e.SCALED_FLOAT="scaled_float",e.DOUBLE="double",e.INTEGER="integer",e.LONG="long",e.SHORT="short",e.UNSIGNED_LONG="unsigned_long",e.AGGREGATE_METRIC_DOUBLE="aggregate_metric_double",e.FLOAT_RANGE="float_range",e.DOUBLE_RANGE="double_range",e.INTEGER_RANGE="integer_range",e.LONG_RANGE="long_range",e.NESTED="nested",e.BYTE="byte",e.IP="ip",e.IP_RANGE="ip_range",e.ATTACHMENT="attachment",e.TOKEN_COUNT="token_count",e.MURMUR3="murmur3",e.HISTOGRAM="histogram"}(a||(a={})),function(e){e._SOURCE="_source",e.ATTACHMENT="attachment",e.BOOLEAN="boolean",e.DATE="date",e.DATE_RANGE="date_range",e.GEO_POINT="geo_point",e.GEO_SHAPE="geo_shape",e.IP="ip",e.IP_RANGE="ip_range",e.MURMUR3="murmur3",e.NUMBER="number",e.NUMBER_RANGE="number_range",e.STRING="string",e.UNKNOWN="unknown",e.CONFLICT="conflict",e.OBJECT="object",e.NESTED="nested",e.HISTOGRAM="histogram",e.MISSING="missing"}(r||(r={}));class kbn_field_type_KbnFieldType{constructor(e={}){n()(this,"name",void 0),n()(this,"sortable",void 0),n()(this,"filterable",void 0),n()(this,"esTypes",void 0),this.name=e.name||r.UNKNOWN,this.sortable=e.sortable||!1,this.filterable=e.filterable||!1,this.esTypes=Object.freeze((e.esTypes||[]).slice())}}const o=new kbn_field_type_KbnFieldType({name:r.UNKNOWN}),d=[new kbn_field_type_KbnFieldType({name:r.STRING,sortable:!0,filterable:!0,esTypes:[a.STRING,a.TEXT,a.MATCH_ONLY_TEXT,a.KEYWORD,a.VERSION,a._TYPE,a._ID]}),new kbn_field_type_KbnFieldType({name:r.NUMBER,sortable:!0,filterable:!0,esTypes:[a.FLOAT,a.HALF_FLOAT,a.SCALED_FLOAT,a.DOUBLE,a.INTEGER,a.LONG,a.UNSIGNED_LONG,a.SHORT,a.BYTE,a.TOKEN_COUNT,a.AGGREGATE_METRIC_DOUBLE]}),new kbn_field_type_KbnFieldType({name:r.NUMBER_RANGE,sortable:!0,filterable:!0,esTypes:[a.FLOAT_RANGE,a.DOUBLE_RANGE,a.INTEGER_RANGE,a.LONG_RANGE]}),new kbn_field_type_KbnFieldType({name:r.DATE,sortable:!0,filterable:!0,esTypes:[a.DATE,a.DATE_NANOS]}),new kbn_field_type_KbnFieldType({name:r.DATE_RANGE,sortable:!0,filterable:!0,esTypes:[a.DATE_RANGE]}),new kbn_field_type_KbnFieldType({name:r.IP,sortable:!0,filterable:!0,esTypes:[a.IP]}),new kbn_field_type_KbnFieldType({name:r.IP_RANGE,sortable:!0,filterable:!0,esTypes:[a.IP_RANGE]}),new kbn_field_type_KbnFieldType({name:r.BOOLEAN,sortable:!0,filterable:!0,esTypes:[a.BOOLEAN]}),new kbn_field_type_KbnFieldType({name:r.OBJECT,esTypes:[a.OBJECT]}),new kbn_field_type_KbnFieldType({name:r.NESTED,esTypes:[a.NESTED]}),new kbn_field_type_KbnFieldType({name:r.GEO_POINT,esTypes:[a.GEO_POINT]}),new kbn_field_type_KbnFieldType({name:r.GEO_SHAPE,esTypes:[a.GEO_SHAPE]}),new kbn_field_type_KbnFieldType({name:r.ATTACHMENT,esTypes:[a.ATTACHMENT]}),new kbn_field_type_KbnFieldType({name:r.MURMUR3,esTypes:[a.MURMUR3]}),new kbn_field_type_KbnFieldType({name:r._SOURCE,esTypes:[a._SOURCE]}),new kbn_field_type_KbnFieldType({name:r.HISTOGRAM,filterable:!0,esTypes:[a.HISTOGRAM]}),new kbn_field_type_KbnFieldType({name:r.CONFLICT}),o],l=e=>d.find((t=>t.name===e))||o,c=e=>{const t=d.find((t=>t.esTypes.includes(e)));return t&&t.name?t.name:r.UNKNOWN},u=()=>d.filter((e=>e.filterable)).map((e=>e.name))},function(e,t,i){"use strict";i.d(t,"e",(function(){return a})),i.d(t,"g",(function(){return r})),i.d(t,"f",(function(){return o})),i.d(t,"c",(function(){return d})),i.d(t,"d",(function(){return l})),i.d(t,"b",(function(){return v})),i.d(t,"a",(function(){return data_view_field_DataViewField}));var s=i(5);const n=Object(s.c)();function a(e){return"_id"===e.name||e.scripted||Boolean(e.searchable&&n.includes(e.type))}const r=u,o=p,d=f,l=h,c=/(.).+?\./g;function u(e){var t;const i=null==e?void 0:e.subType;return!(null==i||null===(t=i.nested)||void 0===t||!t.path)}function h(e){return u(e)?e.subType:void 0}function p(e){var t;const i=null==e?void 0:e.subType;return!(null==i||null===(t=i.multi)||void 0===t||!t.parent)}function f(e){return p(e)?e.subType:void 0}var m=i(0),g=i.n(m),b=i(1);class data_view_field_DataViewField{constructor(e){g()(this,"spec",void 0),g()(this,"kbnFieldType",void 0),this.spec={...e,type:"_source"===e.name?"_source":e.type},this.kbnFieldType=Object(s.d)(e.type)}get count(){return this.spec.count||0}set count(e){this.spec.count=e}get runtimeField(){return this.spec.runtimeField}set runtimeField(e){this.spec.runtimeField=e}get script(){return this.spec.script}set script(e){this.spec.script=e}get lang(){return this.spec.lang}set lang(e){this.spec.lang=e}get customLabel(){return this.spec.customLabel}set customLabel(e){this.spec.customLabel=e}get conflictDescriptions(){return this.spec.conflictDescriptions}set conflictDescriptions(e){this.spec.conflictDescriptions=e}get name(){return this.spec.name}get displayName(){return this.spec.customLabel?this.spec.customLabel:this.spec.shortDotsEnable?"string"!=typeof(e=this.spec.name)?e:e.replace(c,"$1."):this.spec.name;var e}get type(){return this.spec.type}get esTypes(){return this.spec.esTypes}get scripted(){return!!this.spec.scripted}get searchable(){return!(!this.spec.searchable&&!this.scripted)}get aggregatable(){return!(!this.spec.aggregatable&&!this.scripted)}get timeSeriesDimension(){return this.spec.timeSeriesDimension||!1}get timeSeriesMetric(){return this.spec.timeSeriesMetric}get fixedInterval(){return this.spec.fixedInterval}get isRolledUpField(){var e;return null===(e=this.esTypes)||void 0===e?void 0:e.includes("aggregate_metric_double")}get timeZone(){return this.spec.timeZone}get readFromDocValues(){return!(!this.spec.readFromDocValues||this.scripted)}get subType(){return this.spec.subType}get isMapped(){return this.spec.isMapped}get isRuntimeField(){return!this.isMapped&&void 0!==this.runtimeField}get sortable(){return"_score"===this.name||(this.spec.indexed||this.aggregatable)&&this.kbnFieldType.sortable}get filterable(){return"_id"===this.name||this.scripted||(this.spec.indexed||this.searchable)&&this.kbnFieldType.filterable}get visualizable(){const e=[s.a.UNKNOWN,s.a.CONFLICT];return this.aggregatable&&!e.includes(this.spec.type)}isSubtypeNested(){return u(this)}isSubtypeMulti(){return p(this)}getSubtypeNested(){return h(this)}getSubtypeMulti(){return f(this)}deleteCount(){delete this.spec.count}toJSON(){return{count:this.count,script:this.script,lang:this.lang,conflictDescriptions:this.conflictDescriptions,name:this.name,type:this.type,esTypes:this.esTypes,scripted:this.scripted,searchable:this.searchable,aggregatable:this.aggregatable,readFromDocValues:this.readFromDocValues,subType:this.subType,customLabel:this.customLabel}}toSpec(e={}){const{getFormatterForField:t}=e,i={count:this.count,script:this.script,lang:this.lang,conflictDescriptions:this.conflictDescriptions,name:this.name,type:this.type,esTypes:this.esTypes,scripted:this.scripted,searchable:this.searchable,aggregatable:this.aggregatable,readFromDocValues:this.readFromDocValues,subType:this.subType,format:t?t(this).toJSON():void 0,customLabel:this.customLabel,shortDotsEnable:this.spec.shortDotsEnable,runtimeField:this.runtimeField,isMapped:this.isMapped,timeSeriesDimension:this.spec.timeSeriesDimension,timeSeriesMetric:this.spec.timeSeriesMetric,timeZone:this.spec.timeZone,fixedInterval:this.spec.fixedInterval};return Object.fromEntries(Object.entries(i).filter((([,e])=>void 0!==e)))}isRuntimeCompositeSubField(){var e;return"composite"===(null===(e=this.runtimeField)||void 0===e?void 0:e.type)}}const v=(e=[],t=!1)=>new class FldList extends Array{constructor(){super(),g()(this,"byName",new Map),g()(this,"groups",new Map),g()(this,"setByName",(e=>this.byName.set(e.name,e))),g()(this,"setByGroup",(e=>{void 0===this.groups.get(e.type)&&this.groups.set(e.type,new Map),this.groups.get(e.type).set(e.name,e)})),g()(this,"removeByGroup",(e=>{var t;return null===(t=this.groups.get(e.type))||void 0===t?void 0:t.delete(e.name)})),g()(this,"getAll",(()=>[...this.byName.values()])),g()(this,"getByName",(e=>this.byName.get(e))),g()(this,"getByType",(e=>[...(this.groups.get(e)||new Map).values()])),g()(this,"add",(e=>{const i=new data_view_field_DataViewField({...e,shortDotsEnable:t});return this.push(i),this.setByName(i),this.setByGroup(i),i})),g()(this,"remove",(e=>{this.removeByGroup(e),this.byName.delete(e.name);const t=Object(b.findIndex)(this,{name:e.name});this.splice(t,1)})),g()(this,"update",(e=>{const t=new data_view_field_DataViewField(e),i=this.findIndex((e=>e.name===t.name));this.splice(i,1,t),this.setByName(t),this.removeByGroup(t),this.setByGroup(t)})),g()(this,"removeAll",(()=>{this.length=0,this.byName.clear(),this.groups.clear()})),g()(this,"replaceAll",((e=[])=>{this.removeAll(),e.forEach(this.add)})),e.map((e=>this.add(e)))}toSpec({getFormatterForField:e}={}){return{...this.reduce(((t,i)=>(t[i.name]=i.toSpec({getFormatterForField:e}),t)),{})}}}},function(e,t){e.exports=__kbnSharedDeps__.KbnI18n},function(e,t,i){"use strict";i.d(t,"e",(function(){return s})),i.d(t,"b",(function(){return n})),i.d(t,"d",(function(){return a})),i.d(t,"a",(function(){return r})),i.d(t,"c",(function(){return o}));const s=["keyword","long","double","date","ip","boolean","geo_point","composite"],n={DATA_STREAMS_TO_IGNORE:["logs-enterprise_search.api-default","logs-enterprise_search.audit-default"]},a="metaFields",r="index-pattern",o="/internal/data_views/_fields_for_wildcard"},function(e,t,i){"use strict";i.d(t,"b",(function(){return n}));var s=i(2);i.d(t,"a",(function(){return s.DATA_VIEW_SAVED_OBJECT_TYPE}));const n=1},function(e,t,i){"use strict";function s(){const e={};return{get:t=>e[t],set:(t,i)=>(e[t]=i,i),clear:t=>{delete e[t]},clearAll:()=>{for(const t in e)e.hasOwnProperty(t)&&delete e[t]}}}i.d(t,"d",(function(){return s})),i.d(t,"a",(function(){return data_view_DataView})),i.d(t,"c",(function(){return data_views_DataViewsService})),i.d(t,"b",(function(){return _}));var n=i(1),a=i.n(n);var r=i(0),o=i.n(r),d=i(5),l=i(12),c=i(6),u=i(11),h=i(13);const p=e=>{const{type:t,script:i,fields:s}=e;return{type:t,script:i,...s&&{fields:Object.entries(s).reduce(((e,[t,i])=>(e[t]={type:i.type},e)),{})}}};class data_view_DataView{constructor(e){o()(this,"id",void 0),o()(this,"title",""),o()(this,"fieldFormatMap",void 0),o()(this,"typeMeta",void 0),o()(this,"fields",void 0),o()(this,"timeFieldName",void 0),o()(this,"type",void 0),o()(this,"flattenHit",void 0),o()(this,"metaFields",void 0),o()(this,"version",void 0),o()(this,"sourceFilters",void 0),o()(this,"namespaces",void 0),o()(this,"originalSavedObjectBody",{}),o()(this,"shortDotsEnable",!1),o()(this,"fieldFormats",void 0),o()(this,"fieldAttrs",void 0),o()(this,"runtimeFieldMap",void 0),o()(this,"allowNoIndex",!1),o()(this,"name",""),o()(this,"matchedIndices",[]),o()(this,"getName",(()=>this.name?this.name:this.title)),o()(this,"getIndexPattern",(()=>this.title)),o()(this,"setIndexPattern",(e=>{this.title=e})),o()(this,"getOriginalSavedObjectBody",(()=>({...this.originalSavedObjectBody}))),o()(this,"resetOriginalSavedObjectBody",(()=>{this.originalSavedObjectBody=this.getAsSavedObjectBody()})),o()(this,"getFieldAttrs",(()=>{const e={...this.fieldAttrs};return this.fields.forEach((t=>{const i={};let s=!1;t.customLabel&&(i.customLabel=t.customLabel,s=!0),t.count&&(i.count=t.count,s=!0),s?e[t.name]=i:delete e[t.name]})),e})),o()(this,"setFieldFormat",((e,t)=>{this.fieldFormatMap[e]=t})),o()(this,"deleteFieldFormat",(e=>{delete this.fieldFormatMap[e]}));const{spec:t={},fieldFormats:i,shortDotsEnable:s=!1,metaFields:r=[]}=e;this.fieldFormats={...i},this.shortDotsEnable=s,this.metaFields=r,this.fields=Object(c.b)([],this.shortDotsEnable),this.flattenHit=function(e,t={},i=new WeakMap){return function(s,n=!1){const r=function(e,t){return function(i){return a.a.each(t,(function(t){"_source"!==t&&(i[t]=e[t])})),a.a.forOwn(e.fields,(function(e,t){Array.isArray(e)&&e.length<=1?i[t]=e[0]:i[t]=e})),new Proxy(i,{ownKeys:e=>Reflect.ownKeys(e).sort(((e,i)=>{const s=a.a.includes(t,e),n=a.a.includes(t,i);return s&&n?String(e).localeCompare(String(i)):s?1:n?-1:String(e).localeCompare(String(i))}))})}}(s,t),o=i.get(s),d=o||function(e,t,i){const s={},n=e.fields.getByName;return function e(t,r=""){r=r?r+".":"",a.a.forOwn(t,(function(t,o){if(o=r+o,i){const i=n(o),s=i&&"nested"===i.type;if(Array.isArray(t)&&a.a.isPlainObject(a.a.first(t))&&!s)return void a.a.each(t,(t=>e(t,o)))}else if(void 0!==s[o])return;const d=n(o),l=d&&"conflict"!==d.type,c=!a.a.isPlainObject(t);l||c?s[o]?Array.isArray(s[o])?s[o].push(t):s[o]=[s[o],t]:s[o]=t:e(t,o)}))}(t._source),s}(e,s,n);return o||i.set(s,{...d}),r(d)}}(this,r),this.id=t.id,this.fieldFormatMap={...t.fieldFormats},this.version=t.version,this.title=t.title||"",this.timeFieldName=t.timeFieldName,this.sourceFilters=[...t.sourceFilters||[]],this.fields.replaceAll(Object.values(t.fields||{})),this.type=t.type,this.typeMeta=t.typeMeta,this.fieldAttrs=Object(n.cloneDeep)(t.fieldAttrs)||{},this.allowNoIndex=t.allowNoIndex||!1,this.runtimeFieldMap=Object(n.cloneDeep)(t.runtimeFieldMap)||{},this.namespaces=t.namespaces||[],this.name=t.name||""}getComputedFields(){const e={};if(!this.fields)return{storedFields:["*"],scriptFields:e,docvalueFields:[],runtimeFields:{}};const t=Object(n.reject)(this.fields.getByType("date"),"scripted").map((e=>({field:e.name,format:e.esTypes&&-1!==e.esTypes.indexOf("date_nanos")?"strict_date_time":"date_time"})));Object(n.each)(this.getScriptedFields(),(function(t){e[t.name]={script:{source:t.script,lang:t.lang}}}));const i=this.getRuntimeMappings();return{storedFields:["*"],scriptFields:e,docvalueFields:t,runtimeFields:i}}isPersisted(){return"string"==typeof this.version}toSpec(e=!0){const t=e&&this.fields?this.fields.toSpec({getFormatterForField:this.getFormatterForField.bind(this)}):void 0,i={id:this.id,version:this.version,title:this.getIndexPattern(),timeFieldName:this.timeFieldName,sourceFilters:[...this.sourceFilters||[]],fields:t,typeMeta:this.typeMeta,type:this.type,fieldFormats:{...this.fieldFormatMap},runtimeFieldMap:Object(n.cloneDeep)(this.runtimeFieldMap),fieldAttrs:Object(n.cloneDeep)(this.fieldAttrs),allowNoIndex:this.allowNoIndex,name:this.name};return Object.fromEntries(Object.entries(i).filter((([,e])=>void 0!==e)))}toMinimalSpec(){const e=this.toSpec(!1);return e.fieldAttrs&&(e.fieldAttrs=Object(n.pickBy)(Object(n.mapValues)(e.fieldAttrs,(e=>Object(n.omit)(e,"count"))),(e=>Object.keys(e).length>0)),0===Object.keys(e.fieldAttrs).length&&(e.fieldAttrs=void 0)),e}getSourceFiltering(){return{excludes:this.sourceFilters&&this.sourceFilters.map((e=>e.value))||[]}}removeScriptedField(e){const t=this.fields.getByName(e);t&&this.fields.remove(t)}getNonScriptedFields(){return[...this.fields.getAll().filter((e=>!e.scripted))]}getScriptedFields(){return[...this.fields.getAll().filter((e=>e.scripted))]}isTSDBMode(){return this.fields.some((e=>e.timeSeriesDimension||e.timeSeriesMetric))}isTimeBased(){return!(!this.timeFieldName||this.fields&&!this.getTimeField())}isTimeNanosBased(){const e=this.getTimeField();return!(!e||!e.esTypes||-1===e.esTypes.indexOf("date_nanos"))}getTimeField(){if(this.timeFieldName&&this.fields&&this.fields.getByName)return this.fields.getByName(this.timeFieldName)}getFieldByName(e){if(this.fields&&this.fields.getByName)return this.fields.getByName(e)}getAggregationRestrictions(){var e;return null===(e=this.typeMeta)||void 0===e?void 0:e.aggs}getAsSavedObjectBody(){var e,t,i;const s=this.getFieldAttrs(),n=this.runtimeFieldMap;return{fieldAttrs:s?JSON.stringify(s):void 0,title:this.getIndexPattern(),timeFieldName:this.timeFieldName,sourceFilters:this.sourceFilters?JSON.stringify(this.sourceFilters):void 0,fields:JSON.stringify(null!==(e=null===(t=this.fields)||void 0===t?void 0:t.filter((e=>e.scripted)))&&void 0!==e?e:[]),fieldFormatMap:this.fieldFormatMap?JSON.stringify(this.fieldFormatMap):void 0,type:this.type,typeMeta:JSON.stringify(null!==(i=this.typeMeta)&&void 0!==i?i:{}),allowNoIndex:this.allowNoIndex?this.allowNoIndex:void 0,runtimeFieldMap:n?JSON.stringify(n):void 0,name:this.name}}getFormatterForField(e){return this.getFormatterForFieldNoDefault(e.name)||this.fieldFormats.getDefaultInstance(e.type,e.esTypes)}addRuntimeField(e,t){if(e.includes("*"))throw new l.CharacterNotAllowedInField("*",e);const{type:i,script:s,customLabel:n,format:a,popularity:r}=t;return"composite"===i?this.addCompositeRuntimeField(e,t):(this.runtimeFieldMap[e]=p(t),[this.updateOrAddRuntimeField(e,i,{type:i,script:s},{customLabel:n,format:a,popularity:r})])}hasRuntimeField(e){return!!this.runtimeFieldMap[e]}getRuntimeField(e){if(!this.runtimeFieldMap[e])return null;const{type:t,script:i,fields:s}={...this.runtimeFieldMap[e]},n={type:t,script:i};return"composite"===t&&(n.fields=s),n}getAllRuntimeFields(){return Object.keys(this.runtimeFieldMap).reduce(((e,t)=>({...e,[t]:this.getRuntimeField(t)})),{})}getFieldsByRuntimeFieldName(e){const t=this.getRuntimeField(e);if(!t)return;if("composite"===t.type)return Object.entries(t.fields).reduce(((t,[i,s])=>{const n=`${e}.${i}`,a=this.getFieldByName(n);return a?(t[i]=a,t):t}),{});const i=this.getFieldByName(e);return i&&{[e]:i}}replaceAllRuntimeFields(e){Object.keys(this.runtimeFieldMap).forEach((e=>{this.removeRuntimeField(e)})),Object.entries(e).forEach((([e,t])=>{this.addRuntimeField(e,t)}))}removeRuntimeField(e){const t=this.getFieldByName(e);t&&t.isMapped?t.runtimeField=void 0:Object.values(this.getFieldsByRuntimeFieldName(e)||{}).forEach((e=>{this.fields.remove(e)})),delete this.runtimeFieldMap[e]}getRuntimeMappings(){const e=this.getMappedFieldNames();return Object.keys(this.runtimeFieldMap).reduce(((t,i)=>(e.includes(i)||(t[i]=this.runtimeFieldMap[i]),t)),{})}getFormatterForFieldNoDefault(e){const t=this.fieldFormatMap[e];if(null!=t&&t.id)return this.fieldFormats.getInstance(t.id,t.params)}setFieldAttrs(e,t,i){this.fieldAttrs[e]||(this.fieldAttrs[e]={}),this.fieldAttrs[e][t]=i}setFieldCustomLabel(e,t){const i=this.fields.getByName(e),s=null===t?void 0:t;i&&(i.customLabel=s),this.setFieldAttrs(e,"customLabel",s)}setFieldCount(e,t){const i=this.fields.getByName(e),s=null===t?void 0:t;i&&(s?i.count=s:i.deleteCount()),this.setFieldAttrs(e,"count",s)}getMappedFieldNames(){return this.fields.getAll().reduce(((e,t)=>(t.isMapped&&e.push(t.name),e)),[])}addCompositeRuntimeField(e,t){const{fields:i}=t;if(void 0===i||0===Object.keys(i).length)throw new Error(`Can't add composite runtime field [name = ${e}] without subfields.`);if(void 0!==this.getFieldByName(e))throw new Error(`Can't create composite runtime field ["${e}"] as there is already a field with this name`);this.removeRuntimeField(e);const s=p(t),n=Object.entries(i).map((([t,i])=>this.updateOrAddRuntimeField(`${e}.${t}`,i.type,s,{customLabel:i.customLabel,format:i.format,popularity:i.popularity})));return this.runtimeFieldMap[e]=p(t),n}updateOrAddRuntimeField(e,t,i,s){var n;if("composite"===t)throw new Error(`Trying to add composite field as primmitive field, this shouldn't happen! [name = ${e}]`);let a;const r=this.getFieldByName(e);var o;return r?r.runtimeField=i:a=this.fields.add({name:e,runtimeField:i,type:Object(d.b)(t),esTypes:[t],aggregatable:!0,searchable:!0,count:null!==(o=s.popularity)&&void 0!==o?o:0,readFromDocValues:!1}),(s.customLabel||null===s.customLabel)&&this.setFieldCustomLabel(e,s.customLabel),(s.popularity||null===s.popularity)&&this.setFieldCount(e,s.popularity),s.format?this.setFieldFormat(e,s.format):null===s.format&&this.deleteFieldFormat(e),null!==(n=a)&&void 0!==n?n:r}}var f=i(7),m=i(17),g=i(18),b=i(2),v=i(3),y=i(4);class data_views_DataViewsService{constructor(e){o()(this,"config",void 0),o()(this,"savedObjectsClient",void 0),o()(this,"savedObjectsCache",void 0),o()(this,"apiClient",void 0),o()(this,"fieldFormats",void 0),o()(this,"onNotification",void 0),o()(this,"onError",void 0),o()(this,"dataViewCache",void 0),o()(this,"getCanSaveAdvancedSettings",void 0),o()(this,"getCanSave",void 0),o()(this,"getIds",(async(e=!1)=>(this.savedObjectsCache&&!e||await this.refreshSavedObjectsCache(),this.savedObjectsCache?this.savedObjectsCache.map((e=>null==e?void 0:e.id)):[]))),o()(this,"getTitles",(async(e=!1)=>(this.savedObjectsCache&&!e||await this.refreshSavedObjectsCache(),this.savedObjectsCache?this.savedObjectsCache.map((e=>{var t;return null==e||null===(t=e.attributes)||void 0===t?void 0:t.title})):[]))),o()(this,"find",(async(e,t=10)=>{const i=(await this.savedObjectsClient.find({fields:["title"],search:e,searchFields:["title","name"],perPage:t})).map((async e=>await this.get(e.id)));return await Promise.all(i)})),o()(this,"getIdsWithTitle",(async(e=!1)=>(this.savedObjectsCache&&!e||await this.refreshSavedObjectsCache(),this.savedObjectsCache?this.savedObjectsCache.map((e=>{var t,i,s,n,a;return{id:null==e?void 0:e.id,namespaces:null==e?void 0:e.namespaces,title:null==e||null===(t=e.attributes)||void 0===t?void 0:t.title,type:null==e||null===(i=e.attributes)||void 0===i?void 0:i.type,typeMeta:(null==e||null===(s=e.attributes)||void 0===s?void 0:s.typeMeta)&&JSON.parse(null==e||null===(n=e.attributes)||void 0===n?void 0:n.typeMeta),name:null==e||null===(a=e.attributes)||void 0===a?void 0:a.name}})):[]))),o()(this,"clearCache",(()=>{this.savedObjectsCache=null})),o()(this,"clearInstanceCache",(e=>{e?this.dataViewCache.clear(e):this.dataViewCache.clearAll()})),o()(this,"getCache",(async()=>(this.savedObjectsCache||await this.refreshSavedObjectsCache(),this.savedObjectsCache))),o()(this,"getDefault",(async(e=!0)=>{const t=await this.getDefaultId();return t?await this.get(t,e):null})),o()(this,"getDefaultId",(async()=>{const e=await this.config.get("defaultIndex");return null!=e?e:null})),o()(this,"setDefault",(async(e,t=!1)=>{!t&&await this.config.get("defaultIndex")||await this.config.set("defaultIndex",e)})),o()(this,"getFieldsForWildcard",(async e=>{const t=await this.config.get(b.META_FIELDS),{fields:i}=await this.apiClient.getFieldsForWildcard({...e,metaFields:t});return i})),o()(this,"getExistingIndices",(async e=>{const t=e.map((e=>{const t=e.trim().startsWith("-")?e.trim().substring(1):e.trim();return Object(u.defer)((()=>Object(u.from)(this.getFieldsForWildcard({fields:["_id"],allowNoIndex:!0,pattern:t}))))}));return new Promise((e=>{(function(e,t=3,i){return Object(u.from)(e).pipe(Object(h.mergeMap)(((e,t)=>e.pipe(Object(h.last)(),Object(h.map)((e=>({index:t,value:e}))),Object(u.catchError)((()=>Object(u.of)({index:t,value:i}))))),t),Object(h.toArray)(),Object(h.map)((e=>e.sort(((e,t)=>e.index-t.index)).map((e=>e.value)))))})(t,3,[]).subscribe((t=>{e(t.map((e=>e.length>0)))}))})).then((t=>e.filter(((e,i,s)=>s.indexOf(e)===i&&t[i])))).catch((()=>e))})),o()(this,"getFieldsForIndexPattern",(async(e,t)=>{var i,s;return this.getFieldsForWildcard({type:e.type,rollupIndex:null==e||null===(i=e.typeMeta)||void 0===i||null===(s=i.params)||void 0===s?void 0:s.rollup_index,allowNoIndex:!0,...t,pattern:e.title})})),o()(this,"getFieldsAndIndicesForDataView",(async e=>{var t,i;const s=await this.config.get(b.META_FIELDS);return this.apiClient.getFieldsForWildcard({type:e.type,rollupIndex:null==e||null===(t=e.typeMeta)||void 0===t||null===(i=t.params)||void 0===i?void 0:i.rollup_index,allowNoIndex:!0,pattern:e.getIndexPattern(),metaFields:s})})),o()(this,"getFieldsAndIndicesForWildcard",(async e=>{const t=await this.config.get(b.META_FIELDS);return this.apiClient.getFieldsForWildcard({pattern:e.pattern,metaFields:t,type:e.type,rollupIndex:e.rollupIndex,allowNoIndex:!0,indexFilter:e.indexFilter})})),o()(this,"refreshFieldsFn",(async e=>{const{fields:t,indices:i}=await this.getFieldsAndIndicesForDataView(e);t.forEach((e=>e.isMapped=!0));const s=e.getScriptedFields().map((e=>e.spec)),n=e.getFieldAttrs(),a=Object.values(this.fieldArrayToMap([...t,...s],n)),r=this.getRuntimeFields(e.getRuntimeMappings(),e.getFieldAttrs()),o=Object.values(r).filter((e=>!a.find((t=>t.name===e.name))));e.fields.replaceAll([...o,...a]),e.matchedIndices=i})),o()(this,"refreshFields",(async(e,t=!0)=>{if(!t)return this.refreshFieldsFn(e);try{await this.refreshFieldsFn(e)}catch(t){t instanceof v.b||this.onError(t,{title:f.i18n.translate("dataViews.fetchFieldErrorTitle",{defaultMessage:"Error fetching fields for data view {title} (ID: {id})",values:{id:e.id,title:e.getIndexPattern()}})},e.getIndexPattern())}})),o()(this,"refreshFieldSpecMap",(async(e,t,i,s,n={},a=!0)=>{const r=Object.values(e),o=r.filter((e=>e.scripted));try{let e;const{fields:t,indices:i}=await this.getFieldsAndIndicesForWildcard(s);return t.forEach((e=>e.isMapped=!0)),e=!s.allowNoIndex||t&&t.length>5?[...t,...o]:r,{fields:this.fieldArrayToMap(e,n),indices:i}}catch(e){if(e instanceof v.b)return{};if(!a)throw e;throw this.onError(e,{title:f.i18n.translate("dataViews.fetchFieldErrorTitle",{defaultMessage:"Error fetching fields for data view {title} (ID: {id})",values:{id:t,title:i}})},i),e}})),o()(this,"fieldArrayToMap",((e,t)=>e.reduce(((e,i)=>{var s,n;return e[i.name]={...i,customLabel:null==t||null===(s=t[i.name])||void 0===s?void 0:s.customLabel,count:null==t||null===(n=t[i.name])||void 0===n?void 0:n.count},e}),{}))),o()(this,"savedObjectToSpec",(e=>{const{id:t,version:i,namespaces:s,attributes:{title:n,timeFieldName:a,fields:r,sourceFilters:o,fieldFormatMap:d,runtimeFieldMap:l,typeMeta:c,type:u,fieldAttrs:h,allowNoIndex:p,name:f}}=e,m=o?JSON.parse(o):void 0,g=c?JSON.parse(c):void 0,b=d?JSON.parse(d):{},v=r?JSON.parse(r):[],y=h?JSON.parse(h):{},_=l?JSON.parse(l):{};return{id:t,version:i,namespaces:s,title:n,timeFieldName:a,sourceFilters:m,fields:this.fieldArrayToMap(v,y),typeMeta:g,type:u,fieldFormats:b,fieldAttrs:y,allowNoIndex:p,runtimeFieldMap:_,name:f}})),o()(this,"getSavedObjectAndInit",(async(e,t=!0)=>{const i=await this.savedObjectsClient.get(e);return this.initFromSavedObject(i,t)})),o()(this,"initFromSavedObjectLoadFields",(async({savedObjectId:e,spec:t,displayErrors:i=!0})=>{var s;const{title:n,type:a,typeMeta:r,runtimeFieldMap:o}=t,{fields:d,indices:l}=await this.refreshFieldSpecMap(t.fields||{},e,t.title,{pattern:n,metaFields:await this.config.get(b.META_FIELDS),type:a,rollupIndex:null==r||null===(s=r.params)||void 0===s?void 0:s.rollup_index,allowNoIndex:t.allowNoIndex},t.fieldAttrs,i);return{fields:{...this.getRuntimeFields(o,t.fieldAttrs),...d},indices:l||[]}})),o()(this,"initFromSavedObject",(async(e,t=!0)=>{const i=this.savedObjectToSpec(e);i.fieldAttrs=e.attributes.fieldAttrs?JSON.parse(e.attributes.fieldAttrs):{};let s={},n=[];if(t)try{const a=await this.initFromSavedObjectLoadFields({savedObjectId:e.id,spec:i,displayErrors:t});s=a.fields,n=a.indices}catch(t){t instanceof v.b||this.onError(t,{title:f.i18n.translate("dataViews.fetchFieldErrorTitle",{defaultMessage:"Error fetching fields for data view {title} (ID: {id})",values:{id:e.id,title:i.title}})},i.title||"")}else{const a=await this.initFromSavedObjectLoadFields({savedObjectId:e.id,spec:i,displayErrors:t});s=a.fields,n=a.indices}i.fields=s,i.fieldFormats=e.attributes.fieldFormatMap?JSON.parse(e.attributes.fieldFormatMap):{};const a=await this.createFromSpec(i,!0,t);return a.matchedIndices=n,a.resetOriginalSavedObjectBody(),a})),o()(this,"getRuntimeFields",((e={},t={})=>{const i={},s=(e,s,n,a)=>{var r,o;i[e]={name:e,type:Object(d.b)(s),esTypes:[s],runtimeField:n,aggregatable:!0,searchable:!0,readFromDocValues:!1,customLabel:null==t||null===(r=t[e])||void 0===r?void 0:r.customLabel,count:null==t||null===(o=t[e])||void 0===o?void 0:o.count},a&&(i[e].parentName=a)};for(const[t,i]of Object.entries(e||{}))"composite"===i.type?Object.entries(i.fields).forEach((([e,n])=>{s(`${t}.${e}`,n.type,i,t)})):s(t,i.type,i);return i})),o()(this,"get",(async(e,t=!0,i=!1)=>{var s;const n=(null===(s=this.dataViewCache.get(e))||void 0===s?void 0:s.then((async e=>(e&&i&&await this.refreshFields(e,t),e))))||this.dataViewCache.set(e,this.getSavedObjectAndInit(e,t));return n.catch((()=>{this.dataViewCache.clear(e)})),n}));const{uiSettings:t,savedObjectsClient:i,apiClient:n,fieldFormats:a,onNotification:r,onError:l,getCanSave:c=(()=>Promise.resolve(!1)),getCanSaveAdvancedSettings:p}=e;this.apiClient=n,this.config=t,this.savedObjectsClient=i,this.fieldFormats=a,this.onNotification=r,this.onError=l,this.getCanSave=c,this.getCanSaveAdvancedSettings=p,this.dataViewCache=s()}async refreshSavedObjectsCache(){const e=await this.savedObjectsClient.find({fields:["title","type","typeMeta","name"],perPage:1e4});this.savedObjectsCache=e}async hasUserDataView(){return this.apiClient.hasUserDataView()}async createFromSpec({id:e,name:t,title:i,...s},n=!1,a=!0){const r=await this.config.get(m.FORMATS_UI_SETTINGS.SHORT_DOTS_ENABLE),o=await this.config.get(b.META_FIELDS),d={id:null!=e?e:Object(g.v4)(),title:i,name:t||i,...s},l=new data_view_DataView({spec:d,fieldFormats:this.fieldFormats,shortDotsEnable:r,metaFields:o});return n||await this.refreshFields(l,a),l}async create(e,t=!1,i=!0){const s=()=>this.createFromSpec(e,t,i);if(e.id){return this.dataViewCache.get(e.id)||this.dataViewCache.set(e.id,s())}const n=await s();return this.dataViewCache.set(n.id,Promise.resolve(n))}async createAndSave(e,t=!1,i=!1,s=!0){const n=await this.createFromSpec(e,i,s),a=await this.createSavedObject(n,t,s);return await this.setDefault(a.id),a}async createSavedObject(e,t=!1,i=!0){if(!await this.getCanSave())throw new y.a;const s=await async function(e,t){if(t){const i=await e.find({perPage:10,search:`"${t}"`,searchFields:["name.keyword"],fields:["name"]});return i?i[0]:void 0}}(this.savedObjectsClient,e.getName());if(s){if(!t)throw new y.c(`Duplicate data view: ${e.getName()}`);await this.delete(s.id)}const n=e.getAsSavedObjectBody(),a=await this.savedObjectsClient.create(n,{id:e.id,initialNamespaces:e.namespaces.length>0?e.namespaces:void 0,overwrite:t}),r=await this.initFromSavedObject(a,i);return this.savedObjectsCache&&this.savedObjectsCache.push(a),r}async updateSavedObject(e,t=0,i=!1,s=!0){if(!e.id)return;if(!await this.getCanSave())throw new y.a(e.id);const n=e.getAsSavedObjectBody(),a=e.getOriginalSavedObjectBody(),r=[];return Object.entries(n).forEach((([e,t])=>{t!==a[e]&&r.push(e)})),this.savedObjectsClient.update(e.id,n,{version:e.version}).then((t=>(e.id=t.id,e.version=t.version,e))).catch((async o=>{var d;if(409===(null==o||null===(d=o.response)||void 0===d?void 0:d.status)&&t++<3){const d=await this.get(e.id,s),l=d.getAsSavedObjectBody(),c=[];Object.entries(l).forEach((([e,t])=>{const i=e;t!==n[i]&&t!==a[i]&&c.push(e)}));let u=!1;for(const e of r)for(const t of c)if(e===t){u=!0;break}if(u){if(i)return;const t=f.i18n.translate("dataViews.unableWriteLabel",{defaultMessage:"Unable to write data view! Refresh the page to get the most up to date changes for this data view."});throw s&&this.onNotification({title:t,color:"danger"},`updateSavedObject:${e.getIndexPattern()}`),o}return c.forEach((t=>{e[t]=d[t]})),e.version=d.version,this.dataViewCache.clear(e.id),this.updateSavedObject(e,t,i,s)}throw o}))}async delete(e){if(!await this.getCanSave())throw new y.a(e);return this.dataViewCache.clear(e),this.savedObjectsClient.delete(e)}async getDefaultDataView(e={}){const{displayErrors:t=!0,refreshFields:i}=e,s=await this.getIdsWithTitle();let n=await this.config.get("defaultIndex");const a=!!n&&s.some((e=>e.id===n));return n&&!a&&(await this.getCanSaveAdvancedSettings()&&await this.config.remove("defaultIndex"),n=void 0),!n&&s.length>=1&&await this.hasUserDataView().catch((()=>!0))&&(n=s[0].id,await this.getCanSaveAdvancedSettings()&&await this.config.set("defaultIndex",n)),n?this.get(n,t,i):null}}const _={inject:(e,t)=>e,extract:e=>({state:e,references:[]}),getAllMigrations:()=>({}),migrateToLatest:({state:e})=>e,telemetry:()=>({})}},function(e,t){e.exports=__kbnSharedDeps__.Rxjs},function(e,t,i){i.r(t);var s=__kbnBundles__.get("plugin/kibanaUtils/common");Object.defineProperties(t,Object.getOwnPropertyDescriptors(s))},function(e,t){e.exports=__kbnSharedDeps__.RxjsOperators},function(e,t,i){"use strict";i.d(t,"a",(function(){return DataViewMissingIndices}));var s=i(12);class DataViewMissingIndices extends s.KbnError{constructor(e){super(e&&e.length?`No matching indices found: ${e}`:"Data view's title does not match any indices")}}},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var s=i(7);const n=()=>({name:"indexPatternLoad",type:"index_pattern",inputTypes:["null"],help:s.i18n.translate("dataViews.functions.dataViewLoad.help",{defaultMessage:"Loads a data view"}),args:{id:{types:["string"],required:!0,help:s.i18n.translate("dataViews.functions.dataViewLoad.id.help",{defaultMessage:"data view id to load"})}},extract(e){const t="indexPatternLoad.id",i=[{name:t,type:"search",id:e.id[0]}];return{state:{...e,id:[t]},references:i}},inject(e,t){const i=t.find((e=>"indexPatternLoad.id"===e.name));return i&&(e.id[0]=i.id),e}})},function(e,t,i){"use strict";let s,n,a;i.d(t,"a",(function(){return s})),i.d(t,"b",(function(){return a})),function(e){e.ROLLUP="rollup",e.DEFAULT="default"}(s||(s={})),function(e){e.OPEN="open",e.CLOSED="closed",e.HIDDEN="hidden",e.FROZEN="frozen"}(n||(n={})),function(e){e.OPEN="open",e.CLOSED="closed",e.HIDDEN="hidden",e.FROZEN="frozen"}(a||(a={}))},function(e,t,i){i.r(t);var s=__kbnBundles__.get("plugin/fieldFormats/common");Object.defineProperties(t,Object.getOwnPropertyDescriptors(s))},function(e,t){e.exports=__kbnSharedDeps__.Uuid},function(e,t,i){i(20),__kbnBundles__.define("plugin/dataViews/public",i,22),__kbnBundles__.define("plugin/dataViews/common",i,2)},function(e,t,i){i.p=window.__kbnPublicPath__.dataViews},function(e,t){e.exports=__kbnSharedDeps_npm__},function(e,t,i){"use strict";i.r(t),i.d(t,"ILLEGAL_CHARACTERS_KEY",(function(){return s.d})),i.d(t,"CONTAINS_SPACES_KEY",(function(){return s.a})),i.d(t,"ILLEGAL_CHARACTERS_VISIBLE",(function(){return s.e})),i.d(t,"ILLEGAL_CHARACTERS",(function(){return s.c})),i.d(t,"validateDataView",(function(){return s.f})),i.d(t,"DataViewField",(function(){return n.DataViewField})),i.d(t,"DataViewType",(function(){return n.DataViewType})),i.d(t,"DataViewSavedObjectConflictError",(function(){return n.DataViewSavedObjectConflictError})),i.d(t,"META_FIELDS",(function(){return n.META_FIELDS})),i.d(t,"DATA_VIEW_SAVED_OBJECT_TYPE",(function(){return n.DATA_VIEW_SAVED_OBJECT_TYPE})),i.d(t,"getFieldSubtypeMulti",(function(){return n.getFieldSubtypeMulti})),i.d(t,"getFieldSubtypeNested",(function(){return n.getFieldSubtypeNested})),i.d(t,"INDEX_PATTERN_TYPE",(function(){return a.a})),i.d(t,"DataViewsApiClient",(function(){return data_views_api_client_DataViewsApiClient})),i.d(t,"DataViewsService",(function(){return r.c})),i.d(t,"DataView",(function(){return r.a})),i.d(t,"UiSettingsPublicToCommon",(function(){return ui_settings_wrapper_UiSettingsPublicToCommon})),i.d(t,"plugin",(function(){return b}));var s=i(3),n=i(2),a=i(16),r=i(10),o=i(0),d=i.n(o),l=i(8);class data_views_api_client_DataViewsApiClient{constructor(e){d()(this,"http",void 0),this.http=e}_request(e,t,i){return(i?this.http.post(e,{query:t,body:i,version:"1"}):this.http.fetch(e,{query:t,version:"1"})).catch((e=>{var t;if(404===e.body.statusCode&&"no_matching_indices"===(null===(t=e.body.attributes)||void 0===t?void 0:t.code))throw new s.b(e.body.message);throw new Error(e.body.message||e.body.error||`${e.body.statusCode} Response`)}))}_getUrl(e){return"/api/index_patterns/"+e.filter(Boolean).map(encodeURIComponent).join("/")}getFieldsForWildcard(e){const{pattern:t,metaFields:i,type:s,rollupIndex:n,allowNoIndex:a,indexFilter:r,includeUnmapped:o,fields:d}=e;return this._request(l.c,{pattern:t,meta_fields:i,type:s,rollup_index:n,allow_no_index:a,include_unmapped:o,fields:d},r?JSON.stringify({index_filter:r}):void 0).then((e=>e||{fields:[],indices:[]}))}async hasUserDataView(){var e;const t=await this._request(this._getUrl(["has_user_index_pattern"]));return null!==(e=null==t?void 0:t.result)&&void 0!==e&&e}}class ui_settings_wrapper_UiSettingsPublicToCommon{constructor(e){d()(this,"uiSettings",void 0),this.uiSettings=e}get(e){return Promise.resolve(this.uiSettings.get(e))}getAll(){return Promise.resolve(this.uiSettings.getAll())}set(e,t){return this.uiSettings.set(e,t),Promise.resolve()}remove(e){return this.uiSettings.remove(e),Promise.resolve()}}var c=i(7),u=i(15);var h=i(12),p=i(4),f=i(9);class content_management_wrapper_ContentMagementWrapper{constructor(e){d()(this,"contentManagementClient",void 0),this.contentManagementClient=e}async find(e){return(await this.contentManagementClient.search({contentTypeId:f.a,query:{text:e.search,limit:e.perPage},options:{searchFields:e.searchFields,fields:e.fields}})).hits}async get(e){let t;try{t=await this.contentManagementClient.get({contentTypeId:f.a,id:e})}catch(t){var i;throw 404===(null===(i=t.body)||void 0===i?void 0:i.statusCode)?new h.SavedObjectNotFound("data view",e,"management/kibana/dataViews"):t}if("conflict"===t.meta.outcome)throw new p.b(e);return t.item}async update(e,t,i){return(await this.contentManagementClient.update({contentTypeId:f.a,id:e,data:t,options:i})).item}async create(e,t){return(await this.contentManagementClient.create({contentTypeId:f.a,data:e,options:t})).item}async delete(e){await this.contentManagementClient.delete({contentTypeId:f.a,id:e,options:{force:!0}})}}class data_views_service_public_DataViewsServicePublic extends r.c{constructor(e){super(e),d()(this,"getCanSaveSync",void 0),d()(this,"getIndices",void 0),d()(this,"hasData",void 0),this.getCanSaveSync=e.getCanSaveSync,this.hasData=e.hasData,this.getIndices=e.getIndices}}class has_data_HasData{constructor(){d()(this,"removeAliases",(e=>!e.item.indices)),d()(this,"isUserDataSource",(e=>!e.name.startsWith(".")&&!n.DEFAULT_ASSETS_TO_IGNORE.DATA_STREAMS_TO_IGNORE.includes(e.name))),d()(this,"responseToItemArray",(e=>{const{indices:t=[],aliases:i=[]}=e,s=[];return[...t,...i,...e.data_streams||[]].forEach((e=>{s.push({name:e.name,item:e})})),s})),d()(this,"getIndicesViaSearch",(async({http:e,pattern:t,showAllIndices:i})=>e.post("/internal/search/ese",{version:"1",body:JSON.stringify({params:{ignore_unavailable:!0,expand_wildcards:i?"all":"open",index:t,body:{size:0,aggs:{indices:{terms:{field:"_index",size:200}}}}}})}).then((e=>!!(e&&e.total>=0))).catch((e=>(console.warn("getIndicesViaSearch failed with error, assuming there is data",e),!0))))),d()(this,"getIndices",(async({http:e,pattern:t,showAllIndices:i})=>e.get(`/internal/index-pattern-management/resolve_index/${t}`,{query:i?{expand_wildcards:"all"}:void 0}).then((e=>e?this.responseToItemArray(e):[])))),d()(this,"checkLocalESData",(e=>this.getIndices({http:e,pattern:"*",showAllIndices:!1}).then((e=>e.some(this.isUserDataSource))).catch((()=>this.getIndicesViaSearch({http:e,pattern:"*",showAllIndices:!1}))))),d()(this,"checkRemoteESData",(e=>this.getIndices({http:e,pattern:"*:*",showAllIndices:!1}).then((e=>!!e.filter(this.removeAliases).length)).catch((()=>this.getIndicesViaSearch({http:e,pattern:"*:*",showAllIndices:!1}))))),d()(this,"getHasDataViews",(async({http:e})=>e.get("/internal/data_views/has_data_views",{version:"1"}))),d()(this,"hasDataViews",(e=>this.getHasDataViews({http:e}).then((e=>{const{hasDataView:t}=e;return t})).catch((e=>(console.warn("hasDataViews failed with error, assuming there are data views",e),!0))))),d()(this,"hasUserDataViews",(e=>this.getHasDataViews({http:e}).then((e=>{const{hasUserDataView:t}=e;return t})).catch((e=>(console.warn("hasUserDataViews failed with error, assuming there are user-created data views",e),!0)))))}start(e){const{http:t}=e;return{hasESData:async()=>{const e=await this.checkLocalESData(t);return e||await this.checkRemoteESData(t)},hasDataView:async()=>await this.hasDataViews(t),hasUserDataView:async()=>await this.hasUserDataViews(t)}}}var m=i(1);const g=(e,t)=>{const i={};return s=>(i[s]||(i[s]=Object(m.debounce)(e,t,{leading:!0})),i[s])};class plugin_DataViewsPublicPlugin{constructor(){d()(this,"hasData",new has_data_HasData)}setup(e,{expressions:t,contentManagement:i}){return t.registerFunction(function({getStartServices:e}){return function({getStartDependencies:e}){return()=>({...Object(u.a)(),async fn(t,i){const{indexPatterns:s}=await e();return{type:"index_pattern",value:(await s.get(i.id)).toSpec()}}})}({getStartDependencies:async()=>{const[,,t]=await e();return{indexPatterns:t}}})}({getStartServices:e.getStartServices})),i.registry.register({id:l.a,version:{latest:f.b},name:c.i18n.translate("dataViews.contentManagementType",{defaultMessage:"Data view"})}),{}}start(e,{fieldFormats:t,contentManagement:s}){const{uiSettings:n,http:a,notifications:r,application:o}=e,d=g(r.toasts.add.bind(r.toasts),1e4),l=g(r.toasts.addError.bind(r.toasts),1e4);return new data_views_service_public_DataViewsServicePublic({hasData:this.hasData.start(e),uiSettings:new ui_settings_wrapper_UiSettingsPublicToCommon(n),savedObjectsClient:new content_management_wrapper_ContentMagementWrapper(s.client),apiClient:new data_views_api_client_DataViewsApiClient(a),fieldFormats:t,onNotification:(e,t)=>{d(t)(e)},onError:(e,t,i)=>{l(i)(e,t)},getCanSave:()=>Promise.resolve(!0===o.capabilities.indexPatterns.save),getCanSaveSync:()=>!0===o.capabilities.indexPatterns.save,getCanSaveAdvancedSettings:()=>Promise.resolve(!0===o.capabilities.advancedSettings.save),getIndices:t=>async function(e){const{getIndices:t}=await i.e(1).then(i.bind(null,23));return t(e)}({...t,http:e.http})})}stop(){}}function b(){return new plugin_DataViewsPublicPlugin}}]);