2 lines
19 KiB
JavaScript
2 lines
19 KiB
JavaScript
|
|
function U(o){let t,d=`algolia-client-js-${o.key}`;function a(){return t===void 0&&(t=o.localStorage||window.localStorage),t}function h(){return JSON.parse(a().getItem(d)||"{}")}function R(f){a().setItem(d,JSON.stringify(f))}function y(){let f=o.timeToLive?o.timeToLive*1e3:null,e=h(),s=Object.fromEntries(Object.entries(e).filter(([,i])=>i.timestamp!==void 0));if(R(s),!f)return;let n=Object.fromEntries(Object.entries(s).filter(([,i])=>{let l=new Date().getTime();return!(i.timestamp+f<l)}));R(n)}return{get(f,e,s={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(y(),h()[JSON.stringify(f)])).then(n=>Promise.all([n?n.value:e(),n!==void 0])).then(([n,i])=>Promise.all([n,i||s.miss(n)])).then(([n])=>n)},set(f,e){return Promise.resolve().then(()=>{let s=h();return s[JSON.stringify(f)]={timestamp:new Date().getTime(),value:e},a().setItem(d,JSON.stringify(s)),e})},delete(f){return Promise.resolve().then(()=>{let e=h();delete e[JSON.stringify(f)],a().setItem(d,JSON.stringify(e))})},clear(){return Promise.resolve().then(()=>{a().removeItem(d)})}}}function V(){return{get(o,t,d={miss:()=>Promise.resolve()}){return t().then(h=>Promise.all([h,d.miss(h)])).then(([h])=>h)},set(o,t){return Promise.resolve(t)},delete(o){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(o){let t=[...o.caches],d=t.shift();return d===void 0?V():{get(a,h,R={miss:()=>Promise.resolve()}){return d.get(a,h,R).catch(()=>E({caches:t}).get(a,h,R))},set(a,h){return d.set(a,h).catch(()=>E({caches:t}).set(a,h))},delete(a){return d.delete(a).catch(()=>E({caches:t}).delete(a))},clear(){return d.clear().catch(()=>E({caches:t}).clear())}}}function x(o={serializable:!0}){let t={};return{get(d,a,h={miss:()=>Promise.resolve()}){let R=JSON.stringify(d);if(R in t)return Promise.resolve(o.serializable?JSON.parse(t[R]):t[R]);let y=a();return y.then(f=>h.miss(f)).then(()=>y)},set(d,a){return t[JSON.stringify(d)]=o.serializable?JSON.stringify(a):a,Promise.resolve(a)},delete(d){return delete t[JSON.stringify(d)],Promise.resolve()},clear(){return t={},Promise.resolve()}}}function Y(o){let t={value:`Algolia for JavaScript (${o})`,add(d){let a=`; ${d.segment}${d.version!==void 0?` (${d.version})`:""}`;return t.value.indexOf(a)===-1&&(t.value=`${t.value}${a}`),t}};return t}function L(o,t,d="WithinHeaders"){let a={"x-algolia-api-key":t,"x-algolia-application-id":o};return{headers(){return d==="WithinHeaders"?a:{}},queryParameters(){return d==="WithinQueryParameters"?a:{}}}}function $({algoliaAgents:o,client:t,version:d}){let a=Y(d).add({segment:t,version:d});return o.forEach(h=>a.add(h)),a}function j(){return{debug(o,t){return Promise.resolve()},info(o,t){return Promise.resolve()},error(o,t){return Promise.resolve()}}}var Q=120*1e3;function _(o,t="up"){let d=Date.now();function a(){return t==="up"||Date.now()-d>Q}function h(){return t==="timed out"&&Date.now()-d<=Q}return{...o,status:t,lastUpdate:d,isUp:a,isTimedOut:h}}var W=class extends Error{name="AlgoliaError";constructor(o,t){super(o),t&&(this.name=t)}};var J=class extends W{stackTrace;constructor(o,t,d){super(o,d),this.stackTrace=t}},Z=class extends J{constructor(o){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",o,"RetryError")}},k=class extends J{status;constructor(o,t,d,a="ApiError"){super(o,d,a),this.status=t}},ee=class extends W{response;constructor(o,t){super(o,"DeserializationError"),this.response=t}},te=class extends k{error;constructor(o,t,d,a){super(o,t,a,"DetailedApiError"),this.error=d}};function re(o,t,d){let a=oe(d),h=`${o.protocol}://${o.url}${o.port?`:${o.port}`:""}/${t.charAt(0)==="/"?t.substring(1):t}`;return a.length&&(h+=`?${a}`),h}function oe(o){return Object.keys(o).filter(t=>o[t]!==void 0).sort().map(t=>`${t}=${encodeURIComponent(Object.prototype.toString.call(o[t])==="[object Array]"?o[t].join(","):o[t]).replace(/\+/g,"%20")}`).join("&")}function se(o,t){if(o.method==="GET"||o.data===void 0&&t.data===
|
||
|
|
//# sourceMappingURL=browser.min.js.map
|