/**
 * Minified by jsDelivr using Terser v5.48.0.
 * Original file: /npm/@algolia/client-personalization@5.64.0/dist/builds/browser.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-personalization"]={})}(this,function(e){"use strict";function t(e){let t,r=`algolia-client-js-${e.key}`;function a(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function s(){return JSON.parse(a().getItem(r)||"{}")}function o(){return new Promise(e=>setTimeout(e,0))}return{get:(t,n,i={miss:()=>Promise.resolve()})=>o().then(()=>{let{namespace:o,changed:l}=function(){let t=e.timeToLive?1e3*e.timeToLive:null,r=s(),a=(new Date).getTime(),o=!1;return{namespace:Object.fromEntries(Object.entries(r).filter(([,e])=>!(!e||void 0===e.timestamp||t&&e.timestamp+t<a)||(o=!0,!1))),changed:o}}(),u=o[JSON.stringify(t)];return l&&function(e){a().setItem(r,JSON.stringify(e))}(o),u?u.value:n().then(e=>i.miss(e).then(()=>e))}),set:(e,t)=>o().then(()=>{let o=s();return o[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},a().setItem(r,JSON.stringify(o)),t}),delete:e=>o().then(()=>{let t=s();delete t[JSON.stringify(e)],a().setItem(r,JSON.stringify(t))}),clear:()=>Promise.resolve().then(()=>{a().removeItem(r)})}}function r(e){let t=[...e.caches],a=t.shift();return void 0===a?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then(e=>Promise.all([e,r.miss(e)])).then(([e])=>e),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,s,o={miss:()=>Promise.resolve()})=>a.get(e,s,o).catch(()=>r({caches:t}).get(e,s,o)),set:(e,s)=>a.set(e,s).catch(()=>r({caches:t}).set(e,s)),delete:e=>a.delete(e).catch(()=>r({caches:t}).delete(e)),clear:()=>a.clear().catch(()=>r({caches:t}).clear())}}function a(e={serializable:!0}){let t={};return{get(r,a,s={miss:()=>Promise.resolve()}){let o=JSON.stringify(r);if(o in t)return Promise.resolve(e.serializable?JSON.parse(t[o]):t[o]);let n=a();return n.then(e=>s.miss(e)).then(()=>n)},set:(r,a)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(a):a,Promise.resolve(a)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}function s({algoliaAgents:e,client:t,version:r}){let a=function(e){let t={value:`Algolia for JavaScript (${e})`,add(e){let r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach(e=>a.add(e)),a}async function*o(e){let t=new TextDecoder("utf-8"),r=[],a=0,s=!1,o=!0;for await(let n of function(e){return Symbol.asyncIterator in e?e:async function*(e){let t=e.getReader();try{for(;;){let{done:e,value:r}=await t.read();if(e)return;yield r}}finally{t.releaseLock()}}(e)}(e)){let e=t.decode(n,{stream:!0}),i=0;for(s&&(s=!1,e.length>0&&"\n"===e[0]&&(i=1));i<e.length;){let t,n,l=e.indexOf("\r",i),u=e.indexOf("\n",i);if(-1===l&&-1===u){let t=e.slice(i);if(r.push(t),a+=t.length,a>10485760)throw new Error("SSE line buffer exceeded 10MB");break}-1!==l&&(-1===u||l<u)?(t=l,l+1<e.length?n="\n"===e[l+1]?2:1:(s=!0,n=1)):(t=u,n=1);let c=e.slice(i,t);r.push(c);let h=1===r.length?r[0]:r.join("");r.length=0,a=0,o&&(h.startsWith("\ufeff")&&(h=h.slice(1)),o=!1),yield h,i=t+n}}let n=t.decode();if(n&&r.push(n),r.length>0){let e=r.join("");o&&e.startsWith("\ufeff")&&(e=e.slice(1)),yield e}}var n=class{data=[];eventType="";lastEventId=null;retry=null;decode(e){if(""===e)return this.dispatch();if(":"===e[0])return null;let t,r,a=e.indexOf(":");switch(-1===a?(t=e,r=""):(t=e.slice(0,a),r=e.slice(a+1)," "===r[0]&&(r=r.slice(1))),t){case"data":this.data.push(r);break;case"event":this.eventType=r;break;case"id":r.includes("\0")||(this.lastEventId=r);break;case"retry":/^[0-9]+$/.test(r)&&(this.retry=parseInt(r,10))}return null}dispatch(){let e=this.eventType;if(this.eventType="",0===this.data.length)return null;let t={data:this.data.join("\n"),event:e,id:this.lastEventId,retry:this.retry};return this.data=[],t}};async function*i(e){let t=new n;for await(let r of o(e)){let e=t.decode(r);null!==e&&(yield e)}}var l=12e4;function u(e,t="up"){let r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>l},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=l}}}var c=class extends Error{name="AlgoliaError";constructor(e,t){super(e),t&&(this.name=t)}},h=class extends c{stackTrace;correlationId;constructor(e,t,r,a){super(a?`${e} (Correlation-ID: ${a})`:e,r),this.stackTrace=t,this.correlationId=a}},d=class extends h{constructor(e,t){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",e,"RetryError",t)}},p=class extends h{status;constructor(e,t,r,a="ApiError",s){super(e,r,a,s),this.status=t}},m=class extends c{response;correlationId;constructor(e,t,r){super(r?`${e} (Correlation-ID: ${r})`:e,"DeserializationError"),this.response=t,this.correlationId=r}},f=class extends p{error;constructor(e,t,r,a,s){super(e,t,a,"DetailedApiError",s),this.error=r}};function g(e,t,r){let a=function(e){return Object.keys(e).filter(t=>void 0!==e[t]).sort().map(t=>`${t}=${encodeURIComponent("[object Array]"===Object.prototype.toString.call(e[t])?e[t].join(","):e[t]).replace(/\+/g,"%20")}`).join("&")}(r),s=`${e.protocol}://${e.url}${e.port?`:${e.port}`:""}/${"/"===t.charAt(0)?t.substring(1):t}`;return a.length&&(s+=`?${a}`),s}function y(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;let r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}function P(e,t,r){let a={Accept:"application/json",...e,...t,...r},s={};return Object.keys(a).forEach(e=>{let t=a[e];s[e.toLowerCase()]=t}),s}function T(e){if(204!==e.status&&0!==e.content.length)try{return JSON.parse(e.content)}catch(t){throw new m(t.message,e,v(e.headers))}}function v(e){if(!e)return;if(void 0!==e["correlation-id"])return e["correlation-id"];let t=Object.keys(e).find(e=>"correlation-id"===e.toLowerCase());return void 0===t?void 0:e[t]}var q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function w(){var e;let t="";if("function"==typeof(null==(e=globalThis.crypto)?void 0:e.getRandomValues)){let e=new Uint8Array(11);globalThis.crypto.getRandomValues(e);for(let r of e)t+=q[r%62];return t}for(let e=0;e<11;e++)t+=q[Math.floor(62*Math.random())];return t}function S({status:e}){return 429===~~e}var b=/^HTTP 429(?:\D|$)/;function I(e){return"object"==typeof e&&null!==e&&"status"in e?S(e):e instanceof Error&&b.test(e.message)}function O(e){if("object"==typeof e&&null!==e&&"headers"in e)return e.headers}function E(e){var t;let r=null==(t=e?.["retry-after"])?void 0:t.trim();if(void 0===r||0===r.length||!/^\d+$/.test(r))return 1e3;let a=Number.parseInt(r,10);return a<=0?1e3:1e3*a}function k(e){return e.map(e=>z(e))}function z(e){let t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function H({hosts:e,hostsCache:t,baseHeaders:r,logger:a,baseQueryParameters:s,algoliaAgent:o,timeouts:n,requester:l,requestsCache:c,responsesCache:h,compress:m,compression:q,requestIdChannel:b,maxRateLimitRetries:H=3}){function W(e,t){void 0===b||void 0!==e["request-id"]||Object.keys(t).some(e=>"x-algolia-request-id"===e.toLowerCase())||("headers"===b?e["request-id"]=w():t["x-algolia-request-id"]=w())}let x=e=>new Promise(t=>{setTimeout(t,e)});async function C(e){let r=await Promise.all(e.map(e=>t.get(e,()=>Promise.resolve(u(e))))),a=r.filter(e=>e.isUp()),s=r.filter(e=>e.isTimedOut()),o=[...a,...s];return{hosts:o.length>0?o:e,getTimeout:(e,t)=>(0===s.length&&0===e?1:s.length+3+e)*t}}async function j(i,c,h){let T=[],w=y(i,c),b=P(r,i.headers,c.headers),I="gzip"===q&&void 0!==w&&w.length>750&&("POST"===i.method||"PUT"===i.method);I&&void 0===m&&a.info("Compression is disabled because no compress method is available.");let O=I&&void 0!==m,j=O?await m(w):w;O&&(b["content-encoding"]="gzip");let A="GET"===i.method?{...i.data,...c.data}:{},$={...s,...i.queryParameters,...A};if(o.value&&($["x-algolia-agent"]=o.value),c&&c.queryParameters)for(let e of Object.keys(c.queryParameters))c.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(c.queryParameters[e])?$[e]=c.queryParameters[e].toString():$[e]=c.queryParameters[e];W(b,$);let R=0,U=H,D=async(e,r)=>{let s=e.pop();if(void 0===s)throw new d(k(T),function(e){for(let t=e.length-1;t>=0;t--){let r=v(e[t].response.headers);if(void 0!==r)return r}}(T));let o={...n,...c.timeouts},m={data:j,headers:b,method:i.method,url:g(s,i.path,$),connectTimeout:r(R,o.connect),responseTimeout:r(R,h?o.read:o.write)},y=t=>{let r={request:m,response:t,host:s,triesLeft:e.length};return T.push(r),r},P=await l.send(m);if(S(P)&&U>0){U--,e.push(s);let t=y(P),o=E(P.headers);return a.info("Retryable failure",{...z(t),wait:o,rateLimitRetriesLeft:U}),await x(o),D(e,r)}if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0===~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(P)){let o=y(P);return P.isTimedOut&&R++,a.info("Retryable failure",z(o)),await t.set(s,u(s,P.isTimedOut?"timed out":"down")),D(e,r)}if(function({status:e}){return 2==~~(e/100)}(P))return P;throw y(P),function(e,t){let{content:r,status:a}=e,s=v(e.headers);try{let e=JSON.parse(r);return"error"in e?new f(e.message,a,e.error,t,s):new p(e.message,a,t,"ApiError",s)}catch{}return new p(r,a,t,"ApiError",s)}(P,k(T))},L=e.filter(e=>"readWrite"===e.accept||(h?"read"===e.accept:"write"===e.accept)),N=await C(L);return D([...N.hosts].reverse(),N.getTimeout)}return{hostsCache:t,requester:l,timeouts:n,logger:a,algoliaAgent:o,baseHeaders:r,baseQueryParameters:s,requestIdChannel:b,hosts:e,maxRateLimitRetries:H,request:function(e,t={}){let a=()=>j(e,t,o).then(e=>T(e)),o=e.useReadTransporter||"GET"===e.method;if(!0!==(t.cacheable||e.cacheable))return a();let n={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return h.get(n,()=>c.get(n,()=>c.set(n,a()).then(e=>Promise.all([c.delete(n),e]),e=>Promise.all([c.delete(n),Promise.reject(e)])).then(([e,t])=>t)),{miss:e=>h.set(n,e)})},requestWithHttpInfo:function(e,t={}){return j(e,t,e.useReadTransporter||"GET"===e.method).then(e=>function(e){return{status:e.status,headers:e.headers,content:e.content,data:T(e)}}(e))},requestStream:async function*(t,u={}){if(!l.sendStream)throw new Error("This requester does not support streaming");let c=y(t,u),h=P(r,t.headers,u.headers);h.accept="text/event-stream";let p="GET"===t.method?{...t.data,...u.data}:{},m={...s,...t.queryParameters,...p};if(o.value&&(m["x-algolia-agent"]=o.value),u&&u.queryParameters)for(let e of Object.keys(u.queryParameters))u.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(u.queryParameters[e])?m[e]=u.queryParameters[e].toString():m[e]=u.queryParameters[e];W(h,m);let f=t.useReadTransporter||"GET"===t.method,T=e.filter(e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept)),v=(await C(T)).hosts[0];if(!v)throw new d([]);let q={...n,...u.timeouts},w={data:c,headers:h,method:t.method,url:g(v,t.path,m),connectTimeout:q.connect,responseTimeout:f?q.read:q.write},S=H;for(;;){let e;try{e=await l.sendStream(w)}catch(e){if(I(e)&&S>0){S--;let t=E(O(e));a.info("Retryable failure",{wait:t,rateLimitRetriesLeft:S,host:v}),await x(t);continue}throw e}return void(yield*i(e))}},requestsCache:c,responsesCache:h}}function W(e,t,r){if(null==r||"string"==typeof r&&0===r.length)throw new Error(`Parameter \`${e}\` is required when calling \`${t}\`.`)}function x(e){let t={};for(let r of e.trim().split(/[\r\n]+/)){let e=r.indexOf(": ");e>0&&(t[r.slice(0,e).toLowerCase()]=r.slice(e+2))}return t}var C="5.64.0",j=["eu","us"];function A(e){return[{url:"personalization.{region}.algolia.com".replace("{region}",e),accept:"readWrite",protocol:"https"}]}e.apiClientVersion=C,e.personalizationClient=function(e,o,n,i){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!o||"string"!=typeof o)throw new Error("`apiKey` is missing.");if(!n||n&&("string"!=typeof n||!j.includes(n)))throw new Error(`\`region\` is required and must be one of the following: ${j.join(", ")}`);let{compression:l,...u}=i||{};return function({appId:e,apiKey:t,authMode:r,algoliaAgents:a,region:o,...n}){let i=function(e,t,r="WithinHeaders"){let a={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?a:{},queryParameters:()=>"WithinQueryParameters"===r?a:{}}}(e,t,r),l=H({hosts:A(o),...n,algoliaAgent:s({algoliaAgents:a,client:"Personalization",version:C}),baseHeaders:{"content-type":"text/plain",...i.headers(),...n.baseHeaders},baseQueryParameters:{...i.queryParameters(),...n.baseQueryParameters}});return{transporter:l,appId:e,apiKey:t,clearCache:()=>Promise.all([l.requestsCache.clear(),l.responsesCache.clear()]).then(()=>{}),get _ua(){return l.algoliaAgent.value},addAlgoliaAgent(e,t){l.algoliaAgent.add({segment:e,version:t})},setClientApiKey({apiKey:e}){r&&"WithinHeaders"!==r?l.baseQueryParameters["x-algolia-api-key"]=e:l.baseHeaders["x-algolia-api-key"]=e},customDelete({path:e,parameters:t},r){W("path","customDelete",e);let a={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return l.request(a,r)},customDeleteWithHTTPInfo({path:e,parameters:t},r){W("path","customDeleteWithHTTPInfo",e);let a={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return l.requestWithHttpInfo(a,r)},customGet({path:e,parameters:t},r){W("path","customGet",e);let a={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return l.request(a,r)},customGetWithHTTPInfo({path:e,parameters:t},r){W("path","customGetWithHTTPInfo",e);let a={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return l.requestWithHttpInfo(a,r)},customPost({path:e,parameters:t,body:r},a){W("path","customPost",e);let s={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return l.request(s,a)},customPostWithHTTPInfo({path:e,parameters:t,body:r},a){W("path","customPostWithHTTPInfo",e);let s={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return l.requestWithHttpInfo(s,a)},customPut({path:e,parameters:t,body:r},a){W("path","customPut",e);let s={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return l.request(s,a)},customPutWithHTTPInfo({path:e,parameters:t,body:r},a){W("path","customPutWithHTTPInfo",e);let s={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return l.requestWithHttpInfo(s,a)},deleteUserProfile({userToken:e},t){W("userToken","deleteUserProfile",e);let r={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return l.request(r,t)},deleteUserProfileWithHTTPInfo({userToken:e},t){W("userToken","deleteUserProfileWithHTTPInfo",e);let r={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return l.requestWithHttpInfo(r,t)},getPersonalizationStrategy:e=>l.request({method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}},e),getPersonalizationStrategyWithHTTPInfo:e=>l.requestWithHttpInfo({method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}},e),getUserTokenProfile({userToken:e},t){W("userToken","getUserTokenProfile",e);let r={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return l.request(r,t)},getUserTokenProfileWithHTTPInfo({userToken:e},t){W("userToken","getUserTokenProfileWithHTTPInfo",e);let r={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return l.requestWithHttpInfo(r,t)},setPersonalizationStrategy(e,t){W("personalizationStrategyParams","setPersonalizationStrategy",e),W("personalizationStrategyParams.eventsScoring","setPersonalizationStrategy",e.eventsScoring),W("personalizationStrategyParams.facetsScoring","setPersonalizationStrategy",e.facetsScoring),W("personalizationStrategyParams.personalizationImpact","setPersonalizationStrategy",e.personalizationImpact);let r={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:e};return l.request(r,t)},setPersonalizationStrategyWithHTTPInfo(e,t){W("personalizationStrategyParams","setPersonalizationStrategyWithHTTPInfo",e),W("personalizationStrategyParams.eventsScoring","setPersonalizationStrategyWithHTTPInfo",e.eventsScoring),W("personalizationStrategyParams.facetsScoring","setPersonalizationStrategyWithHTTPInfo",e.facetsScoring),W("personalizationStrategyParams.personalizationImpact","setPersonalizationStrategyWithHTTPInfo",e.personalizationImpact);let r={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:e};return l.requestWithHttpInfo(r,t)}}}({appId:e,apiKey:o,region:n,timeouts:{connect:1e3,read:2e3,write:3e4},logger:{debug:(e,t)=>Promise.resolve(),info:(e,t)=>Promise.resolve(),error:(e,t)=>Promise.resolve()},requester:{send:function(e){return new Promise(t=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(t=>r.setRequestHeader(t,e.headers[t]));let a,s=(e,a)=>setTimeout(()=>{r.abort(),t({status:0,content:a,isTimedOut:!0})},e),o=s(e.connectTimeout,"Connection timeout");r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===a&&(clearTimeout(o),a=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(o),clearTimeout(a),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(o),clearTimeout(a),t({content:r.responseText,headers:x(r.getAllResponseHeaders()),status:r.status,isTimedOut:!1})},r.send(e.data)})}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:a(),requestsCache:a({serializable:!1}),hostsCache:r({caches:[t({key:`${C}-${e}`}),a()]}),...u})}});
//# sourceMappingURL=/sm/e994afcfdeea7555f5123d3e1b48f4a75958c7a1184020d521217307629fadf4.map