1function W(e){const t=`algoliasearch-client-js-${e.key}`;let r;const n=()=>(r===void 0&&(r=e.localStorage||window.localStorage),r),s=()=>JSON.parse(n().getItem(t)||"{}"),a=o=>{n().setItem(t,JSON.stringify(o))},u=()=>{const o=e.timeToLive?e.timeToLive*1e3:null,d=s(),h=Object.fromEntries(Object.entries(d).filter(([,c])=>c.timestamp!==void 0));if(a(h),!o)return;const l=Object.fromEntries(Object.entries(h).filter(([,c])=>{const m=new Date().getTime();return!(c.timestamp+o<m)}));a(l)};return{get(o,d,h={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>{u();const l=JSON.stringify(o);return s()[l]}).then(l=>Promise.all([l?l.value:d(),l!==void 0])).then(([l,c])=>Promise.all([l,c||h.miss(l)])).then(([l])=>l)},set(o,d){return Promise.resolve().then(()=>{const h=s();return h[JSON.stringify(o)]={timestamp:new Date().getTime(),value:d},n().setItem(t,JSON.stringify(h)),d})},delete(o){return Promise.resolve().then(()=>{const d=s();delete d[JSON.stringify(o)],n().setItem(t,JSON.stringify(d))})},clear(){return Promise.resolve().then(()=>{n().removeItem(t)})}}}function T(e){const t=[...e.caches],r=t.shift();return r===void 0?M():{get(n,s,a={miss:()=>Promise.resolve()}){return r.get(n,s,a).catch(()=>T({caches:t}).get(n,s,a))},set(n,s){return r.set(n,s).catch(()=>T({caches:t}).set(n,s))},delete(n){return r.delete(n).catch(()=>T({caches:t}).delete(n))},clear(){return r.clear().catch(()=>T({caches:t}).clear())}}}function M(){return{get(e,t,r={miss:()=>Promise.resolve()}){return t().then(s=>Promise.all([s,r.miss(s)])).then(([s])=>s)},set(e,t){return Promise.resolve(t)},delete(e){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(e={serializable:!0}){let t={};return{get(r,n,s={miss:()=>Promise.resolve()}){const a=JSON.stringify(r);if(a in t)return Promise.resolve(e.serializable?JSON.parse(t[a]):t[a]);const u=n(),o=s&&s.miss||(()=>Promise.resolve());return u.then(d=>o(d)).then(()=>u)},set(r,n){return t[JSON.stringify(r)]=e.serializable?JSON.stringify(n):n,Promise.resolve(n)},delete(r){return delete t[JSON.stringify(r)],Promise.resolve()},clear(){return t={},Promise.resolve()}}}function L(e,t,r){const n={"x-algolia-api-key":r,"x-algolia-application-id":t};return{headers(){return e===v.WithinHeaders?n:{}},queryParameters(){return e===v.WithinQueryParameters?n:{}}}}function Q(e){let t=e.length-1;for(t;t>0;t--){const r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}function q(e,t){return t&&Object.keys(t).forEach(r=>{e[r]=t[r](e)}),e}function C(e,...t){let r=0;return e.replace(/%s/g,()=>encodeURIComponent(t[r++]))}const N="4.20.0",v={WithinQueryParameters:0,WithinHeaders:1};function x(e,t){const r=e||{},n=r.data||{};return Object.keys(r).forEach(s=>{["timeout","headers","queryParameters","data","cacheable"].indexOf(s)===-1&&(n[s]=r[s])}),{data:Object.entries(n).length>0?n:void 0,timeout:r.timeout||t,headers:r.headers||{},queryParameters:r.queryParameters||{},cacheable:r.cacheable}}const b={Read:1,Write:2,Any:3},S={Up:1,Down:2,Timeouted:3},D=2*60*1e3;function J(e,t=S.Up){return{...e,status:t,lastUpdate:Date.now()}}function G(e){return e.status===S.Up||Date.now()-e.lastUpdate>D}function _(e){return e.status===S.Timeouted&&Date.now()-e.lastUpdate<=D}function U(e){return typeof e=="string"?{protocol:"https",url:e,accept:b.Any}:{protocol:e.protocol||"https",url:e.url,accept:e.accept||b.Any}}const y={Delete:"DELETE",Get:"GET",Post:"POST",Put:"PUT"};function B(e,t){return Promise.all(t.map(r=>e.get(r,()=>Promise.resolve(J(r))))).then(r=>{const n=r.filter(o=>G(o)),s=r.filter(o=>_(o)),a=[...n,...s],u=a.length>0?a.map(o=>U(o)):t;return{getTimeout(o,d){return(s.length===0&&o===0?1:s.length+3+o)*d},statelessHosts:u}})}const V=({isTimedOut:e,status:t})=>!e&&~~t===0,X=e=>{const t=e.status;return e.isTimedOut||V(e)||~~(t/100)!==2&&~~(t/100)!==4},K=({status:e})=>~~(e/100)===2,Y=(e,t)=>X(e)?t.onRetry(e):K(e)?t.onSuccess(e):t.onFail(e);function R(e,t,r,n){const s=[],a=se(r,n),u=ae(e,n),o=r.method,d=r.method!==y.Get?{}:{...r.data,...n.data},h={"x-algolia-agent":e.userAgent.value,...e.queryParameters,...d,...n.queryParameters};let l=0;const c=(m,g)=>{const f=m.pop();if(f===void 0)throw ie(I(s));const O={data:a,headers:u,method:o,url:ne(f,r.path,h),connectTimeout:g(l,e.timeouts.connect),responseTimeout:g(l,n.timeout)},A=i=>{const P={request:O,response:i,host:f,triesLeft:m.length};return s.push(P),P},p={onSuccess:i=>te(i),onRetry(i){const P=A(i);return i.isTimedOut&&l++,Promise.all([e.logger.info("Retryable failure",z(P)),e.hostsCache.set(f,J(f,i.isTimedOut?S.Timeouted:S.Down))]).then(()=>c(m,g))},onFail(i){throw A(i),re(i,I(s))}};return e.requester.send(O).then(i=>Y(i,p))};return B(e.hostsCache,t).then(m=>c([...m.statelessHosts].reverse(),m.getTimeout))}function Z(e){const{hostsCache:t,logger:r,requester:n,requestsCache:s,responsesCache:a,timeouts:u,userAgent:o,hosts:d,queryParameters:h,headers:l}=e,c={hostsCache:t,logger:r,requester:n,requestsCache:s,responsesCache:a,timeouts:u,userAgent:o,headers:l,queryParameters:h,hosts:d.map(m=>U(m)),read(m,g){const f=x(g,c.timeouts.read),O=()=>R(c,c.hosts.filter(i=>(i.accept&b.Read)!==0),m,f);if((f.cacheable!==void 0?f.cacheable:m.cacheable)!==!0)return O();const p={request:m,mappedRequestOptions:f,transporter:{queryParameters:c.queryParameters,headers:c.headers}};return c.responsesCache.get(p,()=>c.requestsCache.get(p,()=>c.requestsCache.set(p,O()).then(i=>Promise.all([c.requestsCache.delete(p),i]),i=>Promise.all([c.requestsCache.delete(p),Promise.reject(i)])).then(([i,P])=>P)),{miss:i=>c.responsesCache.set(p,i)})},write(m,g){return R(c,c.hosts.filter(f=>(f.accept&b.Write)!==0),m,x(g,c.timeouts.write))}};return c}function ee(e){const t={value:`Algolia for JavaScript (${e})`,add(r){const n=`; ${r.segment}${r.version!==void 0?` (${r.version})`:""}`;return t.value.indexOf(n)===-1&&(t.value=`${t.value}${n}`),t}};return t}function te(e){try{return JSON.parse(e.content)}catch(t){throw ce(t.message,e)}}function re({content:e,status:t},r){let n=e;try{n=JSON.parse(e).message}catch{}return oe(n,t,r)}function ne(e,t,r){const n=k(r);let s=`${e.protocol}://${e.url}/${t.charAt(0)==="/"?t.substr(1):t}`;return n.length&&(s+=`?${n}`),s}function k(e){const t=r=>Object.prototype.toString.call(r)==="[object Object]"||Object.prototype.toString.call(r)==="[object Array]";return Object.keys(e).map(r=>C("%s=%s",r,t(e[r])?JSON.stringify(e[r]):e[r])).join("&")}function se(e,t){if(e.method===y.Get||e.data===void 0&&t.data===void 0)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}function ae(e,t){const r={...e.headers,...t.headers},n={};return Object.keys(r).forEach(s=>{const a=r[s];n[s.toLowerCase()]=a}),n}function I(e){return e.map(t=>z(t))}function z(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function oe(e,t,r){return{name:"ApiError",message:e,status:t,transporterStackTrace:r}}function ce(e,t){return{name:"DeserializationError",message:e,response:t}}function ie(e){return{name:"RetryError",message:"Unreachable hosts - your application id may be incorrect. If the error persists, contact [email protected].",transporterStackTrace:e}}const ue=e=>{const t=e.appId,r=L(e.authMode!==void 0?e.authMode:v.WithinHeaders,t,e.apiKey),n=Z({hosts:[{url:`${t}-dsn.algolia.net`,accept:b.Read},{url:`${t}.algolia.net`,accept:b.Write}].concat(Q([{url:`${t}-1.algolianet.com`},{url:`${t}-2.algolianet.com`},{url:`${t}-3.algolianet.com`}])),...e,headers:{...r.headers(),"content-type":"application/x-www-form-urlencoded",...e.headers},queryParameters:{...r.queryParameters(),...e.queryParameters}});return q({transporter:n,appId:t,addAlgoliaAgent(a,u){n.userAgent.add({segment:a,version:u})},clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})}},e.methods)},le=e=>(t,r)=>t.method===y.Get?e.transporter.read(t,r):e.transporter.write(t,r),F=e=>(t,r={})=>{const n={transporter:e.transporter,appId:e.appId,indexName:t};return q(n,r.methods)},j=e=>(t,r)=>{const n=t.map(s=>({...s,params:k(s.params||{})}));return e.transporter.read({method:y.Post,path:"1/indexes/*/queries",data:{requests:n},cacheable:!0},r)},$=e=>(t,r)=>Promise.all(t.map(n=>{const{facetName:s,facetQuery:a,...u}=n.params;return F(e)(n.indexName,{methods:{searchForFacetValues:H}}).searchForFacetValues(s,a,{...r,...u})})),de=e=>(t,r,n)=>e.transporter.read({method:y.Post,path:C("1/answers/%s/prediction",e.indexName),data:{query:t,queryLanguages:r},cacheable:!0},n),me=e=>(t,r)=>e.transporter.read({method:y.Post,path:C("1/indexes/%s/query",e.indexName),data:{query:t},cacheable:!0},r),H=e=>(t,r,n)=>e.transporter.read({method:y.Post,path:C("1/indexes/%s/facets/%s/query",e.indexName,t),data:{facetQuery:r},cacheable:!0},n),w={Debug:1,Info:2,Error:3};function he(e){return{debug(t,r){return w.Debug>=e&&console.debug(t,r),Promise.resolve()},info(t,r){return w.Info>=e&&console.info(t,r),Promise.resolve()},error(t,r){return console.error(t,r),Promise.resolve()}}}function fe(){return{send(e){return new Promise(t=>{const r=new XMLHttpRequest;
1r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(u=>r.setRequestHeader(u,e.headers[u]));const n=(u,o)=>setTimeout(()=>{r.abort(),t({status:0,content:o,isTimedOut:!0})},u*1e3),s=n(e.connectTimeout,"Connection timeout");let a;r.onreadystatechange=()=>{r.readyState>r.OPENED&&a===void 0&&(clearTimeout(s),a=n(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(s),clearTimeout(a),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(s),clearTimeout(a),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}}}function ge(e,t,r){const n={appId:e,apiKey:t,timeouts:{connect:1,read:2,write:30},requester:fe(),logger:he(w.Error),responsesCache:E(),requestsCache:E({serializable:!1}),hostsCache:T({caches:[W({key:`${N}-${e}`}),E()]}),userAgent:ee(N).add({segment:"Browser",version:"lite"}),authMode:v.WithinQueryParameters};return ue({...n,...r,methods:{search:j,searchForFacetValues:$,multipleQueries:j,multipleSearchForFacetValues:$,customRequest:le,initIndex:s=>a=>F(s)(a,{methods:{search:me,searchForFacetValues:H,findAnswers:de}})}})}ge.version=N;export{ge as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.