Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@appbaseio/searchbase

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appbaseio/searchbase - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

30

dist/@appbaseio/searchbase.es.js

@@ -827,2 +827,3 @@ import AppbaseAnalytics from '@appbaseio/analytics';

// To show the distinct suggestions
// preserve the data for infinite loading
// query error

@@ -873,3 +874,4 @@ // state changes subject

showDistinctSuggestions = _ref.showDistinctSuggestions,
rsAPIConfig = _objectWithoutPropertiesLoose(_ref, ["index", "url", "credentials", "appbaseConfig", "headers", "transformRequest", "transformResponse", "beforeValueChange", "onValueChange", "onResults", "onAggregationData", "onError", "onRequestStatusChange", "onQueryChange", "onMicStatusChange", "enablePopularSuggestions", "results", "showDistinctSuggestions"]);
preserveResults = _ref.preserveResults,
rsAPIConfig = _objectWithoutPropertiesLoose(_ref, ["index", "url", "credentials", "appbaseConfig", "headers", "transformRequest", "transformResponse", "beforeValueChange", "onValueChange", "onResults", "onAggregationData", "onError", "onRequestStatusChange", "onQueryChange", "onMicStatusChange", "enablePopularSuggestions", "results", "showDistinctSuggestions", "preserveResults"]);

@@ -1158,3 +1160,3 @@ _this = _Base.call(this, {

_this.results.setRaw(rawResults);
_this._appendResults(rawResults);

@@ -1164,3 +1166,3 @@ afterResponse();

} else {
_this.results.setRaw(rawResults);
_this._appendResults(rawResults);

@@ -1538,3 +1540,4 @@ afterResponse();

_this.enablePopularSuggestions = enablePopularSuggestions;
_this.showDistinctSuggestions = showDistinctSuggestions; // Initialize the state changes observable
_this.showDistinctSuggestions = showDistinctSuggestions;
_this.preserveResults = preserveResults; // Initialize the state changes observable

@@ -1610,3 +1613,15 @@ _this.stateChanges = new Observable();

/* -------- Private methods only for the internal use -------- */
// Method to apply the changed based on set options
_proto._appendResults = function _appendResults(rawResults) {
if (this.preserveResults && rawResults && Array.isArray(rawResults.hits && rawResults.hits.hits) && Array.isArray(this.results.rawData && this.results.rawData.hits && this.results.rawData.hits.hits)) {
this.results.setRaw(_extends({}, rawResults, {
hits: _extends({}, rawResults.hits, {
hits: [].concat(this.results.rawData.hits.hits, rawResults.hits.hits)
})
}));
} else {
this.results.setRaw(rawResults);
}
} // Method to apply the changed based on set options
;
_proto._applyOptions = function _applyOptions(options, key, prevValue, nextValue) {

@@ -2068,2 +2083,7 @@ // // Trigger mic events

if (_this._components[componentId]) {
// return existing instance
return _this._components[componentId];
}
var componentInstance = component;

@@ -2070,0 +2090,0 @@

2

dist/@appbaseio/searchbase.umd.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Searchbase={})}(this,(function(e){"use strict";function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var o=function(){function e(){this.observers=[]}var t=e.prototype;return t.subscribe=function(e,t){this.observers.push({callback:e,properties:t})},t.unsubscribe=function(e){this.observers=e?this.observers.filter((function(t){return t.callback!==e?t:null})):[]},t.next=function(e,t,r){var n=r||window;this.observers.forEach((function(r){(void 0===r.properties||r.properties instanceof Array&&r.properties.length&&r.properties.includes(t)||"string"==typeof r.properties&&r.properties&&r.properties===t)&&r.callback.call(n,e)}))},e}(),u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var c=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){var r=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:u);!function(e){!function(t){var r="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,s="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,a="ArrayBuffer"in e;if(a)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(e){return e&&o.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function h(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function y(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():a&&s&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(e)||u(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var e,t,r,n=d(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=p(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(_)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(e,t){e=c(e),t=h(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},f.prototype.delete=function(e){delete this.map[c(e)]},f.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},f.prototype.set=function(e,t){this.map[c(e)]=h(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),l(e)},f.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),l(e)},f.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),l(e)},n&&(f.prototype[Symbol.iterator]=f.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(e,t){var r,n,s=(t=t||{}).body;if(e instanceof b){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,s||null==e._bodyInit||(s=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(r=t.method||this.method||"GET",n=r.toUpperCase(),v.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function _(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(s))}})),t}function w(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},m.call(b.prototype),m.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},w.error=function(){var e=new w(null,{status:0,statusText:""});return e.type="error",e};var S=[301,302,303,307,308];w.redirect=function(e,t){if(-1===S.indexOf(t))throw new RangeError("Invalid status code");return new w(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function q(e,r){return new Promise((function(n,i){var a=new b(e,r);if(a.signal&&a.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function u(){o.abort()}o.onload=function(){var e,t,r={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var s=r.join(":").trim();t.append(n,s)}})),t)};r.url="responseURL"in o?o.responseURL:r.headers.get("X-Request-URL");var s="response"in o?o.response:o.responseText;n(new w(s,r))},o.onerror=function(){i(new TypeError("Network request failed"))},o.ontimeout=function(){i(new TypeError("Network request failed"))},o.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},o.open(a.method,a.url,!0),"include"===a.credentials?o.withCredentials=!0:"omit"===a.credentials&&(o.withCredentials=!1),"responseType"in o&&s&&(o.responseType="blob"),a.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),a.signal&&(a.signal.addEventListener("abort",u),o.onreadystatechange=function(){4===o.readyState&&a.signal.removeEventListener("abort",u)}),o.send(void 0===a._bodyInit?null:a._bodyInit)}))}q.polyfill=!0,e.fetch||(e.fetch=q,e.Headers=f,e.Request=b,e.Response=w),t.Headers=f,t.Request=b,t.Response=w,t.fetch=q}({})}(r),delete r.fetch.polyfill,(t=r.fetch).default=r.fetch,t.fetch=r.fetch,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,e.exports=t}));c.fetch,c.Headers,c.Request,c.Response;function h(){return(h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e){void 0===e&&(e="");for(var t,r=e,n="",s=0,i=0,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|i)||(a="=",i%1);n+=a.charAt(63&s>>8-i%1*8)){if((t=r.charCodeAt(i+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');s=s<<8|t}return n}function f(e,t){if(null==e&&!t)throw new Error("appbase-analytics: query or queryID must be present to register a click/conversion event")}var d={init:function(e){void 0===e&&(e={});var t={credentials:e.credentials,index:e.index,url:e.url,userID:e.userID,globalEventData:e.globalEventData,queryID:"",headers:null};return function(e){if(!e)throw new Error("appbase-analytics: A valid index must be present to record analytics events.")}(t.index),function(e){if(!e)throw new Error("appbase-analytics: Auth credentials is missing.")}(t.credentials),function(e){if(!e)throw new Error("appbase-analytics: URL is missing.")}(t.url),t._request=function(e,r,n){var s=h({},r,{user_id:t.userID,event_data:h({},r&&r.event_data,{},t.globalEventData)});return c(t.url+"/"+t.index+"/_analytics/"+e,{method:"PUT",headers:h({},t.headers,{"Content-Type":"application/json",Authorization:"Basic "+l(t.credentials)}),body:JSON.stringify(s)}).then((function(e){n&&n(null,e)})).catch((function(e){console.error(e),n&&n(e,null)}))},t.search=function(e,r){f(e.query,e.queryID);if(t._request){var n={query:e.query,query_id:e.queryID,event_data:e.eventData,filters:e.filters,hits:e.hits};t._request("search",n,(function(e,n){n&&n.json().then((function(e){e&&e.query_id&&(t.queryID=e.query_id)})).catch((function(e){console.error(e)})),r&&r(e,n)}))}},t.click=function(e,r){if(f(e.query,e.queryID),function(e){if(!e||Object.keys(e).length<1)throw new Error("appbase-analytics: at least one click object must be present to register a click event")}(e.objects),t._request){var n={click_on:e.objects,click_type:e.isSuggestionClick?"suggestion":"result",query:e.query,query_id:e.queryID,event_data:e.eventData};t._request("click",n,r)}},t.conversion=function(e,r){if(f(e.query,e.queryID),function(e){if(!e||Object.keys(e).length<1)throw new Error("appbase-analytics: at least one click object must be present to register a click event")}(e.objects),t._request){var n={conversion_on:e.objects,query:e.query,query_id:e.queryID,event_data:e.eventData};t._request("conversion",n,r)}},t.setUserID=function(e){t.userID=e},t.setGlobalEventData=function(e){t.globalEventData=e},t.setHeaders=function(e){t.headers=e},t}};function p(e){return"SearchBase: "+e}var y={invalidIndex:p("Please provide a valid index."),invalidURL:p("Please provide a valid url."),invalidComponentId:p("Please provide component id."),invalidDataField:p("Please provide data field."),dataFieldAsArray:p("Only components with `search` type supports the multiple data fields. Please define `dataField` as a string.")},g=["key","key.autosuggest"],m="search",v=function(e){var t=[];return e&&(t=[].concat(e).map((function(e){var t=function(e){var t=s({},e);return t.highlight&&Object.keys(t.highlight).forEach((function(e){var r,n=t.highlight[e][0];t._source=s({},t._source,((r={})[e]=n,r))})),t}(e);return Object.keys(t).filter((function(e){return"_source"!==e})).reduce((function(e,r){return e[r]=t[r],e}),s({},t._source))}))),t},b=function(e){if(e){if(!Array.isArray(e))return[e];if(e.length){var t=[];return e.forEach((function(e){"string"==typeof e?t.push(e):e.field&&t.push(e.field)})),t}}};var _=function(e){if(e&&Array.isArray(e)&&e.length){var t=[];return e.forEach((function(e){var r;r=e.weight,!Number.isNaN(parseFloat(r))&&Number.isFinite(r)?t.push(e.weight):t.push(1)})),t}};function w(e,t){var r=[];return function e(t){t&&Object.keys(t)&&Object.keys(t).forEach((function(n){t[n]&&("string"==typeof t[n]?r=[].concat(r,[t[n]]):Array.isArray(t[n])?r=[].concat(r,t[n]):"object"==typeof t[n]&&e(t[n]))}))}(e),r=r.filter((function(e){return e!==t}))}var S=function(e){return"object"==typeof e?Array.isArray(e)?function e(t){return t.reduce((function(t,r){return t.concat(Array.isArray(r)?e(r):r)}),[])}(e):null:e};function q(e,t){if(e===t)return!0;if(!(e instanceof Object&&t instanceof Object))return!1;if(e.constructor!==t.constructor)return!1;for(var r in e)if(e.hasOwnProperty(r)){if(!t.hasOwnProperty(r))return!1;if(e[r]!==t[r]){if("object"!=typeof e[r])return!1;if(!q(e[r],t[r]))return!1}}for(var n in t)if(t.hasOwnProperty(n)&&!e.hasOwnProperty(n))return!1;return!0}var C={id:"id",type:"type",react:"react",queryFormat:"queryFormat",dataField:"dataField",categoryField:"categoryField",categoryValue:"categoryValue",nestedField:"nestedField",from:"from",size:"size",sortBy:"sortBy",value:"value",aggregationField:"aggregationField",after:"after",includeNullValues:"includeNullValues",includeFields:"includeFields",excludeFields:"excludeFields",fuzziness:"fuzziness",searchOperators:"searchOperators",highlight:"highlight",highlightField:"highlightField",customHighlight:"customHighlight",interval:"interval",aggregations:"aggregations",missingLabel:"missingLabel",showMissing:"showMissing",enableSynonyms:"enableSynonyms",selectAllLabel:"selectAllLabel",pagination:"pagination",queryString:"queryString",enablePopularSuggestions:"enablePopularSuggestions",showDistinctSuggestions:"showDistinctSuggestions",error:"error",defaultQuery:"defaultQuery",customQuery:"customQuery",requestStatus:"requestStatus",results:"results",aggregationData:"aggregationData",micStatus:"micStatus",micInstance:"micInstance",micActive:"micActive",micInactive:"micInactive",micDenied:"micDenied",query:"query",requestPending:"loading",appbaseSettings:"appbaseConfig",suggestions:"suggestions",queryId:"queryId",recentSearches:"recentSearches",onMicClick:"handleMicClick",triggerDefaultQuery:"triggerDefaultQuery",triggerCustomQuery:"triggerCustomQuery",recordClick:"recordClick",recordConversions:"recordConversions",subscribeToStateChanges:"subscribeToStateChanges",unsubscribeToStateChanges:"unsubscribeToStateChanges",setDataField:"setDataField",setValue:"setValue",setSize:"setSize",setFrom:"setFrom",setFuzziness:"setFuzziness",setIncludeFields:"setIncludeFields",setExcludeFields:"setExcludeFields",setSortBy:"setSortBy",setReact:"setReact",setDefaultQuery:"setDefaultQuery",setCustomQuery:"setCustomQuery"};function D(e){void 0===e&&(e="");for(var t,r=e,n="",s=0,i=0,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|i)||(a="=",i%1);n+=a.charAt(63&s>>8-i%1*8)){if((t=r.charCodeAt(i+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');s=s<<8|t}return n}var R=function(){function e(e){var t=e.index,r=e.url,n=e.credentials,i=e.headers,a=e.appbaseConfig,o=e.transformRequest,u=e.transformResponse;if(!t)throw new Error(y.invalidIndex);if(!r)throw new Error(y.invalidURL);this.index=t,this.url=r,this.credentials=n||"",a&&(this.appbaseConfig=a),o&&(this.transformRequest=o),u&&(this.transformResponse=u),this.headers={Accept:"application/json","Content-Type":"application/json"},this.credentials&&(this.headers=s({},this.headers,{Authorization:"Basic "+D(this.credentials)})),i&&this.setHeaders(i),this._analyticsInstance=d.init({index:t,url:r,credentials:n})}var t=e.prototype;return t.setHeaders=function(e){this.headers=s({},this.headers,e)},t.setQueryID=function(e){this._queryId=e},e}(),E=function(){function e(e){var t=this;n(this,"setRaw",(function(e){t.raw=e,e.hits&&e.hits.hits&&t.setData(e.hits.hits)})),this.data=e||[]}return e.prototype.setData=function(e){var t,r=v(e);if(this.promotedData.length){var n=this.promotedData.map((function(e){return e._id})).filter(Boolean);n&&(r=r.filter((function(e){return!n.includes(e._id)}))),r=[].concat(this.promotedData.map((function(e){return s({},e,{_promoted:!0})})),r)}this.parseResults?this.data=this.parseResults(r,e):this.data=r,this.data=(void 0===(t=this.data)&&(t=[]),t.map((function(e,t){return s({},e,{_click_id:t+1})})))},r(e,[{key:"numberOfResults",get:function(){return this.raw&&this.raw.hits?"object"==typeof this.raw.hits.total?this.raw.hits.total.value:this.raw.hits.total:0}},{key:"time",get:function(){return this.raw?this.raw.took:0}},{key:"hidden",get:function(){return this.raw&&this.raw.hits&&this.raw.hits.hidden||0}},{key:"promotedData",get:function(){return this.raw&&this.raw.promoted&&this.raw.promoted||[]}},{key:"promoted",get:function(){return this.promotedData.length||0}},{key:"rawData",get:function(){return this.raw||{}}},{key:"customData",get:function(){return this.raw&&this.raw.customData&&this.raw.customData||{}}}]),e}(),O=function(){function e(e){this.data=e||[]}var t=e.prototype;return t.setRaw=function(e){this.raw=e,e.after_key&&this.setAfterKey(e.after_key)},t.setAfterKey=function(e){this.afterKey=e},t.setData=function(e,t){var r,n;this.data=(r=e,void 0===(n=t)&&(n=[]),n.map((function(e){var t=e.doc_count,n=e.key,i=e[r];return s({_doc_count:t,_key:void 0!==n[r]?n[r]:n},i)})))},r(e,[{key:"rawData",get:function(){return this.raw||{}}}]),e}(),F={triggerDefaultQuery:!0,triggerCustomQuery:!1,stateChanges:!0},A={stateChanges:!0},I="INACTIVE",x="ACTIVE",k="DENIED",Q="INACTIVE",j="PENDING",P="ERROR",B=function(e){function t(t){var r,i=t.index,u=t.url,c=t.credentials,h=t.appbaseConfig,l=t.headers,f=t.transformRequest,d=t.transformResponse,p=t.beforeValueChange,g=t.onValueChange,v=t.onResults,b=t.onAggregationData,_=t.onError,w=t.onRequestStatusChange,S=t.onQueryChange,C=t.onMicStatusChange,D=t.enablePopularSuggestions,R=t.results,P=t.showDistinctSuggestions,B=function(e,t){if(null==e)return{};var r,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(s[r]=e[r]);return s}(t,["index","url","credentials","appbaseConfig","headers","transformRequest","transformResponse","beforeValueChange","onValueChange","onResults","onAggregationData","onError","onRequestStatusChange","onQueryChange","onMicStatusChange","enablePopularSuggestions","results","showDistinctSuggestions"]);n(a(r=e.call(this,{index:i,url:u,credentials:c,headers:l,appbaseConfig:h,transformRequest:f,transformResponse:d})||this),"onMicClick",(function(e,t){void 0===e&&(e={}),void 0===t&&(t={triggerDefaultQuery:!1,triggerCustomQuery:!1,stateChanges:!0});var n=r._micStatus;if("undefined"!=typeof window&&(window.SpeechRecognition=window.webkitSpeechRecognition||window.SpeechRecognition||null),window&&window.SpeechRecognition&&n!==k){n===x&&r._setMicStatus(I,t);var s=window.SpeechRecognition;if(r._micInstance)return void r._stopMic();r._micInstance=new s,r._micInstance.continuous=!0,r._micInstance.interimResults=!0,Object.assign(r._micInstance,e),r._micInstance.start(),r._micInstance.onstart=function(){r._setMicStatus(x,t)},r._micInstance.onresult=function(e){var n=e.results;n&&n[0]&&n[0].isFinal&&r._stopMic(),r._handleVoiceResults({results:n},t)},r._micInstance.onerror=function(e){"no-speech"===e.error||"audio-capture"===e.error?r._setMicStatus(I,t):"not-allowed"===e.error&&r._setMicStatus(k,t),console.error(e)}}})),n(a(r),"setDataField",(function(e,t){void 0===t&&(t=F);var n=r.dataField;r.dataField=e,r._applyOptions(t,"dataField",n,e)})),n(a(r),"setParent",(function(e){r._parent=e})),n(a(r),"setValue",(function(e,t){void 0===t&&(t=F);var n=function(){var n=r.value;r.value=e,r._applyOptions(t,"value",n,r.value)};r.beforeValueChange?r.beforeValueChange(e).then(n).catch((function(e){console.warn("beforeValueChange rejected the promise with ",e)})):n()})),n(a(r),"setSize",(function(e,t){void 0===t&&(t=F);var n=r.size;r.size=e,r._applyOptions(t,"size",n,r.size)})),n(a(r),"setFrom",(function(e,t){void 0===t&&(t=F);var n=r.from;r.from=e,r._applyOptions(t,"from",n,r.from)})),n(a(r),"setFuzziness",(function(e,t){void 0===t&&(t=F);var n=r.fuzziness;r.fuzziness=e,r._applyOptions(t,"fuzziness",n,r.fuzziness)})),n(a(r),"setIncludeFields",(function(e,t){void 0===t&&(t=F);var n=r.includeFields;r.includeFields=e,r._applyOptions(t,"includeFields",n,e)})),n(a(r),"setExcludeFields",(function(e,t){void 0===t&&(t=F);var n=r.excludeFields;r.excludeFields=e,r._applyOptions(t,"excludeFields",n,e)})),n(a(r),"setSortBy",(function(e,t){void 0===t&&(t=F);var n=r.sortBy;r.sortBy=e,r._applyOptions(t,"sortBy",n,e)})),n(a(r),"setReact",(function(e,t){void 0===t&&(t=F);var n=r.react;r.react=e,r._applyOptions(t,"react",n,e)})),n(a(r),"setDefaultQuery",(function(e,t){void 0===t&&(t=F);var n=r.defaultQuery;r.defaultQuery=e,r._applyOptions(t,"defaultQuery",n,e)})),n(a(r),"setCustomQuery",(function(e,t){void 0===t&&(t=F);var n=r.customQuery;r.customQuery=e,r._applyOptions(t,"customQuery",n,e)})),n(a(r),"setAfter",(function(e,t){void 0===t&&(t=F);var n=r.after;r.after=e,r._applyOptions(t,"after",n,e)})),n(a(r),"triggerDefaultQuery",(function(e){if(void 0===e&&(e=A),q(r._query,r.componentQuery))return Promise.resolve(!0);var t=function(t){return r._setError(t,{stateChanges:e.stateChanges}),console.error(t),Promise.reject(t)};try{return r._updateQuery(),r._setRequestStatus(j),r._fetchRequest({query:Array.isArray(r.query)?r.query:[r.query],settings:r.appbaseSettings}).then((function(n){var i=r.results,a=n&&n[r.id],o=function(){a.aggregations&&r._handleAggregationResponse(a.aggregations,s({defaultOptions:F},e)),r._setRequestStatus(Q),r._applyOptions({stateChanges:e.stateChanges},"results",i,r.results)};return r.type&&r.type!==m||!r.enablePopularSuggestions?(r.results.setRaw(a),o()):r._fetchRequest(r.getSuggestionsQuery(),!0).then((function(e){var t=e.DataSearch__suggestions;t&&t.hits&&t.hits.hits&&a.hits&&a.hits.hits&&(a.hits.hits=[].concat((t.hits.hits||[]).map((function(e){return s({},e,{_popular_suggestion:!0})})),a.hits.hits)),r.results.setRaw(a),o()})).catch(t),Promise.resolve(a)})).catch(t)}catch(e){return t(e)}})),n(a(r),"triggerCustomQuery",(function(e){void 0===e&&(e=A);var t=r._generateQuery(),n=t.requestBody,i=t.orderOfQueries;if(!n.length)return Promise.resolve({});if(q(r._query,n))return Promise.resolve(!0);var a=function(t){return r._setError(t,{stateChanges:e.stateChanges}),console.error(t),Promise.reject(t)};try{i.forEach((function(e){var t=r._parent.getComponent(e);t&&(t.setFrom(0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1}),t.setAfter(void 0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1}),t._setRequestStatus(j),t._updateQuery())}));var o=r._generateQuery().requestBody;return r._fetchRequest({query:o,settings:r.appbaseSettings}).then((function(t){return i.forEach((function(n){var i=r._parent.getComponent(n);if(i){i._setRequestStatus(Q),i.setValue(void 0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1});var a=i.results,o=t&&t[n];o.hits&&(i.results.setRaw(o),i._applyOptions({stateChanges:e.stateChanges},"results",a,i.results)),o.aggregations&&i._handleAggregationResponse(o.aggregations,s({defaultOptions:F},e))}})),Promise.resolve(t)})).catch(a)}catch(e){return a(e)}})),n(a(r),"recordClick",(function(e,t){void 0===t&&(t=!1),r._analyticsInstance&&r.queryId&&r._analyticsInstance.click({queryID:r.queryId,objects:e,isSuggestionClick:t})})),n(a(r),"recordConversions",(function(e){r._analyticsInstance&&r.queryId&&r._analyticsInstance.conversion({queryID:r.queryId,objects:e})})),n(a(r),"subscribeToStateChanges",(function(e,t){r.stateChanges.subscribe(e,t)})),n(a(r),"unsubscribeToStateChanges",(function(e){r.stateChanges.unsubscribe(e)})),n(a(r),"clearResults",(function(e){void 0===e&&(e=A);var t=r.results;r.results.setRaw({hits:{hits:[]}}),r._applyOptions({stateChanges:e.stateChanges},"results",t,r.results)})),n(a(r),"getRecentSearches",(function(e,t){void 0===e&&(e={size:5,minChars:3}),void 0===t&&(t=A);var n={headers:s({},r.headers)},i="",a=function(e,t){i+=i?"&"+e+"="+t:e+"="+t};return r.appbaseSettings&&r.appbaseSettings.userId&&a("user_id",r.appbaseSettings.userId),e&&(e.size&&a("size",String(e.size)),e.from&&a("from",e.from),e.to&&a("to",e.to),e.minChars&&a("min_chars",String(e.minChars)),e.customEvents&&Object.keys(e.customEvents).forEach((function(t){a(t,e.customEvents[t])}))),new Promise((function(e,s){fetch(r.url+"/_analytics/"+r.index+"/recent-searches?"+i,n).then((function(e){return e.status>=500||e.status>=400?s(e):e.json().then((function(e){var n=r.recentSearches;r.recentSearches=e.map((function(e){return{label:e.key,value:e.key}})),r._applyOptions({stateChanges:t.stateChanges},"recentSearches",n,r.recentSearches)})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),s(e)}))})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),s(e)}))}))})),n(a(r),"_handleVoiceResults",(function(e,t){var n=e.results;void 0===t&&(t=F),n&&n[0]&&n[0].isFinal&&n[0][0]&&n[0][0].transcript&&n[0][0].transcript.trim()&&r.setValue(n[0][0].transcript.trim(),s({},t,{triggerCustomQuery:!0,triggerDefaultQuery:!0}))})),n(a(r),"_stopMic",(function(){r._micInstance&&(r._micInstance.stop(),r._micInstance=null,r._setMicStatus(I))})),n(a(r),"_setMicStatus",(function(e,t){void 0===t&&(t=F);var n=r._micStatus;r._micStatus=e,r._applyOptions(t,"micStatus",n,r._micStatus)}));var T=B.id,z=B.type,M=B.react,V=B.queryFormat,L=B.dataField,U=B.categoryField,N=B.categoryValue,H=B.nestedField,G=B.from,K=B.size,J=B.sortBy,X=B.value,W=B.aggregationField,Y=B.after,Z=B.includeNullValues,$=B.includeFields,ee=B.excludeFields,te=B.fuzziness,re=B.searchOperators,ne=B.highlight,se=B.highlightField,ie=B.customHighlight,ae=B.interval,oe=B.aggregations,ue=B.missingLabel,ce=B.showMissing,he=B.defaultQuery,le=B.customQuery,fe=B.execute,de=B.enableSynonyms,pe=B.selectAllLabel,ye=B.pagination,ge=B.queryString;if(!T)throw new Error(y.invalidComponentId);if(z&&z!==m){if(!L)throw new Error(y.invalidDataField);if(Array.isArray(L))throw new Error(y.dataFieldAsArray)}return r.id=T,r.type=z,r.react=M,r.queryFormat=V,r.dataField=L,r.categoryField=U,r.categoryValue=N,r.nestedField=H,r.from=G,r.size=K,r.sortBy=J,r.aggregationField=W,r.after=Y,r.includeNullValues=Z,r.includeFields=$,r.excludeFields=ee,r.fuzziness=te,r.searchOperators=re,r.highlight=ne,r.highlightField=se,r.customHighlight=ie,r.interval=ae,r.aggregations=oe,r.missingLabel=ue,r.showMissing=ce,r.execute=fe,r.enableSynonyms=de,r.selectAllLabel=pe,r.pagination=ye,r.queryString=ge,r.defaultQuery=he,r.customQuery=le,r.beforeValueChange=p,r.onValueChange=g,r.onResults=v,r.onAggregationData=b,r.onError=_,r.onRequestStatusChange=w,r.onQueryChange=S,r.onMicStatusChange=C,r.enablePopularSuggestions=D,r.showDistinctSuggestions=P,r.stateChanges=new o,r.results=new E(R),r.aggregationData=new O,X?r.setValue(X,{stateChanges:!0}):r.value=X,r}i(t,e);var u=t.prototype;return u.getSuggestionsQuery=function(){return{query:[{id:"DataSearch__suggestions",dataField:g,size:5,value:this.value,defaultQuery:{query:{bool:{minimum_should_match:1,should:[{function_score:{field_value_factor:{field:"count",modifier:"sqrt",missing:1}}},{multi_match:{fields:["key^9","key.autosuggest^1","key.keyword^10"],fuzziness:0,operator:"or",query:this.value,type:"best_fields"}},{multi_match:{fields:["key^9","key.autosuggest^1","key.keyword^10"],operator:"or",query:this.value,type:"phrase"}},{multi_match:{fields:["key^9"],operator:"or",query:this.value,type:"phrase_prefix"}}]}}}}]}},u._applyOptions=function(e,t,r,n){var s;("micStatus"===t&&this.onMicStatusChange&&this.onMicStatusChange(n,r),"query"===t&&this.onQueryChange&&this.onQueryChange(n,r),"value"===t&&this.onValueChange&&this.onValueChange(n,r),"error"===t&&this.onError&&this.onError(n),"results"===t&&this.onResults&&this.onResults(n,r),"aggregationData"===t&&this.onAggregationData&&this.onAggregationData(n,r),"requestStatus"===t&&this.onRequestStatusChange&&this.onRequestStatusChange(n,r),e.triggerDefaultQuery&&this.triggerDefaultQuery(),e.triggerCustomQuery&&this.triggerCustomQuery(),!1!==e.stateChanges)&&this.stateChanges.next(((s={})[t]={prev:r,next:n},s),t)},u._fetchRequest=function(e,t){var r=this;void 0===t&&(t=!1);var n={method:"POST",body:JSON.stringify(e),headers:s({},this.headers)};return new Promise((function(e,i){r._handleTransformRequest(n).then((function(n){var a=Date.now(),o=t?".suggestions":r.index;return fetch(r.url+"/"+o+"/_reactivesearch.v3",n).then((function(t){var n=t.headers;if(t.headers){var o=t.headers.get("X-Search-Id");o&&(r._parent?r._parent.setQueryID(o):r.setQueryID(o))}return t.status>=500||t.status>=400?i(t):t.json().then((function(t){r._handleTransformResponse(t).then((function(t){t&&Object.prototype.hasOwnProperty.call(t,"error")&&i(t);var r=s({},t,{_timestamp:a,_headers:n});return e(r)})).catch((function(e){return console.warn("SearchBase: transformResponse rejected the promise with ",e),i(e)}))}))})).catch((function(e){return i(e)}))})).catch((function(e){return console.warn("SearchBase: transformRequest rejected the promise with ",e),i(e)}))}))},u._generateQuery=function(){var e=this;if(this._parent){var t=this._parent.getComponents(),r=[];Object.keys(t).forEach((function(n){var s=t[n];s&&s.react&&(w(s.react,n).indexOf(e.id)>-1&&r.push(n))}));var n={};return r.forEach((function(t){var r=e._parent.getComponent(t);r&&(n[t]=r.componentQuery,w(r.react,r.id).forEach((function(t){if(!n[t]){var r=e._parent.getComponent(t);if(r&&r.value){var s=r.componentQuery;s.execute=!1,n[t]=s}}})))})),{requestBody:Object.values(n),orderOfQueries:r}}return{requestBody:[],orderOfQueries:[]}},u._handleTransformResponse=function(e){return this.transformResponse&&"function"==typeof this.transformResponse?this.transformResponse(e):new Promise((function(t){return t(e)}))},u._handleTransformRequest=function(e){return this.transformRequest&&"function"==typeof this.transformRequest?this.transformRequest(e):new Promise((function(t){return t(e)}))},u._handleAggregationResponse=function(e,t){void 0===t&&(t=F);var r=this.aggregationField;r||"string"!=typeof this.dataField||(r=this.dataField);var n=this.aggregationData;this.aggregationData.setRaw(e[r]),this.aggregationData.setData(r,e[r].buckets),this._applyOptions({stateChanges:t.stateChanges},"aggregationData",n,this.aggregationData)},u._setError=function(e,t){void 0===t&&(t=F),this._setRequestStatus(P);var r=this.error;this.error=e,this._applyOptions(t,"error",r,this.error)},u._setRequestStatus=function(e){var t=this.requestStatus;this.requestStatus=e,this._applyOptions({stateChanges:!0},"requestStatus",t,this.requestStatus)},u._updateQuery=function(e){var t,r=this;t=s({},this._query);var n=[this.componentQuery];w(this.react,this.id).forEach((function(e){var t=r._parent.getComponent(e);if(t&&t.value){var s=t.componentQuery;s.execute=!1,n.push(s)}})),this._query=e||n,this._applyOptions({stateChanges:!1},"query",t,this._query)},r(t,[{key:"micStatus",get:function(){return this._micStatus}},{key:"micInstance",get:function(){return this._micInstance}},{key:"micActive",get:function(){return this._micStatus===x}},{key:"micInactive",get:function(){return this._micStatus===I}},{key:"micDenied",get:function(){return this._micStatus===k}},{key:"query",get:function(){return this._query}},{key:"requestPending",get:function(){return this.requestStatus===j}},{key:"appbaseSettings",get:function(){var e=this.appbaseConfig||{};return{recordAnalytics:e.recordAnalytics,customEvents:e.customEvents,enableQueryRules:e.enableQueryRules,userId:e.userId}}},{key:"suggestions",get:function(){if(this.type&&this.type!==m)return[];if(this.results){var e=b(this.dataField)||[];return 0===e.length&&this.results.data&&Array.isArray(this.results.data)&&this.results.data.length>0&&this.results.data[0]&&this.results.data[0]._source&&(e=Object.keys(this.results.data[0]._source)),this.enablePopularSuggestions&&(e=[].concat(e,g)),function(e,t,r,n){void 0===e&&(e=[]),void 0===r&&(r=""),void 0===n&&(n=!0);var i=[],a=[],o=!1,u=r||"",c=function(e,t,r){if((o||u.trim().split(" ").some((function(t){return String(e).toLowerCase().includes(t)})))&&!a.includes(e)||r._promoted){var c=s({},{label:e,value:e,source:r});if(a=[].concat(a,[e]),i=[].concat(i,[c]),n)return!0}return!1},h=function e(t,r,s){if(void 0===r&&(r=""),void 0===s&&(s=t),"object"==typeof t){var i=r.split("."),a=t[i[0]];if(a)if(i.length>1){var o=r.substring(i[0].length+1);Array.isArray(a)?a.forEach((function(t){e(t,o,s)})):e(a,o,s)}else{var u=S(a);if(u){if(Array.isArray(u)){if(n)return u.some((function(e){return c(e,0,s)}));u.forEach((function(e){return c(e,0,s)}))}return c(u,0,s)}}}return!1},l=function(){n?t.forEach((function(t){e.some((function(e){return h(t,e)}))})):t.forEach((function(t){e.forEach((function(e){h(t,e)}))}))};return l(),i.length<t.length&&!o&&(o=!0,l()),i}(e,this.results.data,this.value,this.showDistinctSuggestions).slice(0,this.size)}return[]}},{key:"componentQuery",get:function(){return{id:this.id,type:this.type,dataField:b(this.dataField),react:this.react,highlight:this.highlight,highlightField:b(this.highlightField),fuzziness:this.fuzziness,searchOperators:this.searchOperators,includeFields:this.includeFields,excludeFields:this.excludeFields,size:this.size,from:this.from,queryFormat:this.queryFormat,sortBy:this.sortBy,fieldWeights:_(this.dataField),includeNullValues:this.includeNullValues,aggregationField:this.aggregationField,categoryField:this.categoryField,missingLabel:this.missingLabel,showMissing:this.showMissing,nestedField:this.nestedField,interval:this.interval,customHighlight:this.customHighlight,customQuery:this.customQuery?this.customQuery(this):void 0,defaultQuery:this.defaultQuery?this.defaultQuery(this):void 0,value:this.value,categoryValue:this.categoryValue,after:this.after,aggregations:this.aggregations,enableSynonyms:this.enableSynonyms,selectAllLabel:this.selectAllLabel,pagination:this.pagination,queryString:this.queryString}}},{key:"queryId",get:function(){return this._parent&&this._parent._queryId?this._parent._queryId:this._queryId?this._queryId:""}},{key:"mappedProps",get:function(){var e=this,t={};return Object.keys(C).forEach((function(r){t[C[r]]=e[r]})),t}}]),t}(R),T=function(e){function t(t){var r,i=t.index,o=t.url,u=t.credentials,c=t.headers,h=t.appbaseConfig;return n(a(r=e.call(this,{index:i,url:o,credentials:u,headers:c,appbaseConfig:h})||this),"register",(function(e,t){if(!e)throw new Error(y.invalidComponentId);var n=t;return!t||t instanceof B?n.id=e:n=new B(s({},t,{id:e,index:t.index||r.index,url:t.url||r.url,credentials:t.credentials||r.credentials,headers:t.headers||r.headers,transformRequest:t.transformRequest||r.transformRequest,transformResponse:t.transformResponse||r.transformResponse,appbaseConfig:t.appbaseConfig||r.appbaseConfig})),r._components[e]=n,n.setParent(a(r)),n})),n(a(r),"unregister",(function(e){e&&delete r._components[e]})),n(a(r),"getComponent",(function(e){return r._components[e]})),n(a(r),"getComponents",(function(){return r._components})),r._components={},r}return i(t,e),t}(R);e.SearchBase=T,e.SearchComponent=B,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Searchbase={})}(this,(function(e){"use strict";function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var o=function(){function e(){this.observers=[]}var t=e.prototype;return t.subscribe=function(e,t){this.observers.push({callback:e,properties:t})},t.unsubscribe=function(e){this.observers=e?this.observers.filter((function(t){return t.callback!==e?t:null})):[]},t.next=function(e,t,r){var n=r||window;this.observers.forEach((function(r){(void 0===r.properties||r.properties instanceof Array&&r.properties.length&&r.properties.includes(t)||"string"==typeof r.properties&&r.properties&&r.properties===t)&&r.callback.call(n,e)}))},e}(),u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var c=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){var r=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:u);!function(e){!function(t){var r="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,s="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,a="ArrayBuffer"in e;if(a)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(e){return e&&o.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function h(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function y(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():a&&s&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(e)||u(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var e,t,r,n=d(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=p(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(_)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(e,t){e=c(e),t=h(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},f.prototype.delete=function(e){delete this.map[c(e)]},f.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},f.prototype.set=function(e,t){this.map[c(e)]=h(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),l(e)},f.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),l(e)},f.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),l(e)},n&&(f.prototype[Symbol.iterator]=f.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(e,t){var r,n,s=(t=t||{}).body;if(e instanceof b){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,s||null==e._bodyInit||(s=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(r=t.method||this.method||"GET",n=r.toUpperCase(),v.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function _(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(s))}})),t}function w(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},m.call(b.prototype),m.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},w.error=function(){var e=new w(null,{status:0,statusText:""});return e.type="error",e};var S=[301,302,303,307,308];w.redirect=function(e,t){if(-1===S.indexOf(t))throw new RangeError("Invalid status code");return new w(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function q(e,r){return new Promise((function(n,i){var a=new b(e,r);if(a.signal&&a.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function u(){o.abort()}o.onload=function(){var e,t,r={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var s=r.join(":").trim();t.append(n,s)}})),t)};r.url="responseURL"in o?o.responseURL:r.headers.get("X-Request-URL");var s="response"in o?o.response:o.responseText;n(new w(s,r))},o.onerror=function(){i(new TypeError("Network request failed"))},o.ontimeout=function(){i(new TypeError("Network request failed"))},o.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},o.open(a.method,a.url,!0),"include"===a.credentials?o.withCredentials=!0:"omit"===a.credentials&&(o.withCredentials=!1),"responseType"in o&&s&&(o.responseType="blob"),a.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),a.signal&&(a.signal.addEventListener("abort",u),o.onreadystatechange=function(){4===o.readyState&&a.signal.removeEventListener("abort",u)}),o.send(void 0===a._bodyInit?null:a._bodyInit)}))}q.polyfill=!0,e.fetch||(e.fetch=q,e.Headers=f,e.Request=b,e.Response=w),t.Headers=f,t.Request=b,t.Response=w,t.fetch=q}({})}(r),delete r.fetch.polyfill,(t=r.fetch).default=r.fetch,t.fetch=r.fetch,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,e.exports=t}));c.fetch,c.Headers,c.Request,c.Response;function h(){return(h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e){void 0===e&&(e="");for(var t,r=e,n="",s=0,i=0,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|i)||(a="=",i%1);n+=a.charAt(63&s>>8-i%1*8)){if((t=r.charCodeAt(i+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');s=s<<8|t}return n}function f(e,t){if(null==e&&!t)throw new Error("appbase-analytics: query or queryID must be present to register a click/conversion event")}var d={init:function(e){void 0===e&&(e={});var t={credentials:e.credentials,index:e.index,url:e.url,userID:e.userID,globalEventData:e.globalEventData,queryID:"",headers:null};return function(e){if(!e)throw new Error("appbase-analytics: A valid index must be present to record analytics events.")}(t.index),function(e){if(!e)throw new Error("appbase-analytics: Auth credentials is missing.")}(t.credentials),function(e){if(!e)throw new Error("appbase-analytics: URL is missing.")}(t.url),t._request=function(e,r,n){var s=h({},r,{user_id:t.userID,event_data:h({},r&&r.event_data,{},t.globalEventData)});return c(t.url+"/"+t.index+"/_analytics/"+e,{method:"PUT",headers:h({},t.headers,{"Content-Type":"application/json",Authorization:"Basic "+l(t.credentials)}),body:JSON.stringify(s)}).then((function(e){n&&n(null,e)})).catch((function(e){console.error(e),n&&n(e,null)}))},t.search=function(e,r){f(e.query,e.queryID);if(t._request){var n={query:e.query,query_id:e.queryID,event_data:e.eventData,filters:e.filters,hits:e.hits};t._request("search",n,(function(e,n){n&&n.json().then((function(e){e&&e.query_id&&(t.queryID=e.query_id)})).catch((function(e){console.error(e)})),r&&r(e,n)}))}},t.click=function(e,r){if(f(e.query,e.queryID),function(e){if(!e||Object.keys(e).length<1)throw new Error("appbase-analytics: at least one click object must be present to register a click event")}(e.objects),t._request){var n={click_on:e.objects,click_type:e.isSuggestionClick?"suggestion":"result",query:e.query,query_id:e.queryID,event_data:e.eventData};t._request("click",n,r)}},t.conversion=function(e,r){if(f(e.query,e.queryID),function(e){if(!e||Object.keys(e).length<1)throw new Error("appbase-analytics: at least one click object must be present to register a click event")}(e.objects),t._request){var n={conversion_on:e.objects,query:e.query,query_id:e.queryID,event_data:e.eventData};t._request("conversion",n,r)}},t.setUserID=function(e){t.userID=e},t.setGlobalEventData=function(e){t.globalEventData=e},t.setHeaders=function(e){t.headers=e},t}};function p(e){return"SearchBase: "+e}var y={invalidIndex:p("Please provide a valid index."),invalidURL:p("Please provide a valid url."),invalidComponentId:p("Please provide component id."),invalidDataField:p("Please provide data field."),dataFieldAsArray:p("Only components with `search` type supports the multiple data fields. Please define `dataField` as a string.")},g=["key","key.autosuggest"],m="search",v=function(e){var t=[];return e&&(t=[].concat(e).map((function(e){var t=function(e){var t=s({},e);return t.highlight&&Object.keys(t.highlight).forEach((function(e){var r,n=t.highlight[e][0];t._source=s({},t._source,((r={})[e]=n,r))})),t}(e);return Object.keys(t).filter((function(e){return"_source"!==e})).reduce((function(e,r){return e[r]=t[r],e}),s({},t._source))}))),t},b=function(e){if(e){if(!Array.isArray(e))return[e];if(e.length){var t=[];return e.forEach((function(e){"string"==typeof e?t.push(e):e.field&&t.push(e.field)})),t}}};var _=function(e){if(e&&Array.isArray(e)&&e.length){var t=[];return e.forEach((function(e){var r;r=e.weight,!Number.isNaN(parseFloat(r))&&Number.isFinite(r)?t.push(e.weight):t.push(1)})),t}};function w(e,t){var r=[];return function e(t){t&&Object.keys(t)&&Object.keys(t).forEach((function(n){t[n]&&("string"==typeof t[n]?r=[].concat(r,[t[n]]):Array.isArray(t[n])?r=[].concat(r,t[n]):"object"==typeof t[n]&&e(t[n]))}))}(e),r=r.filter((function(e){return e!==t}))}var S=function(e){return"object"==typeof e?Array.isArray(e)?function e(t){return t.reduce((function(t,r){return t.concat(Array.isArray(r)?e(r):r)}),[])}(e):null:e};function q(e,t){if(e===t)return!0;if(!(e instanceof Object&&t instanceof Object))return!1;if(e.constructor!==t.constructor)return!1;for(var r in e)if(e.hasOwnProperty(r)){if(!t.hasOwnProperty(r))return!1;if(e[r]!==t[r]){if("object"!=typeof e[r])return!1;if(!q(e[r],t[r]))return!1}}for(var n in t)if(t.hasOwnProperty(n)&&!e.hasOwnProperty(n))return!1;return!0}var C={id:"id",type:"type",react:"react",queryFormat:"queryFormat",dataField:"dataField",categoryField:"categoryField",categoryValue:"categoryValue",nestedField:"nestedField",from:"from",size:"size",sortBy:"sortBy",value:"value",aggregationField:"aggregationField",after:"after",includeNullValues:"includeNullValues",includeFields:"includeFields",excludeFields:"excludeFields",fuzziness:"fuzziness",searchOperators:"searchOperators",highlight:"highlight",highlightField:"highlightField",customHighlight:"customHighlight",interval:"interval",aggregations:"aggregations",missingLabel:"missingLabel",showMissing:"showMissing",enableSynonyms:"enableSynonyms",selectAllLabel:"selectAllLabel",pagination:"pagination",queryString:"queryString",enablePopularSuggestions:"enablePopularSuggestions",showDistinctSuggestions:"showDistinctSuggestions",error:"error",defaultQuery:"defaultQuery",customQuery:"customQuery",requestStatus:"requestStatus",results:"results",aggregationData:"aggregationData",micStatus:"micStatus",micInstance:"micInstance",micActive:"micActive",micInactive:"micInactive",micDenied:"micDenied",query:"query",requestPending:"loading",appbaseSettings:"appbaseConfig",suggestions:"suggestions",queryId:"queryId",recentSearches:"recentSearches",onMicClick:"handleMicClick",triggerDefaultQuery:"triggerDefaultQuery",triggerCustomQuery:"triggerCustomQuery",recordClick:"recordClick",recordConversions:"recordConversions",subscribeToStateChanges:"subscribeToStateChanges",unsubscribeToStateChanges:"unsubscribeToStateChanges",setDataField:"setDataField",setValue:"setValue",setSize:"setSize",setFrom:"setFrom",setFuzziness:"setFuzziness",setIncludeFields:"setIncludeFields",setExcludeFields:"setExcludeFields",setSortBy:"setSortBy",setReact:"setReact",setDefaultQuery:"setDefaultQuery",setCustomQuery:"setCustomQuery"};function D(e){void 0===e&&(e="");for(var t,r=e,n="",s=0,i=0,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|i)||(a="=",i%1);n+=a.charAt(63&s>>8-i%1*8)){if((t=r.charCodeAt(i+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');s=s<<8|t}return n}var R=function(){function e(e){var t=e.index,r=e.url,n=e.credentials,i=e.headers,a=e.appbaseConfig,o=e.transformRequest,u=e.transformResponse;if(!t)throw new Error(y.invalidIndex);if(!r)throw new Error(y.invalidURL);this.index=t,this.url=r,this.credentials=n||"",a&&(this.appbaseConfig=a),o&&(this.transformRequest=o),u&&(this.transformResponse=u),this.headers={Accept:"application/json","Content-Type":"application/json"},this.credentials&&(this.headers=s({},this.headers,{Authorization:"Basic "+D(this.credentials)})),i&&this.setHeaders(i),this._analyticsInstance=d.init({index:t,url:r,credentials:n})}var t=e.prototype;return t.setHeaders=function(e){this.headers=s({},this.headers,e)},t.setQueryID=function(e){this._queryId=e},e}(),E=function(){function e(e){var t=this;n(this,"setRaw",(function(e){t.raw=e,e.hits&&e.hits.hits&&t.setData(e.hits.hits)})),this.data=e||[]}return e.prototype.setData=function(e){var t,r=v(e);if(this.promotedData.length){var n=this.promotedData.map((function(e){return e._id})).filter(Boolean);n&&(r=r.filter((function(e){return!n.includes(e._id)}))),r=[].concat(this.promotedData.map((function(e){return s({},e,{_promoted:!0})})),r)}this.parseResults?this.data=this.parseResults(r,e):this.data=r,this.data=(void 0===(t=this.data)&&(t=[]),t.map((function(e,t){return s({},e,{_click_id:t+1})})))},r(e,[{key:"numberOfResults",get:function(){return this.raw&&this.raw.hits?"object"==typeof this.raw.hits.total?this.raw.hits.total.value:this.raw.hits.total:0}},{key:"time",get:function(){return this.raw?this.raw.took:0}},{key:"hidden",get:function(){return this.raw&&this.raw.hits&&this.raw.hits.hidden||0}},{key:"promotedData",get:function(){return this.raw&&this.raw.promoted&&this.raw.promoted||[]}},{key:"promoted",get:function(){return this.promotedData.length||0}},{key:"rawData",get:function(){return this.raw||{}}},{key:"customData",get:function(){return this.raw&&this.raw.customData&&this.raw.customData||{}}}]),e}(),A=function(){function e(e){this.data=e||[]}var t=e.prototype;return t.setRaw=function(e){this.raw=e,e.after_key&&this.setAfterKey(e.after_key)},t.setAfterKey=function(e){this.afterKey=e},t.setData=function(e,t){var r,n;this.data=(r=e,void 0===(n=t)&&(n=[]),n.map((function(e){var t=e.doc_count,n=e.key,i=e[r];return s({_doc_count:t,_key:void 0!==n[r]?n[r]:n},i)})))},r(e,[{key:"rawData",get:function(){return this.raw||{}}}]),e}(),O={triggerDefaultQuery:!0,triggerCustomQuery:!1,stateChanges:!0},F={stateChanges:!0},I="INACTIVE",x="ACTIVE",k="DENIED",Q="INACTIVE",j="PENDING",P="ERROR",B=function(e){function t(t){var r,i=t.index,u=t.url,c=t.credentials,h=t.appbaseConfig,l=t.headers,f=t.transformRequest,d=t.transformResponse,p=t.beforeValueChange,g=t.onValueChange,v=t.onResults,b=t.onAggregationData,_=t.onError,w=t.onRequestStatusChange,S=t.onQueryChange,C=t.onMicStatusChange,D=t.enablePopularSuggestions,R=t.results,P=t.showDistinctSuggestions,B=t.preserveResults,T=function(e,t){if(null==e)return{};var r,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(s[r]=e[r]);return s}(t,["index","url","credentials","appbaseConfig","headers","transformRequest","transformResponse","beforeValueChange","onValueChange","onResults","onAggregationData","onError","onRequestStatusChange","onQueryChange","onMicStatusChange","enablePopularSuggestions","results","showDistinctSuggestions","preserveResults"]);n(a(r=e.call(this,{index:i,url:u,credentials:c,headers:l,appbaseConfig:h,transformRequest:f,transformResponse:d})||this),"onMicClick",(function(e,t){void 0===e&&(e={}),void 0===t&&(t={triggerDefaultQuery:!1,triggerCustomQuery:!1,stateChanges:!0});var n=r._micStatus;if("undefined"!=typeof window&&(window.SpeechRecognition=window.webkitSpeechRecognition||window.SpeechRecognition||null),window&&window.SpeechRecognition&&n!==k){n===x&&r._setMicStatus(I,t);var s=window.SpeechRecognition;if(r._micInstance)return void r._stopMic();r._micInstance=new s,r._micInstance.continuous=!0,r._micInstance.interimResults=!0,Object.assign(r._micInstance,e),r._micInstance.start(),r._micInstance.onstart=function(){r._setMicStatus(x,t)},r._micInstance.onresult=function(e){var n=e.results;n&&n[0]&&n[0].isFinal&&r._stopMic(),r._handleVoiceResults({results:n},t)},r._micInstance.onerror=function(e){"no-speech"===e.error||"audio-capture"===e.error?r._setMicStatus(I,t):"not-allowed"===e.error&&r._setMicStatus(k,t),console.error(e)}}})),n(a(r),"setDataField",(function(e,t){void 0===t&&(t=O);var n=r.dataField;r.dataField=e,r._applyOptions(t,"dataField",n,e)})),n(a(r),"setParent",(function(e){r._parent=e})),n(a(r),"setValue",(function(e,t){void 0===t&&(t=O);var n=function(){var n=r.value;r.value=e,r._applyOptions(t,"value",n,r.value)};r.beforeValueChange?r.beforeValueChange(e).then(n).catch((function(e){console.warn("beforeValueChange rejected the promise with ",e)})):n()})),n(a(r),"setSize",(function(e,t){void 0===t&&(t=O);var n=r.size;r.size=e,r._applyOptions(t,"size",n,r.size)})),n(a(r),"setFrom",(function(e,t){void 0===t&&(t=O);var n=r.from;r.from=e,r._applyOptions(t,"from",n,r.from)})),n(a(r),"setFuzziness",(function(e,t){void 0===t&&(t=O);var n=r.fuzziness;r.fuzziness=e,r._applyOptions(t,"fuzziness",n,r.fuzziness)})),n(a(r),"setIncludeFields",(function(e,t){void 0===t&&(t=O);var n=r.includeFields;r.includeFields=e,r._applyOptions(t,"includeFields",n,e)})),n(a(r),"setExcludeFields",(function(e,t){void 0===t&&(t=O);var n=r.excludeFields;r.excludeFields=e,r._applyOptions(t,"excludeFields",n,e)})),n(a(r),"setSortBy",(function(e,t){void 0===t&&(t=O);var n=r.sortBy;r.sortBy=e,r._applyOptions(t,"sortBy",n,e)})),n(a(r),"setReact",(function(e,t){void 0===t&&(t=O);var n=r.react;r.react=e,r._applyOptions(t,"react",n,e)})),n(a(r),"setDefaultQuery",(function(e,t){void 0===t&&(t=O);var n=r.defaultQuery;r.defaultQuery=e,r._applyOptions(t,"defaultQuery",n,e)})),n(a(r),"setCustomQuery",(function(e,t){void 0===t&&(t=O);var n=r.customQuery;r.customQuery=e,r._applyOptions(t,"customQuery",n,e)})),n(a(r),"setAfter",(function(e,t){void 0===t&&(t=O);var n=r.after;r.after=e,r._applyOptions(t,"after",n,e)})),n(a(r),"triggerDefaultQuery",(function(e){if(void 0===e&&(e=F),q(r._query,r.componentQuery))return Promise.resolve(!0);var t=function(t){return r._setError(t,{stateChanges:e.stateChanges}),console.error(t),Promise.reject(t)};try{return r._updateQuery(),r._setRequestStatus(j),r._fetchRequest({query:Array.isArray(r.query)?r.query:[r.query],settings:r.appbaseSettings}).then((function(n){var i=r.results,a=n&&n[r.id],o=function(){a.aggregations&&r._handleAggregationResponse(a.aggregations,s({defaultOptions:O},e)),r._setRequestStatus(Q),r._applyOptions({stateChanges:e.stateChanges},"results",i,r.results)};return r.type&&r.type!==m||!r.enablePopularSuggestions?(r._appendResults(a),o()):r._fetchRequest(r.getSuggestionsQuery(),!0).then((function(e){var t=e.DataSearch__suggestions;t&&t.hits&&t.hits.hits&&a.hits&&a.hits.hits&&(a.hits.hits=[].concat((t.hits.hits||[]).map((function(e){return s({},e,{_popular_suggestion:!0})})),a.hits.hits)),r._appendResults(a),o()})).catch(t),Promise.resolve(a)})).catch(t)}catch(e){return t(e)}})),n(a(r),"triggerCustomQuery",(function(e){void 0===e&&(e=F);var t=r._generateQuery(),n=t.requestBody,i=t.orderOfQueries;if(!n.length)return Promise.resolve({});if(q(r._query,n))return Promise.resolve(!0);var a=function(t){return r._setError(t,{stateChanges:e.stateChanges}),console.error(t),Promise.reject(t)};try{i.forEach((function(e){var t=r._parent.getComponent(e);t&&(t.setFrom(0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1}),t.setAfter(void 0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1}),t._setRequestStatus(j),t._updateQuery())}));var o=r._generateQuery().requestBody;return r._fetchRequest({query:o,settings:r.appbaseSettings}).then((function(t){return i.forEach((function(n){var i=r._parent.getComponent(n);if(i){i._setRequestStatus(Q),i.setValue(void 0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1});var a=i.results,o=t&&t[n];o.hits&&(i.results.setRaw(o),i._applyOptions({stateChanges:e.stateChanges},"results",a,i.results)),o.aggregations&&i._handleAggregationResponse(o.aggregations,s({defaultOptions:O},e))}})),Promise.resolve(t)})).catch(a)}catch(e){return a(e)}})),n(a(r),"recordClick",(function(e,t){void 0===t&&(t=!1),r._analyticsInstance&&r.queryId&&r._analyticsInstance.click({queryID:r.queryId,objects:e,isSuggestionClick:t})})),n(a(r),"recordConversions",(function(e){r._analyticsInstance&&r.queryId&&r._analyticsInstance.conversion({queryID:r.queryId,objects:e})})),n(a(r),"subscribeToStateChanges",(function(e,t){r.stateChanges.subscribe(e,t)})),n(a(r),"unsubscribeToStateChanges",(function(e){r.stateChanges.unsubscribe(e)})),n(a(r),"clearResults",(function(e){void 0===e&&(e=F);var t=r.results;r.results.setRaw({hits:{hits:[]}}),r._applyOptions({stateChanges:e.stateChanges},"results",t,r.results)})),n(a(r),"getRecentSearches",(function(e,t){void 0===e&&(e={size:5,minChars:3}),void 0===t&&(t=F);var n={headers:s({},r.headers)},i="",a=function(e,t){i+=i?"&"+e+"="+t:e+"="+t};return r.appbaseSettings&&r.appbaseSettings.userId&&a("user_id",r.appbaseSettings.userId),e&&(e.size&&a("size",String(e.size)),e.from&&a("from",e.from),e.to&&a("to",e.to),e.minChars&&a("min_chars",String(e.minChars)),e.customEvents&&Object.keys(e.customEvents).forEach((function(t){a(t,e.customEvents[t])}))),new Promise((function(e,s){fetch(r.url+"/_analytics/"+r.index+"/recent-searches?"+i,n).then((function(e){return e.status>=500||e.status>=400?s(e):e.json().then((function(e){var n=r.recentSearches;r.recentSearches=e.map((function(e){return{label:e.key,value:e.key}})),r._applyOptions({stateChanges:t.stateChanges},"recentSearches",n,r.recentSearches)})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),s(e)}))})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),s(e)}))}))})),n(a(r),"_handleVoiceResults",(function(e,t){var n=e.results;void 0===t&&(t=O),n&&n[0]&&n[0].isFinal&&n[0][0]&&n[0][0].transcript&&n[0][0].transcript.trim()&&r.setValue(n[0][0].transcript.trim(),s({},t,{triggerCustomQuery:!0,triggerDefaultQuery:!0}))})),n(a(r),"_stopMic",(function(){r._micInstance&&(r._micInstance.stop(),r._micInstance=null,r._setMicStatus(I))})),n(a(r),"_setMicStatus",(function(e,t){void 0===t&&(t=O);var n=r._micStatus;r._micStatus=e,r._applyOptions(t,"micStatus",n,r._micStatus)}));var z=T.id,M=T.type,V=T.react,L=T.queryFormat,U=T.dataField,N=T.categoryField,H=T.categoryValue,G=T.nestedField,K=T.from,J=T.size,X=T.sortBy,W=T.value,Y=T.aggregationField,Z=T.after,$=T.includeNullValues,ee=T.includeFields,te=T.excludeFields,re=T.fuzziness,ne=T.searchOperators,se=T.highlight,ie=T.highlightField,ae=T.customHighlight,oe=T.interval,ue=T.aggregations,ce=T.missingLabel,he=T.showMissing,le=T.defaultQuery,fe=T.customQuery,de=T.execute,pe=T.enableSynonyms,ye=T.selectAllLabel,ge=T.pagination,me=T.queryString;if(!z)throw new Error(y.invalidComponentId);if(M&&M!==m){if(!U)throw new Error(y.invalidDataField);if(Array.isArray(U))throw new Error(y.dataFieldAsArray)}return r.id=z,r.type=M,r.react=V,r.queryFormat=L,r.dataField=U,r.categoryField=N,r.categoryValue=H,r.nestedField=G,r.from=K,r.size=J,r.sortBy=X,r.aggregationField=Y,r.after=Z,r.includeNullValues=$,r.includeFields=ee,r.excludeFields=te,r.fuzziness=re,r.searchOperators=ne,r.highlight=se,r.highlightField=ie,r.customHighlight=ae,r.interval=oe,r.aggregations=ue,r.missingLabel=ce,r.showMissing=he,r.execute=de,r.enableSynonyms=pe,r.selectAllLabel=ye,r.pagination=ge,r.queryString=me,r.defaultQuery=le,r.customQuery=fe,r.beforeValueChange=p,r.onValueChange=g,r.onResults=v,r.onAggregationData=b,r.onError=_,r.onRequestStatusChange=w,r.onQueryChange=S,r.onMicStatusChange=C,r.enablePopularSuggestions=D,r.showDistinctSuggestions=P,r.preserveResults=B,r.stateChanges=new o,r.results=new E(R),r.aggregationData=new A,W?r.setValue(W,{stateChanges:!0}):r.value=W,r}i(t,e);var u=t.prototype;return u.getSuggestionsQuery=function(){return{query:[{id:"DataSearch__suggestions",dataField:g,size:5,value:this.value,defaultQuery:{query:{bool:{minimum_should_match:1,should:[{function_score:{field_value_factor:{field:"count",modifier:"sqrt",missing:1}}},{multi_match:{fields:["key^9","key.autosuggest^1","key.keyword^10"],fuzziness:0,operator:"or",query:this.value,type:"best_fields"}},{multi_match:{fields:["key^9","key.autosuggest^1","key.keyword^10"],operator:"or",query:this.value,type:"phrase"}},{multi_match:{fields:["key^9"],operator:"or",query:this.value,type:"phrase_prefix"}}]}}}}]}},u._appendResults=function(e){this.preserveResults&&e&&Array.isArray(e.hits&&e.hits.hits)&&Array.isArray(this.results.rawData&&this.results.rawData.hits&&this.results.rawData.hits.hits)?this.results.setRaw(s({},e,{hits:s({},e.hits,{hits:[].concat(this.results.rawData.hits.hits,e.hits.hits)})})):this.results.setRaw(e)},u._applyOptions=function(e,t,r,n){var s;("micStatus"===t&&this.onMicStatusChange&&this.onMicStatusChange(n,r),"query"===t&&this.onQueryChange&&this.onQueryChange(n,r),"value"===t&&this.onValueChange&&this.onValueChange(n,r),"error"===t&&this.onError&&this.onError(n),"results"===t&&this.onResults&&this.onResults(n,r),"aggregationData"===t&&this.onAggregationData&&this.onAggregationData(n,r),"requestStatus"===t&&this.onRequestStatusChange&&this.onRequestStatusChange(n,r),e.triggerDefaultQuery&&this.triggerDefaultQuery(),e.triggerCustomQuery&&this.triggerCustomQuery(),!1!==e.stateChanges)&&this.stateChanges.next(((s={})[t]={prev:r,next:n},s),t)},u._fetchRequest=function(e,t){var r=this;void 0===t&&(t=!1);var n={method:"POST",body:JSON.stringify(e),headers:s({},this.headers)};return new Promise((function(e,i){r._handleTransformRequest(n).then((function(n){var a=Date.now(),o=t?".suggestions":r.index;return fetch(r.url+"/"+o+"/_reactivesearch.v3",n).then((function(t){var n=t.headers;if(t.headers){var o=t.headers.get("X-Search-Id");o&&(r._parent?r._parent.setQueryID(o):r.setQueryID(o))}return t.status>=500||t.status>=400?i(t):t.json().then((function(t){r._handleTransformResponse(t).then((function(t){t&&Object.prototype.hasOwnProperty.call(t,"error")&&i(t);var r=s({},t,{_timestamp:a,_headers:n});return e(r)})).catch((function(e){return console.warn("SearchBase: transformResponse rejected the promise with ",e),i(e)}))}))})).catch((function(e){return i(e)}))})).catch((function(e){return console.warn("SearchBase: transformRequest rejected the promise with ",e),i(e)}))}))},u._generateQuery=function(){var e=this;if(this._parent){var t=this._parent.getComponents(),r=[];Object.keys(t).forEach((function(n){var s=t[n];s&&s.react&&(w(s.react,n).indexOf(e.id)>-1&&r.push(n))}));var n={};return r.forEach((function(t){var r=e._parent.getComponent(t);r&&(n[t]=r.componentQuery,w(r.react,r.id).forEach((function(t){if(!n[t]){var r=e._parent.getComponent(t);if(r&&r.value){var s=r.componentQuery;s.execute=!1,n[t]=s}}})))})),{requestBody:Object.values(n),orderOfQueries:r}}return{requestBody:[],orderOfQueries:[]}},u._handleTransformResponse=function(e){return this.transformResponse&&"function"==typeof this.transformResponse?this.transformResponse(e):new Promise((function(t){return t(e)}))},u._handleTransformRequest=function(e){return this.transformRequest&&"function"==typeof this.transformRequest?this.transformRequest(e):new Promise((function(t){return t(e)}))},u._handleAggregationResponse=function(e,t){void 0===t&&(t=O);var r=this.aggregationField;r||"string"!=typeof this.dataField||(r=this.dataField);var n=this.aggregationData;this.aggregationData.setRaw(e[r]),this.aggregationData.setData(r,e[r].buckets),this._applyOptions({stateChanges:t.stateChanges},"aggregationData",n,this.aggregationData)},u._setError=function(e,t){void 0===t&&(t=O),this._setRequestStatus(P);var r=this.error;this.error=e,this._applyOptions(t,"error",r,this.error)},u._setRequestStatus=function(e){var t=this.requestStatus;this.requestStatus=e,this._applyOptions({stateChanges:!0},"requestStatus",t,this.requestStatus)},u._updateQuery=function(e){var t,r=this;t=s({},this._query);var n=[this.componentQuery];w(this.react,this.id).forEach((function(e){var t=r._parent.getComponent(e);if(t&&t.value){var s=t.componentQuery;s.execute=!1,n.push(s)}})),this._query=e||n,this._applyOptions({stateChanges:!1},"query",t,this._query)},r(t,[{key:"micStatus",get:function(){return this._micStatus}},{key:"micInstance",get:function(){return this._micInstance}},{key:"micActive",get:function(){return this._micStatus===x}},{key:"micInactive",get:function(){return this._micStatus===I}},{key:"micDenied",get:function(){return this._micStatus===k}},{key:"query",get:function(){return this._query}},{key:"requestPending",get:function(){return this.requestStatus===j}},{key:"appbaseSettings",get:function(){var e=this.appbaseConfig||{};return{recordAnalytics:e.recordAnalytics,customEvents:e.customEvents,enableQueryRules:e.enableQueryRules,userId:e.userId}}},{key:"suggestions",get:function(){if(this.type&&this.type!==m)return[];if(this.results){var e=b(this.dataField)||[];return 0===e.length&&this.results.data&&Array.isArray(this.results.data)&&this.results.data.length>0&&this.results.data[0]&&this.results.data[0]._source&&(e=Object.keys(this.results.data[0]._source)),this.enablePopularSuggestions&&(e=[].concat(e,g)),function(e,t,r,n){void 0===e&&(e=[]),void 0===r&&(r=""),void 0===n&&(n=!0);var i=[],a=[],o=!1,u=r||"",c=function(e,t,r){if((o||u.trim().split(" ").some((function(t){return String(e).toLowerCase().includes(t)})))&&!a.includes(e)||r._promoted){var c=s({},{label:e,value:e,source:r});if(a=[].concat(a,[e]),i=[].concat(i,[c]),n)return!0}return!1},h=function e(t,r,s){if(void 0===r&&(r=""),void 0===s&&(s=t),"object"==typeof t){var i=r.split("."),a=t[i[0]];if(a)if(i.length>1){var o=r.substring(i[0].length+1);Array.isArray(a)?a.forEach((function(t){e(t,o,s)})):e(a,o,s)}else{var u=S(a);if(u){if(Array.isArray(u)){if(n)return u.some((function(e){return c(e,0,s)}));u.forEach((function(e){return c(e,0,s)}))}return c(u,0,s)}}}return!1},l=function(){n?t.forEach((function(t){e.some((function(e){return h(t,e)}))})):t.forEach((function(t){e.forEach((function(e){h(t,e)}))}))};return l(),i.length<t.length&&!o&&(o=!0,l()),i}(e,this.results.data,this.value,this.showDistinctSuggestions).slice(0,this.size)}return[]}},{key:"componentQuery",get:function(){return{id:this.id,type:this.type,dataField:b(this.dataField),react:this.react,highlight:this.highlight,highlightField:b(this.highlightField),fuzziness:this.fuzziness,searchOperators:this.searchOperators,includeFields:this.includeFields,excludeFields:this.excludeFields,size:this.size,from:this.from,queryFormat:this.queryFormat,sortBy:this.sortBy,fieldWeights:_(this.dataField),includeNullValues:this.includeNullValues,aggregationField:this.aggregationField,categoryField:this.categoryField,missingLabel:this.missingLabel,showMissing:this.showMissing,nestedField:this.nestedField,interval:this.interval,customHighlight:this.customHighlight,customQuery:this.customQuery?this.customQuery(this):void 0,defaultQuery:this.defaultQuery?this.defaultQuery(this):void 0,value:this.value,categoryValue:this.categoryValue,after:this.after,aggregations:this.aggregations,enableSynonyms:this.enableSynonyms,selectAllLabel:this.selectAllLabel,pagination:this.pagination,queryString:this.queryString}}},{key:"queryId",get:function(){return this._parent&&this._parent._queryId?this._parent._queryId:this._queryId?this._queryId:""}},{key:"mappedProps",get:function(){var e=this,t={};return Object.keys(C).forEach((function(r){t[C[r]]=e[r]})),t}}]),t}(R),T=function(e){function t(t){var r,i=t.index,o=t.url,u=t.credentials,c=t.headers,h=t.appbaseConfig;return n(a(r=e.call(this,{index:i,url:o,credentials:u,headers:c,appbaseConfig:h})||this),"register",(function(e,t){if(!e)throw new Error(y.invalidComponentId);if(r._components[e])return r._components[e];var n=t;return!t||t instanceof B?n.id=e:n=new B(s({},t,{id:e,index:t.index||r.index,url:t.url||r.url,credentials:t.credentials||r.credentials,headers:t.headers||r.headers,transformRequest:t.transformRequest||r.transformRequest,transformResponse:t.transformResponse||r.transformResponse,appbaseConfig:t.appbaseConfig||r.appbaseConfig})),r._components[e]=n,n.setParent(a(r)),n})),n(a(r),"unregister",(function(e){e&&delete r._components[e]})),n(a(r),"getComponent",(function(e){return r._components[e]})),n(a(r),"getComponents",(function(){return r._components})),r._components={},r}return i(t,e),t}(R);e.SearchBase=T,e.SearchComponent=B,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=searchbase.umd.min.js.map

@@ -84,2 +84,5 @@ import * as types from './types';

// To preserve the results state
preserveResults: boolean;
// query error

@@ -86,0 +89,0 @@ error: any;

{
"name": "@appbaseio/searchbase",
"version": "1.0.3",
"version": "1.0.4",
"private": false,

@@ -5,0 +5,0 @@ "description": "Headless core + common utilities for search",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc