function me(e){const t=`algoliasearch-client-js-${e.key}`;let r;const n=()=>(r===void 0&&(r=e.localStorage||window.localStorage),r),s=()=>JSON.parse(n().getItem(t)||"{}"),a=i=>{n().setItem(t,JSON.stringify(i))},o=()=>{const i=e.timeToLive?e.timeToLive*1e3:null,d=s(),m=Object.fromEntries(Object.entries(d).filter(([,u])=>u.timestamp!==void 0));if(a(m),!i)return;const h=Object.fromEntries(Object.entries(m).filter(([,u])=>{const f=new Date().getTime();return!(u.timestamp+iPromise.resolve()}){return Promise.resolve().then(()=>{o();const h=JSON.stringify(i);return s()[h]}).then(h=>Promise.all([h?h.value:d(),h!==void 0])).then(([h,u])=>Promise.all([h,u||m.miss(h)])).then(([h])=>h)},set(i,d){return Promise.resolve().then(()=>{const m=s();return m[JSON.stringify(i)]={timestamp:new Date().getTime(),value:d},n().setItem(t,JSON.stringify(m)),d})},delete(i){return Promise.resolve().then(()=>{const d=s();delete d[JSON.stringify(i)],n().setItem(t,JSON.stringify(d))})},clear(){return Promise.resolve().then(()=>{n().removeItem(t)})}}}function R(e){const t=[...e.caches],r=t.shift();return r===void 0?pe():{get(n,s,a={miss:()=>Promise.resolve()}){return r.get(n,s,a).catch(()=>R({caches:t}).get(n,s,a))},set(n,s){return r.set(n,s).catch(()=>R({caches:t}).set(n,s))},delete(n){return r.delete(n).catch(()=>R({caches:t}).delete(n))},clear(){return r.clear().catch(()=>R({caches:t}).clear())}}}function pe(){return{get(e,t,r={miss:()=>Promise.resolve()}){return t().then(s=>Promise.all([s,r.miss(s)])).then(([s])=>s)},set(e,t){return Promise.resolve(t)},delete(e){return Promise.resolve()},clear(){return Promise.resolve()}}}function $(e={serializable:!0}){let t={};return{get(r,n,s={miss:()=>Promise.resolve()}){const a=JSON.stringify(r);if(a in t)return Promise.resolve(e.serializable?JSON.parse(t[a]):t[a]);const o=n(),i=s&&s.miss||(()=>Promise.resolve());return o.then(d=>i(d)).then(()=>o)},set(r,n){return t[JSON.stringify(r)]=e.serializable?JSON.stringify(n):n,Promise.resolve(n)},delete(r){return delete t[JSON.stringify(r)],Promise.resolve()},clear(){return t={},Promise.resolve()}}}function C(e,t,r){const n={"x-algolia-api-key":r,"x-algolia-application-id":t};return{headers(){return e===k.WithinHeaders?n:{}},queryParameters(){return e===k.WithinQueryParameters?n:{}}}}function q(e){let t=0;const r=()=>(t++,new Promise(n=>{setTimeout(()=>{n(e(r))},Math.min(100*t,1e3))}));return e(r)}function p(e,t=(r,n)=>Promise.resolve()){return Object.assign(e,{wait(r){return p(e.then(n=>Promise.all([t(n,r),n])).then(n=>n[1]))}})}function ge(e){let t=e.length-1;for(t;t>0;t--){const r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}function U(e,t){return t&&Object.keys(t).forEach(r=>{e[r]=t[r](e)}),e}function l(e,...t){let r=0;return e.replace(/%s/g,()=>encodeURIComponent(t[r++]))}const H="4.25.3",k={WithinQueryParameters:0,WithinHeaders:1};function b(e,t){const r=e||{},n=r.data||{};return Object.keys(r).forEach(s=>{["timeout","headers","queryParameters","data","cacheable"].indexOf(s)===-1&&(n[s]=r[s])}),{data:Object.entries(n).length>0?n:void 0,timeout:r.timeout||t,headers:r.headers||{},queryParameters:r.queryParameters||{},cacheable:r.cacheable}}const S={Read:1,Write:2,Any:3},N={Up:1,Down:2,Timeouted:3},Y=120*1e3;function Z(e,t=N.Up){return{...e,status:t,lastUpdate:Date.now()}}function fe(e){return e.status===N.Up||Date.now()-e.lastUpdate>Y}function ye(e){return e.status===N.Timeouted&&Date.now()-e.lastUpdate<=y}function ee(e){return typeof e=="string"?{protocol:"https",url:e,accept:S.Any}:{protocol:e.protocol||"https",url:e.url,accept:e.accept||S.Any}}const c={Delete:"DELETE",Get:"GET",Post:"POST",Put:"PUT"};function Pe(e,t){return Promise.all(t.map(r=>e.get(r,()=>Promise.resolve(Z(r))))).then(r=>{const n=r.filter(i=>fe(i)),s=r.filter(i=>ye(i)),a=[...n,...s],o=a.length>0?a.map(i=>ee(i)):t;return{getTimeout(i,d){return(s.length===0&&i===0?1:s.length+3+i)*d},statelessHosts:o}})}const we=({isTimedOut:e,status:t})=>!e&&~~t===0,Ie=e=>{const t=e.status;return e.isTimedOut||we(e)||~~(t/100)!==2&&~~(t/100)!==4},be=({status:e})=>~~(e/100)===2,Oe=(e,t)=>Ie(e)?t.onRetry(e):be(e)?t.onSuccess(e):t.onFail(e);function Q(e,t,r,n){const s=[],a=Se(r,n),o=ke(e,n),i=r.method,d=r.method!==c.Get?{}:{...r.data,...n.data},m={"x-algolia-agent":e.userAgent.value,...e.queryParameters,...d,...n.queryParameters};let h=0;const u=(f,w)=>{const g=f.pop();if(g===void 0)throw Re(K(s));const I={data:a,headers:o,method:i,url:Te(g,r.path,m),connectTimeout:w(h,e.timeouts.connect),responseTimeout:w(h,n.timeout)},D=y=>{const T={request:I,response:y,host:g,triesLeft:f.length};return s.push(T),T},O={onSuccess:y=>De(y),onRetry(y){const T=D(y);return y.isTimedOut&&h++,Promise.all([e.logger.info("Retryable failure",re(T)),e.hostsCache.set(g,Z(g,y.isTimedOut?N.Timeouted:N.Down))]).then(()=>u(f,w))},onFail(y){throw D(y),je(y,K(s))}};return e.requester.send(I).then(y=>Oe(y,O))};return Pe(e.hostsCache,t).then(f=>u([...f.statelessHosts].reverse(),f.getTimeout))}function G(e){const{hostsCache:t,logger:r,requester:n,requestsCache:s,responsesCache:a,timeouts:o,userAgent:i,hosts:d,queryParameters:m,headers:h}=e,u={hostsCache:t,logger:r,requester:n,requestsCache:s,responsesCache:a,timeouts:o,userAgent:i,headers:h,queryParameters:m,hosts:d.map(f=>ee(f)),read(f,w){const g=b(w,u.timeouts.read),I=()=>Q(u,u.hosts.filter(y=>(y.accept&S.Read)!==0),f,g);if((g.cacheable!==void 0?g.cacheable:f.cacheable)!==!0)return I();const O={request:f,mappedRequestOptions:g,transporter:{queryParameters:u.queryParameters,headers:u.headers}};return u.responsesCache.get(O,()=>u.requestsCache.get(O,()=>u.requestsCache.set(O,I()).then(y=>Promise.all([u.requestsCache.delete(O),y]),y=>Promise.all([u.requestsCache.delete(O),Promise.reject(y)])).then(([y,T])=>T)),{miss:y=>u.responsesCache.set(O,y)})},write(f,w){return Q(u,u.hosts.filter(g=>(g.accept&S.Write)!==0),f,b(w,u.timeouts.write))}};return u}function xe(e){const t={value:`Algolia for JavaScript (${e})`,add(r){const n=`; ${r.segment}${r.version!==void 0?` (${r.version})`:""}`;return t.value.indexOf(n)===-1&&(t.value=`${t.value}${n}`),t}};return t}function De(e){try{return JSON.parse(e.content)}catch(t){throw Ae(t.message,e)}}function je({content:e,status:t},r){let n=e;try{n=JSON.parse(e).message}catch{}return qe(n,t,r)}function Te(e,t,r){const n=te(r);let s=`${e.protocol}://${e.url}/${t.charAt(0)==="/"?t.substr(1):t}`;return n.length&&(s+=`?${n}`),s}function te(e){const t=r=>Object.prototype.toString.call(r)==="[object Object]"||Object.prototype.toString.call(r)==="[object Array]";return Object.keys(e).map(r=>l("%s=%s",r,t(e[r])?JSON.stringify(e[r]):e[r])).join("&")}function Se(e,t){if(e.method===c.Get||e.data===void 0&&t.data===void 0)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}function ke(e,t){const r={...e.headers,...t.headers},n={};return Object.keys(r).forEach(s=>{const a=r[s];n[s.toLowerCase()]=a}),n}function K(e){return e.map(t=>re(t))}function re(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function qe(e,t,r){return{name:"ApiError",message:e,status:t,transporterStackTrace:r}}function Ae(e,t){return{name:"DeserializationError",message:e,response:t}}function Re(e){return{name:"RetryError",message:"Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support .",transporterStackTrace:e}}const Ne=e=>{const t=e.region||"us",r=C(k.WithinHeaders,e.appId,e.apiKey),n=G({hosts:[{url:`analytics.${t}.algolia.com`}],...e,headers:{...r.headers(),"content-type":"application/json",...e.headers},queryParameters:{...r.queryParameters(),...e.queryParameters}}),s=e.appId;return U({appId:s,transporter:n},e.methods)},Ee=e=>(t,r)=>e.transporter.write({method:c.Post,path:"2/abtests",data:t},r),ve=e=>(t,r)=>e.transporter.write({method:c.Delete,path:l("2/abtests/%s",t)},r),Ce=e=>(t,r)=>e.transporter.read({method:c.Get,path:l("2/abtests/%s",t)},r),Ue=e=>t=>e.transporter.read({method:c.Get,path:"2/abtests"},t),Ge=e=>(t,r)=>e.transporter.write({method:c.Post,path:l("2/abtests/%s/stop",t)},r),We=e=>{const t=e.region||"us",r=C(k.WithinHeaders,e.appId,e.apiKey),n=G({hosts:[{url:`personalization.${t}.algolia.com`}],...e,headers:{...r.headers(),"content-type":"application/json",...e.headers},queryParameters:{...r.queryParameters(),...e.queryParameters}});return U({appId:e.appId,transporter:n},e.methods)},ze=e=>t=>e.transporter.read({method:c.Get,path:"1/strategies/personalization"},t),$e=e=>(t,r)=>e.transporter.write({method:c.Post,path:"1/strategies/personalization",data:t},r);function J(e){const t=r=>e.request(r).then(n=>{if(e.batch!==void 0&&e.batch(n.hits),!e.shouldStop(n))return n.cursor?t({cursor:n.cursor}):t({page:(r.page||0)+1})});return t({})}const He=e=>{const t=e.appId,r=C(e.authMode!==void 0?e.authMode:k.WithinHeaders,t,e.apiKey),n=G({hosts:[{url:`${t}-dsn.algolia.net`,accept:S.Read},{url:`${t}.algolia.net`,accept:S.Write}].concat(ge([{url:`${t}-1.algolianet.com`},{url:`${t}-2.algolianet.com`},{url:`${t}-3.algolianet.com`}])),...e,headers:{...r.headers(),"content-type":"application/x-www-form-urlencoded",...e.headers},queryParameters:{...r.queryParameters(),...e.queryParameters}});return U({transporter:n,appId:t,addAlgoliaAgent(a,o){n.userAgent.add({segment:a,version:o})},clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})}},e.methods)};function Je(){return{name:"MissingObjectIDError",message:"All objects must have an unique objectID (like a primary key) to be valid. Algolia is also able to generate objectIDs automatically but *it's not recommended*. To do it, use the `{'autoGenerateObjectIDIfNotExist': true}` option."}}function Me(){return{name:"ObjectNotFoundError",message:"Object not found."}}const Be=e=>(t,r)=>{const{queryParameters:n,...s}=r||{},a={acl:t,...n!==void 0?{queryParameters:n}:{}},o=(i,d)=>q(m=>E(e)(i.key,d).catch(h=>{if(h.status!==404)throw h;return m()}));return p(e.transporter.write({method:c.Post,path:"1/keys",data:a},s),o)},_e=e=>(t,r,n)=>{const s=b(n);return s.queryParameters["X-Algolia-User-ID"]=t,e.transporter.write({method:c.Post,path:"1/clusters/mapping",data:{cluster:r}},s)},Fe=e=>(t,r,n)=>e.transporter.write({method:c.Post,path:"1/clusters/mapping/batch",data:{users:t,cluster:r}},n),Le=e=>(t,r)=>p(e.transporter.write({method:c.Post,path:l("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!0,requests:{action:"addEntry",body:[]}}},r),(n,s)=>A(e)(n.taskID,s)),W=e=>(t,r,n)=>{const s=(a,o)=>v(e)(t,{methods:{waitTask:P}}).waitTask(a.taskID,o);return p(e.transporter.write({method:c.Post,path:l("1/indexes/%s/operation",t),data:{operation:"copy",destination:r}},n),s)},Qe=e=>(t,r,n)=>W(e)(t,r,{...n,scope:[L.Rules]}),Ke=e=>(t,r,n)=>W(e)(t,r,{...n,scope:[L.Settings]}),Xe=e=>(t,r,n)=>W(e)(t,r,{...n,scope:[L.Synonyms]}),Ve=e=>(t,r)=>t.method===c.Get?e.transporter.read(t,r):e.transporter.write(t,r),Ye=e=>(t,r)=>{const n=(s,a)=>q(o=>E(e)(t,a).then(o).catch(i=>{if(i.status!==404)throw i}));return p(e.transporter.write({method:c.Delete,path:l("1/keys/%s",t)},r),n)},Ze=e=>(t,r,n)=>{const s=r.map(a=>({action:"deleteEntry",body:{objectID:a}}));return p(e.transporter.write({method:c.Post,path:l("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!1,requests:s}},n),(a,o)=>A(e)(a.taskID,o))},E=e=>(t,r)=>e.transporter.read({method:c.Get,path:l("1/keys/%s",t)},r),ne=e=>(t,r)=>e.transporter.read({method:c.Get,path:l("1/task/%s",t.toString())},r),et=e=>t=>e.transporter.read({method:c.Get,path:"/1/dictionaries/*/settings"},t),tt=e=>t=>e.transporter.read({method:c.Get,path:"1/logs"},t),rt=e=>t=>e.transporter.read({method:c.Get,path:"1/clusters/mapping/top"},t),nt=e=>(t,r)=>e.transporter.read({method:c.Get,path:l("1/clusters/mapping/%s",t)},r),st=e=>t=>{const{retrieveMappings:r,...n}=t||{};return r===!0&&(n.getClusters=!0),e.transporter.read({method:c.Get,path:"1/clusters/mapping/pending"},n)},v=e=>(t,r={})=>{const n={transporter:e.transporter,appId:e.appId,indexName:t};return U(n,r.methods)},at=e=>t=>e.transporter.read({method:c.Get,path:"1/keys"},t),ot=e=>t=>e.transporter.read({method:c.Get,path:"1/clusters"},t),it=e=>t=>e.transporter.read({method:c.Get,path:"1/indexes"},t),ct=e=>t=>e.transporter.read({method:c.Get,path:"1/clusters/mapping"},t),ut=e=>(t,r,n)=>{const s=(a,o)=>v(e)(t,{methods:{waitTask:P}}).waitTask(a.taskID,o);return p(e.transporter.write({method:c.Post,path:l("1/indexes/%s/operation",t),data:{operation:"move",destination:r}},n),s)},dt=e=>(t,r)=>{const n=(s,a)=>Promise.all(Object.keys(s.taskID).map(o=>v(e)(o,{methods:{waitTask:P}}).waitTask(s.taskID[o],a)));return p(e.transporter.write({method:c.Post,path:"1/indexes/*/batch",data:{requests:t}},r),n)},lt=e=>(t,r)=>e.transporter.read({method:c.Post,path:"1/indexes/*/objects",data:{requests:t}},r),X=e=>(t,r)=>{const n=t.map(s=>({...s,params:te(s.params||{})}));return e.transporter.read({method:c.Post,path:"1/indexes/*/queries",data:{requests:n},cacheable:!0},r)},V=e=>(t,r)=>Promise.all(t.map(n=>{const{facetName:s,facetQuery:a,...o}=n.params;return v(e)(n.indexName,{methods:{searchForFacetValues:de}}).searchForFacetValues(s,a,{...r,...o})})),ht=e=>(t,r)=>{const n=b(r);return n.queryParameters["X-Algolia-User-ID"]=t,e.transporter.write({method:c.Delete,path:"1/clusters/mapping"},n)},mt=e=>(t,r,n)=>{const s=r.map(a=>({action:"addEntry",body:a}));return p(e.transporter.write({method:c.Post,path:l("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!0,requests:s}},n),(a,o)=>A(e)(a.taskID,o))},pt=e=>(t,r)=>{const n=(s,a)=>q(o=>E(e)(t,a).catch(i=>{if(i.status!==404)throw i;return o()}));return p(e.transporter.write({method:c.Post,path:l("1/keys/%s/restore",t)},r),n)},gt=e=>(t,r,n)=>{const s=r.map(a=>({action:"addEntry",body:a}));return p(e.transporter.write({method:c.Post,path:l("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!1,requests:s}},n),(a,o)=>A(e)(a.taskID,o))},ft=e=>(t,r,n)=>e.transporter.read({method:c.Post,path:l("/1/dictionaries/%s/search",t),data:{query:r},cacheable:!0},n),yt=e=>(t,r)=>e.transporter.read({method:c.Post,path:"1/clusters/mapping/search",data:{query:t}},r),Pt=e=>(t,r)=>p(e.transporter.write({method:c.Put,path:"/1/dictionaries/*/settings",data:t},r),(n,s)=>A(e)(n.taskID,s)),wt=e=>(t,r)=>{const n=Object.assign({},r),{queryParameters:s,...a}=r||{},o=s?{queryParameters:s}:{},i=["acl","indexes","referers","restrictSources","queryParameters","description","maxQueriesPerIPPerHour","maxHitsPerQuery"],d=h=>Object.keys(n).filter(u=>i.indexOf(u)!==-1).every(u=>{if(Array.isArray(h[u])&&Array.isArray(n[u])){const f=h[u];return f.length===n[u].length&&f.every((w,g)=>w===n[u][g])}else return h[u]===n[u]}),m=(h,u)=>q(f=>E(e)(t,u).then(w=>d(w)?Promise.resolve():f()));return p(e.transporter.write({method:c.Put,path:l("1/keys/%s",t),data:o},a),m)},A=e=>(t,r)=>q(n=>ne(e)(t,r).then(s=>s.status!=="published"?n():void 0)),se=e=>(t,r)=>{const n=(s,a)=>P(e)(s.taskID,a);return p(e.transporter.write({method:c.Post,path:l("1/indexes/%s/batch",e.indexName),data:{requests:t}},r),n)},It=e=>t=>J({shouldStop:r=>r.cursor===void 0,...t,request:r=>e.transporter.read({method:c.Post,path:l("1/indexes/%s/browse",e.indexName),data:r},t)}),bt=e=>t=>{const r={hitsPerPage:1e3,...t};return J({shouldStop:n=>n.hits.length({...s,hits:s.hits.map(a=>(delete a._highlightResult,a))}))}})},Ot=e=>t=>{const r={hitsPerPage:1e3,...t};return J({shouldStop:n=>n.hits.length({...s,hits:s.hits.map(a=>(delete a._highlightResult,a))}))}})},M=e=>(t,r,n)=>{const{batchSize:s,...a}=n||{},o={taskIDs:[],objectIDs:[]},i=(d=0)=>{const m=[];let h;for(h=d;h({action:r,body:u})),a).then(u=>(o.objectIDs=o.objectIDs.concat(u.objectIDs),o.taskIDs.push(u.taskID),h++,i(h)))};return p(i(),(d,m)=>Promise.all(d.taskIDs.map(h=>P(e)(h,m))))},xt=e=>t=>p(e.transporter.write({method:c.Post,path:l("1/indexes/%s/clear",e.indexName)},t),(r,n)=>P(e)(r.taskID,n)),Dt=e=>t=>{const{forwardToReplicas:r,...n}=t||{},s=b(n);return r&&(s.queryParameters.forwardToReplicas=1),p(e.transporter.write({method:c.Post,path:l("1/indexes/%s/rules/clear",e.indexName)},s),(a,o)=>P(e)(a.taskID,o))},jt=e=>t=>{const{forwardToReplicas:r,...n}=t||{},s=b(n);return r&&(s.queryParameters.forwardToReplicas=1),p(e.transporter.write({method:c.Post,path:l("1/indexes/%s/synonyms/clear",e.indexName)},s),(a,o)=>P(e)(a.taskID,o))},Tt=e=>(t,r)=>p(e.transporter.write({method:c.Post,path:l("1/indexes/%s/deleteByQuery",e.indexName),data:t},r),(n,s)=>P(e)(n.taskID,s)),ae=e=>t=>p(e.transporter.write({method:c.Delete,path:l("1/indexes/%s",e.indexName)},t),(r,n)=>P(e)(r.taskID,n)),St=e=>(t,r)=>p(oe(e)([t],r).then(n=>({taskID:n.taskIDs[0]})),(n,s)=>P(e)(n.taskID,s)),oe=e=>(t,r)=>{const n=t.map(s=>({objectID:s}));return M(e)(n,x.DeleteObject,r)},kt=e=>(t,r)=>{const{forwardToReplicas:n,...s}=r||{},a=b(s);return n&&(a.queryParameters.forwardToReplicas=1),p(e.transporter.write({method:c.Delete,path:l("1/indexes/%s/rules/%s",e.indexName,t)},a),(o,i)=>P(e)(o.taskID,i))},qt=e=>(t,r)=>{const{forwardToReplicas:n,...s}=r||{},a=b(s);return n&&(a.queryParameters.forwardToReplicas=1),p(e.transporter.write({method:c.Delete,path:l("1/indexes/%s/synonyms/%s",e.indexName,t)},a),(o,i)=>P(e)(o.taskID,i))},At=e=>t=>ie(e)(t).then(()=>!0).catch(r=>{if(r.status!==404)throw r;return!1}),Rt=e=>(t,r,n)=>e.transporter.read({method:c.Post,path:l("1/answers/%s/prediction",e.indexName),data:{query:t,queryLanguages:r},cacheable:!0},n),Nt=e=>(t,r)=>{const{query:n,paginate:s,...a}=r||{};let o=0;const i=()=>ue(e)(n||"",{...a,page:o}).then(d=>{for(const[m,h]of Object.entries(d.hits))if(t(h))return{object:h,position:parseInt(m,10),page:o};if(o++,s===!1||o>=d.nbPages)throw Me();return i()});return i()},Et=e=>(t,r)=>e.transporter.read({method:c.Get,path:l("1/indexes/%s/%s",e.indexName,t)},r),vt=()=>(e,t)=>{for(const[r,n]of Object.entries(e.hits))if(n.objectID===t)return parseInt(r,10);return-1},Ct=e=>(t,r)=>{const{attributesToRetrieve:n,...s}=r||{},a=t.map(o=>({indexName:e.indexName,objectID:o,...n?{attributesToRetrieve:n}:{}}));return e.transporter.read({method:c.Post,path:"1/indexes/*/objects",data:{requests:a}},s)},Ut=e=>(t,r)=>e.transporter.read({method:c.Get,path:l("1/indexes/%s/rules/%s",e.indexName,t)},r),ie=e=>t=>e.transporter.read({method:c.Get,path:l("1/indexes/%s/settings",e.indexName),data:{getVersion:2}},t),Gt=e=>(t,r)=>e.transporter.read({method:c.Get,path:l("1/indexes/%s/synonyms/%s",e.indexName,t)},r),Wt=e=>(t,r)=>e.transporter.read({method:c.Get,path:l("1/indexes/%s/task/%s",e.indexName,t.toString())},r),zt=e=>(t,r)=>p(ce(e)([t],r).then(n=>({objectID:n.objectIDs[0],taskID:n.taskIDs[0]})),(n,s)=>P(e)(n.taskID,s)),ce=e=>(t,r)=>{const{createIfNotExists:n,...s}=r||{},a=n?x.PartialUpdateObject:x.PartialUpdateObjectNoCreate;return M(e)(t,a,s)},$t=e=>(t,r)=>{const{safe:n,autoGenerateObjectIDIfNotExist:s,batchSize:a,...o}=r||{},i=(g,I,D,O)=>p(e.transporter.write({method:c.Post,path:l("1/indexes/%s/operation",g),data:{operation:D,destination:I}},O),(y,T)=>P(e)(y.taskID,T)),d=Math.random().toString(36).substring(7),m=`${e.indexName}_tmp_${d}`,h=B({appId:e.appId,transporter:e.transporter,indexName:m});let u=[];const f=i(e.indexName,m,"copy",{...o,scope:["settings","synonyms","rules"]});u.push(f);const w=(n?f.wait(o):f).then(()=>{const g=h(t,{...o,autoGenerateObjectIDIfNotExist:s,batchSize:a});return u.push(g),n?g.wait(o):g}).then(()=>{const g=i(m,e.indexName,"move",o);return u.push(g),n?g.wait(o):g}).then(()=>Promise.all(u)).then(([g,I,D])=>({objectIDs:I.objectIDs,taskIDs:[g.taskID,...I.taskIDs,D.taskID]})).catch(g=>ae({appId:e.appId,transporter:e.transporter,indexName:m})().catch(()=>{}).then(()=>{throw g}));return p(w,(g,I)=>Promise.all(u.map(D=>D.wait(I))))},Ht=e=>(t,r)=>_(e)(t,{...r,clearExistingRules:!0}),Jt=e=>(t,r)=>F(e)(t,{...r,clearExistingSynonyms:!0}),Mt=e=>(t,r)=>p(B(e)([t],r).then(n=>({objectID:n.objectIDs[0],taskID:n.taskIDs[0]})),(n,s)=>P(e)(n.taskID,s)),B=e=>(t,r)=>{const{autoGenerateObjectIDIfNotExist:n,...s}=r||{},a=n?x.AddObject:x.UpdateObject;if(a===x.UpdateObject){for(const o of t)if(o.objectID===void 0)return p(Promise.reject(Je()))}return M(e)(t,a,s)},Bt=e=>(t,r)=>_(e)([t],r),_=e=>(t,r)=>{const{forwardToReplicas:n,clearExistingRules:s,...a}=r||{},o=b(a);return n&&(o.queryParameters.forwardToReplicas=1),s&&(o.queryParameters.clearExistingRules=1),p(e.transporter.write({method:c.Post,path:l("1/indexes/%s/rules/batch",e.indexName),data:t},o),(i,d)=>P(e)(i.taskID,d))},_t=e=>(t,r)=>F(e)([t],r),F=e=>(t,r)=>{const{forwardToReplicas:n,clearExistingSynonyms:s,replaceExistingSynonyms:a,...o}=r||{},i=b(o);return n&&(i.queryParameters.forwardToReplicas=1),(a||s)&&(i.queryParameters.replaceExistingSynonyms=1),p(e.transporter.write({method:c.Post,path:l("1/indexes/%s/synonyms/batch",e.indexName),data:t},i),(d,m)=>P(e)(d.taskID,m))},ue=e=>(t,r)=>e.transporter.read({method:c.Post,path:l("1/indexes/%s/query",e.indexName),data:{query:t},cacheable:!0},r),de=e=>(t,r,n)=>e.transporter.read({method:c.Post,path:l("1/indexes/%s/facets/%s/query",e.indexName,t),data:{facetQuery:r},cacheable:!0},n),le=e=>(t,r)=>e.transporter.read({method:c.Post,path:l("1/indexes/%s/rules/search",e.indexName),data:{query:t}},r),he=e=>(t,r)=>e.transporter.read({method:c.Post,path:l("1/indexes/%s/synonyms/search",e.indexName),data:{query:t}},r),Ft=e=>(t,r)=>{const{forwardToReplicas:n,...s}=r||{},a=b(s);return n&&(a.queryParameters.forwardToReplicas=1),p(e.transporter.write({method:c.Put,path:l("1/indexes/%s/settings",e.indexName),data:t},a),(o,i)=>P(e)(o.taskID,i))},P=e=>(t,r)=>q(n=>Wt(e)(t,r).then(s=>s.status!=="published"?n():void 0)),x={AddObject:"addObject",UpdateObject:"updateObject",PartialUpdateObject:"partialUpdateObject",PartialUpdateObjectNoCreate:"partialUpdateObjectNoCreate",DeleteObject:"deleteObject"},L={Settings:"settings",Synonyms:"synonyms",Rules:"rules"};function Lt(e){return{debug(t,r){return Promise.resolve()},info(t,r){return Promise.resolve()},error(t,r){return console.error(t,r),Promise.resolve()}}}const z=e=>(t,r)=>{const n=t.map(s=>({...s,threshold:s.threshold||0}));return e.transporter.read({method:c.Post,path:"1/indexes/*/recommendations",data:{requests:n},cacheable:!0},r)},Qt=e=>(t,r)=>z(e)(t.map(n=>({...n,fallbackParameters:{},model:"bought-together"})),r),Kt=e=>(t,r)=>z(e)(t.map(n=>({...n,model:"related-products"})),r),Xt=e=>(t,r)=>{const n=t.map(s=>({...s,model:"trending-facets",threshold:s.threshold||0}));return e.transporter.read({method:c.Post,path:"1/indexes/*/recommendations",data:{requests:n},cacheable:!0},r)},Vt=e=>(t,r)=>{const n=t.map(s=>({...s,model:"trending-items",threshold:s.threshold||0}));return e.transporter.read({method:c.Post,path:"1/indexes/*/recommendations",data:{requests:n},cacheable:!0},r)},Yt=e=>(t,r)=>z(e)(t.map(n=>({...n,model:"looking-similar"})),r),Zt=e=>(t,r)=>{const n=t.map(s=>({...s,model:"recommended-for-you",threshold:s.threshold||0}));return e.transporter.read({method:c.Post,path:"1/indexes/*/recommendations",data:{requests:n},cacheable:!0},r)};function er(){return{send(e){return new Promise(t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(o=>r.setRequestHeader(o,e.headers[o]));const n=(o,i)=>setTimeout(()=>{r.abort(),t({status:0,content:i,isTimedOut:!0})},o*1e3),s=n(e.connectTimeout,"Connection timeout");let a;r.onreadystatechange=()=>{r.readyState>r.OPENED&&a===void 0&&(clearTimeout(s),a=n(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(s),clearTimeout(a),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(s),clearTimeout(a),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}}}function tr(e){if(!e||!e.transformation||!e.transformation.region)throw j("`region` must be provided when leveraging the transformation pipeline");if(e.transformation.region!=="eu"&&e.transformation.region!=="us")throw j("`region` is required and must be one of the following: eu, us");const t=e.appId,r=C(k.WithinHeaders,t,e.apiKey),n=G({hosts:[{url:`data.${e.transformation.region}.algolia.com`,accept:S.ReadWrite,protocol:"https"}],...e,headers:{...r.headers(),"content-type":"text/plain",...e.headers},queryParameters:{...r.queryParameters(),...e.queryParameters}});return{transporter:n,appId:t,addAlgoliaAgent(s,a){n.userAgent.add({segment:s,version:a}),n.userAgent.add({segment:"Ingestion",version:a}),n.userAgent.add({segment:"Ingestion via Algoliasearch"})},clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},push({indexName:s,pushTaskPayload:a,watch:o},i){if(!s)throw j("Parameter `indexName` is required when calling `push`.");if(!a)throw j("Parameter `pushTaskPayload` is required when calling `push`.");if(!a.action)throw j("Parameter `pushTaskPayload.action` is required when calling `push`.");if(!a.records)throw j("Parameter `pushTaskPayload.records` is required when calling `push`.");const d=i||{queryParameters:{}};return n.write({method:c.Post,path:l("1/push/%s",s),data:a},{...d,queryParameters:{...d.queryParameters,watch:o!==void 0}})}}}function rr(e,t){return(r,n)=>{if(!t)throw j("`options.transformation.region` must be provided at client instantiation before calling this method.");const{autoGenerateObjectIDIfNotExist:s,watch:a,...o}=n||{},i=s?x.AddObject:x.UpdateObject;return t.push({indexName:e,pushTaskPayload:{action:i,records:r},watch:a},o)}}function nr(e,t){return(r,n)=>{if(!t)throw j("`options.transformation.region` must be provided at client instantiation before calling this method.");const{createIfNotExists:s,watch:a,...o}=n||{},i=s?x.PartialUpdateObject:x.PartialUpdateObjectNoCreate;return t.push({indexName:e,pushTaskPayload:{action:i,records:r},watch:a},o)}}function j(e){return{name:"TransformationConfigurationError",message:e}}function sr(e,t,r){const n={appId:e,apiKey:t,timeouts:{connect:1,read:2,write:30},requester:er(),logger:Lt(),responsesCache:$(),requestsCache:$({serializable:!1}),hostsCache:R({caches:[me({key:`${H}-${e}`}),$()]}),userAgent:xe(H).add({segment:"Browser"})},s={...n,...r},a=()=>i=>We({...n,...i,methods:{getPersonalizationStrategy:ze,setPersonalizationStrategy:$e}});let o;if(r&&r.transformation){if(!r.transformation.region)throw j("`region` must be provided when leveraging the transformation pipeline");o=tr({...r,...n})}return He({...s,methods:{search:X,searchForFacetValues:V,multipleBatch:dt,multipleGetObjects:lt,multipleQueries:X,copyIndex:W,copySettings:Ke,copySynonyms:Xe,copyRules:Qe,moveIndex:ut,listIndices:it,getLogs:tt,listClusters:ot,multipleSearchForFacetValues:V,getApiKey:E,addApiKey:Be,listApiKeys:at,updateApiKey:wt,deleteApiKey:Ye,restoreApiKey:pt,assignUserID:_e,assignUserIDs:Fe,getUserID:nt,searchUserIDs:yt,listUserIDs:ct,getTopUserIDs:rt,removeUserID:ht,hasPendingMappings:st,clearDictionaryEntries:Le,deleteDictionaryEntries:Ze,getDictionarySettings:et,getAppTask:ne,replaceDictionaryEntries:mt,saveDictionaryEntries:gt,searchDictionaryEntries:ft,setDictionarySettings:Pt,waitAppTask:A,customRequest:Ve,initIndex:i=>d=>({...v(i)(d,{methods:{batch:se,delete:ae,findAnswers:Rt,getObject:Et,getObjects:Ct,saveObject:Mt,saveObjects:B,search:ue,searchForFacetValues:de,waitTask:P,setSettings:Ft,getSettings:ie,partialUpdateObject:zt,partialUpdateObjects:ce,deleteObject:St,deleteObjects:oe,deleteBy:Tt,clearObjects:xt,browseObjects:It,getObjectPosition:vt,findObject:Nt,exists:At,saveSynonym:_t,saveSynonyms:F,getSynonym:Gt,searchSynonyms:he,browseSynonyms:Ot,deleteSynonym:qt,clearSynonyms:jt,replaceAllObjects:$t,replaceAllSynonyms:Jt,searchRules:le,getRule:Ut,deleteRule:kt,saveRule:Bt,saveRules:_,replaceAllRules:Ht,browseRules:bt,clearRules:Dt}}),saveObjectsWithTransformation:rr(d,o),partialUpdateObjectsWithTransformation:nr(d,o)}),initAnalytics:()=>i=>Ne({...n,...i,methods:{addABTest:Ee,getABTest:Ce,getABTests:Ue,stopABTest:Ge,deleteABTest:ve}}),initPersonalization:a,initRecommendation:()=>i=>(s.logger.info("The `initRecommendation` method is deprecated. Use `initPersonalization` instead."),a()(i)),getRecommendations:z,getFrequentlyBoughtTogether:Qt,getLookingSimilar:Yt,getRecommendedForYou:Zt,getRelatedProducts:Kt,getTrendingFacets:Xt,getTrendingItems:Vt}})}sr.version=H;export{sr as default};

AltStyle によって変換されたページ (->オリジナル) /