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

@algolia/client-abtesting

Package Overview
Dependencies
Maintainers
0
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/client-abtesting - npm Package Compare versions

Comparing version 5.15.0 to 5.16.0

2

dist/browser.d.ts

@@ -469,3 +469,3 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.15.0";
declare const apiClientVersion = "5.16.0";
declare const REGIONS: readonly ["de", "us"];

@@ -472,0 +472,0 @@ type Region = (typeof REGIONS)[number];

@@ -7,6 +7,3 @@ // builds/browser.ts

createMemoryCache,
createNullLogger,
DEFAULT_CONNECT_TIMEOUT_BROWSER,
DEFAULT_READ_TIMEOUT_BROWSER,
DEFAULT_WRITE_TIMEOUT_BROWSER
createNullLogger
} from "@algolia/client-common";

@@ -16,3 +13,3 @@

import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.15.0";
var apiClientVersion = "5.16.0";
var REGIONS = ["de", "us"];

@@ -408,5 +405,5 @@ function getDefaultHosts(region) {

timeouts: {
connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
read: DEFAULT_READ_TIMEOUT_BROWSER,
write: DEFAULT_WRITE_TIMEOUT_BROWSER
connect: 1e3,
read: 2e3,
write: 3e4
},

@@ -413,0 +410,0 @@ logger: createNullLogger(),

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

function H(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>r.setRequestHeader(n,e.headers[n]));let i=(n,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0})},n),m=i(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(m),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}function $(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function i(){return JSON.parse(r().getItem(s)||"{}")}function m(n){r().setItem(s,JSON.stringify(n))}function p(){let n=t.timeToLive?t.timeToLive*1e3:null,o=i(),a=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(a),!n)return;let c=Object.fromEntries(Object.entries(a).filter(([,d])=>{let P=new Date().getTime();return!(d.timestamp+n<P)}));m(c)}return{get(n,o,a={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(n)])).then(c=>Promise.all([c?c.value:o(),c!==void 0])).then(([c,d])=>Promise.all([c,d||a.miss(c)])).then(([c])=>c)},set(n,o){return Promise.resolve().then(()=>{let a=i();return a[JSON.stringify(n)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(a)),o})},delete(n){return Promise.resolve().then(()=>{let o=i();delete o[JSON.stringify(n)],r().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{r().removeItem(s)})}}}function ee(){return{get(t,e,s={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,s.miss(i)])).then(([i])=>i)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(t){let e=[...t.caches],s=e.shift();return s===void 0?ee():{get(r,i,m={miss:()=>Promise.resolve()}){return s.get(r,i,m).catch(()=>E({caches:e}).get(r,i,m))},set(r,i){return s.set(r,i).catch(()=>E({caches:e}).set(r,i))},delete(r){return s.delete(r).catch(()=>E({caches:e}).delete(r))},clear(){return s.clear().catch(()=>E({caches:e}).clear())}}}function v(t={serializable:!0}){let e={};return{get(s,r,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let p=r();return p.then(n=>i.miss(n)).then(()=>p)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var j=1e3,Q=2e3,J=3e4;function te(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function G(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return{headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function M({algoliaAgents:t,client:e,version:s}){let r=te(s).add({segment:e,version:s});return t.forEach(i=>r.add(i)),r}function z(){return{debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var k=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>k}function i(){return e==="timed out"&&Date.now()-s<=k}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:i}}var F=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},X=class extends F{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},re=class extends X{constructor(t){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.",t,"RetryError")}},C=class extends X{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},se=class extends F{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},oe=class extends C{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function ae(t,e,s){let r=ne(s),i=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(i+=`?${r}`),i}function ne(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replace(/\+/g,"%20")}`).join("&")}function ie(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function ue(t,e,s){let r={Accept:"application/json",...t,...e,...s},i={};return Object.keys(r).forEach(m=>{let p=r[m];i[m.toLowerCase()]=p}),i}function ce(t){try{return JSON.parse(t.content)}catch(e){throw new se(e.message,t)}}function le({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new oe(r.message,e,r.error,s):new C(r.message,e,s)}catch{}return new C(t,e,s)}function me({isTimedOut:t,status:e}){return!t&&~~e===0}function de({isTimedOut:t,status:e}){return t||me({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:t}){return~~(t/100)===2}function pe(t){return t.map(e=>K(e))}function K(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function V({hosts:t,hostsCache:e,baseHeaders:s,logger:r,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:n,requestsCache:o,responsesCache:a}){async function c(u){let l=await Promise.all(u.map(h=>e.get(h,()=>Promise.resolve(W(h))))),f=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),w=[...f,...T];return{hosts:w.length>0?w:u,getTimeout(h,A){return(T.length===0&&h===0?1:T.length+3+h)*A}}}async function d(u,l,f=!0){let T=[],w=ie(u,l),y=ue(s,u.headers,l.headers),h=u.method==="GET"?{...u.data,...l.data}:{},A={...i,...u.queryParameters,...h};if(m.value&&(A["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let g of Object.keys(l.queryParameters))!l.queryParameters[g]||Object.prototype.toString.call(l.queryParameters[g])==="[object Object]"?A[g]=l.queryParameters[g]:A[g]=l.queryParameters[g].toString();let O=0,N=async(g,b)=>{let R=g.pop();if(R===void 0)throw new re(pe(T));let x={...p,...l.timeouts},I={data:w,headers:y,method:u.method,url:ae(R,u.path,A),connectTimeout:b(O,x.connect),responseTimeout:b(O,f?x.read:x.write)},U=S=>{let L={request:I,response:S,host:R,triesLeft:g.length};return T.push(L),L},q=await n.send(I);if(de(q)){let S=U(q);return q.isTimedOut&&O++,r.info("Retryable failure",K(S)),await e.set(R,W(R,q.isTimedOut?"timed out":"down")),N(g,b)}if(he(q))return ce(q);throw U(q),le(q,T)},Z=t.filter(g=>g.accept==="readWrite"||(f?g.accept==="read":g.accept==="write")),D=await c(Z);return N([...D.hosts].reverse(),D.getTimeout)}function P(u,l={}){let f=u.useReadTransporter||u.method==="GET";if(!f)return d(u,l,f);let T=()=>d(u,l);if((l.cacheable||u.cacheable)!==!0)return T();let y={request:u,requestOptions:l,transporter:{queryParameters:i,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,T()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,A])=>A)),{miss:h=>a.set(y,h)})}return{hostsCache:e,requester:n,timeouts:p,logger:r,algoliaAgent:m,baseHeaders:s,baseQueryParameters:i,hosts:t,request:P,requestsCache:o,responsesCache:a}}var B="5.15.0",_=["de","us"];function fe(t){return[{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function Y({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:i,...m}){let p=G(t,e,s),n=V({hosts:fe(i),...m,algoliaAgent:M({algoliaAgents:r,client:"Abtesting",version:B}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return{transporter:n,appId:t,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(o,a){n.algoliaAgent.add({segment:o,version:a})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=o:n.baseQueryParameters["x-algolia-api-key"]=o},addABTests(o,a){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let u={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return n.request(u,a)},customDelete({path:o,parameters:a},c){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return n.request(l,c)},customGet({path:o,parameters:a},c){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return n.request(l,c)},customPost({path:o,parameters:a,body:c},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:c||{}};return n.request(f,d)},customPut({path:o,parameters:a,body:c},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:c||{}};return n.request(f,d)},deleteABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let u={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)},estimateABTest(o,a){if(!o)throw new Error("Parameter `estimateABTestRequest` is required when calling `estimateABTest`.");if(!o.configuration)throw new Error("Parameter `estimateABTestRequest.configuration` is required when calling `estimateABTest`.");if(!o.variants)throw new Error("Parameter `estimateABTestRequest.variants` is required when calling `estimateABTest`.");let u={method:"POST",path:"/2/abtests/estimate",queryParameters:{},headers:{},data:o};return n.request(u,a)},getABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let u={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)},listABTests({offset:o,limit:a,indexPrefix:c,indexSuffix:d}={},P=void 0){let u="/2/abtests",l={},f={};o!==void 0&&(f.offset=o.toString()),a!==void 0&&(f.limit=a.toString()),c!==void 0&&(f.indexPrefix=c.toString()),d!==void 0&&(f.indexSuffix=d.toString());let T={method:"GET",path:u,queryParameters:f,headers:l};return n.request(T,P)},scheduleABTest(o,a){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let u={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return n.request(u,a)},stopABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let u={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)}}}function rt(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!_.includes(s)))throw new Error(`\`region\` must be one of the following: ${_.join(", ")}`);return Y({appId:t,apiKey:e,region:s,timeouts:{connect:j,read:Q,write:J},logger:z(),requester:H(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:v(),requestsCache:v({serializable:!1}),hostsCache:E({caches:[$({key:`${B}-${t}`}),v()]}),...r})}export{rt as abtestingClient,B as apiClientVersion};
function k(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>r.setRequestHeader(n,e.headers[n]));let i=(n,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0})},n),m=i(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(m),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}function j(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function i(){return JSON.parse(r().getItem(s)||"{}")}function m(n){r().setItem(s,JSON.stringify(n))}function p(){let n=t.timeToLive?t.timeToLive*1e3:null,o=i(),a=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(a),!n)return;let c=Object.fromEntries(Object.entries(a).filter(([,d])=>{let P=new Date().getTime();return!(d.timestamp+n<P)}));m(c)}return{get(n,o,a={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(n)])).then(c=>Promise.all([c?c.value:o(),c!==void 0])).then(([c,d])=>Promise.all([c,d||a.miss(c)])).then(([c])=>c)},set(n,o){return Promise.resolve().then(()=>{let a=i();return a[JSON.stringify(n)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(a)),o})},delete(n){return Promise.resolve().then(()=>{let o=i();delete o[JSON.stringify(n)],r().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{r().removeItem(s)})}}}function V(){return{get(t,e,s={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,s.miss(i)])).then(([i])=>i)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(t){let e=[...t.caches],s=e.shift();return s===void 0?V():{get(r,i,m={miss:()=>Promise.resolve()}){return s.get(r,i,m).catch(()=>w({caches:e}).get(r,i,m))},set(r,i){return s.set(r,i).catch(()=>w({caches:e}).set(r,i))},delete(r){return s.delete(r).catch(()=>w({caches:e}).delete(r))},clear(){return s.clear().catch(()=>w({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return{get(s,r,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let p=r();return p.then(n=>i.miss(n)).then(()=>p)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function Q(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return{headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function W({algoliaAgents:t,client:e,version:s}){let r=Y(s).add({segment:e,version:s});return t.forEach(i=>r.add(i)),r}function J(){return{debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var U=2*60*1e3;function $(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>U}function i(){return e==="timed out"&&Date.now()-s<=U}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:i}}var G=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},z=class extends G{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},Z=class extends z{constructor(t){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.",t,"RetryError")}},C=class extends z{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},ee=class extends G{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},te=class extends C{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function re(t,e,s){let r=se(s),i=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(i+=`?${r}`),i}function se(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replace(/\+/g,"%20")}`).join("&")}function oe(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function ae(t,e,s){let r={Accept:"application/json",...t,...e,...s},i={};return Object.keys(r).forEach(m=>{let p=r[m];i[m.toLowerCase()]=p}),i}function ne(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new te(r.message,e,r.error,s):new C(r.message,e,s)}catch{}return new C(t,e,s)}function ue({isTimedOut:t,status:e}){return!t&&~~e===0}function ce({isTimedOut:t,status:e}){return t||ue({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:t}){return~~(t/100)===2}function me(t){return t.map(e=>M(e))}function M(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function F({hosts:t,hostsCache:e,baseHeaders:s,logger:r,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:n,requestsCache:o,responsesCache:a}){async function c(u){let l=await Promise.all(u.map(h=>e.get(h,()=>Promise.resolve($(h))))),f=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),E=[...f,...T];return{hosts:E.length>0?E:u,getTimeout(h,A){return(T.length===0&&h===0?1:T.length+3+h)*A}}}async function d(u,l,f=!0){let T=[],E=oe(u,l),y=ae(s,u.headers,l.headers),h=u.method==="GET"?{...u.data,...l.data}:{},A={...i,...u.queryParameters,...h};if(m.value&&(A["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let g of Object.keys(l.queryParameters))!l.queryParameters[g]||Object.prototype.toString.call(l.queryParameters[g])==="[object Object]"?A[g]=l.queryParameters[g]:A[g]=l.queryParameters[g].toString();let v=0,D=async(g,b)=>{let R=g.pop();if(R===void 0)throw new Z(me(T));let x={...p,...l.timeouts},I={data:E,headers:y,method:u.method,url:re(R,u.path,A),connectTimeout:b(v,x.connect),responseTimeout:b(v,f?x.read:x.write)},H=S=>{let L={request:I,response:S,host:R,triesLeft:g.length};return T.push(L),L},q=await n.send(I);if(ce(q)){let S=H(q);return q.isTimedOut&&v++,r.info("Retryable failure",M(S)),await e.set(R,$(R,q.isTimedOut?"timed out":"down")),D(g,b)}if(le(q))return ne(q);throw H(q),ie(q,T)},K=t.filter(g=>g.accept==="readWrite"||(f?g.accept==="read":g.accept==="write")),_=await c(K);return D([..._.hosts].reverse(),_.getTimeout)}function P(u,l={}){let f=u.useReadTransporter||u.method==="GET";if(!f)return d(u,l,f);let T=()=>d(u,l);if((l.cacheable||u.cacheable)!==!0)return T();let y={request:u,requestOptions:l,transporter:{queryParameters:i,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,T()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,A])=>A)),{miss:h=>a.set(y,h)})}return{hostsCache:e,requester:n,timeouts:p,logger:r,algoliaAgent:m,baseHeaders:s,baseQueryParameters:i,hosts:t,request:P,requestsCache:o,responsesCache:a}}var B="5.16.0",N=["de","us"];function de(t){return[{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function X({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:i,...m}){let p=Q(t,e,s),n=F({hosts:de(i),...m,algoliaAgent:W({algoliaAgents:r,client:"Abtesting",version:B}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return{transporter:n,appId:t,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(o,a){n.algoliaAgent.add({segment:o,version:a})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=o:n.baseQueryParameters["x-algolia-api-key"]=o},addABTests(o,a){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let u={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return n.request(u,a)},customDelete({path:o,parameters:a},c){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return n.request(l,c)},customGet({path:o,parameters:a},c){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return n.request(l,c)},customPost({path:o,parameters:a,body:c},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:c||{}};return n.request(f,d)},customPut({path:o,parameters:a,body:c},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:c||{}};return n.request(f,d)},deleteABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let u={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)},estimateABTest(o,a){if(!o)throw new Error("Parameter `estimateABTestRequest` is required when calling `estimateABTest`.");if(!o.configuration)throw new Error("Parameter `estimateABTestRequest.configuration` is required when calling `estimateABTest`.");if(!o.variants)throw new Error("Parameter `estimateABTestRequest.variants` is required when calling `estimateABTest`.");let u={method:"POST",path:"/2/abtests/estimate",queryParameters:{},headers:{},data:o};return n.request(u,a)},getABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let u={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)},listABTests({offset:o,limit:a,indexPrefix:c,indexSuffix:d}={},P=void 0){let u="/2/abtests",l={},f={};o!==void 0&&(f.offset=o.toString()),a!==void 0&&(f.limit=a.toString()),c!==void 0&&(f.indexPrefix=c.toString()),d!==void 0&&(f.indexSuffix=d.toString());let T={method:"GET",path:u,queryParameters:f,headers:l};return n.request(T,P)},scheduleABTest(o,a){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let u={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return n.request(u,a)},stopABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let u={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)}}}function Ze(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return X({appId:t,apiKey:e,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},logger:J(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:w({caches:[j({key:`${B}-${t}`}),O()]}),...r})}export{Ze as abtestingClient,B as apiClientVersion};
//# sourceMappingURL=browser.min.js.map

@@ -7,7 +7,7 @@ (function (global, factory) {

function H(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>r.setRequestHeader(n,e.headers[n]));let i=(n,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0});},n),m=i(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}));},r.onload=()=>{clearTimeout(m),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1});},r.send(e.data);})}return {send:t}}function $(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function i(){return JSON.parse(r().getItem(s)||"{}")}function m(n){r().setItem(s,JSON.stringify(n));}function p(){let n=t.timeToLive?t.timeToLive*1e3:null,o=i(),a=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(a),!n)return;let c=Object.fromEntries(Object.entries(a).filter(([,d])=>{let P=new Date().getTime();return !(d.timestamp+n<P)}));m(c);}return {get(n,o,a={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(n)])).then(c=>Promise.all([c?c.value:o(),c!==void 0])).then(([c,d])=>Promise.all([c,d||a.miss(c)])).then(([c])=>c)},set(n,o){return Promise.resolve().then(()=>{let a=i();return a[JSON.stringify(n)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(a)),o})},delete(n){return Promise.resolve().then(()=>{let o=i();delete o[JSON.stringify(n)],r().setItem(s,JSON.stringify(o));})},clear(){return Promise.resolve().then(()=>{r().removeItem(s);})}}}function ee(){return {get(t,e,s={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,s.miss(i)])).then(([i])=>i)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(t){let e=[...t.caches],s=e.shift();return s===void 0?ee():{get(r,i,m={miss:()=>Promise.resolve()}){return s.get(r,i,m).catch(()=>E({caches:e}).get(r,i,m))},set(r,i){return s.set(r,i).catch(()=>E({caches:e}).set(r,i))},delete(r){return s.delete(r).catch(()=>E({caches:e}).delete(r))},clear(){return s.clear().catch(()=>E({caches:e}).clear())}}}function v(t={serializable:!0}){let e={};return {get(s,r,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let p=r();return p.then(n=>i.miss(n)).then(()=>p)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var j=1e3,Q=2e3,J=3e4;function te(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function G(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return {headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function M({algoliaAgents:t,client:e,version:s}){let r=te(s).add({segment:e,version:s});return t.forEach(i=>r.add(i)),r}function z(){return {debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var k=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>k}function i(){return e==="timed out"&&Date.now()-s<=k}return {...t,status:e,lastUpdate:s,isUp:r,isTimedOut:i}}var F=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e);}},X=class extends F{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e;}},re=class extends X{constructor(t){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.",t,"RetryError");}},C=class extends X{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e;}},se=class extends F{response;constructor(t,e){super(t,"DeserializationError"),this.response=e;}},oe=class extends C{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s;}};function ae(t,e,s){let r=ne(s),i=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(i+=`?${r}`),i}function ne(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replace(/\+/g,"%20")}`).join("&")}function ie(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function ue(t,e,s){let r={Accept:"application/json",...t,...e,...s},i={};return Object.keys(r).forEach(m=>{let p=r[m];i[m.toLowerCase()]=p;}),i}function ce(t){try{return JSON.parse(t.content)}catch(e){throw new se(e.message,t)}}function le({content:t,status:e},s){try{let r=JSON.parse(t);return "error"in r?new oe(r.message,e,r.error,s):new C(r.message,e,s)}catch{}return new C(t,e,s)}function me({isTimedOut:t,status:e}){return !t&&~~e===0}function de({isTimedOut:t,status:e}){return t||me({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:t}){return ~~(t/100)===2}function pe(t){return t.map(e=>K(e))}function K(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function V({hosts:t,hostsCache:e,baseHeaders:s,logger:r,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:n,requestsCache:o,responsesCache:a}){async function c(u){let l=await Promise.all(u.map(h=>e.get(h,()=>Promise.resolve(W(h))))),f=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),w=[...f,...T];return {hosts:w.length>0?w:u,getTimeout(h,A){return (T.length===0&&h===0?1:T.length+3+h)*A}}}async function d(u,l,f=!0){let T=[],w=ie(u,l),y=ue(s,u.headers,l.headers),h=u.method==="GET"?{...u.data,...l.data}:{},A={...i,...u.queryParameters,...h};if(m.value&&(A["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let g of Object.keys(l.queryParameters))!l.queryParameters[g]||Object.prototype.toString.call(l.queryParameters[g])==="[object Object]"?A[g]=l.queryParameters[g]:A[g]=l.queryParameters[g].toString();let O=0,N=async(g,b)=>{let R=g.pop();if(R===void 0)throw new re(pe(T));let x={...p,...l.timeouts},I={data:w,headers:y,method:u.method,url:ae(R,u.path,A),connectTimeout:b(O,x.connect),responseTimeout:b(O,f?x.read:x.write)},U=S=>{let L={request:I,response:S,host:R,triesLeft:g.length};return T.push(L),L},q=await n.send(I);if(de(q)){let S=U(q);return q.isTimedOut&&O++,r.info("Retryable failure",K(S)),await e.set(R,W(R,q.isTimedOut?"timed out":"down")),N(g,b)}if(he(q))return ce(q);throw U(q),le(q,T)},Z=t.filter(g=>g.accept==="readWrite"||(f?g.accept==="read":g.accept==="write")),D=await c(Z);return N([...D.hosts].reverse(),D.getTimeout)}function P(u,l={}){let f=u.useReadTransporter||u.method==="GET";if(!f)return d(u,l,f);let T=()=>d(u,l);if((l.cacheable||u.cacheable)!==!0)return T();let y={request:u,requestOptions:l,transporter:{queryParameters:i,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,T()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,A])=>A)),{miss:h=>a.set(y,h)})}return {hostsCache:e,requester:n,timeouts:p,logger:r,algoliaAgent:m,baseHeaders:s,baseQueryParameters:i,hosts:t,request:P,requestsCache:o,responsesCache:a}}var B="5.15.0",_=["de","us"];function fe(t){return [{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function Y({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:i,...m}){let p=G(t,e,s),n=V({hosts:fe(i),...m,algoliaAgent:M({algoliaAgents:r,client:"Abtesting",version:B}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return {transporter:n,appId:t,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(o,a){n.algoliaAgent.add({segment:o,version:a});},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=o:n.baseQueryParameters["x-algolia-api-key"]=o;},addABTests(o,a){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let u={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return n.request(u,a)},customDelete({path:o,parameters:a},c){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return n.request(l,c)},customGet({path:o,parameters:a},c){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return n.request(l,c)},customPost({path:o,parameters:a,body:c},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:c||{}};return n.request(f,d)},customPut({path:o,parameters:a,body:c},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:c||{}};return n.request(f,d)},deleteABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let u={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)},estimateABTest(o,a){if(!o)throw new Error("Parameter `estimateABTestRequest` is required when calling `estimateABTest`.");if(!o.configuration)throw new Error("Parameter `estimateABTestRequest.configuration` is required when calling `estimateABTest`.");if(!o.variants)throw new Error("Parameter `estimateABTestRequest.variants` is required when calling `estimateABTest`.");let u={method:"POST",path:"/2/abtests/estimate",queryParameters:{},headers:{},data:o};return n.request(u,a)},getABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let u={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)},listABTests({offset:o,limit:a,indexPrefix:c,indexSuffix:d}={},P=void 0){let u="/2/abtests",l={},f={};o!==void 0&&(f.offset=o.toString()),a!==void 0&&(f.limit=a.toString()),c!==void 0&&(f.indexPrefix=c.toString()),d!==void 0&&(f.indexSuffix=d.toString());let T={method:"GET",path:u,queryParameters:f,headers:l};return n.request(T,P)},scheduleABTest(o,a){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let u={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return n.request(u,a)},stopABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let u={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)}}}function rt(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!_.includes(s)))throw new Error(`\`region\` must be one of the following: ${_.join(", ")}`);return Y({appId:t,apiKey:e,region:s,timeouts:{connect:j,read:Q,write:J},logger:z(),requester:H(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:v(),requestsCache:v({serializable:!1}),hostsCache:E({caches:[$({key:`${B}-${t}`}),v()]}),...r})}
function k(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>r.setRequestHeader(n,e.headers[n]));let i=(n,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0});},n),m=i(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}));},r.onload=()=>{clearTimeout(m),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1});},r.send(e.data);})}return {send:t}}function j(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function i(){return JSON.parse(r().getItem(s)||"{}")}function m(n){r().setItem(s,JSON.stringify(n));}function p(){let n=t.timeToLive?t.timeToLive*1e3:null,o=i(),a=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(a),!n)return;let c=Object.fromEntries(Object.entries(a).filter(([,d])=>{let P=new Date().getTime();return !(d.timestamp+n<P)}));m(c);}return {get(n,o,a={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(n)])).then(c=>Promise.all([c?c.value:o(),c!==void 0])).then(([c,d])=>Promise.all([c,d||a.miss(c)])).then(([c])=>c)},set(n,o){return Promise.resolve().then(()=>{let a=i();return a[JSON.stringify(n)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(a)),o})},delete(n){return Promise.resolve().then(()=>{let o=i();delete o[JSON.stringify(n)],r().setItem(s,JSON.stringify(o));})},clear(){return Promise.resolve().then(()=>{r().removeItem(s);})}}}function V(){return {get(t,e,s={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,s.miss(i)])).then(([i])=>i)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(t){let e=[...t.caches],s=e.shift();return s===void 0?V():{get(r,i,m={miss:()=>Promise.resolve()}){return s.get(r,i,m).catch(()=>w({caches:e}).get(r,i,m))},set(r,i){return s.set(r,i).catch(()=>w({caches:e}).set(r,i))},delete(r){return s.delete(r).catch(()=>w({caches:e}).delete(r))},clear(){return s.clear().catch(()=>w({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return {get(s,r,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let p=r();return p.then(n=>i.miss(n)).then(()=>p)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function Q(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return {headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function W({algoliaAgents:t,client:e,version:s}){let r=Y(s).add({segment:e,version:s});return t.forEach(i=>r.add(i)),r}function J(){return {debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var U=2*60*1e3;function $(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>U}function i(){return e==="timed out"&&Date.now()-s<=U}return {...t,status:e,lastUpdate:s,isUp:r,isTimedOut:i}}var G=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e);}},z=class extends G{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e;}},Z=class extends z{constructor(t){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.",t,"RetryError");}},C=class extends z{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e;}},ee=class extends G{response;constructor(t,e){super(t,"DeserializationError"),this.response=e;}},te=class extends C{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s;}};function re(t,e,s){let r=se(s),i=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(i+=`?${r}`),i}function se(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replace(/\+/g,"%20")}`).join("&")}function oe(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function ae(t,e,s){let r={Accept:"application/json",...t,...e,...s},i={};return Object.keys(r).forEach(m=>{let p=r[m];i[m.toLowerCase()]=p;}),i}function ne(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},s){try{let r=JSON.parse(t);return "error"in r?new te(r.message,e,r.error,s):new C(r.message,e,s)}catch{}return new C(t,e,s)}function ue({isTimedOut:t,status:e}){return !t&&~~e===0}function ce({isTimedOut:t,status:e}){return t||ue({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:t}){return ~~(t/100)===2}function me(t){return t.map(e=>M(e))}function M(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function F({hosts:t,hostsCache:e,baseHeaders:s,logger:r,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:n,requestsCache:o,responsesCache:a}){async function c(u){let l=await Promise.all(u.map(h=>e.get(h,()=>Promise.resolve($(h))))),f=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),E=[...f,...T];return {hosts:E.length>0?E:u,getTimeout(h,A){return (T.length===0&&h===0?1:T.length+3+h)*A}}}async function d(u,l,f=!0){let T=[],E=oe(u,l),y=ae(s,u.headers,l.headers),h=u.method==="GET"?{...u.data,...l.data}:{},A={...i,...u.queryParameters,...h};if(m.value&&(A["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let g of Object.keys(l.queryParameters))!l.queryParameters[g]||Object.prototype.toString.call(l.queryParameters[g])==="[object Object]"?A[g]=l.queryParameters[g]:A[g]=l.queryParameters[g].toString();let v=0,D=async(g,b)=>{let R=g.pop();if(R===void 0)throw new Z(me(T));let x={...p,...l.timeouts},I={data:E,headers:y,method:u.method,url:re(R,u.path,A),connectTimeout:b(v,x.connect),responseTimeout:b(v,f?x.read:x.write)},H=S=>{let L={request:I,response:S,host:R,triesLeft:g.length};return T.push(L),L},q=await n.send(I);if(ce(q)){let S=H(q);return q.isTimedOut&&v++,r.info("Retryable failure",M(S)),await e.set(R,$(R,q.isTimedOut?"timed out":"down")),D(g,b)}if(le(q))return ne(q);throw H(q),ie(q,T)},K=t.filter(g=>g.accept==="readWrite"||(f?g.accept==="read":g.accept==="write")),_=await c(K);return D([..._.hosts].reverse(),_.getTimeout)}function P(u,l={}){let f=u.useReadTransporter||u.method==="GET";if(!f)return d(u,l,f);let T=()=>d(u,l);if((l.cacheable||u.cacheable)!==!0)return T();let y={request:u,requestOptions:l,transporter:{queryParameters:i,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,T()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,A])=>A)),{miss:h=>a.set(y,h)})}return {hostsCache:e,requester:n,timeouts:p,logger:r,algoliaAgent:m,baseHeaders:s,baseQueryParameters:i,hosts:t,request:P,requestsCache:o,responsesCache:a}}var B="5.16.0",N=["de","us"];function de(t){return [{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function X({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:i,...m}){let p=Q(t,e,s),n=F({hosts:de(i),...m,algoliaAgent:W({algoliaAgents:r,client:"Abtesting",version:B}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return {transporter:n,appId:t,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(o,a){n.algoliaAgent.add({segment:o,version:a});},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=o:n.baseQueryParameters["x-algolia-api-key"]=o;},addABTests(o,a){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let u={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return n.request(u,a)},customDelete({path:o,parameters:a},c){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return n.request(l,c)},customGet({path:o,parameters:a},c){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return n.request(l,c)},customPost({path:o,parameters:a,body:c},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:c||{}};return n.request(f,d)},customPut({path:o,parameters:a,body:c},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:c||{}};return n.request(f,d)},deleteABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let u={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)},estimateABTest(o,a){if(!o)throw new Error("Parameter `estimateABTestRequest` is required when calling `estimateABTest`.");if(!o.configuration)throw new Error("Parameter `estimateABTestRequest.configuration` is required when calling `estimateABTest`.");if(!o.variants)throw new Error("Parameter `estimateABTestRequest.variants` is required when calling `estimateABTest`.");let u={method:"POST",path:"/2/abtests/estimate",queryParameters:{},headers:{},data:o};return n.request(u,a)},getABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let u={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)},listABTests({offset:o,limit:a,indexPrefix:c,indexSuffix:d}={},P=void 0){let u="/2/abtests",l={},f={};o!==void 0&&(f.offset=o.toString()),a!==void 0&&(f.limit=a.toString()),c!==void 0&&(f.indexPrefix=c.toString()),d!==void 0&&(f.indexSuffix=d.toString());let T={method:"GET",path:u,queryParameters:f,headers:l};return n.request(T,P)},scheduleABTest(o,a){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let u={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return n.request(u,a)},stopABTest({id:o},a){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let u={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return n.request(u,a)}}}function Ze(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return X({appId:t,apiKey:e,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},logger:J(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:w({caches:[j({key:`${B}-${t}`}),O()]}),...r})}
exports.abtestingClient = rt;
exports.abtestingClient = Ze;
exports.apiClientVersion = B;
}));
// builds/fetch.ts
import {
createMemoryCache,
createNullCache,
createNullLogger,
DEFAULT_CONNECT_TIMEOUT_NODE,
DEFAULT_READ_TIMEOUT_NODE,
DEFAULT_WRITE_TIMEOUT_NODE
} from "@algolia/client-common";
import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/client-common";
import { createFetchRequester } from "@algolia/requester-fetch";

@@ -14,3 +7,3 @@

import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.15.0";
var apiClientVersion = "5.16.0";
var REGIONS = ["de", "us"];

@@ -407,5 +400,5 @@ function getDefaultHosts(region) {

timeouts: {
connect: DEFAULT_CONNECT_TIMEOUT_NODE,
read: DEFAULT_READ_TIMEOUT_NODE,
write: DEFAULT_WRITE_TIMEOUT_NODE
connect: 2e3,
read: 5e3,
write: 3e4
},

@@ -412,0 +405,0 @@ logger: createNullLogger(),

// builds/node.ts
import { createHttpRequester } from "@algolia/requester-node-http";
import {
createMemoryCache,
createNullCache,
createNullLogger,
DEFAULT_CONNECT_TIMEOUT_NODE,
DEFAULT_READ_TIMEOUT_NODE,
DEFAULT_WRITE_TIMEOUT_NODE
} from "@algolia/client-common";
import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/client-common";
// src/abtestingClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.15.0";
var apiClientVersion = "5.16.0";
var REGIONS = ["de", "us"];

@@ -406,5 +399,5 @@ function getDefaultHosts(region) {

timeouts: {
connect: DEFAULT_CONNECT_TIMEOUT_NODE,
read: DEFAULT_READ_TIMEOUT_NODE,
write: DEFAULT_WRITE_TIMEOUT_NODE
connect: 2e3,
read: 5e3,
write: 3e4
},

@@ -411,0 +404,0 @@ logger: createNullLogger(),

@@ -469,3 +469,3 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.15.0";
declare const apiClientVersion = "5.16.0";
declare const REGIONS: readonly ["de", "us"];

@@ -472,0 +472,0 @@ type Region = (typeof REGIONS)[number];

@@ -469,3 +469,3 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.15.0";
declare const apiClientVersion = "5.16.0";
declare const REGIONS: readonly ["de", "us"];

@@ -472,0 +472,0 @@ type Region = (typeof REGIONS)[number];

// src/abtestingClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.15.0";
var apiClientVersion = "5.16.0";
var REGIONS = ["de", "us"];

@@ -5,0 +5,0 @@ function getDefaultHosts(region) {

{
"version": "5.15.0",
"version": "5.16.0",
"repository": {

@@ -7,2 +7,3 @@ "type": "git",

},
"homepage": "https://github.com/algolia/algoliasearch-client-javascript/packages/client-abtesting#readme",
"type": "module",

@@ -52,14 +53,14 @@ "license": "MIT",

"dependencies": {
"@algolia/client-common": "5.15.0",
"@algolia/requester-browser-xhr": "5.15.0",
"@algolia/requester-fetch": "5.15.0",
"@algolia/requester-node-http": "5.15.0"
"@algolia/client-common": "5.16.0",
"@algolia/requester-browser-xhr": "5.16.0",
"@algolia/requester-fetch": "5.16.0",
"@algolia/requester-node-http": "5.16.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.17.0",
"@types/node": "22.9.0",
"@arethetypeswrong/cli": "0.17.1",
"@types/node": "22.10.1",
"publint": "0.2.12",
"rollup": "4.27.2",
"rollup": "4.28.1",
"tsup": "8.3.5",
"typescript": "5.6.3"
"typescript": "5.7.2"
},

@@ -66,0 +67,0 @@ "engines": {

@@ -44,7 +44,7 @@ <p align="center">

```bash
yarn add @algolia/client-abtesting@5.15.0
yarn add @algolia/client-abtesting@5.16.0
# or
npm install @algolia/client-abtesting@5.15.0
npm install @algolia/client-abtesting@5.16.0
# or
pnpm add @algolia/client-abtesting@5.15.0
pnpm add @algolia/client-abtesting@5.16.0
```

@@ -57,3 +57,3 @@

```html
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-abtesting@5.15.0/dist/builds/browser.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-abtesting@5.16.0/dist/builds/browser.umd.js"></script>
```

@@ -60,0 +60,0 @@

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 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

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