@algolia/client-analytics
Advanced tools
Comparing version 5.3.2 to 5.4.0
@@ -14,3 +14,3 @@ // builds/browser.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.3.2"; | ||
var apiClientVersion = "5.4.0"; | ||
var REGIONS = ["de", "us"]; | ||
@@ -17,0 +17,0 @@ function getDefaultHosts(region) { |
@@ -1,2 +0,2 @@ | ||
function I(o,r,d="WithinHeaders"){let c={"x-algolia-api-key":r,"x-algolia-application-id":o};return{headers(){return d==="WithinHeaders"?c:{}},queryParameters(){return d==="WithinQueryParameters"?c:{}}}}function L(o){let r,d=`algolia-client-js-${o.key}`;function c(){return r===void 0&&(r=o.localStorage||window.localStorage),r}function g(){return JSON.parse(c().getItem(d)||"{}")}function R(f){c().setItem(d,JSON.stringify(f))}function q(){let f=o.timeToLive?o.timeToLive*1e3:null,e=g(),s=Object.fromEntries(Object.entries(e).filter(([,i])=>i.timestamp!==void 0));if(R(s),!f)return;let n=Object.fromEntries(Object.entries(s).filter(([,i])=>{let a=new Date().getTime();return!(i.timestamp+f<a)}));R(n)}return{get(f,e,s={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(q(),g()[JSON.stringify(f)])).then(n=>Promise.all([n?n.value:e(),n!==void 0])).then(([n,i])=>Promise.all([n,i||s.miss(n)])).then(([n])=>n)},set(f,e){return Promise.resolve().then(()=>{let s=g();return s[JSON.stringify(f)]={timestamp:new Date().getTime(),value:e},c().setItem(d,JSON.stringify(s)),e})},delete(f){return Promise.resolve().then(()=>{let e=g();delete e[JSON.stringify(f)],c().setItem(d,JSON.stringify(e))})},clear(){return Promise.resolve().then(()=>{c().removeItem(d)})}}}function Y(){return{get(o,r,d={miss:()=>Promise.resolve()}){return r().then(g=>Promise.all([g,d.miss(g)])).then(([g])=>g)},set(o,r){return Promise.resolve(r)},delete(o){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(o){let r=[...o.caches],d=r.shift();return d===void 0?Y():{get(c,g,R={miss:()=>Promise.resolve()}){return d.get(c,g,R).catch(()=>w({caches:r}).get(c,g,R))},set(c,g){return d.set(c,g).catch(()=>w({caches:r}).set(c,g))},delete(c){return d.delete(c).catch(()=>w({caches:r}).delete(c))},clear(){return d.clear().catch(()=>w({caches:r}).clear())}}}function G(o={serializable:!0}){let r={};return{get(d,c,g={miss:()=>Promise.resolve()}){let R=JSON.stringify(d);if(R in r)return Promise.resolve(o.serializable?JSON.parse(r[R]):r[R]);let q=c();return q.then(f=>g.miss(f)).then(()=>q)},set(d,c){return r[JSON.stringify(d)]=o.serializable?JSON.stringify(c):c,Promise.resolve(c)},delete(d){return delete r[JSON.stringify(d)],Promise.resolve()},clear(){return r={},Promise.resolve()}}}var _=2*60*1e3;function Q(o,r="up"){let d=Date.now();function c(){return r==="up"||Date.now()-d>_}function g(){return r==="timed out"&&Date.now()-d<=_}return{...o,status:r,lastUpdate:d,isUp:c,isTimedOut:g}}var W=class extends Error{name="AlgoliaError";constructor(o,r){super(o),r&&(this.name=r)}},j=class extends W{stackTrace;constructor(o,r,d){super(o,d),this.stackTrace=r}},Z=class extends j{constructor(o){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",o,"RetryError")}},k=class extends j{status;constructor(o,r,d,c="ApiError"){super(o,d,c),this.status=r}},ee=class extends W{response;constructor(o,r){super(o,"DeserializationError"),this.response=r}},te=class extends k{error;constructor(o,r,d,c){super(o,r,c,"DetailedApiError"),this.error=d}};function re(o,r,d){let c=oe(d),g=`${o.protocol}://${o.url}${o.port?`:${o.port}`:""}/${r.charAt(0)==="/"?r.substring(1):r}`;return c.length&&(g+=`?${c}`),g}function oe(o){return Object.keys(o).filter(r=>o[r]!==void 0).sort().map(r=>`${r}=${encodeURIComponent(Object.prototype.toString.call(o[r])==="[object Array]"?o[r].join(","):o[r]).replaceAll("+","%20")}`).join("&")}function se(o,r){if(o.method==="GET"||o.data===void 0&&r.data===void 0)return;let d=Array.isArray(o.data)?o.data:{...o.data,...r.data};return JSON.stringify(d)}function ne(o,r,d){let c={Accept:"application/json",...o,...r,...d},g={};return Object.keys(c).forEach(R=>{let q=c[R];g[R.toLowerCase()]=q}),g}function ie(o){try{return JSON.parse(o.content)}catch(r){throw new ee(r.message,o)}}function ae({content:o,status:r},d){try{let c=JSON.parse(o);return"error"in c?new te(c.message,r,c.error,d):new k(c.message,r,d)}catch{}return new k(o,r,d)}function ue({isTimedOut:o,status:r}){return!o&&~~r===0}function ce({isTimedOut:o,status:r}){return o||ue({isTimedOut:o,status:r})||~~(r/100)!==2&&~~(r/100)!==4}function de({status:o}){return~~(o/100)===2}function le(o){return o.map(r=>J(r))}function J(o){let r=o.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...o,request:{...o.request,headers:{...o.request.headers,...r}}}}function $({hosts:o,hostsCache:r,baseHeaders:d,baseQueryParameters:c,algoliaAgent:g,timeouts:R,requester:q,requestsCache:f,responsesCache:e}){async function s(a){let u=await Promise.all(a.map(m=>r.get(m,()=>Promise.resolve(Q(m))))),l=u.filter(m=>m.isUp()),t=u.filter(m=>m.isTimedOut()),p=[...l,...t];return{hosts:p.length>0?p:a,getTimeout(m,P){return(t.length===0&&m===0?1:t.length+3+m)*P}}}async function n(a,u,l=!0){let t=[],p=se(a,u),h=ne(d,a.headers,u.headers),m=a.method==="GET"?{...a.data,...u.data}:{},P={...c,...a.queryParameters,...m};if(g.value&&(P["x-algolia-agent"]=g.value),u&&u.queryParameters)for(let T of Object.keys(u.queryParameters))!u.queryParameters[T]||Object.prototype.toString.call(u.queryParameters[T])==="[object Object]"?P[T]=u.queryParameters[T]:P[T]=u.queryParameters[T].toString();let S=0,y=async(T,x)=>{let C=T.pop();if(C===void 0)throw new Z(le(t));let O={...R,...u.timeouts},F={data:p,headers:h,method:a.method,url:re(C,a.path,P),connectTimeout:x(S,O.connect),responseTimeout:x(S,l?O.read:O.write)},U=N=>{let D={request:F,response:N,host:C,triesLeft:T.length};return t.push(D),D},E=await q.send(F);if(ce(E)){let N=U(E);return E.isTimedOut&&S++,console.log("Retryable failure",J(N)),await r.set(C,Q(C,E.isTimedOut?"timed out":"down")),y(T,x)}if(de(E))return ie(E);throw U(E),ae(E,t)},A=o.filter(T=>T.accept==="readWrite"||(l?T.accept==="read":T.accept==="write")),H=await s(A);return y([...H.hosts].reverse(),H.getTimeout)}function i(a,u={}){let l=a.useReadTransporter||a.method==="GET";if(!l)return n(a,u,l);let t=()=>n(a,u);if((u.cacheable||a.cacheable)!==!0)return t();let h={request:a,requestOptions:u,transporter:{queryParameters:c,headers:d}};return e.get(h,()=>f.get(h,()=>f.set(h,t()).then(m=>Promise.all([f.delete(h),m]),m=>Promise.all([f.delete(h),Promise.reject(m)])).then(([m,P])=>P)),{miss:m=>e.set(h,m)})}return{hostsCache:r,requester:q,timeouts:R,algoliaAgent:g,baseHeaders:d,baseQueryParameters:c,hosts:o,request:i,requestsCache:f,responsesCache:e}}function fe(o){let r={value:`Algolia for JavaScript (${o})`,add(d){let c=`; ${d.segment}${d.version!==void 0?` (${d.version})`:""}`;return r.value.indexOf(c)===-1&&(r.value=`${r.value}${c}`),r}};return r}function M({algoliaAgents:o,client:r,version:d}){let c=fe(d).add({segment:r,version:d});return o.forEach(g=>c.add(g)),c}var z=1e3,B=2e3,X=3e4;function K(){function o(r){return new Promise(d=>{let c=new XMLHttpRequest;c.open(r.method,r.url,!0),Object.keys(r.headers).forEach(f=>c.setRequestHeader(f,r.headers[f]));let g=(f,e)=>setTimeout(()=>{c.abort(),d({status:0,content:e,isTimedOut:!0})},f),R=g(r.connectTimeout,"Connection timeout"),q;c.onreadystatechange=()=>{c.readyState>c.OPENED&&q===void 0&&(clearTimeout(R),q=g(r.responseTimeout,"Socket timeout"))},c.onerror=()=>{c.status===0&&(clearTimeout(R),clearTimeout(q),d({content:c.responseText||"Network request failed",status:c.status,isTimedOut:!1}))},c.onload=()=>{clearTimeout(R),clearTimeout(q),d({content:c.responseText,status:c.status,isTimedOut:!1})},c.send(r.data)})}return{send:o}}var v="5.3.2",b=["de","us"];function me(o){return[{url:o?"analytics.{region}.algolia.com".replace("{region}",o):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function V({appId:o,apiKey:r,authMode:d,algoliaAgents:c,region:g,...R}){let q=I(o,r,d),f=$({hosts:me(g),...R,algoliaAgent:M({algoliaAgents:c,client:"Analytics",version:v}),baseHeaders:{"content-type":"text/plain",...q.headers(),...R.baseHeaders},baseQueryParameters:{...q.queryParameters(),...R.baseQueryParameters}});return{transporter:f,appId:o,clearCache(){return Promise.all([f.requestsCache.clear(),f.responsesCache.clear()]).then(()=>{})},get _ua(){return f.algoliaAgent.value},addAlgoliaAgent(e,s){f.algoliaAgent.add({segment:e,version:s})},setClientApiKey({apiKey:e}){!d||d==="WithinHeaders"?f.baseHeaders["x-algolia-api-key"]=e:f.baseQueryParameters["x-algolia-api-key"]=e},customDelete({path:e,parameters:s},n){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{}};return f.request(l,n)},customGet({path:e,parameters:s},n){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{}};return f.request(l,n)},customPost({path:e,parameters:s,body:n},i){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");let t={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{},data:n||{}};return f.request(t,i)},customPut({path:e,parameters:s,body:n},i){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");let t={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{},data:n||{}};return f.request(t,i)},getAddToCartRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getAddToCartRate`.");let u="/2/conversions/addToCartRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getAverageClickPosition({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getAverageClickPosition`.");let u="/2/clicks/averageClickPosition",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getClickPositions({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getClickPositions`.");let u="/2/clicks/positions",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getClickThroughRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getClickThroughRate`.");let u="/2/clicks/clickThroughRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getConversionRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getConversionRate`.");let u="/2/conversions/conversionRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getNoClickRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getNoClickRate`.");let u="/2/searches/noClickRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getNoResultsRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getNoResultsRate`.");let u="/2/searches/noResultRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getPurchaseRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getPurchaseRate`.");let u="/2/conversions/purchaseRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getRevenue({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getRevenue`.");let u="/2/conversions/revenue",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getSearchesCount({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesCount`.");let u="/2/searches/count",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getSearchesNoClicks({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoClicks`.");let t="/2/searches/noClicks",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getSearchesNoResults({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoResults`.");let t="/2/searches/noResults",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getStatus({index:e},s){if(!e)throw new Error("Parameter `index` is required when calling `getStatus`.");let n="/2/status",i={},a={};e!==void 0&&(a.index=e.toString());let u={method:"GET",path:n,queryParameters:a,headers:i};return f.request(u,s)},getTopCountries({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getTopCountries`.");let t="/2/countries",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getTopFilterAttributes({index:e,search:s,startDate:n,endDate:i,limit:a,offset:u,tags:l},t){if(!e)throw new Error("Parameter `index` is required when calling `getTopFilterAttributes`.");let p="/2/filters",h={},m={};e!==void 0&&(m.index=e.toString()),s!==void 0&&(m.search=s.toString()),n!==void 0&&(m.startDate=n.toString()),i!==void 0&&(m.endDate=i.toString()),a!==void 0&&(m.limit=a.toString()),u!==void 0&&(m.offset=u.toString()),l!==void 0&&(m.tags=l.toString());let P={method:"GET",path:p,queryParameters:m,headers:h};return f.request(P,t)},getTopFilterForAttribute({attribute:e,index:s,search:n,startDate:i,endDate:a,limit:u,offset:l,tags:t},p){if(!e)throw new Error("Parameter `attribute` is required when calling `getTopFilterForAttribute`.");if(!s)throw new Error("Parameter `index` is required when calling `getTopFilterForAttribute`.");let h="/2/filters/{attribute}".replace("{attribute}",encodeURIComponent(e)),m={},P={};s!==void 0&&(P.index=s.toString()),n!==void 0&&(P.search=n.toString()),i!==void 0&&(P.startDate=i.toString()),a!==void 0&&(P.endDate=a.toString()),u!==void 0&&(P.limit=u.toString()),l!==void 0&&(P.offset=l.toString()),t!==void 0&&(P.tags=t.toString());let S={method:"GET",path:h,queryParameters:P,headers:m};return f.request(S,p)},getTopFiltersNoResults({index:e,search:s,startDate:n,endDate:i,limit:a,offset:u,tags:l},t){if(!e)throw new Error("Parameter `index` is required when calling `getTopFiltersNoResults`.");let p="/2/filters/noResults",h={},m={};e!==void 0&&(m.index=e.toString()),s!==void 0&&(m.search=s.toString()),n!==void 0&&(m.startDate=n.toString()),i!==void 0&&(m.endDate=i.toString()),a!==void 0&&(m.limit=a.toString()),u!==void 0&&(m.offset=u.toString()),l!==void 0&&(m.tags=l.toString());let P={method:"GET",path:p,queryParameters:m,headers:h};return f.request(P,t)},getTopHits({index:e,search:s,clickAnalytics:n,revenueAnalytics:i,startDate:a,endDate:u,limit:l,offset:t,tags:p},h){if(!e)throw new Error("Parameter `index` is required when calling `getTopHits`.");let m="/2/hits",P={},S={};e!==void 0&&(S.index=e.toString()),s!==void 0&&(S.search=s.toString()),n!==void 0&&(S.clickAnalytics=n.toString()),i!==void 0&&(S.revenueAnalytics=i.toString()),a!==void 0&&(S.startDate=a.toString()),u!==void 0&&(S.endDate=u.toString()),l!==void 0&&(S.limit=l.toString()),t!==void 0&&(S.offset=t.toString()),p!==void 0&&(S.tags=p.toString());let y={method:"GET",path:m,queryParameters:S,headers:P};return f.request(y,h)},getTopSearches({index:e,clickAnalytics:s,revenueAnalytics:n,startDate:i,endDate:a,orderBy:u,direction:l,limit:t,offset:p,tags:h},m){if(!e)throw new Error("Parameter `index` is required when calling `getTopSearches`.");let P="/2/searches",S={},y={};e!==void 0&&(y.index=e.toString()),s!==void 0&&(y.clickAnalytics=s.toString()),n!==void 0&&(y.revenueAnalytics=n.toString()),i!==void 0&&(y.startDate=i.toString()),a!==void 0&&(y.endDate=a.toString()),u!==void 0&&(y.orderBy=u.toString()),l!==void 0&&(y.direction=l.toString()),t!==void 0&&(y.limit=t.toString()),p!==void 0&&(y.offset=p.toString()),h!==void 0&&(y.tags=h.toString());let A={method:"GET",path:P,queryParameters:y,headers:S};return f.request(A,m)},getUsersCount({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getUsersCount`.");let u="/2/users/count",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)}}}function Nt(o,r,d,c){if(!o||typeof o!="string")throw new Error("`appId` is missing.");if(!r||typeof r!="string")throw new Error("`apiKey` is missing.");if(d&&(typeof d!="string"||!b.includes(d)))throw new Error(`\`region\` must be one of the following: ${b.join(", ")}`);return V({appId:o,apiKey:r,region:d,timeouts:{connect:z,read:B,write:X},requester:K(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:G(),requestsCache:G({serializable:!1}),hostsCache:w({caches:[L({key:`${v}-${o}`}),G()]}),...c})}export{Nt as analyticsClient,v as apiClientVersion}; | ||
function I(o,r,d="WithinHeaders"){let c={"x-algolia-api-key":r,"x-algolia-application-id":o};return{headers(){return d==="WithinHeaders"?c:{}},queryParameters(){return d==="WithinQueryParameters"?c:{}}}}function W(o){let r,d=`algolia-client-js-${o.key}`;function c(){return r===void 0&&(r=o.localStorage||window.localStorage),r}function g(){return JSON.parse(c().getItem(d)||"{}")}function R(f){c().setItem(d,JSON.stringify(f))}function q(){let f=o.timeToLive?o.timeToLive*1e3:null,e=g(),s=Object.fromEntries(Object.entries(e).filter(([,i])=>i.timestamp!==void 0));if(R(s),!f)return;let n=Object.fromEntries(Object.entries(s).filter(([,i])=>{let a=new Date().getTime();return!(i.timestamp+f<a)}));R(n)}return{get(f,e,s={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(q(),g()[JSON.stringify(f)])).then(n=>Promise.all([n?n.value:e(),n!==void 0])).then(([n,i])=>Promise.all([n,i||s.miss(n)])).then(([n])=>n)},set(f,e){return Promise.resolve().then(()=>{let s=g();return s[JSON.stringify(f)]={timestamp:new Date().getTime(),value:e},c().setItem(d,JSON.stringify(s)),e})},delete(f){return Promise.resolve().then(()=>{let e=g();delete e[JSON.stringify(f)],c().setItem(d,JSON.stringify(e))})},clear(){return Promise.resolve().then(()=>{c().removeItem(d)})}}}function Y(){return{get(o,r,d={miss:()=>Promise.resolve()}){return r().then(g=>Promise.all([g,d.miss(g)])).then(([g])=>g)},set(o,r){return Promise.resolve(r)},delete(o){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(o){let r=[...o.caches],d=r.shift();return d===void 0?Y():{get(c,g,R={miss:()=>Promise.resolve()}){return d.get(c,g,R).catch(()=>w({caches:r}).get(c,g,R))},set(c,g){return d.set(c,g).catch(()=>w({caches:r}).set(c,g))},delete(c){return d.delete(c).catch(()=>w({caches:r}).delete(c))},clear(){return d.clear().catch(()=>w({caches:r}).clear())}}}function G(o={serializable:!0}){let r={};return{get(d,c,g={miss:()=>Promise.resolve()}){let R=JSON.stringify(d);if(R in r)return Promise.resolve(o.serializable?JSON.parse(r[R]):r[R]);let q=c();return q.then(f=>g.miss(f)).then(()=>q)},set(d,c){return r[JSON.stringify(d)]=o.serializable?JSON.stringify(c):c,Promise.resolve(c)},delete(d){return delete r[JSON.stringify(d)],Promise.resolve()},clear(){return r={},Promise.resolve()}}}var _=2*60*1e3;function Q(o,r="up"){let d=Date.now();function c(){return r==="up"||Date.now()-d>_}function g(){return r==="timed out"&&Date.now()-d<=_}return{...o,status:r,lastUpdate:d,isUp:c,isTimedOut:g}}var L=class extends Error{name="AlgoliaError";constructor(o,r){super(o),r&&(this.name=r)}},$=class extends L{stackTrace;constructor(o,r,d){super(o,d),this.stackTrace=r}},Z=class extends ${constructor(o){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",o,"RetryError")}},k=class extends ${status;constructor(o,r,d,c="ApiError"){super(o,d,c),this.status=r}},ee=class extends L{response;constructor(o,r){super(o,"DeserializationError"),this.response=r}},te=class extends k{error;constructor(o,r,d,c){super(o,r,c,"DetailedApiError"),this.error=d}};function re(o,r,d){let c=oe(d),g=`${o.protocol}://${o.url}${o.port?`:${o.port}`:""}/${r.charAt(0)==="/"?r.substring(1):r}`;return c.length&&(g+=`?${c}`),g}function oe(o){return Object.keys(o).filter(r=>o[r]!==void 0).sort().map(r=>`${r}=${encodeURIComponent(Object.prototype.toString.call(o[r])==="[object Array]"?o[r].join(","):o[r]).replaceAll("+","%20")}`).join("&")}function se(o,r){if(o.method==="GET"||o.data===void 0&&r.data===void 0)return;let d=Array.isArray(o.data)?o.data:{...o.data,...r.data};return JSON.stringify(d)}function ne(o,r,d){let c={Accept:"application/json",...o,...r,...d},g={};return Object.keys(c).forEach(R=>{let q=c[R];g[R.toLowerCase()]=q}),g}function ie(o){try{return JSON.parse(o.content)}catch(r){throw new ee(r.message,o)}}function ae({content:o,status:r},d){try{let c=JSON.parse(o);return"error"in c?new te(c.message,r,c.error,d):new k(c.message,r,d)}catch{}return new k(o,r,d)}function ue({isTimedOut:o,status:r}){return!o&&~~r===0}function ce({isTimedOut:o,status:r}){return o||ue({isTimedOut:o,status:r})||~~(r/100)!==2&&~~(r/100)!==4}function de({status:o}){return~~(o/100)===2}function le(o){return o.map(r=>j(r))}function j(o){let r=o.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...o,request:{...o.request,headers:{...o.request.headers,...r}}}}function J({hosts:o,hostsCache:r,baseHeaders:d,baseQueryParameters:c,algoliaAgent:g,timeouts:R,requester:q,requestsCache:f,responsesCache:e}){async function s(a){let u=await Promise.all(a.map(m=>r.get(m,()=>Promise.resolve(Q(m))))),l=u.filter(m=>m.isUp()),t=u.filter(m=>m.isTimedOut()),p=[...l,...t];return{hosts:p.length>0?p:a,getTimeout(m,P){return(t.length===0&&m===0?1:t.length+3+m)*P}}}async function n(a,u,l=!0){let t=[],p=se(a,u),h=ne(d,a.headers,u.headers),m=a.method==="GET"?{...a.data,...u.data}:{},P={...c,...a.queryParameters,...m};if(g.value&&(P["x-algolia-agent"]=g.value),u&&u.queryParameters)for(let T of Object.keys(u.queryParameters))!u.queryParameters[T]||Object.prototype.toString.call(u.queryParameters[T])==="[object Object]"?P[T]=u.queryParameters[T]:P[T]=u.queryParameters[T].toString();let S=0,y=async(T,x)=>{let C=T.pop();if(C===void 0)throw new Z(le(t));let O={...R,...u.timeouts},F={data:p,headers:h,method:a.method,url:re(C,a.path,P),connectTimeout:x(S,O.connect),responseTimeout:x(S,l?O.read:O.write)},U=N=>{let D={request:F,response:N,host:C,triesLeft:T.length};return t.push(D),D},E=await q.send(F);if(ce(E)){let N=U(E);return E.isTimedOut&&S++,console.log("Retryable failure",j(N)),await r.set(C,Q(C,E.isTimedOut?"timed out":"down")),y(T,x)}if(de(E))return ie(E);throw U(E),ae(E,t)},v=o.filter(T=>T.accept==="readWrite"||(l?T.accept==="read":T.accept==="write")),H=await s(v);return y([...H.hosts].reverse(),H.getTimeout)}function i(a,u={}){let l=a.useReadTransporter||a.method==="GET";if(!l)return n(a,u,l);let t=()=>n(a,u);if((u.cacheable||a.cacheable)!==!0)return t();let h={request:a,requestOptions:u,transporter:{queryParameters:c,headers:d}};return e.get(h,()=>f.get(h,()=>f.set(h,t()).then(m=>Promise.all([f.delete(h),m]),m=>Promise.all([f.delete(h),Promise.reject(m)])).then(([m,P])=>P)),{miss:m=>e.set(h,m)})}return{hostsCache:r,requester:q,timeouts:R,algoliaAgent:g,baseHeaders:d,baseQueryParameters:c,hosts:o,request:i,requestsCache:f,responsesCache:e}}function fe(o){let r={value:`Algolia for JavaScript (${o})`,add(d){let c=`; ${d.segment}${d.version!==void 0?` (${d.version})`:""}`;return r.value.indexOf(c)===-1&&(r.value=`${r.value}${c}`),r}};return r}function M({algoliaAgents:o,client:r,version:d}){let c=fe(d).add({segment:r,version:d});return o.forEach(g=>c.add(g)),c}var z=1e3,B=2e3,X=3e4;function K(){function o(r){return new Promise(d=>{let c=new XMLHttpRequest;c.open(r.method,r.url,!0),Object.keys(r.headers).forEach(f=>c.setRequestHeader(f,r.headers[f]));let g=(f,e)=>setTimeout(()=>{c.abort(),d({status:0,content:e,isTimedOut:!0})},f),R=g(r.connectTimeout,"Connection timeout"),q;c.onreadystatechange=()=>{c.readyState>c.OPENED&&q===void 0&&(clearTimeout(R),q=g(r.responseTimeout,"Socket timeout"))},c.onerror=()=>{c.status===0&&(clearTimeout(R),clearTimeout(q),d({content:c.responseText||"Network request failed",status:c.status,isTimedOut:!1}))},c.onload=()=>{clearTimeout(R),clearTimeout(q),d({content:c.responseText,status:c.status,isTimedOut:!1})},c.send(r.data)})}return{send:o}}var A="5.4.0",b=["de","us"];function me(o){return[{url:o?"analytics.{region}.algolia.com".replace("{region}",o):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function V({appId:o,apiKey:r,authMode:d,algoliaAgents:c,region:g,...R}){let q=I(o,r,d),f=J({hosts:me(g),...R,algoliaAgent:M({algoliaAgents:c,client:"Analytics",version:A}),baseHeaders:{"content-type":"text/plain",...q.headers(),...R.baseHeaders},baseQueryParameters:{...q.queryParameters(),...R.baseQueryParameters}});return{transporter:f,appId:o,clearCache(){return Promise.all([f.requestsCache.clear(),f.responsesCache.clear()]).then(()=>{})},get _ua(){return f.algoliaAgent.value},addAlgoliaAgent(e,s){f.algoliaAgent.add({segment:e,version:s})},setClientApiKey({apiKey:e}){!d||d==="WithinHeaders"?f.baseHeaders["x-algolia-api-key"]=e:f.baseQueryParameters["x-algolia-api-key"]=e},customDelete({path:e,parameters:s},n){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{}};return f.request(l,n)},customGet({path:e,parameters:s},n){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{}};return f.request(l,n)},customPost({path:e,parameters:s,body:n},i){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");let t={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{},data:n||{}};return f.request(t,i)},customPut({path:e,parameters:s,body:n},i){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");let t={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{},data:n||{}};return f.request(t,i)},getAddToCartRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getAddToCartRate`.");let u="/2/conversions/addToCartRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getAverageClickPosition({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getAverageClickPosition`.");let u="/2/clicks/averageClickPosition",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getClickPositions({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getClickPositions`.");let u="/2/clicks/positions",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getClickThroughRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getClickThroughRate`.");let u="/2/clicks/clickThroughRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getConversionRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getConversionRate`.");let u="/2/conversions/conversionRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getNoClickRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getNoClickRate`.");let u="/2/searches/noClickRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getNoResultsRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getNoResultsRate`.");let u="/2/searches/noResultRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getPurchaseRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getPurchaseRate`.");let u="/2/conversions/purchaseRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getRevenue({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getRevenue`.");let u="/2/conversions/revenue",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getSearchesCount({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesCount`.");let u="/2/searches/count",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getSearchesNoClicks({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoClicks`.");let t="/2/searches/noClicks",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getSearchesNoResults({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoResults`.");let t="/2/searches/noResults",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getStatus({index:e},s){if(!e)throw new Error("Parameter `index` is required when calling `getStatus`.");let n="/2/status",i={},a={};e!==void 0&&(a.index=e.toString());let u={method:"GET",path:n,queryParameters:a,headers:i};return f.request(u,s)},getTopCountries({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getTopCountries`.");let t="/2/countries",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getTopFilterAttributes({index:e,search:s,startDate:n,endDate:i,limit:a,offset:u,tags:l},t){if(!e)throw new Error("Parameter `index` is required when calling `getTopFilterAttributes`.");let p="/2/filters",h={},m={};e!==void 0&&(m.index=e.toString()),s!==void 0&&(m.search=s.toString()),n!==void 0&&(m.startDate=n.toString()),i!==void 0&&(m.endDate=i.toString()),a!==void 0&&(m.limit=a.toString()),u!==void 0&&(m.offset=u.toString()),l!==void 0&&(m.tags=l.toString());let P={method:"GET",path:p,queryParameters:m,headers:h};return f.request(P,t)},getTopFilterForAttribute({attribute:e,index:s,search:n,startDate:i,endDate:a,limit:u,offset:l,tags:t},p){if(!e)throw new Error("Parameter `attribute` is required when calling `getTopFilterForAttribute`.");if(!s)throw new Error("Parameter `index` is required when calling `getTopFilterForAttribute`.");let h="/2/filters/{attribute}".replace("{attribute}",encodeURIComponent(e)),m={},P={};s!==void 0&&(P.index=s.toString()),n!==void 0&&(P.search=n.toString()),i!==void 0&&(P.startDate=i.toString()),a!==void 0&&(P.endDate=a.toString()),u!==void 0&&(P.limit=u.toString()),l!==void 0&&(P.offset=l.toString()),t!==void 0&&(P.tags=t.toString());let S={method:"GET",path:h,queryParameters:P,headers:m};return f.request(S,p)},getTopFiltersNoResults({index:e,search:s,startDate:n,endDate:i,limit:a,offset:u,tags:l},t){if(!e)throw new Error("Parameter `index` is required when calling `getTopFiltersNoResults`.");let p="/2/filters/noResults",h={},m={};e!==void 0&&(m.index=e.toString()),s!==void 0&&(m.search=s.toString()),n!==void 0&&(m.startDate=n.toString()),i!==void 0&&(m.endDate=i.toString()),a!==void 0&&(m.limit=a.toString()),u!==void 0&&(m.offset=u.toString()),l!==void 0&&(m.tags=l.toString());let P={method:"GET",path:p,queryParameters:m,headers:h};return f.request(P,t)},getTopHits({index:e,search:s,clickAnalytics:n,revenueAnalytics:i,startDate:a,endDate:u,limit:l,offset:t,tags:p},h){if(!e)throw new Error("Parameter `index` is required when calling `getTopHits`.");let m="/2/hits",P={},S={};e!==void 0&&(S.index=e.toString()),s!==void 0&&(S.search=s.toString()),n!==void 0&&(S.clickAnalytics=n.toString()),i!==void 0&&(S.revenueAnalytics=i.toString()),a!==void 0&&(S.startDate=a.toString()),u!==void 0&&(S.endDate=u.toString()),l!==void 0&&(S.limit=l.toString()),t!==void 0&&(S.offset=t.toString()),p!==void 0&&(S.tags=p.toString());let y={method:"GET",path:m,queryParameters:S,headers:P};return f.request(y,h)},getTopSearches({index:e,clickAnalytics:s,revenueAnalytics:n,startDate:i,endDate:a,orderBy:u,direction:l,limit:t,offset:p,tags:h},m){if(!e)throw new Error("Parameter `index` is required when calling `getTopSearches`.");let P="/2/searches",S={},y={};e!==void 0&&(y.index=e.toString()),s!==void 0&&(y.clickAnalytics=s.toString()),n!==void 0&&(y.revenueAnalytics=n.toString()),i!==void 0&&(y.startDate=i.toString()),a!==void 0&&(y.endDate=a.toString()),u!==void 0&&(y.orderBy=u.toString()),l!==void 0&&(y.direction=l.toString()),t!==void 0&&(y.limit=t.toString()),p!==void 0&&(y.offset=p.toString()),h!==void 0&&(y.tags=h.toString());let v={method:"GET",path:P,queryParameters:y,headers:S};return f.request(v,m)},getUsersCount({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getUsersCount`.");let u="/2/users/count",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)}}}function xt(o,r,d,c){if(!o||typeof o!="string")throw new Error("`appId` is missing.");if(!r||typeof r!="string")throw new Error("`apiKey` is missing.");if(d&&(typeof d!="string"||!b.includes(d)))throw new Error(`\`region\` must be one of the following: ${b.join(", ")}`);return V({appId:o,apiKey:r,region:d,timeouts:{connect:z,read:B,write:X},requester:K(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:G(),requestsCache:G({serializable:!1}),hostsCache:w({caches:[W({key:`${A}-${o}`}),G()]}),...c})}export{xt as analyticsClient,A as apiClientVersion}; | ||
//# sourceMappingURL=browser.min.js.map |
@@ -7,7 +7,7 @@ (function (global, factory) { | ||
function I(o,r,d="WithinHeaders"){let c={"x-algolia-api-key":r,"x-algolia-application-id":o};return {headers(){return d==="WithinHeaders"?c:{}},queryParameters(){return d==="WithinQueryParameters"?c:{}}}}function L(o){let r,d=`algolia-client-js-${o.key}`;function c(){return r===void 0&&(r=o.localStorage||window.localStorage),r}function g(){return JSON.parse(c().getItem(d)||"{}")}function R(f){c().setItem(d,JSON.stringify(f));}function q(){let f=o.timeToLive?o.timeToLive*1e3:null,e=g(),s=Object.fromEntries(Object.entries(e).filter(([,i])=>i.timestamp!==void 0));if(R(s),!f)return;let n=Object.fromEntries(Object.entries(s).filter(([,i])=>{let a=new Date().getTime();return !(i.timestamp+f<a)}));R(n);}return {get(f,e,s={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(q(),g()[JSON.stringify(f)])).then(n=>Promise.all([n?n.value:e(),n!==void 0])).then(([n,i])=>Promise.all([n,i||s.miss(n)])).then(([n])=>n)},set(f,e){return Promise.resolve().then(()=>{let s=g();return s[JSON.stringify(f)]={timestamp:new Date().getTime(),value:e},c().setItem(d,JSON.stringify(s)),e})},delete(f){return Promise.resolve().then(()=>{let e=g();delete e[JSON.stringify(f)],c().setItem(d,JSON.stringify(e));})},clear(){return Promise.resolve().then(()=>{c().removeItem(d);})}}}function Y(){return {get(o,r,d={miss:()=>Promise.resolve()}){return r().then(g=>Promise.all([g,d.miss(g)])).then(([g])=>g)},set(o,r){return Promise.resolve(r)},delete(o){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(o){let r=[...o.caches],d=r.shift();return d===void 0?Y():{get(c,g,R={miss:()=>Promise.resolve()}){return d.get(c,g,R).catch(()=>w({caches:r}).get(c,g,R))},set(c,g){return d.set(c,g).catch(()=>w({caches:r}).set(c,g))},delete(c){return d.delete(c).catch(()=>w({caches:r}).delete(c))},clear(){return d.clear().catch(()=>w({caches:r}).clear())}}}function G(o={serializable:!0}){let r={};return {get(d,c,g={miss:()=>Promise.resolve()}){let R=JSON.stringify(d);if(R in r)return Promise.resolve(o.serializable?JSON.parse(r[R]):r[R]);let q=c();return q.then(f=>g.miss(f)).then(()=>q)},set(d,c){return r[JSON.stringify(d)]=o.serializable?JSON.stringify(c):c,Promise.resolve(c)},delete(d){return delete r[JSON.stringify(d)],Promise.resolve()},clear(){return r={},Promise.resolve()}}}var _=2*60*1e3;function Q(o,r="up"){let d=Date.now();function c(){return r==="up"||Date.now()-d>_}function g(){return r==="timed out"&&Date.now()-d<=_}return {...o,status:r,lastUpdate:d,isUp:c,isTimedOut:g}}var W=class extends Error{name="AlgoliaError";constructor(o,r){super(o),r&&(this.name=r);}},j=class extends W{stackTrace;constructor(o,r,d){super(o,d),this.stackTrace=r;}},Z=class extends j{constructor(o){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",o,"RetryError");}},k=class extends j{status;constructor(o,r,d,c="ApiError"){super(o,d,c),this.status=r;}},ee=class extends W{response;constructor(o,r){super(o,"DeserializationError"),this.response=r;}},te=class extends k{error;constructor(o,r,d,c){super(o,r,c,"DetailedApiError"),this.error=d;}};function re(o,r,d){let c=oe(d),g=`${o.protocol}://${o.url}${o.port?`:${o.port}`:""}/${r.charAt(0)==="/"?r.substring(1):r}`;return c.length&&(g+=`?${c}`),g}function oe(o){return Object.keys(o).filter(r=>o[r]!==void 0).sort().map(r=>`${r}=${encodeURIComponent(Object.prototype.toString.call(o[r])==="[object Array]"?o[r].join(","):o[r]).replaceAll("+","%20")}`).join("&")}function se(o,r){if(o.method==="GET"||o.data===void 0&&r.data===void 0)return;let d=Array.isArray(o.data)?o.data:{...o.data,...r.data};return JSON.stringify(d)}function ne(o,r,d){let c={Accept:"application/json",...o,...r,...d},g={};return Object.keys(c).forEach(R=>{let q=c[R];g[R.toLowerCase()]=q;}),g}function ie(o){try{return JSON.parse(o.content)}catch(r){throw new ee(r.message,o)}}function ae({content:o,status:r},d){try{let c=JSON.parse(o);return "error"in c?new te(c.message,r,c.error,d):new k(c.message,r,d)}catch{}return new k(o,r,d)}function ue({isTimedOut:o,status:r}){return !o&&~~r===0}function ce({isTimedOut:o,status:r}){return o||ue({isTimedOut:o,status:r})||~~(r/100)!==2&&~~(r/100)!==4}function de({status:o}){return ~~(o/100)===2}function le(o){return o.map(r=>J(r))}function J(o){let r=o.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...o,request:{...o.request,headers:{...o.request.headers,...r}}}}function $({hosts:o,hostsCache:r,baseHeaders:d,baseQueryParameters:c,algoliaAgent:g,timeouts:R,requester:q,requestsCache:f,responsesCache:e}){async function s(a){let u=await Promise.all(a.map(m=>r.get(m,()=>Promise.resolve(Q(m))))),l=u.filter(m=>m.isUp()),t=u.filter(m=>m.isTimedOut()),p=[...l,...t];return {hosts:p.length>0?p:a,getTimeout(m,P){return (t.length===0&&m===0?1:t.length+3+m)*P}}}async function n(a,u,l=!0){let t=[],p=se(a,u),h=ne(d,a.headers,u.headers),m=a.method==="GET"?{...a.data,...u.data}:{},P={...c,...a.queryParameters,...m};if(g.value&&(P["x-algolia-agent"]=g.value),u&&u.queryParameters)for(let T of Object.keys(u.queryParameters))!u.queryParameters[T]||Object.prototype.toString.call(u.queryParameters[T])==="[object Object]"?P[T]=u.queryParameters[T]:P[T]=u.queryParameters[T].toString();let S=0,y=async(T,x)=>{let C=T.pop();if(C===void 0)throw new Z(le(t));let O={...R,...u.timeouts},F={data:p,headers:h,method:a.method,url:re(C,a.path,P),connectTimeout:x(S,O.connect),responseTimeout:x(S,l?O.read:O.write)},U=N=>{let D={request:F,response:N,host:C,triesLeft:T.length};return t.push(D),D},E=await q.send(F);if(ce(E)){let N=U(E);return E.isTimedOut&&S++,console.log("Retryable failure",J(N)),await r.set(C,Q(C,E.isTimedOut?"timed out":"down")),y(T,x)}if(de(E))return ie(E);throw U(E),ae(E,t)},A=o.filter(T=>T.accept==="readWrite"||(l?T.accept==="read":T.accept==="write")),H=await s(A);return y([...H.hosts].reverse(),H.getTimeout)}function i(a,u={}){let l=a.useReadTransporter||a.method==="GET";if(!l)return n(a,u,l);let t=()=>n(a,u);if((u.cacheable||a.cacheable)!==!0)return t();let h={request:a,requestOptions:u,transporter:{queryParameters:c,headers:d}};return e.get(h,()=>f.get(h,()=>f.set(h,t()).then(m=>Promise.all([f.delete(h),m]),m=>Promise.all([f.delete(h),Promise.reject(m)])).then(([m,P])=>P)),{miss:m=>e.set(h,m)})}return {hostsCache:r,requester:q,timeouts:R,algoliaAgent:g,baseHeaders:d,baseQueryParameters:c,hosts:o,request:i,requestsCache:f,responsesCache:e}}function fe(o){let r={value:`Algolia for JavaScript (${o})`,add(d){let c=`; ${d.segment}${d.version!==void 0?` (${d.version})`:""}`;return r.value.indexOf(c)===-1&&(r.value=`${r.value}${c}`),r}};return r}function M({algoliaAgents:o,client:r,version:d}){let c=fe(d).add({segment:r,version:d});return o.forEach(g=>c.add(g)),c}var z=1e3,B=2e3,X=3e4;function K(){function o(r){return new Promise(d=>{let c=new XMLHttpRequest;c.open(r.method,r.url,!0),Object.keys(r.headers).forEach(f=>c.setRequestHeader(f,r.headers[f]));let g=(f,e)=>setTimeout(()=>{c.abort(),d({status:0,content:e,isTimedOut:!0});},f),R=g(r.connectTimeout,"Connection timeout"),q;c.onreadystatechange=()=>{c.readyState>c.OPENED&&q===void 0&&(clearTimeout(R),q=g(r.responseTimeout,"Socket timeout"));},c.onerror=()=>{c.status===0&&(clearTimeout(R),clearTimeout(q),d({content:c.responseText||"Network request failed",status:c.status,isTimedOut:!1}));},c.onload=()=>{clearTimeout(R),clearTimeout(q),d({content:c.responseText,status:c.status,isTimedOut:!1});},c.send(r.data);})}return {send:o}}var v="5.3.2",b=["de","us"];function me(o){return [{url:o?"analytics.{region}.algolia.com".replace("{region}",o):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function V({appId:o,apiKey:r,authMode:d,algoliaAgents:c,region:g,...R}){let q=I(o,r,d),f=$({hosts:me(g),...R,algoliaAgent:M({algoliaAgents:c,client:"Analytics",version:v}),baseHeaders:{"content-type":"text/plain",...q.headers(),...R.baseHeaders},baseQueryParameters:{...q.queryParameters(),...R.baseQueryParameters}});return {transporter:f,appId:o,clearCache(){return Promise.all([f.requestsCache.clear(),f.responsesCache.clear()]).then(()=>{})},get _ua(){return f.algoliaAgent.value},addAlgoliaAgent(e,s){f.algoliaAgent.add({segment:e,version:s});},setClientApiKey({apiKey:e}){!d||d==="WithinHeaders"?f.baseHeaders["x-algolia-api-key"]=e:f.baseQueryParameters["x-algolia-api-key"]=e;},customDelete({path:e,parameters:s},n){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{}};return f.request(l,n)},customGet({path:e,parameters:s},n){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{}};return f.request(l,n)},customPost({path:e,parameters:s,body:n},i){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");let t={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{},data:n||{}};return f.request(t,i)},customPut({path:e,parameters:s,body:n},i){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");let t={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{},data:n||{}};return f.request(t,i)},getAddToCartRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getAddToCartRate`.");let u="/2/conversions/addToCartRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getAverageClickPosition({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getAverageClickPosition`.");let u="/2/clicks/averageClickPosition",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getClickPositions({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getClickPositions`.");let u="/2/clicks/positions",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getClickThroughRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getClickThroughRate`.");let u="/2/clicks/clickThroughRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getConversionRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getConversionRate`.");let u="/2/conversions/conversionRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getNoClickRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getNoClickRate`.");let u="/2/searches/noClickRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getNoResultsRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getNoResultsRate`.");let u="/2/searches/noResultRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getPurchaseRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getPurchaseRate`.");let u="/2/conversions/purchaseRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getRevenue({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getRevenue`.");let u="/2/conversions/revenue",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getSearchesCount({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesCount`.");let u="/2/searches/count",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getSearchesNoClicks({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoClicks`.");let t="/2/searches/noClicks",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getSearchesNoResults({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoResults`.");let t="/2/searches/noResults",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getStatus({index:e},s){if(!e)throw new Error("Parameter `index` is required when calling `getStatus`.");let n="/2/status",i={},a={};e!==void 0&&(a.index=e.toString());let u={method:"GET",path:n,queryParameters:a,headers:i};return f.request(u,s)},getTopCountries({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getTopCountries`.");let t="/2/countries",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getTopFilterAttributes({index:e,search:s,startDate:n,endDate:i,limit:a,offset:u,tags:l},t){if(!e)throw new Error("Parameter `index` is required when calling `getTopFilterAttributes`.");let p="/2/filters",h={},m={};e!==void 0&&(m.index=e.toString()),s!==void 0&&(m.search=s.toString()),n!==void 0&&(m.startDate=n.toString()),i!==void 0&&(m.endDate=i.toString()),a!==void 0&&(m.limit=a.toString()),u!==void 0&&(m.offset=u.toString()),l!==void 0&&(m.tags=l.toString());let P={method:"GET",path:p,queryParameters:m,headers:h};return f.request(P,t)},getTopFilterForAttribute({attribute:e,index:s,search:n,startDate:i,endDate:a,limit:u,offset:l,tags:t},p){if(!e)throw new Error("Parameter `attribute` is required when calling `getTopFilterForAttribute`.");if(!s)throw new Error("Parameter `index` is required when calling `getTopFilterForAttribute`.");let h="/2/filters/{attribute}".replace("{attribute}",encodeURIComponent(e)),m={},P={};s!==void 0&&(P.index=s.toString()),n!==void 0&&(P.search=n.toString()),i!==void 0&&(P.startDate=i.toString()),a!==void 0&&(P.endDate=a.toString()),u!==void 0&&(P.limit=u.toString()),l!==void 0&&(P.offset=l.toString()),t!==void 0&&(P.tags=t.toString());let S={method:"GET",path:h,queryParameters:P,headers:m};return f.request(S,p)},getTopFiltersNoResults({index:e,search:s,startDate:n,endDate:i,limit:a,offset:u,tags:l},t){if(!e)throw new Error("Parameter `index` is required when calling `getTopFiltersNoResults`.");let p="/2/filters/noResults",h={},m={};e!==void 0&&(m.index=e.toString()),s!==void 0&&(m.search=s.toString()),n!==void 0&&(m.startDate=n.toString()),i!==void 0&&(m.endDate=i.toString()),a!==void 0&&(m.limit=a.toString()),u!==void 0&&(m.offset=u.toString()),l!==void 0&&(m.tags=l.toString());let P={method:"GET",path:p,queryParameters:m,headers:h};return f.request(P,t)},getTopHits({index:e,search:s,clickAnalytics:n,revenueAnalytics:i,startDate:a,endDate:u,limit:l,offset:t,tags:p},h){if(!e)throw new Error("Parameter `index` is required when calling `getTopHits`.");let m="/2/hits",P={},S={};e!==void 0&&(S.index=e.toString()),s!==void 0&&(S.search=s.toString()),n!==void 0&&(S.clickAnalytics=n.toString()),i!==void 0&&(S.revenueAnalytics=i.toString()),a!==void 0&&(S.startDate=a.toString()),u!==void 0&&(S.endDate=u.toString()),l!==void 0&&(S.limit=l.toString()),t!==void 0&&(S.offset=t.toString()),p!==void 0&&(S.tags=p.toString());let y={method:"GET",path:m,queryParameters:S,headers:P};return f.request(y,h)},getTopSearches({index:e,clickAnalytics:s,revenueAnalytics:n,startDate:i,endDate:a,orderBy:u,direction:l,limit:t,offset:p,tags:h},m){if(!e)throw new Error("Parameter `index` is required when calling `getTopSearches`.");let P="/2/searches",S={},y={};e!==void 0&&(y.index=e.toString()),s!==void 0&&(y.clickAnalytics=s.toString()),n!==void 0&&(y.revenueAnalytics=n.toString()),i!==void 0&&(y.startDate=i.toString()),a!==void 0&&(y.endDate=a.toString()),u!==void 0&&(y.orderBy=u.toString()),l!==void 0&&(y.direction=l.toString()),t!==void 0&&(y.limit=t.toString()),p!==void 0&&(y.offset=p.toString()),h!==void 0&&(y.tags=h.toString());let A={method:"GET",path:P,queryParameters:y,headers:S};return f.request(A,m)},getUsersCount({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getUsersCount`.");let u="/2/users/count",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)}}}function Nt(o,r,d,c){if(!o||typeof o!="string")throw new Error("`appId` is missing.");if(!r||typeof r!="string")throw new Error("`apiKey` is missing.");if(d&&(typeof d!="string"||!b.includes(d)))throw new Error(`\`region\` must be one of the following: ${b.join(", ")}`);return V({appId:o,apiKey:r,region:d,timeouts:{connect:z,read:B,write:X},requester:K(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:G(),requestsCache:G({serializable:!1}),hostsCache:w({caches:[L({key:`${v}-${o}`}),G()]}),...c})} | ||
function I(o,r,d="WithinHeaders"){let c={"x-algolia-api-key":r,"x-algolia-application-id":o};return {headers(){return d==="WithinHeaders"?c:{}},queryParameters(){return d==="WithinQueryParameters"?c:{}}}}function W(o){let r,d=`algolia-client-js-${o.key}`;function c(){return r===void 0&&(r=o.localStorage||window.localStorage),r}function g(){return JSON.parse(c().getItem(d)||"{}")}function R(f){c().setItem(d,JSON.stringify(f));}function q(){let f=o.timeToLive?o.timeToLive*1e3:null,e=g(),s=Object.fromEntries(Object.entries(e).filter(([,i])=>i.timestamp!==void 0));if(R(s),!f)return;let n=Object.fromEntries(Object.entries(s).filter(([,i])=>{let a=new Date().getTime();return !(i.timestamp+f<a)}));R(n);}return {get(f,e,s={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(q(),g()[JSON.stringify(f)])).then(n=>Promise.all([n?n.value:e(),n!==void 0])).then(([n,i])=>Promise.all([n,i||s.miss(n)])).then(([n])=>n)},set(f,e){return Promise.resolve().then(()=>{let s=g();return s[JSON.stringify(f)]={timestamp:new Date().getTime(),value:e},c().setItem(d,JSON.stringify(s)),e})},delete(f){return Promise.resolve().then(()=>{let e=g();delete e[JSON.stringify(f)],c().setItem(d,JSON.stringify(e));})},clear(){return Promise.resolve().then(()=>{c().removeItem(d);})}}}function Y(){return {get(o,r,d={miss:()=>Promise.resolve()}){return r().then(g=>Promise.all([g,d.miss(g)])).then(([g])=>g)},set(o,r){return Promise.resolve(r)},delete(o){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(o){let r=[...o.caches],d=r.shift();return d===void 0?Y():{get(c,g,R={miss:()=>Promise.resolve()}){return d.get(c,g,R).catch(()=>w({caches:r}).get(c,g,R))},set(c,g){return d.set(c,g).catch(()=>w({caches:r}).set(c,g))},delete(c){return d.delete(c).catch(()=>w({caches:r}).delete(c))},clear(){return d.clear().catch(()=>w({caches:r}).clear())}}}function G(o={serializable:!0}){let r={};return {get(d,c,g={miss:()=>Promise.resolve()}){let R=JSON.stringify(d);if(R in r)return Promise.resolve(o.serializable?JSON.parse(r[R]):r[R]);let q=c();return q.then(f=>g.miss(f)).then(()=>q)},set(d,c){return r[JSON.stringify(d)]=o.serializable?JSON.stringify(c):c,Promise.resolve(c)},delete(d){return delete r[JSON.stringify(d)],Promise.resolve()},clear(){return r={},Promise.resolve()}}}var _=2*60*1e3;function Q(o,r="up"){let d=Date.now();function c(){return r==="up"||Date.now()-d>_}function g(){return r==="timed out"&&Date.now()-d<=_}return {...o,status:r,lastUpdate:d,isUp:c,isTimedOut:g}}var L=class extends Error{name="AlgoliaError";constructor(o,r){super(o),r&&(this.name=r);}},$=class extends L{stackTrace;constructor(o,r,d){super(o,d),this.stackTrace=r;}},Z=class extends ${constructor(o){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",o,"RetryError");}},k=class extends ${status;constructor(o,r,d,c="ApiError"){super(o,d,c),this.status=r;}},ee=class extends L{response;constructor(o,r){super(o,"DeserializationError"),this.response=r;}},te=class extends k{error;constructor(o,r,d,c){super(o,r,c,"DetailedApiError"),this.error=d;}};function re(o,r,d){let c=oe(d),g=`${o.protocol}://${o.url}${o.port?`:${o.port}`:""}/${r.charAt(0)==="/"?r.substring(1):r}`;return c.length&&(g+=`?${c}`),g}function oe(o){return Object.keys(o).filter(r=>o[r]!==void 0).sort().map(r=>`${r}=${encodeURIComponent(Object.prototype.toString.call(o[r])==="[object Array]"?o[r].join(","):o[r]).replaceAll("+","%20")}`).join("&")}function se(o,r){if(o.method==="GET"||o.data===void 0&&r.data===void 0)return;let d=Array.isArray(o.data)?o.data:{...o.data,...r.data};return JSON.stringify(d)}function ne(o,r,d){let c={Accept:"application/json",...o,...r,...d},g={};return Object.keys(c).forEach(R=>{let q=c[R];g[R.toLowerCase()]=q;}),g}function ie(o){try{return JSON.parse(o.content)}catch(r){throw new ee(r.message,o)}}function ae({content:o,status:r},d){try{let c=JSON.parse(o);return "error"in c?new te(c.message,r,c.error,d):new k(c.message,r,d)}catch{}return new k(o,r,d)}function ue({isTimedOut:o,status:r}){return !o&&~~r===0}function ce({isTimedOut:o,status:r}){return o||ue({isTimedOut:o,status:r})||~~(r/100)!==2&&~~(r/100)!==4}function de({status:o}){return ~~(o/100)===2}function le(o){return o.map(r=>j(r))}function j(o){let r=o.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...o,request:{...o.request,headers:{...o.request.headers,...r}}}}function J({hosts:o,hostsCache:r,baseHeaders:d,baseQueryParameters:c,algoliaAgent:g,timeouts:R,requester:q,requestsCache:f,responsesCache:e}){async function s(a){let u=await Promise.all(a.map(m=>r.get(m,()=>Promise.resolve(Q(m))))),l=u.filter(m=>m.isUp()),t=u.filter(m=>m.isTimedOut()),p=[...l,...t];return {hosts:p.length>0?p:a,getTimeout(m,P){return (t.length===0&&m===0?1:t.length+3+m)*P}}}async function n(a,u,l=!0){let t=[],p=se(a,u),h=ne(d,a.headers,u.headers),m=a.method==="GET"?{...a.data,...u.data}:{},P={...c,...a.queryParameters,...m};if(g.value&&(P["x-algolia-agent"]=g.value),u&&u.queryParameters)for(let T of Object.keys(u.queryParameters))!u.queryParameters[T]||Object.prototype.toString.call(u.queryParameters[T])==="[object Object]"?P[T]=u.queryParameters[T]:P[T]=u.queryParameters[T].toString();let S=0,y=async(T,x)=>{let C=T.pop();if(C===void 0)throw new Z(le(t));let O={...R,...u.timeouts},F={data:p,headers:h,method:a.method,url:re(C,a.path,P),connectTimeout:x(S,O.connect),responseTimeout:x(S,l?O.read:O.write)},U=N=>{let D={request:F,response:N,host:C,triesLeft:T.length};return t.push(D),D},E=await q.send(F);if(ce(E)){let N=U(E);return E.isTimedOut&&S++,console.log("Retryable failure",j(N)),await r.set(C,Q(C,E.isTimedOut?"timed out":"down")),y(T,x)}if(de(E))return ie(E);throw U(E),ae(E,t)},v=o.filter(T=>T.accept==="readWrite"||(l?T.accept==="read":T.accept==="write")),H=await s(v);return y([...H.hosts].reverse(),H.getTimeout)}function i(a,u={}){let l=a.useReadTransporter||a.method==="GET";if(!l)return n(a,u,l);let t=()=>n(a,u);if((u.cacheable||a.cacheable)!==!0)return t();let h={request:a,requestOptions:u,transporter:{queryParameters:c,headers:d}};return e.get(h,()=>f.get(h,()=>f.set(h,t()).then(m=>Promise.all([f.delete(h),m]),m=>Promise.all([f.delete(h),Promise.reject(m)])).then(([m,P])=>P)),{miss:m=>e.set(h,m)})}return {hostsCache:r,requester:q,timeouts:R,algoliaAgent:g,baseHeaders:d,baseQueryParameters:c,hosts:o,request:i,requestsCache:f,responsesCache:e}}function fe(o){let r={value:`Algolia for JavaScript (${o})`,add(d){let c=`; ${d.segment}${d.version!==void 0?` (${d.version})`:""}`;return r.value.indexOf(c)===-1&&(r.value=`${r.value}${c}`),r}};return r}function M({algoliaAgents:o,client:r,version:d}){let c=fe(d).add({segment:r,version:d});return o.forEach(g=>c.add(g)),c}var z=1e3,B=2e3,X=3e4;function K(){function o(r){return new Promise(d=>{let c=new XMLHttpRequest;c.open(r.method,r.url,!0),Object.keys(r.headers).forEach(f=>c.setRequestHeader(f,r.headers[f]));let g=(f,e)=>setTimeout(()=>{c.abort(),d({status:0,content:e,isTimedOut:!0});},f),R=g(r.connectTimeout,"Connection timeout"),q;c.onreadystatechange=()=>{c.readyState>c.OPENED&&q===void 0&&(clearTimeout(R),q=g(r.responseTimeout,"Socket timeout"));},c.onerror=()=>{c.status===0&&(clearTimeout(R),clearTimeout(q),d({content:c.responseText||"Network request failed",status:c.status,isTimedOut:!1}));},c.onload=()=>{clearTimeout(R),clearTimeout(q),d({content:c.responseText,status:c.status,isTimedOut:!1});},c.send(r.data);})}return {send:o}}var A="5.4.0",b=["de","us"];function me(o){return [{url:o?"analytics.{region}.algolia.com".replace("{region}",o):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function V({appId:o,apiKey:r,authMode:d,algoliaAgents:c,region:g,...R}){let q=I(o,r,d),f=J({hosts:me(g),...R,algoliaAgent:M({algoliaAgents:c,client:"Analytics",version:A}),baseHeaders:{"content-type":"text/plain",...q.headers(),...R.baseHeaders},baseQueryParameters:{...q.queryParameters(),...R.baseQueryParameters}});return {transporter:f,appId:o,clearCache(){return Promise.all([f.requestsCache.clear(),f.responsesCache.clear()]).then(()=>{})},get _ua(){return f.algoliaAgent.value},addAlgoliaAgent(e,s){f.algoliaAgent.add({segment:e,version:s});},setClientApiKey({apiKey:e}){!d||d==="WithinHeaders"?f.baseHeaders["x-algolia-api-key"]=e:f.baseQueryParameters["x-algolia-api-key"]=e;},customDelete({path:e,parameters:s},n){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{}};return f.request(l,n)},customGet({path:e,parameters:s},n){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{}};return f.request(l,n)},customPost({path:e,parameters:s,body:n},i){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");let t={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{},data:n||{}};return f.request(t,i)},customPut({path:e,parameters:s,body:n},i){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");let t={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:s||{},headers:{},data:n||{}};return f.request(t,i)},getAddToCartRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getAddToCartRate`.");let u="/2/conversions/addToCartRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getAverageClickPosition({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getAverageClickPosition`.");let u="/2/clicks/averageClickPosition",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getClickPositions({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getClickPositions`.");let u="/2/clicks/positions",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getClickThroughRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getClickThroughRate`.");let u="/2/clicks/clickThroughRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getConversionRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getConversionRate`.");let u="/2/conversions/conversionRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getNoClickRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getNoClickRate`.");let u="/2/searches/noClickRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getNoResultsRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getNoResultsRate`.");let u="/2/searches/noResultRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getPurchaseRate({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getPurchaseRate`.");let u="/2/conversions/purchaseRate",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getRevenue({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getRevenue`.");let u="/2/conversions/revenue",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getSearchesCount({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesCount`.");let u="/2/searches/count",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)},getSearchesNoClicks({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoClicks`.");let t="/2/searches/noClicks",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getSearchesNoResults({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoResults`.");let t="/2/searches/noResults",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getStatus({index:e},s){if(!e)throw new Error("Parameter `index` is required when calling `getStatus`.");let n="/2/status",i={},a={};e!==void 0&&(a.index=e.toString());let u={method:"GET",path:n,queryParameters:a,headers:i};return f.request(u,s)},getTopCountries({index:e,startDate:s,endDate:n,limit:i,offset:a,tags:u},l){if(!e)throw new Error("Parameter `index` is required when calling `getTopCountries`.");let t="/2/countries",p={},h={};e!==void 0&&(h.index=e.toString()),s!==void 0&&(h.startDate=s.toString()),n!==void 0&&(h.endDate=n.toString()),i!==void 0&&(h.limit=i.toString()),a!==void 0&&(h.offset=a.toString()),u!==void 0&&(h.tags=u.toString());let m={method:"GET",path:t,queryParameters:h,headers:p};return f.request(m,l)},getTopFilterAttributes({index:e,search:s,startDate:n,endDate:i,limit:a,offset:u,tags:l},t){if(!e)throw new Error("Parameter `index` is required when calling `getTopFilterAttributes`.");let p="/2/filters",h={},m={};e!==void 0&&(m.index=e.toString()),s!==void 0&&(m.search=s.toString()),n!==void 0&&(m.startDate=n.toString()),i!==void 0&&(m.endDate=i.toString()),a!==void 0&&(m.limit=a.toString()),u!==void 0&&(m.offset=u.toString()),l!==void 0&&(m.tags=l.toString());let P={method:"GET",path:p,queryParameters:m,headers:h};return f.request(P,t)},getTopFilterForAttribute({attribute:e,index:s,search:n,startDate:i,endDate:a,limit:u,offset:l,tags:t},p){if(!e)throw new Error("Parameter `attribute` is required when calling `getTopFilterForAttribute`.");if(!s)throw new Error("Parameter `index` is required when calling `getTopFilterForAttribute`.");let h="/2/filters/{attribute}".replace("{attribute}",encodeURIComponent(e)),m={},P={};s!==void 0&&(P.index=s.toString()),n!==void 0&&(P.search=n.toString()),i!==void 0&&(P.startDate=i.toString()),a!==void 0&&(P.endDate=a.toString()),u!==void 0&&(P.limit=u.toString()),l!==void 0&&(P.offset=l.toString()),t!==void 0&&(P.tags=t.toString());let S={method:"GET",path:h,queryParameters:P,headers:m};return f.request(S,p)},getTopFiltersNoResults({index:e,search:s,startDate:n,endDate:i,limit:a,offset:u,tags:l},t){if(!e)throw new Error("Parameter `index` is required when calling `getTopFiltersNoResults`.");let p="/2/filters/noResults",h={},m={};e!==void 0&&(m.index=e.toString()),s!==void 0&&(m.search=s.toString()),n!==void 0&&(m.startDate=n.toString()),i!==void 0&&(m.endDate=i.toString()),a!==void 0&&(m.limit=a.toString()),u!==void 0&&(m.offset=u.toString()),l!==void 0&&(m.tags=l.toString());let P={method:"GET",path:p,queryParameters:m,headers:h};return f.request(P,t)},getTopHits({index:e,search:s,clickAnalytics:n,revenueAnalytics:i,startDate:a,endDate:u,limit:l,offset:t,tags:p},h){if(!e)throw new Error("Parameter `index` is required when calling `getTopHits`.");let m="/2/hits",P={},S={};e!==void 0&&(S.index=e.toString()),s!==void 0&&(S.search=s.toString()),n!==void 0&&(S.clickAnalytics=n.toString()),i!==void 0&&(S.revenueAnalytics=i.toString()),a!==void 0&&(S.startDate=a.toString()),u!==void 0&&(S.endDate=u.toString()),l!==void 0&&(S.limit=l.toString()),t!==void 0&&(S.offset=t.toString()),p!==void 0&&(S.tags=p.toString());let y={method:"GET",path:m,queryParameters:S,headers:P};return f.request(y,h)},getTopSearches({index:e,clickAnalytics:s,revenueAnalytics:n,startDate:i,endDate:a,orderBy:u,direction:l,limit:t,offset:p,tags:h},m){if(!e)throw new Error("Parameter `index` is required when calling `getTopSearches`.");let P="/2/searches",S={},y={};e!==void 0&&(y.index=e.toString()),s!==void 0&&(y.clickAnalytics=s.toString()),n!==void 0&&(y.revenueAnalytics=n.toString()),i!==void 0&&(y.startDate=i.toString()),a!==void 0&&(y.endDate=a.toString()),u!==void 0&&(y.orderBy=u.toString()),l!==void 0&&(y.direction=l.toString()),t!==void 0&&(y.limit=t.toString()),p!==void 0&&(y.offset=p.toString()),h!==void 0&&(y.tags=h.toString());let v={method:"GET",path:P,queryParameters:y,headers:S};return f.request(v,m)},getUsersCount({index:e,startDate:s,endDate:n,tags:i},a){if(!e)throw new Error("Parameter `index` is required when calling `getUsersCount`.");let u="/2/users/count",l={},t={};e!==void 0&&(t.index=e.toString()),s!==void 0&&(t.startDate=s.toString()),n!==void 0&&(t.endDate=n.toString()),i!==void 0&&(t.tags=i.toString());let p={method:"GET",path:u,queryParameters:t,headers:l};return f.request(p,a)}}}function xt(o,r,d,c){if(!o||typeof o!="string")throw new Error("`appId` is missing.");if(!r||typeof r!="string")throw new Error("`apiKey` is missing.");if(d&&(typeof d!="string"||!b.includes(d)))throw new Error(`\`region\` must be one of the following: ${b.join(", ")}`);return V({appId:o,apiKey:r,region:d,timeouts:{connect:z,read:B,write:X},requester:K(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:G(),requestsCache:G({serializable:!1}),hostsCache:w({caches:[W({key:`${A}-${o}`}),G()]}),...c})} | ||
exports.analyticsClient = Nt; | ||
exports.apiClientVersion = v; | ||
exports.analyticsClient = xt; | ||
exports.apiClientVersion = A; | ||
})); |
@@ -13,3 +13,3 @@ // builds/node.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.3.2"; | ||
var apiClientVersion = "5.4.0"; | ||
var REGIONS = ["de", "us"]; | ||
@@ -16,0 +16,0 @@ function getDefaultHosts(region) { |
// src/analyticsClient.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.3.2"; | ||
var apiClientVersion = "5.4.0"; | ||
var REGIONS = ["de", "us"]; | ||
@@ -5,0 +5,0 @@ function getDefaultHosts(region) { |
{ | ||
"version": "5.3.2", | ||
"version": "5.4.0", | ||
"repository": { | ||
@@ -29,2 +29,6 @@ "type": "git", | ||
}, | ||
"worker": { | ||
"types": "./dist/fetch.d.ts", | ||
"default": "./dist/builds/fetch.js" | ||
}, | ||
"default": { | ||
@@ -48,5 +52,6 @@ "types": "./dist/browser.d.ts", | ||
"dependencies": { | ||
"@algolia/client-common": "5.3.2", | ||
"@algolia/requester-browser-xhr": "5.3.2", | ||
"@algolia/requester-node-http": "5.3.2" | ||
"@algolia/client-common": "5.4.0", | ||
"@algolia/requester-browser-xhr": "5.4.0", | ||
"@algolia/requester-fetch": "5.4.0", | ||
"@algolia/requester-node-http": "5.4.0" | ||
}, | ||
@@ -53,0 +58,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1240299
81
13411
4
+ Added@algolia/client-common@5.4.0(transitive)
+ Added@algolia/requester-browser-xhr@5.4.0(transitive)
+ Added@algolia/requester-fetch@5.4.0(transitive)
+ Added@algolia/requester-node-http@5.4.0(transitive)
- Removed@algolia/client-common@5.3.2(transitive)
- Removed@algolia/requester-browser-xhr@5.3.2(transitive)
- Removed@algolia/requester-node-http@5.3.2(transitive)
Updated@algolia/client-common@5.4.0